hexsha
stringlengths 40
40
| size
int64 7
1.05M
| ext
stringclasses 13
values | lang
stringclasses 1
value | max_stars_repo_path
stringlengths 4
269
| max_stars_repo_name
stringlengths 5
109
| max_stars_repo_head_hexsha
stringlengths 40
40
| max_stars_repo_licenses
sequencelengths 1
9
| max_stars_count
int64 1
191k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 4
269
| max_issues_repo_name
stringlengths 5
116
| max_issues_repo_head_hexsha
stringlengths 40
40
| max_issues_repo_licenses
sequencelengths 1
9
| max_issues_count
int64 1
48.5k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 4
269
| max_forks_repo_name
stringlengths 5
116
| max_forks_repo_head_hexsha
stringlengths 40
40
| max_forks_repo_licenses
sequencelengths 1
9
| max_forks_count
int64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | content
stringlengths 7
1.05M
| avg_line_length
float64 1.21
330k
| max_line_length
int64 6
990k
| alphanum_fraction
float64 0.01
0.99
| author_id
stringlengths 2
40
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
5081c7d33af9647d83b7b6a0905c91a566c1685a | 856 | cpp | C++ | codeforces/587div3/B.cpp | xenowits/cp | 963b3c7df65b5328d5ce5ef894a46691afefb98c | [
"MIT"
] | null | null | null | codeforces/587div3/B.cpp | xenowits/cp | 963b3c7df65b5328d5ce5ef894a46691afefb98c | [
"MIT"
] | null | null | null | codeforces/587div3/B.cpp | xenowits/cp | 963b3c7df65b5328d5ce5ef894a46691afefb98c | [
"MIT"
] | null | null | null | #include<bits/stdc++.h>
using namespace std;
#define fori(i,a,b) for (long int i = a; i <= b ; ++i)
#define ford(i,a,b) for(long int i = a;i >= b ; --i)
#define mk make_pair
#define mod 1000000007
#define pb push_back
#define vec vector<long long int>
#define ll long long
#define rnd mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count())
#define pi pair<long long int,long long int>
#define sc second
#define fs first
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,temp;
cin >> n;
vector<pi> v;
fori(i,1,n)
{
cin >> temp;
v.pb(mk(temp,i));
}
sort(v.begin(), v.end());
reverse(v.begin(), v.end());
ll ans = 0, hell = 0;
fori(i,0,n-1)
{
ans += (v[i].fs*hell);
hell += 1;
}
cout << ans+n << endl;
fori(i,0,n-1)
cout << v[i].sc << " ";
return 0;
}
| 17.12 | 91 | 0.593458 | xenowits |
5088bd07be39f03921292ee9a9af76c4f3883ed7 | 1,067 | cpp | C++ | competitive programming/leetcode/905. Sort Array By Parity.cpp | kashyap99saksham/Code | 96658d0920eb79c007701d2a3cc9dbf453d78f96 | [
"MIT"
] | 16 | 2020-06-02T19:22:45.000Z | 2022-02-05T10:35:28.000Z | competitive programming/leetcode/905. Sort Array By Parity.cpp | codezoned/Code | de91ffc7ef06812a31464fb40358e2436734574c | [
"MIT"
] | null | null | null | competitive programming/leetcode/905. Sort Array By Parity.cpp | codezoned/Code | de91ffc7ef06812a31464fb40358e2436734574c | [
"MIT"
] | 2 | 2020-08-27T17:40:06.000Z | 2022-02-05T10:33:52.000Z | Given an array A of non-negative integers, return an array consisting of all the even elements of A, followed by all the odd elements of A.
You may return any answer array that satisfies this condition.
Example 1:
Input: [3,1,2,4]
Output: [2,4,3,1]
The outputs [4,2,3,1], [2,4,1,3], and [4,2,1,3] would also be accepted.
Note:
1 <= A.length <= 5000
0 <= A[i] <= 5000
// Without extra space
class Solution {
public:
vector<int> sortArrayByParity(vector<int>& A) {
int n=A.size();
int j=0;
for(int i=0;i<n;i++){
if(A[i]%2==0){
swap(A[i], A[j]);
j++;
}
}
return A;
}
};
// Extra space
class Solution {
public:
vector<int> sortArrayByParity(vector<int>& A) {
int n=A.size();
vector<int> res(n);
int start=0, last=n-1;
for(int i=0;i<n;i++){
if(A[i]%2==0){
res[start++]=A[i];
} else {
res[last--]=A[i];
}
}
return res;
}
};
| 16.936508 | 139 | 0.492971 | kashyap99saksham |
5089af9edf6629885ea3f89dd4f8105bc13337a7 | 1,585 | hpp | C++ | infra/util/Allocator.hpp | oguzcanphilips/embeddedinfralib | f1b083d61a34d123d34ab7cd51267377aa2f7855 | [
"Unlicense"
] | 54 | 2019-04-02T14:42:54.000Z | 2022-03-20T23:02:19.000Z | infra/util/Allocator.hpp | oguzcanphilips/embeddedinfralib | f1b083d61a34d123d34ab7cd51267377aa2f7855 | [
"Unlicense"
] | 32 | 2019-03-26T06:57:29.000Z | 2022-03-25T00:04:44.000Z | infra/util/Allocator.hpp | oguzcanphilips/embeddedinfralib | f1b083d61a34d123d34ab7cd51267377aa2f7855 | [
"Unlicense"
] | 20 | 2019-03-25T15:49:49.000Z | 2022-03-20T23:02:22.000Z | #ifndef INFRA_ALLOCATOR_HPP
#define INFRA_ALLOCATOR_HPP
#include <memory>
namespace infra
{
class AllocatorBase
{
protected:
AllocatorBase() = default;
AllocatorBase(const AllocatorBase& other) = delete;
AllocatorBase& operator=(const AllocatorBase& other) = delete;
~AllocatorBase() = default;
public:
virtual void Deallocate(void* object) = 0;
};
class Deallocator
{
public:
Deallocator() = default;
explicit Deallocator(AllocatorBase& allocator);
void operator()(void* object);
private:
AllocatorBase* allocator = nullptr;
};
template<class T>
using UniquePtr = std::unique_ptr<T, Deallocator>;
template<class T>
UniquePtr<T> MakeUnique(T* object, AllocatorBase& allocator);
template<class T, class ConstructionArgs>
class Allocator;
template<class T, class... ConstructionArgs>
class Allocator<T, void(ConstructionArgs...)>
: public AllocatorBase
{
public:
virtual UniquePtr<T> Allocate(ConstructionArgs... args) = 0;
protected:
~Allocator() = default;
};
//// Implementation ////
inline Deallocator::Deallocator(AllocatorBase& allocator)
: allocator(&allocator)
{}
inline void Deallocator::operator()(void* object)
{
allocator->Deallocate(object);
}
template<class T>
UniquePtr<T> MakeUnique(T* object, AllocatorBase& allocator)
{
return infra::UniquePtr<T>(object, Deallocator(allocator));
}
}
#endif
| 22.323944 | 70 | 0.634069 | oguzcanphilips |
509162b1e05af53522a2ceacc5e9f25212b7add7 | 1,862 | hpp | C++ | Simple++/MemoryAllocation.hpp | Oriode/Simpleplusplus | 2ba44eeab5078d6dab66bdefdf73617696b8cb2e | [
"Apache-2.0"
] | null | null | null | Simple++/MemoryAllocation.hpp | Oriode/Simpleplusplus | 2ba44eeab5078d6dab66bdefdf73617696b8cb2e | [
"Apache-2.0"
] | null | null | null | Simple++/MemoryAllocation.hpp | Oriode/Simpleplusplus | 2ba44eeab5078d6dab66bdefdf73617696b8cb2e | [
"Apache-2.0"
] | null | null | null |
MemoryAllocation::MemoryAllocation( void ) {
}
MemoryAllocation::MemoryAllocation( unsigned long memoryAddress, unsigned long memorySize, const StringASCII & allocationFileName, unsigned int lineNumber ) {
this -> memoryAddress = memoryAddress;
this -> memorySize = memorySize;
this -> allocationFileName = allocationFileName;
this -> allocationLineNumber = lineNumber;
this -> bAllocated = true;
}
MemoryAllocation::~MemoryAllocation( void ) {
}
void MemoryAllocation::setAllocationFileName( const StringASCII & fileName ) {
this -> allocationFileName = fileName;
}
void MemoryAllocation::setAllocationLineNumber( int lineNumber ) {
this -> allocationFileName = lineNumber;
}
void MemoryAllocation::setDeleteFileName( const StringASCII & fileName ) {
this -> deleteFileName = fileName;
}
void MemoryAllocation::setDeleteLineNumber( int lineNumber ) {
this -> deleteLineNumber = lineNumber;
}
void MemoryAllocation::setMemoryAddress( unsigned long long address ) {
this -> memoryAddress = address;
}
void MemoryAllocation::setMemorySize( unsigned long long size ) {
this -> memorySize = size;
}
const StringASCII & MemoryAllocation::getAllocationFileName() const {
return this -> allocationFileName;
}
int MemoryAllocation::getAllocationLineNumber() const {
return this -> allocationLineNumber;
}
const StringASCII & MemoryAllocation::getDeleteFileName() const {
return this -> deleteFileName;
}
int MemoryAllocation::getDeleteLineNumber() const {
return this -> deleteLineNumber;
}
unsigned long long MemoryAllocation::getMemoryAddress() const {
return this -> memoryAddress;
}
unsigned long long MemoryAllocation::getMemorySize() const {
return this -> memorySize;
}
bool MemoryAllocation::isAllocated() const {
return this -> bAllocated;
}
void MemoryAllocation::setAllocated( bool value ) {
this -> bAllocated = value;
}
| 25.861111 | 158 | 0.767991 | Oriode |
5092c1c3cc00fc3ec505ba5fe0f40c04f6f003dd | 1,891 | hpp | C++ | lab_4/matrixline_methods.hpp | DrStarland/bmstu_AA_2020 | acbb0c76d5763c06db0230025423e0fbb4382a9f | [
"Apache-2.0"
] | null | null | null | lab_4/matrixline_methods.hpp | DrStarland/bmstu_AA_2020 | acbb0c76d5763c06db0230025423e0fbb4382a9f | [
"Apache-2.0"
] | null | null | null | lab_4/matrixline_methods.hpp | DrStarland/bmstu_AA_2020 | acbb0c76d5763c06db0230025423e0fbb4382a9f | [
"Apache-2.0"
] | null | null | null | #ifndef MATRIXLINE_METHODS_HPP
#define MATRIXLINE_METHODS_HPP
#include "matrix.h"
template <typename T>
Matrix<T>::MatrixLine::MatrixLine(size_t len) : MatrixLine(len, nullptr) {}
template <typename T>
Matrix<T>::MatrixLine::MatrixLine(MatrixLine &©) { this->_move(std::move(copy)); }
template <typename T>
Matrix<T>::MatrixLine::MatrixLine(const MatrixLine ©) : MatrixLine(copy.m_len, ©) {}
template <typename T>
Matrix<T>::MatrixLine::MatrixLine(size_t n, const MatrixLine* source) {
this->m_len = n, this->alloc_ptr();
if (source != nullptr)
for (size_t i = 0; i < this->m_len; i++)
this->m_ptr[i] = source->m_ptr[i];
}
template <typename T>
void Matrix<T>::MatrixLine::alloc_ptr() {
T* temp = new (std::nothrow) T[m_len];
time_t _time = time(NULL);
if (!temp)
throw MemoryException(__FILE__, typeid(*this).name(), __LINE__, ctime(&_time));
m_ptr = shared_ptr<T[]> (temp);
}
template <typename T>
typename Matrix<T>::MatrixLine& Matrix<T>::MatrixLine::operator=(MatrixLine&& copy) {
this->_move(std::move(copy));
return *this;
}
template <typename T>
T& Matrix<T>::MatrixLine::operator[](size_t ind) {
time_t _time = time(NULL);
if (this->m_len <= ind)
throw IndexException(__FILE__, typeid(*this).name(), __LINE__, ctime(&_time));
return this->m_ptr[ind];
}
template <typename T>
const T& Matrix<T>::MatrixLine::operator[](size_t ind) const {
time_t _time = time(NULL);
if (this->m_len <= ind)
throw IndexException(__FILE__, typeid(*this).name(), __LINE__, ctime(&_time));
return this->m_ptr[ind];
}
template <typename T>
void Matrix<T>::MatrixLine::_move(MatrixLine &©) {
this->m_len = copy.m_len, this->m_ptr = copy.m_ptr;
copy.m_ptr = nullptr, copy.m_len = 0;
}
#endif // MATRIXLINE_METHODS_HPP
| 32.603448 | 93 | 0.649392 | DrStarland |
50a14eb15659a1a668e106113a140777c86b501d | 5,979 | cpp | C++ | test/android/jni.cpp | 10110111/GLFFT | 78176d4480bc3675327bf2bcfd80d5dae1820081 | [
"MIT"
] | 176 | 2015-08-17T20:47:10.000Z | 2022-03-30T09:14:33.000Z | test/android/jni.cpp | 10110111/GLFFT | 78176d4480bc3675327bf2bcfd80d5dae1820081 | [
"MIT"
] | 6 | 2017-09-21T15:55:44.000Z | 2020-11-07T03:15:44.000Z | test/android/jni.cpp | 10110111/GLFFT | 78176d4480bc3675327bf2bcfd80d5dae1820081 | [
"MIT"
] | 28 | 2016-02-28T04:37:50.000Z | 2022-02-27T12:35:55.000Z | /* Copyright (C) 2015 Hans-Kristian Arntzen <[email protected]>
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "glfft_gl_interface.hpp"
#include "glfft_context.hpp"
#include "glfft_cli.hpp"
#include <GLES2/gl2ext.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include "net_themaister_glfft_Native.h"
#include <memory>
#include <vector>
using namespace GLFFT;
using namespace std;
struct AndroidEGLContext : GLContext
{
EGLContext ctx = EGL_NO_CONTEXT;
EGLSurface surf = EGL_NO_SURFACE;
EGLDisplay dpy = EGL_NO_SURFACE;
EGLConfig conf = 0;
~AndroidEGLContext()
{
if (dpy)
{
teardown();
eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (ctx)
eglDestroyContext(dpy, ctx);
if (surf)
eglDestroySurface(dpy, surf);
eglTerminate(dpy);
}
}
};
unique_ptr<Context> GLFFT::create_cli_context()
{
unique_ptr<AndroidEGLContext> egl(new AndroidEGLContext);
static const EGLint attr[] = {
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
EGL_RED_SIZE, 1,
EGL_GREEN_SIZE, 1,
EGL_BLUE_SIZE, 1,
EGL_ALPHA_SIZE, 0,
EGL_DEPTH_SIZE, 0,
EGL_STENCIL_SIZE, 0,
EGL_NONE,
};
static const EGLint context_attr[] = {
EGL_CONTEXT_CLIENT_VERSION, 3,
EGL_NONE,
};
static const EGLint surface_attr[] = {
EGL_WIDTH, 64,
EGL_HEIGHT, 64,
EGL_NONE,
};
egl->dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (egl->dpy == EGL_NO_DISPLAY)
{
egl->log("Failed to create display.\n");
return nullptr;
}
eglInitialize(egl->dpy, nullptr, nullptr);
EGLint num_configs = 0;
eglChooseConfig(egl->dpy, attr, &egl->conf, 1, &num_configs);
if (num_configs != 1)
{
egl->log("Failed to get EGL config.\n");
return nullptr;
}
egl->ctx = eglCreateContext(egl->dpy, egl->conf, EGL_NO_CONTEXT, context_attr);
if (egl->ctx == EGL_NO_CONTEXT)
{
egl->log("Failed to create GLES context.\n");
return nullptr;
}
egl->surf = eglCreatePbufferSurface(egl->dpy, egl->conf, surface_attr);
if (egl->surf == EGL_NO_SURFACE)
{
egl->log("Failed to create Pbuffer surface.\n");
return nullptr;
}
if (!eglMakeCurrent(egl->dpy, egl->surf, egl->surf, egl->ctx))
{
egl->log("Failed to make EGL context current.\n");
return nullptr;
}
const char *version = reinterpret_cast<const char*>(glGetString(GL_VERSION));
unsigned major = 0, minor = 0;
sscanf(version, "OpenGL ES %u.%u", &major, &minor);
unsigned ctx_version = major * 1000 + minor;
if (ctx_version < 3001)
{
egl->log("OpenGL ES 3.1 not supported (got %u.%u context).\n",
major, minor);
return nullptr;
}
egl->log("Version: %s\n", version);
return unique_ptr<Context>(move(egl));
}
void glfft_log(const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
__android_log_vprint(ANDROID_LOG_INFO, "GLFFT", fmt, va);
va_end(va);
#ifdef GLFFT_CLI_ASYNC
char buffer[16 * 1024];
va_start(va, fmt);
vsnprintf(buffer, sizeof(buffer), fmt, va);
GLFFT::get_async_task()->push_message(buffer);
#endif
}
static int start_task(const vector<const char*> &argv)
{
GLFFT::set_async_task([argv] {
return GLFFT::cli_main(
GLFFT::get_async_context(),
argv.size() - 1, (char**)argv.data());
});
GLFFT::get_async_task()->start();
return 0;
}
JNIEXPORT jint JNICALL Java_net_themaister_glfft_Native_beginRunTestSuiteTask(JNIEnv *, jclass)
{
vector<const char*> argv = {
"glfft_cli",
"test",
"--test-all",
nullptr,
};
return start_task(argv);
}
JNIEXPORT jint JNICALL Java_net_themaister_glfft_Native_beginBenchTask
(JNIEnv *, jclass)
{
vector<const char*> argv = {
"glfft_cli",
"bench",
"--width",
"2048",
"--height",
"2048",
"--fp16",
nullptr,
};
return start_task(argv);
}
JNIEXPORT jstring JNICALL Java_net_themaister_glfft_Native_pull
(JNIEnv *env, jclass)
{
string str;
auto *task = GLFFT::get_async_task();
bool ret = task->pull(str);
return ret ? env->NewStringUTF(str.c_str()) : nullptr;
}
JNIEXPORT jint JNICALL Java_net_themaister_glfft_Native_getExitCode
(JNIEnv *, jclass)
{
auto *task = GLFFT::get_async_task();
return task->get_exit_code();
}
JNIEXPORT jint JNICALL Java_net_themaister_glfft_Native_isComplete
(JNIEnv *, jclass)
{
auto *task = GLFFT::get_async_task();
return task->is_completed();
}
JNIEXPORT void JNICALL Java_net_themaister_glfft_Native_endTask
(JNIEnv *, jclass)
{
GLFFT::end_async_task();
}
| 26.811659 | 129 | 0.646596 | 10110111 |
50a3fa8ab19998e82f47f1c1c383e3b87fac989a | 1,752 | hpp | C++ | src/ScreenServer.hpp | RobinSinghNanda/Home-assistant-display | 6f59104012c0956b54d4b55e190aa89941c2c1af | [
"MIT"
] | 2 | 2020-10-23T19:53:56.000Z | 2020-11-06T08:59:48.000Z | src/ScreenServer.hpp | RobinSinghNanda/Home-assistant-display | 6f59104012c0956b54d4b55e190aa89941c2c1af | [
"MIT"
] | null | null | null | src/ScreenServer.hpp | RobinSinghNanda/Home-assistant-display | 6f59104012c0956b54d4b55e190aa89941c2c1af | [
"MIT"
] | null | null | null | #ifndef __SCREENSERVER_H__
#define __SCREENSERVER_H__
#include "Arduino.h"
#include "TFT_eSPI.h"
//====================================================================================
// Definitions
//====================================================================================
#define PIXEL_TIMEOUT 100 // 100ms Time-out between pixel requests
#define START_TIMEOUT 10000 // 10s Maximum time to wait at start transfer
#define BITS_PER_PIXEL 16 // 24 for RGB colour format, 16 for 565 colour format
// File names must be alpha-numeric characters (0-9, a-z, A-Z) or "/" underscore "_"
// other ascii characters are stripped out by client, including / generates
// sub-directories
#define DEFAULT_FILENAME "tft_screenshots/screenshot" // In case none is specified
#define FILE_TYPE "png" // jpg, bmp, png, tif are valid
// Filename extension
// '#' = add incrementing number, '@' = add timestamp, '%' add millis() timestamp,
// '*' = add nothing
// '@' and '%' will generate new unique filenames, so beware of cluttering up your
// hard drive with lots of images! The PC client sketch is set to limit the number of
// saved images to 1000 and will then prompt for a restart.
#define FILE_EXT '@'
// Number of pixels to send in a burst (minimum of 1), no benefit above 8
// NPIXELS values and render times:
// NPIXELS 1 = use readPixel() = >5s and 16 bit pixels only
// NPIXELS >1 using rectRead() 2 = 1.75s, 4 = 1.68s, 8 = 1.67s
#define NPIXELS 8 // Must be integer division of both TFT width and TFT height
bool screenServer(void);
bool screenServer(String filename);
bool serialScreenServer(String filename);
void sendParameters(String filename);
#endif // __SCREENSERVER_H__ | 42.731707 | 86 | 0.639269 | RobinSinghNanda |
50a62b87724180c6555f2d0fdc10c3b01f22255d | 2,388 | cpp | C++ | dia/ParserEditorUndoCommand.cpp | BKEngine/Creator | 5cc08fb828866cfa970951a14e41c38ecd471a8d | [
"CNRI-Python"
] | 25 | 2016-11-20T15:33:09.000Z | 2022-02-22T09:35:20.000Z | dia/ParserEditorUndoCommand.cpp | BKEngine/Creator | 5cc08fb828866cfa970951a14e41c38ecd471a8d | [
"CNRI-Python"
] | 3 | 2017-05-25T23:19:44.000Z | 2019-07-10T02:18:58.000Z | dia/ParserEditorUndoCommand.cpp | BKEngine/Creator | 5cc08fb828866cfa970951a14e41c38ecd471a8d | [
"CNRI-Python"
] | 8 | 2016-12-23T22:40:04.000Z | 2021-08-09T04:43:11.000Z | #include "ParserEditorUndoCommand.h"
#include "ParserEditorTreeModel.h"
#include "ParserEditorTreeItem.h"
InsertRowsCommand::InsertRowsCommand(ParserEditorTreeModel *model, int row, int count, const QModelIndex &parent)
: model(model)
, row(row)
, count(count)
, parent(parent)
{
}
void InsertRowsCommand::undo()
{
model->removeRowsInternal(row, count, parent);
}
void InsertRowsCommand::redo()
{
model->insertRowsInternal(row, count, parent);
}
RemoveRowsCommand::RemoveRowsCommand(ParserEditorTreeModel *model, int row, int count, const QModelIndex &parent)
: model(model)
, row(row)
, count(count)
, parent(parent)
{
items = model->itemsForRows(row, count, parent);
for (auto &&item : items)
{
item = item->duplicate();
}
}
RemoveRowsCommand::~RemoveRowsCommand()
{
qDeleteAll(items);
}
void RemoveRowsCommand::undo()
{
QList<ParserEditorTreeItem *> items;
for (auto item : this->items)
{
items << item->duplicate();
}
model->insertDataInternal(row, items, parent);
}
void RemoveRowsCommand::redo()
{
model->removeRowsInternal(row, count, parent);
}
InsertDataCommand::InsertDataCommand(ParserEditorTreeModel * model, int row, const QList<ParserEditorTreeItem*>& items, const QModelIndex & parent)
: model(model)
, row(row)
, items(items)
, parent(parent)
{
}
InsertDataCommand::~InsertDataCommand()
{
qDeleteAll(items);
}
void InsertDataCommand::undo()
{
model->removeRowsInternal(row, items.count(), parent);
}
void InsertDataCommand::redo()
{
QList<ParserEditorTreeItem *> items;
for (auto item : this->items)
{
items << item->duplicate();
}
model->insertDataInternal(row, items, parent);
}
ModifyDataCommand::ModifyDataCommand(ParserEditorTreeModel *model, const QModelIndex &index, const QVariant &data)
: model(model)
, index(index)
, data(data)
{
oldData = model->data(index, Qt::DisplayRole);
}
void ModifyDataCommand::undo()
{
model->setDataInternal(index, oldData);
}
void ModifyDataCommand::redo()
{
model->setDataInternal(index, data);
}
ChangeTypeCommand::ChangeTypeCommand(ParserEditorTreeModel *model, const QModelIndex &index, const QVariant &data)
: model(model)
, index(index)
, data(data)
{
item = model->item(index)->duplicate();
}
ChangeTypeCommand::~ChangeTypeCommand()
{
delete item;
}
void ChangeTypeCommand::undo()
{
}
void ChangeTypeCommand::redo()
{
model->setDataInternal(index, data);
}
| 19.258065 | 147 | 0.730318 | BKEngine |
27084f8412eae86805d019686bfd70a04db14971 | 6,627 | hpp | C++ | dof-mgr/src/Panzer_IntrepidFieldPattern.hpp | hillyuan/Panzer | 13ece3ea4c145c4d7b6339e3ad6332a501932ea8 | [
"BSD-3-Clause"
] | 1 | 2022-03-22T03:49:50.000Z | 2022-03-22T03:49:50.000Z | dof-mgr/src/Panzer_IntrepidFieldPattern.hpp | hillyuan/Panzer | 13ece3ea4c145c4d7b6339e3ad6332a501932ea8 | [
"BSD-3-Clause"
] | null | null | null | dof-mgr/src/Panzer_IntrepidFieldPattern.hpp | hillyuan/Panzer | 13ece3ea4c145c4d7b6339e3ad6332a501932ea8 | [
"BSD-3-Clause"
] | null | null | null | // @HEADER
// ***********************************************************************
//
// Panzer: A partial differential equation assembly
// engine for strongly coupled complex multiphysics systems
// Copyright (2011) Sandia Corporation
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "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 SANDIA CORPORATION 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.
//
// Questions? Contact Roger P. Pawlowski ([email protected]) and
// Eric C. Cyr ([email protected])
// ***********************************************************************
// @HEADER
#ifndef __Panzer_IntrepidFieldPattern_hpp__
#define __Panzer_IntrepidFieldPattern_hpp__
#include "Panzer_FieldPattern.hpp"
// Trilinos includes
#include "Kokkos_Core.hpp"
#include "Kokkos_DynRankView.hpp"
#include "Intrepid2_Basis.hpp"
#include "Phalanx_KokkosDeviceTypes.hpp"
#include "Teuchos_RCP.hpp"
#include <set>
namespace panzer {
/** This is a derived class that specializes based
* on a single intrepid basis function.
*/
class Intrepid2FieldPattern : public FieldPattern {
public:
Intrepid2FieldPattern(const Teuchos::RCP< Intrepid2::Basis<PHX::Device,double,double> > &intrepidBasis);
virtual int getSubcellCount(int dim) const;
virtual const std::vector<int> & getSubcellIndices(int dim, int cellIndex) const;
virtual int getDimension() const;
virtual shards::CellTopology getCellTopology() const;
virtual void getSubcellClosureIndices(int dim,int cellIndex,std::vector<int> & indices) const;
// static functions for examining shards objects
/** For a given sub cell find the set of sub cells at all dimensions contained
* internally. This is inclusive, so that (dim,subCell) will be in the set.
*
* \param[in] cellTopo Parent cell topology being used.
* \param[in] dim Dimension of sub cell
* \param[in] subCell Ordinal of sub cell at specified dimension
* \param[in,out] closure Set of sub cells associated with specified sub cell.
*
* \note Sub cell dimension and ordinals are inserted into <code>closure</code>.
* Previous information will not be removed.
*/
static void buildSubcellClosure(const shards::CellTopology & cellTopo,unsigned dim,unsigned subCell,
std::set<std::pair<unsigned,unsigned> > & closure);
/** Search a cell topology for sub cells containing a specfic set of nodes.
* This is a downward search (inclusive) from a user specified dimension.
*
* \param[in] cellTopo Parent cell topology being used.
* \param[in] dim Dimension of sub cell
* \param[in] nodes Nodes forming the super set
* \param[in,out] subCells Specific sub cells containing the nodes.
*
* \note Sub cell dimension and ordinals are inserted into <code>subCells</code>.
* Previous information will not be removed.
*/
static void findContainedSubcells(const shards::CellTopology & cellTopo,unsigned dim,
const std::vector<unsigned> & nodes,
std::set<std::pair<unsigned,unsigned> > & subCells);
/** Get the set of nodes making up the user specified sub cells.
*
* \param[in] cellTopo Parent cell topology being used.
* \param[in] dim Dimension of sub cell
* \param[in] subCell Ordinal of sub cell at specified dimension
* \param[in,out] nodes Nodes associated with sub cell.
*/
static void getSubcellNodes(const shards::CellTopology & cellTopo,unsigned dim,unsigned subCell,
std::vector<unsigned> & nodes);
/** \brief Does this field pattern support interpolatory coordinates?
*
* If this method returns true then <code>getInterpolatoryCoordinates</code> will
* succeed, otherwise it will throw.
*
* \returns True if this pattern supports interpolatory coordinates.
*/
bool supportsInterpolatoryCoordinates() const;
/** Get the local coordinates for this field. This is independent of element
* locations.
*
* \param[in,out] coords Coordinates associated with this field type.
*/
void getInterpolatoryCoordinates(Kokkos::DynRankView<double,PHX::Device> & coords) const;
/** Get the local coordinates for this field.
*
* \param[in] cellVertices Coordinates associated with this field type.
* \param[in,out] coords Coordinates associated with this field type.
*/
void getInterpolatoryCoordinates(const Kokkos::DynRankView<double,PHX::Device> & cellVertices,
Kokkos::DynRankView<double,PHX::Device> & coords) const;
/// Returns the underlying Intrepid2::Basis object
Teuchos::RCP< Intrepid2::Basis<PHX::Device,double,double> > getIntrepidBasis() const;
protected:
Teuchos::RCP< Intrepid2::Basis<PHX::Device,double,double> > intrepidBasis_;
//mutable std::vector<int> subcellIndices_;
mutable std::vector<std::vector<std::vector<int> > > subcellIndicies_;
std::vector<int> empty_;
};
}
#endif
| 43.598684 | 108 | 0.689 | hillyuan |
270aff09f7b49dba066873ece2b73065be1fbf58 | 13,021 | hpp | C++ | include/boost/gil/io/device.hpp | sdebionne/gil-reformated | 7065d600d7f84d9ef2ed4df9862c596ff7e8a8c2 | [
"BSL-1.0"
] | null | null | null | include/boost/gil/io/device.hpp | sdebionne/gil-reformated | 7065d600d7f84d9ef2ed4df9862c596ff7e8a8c2 | [
"BSL-1.0"
] | null | null | null | include/boost/gil/io/device.hpp | sdebionne/gil-reformated | 7065d600d7f84d9ef2ed4df9862c596ff7e8a8c2 | [
"BSL-1.0"
] | null | null | null | //
// Copyright 2007-2012 Christian Henning, Andreas Pokorny
//
// Distributed under the Boost Software License, Version 1.0
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
#ifndef BOOST_GIL_IO_DEVICE_HPP
#define BOOST_GIL_IO_DEVICE_HPP
#include <boost/gil/detail/mp11.hpp>
#include <boost/gil/io/base.hpp>
#include <cstdio>
#include <memory>
#include <type_traits>
namespace boost {
namespace gil {
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(push)
#pragma warning(disable : 4512) // assignment operator could not be generated
#endif
namespace detail {
template <typename T> struct buff_item {
static const unsigned int size = sizeof(T);
};
template <> struct buff_item<void> { static const unsigned int size = 1; };
/*!
* Implements the IODevice concept c.f. to \ref IODevice required by Image
* libraries like libjpeg and libpng.
*
* \todo switch to a sane interface as soon as there is
* something good in boost. I.E. the IOChains library
* would fit very well here.
*
* This implementation is based on FILE*.
*/
template <typename FormatTag> class file_stream_device {
public:
using format_tag_t = FormatTag;
public:
/// Used to overload the constructor.
struct read_tag {};
struct write_tag {};
///
/// Constructor
///
file_stream_device(const std::string &file_name, read_tag tag = read_tag())
: file_stream_device(file_name.c_str(), tag) {}
///
/// Constructor
///
file_stream_device(const char *file_name, read_tag = read_tag()) {
FILE *file = nullptr;
io_error_if((file = fopen(file_name, "rb")) == nullptr,
"file_stream_device: failed to open file for reading");
_file = file_ptr_t(file, file_deleter);
}
///
/// Constructor
///
file_stream_device(const std::string &file_name, write_tag tag)
: file_stream_device(file_name.c_str(), tag) {}
///
/// Constructor
///
file_stream_device(const char *file_name, write_tag) {
FILE *file = nullptr;
io_error_if((file = fopen(file_name, "wb")) == nullptr,
"file_stream_device: failed to open file for writing");
_file = file_ptr_t(file, file_deleter);
}
///
/// Constructor
///
file_stream_device(FILE *file) : _file(file, file_deleter) {}
FILE *get() { return _file.get(); }
const FILE *get() const { return _file.get(); }
int getc_unchecked() { return std::getc(get()); }
char getc() {
int ch;
io_error_if((ch = std::getc(get())) == EOF,
"file_stream_device: unexpected EOF");
return (char)ch;
}
///@todo: change byte_t* to void*
std::size_t read(byte_t *data, std::size_t count) {
std::size_t num_elements = fread(data, 1, static_cast<int>(count), get());
///@todo: add compiler symbol to turn error checking on and off.
io_error_if(ferror(get()), "file_stream_device: file read error");
// libjpeg sometimes reads blocks in 4096 bytes even when the file is
// smaller than that. return value indicates how much was actually read
// returning less than "count" is not an error
return num_elements;
}
/// Reads array
template <typename T, int N> void read(T (&buf)[N]) {
io_error_if(read(buf, N) < N, "file_stream_device: file read error");
}
/// Reads byte
uint8_t read_uint8() {
byte_t m[1];
read(m);
return m[0];
}
/// Reads 16 bit little endian integer
uint16_t read_uint16() {
byte_t m[2];
read(m);
return (m[1] << 8) | m[0];
}
/// Reads 32 bit little endian integer
uint32_t read_uint32() {
byte_t m[4];
read(m);
return (m[3] << 24) | (m[2] << 16) | (m[1] << 8) | m[0];
}
/// Writes number of elements from a buffer
template <typename T> std::size_t write(const T *buf, std::size_t count) {
std::size_t num_elements = fwrite(buf, buff_item<T>::size, count, get());
// return value indicates how much was actually written
// returning less than "count" is not an error
return num_elements;
}
/// Writes array
template <typename T, std::size_t N> void write(const T (&buf)[N]) {
io_error_if(write(buf, N) < N, "file_stream_device: file write error");
return;
}
/// Writes byte
void write_uint8(uint8_t x) {
byte_t m[1] = {x};
write(m);
}
/// Writes 16 bit little endian integer
void write_uint16(uint16_t x) {
byte_t m[2];
m[0] = byte_t(x >> 0);
m[1] = byte_t(x >> 8);
write(m);
}
/// Writes 32 bit little endian integer
void write_uint32(uint32_t x) {
byte_t m[4];
m[0] = byte_t(x >> 0);
m[1] = byte_t(x >> 8);
m[2] = byte_t(x >> 16);
m[3] = byte_t(x >> 24);
write(m);
}
void seek(long count, int whence = SEEK_SET) {
io_error_if(fseek(get(), count, whence) != 0,
"file_stream_device: file seek error");
}
long int tell() {
long int pos = ftell(get());
io_error_if(pos == -1L, "file_stream_device: file position error");
return pos;
}
void flush() { fflush(get()); }
/// Prints formatted ASCII text
void print_line(const std::string &line) {
std::size_t num_elements =
fwrite(line.c_str(), sizeof(char), line.size(), get());
io_error_if(num_elements < line.size(),
"file_stream_device: line print error");
}
int error() { return ferror(get()); }
private:
static void file_deleter(FILE *file) {
if (file) {
fclose(file);
}
}
private:
using file_ptr_t = std::shared_ptr<FILE>;
file_ptr_t _file;
};
/**
* Input stream device
*/
template <typename FormatTag> class istream_device {
public:
istream_device(std::istream &in) : _in(in) {
// does the file exists?
io_error_if(!in, "istream_device: Stream is not valid.");
}
int getc_unchecked() { return _in.get(); }
char getc() {
int ch;
io_error_if((ch = _in.get()) == EOF, "istream_device: unexpected EOF");
return (char)ch;
}
std::size_t read(byte_t *data, std::size_t count) {
std::streamsize cr = 0;
do {
_in.peek();
std::streamsize c = _in.readsome(reinterpret_cast<char *>(data),
static_cast<std::streamsize>(count));
count -= static_cast<std::size_t>(c);
data += c;
cr += c;
} while (count && _in);
return static_cast<std::size_t>(cr);
}
/// Reads array
template <typename T, int N> void read(T (&buf)[N]) { read(buf, N); }
/// Reads byte
uint8_t read_uint8() {
byte_t m[1];
read(m);
return m[0];
}
/// Reads 16 bit little endian integer
uint16_t read_uint16() {
byte_t m[2];
read(m);
return (m[1] << 8) | m[0];
}
/// Reads 32 bit little endian integer
uint32_t read_uint32() {
byte_t m[4];
read(m);
return (m[3] << 24) | (m[2] << 16) | (m[1] << 8) | m[0];
}
void seek(long count, int whence = SEEK_SET) {
_in.seekg(count, whence == SEEK_SET ? std::ios::beg
: (whence == SEEK_CUR ? std::ios::cur
: std::ios::end));
}
void write(const byte_t *, std::size_t) {
io_error("istream_device: Bad io error.");
}
void flush() {}
private:
std::istream &_in;
};
/**
* Output stream device
*/
template <typename FormatTag> class ostream_device {
public:
ostream_device(std::ostream &out) : _out(out) {}
std::size_t read(byte_t *, std::size_t) {
io_error("ostream_device: Bad io error.");
return 0;
}
void seek(long count, int whence) {
_out.seekp(count,
whence == SEEK_SET
? std::ios::beg
: (whence == SEEK_CUR ? std::ios::cur : std::ios::end));
}
void write(const byte_t *data, std::size_t count) {
_out.write(reinterpret_cast<char const *>(data),
static_cast<std::streamsize>(count));
}
/// Writes array
template <typename T, std::size_t N> void write(const T (&buf)[N]) {
write(buf, N);
}
/// Writes byte
void write_uint8(uint8_t x) {
byte_t m[1] = {x};
write(m);
}
/// Writes 16 bit little endian integer
void write_uint16(uint16_t x) {
byte_t m[2];
m[0] = byte_t(x >> 0);
m[1] = byte_t(x >> 8);
write(m);
}
/// Writes 32 bit little endian integer
void write_uint32(uint32_t x) {
byte_t m[4];
m[0] = byte_t(x >> 0);
m[1] = byte_t(x >> 8);
m[2] = byte_t(x >> 16);
m[3] = byte_t(x >> 24);
write(m);
}
void flush() { _out << std::flush; }
/// Prints formatted ASCII text
void print_line(const std::string &line) { _out << line; }
private:
std::ostream &_out;
};
/**
* Metafunction to detect input devices.
* Should be replaced by an external facility in the future.
*/
template <typename IODevice> struct is_input_device : std::false_type {};
template <typename FormatTag>
struct is_input_device<file_stream_device<FormatTag>> : std::true_type {};
template <typename FormatTag>
struct is_input_device<istream_device<FormatTag>> : std::true_type {};
template <typename FormatTag, typename T, typename D = void>
struct is_adaptable_input_device : std::false_type {};
template <typename FormatTag, typename T>
struct is_adaptable_input_device<
FormatTag, T,
typename std::enable_if<
mp11::mp_or<std::is_base_of<std::istream, T>,
std::is_same<std::istream, T>>::value>::type>
: std::true_type {
using device_type = istream_device<FormatTag>;
};
template <typename FormatTag>
struct is_adaptable_input_device<FormatTag, FILE *, void> : std::true_type {
using device_type = file_stream_device<FormatTag>;
};
///
/// Metafunction to decide if a given type is an acceptable read device type.
///
template <typename FormatTag, typename T, typename D = void>
struct is_read_device : std::false_type {};
template <typename FormatTag, typename T>
struct is_read_device<
FormatTag, T,
typename std::enable_if<
mp11::mp_or<is_input_device<FormatTag>,
is_adaptable_input_device<FormatTag, T>>::value>::type>
: std::true_type {};
/**
* Metafunction to detect output devices.
* Should be replaced by an external facility in the future.
*/
template <typename IODevice> struct is_output_device : std::false_type {};
template <typename FormatTag>
struct is_output_device<file_stream_device<FormatTag>> : std::true_type {};
template <typename FormatTag>
struct is_output_device<ostream_device<FormatTag>> : std::true_type {};
template <typename FormatTag, typename IODevice, typename D = void>
struct is_adaptable_output_device : std::false_type {};
template <typename FormatTag, typename T>
struct is_adaptable_output_device<
FormatTag, T,
typename std::enable_if<
mp11::mp_or<std::is_base_of<std::ostream, T>,
std::is_same<std::ostream, T>>::value>::type>
: std::true_type {
using device_type = ostream_device<FormatTag>;
};
template <typename FormatTag>
struct is_adaptable_output_device<FormatTag, FILE *, void> : std::true_type {
using device_type = file_stream_device<FormatTag>;
};
///
/// Metafunction to decide if a given type is an acceptable read device type.
///
template <typename FormatTag, typename T, typename D = void>
struct is_write_device : std::false_type {};
template <typename FormatTag, typename T>
struct is_write_device<
FormatTag, T,
typename std::enable_if<
mp11::mp_or<is_output_device<FormatTag>,
is_adaptable_output_device<FormatTag, T>>::value>::type>
: std::true_type {};
} // namespace detail
template <typename Device, typename FormatTag> class scanline_reader;
template <typename Device, typename FormatTag, typename ConversionPolicy>
class reader;
template <typename Device, typename FormatTag, typename Log = no_log>
class writer;
template <typename Device, typename FormatTag> class dynamic_image_reader;
template <typename Device, typename FormatTag, typename Log = no_log>
class dynamic_image_writer;
namespace detail {
template <typename T> struct is_reader : std::false_type {};
template <typename Device, typename FormatTag, typename ConversionPolicy>
struct is_reader<reader<Device, FormatTag, ConversionPolicy>> : std::true_type {
};
template <typename T> struct is_dynamic_image_reader : std::false_type {};
template <typename Device, typename FormatTag>
struct is_dynamic_image_reader<dynamic_image_reader<Device, FormatTag>>
: std::true_type {};
template <typename T> struct is_writer : std::false_type {};
template <typename Device, typename FormatTag>
struct is_writer<writer<Device, FormatTag>> : std::true_type {};
template <typename T> struct is_dynamic_image_writer : std::false_type {};
template <typename Device, typename FormatTag>
struct is_dynamic_image_writer<dynamic_image_writer<Device, FormatTag>>
: std::true_type {};
} // namespace detail
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(pop)
#endif
} // namespace gil
} // namespace boost
#endif
| 25.531373 | 80 | 0.651179 | sdebionne |
270e8b3df3b7bd8b52e67cb3eea40f08be838f4c | 1,135 | hpp | C++ | e-Paper/src/WiFiHandler.hpp | PDA-UR/Dumb-e-Paper | 99aecce5fbcb64d32b7e47809df393e0e2e7fab4 | [
"MIT"
] | 2 | 2019-01-30T13:48:14.000Z | 2021-10-30T16:11:03.000Z | e-Paper/src/WiFiHandler.hpp | PDA-UR/Dumb-e-Paper | 99aecce5fbcb64d32b7e47809df393e0e2e7fab4 | [
"MIT"
] | null | null | null | e-Paper/src/WiFiHandler.hpp | PDA-UR/Dumb-e-Paper | 99aecce5fbcb64d32b7e47809df393e0e2e7fab4 | [
"MIT"
] | 2 | 2018-02-14T12:45:59.000Z | 2021-12-17T20:57:02.000Z | #ifndef __WIFIHANDLER_H_INCLUDED__
#define __WIFIHANDLER_H_INCLUDED__
/**
* @defgroup WiFi Handler
*/
/** @addtogroup WiFi Handler */
/*@{*/
#include "main.hpp"
#include <WiFi.h>
#include <WiFiMulti.h>
/**
* @brief Could be anything but must also be changed in python script
*/
const int PORT = 1516;
enum class WiFiStatus
{
WIFI_SUCCESS,
WIFI_ERROR,
WIFI_WAIT,
SHOW_PICTURE_01,
SHOW_PICTURE_02,
CLEAR_SCREEN
};
class WiFiHandler
{
public:
/**
* @brief Start WiFi connection
*
* @param id ssid to connect
* @param password for network
* @return true if WiFi could connect
*/
static bool init(String id, String password);
/**
* @brief Receive data from WiFi and write to buffer
*
* @param buffer gets WiFi data
* @param le buffer length
* @return WiFiStatus
*/
static WiFiStatus handle(byte *buffer, int le);
/**
* @brief Sends "OK" to server, to receive new data
*/
static void requestDataChunk();
private:
static const byte O;
static const byte K;
static char *ip;
};
/*@}*/
#endif
| 17.461538 | 69 | 0.629956 | PDA-UR |
271977f61e3e2b952a3d340389cb5a28802382f2 | 2,378 | cpp | C++ | src/graphics/backend/depth_pass.cpp | NotAPenguin0/Andromeda | 69ac0e448dbc7d5ba8f5915177f333bd8cd1a1b4 | [
"MIT"
] | 7 | 2020-04-28T11:01:55.000Z | 2022-02-22T09:59:33.000Z | src/graphics/backend/depth_pass.cpp | NotAPenguin0/Andromeda | 69ac0e448dbc7d5ba8f5915177f333bd8cd1a1b4 | [
"MIT"
] | 2 | 2021-09-03T12:58:06.000Z | 2021-09-20T20:07:33.000Z | src/graphics/backend/depth_pass.cpp | NotAPenguin0/Andromeda | 69ac0e448dbc7d5ba8f5915177f333bd8cd1a1b4 | [
"MIT"
] | 1 | 2021-09-03T12:56:25.000Z | 2021-09-03T12:56:25.000Z | #include <andromeda/graphics/backend/depth_pass.hpp>
#include <andromeda/graphics/backend/mesh_draw.hpp>
namespace andromeda::gfx::backend {
void create_depth_only_pipeline(gfx::Context& ctx, VkSampleCountFlagBits samples, float sample_ratio) {
ph::PipelineCreateInfo pci = ph::PipelineBuilder::create(ctx, "depth_only")
.add_shader("data/shaders/depth.vert.spv", "main", ph::ShaderStage::Vertex)
.add_vertex_input(0)
// Note that not all these attributes will be used, but they are specified because the vertex size is deduced from them
.add_vertex_attribute(0, 0, VK_FORMAT_R32G32B32_SFLOAT) // iPos
.add_vertex_attribute(0, 1, VK_FORMAT_R32G32B32_SFLOAT) // iNormal
.add_vertex_attribute(0, 2, VK_FORMAT_R32G32B32_SFLOAT) // iTangent
.add_vertex_attribute(0, 3, VK_FORMAT_R32G32_SFLOAT) // iUV
.add_dynamic_state(VK_DYNAMIC_STATE_SCISSOR)
.add_dynamic_state(VK_DYNAMIC_STATE_VIEWPORT)
.set_depth_test(true)
.set_depth_write(true)
.set_cull_mode(VK_CULL_MODE_BACK_BIT)
.set_samples(samples)
.set_sample_shading(sample_ratio)
.reflect()
.get();
ctx.create_named_pipeline(std::move(pci));
}
ph::Pass build_depth_pass(gfx::Context& ctx, ph::InFlightContext& ifc, std::string_view target, gfx::SceneDescription const& scene, ph::BufferSlice camera, ph::BufferSlice transforms) {
ph::Pass pass = ph::PassBuilder::create("fwd_plus_depth")
.add_depth_attachment(target, ph::LoadOp::Clear, {.depth_stencil = {.depth = 1.0f, .stencil = 0}})
.execute([&ctx, &ifc, &scene, camera, transforms](ph::CommandBuffer& cmd) {
cmd.bind_pipeline("depth_only");
cmd.auto_viewport_scissor();
VkDescriptorSet set = ph::DescriptorBuilder::create(ctx, cmd.get_bound_pipeline())
.add_uniform_buffer("camera", camera)
.add_storage_buffer("transforms", transforms)
.get();
cmd.bind_descriptor_set(set);
for_each_ready_mesh(scene, [&cmd](auto const& _, gfx::Mesh const& mesh, uint32_t index) {
cmd.push_constants(ph::ShaderStage::Vertex, 0, sizeof(uint32_t), &index); // mesh index is also the transform index
bind_and_draw(cmd, mesh);
});
})
.get();
return pass;
}
} | 48.530612 | 185 | 0.671152 | NotAPenguin0 |
271a6bb390cdea7444ec97670599d0ec5b539f6f | 344 | cpp | C++ | hilbert_mapper/src/hilbert_mapper_node.cpp | Jaeyoung-Lim/mav_hilbertmap_planning | 96df718a04953df3b39f080a7e33565407ad6be1 | [
"BSD-3-Clause"
] | 4 | 2019-01-16T16:18:16.000Z | 2019-06-06T14:30:56.000Z | hilbert_mapper/src/hilbert_mapper_node.cpp | Wayne-xixi/mav_hilbertmap_planning | 96df718a04953df3b39f080a7e33565407ad6be1 | [
"BSD-3-Clause"
] | 16 | 2019-01-24T12:44:28.000Z | 2021-01-08T01:44:41.000Z | hilbert_mapper/src/hilbert_mapper_node.cpp | Wayne-xixi/mav_hilbertmap_planning | 96df718a04953df3b39f080a7e33565407ad6be1 | [
"BSD-3-Clause"
] | 2 | 2020-01-10T09:31:49.000Z | 2021-01-02T23:25:53.000Z | // July/2018, ETHZ, Jaeyoung Lim, [email protected]
#include "hilbert_mapper/hilbert_mapper.h"
//using namespace RAI;
int main(int argc, char** argv) {
ros::init(argc,argv,"geometric_controller");
ros::NodeHandle nh("");
ros::NodeHandle nh_private("~");
HilbertMapper Hilbertmapper(nh, nh_private);
ros::spin();
return 0;
}
| 22.933333 | 56 | 0.700581 | Jaeyoung-Lim |
272ef38e2bdd26b398d8e764eadb4f729ee15768 | 3,715 | cpp | C++ | Src/Vessel/Atlantis/Common.cpp | Ybalrid/orbiter | 7bed82f845ea8347f238011367e07007b0a24099 | [
"MIT"
] | 1,040 | 2021-07-27T12:12:06.000Z | 2021-08-02T14:24:49.000Z | Src/Vessel/Atlantis/Common.cpp | Ybalrid/orbiter | 7bed82f845ea8347f238011367e07007b0a24099 | [
"MIT"
] | 20 | 2021-07-27T12:25:22.000Z | 2021-08-02T12:22:19.000Z | Src/Vessel/Atlantis/Common.cpp | Ybalrid/orbiter | 7bed82f845ea8347f238011367e07007b0a24099 | [
"MIT"
] | 71 | 2021-07-27T14:19:49.000Z | 2021-08-02T05:51:52.000Z | // ==============================================================
// ORBITER MODULE: Atlantis
// Part of the ORBITER SDK
// Copyright (C) 2001-2003 Martin Schweiger
// All rights reserved
//
// Common.cpp
// Utility functions common to multiple Atlantis-related modules
// ==============================================================
#include "Atlantis.h"
#ifdef _DEBUG
// D. Beachy: GROW THE STACK HERE SO WE CAN USE BOUNDSCHECKER FOR DEBUGGING
// We need this is because BoundsChecker (for this object) grows the stack more than 1 full page (4K) at once
// and then touches data beyond the initial 4K, skipping over the guard page that Windows places below the stack to grow it automatically.
// Therefore we will grow the stack manually in one-page increments here.
// This is only necessary for BoundsChecker debugging.
int GrowStack()
{
#ifdef UNDEF // This function causes a crash (LoadLibrary fails with code 1001 (stack overflow) on compiling with VS2019, so I am disabling it for now
// NOTE: this requires that orbiter.exe has its 'Size of Stack Reserve' PE header parameter set to 4 MB
int pageCount = 256; // 256 4K pages = reserve 1 MB of stack
DWORD dwStackDelta = 0; // total # of stack bytes used
for (int i=0; i < pageCount; i++)
{
dwStackDelta += 4096;
__asm
{
sub esp, 4092; // 1 page - 4 bytes
push 0xFEEDFEED // touch the page
}
}
// now pop the stack we touched
__asm
{
mov eax, [dwStackDelta] // size in bytes
add esp, eax
}
#endif
return 0;
}
// invoke GrowStack early before the next lines are called (otherwise BoundsChecker will crash)
int growStack=GrowStack();
#endif
int SRB_nt = 6;
double SRB_Seq[6] = {-SRB_STABILISATION_TIME, -1, 103, 115, SRB_SEPARATION_TIME, SRB_CUTOUT_TIME};
double SRB_Thrust[6] = { 0, 1, 1, 0.85, 0.05, 0 };
double SRB_Prop[6] = { 1, 0.98768, 0.13365, 0.04250, 0.001848, 0 };
double SRB_ThrSCL[5] = {(SRB_Thrust[1]-SRB_Thrust[0])/(SRB_Seq[1]-SRB_Seq[0]),
(SRB_Thrust[2]-SRB_Thrust[1])/(SRB_Seq[2]-SRB_Seq[1]),
(SRB_Thrust[3]-SRB_Thrust[2])/(SRB_Seq[3]-SRB_Seq[2]),
(SRB_Thrust[4]-SRB_Thrust[3])/(SRB_Seq[4]-SRB_Seq[3]),
(SRB_Thrust[5]-SRB_Thrust[4])/(SRB_Seq[5]-SRB_Seq[4])};
double SRB_PrpSCL[5] = {(SRB_Prop[1]-SRB_Prop[0])/(SRB_Seq[1]-SRB_Seq[0]),
(SRB_Prop[2]-SRB_Prop[1])/(SRB_Seq[2]-SRB_Seq[1]),
(SRB_Prop[3]-SRB_Prop[2])/(SRB_Seq[3]-SRB_Seq[2]),
(SRB_Prop[4]-SRB_Prop[3])/(SRB_Seq[4]-SRB_Seq[3]),
(SRB_Prop[5]-SRB_Prop[4])/(SRB_Seq[5]-SRB_Seq[4])};
//PARTICLESTREAMSPEC srb_contrail = {
// 0, 12.0, 3, 150.0, 0.4, 8.0, 4, 3.0, PARTICLESTREAMSPEC::DIFFUSE,
// PARTICLESTREAMSPEC::LVL_PSQRT, 0, 0.5,
// PARTICLESTREAMSPEC::ATM_PLOG, 1e-6, 0.1
//};
PARTICLESTREAMSPEC srb_contrail = {
0, 12.0, 3, 200.0, 0.25, 12.0, 11, 10.0, PARTICLESTREAMSPEC::DIFFUSE,
PARTICLESTREAMSPEC::LVL_PSQRT, 0, 0.7,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-6, 0.1
};
PARTICLESTREAMSPEC srb_exhaust = {
0, 6.0, 40, 250.0, 0.04, 0.4, 20, 6.0, PARTICLESTREAMSPEC::EMISSIVE,
PARTICLESTREAMSPEC::LVL_SQRT, 1, 1,
PARTICLESTREAMSPEC::ATM_FLAT, 1, 1
};
// time-dependent calculation of SRB thrust and remaining propellant
void GetSRB_State (double met, double &thrust_level, double &prop_level)
{
int i;
for (i = SRB_nt-2; i >= 0; i--)
if (met > SRB_Seq[i]) break;
thrust_level = SRB_ThrSCL[i] * (met-SRB_Seq[i]) + SRB_Thrust[i];
prop_level = SRB_PrpSCL[i] * (met-SRB_Seq[i]) + SRB_Prop[i];
}
| 40.380435 | 150 | 0.61319 | Ybalrid |
27305309e16b21f4b91241bdb63de3e3ea06e5ee | 6,215 | cxx | C++ | EVE/EveDet/AliEveEMCALSModuleData.cxx | AllaMaevskaya/AliRoot | c53712645bf1c7d5f565b0d3228e3a6b9b09011a | [
"BSD-3-Clause"
] | 52 | 2016-12-11T13:04:01.000Z | 2022-03-11T11:49:35.000Z | EVE/EveDet/AliEveEMCALSModuleData.cxx | AllaMaevskaya/AliRoot | c53712645bf1c7d5f565b0d3228e3a6b9b09011a | [
"BSD-3-Clause"
] | 1,388 | 2016-11-01T10:27:36.000Z | 2022-03-30T15:26:09.000Z | EVE/EveDet/AliEveEMCALSModuleData.cxx | AllaMaevskaya/AliRoot | c53712645bf1c7d5f565b0d3228e3a6b9b09011a | [
"BSD-3-Clause"
] | 275 | 2016-06-21T20:24:05.000Z | 2022-03-31T13:06:19.000Z | /**************************************************************************
* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
* *
* Author: The ALICE Off-line Project. *
* Contributors are mentioned in the code where appropriate. *
* *
* Permission to use, copy, modify and distribute this software and its *
* documentation strictly for non-commercial purposes is hereby granted *
* without fee, provided that the above copyright notice appears in all *
* copies and that both the copyright notice and this permission notice *
* appear in the supporting documentation. The authors make no claims *
* about the suitability of this software for any purpose. It is *
* provided "as is" without express or implied warranty. *
**************************************************************************/
#include <TGeoBBox.h>
#include "AliEMCALGeometry.h"
#include "AliEveEMCALSModuleData.h"
class TClonesArray;
class TGeoNode;
//class TGeoMatrix;
class TVector2;
class AliEveEventManager;
/// \cond CLASSIMP
ClassImp(AliEveEMCALSModuleData) ;
/// \endcond
Float_t AliEveEMCALSModuleData::fgSModuleBigBox0 = 0.;
Float_t AliEveEMCALSModuleData::fgSModuleBigBox1 = 0.;
Float_t AliEveEMCALSModuleData::fgSModuleBigBox2 = 0.;
Float_t AliEveEMCALSModuleData::fgSModuleSmallBox0 = 0.;
Float_t AliEveEMCALSModuleData::fgSModuleSmallBox1 = 0.;
Float_t AliEveEMCALSModuleData::fgSModuleSmallBox2 = 0.;
Float_t AliEveEMCALSModuleData::fgSModuleDCalBox0 = 0.;
Float_t AliEveEMCALSModuleData::fgSModuleDCalBox1 = 0.;
Float_t AliEveEMCALSModuleData::fgSModuleDCalBox2 = 0.;
Float_t AliEveEMCALSModuleData::fgSModuleSmallDBox0 = 0.;
Float_t AliEveEMCALSModuleData::fgSModuleSmallDBox1 = 0.;
Float_t AliEveEMCALSModuleData::fgSModuleSmallDBox2 = 0.;
//
// Constructor
//
//______________________________________________________________________________
AliEveEMCALSModuleData::AliEveEMCALSModuleData(Int_t sm,AliEMCALGeometry* geom, TGeoNode* node): //, TGeoHMatrix* m) :
TObject(),
fGeom(geom),
fNode(node),
fSmId(sm),
fNsm(0),
fNDigits(0),
fNClusters(0),
fNHits(0),
fPhiTileSize(0), fEtaTileSize(0),
fHitArray(0),
fDigitArray(0),
fClusterArray(0)
// fMatrix(0),
// fHMatrix(m)
{
Init(sm);
}
///
/// Copy constructor
///
//______________________________________________________________________________
AliEveEMCALSModuleData::AliEveEMCALSModuleData(const AliEveEMCALSModuleData &esmdata) :
TObject(),
fGeom(esmdata.fGeom),
fNode(esmdata.fNode),
fSmId(esmdata.fSmId),
fNsm(esmdata.fNsm),
fNDigits(esmdata.fNDigits),
fNClusters(esmdata.fNClusters),
fNHits(esmdata.fNHits),
fPhiTileSize(esmdata.fPhiTileSize), fEtaTileSize(esmdata.fEtaTileSize),
fHitArray(esmdata.fHitArray),
fDigitArray(esmdata.fDigitArray),
fClusterArray(esmdata.fClusterArray)
// fMatrix(esmdata.fMatrix),
// fHMatrix(esmdata.fHMatrix)
{
Init(esmdata.fNsm);
}
///
/// Destructor
///
//______________________________________________________________________________
AliEveEMCALSModuleData::~AliEveEMCALSModuleData()
{
if(!fHitArray.empty())
fHitArray.clear();
if(!fDigitArray.empty())
fDigitArray.clear();
if(!fClusterArray.empty())
fClusterArray.clear();
}
///
/// Release the SM data.
///
//______________________________________________________________________________
void AliEveEMCALSModuleData::DropData()
{
fNDigits = 0;
fNClusters = 0;
fNHits = 0;
if(!fHitArray.empty())
fHitArray.clear();
if(!fDigitArray.empty())
fDigitArray.clear();
if(!fClusterArray.empty())
fClusterArray.clear();
return;
}
///
/// Initialize parameters
///
// ______________________________________________________________________________
void AliEveEMCALSModuleData::Init(Int_t sm)
{
fNsm = fGeom->GetNumberOfSuperModules();
fPhiTileSize = fGeom->GetPhiTileSize();
fEtaTileSize = fGeom->GetPhiTileSize();
//fMatrix = (TGeoMatrix*) fNode->GetDaughter(sm)->GetMatrix();
TGeoBBox * bbox = (TGeoBBox*) fNode->GetDaughter(sm)->GetVolume()->GetShape();
if(sm < 10)
{
fgSModuleBigBox0 = bbox->GetDX();
fgSModuleBigBox1 = bbox->GetDY();
fgSModuleBigBox2 = bbox->GetDZ();
}
else if(sm < 12)
{
fgSModuleSmallBox0 = bbox->GetDX();
fgSModuleSmallBox1 = bbox->GetDY();
fgSModuleSmallBox2 = bbox->GetDZ();
}
else if(sm < 18)
{
fgSModuleDCalBox0 = bbox->GetDX();
fgSModuleDCalBox1 = bbox->GetDY();
fgSModuleDCalBox2 = bbox->GetDZ();
}
else if(sm < 20)
{
fgSModuleSmallDBox0 = bbox->GetDX();
fgSModuleSmallDBox1 = bbox->GetDY();
fgSModuleSmallDBox2 = bbox->GetDZ();
}
}
///
/// Add a digit to this SM
///
// ______________________________________________________________________________
void AliEveEMCALSModuleData::RegisterDigit(Int_t AbsId, Int_t isupMod, Double_t iamp, Double_t ix, Double_t iy, Double_t iz)
{
std::vector<Double_t> bufDig(6);
bufDig[0] = AbsId;
bufDig[1] = isupMod;
bufDig[2] = iamp;
bufDig[3] = ix;
bufDig[4] = iy;
bufDig[5] = iz;
fDigitArray.push_back(bufDig);
fNDigits++;
}
///
/// Add a hit to this SM
///
// ______________________________________________________________________________
void AliEveEMCALSModuleData::RegisterHit(Int_t AbsId, Int_t isupMod, Double_t iamp, Double_t ix, Double_t iy, Double_t iz)
{
std::vector<Float_t> bufHit(6);
bufHit[0] = AbsId;
bufHit[1] = isupMod;
bufHit[2] = iamp;
bufHit[3] = ix;
bufHit[4] = iy;
bufHit[5] = iz;
fHitArray.push_back(bufHit);
fNHits++;
}
///
/// Add a cluster to this SM
///
// ______________________________________________________________________________
void AliEveEMCALSModuleData::RegisterCluster(Int_t isupMod, Double_t iamp, Double_t ix, Double_t iy, Double_t iz)
{
std::vector<Double_t> bufClu(5);
bufClu[0] = isupMod;
bufClu[1] = iamp;
bufClu[2] = ix;
bufClu[3] = iy;
bufClu[4] = iz;
fClusterArray.push_back(bufClu);
fNClusters++;
}
| 27.258772 | 124 | 0.684312 | AllaMaevskaya |
27307444b2da9e8959408ee53db2556cc14f1982 | 578 | cpp | C++ | codes/HDU/hdu5510.cpp | JeraKrs/ACM | edcd61ec6764b8cd804bf1538dfde53d0ff572b5 | [
"Apache-2.0"
] | null | null | null | codes/HDU/hdu5510.cpp | JeraKrs/ACM | edcd61ec6764b8cd804bf1538dfde53d0ff572b5 | [
"Apache-2.0"
] | null | null | null | codes/HDU/hdu5510.cpp | JeraKrs/ACM | edcd61ec6764b8cd804bf1538dfde53d0ff572b5 | [
"Apache-2.0"
] | null | null | null | #include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 505;
const int maxm = 2005;
int N, F[maxn];
char str[maxn][maxm];
int main () {
int cas;
scanf("%d", &cas);
for (int kcas = 1; kcas <= cas; kcas++) {
scanf("%d", &N);
for (int i = 0; i < N; i++) scanf("%s", str[i]);
int p = N-1;
while (p && strstr(str[p], str[p-1]) != NULL) p--;
p++;
for (int i = p-2; i >= 0 && p < N; i--) {
while (p < N && strstr(str[p], str[i]) == NULL) p++;
}
if (p == 1) p = -1;
printf("Case #%d: %d\n", kcas, p);
}
return 0;
}
| 18.645161 | 55 | 0.50346 | JeraKrs |
27328566237e55700f7895bf93f686526d64ee99 | 3,341 | cpp | C++ | tests/src/QtSettingsUtilsTests.cpp | oclero/qtutils | 477d65211a15bffabe11d9f0b526c917893ae8ee | [
"MIT"
] | null | null | null | tests/src/QtSettingsUtilsTests.cpp | oclero/qtutils | 477d65211a15bffabe11d9f0b526c917893ae8ee | [
"MIT"
] | null | null | null | tests/src/QtSettingsUtilsTests.cpp | oclero/qtutils | 477d65211a15bffabe11d9f0b526c917893ae8ee | [
"MIT"
] | null | null | null | #include "QtSettingsUtilsTests.hpp"
#include <QTest>
#include <oclero/QtSettingsUtils.hpp>
constexpr auto SETTINGS_KEY = "Toto";
using namespace oclero;
void QtSettingsUtilsTests::init() {
{
QSettings qSettings;
qSettings.remove(SETTINGS_KEY);
}
}
void QtSettingsUtilsTests::cleanup() {
{
QSettings qSettings;
qSettings.remove(SETTINGS_KEY);
}
}
void QtSettingsUtilsTests::test_tryLoadInexistentSetting_enum() const {
QSettings settings;
auto const optionalValue = tryLoadSetting<DummyEnum>(settings, SETTINGS_KEY);
QVERIFY(!optionalValue.has_value());
}
void QtSettingsUtilsTests::test_tryLoadInvalidSetting_enum() const {
{ QSettings{}.setValue(SETTINGS_KEY, "1"); }
QSettings settings;
auto const optionalValue = tryLoadSetting<DummyEnum>(settings, SETTINGS_KEY);
QVERIFY(!optionalValue.has_value());
}
void QtSettingsUtilsTests::test_tryLoadValidSetting_enum() const {
{ QSettings{}.setValue(SETTINGS_KEY, "DummyValue2"); }
QSettings settings;
auto const optionalValue = tryLoadSetting<DummyEnum>(settings, SETTINGS_KEY);
QVERIFY(optionalValue.has_value() && optionalValue.value() == DummyEnum::DummyValue2);
}
void QtSettingsUtilsTests::test_tryLoadInexistentSetting_int() const {
QSettings settings;
auto const optionalValue = tryLoadSetting<int>(settings, SETTINGS_KEY);
QVERIFY(!optionalValue.has_value());
}
void QtSettingsUtilsTests::test_tryLoadInvalidSetting_int() const {
{ QSettings{}.setValue(SETTINGS_KEY, "abc"); }
QSettings settings;
auto const optionalValue = tryLoadSetting<int>(settings, SETTINGS_KEY);
QVERIFY(!optionalValue.has_value());
}
void QtSettingsUtilsTests::test_tryLoadValidSetting_int() const {
{ QSettings{}.setValue(SETTINGS_KEY, 42); }
QSettings settings;
auto const optionalValue = tryLoadSetting<int>(settings, SETTINGS_KEY);
QVERIFY(optionalValue.has_value() && optionalValue.value() == 42);
}
void QtSettingsUtilsTests::test_loadValidSetting() const {
{ QSettings{}.setValue(SETTINGS_KEY, 42); }
QSettings settings;
auto const value = loadSetting<int>(settings, SETTINGS_KEY);
QVERIFY(value == 42);
}
void QtSettingsUtilsTests::test_loadInvalidSetting() const {
QSettings settings;
auto const value = loadSetting<int>(settings, SETTINGS_KEY, 12);
QVERIFY(value == 12);
}
void QtSettingsUtilsTests::test_saveSetting_int() const {
{
QSettings settings;
saveSetting<int>(settings, SETTINGS_KEY, 42);
}
auto const value = QSettings{}.value(SETTINGS_KEY).toInt();
QVERIFY(value == 42);
}
void QtSettingsUtilsTests::test_saveSetting_enum() const {
{
QSettings settings;
saveSetting<DummyEnum>(settings, SETTINGS_KEY, DummyEnum::DummyValue2);
}
// Enum are saved as strings and parsed.
auto const value = QSettings{}.value(SETTINGS_KEY).toString();
QVERIFY(value == "DummyValue2");
}
void QtSettingsUtilsTests::test_useQStringAsKey() const {
auto qStringKey = QString{ SETTINGS_KEY };
{
QSettings settings;
saveSetting<int>(settings, qStringKey, 42);
}
auto const value = QSettings{}.value(SETTINGS_KEY).toInt();
QVERIFY(value == 42);
QSettings{}.setValue(qStringKey, "DummyValue");
{
QSettings settings;
auto const valueInSettings = loadSetting<QString>(settings, qStringKey, QString{});
QVERIFY(valueInSettings == "DummyValue");
}
}
| 29.052174 | 88 | 0.747082 | oclero |
2734ad912439e8edf65e2870e1d3906a68a2fbd6 | 13,656 | hpp | C++ | src/Memory/AffixAllocator.hpp | epicbrownie/Epic | c54159616b899bb24c6d59325d582e73f2803ab6 | [
"MIT"
] | null | null | null | src/Memory/AffixAllocator.hpp | epicbrownie/Epic | c54159616b899bb24c6d59325d582e73f2803ab6 | [
"MIT"
] | 29 | 2016-08-01T14:50:12.000Z | 2017-12-17T20:28:27.000Z | src/Memory/AffixAllocator.hpp | epicbrownie/Epic | c54159616b899bb24c6d59325d582e73f2803ab6 | [
"MIT"
] | null | null | null | //////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2016 Ronnie Brohn (EpicBrownie)
//
// Distributed under The MIT License (MIT).
// (See accompanying file License.txt or copy at
// https://opensource.org/licenses/MIT)
//
// Please report any bugs, typos, or suggestions to
// https://github.com/epicbrownie/Epic/issues
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include <Epic/Memory/MemoryBlock.hpp>
#include <Epic/Memory/detail/AllocatorTraits.hpp>
#include <Epic/Memory/detail/AllocatorHelpers.hpp>
#include <Epic/Memory/detail/AffixHelpers.hpp>
#include <cassert>
#include <cstdint>
#include <algorithm>
#include <type_traits>
//////////////////////////////////////////////////////////////////////////////
namespace Epic
{
template<class Allocator, class Prefix, class Suffix = void>
class AffixAllocator;
}
//////////////////////////////////////////////////////////////////////////////
/// AffixAllocator<A, Prefix, Suffix>
template<class A, class Prefix, class Suffix>
class Epic::AffixAllocator
{
static_assert(std::is_default_constructible<A>::value, "The affix allocator must be default-constructible.");
public:
using Type = Epic::AffixAllocator<A, Prefix, Suffix>;
using AllocatorType = A;
using PrefixType = Prefix;
using SuffixType = Suffix;
public:
static constexpr size_t Alignment = A::Alignment;
private:
static constexpr bool HasPrefix = !std::is_same<Prefix, void>::value;
static constexpr bool HasSuffix = !std::is_same<Suffix, void>::value;
static constexpr size_t UnalignedPrefixSize = detail::AffixSize<Prefix>::value;
static constexpr size_t PrefixSize = detail::RoundToAligned(UnalignedPrefixSize, Alignment);
static constexpr size_t SuffixSize = detail::AffixSize<Suffix>::value;
using AlignmentMemento = uint16_t;
private:
static constexpr size_t NonAllocSize = (PrefixSize + SuffixSize + sizeof(AlignmentMemento));
public:
static constexpr size_t MinAllocSize = A::MinAllocSize;
static constexpr size_t MaxAllocSize = A::MaxAllocSize - NonAllocSize;
static constexpr bool IsShareable = A::IsShareable;
static_assert(!HasPrefix || std::is_default_constructible<Prefix>::value, "The Prefix Type must be default-constructible.");
static_assert(!HasSuffix || std::is_default_constructible<Suffix>::value, "The Suffix Type must be default-constructible.");
static_assert(A::MaxAllocSize > NonAllocSize && MaxAllocSize > MinAllocSize,
"The affix sizes are too large for the backing Allocator.");
private:
AllocatorType m_Allocator;
public:
constexpr AffixAllocator()
noexcept(std::is_nothrow_default_constructible<A>::value) = default;
template<typename = std::enable_if_t<std::is_copy_constructible<A>::value>>
constexpr AffixAllocator(const Type& obj)
noexcept(std::is_nothrow_copy_constructible<A>::value)
: m_Allocator{ obj.m_Allocator }
{ }
template<typename = std::enable_if_t<std::is_move_constructible<A>::value>>
constexpr AffixAllocator(Type&& obj)
noexcept(std::is_nothrow_move_constructible<A>::value)
: m_Allocator{ std::move(obj.m_Allocator) }
{ }
template<typename = std::enable_if_t<std::is_copy_assignable<A>::value>>
AffixAllocator& operator = (const Type& obj)
noexcept(std::is_nothrow_copy_assignable<A>::value)
{
m_Allocator = obj.m_Allocator;
return *this;
}
template<typename = std::enable_if_t<std::is_move_assignable<A>::value>>
AffixAllocator& operator = (Type&& obj)
noexcept(std::is_nothrow_move_assignable<A>::value)
{
m_Allocator = std::move(obj.m_Allocator);
return *this;
}
private:
static constexpr Blk ClientToAffixedBlock(const Blk& blk, const AlignmentMemento& alignment) noexcept
{
return Blk
{
reinterpret_cast<unsigned char*>(blk.Ptr) - detail::RoundToAligned(UnalignedPrefixSize, alignment),
blk.Size + (detail::RoundToAligned(UnalignedPrefixSize, alignment) + SuffixSize + sizeof(AlignmentMemento))
};
}
static constexpr Blk AffixedToClientBlock(const Blk& blk, const AlignmentMemento& alignment) noexcept
{
return Blk
{
reinterpret_cast<unsigned char*>(blk.Ptr) + detail::RoundToAligned(UnalignedPrefixSize, alignment),
blk.Size - (detail::RoundToAligned(UnalignedPrefixSize, alignment) + SuffixSize + sizeof(AlignmentMemento))
};
}
static constexpr void* AffixedToPrefixPtr(const Blk& blk) noexcept
{
return blk.Ptr;
}
static constexpr void* AffixedToSuffixPtr(const Blk& blk) noexcept
{
return static_cast<void*>(reinterpret_cast<unsigned char*>(blk.Ptr) + blk.Size - SuffixSize);
}
static constexpr AlignmentMemento* AffixedToAlignmentMementoPtr(const Blk& blk)
{
return reinterpret_cast<AlignmentMemento*>(reinterpret_cast<unsigned char*>(AffixedToSuffixPtr(blk)) - sizeof(AlignmentMemento));
}
static constexpr void* ClientToPrefixPtr(const Blk& blk, const AlignmentMemento& alignment) noexcept
{
return static_cast<void*>(reinterpret_cast<unsigned char*>(blk.Ptr) - detail::RoundToAligned(UnalignedPrefixSize, alignment));
}
static constexpr void* ClientToSuffixPtr(const Blk& blk) noexcept
{
return static_cast<void*>(reinterpret_cast<unsigned char*>(blk.Ptr) + blk.Size + sizeof(AlignmentMemento));
}
static constexpr AlignmentMemento* ClientToAlignmentMementoPtr(const Blk& blk)
{
return reinterpret_cast<AlignmentMemento*>(reinterpret_cast<unsigned char*>(blk.Ptr) + blk.Size);
}
public:
/* Returns whether or not this allocator is responsible for the block Blk. */
inline bool Owns(const Blk& blk) const noexcept
{
return blk ? m_Allocator.Owns(ClientToAffixedBlock(blk, *ClientToAlignmentMementoPtr(blk))) : false;
}
public:
/* Returns a block of uninitialized memory.
The memory will be surrounded by constructed Affix objects. */
template<typename = std::enable_if_t<detail::CanAllocate<A>::value>>
Blk Allocate(size_t sz) noexcept
{
// Verify that the requested size isn't zero.
if (sz == 0) return{ nullptr, 0 };
// Verify that the requested size is within our allowed bounds
if (sz < MinAllocSize || sz > MaxAllocSize)
return{ nullptr, 0 };
// Allocate the block
auto blk = m_Allocator.Allocate(sz + NonAllocSize);
if (!blk) return{ nullptr, 0 };
// Construct the Prefix and Suffix objects
if constexpr (HasPrefix)
::new (AffixedToPrefixPtr(blk)) Prefix();
if constexpr (HasSuffix)
::new (AffixedToSuffixPtr(blk)) Suffix();
// Store alignment memento
const auto memento = static_cast<AlignmentMemento>(Alignment);
*AffixedToAlignmentMementoPtr(blk) = memento;
return AffixedToClientBlock(blk, memento);
}
/* Returns a block of uninitialized memory (aligned to 'alignment').
The memory will be surrounded by constructed Affix objects. */
template<typename = std::enable_if_t<detail::CanAllocateAligned<A>::value>>
Blk AllocateAligned(size_t sz, size_t alignment = Alignment) noexcept
{
// Verify that the alignment is acceptable
if (!detail::IsGoodAlignment(alignment))
return{ nullptr, 0 };
assert(alignment <= std::numeric_limits<AlignmentMemento>::max() &&
"AffixAllocator::AllocateAligned - Unsupported alignment value");
// Verify that the requested size isn't zero.
if (sz == 0) return{ nullptr, 0 };
// Verify that the requested size is within our allowed bounds
if (sz < MinAllocSize || sz > MaxAllocSize)
return{ nullptr, 0 };
// Allocate the block
const size_t szNew = sz + detail::RoundToAligned(UnalignedPrefixSize, alignment) + sizeof(AlignmentMemento) + SuffixSize;
auto blk = m_Allocator.AllocateAligned(szNew, alignment);
if (!blk) return{ nullptr, 0 };
// Construct the Prefix and Suffix objects
if constexpr (HasPrefix)
::new (AffixedToPrefixPtr(blk)) Prefix();
if constexpr (HasSuffix)
::new (AffixedToSuffixPtr(blk)) Suffix();
// Store alignment memento
const auto memento = static_cast<AlignmentMemento>(alignment);
*AffixedToAlignmentMementoPtr(blk) = memento;
return AffixedToClientBlock(blk, memento);
}
/* Attempts to reallocate the memory of blk to the new size sz.
The Affix objects will be moved as necessary. */
template<typename = std::enable_if_t<detail::CanReallocate<A>::value && detail::AffixBuffer<Suffix>::CanStore>>
bool Reallocate(Blk& blk, size_t sz)
{
// If the block isn't valid, delegate to Allocate
if (!blk)
{
if constexpr (detail::CanAllocate<Type>::value)
return (bool)(blk = Allocate(sz));
}
// If the requested size is zero, delegate to Deallocate
if (sz == 0)
{
if constexpr (detail::CanDeallocate<Type>::value)
Deallocate(blk);
blk = { nullptr, 0 };
return true;
}
// Verify that the requested size is within our allowed bounds
if (sz < MinAllocSize || sz > MaxAllocSize)
return false;
// Move the Suffix object to the stack
auto pSuffix = GetSuffixObject(blk);
detail::AffixBuffer<Suffix> suffix{ pSuffix };
// Reallocate the block
Blk affixedBlk = ClientToAffixedBlock(blk, Alignment);
if (!m_Allocator.Reallocate(affixedBlk, sz + NonAllocSize))
{
suffix.Restore(pSuffix);
return false;
}
// Place the Suffix object and the alignment memento
suffix.Restore(AffixedToSuffixPtr(affixedBlk));
*AffixedToAlignmentMementoPtr(affixedBlk) = Alignment;
blk = AffixedToClientBlock(affixedBlk, Alignment);
return true;
}
/* Attempts to reallocate the memory of blk to the new size 'sz' (aligned to 'alignment').
It must have been allocated through AllocateAligned().
The Affix objects will be moved as necessary. */
template<typename = std::enable_if_t<detail::CanReallocateAligned<A>::value && detail::AffixBuffer<Suffix>::CanStore>>
bool ReallocateAligned(Blk& blk, size_t sz, size_t alignment = Alignment)
{
// Verify that the alignment is acceptable
if (!detail::IsGoodAlignment(alignment))
return false;
assert(alignment <= std::numeric_limits<AlignmentMemento>::max() &&
"AffixAllocator::ReallocateAligned - Unsupported alignment value");
// If the block isn't valid, delegate to AllocateAligned
if (!blk)
{
if constexpr (detail::CanAllocateAligned<Type>::value)
return (bool)(blk = AllocateAligned(sz, alignment));
}
// If the requested size is zero, delegate to DeallocateAligned
if (sz == 0)
{
if constexpr (detail::CanDeallocateAligned<Type>::value)
DeallocateAligned(blk);
blk = { nullptr, 0 };
return true;
}
// Verify that the requested size is within our allowed bounds
if (sz < MinAllocSize || sz > MaxAllocSize)
return false;
// Verify alignment memento
const AlignmentMemento memento = *ClientToAlignmentMementoPtr(blk);
assert(detail::IsGoodAlignment(memento) &&
"AffixAllocator::ReallocateAligned - Either this block was not allocated aligned or the heap has been corrupted");
assert(alignment == memento &&
"AffixAllocator::ReallocateAligned - Once allocated, the alignment of an allocated block cannot be changed");
// Move the Suffix object to the stack
auto pSuffix = GetSuffixObject(blk);
detail::AffixBuffer<Suffix> suffix{ pSuffix };
// Reallocate the block
Blk affixedBlk = ClientToAffixedBlock(blk, memento);
size_t szNew = sz + detail::RoundToAligned(UnalignedPrefixSize, alignment) + sizeof(AlignmentMemento) + SuffixSize;
if (!m_Allocator.ReallocateAligned(affixedBlk, szNew))
{
suffix.Restore(pSuffix);
return false;
}
// Place the Suffix object and the alignment memento
suffix.Restore(AffixedToSuffixPtr(affixedBlk));
*AffixedToAlignmentMementoPtr(affixedBlk) = memento;
blk = AffixedToClientBlock(affixedBlk, memento);
return true;
}
public:
/* Frees the memory for blk.
The surrounding Affix objects will also be destroyed. */
template<typename = std::enable_if_t<detail::CanDeallocate<A>::value>>
void Deallocate(const Blk& blk)
{
if (!blk) return;
assert(Owns(blk) &&
"AffixAllocator::Deallocate - "
"Attempted to free a block that was not allocated by this allocator");
// Deconstruct the affix objects
if (HasPrefix) GetPrefixObject(blk)->~Prefix();
if (HasSuffix) GetSuffixObject(blk)->~Suffix();
// Deallocate the affixed block
m_Allocator.Deallocate(ClientToAffixedBlock(blk, static_cast<AlignmentMemento>(Alignment)));
}
/* Frees the memory for blk. It must have been allocated through AllocateAligned().
The surrounding Affix objects will also be destroyed. */
template<typename = std::enable_if_t<detail::CanDeallocateAligned<A>::value>>
void DeallocateAligned(const Blk& blk)
{
if (!blk) return;
assert(Owns(blk) &&
"AffixAllocator::DeallocateAligned - "
"Attempted to free a block that was not allocated by this allocator");
// Verify alignment memento
assert(detail::IsGoodAlignment(*ClientToAlignmentMementoPtr(blk)) &&
"AffixAllocator::DeallocateAligned - "
"Either this block was not allocated aligned or the heap has been corrupted");
// Deconstruct the affix objects
if (HasPrefix) GetPrefixObject(blk)->~Prefix();
if (HasSuffix) GetSuffixObject(blk)->~Suffix();
// Deallocate the affixed block
m_Allocator.DeallocateAligned(ClientToAffixedBlock(blk, *ClientToAlignmentMementoPtr(blk)));
}
public:
static constexpr Prefix* GetPrefixObject(const Blk& blk, size_t alignment = Alignment) noexcept
{
return HasPrefix ?
reinterpret_cast<Prefix*>(ClientToPrefixPtr(blk, static_cast<AlignmentMemento>(alignment))) :
nullptr;
}
static constexpr Suffix* GetSuffixObject(const Blk& blk) noexcept
{
return HasSuffix ? reinterpret_cast<Suffix*>(ClientToSuffixPtr(blk)) : nullptr;
}
};
| 33.80198 | 131 | 0.719098 | epicbrownie |
2738cad2ad0f4fd1993a2d3118846cbfdce350c9 | 6,275 | cpp | C++ | src/morda/widgets/label/NinePatch.cpp | Mactor2018/morda | 7194f973783b4472b8671fbb52e8c96e8c972b90 | [
"MIT"
] | 1 | 2018-10-27T05:07:05.000Z | 2018-10-27T05:07:05.000Z | src/morda/widgets/label/NinePatch.cpp | Mactor2018/morda | 7194f973783b4472b8671fbb52e8c96e8c972b90 | [
"MIT"
] | null | null | null | src/morda/widgets/label/NinePatch.cpp | Mactor2018/morda | 7194f973783b4472b8671fbb52e8c96e8c972b90 | [
"MIT"
] | null | null | null | #include <utki/util.hpp>
#include <utki/types.hpp>
#include "../../Morda.hpp"
#include "../../util/util.hpp"
#include "../proxy/ResizeProxy.hpp"
#include "NinePatch.hpp"
using namespace morda;
namespace{
const char* ninePatchLayout_c = R"qwertyuiop(
Row{
layout{dx{fill}}
Image{
name{morda_lt}
}
Image{
layout{dx{0}weight{1}}
name{morda_t}
}
Image{
name{morda_rt}
}
}
Row{
layout{
dx{max}
weight{1}
}
Image{
name{morda_l}
layout{dy{fill}}
}
Pile{
name{morda_content}
layout{
weight{1}
dy{max}
}
Image{
name{morda_m}
layout{dx{fill}dy{fill}}
}
}
Image{
name{morda_r}
layout{dy{fill}}
}
}
Row{
layout{dx{fill}}
Image{
name{morda_lb}
}
Image{
layout{dx{0}weight{1}}
name{morda_b}
}
Image{
name{morda_rb}
}
}
)qwertyuiop";
}
NinePatch::NinePatch(const stob::Node* chain) :
Widget(chain),
BlendingWidget(chain),
Column(stob::parse(ninePatchLayout_c).get())
{
this->imageMatrix_v[0][0] = this->findByNameAs<Image>("morda_lt");
this->imageMatrix_v[0][1] = this->findByNameAs<Image>("morda_t");
this->imageMatrix_v[0][2] = this->findByNameAs<Image>("morda_rt");
this->imageMatrix_v[1][0] = this->findByNameAs<Image>("morda_l");
this->imageMatrix_v[1][1] = this->findByNameAs<Image>("morda_m");
this->imageMatrix_v[1][2] = this->findByNameAs<Image>("morda_r");
this->imageMatrix_v[2][0] = this->findByNameAs<Image>("morda_lb");
this->imageMatrix_v[2][1] = this->findByNameAs<Image>("morda_b");
this->imageMatrix_v[2][2] = this->findByNameAs<Image>("morda_rb");
this->onBlendingChanged();
this->content_v = this->findByNameAs<Pile>("morda_content");
if(auto n = getProperty(chain, "left")){
this->borders.left() = dimValueFromSTOB(*n);//'min' is by default, but not allowed to specify explicitly, as well as 'max' and 'fill'
}else{
this->borders.left() = LayoutParams::min_c;
}
if(auto n = getProperty(chain, "right")){
this->borders.right() = dimValueFromSTOB(*n);
}else{
this->borders.right() = LayoutParams::min_c;
}
if(auto n = getProperty(chain, "top")){
this->borders.top() = dimValueFromSTOB(*n);
}else{
this->borders.top() = LayoutParams::min_c;
}
if(auto n = getProperty(chain, "bottom")){
this->borders.bottom() = dimValueFromSTOB(*n);
}else{
this->borders.bottom() = LayoutParams::min_c;
}
if(auto n = getProperty(chain, "centerVisible")){
this->setCenterVisible(n->asBool());
}
//this should go after setting up border widgets
if(const stob::Node* n = getProperty(chain, "image")){
this->setNinePatch(morda::Morda::inst().resMan.load<ResNinePatch>(n->value()));
}
if(chain){
this->content_v->add(*chain);
}
}
void NinePatch::render(const morda::Matr4r& matrix) const {
this->Column::render(matrix);
}
void NinePatch::setNinePatch(std::shared_ptr<const ResNinePatch> np){
this->image = std::move(np);
this->scaledImage.reset();
this->applyImages();
this->clearCache();
}
Sidesr NinePatch::getActualBorders() const noexcept{
Sidesr ret;
for(auto i = 0; i != ret.size(); ++i){
if(this->borders[i] >= 0){
ret[i] = this->borders[i];
}else if(!this->image){
ret[i] = 0;
}else{
ret[i] = this->image->borders()[i];
}
}
return ret;
}
void NinePatch::applyImages(){
if(!this->image){
for(auto& i : this->imageMatrix_v){
for(auto& j : i){
j->setImage(nullptr);
}
}
return;
}
auto& minBorders = this->image->borders();
// TRACE(<< "minBorders = " << minBorders << std::endl)
{
//non-const call to getLayoutParams requests relayout which is not necessarily needed, so try to avoid it if possible
auto& layoutParams = utki::makePtrToConst(this->imageMatrix_v[0][0].get())->getLayoutParams();
if(this->borders.left() == LayoutParams::min_c){
if(layoutParams.dim.x != minBorders.left()){
auto& lp = this->imageMatrix_v[0][0].get()->getLayoutParams();
lp.dim.x = minBorders.left();
}
}else{
if(layoutParams.dim.x != this->borders.left()){
auto& lp = this->imageMatrix_v[0][0].get()->getLayoutParams();
lp.dim.x = this->borders.left();
}
}
if(this->borders.top() == LayoutParams::min_c){
if(layoutParams.dim.y != minBorders.top()){
auto& lp = this->imageMatrix_v[0][0].get()->getLayoutParams();
lp.dim.y = minBorders.top();
}
}else{
if(layoutParams.dim.y != this->borders.top()){
auto& lp = this->imageMatrix_v[0][0].get()->getLayoutParams();
lp.dim.y = this->borders.top();
}
}
// TRACE(<< "layoutParams.dim = " << layoutParams.dim << std::endl)
}
{
//non-const call to getLayoutParams requests relayout which is not necessarily needed, so try to avoid it if possible
auto& layoutParams = utki::makePtrToConst(this->imageMatrix_v[2][2].get())->getLayoutParams();
if(this->borders.right() == LayoutParams::min_c){
if(layoutParams.dim.x != minBorders.right()){
auto& lp = this->imageMatrix_v[2][2]->getLayoutParams();
lp.dim.x = minBorders.right();
}
}else{
if(layoutParams.dim.x != this->borders.right()){
auto& lp = this->imageMatrix_v[2][2]->getLayoutParams();
lp.dim.x = this->borders.right();
}
}
if(this->borders.bottom() == LayoutParams::min_c){
if(layoutParams.dim.y != minBorders.bottom()){
auto& lp = this->imageMatrix_v[2][2]->getLayoutParams();
lp.dim.y = minBorders.bottom();
}
}else{
if(layoutParams.dim.y != this->borders.bottom()){
auto& lp = this->imageMatrix_v[2][2]->getLayoutParams();
lp.dim.y = this->borders.bottom();
}
}
// TRACE(<< "lp.dim = " << lp.dim << std::endl)
}
// TRACE(<< "this->borders = " << this->borders << std::endl)
this->scaledImage = this->image->get(this->borders);
for(unsigned i = 0; i != 3; ++i){
for(unsigned j = 0; j != 3; ++j){
this->imageMatrix_v[i][j]->setImage(this->scaledImage->images()[i][j]);
}
}
}
void NinePatch::setCenterVisible(bool visible){
ASSERT(this->imageMatrix_v[1][1])
this->imageMatrix_v[1][1]->setVisible(visible);
}
void NinePatch::onBlendingChanged(){
for(unsigned i = 0; i != 3; ++i){
for(unsigned j = 0; j != 3; ++j){
this->imageMatrix_v[i][j]->setBlendingParams(this->blendingParams());
}
}
}
| 23.501873 | 135 | 0.631076 | Mactor2018 |
27398d4050dfe38b74e7be92aaa139b91bd37c3e | 988 | cpp | C++ | src/input/InputConfiguration.cpp | jaspervdj/JVGS | 59be35ed61b355b445b82bf32796c0f229e21b60 | [
"WTFPL"
] | 31 | 2015-02-02T04:51:10.000Z | 2021-02-20T10:04:41.000Z | src/input/InputConfiguration.cpp | jaspervdj/JVGS | 59be35ed61b355b445b82bf32796c0f229e21b60 | [
"WTFPL"
] | 2 | 2016-08-30T09:26:31.000Z | 2016-09-14T20:01:20.000Z | src/input/InputConfiguration.cpp | jaspervdj/JVGS | 59be35ed61b355b445b82bf32796c0f229e21b60 | [
"WTFPL"
] | 7 | 2015-02-02T05:02:09.000Z | 2021-12-24T06:53:01.000Z | #include "InputConfiguration.h"
#include "../core/LogManager.h"
using namespace jvgs::core;
using namespace std;
namespace jvgs
{
namespace input
{
InputConfiguration::InputConfiguration()
{
}
InputConfiguration::~InputConfiguration()
{
}
InputConfiguration *InputConfiguration::getConfiguration()
{
static InputConfiguration configuration;
return &configuration;
}
const Key &InputConfiguration::getKey(const string &action)
{
map<string, Key>::iterator result = keys.find(action);
if(result != keys.end())
return result->second;
else
LogManager::getInstance()->error(
"No key defined for action '%s'", action.c_str());
}
void InputConfiguration::setKey(const string &action, const Key &key)
{
keys[action] = key;
}
}
}
| 23.52381 | 77 | 0.554656 | jaspervdj |
273cc8c66a8ab4bb13e42655a91d801541d9d465 | 1,609 | hpp | C++ | src/Core/Window.hpp | llGuy/Ondine | 325c2d3ea5bd5ef5456b0181c53ad227571fada3 | [
"MIT"
] | 1 | 2022-01-24T18:15:56.000Z | 2022-01-24T18:15:56.000Z | src/Core/Window.hpp | llGuy/Ondine | 325c2d3ea5bd5ef5456b0181c53ad227571fada3 | [
"MIT"
] | null | null | null | src/Core/Window.hpp | llGuy/Ondine | 325c2d3ea5bd5ef5456b0181c53ad227571fada3 | [
"MIT"
] | null | null | null | #pragma once
#include "IO.hpp"
#include <string_view>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include "Event.hpp"
#include "Time.hpp"
#include "Utils.hpp"
namespace Ondine::Core {
enum class WindowMode {
Fullscreen,
Windowed
};
using SurfaceCreationProc = void(*)(
struct VkInstance_T *instance,
struct VkSurfaceKHR_T **surface,
void *windowHandle);
/* To pass to graphics context */
struct WindowContextInfo {
void *handle;
Resolution resolution;
SurfaceCreationProc surfaceCreateProc;
};
class Window {
public:
Window(
WindowMode mode,
const std::string_view &title,
const Resolution &resolution = {});
WindowContextInfo init(OnEventProc callback);
void pollInput();
void toggleFullscreen();
void changeCursorDisplay(bool show);
static void initWindowAPI();
private:
void keyCallback(int key, int scancode, int action, int mods) const;
void mouseButtonCallback(int button, int action, int mods) const;
void charCallback(unsigned int codePoint) const;
void cursorMoveCallback(float x, float y) const;
void resizeCallback(unsigned width, unsigned height);
void scrollCallback(float x, float y) const;
void closeCallback() const;
static void createVulkanSurface(
struct VkInstance_T *instance,
struct VkSurfaceKHR_T **surface,
void *windowHandle);
private:
GLFWwindow *mHandle;
Resolution mResolution;
Resolution mPreviousWindowedResolution;
OnEventProc mEventCallback;
WindowMode mWindowMode;
bool mIsFullscreen;
bool mResized;
glm::ivec2 mPreviousWindowedPosition;
const std::string_view mTitle;
};
}
| 22.347222 | 70 | 0.747669 | llGuy |
2744efcee9ee1238eb1db6f9df77044fae3d1a37 | 156 | hpp | C++ | game_server/src/server_ui.hpp | CellWarsOfficial/CellWars | 40b1e956c871ee686062eba1251a9f9a43d86c2c | [
"Apache-2.0"
] | 5 | 2017-07-20T10:36:23.000Z | 2018-01-30T16:18:31.000Z | game_server/src/server_ui.hpp | CellWarsOfficial/CellWars | 40b1e956c871ee686062eba1251a9f9a43d86c2c | [
"Apache-2.0"
] | null | null | null | game_server/src/server_ui.hpp | CellWarsOfficial/CellWars | 40b1e956c871ee686062eba1251a9f9a43d86c2c | [
"Apache-2.0"
] | null | null | null | #ifndef SERVER_UI_H
#define SERVER_UI_H
#include <log.hpp>
extern Game *game;
void signal_interpreter(int s);
void init_server_ui(Logger *log);
#endif
| 12 | 33 | 0.762821 | CellWarsOfficial |
2746c88ef909c7345bcb0470a83a4b4fe1616962 | 69,161 | cpp | C++ | cdl/CDL_interface.cpp | disi33/libRetroReversing | 1c825a1971820dbb73fcc96aa444408f6b65803d | [
"MIT"
] | null | null | null | cdl/CDL_interface.cpp | disi33/libRetroReversing | 1c825a1971820dbb73fcc96aa444408f6b65803d | [
"MIT"
] | null | null | null | cdl/CDL_interface.cpp | disi33/libRetroReversing | 1c825a1971820dbb73fcc96aa444408f6b65803d | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#endif
#include <windows.h>
#else
#include <sys/time.h>
#endif
#include <stdio.h>
#include <map>
#include <fstream>
#include <iostream>
#include <sstream>
#include "../cdl/CDL_FileWriting.hpp"
#include "nlohmann/json.hpp"
using json = nlohmann::json;
using namespace std;
#include "CDL.hpp"
extern json fileConfig;
extern json reConfig;
extern json playthough_function_usage;
extern json libRR_console_constants;
json libultra_signatures;
json linker_map_file;
#define USE_CDL 1;
extern std::map<uint32_t,string> memory_to_log;
extern std::map<uint32_t,char> jumps;
extern std::map<uint32_t,string> audio_address;
extern std::map<uint32_t,uint8_t> cached_jumps;
std::map<uint32_t, uint8_t*> jump_data;
extern std::map<uint32_t,uint32_t> rsp_reads;
extern std::map<uint32_t,uint32_t> rdram_reads;
std::map<uint32_t,bool> offsetHasAssembly;
extern "C" {
// TODO: move the following includes, they are for N64
// #include "../main/rom.h"
// #include "../device/r4300/tlb.h"
// #include "../device/r4300/r4300_core.h"
// #include "../device/memory/memory.h"
// TODO: need to log input and then call input.keyDown(keymod, keysym);
//
// # Variables
//
string rom_name = "UNKNOWN_ROM"; // ROM_PARAMS.headername
int corrupt_start = 0xb2b77c;
int corrupt_end = 0xb2b77c;
int difference = corrupt_end-corrupt_start;
void find_most_similar_function(uint32_t function_offset, string bytes);
bool libRR_finished_boot_rom = false;
string last_reversed_address = "";
bool should_reverse_jumps = false;
bool should_change_jumps = false;
int frame_last_reversed = 0;
int time_last_reversed = 0;
string libRR_game_name = "";
string ucode_crc = "";
// string next_dma_type = "";
// uint32_t previous_function = 0;
std::vector<uint32_t> function_stack = std::vector<uint32_t>();
std::vector<uint32_t> previous_ra; // previous return address
std::map<uint32_t, std::map<string, string> > addresses;
uint32_t rspboot = 0;
#define NUMBER_OF_MANY_READS 40
#define NUMBER_OF_MANY_WRITES 40
//
// # Toggles
//
bool support_n64_prints = false;
bool cdl_log_memory = false;
bool tag_functions = false;
bool log_notes = false;
bool log_function_calls = false;
bool log_ostasks = false;
bool log_rsp = false;
void cdl_keyevents(int keysym, int keymod) {
#ifndef USE_CDL
return;
#endif
printf("event_sdl_keydown frame:%d key:%d modifier:%d \n", l_CurFrame, keysym, keymod);
should_reverse_jumps = false;
// S key
if (keysym == 115) {
printf("Lets save! \n");
main_state_save(0, NULL);
}
// L Key
if (keysym == 108) {
printf("Lets load! \n");
main_state_load(NULL);
}
// Z Key
if (keysym == 122) {
write_rom_mapping();
cdl_log_memory = !cdl_log_memory;
tag_functions = !tag_functions;
// should_change_jumps = true;
//should_reverse_jumps = true;
// show_interface();
}
}
bool createdCartBackup = false;
void backupCart() {
// libRR_game_name = alphabetic_only_name((char*)rom_name.c_str(), 21);
std::cout << "TODO: backup";
createdCartBackup = true;
}
void resetCart() {
std::cout << "TODO: reset";
}
void readLibUltraSignatures() {
std::ifstream i("libultra.json");
if (i.good()) {
i >> libultra_signatures;
}
if (libultra_signatures.find("function_signatures") == libultra_signatures.end()) {
libultra_signatures["function_signatures"] = R"([])"_json;
}
}
void saveLibUltraSignatures() {
std::ofstream o("libultra.json");
o << libultra_signatures.dump(1) << std::endl;
}
void setTogglesBasedOnConfig() {
cdl_log_memory = reConfig["shouldLogMemory"];
tag_functions = reConfig["shouldTagFunctions"];
log_notes = reConfig["shouldLogNotes"];
log_function_calls = reConfig["shouldLogFunctionCalls"];
support_n64_prints = reConfig["shouldSupportN64Prints"];
log_ostasks = reConfig["shouldLogOsTasks"];
log_rsp = reConfig["shouldLogRsp"];
}
void readJsonFromFile() {
readLibUltraSignatures();
readJsonToObject("symbols.json", linker_map_file);
readJsonToObject("./reconfig.json", reConfig);
setTogglesBasedOnConfig();
string filename = "./configs/";
filename+=rom_name;
filename += ".json";
// read a JSON file
if (!reConfig["startFreshEveryTime"]) {
cout << "Reading previous game config file \n";
readJsonToObject(filename, fileConfig);
}
if (fileConfig.find("jumps") == fileConfig.end()) {
fileConfig["jumps"] = R"([])"_json;
}
if (fileConfig.find("tlbs") == fileConfig.end()) {
fileConfig["tlbs"] = R"([])"_json;
}
if (fileConfig.find("dmas") == fileConfig.end()) {
fileConfig["dmas"] = R"([])"_json;
}
if (fileConfig.find("rsp_reads") == fileConfig.end()) {
fileConfig["rsp_reads"] = R"([])"_json;
}
if (fileConfig.find("rdram_reads") == fileConfig.end())
fileConfig["rdram_reads"] = R"([])"_json;
if (fileConfig.find("reversed_jumps") == fileConfig.end())
fileConfig["reversed_jumps"] = R"({})"_json;
if (fileConfig.find("labels") == fileConfig.end())
fileConfig["labels"] = R"([])"_json;
if (fileConfig.find("jump_returns") == fileConfig.end())
fileConfig["jump_returns"] = R"([])"_json;
if (fileConfig.find("memory_to_log") == fileConfig.end())
fileConfig["memory_to_log"] = R"([])"_json;
memory_to_log = fileConfig["memory_to_log"].get< std::map<uint32_t,string> >();
memory_to_log[0x0E5320] = "rsp.boot";
jumps = fileConfig["jumps"].get< std::map<uint32_t,char> >();
tlbs = fileConfig["tlbs"].get< std::map<uint32_t,cdl_tlb> >();
dmas = fileConfig["dmas"].get< std::map<uint32_t,cdl_dma> >();
rsp_reads = fileConfig["rsp_reads"].get< std::map<uint32_t,uint32_t> >();
rdram_reads = fileConfig["rdram_reads"].get< std::map<uint32_t,uint32_t> >();
labels = fileConfig["labels"].get< std::map<uint32_t,cdl_labels> >();
jump_returns = fileConfig["jump_returns"].get< std::map<uint32_t,cdl_jump_return> >();
}
void saveJsonToFile() {
string filename = "./configs/";
filename += rom_name;
filename += ".json";
std::ofstream o(filename);
o << fileConfig.dump(1) << std::endl;
}
void show_interface() {
int answer;
std::cout << "1) Reset ROM 2) Change corrupt number ";
std::cin >> std::hex >> answer;
if (answer == 1) {
std::cout << "Resetting ROM";
resetCart();
}
else {
std::cout << "Unknown command";
}
printf("Answer: %d \n", answer);
}
void corrupt_if_in_range(uint8_t* mem, uint32_t proper_cart_address) {
// if (proper_cart_address >= corrupt_start && proper_cart_address <= corrupt_end) { //l_CurFrame == 0x478 && length == 0x04) { //} proper_cart_address == 0xb4015c) {
// printf("save_state_before\n");
// main_state_save(0, "before_corruption");
// printBytes(mem, proper_cart_address);
// printf("MODIFIED IT!! %#08x\n\n\n", mem[proper_cart_address+1]);
// corruptBytes(mem, proper_cart_address, 10);
// printBytes(mem, proper_cart_address);
// }
}
void corruptBytes(uint8_t* mem, uint32_t cartAddr, int times) {
#ifndef USE_CDL
return;
#endif
if (times>difference) {
times=difference/4;
}
// srand(time(NULL)); //doesn't work on windows
printf("Corrupt Start: %d End: %d Difference: %d \n", corrupt_start, corrupt_end, difference);
int randomNewValue = rand() % 0xFF;
for (int i=0; i<=times; i++) {
int randomOffset = rand() % difference;
int currentOffset = randomOffset;
printf("Offset: %d OldValue: %#08x NewValue: %#08x \n", currentOffset, mem[cartAddr+currentOffset], randomNewValue);
mem[cartAddr+currentOffset] = randomNewValue;
}
}
void cdl_log_opcode(uint32_t program_counter, uint8_t* op_address) {
// only called in pure_interp mode
// jump_data[program_counter] = op_address;
// if (!labels[function_stack.back()].generatedSignature) {
// printf("Not generated sig yet: %#08x \n", *op_address);
// }
}
int note_count = 0;
void add_note(uint32_t pc, uint32_t target, string problem) {
if (!log_notes) return;
if (labels[function_stack.back()].doNotLog) return;
std::stringstream sstream;
sstream << std::hex << "pc:0x" << pc << "-> 0x" << target;
sstream << problem << " noteNumber:"<<note_count;
// cout << sstream.str();
labels[function_stack.back()].notes[pc] = sstream.str();
note_count++;
}
uint32_t map_assembly_offset_to_rom_offset(uint32_t assembly_offset, uint32_t tlb_mapped_addr) {
// or if its in KSEG0/1
if (assembly_offset >= 0x80000000) {
uint32_t mapped_offset = assembly_offset & UINT32_C(0x1ffffffc);
// std::cout << "todo:" << std::hex << assembly_offset << "\n";
return map_assembly_offset_to_rom_offset(mapped_offset, assembly_offset);
}
for(auto it = tlbs.begin(); it != tlbs.end(); ++it) {
auto t = it->second;
if (assembly_offset>=t.start && assembly_offset <=t.end) {
uint32_t mapped_offset = t.rom_offset + (assembly_offset-t.start);
return map_assembly_offset_to_rom_offset(mapped_offset, assembly_offset);
}
}
for(auto it = dmas.begin(); it != dmas.end(); ++it) {
auto& t = it->second;
if (assembly_offset>=t.dram_start && assembly_offset <=t.dram_end) {
uint32_t mapped_offset = t.rom_start + (assembly_offset-t.dram_start);
t.is_assembly = true;
t.tbl_mapped_addr = tlb_mapped_addr;
// DMA is likely the actual value in rom
return mapped_offset;
}
}
// std::cout << "Not in dmas:" << std::hex << assembly_offset << "\n";
// std::cout << "Unmapped: " << std::hex << assembly_offset << "\n";
return assembly_offset;
}
uint32_t current_function = 0;
void log_dma_write(uint8_t* mem, uint32_t proper_cart_address, uint32_t cart_addr, uint32_t length, uint32_t dram_addr) {
if (dmas.find(proper_cart_address) != dmas.end() )
return;
auto t = cdl_dma();
t.dram_start=dram_addr;
t.dram_end = dram_addr+length;
t.rom_start = proper_cart_address;
t.rom_end = proper_cart_address+length;
t.length = length;
t.ascii_header = get_header_ascii(mem, proper_cart_address);
t.header = mem[proper_cart_address+3];
t.frame = l_CurFrame;
// if (function_stack.size() > 0 && labels.find(current_function) != labels.end()) {
t.func_addr = print_function_stack_trace(); // labels[current_function].func_name;
// }
dmas[proper_cart_address] = t;
// std::cout << "DMA: Dram:0x" << std::hex << t.dram_start << "->0x" << t.dram_end << " Length:0x" << t.length << " " << t.ascii_header << " Stack:" << function_stack.size() << " " << t.func_addr << " last:"<< function_stack.back() << "\n";
}
void cdl_finish_pi_dma(uint32_t a) {
// cout <<std::hex<< "Finish PI DMA:" << a << "\n";
}
void cdl_finish_si_dma(uint32_t a) {
cout <<std::hex<< "Finish SI DMA:" << a << "\n";
}
void cdl_finish_ai_dma(uint32_t a) {
// cout <<std::hex<< "Finish AI DMA:" << (a & 0xffffff) << "\n";
}
void cdl_clear_dma_log() {
// next_dma_type = "cleared";
}
void cdl_clear_dma_log2() {
// next_dma_type = "interesting";
}
void cdl_log_cart_reg_access() {
// next_dma_type = "bin";
add_tag_to_function("_cartRegAccess", function_stack.back());
}
void cdl_log_dma_si_read() {
add_tag_to_function("_dmaSiRead", function_stack.back());
}
void cdl_log_copy_pif_rdram() {
add_tag_to_function("_copyPifRdram", function_stack.back());
}
void cdl_log_si_reg_access() {
// COntrollers, rumble paks etc
add_tag_to_function("_serialInterfaceRegAccess", function_stack.back());
}
void cdl_log_mi_reg_access() {
// The MI performs the read, modify, and write operations for the individual pixels at either one pixel per clock or one pixel for every two clocks. The MI also has special modes for loading the TMEM, filling rectangles (fast clears), and copying multiple pixels from the TMEM into the framebuffer (sprites).
add_tag_to_function("_miRegRead", function_stack.back());
}
void cdl_log_mi_reg_write() {
// The MI performs the read, modify, and write operations for the individual pixels at either one pixel per clock or one pixel for every two clocks. The MI also has special modes for loading the TMEM, filling rectangles (fast clears), and copying multiple pixels from the TMEM into the framebuffer (sprites).
add_tag_to_function("_miRegWrite", function_stack.back());
}
void cdl_log_pi_reg_read() {
if (function_stack.size() > 0)
add_tag_to_function("_piRegRead", function_stack.back());
}
void cdl_log_pi_reg_write() {
if (function_stack.size() > 0)
add_tag_to_function("_piRegWrite", function_stack.back());
}
void cdl_log_read_rsp_regs2() {
add_tag_to_function("_rspReg2Read", function_stack.back());
}
void cdl_log_write_rsp_regs2() {
add_tag_to_function("_rspReg2Write", function_stack.back());
}
void cdl_log_read_rsp_regs() {
if (function_stack.size() > 0)
add_tag_to_function("_rspRegRead", function_stack.back());
}
void cdl_log_write_rsp_regs() {
if (function_stack.size() > 0)
add_tag_to_function("_rspRegWrite", function_stack.back());
}
void cdl_log_update_sp_status() {
if (function_stack.size() > 0)
add_tag_to_function("_updatesSPStatus", function_stack.back());
}
void cdl_common_log_tag(const char* tag) {
if (function_stack.size() > 0)
add_tag_to_function(tag, function_stack.back());
}
void cdl_log_audio_reg_access() {
// TODO speed this up with a check first
add_tag_to_function("_audioRegAccess", function_stack.back());
}
string print_function_stack_trace() {
if (function_stack.size() ==0 || functions.size() ==0 /*|| labels.size() ==0*/ || function_stack.size() > 0xF) {
return "";
}
std::stringstream sstream;
int current_stack_number = 0;
for (auto& it : function_stack) {
if (strcmp(functions[it].func_name.c_str(),"") == 0) {
sstream << "0x" << std::hex << it<< "->";
continue;
}
if (current_stack_number>0) {
sstream << "->";
}
sstream << functions[it].func_name;
current_stack_number++;
}
// cout << "Stack:"<< sstream.str() << "\n";
return sstream.str();
}
void resetReversing() {
// time_last_reversed = time(0); // doesn;t work on windows
last_reversed_address="";
}
void save_cdl_files() {
resetReversing();
find_asm_sections();
find_audio_sections();
find_audio_functions();
save_dram_rw_to_json();
saveJsonToFile();
saveLibUltraSignatures();
}
uint32_t cdl_get_alternative_jump(uint32_t current_jump) {
if (!should_change_jumps) {
return current_jump;
}
for (auto& it : linker_map_file.items()) {
uint32_t new_jump = hex_to_int(it.key());
cout << "it:" << it.value() << " = " << it.key() << " old:" << current_jump << " new:"<< new_jump << "\n";
linker_map_file.erase(it.key());
should_change_jumps = false;
return new_jump;
}
return current_jump;
}
int reverse_jump(int take_jump, uint32_t jump_target) {
// this function doesn't work on windows
// time_t now = time(0);
// string key = n2hexstr(jump_target);
// printf("Reversing jump %#08x %d \n", jump_target, jumps[jump_target]);
// take_jump = !take_jump;
// time_last_reversed = now;
// frame_last_reversed=l_CurFrame;
// last_reversed_address = key;
// fileConfig["reversed_jumps"][key] = jumps[jump_target];
// write_rom_mapping();
return take_jump;
}
void cdl_log_jump_cached(int take_jump, uint32_t jump_target, uint8_t* jump_target_memory) {
if (cached_jumps.find(jump_target) != cached_jumps.end() )
return;
cached_jumps[jump_target] = 1;
cout << "Cached:" << std::hex << jump_target << "\n";
}
int number_of_functions = 0;
bool libRR_full_function_log = false;
bool libRR_full_trace_log = true;
int last_return_address = 0;
uint32_t libRR_call_depth = 0; // Tracks how big our stack trace is in terms of number of function calls
// We store the stackpointers in backtrace_stackpointers everytime a function gets called
uint16_t libRR_backtrace_stackpointers[0x200]; // 0x200 should be tons of function calls
uint32_t libRR_backtrace_size = 0; // Used with backtrace_stackpointers - Tracks how big our stack trace is in terms of number of function calls
extern uint32_t libRR_pc_lookahead;
string current_trace_log = "";
const int trace_messages_until_flush = 40;
int current_trace_count = 0;
bool first_trace_write = true;
void libRR_log_trace_str(string message) {
if (!libRR_full_trace_log) {
return;
}
current_trace_log += message + "\n";
current_trace_count++;
if (current_trace_count >= trace_messages_until_flush) {
libRR_log_trace_flush();
current_trace_count = 0;
current_trace_log="";
}
}
void libRR_log_trace(const char* message) {
libRR_log_trace_str(message);
}
void libRR_log_trace_flush() {
if (!libRR_full_trace_log) {
return;
}
string output_file_path = libRR_export_directory + "trace_log.txt";
if (first_trace_write) {
codeDataLogger::writeStringToFile(output_file_path, current_trace_log);
first_trace_write = false;
} else {
codeDataLogger::appendStringToFile(output_file_path, current_trace_log);
}
}
// libRR_log_return_statement
// stack_pointer is used to make sure our function stack doesn't exceed the actual stack pointer
void libRR_log_return_statement(uint32_t current_pc, uint32_t return_target, uint32_t stack_pointer) {
if (libRR_full_trace_log) {
libRR_log_trace_str("Return:"+n2hexstr(current_pc)+"->"+n2hexstr(return_target));
}
// printf("libRR_log_return_statement pc:%d return:%d stack:%d\n", current_pc, return_target, 65534-stack_pointer);
// check the integrety of the call stack
if (libRR_call_depth < 0) {
printf("Function seems to have returned without changing the stack, PC: %d \n", current_pc);
}
auto function_returning_from = function_stack.back();
auto presumed_return_address = previous_ra.back();
if (return_target != presumed_return_address) {
// printf("ERROR: Presumed return: %d actual return: %d current_pc: %d\n", presumed_return_address, return_target, current_pc);
// sometimes code manually pushes the ret value to the stack and returns
// if so we don't want to log as a function return
// but in the future we might want to consider making the previous jump a function call
return;
} else {
libRR_call_depth--;
// Remove from stacks
function_stack.pop_back();
previous_ra.pop_back();
}
if (!libRR_full_function_log) {
return;
}
current_pc -= libRR_pc_lookahead;
string current_function = n2hexstr(function_returning_from);
string current_pc_str = n2hexstr(current_pc);
// printf("Returning from function: %s current_pc:%s \n", current_function.c_str(), current_pc_str.c_str());
// string function_key = current_function;
playthough_function_usage[current_function]["returns"][current_pc_str] = return_target;
// Add max return to functions
if (functions.find(function_returning_from) != functions.end() ) {
uint32_t relative_return_pc = current_pc - function_returning_from;
if (relative_return_pc > functions[function_returning_from].return_offset_from_start) {
functions[function_returning_from].return_offset_from_start = relative_return_pc;
}
}
// TODO: Calculate Function Signature so we can check for its name
int length = current_pc - function_returning_from;
string length_str = n2hexstr(length);
playthough_function_usage[current_function]["lengths"][length_str] = length;
if (length > 0 && length < 200) {
if (playthough_function_usage[current_function]["signatures"].contains(length_str)) {
} else {
printf("Function Signature: About to get length: %d \n", length);
playthough_function_usage[current_function]["signatures"][n2hexstr(length)] = libRR_get_data_for_function(function_returning_from, length+1, true, true);
}
}
// string bytes_with_branch_delay = printBytesToStr(jump_data[previous_function_backup], byte_len+4)+"_"+n2hexstr(length+4);
// string word_pattern = printWordsToStr(jump_data[previous_function_backup], byte_len+4)+" L"+n2hexstr(length+4,4);
// TODO: need to get the moment where the bytes for the function are located
// printf("Logged inst: %s \n", name.c_str());
}
// libRR_log_full_function_call is expensive as it does extensive logging
void libRR_log_full_function_call(uint32_t current_pc, uint32_t jump_target) {
// Instead of using function name, we just use the location
string function_name = /*game_name + "_func_" +*/ n2hexstr(jump_target);
// printf("libRR_log_full_function_call Full function logging on %s \n", print_function_stack_trace().c_str());
// This is playthough specific
if (!playthough_function_usage.contains(function_name)) {
// printf("Adding new function %s \n", function_name.c_str());
playthough_function_usage[function_name] = json::parse("{}");
playthough_function_usage[function_name]["first_frame_access"] = RRCurrentFrame;
playthough_function_usage[function_name]["number_of_frames"]=0;
playthough_function_usage[function_name]["last_frame_access"] = 0;
playthough_function_usage[function_name]["number_of_calls_per_frame"] = 1;
}
else if (RRCurrentFrame < playthough_function_usage[function_name]["last_frame_access"]) {
// we have already ran this frame before, probably replaying, no need to add more logging
return;
}
if (RRCurrentFrame > playthough_function_usage[function_name]["last_frame_access"]) {
playthough_function_usage[function_name]["last_frame_access"] = RRCurrentFrame;
playthough_function_usage[function_name]["number_of_frames"]= (int)playthough_function_usage[function_name]["number_of_frames"]+1;
playthough_function_usage[function_name]["number_of_calls_per_frame"]=0;
}
else if (RRCurrentFrame == playthough_function_usage[function_name]["last_frame_access"]) {
// we are in the same frame so its called more than once per frame
playthough_function_usage[function_name]["number_of_calls_per_frame"]=(int)playthough_function_usage[function_name]["number_of_calls_per_frame"]+1;
}
// TODO: log read/writes to memory
// TODO: calculate return and paramerters
// TODO: find out how long the function is
}
const char* libRR_log_long_jump(uint32_t current_pc, uint32_t jump_target, const char* type) {
// cout << "Long Jump from:" << n2hexstr(current_pc) << " to:" << n2hexstr(jump_target) << "\n";
if (libRR_full_trace_log) {
libRR_log_trace_str("Long Jump:"+n2hexstr(current_pc)+"->"+n2hexstr(jump_target)+" type:"+type);
}
string target_bank_number = "0000";
string pc_bank_number = "0000";
target_bank_number = n2hexstr(get_current_bank_number_for_address(jump_target), 4);
// now we need the bank number of the function we are calling
pc_bank_number = n2hexstr(get_current_bank_number_for_address(current_pc), 4);
libRR_long_jumps[target_bank_number][n2hexstr(jump_target)][pc_bank_number+"::"+n2hexstr(current_pc)]=type;
return libRR_log_jump_label(jump_target, current_pc);
}
void libRR_log_interrupt_call(uint32_t current_pc, uint32_t jump_target) {
string pc_bank_number = "0000";
pc_bank_number = n2hexstr(get_current_bank_number_for_address(current_pc), 4);
// printf("Interrupt call at: %s::%s target:%s \n", pc_bank_number.c_str(), n2hexstr(current_pc).c_str(), n2hexstr(jump_target).c_str());
libRR_long_jumps["0000"][n2hexstr(jump_target)][pc_bank_number+"::"+n2hexstr(current_pc)]=true;
}
// Restarts are very similar to calls but can only jump to specific targets and only take up 1 byte
void libRR_log_rst(uint32_t current_pc, uint32_t jump_target) {
// for now just log it as a standard function call
libRR_log_function_call(current_pc, jump_target, 0x00);
}
string function_name = ""; // last function name called
const char* libRR_log_function_call(uint32_t current_pc, uint32_t jump_target, uint32_t stack_pointer) {
// TODO: find out why uncommeting the following causes a segfault
// if (!libRR_full_function_log || !libRR_finished_boot_rom) {
// return;
// }
string bank_number = "0000";
uint32_t calculated_jump_target = jump_target;
if (libRR_bank_switching_available) {
int bank = get_current_bank_number_for_address(jump_target);
bank_number = n2hexstr(bank, 4);
// TODO: the following might be gameboy specific
if (jump_target >= libRR_bank_size) {
// printf("TODO: remove this in gameboy!\n");
calculated_jump_target = jump_target + ((bank-1) * libRR_bank_size);
}
// END TODO
}
string jump_target_str = n2hexstr(jump_target);
function_name = "_"+bank_number+"_func_"+jump_target_str;
libRR_called_functions[bank_number][n2hexstr(jump_target)] = function_name;
libRR_log_trace_str("Function call: 0x"+jump_target_str);
// Start Stacktrace handling
libRR_call_depth++;
// End Stacktrace handling
last_return_address = current_pc;
function_stack.push_back(jump_target);
previous_ra.push_back(current_pc);
if (libRR_full_function_log) {
libRR_log_full_function_call(current_pc, jump_target);
}
if (functions.find(jump_target) != functions.end() ) {
// We have already logged this function, so ignore for now
return function_name.c_str();
}
// We have never logged this function so lets create it
auto t = cdl_labels();
t.func_offset = n2hexstr(calculated_jump_target);
// if (functions.find(previous_function_backup) != functions.end()) {
// t.caller_offset = functions[previous_function_backup].func_name+" (ra:"+n2hexstr(ra)+")";
// } else {
// t.caller_offset = n2hexstr(previous_function_backup);
// }
t.func_name = function_name; // /*libRR_game_name+*/"_"+bank_number+"_func_"+jump_target_str;
//t.func_stack = function_stack.size();
//t.export_path = "";
//t.bank_number = bank_number;
//t.bank_offset = jump_target;
// t.stack_trace = print_function_stack_trace();
t.doNotLog = false;
t.many_memory_reads = false;
t.many_memory_writes = false;
// t.additional["callers"][print_function_stack_trace()] = RRCurrentFrame;
printf("Logged new function: %s target:%d number_of_functions:%d \n", t.func_name.c_str(), jump_target, number_of_functions);
functions[jump_target] = t;
number_of_functions++;
return function_name.c_str();
}
// This will be replace be libRR_log_function_call
void log_function_call(uint32_t function_that_is_being_called) {
if (!log_function_calls) return;
uint32_t function_that_is_calling = function_stack.back();
if (labels.find(function_that_is_calling) == labels.end()) return;
if (labels[function_that_is_calling].isRenamed || labels[function_that_is_calling].doNotLog) return;
labels[function_that_is_calling].function_calls[function_that_is_being_called] = labels[function_that_is_being_called].func_name;
}
void cdl_log_jump_always(int take_jump, uint32_t jump_target, uint8_t* jump_target_memory, uint32_t ra, uint32_t pc) {
add_note(ra-8, pc, "Call (jal)");
previous_ra.push_back(ra);
uint32_t previous_function_backup = function_stack.back();
function_stack.push_back(jump_target);
current_function = jump_target;
if (jumps[jump_target] >3) return;
jumps[jump_target] = 0x04;
if (labels.find(jump_target) != labels.end() )
return;
log_function_call(jump_target);
auto t = cdl_labels();
string jump_target_str = n2hexstr(jump_target);
t.func_offset = jump_target_str;
if (labels.find(previous_function_backup) != labels.end()) {
t.caller_offset = labels[previous_function_backup].func_name+" (ra:"+n2hexstr(ra)+")";
} else {
t.caller_offset = n2hexstr(previous_function_backup);
}
t.func_name = libRR_game_name+"_func_"+jump_target_str;
t.func_stack = function_stack.size();
t.stack_trace = print_function_stack_trace();
t.doNotLog = false;
t.many_memory_reads = false;
t.many_memory_writes = false;
labels[jump_target] = t;
jump_data[jump_target] = jump_target_memory;
}
void cdl_log_jump_return(int take_jump, uint32_t jump_target, uint32_t pc, uint32_t ra, int64_t* registers, struct r4300_core* r4300) {
uint32_t previous_function_backup = -1;
if (!libRR_full_function_log || !libRR_finished_boot_rom) {
return;
}
// if (previous_function_backup > ra) {
// // cout << std::hex << " Odd the prev function start should never be before return address ra:" << ra << " previous_function_backup:" << previous_function_backup << "\n";
// return;
// }
if (function_stack.size()>0) {
previous_function_backup = function_stack.back();
}
else {
add_note(pc, jump_target, "function_stack <0");
// probably jumping from exception?
// cout << "Missed push back?" << std::hex << jump_target << " ra" << ra << " pc:"<< pc<< "\n";
// return;
}
if (jump_target == previous_ra.back()) {
add_note(pc, jump_target, "successful return");
} else {
string problem = "Expected $ra to be 0x";
problem += n2hexstr(previous_ra.back());
problem += " but was:";
problem += n2hexstr(jump_target);
add_note(pc, jump_target, problem);
// return;
}
function_stack.pop_back();
current_function = function_stack.back();
previous_ra.pop_back();
console_log_jump_return(take_jump, jump_target, pc, ra, registers, r4300);
if (jumps[jump_target] >3) return;
jumps[jump_target] = 0x04;
if (jump_returns.find(previous_function_backup) != jump_returns.end())
{
return;
}
auto t = cdl_jump_return();
string jump_target_str = n2hexstr(jump_target);
t.return_offset = pc;
t.func_offset = previous_function_backup;
t.caller_offset = jump_target;
jump_returns[previous_function_backup] = t;
uint64_t length = pc-previous_function_backup;
// labels[previous_function_backup].return_offset_from_start = length;
if (length<2) {
return;
}
if (jump_data.find(previous_function_backup) != jump_data.end()) {
uint64_t byte_len = length;
if (byte_len > 0xFFFF) {
byte_len = 0xFFFF;
}
// string bytes = printBytesToStr(jump_data[previous_function_backup], byte_len)+"_"+n2hexstr(length);
string bytes_with_branch_delay = printBytesToStr(jump_data[previous_function_backup], byte_len+4)+"_"+n2hexstr(length+4);
string word_pattern = printWordsToStr(jump_data[previous_function_backup], byte_len+4)+" L"+n2hexstr(length+4,4);
labels[previous_function_backup].function_bytes = bytes_with_branch_delay;
labels[previous_function_backup].doNotLog = true;
labels[previous_function_backup].generatedSignature = true;
// labels[previous_function_backup].function_bytes_endian = Swap4Bytes(bytes);
// now check to see if its in the mario map
// if (/*strcmp(game_name.c_str(),"SUPERMARIO") == 0 &&*/ linker_map_file.find( n2hexstr(previous_function_backup) ) != linker_map_file.end()) {
// string offset = n2hexstr(previous_function_backup);
// string func_name = linker_map_file[offset];
// cout << game_name << "It is in the map file!" << n2hexstr(previous_function_backup) << " as:" << linker_map_file[n2hexstr(previous_function_backup)] << "\n";
// function_signatures[bytes] = func_name;
// if (strcmp(func_name.c_str(),"gcc2_compiled.")==0) return; // we don't want gcc2_compiled labels
// libultra_signatures["function_signatures"][bytes_with_branch_delay] = func_name;
// labels[previous_function_backup].func_name = libultra_signatures["function_signatures"][bytes_with_branch_delay];
// return;
// }
// if it is a libultra function then lets name it
if (libultra_signatures["library_signatures"].find(word_pattern) != libultra_signatures["library_signatures"].end()) {
std::cout << "In library_signatures:" << word_pattern << " name:"<< libultra_signatures["library_signatures"][word_pattern] << "\n";
labels[previous_function_backup].func_name = libultra_signatures["library_signatures"][word_pattern];
labels[previous_function_backup].isRenamed = true;
// return since we have already named this functions, don't need its signature to be saved
return;
}
if (libultra_signatures["game_signatures"].find(word_pattern) != libultra_signatures["game_signatures"].end()) {
// std::cout << "In game_signatures:" << word_pattern << " name:"<< libultra_signatures["game_signatures"][word_pattern] << "\n";
labels[previous_function_backup].func_name = libultra_signatures["game_signatures"][word_pattern];
// return since we have already named this functions, don't need its signature to be saved
return;
}
// if it is a libultra function then lets name it
if (libultra_signatures["function_signatures"].find(bytes_with_branch_delay) != libultra_signatures["function_signatures"].end()) {
std::cout << "In old libultra:" << bytes_with_branch_delay << " name:"<< libultra_signatures["function_signatures"][bytes_with_branch_delay] << "\n";
labels[previous_function_backup].func_name = libultra_signatures["function_signatures"][bytes_with_branch_delay];
if (labels[previous_function_backup].func_name.find("_func_") != std::string::npos) {
// this is a non renamed function as it was auto generated
find_most_similar_function(previous_function_backup, word_pattern);
libultra_signatures["game_signatures"][word_pattern] = labels[previous_function_backup].func_name;
}
else {
libultra_signatures["library_signatures"][word_pattern] = labels[previous_function_backup].func_name;
labels[previous_function_backup].isRenamed = true;
}
libultra_signatures["function_signatures"].erase(bytes_with_branch_delay);
// return since we have already named this functions, don't need its signature to be saved
return;
}
// if it is an OLD libultra function then lets name it (without branch delay)
// if (libultra_signatures["function_signatures"].find(bytes) != libultra_signatures["function_signatures"].end()) {
// std::cout << "In OLDEST libultra:" << bytes << " name:"<< libultra_signatures["function_signatures"][bytes] << "\n";
// labels[previous_function_backup].func_name = libultra_signatures["function_signatures"][bytes];
// labels[previous_function_backup].isRenamed = true;
// libultra_signatures["function_signatures"][bytes_with_branch_delay] = labels[previous_function_backup].func_name;
// // delete the old non-branch delay version
// libultra_signatures["function_signatures"].erase(bytes);
// // return since we have already named this functions, don't need its signature to be saved
// return;
// }
find_most_similar_function(previous_function_backup, word_pattern);
// cout << "word_pattern:" << word_pattern << "\n";
if (function_signatures.find(word_pattern) == function_signatures.end()) {
// save this new function to both libultra and trace json
function_signatures[word_pattern] = labels[previous_function_backup].func_name;
libultra_signatures["game_signatures"][word_pattern] = labels[previous_function_backup].func_name;
} else {
//function_signatures.erase(bytes);
// function_signatures[word_pattern] = "Multiple functions";
std::cout << "Multiple Functions for :" << *jump_data[previous_function_backup] << " len:" << length << " pc:0x"<< pc << " - 0x" << previous_function_backup << "\n";
}
}
}
void find_most_similar_function(uint32_t function_offset, string bytes) {
string named_function_with_highest_distance = "";
// string auto_generated_function_with_highest_distance = "";
double highest_distance = 0;
// double highest_auto_distance = 0;
for(auto it = libultra_signatures["library_signatures"].begin(); it != libultra_signatures["library_signatures"].end(); ++it) {
double distance = jaro_winkler_distance(bytes.c_str(), it.key().c_str());
if (distance >= highest_distance) {
string function_name = it.value();
// if (!is_auto_generated_function_name(function_name)) {
if (distance == highest_distance) {
named_function_with_highest_distance += "_or_";
named_function_with_highest_distance += function_name;
} else {
highest_distance = distance;
named_function_with_highest_distance = function_name;
}
// } else {
// highest_auto_distance = distance;
// auto_generated_function_with_highest_distance=function_name;
// }
}
// cout << "IT:" << it.value() << " distance:" << jaro_winkler_distance(bytes_with_branch_delay.c_str(), it.key().c_str()) << "\n";
}
uint32_t highest_distance_percent = highest_distance*100;
// cout << "generated function_with_highest_distance to "<< std::hex << function_offset << " is:"<<auto_generated_function_with_highest_distance<<" with "<< std::dec << highest_auto_distance <<"%\n";
if (highest_distance_percent>=95) {
cout << "function will be renamed "<< std::hex << function_offset << " is:"<<named_function_with_highest_distance<<" with "<< std::dec << highest_distance_percent <<"%\n";
labels[function_offset].func_name = named_function_with_highest_distance;
labels[function_offset].isRenamed = true;
} else if (highest_distance_percent>=90) {
cout << "function_with_highest_distance to "<< std::hex << function_offset << " is:"<<named_function_with_highest_distance<<" with "<< std::dec << highest_distance_percent <<"%\n";
labels[function_offset].func_name += "_predict_"+named_function_with_highest_distance+"_";
labels[function_offset].func_name += (to_string(highest_distance_percent));
labels[function_offset].func_name += "percent";
}
}
// loop through and erse multiple functions
void erase_multiple_func_signatures() {
// function_signatures
// Multiple functions
}
bool is_auto_generated_function_name(string func_name) {
if (func_name.find("_func_") != std::string::npos) {
// this is a non renamed function as it was auto generated
return true;
}
return false;
}
unsigned int find_first_non_executed_jump() {
for(map<unsigned int, char>::iterator it = jumps.begin(); it != jumps.end(); ++it) {
if ((it->second+0) <3) {
return it->first;
}
}
return -1;
}
int cdl_log_jump(int take_jump, uint32_t jump_target, uint8_t* jump_target_memory, uint32_t pc, uint32_t ra) {
add_note(pc, jump_target, "jump");
// if (previous_ra.size() > 0 && ra != previous_ra.back()) {
// cdl_log_jump_always(take_jump, jump_target, jump_target_memory, ra, pc);
// //previous_ra.push_back(ra);
// return take_jump;
// }
// if (should_reverse_jumps)
// {
// time_t now = time(0);
// if (jumps[jump_target] < 3) {
// // should_reverse_jumps=false;
// if ( now-time_last_reversed > 2) { // l_CurFrame-frame_last_reversed >(10*5) ||
// take_jump = reverse_jump(take_jump, jump_target);
// }
// } else if (now-time_last_reversed > 15) {
// printf("Stuck fixing %d\n", find_first_non_executed_jump());
// take_jump=!take_jump;
// main_state_load(NULL);
// // we are stuck so lets load
// }
// }
if (take_jump) {
jumps[jump_target] |= 1UL << 0;
}
else {
jumps[jump_target] |= 1UL << 1;
}
return take_jump;
}
void save_table_mapping(int entry, uint32_t phys, uint32_t start,uint32_t end, bool isOdd) {
//printf("tlb_map:%d ODD Start:%#08x End:%#08x Phys:%#08x \n",entry, e->start_odd, e->end_odd, e->phys_odd);
uint32_t length = end-start;
auto t = cdl_tlb();
t.start=start;
t.end = end;
t.rom_offset = phys;
tlbs[phys]=t;
string key = "";
key+="[0x";
key+=n2hexstr(phys);
key+=", 0x";
key+=n2hexstr(phys+length);
key+="] Virtual: 0x";
key+=n2hexstr(start);
key+=" to 0x";
key+=n2hexstr(end);
if (isOdd)
key+=" Odd";
else
key+=" Even";
string value = "Entry:";
value += to_string(entry);
// value += " Frame:0x";
value += n2hexstr(l_CurFrame);
bool isInJson = fileConfig["tlb"].find(key) != fileConfig["tlb"].end();
if (isInJson) {
string original = fileConfig["tlb"][key];
bool isSameValue = (strcmp(original.c_str(), value.c_str()) == 0);
if (isSameValue) return;
// printf("isSameValue:%d \noriginal:%s \nnew:%s\n", isSameValue, original.c_str(), value.c_str());
return; // don't replace the original value as it is useful to match frame numbers to the mappings
}
fileConfig["tlb"][key] = value;
printf("TLB %s\n", value.c_str());
}
void cdl_log_dram_read(uint32_t address) {
}
void cdl_log_dram_write(uint32_t address, uint32_t value, uint32_t mask) {
}
void cdl_log_rsp_mem(uint32_t address, uint32_t* mem,int isBootRom) {
if (isBootRom) return;
rsp_reads[address] = (uint32_t)*mem;
}
void cdl_log_rdram(uint32_t address, uint32_t* mem,int isBootRom) {
//printf("RDRAM %#08x \n", address);
if (isBootRom) return;
rdram_reads[address] = (uint32_t)*mem;
}
void cdl_log_mm_cart_rom(uint32_t address,int isBootRom) {
printf("Cart ROM %#08x \n", address);
}
void cdl_log_mm_cart_rom_pif(uint32_t address,int isBootRom) {
printf("PIF? %#08x \n", address);
}
void cdl_log_pif_ram(uint32_t address, uint32_t* value) {
#ifndef USE_CDL
return;
#endif
printf("Game was reset? \n");
if (!createdCartBackup) {
backupCart();
readJsonFromFile();
function_stack.push_back(0);
}
if (should_reverse_jumps) {
// should_reverse_jumps = false;
fileConfig["bad_jumps"][last_reversed_address] = "reset";
main_state_load(NULL);
write_rom_mapping();
}
}
void cdl_log_opcode_error() {
printf("Very bad opcode, caused crash! \n");
fileConfig["bad_jumps"][last_reversed_address] = "crash";
main_state_load(NULL);
}
void find_asm_sections() {
printf("finding asm in sections \n");
for(map<unsigned int, char>::iterator it = jumps.begin(); it != jumps.end(); ++it) {
string jump_target_str = n2hexstr(it->first);
fileConfig["jumps_rom"][jump_target_str] = n2hexstr(map_assembly_offset_to_rom_offset(it->first,0));
}
}
void find_audio_sections() {
printf("finding audio sections \n");
for(map<uint32_t, cdl_dma>::iterator it = dmas.begin(); it != dmas.end(); ++it) {
uint32_t address = it->second.dram_start;
if (audio_address.find(address) == audio_address.end() )
continue;
dmas[address].guess_type = "audio";
it->second.guess_type="audio";
}
}
void add_tag_to_function(string tag, uint32_t labelAddr) {
if (!tag_functions || labels[labelAddr].isRenamed) return;
if (labels[labelAddr].func_name.find(tag) != std::string::npos) return;
labels[labelAddr].func_name += tag;
}
void find_audio_functions() {
printf("finding audio functions \n");
for(map<uint32_t, cdl_labels>::iterator it = labels.begin(); it != labels.end(); ++it) {
cdl_labels label = it->second;
if (label.isRenamed) {
continue; // only do it for new functions
}
if (label.many_memory_reads) {
add_tag_to_function("_manyMemoryReads", it->first);
}
if (label.many_memory_writes) {
add_tag_to_function("_manyMemoryWrites", it->first);
}
for(map<string, string>::iterator it2 = label.read_addresses.begin(); it2 != label.read_addresses.end(); ++it2) {
uint32_t address = hex_to_int(it2->first);
if (audio_address.find(address) != audio_address.end() )
{
cout << "Function IS audio:"<< label.func_name << "\n";
}
if (address>0x10000000 && address <= 0x107fffff) {
cout << "Function accesses cart rom:"<< label.func_name << "\n";
}
}
for(map<string, string>::iterator it2 = label.write_addresses.begin(); it2 != label.write_addresses.end(); ++it2) {
uint32_t address = hex_to_int(it2->first);
if (audio_address.find(address) != audio_address.end() )
{
cout << "Function IS audio:"<< label.func_name << "\n";
}
if (address>0x10000000 && address <= 0x107fffff) {
cout << "Function IS cart rom:"<< label.func_name << "\n";
}
}
}
}
bool isAddressCartROM(uint32_t address) {
return (address>0x10000000 && address <= 0x107fffff);
}
void cdl_log_audio_sample(uint32_t saved_ai_dram, uint32_t saved_ai_length) {
if (audio_samples.find(saved_ai_dram) != audio_samples.end() )
return;
auto t = cdl_dram_cart_map();
t.dram_offset = n2hexstr(saved_ai_dram);
t.rom_offset = n2hexstr(saved_ai_length);
audio_samples[saved_ai_dram] = t;
// printf("audio_plugin_push_samples AI_DRAM_ADDR_REG:%#08x length:%#08x\n", saved_ai_dram, saved_ai_length);
}
void cdl_log_cart_rom_dma_write(uint32_t dram_addr, uint32_t cart_addr, uint32_t length) {
if (cart_rom_dma_writes.find(cart_addr) != cart_rom_dma_writes.end() )
return;
auto t = cdl_dram_cart_map();
t.dram_offset = n2hexstr(dram_addr);
t.rom_offset = n2hexstr(cart_addr);
cart_rom_dma_writes[cart_addr] = t;
printf("cart_rom_dma_write: dram_addr:%#008x cart_addr:%#008x length:%#008x\n", dram_addr, cart_addr, length);
}
void cdl_log_dma_sp_write(uint32_t spmemaddr, uint32_t dramaddr, uint32_t length, unsigned char *dram) {
if (dma_sp_writes.find(dramaddr) != dma_sp_writes.end() )
return;
auto t = cdl_dram_cart_map();
t.dram_offset = n2hexstr(dramaddr);
t.rom_offset = n2hexstr(spmemaddr);
dma_sp_writes[dramaddr] = t;
// FrameBuffer RSP info
printWords(dram, dramaddr, length);
printf("FB: dma_sp_write SPMemAddr:%#08x Dramaddr:%#08x length:%#08x \n", spmemaddr, dramaddr, length);
}
inline void cdl_log_memory_common(const uint32_t lsaddr, uint32_t pc) {
// if (addresses.find(lsaddr) != addresses.end() )
// return;
// addresses[lsaddr] = currentMap;
}
void cdl_log_mem_read(const uint32_t lsaddr, uint32_t pc) {
if (!cdl_log_memory) return;
if (memory_to_log.find(lsaddr) != memory_to_log.end() )
{
cout << "Logging Mem Read for 0x"<< std::hex << lsaddr << " At PC:" << pc <<"\n";
}
if (labels[current_function].isRenamed || labels[current_function].doNotLog) {
// only do it for new functions
return;
}
if (labels[current_function].read_addresses.size() > NUMBER_OF_MANY_READS) {
labels[current_function].many_memory_reads = true;
return;
}
// auto currentMap = addresses[lsaddr];
// currentMap[n2hexstr(lsaddr)]=labels[current_function].func_name+"("+n2hexstr(current_function)+"+"+n2hexstr(pc-current_function)+")";
auto offset = pc-current_function;
labels[current_function].read_addresses[n2hexstr(lsaddr)] = "func+0x"+n2hexstr(offset)+" pc=0x"+n2hexstr(pc);
}
void cdl_log_mem_write(const uint32_t lsaddr, uint32_t pc) {
if (!cdl_log_memory) return;
if (memory_to_log.find(lsaddr) != memory_to_log.end() )
{
cout << "Logging Mem Write to 0x"<< std::hex << lsaddr << " At PC:" << pc <<"\n";
}
if (labels[current_function].isRenamed || labels[current_function].doNotLog) {
// only do it for new functions
return;
}
if (labels[current_function].write_addresses.size() > NUMBER_OF_MANY_WRITES) {
labels[current_function].many_memory_writes = true;
return;
}
// auto currentMap = addresses[lsaddr];
// currentMap[n2hexstr(lsaddr)]=labels[current_function].func_name+"("+n2hexstr(current_function)+"+"+n2hexstr(pc-current_function)+")";
auto offset = pc-current_function;
labels[current_function].write_addresses[n2hexstr(lsaddr)] = "+0x"+n2hexstr(offset)+" pc=0x"+n2hexstr(pc);
}
void cdl_hit_memory_log_point(uint32_t address) {
if (address>0x10000000 && address <= 0x107fffff) {
cout << "Cart Memory access!" << std::hex << address << " in:" << labels[current_function].func_name << "\n";
}
}
void cdl_log_masked_write(uint32_t* address, uint32_t dst2) {
if (!cdl_log_memory) return;
// cout << "masked write:"<<std::hex<<dst<<" : "<<dst2<<"\n";
// if (memory_to_log.find(address) != memory_to_log.end() )
// {
// cout << "Logging Mem Write to 0x"<< std::hex << address << " At PC:" <<"\n";
// }
}
void cdl_log_get_mem_handler(uint32_t address) {
if (!cdl_log_memory) return;
cdl_hit_memory_log_point(address);
if (memory_to_log.find(address) != memory_to_log.end() )
{
cout << "Logging Mem cdl_log_get_mem_handler access 0x"<< std::hex << address <<"\n";
cdl_hit_memory_log_point(address);
}
}
void cdl_log_mem_read32(uint32_t address) {
if (!cdl_log_memory) return;
cdl_hit_memory_log_point(address);
if (memory_to_log.find(address) != memory_to_log.end() )
{
cout << "Logging Mem cdl_log_mem_read32 access 0x"<< std::hex << address <<"\n";
cdl_hit_memory_log_point(address);
}
}
void cdl_log_mem_write32(uint32_t address) {
if (!cdl_log_memory) return;
cdl_hit_memory_log_point(address);
if (memory_to_log.find(address) != memory_to_log.end() )
{
cout << "Logging Mem cdl_log_mem_write32 access 0x"<< std::hex << address <<"\n";
cdl_hit_memory_log_point(address);
}
}
string mapping_names[] = {
"M64P_MEM_NOTHING",
"M64P_MEM_NOTHING",
"M64P_MEM_RDRAM",
"M64P_MEM_RDRAMREG",
"M64P_MEM_RSPMEM",
"M64P_MEM_RSPREG",
"M64P_MEM_RSP",
"M64P_MEM_DP",
"M64P_MEM_DPS",
"M64P_MEM_VI",
"M64P_MEM_AI",
"M64P_MEM_PI",
"M64P_MEM_RI",
"M64P_MEM_SI",
"M64P_MEM_FLASHRAMSTAT",
"M64P_MEM_ROM",
"M64P_MEM_PIF",
"M64P_MEM_MI"
};
#define OSTASK_GFX 1
#define OSTASK_AUDIO 2
void cdl_log_ostask(uint32_t type, uint32_t flags, uint32_t bootcode, uint32_t bootSize, uint32_t ucode, uint32_t ucodeSize, uint32_t ucodeData, uint32_t ucodeDataSize) {
if (!log_ostasks) return;
if (rspboot == 0) {
rspboot = map_assembly_offset_to_rom_offset(bootcode,0);
auto bootDma = cdl_dma();
bootDma.dram_start=rspboot;
bootDma.dram_end = rspboot+bootSize;
bootDma.rom_start = rspboot;
bootDma.rom_end = rspboot+bootSize;
bootDma.length = bootSize;
bootDma.frame = l_CurFrame;
bootDma.func_addr = print_function_stack_trace();
bootDma.known_name = "rsp.boot";
dmas[rspboot] = bootDma;
}
uint32_t ucodeRom = map_assembly_offset_to_rom_offset(ucode,0);
if (dmas.find(ucodeRom) != dmas.end() )
return;
printf("OSTask type:%#08x flags:%#08x bootcode:%#08x ucode:%#08x ucodeSize:%#08x ucodeData:%#08x ucodeDataSize:%#08x \n", type, flags, bootcode, ucode, ucodeSize, ucodeData, ucodeDataSize);
uint32_t ucodeDataRom = map_assembly_offset_to_rom_offset(ucodeData,0);
auto data = cdl_dma();
data.dram_start=ucodeData;
data.dram_end = ucodeData+ucodeDataSize;
data.rom_start = ucodeDataRom;
data.rom_end = ucodeDataRom+ucodeDataSize;
data.length = ucodeDataSize;
data.frame = l_CurFrame;
data.func_addr = print_function_stack_trace();
data.is_assembly = false;
auto t = cdl_dma();
t.dram_start=ucode;
t.dram_end = ucode+ucodeSize;
t.rom_start = ucodeRom;
t.rom_end = ucodeRom+ucodeSize;
t.length = ucodeSize;
t.frame = l_CurFrame;
t.func_addr = print_function_stack_trace();
t.is_assembly = false;
if (type == OSTASK_AUDIO) {
t.guess_type = "rsp.audio";
t.ascii_header = "rsp.audio";
t.known_name = "rsp.audio";
data.ascii_header = "rsp.audio.data";
data.known_name = "rsp.audio.data";
} else if (type == OSTASK_GFX) {
t.guess_type = "rsp.graphics";
t.ascii_header = "rsp.graphics";
t.known_name = "rsp.graphics";
data.ascii_header = "rsp.graphics.data";
data.known_name = "rsp.graphics.data";
} else {
printf("other type:%#08x ucode:%#08x \n",type, ucodeRom);
}
dmas[ucodeRom] = t;
dmas[ucodeDataRom] = data;
}
#define CDL_ALIST 0
#define CDL_UCODE_CRC 2
void cdl_log_rsp(uint32_t log_type, uint32_t address, const char * extra_data) {
if (!log_rsp) return;
if (log_type == CDL_ALIST) {
if (audio_address.find(address) != audio_address.end() )
return;
audio_address[address] = n2hexstr(address)+extra_data;
// cout << "Alist address:" << std::hex << address << " " << extra_data << "\n";
return;
}
if (log_type == CDL_UCODE_CRC) {
ucode_crc = n2hexstr(address);
return;
}
cout << "Log rsp\n";
}
void cdl_log_dpc_reg_write(uint32_t address, uint32_t value, uint32_t mask) {
cdl_common_log_tag("writeDPCRegs");
}
} // end extern C
// C++
uint32_t libRR_offset_to_look_for = 0x8149;
bool libRR_enable_look = false;
json libRR_disassembly = {};
json libRR_memory_reads = {};
json libRR_consecutive_rom_reads = {};
json libRR_called_functions = {};
json libRR_long_jumps = {};
int32_t previous_consecutive_rom_read = 0; // previous read address to check if this read is part of the chain
int16_t previous_consecutive_rom_bank = 0; // previous read address to check if this read is part of the chain
int32_t current_consecutive_rom_start = 0; // start address of the current chain
bool replace(std::string& str, const std::string from, const std::string to) {
size_t start_pos = str.find(from);
if(start_pos == std::string::npos)
return false;
str.replace(start_pos, from.length(), to);
return true;
}
extern "C" void libRR_log_dma(int32_t offset) {
if (offset> 0x7fff) {
return;
}
cout << "DMA: " << n2hexstr(offset) << "\n";
}
static string label_name = "";
extern "C" const char* libRR_log_jump_label_with_name(uint32_t offset, uint32_t current_pc, const char* label_name) {
if (!libRR_full_function_log || !libRR_finished_boot_rom) {
return "";
}
string offset_str = n2hexstr(offset);
int bank = get_current_bank_number_for_address(offset);
string current_bank_str = n2hexstr(bank, 4);
if (offset >libRR_slot_2_max_addr) {
// if its greater than the max bank value then its probably in ram
return "";
}
// debugging code start
if (libRR_enable_look && (offset == libRR_offset_to_look_for || current_pc == libRR_offset_to_look_for)) {
printf("Found long jump label with name offset: %d\n", libRR_offset_to_look_for);
}
// debugging code end
// string label_name = "LAB_" + current_bank_str + "_" + n2hexstr(offset);
if (!libRR_disassembly[current_bank_str][offset_str].contains("label_name")) {
libRR_disassembly[current_bank_str][offset_str]["label_name"] = label_name;
}
libRR_disassembly[current_bank_str][offset_str]["meta"]["label_callers"][current_bank_str + "_" + n2hexstr(current_pc)] = true;
return label_name;
}
extern "C" const char* libRR_log_jump_label(uint32_t offset, uint32_t current_pc) {
if (!libRR_full_function_log || !libRR_finished_boot_rom) {
return "_not_logging";
}
string offset_str = n2hexstr(offset);
int bank = get_current_bank_number_for_address(offset);
string current_bank_str = n2hexstr(bank, 4);
if (offset >libRR_slot_2_max_addr) {
// if its greater than the max bank value then its probably in ram
return "max_bank_value";
}
// debugging code start
if (libRR_enable_look && (offset == libRR_offset_to_look_for || current_pc == libRR_offset_to_look_for)) {
printf("Found long jump label offset: %d\n", libRR_offset_to_look_for);
}
// debugging code end
label_name = "LAB_" + current_bank_str + "_" + n2hexstr(offset);
// return libRR_log_jump_label_with_name(offset, current_pc, label_name.c_str());
if (!libRR_disassembly[current_bank_str][offset_str].contains("label_name")) {
libRR_disassembly[current_bank_str][offset_str]["label_name"] = label_name;
}
libRR_disassembly[current_bank_str][offset_str]["meta"]["label_callers"][current_bank_str + "_" + n2hexstr(current_pc)] = true;
return label_name.c_str();
}
extern "C" void libRR_log_memory_read(int8_t bank, int32_t offset, const char* type, uint8_t byte_size, char* bytes) {
libRR_log_rom_read(bank, offset, type, byte_size, bytes);
}
extern "C" void libRR_log_rom_read(int16_t bank, int32_t offset, const char* type, uint8_t byte_size, char* bytes) {
string bank_str = n2hexstr(bank, 4);
string previous_bank_str = n2hexstr(previous_consecutive_rom_bank, 4);
string offset_str = n2hexstr(offset);
string current_consecutive_rom_start_str = n2hexstr(current_consecutive_rom_start);
if (libRR_full_trace_log) {
libRR_log_trace_str("Rom Read bank:"+bank_str+":"+n2hexstr(offset)+" = "+n2hexstr(bytes[0], 2));
}
// Check to see if the last read address is the same or 1 away
// Check for the same is because sometimes data is checked by reading the first byte
if (previous_consecutive_rom_bank == bank && previous_consecutive_rom_read == offset) {
// do nothing if its the same byte read twice
previous_consecutive_rom_bank = bank;
libRR_consecutive_rom_reads[previous_bank_str][current_consecutive_rom_start_str]["length"] = 1;
return;
}
if (previous_consecutive_rom_bank == bank && previous_consecutive_rom_read == (offset-1)) {
if (libRR_consecutive_rom_reads[previous_bank_str][current_consecutive_rom_start_str].is_null()) {
// check to see if the current read is null and if so create it
libRR_consecutive_rom_reads[previous_bank_str][current_consecutive_rom_start_str]["length"] = 1+ byte_size;
} else {
libRR_consecutive_rom_reads[previous_bank_str][current_consecutive_rom_start_str]["length"] = ((uint32_t) libRR_consecutive_rom_reads[previous_bank_str][current_consecutive_rom_start_str]["length"]) +byte_size;
}
for (int i=0; i<byte_size; i++) {
libRR_consecutive_rom_reads[previous_bank_str][current_consecutive_rom_start_str]["value"][n2hexstr(offset+i)] = n2hexstr(bytes[i]);
}
}
else {
// cout << "previous consecutive length from:" << (int)previous_consecutive_rom_bank << "::" << n2hexstr(current_consecutive_rom_start) << " -> " << n2hexstr(previous_consecutive_rom_read) << " len:" << libRR_consecutive_rom_reads[previous_bank_str][current_consecutive_rom_start_str]["length"] << "\n";
current_consecutive_rom_start = offset;
current_consecutive_rom_start_str = n2hexstr(current_consecutive_rom_start);
// initialise new consecutive run
libRR_consecutive_rom_reads[bank_str][current_consecutive_rom_start_str]["length"] = 1;
for (int i=0; i<byte_size; i++) {
libRR_consecutive_rom_reads[bank_str][current_consecutive_rom_start_str]["value"][n2hexstr(offset+i)] = n2hexstr(bytes[i]);
}
}
previous_consecutive_rom_read = offset+(byte_size-1); // add byte_size to take into account 2 byte reads
previous_consecutive_rom_bank = bank;
string value_str = "";
if (byte_size == 2) {
value_str = n2hexstr(two_bytes_to_16bit_value(bytes[1], bytes[0]));
} else {
value_str = n2hexstr(bytes[0]);
}
// printf("Access data: %d::%s type: %s size: %d value: %s\n", bank, n2hexstr(offset).c_str(), type, byte_size, value_str.c_str());
}
extern "C" void libRR_log_instruction_2int(uint32_t current_pc, const char* c_name, uint32_t instruction_bytes, int number_of_bytes, uint32_t operand, uint32_t operand2) {
if (!libRR_full_function_log || !libRR_finished_boot_rom) {
return;
}
std::string name(c_name);
replace(name, "%int%", libRR_constant_replace(operand));
replace(name, "%int2%", libRR_constant_replace(operand2));
libRR_log_instruction(current_pc, name, instruction_bytes, number_of_bytes);
}
// Takes a single int argument and replaces it in the string
extern "C" void libRR_log_instruction_1int(uint32_t current_pc, const char* c_name, uint32_t instruction_bytes, int number_of_bytes, uint32_t operand) {
return libRR_log_instruction_2int(current_pc, c_name, instruction_bytes, number_of_bytes, operand, 0);
}
extern "C" void libRR_log_instruction_1string(uint32_t current_pc, const char* c_name, uint32_t instruction_bytes, int number_of_bytes, const char* c_register_name) {
if (!libRR_full_function_log || !libRR_finished_boot_rom) {
return;
}
std::string name(c_name);
std::string register_name(c_register_name);
replace(name, "%str%",register_name);
libRR_log_instruction_1int(current_pc, name.c_str(), instruction_bytes, number_of_bytes, 0x00);
}
extern "C" void libRR_log_instruction_1int_registername(uint32_t current_pc, const char* c_name, uint32_t instruction_bytes, int number_of_bytes, uint32_t operand, const char* c_register_name) {
if (!libRR_full_function_log || !libRR_finished_boot_rom) {
return;
}
std::string name(c_name);
std::string register_name(c_register_name);
replace(name, "%r%",register_name);
libRR_log_instruction_1int(current_pc, name.c_str(), instruction_bytes, number_of_bytes, operand);
}
extern "C" void libRR_log_instruction_z80_s_d(uint32_t current_pc, const char* c_name, uint32_t instruction_bytes, int number_of_bytes, const char* source, const char* destination) {
if (!libRR_full_function_log || !libRR_finished_boot_rom) {
return;
}
std::string name(c_name);
replace(name, "%s%", source);
replace(name, "%d%", destination);
libRR_log_instruction(current_pc, name, instruction_bytes, number_of_bytes);
}
//
// Z80 End
//
// current_pc - current program counter
// instruction bytes as integer used for hex
// arguments - number of arguments - currently not really used for anything
// m - used for register number, replaces Rm with R1/R2 etc
void libRR_log_instruction(uint32_t current_pc, string name, uint32_t instruction_bytes, int number_of_bytes, unsigned m, unsigned n, unsigned imm, unsigned d, unsigned ea) {
if (!libRR_full_function_log || !libRR_finished_boot_rom) {
return;
}
replace(name, "%EA", "0x"+n2hexstr(ea));
libRR_log_instruction(current_pc, name, instruction_bytes, number_of_bytes, m, n, imm, d);
}
void libRR_log_instruction(uint32_t current_pc, string name, uint32_t instruction_bytes, int number_of_bytes, unsigned m, unsigned n, unsigned imm, unsigned d) {
if (!libRR_full_function_log || !libRR_finished_boot_rom) {
return;
}
replace(name, "#imm", "#"+to_string(imm));
replace(name, "disp", ""+to_string(d));
if (name.find("SysRegs") != std::string::npos) {
replace(name, "SysRegs[#0]", "MACH");
replace(name, "SysRegs[#1]", "MACL");
replace(name, "SysRegs[#2]", "PR");
}
libRR_log_instruction(current_pc, name, instruction_bytes, number_of_bytes, m, n);
}
void libRR_log_instruction(uint32_t current_pc, string name, uint32_t instruction_bytes, int number_of_bytes, unsigned m, unsigned n) {
if (!libRR_full_function_log || !libRR_finished_boot_rom) {
return;
}
replace(name, "Rm", "R"+to_string(m));
replace(name, "Rn", "R"+to_string(n));
libRR_log_instruction(current_pc, name, instruction_bytes, number_of_bytes);
}
extern "C" void libRR_log_instruction(uint32_t current_pc, const char* name, uint32_t instruction_bytes, int number_of_bytes)
{
if (!libRR_full_function_log || !libRR_finished_boot_rom) {
return;
}
// printf("libRR_log_instruction pc:%d name: %s bytes: %d\n", current_pc, name, instruction_bytes);
std::string str(name);
libRR_log_instruction(current_pc, str, instruction_bytes, number_of_bytes);
}
// C version of the c++ template
extern "C" const char* n2hexstr_c(int number, size_t hex_len) {
return n2hexstr(number, hex_len).c_str();
}
string libRR_constant_replace(uint32_t da8) {
string addr_str = n2hexstr(da8);
if (libRR_console_constants["addresses"].contains(addr_str)) {
return libRR_console_constants["addresses"][addr_str];
}
return "$"+n2hexstr(da8);
}
int32_t previous_pc = 0; // used for debugging
bool has_read_first_ever_instruction = false;
void libRR_log_instruction(uint32_t current_pc, string name, uint32_t instruction_bytes, int number_of_bytes) {
if (!libRR_full_function_log || !libRR_finished_boot_rom) {
return;
}
if (!has_read_first_ever_instruction) {
// special handling for the entry point, we wanr to force a label here to it gets written to output
libRR_log_jump_label_with_name(current_pc, current_pc, "entry");
has_read_first_ever_instruction = true;
libRR_isDelaySlot = false;
}
int bank = get_current_bank_number_for_address(current_pc);
string current_bank_str = n2hexstr(bank, 4);
// trace log each instruction
if (libRR_full_trace_log) {
libRR_log_trace_str(name + "; pc:"+current_bank_str+":"+n2hexstr(current_pc));
}
// Code used for debugging why an address was reached
if (libRR_enable_look && current_pc == libRR_offset_to_look_for) {
printf("Reached %s: previous addr: %s name:%s bank:%d \n ", n2hexstr(libRR_offset_to_look_for).c_str(), n2hexstr(previous_pc).c_str(), name.c_str(), bank);
}
// end debugging code
if (strcmp(libRR_console,"Saturn")==0) {
printf("isSaturn\n");
// For saturn we remove 2 from the program counter, but this will vary per console
current_pc -= 4; // was -2
}
// string current_function = n2hexstr(function_stack.back());
string current_pc_str = n2hexstr(current_pc);
// printf("libRR_log_instruction %s \n", current_function.c_str());
if (strcmp(libRR_console,"Saturn")==0) {
if (libRR_isDelaySlot) {
current_pc_str = n2hexstr(libRR_delay_slot_pc - 2); //subtract 2 as pc is ahead
// printf("Delay Slot %s \n", current_pc_str.c_str());
libRR_isDelaySlot = false;
}
}
// TODO: Hex bytes should change based on number_of_bytes
string hexBytes = n2hexstr((uint32_t)instruction_bytes, number_of_bytes*2);
// if we are below the max addr of bank 0 (e.g 0x4000 for GB) then we are always in bank 0
// if (current_pc <libRR_slot_0_max_addr) {
// current_bank_str="0000";
// }
// libRR_disassembly[current_bank_str][current_pc_str][name]["frame"]=RRCurrentFrame;
libRR_disassembly[current_bank_str][current_pc_str][name]["bytes"]=hexBytes;
libRR_disassembly[current_bank_str][current_pc_str][name]["bytes_length"]=number_of_bytes;
previous_pc = current_pc;
} | 40.186519 | 312 | 0.672836 | disi33 |
274859fcc3c14d6621bb5912b64e71495ce6c751 | 518 | cpp | C++ | C++/402.remove-k-digits.cpp | WilliamZhaoz/github | 2aa0eb17e272249fc225cf2e9861c4c44bd0e265 | [
"MIT"
] | 1 | 2018-03-06T05:07:22.000Z | 2018-03-06T05:07:22.000Z | C++/402.remove-k-digits.cpp | WilliamZhaoz/github | 2aa0eb17e272249fc225cf2e9861c4c44bd0e265 | [
"MIT"
] | 1 | 2021-12-24T16:41:02.000Z | 2021-12-24T16:41:02.000Z | C++/402.remove-k-digits.cpp | WilliamZhaoz/github | 2aa0eb17e272249fc225cf2e9861c4c44bd0e265 | [
"MIT"
] | null | null | null | class Solution {
public:
string removeKdigits(string num, int k) {
int n = num.size();
int leave = n - k;
string res = "";
for (int i = 0; i < num.size(); i++) {
while (k && res.back() > num[i]) {
k--;
res.pop_back();
}
res += num[i];
}
res.resize(leave);
while (!res.empty() && res[0] == '0') {
res.erase(res.begin());
}
return res.empty() ? "0" : res;
}
}; | 25.9 | 47 | 0.3861 | WilliamZhaoz |
27491f61d7399b5fc86b9abe57f70c2615370f62 | 1,688 | cpp | C++ | vs2017/ui/mainwindow/workbench/AppStoreList.cpp | cheechang/cppcc | 0292e9a9b27e0579970c83b4f6a75dcdae1558bf | [
"MIT"
] | null | null | null | vs2017/ui/mainwindow/workbench/AppStoreList.cpp | cheechang/cppcc | 0292e9a9b27e0579970c83b4f6a75dcdae1558bf | [
"MIT"
] | null | null | null | vs2017/ui/mainwindow/workbench/AppStoreList.cpp | cheechang/cppcc | 0292e9a9b27e0579970c83b4f6a75dcdae1558bf | [
"MIT"
] | null | null | null | #include "AppStoreList.h"
#include <QListWidgetItem>
#include "AppStoreListItem.h"
namespace ui{
AppStoreList::AppStoreList(QWidget *parent)
: QListWidget(parent)
{
m_pAppMgr = APPMGRCONTROL;
CONNECT_SERVICE(GetApplication(std::vector<data::AppInfo>));
if (m_pAppMgr != CNull)
{
m_pAppMgr->getAllApplication(CBind
(&AppStoreList::signalSerGetApplication, this,
CPlaceholders _1));
}
this->setSelectionMode(SelectionMode::NoSelection);
this->setObjectName("appStoreList");
}
AppStoreList::~AppStoreList()
{
}
void AppStoreList::onSerGetApplication(std::vector<data::AppInfo> vec)
{
for (int i = 0; i < vec.size(); i++)
{
QListWidgetItem* pItem = new QListWidgetItem(this);
AppStoreListItem* pListItem = new AppStoreListItem(this);
connect(pListItem, SIGNAL(installApp(int64, QString, QString, QString)),
this, SLOT(onInstallApp(int64, QString, QString, QString)));
connect(pListItem, SIGNAL(uninstallApp(int64)),
this, SLOT(onUninstallApp(int64)));
pListItem->setAppID(vec[i].appID);
pListItem->setName(QString::fromUtf8(vec[i].name.data()));
pListItem->setAvatar(QString::fromUtf8(vec[i].icon.data()));
pListItem->setIntroduce(QString::fromUtf8(vec[i].introduction.data()));
pListItem->setUrl(QString::fromUtf8(vec[i].url.data()));
pListItem->setButtonStatus(vec[i].isInstalled);
this->setItemWidget(pItem, pListItem);
}
//this->update();
}
void AppStoreList::onInstallApp(int64 iAppID, QString strName,
QString strIcon, QString strUrl)
{
emit installApp(iAppID, strName, strIcon, strUrl);
}
void AppStoreList::onUninstallApp(int64 iAppID)
{
emit uninstallApp(iAppID);
}
}
| 25.969231 | 75 | 0.716232 | cheechang |
274b82dafccc64c402de9bd66315b1e8e8c56fd1 | 16,654 | cpp | C++ | regex_to_min_dfa.cpp | avinal/C_ode | f056da37c8c56a4a62a06351c2ea3773d16d1b11 | [
"MIT"
] | 1 | 2020-08-23T20:21:35.000Z | 2020-08-23T20:21:35.000Z | regex_to_min_dfa.cpp | avinal/C_ode | f056da37c8c56a4a62a06351c2ea3773d16d1b11 | [
"MIT"
] | null | null | null | regex_to_min_dfa.cpp | avinal/C_ode | f056da37c8c56a4a62a06351c2ea3773d16d1b11 | [
"MIT"
] | 2 | 2019-03-18T10:22:13.000Z | 2021-01-03T10:12:28.000Z | #include <iostream>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include<string>
using namespace std;
struct nst
{
vector<int> a[2], e;
bool f = 0;
};
vector<nst> nfa;
struct dst
{
int a[2] = {-1, -1};
bool f = 0;
};
vector<dst> dfa;
stack<int> st;
int nfa_size, dfa_size;
string dispregex;
struct nst init_nfa_state;
struct dst init_dfa_state;
void custom_clear()
{
for (int i = 0; i < 100; i++)
cout << endl;
}
/***************************** regex to nfa ****************************/
string insert_concat(string regexp)
{
string ret = "";
char c, c2;
for (unsigned int i = 0; i < regexp.size(); i++)
{
c = regexp[i];
if (i + 1 < regexp.size())
{
c2 = regexp[i + 1];
ret += c;
if (c != '(' && c2 != ')' && c != '+' && c2 != '+' && c2 != '*')
{
ret += '.';
}
}
}
ret += regexp[regexp.size() - 1];
return ret;
}
void character(int i)
{
nfa.push_back(init_nfa_state);
nfa.push_back(init_nfa_state);
nfa[nfa_size].a[i].push_back(nfa_size + 1);
st.push(nfa_size);
nfa_size++;
st.push(nfa_size);
nfa_size++;
}
void union_()
{
nfa.push_back(init_nfa_state);
nfa.push_back(init_nfa_state);
int d = st.top();
st.pop();
int c = st.top();
st.pop();
int b = st.top();
st.pop();
int a = st.top();
st.pop();
nfa[nfa_size].e.push_back(a);
nfa[nfa_size].e.push_back(c);
nfa[b].e.push_back(nfa_size + 1);
nfa[d].e.push_back(nfa_size + 1);
st.push(nfa_size);
nfa_size++;
st.push(nfa_size);
nfa_size++;
}
void concatenation()
{
int d = st.top();
st.pop();
int c = st.top();
st.pop();
int b = st.top();
st.pop();
int a = st.top();
st.pop();
nfa[b].e.push_back(c);
st.push(a);
st.push(d);
}
void kleene_star()
{
nfa.push_back(init_nfa_state);
nfa.push_back(init_nfa_state);
int b = st.top();
st.pop();
int a = st.top();
st.pop();
nfa[nfa_size].e.push_back(a);
nfa[nfa_size].e.push_back(nfa_size + 1);
nfa[b].e.push_back(a);
nfa[b].e.push_back(nfa_size + 1);
st.push(nfa_size);
nfa_size++;
st.push(nfa_size);
nfa_size++;
}
void postfix_to_nfa(string postfix)
{
for (unsigned int i = 0; i < postfix.size(); i++)
{
switch (postfix[i])
{
case 'a':
case 'b':
character(postfix[i] - 'a');
break;
case '*':
kleene_star();
break;
case '.':
concatenation();
break;
case '+':
union_();
}
}
}
void display_nfa()
{
cout << endl
<< endl;
cout << "Phase 1: regex to nfa conversion using thompson's construction algorithm\n";
cout << "------------------------------------------------------------------------\n";
cout << "State\t|\ta\t|\tb\t|\teps\t|accepting state|" << endl;
cout << "------------------------------------------------------------------------\n";
for (unsigned int i = 0; i < nfa.size(); i++)
{
cout << i << "\t|\t";
for (unsigned int j = 0; j < nfa[i].a[0].size(); j++)
cout << nfa[i].a[0][j] << ' ';
cout << "\t|\t";
for (unsigned int j = 0; j < nfa[i].a[1].size(); j++)
cout << nfa[i].a[1][j] << ' ';
cout << "\t|\t";
for (unsigned int j = 0; j < nfa[i].e.size(); j++)
cout << nfa[i].e[j] << ' ';
cout << "\t|\t";
if (nfa[i].f)
cout << "Yes";
else
cout << "No";
cout << "\t|\n";
}
cout << "------------------------------------------------------------------------\n";
}
int priority(char c)
{
switch (c)
{
case '*':
return 3;
case '.':
return 2;
case '+':
return 1;
default:
return 0;
}
}
string regexp_to_postfix(string regexp)
{
string postfix = "";
stack<char> op;
char c;
for (unsigned int i = 0; i < regexp.size(); i++)
{
switch (regexp[i])
{
case 'a':
case 'b':
postfix += regexp[i];
break;
case '(':
op.push(regexp[i]);
break;
case ')':
while (op.top() != '(')
{
postfix += op.top();
op.pop();
}
op.pop();
break;
default:
while (!op.empty())
{
c = op.top();
if (priority(c) >= priority(regexp[i]))
{
postfix += op.top();
op.pop();
}
else
break;
}
op.push(regexp[i]);
}
//cout<<regexp[i]<<' '<<postfix<<endl;
}
while (!op.empty())
{
postfix += op.top();
op.pop();
}
return postfix;
}
/***************************** nfa to dfa ****************************/
void print_dfa()
{
cout << endl;
cout << "NFA TO DFA CONVERSION" << endl;
cout << "---------------------------------------------------------" << endl;
cout << "STATE\t|\t"
<< "a"
<< "\t|\t"
<< "b"
<< "\t|\t"
<< "FINAL"
<< "\t|" << endl;
cout << "---------------------------------------------------------" << endl;
for (int i = 0; i < dfa.size(); i++)
{
cout << i << "\t|\t" << dfa[i].a[0] << "\t|\t" << dfa[i].a[1] << "\t|\t" << dfa[i].f << "\t|" << endl;
}
cout << "---------------------------------------------------------" << endl;
}
void epsilon_closure(int state, set<int> &si)
{
for (unsigned int i = 0; i < nfa[state].e.size(); i++)
{
if (si.count(nfa[state].e[i]) == 0)
{
si.insert(nfa[state].e[i]);
epsilon_closure(nfa[state].e[i], si);
}
}
}
set<int> state_change(int c, set<int> &si)
{
set<int> temp;
if (c == 1)
{
for (std::set<int>::iterator it = si.begin(); it != si.end(); ++it)
{
for (unsigned int j = 0; j < nfa[*it].a[0].size(); j++)
{
temp.insert(nfa[*it].a[0][j]);
}
}
}
else
{
for (std::set<int>::iterator it = si.begin(); it != si.end(); ++it)
{
for (unsigned int j = 0; j < nfa[*it].a[1].size(); j++)
{
temp.insert(nfa[*it].a[1][j]);
}
}
}
return temp;
}
void nfa_to_dfa(set<int> &si, queue<set<int>> &que, int start_state)
{
map<set<int>, int> mp;
mp[si] = -1;
set<int> temp1;
set<int> temp2;
int ct = 0;
si.clear();
si.insert(0);
epsilon_closure(start_state, si);
if (mp.count(si) == 0)
{
mp[si] = ct++;
que.push(si);
}
int p = 0;
bool f1 = false;
while (que.size() != 0)
{
dfa.push_back(init_dfa_state);
si.empty();
si = que.front();
f1 = false;
for (set<int>::iterator it = si.begin(); it != si.end(); ++it)
{
if (nfa[*it].f == true)
f1 = true;
}
dfa[p].f = f1;
temp1 = state_change(1, si);
si = temp1;
for (set<int>::iterator it = si.begin(); it != si.end(); ++it)
{
epsilon_closure(*it, si);
}
if (mp.count(si) == 0)
{
mp[si] = ct++;
que.push(si);
dfa[p].a[0] = ct - 1;
}
else
{
dfa[p].a[0] = mp.find(si)->second;
}
temp1.clear();
si = que.front();
temp2 = state_change(2, si);
si = temp2;
for (set<int>::iterator it = si.begin(); it != si.end(); ++it)
{
epsilon_closure(*it, si);
}
if (mp.count(si) == 0)
{
mp[si] = ct++;
que.push(si);
dfa[p].a[1] = ct - 1;
}
else
{
dfa[p].a[1] = mp.find(si)->second;
}
temp2.clear();
que.pop();
p++;
}
for (int i = 0; i < p; i++)
{
if (dfa[i].a[0] == -1)
dfa[i].a[0] = p;
if (dfa[i].a[1] == -1)
dfa[i].a[1] = p;
}
dfa.push_back(init_dfa_state);
dfa[p].a[0] = p;
dfa[p].a[1] = p;
//cout<<p<<endl;
}
/***************************** min dfa ****************************/
/// Function to minimize DFA
pair<int, vector<tuple<int, int, bool>>> minimize_dfa(vector<dst> dfa)
{
//cout<<dfa.size()<<endl;
vector<int> grp(dfa.size()); /// Group number for states
vector<vector<int>> part(2, vector<int>()); /// Partition for groups
/// Initializing the groups
part[0].push_back(0);
for (int i = 1; i < (int)grp.size(); i++)
{
if (dfa[i].f == dfa[0].f)
{
grp[i] = 0;
part[0].push_back(i);
}
else
{
grp[i] = 1;
part[1].push_back(i);
}
}
if (!part[1].size())
part.erase(part.end());
/// Loop until no new partition is created
bool chk = true; /// Check if any new partition is created
int strt = 0; /// Starting State
while (chk)
{
chk = false;
/*for(int i=0; i<part.size(); i++) {
cout<<i<<":";
for(int j=0; j<part[i].size(); j++) {
cout<<part[i][j]<<" ";
} cout<<endl;
} cout<<endl;*/
/// Iterate over partitions and alphabets
for (int i = 0; i < part.size(); i++)
{
for (int j = 0; j < 2; j++)
{
vector<pair<int, int>> trans(part[i].size()); /// Transitions for the states of partitions
/// Iterate over states of partitions and find transition groups
for (int k = 0; k < part[i].size(); k++)
{
if (dfa[part[i][k]].a[j] >= 0)
trans[k] = make_pair(grp[dfa[part[i][k]].a[j]], part[i][k]);
else
trans[k] = make_pair(-1, part[i][k]);
}
sort(trans.begin(), trans.end());
/// Break partition in case of different transitions
if (trans[0].first != trans[trans.size() - 1].first)
{
chk = true;
int k, m = part.size() - 1;
part[i].clear();
part[i].push_back(trans[0].second);
for (k = 1; k < trans.size() && (trans[k].first == trans[k - 1].first); k++)
{
part[i].push_back(trans[k].second);
}
while (k < trans.size())
{
if (trans[k].first != trans[k - 1].first)
{
part.push_back(vector<int>());
m++;
}
grp[trans[k].second] = m;
part[m].push_back(trans[k].second);
k++;
}
}
}
}
}
for (int i = 0; i < part.size(); i++)
{
for (int j = 0; j < part[i].size(); j++)
{
if (part[i][j] == 0)
strt = i;
}
}
vector<tuple<int, int, bool>> ret(part.size());
//cout<<part.size()<<endl;
//sort(part.begin(), part.end());
for (int i = 0; i < (int)part.size(); i++)
{
//cout<<grp[part[i][0]]<<endl;
get<0>(ret[i]) = (dfa[part[i][0]].a[0] >= 0) ? grp[dfa[part[i][0]].a[0]] : -1;
get<1>(ret[i]) = (dfa[part[i][0]].a[1] >= 0) ? grp[dfa[part[i][0]].a[1]] : -1;
get<2>(ret[i]) = dfa[part[i][0]].f;
}
return make_pair(strt, ret);
}
void print_menu()
{
cout << "\n---------------------------------------\n";
cout << "Input Regex: " << dispregex << endl
<< endl;
cout << "1. NFA\n";
cout << "2. Intermediate DFA\n";
cout << "3. Minimized DFA\n";
cout << "4. Simulation\n";
cout << "Press any other key to exit...\n\n";
}
void print(vector<tuple<int, int, bool>> min_dfa)
{
cout << "---------------------------------------------------------" << endl;
cout << "State\t|\tA\t|\tB\t|\tFinal\t|" << endl;
cout << "---------------------------------------------------------" << endl;
for (int i = 0; i < (int)min_dfa.size(); i++)
{
cout << i << "\t|\t";
cout << get<0>(min_dfa[i]) << "\t|\t";
cout << get<1>(min_dfa[i]) << "\t|\t";
if (get<2>(min_dfa[i]))
cout << "Yes\t|";
else
cout << "No\t|";
cout << endl;
}
cout << "---------------------------------------------------------" << endl;
}
void simulate(int start_st, vector<tuple<int, int, bool>> min_dfa)
{
print_menu();
cout << "Enter string : ";
string input;
cin.ignore();
getline(cin, input);
int curr_state, next_state;
curr_state = start_st;
custom_clear();
cout << "-----------------------------------------" << endl;
cout << "Input\t|\tCurrent\t|\tNext\t|" << endl;
cout << "-----------------------------------------" << endl;
for (unsigned i = 0; i < input.size(); i++)
{
if (input[i] == 'a')
next_state = get<0>(min_dfa[curr_state]);
else
next_state = get<1>(min_dfa[curr_state]);
cout << input[i] << "\t|\t" << curr_state << "\t|\t" << next_state << "\t|\n";
curr_state = next_state;
}
cout << "-----------------------------------------" << endl;
cout << endl
<< "Verdict: ";
if (curr_state >= 0 && get<2>(min_dfa[curr_state]))
cout << "Accepted";
else
cout << "Rejected";
cout << endl;
}
int main()
{
custom_clear();
string regexp, postfix;
cout << "Enter Regular Expression: ";
cin >> regexp;
dispregex = regexp;
regexp = insert_concat(regexp);
postfix = regexp_to_postfix(regexp);
cout << "Postfix Expression: " << postfix << endl;
postfix_to_nfa(postfix);
int final_state = st.top();
st.pop();
int start_state = st.top();
st.pop();
//cout<<start_state<<' '<<final_state<<endl;
nfa[final_state].f = 1;
set<int> si;
queue<set<int>> que;
nfa_to_dfa(si, que, start_state);
cout << endl
<< endl;
pair<int, vector<tuple<int, int, bool>>> min_dfa_tmp = minimize_dfa(dfa);
vector<tuple<int, int, bool>> min_dfa = min_dfa_tmp.second;
int start_st = min_dfa_tmp.first;
getchar();
custom_clear();
while (1)
{
print_menu();
char choice;
choice = getchar();
custom_clear();
switch (choice)
{
case '1':
display_nfa();
getchar();
break;
case '2':
print_dfa();
getchar();
break;
case '3':
print(min_dfa);
getchar();
break;
case '4':
simulate(start_st, min_dfa);
break;
default:
exit(EXIT_SUCCESS);
}
}
cout << endl
<< endl;
cout << "Enter string : ";
string input;
cin.ignore();
getline(cin, input);
int curr_state, next_state;
while (input != "")
{
//cout<<input<<endl;
curr_state = start_st;
for (unsigned i = 0; i < input.size(); i++)
{
if (curr_state >= 0)
{
if (input[i] == 'a')
next_state = get<0>(min_dfa[curr_state]);
else
next_state = get<1>(min_dfa[curr_state]);
if (next_state >= 0)
{
cout << input[i] << " : State " << curr_state << " -> State " << next_state << endl;
}
else
cout << input[i] << " : State " << curr_state << " -> Trap State" << endl;
}
else
cout << input[i] << " : Trapped" << endl;
curr_state = next_state;
}
if (curr_state >= 0 && get<2>(min_dfa[curr_state]))
cout << "accepted";
else
cout << "rejected";
cout << endl
<< endl;
cout << "Enter string : ";
getline(cin, input);
}
return 0;
}
| 25.119155 | 110 | 0.402066 | avinal |
27525b161306b860b02f28e342178932470bbecf | 21,657 | cpp | C++ | source/add-ons/Quantize/Quantize.cpp | thaflo/Becasso | 9a1411913ee46f4dfa5116def50ebc41495dad28 | [
"MIT"
] | 2 | 2020-10-05T14:18:09.000Z | 2021-08-05T02:56:43.000Z | source/add-ons/Quantize/Quantize.cpp | thaflo/Becasso | 9a1411913ee46f4dfa5116def50ebc41495dad28 | [
"MIT"
] | 26 | 2017-01-10T19:54:10.000Z | 2020-12-17T07:28:57.000Z | source/add-ons/Quantize/Quantize.cpp | thaflo/Becasso | 9a1411913ee46f4dfa5116def50ebc41495dad28 | [
"MIT"
] | 5 | 2017-12-14T18:46:08.000Z | 2020-12-13T18:22:34.000Z | // © 2000-2001 Sum Software
#define BUILDING_ADDON
#include "BecassoAddOn.h"
#include "AddOnSupport.h"
#include "Slider.h"
#include <string.h>
#include <CheckBox.h>
#include <RadioButton.h>
#include <Box.h>
#define bzero(p,n) memset (p, 0, n)
int16 *gLut = 0;
#define FOREGROUND 0
#define BACKGROUND 1
#define R_BITS 5
#define G_BITS 6
#define B_BITS 5
#define R_PREC (1<<R_BITS)
#define G_PREC (1<<G_BITS)
#define B_PREC (1<<B_BITS)
#define ELEM(array,r,g,b) (array[b*R_PREC*G_PREC+r*G_PREC+g])
// This is because on MWCC, the huge array needed for the lut can't be
// created on the stack. Hence this workaround.
//#define FLOAT_WEIGHTS 1
// Strangely, the new weights give worst results.
// With the integer weights, results are almost identical with the old floats,
// and probably a lot faster.
#if defined (FLOAT_WEIGHTS)
# define R_WEIGHT 0.2125
# define G_WEIGHT 0.7154
# define B_WEIGHT 0.0721
#elif defined (OLD_WEIGHTS)
# define R_WEIGHT 0.299
# define G_WEIGHT 0.587
# define B_WEIGHT 0.114
#else
# define R_WEIGHT 2
# define G_WEIGHT 3
# define B_WEIGHT 1
#endif
#define R_SHIFT 3
#define G_SHIFT 2
#define B_SHIFT 3
/* log2(histogram cells in update box) for each axis; this can be adjusted */
#define BOX_R_LOG (R_BITS - 3)
#define BOX_G_LOG (G_BITS - 3)
#define BOX_B_LOG (B_BITS - 3)
#define BOX_R_ELEMS (1 << BOX_R_LOG) /* # of hist cells in update box */
#define BOX_G_ELEMS (1 << BOX_G_LOG)
#define BOX_B_ELEMS (1 << BOX_B_LOG)
#define BOX_R_SHIFT (R_SHIFT + BOX_R_LOG)
#define BOX_G_SHIFT (G_SHIFT + BOX_G_LOG)
#define BOX_B_SHIFT (B_SHIFT + BOX_B_LOG)
class QView : public BView
{
public:
QView (BRect rect) : BView (rect, "Quantize_view", B_FOLLOW_ALL, B_WILL_DRAW)
{
fNumColors = 256;
fDitherCB = NULL;
fPalette = FOREGROUND;
ResizeTo (188, 118);
Slider *nSlid = new Slider (BRect (8, 8, 180, 24), 50, "# Colors", 1, 256, 1, new BMessage ('numC'));
AddChild (nSlid);
nSlid->SetValue (256);
fDitherCB = new BCheckBox (BRect (8, 30, 180, 46), "dither", "Floyd-Steinberg Dithering", new BMessage ('fsDt'));
fDitherCB->SetValue (false);
AddChild (fDitherCB);
BBox *palB = new BBox (BRect (8, 54, 180, 110), "palette");
palB->SetLabel ("Use Colors From");
AddChild (palB);
BRadioButton *fgF = new BRadioButton (BRect (4, 14, 170, 30), "fg", "Foreground Palette", new BMessage ('palF'));
BRadioButton *fgB = new BRadioButton (BRect (4, 32, 170, 48), "bg", "Background Palette", new BMessage ('palB'));
palB->AddChild (fgF);
palB->AddChild (fgB);
fgF->SetValue (true);
}
virtual ~QView () {}
virtual void MessageReceived (BMessage *msg);
int numColors () { return fNumColors; }
bool dither () { return (fDitherCB ? fDitherCB->Value() : false); }
int palette () { return fPalette; }
BCheckBox *fDitherCB;
private:
int fNumColors;
int fPalette;
};
QView *view = NULL;
void QView::MessageReceived (BMessage *msg)
{
switch (msg->what)
{
case 'numC':
fNumColors = int (msg->FindFloat ("value"));
break;
case 'fsDt':
// We query the button itself...
break;
case 'palF':
fPalette = FOREGROUND;
break;
case 'palB':
fPalette = BACKGROUND;
break;
default:
BView::MessageReceived (msg);
return;
}
for (int32 i = 0; i < R_PREC; i++)
for (int32 j = 0; j < G_PREC; j++)
for (int32 k = 0; k < B_PREC; k++)
ELEM (gLut, i, j, k) = -1; // We build the LUT on the fly
addon_preview();
}
status_t addon_init (uint32 index, becasso_addon_info *info)
{
strcpy (info->name, "Quantize");
strcpy (info->author, "Sander Stoks");
strcpy (info->copyright, "© 2000-2001 ∑ Sum Software");
strcpy (info->description, "Quantizes the colors to a given palette");
info->type = BECASSO_FILTER;
info->index = index;
info->version = 0;
info->release = 7;
info->becasso_version = 2;
info->becasso_release = 0;
info->does_preview = PREVIEW_FULLSCALE;
info->flags = LAYER_ONLY;
return B_OK;
}
status_t addon_close (void)
{
delete [] gLut;
gLut = 0;
return B_OK;
}
status_t addon_exit (void)
{
return B_OK;
}
void fill_lut (int16 *lut, rgb_color palette[], int max_colors, int r, int g, int b);
int find_nearby_colors (rgb_color palette[], int numcolors, uint8 color_list[], int min_r, int min_g, int min_b);
void find_best_colors (rgb_color palette[], int numcolors, int minr, int ming, int minb, uint8 colorlist[], uint8 bestcolors[]);
int find_nearby_colors (rgb_color palette[], int numcolors, uint8 color_list[], int minr, int ming, int minb)
{
int maxr, maxg, maxb;
int cr, cg, cb;
int i, x, ncolors;
float minmaxdist, min_dist, max_dist, tdist;
float mindist[256]; // 256 = the maximum palette size, actually.
maxr = minr + ((1 << BOX_R_SHIFT) - (1 << R_SHIFT));
cr = (minr + maxr)/2;
maxg = ming + ((1 << BOX_G_SHIFT) - (1 << G_SHIFT));
cg = (ming + maxg)/2;
maxb = minb + ((1 << BOX_B_SHIFT) - (1 << B_SHIFT));
cb = (minb + maxb)/2;
/* For each color in colormap, find:
* 1. its minimum squared-distance to any point in the update box
* (zero if color is within update box);
* 2. its maximum squared-distance to any point in the update box.
* Both of these can be found by considering only the corners of the box.
* We save the minimum distance for each color in mindist[];
* only the smallest maximum distance is of interest.
*/
minmaxdist = 0x7FFFFFFFL;
for (i = 0; i < numcolors; i++)
{
/* We compute the squared-r-distance term, then add in the other two. */
x = palette[i].red;
if (x < minr)
{
tdist = (x - minr)*R_WEIGHT;
min_dist = tdist*tdist;
tdist = (x - maxr)*R_WEIGHT;
max_dist = tdist*tdist;
}
else if (x > maxr)
{
tdist = (x - maxr)*R_WEIGHT;
min_dist = tdist*tdist;
tdist = (x - minr)*R_WEIGHT;
max_dist = tdist*tdist;
}
else // within cell range so no contribution to min_dist
{
min_dist = 0;
if (x <= cr)
{
tdist = (x - maxr)*R_WEIGHT;
max_dist = tdist*tdist;
}
else
{
tdist = (x - minr)*R_WEIGHT;
max_dist = tdist*tdist;
}
}
x = palette[i].green;
if (x < ming)
{
tdist = (x - ming)*G_WEIGHT;
min_dist += tdist*tdist;
tdist = (x - maxg)*G_WEIGHT;
max_dist += tdist*tdist;
}
else if (x > maxg)
{
tdist = (x - maxg)*G_WEIGHT;
min_dist += tdist*tdist;
tdist = (x - ming)*G_WEIGHT;
max_dist += tdist*tdist;
}
else
{
if (x <= cg)
{
tdist = (x - maxg)*G_WEIGHT;
max_dist += tdist*tdist;
}
else
{
tdist = (x - ming)*G_WEIGHT;
max_dist += tdist*tdist;
}
}
x = palette[i].blue;
if (x < minb)
{
tdist = (x - minb)*B_WEIGHT;
min_dist += tdist*tdist;
tdist = (x - maxb)*B_WEIGHT;
max_dist += tdist*tdist;
}
else if (x > maxb)
{
tdist = (x - maxb)*B_WEIGHT;
min_dist += tdist*tdist;
tdist = (x - minb)*B_WEIGHT;
max_dist += tdist*tdist;
}
else
{
if (x <= cb)
{
tdist = (x - maxb)*B_WEIGHT;
max_dist += tdist*tdist;
}
else
{
tdist = (x - minb)*B_WEIGHT;
max_dist += tdist*tdist;
}
}
mindist[i] = min_dist; /* save away the results */
if (max_dist < minmaxdist)
minmaxdist = max_dist;
}
/* Now we know that no cell in the update box is more than minmaxdist
* away from some colormap entry. Therefore, only colors that are
* within minmaxdist of some part of the box need be considered.
*/
ncolors = 0;
for (i = 0; i < numcolors; i++)
{
if (mindist[i] <= minmaxdist)
color_list[ncolors++] = i;
}
return ncolors;
}
void find_best_colors (rgb_color palette[], int numcolors, int minr, int ming, int minb, uint8 colorlist[], uint8 bestcolors[])
{
int ir, ig, ib;
int i, icolor;
register float *bptr; // pointer into bestdist[] array
uint8 *cptr; // pointer into bestcolor[] array
float dist0, dist1; // initial distance values
register float dist2; // current distance in inner loop
float xx0, xx1; // distance increments
register float xx2;
float inc0, inc1, inc2; // initial values for increments
// This array holds the distance to the nearest-so-far color for each cell
float bestdist[BOX_R_ELEMS*BOX_G_ELEMS*BOX_B_ELEMS];
/* Initialize best-distance for each cell of the update box */
bptr = bestdist - 1;
for (i = BOX_R_ELEMS*BOX_G_ELEMS*BOX_B_ELEMS - 1; i >= 0; i--)
*(++bptr) = 0x7FFFFFFFL;
/* For each color selected by find_nearby_colors,
* compute its distance to the center of each cell in the box.
* If that's less than best-so-far, update best distance and color number.
*/
/* Nominal steps between cell centers ("x" in Thomas article) */
#define STEP_R ((1 << R_SHIFT)*R_WEIGHT)
#define STEP_G ((1 << G_SHIFT)*G_WEIGHT)
#define STEP_B ((1 << B_SHIFT)*B_WEIGHT)
for (i = 0; i < numcolors; i++)
{
icolor = colorlist[i];
/* Compute (square of) distance from minr/g/b to this color */
inc0 = (minr - palette[icolor].red)*R_WEIGHT;
dist0 = inc0*inc0;
inc1 = (ming - palette[icolor].green)*G_WEIGHT;
dist0 += inc1*inc1;
inc2 = (minb - palette[icolor].blue)*B_WEIGHT;
dist0 += inc2*inc2;
/* Form the initial difference increments */
inc0 = inc0*(2*STEP_R) + STEP_R*STEP_R;
inc1 = inc1*(2*STEP_G) + STEP_G*STEP_G;
inc2 = inc2*(2*STEP_B) + STEP_B*STEP_B;
/* Now loop over all cells in box, updating distance per Thomas method */
bptr = bestdist;
cptr = bestcolors;
xx0 = inc0;
for (ir = BOX_R_ELEMS - 1; ir >= 0; ir--)
{
dist1 = dist0;
xx1 = inc1;
for (ig = BOX_G_ELEMS - 1; ig >= 0; ig--)
{
dist2 = dist1;
xx2 = inc2;
for (ib = BOX_B_ELEMS - 1; ib >= 0; ib--)
{
if (dist2 < *bptr)
{
*bptr = dist2;
*cptr = icolor;
}
dist2 += xx2;
xx2 += 2*STEP_B*STEP_B;
bptr++;
cptr++;
}
dist1 += xx1;
xx1 += 2*STEP_G*STEP_G;
}
dist0 += xx0;
xx0 += 2*STEP_R*STEP_R;
}
}
}
void fill_lut (int16 *lut, rgb_color palette[], int max_colors, int r, int g, int b)
{
int minr, ming, minb; /* lower left corner of update box */
int ir, ig, ib;
register uint8 *cptr; /* pointer into bestcolor[] array */
/* This array lists the candidate colormap indexes. */
uint8 colorlist[256];
int numcolors; /* number of candidate colors */
/* This array holds the actually closest colormap index for each cell. */
uint8 bestcolor[BOX_R_ELEMS*BOX_G_ELEMS*BOX_B_ELEMS];
/* Convert cell coordinates to update box ID */
r >>= BOX_R_LOG;
g >>= BOX_G_LOG;
b >>= BOX_B_LOG;
/* Compute true coordinates of update box's origin corner.
* Actually we compute the coordinates of the center of the corner
* histogram cell, which are the lower bounds of the volume we care about.
*/
minr = (r << BOX_R_SHIFT) + ((1 << R_SHIFT) >> 1);
ming = (g << BOX_G_SHIFT) + ((1 << G_SHIFT) >> 1);
minb = (b << BOX_B_SHIFT) + ((1 << B_SHIFT) >> 1);
/* Determine which colormap entries are close enough to be candidates
* for the nearest entry to some cell in the update box.
*/
numcolors = find_nearby_colors (palette, max_colors, colorlist, minr, ming, minb);
/* Determine the actually nearest colors. */
find_best_colors (palette, numcolors, minr, ming, minb, colorlist, bestcolor);
/* Save the best color numbers (plus 1) in the main cache array */
r <<= BOX_R_LOG; /* convert ID back to base cell indexes */
g <<= BOX_G_LOG;
b <<= BOX_B_LOG;
cptr = bestcolor - 1;
for (ir = 0; ir < BOX_R_ELEMS; ir++)
for (ig = 0; ig < BOX_G_ELEMS; ig++)
for (ib = 0; ib < BOX_B_ELEMS; ib++)
ELEM (lut, (r + ir), (g + ig), (b + ib)) = *(++cptr);
}
status_t addon_make_config (BView **vw, BRect rect)
{
view = new QView (rect);
*vw = view;
gLut = new int16 [R_PREC*G_PREC*B_PREC];
for (int32 i = 0; i < R_PREC; i++)
for (int32 j = 0; j < G_PREC; j++)
for (int32 k = 0; k < B_PREC; k++)
ELEM (gLut, i, j, k) = -1; // We build the LUT on the fly
return B_OK;
}
status_t process (Layer *inLayer, Selection *inSelection,
Layer **outLayer, Selection **outSelection, int32 mode,
BRect * /* frame */, bool final, BPoint /* point */, uint32 /* buttons */)
{
int error = ADDON_OK;
BRect bounds = inLayer->Bounds();
// printf ("Bounds: ");
// bounds.PrintToStream();
// printf ("Frame: ");
// frame->PrintToStream();
if (*outLayer == NULL && mode== M_DRAW)
*outLayer = new Layer (*inLayer);
if (mode == M_SELECT)
{
if (inSelection)
*outSelection = new Selection (*inSelection);
else // No Selection to Quantize
return (0);
}
if (*outLayer)
(*outLayer)->Lock();
if (*outSelection)
(*outSelection)->Lock();
uint32 h = bounds.IntegerHeight() + 1;
uint32 w = bounds.IntegerWidth() + 1;
grey_pixel *mapbits = NULL;
uint32 mbpr = 0;
uint32 mdiff = 0;
if (inSelection)
{
mapbits = (grey_pixel *) inSelection->Bits() - 1;
mbpr = inSelection->BytesPerRow();
mdiff = mbpr - w;
}
if (final)
addon_start();
float delta = 100.0/h; // For the Status Bar.
switch (mode)
{
case M_DRAW:
{
bgra_pixel *sbits = (bgra_pixel *) inLayer->Bits() - 1;
bgra_pixel *dbits = (bgra_pixel *) (*outLayer)->Bits() - 1;
rgb_color *palette;
if (view->palette() == BACKGROUND)
palette = lowpalette();
else
palette = highpalette();
int numcolors = view->numColors();
if (!view->dither()) // Simple quantizer
{
for (uint32 y = 0; y < h; y++)
{
if (final)
{
addon_update_statusbar (delta);
if (addon_stop())
{
error = ADDON_ABORT;
break;
}
}
for (uint32 x = 0; x < w; x++)
{
bgra_pixel pixel = *(++sbits);
if (!inSelection || *(++mapbits))
{
uint8 r = RED (pixel);
uint8 g = GREEN (pixel);
uint8 b = BLUE (pixel);
// uint16 appr = ((r << 8) & 0xF700)|((g << 3) & 0x07E0)|((b >> 3) & 0x001F);
int rs = r >> R_SHIFT;
int gs = g >> G_SHIFT;
int bs = b >> B_SHIFT;
if (ELEM (gLut, rs, gs, bs) < 0) // Not filled in yet
{
fill_lut (gLut, palette, numcolors, r >> R_SHIFT, g >> G_SHIFT, b >> B_SHIFT);
}
*(++dbits) = rgb2bgra (palette[ELEM (gLut, rs, gs, bs)]);
}
else
*(++dbits) = *(++sbits);
}
mapbits += mdiff;
}
}
else // FS Dither
{
// Foley & Van Dam, pp 572.
// Own note: Probably the errors in the different color channels should be weighted
// according to visual sensibility. But this version is primarily meant to
// be quick.
uint32 width = bounds.IntegerWidth() + 1;
uint32 slpr = inLayer->BytesPerRow()/4;
bgra_pixel *src = sbits; //(bgra_pixel *) inLayer->Bits() + int (bounds.top)*slpr + int (bounds.left) - 1;
int32 sdif = slpr - width;
uint32 dbpr = (*outLayer)->BytesPerRow()/4;
bgra_pixel *dest = dbits; //(bgra_pixel *) (*outLayer)->Bits() + int (bounds.top)*dbpr + int (bounds.left) - 1;
int32 ddif = dbpr - width;
int *nera = new int[width];
int *nega = new int[width];
int *neba = new int[width];
int *cera = new int[width];
int *cega = new int[width];
int *ceba = new int[width];
bzero (nera, width*sizeof(int));
bzero (nega, width*sizeof(int));
bzero (neba, width*sizeof(int));
bzero (cera, width*sizeof(int));
bzero (cega, width*sizeof(int));
bzero (ceba, width*sizeof(int));
int r, g, b, er, eg, eb, per, peg, peb;
uint8 apix;
uint32 x, y;
rgb_color a;
for (y = uint32 (bounds.top); y < uint32 (bounds.bottom); y++)
{
// printf ("%ld", y); fflush (stdout);
if (final)
{
addon_update_statusbar (delta);
if (addon_stop())
{
error = ADDON_ABORT;
break;
}
}
x = 0;
// Special case: First pixel in a row
bgra_pixel s = *(++src);
r = clip8 (RED (s) + cera[0]);
g = clip8 (GREEN (s) + cega[0]);
b = clip8 (BLUE (s) + ceba[0]);
cera[0] = 0;
cega[0] = 0;
ceba[0] = 0;
// Find the nearest match in the palette and write it out
int rs = r >> R_SHIFT;
int gs = g >> G_SHIFT;
int bs = b >> B_SHIFT;
if (ELEM (gLut, rs, gs, bs) < 0) // Not filled in yet
fill_lut (gLut, palette, numcolors, rs, gs, bs);
apix = ELEM (gLut, rs, gs, bs);
// And the corresponding RGB color
a = palette[apix];
if (!inSelection || *(++mapbits))
*(++dest) = rgb2bgra (a);
else
*(++dest) = s;
// Calculate the error terms
er = r - a.red;
eg = g - a.green;
eb = b - a.blue;
per = 7*er/16;
peg = 7*eg/16;
peb = 7*eb/16;
// Put all the remaining error in the pixels down and down-right
// (since there is no pixel down-left...)
nera[x] += er/2;
nega[x] += eg/2;
neba[x] += eb/2;
nera[x + 1] += er/16;
nega[x + 1] += eg/16;
neba[x + 1] += eb/16;
for (x = 1; x < width - 1; x++)
{
// printf (","); fflush (stdout);
// Get one source pixel
s = *(++src);
// Get color components and add errors from previous pixel
r = clip8 (RED (s) + per + cera[x]);
g = clip8 (GREEN (s) + peg + cega[x]);
b = clip8 (BLUE (s) + peb + ceba[x]);
cera[x] = 0;
cega[x] = 0;
ceba[x] = 0;
// Find the nearest match in the palette and write it out
int rs = r >> R_SHIFT;
int gs = g >> G_SHIFT;
int bs = b >> B_SHIFT;
if (ELEM (gLut, rs, gs, bs) < 0) // Not filled in yet
fill_lut (gLut, palette, numcolors, rs, gs, bs);
apix = ELEM (gLut, rs, gs, bs);
// And the corresponding RGB color
a = palette[apix];
// printf ("%c.", 8); fflush (stdout);
if (!inSelection || *(++mapbits))
*(++dest) = rgb2bgra (a);
else
*(++dest) = s;
// printf ("%c:", 8); fflush (stdout);
// Calculate the error terms
er = r - a.red;
eg = g - a.green;
eb = b - a.blue;
per = 7*er/16;
peg = 7*eg/16;
peb = 7*eb/16;
nera[x - 1] += 3*er/16;
nega[x - 1] += 3*eg/16;
neba[x - 1] += 3*eb/16;
nera[x] += 5*er/16;
nega[x] += 5*eg/16;
neba[x] += 5*eb/16;
nera[x + 1] += er/16;
nega[x + 1] += eg/16;
neba[x + 1] += eb/16;
}
// Special case: Last pixel
// printf ("Writing last pixel - "); fflush (stdout);
s = *(++src);
// printf ("1"); fflush (stdout);
// Get color components and add errors from previous pixel
r = clip8 (RED (s) + per + cera[x]);
g = clip8 (GREEN (s) + peg + cega[x]);
b = clip8 (BLUE (s) + peb + ceba[x]);
cera[x] = 0;
cega[x] = 0;
ceba[x] = 0;
// Find the nearest match in the palette and write it out
rs = r >> R_SHIFT;
gs = g >> G_SHIFT;
bs = b >> B_SHIFT;
if (ELEM (gLut, rs, gs, bs) < 0) // Not filled in yet
fill_lut (gLut, palette, numcolors, rs, gs, bs);
apix = ELEM (gLut, rs, gs, bs);
// printf ("@"); fflush (stdout);
// And the corresponding RGB color
a = palette[apix];
// printf ("2"); fflush (stdout);
if (!inSelection || *(++mapbits))
*(++dest) = rgb2bgra (a);
else
*(++dest) = s;
// printf ("Still alive.\n");
// Calculate the error terms
er = r - a.red;
eg = g - a.green;
eb = b - a.blue;
// Put all the error in the pixels down and down-left
nera[x - 1] += er/2;
nega[x - 1] += eg/2;
neba[x - 1] += eb/2;
nera[x] += er/2;
nega[x] += eg/2;
neba[x] += eb/2;
// Switch the scratch data
int *tmp;
tmp = cera; cera = nera; nera = tmp;
tmp = cega; cega = nega; nega = tmp;
tmp = ceba; ceba = neba; neba = tmp;
dest += ddif;
src += sdif;
mapbits += mdiff;
}
// Special case: Last line
// All the error goes into the right pixel.
er = 0;
eg = 0;
eb = 0;
// printf ("Entering last line...\n");
for (x = 0; x < width - 1; x++)
{
// Get one source pixel
bgra_pixel s = *(++src);
// Get color components and add errors from previous pixel
r = clip8 (RED (s) + er + cera[x]);
g = clip8 (GREEN (s) + eg + cega[x]);
b = clip8 (BLUE (s) + eb + ceba[x]);
// Find the nearest match in the palette and write it out
int rs = r >> R_SHIFT;
int gs = g >> G_SHIFT;
int bs = b >> B_SHIFT;
if (ELEM (gLut, rs, gs, bs) < 0) // Not filled in yet
fill_lut (gLut, palette, numcolors, rs, gs, bs);
apix = ELEM (gLut, rs, gs, bs);
// And the corresponding RGB color
a = palette[apix];
if (!inSelection || *(++mapbits))
*(++dest) = rgb2bgra (a);
else
*(++dest) = s;
// Calculate the error terms
er = r - a.red;
eg = g - a.green;
eb = b - a.blue;
}
// Last but not least, the bottom right pixel.
bgra_pixel s = *(++src);
r = clip8 (RED (s) + er + cera[x]);
g = clip8 (GREEN (s) + eg + cega[x]);
b = clip8 (BLUE (s) + eb + ceba[x]);
int rs = r >> R_SHIFT;
int gs = g >> G_SHIFT;
int bs = b >> B_SHIFT;
if (ELEM (gLut, rs, gs, bs) < 0) // Not filled in yet
fill_lut (gLut, palette, numcolors, rs, gs, bs);
apix = ELEM (gLut, rs, gs, bs);
if (!inSelection || *(++mapbits))
*(++dest) = rgb2bgra (palette[apix]);
else
*(++dest) = s;
delete [] nera;
delete [] nega;
delete [] neba;
delete [] cera;
delete [] cega;
delete [] ceba;
}
delete [] palette;
break;
}
case M_SELECT:
{
break;
}
default:
fprintf (stderr, "Quantize: Unknown mode\n");
error = ADDON_UNKNOWN;
}
if (*outSelection)
(*outSelection)->Unlock();
if (*outLayer)
(*outLayer)->Unlock();
if (final)
addon_done();
return (error);
}
| 26.540441 | 128 | 0.586323 | thaflo |
27529bcb836fad9ead65325abb59bf5376582755 | 5,373 | cpp | C++ | 55479c656d65636fdb050000/code/RobotAI.cpp | MechEmpire/Mechempire-meches | aa95b15f061f4179c9061595e73c7127587cc4df | [
"Apache-2.0"
] | 1 | 2020-07-29T05:50:16.000Z | 2020-07-29T05:50:16.000Z | 55479ffa6d65636fdb0d0000/code/RobotAI.cpp | MechEmpire/Mechempire-meches | aa95b15f061f4179c9061595e73c7127587cc4df | [
"Apache-2.0"
] | null | null | null | 55479ffa6d65636fdb0d0000/code/RobotAI.cpp | MechEmpire/Mechempire-meches | aa95b15f061f4179c9061595e73c7127587cc4df | [
"Apache-2.0"
] | null | null | null | #include "RobotAI.h"
#include<math.h>
#include<iostream>
using namespace std;
RobotAI::RobotAI()
{
}
RobotAI::~RobotAI()
{
}
//-----------------------------------------------------
//1.必须完成的战斗核心
//-----------------------------------------------------
struct node
{
double x,y,dis;
};
double max_num(double a,double b)
{
return a>b?a:b;
}
void RobotAI::Update(RobotAI_Order& order,const RobotAI_BattlefieldInformation& info,int myID)
{
int enery;
if(myID==1)
enery=0;
else
enery=1;
int x=info.robotInformation[myID].circle.x;
int y=info.robotInformation[myID].circle.y;
int x1=info.robotInformation[enery].circle.x;
int y1=info.robotInformation[enery].circle.y;
int x2=300;
int y2=250;
int x3=1066;
int y3=430;
int d=120;
int dis;
int ddx;
int ddy;
if(myID==1)
{
dis=(int)sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
ddx=(120*(x3-x1))/dis+x3;
ddy=(120*(y3-y1))/dis+y3;
}
else
{
dis=(int)sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
ddx=x2-dis*(x1-x2)/120;
ddy=y2-dis*(y1-y2)/120;
}
int dx=(x1-x);
int dy=(y1-y);
double k=Random0_1();
double kk,kk1;
if(myID==1)
{
kk=(y1-430)/max_num(0.01,(x1-1066));
kk1=(430-y)/(max_num(0.01,(1066-x)));
}
else
{
kk=(y1-250)/max_num(0.01,(x1-300));
kk1=(250-y)/(max_num(0.01,(300-x)));
}
//1234 左右上下
if(k<0.5)
{
if(ddx>x)
order.run=2;
else
order.run=1;
}
else
{
if(ddy>y)
order.run=4;
else
order.run=3;
}
if(myID==1)
{
if(info.robotInformation[myID].circle.x>1066+d)
order.run=1;
if(info.robotInformation[myID].circle.x<1066-d)
order.run=2;
if(info.robotInformation[myID].circle.y>430+d)
order.run=3;
if(info.robotInformation[myID].circle.y<430-d)
order.run=4;
}
if(myID==0)
{
if(info.robotInformation[myID].circle.x>300+d)
order.run=1;
if(info.robotInformation[myID].circle.x<300-d)
order.run=2;
if(info.robotInformation[myID].circle.y>250+d)
order.run=3;
if(info.robotInformation[myID].circle.y<250-d)
order.run=4;
}
double kiss=Random0_1();
if(info.robotInformation[myID].remainingAmmo==0)
{
for(int i=0;i<2;i++)
{
if(info.arsenal[i].respawning_time==0)
{
if(kiss<0.5)
{
if(info.arsenal[i].circle.x+30>info.robotInformation[myID].circle.x)
{
order.run=2;
break;
}
if(info.arsenal[i].circle.x+30<info.robotInformation[myID].circle.x)
{
order.run=1;
break;
}
}
else
{
if(info.arsenal[i].circle.y+30>info.robotInformation[myID].circle.y)
{
order.run=4;
break;
}
if(info.arsenal[i].circle.y+30<info.robotInformation[myID].circle.y)
{
order.run=3;
break;
}
}
}
}
}
double ck;
Beam shoot;
double ck1=info.robotInformation[myID].weaponRotation;
shoot.x=x;
shoot.y=y;
shoot.rotation=ck1;
Circle kis;
if(myID==1)
{
kis.x=1066;
kis.y=430;
kis.r=100;
if(HitTestBeamCircle(shoot,kis))
order.wturn=1;
}
else
{
kis.x=300;
kis.y=250;
kis.r=80;
if(HitTestBeamCircle(shoot,kis))
order.wturn=1;
}
if(myID==0)
order.fire=2;
else
order.fire=1;
}
void RobotAI::ChooseArmor(weapontypename& weapon,enginetypename& engine,bool a)
{
//挑选装备函数
//功能:在战斗开始时为你的机甲选择合适的武器炮塔和引擎载具
//参数:weapon ... 代表你选择的武器,在函数体中给它赋值
// engine ... 代表你选择的引擎,在函数体中给它赋值
//tip: 括号里的参数是枚举类型 weapontypename 或 enginetypename
// 开发文档中有详细说明,你也可以在RobotAIstruct.h中直接找到它们的代码
//tip: 最后一个bool是没用的。。那是一个退化的器官
weapon = WT_MissileLauncher;
engine = ET_Spider;
}
//-----------------------------------------------------
//2.个性信息
//-----------------------------------------------------
string RobotAI::GetName()
{
//返回你的机甲的名字
return "bird_raincoatV0.19";
}
string RobotAI::GetAuthor()
{
//返回机甲制作人或团队的名字
return "qscqesze";
}
//返回一个(-255,255)之间的机甲武器炮塔的颜色偏移值(红、绿、蓝)
//你可以在flash客户端的参数预览中预览颜色搭配的效果
int RobotAI::GetWeaponRed()
{
//返回一个-255-255之间的整数,代表武器红色的偏移值
return 255;
}
int RobotAI::GetWeaponGreen()
{
//返回一个-255-255之间的整数,代表武器绿色的偏移值
return -69;
}
int RobotAI::GetWeaponBlue()
{
//返回一个-255-255之间的整数,代表武器蓝色的偏移值
return 31;
}
//返回一个(-255,255)之间的机甲引擎载具的颜色偏移值(红、绿、蓝)
//你可以在flash客户端的参数预览中预览颜色搭配的效果
int RobotAI::GetEngineRed()
{
//返回一个-255-255之间的数,代表载具红色的偏移值
return -255;
}
int RobotAI::GetEngineGreen()
{
//返回一个-255-255之间的整数,代表载具绿色的偏移值
return -106;
}
int RobotAI::GetEngineBlue()
{
//返回一个-255-255之间的整数,代表载具蓝色的偏移值
return -4;
}
//-----------------------------------------------------
//3.用不用随你的触发函数
//-----------------------------------------------------
void RobotAI::onBattleStart(const RobotAI_BattlefieldInformation& info,int myID)
{
//一场战斗开始时被调用,可能可以用来初始化
//参数:info ... 战场信息
// myID ... 自己机甲在info中robot数组对应的下标
}
void RobotAI::onBattleEnd(const RobotAI_BattlefieldInformation& info,int myID)
{
//一场战斗结束时被调用,可能可以用来析构你动态分配的内存空间(如果你用了的话)
//参数:info ... 战场信息
// myID ... 自己机甲在info中robot数组对应的下标
}
void RobotAI::onSomeoneFire(int fireID)
{
//有机甲开火时被调用
//参数:fireID ... 开火的机甲下标
}
void RobotAI::onHit(int launcherID,bullettypename btn)
{
//被子弹击中时被调用
//参数:btn ... 击中你的子弹种类(枚举类型)
}
//TODO:这里可以实现你自己的函数 | 17.166134 | 95 | 0.577703 | MechEmpire |
27535f079eb414837f11b815cca167a6b7fe7654 | 10,997 | cpp | C++ | webkit/WebCore/dom/Text.cpp | s1rcheese/nintendo-3ds-internetbrowser-sourcecode | 3dd05f035e0a5fc9723300623e9b9b359be64e11 | [
"Unlicense"
] | 15 | 2016-01-05T12:43:41.000Z | 2022-03-15T10:34:47.000Z | webkit/WebCore/dom/Text.cpp | s1rcheese/nintendo-3ds-internetbrowser-sourcecode | 3dd05f035e0a5fc9723300623e9b9b359be64e11 | [
"Unlicense"
] | null | null | null | webkit/WebCore/dom/Text.cpp | s1rcheese/nintendo-3ds-internetbrowser-sourcecode | 3dd05f035e0a5fc9723300623e9b9b359be64e11 | [
"Unlicense"
] | 2 | 2020-11-30T18:36:01.000Z | 2021-02-05T23:20:24.000Z | /*
* Copyright (C) 1999 Lars Knoll ([email protected])
* (C) 1999 Antti Koivisto ([email protected])
* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include "Text.h"
#include "CString.h"
#include "ExceptionCode.h"
#include "RenderText.h"
#include "TextBreakIterator.h"
#if ENABLE(SVG)
#include "RenderSVGInlineText.h"
#include "SVGNames.h"
#endif
#if ENABLE(WML)
#include "WMLDocument.h"
#include "WMLVariables.h"
#endif
using namespace std;
namespace WebCore {
Text::Text(Document* document, const String& data)
: CharacterData(document, data, CreateText)
{
}
PassRefPtr<Text> Text::create(Document* document, const String& data)
{
return adoptRef(new Text(document, data));
}
PassRefPtr<Text> Text::splitText(unsigned offset, ExceptionCode& ec)
{
ec = 0;
// INDEX_SIZE_ERR: Raised if the specified offset is negative or greater than
// the number of 16-bit units in data.
if (offset > length()) {
ec = INDEX_SIZE_ERR;
return 0;
}
RefPtr<StringImpl> oldStr = dataImpl();
RefPtr<Text> newText = virtualCreate(oldStr->substring(offset));
setDataImpl(oldStr->substring(0, offset));
dispatchModifiedEvent(oldStr.get());
if (parentNode())
parentNode()->insertBefore(newText.get(), nextSibling(), ec);
if (ec)
return 0;
if (parentNode())
document()->textNodeSplit(this);
if (renderer())
toRenderText(renderer())->setText(dataImpl());
return newText.release();
}
static const Text* earliestLogicallyAdjacentTextNode(const Text* t)
{
const Node* n = t;
while ((n = n->previousSibling())) {
Node::NodeType type = n->nodeType();
if (type == Node::TEXT_NODE || type == Node::CDATA_SECTION_NODE) {
t = static_cast<const Text*>(n);
continue;
}
// We would need to visit EntityReference child text nodes if they existed
ASSERT(type != Node::ENTITY_REFERENCE_NODE || !n->hasChildNodes());
break;
}
return t;
}
static const Text* latestLogicallyAdjacentTextNode(const Text* t)
{
const Node* n = t;
while ((n = n->nextSibling())) {
Node::NodeType type = n->nodeType();
if (type == Node::TEXT_NODE || type == Node::CDATA_SECTION_NODE) {
t = static_cast<const Text*>(n);
continue;
}
// We would need to visit EntityReference child text nodes if they existed
ASSERT(type != Node::ENTITY_REFERENCE_NODE || !n->hasChildNodes());
break;
}
return t;
}
String Text::wholeText() const
{
const Text* startText = earliestLogicallyAdjacentTextNode(this);
const Text* endText = latestLogicallyAdjacentTextNode(this);
Node* onePastEndText = endText->nextSibling();
unsigned resultLength = 0;
for (const Node* n = startText; n != onePastEndText; n = n->nextSibling()) {
if (!n->isTextNode())
continue;
const Text* t = static_cast<const Text*>(n);
const String& data = t->data();
#if 1
// added at webkit.org trunk r68705
if (std::numeric_limits<unsigned>::max() - data.length() < resultLength)
CRASH();
#endif
resultLength += data.length();
}
UChar* resultData;
String result = String::createUninitialized(resultLength, resultData);
UChar* p = resultData;
for (const Node* n = startText; n != onePastEndText; n = n->nextSibling()) {
if (!n->isTextNode())
continue;
const Text* t = static_cast<const Text*>(n);
const String& data = t->data();
unsigned dataLength = data.length();
memcpy(p, data.characters(), dataLength * sizeof(UChar));
p += dataLength;
}
ASSERT(p == resultData + resultLength);
return result;
}
PassRefPtr<Text> Text::replaceWholeText(const String& newText, ExceptionCode&)
{
// Remove all adjacent text nodes, and replace the contents of this one.
// Protect startText and endText against mutation event handlers removing the last ref
RefPtr<Text> startText = const_cast<Text*>(earliestLogicallyAdjacentTextNode(this));
RefPtr<Text> endText = const_cast<Text*>(latestLogicallyAdjacentTextNode(this));
RefPtr<Text> protectedThis(this); // Mutation event handlers could cause our last ref to go away
Node* parent = parentNode(); // Protect against mutation handlers moving this node during traversal
ExceptionCode ignored = 0;
for (RefPtr<Node> n = startText; n && n != this && n->isTextNode() && n->parentNode() == parent;) {
RefPtr<Node> nodeToRemove(n.release());
n = nodeToRemove->nextSibling();
parent->removeChild(nodeToRemove.get(), ignored);
}
if (this != endText) {
Node* onePastEndText = endText->nextSibling();
for (RefPtr<Node> n = nextSibling(); n && n != onePastEndText && n->isTextNode() && n->parentNode() == parent;) {
RefPtr<Node> nodeToRemove(n.release());
n = nodeToRemove->nextSibling();
parent->removeChild(nodeToRemove.get(), ignored);
}
}
if (newText.isEmpty()) {
if (parent && parentNode() == parent)
parent->removeChild(this, ignored);
return 0;
}
setData(newText, ignored);
return protectedThis.release();
}
String Text::nodeName() const
{
return textAtom.string();
}
Node::NodeType Text::nodeType() const
{
return TEXT_NODE;
}
PassRefPtr<Node> Text::cloneNode(bool /*deep*/)
{
return create(document(), data());
}
bool Text::rendererIsNeeded(RenderStyle *style)
{
if (!CharacterData::rendererIsNeeded(style))
return false;
bool onlyWS = containsOnlyWhitespace();
if (!onlyWS)
return true;
RenderObject *par = parentNode()->renderer();
if (par->isTable() || par->isTableRow() || par->isTableSection() || par->isTableCol() || par->isFrameSet())
return false;
if (style->preserveNewline()) // pre/pre-wrap/pre-line always make renderers.
return true;
RenderObject *prev = previousRenderer();
if (prev && prev->isBR()) // <span><br/> <br/></span>
return false;
if (par->isRenderInline()) {
// <span><div/> <div/></span>
if (prev && !prev->isInline())
return false;
} else {
if (par->isRenderBlock() && !par->childrenInline() && (!prev || !prev->isInline()))
return false;
RenderObject *first = par->firstChild();
while (first && first->isFloatingOrPositioned())
first = first->nextSibling();
RenderObject *next = nextRenderer();
if (!first || next == first)
// Whitespace at the start of a block just goes away. Don't even
// make a render object for this text.
return false;
}
return true;
}
RenderObject* Text::createRenderer(RenderArena* arena, RenderStyle*)
{
#if ENABLE(SVG)
if (parentNode()->isSVGElement()
#if ENABLE(SVG_FOREIGN_OBJECT)
&& !parentNode()->hasTagName(SVGNames::foreignObjectTag)
#endif
)
return new (arena) RenderSVGInlineText(this, dataImpl());
#endif
return new (arena) RenderText(this, dataImpl());
}
void Text::attach()
{
#if ENABLE(WML)
if (document()->isWMLDocument() && !containsOnlyWhitespace()) {
String text = data();
ASSERT(!text.isEmpty());
text = substituteVariableReferences(text, document());
ExceptionCode code = 0;
setData(text, code);
ASSERT(!code);
}
#endif
createRendererIfNeeded();
CharacterData::attach();
}
void Text::recalcStyle(StyleChange change)
{
if (change != NoChange && parentNode()) {
if (renderer())
renderer()->setStyle(parentNode()->renderer()->style());
}
if (needsStyleRecalc()) {
if (renderer()) {
if (renderer()->isText())
toRenderText(renderer())->setText(dataImpl());
} else {
if (attached())
detach();
attach();
}
}
setNeedsStyleRecalc(NoStyleChange);
}
bool Text::childTypeAllowed(NodeType)
{
return false;
}
PassRefPtr<Text> Text::virtualCreate(const String& data)
{
return create(document(), data);
}
PassRefPtr<Text> Text::createWithLengthLimit(Document* document, const String& data, unsigned& charsLeft, unsigned maxChars)
{
unsigned dataLength = data.length();
if (charsLeft == dataLength && charsLeft <= maxChars) {
charsLeft = 0;
return create(document, data);
}
unsigned start = dataLength - charsLeft;
unsigned end = start + min(charsLeft, maxChars);
// Check we are not on an unbreakable boundary.
// Some text break iterator implementations work best if the passed buffer is as small as possible,
// see <https://bugs.webkit.org/show_bug.cgi?id=29092>.
// We need at least two characters look-ahead to account for UTF-16 surrogates.
if (end < dataLength) {
TextBreakIterator* it = characterBreakIterator(data.characters() + start, (end + 2 > dataLength) ? dataLength - start : end - start + 2);
if (!isTextBreak(it, end - start))
end = textBreakPreceding(it, end - start) + start;
}
// If we have maxChars of unbreakable characters the above could lead to
// an infinite loop.
// FIXME: It would be better to just have the old value of end before calling
// textBreakPreceding rather than this, because this exceeds the length limit.
if (end <= start)
end = dataLength;
charsLeft = dataLength - end;
return create(document, data.substring(start, end - start));
}
#ifndef NDEBUG
void Text::formatForDebugger(char *buffer, unsigned length) const
{
String result;
String s;
s = nodeName();
if (s.length() > 0) {
result += s;
}
s = data();
if (s.length() > 0) {
if (result.length() > 0)
result += "; ";
result += "value=";
result += s;
}
strncpy(buffer, result.utf8().data(), length - 1);
}
#endif
} // namespace WebCore
| 29.964578 | 145 | 0.626807 | s1rcheese |
2753944f40611ce3b32bdff335d878da63ecb12b | 2,770 | cpp | C++ | Source/Planet/Map/PlanetMapTile.cpp | unconed/NFSpace | bbd544afb32a10bc4ee497e1d58cefe4bbbe7953 | [
"BSD-3-Clause"
] | 91 | 2015-01-19T11:03:56.000Z | 2022-03-12T15:54:06.000Z | Source/Planet/Map/PlanetMapTile.cpp | unconed/NFSpace | bbd544afb32a10bc4ee497e1d58cefe4bbbe7953 | [
"BSD-3-Clause"
] | null | null | null | Source/Planet/Map/PlanetMapTile.cpp | unconed/NFSpace | bbd544afb32a10bc4ee497e1d58cefe4bbbe7953 | [
"BSD-3-Clause"
] | 9 | 2015-03-16T03:36:50.000Z | 2021-06-17T09:47:26.000Z | /*
* PlanetMapTile.cpp
* NFSpace
*
* Created by Steven Wittens on 26/11/09.
* Copyright 2009 __MyCompanyName__. All rights reserved.
*
*/
#include "PlanetMapTile.h"
#include "Utility.h"
namespace NFSpace {
PlanetMapTile::PlanetMapTile(QuadTreeNode* node, TexturePtr heightTexture, Image heightImage, TexturePtr normalTexture, int size) {
mNode = node;
mHeightTexture = heightTexture;
mHeightImage = heightImage;
mNormalTexture = normalTexture;
mSize = size;
mReferences = 0;
PlanetStats::totalTiles++;
prepareMaterial();
}
PlanetMapTile::~PlanetMapTile() {
OGRE_FREE(mHeightImage.getData(), MEMCATEGORY_GENERAL);
if (mMaterialCreated) {
MaterialManager::getSingleton().remove(mMaterial->getName());
}
TextureManager::getSingleton().remove(mHeightTexture->getName());
TextureManager::getSingleton().remove(mNormalTexture->getName());
PlanetStats::totalTiles--;
}
String PlanetMapTile::getMaterial() {
if (!mMaterialCreated) prepareMaterial();
return mMaterial->getName();//"Planet/Surface";//mMaterial->getName();
}
Image* PlanetMapTile::getHeightMap() {
return &mHeightImage;
}
void PlanetMapTile::prepareMaterial() {
mMaterialCreated = TRUE;
// Get original planet/surface material and clone it.
MaterialPtr planetSurface = MaterialManager::getSingleton().getByName("Planet/Surface");
mMaterial = planetSurface->clone("Planet/Surface/" + getUniqueId(""));
// Prepare texture substitution list.
AliasTextureNamePairList aliasList;
aliasList.insert(AliasTextureNamePairList::value_type("heightMap", mHeightTexture->getName()));
aliasList.insert(AliasTextureNamePairList::value_type("normalMap", mNormalTexture->getName()));
mMaterial->applyTextureAliases(aliasList);
// Clear out pass caches between scene managers.
updateSceneManagersAfterMaterialsChange();
}
const QuadTreeNode* PlanetMapTile::getNode() {
return mNode;
}
size_t PlanetMapTile::getGPUMemoryUsage() {
return 1.3125 * (
mHeightTexture->getWidth() * mHeightTexture->getHeight() * Ogre::PixelUtil::getNumElemBytes(mHeightTexture->getFormat()) +
mNormalTexture->getWidth() * mNormalTexture->getHeight() * Ogre::PixelUtil::getNumElemBytes(mNormalTexture->getFormat()));
}
void PlanetMapTile::addReference() {
mReferences++;
}
void PlanetMapTile::removeReference() {
mReferences--;
}
int PlanetMapTile::getReferences() {
return mReferences;
}
}
| 31.123596 | 135 | 0.651264 | unconed |
2755d2ac1baa5df3c2f5c744333f2853a896e547 | 1,579 | cpp | C++ | Graphs/dijkstra.cpp | adiletabs/Algos | fa2bb9edddb517f52b79fc712f70d6f8a0786e33 | [
"MIT"
] | 3 | 2020-01-29T18:26:37.000Z | 2021-01-19T06:26:34.000Z | Graphs/dijkstra.cpp | adiletabs/Algos | fa2bb9edddb517f52b79fc712f70d6f8a0786e33 | [
"MIT"
] | null | null | null | Graphs/dijkstra.cpp | adiletabs/Algos | fa2bb9edddb517f52b79fc712f70d6f8a0786e33 | [
"MIT"
] | 2 | 2019-03-06T03:40:42.000Z | 2019-09-23T03:48:21.000Z | #include <bits/stdc++.h>
using namespace std;
const int N = 2020, inf = INT_MAX;
vector<pair<int, int> > g[N];
int dist[N], par[N], n, m;
bool used[N];
vector<int> path;
void init(int s) {
for (int i = 0; i < N; i++)
dist[i] = inf;
dist[s] = 0;
}
void dijkstra(int s) {
init(s);
for (int i = 0; i < n; i++) {
int v = -1;
for (int j = 0; j < n; j++)
if (!used[j] && (v == -1 || dist[j] < dist[v]))
v = j;
used[v] = true;
for (pair<int, int> p: g[v]) {
int to = p.first, len = p.second;
if (dist[v] + len < dist[to]) {
dist[to] = dist[v] + len;
par[to] = v;
}
}
}
}
void fast_dijkstra(int s) {
init(s);
set<pair<int, int> > best_vertices;
best_vertices.insert(make_pair(dist[s], s));
while (!best_vertices.empty()) {
int v = best_vertices.begin()->second;
best_vertices.erase(best_vertices.begin());
for (pair<int, int> p: g[v]) {
int to = p.first, len = p.second;
if (dist[v] + len < dist[to]) {
best_vertices.erase(make_pair(dist[to], to));
dist[to] = dist[v] + len;
par[to] = v;
best_vertices.insert(make_pair(dist[to], to));
}
}
}
}
void get_best_path(int start, int target) {
fast_dijkstra(start);
for (int v = target; v != start; v = par[v])
path.push_back(v);
path.push_back(start);
reverse(path.begin(), path.end());
}
int main() {
cin >> n >> m;
while (m--) {
int v, u, weight;
g[v].push_back(make_pair(u, weight));
g[u].push_back(make_pair(v, weight));
}
int start;
cin >> start;
fast_dijkstra(start);
for (int i = 1; i <= n; i++)
cout << dist[i] << ' ';
}
| 20.24359 | 50 | 0.559215 | adiletabs |
2756ebb0e82a9b58972a2a24859faf61057b140e | 5,107 | hpp | C++ | src/threepp/renderers/gl/GLClipping.hpp | maidamai0/threepp | 9b50e2c0f2a7bb3ebfd3ffeef61dbefcd54c7071 | [
"MIT"
] | null | null | null | src/threepp/renderers/gl/GLClipping.hpp | maidamai0/threepp | 9b50e2c0f2a7bb3ebfd3ffeef61dbefcd54c7071 | [
"MIT"
] | null | null | null | src/threepp/renderers/gl/GLClipping.hpp | maidamai0/threepp | 9b50e2c0f2a7bb3ebfd3ffeef61dbefcd54c7071 | [
"MIT"
] | null | null | null | // https://github.com/mrdoob/three.js/blob/r129/src/renderers/webgl/WebGLClipping.js
#ifndef THREEPP_GLCLIPPING_HPP
#define THREEPP_GLCLIPPING_HPP
#include "GLProperties.hpp"
#include "threepp/cameras/Camera.hpp"
#include "threepp/math/Plane.hpp"
#include "threepp/core/Uniform.hpp"
namespace threepp::gl {
struct GLClipping {
std::optional<std::vector<float>> globalState;
int numGlobalPlanes = 0;
bool localClippingEnabled = false;
bool renderingShadows = false;
Plane plane;
Matrix3 viewNormalMatrix;
Uniform uniform;
int numPlanes = 0;
int numIntersection = 0;
explicit GLClipping(GLProperties &properties) : properties(properties) {
uniform.needsUpdate = false;
}
bool init(
const std::vector<Plane> &planes,
bool enableLocalClipping,
const std::shared_ptr<Camera> &camera) {
bool enabled =
!planes.empty() ||
enableLocalClipping ||
// enable state of previous frame - the clipping code has to
// run another frame in order to reset the state:
numGlobalPlanes != 0 || localClippingEnabled;
localClippingEnabled = enableLocalClipping;
globalState = projectPlanes(planes, camera, 0);
numGlobalPlanes = (int) planes.size();
return enabled;
}
void beginShadows() {
renderingShadows = true;
projectPlanes();
}
void endShadows() {
renderingShadows = false;
resetGlobalState();
}
void setState(const std::shared_ptr<Material> &material, const std::shared_ptr<Camera> &camera, bool useCache) {
auto &planes = material->clippingPlanes;
auto clipIntersection = material->clipIntersection;
auto clipShadows = material->clipShadows;
auto &materialProperties = properties.materialProperties.get(material->uuid);
if (!localClippingEnabled || planes.empty() || renderingShadows && !clipShadows) {
// there's no local clipping
if (renderingShadows) {
// there's no global clipping
projectPlanes();
} else {
resetGlobalState();
}
} else {
const auto nGlobal = renderingShadows ? 0 : numGlobalPlanes,
lGlobal = nGlobal * 4;
auto &dstArray = materialProperties.clippingState;
uniform.setValue(dstArray);// ensure unique state
dstArray = projectPlanes(planes, camera, lGlobal, useCache);
for (int i = 0; i != lGlobal; ++i) {
dstArray[i] = globalState.value()[i];
}
materialProperties.clippingState = dstArray;
this->numIntersection = clipIntersection ? this->numPlanes : 0;
this->numPlanes += nGlobal;
}
}
void resetGlobalState() {
if (!uniform.hasValue() || uniform.value<std::vector<float>>() != globalState) {
uniform.setValue(*globalState);
uniform.needsUpdate = numGlobalPlanes > 0;
}
numPlanes = numGlobalPlanes;
numIntersection = 0;
}
void projectPlanes() {
numPlanes = 0;
numIntersection = 0;
}
std::vector<float> projectPlanes(
const std::vector<Plane> &planes,
const std::shared_ptr<Camera> &camera,
int dstOffset, bool skipTransform = false) {
int nPlanes = (int) planes.size();
std::vector<float> dstArray;
if (nPlanes != 0) {
if (uniform.hasValue()) {
dstArray = uniform.value<std::vector<float>>();
}
if (!skipTransform || dstArray.empty()) {
const auto flatSize = dstOffset + nPlanes * 4;
const auto &viewMatrix = camera->matrixWorldInverse;
viewNormalMatrix.getNormalMatrix(viewMatrix);
if (dstArray.size() < flatSize) {
dstArray.resize(flatSize);
}
for (int i = 0, i4 = dstOffset; i != nPlanes; ++i, i4 += 4) {
plane.copy(planes[i]).applyMatrix4(viewMatrix, viewNormalMatrix);
plane.normal.toArray(dstArray, i4);
dstArray[i4 + 3] = plane.constant;
}
}
uniform.setValue(dstArray);
uniform.needsUpdate = true;
}
numPlanes = nPlanes;
numIntersection = 0;
return dstArray;
}
private:
GLProperties &properties;
};
}// namespace threepp::gl
#endif//THREEPP_GLCLIPPING_HPP
| 27.907104 | 120 | 0.527511 | maidamai0 |
2758945d92d2bba295767c04dccf123ca71c6a50 | 960 | cpp | C++ | src/console/commands/environment/terrain/environmentTerrainValleys.cpp | fantasiorona/LGen | bb670278b7faf82154d6256e6a283fa3e226c00b | [
"MIT"
] | 22 | 2019-08-01T22:04:43.000Z | 2021-12-23T07:53:59.000Z | src/console/commands/environment/terrain/environmentTerrainValleys.cpp | fantasiorona/LGen | bb670278b7faf82154d6256e6a283fa3e226c00b | [
"MIT"
] | 15 | 2019-05-01T10:57:36.000Z | 2019-05-27T11:23:42.000Z | src/console/commands/environment/terrain/environmentTerrainValleys.cpp | fantasiorona/LGen | bb670278b7faf82154d6256e6a283fa3e226c00b | [
"MIT"
] | 4 | 2019-08-02T08:07:45.000Z | 2022-01-22T00:46:03.000Z | #include "environmentTerrainValleys.h"
#include "environment/terrain/terrainValleys.h"
using namespace LGen;
const std::string Command::Environment::Terrain::Valleys::KEYWORD = "valleys";
const std::string Command::Environment::Terrain::Valleys::FILE_HELP = "text/helpEnvironmentTerrainValleys.txt";
Command::Environment::Terrain::Valleys::Valleys() :
Command({ KEYWORD }, FILE_HELP, 3) {
}
void Command::Environment::Terrain::Valleys::application(
const std::vector<std::string> &arguments,
Console &console) {
if(!workspace.environment) {
console << MSG_NO_ENVIRONMENT << std::endl;
return;
}
try {
const auto width = std::stof(arguments[ARG_WIDTH]);
const auto height = std::stof(arguments[ARG_HEIGHT]);
const auto resolution = std::stof(arguments[ARG_RESOLUTION]);
workspace.environment->setTerrain(std::make_unique<TerrainValleys>(width, height, resolution));
}
catch(...) {
console << MSG_INVALID_INPUT << std::endl;
}
}
| 27.428571 | 111 | 0.734375 | fantasiorona |
275af587f3742e93eef69ddd318501c98c79f037 | 3,214 | hpp | C++ | Code/Engine/Renderer/Effects/Tonemapping.hpp | ntaylorbishop/Copycat | c02f2881f0700a33a2630fd18bc409177d80b8cd | [
"MIT"
] | 2 | 2017-10-02T03:18:55.000Z | 2018-11-21T16:30:36.000Z | Code/Engine/Renderer/Effects/Tonemapping.hpp | ntaylorbishop/Copycat | c02f2881f0700a33a2630fd18bc409177d80b8cd | [
"MIT"
] | null | null | null | Code/Engine/Renderer/Effects/Tonemapping.hpp | ntaylorbishop/Copycat | c02f2881f0700a33a2630fd18bc409177d80b8cd | [
"MIT"
] | null | null | null | #pragma once
#include "Engine/General/Core/EngineCommon.hpp"
#include "Engine/Renderer/General/RenderCommon.hpp"
#include "Engine/Math/Objects/AABB3.hpp"
class TextureBuffer;
class Material;
class Framebuffer;
const float MIN_EXPOSURE = 1.6f;
const float MAX_EXPOSURE = 6.f;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//EXPOSURE VOLUME
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//---------------------------------------------------------------------------------------------------------------------------
struct ExposureVolume {
ExposureVolume();
ExposureVolume(const AABB3& vol, float exposure)
: m_volume(vol)
, m_exposureVal(exposure)
{ }
AABB3 m_volume = AABB3();
float m_exposureVal = 0.f;
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TONEMAPPING PASS CLASS
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//---------------------------------------------------------------------------------------------------------------------------
class Tonemapping {
public:
//GET
static Tonemapping* Get();
//UPDATE RENDER
void Update(float deltaSeconds);
void RunPass();
//ADD VOLUMES
void AddExposureVolume(const AABB3& volume, float exposureVal);
void SetMinExposure(float minExposure) { m_minExposure = minExposure; }
void SetMaxExposure(float maxExposure) { m_maxExposure = maxExposure; }
void SetExposureChangeRate(float changeRate) { m_exposureChangeRate = changeRate; }
void SetDefaultExposure(float defExp) { m_defaultExposure = defExp; }
void EnableDebugVisualizer() { m_debugVisualizer = true; }
void DisableDebugVisualizer() { m_debugVisualizer = false; }
void ToggleExposureVolumes(bool enabled) { m_exposureVolumesEnabled = enabled; }
private:
//STRUCTORS
Tonemapping();
~Tonemapping();
static void Shutdown();
TextureBuffer* m_colorTarget = nullptr;
Material* m_tonemappingMat = nullptr;
Framebuffer* m_tonemapFBO = nullptr;
float m_minExposure = 0.f;
float m_maxExposure = 0.f;
float m_exposureChangeRate = 0.f;
float m_exposure = 0.f;
float m_targetExposure = 1.f;
float m_defaultExposure = 1.f;
MeshID m_fullScreenMesh = 0;
bool m_debugDraw = false;
bool m_debugVisualizer = false;
bool m_exposureVolumesEnabled = true;
std::vector<ExposureVolume> m_exposureVolumes;
static Tonemapping* s_HDR;
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//INLINES
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//---------------------------------------------------------------------------------------------------------------------------
inline void Tonemapping::AddExposureVolume(const AABB3& volume, float exposureVal) {
m_exposureVolumes.push_back(ExposureVolume(volume, exposureVal));
}
| 33.479167 | 125 | 0.47822 | ntaylorbishop |
275e4de2d23f93672a8e3a261c6cb895b631b1a2 | 18,965 | cpp | C++ | CaptureManagerSource/SampleAccumulatorNode/SampleAccumulator.cpp | luoyingwen/CaptureManagerSDK | e96395a120175a45c56ff4e2b3283b807a42fd75 | [
"MIT"
] | 64 | 2020-07-20T09:35:16.000Z | 2022-03-27T19:13:08.000Z | CaptureManagerSource/SampleAccumulatorNode/SampleAccumulator.cpp | luoyingwen/CaptureManagerSDK | e96395a120175a45c56ff4e2b3283b807a42fd75 | [
"MIT"
] | 8 | 2020-07-30T09:20:28.000Z | 2022-03-03T22:37:10.000Z | CaptureManagerSource/SampleAccumulatorNode/SampleAccumulator.cpp | luoyingwen/CaptureManagerSDK | e96395a120175a45c56ff4e2b3283b807a42fd75 | [
"MIT"
] | 28 | 2020-07-20T13:02:42.000Z | 2022-03-18T07:36:05.000Z | /*
MIT License
Copyright(c) 2020 Evgeny Pereguda
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "SampleAccumulator.h"
#include "../MediaFoundationManager/MediaFoundationManager.h"
#include "../Common/MFHeaders.h"
#include "../Common/Common.h"
#include "../LogPrintOut/LogPrintOut.h"
#include "../MemoryManager/MemoryManager.h"
#include "../Common/Singleton.h"
namespace CaptureManager
{
namespace Transform
{
namespace Accumulator
{
using namespace CaptureManager::Core;
SampleAccumulator::SampleAccumulator(
UINT32 aAccumulatorSize) :
mAccumulatorSize(aAccumulatorSize),
mPtrOutputSampleAccumulator(nullptr),
mEndOfStream(false),
mCurrentLength(0)
{
mPtrInputSampleAccumulator = &mFirstSampleAccumulator;
mPtrOutputSampleAccumulator = &mSecondSampleAccumulator;
Singleton<MemoryManager>::getInstance().initialize();
}
SampleAccumulator::~SampleAccumulator()
{
}
STDMETHODIMP SampleAccumulator::GetStreamLimits(DWORD* aPtrInputMinimum, DWORD* aPtrInputMaximum,
DWORD* aPtrOutputMinimum, DWORD* aPtrOutputMaximum)
{
HRESULT lresult = E_FAIL;
do
{
LOG_CHECK_STATE_DESCR(aPtrInputMinimum == NULL ||
aPtrInputMaximum == NULL ||
aPtrOutputMinimum == NULL ||
aPtrOutputMaximum == NULL, E_POINTER);
*aPtrInputMinimum = 1;
*aPtrInputMaximum = 1;
*aPtrOutputMinimum = 1;
*aPtrOutputMaximum = 1;
lresult = S_OK;
} while (false);
return lresult;
}
STDMETHODIMP SampleAccumulator::GetStreamIDs(DWORD aInputIDArraySize, DWORD* aPtrInputIDs,
DWORD aOutputIDArraySize, DWORD* aPtrOutputIDs)
{
return E_NOTIMPL;
}
STDMETHODIMP SampleAccumulator::GetStreamCount(DWORD* aPtrInputStreams, DWORD* aPtrOutputStreams)
{
HRESULT lresult = E_FAIL;
do
{
LOG_CHECK_STATE_DESCR(aPtrInputStreams == NULL || aPtrOutputStreams == NULL, E_POINTER);
*aPtrInputStreams = 1;
*aPtrOutputStreams = 1;
lresult = S_OK;
} while (false);
return lresult;
}
STDMETHODIMP SampleAccumulator::GetInputStreamInfo(DWORD aInputStreamID,
MFT_INPUT_STREAM_INFO* aPtrStreamInfo)
{
HRESULT lresult = S_OK;
do
{
std::lock_guard<std::mutex> lock(mMutex);
LOG_CHECK_PTR_MEMORY(aPtrStreamInfo);
LOG_CHECK_STATE_DESCR(aInputStreamID != 0, MF_E_INVALIDSTREAMNUMBER);
aPtrStreamInfo->dwFlags = MFT_INPUT_STREAM_WHOLE_SAMPLES |
MFT_INPUT_STREAM_SINGLE_SAMPLE_PER_BUFFER;
aPtrStreamInfo->cbMaxLookahead = 0;
aPtrStreamInfo->cbAlignment = 0;
aPtrStreamInfo->hnsMaxLatency = 0;
aPtrStreamInfo->cbSize = 0;
} while (false);
return lresult;
}
STDMETHODIMP SampleAccumulator::GetOutputStreamInfo(DWORD aOutputStreamID,
MFT_OUTPUT_STREAM_INFO* aPtrStreamInfo)
{
HRESULT lresult = S_OK;
do
{
std::lock_guard<std::mutex> lock(mMutex);
LOG_CHECK_PTR_MEMORY(aPtrStreamInfo);
LOG_CHECK_STATE_DESCR(aOutputStreamID != 0, MF_E_INVALIDSTREAMNUMBER);
aPtrStreamInfo->dwFlags =
MFT_OUTPUT_STREAM_WHOLE_SAMPLES |
MFT_OUTPUT_STREAM_SINGLE_SAMPLE_PER_BUFFER |
MFT_OUTPUT_STREAM_FIXED_SAMPLE_SIZE |
MFT_OUTPUT_STREAM_PROVIDES_SAMPLES;
aPtrStreamInfo->cbAlignment = 0;
aPtrStreamInfo->cbSize = 0;
} while (false);
return lresult;
}
STDMETHODIMP SampleAccumulator::GetInputStreamAttributes(DWORD aInputStreamID,
IMFAttributes** aPtrPtrAttributes)
{
return E_NOTIMPL;
}
STDMETHODIMP SampleAccumulator::GetOutputStreamAttributes(DWORD aOutputStreamID,
IMFAttributes** aPtrPtrAttributes)
{
return E_NOTIMPL;
}
STDMETHODIMP SampleAccumulator::DeleteInputStream(DWORD aStreamID)
{
return E_NOTIMPL;
}
STDMETHODIMP SampleAccumulator::AddInputStreams(DWORD aStreams, DWORD* aPtrStreamIDs)
{
return E_NOTIMPL;
}
STDMETHODIMP SampleAccumulator::GetInputAvailableType(DWORD aInputStreamID, DWORD aTypeIndex,
IMFMediaType** aPtrPtrType)
{
HRESULT lresult = S_OK;
CComPtrCustom<IMFMediaType> lMediaType;
do
{
std::lock_guard<std::mutex> lock(mMutex);
LOG_CHECK_PTR_MEMORY(aPtrPtrType);
LOG_CHECK_STATE_DESCR(aInputStreamID != 0, MF_E_INVALIDSTREAMNUMBER);
*aPtrPtrType = NULL;
if (!mInputMediaType)
{
*aPtrPtrType = lMediaType.Detach();
}
else if (aTypeIndex == 0)
{
*aPtrPtrType = mInputMediaType.get();
(*aPtrPtrType)->AddRef();
}
else
{
lresult = MF_E_NO_MORE_TYPES;
}
} while (false);
return lresult;
}
STDMETHODIMP SampleAccumulator::GetOutputAvailableType(DWORD aOutputStreamID, DWORD aTypeIndex,
IMFMediaType** aPtrPtrType)
{
HRESULT lresult = S_OK;
CComPtrCustom<IMFMediaType> lMediaType;
do
{
std::lock_guard<std::mutex> lock(mMutex);
LOG_CHECK_PTR_MEMORY(aPtrPtrType);
LOG_CHECK_STATE_DESCR(aOutputStreamID != 0, MF_E_INVALIDSTREAMNUMBER);
if (!mOutputMediaType)
{
*aPtrPtrType = lMediaType.get();
(*aPtrPtrType)->AddRef();
}
else
{
*aPtrPtrType = mOutputMediaType.get();
(*aPtrPtrType)->AddRef();
}
} while (false);
return lresult;
}
STDMETHODIMP SampleAccumulator::SetInputType(DWORD aInputStreamID, IMFMediaType* aPtrType,
DWORD aFlags)
{
HRESULT lresult = S_OK;
CComPtrCustom<IMFAttributes> lTypeAttributes;
do
{
lTypeAttributes = aPtrType;
std::lock_guard<std::mutex> lock(mMutex);
LOG_CHECK_STATE_DESCR(aInputStreamID != 0, MF_E_INVALIDSTREAMNUMBER);
LOG_CHECK_STATE_DESCR(!mFirstSampleAccumulator.empty() || !mSecondSampleAccumulator.empty(),
MF_E_TRANSFORM_CANNOT_CHANGE_MEDIATYPE_WHILE_PROCESSING);
if (aPtrType != nullptr && !(!mInputMediaType))
{
BOOL lBoolResult = FALSE;
LOG_INVOKE_MF_METHOD(Compare,
aPtrType,
lTypeAttributes,
MF_ATTRIBUTES_MATCH_INTERSECTION,
&lBoolResult);
if (lBoolResult == FALSE)
{
lresult = MF_E_INVALIDMEDIATYPE;
break;
}
}
if (aFlags != MFT_SET_TYPE_TEST_ONLY)
{
mInputMediaType = aPtrType;
PROPVARIANT lVarItem;
LOG_INVOKE_MF_METHOD(GetItem,
mInputMediaType,
MF_MT_FRAME_SIZE,
&lVarItem);
UINT32 lHigh = 0, lLow = 0;
DataParser::unpack2UINT32AsUINT64(lVarItem, lHigh, lLow);
LONG lstride = 0;
do
{
LOG_INVOKE_MF_METHOD(GetUINT32,
mInputMediaType,
MF_MT_DEFAULT_STRIDE,
((UINT32*)&lstride));
} while (false);
//if (FAILED(lresult))
//{
// GUID lSubType;
// LOG_INVOKE_MF_METHOD(GetGUID,
// mInputMediaType,
// MF_MT_SUBTYPE,
// &lSubType);
//
// lresult = LOG_INVOKE_MF_FUNCTION(MFGetStrideForBitmapInfoHeader,
// lSubType.Data1,
// lHigh,
// &lstride);
// LOG_CHECK_STATE(lstride == 0);
// LOG_INVOKE_MF_METHOD(SetUINT32,
// mInputMediaType,
// MF_MT_DEFAULT_STRIDE,
// *((UINT32*)&lstride));
//}
if (SUCCEEDED(lresult))
mCurrentLength = lLow * ::abs(lstride);
lresult = S_OK;
mOutputMediaType = aPtrType;
}
} while (false);
return lresult;
}
STDMETHODIMP SampleAccumulator::SetOutputType(DWORD aOutputStreamID, IMFMediaType* aPtrType,
DWORD aFlags)
{
HRESULT lresult = S_OK;
CComPtrCustom<IMFMediaType> lType;
do
{
lType = aPtrType;
std::lock_guard<std::mutex> lock(mMutex);
LOG_CHECK_STATE_DESCR(aOutputStreamID != 0, MF_E_INVALIDSTREAMNUMBER);
LOG_CHECK_STATE_DESCR(!mFirstSampleAccumulator.empty() || !mSecondSampleAccumulator.empty(),
MF_E_TRANSFORM_CANNOT_CHANGE_MEDIATYPE_WHILE_PROCESSING);
if (!(!lType) && !(!mInputMediaType))
{
DWORD flags = 0;
LOG_INVOKE_MF_METHOD(IsEqual,
lType,
mInputMediaType,
&flags);
}
if (aFlags != MFT_SET_TYPE_TEST_ONLY)
{
mOutputMediaType = lType.Detach();
}
} while (false);
return lresult;
}
STDMETHODIMP SampleAccumulator::GetInputCurrentType(DWORD aInputStreamID, IMFMediaType** aPtrPtrType)
{
HRESULT lresult = S_OK;
do
{
std::lock_guard<std::mutex> lock(mMutex);
LOG_CHECK_PTR_MEMORY(aPtrPtrType);
LOG_CHECK_STATE_DESCR(aInputStreamID != 0, MF_E_INVALIDSTREAMNUMBER);
LOG_CHECK_STATE_DESCR(!mInputMediaType, MF_E_TRANSFORM_TYPE_NOT_SET);
*aPtrPtrType = mInputMediaType;
(*aPtrPtrType)->AddRef();
} while (false);
return lresult;
}
STDMETHODIMP SampleAccumulator::GetOutputCurrentType(DWORD aOutputStreamID, IMFMediaType** aPtrPtrType)
{
HRESULT lresult = S_OK;
do
{
std::lock_guard<std::mutex> lock(mMutex);
LOG_CHECK_PTR_MEMORY(aPtrPtrType);
LOG_CHECK_STATE_DESCR(aOutputStreamID != 0, MF_E_INVALIDSTREAMNUMBER);
LOG_CHECK_STATE_DESCR(!mOutputMediaType, MF_E_TRANSFORM_TYPE_NOT_SET);
*aPtrPtrType = mOutputMediaType;
(*aPtrPtrType)->AddRef();
} while (false);
return lresult;
}
STDMETHODIMP SampleAccumulator::GetInputStatus(DWORD aInputStreamID, DWORD* aPtrFlags)
{
HRESULT lresult = S_OK;
do
{
std::lock_guard<std::mutex> lock(mMutex);
LOG_CHECK_PTR_MEMORY(aPtrFlags);
LOG_CHECK_STATE_DESCR(aInputStreamID != 0, MF_E_INVALIDSTREAMNUMBER);
*aPtrFlags = MFT_INPUT_STATUS_ACCEPT_DATA;
} while (false);
return lresult;
}
STDMETHODIMP SampleAccumulator::GetOutputStatus(DWORD* aPtrFlags)
{
return E_NOTIMPL;
}
STDMETHODIMP SampleAccumulator::SetOutputBounds(LONGLONG aLowerBound, LONGLONG aUpperBound)
{
return E_NOTIMPL;
}
STDMETHODIMP SampleAccumulator::ProcessEvent(DWORD aInputStreamID, IMFMediaEvent* aPtrEvent)
{
return E_NOTIMPL;
}
STDMETHODIMP SampleAccumulator::GetAttributes(IMFAttributes** aPtrPtrAttributes)
{
return E_NOTIMPL;
}
STDMETHODIMP SampleAccumulator::ProcessMessage(MFT_MESSAGE_TYPE aMessage, ULONG_PTR aParam)
{
HRESULT lresult = S_OK;
do
{
std::lock_guard<std::mutex> lock(mMutex);
if (aMessage == MFT_MESSAGE_COMMAND_FLUSH)
{
while (!mFirstSampleAccumulator.empty())
{
mFirstSampleAccumulator.pop();
}
while (!mSecondSampleAccumulator.empty())
{
mSecondSampleAccumulator.pop();
}
}
else if (aMessage == MFT_MESSAGE_COMMAND_DRAIN)
{
while (!mFirstSampleAccumulator.empty())
{
mFirstSampleAccumulator.pop();
}
while (!mSecondSampleAccumulator.empty())
{
mSecondSampleAccumulator.pop();
}
}
else if (aMessage == MFT_MESSAGE_NOTIFY_BEGIN_STREAMING)
{
}
else if (aMessage == MFT_MESSAGE_NOTIFY_END_STREAMING)
{
}
else if (aMessage == MFT_MESSAGE_NOTIFY_END_OF_STREAM)
{
mEndOfStream = true;
}
else if (aMessage == MFT_MESSAGE_NOTIFY_START_OF_STREAM)
{
}
} while (false);
return lresult;
}
STDMETHODIMP SampleAccumulator::ProcessInput(DWORD aInputStreamID, IMFSample* aPtrSample,
DWORD aFlags)
{
HRESULT lresult = S_OK;
DWORD dwBufferCount = 0;
do
{
std::lock_guard<std::mutex> lock(mMutex);
LOG_CHECK_PTR_MEMORY(aPtrSample);
LOG_CHECK_STATE(aInputStreamID != 0 || aFlags != 0);
LOG_CHECK_STATE_DESCR(!mInputMediaType, MF_E_NOTACCEPTING);
LOG_CHECK_STATE_DESCR(!mOutputMediaType, MF_E_NOTACCEPTING);
CComPtrCustom<IMFSample> lUnk;
LOG_INVOKE_FUNCTION(copySample,
aPtrSample, &lUnk);
if (mPtrInputSampleAccumulator->size() >= mAccumulatorSize )
{
mPtrInputSampleAccumulator->front().Release();
mPtrInputSampleAccumulator->pop();
}
mPtrInputSampleAccumulator->push(lUnk);
lresult = S_FALSE;// MF_E_TRANSFORM_NEED_MORE_INPUT;
} while (false);
return lresult;
}
HRESULT SampleAccumulator::copySample(
IMFSample* aPtrOriginalSample,
IMFSample** aPtrPtrCopySample)
{
class MediaBufferLock
{
public:
MediaBufferLock(
IMFMediaBuffer* aPtrInputBuffer,
DWORD& aRefMaxLength,
DWORD& aRefCurrentLength,
BYTE** aPtrPtrInputBuffer,
HRESULT& aRefResult)
{
HRESULT lresult;
do
{
LOG_CHECK_PTR_MEMORY(aPtrInputBuffer);
LOG_CHECK_PTR_MEMORY(aPtrPtrInputBuffer);
LOG_INVOKE_POINTER_METHOD(aPtrInputBuffer, Lock,
aPtrPtrInputBuffer,
&aRefMaxLength,
&aRefCurrentLength);
LOG_CHECK_PTR_MEMORY(aPtrPtrInputBuffer);
mInputBuffer = aPtrInputBuffer;
} while (false);
aRefResult = lresult;
}
~MediaBufferLock()
{
if (mInputBuffer)
{
mInputBuffer->Unlock();
}
}
private:
CComPtrCustom<IMFMediaBuffer> mInputBuffer;
MediaBufferLock(
const MediaBufferLock&){}
MediaBufferLock& operator=(
const MediaBufferLock&){
return *this;
}
};
HRESULT lresult;
CComPtrCustom<IMFSample> lOutputSample;
CComPtrCustom<IMFMediaBuffer> lMediaBuffer;
CComPtrCustom<IMFMediaBuffer> lOriginalMediaBuffer;
do
{
LOG_CHECK_PTR_MEMORY(aPtrOriginalSample);
LOG_CHECK_PTR_MEMORY(aPtrPtrCopySample);
LOG_INVOKE_MF_METHOD(GetBufferByIndex, aPtrOriginalSample,
0,
&lOriginalMediaBuffer);
DWORD lCurrentLength;
LOG_INVOKE_MF_METHOD(GetCurrentLength, lOriginalMediaBuffer,
&lCurrentLength);
LOG_INVOKE_MF_FUNCTION(MFCreateSample,
&lOutputSample);
LOG_INVOKE_MF_FUNCTION(MFCreateMemoryBuffer,
lCurrentLength,
&lMediaBuffer);
LOG_INVOKE_MF_FUNCTION(SetCurrentLength, lMediaBuffer,
lCurrentLength);
LOG_INVOKE_MF_METHOD(AddBuffer,
lOutputSample,
lMediaBuffer);
LOG_INVOKE_MF_METHOD(CopyAllItems, aPtrOriginalSample,
lOutputSample);
MFTIME lTime;
LOG_INVOKE_MF_METHOD(GetSampleDuration, aPtrOriginalSample,
&lTime);
LOG_INVOKE_MF_METHOD(SetSampleDuration, lOutputSample, lTime);
LOG_INVOKE_MF_METHOD(GetSampleTime, aPtrOriginalSample, &lTime);
LOG_INVOKE_MF_METHOD(SetSampleTime, lOutputSample, lTime);
DWORD lMaxDestLength;
DWORD lCurrentDestLength;
BYTE* lPtrDestBuffer;
MediaBufferLock lMediaBufferLock(
lMediaBuffer,
lMaxDestLength,
lCurrentDestLength,
&lPtrDestBuffer,
lresult);
if (FAILED(lresult))
{
break;
}
DWORD lMaxScrLength;
DWORD lCurrentScrLength;
BYTE* lPtrScrBuffer;
MediaBufferLock lScrMediaBufferLock(
lOriginalMediaBuffer,
lMaxScrLength,
lCurrentScrLength,
&lPtrScrBuffer,
lresult);
if (FAILED(lresult))
{
break;
}
MemoryManager::memcpy(lPtrDestBuffer, lPtrScrBuffer, lCurrentLength > lCurrentScrLength ? lCurrentScrLength : lCurrentLength);
LOG_INVOKE_QUERY_INTERFACE_METHOD(lOutputSample, aPtrPtrCopySample);
} while (false);
return lresult;
}
STDMETHODIMP SampleAccumulator::ProcessOutput(DWORD aFlags, DWORD aOutputBufferCount,
MFT_OUTPUT_DATA_BUFFER* aPtrOutputSamples, DWORD* aPtrStatus)
{
HRESULT lresult = S_OK;
do
{
LOG_CHECK_PTR_MEMORY(aPtrOutputSamples);
LOG_CHECK_PTR_MEMORY(aPtrStatus);
LOG_CHECK_STATE_DESCR(aOutputBufferCount != 1 || aFlags != 0, E_INVALIDARG);
//LOG_CHECK_STATE_DESCR(!mSample, MF_E_TRANSFORM_NEED_MORE_INPUT);
CComPtrCustom<IMFSample> lOutputSample;
{
std::lock_guard<std::mutex> lock(mMutex);
if (mEndOfStream)
{
aPtrOutputSamples[0].pSample = lOutputSample.Detach();
aPtrOutputSamples[0].dwStatus = 0;
*aPtrStatus = 0;
lresult = MF_E_TRANSFORM_NEED_MORE_INPUT;
break;
}
if (mFirstSampleAccumulator.empty() && mSecondSampleAccumulator.empty())
{
CComPtrCustom<IMFMediaBuffer> lMediaBuffer;
LOG_INVOKE_MF_FUNCTION(MFCreateSample,
&lOutputSample);
LOG_INVOKE_MF_FUNCTION(MFCreateMemoryBuffer,
mCurrentLength,
&lMediaBuffer);
LOG_CHECK_PTR_MEMORY(lMediaBuffer);
LOG_INVOKE_MF_METHOD(SetCurrentLength,
lMediaBuffer,
mCurrentLength);
LOG_INVOKE_MF_METHOD(AddBuffer,
lOutputSample,
lMediaBuffer);
aPtrOutputSamples[0].pSample = lOutputSample.Detach();
aPtrOutputSamples[0].dwStatus = 0;
*aPtrStatus = 0;
break;
}
else if (mPtrOutputSampleAccumulator->empty())
{
auto ltempPtr = mPtrOutputSampleAccumulator;
mPtrOutputSampleAccumulator = mPtrInputSampleAccumulator;
mPtrInputSampleAccumulator = ltempPtr;
//CComPtrCustom<IMFMediaBuffer> lMediaBuffer;
//LOG_INVOKE_MF_FUNCTION(MFCreateSample,
// &lOutputSample);
//LOG_INVOKE_MF_FUNCTION(MFCreateMemoryBuffer,
// 1,
// &lMediaBuffer);
//LOG_INVOKE_MF_METHOD(AddBuffer,
// lOutputSample,
// lMediaBuffer);
//lMediaBuffer->SetCurrentLength(1);
//aPtrOutputSamples[0].pSample = lOutputSample.Detach();
//aPtrOutputSamples[0].dwStatus = 0;
//*aPtrStatus = 0;
//break;
}
}
aPtrOutputSamples[0].pSample = mPtrOutputSampleAccumulator->front().Detach();
mPtrOutputSampleAccumulator->pop();
aPtrOutputSamples[0].dwStatus = 0;
*aPtrStatus = 0;
} while (false);
return lresult;
}
}
}
} | 22.443787 | 131 | 0.670393 | luoyingwen |
275e5f0f0c8ed2d36c61c7e308e3de6edd03bc34 | 11,634 | cpp | C++ | source/io/net/TlsServer.cpp | tarm-project/tarm-io | 6aebd85573f65017decf81be073c8b13ce6ac12c | [
"MIT"
] | 4 | 2021-01-14T15:19:35.000Z | 2022-01-09T09:22:18.000Z | source/io/net/TlsServer.cpp | ink-splatters/tarm-io | 6aebd85573f65017decf81be073c8b13ce6ac12c | [
"MIT"
] | null | null | null | source/io/net/TlsServer.cpp | ink-splatters/tarm-io | 6aebd85573f65017decf81be073c8b13ce6ac12c | [
"MIT"
] | 1 | 2020-08-05T21:14:59.000Z | 2020-08-05T21:14:59.000Z | /*----------------------------------------------------------------------------------------------
* Copyright (c) 2020 - present Alexander Voitenko
* Licensed under the MIT License. See License.txt in the project root for license information.
*----------------------------------------------------------------------------------------------*/
#include "net/TlsServer.h"
#include "Convert.h"
#include "net/TcpServer.h"
#include "detail/ConstexprString.h"
#include "detail/TlsContext.h"
#include "detail/OpenSslContext.h"
#include <openssl/pem.h>
#include <openssl/evp.h>
#include <openssl/ec.h>
#include <openssl/bn.h>
#include <iostream>
#include <memory>
#include <cstdio>
namespace tarm {
namespace io {
namespace net {
class TlsServer::Impl {
public:
Impl(EventLoop& loop, const fs::Path& certificate_path, const fs::Path& private_key_path, TlsVersionRange version_range, TlsServer& parent);
~Impl();
Error listen(const Endpoint endpoint,
const NewConnectionCallback& new_connection_callback,
const DataReceivedCallback& data_receive_callback,
const CloseConnectionCallback& close_connection_callback,
int backlog_size);
void shutdown(const ShutdownServerCallback& shutdown_callback);
void close(const CloseServerCallback& close_callback);
std::size_t connected_clients_count() const;
bool certificate_and_key_match();
TlsVersionRange version_range() const;
bool schedule_removal();
protected:
const SSL_METHOD* ssl_method();
// callbacks
void on_new_connection(TcpConnectedClient& tcp_client, const Error& tcp_error);
void on_data_receive(TcpConnectedClient& tcp_client, const DataChunk&, const Error& tcp_error);
void on_connection_close(TcpConnectedClient& tcp_client, const Error& tcp_error);
private:
using X509Ptr = std::unique_ptr<::X509, decltype(&::X509_free)>;
using EvpPkeyPtr = std::unique_ptr<::EVP_PKEY, decltype(&::EVP_PKEY_free)>;
TlsServer* m_parent;
EventLoop* m_loop;
TcpServer* m_tcp_server;
fs::Path m_certificate_path;
fs::Path m_private_key_path;
X509Ptr m_certificate;
EvpPkeyPtr m_private_key;
TlsVersionRange m_version_range;
detail::OpenSslContext<TlsServer, TlsServer::Impl> m_openssl_context;
NewConnectionCallback m_new_connection_callback = nullptr;
DataReceivedCallback m_data_receive_callback = nullptr;
CloseConnectionCallback m_close_connection_callback = nullptr;
};
TlsServer::Impl::Impl(EventLoop& loop,
const fs::Path& certificate_path,
const fs::Path& private_key_path,
TlsVersionRange version_range,
TlsServer& parent) :
m_parent(&parent),
m_loop(&loop),
m_tcp_server(new TcpServer(loop)),
m_certificate_path(certificate_path),
m_private_key_path(private_key_path),
m_certificate(nullptr, ::X509_free),
m_private_key(nullptr, ::EVP_PKEY_free),
m_version_range(version_range),
m_openssl_context(loop, parent) {
}
TlsServer::Impl::~Impl() {
}
bool TlsServer::Impl::schedule_removal() {
LOG_TRACE(m_loop, m_parent, "");
if (m_parent->is_removal_scheduled()) {
LOG_TRACE(m_loop, m_parent, "is_removal_scheduled: true");
return true;
}
if (m_tcp_server->is_open()) {
m_tcp_server->close([this](TcpServer& server, const Error& error) {
if (error.code() != StatusCode::NOT_CONNECTED) {
LOG_ERROR(this->m_loop, error);
}
this->m_parent->schedule_removal();
server.schedule_removal();
});
m_parent->set_removal_scheduled();
return false;
} else {
m_tcp_server->schedule_removal();
return true;
}
}
const SSL_METHOD* TlsServer::Impl::ssl_method() {
return SSLv23_server_method(); // This call includes also TLS versions
}
TlsVersionRange TlsServer::Impl::version_range() const {
return m_version_range;
}
void TlsServer::Impl::on_new_connection(TcpConnectedClient& tcp_client, const Error& tcp_error) {
detail::TlsContext context {
m_certificate.get(),
m_private_key.get(),
m_openssl_context.ssl_ctx(),
m_version_range
};
// Can not use unique_ptr here because TlsConnectedClient has proteted destructor and
// TlsServer is a friend of TlsConnectedClient, but we can not transfer that friendhsip to unique_ptr.
auto tls_client = new TlsConnectedClient(*m_loop, *m_parent, m_new_connection_callback, tcp_client, &context);
if (tcp_error) {
if (m_new_connection_callback) {
m_new_connection_callback(*tls_client, tcp_error);
}
delete tls_client;
return;
}
Error tls_init_error = tls_client->init_ssl();
if (tls_init_error) {
if (m_new_connection_callback) {
m_new_connection_callback(*tls_client, tls_init_error);
}
tcp_client.set_user_data(nullptr); // to not process deletion in on_connection_close
tcp_client.close();
delete tls_client;
} else {
tls_client->set_data_receive_callback(m_data_receive_callback);
}
}
void TlsServer::Impl::on_data_receive(TcpConnectedClient& tcp_client, const DataChunk& chunk, const Error& tcp_error) {
auto& tls_client = *reinterpret_cast<TlsConnectedClient*>(tcp_client.user_data());
tls_client.on_data_receive(chunk.buf.get(), chunk.size, tcp_error);
}
void TlsServer::Impl::on_connection_close(TcpConnectedClient& tcp_client, const Error& tcp_error) {
LOG_TRACE(this->m_loop, "Removing TLS client");
if (tcp_client.user_data()) {
auto& tls_client = *reinterpret_cast<TlsConnectedClient*>(tcp_client.user_data());
if (m_close_connection_callback) {
m_close_connection_callback(tls_client, tcp_error);
}
delete &tls_client;
}
}
Error TlsServer::Impl::listen(const Endpoint endpoint,
const NewConnectionCallback& new_connection_callback,
const DataReceivedCallback& data_receive_callback,
const CloseConnectionCallback& close_connection_callback,
int backlog_size) {
m_new_connection_callback = new_connection_callback;
m_data_receive_callback = data_receive_callback;
m_close_connection_callback = close_connection_callback;
using FilePtr = std::unique_ptr<FILE, decltype(&std::fclose)>;
FilePtr certificate_file(std::fopen(m_certificate_path.string().c_str(), "r"), &std::fclose);
if (certificate_file == nullptr) {
return Error(StatusCode::TLS_CERTIFICATE_FILE_NOT_EXIST);
}
m_certificate.reset(PEM_read_X509(certificate_file.get(), nullptr, nullptr, nullptr));
if (m_certificate == nullptr) {
return Error(StatusCode::TLS_CERTIFICATE_INVALID);
}
FilePtr private_key_file(std::fopen(m_private_key_path.string().c_str(), "r"), &std::fclose);
if (private_key_file == nullptr) {
return Error(StatusCode::TLS_PRIVATE_KEY_FILE_NOT_EXIST);
}
m_private_key.reset(PEM_read_PrivateKey(private_key_file.get(), nullptr, nullptr, nullptr));
if (m_private_key == nullptr) {
return Error(StatusCode::TLS_PRIVATE_KEY_INVALID);
}
if (!certificate_and_key_match()) {
return Error(StatusCode::TLS_PRIVATE_KEY_AND_CERTIFICATE_NOT_MATCH);
}
const auto& context_init_error = m_openssl_context.init_ssl_context(ssl_method());
if (context_init_error) {
return context_init_error;
}
const auto& version_error = m_openssl_context.set_tls_version(std::get<0>(m_version_range), std::get<1>(m_version_range));
if (version_error) {
return version_error;
}
const auto& certificate_error = m_openssl_context.ssl_init_certificate_and_key(m_certificate.get(), m_private_key.get());
if (certificate_error) {
return certificate_error;
}
using namespace std::placeholders;
return m_tcp_server->listen(endpoint,
std::bind(&TlsServer::Impl::on_new_connection, this, _1, _2),
std::bind(&TlsServer::Impl::on_data_receive, this, _1, _2, _3),
std::bind(&TlsServer::Impl::on_connection_close, this, _1, _2));
}
void TlsServer::Impl::shutdown(const ShutdownServerCallback& shutdown_callback) {
if (shutdown_callback) {
m_tcp_server->shutdown([this, shutdown_callback](TcpServer&, const Error& error) {
shutdown_callback(*m_parent, error);
});
} else {
m_tcp_server->shutdown();
}
}
void TlsServer::Impl::close(const CloseServerCallback& close_callback) {
if (close_callback) {
m_tcp_server->shutdown([this, close_callback](TcpServer&, const Error& error) {
close_callback(*m_parent, error);
});
} else {
m_tcp_server->close();
}
}
std::size_t TlsServer::Impl::connected_clients_count() const {
return m_tcp_server->connected_clients_count();
}
namespace {
//int ssl_key_type(::EVP_PKEY* pkey) {
// assert(pkey);
// return pkey ? EVP_PKEY_type(pkey->type) : NID_undef;
//}
} // namespace
bool TlsServer::Impl::certificate_and_key_match() {
assert(m_certificate);
assert(m_private_key);
return X509_verify(m_certificate.get(), m_private_key.get()) != 0;
}
///////////////////////////////////////// implementation ///////////////////////////////////////////
TlsServer::TlsServer(EventLoop& loop, const fs::Path& certificate_path, const fs::Path& private_key_path, TlsVersionRange version_range) :
Removable(loop),
m_impl(new Impl(loop, certificate_path, private_key_path, version_range, *this)) {
}
TlsServer::~TlsServer() {
}
Error TlsServer::listen(const Endpoint endpoint,
const NewConnectionCallback& new_connection_callback,
const DataReceivedCallback& data_receive_callback,
const CloseConnectionCallback& close_connection_callback,
int backlog_size) {
return m_impl->listen(endpoint, new_connection_callback, data_receive_callback, close_connection_callback, backlog_size);
}
Error TlsServer::listen(const Endpoint endpoint,
const DataReceivedCallback& data_receive_callback,
int backlog_size) {
return m_impl->listen(endpoint, nullptr, data_receive_callback, nullptr, backlog_size);
}
Error TlsServer::listen(const Endpoint endpoint,
const NewConnectionCallback& new_connection_callback,
const DataReceivedCallback& data_receive_callback,
int backlog_size) {
return m_impl->listen(endpoint, new_connection_callback, data_receive_callback, nullptr, backlog_size);
}
void TlsServer::shutdown(const CloseServerCallback& shutdown_callback) {
return m_impl->shutdown(shutdown_callback);
}
void TlsServer::close(const CloseServerCallback& close_callback) {
return m_impl->close(close_callback);
}
std::size_t TlsServer::connected_clients_count() const {
return m_impl->connected_clients_count();
}
TlsVersionRange TlsServer::version_range() const {
return m_impl->version_range();
}
void TlsServer::schedule_removal() {
const bool ready_to_remove = m_impl->schedule_removal();
if (ready_to_remove) {
Removable::schedule_removal();
}
}
} // namespace net
} // namespace io
} // namespace tarm
| 34.318584 | 144 | 0.670191 | tarm-project |
2763e7da0af34195ab15cee538b3c4b789795527 | 1,840 | cpp | C++ | docs/melb-cpp-talk-feb-2017/24a-cpp17-auto-template-parameter.cpp | RossBencina/StaticMode | 04eead233a6a03aa4f47c22f81c1d89b4e5cf5ca | [
"MIT"
] | 3 | 2017-02-15T22:49:40.000Z | 2018-04-19T15:42:57.000Z | docs/melb-cpp-talk-feb-2017/24a-cpp17-auto-template-parameter.cpp | RossBencina/StaticMode | 04eead233a6a03aa4f47c22f81c1d89b4e5cf5ca | [
"MIT"
] | 14 | 2017-02-19T14:25:30.000Z | 2017-02-20T10:11:42.000Z | docs/melb-cpp-talk-feb-2017/24a-cpp17-auto-template-parameter.cpp | RossBencina/StaticMode | 04eead233a6a03aa4f47c22f81c1d89b4e5cf5ca | [
"MIT"
] | null | null | null | //!clang++ -std=c++1z -Weverything -Wno-c++98-compat 24a-cpp17-auto-template-parameter.cpp -o z24a.out && ./z24a.out
// WARNING: bleeding edge. tested in gcc 7, possibly clang 4
// This file is optional. It's a side note about C++17 auto template parameters.
// It requires clang 4 or GCC 7 to compile.
// When C++17 arrives, "auto template parameter" syntax will allow us to
// simplify the declaration of Mode instances as follows:
// C++11:
// template<typename T, T X>
// struct Mode : ModeType<T> { ... };
//
// constexpr Mode<LineStyle, LineStyle::dotted> dotted; // <-- notice that LineStyle appears twice
// C++17: (this file)
// template<auto X> // C++17: auto template parameter
// struct Mode { ... };
//
// constexpr Mode<LineStyle::dotted> dotted; // <-- simplified
//
// http://en.cppreference.com/w/cpp/language/auto
#include <iostream> // cout
// ............................................................................
// Library code
template<typename T>
struct ModeType {}; // aka mode category
template<auto X> // C++17: auto template parameter
struct Mode : ModeType<decltype(X)> {
constexpr Mode() {}
};
// ............................................................................
enum class LineStyle { dotted, dashed, solid };
constexpr Mode<LineStyle::dotted> dotted; // note simplified syntax
constexpr Mode<LineStyle::dashed> dashed;
constexpr Mode<LineStyle::solid> solid;
class AsciiPainter {
public:
void drawLine(decltype(dotted)) {
std::cout << "..........\n";
}
void drawLine(decltype(dashed)) {
std::cout << "----------\n";
}
void drawLine(decltype(solid)) {
std::cout << "__________\n";
}
};
int main()
{
AsciiPainter painter;
painter.drawLine(dotted);
painter.drawLine(dashed);
painter.drawLine(solid);
}
| 27.462687 | 116 | 0.59837 | RossBencina |
2764a0b63daefb8e607a670a6a3612e9adc2079a | 2,885 | cpp | C++ | test/test_main.cpp | ChrizZhuang/3D_particle_simulator | cc2a0c75dc67ec7e4f89a270bca736d9425dbec0 | [
"MIT"
] | null | null | null | test/test_main.cpp | ChrizZhuang/3D_particle_simulator | cc2a0c75dc67ec7e4f89a270bca736d9425dbec0 | [
"MIT"
] | null | null | null | test/test_main.cpp | ChrizZhuang/3D_particle_simulator | cc2a0c75dc67ec7e4f89a270bca736d9425dbec0 | [
"MIT"
] | null | null | null | // File to test main functions
#include <iostream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <math.h>
#include <cmath>
#include <assert.h>
#include <string>
#include "Vector3D.hpp"
#include "SimpleParticleList.hpp"
#include "Spring1DForce.hpp"
#include "LatticeParticleList.hpp"
#include "LatticeParticleForce.hpp"
#include "GravityForce.hpp"
#include "FrictionForce.hpp"
#include "verlet_integrator.hpp"
#include "test_main.hpp"
void test_func()
{
struct Args
{
int N = 64; // -n <N> (int), number of interior particles
int Nstep = 1e4; // -nstep <Nstep> (int), number of time steps
std::string test; // -test <test> (string), the type of test
double L = 2; // -l <L> (double), length of the cubic simulation box
double t_end = 2; // -time (double), end of simulation time.
};
Args args;
args.test = "equil";
// args.test = "shift";
// args.test = "moving";
/*
* Struct to hold constants needed for the particle calculation
* NOTE: we declare it here "static const" to avoid updating values
*/
struct ParticleConst
{
double gamma = 5;
double c=0.5; // spring constant N/m
double mass = 0.1; // mass per particle, kg
};
static const ParticleConst pc;
// Defensive programming: check that the input N is an integer to the third power
int index = 0; // initiate a index to mark when the input N is not an integer to the third power
for (int i=0; i<=args.N; i++)
{
if (args.N == pow(i, 3))
{
index = 1; // change the index if the input N is an integer to the third power
}
}
if (index == 0)
{
std::cout << "error: The input N is not an integer to the third power!" << std::endl; // print out message to indicate the possible mistakes
}
assert(index == 1);
// Convert the mass value to a vector
std::vector<double> mass_vec;
mass_vec.assign(args.N, pc.mass);
// Instantiate the LatticeParticleList
LatticeParticleList lpl(args.N, mass_vec);
// Instantiate verlet_integrator
verlet_integrator vi(args.N, args.Nstep, args.test, args.L, args.t_end, pc.gamma, pc.c, pc.mass, lpl);
// Initialize the particle positions, velocities and accelerations regarding the condition
vi.init_particles(lpl);
// Test init
test_main tm(args.N, args.Nstep, args.test, args.L, args.t_end, pc.gamma, pc.c, pc.mass);
tm.test_init(lpl);
// Instantiate some objects
double equil_distance = args.L/(std::cbrt(args.N)-1);
LatticeParticleForce lpf(args.N, pc.c, equil_distance);
double drag = 0.1;
FrictionForce ff(args.N, drag);
double g[3] = {0, 0, -9.8}; // gravity in z direction
GravityForce gf(args.N, g);
// Calculate the particle final position, velocity and acceleration
vi.do_time_integration(lpl, lpf, ff, gf);
// Test integration
tm.test_results(lpl);
std::cout << ".. Main tests passed!" << std::endl;
}
| 29.141414 | 144 | 0.67383 | ChrizZhuang |
276533790d14865853af0f89f47ee160125a3ee4 | 169 | cpp | C++ | Code full house/buoi20 nguyen dinh trung duc/implement/bai 16 1352A.cpp | ducyb2001/CbyTrungDuc | 0e93394dce600876a098b90ae969575bac3788e1 | [
"Apache-2.0"
] | null | null | null | Code full house/buoi20 nguyen dinh trung duc/implement/bai 16 1352A.cpp | ducyb2001/CbyTrungDuc | 0e93394dce600876a098b90ae969575bac3788e1 | [
"Apache-2.0"
] | null | null | null | Code full house/buoi20 nguyen dinh trung duc/implement/bai 16 1352A.cpp | ducyb2001/CbyTrungDuc | 0e93394dce600876a098b90ae969575bac3788e1 | [
"Apache-2.0"
] | null | null | null | /*bai 16 1325A*/
#include<stdio.h>
int main(){
int T;
scanf("%d",&T);
while (T--)
{
int x;
scanf("%d",&x);
printf("1 %d\n",x-1);
}
}
| 12.071429 | 26 | 0.408284 | ducyb2001 |
2777883fc452b8b0d7f2cfb50caebc5a9ae8dcaa | 539 | cpp | C++ | leetcode/88/main.cpp | yukienomiya/competitive-programming | 6f5e502ba66da2f62fb37aaa786a841f64bb192a | [
"MIT"
] | null | null | null | leetcode/88/main.cpp | yukienomiya/competitive-programming | 6f5e502ba66da2f62fb37aaa786a841f64bb192a | [
"MIT"
] | null | null | null | leetcode/88/main.cpp | yukienomiya/competitive-programming | 6f5e502ba66da2f62fb37aaa786a841f64bb192a | [
"MIT"
] | null | null | null | #include <vector>
using namespace std;
class Solution {
public:
void merge(vector<int>& nums1, int m, vector<int>& nums2, int n) {
vector<int> nums3(m + n, 0);
int idx1 = 0, idx2 = 0, idx3 = 0;
while (idx1 < m && idx2 < n) {
if (nums1[idx1] <= nums2[idx2]) nums3[idx3++] = nums1[idx1++];
else nums3[idx3++] = nums2[idx2++];
}
while (idx1 < m) nums3[idx3++] = nums1[idx1++];
while (idx2 < n) nums3[idx3++] = nums2[idx2++];
for (int i = 0; i < m + n; i++) {
nums1[i] = nums3[i];
}
}
}; | 26.95 | 68 | 0.526902 | yukienomiya |
277797464e507b139fac06991ad4b81922a4e221 | 8,478 | cpp | C++ | projects/Phantom.Code/phantom/lang/Project.cpp | vlmillet/Phantom.Code | 05ed65bc4a456e76da4b2d9da1fe3dabe64ba1b3 | [
"MIT"
] | null | null | null | projects/Phantom.Code/phantom/lang/Project.cpp | vlmillet/Phantom.Code | 05ed65bc4a456e76da4b2d9da1fe3dabe64ba1b3 | [
"MIT"
] | null | null | null | projects/Phantom.Code/phantom/lang/Project.cpp | vlmillet/Phantom.Code | 05ed65bc4a456e76da4b2d9da1fe3dabe64ba1b3 | [
"MIT"
] | null | null | null | // license [
// This file is part of the Phantom project. Copyright 2011-2020 Vivien Millet.
// Distributed under the MIT license. Text available here at
// https://github.com/vlmillet/phantom
// ]
#include "Project.h"
#include "CompiledSource.h"
#include "Compiler.h"
#include "Solution.h"
#include <fstream>
#include <phantom/lang/Application.h>
#include <phantom/lang/Module.h>
#include <phantom/lang/Package.h>
#include <phantom/lang/Plugin.h>
#include <phantom/lang/SourceFile.h>
#include <phantom/utils/Path.h>
#include <phantom/utils/StringUtil.h>
#include <system_error>
namespace phantom
{
namespace lang
{
Project::~Project()
{
if (m_pModule)
{
// Compiler::Get()->cleanupProject(this);
if (!m_pModule->isNative())
{
if (m_pModule->getOwner())
Application::Get()->removeModule(m_pModule);
Application::Get()->deleteModule(m_pModule);
m_pModule = nullptr;
}
}
}
Projects Project::getDependenciesProjects() const
{
Projects projs;
for (auto pMod : getDependencies())
{
if (Project* pDep = getSolution()->getProjectFromModule(pMod))
projs.push_back(pDep);
}
return projs;
}
phantom::String Project::getSourcePath() const
{
return Path(m_Path).parentPath().genericString();
}
Package* Project::getPackageForSourceStream(SourceStream* a_pStream) const
{
PHANTOM_ASSERT(std::find(m_SourceFiles.begin(), m_SourceFiles.end(), a_pStream) != m_SourceFiles.end());
Path p(Path(a_pStream->getPath()).relative(Path(getPath()).parentPath()));
if (p.size() == 1)
{
return m_pModule->getOrCreatePackage("default");
}
String packageName;
for (size_t i = 0; i < p.size() - 1; ++i)
{
if (packageName.empty())
packageName = p[i];
else
packageName += '.' + p[i];
}
return m_pModule->getOrCreatePackage(packageName);
}
SourceFile* Project::getSourceFileByPath(StringView a_Path) const
{
for (SourceFile* pSourceFile : m_SourceFiles)
if (Path::Equivalent(Path(pSourceFile->getPath()).relative(Path(getPath()).parentPath()),
Path(a_Path).relative(Path(getPath()).parentPath())))
return pSourceFile;
return nullptr;
}
void Project::addDependency(Module* a_pModule)
{
PHANTOM_ASSERT(std::find(m_Dependencies.begin(), m_Dependencies.end(), a_pModule) == m_Dependencies.end());
PHANTOM_ASSERT(m_pSolution->getProjectFromModule(a_pModule) || a_pModule->getPlugin(),
"the module is neither a project neither a plugin");
m_Dependencies.push_back(a_pModule);
m_pModule->addDependency(a_pModule);
}
bool Project::addDependency(StringView a_Name)
{
if (std::find_if(m_Dependencies.begin(), m_Dependencies.end(), [&](Module* m) { return m->getName() == a_Name; }) !=
m_Dependencies.end())
{
PHANTOM_LOG(Warning, "'%.*s' : dependency project '%.*s' already declared",
PHANTOM_STRING_AS_PRINTF_ARG(m_Path), PHANTOM_STRING_AS_PRINTF_ARG(a_Name));
return true;
}
if (Project* pProject = m_pSolution->getProjectFromName(a_Name))
{
if (pProject == this || pProject->hasProjectDependencyCascade(this))
return false;
addDependency(pProject->getModule());
return true;
}
if (Plugin* pPlugin = Application::Get()->getPlugin(a_Name))
{
pPlugin->load();
addDependency(pPlugin->getModule());
return true;
}
return false;
}
void Project::removeDependency(Module* a_pModule)
{
PHANTOM_ASSERT(m_pSolution->getProjectFromModule(a_pModule) || a_pModule->getPlugin());
auto found = std::find(m_Dependencies.begin(), m_Dependencies.end(), a_pModule);
PHANTOM_ASSERT(found != m_Dependencies.end());
m_pModule->removeDependency(a_pModule);
m_Dependencies.erase(found);
}
bool Project::hasDependency(Module* a_pModule) const
{
auto found = std::find(m_Dependencies.begin(), m_Dependencies.end(), a_pModule);
return found != m_Dependencies.end();
}
bool Project::addSourceFile(SourceFile* a_pSourceFile)
{
PHANTOM_ASSERT(getSourceFileByPath(a_pSourceFile->getPath()) == nullptr, "source file already added");
m_SourceFiles.push_back(a_pSourceFile);
return true;
}
SourceFile* Project::addSourceFile(StringView a_RelativePath, StringView a_Code /*= ""*/)
{
if (getSourceFileByPath(a_RelativePath))
return nullptr;
Path projectFullPath(getPath());
Path sourcePath = a_RelativePath;
if (!sourcePath.isAbsolute())
sourcePath = projectFullPath.parentPath().childPath(sourcePath);
if (!sourcePath.exists())
{
std::error_code errcode;
if (!Path::CreateDirectories(sourcePath.parentPath(), errcode))
return nullptr;
std::ofstream os(sourcePath.genericString().c_str());
if (!os.is_open())
return nullptr;
os.write(a_Code.data(), a_Code.size());
}
SourceFile* pSourceFile = new_<SourceFile>(sourcePath.genericString());
if (!addSourceFile(pSourceFile))
{
delete_<SourceFile>(pSourceFile);
return nullptr;
}
return pSourceFile;
}
void Project::removeSourceFile(SourceFile* a_pSourceFile)
{
auto found = std::find(m_SourceFiles.begin(), m_SourceFiles.end(), a_pSourceFile);
PHANTOM_ASSERT(found != m_SourceFiles.end());
m_SourceFiles.erase(found);
}
bool Project::isPathExisting() const
{
Path path = getPath();
return path.exists() && path.isDirectory();
}
bool Project::hasProjectDependencyCascade(Project* a_pOther) const
{
if (hasDependency(a_pOther->getModule()))
return true;
for (Module* pDep : m_Dependencies)
{
if (Project* pDepProj = m_pSolution->getProjectFromModule(pDep))
if (pDepProj->hasProjectDependencyCascade(a_pOther))
return true;
}
return false;
}
void Project::getCompiledSources(CompiledSources& _out) const
{
for (auto source : m_SourceFiles)
{
if (auto pCS = Compiler::Get()->getCompiledSource(source))
_out.push_back(pCS);
}
}
phantom::lang::CompiledSources Project::getCompiledSources() const
{
CompiledSources sources;
getCompiledSources(sources);
return sources;
}
phantom::String Project::getPath() const
{
if (Path::IsAbsolute(m_Path))
{
return m_Path;
}
return Path(m_pSolution->getPath()).parentPath().childPath(m_Path).genericString();
}
Project::Project(Solution* a_pSolution, StringView a_Path, Module* a_pModule)
: m_pSolution(a_pSolution), m_Path(a_Path), m_pModule(a_pModule)
{
}
ProjectData Project::getData() const
{
ProjectData data;
data.options = m_Options;
for (SourceFile* pSourceFile : m_SourceFiles)
{
data.files.push_back(Path(pSourceFile->getPath()).relative(Path(getPath()).parentPath()).genericString());
}
for (Module* pModule : m_Dependencies)
{
if (Project* pProject = m_pSolution->getProjectFromModule(pModule))
{
data.dependencies.push_back(pProject->getName());
}
else
{
PHANTOM_ASSERT(pModule->getPlugin());
data.dependencies.push_back(pModule->getPlugin()->getName());
}
}
return data;
}
int Project::getDependencyLevel() const
{
int maxLevel = 0;
for (auto dep : m_Dependencies)
{
if (Project* pProject = m_pSolution->getProjectFromModule(dep))
{
int level = pProject->getDependencyLevel() + 1;
if (level > maxLevel)
maxLevel = level;
}
}
return maxLevel;
}
bool Project::setData(ProjectData _data)
{
PHANTOM_ASSERT(m_pModule);
m_Options = _data.options;
for (auto& file : _data.files)
{
Path p(Path(getPath()).parentPath().childPath(file));
if (getSourceFileByPath(p.genericString()))
{
PHANTOM_LOG(Warning, "file '%.*s' already exists in this project, skipping doublon",
PHANTOM_STRING_AS_PRINTF_ARG(p.genericString()));
continue;
}
addSourceFile(new_<SourceFile>(p.genericString()));
}
for (auto& dep : _data.dependencies)
{
if (!addDependency(dep))
return false;
}
return true;
}
void Project::removeFromDisk()
{
Path::Remove(getPath());
}
} // namespace lang
} // namespace phantom
| 28.935154 | 120 | 0.651215 | vlmillet |
277a4ebe107b13457f249f8345419ed6ebef086f | 19,986 | hpp | C++ | include/chobo/vector_view.hpp | mikke89/chobo-shl | 7f888d1c97e0a69da99ab147c7f691ca0c64038f | [
"MIT"
] | 147 | 2016-09-23T19:33:11.000Z | 2021-09-25T01:44:10.000Z | include/chobo/vector_view.hpp | mikke89/chobo-shl | 7f888d1c97e0a69da99ab147c7f691ca0c64038f | [
"MIT"
] | 14 | 2016-09-27T10:54:35.000Z | 2020-10-15T03:56:41.000Z | include/chobo/vector_view.hpp | mikke89/chobo-shl | 7f888d1c97e0a69da99ab147c7f691ca0c64038f | [
"MIT"
] | 19 | 2016-09-25T15:49:26.000Z | 2021-08-09T06:34:28.000Z | // chobo-vector-view v1.01
//
// A view of a std::vector which makes it look as a vector of another type
//
// MIT License:
// Copyright(c) 2016 Chobolabs Inc.
//
// 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.
//
//
// VERSION HISTORY
//
// 1.01 (2016-09-27) Added checks for unsupported resizes when
// sizeof(view type) is less than half of sizeof(vec type)
// 1.00 (2016-09-23) First public release
//
//
// DOCUMENTATION
//
// Simply include this file wherever you need.
// A vector view is a class which attaches to an existing std::vector
// and provides a view to its data as an alternative type, along
// with a working std::vector-like interface.
//
// THIS IS DANGEROUS, so you must know the risks ot doing so before
// using this library.
//
// The library includes two classes, for viewing const and non-const
// vectors: vector_view, and const_vector_view. To automatically generate
// the appropriate pointer, use `make_vector_view<NewType>(your_vector)`.
//
// Example:
//
// vector<vector2D> geometry;
// ... // fill geometry with data
// auto float_view = make_vector_view<float>(geometry);
// float_view[5] = 8; // equivalent to geometry[2].y = 8;
//
// auto view4d = make_vector_view<vector4D>(geometry);
//
// // add two elements to original array {1,2} and {3,4}
// view4d.push_back(make_vector4D(1, 2, 3, 4));
//
// Reference:
//
// vector_view has the most common std::vector methods and operators
// const_vector_view has the most common std::vector const methods and operators
//
// besides that both have a method vector& vec() for getting the underlying
// std::vector
//
//
// Configuration
//
// chobo::vector_view has two configurable settings:
//
// Config bounds checks:
//
// By default bounds checks are made in debug mode (via an assert) when accessing
// elements (with `at` or `[]`). Iterators are not checked (yet...)
//
// To disable them, you can define CHOBO_VECTOR_VIEW_NO_DEBUG_BOUNDS_CHECK
// before including the header.
//
// Config POD check:
//
// By default the library checks that both the source and the target type of
// the view are PODs. This is a good idea but sometimes a type is almost a POD
// (say constructors to geometry vectors) and is still fit for a view
//
// To disable the POD checks, define CHOBO_VECTOR_VIEW_NO_POD_CHECK
// before including the header.
//
// Using vector_view with non-POD types
//
// If you end up using the class with a non-pod type, you should take into
// account that when changing the size of the vector via its view ONLY the
// constructors and destructors of the source type (the one in the std::vector)
// will be called. The target type's constructors and destructors will NEVER be
// called. All assignments happen with its assignment operator (oprator=).
//
//
// TESTS
//
// The tests are included in the header file and use doctest (https://github.com/onqtam/doctest).
// To run them, define CHOBO_VECTOR_VIEW_TEST_WITH_DOCTEST before including
// the header in a file which has doctest.h already included.
//
#pragma once
#include <vector>
#if defined(CHOBO_VECTOR_VIEW_NO_DEBUG_BOUNDS_CHECK)
# define _CHOBO_VECTOR_VIEW_BOUNDS_CHECK(i)
#else
# include <cassert>
# define _CHOBO_VECTOR_VIEW_BOUNDS_CHECK(i) assert((i) < this->size())
#endif
#if defined(CHOBO_VECTOR_VIEW_NO_POD_CHECK)
#define _CHOBO_VECTOR_VIEW_POD_CHECK(T)
#else
#include <type_traits>
#define _CHOBO_VECTOR_VIEW_POD_CHECK(T) static_assert(std::is_pod<T>::value, #T " must be a pod");
#endif
namespace chobo
{
template <typename T, typename U, typename Alloc = std::allocator<T>>
class vector_view
{
_CHOBO_VECTOR_VIEW_POD_CHECK(T)
_CHOBO_VECTOR_VIEW_POD_CHECK(U)
public:
typedef std::vector<T, Alloc> vector;
typedef U value_type;
typedef T vec_value_type;
typedef Alloc allocator_type;
typedef typename vector::size_type size_type;
typedef typename vector::difference_type difference_type;
typedef U& reference;
typedef const U& const_reference;
typedef U* pointer;
typedef const U* const_pointer;
typedef pointer iterator;
typedef const_pointer const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
explicit vector_view(vector& vec)
: m_vector(vec)
{}
vector_view(const vector_view& other) = delete;
vector_view& operator=(const vector_view& other) = delete;
vector_view(vector_view&& other)
: m_vector(other.m_vector)
{} // intentionally don't inavlidate the other view
vector_view& operator=(vector_view&& other)
{
m_vector = std::move(other.m_vector);
}
vector& vec()
{
return m_vector;
}
const vector& vec() const
{
return m_vector;
}
template <typename UAlloc>
vector_view& operator=(const std::vector<U, UAlloc>& other)
{
size_type n = other.size();
resize(n);
for (size_type i = 0; i < n; ++i)
{
this->at(i) = other[i];
}
}
iterator begin() noexcept
{
return reinterpret_cast<iterator>(m_vector.data());
}
const_iterator begin() const noexcept
{
return reinterpret_cast<const_iterator>(m_vector.data());
}
const_iterator cbegin() const noexcept
{
return begin();
}
iterator end() noexcept
{
return begin() + size();
}
const_iterator end() const noexcept
{
return begin() + size();
}
const_iterator cend() const noexcept
{
return begin() + size();
}
reverse_iterator rbegin() noexcept
{
return reverse_iterator(end());
}
const_reverse_iterator rbegin() const noexcept
{
return const_reverse_iterator(end());
}
const_reverse_iterator crbegin() const noexcept
{
return const_reverse_iterator(end());
}
reverse_iterator rend() noexcept
{
return reverse_iterator(begin());
}
const_reverse_iterator rend() const noexcept
{
return const_reverse_iterator(begin());
}
const_reverse_iterator crend() const noexcept
{
return const_reverse_iterator(begin());
}
size_type size() const noexcept
{
return (m_vector.size() * sizeof(vec_value_type)) / sizeof(value_type);
}
size_type capacity() const noexcept
{
return (m_vector.capacity() * sizeof(vec_value_type)) / sizeof(value_type);
}
size_type max_size() const noexcept
{
return (m_vector.max_size() * sizeof(vec_value_type)) / sizeof(value_type);
}
void resize(size_type n)
{
size_type s = (n * sizeof(value_type) + sizeof(vec_value_type) - 1) / sizeof(vec_value_type);
m_vector.resize(s);
#if !defined CHOBO_VECTOR_VIEW_NO_RESIZE_CHECK
// Is this assert fails, here's what has happened:
// The size of the type of the view is smaller than the half of the size of the vector.
// Since the vector's number of elements must be a whole number, we cannot resize it to
// hold cerrtain numbers of the type of the view (ie not multiples of the sizeof(vec_type)/sizeof(view_type))
//
// In theory this could be supported if we add a custom size variable for the view class
// However, besides the increase in complexity, this will cause us to lose a cruicial
// feature - having changes to the vector from outside be automatically reflected on the view
// because it's only a view, and has no state of its own.
// Adding such size will be a state for this class.
// Perhaps if there is need such a feature could be implemented but in a class
// with another name, where it's clear that persisting it would be hurtful.
//
// So to avoid potential bugs this assertion, as well as the static assertions in
// push_back and pop_back have been added.
assert(size() == n && "unsupported resize");
#endif
}
void resize(size_type n, const value_type& val)
{
size_type prev_size = size();
resize(n);
for (iterator i = begin() + prev_size; i != end(); ++i)
{
*i = val;
}
}
bool empty() const noexcept
{
return m_vector.size() * sizeof(vec_value_type) < sizeof(value_type);
}
void reserve(size_type n)
{
n = (n * sizeof(value_type) + sizeof(vec_value_type) - 1) / sizeof(vec_value_type);
m_vector.reserve(n);
}
void shrink_to_fit()
{
m_vector.shrink_to_fit();
}
const_reference at(size_type i) const
{
_CHOBO_VECTOR_VIEW_BOUNDS_CHECK(i);
return *(begin() + i);
}
reference at(size_type i)
{
_CHOBO_VECTOR_VIEW_BOUNDS_CHECK(i);
return *(begin() + i);
}
const_reference operator[](size_type i) const
{
return at(i);
}
reference operator[](size_type i)
{
return at(i);
}
const_reference front() const
{
return at(0);
}
reference front()
{
return at(0);
}
const_reference back() const
{
return *(end() - 1);
}
reference back()
{
return *(end() - 1);
}
const_pointer data() const noexcept
{
return begin();
}
pointer data() noexcept
{
return begin();
}
void push_back(const value_type& val)
{
// see comment in resize for an explanation
static_assert(sizeof(value_type) > sizeof(vec_value_type) / 2,
"vector_view::push_back is not supported for value_type with size smaller than half of the viewed type");
resize(size() + 1, val);
}
void push_back(value_type&& val)
{
// see comment in resize for an explanation
static_assert(sizeof(value_type) > sizeof(vec_value_type) / 2,
"vector_view::push_back is not supported for value_type with size smaller than half of the viewed type");
resize(size() + 1);
back() = std::move(val);
}
void pop_back()
{
// see comment in resize for an explanation
static_assert(sizeof(value_type) > sizeof(vec_value_type) / 2,
"vector_view::pop_back is not supported for value_type with size smaller than half of the viewed type");
resize(size() - 1);
}
void clear() noexcept
{
m_vector.clear();
}
private:
vector& m_vector;
};
///////////////////////////////////////////////////////////////////////////////
template <typename T, typename U, typename Alloc = std::allocator<T>>
class const_vector_view
{
_CHOBO_VECTOR_VIEW_POD_CHECK(T)
_CHOBO_VECTOR_VIEW_POD_CHECK(U)
public:
typedef std::vector<T, Alloc> vector;
typedef U value_type;
typedef T vec_value_type;
typedef Alloc allocator_type;
typedef typename vector::size_type size_type;
typedef typename vector::difference_type difference_type;
typedef U& reference;
typedef const U& const_reference;
typedef U* pointer;
typedef const U* const_pointer;
typedef pointer iterator;
typedef const_pointer const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
explicit const_vector_view(const vector& vec)
: m_vector(vec)
{}
const_vector_view(const const_vector_view& other) = delete;
const_vector_view& operator=(const const_vector_view& other) = delete;
const_vector_view(const_vector_view&& other)
: m_vector(other.m_vector)
{} // intentionally don't inavlidate the other view
const_vector_view& operator=(const_vector_view&& other) = delete;
const vector& vec() const
{
return m_vector;
}
const_iterator begin() const noexcept
{
return reinterpret_cast<const_iterator>(m_vector.data());
}
const_iterator cbegin() const noexcept
{
return begin();
}
const_iterator end() const noexcept
{
return begin() + size();
}
const_iterator cend() const noexcept
{
return begin() + size();
}
const_reverse_iterator rbegin() const noexcept
{
return const_reverse_iterator(end());
}
const_reverse_iterator crbegin() const noexcept
{
return const_reverse_iterator(end());
}
const_reverse_iterator rend() const noexcept
{
return const_reverse_iterator(begin());
}
const_reverse_iterator crend() const noexcept
{
return const_reverse_iterator(begin());
}
size_type size() const noexcept
{
return (m_vector.size() * sizeof(vec_value_type)) / sizeof(value_type);
}
size_type capacity() const noexcept
{
return (m_vector.capacity() * sizeof(vec_value_type)) / sizeof(value_type);
}
size_type max_size() const noexcept
{
return (m_vector.max_size() * sizeof(vec_value_type)) / sizeof(value_type);
}
bool empty() const noexcept
{
return m_vector.size() * sizeof(vec_value_type) < sizeof(value_type);
}
const_reference at(size_type i) const
{
_CHOBO_VECTOR_VIEW_BOUNDS_CHECK(i);
return *(begin() + i);
}
const_reference operator[](size_type i) const
{
return at(i);
}
const_reference front() const
{
return at(0);
}
const_reference back() const
{
return *(end() - 1);
}
const_pointer data() const noexcept
{
return begin();
}
private:
const vector& m_vector;
};
///////////////////////////////////////////////////////////////////////////////
template <typename U, typename T, typename Alloc>
vector_view<T, U, Alloc> make_vector_view(std::vector<T, Alloc>& vec)
{
return vector_view<T, U, Alloc>(vec);
}
template <typename U, typename T, typename Alloc>
const_vector_view<T, U, Alloc> make_vector_view(const std::vector<T, Alloc>& vec)
{
return const_vector_view<T, U, Alloc>(vec);
}
}
#if defined(CHOBO_VECTOR_VIEW_TEST_WITH_DOCTEST)
namespace chobo_vector_view_test
{
struct vector3D
{
int x, y, z;
};
struct vector4D
{
int x, y, z, w;
};
struct chobo_vector3D
{
int a, b, c;
};
}
TEST_CASE("[vector_view] test")
{
using namespace chobo;
using namespace chobo_vector_view_test;
std::vector<int> vec;
auto v3dview = make_vector_view<vector3D>(vec);
CHECK(v3dview.empty());
CHECK(v3dview.size() == 0);
vec.push_back(5);
CHECK(v3dview.empty());
CHECK(v3dview.size() == 0);
vec.push_back(10);
CHECK(v3dview.empty());
CHECK(v3dview.size() == 0);
vec.push_back(15);
CHECK(!v3dview.empty());
CHECK(v3dview.size() == 1);
CHECK(v3dview.front().x == 5);
CHECK(v3dview.front().y == 10);
CHECK(v3dview.front().z == 15);
CHECK(v3dview.back().x == 5);
CHECK(v3dview.back().y == 10);
CHECK(v3dview.back().z == 15);
v3dview.resize(2);
CHECK(vec.size() == 6);
v3dview[1].x = 2;
v3dview.at(1).y = 4;
(v3dview.begin() + 1)->z = 6;
CHECK(vec[3] == 2);
CHECK(vec[4] == 4);
CHECK(vec[5] == 6);
CHECK((v3dview.rend() - 2)->z == 6);
vector3D foo = { 1,3,5 };
v3dview.resize(4, foo);
CHECK(vec.size() == 12);
CHECK(vec.back() == 5);
CHECK(vec[6] == 1);
CHECK(v3dview.rbegin()->y == 3);
v3dview.resize(3);
CHECK(vec.size() == 9);
CHECK(v3dview.crbegin()->z == 5);
v3dview.push_back(foo);
CHECK(vec.size() == 12);
CHECK(vec[9] == 1);
CHECK(vec[10] == 3);
CHECK(vec[11] == 5);
v3dview.pop_back();
CHECK(vec.size() == 9);
v3dview.clear();
CHECK(vec.empty());
vec.resize(5);
CHECK(v3dview.size() == 1);
v3dview.resize(2);
CHECK(vec.size() == 6);
void* data = vec.data();
CHECK(v3dview.data() == data);
// same
std::vector<chobo_vector3D> vec3d;
auto v3dview_chobo = make_vector_view<vector3D>(vec3d);
vec3d.resize(5);
CHECK(v3dview_chobo.size() == 5);
vec3d[2].a = 7;
vec3d[2].b = 8;
vec3d[2].c = 9;
CHECK(v3dview_chobo[2].x == 7);
CHECK(v3dview_chobo.at(2).y == 8);
CHECK((v3dview_chobo.begin() + 2)->z == 9);
// unequal
std::vector<vector4D> vec4d;
auto v3dview4d = make_vector_view<vector3D>(vec4d);
vec4d.resize(1);
CHECK(v3dview4d.size() == 1);
v3dview4d.resize(2);
CHECK(v3dview4d.size() == 2);
CHECK(vec4d.size() == 2);
// smaller
auto iview = make_vector_view<int>(vec4d);
CHECK(iview.size() == 8);
iview.resize(12);
CHECK(vec4d.size() == 3);
}
TEST_CASE("[const_vector_view] test")
{
using namespace chobo;
using namespace chobo_vector_view_test;
std::vector<int> vvec;
const auto& vec = vvec;
auto v3dview = make_vector_view<vector3D>(vec);
CHECK(v3dview.empty());
CHECK(v3dview.size() == 0);
vvec.push_back(5);
CHECK(v3dview.empty());
CHECK(v3dview.size() == 0);
vvec.push_back(10);
CHECK(v3dview.empty());
CHECK(v3dview.size() == 0);
vvec.push_back(15);
CHECK(!v3dview.empty());
CHECK(v3dview.size() == 1);
CHECK(v3dview.front().x == 5);
CHECK(v3dview.front().y == 10);
CHECK(v3dview.front().z == 15);
CHECK(v3dview.back().x == 5);
CHECK(v3dview.back().y == 10);
CHECK(v3dview.back().z == 15);
vvec.resize(6);
CHECK(v3dview.size() == 2);
vvec[3] = 2;
vvec[4] = 4;
vvec[5] = 6;
CHECK(v3dview[1].x == 2);
CHECK(v3dview.at(1).y == 4);
CHECK((v3dview.begin() + 1)->z == 6);
CHECK((v3dview.rend() - 2)->z == 6);
vvec.resize(12);
CHECK(v3dview.size() == 4);
vvec[10] = 3;
CHECK(v3dview.rbegin()->y == 3);
vvec.resize(9);
CHECK(v3dview.size() == 3);
vvec.clear();
CHECK(v3dview.empty());
vvec.resize(5);
CHECK(v3dview.size() == 1);
const void* data = vec.data();
CHECK(v3dview.data() == data);
// same
std::vector<chobo_vector3D> vvec3d;
const auto& vec3d = vvec3d;
auto v3dview_chobo = make_vector_view<vector3D>(vec3d);
vvec3d.resize(5);
CHECK(v3dview_chobo.size() == 5);
vvec3d[2].a = 7;
vvec3d[2].b = 8;
vvec3d[2].c = 9;
CHECK(v3dview_chobo[2].x == 7);
CHECK(v3dview_chobo.at(2).y == 8);
CHECK((v3dview_chobo.begin() + 2)->z == 9);
// unequal
std::vector<vector4D> vvec4d;
const auto& vec4d = vvec4d;
auto v3dview4d = make_vector_view<vector3D>(vec4d);
vvec4d.resize(1);
CHECK(v3dview4d.size() == 1);
vvec4d.resize(2);
CHECK(v3dview4d.size() == 2);
vvec4d.resize(3);
CHECK(v3dview4d.size() == 4);
// smaller
auto iview = make_vector_view<int>(vec4d);
CHECK(iview.size() == 12);
}
#endif | 26.262812 | 117 | 0.631992 | mikke89 |
277c302017dae8c7514180218fc0b1412a451c54 | 3,057 | cpp | C++ | array_inversion/main.cpp | 8alery/algorithms | 67cf12724f61cdae7eff1788062c1b7c26f98ca4 | [
"Apache-2.0"
] | null | null | null | array_inversion/main.cpp | 8alery/algorithms | 67cf12724f61cdae7eff1788062c1b7c26f98ca4 | [
"Apache-2.0"
] | null | null | null | array_inversion/main.cpp | 8alery/algorithms | 67cf12724f61cdae7eff1788062c1b7c26f98ca4 | [
"Apache-2.0"
] | null | null | null | #include <iostream>
#include <vector>
#include <random>
#include <algorithm>
#include <queue>
#include <limits>
void printVector(std::vector<int> array){
for (auto v:array){
std::cout << v << " ";
}
std::cout << std::endl;
}
int next_power_of_two(int v){
v--;
v |= v >> 1;
v |= v >> 2;
v |= v >> 4;
v |= v >> 8;
v |= v >> 16;
return v++;
}
long merge_sort_iterative(std::vector<int> array){
long inversions = 0;
int sizeModified = next_power_of_two(array.size());
std::queue<std::vector<int>> queue;
for (auto value:array){
queue.push(std::vector<int>{ value });
}
for (int i = array.size(); i <= sizeModified; i++){
queue.push(std::vector<int>{ std::numeric_limits<int>::max() });
}
while (queue.size() > 1){
auto first = queue.front();
queue.pop();
auto second = queue.front();
queue.pop();
std::cout << "first: ";
printVector(first);
std::cout << "second: ";
printVector(second);
int i = 0, j = 0, totalSize = first.size() + second.size();
std::vector<int> sorted;
int current;
long currentInversions = 0;
while (i < first.size() && j < second.size()){
if (first[i] <= second[j]){
current = first[i++];
} else {
current = second[j++];
currentInversions += (first.size() - i);
}
sorted.push_back(current);
}
while (i < first.size()) {
sorted.push_back(first[i++]);
}
while (j < second.size()) {
sorted.push_back(second[j++]);
}
queue.push(sorted);
std::cout << "inversions: " << currentInversions << std::endl;
std::cout << "sorted: ";
printVector(sorted);
inversions += currentInversions;
}
std::cout << "inversions: " << inversions << std::endl;
std::cout << "sorted: ";
printVector(queue.front());
return inversions;
}
int main() {
// std::vector<int> array = {7, 6, 5, 4, 3, 2, 1 };
// int n = array.size();
int n;
std::cin >> n;
std::vector<int> array;
for (int i = 0; i < n; i++){
int element = 0; //dis(gen);
std::cin >> element;
array.push_back(element);
}
long inversionsCount = merge_sort_iterative(array);
std::cout << inversionsCount << std::endl;
return 0;
// int n = 100000;
// std::vector<int> array;
// std::random_device rd; //Will be used to obtain a seed for the random number engine
// std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
// std::uniform_int_distribution<> dis(1, 1000000000);
// for (int i = 0; i < n; i++){
// int element = dis(gen);
// array.push_back(element);
// }
// long inversionsCount = merge_sort_iterative(array);
// std::cout << inversionsCount << std::endl;
// return 0;
} | 26.815789 | 94 | 0.514884 | 8alery |
277d97de0c9342aa004f99d363161c6cd19d89b8 | 54 | cpp | C++ | App/FIFOServer/ClientB.cpp | Lw-Cui/Compression-server | 3501d746f14145d3764700d40d3672a0da0b2eae | [
"MIT"
] | 3 | 2016-12-10T16:06:20.000Z | 2017-06-25T12:47:06.000Z | App/FIFOServer/ClientB.cpp | Lw-Cui/Compression-server | 3501d746f14145d3764700d40d3672a0da0b2eae | [
"MIT"
] | 2 | 2017-05-15T15:22:36.000Z | 2017-05-20T15:01:25.000Z | App/FIFOServer/ClientB.cpp | Lw-Cui/Tiny-server | 3501d746f14145d3764700d40d3672a0da0b2eae | [
"MIT"
] | null | null | null |
#define CLIENT "ClientB"
#include "ClientBody.cpp"
| 9 | 25 | 0.722222 | Lw-Cui |
277ec282bacc3d331bb049b9c28b4d96dc43d669 | 4,003 | cpp | C++ | src/Samples/Synthetic_TwoView/main.cpp | eivan/one-ac-pose | 79451626238f47130578c18b65e37cabd7332de1 | [
"MIT"
] | 4 | 2020-07-31T19:12:44.000Z | 2022-02-22T14:34:48.000Z | src/Samples/Synthetic_TwoView/main.cpp | eivan/OneAC | 79451626238f47130578c18b65e37cabd7332de1 | [
"MIT"
] | null | null | null | src/Samples/Synthetic_TwoView/main.cpp | eivan/OneAC | 79451626238f47130578c18b65e37cabd7332de1 | [
"MIT"
] | null | null | null | #include <iostream>
#include <time.h>
#include <common/numeric.hpp>
#include <common/camera_radial.hpp>
#include <common/local_affine_frame.hpp>
#include <common/pose_estimation.hpp>
using namespace OneACPose;
void compute_synthetic_LAF(
const Mat34& P, const common::CameraPtr& cam,
const Vec3& X, const Mat32& dX_dx,
common::Feature_LAF_D& laf);
int main()
{
srand(time(0));
// ==========================================================================
// initialize two poses
// ==========================================================================
const Vec3 target{ Vec3::Random() };
const double distance_from_target = 5;
// init pose 0
const Vec3 C0{ Vec3::Random().normalized() * distance_from_target };
const Mat3 R0{ common::LookAt(target - C0) };
const Mat34 P0{ (Mat34() << R0, -R0 * C0).finished() };
// init pose 1
const Vec3 C1{ Vec3::Random().normalized() * distance_from_target };
const Mat3 R1{ common::LookAt(target - C1) };
const Mat34 P1{ (Mat34() << R1, -R1 * C1).finished() };
// ==========================================================================
// initialize two cameras
// ==========================================================================
common::CameraPtr cam0 = std::make_shared<common::Camera_Radial>();
cam0->set_params({ 1000.0, 1000.0, 500.0, 500.0, 0.0, 0.0, 0.0 });
common::CameraPtr cam1 = std::make_shared<common::Camera_Radial>();
cam1->set_params({ 1000.0, 1000.0, 500.0, 500.0, 0.0, 0.0, 0.0 });
// ==========================================================================
// initialize 3D structure
// ==========================================================================
// surface point
const Vec3 X{ Vec3::Random() };
// surface normal at X
const Vec3 N{ Vec3::Random().normalized() };
// local frame of surface around X (perpendicular to N)
const Mat32 dX_dx{ common::nullspace(N) };
// ==========================================================================
// compute synthetic LAFs with depths, by projecting X and dX_dx onto the image plane
// ==========================================================================
common::Feature_LAF_D laf0;
compute_synthetic_LAF(P0, cam0, X, dX_dx, laf0);
common::Feature_LAF_D laf1;
compute_synthetic_LAF(P1, cam1, X, dX_dx, laf1);
// ==========================================================================
// perform estimation
// ==========================================================================
double scale;
Mat3 R;
Vec3 t;
estimatePose_1ACD(
cam0, cam1, // calibrated cameras
laf0, // LAF 0: 2d location, 2D shape, depth and depth derivatives
laf1, // LAF 1, 2d location, 2D shape, depth and depth derivatives
scale, R, t);
// ==========================================================================
// measure errors wrt ground truth
// ==========================================================================
std::cout << "R_gt:\t" << (R1 * R0.transpose()) << std::endl;
std::cout << "R_est:\t" << R << std::endl;
std::cout << "t_est:\t" << (t).transpose() << std::endl;
std::cout << "t_gt:\t" << (R1 * (C0 - C1)).transpose() << std::endl;
std::cout << "scale:\t" << scale << std::endl;
}
void compute_synthetic_LAF(
const Mat34& P, const common::CameraPtr& cam,
const Vec3& X, const Mat32& dX_dx,
common::Feature_LAF_D& laf)
{
const Vec3 Y = P * X.homogeneous();
const Mat32 dY_dx = P.topLeftCorner<3, 3>() * dX_dx;
Mat23 dx_dY;
//std::tie(laf.x.noalias(), dx_dY.noalias()) = cam->p_gradient(Y); // g++8 error, msvc works
std::tie(laf.x, dx_dY) = cam->p_gradient(Y);
// affine shape around x, aka dx0_dx
laf.M.noalias() = dx_dY * dY_dx;
RowVec3 dlambda_dY;
//std::tie(laf.lambda, dlambda_dY.noalias()) = cam->depth_gradient(Y); // g++8 error, msvc works
std::tie(laf.lambda, dlambda_dY) = cam->depth_gradient(Y);
// aka dlambda_dx
laf.dlambda_dx.noalias() = dlambda_dY * dY_dx;
} | 36.390909 | 98 | 0.501624 | eivan |
95970213c76d95fd6fc8c0f6d18e242c1c502780 | 4,419 | cpp | C++ | code/clustered_setup/fgm-master/LSGMcode-master/algorithms/graphm-0.52/algorithm_umeyama.cpp | mk2510/jointGraphMatchingAndClustering | 52f579a07d106cb241d21dbc29a2ec9e9c77b254 | [
"Unlicense"
] | 10 | 2015-08-27T14:10:38.000Z | 2021-02-08T21:38:55.000Z | code/clustered_setup/fgm-master/LSGMcode-master/algorithms/graphm-0.52/algorithm_umeyama.cpp | mk2510/jointGraphMatchingAndClustering | 52f579a07d106cb241d21dbc29a2ec9e9c77b254 | [
"Unlicense"
] | 2 | 2015-02-20T01:53:58.000Z | 2016-08-24T11:14:00.000Z | code/clustered_setup/fgm-master/LSGMcode-master/algorithms/graphm-0.52/algorithm_umeyama.cpp | mk2510/jointGraphMatchingAndClustering | 52f579a07d106cb241d21dbc29a2ec9e9c77b254 | [
"Unlicense"
] | 7 | 2016-08-23T11:44:05.000Z | 2021-08-06T01:41:25.000Z | /***************************************************************************
* Copyright (C) 2008 by Mikhail Zaslavskiy *
* [email protected] *
* *
* 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., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "algorithm_umeyama.h"
match_result algorithm_umeyama::match(graph& g, graph& h,gsl_matrix* gm_P_i,gsl_matrix* gm_ldh,double dalpha_ldh)
{
if (bverbose)
*gout<<"Umeyama algorithm"<<std::endl;
bool bblast_match_end=(get_param_i("blast_match_proj")==1);
//some duplicate variables
gsl_matrix* gm_Ag_d=g.get_descmatrix(cdesc_matrix);
gsl_matrix* gm_Ah_d=h.get_descmatrix(cdesc_matrix);
if (pdebug.ivalue) gsl_matrix_printout(gm_Ag_d,"Ag",pdebug.strvalue);
if (pdebug.ivalue) gsl_matrix_printout(gm_Ah_d,"Ah",pdebug.strvalue);
//memory allocation
gsl_eigen_symmv_workspace * gesw= gsl_eigen_symmv_alloc (N);
gsl_vector* eval_g=gsl_vector_alloc(N);
gsl_vector* eval_h=gsl_vector_alloc(N);
gsl_matrix* evec_g=gsl_matrix_alloc(N,N);
gsl_matrix* evec_h=gsl_matrix_alloc(N,N);
if (bverbose) *gout<<"Memory allocation finished"<<std::endl;
//eigenvalues and eigenvectors for both matrices
gsl_eigen_symmv (gm_Ag_d, eval_g,evec_g,gesw);
if (bverbose) *gout<<"Ag eigen vectors"<<std::endl;
gsl_eigen_symmv (gm_Ah_d, eval_h,evec_h,gesw);
gsl_matrix_free(gm_Ag_d);
gsl_matrix_free(gm_Ah_d);
if (bverbose) *gout<<"Ah eigen vectors"<<std::endl;
gsl_eigen_symmv_sort (eval_g, evec_g, GSL_EIGEN_SORT_VAL_DESC);
gsl_eigen_symmv_sort (eval_h, evec_h, GSL_EIGEN_SORT_VAL_DESC);
if (pdebug.ivalue){ gsl_matrix_printout(eval_g,"eval_g",pdebug.strvalue);
gsl_matrix_printout(eval_h,"eval_h",pdebug.strvalue);
gsl_matrix_printout(evec_g,"evec_g",pdebug.strvalue);
gsl_matrix_printout(evec_h,"evec_h",pdebug.strvalue);};
gsl_matrix_abs(evec_g);
gsl_matrix_abs(evec_h);
if (pdebug.ivalue) gsl_matrix_printout(evec_g,"abs(evec_g)",pdebug.strvalue);
if (pdebug.ivalue) gsl_matrix_printout(evec_h,"abs(evec_h)",pdebug.strvalue);
//loss matrix construction
gsl_matrix* C=gsl_matrix_alloc(N,N);
if (bverbose) *gout<<"Loss function matrix allocation"<<std::endl;
gsl_blas_dgemm(CblasNoTrans,CblasTrans,1,evec_g,evec_h,0,C);
if (pdebug.ivalue) gsl_matrix_printout(C,"C=abs(evec_g)*abs(evec_h')",pdebug.strvalue);
//label cost matrix
update_C_hungarian(C,-1);
//scaling for hungarian
double dscale_factor =gsl_matrix_max_abs(C);
dscale_factor=(dscale_factor>EPSILON)?dscale_factor:EPSILON;
dscale_factor=10000/dscale_factor;
gsl_matrix_scale(C,-dscale_factor);
gsl_matrix_transpose(C);
if (pdebug.ivalue) gsl_matrix_printout(C,"scale(C)",pdebug.strvalue);
gsl_matrix* gm_P=gsl_matrix_alloc(N,N);
gsl_matrix_hungarian(C,gm_P,NULL,NULL,false,(bblast_match_end?gm_ldh:NULL),false);
if (pdebug.ivalue) gsl_matrix_printout(gm_P,"gm_P",pdebug.strvalue);
if (bverbose) *gout<<"Hungarian solved"<<std::endl;
match_result mres;
mres.gm_P=gm_P;
//initial score
mres.vd_trace.push_back(graph_dist(g,h,cscore_matrix));
//final score
mres.vd_trace.push_back(graph_dist(g,h,gm_P,cscore_matrix));
//other output parameters
mres.dres=mres.vd_trace.at(1);
mres.inum_iteration=2;
//transpose matrix save
mres.gm_P=gm_P;
mres.gm_P_exact=NULL;
return mres;
}
| 47.010638 | 113 | 0.661914 | mk2510 |
9598d34a7577c3b1097b2cdac4e5058f7affa603 | 683 | cpp | C++ | drivers/port_io/port_io.cpp | Tomer2003/ro-os | 843b0258e8d14de7cc24f9ae9bfa19fe02ccd00d | [
"MIT"
] | null | null | null | drivers/port_io/port_io.cpp | Tomer2003/ro-os | 843b0258e8d14de7cc24f9ae9bfa19fe02ccd00d | [
"MIT"
] | null | null | null | drivers/port_io/port_io.cpp | Tomer2003/ro-os | 843b0258e8d14de7cc24f9ae9bfa19fe02ccd00d | [
"MIT"
] | null | null | null | #include "port_io.hpp"
void portWriteByte(unsigned short portAddress, unsigned char data)
{
__asm__ __volatile__("out %%al, %%dx" :: "a"(data), "d"(portAddress));
}
unsigned char portReadByte(unsigned short portAddress)
{
unsigned char result;
__asm__ __volatile__("in %%dx, %%al" : "=a"(result) : "d"(portAddress));
return result;
}
void portWriteWord(unsigned short portAddress, unsigned short data)
{
__asm__ __volatile__("out %%ax, %%dx" :: "a"(data), "d"(portAddress));
}
unsigned short portReadWord(unsigned short portAddress)
{
unsigned short result;
__asm__ __volatile__("in %%dx, %%ax" : "=a"(result) : "d"(portAddress));
return result;
} | 27.32 | 76 | 0.679356 | Tomer2003 |
95a2502d0f83bdf392fc3037a78b0db10a6d1f06 | 15,415 | cpp | C++ | src/apps/mplayerc/EditListEditor.cpp | chinajeffery/MPC-BE--1.2.3 | 2229fde5535f565ba4a496a7f73267bd2c1ad338 | [
"MIT"
] | null | null | null | src/apps/mplayerc/EditListEditor.cpp | chinajeffery/MPC-BE--1.2.3 | 2229fde5535f565ba4a496a7f73267bd2c1ad338 | [
"MIT"
] | 1 | 2019-11-14T04:18:32.000Z | 2019-11-14T04:18:32.000Z | src/apps/mplayerc/EditListEditor.cpp | chinajeffery/MPC-BE--1.2.3 | 2229fde5535f565ba4a496a7f73267bd2c1ad338 | [
"MIT"
] | null | null | null | /*
* $Id: EditListEditor.cpp 2326 2013-03-21 12:41:26Z aleksoid $
*
* (C) 2006-2013 see Authors.txt
*
* This file is part of MPC-BE.
*
* MPC-BE 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.
*
* MPC-BE 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 "stdafx.h"
#include "EditListEditor.h"
CClip::CClip()
{
m_rtIn = INVALID_TIME;
m_rtOut = INVALID_TIME;
}
void CClip::SetIn(LPCTSTR strVal)
{
m_rtIn = StringToReftime (strVal);
}
void CClip::SetOut(LPCTSTR strVal)
{
m_rtOut = StringToReftime (strVal);
}
void CClip::SetIn (REFERENCE_TIME rtVal)
{
m_rtIn = rtVal;
if (m_rtIn > m_rtOut) {
m_rtOut = INVALID_TIME;
}
};
void CClip::SetOut (REFERENCE_TIME rtVal)
{
m_rtOut = rtVal;
if (m_rtIn > m_rtOut) {
m_rtIn = INVALID_TIME;
}
};
CString CClip::GetIn()
{
if (m_rtIn == INVALID_TIME) {
return _T("");
} else {
return ReftimeToString(m_rtIn);
}
}
CString CClip::GetOut()
{
if (m_rtOut == INVALID_TIME) {
return _T("");
} else {
return ReftimeToString(m_rtOut);
}
}
IMPLEMENT_DYNAMIC(CEditListEditor, CPlayerBar)
CEditListEditor::CEditListEditor(void)
{
m_CurPos = NULL;
m_bDragging = FALSE;
m_nDragIndex = -1;
m_nDropIndex = -1;
m_bFileOpen = false;
}
CEditListEditor::~CEditListEditor(void)
{
SaveEditListToFile();
}
BEGIN_MESSAGE_MAP(CEditListEditor, CPlayerBar)
ON_WM_SIZE()
ON_NOTIFY(LVN_ITEMCHANGED, IDC_EDITLIST, OnLvnItemchanged)
ON_NOTIFY(LVN_KEYDOWN, IDC_EDITLIST, OnLvnKeyDown)
ON_WM_DRAWITEM()
ON_NOTIFY(LVN_BEGINDRAG, IDC_EDITLIST, OnBeginDrag)
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONUP()
ON_WM_TIMER()
ON_NOTIFY(LVN_BEGINLABELEDIT, IDC_EDITLIST, OnBeginlabeleditList)
ON_NOTIFY(LVN_DOLABELEDIT, IDC_EDITLIST, OnDolabeleditList)
ON_NOTIFY(LVN_ENDLABELEDIT, IDC_EDITLIST, OnEndlabeleditList)
END_MESSAGE_MAP()
BOOL CEditListEditor::Create(CWnd* pParentWnd, UINT defDockBarID)
{
if (!__super::Create(ResStr(IDS_EDIT_LIST_EDITOR), pParentWnd, ID_VIEW_EDITLISTEDITOR, defDockBarID, _T("Edit List Editor"))) {
return FALSE;
}
m_stUsers.Create (_T("User :"), WS_VISIBLE|WS_CHILD, CRect (5,5,100,21), this, 0);
m_cbUsers.Create (WS_CHILD|WS_VISIBLE|CBS_DROPDOWNLIST, CRect (90,0, 260, 21), this, 0);
FillCombo(_T("Users.txt"), m_cbUsers, false);
m_stHotFolders.Create (_T("Hot folder :"), WS_VISIBLE|WS_CHILD, CRect (5,35,100,51), this, 0);
m_cbHotFolders.Create (WS_CHILD|WS_VISIBLE|CBS_DROPDOWNLIST, CRect (90,30, 260, 21), this, 0);
FillCombo(_T("HotFolders.txt"), m_cbHotFolders, true);
m_list.CreateEx(
WS_EX_DLGMODALFRAME|WS_EX_CLIENTEDGE,
WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_TABSTOP
|LVS_OWNERDRAWFIXED
|LVS_REPORT|LVS_SINGLESEL|LVS_AUTOARRANGE|LVS_NOSORTHEADER,
CRect(0,0,100,100), this, IDC_EDITLIST);
m_list.SetExtendedStyle(m_list.GetExtendedStyle()|LVS_EX_FULLROWSELECT|LVS_EX_DOUBLEBUFFER);
m_list.InsertColumn(COL_IN, _T("Nb."), LVCFMT_LEFT, 35);
m_list.InsertColumn(COL_IN, _T("In"), LVCFMT_LEFT, 100);
m_list.InsertColumn(COL_OUT, _T("Out"), LVCFMT_LEFT, 100);
m_list.InsertColumn(COL_NAME, _T("Name"), LVCFMT_LEFT, 150);
m_fakeImageList.Create(1, 16, ILC_COLOR4, 10, 10);
m_list.SetImageList(&m_fakeImageList, LVSIL_SMALL);
return TRUE;
}
void CEditListEditor::OnSize(UINT nType, int cx, int cy)
{
CSizingControlBarG::OnSize(nType, cx, cy);
ResizeListColumn();
}
void CEditListEditor::ResizeListColumn()
{
if (::IsWindow(m_list.m_hWnd)) {
CRect r;
GetClientRect(r);
r.DeflateRect(2, 2);
r.top += 60;
m_list.SetRedraw(FALSE);
m_list.MoveWindow(r);
m_list.GetClientRect(r);
m_list.SetRedraw(TRUE);
}
}
void CEditListEditor::SaveEditListToFile()
{
if ((m_bFileOpen || m_EditList.GetCount() >0) && !m_strFileName.IsEmpty()) {
CStdioFile EditListFile;
if (EditListFile.Open (m_strFileName, CFile::modeCreate|CFile::modeWrite)) {
CString strLine;
int nIndex;
CString strUser;
CString strHotFolders;
nIndex = m_cbUsers.GetCurSel();
if (nIndex >= 0) {
m_cbUsers.GetLBText(nIndex, strUser);
}
nIndex = m_cbHotFolders.GetCurSel();
if (nIndex >= 0) {
m_cbHotFolders.GetLBText(nIndex, strHotFolders);
}
POSITION pos = m_EditList.GetHeadPosition();
for (int i = 0; pos; i++, m_EditList.GetNext(pos)) {
CClip& CurClip = m_EditList.GetAt(pos);
if (CurClip.HaveIn() && CurClip.HaveOut()) {
strLine.Format(_T("%s\t%s\t%s\t%s\t%s\n"), CurClip.GetIn(), CurClip.GetOut(), CurClip.GetName(), strUser, strHotFolders);
EditListFile.WriteString (strLine);
}
}
EditListFile.Close();
}
}
}
void CEditListEditor::CloseFile()
{
SaveEditListToFile();
m_EditList.RemoveAll();
m_list.DeleteAllItems();
m_CurPos = NULL;
m_strFileName = "";
m_bFileOpen = false;
m_cbHotFolders.SetCurSel(0);
}
void CEditListEditor::OpenFile(LPCTSTR lpFileName)
{
CString strLine;
CStdioFile EditListFile;
CString strUser;
CString strHotFolders;
CloseFile();
m_strFileName.Format(_T("%s.edl"), lpFileName);
if (EditListFile.Open (m_strFileName, CFile::modeRead)) {
m_bFileOpen = true;
while (EditListFile.ReadString(strLine)) {
//int nPos = 0;
CString strIn; // = strLine.Tokenize(_T(" \t"), nPos);
CString strOut; // = strLine.Tokenize(_T(" \t"), nPos);
CString strName; // = strLine.Tokenize(_T(" \t"), nPos);
AfxExtractSubString (strIn, strLine, 0, _T('\t'));
AfxExtractSubString (strOut, strLine, 1, _T('\t'));
AfxExtractSubString (strName, strLine, 2, _T('\t'));
if (strUser.IsEmpty()) {
AfxExtractSubString (strUser, strLine, 3, _T('\t'));
SelectCombo(strUser, m_cbUsers);
}
if (strHotFolders.IsEmpty()) {
AfxExtractSubString (strHotFolders, strLine, 4, _T('\t'));
SelectCombo(strHotFolders, m_cbHotFolders);
}
if (!strIn.IsEmpty() && !strOut.IsEmpty()) {
CClip NewClip;
NewClip.SetIn (strIn);
NewClip.SetOut (strOut);
NewClip.SetName(strName);
InsertClip (NULL, NewClip);
}
}
EditListFile.Close();
} else {
m_bFileOpen = false;
}
if (m_NameList.GetCount() == 0) {
CStdioFile NameFile;
CString str;
if (NameFile.Open (_T("EditListNames.txt"), CFile::modeRead)) {
while (NameFile.ReadString(str)) {
m_NameList.Add(str);
}
NameFile.Close();
}
}
}
void CEditListEditor::SetIn (REFERENCE_TIME rtIn)
{
if (m_CurPos != NULL) {
CClip& CurClip = m_EditList.GetAt (m_CurPos);
CurClip.SetIn (rtIn);
m_list.Invalidate();
}
}
void CEditListEditor::SetOut(REFERENCE_TIME rtOut)
{
if (m_CurPos != NULL) {
CClip& CurClip = m_EditList.GetAt (m_CurPos);
CurClip.SetOut (rtOut);
m_list.Invalidate();
}
}
void CEditListEditor::NewClip(REFERENCE_TIME rtVal)
{
CClip NewClip;
if (m_CurPos != NULL) {
CClip& CurClip = m_EditList.GetAt (m_CurPos);
if (CurClip.HaveIn()) {
if (!CurClip.HaveOut()) {
CurClip.SetOut (rtVal);
}
}
}
m_CurPos = InsertClip (m_CurPos, NewClip);
m_list.Invalidate();
}
void CEditListEditor::Save()
{
SaveEditListToFile();
}
int CEditListEditor::FindIndex(POSITION pos)
{
int iItem = 0;
POSITION CurPos = m_EditList.GetHeadPosition();
while (CurPos && CurPos != pos) {
m_EditList.GetNext (CurPos);
iItem++;
}
return iItem;
}
POSITION CEditListEditor::InsertClip(POSITION pos, CClip& NewClip)
{
LVITEM lv;
POSITION NewClipPos;
if (pos == NULL) {
NewClipPos = m_EditList.AddTail (NewClip);
} else {
NewClipPos = m_EditList.InsertAfter (pos, NewClip);
}
lv.mask = LVIF_STATE | LVIF_TEXT;
lv.iItem = FindIndex (pos);
lv.iSubItem = 0;
lv.pszText = _T("");
lv.state = m_list.GetItemCount()==0 ? LVIS_SELECTED : 0;
m_list.InsertItem(&lv);
return NewClipPos;
}
void CEditListEditor::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
if (nIDCtl != IDC_EDITLIST) {
return;
}
int nItem = lpDrawItemStruct->itemID;
CRect rcItem = lpDrawItemStruct->rcItem;
POSITION pos = m_EditList.FindIndex(nItem);
if (pos != NULL) {
bool fSelected = (pos == m_CurPos);
UNREFERENCED_PARAMETER(fSelected);
CClip& CurClip = m_EditList.GetAt(pos);
CString strTemp;
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
if (!!m_list.GetItemState(nItem, LVIS_SELECTED)) {
FillRect(pDC->m_hDC, rcItem, CBrush(0xf1dacc));
FrameRect(pDC->m_hDC, rcItem, CBrush(0xc56a31));
} else {
FillRect(pDC->m_hDC, rcItem, CBrush(GetSysColor(COLOR_WINDOW)));
}
COLORREF textcolor = RGB(0,0,0);
if (!CurClip.HaveIn() || !CurClip.HaveOut()) {
textcolor = RGB(255,0,0);
}
for (int i=0; i<COL_MAX; i++) {
m_list.GetSubItemRect(nItem, i, LVIR_LABEL, rcItem);
pDC->SetTextColor(textcolor);
switch (i) {
case COL_INDEX :
strTemp.Format (_T("%d"), nItem+1);
pDC->DrawText (strTemp, rcItem, DT_CENTER | DT_VCENTER);
break;
case COL_IN :
pDC->DrawText (CurClip.GetIn(), rcItem, DT_CENTER | DT_VCENTER);
break;
case COL_OUT :
pDC->DrawText (CurClip.GetOut(), rcItem, DT_CENTER | DT_VCENTER);
break;
case COL_NAME :
pDC->DrawText (CurClip.GetName(), rcItem, DT_LEFT | DT_VCENTER);
break;
}
}
}
}
void CEditListEditor::OnLvnItemchanged(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
if (pNMLV->iItem >= 0) {
m_CurPos = m_EditList.FindIndex (pNMLV->iItem);
}
}
void CEditListEditor::OnLvnKeyDown(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMLVKEYDOWN pLVKeyDown = reinterpret_cast<LPNMLVKEYDOWN>(pNMHDR);
*pResult = FALSE;
if (pLVKeyDown->wVKey == VK_DELETE) {
POSITION pos = m_list.GetFirstSelectedItemPosition();
POSITION ClipPos;
int nItem = -1;
while (pos) {
nItem = m_list.GetNextSelectedItem(pos);
ClipPos = m_EditList.FindIndex (nItem);
if (ClipPos) {
m_EditList.RemoveAt (ClipPos);
}
m_list.DeleteItem (nItem);
}
if (nItem != -1) {
m_list.SetItemState (min (nItem, m_list.GetItemCount()-1), LVIS_SELECTED, LVIS_SELECTED);
}
m_list.Invalidate();
}
}
void CEditListEditor::OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult)
{
ModifyStyle(WS_EX_ACCEPTFILES, 0);
m_nDragIndex = ((LPNMLISTVIEW)pNMHDR)->iItem;
CPoint p(0, 0);
m_pDragImage = m_list.CreateDragImageEx(&p);
CPoint p2 = ((LPNMLISTVIEW)pNMHDR)->ptAction;
m_pDragImage->BeginDrag(0, p2 - p);
m_pDragImage->DragEnter(GetDesktopWindow(), ((LPNMLISTVIEW)pNMHDR)->ptAction);
m_bDragging = TRUE;
m_nDropIndex = -1;
SetCapture();
}
void CEditListEditor::OnMouseMove(UINT nFlags, CPoint point)
{
if (m_bDragging) {
m_ptDropPoint = point;
ClientToScreen(&m_ptDropPoint);
m_pDragImage->DragMove(m_ptDropPoint);
m_pDragImage->DragShowNolock(FALSE);
WindowFromPoint(m_ptDropPoint)->ScreenToClient(&m_ptDropPoint);
m_pDragImage->DragShowNolock(TRUE);
{
int iOverItem = m_list.HitTest(m_ptDropPoint);
int iTopItem = m_list.GetTopIndex();
int iBottomItem = m_list.GetBottomIndex();
if (iOverItem == iTopItem && iTopItem != 0) { // top of list
SetTimer(1, 100, NULL);
} else {
KillTimer(1);
}
if (iOverItem >= iBottomItem && iBottomItem != (m_list.GetItemCount() - 1)) { // bottom of list
SetTimer(2, 100, NULL);
} else {
KillTimer(2);
}
}
}
__super::OnMouseMove(nFlags, point);
}
void CEditListEditor::OnTimer(UINT_PTR nIDEvent)
{
int iTopItem = m_list.GetTopIndex();
int iBottomItem = iTopItem + m_list.GetCountPerPage() - 1;
if (m_bDragging) {
m_pDragImage->DragShowNolock(FALSE);
if (nIDEvent == 1) {
m_list.EnsureVisible(iTopItem - 1, false);
m_list.UpdateWindow();
if (m_list.GetTopIndex() == 0) {
KillTimer(1);
}
} else if (nIDEvent == 2) {
m_list.EnsureVisible(iBottomItem + 1, false);
m_list.UpdateWindow();
if (m_list.GetBottomIndex() == (m_list.GetItemCount() - 1)) {
KillTimer(2);
}
}
m_pDragImage->DragShowNolock(TRUE);
}
__super::OnTimer(nIDEvent);
}
void CEditListEditor::OnLButtonUp(UINT nFlags, CPoint point)
{
if (m_bDragging) {
::ReleaseCapture();
m_bDragging = FALSE;
m_pDragImage->DragLeave(GetDesktopWindow());
m_pDragImage->EndDrag();
delete m_pDragImage;
m_pDragImage = NULL;
KillTimer(1);
KillTimer(2);
CPoint pt(point);
ClientToScreen(&pt);
if (WindowFromPoint(pt) == &m_list) {
DropItemOnList();
}
}
ModifyStyle(0, WS_EX_ACCEPTFILES);
__super::OnLButtonUp(nFlags, point);
}
void CEditListEditor::DropItemOnList()
{
m_ptDropPoint.y -= 10;
m_nDropIndex = m_list.HitTest(CPoint(10, m_ptDropPoint.y));
POSITION DragPos = m_EditList.FindIndex (m_nDragIndex);
POSITION DropPos = m_EditList.FindIndex (m_nDropIndex);
if ((DragPos!=NULL) && (DropPos!=NULL)) {
CClip& DragClip = m_EditList.GetAt(DragPos);
m_EditList.InsertAfter (DropPos, DragClip);
m_EditList.RemoveAt (DragPos);
m_list.Invalidate();
}
}
void CEditListEditor::OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
LV_ITEM* pItem = &pDispInfo->item;
*pResult = FALSE;
if (pItem->iItem < 0) {
return;
}
if (pItem->iSubItem == COL_NAME) {
*pResult = TRUE;
}
}
void CEditListEditor::OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
LV_ITEM* pItem = &pDispInfo->item;
*pResult = FALSE;
if (pItem->iItem < 0) {
return;
}
if (m_CurPos != NULL && pItem->iSubItem == COL_NAME) {
CClip& CurClip = m_EditList.GetAt (m_CurPos);
int nSel = FindNameIndex (CurClip.GetName());
CAtlList<CString> sl;
for (int i=0; i<m_NameList.GetCount(); i++) {
sl.AddTail(m_NameList.GetAt(i));
}
m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel, true);
*pResult = TRUE;
}
}
void CEditListEditor::OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
LV_ITEM* pItem = &pDispInfo->item;
*pResult = FALSE;
if (!m_list.m_fInPlaceDirty) {
return;
}
if (pItem->iItem < 0) {
return;
}
CString& CurName = m_NameList.GetAt(pItem->lParam);
if (m_CurPos != NULL && pItem->iSubItem == COL_NAME) {
CClip& CurClip = m_EditList.GetAt (m_CurPos);
CurClip.SetName(CurName);
*pResult = TRUE;
}
}
int CEditListEditor::FindNameIndex(LPCTSTR strName)
{
int nResult = -1;
for (int i = 0; i<m_NameList.GetCount(); i++) {
CString& CurName = m_NameList.GetAt(i);
if (CurName == strName) {
nResult = i;
break;
}
}
return nResult;
}
void CEditListEditor::FillCombo(LPCTSTR strFileName, CComboBox& Combo, bool bAllowNull)
{
CStdioFile NameFile;
CString str;
if (NameFile.Open (strFileName, CFile::modeRead)) {
if (bAllowNull) {
Combo.AddString(_T(""));
}
while (NameFile.ReadString(str)) {
Combo.AddString(str);
}
NameFile.Close();
}
}
void CEditListEditor::SelectCombo(LPCTSTR strValue, CComboBox& Combo)
{
for (int i=0; i<Combo.GetCount(); i++) {
CString strTemp;
Combo.GetLBText(i, strTemp);
if (strTemp == strValue) {
Combo.SetCurSel(i);
break;
}
}
}
| 22.50365 | 128 | 0.69108 | chinajeffery |
95ac5b8bf81d55048ebc62024c8209171266b8cd | 7,064 | cpp | C++ | Nacro/SDK/FN_QuestUpdatesLog_functions.cpp | Milxnor/Nacro | eebabf662bbce6d5af41820ea0342d3567a0aecc | [
"BSD-2-Clause"
] | 11 | 2021-08-08T23:25:10.000Z | 2022-02-19T23:07:22.000Z | Nacro/SDK/FN_QuestUpdatesLog_functions.cpp | Milxnor/Nacro | eebabf662bbce6d5af41820ea0342d3567a0aecc | [
"BSD-2-Clause"
] | 1 | 2022-01-01T22:51:59.000Z | 2022-01-08T16:14:15.000Z | Nacro/SDK/FN_QuestUpdatesLog_functions.cpp | Milxnor/Nacro | eebabf662bbce6d5af41820ea0342d3567a0aecc | [
"BSD-2-Clause"
] | 8 | 2021-08-09T13:51:54.000Z | 2022-01-26T20:33:37.000Z | // Fortnite (1.8) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "../SDK.hpp"
namespace SDK
{
//---------------------------------------------------------------------------
//Functions
//---------------------------------------------------------------------------
// Function QuestUpdatesLog.QuestUpdatesLog_C.CanDisplayAnotherObjective
// (Public, HasOutParms, BlueprintCallable, BlueprintEvent, BlueprintPure)
// Parameters:
// bool Result (Parm, OutParm, ZeroConstructor, IsPlainOldData)
void UQuestUpdatesLog_C::CanDisplayAnotherObjective(bool* Result)
{
static auto fn = UObject::FindObject<UFunction>("Function QuestUpdatesLog.QuestUpdatesLog_C.CanDisplayAnotherObjective");
UQuestUpdatesLog_C_CanDisplayAnotherObjective_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
if (Result != nullptr)
*Result = params.Result;
}
// Function QuestUpdatesLog.QuestUpdatesLog_C.GetTotalDisplayedObjectives
// (Public, HasOutParms, BlueprintCallable, BlueprintEvent, BlueprintPure)
// Parameters:
// int NumObjectives (Parm, OutParm, ZeroConstructor, IsPlainOldData)
void UQuestUpdatesLog_C::GetTotalDisplayedObjectives(int* NumObjectives)
{
static auto fn = UObject::FindObject<UFunction>("Function QuestUpdatesLog.QuestUpdatesLog_C.GetTotalDisplayedObjectives");
UQuestUpdatesLog_C_GetTotalDisplayedObjectives_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
if (NumObjectives != nullptr)
*NumObjectives = params.NumObjectives;
}
// Function QuestUpdatesLog.QuestUpdatesLog_C.CreateAnnouncementUpdate
// (Public, HasDefaults, BlueprintCallable, BlueprintEvent)
// Parameters:
// struct FDynamicQuestUpdateInfo UpdateInfo (Parm)
void UQuestUpdatesLog_C::CreateAnnouncementUpdate(const struct FDynamicQuestUpdateInfo& UpdateInfo)
{
static auto fn = UObject::FindObject<UFunction>("Function QuestUpdatesLog.QuestUpdatesLog_C.CreateAnnouncementUpdate");
UQuestUpdatesLog_C_CreateAnnouncementUpdate_Params params;
params.UpdateInfo = UpdateInfo;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function QuestUpdatesLog.QuestUpdatesLog_C.HandleQuestUpdateWidgetFinished
// (Public, HasDefaults, BlueprintCallable, BlueprintEvent)
// Parameters:
// class UQuestUpdateEntry_C* UpdateWidget (Parm, ZeroConstructor, IsPlainOldData)
void UQuestUpdatesLog_C::HandleQuestUpdateWidgetFinished(class UQuestUpdateEntry_C* UpdateWidget)
{
static auto fn = UObject::FindObject<UFunction>("Function QuestUpdatesLog.QuestUpdatesLog_C.HandleQuestUpdateWidgetFinished");
UQuestUpdatesLog_C_HandleQuestUpdateWidgetFinished_Params params;
params.UpdateWidget = UpdateWidget;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function QuestUpdatesLog.QuestUpdatesLog_C.GetAvailableQuestUpdateWidget
// (Public, HasOutParms, BlueprintCallable, BlueprintEvent)
// Parameters:
// struct FDynamicQuestUpdateInfo UpdateInfo (Parm)
// class UQuestUpdateEntry_C* AvailableWIdget (Parm, OutParm, ZeroConstructor, IsPlainOldData)
void UQuestUpdatesLog_C::GetAvailableQuestUpdateWidget(const struct FDynamicQuestUpdateInfo& UpdateInfo, class UQuestUpdateEntry_C** AvailableWIdget)
{
static auto fn = UObject::FindObject<UFunction>("Function QuestUpdatesLog.QuestUpdatesLog_C.GetAvailableQuestUpdateWidget");
UQuestUpdatesLog_C_GetAvailableQuestUpdateWidget_Params params;
params.UpdateInfo = UpdateInfo;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
if (AvailableWIdget != nullptr)
*AvailableWIdget = params.AvailableWIdget;
}
// Function QuestUpdatesLog.QuestUpdatesLog_C.TryDisplayDynamicQuestStatusUpdate
// (Public, HasDefaults, BlueprintCallable, BlueprintEvent)
void UQuestUpdatesLog_C::TryDisplayDynamicQuestStatusUpdate()
{
static auto fn = UObject::FindObject<UFunction>("Function QuestUpdatesLog.QuestUpdatesLog_C.TryDisplayDynamicQuestStatusUpdate");
UQuestUpdatesLog_C_TryDisplayDynamicQuestStatusUpdate_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function QuestUpdatesLog.QuestUpdatesLog_C.CreateQuestUpdateWIdgets
// (Public, BlueprintCallable, BlueprintEvent)
void UQuestUpdatesLog_C::CreateQuestUpdateWIdgets()
{
static auto fn = UObject::FindObject<UFunction>("Function QuestUpdatesLog.QuestUpdatesLog_C.CreateQuestUpdateWIdgets");
UQuestUpdatesLog_C_CreateQuestUpdateWIdgets_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function QuestUpdatesLog.QuestUpdatesLog_C.HandleDisplayDynamicQuestUpdate
// (Public, HasDefaults, BlueprintCallable, BlueprintEvent)
// Parameters:
// class UFortQuestObjectiveInfo* QuestObjective (Parm, ZeroConstructor, IsPlainOldData)
// bool bDisplayStatusUpdate (Parm, ZeroConstructor, IsPlainOldData)
// bool bDisplayAnnouncementUpdate (Parm, ZeroConstructor, IsPlainOldData)
void UQuestUpdatesLog_C::HandleDisplayDynamicQuestUpdate(class UFortQuestObjectiveInfo* QuestObjective, bool bDisplayStatusUpdate, bool bDisplayAnnouncementUpdate)
{
static auto fn = UObject::FindObject<UFunction>("Function QuestUpdatesLog.QuestUpdatesLog_C.HandleDisplayDynamicQuestUpdate");
UQuestUpdatesLog_C_HandleDisplayDynamicQuestUpdate_Params params;
params.QuestObjective = QuestObjective;
params.bDisplayStatusUpdate = bDisplayStatusUpdate;
params.bDisplayAnnouncementUpdate = bDisplayAnnouncementUpdate;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function QuestUpdatesLog.QuestUpdatesLog_C.Construct
// (BlueprintCosmetic, Event, Public, BlueprintEvent)
void UQuestUpdatesLog_C::Construct()
{
static auto fn = UObject::FindObject<UFunction>("Function QuestUpdatesLog.QuestUpdatesLog_C.Construct");
UQuestUpdatesLog_C_Construct_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function QuestUpdatesLog.QuestUpdatesLog_C.ExecuteUbergraph_QuestUpdatesLog
// ()
// Parameters:
// int EntryPoint (Parm, ZeroConstructor, IsPlainOldData)
void UQuestUpdatesLog_C::ExecuteUbergraph_QuestUpdatesLog(int EntryPoint)
{
static auto fn = UObject::FindObject<UFunction>("Function QuestUpdatesLog.QuestUpdatesLog_C.ExecuteUbergraph_QuestUpdatesLog");
UQuestUpdatesLog_C_ExecuteUbergraph_QuestUpdatesLog_Params params;
params.EntryPoint = EntryPoint;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| 31.67713 | 163 | 0.76359 | Milxnor |
95afc1b5eb96e3c20a7a848421c691ce9c46a11a | 12,766 | cpp | C++ | EXAMPLES/Controls/SingleInst/singleinstance.cpp | earthsiege2/borland-cpp-ide | 09bcecc811841444338e81b9c9930c0e686f9530 | [
"Unlicense",
"FSFAP",
"Apache-1.1"
] | 1 | 2022-01-13T01:03:55.000Z | 2022-01-13T01:03:55.000Z | EXAMPLES/Controls/SingleInst/singleinstance.cpp | earthsiege2/borland-cpp-ide | 09bcecc811841444338e81b9c9930c0e686f9530 | [
"Unlicense",
"FSFAP",
"Apache-1.1"
] | null | null | null | EXAMPLES/Controls/SingleInst/singleinstance.cpp | earthsiege2/borland-cpp-ide | 09bcecc811841444338e81b9c9930c0e686f9530 | [
"Unlicense",
"FSFAP",
"Apache-1.1"
] | null | null | null | //---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#define NDEBUG
#include <cassert>
#include "SingleInstance.h"
#pragma package(smart_init)
//---------------------------------------------------------------------------
// ValidCtrCheck is used to assure that the components created do not have
// any pure virtual functions.
//
static inline void ValidCtrCheck(TSingleAppInstance *)
{
new TSingleAppInstance(NULL);
}
//---------------------------------------------------------------------------
// We introduce a global boolean to serve as
// a marker. If a component is "activated"
// to serve as a single instance guarantee,
// we flag this here.
// This provides a mechanism that prevents
// more than a single component from getting
// active at any time.
// This is extremely important in those cases
// where the user might accidentally instatiate
// a second copy of the component in *the same*
// process.
// Alert: as with all global variables this
// is NOT thread-safe.
bool SingleAppInstanceComponentActive = false;
//---------------------------------------------------------------------------
void __fastcall TSingleAppInstance::AssertValidMarkerText(const String& Value)
{
int Len;
// Note the Windows API documentation:
// "The name can contain any character except the backslash character (\)"
Len = Value.Length();
for (int i = 1; i <= Len; ++i)
{
if (Value[i] == '\\')
{
throw Exception("A marker may not contain the '\\' character");
}
}
}
bool __fastcall TSingleAppInstance::IsValidMarkerText(const String& Value)
{
int Len;
bool IsValid;
// Note the Windows API documentation:
// "The name can contain any character except the backslash character (\)"
IsValid = true;
Len = Value.Length();
for (int i = 1; i <= Len; ++i)
{
if (Value[i] == '\\')
{
IsValid = false;
break;
}
}
return IsValid;
}
String __fastcall TSingleAppInstance::TranslateSlashes(const String& Value)
{
// Since slashes are not allowed in certain
// strings (see above), provide an internal
// mapping that replaces these slashes with
// something else.
const char ReplacementCharacter = '_';
int Len;
String Result;
Result = Value;
Len = Result.Length();
for (int i = 1; i <= Len; ++i)
{
if (Result[i] == '\\')
{
Result[i] = ReplacementCharacter;
}
}
return Result;
}
//---------------------------------------------------------------------------
// We are storing some data in the marking
// memory-mapped file. The following struct
// makes the data structure reasonably opaque.
struct MappedData
{
HANDLE FirstInstanceHandle;
};
typedef MappedData* PMappedData;
//---------------------------------------------------------------------------
__fastcall TSingleAppInstance::TSingleAppInstance(TComponent* Owner)
: TComponent(Owner)
{
InitializeCriticalSection(&FWndProcCriticalSection);
FHiddenWindow = AllocateHWnd(LocalWinProc);
FPassCommandLine = true;
// If we are loaded as part of a stream,
// set Enabled = true - the default streaming
// value specified in the property declaration.
//
// If this is not the case, it is very likely
// that the user manually instantiates the
// component. Start disabled then and allow
// (rather: force) the user to assign events
// and only then enable the component.
FEnabled = true;
FEnabled = (Owner != NULL) &&
Owner->ComponentState.Contains(csLoading);
}
__fastcall TSingleAppInstance::~TSingleAppInstance(void)
{
ReleaseInternalMapFile();
DeleteCriticalSection(&FWndProcCriticalSection);
DeallocateHWnd(FHiddenWindow);
FHiddenWindow = INVALID_HANDLE_VALUE;
delete[] FPassedCommandLine;
FPassedCommandLine = NULL;
}
void __fastcall TSingleAppInstance::DoOnSecondInstance(bool& DoTerminate)
{
if (FOnSecondInstance != NULL)
FOnSecondInstance(this, DoTerminate);
}
void __fastcall TSingleAppInstance::Loaded(void)
{
inherited::Loaded();
if (!ComponentState.Contains(csDesigning))
{
if (SingleAppInstanceComponentActive)
{
// In case an instance is already active,
// we simply unconditionally set FEnabled
// to false.
if (FEnabled)
FEnabled = false;
}
else
{
PerformSingletonCode();
}
}
}
void __fastcall TSingleAppInstance::LocalWinProc(Messages::TMessage &Message)
{
if (Message.Msg != WM_COPYDATA)
{
Message.Result = DefWindowProc(FHiddenWindow, Message.Msg, Message.WParam, Message.LParam);
}
else
{
DWORD CountData;
PCOPYDATASTRUCT PassedCopyDataStruct;
// We need to be left alone for a moment,
// so lock everyone out of this code sequence.
//
// Design issue:
//
// This piece of code will BLOCK the SENDING
// application until we have made our call
// to ReplyMessage below.
// This means that if multiple "single-instance"
// processes are launched roughly at the same
// time ALL these processes will block at the
// same time.
// The provided critical section should guarantee,
// though, that we have a nice, serialized access.
// (no mutex, since we stay inside the same process)
EnterCriticalSection(&FWndProcCriticalSection);
try
{
if (FPassedCommandLine != NULL)
{
delete[] FPassedCommandLine;
FPassedCommandLine = NULL;
}
assert(Message.LParam != NULL);
PassedCopyDataStruct = reinterpret_cast<COPYDATASTRUCT*>(Message.LParam);
// We copy the passed command-line to a local
// buffer in order to be able to return to the
// calling application as soon as possible,
// without it waiting for us to process the data.
CountData = PassedCopyDataStruct->cbData;
if (CountData > 0)
{
FPassedCommandLine = new char[CountData];
if (PassedCopyDataStruct->lpData != NULL)
memmove(FPassedCommandLine, PassedCopyDataStruct->lpData, CountData);
}
FPassedData = PassedCopyDataStruct->dwData;
// Fine, so we have the data let the other process
// off the SendMessage "hook" (metaphorically speaking).
Win32Check( ReplyMessage(true) );
DoReceiveCommandLine(FPassedCommandLine);
}
__finally
{
LeaveCriticalSection(&FWndProcCriticalSection);
}
}
}
void __fastcall TSingleAppInstance::DoReceiveCommandLine(const char * const CommandLine)
{
if (FOnReceiveCommandLine != NULL)
{
FOnReceiveCommandLine(this, FPassedCommandLine);
}
}
// Return true if the memory mapped file was successfully created;
// false if this was not done.
bool __fastcall TSingleAppInstance::CreateInternalMapFile(void)
{
LPVOID MapView;
bool CreateResult;
DWORD LastErrorCode;
CreateResult = false;
assert(FMappingObject == NULL);
FMappingObject = CreateFileMapping( reinterpret_cast<HANDLE>(0xFFFFFFFF), NULL,
PAGE_READWRITE | SEC_COMMIT,
0, sizeof(MappedData),
FMarker.c_str() );
if (FMappingObject == NULL)
RaiseLastWin32Error();
LastErrorCode = GetLastError();
if (LastErrorCode == ERROR_ALREADY_EXISTS)
{
// Whoops. Somebody already has created this memory mapped file.
// Do nothing; CreateResult has the right value
// already and will signal that the memory mapped file
// (and thus the marker) already existed.
// TODO: Is this the right thing to do? Return with false? Or throw an exception?
}
else
{
MapView = MapViewOfFile(FMappingObject, FILE_MAP_ALL_ACCESS, 0, 0, 0);
if (MapView == NULL)
RaiseLastWin32Error();
try
{
assert(FHiddenWindow != INVALID_HANDLE_VALUE);
static_cast<PMappedData>(MapView)->FirstInstanceHandle = FHiddenWindow;
}
__finally
{
Win32Check( UnmapViewOfFile(MapView) );
}
CreateResult = true;
}
return CreateResult;
}
void __fastcall TSingleAppInstance::ReleaseInternalMapFile(void)
{
if (FMappingObject != NULL)
{
Win32Check( CloseHandle(FMappingObject) );
FMappingObject = NULL;
}
}
void __fastcall TSingleAppInstance::PerformSingletonCode(void)
{
if (FEnabled)
{
// It is pretty pointless to have an empty marker.
// Use a default marker (i.e. the name of the executable)
// if we are in dire need of one.
if (FMarker.Length() == 0)
{
// Note that we have to translate backslashes ('\')
// into something else (here: underscores ('_'))
// as the Windows API does not allow names for
// memory mapped files that contain backslashes.
// And we use the creating process's name
// as the "default" marker which definitely does
// contain backslashes.
SetMarker(TranslateSlashes(ParamStr(0)));
}
if (CreateInternalMapFile())
{
SingleAppInstanceComponentActive = true;
}
else
{
// The memory mapped file already existed.
TakeSecondInstanceAction();
}
}
else
{
ReleaseInternalMapFile();
}
}
void __fastcall TSingleAppInstance::PassThisInstanceCommandLine(void)
{
HANDLE FileMapping;
LPVOID MapView;
HANDLE FirstInstance;
// Before sending over the command line, we need to
// retrieve the handle from the present memory-mapped
// file.
FileMapping = OpenFileMapping(FILE_MAP_READ, false, FMarker.c_str());
if (FileMapping == NULL)
RaiseLastWin32Error();
try
{
MapView = MapViewOfFile(FileMapping, FILE_MAP_READ, 0, 0, 0);
if (MapView == NULL)
RaiseLastWin32Error();
try
{
FirstInstance = static_cast<PMappedData>(MapView)->FirstInstanceHandle;
}
__finally
{
Win32Check( UnmapViewOfFile(MapView) );
}
}
__finally
{
Win32Check( CloseHandle(FileMapping) );
}
// Now we pass on our command-line. Note that we must
// use SendMessage in combination with WM_COPYDATA; only
// then does the Win32 kernel marshal the data across
// process boundaries.
COPYDATASTRUCT CopyData = { 0, strlen(CmdLine) + sizeof(char), CmdLine };
// We don't bother about a return value...
SendMessage( FirstInstance, WM_COPYDATA,
reinterpret_cast<WPARAM>(FHiddenWindow),
reinterpret_cast<LPARAM>(&CopyData));
}
void __fastcall TSingleAppInstance::TakeSecondInstanceAction(void)
{
bool TerminateApplication;
// Send command line to other application if this is desired.
if (FPassCommandLine)
PassThisInstanceCommandLine();
// Fire the event for this application, "notifying"
// it that there is something else.
// By default, terminate the application.
TerminateApplication = true;
if (FOnSecondInstance != NULL)
{
FOnSecondInstance(this, TerminateApplication);
}
if (TerminateApplication)
Application->Terminate();
}
void __fastcall TSingleAppInstance::SetEnabled(const bool Value)
{
if (Value != FEnabled)
{
// Is there an attempt to enable a second
// instance of the component at runtime?
// We cannot allow this to pass through,
// as there can be only one entry point
// for command line parameter messages.
if (SingleAppInstanceComponentActive &&
Value /* == true */ &&
!ComponentState.Contains(csDesigning))
{
// TODO: Possibly throw an exception here?
/*
AnsiString ExceptionMessage;
ExceptionMessage.sprintf( "Only one instance of %s may be active at a time",
AnsiString(this->ClassName()).c_str() );
throw Exception(ExceptionMessage);
*/
return;
}
FEnabled = Value;
// We only react to changes in the Enabled
// state if
// a) this happens at runtime (!csDesigning)
// b) the component data is not streaming
// [because for *streaming*, we use the Loaded
// method which is a tad bit better.]
if (!ComponentState.Contains(csDesigning) &&
!ComponentState.Contains(csReading))
{
PerformSingletonCode();
}
}
}
void __fastcall TSingleAppInstance::SetMarker(const String Value)
{
if (Value != FMarker)
{
AssertValidMarkerText(Value);
FMarker = Value;
}
}
| 26.819328 | 96 | 0.624315 | earthsiege2 |
95aff5bb20c5b67c58315b74f1a3c25b255d2b2f | 996 | hpp | C++ | library/ATF/_attack_selfdestruction_result_zoclInfo.hpp | lemkova/Yorozuya | f445d800078d9aba5de28f122cedfa03f26a38e4 | [
"MIT"
] | 29 | 2017-07-01T23:08:31.000Z | 2022-02-19T10:22:45.000Z | library/ATF/_attack_selfdestruction_result_zoclInfo.hpp | kotopes/Yorozuya | 605c97d3a627a8f6545cc09f2a1b0a8afdedd33a | [
"MIT"
] | 90 | 2017-10-18T21:24:51.000Z | 2019-06-06T02:30:33.000Z | library/ATF/_attack_selfdestruction_result_zoclInfo.hpp | kotopes/Yorozuya | 605c97d3a627a8f6545cc09f2a1b0a8afdedd33a | [
"MIT"
] | 44 | 2017-12-19T08:02:59.000Z | 2022-02-24T23:15:01.000Z | // This file auto generated by plugin for ida pro. Generated code only for x64. Please, dont change manually
#pragma once
#include <common/common.h>
#include <_attack_selfdestruction_result_zocl.hpp>
START_ATF_NAMESPACE
namespace Info
{
using _attack_selfdestruction_result_zoclctor__attack_selfdestruction_result_zocl2_ptr = void (WINAPIV*)(struct _attack_selfdestruction_result_zocl*);
using _attack_selfdestruction_result_zoclctor__attack_selfdestruction_result_zocl2_clbk = void (WINAPIV*)(struct _attack_selfdestruction_result_zocl*, _attack_selfdestruction_result_zoclctor__attack_selfdestruction_result_zocl2_ptr);
using _attack_selfdestruction_result_zoclsize4_ptr = int (WINAPIV*)(struct _attack_selfdestruction_result_zocl*);
using _attack_selfdestruction_result_zoclsize4_clbk = int (WINAPIV*)(struct _attack_selfdestruction_result_zocl*, _attack_selfdestruction_result_zoclsize4_ptr);
}; // end namespace Info
END_ATF_NAMESPACE
| 55.333333 | 241 | 0.828313 | lemkova |
95b10c3e682f252f91eb832efa205268280b326f | 3,264 | cpp | C++ | NativePlugin/CaptainAsteroid/src/physics/Game.cpp | axoloto/CaptainAsteroid | fcdcb6bc6987ecf53226daa7027116e40d74401a | [
"Apache-2.0"
] | null | null | null | NativePlugin/CaptainAsteroid/src/physics/Game.cpp | axoloto/CaptainAsteroid | fcdcb6bc6987ecf53226daa7027116e40d74401a | [
"Apache-2.0"
] | null | null | null | NativePlugin/CaptainAsteroid/src/physics/Game.cpp | axoloto/CaptainAsteroid | fcdcb6bc6987ecf53226daa7027116e40d74401a | [
"Apache-2.0"
] | null | null | null | #include "Game.hpp"
#include "Logging.hpp"
#include "systems/ControlByPlayer.hpp"
#include "systems/Move.hpp"
#include "systems/Collide.hpp"
#include "systems/FireLaser.hpp"
#include "systems/ReduceLifeTime.hpp"
#include "systems/SplitAsteroid.hpp"
#include "systems/RemoveDead.hpp"
#include "components/Motion.hpp"
#include "components/Position.hpp"
#include "components/PlayerControl.hpp"
#include "components/Laser.hpp"
#include "events/PlayGame.hpp"
namespace CaptainAsteroidCPP
{
Game::Game() : m_eventManager(),
m_entityManager(m_eventManager),
m_systemManager(m_entityManager, m_eventManager),
m_gameManager(m_entityManager, m_eventManager),
m_spaceShip(m_entityManager),
m_asteroidField(m_entityManager, m_eventManager),
m_laserShots(m_entityManager)
{
Utils::InitializeLogger();
LOG_INFO("Game Created");
}
void Game::init(Def::InitParams initParams)
{
m_gameManager.init();
m_spaceShip.init();
m_asteroidField.init(initParams);
createSystems(initParams.boundaryDomainV, initParams.boundaryDomainH);
m_eventManager.emit<Ev::PlayGame>();
LOG_INFO("Game Initialized");
}
void Game::createSystems(float boundaryV, float boundaryH)
{
m_systemManager.add<Sys::ControlByPlayer>();
m_systemManager.add<Sys::Move>(boundaryV, boundaryH);
m_systemManager.add<Sys::Collide>();
m_systemManager.add<Sys::FireLaser>(m_laserShots);
m_systemManager.add<Sys::ReduceLifeTime>();
m_systemManager.add<Sys::SplitAsteroid>(m_asteroidField);
m_systemManager.add<Sys::RemoveDead>(m_asteroidField, m_laserShots);
m_systemManager.configure();
LOG_INFO("DOD Systems Initialized");
}
void Game::update(Def::KeyState keyState, float deltaTime)
{
m_eventManager.emit<Ev::PlayerInput>(keyState);
if (m_gameManager.isGameRunning())
{
m_systemManager.update<Sys::ControlByPlayer>(deltaTime);
m_systemManager.update<Sys::Move>(deltaTime);
m_systemManager.update<Sys::Collide>(deltaTime);
m_systemManager.update<Sys::FireLaser>(deltaTime);
m_systemManager.update<Sys::ReduceLifeTime>(deltaTime);
m_systemManager.update<Sys::SplitAsteroid>(deltaTime);
m_systemManager.update<Sys::RemoveDead>(deltaTime);
}
}
void Game::getSpaceShipCoords(float &x, float &y, float &angle) const
{
const std::array<float, 3> coordsAndRot = m_spaceShip.getPosAndDir();
x = coordsAndRot[0];
y = coordsAndRot[1];
angle = coordsAndRot[2];
}
void Game::fillPosEntityList(float *posEntities, int size, int *nbEntities, Def::EntityType entityType) const
{
if (entityType & Def::EntityType::Asteroid_XXL
|| entityType & Def::EntityType::Asteroid_M
|| entityType & Def::EntityType::Asteroid_S)
{
m_asteroidField.fillPosEntityList(posEntities, size, nbEntities, entityType);
}
else if (entityType & Def::EntityType::LaserShot)
{
m_laserShots.fillPosEntityList(posEntities, size, nbEntities, entityType);
}
}
Def::GameState Game::currentGameState() const
{
return m_gameManager.gameState();
}
std::int32_t Game::currentScore() const
{
return m_gameManager.score();
}
std::int32_t Game::currentNbAsteroids() const
{
return m_asteroidField.totalNbAsteroids();
}
}// namespace CaptainAsteroidCPP
| 27.897436 | 109 | 0.739583 | axoloto |
95b24eb6996724fd198d8985c5323221ad48343b | 1,240 | cpp | C++ | dep/include/yse/synth/synthManager.cpp | ChrSacher/MyEngine | 8fe71fd9e84b9536148e0d4ebb4e53751ab49ce8 | [
"Apache-2.0"
] | 2 | 2015-10-27T21:36:59.000Z | 2017-03-17T21:52:19.000Z | dep/include/yse/synth/synthManager.cpp | ChrSacher/MyEngine | 8fe71fd9e84b9536148e0d4ebb4e53751ab49ce8 | [
"Apache-2.0"
] | null | null | null | dep/include/yse/synth/synthManager.cpp | ChrSacher/MyEngine | 8fe71fd9e84b9536148e0d4ebb4e53751ab49ce8 | [
"Apache-2.0"
] | null | null | null | /*
==============================================================================
synthManager.cpp
Created: 6 Jul 2014 10:01:40pm
Author: yvan
==============================================================================
*/
#include "synthManager.h"
#include "../internalHeaders.h"
YSE::SYNTH::managerObject & YSE::SYNTH::Manager() {
static managerObject m;
return m;
}
YSE::SYNTH::implementationObject * YSE::SYNTH::managerObject::addImplementation(YSE::SYNTH::interfaceObject * head) {
implementations.emplace_front(head);
return &implementations.front();
}
void YSE::SYNTH::managerObject::update() {
bool remove = false;
for (auto i = implementations.begin(); i != implementations.end(); ++i) {
if (!(*i).sync()) {
remove = true;
}
}
// I assume that removing a synth happens not very often. So it's
// faster to do a second run if this is the case, instead of updating
// 2 iterators all the time
if (remove) {
auto previous = implementations.before_begin();
for (auto i = implementations.begin(); i != implementations.end(); ++i) {
if (!(*i).hasInterface()) {
implementations.erase_after(previous);
return;
}
previous++;
}
}
} | 27.555556 | 117 | 0.560484 | ChrSacher |
95b3726da577384740325b9d5cb46370d37a5f58 | 789 | cpp | C++ | Applications/cli/commands/less.cpp | mschwartz/amos | 345a4f8f52b9805722c10ac4cedb24b480fe2dc7 | [
"MIT"
] | 4 | 2020-08-18T00:11:09.000Z | 2021-04-05T11:16:32.000Z | Applications/cli/commands/less.cpp | mschwartz/amos | 345a4f8f52b9805722c10ac4cedb24b480fe2dc7 | [
"MIT"
] | 1 | 2020-08-15T20:39:13.000Z | 2020-08-15T20:39:13.000Z | Applications/cli/commands/less.cpp | mschwartz/amos | 345a4f8f52b9805722c10ac4cedb24b480fe2dc7 | [
"MIT"
] | null | null | null | #include "commands.hpp"
TInt64 CliTask::command_less(TInt ac, char **av) {
if (ac != 2) {
return Error("%s requires 1 argument", av[0]);
}
FileDescriptor *fd;
fd = OpenFile(av[1]);
if (!fd) {
return Error("Could not open %s", av[1]);
}
else {
char buf[512];
TInt count = 0;
for (;;) {
TUint64 actual = ReadFile(fd, buf, 512);
if (actual == 0) {
break;
}
// TODO: count lines, use mWindow console height (rows)
for (TUint64 x = 0; x < actual; x++) {
if (buf[x] == '\n') {
mWindow->Write(buf[x]);
count++;
if (count >= mWindow->Rows()) {
count = 0;
}
}
else {
mWindow->Write(buf[x]);
}
}
}
CloseFile(fd);
}
return 0;
}
| 20.230769 | 61 | 0.47275 | mschwartz |
95c156ec977b003837947dd71df125dc1385831e | 2,106 | cpp | C++ | cci/graph.cpp | vino-ebe/int-pgms | 124e63d46092bd974d44afe67bd17727892afefa | [
"BSD-2-Clause"
] | null | null | null | cci/graph.cpp | vino-ebe/int-pgms | 124e63d46092bd974d44afe67bd17727892afefa | [
"BSD-2-Clause"
] | null | null | null | cci/graph.cpp | vino-ebe/int-pgms | 124e63d46092bd974d44afe67bd17727892afefa | [
"BSD-2-Clause"
] | null | null | null | #include<iostream>
using namespace std;
struct graphNode {
int vertex;
struct graphNode* next;
};
class graph {
private:
static const int NUM_VERTEX = 10;
graphNode* V[NUM_VERTEX];
int numEdges[NUM_VERTEX];
bool visited[NUM_VERTEX];
graphNode* createNode(int vertex) {
graphNode *temp = new graphNode();
temp->vertex = vertex;
temp->next = NULL;
return temp;
}
public:
graph() {
for (int i = 0; i < NUM_VERTEX; i++) {
V[i] = NULL;
numEdges[i] = 0;
visited = false;
}
}
void addEdge(int fromVertex, int toVertex) {
if (!V[fromVertex]) {
V[fromVertex] = createNode(fromVertex);
}
graphNode* temp = createNode(toVertex);
temp->next = V[fromVertex]->next;
V[fromVertex]->next = temp;
}
void printGraph() {
graphNode *temp = NULL;
for (int i = 0; i < NUM_VERTEX; i++) {
temp = V[i];
if (temp) {
cout<<"Vertex ["<<i<<"] --->";
while (temp) {
cout<<temp->vertex;
temp = temp->next;
cout<<"--->";
}
}
cout<<endl;
}
}
bool routeExist(int vertex1, int vertex2) {
graphNode* temp = V[vertex1];
while (temp) {
if (temp->vertex == vertex2) {
return true;
}
temp = temp->next;
}
return false;
}
};
int main()
{
graph g;
g.addEdge(1,2);
g.addEdge(1,3);
g.addEdge(2,1);
g.addEdge(2,3);
g.addEdge(3,1);
g.addEdge(3,2);
g.addEdge(3,4);
g.addEdge(4,3);
g.printGraph();
if (g.routeExist(3,5)) {
cout<<"Route Exist"<<endl;
} else {
cout<<"Route does not exist"<<endl;
}
}
| 22.645161 | 55 | 0.420228 | vino-ebe |
95c32850a295113d071f24e4730031c3f0412056 | 2,712 | cpp | C++ | LinkDelay/LinkDelay.cpp | kravitz/transims4 | ea0848bf3dc71440d54724bb3ecba3947b982215 | [
"NASA-1.3"
] | 2 | 2018-04-27T11:07:02.000Z | 2020-04-24T06:53:21.000Z | LinkDelay/LinkDelay.cpp | idkravitz/transims4 | ea0848bf3dc71440d54724bb3ecba3947b982215 | [
"NASA-1.3"
] | null | null | null | LinkDelay/LinkDelay.cpp | idkravitz/transims4 | ea0848bf3dc71440d54724bb3ecba3947b982215 | [
"NASA-1.3"
] | null | null | null | //*********************************************************
// LinkDelay.cpp - manipulate the link delay file
//*********************************************************
#include "LinkDelay.hpp"
char * LinkDelay::PREVIOUS_LINK_DELAY_FILE = "PREVIOUS_LINK_DELAY_FILE";
char * LinkDelay::PREVIOUS_LINK_DELAY_FORMAT = "PREVIOUS_LINK_DELAY_FORMAT";
char * LinkDelay::PREVIOUS_WEIGHTING_FACTOR = "PREVIOUS_WEIGHTING_FACTOR";
char * LinkDelay::PREVIOUS_LINK_FILE = "PREVIOUS_LINK_FILE";
char * LinkDelay::TIME_OF_DAY_FORMAT = "TIME_OF_DAY_FORMAT";
char * LinkDelay::PROCESSING_METHOD = "PROCESSING_METHOD";
char * LinkDelay::SMOOTH_GROUP_SIZE = "SMOOTH_GROUP_SIZE";
char * LinkDelay::PERCENT_MOVED_FORWARD = "PERCENT_MOVED_FORWARD";
char * LinkDelay::PERCENT_MOVED_BACKWARD = "PERCENT_MOVED_BACKWARD";
char * LinkDelay::NUMBER_OF_ITERATIONS = "NUMBER_OF_ITERATIONS";
char * LinkDelay::CIRCULAR_GROUP_FLAG = "CIRCULAR_GROUP_FLAG";
char * LinkDelay::TIME_PERIOD_SORT = "TIME_PERIOD_SORT";
//---------------------------------------------------------
// LinkDelay constructor
//---------------------------------------------------------
LinkDelay::LinkDelay (void) : Demand_Service ()
{
Program ("LinkDelay");
Version ("4.0.11");
Title ("Manipulate the Link Delay File");
Network_File required_network [] = {
LINK, END_NETWORK
};
Network_File optional_network [] = {
DIRECTORY, LANE_CONNECTIVITY, END_NETWORK
};
Demand_File required_demand [] = {
NEW_LINK_DELAY, END_DEMAND
};
Demand_File optional_demand [] = {
LINK_DELAY, END_DEMAND
};
char *keys [] = {
PREVIOUS_LINK_DELAY_FILE,
PREVIOUS_LINK_DELAY_FORMAT,
PREVIOUS_WEIGHTING_FACTOR,
PREVIOUS_LINK_FILE,
PROCESSING_METHOD,
SMOOTH_GROUP_SIZE,
PERCENT_MOVED_FORWARD,
PERCENT_MOVED_BACKWARD,
NUMBER_OF_ITERATIONS,
CIRCULAR_GROUP_FLAG,
TIME_PERIOD_SORT,
NULL
};
Key_List (keys);
Required_Network_Files (required_network);
Optional_Network_Files (optional_network);
Required_Demand_Files (required_demand);
Optional_Demand_Files (optional_demand);
previous_flag = link_flag = false;
method = SIMPLE_AVERAGE;
factor = 1.0;
nerror = 0;
niter = 3;
naverage = 3;
forward = 20.0;
backward = 20.0;
loop_flag = true;
sort_flag = false;
}
//---------------------------------------------------------
// LinkDelay destructor
//---------------------------------------------------------
LinkDelay::~LinkDelay (void)
{
}
//---------------------------------------------------------
// main program
//---------------------------------------------------------
int main (int commands, char *control [])
{
LinkDelay *exe = new LinkDelay ();
return (exe->Start_Execution (commands, control));
}
| 28.25 | 76 | 0.620575 | kravitz |
95c41364396c72ef419b126279ffe3586e0ae5df | 475 | cpp | C++ | Train/T.cpp | dangercard/Uva_Challenges | 735bf80da5d1995fece4614d38174d1ea276e7c2 | [
"Apache-2.0"
] | null | null | null | Train/T.cpp | dangercard/Uva_Challenges | 735bf80da5d1995fece4614d38174d1ea276e7c2 | [
"Apache-2.0"
] | null | null | null | Train/T.cpp | dangercard/Uva_Challenges | 735bf80da5d1995fece4614d38174d1ea276e7c2 | [
"Apache-2.0"
] | null | null | null | #include <iostream>
#include <stack>
#include <string>
using namespace std ;
int main()
{
string stI, stO ;
int j = 0 ;
cin >> stI ;
cin >> stO ;
stack <char> S ;
// S.push(stI[0]) ;
for(int i = 0; i < stI.length() ; i++)
{
if(stO[j] == S.top())
{
S.pop() ;
j++ ;
}
else
{
S.push(stI[i]) ;
}
}
if(S.empty())
{
cout << "True" << endl ;
}
else
{
cout << "False" << endl ;
}
return 0 ;
}
| 11.046512 | 40 | 0.427368 | dangercard |
95cbec5d7d2291e6f2b109179f40f62aa22c908a | 623 | cpp | C++ | USACO Bronze/December 2016 Contest/cowsignal.cpp | Alecs-Li/Competitive-Programming | 39941ff8e2c8994abbae8c96a1ed0a04b10058b8 | [
"MIT"
] | 1 | 2021-07-06T02:14:03.000Z | 2021-07-06T02:14:03.000Z | USACO Bronze/December 2016 Contest/cowsignal.cpp | Alex01890-creator/competitive-programming | 39941ff8e2c8994abbae8c96a1ed0a04b10058b8 | [
"MIT"
] | null | null | null | USACO Bronze/December 2016 Contest/cowsignal.cpp | Alex01890-creator/competitive-programming | 39941ff8e2c8994abbae8c96a1ed0a04b10058b8 | [
"MIT"
] | null | null | null | #include <iostream>
#include <fstream>
using namespace std;
int main() {
ifstream fin("cowsignal.in");
ofstream fout("cowsignal.out");
int m, n, k; fin >> m >> n >> k;
char arr[m*n];
string temp = "";
char ans[(m*k)*(n*k)];
for(int a=0; a<m*n; a++){
fin >> arr[a];
}
for(int a=0; a<=m*n; a++){
if(a % n == 0 && a != 0){
fout << "\n";
for(int b=0; b<k-1; b++){
fout << temp << "\n";
}
temp = "";
if(a == m*n){
break;
}
}
for(int b=0; b<k; b++){
ans[a + b] = arr[a];
temp += arr[a];
fout << ans[a+b];
}
}
}
| 18.323529 | 34 | 0.410915 | Alecs-Li |
95d1cf50c77c13f8caa762f74792d59c3b2dcdb1 | 1,396 | hpp | C++ | framework/include/planet.hpp | der-freddy/computergrafik | c47e32de23edc1c2aff45f2c789286219afcbf8f | [
"MIT"
] | null | null | null | framework/include/planet.hpp | der-freddy/computergrafik | c47e32de23edc1c2aff45f2c789286219afcbf8f | [
"MIT"
] | null | null | null | framework/include/planet.hpp | der-freddy/computergrafik | c47e32de23edc1c2aff45f2c789286219afcbf8f | [
"MIT"
] | null | null | null | #ifndef PLANETS_HPP
#define PLANETS_HPP
#include <memory>
#include <map>
#include <glbinding/gl/gl.h>
#include <glm/gtc/type_precision.hpp>
#include <glm/gtc/matrix_transform.hpp>
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>
// use gl definitions from glbinding
using namespace gl;
struct Planet{
Planet(glm::fvec3 rotation = glm::fvec3(), glm::fvec3 translation = glm::fvec3(), glm::fvec3 scale = glm::fvec3(),
double rotationSpeed = 1.0f, glm::vec3 color = glm::fvec3(), float glossyness = 1.0f,
std::shared_ptr<Planet> ref_pl = nullptr, texture_object texObj = texture_object())
{
rotation_ = rotation;
translation_ = translation;
scale_ = scale;
rotationSpeed_ = rotationSpeed;
color_ = color;
ref_pl_ = ref_pl;
glossyness_ = glossyness;
texObj_ = texObj;
}
glm::fvec3 rotation_;
glm::fvec3 translation_;
glm::fvec3 scale_;
double rotationSpeed_;
glm::fvec3 color_;
std::shared_ptr<Planet> ref_pl_;
float glossyness_;
texture_object texObj_;
};
glm::fmat4 model_matrix(std::shared_ptr<Planet> const& planet)
{
glm::fmat4 matrix{};
if(planet->ref_pl_ != nullptr)
{
matrix *= model_matrix(planet->ref_pl_);
}
matrix *= glm::rotate(glm::fmat4{}, float(glfwGetTime()*planet->rotationSpeed_), planet->rotation_);
matrix *= glm::translate(glm::fmat4{}, planet->translation_);
return matrix;
}
#endif | 25.381818 | 117 | 0.699857 | der-freddy |
95dbd0f6c9879cd5d0f0fab70fffbcf8e675ba91 | 106 | hpp | C++ | src/health.hpp | BUDDGAF/eft-packet-1 | cd10a52f4ea6e98219a14e17a8a5ba6bd7d98cc0 | [
"MIT"
] | 13 | 2020-05-02T00:32:14.000Z | 2021-12-28T03:01:28.000Z | src/health.hpp | BUDDGAF/eft-packet-1 | cd10a52f4ea6e98219a14e17a8a5ba6bd7d98cc0 | [
"MIT"
] | null | null | null | src/health.hpp | BUDDGAF/eft-packet-1 | cd10a52f4ea6e98219a14e17a8a5ba6bd7d98cc0 | [
"MIT"
] | 8 | 2020-05-01T19:24:55.000Z | 2022-03-14T14:47:51.000Z | std::unordered_map<std::string, std::string> healthItems = {
{ "544fb45d4bdc2dee738b4568", "Salewa"},
}; | 35.333333 | 61 | 0.707547 | BUDDGAF |
95de790876c884e506a77dba01c034af8b4d3503 | 2,009 | cpp | C++ | libs/viewport/impl/src/viewport/impl/center.cpp | cpreh/spacegameengine | 313a1c34160b42a5135f8223ffaa3a31bc075a01 | [
"BSL-1.0"
] | 2 | 2016-01-27T13:18:14.000Z | 2018-05-11T01:11:32.000Z | libs/viewport/impl/src/viewport/impl/center.cpp | cpreh/spacegameengine | 313a1c34160b42a5135f8223ffaa3a31bc075a01 | [
"BSL-1.0"
] | null | null | null | libs/viewport/impl/src/viewport/impl/center.cpp | cpreh/spacegameengine | 313a1c34160b42a5135f8223ffaa3a31bc075a01 | [
"BSL-1.0"
] | 3 | 2018-05-11T01:11:34.000Z | 2021-04-24T19:47:45.000Z | // Copyright Carl Philipp Reh 2006 - 2019.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <sge/renderer/dim2.hpp>
#include <sge/renderer/pixel_rect.hpp>
#include <sge/renderer/pixel_unit.hpp>
#include <sge/renderer/target/viewport.hpp>
#include <sge/viewport/impl/center.hpp>
#include <sge/window/dim.hpp>
#include <fcppt/assert/error.hpp>
#include <fcppt/cast/size.hpp>
#include <fcppt/cast/to_signed.hpp>
#include <fcppt/cast/to_signed_fun.hpp>
#include <fcppt/math/dim/structure_cast.hpp>
#include <fcppt/math/vector/null.hpp>
namespace
{
sge::renderer::pixel_unit center_position(
sge::window::dim::value_type const _target_size,
sge::window::dim::value_type const _window_size)
{
FCPPT_ASSERT_ERROR(_window_size >= _target_size);
return fcppt::cast::size<sge::renderer::pixel_unit>(
fcppt::cast::to_signed((_window_size - _target_size) / 2U));
}
}
sge::renderer::target::viewport
sge::viewport::impl::center(sge::window::dim const &_ref_dim, sge::window::dim const &_window_dim)
{
return _ref_dim.w() > _window_dim.w() || _ref_dim.h() > _window_dim.h()
? sge::renderer::target::viewport(sge::renderer::pixel_rect(
fcppt::math::vector::null<sge::renderer::pixel_rect::vector>(),
fcppt::math::dim::
structure_cast<sge::renderer::pixel_rect::dim, fcppt::cast::to_signed_fun>(
_window_dim)))
: sge::renderer::target::viewport(sge::renderer::pixel_rect(
sge::renderer::pixel_rect::vector(
center_position(_ref_dim.w(), _window_dim.w()),
center_position(_ref_dim.h(), _window_dim.h())),
fcppt::math::dim::
structure_cast<sge::renderer::pixel_rect::dim, fcppt::cast::to_signed_fun>(
_ref_dim)));
}
| 39.392157 | 98 | 0.644102 | cpreh |
95df578aff1c8a74dd14af06aaf5eb825204fbf2 | 5,648 | cpp | C++ | node/silkworm/db/genesis_test.cpp | elmato/silkworm | 711c73547cd1f7632ff02d5f86dfac5b0d249344 | [
"Apache-2.0"
] | 87 | 2020-08-03T11:40:39.000Z | 2022-03-31T10:27:58.000Z | node/silkworm/db/genesis_test.cpp | elmato/silkworm | 711c73547cd1f7632ff02d5f86dfac5b0d249344 | [
"Apache-2.0"
] | 452 | 2020-08-17T16:32:00.000Z | 2022-03-28T19:19:59.000Z | node/silkworm/db/genesis_test.cpp | elmato/silkworm | 711c73547cd1f7632ff02d5f86dfac5b0d249344 | [
"Apache-2.0"
] | 28 | 2020-08-27T02:06:50.000Z | 2022-03-03T22:30:46.000Z | /*
Copyright 2021 The Silkworm Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "genesis.hpp"
#include <catch2/catch.hpp>
#include <silkworm/chain/genesis.hpp>
#include <silkworm/common/test_context.hpp>
namespace silkworm {
namespace db {
TEST_CASE("Database genesis initialization") {
test::Context context;
auto& txn{context.txn()};
SECTION("Initialize with Mainnet") {
auto source_data{silkworm::read_genesis_data(silkworm::kMainnetConfig.chain_id)};
auto genesis_json = nlohmann::json::parse(source_data, nullptr, /*allow_exceptions=*/false);
REQUIRE(db::initialize_genesis(txn, genesis_json, /*allow_exceptions=*/false));
context.commit_and_renew_txn();
CHECK(db::read_chain_config(txn) == silkworm::kMainnetConfig);
}
SECTION("Initialize with Goerli") {
auto source_data{silkworm::read_genesis_data(silkworm::kGoerliConfig.chain_id)};
auto genesis_json = nlohmann::json::parse(source_data, nullptr, /*allow_exceptions=*/false);
REQUIRE(db::initialize_genesis(txn, genesis_json, /*allow_exceptions=*/false));
CHECK(db::read_chain_config(txn) == silkworm::kGoerliConfig);
}
SECTION("Initialize with Rinkeby") {
auto source_data{silkworm::read_genesis_data(silkworm::kRinkebyConfig.chain_id)};
auto genesis_json = nlohmann::json::parse(source_data, nullptr, /*allow_exceptions=*/false);
REQUIRE(db::initialize_genesis(txn, genesis_json, /*allow_exceptions=*/false));
CHECK(db::read_chain_config(txn) == silkworm::kRinkebyConfig);
}
SECTION("Initialize with Ropsten") {
auto source_data{silkworm::read_genesis_data(silkworm::kRopstenConfig.chain_id)};
auto genesis_json = nlohmann::json::parse(source_data, nullptr, /*allow_exceptions=*/false);
// We don't have json data (yet)
REQUIRE(db::initialize_genesis(txn, genesis_json, /*allow_exceptions=*/false) == false);
}
SECTION("Initialize with invalid Json") {
std::string source_data{"{chainId="};
auto genesis_json = nlohmann::json::parse(source_data, nullptr, /*allow_exceptions=*/false);
REQUIRE_THROWS(db::initialize_genesis(txn, genesis_json, /*allow_exceptions=*/true));
}
SECTION("Initialize with errors in Json payload") {
// Base is mainnet
auto source_data{silkworm::read_genesis_data(silkworm::kMainnetConfig.chain_id)};
nlohmann::json notHex = "0xgg";
// Remove mandatory members
{
auto genesis_json = nlohmann::json::parse(source_data, nullptr, /*allow_exceptions=*/false);
REQUIRE(genesis_json.is_discarded() == false);
auto removed_count = genesis_json.erase("difficulty");
removed_count += genesis_json.erase("gaslimit");
removed_count += genesis_json.erase("timestamp");
removed_count += genesis_json.erase("extraData");
removed_count += genesis_json.erase("config");
const auto& [valid, errors]{db::validate_genesis_json(genesis_json)};
REQUIRE(valid == false);
CHECK(errors.size() == removed_count);
}
// Tamper with hex values
{
auto genesis_json = nlohmann::json::parse(source_data, nullptr, /*allow_exceptions=*/false);
REQUIRE(genesis_json.is_discarded() == false);
genesis_json["difficulty"] = notHex;
genesis_json["nonce"] = notHex;
const auto& [valid, errors]{db::validate_genesis_json(genesis_json)};
REQUIRE(valid == false);
CHECK(errors.size() == 2);
genesis_json = nlohmann::json::parse(source_data, nullptr, /*allow_exceptions=*/false);
genesis_json["alloc"]["c951900c341abbb3bafbf7ee2029377071dbc36a"]["balance"] = notHex;
}
// Tamper with hex values on allocations
{
auto genesis_json = nlohmann::json::parse(source_data, nullptr, /*allow_exceptions=*/false);
genesis_json["alloc"]["c951900c341abbb3bafbf7ee2029377071dbc36a"]["balance"] = notHex;
genesis_json["alloc"]["c951900c341abbb3bafbf7ee2029377071dbc"]["balance"] = notHex;
const auto& [valid, errors]{db::validate_genesis_json(genesis_json)};
REQUIRE(valid == false);
CHECK(errors.size() == 2);
}
// Remove chainId from config member
{
auto genesis_json = nlohmann::json::parse(source_data, nullptr, /*allow_exceptions=*/false);
genesis_json["config"].erase("chainId");
const auto& [valid, errors]{db::validate_genesis_json(genesis_json)};
REQUIRE(valid == false);
CHECK(errors.size() == 1);
}
}
}
} // namespace db
} // namespace silkworm
| 47.066667 | 108 | 0.625354 | elmato |
95df962b0c35f50c2c5dd71789129eebb8683eed | 438 | cpp | C++ | src/ByteEngine/Utility/Shapes/ConeWithFalloff.cpp | Facundo961/Game-Studio | 8f404fd9b5659e65e7c5a7fe5f191d39b7a5a071 | [
"MIT"
] | 10 | 2020-05-05T03:21:34.000Z | 2022-01-22T23:01:22.000Z | src/ByteEngine/Utility/Shapes/ConeWithFalloff.cpp | Facundo961/Game-Studio | 8f404fd9b5659e65e7c5a7fe5f191d39b7a5a071 | [
"MIT"
] | null | null | null | src/ByteEngine/Utility/Shapes/ConeWithFalloff.cpp | Facundo961/Game-Studio | 8f404fd9b5659e65e7c5a7fe5f191d39b7a5a071 | [
"MIT"
] | 1 | 2020-09-07T03:04:48.000Z | 2020-09-07T03:04:48.000Z | #include "ConeWithFalloff.h"
#include <GTSL/Math/Math.hpp>
ConeWithFalloff::ConeWithFalloff(const float Radius, const float Length) : Cone(Radius, Length)
{
}
ConeWithFalloff::ConeWithFalloff(const float Radius, const float Length, const float ExtraRadius) : Cone(Radius, Length), ExtraRadius(ExtraRadius)
{
}
float ConeWithFalloff::GetOuterConeInnerRadius() const
{
return GTSL::Math::ArcTangent((Radius + ExtraRadius) / Length);
}
| 25.764706 | 146 | 0.773973 | Facundo961 |
95e1341ada4a78caed6969a85bf6aa78612254b5 | 28,086 | cpp | C++ | __Source__/Jimara/Physics/PhysX/PhysXScene.cpp | TheDonsky/Jimara | d677090e61dc1ddfd8c1be61d5202fbf09b1e3ab | [
"MIT"
] | 1 | 2022-03-28T13:57:09.000Z | 2022-03-28T13:57:09.000Z | __Source__/Jimara/Physics/PhysX/PhysXScene.cpp | TheDonsky/Jimara | d677090e61dc1ddfd8c1be61d5202fbf09b1e3ab | [
"MIT"
] | null | null | null | __Source__/Jimara/Physics/PhysX/PhysXScene.cpp | TheDonsky/Jimara | d677090e61dc1ddfd8c1be61d5202fbf09b1e3ab | [
"MIT"
] | 1 | 2021-02-02T13:34:57.000Z | 2021-02-02T13:34:57.000Z | #include "PhysXScene.h"
#include "PhysXStaticBody.h"
#include "PhysXDynamicBody.h"
#include "../../Core/Unused.h"
#include "PhysXCollider.h"
#pragma warning(disable: 26812)
namespace Jimara {
namespace Physics {
namespace PhysX {
namespace {
#define JIMARA_PHYSX_LAYER_COUNT 256
#define JIMARA_PHYSX_LAYER_DATA_BYTE_ID(layerId) (layerId >> 3)
#define JIMARA_PHYSX_LAYER_DATA_WIDTH JIMARA_PHYSX_LAYER_DATA_BYTE_ID(JIMARA_PHYSX_LAYER_COUNT)
#define JIMARA_PHYSX_LAYER_FILTER_DATA_SIZE (JIMARA_PHYSX_LAYER_COUNT * JIMARA_PHYSX_LAYER_DATA_WIDTH)
#define JIMARA_PHYSX_GET_LAYER_DATA_BYTE(data, layerA, layerB) data[(layerA * JIMARA_PHYSX_LAYER_DATA_WIDTH) + JIMARA_PHYSX_LAYER_DATA_BYTE_ID(layerB)]
#define JIMARA_PHYSX_LAYER_DATA_BIT(layerB) static_cast<uint8_t>(1u << (layerB & 7))
#define JIMARA_PHYSX_GET_LAYER_DATA_BIT(data, layerA, layerB) ((JIMARA_PHYSX_GET_LAYER_DATA_BYTE(data, layerA, layerB) & JIMARA_PHYSX_LAYER_DATA_BIT(layerB)) != 0)
static PX_INLINE physx::PxFilterFlags SimulationFilterShader(
physx::PxFilterObjectAttributes attributes0,
physx::PxFilterData filterData0,
physx::PxFilterObjectAttributes attributes1,
physx::PxFilterData filterData1,
physx::PxPairFlags& pairFlags,
const void* constantBlock,
physx::PxU32 constantBlockSize) {
Unused(attributes0, attributes1, constantBlockSize, constantBlock);
PhysicsCollider::Layer layerA = PhysXCollider::GetLayer(filterData0);
PhysicsCollider::Layer layerB = PhysXCollider::GetLayer(filterData1);
if (!JIMARA_PHYSX_GET_LAYER_DATA_BIT(static_cast<const uint8_t*>(constantBlock), layerA, layerB))
return physx::PxFilterFlag::eSUPPRESS;
if ((PhysXCollider::GetFilterFlags(filterData0) & static_cast<PhysXCollider::FilterFlags>(PhysXCollider::FilterFlag::IS_TRIGGER)) != 0 ||
(PhysXCollider::GetFilterFlags(filterData1) & static_cast<PhysXCollider::FilterFlags>(PhysXCollider::FilterFlag::IS_TRIGGER)) != 0) {
pairFlags = physx::PxPairFlag::eTRIGGER_DEFAULT;
}
else pairFlags = physx::PxPairFlag::eCONTACT_DEFAULT | physx::PxPairFlag::eNOTIFY_CONTACT_POINTS;
pairFlags |= physx::PxPairFlag::eNOTIFY_TOUCH_CCD
| physx::PxPairFlag::eNOTIFY_TOUCH_FOUND
| physx::PxPairFlag::eNOTIFY_TOUCH_PERSISTS
| physx::PxPairFlag::eNOTIFY_TOUCH_LOST
| physx::PxPairFlag::eNOTIFY_THRESHOLD_FORCE_FOUND
| physx::PxPairFlag::eNOTIFY_THRESHOLD_FORCE_PERSISTS
| physx::PxPairFlag::eNOTIFY_THRESHOLD_FORCE_LOST;
return physx::PxFilterFlag::eDEFAULT;
}
}
PhysXScene::PhysXScene(PhysXInstance* instance, size_t maxSimulationThreads, const Vector3 gravity) : PhysicsScene(instance) {
m_dispatcher = physx::PxDefaultCpuDispatcherCreate(static_cast<uint32_t>(max(maxSimulationThreads, static_cast<size_t>(1u))));
if (m_dispatcher == nullptr) {
APIInstance()->Log()->Fatal("PhysicXScene - Failed to create the dispatcher!");
return;
}
physx::PxSceneDesc sceneDesc((*instance)->getTolerancesScale());
sceneDesc.gravity = physx::PxVec3(gravity.x, gravity.y, gravity.z);
sceneDesc.cpuDispatcher = m_dispatcher;
sceneDesc.filterShader = SimulationFilterShader;
sceneDesc.simulationEventCallback = &m_simulationEventCallback;
sceneDesc.kineKineFilteringMode = physx::PxPairFilteringMode::eKEEP;
sceneDesc.staticKineFilteringMode = physx::PxPairFilteringMode::eKEEP;
sceneDesc.flags |= physx::PxSceneFlag::eENABLE_CCD;
m_scene = (*instance)->createScene(sceneDesc);
if (m_scene == nullptr) {
APIInstance()->Log()->Fatal("PhysicXScene - Failed to create the scene!");
return;
}
m_layerFilterData = new uint8_t[JIMARA_PHYSX_LAYER_FILTER_DATA_SIZE];
for (size_t i = 0; i < JIMARA_PHYSX_LAYER_FILTER_DATA_SIZE; i++) m_layerFilterData[i] = ~((uint8_t)0);
physx::PxPvdSceneClient* pvdClient = m_scene->getScenePvdClient();
if (pvdClient != nullptr)
{
pvdClient->setScenePvdFlag(physx::PxPvdSceneFlag::eTRANSMIT_CONSTRAINTS, true);
pvdClient->setScenePvdFlag(physx::PxPvdSceneFlag::eTRANSMIT_CONTACTS, true);
pvdClient->setScenePvdFlag(physx::PxPvdSceneFlag::eTRANSMIT_SCENEQUERIES, true);
pvdClient->setScenePvdFlag(physx::PxPvdSceneFlag::eTRANSMIT_CONTACTS, true);
}
}
PhysXScene::~PhysXScene() {
if (m_scene != nullptr) {
m_scene->release();
m_scene = nullptr;
}
if (m_dispatcher != nullptr) {
m_dispatcher->release();
m_dispatcher = nullptr;
}
if (m_layerFilterData != nullptr) {
delete[] m_layerFilterData;
m_layerFilterData = nullptr;
}
}
Vector3 PhysXScene::Gravity()const {
ReadLock lock(this);
physx::PxVec3 gravity = m_scene->getGravity();
return Vector3(gravity.x, gravity.y, gravity.z);
}
void PhysXScene::SetGravity(const Vector3& value) {
WriteLock lock(this);
m_scene->setGravity(physx::PxVec3(value.x, value.y, value.z));
}
bool PhysXScene::LayersInteract(PhysicsCollider::Layer a, PhysicsCollider::Layer b)const {
if (m_layerFilterData == nullptr) return false;
else return JIMARA_PHYSX_GET_LAYER_DATA_BIT(m_layerFilterData, a, b);
}
void PhysXScene::FilterLayerInteraction(PhysicsCollider::Layer a, PhysicsCollider::Layer b, bool enableIntaraction) {
if (m_layerFilterData == nullptr) {
APIInstance()->Log()->Fatal("PhysXScene::FilterLayerInteraction - layer filter data missing!");
return;
}
if (enableIntaraction) {
JIMARA_PHYSX_GET_LAYER_DATA_BYTE(m_layerFilterData, a, b) |= JIMARA_PHYSX_LAYER_DATA_BIT(b);
JIMARA_PHYSX_GET_LAYER_DATA_BYTE(m_layerFilterData, b, a) |= JIMARA_PHYSX_LAYER_DATA_BIT(a);
}
else {
JIMARA_PHYSX_GET_LAYER_DATA_BYTE(m_layerFilterData, a, b) &= ~JIMARA_PHYSX_LAYER_DATA_BIT(b);
JIMARA_PHYSX_GET_LAYER_DATA_BYTE(m_layerFilterData, b, a) &= ~JIMARA_PHYSX_LAYER_DATA_BIT(a);
}
m_layerFilterDataDirty = true;
}
Reference<DynamicBody> PhysXScene::AddRigidBody(const Matrix4& pose, bool enabled) {
PhysXScene::WriteLock lock(this);
return Object::Instantiate<PhysXDynamicBody>(this, pose, enabled);
}
Reference<StaticBody> PhysXScene::AddStaticBody(const Matrix4& pose, bool enabled) {
PhysXScene::WriteLock lock(this);
return Object::Instantiate<PhysXStaticBody>(this, pose, enabled);
}
namespace {
struct LocationHitTranslator {
inline static RaycastHit TranslateHit(const physx::PxLocationHit& hitInfo) {
RaycastHit hit;
hit.collider = ((PhysXCollider::UserData*)hitInfo.shape->userData)->Collider();
hit.normal = Translate(hitInfo.normal);
hit.point = Translate(hitInfo.position);
hit.distance = hitInfo.distance;
return hit;
}
};
struct OverlapHitTranslator {
inline static PhysicsCollider* TranslateHit(const physx::PxOverlapHit& hitInfo) {
return ((PhysXCollider::UserData*)hitInfo.shape->userData)->Collider();
}
};
struct QueryFilterCallback : public physx::PxQueryFilterCallback {
const PhysicsCollider::LayerMask layers;
const Function<PhysicsScene::QueryFilterFlag, PhysicsCollider*>* const preFilterCallback = nullptr;
const Function<PhysicsScene::QueryFilterFlag, const RaycastHit&>* const postFilterCallback = nullptr;
const bool findAll = false;
const physx::PxQueryFilterData filterData;
inline physx::PxQueryHitType::Enum TypeFromFlag(PhysicsScene::QueryFilterFlag flag) {
return
(flag == PhysicsScene::QueryFilterFlag::REPORT) ? (findAll ? physx::PxQueryHitType::eTOUCH : physx::PxQueryHitType::eBLOCK) :
(flag == PhysicsScene::QueryFilterFlag::REPORT_BLOCK) ? physx::PxQueryHitType::eBLOCK : physx::PxQueryHitType::eNONE;
}
inline virtual physx::PxQueryHitType::Enum preFilter(
const physx::PxFilterData& filterData, const physx::PxShape* shape, const physx::PxRigidActor* actor, physx::PxHitFlags& queryFlags) override {
Unused(filterData, actor, queryFlags);
PhysXCollider::UserData* data = (PhysXCollider::UserData*)shape->userData;
if (data == nullptr) return physx::PxQueryHitType::eNONE;
PhysicsCollider* collider = data->Collider();
if (collider == nullptr) return physx::PxQueryHitType::eNONE;
else if (!layers[collider->GetLayer()]) return physx::PxQueryHitType::eNONE;
else if (preFilterCallback != nullptr) return TypeFromFlag((*preFilterCallback)(collider));
else return (findAll ? physx::PxQueryHitType::eTOUCH : physx::PxQueryHitType::eBLOCK);
}
inline virtual physx::PxQueryHitType::Enum postFilter(const physx::PxFilterData& filterData, const physx::PxQueryHit& hit) override {
Unused(filterData);
if (hit.shape->userData == nullptr) return physx::PxQueryHitType::eNONE;
RaycastHit checkHit = LocationHitTranslator::TranslateHit((physx::PxLocationHit&)hit);
if (checkHit.collider == nullptr) return physx::PxQueryHitType::eNONE;
else return TypeFromFlag((*postFilterCallback)(checkHit));
}
inline QueryFilterCallback(const PhysicsCollider::LayerMask& mask
, const Function<PhysicsScene::QueryFilterFlag, PhysicsCollider*>* preFilterCall
, const Function<PhysicsScene::QueryFilterFlag, const RaycastHit&>* postFilterCall
, PhysicsScene::QueryFlags flags, bool ignoreOrder = false)
: layers(mask)
, preFilterCallback(preFilterCall), postFilterCallback(postFilterCall)
, findAll((flags & PhysicsScene::Query(PhysicsScene::QueryFlag::REPORT_MULTIPLE_HITS)) != 0)
, filterData([&]() {
physx::PxQueryFilterData data;
data.flags = physx::PxQueryFlag::ePREFILTER;
if ((flags & PhysicsScene::Query(PhysicsScene::QueryFlag::EXCLUDE_STATIC_BODIES)) == 0) data.flags |= physx::PxQueryFlag::eSTATIC;
if ((flags & PhysicsScene::Query(PhysicsScene::QueryFlag::EXCLUDE_DYNAMIC_BODIES)) == 0) data.flags |= physx::PxQueryFlag::eDYNAMIC;
if (postFilterCall != nullptr) data.flags |= physx::PxQueryFlag::ePOSTFILTER;
bool queryAll = ((flags & PhysicsScene::Query(PhysicsScene::QueryFlag::REPORT_MULTIPLE_HITS)) != 0);
if (queryAll) {
if (ignoreOrder || (preFilterCall == nullptr && postFilterCall == nullptr)) data.flags |= physx::PxQueryFlag::eNO_BLOCK;
}
else if (ignoreOrder) data.flags |= physx::PxQueryFlag::eANY_HIT;
return data;
}()) {}
};
template<typename HitType, typename ReportedType = const RaycastHit&, typename HitTranslator = LocationHitTranslator>
class MultiHitCallbacks : public virtual physx::PxHitCallback<HitType> {
private:
HitType m_touchBuffer[128];
const Callback<ReportedType>* m_onHitFound;
size_t m_numTouches = 0;
public:
inline MultiHitCallbacks(const Callback<ReportedType>* onHitFound)
: physx::PxHitCallback<HitType>(m_touchBuffer, static_cast<physx::PxU32>(sizeof(m_touchBuffer) / sizeof(HitType)))
, m_onHitFound(onHitFound) { }
inline virtual physx::PxAgain processTouches(const HitType* buffer, physx::PxU32 nbHits) override {
for (physx::PxU32 i = 0; i < nbHits; i++) (*m_onHitFound)(HitTranslator::TranslateHit(buffer[i]));
m_numTouches += nbHits;
return true;
}
inline size_t NumTouches()const { return m_numTouches; }
};
inline static bool FixDirection(const Vector3& direction, float& maxDistance, physx::PxVec3& dir) {
if (maxDistance < 0.0f) {
maxDistance = -maxDistance;
dir = -Translate(direction);
}
else dir = Translate(direction);
float rawDirMagn = dir.magnitude();
if (rawDirMagn <= 0.0f) return false;
else {
dir /= rawDirMagn;
return true;
}
}
inline static size_t PhysXSweep(physx::PxScene* scene, const physx::PxGeometry& shape, const physx::PxTransform& transform
, const Vector3& direction, float maxDistance, const Callback<const RaycastHit&>& onHitFound
, const PhysicsCollider::LayerMask& layerMask, PhysicsScene::QueryFlags flags
, const Function<PhysicsScene::QueryFilterFlag, PhysicsCollider*>* preFilter
, const Function<PhysicsScene::QueryFilterFlag, const RaycastHit&>* postFilter) {
physx::PxVec3 dir;
if (!FixDirection(direction, maxDistance, dir)) return 0;
QueryFilterCallback filterCallback(layerMask, preFilter, postFilter, flags);
physx::PxHitFlags hitFlags = physx::PxHitFlag::ePOSITION | physx::PxHitFlag::eNORMAL;
if (filterCallback.findAll) {
MultiHitCallbacks<physx::PxSweepHit> hitBuff(&onHitFound);
scene->sweep(shape, transform, dir, maxDistance, hitBuff, hitFlags | physx::PxHitFlag::eMESH_MULTIPLE, filterCallback.filterData, &filterCallback);
if (hitBuff.hasBlock) {
onHitFound(LocationHitTranslator::TranslateHit(hitBuff.block));
return hitBuff.NumTouches() + 1;
}
else return hitBuff.NumTouches();
}
else {
physx::PxSweepBuffer hitBuff;
if (scene->sweep(shape, transform, dir, maxDistance, hitBuff, hitFlags, filterCallback.filterData, &filterCallback)) {
assert(hitBuff.hasBlock);
onHitFound(LocationHitTranslator::TranslateHit(hitBuff.block));
return 1;
}
else return 0;
}
}
inline static size_t PhysXOverlap(physx::PxScene* scene, const physx::PxGeometry& shape, const physx::PxTransform& transform
, const Callback<PhysicsCollider*>& onHitFound, const PhysicsCollider::LayerMask& layerMask, PhysicsScene::QueryFlags flags
, const Function<PhysicsScene::QueryFilterFlag, PhysicsCollider*>* filter) {
QueryFilterCallback filterCallback(layerMask, filter, nullptr, flags, true);
if (filterCallback.findAll) {
MultiHitCallbacks<physx::PxOverlapHit, PhysicsCollider*, OverlapHitTranslator> hitBuff(&onHitFound);
scene->overlap(shape, transform, hitBuff, filterCallback.filterData, &filterCallback);
if (hitBuff.hasBlock) {
onHitFound(OverlapHitTranslator::TranslateHit(hitBuff.block));
return hitBuff.NumTouches() + 1;
}
else return hitBuff.NumTouches();
}
else {
physx::PxOverlapBuffer hitBuff;
if (scene->overlap(shape, transform, hitBuff, filterCallback.filterData, &filterCallback)) {
assert(hitBuff.hasBlock);
onHitFound(OverlapHitTranslator::TranslateHit(hitBuff.block));
return 1;
}
else return 0;
}
}
}
size_t PhysXScene::Raycast(const Vector3& origin, const Vector3& direction, float maxDistance
, const Callback<const RaycastHit&>& onHitFound, const PhysicsCollider::LayerMask& layerMask, QueryFlags flags
, const Function<QueryFilterFlag, PhysicsCollider*>* preFilter, const Function<QueryFilterFlag, const RaycastHit&>* postFilter)const {
static_assert(sizeof(physx::PxFilterData) >= sizeof(PhysicsCollider::LayerMask*));
physx::PxVec3 dir;
if (!FixDirection(direction, maxDistance, dir)) return 0;
QueryFilterCallback filterCallback(layerMask, preFilter, postFilter, flags);
physx::PxHitFlags hitFlags = physx::PxHitFlag::ePOSITION | physx::PxHitFlag::eNORMAL;
if (filterCallback.findAll) {
MultiHitCallbacks<physx::PxRaycastHit> hitBuff(&onHitFound);
ReadLock lock(this);
m_scene->raycast(Translate(origin), dir, maxDistance, hitBuff, hitFlags | physx::PxHitFlag::eMESH_MULTIPLE, filterCallback.filterData, &filterCallback);
if (hitBuff.hasBlock) {
onHitFound(LocationHitTranslator::TranslateHit(hitBuff.block));
return hitBuff.NumTouches() + 1;
}
else return hitBuff.NumTouches();
}
else {
physx::PxRaycastBuffer hitBuff;
ReadLock lock(this);
if (m_scene->raycast(Translate(origin), dir, maxDistance, hitBuff, hitFlags, filterCallback.filterData, &filterCallback)) {
assert(hitBuff.hasBlock);
onHitFound(LocationHitTranslator::TranslateHit(hitBuff.block));
return 1;
}
else return 0;
}
}
size_t PhysXScene::Sweep(const SphereShape& shape, const Matrix4& pose, const Vector3& direction, float maxDistance
, const Callback<const RaycastHit&>& onHitFound, const PhysicsCollider::LayerMask& layerMask, QueryFlags flags
, const Function<QueryFilterFlag, PhysicsCollider*>* preFilter, const Function<QueryFilterFlag, const RaycastHit&>* postFilter)const {
ReadLock lock(this);
return PhysXSweep(
m_scene, PhysXSphereCollider::Geometry(shape), physx::PxTransform(Translate(pose))
, direction, maxDistance, onHitFound, layerMask, flags, preFilter, postFilter);
}
size_t PhysXScene::Sweep(const CapsuleShape& shape, const Matrix4& pose, const Vector3& direction, float maxDistance
, const Callback<const RaycastHit&>& onHitFound, const PhysicsCollider::LayerMask& layerMask, QueryFlags flags
, const Function<QueryFilterFlag, PhysicsCollider*>* preFilter, const Function<QueryFilterFlag, const RaycastHit&>* postFilter)const {
ReadLock lock(this);
return PhysXSweep(
m_scene, PhysXCapusuleCollider::Geometry(shape), physx::PxTransform(Translate(pose * PhysXCapusuleCollider::Wrangle(shape.alignment).first))
, direction, maxDistance, onHitFound, layerMask, flags, preFilter, postFilter);
}
size_t PhysXScene::Sweep(const BoxShape& shape, const Matrix4& pose, const Vector3& direction, float maxDistance
, const Callback<const RaycastHit&>& onHitFound, const PhysicsCollider::LayerMask& layerMask, QueryFlags flags
, const Function<QueryFilterFlag, PhysicsCollider*>* preFilter, const Function<QueryFilterFlag, const RaycastHit&>* postFilter)const {
ReadLock lock(this);
return PhysXSweep(
m_scene, PhysXBoxCollider::Geometry(shape), physx::PxTransform(Translate(pose))
, direction, maxDistance, onHitFound, layerMask, flags, preFilter, postFilter);
}
size_t PhysXScene::Overlap(const SphereShape& shape, const Matrix4& pose, const Callback<PhysicsCollider*>& onOverlapFound
, const PhysicsCollider::LayerMask& layerMask, QueryFlags flags, const Function<QueryFilterFlag, PhysicsCollider*>* filter)const {
ReadLock lock(this);
return PhysXOverlap(m_scene, PhysXSphereCollider::Geometry(shape), physx::PxTransform(Translate(pose)), onOverlapFound, layerMask, flags, filter);
}
size_t PhysXScene::Overlap(const CapsuleShape& shape, const Matrix4& pose, const Callback<PhysicsCollider*>& onOverlapFound
, const PhysicsCollider::LayerMask& layerMask, QueryFlags flags, const Function<QueryFilterFlag, PhysicsCollider*>* filter)const {
ReadLock lock(this);
return PhysXOverlap(
m_scene, PhysXCapusuleCollider::Geometry(shape), physx::PxTransform(Translate(pose * PhysXCapusuleCollider::Wrangle(shape.alignment).first)),
onOverlapFound, layerMask, flags, filter);
}
size_t PhysXScene::Overlap(const BoxShape& shape, const Matrix4& pose, const Callback<PhysicsCollider*>& onOverlapFound
, const PhysicsCollider::LayerMask& layerMask, QueryFlags flags, const Function<QueryFilterFlag, PhysicsCollider*>* filter)const {
ReadLock lock(this);
return PhysXOverlap(m_scene, PhysXBoxCollider::Geometry(shape), physx::PxTransform(Translate(pose)), onOverlapFound, layerMask, flags, filter);
}
void PhysXScene::SimulateAsynch(float deltaTime) {
WriteLock lock(this);
if (m_layerFilterDataDirty) {
m_scene->setFilterShaderData(m_layerFilterData, static_cast<physx::PxU32>(JIMARA_PHYSX_LAYER_FILTER_DATA_SIZE));
m_layerFilterDataDirty = false;
}
m_scene->simulate(deltaTime);
}
void PhysXScene::SynchSimulation() {
{
WriteLock lock(this);
m_scene->fetchResults(true);
}
m_simulationEventCallback.NotifyEvents();
}
PhysXScene::operator physx::PxScene* () const { return m_scene; }
physx::PxScene* PhysXScene::operator->()const { return m_scene; }
void PhysXScene::SimulationEventCallback::onConstraintBreak(physx::PxConstraintInfo* constraints, physx::PxU32 count) {
Unused(constraints, count);
}
void PhysXScene::SimulationEventCallback::onWake(physx::PxActor** actors, physx::PxU32 count) {
Unused(actors, count);
}
void PhysXScene::SimulationEventCallback::onSleep(physx::PxActor** actors, physx::PxU32 count) {
Unused(actors, count);
}
void PhysXScene::SimulationEventCallback::onContact(const physx::PxContactPairHeader& pairHeader, const physx::PxContactPair* pairs, physx::PxU32 nbPairs) {
Unused(pairHeader);
std::unique_lock<std::mutex> lock(m_eventLock);
uint8_t bufferId = m_backBuffer;
std::vector<PhysicsCollider::ContactPoint>& pointBuffer = m_contactPoints[bufferId];
for (size_t i = 0; i < nbPairs; i++) {
const physx::PxContactPair& pair = pairs[i];
PhysXCollider::UserData* data[2] = { (PhysXCollider::UserData*)pair.shapes[0]->userData, (PhysXCollider::UserData*)pair.shapes[1]->userData };
if (data[0] == nullptr || data[1] == nullptr) continue;
bool isTriggerContact = data[0]->Collider()->IsTrigger() || data[1]->Collider()->IsTrigger();
ContactPairInfo info = {};
info.info.type =
(((physx::PxU16)pair.events & physx::PxPairFlag::eNOTIFY_TOUCH_FOUND) != 0)
? (isTriggerContact ? PhysicsCollider::ContactType::ON_TRIGGER_BEGIN : PhysicsCollider::ContactType::ON_COLLISION_BEGIN) :
(((physx::PxU16)pair.events & physx::PxPairFlag::eNOTIFY_TOUCH_LOST) != 0)
? (isTriggerContact ? PhysicsCollider::ContactType::ON_TRIGGER_END : PhysicsCollider::ContactType::ON_COLLISION_END) :
(((physx::PxU16)pair.events & physx::PxPairFlag::eNOTIFY_TOUCH_PERSISTS) != 0)
? (isTriggerContact ? PhysicsCollider::ContactType::ON_TRIGGER_PERSISTS : PhysicsCollider::ContactType::ON_COLLISION_PERSISTS) :
PhysicsCollider::ContactType::CONTACT_TYPE_COUNT;
if (info.info.type >= PhysicsCollider::ContactType::CONTACT_TYPE_COUNT) continue;
if (pair.shapes[0] < pair.shapes[1]) {
info.shapes[0] = pair.shapes[0];
info.shapes[1] = pair.shapes[1];
info.info.reverseOrder = false;
}
else {
info.shapes[0] = pair.shapes[1];
info.shapes[1] = pair.shapes[0];
info.info.reverseOrder = true;
}
if (m_contactPointBuffer.size() < pair.contactCount) m_contactPointBuffer.resize(pair.contactCount);
size_t contactCount = pair.extractContacts(m_contactPointBuffer.data(), (uint32_t)m_contactPointBuffer.size());
info.info.pointBuffer = bufferId;
info.info.firstContactPoint = pointBuffer.size();
for (size_t i = 0; i < contactCount; i++) {
const physx::PxContactPairPoint& point = m_contactPointBuffer[i];
PhysicsCollider::ContactPoint info = {};
info.position = Translate(point.position);
info.normal = Translate(point.normal);
pointBuffer.push_back(info);
}
info.info.lastContactPoint = pointBuffer.size();
m_contacts.push_back(info);
}
}
void PhysXScene::SimulationEventCallback::onTrigger(physx::PxTriggerPair* pairs, physx::PxU32 count) {
std::unique_lock<std::mutex> lock(m_eventLock);
uint8_t bufferId = m_backBuffer;
for (size_t i = 0; i < count; i++) {
const physx::PxTriggerPair& pair = pairs[i];
ContactPairInfo info = {};
info.info.type =
(pair.status == physx::PxPairFlag::eNOTIFY_TOUCH_FOUND) ? PhysicsCollider::ContactType::ON_TRIGGER_BEGIN :
(pair.status == physx::PxPairFlag::eNOTIFY_TOUCH_LOST) ? PhysicsCollider::ContactType::ON_TRIGGER_END :
PhysicsCollider::ContactType::CONTACT_TYPE_COUNT;
if (info.info.type >= PhysicsCollider::ContactType::CONTACT_TYPE_COUNT) continue;
if (pair.triggerShape < pair.otherShape) {
info.shapes[0] = pair.triggerShape;
info.shapes[1] = pair.otherShape;
info.info.reverseOrder = false;
}
else {
info.shapes[0] = pair.otherShape;
info.shapes[1] = pair.triggerShape;
info.info.reverseOrder = true;
}
if (info.shapes[0]->userData == nullptr || info.shapes[1]->userData == nullptr) continue;
info.info.pointBuffer = bufferId;
m_contacts.push_back(info);
}
}
void PhysXScene::SimulationEventCallback::onAdvance(const physx::PxRigidBody* const* bodyBuffer, const physx::PxTransform* poseBuffer, const physx::PxU32 count) {
Unused(bodyBuffer, poseBuffer, count);
}
void PhysXScene::SimulationEventCallback::NotifyEvents() {
std::unique_lock<std::mutex> lock(m_eventLock);
// Current contact point buffer:
const uint8_t bufferId = m_backBuffer;
std::vector<PhysicsCollider::ContactPoint>& pointBuffer = m_contactPoints[bufferId];
// Notifies listeners about the pair contact (returns false, if the shapes are no longer valid):
auto notifyContact = [&](const ShapePair& pair, ContactInfo& info) {
PhysXCollider::UserData* listener = (PhysXCollider::UserData*)pair.shapes[0]->userData;
PhysXCollider::UserData* otherListener = (PhysXCollider::UserData*)pair.shapes[1]->userData;
if (listener == nullptr || otherListener == nullptr) return false;
PhysicsCollider::ContactPoint* const contactPoints = pointBuffer.data() + info.firstContactPoint;
const size_t contactPointCount = (info.lastContactPoint - info.firstContactPoint);
auto reverse = [&]() {
for (size_t i = 0; i < contactPointCount; i++) {
PhysicsCollider::ContactPoint& point = contactPoints[i];
point.normal = -point.normal;
}
info.reverseOrder ^= 1;
};
if (info.reverseOrder) {
otherListener->OnContact(pair.shapes[1], pair.shapes[0], info.type, contactPoints, contactPointCount);
reverse();
listener->OnContact(pair.shapes[0], pair.shapes[1], info.type, contactPoints, contactPointCount);
}
else {
listener->OnContact(pair.shapes[0], pair.shapes[1], info.type, contactPoints, contactPointCount);
reverse();
otherListener->OnContact(pair.shapes[1], pair.shapes[0], info.type, contactPoints, contactPointCount);
}
return true;
};
// Notifies about the newly contacts and saves persistent contacts in case the actors start sleeping:
for (size_t contactId = 0; contactId < m_contacts.size(); contactId++) {
ContactPairInfo& info = m_contacts[contactId];
ShapePair pair;
pair.shapes[0] = info.shapes[0];
pair.shapes[1] = info.shapes[1];
notifyContact(pair, info.info);
if (info.info.type == PhysicsCollider::ContactType::ON_COLLISION_END ||
info.info.type == PhysicsCollider::ContactType::ON_TRIGGER_END)
m_persistentContacts.erase(pair);
else {
ContactInfo contact = info.info;
if (contact.type == PhysicsCollider::ContactType::ON_COLLISION_BEGIN)
contact.type = PhysicsCollider::ContactType::ON_COLLISION_PERSISTS;
else if (contact.type == PhysicsCollider::ContactType::ON_TRIGGER_BEGIN)
contact.type = PhysicsCollider::ContactType::ON_TRIGGER_PERSISTS;
m_persistentContacts[pair] = contact;
}
}
// Notifies about sleeping persistent contacts:
for (PersistentContactMap::iterator it = m_persistentContacts.begin(); it != m_persistentContacts.end(); ++it) {
ContactInfo& info = it->second;
if (info.pointBuffer == bufferId) continue;
const size_t contactPointCount = (info.lastContactPoint - info.firstContactPoint);
const PhysicsCollider::ContactPoint* const contactPoints = m_contactPoints[info.pointBuffer].data() + info.firstContactPoint;
info.firstContactPoint = pointBuffer.size();
for (size_t i = 0; i < contactPointCount; i++)
pointBuffer.push_back(contactPoints[i]);
info.lastContactPoint = pointBuffer.size();
info.pointBuffer = bufferId;
if (!notifyContact(it->first, info)) m_pairsToRemove.push_back(it->first);
}
// Remove invalidated persistent contacts:
for (size_t i = 0; i < m_pairsToRemove.size(); i++)
m_persistentContacts.erase(m_pairsToRemove[i]);
m_pairsToRemove.clear();
// Swaps contact buffers:
m_backBuffer ^= 1;
m_contacts.clear();
m_contactPoints[m_backBuffer].clear();
}
}
}
}
#pragma warning(default: 26812)
| 48.257732 | 166 | 0.719504 | TheDonsky |
95e4a43f68f6cc9a521e6035d8e96e5bf407b08a | 3,916 | hpp | C++ | include/polycalc/quadrature/gauss_lobatto.hpp | BryanFlynt/PolyCalc | 9fe70f83647c6f5683e6e8f5cfee23b417974ebb | [
"Apache-2.0"
] | null | null | null | include/polycalc/quadrature/gauss_lobatto.hpp | BryanFlynt/PolyCalc | 9fe70f83647c6f5683e6e8f5cfee23b417974ebb | [
"Apache-2.0"
] | null | null | null | include/polycalc/quadrature/gauss_lobatto.hpp | BryanFlynt/PolyCalc | 9fe70f83647c6f5683e6e8f5cfee23b417974ebb | [
"Apache-2.0"
] | null | null | null | /**
* \file gauss_lobatto.hpp
* \author Bryan Flynt
* \date Sep 02, 2021
* \copyright Copyright (C) 2021 Bryan Flynt - All Rights Reserved
*/
#pragma once
#include <cassert>
#include <vector>
#include "polycalc/parameters.hpp"
#include "polycalc/polynomial/jacobi.hpp"
namespace polycalc {
namespace quadrature {
template <typename T, typename P = DefaultParameters<T>>
class GaussLobatto {
public:
using value_type = T;
using params = P;
using size_type = std::size_t;
using polynomial = ::polycalc::polynomial::Jacobi<T, P>;
GaussLobatto() = delete;
GaussLobatto(const GaussLobatto& other) = default;
GaussLobatto(GaussLobatto&& other) = default;
~GaussLobatto() = default;
GaussLobatto& operator=(const GaussLobatto& other) = default;
GaussLobatto& operator=(GaussLobatto&& other) = default;
GaussLobatto(const value_type a, const value_type b) : alpha_(a), beta_(b) {}
/** Quadrature Locations
*
* Returns the Gauss-Lobatto quadrature locations at n locations.
*/
std::vector<value_type> zeros(const unsigned n) const;
/** Quadrature Weights
*
* Returns the Gauss-Jacobi weights at n Lobatto zeros.
*/
std::vector<value_type> weights(const unsigned n) const;
private:
value_type alpha_;
value_type beta_;
};
template <typename T, typename P>
std::vector<typename GaussLobatto<T, P>::value_type> GaussLobatto<T, P>::zeros(const unsigned n) const {
assert(n > 0);
// Good Decimal Calculator found at following site
// https://keisan.casio.com/exec/system/1280801905
// Zeros to return
std::vector<value_type> x(n);
switch (n) {
case 1:
x[0] = 0.0;
break;
case 2:
x[0] = -1.0;
x[1] = +1.0;
break;
case 3:
x[0] = -1.0;
x[1] = 0.0;
x[2] = +1.0;
break;
default:
polynomial jac(alpha_ + 1, beta_ + 1);
auto zeros = jac.zeros(n - 2);
x.front() = -1.0;
std::copy(zeros.begin(), zeros.end(), x.begin() + 1);
x.back() = +1.0;
if (!(n % 2 == 0)) {
x[std::ptrdiff_t(n / 2)] = 0; // Correct 10E-16 error at zero
}
}
return x;
}
template <typename T, typename P>
std::vector<typename GaussLobatto<T, P>::value_type> GaussLobatto<T, P>::weights(const unsigned n) const {
assert(n > 0);
// Good Decimal Calculator found at following site
// https://keisan.casio.com/exec/system/1280801905
// Weights to return
std::vector<value_type> w(n);
switch (n) {
case 1:
w[0] = +2.0;
break;
case 2:
w[0] = +1.0;
w[1] = +1.0;
break;
case 3:
w[0] = 1.0L / 3.0L;
w[1] = 4.0L / 3.0L;
w[2] = 1.0L / 3.0L;
break;
default:
// Get location of zeros
auto z = this->zeros(n);
// Evaluate Jacobi n-1 polynomial at each zero
polynomial jac(alpha_, beta_);
for (size_type i = 0; i < n; ++i) {
w[i] = jac.eval(n - 1, z[i]);
}
const value_type one = 1;
const value_type two = 2;
const value_type apb = alpha_ + beta_;
value_type fac;
fac = std::pow(two, apb + one) * std::tgamma(alpha_ + n) * std::tgamma(beta_ + n);
fac /= (n - 1) * std::tgamma(n) * std::tgamma(alpha_ + beta_ + n + one);
for (size_type i = 0; i < n; ++i) {
w[i] = fac / (w[i] * w[i]);
}
w[0] *= (beta_ + one);
w[n - 1] *= (alpha_ + one);
}
return w;
}
} // namespace quadrature
} // namespace polycalc | 27.77305 | 106 | 0.522472 | BryanFlynt |
95e5037325108bcb3a68d454b1596a032466ddf7 | 1,277 | cpp | C++ | RPSolver/conditions/ColorConditionPosition.cpp | igui/OppositeRenderer | 2442741792b3f0f426025c2015002694fab692eb | [
"MIT"
] | 9 | 2016-06-25T15:52:05.000Z | 2020-01-15T17:31:49.000Z | RPSolver/conditions/ColorConditionPosition.cpp | igui/OppositeRenderer | 2442741792b3f0f426025c2015002694fab692eb | [
"MIT"
] | null | null | null | RPSolver/conditions/ColorConditionPosition.cpp | igui/OppositeRenderer | 2442741792b3f0f426025c2015002694fab692eb | [
"MIT"
] | 2 | 2018-10-17T18:33:37.000Z | 2022-03-14T20:17:30.000Z | #include "ColorConditionPosition.h"
#include "renderer/PMOptixRenderer.h"
#include <QLocale>
#include <QVector>
#include <QColor>
ColorConditionPosition::ColorConditionPosition(const QString& node, const optix::float3& hsvColor) :
m_node(node),
m_hsvColor(hsvColor)
{
}
/// adapted from http://www.cs.rit.edu/~ncs/color/t_convert.html
optix::float3 ColorConditionPosition::rgbColor() const
{
QColor color = QColor::fromHsvF(m_hsvColor.x / 360.f, m_hsvColor.y, m_hsvColor.z);
return optix::make_float3(color.redF(), color.greenF(), color.blueF());
}
void ColorConditionPosition::apply(PMOptixRenderer *renderer) const
{
renderer->setNodeDiffuseMaterialKd(m_node, rgbColor());
}
optix::float3 ColorConditionPosition::hsvColor() const
{
return m_hsvColor;
}
float ColorConditionPosition::value() const
{
return m_hsvColor.z;
}
QString ColorConditionPosition::node() const
{
return m_node;
}
QVector<float> ColorConditionPosition::normalizedPosition() const
{
return QVector<float>() << value();
}
QStringList ColorConditionPosition::info() const
{
QLocale locale;
auto color = rgbColor();
auto x = locale.toString(color.x, 'f', 2);
auto y = locale.toString(color.y, 'f', 2);
auto z = locale.toString(color.z, 'f', 2);
return QStringList() << x << y << z;
} | 23.648148 | 100 | 0.740016 | igui |
95e691961ebfa6bbdb05b501023cc8f9232bca74 | 470 | cpp | C++ | test/one_pole_test.cpp | hansen-audio/dsp-tool-box | 4b73b39c4149b1a160ff9baa58830d6a4478feef | [
"MIT"
] | null | null | null | test/one_pole_test.cpp | hansen-audio/dsp-tool-box | 4b73b39c4149b1a160ff9baa58830d6a4478feef | [
"MIT"
] | null | null | null | test/one_pole_test.cpp | hansen-audio/dsp-tool-box | 4b73b39c4149b1a160ff9baa58830d6a4478feef | [
"MIT"
] | null | null | null | // Copyright(c) 2021 Hansen Audio.
#include "ha/dsp_tool_box/filtering/one_pole.h"
#include "gtest/gtest.h"
using namespace ha::dtb::filtering;
/**
* @brief one_pole_test
*/
TEST(one_pole_test, test_one_pole_initialisation)
{
auto one_pole = OnePoleImpl::create();
EXPECT_FLOAT_EQ(one_pole.a, 0.9);
EXPECT_FLOAT_EQ(one_pole.b, 0.1);
EXPECT_FLOAT_EQ(one_pole.z, 0.0);
}
//----------------------------------------------------------------------------- | 24.736842 | 79 | 0.595745 | hansen-audio |
95ebda8d3be8708b52ecab9bc614b240388f153f | 944 | cpp | C++ | codeforces/1567B.cpp | sgrade/cpptest | 84ade6ec03ea394d4a4489c7559d12b4799c0b62 | [
"MIT"
] | null | null | null | codeforces/1567B.cpp | sgrade/cpptest | 84ade6ec03ea394d4a4489c7559d12b4799c0b62 | [
"MIT"
] | null | null | null | codeforces/1567B.cpp | sgrade/cpptest | 84ade6ec03ea394d4a4489c7559d12b4799c0b62 | [
"MIT"
] | null | null | null | // B. MEXor Mixup
#include <iostream>
using namespace std;
// Method to calculate xor
int computeXOR(int n) {
// Source - https://www.geeksforgeeks.org/calculate-xor-1-n/
// If n is a multiple of 4
if (n % 4 == 0) {
return n;
}
// If n%4 gives remainder 1
if (n % 4 == 1) {
return 1;
}
// If n%4 gives remainder 2
if (n % 4 == 2) {
return n + 1;
}
// If n%4 gives remainder 3
return 0;
}
int main() {
int t;
cin >> t;
while (t--) {
int a, b;
cin >> a >> b;
int ans;
// Editorial - https://codeforces.com/blog/entry/94581
int x = computeXOR(a-1);
if (x == b) {
ans = a;
}
else {
if ((x ^ b) != a) {
ans = a + 1;
}
else {
ans = a + 2;
}
}
cout << ans << endl;
}
}
| 15.225806 | 64 | 0.400424 | sgrade |
95ec924801c63c19c0604cdbd92f81fcfb7c89c5 | 2,081 | cpp | C++ | lib/netdata/fragments_server.cpp | siilky/catomania | cb3a05cbef523d16b8929b390e190e0cd5924ee9 | [
"MIT"
] | 1 | 2021-02-05T23:20:07.000Z | 2021-02-05T23:20:07.000Z | lib/netdata/fragments_server.cpp | siilky/catomania | cb3a05cbef523d16b8929b390e190e0cd5924ee9 | [
"MIT"
] | null | null | null | lib/netdata/fragments_server.cpp | siilky/catomania | cb3a05cbef523d16b8929b390e190e0cd5924ee9 | [
"MIT"
] | null | null | null | #include "stdafx.h"
#include "netdata/fragments_server.h"
namespace serverdata
{
static const fragmentCollection_t fragments[] =
{
COLLECTION_ELEMENT(Array),
COLLECTION_ELEMENT(ArrayPacked),
COLLECTION_ELEMENT(GameinfoSet),
COLLECTION_ELEMENT(AccInfo),
COLLECTION_ELEMENT(ErrorInfo),
COLLECTION_ELEMENT(StatusAnnounce),
COLLECTION_ELEMENT(PlayerLogout),
COLLECTION_ELEMENT(SelectRoleRe),
// 50
COLLECTION_ELEMENT(ChatMessage),
COLLECTION_ELEMENT(CreateRoleRe),
COLLECTION_ELEMENT(RoleListRe),
COLLECTION_ELEMENT(Keepalive),
COLLECTION_ELEMENT(PlayerBaseInfoRe),
// 60
COLLECTION_ELEMENT(PrivateChat),
COLLECTION_ELEMENT(BannedMessage),
COLLECTION_ELEMENT(WorldChat),
COLLECTION_ELEMENT(LoginIpInfo),
COLLECTION_ELEMENT(GetFriendsRe),
COLLECTION_ELEMENT(SetLockTimeRe),
COLLECTION_ELEMENT(BattleGetMapRe),
COLLECTION_ELEMENT(BattleChallengeMapRe),
//
COLLECTION_ELEMENT(ComissionShop),
COLLECTION_ELEMENT(ComissionShopList),
COLLECTION_ELEMENT(TradeStartRe),
COLLECTION_ELEMENT(TradeRequest),
COLLECTION_ELEMENT(TradeAddGoodsRe),
COLLECTION_ELEMENT(TradeRemoveGoodsRe),
COLLECTION_ELEMENT(TradeSubmitRe),
COLLECTION_ELEMENT(TradeConfirmRe),
COLLECTION_ELEMENT(TradeDiscardRe),
COLLECTION_ELEMENT(TradeEnd),
// 1200
COLLECTION_ELEMENT(FactionChat),
COLLECTION_ELEMENT(GetFactionBaseInfoRe),
COLLECTION_ELEMENT(ACWhoami),
COLLECTION_ELEMENT(ACRemoteCode),
COLLECTION_ELEMENT(ACProtoStat),
COLLECTION_ELEMENT(ACStatusAnnounce),
COLLECTION_ELEMENT(ACReportCheater),
COLLECTION_ELEMENT(ACTriggerQuestion),
COLLECTION_ELEMENT(ACQuestion),
COLLECTION_ELEMENT(ACAnswer),
COLLECTION_END
};
FragmentFactory fragmentFactory(identifyFragment, fragments, fragment_static_ctor<Fragment>);
} // namespace
| 32.515625 | 97 | 0.702547 | siilky |
95eead97864fb897edd4dd8a2cbc86b300d5d66f | 775 | cpp | C++ | graph-source-code/296-D/10047350.cpp | AmrARaouf/algorithm-detection | 59f3028d2298804870b32729415d71eec6116557 | [
"MIT"
] | null | null | null | graph-source-code/296-D/10047350.cpp | AmrARaouf/algorithm-detection | 59f3028d2298804870b32729415d71eec6116557 | [
"MIT"
] | null | null | null | graph-source-code/296-D/10047350.cpp | AmrARaouf/algorithm-detection | 59f3028d2298804870b32729415d71eec6116557 | [
"MIT"
] | null | null | null | //Language: GNU C++
//In the name of God
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <map>
#include <cstdio>
using namespace std;
#define mp make_pair
#define X first
#define Y second
#define lol long long
const int MAXN=510;
lol dis[MAXN][MAXN],a[MAXN],ans[MAXN];
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
cin>>dis[i][j];
for(int i=1;i<=n;i++)
cin>>a[i];
for(int i=n;i>0;i--)
{
for(int j=1;j<=n;j++)
for(int k=1;k<=n;k++)
dis[a[j]][a[k]]=min(dis[a[j]][a[k]],dis[a[j]][a[i]]+dis[a[i]][a[k]]);
for(int j=i;j<=n;j++)
for(int k=i;k<=n;k++)
ans[i]+=dis[a[j]][a[k]];
}
for(int i=1;i<=n;i++)
cout<<ans[i]<<" ";
cout<<endl;
return 0;
}
| 17.613636 | 72 | 0.536774 | AmrARaouf |
95f63141ee8879d95b09b6d158efeaadc1b9224a | 981 | cpp | C++ | topic_wise/binarysearch/russianDollEnvelopes.cpp | archit-1997/LeetCode | 7c0f74da0836d3b0855f09bae8960f81a384f3f3 | [
"MIT"
] | 1 | 2021-01-27T16:37:36.000Z | 2021-01-27T16:37:36.000Z | topic_wise/binarysearch/russianDollEnvelopes.cpp | archit-1997/LeetCode | 7c0f74da0836d3b0855f09bae8960f81a384f3f3 | [
"MIT"
] | null | null | null | topic_wise/binarysearch/russianDollEnvelopes.cpp | archit-1997/LeetCode | 7c0f74da0836d3b0855f09bae8960f81a384f3f3 | [
"MIT"
] | null | null | null | /**
* @author : archit
* @GitHub : archit-1997
* @Email : [email protected]
* @file : russianDollEnvelopes.cpp
* @created : Friday Aug 20, 2021 19:49:02 IST
*/
#include <bits/stdc++.h>
using namespace std;
bool compare(const vector<int> &a,const vector<int> &b){
if(a[0]==b[0])
return a[1]>b[1];
return a[0]<b[0];
}
class Solution {
public:
int maxEnvelopes(vector<vector<int>>& envelopes) {
int n=envelopes.size();
//we will sort on the basis of the first param and in descending on the basis of the second param
vector<int> ans;
sort(envelopes.begin(),envelopes.end(),compare);
for(int i=0;i<n;i++){
int index=lower_bound(ans.begin(),ans.end(),envelopes[i][1])-ans.begin();
if(index==ans.size())
ans.push_back(envelopes[i][1]);
else
ans[index]=envelopes[i][1];
}
return ans.size();
}
};
| 27.25 | 105 | 0.559633 | archit-1997 |
2507f8068640fc6f36eb0b4121359f400f7b1814 | 1,034 | cpp | C++ | C++/problem0125.cpp | 1050669722/LeetCode-Answers | c8f4d1ccaac09cda63b60d75144335347b06dc81 | [
"MIT"
] | null | null | null | C++/problem0125.cpp | 1050669722/LeetCode-Answers | c8f4d1ccaac09cda63b60d75144335347b06dc81 | [
"MIT"
] | null | null | null | C++/problem0125.cpp | 1050669722/LeetCode-Answers | c8f4d1ccaac09cda63b60d75144335347b06dc81 | [
"MIT"
] | null | null | null | class Solution {
public:
bool isPalindrome(string s) {
if (s.size() == 0)
{
return true;
}
vector<char> v;
for (int i = 0; i < s.size(); ++i)
{
if (isalnum(s[i]))
{
v.push_back(s[i]);
// cout << s[i] << ' ';
}
}
int i = 0, j = v.size() - 1;
while (i < j)
{
// cout << v[i] << ' ' << v[j] << endl;
if (toupper(v[i]) != toupper(v[j]))
// if (strupr(v[i]) != strupr(v[j]))
{
return false;
}
i++, j--;
}
// vector<char>::iterator it_i = v.begin(), it_j = v.end() - 1;
// cout << *it_i << ' ' << *it_j << endl;
// while (it_i < it_j)
// {
// if (toupper(*it_i) != toupper(*it_j))
// {
// return false;
// }
// it_i++, it_j--;
// }
return true;
}
};
| 22 | 71 | 0.305609 | 1050669722 |
2508bfcdb6b42e2a10b88a833dd0167bfe49dda3 | 476 | hpp | C++ | king/include/king/Math/VectorType.hpp | tobiasbu/king | 7a6892a93d5d4c5f14e2618104f2955281f0bada | [
"MIT"
] | 3 | 2017-03-10T13:57:25.000Z | 2017-05-31T19:05:35.000Z | king/include/king/Math/VectorType.hpp | tobiasbu/king | 7a6892a93d5d4c5f14e2618104f2955281f0bada | [
"MIT"
] | null | null | null | king/include/king/Math/VectorType.hpp | tobiasbu/king | 7a6892a93d5d4c5f14e2618104f2955281f0bada | [
"MIT"
] | null | null | null |
#ifndef KING_VECTORTYPE_HPP
#define KING_VECTORTYPE_HPP
namespace king {
// Vectors Types Predefinition
template <typename T> class Vector2;
template <typename T> class Vector3;
template <typename T> class Vector4;
// Most Commom Vectors Types
typedef Vector2<float> Vector2f;
typedef Vector2<int> Vector2i;
typedef Vector2<unsigned int> Vector2ui;
typedef Vector3<float> Vector3f;
typedef Vector3<int> Vector3i;
typedef Vector4<float> Vector4f;
}
#endif | 18.307692 | 41 | 0.771008 | tobiasbu |
250c942de9921b043307f0332d526be930225d62 | 1,961 | cpp | C++ | src/PrintHelper.cpp | TB989/Game | 9cf6e1267f1bc08b2e7f5f9a8278914f930c7c51 | [
"MIT"
] | null | null | null | src/PrintHelper.cpp | TB989/Game | 9cf6e1267f1bc08b2e7f5f9a8278914f930c7c51 | [
"MIT"
] | null | null | null | src/PrintHelper.cpp | TB989/Game | 9cf6e1267f1bc08b2e7f5f9a8278914f930c7c51 | [
"MIT"
] | null | null | null | #include <string>
#include <iostream>
void startHeader(std::string locationName){
std::cout << "**********" << locationName << "**********\n";
}
void finishHeader(std::string locationName){
std::cout << "**********";
for(unsigned int i=0;i<locationName.length();i++){
std::cout << "*";
}
std::cout<< "**********\n";
}
void printChoices(std::string option1){
std::cout << "What do you want to do?\n";
std::cout << "1: " << option1 << "\n";
}
void printChoices(std::string option1,std::string option2){
std::cout << "What do you want to do?\n";
std::cout << "1: " << option1 << "\n";
std::cout << "2: " << option2 << "\n";
}
void printChoices(std::string option1,std::string option2,std::string option3){
std::cout << "What do you want to do?\n";
std::cout << "1: " << option1 << "\n";
std::cout << "2: " << option2 << "\n";
std::cout << "3: " << option3 << "\n";
}
void printChoices(std::string option1,std::string option2,std::string option3,std::string option4){
std::cout << "What do you want to do?\n";
std::cout << "1: " << option1 << "\n";
std::cout << "2: " << option2 << "\n";
std::cout << "3: " << option3 << "\n";
std::cout << "4: " << option4 << "\n";
}
int getChoice(int maxChoices){
int choice;
while(true){
std::cout << "Your choice: ";
std::cin >> choice;
std::cin.ignore(32767, '\n');
if(!std::cin.fail()){
if(choice==0){
exit(0);
}
else if(0<choice&&choice<=maxChoices){
return choice;
}
else{
std::cin.clear();
std::cin.ignore(32767, '\n');
std::cout << "Invalid choice, try again!\n";
}
}
else{
std::cin.clear();
std::cin.ignore(32767, '\n');
std::cout << "Invalid choice, try again!\n";
}
}
}
| 28.42029 | 99 | 0.481387 | TB989 |
251e742f8655e82fa15cf61f177b17e665922ff0 | 4,157 | cpp | C++ | src/types/Criteria.cpp | Mostah/parallel-pymcda | d5f5bb0de95dec90b88be9d00a3860e52eed4003 | [
"MIT"
] | 2 | 2020-12-12T22:48:57.000Z | 2021-02-24T09:37:40.000Z | src/types/Criteria.cpp | Mostah/parallel-pymcda | d5f5bb0de95dec90b88be9d00a3860e52eed4003 | [
"MIT"
] | 5 | 2021-01-07T19:34:24.000Z | 2021-03-17T13:52:22.000Z | src/types/Criteria.cpp | Mostah/parallel-pymcda | d5f5bb0de95dec90b88be9d00a3860e52eed4003 | [
"MIT"
] | 3 | 2020-12-12T22:49:56.000Z | 2021-09-08T05:26:38.000Z | #include "../../include/types/Criteria.h"
#include "../../include/types/Criterion.h"
#include "../../include/utils.h"
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
Criteria::Criteria(std::vector<Criterion> &criterion_vect) {
std::vector<std::string> crit_id_vect;
for (Criterion crit : criterion_vect) {
// ensure there is no criterion with duplicated name
if (std::find(crit_id_vect.begin(), crit_id_vect.end(), crit.getId()) !=
crit_id_vect.end()) {
throw std::invalid_argument("Each criterion must have different ids.");
}
crit_id_vect.push_back(crit.getId());
criterion_vect_.push_back(Criterion(crit));
}
}
Criteria::Criteria(int nb_of_criteria, std::string prefix) {
for (int i = 0; i < nb_of_criteria; i++) {
criterion_vect_.push_back(Criterion(prefix + std::to_string(i)));
}
}
Criteria::Criteria(const Criteria &crits) {
// deep copy
for (int i = 0; i < crits.criterion_vect_.size(); i++) {
criterion_vect_.push_back(Criterion(crits.criterion_vect_[i]));
}
}
Criteria::~Criteria() {}
std::ostream &operator<<(std::ostream &out, const Criteria &crits) {
out << "Criteria(";
for (Criterion crit : crits.criterion_vect_) {
out << crit << ", ";
}
out << ")";
return out;
}
void Criteria::setCriterionVect(std::vector<Criterion> &criterion_vect) {
criterion_vect_.clear();
// deep copy
for (int i = 0; i < criterion_vect.size(); i++) {
criterion_vect_.push_back(Criterion(criterion_vect[i]));
}
}
std::vector<Criterion> Criteria::getCriterionVect() const {
return criterion_vect_;
};
float Criteria::getMinWeight() {
if (criterion_vect_.size() == 0) {
return 0;
}
float min = criterion_vect_[0].getWeight();
for (Criterion crit : criterion_vect_) {
if (crit.getWeight() < min) {
min = crit.getWeight();
}
}
return min;
}
float Criteria::getMaxWeight() {
if (criterion_vect_.size() == 0) {
return 0;
}
float max = criterion_vect_[0].getWeight();
for (Criterion crit : criterion_vect_) {
if (crit.getWeight() > max) {
max = crit.getWeight();
}
}
return max;
}
float Criteria::getSumWeight() {
float sum = 0;
for (Criterion crit : criterion_vect_) {
sum += crit.getWeight();
}
return sum;
}
std::vector<float> Criteria::getWeights() const {
std::vector<float> weights;
for (Criterion c : criterion_vect_) {
weights.push_back(c.getWeight());
}
return weights;
}
void Criteria::setWeights(std::vector<float> newWeigths) {
if (newWeigths.size() != criterion_vect_.size()) {
throw std::invalid_argument(
"New weight vector must have same length as Criteria ie have the same "
"value as the number of criteria");
}
for (int i = 0; i < criterion_vect_.size(); i++) {
criterion_vect_[i].setWeight(newWeigths[i]);
}
}
void Criteria::normalizeWeights() {
float sum = Criteria::getSumWeight();
std::vector<float> weights = Criteria::getWeights();
std::transform(weights.begin(), weights.end(), weights.begin(),
[&sum](float &c) { return c / sum; });
for (int i = 0; i < weights.size(); i++) {
criterion_vect_[i].setWeight(weights[i]);
}
}
// TODO Generation is not completely uniform here, might need to find an other
// method
void Criteria::generateRandomCriteriaWeights(unsigned long int seed) {
std::vector<float> weights;
for (int i = 0; i < criterion_vect_.size(); i++) {
weights.push_back(getRandomUniformFloat(seed));
}
float totSum = std::accumulate(weights.begin(), weights.end(), 0.00f);
std::transform(weights.begin(), weights.end(), weights.begin(),
[totSum](float &c) { return c / totSum; });
Criteria::setWeights(weights);
}
Criterion Criteria::operator[](std::string name) const {
for (Criterion c : criterion_vect_) {
if (c.getId() == name) {
return c;
}
}
throw std::invalid_argument("Criterion not found in this Criteria vector");
}
Criterion Criteria::operator[](int index) { return criterion_vect_[index]; }
Criterion Criteria::operator[](int index) const {
return criterion_vect_[index];
} | 28.087838 | 79 | 0.660573 | Mostah |
2520af0b6c32847350b4e715a9d45c750e9af6c2 | 15,144 | hpp | C++ | libmesh/include/sirikata/mesh/Meshdata.hpp | pathorn/sirikata | 5d366a822ef2fb57cd9f64cc4f6085c0a635fdfa | [
"BSD-3-Clause"
] | 1 | 2016-05-09T03:34:51.000Z | 2016-05-09T03:34:51.000Z | libmesh/include/sirikata/mesh/Meshdata.hpp | pathorn/sirikata | 5d366a822ef2fb57cd9f64cc4f6085c0a635fdfa | [
"BSD-3-Clause"
] | null | null | null | libmesh/include/sirikata/mesh/Meshdata.hpp | pathorn/sirikata | 5d366a822ef2fb57cd9f64cc4f6085c0a635fdfa | [
"BSD-3-Clause"
] | null | null | null | /* Sirikata
* Meshdata.hpp
*
* Copyright (c) 2010, Daniel B. Miller
* 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 Sirikata 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 OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _SIRIKATA_MESH_MESHDATA_HPP_
#define _SIRIKATA_MESH_MESHDATA_HPP_
#include <sirikata/mesh/Platform.hpp>
#include <sirikata/mesh/Visual.hpp>
#include "LightInfo.hpp"
#include <stack>
namespace Sirikata {
namespace Mesh {
// Typedefs for NodeIndices, which refer to scene graph nodes in the model
typedef int32 NodeIndex;
extern SIRIKATA_MESH_EXPORT NodeIndex NullNodeIndex;
typedef std::vector<NodeIndex> NodeIndexList;
typedef std::vector<LightInfo> LightInfoList;
typedef std::vector<std::string> TextureList;
struct Meshdata;
typedef std::tr1::shared_ptr<Meshdata> MeshdataPtr;
typedef std::tr1::weak_ptr<Meshdata> MeshdataWPtr;
/** Represents a skinned animation. A skinned animation is directly associated
* with a SubMeshGeometry.
*/
struct SIRIKATA_MESH_EXPORT SkinController {
// Joints for this controls Indexes into the Meshdata.joints array
// (which indexes into Meshdata.nodes).
std::vector<uint32> joints;
Matrix4x4f bindShapeMatrix;
///n+1 elements where n is the number of vertices, so that we can do simple
///subtraction to find out how many joints influence each vertex
std::vector<unsigned int> weightStartIndices;
// weights and jointIndices are the same size and are a sparse
// representation of the (vertex,bone) = weight matrix: the
// weightStartIndices let you figure out the range in these arrays that
// correspond to a single vertex. In that range, each pair represents the
// weight for one joint for the current vertex, with the rest of the joints
// having weight 0.
std::vector<float> weights;
std::vector<unsigned int>jointIndices;
// One inverse bind matrix per joint.
std::vector<Matrix4x4f> inverseBindMatrices;
};
typedef std::vector<SkinController> SkinControllerList;
struct SIRIKATA_MESH_EXPORT SubMeshGeometry {
std::string name;
std::vector<Sirikata::Vector3f> positions;
std::vector<Sirikata::Vector3f> normals;
std::vector<Sirikata::Vector3f> tangents;
std::vector<Sirikata::Vector4f> colors;
struct TextureSet {
unsigned int stride;
std::vector<float> uvs;
};
std::vector<TextureSet>texUVs;
struct Primitive {
std::vector<unsigned short> indices;
enum PrimitiveType {
TRIANGLES,
LINES,
POINTS,
LINESTRIPS,
TRISTRIPS,
TRIFANS
}primitiveType;
typedef size_t MaterialId;
MaterialId materialId;
};
std::vector<Primitive> primitives;
BoundingBox3f3f aabb;
double radius;
void recomputeBounds();
SkinControllerList skinControllers;
/** Append the given SubMeshGeometry to the end of this one. Use the given
* transformation to transform the geometry before adding it. This is a
* useful primitive when trying to merge/simplify geometry.
*/
void append(const SubMeshGeometry& rhs, const Matrix4x4f& xform);
};
typedef std::vector<SubMeshGeometry> SubMeshGeometryList;
struct SIRIKATA_MESH_EXPORT GeometryInstance {
typedef std::map<SubMeshGeometry::Primitive::MaterialId,size_t> MaterialBindingMap;
MaterialBindingMap materialBindingMap;//maps materialIndex to offset in Meshdata's materials
unsigned int geometryIndex; // Index in SubMeshGeometryList
NodeIndex parentNode; // Index of node holding this instance
/** Compute the bounds of this instance with the given transform. This is
* more precise, and much more expensive, than transforming the
* SubMeshGeometry's bounds.
*/
BoundingBox3f3f computeTransformedBounds(MeshdataPtr parent, const Matrix4x4f& xform) const;
BoundingBox3f3f computeTransformedBounds(const Meshdata& parent, const Matrix4x4f& xform) const;
void computeTransformedBounds(MeshdataPtr parent, const Matrix4x4f& xform, BoundingBox3f3f* bounds_out, double* radius_out) const;
void computeTransformedBounds(const Meshdata& parent, const Matrix4x4f& xform, BoundingBox3f3f* bounds_out, double* radius_out) const;
};
typedef std::vector<GeometryInstance> GeometryInstanceList;
struct SIRIKATA_MESH_EXPORT LightInstance {
int lightIndex; // Index in LightInfoList
NodeIndex parentNode; // Index of node holding this instance
};
typedef std::vector<LightInstance> LightInstanceList;
struct SIRIKATA_MESH_EXPORT MaterialEffectInfo {
struct Texture {
std::string uri;
Vector4f color;//color while the texture is pulled in, or if the texture is 404'd
size_t texCoord;
enum Affecting {
DIFFUSE,
SPECULAR,
EMISSION,
AMBIENT,
REFLECTIVE,
OPACITY,
}affecting;
enum SamplerType
{
SAMPLER_TYPE_UNSPECIFIED,
SAMPLER_TYPE_1D,
SAMPLER_TYPE_2D,
SAMPLER_TYPE_3D,
SAMPLER_TYPE_CUBE,
SAMPLER_TYPE_RECT,
SAMPLER_TYPE_DEPTH,
SAMPLER_TYPE_STATE
} samplerType;
enum SamplerFilter
{
SAMPLER_FILTER_UNSPECIFIED,
SAMPLER_FILTER_NONE,
SAMPLER_FILTER_NEAREST,
SAMPLER_FILTER_LINEAR,
SAMPLER_FILTER_NEAREST_MIPMAP_NEAREST,
SAMPLER_FILTER_LINEAR_MIPMAP_NEAREST,
SAMPLER_FILTER_NEAREST_MIPMAP_LINEAR,
SAMPLER_FILTER_LINEAR_MIPMAP_LINEAR
};
SamplerFilter minFilter;
SamplerFilter magFilter;
enum WrapMode
{
WRAP_MODE_UNSPECIFIED=0,
// NONE == GL_CLAMP_TO BORDER The defined behavior for NONE is
// consistent with decal texturing where the border is black.
// Mapping this calculation to GL_CLAMP_TO_BORDER is the best
// approximation of this.
WRAP_MODE_NONE,
// WRAP == GL_REPEAT Ignores the integer part of texture coordinates,
// using only the fractional part.
WRAP_MODE_WRAP,
// MIRROR == GL_MIRRORED_REPEAT First mirrors the texture coordinate.
// The mirrored coordinate is then clamped as described for CLAMP_TO_EDGE.
WRAP_MODE_MIRROR,
// CLAMP == GL_CLAMP_TO_EDGE Clamps texture coordinates at all
// mipmap levels such that the texture filter never samples a
// border texel. Note: GL_CLAMP takes any texels beyond the
// sampling border and substitutes those texels with the border
// color. So CLAMP_TO_EDGE is more appropriate. This also works
// much better with OpenGL ES where the GL_CLAMP symbol was removed
// from the OpenGL ES specification.
WRAP_MODE_CLAMP,
// BORDER GL_CLAMP_TO_BORDER Clamps texture coordinates at all
// MIPmaps such that the texture filter always samples border
// texels for fragments whose corresponding texture coordinate
// is sufficiently far outside the range [0, 1].
WRAP_MODE_BORDER
};
WrapMode wrapS,wrapT,wrapU;
unsigned int maxMipLevel;
float mipBias;
bool operator==(const Texture& rhs) const;
bool operator!=(const Texture& rhs) const;
};
typedef std::vector<Texture> TextureList;
TextureList textures;
float shininess;
float reflectivity;
bool operator==(const MaterialEffectInfo& rhs) const;
bool operator!=(const MaterialEffectInfo& rhs) const;
};
typedef std::vector<MaterialEffectInfo> MaterialEffectInfoList;
struct SIRIKATA_MESH_EXPORT InstanceSkinAnimation {
};
/** Represents a series of key frames */
struct SIRIKATA_MESH_EXPORT TransformationKeyFrames {
typedef std::vector<float> TimeList;
TimeList inputs;
typedef std::vector<Matrix4x4f> TransformationList;
TransformationList outputs;
};
// A scene graph node. Contains a transformation, set of children nodes,
// camera instances, geometry instances, skin controller instances, light
// instances, and instances of other nodes.
struct SIRIKATA_MESH_EXPORT Node {
Node();
Node(NodeIndex par, const Matrix4x4f& xform);
Node(const Matrix4x4f& xform);
bool containsInstanceController;
// Parent node in the actual hierarchy (not instantiated).
NodeIndex parent;
// Transformation to apply when traversing this node.
Matrix4x4f transform;
// Direct children, i.e. they are contained by this node directly and their
// parent NodeIndex will reflect that.
NodeIndexList children;
// Instantiations of other nodes (and their children) into this
// subtree. Because they are instantiations, their
// instanceChildren[i]->parent != this node's index.
NodeIndexList instanceChildren;
// Map of name -> animation curve.
typedef std::map<String, TransformationKeyFrames> AnimationMap;
AnimationMap animations;
};
typedef std::vector<Node> NodeList;
struct SIRIKATA_MESH_EXPORT Meshdata : public Visual {
private:
static String sType;
public:
virtual ~Meshdata();
virtual const String& type() const;
SubMeshGeometryList geometry;
TextureList textures;
LightInfoList lights;
MaterialEffectInfoList materials;
long id;
bool hasAnimations;
GeometryInstanceList instances;
LightInstanceList lightInstances;
// The global transform should be applied to all nodes and instances
Matrix4x4f globalTransform;
// We track two sets of nodes: roots and the full list. (Obviously the roots
// are a subset of the full list). The node list is just the full set,
// usually only used to look up children/parents. The roots list is just a
// set of indices into the full list.
NodeList nodes;
NodeIndexList rootNodes;
//Stores a list of transforms on the path from the scene root
//to the instance controller for the skeleton.
std::vector<Matrix4x4f> mInstanceControllerTransformList;
// Joints are tracked as indices of the nodes they are associated with.
NodeIndexList joints;
// Be careful using these methods. Since there are no "parent" links for
// instance nodes (and even if there were, there could be more than one),
// these methods cannot correctly compute the transform when instance_nodes
// are involved.
Matrix4x4f getTransform(NodeIndex index) const;
private:
// A stack of NodeState is used to track the current traversal state for
// instance iterators
struct SIRIKATA_MESH_EXPORT NodeState {
enum Step {
Init,
Nodes,
InstanceNodes,
InstanceGeometries,
InstanceLights,
Done
};
NodeIndex index;
Matrix4x4f transform;
Step step;
int32 currentChild;
};
struct SIRIKATA_MESH_EXPORT JointNodeState : public NodeState {
uint32 joint_id;
std::vector<Matrix4x4f> transformList;
};
public:
// Allows you to generate a list of GeometryInstances with their transformations.
class SIRIKATA_MESH_EXPORT GeometryInstanceIterator {
public:
GeometryInstanceIterator(const Meshdata* const mesh);
// Get the next GeometryInstance and its transform. Returns true if
// values were set, false if there were no more instances. The index
// returned is of the geometry instance.
bool next(uint32* geoinst_idx, Matrix4x4f* xform);
private:
const Meshdata* mMesh;
int32 mRoot;
std::stack<NodeState> mStack;
};
GeometryInstanceIterator getGeometryInstanceIterator() const;
/** Get count of instanced geometry. This can differ from instances.size()
* because many nodes may refer to the same InstanceGeometry.
*/
uint32 getInstancedGeometryCount() const;
// Allows you to generate a list of joints with their transformations.
class SIRIKATA_MESH_EXPORT JointIterator {
public:
JointIterator(const Meshdata* const mesh);
// Get the next Joint's unique ID, its index in the list of joints, its
// transform, and parent joint ID. Also gets the list of transforms from the root node
// to the instance controller of the skeleton referencing the joint. Returns true if
// values were set, false if there were no more joints. Joint IDs are
// non-zero, so you can check for, e.g., no parent with parent_id == 0
// or if (parent_id). The joint_idx is an index into Meshdata::joints.
bool next(uint32* joint_id, uint32* joint_idx, Matrix4x4f* xform, uint32* parent_id, std::vector<Matrix4x4f>& transformList);
private:
const Meshdata* mMesh;
int32 mRoot;
std::stack<JointNodeState> mStack;
uint32 mNextID;
};
JointIterator getJointIterator() const;
/** Get count of joints geometry. This can differ from joints.size()
* because nodes acting as joints may be instantiated multiple times.
*/
uint32 getJointCount() const;
// Allows you to generate a list of GeometryInstances with their transformations.
class SIRIKATA_MESH_EXPORT LightInstanceIterator {
public:
LightInstanceIterator(const Meshdata* const mesh);
// Get the next LightInstance and its transform. Returns true if
// values were set, false if there were no more instances. The index
// returned is of the light instance.
bool next(uint32* lightinst_idx, Matrix4x4f* xform);
private:
const Meshdata* mMesh;
int32 mRoot;
std::stack<NodeState> mStack;
};
LightInstanceIterator getLightInstanceIterator() const;
/** Get count of instanced lights. This can differ from
* lightInstances.size() because many nodes may refer to the same
* InstanceLight.
*/
uint32 getInstancedLightCount() const;
};
} // namespace Mesh
} // namespace Sirikata
#endif //_SIRIKATA_MESH_MESHDATA_HPP_
| 36.757282 | 138 | 0.719427 | pathorn |
2532703c98e156e338f8abd5c4d6dcc28a4dc5d0 | 8,616 | cpp | C++ | PrgApps4/17-MMFSparse/MMFSparse.cpp | JimYang365/samples | 920c2d98b1ef0dc3d3b861b9b73ab6a3d0e5ced0 | [
"MIT"
] | null | null | null | PrgApps4/17-MMFSparse/MMFSparse.cpp | JimYang365/samples | 920c2d98b1ef0dc3d3b861b9b73ab6a3d0e5ced0 | [
"MIT"
] | null | null | null | PrgApps4/17-MMFSparse/MMFSparse.cpp | JimYang365/samples | 920c2d98b1ef0dc3d3b861b9b73ab6a3d0e5ced0 | [
"MIT"
] | null | null | null | /******************************************************************************
Module: MMFSparse.cpp
Notices: Copyright (c) 2000 Jeffrey Richter
******************************************************************************/
#include "..\CmnHdr.h" /* See Appendix A. */
#include <tchar.h>
#include <WindowsX.h>
#include <WinIoCtl.h>
#include "SparseStream.h"
#include "Resource.h"
//////////////////////////////////////////////////////////////////////////////
// This class makes it easy to work with memory-mapped sparse files
class CMMFSparse : public CSparseStream {
private:
HANDLE m_hfilemap; // File-mapping object
PVOID m_pvFile; // Address to start of mapped file
public:
// Creates a Sparse MMF and maps it in the process's address space.
CMMFSparse(HANDLE hstream = NULL, SIZE_T dwStreamSizeMax = 0);
// Closes a Sparse MMF
virtual ~CMMFSparse() { ForceClose(); }
// Creates a sparse MMF and maps it in the process's address space.
BOOL Initialize(HANDLE hstream, SIZE_T dwStreamSizeMax);
// MMF to BYTE cast operator returns address of first byte
// in the memory-mapped sparse file.
operator PBYTE() const { return((PBYTE) m_pvFile); }
// Allows you to explicitly close the MMF without having
// to wait for the destructor to be called.
VOID ForceClose();
};
//////////////////////////////////////////////////////////////////////////////
CMMFSparse::CMMFSparse(HANDLE hstream, SIZE_T dwStreamSizeMax) {
Initialize(hstream, dwStreamSizeMax);
}
//////////////////////////////////////////////////////////////////////////////
BOOL CMMFSparse::Initialize(HANDLE hstream, SIZE_T dwStreamSizeMax) {
if (m_hfilemap != NULL)
ForceClose();
// Initialize to NULL in case something goes wrong
m_hfilemap = m_pvFile = NULL;
BOOL fOk = TRUE; // Assume success
if (hstream != NULL) {
if (dwStreamSizeMax == 0) {
DebugBreak(); // Illegal stream size
}
CSparseStream::Initialize(hstream);
fOk = MakeSparse(); // Make the stream sparse
if (fOk) {
// Create a file-mapping object
m_hfilemap = ::CreateFileMapping(hstream, NULL, PAGE_READWRITE,
(DWORD) (dwStreamSizeMax >> 32I64), (DWORD) dwStreamSizeMax, NULL);
if (m_hfilemap != NULL) {
// Map the stream into the process's address space
m_pvFile = ::MapViewOfFile(m_hfilemap,
FILE_MAP_WRITE | FILE_MAP_READ, 0, 0, 0);
} else {
// Failed to map the file, cleanup
CSparseStream::Initialize(NULL);
ForceClose();
fOk = FALSE;
}
}
}
return(fOk);
}
//////////////////////////////////////////////////////////////////////////////
VOID CMMFSparse::ForceClose() {
// Cleanup everything that was done sucessfully
if (m_pvFile != NULL) {
::UnmapViewOfFile(m_pvFile);
m_pvFile = NULL;
}
if (m_hfilemap != NULL) {
::CloseHandle(m_hfilemap);
m_hfilemap = NULL;
}
}
//////////////////////////////////////////////////////////////////////////////
#define STREAMSIZE (1 * 1024 * 1024) // 1 MB (1024 KB)
TCHAR szPathname[] = TEXT("C:\\MMFSparse.");
HANDLE g_hstream = INVALID_HANDLE_VALUE;
CMMFSparse g_mmf;
///////////////////////////////////////////////////////////////////////////////
BOOL Dlg_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam) {
chSETDLGICONS(hwnd, IDI_MMFSPARSE);
// Initialize the dialog box controls.
EnableWindow(GetDlgItem(hwnd, IDC_OFFSET), FALSE);
Edit_LimitText(GetDlgItem(hwnd, IDC_OFFSET), 4);
SetDlgItemInt(hwnd, IDC_OFFSET, 1000, FALSE);
EnableWindow(GetDlgItem(hwnd, IDC_BYTE), FALSE);
Edit_LimitText(GetDlgItem(hwnd, IDC_BYTE), 3);
SetDlgItemInt(hwnd, IDC_BYTE, 5, FALSE);
EnableWindow(GetDlgItem(hwnd, IDC_WRITEBYTE), FALSE);
EnableWindow(GetDlgItem(hwnd, IDC_READBYTE), FALSE);
EnableWindow(GetDlgItem(hwnd, IDC_FREEALLOCATEDREGIONS), FALSE);
return(TRUE);
}
///////////////////////////////////////////////////////////////////////////////
void Dlg_ShowAllocatedRanges(HWND hwnd) {
// Fill in the Allocated Ranges edit control
DWORD dwNumEntries;
FILE_ALLOCATED_RANGE_BUFFER* pfarb =
g_mmf.QueryAllocatedRanges(&dwNumEntries);
if (dwNumEntries == 0) {
SetDlgItemText(hwnd, IDC_FILESTATUS,
TEXT("No allocated ranges in the file"));
} else {
TCHAR sz[4096] = { 0 };
for (DWORD dwEntry = 0; dwEntry < dwNumEntries; dwEntry++) {
wsprintf(_tcschr(sz, 0), TEXT("Offset: %7.7u, Length: %7.7u\r\n"),
pfarb[dwEntry].FileOffset.LowPart, pfarb[dwEntry].Length.LowPart);
}
SetDlgItemText(hwnd, IDC_FILESTATUS, sz);
}
g_mmf.FreeAllocatedRanges(pfarb);
}
///////////////////////////////////////////////////////////////////////////////
void Dlg_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) {
switch (id) {
case IDCANCEL:
if (g_hstream != INVALID_HANDLE_VALUE)
CloseHandle(g_hstream);
EndDialog(hwnd, id);
break;
case IDC_CREATEMMF:
// Create the file
g_hstream = CreateFile(szPathname, GENERIC_READ | GENERIC_WRITE,
0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (g_hstream == INVALID_HANDLE_VALUE) {
chFAIL("Failed to create file.");
}
// Create a 1MB (1024 KB) MMF using the file
if (!g_mmf.Initialize(g_hstream, STREAMSIZE)) {
chFAIL("Failed to initialize Sparse MMF.");
}
Dlg_ShowAllocatedRanges(hwnd);
// Enable/disable the other controls.
EnableWindow(GetDlgItem(hwnd, IDC_CREATEMMF), FALSE);
EnableWindow(GetDlgItem(hwnd, IDC_OFFSET), TRUE);
EnableWindow(GetDlgItem(hwnd, IDC_BYTE), TRUE);
EnableWindow(GetDlgItem(hwnd, IDC_WRITEBYTE), TRUE);
EnableWindow(GetDlgItem(hwnd, IDC_READBYTE), TRUE);
EnableWindow(GetDlgItem(hwnd, IDC_FREEALLOCATEDREGIONS), TRUE);
// Force the Offset edit control to have the focus.
SetFocus(GetDlgItem(hwnd, IDC_OFFSET));
break;
case IDC_WRITEBYTE:
{
BOOL fTranslated;
DWORD dwOffset = GetDlgItemInt(hwnd, IDC_OFFSET, &fTranslated, FALSE);
if (fTranslated) {
g_mmf[dwOffset * 1024] = (BYTE)
GetDlgItemInt(hwnd, IDC_BYTE, NULL, FALSE);
Dlg_ShowAllocatedRanges(hwnd);
}
}
break;
case IDC_READBYTE:
{
BOOL fTranslated;
DWORD dwOffset = GetDlgItemInt(hwnd, IDC_OFFSET, &fTranslated, FALSE);
if (fTranslated) {
SetDlgItemInt(hwnd, IDC_BYTE, g_mmf[dwOffset * 1024], FALSE);
Dlg_ShowAllocatedRanges(hwnd);
}
}
break;
case IDC_FREEALLOCATEDREGIONS:
// Normally the destructor causes the file-mapping to close.
// But, in this case, we wish to force it so that we can reset
// a portion of the file back to all zeroes.
g_mmf.ForceClose();
// We call ForceClose above because attempting to zero a portion of
// the file while it is mapped, causes DeviceIoControl to fail with
// error ERROR_USER_MAPPED_FILE ("The requested operation cannot
// be performed on a file with a user-mapped section open.")
g_mmf.DecommitPortionOfStream(0, STREAMSIZE);
g_mmf.Initialize(g_hstream, STREAMSIZE);
Dlg_ShowAllocatedRanges(hwnd);
break;
}
}
///////////////////////////////////////////////////////////////////////////////
INT_PTR WINAPI Dlg_Proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
chHANDLE_DLGMSG(hwnd, WM_INITDIALOG, Dlg_OnInitDialog);
chHANDLE_DLGMSG(hwnd, WM_COMMAND, Dlg_OnCommand);
}
return(FALSE);
}
///////////////////////////////////////////////////////////////////////////////
int WINAPI _tWinMain(HINSTANCE hinstExe, HINSTANCE, PTSTR pszCmdLine, int) {
chWindows2000Required();
DialogBox(hinstExe, MAKEINTRESOURCE(IDD_MMFSPARSE), NULL, Dlg_Proc);
return(0);
}
//////////////////////////////// End of File //////////////////////////////////
| 31.445255 | 80 | 0.543988 | JimYang365 |
253595dff9926cc3c167493f95b92c4e424811a0 | 1,565 | cpp | C++ | treefunctions.cpp | waha99922/JuicyBros_TOOLBOX_V1.0 | ff59f3842e9a4bf1b40e18613f555b923cd9b949 | [
"MIT"
] | null | null | null | treefunctions.cpp | waha99922/JuicyBros_TOOLBOX_V1.0 | ff59f3842e9a4bf1b40e18613f555b923cd9b949 | [
"MIT"
] | null | null | null | treefunctions.cpp | waha99922/JuicyBros_TOOLBOX_V1.0 | ff59f3842e9a4bf1b40e18613f555b923cd9b949 | [
"MIT"
] | null | null | null | #include <iostream>
#include "Tree.h"
using namespace std;
Tree::Tree()
{
root = NULL;
}
void Tree::insert(double value)
{
Tnode* ptr = new Tnode(value);
Tnode* temp = root;
if (root == NULL)
{
root = ptr;
}
else
{
while (temp != NULL)
{
if (temp->data > value && temp->left == NULL)
{
temp->left = ptr;
break;
}
else if (temp->data < value && temp->right == NULL)
{
temp->right = ptr;
break;
}
else if (temp->data > value && temp->left != NULL)
{
temp = temp->left;
}
else if (temp->data < value && temp->right != NULL)
{
temp = temp->right;
}
}
}
}
Tnode* Tree::Inorder_print(Tnode* temp)
{
if (temp == NULL)
{
return NULL;
}
else
{
Inorder_print(temp->left);
cout << temp->data <<endl;
Inorder_print(temp->right);
}
}
Tnode* Tree::Postorder_print(Tnode* temp)
{
if (temp == NULL)
{
return NULL;
}
else
{
Postorder_print(temp->left);
Postorder_print(temp->right);
cout << temp->data <<endl;
}
}
Tnode* Tree::Preorder_print(Tnode* temp)
{
if (temp == NULL)
{
return NULL;
}
else
{
cout << temp->data <<endl;
Preorder_print(temp->left);
Postorder_print(temp->right);
}
}
Tnode* Tree::search(Tnode* temp,double key)
{
if (temp == NULL)
{
return NULL;
}
else if (temp->data == key)
{
return temp;
}
else if (key < temp->data)
{
search(temp->left, key);
}
else if (key>temp->data)
{
search(temp->right, key);
}
}
| 14.490741 | 55 | 0.532907 | waha99922 |
2536ba074888894f3711036500cd7a040eb22d84 | 4,865 | cpp | C++ | main.cpp | gnole/CG-HW3 | 9c0859bda43291d49a47b929352d6ba5da2bdae9 | [
"MIT"
] | null | null | null | main.cpp | gnole/CG-HW3 | 9c0859bda43291d49a47b929352d6ba5da2bdae9 | [
"MIT"
] | null | null | null | main.cpp | gnole/CG-HW3 | 9c0859bda43291d49a47b929352d6ba5da2bdae9 | [
"MIT"
] | null | null | null | #include <SFML/Graphics.hpp>
#include <unistd.h>
#include <cmath>
#include <iostream>
void drawLineRed(int x1, int y1, int x2, int y2, sf::RenderWindow &window) {
const int deltaX = abs(x2 - x1);
const int deltaY = abs(y2 - y1);
const int signX = x1 < x2 ? 1 : -1;
const int signY = y1 < y2 ? 1 : -1;
int error = deltaX - deltaY;
sf::Vertex point(sf::Vector2f(x2, y2), sf::Color::Red);
window.draw(&point, 1, sf::Points);
while (x1 != x2 || y1 != y2) {
sf::Vertex point1(sf::Vector2f(x1, y1), sf::Color::Red);
window.draw(&point1, 1, sf::Points);
int error2 = error * 2;
if (error2 > -deltaY) {
error -= deltaY;
x1 += signX;
}
if (error2 < deltaX) {
error += deltaX;
y1 += signY;
}
}
}
int dot(std::pair<int, int> p0, std::pair<int, int> p1) {
return p0.first * p1.first + p0.second * p1.second;
}
float max(std::vector<float> t) {
float maximum = -1000000;
for (int i = 0; i < t.size(); i++)
if (t[i] > maximum)
maximum = t[i];
return maximum;
}
float min(std::vector<float> t) {
float minimum = 1000000;
for (int i = 0; i < t.size(); i++)
if (t[i] < minimum)
minimum = t[i];
return minimum;
}
void cyrusBeck(std::vector<std::pair<int, int>> vertices,
std::vector<std::pair<int, int>> line, std::vector<std::pair<int, int>> &vec_line_cb) {
const int n = vertices.size();
std::pair<int, int> *newPair = new std::pair<int, int>[2];
std::pair<int, int> *normal = new std::pair<int, int>[n];
for (int i = 0; i < n; i++) {
normal[i].second = vertices[(i + 1) % n].first - vertices[i].first;
normal[i].first = vertices[i].second - vertices[(i + 1) % n].second;
}
std::pair<int, int> P1_P0 = std::make_pair(line[1].first - line[0].first,
line[1].second - line[0].second);
std::pair<int, int> *P0_PEi = new std::pair<int, int>[n];
for (int i = 0; i < n; i++) {
P0_PEi[i].first = vertices[i].first - line[0].first;
P0_PEi[i].second = vertices[i].second - line[0].second;
}
int *numerator = new int[n], *denominator = new int[n];
for (int i = 0; i < n; i++) {
numerator[i] = dot(normal[i], P0_PEi[i]);
denominator[i] = dot(normal[i], P1_P0);
}
float *t = new float[n];
std::vector<float> tE, tL;
for (int i = 0; i < n; i++) {
t[i] = (float)(numerator[i]) / (float)(denominator[i]);
if (denominator[i] > 0)
tE.push_back(t[i]);
else
tL.push_back(t[i]);
}
float temp[2];
tE.push_back(0.f);
temp[0] = max(tE);
tL.push_back(1.f);
temp[1] = min(tL);
if (temp[0] > temp[1]) {
newPair[0] = std::make_pair(-1, -1);
newPair[1] = std::make_pair(-1, -1);
vec_line_cb.push_back(std::make_pair(newPair[0].first, newPair[0].second));
vec_line_cb.push_back(std::make_pair(newPair[1].first, newPair[1].second));
} else {
newPair[0].first = (float)line[0].first + (float)P1_P0.first * (float)temp[0];
newPair[0].second = (float)line[0].second + (float)P1_P0.second * (float)temp[0];
newPair[1].first = (float)line[0].first + (float)P1_P0.first * (float)temp[1];
newPair[1].second = (float)line[0].second + (float)P1_P0.second * (float)temp[1];
}
vec_line_cb.push_back(std::make_pair(newPair[0].first, newPair[0].second));
vec_line_cb.push_back(std::make_pair(newPair[1].first, newPair[1].second));
}
int main() {
sf::RenderWindow window(sf::VideoMode(740, 680), "HW3");
window.setFramerateLimit(50);
std::vector<std::pair<int, int>> vec_points;
std::vector<std::pair<int, int>> vec_line;
std::vector<std::pair<int, int>> vec_line_cb;
bool dr = false;
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
switch (event.type) {
case sf::Event::Closed: {
window.close();
return 0;
}
case sf::Event::MouseButtonPressed: {
if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) {
if (dr) {
vec_line.insert(vec_line.begin(), 1, std::make_pair(event.mouseButton.x, event.mouseButton.y));
} else {
vec_points.push_back(std::make_pair(event.mouseButton.x, event.mouseButton.y));
}
}
if (sf::Mouse::isButtonPressed(sf::Mouse::Right)) {
dr = true;
auto itend = vec_points.begin();
vec_points.push_back(std::make_pair(itend->first, itend->second));
}
}
}
}
window.clear(sf::Color::White);
if (vec_points.size() >= 2) {
auto it0 = vec_points.begin();
auto it1 = vec_points.begin();
++it1;
for (; it1 != vec_points.end(); ++it0, ++it1) {
drawLineRed(it0->first, it0->second, it1->first, it1->second, window);
}
}
if (vec_line.size() >= 2) {
if (vec_line.size() % 2 == 0) {
cyrusBeck(vec_points, vec_line, vec_line_cb);
}
auto it0 = vec_line_cb.begin();
auto it1 = vec_line_cb.begin();
++it1;
for (int i = 0; it1 != vec_line_cb.end(); ++it1, ++it0, ++i) {
if (i % 2 == 0) {
drawLineRed(it0->first, it0->second, it1->first, it1->second, window);
}
}
}
window.display();
}
return 0;
}
| 29.131737 | 101 | 0.610277 | gnole |
2536d4a70dc875741c6131f4b37f41f5ebd314dd | 780 | cpp | C++ | Team01/Game/Project/SceneGame.cpp | OiCGame/GameJam03 | 535fff1e39a3c509c4104029bd40386c5d8b4a69 | [
"MIT"
] | null | null | null | Team01/Game/Project/SceneGame.cpp | OiCGame/GameJam03 | 535fff1e39a3c509c4104029bd40386c5d8b4a69 | [
"MIT"
] | null | null | null | Team01/Game/Project/SceneGame.cpp | OiCGame/GameJam03 | 535fff1e39a3c509c4104029bd40386c5d8b4a69 | [
"MIT"
] | 1 | 2021-02-01T02:48:17.000Z | 2021-02-01T02:48:17.000Z | #include "SceneGame.h"
CSceneGame::CSceneGame() {
}
CSceneGame::~CSceneGame() {
}
bool CSceneGame::Load() {
return false;
}
void CSceneGame::Initialize() {
m_Game.Initialize();
}
void CSceneGame::Update() {
FadeInOut();
if (m_bEndStart) { return; }
m_Game.Update();
// if (g_pInput->IsKeyPush(MOFKEY_F2)) {
if (m_Game.GetPhaseNo() == 2)
{
m_Alpha = 255;
}
// if (m_Game.IsAllPhaseEnd()) {
if (m_Game.BossDead()) {
m_bEndStart = true;
m_NextSceneNo = SCENENO_GAMECLEAR;
}
// if (g_pInput->IsKeyPush(MOFKEY_F3)) {
if (m_Game.IsPlayerDead()) {
m_bEndStart = true;
m_NextSceneNo = SCENENO_GAMEOVER;
}
}
void CSceneGame::Render() {
m_Game.Render();
RenderFade();
}
void CSceneGame::RenderDebug() {
}
void CSceneGame::Release() {
m_Game.Release();
} | 15.6 | 41 | 0.664103 | OiCGame |
2538fdd3e154e6fe6f933447ee849fa4d272cdfc | 18 | cpp | C++ | src/root/root.cpp | keithalewis/libfms | 8389d2d022af2a23764653f13addf989d6d9e7fe | [
"MIT"
] | null | null | null | src/root/root.cpp | keithalewis/libfms | 8389d2d022af2a23764653f13addf989d6d9e7fe | [
"MIT"
] | null | null | null | src/root/root.cpp | keithalewis/libfms | 8389d2d022af2a23764653f13addf989d6d9e7fe | [
"MIT"
] | null | null | null | #include "root.h"
| 9 | 17 | 0.666667 | keithalewis |
253a85ba64ff7c4ced3e3c7c26e811efead82d1f | 1,306 | hh | C++ | elements/local/autodpaint.hh | MacWR/Click-changed-for-ParaGraph | 18285e5da578fbb7285d10380836146e738dee6e | [
"Apache-2.0"
] | null | null | null | elements/local/autodpaint.hh | MacWR/Click-changed-for-ParaGraph | 18285e5da578fbb7285d10380836146e738dee6e | [
"Apache-2.0"
] | null | null | null | elements/local/autodpaint.hh | MacWR/Click-changed-for-ParaGraph | 18285e5da578fbb7285d10380836146e738dee6e | [
"Apache-2.0"
] | null | null | null | #ifndef CLICK_AUTODPAINT_HH
#define CLICK_AUTODPAINT_HH
#include <click/element.hh>
CLICK_DECLS
/*
=c
AutoDPaint(COLORANGE,OPERATIONCOLOR)
=s autoDpaint
sets packet two layers' autodpaint annotations
=d
The first layer Paint is to protect the consistency of the packet copys:
Sets each packet's first Paint annotation (default is startanno=8 )to STARTCOLOR, an integer 0-2^16-1, default is startcolor=0;
The second layer Paint is to mark the operation on the packert copys:
Set each packert's second Paint annotation ( default is startanno+1 ) to COLOR, an integer 250..254, default is color=0(operation: read);
The ANNO argument can specify any one-byte annotation.
=h color read/write
Get/set the color to autodpaint.
=a Paint, PaintTee */
class AutoDPaint : public Element { public:
AutoDPaint() CLICK_COLD;
const char *class_name() const { return "AutoDPaint"; }
const char *port_count() const { return PORTS_1_1; }
int configure(Vector<String> &, ErrorHandler *) CLICK_COLD;
bool can_live_reconfigure() const { return true; }
void add_handlers() CLICK_COLD;
Packet *simple_action(Packet *);
private:
uint16_t _startcolor;
uint16_t _nowcolor;
uint8_t _operationcolor;
int _colorange;
uint16_t _nowrange;
};
CLICK_ENDDECLS
#endif
| 24.185185 | 137 | 0.743492 | MacWR |
253ce622b9954c1ada6315da36f8d6ad38172cf0 | 388 | cpp | C++ | IOST14.cpp | aaryan0348/E-Lab-Object-Oriented-Programming | 29f3ca80dbf2268441b5b9e426415650a607195a | [
"MIT"
] | null | null | null | IOST14.cpp | aaryan0348/E-Lab-Object-Oriented-Programming | 29f3ca80dbf2268441b5b9e426415650a607195a | [
"MIT"
] | null | null | null | IOST14.cpp | aaryan0348/E-Lab-Object-Oriented-Programming | 29f3ca80dbf2268441b5b9e426415650a607195a | [
"MIT"
] | null | null | null | #include <iostream>
using namespace std;
int main()
{
float n;
float pi;
cin>>n;
int i=0;
int n1=n;
while(n>0)
{
pi=(float)22/7;
cout.precision(n);
cout<<pi;
while(i)
{
cout<<'*';
i--;
}
i=n1-n+1;
n--;
cout<<endl;
}
cout<<"3"<<endl<<"Fill Setting:*";
return 0;
}
void d(){
cout.fill('a');
cout.width(10);
} | 12.125 | 37 | 0.466495 | aaryan0348 |
2540014eae291b7d481e70e6939ec48afa99fdfb | 200,731 | inl | C++ | 2d_samples/pmj02_180.inl | st-ario/rayme | 315c57c23f4aa4934a8a80e84e3243acd3400808 | [
"MIT"
] | 1 | 2021-12-10T23:35:04.000Z | 2021-12-10T23:35:04.000Z | 2d_samples/pmj02_180.inl | st-ario/rayme | 315c57c23f4aa4934a8a80e84e3243acd3400808 | [
"MIT"
] | null | null | null | 2d_samples/pmj02_180.inl | st-ario/rayme | 315c57c23f4aa4934a8a80e84e3243acd3400808 | [
"MIT"
] | null | null | null | {std::array<float,2>{0.407800078f, 0.8442536f},
std::array<float,2>{0.587527096f, 0.23548229f},
std::array<float,2>{0.978728712f, 0.646827936f},
std::array<float,2>{0.130732656f, 0.300448418f},
std::array<float,2>{0.103660405f, 0.522768974f},
std::array<float,2>{0.782684922f, 0.481478781f},
std::array<float,2>{0.713951111f, 0.962670207f},
std::array<float,2>{0.30073148f, 0.00499550067f},
std::array<float,2>{0.340997994f, 0.709573328f},
std::array<float,2>{0.648365676f, 0.339554101f},
std::array<float,2>{0.820601285f, 0.807329476f},
std::array<float,2>{0.018924525f, 0.151460499f},
std::array<float,2>{0.247321576f, 0.877124131f},
std::array<float,2>{0.905929983f, 0.0813911036f},
std::array<float,2>{0.548345804f, 0.61819613f},
std::array<float,2>{0.456791341f, 0.432048112f},
std::array<float,2>{0.277148992f, 0.982685149f},
std::array<float,2>{0.743986547f, 0.0501060486f},
std::array<float,2>{0.757856607f, 0.535368085f},
std::array<float,2>{0.0630864277f, 0.44095251f},
std::array<float,2>{0.162640274f, 0.68412447f},
std::array<float,2>{0.967815936f, 0.25990811f},
std::array<float,2>{0.619917929f, 0.837838233f},
std::array<float,2>{0.393650919f, 0.188003272f},
std::array<float,2>{0.476973504f, 0.5719226f},
std::array<float,2>{0.531063199f, 0.381219268f},
std::array<float,2>{0.923539579f, 0.924037337f},
std::array<float,2>{0.191263899f, 0.0944396406f},
std::array<float,2>{0.0406171195f, 0.760097921f},
std::array<float,2>{0.868816078f, 0.172067776f},
std::array<float,2>{0.685444176f, 0.730339706f},
std::array<float,2>{0.372586936f, 0.344608366f},
std::array<float,2>{0.346662909f, 0.789863229f},
std::array<float,2>{0.669065595f, 0.134517998f},
std::array<float,2>{0.852965176f, 0.687735915f},
std::array<float,2>{0.0509867892f, 0.323053598f},
std::array<float,2>{0.215056375f, 0.595274866f},
std::array<float,2>{0.909260869f, 0.420297325f},
std::array<float,2>{0.506124198f, 0.902223229f},
std::array<float,2>{0.48880133f, 0.0654655099f},
std::array<float,2>{0.378038228f, 0.637833595f},
std::array<float,2>{0.608418703f, 0.283659577f},
std::array<float,2>{0.950592816f, 0.869384646f},
std::array<float,2>{0.179770336f, 0.222733393f},
std::array<float,2>{0.0919908658f, 0.949330807f},
std::array<float,2>{0.78020376f, 0.0236400198f},
std::array<float,2>{0.732879877f, 0.504261851f},
std::array<float,2>{0.260396898f, 0.489553899f},
std::array<float,2>{0.445002854f, 0.91425705f},
std::array<float,2>{0.54076916f, 0.11024221f},
std::array<float,2>{0.884152472f, 0.5799734f},
std::array<float,2>{0.222507253f, 0.395714849f},
std::array<float,2>{0.00965865608f, 0.739356577f},
std::array<float,2>{0.834269226f, 0.371792018f},
std::array<float,2>{0.637296796f, 0.775155663f},
std::array<float,2>{0.312705249f, 0.161678031f},
std::array<float,2>{0.284860462f, 0.554244876f},
std::array<float,2>{0.69564271f, 0.464865297f},
std::array<float,2>{0.804718673f, 0.99447161f},
std::array<float,2>{0.117304727f, 0.0337151326f},
std::array<float,2>{0.148720101f, 0.826953292f},
std::array<float,2>{0.990704f, 0.207547486f},
std::array<float,2>{0.567569375f, 0.667353034f},
std::array<float,2>{0.42272976f, 0.281058222f},
std::array<float,2>{0.49331224f, 0.77315557f},
std::array<float,2>{0.508405089f, 0.1653613f},
std::array<float,2>{0.914393485f, 0.742680132f},
std::array<float,2>{0.206856087f, 0.365188807f},
std::array<float,2>{0.054897882f, 0.587071419f},
std::array<float,2>{0.847211301f, 0.404284149f},
std::array<float,2>{0.663582563f, 0.911589146f},
std::array<float,2>{0.354949206f, 0.124640524f},
std::array<float,2>{0.256600976f, 0.662967324f},
std::array<float,2>{0.726482093f, 0.271277845f},
std::array<float,2>{0.765996695f, 0.814541519f},
std::array<float,2>{0.0816338062f, 0.217510566f},
std::array<float,2>{0.173378974f, 0.988176823f},
std::array<float,2>{0.941348612f, 0.0421277247f},
std::array<float,2>{0.599058151f, 0.562450945f},
std::array<float,2>{0.38435784f, 0.459767342f},
std::array<float,2>{0.323674768f, 0.895264328f},
std::array<float,2>{0.631596744f, 0.0706630498f},
std::array<float,2>{0.841234326f, 0.603139997f},
std::array<float,2>{0.00163358485f, 0.406949043f},
std::array<float,2>{0.227949619f, 0.697604775f},
std::array<float,2>{0.882083654f, 0.315044045f},
std::array<float,2>{0.53641504f, 0.783590555f},
std::array<float,2>{0.449078381f, 0.127173364f},
std::array<float,2>{0.433736444f, 0.514228582f},
std::array<float,2>{0.57316649f, 0.497259825f},
std::array<float,2>{0.997710943f, 0.939372659f},
std::array<float,2>{0.144460827f, 0.0183427017f},
std::array<float,2>{0.110407591f, 0.862124979f},
std::array<float,2>{0.799519837f, 0.232644349f},
std::array<float,2>{0.694805741f, 0.629477739f},
std::array<float,2>{0.290382296f, 0.290739834f},
std::array<float,2>{0.310096264f, 0.834093034f},
std::array<float,2>{0.70742619f, 0.201512501f},
std::array<float,2>{0.791399121f, 0.6784724f},
std::array<float,2>{0.0972860381f, 0.25335598f},
std::array<float,2>{0.139236212f, 0.542568684f},
std::array<float,2>{0.970144689f, 0.450458378f},
std::array<float,2>{0.580245674f, 0.973264396f},
std::array<float,2>{0.417151004f, 0.059310738f},
std::array<float,2>{0.466592312f, 0.719223619f},
std::array<float,2>{0.556581616f, 0.356821895f},
std::array<float,2>{0.895227373f, 0.75231415f},
std::array<float,2>{0.234469935f, 0.18720001f},
std::array<float,2>{0.025924528f, 0.936584175f},
std::array<float,2>{0.815787315f, 0.108674511f},
std::array<float,2>{0.653830111f, 0.565007627f},
std::array<float,2>{0.328151435f, 0.388601631f},
std::array<float,2>{0.40212363f, 0.957877576f},
std::array<float,2>{0.610874712f, 0.00954037812f},
std::array<float,2>{0.953150094f, 0.524623334f},
std::array<float,2>{0.164949998f, 0.475803316f},
std::array<float,2>{0.0756694227f, 0.651290834f},
std::array<float,2>{0.757591903f, 0.306503564f},
std::array<float,2>{0.74129349f, 0.854687214f},
std::array<float,2>{0.270782471f, 0.249976739f},
std::array<float,2>{0.363641679f, 0.614321113f},
std::array<float,2>{0.671944261f, 0.424458712f},
std::array<float,2>{0.861762941f, 0.885710657f},
std::array<float,2>{0.0333211236f, 0.0891774967f},
std::array<float,2>{0.20086661f, 0.799280822f},
std::array<float,2>{0.937116027f, 0.142556131f},
std::array<float,2>{0.522614956f, 0.712271154f},
std::array<float,2>{0.470711589f, 0.333427578f},
std::array<float,2>{0.388623744f, 0.812211156f},
std::array<float,2>{0.594500422f, 0.15287149f},
std::array<float,2>{0.942827761f, 0.706393301f},
std::array<float,2>{0.176652983f, 0.342898756f},
std::array<float,2>{0.0826201364f, 0.624080956f},
std::array<float,2>{0.772027135f, 0.436022013f},
std::array<float,2>{0.719068646f, 0.879550219f},
std::array<float,2>{0.252090663f, 0.0858609527f},
std::array<float,2>{0.357299477f, 0.642480254f},
std::array<float,2>{0.657624066f, 0.304558963f},
std::array<float,2>{0.848836362f, 0.850528717f},
std::array<float,2>{0.0611987561f, 0.241425619f},
std::array<float,2>{0.208286315f, 0.967661738f},
std::array<float,2>{0.92110914f, 0.00182187103f},
std::array<float,2>{0.513671815f, 0.518064857f},
std::array<float,2>{0.49717018f, 0.479422539f},
std::array<float,2>{0.294903666f, 0.928037763f},
std::array<float,2>{0.690481901f, 0.0981527194f},
std::array<float,2>{0.801632762f, 0.576050162f},
std::array<float,2>{0.114739195f, 0.377047062f},
std::array<float,2>{0.146478072f, 0.73282963f},
std::array<float,2>{0.996013701f, 0.34807539f},
std::array<float,2>{0.576001108f, 0.762289166f},
std::array<float,2>{0.433488071f, 0.178781077f},
std::array<float,2>{0.449219137f, 0.532912254f},
std::array<float,2>{0.533353984f, 0.441479385f},
std::array<float,2>{0.878864169f, 0.976987422f},
std::array<float,2>{0.233585164f, 0.0512894504f},
std::array<float,2>{0.00665393565f, 0.840637386f},
std::array<float,2>{0.838939846f, 0.191796377f},
std::array<float,2>{0.626270533f, 0.680124104f},
std::array<float,2>{0.327953875f, 0.264478862f},
std::array<float,2>{0.333593756f, 0.871495247f},
std::array<float,2>{0.648543477f, 0.218937173f},
std::array<float,2>{0.817587376f, 0.636083603f},
std::array<float,2>{0.0294836741f, 0.288520604f},
std::array<float,2>{0.240476608f, 0.500685334f},
std::array<float,2>{0.893328726f, 0.48801285f},
std::array<float,2>{0.561872005f, 0.948143542f},
std::array<float,2>{0.461407006f, 0.0290995762f},
std::array<float,2>{0.420626223f, 0.691942036f},
std::array<float,2>{0.583666682f, 0.32808277f},
std::array<float,2>{0.975660086f, 0.796263754f},
std::array<float,2>{0.135991469f, 0.14061299f},
std::array<float,2>{0.100726105f, 0.905622959f},
std::array<float,2>{0.796414614f, 0.0698261335f},
std::array<float,2>{0.70628202f, 0.599173486f},
std::array<float,2>{0.306217939f, 0.415550143f},
std::array<float,2>{0.47600463f, 0.998870194f},
std::array<float,2>{0.516188204f, 0.0353293344f},
std::array<float,2>{0.932674825f, 0.549348891f},
std::array<float,2>{0.198199302f, 0.461116254f},
std::array<float,2>{0.0376486517f, 0.671339035f},
std::array<float,2>{0.864086986f, 0.275141418f},
std::array<float,2>{0.677708209f, 0.82406503f},
std::array<float,2>{0.36273697f, 0.204850554f},
std::array<float,2>{0.267366916f, 0.583033502f},
std::array<float,2>{0.735691011f, 0.391706198f},
std::array<float,2>{0.752574503f, 0.92045176f},
std::array<float,2>{0.0722872168f, 0.115434937f},
std::array<float,2>{0.168665215f, 0.780546784f},
std::array<float,2>{0.957067549f, 0.159333989f},
std::array<float,2>{0.614732146f, 0.734807014f},
std::array<float,2>{0.405130297f, 0.370120108f},
std::array<float,2>{0.457224429f, 0.817982376f},
std::array<float,2>{0.552010417f, 0.212290391f},
std::array<float,2>{0.900605857f, 0.658466458f},
std::array<float,2>{0.244201586f, 0.268995106f},
std::array<float,2>{0.0221697409f, 0.557135999f},
std::array<float,2>{0.82716471f, 0.456625611f},
std::array<float,2>{0.643815041f, 0.988455474f},
std::array<float,2>{0.336760014f, 0.0442448184f},
std::array<float,2>{0.30262661f, 0.747653723f},
std::array<float,2>{0.715126157f, 0.361557931f},
std::array<float,2>{0.788158417f, 0.767303407f},
std::array<float,2>{0.107898936f, 0.169469029f},
std::array<float,2>{0.128565311f, 0.908115089f},
std::array<float,2>{0.980905652f, 0.120990574f},
std::array<float,2>{0.593687594f, 0.591980577f},
std::array<float,2>{0.41259262f, 0.400172234f},
std::array<float,2>{0.370026022f, 0.941775084f},
std::array<float,2>{0.680722654f, 0.0196406413f},
std::array<float,2>{0.874131262f, 0.508871913f},
std::array<float,2>{0.0440699011f, 0.494355112f},
std::array<float,2>{0.19265607f, 0.62503469f},
std::array<float,2>{0.926576257f, 0.294730186f},
std::array<float,2>{0.526447475f, 0.865051866f},
std::array<float,2>{0.481470257f, 0.23011978f},
std::array<float,2>{0.398376912f, 0.607328475f},
std::array<float,2>{0.621509016f, 0.41038543f},
std::array<float,2>{0.961684406f, 0.892019808f},
std::array<float,2>{0.158998922f, 0.0745794326f},
std::array<float,2>{0.0666533113f, 0.786859274f},
std::array<float,2>{0.764476836f, 0.13115485f},
std::array<float,2>{0.746237934f, 0.70230335f},
std::array<float,2>{0.279104769f, 0.317477107f},
std::array<float,2>{0.26199457f, 0.75700599f},
std::array<float,2>{0.729268909f, 0.180913851f},
std::array<float,2>{0.775640368f, 0.725953639f},
std::array<float,2>{0.0885100886f, 0.352957755f},
std::array<float,2>{0.184136584f, 0.567822278f},
std::array<float,2>{0.946556151f, 0.385947883f},
std::array<float,2>{0.601894855f, 0.93338871f},
std::array<float,2>{0.379741549f, 0.104967512f},
std::array<float,2>{0.486559421f, 0.673461676f},
std::array<float,2>{0.50235188f, 0.255850315f},
std::array<float,2>{0.911413252f, 0.831084311f},
std::array<float,2>{0.214753106f, 0.198372915f},
std::array<float,2>{0.0477297679f, 0.971329689f},
std::array<float,2>{0.855946898f, 0.057430502f},
std::array<float,2>{0.667217255f, 0.546526074f},
std::array<float,2>{0.350905031f, 0.447329879f},
std::array<float,2>{0.425847024f, 0.890043318f},
std::array<float,2>{0.565899849f, 0.0931400359f},
std::array<float,2>{0.987779438f, 0.610598147f},
std::array<float,2>{0.15334034f, 0.428494334f},
std::array<float,2>{0.121543474f, 0.717390954f},
std::array<float,2>{0.811366141f, 0.331563771f},
std::array<float,2>{0.699797571f, 0.801396489f},
std::array<float,2>{0.287676424f, 0.145555481f},
std::array<float,2>{0.319651484f, 0.530496657f},
std::array<float,2>{0.636328042f, 0.471472651f},
std::array<float,2>{0.829169333f, 0.954607129f},
std::array<float,2>{0.0131604057f, 0.0139937364f},
std::array<float,2>{0.225607395f, 0.857046247f},
std::array<float,2>{0.888626575f, 0.245189324f},
std::array<float,2>{0.544569075f, 0.654186547f},
std::array<float,2>{0.437935233f, 0.311698079f},
std::array<float,2>{0.39214474f, 0.839653254f},
std::array<float,2>{0.618335426f, 0.191159308f},
std::array<float,2>{0.966076553f, 0.686898708f},
std::array<float,2>{0.160930097f, 0.259198308f},
std::array<float,2>{0.0650830716f, 0.537700951f},
std::array<float,2>{0.760437727f, 0.438577086f},
std::array<float,2>{0.744758725f, 0.981775403f},
std::array<float,2>{0.273723453f, 0.0476011299f},
std::array<float,2>{0.374456614f, 0.727907181f},
std::array<float,2>{0.686308622f, 0.345900267f},
std::array<float,2>{0.869488478f, 0.758589745f},
std::array<float,2>{0.041853413f, 0.174592376f},
std::array<float,2>{0.188433394f, 0.92213279f},
std::array<float,2>{0.924613476f, 0.095964618f},
std::array<float,2>{0.529154301f, 0.573418677f},
std::array<float,2>{0.47916761f, 0.380441248f},
std::array<float,2>{0.297846705f, 0.96310854f},
std::array<float,2>{0.71203506f, 0.00652603153f},
std::array<float,2>{0.784033f, 0.520200968f},
std::array<float,2>{0.10276103f, 0.484083772f},
std::array<float,2>{0.131277591f, 0.645650327f},
std::array<float,2>{0.978118181f, 0.298546523f},
std::array<float,2>{0.589101374f, 0.847303033f},
std::array<float,2>{0.409638077f, 0.237477913f},
std::array<float,2>{0.454192549f, 0.620211184f},
std::array<float,2>{0.549742162f, 0.43054077f},
std::array<float,2>{0.902784348f, 0.875646591f},
std::array<float,2>{0.249286845f, 0.0784615055f},
std::array<float,2>{0.0169686191f, 0.806392491f},
std::array<float,2>{0.823862433f, 0.148619682f},
std::array<float,2>{0.646289229f, 0.707868695f},
std::array<float,2>{0.342205524f, 0.337391883f},
std::array<float,2>{0.315231621f, 0.776924908f},
std::array<float,2>{0.639747798f, 0.162384361f},
std::array<float,2>{0.833170116f, 0.741469502f},
std::array<float,2>{0.0109010097f, 0.374350637f},
std::array<float,2>{0.219952822f, 0.581498027f},
std::array<float,2>{0.884854734f, 0.398058474f},
std::array<float,2>{0.541159809f, 0.917203605f},
std::array<float,2>{0.44165957f, 0.111978024f},
std::array<float,2>{0.425078541f, 0.665395021f},
std::array<float,2>{0.570168078f, 0.277795851f},
std::array<float,2>{0.990105629f, 0.825835466f},
std::array<float,2>{0.151464283f, 0.210772812f},
std::array<float,2>{0.119205862f, 0.993170321f},
std::array<float,2>{0.80824244f, 0.0319462791f},
std::array<float,2>{0.697387338f, 0.5517537f},
std::array<float,2>{0.281361759f, 0.467261165f},
std::array<float,2>{0.491174787f, 0.900075853f},
std::array<float,2>{0.504326582f, 0.06432724f},
std::array<float,2>{0.907155395f, 0.596960008f},
std::array<float,2>{0.217191711f, 0.41828841f},
std::array<float,2>{0.0530938096f, 0.689706624f},
std::array<float,2>{0.85476613f, 0.32189849f},
std::array<float,2>{0.671329916f, 0.792057216f},
std::array<float,2>{0.344777822f, 0.135309562f},
std::array<float,2>{0.258722007f, 0.506961823f},
std::array<float,2>{0.730477273f, 0.491352886f},
std::array<float,2>{0.77793628f, 0.952292621f},
std::array<float,2>{0.0913099721f, 0.0273388624f},
std::array<float,2>{0.182279229f, 0.868515432f},
std::array<float,2>{0.952219188f, 0.225858644f},
std::array<float,2>{0.605646968f, 0.639111698f},
std::array<float,2>{0.375875086f, 0.282675385f},
std::array<float,2>{0.445404589f, 0.781529486f},
std::array<float,2>{0.538246989f, 0.1264759f},
std::array<float,2>{0.880136192f, 0.697002411f},
std::array<float,2>{0.228771269f, 0.313969582f},
std::array<float,2>{0.00351237855f, 0.604052246f},
std::array<float,2>{0.84204495f, 0.408901244f},
std::array<float,2>{0.630729795f, 0.897060633f},
std::array<float,2>{0.321703434f, 0.0739533752f},
std::array<float,2>{0.291474074f, 0.632784128f},
std::array<float,2>{0.691957355f, 0.291982383f},
std::array<float,2>{0.797536612f, 0.860208631f},
std::array<float,2>{0.111967944f, 0.231501773f},
std::array<float,2>{0.14119415f, 0.940890551f},
std::array<float,2>{0.999885261f, 0.016818149f},
std::array<float,2>{0.571309745f, 0.51296401f},
std::array<float,2>{0.436867148f, 0.499112517f},
std::array<float,2>{0.353077561f, 0.912769496f},
std::array<float,2>{0.660629272f, 0.12277998f},
std::array<float,2>{0.844532609f, 0.588145912f},
std::array<float,2>{0.0577432141f, 0.404488564f},
std::array<float,2>{0.203638941f, 0.745908856f},
std::array<float,2>{0.917910814f, 0.365257829f},
std::array<float,2>{0.509824693f, 0.770660162f},
std::array<float,2>{0.494715363f, 0.167087689f},
std::array<float,2>{0.38607648f, 0.560364246f},
std::array<float,2>{0.600943089f, 0.457492501f},
std::array<float,2>{0.938341141f, 0.986161768f},
std::array<float,2>{0.174110338f, 0.03928826f},
std::array<float,2>{0.0785425678f, 0.813009799f},
std::array<float,2>{0.767648339f, 0.216300324f},
std::array<float,2>{0.723633349f, 0.661445677f},
std::array<float,2>{0.254109144f, 0.27322191f},
std::array<float,2>{0.272639006f, 0.853186011f},
std::array<float,2>{0.739504397f, 0.24658379f},
std::array<float,2>{0.754607141f, 0.648792922f},
std::array<float,2>{0.0764547735f, 0.307633311f},
std::array<float,2>{0.166501865f, 0.525849998f},
std::array<float,2>{0.955955684f, 0.473437935f},
std::array<float,2>{0.611508846f, 0.960688055f},
std::array<float,2>{0.39849925f, 0.0110436622f},
std::array<float,2>{0.470601052f, 0.713797033f},
std::array<float,2>{0.520832181f, 0.335666627f},
std::array<float,2>{0.933807135f, 0.797804058f},
std::array<float,2>{0.201264814f, 0.144331768f},
std::array<float,2>{0.0328588635f, 0.883463562f},
std::array<float,2>{0.861020923f, 0.0878087804f},
std::array<float,2>{0.675451458f, 0.615429759f},
std::array<float,2>{0.366024435f, 0.42353031f},
std::array<float,2>{0.415228248f, 0.974789023f},
std::array<float,2>{0.579960048f, 0.0605898872f},
std::array<float,2>{0.971613467f, 0.540011108f},
std::array<float,2>{0.137899518f, 0.451973766f},
std::array<float,2>{0.0953332856f, 0.675859809f},
std::array<float,2>{0.789370656f, 0.250897408f},
std::array<float,2>{0.709659755f, 0.833530605f},
std::array<float,2>{0.31154865f, 0.199481249f},
std::array<float,2>{0.330471218f, 0.563907802f},
std::array<float,2>{0.655210733f, 0.389783412f},
std::array<float,2>{0.813119292f, 0.934480965f},
std::array<float,2>{0.0248409901f, 0.106917977f},
std::array<float,2>{0.238140345f, 0.750756979f},
std::array<float,2>{0.898065567f, 0.183640629f},
std::array<float,2>{0.557583332f, 0.720808864f},
std::array<float,2>{0.468466222f, 0.357581168f},
std::array<float,2>{0.430905491f, 0.765448213f},
std::array<float,2>{0.577270508f, 0.176731616f},
std::array<float,2>{0.992563665f, 0.731974721f},
std::array<float,2>{0.147867993f, 0.351103067f},
std::array<float,2>{0.115861207f, 0.577195525f},
std::array<float,2>{0.80364424f, 0.375787735f},
std::array<float,2>{0.68773663f, 0.92656517f},
std::array<float,2>{0.295378029f, 0.101396635f},
std::array<float,2>{0.32509473f, 0.683481514f},
std::array<float,2>{0.627925873f, 0.263487279f},
std::array<float,2>{0.835987747f, 0.842866421f},
std::array<float,2>{0.00517386151f, 0.194847926f},
std::array<float,2>{0.232182413f, 0.979006529f},
std::array<float,2>{0.876427412f, 0.0531123169f},
std::array<float,2>{0.532134235f, 0.534440517f},
std::array<float,2>{0.452620506f, 0.444689512f},
std::array<float,2>{0.251265764f, 0.882345796f},
std::array<float,2>{0.722341955f, 0.0822830945f},
std::array<float,2>{0.770029426f, 0.621996701f},
std::array<float,2>{0.0855053812f, 0.433835208f},
std::array<float,2>{0.179474682f, 0.7044487f},
std::array<float,2>{0.943846822f, 0.341133028f},
std::array<float,2>{0.596171558f, 0.809433043f},
std::array<float,2>{0.388905346f, 0.155820951f},
std::array<float,2>{0.49941203f, 0.516616166f},
std::array<float,2>{0.514285088f, 0.476798654f},
std::array<float,2>{0.919676006f, 0.965253651f},
std::array<float,2>{0.210526913f, 0.00233853213f},
std::array<float,2>{0.0587263219f, 0.848745763f},
std::array<float,2>{0.851372361f, 0.239263117f},
std::array<float,2>{0.659098685f, 0.643137634f},
std::array<float,2>{0.359024376f, 0.300859272f},
std::array<float,2>{0.361200035f, 0.821722746f},
std::array<float,2>{0.678126097f, 0.205832973f},
std::array<float,2>{0.866943777f, 0.668590486f},
std::array<float,2>{0.0360662341f, 0.275914341f},
std::array<float,2>{0.195727512f, 0.548553765f},
std::array<float,2>{0.930145204f, 0.462957323f},
std::array<float,2>{0.518704295f, 0.997960448f},
std::array<float,2>{0.473420173f, 0.0387429297f},
std::array<float,2>{0.403534442f, 0.737801433f},
std::array<float,2>{0.615316033f, 0.369112462f},
std::array<float,2>{0.959219456f, 0.777662694f},
std::array<float,2>{0.170337498f, 0.158167362f},
std::array<float,2>{0.0720550716f, 0.918954432f},
std::array<float,2>{0.750513911f, 0.114521116f},
std::array<float,2>{0.736694872f, 0.584249556f},
std::array<float,2>{0.26795125f, 0.394394636f},
std::array<float,2>{0.46346879f, 0.946514845f},
std::array<float,2>{0.558665276f, 0.0312227216f},
std::array<float,2>{0.891808748f, 0.50200516f},
std::array<float,2>{0.238801822f, 0.484907538f},
std::array<float,2>{0.0278833583f, 0.633889019f},
std::array<float,2>{0.818944156f, 0.28541857f},
std::array<float,2>{0.650577664f, 0.874738693f},
std::array<float,2>{0.335067898f, 0.221357748f},
std::array<float,2>{0.308271408f, 0.59967196f},
std::array<float,2>{0.704034269f, 0.416461587f},
std::array<float,2>{0.793772876f, 0.903361857f},
std::array<float,2>{0.0979364812f, 0.0678821802f},
std::array<float,2>{0.133110151f, 0.793952525f},
std::array<float,2>{0.97360152f, 0.137770861f},
std::array<float,2>{0.585564792f, 0.693700552f},
std::array<float,2>{0.419803143f, 0.324950069f},
std::array<float,2>{0.483108222f, 0.865911782f},
std::array<float,2>{0.523747623f, 0.226751938f},
std::array<float,2>{0.929680824f, 0.628245294f},
std::array<float,2>{0.194428846f, 0.295606941f},
std::array<float,2>{0.0465325862f, 0.510032058f},
std::array<float,2>{0.872163355f, 0.493478417f},
std::array<float,2>{0.682685316f, 0.945297837f},
std::array<float,2>{0.368669152f, 0.0224835165f},
std::array<float,2>{0.280736566f, 0.700398207f},
std::array<float,2>{0.749181747f, 0.319896191f},
std::array<float,2>{0.762358367f, 0.788493335f},
std::array<float,2>{0.0684948266f, 0.130726665f},
std::array<float,2>{0.15652056f, 0.894476831f},
std::array<float,2>{0.963696182f, 0.0772592872f},
std::array<float,2>{0.624921024f, 0.608892918f},
std::array<float,2>{0.395222336f, 0.413482219f},
std::array<float,2>{0.339586556f, 0.991027355f},
std::array<float,2>{0.642169297f, 0.0454329811f},
std::array<float,2>{0.824472785f, 0.556195617f},
std::array<float,2>{0.0209426042f, 0.454979181f},
std::array<float,2>{0.243461072f, 0.656735778f},
std::array<float,2>{0.899548411f, 0.267387092f},
std::array<float,2>{0.554203153f, 0.819984972f},
std::array<float,2>{0.459265471f, 0.214704335f},
std::array<float,2>{0.411329597f, 0.590845764f},
std::array<float,2>{0.590169489f, 0.401060343f},
std::array<float,2>{0.983068347f, 0.908992529f},
std::array<float,2>{0.125382155f, 0.118383616f},
std::array<float,2>{0.107131861f, 0.768579841f},
std::array<float,2>{0.785319686f, 0.170786366f},
std::array<float,2>{0.716955781f, 0.749455512f},
std::array<float,2>{0.303002685f, 0.361108392f},
std::array<float,2>{0.286008298f, 0.803569257f},
std::array<float,2>{0.702156246f, 0.147713408f},
std::array<float,2>{0.809389651f, 0.716467679f},
std::array<float,2>{0.123463891f, 0.329362005f},
std::array<float,2>{0.156219363f, 0.611963391f},
std::array<float,2>{0.985434592f, 0.427625269f},
std::array<float,2>{0.564112067f, 0.888247311f},
std::array<float,2>{0.429311663f, 0.0916610658f},
std::array<float,2>{0.440047115f, 0.654954672f},
std::array<float,2>{0.545056999f, 0.310478568f},
std::array<float,2>{0.889341295f, 0.858947515f},
std::array<float,2>{0.223955408f, 0.243080422f},
std::array<float,2>{0.0147097073f, 0.956411362f},
std::array<float,2>{0.831688523f, 0.0130475787f},
std::array<float,2>{0.633896351f, 0.527444959f},
std::array<float,2>{0.316465527f, 0.469010949f},
std::array<float,2>{0.382679313f, 0.930815578f},
std::array<float,2>{0.605376482f, 0.102565587f},
std::array<float,2>{0.948376238f, 0.568876565f},
std::array<float,2>{0.187056631f, 0.384312034f},
std::array<float,2>{0.0876016542f, 0.722934186f},
std::array<float,2>{0.77419591f, 0.354108214f},
std::array<float,2>{0.726570308f, 0.755042791f},
std::array<float,2>{0.26454249f, 0.18279773f},
std::array<float,2>{0.348626792f, 0.543819487f},
std::array<float,2>{0.664188921f, 0.445757776f},
std::array<float,2>{0.857609153f, 0.97066313f},
std::array<float,2>{0.0506838895f, 0.0564820096f},
std::array<float,2>{0.212611273f, 0.828845441f},
std::array<float,2>{0.913470507f, 0.196137995f},
std::array<float,2>{0.500569224f, 0.674351037f},
std::array<float,2>{0.484903544f, 0.256354392f},
std::array<float,2>{0.376459539f, 0.870499015f},
std::array<float,2>{0.607164085f, 0.224390805f},
std::array<float,2>{0.952095628f, 0.637283921f},
std::array<float,2>{0.182621986f, 0.284826636f},
std::array<float,2>{0.0902179256f, 0.504964769f},
std::array<float,2>{0.77900821f, 0.488304257f},
std::array<float,2>{0.731606126f, 0.950235069f},
std::array<float,2>{0.259710371f, 0.0250334367f},
std::array<float,2>{0.344691813f, 0.688612938f},
std::array<float,2>{0.670178771f, 0.323929697f},
std::array<float,2>{0.853683412f, 0.790087104f},
std::array<float,2>{0.0546334051f, 0.133054763f},
std::array<float,2>{0.218740776f, 0.90112406f},
std::array<float,2>{0.907901049f, 0.0650304556f},
std::array<float,2>{0.505827487f, 0.59418124f},
std::array<float,2>{0.491839677f, 0.421582669f},
std::array<float,2>{0.28226614f, 0.995607376f},
std::array<float,2>{0.698809326f, 0.0345584527f},
std::array<float,2>{0.807386398f, 0.55290693f},
std::array<float,2>{0.120490715f, 0.466003388f},
std::array<float,2>{0.150694445f, 0.666873991f},
std::array<float,2>{0.988608003f, 0.279513985f},
std::array<float,2>{0.568589032f, 0.827696323f},
std::array<float,2>{0.423949659f, 0.208357364f},
std::array<float,2>{0.442815781f, 0.57909286f},
std::array<float,2>{0.542569816f, 0.394723088f},
std::array<float,2>{0.886312544f, 0.915612876f},
std::array<float,2>{0.218952641f, 0.11088632f},
std::array<float,2>{0.00989048835f, 0.774101913f},
std::array<float,2>{0.832580566f, 0.160498753f},
std::array<float,2>{0.639636815f, 0.739238262f},
std::array<float,2>{0.316321254f, 0.372581959f},
std::array<float,2>{0.3435013f, 0.808181286f},
std::array<float,2>{0.644578695f, 0.151331261f},
std::array<float,2>{0.822710037f, 0.709987283f},
std::array<float,2>{0.0160662606f, 0.338420063f},
std::array<float,2>{0.248915061f, 0.618043423f},
std::array<float,2>{0.903545499f, 0.432664007f},
std::array<float,2>{0.550261259f, 0.878105462f},
std::array<float,2>{0.453282386f, 0.080662027f},
std::array<float,2>{0.408750236f, 0.648035944f},
std::array<float,2>{0.588666558f, 0.298881143f},
std::array<float,2>{0.977033079f, 0.844861865f},
std::array<float,2>{0.132707208f, 0.234413043f},
std::array<float,2>{0.101574905f, 0.961701512f},
std::array<float,2>{0.784790516f, 0.00421790034f},
std::array<float,2>{0.711446404f, 0.52232635f},
std::array<float,2>{0.297994524f, 0.480702877f},
std::array<float,2>{0.479888201f, 0.92501682f},
std::array<float,2>{0.528006434f, 0.0954090804f},
std::array<float,2>{0.925130725f, 0.570543647f},
std::array<float,2>{0.189114705f, 0.382377386f},
std::array<float,2>{0.0423936322f, 0.728835762f},
std::array<float,2>{0.871021926f, 0.345499039f},
std::array<float,2>{0.687429428f, 0.760900497f},
std::array<float,2>{0.373556674f, 0.173598468f},
std::array<float,2>{0.275066525f, 0.536201596f},
std::array<float,2>{0.745346904f, 0.439867288f},
std::array<float,2>{0.761407793f, 0.983957589f},
std::array<float,2>{0.0656989068f, 0.0493787155f},
std::array<float,2>{0.161449969f, 0.836049259f},
std::array<float,2>{0.965679348f, 0.189048722f},
std::array<float,2>{0.617403865f, 0.685312212f},
std::array<float,2>{0.391496897f, 0.261234999f},
std::array<float,2>{0.467300534f, 0.75330925f},
std::array<float,2>{0.557764292f, 0.186118051f},
std::array<float,2>{0.897328794f, 0.719989479f},
std::array<float,2>{0.236956045f, 0.356038988f},
std::array<float,2>{0.0235385634f, 0.565487146f},
std::array<float,2>{0.813557863f, 0.387227327f},
std::array<float,2>{0.655467629f, 0.935987532f},
std::array<float,2>{0.331843883f, 0.107720755f},
std::array<float,2>{0.311129004f, 0.678910792f},
std::array<float,2>{0.710621059f, 0.252783537f},
std::array<float,2>{0.790814996f, 0.835925281f},
std::array<float,2>{0.094620578f, 0.203106955f},
std::array<float,2>{0.137295321f, 0.97423929f},
std::array<float,2>{0.972596288f, 0.0601938553f},
std::array<float,2>{0.57903707f, 0.54172045f},
std::array<float,2>{0.414721668f, 0.449500263f},
std::array<float,2>{0.366809279f, 0.885893762f},
std::array<float,2>{0.674702823f, 0.0885955691f},
std::array<float,2>{0.860233068f, 0.613550067f},
std::array<float,2>{0.0312910043f, 0.425566196f},
std::array<float,2>{0.202985033f, 0.711746275f},
std::array<float,2>{0.934612572f, 0.332081437f},
std::array<float,2>{0.520301282f, 0.800258517f},
std::array<float,2>{0.469712973f, 0.141132846f},
std::array<float,2>{0.399699062f, 0.52429682f},
std::array<float,2>{0.612982929f, 0.47521618f},
std::array<float,2>{0.956517816f, 0.958076537f},
std::array<float,2>{0.167156205f, 0.00850879867f},
std::array<float,2>{0.0774962306f, 0.854030788f},
std::array<float,2>{0.755422413f, 0.248809159f},
std::array<float,2>{0.738822579f, 0.651418328f},
std::array<float,2>{0.271925956f, 0.304934502f},
std::array<float,2>{0.255490571f, 0.816147149f},
std::array<float,2>{0.723543167f, 0.218168363f},
std::array<float,2>{0.76913923f, 0.664053202f},
std::array<float,2>{0.0794734433f, 0.269759893f},
std::array<float,2>{0.17531839f, 0.560569048f},
std::array<float,2>{0.938538432f, 0.460465014f},
std::array<float,2>{0.599831223f, 0.986390531f},
std::array<float,2>{0.385582596f, 0.0410644636f},
std::array<float,2>{0.495855033f, 0.744065225f},
std::array<float,2>{0.51141125f, 0.363902956f},
std::array<float,2>{0.916514993f, 0.771777272f},
std::array<float,2>{0.20460549f, 0.164634943f},
std::array<float,2>{0.0567004979f, 0.910267174f},
std::array<float,2>{0.845273077f, 0.123851426f},
std::array<float,2>{0.661600947f, 0.586175859f},
std::array<float,2>{0.351780057f, 0.402463019f},
std::array<float,2>{0.436403453f, 0.93843776f},
std::array<float,2>{0.570840478f, 0.0189837012f},
std::array<float,2>{0.9985376f, 0.515240073f},
std::array<float,2>{0.141820237f, 0.49670884f},
std::array<float,2>{0.112319827f, 0.62989527f},
std::array<float,2>{0.798111975f, 0.289840937f},
std::array<float,2>{0.692741215f, 0.863097906f},
std::array<float,2>{0.292010695f, 0.233917177f},
std::array<float,2>{0.32042405f, 0.601844788f},
std::array<float,2>{0.629326642f, 0.408151329f},
std::array<float,2>{0.843470335f, 0.896361351f},
std::array<float,2>{0.00206798222f, 0.0718520433f},
std::array<float,2>{0.230197668f, 0.784939468f},
std::array<float,2>{0.879524171f, 0.128044263f},
std::array<float,2>{0.537745893f, 0.69887954f},
std::array<float,2>{0.446859509f, 0.316368014f},
std::array<float,2>{0.418053657f, 0.795366466f},
std::array<float,2>{0.584742904f, 0.139049143f},
std::array<float,2>{0.974215806f, 0.693143845f},
std::array<float,2>{0.134502068f, 0.32632646f},
std::array<float,2>{0.0993236229f, 0.598320127f},
std::array<float,2>{0.794411182f, 0.41447562f},
std::array<float,2>{0.704905272f, 0.904529274f},
std::array<float,2>{0.30711025f, 0.0686947182f},
std::array<float,2>{0.334843874f, 0.635603428f},
std::array<float,2>{0.651846707f, 0.287139893f},
std::array<float,2>{0.820027649f, 0.872361839f},
std::array<float,2>{0.028539177f, 0.219814628f},
std::array<float,2>{0.240137905f, 0.948646784f},
std::array<float,2>{0.890851796f, 0.0283090621f},
std::array<float,2>{0.560022891f, 0.501750648f},
std::array<float,2>{0.464656323f, 0.486664116f},
std::array<float,2>{0.269000173f, 0.921161711f},
std::array<float,2>{0.737701297f, 0.116913483f},
std::array<float,2>{0.751786292f, 0.582403779f},
std::array<float,2>{0.0708467737f, 0.391563952f},
std::array<float,2>{0.171693087f, 0.735697269f},
std::array<float,2>{0.960732102f, 0.369711101f},
std::array<float,2>{0.616650581f, 0.779664636f},
std::array<float,2>{0.403000206f, 0.158514649f},
std::array<float,2>{0.473880798f, 0.550210416f},
std::array<float,2>{0.51833719f, 0.462442309f},
std::array<float,2>{0.931203246f, 0.999309301f},
std::array<float,2>{0.196913257f, 0.0362814888f},
std::array<float,2>{0.0364864022f, 0.822332025f},
std::array<float,2>{0.865887582f, 0.203423738f},
std::array<float,2>{0.679496765f, 0.670399129f},
std::array<float,2>{0.359502286f, 0.273779809f},
std::array<float,2>{0.357751429f, 0.850634813f},
std::array<float,2>{0.659470081f, 0.240767285f},
std::array<float,2>{0.850506425f, 0.641406596f},
std::array<float,2>{0.0605247132f, 0.302908272f},
std::array<float,2>{0.209277168f, 0.518821657f},
std::array<float,2>{0.918260872f, 0.480232149f},
std::array<float,2>{0.515459239f, 0.968669891f},
std::array<float,2>{0.49846971f, 0.000748933235f},
std::array<float,2>{0.390472919f, 0.705357313f},
std::array<float,2>{0.597103894f, 0.342516482f},
std::array<float,2>{0.94500041f, 0.811356068f},
std::array<float,2>{0.178156868f, 0.153825387f},
std::array<float,2>{0.084174782f, 0.880134404f},
std::array<float,2>{0.771352649f, 0.0840693712f},
std::array<float,2>{0.721473753f, 0.623227656f},
std::array<float,2>{0.250576586f, 0.437077254f},
std::array<float,2>{0.451882422f, 0.978259146f},
std::array<float,2>{0.533202052f, 0.0524256825f},
std::array<float,2>{0.875500083f, 0.531882524f},
std::array<float,2>{0.2312987f, 0.443274736f},
std::array<float,2>{0.00452649267f, 0.681139886f},
std::array<float,2>{0.837599277f, 0.264894783f},
std::array<float,2>{0.628586233f, 0.841314554f},
std::array<float,2>{0.325563431f, 0.19239825f},
std::array<float,2>{0.296355695f, 0.574750483f},
std::array<float,2>{0.689161003f, 0.378573209f},
std::array<float,2>{0.804176807f, 0.929275036f},
std::array<float,2>{0.116496317f, 0.0989582017f},
std::array<float,2>{0.147132516f, 0.763458848f},
std::array<float,2>{0.993406653f, 0.177735746f},
std::array<float,2>{0.576456368f, 0.734049737f},
std::array<float,2>{0.43064779f, 0.349180013f},
std::array<float,2>{0.485663086f, 0.830744445f},
std::array<float,2>{0.501947939f, 0.197766542f},
std::array<float,2>{0.91265893f, 0.672255933f},
std::array<float,2>{0.211672813f, 0.254376829f},
std::array<float,2>{0.0490491092f, 0.545874119f},
std::array<float,2>{0.858745873f, 0.448950946f},
std::array<float,2>{0.665929377f, 0.971852779f},
std::array<float,2>{0.348823309f, 0.0578030683f},
std::array<float,2>{0.265157461f, 0.725150526f},
std::array<float,2>{0.728509009f, 0.352082103f},
std::array<float,2>{0.775253475f, 0.756405175f},
std::array<float,2>{0.0865998641f, 0.180600807f},
std::array<float,2>{0.185992599f, 0.932274461f},
std::array<float,2>{0.948005259f, 0.104339719f},
std::array<float,2>{0.603986681f, 0.566938221f},
std::array<float,2>{0.381632924f, 0.385520637f},
std::array<float,2>{0.317738503f, 0.953937232f},
std::array<float,2>{0.633229852f, 0.0155791715f},
std::array<float,2>{0.830186963f, 0.529971182f},
std::array<float,2>{0.0140524302f, 0.472050428f},
std::array<float,2>{0.223530605f, 0.65310216f},
std::array<float,2>{0.889989614f, 0.311094701f},
std::array<float,2>{0.546420157f, 0.856321394f},
std::array<float,2>{0.440610975f, 0.244575948f},
std::array<float,2>{0.427925199f, 0.609758615f},
std::array<float,2>{0.562998712f, 0.428962916f},
std::array<float,2>{0.985062718f, 0.889469326f},
std::array<float,2>{0.154654533f, 0.0923320502f},
std::array<float,2>{0.124463506f, 0.802360296f},
std::array<float,2>{0.810037017f, 0.145193785f},
std::array<float,2>{0.701862156f, 0.717888296f},
std::array<float,2>{0.286426365f, 0.331032693f},
std::array<float,2>{0.304061592f, 0.765637398f},
std::array<float,2>{0.718061924f, 0.168540061f},
std::array<float,2>{0.786136866f, 0.74673593f},
std::array<float,2>{0.106005415f, 0.363132119f},
std::array<float,2>{0.126614153f, 0.593155146f},
std::array<float,2>{0.983712554f, 0.398658484f},
std::array<float,2>{0.59151721f, 0.906806171f},
std::array<float,2>{0.410429358f, 0.119958267f},
std::array<float,2>{0.460206151f, 0.659730017f},
std::array<float,2>{0.553032637f, 0.268211246f},
std::array<float,2>{0.898987412f, 0.817274272f},
std::array<float,2>{0.242266729f, 0.211315915f},
std::array<float,2>{0.0199743286f, 0.990069807f},
std::array<float,2>{0.825275123f, 0.0431098081f},
std::array<float,2>{0.640656054f, 0.558422506f},
std::array<float,2>{0.338356733f, 0.455570877f},
std::array<float,2>{0.395828009f, 0.891275227f},
std::array<float,2>{0.623734772f, 0.0759909675f},
std::array<float,2>{0.964636981f, 0.606342852f},
std::array<float,2>{0.157513633f, 0.411737472f},
std::array<float,2>{0.0693995208f, 0.701793611f},
std::array<float,2>{0.763148785f, 0.316643834f},
std::array<float,2>{0.748185754f, 0.785794258f},
std::array<float,2>{0.279856175f, 0.132796571f},
std::array<float,2>{0.367726505f, 0.507973492f},
std::array<float,2>{0.68258661f, 0.49522084f},
std::array<float,2>{0.871758521f, 0.942952871f},
std::array<float,2>{0.0458465517f, 0.0209367611f},
std::array<float,2>{0.194050387f, 0.863344252f},
std::array<float,2>{0.928185523f, 0.229142323f},
std::array<float,2>{0.524787247f, 0.626341641f},
std::array<float,2>{0.483579844f, 0.29344064f},
std::array<float,2>{0.423804909f, 0.824314177f},
std::array<float,2>{0.56657064f, 0.209874839f},
std::array<float,2>{0.991378069f, 0.664655745f},
std::array<float,2>{0.149548203f, 0.279154092f},
std::array<float,2>{0.118850097f, 0.552557826f},
std::array<float,2>{0.806639016f, 0.467967838f},
std::array<float,2>{0.696538329f, 0.992567778f},
std::array<float,2>{0.283796132f, 0.0328660272f},
std::array<float,2>{0.314189762f, 0.741178751f},
std::array<float,2>{0.637880802f, 0.37378028f},
std::array<float,2>{0.835584939f, 0.77613312f},
std::array<float,2>{0.00823593326f, 0.164037064f},
std::array<float,2>{0.221650198f, 0.916425765f},
std::array<float,2>{0.883384228f, 0.113207817f},
std::array<float,2>{0.539912105f, 0.581026316f},
std::array<float,2>{0.444196612f, 0.397096485f},
std::array<float,2>{0.261107653f, 0.951215446f},
std::array<float,2>{0.733538568f, 0.0258203913f},
std::array<float,2>{0.780318737f, 0.50667274f},
std::array<float,2>{0.0930427536f, 0.490946501f},
std::array<float,2>{0.181404293f, 0.640071452f},
std::array<float,2>{0.949292183f, 0.281808376f},
std::array<float,2>{0.607560217f, 0.868091762f},
std::array<float,2>{0.37773487f, 0.225194246f},
std::array<float,2>{0.489298642f, 0.596473157f},
std::array<float,2>{0.507626653f, 0.419551075f},
std::array<float,2>{0.908667803f, 0.898741901f},
std::array<float,2>{0.216460451f, 0.0632154718f},
std::array<float,2>{0.0527336001f, 0.791709602f},
std::array<float,2>{0.85237056f, 0.136321336f},
std::array<float,2>{0.668735147f, 0.691106498f},
std::array<float,2>{0.347245336f, 0.320707053f},
std::array<float,2>{0.371774286f, 0.759105504f},
std::array<float,2>{0.684216976f, 0.17515716f},
std::array<float,2>{0.86731261f, 0.726894915f},
std::array<float,2>{0.0400292799f, 0.347100675f},
std::array<float,2>{0.189761549f, 0.572828352f},
std::array<float,2>{0.922669053f, 0.379596323f},
std::array<float,2>{0.529628575f, 0.923188567f},
std::array<float,2>{0.477970898f, 0.0968795717f},
std::array<float,2>{0.393248767f, 0.686493337f},
std::array<float,2>{0.620525062f, 0.25837332f},
std::array<float,2>{0.967521906f, 0.837955117f},
std::array<float,2>{0.163972318f, 0.190299824f},
std::array<float,2>{0.0639365241f, 0.980696142f},
std::array<float,2>{0.759680331f, 0.0482412204f},
std::array<float,2>{0.743148565f, 0.538461268f},
std::array<float,2>{0.275785536f, 0.438086331f},
std::array<float,2>{0.455468088f, 0.876775622f},
std::array<float,2>{0.547042131f, 0.0791949704f},
std::array<float,2>{0.904308498f, 0.61940825f},
std::array<float,2>{0.24649246f, 0.43143782f},
std::array<float,2>{0.0179843493f, 0.708352208f},
std::array<float,2>{0.822244406f, 0.336013347f},
std::array<float,2>{0.646979094f, 0.805657208f},
std::array<float,2>{0.340123087f, 0.149518594f},
std::array<float,2>{0.299512088f, 0.520962656f},
std::array<float,2>{0.713368773f, 0.482845306f},
std::array<float,2>{0.781320572f, 0.96417737f},
std::array<float,2>{0.105316751f, 0.00773037784f},
std::array<float,2>{0.129154086f, 0.846604049f},
std::array<float,2>{0.980275273f, 0.237093464f},
std::array<float,2>{0.586190164f, 0.645110965f},
std::array<float,2>{0.406785399f, 0.297395766f},
std::array<float,2>{0.472018212f, 0.798360229f},
std::array<float,2>{0.521528125f, 0.143361717f},
std::array<float,2>{0.936358809f, 0.714828432f},
std::array<float,2>{0.200173199f, 0.334332407f},
std::array<float,2>{0.0350981876f, 0.616347373f},
std::array<float,2>{0.862828493f, 0.422419459f},
std::array<float,2>{0.672921479f, 0.884250402f},
std::array<float,2>{0.364282906f, 0.0860977024f},
std::array<float,2>{0.270137936f, 0.650131345f},
std::array<float,2>{0.740709901f, 0.307519764f},
std::array<float,2>{0.756203294f, 0.852238297f},
std::array<float,2>{0.0745345056f, 0.247197345f},
std::array<float,2>{0.165090844f, 0.95986712f},
std::array<float,2>{0.95450139f, 0.0105340006f},
std::array<float,2>{0.609431565f, 0.527290583f},
std::array<float,2>{0.401360601f, 0.474294215f},
std::array<float,2>{0.329347163f, 0.934995353f},
std::array<float,2>{0.652624965f, 0.105718881f},
std::array<float,2>{0.815019429f, 0.562531769f},
std::array<float,2>{0.0270480122f, 0.389276683f},
std::array<float,2>{0.235965669f, 0.722253621f},
std::array<float,2>{0.8962152f, 0.359205872f},
std::array<float,2>{0.555155396f, 0.751655757f},
std::array<float,2>{0.465303779f, 0.1854067f},
std::array<float,2>{0.416093498f, 0.540374398f},
std::array<float,2>{0.581656814f, 0.452189356f},
std::array<float,2>{0.969161749f, 0.976484239f},
std::array<float,2>{0.140077457f, 0.0618839711f},
std::array<float,2>{0.0960148796f, 0.83231312f},
std::array<float,2>{0.792116821f, 0.200756162f},
std::array<float,2>{0.708954513f, 0.677160442f},
std::array<float,2>{0.309047192f, 0.251071423f},
std::array<float,2>{0.28966549f, 0.860384703f},
std::array<float,2>{0.694029987f, 0.230987817f},
std::array<float,2>{0.799845934f, 0.630889058f},
std::array<float,2>{0.110273845f, 0.29227376f},
std::array<float,2>{0.143345445f, 0.512009442f},
std::array<float,2>{0.996772468f, 0.49805066f},
std::array<float,2>{0.573302567f, 0.940125942f},
std::array<float,2>{0.435074776f, 0.0157894976f},
std::array<float,2>{0.448213339f, 0.695974767f},
std::array<float,2>{0.535925686f, 0.313241422f},
std::array<float,2>{0.881143808f, 0.782463729f},
std::array<float,2>{0.227479771f, 0.125102609f},
std::array<float,2>{0.000939437421f, 0.89796114f},
std::array<float,2>{0.840144336f, 0.0724379346f},
std::array<float,2>{0.632361889f, 0.605256259f},
std::array<float,2>{0.322332472f, 0.409288317f},
std::array<float,2>{0.383167475f, 0.984912038f},
std::array<float,2>{0.598345101f, 0.0402359813f},
std::array<float,2>{0.939927578f, 0.558672845f},
std::array<float,2>{0.172383472f, 0.458608657f},
std::array<float,2>{0.0804190487f, 0.660974324f},
std::array<float,2>{0.767491162f, 0.272453666f},
std::array<float,2>{0.724770308f, 0.814031124f},
std::array<float,2>{0.257017374f, 0.215471417f},
std::array<float,2>{0.354272515f, 0.589432716f},
std::array<float,2>{0.662653208f, 0.405542284f},
std::array<float,2>{0.846511006f, 0.913895845f},
std::array<float,2>{0.0564602204f, 0.121749312f},
std::array<float,2>{0.205626443f, 0.770393729f},
std::array<float,2>{0.915755808f, 0.166362494f},
std::array<float,2>{0.509572566f, 0.744632483f},
std::array<float,2>{0.492780179f, 0.366280735f},
std::array<float,2>{0.405980468f, 0.778943777f},
std::array<float,2>{0.613506973f, 0.157153621f},
std::array<float,2>{0.958705604f, 0.736665845f},
std::array<float,2>{0.169676825f, 0.368036032f},
std::array<float,2>{0.0734835863f, 0.585382998f},
std::array<float,2>{0.753194451f, 0.392895371f},
std::array<float,2>{0.734619379f, 0.918498278f},
std::array<float,2>{0.265755564f, 0.113915555f},
std::array<float,2>{0.36167562f, 0.669611752f},
std::array<float,2>{0.676344097f, 0.277254999f},
std::array<float,2>{0.865169644f, 0.82096678f},
std::array<float,2>{0.0384238474f, 0.206785306f},
std::array<float,2>{0.19876416f, 0.996252716f},
std::array<float,2>{0.931950748f, 0.0374734811f},
std::array<float,2>{0.516627252f, 0.547351539f},
std::array<float,2>{0.474995673f, 0.464432478f},
std::array<float,2>{0.30529967f, 0.902602732f},
std::array<float,2>{0.705233634f, 0.0672708005f},
std::array<float,2>{0.795737207f, 0.600812972f},
std::array<float,2>{0.100361057f, 0.417465895f},
std::array<float,2>{0.134860262f, 0.694823086f},
std::array<float,2>{0.975465178f, 0.325906932f},
std::array<float,2>{0.582380056f, 0.793346584f},
std::array<float,2>{0.420962065f, 0.13692677f},
std::array<float,2>{0.462299228f, 0.503693879f},
std::array<float,2>{0.560991228f, 0.486041844f},
std::array<float,2>{0.893957734f, 0.945813656f},
std::array<float,2>{0.242177978f, 0.0293587334f},
std::array<float,2>{0.030626867f, 0.873350561f},
std::array<float,2>{0.817261636f, 0.222623512f},
std::array<float,2>{0.649861872f, 0.633044899f},
std::array<float,2>{0.332767963f, 0.286857992f},
std::array<float,2>{0.326959878f, 0.842234373f},
std::array<float,2>{0.625262737f, 0.19348304f},
std::array<float,2>{0.838798225f, 0.681680083f},
std::array<float,2>{0.00729339151f, 0.26185295f},
std::array<float,2>{0.233273834f, 0.534092844f},
std::array<float,2>{0.877615809f, 0.443835258f},
std::array<float,2>{0.534923434f, 0.979539454f},
std::array<float,2>{0.450421274f, 0.0546697862f},
std::array<float,2>{0.432572663f, 0.730549097f},
std::array<float,2>{0.57514292f, 0.350457937f},
std::array<float,2>{0.99476546f, 0.764297128f},
std::array<float,2>{0.144738019f, 0.177033827f},
std::array<float,2>{0.114152871f, 0.926862121f},
std::array<float,2>{0.801759005f, 0.100080013f},
std::array<float,2>{0.690189481f, 0.576596975f},
std::array<float,2>{0.293357134f, 0.375976652f},
std::array<float,2>{0.496321619f, 0.966626167f},
std::array<float,2>{0.512036502f, 0.00381708657f},
std::array<float,2>{0.92016542f, 0.516104937f},
std::array<float,2>{0.207455084f, 0.478405863f},
std::array<float,2>{0.0619154423f, 0.643727541f},
std::array<float,2>{0.847747326f, 0.301975042f},
std::array<float,2>{0.656853795f, 0.848040402f},
std::array<float,2>{0.355493069f, 0.238774642f},
std::array<float,2>{0.253041059f, 0.622274399f},
std::array<float,2>{0.720412314f, 0.435212135f},
std::array<float,2>{0.773156703f, 0.88170898f},
std::array<float,2>{0.0832161829f, 0.083129935f},
std::array<float,2>{0.17725037f, 0.809876263f},
std::array<float,2>{0.941451728f, 0.154539704f},
std::array<float,2>{0.595532417f, 0.703380942f},
std::array<float,2>{0.387016982f, 0.340691358f},
std::array<float,2>{0.439113438f, 0.85757941f},
std::array<float,2>{0.543832362f, 0.243839264f},
std::array<float,2>{0.886741459f, 0.656211317f},
std::array<float,2>{0.225569069f, 0.308739394f},
std::array<float,2>{0.0119907688f, 0.529229641f},
std::array<float,2>{0.828632176f, 0.469853491f},
std::array<float,2>{0.635550499f, 0.956044137f},
std::array<float,2>{0.319265544f, 0.0121656619f},
std::array<float,2>{0.288840413f, 0.71523875f},
std::array<float,2>{0.700471759f, 0.32821238f},
std::array<float,2>{0.812123418f, 0.804047048f},
std::array<float,2>{0.122171022f, 0.146621227f},
std::array<float,2>{0.153058395f, 0.887075543f},
std::array<float,2>{0.987053692f, 0.0906333253f},
std::array<float,2>{0.565403163f, 0.612420142f},
std::array<float,2>{0.427049309f, 0.426202863f},
std::array<float,2>{0.349714011f, 0.969111145f},
std::array<float,2>{0.666494012f, 0.0554511994f},
std::array<float,2>{0.857327402f, 0.544358492f},
std::array<float,2>{0.048037827f, 0.44657737f},
std::array<float,2>{0.213778049f, 0.675662637f},
std::array<float,2>{0.910261214f, 0.256864011f},
std::array<float,2>{0.50353241f, 0.829127312f},
std::array<float,2>{0.488038093f, 0.196512967f},
std::array<float,2>{0.379993081f, 0.570219219f},
std::array<float,2>{0.603135109f, 0.383307517f},
std::array<float,2>{0.945506334f, 0.929703057f},
std::array<float,2>{0.184980735f, 0.101928234f},
std::array<float,2>{0.089577049f, 0.754421353f},
std::array<float,2>{0.776800573f, 0.1825753f},
std::array<float,2>{0.729620755f, 0.724348009f},
std::array<float,2>{0.262916178f, 0.354956567f},
std::array<float,2>{0.2775428f, 0.787388861f},
std::array<float,2>{0.74799484f, 0.129109412f},
std::array<float,2>{0.765153408f, 0.699424267f},
std::array<float,2>{0.067578651f, 0.319093525f},
std::array<float,2>{0.160035506f, 0.607596397f},
std::array<float,2>{0.962509274f, 0.412130564f},
std::array<float,2>{0.622997522f, 0.892901182f},
std::array<float,2>{0.39686358f, 0.0768947005f},
std::array<float,2>{0.480494499f, 0.627587795f},
std::array<float,2>{0.525887728f, 0.296204984f},
std::array<float,2>{0.927369595f, 0.867089689f},
std::array<float,2>{0.191804826f, 0.227992535f},
std::array<float,2>{0.0434516035f, 0.943893552f},
std::array<float,2>{0.873166203f, 0.0219417159f},
std::array<float,2>{0.680279553f, 0.511380553f},
std::array<float,2>{0.370534748f, 0.492984891f},
std::array<float,2>{0.413623273f, 0.909745932f},
std::array<float,2>{0.591871917f, 0.117482617f},
std::array<float,2>{0.98228246f, 0.590554118f},
std::array<float,2>{0.12754038f, 0.40222156f},
std::array<float,2>{0.10936591f, 0.74854207f},
std::array<float,2>{0.788062811f, 0.359661222f},
std::array<float,2>{0.716437578f, 0.767733037f},
std::array<float,2>{0.301213175f, 0.171808943f},
std::array<float,2>{0.336987197f, 0.555022776f},
std::array<float,2>{0.643104315f, 0.45377925f},
std::array<float,2>{0.826611161f, 0.991888821f},
std::array<float,2>{0.0224857721f, 0.0460524112f},
std::array<float,2>{0.24531433f, 0.818624735f},
std::array<float,2>{0.901433647f, 0.213521063f},
std::array<float,2>{0.551652312f, 0.657415152f},
std::array<float,2>{0.458275437f, 0.265950203f},
std::array<float,2>{0.434903204f, 0.862482488f},
std::array<float,2>{0.573967695f, 0.233684912f},
std::array<float,2>{0.996415496f, 0.630732f},
std::array<float,2>{0.142717481f, 0.289439559f},
std::array<float,2>{0.109754421f, 0.515018702f},
std::array<float,2>{0.800626457f, 0.496471494f},
std::array<float,2>{0.693416476f, 0.937712491f},
std::array<float,2>{0.289190054f, 0.0195184126f},
std::array<float,2>{0.322761416f, 0.698679745f},
std::array<float,2>{0.632073045f, 0.315458298f},
std::array<float,2>{0.84060812f, 0.784510076f},
std::array<float,2>{4.65709418e-05f, 0.1287435f},
std::array<float,2>{0.226916984f, 0.895791352f},
std::array<float,2>{0.881369174f, 0.0713513717f},
std::array<float,2>{0.535403609f, 0.602194309f},
std::array<float,2>{0.447490662f, 0.407583922f},
std::array<float,2>{0.257786691f, 0.986943424f},
std::array<float,2>{0.725209951f, 0.041861739f},
std::array<float,2>{0.766702235f, 0.561302602f},
std::array<float,2>{0.0806553513f, 0.460306048f},
std::array<float,2>{0.172203094f, 0.663380146f},
std::array<float,2>{0.940150678f, 0.27030921f},
std::array<float,2>{0.597935021f, 0.815765083f},
std::array<float,2>{0.38340044f, 0.218570888f},
std::array<float,2>{0.492256999f, 0.586623788f},
std::array<float,2>{0.508927166f, 0.403036356f},
std::array<float,2>{0.91524905f, 0.911055565f},
std::array<float,2>{0.2055372f, 0.123408221f},
std::array<float,2>{0.0560934544f, 0.772442698f},
std::array<float,2>{0.846017957f, 0.164162204f},
std::array<float,2>{0.662156224f, 0.74346751f},
std::array<float,2>{0.353699803f, 0.36362049f},
std::array<float,2>{0.364990115f, 0.800649583f},
std::array<float,2>{0.673812807f, 0.140955999f},
std::array<float,2>{0.862476289f, 0.711374462f},
std::array<float,2>{0.034324903f, 0.332737058f},
std::array<float,2>{0.199489772f, 0.613873243f},
std::array<float,2>{0.935969412f, 0.424955398f},
std::array<float,2>{0.522133648f, 0.88640362f},
std::array<float,2>{0.472638041f, 0.0878945887f},
std::array<float,2>{0.400485426f, 0.652016282f},
std::array<float,2>{0.610176861f, 0.305594236f},
std::array<float,2>{0.955020368f, 0.853993118f},
std::array<float,2>{0.16568248f, 0.248281136f},
std::array<float,2>{0.0751129016f, 0.958824277f},
std::array<float,2>{0.756365418f, 0.00792081095f},
std::array<float,2>{0.740886807f, 0.523506105f},
std::array<float,2>{0.269681275f, 0.474845976f},
std::array<float,2>{0.465630591f, 0.936196387f},
std::array<float,2>{0.555514574f, 0.108374104f},
std::array<float,2>{0.89577347f, 0.566277802f},
std::array<float,2>{0.23547855f, 0.386828512f},
std::array<float,2>{0.0265270341f, 0.720324457f},
std::array<float,2>{0.814841986f, 0.355782121f},
std::array<float,2>{0.653213501f, 0.753614187f},
std::array<float,2>{0.329997569f, 0.185597524f},
std::array<float,2>{0.309332669f, 0.541105747f},
std::array<float,2>{0.708294272f, 0.450154006f},
std::array<float,2>{0.792877555f, 0.973876417f},
std::array<float,2>{0.0964665711f, 0.0595910661f},
std::array<float,2>{0.140616432f, 0.835283518f},
std::array<float,2>{0.969691038f, 0.202306166f},
std::array<float,2>{0.581239164f, 0.679402351f},
std::array<float,2>{0.416550815f, 0.252039015f},
std::array<float,2>{0.478384852f, 0.761442363f},
std::array<float,2>{0.5301404f, 0.173162133f},
std::array<float,2>{0.922305286f, 0.729480922f},
std::array<float,2>{0.190420419f, 0.345162749f},
std::array<float,2>{0.0392670296f, 0.571051776f},
std::array<float,2>{0.86780113f, 0.381844848f},
std::array<float,2>{0.683955967f, 0.925477862f},
std::array<float,2>{0.371356755f, 0.0952112824f},
std::array<float,2>{0.276215076f, 0.684867859f},
std::array<float,2>{0.742409945f, 0.260892898f},
std::array<float,2>{0.758836985f, 0.836791456f},
std::array<float,2>{0.0643258318f, 0.188756779f},
std::array<float,2>{0.163221732f, 0.983656287f},
std::array<float,2>{0.966870308f, 0.0490773246f},
std::array<float,2>{0.620764434f, 0.537050068f},
std::array<float,2>{0.392642051f, 0.440360695f},
std::array<float,2>{0.340680033f, 0.878702223f},
std::array<float,2>{0.646525383f, 0.0802309811f},
std::array<float,2>{0.821358383f, 0.617300391f},
std::array<float,2>{0.0184756164f, 0.433312416f},
std::array<float,2>{0.246941254f, 0.710795283f},
std::array<float,2>{0.904820502f, 0.337997139f},
std::array<float,2>{0.547604799f, 0.80761838f},
std::array<float,2>{0.455736279f, 0.150822461f},
std::array<float,2>{0.406563699f, 0.521500289f},
std::array<float,2>{0.586585462f, 0.481292635f},
std::array<float,2>{0.979724407f, 0.961321056f},
std::array<float,2>{0.129775017f, 0.00445871288f},
std::array<float,2>{0.104603641f, 0.845463276f},
std::array<float,2>{0.781998336f, 0.235194445f},
std::array<float,2>{0.713516831f, 0.647575259f},
std::array<float,2>{0.298875421f, 0.299384803f},
std::array<float,2>{0.283458441f, 0.827389836f},
std::array<float,2>{0.697049499f, 0.208507583f},
std::array<float,2>{0.805731833f, 0.666116297f},
std::array<float,2>{0.118210115f, 0.280197918f},
std::array<float,2>{0.150174856f, 0.553698361f},
std::array<float,2>{0.991982698f, 0.466616929f},
std::array<float,2>{0.566910565f, 0.99537915f},
std::array<float,2>{0.423035085f, 0.0347298533f},
std::array<float,2>{0.443731517f, 0.738612175f},
std::array<float,2>{0.539203703f, 0.372246653f},
std::array<float,2>{0.882880569f, 0.773726404f},
std::array<float,2>{0.220884457f, 0.160873801f},
std::array<float,2>{0.00837633666f, 0.915375829f},
std::array<float,2>{0.835214376f, 0.110709623f},
std::array<float,2>{0.638447762f, 0.578561425f},
std::array<float,2>{0.313905209f, 0.395380557f},
std::array<float,2>{0.377083659f, 0.950912893f},
std::array<float,2>{0.608244956f, 0.0246934425f},
std::array<float,2>{0.950082898f, 0.505780995f},
std::array<float,2>{0.180998564f, 0.488942266f},
std::array<float,2>{0.0936926752f, 0.637114644f},
std::array<float,2>{0.780918837f, 0.284603655f},
std::array<float,2>{0.733985603f, 0.870696902f},
std::array<float,2>{0.261245191f, 0.224024624f},
std::array<float,2>{0.347075015f, 0.59436363f},
std::array<float,2>{0.668431163f, 0.421314955f},
std::array<float,2>{0.851842105f, 0.9008407f},
std::array<float,2>{0.0519385561f, 0.0648909062f},
std::array<float,2>{0.216168627f, 0.79064554f},
std::array<float,2>{0.9091416f, 0.133375317f},
std::array<float,2>{0.506891549f, 0.689225793f},
std::array<float,2>{0.489974171f, 0.323346943f},
std::array<float,2>{0.397284597f, 0.785383761f},
std::array<float,2>{0.622351646f, 0.13201949f},
std::array<float,2>{0.962081611f, 0.701234519f},
std::array<float,2>{0.159544215f, 0.316923231f},
std::array<float,2>{0.0681659579f, 0.605509937f},
std::array<float,2>{0.764656663f, 0.411351711f},
std::array<float,2>{0.747206032f, 0.890885413f},
std::array<float,2>{0.278244883f, 0.0754690692f},
std::array<float,2>{0.370920837f, 0.626655936f},
std::array<float,2>{0.679987133f, 0.293934256f},
std::array<float,2>{0.873564065f, 0.864048123f},
std::array<float,2>{0.043666359f, 0.228735551f},
std::array<float,2>{0.191922724f, 0.942487061f},
std::array<float,2>{0.926946223f, 0.0213090051f},
std::array<float,2>{0.525584757f, 0.508771181f},
std::array<float,2>{0.481023401f, 0.495700896f},
std::array<float,2>{0.301342815f, 0.906346977f},
std::array<float,2>{0.716154277f, 0.119549274f},
std::array<float,2>{0.787149191f, 0.593749881f},
std::array<float,2>{0.108719423f, 0.39915356f},
std::array<float,2>{0.127359524f, 0.746482015f},
std::array<float,2>{0.981682241f, 0.362523198f},
std::array<float,2>{0.592318118f, 0.766179681f},
std::array<float,2>{0.413393795f, 0.168233439f},
std::array<float,2>{0.458846271f, 0.557714462f},
std::array<float,2>{0.550984085f, 0.455233365f},
std::array<float,2>{0.901932955f, 0.989303648f},
std::array<float,2>{0.245985493f, 0.0437498912f},
std::array<float,2>{0.0234236624f, 0.816509187f},
std::array<float,2>{0.827013791f, 0.211566776f},
std::array<float,2>{0.642980158f, 0.65956825f},
std::array<float,2>{0.337807536f, 0.267911166f},
std::array<float,2>{0.318725318f, 0.855534554f},
std::array<float,2>{0.634845614f, 0.244716182f},
std::array<float,2>{0.828153968f, 0.652640224f},
std::array<float,2>{0.0123262014f, 0.310793668f},
std::array<float,2>{0.224923268f, 0.529489696f},
std::array<float,2>{0.887235463f, 0.472413719f},
std::array<float,2>{0.543381095f, 0.953283012f},
std::array<float,2>{0.438571036f, 0.0147293713f},
std::array<float,2>{0.427470654f, 0.718530238f},
std::array<float,2>{0.564531565f, 0.330478102f},
std::array<float,2>{0.986380517f, 0.802087069f},
std::array<float,2>{0.152489051f, 0.144984841f},
std::array<float,2>{0.122734696f, 0.888882279f},
std::array<float,2>{0.811899781f, 0.0918048918f},
std::array<float,2>{0.701112092f, 0.610049069f},
std::array<float,2>{0.288396269f, 0.429445505f},
std::array<float,2>{0.487331212f, 0.972392797f},
std::array<float,2>{0.503135085f, 0.0581240878f},
std::array<float,2>{0.910828829f, 0.544991314f},
std::array<float,2>{0.213244349f, 0.448333502f},
std::array<float,2>{0.0486672632f, 0.672374964f},
std::array<float,2>{0.856888592f, 0.254505575f},
std::array<float,2>{0.66651994f, 0.830432832f},
std::array<float,2>{0.350245386f, 0.197426066f},
std::array<float,2>{0.263376117f, 0.566771269f},
std::array<float,2>{0.73037076f, 0.384765983f},
std::array<float,2>{0.777144015f, 0.931872904f},
std::array<float,2>{0.0891217738f, 0.103843138f},
std::array<float,2>{0.185131267f, 0.75594002f},
std::array<float,2>{0.945833206f, 0.179734811f},
std::array<float,2>{0.602926314f, 0.724816918f},
std::array<float,2>{0.380484581f, 0.351599455f},
std::array<float,2>{0.450910926f, 0.841092348f},
std::array<float,2>{0.534508228f, 0.193352342f},
std::array<float,2>{0.877335906f, 0.681238472f},
std::array<float,2>{0.232800037f, 0.265502572f},
std::array<float,2>{0.00745793339f, 0.53131932f},
std::array<float,2>{0.838280201f, 0.442857057f},
std::array<float,2>{0.625822783f, 0.977896512f},
std::array<float,2>{0.326573581f, 0.051983051f},
std::array<float,2>{0.293880433f, 0.733472645f},
std::array<float,2>{0.689764857f, 0.348854274f},
std::array<float,2>{0.802473009f, 0.763165772f},
std::array<float,2>{0.113494866f, 0.178462565f},
std::array<float,2>{0.14524889f, 0.929112613f},
std::array<float,2>{0.994346678f, 0.0991394594f},
std::array<float,2>{0.574266911f, 0.574607432f},
std::array<float,2>{0.431859761f, 0.378212899f},
std::array<float,2>{0.356127799f, 0.967989624f},
std::array<float,2>{0.656417668f, 0.000169046209f},
std::array<float,2>{0.848543763f, 0.51909095f},
std::array<float,2>{0.0624896511f, 0.479787081f},
std::array<float,2>{0.207629532f, 0.640856743f},
std::array<float,2>{0.920443773f, 0.303278595f},
std::array<float,2>{0.512306631f, 0.85144496f},
std::array<float,2>{0.496977895f, 0.240342915f},
std::array<float,2>{0.387299329f, 0.624000609f},
std::array<float,2>{0.595087707f, 0.436943322f},
std::array<float,2>{0.942375362f, 0.880673945f},
std::array<float,2>{0.177082747f, 0.0845698863f},
std::array<float,2>{0.0836105421f, 0.810658038f},
std::array<float,2>{0.772755265f, 0.153324381f},
std::array<float,2>{0.720098019f, 0.705728769f},
std::array<float,2>{0.25350818f, 0.342103004f},
std::array<float,2>{0.266317129f, 0.780126452f},
std::array<float,2>{0.735224724f, 0.159121901f},
std::array<float,2>{0.753603816f, 0.735865712f},
std::array<float,2>{0.0738992169f, 0.369481087f},
std::array<float,2>{0.169118911f, 0.582532465f},
std::array<float,2>{0.958129227f, 0.390887141f},
std::array<float,2>{0.614050388f, 0.921428859f},
std::array<float,2>{0.405298352f, 0.11658553f},
std::array<float,2>{0.475472569f, 0.670599759f},
std::array<float,2>{0.517257631f, 0.274051517f},
std::array<float,2>{0.932240844f, 0.822862327f},
std::array<float,2>{0.198268279f, 0.203748494f},
std::array<float,2>{0.038582202f, 0.999626875f},
std::array<float,2>{0.864306867f, 0.0366216116f},
std::array<float,2>{0.67597419f, 0.5505597f},
std::array<float,2>{0.362200797f, 0.462084442f},
std::array<float,2>{0.421696544f, 0.905002773f},
std::array<float,2>{0.582973599f, 0.0688713118f},
std::array<float,2>{0.974710345f, 0.597954929f},
std::array<float,2>{0.135652259f, 0.414920866f},
std::array<float,2>{0.0997019783f, 0.692708552f},
std::array<float,2>{0.795091927f, 0.326726049f},
std::array<float,2>{0.706018984f, 0.795464516f},
std::array<float,2>{0.304807216f, 0.13961038f},
std::array<float,2>{0.332154453f, 0.501135886f},
std::array<float,2>{0.650370955f, 0.487110287f},
std::array<float,2>{0.816813648f, 0.949175775f},
std::array<float,2>{0.03107691f, 0.0277459398f},
std::array<float,2>{0.241650641f, 0.872740507f},
std::array<float,2>{0.894360185f, 0.220289931f},
std::array<float,2>{0.561074138f, 0.635004699f},
std::array<float,2>{0.462684393f, 0.287791789f},
std::array<float,2>{0.385166287f, 0.813661218f},
std::array<float,2>{0.600306213f, 0.215120539f},
std::array<float,2>{0.939129293f, 0.660352647f},
std::array<float,2>{0.174964458f, 0.271774918f},
std::array<float,2>{0.079677701f, 0.559326053f},
std::array<float,2>{0.769017518f, 0.458432287f},
std::array<float,2>{0.722729623f, 0.98462224f},
std::array<float,2>{0.25498423f, 0.0408877321f},
std::array<float,2>{0.352071375f, 0.744479418f},
std::array<float,2>{0.662030637f, 0.367133349f},
std::array<float,2>{0.844870985f, 0.769865394f},
std::array<float,2>{0.0572891496f, 0.166793898f},
std::array<float,2>{0.204388052f, 0.913372159f},
std::array<float,2>{0.916046441f, 0.121429063f},
std::array<float,2>{0.511031687f, 0.58927083f},
std::array<float,2>{0.495406181f, 0.406005323f},
std::array<float,2>{0.292727143f, 0.939823389f},
std::array<float,2>{0.693194687f, 0.0164075848f},
std::array<float,2>{0.79840076f, 0.512606204f},
std::array<float,2>{0.112871788f, 0.498751044f},
std::array<float,2>{0.14214921f, 0.631417274f},
std::array<float,2>{0.998314798f, 0.292859733f},
std::array<float,2>{0.5704633f, 0.860888839f},
std::array<float,2>{0.436018497f, 0.230488658f},
std::array<float,2>{0.446371257f, 0.604897738f},
std::array<float,2>{0.537562013f, 0.40984571f},
std::array<float,2>{0.879062057f, 0.897481501f},
std::array<float,2>{0.229595885f, 0.0731116459f},
std::array<float,2>{0.00245260284f, 0.783008277f},
std::array<float,2>{0.842989862f, 0.125803888f},
std::array<float,2>{0.629507005f, 0.695364654f},
std::array<float,2>{0.321254075f, 0.312594324f},
std::array<float,2>{0.331091166f, 0.751369536f},
std::array<float,2>{0.655984044f, 0.184755132f},
std::array<float,2>{0.814400792f, 0.72180897f},
std::array<float,2>{0.0243893676f, 0.358800471f},
std::array<float,2>{0.236776382f, 0.56331706f},
std::array<float,2>{0.896623313f, 0.389131755f},
std::array<float,2>{0.558391333f, 0.935212851f},
std::array<float,2>{0.467212021f, 0.10599412f},
std::array<float,2>{0.414168358f, 0.677278101f},
std::array<float,2>{0.578388512f, 0.251892835f},
std::array<float,2>{0.971913517f, 0.832913697f},
std::array<float,2>{0.136899918f, 0.200246662f},
std::array<float,2>{0.0937905014f, 0.975885987f},
std::array<float,2>{0.790141106f, 0.0620838478f},
std::array<float,2>{0.70999068f, 0.540707171f},
std::array<float,2>{0.310608923f, 0.452982157f},
std::array<float,2>{0.468859166f, 0.884758294f},
std::array<float,2>{0.51960206f, 0.086885348f},
std::array<float,2>{0.935413539f, 0.616894484f},
std::array<float,2>{0.202210218f, 0.422077745f},
std::array<float,2>{0.032065697f, 0.714248776f},
std::array<float,2>{0.859482646f, 0.334664404f},
std::array<float,2>{0.674031436f, 0.797872245f},
std::array<float,2>{0.366434783f, 0.142699197f},
std::array<float,2>{0.272196025f, 0.526818514f},
std::array<float,2>{0.738382101f, 0.473998755f},
std::array<float,2>{0.755304039f, 0.95909673f},
std::array<float,2>{0.0777859911f, 0.00993445795f},
std::array<float,2>{0.16759029f, 0.851597369f},
std::array<float,2>{0.956695497f, 0.247885227f},
std::array<float,2>{0.612324059f, 0.649445653f},
std::array<float,2>{0.400300711f, 0.306858748f},
std::array<float,2>{0.453623444f, 0.804728508f},
std::array<float,2>{0.550431013f, 0.149986789f},
std::array<float,2>{0.90401727f, 0.708501101f},
std::array<float,2>{0.248431414f, 0.336491674f},
std::array<float,2>{0.01642498f, 0.620072603f},
std::array<float,2>{0.82277447f, 0.430844337f},
std::array<float,2>{0.645206213f, 0.876282573f},
std::array<float,2>{0.343141258f, 0.0798662975f},
std::array<float,2>{0.29854086f, 0.644632101f},
std::array<float,2>{0.711424947f, 0.296933413f},
std::array<float,2>{0.784605205f, 0.845829725f},
std::array<float,2>{0.102162659f, 0.236539587f},
std::array<float,2>{0.132231459f, 0.964532137f},
std::array<float,2>{0.977120757f, 0.00727838976f},
std::array<float,2>{0.588061273f, 0.521141052f},
std::array<float,2>{0.408523083f, 0.483073652f},
std::array<float,2>{0.373397648f, 0.923512638f},
std::array<float,2>{0.686956823f, 0.0974674523f},
std::array<float,2>{0.870212197f, 0.572742581f},
std::array<float,2>{0.0429662094f, 0.379040718f},
std::array<float,2>{0.188591883f, 0.727199793f},
std::array<float,2>{0.925655603f, 0.347195536f},
std::array<float,2>{0.527805388f, 0.759284914f},
std::array<float,2>{0.480457872f, 0.175316706f},
std::array<float,2>{0.390738815f, 0.538699269f},
std::array<float,2>{0.617688298f, 0.437649578f},
std::array<float,2>{0.964885652f, 0.981116116f},
std::array<float,2>{0.16208005f, 0.0488024466f},
std::array<float,2>{0.0661819279f, 0.838831186f},
std::array<float,2>{0.760979593f, 0.189595729f},
std::array<float,2>{0.745612323f, 0.685707629f},
std::array<float,2>{0.274605453f, 0.257938743f},
std::array<float,2>{0.258820266f, 0.867325425f},
std::array<float,2>{0.731953621f, 0.224690929f},
std::array<float,2>{0.77840817f, 0.640551269f},
std::array<float,2>{0.0906326622f, 0.281464934f},
std::array<float,2>{0.18335703f, 0.505947173f},
std::array<float,2>{0.951572895f, 0.490628242f},
std::array<float,2>{0.606576562f, 0.951866448f},
std::array<float,2>{0.376937419f, 0.0260633379f},
std::array<float,2>{0.491232127f, 0.690645516f},
std::array<float,2>{0.50507313f, 0.320843965f},
std::array<float,2>{0.907351851f, 0.791077197f},
std::array<float,2>{0.21825774f, 0.135973021f},
std::array<float,2>{0.0537401475f, 0.899170995f},
std::array<float,2>{0.854211152f, 0.0628786907f},
std::array<float,2>{0.670770288f, 0.596064389f},
std::array<float,2>{0.343888938f, 0.419398218f},
std::array<float,2>{0.424379975f, 0.993010879f},
std::array<float,2>{0.569305658f, 0.0325559527f},
std::array<float,2>{0.989095688f, 0.552240252f},
std::array<float,2>{0.15123105f, 0.468719184f},
std::array<float,2>{0.120799452f, 0.664149106f},
std::array<float,2>{0.806911588f, 0.278638482f},
std::array<float,2>{0.6985237f, 0.825019121f},
std::array<float,2>{0.283064425f, 0.209319457f},
std::array<float,2>{0.315728635f, 0.58047235f},
std::array<float,2>{0.638733566f, 0.396694273f},
std::array<float,2>{0.832118392f, 0.916514874f},
std::array<float,2>{0.010717757f, 0.112589367f},
std::array<float,2>{0.219363108f, 0.775865614f},
std::array<float,2>{0.886201084f, 0.163502589f},
std::array<float,2>{0.542461336f, 0.740642726f},
std::array<float,2>{0.443012416f, 0.373316258f},
std::array<float,2>{0.410952538f, 0.768401384f},
std::array<float,2>{0.590873539f, 0.171018869f},
std::array<float,2>{0.984011173f, 0.7483055f},
std::array<float,2>{0.126204133f, 0.359954745f},
std::array<float,2>{0.10580641f, 0.590038896f},
std::array<float,2>{0.787058711f, 0.401489705f},
std::array<float,2>{0.718747973f, 0.909661055f},
std::array<float,2>{0.304518372f, 0.117764205f},
std::array<float,2>{0.338632315f, 0.657897711f},
std::array<float,2>{0.641450167f, 0.266585529f},
std::array<float,2>{0.825757146f, 0.819252729f},
std::array<float,2>{0.0204297341f, 0.213188037f},
std::array<float,2>{0.242976218f, 0.991266072f},
std::array<float,2>{0.898566008f, 0.0467512086f},
std::array<float,2>{0.55360353f, 0.555582345f},
std::array<float,2>{0.460808277f, 0.453307241f},
std::array<float,2>{0.279417098f, 0.893297851f},
std::array<float,2>{0.748588741f, 0.0764652416f},
std::array<float,2>{0.763385236f, 0.608303905f},
std::array<float,2>{0.0702528507f, 0.412805021f},
std::array<float,2>{0.157828271f, 0.700048864f},
std::array<float,2>{0.964182615f, 0.318501115f},
std::array<float,2>{0.623446286f, 0.787798285f},
std::array<float,2>{0.396165967f, 0.129402325f},
std::array<float,2>{0.484100878f, 0.511129022f},
std::array<float,2>{0.525052607f, 0.492656559f},
std::array<float,2>{0.928357363f, 0.943841815f},
std::array<float,2>{0.193477303f, 0.0219933689f},
std::array<float,2>{0.0450383276f, 0.866586089f},
std::array<float,2>{0.87151593f, 0.228136092f},
std::array<float,2>{0.682058394f, 0.627296865f},
std::array<float,2>{0.367582768f, 0.296498388f},
std::array<float,2>{0.349575579f, 0.829743266f},
std::array<float,2>{0.665132165f, 0.197063819f},
std::array<float,2>{0.85900569f, 0.675135911f},
std::array<float,2>{0.0498030186f, 0.257644415f},
std::array<float,2>{0.211161941f, 0.544490337f},
std::array<float,2>{0.912474513f, 0.447012991f},
std::array<float,2>{0.501008213f, 0.969461381f},
std::array<float,2>{0.486297101f, 0.0549251214f},
std::array<float,2>{0.381224632f, 0.723808646f},
std::array<float,2>{0.604375184f, 0.355233878f},
std::array<float,2>{0.947720528f, 0.75430572f},
std::array<float,2>{0.186226368f, 0.18189612f},
std::array<float,2>{0.0861159861f, 0.930523217f},
std::array<float,2>{0.774699926f, 0.102315895f},
std::array<float,2>{0.728013277f, 0.5697335f},
std::array<float,2>{0.264903784f, 0.382885486f},
std::array<float,2>{0.441009641f, 0.955379725f},
std::array<float,2>{0.546068072f, 0.0124696046f},
std::array<float,2>{0.890602112f, 0.5287323f},
std::array<float,2>{0.222961128f, 0.470361143f},
std::array<float,2>{0.0145290224f, 0.65566802f},
std::array<float,2>{0.830931067f, 0.309309036f},
std::array<float,2>{0.633654118f, 0.85823518f},
std::array<float,2>{0.317947984f, 0.243339419f},
std::array<float,2>{0.286827087f, 0.613219738f},
std::array<float,2>{0.701650023f, 0.426751941f},
std::array<float,2>{0.810505509f, 0.887312233f},
std::array<float,2>{0.124618322f, 0.0898522958f},
std::array<float,2>{0.155143172f, 0.8043136f},
std::array<float,2>{0.984452009f, 0.147360146f},
std::array<float,2>{0.562974393f, 0.715665519f},
std::array<float,2>{0.428588927f, 0.328701377f},
std::array<float,2>{0.498728901f, 0.848170817f},
std::array<float,2>{0.514950335f, 0.238640308f},
std::array<float,2>{0.918747544f, 0.644062042f},
std::array<float,2>{0.209675908f, 0.302565873f},
std::array<float,2>{0.0596758984f, 0.516128182f},
std::array<float,2>{0.849956691f, 0.477876335f},
std::array<float,2>{0.660117924f, 0.965857685f},
std::array<float,2>{0.358293086f, 0.00307745743f},
std::array<float,2>{0.250031769f, 0.70396167f},
std::array<float,2>{0.721049547f, 0.340115905f},
std::array<float,2>{0.770854592f, 0.810065389f},
std::array<float,2>{0.0845821649f, 0.155269429f},
std::array<float,2>{0.178486004f, 0.880942345f},
std::array<float,2>{0.944434643f, 0.0834986046f},
std::array<float,2>{0.597481251f, 0.622595251f},
std::array<float,2>{0.390011489f, 0.434954703f},
std::array<float,2>{0.325695664f, 0.98043859f},
std::array<float,2>{0.627988279f, 0.0540323891f},
std::array<float,2>{0.837070644f, 0.533410728f},
std::array<float,2>{0.00416932767f, 0.444033563f},
std::array<float,2>{0.230611533f, 0.68244499f},
std::array<float,2>{0.875272274f, 0.262377739f},
std::array<float,2>{0.532279253f, 0.842511892f},
std::array<float,2>{0.451361597f, 0.193874225f},
std::array<float,2>{0.430104673f, 0.576975822f},
std::array<float,2>{0.577055097f, 0.376625657f},
std::array<float,2>{0.993995428f, 0.927345872f},
std::array<float,2>{0.146493554f, 0.100277506f},
std::array<float,2>{0.117137991f, 0.763813019f},
std::array<float,2>{0.804620028f, 0.177466363f},
std::array<float,2>{0.688520432f, 0.731415629f},
std::array<float,2>{0.296508819f, 0.350015998f},
std::array<float,2>{0.307262689f, 0.793879151f},
std::array<float,2>{0.704521954f, 0.137487531f},
std::array<float,2>{0.794797719f, 0.695219755f},
std::array<float,2>{0.0987502113f, 0.32534349f},
std::array<float,2>{0.134065747f, 0.601180017f},
std::array<float,2>{0.97390908f, 0.417953908f},
std::array<float,2>{0.584391415f, 0.903011382f},
std::array<float,2>{0.418707132f, 0.0666323826f},
std::array<float,2>{0.464107096f, 0.633359492f},
std::array<float,2>{0.560079336f, 0.286135703f},
std::array<float,2>{0.891550004f, 0.87378186f},
std::array<float,2>{0.23939772f, 0.221949905f},
std::array<float,2>{0.0292278156f, 0.945623279f},
std::array<float,2>{0.819418132f, 0.0298630241f},
std::array<float,2>{0.65211302f, 0.503237128f},
std::array<float,2>{0.334234506f, 0.485687405f},
std::array<float,2>{0.402351588f, 0.918415904f},
std::array<float,2>{0.617109716f, 0.11345385f},
std::array<float,2>{0.960117519f, 0.585812807f},
std::array<float,2>{0.170922056f, 0.393364429f},
std::array<float,2>{0.0707706213f, 0.737270832f},
std::array<float,2>{0.751389563f, 0.367467761f},
std::array<float,2>{0.738068342f, 0.77865082f},
std::array<float,2>{0.269298732f, 0.156592742f},
std::array<float,2>{0.360130519f, 0.547446966f},
std::array<float,2>{0.678911984f, 0.46421814f},
std::array<float,2>{0.865611196f, 0.996984363f},
std::array<float,2>{0.0368964076f, 0.0378252566f},
std::array<float,2>{0.196368814f, 0.820683241f},
std::array<float,2>{0.930782318f, 0.206229985f},
std::array<float,2>{0.51775825f, 0.669364512f},
std::array<float,2>{0.47455129f, 0.276589364f},
std::array<float,2>{0.398948282f, 0.855033755f},
std::array<float,2>{0.611934781f, 0.249025166f},
std::array<float,2>{0.955199063f, 0.650580585f},
std::array<float,2>{0.166662425f, 0.305927694f},
std::array<float,2>{0.0770287588f, 0.525291145f},
std::array<float,2>{0.754369318f, 0.476544231f},
std::array<float,2>{0.739915609f, 0.95723331f},
std::array<float,2>{0.273107976f, 0.00892534014f},
std::array<float,2>{0.365698129f, 0.712466598f},
std::array<float,2>{0.674975574f, 0.333983272f},
std::array<float,2>{0.860525012f, 0.799517572f},
std::array<float,2>{0.0323596746f, 0.141856179f},
std::array<float,2>{0.201911986f, 0.884906828f},
std::array<float,2>{0.934107304f, 0.0897863209f},
std::array<float,2>{0.521068633f, 0.614954174f},
std::array<float,2>{0.469775915f, 0.42411238f},
std::array<float,2>{0.312205225f, 0.973005772f},
std::array<float,2>{0.709163547f, 0.0590748787f},
std::array<float,2>{0.789875269f, 0.542158306f},
std::array<float,2>{0.0948834866f, 0.451120675f},
std::array<float,2>{0.138196945f, 0.677782834f},
std::array<float,2>{0.970748782f, 0.253476232f},
std::array<float,2>{0.579330623f, 0.834783316f},
std::array<float,2>{0.415571928f, 0.202012554f},
std::array<float,2>{0.467798531f, 0.564701259f},
std::array<float,2>{0.556988537f, 0.387736738f},
std::array<float,2>{0.897583365f, 0.937430024f},
std::array<float,2>{0.2374219f, 0.10907083f},
std::array<float,2>{0.0251401775f, 0.752659261f},
std::array<float,2>{0.812536776f, 0.186527371f},
std::array<float,2>{0.654566288f, 0.719652474f},
std::array<float,2>{0.330572009f, 0.357119799f},
std::array<float,2>{0.321822822f, 0.783744216f},
std::array<float,2>{0.629950404f, 0.12748605f},
std::array<float,2>{0.842705131f, 0.697947264f},
std::array<float,2>{0.00317999674f, 0.314698637f},
std::array<float,2>{0.229391798f, 0.602913082f},
std::array<float,2>{0.880471647f, 0.40661037f},
std::array<float,2>{0.53897351f, 0.894581854f},
std::array<float,2>{0.44600752f, 0.070961453f},
std::array<float,2>{0.437035769f, 0.629324079f},
std::array<float,2>{0.571874022f, 0.290103137f},
std::array<float,2>{0.999075472f, 0.861589611f},
std::array<float,2>{0.140857831f, 0.233087167f},
std::array<float,2>{0.111783579f, 0.938701749f},
std::array<float,2>{0.796927869f, 0.0178311877f},
std::array<float,2>{0.691585481f, 0.513702512f},
std::array<float,2>{0.29170537f, 0.497902811f},
std::array<float,2>{0.494573742f, 0.91179651f},
std::array<float,2>{0.510733485f, 0.124448173f},
std::array<float,2>{0.917477965f, 0.587459505f},
std::array<float,2>{0.203476712f, 0.403808117f},
std::array<float,2>{0.0581548922f, 0.742411077f},
std::array<float,2>{0.844007075f, 0.36434117f},
std::array<float,2>{0.661031842f, 0.772674263f},
std::array<float,2>{0.352850527f, 0.16570577f},
std::array<float,2>{0.25469923f, 0.56161654f},
std::array<float,2>{0.724502444f, 0.459131628f},
std::array<float,2>{0.768128514f, 0.987408936f},
std::array<float,2>{0.0786182508f, 0.042538695f},
std::array<float,2>{0.174400732f, 0.81499958f},
std::array<float,2>{0.937602043f, 0.216939852f},
std::array<float,2>{0.601357698f, 0.662430525f},
std::array<float,2>{0.386427879f, 0.270546675f},
std::array<float,2>{0.44221431f, 0.774848342f},
std::array<float,2>{0.541956425f, 0.161365375f},
std::array<float,2>{0.885713816f, 0.739838183f},
std::array<float,2>{0.220216021f, 0.371566772f},
std::array<float,2>{0.0113577163f, 0.579187453f},
std::array<float,2>{0.833759665f, 0.39633128f},
std::array<float,2>{0.640606403f, 0.91484046f},
std::array<float,2>{0.314939737f, 0.109675363f},
std::array<float,2>{0.282116055f, 0.667621076f},
std::array<float,2>{0.698000491f, 0.280542552f},
std::array<float,2>{0.807942271f, 0.826490819f},
std::array<float,2>{0.119642474f, 0.207425669f},
std::array<float,2>{0.152249902f, 0.994685411f},
std::array<float,2>{0.989306688f, 0.0334448777f},
std::array<float,2>{0.569723189f, 0.55379194f},
std::array<float,2>{0.425632894f, 0.465749502f},
std::array<float,2>{0.345451683f, 0.901646316f},
std::array<float,2>{0.671708703f, 0.066326119f},
std::array<float,2>{0.855012715f, 0.594924629f},
std::array<float,2>{0.0535083003f, 0.420423329f},
std::array<float,2>{0.217717737f, 0.688036799f},
std::array<float,2>{0.90665108f, 0.322370887f},
std::array<float,2>{0.504778624f, 0.789231896f},
std::array<float,2>{0.490353525f, 0.134091228f},
std::array<float,2>{0.375040025f, 0.504584014f},
std::array<float,2>{0.605990469f, 0.489888459f},
std::array<float,2>{0.952682555f, 0.949933827f},
std::array<float,2>{0.181979612f, 0.0243427493f},
std::array<float,2>{0.0909060687f, 0.869813085f},
std::array<float,2>{0.777542949f, 0.223359317f},
std::array<float,2>{0.73104763f, 0.63838762f},
std::array<float,2>{0.258128017f, 0.283724785f},
std::array<float,2>{0.274096072f, 0.837011337f},
std::array<float,2>{0.744173467f, 0.187527746f},
std::array<float,2>{0.760019183f, 0.68401885f},
std::array<float,2>{0.0649147555f, 0.260560542f},
std::array<float,2>{0.160218582f, 0.535777509f},
std::array<float,2>{0.966464043f, 0.440680504f},
std::array<float,2>{0.61910969f, 0.982960284f},
std::array<float,2>{0.39188236f, 0.050488852f},
std::array<float,2>{0.478875816f, 0.729738832f},
std::array<float,2>{0.52879113f, 0.344057858f},
std::array<float,2>{0.923885405f, 0.760333717f},
std::array<float,2>{0.187802628f, 0.172606781f},
std::array<float,2>{0.0410389006f, 0.924528897f},
std::array<float,2>{0.869750798f, 0.0940210298f},
std::array<float,2>{0.685667694f, 0.57139653f},
std::array<float,2>{0.374745488f, 0.381558597f},
std::array<float,2>{0.410062134f, 0.962168872f},
std::array<float,2>{0.589743555f, 0.00572682824f},
std::array<float,2>{0.977992535f, 0.523436487f},
std::array<float,2>{0.131500259f, 0.481979489f},
std::array<float,2>{0.103148252f, 0.647278666f},
std::array<float,2>{0.783618033f, 0.299844533f},
std::array<float,2>{0.712582707f, 0.843854547f},
std::array<float,2>{0.296922088f, 0.236224279f},
std::array<float,2>{0.342378229f, 0.618726552f},
std::array<float,2>{0.645941436f, 0.432489932f},
std::array<float,2>{0.823313594f, 0.877453864f},
std::array<float,2>{0.0173686706f, 0.0818014145f},
std::array<float,2>{0.249624446f, 0.806668818f},
std::array<float,2>{0.902849019f, 0.152108461f},
std::array<float,2>{0.549048305f, 0.70929569f},
std::array<float,2>{0.454639465f, 0.339140534f},
std::array<float,2>{0.42912516f, 0.801063716f},
std::array<float,2>{0.563814461f, 0.146388888f},
std::array<float,2>{0.985840976f, 0.716887712f},
std::array<float,2>{0.155464828f, 0.3313196f},
std::array<float,2>{0.123882234f, 0.610855937f},
std::array<float,2>{0.808654845f, 0.427805841f},
std::array<float,2>{0.702697098f, 0.890408516f},
std::array<float,2>{0.285220832f, 0.09329734f},
std::array<float,2>{0.317285687f, 0.653652966f},
std::array<float,2>{0.634557784f, 0.312301666f},
std::array<float,2>{0.83149749f, 0.856558263f},
std::array<float,2>{0.0154928565f, 0.245782569f},
std::array<float,2>{0.224191844f, 0.954196751f},
std::array<float,2>{0.888774812f, 0.0143245216f},
std::array<float,2>{0.545466065f, 0.531011105f},
std::array<float,2>{0.439819723f, 0.470890433f},
std::array<float,2>{0.263966531f, 0.932807624f},
std::array<float,2>{0.727528334f, 0.105378129f},
std::array<float,2>{0.773457885f, 0.567871511f},
std::array<float,2>{0.0870598927f, 0.386498123f},
std::array<float,2>{0.186593592f, 0.726530492f},
std::array<float,2>{0.94903636f, 0.353037119f},
std::array<float,2>{0.604708314f, 0.757485092f},
std::array<float,2>{0.381964326f, 0.181407616f},
std::array<float,2>{0.484585881f, 0.545991004f},
std::array<float,2>{0.500098467f, 0.448050976f},
std::array<float,2>{0.913683712f, 0.971158326f},
std::array<float,2>{0.211951882f, 0.0568984151f},
std::array<float,2>{0.0501320027f, 0.831584394f},
std::array<float,2>{0.858241379f, 0.198741063f},
std::array<float,2>{0.664638877f, 0.67319864f},
std::array<float,2>{0.347779363f, 0.254987419f},
std::array<float,2>{0.368218392f, 0.864421785f},
std::array<float,2>{0.683120131f, 0.229842037f},
std::array<float,2>{0.872693121f, 0.625638247f},
std::array<float,2>{0.0461226925f, 0.294298768f},
std::array<float,2>{0.194862574f, 0.509305835f},
std::array<float,2>{0.92893523f, 0.494850457f},
std::array<float,2>{0.52431792f, 0.942364395f},
std::array<float,2>{0.482455969f, 0.02038729f},
std::array<float,2>{0.394942492f, 0.702849805f},
std::array<float,2>{0.624037087f, 0.318081051f},
std::array<float,2>{0.963323236f, 0.786501408f},
std::array<float,2>{0.157180652f, 0.131811529f},
std::array<float,2>{0.0689287633f, 0.892265499f},
std::array<float,2>{0.761780143f, 0.0749478042f},
std::array<float,2>{0.749609947f, 0.606668532f},
std::array<float,2>{0.280866355f, 0.410697252f},
std::array<float,2>{0.459952712f, 0.989005268f},
std::array<float,2>{0.553952932f, 0.0447551422f},
std::array<float,2>{0.90007174f, 0.556738436f},
std::array<float,2>{0.243676975f, 0.456534535f},
std::array<float,2>{0.021371549f, 0.658802152f},
std::array<float,2>{0.824891925f, 0.269306481f},
std::array<float,2>{0.64180088f, 0.817753017f},
std::array<float,2>{0.33911401f, 0.212677523f},
std::array<float,2>{0.303587198f, 0.592572093f},
std::array<float,2>{0.717395604f, 0.399499327f},
std::array<float,2>{0.785680294f, 0.907693624f},
std::array<float,2>{0.106631555f, 0.120570637f},
std::array<float,2>{0.125516981f, 0.766848266f},
std::array<float,2>{0.982650518f, 0.169343099f},
std::array<float,2>{0.590725005f, 0.747525632f},
std::array<float,2>{0.411724061f, 0.362195075f},
std::array<float,2>{0.473109007f, 0.82343328f},
std::array<float,2>{0.519161403f, 0.204298675f},
std::array<float,2>{0.930443168f, 0.671683371f},
std::array<float,2>{0.195952684f, 0.274422497f},
std::array<float,2>{0.0355343372f, 0.549257159f},
std::array<float,2>{0.866263509f, 0.461611658f},
std::array<float,2>{0.678223252f, 0.998232305f},
std::array<float,2>{0.360390961f, 0.0356768519f},
std::array<float,2>{0.268091679f, 0.735035717f},
std::array<float,2>{0.736918271f, 0.371001244f},
std::array<float,2>{0.750180781f, 0.781143248f},
std::array<float,2>{0.0717041641f, 0.16009374f},
std::array<float,2>{0.170890912f, 0.920302987f},
std::array<float,2>{0.959850013f, 0.11619892f},
std::array<float,2>{0.615725994f, 0.583529711f},
std::array<float,2>{0.40415293f, 0.39213562f},
std::array<float,2>{0.335785598f, 0.947508991f},
std::array<float,2>{0.651148498f, 0.0283562578f},
std::array<float,2>{0.818636715f, 0.500138581f},
std::array<float,2>{0.0274496563f, 0.487519115f},
std::array<float,2>{0.238595814f, 0.636713684f},
std::array<float,2>{0.892571867f, 0.28902927f},
std::array<float,2>{0.55935055f, 0.871654809f},
std::array<float,2>{0.463140607f, 0.219659358f},
std::array<float,2>{0.419158876f, 0.598677456f},
std::array<float,2>{0.585392416f, 0.415185541f},
std::array<float,2>{0.972848356f, 0.905853391f},
std::array<float,2>{0.133521497f, 0.0694709122f},
std::array<float,2>{0.0984888077f, 0.796401143f},
std::array<float,2>{0.793411314f, 0.13997671f},
std::array<float,2>{0.703439236f, 0.691682577f},
std::array<float,2>{0.307904959f, 0.327176929f},
std::array<float,2>{0.295809507f, 0.762160599f},
std::array<float,2>{0.68804729f, 0.179402307f},
std::array<float,2>{0.80295217f, 0.733283341f},
std::array<float,2>{0.115533948f, 0.348319978f},
std::array<float,2>{0.148034051f, 0.575607896f},
std::array<float,2>{0.992724776f, 0.377903014f},
std::array<float,2>{0.578052819f, 0.928565502f},
std::array<float,2>{0.431175113f, 0.0979187116f},
std::array<float,2>{0.452838928f, 0.680455446f},
std::array<float,2>{0.531693876f, 0.263763905f},
std::array<float,2>{0.876799762f, 0.840220094f},
std::array<float,2>{0.231528431f, 0.192118675f},
std::array<float,2>{0.00568123441f, 0.977223337f},
std::array<float,2>{0.836568177f, 0.0507828705f},
std::array<float,2>{0.627322912f, 0.532425642f},
std::array<float,2>{0.324389726f, 0.442122877f},
std::array<float,2>{0.389511406f, 0.879236102f},
std::array<float,2>{0.596421719f, 0.0852827579f},
std::array<float,2>{0.944006562f, 0.624709487f},
std::array<float,2>{0.178862706f, 0.436172992f},
std::array<float,2>{0.0852004588f, 0.706918001f},
std::array<float,2>{0.769671261f, 0.34366709f},
std::array<float,2>{0.721939266f, 0.81197226f},
std::array<float,2>{0.251512945f, 0.15243268f},
std::array<float,2>{0.358500719f, 0.518147171f},
std::array<float,2>{0.658566713f, 0.478964329f},
std::array<float,2>{0.85084188f, 0.967176199f},
std::array<float,2>{0.0595397502f, 0.00134706427f},
std::array<float,2>{0.209995806f, 0.849865079f},
std::array<float,2>{0.919130743f, 0.242157295f},
std::array<float,2>{0.513985872f, 0.641785324f},
std::array<float,2>{0.499516636f, 0.303754091f},
std::array<float,2>{0.417568773f, 0.833139956f},
std::array<float,2>{0.580828488f, 0.199865863f},
std::array<float,2>{0.970460355f, 0.676294506f},
std::array<float,2>{0.139077231f, 0.250479549f},
std::array<float,2>{0.0969912112f, 0.539368391f},
std::array<float,2>{0.791796029f, 0.451411813f},
std::array<float,2>{0.707693577f, 0.975185156f},
std::array<float,2>{0.309944838f, 0.0613415837f},
std::array<float,2>{0.329086572f, 0.72137624f},
std::array<float,2>{0.65374583f, 0.358317077f},
std::array<float,2>{0.815947354f, 0.750408351f},
std::array<float,2>{0.0258051325f, 0.184161022f},
std::array<float,2>{0.235350817f, 0.933662176f},
std::array<float,2>{0.894858837f, 0.107271805f},
std::array<float,2>{0.555897593f, 0.564082265f},
std::array<float,2>{0.465948015f, 0.390283883f},
std::array<float,2>{0.271449417f, 0.960149169f},
std::array<float,2>{0.741799772f, 0.0114228241f},
std::array<float,2>{0.757059216f, 0.526248574f},
std::array<float,2>{0.0760218278f, 0.472941637f},
std::array<float,2>{0.164414346f, 0.6492818f},
std::array<float,2>{0.953715682f, 0.308273464f},
std::array<float,2>{0.610383034f, 0.852672696f},
std::array<float,2>{0.401640654f, 0.246137783f},
std::array<float,2>{0.471585006f, 0.616130769f},
std::array<float,2>{0.523193538f, 0.423130244f},
std::array<float,2>{0.936822236f, 0.882912755f},
std::array<float,2>{0.200537592f, 0.0872243568f},
std::array<float,2>{0.0341355726f, 0.79712975f},
std::array<float,2>{0.862132668f, 0.143896654f},
std::array<float,2>{0.672424078f, 0.713332057f},
std::array<float,2>{0.364252985f, 0.335441262f},
std::array<float,2>{0.355139524f, 0.771211445f},
std::array<float,2>{0.663551986f, 0.167801484f},
std::array<float,2>{0.846771598f, 0.745537341f},
std::array<float,2>{0.0552212894f, 0.365847826f},
std::array<float,2>{0.206353486f, 0.588581324f},
std::array<float,2>{0.914818943f, 0.40501371f},
std::array<float,2>{0.507888794f, 0.912259161f},
std::array<float,2>{0.493932992f, 0.122521043f},
std::array<float,2>{0.383865207f, 0.661813021f},
std::array<float,2>{0.599466443f, 0.272614956f},
std::array<float,2>{0.940834224f, 0.812574625f},
std::array<float,2>{0.17321527f, 0.216541573f},
std::array<float,2>{0.0812852681f, 0.985512555f},
std::array<float,2>{0.766297877f, 0.0399381109f},
std::array<float,2>{0.725984275f, 0.559699476f},
std::array<float,2>{0.255871505f, 0.457853258f},
std::array<float,2>{0.448604137f, 0.896610379f},
std::array<float,2>{0.537092388f, 0.0733457804f},
std::array<float,2>{0.882657826f, 0.603625834f},
std::array<float,2>{0.228176236f, 0.408614427f},
std::array<float,2>{0.00130258664f, 0.696547866f},
std::array<float,2>{0.841375291f, 0.313951105f},
std::array<float,2>{0.630892813f, 0.781744301f},
std::array<float,2>{0.32411167f, 0.126381636f},
std::array<float,2>{0.290658146f, 0.51349777f},
std::array<float,2>{0.694948137f, 0.499703646f},
std::array<float,2>{0.799046814f, 0.941207767f},
std::array<float,2>{0.111126222f, 0.0174720604f},
std::array<float,2>{0.143812016f, 0.85974735f},
std::array<float,2>{0.997380018f, 0.232060879f},
std::array<float,2>{0.572434306f, 0.631971896f},
std::array<float,2>{0.434261739f, 0.291301101f},
std::array<float,2>{0.488445371f, 0.792529583f},
std::array<float,2>{0.506618977f, 0.135225788f},
std::array<float,2>{0.909687817f, 0.690203905f},
std::array<float,2>{0.21572943f, 0.321304768f},
std::array<float,2>{0.0514055677f, 0.597187161f},
std::array<float,2>{0.853117168f, 0.418791205f},
std::array<float,2>{0.669902146f, 0.899693489f},
std::array<float,2>{0.34589991f, 0.0635732785f},
std::array<float,2>{0.25984633f, 0.639278471f},
std::array<float,2>{0.733376324f, 0.283028603f},
std::array<float,2>{0.779304266f, 0.869059503f},
std::array<float,2>{0.0923987478f, 0.226494536f},
std::array<float,2>{0.180507809f, 0.953031182f},
std::array<float,2>{0.950934291f, 0.0264862943f},
std::array<float,2>{0.609125495f, 0.507335544f},
std::array<float,2>{0.378569365f, 0.491830647f},
std::array<float,2>{0.313349128f, 0.917873144f},
std::array<float,2>{0.636813343f, 0.111639388f},
std::array<float,2>{0.834525049f, 0.581956029f},
std::array<float,2>{0.0089543378f, 0.39761135f},
std::array<float,2>{0.222018734f, 0.741765559f},
std::array<float,2>{0.884742975f, 0.374852568f},
std::array<float,2>{0.540486455f, 0.776638269f},
std::array<float,2>{0.444605052f, 0.162785769f},
std::array<float,2>{0.422350019f, 0.551062107f},
std::array<float,2>{0.568338156f, 0.467619002f},
std::array<float,2>{0.99119848f, 0.993662238f},
std::array<float,2>{0.149389356f, 0.0314262807f},
std::array<float,2>{0.117746949f, 0.825339615f},
std::array<float,2>{0.805330455f, 0.210350454f},
std::array<float,2>{0.696243107f, 0.66589421f},
std::array<float,2>{0.284517199f, 0.27824834f},
std::array<float,2>{0.300039172f, 0.847056627f},
std::array<float,2>{0.714727879f, 0.238243565f},
std::array<float,2>{0.782840431f, 0.646002769f},
std::array<float,2>{0.104294091f, 0.298124999f},
std::array<float,2>{0.130171269f, 0.519610345f},
std::array<float,2>{0.979030788f, 0.483639985f},
std::array<float,2>{0.587014198f, 0.963846266f},
std::array<float,2>{0.407575607f, 0.00626713922f},
std::array<float,2>{0.456422418f, 0.70706749f},
std::array<float,2>{0.547931552f, 0.337802619f},
std::array<float,2>{0.905697703f, 0.806093395f},
std::array<float,2>{0.248029381f, 0.149106786f},
std::array<float,2>{0.0190595593f, 0.875291407f},
std::array<float,2>{0.821269572f, 0.0790501535f},
std::array<float,2>{0.647680163f, 0.62105906f},
std::array<float,2>{0.341414183f, 0.429931015f},
std::array<float,2>{0.394420922f, 0.982172489f},
std::array<float,2>{0.619151473f, 0.0472220443f},
std::array<float,2>{0.968529224f, 0.537393272f},
std::array<float,2>{0.162581339f, 0.439017802f},
std::array<float,2>{0.0627167076f, 0.687307477f},
std::array<float,2>{0.758537292f, 0.259755731f},
std::array<float,2>{0.743335366f, 0.839312494f},
std::array<float,2>{0.276584446f, 0.190504357f},
std::array<float,2>{0.372113019f, 0.573987842f},
std::array<float,2>{0.684902549f, 0.379902393f},
std::array<float,2>{0.868534207f, 0.922472656f},
std::array<float,2>{0.0404684357f, 0.0964252949f},
std::array<float,2>{0.190643772f, 0.757923961f},
std::array<float,2>{0.922960699f, 0.173900634f},
std::array<float,2>{0.530578554f, 0.728486776f},
std::array<float,2>{0.477538109f, 0.346610606f},
std::array<float,2>{0.379352778f, 0.755673587f},
std::array<float,2>{0.602239609f, 0.183388963f},
std::array<float,2>{0.947222173f, 0.723214924f},
std::array<float,2>{0.18387866f, 0.353798866f},
std::array<float,2>{0.0882273838f, 0.568683386f},
std::array<float,2>{0.776317716f, 0.383957446f},
std::array<float,2>{0.728612125f, 0.931393445f},
std::array<float,2>{0.262514174f, 0.103030786f},
std::array<float,2>{0.351499528f, 0.674268961f},
std::array<float,2>{0.667818069f, 0.255909622f},
std::array<float,2>{0.856256843f, 0.828385115f},
std::array<float,2>{0.04712734f, 0.195537314f},
std::array<float,2>{0.214315861f, 0.969863653f},
std::array<float,2>{0.911918581f, 0.0559158921f},
std::array<float,2>{0.502443373f, 0.543173671f},
std::array<float,2>{0.486959279f, 0.445887387f},
std::array<float,2>{0.287578642f, 0.887789667f},
std::array<float,2>{0.699478507f, 0.0909899324f},
std::array<float,2>{0.810788155f, 0.611488223f},
std::array<float,2>{0.121636696f, 0.427085042f},
std::array<float,2>{0.153897583f, 0.716065168f},
std::array<float,2>{0.987871945f, 0.32990396f},
std::array<float,2>{0.566285729f, 0.803172886f},
std::array<float,2>{0.42633006f, 0.148198888f},
std::array<float,2>{0.438127369f, 0.528185129f},
std::array<float,2>{0.544405639f, 0.469536424f},
std::array<float,2>{0.887698889f, 0.956947803f},
std::array<float,2>{0.22630173f, 0.0132665047f},
std::array<float,2>{0.0132395541f, 0.858768344f},
std::array<float,2>{0.829919398f, 0.242396116f},
std::array<float,2>{0.6359272f, 0.65456003f},
std::array<float,2>{0.319956869f, 0.309654057f},
std::array<float,2>{0.336167246f, 0.819654286f},
std::array<float,2>{0.644477665f, 0.214276865f},
std::array<float,2>{0.827743888f, 0.657167435f},
std::array<float,2>{0.0219235774f, 0.267023623f},
std::array<float,2>{0.24508287f, 0.555875778f},
std::array<float,2>{0.90098083f, 0.454327583f},
std::array<float,2>{0.5525617f, 0.990450084f},
std::array<float,2>{0.45796454f, 0.0450804234f},
std::array<float,2>{0.413069665f, 0.749570429f},
std::array<float,2>{0.593220294f, 0.360579461f},
std::array<float,2>{0.981055915f, 0.769072711f},
std::array<float,2>{0.128164127f, 0.170073733f},
std::array<float,2>{0.107933886f, 0.90838486f},
std::array<float,2>{0.788773835f, 0.119043991f},
std::array<float,2>{0.715599477f, 0.591663063f},
std::array<float,2>{0.301826984f, 0.400506973f},
std::array<float,2>{0.481981456f, 0.944431484f},
std::array<float,2>{0.527310431f, 0.0229677428f},
std::array<float,2>{0.926250577f, 0.510657847f},
std::array<float,2>{0.193048418f, 0.493914336f},
std::array<float,2>{0.0448804051f, 0.628578722f},
std::array<float,2>{0.874630451f, 0.295120925f},
std::array<float,2>{0.681318581f, 0.865495741f},
std::array<float,2>{0.369242191f, 0.227211401f},
std::array<float,2>{0.278449893f, 0.608460903f},
std::array<float,2>{0.747036338f, 0.413692564f},
std::array<float,2>{0.764108956f, 0.893739045f},
std::array<float,2>{0.0673556626f, 0.0780302286f},
std::array<float,2>{0.15865007f, 0.788824856f},
std::array<float,2>{0.961397231f, 0.13033019f},
std::array<float,2>{0.621894836f, 0.7010656f},
std::array<float,2>{0.397551209f, 0.319501787f},
std::array<float,2>{0.461590141f, 0.874398947f},
std::array<float,2>{0.562374532f, 0.221066758f},
std::array<float,2>{0.892933846f, 0.634490252f},
std::array<float,2>{0.240839899f, 0.285744607f},
std::array<float,2>{0.0300006699f, 0.50273174f},
std::array<float,2>{0.818049133f, 0.484770238f},
std::array<float,2>{0.649331391f, 0.947219431f},
std::array<float,2>{0.333305568f, 0.0303160623f},
std::array<float,2>{0.305882454f, 0.694013178f},
std::array<float,2>{0.706594169f, 0.324304253f},
std::array<float,2>{0.796379924f, 0.794761002f},
std::array<float,2>{0.101412095f, 0.138547391f},
std::array<float,2>{0.136530921f, 0.903963566f},
std::array<float,2>{0.976195693f, 0.0675817057f},
std::array<float,2>{0.58302784f, 0.600570738f},
std::array<float,2>{0.420343816f, 0.416980505f},
std::array<float,2>{0.362924755f, 0.997407317f},
std::array<float,2>{0.676855505f, 0.0381727628f},
std::array<float,2>{0.863423228f, 0.5481444f},
std::array<float,2>{0.0372209065f, 0.463565648f},
std::array<float,2>{0.197356254f, 0.668095112f},
std::array<float,2>{0.933237731f, 0.275512367f},
std::array<float,2>{0.515832007f, 0.821897924f},
std::array<float,2>{0.4762806f, 0.205232218f},
std::array<float,2>{0.404782087f, 0.584562361f},
std::array<float,2>{0.614943743f, 0.393989712f},
std::array<float,2>{0.957768679f, 0.919537306f},
std::array<float,2>{0.167992607f, 0.115189508f},
std::array<float,2>{0.0732236058f, 0.778184652f},
std::array<float,2>{0.752029479f, 0.157649606f},
std::array<float,2>{0.735848129f, 0.73737973f},
std::array<float,2>{0.266863078f, 0.368311882f},
std::array<float,2>{0.252587199f, 0.808692575f},
std::array<float,2>{0.719420075f, 0.155342937f},
std::array<float,2>{0.771606207f, 0.705016136f},
std::array<float,2>{0.0820452869f, 0.341472775f},
std::array<float,2>{0.175798655f, 0.621390045f},
std::array<float,2>{0.942923725f, 0.434277147f},
std::array<float,2>{0.594114482f, 0.88218528f},
std::array<float,2>{0.388018787f, 0.0829027966f},
std::array<float,2>{0.497853786f, 0.642679453f},
std::array<float,2>{0.513165355f, 0.301560014f},
std::array<float,2>{0.921655297f, 0.849584103f},
std::array<float,2>{0.20856522f, 0.23983252f},
std::array<float,2>{0.0610159673f, 0.965371072f},
std::array<float,2>{0.849409044f, 0.00257579167f},
std::array<float,2>{0.657726884f, 0.517558098f},
std::array<float,2>{0.356853217f, 0.477093786f},
std::array<float,2>{0.433052033f, 0.92609024f},
std::array<float,2>{0.575537324f, 0.100950196f},
std::array<float,2>{0.995535433f, 0.577787519f},
std::array<float,2>{0.145963982f, 0.375014901f},
std::array<float,2>{0.114807032f, 0.731453419f},
std::array<float,2>{0.800947964f, 0.350732684f},
std::array<float,2>{0.690980375f, 0.76500982f},
std::array<float,2>{0.2942518f, 0.176238477f},
std::array<float,2>{0.327413738f, 0.534912944f},
std::array<float,2>{0.626797855f, 0.445222437f},
std::array<float,2>{0.839492857f, 0.978855133f},
std::array<float,2>{0.00586049212f, 0.0533290841f},
std::array<float,2>{0.234214112f, 0.843461931f},
std::array<float,2>{0.878363609f, 0.194602385f},
std::array<float,2>{0.534135818f, 0.682679534f},
std::array<float,2>{0.449750692f, 0.262750655f},
std::array<float,2>{0.426845312f, 0.856715441f},
std::array<float,2>{0.565141618f, 0.246032476f},
std::array<float,2>{0.987115204f, 0.653375983f},
std::array<float,2>{0.153090373f, 0.31219551f},
std::array<float,2>{0.122458376f, 0.530915439f},
std::array<float,2>{0.812412858f, 0.471046418f},
std::array<float,2>{0.700404227f, 0.954437673f},
std::array<float,2>{0.288721323f, 0.0146147516f},
std::array<float,2>{0.319081455f, 0.717280805f},
std::array<float,2>{0.63536799f, 0.331158787f},
std::array<float,2>{0.828975797f, 0.800969243f},
std::array<float,2>{0.0118858591f, 0.14618884f},
std::array<float,2>{0.225152448f, 0.890350521f},
std::array<float,2>{0.887029946f, 0.0935789272f},
std::array<float,2>{0.543547988f, 0.611137211f},
std::array<float,2>{0.439280242f, 0.428020447f},
std::array<float,2>{0.263127506f, 0.970886528f},
std::array<float,2>{0.729802191f, 0.0568394996f},
std::array<float,2>{0.77659291f, 0.546328962f},
std::array<float,2>{0.0897878036f, 0.447755903f},
std::array<float,2>{0.184800386f, 0.673093855f},
std::array<float,2>{0.945766866f, 0.255351365f},
std::array<float,2>{0.603450239f, 0.831788361f},
std::array<float,2>{0.380246818f, 0.199046746f},
std::array<float,2>{0.487917036f, 0.568196833f},
std::array<float,2>{0.503869772f, 0.386365503f},
std::array<float,2>{0.910444677f, 0.932997882f},
std::array<float,2>{0.213517442f, 0.105165742f},
std::array<float,2>{0.048132617f, 0.757668972f},
std::array<float,2>{0.857145607f, 0.181211457f},
std::array<float,2>{0.666238725f, 0.726159275f},
std::array<float,2>{0.350012332f, 0.353351712f},
std::array<float,2>{0.370166093f, 0.786136389f},
std::array<float,2>{0.680421233f, 0.131427601f},
std::array<float,2>{0.873317778f, 0.702898562f},
std::array<float,2>{0.043098297f, 0.318182319f},
std::array<float,2>{0.191489562f, 0.606910765f},
std::array<float,2>{0.927615941f, 0.411125571f},
std::array<float,2>{0.526193678f, 0.892546535f},
std::array<float,2>{0.480732024f, 0.0750040412f},
std::array<float,2>{0.396585763f, 0.625815392f},
std::array<float,2>{0.622733474f, 0.2940301f},
std::array<float,2>{0.962753177f, 0.864662826f},
std::array<float,2>{0.159886286f, 0.229638025f},
std::array<float,2>{0.0677131414f, 0.942115307f},
std::array<float,2>{0.765473247f, 0.0201748051f},
std::array<float,2>{0.747648358f, 0.509741604f},
std::array<float,2>{0.277706653f, 0.495091707f},
std::array<float,2>{0.458060443f, 0.907318354f},
std::array<float,2>{0.551315904f, 0.120157026f},
std::array<float,2>{0.901637256f, 0.592310369f},
std::array<float,2>{0.245599732f, 0.399660081f},
std::array<float,2>{0.0227594059f, 0.747307837f},
std::array<float,2>{0.826368034f, 0.36201027f},
std::array<float,2>{0.643472135f, 0.766820371f},
std::array<float,2>{0.337333769f, 0.169176042f},
std::array<float,2>{0.300948411f, 0.55692631f},
std::array<float,2>{0.71671927f, 0.456262708f},
std::array<float,2>{0.787641764f, 0.989197731f},
std::array<float,2>{0.108951814f, 0.0446775146f},
std::array<float,2>{0.127840027f, 0.817589581f},
std::array<float,2>{0.982069433f, 0.212579027f},
std::array<float,2>{0.592150271f, 0.659061074f},
std::array<float,2>{0.413863361f, 0.269124657f},
std::array<float,2>{0.474691421f, 0.780841053f},
std::array<float,2>{0.51688993f, 0.159794122f},
std::array<float,2>{0.931776762f, 0.735216439f},
std::array<float,2>{0.198976249f, 0.370701849f},
std::array<float,2>{0.0383008122f, 0.583861351f},
std::array<float,2>{0.864771664f, 0.392397612f},
std::array<float,2>{0.67667377f, 0.920069873f},
std::array<float,2>{0.361342251f, 0.115856826f},
std::array<float,2>{0.266020894f, 0.671470761f},
std::array<float,2>{0.734516263f, 0.274772435f},
std::array<float,2>{0.75306344f, 0.823707998f},
std::array<float,2>{0.0736780465f, 0.204566896f},
std::array<float,2>{0.16987446f, 0.998462915f},
std::array<float,2>{0.958790481f, 0.0359734222f},
std::array<float,2>{0.613602817f, 0.548891246f},
std::array<float,2>{0.406218708f, 0.461739361f},
std::array<float,2>{0.332547814f, 0.906100154f},
std::array<float,2>{0.649578214f, 0.06973885f},
std::array<float,2>{0.817138076f, 0.598904371f},
std::array<float,2>{0.0304994788f, 0.415516406f},
std::array<float,2>{0.241851255f, 0.691495478f},
std::array<float,2>{0.893792868f, 0.327563584f},
std::array<float,2>{0.560565412f, 0.796633363f},
std::array<float,2>{0.461952746f, 0.139814094f},
std::array<float,2>{0.421359837f, 0.500274122f},
std::array<float,2>{0.582056463f, 0.487582356f},
std::array<float,2>{0.975221097f, 0.947688103f},
std::array<float,2>{0.135243267f, 0.0285752993f},
std::array<float,2>{0.100260757f, 0.871979475f},
std::array<float,2>{0.795653641f, 0.219411254f},
std::array<float,2>{0.70553565f, 0.636266172f},
std::array<float,2>{0.305506706f, 0.288665652f},
std::array<float,2>{0.293100834f, 0.839993298f},
std::array<float,2>{0.690033734f, 0.192168251f},
std::array<float,2>{0.802033484f, 0.680328488f},
std::array<float,2>{0.11377418f, 0.264091909f},
std::array<float,2>{0.144915432f, 0.532573044f},
std::array<float,2>{0.995022118f, 0.442176342f},
std::array<float,2>{0.574754417f, 0.977316022f},
std::array<float,2>{0.432323188f, 0.0511201322f},
std::array<float,2>{0.45067516f, 0.732988954f},
std::array<float,2>{0.534753442f, 0.348600268f},
std::array<float,2>{0.877799749f, 0.761953473f},
std::array<float,2>{0.232933402f, 0.179464787f},
std::array<float,2>{0.00695443712f, 0.928348899f},
std::array<float,2>{0.83851862f, 0.0978141353f},
std::array<float,2>{0.625197291f, 0.575208068f},
std::array<float,2>{0.326835871f, 0.377671152f},
std::array<float,2>{0.386758626f, 0.966845751f},
std::array<float,2>{0.595276892f, 0.00104215799f},
std::array<float,2>{0.941689491f, 0.518464386f},
std::array<float,2>{0.177566558f, 0.478624016f},
std::array<float,2>{0.0833874866f, 0.642056465f},
std::array<float,2>{0.773366392f, 0.304015487f},
std::array<float,2>{0.720670521f, 0.84972471f},
std::array<float,2>{0.253203303f, 0.241941437f},
std::array<float,2>{0.355771214f, 0.624951839f},
std::array<float,2>{0.657162249f, 0.436513811f},
std::array<float,2>{0.847941756f, 0.878979445f},
std::array<float,2>{0.0617368817f, 0.0849631578f},
std::array<float,2>{0.207193896f, 0.811765969f},
std::array<float,2>{0.920246303f, 0.152807042f},
std::array<float,2>{0.511838913f, 0.706685126f},
std::array<float,2>{0.496493042f, 0.343265712f},
std::array<float,2>{0.400990546f, 0.799804628f},
std::array<float,2>{0.609658122f, 0.141769126f},
std::array<float,2>{0.954310238f, 0.712765694f},
std::array<float,2>{0.165392488f, 0.333513319f},
std::array<float,2>{0.0743840784f, 0.615026057f},
std::array<float,2>{0.755968988f, 0.423936039f},
std::array<float,2>{0.740370691f, 0.885204256f},
std::array<float,2>{0.270400941f, 0.0895434618f},
std::array<float,2>{0.364637882f, 0.650684476f},
std::array<float,2>{0.673163414f, 0.305802137f},
std::array<float,2>{0.86317569f, 0.855425656f},
std::array<float,2>{0.0347638093f, 0.249510184f},
std::array<float,2>{0.199729756f, 0.957358003f},
std::array<float,2>{0.936258197f, 0.00921436958f},
std::array<float,2>{0.521865666f, 0.525039673f},
std::array<float,2>{0.471795678f, 0.476198107f},
std::array<float,2>{0.308734357f, 0.937086463f},
std::array<float,2>{0.708525419f, 0.109205693f},
std::array<float,2>{0.792350113f, 0.564456463f},
std::array<float,2>{0.0957593396f, 0.388058394f},
std::array<float,2>{0.139744624f, 0.719419539f},
std::array<float,2>{0.96879673f, 0.357393473f},
std::array<float,2>{0.581922293f, 0.752881408f},
std::array<float,2>{0.416457683f, 0.186962366f},
std::array<float,2>{0.464908153f, 0.54240942f},
std::array<float,2>{0.554741502f, 0.45078212f},
std::array<float,2>{0.896321595f, 0.972875595f},
std::array<float,2>{0.236191779f, 0.0587468483f},
std::array<float,2>{0.0272912886f, 0.834631383f},
std::array<float,2>{0.815326035f, 0.201749042f},
std::array<float,2>{0.652533591f, 0.678077281f},
std::array<float,2>{0.329209059f, 0.253869593f},
std::array<float,2>{0.322539121f, 0.8613922f},
std::array<float,2>{0.63276577f, 0.233308956f},
std::array<float,2>{0.839992821f, 0.628965855f},
std::array<float,2>{0.000610792194f, 0.290496618f},
std::array<float,2>{0.227290317f, 0.514034688f},
std::array<float,2>{0.881076574f, 0.497559011f},
std::array<float,2>{0.535835326f, 0.938838363f},
std::array<float,2>{0.447960168f, 0.0175982397f},
std::array<float,2>{0.435403168f, 0.698157668f},
std::array<float,2>{0.573515594f, 0.314577997f},
std::array<float,2>{0.996864319f, 0.78396976f},
std::array<float,2>{0.143105134f, 0.12779206f},
std::array<float,2>{0.110082805f, 0.894854307f},
std::array<float,2>{0.800222576f, 0.0710584968f},
std::array<float,2>{0.694163501f, 0.602542996f},
std::array<float,2>{0.289803654f, 0.406287968f},
std::array<float,2>{0.492980242f, 0.987668753f},
std::array<float,2>{0.509333491f, 0.0429482721f},
std::array<float,2>{0.915962994f, 0.561855197f},
std::array<float,2>{0.206004322f, 0.459458113f},
std::array<float,2>{0.0561535917f, 0.662296414f},
std::array<float,2>{0.84627229f, 0.270793319f},
std::array<float,2>{0.66305995f, 0.815368056f},
std::array<float,2>{0.354237854f, 0.21707575f},
std::array<float,2>{0.257088453f, 0.587831557f},
std::array<float,2>{0.724956453f, 0.40351662f},
std::array<float,2>{0.767104506f, 0.911869347f},
std::array<float,2>{0.0801032931f, 0.124177642f},
std::array<float,2>{0.172723785f, 0.772876322f},
std::array<float,2>{0.939666688f, 0.166002288f},
std::array<float,2>{0.598529518f, 0.742491305f},
std::array<float,2>{0.382954061f, 0.364569187f},
std::array<float,2>{0.444077015f, 0.826262951f},
std::array<float,2>{0.539583802f, 0.207156822f},
std::array<float,2>{0.883632362f, 0.667945981f},
std::array<float,2>{0.221266717f, 0.280435175f},
std::array<float,2>{0.00802631304f, 0.55396229f},
std::array<float,2>{0.835693836f, 0.465404868f},
std::array<float,2>{0.638160229f, 0.99510181f},
std::array<float,2>{0.314347267f, 0.0335065909f},
std::array<float,2>{0.284129798f, 0.740087092f},
std::array<float,2>{0.696478903f, 0.371281832f},
std::array<float,2>{0.806356013f, 0.774632454f},
std::array<float,2>{0.118901432f, 0.161415264f},
std::array<float,2>{0.149791464f, 0.914597213f},
std::array<float,2>{0.991459131f, 0.109489195f},
std::array<float,2>{0.566801131f, 0.57948786f},
std::array<float,2>{0.423378915f, 0.396012247f},
std::array<float,2>{0.347414076f, 0.950170636f},
std::array<float,2>{0.668559968f, 0.0241433736f},
std::array<float,2>{0.85226053f, 0.504811823f},
std::array<float,2>{0.0522994027f, 0.4900814f},
std::array<float,2>{0.216782004f, 0.638537705f},
std::array<float,2>{0.908280849f, 0.284169495f},
std::array<float,2>{0.507411301f, 0.869918525f},
std::array<float,2>{0.489733696f, 0.2235239f},
std::array<float,2>{0.377540171f, 0.595036447f},
std::array<float,2>{0.607794106f, 0.420837492f},
std::array<float,2>{0.949533641f, 0.901590168f},
std::array<float,2>{0.181256667f, 0.065998584f},
std::array<float,2>{0.0928008854f, 0.789448798f},
std::array<float,2>{0.780733883f, 0.133796573f},
std::array<float,2>{0.733709455f, 0.688451111f},
std::array<float,2>{0.260932058f, 0.322661489f},
std::array<float,2>{0.275529206f, 0.760623872f},
std::array<float,2>{0.742749214f, 0.172666535f},
std::array<float,2>{0.759512126f, 0.729545951f},
std::array<float,2>{0.0637051016f, 0.343937725f},
std::array<float,2>{0.163692713f, 0.571582317f},
std::array<float,2>{0.967745185f, 0.381694943f},
std::array<float,2>{0.620303094f, 0.92468518f},
std::array<float,2>{0.39339301f, 0.0939459577f},
std::array<float,2>{0.477637798f, 0.683812082f},
std::array<float,2>{0.529298127f, 0.260366768f},
std::array<float,2>{0.922530055f, 0.837290645f},
std::array<float,2>{0.189557895f, 0.187933221f},
std::array<float,2>{0.0397377163f, 0.983300984f},
std::array<float,2>{0.867498219f, 0.0506579019f},
std::array<float,2>{0.684550703f, 0.535992742f},
std::array<float,2>{0.37197426f, 0.440616339f},
std::array<float,2>{0.407007694f, 0.877846599f},
std::array<float,2>{0.586069822f, 0.0815518573f},
std::array<float,2>{0.980170131f, 0.619083524f},
std::array<float,2>{0.128966734f, 0.432372242f},
std::array<float,2>{0.105209529f, 0.709097147f},
std::array<float,2>{0.781524956f, 0.338976741f},
std::array<float,2>{0.712948263f, 0.807012975f},
std::array<float,2>{0.299593717f, 0.151864514f},
std::array<float,2>{0.339953333f, 0.523038805f},
std::array<float,2>{0.647392392f, 0.482282043f},
std::array<float,2>{0.821973145f, 0.962119401f},
std::array<float,2>{0.0177558828f, 0.00540096499f},
std::array<float,2>{0.246164247f, 0.844087422f},
std::array<float,2>{0.90457958f, 0.236073762f},
std::array<float,2>{0.547181368f, 0.647118628f},
std::array<float,2>{0.45531258f, 0.300051242f},
std::array<float,2>{0.381394029f, 0.828191578f},
std::array<float,2>{0.603520036f, 0.195765138f},
std::array<float,2>{0.947835326f, 0.673856139f},
std::array<float,2>{0.185708284f, 0.256287873f},
std::array<float,2>{0.086803928f, 0.543436885f},
std::array<float,2>{0.775021136f, 0.446243972f},
std::array<float,2>{0.7281937f, 0.970204175f},
std::array<float,2>{0.265407562f, 0.0558401942f},
std::array<float,2>{0.349070996f, 0.723609209f},
std::array<float,2>{0.665683925f, 0.353719711f},
std::array<float,2>{0.8585127f, 0.755607963f},
std::array<float,2>{0.0492553301f, 0.183206975f},
std::array<float,2>{0.211665362f, 0.931482077f},
std::array<float,2>{0.912923217f, 0.103325434f},
std::array<float,2>{0.501483738f, 0.568477631f},
std::array<float,2>{0.485567659f, 0.384097457f},
std::array<float,2>{0.286359817f, 0.956604064f},
std::array<float,2>{0.701966882f, 0.0135846687f},
std::array<float,2>{0.809649169f, 0.528044224f},
std::array<float,2>{0.124182373f, 0.469283015f},
std::array<float,2>{0.154408425f, 0.654340088f},
std::array<float,2>{0.985338986f, 0.309991986f},
std::array<float,2>{0.563311994f, 0.858519256f},
std::array<float,2>{0.428077072f, 0.242608353f},
std::array<float,2>{0.440850884f, 0.611810446f},
std::array<float,2>{0.546662867f, 0.42693907f},
std::array<float,2>{0.88980943f, 0.887998641f},
std::array<float,2>{0.223366141f, 0.0910921246f},
std::array<float,2>{0.0137026226f, 0.802923799f},
std::array<float,2>{0.830358207f, 0.148099169f},
std::array<float,2>{0.633020341f, 0.715950191f},
std::array<float,2>{0.317564577f, 0.329806864f},
std::array<float,2>{0.337961555f, 0.769476712f},
std::array<float,2>{0.6409024f, 0.170292974f},
std::array<float,2>{0.825485528f, 0.74976629f},
std::array<float,2>{0.0196597576f, 0.360635906f},
std::array<float,2>{0.24244453f, 0.591421545f},
std::array<float,2>{0.899174213f, 0.400787175f},
std::array<float,2>{0.552927494f, 0.908499599f},
std::array<float,2>{0.460099638f, 0.118690029f},
std::array<float,2>{0.410207808f, 0.656858444f},
std::array<float,2>{0.591575146f, 0.266605198f},
std::array<float,2>{0.983398855f, 0.819453835f},
std::array<float,2>{0.126727849f, 0.213917136f},
std::array<float,2>{0.106405221f, 0.990701497f},
std::array<float,2>{0.786558211f, 0.0453686342f},
std::array<float,2>{0.717875659f, 0.556150079f},
std::array<float,2>{0.303809643f, 0.454529166f},
std::array<float,2>{0.483738899f, 0.893839896f},
std::array<float,2>{0.524465621f, 0.0778089315f},
std::array<float,2>{0.927764654f, 0.608779132f},
std::array<float,2>{0.194310725f, 0.414033234f},
std::array<float,2>{0.0456297174f, 0.700733244f},
std::array<float,2>{0.872049749f, 0.319632083f},
std::array<float,2>{0.682216525f, 0.788746059f},
std::array<float,2>{0.367954373f, 0.129943475f},
std::array<float,2>{0.280234337f, 0.510323703f},
std::array<float,2>{0.748408437f, 0.493852526f},
std::array<float,2>{0.762771189f, 0.9448089f},
std::array<float,2>{0.0696095005f, 0.0233096872f},
std::array<float,2>{0.157422364f, 0.865258336f},
std::array<float,2>{0.964386344f, 0.227360889f},
std::array<float,2>{0.623873115f, 0.628700256f},
std::array<float,2>{0.395680338f, 0.29519701f},
std::array<float,2>{0.464501381f, 0.794444203f},
std::array<float,2>{0.559746385f, 0.138425708f},
std::array<float,2>{0.891084552f, 0.694104433f},
std::array<float,2>{0.239845723f, 0.324491411f},
std::array<float,2>{0.0287363753f, 0.600280881f},
std::array<float,2>{0.820295513f, 0.416604012f},
std::array<float,2>{0.651441276f, 0.904116929f},
std::array<float,2>{0.33460182f, 0.067816034f},
std::array<float,2>{0.306880504f, 0.634631753f},
std::array<float,2>{0.704595327f, 0.285890371f},
std::array<float,2>{0.793968201f, 0.874166131f},
std::array<float,2>{0.0995323434f, 0.220806614f},
std::array<float,2>{0.134585604f, 0.946981966f},
std::array<float,2>{0.974471569f, 0.030656008f},
std::array<float,2>{0.584565282f, 0.502460837f},
std::array<float,2>{0.418256015f, 0.484531105f},
std::array<float,2>{0.359828234f, 0.919851959f},
std::array<float,2>{0.679212987f, 0.114982739f},
std::array<float,2>{0.866009295f, 0.584816456f},
std::array<float,2>{0.0362176038f, 0.393653899f},
std::array<float,2>{0.197214693f, 0.737644374f},
std::array<float,2>{0.931412935f, 0.368642926f},
std::array<float,2>{0.518075287f, 0.778048515f},
std::array<float,2>{0.473861963f, 0.157363176f},
std::array<float,2>{0.403131038f, 0.54796505f},
std::array<float,2>{0.616442919f, 0.463787287f},
std::array<float,2>{0.960527718f, 0.997260749f},
std::array<float,2>{0.171441883f, 0.0384694785f},
std::array<float,2>{0.0711093396f, 0.822107136f},
std::array<float,2>{0.751566112f, 0.205448046f},
std::array<float,2>{0.737356603f, 0.668250382f},
std::array<float,2>{0.268579215f, 0.275873244f},
std::array<float,2>{0.250927866f, 0.849364877f},
std::array<float,2>{0.721426368f, 0.240146473f},
std::array<float,2>{0.770999491f, 0.642871439f},
std::array<float,2>{0.0844154581f, 0.301393479f},
std::array<float,2>{0.177750021f, 0.517166257f},
std::array<float,2>{0.945215106f, 0.477513283f},
std::array<float,2>{0.596797943f, 0.96575141f},
std::array<float,2>{0.390188873f, 0.00275294832f},
std::array<float,2>{0.498188317f, 0.704818726f},
std::array<float,2>{0.51521337f, 0.341702729f},
std::array<float,2>{0.918089092f, 0.808954239f},
std::array<float,2>{0.209066406f, 0.155558854f},
std::array<float,2>{0.0601837076f, 0.881924808f},
std::array<float,2>{0.850247502f, 0.0827098265f},
std::array<float,2>{0.659283936f, 0.621289372f},
std::array<float,2>{0.357428432f, 0.434355795f},
std::array<float,2>{0.430265665f, 0.978522122f},
std::array<float,2>{0.57620877f, 0.0534764864f},
std::array<float,2>{0.993552923f, 0.534673154f},
std::array<float,2>{0.147268876f, 0.445042402f},
std::array<float,2>{0.116266102f, 0.683045566f},
std::array<float,2>{0.80373913f, 0.263035208f},
std::array<float,2>{0.689213693f, 0.843634367f},
std::array<float,2>{0.296070904f, 0.194377869f},
std::array<float,2>{0.325383455f, 0.578007817f},
std::array<float,2>{0.628888249f, 0.375355482f},
std::array<float,2>{0.837846756f, 0.92592442f},
std::array<float,2>{0.00475392397f, 0.100704186f},
std::array<float,2>{0.231114328f, 0.764847755f},
std::array<float,2>{0.875793278f, 0.175977334f},
std::array<float,2>{0.532843709f, 0.731852829f},
std::array<float,2>{0.452054888f, 0.351044148f},
std::array<float,2>{0.41493538f, 0.750160038f},
std::array<float,2>{0.578832209f, 0.184347302f},
std::array<float,2>{0.972410202f, 0.721547663f},
std::array<float,2>{0.137537777f, 0.357981086f},
std::array<float,2>{0.0944679752f, 0.564426899f},
std::array<float,2>{0.790683448f, 0.390423954f},
std::array<float,2>{0.710865796f, 0.93390882f},
std::array<float,2>{0.311522782f, 0.107149243f},
std::array<float,2>{0.331560493f, 0.67666769f},
std::array<float,2>{0.655725241f, 0.25016582f},
std::array<float,2>{0.813916385f, 0.833337784f},
std::array<float,2>{0.0237646773f, 0.200179398f},
std::array<float,2>{0.237169102f, 0.975388467f},
std::array<float,2>{0.897175908f, 0.0610900186f},
std::array<float,2>{0.557942092f, 0.53930074f},
std::array<float,2>{0.467584819f, 0.451416254f},
std::array<float,2>{0.2716389f, 0.883221865f},
std::array<float,2>{0.739221632f, 0.0869182125f},
std::array<float,2>{0.755705893f, 0.615826786f},
std::array<float,2>{0.0773420632f, 0.422981024f},
std::array<float,2>{0.167293504f, 0.712981701f},
std::array<float,2>{0.956208169f, 0.335035741f},
std::array<float,2>{0.613061786f, 0.79700315f},
std::array<float,2>{0.399444699f, 0.14371191f},
std::array<float,2>{0.469294608f, 0.525910378f},
std::array<float,2>{0.520195425f, 0.472843766f},
std::array<float,2>{0.934955239f, 0.960244358f},
std::array<float,2>{0.202827811f, 0.0116242478f},
std::array<float,2>{0.0317158476f, 0.852835178f},
std::array<float,2>{0.859906554f, 0.246392861f},
std::array<float,2>{0.674344838f, 0.648980856f},
std::array<float,2>{0.367164314f, 0.308493525f},
std::array<float,2>{0.352034301f, 0.812753141f},
std::array<float,2>{0.661375284f, 0.216585323f},
std::array<float,2>{0.845551729f, 0.662082016f},
std::array<float,2>{0.057105083f, 0.272797048f},
std::array<float,2>{0.204946026f, 0.559838593f},
std::array<float,2>{0.916944325f, 0.457639337f},
std::array<float,2>{0.511520386f, 0.985687912f},
std::array<float,2>{0.495754063f, 0.0396431684f},
std::array<float,2>{0.385419488f, 0.745191038f},
std::array<float,2>{0.599899948f, 0.366017997f},
std::array<float,2>{0.938885152f, 0.771273494f},
std::array<float,2>{0.17565462f, 0.167718843f},
std::array<float,2>{0.0791095942f, 0.91246897f},
std::array<float,2>{0.769352555f, 0.122084863f},
std::array<float,2>{0.723193407f, 0.588828027f},
std::array<float,2>{0.255664974f, 0.405032516f},
std::array<float,2>{0.44724068f, 0.940943062f},
std::array<float,2>{0.537890673f, 0.0172485691f},
std::array<float,2>{0.879791439f, 0.513354599f},
std::array<float,2>{0.230307773f, 0.499916732f},
std::array<float,2>{0.002296953f, 0.632202625f},
std::array<float,2>{0.84351182f, 0.291025639f},
std::array<float,2>{0.629050314f, 0.859601319f},
std::array<float,2>{0.320667893f, 0.232347444f},
std::array<float,2>{0.292474151f, 0.603896201f},
std::array<float,2>{0.692491651f, 0.408342242f},
std::array<float,2>{0.797989309f, 0.896861434f},
std::array<float,2>{0.112567335f, 0.0735147893f},
std::array<float,2>{0.14188914f, 0.782068253f},
std::array<float,2>{0.998840213f, 0.125993699f},
std::array<float,2>{0.571130991f, 0.69648695f},
std::array<float,2>{0.436048239f, 0.313588411f},
std::array<float,2>{0.492029071f, 0.868828833f},
std::array<float,2>{0.50554955f, 0.226310596f},
std::array<float,2>{0.908193052f, 0.639488399f},
std::array<float,2>{0.218289122f, 0.282734543f},
std::array<float,2>{0.0544329025f, 0.507713795f},
std::array<float,2>{0.853968441f, 0.492156476f},
std::array<float,2>{0.670057595f, 0.952657998f},
std::array<float,2>{0.344423473f, 0.0267154425f},
std::array<float,2>{0.259390503f, 0.690139234f},
std::array<float,2>{0.731698513f, 0.321738333f},
std::array<float,2>{0.77918154f, 0.79275322f},
std::array<float,2>{0.0898703709f, 0.134836718f},
std::array<float,2>{0.182872355f, 0.899580359f},
std::array<float,2>{0.951861203f, 0.0637301654f},
std::array<float,2>{0.607347131f, 0.597582459f},
std::array<float,2>{0.375999004f, 0.418671548f},
std::array<float,2>{0.315951198f, 0.994051695f},
std::array<float,2>{0.63930732f, 0.0316412225f},
std::array<float,2>{0.832983792f, 0.551009655f},
std::array<float,2>{0.0101194698f, 0.467376888f},
std::array<float,2>{0.219162986f, 0.665602803f},
std::array<float,2>{0.886580527f, 0.277940452f},
std::array<float,2>{0.542884767f, 0.825640619f},
std::array<float,2>{0.442530334f, 0.210024968f},
std::array<float,2>{0.42410171f, 0.581745088f},
std::array<float,2>{0.568785369f, 0.397764325f},
std::array<float,2>{0.988419473f, 0.917628706f},
std::array<float,2>{0.150465503f, 0.111396611f},
std::array<float,2>{0.120354675f, 0.776370943f},
std::array<float,2>{0.807308257f, 0.162887201f},
std::array<float,2>{0.698993504f, 0.741952062f},
std::array<float,2>{0.282706082f, 0.374713928f},
std::array<float,2>{0.298321784f, 0.805726647f},
std::array<float,2>{0.711795866f, 0.149243489f},
std::array<float,2>{0.784991562f, 0.707282603f},
std::array<float,2>{0.10185241f, 0.337442547f},
std::array<float,2>{0.132365078f, 0.620784223f},
std::array<float,2>{0.976615906f, 0.430026531f},
std::array<float,2>{0.588484228f, 0.875133157f},
std::array<float,2>{0.409088522f, 0.0788330808f},
std::array<float,2>{0.453561395f, 0.646443248f},
std::array<float,2>{0.54987222f, 0.297959745f},
std::array<float,2>{0.903772414f, 0.846766353f},
std::array<float,2>{0.248622298f, 0.237912908f},
std::array<float,2>{0.0157421175f, 0.963525057f},
std::array<float,2>{0.822423995f, 0.00591851771f},
std::array<float,2>{0.644958496f, 0.520005047f},
std::array<float,2>{0.34368062f, 0.483644247f},
std::array<float,2>{0.391357213f, 0.922840297f},
std::array<float,2>{0.617605805f, 0.0966167077f},
std::array<float,2>{0.965389967f, 0.573963821f},
std::array<float,2>{0.161335602f, 0.380204737f},
std::array<float,2>{0.0654303208f, 0.728118122f},
std::array<float,2>{0.761490464f, 0.346377045f},
std::array<float,2>{0.745396554f, 0.758221745f},
std::array<float,2>{0.275319576f, 0.174306765f},
std::array<float,2>{0.373892725f, 0.537116885f},
std::array<float,2>{0.687236845f, 0.439299017f},
std::array<float,2>{0.870657742f, 0.982350647f},
std::array<float,2>{0.0421062857f, 0.0469038524f},
std::array<float,2>{0.189382434f, 0.839034736f},
std::array<float,2>{0.925047755f, 0.190765977f},
std::array<float,2>{0.52811265f, 0.687105119f},
std::array<float,2>{0.479605436f, 0.259285808f},
std::array<float,2>{0.395483702f, 0.863883197f},
std::array<float,2>{0.624594688f, 0.228800505f},
std::array<float,2>{0.963486552f, 0.626744807f},
std::array<float,2>{0.156423792f, 0.293475419f},
std::array<float,2>{0.068730399f, 0.508359551f},
std::array<float,2>{0.762461841f, 0.49608928f},
std::array<float,2>{0.749292016f, 0.94286418f},
std::array<float,2>{0.280336559f, 0.0211066213f},
std::array<float,2>{0.369014859f, 0.701517105f},
std::array<float,2>{0.682940483f, 0.317239165f},
std::array<float,2>{0.872348905f, 0.785457432f},
std::array<float,2>{0.0467051938f, 0.132208198f},
std::array<float,2>{0.19460687f, 0.890643656f},
std::array<float,2>{0.92936182f, 0.075430125f},
std::array<float,2>{0.523646533f, 0.605751991f},
std::array<float,2>{0.483250409f, 0.411500812f},
std::array<float,2>{0.302797258f, 0.989693284f},
std::array<float,2>{0.71718961f, 0.0434936471f},
std::array<float,2>{0.785552323f, 0.557991922f},
std::array<float,2>{0.1072478f, 0.45540458f},
std::array<float,2>{0.125171497f, 0.659397721f},
std::array<float,2>{0.983223975f, 0.26776123f},
std::array<float,2>{0.590077937f, 0.816700697f},
std::array<float,2>{0.411453217f, 0.21169883f},
std::array<float,2>{0.45899421f, 0.593443751f},
std::array<float,2>{0.554586291f, 0.399345577f},
std::array<float,2>{0.899802983f, 0.906659186f},
std::array<float,2>{0.243394852f, 0.119149901f},
std::array<float,2>{0.0206396487f, 0.766546547f},
std::array<float,2>{0.824284375f, 0.168166235f},
std::array<float,2>{0.642452776f, 0.746326685f},
std::array<float,2>{0.339618564f, 0.36256364f},
std::array<float,2>{0.316705436f, 0.801922858f},
std::array<float,2>{0.63408047f, 0.144762516f},
std::array<float,2>{0.83192414f, 0.718294144f},
std::array<float,2>{0.0149632469f, 0.330177337f},
std::array<float,2>{0.223749205f, 0.610129178f},
std::array<float,2>{0.889503896f, 0.429428577f},
std::array<float,2>{0.545347273f, 0.889000058f},
std::array<float,2>{0.440192938f, 0.0921988785f},
std::array<float,2>{0.429679036f, 0.652478576f},
std::array<float,2>{0.564427614f, 0.310751796f},
std::array<float,2>{0.985823452f, 0.855765522f},
std::array<float,2>{0.155853286f, 0.244925708f},
std::array<float,2>{0.123099834f, 0.953581154f},
std::array<float,2>{0.80916065f, 0.0150241954f},
std::array<float,2>{0.702453673f, 0.529559255f},
std::array<float,2>{0.285814613f, 0.472366631f},
std::array<float,2>{0.48512736f, 0.93194145f},
std::array<float,2>{0.50077188f, 0.103753358f},
std::array<float,2>{0.91321975f, 0.566582084f},
std::array<float,2>{0.212704986f, 0.385111064f},
std::array<float,2>{0.0503021739f, 0.724955201f},
std::array<float,2>{0.857806027f, 0.352000773f},
std::array<float,2>{0.664523482f, 0.7562024f},
std::array<float,2>{0.348383427f, 0.179961577f},
std::array<float,2>{0.264337152f, 0.545269012f},
std::array<float,2>{0.726868272f, 0.44855395f},
std::array<float,2>{0.774099708f, 0.97254318f},
std::array<float,2>{0.0877190158f, 0.0583856963f},
std::array<float,2>{0.187331915f, 0.830218196f},
std::array<float,2>{0.948673308f, 0.19754754f},
std::array<float,2>{0.605111003f, 0.672649205f},
std::array<float,2>{0.382423699f, 0.254836023f},
std::array<float,2>{0.452250183f, 0.762845278f},
std::array<float,2>{0.531876683f, 0.178699389f},
std::array<float,2>{0.876074374f, 0.733673632f},
std::array<float,2>{0.232012749f, 0.349097401f},
std::array<float,2>{0.00502374023f, 0.574278951f},
std::array<float,2>{0.836325884f, 0.378102213f},
std::array<float,2>{0.627574146f, 0.928872108f},
std::array<float,2>{0.324907213f, 0.0994309634f},
std::array<float,2>{0.295032322f, 0.681439102f},
std::array<float,2>{0.687749982f, 0.265158027f},
std::array<float,2>{0.80330801f, 0.840918243f},
std::array<float,2>{0.116068006f, 0.193092898f},
std::array<float,2>{0.147474915f, 0.977556884f},
std::array<float,2>{0.992404938f, 0.0520928167f},
std::array<float,2>{0.577525914f, 0.53156209f},
std::array<float,2>{0.430915117f, 0.442426085f},
std::array<float,2>{0.359188527f, 0.880422711f},
std::array<float,2>{0.658829212f, 0.0848377571f},
std::array<float,2>{0.851099193f, 0.623576045f},
std::array<float,2>{0.058917705f, 0.436628014f},
std::array<float,2>{0.210776389f, 0.705889225f},
std::array<float,2>{0.919864714f, 0.34201932f},
std::array<float,2>{0.514506698f, 0.810812294f},
std::array<float,2>{0.499180526f, 0.15363355f},
std::array<float,2>{0.388986051f, 0.519394338f},
std::array<float,2>{0.595921695f, 0.479548514f},
std::array<float,2>{0.943466067f, 0.96823138f},
std::array<float,2>{0.179253861f, 0.000381717226f},
std::array<float,2>{0.0859122351f, 0.851234615f},
std::array<float,2>{0.770475745f, 0.240499422f},
std::array<float,2>{0.722425938f, 0.641049981f},
std::array<float,2>{0.25116688f, 0.303615928f},
std::array<float,2>{0.267645985f, 0.823104441f},
std::array<float,2>{0.736368775f, 0.203980893f},
std::array<float,2>{0.750831306f, 0.67072463f},
std::array<float,2>{0.0718821511f, 0.2743527f},
std::array<float,2>{0.170076355f, 0.550312579f},
std::array<float,2>{0.959430516f, 0.462254792f},
std::array<float,2>{0.61552f, 0.999863744f},
std::array<float,2>{0.403599143f, 0.0370328277f},
std::array<float,2>{0.473214865f, 0.736157775f},
std::array<float,2>{0.518971264f, 0.369349718f},
std::array<float,2>{0.929763675f, 0.779806674f},
std::array<float,2>{0.195415735f, 0.158877701f},
std::array<float,2>{0.0358537398f, 0.921796203f},
std::array<float,2>{0.866939127f, 0.116214834f},
std::array<float,2>{0.677949667f, 0.582878649f},
std::array<float,2>{0.360868424f, 0.390820146f},
std::array<float,2>{0.4195126f, 0.948965132f},
std::array<float,2>{0.585889459f, 0.0273634531f},
std::array<float,2>{0.973249316f, 0.501228094f},
std::array<float,2>{0.132933065f, 0.486971021f},
std::array<float,2>{0.0978096575f, 0.635249913f},
std::array<float,2>{0.79352963f, 0.288009971f},
std::array<float,2>{0.703644633f, 0.872878075f},
std::array<float,2>{0.308354616f, 0.220647633f},
std::array<float,2>{0.335370272f, 0.597676218f},
std::array<float,2>{0.650747597f, 0.414774179f},
std::array<float,2>{0.81916064f, 0.905194283f},
std::array<float,2>{0.0282349102f, 0.0691218898f},
std::array<float,2>{0.239201233f, 0.795846343f},
std::array<float,2>{0.892037094f, 0.139192909f},
std::array<float,2>{0.558877468f, 0.69244051f},
std::array<float,2>{0.463630646f, 0.326946527f},
std::array<float,2>{0.436720699f, 0.784326971f},
std::array<float,2>{0.571676552f, 0.128446728f},
std::array<float,2>{0.999578655f, 0.698250055f},
std::array<float,2>{0.141513661f, 0.315798491f},
std::array<float,2>{0.112299025f, 0.602392793f},
std::array<float,2>{0.797614455f, 0.407438874f},
std::array<float,2>{0.69217211f, 0.895696342f},
std::array<float,2>{0.291239172f, 0.0717325732f},
std::array<float,2>{0.321334124f, 0.630419672f},
std::array<float,2>{0.630481958f, 0.289199263f},
std::array<float,2>{0.84201628f, 0.862680435f},
std::array<float,2>{0.00382983452f, 0.233615398f},
std::array<float,2>{0.228759408f, 0.937871575f},
std::array<float,2>{0.880063832f, 0.0191791151f},
std::array<float,2>{0.538369536f, 0.514717758f},
std::array<float,2>{0.445565909f, 0.496299654f},
std::array<float,2>{0.254386753f, 0.91072768f},
std::array<float,2>{0.724031687f, 0.123211339f},
std::array<float,2>{0.767839789f, 0.586699307f},
std::array<float,2>{0.0783141628f, 0.403225183f},
std::array<float,2>{0.17394796f, 0.74340409f},
std::array<float,2>{0.938081622f, 0.363417953f},
std::array<float,2>{0.600736439f, 0.77216953f},
std::array<float,2>{0.385829031f, 0.164506838f},
std::array<float,2>{0.494907975f, 0.561092615f},
std::array<float,2>{0.510143697f, 0.460178465f},
std::array<float,2>{0.917657852f, 0.987225294f},
std::array<float,2>{0.203937903f, 0.0416217893f},
std::array<float,2>{0.0579147525f, 0.815539837f},
std::array<float,2>{0.844353676f, 0.218341425f},
std::array<float,2>{0.660196602f, 0.663114786f},
std::array<float,2>{0.353459895f, 0.270058334f},
std::array<float,2>{0.365832686f, 0.85361892f},
std::array<float,2>{0.675546288f, 0.248303533f},
std::array<float,2>{0.861180663f, 0.652248859f},
std::array<float,2>{0.0330201127f, 0.305219233f},
std::array<float,2>{0.201575547f, 0.523741186f},
std::array<float,2>{0.934049785f, 0.47502625f},
std::array<float,2>{0.520675659f, 0.958499253f},
std::array<float,2>{0.470404565f, 0.00815539621f},
std::array<float,2>{0.398823291f, 0.711040735f},
std::array<float,2>{0.611738801f, 0.332853496f},
std::array<float,2>{0.955711663f, 0.800393283f},
std::array<float,2>{0.166165039f, 0.14077881f},
std::array<float,2>{0.076208733f, 0.886525035f},
std::array<float,2>{0.754712939f, 0.0881382376f},
std::array<float,2>{0.73934114f, 0.614178121f},
std::array<float,2>{0.272734612f, 0.425136209f},
std::array<float,2>{0.468573362f, 0.973971009f},
std::array<float,2>{0.557214618f, 0.0599621534f},
std::array<float,2>{0.898433626f, 0.541436136f},
std::array<float,2>{0.238001198f, 0.449743658f},
std::array<float,2>{0.0246225838f, 0.679521263f},
std::array<float,2>{0.81331569f, 0.252387285f},
std::array<float,2>{0.654864311f, 0.835012853f},
std::array<float,2>{0.330292344f, 0.202455431f},
std::array<float,2>{0.311843842f, 0.566013455f},
std::array<float,2>{0.709717989f, 0.387204558f},
std::array<float,2>{0.789304495f, 0.936302185f},
std::array<float,2>{0.0955414996f, 0.107955143f},
std::array<float,2>{0.138026506f, 0.753802836f},
std::array<float,2>{0.971267462f, 0.185856745f},
std::array<float,2>{0.579625964f, 0.720495224f},
std::array<float,2>{0.41541642f, 0.355683982f},
std::array<float,2>{0.479415566f, 0.836595118f},
std::array<float,2>{0.528967798f, 0.188672036f},
std::array<float,2>{0.924503803f, 0.684638381f},
std::array<float,2>{0.188169792f, 0.261178732f},
std::array<float,2>{0.0416950732f, 0.53681314f},
std::array<float,2>{0.86938262f, 0.440035909f},
std::array<float,2>{0.686161041f, 0.983532906f},
std::array<float,2>{0.374086797f, 0.049000185f},
std::array<float,2>{0.273613036f, 0.729247212f},
std::array<float,2>{0.745091259f, 0.344939083f},
std::array<float,2>{0.760572195f, 0.761576533f},
std::array<float,2>{0.0653455183f, 0.172906414f},
std::array<float,2>{0.160853028f, 0.925753117f},
std::array<float,2>{0.966000736f, 0.0947791114f},
std::array<float,2>{0.618644536f, 0.571000397f},
std::array<float,2>{0.392491579f, 0.382210672f},
std::array<float,2>{0.341834277f, 0.960979223f},
std::array<float,2>{0.646159947f, 0.00476366561f},
std::array<float,2>{0.824152052f, 0.521963894f},
std::array<float,2>{0.0167356636f, 0.481019825f},
std::array<float,2>{0.249142498f, 0.647931278f},
std::array<float,2>{0.90237242f, 0.299614072f},
std::array<float,2>{0.549366951f, 0.845370591f},
std::array<float,2>{0.454460412f, 0.235049188f},
std::array<float,2>{0.409363329f, 0.617437005f},
std::array<float,2>{0.589274883f, 0.433440685f},
std::array<float,2>{0.978336394f, 0.878617585f},
std::array<float,2>{0.13097471f, 0.0803843886f},
std::array<float,2>{0.103016056f, 0.80808413f},
std::array<float,2>{0.78372848f, 0.150607005f},
std::array<float,2>{0.712319136f, 0.710658014f},
std::array<float,2>{0.297544032f, 0.338298142f},
std::array<float,2>{0.281681776f, 0.77351743f},
std::array<float,2>{0.697547734f, 0.161115885f},
std::array<float,2>{0.808367908f, 0.738405943f},
std::array<float,2>{0.119487956f, 0.372342348f},
std::array<float,2>{0.151819289f, 0.578293502f},
std::array<float,2>{0.989822865f, 0.395139694f},
std::array<float,2>{0.569895208f, 0.915242195f},
std::array<float,2>{0.424892992f, 0.110556364f},
std::array<float,2>{0.441468447f, 0.666396916f},
std::array<float,2>{0.541334033f, 0.279928952f},
std::array<float,2>{0.885230601f, 0.827407837f},
std::array<float,2>{0.220085219f, 0.208868146f},
std::array<float,2>{0.01106284f, 0.995273948f},
std::array<float,2>{0.833484352f, 0.035075102f},
std::array<float,2>{0.639980912f, 0.553453088f},
std::array<float,2>{0.315070629f, 0.466393054f},
std::array<float,2>{0.375618935f, 0.90050441f},
std::array<float,2>{0.605881155f, 0.0646582469f},
std::array<float,2>{0.952610791f, 0.594590843f},
std::array<float,2>{0.182603836f, 0.421043515f},
std::array<float,2>{0.0916456133f, 0.689171612f},
std::array<float,2>{0.778280854f, 0.32369107f},
std::array<float,2>{0.730838299f, 0.790884256f},
std::array<float,2>{0.258414954f, 0.133726269f},
std::array<float,2>{0.345183104f, 0.505594492f},
std::array<float,2>{0.671056926f, 0.489257127f},
std::array<float,2>{0.854614854f, 0.950934589f},
std::array<float,2>{0.0529371127f, 0.024631571f},
std::array<float,2>{0.216911867f, 0.870936096f},
std::array<float,2>{0.906882584f, 0.223758966f},
std::array<float,2>{0.504133403f, 0.636787772f},
std::array<float,2>{0.490935504f, 0.284210235f},
std::array<float,2>{0.412200838f, 0.818851888f},
std::array<float,2>{0.593491137f, 0.212902039f},
std::array<float,2>{0.980687022f, 0.658125818f},
std::array<float,2>{0.128698915f, 0.266140282f},
std::array<float,2>{0.107579015f, 0.555194855f},
std::array<float,2>{0.788384259f, 0.453471243f},
std::array<float,2>{0.7149809f, 0.991669714f},
std::array<float,2>{0.302426904f, 0.0465502478f},
std::array<float,2>{0.33650285f, 0.748211265f},
std::array<float,2>{0.643758476f, 0.360241503f},
std::array<float,2>{0.827553749f, 0.768278122f},
std::array<float,2>{0.0223970171f, 0.171240196f},
std::array<float,2>{0.244417906f, 0.909350216f},
std::array<float,2>{0.900728285f, 0.11796163f},
std::array<float,2>{0.551897824f, 0.590091944f},
std::array<float,2>{0.457346588f, 0.401629359f},
std::array<float,2>{0.278847903f, 0.943386555f},
std::array<float,2>{0.746422648f, 0.0224461276f},
std::array<float,2>{0.764216661f, 0.510892391f},
std::array<float,2>{0.0665290207f, 0.492420316f},
std::array<float,2>{0.158899426f, 0.627121985f},
std::array<float,2>{0.961443841f, 0.296867549f},
std::array<float,2>{0.621284246f, 0.866277874f},
std::array<float,2>{0.398101777f, 0.228327185f},
std::array<float,2>{0.48179698f, 0.608093679f},
std::array<float,2>{0.52662009f, 0.413080454f},
std::array<float,2>{0.926324129f, 0.893376827f},
std::array<float,2>{0.19254972f, 0.0761782676f},
std::array<float,2>{0.0444051474f, 0.788058877f},
std::array<float,2>{0.8743788f, 0.12978898f},
std::array<float,2>{0.681079209f, 0.699779153f},
std::array<float,2>{0.369704306f, 0.318679333f},
std::array<float,2>{0.350817144f, 0.754056752f},
std::array<float,2>{0.667405069f, 0.181822956f},
std::array<float,2>{0.855527401f, 0.723959386f},
std::array<float,2>{0.0474753641f, 0.35512045f},
std::array<float,2>{0.214520991f, 0.56941098f},
std::array<float,2>{0.911339164f, 0.383226156f},
std::array<float,2>{0.502139747f, 0.930414498f},
std::array<float,2>{0.486673862f, 0.10208644f},
std::array<float,2>{0.379554838f, 0.674993336f},
std::array<float,2>{0.601672232f, 0.257499129f},
std::array<float,2>{0.946310937f, 0.82990855f},
std::array<float,2>{0.184476793f, 0.196829766f},
std::array<float,2>{0.0888095722f, 0.969675839f},
std::array<float,2>{0.775471866f, 0.054945007f},
std::array<float,2>{0.729070365f, 0.544796407f},
std::array<float,2>{0.261816621f, 0.447251409f},
std::array<float,2>{0.437553823f, 0.88749826f},
std::array<float,2>{0.544774055f, 0.0901410505f},
std::array<float,2>{0.88832891f, 0.612887084f},
std::array<float,2>{0.225868568f, 0.426443368f},
std::array<float,2>{0.0128933135f, 0.715468109f},
std::array<float,2>{0.829569757f, 0.329078346f},
std::array<float,2>{0.636702299f, 0.804661632f},
std::array<float,2>{0.319356233f, 0.147120088f},
std::array<float,2>{0.287984639f, 0.528441668f},
std::array<float,2>{0.700186372f, 0.470501214f},
std::array<float,2>{0.811104715f, 0.95530206f},
std::array<float,2>{0.121265918f, 0.0122993691f},
std::array<float,2>{0.153598145f, 0.85804081f},
std::array<float,2>{0.987538338f, 0.243581638f},
std::array<float,2>{0.565539241f, 0.655454695f},
std::array<float,2>{0.426257879f, 0.309454471f},
std::array<float,2>{0.497478813f, 0.810492218f},
std::array<float,2>{0.513387501f, 0.15493004f},
std::array<float,2>{0.92120862f, 0.703828096f},
std::array<float,2>{0.208082065f, 0.339959621f},
std::array<float,2>{0.0614755228f, 0.622868717f},
std::array<float,2>{0.849085629f, 0.434747189f},
std::array<float,2>{0.657446623f, 0.881311953f},
std::array<float,2>{0.35715121f, 0.0838502571f},
std::array<float,2>{0.252431035f, 0.644527614f},
std::array<float,2>{0.718987107f, 0.302467436f},
std::array<float,2>{0.772316813f, 0.848442137f},
std::array<float,2>{0.0827998146f, 0.238385469f},
std::array<float,2>{0.176453263f, 0.966191947f},
std::array<float,2>{0.942405164f, 0.00322241383f},
std::array<float,2>{0.594351828f, 0.516548872f},
std::array<float,2>{0.388388872f, 0.477561325f},
std::array<float,2>{0.327671796f, 0.9275949f},
std::array<float,2>{0.626134396f, 0.100533985f},
std::array<float,2>{0.839326382f, 0.576835036f},
std::array<float,2>{0.00652248319f, 0.376873374f},
std::array<float,2>{0.233802766f, 0.731044054f},
std::array<float,2>{0.878660023f, 0.349822879f},
std::array<float,2>{0.533627629f, 0.763923585f},
std::array<float,2>{0.449528813f, 0.177537784f},
std::array<float,2>{0.433114916f, 0.533533037f},
std::array<float,2>{0.575791121f, 0.444288969f},
std::array<float,2>{0.995698392f, 0.980034709f},
std::array<float,2>{0.146140561f, 0.053876169f},
std::array<float,2>{0.114398688f, 0.842529953f},
std::array<float,2>{0.801353157f, 0.194299683f},
std::array<float,2>{0.69068408f, 0.682257414f},
std::array<float,2>{0.294575155f, 0.262613416f},
std::array<float,2>{0.306590647f, 0.873589456f},
std::array<float,2>{0.706441343f, 0.221920565f},
std::array<float,2>{0.796711326f, 0.633778453f},
std::array<float,2>{0.101018056f, 0.286470801f},
std::array<float,2>{0.135836318f, 0.503123343f},
std::array<float,2>{0.975848615f, 0.485439509f},
std::array<float,2>{0.583788335f, 0.94537884f},
std::array<float,2>{0.420761645f, 0.0302591287f},
std::array<float,2>{0.461111814f, 0.694862008f},
std::array<float,2>{0.561607659f, 0.325619161f},
std::array<float,2>{0.893128455f, 0.793694258f},
std::array<float,2>{0.240641326f, 0.137306973f},
std::array<float,2>{0.0296976846f, 0.903273523f},
std::array<float,2>{0.817678392f, 0.0666977316f},
std::array<float,2>{0.648777783f, 0.601403832f},
std::array<float,2>{0.333749473f, 0.417623073f},
std::array<float,2>{0.405028105f, 0.996703506f},
std::array<float,2>{0.614366949f, 0.0379928052f},
std::array<float,2>{0.957352638f, 0.547670841f},
std::array<float,2>{0.16877611f, 0.463914186f},
std::array<float,2>{0.0725876838f, 0.669021249f},
std::array<float,2>{0.752728164f, 0.276626289f},
std::array<float,2>{0.735510647f, 0.820393085f},
std::array<float,2>{0.267192274f, 0.206310377f},
std::array<float,2>{0.36246559f, 0.58568418f},
std::array<float,2>{0.677403808f, 0.393213779f},
std::array<float,2>{0.863932312f, 0.917982101f},
std::array<float,2>{0.0380633585f, 0.113586567f},
std::array<float,2>{0.197799221f, 0.778398931f},
std::array<float,2>{0.932937622f, 0.156466752f},
std::array<float,2>{0.516404867f, 0.736828864f},
std::array<float,2>{0.475817144f, 0.367336869f},
std::array<float,2>{0.384538889f, 0.76961112f},
std::array<float,2>{0.598764777f, 0.166551843f},
std::array<float,2>{0.941115737f, 0.744241416f},
std::array<float,2>{0.173715115f, 0.366794109f},
std::array<float,2>{0.0818772167f, 0.58887291f},
std::array<float,2>{0.765670478f, 0.406128734f},
std::array<float,2>{0.726163685f, 0.913197637f},
std::array<float,2>{0.256424457f, 0.121259779f},
std::array<float,2>{0.354592234f, 0.660537183f},
std::array<float,2>{0.664021611f, 0.271627188f},
std::array<float,2>{0.84746325f, 0.813782096f},
std::array<float,2>{0.0550211854f, 0.214983687f},
std::array<float,2>{0.206709385f, 0.984587967f},
std::array<float,2>{0.914241135f, 0.0405671038f},
std::array<float,2>{0.508546114f, 0.559375286f},
std::array<float,2>{0.493443549f, 0.458030343f},
std::array<float,2>{0.290203482f, 0.897909999f},
std::array<float,2>{0.694418907f, 0.0729010478f},
std::array<float,2>{0.799683213f, 0.604536116f},
std::array<float,2>{0.110802703f, 0.409968674f},
std::array<float,2>{0.144251212f, 0.695573509f},
std::array<float,2>{0.997930229f, 0.312799871f},
std::array<float,2>{0.572774649f, 0.782858014f},
std::array<float,2>{0.43385601f, 0.125623569f},
std::array<float,2>{0.448921591f, 0.512350619f},
std::array<float,2>{0.536278129f, 0.498872727f},
std::array<float,2>{0.882009506f, 0.939565063f},
std::array<float,2>{0.227746263f, 0.0163097531f},
std::array<float,2>{0.00189035281f, 0.861184835f},
std::array<float,2>{0.84094888f, 0.230925158f},
std::array<float,2>{0.631462097f, 0.631656647f},
std::array<float,2>{0.323392004f, 0.292480707f},
std::array<float,2>{0.32844159f, 0.832742393f},
std::array<float,2>{0.654063225f, 0.200502753f},
std::array<float,2>{0.815662086f, 0.677662969f},
std::array<float,2>{0.026230149f, 0.251607537f},
std::array<float,2>{0.23485966f, 0.540784955f},
std::array<float,2>{0.895278811f, 0.452752739f},
std::array<float,2>{0.556323469f, 0.975746095f},
std::array<float,2>{0.466447115f, 0.0624607243f},
std::array<float,2>{0.417373478f, 0.721960008f},
std::array<float,2>{0.580501318f, 0.358514756f},
std::array<float,2>{0.969885588f, 0.751140714f},
std::array<float,2>{0.13960509f, 0.184898779f},
std::array<float,2>{0.0976536348f, 0.935384691f},
std::array<float,2>{0.791042089f, 0.106231242f},
std::array<float,2>{0.707222819f, 0.563218236f},
std::array<float,2>{0.310305506f, 0.38886717f},
std::array<float,2>{0.471097976f, 0.959272325f},
std::array<float,2>{0.522848964f, 0.0100175152f},
std::array<float,2>{0.937465906f, 0.526386499f},
std::array<float,2>{0.201062351f, 0.473651588f},
std::array<float,2>{0.0335000902f, 0.649883747f},
std::array<float,2>{0.861422658f, 0.306988239f},
std::array<float,2>{0.672160268f, 0.851811111f},
std::array<float,2>{0.36330542f, 0.247737333f},
std::array<float,2>{0.270524561f, 0.616956592f},
std::array<float,2>{0.741499364f, 0.422352105f},
std::array<float,2>{0.757476926f, 0.884384453f},
std::array<float,2>{0.0752856135f, 0.0865098983f},
std::array<float,2>{0.164638638f, 0.798295438f},
std::array<float,2>{0.953445911f, 0.142982394f},
std::array<float,2>{0.611236751f, 0.7140522f},
std::array<float,2>{0.401912212f, 0.334770769f},
std::array<float,2>{0.456785679f, 0.845959127f},
std::array<float,2>{0.548774183f, 0.236742005f},
std::array<float,2>{0.906124949f, 0.645016372f},
std::array<float,2>{0.247216299f, 0.297121167f},
std::array<float,2>{0.0186332762f, 0.521455884f},
std::array<float,2>{0.820503414f, 0.483213782f},
std::array<float,2>{0.647969484f, 0.964614511f},
std::array<float,2>{0.341244221f, 0.00703766989f},
std::array<float,2>{0.300442606f, 0.708853126f},
std::array<float,2>{0.714171648f, 0.336683929f},
std::array<float,2>{0.782289684f, 0.805131078f},
std::array<float,2>{0.10378255f, 0.150175452f},
std::array<float,2>{0.130413309f, 0.876098931f},
std::array<float,2>{0.978906691f, 0.0796626657f},
std::array<float,2>{0.587666929f, 0.619848907f},
std::array<float,2>{0.408110738f, 0.430996746f},
std::array<float,2>{0.372881621f, 0.981215894f},
std::array<float,2>{0.685108542f, 0.0485782996f},
std::array<float,2>{0.86902684f, 0.538853586f},
std::array<float,2>{0.0409852378f, 0.437981874f},
std::array<float,2>{0.191103056f, 0.685959399f},
std::array<float,2>{0.923702836f, 0.25822252f},
std::array<float,2>{0.531000912f, 0.838466465f},
std::array<float,2>{0.476581991f, 0.189940855f},
std::array<float,2>{0.394038647f, 0.57244885f},
std::array<float,2>{0.619686127f, 0.379205346f},
std::array<float,2>{0.968229949f, 0.923694015f},
std::array<float,2>{0.163026437f, 0.0972186103f},
std::array<float,2>{0.0633258596f, 0.759691834f},
std::array<float,2>{0.758160889f, 0.175669417f},
std::array<float,2>{0.743734419f, 0.727475345f},
std::array<float,2>{0.276968956f, 0.347549707f},
std::array<float,2>{0.260632962f, 0.791410863f},
std::array<float,2>{0.732619941f, 0.136104107f},
std::array<float,2>{0.779884219f, 0.690717041f},
std::array<float,2>{0.0922437757f, 0.321078092f},
std::array<float,2>{0.180165425f, 0.595752835f},
std::array<float,2>{0.950308859f, 0.419149637f},
std::array<float,2>{0.608852983f, 0.898931324f},
std::array<float,2>{0.378378928f, 0.0626559779f},
std::array<float,2>{0.489046544f, 0.640266478f},
std::array<float,2>{0.505960226f, 0.281565964f},
std::array<float,2>{0.909430146f, 0.867456853f},
std::array<float,2>{0.215183735f, 0.225080028f},
std::array<float,2>{0.0512568913f, 0.952142835f},
std::array<float,2>{0.852584362f, 0.0261850972f},
std::array<float,2>{0.669379473f, 0.506190658f},
std::array<float,2>{0.346361876f, 0.490257144f},
std::array<float,2>{0.422562838f, 0.916755021f},
std::array<float,2>{0.567850173f, 0.112469055f},
std::array<float,2>{0.990312338f, 0.580261409f},
std::array<float,2>{0.148441046f, 0.396834403f},
std::array<float,2>{0.117510639f, 0.740338445f},
std::array<float,2>{0.8050403f, 0.373200983f},
std::array<float,2>{0.695531726f, 0.77555865f},
std::array<float,2>{0.28504777f, 0.16322124f},
std::array<float,2>{0.312905639f, 0.55196476f},
std::array<float,2>{0.637534022f, 0.468462765f},
std::array<float,2>{0.834197521f, 0.99291271f},
std::array<float,2>{0.00935503468f, 0.0322534032f},
std::array<float,2>{0.222379774f, 0.824861526f},
std::array<float,2>{0.883929372f, 0.209078386f},
std::array<float,2>{0.540908754f, 0.664360583f},
std::array<float,2>{0.445280045f, 0.278517634f},
std::array<float,2>{0.419933856f, 0.872077525f},
std::array<float,2>{0.583411694f, 0.220103204f},
std::array<float,2>{0.976506412f, 0.635271728f},
std::array<float,2>{0.136235133f, 0.287481606f},
std::array<float,2>{0.101267755f, 0.501594901f},
std::array<float,2>{0.795985937f, 0.486474723f},
std::array<float,2>{0.706806123f, 0.948436439f},
std::array<float,2>{0.306047618f, 0.027985448f},
std::array<float,2>{0.333037674f, 0.69289583f},
std::array<float,2>{0.649003327f, 0.326423645f},
std::array<float,2>{0.818323553f, 0.79513377f},
std::array<float,2>{0.0301029757f, 0.138700619f},
std::array<float,2>{0.24117361f, 0.904692948f},
std::array<float,2>{0.892600358f, 0.0684049651f},
std::array<float,2>{0.562230349f, 0.59847635f},
std::array<float,2>{0.461802751f, 0.414188385f},
std::array<float,2>{0.26676023f, 0.99917978f},
std::array<float,2>{0.736239433f, 0.0365125872f},
std::array<float,2>{0.752402008f, 0.550041258f},
std::array<float,2>{0.0729930103f, 0.46284011f},
std::array<float,2>{0.16844593f, 0.669926584f},
std::array<float,2>{0.957750201f, 0.273631871f},
std::array<float,2>{0.615014374f, 0.822633624f},
std::array<float,2>{0.404354304f, 0.203353375f},
std::array<float,2>{0.476449668f, 0.582190335f},
std::array<float,2>{0.515876174f, 0.391273677f},
std::array<float,2>{0.933466971f, 0.921081901f},
std::array<float,2>{0.197520509f, 0.117073998f},
std::array<float,2>{0.0375053585f, 0.779318631f},
std::array<float,2>{0.863580704f, 0.158409312f},
std::array<float,2>{0.677223861f, 0.735497594f},
std::array<float,2>{0.363264382f, 0.369916946f},
std::array<float,2>{0.356669188f, 0.811058462f},
std::array<float,2>{0.658103824f, 0.154146075f},
std::array<float,2>{0.849123538f, 0.705216348f},
std::array<float,2>{0.0607155599f, 0.342667818f},
std::array<float,2>{0.208855093f, 0.623430669f},
std::array<float,2>{0.921558678f, 0.437359065f},
std::array<float,2>{0.51282239f, 0.880126894f},
std::array<float,2>{0.497568905f, 0.0843525901f},
std::array<float,2>{0.387857497f, 0.641146302f},
std::array<float,2>{0.593793035f, 0.303152919f},
std::array<float,2>{0.943304002f, 0.851056755f},
std::array<float,2>{0.176166356f, 0.241048992f},
std::array<float,2>{0.0823335499f, 0.968306065f},
std::array<float,2>{0.771966517f, 0.000499712361f},
std::array<float,2>{0.719528794f, 0.518684864f},
std::array<float,2>{0.252854466f, 0.480051339f},
std::array<float,2>{0.450187355f, 0.929620385f},
std::array<float,2>{0.533837676f, 0.0988567024f},
std::array<float,2>{0.878109932f, 0.575158656f},
std::array<float,2>{0.233924493f, 0.378825456f},
std::array<float,2>{0.00622655917f, 0.734175324f},
std::array<float,2>{0.839832723f, 0.349382013f},
std::array<float,2>{0.626664639f, 0.763363779f},
std::array<float,2>{0.327299207f, 0.178221658f},
std::array<float,2>{0.294166505f, 0.532191157f},
std::array<float,2>{0.691368639f, 0.443079531f},
std::array<float,2>{0.801068723f, 0.978314519f},
std::array<float,2>{0.115207925f, 0.0525341071f},
std::array<float,2>{0.145549566f, 0.841652274f},
std::array<float,2>{0.995151758f, 0.192844719f},
std::array<float,2>{0.575293243f, 0.680742025f},
std::array<float,2>{0.432790965f, 0.264670312f},
std::array<float,2>{0.48713398f, 0.756800413f},
std::array<float,2>{0.502816021f, 0.180264443f},
std::array<float,2>{0.911757827f, 0.725534141f},
std::array<float,2>{0.21401459f, 0.352505326f},
std::array<float,2>{0.0470804572f, 0.567166507f},
std::array<float,2>{0.856018066f, 0.385393292f},
std::array<float,2>{0.667665422f, 0.932548523f},
std::array<float,2>{0.351182848f, 0.104015902f},
std::array<float,2>{0.262398154f, 0.672114134f},
std::array<float,2>{0.728810012f, 0.253922284f},
std::array<float,2>{0.775889218f, 0.831051886f},
std::array<float,2>{0.087978825f, 0.19806461f},
std::array<float,2>{0.183606818f, 0.971968055f},
std::array<float,2>{0.946840763f, 0.0578945689f},
std::array<float,2>{0.602394402f, 0.545432508f},
std::array<float,2>{0.378922731f, 0.449032396f},
std::array<float,2>{0.320281029f, 0.889206409f},
std::array<float,2>{0.636117816f, 0.0926540941f},
std::array<float,2>{0.829740226f, 0.609613538f},
std::array<float,2>{0.013431685f, 0.428760529f},
std::array<float,2>{0.226336971f, 0.718098342f},
std::array<float,2>{0.888167441f, 0.330669552f},
std::array<float,2>{0.544079542f, 0.802525878f},
std::array<float,2>{0.438449234f, 0.145396054f},
std::array<float,2>{0.426527292f, 0.530081868f},
std::array<float,2>{0.565995216f, 0.471871167f},
std::array<float,2>{0.988183677f, 0.953769505f},
std::array<float,2>{0.154075906f, 0.0152695794f},
std::array<float,2>{0.122020103f, 0.856199801f},
std::array<float,2>{0.810954928f, 0.244288951f},
std::array<float,2>{0.699288428f, 0.652952313f},
std::array<float,2>{0.287190288f, 0.311337322f},
std::array<float,2>{0.30205375f, 0.816899002f},
std::array<float,2>{0.715417206f, 0.211100787f},
std::array<float,2>{0.788841844f, 0.659972787f},
std::array<float,2>{0.108305089f, 0.268463641f},
std::array<float,2>{0.128248945f, 0.558215678f},
std::array<float,2>{0.981210351f, 0.45584169f},
std::array<float,2>{0.592986941f, 0.989897013f},
std::array<float,2>{0.412608236f, 0.0432427004f},
std::array<float,2>{0.457676172f, 0.747030318f},
std::array<float,2>{0.552435815f, 0.362836719f},
std::array<float,2>{0.9011935f, 0.765975177f},
std::array<float,2>{0.244730368f, 0.168833092f},
std::array<float,2>{0.0215433259f, 0.907008886f},
std::array<float,2>{0.828122854f, 0.119796984f},
std::array<float,2>{0.644228816f, 0.592827022f},
std::array<float,2>{0.336289823f, 0.398789138f},
std::array<float,2>{0.397709638f, 0.943271518f},
std::array<float,2>{0.621740937f, 0.0206059571f},
std::array<float,2>{0.961049139f, 0.508057058f},
std::array<float,2>{0.158241421f, 0.495462596f},
std::array<float,2>{0.0670877099f, 0.626090586f},
std::array<float,2>{0.763817847f, 0.293207794f},
std::array<float,2>{0.746701598f, 0.86361903f},
std::array<float,2>{0.278777629f, 0.229350567f},
std::array<float,2>{0.369435728f, 0.606182694f},
std::array<float,2>{0.681493163f, 0.412095457f},
std::array<float,2>{0.874961913f, 0.891430676f},
std::array<float,2>{0.0445710458f, 0.0758327171f},
std::array<float,2>{0.193268493f, 0.785918653f},
std::array<float,2>{0.925913692f, 0.132461205f},
std::array<float,2>{0.52708143f, 0.701910496f},
std::array<float,2>{0.482254952f, 0.316703349f},
std::array<float,2>{0.378850937f, 0.790362537f},
std::array<float,2>{0.60929817f, 0.133150533f},
std::array<float,2>{0.950847745f, 0.688808322f},
std::array<float,2>{0.180329844f, 0.323990017f},
std::array<float,2>{0.0927595124f, 0.593977332f},
std::array<float,2>{0.779599786f, 0.421773791f},
std::array<float,2>{0.733036339f, 0.900911033f},
std::array<float,2>{0.260038167f, 0.0653600097f},
std::array<float,2>{0.34596023f, 0.637474895f},
std::array<float,2>{0.669644296f, 0.285003364f},
std::array<float,2>{0.853298664f, 0.870144129f},
std::array<float,2>{0.051702641f, 0.224293664f},
std::array<float,2>{0.215467453f, 0.950615346f},
std::array<float,2>{0.910004735f, 0.0253311992f},
std::array<float,2>{0.506493688f, 0.505136013f},
std::array<float,2>{0.488569438f, 0.488592297f},
std::array<float,2>{0.28435412f, 0.915992975f},
std::array<float,2>{0.695970297f, 0.111323066f},
std::array<float,2>{0.805516303f, 0.578748703f},
std::array<float,2>{0.118159622f, 0.394839913f},
std::array<float,2>{0.149105087f, 0.738891602f},
std::array<float,2>{0.990936995f, 0.372927725f},
std::array<float,2>{0.568022966f, 0.774240851f},
std::array<float,2>{0.421923071f, 0.160282135f},
std::array<float,2>{0.444419831f, 0.553099215f},
std::array<float,2>{0.540240347f, 0.466087103f},
std::array<float,2>{0.884311795f, 0.995962739f},
std::array<float,2>{0.22183679f, 0.0342938006f},
std::array<float,2>{0.00921876077f, 0.828055143f},
std::array<float,2>{0.834930301f, 0.20814988f},
std::array<float,2>{0.637096047f, 0.666648507f},
std::array<float,2>{0.313166738f, 0.279772282f},
std::array<float,2>{0.341686338f, 0.845157564f},
std::array<float,2>{0.647707701f, 0.234700739f},
std::array<float,2>{0.820905149f, 0.648318231f},
std::array<float,2>{0.0193005335f, 0.299225658f},
std::array<float,2>{0.247725859f, 0.522096395f},
std::array<float,2>{0.905430079f, 0.480767787f},
std::array<float,2>{0.548226357f, 0.961511314f},
std::array<float,2>{0.456262678f, 0.00402234541f},
std::array<float,2>{0.407296509f, 0.710412204f},
std::array<float,2>{0.587177098f, 0.338664353f},
std::array<float,2>{0.979359806f, 0.808397233f},
std::array<float,2>{0.130084708f, 0.151096404f},
std::array<float,2>{0.104142703f, 0.878363371f},
std::array<float,2>{0.783084631f, 0.0808997154f},
std::array<float,2>{0.714408875f, 0.617765069f},
std::array<float,2>{0.300108135f, 0.433098316f},
std::array<float,2>{0.477068096f, 0.984155297f},
std::array<float,2>{0.530447662f, 0.0496076085f},
std::array<float,2>{0.923337042f, 0.536599576f},
std::array<float,2>{0.190737456f, 0.439623058f},
std::array<float,2>{0.0401771367f, 0.68516767f},
std::array<float,2>{0.868376851f, 0.261496931f},
std::array<float,2>{0.684608281f, 0.836395621f},
std::array<float,2>{0.372412354f, 0.189239398f},
std::array<float,2>{0.276786983f, 0.570713878f},
std::array<float,2>{0.743636131f, 0.382625997f},
std::array<float,2>{0.758632958f, 0.925279796f},
std::array<float,2>{0.0627870709f, 0.0956088901f},
std::array<float,2>{0.162148952f, 0.761007667f},
std::array<float,2>{0.968345046f, 0.173581287f},
std::array<float,2>{0.619593918f, 0.728726447f},
std::array<float,2>{0.394172728f, 0.345370144f},
std::array<float,2>{0.466295183f, 0.835538626f},
std::array<float,2>{0.555942178f, 0.202737167f},
std::array<float,2>{0.894737244f, 0.679136038f},
std::array<float,2>{0.234917507f, 0.252654701f},
std::array<float,2>{0.0254957452f, 0.541979313f},
std::array<float,2>{0.816356897f, 0.44939819f},
std::array<float,2>{0.653327286f, 0.974551439f},
std::array<float,2>{0.328748137f, 0.0603811257f},
std::array<float,2>{0.309755206f, 0.719750643f},
std::array<float,2>{0.70778352f, 0.356366664f},
std::array<float,2>{0.791657746f, 0.753152132f},
std::array<float,2>{0.0968813226f, 0.186362535f},
std::array<float,2>{0.138852268f, 0.935719788f},
std::array<float,2>{0.970386982f, 0.107521862f},
std::array<float,2>{0.580648661f, 0.565712094f},
std::array<float,2>{0.417814732f, 0.387681723f},
std::array<float,2>{0.3638677f, 0.958367467f},
std::array<float,2>{0.672669172f, 0.00855880231f},
std::array<float,2>{0.861994624f, 0.52400279f},
std::array<float,2>{0.0337983295f, 0.475464642f},
std::array<float,2>{0.200268283f, 0.651807368f},
std::array<float,2>{0.936646879f, 0.304824114f},
std::array<float,2>{0.523179293f, 0.854314268f},
std::array<float,2>{0.471391946f, 0.248763576f},
std::array<float,2>{0.401521415f, 0.613463342f},
std::array<float,2>{0.610830188f, 0.425327957f},
std::array<float,2>{0.954086781f, 0.886072099f},
std::array<float,2>{0.164293766f, 0.0887828469f},
std::array<float,2>{0.0757485256f, 0.799872816f},
std::array<float,2>{0.757156968f, 0.1415921f},
std::array<float,2>{0.74203974f, 0.711627245f},
std::array<float,2>{0.271071881f, 0.332484752f},
std::array<float,2>{0.256258428f, 0.771497309f},
std::array<float,2>{0.725681961f, 0.164926305f},
std::array<float,2>{0.766383648f, 0.743806303f},
std::array<float,2>{0.0813604817f, 0.364183217f},
std::array<float,2>{0.172996446f, 0.586212635f},
std::array<float,2>{0.940663278f, 0.402659357f},
std::array<float,2>{0.599287629f, 0.910583079f},
std::array<float,2>{0.384273887f, 0.123580821f},
std::array<float,2>{0.493735343f, 0.663799763f},
std::array<float,2>{0.508289993f, 0.269931853f},
std::array<float,2>{0.914775372f, 0.816318631f},
std::array<float,2>{0.206234574f, 0.217944741f},
std::array<float,2>{0.0555047505f, 0.986733556f},
std::array<float,2>{0.847056866f, 0.0414342284f},
std::array<float,2>{0.663156688f, 0.560804188f},
std::array<float,2>{0.355421662f, 0.460777789f},
std::array<float,2>{0.434372783f, 0.896062195f},
std::array<float,2>{0.57254988f, 0.072213009f},
std::array<float,2>{0.997193635f, 0.601745546f},
std::array<float,2>{0.143654704f, 0.407911032f},
std::array<float,2>{0.111079723f, 0.69918853f},
std::array<float,2>{0.799104631f, 0.316135466f},
std::array<float,2>{0.695127487f, 0.784860492f},
std::array<float,2>{0.290999144f, 0.128372103f},
std::array<float,2>{0.323840499f, 0.515574038f},
std::array<float,2>{0.631141484f, 0.49693644f},
std::array<float,2>{0.841667831f, 0.938059926f},
std::array<float,2>{0.00110281678f, 0.0187396072f},
std::array<float,2>{0.228273407f, 0.863012791f},
std::array<float,2>{0.882459581f, 0.234278783f},
std::array<float,2>{0.536785603f, 0.630215704f},
std::array<float,2>{0.448457181f, 0.28965956f},
std::array<float,2>{0.403850228f, 0.821119428f},
std::array<float,2>{0.616049588f, 0.206932425f},
std::array<float,2>{0.959491253f, 0.669883907f},
std::array<float,2>{0.170421645f, 0.277012438f},
std::array<float,2>{0.0713521168f, 0.547058225f},
std::array<float,2>{0.750264645f, 0.464781135f},
std::array<float,2>{0.737139404f, 0.996506035f},
std::array<float,2>{0.268391222f, 0.0371719673f},
std::array<float,2>{0.360772878f, 0.736353636f},
std::array<float,2>{0.678578973f, 0.367857426f},
std::array<float,2>{0.866500556f, 0.779286504f},
std::array<float,2>{0.0352348983f, 0.156892031f},
std::array<float,2>{0.196260929f, 0.918817222f},
std::array<float,2>{0.930194974f, 0.114161462f},
std::array<float,2>{0.519527614f, 0.585183978f},
std::array<float,2>{0.472798884f, 0.392803758f},
std::array<float,2>{0.307740539f, 0.946276903f},
std::array<float,2>{0.70328331f, 0.0296325218f},
std::array<float,2>{0.793164372f, 0.503532648f},
std::array<float,2>{0.0981710181f, 0.486188531f},
std::array<float,2>{0.133781075f, 0.633261919f},
std::array<float,2>{0.972926199f, 0.287059724f},
std::array<float,2>{0.585187674f, 0.873167634f},
std::array<float,2>{0.419396847f, 0.222269386f},
std::array<float,2>{0.463051766f, 0.600844145f},
std::array<float,2>{0.559138894f, 0.417102575f},
std::array<float,2>{0.892319024f, 0.902390778f},
std::array<float,2>{0.238449544f, 0.0669826642f},
std::array<float,2>{0.0277437046f, 0.793059766f},
std::array<float,2>{0.818405688f, 0.137015045f},
std::array<float,2>{0.650988877f, 0.694563568f},
std::array<float,2>{0.335508853f, 0.326089382f},
std::array<float,2>{0.324626237f, 0.764560223f},
std::array<float,2>{0.627174318f, 0.176790535f},
std::array<float,2>{0.836771131f, 0.730789721f},
std::array<float,2>{0.00560027594f, 0.350217074f},
std::array<float,2>{0.231794238f, 0.576222122f},
std::array<float,2>{0.876663864f, 0.376409501f},
std::array<float,2>{0.531464219f, 0.927006483f},
std::array<float,2>{0.452980399f, 0.0997619256f},
std::array<float,2>{0.431488425f, 0.681906581f},
std::array<float,2>{0.57777679f, 0.262063891f},
std::array<float,2>{0.993125081f, 0.841905534f},
std::array<float,2>{0.148386657f, 0.193780527f},
std::array<float,2>{0.115418859f, 0.979890764f},
std::array<float,2>{0.803109407f, 0.0542180315f},
std::array<float,2>{0.68833226f, 0.533851743f},
std::array<float,2>{0.295560122f, 0.443541914f},
std::array<float,2>{0.499906331f, 0.881572187f},
std::array<float,2>{0.513783097f, 0.083254829f},
std::array<float,2>{0.919336081f, 0.62250942f},
std::array<float,2>{0.210355565f, 0.435325772f},
std::array<float,2>{0.0591307245f, 0.703177154f},
std::array<float,2>{0.850624204f, 0.340334117f},
std::array<float,2>{0.658299327f, 0.809796393f},
std::array<float,2>{0.358645558f, 0.154650137f},
std::array<float,2>{0.251819074f, 0.51575768f},
std::array<float,2>{0.721751213f, 0.478130072f},
std::array<float,2>{0.769783556f, 0.966464639f},
std::array<float,2>{0.0853745714f, 0.00355182006f},
std::array<float,2>{0.178987816f, 0.847864091f},
std::array<float,2>{0.944268465f, 0.239051014f},
std::array<float,2>{0.596658349f, 0.644007206f},
std::array<float,2>{0.389361739f, 0.302236527f},
std::array<float,2>{0.439521819f, 0.803854823f},
std::array<float,2>{0.545661867f, 0.146860659f},
std::array<float,2>{0.889155984f, 0.714927852f},
std::array<float,2>{0.22459273f, 0.32847479f},
std::array<float,2>{0.015274819f, 0.61257565f},
std::array<float,2>{0.831136703f, 0.425888091f},
std::array<float,2>{0.63432318f, 0.886876345f},
std::array<float,2>{0.316961735f, 0.0904507264f},
std::array<float,2>{0.285637707f, 0.655798018f},
std::array<float,2>{0.702926457f, 0.308918417f},
std::array<float,2>{0.809001207f, 0.857863426f},
std::array<float,2>{0.123700388f, 0.243997052f},
std::array<float,2>{0.155529916f, 0.95577389f},
std::array<float,2>{0.986169636f, 0.0118106399f},
std::array<float,2>{0.563669801f, 0.528891563f},
std::array<float,2>{0.428821564f, 0.470187664f},
std::array<float,2>{0.347974271f, 0.93009001f},
std::array<float,2>{0.664858758f, 0.101579174f},
std::array<float,2>{0.857995391f, 0.569884717f},
std::array<float,2>{0.0500170216f, 0.383568734f},
std::array<float,2>{0.21237047f, 0.724568307f},
std::array<float,2>{0.913944542f, 0.354549438f},
std::array<float,2>{0.500466049f, 0.754640996f},
std::array<float,2>{0.484790325f, 0.182282835f},
std::array<float,2>{0.382080883f, 0.54417491f},
std::array<float,2>{0.604900837f, 0.446435571f},
std::array<float,2>{0.94880569f, 0.968832433f},
std::array<float,2>{0.186855763f, 0.0553635545f},
std::array<float,2>{0.0871851519f, 0.829432845f},
std::array<float,2>{0.773723364f, 0.196559891f},
std::array<float,2>{0.727122664f, 0.675403416f},
std::array<float,2>{0.26368323f, 0.257318765f},
std::array<float,2>{0.281145215f, 0.866869867f},
std::array<float,2>{0.749967992f, 0.227648944f},
std::array<float,2>{0.762115777f, 0.627809644f},
std::array<float,2>{0.0690959543f, 0.296079755f},
std::array<float,2>{0.156801507f, 0.51167357f},
std::array<float,2>{0.963058531f, 0.492690355f},
std::array<float,2>{0.624281883f, 0.944124341f},
std::array<float,2>{0.394541711f, 0.0214890093f},
std::array<float,2>{0.482877284f, 0.699568033f},
std::array<float,2>{0.524041831f, 0.318980485f},
std::array<float,2>{0.929043233f, 0.78729713f},
std::array<float,2>{0.195237115f, 0.12921907f},
std::array<float,2>{0.046238035f, 0.892609477f},
std::array<float,2>{0.872938752f, 0.0770472363f},
std::array<float,2>{0.683465958f, 0.60781616f},
std::array<float,2>{0.368482679f, 0.412364572f},
std::array<float,2>{0.411866426f, 0.99202919f},
std::array<float,2>{0.590462863f, 0.0463270172f},
std::array<float,2>{0.982852817f, 0.55473578f},
std::array<float,2>{0.125937998f, 0.453865558f},
std::array<float,2>{0.106770918f, 0.65764451f},
std::array<float,2>{0.786016285f, 0.265802652f},
std::array<float,2>{0.717642069f, 0.818422794f},
std::array<float,2>{0.303310573f, 0.213725388f},
std::array<float,2>{0.338947564f, 0.590786636f},
std::array<float,2>{0.641962886f, 0.401963472f},
std::array<float,2>{0.825192809f, 0.909962356f},
std::array<float,2>{0.0211889651f, 0.117224567f},
std::array<float,2>{0.243993297f, 0.76797992f},
std::array<float,2>{0.900352836f, 0.17159231f},
std::array<float,2>{0.554007709f, 0.748848081f},
std::array<float,2>{0.459546387f, 0.35953021f},
std::array<float,2>{0.425477833f, 0.775994062f},
std::array<float,2>{0.569503665f, 0.163688883f},
std::array<float,2>{0.989646673f, 0.740912139f},
std::array<float,2>{0.151961848f, 0.373600453f},
std::array<float,2>{0.120100781f, 0.580705106f},
std::array<float,2>{0.807621777f, 0.397449613f},
std::array<float,2>{0.697779238f, 0.916201413f},
std::array<float,2>{0.2818425f, 0.113028511f},
std::array<float,2>{0.31451115f, 0.664911568f},
std::array<float,2>{0.640217304f, 0.27884227f},
std::array<float,2>{0.833508968f, 0.824463665f},
std::array<float,2>{0.011504868f, 0.209624335f},
std::array<float,2>{0.220496431f, 0.992412508f},
std::array<float,2>{0.885386586f, 0.0331671275f},
std::array<float,2>{0.541740239f, 0.552400768f},
std::array<float,2>{0.442015141f, 0.468143284f},
std::array<float,2>{0.257885844f, 0.898670912f},
std::array<float,2>{0.731381714f, 0.0634494796f},
std::array<float,2>{0.777604342f, 0.596300066f},
std::array<float,2>{0.091081731f, 0.419715434f},
std::array<float,2>{0.181753442f, 0.691275954f},
std::array<float,2>{0.952975333f, 0.320337802f},
std::array<float,2>{0.606252015f, 0.79186815f},
std::array<float,2>{0.375254124f, 0.136608377f},
std::array<float,2>{0.490534037f, 0.506579995f},
std::array<float,2>{0.504533887f, 0.49102819f},
std::array<float,2>{0.906480551f, 0.951416135f},
std::array<float,2>{0.21743992f, 0.0255964585f},
std::array<float,2>{0.0533746369f, 0.867845118f},
std::array<float,2>{0.855319798f, 0.225512102f},
std::array<float,2>{0.671391845f, 0.639696062f},
std::array<float,2>{0.345531613f, 0.282209873f},
std::array<float,2>{0.374823868f, 0.838288188f},
std::array<float,2>{0.6858899f, 0.190158471f},
std::array<float,2>{0.86994046f, 0.686273456f},
std::array<float,2>{0.0414038338f, 0.258555353f},
std::array<float,2>{0.187677965f, 0.538308203f},
std::array<float,2>{0.924170196f, 0.438256174f},
std::array<float,2>{0.528449178f, 0.980813146f},
std::array<float,2>{0.478680581f, 0.0478859618f},
std::array<float,2>{0.391775936f, 0.726705015f},
std::array<float,2>{0.618706286f, 0.346895754f},
std::array<float,2>{0.966769934f, 0.75891614f},
std::array<float,2>{0.160434738f, 0.175041631f},
std::array<float,2>{0.0646419004f, 0.92287004f},
std::array<float,2>{0.759977877f, 0.0969254002f},
std::array<float,2>{0.744585991f, 0.573168933f},
std::array<float,2>{0.27440235f, 0.379690737f},
std::array<float,2>{0.454834163f, 0.963964581f},
std::array<float,2>{0.549278975f, 0.00753859105f},
std::array<float,2>{0.903238177f, 0.520605564f},
std::array<float,2>{0.249816522f, 0.482465863f},
std::array<float,2>{0.0172228236f, 0.645401537f},
std::array<float,2>{0.823673368f, 0.297695965f},
std::array<float,2>{0.645728171f, 0.84619844f},
std::array<float,2>{0.342622727f, 0.236822888f},
std::array<float,2>{0.297126859f, 0.619271755f},
std::array<float,2>{0.712886095f, 0.431208134f},
std::array<float,2>{0.783203781f, 0.876560509f},
std::array<float,2>{0.103283465f, 0.079583995f},
std::array<float,2>{0.131785065f, 0.805333197f},
std::array<float,2>{0.977592051f, 0.149804145f},
std::array<float,2>{0.589431226f, 0.708185554f},
std::array<float,2>{0.409692258f, 0.336221725f},
std::array<float,2>{0.470170856f, 0.852446318f},
std::array<float,2>{0.521260083f, 0.247470096f},
std::array<float,2>{0.934459925f, 0.650369227f},
std::array<float,2>{0.201733321f, 0.307147086f},
std::array<float,2>{0.0325707197f, 0.527048409f},
std::array<float,2>{0.860729992f, 0.474395305f},
std::array<float,2>{0.675111175f, 0.95963335f},
std::array<float,2>{0.365423977f, 0.0104455324f},
std::array<float,2>{0.273330152f, 0.714462817f},
std::array<float,2>{0.740177214f, 0.334217459f},
std::array<float,2>{0.754070103f, 0.79864198f},
std::array<float,2>{0.0768844932f, 0.143131629f},
std::array<float,2>{0.16685456f, 0.883866727f},
std::array<float,2>{0.955545306f, 0.0862141997f},
std::array<float,2>{0.612103701f, 0.616665184f},
std::array<float,2>{0.399402291f, 0.422838062f},
std::array<float,2>{0.330831707f, 0.976090491f},
std::array<float,2>{0.654514194f, 0.0615309179f},
std::array<float,2>{0.812983274f, 0.540175736f},
std::array<float,2>{0.0251521599f, 0.452401012f},
std::array<float,2>{0.237663165f, 0.676796138f},
std::array<float,2>{0.897848368f, 0.251401454f},
std::array<float,2>{0.556662977f, 0.832143247f},
std::array<float,2>{0.46815896f, 0.201130062f},
std::array<float,2>{0.415822208f, 0.562979817f},
std::array<float,2>{0.579529762f, 0.389484882f},
std::array<float,2>{0.971089005f, 0.934681833f},
std::array<float,2>{0.138429418f, 0.105654269f},
std::array<float,2>{0.0950267762f, 0.751803756f},
std::array<float,2>{0.789573133f, 0.185071751f},
std::array<float,2>{0.709367871f, 0.722558618f},
std::array<float,2>{0.312294543f, 0.358964026f},
std::array<float,2>{0.291875273f, 0.782690167f},
std::array<float,2>{0.691766858f, 0.125374466f},
std::array<float,2>{0.797203183f, 0.696053147f},
std::array<float,2>{0.111537285f, 0.313051522f},
std::array<float,2>{0.141047597f, 0.605078936f},
std::array<float,2>{0.999276698f, 0.409468055f},
std::array<float,2>{0.572204471f, 0.898358405f},
std::array<float,2>{0.437375754f, 0.0726688802f},
std::array<float,2>{0.446247339f, 0.631320655f},
std::array<float,2>{0.538727939f, 0.292034656f},
std::array<float,2>{0.880714834f, 0.860595942f},
std::array<float,2>{0.229197159f, 0.231378615f},
std::array<float,2>{0.00298855361f, 0.940421343f},
std::array<float,2>{0.842499495f, 0.0159182306f},
std::array<float,2>{0.630254805f, 0.511929989f},
std::array<float,2>{0.322112978f, 0.498396337f},
std::array<float,2>{0.386508644f, 0.913596213f},
std::array<float,2>{0.601125419f, 0.121888638f},
std::array<float,2>{0.937906623f, 0.589751899f},
std::array<float,2>{0.174792081f, 0.405503154f},
std::array<float,2>{0.0789716542f, 0.745087206f},
std::array<float,2>{0.76832968f, 0.366603166f},
std::array<float,2>{0.724151969f, 0.770256996f},
std::array<float,2>{0.254637748f, 0.166096076f},
std::array<float,2>{0.352758765f, 0.559072256f},
std::array<float,2>{0.660648942f, 0.458933085f},
std::array<float,2>{0.843922198f, 0.985217333f},
std::array<float,2>{0.0585144721f, 0.040460173f},
std::array<float,2>{0.203162938f, 0.814444125f},
std::array<float,2>{0.917029083f, 0.215588182f},
std::array<float,2>{0.510443389f, 0.66073662f},
std::array<float,2>{0.494281173f, 0.272004366f},
std::array<float,2>{0.389658123f, 0.850231111f},
std::array<float,2>{0.597402155f, 0.241485104f},
std::array<float,2>{0.944676995f, 0.642121732f},
std::array<float,2>{0.178433552f, 0.304427534f},
std::array<float,2>{0.0849258304f, 0.517691195f},
std::array<float,2>{0.770588815f, 0.479079694f},
std::array<float,2>{0.720943451f, 0.96737963f},
std::array<float,2>{0.250396103f, 0.00166133582f},
std::array<float,2>{0.358091652f, 0.706145465f},
std::array<float,2>{0.659846544f, 0.34325552f},
std::array<float,2>{0.849812627f, 0.812494099f},
std::array<float,2>{0.0598543882f, 0.153196707f},
std::array<float,2>{0.209756896f, 0.879797161f},
std::array<float,2>{0.918660641f, 0.0855960846f},
std::array<float,2>{0.514801264f, 0.624480665f},
std::array<float,2>{0.498890996f, 0.435654312f},
std::array<float,2>{0.296813756f, 0.976734638f},
std::array<float,2>{0.688859582f, 0.0517518669f},
std::array<float,2>{0.804295838f, 0.533172309f},
std::array<float,2>{0.116844505f, 0.441765815f},
std::array<float,2>{0.146960989f, 0.679880202f},
std::array<float,2>{0.993843019f, 0.264255792f},
std::array<float,2>{0.576753438f, 0.840420306f},
std::array<float,2>{0.429911315f, 0.19163847f},
std::array<float,2>{0.451436162f, 0.575748682f},
std::array<float,2>{0.532495201f, 0.377210557f},
std::array<float,2>{0.875197291f, 0.927951813f},
std::array<float,2>{0.230921254f, 0.0985286087f},
std::array<float,2>{0.00405143527f, 0.762690485f},
std::array<float,2>{0.837195456f, 0.179062843f},
std::array<float,2>{0.628375769f, 0.732574582f},
std::array<float,2>{0.326145321f, 0.347857386f},
std::array<float,2>{0.334215492f, 0.796111703f},
std::array<float,2>{0.651896536f, 0.14026162f},
std::array<float,2>{0.819698036f, 0.692304015f},
std::array<float,2>{0.0289969407f, 0.327814728f},
std::array<float,2>{0.239555955f, 0.599588037f},
std::array<float,2>{0.891345263f, 0.415864944f},
std::array<float,2>{0.560465276f, 0.905346096f},
std::array<float,2>{0.464332461f, 0.0702067241f},
std::array<float,2>{0.418668181f, 0.635760188f},
std::array<float,2>{0.58405292f, 0.288302571f},
std::array<float,2>{0.973861814f, 0.871196866f},
std::array<float,2>{0.133896589f, 0.219103888f},
std::array<float,2>{0.0990633443f, 0.947925508f},
std::array<float,2>{0.794568598f, 0.0289363526f},
std::array<float,2>{0.704239905f, 0.500894487f},
std::array<float,2>{0.307373285f, 0.488082439f},
std::array<float,2>{0.474317014f, 0.920696735f},
std::array<float,2>{0.51803565f, 0.115710102f},
std::array<float,2>{0.931139588f, 0.583477736f},
std::array<float,2>{0.196607724f, 0.392001629f},
std::array<float,2>{0.0367599875f, 0.734595239f},
std::array<float,2>{0.865429878f, 0.370542645f},
std::array<float,2>{0.679192066f, 0.780359089f},
std::array<float,2>{0.360078365f, 0.159521386f},
std::array<float,2>{0.269049764f, 0.549705029f},
std::array<float,2>{0.737885177f, 0.461237371f},
std::array<float,2>{0.75099349f, 0.998722553f},
std::array<float,2>{0.0703311488f, 0.0355375186f},
std::array<float,2>{0.171159953f, 0.823920727f},
std::array<float,2>{0.960278511f, 0.204634607f},
std::array<float,2>{0.61690414f, 0.670956314f},
std::array<float,2>{0.402633965f, 0.275307626f},
std::array<float,2>{0.460508734f, 0.767347157f},
std::array<float,2>{0.553284287f, 0.169838592f},
std::array<float,2>{0.898883641f, 0.747972906f},
std::array<float,2>{0.242837399f, 0.361744702f},
std::array<float,2>{0.020109864f, 0.592214286f},
std::array<float,2>{0.825978339f, 0.400000632f},
std::array<float,2>{0.641169131f, 0.907957852f},
std::array<float,2>{0.338389069f, 0.120753251f},
std::array<float,2>{0.304224432f, 0.658327699f},
std::array<float,2>{0.718384624f, 0.268789887f},
std::array<float,2>{0.786804318f, 0.818213046f},
std::array<float,2>{0.105584458f, 0.211919844f},
std::array<float,2>{0.126405969f, 0.988664865f},
std::array<float,2>{0.984186053f, 0.0441602021f},
std::array<float,2>{0.591079473f, 0.557421148f},
std::array<float,2>{0.410847664f, 0.456826061f},
std::array<float,2>{0.367342472f, 0.891691446f},
std::array<float,2>{0.681674421f, 0.0742577985f},
std::array<float,2>{0.871178269f, 0.607119024f},
std::array<float,2>{0.0451921523f, 0.410568416f},
std::array<float,2>{0.193712875f, 0.70241183f},
std::array<float,2>{0.928512275f, 0.317787528f},
std::array<float,2>{0.525297701f, 0.786999345f},
std::array<float,2>{0.484244853f, 0.130868495f},
std::array<float,2>{0.396461457f, 0.509276032f},
std::array<float,2>{0.623287976f, 0.494598389f},
std::array<float,2>{0.964082897f, 0.941571832f},
std::array<float,2>{0.158075899f, 0.0199701898f},
std::array<float,2>{0.0698464662f, 0.86491698f},
std::array<float,2>{0.76353848f, 0.2303859f},
std::array<float,2>{0.748867869f, 0.62545836f},
std::array<float,2>{0.279554754f, 0.29463926f},
std::array<float,2>{0.264651209f, 0.831514955f},
std::array<float,2>{0.727549016f, 0.198613122f},
std::array<float,2>{0.774636447f, 0.673717916f},
std::array<float,2>{0.0862419903f, 0.255529583f},
std::array<float,2>{0.186307624f, 0.546760261f},
std::array<float,2>{0.947301626f, 0.44773677f},
std::array<float,2>{0.604035556f, 0.971630096f},
std::array<float,2>{0.381102294f, 0.0572090186f},
std::array<float,2>{0.485887617f, 0.725654483f},
std::array<float,2>{0.501226723f, 0.352716446f},
std::array<float,2>{0.91220963f, 0.757316709f},
std::array<float,2>{0.211354703f, 0.180761799f},
std::array<float,2>{0.0493744537f, 0.933120251f},
std::array<float,2>{0.85928905f, 0.104709566f},
std::array<float,2>{0.665451765f, 0.567606032f},
std::array<float,2>{0.349337071f, 0.386220604f},
std::array<float,2>{0.428266406f, 0.954907656f},
std::array<float,2>{0.562573254f, 0.0138804009f},
std::array<float,2>{0.984694242f, 0.530667663f},
std::array<float,2>{0.15501155f, 0.47121951f},
std::array<float,2>{0.124854296f, 0.65396893f},
std::array<float,2>{0.810066462f, 0.311923683f},
std::array<float,2>{0.701197624f, 0.85740298f},
std::array<float,2>{0.286919534f, 0.245463073f},
std::array<float,2>{0.318200797f, 0.610485256f},
std::array<float,2>{0.633490801f, 0.428332597f},
std::array<float,2>{0.830783606f, 0.889798343f},
std::array<float,2>{0.0142585272f, 0.0929040834f},
std::array<float,2>{0.222728401f, 0.801641524f},
std::array<float,2>{0.890334487f, 0.145801038f},
std::array<float,2>{0.546371639f, 0.717639565f},
std::array<float,2>{0.441330999f, 0.331793129f},
std::array<float,2>{0.408313543f, 0.807496965f},
std::array<float,2>{0.588174939f, 0.15173997f},
std::array<float,2>{0.977411389f, 0.709938884f},
std::array<float,2>{0.13184464f, 0.339600027f},
std::array<float,2>{0.102380551f, 0.618583739f},
std::array<float,2>{0.784325004f, 0.431737155f},
std::array<float,2>{0.711120725f, 0.877203941f},
std::array<float,2>{0.298820674f, 0.0812735111f},
std::array<float,2>{0.34282431f, 0.646565259f},
std::array<float,2>{0.645421565f, 0.300713956f},
std::array<float,2>{0.823117137f, 0.844503939f},
std::array<float,2>{0.01612233f, 0.235623196f},
std::array<float,2>{0.248229399f, 0.96244812f},
std::array<float,2>{0.904260218f, 0.00531441532f},
std::array<float,2>{0.550636172f, 0.522517443f},
std::array<float,2>{0.454081684f, 0.481713027f},
std::array<float,2>{0.274805248f, 0.924239218f},
std::array<float,2>{0.746059179f, 0.0945355818f},
std::array<float,2>{0.761021852f, 0.572173953f},
std::array<float,2>{0.0661041215f, 0.380863279f},
std::array<float,2>{0.161739036f, 0.730189502f},
std::array<float,2>{0.965245545f, 0.344266862f},
std::array<float,2>{0.618030667f, 0.759864509f},
std::array<float,2>{0.390953213f, 0.172317266f},
std::array<float,2>{0.480030894f, 0.535433888f},
std::array<float,2>{0.527410209f, 0.441294074f},
std::array<float,2>{0.925355375f, 0.982480049f},
std::array<float,2>{0.188745528f, 0.049943056f},
std::array<float,2>{0.042523209f, 0.837571561f},
std::array<float,2>{0.870565057f, 0.18840532f},
std::array<float,2>{0.686630905f, 0.684368432f},
std::array<float,2>{0.373066932f, 0.260244429f},
std::array<float,2>{0.344169647f, 0.869583249f},
std::array<float,2>{0.670511782f, 0.223104954f},
std::array<float,2>{0.854348361f, 0.638121426f},
std::array<float,2>{0.0539767221f, 0.283248127f},
std::array<float,2>{0.217966557f, 0.504079282f},
std::array<float,2>{0.907533526f, 0.489364356f},
std::array<float,2>{0.505183756f, 0.949689448f},
std::array<float,2>{0.491545856f, 0.0238004792f},
std::array<float,2>{0.37657693f, 0.687957346f},
std::array<float,2>{0.606722116f, 0.322975218f},
std::array<float,2>{0.951300144f, 0.789741457f},
std::array<float,2>{0.183118567f, 0.13463971f},
std::array<float,2>{0.0905439332f, 0.901910603f},
std::array<float,2>{0.778589785f, 0.0658864379f},
std::array<float,2>{0.732284188f, 0.595582962f},
std::array<float,2>{0.259225309f, 0.420154363f},
std::array<float,2>{0.443262994f, 0.994144201f},
std::array<float,2>{0.542149246f, 0.0340421237f},
std::array<float,2>{0.885818899f, 0.554585516f},
std::array<float,2>{0.219546646f, 0.4652147f},
std::array<float,2>{0.0104943439f, 0.66701138f},
std::array<float,2>{0.832277238f, 0.280827492f},
std::array<float,2>{0.639040351f, 0.826775312f},
std::array<float,2>{0.315617174f, 0.207846642f},
std::array<float,2>{0.282740712f, 0.579623461f},
std::array<float,2>{0.698351085f, 0.395860672f},
std::array<float,2>{0.806834996f, 0.914440811f},
std::array<float,2>{0.120997936f, 0.109925926f},
std::array<float,2>{0.150987774f, 0.775096416f},
std::array<float,2>{0.989002168f, 0.161979526f},
std::array<float,2>{0.568921506f, 0.739679039f},
std::array<float,2>{0.424762696f, 0.372016519f},
std::array<float,2>{0.495315373f, 0.814735889f},
std::array<float,2>{0.510780752f, 0.217585593f},
std::array<float,2>{0.916455388f, 0.662729025f},
std::array<float,2>{0.204339057f, 0.271125525f},
std::array<float,2>{0.0575501844f, 0.56206274f},
std::array<float,2>{0.845073402f, 0.45965147f},
std::array<float,2>{0.661668658f, 0.987887204f},
std::array<float,2>{0.352392167f, 0.0423837863f},
std::array<float,2>{0.255326957f, 0.743100584f},
std::array<float,2>{0.723082066f, 0.364912182f},
std::array<float,2>{0.768623829f, 0.773227274f},
std::array<float,2>{0.0799219161f, 0.165252209f},
std::array<float,2>{0.175281823f, 0.911273837f},
std::array<float,2>{0.939232111f, 0.124942362f},
std::array<float,2>{0.600392878f, 0.587219477f},
std::array<float,2>{0.384778559f, 0.40402627f},
std::array<float,2>{0.320987761f, 0.939052761f},
std::array<float,2>{0.629823983f, 0.0182402041f},
std::array<float,2>{0.84319675f, 0.514451802f},
std::array<float,2>{0.00280778063f, 0.497558594f},
std::array<float,2>{0.229902878f, 0.62965858f},
std::array<float,2>{0.87926966f, 0.290852726f},
std::array<float,2>{0.537235439f, 0.861890376f},
std::array<float,2>{0.446671307f, 0.232769579f},
std::array<float,2>{0.435684741f, 0.603318214f},
std::array<float,2>{0.570667624f, 0.407086462f},
std::array<float,2>{0.998182595f, 0.895146132f},
std::array<float,2>{0.142434463f, 0.0704170689f},
std::array<float,2>{0.113228723f, 0.783447087f},
std::array<float,2>{0.798729241f, 0.127422988f},
std::array<float,2>{0.692883551f, 0.697469354f},
std::array<float,2>{0.29258737f, 0.315378696f},
std::array<float,2>{0.31089139f, 0.75218606f},
std::array<float,2>{0.710238099f, 0.187406346f},
std::array<float,2>{0.790383339f, 0.718969643f},
std::array<float,2>{0.0941190347f, 0.356580973f},
std::array<float,2>{0.137164518f, 0.565262377f},
std::array<float,2>{0.97192955f, 0.388366371f},
std::array<float,2>{0.578302801f, 0.936893165f},
std::array<float,2>{0.414548934f, 0.10842973f},
std::array<float,2>{0.466852844f, 0.678225517f},
std::array<float,2>{0.55831778f, 0.253055453f},
std::array<float,2>{0.896835268f, 0.834346533f},
std::array<float,2>{0.236373484f, 0.201298118f},
std::array<float,2>{0.0239528958f, 0.973473907f},
std::array<float,2>{0.814046502f, 0.0593678616f},
std::array<float,2>{0.656199217f, 0.542828381f},
std::array<float,2>{0.331385016f, 0.450331807f},
std::array<float,2>{0.400104493f, 0.885331988f},
std::array<float,2>{0.612646043f, 0.0889476016f},
std::array<float,2>{0.956905007f, 0.61471504f},
std::array<float,2>{0.167967901f, 0.424786359f},
std::array<float,2>{0.0779289678f, 0.711937666f},
std::array<float,2>{0.75506562f, 0.333100438f},
std::array<float,2>{0.738632023f, 0.798879683f},
std::array<float,2>{0.272358805f, 0.142196298f},
std::array<float,2>{0.366694659f, 0.524802685f},
std::array<float,2>{0.67419976f, 0.476016313f},
std::array<float,2>{0.859767973f, 0.957613766f},
std::array<float,2>{0.0319541432f, 0.00949833728f},
std::array<float,2>{0.20251675f, 0.854949594f},
std::array<float,2>{0.935220242f, 0.249536306f},
std::array<float,2>{0.519920766f, 0.651003659f},
std::array<float,2>{0.469016373f, 0.306267351f},
std::array<float,2>{0.431893528f, 0.84303534f},
std::array<float,2>{0.574488163f, 0.19511655f},
std::array<float,2>{0.994472742f, 0.683241367f},
std::array<float,2>{0.145323426f, 0.263209403f},
std::array<float,2>{0.113679551f, 0.534366846f},
std::array<float,2>{0.802688539f, 0.444409758f},
std::array<float,2>{0.689529419f, 0.979463935f},
std::array<float,2>{0.293560863f, 0.0529296026f},
std::array<float,2>{0.326399714f, 0.732195556f},
std::array<float,2>{0.625711799f, 0.351348966f},
std::array<float,2>{0.838037729f, 0.765330136f},
std::array<float,2>{0.00766497944f, 0.1763293f},
std::array<float,2>{0.232501775f, 0.926323175f},
std::array<float,2>{0.877000391f, 0.101289779f},
std::array<float,2>{0.534378529f, 0.577462316f},
std::array<float,2>{0.451153964f, 0.375522345f},
std::array<float,2>{0.25385052f, 0.964892328f},
std::array<float,2>{0.719763041f, 0.00203259452f},
std::array<float,2>{0.772541404f, 0.516986787f},
std::array<float,2>{0.0838040486f, 0.477050245f},
std::array<float,2>{0.176996112f, 0.643315911f},
std::array<float,2>{0.942036092f, 0.30124414f},
std::array<float,2>{0.594816625f, 0.848947108f},
std::array<float,2>{0.387545437f, 0.239636987f},
std::array<float,2>{0.496590585f, 0.621590734f},
std::array<float,2>{0.51269412f, 0.434066653f},
std::array<float,2>{0.920871496f, 0.882615089f},
std::array<float,2>{0.207784846f, 0.0821063593f},
std::array<float,2>{0.0620933063f, 0.809179366f},
std::array<float,2>{0.8483513f, 0.156143472f},
std::array<float,2>{0.656649888f, 0.704276979f},
std::array<float,2>{0.356379658f, 0.340893388f},
std::array<float,2>{0.361847997f, 0.777512193f},
std::array<float,2>{0.676086783f, 0.157739282f},
std::array<float,2>{0.864738643f, 0.738080561f},
std::array<float,2>{0.0389008857f, 0.368809015f},
std::array<float,2>{0.198501855f, 0.58412993f},
std::array<float,2>{0.932431042f, 0.394269615f},
std::array<float,2>{0.517438471f, 0.919331729f},
std::array<float,2>{0.475232601f, 0.114298426f},
std::array<float,2>{0.405715048f, 0.668854773f},
std::array<float,2>{0.613960922f, 0.276344925f},
std::array<float,2>{0.958323658f, 0.821301937f},
std::array<float,2>{0.169432744f, 0.205607951f},
std::array<float,2>{0.07420066f, 0.997756958f},
std::array<float,2>{0.753714621f, 0.0388533771f},
std::array<float,2>{0.734925091f, 0.548770308f},
std::array<float,2>{0.266512752f, 0.463367343f},
std::array<float,2>{0.462454647f, 0.903802395f},
std::array<float,2>{0.561323524f, 0.0682739466f},
std::array<float,2>{0.89428246f, 0.600013494f},
std::array<float,2>{0.241373107f, 0.416052669f},
std::array<float,2>{0.0309173521f, 0.693426371f},
std::array<float,2>{0.816516399f, 0.325108886f},
std::array<float,2>{0.650036335f, 0.794245362f},
std::array<float,2>{0.332497805f, 0.13795948f},
std::array<float,2>{0.305008262f, 0.502345502f},
std::array<float,2>{0.705753088f, 0.485310823f},
std::array<float,2>{0.795371056f, 0.946624279f},
std::array<float,2>{0.0999370068f, 0.0308481976f},
std::array<float,2>{0.135384202f, 0.874824882f},
std::array<float,2>{0.975065887f, 0.221597537f},
std::array<float,2>{0.582721472f, 0.634201348f},
std::array<float,2>{0.421603769f, 0.285169184f},
std::array<float,2>{0.481379122f, 0.788141131f},
std::array<float,2>{0.525799453f, 0.130581334f},
std::array<float,2>{0.927231371f, 0.70065403f},
std::array<float,2>{0.192216441f, 0.320240468f},
std::array<float,2>{0.0437896587f, 0.609248817f},
std::array<float,2>{0.874019682f, 0.413163364f},
std::array<float,2>{0.679774642f, 0.894099295f},
std::array<float,2>{0.370740861f, 0.0774086416f},
std::array<float,2>{0.277864248f, 0.628020823f},
std::array<float,2>{0.747541666f, 0.295747548f},
std::array<float,2>{0.765019834f, 0.866005838f},
std::array<float,2>{0.0679436028f, 0.226970911f},
std::array<float,2>{0.159423068f, 0.944930136f},
std::array<float,2>{0.962380707f, 0.022803193f},
std::array<float,2>{0.622223258f, 0.509984016f},
std::array<float,2>{0.397001445f, 0.493384004f},
std::array<float,2>{0.337547153f, 0.908848464f},
std::array<float,2>{0.642719269f, 0.118584655f},
std::array<float,2>{0.826847494f, 0.591222048f},
std::array<float,2>{0.0230418872f, 0.401286781f},
std::array<float,2>{0.245804191f, 0.749181628f},
std::array<float,2>{0.902316809f, 0.360858619f},
std::array<float,2>{0.551057339f, 0.768942714f},
std::array<float,2>{0.458525449f, 0.170575082f},
std::array<float,2>{0.413203984f, 0.556516767f},
std::array<float,2>{0.592729151f, 0.454637289f},
std::array<float,2>{0.98179549f, 0.990763485f},
std::array<float,2>{0.127101973f, 0.0457284674f},
std::array<float,2>{0.108483583f, 0.820075095f},
std::array<float,2>{0.787363112f, 0.214504197f},
std::array<float,2>{0.715934217f, 0.656334698f},
std::array<float,2>{0.301701456f, 0.267211348f},
std::array<float,2>{0.288283587f, 0.859234929f},
std::array<float,2>{0.700766325f, 0.242834374f},
std::array<float,2>{0.811552644f, 0.655181646f},
std::array<float,2>{0.122880101f, 0.310191602f},
std::array<float,2>{0.152613655f, 0.52780515f},
std::array<float,2>{0.986617565f, 0.468921125f},
std::array<float,2>{0.564770877f, 0.956129432f},
std::array<float,2>{0.427685142f, 0.0127791492f},
std::array<float,2>{0.438770324f, 0.716731787f},
std::array<float,2>{0.543034792f, 0.329321414f},
std::array<float,2>{0.887491405f, 0.803433597f},
std::array<float,2>{0.224723458f, 0.147611767f},
std::array<float,2>{0.0125314975f, 0.888538718f},
std::array<float,2>{0.828488171f, 0.0914451629f},
std::array<float,2>{0.6350227f, 0.612102866f},
std::array<float,2>{0.3185727f, 0.427342445f},
std::array<float,2>{0.380687892f, 0.970373809f},
std::array<float,2>{0.602720857f, 0.0562855937f},
std::array<float,2>{0.946052909f, 0.543598831f},
std::array<float,2>{0.185465813f, 0.445483446f},
std::array<float,2>{0.0889889672f, 0.674784958f},
std::array<float,2>{0.776984036f, 0.256630361f},
std::array<float,2>{0.730171919f, 0.828941941f},
std::array<float,2>{0.263482511f, 0.19593358f},
std::array<float,2>{0.350383282f, 0.569254816f},
std::array<float,2>{0.666885078f, 0.384536088f},
std::array<float,2>{0.856630981f, 0.931080043f},
std::array<float,2>{0.0484970286f, 0.102783501f},
std::array<float,2>{0.213109821f, 0.755273819f},
std::array<float,2>{0.910926044f, 0.183078542f},
std::array<float,2>{0.503188789f, 0.722662926f},
std::array<float,2>{0.487633616f, 0.354286462f},
std::array<float,2>{0.392963767f, 0.758478642f},
std::array<float,2>{0.62100327f, 0.174324006f},
std::array<float,2>{0.967209756f, 0.727678239f},
std::array<float,2>{0.163459599f, 0.346135557f},
std::array<float,2>{0.0640544444f, 0.573661745f},
std::array<float,2>{0.759039462f, 0.380764127f},
std::array<float,2>{0.742651641f, 0.921921015f},
std::array<float,2>{0.275970757f, 0.0959455818f},
std::array<float,2>{0.371285349f, 0.686601877f},
std::array<float,2>{0.683625102f, 0.258908361f},
std::array<float,2>{0.867949367f, 0.839382112f},
std::array<float,2>{0.0394759849f, 0.191319078f},
std::array<float,2>{0.190137938f, 0.981585801f},
std::array<float,2>{0.921922386f, 0.0476316884f},
std::array<float,2>{0.52980423f, 0.538014889f},
std::array<float,2>{0.478118151f, 0.43894574f},
std::array<float,2>{0.299307853f, 0.875792086f},
std::array<float,2>{0.71373409f, 0.0781665891f},
std::array<float,2>{0.781802952f, 0.620604038f},
std::array<float,2>{0.104969606f, 0.430193484f},
std::array<float,2>{0.129495412f, 0.707542658f},
std::array<float,2>{0.979883671f, 0.337006509f},
std::array<float,2>{0.586863756f, 0.806612909f},
std::array<float,2>{0.406490266f, 0.148683012f},
std::array<float,2>{0.456021667f, 0.520471156f},
std::array<float,2>{0.547751307f, 0.484305054f},
std::array<float,2>{0.90512687f, 0.963278472f},
std::array<float,2>{0.246704742f, 0.00667117722f},
std::array<float,2>{0.0180723909f, 0.847625971f},
std::array<float,2>{0.821733117f, 0.237655252f},
std::array<float,2>{0.646802187f, 0.645800173f},
std::array<float,2>{0.340561658f, 0.29875949f},
std::array<float,2>{0.313714623f, 0.825974643f},
std::array<float,2>{0.638294518f, 0.210664615f},
std::array<float,2>{0.835040867f, 0.665191293f},
std::array<float,2>{0.00855642278f, 0.277401179f},
std::array<float,2>{0.221063837f, 0.551338911f},
std::array<float,2>{0.883177221f, 0.466885298f},
std::array<float,2>{0.539307714f, 0.99341476f},
std::array<float,2>{0.443431258f, 0.0321873426f},
std::array<float,2>{0.423138022f, 0.741447806f},
std::array<float,2>{0.567139983f, 0.374124229f},
std::array<float,2>{0.99171108f, 0.77723074f},
std::array<float,2>{0.150121823f, 0.162229016f},
std::array<float,2>{0.118529759f, 0.917436957f},
std::array<float,2>{0.806106031f, 0.112202436f},
std::array<float,2>{0.69683212f, 0.581237316f},
std::array<float,2>{0.283376515f, 0.398288637f},
std::array<float,2>{0.490107536f, 0.952600658f},
std::array<float,2>{0.507113993f, 0.026937779f},
std::array<float,2>{0.908851683f, 0.507128298f},
std::array<float,2>{0.21602793f, 0.491575032f},
std::array<float,2>{0.0522372983f, 0.638748109f},
std::array<float,2>{0.851749599f, 0.282386214f},
std::array<float,2>{0.667997777f, 0.868321717f},
std::array<float,2>{0.346898168f, 0.225687757f},
std::array<float,2>{0.261611968f, 0.596848369f},
std::array<float,2>{0.73414433f, 0.418123543f},
std::array<float,2>{0.781115055f, 0.900331318f},
std::array<float,2>{0.093295902f, 0.0641842112f},
std::array<float,2>{0.180690169f, 0.792435467f},
std::array<float,2>{0.949932516f, 0.135623023f},
std::array<float,2>{0.607915521f, 0.689680159f},
std::array<float,2>{0.377427846f, 0.322155356f},
std::array<float,2>{0.447753131f, 0.860022902f},
std::array<float,2>{0.535184443f, 0.231692702f},
std::array<float,2>{0.881603479f, 0.632484078f},
std::array<float,2>{0.226691589f, 0.291740268f},
std::array<float,2>{0.000370884605f, 0.5127545f},
std::array<float,2>{0.840553463f, 0.499308407f},
std::array<float,2>{0.632302821f, 0.94048214f},
std::array<float,2>{0.323186129f, 0.0170011651f},
std::array<float,2>{0.289489895f, 0.697196841f},
std::array<float,2>{0.693827331f, 0.314235836f},
std::array<float,2>{0.800329506f, 0.781408191f},
std::array<float,2>{0.109588124f, 0.126737133f},
std::array<float,2>{0.142955676f, 0.897396743f},
std::array<float,2>{0.996101618f, 0.0739929453f},
std::array<float,2>{0.574115396f, 0.604478419f},
std::array<float,2>{0.434720725f, 0.408972919f},
std::array<float,2>{0.353975743f, 0.986008048f},
std::array<float,2>{0.662354648f, 0.0395469405f},
std::array<float,2>{0.845856786f, 0.560233176f},
std::array<float,2>{0.0556917451f, 0.457083076f},
std::array<float,2>{0.205255151f, 0.661179662f},
std::array<float,2>{0.915353537f, 0.273012012f},
std::array<float,2>{0.509259999f, 0.81342262f},
std::array<float,2>{0.492432594f, 0.216023371f},
std::array<float,2>{0.383761495f, 0.587902248f},
std::array<float,2>{0.597772956f, 0.404593438f},
std::array<float,2>{0.940387845f, 0.913030744f},
std::array<float,2>{0.172063813f, 0.122950569f},
std::array<float,2>{0.0808824524f, 0.770782769f},
std::array<float,2>{0.766876638f, 0.167362213f},
std::array<float,2>{0.725536287f, 0.745843649f},
std::array<float,2>{0.257352769f, 0.365554661f},
std::array<float,2>{0.269785047f, 0.797463536f},
std::array<float,2>{0.740984261f, 0.144070804f},
std::array<float,2>{0.756677449f, 0.713508904f},
std::array<float,2>{0.0749332905f, 0.33589384f},
std::array<float,2>{0.165997028f, 0.615666151f},
std::array<float,2>{0.954616129f, 0.423597008f},
std::array<float,2>{0.609913111f, 0.883545101f},
std::array<float,2>{0.400723934f, 0.0874790177f},
std::array<float,2>{0.472297162f, 0.648561001f},
std::array<float,2>{0.522265017f, 0.307907641f},
std::array<float,2>{0.935745358f, 0.853369415f},
std::array<float,2>{0.19934319f, 0.246876791f},
std::array<float,2>{0.0345808268f, 0.960715711f},
std::array<float,2>{0.862619042f, 0.0109427599f},
std::array<float,2>{0.673530996f, 0.525599718f},
std::array<float,2>{0.365111172f, 0.473147482f},
std::array<float,2>{0.416992158f, 0.934325576f},
std::array<float,2>{0.581542492f, 0.106640384f},
std::array<float,2>{0.96940583f, 0.563605368f},
std::array<float,2>{0.140212789f, 0.390095264f},
std::array<float,2>{0.096392706f, 0.721104443f},
std::array<float,2>{0.79268688f, 0.357698679f},
std::array<float,2>{0.708065033f, 0.750505567f},
std::array<float,2>{0.30928424f, 0.184020296f},
std::array<float,2>{0.329709262f, 0.539556623f},
std::array<float,2>{0.65301764f, 0.451826185f},
std::array<float,2>{0.814564943f, 0.975010157f},
std::array<float,2>{0.0267291255f, 0.0610029921f},
std::array<float,2>{0.235713214f, 0.833980739f},
std::array<float,2>{0.895558238f, 0.199434459f},
std::array<float,2>{0.555389762f, 0.676100671f},
std::array<float,2>{0.465560883f, 0.250514925f}} | 49.006592 | 51 | 0.734725 | st-ario |
2542029350b0b404fbb1ac81123e1b99e37bef78 | 1,206 | hpp | C++ | src/utils/io.hpp | aligungr/ue-ran-sim | 564f9d228723f03adfa2b02df2ea019bdf305085 | [
"MIT"
] | 16 | 2020-04-16T02:07:37.000Z | 2020-07-23T10:48:27.000Z | src/utils/io.hpp | aligungr/ue-ran-sim | 564f9d228723f03adfa2b02df2ea019bdf305085 | [
"MIT"
] | 8 | 2020-07-13T17:11:35.000Z | 2020-08-03T16:46:31.000Z | src/utils/io.hpp | aligungr/ue-ran-sim | 564f9d228723f03adfa2b02df2ea019bdf305085 | [
"MIT"
] | 9 | 2020-03-04T15:05:08.000Z | 2020-07-30T06:18:18.000Z | //
// This file is a part of UERANSIM open source project.
// Copyright (c) 2021 ALİ GÜNGÖR.
//
// The software and all associated files are licensed under GPL-3.0
// and subject to the terms and conditions defined in LICENSE file.
//
#pragma once
#include <string>
#include <vector>
namespace io
{
void CreateDirectory(const std::string &path);
bool Exists(const std::string &path);
std::string ReadAllText(const std::string &file);
void WriteAllText(const std::string &path, const std::string &content);
void RelaxPermissions(const std::string &path);
bool Remove(const std::string &path);
std::vector<std::string> GetEntries(const std::string &path);
std::vector<std::string> GetAllEntries(const std::string &path);
void PreOrderEntries(const std::string &root, std::vector<std::string> &visitor);
bool IsDirectory(const std::string &path);
bool IsRegularFile(const std::string &path);
std::string GetStem(const std::string &path);
void AppendPath(std::string &source, const std::string &target);
std::string GetIp4OfInterface(const std::string &ifName);
std::string GetIp6OfInterface(const std::string &ifName);
std::string GetHostByName(const std::string& name);
} // namespace io
| 24.12 | 81 | 0.740464 | aligungr |
25434081e9cb5acc2e145d1a614574615f6f255f | 136 | cpp | C++ | cpp/pb_large_map/LargeMap.cpp | patrit/playground | 6ace43f81123a06e9b5820e1f75e5a9af0cb37b9 | [
"MIT"
] | null | null | null | cpp/pb_large_map/LargeMap.cpp | patrit/playground | 6ace43f81123a06e9b5820e1f75e5a9af0cb37b9 | [
"MIT"
] | null | null | null | cpp/pb_large_map/LargeMap.cpp | patrit/playground | 6ace43f81123a06e9b5820e1f75e5a9af0cb37b9 | [
"MIT"
] | null | null | null | #include "LargeMap.hpp"
LargeMap::Map LargeMap::_map{
{"foo",
{{"bar42", 42},
{"bar43", 43},
}
},
};
| 13.6 | 29 | 0.426471 | patrit |
25452d7b66752b9252960b9985a8b6186e1030b4 | 1,095 | hpp | C++ | src/engine/mapset.hpp | eXl-Nic/eXl | a5a0f77f47db3179365c107a184bb38b80280279 | [
"MIT"
] | null | null | null | src/engine/mapset.hpp | eXl-Nic/eXl | a5a0f77f47db3179365c107a184bb38b80280279 | [
"MIT"
] | null | null | null | src/engine/mapset.hpp | eXl-Nic/eXl | a5a0f77f47db3179365c107a184bb38b80280279 | [
"MIT"
] | null | null | null | #pragma once
#include <dunatk/map/map.hpp>
#include <dunatk/map/tile.hpp>
#include <dunatk/map/tileblock.hpp>
namespace eXl
{
class MapSet : public HeapObject
{
MapSet();
public:
IntrusivePtr<SpriteDesc const> texFloor;
IntrusivePtr<SpriteDesc const> texFloorBorder;
IntrusivePtr<SpriteDesc const> texFloorIntCorner;
IntrusivePtr<SpriteDesc const> texFloorExtCorner;
IntrusivePtr<SpriteDesc const> texWall;
IntrusivePtr<SpriteDesc const> texFill;
IntrusivePtr<SpriteDesc const> texIntCorner;
IntrusivePtr<SpriteDesc const> texExtCorner;
TileLoc locFloor;
TileLoc locFloorBorder;
TileLoc locFloorIntCorner;
TileLoc locFloorExtCorner;
TileLoc locWall;
TileLoc locWallIntCorner;
TileLoc locWallExtCorner;
TileLoc locFill;
Tile_OLD tileFloor;
Tile_OLD tileFloorBorder;
Tile_OLD tileFloorIntCorner;
Tile_OLD tileFloorExtCorner;
Tile_OLD tileWall;
Tile_OLD tileWallIntCorner;
Tile_OLD tileWallExtCorner;
Tile_OLD tileFill;
public:
Old::TileSet mapSet;
static MapSet& Get();
};
} | 24.886364 | 53 | 0.742466 | eXl-Nic |
8584124fdaa67095b42aa00325694a65e9782bcb | 5,735 | cpp | C++ | cocos2dx_playground/Classes/step_rain_of_chaos_game_test_ActorMoveScene.cpp | R2Road/cocos2dx_playground | 6e6f349b5c9fc702558fe8720ba9253a8ba00164 | [
"Apache-2.0"
] | 9 | 2020-06-11T17:09:44.000Z | 2021-12-25T00:34:33.000Z | cocos2dx_playground/Classes/step_rain_of_chaos_game_test_ActorMoveScene.cpp | R2Road/cocos2dx_playground | 6e6f349b5c9fc702558fe8720ba9253a8ba00164 | [
"Apache-2.0"
] | 9 | 2019-12-21T15:01:01.000Z | 2020-12-05T15:42:43.000Z | cocos2dx_playground/Classes/step_rain_of_chaos_game_test_ActorMoveScene.cpp | R2Road/cocos2dx_playground | 6e6f349b5c9fc702558fe8720ba9253a8ba00164 | [
"Apache-2.0"
] | 1 | 2020-09-07T01:32:16.000Z | 2020-09-07T01:32:16.000Z | #include "step_rain_of_chaos_game_test_ActorMoveScene.h"
#include <new>
#include <numeric>
#include "2d/CCLabel.h"
#include "2d/CCLayer.h"
#include "base/CCDirector.h"
#include "base/CCEventDispatcher.h"
#include "base/CCEventListenerKeyboard.h"
#include "base/ccUTF8.h"
#include "cpg_SStream.h"
#include "cpg_StringTable.h"
#include "step_mole_CircleCollisionComponentConfig.h"
#include "step_rain_of_chaos_game_PlayerNode.h"
USING_NS_CC;
namespace
{
const int TAG_PlayerNode = 20140416;
const int TAG_MoveSpeedNode = 20160528;
}
namespace step_rain_of_chaos
{
namespace game_test
{
ActorMoveScene::ActorMoveScene( const helper::FuncSceneMover& back_to_the_previous_scene_callback ) :
helper::BackToThePreviousScene( back_to_the_previous_scene_callback )
, mKeyboardListener( nullptr )
, mKeyCodeCollector()
, mMoveSpeed( 150.f )
{}
Scene* ActorMoveScene::create( const helper::FuncSceneMover& back_to_the_previous_scene_callback )
{
auto ret = new ( std::nothrow ) ActorMoveScene( back_to_the_previous_scene_callback );
if( !ret || !ret->init() )
{
delete ret;
ret = nullptr;
}
else
{
ret->autorelease();
}
return ret;
}
bool ActorMoveScene::init()
{
if( !Scene::init() )
{
return false;
}
schedule( schedule_selector( ActorMoveScene::UpdateForInput ) );
const auto visibleSize = _director->getVisibleSize();
const auto visibleOrigin = _director->getVisibleOrigin();
//
// Summury
//
{
std::stringstream ss;
ss << "+ " << getTitle();
ss << cpg::linefeed;
ss << cpg::linefeed;
ss << "[ESC] : Return to Root";
ss << cpg::linefeed;
ss << cpg::linefeed;
ss << "[1] : Move Speed Up";
ss << cpg::linefeed;
ss << "[2] : Move Speed Down";
ss << cpg::linefeed;
ss << cpg::linefeed;
ss << "[Arrow Key] : Move";
auto label = Label::createWithTTF( ss.str(), cpg::StringTable::GetFontPath(), 9, Size::ZERO, TextHAlignment::LEFT );
label->setAnchorPoint( Vec2( 0.f, 1.f ) );
label->setPosition( Vec2(
visibleOrigin.x
, visibleOrigin.y + visibleSize.height
) );
addChild( label, std::numeric_limits<int>::max() );
}
//
// Background
//
{
auto background_layer = LayerColor::create( Color4B( 63, 23, 14, 255 ) );
addChild( background_layer, std::numeric_limits<int>::min() );
}
//
// Current Life Time
//
{
auto label = Label::createWithTTF( "", cpg::StringTable::GetFontPath(), 12, Size::ZERO, TextHAlignment::LEFT );
label->setTag( TAG_MoveSpeedNode );
label->setAnchorPoint( Vec2( 1.f, 1.f ) );
label->setColor( Color3B::GREEN );
label->setPosition( Vec2(
visibleOrigin.x + visibleSize.width
, visibleOrigin.y + visibleSize.height
) );
addChild( label, std::numeric_limits<int>::max() );
updateMoveSpeedView();
}
//
// Player Node
//
{
auto player_node = game::PlayerNode::create( 5.f, game::PlayerNode::DebugConfig{ true }, step_mole::CircleCollisionComponentConfig{ true, true, true } );
player_node->setTag( TAG_PlayerNode );
player_node->setPosition( Vec2(
static_cast<int>( visibleOrigin.x + ( visibleSize.width * 0.5f ) )
, static_cast<int>( visibleOrigin.y + ( visibleSize.height * 0.5f ) )
) );
addChild( player_node );
}
return true;
}
void ActorMoveScene::onEnter()
{
Scene::onEnter();
assert( !mKeyboardListener );
mKeyboardListener = EventListenerKeyboard::create();
mKeyboardListener->onKeyPressed = CC_CALLBACK_2( ActorMoveScene::onKeyPressed, this );
mKeyboardListener->onKeyReleased = CC_CALLBACK_2( ActorMoveScene::onKeyReleased, this );
getEventDispatcher()->addEventListenerWithSceneGraphPriority( mKeyboardListener, this );
}
void ActorMoveScene::onExit()
{
assert( mKeyboardListener );
getEventDispatcher()->removeEventListener( mKeyboardListener );
mKeyboardListener = nullptr;
Scene::onExit();
}
void ActorMoveScene::UpdateForInput( float delta_time )
{
Vec2 move_vector;
if( mKeyCodeCollector.isActiveKey( EventKeyboard::KeyCode::KEY_UP_ARROW ) )
{
move_vector.y += 1.f;
}
if( mKeyCodeCollector.isActiveKey( EventKeyboard::KeyCode::KEY_DOWN_ARROW ) )
{
move_vector.y -= 1.f;
}
if( mKeyCodeCollector.isActiveKey( EventKeyboard::KeyCode::KEY_RIGHT_ARROW ) )
{
move_vector.x += 1.f;
}
if( mKeyCodeCollector.isActiveKey( EventKeyboard::KeyCode::KEY_LEFT_ARROW ) )
{
move_vector.x -= 1.f;
}
if( 0.f != move_vector.x || 0.f != move_vector.y )
{
move_vector.normalize();
move_vector.scale( mMoveSpeed * delta_time );
auto animation_node = getChildByTag( TAG_PlayerNode );
animation_node->setPosition( animation_node->getPosition() + move_vector );
updateMoveSpeedView();
}
}
void ActorMoveScene::onKeyPressed( EventKeyboard::KeyCode keycode, Event* /*event*/ )
{
if( EventKeyboard::KeyCode::KEY_ESCAPE == keycode )
{
helper::BackToThePreviousScene::MoveBack();
return;
}
if( EventKeyboard::KeyCode::KEY_1 == keycode )
{
mMoveSpeed += 1.f;
updateMoveSpeedView();
}
if( EventKeyboard::KeyCode::KEY_2 == keycode )
{
mMoveSpeed = std::max( 1.f, mMoveSpeed - 1.f );
updateMoveSpeedView();
}
mKeyCodeCollector.onKeyPressed( keycode );
}
void ActorMoveScene::onKeyReleased( EventKeyboard::KeyCode keycode, Event* /*event*/ )
{
mKeyCodeCollector.onKeyReleased( keycode );
}
void ActorMoveScene::updateMoveSpeedView()
{
auto label = static_cast<Label*>( getChildByTag( TAG_MoveSpeedNode ) );
label->setString( StringUtils::format( "Move Speed : %.2f", mMoveSpeed ) );
}
}
}
| 26.068182 | 157 | 0.668178 | R2Road |
8587631e041c8479eaedc531b415d9a88ae52421 | 2,957 | cpp | C++ | src/io/serialPort.cpp | oblaser/omw | 3206f5faf8ec26c63004de358235ba7efbd10c4f | [
"MIT"
] | null | null | null | src/io/serialPort.cpp | oblaser/omw | 3206f5faf8ec26c63004de358235ba7efbd10c4f | [
"MIT"
] | null | null | null | src/io/serialPort.cpp | oblaser/omw | 3206f5faf8ec26c63004de358235ba7efbd10c4f | [
"MIT"
] | null | null | null | /*
author Oliver Blaser
date 17.12.2021
copyright MIT - Copyright (c) 2021 Oliver Blaser
*/
#include <algorithm>
#include <string>
#include <vector>
#include "omw/defs.h"
#include "omw/io/serialPort.h"
#include "omw/string.h"
#include "omw/windows/windows.h"
namespace
{
#ifdef OMW_PLAT_WIN
bool isCom0com(const std::string& device)
{
const omw::string tmpDevice = (omw::string(device)).toLower_asciiExt();
const std::vector<omw::string> info = omw::windows::queryDosDevice(device);
for (size_t i = 0; i < info.size(); ++i)
{
const omw::string tmpInfo = info[i].toLower_asciiExt();
if (tmpInfo.contains("com0com") && !tmpDevice.contains("com0com#port#"))
{
return true;
}
}
return false;
}
#endif // OMW_PLAT_WIN
}
#ifndef OMWi_SERIAL_PORT_PREVIEW
omw::SerialPort::SerialPort()
{
}
#endif
std::vector<omw::string> omw::getSerialPortList(bool onlyCOMx)
{
std::vector<omw::string> serialPorts;
#ifdef OMW_PLAT_WIN
const std::vector<omw::string> devices = omw::windows::getAllDosDevices();
for (size_t i = 0; i < devices.size(); ++i)
{
bool isC0C = false;
if (!onlyCOMx) isC0C = ::isCom0com(devices[i]);
if ((devices[i].compare(0, 3, "COM") == 0) || (!onlyCOMx && isC0C))
{
serialPorts.push_back(devices[i]);
}
}
#endif // OMW_PLAT_WIN
return serialPorts;
}
void omw::sortSerialPortList(std::vector<omw::string>& ports)
{
#ifdef OMW_PLAT_WIN
#if /*simple*/ 0
std::sort(ports.begin(), ports.end());
#else
const char* const comStr = "COM";
std::vector<int> comPorts;
std::vector<omw::string> otherPorts;
for (size_t i = 0; i < ports.size(); ++i)
{
try
{
omw::string port = ports[i];
if (port.compare(0, 3, comStr) == 0)
{
const omw::string intStr = port.substr(3);
if (omw::isUInteger(intStr)) comPorts.push_back(std::stoi(intStr));
else throw (-1);
}
else throw (-1);
}
catch (...) { otherPorts.push_back(ports[i]); }
}
std::sort(comPorts.begin(), comPorts.end());
std::sort(otherPorts.begin(), otherPorts.end());
ports.clear();
ports.reserve(comPorts.size() + otherPorts.size());
for (size_t i = 0; i < comPorts.size(); ++i)
{
ports.push_back(comStr + std::to_string(comPorts[i]));
}
for (size_t i = 0; i < otherPorts.size(); ++i)
{
ports.push_back(otherPorts[i]);
}
#endif
#else // OMW_PLAT_WIN
std::sort(ports.begin(), ports.end());
#endif // OMW_PLAT_WIN
}
void omw::sortSerialPortList(std::vector<std::string>& ports)
{
omw::stringVector_t tmpPorts = omw::stringVector(ports);
omw::sortSerialPortList(tmpPorts);
ports = omw::stdStringVector(tmpPorts);
}
| 22.233083 | 84 | 0.578627 | oblaser |
858b3f66f848eea4e5fe243506ea4b0584394681 | 531 | cpp | C++ | Source/URoboViz/Private/Controllers/RobotController.cpp | HoangGiang93/URoboViz | dcaab223c30827977d15300f7ae4b19ba0ddfa4f | [
"MIT"
] | null | null | null | Source/URoboViz/Private/Controllers/RobotController.cpp | HoangGiang93/URoboViz | dcaab223c30827977d15300f7ae4b19ba0ddfa4f | [
"MIT"
] | null | null | null | Source/URoboViz/Private/Controllers/RobotController.cpp | HoangGiang93/URoboViz | dcaab223c30827977d15300f7ae4b19ba0ddfa4f | [
"MIT"
] | null | null | null | // Copyright (c) 2022, Hoang Giang Nguyen - Institute for Artificial Intelligence, University Bremen
#include "Controllers/RobotController.h"
#include "Animation/SkeletalMeshActor.h"
DEFINE_LOG_CATEGORY_STATIC(LogRobotController, Log, All);
URobotController::URobotController()
{
}
void URobotController::Init(ASkeletalMeshActor *InOwner)
{
if (InOwner == nullptr)
{
UE_LOG(LogRobotController, Error, TEXT("Owner of %s is nullptr"), *GetName())
return;
}
SetOwner(InOwner);
Init();
}
| 22.125 | 101 | 0.709981 | HoangGiang93 |
858d1219e9e1be331ca432ebb6a99d65c36bf1a1 | 2,023 | cpp | C++ | android/app/src/cpp/src/base/tools/Timer.cpp | FlameSalamander/react-native-xmrig | 6a6e3b301bd78b88459989f334d759f65e434082 | [
"MIT"
] | 28 | 2021-05-11T03:28:57.000Z | 2022-03-09T14:34:57.000Z | android/app/src/cpp/src/base/tools/Timer.cpp | FlameSalamander/react-native-xmrig | 6a6e3b301bd78b88459989f334d759f65e434082 | [
"MIT"
] | 10 | 2021-05-16T19:50:31.000Z | 2022-01-30T03:56:45.000Z | android/app/src/cpp/src/base/tools/Timer.cpp | FlameSalamander/react-native-xmrig | 6a6e3b301bd78b88459989f334d759f65e434082 | [
"MIT"
] | 12 | 2021-07-19T22:14:58.000Z | 2022-02-08T02:24:05.000Z | /* XMRig
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <[email protected]>
*
* 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 "base/tools/Timer.h"
#include "base/kernel/interfaces/ITimerListener.h"
#include "base/tools/Handle.h"
xmrig::Timer::Timer(ITimerListener *listener) :
m_listener(listener)
{
init();
}
xmrig::Timer::Timer(ITimerListener *listener, uint64_t timeout, uint64_t repeat) :
m_listener(listener)
{
init();
start(timeout, repeat);
}
xmrig::Timer::~Timer()
{
Handle::close(m_timer);
}
uint64_t xmrig::Timer::repeat() const
{
return uv_timer_get_repeat(m_timer);
}
void xmrig::Timer::setRepeat(uint64_t repeat)
{
uv_timer_set_repeat(m_timer, repeat);
}
void xmrig::Timer::singleShot(uint64_t timeout, int id)
{
m_id = id;
stop();
start(timeout, 0);
}
void xmrig::Timer::start(uint64_t timeout, uint64_t repeat)
{
uv_timer_start(m_timer, onTimer, timeout, repeat);
}
void xmrig::Timer::stop()
{
setRepeat(0);
uv_timer_stop(m_timer);
}
void xmrig::Timer::init()
{
m_timer = new uv_timer_t;
m_timer->data = this;
uv_timer_init(uv_default_loop(), m_timer);
}
void xmrig::Timer::onTimer(uv_timer_t *handle)
{
const auto timer = static_cast<Timer *>(handle->data);
timer->m_listener->onTimer(timer);
}
| 21.521277 | 82 | 0.695502 | FlameSalamander |
859144fe3502ca1d0a582301f21ac43a1abcc4b9 | 4,268 | hpp | C++ | include/codegen/include/System/DateTimeResult.hpp | Futuremappermydud/Naluluna-Modifier-Quest | bfda34370764b275d90324b3879f1a429a10a873 | [
"MIT"
] | 1 | 2021-11-12T09:29:31.000Z | 2021-11-12T09:29:31.000Z | include/codegen/include/System/DateTimeResult.hpp | Futuremappermydud/Naluluna-Modifier-Quest | bfda34370764b275d90324b3879f1a429a10a873 | [
"MIT"
] | null | null | null | include/codegen/include/System/DateTimeResult.hpp | Futuremappermydud/Naluluna-Modifier-Quest | bfda34370764b275d90324b3879f1a429a10a873 | [
"MIT"
] | 2 | 2021-10-03T02:14:20.000Z | 2021-11-12T09:29:36.000Z | // Autogenerated from CppHeaderCreator
// Created by Sc2ad
// =========================================================================
#pragma once
#pragma pack(push, 8)
// Begin includes
#include "extern/beatsaber-hook/shared/utils/typedefs.h"
// Including type: System.ValueType
#include "System/ValueType.hpp"
// Including type: System.ParseFlags
#include "System/ParseFlags.hpp"
// Including type: System.TimeSpan
#include "System/TimeSpan.hpp"
// Including type: System.DateTime
#include "System/DateTime.hpp"
// Including type: System.ParseFailureKind
#include "System/ParseFailureKind.hpp"
// Completed includes
// Begin forward declares
// Forward declaring namespace: System::Globalization
namespace System::Globalization {
// Forward declaring type: Calendar
class Calendar;
}
// Completed forward declares
// Type namespace: System
namespace System {
// Autogenerated type: System.DateTimeResult
struct DateTimeResult : public System::ValueType {
public:
// System.Int32 Year
// Offset: 0x0
int Year;
// System.Int32 Month
// Offset: 0x4
int Month;
// System.Int32 Day
// Offset: 0x8
int Day;
// System.Int32 Hour
// Offset: 0xC
int Hour;
// System.Int32 Minute
// Offset: 0x10
int Minute;
// System.Int32 Second
// Offset: 0x14
int Second;
// System.Double fraction
// Offset: 0x18
double fraction;
// System.Int32 era
// Offset: 0x20
int era;
// System.ParseFlags flags
// Offset: 0x24
System::ParseFlags flags;
// System.TimeSpan timeZoneOffset
// Offset: 0x28
System::TimeSpan timeZoneOffset;
// System.Globalization.Calendar calendar
// Offset: 0x30
System::Globalization::Calendar* calendar;
// System.DateTime parsedDate
// Offset: 0x38
System::DateTime parsedDate;
// System.ParseFailureKind failure
// Offset: 0x40
System::ParseFailureKind failure;
// System.String failureMessageID
// Offset: 0x48
::Il2CppString* failureMessageID;
// System.Object failureMessageFormatArgument
// Offset: 0x50
::Il2CppObject* failureMessageFormatArgument;
// System.String failureArgumentName
// Offset: 0x58
::Il2CppString* failureArgumentName;
// Creating value type constructor for type: DateTimeResult
DateTimeResult(int Year_ = {}, int Month_ = {}, int Day_ = {}, int Hour_ = {}, int Minute_ = {}, int Second_ = {}, double fraction_ = {}, int era_ = {}, System::ParseFlags flags_ = {}, System::TimeSpan timeZoneOffset_ = {}, System::Globalization::Calendar* calendar_ = {}, System::DateTime parsedDate_ = {}, System::ParseFailureKind failure_ = {}, ::Il2CppString* failureMessageID_ = {}, ::Il2CppObject* failureMessageFormatArgument_ = {}, ::Il2CppString* failureArgumentName_ = {}) : Year{Year_}, Month{Month_}, Day{Day_}, Hour{Hour_}, Minute{Minute_}, Second{Second_}, fraction{fraction_}, era{era_}, flags{flags_}, timeZoneOffset{timeZoneOffset_}, calendar{calendar_}, parsedDate{parsedDate_}, failure{failure_}, failureMessageID{failureMessageID_}, failureMessageFormatArgument{failureMessageFormatArgument_}, failureArgumentName{failureArgumentName_} {}
// System.Void Init()
// Offset: 0xA2CEB0
void Init();
// System.Void SetDate(System.Int32 year, System.Int32 month, System.Int32 day)
// Offset: 0xA2CED0
void SetDate(int year, int month, int day);
// System.Void SetFailure(System.ParseFailureKind failure, System.String failureMessageID, System.Object failureMessageFormatArgument)
// Offset: 0xA2CEDC
void SetFailure(System::ParseFailureKind failure, ::Il2CppString* failureMessageID, ::Il2CppObject* failureMessageFormatArgument);
// System.Void SetFailure(System.ParseFailureKind failure, System.String failureMessageID, System.Object failureMessageFormatArgument, System.String failureArgumentName)
// Offset: 0xA2CF18
void SetFailure(System::ParseFailureKind failure, ::Il2CppString* failureMessageID, ::Il2CppObject* failureMessageFormatArgument, ::Il2CppString* failureArgumentName);
}; // System.DateTimeResult
}
#include "extern/beatsaber-hook/shared/utils/il2cpp-type-check.hpp"
DEFINE_IL2CPP_ARG_TYPE(System::DateTimeResult, "System", "DateTimeResult");
#pragma pack(pop)
| 43.55102 | 862 | 0.714855 | Futuremappermydud |
85930680ecaf000349ed02a841828353c188a384 | 10,830 | cc | C++ | Third-party/Sokol/src/d3d11/imgui-d3d11.cc | VLiance/Demos | fa8435c2fa0f46e1324a71501fdf646326936148 | [
"Unlicense"
] | null | null | null | Third-party/Sokol/src/d3d11/imgui-d3d11.cc | VLiance/Demos | fa8435c2fa0f46e1324a71501fdf646326936148 | [
"Unlicense"
] | null | null | null | Third-party/Sokol/src/d3d11/imgui-d3d11.cc | VLiance/Demos | fa8435c2fa0f46e1324a71501fdf646326936148 | [
"Unlicense"
] | null | null | null | //------------------------------------------------------------------------------
// imgui-d3d11.cc
// Dear ImGui integration sample with D3D11 backend.
//------------------------------------------------------------------------------
#include "d3d11entry.h"
#define SOKOL_IMPL
#define SOKOL_D3D11
#define SOKOL_D3D11_SHADER_COMPILER
#define SOKOL_LOG(s) OutputDebugStringA(s)
#include "sokol_gfx.h"
#include "sokol_time.h"
#include "imgui.h"
const int Width = 1024;
const int Height = 768;
const int MaxVertices = (1<<16);
const int MaxIndices = MaxVertices * 3;
uint64_t last_time = 0;
bool show_test_window = true;
bool show_another_window = false;
sg_draw_state draw_state = { };
sg_pass_action pass_action = { };
ImDrawVert vertices[MaxVertices];
uint16_t indices[MaxIndices];
typedef struct {
ImVec2 disp_size;
} vs_params_t;
void imgui_draw_cb(ImDrawData*);
int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow) {
// setup d3d11 app wrapper, sokol_gfx, sokol_time
d3d11_init(Width, Height, 1, L"Sokol Dear ImGui D3D11");
sg_desc desc = { };
desc.d3d11_device = d3d11_device();
desc.d3d11_device_context = d3d11_device_context();
desc.d3d11_render_target_view_cb = d3d11_render_target_view;
desc.d3d11_depth_stencil_view_cb = d3d11_depth_stencil_view;
sg_setup(&desc);
stm_setup();
// input forwarding
d3d11_mouse_pos([] (float x, float y) { ImGui::GetIO().MousePos = ImVec2(x, y); });
d3d11_mouse_btn_down([] (int btn) { ImGui::GetIO().MouseDown[btn] = true; });
d3d11_mouse_btn_up([] (int btn) { ImGui::GetIO().MouseDown[btn] = false; });
d3d11_mouse_wheel([](float v) { ImGui::GetIO().MouseWheel = v; });
d3d11_char([] (wchar_t c) { ImGui::GetIO().AddInputCharacter(c); });
d3d11_key_down([] (int key) { if (key < 512) ImGui::GetIO().KeysDown[key] = true; });
d3d11_key_up([] (int key) { if (key < 512) ImGui::GetIO().KeysDown[key] = false; });
// setup Dear Imgui
ImGui::CreateContext();
ImGui::StyleColorsDark();
ImGuiIO& io = ImGui::GetIO();
io.IniFilename = nullptr;
io.RenderDrawListsFn = imgui_draw_cb;
io.Fonts->AddFontDefault();
io.KeyMap[ImGuiKey_Tab] = VK_TAB;
io.KeyMap[ImGuiKey_LeftArrow] = VK_LEFT;
io.KeyMap[ImGuiKey_RightArrow] = VK_RIGHT;
io.KeyMap[ImGuiKey_UpArrow] = VK_UP;
io.KeyMap[ImGuiKey_DownArrow] = VK_DOWN;
io.KeyMap[ImGuiKey_Home] = VK_HOME;
io.KeyMap[ImGuiKey_End] = VK_END;
io.KeyMap[ImGuiKey_Delete] = VK_DELETE;
io.KeyMap[ImGuiKey_Backspace] = VK_BACK;
io.KeyMap[ImGuiKey_Enter] = VK_RETURN;
io.KeyMap[ImGuiKey_Escape] = VK_ESCAPE;
io.KeyMap[ImGuiKey_A] = 'A';
io.KeyMap[ImGuiKey_C] = 'C';
io.KeyMap[ImGuiKey_V] = 'V';
io.KeyMap[ImGuiKey_X] = 'X';
io.KeyMap[ImGuiKey_Y] = 'Y';
io.KeyMap[ImGuiKey_Z] = 'Z';
// dynamic vertex- and index-buffers for imgui-generated geometry
sg_buffer_desc vbuf_desc = { };
vbuf_desc.usage = SG_USAGE_STREAM;
vbuf_desc.size = sizeof(vertices);
draw_state.vertex_buffers[0] = sg_make_buffer(&vbuf_desc);
sg_buffer_desc ibuf_desc = { };
ibuf_desc.type = SG_BUFFERTYPE_INDEXBUFFER;
ibuf_desc.usage = SG_USAGE_STREAM;
ibuf_desc.size = sizeof(indices);
draw_state.index_buffer = sg_make_buffer(&ibuf_desc);
// font texture for imgui's default font
unsigned char* font_pixels;
int font_width, font_height;
io.Fonts->GetTexDataAsRGBA32(&font_pixels, &font_width, &font_height);
sg_image_desc img_desc = { };
img_desc.width = font_width;
img_desc.height = font_height;
img_desc.pixel_format = SG_PIXELFORMAT_RGBA8;
img_desc.wrap_u = SG_WRAP_CLAMP_TO_EDGE;
img_desc.wrap_v = SG_WRAP_CLAMP_TO_EDGE;
img_desc.content.subimage[0][0].ptr = font_pixels;
img_desc.content.subimage[0][0].size = font_width * font_height * 4;
draw_state.fs_images[0] = sg_make_image(&img_desc);
// shader object for imgui rendering
sg_shader_desc shd_desc = { };
auto& ub = shd_desc.vs.uniform_blocks[0];
ub.size = sizeof(vs_params_t);
shd_desc.vs.source =
"cbuffer params {\n"
" float2 disp_size;\n"
"};\n"
"struct vs_in {\n"
" float2 pos: POSITION;\n"
" float2 uv: TEXCOORD0;\n"
" float4 color: COLOR0;\n"
"};\n"
"struct vs_out {\n"
" float2 uv: TEXCOORD0;\n"
" float4 color: COLOR0;\n"
" float4 pos: SV_Position;\n"
"};\n"
"vs_out main(vs_in inp) {\n"
" vs_out outp;\n"
" outp.pos = float4(((inp.pos/disp_size)-0.5)*float2(2.0,-2.0), 0.5, 1.0);\n"
" outp.uv = inp.uv;\n"
" outp.color = inp.color;\n"
" return outp;\n"
"}\n";
shd_desc.fs.images[0].type = SG_IMAGETYPE_2D;
shd_desc.fs.source =
"Texture2D<float4> tex: register(t0);\n"
"sampler smp: register(s0);\n"
"float4 main(float2 uv: TEXCOORD0, float4 color: COLOR0): SV_Target0 {\n"
" return tex.Sample(smp, uv) * color;\n"
"}\n";
sg_shader shd = sg_make_shader(&shd_desc);
// pipeline object for imgui rendering
sg_pipeline_desc pip_desc = { };
pip_desc.layout.buffers[0].stride = sizeof(ImDrawVert);
auto& attrs = pip_desc.layout.attrs;
attrs[0].sem_name="POSITION"; attrs[0].offset=offsetof(ImDrawVert, pos); attrs[0].format=SG_VERTEXFORMAT_FLOAT2;
attrs[1].sem_name="TEXCOORD"; attrs[1].offset=offsetof(ImDrawVert, uv); attrs[1].format=SG_VERTEXFORMAT_FLOAT2;
attrs[2].sem_name="COLOR"; attrs[2].offset=offsetof(ImDrawVert, col); attrs[2].format=SG_VERTEXFORMAT_UBYTE4N;
pip_desc.shader = shd;
pip_desc.index_type = SG_INDEXTYPE_UINT16;
pip_desc.blend.enabled = true;
pip_desc.blend.src_factor_rgb = SG_BLENDFACTOR_SRC_ALPHA;
pip_desc.blend.dst_factor_rgb = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA;
pip_desc.blend.color_write_mask = SG_COLORMASK_RGB;
draw_state.pipeline = sg_make_pipeline(&pip_desc);
// initial clear color
pass_action.colors[0].action = SG_ACTION_CLEAR;
pass_action.colors[0].val[0] = 0.0f;
pass_action.colors[0].val[1] = 0.5f;
pass_action.colors[0].val[2] = 0.7f;
pass_action.colors[0].val[3] = 1.0f;
// draw loop
while (d3d11_process_events()) {
const int cur_width = d3d11_width();
const int cur_height = d3d11_height();
// this is standard ImGui demo code
ImGuiIO& io = ImGui::GetIO();
io.DisplaySize = ImVec2(float(cur_width), float(cur_height));
io.DeltaTime = (float) stm_sec(stm_laptime(&last_time));
ImGui::NewFrame();
// 1. Show a simple window
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
static float f = 0.0f;
ImGui::Text("Hello, world!");
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
ImGui::ColorEdit3("clear color", &pass_action.colors[0].val[0]);
if (ImGui::Button("Test Window")) show_test_window ^= 1;
if (ImGui::Button("Another Window")) show_another_window ^= 1;
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
// 2. Show another simple window, this time using an explicit Begin/End pair
if (show_another_window) {
ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiSetCond_FirstUseEver);
ImGui::Begin("Another Window", &show_another_window);
ImGui::Text("Hello");
ImGui::End();
}
// 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
if (show_test_window) {
ImGui::SetNextWindowPos(ImVec2(460, 20), ImGuiSetCond_FirstUseEver);
ImGui::ShowTestWindow();
}
// the sokol_gfx draw pass
sg_begin_default_pass(&pass_action, cur_width, cur_height);
ImGui::Render();
sg_end_pass();
sg_commit();
d3d11_present();
}
ImGui::DestroyContext();
sg_shutdown();
d3d11_shutdown();
}
// imgui draw callback
void imgui_draw_cb(ImDrawData* draw_data) {
assert(draw_data);
if (draw_data->CmdListsCount == 0) {
return;
}
// copy vertices and indices
int num_vertices = 0;
int num_indices = 0;
int num_cmdlists = 0;
for (num_cmdlists = 0; num_cmdlists < draw_data->CmdListsCount; num_cmdlists++) {
const ImDrawList* cl = draw_data->CmdLists[num_cmdlists];
const int cl_num_vertices = cl->VtxBuffer.size();
const int cl_num_indices = cl->IdxBuffer.size();
// overflow check
if ((num_vertices + cl_num_vertices) > MaxVertices) {
break;
}
if ((num_indices + cl_num_indices) > MaxIndices) {
break;
}
// copy vertices
memcpy(&vertices[num_vertices], &cl->VtxBuffer.front(), cl_num_vertices*sizeof(ImDrawVert));
// copy indices, need to 'rebase' indices to start of global vertex buffer
const ImDrawIdx* src_index_ptr = &cl->IdxBuffer.front();
const uint16_t base_vertex_index = num_vertices;
for (int i = 0; i < cl_num_indices; i++) {
indices[num_indices++] = src_index_ptr[i] + base_vertex_index;
}
num_vertices += cl_num_vertices;
}
// update vertex and index buffers
const int vertex_data_size = num_vertices * sizeof(ImDrawVert);
const int index_data_size = num_indices * sizeof(uint16_t);
sg_update_buffer(draw_state.vertex_buffers[0], vertices, vertex_data_size);
sg_update_buffer(draw_state.index_buffer, indices, index_data_size);
// render the command list
vs_params_t vs_params;
vs_params.disp_size = ImGui::GetIO().DisplaySize;
sg_apply_draw_state(&draw_state);
sg_apply_uniform_block(SG_SHADERSTAGE_VS, 0, &vs_params, sizeof(vs_params));
int base_element = 0;
for (int cl_index=0; cl_index<num_cmdlists; cl_index++) {
const ImDrawList* cmd_list = draw_data->CmdLists[cl_index];
for (const ImDrawCmd& pcmd : cmd_list->CmdBuffer) {
if (pcmd.UserCallback) {
pcmd.UserCallback(cmd_list, &pcmd);
}
else {
const int sx = (int) pcmd.ClipRect.x;
const int sy = (int) pcmd.ClipRect.y;
const int sw = (int) (pcmd.ClipRect.z - pcmd.ClipRect.x);
const int sh = (int) (pcmd.ClipRect.w - pcmd.ClipRect.y);
sg_apply_scissor_rect(sx, sy, sw, sh, true);
sg_draw(base_element, pcmd.ElemCount, 1);
}
base_element += pcmd.ElemCount;
}
}
}
| 39.525547 | 130 | 0.637027 | VLiance |
8594dcfafda4d2bda1e07bb9eb18ee8bd8228b10 | 2,771 | cpp | C++ | engine/RenderPipelineManager.cpp | shanysheng/orange3d | 9ee081a98e14fdeb3aaafd6bbb49fe027d4cd3c0 | [
"BSD-2-Clause"
] | 11 | 2017-06-06T17:22:30.000Z | 2022-03-23T11:56:49.000Z | engine/RenderPipelineManager.cpp | shanysheng/orange3d | 9ee081a98e14fdeb3aaafd6bbb49fe027d4cd3c0 | [
"BSD-2-Clause"
] | null | null | null | engine/RenderPipelineManager.cpp | shanysheng/orange3d | 9ee081a98e14fdeb3aaafd6bbb49fe027d4cd3c0 | [
"BSD-2-Clause"
] | 5 | 2018-02-07T02:48:59.000Z | 2021-08-23T05:16:59.000Z | #include "RenderPipelineManager.h"
namespace pipeline{
CRenderPipelineManager::CRenderPipelineManager():m_pRenderingEngine(NULL)
{
}
CRenderPipelineManager::~CRenderPipelineManager()
{
ClearRenderPipeline();
ClearPrototypes();
}
IRenderPipeline*CRenderPipelineManager::Give( const std::string& Name, const std::string& PrototypeName )
{
std::unordered_map< std::string, IRenderPipeline *>::iterator pos;
pos = m_RenderPipelines.find(Name);
if (pos!=m_RenderPipelines.end())
{
return pos->second;
}
pos = m_Prototypes.find(PrototypeName);
if (pos!=m_Prototypes.end())
{
IRenderPipeline* pRenderPipeline = pos->second->Clone();
pRenderPipeline->SetContext(this->m_pRenderingEngine);
m_RenderPipelines.insert(std::make_pair(Name, pRenderPipeline));
return pRenderPipeline;
}
return NULL;
}
void CRenderPipelineManager::Register(const std::string& PrototypeName, IRenderPipeline * pPrototype )
{
std::unordered_map< std::string, IRenderPipeline *>::iterator pos;
pos = m_Prototypes.find(PrototypeName);
if (pos!=m_Prototypes.end())
{
if (pos->second)
delete pos->second;
pos->second = pPrototype;
return ;
}
m_Prototypes.insert(std::make_pair(PrototypeName, pPrototype));
}
IRenderPipeline * CRenderPipelineManager::operator [](const std::string& Name)
{
std::unordered_map< std::string, IRenderPipeline *>::iterator pos;
pos = m_RenderPipelines.find(Name);
if(pos == m_RenderPipelines.end())
return NULL;
return pos->second;
}
void CRenderPipelineManager::ClearPrototypes()
{
std::unordered_map< std::string, IRenderPipeline *>::iterator pos;
pos = m_Prototypes.begin();
while (pos!=m_Prototypes.end())
{
if (pos->second)
delete pos->second;
++pos;
}
m_Prototypes.clear();
}
void CRenderPipelineManager::ClearRenderPipeline()
{
std::unordered_map< std::string, IRenderPipeline *>::iterator pos;
pos = m_RenderPipelines.begin();
while (pos!=m_RenderPipelines.end())
{
if (pos->second)
delete pos->second;
++pos;
}
m_RenderPipelines.clear();
}
CRenderModuleManager& CRenderPipelineManager::GetRenderModuleManager()
{
return m_RenderModuleMgr;
}
}
| 27.71 | 109 | 0.568748 | shanysheng |
85a95df74baa0d5171c000bcde253f924c623d5d | 4,791 | hpp | C++ | contrib/autoboost/autoboost/mpl/aux_/logical_op.hpp | CaseyCarter/autowiring | 48e95a71308318c8ffb7ed1348e034fd9110f70c | [
"Apache-2.0"
] | 87 | 2015-01-18T00:43:06.000Z | 2022-02-11T17:40:50.000Z | contrib/autoboost/autoboost/mpl/aux_/logical_op.hpp | CaseyCarter/autowiring | 48e95a71308318c8ffb7ed1348e034fd9110f70c | [
"Apache-2.0"
] | 274 | 2015-01-03T04:50:49.000Z | 2021-03-08T09:01:09.000Z | contrib/autoboost/autoboost/mpl/aux_/logical_op.hpp | CaseyCarter/autowiring | 48e95a71308318c8ffb7ed1348e034fd9110f70c | [
"Apache-2.0"
] | 15 | 2015-09-30T20:58:43.000Z | 2020-12-19T21:24:56.000Z |
// Copyright Aleksey Gurtovoy 2000-2004
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/mpl for documentation.
// $Id$
// $Date$
// $Revision$
// NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION!
#if !defined(AUTOBOOST_MPL_PREPROCESSING_MODE)
# include <autoboost/mpl/bool.hpp>
# include <autoboost/mpl/aux_/nested_type_wknd.hpp>
# include <autoboost/mpl/aux_/na_spec.hpp>
# include <autoboost/mpl/aux_/lambda_support.hpp>
#endif
#include <autoboost/mpl/limits/arity.hpp>
#include <autoboost/mpl/aux_/preprocessor/params.hpp>
#include <autoboost/mpl/aux_/preprocessor/ext_params.hpp>
#include <autoboost/mpl/aux_/preprocessor/def_params_tail.hpp>
#include <autoboost/mpl/aux_/preprocessor/enum.hpp>
#include <autoboost/mpl/aux_/preprocessor/sub.hpp>
#include <autoboost/mpl/aux_/config/ctps.hpp>
#include <autoboost/mpl/aux_/config/workaround.hpp>
#include <autoboost/preprocessor/dec.hpp>
#include <autoboost/preprocessor/inc.hpp>
#include <autoboost/preprocessor/cat.hpp>
namespace autoboost { namespace mpl {
# define AUX778076_PARAMS(param, sub) \
AUTOBOOST_MPL_PP_PARAMS( \
AUTOBOOST_MPL_PP_SUB(AUTOBOOST_MPL_LIMIT_METAFUNCTION_ARITY, sub) \
, param \
) \
/**/
# define AUX778076_SHIFTED_PARAMS(param, sub) \
AUTOBOOST_MPL_PP_EXT_PARAMS( \
2, AUTOBOOST_MPL_PP_SUB(AUTOBOOST_PP_INC(AUTOBOOST_MPL_LIMIT_METAFUNCTION_ARITY), sub) \
, param \
) \
/**/
# define AUX778076_SPEC_PARAMS(param) \
AUTOBOOST_MPL_PP_ENUM( \
AUTOBOOST_PP_DEC(AUTOBOOST_MPL_LIMIT_METAFUNCTION_ARITY) \
, param \
) \
/**/
namespace aux {
#if !defined(AUTOBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
template< bool C_, AUX778076_PARAMS(typename T, 1) >
struct AUTOBOOST_PP_CAT(AUX778076_OP_NAME,impl)
: AUTOBOOST_PP_CAT(AUX778076_OP_VALUE1,_)
{
};
template< AUX778076_PARAMS(typename T, 1) >
struct AUTOBOOST_PP_CAT(AUX778076_OP_NAME,impl)< AUX778076_OP_VALUE2,AUX778076_PARAMS(T, 1) >
: AUTOBOOST_PP_CAT(AUX778076_OP_NAME,impl)<
AUTOBOOST_MPL_AUX_NESTED_TYPE_WKND(T1)::value
, AUX778076_SHIFTED_PARAMS(T, 1)
, AUTOBOOST_PP_CAT(AUX778076_OP_VALUE2,_)
>
{
};
template<>
struct AUTOBOOST_PP_CAT(AUX778076_OP_NAME,impl)<
AUX778076_OP_VALUE2
, AUX778076_SPEC_PARAMS(AUTOBOOST_PP_CAT(AUX778076_OP_VALUE2,_))
>
: AUTOBOOST_PP_CAT(AUX778076_OP_VALUE2,_)
{
};
#else
template< bool C_ > struct AUTOBOOST_PP_CAT(AUX778076_OP_NAME,impl)
{
template< AUX778076_PARAMS(typename T, 1) > struct result_
: AUTOBOOST_PP_CAT(AUX778076_OP_VALUE1,_)
{
};
};
template<> struct AUTOBOOST_PP_CAT(AUX778076_OP_NAME,impl)<AUX778076_OP_VALUE2>
{
template< AUX778076_PARAMS(typename T, 1) > struct result_
: AUTOBOOST_PP_CAT(AUX778076_OP_NAME,impl)<
AUTOBOOST_MPL_AUX_NESTED_TYPE_WKND(T1)::value
>::template result_< AUX778076_SHIFTED_PARAMS(T,1),AUTOBOOST_PP_CAT(AUX778076_OP_VALUE2,_) >
{
};
#if AUTOBOOST_WORKAROUND(AUTOBOOST_MSVC, == 1300)
template<> struct result_<AUX778076_SPEC_PARAMS(AUTOBOOST_PP_CAT(AUX778076_OP_VALUE2,_))>
: AUTOBOOST_PP_CAT(AUX778076_OP_VALUE2,_)
{
};
};
#else
};
template<>
struct AUTOBOOST_PP_CAT(AUX778076_OP_NAME,impl)<AUX778076_OP_VALUE2>
::result_< AUX778076_SPEC_PARAMS(AUTOBOOST_PP_CAT(AUX778076_OP_VALUE2,_)) >
: AUTOBOOST_PP_CAT(AUX778076_OP_VALUE2,_)
{
};
#endif // AUTOBOOST_MSVC == 1300
#endif // AUTOBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
} // namespace aux
template<
typename AUTOBOOST_MPL_AUX_NA_PARAM(T1)
, typename AUTOBOOST_MPL_AUX_NA_PARAM(T2)
AUTOBOOST_MPL_PP_DEF_PARAMS_TAIL(2, typename T, AUTOBOOST_PP_CAT(AUX778076_OP_VALUE2,_))
>
struct AUX778076_OP_NAME
#if !defined(AUTOBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
: aux::AUTOBOOST_PP_CAT(AUX778076_OP_NAME,impl)<
AUTOBOOST_MPL_AUX_NESTED_TYPE_WKND(T1)::value
, AUX778076_SHIFTED_PARAMS(T,0)
>
#else
: aux::AUTOBOOST_PP_CAT(AUX778076_OP_NAME,impl)<
AUTOBOOST_MPL_AUX_NESTED_TYPE_WKND(T1)::value
>::template result_< AUX778076_SHIFTED_PARAMS(T,0) >
#endif
{
AUTOBOOST_MPL_AUX_LAMBDA_SUPPORT(
AUTOBOOST_MPL_LIMIT_METAFUNCTION_ARITY
, AUX778076_OP_NAME
, (AUX778076_PARAMS(T, 0))
)
};
AUTOBOOST_MPL_AUX_NA_SPEC2(
2
, AUTOBOOST_MPL_LIMIT_METAFUNCTION_ARITY
, AUX778076_OP_NAME
)
}}
#undef AUX778076_SPEC_PARAMS
#undef AUX778076_SHIFTED_PARAMS
#undef AUX778076_PARAMS
#undef AUX778076_OP_NAME
#undef AUX778076_OP_VALUE1
#undef AUX778076_OP_VALUE2
| 28.861446 | 104 | 0.736798 | CaseyCarter |
85b0c4fb364783a7874cf6a4da39e9523835dede | 666 | cpp | C++ | server/memory.cpp | FaresMehanna/Monitor-And-Control-Server-Room | 29caea1501a5174c63ba87c47545c889b9cf2e51 | [
"MIT"
] | null | null | null | server/memory.cpp | FaresMehanna/Monitor-And-Control-Server-Room | 29caea1501a5174c63ba87c47545c889b9cf2e51 | [
"MIT"
] | null | null | null | server/memory.cpp | FaresMehanna/Monitor-And-Control-Server-Room | 29caea1501a5174c63ba87c47545c889b9cf2e51 | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <pthread.h>
#include <unistd.h>
#include <stdlib.h>
#include "device.h"
#include "memory.h"
void acquire(DeviceData* device_data) {
printf("acquire.\n");
pthread_mutex_lock(&(device_data->itmes_mutex));
(device_data->memory_pointers)++;
pthread_mutex_unlock(&(device_data->itmes_mutex));
}
void release(DeviceData* device_data) {
printf("release.\n");
pthread_mutex_lock(&(device_data->itmes_mutex));
(device_data->memory_pointers)--;
if(0 == device_data->memory_pointers) {
close(device_data->sockfd);
delete(device_data);
printf("delete.\n");
}
pthread_mutex_unlock(&(device_data->itmes_mutex));
} | 26.64 | 54 | 0.71021 | FaresMehanna |
85c2389dec561ca7a80bd6c08f9934a6746ac57a | 7,736 | cpp | C++ | appsrc/DistributedConfigGenerator.cpp | slashdotted/PomaPure | c469efba9813b4b897129cff9699983c3f90b24b | [
"BSD-3-Clause"
] | 2 | 2017-12-11T01:07:45.000Z | 2021-08-21T20:57:04.000Z | appsrc/DistributedConfigGenerator.cpp | slashdotted/PomaPure | c469efba9813b4b897129cff9699983c3f90b24b | [
"BSD-3-Clause"
] | null | null | null | appsrc/DistributedConfigGenerator.cpp | slashdotted/PomaPure | c469efba9813b4b897129cff9699983c3f90b24b | [
"BSD-3-Clause"
] | 1 | 2017-08-29T17:53:20.000Z | 2017-08-29T17:53:20.000Z | /*
* Copyright (C)2015,2016,2017 Amos Brocco ([email protected])
* Scuola Universitaria Professionale della
* Svizzera Italiana (SUPSI)
* 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 Scuola Universitaria Professionale della Svizzera
* Italiana (SUPSI) 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 <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <boost/property_tree/json_parser.hpp>
#include <boost/lexical_cast.hpp>
#include <cstdlib>
#include "DistributedConfigGenerator.h"
#include <iostream>
namespace poma {
DistributedConfigGenerator::DistributedConfigGenerator(const std::string &p_source_mid,
const std::map<std::string, Module> &p_modules,
const std::vector<Link> &p_links,
unsigned int base_port)
: m_source_mid{p_source_mid}, m_modules{p_modules}, m_links{p_links}, m_base_port{base_port} {
}
void DistributedConfigGenerator::process()
{
for (auto &it : m_modules) {
auto v{m_modules.find(it.first)};
const Module &mod{v->second};
m_host_modules_map.insert(std::make_pair(mod.mhost, mod));
m_module_host_map.insert(std::make_pair(mod.mid, mod.mhost));
}
std::string source_host{m_module_host_map.find(m_source_mid)->second};
Link lnkprocessor;
lnkprocessor.fid = Module::source(source_host);
lnkprocessor.tid = m_source_mid;
m_host_link_map.insert(std::make_pair(source_host, lnkprocessor));
for (auto &lnk : m_links) {
if (lnk.fid == "" || m_module_host_map.count(lnk.fid) == 0) {
die("invalid link definition: invalid or no source specified: " + lnk.fid + ", to " + lnk.tid +
", channel " + lnk.channel);
}
if (lnk.tid == "" || m_module_host_map.count(lnk.tid) == 0) {
die("invalid link definition: invalid or no destination specified: " + lnk.tid + ", from " + lnk.fid +
", channel " + lnk.channel);
}
if (lnk.channel == "") {
die("invalid link definition: channel cannot be empty");
}
std::string fhost{m_module_host_map[lnk.fid]};
std::string thost{m_module_host_map[lnk.tid]};
if (fhost == thost) {
std::cout << fhost << "<->" << thost << std::endl;
m_host_link_map.insert(std::make_pair(fhost, lnk));
} else {
// Insert ZeroMQ bridge
Module sink;
sink.mid = Module::unique("__net_sink_");
sink.mtype = "ZeroMQSink";
sink.mhost = fhost;
sink.mparams["sinkaddress"] = Module::address(thost, m_base_port);
sink.mparams["#bandwidth"] = lnk.bandwidth;
Module source;
source.mid = Module::unique("__net_source");
source.mtype = "ZeroMQSource";
source.mhost = thost;
source.mparams["sourceaddress"] = Module::address("*", m_base_port);
source.mparams["#bandwidth"] = lnk.bandwidth;
++m_base_port;
m_host_modules_map.insert(std::make_pair(sink.mhost, sink));
m_host_modules_map.insert(std::make_pair(source.mhost, source));
m_module_host_map[sink.mid] = sink.mhost;
m_module_host_map[source.mid] = source.mhost;
Link lnksink;
lnksink.fid = lnk.fid;
lnksink.tid = sink.mid;
lnksink.channel = lnk.channel;
lnksink.debug = lnk.debug;
lnksink.bandwidth = lnk.bandwidth;
m_host_link_map.insert(std::make_pair(fhost, lnksink));
Link lnksource;
lnksource.fid = source.mid;
lnksource.tid = lnk.tid;
lnksource.channel = lnk.channel;
lnksource.debug = lnk.debug;
lnksource.bandwidth = lnk.bandwidth;
m_host_link_map.insert(std::make_pair(thost, lnksource));
Link lnkprocessor;
lnkprocessor.fid = Module::source(thost);
lnkprocessor.tid = source.mid;
m_host_link_map.insert(std::make_pair(thost, lnkprocessor));
}
}
// Each host must have a ParProcessor module as source
for (auto const &h: hosts()) {
Module source_pp;
source_pp.mid = Module::source(h);
source_pp.mhost = h;
source_pp.mtype = "ParProcessor";
m_host_modules_map.insert(std::make_pair(source_pp.mhost, source_pp));
m_module_host_map.insert(std::make_pair(source_pp.mid, source_pp.mhost));
}
}
void DistributedConfigGenerator::get_config(const std::string &host, std::string &p_source_mid,
std::map<std::string, Module> &p_modules,
std::vector<Link> &p_links) {
p_source_mid = Module::source(host);
auto iter = m_host_modules_map.equal_range(host);
for (auto it = iter.first; it != iter.second; ++it) {
const Module& module{it->second};
p_modules[module.mid] = module;
}
auto iter2 = m_host_link_map.equal_range(host);
for (auto it = iter2.first; it != iter2.second; ++it) {
p_links.push_back(it->second);
}
}
std::set<std::string> DistributedConfigGenerator::hosts() const {
std::set<std::string> hosts;
for(auto const& h: m_host_modules_map) {
hosts.insert(h.first);
}
return hosts;
}
std::set<std::string> DistributedConfigGenerator::modules(const std::string &host) const {
std::set<std::string> modules;
auto iter = m_host_modules_map.equal_range(host);
for (auto it = iter.first; it != iter.second; ++it) {
const Module& module{it->second};
modules.insert(module.mtype);
}
return modules;
}
} | 47.460123 | 118 | 0.586608 | slashdotted |
85c3a32ec8a115fac835f0e829db3cbda2aa6e23 | 35,918 | cpp | C++ | csl/cslbase/arith07.cpp | arthurcnorman/general | 5e8fef0cc7999fa8ab75d8fdf79ad5488047282b | [
"BSD-2-Clause"
] | null | null | null | csl/cslbase/arith07.cpp | arthurcnorman/general | 5e8fef0cc7999fa8ab75d8fdf79ad5488047282b | [
"BSD-2-Clause"
] | null | null | null | csl/cslbase/arith07.cpp | arthurcnorman/general | 5e8fef0cc7999fa8ab75d8fdf79ad5488047282b | [
"BSD-2-Clause"
] | null | null | null | // arith07.cpp Copyright (C) 1990-2020 Codemist
//
// Arithmetic functions. negation plus a load of Common Lisp things
// for support of complex numbers.
//
//
/**************************************************************************
* Copyright (C) 2020, Codemist. A C Norman *
* *
* 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 relevant *
* 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. *
* *
* 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 OWNERS 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. *
*************************************************************************/
// $Id: arith07.cpp 5387 2020-08-20 19:40:24Z arthurcnorman $
#include "headers.h"
LispObject copyb(LispObject a)
//
// copy a bignum.
//
{ LispObject b;
size_t len = bignum_length(a), i;
push(a);
b = get_basic_vector(TAG_NUMBERS, TYPE_BIGNUM, len);
pop(a);
len = (len-CELL)/4;
for (i=0; i<len; i++)
bignum_digits(b)[i] = vbignum_digits(a)[i];
return b;
}
LispObject negateb(LispObject a)
//
// Negate a bignum. Note that negating the 1-word bignum
// value of 0x08000000 will produce a fixnum as a result (for 32 bits),
// which might confuse the caller... in a similar way negating
// the value -0x40000000 will need to promote from a one-word
// bignum to a 2-word bignum. How messy just for negation!
// And on 64 bit systems the same effect applies but with larger values!
// In an analogous manner negating the positive number of the style
// 0x40000000 can lead to a negative result that uses one less digit.
// Well on a 64-bit machine it is a 2-word bignum that can end up
// negated to get a fixnum result.
//
{ LispObject b;
size_t len = bignum_length(a), i;
int32_t carry;
// There are two messy special cases here. The first is that there is a
// positive value (2^27 or 2^59) which has to be represented as a bignum,
// but when you negate it you get a fixnum.
// Then there will be negative values (the smallest being -2^31 or -2^62)
// that fit in a certain number of words of bignum, but their absolute
// value needs one more word...
// Note that on a 64-bit machine there ought never to be any one-word
// bignums because all the values representable with just one 31-bit digit
// can be handled as fixnums instead.
if (SIXTY_FOUR_BIT &&
len == CELL+8) // two-word bignum - do specially
{ if (bignum_digits(a)[0] == 0 &&
bignum_digits(a)[1] == (int32_t)0x10000000)
return MOST_NEGATIVE_FIXNUM;
else if (bignum_digits(a)[0] == 0 &&
(int32_t)bignum_digits(a)[1] == -(int32_t)(1<<30))
return make_three_word_bignum(0, 1<<30, 0);
uint32_t d0 = bignum_digits(a)[0];
int32_t d1 = (int32_t)~bignum_digits(a)[1];
if (d0 == 0) d1++;
else return make_two_word_bignum(d1, (-d0) & 0x7fffffff);
}
if (!SIXTY_FOUR_BIT &&
len == CELL+4) // one-word bignum - do specially
{ int32_t d0 = -(int32_t)bignum_digits(a)[0];
if (d0 == MOST_NEGATIVE_FIXVAL) return MOST_NEGATIVE_FIXNUM;
else if (d0 == 0x40000000) return make_two_word_bignum(0, d0);
else return make_one_word_bignum(d0);
}
push(a);
b = get_basic_vector(TAG_NUMBERS, TYPE_BIGNUM, len);
pop(a);
len = (len-CELL-4)/4;
carry = -1;
for (i=0; i<len; i++)
{
// The next couple of lines really caught me out wrt compiler optimisation
// before I put in all the casts. I used to have what was in effect
// carry = (signed_x ^ 0x7fffffff) + (int32_t)((uint32_t)carry>>31);
// ... ((uint32_t)carry >> 31);
// and a compiler seems to have observed that the masking leaves the left
// operand of the addition positive, and that the unsigned shift right
// leaves the right operand positive too. So based on an assumption that
// signed integer overflow will not happen it deduces that the sum will also
// be positive, and hence that on the next line (carry>>31) will be zero.
// For the assumption to fail there will have had to be integer overflow, and
// the C/C++ standards say that the consequence of that are undefined - a term
// that can include behaviour as per the optimised code here.
//
// To avoid that I am working on the basis that casts between int32_t and
// uint32_t will leave bit representations unchanged and that arithmetic uses
// twos complement for signed values. Then by casting to unsigned at times
// I can allow a carry to propagate into the top bit of a word without that
// counting as an overflow, and that should force the compiler to do the
// arithmetic in full.
//
// Having spotted this particular case I now worry about how many related
// ones there may be hiding in the code!
//
carry = ADD32(clear_top_bit(~bignum_digits(a)[i]),
top_bit(carry));
bignum_digits(b)[i] = clear_top_bit(carry);
}
// Handle the top digit separately since it is signed.
carry = ADD32(~bignum_digits(a)[i], top_bit(carry));
if (!signed_overflow(carry))
{
// If the most significant word ends up as -1 then I just might
// have 0x40000000 in the next word down and so I may need to shrink
// the number. Since I handled 1-word bignums specially I have at
// least two words to deal with here.
if (carry == -1 && (bignum_digits(b)[i-1] & 0x40000000) != 0)
{ bignum_digits(b)[i-1] |= ~0x7fffffff;
setnumhdr(b, numhdr(b) - pack_hdrlength(1));
if (SIXTY_FOUR_BIT)
{ if ((i & 1) != 0) bignum_digits(b)[i] = 0;
else *reinterpret_cast<Header *>(&bignum_digits(b)[i]) = make_bighdr(
2);
}
else
{ if ((i & 1) == 0) bignum_digits(b)[i] = 0;
else *reinterpret_cast<Header *>(&bignum_digits(b)[i]) = make_bighdr(
2);
}
}
else bignum_digits(b)[i] = carry; // no shrinking needed
return b;
}
// Here I have overflow: this can only happen when I negate a number
// that started off with 0xc0000000 in the most significant digit,
// and I have to pad a zero word onto the front.
bignum_digits(b)[i] = clear_top_bit(carry);
return lengthen_by_one_bit(b, carry);
}
//
// generic negation
//
LispObject negate(LispObject a)
{ switch (static_cast<int>(a) & TAG_BITS)
{ case TAG_FIXNUM:
if (!SIXTY_FOUR_BIT && is_sfloat(a))
return a ^ 0x80000000U;
if (SIXTY_FOUR_BIT && is_sfloat(a))
return a ^ UINT64_C(0x8000000000000000);
else return make_lisp_integer64(-int_of_fixnum(a));
case TAG_NUMBERS:
{ int32_t ha = type_of_header(numhdr(a));
switch (ha)
{ case TYPE_BIGNUM:
return negateb(a);
case TYPE_RATNUM:
{ LispObject n = numerator(a),
d = denominator(a);
push(d);
n = negate(n);
pop(d);
return make_ratio(n, d);
}
case TYPE_COMPLEX_NUM:
{ LispObject r = real_part(a),
i = imag_part(a);
push(i);
r = negate(r);
pop(i);
push(r);
i = negate(i);
pop(r);
return make_complex(r, i);
}
default:
return aerror1("bad arg for minus", a);
}
}
case TAG_BOXFLOAT:
switch (type_of_header(flthdr(a)))
{ case TYPE_SINGLE_FLOAT:
return make_boxfloat(-single_float_val(a),
TYPE_SINGLE_FLOAT);
case TYPE_DOUBLE_FLOAT:
return make_boxfloat(-double_float_val(a),
TYPE_DOUBLE_FLOAT);
#ifdef HAVE_SOFTFLOAT
case TYPE_LONG_FLOAT:
{ float128_t aa = long_float_val(a);
f128M_negate(&aa);
return make_boxfloat128(aa);
}
#endif // HAVE_SOFTFLOAT
}
default:
return aerror1("bad arg for minus", a);
}
}
/*****************************************************************************/
//** Transcendental functions etcetera. **
/*****************************************************************************/
//
// Much of the code here is extracted from the portable Fortran library
// used by Codemist with its Fortran compiler.
//
//
// The object of the following macro is to adjust the floating point
// variables concerned so that the more significant one can be squared
// with NO LOSS OF PRECISION. It is only used when there is no danger
// of over- or under-flow.
//
// This code is NOT PORTABLE but can be modified for use elsewhere
// It should, however, serve for IEEE and IBM FP formats.
//
typedef union _char_double
{ double d;
char c[8];
} char_double_union;
#ifdef LITTLEENDIAN
#define LOW_BITS_OFFSET 0
#else
#define LOW_BITS_OFFSET 4
#endif
// The code here explictly puns between a double and a row of char values
// so that it can force the bottom 32-bits of the represenattion of the
// double to be zero. The use of the char type here and then memset to clear
// it is intended to keep me safe from strict-aliasing concerns, and modern
// C compilers are liable to map the use of memset onto a simple store
// instruction.
#define _fp_normalize(high, low) \
{ char_double_union temp; /* access to representation */ \
temp.d = high; /* take original number */ \
std::memset(&temp.c[LOW_BITS_OFFSET], 0, 4); \
/* make low part of mantissa 0 */ \
low += (high - temp.d); /* add into low-order result */ \
high = temp.d; \
}
//
// A modern C system will provide a datatype "complex double" which
// will (I hope) provide direct implementations of some things I need
// here. However in the end I may prefer not to use it because for
// real floating point I am using crlibm that implements correctly
// rounded and hence consistent across all platforms values. If I use
// that as a basis for my complex code I will at least get bit-for-bit
// identical results everywhere even if I do not manage to achieve
// correctly rounded last-bit performance in all cases.
// log, sqrt and all the inverse trig functions here need careful review
// as to their treatment of -0.0 on branch-cuts!
//
double Cabs(Complex z)
{
//
// Obtain the absolute value of a complex number - note that the main
// agony here is in ensuring that neither overflow nor underflow can
// wreck the calculation. Given ideal arithmetic the sum could be carried
// through as just sqrt(x^2 + y^2).
//
double x = z.real, y = z.imag;
double scale;
int n1, n2;
if (x==0.0) return std::fabs(y);
else if (y==0.0) return std::fabs(x);
static_cast<void>(std::frexp(x, &n1));
static_cast<void>(std::frexp(y, &n2));
// The exact range of values returned by frexp does not matter here
if (n2>n1) n1 = n2;
// n1 is now the exponent of the larger (in absolute value) of x, y
scale = std::ldexp(1.0, n1); // can not be 0.0
x /= scale;
y /= scale;
// The above scaling operation introduces no rounding error (since the
// scale factor is exactly a power of 2). It reduces the larger of x, y
// to be somewhere near 1.0 so overflow in x*x+y*y is impossible. It is
// still possible that one of x*x and y*y will underflow (but not both)
// but this is harmless.
return scale * std::sqrt(x*x + y*y);
}
Complex Ccos(Complex z)
{ double x = z.real, y = z.imag;
//
// cos(x + iy) = cos(x)*cosh(y) - i sin(x)*sinh(y)
// For smallish y this can be used directly. For |y| > 50 I will
// compute sinh and cosh as just +/- exp(|y|)/2
//
double s = std::sin(x), c = std::cos(x);
double absy = std::fabs(y);
if (absy <= 50.0)
{ double sh = std::sinh(y), ch = std::cosh(y);
z.real = c*ch;
z.imag = - s*sh;
return z;
}
else
{ double w;
int n = _reduced_exp(absy, &w) - 1;
z.real = std::ldexp(c*w, n);
if (y < 0.0) z.imag = std::ldexp(s*w, n);
else z.imag = std::ldexp(-s*w, n);
return z;
}
}
static double reduced_power(double a, int n)
{
//
// Compute (1 + a)^n - 1 avoiding undue roundoff error.
// Assumes n >= 1 on entry and that a is small.
//
if (n == 1) return a;
{ double d = reduced_power(a, n/2);
d = (2.0 + d)*d;
if (n & 1) d += (1.0 + d)*a;
return d;
}
}
//
// The following value is included for documentation purposes - it
// give the largest args that can be given to exp() without leading to
// overflow on IEEE-arithmetic machines.
// #define _exp_arg_limit 709.78271289338397
// Note that in any case exp(50.0) will not overflow (it is only 5.2e21),
// so it can be evaluated the simple direct way.
//
int _reduced_exp(double x, double *r)
{
//
// (*r) = exp(x)/2^n; return n;
// where n will be selected so that *r gets set to a fairly small value
// (precise range of r unimportant provided it will be WELL away from
// chances of overflow, even when exp(x) would actually overflow). This
// function may only be called with argument x that is positive and
// large enough that n will end up satisfying n>=1. The coding here
// will ensure that if x>4.0, and in general the use of this function
// will only be for x > 50.
// For IBM hardware it would be good to be able to control the value
// of n mod 4, maybe, to help counter wobbling precision. This is not
// done here.
//
int n;
double f;
n = static_cast<int>(x / 7.625 + 0.5);
//
// 7.625 = 61/8 and is expected to have an exact floating point
// representation here, so f is computed without any rounding error.
// (do I need something like the (x - 0.5) - 0.5 trick here?)
//
f = std::exp(x - 7.625*static_cast<double>(n));
//
// the magic constant is ((exp(61/8) / 2048) - 1) and it arises because
// 61/88 is a decent rational approximation to log(2), hence exp(61/8)
// is almost 2^11. Thus I compute exp(x) as
// 2^(11*n) * (exp(61/8)/2^11)^n * exp(f)
// The first factor is exact, the second is (1+e)^n where e is small and
// n is an integer, so can be computer accurately, and the residue f at the
// end is small enough not to give over-bad trouble.
// The numeric constant given here was calculated with the REDUCE 3.3
// bigfloat package.
//
#define _e61q8 3.81086435594567676751e-4
*r = reduced_power(_e61q8, n)*f + f;
#undef _e61q8
return 11*n;
}
Complex Cexp(Complex z)
{ double x = z.real, y = z.imag;
//
// value is exp(x)*(cos(y) + i sin(y)) but have care with overflow
// Here (and throughout the complex library) there is an opportunity
// to save time by computing sin(y) and cos(y) together. Since this
// code is (to begin with) to sit on top of an arbitrary C library,
// perhaps with hardware support for the calculation of real-valued
// trig functions I am not going to try to realise this saving.
//
double s = std::sin(y), c = std::cos(y);
//
// if x > 50 I will use a cautious sceme which computes exp(x) with
// its (binary) exponent separated. Note that 50.0 is chosen as a
// number noticably smaller than _exp_arg_limit (exp(50) = 5.18e21),
// but is not a critical very special number.
//
if (x <= 50.0) // includes x < 0.0, of course
{ double w = std::exp(x);
z.real = w*c;
z.imag = w*s;
return z;
}
else
{ double w;
int n = _reduced_exp(x, &w);
z.real = std::ldexp(w*c, n);
z.imag = std::ldexp(w*s, n);
return z;
}
}
Complex Cln(Complex z)
{ double x = z.real, y = z.imag;
//
// if x and y are both very large then cabs(z) may be out of range
// even though log or if is OK. Thus it is necessary to perform an
// elaborate scaled calculation here, and not just
// z.real = log(cabs(z));
//
double scale, r;
int n1, n2;
if (x==0.0) r = std::log(std::fabs(y));
else if (y==0.0) r = std::log(std::fabs(x));
else
{ static_cast<void>(std::frexp(x, &n1));
static_cast<void>(std::frexp(y, &n2));
// The exact range of values returned by frexp does not matter here
if (n2>n1) n1 = n2;
scale = std::ldexp(1.0, n1);
x /= scale;
y /= scale;
r = std::log(scale) + 0.5*std::log(x*x + y*y);
}
z.real = r;
//
// The C standard is not very explicit about the behaviour of atan2(0.0, -n)
// while for Fortran it is necessary that this returns +pi not -pi. Hence
// with extreme caution I put a special test here.
//
if (y == 0.0)
if (x < 0.0) z.imag = _pi;
else z.imag = 0.0;
else z.imag = std::atan2(y, x);
return z;
}
//
// Complex raising to a power. This seems to be pretty nasty
// to get right, and the code includes extra high precision variants
// on atan() and log(). Further refinements wrt efficiency may be
// possible later on.
// This code has been partially tested, and seems to be uniformly
// better than using just a**b = exp(b*log(a)), but much more careful
// study is needed before it can possibly be claimed that it is
// right in the sense of not throwing away accuracy when it does not
// have to. I also need to make careful checks to verify that the
// correct (principal) value is computed.
//
//
// The next function is used after arithmetic has been done on extra-
// precision numbers so that the relationship between high and low parts
// is no longer known. Re-instate it.
//
#define _two_minus_25 2.98023223876953125e-8 // 2^(-25)
static double fp_add(double a, double b, double *lowres)
{
// Result is the high part of a+b, with the low part assigned to *lowres
double absa, absb;
if (a >= 0.0) absa = a;
else absa = -a;
if (b >= 0.0) absb = b;
else absb = -b;
if (absa < absb)
{ double t = a; a = b; b = t;
}
// Now a is the larger (in absolute value) of the two numbers
if (absb > absa * _two_minus_25)
{ double al = 0.0, bl = 0.0;
//
// If the exponent difference beweeen a and b is no more than 25 then
// I can add the top part (20 or 24 bits) of a to the top part of b
// without going beyond the 52 or 56 bits that a full mantissa can hold.
//
_fp_normalize(a, al);
_fp_normalize(b, bl);
a = a + b; // No rounding needed here
b = al + bl;
if (a == 0.0)
{ a = b;
b = 0.0;
}
}
//
// The above step leaves b small wrt the value in a (unless a+b led
// to substantial cancellation of leading digits), but leaves the high
// part a with bits everywhere. Force low part of a to zero.
//
{ double al = 0.0;
_fp_normalize(a, al);
b = b + al;
}
if (a >= 0.0) absa = a;
else absa = -a;
if (b >= 0.0) absb = b;
else absb = -b;
if (absb > absa * _two_minus_25)
//
// If on input a is close to -b, then a+b is close to zero. In this
// case the exponents of a abd b matched, and so earlier calculations
// have all been done exactly. Go around again to split residue into
// high and low parts.
//
{ double al = 0.0, bl = 0.0;
_fp_normalize(b, bl);
a = a + b;
_fp_normalize(a, al);
b = bl + al;
}
*lowres = b;
return a;
}
#undef _two_minus_25
static void extended_atan2(double b, double a, double *thetah,
double *thetal)
{ int octant;
double rh, rl, thh, thl;
//
// First reduce the argument to the first octant (i.e. a, b both +ve,
// and b <= a).
//
if (b < 0.0)
{ octant = 4;
a = -a;
b = -b;
}
else octant = 0;
if (a < 0.0)
{ double t = a;
octant += 2;
a = b;
b = -t;
}
if (b > a)
{ double t = a;
octant += 1;
a = b;
b = t;
}
{ static struct
{ double h;
double l;
} _atan[] =
{
//
// The table here gives atan(n/16) in 1.5-precision for n=0..16
// Note that all the magic numbers used in this file were calculated
// using the REDUCE bigfloat package, and all the 'exact' parts have
// a denominator of at worst 2^26 and so are expected to have lots
// of trailing zero bits in their floating point representation.
//
{ 0.0, 0.0 },
{ 0.06241881847381591796875, -0.84778585694947708870e-8 },
{ 0.124355018138885498046875, -2.35921240630155201508e-8 },
{ 0.185347974300384521484375, -2.43046897565983490387e-8 },
{ 0.2449786663055419921875, -0.31786778380154175187e-8 },
{ 0.302884876728057861328125, -0.83530864557675689054e-8 },
{ 0.358770668506622314453125, 0.17639499059427950639e-8 },
{ 0.412410438060760498046875, 0.35366268088529162896e-8 },
{ 0.4636476039886474609375, 0.50121586552767562314e-8 },
{ 0.512389481067657470703125, -2.07569197640365239794e-8 },
{ 0.558599293231964111328125, 2.21115983246433832164e-8 },
{ 0.602287352085113525390625, -0.59501493437085023057e-8 },
{ 0.643501102924346923828125, 0.58689374629746842287e-8 },
{ 0.6823165416717529296875, 1.32029951485689299817e-8 },
{ 0.71882998943328857421875, 1.01883359311982641515e-8 },
{ 0.75315129756927490234375, -1.66070805128190106297e-8 },
{ 0.785398185253143310546875, -2.18556950009312141541e-8 }
};
int k = static_cast<int>(16.0*(b/a + 0.03125)); // 0 to 16
double kd = static_cast<double>(k)/16.0;
double ah = a, al = 0.0,
bh = b, bl = 0.0,
ch, cl, q, q2;
_fp_normalize(ah, al);
_fp_normalize(bh, bl);
ch = bh - ah*kd; cl = bl - al*kd;
ah = ah + bh*kd; al = al + bl*kd;
bh = ch; bl = cl;
// Now |(a/b)| <= 1/32
ah = fp_add(ah, al, &al); // Re-normalise
bh = fp_add(bh, bl, &bl);
// Compute approximation to b/a
rh = (bh + bl)/(ah + al); rl = 0.0;
_fp_normalize(rh, rl);
bh -= ah*rh; bl -= al*rh;
rl = (bh + bl)/(ah + al); // Quotient now formed
//
// Now it is necessary to compute atan(q) to one-and-a-half precision.
// Since |q| < 1/32 I will leave just q as the high order word of
// the result and compute atan(q)-q as a single precision value. This
// gives about 16 bits accuracy beyond regular single precision work.
//
q = rh + rl;
q2 = q*q;
// The expansion the follows could be done better using a minimax poly
rl -= q*q2*(0.33333333333333333333 -
q2*(0.20000000000000000000 -
q2*(0.14285714285714285714 -
q2*(0.11111111111111111111 -
q2* 0.09090909090909090909))));
// OK - now (rh, rl) is atan(reduced b/a). Need to add on atan(kd)
rh += _atan[k].h;
rl += _atan[k].l;
}
//
// The following constants give high precision versions of pi and pi/2,
// and the high partwords (p2h and pih) have lots of low order zero bits
// in their binary representation. Expect (=require) that the arithmetic
// that computes thh is done without introduced rounding error.
//
#define _p2h 1.57079632580280303955078125
#define _p2l 9.92093579680540441639751e-10
#define _pih 3.14159265160560607910156250
#define _pil 1.984187159361080883279502e-9
switch (octant)
{ default:
case 0: thh = rh; thl = rl; break;
case 1: thh = _p2h - rh; thl = _p2l - rl; break;
case 2: thh = _p2h + rh; thl = _p2l + rl; break;
case 3: thh = _pih - rh; thl = _pil - rl; break;
case 4: thh = -_pih + rh; thl = -_pil + rl; break;
case 5: thh = -_p2h - rh; thl = -_p2l - rl; break;
case 6: thh = -_p2h + rh; thl = -_p2l + rl; break;
case 7: thh = -rh; thl = -rl; break;
}
#undef _p2h
#undef _p2l
#undef _pih
#undef _pil
*thetah = fp_add(thh, thl, thetal);
}
static void extended_log(int k, double a, double b,
double *logrh, double *logrl)
{
//
// If we had exact arithmetic this procedure could be:
// k*log(2) + 0.5*log(a^2 + b^2)
//
double al = 0.0, bl = 0.0, all = 0.0, bll = 0.0, c, ch, cl, cll;
double w, q, qh, ql, rh, rl;
int n;
//
// First (a^2 + b^2) is calculated, using extra precision.
// Because any rounding at this stage can lead to bad errors in
// the power that I eventually want to compute, I use 3-word
// arithmetic here, and with the version of _fp_normalize given
// above and IEEE or IBM370 arithmetic this part of the
// computation is exact.
//
_fp_normalize(a, al); _fp_normalize(al, all);
_fp_normalize(b, bl); _fp_normalize(bl, bll);
ch = a*a + b*b;
cl = 2.0*(a*al + b*bl);
cll = (al*al + bl*bl) +
all*(2.0*(a + al) + all) +
bll*(2.0*(b + bl) + bll);
_fp_normalize(ch, cl);
_fp_normalize(cl, cll);
c = ch + (cl + cll); // single precision approximation
//
// At this stage the scaling of the input value will mean that we
// have 0.25 <= c <= 2.0
//
// Now rewrite things as
// (2*k + n)*log(s) + 0.5*log((a^2 + b^2)/2^n))
// where s = sqrt(2)
// and where the arg to the log is in sqrt(0.5), sqrt(2)
//
#define _sqrt_half 0.70710678118654752440
#define _sqrt_two 1.41421356237309504880
k = 2*k;
while (c < _sqrt_half)
{ k -= 1;
ch *= 2.0;
cl *= 2.0;
cll *= 2.0;
c *= 2.0;
}
while (c > _sqrt_two)
{ k += 1;
ch *= 0.5;
cl *= 0.5;
cll *= 0.5;
c *= 0.5;
}
#undef _sqrt_half
#undef _sqrt_two
n = static_cast<int>(16.0/c + 0.5);
w = static_cast<double>(n) / 16.0;
ch *= w;
cl *= w;
cll *= w; // Now |c-1| < 0.04317
ch = (ch - 0.5) - 0.5;
ch = fp_add(ch, cl, &cl);
cl = cl + cll;
//
// (ch, cl) is now the reduced argument ready for calculating log(1+c),
// and now that the reduction is over I can drop back to the use of just
// two doubleprecision values to represent c.
//
c = ch + cl;
qh = c / (2.0 + c);
ql = 0.0;
_fp_normalize(qh, ql);
ql = ((ch - qh*(2.0 + ch)) + cl - qh*cl) / (2.0 + c);
// (qh, ql) is now c/(2.0 + c)
rh = qh; // 18 bits bigger than low part will end up
q = qh + ql;
w = q*q;
rl = ql + q*w*(0.33333333333333333333 +
w*(0.20000000000000000000 +
w*(0.14285714285714285714 +
w*(0.11111111111111111111 +
w*(0.09090909090909090909)))));
//
// (rh, rl) is now atan(c) correct to double precision plus about 18 bits.
//
{ double temp;
static struct
{ double h;
double l;
} _log_table[] =
{
//
// The following values are (in extra precision) -log(n/16)/2 for n
// in the range 11 to 23 (i.e. roughly over sqrt(2)/2 to sqrt(2))
//
{ 0.1873466968536376953125, 2.786706765149099245e-8 },
{ 0.1438410282135009765625, 0.801238948715710950e-8 },
{ 0.103819668292999267578125, 1.409612298322959552e-8 },
{ 0.066765725612640380859375, -2.930037906928620319e-8 },
{ 0.0322692394256591796875, 2.114312640614896196e-8 },
{ 0.0, 0.0 },
{ -0.0303122997283935546875, -1.117982386660280307e-8 },
{ -0.0588915348052978515625, 1.697710612429310295e-8 },
{ -0.08592510223388671875, -2.622944289242004947e-8 },
{ -0.111571788787841796875, 1.313073691899185245e-8 },
{ -0.135966837406158447265625, -2.033566243215020975e-8 },
{ -0.159226894378662109375, 2.881939480146987639e-8 },
{ -0.18145275115966796875, 0.431498374218108783e-8 }
};
rh = fp_add(rh, _log_table[n-11].h, &temp);
rl = temp + _log_table[n-11].l + rl;
}
#define _exact_part_logroot2 0.3465735912322998046875
#define _approx_part_logroot2 (-9.5232714997888393927e-10)
// Multiply this by k and add it in
{ double temp, kd = static_cast<double>(k);
rh = fp_add(rh, kd*_exact_part_logroot2, &temp);
rl = rl + temp + kd*_approx_part_logroot2;
}
#undef _exact_part_logroot2
#undef _approx_part_logroot2
*logrh = rh;
*logrl = rl;
return;
}
Complex Cpow(Complex z1, Complex z2)
{ double a = z1.real, b = z1.imag,
c = z2.real, d = z2.imag;
int k, m, n;
double scale;
double logrh, logrl, thetah, thetal;
double r, i, rh, rl, ih, il, clow, dlow, q;
double cw, sw, cost, sint;
if (b == 0.0 && d == 0.0 &&
a >= 0.0)// Simple case if both args are real
{ z1.real = std::pow(a, c);
z1.imag = 0.0;
return z1;
}
//
// Start by scaling z1 by dividing out a power of 2 so that |z1| is
// fairly close to 1
//
if (a == 0.0)
{ if (b == 0.0) return z1; // 0.0**anything is really an error
// The exact values returned by frexp do not matter here
static_cast<void>(std::frexp(b, &k));
}
else
{ static_cast<void>(std::frexp(a, &k));
if (b != 0.0)
{ int n;
static_cast<void>(std::frexp(b, &n));
if (n > k) k = n;
}
}
scale = std::ldexp(1.0, k);
a /= scale;
b /= scale;
//
// The idea next is to express z1 as r*exp(i theta), then z1**z2
// is exp(z2*log(z1)) and the exponent simplifies to
// (c*log r - d*theta) + i(c theta + d log r).
// Note r = scale*sqrt(a*a + b*b) now.
// The argument for exp() must be computed to noticably more than
// regular precision, since otherwise exp() greatly magnifies the
// error in the real part (if it is large and positive) and range
// reduction in the imaginary part can equally lead to accuracy
// problems. Neither c nor d can usefully be anywhere near the
// extreme range of floating point values, so I will not even try
// to scale them, thus I will end up happy(ish) if I can compute
// atan2(b, a) and log(|z1|) in one-and-a-half precision form.
// It would be best to compute theta in units of pi/4 rather than in
// raidians, since then the case of z^n (integer n) with arg(z) an
// exact multiple of pi/4 would work out better. However at present I
// just hope that the 1.5-precision working is good enough.
//
extended_atan2(b, a, &thetah, &thetal);
extended_log(k, a, b, &logrh, &logrl);
// Normalise all numbers
clow = 0.0;
dlow = 0.0;
_fp_normalize(c, clow);
_fp_normalize(d, dlow);
// (rh, rl) = c*logr - d*theta;
rh = c*logrh - d*thetah; // No rounding in this computation
rl = c*logrl + clow*(logrh + logrl) - d*thetal - dlow*
(thetah + thetal);
// (ih, il) = c*theta + d*logr;
ih = c*thetah + d*logrh; // No rounding in this computation
il = c*thetal + clow*(thetah + thetal) + d*logrl + dlow*
(logrh + logrl);
//
// Now it remains to take the exponential of the extended precision
// value in ((rh, rl), (ih, il)).
// Range reduce the real part by multiples of log(2), and the imaginary
// part by multiples of pi/2.
//
rh = fp_add(rh, rl, &rl); // renormalise
r = rh + rl; // Approximate value
#define _recip_log_2 1.4426950408889634074
q = r * _recip_log_2;
m = (q < 0.0) ? static_cast<int>(q - 0.5) : static_cast<int>(q + 0.5);
q = static_cast<double>(m);
#undef _recip_log_2
//
// log 2 = 11629080/2^24 - 0.000 00000 19046 54299 95776 78785
// to reasonable accuracy. It is vital that the exact part be
// read in as a number with lots of low zero bits, so when it gets
// multiplied by the integer q there is NO rounding needed.
//
#define _exact_part_log2 0.693147182464599609375
#define _approx_part_log2 (-1.9046542999577678785418e-9)
rh = rh - q*_exact_part_log2;
rl = rl - q*_approx_part_log2;
#undef _exact_part_log2
#undef _approx_part_log2
r = std::exp(rh + rl); // This should now be accurate enough
ih = fp_add(ih, il, &il);
i = ih + il; // Approximate value
#define _recip_pi_by_2 0.6366197723675813431
q = i * _recip_pi_by_2;
n = (q < 0.0) ? static_cast<int>(q - 0.5) : static_cast<int>(q + 0.5);
q = static_cast<double>(n);
//
// pi/2 = 105414357/2^26 + 0.000 00000 09920 93579 68054 04416 39751
// to reasonable accuracy. It is vital that the exact part be
// read in as a number with lots of low zero bits, so when it gets
// multiplied by the integer q there is NO rounding needed.
//
#define _exact_part_pi2 1.57079632580280303955078125
#define _approx_part_pi2 9.92093579680540441639751e-10
ih = ih - q*_exact_part_pi2;
il = il - q*_approx_part_pi2;
#undef _recip_pi_by_2
#undef _exact_part_pi2
#undef _approx_part_pi2
i = ih + il; // Now accurate enough
//
// Having done super-careful range reduction I can call the regular
// sin/cos routines here. If sin/cos could both be computed together
// that could speed things up a little bit, but by this stage they have
// not much in common.
//
cw = std::cos(i);
sw = std::sin(i);
switch (n & 3) // quadrant control
{ default:
case 0: cost = cw; sint = sw; break;
case 1: cost = -sw; sint = cw; break;
case 2: cost = -cw; sint = -sw; break;
case 3: cost = sw; sint = -cw; break;
}
//
// Now, at long last, I can assemble the results and return.
//
z1.real = std::ldexp(r*cost, m);
z1.imag = std::ldexp(r*sint, m);
return z1;
}
//
// End of complex-to-complex-power code.
//
// end of arith07.cpp
| 36.914697 | 85 | 0.587143 | arthurcnorman |
85c99d2b6b4215afc6f0ae82c6234c5939f9b5cc | 7,056 | cpp | C++ | src/testcase/backtrace.cpp | jjg1914/testcase | 1edca3295ea65d654f0b363bd0bde8c0f0b653f3 | [
"MIT"
] | null | null | null | src/testcase/backtrace.cpp | jjg1914/testcase | 1edca3295ea65d654f0b363bd0bde8c0f0b653f3 | [
"MIT"
] | null | null | null | src/testcase/backtrace.cpp | jjg1914/testcase | 1edca3295ea65d654f0b363bd0bde8c0f0b653f3 | [
"MIT"
] | null | null | null | #include <bfd.h>
#include <execinfo.h>
#include <cxxabi.h>
#include <csignal>
#include <cmath>
#include <map>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <memory>
#include "testcase/backtrace.h"
using namespace std;
using namespace testcase;
#define BACKTRACE_BUF_SIZE \
(sizeof(backtrace_buf)/sizeof(backtrace_buf[0]))
namespace {
backtrace_exception_f exception_handler;
void* backtrace_buf[1024];
struct BFD_info {
bool found;
string filename;
string functionname;
unsigned int line;
};
struct BFD {
static void init();
BFD(const string &fname);
~BFD();
BFD_info addr_info(const string &addr);
bfd_vma addr_vma(const string &addr);
private:
static void find_addr(bfd* p, asection *section, void *data);
bfd* ptr_bfd;
map<string,bfd_vma> map_syms;
static bfd_vma pc;
static asymbol **info_symtab;
static bfd_boolean info_found;
static const char* info_filename;
static const char* info_functionname;
static unsigned int info_line;
};
std::string sym2fname(const char *sym);
std::string sym2addr(const char *sym);
void handle_terminate();
void handle_sigsegv(int);
void handle_sigfpe(int);
void handle_sigill(int);
void handle_sigbus(int);
}
bfd_vma BFD::pc;
asymbol **BFD::info_symtab = NULL;
bfd_boolean BFD::info_found = 0;
const char* BFD::info_filename;
const char* BFD::info_functionname;
unsigned int BFD::info_line;
void BFD::init()
{
bfd_init();
}
BFD::BFD(const string &fname)
: ptr_bfd(bfd_openr(fname.c_str(),NULL))
{
char **matching;
if (ptr_bfd &&
!bfd_check_format(ptr_bfd, bfd_archive) &&
bfd_check_format_matches(ptr_bfd, bfd_object, &matching) &&
bfd_get_file_flags(ptr_bfd) & HAS_SYMS) {
unsigned int size;
asymbol **symtab;
long symc = bfd_read_minisymbols(ptr_bfd, 0, (void**) &symtab, &size);
if (symc == 0) {
symc = bfd_read_minisymbols(ptr_bfd, 1, (void**) &symtab, &size);
}
for (int i = 0; i < symc; ++i) {
symbol_info info;
bfd_symbol_info(symtab[i], &info);
map_syms.emplace(symtab[i]->name, info.value);
}
}
}
BFD::~BFD()
{
if (ptr_bfd) {
bfd_close(ptr_bfd);
}
}
BFD_info BFD::addr_info(const string &addr)
{
BFD_info rval;
pc = addr_vma(addr);
rval.found = (info_found = 0);
bfd_map_over_sections(ptr_bfd,BFD::find_addr, NULL);
if (info_found) {
rval.found = true;
rval.filename = (info_filename ? info_filename : "");
rval.functionname = (info_functionname ? info_functionname :
"Anonymous Function");
rval.line = info_line;
}
return rval;
}
bfd_vma BFD::addr_vma(const string &addr)
{
int i = addr.find_last_of('+');
bfd_vma base = 0;
if (i > 0) {
string sym = addr.substr(0,i);
auto it = map_syms.find(sym);
if (it != map_syms.end()) {
base = it->second;
}
}
bfd_vma offset = bfd_scan_vma(addr.substr(i + 1).c_str(), NULL, 16);
return base + offset;
}
void BFD::find_addr(bfd* p, asection *section, void *)
{
bfd_vma vma;
bfd_size_type size;
if (info_found)
return;
if ((bfd_get_section_flags(p, section) & SEC_ALLOC) == 0)
return;
vma = bfd_get_section_vma(p, section);
if (pc < vma)
return;
size = bfd_get_section_size(section);
if (pc >= vma + size)
return;
info_found = bfd_find_nearest_line(p, section, info_symtab, pc - vma,
&info_filename, &info_functionname, &info_line);
}
namespace {
std::string sym2fname(const char *sym) {
string base(sym);
int i = base.size() - 1;
while (base[i] != '(') {
--i;
}
return base.substr(0,i);
}
std::string sym2addr(const char *sym) {
string base(sym);
int e = base.size() - 1, s;
while (base[e] != ')') {
--e;
}
s = e;
while (base[s] != '(') {
--s;
}
if (e - s == 1) {
e = base.size() - 1;
while (base[e] != ']') {
--e;
}
s = e;
while (base[s] != '[') {
--s;
}
}
return base.substr(s + 1,e - s - 1);
}
void handle_terminate()
{
static bool recursive_guard = 0;
static int init_depth = 0;
ErrorInfo info(ErrorInfo::ETERM, backtrace_depth());
try {
if (recursive_guard) {
exception e;
info.depth = init_depth;
exception_handler(info, e);
} else {
recursive_guard = true;
init_depth = info.depth;;
throw;
}
} catch (exception &e) {
info.eno = ErrorInfo::EEXP;
exception_handler(info, e);
} catch (...) {
exception e;
info.eno = ErrorInfo::EUNKNOWN;
exception_handler(info, e);
}
}
void handle_sigsegv(int)
{
ErrorInfo info(ErrorInfo::ESEGV, backtrace_depth());
exception e;
exception_handler(info, e);
}
void handle_sigfpe(int)
{
ErrorInfo info(ErrorInfo::EFPE, backtrace_depth());
exception e;
exception_handler(info, e);
}
void handle_sigill(int)
{
ErrorInfo info(ErrorInfo::EILL, backtrace_depth());
exception e;
exception_handler(info, e);
}
void handle_sigbus(int)
{
ErrorInfo info(ErrorInfo::EBUS, backtrace_depth());
exception e;
exception_handler(info, e);
}
}
testcase::ErrorInfo::ErrorInfo(Errno eno, int depth)
: eno(eno),
depth(depth)
{}
std::string testcase::sbacktrace(int bottom, int top)
{
stringstream ss;
int size = backtrace((void**)&backtrace_buf,BACKTRACE_BUF_SIZE);
char **sym = backtrace_symbols(backtrace_buf, size);
BFD::init();
map<string,BFD> str2bfd;
int s = size - bottom + 1;
int width = log10(size - top - 1 - s) + 1;
for (int i = s; i < size - top - 1; ++i) {
string fname(sym2fname(sym[i]));
BFD& rbfd = str2bfd.emplace(fname, fname).first->second;
BFD_info info = rbfd.addr_info(sym2addr(sym[i]));
if (info.found) {
ss << setw(width) << (i - s);
ss << ": " << backtrace_demangle(info.functionname) << endl;
ss << string(width + 2,' ');
ss << "[" << info.filename << ":" << info.line << "]" << endl;
ss << string(width + 2,' ');
ss << fname << "(+0x" << hex << rbfd.addr_vma(sym2addr(sym[i])) << ")";
ss << dec << endl;
} else {
ss << setw(width) << (i - s) << ": " << sym[i] << endl;
}
}
free(sym);
return ss.str();
}
void testcase::backtrace_exception(const std::function<void(const ErrorInfo&,
const std::exception &e)> &f)
{
exception_handler = f;
set_terminate(handle_terminate);
signal(SIGSEGV,handle_sigsegv);
signal(SIGFPE,handle_sigfpe);
signal(SIGILL,handle_sigill);
signal(SIGBUS,handle_sigbus);
}
std::string testcase::backtrace_demangle(const std::string &sym)
{
int status;
unique_ptr<char> realname(abi::__cxa_demangle(sym.c_str(), 0, 0, &status));
if (status) {
return sym;
} else {
return realname.get();
}
}
int testcase::backtrace_depth()
{
return backtrace((void**)&backtrace_buf,BACKTRACE_BUF_SIZE) - 1;
}
void testcase::backtrace_trap()
{
raise(SIGTRAP);
}
| 21.512195 | 77 | 0.618906 | jjg1914 |
85cb6cbecfb350484fccd1aee3264ef374dbd7b6 | 4,152 | cpp | C++ | src/guacamole/guac_clipboard.cpp | unk0rrupt/collab-vm-server | 30a18cc91b757216a08e900826b589ce29bc3bf0 | [
"Apache-2.0"
] | 74 | 2020-12-20T19:29:21.000Z | 2021-12-04T14:59:29.000Z | src/guacamole/guac_clipboard.cpp | unk0rrupt/collab-vm-server | 30a18cc91b757216a08e900826b589ce29bc3bf0 | [
"Apache-2.0"
] | 2 | 2020-12-27T12:10:50.000Z | 2021-01-24T12:38:24.000Z | src/guacamole/guac_clipboard.cpp | unk0rrupt/collab-vm-server | 30a18cc91b757216a08e900826b589ce29bc3bf0 | [
"Apache-2.0"
] | 4 | 2020-12-20T14:28:11.000Z | 2021-08-20T17:01:11.000Z | /*
* Copyright (C) 2014 Glyptodon 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.
*/
#define _CRT_SECURE_NO_WARNINGS
#include "config.h"
#include "guac_clipboard.h"
#include "guacamole/protocol.h"
#include "guacamole/stream.h"
#include "GuacClient.h"
#include "GuacUser.h"
#include <string.h>
#include <stdlib.h>
guac_common_clipboard* guac_common_clipboard_alloc(int size) {
guac_common_clipboard* clipboard = (guac_common_clipboard*)malloc(sizeof(guac_common_clipboard));
/* Init clipboard */
clipboard->mimetype[0] = '\0';
clipboard->buffer = (char*)malloc(size);
clipboard->length = 0;
clipboard->available = size;
return clipboard;
}
void guac_common_clipboard_free(guac_common_clipboard* clipboard) {
free(clipboard->buffer);
free(clipboard);
}
/**
* Callback for guac_client_foreach_user() which sends clipboard data to each
* connected client.
*/
static void __send_user_clipboard(GuacUser* user, void* data) {
guac_common_clipboard* clipboard = (guac_common_clipboard*) data;
char* current = clipboard->buffer;
int remaining = clipboard->length;
/* Begin stream */
guac_stream* stream = user->AllocStream();
guac_protocol_send_clipboard(user->socket_, stream, clipboard->mimetype);
user->Log(GUAC_LOG_DEBUG,
"Created stream %i for %s clipboard data.",
stream->index, clipboard->mimetype);
/* Split clipboard into chunks */
while (remaining > 0) {
/* Calculate size of next block */
int block_size = GUAC_COMMON_CLIPBOARD_BLOCK_SIZE;
if (remaining < block_size)
block_size = remaining;
/* Send block */
guac_protocol_send_blob(user->socket_, stream, current, block_size);
user->Log(GUAC_LOG_DEBUG,
"Sent %i bytes of clipboard data on stream %i.",
block_size, stream->index);
/* Next block */
remaining -= block_size;
current += block_size;
}
user->Log(GUAC_LOG_DEBUG,
"Clipboard stream %i complete.",
stream->index);
/* End stream */
guac_protocol_send_end(user->socket_, stream);
user->FreeStream(stream);
}
void guac_common_clipboard_send(guac_common_clipboard* clipboard, GuacClient* client) {
//guac_client_log(client, GUAC_LOG_DEBUG, "Broadcasting clipboard to all connected users.");
//guac_client_foreach_user(client, __send_user_clipboard, clipboard);
//guac_client_log(client, GUAC_LOG_DEBUG, "Broadcast of clipboard complete.");
}
void guac_common_clipboard_reset(guac_common_clipboard* clipboard, const char* mimetype) {
clipboard->length = 0;
strncpy(clipboard->mimetype, mimetype, sizeof(clipboard->mimetype)-1);
}
void guac_common_clipboard_append(guac_common_clipboard* clipboard, const char* data, int length) {
/* Truncate data to available length */
int remaining = clipboard->available - clipboard->length;
if (remaining < length)
length = remaining;
/* Append to buffer */
memcpy(clipboard->buffer + clipboard->length, data, length);
/* Update length */
clipboard->length += length;
}
| 32.692913 | 99 | 0.71315 | unk0rrupt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.