hexsha
stringlengths
40
40
size
int64
7
1.05M
ext
stringclasses
13 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
4
269
max_stars_repo_name
stringlengths
5
108
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
listlengths
1
9
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
4
269
max_issues_repo_name
stringlengths
5
116
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
listlengths
1
9
max_issues_count
float64
1
77k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
4
269
max_forks_repo_name
stringlengths
5
116
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
listlengths
1
9
max_forks_count
float64
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
653k
max_line_length
int64
6
990k
alphanum_fraction
float64
0.01
1
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
275539f8ed66e07326ce2c9dd10b293a6a2da793
3,424
cpp
C++
vintergatan/octree_tests.cpp
anfive/vintergatan
3de81defc0e49a3e0f0194df6191f68751f02b39
[ "MIT" ]
null
null
null
vintergatan/octree_tests.cpp
anfive/vintergatan
3de81defc0e49a3e0f0194df6191f68751f02b39
[ "MIT" ]
null
null
null
vintergatan/octree_tests.cpp
anfive/vintergatan
3de81defc0e49a3e0f0194df6191f68751f02b39
[ "MIT" ]
null
null
null
/* octree_tests.cpp Author: Andrea Ferrario Some quick and simple tests for the octree data structure and its methods. They mostly rely on Octree's internal verify() method to check the results (or I ran them with the debugger and checked manually - no time to write better checks...) */ #include <iostream> #include <algorithm> #include "octree.h" #ifdef _MSC_VER void test1() { Octree o; std::vector<Particle> p(4); p[0].pos = Vector3(-.5, -.5, -1.0); p[1].pos = Vector3(.5, -.5, -1.0); p[2].pos = Vector3(-.5, .5, -1.0); p[3].pos = Vector3(.5, .5, -1.0); for (int i = 0; i < p.size(); ++i) { p[i].index = MortonIndex(p[i].pos); } std::sort(p.begin(), p.end(), [](const Particle& p1, const Particle& p2) { return p1.index < p2.index; }); for (int i = 0; i < p.size(); ++i) { o.addParticle(&p[i]); } } void test2() { auto mi0 = MortonIndex(Vector3(-1.0, -1.0, -1.0)); auto mi1 = MortonIndex(Vector3(1.0, 1.0, 1.0)); auto mi2 = MortonIndex(Vector3(0.0, 0.0, 0.0)); auto mi3 = MortonIndex(Vector3(0.001, 0.0, 0.0)); auto mi4 = MortonIndex(Vector3(0.0, 0.001, 0.0)); auto mi5 = MortonIndex(Vector3(0.0, 0.0, 0.001)); auto mi6 = MortonIndex(Vector3(-1.0+0.001, -1.0, -1.0)); auto mi7 = MortonIndex(Vector3(-1.0, -1.0+0.001, -1.0)); auto mi8 = MortonIndex(Vector3(-1.0, - 1.0, -1.0+0.001)); auto mi2_1 = mi2.getIndexAtLevel(1); auto mi2_2 = mi2.getIndexAtLevel(2); assert(mi2_1 == mi2_2.getIndexAtLevel(1)); auto eq1 = MortonIndex(Vector3(-1.0, -1.0, -1.0)); auto eq2 = MortonIndex(Vector3(-1.0 + 1.999 / pow(2.0, MAX_OCTREE_DEPTH), -1.0, -1.0)); assert(eq1 == eq2); eq1 = MortonIndex(Vector3(-1.0, -1.0, -1.0)); eq2 = MortonIndex(Vector3(-1.0 + 2.0 / pow(2.0, MAX_OCTREE_DEPTH), -1.0, -1.0)); assert(eq1 != eq2); } void test3() { Octree o; int ix = 0; std::vector<Particle> p(6); p[ix++].pos = Vector3(-.5, -.5, -1.0); p[ix++].pos = Vector3(.5, -.5, -1.0); p[ix++].pos = Vector3(-.5, .5, -1.0); p[ix++].pos = Vector3(-.5 + 0.0001, .5, -1.0); p[ix++].pos = Vector3(-.5 + 0.0002, .5, -1.0); p[ix++].pos = Vector3(.5, .5, -1.0); for (int i = 0; i < p.size(); ++i) { p[i].index = MortonIndex(p[i].pos); } std::sort(p.begin(), p.end(), [](const Particle& p1, const Particle& p2) { return p1.index < p2.index; }); for (int i = 0; i < p.size(); ++i) { o.addParticle(&p[i]); } o.computeCOMs(); } void test4() { Octree o; int ix = 0; std::vector<Particle> p(4); p[ix++].pos = Vector3(-1.0, -1.0, -1.0); p[ix++].pos = Vector3(-1.0 + 2.0 / pow(2.0, MAX_OCTREE_DEPTH), -1.0, -1.0); p[ix++].pos = Vector3(1.0, 1.0, 1.0); p[ix++].pos = Vector3(1.0 - 2.0001 / pow(2.0, MAX_OCTREE_DEPTH), 1.0, 1.0); for (int i = 0; i < p.size(); ++i) { p[i].index = MortonIndex(p[i].pos); } std::sort(p.begin(), p.end(), [](const Particle& p1, const Particle& p2) { return p1.index < p2.index; }); for (int i = 0; i < p.size(); ++i) { o.addParticle(&p[i]); } o.computeCOMs(); } void octreeTests() { std::cout << "Running octree unit tests" << std::endl; test1(); test2(); test3(); test4(); std::cout << "Done." << std::endl; } #else void octreeTests() { std::cout << "Octree unit tests not available." << std::endl; } #endif
25.176471
109
0.543808
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
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
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
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
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
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
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
27645cc5b63715c2686976d8c80b04e1667d197e
330
cpp
C++
Black Horse C++/ex0027_encapsulation/main.cpp
Dragontalker/CPP-study-notes
d9ebd183d414d2de247ef37c03a24504dd3053d5
[ "MIT" ]
null
null
null
Black Horse C++/ex0027_encapsulation/main.cpp
Dragontalker/CPP-study-notes
d9ebd183d414d2de247ef37c03a24504dd3053d5
[ "MIT" ]
null
null
null
Black Horse C++/ex0027_encapsulation/main.cpp
Dragontalker/CPP-study-notes
d9ebd183d414d2de247ef37c03a24504dd3053d5
[ "MIT" ]
null
null
null
#include <iostream> class Circle { private: const double PI = 3.1415926; public: double m_r; double calculateZC() { return 2 * PI * m_r; } }; int main() { Circle c1; c1.m_r = 10; std::cout << "The raius of our circle = " << c1.calculateZC() << std::endl; return 0; }
12.692308
47
0.524242
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
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
27657d88fd215d96f5e3585a5224aaf294f12e25
15,198
cc
C++
agent/src/agent_win.cc
chromium/content_analysis_sdk
1a6e24f9ced8a4cf180ee7eafbc5fa0beb1046eb
[ "BSD-3-Clause" ]
null
null
null
agent/src/agent_win.cc
chromium/content_analysis_sdk
1a6e24f9ced8a4cf180ee7eafbc5fa0beb1046eb
[ "BSD-3-Clause" ]
1
2022-03-30T21:06:11.000Z
2022-03-30T21:06:11.000Z
agent/src/agent_win.cc
chromium/content_analysis_sdk
1a6e24f9ced8a4cf180ee7eafbc5fa0beb1046eb
[ "BSD-3-Clause" ]
1
2022-03-14T23:15:39.000Z
2022-03-14T23:15:39.000Z
// Copyright 2022 The Chromium Authors. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include <ios> #include <utility> #include <vector> #include <windows.h> #include <sddl.h> #include "common/utils_win.h" #include "agent_utils_win.h" #include "agent_win.h" #include "event_win.h" namespace content_analysis { namespace sdk { // The minimum number of pipe in listening mode. This is greater than one to // handle the case of multiple instance of Google Chrome browser starting // at the same time. const DWORD kMinNumListeningPipeInstances = 2; // The minimum number of handles to wait on. This is the minimum number // of pipes in listening mode plus the stop event. const DWORD kMinNumWaitHandles = kMinNumListeningPipeInstances + 1; // static std::unique_ptr<Agent> Agent::Create( Config config, std::unique_ptr<AgentEventHandler> handler, ResultCode* rc) { auto agent = std::make_unique<AgentWin>(std::move(config), std::move(handler), rc); return *rc == ResultCode::OK ? std::move(agent) : nullptr; } AgentWin::Connection::Connection(const std::string& pipename, AgentEventHandler* handler, bool is_first_pipe, ResultCode* rc) : handler_(handler) { *rc = ResultCode::OK; memset(&overlapped_, 0, sizeof(overlapped_)); // Create a manual reset event as specified for overlapped IO. // Use default security attriutes and no name since this event is not // shared with other processes. overlapped_.hEvent = CreateEvent(/*securityAttr=*/nullptr, /*manualReset=*/TRUE, /*initialState=*/FALSE, /*name=*/nullptr); if (!overlapped_.hEvent) { *rc = ResultCode::ERR_CANNOT_CREATE_CHANNEL_IO_EVENT; return; } *rc = ResetInternal(pipename, is_first_pipe); } AgentWin::Connection::~Connection() { Cleanup(); if (handle_ != INVALID_HANDLE_VALUE) { CloseHandle(handle_); } // Invalid event handles are represented as null. if (overlapped_.hEvent) { CloseHandle(overlapped_.hEvent); } } ResultCode AgentWin::Connection::Reset(const std::string& pipename) { return ResetInternal(pipename, false); } ResultCode AgentWin::Connection::HandleEvent(HANDLE handle) { auto rc = ResultCode::OK; DWORD count; BOOL success = GetOverlappedResult(handle, &overlapped_, &count, /*wait=*/FALSE); if (!is_connected_) { // This connection is currently listing for a new connection from a Google // Chrome browser. If the result is a success, this means the browser has // connected as expected. Otherwise an error occured so report it to the // caller. if (success) { // A Google Chrome browser connected to the agent. Reset this // connection object to handle communication with the browser and then // tell the handler about it. is_connected_ = true; buffer_.resize(internal::kBufferSize); rc = BuildBrowserInfo(); if (rc == ResultCode::OK) { handler_->OnBrowserConnected(browser_info_); } } else { rc = ErrorToResultCode(GetLastError()); } } else { // Some data has arrived from Google Chrome. This data is (part of) an // instance of the proto message `ChromeToAgent`. // // If the message is small it is received in by one call to ReadFile(). // If the message is larger it is received in by multiple calls to // ReadFile(). // // `success` is true if the data just read is the last bytes for a message. // Otherwise it is false. rc = OnReadFile(success, count); } // If all data has been read, queue another read. if (rc == ResultCode::OK || rc == ResultCode::ERR_MORE_DATA) { rc = QueueReadFile(rc == ResultCode::OK); } if (rc != ResultCode::OK && rc != ResultCode::ERR_IO_PENDING && rc != ResultCode::ERR_MORE_DATA) { Cleanup(); } else { // Don't propagate all the "success" error codes to the called to keep // this simpler. rc = ResultCode::OK; } return rc; } void AgentWin::Connection::AppendDebugString(std::stringstream& state) const { state << "{handle=" << handle_; state << " connected=" << is_connected_; state << " pid=" << browser_info_.pid; state << " rsize=" << read_size_; state << " fsize=" << final_size_; state << "}"; } ResultCode AgentWin::Connection::ConnectPipe() { // In overlapped mode, connecting to a named pipe always returns false. if (ConnectNamedPipe(handle_, &overlapped_)) { return ErrorToResultCode(GetLastError()); } DWORD err = GetLastError(); if (err == ERROR_IO_PENDING) { // Waiting for a Google Chrome Browser to connect. return ResultCode::OK; } else if (err == ERROR_PIPE_CONNECTED) { // A Google Chrome browser is already connected. Make sure event is in // signaled state in order to process the connection. if (SetEvent(overlapped_.hEvent)) { err = ERROR_SUCCESS; } else { err = GetLastError(); } } return ErrorToResultCode(err); } ResultCode AgentWin::Connection::ResetInternal(const std::string& pipename, bool is_first_pipe) { auto rc = ResultCode::OK; // If this is the not the first time, disconnect from any existing Google // Chrome browser. Otherwise creater a new pipe. if (handle_ != INVALID_HANDLE_VALUE) { if (!DisconnectNamedPipe(handle_)) { rc = ErrorToResultCode(GetLastError()); } } else { rc = ErrorToResultCode( internal::CreatePipe(pipename, is_first_pipe, &handle_)); } // Make sure event starts in reset state. if (rc == ResultCode::OK && !ResetEvent(overlapped_.hEvent)) { rc = ErrorToResultCode(GetLastError()); } if (rc == ResultCode::OK) { rc = ConnectPipe(); } if (rc != ResultCode::OK) { Cleanup(); handle_ = INVALID_HANDLE_VALUE; } return rc; } void AgentWin::Connection::Cleanup() { if (is_connected_ && handler_) { handler_->OnBrowserDisconnected(browser_info_); } is_connected_ = false; browser_info_ = BrowserInfo(); buffer_.clear(); cursor_ = nullptr; read_size_ = 0; final_size_ = 0; if (handle_ != INVALID_HANDLE_VALUE) { // Cancel all outstanding IO requests on this pipe by using a null for // overlapped. CancelIoEx(handle_, /*overlapped=*/nullptr); } // This function does not close `handle_` or the event in `overlapped` so // that the server can resuse the pipe with an new Google Chrome browser // instance. } ResultCode AgentWin::Connection::QueueReadFile(bool reset_cursor) { if (reset_cursor) { cursor_ = buffer_.data(); read_size_ = buffer_.size(); final_size_ = 0; } // When this function is called there are the following possiblities: // // 1/ Data is already available and the buffer is filled in. ReadFile() // return TRUE and the event is set. // 2/ Data is not avaiable yet. ReadFile() returns FALSE and the last error // is ERROR_IO_PENDING(997) and the event is reset. // 3/ Some error occurred, like for example Google Chrome stops. ReadFile() // returns FALSE and the last error is something other than // ERROR_IO_PENDING, for example ERROR_BROKEN_PIPE(109). The event // state is unchanged. auto rc = ResultCode::OK; DWORD count; if (!ReadFile(handle_, cursor_, read_size_, &count, &overlapped_)) { rc = ErrorToResultCode(GetLastError()); } return rc; } ResultCode AgentWin::Connection::OnReadFile(BOOL done_reading, DWORD count) { final_size_ += count; // If `done_reading` is TRUE, this means the full message has been read. // Call the appropriate handler method. if (done_reading) { return CallHandler(); } // If success os false, there are two possibilities: // // 1/ The last error is ERROR_MORE_DATA(234). This means there are more // bytes to read before the request message is complete. Resize the // buffer and adjust the cursor. The caller will queue up another read // and wait. // 2/ Some error occured. In this case return the error. DWORD err = GetLastError(); if (err == ERROR_MORE_DATA) { read_size_ = internal::kBufferSize; buffer_.resize(buffer_.size() + read_size_); cursor_ = buffer_.data() + buffer_.size() - read_size_; } return ErrorToResultCode(err); } ResultCode AgentWin::Connection::CallHandler() { ChromeToAgent message; if (!message.ParseFromArray(buffer_.data(), final_size_)) { // Malformed message. return ResultCode::ERR_INVALID_REQUEST_FROM_BROWSER; } auto rc = ResultCode::OK; if (message.has_request()) { // This is a request from Google Chrome to perform a content analysis // request. // // Move the request from `message` to the event to reduce the amount // of memory allocation/copying and also because the the handler takes // ownership of the event. auto event = std::make_unique<ContentAnalysisEventWin>( handle_, browser_info_, std::move(*message.mutable_request())); rc = event->Init(); if (rc == ResultCode::OK) { handler_->OnAnalysisRequested(std::move(event)); } else { // Malformed message. rc = ResultCode::ERR_INVALID_REQUEST_FROM_BROWSER; } } else if (message.has_ack()) { // This is an ack from Google Chrome that it has received a content // analysis response from the agent. handler_->OnResponseAcknowledged(message.ack()); } else { // Malformed message. rc = ResultCode::ERR_INVALID_REQUEST_FROM_BROWSER; } return rc; } ResultCode AgentWin::Connection::BuildBrowserInfo() { if (!GetNamedPipeClientProcessId(handle_, &browser_info_.pid)) { return ResultCode::ERR_CANNOT_GET_BROWSER_PID; } HANDLE hProc = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, browser_info_.pid); if (hProc == nullptr) { return ResultCode::ERR_CANNOT_OPEN_BROWSER_PROCESS; } auto rc = ResultCode::OK; char path[MAX_PATH]; DWORD size = sizeof(path); DWORD length = QueryFullProcessImageNameA(hProc, /*flags=*/0, path, &size); if (length == 0) { rc = ResultCode::ERR_CANNOT_GET_BROWSER_BINARY_PATH; } CloseHandle(hProc); browser_info_.binary_path = path; return rc; } AgentWin::AgentWin( Config config, std::unique_ptr<AgentEventHandler> event_handler, ResultCode* rc) : AgentBase(std::move(config), std::move(event_handler)) { *rc = ResultCode::OK; if (handler() == nullptr) { *rc = ResultCode::ERR_AGENT_EVENT_HANDLER_NOT_SPECIFIED; return; } stop_event_ = CreateEvent(/*securityAttr=*/nullptr, /*manualReset=*/TRUE, /*initialState=*/FALSE, /*name=*/nullptr); if (stop_event_ == nullptr) { *rc = ResultCode::ERR_CANNOT_CREATE_AGENT_STOP_EVENT; return; } std::string pipename = internal::GetPipeName(configuration().name, configuration().user_specific); if (pipename.empty()) { *rc = ResultCode::ERR_INVALID_CHANNEL_NAME; return; } pipename_ = pipename; connections_.reserve(kMinNumListeningPipeInstances); for (int i = 0; i < kMinNumListeningPipeInstances; ++i) { connections_.emplace_back( std::make_unique<Connection>(pipename_, handler(), i == 0, rc)); if (*rc != ResultCode::OK || !connections_.back()->IsValid()) { Shutdown(); break; } } } AgentWin::~AgentWin() { Shutdown(); } ResultCode AgentWin::HandleEvents() { std::vector<HANDLE> wait_handles; auto rc = ResultCode::OK; bool stopped = false; while (!stopped && rc == ResultCode::OK) { rc = HandleOneEvent(wait_handles, &stopped); } return rc; } ResultCode AgentWin::Stop() { SetEvent(stop_event_); return AgentBase::Stop(); } std::string AgentWin::DebugString() const { std::stringstream state; state.setf(std::ios::boolalpha); state << "AgentWin{pipe=\"" << pipename_; state << "\" stop=" << stop_event_; for (size_t i = 0; i < connections_.size(); ++i) { state << " conn@" << i; connections_[i]->AppendDebugString(state); } state << "}" << std::ends; return state.str(); } void AgentWin::GetHandles(std::vector<HANDLE>& wait_handles) const { // Reserve enough space in the handles vector to include the stop event plus // all connections. wait_handles.clear(); wait_handles.reserve(1 + connections_.size()); for (auto& state : connections_) { HANDLE wait_handle = state->GetWaitHandle(); if (!wait_handle) { wait_handles.clear(); break; } wait_handles.push_back(wait_handle); } // Push the stop event last so that connections_ index calculations in // HandleOneEvent() don't have to account for this handle. wait_handles.push_back(stop_event_); } ResultCode AgentWin::HandleOneEventForTesting() { std::vector<HANDLE> wait_handles; bool stopped; return HandleOneEvent(wait_handles, &stopped); } bool AgentWin::IsAClientConnectedForTesting() { for (const auto& state : connections_) { if (state->IsConnected()) { return true; } } return false; } ResultCode AgentWin::HandleOneEvent(std::vector<HANDLE>& wait_handles, bool* stopped) { *stopped = false; // Wait on the specified handles for an event to occur. GetHandles(wait_handles); if (wait_handles.size() < kMinNumWaitHandles) { return ResultCode::ERR_AGENT_NOT_INITIALIZED; } DWORD index = WaitForMultipleObjects( wait_handles.size(), wait_handles.data(), /*waitAll=*/FALSE, /*timeoutMs=*/INFINITE); if (index == WAIT_FAILED) { return ErrorToResultCode(GetLastError()); } // If the index of signaled handle is the last one in wait_handles, then the // stop event was signaled. index -= WAIT_OBJECT_0; if (index == wait_handles.size() - 1) { *stopped = true; return ResultCode::OK; } auto& connection = connections_[index]; bool was_listening = !connection->IsConnected(); auto rc = connection->HandleEvent(wait_handles[index]); if (rc != ResultCode::OK) { // If `connection` was not listening and there are more than // kNumPipeInstances pipes, delete this connection. Otherwise // reset it so that it becomes a listener. if (!was_listening && connections_.size() > kMinNumListeningPipeInstances) { connections_.erase(connections_.begin() + index); } else { rc = connection->Reset(pipename_); } } // If `connection` was listening and is now connected, create a new // one so that there are always kNumPipeInstances listening. if (rc == ResultCode::OK && was_listening && connection->IsConnected()) { connections_.emplace_back( std::make_unique<Connection>(pipename_, handler(), false, &rc)); } return ResultCode::OK; } void AgentWin::Shutdown() { connections_.clear(); pipename_.clear(); if (stop_event_ != nullptr) { CloseHandle(stop_event_); stop_event_ = nullptr; } } } // namespace sdk } // namespace content_analysis
30.035573
87
0.665745
2776b138321d36f835b798181a8f27dbae2206f0
1,119
cpp
C++
tools/disktool/src/AssistantPage.cpp
DarkMaguz/CodingPiratesOS
7750224b87646ad376664bd1f826aae5112ea41c
[ "MIT" ]
1
2020-03-09T14:14:02.000Z
2020-03-09T14:14:02.000Z
tools/disktool/src/AssistantPage.cpp
DarkMaguz/CodingPiratesOS
7750224b87646ad376664bd1f826aae5112ea41c
[ "MIT" ]
null
null
null
tools/disktool/src/AssistantPage.cpp
DarkMaguz/CodingPiratesOS
7750224b87646ad376664bd1f826aae5112ea41c
[ "MIT" ]
2
2020-03-11T21:29:20.000Z
2020-07-06T20:20:18.000Z
/* * AssistantPage.cpp * * Created on: Mar 20, 2022 * Author: magnus */ #include "AssistantPage.h" #include <iostream> AssistantPage::AssistantPage(const Glib::ustring &resourcePath) : m_assistantPage(nullptr), m_refBuilder(Gtk::Builder::create()) { try { m_refBuilder->add_from_resource(resourcePath); } catch(const Gio::ResourceError& ex) { std::cerr << "ResourceError: " << ex.what() << std::endl; } catch(const Glib::FileError& ex) { std::cerr << "FileError: " << ex.what() << std::endl; } catch(const Glib::MarkupError& ex) { std::cerr << "MarkupError: " << ex.what() << std::endl; } catch(const Gtk::BuilderError& ex) { std::cerr << "BuilderError: " << ex.what() << std::endl; } } AssistantPage::~AssistantPage() { for (auto garbage : m_gc) if (garbage) delete garbage; } Gtk::Box *AssistantPage::GetPage(void) { return m_assistantPage; } AssistantPage::type_signalPageComplete AssistantPage::SignalPageComplete(void) { return m_signalPageComplete; } void AssistantPage::EvaluatePageCompleteness(void) { m_signalPageComplete.emit(true); }
18.966102
78
0.669348
2776b3077b548c5674269fbc460f15f64720a1c2
16,734
cpp
C++
src/parse_symbol_set.cpp
DavideConficconi/hscompile
819e35c50ffb2a767cbf4634bc05cd2c9e4d21a7
[ "BSD-3-Clause" ]
4
2017-06-22T19:30:05.000Z
2021-11-17T07:45:24.000Z
src/parse_symbol_set.cpp
DavideConficconi/hscompile
819e35c50ffb2a767cbf4634bc05cd2c9e4d21a7
[ "BSD-3-Clause" ]
2
2018-03-19T15:29:22.000Z
2021-03-14T13:16:59.000Z
src/parse_symbol_set.cpp
DavideConficconi/hscompile
819e35c50ffb2a767cbf4634bc05cd2c9e4d21a7
[ "BSD-3-Clause" ]
4
2018-03-13T17:23:12.000Z
2021-04-18T16:17:18.000Z
/* * Copyright (c) 2016, University of Virginia * 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 University of Virginia 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 UNIVERSITY OF VIRGINIA 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. * * This software was originally developed by Jack Wadden (jackwadden@gmail.com). * A list of all contributors is maintained at https://github.com/jackwadden/VASim. * * If you use VASim in your project, please use the following citation: * Wadden, J. and Skadron, K. "VASim: An Open Source Simulation and Analysis * Platform for Finite Automata Applications and Architecture Research." GitHub * repository, https://github.com/jackwadden/VASim. University of Virginia, 2016. */ /* * Modified by Kevin Angstadt <angstadt@virginia.edu> for use with HyperScan */ #include "parse_symbol_set.h" #include <string> #include <iostream> namespace ue2 { void parseSymbolSet(CharReach &column, std::string symbol_set) { if(symbol_set.compare("*") == 0){ column.setall(); return; } // KAA found that apcompile parses symbol-set="." to mean "^\x0a" // hard-coding this here if(symbol_set.compare(".") == 0) { column.set('\n'); column.flip(); return; } bool in_charset = false; bool escaped = false; bool inverting = false; bool range_set = false; int bracket_sem = 0; int brace_sem = 0; const unsigned int value = 1; unsigned char last_char = 0; unsigned char range_start = 0; // handle symbol sets that start and end with curly braces {###} if((symbol_set[0] == '{') && (symbol_set[symbol_set.size() - 1] == '}')){ std::cout << "CURLY BRACES NOT IMPLEMENTED" << std::endl; exit(1); } int index = 0; while(index < symbol_set.size()) { unsigned char c = symbol_set[index]; //std::cout << "PROCESSING CHAR: " << c << std::endl; switch(c){ // Brackets case '[' : if(escaped){ column.set(c); if(range_set){ column.setRange(range_start,c); range_set = false; } last_char = c; escaped = false; }else{ bracket_sem++; } break; case ']' : if(escaped){ column.set(c); if(range_set){ column.setRange(range_start,c); range_set = false; } escaped = false; last_char = c; }else{ bracket_sem--; } break; // Braces case '{' : //if(escaped){ column.set(c); if(range_set){ column.setRange(range_start,c); range_set = false; } last_char = c; //escaped = false; //}else{ //brace_sem++; //} break; case '}' : //if(escaped){ column.set(c); if(range_set){ column.setRange(range_start,c); range_set = false; } last_char = c; //escaped = false; //}else{ //brace_sem--; //} break; //escape case '\\' : if(escaped){ column.set(c); if(range_set){ column.setRange(range_start,c); range_set = false; } last_char = c; escaped = false; }else{ escaped = true; } break; // escaped chars case 'n' : if(escaped){ column.set('\n'); if(range_set){ column.setRange(range_start,'\n'); range_set = false; } last_char = '\n'; escaped = false; }else{ column.set(c); if(range_set){ column.setRange(range_start,c); range_set = false; } last_char = c; } break; case 'r' : if(escaped){ column.set('\r'); if(range_set){ column.setRange(range_start,'\r'); range_set = false; } last_char = '\r'; escaped = false; }else{ column.set(c); if(range_set){ column.setRange(range_start,c); range_set = false; } last_char = c; } break; case 't' : if(escaped){ column.set('\t'); if(range_set){ column.setRange(range_start,'\t'); range_set = false; } last_char = '\t'; escaped = false; }else{ column.set(c); if(range_set){ column.setRange(range_start,c); range_set = false; } last_char = c; } break; case 'a' : if(escaped){ column.set('\a'); if(range_set){ column.setRange(range_start,'\a'); range_set = false; } last_char = '\a'; escaped = false; }else{ column.set(c); if(range_set){ column.setRange(range_start,c); range_set = false; } last_char = c; } break; case 'b' : if(escaped){ column.set('\b'); if(range_set){ column.setRange(range_start,'\b'); range_set = false; } last_char = '\b'; escaped = false; }else{ column.set(c); if(range_set){ //std::cout << "RANGE SET" << std::endl; column.setRange(range_start,c); range_set = false; } last_char = c; } break; case 'f' : if(escaped){ column.set('\f'); if(range_set){ column.setRange(range_start,'\f'); range_set = false; } last_char = '\f'; escaped = false; }else{ column.set(c); if(range_set){ column.setRange(range_start,c); range_set = false; } last_char = c; } break; case 'v' : if(escaped){ column.set('\v'); if(range_set){ column.setRange(range_start,'\v'); range_set = false; } last_char = '\v'; escaped = false; }else{ column.set(c); if(range_set){ column.setRange(range_start,c); range_set = false; } last_char = c; } break; case '\'' : if(escaped){ column.set('\''); if(range_set){ column.setRange(range_start,'\''); range_set = false; } last_char = '\''; escaped = false; }else{ column.set(c); if(range_set){ column.setRange(range_start,c); range_set = false; } last_char = c; } break; case '\"' : if(escaped){ column.set('\"'); if(range_set){ column.setRange(range_start,'\"'); range_set = false; } last_char = '\"'; escaped = false; }else{ column.set(c); if(range_set){ column.setRange(range_start,c); range_set = false; } last_char = c; } break; /* case '?' : if(escaped){ column.set('?',value); last_char = '?'; escaped = false; }else{ column.set(c, value); last_char = c; } break; */ // Range case '-' : if(escaped){ column.set('-'); if(range_set){ column.setRange(range_start,'-'); range_set = false; } last_char = '-'; escaped = false; }else{ range_set = true; range_start = last_char; } break; // Special Classes case 's' : if(escaped){ column.set('\n'); column.set('\t'); column.set('\r'); column.set('\x0B'); //vertical tab column.set('\x0C'); column.set('\x20'); escaped = false; }else{ column.set(c); if(range_set){ column.setRange(range_start,c); range_set = false; } last_char = c; } break; case 'd' : if(escaped){ column.setRange(48,57); //setRange(column,48,57, value); escaped = false; }else{ column.set(c); if(range_set){ column.setRange(range_start,c); range_set = false; } last_char = c; } break; case 'w' : if(escaped){ column.set('_'); // '_' column.setRange(48,57); //setRange(column,48,57, value); // d column.setRange(65,90); //setRange(column,65,90, value); // A-Z column.setRange(97,122); // setRange(column,97,122, value); // a-z escaped = false; }else{ column.set(c); if(range_set){ column.setRange(range_start,c); range_set = false; } last_char = c; } break; // Inversion case '^' : if(escaped){ column.set(c); if(range_set){ column.setRange(range_start,c); range_set = false; } last_char = c; escaped = false; }else{ inverting = true; } break; // HEX case 'x' : if(escaped){ //process hex char ++index; char hex[3]; hex[0] = (char)symbol_set.c_str()[index]; hex[1] = (char)symbol_set.c_str()[index+1]; hex[2] = '\0'; unsigned char number = (unsigned char)std::strtoul(hex, NULL, 16); // ++index; column.set(number); if(range_set){ column.setRange(range_start,number); range_set = false; } last_char = number; escaped = false; }else{ column.set(c); if(range_set){ column.setRange(range_start,c); range_set = false; } last_char = c; } break; // Other characters default: if(escaped){ // we escaped a char that is not valid so treat it normaly escaped = false; } column.set(c); if(range_set){ column.setRange(range_start,c); range_set = false; } last_char = c; }; index++; } // char while loop if(inverting) column.flip(); if(bracket_sem != 0 || brace_sem != 0){ std::cout << "MALFORMED BRACKETS OR BRACES: " << symbol_set << std::endl; std::cout << "brackets: " << bracket_sem << std::endl; exit(1); } /* std::cout << "***" << std::endl; for(int i = 0; i < 256; i++){ if(column.test(i)) std::cout << i << " : 1" << std::endl; else std::cout << i << " : 0" << std::endl; } std::cout << "***" << std::endl; */ } };
33.806061
86
0.369906
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
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
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
277b93df3e0d432f978009c9bf64272146c36b1d
1,014
cpp
C++
Stacks/Longest-Valid-Parentheses-32.cpp
devangi2000/Data-Structures-Algorithms-Handbook
ce0f00de89af5da7f986e65089402dc6908a09b5
[ "MIT" ]
38
2021-10-14T09:36:53.000Z
2022-01-27T02:36:19.000Z
Stacks/Longest-Valid-Parentheses-32.cpp
devangi2000/Data-Structures-Algorithms-Handbook
ce0f00de89af5da7f986e65089402dc6908a09b5
[ "MIT" ]
null
null
null
Stacks/Longest-Valid-Parentheses-32.cpp
devangi2000/Data-Structures-Algorithms-Handbook
ce0f00de89af5da7f986e65089402dc6908a09b5
[ "MIT" ]
4
2021-12-06T15:47:12.000Z
2022-02-04T04:25:00.000Z
// Given a string containing just the characters '(' and ')', find the // length of the longest valid (well-formed) parentheses substring. // Example 1: // Input: s = "(()" // Output: 2 // Explanation: The longest valid parentheses substring is "()". // Example 2: // Input: s = ")()())" // Output: 4 // Explanation: The longest valid parentheses substring is "()()". // Example 3: // Input: s = "" // Output: 0 // Constraints: // 0 <= s.length <= 3 * 104 // s[i] is '(', or ')'. class Solution { public: stack<int> st; int ans = 0; int longestValidParentheses(string s){ int n = s.size(); st.push(-1); for(int i=0; i<n; ++i){ if(s[i] == '('){ st.push(i); } else{ st.pop(); if(st.empty()){ st.push(i); } ans = max(ans, i - st.top()); } } return ans; } };
22.533333
72
0.439842
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
277d16cc64a386e3bc92eb09a29e6fac42aec4ec
5,323
cpp
C++
compat/BSSynchronizedClipGenerator_1.cpp
BlazesRus/hkxcmd
e00a554225234e40e111e808b095156ac1d4b1fe
[ "Intel" ]
38
2015-03-24T00:41:59.000Z
2022-03-23T09:18:29.000Z
compat/BSSynchronizedClipGenerator_1.cpp
BlazesRus/hkxcmd
e00a554225234e40e111e808b095156ac1d4b1fe
[ "Intel" ]
2
2015-10-14T07:41:48.000Z
2015-12-14T02:19:05.000Z
compat/BSSynchronizedClipGenerator_1.cpp
BlazesRus/hkxcmd
e00a554225234e40e111e808b095156ac1d4b1fe
[ "Intel" ]
24
2015-08-03T20:41:07.000Z
2022-03-27T03:58:37.000Z
#include "StdAfx.h" #include "BSSynchronizedClipGenerator_1.h" #include <Common/Serialize/hkSerialize.h> #include <Common/Serialize/Util/hkSerializeUtil.h> #include <Common/Serialize/Version/hkVersionPatchManager.h> #include <Common/Serialize/Data/Dict/hkDataObjectDict.h> #include <Common/Serialize/Data/Native/hkDataObjectNative.h> #include <Common/Serialize/Data/Util/hkDataObjectUtil.h> #include <Common/Base/Reflection/Registry/hkDynamicClassNameRegistry.h> #include <Common/Base/Reflection/Registry/hkVtableClassRegistry.h> #include <Common/Base/Reflection/hkClass.h> #include <Common/Base/Reflection/hkInternalClassMember.h> #include <Common/Serialize/Util/hkSerializationCheckingUtils.h> #include <Common/Serialize/Util/hkVersionCheckingUtils.h> static const hkInternalClassMember BSSynchronizedClipGeneratorClass_Members[] = { { "pClipGenerator",&hkbGeneratorClass,HK_NULL,hkClassMember::TYPE_POINTER,hkClassMember::TYPE_STRUCT,0,hkClassMember::ALIGN_16,HK_OFFSET_OF(BSSynchronizedClipGenerator,m_pClipGenerator) /*48*/,HK_NULL}, { "SyncAnimPrefix",HK_NULL,HK_NULL,hkClassMember::TYPE_CSTRING,hkClassMember::TYPE_VOID,0,hkClassMember::FLAGS_NONE,HK_OFFSET_OF(BSSynchronizedClipGenerator,m_SyncAnimPrefix) /*52*/,HK_NULL}, { "bSyncClipIgnoreMarkPlacement",HK_NULL,HK_NULL,hkClassMember::TYPE_BOOL,hkClassMember::TYPE_VOID,0,hkClassMember::FLAGS_NONE,HK_OFFSET_OF(BSSynchronizedClipGenerator,m_bSyncClipIgnoreMarkPlacement) /*56*/,HK_NULL}, { "fGetToMarkTime",HK_NULL,HK_NULL,hkClassMember::TYPE_REAL,hkClassMember::TYPE_VOID,0,hkClassMember::FLAGS_NONE,HK_OFFSET_OF(BSSynchronizedClipGenerator,m_fGetToMarkTime) /*60*/,HK_NULL}, { "fMarkErrorThreshold",HK_NULL,HK_NULL,hkClassMember::TYPE_REAL,hkClassMember::TYPE_VOID,0,hkClassMember::FLAGS_NONE,HK_OFFSET_OF(BSSynchronizedClipGenerator,m_fMarkErrorThreshold) /*64*/,HK_NULL}, { "bLeadCharacter",HK_NULL,HK_NULL,hkClassMember::TYPE_BOOL,hkClassMember::TYPE_VOID,0,hkClassMember::FLAGS_NONE,HK_OFFSET_OF(BSSynchronizedClipGenerator,m_bLeadCharacter) /*68*/,HK_NULL}, { "bReorientSupportChar",HK_NULL,HK_NULL,hkClassMember::TYPE_BOOL,hkClassMember::TYPE_VOID,0,hkClassMember::FLAGS_NONE,HK_OFFSET_OF(BSSynchronizedClipGenerator,m_bReorientSupportChar) /*69*/,HK_NULL}, { "bApplyMotionFromRoot",HK_NULL,HK_NULL,hkClassMember::TYPE_BOOL,hkClassMember::TYPE_VOID,0,hkClassMember::FLAGS_NONE,HK_OFFSET_OF(BSSynchronizedClipGenerator,m_bApplyMotionFromRoot) /*70*/,HK_NULL}, { "pSyncScene",HK_NULL,HK_NULL,hkClassMember::TYPE_POINTER,hkClassMember::TYPE_VOID,0,hkClassMember::SERIALIZE_IGNORED,HK_OFFSET_OF(BSSynchronizedClipGenerator,m_pSyncScene) /*72*/,HK_NULL}, { "StartMarkWS",HK_NULL,HK_NULL,hkClassMember::TYPE_QSTRANSFORM,hkClassMember::TYPE_VOID,0,hkClassMember::SERIALIZE_IGNORED,HK_OFFSET_OF(BSSynchronizedClipGenerator,m_StartMarkWS) /*80*/,HK_NULL}, { "EndMarkWS",HK_NULL,HK_NULL,hkClassMember::TYPE_QSTRANSFORM,hkClassMember::TYPE_VOID,0,hkClassMember::SERIALIZE_IGNORED,HK_OFFSET_OF(BSSynchronizedClipGenerator,m_EndMarkWS) /*128*/,HK_NULL}, { "StartMarkMS",HK_NULL,HK_NULL,hkClassMember::TYPE_QSTRANSFORM,hkClassMember::TYPE_VOID,0,hkClassMember::SERIALIZE_IGNORED,HK_OFFSET_OF(BSSynchronizedClipGenerator,m_StartMarkMS) /*176*/,HK_NULL}, { "fCurrentLerp",HK_NULL,HK_NULL,hkClassMember::TYPE_REAL,hkClassMember::TYPE_VOID,0,hkClassMember::SERIALIZE_IGNORED,HK_OFFSET_OF(BSSynchronizedClipGenerator,m_fCurrentLerp) /*224*/,HK_NULL}, { "pLocalSyncBinding",HK_NULL,HK_NULL,hkClassMember::TYPE_POINTER,hkClassMember::TYPE_VOID,0,hkClassMember::SERIALIZE_IGNORED,HK_OFFSET_OF(BSSynchronizedClipGenerator,m_pLocalSyncBinding) /*228*/,HK_NULL}, { "pEventMap",HK_NULL,HK_NULL,hkClassMember::TYPE_POINTER,hkClassMember::TYPE_VOID,0,hkClassMember::SERIALIZE_IGNORED,HK_OFFSET_OF(BSSynchronizedClipGenerator,m_pEventMap) /*232*/,HK_NULL}, { "sAnimationBindingIndex",HK_NULL,HK_NULL,hkClassMember::TYPE_INT16,hkClassMember::TYPE_VOID,0,hkClassMember::FLAGS_NONE,HK_OFFSET_OF(BSSynchronizedClipGenerator,m_sAnimationBindingIndex) /*236*/,HK_NULL}, { "bAtMark",HK_NULL,HK_NULL,hkClassMember::TYPE_BOOL,hkClassMember::TYPE_VOID,0,hkClassMember::SERIALIZE_IGNORED,HK_OFFSET_OF(BSSynchronizedClipGenerator,m_bAtMark) /*238*/,HK_NULL}, { "bAllCharactersInScene",HK_NULL,HK_NULL,hkClassMember::TYPE_BOOL,hkClassMember::TYPE_VOID,0,hkClassMember::SERIALIZE_IGNORED,HK_OFFSET_OF(BSSynchronizedClipGenerator,m_bAllCharactersInScene) /*239*/,HK_NULL}, { "bAllCharactersAtMarks",HK_NULL,HK_NULL,hkClassMember::TYPE_BOOL,hkClassMember::TYPE_VOID,0,hkClassMember::SERIALIZE_IGNORED,HK_OFFSET_OF(BSSynchronizedClipGenerator,m_bAllCharactersAtMarks) /*240*/,HK_NULL}, }; // Signature: d83bea64 extern const hkClass hkbGeneratorClass; extern const hkClass BSSynchronizedClipGeneratorClass; const hkClass BSSynchronizedClipGeneratorClass( "BSSynchronizedClipGenerator", &hkbGeneratorClass, // parent sizeof(BSSynchronizedClipGenerator), HK_NULL, 0, // interfaces HK_NULL, 0, // enums reinterpret_cast<const hkClassMember*>(BSSynchronizedClipGeneratorClass_Members), HK_COUNT_OF(BSSynchronizedClipGeneratorClass_Members), HK_NULL, // defaults HK_NULL, // attributes 0, // flags 1 // version ); HK_REFLECTION_DEFINE_VIRTUAL(BSSynchronizedClipGenerator, BSSynchronizedClipGenerator);
91.775862
219
0.833177
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
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
2781bcf952dd6a69ef27efa1398d0fd37c4447a9
8,979
cpp
C++
src/cpu.cpp
jonathandeiven/CHIP8-Emulator
5c1d0b8760e9eeb783cbb0c2bded8ee6ac6444dc
[ "MIT" ]
4
2016-01-06T15:46:07.000Z
2017-04-29T03:00:09.000Z
src/cpu.cpp
jonathandeiven/CHIP8-Emulator
5c1d0b8760e9eeb783cbb0c2bded8ee6ac6444dc
[ "MIT" ]
null
null
null
src/cpu.cpp
jonathandeiven/CHIP8-Emulator
5c1d0b8760e9eeb783cbb0c2bded8ee6ac6444dc
[ "MIT" ]
2
2016-09-15T00:02:45.000Z
2019-08-21T00:54:19.000Z
#include "cpu.h" #include "fontset.h" #include <stdio.h> #include <stdlib.h> #include <random> // Default constructor Chip8::Chip8() {} // Default destructor Chip8::~Chip8() {} // Init registers and memory void Chip8::initialize() { // Reset registers opcode = 0; I = 0; sp = 0; // Program counter reset pc = 0x200; // Reset timers delay_timer = 0; sound_timer = 0; // Clear display for (int i = 0; i < GFX_SIZE; i++) { gfx[i] = 0; } // Clear stack for (int i = 0; i < STACK_SIZE; i++) { stack[i] = 0; } // Clear registers for (int i = 0; i < REGISTER_SIZE; i++) { V[i] = 0; } // Clear keys for (int i = 0; i < KEY_SIZE; i++) { key[i] = 0; } // Clear memory for (int i = 0; i < MEMORY_SIZE; i++) { memory[i] = 0; } // Load fontset into memory for (int i = 0; i < 80; i++) { memory[i] = fontset[i]; } // Seed the RNG srand (time(NULL)); } // Load the ROM void Chip8::load(const char* rom) { FILE *program_file; size_t read_size; // Open ROM into file program_file = fopen(rom, "rb"); if (program_file == NULL) { printf("ERROR: Cannot open ROM"); exit (EXIT_FAILURE); } // Get ROM size fseek(program_file, 0, SEEK_END); file_size = ftell(program_file); // Rewind to ROM file start rewind(program_file); // Copy ROM to memory read_size = fread(&memory[I+0x200], sizeof(char), file_size, program_file); if ((read_size != file_size) || (file_size > (0x1000 - 0x200))) { printf("ERROR: Cannot load ROM to memory"); exit (EXIT_FAILURE); } fclose(program_file); } // Fetch, decode, execute opcode void Chip8::cycle() { // Flag for key press bool key_pressed = false; // Fetch two bytes and merge them to get opcode opcode = memory[pc] << 8 | memory[pc + 1]; // 4-bit Register identifiers unsigned short X = (opcode&0x0F00) >> 8; unsigned short Y = (opcode&0x00F0) >> 4; pc += 2; // Decode opcode switch(opcode & 0xF000) { case 0x0000: switch(opcode & 0x000F) { case 0x0000: // 0x00E0: Clear screen (CLS) for (int i = 0; i < GFX_SIZE; i++) { gfx[i] = 0; } drawFlag = true; break; case 0x000E: // 0x00EE: Return from subroutine (RTS) pc = stack[--sp]; break; default: printf("Opcode unknown: 0x%X\n", opcode); break; } break; case 0x1000: // 0x1NNN: Jump to address NNN pc = opcode & 0x0FFF; break; case 0x2000: // 0x2NNN: Calls subroutine at NNN stack[sp++] = pc; pc = opcode & 0x0FFF; break; case 0x3000: // 0x3XNN: Skips next instruction if VX = NN if (V[X] == (opcode & 0x00FF)) pc += 2; break; case 0x4000: // 0x4XNN: Skips next instruction if VX != NN if (V[X] != (opcode & 0x00FF)) pc += 2; break; case 0x5000: // 0x5XY0: Skips next instruction if VX = VY if (V[X] == V[Y]) pc += 2; break; case 0x6000: // 0x6XNN: Sets VX = NN V[X] = (opcode & 0x00FF); break; case 0x7000: // 0x7XNN: Adds NN to VX V[X] += (opcode & 0x00FF); break; //Register operations case 0x8000: switch(opcode & 0x000F) { case 0x0: // 0x8XY0: Sets VX to value of VY (MOV) V[X] = V[Y]; break; case 0x1: // 0x8XY2: Sets VX to VX or VY (OR) V[X] = (V[X] | V[Y]); break; case 0x2: // 0x8XY2: Sets VX to VX and VY (AND) V[X] = (V[X] & V[Y]); break; case 0x3: // 0x8XY3: Sets VX to VX xor VY (XOR) V[X] = (V[X] ^ V[Y]); break; case 0x4: // 0x8XY4: Adds VY to VX; VF is 1 when // there's a carry and 0 if not (ADD) if ((V[Y] + V[X]) > 0xFF) V[0xF] = 1; // carry else V[0xF] = 0; V[X] += V[Y]; break; case 0x5: // 0x8XY5: VY subtracted from VX. VF is // 0 if there's a borrow and 1 if not (SUB) if (V[X] > V[Y]) V[0xF] = 1; else V[0xF] = 0; V[X] -= V[Y]; break; case 0x6: // 0x8XY6: Shifts VX right by 1. VF is // least significant bit of VX before shift (SHR) V[0xF] = V[X] & 0x1; V[X] = V[X] >> 1; break; case 0x7: // 0x8XY7: Sets VX to VY minus VX. VF is 0 // if there's a borrow and 1 if not (SUBB) if (V[Y] > V[X]) V[0xF] = 1; else V[0xF] = 0; V[X] = V[Y] - V[X]; break; case 0xE: // 0x8XY8: Shifts VX left by 1. VF is set to // most significant bit of VX before shift (SHL) V[0xF] = V[X] >> 7; V[X] = V[X] << 1; break; default: printf("Opcode unknown: 0x%X\n", opcode); break; } break; case 0x9000: // 0x9XY0: Skips next instruction if VX != VY if (V[X] != V[Y]) pc += 2; break; case 0xA000: // 0xANNN: Set I to address NNN I = opcode & 0x0FFF; break; case 0xB000: // 0xBNNN: Jumps to address of NNN + V0 pc = (opcode & 0x0FFF) + V[0]; break; case 0xC000: // 0xCXNN: Sets VX to result of bitwise operation // on random number and NN V[X] = (rand() % 0xFF) & (opcode & 0xFF); break; case 0xD000: // 0xDXYN: Graphics sprite draw_sprite(X, Y, opcode & 0x000F); drawFlag = true; break; case 0xE000: switch(opcode & 0x00FF) { case 0x9E: // 0xEX9E: Skips next instruction if key // stored in VX is pressed. if(key[V[X]] != 0) pc += 2; break; case 0xA1: // 0xEXA1: Skips next instruction if key // stored in VX isn't pressed. if(key[V[X]] == 0) pc += 2; break; default: printf("Opcode unknown: 0x%X\n", opcode); break; } break; case 0xF000: switch(opcode & 0x00FF) { case 0x07: // 0xFX07: Sets VX to delay timer value V[X] = delay_timer; break; case 0x0A: // 0xFX0A: Key press awaited, and stored in VX for (int i = 0; i < KEY_SIZE; i++) { if (key[i] != 0) { V[X] = i; key_pressed = true; } } // No key pressed if (key_pressed == 0) { pc -= 2; return; } break; case 0x15: // 0xFX15: Sets delay timer to VX delay_timer = V[X]; break; case 0x18: // 0xFX18: Sets sound timer to VX sound_timer = V[X]; break; case 0x1E: // 0xFX1E: Adds VX to I I += V[X]; break; case 0x29: // 0xFX29: Sets I to location of sprite I = V[X] * 5; // Font is 4x5 bits break; case 0x33: // 0xFX33: Stores binary-coded decimal of VX memory[I] = V[X] / 100; memory[I + 1] = (V[X] / 10) % 10; memory[I + 2] = (V[X] % 100) % 10; break; case 0x55: // 0xFX55: Stores V0 to VX in memory address // starting at address I for (int i = 0; i < X; i++) memory[I + i] = V[i]; I = I + X + 0x1; break; case 0x65: // 0xFX65: Fills V0 to VX with values from // memory starting at address I for (int i = 0; i < X; i++) V[i] = memory[I + i]; I = I + X + 0x1; break; default: printf("Opcode unknown: 0x%X\n", opcode); break; } break; default: printf("Opcode unknown: 0x%X\n", opcode); break; } // Update delay timer if (delay_timer > 0) --delay_timer; // Update sound timer if (sound_timer > 0) { if(sound_timer == 1) { //printf("BEEP!\n"); // Implement sound here } --sound_timer; } } // Draws sprite at (V[X], V[Y]) of specified height void Chip8::draw_sprite(unsigned short X, unsigned short Y, unsigned short height) { unsigned short x = V[X]; // x-position of sprite unsigned short y = V[Y]; // y-position of sprite unsigned short pixel; V[0xF] = 0; // Reset V[F] register for (int y_line = 0; y_line < height; y_line++) { pixel = memory[I + y_line]; // Get pixel to draw // Each pixel is 8 bits long, so loop through for(int x_col = 0; x_col < 0x08; x_col++) { if((pixel & (0x80 >> x_col)) != 0) { if(gfx[x + x_col + ((y + y_line) * 64)] == 1) V[0xF] = 1; // Collision gfx[x + x_col + ((y + y_line) * 64)] ^= 1; } } } } // Dumps contents of memory void Chip8::ram_dump() { printf("********************************\n"); printf(" RAM DUMP\n\n"); if (file_size == 0) printf("ROM not loaded...\n"); else { for (int i = 0; i <= 0x200 + file_size; i++) { printf("%02X ", memory[i]); if ((i + 1) % 11 == 0) printf("\n"); } } printf("\n\n********************************\n"); } // Dumps contents of CPU register and stack void Chip8::cpu_dump() { printf("********************************\n"); printf(" CPU DUMP\n\n"); if (file_size == 0) printf("ROM not loaded...\n"); else { printf("Program Counter: 0x%hx\n", pc); printf("Index Register: 0x%hx\n", I); printf("Stack Pointer: 0x%hx\n", sp); printf("\nRegister Dump:\n"); for (int i = 0; i < REGISTER_SIZE; i++) { printf("%02X ", V[i]); if ((i + 1) % 11 == 0) printf("\n"); } printf("\nStack Dump:\n"); for (int i = 0; i < sp; i++) { printf("%hx ", stack[i]); if ((i + 1) % 11 == 0) printf("\n"); } } printf("\n\n********************************\n"); }
20.784722
76
0.534803
2781f20cc59b853f6ec7a82b620e3a0f1f376ff2
28,342
cc
C++
service/auto/Spi.cc
lilinj2000/cata
a4f63913fc8e2b8015fa94c3baf51b3934d57637
[ "Apache-2.0" ]
null
null
null
service/auto/Spi.cc
lilinj2000/cata
a4f63913fc8e2b8015fa94c3baf51b3934d57637
[ "Apache-2.0" ]
null
null
null
service/auto/Spi.cc
lilinj2000/cata
a4f63913fc8e2b8015fa94c3baf51b3934d57637
[ "Apache-2.0" ]
1
2021-08-21T09:19:08.000Z
2021-08-21T09:19:08.000Z
void MDSpiImpl::OnFrontConnected() { SOIL_FUNC_TRACE; } void MDSpiImpl::OnFrontDisconnected( int nReason) { SOIL_FUNC_TRACE; SOIL_DEBUG_PRINT(nReason); } void MDSpiImpl::OnHeartBeatWarning( int nTimeLapse) { SOIL_FUNC_TRACE; SOIL_DEBUG_PRINT(nTimeLapse); } void MDSpiImpl::OnRspAuthenticate( CThostFtdcRspAuthenticateField *pRspAuthenticateField, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspAuthenticate, pRspAuthenticateField, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspUserLogin( CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; SOIL_DEBUG_IF_PRINT(pRspUserLogin); SOIL_DEBUG_IF_PRINT(pRspInfo); SOIL_DEBUG_PRINT(nRequestID); SOIL_DEBUG_PRINT(bIsLast); } void MDSpiImpl::OnRspUserLogout( CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; SOIL_DEBUG_IF_PRINT(pUserLogout); SOIL_DEBUG_IF_PRINT(pRspInfo); SOIL_DEBUG_PRINT(nRequestID); SOIL_DEBUG_PRINT(bIsLast); } void MDSpiImpl::OnRspUserPasswordUpdate( CThostFtdcUserPasswordUpdateField *pUserPasswordUpdate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspUserPasswordUpdate, pUserPasswordUpdate, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspTradingAccountPasswordUpdate( CThostFtdcTradingAccountPasswordUpdateField *pTradingAccountPasswordUpdate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspTradingAccountPasswordUpdate, pTradingAccountPasswordUpdate, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspUserAuthMethod( CThostFtdcRspUserAuthMethodField *pRspUserAuthMethod, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspUserAuthMethod, pRspUserAuthMethod, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspGenUserCaptcha( CThostFtdcRspGenUserCaptchaField *pRspGenUserCaptcha, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspGenUserCaptcha, pRspGenUserCaptcha, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspGenUserText( CThostFtdcRspGenUserTextField *pRspGenUserText, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspGenUserText, pRspGenUserText, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspOrderInsert( CThostFtdcInputOrderField *pInputOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspOrderInsert, pInputOrder, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspParkedOrderInsert( CThostFtdcParkedOrderField *pParkedOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspParkedOrderInsert, pParkedOrder, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspParkedOrderAction( CThostFtdcParkedOrderActionField *pParkedOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspParkedOrderAction, pParkedOrderAction, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspOrderAction( CThostFtdcInputOrderActionField *pInputOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspOrderAction, pInputOrderAction, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQueryMaxOrderVolume( CThostFtdcQueryMaxOrderVolumeField *pQueryMaxOrderVolume, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQueryMaxOrderVolume, pQueryMaxOrderVolume, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspSettlementInfoConfirm( CThostFtdcSettlementInfoConfirmField *pSettlementInfoConfirm, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspSettlementInfoConfirm, pSettlementInfoConfirm, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspRemoveParkedOrder( CThostFtdcRemoveParkedOrderField *pRemoveParkedOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspRemoveParkedOrder, pRemoveParkedOrder, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspRemoveParkedOrderAction( CThostFtdcRemoveParkedOrderActionField *pRemoveParkedOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspRemoveParkedOrderAction, pRemoveParkedOrderAction, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspExecOrderInsert( CThostFtdcInputExecOrderField *pInputExecOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspExecOrderInsert, pInputExecOrder, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspExecOrderAction( CThostFtdcInputExecOrderActionField *pInputExecOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspExecOrderAction, pInputExecOrderAction, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspForQuoteInsert( CThostFtdcInputForQuoteField *pInputForQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspForQuoteInsert, pInputForQuote, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQuoteInsert( CThostFtdcInputQuoteField *pInputQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQuoteInsert, pInputQuote, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQuoteAction( CThostFtdcInputQuoteActionField *pInputQuoteAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQuoteAction, pInputQuoteAction, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspBatchOrderAction( CThostFtdcInputBatchOrderActionField *pInputBatchOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspBatchOrderAction, pInputBatchOrderAction, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspOptionSelfCloseInsert( CThostFtdcInputOptionSelfCloseField *pInputOptionSelfClose, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspOptionSelfCloseInsert, pInputOptionSelfClose, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspOptionSelfCloseAction( CThostFtdcInputOptionSelfCloseActionField *pInputOptionSelfCloseAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspOptionSelfCloseAction, pInputOptionSelfCloseAction, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspCombActionInsert( CThostFtdcInputCombActionField *pInputCombAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspCombActionInsert, pInputCombAction, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryOrder( CThostFtdcOrderField *pOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryOrder, pOrder, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryTrade( CThostFtdcTradeField *pTrade, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryTrade, pTrade, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryInvestorPosition( CThostFtdcInvestorPositionField *pInvestorPosition, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryInvestorPosition, pInvestorPosition, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryTradingAccount( CThostFtdcTradingAccountField *pTradingAccount, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryTradingAccount, pTradingAccount, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryInvestor( CThostFtdcInvestorField *pInvestor, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryInvestor, pInvestor, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryTradingCode( CThostFtdcTradingCodeField *pTradingCode, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryTradingCode, pTradingCode, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryInstrumentMarginRate( CThostFtdcInstrumentMarginRateField *pInstrumentMarginRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryInstrumentMarginRate, pInstrumentMarginRate, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryInstrumentCommissionRate( CThostFtdcInstrumentCommissionRateField *pInstrumentCommissionRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryInstrumentCommissionRate, pInstrumentCommissionRate, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryExchange( CThostFtdcExchangeField *pExchange, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryExchange, pExchange, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryProduct( CThostFtdcProductField *pProduct, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryProduct, pProduct, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryInstrument( CThostFtdcInstrumentField *pInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryInstrument, pInstrument, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryDepthMarketData( CThostFtdcDepthMarketDataField *pDepthMarketData, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryDepthMarketData, pDepthMarketData, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQrySettlementInfo( CThostFtdcSettlementInfoField *pSettlementInfo, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQrySettlementInfo, pSettlementInfo, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryTransferBank( CThostFtdcTransferBankField *pTransferBank, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryTransferBank, pTransferBank, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryInvestorPositionDetail( CThostFtdcInvestorPositionDetailField *pInvestorPositionDetail, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryInvestorPositionDetail, pInvestorPositionDetail, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryNotice( CThostFtdcNoticeField *pNotice, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryNotice, pNotice, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQrySettlementInfoConfirm( CThostFtdcSettlementInfoConfirmField *pSettlementInfoConfirm, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQrySettlementInfoConfirm, pSettlementInfoConfirm, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryInvestorPositionCombineDetail( CThostFtdcInvestorPositionCombineDetailField *pInvestorPositionCombineDetail, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryInvestorPositionCombineDetail, pInvestorPositionCombineDetail, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryCFMMCTradingAccountKey( CThostFtdcCFMMCTradingAccountKeyField *pCFMMCTradingAccountKey, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryCFMMCTradingAccountKey, pCFMMCTradingAccountKey, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryEWarrantOffset( CThostFtdcEWarrantOffsetField *pEWarrantOffset, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryEWarrantOffset, pEWarrantOffset, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryInvestorProductGroupMargin( CThostFtdcInvestorProductGroupMarginField *pInvestorProductGroupMargin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryInvestorProductGroupMargin, pInvestorProductGroupMargin, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryExchangeMarginRate( CThostFtdcExchangeMarginRateField *pExchangeMarginRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryExchangeMarginRate, pExchangeMarginRate, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryExchangeMarginRateAdjust( CThostFtdcExchangeMarginRateAdjustField *pExchangeMarginRateAdjust, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryExchangeMarginRateAdjust, pExchangeMarginRateAdjust, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryExchangeRate( CThostFtdcExchangeRateField *pExchangeRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryExchangeRate, pExchangeRate, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQrySecAgentACIDMap( CThostFtdcSecAgentACIDMapField *pSecAgentACIDMap, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQrySecAgentACIDMap, pSecAgentACIDMap, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryProductExchRate( CThostFtdcProductExchRateField *pProductExchRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryProductExchRate, pProductExchRate, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryProductGroup( CThostFtdcProductGroupField *pProductGroup, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryProductGroup, pProductGroup, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryMMInstrumentCommissionRate( CThostFtdcMMInstrumentCommissionRateField *pMMInstrumentCommissionRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryMMInstrumentCommissionRate, pMMInstrumentCommissionRate, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryMMOptionInstrCommRate( CThostFtdcMMOptionInstrCommRateField *pMMOptionInstrCommRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryMMOptionInstrCommRate, pMMOptionInstrCommRate, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryInstrumentOrderCommRate( CThostFtdcInstrumentOrderCommRateField *pInstrumentOrderCommRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryInstrumentOrderCommRate, pInstrumentOrderCommRate, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQrySecAgentTradingAccount( CThostFtdcTradingAccountField *pTradingAccount, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQrySecAgentTradingAccount, pTradingAccount, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQrySecAgentCheckMode( CThostFtdcSecAgentCheckModeField *pSecAgentCheckMode, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQrySecAgentCheckMode, pSecAgentCheckMode, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQrySecAgentTradeInfo( CThostFtdcSecAgentTradeInfoField *pSecAgentTradeInfo, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQrySecAgentTradeInfo, pSecAgentTradeInfo, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryOptionInstrTradeCost( CThostFtdcOptionInstrTradeCostField *pOptionInstrTradeCost, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryOptionInstrTradeCost, pOptionInstrTradeCost, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryOptionInstrCommRate( CThostFtdcOptionInstrCommRateField *pOptionInstrCommRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryOptionInstrCommRate, pOptionInstrCommRate, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryExecOrder( CThostFtdcExecOrderField *pExecOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryExecOrder, pExecOrder, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryForQuote( CThostFtdcForQuoteField *pForQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryForQuote, pForQuote, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryQuote( CThostFtdcQuoteField *pQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryQuote, pQuote, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryOptionSelfClose( CThostFtdcOptionSelfCloseField *pOptionSelfClose, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryOptionSelfClose, pOptionSelfClose, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryInvestUnit( CThostFtdcInvestUnitField *pInvestUnit, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryInvestUnit, pInvestUnit, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryCombInstrumentGuard( CThostFtdcCombInstrumentGuardField *pCombInstrumentGuard, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryCombInstrumentGuard, pCombInstrumentGuard, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryCombAction( CThostFtdcCombActionField *pCombAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryCombAction, pCombAction, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryTransferSerial( CThostFtdcTransferSerialField *pTransferSerial, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryTransferSerial, pTransferSerial, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryAccountregister( CThostFtdcAccountregisterField *pAccountregister, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryAccountregister, pAccountregister, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspError( CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_ERROR_CALLBACK( onRspError, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRtnOrder( CThostFtdcOrderField *pOrder) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnOrder, pOrder); } void MDSpiImpl::OnRtnTrade( CThostFtdcTradeField *pTrade) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnTrade, pTrade); } void MDSpiImpl::OnRtnInstrumentStatus( CThostFtdcInstrumentStatusField *pInstrumentStatus) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnInstrumentStatus, pInstrumentStatus); } void MDSpiImpl::OnRtnBulletin( CThostFtdcBulletinField *pBulletin) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnBulletin, pBulletin); } void MDSpiImpl::OnRtnTradingNotice( CThostFtdcTradingNoticeInfoField *pTradingNoticeInfo) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnTradingNotice, pTradingNoticeInfo); } void MDSpiImpl::OnRtnErrorConditionalOrder( CThostFtdcErrorConditionalOrderField *pErrorConditionalOrder) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnErrorConditionalOrder, pErrorConditionalOrder); } void MDSpiImpl::OnRtnExecOrder( CThostFtdcExecOrderField *pExecOrder) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnExecOrder, pExecOrder); } void MDSpiImpl::OnRtnQuote( CThostFtdcQuoteField *pQuote) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnQuote, pQuote); } void MDSpiImpl::OnRtnForQuoteRsp( CThostFtdcForQuoteRspField *pForQuoteRsp) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnForQuoteRsp, pForQuoteRsp); } void MDSpiImpl::OnRtnCFMMCTradingAccountToken( CThostFtdcCFMMCTradingAccountTokenField *pCFMMCTradingAccountToken) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnCFMMCTradingAccountToken, pCFMMCTradingAccountToken); } void MDSpiImpl::OnRtnOptionSelfClose( CThostFtdcOptionSelfCloseField *pOptionSelfClose) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnOptionSelfClose, pOptionSelfClose); } void MDSpiImpl::OnRtnCombAction( CThostFtdcCombActionField *pCombAction) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnCombAction, pCombAction); } void MDSpiImpl::OnRspQryContractBank( CThostFtdcContractBankField *pContractBank, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryContractBank, pContractBank, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryParkedOrder( CThostFtdcParkedOrderField *pParkedOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryParkedOrder, pParkedOrder, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryParkedOrderAction( CThostFtdcParkedOrderActionField *pParkedOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryParkedOrderAction, pParkedOrderAction, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryTradingNotice( CThostFtdcTradingNoticeField *pTradingNotice, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryTradingNotice, pTradingNotice, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryBrokerTradingParams( CThostFtdcBrokerTradingParamsField *pBrokerTradingParams, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryBrokerTradingParams, pBrokerTradingParams, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQryBrokerTradingAlgos( CThostFtdcBrokerTradingAlgosField *pBrokerTradingAlgos, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQryBrokerTradingAlgos, pBrokerTradingAlgos, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQueryCFMMCTradingAccountToken( CThostFtdcQueryCFMMCTradingAccountTokenField *pQueryCFMMCTradingAccountToken, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQueryCFMMCTradingAccountToken, pQueryCFMMCTradingAccountToken, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRtnFromBankToFutureByBank( CThostFtdcRspTransferField *pRspTransfer) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnFromBankToFutureByBank, pRspTransfer); } void MDSpiImpl::OnRtnFromFutureToBankByBank( CThostFtdcRspTransferField *pRspTransfer) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnFromFutureToBankByBank, pRspTransfer); } void MDSpiImpl::OnRtnRepealFromBankToFutureByBank( CThostFtdcRspRepealField *pRspRepeal) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnRepealFromBankToFutureByBank, pRspRepeal); } void MDSpiImpl::OnRtnRepealFromFutureToBankByBank( CThostFtdcRspRepealField *pRspRepeal) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnRepealFromFutureToBankByBank, pRspRepeal); } void MDSpiImpl::OnRtnFromBankToFutureByFuture( CThostFtdcRspTransferField *pRspTransfer) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnFromBankToFutureByFuture, pRspTransfer); } void MDSpiImpl::OnRtnFromFutureToBankByFuture( CThostFtdcRspTransferField *pRspTransfer) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnFromFutureToBankByFuture, pRspTransfer); } void MDSpiImpl::OnRtnRepealFromBankToFutureByFutureManual( CThostFtdcRspRepealField *pRspRepeal) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnRepealFromBankToFutureByFutureManual, pRspRepeal); } void MDSpiImpl::OnRtnRepealFromFutureToBankByFutureManual( CThostFtdcRspRepealField *pRspRepeal) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnRepealFromFutureToBankByFutureManual, pRspRepeal); } void MDSpiImpl::OnRtnQueryBankBalanceByFuture( CThostFtdcNotifyQueryAccountField *pNotifyQueryAccount) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnQueryBankBalanceByFuture, pNotifyQueryAccount); } void MDSpiImpl::OnRtnRepealFromBankToFutureByFuture( CThostFtdcRspRepealField *pRspRepeal) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnRepealFromBankToFutureByFuture, pRspRepeal); } void MDSpiImpl::OnRtnRepealFromFutureToBankByFuture( CThostFtdcRspRepealField *pRspRepeal) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnRepealFromFutureToBankByFuture, pRspRepeal); } void MDSpiImpl::OnRspFromBankToFutureByFuture( CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspFromBankToFutureByFuture, pReqTransfer, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspFromFutureToBankByFuture( CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspFromFutureToBankByFuture, pReqTransfer, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRspQueryBankAccountMoneyByFuture( CThostFtdcReqQueryAccountField *pReqQueryAccount, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { SOIL_FUNC_TRACE; CATA_ON_RSP_CALLBACK( onRspQueryBankAccountMoneyByFuture, pReqQueryAccount, pRspInfo, nRequestID, bIsLast); } void MDSpiImpl::OnRtnOpenAccountByBank( CThostFtdcOpenAccountField *pOpenAccount) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnOpenAccountByBank, pOpenAccount); } void MDSpiImpl::OnRtnCancelAccountByBank( CThostFtdcCancelAccountField *pCancelAccount) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnCancelAccountByBank, pCancelAccount); } void MDSpiImpl::OnRtnChangeAccountByBank( CThostFtdcChangeAccountField *pChangeAccount) { SOIL_FUNC_TRACE; CATA_ON_RTN_CALLBACK( onRtnChangeAccountByBank, pChangeAccount); }
19.586731
78
0.811975
27836637b1c8d8e2ece8d9fcebc6989f35efa4f0
34,419
cpp
C++
src/widgetopengldraw.cpp
jonpas/FERI-OpenGL
6cdf079dc2ed27ead53774ca5fdeb518a83fada9
[ "MIT" ]
null
null
null
src/widgetopengldraw.cpp
jonpas/FERI-OpenGL
6cdf079dc2ed27ead53774ca5fdeb518a83fada9
[ "MIT" ]
null
null
null
src/widgetopengldraw.cpp
jonpas/FERI-OpenGL
6cdf079dc2ed27ead53774ca5fdeb518a83fada9
[ "MIT" ]
null
null
null
#include "widgetopengldraw.h" WidgetOpenGLDraw::WidgetOpenGLDraw(QWidget *parent) : QOpenGLWidget(parent) { setMouseTracking(true); updateCameraFront(); std::random_device rd; rng = std::mt19937(rd()); } WidgetOpenGLDraw::~WidgetOpenGLDraw() { // Clean state gl.glDeleteProgram(programShaderID); gl.glDeleteShader(vertexShaderID); gl.glDeleteShader(fragmentShaderID); for (const auto &object : objects) { gl.glDeleteVertexArrays(1, &object.VAO); gl.glDeleteBuffers(1, &object.VBO); gl.glDeleteBuffers(1, &object.IBO); gl.glDeleteBuffers(2, object.TBO); } } void WidgetOpenGLDraw::printProgramInfoLog(GLuint obj) { int infologLength = 0; gl.glGetProgramiv(obj, GL_INFO_LOG_LENGTH, &infologLength); if (infologLength > 0) { std::unique_ptr<char[]> infoLog(new char[infologLength]); int charsWritten = 0; gl.glGetProgramInfoLog(obj, infologLength, &charsWritten, infoLog.get()); std::cerr << infoLog.get() << std::endl; } } void WidgetOpenGLDraw::printShaderInfoLog(GLuint obj) { int infologLength = 0; gl.glGetShaderiv(obj, GL_INFO_LOG_LENGTH, &infologLength); if (infologLength > 0) { std::unique_ptr<char[]> infoLog(new char[infologLength]); int charsWritten = 0; gl.glGetShaderInfoLog(obj, infologLength, &charsWritten, infoLog.get()); std::cerr << infoLog.get() << std::endl; } } const GLchar* WidgetOpenGLDraw::vertexShaderSource = R"glsl( #version 330 core const uint MAPPING_TYPE_SIMPLE = uint(0); const uint MAPPING_TYPE_PLANAR = uint(1); const uint MAPPING_TYPE_CYLINDRICAL = uint(2); const uint MAPPING_TYPE_SPHERICAL = uint(3); const uint MAPPING_AXIS_X = uint(0); const uint MAPPING_AXIS_Y = uint(1); const uint MAPPING_AXIS_Z = uint(2); layout(location=0) in vec3 position; layout(location=1) in vec2 uv; layout(location=2) in vec3 normal; uniform mat4 P; uniform mat4 V; uniform mat4 M; uniform uint TextureMappingType; uniform uint TextureMappingAxis; uniform vec3 BoundingBoxMin; uniform vec3 BoundingBoxMax; out vec2 TextureUV; out vec3 VertexPosition; out vec3 NormalInterpolated; vec2 textureMapping(vec2 uv) { vec3 objectSize = BoundingBoxMax - BoundingBoxMin; // Distance from one edge of bounding box to another vec3 objectCenter = BoundingBoxMin + objectSize / 2; // Bounding box center vec3 objectCenterToVertex = position - objectCenter; // Vector from vertex to bounding box center // GLSL atan(y, x): x and y parameters inversed! if (TextureMappingType == MAPPING_TYPE_SIMPLE) { if (TextureMappingAxis == MAPPING_AXIS_Y) { uv = vec2(uv.y, uv.x); } } else if (TextureMappingType == MAPPING_TYPE_PLANAR) { if (TextureMappingAxis == MAPPING_AXIS_X) { uv.x = (position.z - BoundingBoxMin.z) / objectSize.z; uv.y = (position.y - BoundingBoxMin.y) / objectSize.y; } else if (TextureMappingAxis == MAPPING_AXIS_Y) { uv.x = (position.x - BoundingBoxMin.x) / objectSize.x; uv.y = (position.z - BoundingBoxMin.z) / objectSize.z; } else if (TextureMappingAxis == MAPPING_AXIS_Z) { uv.x = (position.x - BoundingBoxMin.x) / objectSize.x; uv.y = (position.y - BoundingBoxMin.y) / objectSize.y; } } else if (TextureMappingType == MAPPING_TYPE_CYLINDRICAL) { float angle = 0.0f; if (TextureMappingAxis == MAPPING_AXIS_X) { angle = atan(objectCenterToVertex.y, objectCenterToVertex.z) + 180.0f; uv.y = objectCenterToVertex.x / objectSize.x + 0.5f; } else if (TextureMappingAxis == MAPPING_AXIS_Y) { angle = atan(objectCenterToVertex.z, objectCenterToVertex.x) + 180.0f; uv.y = objectCenterToVertex.y / objectSize.y + 0.5f; } else if (TextureMappingAxis == MAPPING_AXIS_Z) { angle = atan(objectCenterToVertex.y, objectCenterToVertex.x) + 180.0f; uv.y = objectCenterToVertex.z / objectSize.z + 0.5f; } uv.x = angle / 360.0f; } else if (TextureMappingType == MAPPING_TYPE_SPHERICAL) { float angle1 = 0.0f; float angle2 = 0.0f; if (TextureMappingAxis == MAPPING_AXIS_X) { angle1 = degrees(atan(objectCenterToVertex.y, objectCenterToVertex.z)) + 180.0f; angle2 = degrees(asin(objectCenterToVertex.x / length(objectCenterToVertex))); } else if (TextureMappingAxis == MAPPING_AXIS_Y) { angle1 = degrees(atan(objectCenterToVertex.z, objectCenterToVertex.x)) + 180.0f; angle2 = degrees(asin(objectCenterToVertex.y / length(objectCenterToVertex))); } else if (TextureMappingAxis == MAPPING_AXIS_Z) { angle1 = degrees(atan(objectCenterToVertex.y, objectCenterToVertex.x)) + 180.0f; angle2 = degrees(asin(objectCenterToVertex.z / length(objectCenterToVertex))); } uv.x = angle1 / 360.0f; uv.y = angle2 / 180.0f + 0.5f; } return uv; } void main() { // Calculate final render matrix (PVM) gl_Position = P * V * M * vec4(position, 1.0); // Map texture by given type and axis TextureUV = textureMapping(uv); // Calculate vertex position in global space vec4 vertPos4 = M * vec4(position, 1.0); VertexPosition = vec3(vertPos4) / vertPos4.w; // Calculate normal interpolated around vertices mat4 normalMatrix = transpose(inverse(M)); NormalInterpolated = vec3(normalMatrix * vec4(normal, 0.0)); } )glsl"; const GLchar* WidgetOpenGLDraw::fragmentShaderSource = R"glsl( #version 330 core // Mesh uniform sampler2D Texture; uniform sampler2D BumpMap; // Light uniform vec3 LightPos; uniform float LightPower; uniform vec3 LightColor; // Material uniform vec3 AmbientColor; uniform vec3 DiffuseColor; uniform vec3 SpecularColor; uniform float SpecularPower; // Shininess factor in vec2 TextureUV; in vec3 VertexPosition; in vec3 NormalInterpolated; out vec4 outColor; const float screenGamma = 2.2; // Assume the monitor is calibrated to the sRGB color space // Bump mapping vec3 bumpMappingFromHeight(vec3 normal, float height) { float bumpU = dFdx(height); float bumpV = dFdy(height); vec3 sU = dFdx(VertexPosition); vec3 sV = dFdy(VertexPosition); vec3 d = bumpU * normalize(cross(normal, sV)) + bumpV * normalize(cross(sU, normal)); return normalize(normal + d); } // Blinn-Phon shading model, gamma corrected vec3 shading(vec3 normal) { vec3 lightDir = LightPos - VertexPosition; float distance = length(lightDir); distance = distance * distance; lightDir = normalize(lightDir); float lambertian = max(dot(lightDir, normal), 0.0); float specular = 0.0; if (lambertian > 0.0) { vec3 viewDir = normalize(-VertexPosition); // Blinn-Phong vec3 halfDir = normalize(lightDir + viewDir); float specAngle = max(dot(halfDir, normal), 0.0); specular = pow(specAngle, SpecularPower); } vec3 colorLinear = AmbientColor + DiffuseColor * lambertian * LightColor * LightPower / distance + SpecularColor * specular * LightColor * LightPower / distance; // Apply gamma correction (assume AmbientColor, DiffuseColor and SpecularColor // have been linearized, i.e. have no gamma correction in them) return pow(colorLinear, vec3(1.0 / screenGamma)); } void main() { // Apply bump mapping float height = length(texture2D(BumpMap, TextureUV.st).xyz); vec3 normal = bumpMappingFromHeight(NormalInterpolated, height); // Apply lighting/shading/reflection vec3 colorGammaCorrected = shading(normal); // Apply texture and use the gamma corrected color in the fragment outColor = texture(Texture, TextureUV) * vec4(colorGammaCorrected, 1.0); } )glsl"; void WidgetOpenGLDraw::compileShaders() { programShaderID = gl.glCreateProgram(); // Create and compile the vertex shader vertexShaderID = gl.glCreateShader(GL_VERTEX_SHADER); std::cout << vertexShaderSource; gl.glShaderSource(vertexShaderID, 1, &vertexShaderSource, nullptr); gl.glCompileShader(vertexShaderID); gl.glAttachShader(programShaderID, vertexShaderID); // Create and compile the fragment shader fragmentShaderID = gl.glCreateShader(GL_FRAGMENT_SHADER); std::cout << fragmentShaderSource; gl.glShaderSource(fragmentShaderID, 1, &fragmentShaderSource, nullptr); gl.glCompileShader(fragmentShaderID); gl.glAttachShader(programShaderID, fragmentShaderID); // Link and use created shader program gl.glLinkProgram(programShaderID); gl.glUseProgram(programShaderID); // Print compiled shaders and program printShaderInfoLog(vertexShaderID); printShaderInfoLog(fragmentShaderID); printProgramInfoLog(programShaderID); } void WidgetOpenGLDraw::initializeGL() { // Load OpenGL functions std::cout << "OpenGL context version: " << context()->format().majorVersion() << "." << context()->format().minorVersion() << std::endl; if (!gl.initializeOpenGLFunctions()) { std::cerr << "Required openGL not supported" << std::endl; QApplication::exit(1); } std::cout << gl.glGetString(GL_VENDOR) << std::endl; std::cout << gl.glGetString(GL_VERSION) << std::endl; std::cout << gl.glGetString(GL_RENDERER) << std::endl; compileShaders(); // In case we drive more overlapping triangles, we want front to cover the ones in the back glEnable(GL_DEPTH_TEST); // Draw only one side of triangles glEnable(GL_CULL_FACE); // Define data (test objects) light = { "Light", {0.0f, 2.0f, 0.0f}, 40.0f }; objects = { { "Ground", { // Lighting will only work from top (ground doesn't go upside down usually) {glm::vec3(-5.0f, 0.0f, 5.0f), glm::vec2(0.0f, 1.0f), glm::vec3(0.0f, 1.0f, 0.0f)}, {glm::vec3(5.0f, 0.0f, 5.0f), glm::vec2(0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f)}, {glm::vec3(5.0f, 0.0f, -5.0f), glm::vec2(1.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f)}, {glm::vec3(-5.0f, 0.0f, -5.0f), glm::vec2(1.0f, 1.0f), glm::vec3(0.0f, 1.0f, 0.0f)}, }, {0, 1, 2, 2, 3, 0} } }; applyTextureFromFile("../test/textures/bricks.jpg", 0, 0, &objects.back(), true); applyBumpMapFromFile("../test/bumpMaps/bricks.jpg", &objects.back(), true); objects.push_back(makePyramid(3, "Pyramid")); objects.back().translation.x = -5.0f; objects.back().translation.z = -5.0f; applyBumpMapFromFile("../test/bumpMaps/leather.jpg", &objects.back(), true); objects.push_back(makeCube("Cube")); objects.back().translation.y += 2.0f; objects.back().translation.z += 5.0f; QImage cubeTex(512, 512, QImage::Format_RGB32); cubeTex.fill(Qt::red); objects.back().textureImage = cubeTex; applyBumpMapFromFile("../test/bumpMaps/dots.jpg", &objects.back(), true); QStringList paths = {"../test/models/icoSphere.obj"}; loadModelsFromFile(paths, true); objects.back().name = "IcoSphere"; objects.back().translation.x = -1.0f; applyTextureFromFile("../test/textures/steelMesh.jpg", 0, 0, &objects.back(), true); applyBumpMapFromFile("../test/bumpMaps/metalScales.jpg", &objects.back(), true); // Connect object selection ComboBox and fill it QObject::connect(objectSelection, SIGNAL(currentIndexChanged(int)), this, SLOT(selectObject(int))); // Add light to object selection dropdown and make it first selected object (same as ComboBox) objectSelection->addItem(light.name); selectedObject = &light; // Buffer data to GPU for (auto &object : objects) { generateObjectBuffers(object); loadObjectTexture(object); loadObjectBumpMap(object); } // Set background color gl.glClearColor(0.2f, 0.2f, 0.2f, 1); const unsigned int err = gl.glGetError(); if (err != 0) { std::cerr << "OpenGL init error: " << err << std::endl; } } void WidgetOpenGLDraw::generateObjectBuffers(MeshObject &object) { // Create Vertex Array Object, carrying properties related with buffer (eg. state of glEnableVertexAttribArray etc.) gl.glGenVertexArrays(1, &object.VAO); gl.glBindVertexArray(object.VAO); // Create and bind Vertex Buffer and load vertices into it gl.glGenBuffers(1, &object.VBO); gl.glBindBuffer(GL_ARRAY_BUFFER, object.VBO); gl.glBufferData(GL_ARRAY_BUFFER, static_cast<GLsizeiptr>(object.vertices.size() * sizeof(Vertex)), &object.vertices.front(), GL_STATIC_DRAW); // Create and bind Index Buffer and load vertex indices into it gl.glGenBuffers(1, &object.IBO); gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, object.IBO); gl.glBufferData(GL_ELEMENT_ARRAY_BUFFER, static_cast<GLsizeiptr>(object.indices.size() * sizeof(GLuint)), &object.indices.front(), GL_STATIC_DRAW); // Setup vertex attributes (specify layout of vertex data) gl.glEnableVertexAttribArray(0); // We use: layout(location=0) and vec3 position; gl.glEnableVertexAttribArray(1); // We use: layout(location=1) and vec2 uv; gl.glEnableVertexAttribArray(2); // We use: layout(location=2) and vec3 normal; gl.glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void *>(offsetof(Vertex, position))); gl.glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void *>(offsetof(Vertex, uv))); gl.glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void *>(offsetof(Vertex, normal))); // Create Texture Buffer gl.glGenTextures(2, object.TBO); #ifdef QT_DEBUG // Unbind to avoid accidental modification gl.glBindVertexArray(0); // VAO must be first! gl.glBindBuffer(GL_ARRAY_BUFFER, 0); gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); #endif // Add to object selection dropdown objectSelection->addItem(object.name); } void WidgetOpenGLDraw::loadObjectTexture(MeshObject &object) { if (object.textureImage.isNull()) { std::cerr << "Loading object texture failed! No texture image loaded for object! [" << object.name.toStdString() << "]" << std::endl; return; } // Bind Texture Buffer and load texture into it gl.glBindTexture(GL_TEXTURE_2D, object.TBO[0]); gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, object.textureImage.width(), object.textureImage.height(), 0, GL_BGRA, GL_UNSIGNED_BYTE, object.textureImage.bits()); gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Use linear filtering for upscaled textures gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); // Use nearest neighbour filtering for downscaled textures #ifdef QT_DEBUG // Unbind to avoid accidental modification gl.glBindTexture(GL_TEXTURE_2D, 0); #endif // Calculate bounding box object.boundingBoxMin = {INFINITY, INFINITY, INFINITY}; object.boundingBoxMax = {-INFINITY, -INFINITY, -INFINITY}; for (auto &vertex : object.vertices) { object.boundingBoxMin = {std::min(vertex.position.x, object.boundingBoxMin.x), std::min(vertex.position.y, object.boundingBoxMin.y), std::min(vertex.position.z, object.boundingBoxMin.z)}; object.boundingBoxMax = {std::max(vertex.position.x, object.boundingBoxMax.x), std::max(vertex.position.y, object.boundingBoxMax.y), std::max(vertex.position.z, object.boundingBoxMax.z)}; } } void WidgetOpenGLDraw::loadObjectBumpMap(MeshObject &object) { if (object.bumpMapImage.isNull()) { std::cerr << "Loading object bump map failed! No bump map image loaded for object! [" << object.name.toStdString() << "]" << std::endl; return; } // Bind Texture Buffer and load bump map into it gl.glBindTexture(GL_TEXTURE_2D, object.TBO[1]); gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, object.bumpMapImage.width(), object.bumpMapImage.height(), 0, GL_BGRA, GL_UNSIGNED_BYTE, object.bumpMapImage.bits()); gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); #ifdef QT_DEBUG // Unbind to avoid accidental modification gl.glBindTexture(GL_TEXTURE_2D, 0); #endif } void WidgetOpenGLDraw::resizeGL(int w, int h) { gl.glViewport(0, 0, w, h); } void WidgetOpenGLDraw::paintGL() { // Clean color and depth buffer (clean frame start) gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Projection matrix glm::mat4 P; if (projectionOrtho) P = glm::ortho(-10.0f, 10.0f, -10.0f, 10.0f, -1000.0f, 1000.0f); else P = glm::perspective(glm::radians(70.0f), float(width()) / height(), 0.01f, 1000.0f); // View matrix (camera position, direction ...) glm::mat4 V = glm::lookAt(cameraPos, cameraPos + cameraFront, cameraUp); // Object for (const auto &object : objects) { // Bind textures to texture units if (!object.textureImage.isNull()) { gl.glActiveTexture(GL_TEXTURE0); gl.glBindTexture(GL_TEXTURE_2D, object.TBO[0]); // Texture } if (!object.bumpMapImage.isNull()) { gl.glActiveTexture(GL_TEXTURE1); gl.glBindTexture(GL_TEXTURE_2D, object.TBO[1]); // Bump Map } gl.glBindVertexArray(object.VAO); // Model matrix (object movement) glm::mat4 M = glm::mat4(1); M = glm::translate(M, object.translation); M = glm::rotate(M, object.rotation.x, glm::vec3(1, 0, 0)); M = glm::rotate(M, object.rotation.y, glm::vec3(0, 0, 1)); M = glm::rotate(M, object.rotation.z, glm::vec3(0, 1, 0)); M = glm::scale(M, object.scale); // Uniforms gl.glUniformMatrix4fv(gl.glGetUniformLocation(programShaderID, "P"), 1, GL_FALSE, glm::value_ptr(P)); gl.glUniformMatrix4fv(gl.glGetUniformLocation(programShaderID, "V"), 1, GL_FALSE, glm::value_ptr(V)); gl.glUniformMatrix4fv(gl.glGetUniformLocation(programShaderID, "M"), 1, GL_FALSE, glm::value_ptr(M)); gl.glUniform1i(gl.glGetUniformLocation(programShaderID, "Texture"), 0); gl.glUniform1i(gl.glGetUniformLocation(programShaderID, "BumpMap"), 1); gl.glUniform3fv(gl.glGetUniformLocation(programShaderID, "LightPos"), 1, glm::value_ptr(light.translation)); gl.glUniform1f(gl.glGetUniformLocation(programShaderID, "LightPower"), light.scale.x); gl.glUniform3fv(gl.glGetUniformLocation(programShaderID, "LightColor"), 1, glm::value_ptr(light.color)); gl.glUniform3fv(gl.glGetUniformLocation(programShaderID, "AmbientColor"), 1, glm::value_ptr(object.material.ambientColor)); gl.glUniform3fv(gl.glGetUniformLocation(programShaderID, "DiffuseColor"), 1, glm::value_ptr(object.material.diffuseColor)); gl.glUniform3fv(gl.glGetUniformLocation(programShaderID, "SpecularColor"), 1, glm::value_ptr(object.material.specularColor)); gl.glUniform1f(gl.glGetUniformLocation(programShaderID, "SpecularPower"), object.material.specularPower); gl.glUniform1ui(gl.glGetUniformLocation(programShaderID, "TextureMappingType"), object.textureMappingType); gl.glUniform1ui(gl.glGetUniformLocation(programShaderID, "TextureMappingAxis"), object.textureMappingAxis); gl.glUniform3fv(gl.glGetUniformLocation(programShaderID, "BoundingBoxMin"), 1, glm::value_ptr(object.boundingBoxMin)); gl.glUniform3fv(gl.glGetUniformLocation(programShaderID, "BoundingBoxMax"), 1, glm::value_ptr(object.boundingBoxMax)); // Draw gl.glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(object.indices.size()), GL_UNSIGNED_INT, nullptr); // Unbind texture specifically to prevent error or already bound texture from being applied (and general cleanup) gl.glActiveTexture(GL_TEXTURE0); gl.glBindTexture(GL_TEXTURE_2D, 0); gl.glActiveTexture(GL_TEXTURE1); gl.glBindTexture(GL_TEXTURE_2D, 0); #ifdef QT_DEBUG // Unbind to avoid accidental modification gl.glBindVertexArray(0); #endif } const unsigned int err = gl.glGetError(); if (err != 0) { std::cerr << "OpenGL draw error: " << err << std::endl; } } void WidgetOpenGLDraw::handleKeys(QSet<int> keys, Qt::KeyboardModifiers modifiers) { // Camera movement if (keys.contains(Qt::Key_W)) { // Move camera in the direction its facing cameraPos += cameraFront * cameraSpeed; } if (keys.contains(Qt::Key_S)) { // Move camera away from the direction its facing cameraPos -= cameraFront * cameraSpeed; } if (keys.contains(Qt::Key_D)) { // Create a vector pointing to the right of the camera (perpendicular to facing direction) and move along it // Normalize to retain move speed independent of cameraFront size cameraPos += glm::normalize(glm::cross(cameraFront, cameraUp)) * cameraSpeed; } if (keys.contains(Qt::Key_A)) { // Create a vector pointing to the left of the camera (perpendicular to facing direction) and move along it // Normalize to retain move speed independent of cameraFront size cameraPos -= glm::normalize(glm::cross(cameraFront, cameraUp)) * cameraSpeed; } if (keys.contains(Qt::Key_Q)) { // Move camera in the direction of up vector cameraPos += cameraUp * cameraSpeed; } if (keys.contains(Qt::Key_E)) { // Move camera in the opposite direction of up vector cameraPos -= cameraUp * cameraSpeed; } // Selected Object movement if (keys.contains(Qt::Key_U)) { // Move up selectedObject->translation.y += 0.25f; } if (keys.contains(Qt::Key_N)) { // Move down selectedObject->translation.y -= 0.25f; } if (keys.contains(Qt::Key_H)) { // Move right selectedObject->translation.x += 0.25f; } if (keys.contains(Qt::Key_L)) { // Move left selectedObject->translation.x -= 0.25f; } if (keys.contains(Qt::Key_K)) { // Move forward selectedObject->translation.z += 0.25f; } if (keys.contains(Qt::Key_J)) { // Move backward selectedObject->translation.z -= 0.25f; } if (keys.contains(Qt::Key_Plus)) { // Scale up selectedObject->scale *= glm::vec3(1.05f); } if (keys.contains(Qt::Key_Minus)) { // Scale down selectedObject->scale *= glm::vec3(0.95f); } if (keys.contains(Qt::Key_X)) { // Rotate on X int8_t dir = (modifiers.testFlag(Qt::ControlModifier)) ? -1 : 1; selectedObject->rotation.x += 0.1f * dir; } if (keys.contains(Qt::Key_Y)) { // Rotate on Y int8_t dir = (modifiers.testFlag(Qt::ControlModifier)) ? -1 : 1; selectedObject->rotation.z += 0.1f * dir; } if (keys.contains(Qt::Key_C)) { // Rotate on Z int8_t dir = (modifiers.testFlag(Qt::ControlModifier)) ? -1 : 1; selectedObject->rotation.y += 0.1f * dir; } // Misc if (keys.contains(Qt::Key_P)) { // Swap projection (orthogonal or perspective) projectionOrtho = !projectionOrtho; } update(); // Redraw scene } void WidgetOpenGLDraw::mousePressEvent(QMouseEvent *event) { if (event->buttons() & Qt::RightButton) { mousePos = event->pos(); } } void WidgetOpenGLDraw::mouseMoveEvent(QMouseEvent *event) { if (event->buttons() & Qt::RightButton) { QPoint mousePosNew = event->pos(); cameraYaw -= static_cast<float>(mousePosNew.x() - mousePos.x()) * cameraSensitivity; cameraPitch -= static_cast<float>(mousePosNew.y() - mousePos.y()) * cameraSensitivity; // Sensible pitch limits if (cameraPitch > 89.0f) cameraPitch = 89.0f; else if (cameraPitch < -89.0f) cameraPitch = -89.0f; updateCameraFront(); mousePos = mousePosNew; } } void WidgetOpenGLDraw::updateCameraFront() { double pitchRad = static_cast<double>(glm::radians(cameraPitch)); double yawRad = static_cast<double>(glm::radians(cameraYaw)); glm::vec3 front; front.x = static_cast<float>(cos(pitchRad) * sin(yawRad)); front.y = static_cast<float>(sin(pitchRad)); front.z = static_cast<float>(cos(pitchRad) * cos(yawRad)); cameraFront = glm::normalize(front); update(); // Redraw scene } void WidgetOpenGLDraw::selectObject(int index) { if (index == 0) { selectedObject = &light; } else { selectedObject = &objects.at(static_cast<uint32_t>(index - 1)); } } bool WidgetOpenGLDraw::isMeshObjectSelected() { return selectedObject != &light; } void WidgetOpenGLDraw::loadModelsFromFile(QStringList &paths, bool preload) { for (auto &path : paths) { QFileInfo fileInfo(path); MeshObject object(fileInfo.fileName()); bool loaded = loadModelOBJ(path.toUtf8().constData(), object); if (loaded) { objects.push_back(object); if (!preload) { // Buffer new data to GPU generateObjectBuffers(objects.back()); // Reference from objects vector, as it is moved in memory when placing into vector! } } } if (!preload) { // Select last added object // (objects index + 1) due to light being at position 0 in ComboBox, but not in objects vector objectSelection->setCurrentIndex(static_cast<int>(objects.size())); update(); // Redraw scene } } void WidgetOpenGLDraw::applyTextureFromFile(QString path, GLuint mappingType, GLuint mappingAxis, MeshObject *object, bool preload) { if (object == nullptr) { object = static_cast<MeshObject *>(selectedObject); } QImage img; if (!img.load(path)) { std::cerr << "Texture image loading failed! [" << path.toStdString() << "]" << std::endl; return; } object->textureImage = img.convertToFormat(QImage::Format_ARGB32); object->textureMappingType = mappingType; object->textureMappingAxis = mappingAxis; if (!preload) { // Buffer new data to GPU loadObjectTexture(*object); update(); // Redraw scene } } void WidgetOpenGLDraw::applyBumpMapFromFile(QString path, MeshObject *object, bool preload) { if (object == nullptr) { object = static_cast<MeshObject *>(selectedObject); } QImage img; if (!img.load(path)) { std::cerr << "Bump map image loading failed! [" << path.toStdString() << "]" << std::endl; return; } object->bumpMapImage = img.convertToFormat(QImage::Format_ARGB32); if (!preload) { // Buffer new data to GPU loadObjectBumpMap(*object); update(); // Redraw scene } } bool WidgetOpenGLDraw::loadModelOBJ(const char *path, MeshObject &object) { std::vector<uint32_t> vertexIndices, uvIndices, normalIndices; std::vector<glm::vec3> tmpPositions; std::vector<glm::vec2> tmpUvs; std::vector<glm::vec3> tmpNormals; std::ifstream ifs; ifs.open(path); // Read file bool error = false; while (!error) { std::string lineHeader; ifs >> lineHeader; if (ifs.eof()) break; if (lineHeader == "v") { glm::vec3 vertex; if (!(ifs >> vertex.x >> vertex.y >> vertex.z)) error = true; tmpPositions.push_back(vertex); } else if (lineHeader == "vt") { glm::vec2 uv; if (!(ifs >> uv.x >> uv.y)) error = true; tmpUvs.push_back(uv); } else if (lineHeader == "vn") { glm::vec3 normal; if (!(ifs >> normal.x >> normal.y >> normal.z)) error = true; tmpNormals.push_back(normal); } else if (lineHeader == "f") { uint32_t vertexIndex[3], uvIndex[3], normalIndex[3]; char s; // Indices separated by '/' (slash) if (!(ifs >> vertexIndex[0] >> s >> uvIndex[0] >> s >> normalIndex[0] >> vertexIndex[1] >> s >> uvIndex[1] >> s >> normalIndex[1] >> vertexIndex[2] >> s >> uvIndex[2] >> s >> normalIndex[2])) error = true; vertexIndices.insert(vertexIndices.end(), {vertexIndex[0], vertexIndex[1], vertexIndex[2]}); uvIndices.insert(uvIndices.end(), {uvIndex[0], uvIndex[1], uvIndex[2]}); normalIndices.insert(normalIndices.end(), {normalIndex[0], normalIndex[1], normalIndex[2]}); } else { // Probably a comment (or something else we don't support), eat up the rest of the line ifs.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); } } if (error) { std::cerr << "Model OBJ file parsing failed! [" << path << "]" << std::endl; ifs.close(); return false; } // Rearrange data - OBJ indexes all parts separately, OpenGL only supports 1 index buffer // Ignore OBJ indexing and just duplicate data for non-index usage (but still directly index them to keep the rest of the code clean) // Each triangle for (uint32_t v = 0; v < vertexIndices.size(); v += 3) { // Each vertex of the triangle for (uint32_t i = 0; i < 3; ++i) { // Get indices of wanted parts uint32_t vertexIndex = vertexIndices[v + i]; glm::vec3 position = tmpPositions[vertexIndex - 1]; uint32_t uvIndex = uvIndices[v + i]; glm::vec2 uv = tmpUvs[uvIndex - 1]; uint32_t normalIndex = normalIndices[v + i]; glm::vec3 normal = tmpNormals[normalIndex - 1]; // Save parts into Vertex and use current overall index object.vertices.push_back({position, uv, normal}); object.indices.push_back(v + i); } } ifs.close(); return true; } MeshObject WidgetOpenGLDraw::makeCube(QString name) { return makeCubeOffset(glm::vec3(0.0f, 0.0f, 0.0f), 0, name); } MeshObject WidgetOpenGLDraw::makeCubeOffset(glm::vec3 baseVertex, GLuint baseIndex, QString name) { MeshObject cube = { name, // Some vertices duplicated to fit indexing of UVs { {baseVertex + glm::vec3(0.0f, 1.0f, 0.0f), glm::vec2(0.0f, 0.66f), glm::vec3(-1.0f, 2.0f, -1.0f)}, {baseVertex + glm::vec3(0.0f, 0.0f, 0.0f), glm::vec2(0.25f, 0.66f), glm::vec3(-1.0f, -1.0f, -1.0f)}, {baseVertex + glm::vec3(1.0f, 1.0f, 0.0f), glm::vec2(0.0f, 0.33f), glm::vec3(2.0f, 2.0f, -1.0f)}, {baseVertex + glm::vec3(1.0f, 0.0f, 0.0f), glm::vec2(0.25f, 0.33f), glm::vec3(2.0f, -1.0f, -1.0f)}, {baseVertex + glm::vec3(0.0f, 0.0f, 1.0f), glm::vec2(0.5f, 0.66f), glm::vec3(-1.0f, -1.0f, 2.0f)}, {baseVertex + glm::vec3(1.0f, 0.0f, 1.0f), glm::vec2(0.5f, 0.33f), glm::vec3(2.0f, -1.0f, 2.0f)}, {baseVertex + glm::vec3(0.0f, 1.0f, 1.0f), glm::vec2(0.75f, 0.66f), glm::vec3(-1.0f, 2.0f, -1.0f)}, {baseVertex + glm::vec3(1.0f, 1.0f, 1.0f), glm::vec2(0.75f, 0.33f), glm::vec3(2.0f, 2.0f, 2.0f)}, {baseVertex + glm::vec3(0.0f, 1.0f, 0.0f), glm::vec2(1.0f, 0.66f), glm::vec3(-1.0f, 2.0f, -1.0f)}, {baseVertex + glm::vec3(1.0f, 1.0f, 0.0f), glm::vec2(1.0f, 0.33f), glm::vec3(2.0f, 2.0f, -1.0f)}, {baseVertex + glm::vec3(0.0f, 1.0f, 0.0f), glm::vec2(0.25f, 1.0f), glm::vec3(-1.0f, 2.0f, -1.0f)}, {baseVertex + glm::vec3(0.0f, 1.0f, 1.0f), glm::vec2(0.5f, 1.0f), glm::vec3(-1.0f, 2.0f, 2.0f)}, {baseVertex + glm::vec3(1.0f, 1.0f, 0.0f), glm::vec2(0.25f, 0.0f), glm::vec3(2.0f, 2.0f, -1.0f)}, {baseVertex + glm::vec3(1.0f, 1.0f, 1.0f), glm::vec2(0.5f, 0.0f), glm::vec3(2.0f, 2.0f, 2.0f)}, }, { baseIndex + 0, baseIndex + 2, baseIndex + 1,baseIndex + 1, baseIndex + 2, baseIndex + 3, // Front baseIndex + 4, baseIndex + 5, baseIndex + 6, baseIndex + 5, baseIndex + 7, baseIndex + 6, // Back baseIndex + 6, baseIndex + 7, baseIndex + 8, baseIndex + 7, baseIndex + 9, baseIndex + 8, // Top baseIndex + 1, baseIndex + 3, baseIndex + 4, baseIndex + 3, baseIndex + 5, baseIndex + 4, // Bottom baseIndex + 1, baseIndex + 11, baseIndex + 10, baseIndex + 1, baseIndex + 4, baseIndex + 11, // Left baseIndex + 3, baseIndex + 12, baseIndex + 5, baseIndex + 5, baseIndex + 12, baseIndex + 13, // Right } }; return cube; } MeshObject WidgetOpenGLDraw::makePyramid(uint32_t rows, QString name) { MeshObject pyramid(name); float offset = 0.0f; for (uint32_t row = 0; row < rows; ++row) { for (uint32_t i = 0; i < rows - row; ++i) { for (uint32_t j = 0; j < rows - row; ++j) { // Make cube and merge it into the pyramid MeshObject cube = makeCubeOffset(glm::vec3(offset + i, row, offset + j), static_cast<GLuint>(pyramid.vertices.size())); pyramid.vertices.insert(std::end(pyramid.vertices), std::begin(cube.vertices), std::end(cube.vertices)); pyramid.indices.insert(std::end(pyramid.indices), std::begin(cube.indices), std::end(cube.indices)); // Note: Normals should be corrected here, but they aren't } } offset += 0.5f; } // Random solid color texture std::uniform_int_distribution<> dist(0, 255); QColor rngColor(dist(rng), dist(rng), dist(rng)); QImage img(1, 1, QImage::Format_ARGB32); img.fill(rngColor); pyramid.textureImage = img; return pyramid; }
40.350528
164
0.630175
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 * * mikhail.zaslavskiy@ensmp.fr * * * * 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
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
95991eec4f58418a24c0ac505366c668ae00c770
459
hpp
C++
include/portable/cxx.hpp
matrixjoeq/candy
53fe18d8b68d2f131c8e1c8f76c7d9b7f752bbdc
[ "MIT" ]
null
null
null
include/portable/cxx.hpp
matrixjoeq/candy
53fe18d8b68d2f131c8e1c8f76c7d9b7f752bbdc
[ "MIT" ]
null
null
null
include/portable/cxx.hpp
matrixjoeq/candy
53fe18d8b68d2f131c8e1c8f76c7d9b7f752bbdc
[ "MIT" ]
null
null
null
#pragma once #include <type_traits> namespace candy { template <bool B, class T = void> using EnableIf = typename std::enable_if<B, T>::type; template <class T> using ResultOf = typename std::result_of<T>::type; template <class Base, class Derived> inline constexpr bool isBaseOf() { return std::is_base_of<Base, Derived>::value; } template <class T> inline constexpr bool isPointer() { return std::is_pointer<T>::value; } } // namespace candy
17.653846
53
0.714597
959b5abb8eb5b8790f60e6eb93d6b4aa7fad2380
5,731
cpp
C++
client/http_secure_args.cpp
boazsade/http_client
5e7a97c73da7e22685c29177581bf9c95e73f2ec
[ "MIT" ]
null
null
null
client/http_secure_args.cpp
boazsade/http_client
5e7a97c73da7e22685c29177581bf9c95e73f2ec
[ "MIT" ]
null
null
null
client/http_secure_args.cpp
boazsade/http_client
5e7a97c73da7e22685c29177581bf9c95e73f2ec
[ "MIT" ]
null
null
null
#include "http_secure_args.h" namespace http { namespace { namespace ssl = boost::asio::ssl; ssl::context init_context(const https_config& conf) { int proto = conf.security_type(); if (proto == -1) { proto = ssl::context_base::sslv23; } ssl::context ctx((ssl::context::method)proto); if (conf.cert_conf().use_default()) { ctx.set_default_verify_paths(); } else { if (conf.cert_conf().is_file()) { ctx.load_verify_file(conf.cert_conf().get_path()); } else { ctx.add_verify_path(conf.cert_conf().get_path()); } } return ctx; } #if 0 bool is_server_side(int value) { switch (value) { case -1: return false; case ssl::context_base::sslv2_server: case ssl::context_base::sslv3_server: case ssl::context_base::tlsv1_server: case ssl::context_base::tlsv11_server: case ssl::context_base::tlsv12_server: case ssl::context_base::sslv23_server: return true; default: return false; } } bool is_any_side(int value) { switch(value) { case -1: return false; case ssl::context_base::sslv2: case ssl::context_base::sslv3: case ssl::context_base::tlsv1: case ssl::context_base::tlsv11: case ssl::context_base::tlsv12: case ssl::context_base::sslv23: return true; default: return false; } } bool is_client_side(int value) { return !(is_any_side(value) || is_server_side(value)); } #endif int type2boost_type_client(https_config::type t) { switch (t) { case https_config::SSL_V2: return ssl::context_base::sslv2_client; case https_config::SSL_V3: return ssl::context_base::sslv3_client; case https_config::TLS_V1: return ssl::context_base::tlsv1_client; case https_config::TLS_V11: return ssl::context_base::tlsv11_client; case https_config::TLS_V12: return ssl::context_base::tlsv12_client; case https_config::SSL_TLS: return ssl::context_base::sslv23_client; case https_config::TYPE_NOT_SET: return -1; } } int type2boost_type_sever(https_config::type t) { switch (t) { case https_config::SSL_V2: return ssl::context_base::sslv2_server; case https_config::SSL_V3: return ssl::context_base::sslv3_server; case https_config::TLS_V1: return ssl::context_base::tlsv1_server; case https_config::TLS_V11: return ssl::context_base::tlsv11_server; case https_config::TLS_V12: return ssl::context_base::tlsv12_server; case https_config::SSL_TLS: return ssl::context_base::sslv23_server; case https_config::TYPE_NOT_SET: return -1; } } int type2boost_type(https_config::type t) { switch (t) { case https_config::SSL_V2: return ssl::context_base::sslv2; case https_config::SSL_V3: return ssl::context_base::sslv3; case https_config::TLS_V1: return ssl::context_base::tlsv1; case https_config::TLS_V11: return ssl::context_base::tlsv11; case https_config::TLS_V12: return ssl::context_base::tlsv12; case https_config::SSL_TLS: return ssl::context_base::sslv23; case https_config::TYPE_NOT_SET: return -1; } } int convert2action(https_config::type t, https_config::which w) { switch (w) { case https_config::CLIENT_ONLY: return type2boost_type_client(t); case https_config::SERVER_ONLY: return type2boost_type_sever(t); default: return type2boost_type(t); } } /////////////////////////////////////////////////////////////////////////////// } // end of local namespce https_cert::https_cert() : fformat(NOT_SET), file(false) { } https_cert::https_cert(const std::string& p, format f) : path(p), fformat(f), file(false) { } https_cert::https_cert(const std::string& p, bool is_file, format f) : path(p), fformat(f), file(is_file) { } bool https_cert::use_default() const { return path.empty(); } https_cert::format https_cert::get_format() const { return fformat; } const char* https_cert::get_path() const { return use_default() ? nullptr : path.c_str(); } bool https_cert::is_file() const { return file; } /////////////////////////////////////////////////////////////////////////////// https_config::https_config(type t, which w, const https_cert& c) : sec_type(convert2action(t, w)), cert(c) { } const https_cert& https_config::cert_conf() const { return cert; } https_config& https_config::set_protocol(type t, which w) { sec_type = convert2action(t, w); return *this; } https_config& https_config::operator = (const https_cert& c) { cert = c; return *this; } int https_config::security_type() const { return sec_type; } /////////////////////////////////////////////////////////////////////////////// security_args::security_args(const https_config& conf) : context(std::move(init_context(conf))), verify_action(security_args::DONT_APPLY) { } security_args::security_args(int verify_type, const https_config& conf) : context(std::move(init_context(conf))), verify_action(verify_type) { } void security_args::sec_method(int type) { verify_action = type; } security_args::ssl_context& security_args::security_handle() { return context; } int security_args::security_method() const { return verify_action;; } } // end of namespace http
24.491453
140
0.61019
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
95a359e0389511a9ef04afe8b0c37ab9c07567f2
1,801
cpp
C++
leetcode/ComboSumIV.cpp
tzaffi/cpp
43d99e70d8fa712f90ea0f6147774e4e0f2b11da
[ "MIT" ]
null
null
null
leetcode/ComboSumIV.cpp
tzaffi/cpp
43d99e70d8fa712f90ea0f6147774e4e0f2b11da
[ "MIT" ]
null
null
null
leetcode/ComboSumIV.cpp
tzaffi/cpp
43d99e70d8fa712f90ea0f6147774e4e0f2b11da
[ "MIT" ]
null
null
null
// // Created by zeph on 11/25/16. // /** * Combination Sum IV Difficulty: Medium Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target. Example: nums = [1, 2, 3] target = 4 The possible combination ways are: (1, 1, 1, 1) (1, 1, 2) (1, 2, 1) (1, 3) (2, 1, 1) (2, 2) (3, 1) Note that different sequences are counted as different combinations. Therefore the output is 7. Follow up: What if negative numbers are allowed in the given array? How does it change the problem? What limitation we need to add to the question to allow negative numbers? Credits: Special thanks to @pbrother for adding this problem and creating all test cases. */ #include <iostream> #include <vector> #include <cassert> #include <cmath> using namespace std; class Solution { public: int combinationSum4(vector<int>& nums, int target){ return bruteForce(nums, target); } private: int bruteForce(vector<int>& nums, int target){ int ans = 0; if (target <= 0){ return ans; } else if (find(nums.cbegin(), nums.cend(), target) != nums.cend()){ ans++; } for(auto& x: nums){ int newTarget = target - x; if( newTarget > 0 ){ ans += combinationSum4(nums, newTarget); } } return ans; } }; int main() { cout << "Combination Sums IV\n\n\n"; vector<int> nums = {1, 2, 3}; int target = 4; Solution s; int ans = s.combinationSum4(nums, target); cout << "got " << ans << " solutions\n\n"; assert(ans == 7); nums = {4,2,1}; target = 32; ans = s.combinationSum4(nums, target); cout << "got " << ans << " solutions\n\n"; return 0; }
21.963415
83
0.605219
95a3a88dfd385f25bc0715b90db46922bea8d373
5,625
cpp
C++
src/mongo/util/alarm.cpp
benety/mongo
203430ac9559f82ca01e3cbb3b0e09149fec0835
[ "Apache-2.0" ]
null
null
null
src/mongo/util/alarm.cpp
benety/mongo
203430ac9559f82ca01e3cbb3b0e09149fec0835
[ "Apache-2.0" ]
null
null
null
src/mongo/util/alarm.cpp
benety/mongo
203430ac9559f82ca01e3cbb3b0e09149fec0835
[ "Apache-2.0" ]
null
null
null
/** * Copyright (C) 2018-present MongoDB, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the Server Side Public License, version 1, * as published by MongoDB, Inc. * * 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 * Server Side Public License for more details. * * You should have received a copy of the Server Side Public License * along with this program. If not, see * <http://www.mongodb.com/licensing/server-side-public-license>. * * As a special exception, the copyright holders give permission to link the * code of portions of this program with the OpenSSL library under certain * conditions as described in each individual source file and distribute * linked combinations including the program with the OpenSSL library. You * must comply with the Server Side Public License in all respects for * all of the code used other than as permitted herein. If you modify file(s) * with this exception, you may extend this exception to your version of the * file(s), but you are not obligated to do so. If you do not wish to do so, * delete this exception statement from your version. If you delete this * exception statement from all source files in the program, then also delete * it in the license file. */ #include "mongo/platform/basic.h" #include "mongo/util/alarm.h" namespace mongo { class AlarmSchedulerPrecise::HandleImpl final : public AlarmScheduler::Handle, public std::enable_shared_from_this<AlarmSchedulerPrecise::HandleImpl> { public: HandleImpl(std::weak_ptr<AlarmSchedulerPrecise> service, AlarmSchedulerPrecise::AlarmMapIt it) : _service(std::move(service)), _myIt(std::move(it)) {} struct MakeEmptyHandle {}; explicit HandleImpl(MakeEmptyHandle) : _service(std::shared_ptr<AlarmSchedulerPrecise>(nullptr)), _myIt(), _done(true) {} Status cancel() override { auto service = _service.lock(); if (!service) { return {ErrorCodes::ShutdownInProgress, "The alarm scheduler was shutdown"}; } stdx::unique_lock<Latch> lk(service->_mutex); if (_done) { return {ErrorCodes::AlarmAlreadyFulfilled, "The alarm has already been canceled"}; } auto state = std::move(_myIt->second); service->_alarms.erase(_myIt); lk.unlock(); std::move(state.promise) .setError({ErrorCodes::CallbackCanceled, "The alarm was canceled before it expired or could be processed"}); return Status::OK(); } void setDone() { _done = true; } private: std::weak_ptr<AlarmSchedulerPrecise> const _service; AlarmSchedulerPrecise::AlarmMapIt _myIt; bool _done = false; }; AlarmSchedulerPrecise::~AlarmSchedulerPrecise() { clearAllAlarms(); } AlarmScheduler::Alarm AlarmSchedulerPrecise::alarmAt(Date_t date) { stdx::unique_lock<Latch> lk(_mutex); if (_shutdown) { Alarm ret; ret.future = Future<void>::makeReady( Status(ErrorCodes::ShutdownInProgress, "Alarm scheduler has been shut down.")); ret.handle = std::make_shared<HandleImpl>(HandleImpl::MakeEmptyHandle{}); return ret; } auto pf = makePromiseFuture<void>(); auto it = _alarms.emplace(date, AlarmData(std::move(pf.promise))); auto nextAlarm = _alarms.begin()->first; auto ret = std::make_shared<HandleImpl>(shared_from_this(), it); it->second.handle = ret; lk.unlock(); callRegisterHook(nextAlarm, shared_from_this()); return {std::move(pf.future), std::move(ret)}; } void AlarmSchedulerPrecise::processExpiredAlarms( boost::optional<AlarmScheduler::AlarmExpireHook> hook) { AlarmCount processed = 0; auto now = clockSource()->now(); std::vector<Promise<void>> toExpire; AlarmMapIt it; stdx::unique_lock<Latch> lk(_mutex); for (it = _alarms.begin(); it != _alarms.end();) { if (hook && !(*hook)(processed + 1)) { break; } if (it->first > now) { break; } processed++; toExpire.push_back(std::move(it->second.promise)); auto handle = it->second.handle.lock(); if (handle) { handle->setDone(); } it = _alarms.erase(it); } lk.unlock(); for (auto& promise : toExpire) { promise.emplaceValue(); } } Date_t AlarmSchedulerPrecise::nextAlarm() { stdx::lock_guard<Latch> lk(_mutex); return (_alarms.empty()) ? Date_t::max() : _alarms.begin()->first; } void AlarmSchedulerPrecise::clearAllAlarms() { stdx::unique_lock<Latch> lk(_mutex); _clearAllAlarmsImpl(lk); } void AlarmSchedulerPrecise::clearAllAlarmsAndShutdown() { stdx::unique_lock<Latch> lk(_mutex); _shutdown = true; _clearAllAlarmsImpl(lk); } void AlarmSchedulerPrecise::_clearAllAlarmsImpl(stdx::unique_lock<Latch>& lk) { std::vector<Promise<void>> toExpire; for (AlarmMapIt it = _alarms.begin(); it != _alarms.end();) { toExpire.push_back(std::move(it->second.promise)); auto handle = it->second.handle.lock(); if (handle) { handle->setDone(); } it = _alarms.erase(it); } lk.unlock(); for (auto& alarm : toExpire) { alarm.setError({ErrorCodes::CallbackCanceled, "Alarm scheduler was cleared"}); } } } // namespace mongo
32.894737
98
0.657244
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, &params); 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, &params); 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, &params); 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, &params); 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, &params); 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, &params); 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, &params); 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, &params); 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, &params); 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, &params); fn->FunctionFlags = flags; } } #ifdef _MSC_VER #pragma pack(pop) #endif
31.67713
163
0.76359
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
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
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
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
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
95b556d3ea0b81e90c7fa3021b1864eca830ff22
1,346
hpp
C++
siar_driver/include/siar_driver/arm_firewall.hpp
robotics-upo/siar_packages
2b9b3e7acbc9bc5845b03d63eb18dbc50bfd3c98
[ "BSD-3-Clause" ]
3
2020-02-06T13:36:38.000Z
2020-11-10T08:52:23.000Z
siar_driver/include/siar_driver/arm_firewall.hpp
robotics-upo/siar_packages
2b9b3e7acbc9bc5845b03d63eb18dbc50bfd3c98
[ "BSD-3-Clause" ]
null
null
null
siar_driver/include/siar_driver/arm_firewall.hpp
robotics-upo/siar_packages
2b9b3e7acbc9bc5845b03d63eb18dbc50bfd3c98
[ "BSD-3-Clause" ]
2
2017-03-20T16:08:37.000Z
2018-04-22T04:26:12.000Z
#ifndef __ARM_FIREWALL_HPP__ #define __ARM_FIREWALL_HPP__ #include "ros/ros.h" #include "siar_driver/SiarArmCommand.h" #include "siar_driver/SiarStatus.h" #include <boost/array.hpp> class ArmFirewall { public: static bool checkJointLimits(const boost::array<int16_t, 5> joint_values) { bool ret_val = (joint_values[0]<805 && joint_values[0]>208); ret_val &= (joint_values[1]<1568 && joint_values[1]>220); ret_val &= (joint_values[2]<2020 && joint_values[2]>191); // Limits from the Arm Reference Value spreadsheet of Carlos Marques ret_val &= (joint_values[3]<958 && joint_values[3]>30); ret_val &= (joint_values[4]<1000 && joint_values[4]>30); return ret_val; } static bool checkTemperatureAndStatus(const boost::array<uint8_t,5> &herculex_temperature, const boost::array<uint8_t,5> &herculex_status) { bool ret_val = true; for(int i = 0; i < 5; i++) { if (herculex_temperature[i]<0 && herculex_temperature[i]>50) { ROS_ERROR("TEMPERATURE OF THE %d LINK IS OUT OF RANGE: %d", i, herculex_temperature[i]); ret_val = false; } // if (herculex_status[i]!=1) // TODO: Check this!! // { // ROS_ERROR("%d LINK STATUS: %d", i, herculex_status[i]); // ret_val = false; // } } return ret_val; } }; #endif
25.884615
142
0.643388
95c08918687ae80cd970c1829c9e0d39c02ad59a
2,210
cpp
C++
FrameworkLib/DX11VertApi.cpp
DashW/Ingenuity
f7944a9e8063beaa3dda31e8372d18b4147782e2
[ "Zlib" ]
null
null
null
FrameworkLib/DX11VertApi.cpp
DashW/Ingenuity
f7944a9e8063beaa3dda31e8372d18b4147782e2
[ "Zlib" ]
null
null
null
FrameworkLib/DX11VertApi.cpp
DashW/Ingenuity
f7944a9e8063beaa3dda31e8372d18b4147782e2
[ "Zlib" ]
null
null
null
#include "stdafx.h" #include "DX11VertApi.h" #ifdef USE_DX11_GPUAPI ID3D11InputLayout* DX11Vertex_Pos::inputLayout = 0; ID3D11InputLayout* DX11Vertex_PosCol::inputLayout = 0; ID3D11InputLayout* DX11Vertex_PosNor::inputLayout = 0; ID3D11InputLayout* DX11Vertex_PosNorTex::inputLayout = 0; bool DX11_VertApi::InitInputLayout(VertexType type, ID3D11Device* device, const void* shaderBytecode, SIZE_T bytecodeLength){ switch(type) { case VertexType_Pos: return DX11Vertex_Pos::initInputLayout(device,shaderBytecode,bytecodeLength); case VertexType_PosCol: return DX11Vertex_PosCol::initInputLayout(device,shaderBytecode,bytecodeLength); case VertexType_PosNor: return DX11Vertex_PosNor::initInputLayout(device,shaderBytecode,bytecodeLength); case VertexType_PosNorTex: return DX11Vertex_PosNorTex::initInputLayout(device,shaderBytecode,bytecodeLength); default: OutputDebugString(L"Could not initialise unrecognized vertex type\n"); return false; } } void DX11_VertApi::ReleaseVertices(){ if(DX11Vertex_Pos::inputLayout) DX11Vertex_Pos::inputLayout->Release(); if(DX11Vertex_PosCol::inputLayout) DX11Vertex_PosCol::inputLayout->Release(); if(DX11Vertex_PosNor::inputLayout) DX11Vertex_PosNor::inputLayout->Release(); if(DX11Vertex_PosNorTex::inputLayout) DX11Vertex_PosNorTex::inputLayout->Release(); } ID3D11InputLayout* DX11_VertApi::GetInputLayout(VertexType type) { switch(type) { case VertexType_Pos: return DX11Vertex_Pos::inputLayout; case VertexType_PosCol: return DX11Vertex_PosCol::inputLayout; case VertexType_PosNor: return DX11Vertex_PosNor::inputLayout; case VertexType_PosNorTex: return DX11Vertex_PosNorTex::inputLayout; default: //OutputDebugString(L"Could not get declaration of unrecognized vertex type\n"); return 0; } } unsigned DX11_VertApi::GetSize(VertexType type) { switch(type) { case VertexType_Pos: return sizeof(DX11Vertex_Pos); case VertexType_PosCol: return sizeof(DX11Vertex_PosCol); case VertexType_PosNor: return sizeof(DX11Vertex_PosNor); case VertexType_PosNorTex: return sizeof(DX11Vertex_PosNorTex); default: //OutputDebugString(L"Could not get size of unrecognized vertex type\n"); return 0; } } #endif
32.028986
85
0.808597
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
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
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
95c73c965ca8007407bccbbf7411eaa2dc8166ec
2,050
cpp
C++
test/TestMatrix.cpp
guneykan/ml-algorithms
4fecf9dbf2ef77ebf86d795ee01939796b0b7e14
[ "MIT" ]
null
null
null
test/TestMatrix.cpp
guneykan/ml-algorithms
4fecf9dbf2ef77ebf86d795ee01939796b0b7e14
[ "MIT" ]
null
null
null
test/TestMatrix.cpp
guneykan/ml-algorithms
4fecf9dbf2ef77ebf86d795ee01939796b0b7e14
[ "MIT" ]
null
null
null
#include "gtest/gtest.h" #include "util/math/matrix.h" TEST(Matrix, sum_1by1) { Matrix m1(std::vector<double>{0.5}, 1, 1); Matrix m2(std::vector<double>{91.2}, 1, 1); Matrix calculated = m1.plus(m2); Matrix actual(std::vector<double>{91.7}, 1, 1); ASSERT_EQ(actual.get(0, 0), calculated.get(0, 0)); } TEST(Matrix, sum_3by3) { Matrix m1({6, 4, 5, 4, 5, 1, 2, 8, 3}, 3, 3); Matrix m2({3, 4, 0, 9, 1, 6, 1, 8, 2}, 3, 3); Matrix calculated = m1.plus(m2); Matrix actual({9, 8, 5, 13, 6, 7, 3, 16, 5}, 3, 3); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { ASSERT_EQ(actual.get(i, j), calculated.get(i, j)); } } } TEST(Matrix, sum_4by5) { Matrix m1({632.929, 490.984, 5121.213, 495.065, 5121.910, 1998.129, 2968.190, 854.135, 32.621, 1254.411, 467.149, 1200.486, 6043.216, 5032.697, 5124.764, 917.703, 534.215, 7100.643, 451.096, 91.431}, 4, 5); Matrix m2({398.013, 43.514, 995.812, 911.531, 1000.548, 69.541, 110.461, 800.694, 2485.441, 322.973, 434.869, 661.964, 857.333, 3.885, 83.132, 995.143, 456.877, 331.583, 901.671, 67.123}, 4, 5); Matrix calculated = m1.plus(m2); Matrix actual({1030.942, 534.498, 6117.025, 1406.596, 6122.458, 2067.670, 3078.651, 1654.829, 2518.062, 1577.384, 902.018, 1862.450, 6900.549, 5036.582, 5207.896, 1912.846, 991.092, 7432.226, 1352.767, 158.554}, 4, 5); for (int i = 0; i < 4; i++) { for (int j = 0; j < 5; j++) { ASSERT_NEAR(actual.get(i, j), calculated.get(i, j), 1E-9); } } } TEST(Matrix, sum_dimension_error) { Matrix m1({4, 5, 4, 5, 1, 2, 8, 3}, 2, 4); Matrix m2({9, 3, 9, 1, 6, 1, 8, 2}, 4, 2); try { Matrix calculated = m1.plus(m2); FAIL() << "Expected Dimension Error"; } catch(DimensionException& e){ EXPECT_EQ(e.what(),std::string("Dimension Error")); }catch(...){ FAIL() << "Expected Dimension Error"; } }
30.597015
77
0.533659
95ca8f857cc1908926568a8676fa040c1de51f9e
212
cpp
C++
dataStructure/sort/insert.cpp
jinbooooom/coding-for-interview
4164a3c7ddc19a61fa58aebefff29620029ac42c
[ "MIT" ]
8
2019-08-21T10:57:29.000Z
2019-10-14T03:35:22.000Z
dataStructure/sort/insert.cpp
jinbooooom/coding-for-interview
4164a3c7ddc19a61fa58aebefff29620029ac42c
[ "MIT" ]
null
null
null
dataStructure/sort/insert.cpp
jinbooooom/coding-for-interview
4164a3c7ddc19a61fa58aebefff29620029ac42c
[ "MIT" ]
null
null
null
void insert(int *arr, int len) { int i, j, t; for (i = 1; i < len; ++i) // 从第二个数开始(索引1),一共 len - 1 轮 { t = arr[i]; for (j = i - 1; j >= 0 && t < arr[j]; --j) arr[j + 1] = arr[j]; arr[j + 1] = t; } }
19.272727
56
0.419811
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
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
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
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
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
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
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
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
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
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
95e822ec2193ba8a1afeec80b6386bec08906a22
376
cpp
C++
a12H.cpp
asokolsky/oddeven
44563d7efa07539335907dde9e17a9602b3e40fa
[ "BSD-2-Clause" ]
null
null
null
a12H.cpp
asokolsky/oddeven
44563d7efa07539335907dde9e17a9602b3e40fa
[ "BSD-2-Clause" ]
null
null
null
a12H.cpp
asokolsky/oddeven
44563d7efa07539335907dde9e17a9602b3e40fa
[ "BSD-2-Clause" ]
null
null
null
#include <iostream> #include <map> #include <string> #include <set> using namespace std; /** Напишите функцию BuildMapValuesSet, принимающую на вход словарь map<int, string> и возвращающую множество значений этого словаря: */ set <string> BuildMapValuesSet(const map<int, string>& m) { set <string> res; for(auto &elt: m) res.insert(elt.second); return res; }
18.8
129
0.715426
95e9041360dd5f89ac2c62dfce38d6eb5fbeea0b
12,094
cpp
C++
p3/src/org/cracs/stheno/core/p2p/p3/leaf/mesh/P3LeafMesh.cpp
rolandomar/stheno
6b41f56f25be1e7d56c8be4973203bf943e4f041
[ "Apache-2.0" ]
7
2015-08-17T16:24:22.000Z
2022-03-16T15:54:19.000Z
p3/src/org/cracs/stheno/core/p2p/p3/leaf/mesh/P3LeafMesh.cpp
rolandomar/stheno
6b41f56f25be1e7d56c8be4973203bf943e4f041
[ "Apache-2.0" ]
null
null
null
p3/src/org/cracs/stheno/core/p2p/p3/leaf/mesh/P3LeafMesh.cpp
rolandomar/stheno
6b41f56f25be1e7d56c8be4973203bf943e4f041
[ "Apache-2.0" ]
null
null
null
/* * Copyright 2012 Rolando Martins, CRACS & INESC-TEC, DCC/FCUP * * 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. * */ /* * File: P3LeafMesh.cpp * Author: rmartins * * Created on September 15, 2010, 11:44 AM */ #include "P3LeafMesh.h" #include <euryale/common/sleep/IncrementalSleep.h> //#include <stheno/core/p2p/p3/superpeer/cell/discovery/CellDiscovery.h> #include <stheno/core/p2p/p3/leaf/mesh/LeafMeshDiscovery.h> #include <stheno/core/p2p/p3/leaf/mesh/net/P3LeafMeshSap.h> #include <stheno/core/p2p/p3/leaf/mesh/net/LeafClientHandler.h> #include <ace/Sock_Connect.h> #include <ace/Connector.h> #include <stheno/core/p2p/p3/leaf/LeafPeer.h> #include <stheno/core/p2p/p3/mesh/net/P3MeshClientHandler.h> #include <stheno/common/TraceRuntime.h> P3LeafMesh::P3LeafMesh(Overlay* overlay) : Mesh(overlay), m_client(0) { } P3LeafMesh::~P3LeafMesh() { } void P3LeafMesh::open_i(ServiceParamsPtr& params, int fttype) throw (ServiceException&) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T) INFO: P3LeafMesh::open_i(%d)\n"), m_status)); ACE_GUARD(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock); if (isStarting() /*|| isResuming()*/) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T) INFO: P3LeafMesh::open_i starting(%d)\n"), m_status)); //Task::activate(); int maxBindTries = 10000; //IncrementalSleep sleeper(1,0); //IncrementalSleep sleeper(0,1000); IncrementalSleep sleeper(0, DEFAULT_BIND_TIME); m_start = ACE_OS::gettimeofday(); for (int i = 0; i < maxBindTries; i++) { try { bind(true); return; } catch (ServiceException& bindEx) { //discard bindEx sleeper.sleep(); } } ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T) INFO: P3LeafMesh::open(): bind failed\n"))); throw ServiceException(ServiceException::REGISTRATION_ERROR); } else { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T) INFO: P3LeafMesh::open(): error\n"))); throw ServiceException(ServiceException::REGISTRATION_ERROR); } } void P3LeafMesh::close_i() throw (ServiceException&) { } void P3LeafMesh::bind(bool firstTime) throw (ServiceException&) { ACE_GUARD(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock); ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T) INFO: P3LeafMesh::bind():open\n"))); UUIDPtr runtimeUUID; this->getUUID(runtimeUUID); LeafMeshDiscovery* discovery = new LeafMeshDiscovery(runtimeUUID); try { discovery->open(); } catch (CellException& ex) { delete discovery; throw ServiceException("Discovery failed to open!"); } CoordinatorInfo* coordInfo = discovery->requestCoordinator(); if (coordInfo == 0) { delete discovery; throw ServiceException("Error connecting to coordinator!"); } m_coordMeshSAP = coordInfo->getMeshSap(); m_fid = coordInfo->getCellID(); m_coordDiscoverySAP = coordInfo->getDiscoverySap(); m_coordinatorUUID = coordInfo->getPID(); ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T) INFO: P3LeafMesh::bind() - DiscoverySAP=%@\n"), m_coordDiscoverySAP.get())); ACE_Connector<LeafClientHandler, ACE_SOCK_Connector> connector; CellID* cellID = new CellID(*coordInfo->getCellID().get()); CellIDPtr cellIDPtr(cellID); //LeafClientHandler* client = new LeafClientHandler(coordInfo->getPID(), cellIDPtr, this, false, false, 0, 0, 0, 0); ThreadPerConnection *tpc = new ThreadPerConnection(); /*ACE_Strong_Bound_Ptr<ThreadPerConnection, ACE_Recursive_Thread_Mutex>* tpcPrt*/ ExecutionModelPtr* tpcPrt = new ExecutionModelPtr (tpc); LeafClientHandler* client = new LeafClientHandler(coordInfo->getPID(), cellIDPtr, this, false, false, tpcPrt, 0, 0, 0); //tpc->open(); CPUQoS* cpuQoS = new CPUPriorityQoS(CPUQoS::SCHEDULE_RT_DEFAULT, CPUQoS::MAX_RT_PRIO); CPUReservation* reserve = 0; if (getQoSManager() != 0) { reserve = getQoSManager()->createCPUReservation("HRT", cpuQoS); } tpc->bind(client); tpc->open(reserve, cpuQoS); //tpc->bind(client); connector.reactor(tpc->getResources()->getReactor()); ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3LeafMesh - Connecting...(%s) client=%@!\n"), coordInfo->getPID()->toString().c_str(), client)); if (connector.connect(client, coordInfo->getCellCoordinatorEndpoint()->getAddr()) == -1) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)ERROR: P3LeafMesh - Error Connecting...(%s) client=%@!\n"), coordInfo->getPID()->toString().c_str(), client)); perror("P3LeafMesh="); /*ACE_ERROR((LM_ERROR, ACE_TEXT("(%T)%@\n"), ACE_TEXT("(%T)connect failed:")));*/ delete coordInfo; delete client; delete discovery; throw ServiceException("Error connecting to coordinator!"); } else { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3LeafMesh:bind() - Connect OK!\n"))); delete discovery; delete coordInfo; m_client.reset(client); if (m_client->asynchronous(true,false) == -1) { //delete m_client; //m_client = 0; m_client.reset(0); throw ServiceException("Error connecting to coordinator (2)!"); } bool joinRet = client->joinMesh(getOverlay_i()->getType()); //m_client = client; if (m_client->setCloseListener(this) == -1) { //delete m_client; //m_client = 0; m_client.reset(0); throw ServiceException("Error connecting to coordinator (2)!"); } ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3LeafMesh:bind() - join(%d)\n"), joinRet)); } ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3LeafMesh:bind() - join end!\n"))); UUIDPtr fid; this->getFID(fid); TraceRuntimeSingleton::instance()->logBindToMesh(runtimeUUID,fid, m_coordinatorUUID, m_fid); if(firstTime){ ACE_Time_Value end = ACE_OS::gettimeofday(); end -= m_start; TraceRuntimeSingleton::instance()->logMembershipTime(end); }else{ ACE_Time_Value end = ACE_OS::gettimeofday(); end -= m_start; TraceRuntimeSingleton::instance()->logMembershipRebindTime(end); } //CellDiscovery* discovery = new CellDiscovery(this->getUUID()); //discovery->open(); //CellReply* info = discovery->requestCell(CellID::INVALID_CELL_ID_UUIDPTR); } void P3LeafMesh::getSAP(SAPInfoPtr& s) { ACE_GUARD(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock); s = m_sap->getSAPInfo(); } void P3LeafMesh::getCoordinatorDiscoverySAP(SAPInfoPtr& sapInfo) throw (ServiceException&){ ACE_GUARD(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock); sapInfo = m_coordDiscoverySAP; //return true; } void P3LeafMesh::getCoordinatorMeshSAP(SAPInfoPtr& coordSAP) throw (ServiceException&){ ACE_GUARD(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock); coordSAP = m_coordMeshSAP; } void P3LeafMesh::getCoordinatorUUID(UUIDPtr& uuid) throw (ServiceException&){ ACE_GUARD(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock); uuid = m_coordinatorUUID; } void P3LeafMesh::onClose(AbstractStreamChannel<ACE_SOCK_Stream, ACE_MT_SYNCH>* channel) { ACE_GUARD(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock); ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3LeafMesh:onClose() - (%@)\n"), channel)); /*if(m_client != channel){ ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3LeafMesh:onClose() - NOT m_client????????????(%@)\n"),channel)); }*/ channel->setCloseListener(0); m_client.reset(0); //delete channel; //m_client = 0; ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3LeafMesh:onClose() - after delete(%@)\n"), channel)); //m_client = 0; IncrementalSleep sleeper(0, DEFAULT_BIND_TIME); m_start = ACE_OS::gettimeofday(); while (true) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3LeafMesh:onClose() - loop with delete channel of (%@)\n"), channel)); try { bind(); break; } catch (ServiceException& ex) { //retry sleeper.sleep(); } } } LeafPeer* P3LeafMesh::getOverlay_i() { return static_cast<LeafPeer*> (m_overlay); } //opens a channel and tries to allocate a remote service void P3LeafMesh::createRemoteService(const SAPInfo* hint, const UUIDPtr& uuid, const UUIDPtr& sid, ServiceParamsPtr& params, UUIDPtr& iid) throw (ServiceException&) { ACE_GUARD(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock); if (hint == 0) { throw ServiceException(ServiceException::SERVICE_WITHOUT_IMPL); } Endpoint endpoint; ACE_Connector<P3MeshClientHandler, ACE_SOCK_Connector> connector; hint->getFirstEndpoint(endpoint); QoSEndpoint qosE = *(endpoint.getQoS()); UUIDPtr runtimeUUID; getUUID(runtimeUUID); UUIDPtr fid; getFID(fid); P3MeshClientHandler* clientHandler = new P3MeshClientHandler( runtimeUUID, fid, qosE, false, false, 0, 0, 0, 0); if (connector.connect(clientHandler, endpoint.getAddr()) == -1) { ACE_ERROR((LM_ERROR, ACE_TEXT("(%T)%@\n"), ACE_TEXT("(%T)ERROR: P3Mesh::createRemoteService - connect failed:"))); clientHandler->close(); clientHandler = 0; delete clientHandler; } else { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3LeafMesh::createRemoteService - Connect OK!\n"))); } int ret = clientHandler->createService(params, iid); clientHandler->close(); delete clientHandler; if (ret == -1) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3LeafMesh::createRemoteService - failed to create, not enough resources\n"))); throw ServiceException(ServiceException::INSUFFICIENT_RESOURCES); } ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3LeafMesh::createRemoteService - service created!\n"))); } //close local & remote void P3LeafMesh::closeRemoteService(UUIDPtr& uuid, UUIDPtr& sid) throw (ServiceException&) { } QoSResources* P3LeafMesh::calculateQoSResources(ServiceParamsPtr& params) { return 0; } list<EndpointPtr>& P3LeafMesh::getEndpoints() throw (ServiceException&) { throw ServiceException(ServiceException::INVALID_ARGUMENT); } bool P3LeafMesh::updateInfo(InfoUpdatePtr& updateInfoPtr) { /*ACE_GUARD_RETURN(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock, false); if (m_client.null()) { return false; }*/ ACE_GUARD_RETURN(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock,false); LeafClientHandlerPtr clientHandler; getClientHandler(clientHandler); if (clientHandler.null()) { return false; } ace_mon.release(); return clientHandler->updateInfo(updateInfoPtr); } void P3LeafMesh::getUUID(UUIDPtr& uuid) { ACE_GUARD(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock); Mesh::getUUID(uuid); } void P3LeafMesh::getFID(UUIDPtr& fid) throw (ServiceException&) { ACE_GUARD(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock); fid = m_fid; } const char* P3LeafMesh::getName() { return "P3LeafMesh"; } PeerMapPtr& P3LeafMesh::getPeerMap() { return m_peerMap; } void P3LeafMesh::allocateQoS(QoSResources* qos) throw (ServiceException&) { } void P3LeafMesh::onAdd(AbstractStreamChannel<ACE_SOCK_Stream, ACE_MT_SYNCH>* channel) { } void P3LeafMesh::getClientHandler(LeafClientHandlerPtr& clientHandler) { ACE_GUARD(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock); clientHandler = m_client; }
37.559006
166
0.663966
95e986976ea930c1b1553927cad9a42a5c591183
28,297
cpp
C++
pass/bitwidth/pass_bitwidth.cpp
mfkiwl/livehd-fpga
a359adaab7cf2e54f0100a5bb6bf0431cfc8ae7e
[ "BSD-3-Clause" ]
1
2022-03-09T23:29:29.000Z
2022-03-09T23:29:29.000Z
pass/bitwidth/pass_bitwidth.cpp
mfkiwl/livehd-fpga
a359adaab7cf2e54f0100a5bb6bf0431cfc8ae7e
[ "BSD-3-Clause" ]
null
null
null
pass/bitwidth/pass_bitwidth.cpp
mfkiwl/livehd-fpga
a359adaab7cf2e54f0100a5bb6bf0431cfc8ae7e
[ "BSD-3-Clause" ]
null
null
null
// This file is distributed under the BSD 3-Clause License. See LICENSE for details. #include "pass_bitwidth.hpp" #include <algorithm> #include <cmath> #include <vector> #include "bitwidth_range.hpp" #include "lbench.hpp" #include "lgedgeiter.hpp" #include "lgraph.hpp" // Useful for debug //#define PRESERVE_ATTR_NODE static Pass_plugin sample("pass_bitwidth", Pass_bitwidth::setup); void Pass_bitwidth::setup() { Eprp_method m1("pass.bitwidth", "MIT algorithm for bitwidth optimization", &Pass_bitwidth::trans); m1.add_label_optional("max_iterations", "maximum number of iterations to try", "10"); m1.add_label_optional("hier", "hierarchical bitwidth", "false"); register_pass(m1); } Pass_bitwidth::Pass_bitwidth(const Eprp_var &var) : Pass("pass.bitwidth", var) { auto miters = var.get("max_iterations"); auto hier_txt = var.get("hier"); if (hier_txt != "false" && hier_txt != "0") hier = true; else hier = false; bool ok = absl::SimpleAtoi(miters, &max_iterations); if (!ok || max_iterations > 100 || max_iterations <= 0) { error("pass.bitwidth max_iterations:{} should be bigger than zero and less than 100", max_iterations); return; } } void Pass_bitwidth::trans(Eprp_var &var) { Pass_bitwidth p(var); std::vector<const LGraph *> lgs; for (const auto &l : var.lgs) { p.do_trans(l); } } void Pass_bitwidth::do_trans(LGraph *lg) { /* Lbench b("pass.bitwidth"); */ bw_pass(lg); } void Pass_bitwidth::process_const(Node &node) { auto dpin = node.get_driver_pin(); auto it = bwmap.emplace(dpin.get_compact(), Bitwidth_range(node.get_type_const())); forward_adjust_dpin(dpin, it.first->second); } void Pass_bitwidth::process_flop(Node &node) { I(node.has_sink_pin_connected(1)); auto d_dpin = node.get_sink_pin(1).get_driver_pin(); Lconst max_val; Lconst min_val; auto it3 = bwmap.find(d_dpin.get_compact()); if (it3 != bwmap.end()) { max_val = it3->second.get_max(); min_val = it3->second.get_min(); } else if (d_dpin.get_bits()) { Lconst b(1); max_val = b.lsh_op(d_dpin.get_bits()) - 1; } else if (node.get_driver_pin(0).get_bits()) { // At least propagate backward the width if (d_dpin.get_bits()==0 || d_dpin.get_bits() > node.get_driver_pin(0).get_bits()) d_dpin.set_bits(node.get_driver_pin(0).get_bits()); return; } else { if (d_dpin.has_name()) fmt::print("pass.bitwidth flop:{} has input pin:{} unconstrained\n", node.debug_name(), d_dpin.get_name()); else fmt::print("pass.bitwidth flop:{} has some inputs unconstrained\n", node.debug_name()); not_finished = true; return; } bwmap.emplace(node.get_driver_pin(0).get_compact(), Bitwidth_range(min_val, max_val)); } void Pass_bitwidth::process_not(Node &node, XEdge_iterator &inp_edges) { I(inp_edges.size()); // Dangling??? Lconst max_val; Lconst min_val; for (auto e : inp_edges) { auto it3 = bwmap.find(e.driver.get_compact()); if (it3 != bwmap.end()) { if (max_val < it3->second.get_max()) max_val = it3->second.get_max(); if (min_val == 0 || min_val > it3->second.get_min()) min_val = it3->second.get_min(); } else if (e.driver.get_bits()) { Lconst b(1); b = b.lsh_op(e.driver.get_bits()); if (b > max_val) max_val = b; min_val = Lconst(0) - max_val; } else { if (e.driver.has_name()) fmt::print("pass.bitwidth not:{} has input pin:{} unconstrained\n", node.debug_name(), e.driver.get_name()); else fmt::print("pass.bitwidth not:{} has some inputs unconstrained\n", node.debug_name()); not_finished = true; return; } } bwmap.emplace(node.get_driver_pin(0).get_compact(), Bitwidth_range(min_val, max_val)); } void Pass_bitwidth::process_mux(Node &node, XEdge_iterator &inp_edges) { I(inp_edges.size()); // Dangling??? Lconst max_val; Lconst min_val; for (auto e : inp_edges) { if (e.sink.get_pid() == 0) continue; // Skip select auto it = bwmap.find(e.driver.get_compact()); if (it != bwmap.end()) { if (max_val < it->second.get_max()) max_val = it->second.get_max(); if (min_val == 0 || min_val > it->second.get_min()) min_val = it->second.get_min(); } else if (e.driver.get_bits()) { Lconst b(1); b = b.lsh_op(e.driver.get_bits()) - 1; // TODO: sign handling if (b > max_val) max_val = b; min_val = Lconst(0); } else { if (e.driver.has_name()) fmt::print("pass.bitwidth mux:{} has input pin:{} unconstrained\n", node.debug_name(), e.driver.get_name()); else fmt::print("pass.bitwidth mux:{} has some inputs unconstrained\n", node.debug_name()); not_finished = true; return; } } Lconst n_options(inp_edges.size() - 1 - 1); // -1 for log and -1 for the select node.get_sink_pin(0).get_driver_pin().set_bits(n_options.get_bits()); Bitwidth_range bw(min_val, max_val); bwmap.emplace(node.get_driver_pin(0).get_compact(), bw); node.get_driver_pin(0).set_bits(bw.get_bits()); } void Pass_bitwidth::process_shr(Node &node, XEdge_iterator &inp_edges) { I(inp_edges.size() == 2); auto a_dpin = node.get_sink_pin(0).get_driver_pin(); auto n_dpin = node.get_sink_pin(1).get_driver_pin(); auto a_it = bwmap.find(a_dpin.get_compact()); auto n_it = bwmap.find(n_dpin.get_compact()); Bitwidth_range a_bw(0); if (a_it == bwmap.end()) { a_bw = Bitwidth_range(a_dpin.get_bits()); } else { a_bw = a_it->second; } Bitwidth_range n_bw(0); if (n_it == bwmap.end()) { n_bw = Bitwidth_range(n_dpin.get_bits()); } else { n_bw = n_it->second; } if (a_bw.get_bits() == 0 || n_bw.get_bits() == 0) { if (node.get_driver_pin().has_name()) fmt::print("pass.bitwidth shr:{} has input pin:{} unconstrained\n", node.debug_name(), node.get_driver_pin().get_name()); else fmt::print("pass.bitwidth shr:{} has some inputs unconstrained\n", node.debug_name()); return; } if (n_bw.get_min() > 0 && n_bw.get_min().is_i()) { auto max = a_bw.get_max(); auto min = a_bw.get_min(); auto amount = n_bw.get_min().to_i(); max = Lconst(max.get_raw_num() >> amount); min = Lconst(min.get_raw_num() >> amount); Bitwidth_range bw(min, max); bwmap.emplace(node.get_driver_pin().get_compact(), bw); node.get_driver_pin().set_bits(bw.get_bits()); } else { bwmap.emplace(node.get_driver_pin().get_compact(), a_bw); node.get_driver_pin().set_bits(a_bw.get_bits()); } } void Pass_bitwidth::process_sum(Node &node, XEdge_iterator &inp_edges) { I(inp_edges.size()); // Dangling sum??? (delete) Lconst max_val; Lconst min_val; for (auto e : inp_edges) { auto it = bwmap.find(e.driver.get_compact()); if (it != bwmap.end()) { if (e.sink.get_pid() == 0 || e.sink.get_pid() == 1) { max_val = max_val + it->second.get_max(); min_val = min_val + it->second.get_min(); } else { fmt::print("max_val:{}, pmax_val:{}\n", max_val.to_i(), it->second.get_max().to_i()); fmt::print("min_val:{}, pmin_val:{}\n", min_val.to_i(), it->second.get_min().to_i()); max_val = max_val - it->second.get_min(); min_val = min_val - it->second.get_max(); } } else if (e.driver.get_bits()) { Lconst b(1); b = b.lsh_op(e.driver.get_bits()) - 1; //FIXME->sh: Debug on Lconst(0) - Lconst(0xFFFF) = 0 ?? max_val = max_val + b; min_val = min_val + b; #if 0 if (e.sink.get_pid() == 0 || e.sink.get_pid() == 1) { max_val = max_val + b; min_val = min_val + b; } else { max_val = max_val - b; min_val = min_val - b; } #endif } else { if (e.driver.has_name()) fmt::print("pass.bitwidth sum:{} has input pin:{} unconstrained\n", node.debug_name(), e.driver.get_name()); else fmt::print("pass.bitwidth sum:{} has some inputs unconstrained\n", node.debug_name()); not_finished = true; return; } } bwmap.emplace(node.get_driver_pin(0).get_compact(), Bitwidth_range(min_val, max_val)); } void Pass_bitwidth::process_pick(Node &node) { auto data_dpin = node.get_sink_pin(0).get_driver_pin(); auto out_dpin = node.get_driver_pin(); auto it3 = bwmap.find(data_dpin.get_compact()); Bitwidth_range bw(out_dpin.get_bits()); if (it3 != bwmap.end()) { bw = it3->second; } else if (data_dpin.get_bits()) { bw = Bitwidth_range(data_dpin.get_bits()); } if (bw.get_bits() <= out_dpin.get_bits()) { bwmap.emplace(node.get_driver_pin(0).get_compact(), bw); } else { bwmap.emplace(node.get_driver_pin(0).get_compact(), Bitwidth_range(out_dpin.get_bits())); } } void Pass_bitwidth::process_comparator(Node &node) { bwmap.emplace(node.get_driver_pin(0).get_compact(), Bitwidth_range(1)); } void Pass_bitwidth::process_logic(Node &node, XEdge_iterator &inp_edges) { bool is_logic_op = node.has_driver_pin_connected(0); bool is_logic_reduction = node.has_driver_pin_connected(1); if (is_logic_reduction) { bwmap.emplace(node.get_driver_pin(1).get_compact(), Bitwidth_range(1)); } if (is_logic_op && inp_edges.size() >= 1) { Bits_t max_bits = 0; for (auto e : inp_edges) { auto it = bwmap.find(e.driver.get_compact()); Bits_t bits = 0; if (it == bwmap.end()) { bits = e.driver.get_bits(); } else { bits = it->second.get_bits(); } if (bits == 0) { if (e.driver.has_name()) { fmt::print("pass.bitwidth gate:{} has input pin:{} unconstrained\n", node.debug_name(), e.driver.get_name()); } else { fmt::print("pass.bitwidth gate:{} has some inputs unconstrained\n", node.debug_name()); } not_finished = true; return; } if (bits > max_bits) max_bits = bits; } bwmap.emplace(node.get_driver_pin(0).get_compact(), Bitwidth_range(max_bits)); } } void Pass_bitwidth::process_logic_and(Node &node, XEdge_iterator &inp_edges) { bool logic_op = node.has_driver_pin_connected(0); bool logic_reduction = node.has_driver_pin_connected(1); if (logic_reduction) { bwmap.emplace(node.get_driver_pin(1).get_compact(), Bitwidth_range(1)); } // determine the min_bits among all inp_edges if (logic_op && inp_edges.size() >= 1) { Bits_t min_bits = UINT16_MAX; for (auto e : inp_edges) { auto pit = bwmap.find(e.driver.get_compact()); Bits_t bits = 0; if (pit == bwmap.end()) { bits = e.driver.get_bits(); } else { bits = pit->second.get_bits(); } if (bits && bits < min_bits) min_bits = bits; } if (min_bits == UINT16_MAX) { fmt::print("pass.bitwidth and:{} does not have any constrained input\n", node.debug_name()); not_finished = true; return; } bwmap.emplace(node.get_driver_pin(0).get_compact(), Bitwidth_range(min_bits)); for (auto e : inp_edges) { auto bits = e.driver.get_bits(); if (bits) continue; // only handle unconstrained inputs if (e.driver.get_num_edges() > 1) { must_perform_backward = true; } else if (bits==0 || bits > min_bits) { // no other output, parent could follow the child e.driver.set_bits(min_bits); } } } } Pass_bitwidth::Attr Pass_bitwidth::get_key_attr(std::string_view key) { if (key.substr(0, 6) == "__bits") return Attr::Set_bits; if (key.substr(0, 5) == "__max") return Attr::Set_max; if (key.substr(0, 5) == "__min") return Attr::Set_min; if (key.substr(0, 11) == "__dp_assign") return Attr::Set_dp_assign; return Attr::Set_other; } void Pass_bitwidth::process_attr_get(Node &node) { I(node.has_sink_pin_connected(1)); auto dpin_key = node.get_sink_pin(1).get_driver_pin(); I(dpin_key.get_node().is_type(TupKey_Op)); auto key = dpin_key.get_name(); auto attr = get_key_attr(key); I(attr != Attr::Set_dp_assign); // Not get attr with __dp_assign if (attr == Attr::Set_other) { not_finished = true; return; } I(node.has_sink_pin_connected(0)); auto dpin_val = node.get_sink_pin(0).get_driver_pin(); auto it = bwmap.find(dpin_val.get_compact()); if (it == bwmap.end()) { not_finished = true; return; } auto &bw = it->second; Lconst result; if (attr == Attr::Set_bits) { result = Lconst(bw.get_bits()); } else if (attr == Attr::Set_max) { result = bw.get_max(); } else if (attr == Attr::Set_min) { result = bw.get_min(); } fmt::print("attr_get key:{} dpin0:{} const:{} node:{}\n", key, dpin_val.debug_name(), result.to_pyrope(), node.debug_name()); auto new_node = node.get_class_lgraph()->create_node_const(result); auto new_dpin = new_node.get_driver_pin(); for (auto &out : node.out_edges()) { new_dpin.connect_sink(out.sink); } //#ifndef PRESERVE_ATTR_NODE if (!hier) // FIXME: once hier del works node.del_node(); //#endif } void Pass_bitwidth::process_attr_set_dp_assign(Node &node) { auto dpin_variable = node.get_sink_pin(2).get_driver_pin(); auto dpin_value = node.get_sink_pin(0).get_driver_pin(); auto dpin_output = node.get_driver_pin(0); auto it = bwmap.find(dpin_variable.get_compact()); Bitwidth_range bw_variable(0); if (it != bwmap.end()) { bw_variable = it->second; } else if (dpin_variable.get_bits()) { bw_variable = Bitwidth_range(dpin_variable.get_bits()); } else { if (dpin_output.has_name()) fmt::print("pass.bitwidth {}:= is unconstrained\n", dpin_output.get_name()); else fmt::print("pass.bitwidth := is unconstrained (node:{})\n", node.debug_name()); return; } auto it2 = bwmap.find(dpin_value.get_compact()); Bitwidth_range bw_value(0); if (it2 != bwmap.end()) { bw_value = it2->second; } else if (dpin_variable.get_bits()) { bw_value = Bitwidth_range(dpin_value.get_bits()); } else { if (dpin_output.has_name()) fmt::print("pass.bitwidth {}:= node:{} is unconstrained\n", dpin_output.get_name(), dpin_variable.debug_name()); else fmt::print("pass.bitwidth := node:{} is unconstrained (node:{})\n", dpin_variable.debug_name(), node.debug_name()); return; } // fmt::print("attr_set_dp_assign name:{} variable_bits:{} bw_value:{} node:{}\n", dpin_variable.debug_name(), // bw_variable.get_bits(), bw_value.get_bits(), node.debug_name()); if (bw_value.get_bits() == 0 && bw_variable.get_bits() == 0) { // Can not solve now if (dpin_output.has_name()) fmt::print("pass.bitwidth {}:= is unconstrained\n", dpin_output.get_name()); else fmt::print("pass.bitwidth := is unconstrained (node:{})\n", node.debug_name()); return; } else { if (bw_value.get_bits() == 0) { fmt::print("pass.bitwidth := propagating bits:{} upwards to node:{}\n", bw_variable.get_bits(), dpin_value.debug_name()); dpin_value.set_bits(bw_variable.get_bits()); bwmap.emplace(dpin_value.get_compact(), bw_variable); return; } if (bw_variable.get_bits() == 0) { if (dpin_output.has_name()) fmt::print("pass.bitwidth {}:= is unconstrained\n", dpin_output.get_name()); else fmt::print("pass.bitwidth := is unconstrained (node:{})\n", node.debug_name()); return; } if (bw_value.get_bits() <= bw_variable.get_bits()) { // Already match for (auto e : node.out_edges()) { dpin_value.connect_sink(e.sink); } } else { // rhs.bits > lhs.bits --> drop rhs bits and reconnect auto new_node = node.get_class_lgraph()->create_node(Pick_Op); auto zero_node = node.get_class_lgraph()->create_node_const(Lconst(0)); auto zero_dpin = zero_node.setup_driver_pin(); auto new_dpin = new_node.get_driver_pin(); new_dpin.set_bits(bw_variable.get_bits()); dpin_value.connect_sink(new_node.setup_sink_pin(0)); zero_dpin.connect_sink(new_node.setup_sink_pin(1)); for (auto e : node.out_edges()) { new_dpin.connect_sink(e.sink); } } } if (!hier) // FIXME: once hier del works node.del_node(); fmt::print("DBG: delete dp_assign\n"); } void Pass_bitwidth::process_attr_set_new_attr(Node &node) { I(node.has_sink_pin_connected(1)); auto dpin_key = node.get_sink_pin(1).get_driver_pin(); auto key = dpin_key.get_name(); auto attr = get_key_attr(key); if (attr == Attr::Set_other) { not_finished = true; return; } if (attr == Attr::Set_dp_assign) { process_attr_set_dp_assign(node); return; } I(node.has_sink_pin_connected(2)); auto dpin_val = node.get_sink_pin(2).get_driver_pin(); if (!dpin_key.get_node().is_type(TupKey_Op)) { not_finished = true; return; // Can not handle now } I(dpin_key.has_name()); auto attr_dpin = node.get_driver_pin(0); std::string_view dpin_name; if (attr_dpin.has_name()) dpin_name = attr_dpin.get_name(); // copy parent's bw for some judgement and then update to attr_set value Bitwidth_range bw(0); bool parent_pending = false; if (node.has_sink_pin_connected(0)) { auto through_dpin = node.get_sink_pin(0).get_driver_pin(); auto it = bwmap.find(through_dpin.get_compact()); if (it != bwmap.end()) { bw = it->second; } else { parent_pending = true; } } // fmt::print("attr_set_new name:{} key:{} bw_bits:{} node:{}\n", dpin_name, key, bw.get_bits(), node.debug_name()); if (attr == Attr::Set_bits) { I(dpin_val.get_node().is_type_const()); auto val = dpin_val.get_node().get_type_const(); if (bw.get_bits() && bw.get_bits() > val.to_i()) { Pass::error("bitwidth missmatch. Variable {} needs {}bits, but constrained to {}bits\n", dpin_name, bw.get_bits(), val.to_i()); } else { if (bw.is_always_positive()) bw.set_ubits(val.to_i()); else bw.set_sbits(val.to_i()); } } else if (attr == Attr::Set_max) { I(false); // FIXME: todo } else if (attr == Attr::Set_min) { I(false); // FIXME: todo } else { I(false); // Attr::Set_dp_assign handled in another method } for (auto out_dpin : node.out_connected_pins()) { out_dpin.set_bits(bw.get_bits()); bwmap.emplace(out_dpin.get_compact(), bw); } // upwards propagate for one step node if (parent_pending) { auto through_dpin = node.get_sink_pin(0).get_driver_pin(); through_dpin.set_bits(bw.get_bits()); bwmap.emplace(through_dpin.get_compact(), bw); } // dpin_val.dump_all_prp_vname(); } void Pass_bitwidth::process_attr_set_propagate(Node &node) { auto attr_dpin = node.get_driver_pin(0); std::string_view dpin_name; if (attr_dpin.has_name()) dpin_name = attr_dpin.get_name(); I(node.has_sink_pin_connected(0)); bool parent_data_pending = false; auto data_dpin = node.get_sink_pin(0).get_driver_pin(); I(node.has_sink_pin_connected(3)); auto parent_attr_dpin = node.get_sink_pin(3).get_driver_pin(); Bitwidth_range data_bw(0); auto data_it = bwmap.find(data_dpin.get_compact()); if (data_it != bwmap.end()) { data_bw = data_it->second; } else { parent_data_pending = true; } /* if (data_it == bwmap.end()) { */ /* fmt::print("attr_set propagate bwmap to AttrSet name:{}\n", dpin_name); */ /* not_finished = true; */ /* return; */ /* } */ /* auto &data_bw = data_it->second; */ auto parent_attr_it = bwmap.find(parent_attr_dpin.get_compact()); if (parent_attr_it == bwmap.end()) { fmt::print("attr_set propagate bwmap to AttrSet name:{}\n", dpin_name); not_finished = true; return; } const auto parent_attr_bw = parent_attr_it->second; fmt::print("attr_set_prop name:{} parent_attr.bits:{} data_bw.bits:{}\n", dpin_name, parent_attr_bw.get_bits(), data_bw.get_bits()); if (parent_attr_bw.get_bits() && data_bw.get_bits()) { if (parent_attr_bw.get_bits() < data_bw.get_bits()) { Pass::error("bitwidth missmatch. Variable {} needs {}bits, but constrained to {}bits\n", dpin_name, data_bw.get_bits(), parent_attr_bw.get_bits()); } else if (parent_attr_bw.get_max() < data_bw.get_max()) { Pass::error("bitwidth missmatch. Variable {} needs {}max, but constrained to {}max\n", dpin_name, data_bw.get_max().to_pyrope(), parent_attr_bw.get_max().to_pyrope()); } else if (parent_attr_bw.get_min() > data_bw.get_min()) { Pass::error("bitwidth missmatch. Variable {} needs {}min, but constrained to {}min\n", dpin_name, data_bw.get_min().to_pyrope(), parent_attr_bw.get_min().to_pyrope()); } } for (auto out_dpin : node.out_connected_pins()) { out_dpin.set_bits(parent_attr_bw.get_bits()); bwmap.emplace(out_dpin.get_compact(), parent_attr_bw); } if (parent_data_pending) { data_dpin.set_bits(parent_attr_bw.get_bits()); fmt::print("data_dpin:{}\n", data_dpin.debug_name()); fmt::print("data_dpin bits:{}\n", data_dpin.get_bits()); bwmap.emplace(data_dpin.get_compact(), parent_attr_bw); } } void Pass_bitwidth::process_attr_set(Node &node) { if (node.has_sink_pin_connected(1)) { process_attr_set_new_attr(node); } else { process_attr_set_propagate(node); } } // focusing on judging the parent is garbage or not void Pass_bitwidth::garbage_collect_support_structures(XEdge_iterator &inp_edges) { for (auto e : inp_edges) { auto pit = outcountmap.find(e.driver.get_node().get_compact()); // pit = parent iterator if (pit == outcountmap.end()) { continue; // parent node not yet visited } auto n = pit->second; if (n <= 1) { // I'm the only child, the parent bw_range object could be recycled outcountmap.erase(pit); for (auto parent_dpin : e.driver.get_node().out_connected_pins()) { auto it2 = bwmap.find(parent_dpin.get_compact()); if (it2 != bwmap.end()) { // Not all the nodes create bwmap (impossible to infer do not) forward_adjust_dpin(parent_dpin, it2->second); bwmap.erase(it2); } } } else { pit->second = n - 1; } } } void Pass_bitwidth::forward_adjust_dpin(Node_pin &dpin, Bitwidth_range &bw) { auto bw_bits = bw.get_bits(); if (bw_bits && bw_bits < dpin.get_bits()) { // fmt::print("bitwidth: bits:{}->{} for dpin:{}\n", dpin.get_bits(), bw_bits, dpin.debug_name()); dpin.set_bits(bw_bits); } } void Pass_bitwidth::set_graph_boundary(Node_pin &dpin, Node_pin &spin) { I(hier); // do not call unless hierarchy is set if (dpin.get_class_lgraph() == spin.get_class_lgraph()) return; I(dpin.get_hidx() != spin.get_hidx()); auto same_level_spin = spin.get_non_hierarchical(); for (auto dpin_sub:same_level_spin.inp_driver()) { if (!dpin_sub.get_node().is_type(SubGraph_Op)) continue; if (dpin_sub.get_bits()==0 || dpin_sub.get_bits() > dpin.get_bits()) dpin_sub.set_bits(dpin.get_bits()); } } void Pass_bitwidth::bw_pass(LGraph *lg) { must_perform_backward = false; not_finished = false; for(auto dpin:lg->get_graph_input_node(hier).out_setup_pins()) { if (dpin.get_bits()) bwmap.emplace(dpin.get_compact(), Bitwidth_range(dpin.get_bits())); } outcountmap[lg->get_graph_input_node(hier).get_compact()] = lg->get_graph_input_node(hier).get_num_out_edges(); for (auto node : lg->forward(hier)) { auto inp_edges = node.inp_edges(); auto op = node.get_type_op(); //fmt::print("bitwidth node:{} lg:{}\n", node.debug_name(), node.get_class_lgraph()->get_name()); if (inp_edges.empty() && (op != Const_Op && op != SubGraph_Op && op != LUT_Op && op != TupKey_Op)) { fmt::print("pass.bitwidth: removing dangling node:{}\n", node.debug_name()); fmt::print("node:{}\n", node.debug_name()); if (!hier) // FIXME: once hier del works node.del_node(); continue; } outcountmap[node.get_compact()] = node.get_num_out_edges(); if (op == Const_Op) { process_const(node); } else if (op == TupKey_Op || op == TupGet_Op || op == TupAdd_Op) { // Nothing to do for this } else if (op == Or_Op || op == Xor_Op) { process_logic(node, inp_edges); } else if (op == And_Op) { process_logic_and(node, inp_edges); } else if (op == AttrSet_Op) { process_attr_set(node); if (node.is_invalid()) continue; } else if (op == AttrGet_Op) { process_attr_get(node); if (node.is_invalid()) continue; } else if (op == Sum_Op) { process_sum(node, inp_edges); } else if (op == ShiftRight_Op) { process_shr(node, inp_edges); } else if (op == Not_Op) { process_not(node, inp_edges); } else if (op == SFlop_Op || op == AFlop_Op || op == FFlop_Op) { process_flop(node); } else if (op == Mux_Op) { process_mux(node, inp_edges); } else if (op == GreaterThan_Op || op == LessThan_Op || op == LessEqualThan_Op || op == Equals_Op || op == GreaterEqualThan_Op) { process_comparator(node); } else if (op == Pick_Op) { process_pick(node); } else { fmt::print("FIXME: node:{} still not handled by bitwidth\n", node.debug_name()); } if (hier) { for (auto e:inp_edges) { set_graph_boundary(e.driver, e.sink); } } for (auto dpin : node.out_connected_pins()) { auto it = bwmap.find(dpin.get_compact()); if (it == bwmap.end()) continue; auto bw_bits = it->second.get_bits(); if (bw_bits == 0 && it->second.is_overflow()) { fmt::print("bitwidth: dpin:{} has over {}bits (simplify first!)\n", dpin.debug_name(), it->second.get_raw_max()); continue; } if (dpin.get_bits() && dpin.get_bits() >= bw_bits) continue; dpin.set_bits(bw_bits); } garbage_collect_support_structures(inp_edges); } for(auto dpin:lg->get_graph_output_node(hier).out_setup_pins()) { auto spin = dpin.get_sink_from_output(); if (!spin.has_inputs()) continue; auto out_driver = spin.get_driver_pin(); I(!out_driver.is_invalid()); auto it = bwmap.find(out_driver.get_compact()); if (it != bwmap.end()) { forward_adjust_dpin(out_driver, it->second); bwmap.erase(it); } if (out_driver.get_bits()) { dpin.set_bits(out_driver.get_bits()); if (hier) set_graph_boundary(out_driver, spin); } /* if (out_driver.get_bits()) { */ /* if (dpin.get_bits()) { // output has been attr set bits */ /* if (dpin.get_bits() > out_driver.get_bits()) { */ /* return; */ /* } */ /* } */ /* dpin.set_bits(out_driver.get_bits()); */ /* } */ } #ifndef PRESERVE_ATTR_NODE if (not_finished) { fmt::print("pass_bitwidth: could not converge\n"); } else { // FIXME: this code may need to move to cprop if we have several types of // attributes. Delete only if all the attributes are finished // // Delete all the attr_set/get for bitwidth for (auto node : lg->fast()) { auto op = node.get_type_op(); if (op == AttrSet_Op) { if (node.has_sink_pin_connected(1)) { auto key_dpin = node.get_sink_pin(1).get_driver_pin(); auto attr = get_key_attr(key_dpin.get_name()); if (attr == Attr::Set_other) continue; } if (node.has_sink_pin_connected(0)) { auto data_dpin = node.get_sink_pin(0).get_driver_pin(); for (auto e : node.out_edges()) { if (e.driver.get_pid() == 0) { e.sink.connect_driver(data_dpin); } } } if (!hier) // FIXME: once hier del works node.del_node(); } else if (op == AttrGet_Op) { I(false); // should be deleted by now if solved } } } #endif if (must_perform_backward) { fmt::print("pass_bitwidth: some nodes need to back propagate width\n"); } }
32.228929
127
0.627699
95eb334cf721182b79ae1a9102b49ddcbb973767
10,292
cpp
C++
newton-4.00/applications/ndSandbox/demos/ndBasicStacks.cpp
Libertus-Lab/newton-dynamics
af6e6635c7f563c697b8e5b088d68ba24fa8fe9c
[ "Zlib" ]
null
null
null
newton-4.00/applications/ndSandbox/demos/ndBasicStacks.cpp
Libertus-Lab/newton-dynamics
af6e6635c7f563c697b8e5b088d68ba24fa8fe9c
[ "Zlib" ]
null
null
null
newton-4.00/applications/ndSandbox/demos/ndBasicStacks.cpp
Libertus-Lab/newton-dynamics
af6e6635c7f563c697b8e5b088d68ba24fa8fe9c
[ "Zlib" ]
null
null
null
/* Copyright (c) <2003-2021> <Newton Game Dynamics> * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely */ #include "ndSandboxStdafx.h" #include "ndSkyBox.h" #include "ndTargaToOpenGl.h" #include "ndDemoMesh.h" #include "ndDemoCamera.h" #include "ndPhysicsUtils.h" #include "ndPhysicsWorld.h" #include "ndMakeStaticMap.h" #include "ndDemoEntityManager.h" #include "ndDemoInstanceEntity.h" static ndBodyDynamic* AddRigidBody(ndDemoEntityManager* const scene, const ndMatrix& matrix, const ndShapeInstance& shape, ndDemoInstanceEntity* const rootEntity, ndFloat32 mass) { ndBodyDynamic* const body = new ndBodyDynamic(); ndDemoEntity* const entity = new ndDemoEntity(matrix, rootEntity); body->SetNotifyCallback(new ndDemoEntityNotify(scene, entity)); body->SetMatrix(matrix); body->SetCollisionShape(shape); body->SetMassMatrix(mass, shape); ndWorld* const world = scene->GetWorld(); world->AddBody(body); return body; } static void BuildSphereColumn(ndDemoEntityManager* const scene, ndFloat32 mass, const ndVector& origin, const ndVector& size, ndInt32 count) { // build a standard block stack of 20 * 3 boxes for a total of 60 ndWorld* const world = scene->GetWorld(); ndVector blockBoxSize(size); // create the stack ndMatrix baseMatrix(dGetIdentityMatrix()); // for the elevation of the floor at the stack position baseMatrix.m_posit.m_x = origin.m_x; baseMatrix.m_posit.m_z = origin.m_z; ndVector floor(FindFloor(*world, baseMatrix.m_posit + ndVector(0.0f, 100.0f, 0.0f, 0.0f), 200.0f)); baseMatrix.m_posit.m_y = floor.m_y + blockBoxSize.m_x; ndShapeInstance shape(new ndShapeSphere(blockBoxSize.m_x)); ndDemoMeshIntance* const geometry = new ndDemoMeshIntance("shape", scene->GetShaderCache(), &shape, "earthmap.tga", "earthmap.tga", "earthmap.tga", 1.0f, dRollMatrix (ndFloat32 (-90.0f) * ndDegreeToRad)); ndDemoInstanceEntity* const rootEntity = new ndDemoInstanceEntity(geometry); scene->AddEntity(rootEntity); for (ndInt32 i = 0; i < count; i++) { AddRigidBody(scene, baseMatrix, shape, rootEntity, mass); baseMatrix.m_posit += baseMatrix.m_up.Scale(blockBoxSize.m_x * 2.0f); } geometry->Release(); } static void BuildBoxColumn(ndDemoEntityManager* const scene, ndFloat32 mass, const ndVector& origin, const ndVector& size, ndInt32 count) { // build a standard block stack of 20 * 3 boxes for a total of 60 ndWorld* const world = scene->GetWorld(); ndVector blockBoxSize(size); blockBoxSize = blockBoxSize.Scale(2.0f); // create the stack ndMatrix baseMatrix(dGetIdentityMatrix()); // for the elevation of the floor at the stack position baseMatrix.m_posit.m_x = origin.m_x; baseMatrix.m_posit.m_z = origin.m_z; ndVector floor(FindFloor(*world, baseMatrix.m_posit + ndVector(0.0f, 100.0f, 0.0f, 0.0f), 200.0f)); baseMatrix.m_posit.m_y = floor.m_y + blockBoxSize.m_y * 0.5f; ndShapeInstance shape(new ndShapeBox(blockBoxSize.m_x, blockBoxSize.m_y, blockBoxSize.m_z)); ndDemoMeshIntance* const geometry = new ndDemoMeshIntance("shape", scene->GetShaderCache(), &shape, "wood_0.tga", "wood_0.tga", "wood_0.tga"); ndDemoInstanceEntity* const rootEntity = new ndDemoInstanceEntity(geometry); scene->AddEntity(rootEntity); //baseMatrix.m_posit.m_y -= 0.02f; ndMatrix rotation(dYawMatrix(20.0f * ndDegreeToRad)); for (ndInt32 i = 0; i < count; i++) { AddRigidBody(scene, baseMatrix, shape, rootEntity, mass); baseMatrix.m_posit += baseMatrix.m_up.Scale(blockBoxSize.m_x); baseMatrix = rotation * baseMatrix; } geometry->Release(); } static void BuildCylinderColumn(ndDemoEntityManager* const scene, ndFloat32 mass, const ndVector& origin, const ndVector& size, ndInt32 count) { // build a standard block stack of 20 * 3 boxes for a total of 60 ndWorld* const world = scene->GetWorld(); ndVector blockBoxSize(size); // create the stack ndMatrix baseMatrix(dGetIdentityMatrix()); // for the elevation of the floor at the stack position baseMatrix.m_posit.m_x = origin.m_x; baseMatrix.m_posit.m_z = origin.m_z; ndVector floor(FindFloor(*world, baseMatrix.m_posit + ndVector(0.0f, 100.0f, 0.0f, 0.0f), 200.0f)); baseMatrix.m_posit.m_y = floor.m_y + blockBoxSize.m_z * 0.5f; ndShapeInstance shape(new ndShapeCylinder(blockBoxSize.m_x, blockBoxSize.m_y, blockBoxSize.m_z)); shape.SetLocalMatrix(dRollMatrix(ndPi * 0.5f)); ndDemoMeshIntance* const geometry = new ndDemoMeshIntance("shape", scene->GetShaderCache(), &shape, "wood_0.tga", "wood_0.tga", "wood_0.tga"); ndDemoInstanceEntity* const rootEntity = new ndDemoInstanceEntity(geometry); scene->AddEntity(rootEntity); ndMatrix rotation(dYawMatrix(20.0f * ndDegreeToRad)); for (ndInt32 i = 0; i < count; i++) { AddRigidBody(scene, baseMatrix, shape, rootEntity, mass); baseMatrix.m_posit += baseMatrix.m_up.Scale(blockBoxSize.m_z); baseMatrix = rotation * baseMatrix; } geometry->Release(); } static void BuildPyramid(ndDemoEntityManager* const scene, ndDemoInstanceEntity* const rootEntity, const ndShapeInstance& shape, ndFloat32 mass, const ndVector& origin, const ndVector& boxSize, ndInt32 count) { ndMatrix matrix(dGetIdentityMatrix()); matrix.m_posit = origin; matrix.m_posit.m_w = 1.0f; // create the shape and visual mesh as a common data to be re used ndWorld* const world = scene->GetWorld(); ndVector floor(FindFloor(*world, origin + ndVector(0.0f, 100.0f, 0.0f, 0.0f), 200.0f)); matrix.m_posit.m_y = floor.m_y; ndFloat32 stepz = boxSize.m_z + 1.0e-2f; ndFloat32 stepy = boxSize.m_y + 1.0e-2f; stepy = boxSize.m_y; ndFloat32 y0 = matrix.m_posit.m_y + stepy / 2.0f; ndFloat32 z0 = matrix.m_posit.m_z - stepz * count / 2; matrix.m_posit.m_y = y0; matrix.m_posit.m_y -= 0.01f; for (ndInt32 j = 0; j < count; j++) { matrix.m_posit.m_z = z0; for (ndInt32 i = 0; i < (count - j); i++) { AddRigidBody(scene, matrix, shape, rootEntity, mass); matrix.m_posit.m_z += stepz; } z0 += stepz * 0.5f; matrix.m_posit.m_y += stepy; } } void BuildPyramidStacks(ndDemoEntityManager* const scene, ndFloat32 mass, const ndVector& origin, const ndVector& boxSize, ndInt32 stackHigh) { ndVector origin1(origin); ndVector size(boxSize.Scale(1.0f)); ndShapeInstance shape(new ndShapeBox(size.m_x, size.m_y, size.m_z)); ndDemoMeshIntance* const geometry = new ndDemoMeshIntance("shape", scene->GetShaderCache(), &shape, "wood_0.tga", "wood_0.tga", "wood_0.tga"); ndDemoInstanceEntity* const rootEntity = new ndDemoInstanceEntity(geometry); scene->AddEntity(rootEntity); origin1.m_z = 0.0f; origin1.m_x += 3.0f; BuildPyramid(scene, rootEntity, shape, mass, origin1, boxSize, stackHigh); geometry->Release(); } static void BuildCapsuleStack(ndDemoEntityManager* const scene, ndFloat32 mass, const ndVector& origin, const ndVector& size, ndInt32 stackHigh) { // build a standard block stack of 20 * 3 boxes for a total of 60 ndWorld* const world = scene->GetWorld(); ndVector blockBoxSize(size); // create the stack ndMatrix baseMatrix(dGetIdentityMatrix()); // for the elevation of the floor at the stack position baseMatrix.m_posit.m_x = origin.m_x; baseMatrix.m_posit.m_z = origin.m_z; ndFloat32 startElevation = 100.0f; ndVector floor(FindFloor(*world, ndVector(baseMatrix.m_posit.m_x, startElevation, baseMatrix.m_posit.m_z, 0.0f), 2.0f * startElevation)); baseMatrix.m_posit.m_y = floor.m_y + blockBoxSize.m_y; // create the shape and visual mesh as a common data to be re used ndShapeInstance collision(new ndShapeCapsule(blockBoxSize.m_x, blockBoxSize.m_x, blockBoxSize.m_z)); ndMatrix uvMatrix(dPitchMatrix(ndPi)); ndDemoMeshIntance* const geometry = new ndDemoMeshIntance("shape", scene->GetShaderCache(), &collision, "smilli.tga", "smilli.tga", "smilli.tga"); ndFloat32 vertialStep = blockBoxSize.m_x * 2.0f; ndFloat32 horizontalStep = blockBoxSize.m_z * 0.8f; ndMatrix matrix0(dGetIdentityMatrix()); matrix0.m_posit = origin; matrix0.m_posit.m_y += blockBoxSize.m_x; matrix0.m_posit.m_w = 1.0f; ndMatrix matrix1(matrix0); matrix1.m_posit.m_z += horizontalStep; ndMatrix matrix2(dYawMatrix(ndPi * 0.5f) * matrix0); matrix2.m_posit.m_x += horizontalStep * 0.5f; matrix2.m_posit.m_z += horizontalStep * 0.5f; matrix2.m_posit.m_y += vertialStep; ndMatrix matrix3(matrix2); matrix3.m_posit.m_x -= horizontalStep; ndDemoInstanceEntity* const rootEntity = new ndDemoInstanceEntity(geometry); scene->AddEntity(rootEntity); for (ndInt32 i = 0; i < stackHigh / 2; i++) { AddRigidBody(scene, matrix0, collision, rootEntity, mass); AddRigidBody(scene, matrix1, collision, rootEntity, mass); AddRigidBody(scene, matrix2, collision, rootEntity, mass); AddRigidBody(scene, matrix3, collision, rootEntity, mass); matrix0.m_posit.m_y += vertialStep * 2.0f; matrix1.m_posit.m_y += vertialStep * 2.0f; matrix2.m_posit.m_y += vertialStep * 2.0f; matrix3.m_posit.m_y += vertialStep * 2.0f; } // do not forget to release the assets geometry->Release(); } void ndBasicStacks (ndDemoEntityManager* const scene) { // build a floor BuildFlatPlane(scene, true); ndVector origin(ndVector::m_zero); //ndInt32 pyramidHigh = 20; ndInt32 pyramidHigh = 30; //ndInt32 pyramidHigh = 60; for (ndInt32 i = 0; i < 4; i++) { BuildPyramidStacks(scene, 1.0f, origin, ndVector(0.5f, 0.25f, 0.8f, 0.0f), pyramidHigh); origin.m_x += 4.0f; } origin = ndVector::m_zero; origin.m_x -= 2.0f; origin.m_z -= 3.0f; BuildSphereColumn(scene, 10.0f, origin, ndVector(0.5f, 0.5f, 0.5f, 0.0f), 20); origin.m_z += 6.0f; BuildBoxColumn(scene, 10.0f, origin, ndVector(0.5f, 0.5f, 0.5f, 0.0f), 20); origin.m_z += 6.0f; BuildCylinderColumn(scene, 10.0f, origin, ndVector(0.75f, 0.6f, 1.0f, 0.0f), 20); origin.m_x -= 6.0f; origin.m_z -= 6.0f; BuildCapsuleStack(scene, 10.0f, origin, ndVector(0.25f, 0.25f, 2.0f, 0.0f), 20); ndQuaternion rot(dYawMatrix (45.0f * ndDegreeToRad)); origin = ndVector::m_zero; origin.m_x -= 3.0f; origin.m_y += 5.0f; origin.m_x -= 15.0f; origin.m_z += 15.0f; scene->SetCameraMatrix(rot, origin); }
34.192691
205
0.735717
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
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
95ee1c3d622ff6dcfa592566fe594b9f5361bf48
359
cpp
C++
example/shm_status.cpp
unhuman-io/motor-realtime
1aee682954096c28c9a3f01546261499052c4e0b
[ "Unlicense" ]
null
null
null
example/shm_status.cpp
unhuman-io/motor-realtime
1aee682954096c28c9a3f01546261499052c4e0b
[ "Unlicense" ]
null
null
null
example/shm_status.cpp
unhuman-io/motor-realtime
1aee682954096c28c9a3f01546261499052c4e0b
[ "Unlicense" ]
1
2021-04-05T18:14:51.000Z
2021-04-05T18:14:51.000Z
#include <motor_manager.h> #include <thread> #include <motor_subscriber.h> int main() { MotorSubscriber<MotorStatus> sub; while(1) { MotorStatus status = sub.read(); std::vector<MotorStatus> statuses(1, status); std::cout << statuses << std::endl; std::this_thread::sleep_for(std::chrono::milliseconds(100)); } }
23.933333
68
0.635097
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
95f2057d92060a6141b994aa38b25df57f1633d8
450
cpp
C++
Project/Zombienator/Layer.cpp
Jallah123/TheZombienator
efbcb93b0b2943cd9b38ac84fe8a6857e329b05b
[ "MIT" ]
null
null
null
Project/Zombienator/Layer.cpp
Jallah123/TheZombienator
efbcb93b0b2943cd9b38ac84fe8a6857e329b05b
[ "MIT" ]
null
null
null
Project/Zombienator/Layer.cpp
Jallah123/TheZombienator
efbcb93b0b2943cd9b38ac84fe8a6857e329b05b
[ "MIT" ]
null
null
null
#pragma once #include "Layer.h" #include "Map.h" #include "TileSet.h" Layer::Layer() { } Layer::Layer(Map * map) : map(map) { } Layer::~Layer() { } void Layer::DrawRect(SDL_Rect* srcRect, SDL_Texture* texture, SDL_Rect* destRect, SDL_Renderer& ren) { SDL_RenderCopy(&ren, texture, srcRect, destRect); } void Layer::DrawRect(SDL_Rect* rect, SDL_Renderer& ren) { SDL_SetRenderDrawColor(&ren, 255, 0, 0, 255); SDL_RenderDrawRect(&ren, rect); }
15.517241
100
0.695556
95f3259db3c8e78193d7b64e3381708b35a84a79
79,644
cpp
C++
src/model/UdmGridCoordinates.cpp
avr-aics-riken/UDMlib
1577b3caa74a7499037099dfbdd68d2f2c92fb43
[ "BSD-2-Clause" ]
3
2016-02-28T05:07:59.000Z
2019-01-31T15:15:31.000Z
src/model/UdmGridCoordinates.cpp
avr-aics-riken/UDMlib
1577b3caa74a7499037099dfbdd68d2f2c92fb43
[ "BSD-2-Clause" ]
4
2015-05-11T12:09:21.000Z
2015-11-24T06:23:38.000Z
src/model/UdmGridCoordinates.cpp
avr-aics-riken/UDMlib
1577b3caa74a7499037099dfbdd68d2f2c92fb43
[ "BSD-2-Clause" ]
5
2015-04-27T06:22:51.000Z
2021-05-10T07:36:57.000Z
// ################################################################################## // // UDMlib - Unstructured Data Management Library // // Copyright (C) 2012-2015 Institute of Industrial Science, The University of Tokyo. // All rights reserved. // // Copyright (c) 2015 Advanced Institute for Computational Science, RIKEN. // All rights reserved. // // ################################################################################### /** * @file UdmCoordinates.cpp * グリッド座標クラスのソースファイル */ #include "model/UdmGridCoordinates.h" #include "model/UdmModel.h" #include "model/UdmZone.h" #include "model/UdmFlowSolutions.h" #include "model/UdmNode.h" #include "model/UdmRankConnectivity.h" namespace udm { /** * コンストラクタ */ UdmGridCoordinates::UdmGridCoordinates() { this->initialize(); } /** * コンストラクタ * @param zone ゾーン */ UdmGridCoordinates::UdmGridCoordinates(UdmZone* zone) { this->initialize(); this->parent_zone = zone; } /** * デストラクタ */ UdmGridCoordinates::~UdmGridCoordinates() { this->finalize(); } /** * 初期化を行う. */ void UdmGridCoordinates::initialize() { this->setDataType(Udm_RealSingle); this->clearNodes(); this->parent_zone = NULL; this->max_nodeid = 0; } /** * 節点(ノード)の破棄処理を行う. */ void UdmGridCoordinates::finalize() { /********************************* std::vector<UdmNode*>::reverse_iterator ritr = this->node_list.rbegin(); while (ritr != this->node_list.rend()) { UdmNode* node = *(--(ritr.base())); if (node != NULL) { node->finalize(); delete node; } this->node_list.erase((++ritr).base()); ritr = this->node_list.rbegin(); } this->node_list.clear(); ritr = this->virtual_nodes.rbegin(); while (ritr != this->virtual_nodes.rend()) { UdmNode* node = *(--(ritr.base())); if (node != NULL) { node->finalize(); delete node; } this->virtual_nodes.erase((++ritr).base()); ritr = this->virtual_nodes.rbegin(); } this->virtual_nodes.clear(); ***************************/ std::vector<UdmNode*>::iterator itr = this->node_list.begin(); for (itr=this->node_list.begin(); itr!=this->node_list.end(); itr++) { UdmNode* node = (*itr); if (node != NULL) { node->finalize(); delete node; } } this->node_list.clear(); itr = this->virtual_nodes.begin(); for (itr=this->virtual_nodes.begin(); itr!=this->virtual_nodes.end(); itr++) { UdmNode* node = (*itr); if (node != NULL) { node->finalize(); delete node; } } this->virtual_nodes.clear(); return; } /** * グリッド構成ノード数を取得する. * @return グリッド構成ノード */ UdmSize_t UdmGridCoordinates::getNumNodes() const { return this->node_list.size(); } /** * ノードIDのグリッド構成ノードを取得する. * @param node_id ノードID(1~getNumNodes()) * @return グリッド構成ノード */ UdmNode* UdmGridCoordinates::getNodeById(UdmSize_t node_id) const { if (this->node_list.size() == 0) return NULL; if (node_id <= 0) return NULL; if (node_id > this->node_list.size()) return NULL; return (this->node_list[node_id - 1]); } /** * ローカルノードIDの節点(ノード)を取得する. * 構成節点(ノード)と仮想節点(ノード)から節点(ノード)を取得する. * @param node_id ノードID(1~getNumNodes()+getNumVirtualNodes()) * @return 節点(ノード) */ UdmNode* UdmGridCoordinates::getNodeByLocalId(UdmSize_t node_id) const { if (node_id <= 0) return NULL; if (node_id <= this->node_list.size()) { return this->getNodeById(node_id); } else if (node_id > this->node_list.size()) { return this->getVirtualNodeById(node_id - this->node_list.size()); } return NULL; } /** * グリッド構成ノードを追加する. * @param node グリッド構成ノード * @return ノードID(1~) : 0の場合は挿入エラー */ UdmSize_t UdmGridCoordinates::insertNode(UdmNode* node) { if (node == NULL) return 0; // グリッド構成ノードを追加する. this->node_list.push_back(node); /// NODE_ID = グリッド構成ノード(node_list)サイズ UdmSize_t node_id = 1; if (this->max_nodeid > 0) { node_id = this->max_nodeid + 1; } else if (this->node_list.size() > 0) { node_id = this->node_list[this->node_list.size()-1]->getId() + 1; } node->setId(node_id); this->max_nodeid = node_id; node->setParentGridcoordinates(this); // MPIランク番号 node->setMyRankno(this->getMpiRankno()); // 内部境界に追加する if (node->getNumMpiRankInfos() > 0) { if (this->getRankConnectivity() != NULL) { this->getRankConnectivity()->insertRankConnectivityNode(node); } } return node->getId(); } /** * グリッド構成ノードを追加する. * ID,ランク番号の設定は行わない. * @param node グリッド構成ノード */ void UdmGridCoordinates::pushbackNode(UdmNode* node) { if (node == NULL) return; // グリッド構成ノードを追加する. this->node_list.push_back(node); /// NODE_ID = グリッド構成ノード(node_list)サイズ UdmSize_t node_id = node->getId(); this->max_nodeid = node_id; node->setParentGridcoordinates(this); // ランク番号,IDを退避する. node->addPreviousRankInfo(node->getMyRankno(), node->getId()); // 内部境界に追加する if (node->getNumMpiRankInfos() > 0) { if (this->getRankConnectivity() != NULL) { this->getRankConnectivity()->insertRankConnectivityNode(node); } } return; } /** * 仮想ノードリスト数を取得する. * @return 仮想ノードリスト数 */ UdmSize_t UdmGridCoordinates::getNumVirtualNodes() const { return this->virtual_nodes.size(); } /** * 仮想ノードIDの仮想ノードリストを取得する. * @param node_id 仮想ノードID(1~getNumVirtualNodes()) * @return 仮想ノードリスト */ UdmNode* UdmGridCoordinates::getVirtualNodeById(UdmSize_t node_id) const { if (this->virtual_nodes.size() == 0) return NULL; if (node_id <= 0) return NULL; if (node_id > this->virtual_nodes.size()) return NULL; return (this->virtual_nodes[node_id - 1]); } /** * 仮想ノードを追加する. * 仮想節点(ノード)のID, 自ランク番号は、実体ランクのID,ランク番号とする. * 仮想節点(ノード)のID, 自ランク番号は上位で設定済みとする. * 仮想節点(ノード)の自ランク番号,IDで昇順に挿入する. * @param node 仮想ノード * @return 仮想ノード数 : 0の場合は挿入エラー */ UdmSize_t UdmGridCoordinates::insertVirtualNode(UdmNode* virtual_node) { if (virtual_node == NULL) return 0; std::vector<UdmNode*>::const_iterator itr; std::vector<UdmNode*>::iterator ins_itr; itr = this->searchUpperGlobalId(this->virtual_nodes, virtual_node); if (itr == this->virtual_nodes.end()) { this->virtual_nodes.push_back(virtual_node); } else { ins_itr = this->virtual_nodes.begin() + (itr - this->virtual_nodes.begin()); ins_itr = this->virtual_nodes.insert(ins_itr, virtual_node); } virtual_node->setParentGridcoordinates(this); virtual_node->setRealityType(Udm_Virtual); return this->virtual_nodes.size(); } /** * ノードをすべて削除する. * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::clearNodes() { /************************ std::vector<UdmNode*>::reverse_iterator ritr = this->node_list.rbegin(); while (ritr != this->node_list.rend()) { UdmNode* node = *(--(ritr.base())); if (node != NULL) { delete node; } this->node_list.erase((++ritr).base()); ritr = this->node_list.rbegin(); } this->node_list.clear(); ritr = this->virtual_nodes.rbegin(); while (ritr != this->virtual_nodes.rend()) { UdmNode* node = *(--(ritr.base())); if (node != NULL) { delete node; } this->virtual_nodes.erase((++ritr).base()); ritr = this->virtual_nodes.rbegin(); } this->virtual_nodes.clear(); ******************/ std::vector<UdmNode*>::iterator itr = this->node_list.begin(); for (itr=this->node_list.begin(); itr!=this->node_list.end(); itr++) { UdmNode* node = (*itr); if (node != NULL) { node->finalize(); delete node; } } this->node_list.clear(); itr = this->virtual_nodes.begin(); for (itr=this->virtual_nodes.begin(); itr!=this->virtual_nodes.end(); itr++) { UdmNode* node = (*itr); if (node != NULL) { node->finalize(); delete node; } } this->virtual_nodes.clear(); return UDM_OK; } /** * 仮想節点(ノード)をすべて削除する. * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::clearVirtualNodes() { /******************** std::vector<UdmNode*>::reverse_iterator ritr = this->node_list.rbegin(); ritr = this->virtual_nodes.rbegin(); while (ritr != this->virtual_nodes.rend()) { UdmNode* node = *(--(ritr.base())); if (node != NULL) { delete node; } this->virtual_nodes.erase((++ritr).base()); ritr = this->virtual_nodes.rbegin(); } this->virtual_nodes.clear(); *************/ std::vector<UdmNode*>::iterator itr = this->virtual_nodes.begin(); for (itr=this->virtual_nodes.begin(); itr!=this->virtual_nodes.end(); itr++) { UdmNode* node = (*itr); if (node != NULL) { delete node; } } this->virtual_nodes.clear(); return UDM_OK; } /** * 削除節点(ノード)を削除する. * @param node 削除節点(ノード) * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::removeNode(const UdmEntity* node) { if (node == NULL) return UDM_ERROR; // 内部境界リストから削除する this->removeRankConnectivity(node); bool found_node = false; UdmSize_t node_id = node->getId(); std::vector<UdmNode*>::const_iterator itr; std::vector<UdmNode*>::iterator rm_itr; // 構成ノードから検索 itr = this->searchGlobalId(this->node_list, node); if (itr != this->node_list.end()) { if ((*itr) == node) { delete (*itr); rm_itr = this->node_list.begin() + (itr - this->node_list.begin()); this->node_list.erase(rm_itr); found_node = true;; } } // 仮想ノードから検索 if (found_node == false) { itr = this->searchGlobalId(this->virtual_nodes, node); if (itr != this->virtual_nodes.end()) { if ((*itr) == node) { delete (*itr); rm_itr = this->virtual_nodes.begin() + (itr - this->virtual_nodes.begin()); this->virtual_nodes.erase(rm_itr); found_node = true;; } } } if (found_node == false) { // node_idが存在しない UDM_WARNING_HANDLER(UDM_WARNING_INVALID_NODE, "not found node[node_id=%ld]", node_id); return UDM_ERROR; } return UDM_OK; } /** * 削除節点(ノード)を削除する. * ゾーン内の一意節点(ノード)IDにてグリッド構成ノード、仮想ノードから節点(ノード)を削除する. * @param node_id ゾーン内節点(ノード)ID(1~) * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::removeNode(UdmSize_t node_id) { if (node_id <= 0) return UDM_ERROR; std::vector<UdmNode*>::const_iterator itr; std::vector<UdmNode*>::iterator rm_itr; // 構成ノードから検索 itr = this->searchEntityId(this->node_list, node_id); if (itr != this->node_list.end()) { // 内部境界リストから削除する this->removeRankConnectivity(*itr); delete (*itr); rm_itr = this->node_list.begin() + (itr - this->node_list.begin()); this->node_list.erase(rm_itr); return UDM_OK; } // 仮想ノードから検索 itr = this->searchEntityId(this->virtual_nodes, node_id); if (itr != this->virtual_nodes.end()) { delete (*itr); rm_itr = this->virtual_nodes.begin() + (itr - this->virtual_nodes.begin()); this->virtual_nodes.erase(rm_itr); return UDM_OK; } // node_idが存在しない UDM_WARNING_HANDLER(UDM_WARNING_INVALID_NODE, "not found node_id=%ld", node_id); return UDM_ERROR; } /** * 親ゾーンを取得する. * @return 親ゾーン */ UdmZone* UdmGridCoordinates::getParentZone() const { return this->parent_zone; } /** * 親ゾーンを設定する. * @param zone 親ゾーン * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::setParentZone(UdmZone* zone) { this->parent_zone = zone; return UDM_OK; } /** * CGNSファイルからGridCoordinates(ノード座標データ)の読込みを行う. * @param index_file CGNSファイルインデックス * @param index_base CGNSベースインデックス * @param index_zone CGNSゾーンインデックス * @param timeslice_step CGNS読込ステップ回数 (default=-1) * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::readCgns(int index_file, int index_base, int index_zone, int timeslice_step) { char zonename[33] = {0x00}, gridname[33] = {0x00}, arrayname[33] = {0x00}; cgsize_t sizes[9] = {0x00}; int num_coords = 0; DataType_t cgns_datatype; UdmDataType_t datatype = Udm_RealSingle; void *x_coords = NULL, *y_coords = NULL, *z_coords = NULL; int datasize; int dimension; cgsize_t vectors[3]; UdmError_t error = UDM_OK; int n; // ゾーンからノードサイズの取得 if (cg_zone_read(index_file, index_base, index_zone, zonename, sizes) != CG_OK) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_ZONE, "failure:cg_zone_read"); } // GridCoordinates名称の取得 error = this->getCgnsIterativeGridCoordinatesName(gridname, index_file, index_base, index_zone, timeslice_step); if (error != UDM_OK) { if (error == UDM_WARNING_CGNS_NOTEXISTS_ITERATIVEDATA) { // 警告メッセージ:CGNS:BaseIterativeData, ZoneIterativeDataが存在しない。 UDM_WARNINGNO_HANDLER(UDM_WARNING_CGNS_NOTEXISTS_ITERATIVEDATA); } int num_grids = 0; cg_ngrids(index_file, index_base, index_zone, &num_grids); if (num_grids > 1 && timeslice_step > 0) { // 複数のGridCoordinatesが存在し、ステップ番号が1以上であるので、GridCoordinates_%010dとする sprintf(gridname, UDM_CGNS_FORMAT_GRIDCOORDINATES, timeslice_step); } else { // timeslice_step=0の場合は必ずGridCoordinates strcpy(gridname, UDM_CGNS_NAME_GRIDCOORDINATES); } } if (cg_goto(index_file, index_base, zonename, 0, gridname, 0, "end") != CG_OK) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GOTO, "zonename=%s,gridname=%s", zonename, gridname); } error = UDM_OK; // GridCoordinatesデータ数 cg_narrays(&num_coords); if (num_coords <= 0) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "num_coords=%d", num_coords); } for (n=1; n<=num_coords; n++) { // CGNS:CoordinateX,CoordinateY,CoordinateZの読込 dimension = 0; vectors[0] = 0; cg_array_info(n, arrayname, &cgns_datatype,&dimension, vectors); if (dimension != 1 && vectors[0] <= 0) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "coords[%d]:dimension=%d,vectors[0]=%d", n, dimension, vectors[0]); } if (vectors[0] != sizes[0]) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "invalid coordinates size:vectors[0]=%d, sizes[0]=%d", vectors[0], sizes[0]); } if (n==1) { datatype = this->setCoordsDatatype(cgns_datatype); if (datatype == Udm_RealSingle) { x_coords = new float[sizes[0]]; y_coords = new float[sizes[0]]; z_coords = new float[sizes[0]]; datasize = sizeof(float); } else if (datatype == Udm_RealDouble) { x_coords = new double[sizes[0]]; y_coords = new double[sizes[0]]; z_coords = new double[sizes[0]]; datasize = sizeof(double); } else { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "invalid coordinates datatype"); } memset(x_coords, 0x00, datasize*sizes[0]); memset(y_coords, 0x00, datasize*sizes[0]); memset(z_coords, 0x00, datasize*sizes[0]); } datatype = this->getDataType(); cgns_datatype = this->toCgnsDataType(datatype); // 座標データの読込 if (strcmp(arrayname, "CoordinateX") == 0) { if (cg_array_read_as(n,cgns_datatype,x_coords) != CG_OK) { error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : CoordinateX"); } } else if (strcmp(arrayname, "CoordinateY") == 0) { if (cg_array_read_as(n,cgns_datatype,y_coords) != CG_OK) { error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : CoordinateY"); } } else if (strcmp(arrayname, "CoordinateZ") == 0) { if (cg_array_read_as(n,cgns_datatype,z_coords) != CG_OK) { error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : CoordinateZ"); } } } if (error != UDM_OK) { this->deleteDataArray(x_coords, datatype); this->deleteDataArray(y_coords, datatype); this->deleteDataArray(z_coords, datatype); return UDM_ERRORNO_HANDLER(error); } // ノードデータの作成 UdmSize_t insert_size = 0; if (datatype == Udm_RealSingle) { insert_size = this->setGridCoordinatesArray(sizes[0], (float*)x_coords, (float*)y_coords, (float*)z_coords); } else if (datatype == Udm_RealDouble) { insert_size = this->setGridCoordinatesArray(sizes[0], (double*)x_coords, (double*)y_coords, (double*)z_coords); } this->deleteDataArray(x_coords, datatype); this->deleteDataArray(y_coords, datatype); this->deleteDataArray(z_coords, datatype); if (insert_size <= 0) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "invalid coordinates datatype"); } // CGNS:UdmRankConnectivityを読み込む if (this->getRankConnectivity() != NULL) { if (this->getRankConnectivity()->readCgns(index_file, index_base, index_zone) != UDM_OK) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_USERDEFINEDDATA, "failure : UdmRankConnectivity::readCgns(index_file=%d, index_base=%d, index_zone=%d)", index_file, index_base, index_zone); } } return error; } /** * CGNSデータ型から座標値のデータ型を設定する. * @param cgns_datatype CGNSデータ型 * @return UDMlib:座標値データ型 */ UdmDataType_t UdmGridCoordinates::setCoordsDatatype(DataType_t cgns_datatype) { UdmDataType_t datatype = this->toUdmDataType(cgns_datatype); this->setDataType(datatype); return datatype; } /** * FlowSolutionクラスを取得する. * @return FlowSolutionクラス */ UdmFlowSolutions* UdmGridCoordinates::getFlowSolutions() const { if (this->parent_zone == NULL) return NULL; return this->parent_zone->getFlowSolutions(); } /** * ステップ数に設定されている時系列CGNS:GridCoordinates名を取得する * @param grid_name ゾーン名 * @param index_file CGNSファイルインデックス * @param index_base CGNSベースインデックス * @param index_zone CGNSゾーンインデックス * @param timeslice_step ステップ数 (default = -1) * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::getCgnsIterativeGridCoordinatesName(char *grid_name, int index_file, int index_base, int index_zone, int timeslice_step) { char arrayname[33], zitername[33]; int narrays; int dimension, num_iterative; cgsize_t n, vectors[3], iterative_index; DataType_t idatatype; if (timeslice_step < 0) { strcpy(grid_name, UDM_CGNS_NAME_GRIDCOORDINATES); return UDM_OK; } // CGNS:BaseIterativeData,ZoneIterativeDataが存在するかチェックする. if (!this->existsCgnsIterativeData(index_file, index_base, index_zone)) { return UDM_WARNING_CGNS_NOTEXISTS_ITERATIVEDATA; } // CGNS:BaseIterativeDataからステップ数と一致するIterativeIDを取得する. std::vector<UdmSize_t> iterative_ids; num_iterative = this->getCgnsBaseIterativeDataIds(iterative_ids, index_file, index_base, timeslice_step); if (num_iterative <= 0) { // GridCoordinatesPointersが存在しない。グリッド座標の時系列座標はない。 return UDM_ERROR; } // 時系列CGNS:GridCoordinatesは1つのみ iterative_index = iterative_ids[0]; // CGNS:ZoneIterativeDataの読込 cg_ziter_read(index_file,index_base,index_zone,zitername); cg_goto(index_file,index_base,"Zone_t",index_zone,"ZoneIterativeData_t",1,"end"); // CGNS:ZoneIterativeData/DataArray_tの数の取得 : cg_narrays narrays = 0; cg_narrays(&narrays); for (n=1; n<=narrays; n++) { // CGNS:ZoneIterativeData/DataArray_tの名前,データ数の取得 : cg_array_info cg_array_info(n, arrayname, &idatatype,&dimension,vectors); if (dimension != 2) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_ITERATIVEDATA, "invalid ZoneIterativeData[dataDimension=%d].", dimension); } if (vectors[1] < iterative_index) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_ITERATIVEDATA, "invalid ZoneIterativeData[dimensionVector[1]=%d,iterative_index=%d].", vectors[1], iterative_index); } if (strcmp(arrayname, "GridCoordinatesPointers")==0) { // char grid_names[vectors[1]][vectors[0]]; char *grid_names = new char[vectors[1]*vectors[0]]; // (時系列GridCoordinates名リストの取得 : GridCoordinatesPointers cg_array_read_as(n,Character,grid_names); // 時系列インデックスの名前の取得(1つのみ) strncpy(grid_name, grid_names+(iterative_index-1)*vectors[0], vectors[0]); this->trim(grid_name); delete []grid_names; return UDM_OK; } } // GridCoordinatesPointersが存在しない。グリッド座標の時系列座標はない。 return UDM_ERROR; } /** * クラス情報を文字列出力する:デバッグ用. * @param buf 出力文字列 */ void UdmGridCoordinates::toString(std::string& buf) const { #ifdef _DEBUG_TRACE std::stringstream stream; UdmSize_t count = 0; // XYZ座標 std::vector<UdmNode*>::const_iterator itr; for (itr=this->node_list.begin(); itr!= this->node_list.end(); itr++) { std::string node_buf; (*itr)->toString(node_buf); stream << "GridCoordinates[" << (*itr)->getId() << "] : " << node_buf; stream << std::endl; } buf += stream.str(); #endif return; } /** * グリッド構成ノード数を取得する. * @return グリッド構成ノード */ UdmSize_t UdmGridCoordinates::getNumEntities() const { return this->getNumNodes(); } /** * ノードIDのグリッド構成ノードを取得する. * @param node_id ノードID(1~) * @return グリッド構成ノード */ UdmEntity* UdmGridCoordinates::getEntityById(UdmSize_t entity_id) { return this->getNodeById(entity_id); } /** * ノードIDのグリッド構成ノードを取得する:const. * @param node_id ノードID(1~) * @return グリッド構成ノード */ const UdmEntity* UdmGridCoordinates::getEntityById(UdmSize_t entity_id) const { return this->getNodeById(entity_id); } /** * CGNS:GridCoordinatesを出力する. * @param index_file CGNSファイルインデックス * @param index_base CGNSベースインデックス * @param index_zone CGNSゾーンインデックス * @param timeslice_step CGNS出力ステップ回数 * @param grid_timeslice CGNS:GridCoordinatesの時系列出力の有無:true=GridCoordinates時系列出力する * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::writeCgns(int index_file, int index_base, int index_zone, int timeslice_step, bool grid_timeslice) { char gridname[33] = {0x00}; int index_grid, index_coord; UdmDataType_t datatype; DataType_t cgns_datatype; cgsize_t coords_size; int cg_error; UdmError_t udm_error = UDM_OK; // 出力CGNS:GridCoordinates名のクリア this->clearCgnsWriteGridCoordnates(); // GridCoordinatesが存在するか sprintf(gridname, "GridCoordinates"); if (cg_goto(index_file, index_base, "Zone_t", index_zone, gridname, 0, "end") == CG_OK) { if (!grid_timeslice) { // 時系列出力の無であるので、CGNS:GridCoordinatesの時系列出力しない。 // GridCoordinatesが存在するので、CGNS:GridCoordinatesは出力しない。 // 出力CGNS:GridCoordinates名を設定する. this->setCgnsWriteGridCoordnates(std::string(gridname)); return UDM_OK; } char itr_name[33] = {0x00}; if (this->getCgnsIterativeGridCoordinatesName(itr_name, index_file, index_base, index_zone, timeslice_step) == UDM_OK) { // 既存出力のGridCoordinates名を使用する. strcpy(gridname, itr_name); } else { // 時系列ステップ番号付きのGridCoordinates名を使用する. // GridCoordinates_%010d sprintf(gridname, UDM_CGNS_FORMAT_GRIDCOORDINATES, timeslice_step); } } // CGNS:GridCoordinatesの出力 index_grid = this->findCgnsGridCoordinates(index_file, index_base, index_zone, gridname); if (index_grid <= 0) { if (cg_grid_write(index_file,index_base,index_zone, gridname, &index_grid) != CG_OK) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_grid_write(gridname=%s)", gridname); } } if (cg_goto(index_file,index_base, "Zone_t", index_zone, "GridCoordinates_t",index_grid, "end") != CG_OK) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_goto(index_grid=%d)", index_grid); } udm_error = UDM_OK; cg_error = 0; datatype = this->getDataType(); cgns_datatype = this->toCgnsDataType(datatype); coords_size = this->getNumNodes(); if (datatype == Udm_RealSingle) { float *coords = new float[coords_size]; // CoordinateX出力 this->getGridCoordinatesX(1, coords_size, (float*)coords); if ((cg_error = cg_array_write("CoordinateX", cgns_datatype, 1, &coords_size, coords)) != CG_OK) { udm_error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_array_write(CoordinateX)"); } if (udm_error != UDM_OK) { delete []coords; return udm_error; } // CoordinateY出力 this->getGridCoordinatesY(1, coords_size, (float*)coords); if ((cg_error = cg_array_write("CoordinateY", cgns_datatype, 1, &coords_size, coords)) != CG_OK) { udm_error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_array_write(CoordinateY)"); } if (udm_error != UDM_OK) { delete []coords; return udm_error; } // CoordinateZ出力 this->getGridCoordinatesZ(1, coords_size, (float*)coords); if ((cg_error = cg_array_write("CoordinateZ", cgns_datatype, 1, &coords_size, coords)) != CG_OK) { udm_error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_array_write(CoordinateZ)"); } if (udm_error != UDM_OK) { delete []coords; return udm_error; } delete []coords; } else if (datatype == Udm_RealDouble) { double *coords = new double[coords_size]; // CoordinateX出力 this->getGridCoordinatesX(1, coords_size, (double*)coords); if ((cg_error = cg_array_write("CoordinateX", cgns_datatype, 1, &coords_size, coords)) != CG_OK) { udm_error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_array_write(CoordinateX)"); } if (udm_error != UDM_OK) { delete []coords; return udm_error; } // CoordinateY出力 this->getGridCoordinatesY(1, coords_size, (double*)coords); if ((cg_error = cg_array_write("CoordinateY", cgns_datatype, 1, &coords_size, coords)) != CG_OK) { udm_error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_array_write(CoordinateY)"); } if (udm_error != UDM_OK) { delete []coords; return udm_error; } // CoordinateZ出力 this->getGridCoordinatesZ(1, coords_size, (double*)coords); if ((cg_error = cg_array_write("CoordinateZ", cgns_datatype, 1, &coords_size, coords)) != CG_OK) { udm_error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_array_write(CoordinateZ)"); } if (udm_error != UDM_OK) { delete []coords; return udm_error; } delete []coords; } else { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "invalid coordinates datatype"); } // 出力CGNS:GridCoordinates名を設定する. this->setCgnsWriteGridCoordnates(std::string(gridname)); // CGNS:UdmRankConenctivityを書き込む. if (this->getRankConnectivity() != NULL) { if (this->getRankConnectivity()->writeCgns(index_file, index_base, index_zone) != UDM_OK) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_USERDEFINEDDATA, "failure : UdmRankConnectivity::writeCgns(index_file=%d, index_base=%d, index_zone=%d)", index_file, index_base, index_zone); } } return UDM_OK; } /** * CGNS:GridCoordinatesのリンクを出力する. * @param index_file CGNSファイルインデックス * @param index_base CGNSベースインデックス * @param index_zone CGNSゾーンインデックス * @param link_output_path リンク出力ファイル * @param linked_files リンクファイルリスト * @param timeslice_step CGNS出力ステップ回数 * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::writeCgnsLinkFile( int index_file, int index_base, int index_zone, const std::string &link_output_path, const std::vector<std::string> &linked_files, int timeslice_step) { UdmError_t error = UDM_OK; char basename[33] = {0x00}; char zonename[33] = {0x00}; char gridname[33] = {0x00}; char linked_gridname[33] = {0x00}; int index_linkfile; std::vector<std::string>::const_iterator itr; char path[256] = {0x00}; std::string filename; int cell_dim, phys_dim; cgsize_t sizes[9] = {0x00}; int cg_ret = 0; // 出力CGNS:GridCoordinates名のクリア this->clearCgnsWriteGridCoordnates(); // リンクファイルにGridCoordinatesが存在するかチェックする. filename.clear(); for (itr=linked_files.begin(); itr!= linked_files.end(); itr++) { filename = (*itr); // リンクファイルオープン if (cg_open(filename.c_str(), CG_MODE_READ, &index_linkfile) != CG_OK) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_OPENERROR, "filename=%s, cgns_error=%s", filename.c_str(), cg_get_error()); } // 出力リンクファイルと同じCGNSベースインデックス, CGNSゾーンインデックスとする. cg_ret = cg_base_read(index_linkfile, index_base, basename, &cell_dim, &phys_dim); cg_ret = cg_zone_read(index_linkfile, index_base, index_zone, zonename, sizes); // GridCoordinates名称の取得 if ((error = this->getCgnsIterativeGridCoordinatesName(gridname, index_linkfile, index_base, index_zone, timeslice_step)) != UDM_OK) { strcpy(gridname, UDM_CGNS_NAME_GRIDCOORDINATES); } if (cg_goto(index_linkfile, index_base, "Zone_t", index_zone, gridname, 0, "end") != CG_OK) { continue; // CGNS:GridCoordinatesが存在しない. } // リンク元GridCoordinates名 strcpy(linked_gridname, gridname); cg_close(index_linkfile); break; } // linked_gridname:リンク元名, gridname:リンク先名 if (strlen(linked_gridname) <= 0) { // GridCoordinatesはリンクしない。 return UDM_OK; } if (filename.empty()) { return UDM_OK; } // リンク元GridCoordinates名が"GridCoordinates"であるので別名とする。 if (strcmp(linked_gridname, UDM_CGNS_NAME_GRIDCOORDINATES) == 0) { // 出力リンクファイルにGridCoordinatesが存在するか if (cg_goto(index_file, index_base, "Zone_t", index_zone, UDM_CGNS_NAME_GRIDCOORDINATES, 0, "end") == CG_OK) { // 出力リンクファイルにGridCoordinatesが存在し、リンク元GridCoordinatesと同名であるので、別名とする. // GridCoordinates_%010d sprintf(gridname, UDM_CGNS_FORMAT_GRIDCOORDINATES, timeslice_step); } } // 出力リンクファイルにリンク別名と同じGridCoordinatesが存在することはない。 if (cg_goto(index_file, index_base, "Zone_t", index_zone, gridname, 0, "end") == CG_OK) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "exists linked GridCoordinates name[gridname=%s].", gridname); } // GridCoordinatesリンクの作成 if (cg_goto(index_file, index_base, "Zone_t", index_zone, "end") != CG_OK) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GOTO, "index_file=%d,index_base=%d,index_zone=%d", index_file, index_base, index_zone); } sprintf(path, "/%s/%s/%s", basename, zonename, linked_gridname); // リンクファイルをリンク出力ファイルからの相対パスに変換する. std::string linked_relativepath; this->getLinkedRelativePath(link_output_path, filename, linked_relativepath); // CGNSリンク出力 if (cg_link_write(gridname, linked_relativepath.c_str(), path) != CG_OK) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_ELEMENTS, "failure:cg_link_write(%s,%s,%s)",gridname, filename.c_str(), path); } // 出力CGNS:GridCoordinates名を設定する. this->setCgnsWriteGridCoordnates(std::string(gridname)); // CGNS:UdmRankConenctivityを書き込む.:実際に書き込む(リンク先が削除されることを考慮して、リンクとしない) if (this->getRankConnectivity() != NULL) { if (this->getRankConnectivity()->writeCgns(index_file, index_base, index_zone) != UDM_OK) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_USERDEFINEDDATA, "failure : UdmRankConnectivity::writeCgns(index_file=%d, index_base=%d, index_zone=%d)", index_file, index_base, index_zone); } } return UDM_OK; } /** * 節点(ノード)グリッド座標を設定する. * 構成節点(ノード)はクリアして設定節点(ノード)数,グリッド座標に置き換える. * グリッド座標から節点(ノード)クラスを生成する. * @param num_nodes 節点(ノード)数 * @param coords_x グリッド座標X * @param coords_y グリッド座標Y * @param coords_z グリッド座標Z * @return 生成節点(ノード)数 */ template<class DATA_TYPE> UdmSize_t UdmGridCoordinates::setGridCoordinatesArray( UdmSize_t num_nodes, DATA_TYPE* coords_x, DATA_TYPE* coords_y, DATA_TYPE* coords_z) { UdmSize_t n; // 節点(ノード)をクリアする. this->clearNodes(); // ノードデータの作成 for (n=0; n<num_nodes; n++) { UdmNode *node = NULL; node = new UdmNode(coords_x[n], coords_y[n], coords_z[n]); // ノードID、ランク番号を設定する node->addPreviousRankInfo(this->getCgnsRankno(), n+1); node->setId(n+1); node->setMyRankno(this->getCgnsRankno()); // 節点(ノード)の挿入 this->pushbackNode(node); } return num_nodes; } template UdmSize_t UdmGridCoordinates::setGridCoordinatesArray(UdmSize_t num_nodes, float* coords_x, float* coords_y, float* coords_z); template UdmSize_t UdmGridCoordinates::setGridCoordinatesArray(UdmSize_t num_nodes, double* coords_x, double* coords_y, double* coords_z); /** * 節点(ノード)グリッド座標を取得する. * @param [in] node_id 節点(ノード)ID:1~ * @param [out] x X座標 * @param [out] y Y座標 * @param [out] z Z座標 * @return エラー番号 : UDM_OK | UDM_ERROR */ template<class DATA_TYPE> UdmError_t UdmGridCoordinates::getGridCoordinates( UdmSize_t node_id, DATA_TYPE &x, DATA_TYPE &y, DATA_TYPE &z) const { const UdmNode *node = this->getNodeById(node_id); if (node == NULL) { return UDM_ERROR; } // グリッド座標を取得する. node->getCoords(x, y, z); return UDM_OK; } template UdmError_t UdmGridCoordinates::getGridCoordinates(UdmSize_t node_id, float &x, float &y, float &z) const; template UdmError_t UdmGridCoordinates::getGridCoordinates(UdmSize_t node_id, double &x, double &y, double &z) const; /** * 節点(ノード)グリッド座標を設定する. * @param node_id 節点(ノード)ID:1~ * @param x X座標 * @param y Y座標 * @param z Z座標 * @return エラー番号 : UDM_OK | UDM_ERROR */ template<class DATA_TYPE> UdmError_t UdmGridCoordinates::setGridCoordinates( UdmSize_t node_id, DATA_TYPE x, DATA_TYPE y, DATA_TYPE z) { UdmNode *node = this->getNodeById(node_id); if (node == NULL) { return UDM_ERROR; } // グリッド座標を設定する. node->setCoords(x, y, z); return UDM_OK; } template UdmError_t UdmGridCoordinates::setGridCoordinates(UdmSize_t node_id, float x, float y, float z); template UdmError_t UdmGridCoordinates::setGridCoordinates(UdmSize_t node_id, double x, double y, double z); /** * 節点(ノード)グリッド座標を追加する. * @param x グリッド座標X * @param y グリッド座標Y * @param z グリッド座標Z * @return 節点(ノード)ID */ template<class DATA_TYPE> UdmSize_t UdmGridCoordinates::insertGridCoordinates( DATA_TYPE x, DATA_TYPE y, DATA_TYPE z) { UdmSize_t n; // ノードデータの作成 UdmNode *node = new UdmNode(x, y, z); return this->insertNode(node);; } template UdmSize_t UdmGridCoordinates::insertGridCoordinates(float x, float y, float z); template UdmSize_t UdmGridCoordinates::insertGridCoordinates(double x, double y, double z); /** * 構成節点(ノード)のグリッド座標を取得する. * @param start_id 取得開始ID * @param end_id 取得終了ID * @param coords_x グリッド座標X * @param coords_y グリッド座標Y * @param coords_z グリッド座標Z * @return 取得節点(ノード)数 */ template<class DATA_TYPE> UdmSize_t UdmGridCoordinates::getGridCoordinatesArray( UdmSize_t start_id, UdmSize_t end_id, DATA_TYPE* coords_x, DATA_TYPE* coords_y, DATA_TYPE* coords_z) { if (start_id <= 0) return 0; if (start_id > end_id) return 0; if (this->node_list.size() <= 0) return 0; if (end_id > this->node_list.size()) return 0; UdmSize_t n; UdmSize_t id = 0; for (n=start_id-1; n<=end_id-1; n++) { this->node_list[n]->getCoords(coords_x[id], coords_y[id], coords_z[id]); ++id; } return id; } template UdmSize_t UdmGridCoordinates::getGridCoordinatesArray(UdmSize_t start_id, UdmSize_t end_id, float* coords_x, float* coords_y, float* coords_z); template UdmSize_t UdmGridCoordinates::getGridCoordinatesArray(UdmSize_t start_id, UdmSize_t end_id, double* coords_x, double* coords_y, double* coords_z); /** * 構成節点(ノード)のグリッド座標Xを取得する. * @param start_id 取得開始ID * @param end_id 取得終了ID * @param coords グリッド座標X * @return 取得節点(ノード)数 */ template<class DATA_TYPE> UdmSize_t UdmGridCoordinates::getGridCoordinatesX( UdmSize_t start_id, UdmSize_t end_id, DATA_TYPE* coords) { if (start_id <= 0) return 0; if (start_id > end_id) return 0; if (this->node_list.size() <= 0) return 0; if (end_id > this->node_list.size()) return 0; UdmSize_t n; UdmSize_t id = 0; DATA_TYPE coords_x, coords_y, coords_z; for (n=start_id-1; n<=end_id-1; n++) { this->node_list[n]->getCoords(coords_x, coords_y, coords_z); coords[id++] = coords_x; } return id; } template UdmSize_t UdmGridCoordinates::getGridCoordinatesX(UdmSize_t start_id, UdmSize_t end_id, float* coords); template UdmSize_t UdmGridCoordinates::getGridCoordinatesX(UdmSize_t start_id, UdmSize_t end_id, double* coords); /** * 構成節点(ノード)のグリッド座標Yを取得する. * @param start_id 取得開始ID * @param end_id 取得終了ID * @param coords グリッド座標Y * @return 取得節点(ノード)数 */ template<class DATA_TYPE> UdmSize_t UdmGridCoordinates::getGridCoordinatesY( UdmSize_t start_id, UdmSize_t end_id, DATA_TYPE* coords) { if (start_id <= 0) return 0; if (start_id > end_id) return 0; if (this->node_list.size() <= 0) return 0; if (end_id > this->node_list.size()) return 0; UdmSize_t n; UdmSize_t id = 0; DATA_TYPE coords_x, coords_y, coords_z; for (n=start_id-1; n<=end_id-1; n++) { this->node_list[n]->getCoords(coords_x, coords_y, coords_z); coords[id++] = coords_y; } return id; } template UdmSize_t UdmGridCoordinates::getGridCoordinatesY(UdmSize_t start_id, UdmSize_t end_id, float* coords); template UdmSize_t UdmGridCoordinates::getGridCoordinatesY(UdmSize_t start_id, UdmSize_t end_id, double* coords); /** * 構成節点(ノード)のグリッド座標Zを取得する. * @param start_id 取得開始ID * @param end_id 取得終了ID * @param coords グリッド座標Z * @return 取得節点(ノード)数 */ template<class DATA_TYPE> UdmSize_t UdmGridCoordinates::getGridCoordinatesZ( UdmSize_t start_id, UdmSize_t end_id, DATA_TYPE* coords) { if (start_id <= 0) return 0; if (start_id > end_id) return 0; if (this->node_list.size() <= 0) return 0; if (end_id > this->node_list.size()) return 0; UdmSize_t n; UdmSize_t id = 0; DATA_TYPE coords_x, coords_y, coords_z; for (n=start_id-1; n<=end_id-1; n++) { this->node_list[n]->getCoords(coords_x, coords_y, coords_z); coords[id++] = coords_z; } return id; } template UdmSize_t UdmGridCoordinates::getGridCoordinatesZ(UdmSize_t start_id, UdmSize_t end_id, float* coords); template UdmSize_t UdmGridCoordinates::getGridCoordinatesZ(UdmSize_t start_id, UdmSize_t end_id, double* coords); /** * 仮想節点(ノード)のグリッド座標を取得する. * @param start_id 取得開始ID * @param end_id 取得終了ID * @param coords_x グリッド座標X * @param coords_y グリッド座標Y * @param coords_z グリッド座標Z * @return 取得節点(ノード)数 */ template<class DATA_TYPE> UdmSize_t UdmGridCoordinates::getGridCoordinatesArrayOfVirtual( UdmSize_t start_id, UdmSize_t end_id, DATA_TYPE* coords_x, DATA_TYPE* coords_y, DATA_TYPE* coords_z) { if (start_id <= 0) return 0; if (start_id > end_id) return 0; if (this->virtual_nodes.size() <= 0) return 0; if (end_id > this->virtual_nodes.size()) return 0; UdmSize_t n; UdmSize_t id = 0; for (n=start_id-1; n<=end_id-1; n++) { this->virtual_nodes[n]->getCoords(coords_x[id], coords_y[id], coords_z[id]); ++id; } return id; } template UdmSize_t UdmGridCoordinates::getGridCoordinatesArrayOfVirtual(UdmSize_t start_id, UdmSize_t end_id, float* coords_x, float* coords_y, float* coords_z); template UdmSize_t UdmGridCoordinates::getGridCoordinatesArrayOfVirtual(UdmSize_t start_id, UdmSize_t end_id, double* coords_x, double* coords_y, double* coords_z); /** * 仮想節点(ノード)のグリッド座標Xを取得する. * @param start_id 取得開始ID * @param end_id 取得終了ID * @param coords グリッド座標X * @return 取得節点(ノード)数 */ template<class DATA_TYPE> UdmSize_t UdmGridCoordinates::getGridCoordinatesXOfVirtual( UdmSize_t start_id, UdmSize_t end_id, DATA_TYPE* coords) { if (start_id <= 0) return 0; if (start_id > end_id) return 0; if (this->virtual_nodes.size() <= 0) return 0; if (end_id > this->virtual_nodes.size()) return 0; UdmSize_t n; UdmSize_t id = 0; DATA_TYPE coords_x, coords_y, coords_z; for (n=start_id-1; n<=end_id-1; n++) { this->virtual_nodes[n]->getCoords(coords_x, coords_y, coords_z); coords[id++] = coords_x; } return id; } template UdmSize_t UdmGridCoordinates::getGridCoordinatesXOfVirtual(UdmSize_t start_id, UdmSize_t end_id, float* coords); template UdmSize_t UdmGridCoordinates::getGridCoordinatesXOfVirtual(UdmSize_t start_id, UdmSize_t end_id, double* coords); /** * 仮想節点(ノード)のグリッド座標Yを取得する. * @param start_id 取得開始ID * @param end_id 取得終了ID * @param coords グリッド座標Y * @return 取得節点(ノード)数 */ template<class DATA_TYPE> UdmSize_t UdmGridCoordinates::getGridCoordinatesYOfVirtual( UdmSize_t start_id, UdmSize_t end_id, DATA_TYPE* coords) { if (start_id <= 0) return 0; if (start_id > end_id) return 0; if (this->virtual_nodes.size() <= 0) return 0; if (end_id > this->virtual_nodes.size()) return 0; UdmSize_t n; UdmSize_t id = 0; DATA_TYPE coords_x, coords_y, coords_z; for (n=start_id-1; n<=end_id-1; n++) { this->virtual_nodes[n]->getCoords(coords_x, coords_y, coords_z); coords[id++] = coords_y; } return id; } template UdmSize_t UdmGridCoordinates::getGridCoordinatesYOfVirtual(UdmSize_t start_id, UdmSize_t end_id, float* coords); template UdmSize_t UdmGridCoordinates::getGridCoordinatesYOfVirtual(UdmSize_t start_id, UdmSize_t end_id, double* coords); /** * 仮想節点(ノード)のグリッド座標Zを取得する. * @param start_id 取得開始ID * @param end_id 取得終了ID * @param coords グリッド座標Z * @return 取得節点(ノード)数 */ template<class DATA_TYPE> UdmSize_t UdmGridCoordinates::getGridCoordinatesZOfVirtual( UdmSize_t start_id, UdmSize_t end_id, DATA_TYPE* coords) { if (start_id <= 0) return 0; if (start_id > end_id) return 0; if (this->virtual_nodes.size() <= 0) return 0; if (end_id > this->virtual_nodes.size()) return 0; UdmSize_t n; UdmSize_t id = 0; DATA_TYPE coords_x, coords_y, coords_z; for (n=start_id-1; n<=end_id-1; n++) { this->virtual_nodes[n]->getCoords(coords_x, coords_y, coords_z); coords[id++] = coords_z; } return id; } template UdmSize_t UdmGridCoordinates::getGridCoordinatesZOfVirtual(UdmSize_t start_id, UdmSize_t end_id, float* coords); template UdmSize_t UdmGridCoordinates::getGridCoordinatesZOfVirtual(UdmSize_t start_id, UdmSize_t end_id, double* coords); /** * 物理量フィールド情報を取得する. * @param solution_name 物理量データ名称 * @return 物理量フィールド情報 */ const UdmSolutionFieldConfig* UdmGridCoordinates::getSolutionFieldConfig(const std::string& solution_name) const { const UdmZone* zone = this->getParentZone(); if (zone == NULL) return NULL; const UdmFlowSolutions* solutions = zone->getFlowSolutions(); if (solutions == NULL) return NULL; return solutions->getSolutionField(solution_name); } /** * 出力CGNS:GrdiCoordinates名を取得する. * @return 出力CGNS:GrdiCoordinates名 */ const std::string& UdmGridCoordinates::getCgnsWriteGridCoordnates() const { return this->cgns_writegridcoordnates; } /** * 出力CGNS:GrdiCoordinates名を設定する. * @param gridcoordnates_name 出力CGNS:GrdiCoordinates名 */ void UdmGridCoordinates::setCgnsWriteGridCoordnates(const std::string& gridcoordnates_name) { this->cgns_writegridcoordnates = gridcoordnates_name; } /** * 出力CGNS:GrdiCoordinates名をクリアする. */ void UdmGridCoordinates::clearCgnsWriteGridCoordnates() { this->cgns_writegridcoordnates.clear(); } /** * 出力結果CGNS:GridCoordnates名があるかチェックする. * 出力結果CGNS:GridCoordnates名がある場合は1と返す。 * @return 1=出力結果CGNS:GridCoordnates名がある, 0=出力結果CGNS:GridCoordnates名がない。 */ int UdmGridCoordinates::getNumCgnsWriteGridCoordnates() const { return (this->cgns_writegridcoordnates.empty()?0:1); } /** * CGNS出力前の初期化を行う. * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::initializeWriteCgns() { this->clearCgnsWriteGridCoordnates(); return UDM_OK; } /** * 物理量データの初期化を行う. * @param solution_name 物理量名称 * @param value 初期設定値 * @return エラー番号 : UDM_OK | UDM_ERROR */ template<class VALUE_TYPE> UdmError_t UdmGridCoordinates::initializeValueEntities(const std::string& solution_name, VALUE_TYPE value) { // 物理量名称が存在するか?ノード(頂点)定義物理量であるかチェックする. const UdmZone* zone = this->getParentZone(); if (zone == NULL) return UDM_ERROR; const UdmFlowSolutions* solutions = zone->getFlowSolutions(); if (solutions == NULL) return UDM_ERROR; const UdmSolutionFieldConfig* config = solutions->getSolutionField(solution_name); if (config == NULL) { return UDM_ERROR_HANDLER(UDM_ERROR_INVALID_PARAMETERS, "not found solution_name=%s", solution_name.c_str()); } if (config->getGridLocation() != Udm_Vertex) { return UDM_ERROR_HANDLER(UDM_ERROR_INVALID_PARAMETERS, "solution_name[%s] is not Vertex.", solution_name.c_str()); } std::vector<UdmNode*>::iterator itr; for (itr=this->node_list.begin(); itr!=this->node_list.end(); itr++) { UdmNode* node = (*itr); node->initializeValue(solution_name, value); } return UDM_OK; } template UdmError_t UdmGridCoordinates::initializeValueEntities<int>(const std::string& solution_name, int value); template UdmError_t UdmGridCoordinates::initializeValueEntities<long long>(const std::string& solution_name, long long value); template UdmError_t UdmGridCoordinates::initializeValueEntities<float>(const std::string& solution_name, float value); template UdmError_t UdmGridCoordinates::initializeValueEntities<double>(const std::string& solution_name, double value); /** * MPIランク番号を取得する. * @return MPIランク番号 */ int UdmGridCoordinates::getMpiRankno() const { if (this->getParentZone() == NULL) return -1; if (this->getParentZone()->getParentModel() == NULL) return -1; return this->getParentZone()->getParentModel()->getMpiRankno(); } /** * MPIプロセス数を取得する. * @return MPIプロセス数 */ int UdmGridCoordinates::getMpiProcessSize() const { if (this->getParentZone() == NULL) return -1; if (this->getParentZone()->getParentModel() == NULL) return -1; return this->getParentZone()->getParentModel()->getMpiProcessSize(); } /** * CGNS:UdmInfoのランク番号を取得する. * @return CGNS:UdmInfoランク番号 */ int UdmGridCoordinates::getCgnsRankno() const { if (this->getParentZone() == NULL) return -1; if (this->getParentZone()->getParentModel() == NULL) return -1; return this->getParentZone()->getParentModel()->getCgnsRankno(); } /** * ランク番号とIDが一致している節点(ノード)を検索する. * 節点(ノード)の現在のランク番号とIDから検索する. * 存在しなければ、以前のランク番号とIDから検索する. * @param src_rankno ランク番号 * @param src_nodeid 節点(ノード)ID * @return 節点(ノード) */ UdmNode* UdmGridCoordinates::findNodeByGlobalId(int src_rankno, UdmSize_t src_nodeid) const { if (src_rankno < 0) return NULL; if (src_nodeid <= 0) return NULL; UdmNode *find_node = NULL; // グリッド構成ノードリストの配列添字として検索 find_node = this->getNodeById(src_nodeid); if (find_node != NULL) { if (find_node->getMyRankno() == src_rankno) { return find_node; } find_node = NULL; } // 2分探索でグローバルIDを検索する std::vector<UdmNode*>::const_iterator find_itr; find_itr = this->searchCurrentGlobalId(this->node_list, src_rankno, src_nodeid); if (find_itr != this->node_list.end()) { find_node = (*find_itr); return find_node; } // 以前のグローバルIDを検索する find_itr = this->searchPreviousGlobalId(this->node_list, src_rankno, src_nodeid); if (find_itr != this->node_list.end()) { find_node = (*find_itr); return find_node; } return NULL; } /** * Zoltan分割によるインポート節点(ノード)を追加する. * @param import_nodes インポート節点(ノード)リスト * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::importNodes(const std::vector<UdmNode*>& import_nodes) { UdmRankConnectivity* inner = this->getRankConnectivity(); if (inner == NULL) { return UDM_ERROR_HANDLER(UDM_ERROR_NULL_VARIABLE, "UdmRankConnectivity is null"); } std::vector<UdmNode*>::const_iterator itr; std::vector<UdmNode*>::const_iterator find_itr; std::vector<UdmNode*> insert_nodes; // 内部境界節点(ノード)のランク番号、ID検索テーブルを作成する。 inner->createSearchTable(); for (itr=import_nodes.begin(); itr!=import_nodes.end(); itr++) { UdmNode *find_node = inner->findMpiRankInfo(*itr); // 既存節点(ノード)であるかチェックする. if (find_node != NULL) continue; // 追加ノードの格納 insert_nodes.push_back(*itr); } // 格納した追加ノードを追加する for (itr=insert_nodes.begin(); itr!=insert_nodes.end(); itr++) { // インポート節点(ノード)を追加する. this->insertNode((*itr)); // 無効MPIランク情報を削除する (*itr)->removeMpiRankInfo((*itr)->getMyRankno(), 0); } return UDM_OK; } /** * 仮想節点(ノード)を追加する. * @param virtual_nodes 仮想節点(ノード)リスト * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::importVirtualNodes(const std::vector<UdmNode*>& virtual_nodes) { std::vector<UdmNode*>::const_iterator itr; std::vector<UdmNode*>::const_iterator found_itr; for (itr=virtual_nodes.begin(); itr!=virtual_nodes.end(); itr++) { UdmNode* node = (*itr); if (node->getRealityType() != Udm_Virtual) continue; // 既存仮想節点(ノード)が存在するかチェックする. found_itr = this->searchGlobalId(this->virtual_nodes, node); if (found_itr != this->virtual_nodes.end()) { continue; } // インポート節点(ノード)を追加する. this->insertVirtualNode(node); } // 仮想要素(セル)ローカルIDの再構築 this->rebuildVirtualNodes(); return UDM_OK; } /** * 内部境界管理クラスを取得する. * @return 内部境界管理クラス */ UdmRankConnectivity* UdmGridCoordinates::getRankConnectivity() const { if (this->parent_zone == NULL) return NULL; return this->parent_zone->getRankConnectivity(); } /** * 内部境界リストから節点(ノード)を削除する. * @param node 削除節点(ノード) * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::removeRankConnectivity(const UdmEntity* node) const { if (node == NULL) return UDM_ERROR; UdmRankConnectivity* inner = this->getRankConnectivity(); if (inner == NULL) { return UDM_ERROR; } // 内部境界リストから削除する. inner->removeBoundaryNode(node); return UDM_OK; } /** * 節点(ノード)のIDの再構築を行う。 * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::rebuildNodes() { UdmSize_t node_id = 0; std::vector<UdmNode*>::iterator itr; for (itr=this->node_list.begin(); itr!= this->node_list.end(); itr++) { UdmNode *node = (*itr); // 現在のIDを以前のIDに設定する. node_id = ++node_id; //if (node->getMyRankno() != this->getMpiRankno() || node->getId() != node_id) { node->addPreviousRankInfo(node->getMyRankno(), node->getId()); //} node->setId(node_id); // IDをインクリメントして設定する node->setLocalId(node_id); // ローカルIDを設定する node->setMyRankno(this->getMpiRankno()); } // 設定済み最大節点(ノード)ID this->max_nodeid = node_id; return UDM_OK; } /** * グリッド座標の基本情報を全プロセスに送信する. * すべてのプロセスにて同一グリッド座標情報が存在するかチェックする. * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::brodcastGridCoordinates() { int mpi_flag; int mpi_rankno; UdmError_t error = UDM_OK; // MPI初期化済みであるかチェックする. udm_mpi_initialized(&mpi_flag); if (!mpi_flag) { return UDM_ERROR_HANDLER(UDM_ERROR_INVALID_MPI, "Please execute MPI_Init beforehand."); } if (!(this->getMpiRankno() >= 0 && this->getMpiProcessSize() >= 1)) { return UDM_ERROR_HANDLER(UDM_ERROR_INVALID_MPI, "invalid mpi process [mpi_rankno=%d,mpi_num_process=%d].", this->getMpiRankno(), this->getMpiProcessSize()); } mpi_rankno = this->getMpiRankno(); UdmSerializeBuffer streamBuffer; UdmSerializeArchive archive(&streamBuffer); int buf_size = 0; char* buf = NULL; if (mpi_rankno == 0) { // シリアライズを行う:バッファーサイズ取得 archive << *this; buf_size = archive.getOverflowSize(); if (buf_size > 0) { // バッファー作成 buf = new char[buf_size]; streamBuffer.initialize(buf, buf_size); // シリアライズを行う archive << *this; } } // バッファーサイズ送信 udm_mpi_bcast(&buf_size, 1, MPI_INT, 0, this->getMpiComm()); if (buf_size <= 0) { return UDM_ERROR_HANDLER(UDM_ERROR_SERIALIZE, "buffer size is zero."); } if (buf == NULL) { // バッファー作成 buf = new char[buf_size]; } // UdmModelシリアライズバッファー送信 udm_mpi_bcast(buf, buf_size, MPI_CHAR, 0, this->getMpiComm()); // デシリアライズ UdmGridCoordinates mpi_grid; streamBuffer.initialize(buf, buf_size); archive >> mpi_grid; if (buf != NULL) { delete []buf; buf = NULL; } // グリッド座標情報が作成済みであるかチェックする. if (this->getNumNodes() == 0) { // グリッド座標情報未作成であるので、グリッド座標情報をコピーする. error = this->cloneGridCoordinates(mpi_grid); if (error != UDM_OK) { UDM_ERRORNO_HANDLER(error); } } // グリッド座標情報が存在するので、グリッド座標情報が同一であるかチェックする. else if (!this->equalsGridCoordinates(mpi_grid)) { error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "not equals GridCoordinates."); } // ACK if (udm_mpi_ack(&error, this->getMpiComm()) != UDM_OK) { return UDM_ERRORNO_HANDLER(UDM_ERROR_MPI_ACK); } return UDM_OK; } /** * グリッド座標の基本情報のシリアライズを行う. * @param archive シリアライズ・デシリアライズクラス */ UdmSerializeArchive& UdmGridCoordinates::serialize(UdmSerializeArchive& archive) const { // Genaral基本情報 // ID : CGNSノードID、要素ローカルID, ノードローカルID // CGNSノードのデータ型 UdmGeneral::serializeGeneralBase(archive, this->getId(), this->getDataType(), this->getName()); return archive; } /** * グリッド座標の基本情報のデシリアライズを行う. * @param archive シリアライズ・デシリアライズクラス */ UdmSerializeArchive& UdmGridCoordinates::deserialize(UdmSerializeArchive& archive) { UdmSize_t grid_id; UdmDataType_t grid_datatype; std::string grid_name; // Genaral基本情報 UdmGeneral::deserializeGeneralBase(archive, grid_id, grid_datatype, grid_name); this->setId(grid_id); this->setDataType(grid_datatype); this->setName(grid_name); return archive; } /** * グリッド座標の基本情報をコピーする. * @param src コピー元グリッド座標 * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::cloneGridCoordinates(const UdmGridCoordinates& src) { // ID this->setId(src.getId()); // データ型 this->setDataType(src.getDataType()); // 名前 this->setName(src.getName()); return UDM_OK; } /** * 同一グリッド座標情報であるかチェックする. * グリッド座標情報の基本情報が同じであるかチェックする. * @param model チェック対象グリッド座標情報 * @return true=同一 */ bool UdmGridCoordinates::equalsGridCoordinates(const UdmGridCoordinates& grid) const { if (this->getId() != grid.getId()) return false; if (this->getDataType() != grid.getDataType()) return false; if (this->getName() != grid.getName()) return false; return true; } /** * 仮想節点(ノード)リストを取得する. * @return 仮想節点(ノード)リスト */ const std::vector<UdmNode*>& UdmGridCoordinates::getVirtualNodes() const { return this->virtual_nodes; } /** * CGNS:GridCoordinatesが出力済みであるかチェックする. * @param filename CGNSファイル名 * @param index_base CGNSベースインデックス:デフォルト=1 * @param index_zone CGNSゾーンインデックス:デフォルト=1 * @return true=CGNS:GridCoordinatesが出力済み */ bool UdmGridCoordinates::existsCgnsGridCoordnates( const std::string& filename, int index_base, int index_zone) { int index_file; // CGNSファイルオープン if (cg_open(filename.c_str(), CG_MODE_READ, &index_file) != CG_OK) { // UDM_ERROR_HANDLER(UDM_ERROR_CGNS_OPENERROR, "filename=%s, cgns_error=%s", filename.c_str(), cg_get_error()); return false; } if (cg_goto(index_file, index_base, "Zone_t", index_zone, UDM_CGNS_NAME_GRIDCOORDINATES, 0, "end") != CG_OK) { return false; // CGNS:GridCoordinatesが存在しない. } return true; } /** * 自ランク番号以下と接続している節点(ノード)を除いた節点(ノード)数を取得する。 * 節点(ノード)数ー(接続節点数ー自ランク番号以上の接続節点数) * @return 自ランク番号以上の接続る節点数 */ UdmSize_t UdmGridCoordinates::getNumNodesWithoutLessRankno() const { UdmSize_t num_nodes = this->getNumNodes(); UdmRankConnectivity* rank_conn = this->getRankConnectivity(); if (rank_conn == NULL) { return UDM_ERROR_HANDLER(UDM_ERROR_NULL_VARIABLE, "UdmRankConnectivity is null"); } // 接続節点数 UdmSize_t num_conns = rank_conn->getNumBoundaryNodes(); if (num_conns <= 0) return num_nodes; if (num_conns > num_nodes) return num_nodes; // 自ランク番号以上の接続節点数 UdmSize_t num_conn_ranks = rank_conn->getNumNodesWithoutLessRankno(); if (num_conns < num_conn_ranks) return num_nodes; return num_nodes - (num_conns - num_conn_ranks); } /** * GridCoordinates名称のGridCoordinatesインデックスを取得する. * @param index_file CGNSファイルインデックス * @param index_base CGNSベースインデックス * @param index_zone CGNSゾーンインデックス * @param gridname GridCoordinates名称 * @return GridCoordinatesインデックス(GridCoordinates名称が存在しない場合は、0を返す) */ int UdmGridCoordinates::findCgnsGridCoordinates( int index_file, int index_base, int index_zone, const char* gridname) const { int num_grids = 0; int n; char cgns_name[33] = {0x00}; cg_ngrids(index_file, index_base, index_zone, &num_grids); if (num_grids <= 0) { return 0; } for (n=1; n<num_grids; n++) { cg_grid_read(index_file, index_base, index_zone, n, cgns_name); if (strcmp(cgns_name, gridname) == 0) { return n; } } return 0; } /** * 節点(ノード)の物理量データ値を取得する:スカラデータ. * @param [in] node_id 節点(ノード)ID(=1~) * @param [in] solution_name 物理量名 * @param [out] value 物理量データ値 * @return エラー番号 : UDM_OK | UDM_ERROR */ template<class VALUE_TYPE> UdmError_t UdmGridCoordinates::getSolutionScalar( UdmSize_t node_id, const std::string& solution_name, VALUE_TYPE& value) const { UdmEntity *entity = this->getNodeById(node_id); if (entity == NULL) return UDM_ERROR; return entity->getSolutionScalar<VALUE_TYPE>(solution_name, value); } /** * 節点(ノード)の物理量データ値を取得する:ベクトルデータ. * @param [in] node_id 節点(ノード)ID(=1~) * @param [in] solution_name 物理量名 * @param [out] values 物理量データ値リスト * @return ベクトルデータ数 */ template<class VALUE_TYPE> unsigned int UdmGridCoordinates::getSolutionVector( UdmSize_t node_id, const std::string& solution_name, VALUE_TYPE* values) const { UdmEntity *entity = this->getNodeById(node_id); if (entity == NULL) return 0; return entity->getSolutionVector<VALUE_TYPE>(solution_name, values); } /** * 節点(ノード)の物理量データ値を設定する:スカラデータ * @param node_id 節点(ノード)ID(=1~) * @param solution_name 物理量名 * @param value 物理量データ値 * @return エラー番号 : UDM_OK | UDM_ERROR */ template<class VALUE_TYPE> UdmError_t UdmGridCoordinates::setSolutionScalar( UdmSize_t node_id, const std::string& solution_name, VALUE_TYPE value) { UdmEntity *entity = this->getNodeById(node_id); if (entity == NULL) return UDM_ERROR; return entity->setSolutionScalar<VALUE_TYPE>(solution_name, value); } /** * 節点(ノード)の物理量データ値を設定する:ベクトルデータ * @param node_id 節点(ノード)ID(=1~) * @param solution_name 物理量名 * @param values 物理量データリスト * @param size 物理量データ数 * @return エラー番号 : UDM_OK | UDM_ERROR */ template<class VALUE_TYPE> UdmError_t UdmGridCoordinates::setSolutionVector( UdmSize_t node_id, const std::string& solution_name, const VALUE_TYPE* values, unsigned int size) { UdmEntity *entity = this->getNodeById(node_id); if (entity == NULL) return UDM_ERROR; return entity->setSolutionVector<VALUE_TYPE>(solution_name, values, size); } template UdmError_t UdmGridCoordinates::getSolutionScalar<int>(UdmSize_t node_id, const std::string& solution_name, int& value) const; template UdmError_t UdmGridCoordinates::getSolutionScalar<long long>(UdmSize_t node_id, const std::string& solution_name, long long& value) const; template UdmError_t UdmGridCoordinates::getSolutionScalar<float>(UdmSize_t node_id, const std::string& solution_name, float& value) const; template UdmError_t UdmGridCoordinates::getSolutionScalar<double>(UdmSize_t node_id, const std::string& solution_name, double& value) const; template unsigned int UdmGridCoordinates::getSolutionVector<int>(UdmSize_t node_id, const std::string& solution_name, int* values) const; template unsigned int UdmGridCoordinates::getSolutionVector<long long>(UdmSize_t node_id, const std::string& solution_name, long long* values) const; template unsigned int UdmGridCoordinates::getSolutionVector<float>(UdmSize_t node_id, const std::string& solution_name, float* values) const; template unsigned int UdmGridCoordinates::getSolutionVector<double>(UdmSize_t node_id, const std::string& solution_name, double* values) const; template UdmError_t UdmGridCoordinates::setSolutionScalar<int>(UdmSize_t node_id, const std::string& solution_name, int value); template UdmError_t UdmGridCoordinates::setSolutionScalar<long long>(UdmSize_t node_id, const std::string& solution_name, long long value); template UdmError_t UdmGridCoordinates::setSolutionScalar<float>(UdmSize_t node_id, const std::string& solution_name, float value); template UdmError_t UdmGridCoordinates::setSolutionScalar<double>(UdmSize_t node_id, const std::string& solution_name, double value); template UdmError_t UdmGridCoordinates::setSolutionVector<int>(UdmSize_t node_id, const std::string& solution_name, const int* values, unsigned int size); template UdmError_t UdmGridCoordinates::setSolutionVector<long long>(UdmSize_t node_id, const std::string& solution_name, const long long* values, unsigned int size); template UdmError_t UdmGridCoordinates::setSolutionVector<float>(UdmSize_t node_id, const std::string& solution_name, const float* values, unsigned int size); template UdmError_t UdmGridCoordinates::setSolutionVector<double>(UdmSize_t node_id, const std::string& solution_name, const double* values, unsigned int size); /** * CGNS:GridCoordinatesを出力する. * @param index_file CGNSファイルインデックス * @param index_base CGNSベースインデックス * @param index_zone CGNSゾーンインデックス * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::writeVirtualNodes(int index_file, int index_base, int index_zone) { char gridname[33] = {0x00}; int index_grid; UdmDataType_t datatype = Udm_RealSingle; DataType_t cgns_datatype; cgsize_t coords_size; cgsize_t virtual_size; cgsize_t actual_size; int cg_error = 0; UdmError_t udm_error = UDM_OK; // 出力CGNS:GridCoordinates名のクリア this->clearCgnsWriteGridCoordnates(); // ローカルIDを設定する. this->rebuildVirtualNodes(); // GridCoordinatesが存在するか sprintf(gridname, "GridCoordinates"); cg_error = 0; udm_error = UDM_OK; // CGNS:GridCoordinatesの出力先 index_grid = this->findCgnsGridCoordinates(index_file, index_base, index_zone, gridname); if (index_grid <= 0) { if (cg_grid_write(index_file,index_base,index_zone, gridname, &index_grid) != CG_OK) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_grid_write(gridname=%s)", gridname); } } if (cg_goto(index_file,index_base, "Zone_t", index_zone, "GridCoordinates_t",index_grid, "end") != CG_OK) { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_goto(index_grid=%d)", index_grid); } datatype = this->getDataType(); cgns_datatype = this->toCgnsDataType(datatype); actual_size = this->getNumNodes(); virtual_size = this->getNumVirtualNodes(); coords_size = actual_size + virtual_size; if (datatype == Udm_RealSingle) { float *coords = new float[coords_size]; // CoordinateX出力 this->getGridCoordinatesX(1, actual_size, (float*)coords); this->getGridCoordinatesXOfVirtual(1, virtual_size, (float*)coords + actual_size); if ((cg_error = cg_array_write("CoordinateX", cgns_datatype, 1, &coords_size, coords)) != CG_OK) { udm_error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_array_write(CoordinateX)"); } if (udm_error != UDM_OK) { delete []coords; return udm_error; } // CoordinateY出力 this->getGridCoordinatesY(1, actual_size, (float*)coords); this->getGridCoordinatesYOfVirtual(1, virtual_size, (float*)coords + actual_size); if ((cg_error = cg_array_write("CoordinateY", cgns_datatype, 1, &coords_size, coords)) != CG_OK) { udm_error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_array_write(CoordinateY)"); } if (udm_error != UDM_OK) { delete []coords; return udm_error; } // CoordinateZ出力 this->getGridCoordinatesY(1, actual_size, (float*)coords); this->getGridCoordinatesYOfVirtual(1, virtual_size, (float*)coords + actual_size); if ((cg_error = cg_array_write("CoordinateZ", cgns_datatype, 1, &coords_size, coords)) != CG_OK) { udm_error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_array_write(CoordinateZ)"); } if (udm_error != UDM_OK) { delete []coords; return udm_error; } delete []coords; } else if (datatype == Udm_RealDouble) { double *coords = new double[coords_size]; // CoordinateX出力 this->getGridCoordinatesX(1, actual_size, (double*)coords); this->getGridCoordinatesXOfVirtual(1, virtual_size, (double*)coords + actual_size); if ((cg_error = cg_array_write("CoordinateX", cgns_datatype, 1, &coords_size, coords)) != CG_OK) { udm_error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_array_write(CoordinateX)"); } if (udm_error != UDM_OK) { delete []coords; return udm_error; } // CoordinateY出力 this->getGridCoordinatesY(1, actual_size, (double*)coords); this->getGridCoordinatesYOfVirtual(1, virtual_size, (double*)coords + actual_size); if ((cg_error = cg_array_write("CoordinateY", cgns_datatype, 1, &coords_size, coords)) != CG_OK) { udm_error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_array_write(CoordinateY)"); } if (udm_error != UDM_OK) { delete []coords; return udm_error; } // CoordinateZ出力 this->getGridCoordinatesY(1, actual_size, (double*)coords); this->getGridCoordinatesYOfVirtual(1, virtual_size, (double*)coords + actual_size); if ((cg_error = cg_array_write("CoordinateZ", cgns_datatype, 1, &coords_size, coords)) != CG_OK) { udm_error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "failure : cg_array_write(CoordinateZ)"); } if (udm_error != UDM_OK) { delete []coords; return udm_error; } delete []coords; } else { return UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_GRIDCOORDINATES, "invalid coordinates datatype"); } if (udm_error != UDM_OK) return udm_error; // 出力CGNS:GridCoordinates名を設定する. this->setCgnsWriteGridCoordnates(std::string(gridname)); // CGNS:UdmRankConenctivityを書き込む. if (this->getRankConnectivity() != NULL) { if (this->getRankConnectivity()->writeCgns(index_file, index_base, index_zone) != UDM_OK) { udm_error = UDM_ERROR_HANDLER(UDM_ERROR_CGNS_INVALID_USERDEFINEDDATA, "failure : UdmRankConnectivity::writeCgns(index_file=%d, index_base=%d, index_zone=%d)", index_file, index_base, index_zone); } } return udm_error; } /** * 仮想節点(ノード)のIDの再構築を行う。 * ローカルIDに構成節点(ノード)+連番を設定する * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::rebuildVirtualNodes() { UdmSize_t node_id = this->node_list.size(); std::vector<UdmNode*>::iterator itr; for (itr=this->virtual_nodes.begin(); itr!= this->virtual_nodes.end(); itr++) { UdmNode *node = (*itr); node->setLocalId(++node_id); // IDをインクリメントして設定する } return UDM_OK; } /** * CGNS:GrdiCoordinatesを結合する. * @param dest_grid 結合GridCoordinates * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::joinCgnsGridCoordinates(UdmGridCoordinates* dest_grid) { UdmSize_t n; if (dest_grid == NULL) { return UDM_ERROR_HANDLER(UDM_ERROR_INVALID_PARAMETERS, "dest_grid is null."); } UdmRankConnectivity *inner_boundary = this->getRankConnectivity(); if (inner_boundary == NULL) { return UDM_ERROR_HANDLER(UDM_ERROR_NULL_VARIABLE, "UdmRankConnectivity is null."); } // MPI接続ランク番号, IDの検索テーブルを作成する. inner_boundary->createSearchMpiRankidTable(); UdmSize_t num_nodes = dest_grid->getNumNodes(); for (n=1; n<=num_nodes; n++) { UdmNode *dest_node = dest_grid->getNodeById(n); int dest_rankno = dest_node->getMyRankno(); UdmSize_t node_id = dest_node->getId(); UdmNode *src_node = NULL; if (dest_node->getNumMpiRankInfos() > 0) { // 内部境界から同一節点(ノード)を検索する src_node = inner_boundary->findMpiRankInfo(dest_rankno, node_id); } if (src_node != NULL) { UdmSize_t src_nodeid = src_node->getId(); int src_rankno = src_node->getMyRankno(); // 追加済み節点(ノード)である。 // 接続ランク番号,IDを削除する. src_node->removeMpiRankInfo(dest_rankno, node_id); // ランク番号,IDを退避する. src_node->addPreviousRankInfo(dest_rankno, node_id); // 共通節点を設定する. dest_node->setCommonNode(src_node); continue; } // ランク番号,IDを退避する. dest_node->addPreviousRankInfo(dest_rankno, node_id); // 節点(ノード)を挿入する. this->insertNode(dest_node); // 共通節点はなし。 dest_node->setCommonNode(NULL); } // UdmZoneのdeleteにてUdmNodeがdeleteされない様に挿入節点(ノード)をeraseする // 残りの節点(ノード)は同一節点(ノード)が存在するので、UdmZoneの削除にて削除する。 /******************** std::vector<UdmNode*>::reverse_iterator rev_itr; for (rev_itr=dest_grid->node_list.rbegin(); rev_itr!=dest_grid->node_list.rend(); rev_itr++) { UdmNode *node = (*rev_itr); if (node->getCommonNode() == NULL) { // 構成節点(ノード)リストから削除 dest_grid->node_list.erase( --(rev_itr.base()) ); } } ******************/ std::vector<UdmNode*>::iterator itr; for (itr=dest_grid->node_list.begin(); itr!=dest_grid->node_list.end(); ) { UdmNode *node = (*itr); if (node->getCommonNode() == NULL) { // 構成節点(ノード)リストから削除 itr = dest_grid->node_list.erase( itr ); continue; } itr++; } return UDM_OK; } /** * 以前のID、ランク番号をクリアする. */ void UdmGridCoordinates::clearPreviousInfos() { std::vector<UdmNode*>::iterator itr; for (itr=this->node_list.begin(); itr!= this->node_list.end(); itr++) { UdmNode *node = (*itr); node->clearPreviousInfos(); } return; } /** * 削除節点(ノード)リストを削除する. * @param remove_nodes 削除節点(ノード)リスト * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::removeNodes(const std::vector<UdmNode*>& remove_nodes) { std::vector<UdmNode*>::const_iterator itr; for (itr=remove_nodes.begin(); itr!=remove_nodes.end(); itr++) { UdmNode* node = (*itr); if (node != NULL) { node->setRemoveEntity(true); } } // 構成ノードから削除 UdmSize_t erase_size = this->node_list.size(); this->node_list.erase( std::remove_if( this->node_list.begin(), this->node_list.end(), std::mem_fun(&UdmEntity::isRemoveEntity)), this->node_list.end()); erase_size -= this->node_list.size(); if (erase_size < remove_nodes.size()) { // 仮想ノードから削除 erase_size += this->virtual_nodes.size(); this->virtual_nodes.erase( std::remove_if( this->virtual_nodes.begin(), this->virtual_nodes.end(), std::mem_fun(&UdmEntity::isRemoveEntity)), this->virtual_nodes.end()); erase_size -= this->virtual_nodes.size(); } // 内部境界リストから削除する UdmRankConnectivity* inner = this->getRankConnectivity(); if (inner != NULL) { // 内部境界リストから削除する. inner->removeBoundaryNodes(remove_nodes); } // 節点(ノード)の削除 for (itr=remove_nodes.begin(); itr!=remove_nodes.end(); itr++) { UdmNode* node = (*itr); if (node != NULL) { delete node; } } return UDM_OK; } /** * 内部境界情報を節点(ノード)に追加する. * @param node_id 節点(ノード)ID(1~) * @param rankno 接続先MPIランク番号(0~) * @param localid 接続先節点(ノード)ID(1~) * @return エラー番号 : UDM_OK | UDM_ERROR */ UdmError_t UdmGridCoordinates::insertRankConnectivity( UdmSize_t node_id, int rankno, UdmSize_t localid) { if (rankno < 0) return UDM_ERROR; if (localid <= 0) return UDM_ERROR; UdmNode *node = this->getNodeById(node_id); // 内部境界情報を追加する. node->addMpiRankInfo(rankno, localid); // 内部境界に追加する if (node->getNumMpiRankInfos() > 0) { if (this->getRankConnectivity() != NULL) { this->getRankConnectivity()->insertRankConnectivityNode(node); } } return UDM_OK; } /** * ランク番号とIDが一致している仮想節点(ノード)を検索する. * @param src_rankno ランク番号 * @param src_nodeid 節点(ノード)ID * @return 節点(ノード) */ UdmNode* UdmGridCoordinates::findVirtualNodeByGlobalId(int src_rankno, UdmSize_t src_nodeid) const { if (src_rankno < 0) return NULL; if (src_nodeid <= 0) return NULL; UdmNode *find_node = NULL; // グリッド構成ノードリストの配列添字として検索 find_node = this->getVirtualNodeById(src_nodeid); if (find_node != NULL) { if (find_node->getMyRankno() == src_rankno) { return find_node; } find_node = NULL; } // 2分探索でグローバルIDを検索する std::vector<UdmNode*>::const_iterator find_itr; find_itr = this->searchCurrentGlobalId(this->virtual_nodes, src_rankno, src_nodeid); if (find_itr != this->virtual_nodes.end()) { find_node = (*find_itr); return find_node; } return NULL; } /** * メモリサイズを取得する. * @return メモリサイズ */ size_t UdmGridCoordinates::getMemSize() const { UdmSize_t size = sizeof(*this); #ifdef _DEBUG printf("this size=%ld\n", sizeof(*this)); printf("node_list size=%ld [count=%ld] [offset=%ld]\n", sizeof(this->node_list), this->node_list.size(), offsetof(UdmGridCoordinates, node_list)); printf("virtual_nodes size=%ld [count=%ld] [offset=%ld]\n", sizeof(this->virtual_nodes), this->virtual_nodes.size(), offsetof(UdmGridCoordinates, virtual_nodes)); printf("parent_zone pointer size=%ld [offset=%ld]\n", sizeof(this->parent_zone), offsetof(UdmGridCoordinates, parent_zone)); printf("cgns_writegridcoordnates size=%ld [offset=%ld]\n", sizeof(this->cgns_writegridcoordnates), offsetof(UdmGridCoordinates, cgns_writegridcoordnates)); printf("max_nodeid size=%ld [offset=%ld]\n", sizeof(this->max_nodeid), offsetof(UdmGridCoordinates, max_nodeid)); size += this->node_list.size()*sizeof(UdmNode*); size += this->virtual_nodes.size()*sizeof(UdmNode*); #endif return size; } } /* namespace udm */
32.829349
207
0.637776
95f51e6d68125e62b3c13fd5ffbb14983da5ee3f
2,567
cpp
C++
yotta_modules/core-util/test/PoolAllocator/main.cpp
lbk003/mbed-cortexm
a4fcb5de906a49a7fa737d6a89fcf5590aa68d31
[ "Apache-2.0" ]
null
null
null
yotta_modules/core-util/test/PoolAllocator/main.cpp
lbk003/mbed-cortexm
a4fcb5de906a49a7fa737d6a89fcf5590aa68d31
[ "Apache-2.0" ]
null
null
null
yotta_modules/core-util/test/PoolAllocator/main.cpp
lbk003/mbed-cortexm
a4fcb5de906a49a7fa737d6a89fcf5590aa68d31
[ "Apache-2.0" ]
null
null
null
/* * PackageLicenseDeclared: Apache-2.0 * Copyright (c) 2015 ARM Limited * * 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 "core-util/PoolAllocator.h" #include "mbed-drivers/test_env.h" #include <stdio.h> #include <stdlib.h> using namespace mbed::util; void app_start(int, char**) { MBED_HOSTTEST_TIMEOUT(5); MBED_HOSTTEST_SELECT(default); MBED_HOSTTEST_DESCRIPTION(mbed-util pool allocator test); MBED_HOSTTEST_START("MBED_UTIL_POOL_ALLOCATOR_TEST"); // Allocate initial space for the pool const size_t elements = 10, element_size = 6; const size_t aligned_size = (element_size + MBED_UTIL_POOL_ALLOC_DEFAULT_ALIGN - 1) & ~(MBED_UTIL_POOL_ALLOC_DEFAULT_ALIGN - 1); size_t pool_size = PoolAllocator::get_pool_size(elements, element_size); MBED_HOSTTEST_ASSERT(pool_size == elements * aligned_size); void *start = malloc(pool_size); MBED_HOSTTEST_ASSERT(start != NULL); PoolAllocator allocator(start, elements, element_size); // Allocate all elements, checking for proper alignment and spacing void *p, *prev, *first; for (size_t i = 0; i < elements; i ++) { p = allocator.alloc(); MBED_HOSTTEST_ASSERT(p != NULL); // Check alignment MBED_HOSTTEST_ASSERT(((uint32_t)p & (MBED_UTIL_POOL_ALLOC_DEFAULT_ALIGN - 1)) == 0); // Check spacing if (i > 0) { MBED_HOSTTEST_ASSERT(((uint32_t)p - (uint32_t)prev) == aligned_size); } else { first = p; MBED_HOSTTEST_ASSERT(p == start); } prev = p; } // No more space in the pool, we should get NULL now MBED_HOSTTEST_ASSERT(allocator.alloc() == NULL); // Free the first element we allocated allocator.free(first); // Verify that we can allocate a single element now, and it has the same address // as the first element we allocated above p = allocator.alloc(); MBED_HOSTTEST_ASSERT(p == first); p = allocator.alloc(); MBED_HOSTTEST_ASSERT(p == NULL); MBED_HOSTTEST_RESULT(true); }
34.689189
132
0.687183
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 : architsingh456@gmail.com * @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
95f76b3ce45e04a7abf750e2e3d9b2f6d346a253
6,160
cpp
C++
1.Race Condition/RaceCondition/main.cpp
Cabrra/Multithreading
0259f6cb48534e583818b10274698df130fd222e
[ "MIT" ]
null
null
null
1.Race Condition/RaceCondition/main.cpp
Cabrra/Multithreading
0259f6cb48534e583818b10274698df130fd222e
[ "MIT" ]
null
null
null
1.Race Condition/RaceCondition/main.cpp
Cabrra/Multithreading
0259f6cb48534e583818b10274698df130fd222e
[ "MIT" ]
null
null
null
// Include file and line numbers for memory leak detection for visual studio in debug mode // NOTE: The current implementation of C++11 shipped with Visual Studio 2012 will leak a single // 44-byte mutex (at_thread_exit_mutex) internally if any threads have been created. This // will show up in the output window without a filename or line number. #if defined _MSC_VER && defined _DEBUG #include <crtdbg.h> #define new new(_NORMAL_BLOCK, __FILE__, __LINE__) #define ENABLE_LEAK_DETECTION() _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF) #else #define ENABLE_LEAK_DETECTION() #endif #define WAIT_FOR_THREAD(r) if ((r)->joinable()) (r)->join(); #include <iostream> #include <thread> #include <vector> #include <mutex> #include <condition_variable> using namespace std; struct ThreadStruct { // ID of the thread int id; // Length of the shared string int sharedStringLength; // Number of strings a single thread will generate int numberOfStringsToGenerate; // Amount of time to sleep before generating strings int waitTime; // Shared string that will be generate in each thread. This memory is shared among all threads. char *sharedString; //my data int runType; std::mutex* Mutex; std::condition_variable* cv; int* currID; }; /////////////////////////////////////////////////////////////////////////////////////////// // Prompts the user to press enter and waits for user input /////////////////////////////////////////////////////////////////////////////////////////// void Pause() { printf("Press enter to continue\n"); getchar(); } /////////////////////////////////////////////////////////////////////////////////// // Entry point for worker threads. // // Arguments: // threadData - Pointer to per-thread data for this thread. /////////////////////////////////////////////////////////////////////////////////// void ThreadEntryPoint(ThreadStruct *threadData) { if (threadData->runType == 2) threadData->Mutex->lock(); if (threadData->runType == 3) { std::unique_lock<std::mutex> locked(*threadData->Mutex); threadData->cv->wait(locked, [threadData](){return *threadData->currID == threadData->id; }); } for(int i = 0; i < threadData->numberOfStringsToGenerate; i++) { if (threadData->waitTime != 0) { // Blocks the current thread for a given amount of time. std::this_thread::sleep_for(std::chrono::milliseconds(threadData->waitTime)); } if (threadData->runType == 1) //type 1 threadData->Mutex->lock(); for (int j = 0; j < threadData->sharedStringLength; j++) { std::this_thread::sleep_for(std::chrono::milliseconds(1)); threadData->sharedString[j] = 'A' + threadData->id; } printf("Thread %d: %s\n", threadData->id, threadData->sharedString); if (threadData->runType == 1) //type 1 threadData->Mutex->unlock(); } if (threadData->runType == 2) threadData->Mutex->unlock(); if (threadData->runType == 3) { (*threadData->currID)++; threadData->cv->notify_all(); } } int main(int argc, char** argv) { ENABLE_LEAK_DETECTION(); int threadCount = 0; int sharedStringLength = 0; int numberOfStringsToGenerate = 0; int waitTime = 0; char *sharedString = nullptr; int runType = 0; ThreadStruct *perThreadData = nullptr; if (argc - 1 != 5) { fprintf(stderr, "Error: missing or incorrect command line arguments\n\n"); fprintf(stderr, "Usage: RaceCondition threadCount sharedStringLength numberOfStringsToGenerate waitTime runType\n\n"); fprintf(stderr, "Arguments:\n"); fprintf(stderr, " threadCount Number of threads to create.\n"); fprintf(stderr, " sharedStringLength Length of string to generate.\n"); fprintf(stderr, " numberOfStringsToGenerate Number of strings to generate per thread.\n"); fprintf(stderr, " waitTime Time to wait before generating the string.\n"); fprintf(stderr, " runType The run type.\n\n"); Pause(); return 1; } threadCount = atoi(argv[1]); sharedStringLength = atoi(argv[2]); numberOfStringsToGenerate = atoi(argv[3]); waitTime = atoi(argv[4]); runType = atoi(argv[5]); if(threadCount < 0 || sharedStringLength < 0 || numberOfStringsToGenerate < 0 || waitTime < 0 || runType < 0) { fprintf(stderr, "Error: All arguments must be positive integer values.\n"); Pause(); return 1; } printf("%d thread(s), string sharedStringLength %d, %d iterations, %d ms pause\n", threadCount, sharedStringLength, numberOfStringsToGenerate, waitTime); sharedString = new char[sharedStringLength + 1]; memset(sharedString, 0, sharedStringLength + 1); perThreadData = new ThreadStruct[threadCount]; //container to store the thread classes std::vector<std::thread*> myThreads; std::mutex myMutex = std::mutex(); std::condition_variable myCV = std::condition_variable(); int currentID = 0; for (int i = threadCount - 1; i >= 0; i--) { perThreadData[i].id = i; perThreadData[i].sharedStringLength = sharedStringLength; perThreadData[i].numberOfStringsToGenerate = numberOfStringsToGenerate; perThreadData[i].waitTime = waitTime; perThreadData[i].sharedString = sharedString; //my variables perThreadData[i].runType = runType; perThreadData[i].Mutex = &myMutex; perThreadData[i].cv = &myCV; perThreadData[i].currID = &currentID; //Setup any additional variables in perThreadData and start the threads. std::thread* thre = new std::thread(ThreadEntryPoint, &perThreadData[i]); myThreads.push_back(thre); } /////////////////////////////////////////////////////////////////////////////////// // Wait for all of the threads to finish. Since we are using // Joinable threads we must Join each one. Joining a thread will cause // the calling thread (main in this case) to block until the thread being // joined has completed executing. /////////////////////////////////////////////////////////////////////////////////// for (int i = 0; i < threadCount; i++) WAIT_FOR_THREAD(myThreads[i]); for (int i = 0; i < threadCount; i++) { delete myThreads[i]; } delete[] sharedString; delete[] perThreadData; Pause(); return 0; }
32.083333
120
0.641396
95f98cdeb21f069a00008843f3f93c41ab1c6da8
310
cpp
C++
aql/benchmark/lib_18/class_6.cpp
menify/sandbox
32166c71044f0d5b414335b2b6559adc571f568c
[ "MIT" ]
null
null
null
aql/benchmark/lib_18/class_6.cpp
menify/sandbox
32166c71044f0d5b414335b2b6559adc571f568c
[ "MIT" ]
null
null
null
aql/benchmark/lib_18/class_6.cpp
menify/sandbox
32166c71044f0d5b414335b2b6559adc571f568c
[ "MIT" ]
null
null
null
#include "class_6.h" #include "class_0.h" #include "class_8.h" #include "class_5.h" #include "class_7.h" #include "class_4.h" #include <lib_8/class_9.h> #include <lib_13/class_3.h> #include <lib_13/class_2.h> #include <lib_0/class_0.h> #include <lib_11/class_6.h> class_6::class_6() {} class_6::~class_6() {}
20.666667
27
0.712903
2503e048a00ec653a7ee4ad553e908b8545f859c
8,922
cpp
C++
ds/security/services/scerpc/xml-jet/secman/securitydatabase.cpp
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
ds/security/services/scerpc/xml-jet/secman/securitydatabase.cpp
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
ds/security/services/scerpc/xml-jet/secman/securitydatabase.cpp
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
/*++ Copyright (c) 2002 Microsoft Corporation Module Name: SecurityDatabase.cpp Abstract: Implementation of CSecurityDatabase interface SecurityDatabase is a COM interface that allows users to perform basic operations on SCE security databases such as analysis, import and export. This is a bare implementation just to expose export functionality of SCE analysis databases. Still needs work. Author: Steven Chan (t-schan) July 2002 --*/ #include <nt.h> #include <ntrtl.h> #include <nturtl.h> #include <windows.h> #include <string.h> #include <shlwapi.h> #include <winnlsp.h> #include <iostream.h> #include "stdafx.h" #include "SecMan.h" #include "SecurityDatabase.h" #include "SceXMLLogWriter.h" #include "SceAnalysisReader.h" #include "SceLogException.h" #include "secedit.h" //REMOVE ONCE DEMO IS DONE! CSecurityDatabase::CSecurityDatabase() { bstrFileName=L""; myModuleHandle=GetModuleHandle(L"SecMan.dll"); } STDMETHODIMP CSecurityDatabase::get_FileName(BSTR *pVal) { return bstrFileName.CopyTo(pVal); } STDMETHODIMP CSecurityDatabase::put_FileName(BSTR newVal) { bstrFileName = newVal; return S_OK; } STDMETHODIMP CSecurityDatabase::get_MachineName(BSTR *pVal) { return E_NOTIMPL; } STDMETHODIMP CSecurityDatabase::put_MachineName(BSTR newVal) { return E_NOTIMPL; } STDMETHODIMP CSecurityDatabase::ImportTemplateFile(BSTR FileName) { // IMPLEMENTED ONLY FOR DEMO!!! // Still needs work to convert SCESTATUS result code to HRESULT SceConfigureSystem(NULL, FileName, bstrFileName, NULL, SCE_OVERWRITE_DB | SCE_NO_CONFIG, AREA_ALL, NULL, NULL, NULL ); return S_OK; } STDMETHODIMP CSecurityDatabase::ImportTemplateString(BSTR TemplateString) { return E_NOTIMPL; } STDMETHODIMP CSecurityDatabase::Analyze() { // IMPLEMENTED ONLY FOR DEMO!!! // Still needs work to convert SCESTATUS result code to HRESULT SceAnalyzeSystem(NULL, NULL, bstrFileName, NULL, SCE_UPDATE_DB, AREA_ALL, NULL, NULL, NULL); return S_OK; } STDMETHODIMP CSecurityDatabase::ExportAnalysisToXML(BSTR FileName, BSTR ErrorLogFileName) /*++ Routine Description: exports the analysis information from this SecurityDatabase to FileName Arguments: FileName: XML file to export to ErrorLogFileName: Error log Return Value: none --*/ { HANDLE hLogFile=NULL; HRESULT result=S_OK; SceXMLLogWriter *LogWriter=NULL; SceAnalysisReader *AnalysisReader=NULL; // // initialize logfile if necessary // if log file fails to be created, we just go about not logging // (a parameter of NULL for log file handle to SceAnalysisReader::ExportAnalysis // indicates no logging // if (ErrorLogFileName!=NULL) { hLogFile = CreateFile(ErrorLogFileName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); } try { trace(IDS_LOG_START_EXPORT, hLogFile); LogWriter = new SceXMLLogWriter(); AnalysisReader = new SceAnalysisReader(myModuleHandle, bstrFileName); AnalysisReader->ExportAnalysis(LogWriter, hLogFile); trace(IDS_LOG_SAVING, hLogFile); trace(FileName, hLogFile); trace(L"\n\r\n\r", hLogFile); LogWriter->SaveAs(FileName); trace(IDS_LOG_SUCCESS, hLogFile); } catch(SceLogException *e) { switch (e->ErrorType) { case SceLogException::SXERROR_INTERNAL: trace(IDS_LOG_ERROR_INTERNAL, hLogFile); result=E_UNEXPECTED; break; case SceLogException::SXERROR_OS_NOT_SUPPORTED: trace(IDS_LOG_ERROR_OS_NOT_SUPPORTED, hLogFile); result=ERROR_OLD_WIN_VERSION; break; case SceLogException::SXERROR_INIT: trace(IDS_LOG_ERROR_INTERNAL, hLogFile); result=ERROR_MOD_NOT_FOUND; break; case SceLogException::SXERROR_INIT_MSXML: trace(IDS_LOG_ERROR_INIT_MSXML, hLogFile); result=ERROR_MOD_NOT_FOUND; break; case SceLogException::SXERROR_SAVE: trace(IDS_LOG_ERROR_SAVE, hLogFile); result=ERROR_WRITE_FAULT; break; case SceLogException::SXERROR_SAVE_INVALID_FILENAME: trace(IDS_LOG_ERROR_SAVE_INVALID_FILENAME, hLogFile); result=ERROR_INVALID_NAME; break; case SceLogException::SXERROR_SAVE_ACCESS_DENIED: trace(IDS_LOG_ERROR_SAVE_ACCESS_DENIED, hLogFile); result=E_ACCESSDENIED; break; case SceLogException::SXERROR_OPEN: trace(IDS_LOG_ERROR_OPEN, hLogFile); result=ERROR_OPEN_FAILED; break; case SceLogException::SXERROR_OPEN_FILE_NOT_FOUND: trace(IDS_LOG_ERROR_OPEN_FILE_NOT_FOUND, hLogFile); result=ERROR_FILE_NOT_FOUND; break; case SceLogException::SXERROR_READ: trace(IDS_LOG_ERROR_READ, hLogFile); result=ERROR_READ_FAULT; break; case SceLogException::SXERROR_READ_NO_ANALYSIS_TABLE: trace(IDS_LOG_ERROR_READ_NO_ANALYSIS_TABLE, hLogFile); result=ERROR_READ_FAULT; break; case SceLogException::SXERROR_READ_NO_CONFIGURATION_TABLE: trace(IDS_LOG_ERROR_READ_NO_CONFIGURATION_TABLE, hLogFile); result=ERROR_READ_FAULT; break; case SceLogException::SXERROR_READ_ANALYSIS_SUGGESTED: trace(IDS_LOG_ERROR_READ_ANALYSIS_SUGGESTED, hLogFile); result=ERROR_READ_FAULT; break; case SceLogException::SXERROR_INSUFFICIENT_MEMORY: trace(IDS_LOG_ERROR_INSUFFICIENT_MEMORY, hLogFile); result=E_OUTOFMEMORY; break; default: trace(IDS_LOG_ERROR_UNEXPECTED, hLogFile); result=E_UNEXPECTED; break; } trace (IDS_LOG_ERROR_DEBUGINFO, hLogFile); trace (e->szDebugInfo, hLogFile); trace (L"\n\r",hLogFile); trace (IDS_LOG_ERROR_AREA, hLogFile); trace (e->szArea, hLogFile); trace (L"\n\r",hLogFile); trace (IDS_LOG_ERROR_SETTING, hLogFile); trace (e->szSettingName, hLogFile); delete e; } catch(...){ trace(IDS_LOG_ERROR_UNEXPECTED, hLogFile); result = E_UNEXPECTED; } if (NULL!=LogWriter) { delete LogWriter; LogWriter=NULL; } if (NULL!=AnalysisReader) { delete AnalysisReader; AnalysisReader=NULL; } if (NULL!=hLogFile) { CloseHandle(hLogFile); } return result; } void CSecurityDatabase::trace( PCWSTR szBuffer, HANDLE hLogFile ) /*++ Routine Description: Internal method to trace info to an error log. Arguments: szBuffer: string to be added to log hLogFile: handle of error log file Return Value: none --*/ { DWORD dwNumWritten; if ((NULL!=hLogFile) && (NULL!=szBuffer)) { WriteFile(hLogFile, szBuffer, wcslen(szBuffer)*sizeof(WCHAR), &dwNumWritten, NULL); } } void CSecurityDatabase::trace( UINT uID, HANDLE hLogFile ) /*++ Routine Description: Internal method to trace info to an error log. Arguments: uID: ID of string to be added to log hLogFile: handle of error log file Return Value: none --*/ { DWORD dwNumWritten; WCHAR szTmpStringBuffer[512]; if (NULL!=hLogFile) { LoadString(myModuleHandle, uID, szTmpStringBuffer, sizeof(szTmpStringBuffer)/sizeof(WCHAR)); WriteFile(hLogFile, szTmpStringBuffer, wcslen(szTmpStringBuffer)*sizeof(WCHAR), &dwNumWritten, NULL); } }
27.20122
90
0.580924
2503e7a6e385bccb094db584c03c8399d1f98eab
1,538
cc
C++
ChiTech/ChiMesh/SurfaceMesher/Predefined/surfmesher_predefined_02_execute.cc
Jrgriss2/chi-tech
db75df761d5f25ca4b79ee19d36f886ef240c2b5
[ "MIT" ]
7
2019-09-10T12:16:08.000Z
2021-05-06T16:01:59.000Z
ChiTech/ChiMesh/SurfaceMesher/Predefined/surfmesher_predefined_02_execute.cc
Jrgriss2/chi-tech
db75df761d5f25ca4b79ee19d36f886ef240c2b5
[ "MIT" ]
72
2019-09-04T15:00:25.000Z
2021-12-02T20:47:29.000Z
ChiTech/ChiMesh/SurfaceMesher/Predefined/surfmesher_predefined_02_execute.cc
Jrgriss2/chi-tech
db75df761d5f25ca4b79ee19d36f886ef240c2b5
[ "MIT" ]
41
2019-09-02T15:33:31.000Z
2022-02-10T13:26:49.000Z
#include "surfmesher_predefined.h" #include "../../MeshHandler/chi_meshhandler.h" #include "../../Region/chi_region.h" #include "../../Boundary/chi_boundary.h" #include<iostream> #include <chi_log.h> extern ChiLog& chi_log; void chi_mesh::SurfaceMesherPredefined::Execute() { chi_log.Log(LOG_0VERBOSE_1) << "SurfaceMesherPredefined executed"; //================================================== Get the current handler chi_mesh::MeshHandler* mesh_handler = chi_mesh::GetCurrentHandler(); //================================================== Check empty region list if (mesh_handler->region_stack.empty()) { chi_log.Log(LOG_ALLERROR) << "SurfaceMesherPredefined: No region added."; exit(EXIT_FAILURE); } //================================================== Loop over all regions // std::vector<chi_mesh::Region*>::iterator region_iter; // for (region_iter = mesh_handler->region_stack.begin(); // region_iter != mesh_handler->region_stack.end(); // region_iter++) for (auto region : mesh_handler->region_stack) { // chi_mesh::Region* region = *region_iter; //=========================================== Check for interfaces //=========================================== Clear non-initial continuums // region->volume_mesh_continua.clear(); //=========================================== Create new continuum // chi_mesh::MeshContinuumPtr remeshed_surfcont = chi_mesh::MeshContinuum::New(); // region->volume_mesh_continua.push_back(remeshed_surfcont); } }
34.177778
84
0.579324
25079ddaa0334b783ca3811633d9d391432c24e8
4,299
cpp
C++
arduino/ledpoi_v2/Colour.cpp
Spherculism/reaktor
33892582497a5ca53d1141bdb4b6bbe282c5c00f
[ "MIT" ]
2
2016-05-11T23:55:48.000Z
2016-05-17T10:38:57.000Z
arduino/ledpoi_v2/Colour.cpp
Spherculism/reaktor
33892582497a5ca53d1141bdb4b6bbe282c5c00f
[ "MIT" ]
1
2015-01-10T09:11:14.000Z
2015-01-10T09:11:14.000Z
arduino/ledpoi_v2/Colour.cpp
Spherculism/reaktor
33892582497a5ca53d1141bdb4b6bbe282c5c00f
[ "MIT" ]
null
null
null
/* Library for RGB and HSV colour settings of two LEDs. Input is in form of a struct, {R, G, B, H, S, V, end} */ #include "WProgram.h" #include "Colour.h" #include "MyTypes.h" // Code that gets called on import of colour class Colour::Colour(byte pointless) // needs an input { // prepare pins for output - DO NOT CHANGE // these pins are also used in function byRGB pinMode(10, OUTPUT);//red, a pinMode(9, OUTPUT);//green, a pinMode(6, OUTPUT);//blue, a pinMode(5, OUTPUT);//red, b pinMode(11, OUTPUT);//green, b pinMode(3, OUTPUT);//blue, b // dim curve, as eyes don't perceive brightness linearly byte dim_curve[] = { 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 22, 22, 22, 23, 23, 24, 24, 25, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 32, 32, 33, 33, 34, 35, 35, 36, 36, 37, 38, 38, 39, 40, 40, 41, 42, 43, 43, 44, 45, 46, 47, 48, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 73, 74, 75, 76, 78, 79, 81, 82, 83, 85, 86, 88, 90, 91, 93, 94, 96, 98, 99, 101, 103, 105, 107, 109, 110, 112, 114, 116, 118, 121, 123, 125, 127, 129, 132, 134, 136, 139, 141, 144, 146, 149, 151, 154, 157, 159, 162, 165, 168, 171, 174, 177, 180, 183, 186, 190, 193, 196, 200, 203, 207, 211, 214, 218, 222, 226, 230, 234, 238, 242, 248, 255, }; for (int i=1; i <= 256; i++) {_dim_curve[i]=dim_curve[i];} //set default colour values Col black = {0,0,0}; Col white = {255,255,255}; Col red = {255,0,0}; Col yellow = {255,255,0}; Col green = {0,255,0}; Col cyan = {0,255,255}; Col blue = {0,0,255}; Col magenta = {255,0,255}; } // set LED to RGB void Colour::byRGB(RGBHSV input) { if (!input.e) { analogWrite(10, 255-_dim_curve[input.R]); analogWrite(9 , 255-_dim_curve[input.G]); analogWrite(6 , 255-_dim_curve[input.B]); } else { analogWrite(5 , 255-_dim_curve[input.R]); analogWrite(11, 255-_dim_curve[input.G]); analogWrite(3 , 255-_dim_curve[input.B]); } } // set LED to HSV void Colour::byHSV(RGBHSV &input) { if (input.H > 360){ input.H = input.H-360; } else if (input.H < 0){ input.H=input.H+360; } // sat = input.S; // val = input.V; val = _dim_curve[input.V]; sat = 255-_dim_curve[255-input.S]; int base; if (sat == 0) { // Acromatic color (gray). Hue doesn't mind. input.R = val; input.G = val; input.B = val; } else { base = ((255 - sat) * val)>>8; switch(input.H/60) { case 0: input.R = val; input.G = (((val-base)*input.H)/60)+base; input.B = base; break; case 1: input.R = (((val-base)*(60-(input.H%60)))/60)+base; input.G = val; input.B = base; break; case 2: input.R = base; input.G = val; input.B = (((val-base)*(input.H%60))/60)+base; break; case 3: input.R = base; input.G = (((val-base)*(60-(input.H%60)))/60)+base; input.B = val; break; case 4: input.R = (((val-base)*(input.H%60))/60)+base; input.G = base; input.B = val; break; case 5: input.R = val; input.G = base; input.B = (((val-base)*(60-(input.H%60)))/60)+base; break; } } byRGB(input); } // set RGB to triplet void Colour::setRGB(RGBHSV &input, byte red, byte grn, byte blu) { input.R = red; input.G = grn; input.B = blu; } // set HSV to triplet void Colour::setHSV(RGBHSV &input, int hue, byte sat, byte val) { input.H = hue; input.S = sat; input.V = val; } // set RGB to triplet void Colour::setCOL(RGBHSV &input, Col col) { input.R = col.R; input.G = col.G; input.B = col.B; }
30.062937
83
0.510119
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
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
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
251823b176ebd495769eb2f4a4b2245d747743ac
4,026
hpp
C++
Kiwi_External.hpp
Musicoll/KiwiExternal
1c1db8e324e6fc96c4b4df54c5a2535f406aa477
[ "MIT" ]
null
null
null
Kiwi_External.hpp
Musicoll/KiwiExternal
1c1db8e324e6fc96c4b4df54c5a2535f406aa477
[ "MIT" ]
null
null
null
Kiwi_External.hpp
Musicoll/KiwiExternal
1c1db8e324e6fc96c4b4df54c5a2535f406aa477
[ "MIT" ]
null
null
null
// // Kiwi_External.h // Kiwi_External // // Created by Pierre on 04/04/2018. // Copyright © 2018 Pierre. All rights reserved. // #pragma once #include <cstdlib> #include <stdexcept> #include <string> #include <vector> //#include <variant> #ifdef _WIN32 #ifdef KIWI_LIBRARY_EXPORTS #define KIWI_LIBRARY_EXTERN __declspec(dllexport) #else #define KIWI_LIBRARY_EXTERN __declspec(dllimport) #endif #else #define KIWI_LIBRARY_EXTERN #endif namespace kiwi { namespace external { #ifdef KIWI_DSP_FLOAT typedef float sample_t; #else typedef double sample_t; #endif typedef std::runtime_error kerror_t; //typedef std::variant<std::string, double> atom_t; typedef std::vector<std::vector<sample_t>> buffer_t; // ==================================================================================== // // OBJECT // // ==================================================================================== // class Object { public: // methods //! @brief The constructor. //! @param ninputs The number of inputs. //! @param noutputs The number of outputs. inline constexpr Object(const size_t ninputs, const size_t noutputs) noexcept : m_ninputs(ninputs), m_noutputs(noutputs) {} //! @brief The destructor. virtual ~Object() = default; //! @brief Gets the current number of inputs. inline size_t getNumberOfInputs() const noexcept {return m_ninputs;} //! @brief Gets the current number of outputs. inline size_t getNumberOfOutputs() const noexcept {return m_noutputs;} //! @brief Receives asynchonous messages. //! @details The method is used to communicate asynchronously with the object. If\n //! something is not valid, you should throw an errot_t. //! @param message The message. //virtual void receive(std::vector<atom_t> const& message) {} //! @brief Prepares everything for the perform method. //! @details You should use this method to check the vector size, the sample rate. If\n //! something is not valid, you should throw an errot_t. //! @param samplerate The sample rate. //! @param blocksize The number of samples per audio block. //! @see perform() and release() virtual void prepare(const size_t samplerate, const size_t blocksize) {} //! @brief Performs the digital signal processing. //! @details Triggers the callback set during prepare phase. //! @param input The input audio buffer. //! @param output The output audio buffer. //! @see prepare() and release() virtual void perform(buffer_t const& input, buffer_t& output) noexcept = 0; //! @brief Releases everything after the digital signal processing. //! @details You can use this method to free the memory allocated during the call of //! the prepare method for example. //! @see prepare() and perform() virtual void release() {} private: // members const size_t m_ninputs; const size_t m_noutputs; }; } } typedef kiwi::external::Object *object_creator(void); typedef void object_disposer(kiwi::external::Object *); extern "C" KIWI_LIBRARY_EXTERN kiwi::external::Object* createObject(); extern "C" KIWI_LIBRARY_EXTERN void freeObject(kiwi::external::Object* c); #define KIWI_LIBRARY_DECLARE(CLASSNAME) \ extern "C" KIWI_LIBRARY_EXTERN kiwi::external::Object* create_object() { return new CLASSNAME(); } \ extern "C" KIWI_LIBRARY_EXTERN void free_object(kiwi::external::Object* c) { delete c; }
37.277778
100
0.577
2519cdd014be2f8ae012d413d418b32188482693
123
cpp
C++
bookcode/cproject/namespace/one.cpp
zhangymPerson/Think-in-java-note
b89ca3b90ad3d43d010e4764d06ee5ffff8e118d
[ "Apache-2.0" ]
null
null
null
bookcode/cproject/namespace/one.cpp
zhangymPerson/Think-in-java-note
b89ca3b90ad3d43d010e4764d06ee5ffff8e118d
[ "Apache-2.0" ]
3
2021-12-14T20:50:59.000Z
2021-12-18T18:26:01.000Z
bookcode/cproject/namespace/one.cpp
zhangymPerson/Think-in-java-note
b89ca3b90ad3d43d010e4764d06ee5ffff8e118d
[ "Apache-2.0" ]
null
null
null
#include "iostream" using namespace std; namespace one { void fun() { cout << "echo one func()\n"; } }
12.3
36
0.544715
251c715ca5539cd71d9f6f3f4f3adbaef47d7759
2,550
cc
C++
chromeos/dbus/shill/fake_modem_messaging_client.cc
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
14,668
2015-01-01T01:57:10.000Z
2022-03-31T23:33:32.000Z
chromeos/dbus/shill/fake_modem_messaging_client.cc
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
86
2015-10-21T13:02:42.000Z
2022-03-14T07:50:50.000Z
chromeos/dbus/shill/fake_modem_messaging_client.cc
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
5,941
2015-01-02T11:32:21.000Z
2022-03-31T16:35:46.000Z
// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chromeos/dbus/shill/fake_modem_messaging_client.h" #include <algorithm> #include <string> #include <vector> #include "base/callback.h" #include "dbus/object_path.h" namespace chromeos { FakeModemMessagingClient::FakeModemMessagingClient() = default; FakeModemMessagingClient::~FakeModemMessagingClient() = default; void FakeModemMessagingClient::SetSmsReceivedHandler( const std::string& service_name, const dbus::ObjectPath& object_path, const SmsReceivedHandler& handler) { sms_received_handlers_.insert( std::pair<dbus::ObjectPath, SmsReceivedHandler>(object_path, handler)); message_paths_map_.insert( std::pair<dbus::ObjectPath, std::vector<dbus::ObjectPath>>(object_path, {})); } void FakeModemMessagingClient::ResetSmsReceivedHandler( const std::string& service_name, const dbus::ObjectPath& object_path) { sms_received_handlers_[object_path].Reset(); } void FakeModemMessagingClient::Delete(const std::string& service_name, const dbus::ObjectPath& object_path, const dbus::ObjectPath& sms_path, VoidDBusMethodCallback callback) { std::vector<dbus::ObjectPath> message_paths = message_paths_map_[object_path]; auto iter = find(message_paths.begin(), message_paths.end(), sms_path); if (iter != message_paths.end()) message_paths.erase(iter); std::move(callback).Run(true); } void FakeModemMessagingClient::List(const std::string& service_name, const dbus::ObjectPath& object_path, ListCallback callback) { std::move(callback).Run(message_paths_map_[object_path]); } ModemMessagingClient::TestInterface* FakeModemMessagingClient::GetTestInterface() { return this; } // ModemMessagingClient::TestInterface overrides. void FakeModemMessagingClient::ReceiveSms(const dbus::ObjectPath& object_path, const dbus::ObjectPath& sms_path) { if (message_paths_map_.find(object_path) == message_paths_map_.end()) { NOTREACHED() << "object_path not found!"; return; } message_paths_map_[object_path].push_back(sms_path); sms_received_handlers_[object_path].Run(sms_path, true); } } // namespace chromeos
35.416667
80
0.683137
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
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
252af395366cb275352e95eee4d73a4fe3e82626
191
cc
C++
example.cc
WingTillDie/CxxPrintf
5b82eeb12840553598efdd291e004c5ba97fbd02
[ "Apache-2.0" ]
null
null
null
example.cc
WingTillDie/CxxPrintf
5b82eeb12840553598efdd291e004c5ba97fbd02
[ "Apache-2.0" ]
null
null
null
example.cc
WingTillDie/CxxPrintf
5b82eeb12840553598efdd291e004c5ba97fbd02
[ "Apache-2.0" ]
null
null
null
#include <iostream> #include <cfloat> #include "cxxprintf.hh" int main(){ std::cout << putf("%3d\n", 23) << putf("%a\n", 256.); std::cerr << putf("%Le\n", LDBL_MAX) << putf("%p", NULL); }
21.222222
58
0.570681
2530cd464b924151a2e29ae753940bfa5eaa65a9
1,040
cpp
C++
hashing/timer/clock.cpp
ShuhaoZhangTony/WalnutDB
9ccc10b23351aa2e6793e0f5c7bd3dd511d7b050
[ "MIT" ]
null
null
null
hashing/timer/clock.cpp
ShuhaoZhangTony/WalnutDB
9ccc10b23351aa2e6793e0f5c7bd3dd511d7b050
[ "MIT" ]
null
null
null
hashing/timer/clock.cpp
ShuhaoZhangTony/WalnutDB
9ccc10b23351aa2e6793e0f5c7bd3dd511d7b050
[ "MIT" ]
null
null
null
// // Created by Shuhao Zhang on 3/3/20. //https://stackoverflow.com/questions/275004/timer-function-to-provide-time-in-nano-seconds-using-c/11485388#11485388 #include "clock.h" #include <iostream> #include <thread> int x::test_clock() { // Define real time units typedef std::chrono::duration<unsigned long long, std::pico> picoseconds; // or: // typedef std::chrono::nanoseconds nanoseconds; // Define double-based unit of clock tick typedef std::chrono::duration<double, typename x::clock::period> Cycle; using std::chrono::duration_cast; const int N = 100000000; // Do it auto t0 = x::clock::now(); for (int j = 0; j < N; ++j) asm volatile(""); auto t1 = x::clock::now(); // Get the clock ticks per iteration auto ticks_per_iter = Cycle(t1-t0)/N; std::cout << ticks_per_iter.count() << " clock ticks per iteration\n"; // Convert to real time units std::cout << duration_cast<picoseconds>(ticks_per_iter).count() << "ps per iteration\n"; }
33.548387
117
0.649038
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
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
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
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
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
25399c4fdef84031784b3f8f3136b92e2f289d4a
1,448
hpp
C++
include/thermistor/util.hpp
matt1795/thermistor
8f7a858fb0fc13b47b16597ae889209726352e71
[ "Apache-2.0" ]
null
null
null
include/thermistor/util.hpp
matt1795/thermistor
8f7a858fb0fc13b47b16597ae889209726352e71
[ "Apache-2.0" ]
null
null
null
include/thermistor/util.hpp
matt1795/thermistor
8f7a858fb0fc13b47b16597ae889209726352e71
[ "Apache-2.0" ]
null
null
null
// Thermistor utility functions // // Author: Matthew Knight // File Name: util.hpp // Date: 2019-08-12 #pragma once #include <iterator> namespace Thermistor { // constexpr range checker. predicate is used to compare every element and // its predesesor template <typename Iterator, typename Predicate> constexpr bool all_of(Iterator first, Iterator last, Predicate p) { first++; for (;first != last; ++first) if (!p(*first, *std::prev(first))) return false; return true; } template <typename Iterator, typename Predicate> constexpr bool any_of(Iterator first, Iterator last, Predicate p) { first++; for (;first != last; ++first) if (p(*first, *std::prev(first))) return true; return false; } // checks if range is in ascending order template <typename Iterator> constexpr bool ascending(Iterator first, Iterator last) { return all_of(first, last, [](auto& current, auto& previous) { return current > previous; }); } // checks if range is in descending order template <typename Iterator> constexpr bool descending(Iterator first, Iterator last) { return all_of(first, last, [](auto& current, auto& previous) { return current < previous; }); } // checks to see if any values are equal template <typename Iterator> constexpr bool over_sampled(Iterator first, Iterator last) { return any_of(first, last, [](auto& current, auto& previous) { return current == previous; }); } }
24.965517
75
0.697514
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
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
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
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
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
25448e6a51424ada9805a6c032e1ec65fdbb7890
1,183
hh
C++
trick_source/data_products/Apps/trkConvert/TRK_DataLog.hh
gilbertguoze/trick
f0537efb0fa3cb5c0c84e36b60f055c1d1c60d21
[ "NASA-1.3" ]
647
2015-05-07T16:08:16.000Z
2022-03-30T02:33:21.000Z
trick_source/data_products/Apps/trkConvert/TRK_DataLog.hh
gilbertguoze/trick
f0537efb0fa3cb5c0c84e36b60f055c1d1c60d21
[ "NASA-1.3" ]
995
2015-04-30T19:44:31.000Z
2022-03-31T20:14:44.000Z
trick_source/data_products/Apps/trkConvert/TRK_DataLog.hh
gilbertguoze/trick
f0537efb0fa3cb5c0c84e36b60f055c1d1c60d21
[ "NASA-1.3" ]
251
2015-05-15T09:24:34.000Z
2022-03-22T20:39:05.000Z
#ifndef TRK_DATA_LOG_HH #define TRK_DATA_LOG_HH #include <stdio.h> // FILE #include <stdint.h> // Requires C99 #include <string> #include <vector> #include "LogFormatter.hh" #include "ParamDescription.hh" class TRK_DataLog { public: static const int LittleEndian; static const int BigEndian; std::vector<ParamDescription*> paramDescriptions; std::vector<int> paramOffsets; std::vector<bool> paramSelected; // Constructors TRK_DataLog(){} TRK_DataLog(std::string fileName); std::string getFileName() const; int parameterCount() const; const char* parameterName(unsigned int n) const; const char* parameterUnits(unsigned int n) const; const char* parameterType(unsigned int n) const; void selectAllParameters(); void selectParameter(unsigned int index); void selectParameter(const char * paramName); void deselectParameter(unsigned int index); void formattedWrite(FILE* out_fp, LogFormatter* formatter); private: std::string fileName; FILE* in_fp; int version; int endianness; uint32_t N_params; fpos_t dataPosition; int dataRecordSize; char* dataRecord; }; #endif
23.66
63
0.71175
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
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
8584f961bca75835df6fe42b8072af2f58d87d2d
451
cpp
C++
src/cmcandy/C_Language_Answers/_0026.cpp
ch98road/leetcode
a9b4be54a169b30f6711809b892dd1f79f2a17e7
[ "MIT" ]
null
null
null
src/cmcandy/C_Language_Answers/_0026.cpp
ch98road/leetcode
a9b4be54a169b30f6711809b892dd1f79f2a17e7
[ "MIT" ]
null
null
null
src/cmcandy/C_Language_Answers/_0026.cpp
ch98road/leetcode
a9b4be54a169b30f6711809b892dd1f79f2a17e7
[ "MIT" ]
1
2020-11-26T03:01:12.000Z
2020-11-26T03:01:12.000Z
#include <iostream> #include <map> #include <vector> using namespace::std; class Solution { public: int removeDuplicates(vector<int>& nums) { int cur=0; map<int,int>m; for (int i = 0; i < nums.size(); i++) { if (m.find(nums[i])==m.end()) { //如果找不到,则加入 m[nums[i]]=1; nums[cur++] = nums[i]; } } return cur; } };
19.608696
45
0.427938
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
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