hexsha
stringlengths 40
40
| size
int64 7
1.05M
| ext
stringclasses 13
values | lang
stringclasses 1
value | max_stars_repo_path
stringlengths 4
269
| max_stars_repo_name
stringlengths 5
109
| max_stars_repo_head_hexsha
stringlengths 40
40
| max_stars_repo_licenses
listlengths 1
9
| max_stars_count
int64 1
191k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 4
269
| max_issues_repo_name
stringlengths 5
116
| max_issues_repo_head_hexsha
stringlengths 40
40
| max_issues_repo_licenses
listlengths 1
9
| max_issues_count
int64 1
48.5k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 4
269
| max_forks_repo_name
stringlengths 5
116
| max_forks_repo_head_hexsha
stringlengths 40
40
| max_forks_repo_licenses
listlengths 1
9
| max_forks_count
int64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | content
stringlengths 7
1.05M
| avg_line_length
float64 1.21
330k
| max_line_length
int64 6
990k
| alphanum_fraction
float64 0.01
0.99
| author_id
stringlengths 2
40
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4b9f20b4d75a9a3f7488a03c24289550eaeb5344
| 4,014
|
cpp
|
C++
|
src/test/MatrixSlicerSquarifiedTest.cpp
|
mp13on11/dwarf_mine
|
e9c83e8d50d5a23670a45bfd174475f7f383a709
|
[
"MIT"
] | 2
|
2015-11-06T03:18:28.000Z
|
2016-06-29T07:43:10.000Z
|
src/test/MatrixSlicerSquarifiedTest.cpp
|
mp13on11/dwarf_mine
|
e9c83e8d50d5a23670a45bfd174475f7f383a709
|
[
"MIT"
] | null | null | null |
src/test/MatrixSlicerSquarifiedTest.cpp
|
mp13on11/dwarf_mine
|
e9c83e8d50d5a23670a45bfd174475f7f383a709
|
[
"MIT"
] | null | null | null |
/*****************************************************************************
* Dwarf Mine - The 13-11 Benchmark
*
* Copyright (c) 2013 Bünger, Thomas; Kieschnick, Christian; Kusber,
* Michael; Lohse, Henning; Wuttke, Nikolai; Xylander, Oliver; Yao, Gary;
* Zimmermann, Florian
*
* 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 "MatrixSlicerSquarifiedTest.h"
#include "MatrixSlicerUtil.h"
#include <matrix/Matrix.h>
#include <matrix/MatrixHelper.h>
#include <matrix/MatrixSlice.h>
#include <algorithm>
#include <cstddef>
using namespace std;
typedef Matrix<float> TestGrid;
TEST_F(MatrixSlicerSquarifiedTest, SimpleUnifiedSlicingTest)
{
size_t rows = 100;
size_t columns = 100;
size_t area = rows * columns;
auto slices = slicer.layout({{0, 1.0}, {1, 1.0}, {2, 1.0}, {3, 1.0}}, rows, columns);
size_t sliceArea = area / 4;
verifySlices(slices, vector<size_t>{sliceArea, sliceArea, sliceArea, sliceArea});
}
TEST_F(MatrixSlicerSquarifiedTest, SimpleDifferentWeightSlicingTest)
{
size_t rows = 100;
size_t columns = 100;
size_t area = rows * columns;
auto slices = slicer.layout({{0, 6}, {1, 2}, {2, 1}, {3, 1}}, rows, columns);
verifySlices(slices, vector<size_t>{ 6 * area / 10, 2 * area / 10, area / 10, area / 10});
}
TEST_F(MatrixSlicerSquarifiedTest, UnifiedSlicingTest)
{
size_t rows = 33;
size_t columns = 67;
auto slices = slicer.layout({{0, 1.0}, {1, 1.0}, {2, 1.0}, {3, 1.0}}, rows, columns);
verifySlices(slices, vector<size_t>{ 561 , 561, 561, 528});
}
TEST_F(MatrixSlicerSquarifiedTest, DifferentWeightSlicingTest)
{
size_t rows = 33;
size_t columns = 67;
auto slices = slicer.layout({{0, 6}, {1, 2}, {2, 1.0}, {3, 1.0}}, rows, columns);
verifySlices(slices, vector<size_t>{ 1353 , 200, 208, 450});
}
TEST_F(MatrixSlicerSquarifiedTest, SliceMultipleTest)
{
size_t rows = 5;
size_t columns = 5;
auto slices = slicer.layout({{0, 1.0}, {1, 1.0}, {2, 1.0},{3, 1.0},{4, 1.0},{5, 1.0}, {6, 1.0}, {7, 1.0},}, rows, columns);
bool matrix[5][5];
for(size_t row = 0; row < rows; ++row)
{
for(size_t column = 0; column < columns; ++column)
{
matrix[row][column] = false;
}
}
for(auto slice : slices)
{
ASSERT_NE((size_t) 0, rows);
ASSERT_NE((size_t) 0, columns);
for(size_t row = 0; row < slice.getRows(); ++row)
{
for(size_t column = 0; column < slice.getColumns(); ++column)
{
ASSERT_FALSE(matrix[slice.getStartY() + row][slice.getStartX() + column]);
matrix[slice.getStartY() + row][slice.getStartX() + column] = true;
}
}
}
for(size_t row = 0; row < rows; ++row)
{
for(size_t column = 0; column < columns; ++column)
{
ASSERT_TRUE(matrix[row][column]);
}
}
}
| 34.016949
| 127
| 0.622571
|
mp13on11
|
4ba648fbff3e4f2cfb1f3932ec829a3dd136f4bc
| 1,642
|
cpp
|
C++
|
Online Judges/LightOJ/1044 - Palindrome Partitioning.cpp
|
akazad13/competitive-programming
|
5cbb67d43ad8d5817459043bcccac3f68d9bc688
|
[
"MIT"
] | null | null | null |
Online Judges/LightOJ/1044 - Palindrome Partitioning.cpp
|
akazad13/competitive-programming
|
5cbb67d43ad8d5817459043bcccac3f68d9bc688
|
[
"MIT"
] | null | null | null |
Online Judges/LightOJ/1044 - Palindrome Partitioning.cpp
|
akazad13/competitive-programming
|
5cbb67d43ad8d5817459043bcccac3f68d9bc688
|
[
"MIT"
] | null | null | null |
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define rep(i,p,n) for( i = p; i<n;i++)
#define lld long long int
#define Clear(a,b) memset(a,b,sizeof(a))
template<class T>inline bool read(T &x) {
int c=getchar();
int sgn=1;
while(~c&&c<'0'||c>'9') {
if(c=='-')sgn=-1;
c=getchar();
}
for(x=0; ~c&&'0'<=c&&c<='9'; c=getchar())x=x*10+c-'0';
x*=sgn;
return ~c;
}
/*****************************************************/
char str[1002];
int dp[1002];
bool ispalindrome[1002][1002];
int solve()
{
int len = strlen(str);
for (int i=0; i<len; i++)
{
ispalindrome[i][i] = true;
}
for (int k=2; k<=len; k++)
{
for (int i=0; i<len-k+1; i++)
{
int j = i+k-1; // Set ending index
if (k == 2)
ispalindrome[i][j] = (str[i] == str[j]);
else
ispalindrome[i][j] = (str[i] == str[j]) && ispalindrome[i+1][j-1];
}
}
for (int i=0; i<len; i++)
{
if(ispalindrome[0][i]==1)
dp[i] = 1;
else
{
dp[i] = INT_MAX;
for(int j=0;j<i;j++)
{
if(ispalindrome[j+1][i] == true && 1+dp[j]<dp[i])
dp[i]=1+dp[j];
}
}
}
return dp[len-1];
}
int main()
{
//freopen("input.txt","r",stdin);
//freopen("out.txt","w",stdout);
int test,i,j,Case,n,m;
char temp[10];
read(test);
rep(Case,1,test+1)
{
gets(str);
int ret = solve();
printf("Case %d: %d\n",Case,ret);
}
return 0;
}
| 18.244444
| 82
| 0.416565
|
akazad13
|
4baa81884e5b02233b0d352b352d4759631cd839
| 3,258
|
cpp
|
C++
|
sdl2/lib/sdl2/sdl-display.cpp
|
leocov-dev/lc-esp32-sprinkler
|
816d06bbe7d3a30b8d3d79167dc1b3481ee4261b
|
[
"MIT"
] | 1
|
2021-01-10T16:06:02.000Z
|
2021-01-10T16:06:02.000Z
|
sdl2/lib/sdl2/sdl-display.cpp
|
leocov-dev/lc-esp32-sprinkler
|
816d06bbe7d3a30b8d3d79167dc1b3481ee4261b
|
[
"MIT"
] | null | null | null |
sdl2/lib/sdl2/sdl-display.cpp
|
leocov-dev/lc-esp32-sprinkler
|
816d06bbe7d3a30b8d3d79167dc1b3481ee4261b
|
[
"MIT"
] | null | null | null |
#include "sdl-display.hpp"
#include <SDL.h>
#include <SDL2_gfxPrimitives.h>
#include <iostream>
#include "sdl-constants.hpp"
#include "sdl-utils.hpp"
#include "sdl-window-icon.hpp"
sprinkler::sdl::SDLDisplay::SDLDisplay(int height, int width, gfx::Point position)
: Display(width, height) {
window_ = std::unique_ptr<SDL_Window, SDLWindowDeleter>(
SDL_CreateWindow("lcSprinkler", position.x, position.y, width * kDisplayScaleFactor,
height * kDisplayScaleFactor, SDL_WINDOW_SHOWN));
if (window_ == nullptr) {
std::cerr << "Unable to initialize window\n";
exit(-1);
}
auto icon_surface = std::unique_ptr<SDL_Surface, SDLSurfaceDeleter>(SDL_CreateRGBSurfaceFrom(
(void*)window_icon_pixels, 16, 16, 16, 16 * 2, 0x0f00, 0x00f0, 0x000f, 0xf000));
SDL_SetWindowIcon(window_.get(), icon_surface.get());
renderer_ = std::unique_ptr<SDL_Renderer, SDLRendererDeleter>(
SDL_CreateRenderer(window_.get(), -1, SDL_RENDERER_ACCELERATED));
// this established the actual hardware OLED pixel accurate dimensions regardless of the window
// size
SDL_RenderSetLogicalSize(renderer_.get(), width, height);
SDL_SetRenderDrawBlendMode(renderer_.get(), SDL_BLENDMODE_BLEND);
if (!renderer_) {
std::cerr << "Unable to initialize renderer\n";
exit(-1);
}
}
void sprinkler::sdl::SDLDisplay::Clear() {
SetRenderDrawColor(renderer_.get(), gfx::Color::K_WHITE);
SDL_RenderClear(renderer_.get());
}
void sprinkler::sdl::SDLDisplay::Refresh() {
SDL_SetRenderDrawColor(renderer_.get(), 200, 200, 200, 128);
if (kDebug) {
SDL_RenderDrawLine(renderer_.get(), 0, 16, 128, 16);
}
SDL_RenderPresent(renderer_.get());
}
void sprinkler::sdl::SDLDisplay::DrawPixelInternal(const gfx::Point& point,
const gfx::Color& color) const {
SetRenderDrawColor(renderer_.get(), color);
SDL_RenderDrawPoint(renderer_.get(), point.x, point.y);
}
void sprinkler::sdl::SDLDisplay::DrawRectInternal(const gfx::Rect& rect,
const gfx::Color& color) const {
SDL_Rect sdl_rect = FromRect(rect);
SetRenderDrawColor(renderer_.get(), color);
SDL_RenderDrawRect(renderer_.get(), &sdl_rect);
}
void sprinkler::sdl::SDLDisplay::FillRectInternal(const gfx::Rect& rect,
const gfx::Color& color) const {
SDL_Rect sdl_rect = FromRect(rect);
SetRenderDrawColor(renderer_.get(), color);
SDL_RenderFillRect(renderer_.get(), &sdl_rect);
}
void sprinkler::sdl::SDLDisplay::DrawCircleInternal(const gfx::Point& center,
int radius,
const gfx::Color& color) const {
circleColor(renderer_.get(), center.x, center.y, radius, HexFromColor(color));
}
void sprinkler::sdl::SDLDisplay::FillCircleInternal(const gfx::Point& center,
int radius,
const gfx::Color& color) const {
filledCircleColor(renderer_.get(), center.x, center.y, radius, HexFromColor(color));
}
SDL_Window* sprinkler::sdl::SDLDisplay::GetWindow() {
return window_.get();
}
| 36.2
| 97
| 0.645795
|
leocov-dev
|
4baaf8e374e98d7b5b1f671305d80b1b78af8432
| 5,490
|
hpp
|
C++
|
include/sph/kernel/computeFindNeighbors.hpp
|
j-piccinali/SPH-EXA_mini-app
|
c3ba4d37f2edf433710d5c0bc2362ec35e75df32
|
[
"MIT"
] | 14
|
2019-03-18T12:51:43.000Z
|
2021-11-09T14:40:36.000Z
|
include/sph/kernel/computeFindNeighbors.hpp
|
j-piccinali/SPH-EXA_mini-app
|
c3ba4d37f2edf433710d5c0bc2362ec35e75df32
|
[
"MIT"
] | 41
|
2019-10-08T19:53:55.000Z
|
2021-11-23T06:56:03.000Z
|
include/sph/kernel/computeFindNeighbors.hpp
|
j-piccinali/SPH-EXA_mini-app
|
c3ba4d37f2edf433710d5c0bc2362ec35e75df32
|
[
"MIT"
] | 8
|
2019-06-20T07:11:52.000Z
|
2021-10-05T13:44:07.000Z
|
#pragma once
#include "../cuda/cudaParticlesData.cuh"
#include "../lookupTables.hpp"
namespace sphexa
{
namespace sph
{
namespace cuda
{
template <typename T>
__global__ void findNeighbors(const cuda::DeviceLinearOctree<T> o, const int *clist, const int n, const T *x, const T *y, const T *z, const T *h, const T displx,
const T disply, const T displz, const int max, const int may, const int maz, const int ngmax, int *neighbors, int *neighborsCount);
}
namespace kernels
{
template <typename T>
CUDA_DEVICE_HOST_FUN inline
T normalize(T d, T min, T max)
{
return (d - min) / (max - min);
}
template <typename T>
CUDA_DEVICE_HOST_FUN inline
void findNeighborsDispl(const int pi, const int *clist, const T *x, const T *y, const T *z, const T *h,
const T displx, const T disply, const T displz, const int ngmax, int *neighbors, int *neighborsCount,
// The linear tree
const int *o_cells, const int *o_ncells, const int *o_localPadding, const int *o_localParticleCount, const T *o_xmin, const T *o_xmax, const T *o_ymin, const T *o_ymax, const T *o_zmin, const T *o_zmax)
{
const int i = clist[pi];
// // 64 is not enough... Depends on the bucket size and h...
// // This can be created and stored on the GPU directly.
// // For a fixed problem and size, if it works then it will always work
int collisionsCount = 0;
int collisionNodes[256];
const T xi = x[i] + displx;
const T yi = y[i] + disply;
const T zi = z[i] + displz;
const T ri = 2.0 * h[i];
constexpr int nX = 2;
constexpr int nY = 2;
constexpr int nZ = 2;
int stack[64];
int stackptr = 0;
stack[stackptr++] = -1;
int node = 0;
do
{
if (o_ncells[node] == 8)
{
int mix = std::max((int)(normalize(xi - ri, o_xmin[node], o_xmax[node]) * nX), 0);
int miy = std::max((int)(normalize(yi - ri, o_ymin[node], o_ymax[node]) * nY), 0);
int miz = std::max((int)(normalize(zi - ri, o_zmin[node], o_zmax[node]) * nZ), 0);
int max = std::min((int)(normalize(xi + ri, o_xmin[node], o_xmax[node]) * nX), nX - 1);
int may = std::min((int)(normalize(yi + ri, o_ymin[node], o_ymax[node]) * nY), nY - 1);
int maz = std::min((int)(normalize(zi + ri, o_zmin[node], o_zmax[node]) * nZ), nZ - 1);
// Maximize threads sync
for (int hz = 0; hz < 2; hz++)
{
for (int hy = 0; hy < 2; hy++)
{
for (int hx = 0; hx < 2; hx++)
{
// if overlap
if (hz >= miz && hz <= maz && hy >= miy && hy <= may && hx >= mix && hx <= max)
{
// int l = hz * nX * nY + hy * nX + hx;
// stack[stackptr++] = o_cells[node * 8 + l];
const int l = hz * nX * nY + hy * nX + hx;
const int child = o_cells[node * 8 + l];
if(o_localParticleCount[child] > 0)
stack[stackptr++] = child;
}
}
}
}
}
if (o_ncells[node] != 8) collisionNodes[collisionsCount++] = node;
node = stack[--stackptr]; // Pop next
} while (node > 0);
//__syncthreads();
int ngc = neighborsCount[pi];
for (int ni = 0; ni < collisionsCount; ni++)
{
int node = collisionNodes[ni];
T r2 = ri * ri;
for (int pj = 0; pj < o_localParticleCount[node]; pj++)
{
int j = o_localPadding[node] + pj;
T xj = x[j];
T yj = y[j];
T zj = z[j];
T xx = xi - xj;
T yy = yi - yj;
T zz = zi - zj;
T dist = xx * xx + yy * yy + zz * zz;
if (dist < r2 && i != j && ngc < ngmax) neighbors[ngc++] = j;
}
}
neighborsCount[pi] = ngc;
//__syncthreads();
}
template <typename T>
CUDA_DEVICE_HOST_FUN inline
void findNeighborsJLoop(const int pi, const int *clist, const T *x, const T *y, const T *z, const T *h, const T displx,
const T disply, const T displz, const int max, const int may, const int maz, const int ngmax, int *neighbors, int *neighborsCount,
// The linear tree
const int *o_cells, const int *o_ncells, const int *o_localPadding, const int *o_localParticleCount, const T *o_xmin, const T *o_xmax, const T *o_ymin, const T *o_ymax, const T *o_zmin, const T *o_zmax)
{
T dispx[3], dispy[3], dispz[3];
dispx[0] = 0;
dispy[0] = 0;
dispz[0] = 0;
dispx[1] = -displx;
dispy[1] = -disply;
dispz[1] = -displz;
dispx[2] = displx;
dispy[2] = disply;
dispz[2] = displz;
neighborsCount[pi] = 0;
for (int hz = 0; hz <= maz; hz++)
for (int hy = 0; hy <= may; hy++)
for (int hx = 0; hx <= max; hx++)
findNeighborsDispl<T>(pi, clist, x, y, z, h, dispx[hx], dispy[hy], dispz[hz], ngmax, &neighbors[pi * ngmax], neighborsCount,
// The linear tree
o_cells, o_ncells, o_localPadding, o_localParticleCount, o_xmin, o_xmax, o_ymin, o_ymax, o_zmin, o_zmax);
}
} // namespace kernels
} // namespace sph
} // namespace sphexa
| 34.099379
| 223
| 0.517851
|
j-piccinali
|
4bb5a22c79868f775c5e12e9707b821393065021
| 730
|
hpp
|
C++
|
include/scene/attachments/light.hpp
|
AttilioProvenzano/goma-engine
|
fc61e4e3db2868a70ef0b8b7b21c5fd3b1a37100
|
[
"MIT"
] | 41
|
2019-05-22T17:13:14.000Z
|
2021-02-25T08:15:24.000Z
|
include/scene/attachments/light.hpp
|
AttilioProvenzano/goma-engine
|
fc61e4e3db2868a70ef0b8b7b21c5fd3b1a37100
|
[
"MIT"
] | 2
|
2019-05-08T21:59:12.000Z
|
2019-05-16T21:41:13.000Z
|
include/scene/attachments/light.hpp
|
AttilioProvenzano/goma-engine
|
fc61e4e3db2868a70ef0b8b7b21c5fd3b1a37100
|
[
"MIT"
] | 1
|
2019-07-03T01:21:35.000Z
|
2019-07-03T01:21:35.000Z
|
#pragma once
#include "common/include.hpp"
namespace goma {
enum LightType {
Directional = 0,
Point = 1,
Spot = 2,
Ambient = 3,
Area = 4,
};
struct Light {
std::string name;
LightType type{LightType::Directional};
glm::vec3 position{glm::vec3(0.0f)};
glm::vec3 direction{0.0f, 0.0f, 1.0f};
glm::vec3 up{0.0f, 1.0f, 0.0f};
float intensity{1.0f};
glm::vec3 diffuse_color{glm::vec3(1.0f)};
glm::vec3 specular_color{glm::vec3(1.0f)};
glm::vec3 ambient_color{glm::vec3(1.0f)};
std::array<float, 3> attenuation{1.0f, 1.0f, 1.0f};
float inner_cone_angle{360.0f};
float outer_cone_angle{360.0f};
glm::vec2 area_size{glm::vec2(0.0f)};
};
} // namespace goma
| 20.857143
| 55
| 0.620548
|
AttilioProvenzano
|
4bb5fa850538954aba44c2cf2cda75340f07e363
| 3,283
|
cpp
|
C++
|
graph.cpp
|
VishalGupta0609/algorithms
|
1dd704a8e8c8e96aeaa43928258e806da3192a6c
|
[
"MIT"
] | 2
|
2020-10-28T15:02:41.000Z
|
2021-10-02T13:18:24.000Z
|
graph.cpp
|
VishalGupta0609/algorithms
|
1dd704a8e8c8e96aeaa43928258e806da3192a6c
|
[
"MIT"
] | 4
|
2020-10-07T05:59:13.000Z
|
2021-10-02T08:01:27.000Z
|
graph.cpp
|
VishalGupta0609/algorithms
|
1dd704a8e8c8e96aeaa43928258e806da3192a6c
|
[
"MIT"
] | 51
|
2020-10-01T03:07:30.000Z
|
2021-10-05T16:25:22.000Z
|
#include<iostream>
using namespace std;
int main()
{
int i,j;
int cost; //weight of edge
//defining number of vertices
int n;
cout<<"Enter the number of vertices you want in the graph ";
cin>>n;
//declaring an array that contain all the vertices
int vertices[n];
for(i=0;i<n;i++)
vertices[i]=i;
char cont;
int matrix[n][n]; //declaring adjacency matrix
//making the user to enter weight of the edges
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(i!=j)
{
cout<<"Does there exist any edge directed from vertix "<<vertices[i]<<" to "<<vertices[j]<<" Y/N?"<<endl;
cin>>cont;
if(cont=='Y'||cont=='y')
{
cout<<"Enter the weight of the edge ";
cin>>cost;
matrix[i][j]=cost;
}
else
{
matrix[i][j]=1000;
//here 1000 represents infinity i.e. the edges are not connected
}
}
else
{
matrix[i][j]=0;
}
}
}
//printing the adjacency matrix
cout<<endl<<"The adjacency matrix for the graph is: "<<endl;
for(i=0;i<n;i++)
{
cout<<endl;
for(j=0;j<n;j++)
{
cout<<"\t"<<matrix[i][j];
}
}
cout<<endl<<endl<<"Note: The value 1000 represents that there might be no edge between the"<<endl
<<"vertices or distance between them is infinity"<<endl;
//asking the user to enter the source node
int source;
cout<<"Enter the source node ";
cin>>source;
//Declaring the array that will contain the traversed nodes
int S[n];
//declaring array distance which contains the minimum distance of each vertex from the source node
int distance[n];
for(i=0;i<n;i++)
{
if(i!=source)
distance[i]=1000;
distance[source]=0;
}
//declaring the array which contains the predecessors of each vertex in shortest path
int pred[n];
for(i=0;i<n;i++)
{
if(i!=source)
pred[i]=-1;
pred[source]=source;
}
//declaring an another array Q which contains the vertices' distances yet to be traversed
int Q[n];
for(i=0;i<n;i++)
Q[i]=distance[i];
int k=0;
int pos;
S[n-1]=n;
int num=n;
while(S[n-1]==n) //Terminating condition....the loop continues till all the nodes are traversed
{
int min=1000;
for(i=0;i<num;i++) // extracting the minimum value out of Q and the correspoinding vertex
{
if(Q[i]<min)
{
min=Q[i];
pos=i;
}
}
for(i=0;i<n;i++)
{
if(matrix[pos][i]!=1000)
{
if(distance[i]>distance[pos]+matrix[pos][i])
{
distance[i]=distance[pos]+matrix[pos][i];
Q[i]=distance[i];
pred[i]=pos;
}
}
}
S[k]=pos;
k++;
num=num-1;
//Deleting the traversed node's distance
for(i=pos;i<num;i++)
{
Q[i]=Q[i+1];
}
}
cout<<"Hence the solution found using DIJKSTRA Algorithm is :"<<endl<<"Vertices\tMin. Distance\tPredecessor"<<endl;
for(i=0;i<n;i++)
{
cout<<vertices[i]<<"\t\t"<<distance[i]<<"\t\t"<<pred[i]<<endl;
}
return 0;
}
| 20.778481
| 117
| 0.52452
|
VishalGupta0609
|
4bbe941222c19d19578cb80c2be64541790b7b9f
| 1,889
|
cpp
|
C++
|
src/utility.cpp
|
ishansheth/ArkanoidGame
|
81a6e48ef8ebb32dd19bbb18aeb0d95e7a1cd4d5
|
[
"MIT"
] | null | null | null |
src/utility.cpp
|
ishansheth/ArkanoidGame
|
81a6e48ef8ebb32dd19bbb18aeb0d95e7a1cd4d5
|
[
"MIT"
] | null | null | null |
src/utility.cpp
|
ishansheth/ArkanoidGame
|
81a6e48ef8ebb32dd19bbb18aeb0d95e7a1cd4d5
|
[
"MIT"
] | null | null | null |
#include "utility.hpp"
template<typename T1,typename T2>
bool isIntersecting(const T1& mA,const T2& mB)
{
return ((mA.right() >= mB.left())
&& (mA.left() <= mB.right())
&& (mA.bottom() >= mB.top())
&& (mA.top() <= mB.bottom()));
}
void solvePaddleBallCollision(const Paddle& mpaddle, Ball& mball) noexcept
{
if(!isIntersecting(mpaddle,mball)) return;
mball.velocity.y = -abs(mball.velocity.y);
mball.velocity.x = (mball.x() < mpaddle.x()) ? (-abs(mball.velocity.x)) : (mball.velocity.x);
}
void solveBrickBulletCollision(Brick& mbrick,Bullet& mbullet) noexcept
{
if(!isIntersecting(mbrick,mbullet))return;
--mbrick.hitsRequired;
if(!mbrick.hitsRequired)
{
mbrick.flingBrick();
}
mbullet.destroyed = true;
}
void solveBallBrickCollision(Brick& mbrick, Ball& mball) noexcept
{
if(!mbrick.isFlying())
{
if(!isIntersecting(mbrick,mball)) return;
--mbrick.hitsRequired;
mball.beepSound->playSound();
if(!mbrick.hitsRequired)
{
mbrick.flingBrick();
}
float overlapLeft{mball.right()-mbrick.left()};
float overlapRight{mbrick.right()-mball.left()};
float overlapTop{mball.bottom()-mbrick.top()};
float overlapBottom{mbrick.bottom()-mball.top()};
bool ballFromLeft{std::abs(overlapLeft) < std::abs(overlapRight)};
bool ballFromRight{std::abs(overlapLeft) > std::abs(overlapRight)};
bool ballFromTop{std::abs(overlapTop) < std::abs(overlapBottom)};
bool ballFromBottom{std::abs(overlapTop) > std::abs(overlapBottom)};
if((overlapLeft < overlapTop && overlapLeft < overlapBottom) || (overlapRight < overlapTop && overlapRight < overlapBottom)){
mball.velocity.x = -mball.velocity.x;
}
else if((overlapTop < overlapLeft && overlapTop < overlapRight) || (overlapBottom < overlapLeft && overlapBottom < overlapRight)){
mball.velocity.y = -mball.velocity.y;
}
}
}
| 29.984127
| 133
| 0.676019
|
ishansheth
|
4bc016ea50ad0250bbe3cda56d071c552c8601db
| 677
|
cpp
|
C++
|
src/main.cpp
|
Danduriel/rocky2
|
1a4441957c00de5f0f457a452398b68a00c9bea4
|
[
"MIT"
] | null | null | null |
src/main.cpp
|
Danduriel/rocky2
|
1a4441957c00de5f0f457a452398b68a00c9bea4
|
[
"MIT"
] | null | null | null |
src/main.cpp
|
Danduriel/rocky2
|
1a4441957c00de5f0f457a452398b68a00c9bea4
|
[
"MIT"
] | null | null | null |
#include "engine.h"
#include "helper.h"
// Add only very first state game should jump into
#include "teststate.h"
#include "menustate.h"
#include "playstate.h"
int main()
{
//Instance of game engine (Holds the sfml screen)
engine game;
//Mainly to initialise the sf::window
game.init(1280,800,"Rocky the Rocket's Path to infinity and beyond");
//Set start State
game.changestate(menustate::instance());
//Main Loop - No touching nessecary
//Add framelimit
while (game.running())
{
//printf("mainloop\n");
game.handleEvents();
game.update();
game.draw();
}
game.cleanup();
return 0;
}
| 18.805556
| 73
| 0.624815
|
Danduriel
|
4bc8eeb76fabe9f3cb2260af163788f89cc37a42
| 673
|
cpp
|
C++
|
pg_answer/0b8da730c9ad43f093ea1f3b7f40e424.cpp
|
Guyutongxue/Introduction_to_Computation
|
062f688fe3ffb8e29cfaf139223e4994edbf64d6
|
[
"WTFPL"
] | 8
|
2019-10-09T14:33:42.000Z
|
2020-12-03T00:49:29.000Z
|
pg_answer/0b8da730c9ad43f093ea1f3b7f40e424.cpp
|
Guyutongxue/Introduction_to_Computation
|
062f688fe3ffb8e29cfaf139223e4994edbf64d6
|
[
"WTFPL"
] | null | null | null |
pg_answer/0b8da730c9ad43f093ea1f3b7f40e424.cpp
|
Guyutongxue/Introduction_to_Computation
|
062f688fe3ffb8e29cfaf139223e4994edbf64d6
|
[
"WTFPL"
] | null | null | null |
#include <iostream>
int sumOfFactor(int x) {
constexpr int MAX{100001};
static int saved[MAX]{};
if (x < MAX && saved[x] != 0) {
return saved[x];
}
int sum{1};
for (int i{2}; i * i <= x; i++) {
if (x % i == 0) {
sum += i;
if (i * i != x) {
sum += x / i;
}
}
}
if (x < MAX) {
saved[x] = sum;
}
return sum;
}
int main() {
int n;
std::cin >> n;
for (int i{1}; i <= n; i++) {
int sf{sumOfFactor(i)};
if (sf > i && sf < n && sumOfFactor(sf) == i) {
std::cout << i << " " << sf << std::endl;
}
}
}
| 19.794118
| 55
| 0.36107
|
Guyutongxue
|
4bc8fab1a0c2d8b5300f554025e93423e72c2c11
| 518
|
cpp
|
C++
|
Machines/dealer-ring-party.cpp
|
triplewz/MP-SPDZ
|
a858e5b440902ec25dbb97c555eef35e12fbf69c
|
[
"BSD-2-Clause"
] | null | null | null |
Machines/dealer-ring-party.cpp
|
triplewz/MP-SPDZ
|
a858e5b440902ec25dbb97c555eef35e12fbf69c
|
[
"BSD-2-Clause"
] | null | null | null |
Machines/dealer-ring-party.cpp
|
triplewz/MP-SPDZ
|
a858e5b440902ec25dbb97c555eef35e12fbf69c
|
[
"BSD-2-Clause"
] | null | null | null |
/*
* dealer-ring-party.cpp
*
*/
#include "Protocols/DealerShare.h"
#include "Protocols/DealerInput.h"
#include "Processor/RingMachine.hpp"
#include "Processor/Machine.hpp"
#include "Protocols/Replicated.hpp"
#include "Protocols/DealerPrep.hpp"
#include "Protocols/DealerInput.hpp"
#include "Protocols/DealerMC.hpp"
#include "Protocols/Beaver.hpp"
#include "Semi.hpp"
#include "GC/DealerPrep.h"
int main(int argc, const char** argv)
{
HonestMajorityRingMachine<DealerRingShare, DealerShare>(argc, argv, 0);
}
| 22.521739
| 75
| 0.754826
|
triplewz
|
4bcf0831bf1af81ed822869ddd24a1b5816e4e1c
| 447
|
cpp
|
C++
|
leetcodes/MinClimingStairs.cpp
|
DaechurJeong/Private_Proj
|
66eec4d22372166af7f7643a9b1307ca7e5ce21a
|
[
"MIT"
] | null | null | null |
leetcodes/MinClimingStairs.cpp
|
DaechurJeong/Private_Proj
|
66eec4d22372166af7f7643a9b1307ca7e5ce21a
|
[
"MIT"
] | null | null | null |
leetcodes/MinClimingStairs.cpp
|
DaechurJeong/Private_Proj
|
66eec4d22372166af7f7643a9b1307ca7e5ce21a
|
[
"MIT"
] | 2
|
2020-04-21T23:52:31.000Z
|
2020-04-24T13:37:28.000Z
|
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int minCostClimbingStairs(vector<int>& cost) {
int n = cost.size();
vector<int> dp(n);
dp[0] = cost[0], dp[1] = cost[1];
for (int i = 2; i < n; ++i)
{
dp[i] = min(dp[i - 1], dp[i - 2]) + cost[i];
}
return min(dp[n - 1], dp[n - 2]);
}
int main(void)
{
vector<int> cost{ 1,100,1,1,1,100,1,1,100,1 };
cout << minCostClimbingStairs(cost) << endl;
return 0;
}
| 17.88
| 47
| 0.583893
|
DaechurJeong
|
4bd1184aa998e4637545a1c355d3de860a293a6a
| 1,788
|
cpp
|
C++
|
backtracking/solve-sudoku.cpp
|
Nilesh-Das/mustdogfg
|
bb39fe6eb9dd4964f97a7ab6d4e65e4c3994fc3f
|
[
"MIT"
] | null | null | null |
backtracking/solve-sudoku.cpp
|
Nilesh-Das/mustdogfg
|
bb39fe6eb9dd4964f97a7ab6d4e65e4c3994fc3f
|
[
"MIT"
] | null | null | null |
backtracking/solve-sudoku.cpp
|
Nilesh-Das/mustdogfg
|
bb39fe6eb9dd4964f97a7ab6d4e65e4c3994fc3f
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <vector>
#include <cassert>
using namespace std;
class Solution {
public:
void print(vector<vector<char>>& board) {
for(int i = 0; i < 9; i++) {
for(int j = 0; j < 9; j++) {
cout << board[i][j] << ' ';
}
cout << '\n';
}
}
bool isValid(vector<vector<char>>& board, int r, int c, char ch) {
for(int i = 0; i < 9; i++){
if(board[i][c] == ch || board[r][i] == ch)
return false;
if(board[3*(r/3)+i/3][3*(c/3)+i%3] == ch)
return false;
}
return true;
}
bool backtrack(vector<vector<char>>& board) {
for(int i = 0; i < board.size(); i++) {
for(int j = 0; j < board[0].size(); j++) {
if(board[i][j] != '.') continue;
for(char c = '1'; c <= '9'; c++) {
if(!isValid(board,i,j,c)) continue;
board[i][j] = c;
if(backtrack(board)) return true;
board[i][j] = '.';
}
return false;
}
}
return true;
}
void solveSudoku(vector<vector<char>>& board) {
backtrack(board);
}
};
int main() {
Solution s;
vector<vector<char>> board;
board =
{{'5','3','.','.','7','.','.','.','.'}
,{'6','.','.','1','9','5','.','.','.'}
,{'.','9','8','.','.','.','.','6','.'}
,{'8','.','.','.','6','.','.','.','3'}
,{'4','.','.','8','.','3','.','.','1'}
,{'7','.','.','.','2','.','.','.','6'}
,{'.','6','.','.','.','.','2','8','.'}
,{'.','.','.','4','1','9','.','.','5'}
,{'.','.','.','.','8','.','.','7','9'}};
s.solveSudoku(board);
s.print(board);
}
| 28.380952
| 70
| 0.342841
|
Nilesh-Das
|
4bdf207a97258c246beae0a7edc6cc9a3a626f60
| 744
|
hpp
|
C++
|
ECS/includes/Event.hpp
|
LiardeauxQ/r-type
|
8a77164c276b2d5958cd3504a9ea34f1cf6823cf
|
[
"MIT"
] | 2
|
2020-02-12T12:02:00.000Z
|
2020-12-23T15:31:59.000Z
|
ECS/includes/Event.hpp
|
LiardeauxQ/r-type
|
8a77164c276b2d5958cd3504a9ea34f1cf6823cf
|
[
"MIT"
] | null | null | null |
ECS/includes/Event.hpp
|
LiardeauxQ/r-type
|
8a77164c276b2d5958cd3504a9ea34f1cf6823cf
|
[
"MIT"
] | 2
|
2020-02-12T12:02:03.000Z
|
2020-12-23T15:32:55.000Z
|
//
// Created by Quentin Liardeaux on 11/19/19.
//
#ifndef R_TYPE_IEVENT_HPP
#define R_TYPE_IEVENT_HPP
#include <string>
#include <functional>
#include <any>
using namespace std;
namespace ecs {
class Event {
public:
Event(string const &type, any value);
Event(const Event &other);
Event(Event&& other) noexcept;
~Event() = default;
[[nodiscard]] bool isOfType(string const &type) const;
template <typename T>
[[nodiscard]] const T& getValue() { return any_cast<T&>(m_value); }
Event& operator=(const Event &) = default;
Event& operator=(Event&& other) noexcept;
private:
size_t m_type;
any m_value;
};
}
#endif //R_TYPE_IEVENT_HPP
| 20.666667
| 75
| 0.620968
|
LiardeauxQ
|
4be18c82bc402d7e5e2dda622c69e28d8abac806
| 558
|
cpp
|
C++
|
test/tasks.cpp
|
CNR-STIIMA-IRAS/realtime_utilities
|
5500b4221ebab92d33b0f1dc7192da8a815b5998
|
[
"Apache-2.0"
] | null | null | null |
test/tasks.cpp
|
CNR-STIIMA-IRAS/realtime_utilities
|
5500b4221ebab92d33b0f1dc7192da8a815b5998
|
[
"Apache-2.0"
] | 1
|
2021-02-24T15:51:52.000Z
|
2021-02-24T15:51:52.000Z
|
test/tasks.cpp
|
CNR-STIIMA-IRAS/realtime_utilities
|
5500b4221ebab92d33b0f1dc7192da8a815b5998
|
[
"Apache-2.0"
] | 1
|
2019-12-17T00:42:54.000Z
|
2019-12-17T00:42:54.000Z
|
#include <iostream>
#include <functional>
#include "realtime_utilities/parallel_computing.h"
int main(int argc, char* argv[])
{
auto function = [](int a) -> int
{
std::cout << "inside: " << a * 10 << std::endl;
return a*10;
};
realtime_utilities::tasks tasks;
std::vector< std::future<int> > res;
for(size_t i=0; i<11; i++)
{
auto f = std::bind(function, i);
res.push_back( tasks.queue(f) );
}
tasks.start(5);
tasks.finish();
for(auto & ret : res)
{
std::cout << ret.get() << std::endl;
}
return 0;
}
| 16.909091
| 51
| 0.577061
|
CNR-STIIMA-IRAS
|
4beb6c64baf73a10fe3276a7f04d32df4c6d1d5f
| 41
|
hpp
|
C++
|
src/boost_config_platform_vms.hpp
|
miathedev/BoostForArduino
|
919621dcd0c157094bed4df752b583ba6ea6409e
|
[
"BSL-1.0"
] | 10
|
2018-03-17T00:58:42.000Z
|
2021-07-06T02:48:49.000Z
|
src/boost_config_platform_vms.hpp
|
miathedev/BoostForArduino
|
919621dcd0c157094bed4df752b583ba6ea6409e
|
[
"BSL-1.0"
] | 2
|
2021-03-26T15:17:35.000Z
|
2021-05-20T23:55:08.000Z
|
src/boost_config_platform_vms.hpp
|
miathedev/BoostForArduino
|
919621dcd0c157094bed4df752b583ba6ea6409e
|
[
"BSL-1.0"
] | 4
|
2019-05-28T21:06:37.000Z
|
2021-07-06T03:06:52.000Z
|
#include <boost/config/platform/vms.hpp>
| 20.5
| 40
| 0.780488
|
miathedev
|
4bf7ea3678948cc7b1420406fcee92633bdc1742
| 6,315
|
cpp
|
C++
|
src/v1/sqlitestatement.cpp
|
studiofuga/mSqliteCpp
|
d557d089bef57fd2ec5ece54d79ca8c34fbc6aca
|
[
"BSD-3-Clause"
] | 3
|
2018-06-25T20:02:26.000Z
|
2021-07-08T09:38:33.000Z
|
src/v1/sqlitestatement.cpp
|
studiofuga/mSqliteCpp
|
d557d089bef57fd2ec5ece54d79ca8c34fbc6aca
|
[
"BSD-3-Clause"
] | 13
|
2018-05-05T09:38:39.000Z
|
2021-03-17T11:48:07.000Z
|
src/v1/sqlitestatement.cpp
|
studiofuga/mSqliteCpp
|
d557d089bef57fd2ec5ece54d79ca8c34fbc6aca
|
[
"BSD-3-Clause"
] | null | null | null |
//
// Created by Federico Fuga on 16/12/17.
//
#include "msqlitecpp/v1/sqlitestatement.h"
using namespace sqlite;
struct sqlite::SQLiteStatement::Impl {
std::weak_ptr<SQLiteStorage> mDb;
sqlite3_stmt *stmt = nullptr;
};
sqlite::SQLiteStatement::SQLiteStatement()
{
}
sqlite::SQLiteStatement::SQLiteStatement(std::shared_ptr<SQLiteStorage> db,
const sqlite::statements::StatementFormatter &stmt)
{
attach(db,stmt);
}
sqlite::SQLiteStatement::SQLiteStatement(std::shared_ptr<SQLiteStorage> db, std::string sql)
{
attach(db,sql);
}
sqlite::SQLiteStatement::SQLiteStatement(std::shared_ptr<SQLiteStorage> db, const char *sql)
{
attach(db, sql);
}
sqlite::SQLiteStatement::~SQLiteStatement()
{
if (p != nullptr && p->stmt != nullptr)
sqlite3_finalize(p->stmt);
}
sqlite::SQLiteStatement::SQLiteStatement(SQLiteStatement &&) = default;
sqlite::SQLiteStatement &SQLiteStatement::operator =(SQLiteStatement &&) = default;
void SQLiteStatement::attach(std::shared_ptr<SQLiteStorage> dbm)
{
init(dbm);
}
void sqlite::SQLiteStatement::attach(std::shared_ptr<SQLiteStorage> dbm, std::string stmt)
{
init(dbm);
prepare(std::string(stmt));
}
void
sqlite::SQLiteStatement::attach(std::shared_ptr<SQLiteStorage> db, const sqlite::statements::StatementFormatter &stmt)
{
init(db);
prepare(stmt.string());
}
void SQLiteStatement::prepare(const sqlite::statements::StatementFormatter &stmt)
{
try {
prepare(stmt.string());
} catch (sqlite::SQLiteException &x) {
std::ostringstream ss;
ss << x.what() << ": " << stmt.string();
throw sqlite::SQLiteException(x, ss.str());
}
}
void SQLiteStatement::init(std::shared_ptr<SQLiteStorage> db)
{
p = (std::make_unique<Impl>());
p->mDb = db;
}
void SQLiteStatement::prepare(std::string sql)
{
auto db = p->mDb.lock();
auto r = sqlite3_prepare_v2(db->handle(), sql.c_str(), -1, &p->stmt, nullptr);
if (r != SQLITE_OK)
throw SQLiteException(db->handle(), sql);
}
void SQLiteStatement::bind(size_t idx, std::string value)
{
auto db = p->mDb.lock();
auto r = sqlite3_bind_text(p->stmt, idx, value.c_str(), value.length(), SQLITE_TRANSIENT);
SQLiteException::throwIfNotOk(r,db->handle());
}
void SQLiteStatement::bind(size_t idx, unsigned long long value)
{
auto db = p->mDb.lock();
auto r = sqlite3_bind_int64(p->stmt, idx, value);
SQLiteException::throwIfNotOk(r,db->handle());
}
void SQLiteStatement::bind(size_t idx, long long value)
{
auto db = p->mDb.lock();
auto r = sqlite3_bind_int64(p->stmt, idx, value);
SQLiteException::throwIfNotOk(r,db->handle());
}
void SQLiteStatement::bind(size_t idx, unsigned long value)
{
auto db = p->mDb.lock();
auto r = sqlite3_bind_int64(p->stmt, idx, value);
SQLiteException::throwIfNotOk(r,db->handle());
}
void SQLiteStatement::bind(size_t idx, long value)
{
auto db = p->mDb.lock();
auto r = sqlite3_bind_int64(p->stmt, idx, value);
SQLiteException::throwIfNotOk(r,db->handle());
}
void SQLiteStatement::bind(size_t idx, unsigned int value)
{
auto db = p->mDb.lock();
auto r = sqlite3_bind_int(p->stmt, idx, value);
SQLiteException::throwIfNotOk(r,db->handle());
}
void SQLiteStatement::bind(size_t idx, int value)
{
auto db = p->mDb.lock();
auto r = sqlite3_bind_int(p->stmt, idx, value);
SQLiteException::throwIfNotOk(r,db->handle());
}
void SQLiteStatement::bind(size_t idx, double value)
{
auto db = p->mDb.lock();
auto r = sqlite3_bind_double(p->stmt, idx, value);
SQLiteException::throwIfNotOk(r,db->handle());
}
void SQLiteStatement::bind(size_t idx, float value)
{
auto db = p->mDb.lock();
auto r = sqlite3_bind_double(p->stmt, idx, value);
SQLiteException::throwIfNotOk(r,db->handle());
}
void SQLiteStatement::bind(size_t idx, std::nullptr_t value)
{
auto db = p->mDb.lock();
auto r = sqlite3_bind_null(p->stmt, idx);
SQLiteException::throwIfNotOk(r,db->handle());
}
long long SQLiteStatement::getLongValue(int idx)
{
return sqlite3_column_int64(p->stmt, idx);
}
unsigned long long SQLiteStatement::getULongValue(int idx)
{
return sqlite3_column_int64(p->stmt, idx);
}
int SQLiteStatement::getIntValue(int idx)
{
return sqlite3_column_int(p->stmt, idx);
}
double SQLiteStatement::getDoubleValue(int idx)
{
return sqlite3_column_double(p->stmt, idx);
}
std::string SQLiteStatement::getStringValue(int idx)
{
auto sptr = sqlite3_column_text(p->stmt, idx);
auto len = sqlite3_column_bytes(p->stmt, idx);
return std::string(sptr, sptr + len);
}
SQLiteStatement::QueryResult SQLiteStatement::executeStep(std::function<bool()> func)
{
auto db = p->mDb.lock();
auto r = sqlite3_step(p->stmt);
if (r == SQLITE_DONE) {
return QueryResult::Completed;
} else if (r != SQLITE_ROW) {
SQLiteException::throwIfNotOk(r, db->handle());
}
return (func() ? QueryResult::Ongoing : QueryResult::Aborted);
}
SQLiteStatement::QueryResult SQLiteStatement::executeStep()
{
return executeStep([]() { return true; });
}
FieldType::Type SQLiteStatement::columnType(int idx)
{
switch (sqlite3_column_type(p->stmt, idx)) {
case SQLITE_TEXT:
return FieldType::Type::Text;
case SQLITE_INTEGER:
return FieldType::Type::Integer;
case SQLITE_FLOAT:
return FieldType::Type::Real;
case SQLITE_BLOB:
return FieldType::Type::Blob;
}
throw std::runtime_error("Unhandled sqlite3 type");
}
bool SQLiteStatement::isNull(int idx)
{
return sqlite3_column_type(p->stmt, idx) == SQLITE_NULL;
}
int SQLiteStatement::columnCount()
{
return sqlite3_column_count(p->stmt);
}
bool SQLiteStatement::execute(std::function<bool()> function)
{
QueryResult result;
try {
while ((result = executeStep(function)) == SQLiteStatement::QueryResult::Ongoing);
} catch (SQLiteException &) {
sqlite3_reset(p->stmt); // Reset the statement before throwing again
throw;
}
sqlite3_reset(p->stmt);
sqlite3_clear_bindings(p->stmt);
return result == SQLiteStatement::QueryResult::Completed;
}
bool SQLiteStatement::execute()
{
return execute([]() { return true; });
}
| 25.566802
| 118
| 0.674426
|
studiofuga
|
ef042e8b371aad1b5c30e9b16df40b0c48210aad
| 2,630
|
cpp
|
C++
|
updater/src/Extractor.cpp
|
debugzxcv/unnamed-sdvx-clone
|
ceedc21666b2597551324714b536d2478a584200
|
[
"MIT"
] | null | null | null |
updater/src/Extractor.cpp
|
debugzxcv/unnamed-sdvx-clone
|
ceedc21666b2597551324714b536d2478a584200
|
[
"MIT"
] | null | null | null |
updater/src/Extractor.cpp
|
debugzxcv/unnamed-sdvx-clone
|
ceedc21666b2597551324714b536d2478a584200
|
[
"MIT"
] | null | null | null |
#include "Extractor.hpp"
#include <iostream>
#include <stdexcept>
#include "archive.h"
#include "archive_entry.h"
void Extractor::Extract(const std::string_view data)
{
struct archive* src = CreateRead(data);
struct archive* dst = CreateDiskWrite();
try
{
CopyArchive(src, dst);
}
catch (...)
{
archive_read_free(src);
archive_write_free(dst);
throw;
}
archive_read_free(src);
archive_write_free(dst);
}
archive* Extractor::CreateRead(const std::string_view data)
{
struct archive* a = archive_read_new();
archive_read_support_format_all(a);
archive_read_support_compression_all(a);
if (int r = archive_read_open_memory(a, data.data(), data.size()))
{
archive_read_free(a);
throw std::runtime_error("Failed to open the archive.");
}
return a;
}
archive* Extractor::CreateDiskWrite()
{
int flags = 0;
flags |= ARCHIVE_EXTRACT_TIME;
flags |= ARCHIVE_EXTRACT_ACL;
flags |= ARCHIVE_EXTRACT_FFLAGS;
flags |= ARCHIVE_EXTRACT_SECURE_NODOTDOT;
flags |= ARCHIVE_EXTRACT_SECURE_SYMLINKS;
struct archive* a = archive_write_disk_new();
archive_write_disk_set_options(a, flags);
archive_write_disk_set_standard_lookup(a);
return a;
}
// https://github.com/libarchive/libarchive/wiki/Examples#a-complete-extractor
static void WarnOrThrow(int code, archive* a, int throw_level)
{
if (code < throw_level) throw std::runtime_error(archive_error_string(a));
if (code < ARCHIVE_OK)
{
std::cerr << "- Warning: " << archive_error_string(a) << std::endl;
}
}
void Extractor::CopyArchive(archive* src, archive* dst)
{
struct archive_entry* entry = nullptr;
for (;;)
{
int r = archive_read_next_header(src, &entry);
if (r == ARCHIVE_EOF) break;
if (r < ARCHIVE_WARN) throw std::runtime_error(archive_error_string(src));
std::cout << "Extracting \"" << archive_entry_pathname(entry) << "\"..." << std::endl;
if (r < ARCHIVE_OK)
{
std::cerr << "- Warning: " << archive_error_string(src) << std::endl;
}
r = archive_write_header(dst, entry);
if (r < ARCHIVE_OK)
{
std::cerr << "- Warning: " << archive_error_string(dst) << std::endl;
}
else if (archive_entry_size(entry) > 0)
{
CopyArchiveData(src, dst);
}
}
}
void Extractor::CopyArchiveData(archive* src, archive* dst)
{
int r;
const void* buff;
size_t size;
la_int64_t offset;
for (;;) {
r = archive_read_data_block(src, &buff, &size, &offset);
if (r == ARCHIVE_EOF) break;
WarnOrThrow(r, src, ARCHIVE_OK);
r = archive_write_data_block(dst, buff, size, offset);
WarnOrThrow(r, dst, ARCHIVE_OK);
}
r = archive_write_finish_entry(dst);
WarnOrThrow(r, dst, ARCHIVE_WARN);
}
| 21.209677
| 88
| 0.70038
|
debugzxcv
|
ef057c271c7c3e886c6e16f0050b8190a0e3ba37
| 7,451
|
cpp
|
C++
|
YAX/src/Vector4.cpp
|
Swillis57/YAX
|
cc366b99af9bbce1d1a3a3580fad9f6c50bbfb4e
|
[
"MS-PL"
] | 1
|
2015-01-29T01:58:56.000Z
|
2015-01-29T01:58:56.000Z
|
YAX/src/Vector4.cpp
|
Swillis57/YAX
|
cc366b99af9bbce1d1a3a3580fad9f6c50bbfb4e
|
[
"MS-PL"
] | 1
|
2015-03-27T11:21:08.000Z
|
2015-03-27T11:21:08.000Z
|
YAX/src/Vector4.cpp
|
Swillis57/YAX
|
cc366b99af9bbce1d1a3a3580fad9f6c50bbfb4e
|
[
"MS-PL"
] | null | null | null |
#include "Vector4.h"
#include "Matrix.h"
#include "MathHelper.h"
#include "Quaternion.h"
#include "Vector2.h"
#include "Vector3.h"
namespace YAX
{
const Vector4 One = Vector4(1, 1, 1, 1);
const Vector4 UnitX = Vector4(1, 0, 0, 0);
const Vector4 UnitY = Vector4(0, 1, 0, 0);
const Vector4 UnitZ = Vector4(0, 0, 1, 0);
const Vector4 UnitW = Vector4(0, 0, 0, 1);
const Vector4 Zero = Vector4(0, 0, 0, 0);
Vector4::Vector4()
: Vector4(0.0f)
{}
Vector4::Vector4(float v)
: X(v), Y(v), Z(v), W(v)
{}
Vector4::Vector4(float x, float y, float z, float w)
: X(x), Y(y), Z(z), W(w)
{}
Vector4::Vector4(Vector2 xy, float z, float w)
: Vector4(xy.X, xy.Y, z, w)
{}
Vector4::Vector4(Vector3 xyz, float w)
: Vector4(xyz.X, xyz.Y, xyz.Z, w)
{}
void Vector4::Normalize()
{
*this /= this->Length();
}
float Vector4::Length()
{
return std::sqrtf(LengthSquared());
}
float Vector4::LengthSquared()
{
return X*X + Y*Y + Z*Z + W*W;
}
Vector4 Vector4::Barycentric(const Vector4& p1, const Vector4& p2, const Vector4& p3, float b2, float b3)
{
return (1 - b2 - b3)*p1 + b2*p2 + b3*p3;
}
Vector4 Vector4::CatmullRom(const Vector4& p1, const Vector4& p2, const Vector4& p3, const Vector4& p4, float t)
{
return Vector4(MathHelper::CatmullRom(p1.X, p2.X, p3.X, p4.X, t),
MathHelper::CatmullRom(p1.Y, p2.Y, p3.Y, p4.Y, t),
MathHelper::CatmullRom(p1.Z, p2.Z, p3.Z, p4.Z, t),
MathHelper::CatmullRom(p1.W, p2.W, p3.W, p4.W, t));
}
Vector4 Vector4::Clamp(const Vector4& val, const Vector4& min, const Vector4& max)
{
return Vector4(MathHelper::Clamp(val.X, min.X, max.X),
MathHelper::Clamp(val.X, min.X, max.X),
MathHelper::Clamp(val.X, min.X, max.X),
MathHelper::Clamp(val.X, min.X, max.X));
}
float Vector4::Distance(const Vector4& p1, const Vector4& p2)
{
return std::sqrtf(DistanceSquared(p1, p2));
}
float Vector4::DistanceSquared(const Vector4& p1, const Vector4& p2)
{
return (p1 - p2).LengthSquared();
}
float Vector4::Dot(const Vector4& v1, const Vector4& v2)
{
return (v1.X*v2.X + v1.Y*v2.Y + v1.Z*v2.Z + v1.W*v2.W);
}
Vector4 Vector4::Hermite(const Vector4& p1, const Vector4& t1, const Vector4& p2, const Vector4& t2, float amt)
{
return Vector4(MathHelper::Hermite(p1.X, t1.X, p2.X, t2.X, amt),
MathHelper::Hermite(p1.Y, t1.Y, p2.Y, t2.Y, amt),
MathHelper::Hermite(p1.Z, t1.Z, p2.Z, t2.Z, amt),
MathHelper::Hermite(p1.W, t1.W, p2.W, t2.W, amt));
}
Vector4 Vector4::Lerp(const Vector4& f, const Vector4& to, float t)
{
return Vector4(MathHelper::Lerp(f.X, to.X, t),
MathHelper::Lerp(f.Y, to.Y, t),
MathHelper::Lerp(f.Z, to.Z, t),
MathHelper::Lerp(f.W, to.W, t));
}
Vector4 Vector4::Max(const Vector4& v1, const Vector4& v2)
{
return Vector4(MathHelper::Max(v1.X, v2.X),
MathHelper::Max(v1.Y, v2.Y),
MathHelper::Max(v1.Z, v2.Z),
MathHelper::Max(v1.W, v2.W));
}
Vector4 Vector4::Min(const Vector4& v1, const Vector4& v2)
{
return Vector4(MathHelper::Min(v1.X, v2.X),
MathHelper::Min(v1.Y, v2.Y),
MathHelper::Min(v1.Z, v2.Z),
MathHelper::Min(v1.W, v2.W));
}
Vector4 Vector4::Normalize(Vector4 v)
{
v.Normalize();
return v;
}
Vector4 Vector4::SmoothStep(const Vector4& f, const Vector4& to, float t)
{
return Vector4(MathHelper::SmoothStep(f.X, to.X, t),
MathHelper::SmoothStep(f.Y, to.Y, t),
MathHelper::SmoothStep(f.Z, to.Z, t),
MathHelper::SmoothStep(f.W, to.W, t));
}
Vector4 Vector4::Transform(const Vector4& v, const Matrix& m)
{
float x = v.X*m.M11 + v.Y*m.M21 + v.Z*m.M31 + v.W*m.M41;
float y = v.X*m.M12 + v.Y*m.M22 + v.Z*m.M32 + v.W*m.M42;
float z = v.X*m.M13 + v.Y*m.M23 + v.Z*m.M33 + v.W*m.M43;
float w = v.X*m.M14 + v.Y*m.M24 + v.Z*m.M34 + v.W*m.M44;
return Vector4(x, y, z, w);
}
Vector4 Vector4::Transform(const Vector4& v, const Quaternion& q)
{
Quaternion vQ(v.X, v.Y, v.Z, v.W);
Quaternion res = q*vQ*Quaternion::Inverse(q);
return Vector4(res.X, res.Y, res.Z, res.W);
}
void Vector4::Transform(const std::vector<Vector4>& source, i32 sourceIdx, const Matrix& mat, std::vector<Vector4>& dest, i32 destIdx, i32 count)
{
for (i32 i = sourceIdx; i < sourceIdx + count; i++)
{
dest[destIdx + (i - sourceIdx)] = Transform(source[i], mat);
}
}
void Vector4::Transform(const std::vector<Vector4>& source, i32 sourceIdx, const Quaternion& q, std::vector<Vector4>& dest, i32 destIdx, i32 count)
{
for (i32 i = sourceIdx; i < sourceIdx + count; i++)
{
dest[destIdx + (i - sourceIdx)] = Transform(source[i], q);
}
}
void Vector4::Transform(const std::vector<Vector4>& source, const Matrix& mat, std::vector<Vector4>& dest)
{
Transform(source, 0, mat, dest, 0, source.size());
}
void Vector4::Transform(const std::vector<Vector4>& source, const Quaternion& q, std::vector<Vector4>& dest)
{
Transform(source, 0, q, dest, 0, source.size());
}
Vector4 Vector4::TransformNormal(const Vector4& norm, const Matrix& mat)
{
float x = norm.X*mat.M11 + norm.Y*mat.M21 + norm.Z*mat.M31;
float y = norm.X*mat.M12 + norm.Y*mat.M22 + norm.Z*mat.M32;
float z = norm.X*mat.M13 + norm.Y*mat.M23 + norm.Z*mat.M33;
float w = norm.X*mat.M14 + norm.Y*mat.M24 + norm.Z*mat.M34;
return Vector4(x, y, z, 0);
}
void Vector4::TransformNormal(const std::vector<Vector4>& source, i32 sourceIdx, const Matrix& mat, std::vector<Vector4>& dest, i32 destIdx, i32 count)
{
for (i32 i = sourceIdx; i < sourceIdx + count; i++)
{
dest[destIdx + (i - sourceIdx)] = TransformNormal(source[i], mat);
}
}
void Vector4::TransformNormal(const std::vector<Vector4>& source, const Matrix& mat, std::vector<Vector4>& dest)
{
TransformNormal(source, 0, mat, dest, 0, source.size());
}
Vector4& Vector4::operator+=(const Vector4& v)
{
X += v.X;
Y += v.Y;
Z += v.Z;
W += v.W;
return *this;
}
Vector4& Vector4::operator-=(const Vector4& v)
{
X /= v.X;
Y /= v.Y;
Z /= v.Z;
W /= v.W;
return *this;
}
Vector4& Vector4::operator*=(const Vector4& v)
{
X *= v.X;
Y *= v.Y;
Z *= v.Z;
W *= v.W;
return *this;
}
Vector4& Vector4::operator*=(float f)
{
X *= f;
Y *= f;
Z *= f;
W *= f;
return *this;
}
Vector4& Vector4::operator/=(const Vector4& v)
{
X /= v.X;
Y /= v.Y;
Z /= v.Z;
W /= v.W;
return *this;
}
Vector4& Vector4::operator/=(float f)
{
X /= f;
Y /= f;
Z /= f;
W /= f;
return *this;
}
Vector4 operator+(Vector4 lhs, const Vector4& rhs)
{
lhs += rhs;
return lhs;
}
Vector4 operator-(Vector4 lhs, const Vector4& rhs)
{
lhs -= rhs;
return lhs;
}
Vector4 operator*(Vector4 lhs, const Vector4& rhs)
{
lhs *= rhs;
return lhs;
}
Vector4 operator*(float lhs, Vector4 rhs)
{
rhs *= lhs;
return rhs;
}
Vector4 operator*(Vector4 lhs, float rhs)
{
return rhs*lhs;
}
Vector4 operator/(Vector4 lhs, const Vector4& rhs)
{
lhs /= rhs;
return lhs;
}
Vector4 operator/(Vector4 lhs, float rhs)
{
lhs /= rhs;
return lhs;
}
Vector4 operator-(Vector4 rhs)
{
rhs.X = -rhs.X;
rhs.Y = -rhs.Y;
rhs.Z = -rhs.Z;
rhs.W = -rhs.W;
return rhs;
}
bool operator==(const Vector4& lhs, const Vector4& rhs)
{
return lhs.X == rhs.X
&& lhs.Y == rhs.Y
&& lhs.Z == rhs.Z
&& lhs.W == rhs.W;
}
bool operator!=(const Vector4& lhs, const Vector4& rhs)
{
return !(lhs == rhs);
}
}
| 23.357367
| 152
| 0.610522
|
Swillis57
|
ef086a03619f9cb0f6fcd0eef3e57c5dcc570252
| 2,494
|
cpp
|
C++
|
CGImysql/sql_connection_pool.cpp
|
luanshaaa/http-WebServer
|
0cf64b5e7c9d41325148b6aa398d6bcec448b76b
|
[
"Apache-2.0"
] | 1
|
2021-09-20T01:26:51.000Z
|
2021-09-20T01:26:51.000Z
|
CGImysql/sql_connection_pool.cpp
|
luanshaaa/http-WebServer
|
0cf64b5e7c9d41325148b6aa398d6bcec448b76b
|
[
"Apache-2.0"
] | null | null | null |
CGImysql/sql_connection_pool.cpp
|
luanshaaa/http-WebServer
|
0cf64b5e7c9d41325148b6aa398d6bcec448b76b
|
[
"Apache-2.0"
] | null | null | null |
//
// sql_connection_pool.cpp
//
//
// Created by apple on 8/18/21.
//
#include <stdio.h>
connection_pool::connection_pool()
{
this->CurConn=0;
this->FreeConn=0;
}
//RAII机制销毁连接池
connection_pool::~connection_pool()
{
DestroyPool();
}
//构造初始化
void connection_pool::init(string url, string User,string PassWord, string DBName, int Port, unsigned int MaxConn)
{
//初始化数据库信息
this->url=url;
this->Port=Port;
this->User=User;
this->PassWord=PassWord;
this->DatabaseName=DBName;
//创建MaxConn条数据库连接
for(int i=0;i<MaxConn;i++)
{
MYSQL *con=NULL;
con=mysql_init(con);
if(con==NULL)
{
cout<<"Error:"<<mysql_error(con);
exit(1);
}
con=mysql_real_connect(con,url.c_str(),User.c_str(),PassWord.c_str(),DBName.c_str(),Port,NULL,0);
if(con==NULL)
{
cout<<"Error: "<<mysql_error(con);
exit(1);
}
//更新连接池和空闲连接数量
connList.push_back(con);
++FreeConn;
}
//将信号量初始化为最大连接次数
reserve=sem(FreeConn);
this->MaxConn=FreeConn;
}
//当有请求时,从数据库连接池中返回一个可用连接,更新使用和空闲连接数
MYSQL *connection_pool::GetConnection()
{
MYSQL *con=NULL;
if(0==connlist.size())
return NULL;
//取出连接,信号量原子减1,为0则等待
reserve.wait();
lock.lock();
con=connList.front();
connList.pop_front();
//这里的两个变量没有用到
--FreeConn;
++CurConn;
lock.unlock();
return con;
}
//释放当前使用的连接
bool connection_pool::ReleaseConnection(MYSQL *con)
{
if(con==NULL)
return false;
lock.lock();
connList.push_back(con);
++FreeConn;
--CurConn;
lock.unlock();
//释放连接原子加1
reserve.post();
return true;
}
//销毁数据库连接池
void connection_pool::DestroyPool()
{
lock.lock();
if(connList.size()>0)
{
//通过迭代器遍历,关闭数据库连接
list<MYSQL *>::iterator it;
for(it=connList.begin();it!=connList.end();++it)
{
MYSQL *con=*it;
mysql_close(con);
}
CurConn=0;
FreeConn=0;
//清空list
connList.clear();
lock.unlock();
}
lock.unlock();
}
connectionRAII::connectionRAII(MYSQL **SQL,connection_pool *connPool)
{
*SQL=connPool->GetConnection();
conRAII=*SQL;
poolRAII=connPool;
}
connectionRAII::~connectionRAII()
{
poolRAII->ReleaseConnection(conRAII);
}
| 17.56338
| 114
| 0.556937
|
luanshaaa
|
ef0eac238d569447382aa06fe75a6fa29ba0979b
| 3,588
|
cc
|
C++
|
src/solv_simple/restarts.cc
|
nerdling/SBSAT
|
6328c6aa105b75693d06bf0dae4a3b5ca220318b
|
[
"Unlicense"
] | 4
|
2015-03-08T07:56:29.000Z
|
2017-10-12T04:19:27.000Z
|
src/solv_simple/restarts.cc
|
nerdling/SBSAT
|
6328c6aa105b75693d06bf0dae4a3b5ca220318b
|
[
"Unlicense"
] | null | null | null |
src/solv_simple/restarts.cc
|
nerdling/SBSAT
|
6328c6aa105b75693d06bf0dae4a3b5ca220318b
|
[
"Unlicense"
] | null | null | null |
/* =========FOR INTERNAL USE ONLY. NO DISTRIBUTION PLEASE ========== */
/*********************************************************************
Copyright 1999-2007, University of Cincinnati. All rights reserved.
By using this software the USER indicates that he or she has read,
understood and will comply with the following:
--- University of Cincinnati hereby grants USER nonexclusive permission
to use, copy and/or modify this software for internal, noncommercial,
research purposes only. Any distribution, including commercial sale
or license, of this software, copies of the software, its associated
documentation and/or modifications of either is strictly prohibited
without the prior consent of University of Cincinnati. Title to copyright
to this software and its associated documentation shall at all times
remain with University of Cincinnati. Appropriate copyright notice shall
be placed on all software copies, and a complete copy of this notice
shall be included in all copies of the associated documentation.
No right is granted to use in advertising, publicity or otherwise
any trademark, service mark, or the name of University of Cincinnati.
--- This software and any associated documentation is provided "as is"
UNIVERSITY OF CINCINNATI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS
OR IMPLIED, INCLUDING THOSE OF MERCHANTABILITY OR FITNESS FOR A
PARTICULAR PURPOSE, OR THAT USE OF THE SOFTWARE, MODIFICATIONS, OR
ASSOCIATED DOCUMENTATION WILL NOT INFRINGE ANY PATENTS, COPYRIGHTS,
TRADEMARKS OR OTHER INTELLECTUAL PROPERTY RIGHTS OF A THIRD PARTY.
University of Cincinnati shall not be liable under any circumstances for
any direct, indirect, special, incidental, or consequential damages
with respect to any claim by USER or any third party on account of
or arising from the use, or inability to use, this software or its
associated documentation, even if University of Cincinnati has been advised
of the possibility of those damages.
*********************************************************************/
#include "sbsat.h"
#include "sbsat_solver.h"
#include "solver.h"
int use_RapidRestarts;
void (*Simple_initRestart)() = NULL;
long (*Simple_nextRestart)() = NULL;
//These routines modeled off of SAT4J code posted here:
//http://www.satcompetition.org/gorydetails/?p=3
//Routines for MiniSAT style restarts
long MiniSAT_RestartBound;
void MiniSAT_initRestart() {
MiniSAT_RestartBound = 100;
}
long MiniSAT_nextRestart() {
return MiniSAT_RestartBound *= 1.5;
}
//-----------------------------------
//Routines for PicoSAT style restarts
double PicoSAT_inner, PicoSAT_outer;
long PicoSAT_RestartBound;
void PicoSAT_initRestart() {
PicoSAT_inner = 100;
PicoSAT_outer = 100;
PicoSAT_RestartBound = PicoSAT_inner;
}
long PicoSAT_nextRestart() {
if (PicoSAT_inner >= PicoSAT_outer) {
PicoSAT_outer *= 1.1;
PicoSAT_inner = 100;
} else {
PicoSAT_inner *= 1.1;
}
return PicoSAT_inner;
}
//-----------------------------------
//Routines for Luby style restarts
//taken from SATZ_rand source code
long Luby_factor;
long Luby_count;
long luby_super(long i) {
long power;
long k;
assert (i > 0);
/* let 2^k be the least power of 2 >= (i+1) */
k = 1;
power = 2;
while (power < (i + 1)) {
k += 1;
power *= 2;
}
if (power == (i + 1))
return (power / 2);
return (luby_super(i - (power / 2) + 1));
}
void Luby_initRestart() {
Luby_factor = 512;//32;
Luby_count = 1;
}
long Luby_nextRestart() {
return luby_super(Luby_count++)*Luby_factor;
}
//-----------------------------------
| 29.652893
| 76
| 0.698997
|
nerdling
|
ef1232f9fdd43727761e20d6f30d761879cc5982
| 8,361
|
cpp
|
C++
|
lab1/debug-exercise/abc.cpp
|
karl97/KompilatorerLabbz
|
761f0536582050cb245972f6fd9a612e8d1a570f
|
[
"Apache-2.0"
] | null | null | null |
lab1/debug-exercise/abc.cpp
|
karl97/KompilatorerLabbz
|
761f0536582050cb245972f6fd9a612e8d1a570f
|
[
"Apache-2.0"
] | null | null | null |
lab1/debug-exercise/abc.cpp
|
karl97/KompilatorerLabbz
|
761f0536582050cb245972f6fd9a612e8d1a570f
|
[
"Apache-2.0"
] | null | null | null |
// ------------------------------------------
// File abc.cc
// ------------------------------------------
#include <string>
#include "a.h"
#include "abscissa.h"
#include "absurdum.h"
#include "ack.h"
#include "abc.h"
// ------------------------------------------
int* allafall(int fasa, std::string* fast) {
if (fasa > 3 || *fast == "fastighetsbeskattning")
return new int (26703);
int fasta = fasa + 1;
std::string fatt("fauna");
int fattning = aning(&fasta, fatt);
std::string feedback("felhantering");
int feldetektering = anslutningspropp(&fasta, feedback);
std::string felskrivning("fem");
int felstavning = alltnog(&fasta, felskrivning);
std::string* femma = new std::string("fena");
std::string femte = almanacka(fasta, femma);
std::string fetstil("fickplunta");
int ficka = annars(&fasta, fetstil);
int* filaccessbeordring = new int(5808);
return filaccessbeordring;
} // allafall
// ------------------------------------------
std::string* allah(int* filmkamera, std::string filt) {
if (*filmkamera > 4 || filt == "finansiering")
return new std::string("fink");
int filtrering = *filmkamera + 1;
std::string finka("finnas");
int finland = annanstans(&filtrering, finka);
std::string finnes("firma");
int finns = aning(&filtrering, finnes);
std::string* fisk = new std::string("flagga");
std::string fixering = antagligen(filtrering, fisk);
std::string* flamma = new std::string("flaskhals");
std::string flaska = anmaning(filtrering, flamma);
std::string flicka("flinga");
std::string* flik = anledning(&filtrering, flicka);
std::string* flisa = new std::string("floppydisk");
std::string flock = almanacka(filtrering, flisa);
std::string flora("fluga");
std::string* flotta = anordning(&filtrering, flora);
std::string* flygning = new std::string("flyttning");
return flygning;
} // allah
// ------------------------------------------
int* alldeles(int fogde, std::string* folkskola) {
if (fogde > 6 || *folkskola == "form")
return new int (18247);
int fordring = fogde + 1;
std::string* formalisering = new std::string("formelbehandling");
int* formattering = anno(fordring, formalisering);
std::string* formligen = new std::string("forntida");
int* formulering = allokering(fordring, formligen);
std::string* forskning = new std::string("fortfarande");
int* fortbildning = aftonsol(fordring, forskning);
std::string fortplantning("fortvarande");
std::string* forts = alltihop(&fordring, fortplantning);
std::string fotboll("fotokopia");
int fotogenlampa = annanstans(&fordring, fotboll);
std::string fotostatkopiering("frammatning");
int frack = anslutningspropp(&fordring, fotostatkopiering);
int* framme = new int(29088);
return framme;
} // alldeles
// ------------------------------------------
std::string* allehanda(int* framsida, std::string framtagning) {
if (*framsida > 6 || framtagning == "frost")
return new std::string("frukost");
int fredag = *framsida + 1;
std::string* frys = new std::string("fullo");
std::string fuga = al(fredag, frys);
std::string fundering("funktionsuppdelning");
std::string* funktionsbeskrivning = alltsammans(&fredag, fundering);
std::string* funnits = new std::string("fy");
std::string futurum = alltid(fredag, funnits);
std::string fyllning("fyra");
int fyr = allena(&fredag, fyllning);
std::string g("gamling");
std::string* gam = allehanda(&fredag, g);
std::string gammal("ganska");
std::string* gammalt = anordning(&fredag, gammal);
std::string* gata = new std::string("gatsten");
return gata;
} // allehanda
// ------------------------------------------
int allena(int* genast, std::string genaste) {
if (*genast > 3 || genaste == "generering")
return 27589;
int generalisering = *genast + 1;
std::string* gentemot = new std::string("gissning");
int* gerilla = allafall(generalisering, gentemot);
std::string* gissningsvis = new std::string("givetvis");
int* giv = alltmer(generalisering, gissningsvis);
std::string* glada = new std::string("glaskupa");
int* glansis = allafall(generalisering, glada);
std::string glass("glidning");
int glest = allena(&generalisering, glass);
std::string glimt("gloria");
std::string* glipa = alltihop(&generalisering, glimt);
std::string* gnista = new std::string("godan");
int* gnutta = anno(generalisering, gnista);
std::string* goddagens = new std::string("goja");
std::string goding = almanacka(generalisering, goddagens);
std::string* gol = new std::string("golfklubb");
int* golfbana = allafall(generalisering, gol);
std::string golfklubba("golvspringa");
std::string* golvlampa = alfa(&generalisering, golfklubba);
int grabb(1092);
return grabb;
} // allena
// ------------------------------------------
int allesammans(int* gradering, std::string grammofonskiva) {
if (*gradering > 5 || grammofonskiva == "grandessa")
return 12390;
int gran = *gradering + 1;
std::string* grandeur = new std::string("grattis");
std::string granskning = anmaning(gran, grandeur);
std::string grav("grekiska");
std::string* grejor = alfa(&gran, grav);
std::string* gren = new std::string("grill");
int* grevinna = anhopning(gran, gren);
std::string grind("groda");
int gris = aha(&gran, grind);
std::string* grodd = new std::string("grop");
int* grogg = alltmera(gran, grodd);
int grotta(12970);
return grotta;
} // allesammans
// ------------------------------------------
int allihop(int* grundlag, std::string grundskola) {
if (*grundlag > 5 || grundskola == "grundval")
return 19571;
int grundtank = *grundlag + 1;
std::string* gruppering = new std::string("gryning");
std::string gruva = al(grundtank, gruppering);
std::string* gryta = new std::string("gud");
int* grytbit = alls(grundtank, gryta);
std::string gudi("guldgruva");
std::string* gudinna = alfa(&grundtank, gudi);
std::string* gumma = new std::string("h");
int* gurka = algebra(grundtank, gumma);
std::string* ha = new std::string("haft");
std::string hade = alika(grundtank, ha);
int haha(24233);
return haha;
} // allihop
// ------------------------------------------
int* allmoge(int haj, std::string* haka) {
if (haj > 3 || *haka == "hals")
return new int (11863);
int hall = haj + 1;
std::string* halshuggning = new std::string("halvannan");
int* halva = ann(hall, halshuggning);
std::string halvering("halvsanning");
int halvkugg = allihop(&hall, halvering);
std::string* halvt = new std::string("hamn");
int* halvtannat = aftonsol(hall, halvt);
std::string* handflata = new std::string("handledning");
int* handha = aj(hall, handflata);
std::string* handling = new std::string("handstil");
std::string handskakning = amortering(hall, handling);
std::string* hantering = new std::string("harpa");
int* har = allmoge(hall, hantering);
int* hatt = new int(25907);
return hatt;
} // allmoge
// ------------------------------------------
int* allokering(int havsyta, std::string* hebreiska) {
if (havsyta > 3 || *hebreiska == "hedning")
return new int (13192);
int hed = havsyta + 1;
std::string hej("hela");
std::string* hejsan = ampere(&hed, hej);
std::string heller("helst");
int hellre = andel(&hed, heller);
std::string hem("hemresa");
int hemma = allteftersom(&hed, hem);
std::string herde("hetat");
int hertig = annars(&hed, herde);
std::string hexkodning("hink");
int hifi = alltnog(&hed, hexkodning);
int* hiss = new int(12388);
return hiss;
} // allokering
// ------------------------------------------
int* allra(int hit, std::string* hittills) {
if (hit > 5 || *hittills == "hjord")
return new int (9833);
int hittillsvarande = hit + 1;
std::string* hjort = new std::string("honom");
std::string hon = al(hittillsvarande, hjort);
std::string* honung = new std::string("hopkoppling");
int* hop = alltmera(hittillsvarande, honung);
std::string* hoppning = new std::string("hopslagning");
int* hoppsan = ande(hittillsvarande, hoppning);
std::string* hoptagning = new std::string("hu");
int* hos = allmoge(hittillsvarande, hoptagning);
std::string* hud = new std::string("humla");
int* huller = ann(hittillsvarande, hud);
int* hund = new int(31313);
return hund;
} // allra
// ------------------------------------------
| 35.88412
| 70
| 0.625045
|
karl97
|
ef16aac990f3496622a597797813a9656f0b37bc
| 5,236
|
hpp
|
C++
|
src/modules/flight_mode_manager/tasks/AutoLineSmoothVel/FlightTaskAutoLineSmoothVel.hpp
|
CQBIT/Firmware
|
6a60fba96de255134ac0e021cd1f31c67be95d74
|
[
"BSD-3-Clause"
] | 1
|
2020-05-29T01:05:18.000Z
|
2020-05-29T01:05:18.000Z
|
src/modules/flight_mode_manager/tasks/AutoLineSmoothVel/FlightTaskAutoLineSmoothVel.hpp
|
ZMurphyy/Firmware
|
177fe4bade08440a0ae2c2679d5972b8e316ec66
|
[
"BSD-3-Clause"
] | null | null | null |
src/modules/flight_mode_manager/tasks/AutoLineSmoothVel/FlightTaskAutoLineSmoothVel.hpp
|
ZMurphyy/Firmware
|
177fe4bade08440a0ae2c2679d5972b8e316ec66
|
[
"BSD-3-Clause"
] | null | null | null |
/****************************************************************************
*
* Copyright (c) 2018 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name PX4 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.
*
****************************************************************************/
/**
* @file FlightTaskAutoLineSmoothVel.hpp
*
* Flight task for autonomous, gps driven mode. The vehicle flies
* along a straight line in between waypoints.
*/
#pragma once
#include "FlightTaskAuto.hpp"
#include <motion_planning/PositionSmoothing.hpp>
#include "Sticks.hpp"
#include "StickAccelerationXY.hpp"
#include "StickYaw.hpp"
class FlightTaskAutoLineSmoothVel : public FlightTaskAuto
{
public:
FlightTaskAutoLineSmoothVel();
virtual ~FlightTaskAutoLineSmoothVel() = default;
bool activate(const vehicle_local_position_setpoint_s &last_setpoint) override;
void reActivate() override;
bool update() override;
private:
PositionSmoothing _position_smoothing;
Vector3f _unsmoothed_velocity_setpoint;
protected:
/** Reset position or velocity setpoints in case of EKF reset event */
void _ekfResetHandlerPositionXY(const matrix::Vector2f &delta_xy) override;
void _ekfResetHandlerVelocityXY(const matrix::Vector2f &delta_vxy) override;
void _ekfResetHandlerPositionZ(float delta_z) override;
void _ekfResetHandlerVelocityZ(float delta_vz) override;
void _ekfResetHandlerHeading(float delta_psi) override;
void _generateSetpoints(); /**< Generate setpoints along line. */
void _generateHeading();
void _checkEmergencyBraking();
bool _generateHeadingAlongTraj(); /**< Generates heading along trajectory. */
bool isTargetModified() const;
bool _is_emergency_braking_active{false};
void _prepareSetpoints(); /**< Generate velocity target points for the trajectory generator. */
void _updateTrajConstraints();
/** determines when to trigger a takeoff (ignored in flight) */
bool _checkTakeoff() override { return _want_takeoff; };
bool _want_takeoff{false};
void _prepareIdleSetpoints();
void _prepareLandSetpoints();
void _prepareVelocitySetpoints();
void _prepareTakeoffSetpoints();
void _preparePositionSetpoints();
bool _highEnoughForLandingGear(); /**< Checks if gears can be lowered. */
void updateParams() override; /**< See ModuleParam class */
Sticks _sticks;
StickAccelerationXY _stick_acceleration_xy;
StickYaw _stick_yaw;
matrix::Vector3f _land_position;
float _land_heading;
WaypointType _type_previous{WaypointType::idle}; /**< Previous type of current target triplet. */
DEFINE_PARAMETERS_CUSTOM_PARENT(FlightTaskAuto,
(ParamFloat<px4::params::MIS_YAW_ERR>) _param_mis_yaw_err, // yaw-error threshold
(ParamFloat<px4::params::MPC_ACC_HOR>) _param_mpc_acc_hor, // acceleration in flight
(ParamFloat<px4::params::MPC_ACC_UP_MAX>) _param_mpc_acc_up_max,
(ParamFloat<px4::params::MPC_ACC_DOWN_MAX>) _param_mpc_acc_down_max,
(ParamFloat<px4::params::MPC_JERK_AUTO>) _param_mpc_jerk_auto,
(ParamFloat<px4::params::MPC_XY_TRAJ_P>) _param_mpc_xy_traj_p,
(ParamFloat<px4::params::MPC_XY_ERR_MAX>) _param_mpc_xy_err_max,
(ParamFloat<px4::params::MPC_LAND_SPEED>) _param_mpc_land_speed,
(ParamInt<px4::params::MPC_LAND_RC_HELP>) _param_mpc_land_rc_help,
(ParamFloat<px4::params::MPC_LAND_ALT1>)
_param_mpc_land_alt1, // altitude at which speed limit downwards reaches maximum speed
(ParamFloat<px4::params::MPC_LAND_ALT2>)
_param_mpc_land_alt2, // altitude at which speed limit downwards reached minimum speed
(ParamFloat<px4::params::MPC_TKO_SPEED>) _param_mpc_tko_speed,
(ParamFloat<px4::params::MPC_TKO_RAMP_T>)
_param_mpc_tko_ramp_t, // time constant for smooth takeoff ramp
(ParamFloat<px4::params::MPC_MAN_Y_MAX>) _param_mpc_man_y_max
);
};
| 41.888
| 98
| 0.750955
|
CQBIT
|
ef16cf8fd5324c621648102564497d8f3c41a9ed
| 5,430
|
hpp
|
C++
|
packages/monte_carlo/collision/photon/src/MonteCarlo_LineEnergyAdjointPhotonScatteringDistribution.hpp
|
bam241/FRENSIE
|
e1760cd792928699c84f2bdce70ff54228e88094
|
[
"BSD-3-Clause"
] | 10
|
2019-11-14T19:58:30.000Z
|
2021-04-04T17:44:09.000Z
|
packages/monte_carlo/collision/photon/src/MonteCarlo_LineEnergyAdjointPhotonScatteringDistribution.hpp
|
bam241/FRENSIE
|
e1760cd792928699c84f2bdce70ff54228e88094
|
[
"BSD-3-Clause"
] | 43
|
2020-03-03T19:59:20.000Z
|
2021-09-08T03:36:08.000Z
|
packages/monte_carlo/collision/photon/src/MonteCarlo_LineEnergyAdjointPhotonScatteringDistribution.hpp
|
bam241/FRENSIE
|
e1760cd792928699c84f2bdce70ff54228e88094
|
[
"BSD-3-Clause"
] | 6
|
2020-02-12T17:37:07.000Z
|
2020-09-08T18:59:51.000Z
|
//---------------------------------------------------------------------------//
//!
//! \file MonteCarlo_LineEnergyAdjointPhotonScatteringDistribution.hpp
//! \author Alex Robinson
//! \brief The line energy adjoint photon scattering distribution
//!
//---------------------------------------------------------------------------//
#ifndef MONTE_CARLO_LINE_ENERGY_ADJOINT_PHOTON_SCATTERING_DISTRIBUTION_HPP
#define MONTE_CARLO_LINE_ENERGY_ADJOINT_PHOTON_SCATTERING_DISTRIBUTION_HPP
// Std Lib Includes
#include <memory>
// FRENSIE Includes
#include "MonteCarlo_AdjointPhotonScatteringDistribution.hpp"
#include "Utility_TabularUnivariateDistribution.hpp"
namespace MonteCarlo{
/*! The line energy adjoint photon scattering distribution class
* \details The line energy distribution is only defined at the line energy.
*/
class LineEnergyAdjointPhotonScatteringDistribution : public AdjointPhotonScatteringDistribution
{
public:
//! The trials counter type
typedef AdjointPhotonScatteringDistribution::Counter Counter;
//! Constructor
LineEnergyAdjointPhotonScatteringDistribution(
const double line_energy,
const double energy_dist_norm_constant,
const std::shared_ptr<const Utility::TabularUnivariateDistribution>&
energy_dist );
//! Destructor
~LineEnergyAdjointPhotonScatteringDistribution()
{ /* ... */ }
//! Set the critical line energies
void setCriticalLineEnergies(
const std::shared_ptr<const std::vector<double> >&
critical_line_energies );
//! Get the critical line energies
const std::vector<double>& getCriticalLineEnergies() const;
//! Get the max energy
double getMaxEnergy() const;
//! Return the line energy
double getLineEnergy() const;
//! Return the minimum outgoing energy
double getMinOutgoingEnergy() const;
//! Return the maximum outgoing energy
double getMaxOutgoingEnergy() const;
//! Evaluate the distribution (differential in scattering angle cosine)
double evaluate( const double incoming_energy,
const double scattering_angle_cosine ) const override;
//! Evaluate the distribution (double differential)
double evaluate( const double incoming_energy,
const double outgoing_energy,
const double scattering_angle_cosine ) const;
//! Evaluate the Marginal PDF (differential in scattering angle cosine)
double evaluatePDF( const double incoming_energy,
const double scattering_angle_cosine ) const override;
//! Evaluate the Marginal PDF (differential in outgoing energy)
double evaluateEnergyPDF( const double incoming_energy,
const double outgoing_energy ) const;
//! Evaluate the Joint PDF
double evaluateJointPDF( const double incoming_energy,
const double outgoing_energy,
const double scattering_angle_cosine ) const;
//! Evaluate the integrated cross section (b)
double evaluateIntegratedCrossSection( const double incoming_energy,
const double precision ) const override;
//! Sample an outgoing energy and direction from the distribution
void sample( const double incoming_energy,
double& outgoing_energy,
double& scattering_angle_cosine ) const override;
//! Sample an outgoing energy and direction from the distribution
void sample( double& outgoing_energy,
double& scattering_angle_cosine ) const;
//! Sample an outgoing energy and direction and record the number of trials
void sampleAndRecordTrials( const double incoming_energy,
double& outgoing_energy,
double& scattering_angle_cosine,
Counter& trials ) const override;
//! Sample an outgoing energy and direction and record the number of trials
void sampleAndRecordTrials( double& outgoing_energy,
double& scattering_angle_cosine,
Counter& trials ) const;
//! Randomly scatter the photon and return the shell that was interacted with
void scatterAdjointPhoton( AdjointPhotonState& adjoint_photon,
ParticleBank& bank,
Data::SubshellType& shell_of_interaction ) const override;
private:
// Sample the polar scattering angle cosine
double samplePolarScatteringAngleCosine() const;
// Create the probe particles
void createProbeParticles( const AdjointPhotonState& adjoint_photon,
ParticleBank& bank ) const;
// The line energy where the scattering distribution is defined
double d_line_energy;
// The energy distribution norm constant
double d_energy_dist_norm_constant;
// The energy distribution
std::shared_ptr<const Utility::TabularUnivariateDistribution> d_energy_dist;
// The critical line energies
std::shared_ptr<const std::vector<double> > d_critical_line_energies;
};
} // end MonteCarlo namespace
#endif // end MONTE_CARLO_ADJOINT_PHOTON_SCATTERING_DISTRIBUTION_HPP
//---------------------------------------------------------------------------//
// end MonteCarlo_LineEnergyAdjointPhotonScatteringDistribution.hpp
//---------------------------------------------------------------------------//
| 37.972028
| 96
| 0.666667
|
bam241
|
fa9c08682ab4562d2f3186a7d07ce0213167c122
| 1,019
|
cpp
|
C++
|
BrickEngine/src/BrickEngine/Renderer/IndexBuffer.cpp
|
HomelikeBrick42/BrickEngine-4.0
|
d0697ea42f604c7d9b685ef0baae96f286121431
|
[
"Apache-2.0"
] | null | null | null |
BrickEngine/src/BrickEngine/Renderer/IndexBuffer.cpp
|
HomelikeBrick42/BrickEngine-4.0
|
d0697ea42f604c7d9b685ef0baae96f286121431
|
[
"Apache-2.0"
] | null | null | null |
BrickEngine/src/BrickEngine/Renderer/IndexBuffer.cpp
|
HomelikeBrick42/BrickEngine-4.0
|
d0697ea42f604c7d9b685ef0baae96f286121431
|
[
"Apache-2.0"
] | null | null | null |
#include "pch.h"
#include "IndexBuffer.h"
#include "BrickEngine/Renderer/Renderer.h"
#include "BrickEngine/Renderer/OpenGL/OpenGLIndexBuffer.h"
namespace BrickEngine {
Ref<IndexBuffer> IndexBuffer::Create(uint32_t* data, uint32_t count)
{
switch (Renderer::GetAPI())
{
case RendererAPI::Unknown:
BRICKENGINE_CORE_ASSERT(false, "Renderer doesn't not support no API!");
return nullptr;
case BrickEngine::RendererAPI::OpenGL:
return CreateRef<OpenGLIndexBuffer>(data, count);
}
BRICKENGINE_CORE_ASSERT(false, "Renderer doesn't not support no API!");
return nullptr;
}
Ref<IndexBuffer> IndexBuffer::Create(uint32_t count)
{
switch (Renderer::GetAPI())
{
case RendererAPI::Unknown:
BRICKENGINE_CORE_ASSERT(false, "Renderer doesn't not support no API!");
return nullptr;
case BrickEngine::RendererAPI::OpenGL:
return CreateRef<OpenGLIndexBuffer>(count);
}
BRICKENGINE_CORE_ASSERT(false, "Renderer doesn't not support no API!");
return nullptr;
}
}
| 25.475
| 74
| 0.727184
|
HomelikeBrick42
|
fa9e47e09c98884d7591635221c32e60480fc583
| 1,475
|
cc
|
C++
|
src/ipm/ipx/src/lu_update.cc
|
chrhansk/HiGHS
|
311aa8571925ed23c952687569dbe7207e542e0a
|
[
"MIT"
] | 241
|
2018-03-27T15:04:14.000Z
|
2022-03-31T14:44:18.000Z
|
src/ipm/ipx/src/lu_update.cc
|
chrhansk/HiGHS
|
311aa8571925ed23c952687569dbe7207e542e0a
|
[
"MIT"
] | 384
|
2018-03-28T10:34:36.000Z
|
2022-03-31T20:19:37.000Z
|
src/ipm/ipx/src/lu_update.cc
|
chrhansk/HiGHS
|
311aa8571925ed23c952687569dbe7207e542e0a
|
[
"MIT"
] | 54
|
2018-04-28T22:43:19.000Z
|
2022-03-31T14:44:22.000Z
|
#include "lu_update.h"
namespace ipx {
Int LuUpdate::Factorize(const Int* Bbegin, const Int* Bend, const Int* Bi,
const double* Bx, bool strict_abs_pivottol) {
updates_ = 0;
return _Factorize(Bbegin, Bend, Bi, Bx, strict_abs_pivottol);
}
void LuUpdate::GetFactors(SparseMatrix* L, SparseMatrix* U, Int* rowperm,
Int* colperm, std::vector<Int>* dependent_cols) {
_GetFactors(L, U, rowperm, colperm, dependent_cols);
}
void LuUpdate::SolveDense(const Vector& rhs, Vector& lhs, char trans) {
_SolveDense(rhs, lhs, trans);
}
void LuUpdate::FtranForUpdate(Int nz, const Int* bi, const double* bx) {
_FtranForUpdate(nz, bi, bx);
}
void LuUpdate::FtranForUpdate(Int nz, const Int* bi, const double* bx,
IndexedVector& lhs) {
_FtranForUpdate(nz, bi, bx, lhs);
}
void LuUpdate::BtranForUpdate(Int p) {
_BtranForUpdate(p);
}
void LuUpdate::BtranForUpdate(Int p, IndexedVector& lhs) {
_BtranForUpdate(p, lhs);
}
Int LuUpdate::Update(double pivot) {
updates_++;
return _Update(pivot);
}
bool LuUpdate::NeedFreshFactorization() {
return _NeedFreshFactorization();
}
double LuUpdate::fill_factor() const {
return _fill_factor();
}
double LuUpdate::pivottol() const {
return _pivottol();
}
void LuUpdate::pivottol(double new_pivottol) {
_pivottol(new_pivottol);
}
Int LuUpdate::updates() const {
return updates_;
}
} // namespace ipx
| 23.412698
| 75
| 0.667797
|
chrhansk
|
faa5d9282dc24eadd8aae59ebd3c2e9246bd15c0
| 4,151
|
cpp
|
C++
|
data_structures/hash_table/separate_chaining/separate_chaining_hash.cpp
|
kruztev/FMI-DSA
|
f509dba6cd95792ec9c4c9ad55620a3dc06c6602
|
[
"MIT"
] | 24
|
2017-12-21T13:57:34.000Z
|
2021-12-08T01:12:32.000Z
|
data_structures/hash_table/separate_chaining/separate_chaining_hash.cpp
|
kruztev/FMI-DSA
|
f509dba6cd95792ec9c4c9ad55620a3dc06c6602
|
[
"MIT"
] | 28
|
2018-11-01T23:34:08.000Z
|
2019-10-07T17:42:54.000Z
|
data_structures/hash_table/separate_chaining/separate_chaining_hash.cpp
|
kruztev/FMI-DSA
|
f509dba6cd95792ec9c4c9ad55620a3dc06c6602
|
[
"MIT"
] | 4
|
2018-04-24T19:28:51.000Z
|
2020-07-19T14:06:23.000Z
|
/*******************************************************************************
* This file is part of the "Data structures and algorithms" course. FMI 2018/19
*******************************************************************************/
/**
* @file separate_chaining_hash.cpp
* @author Ivan Filipov
* @date 01.2019
* @brief Basic implementation of hash table, using
* opened hashing (closed address) strategy -
* separate chaining.
* Depends only on our custom dynamic array and doubly linked list.
* @see https://en.wikipedia.org/wiki/Hash_table
*/
#include "separate_chaining_hash.h"
// include only if debugging is ON
#if DEBUG_HASH == 1
#include <iostream> //std::cin, std::cout
#endif // DEBUG_HASH
// the hash function, it is the most critical zone,
// the implementation below is pretty simple, consider
// using better hash functions in your applications
size_t sp_ch_hash_table::hash_func(const key_type& key, const size_t size) {
// get the size of the string
size_t result = key.size();
// add the ASCII code for each character
for (unsigned char c : key)
result += c;
// return result % size;
// but better in case the SIZE is a power of 2
return result & (size - 1);
}
void sp_ch_hash_table::rehash() {
// debug print
#if DEBUG_HASH == 1
std::cout << "\n...rehashing ...\n";
#endif // DEBUG_HASH
// create new table
sp_ch_hash_table new_table(table.size() * 2);
// for each chain ...
for (dsa::dlinked_list<table_elem>& list: table)
if (!list.empty())
for(table_elem& el: list) // for each of its elements
new_table.insert(el.key, el.data); // put it in the new table
// which will lead to re-calculating the hash values
new_table.table.swap_with(table);
#if DEBUG_HASH == 1
std::cout << ".............\n";
#endif // DEBUG_HASH
}
sp_ch_hash_table::chain_iter sp_ch_hash_table::find(size_t index, const key_type& key) {
chain_iter it = table[index].begin();
while (it != table[index].end() && it->key != key)
++it;
return it;
}
void sp_ch_hash_table::insert(const key_type& key, const data_type& data) {
// calculate where to add the new element using the hash function
size_t index = hash_func(key, table.size());
// check if this key is taken
chain_iter it = find(index, key);
if (it != table[index].end())
throw std::logic_error("this key is already taken!\n");
// check if resizing is needed
if (table[index].size() >= MAX_CHAIN_SIZE) {
rehash();
// calculate the hash again, because the table now have different size
index = hash_func(key, table.size());
}
// add the new elem as a first in the list for O(1)
table[index].push_front({ key, data });
#if DEBUG_HASH == 1
std::cout << "stored at hash " << index << std::endl;
#endif
}
data_type sp_ch_hash_table::get(const key_type& key) {
// calculate where to add the new element using the hash function
size_t index = hash_func(key, table.size());
// iterate through the elements of the list
// searching for exactly the same key
chain_iter it = find(index, key);
// there is not such element
if (it == table[index].end())
throw std::logic_error("there isn't element with such key\n");
return it->data;
}
void sp_ch_hash_table::erase(const key_type& key) {
// calculate where to add the new element using the hash function
size_t index = hash_func(key, table.size());
// find it and get a iterator to it
chain_iter it = find(index, key);
// can't find it
if (it == table[index].end())
throw std::logic_error("there isn't element with such key\n");
// remove it for O(1)
table[index].remove(it);
}
void sp_ch_hash_table::print() {
#if DEBUG_HASH == 1
for (size_t i = 0; i < table.size(); i++) {
std::cout << "hash = " << i << " :";
if (table[i].empty()) {
std::cout << "{}" << std::endl;
continue;
}
std::cout << "{ ";
size_t j = 0;
for (chain_iter it = table[i].begin(); it != table[i].end(); ++it) {
std::cout << "{ key: " << it->key << ", "
<< " data: " << it->data << " }";
if (j != table[i].size() -1) std::cout << ", ";
j++;
}
std::cout << " }" << std::endl;
}
#endif // DEBUG_HASH
}
| 31.210526
| 88
| 0.626596
|
kruztev
|
faa9b5e2ca6265b83fed3b5e28a84cbeab16945d
| 1,482
|
cpp
|
C++
|
android-31/android/service/quickaccesswallet/GetWalletCardsError.cpp
|
YJBeetle/QtAndroidAPI
|
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
|
[
"Apache-2.0"
] | 12
|
2020-03-26T02:38:56.000Z
|
2022-03-14T08:17:26.000Z
|
android-31/android/service/quickaccesswallet/GetWalletCardsError.cpp
|
YJBeetle/QtAndroidAPI
|
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
|
[
"Apache-2.0"
] | 1
|
2021-01-27T06:07:45.000Z
|
2021-11-13T19:19:43.000Z
|
android-31/android/service/quickaccesswallet/GetWalletCardsError.cpp
|
YJBeetle/QtAndroidAPI
|
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
|
[
"Apache-2.0"
] | 3
|
2021-02-02T12:34:55.000Z
|
2022-03-08T07:45:57.000Z
|
#include "../../graphics/drawable/Icon.hpp"
#include "../../os/Parcel.hpp"
#include "../../../JString.hpp"
#include "./GetWalletCardsError.hpp"
namespace android::service::quickaccesswallet
{
// Fields
JObject GetWalletCardsError::CREATOR()
{
return getStaticObjectField(
"android.service.quickaccesswallet.GetWalletCardsError",
"CREATOR",
"Landroid/os/Parcelable$Creator;"
);
}
// QJniObject forward
GetWalletCardsError::GetWalletCardsError(QJniObject obj) : JObject(obj) {}
// Constructors
GetWalletCardsError::GetWalletCardsError(android::graphics::drawable::Icon arg0, JString arg1)
: JObject(
"android.service.quickaccesswallet.GetWalletCardsError",
"(Landroid/graphics/drawable/Icon;Ljava/lang/CharSequence;)V",
arg0.object(),
arg1.object<jstring>()
) {}
// Methods
jint GetWalletCardsError::describeContents() const
{
return callMethod<jint>(
"describeContents",
"()I"
);
}
android::graphics::drawable::Icon GetWalletCardsError::getIcon() const
{
return callObjectMethod(
"getIcon",
"()Landroid/graphics/drawable/Icon;"
);
}
JString GetWalletCardsError::getMessage() const
{
return callObjectMethod(
"getMessage",
"()Ljava/lang/CharSequence;"
);
}
void GetWalletCardsError::writeToParcel(android::os::Parcel arg0, jint arg1) const
{
callMethod<void>(
"writeToParcel",
"(Landroid/os/Parcel;I)V",
arg0.object(),
arg1
);
}
} // namespace android::service::quickaccesswallet
| 23.52381
| 95
| 0.709177
|
YJBeetle
|
faaa9caa847f6b6550e85973e7bd6200b3e87ccc
| 314
|
cpp
|
C++
|
UVA10812.cpp
|
MaSteve/UVA-problems
|
3a240fcca02e24a9c850b7e86062f8581df6f95f
|
[
"MIT"
] | 17
|
2015-12-08T18:50:03.000Z
|
2022-03-16T01:23:20.000Z
|
UVA10812.cpp
|
MaSteve/UVA-problems
|
3a240fcca02e24a9c850b7e86062f8581df6f95f
|
[
"MIT"
] | null | null | null |
UVA10812.cpp
|
MaSteve/UVA-problems
|
3a240fcca02e24a9c850b7e86062f8581df6f95f
|
[
"MIT"
] | 6
|
2017-04-04T18:16:23.000Z
|
2020-06-28T11:07:22.000Z
|
#include <cstdio>
using namespace std;
int main() {
int cases;
scanf("%d", &cases);
for (int i = 0; i < cases; i++) {
long long s, d, r1, r2;
scanf("%lld %lld", &s, &d);
r1 = (s+d)/2;
r2 = s-r1;
if (r2 >=0 && r1 - r2 == d) printf("%lld %lld\n", r1, r2);
else printf("impossible\n");
}
return 0;
}
| 19.625
| 60
| 0.519108
|
MaSteve
|
faac660f7683212f00cc87e2dbbc0471617883b0
| 5,107
|
cpp
|
C++
|
Filter/sort_fastq_mem_eff.cpp
|
jwnam/etching
|
7f6750de03bbd44e86451ee9ab4edaa9ed77d3a3
|
[
"MIT"
] | 6
|
2020-08-27T00:14:44.000Z
|
2022-01-20T11:11:12.000Z
|
Filter/sort_fastq_mem_eff.cpp
|
jwnam/etching
|
7f6750de03bbd44e86451ee9ab4edaa9ed77d3a3
|
[
"MIT"
] | 1
|
2021-02-02T07:02:33.000Z
|
2021-02-03T08:30:24.000Z
|
Filter/sort_fastq_mem_eff.cpp
|
jwnam/etching
|
7f6750de03bbd44e86451ee9ab4edaa9ed77d3a3
|
[
"MIT"
] | 1
|
2020-08-27T00:14:32.000Z
|
2020-08-27T00:14:32.000Z
|
#include <string>
#include <vector>
#include <map>
#include <fstream>
#include <iostream>
#include <functional>
uint32_t adler32(std::string & input)
{
//uint32_t MOD_ADLER = 65521;
uint32_t a = 1;
uint32_t b = 0;
std::size_t Size = input.size();
for (std::size_t i = 0; i < Size ; i++ ){
a = (a + input[i]) % 65521;
b = (b + a) % 65521;
}
return (b << 16) | a;
}
int64_t file_size(std::string infile){
std::ifstream fin;
fin.open(infile.c_str(), std::ios_base::binary);
fin.seekg(0,std::ios_base::end);
int64_t size = fin.tellg();
fin.close();
return size;
}
void sort_and_write_fastq ( std::string infile , std::string outfile ){
std::ifstream fin ( infile.c_str() );
std::ofstream fout ( outfile.c_str() );
std::string id;
std::string seq;
std::string desc;
std::string qual;
std::map < std::string , std::pair < std::string , std::string > > fastq_map;
while ( std::getline ( fin , id ) && std::getline ( fin , seq ) &&
std::getline ( fin , desc ) && std::getline ( fin , qual ) ){
if ( id.substr(id.size()-2) == "/1" || id.substr(id.size()-2) == "/2"){
id = id.substr(0,id.size()-2);
}
fastq_map[id].first = seq;
fastq_map[id].second = qual;
}
for ( auto & i : fastq_map ){
id = i.first;
seq = i.second.first;
qual = i.second.second;
fout << id << "\n" << seq << "\n+\n" << qual << "\n";
}
fin.close();
fout.close();
}
void split_file ( std::string infile , std::vector < std::string > fname_vec, int64_t fsize ){
// std::hash<std::string> hashing;
std::ifstream fin;
std::string id;
std::string seq;
std::string desc;
std::string qual;
// open file streams
fin.open(infile.c_str());
//std::vector < std::ofstream > fout;
std::ofstream * fout = new std::ofstream [fsize];
//fout.resize(fsize);
for ( uint i = 0 ; i < fsize ; i ++ ){
fout[i].open(fname_vec[i].c_str());
}
while ( std::getline ( fin , id ) && std::getline ( fin , seq ) &&
std::getline ( fin , desc ) && std::getline ( fin , qual ) ){
if ( id.substr(id.size()-2) == "/1" || id.substr(id.size()-2) == "/2"){
id = id.substr(0,id.size()-2);
}
// std::size_t hval = hashing ( id );
std::size_t hval = adler32 ( id );
std::size_t fnumber = hval % fsize;
fout[fnumber] << id << "\n" << seq << "\n+\n" << qual << "\n";
}
// close file streams
fin.close();
for ( uint i = 0 ; i < fsize ; i ++ ){
fout[i].close();
}
delete [] fout;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Main
//
int main ( int argc , char ** argv ){
if ( argc == 1 ){
std::cout << "sort_fastq input.fastq output.fastq chunk_file_size(GB)\n";
return 0;
}
std::string infile(argv[1]);
std::string outfile(argv[2]);
int64_t FSIZE = atoi(argv[3]);
int64_t GB = 1024*1024*1024 ;
int64_t fsize = file_size(infile) / ( FSIZE * GB ) + 1;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// If file size is < 1 GB, just sort using binary tree (std::map).
//
//std::cout << "File size: " << file_size(infile) << " Byte\n";
if ( fsize == 1 ){
sort_and_write_fastq(infile, outfile);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// If file size is greater 1 GB, split files
//
// < 2 GB --> 2 files
// < 3 GB --> 3 files
// .
// < n GB --> n files
else{
// std::cout << "Split sort\n";
std::vector < std::string > fname_vec;
std::vector < std::string > sname_vec;
// initializing variables
for ( uint i = 0 ; i < fsize ; i ++ ){
std::string fname = outfile + "_" + std::to_string(i);
std::string sname = fname + "_sort";
sname_vec.push_back(sname);
fname_vec.push_back(fname);
}
// split file
split_file ( infile, fname_vec, fsize );
// sort by id
for ( uint i = 0 ; i < fsize ; i ++ ){
std::string fname = fname_vec[i];
std::string sname = sname_vec[i];
sort_and_write_fastq(fname, sname);
}
// remove split files
for ( uint i = 0 ; i < fsize ; i ++ ){
remove(fname_vec[i].c_str());
}
// merge and print
std::ofstream fout ( outfile.c_str() );
for ( uint i = 0 ; i < fsize ; i ++ ){
std::string sname = sname_vec[i];
std::string id;
std::string seq;
std::string desc;
std::string qual;
std::ifstream fin ( sname.c_str() );
while ( std::getline ( fin , id ) && std::getline ( fin , seq ) &&
std::getline ( fin , desc ) && std::getline ( fin , qual ) ){
if ( id.substr(id.size()-2) == "/1" || id.substr(id.size()-2) == "/2"){
id = id.substr(0,id.size()-2);
}
fout << id << "\n" << seq << "\n+\n" << qual << "\n";
}
fin.close();
}
// remove sorted split files
for ( uint i = 0 ; i < fsize ; i ++ ){
remove(sname_vec[i].c_str());
}
fout.close();
}
return 0;
}
| 24.791262
| 120
| 0.504797
|
jwnam
|
faad80a483b98bbb86df5b4a0f58dbfdedf34472
| 7,893
|
cpp
|
C++
|
AdvancedSessions/Source/AdvancedSessions/Private/AdvancedIdentityLibrary.cpp
|
Ji-Rath/AdvancedSessionsPlugin
|
94fb993ad70a7a497b827180a66a66d18e769db6
|
[
"MIT"
] | 211
|
2020-06-08T19:38:26.000Z
|
2022-03-25T13:51:05.000Z
|
AdvancedSessions/Source/AdvancedSessions/Private/AdvancedIdentityLibrary.cpp
|
Ji-Rath/AdvancedSessionsPlugin
|
94fb993ad70a7a497b827180a66a66d18e769db6
|
[
"MIT"
] | 24
|
2020-06-30T00:05:31.000Z
|
2022-03-26T08:28:05.000Z
|
AdvancedSessions/Source/AdvancedSessions/Private/AdvancedIdentityLibrary.cpp
|
Ji-Rath/AdvancedSessionsPlugin
|
94fb993ad70a7a497b827180a66a66d18e769db6
|
[
"MIT"
] | 56
|
2020-06-08T06:56:12.000Z
|
2022-03-25T13:51:10.000Z
|
// Fill out your copyright notice in the Description page of Project Settings.
#include "AdvancedIdentityLibrary.h"
//General Log
DEFINE_LOG_CATEGORY(AdvancedIdentityLog);
void UAdvancedIdentityLibrary::GetPlayerAuthToken(APlayerController * PlayerController, FString & AuthToken, EBlueprintResultSwitch &Result)
{
if (!PlayerController)
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerAuthToken was passed a bad player controller!"));
Result = EBlueprintResultSwitch::OnFailure;
return;
}
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
if (!Player)
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerAuthToken failed to get LocalPlayer!"));
Result = EBlueprintResultSwitch::OnFailure;
return;
}
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface();
if (!IdentityInterface.IsValid())
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerAuthToken Failed to get identity interface!"));
Result = EBlueprintResultSwitch::OnFailure;
return;
}
AuthToken = IdentityInterface->GetAuthToken(Player->GetControllerId());
Result = EBlueprintResultSwitch::OnSuccess;
}
void UAdvancedIdentityLibrary::GetPlayerNickname(const FBPUniqueNetId & UniqueNetID, FString & PlayerNickname)
{
if (!UniqueNetID.IsValid())
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerNickname was passed a bad player uniquenetid!"));
return;
}
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface();
if (!IdentityInterface.IsValid())
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerNickname Failed to get identity interface!"));
return;
}
PlayerNickname = IdentityInterface->GetPlayerNickname(*UniqueNetID.GetUniqueNetId());
}
void UAdvancedIdentityLibrary::GetLoginStatus(const FBPUniqueNetId & UniqueNetID, EBPLoginStatus & LoginStatus, EBlueprintResultSwitch &Result)
{
if (!UniqueNetID.IsValid())
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetLoginStatus was passed a bad player uniquenetid!"));
Result = EBlueprintResultSwitch::OnFailure;
return;
}
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface();
if (!IdentityInterface.IsValid())
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetLoginStatus Failed to get identity interface!"));
Result = EBlueprintResultSwitch::OnFailure;
return;
}
LoginStatus = (EBPLoginStatus)IdentityInterface->GetLoginStatus(*UniqueNetID.GetUniqueNetId());
Result = EBlueprintResultSwitch::OnSuccess;
}
void UAdvancedIdentityLibrary::GetAllUserAccounts(TArray<FBPUserOnlineAccount> & AccountInfos, EBlueprintResultSwitch &Result)
{
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface();
if (!IdentityInterface.IsValid())
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetAllUserAccounts Failed to get identity interface!"));
Result = EBlueprintResultSwitch::OnFailure;
return;
}
TArray<TSharedPtr<FUserOnlineAccount>> accountInfos = IdentityInterface->GetAllUserAccounts();
for (int i = 0; i < accountInfos.Num(); ++i)
{
AccountInfos.Add(FBPUserOnlineAccount(accountInfos[i]));
}
Result = EBlueprintResultSwitch::OnSuccess;
}
void UAdvancedIdentityLibrary::GetUserAccount(const FBPUniqueNetId & UniqueNetId, FBPUserOnlineAccount & AccountInfo, EBlueprintResultSwitch &Result)
{
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface();
if(!UniqueNetId.IsValid())
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccount was passed a bad unique net id!"));
Result = EBlueprintResultSwitch::OnFailure;
return;
}
if (!IdentityInterface.IsValid())
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccount Failed to get identity interface!"));
Result = EBlueprintResultSwitch::OnFailure;
return;
}
TSharedPtr<FUserOnlineAccount> accountInfo = IdentityInterface->GetUserAccount(*UniqueNetId.GetUniqueNetId());
if (!accountInfo.IsValid())
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccount Failed to get the account!"));
Result = EBlueprintResultSwitch::OnFailure;
return;
}
AccountInfo.UserAccountInfo = accountInfo;
Result = EBlueprintResultSwitch::OnSuccess;
}
void UAdvancedIdentityLibrary::GetUserAccountAccessToken(const FBPUserOnlineAccount & AccountInfo, FString & AccessToken)
{
if (!AccountInfo.UserAccountInfo.IsValid())
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAccessToken was passed an invalid account!"));
return;
}
AccessToken = AccountInfo.UserAccountInfo->GetAccessToken();
}
void UAdvancedIdentityLibrary::GetUserAccountAuthAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, FString & AuthAttribute, EBlueprintResultSwitch &Result)
{
if (!AccountInfo.UserAccountInfo.IsValid())
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAuthAttribute was passed an invalid account!"));
Result = EBlueprintResultSwitch::OnFailure;
return;
}
if (!AccountInfo.UserAccountInfo->GetAuthAttribute(AttributeName, AuthAttribute))
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAuthAttribute couldn't find the attribute!"));
Result = EBlueprintResultSwitch::OnFailure;
return;
}
Result = EBlueprintResultSwitch::OnSuccess;
}
void UAdvancedIdentityLibrary::SetUserAccountAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, const FString & NewAttributeValue, EBlueprintResultSwitch &Result)
{
if (!AccountInfo.UserAccountInfo.IsValid())
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("SetUserAccountAuthAttribute was passed an invalid account!"));
Result = EBlueprintResultSwitch::OnFailure;
return;
}
if (!AccountInfo.UserAccountInfo->SetUserAttribute(AttributeName, NewAttributeValue))
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("SetUserAccountAuthAttribute was unable to set the attribute!"));
Result = EBlueprintResultSwitch::OnFailure;
return;
}
Result = EBlueprintResultSwitch::OnSuccess;
}
void UAdvancedIdentityLibrary::GetUserID(const FBPUserOnlineAccount & AccountInfo, FBPUniqueNetId & UniqueNetID)
{
if (!AccountInfo.UserAccountInfo.IsValid())
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserID was passed an invalid account!"));
return;
}
UniqueNetID.SetUniqueNetId(AccountInfo.UserAccountInfo->GetUserId());
}
void UAdvancedIdentityLibrary::GetUserAccountRealName(const FBPUserOnlineAccount & AccountInfo, FString & UserName)
{
if (!AccountInfo.UserAccountInfo.IsValid())
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountRealName was passed an invalid account!"));
return;
}
UserName = AccountInfo.UserAccountInfo->GetRealName();
}
void UAdvancedIdentityLibrary::GetUserAccountDisplayName(const FBPUserOnlineAccount & AccountInfo, FString & DisplayName)
{
if (!AccountInfo.UserAccountInfo.IsValid())
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountDisplayName was passed an invalid account!"));
return;
}
DisplayName = AccountInfo.UserAccountInfo->GetDisplayName();
}
void UAdvancedIdentityLibrary::GetUserAccountAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, FString & AttributeValue, EBlueprintResultSwitch &Result)
{
if (!AccountInfo.UserAccountInfo.IsValid())
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAttribute was passed an invalid account!"));
Result = EBlueprintResultSwitch::OnFailure;
return;
}
if (!AccountInfo.UserAccountInfo->GetUserAttribute(AttributeName, AttributeValue))
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAttribute failed to get user attribute!"));
Result = EBlueprintResultSwitch::OnFailure;
return;
}
Result = EBlueprintResultSwitch::OnSuccess;
}
| 33.587234
| 195
| 0.766502
|
Ji-Rath
|
faaf0579add76f1ace7e96e0b4cd192a432f5fb5
| 89
|
cpp
|
C++
|
GameEngineContents/Chapter7Map.cpp
|
AnWooJin/Portfolio
|
612c1b9d29f552d1bba586f461babf7dff3a1e4e
|
[
"MIT"
] | null | null | null |
GameEngineContents/Chapter7Map.cpp
|
AnWooJin/Portfolio
|
612c1b9d29f552d1bba586f461babf7dff3a1e4e
|
[
"MIT"
] | null | null | null |
GameEngineContents/Chapter7Map.cpp
|
AnWooJin/Portfolio
|
612c1b9d29f552d1bba586f461babf7dff3a1e4e
|
[
"MIT"
] | null | null | null |
#include "Chapter7Map.h"
Chapter7Map::Chapter7Map()
{
}
Chapter7Map::~Chapter7Map()
{
}
| 9.888889
| 27
| 0.707865
|
AnWooJin
|
faaf227493eed0fea7e5ac75d4fa467e487c95b5
| 1,484
|
cpp
|
C++
|
Segment Tree/Sum (mem optim (Euler tour)).cpp
|
yokeshrana/Fast_Algorithms_in_Data_Structures
|
2346fee16c6c3ffceac7cb79b1f449b4d8dc9df2
|
[
"MIT"
] | 4
|
2021-01-15T16:30:48.000Z
|
2021-08-12T03:17:00.000Z
|
Segment Tree/Sum (mem optim (Euler tour)).cpp
|
andy489/Fast_Algorithms_in_Data_Structures
|
0f28a75030df3367902f0aa859a34096ea2b2582
|
[
"MIT"
] | null | null | null |
Segment Tree/Sum (mem optim (Euler tour)).cpp
|
andy489/Fast_Algorithms_in_Data_Structures
|
0f28a75030df3367902f0aa859a34096ea2b2582
|
[
"MIT"
] | 2
|
2021-02-24T14:50:08.000Z
|
2021-02-28T17:39:41.000Z
|
// github.com/andy489
#include <stdio.h>
#include <algorithm>
int a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
const int n = sizeof a / sizeof(int);
int t[2 * n];
using namespace std;
void build(int v, int tl, int tr) {
if (tl == tr)
t[v] = a[tl];
else {
int tm = tl + tr >> 1;
build(v + 1, tl, tm);
build(v + 2 * (tm - tl + 1) - 1 + 1, tm + 1, tr);
t[v] = t[v + 1] + t[v + 2 * (tm - tl + 1)];
}
}
int sum(int v, int tl, int tr, int l, int r) {
if (l > r)
return 0;
if (l == tl && r == tr)
return t[v];
int tm = tl + tr >> 1;
return sum(v + 1, tl, tm, l, min(r, tm)) +
sum(v + 2 * (tm - tl + 1), tm + 1, tr, max(l, tm + 1), r);
}
void update(int v, int tl, int tr, int pos, int newVal) {
if (tl == tr)
t[v] = newVal;
else {
int tm = tl + tr >> 1;
if (pos <= tm)
update(v + 1, tl, tm, pos, newVal);
else
update(v + 2 * (tm - tl + 1), tm + 1, tr, pos, newVal);
t[v] = t[v + 1] + t[v + 2 * (tm - tl + 1)];
}
}
int main() {
build(1, 0, n - 1);
int q, cmd, l, r;
scanf("%d", &q);
while (q--) {
scanf("%d", &cmd);
if (cmd == 1) {
scanf("%d%d", &l, &r);
--l, --r;
printf("%d\n", sum(1, 0, n - 1, l, r));
} else {
scanf("%d%d", &l, &r); // l = pos, r = x
update(1, 0, n - 1, l - 1, r);
}
}
return 0;
}
| 23.1875
| 69
| 0.382749
|
yokeshrana
|
fab15ac345de4294ff1ce1546e755c5446dc4a24
| 1,283
|
hpp
|
C++
|
include/RAJA/policy/loop/WorkGroup/Vtable.hpp
|
ggeorgakoudis/RAJA
|
05f4a5e473a4160ddfdb5e829b4fdc9e0384ae26
|
[
"BSD-3-Clause"
] | 1
|
2020-11-19T04:55:20.000Z
|
2020-11-19T04:55:20.000Z
|
include/RAJA/policy/loop/WorkGroup/Vtable.hpp
|
ggeorgakoudis/RAJA
|
05f4a5e473a4160ddfdb5e829b4fdc9e0384ae26
|
[
"BSD-3-Clause"
] | null | null | null |
include/RAJA/policy/loop/WorkGroup/Vtable.hpp
|
ggeorgakoudis/RAJA
|
05f4a5e473a4160ddfdb5e829b4fdc9e0384ae26
|
[
"BSD-3-Clause"
] | null | null | null |
/*!
******************************************************************************
*
* \file
*
* \brief Header file containing RAJA workgroup Vtable.
*
******************************************************************************
*/
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Copyright (c) 2016-20, Lawrence Livermore National Security, LLC
// and RAJA project contributors. See the RAJA/COPYRIGHT file for details.
//
// SPDX-License-Identifier: (BSD-3-Clause)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
#ifndef RAJA_loop_WorkGroup_Vtable_HPP
#define RAJA_loop_WorkGroup_Vtable_HPP
#include "RAJA/config.hpp"
#include "RAJA/policy/loop/policy.hpp"
#include "RAJA/pattern/WorkGroup/Vtable.hpp"
namespace RAJA
{
namespace detail
{
/*!
* Populate and return a Vtable object
*/
template < typename T, typename Vtable_T >
inline const Vtable_T* get_Vtable(loop_work const&)
{
static Vtable_T vtable{
&Vtable_T::template move_construct_destroy<T>,
&Vtable_T::template host_call<T>,
&Vtable_T::template destroy<T>,
sizeof(T)
};
return &vtable;
}
} // namespace detail
} // namespace RAJA
#endif // closing endif for header file include guard
| 23.759259
| 79
| 0.530008
|
ggeorgakoudis
|
fabaa8405311da34ea23ced24a9ce91c1c6b751e
| 12,243
|
cpp
|
C++
|
CoreLib/CDate.cpp
|
NuLL3rr0r/blog-subscription-service
|
4458c0679229ad20ee446e1d1f7c58d1aa04b64d
|
[
"MIT"
] | 6
|
2016-01-30T03:25:00.000Z
|
2022-01-23T23:29:22.000Z
|
CoreLib/CDate.cpp
|
NuLL3rr0r/blog-subscription-service
|
4458c0679229ad20ee446e1d1f7c58d1aa04b64d
|
[
"MIT"
] | 1
|
2018-09-01T09:46:34.000Z
|
2019-01-12T15:05:50.000Z
|
CoreLib/CDate.cpp
|
NuLL3rr0r/blog-subscription-service
|
4458c0679229ad20ee446e1d1f7c58d1aa04b64d
|
[
"MIT"
] | 6
|
2017-01-05T14:55:02.000Z
|
2021-03-30T14:05:10.000Z
|
/**
* @file
* @author Mamadou Babaei <info@babaei.net>
* @version 0.1.0
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2016 - 2021 Mamadou Babaei
*
* 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.
*
* @section DESCRIPTION
*
* A Gregorian to Jalali and vice-versa date converter with optional support
* for arabic and farsi glyphs.
* Note that it's only accurate over a 33 years time span which is fine by me
* for now.
*/
#include <sstream>
#include <ctime>
#include <boost/lexical_cast.hpp>
#include <boost/locale.hpp>
#include "CDate.hpp"
#include "make_unique.hpp"
using namespace std;
using namespace boost;
using namespace CoreLib::CDate;
struct Now::Impl
{
struct tm *TimeInfo;
CDate::Timezone Timezone;
time_t RawTime;
int DaylightSavingTime;
int DayOfMonth;
int DayOfWeek;
int DayOfYear;
int Hour;
int Minutes;
int Month;
int Seconds;
int Year;
};
Now::Now(const Timezone &tz)
: m_pimpl(make_unique<Now::Impl>())
{
m_pimpl->Timezone = tz;
time(&m_pimpl->RawTime);
if (tz == Timezone::UTC) {
m_pimpl->TimeInfo = gmtime(&m_pimpl->RawTime);
} else {
m_pimpl->TimeInfo = localtime(&m_pimpl->RawTime);
}
m_pimpl->Hour = m_pimpl->TimeInfo->tm_hour; // hour (0 - 23)
m_pimpl->Minutes = m_pimpl->TimeInfo->tm_min; // minutes (0 - 59)
/*
A leap second is a plus or minus one-second adjustment to the Coordinated Universal Time (UTC) time scale that keeps it close to mean solar time.
When a positive leap second is added at 23:59:60 UTC, it delays the start of the following UTC day (at 00:00:00 UTC) by one second, effectively slowing the UTC clock.
*/
m_pimpl->Seconds = m_pimpl->TimeInfo->tm_sec != 60 ? m_pimpl->TimeInfo->tm_sec : 59; // seconds (0 - 60, 60 = Leap second)
m_pimpl->DayOfWeek = m_pimpl->TimeInfo->tm_wday + 1; // day of the week (0 - 6, 0 = Sunday)
m_pimpl->DayOfMonth = m_pimpl->TimeInfo->tm_mday; // day of the month (1 - 31)
m_pimpl->DayOfYear = m_pimpl->TimeInfo->tm_yday + 1; // day of the year (0 - 365)
m_pimpl->Month = m_pimpl->TimeInfo->tm_mon + 1; // month (0 - 11, 0 = January)
m_pimpl->Year = m_pimpl->TimeInfo->tm_year + 1900; // year since 1900
m_pimpl->DaylightSavingTime = m_pimpl->TimeInfo->tm_isdst; // Daylight saving time enabled (> 0), disabled (= 0), or unknown (< 0)
}
Now::~Now() = default;
const struct tm *Now::TimeInfo() const
{
return m_pimpl->TimeInfo;
}
const CoreLib::CDate::Timezone &Now::TimezoneOffset() const
{
return m_pimpl->Timezone;
}
time_t Now::RawTime() const
{
return m_pimpl->RawTime;
}
int Now::DaylightSavingTime() const
{
return m_pimpl->DaylightSavingTime;
}
int Now::DayOfMonth() const
{
return m_pimpl->DayOfMonth;
}
int Now::DayOfWeek() const
{
return m_pimpl->DayOfWeek;
}
int Now::DayOfYear() const
{
return m_pimpl->DayOfYear;
}
int Now::Hour() const
{
return m_pimpl->Hour;
}
int Now::Minutes() const
{
return m_pimpl->Minutes;
}
int Now::Month() const
{
return m_pimpl->Month;
}
int Now::Seconds() const
{
return m_pimpl->Seconds;
}
int Now::Year() const
{
return m_pimpl->Year;
}
std::string DateConv::ToGregorian(const int jYear, const int jMonth, const int jDay)
{
boost::locale::generator generator;
std::locale locale_gregorian = generator("en_US.UTF-8");
std::locale locale_jalali = generator("en_US.UTF-8@calendar=persian");
boost::locale::date_time jalali(
boost::locale::period::year(jYear)
+ boost::locale::period::month(jMonth - 1)
+ boost::locale::period::day(jDay),
locale_jalali);
boost::locale::date_time gregorian(jalali.time(), locale_gregorian);
std::stringstream ss;
ss << std::setfill('0') << std::setw(4)
<< gregorian / boost::locale::period::year()
<< "/" << std::setfill('0') << std::setw(2)
<< (gregorian / boost::locale::period::month()) + 1
<< "/" << std::setfill('0') << std::setw(2)
<< gregorian / boost::locale::period::day();
return ss.str();
}
std::string DateConv::ToGregorian(const CDate::Timezone &tz)
{
Now n(tz);
std::stringstream ss;
ss << std::setfill('0') << std::setw(4)
<< n.Year()
<< "/" << std::setfill('0') << std::setw(2)
<< n.Month()
<< "/" << std::setfill('0') << std::setw(2)
<< n.DayOfMonth();
return ss.str();
}
std::string DateConv::ToGregorian(const CDate::Now &now)
{
std::stringstream ss;
ss << std::setfill('0') << std::setw(4)
<< now.Year()
<< "/" << std::setfill('0') << std::setw(2)
<< now.Month()
<< "/" << std::setfill('0') << std::setw(2)
<< now.DayOfMonth();
return ss.str();
}
std::string DateConv::ToJalali(int gYear, int gMonth, int gDay)
{
boost::locale::generator generator;
std::locale locale_gregorian = generator("en_US.UTF-8");
std::locale locale_jalali = generator("en_US.UTF-8@calendar=persian");
boost::locale::date_time gregorian(
boost::locale::period::year(gYear)
+ boost::locale::period::month(gMonth - 1)
+ boost::locale::period::day(gDay),
locale_gregorian);
boost::locale::date_time jalali(gregorian.time(), locale_jalali);
std::stringstream ss;
ss << std::setfill('0') << std::setw(4)
<< jalali / boost::locale::period::year()
<< "/" << std::setfill('0') << std::setw(2)
<< (jalali / boost::locale::period::month()) + 1
<< "/" << std::setfill('0') << std::setw(2)
<< jalali / boost::locale::period::day();
return ss.str();
}
std::string DateConv::ToJalali(const CDate::Timezone &tz)
{
Now n(tz);
return DateConv::ToJalali(n.DayOfMonth(), n.Month(), n.Year());
}
std::string DateConv::ToJalali(const CDate::Now &now)
{
return DateConv::ToJalali(now.DayOfMonth(), now.Month(), now.Year());
}
std::string DateConv::ToJalali(const std::time_t rawTime, const CDate::Timezone &tz)
{
struct tm *timeInfo;
if (tz == Timezone::UTC) {
timeInfo = gmtime(&rawTime);
} else {
timeInfo = localtime(&rawTime);
}
return DateConv::ToJalali(timeInfo->tm_year + 1900,
timeInfo->tm_mon + 1, timeInfo->tm_mday);
}
std::string DateConv::Time(const CDate::Now &now)
{
std::stringstream ss;
ss << std::setfill('0') << std::setw(2)
<< now.Hour()
<< "/" << std::setfill('0') << std::setw(2)
<< now.Minutes()
<< "/" << std::setfill('0') << std::setw(2)
<< now.Seconds();
return ss.str();
}
std::string DateConv::DateTimeString(const std::time_t rawTime, const CDate::Timezone &tz)
{
if (tz == CDate::Timezone::UTC) {
return asctime(gmtime(&rawTime));
} else {
return asctime(localtime(&rawTime));
}
}
std::string DateConv::DateTimeString(const CDate::Now &now)
{
return asctime(now.TimeInfo());
}
std::wstring DateConv::GetPersianDayOfWeek(const CDate::Now &now)
{
switch (now.DayOfWeek()) {
case 7:
return L"شنبه";
case 1:
return L"یکشنبه";
case 2:
return L"دوشنبه";
case 3:
return L"سه شنبه";
case 4:
return L"چهارشنبه";
case 5:
return L"پنج شنبه";
case 6:
return L"جمعه";
default:
break;
}
return L"";
}
std::wstring DateConv::FormatToPersianNums(const std::string &date)
{
wstring res;
for (size_t i = 0; i < date.length(); ++i) {
switch(date[i]) {
case 0x30:
res += 0x06F0; // ۰
break;
case 0x31:
res += 0x06F1; // ۱
break;
case 0x32:
res += 0x06F2; // ۲
break;
case 0x33:
res += 0x06F3; // ۳
break;
case 0x34:
res += 0x06F4; // ۴
break;
case 0x35:
res += 0x06F5; // ۵
break;
case 0x36:
res += 0x06F6; // ۶
break;
case 0x37:
res += 0x06F7; // ۷
break;
case 0x38:
res += 0x06F8; // ۸
break;
case 0x39:
res += 0x06F9; // ۹
break;
default:
res += date[i];
break;
}
}
return res;
}
std::wstring DateConv::FormatToPersianNums(const std::wstring &date)
{
wstring res;
for (size_t i = 0; i < date.length(); ++i) {
switch(date[i]) {
case 0x30:
res += 0x06F0; // ۰
break;
case 0x31:
res += 0x06F1; // ۱
break;
case 0x32:
res += 0x06F2; // ۲
break;
case 0x33:
res += 0x06F3; // ۳
break;
case 0x34:
res += 0x06F4; // ۴
break;
case 0x35:
res += 0x06F5; // ۵
break;
case 0x36:
res += 0x06F6; // ۶
break;
case 0x37:
res += 0x06F7; // ۷
break;
case 0x38:
res += 0x06F8; // ۸
break;
case 0x39:
res += 0x06F9; // ۹
break;
default:
res += date[i];
break;
}
}
return res;
}
std::string DateConv::SecondsToHumanReadableTime(const std::time_t seconds)
{
tm *timeInfo = gmtime(&seconds);
stringstream ss;
int years = timeInfo->tm_year - 70; // years since 1900
if (years > 0) {
ss << years;
if (years == 1) {
ss << " year";
} else {
ss << " years";
}
}
int months = timeInfo->tm_mon; // months since January, 0-11
if (months > 0) {
if (ss.str().size() > 0) {
ss << ", ";
}
ss << months;
if (months == 1) {
ss << " month";
} else {
ss << " months";
}
}
int days = timeInfo->tm_mday - 1; // day of the month, 1-31
if (days > 0) {
if (ss.str().size() > 0) {
ss << ", ";
}
ss << days;
if (days == 1) {
ss << " day";
} else {
ss << " days";
}
}
int hours = timeInfo->tm_hour; // hours since midnight, 0-23
if (hours > 0) {
if (ss.str().size() > 0) {
ss << ", ";
}
ss << hours;
if (hours == 1) {
ss << " hour";
} else {
ss << " hours";
}
}
int minutes = timeInfo->tm_min; // minutes after the hour, 0-59
if (minutes > 0) {
if (ss.str().size() > 0) {
ss << ", ";
}
ss << minutes;
if (minutes == 1) {
ss << " minute";
} else {
ss << " minutes";
}
}
int seconds_ = timeInfo->tm_sec; // seconds after the minute, 0-61
if (seconds_ > 0) {
if (ss.str().size() > 0) {
ss << ", ";
}
ss << seconds_;
if (seconds_ == 1) {
ss << " second";
} else {
ss << " seconds";
}
}
return ss.str();
}
| 24.633803
| 170
| 0.548477
|
NuLL3rr0r
|
fabadb519efc48bf5a5ca684942147b894107661
| 20,824
|
cpp
|
C++
|
tests/unit/utils/test_pdu.cpp
|
ETCLabs/sACN
|
af246e04106f2342937566097322ac1ebb86fae0
|
[
"Apache-2.0"
] | 11
|
2020-08-06T16:08:29.000Z
|
2022-03-25T03:47:30.000Z
|
tests/unit/utils/test_pdu.cpp
|
ETCLabs/sACN
|
af246e04106f2342937566097322ac1ebb86fae0
|
[
"Apache-2.0"
] | 19
|
2020-05-21T21:36:06.000Z
|
2021-03-26T14:07:51.000Z
|
tests/unit/utils/test_pdu.cpp
|
ETCLabs/sACN
|
af246e04106f2342937566097322ac1ebb86fae0
|
[
"Apache-2.0"
] | 2
|
2021-05-04T05:19:31.000Z
|
2022-03-23T15:16:11.000Z
|
/******************************************************************************
* Copyright 2021 ETC Inc.
*
* 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.
******************************************************************************
* This file is a part of sACN. For more information, go to:
* https://github.com/ETCLabs/sACN
*****************************************************************************/
#include "sacn/private/pdu.h"
#include "etcpal/cpp/uuid.h"
#include "etcpal_mock/common.h"
#include "sacn/private/mem.h"
#include "sacn/private/opts.h"
#include "sacn_mock/private/common.h"
#include "gtest/gtest.h"
#include "fff.h"
// Suppress strncpy() warning on Windows/MSVC.
#ifdef _MSC_VER
#pragma warning(disable : 4996)
#endif
#if SACN_DYNAMIC_MEM
#define TestPdu TestPduDynamic
#else
#define TestPdu TestPduStatic
#endif
class TestPdu : public ::testing::Test
{
protected:
void SetUp() override
{
etcpal_reset_all_fakes();
sacn_common_reset_all_fakes();
memset(test_buffer_, 0, SACN_MTU);
}
void TearDown() override {}
void InitDataPacket(uint8_t* output, const SacnRemoteSource& source_info, const SacnRecvUniverseData& universe_data,
uint8_t seq, bool terminated)
{
memset(output, 0, SACN_MTU);
uint8_t* pcur = output;
pcur = InitRootLayer(pcur, source_info, universe_data);
pcur = InitFramingLayer(pcur, source_info, universe_data, seq, terminated);
InitDmpLayer(pcur, universe_data);
}
uint8_t* InitRootLayer(uint8_t* output, const SacnRemoteSource& source_info, const SacnRecvUniverseData& universe_data)
{
return InitRootLayer(output, SACN_DATA_HEADER_SIZE + universe_data.slot_range.address_count, false, source_info.cid);
}
uint8_t* InitRootLayer(uint8_t* output, int pdu_length, bool extended, const EtcPalUuid& source_cid)
{
uint8_t* pcur = output;
pcur += acn_pack_udp_preamble(pcur, ACN_UDP_PREAMBLE_SIZE); // Preamble & Post-amble Sizes + ACN Packet Identifier
(*pcur) |= 0x70u; // Flags
ACN_PDU_PACK_NORMAL_LEN(pcur, pdu_length - ACN_UDP_PREAMBLE_SIZE); // Length
pcur += 2;
etcpal_pack_u32b(pcur, extended ? ACN_VECTOR_ROOT_E131_EXTENDED : ACN_VECTOR_ROOT_E131_DATA); // Vector
pcur += 4;
memcpy(pcur, source_cid.data, ETCPAL_UUID_BYTES); // CID
pcur += ETCPAL_UUID_BYTES;
return pcur;
}
uint8_t* InitFramingLayer(uint8_t* output, const SacnRemoteSource& source_info,
const SacnRecvUniverseData& universe_data, uint8_t seq, bool terminated)
{
return InitFramingLayer(output, universe_data.slot_range.address_count, VECTOR_E131_DATA_PACKET, source_info.name,
universe_data.priority, seq, universe_data.preview, terminated, universe_data.universe_id);
}
uint8_t* InitFramingLayer(uint8_t* output, int slot_count, uint32_t vector, const char* source_name,
uint8_t priority, uint8_t seq_num, bool preview, bool terminated, uint16_t universe_id)
{
uint8_t* pcur = output;
(*pcur) |= 0x70u; // Flags
ACN_PDU_PACK_NORMAL_LEN(pcur, SACN_DATA_HEADER_SIZE + slot_count - SACN_FRAMING_OFFSET); // Length
pcur += 2;
etcpal_pack_u32b(pcur, vector); // Vector
pcur += 4;
strncpy((char*)pcur, source_name, SACN_SOURCE_NAME_MAX_LEN); // Source Name
pcur += SACN_SOURCE_NAME_MAX_LEN;
(*pcur) = priority; // Priority
++pcur;
etcpal_pack_u16b(pcur, 0u); // TODO: Synchronization Address
pcur += 2;
(*pcur) = seq_num; // Sequence Number
++pcur;
// Options
if (preview)
*pcur |= SACN_OPTVAL_PREVIEW;
if (terminated)
*pcur |= SACN_OPTVAL_TERMINATED;
// TODO: force_sync
++pcur;
etcpal_pack_u16b(pcur, universe_id); // Universe
pcur += 2;
return pcur;
}
uint8_t* InitDmpLayer(uint8_t* output, const SacnRecvUniverseData& universe_data)
{
return InitDmpLayer(output, universe_data.start_code, universe_data.slot_range.address_count, universe_data.slots);
}
uint8_t* InitDmpLayer(uint8_t* output, uint8_t start_code, int slot_count, const uint8_t* pdata)
{
uint8_t* pcur = output;
(*pcur) |= 0x70u; // Flags
ACN_PDU_PACK_NORMAL_LEN(pcur, SACN_DATA_HEADER_SIZE + slot_count - SACN_DMP_OFFSET); // Length
pcur += 2;
(*pcur) = 0x02u; // Vector = VECTOR_DMP_SET_PROPERTY
++pcur;
(*pcur) = 0xA1u; // Address Type & Data Type
++pcur;
etcpal_pack_u16b(pcur, 0x0000u); // First Property Address
pcur += 2;
etcpal_pack_u16b(pcur, 0x0001u); // Address Increment
pcur += 2;
etcpal_pack_u16b(pcur, static_cast<uint16_t>(slot_count) + 1u); // Property value count
pcur += 2;
(*pcur) = start_code; // DMX512-A START Code
++pcur;
if (pdata)
{
memcpy(pcur, pdata, slot_count); // Data
pdata += slot_count;
}
return pcur;
}
void TestParseDataPacket(const SacnRemoteSource& source_info, const SacnRecvUniverseData& universe_data, uint8_t seq,
bool terminated)
{
InitDataPacket(test_buffer_, source_info, universe_data, seq, terminated);
SacnRemoteSource source_info_out;
SacnRecvUniverseData universe_data_out;
uint8_t seq_out;
bool terminated_out;
EXPECT_TRUE(parse_sacn_data_packet(&test_buffer_[SACN_FRAMING_OFFSET], SACN_MTU - SACN_FRAMING_OFFSET,
&source_info_out, &seq_out, &terminated_out, &universe_data_out));
EXPECT_EQ(strcmp(source_info_out.name, source_info.name), 0);
EXPECT_EQ(universe_data_out.universe_id, universe_data.universe_id);
EXPECT_EQ(universe_data_out.priority, universe_data.priority);
EXPECT_EQ(universe_data_out.preview, universe_data.preview);
EXPECT_EQ(universe_data_out.start_code, universe_data.start_code);
EXPECT_EQ(universe_data_out.slot_range.address_count, universe_data.slot_range.address_count);
EXPECT_EQ(seq_out, seq);
EXPECT_EQ(terminated_out, terminated);
EXPECT_EQ(memcmp(universe_data_out.slots, universe_data.slots, universe_data.slot_range.address_count), 0);
}
void TestPackRootLayer(uint16_t pdu_length, bool extended, const EtcPalUuid& source_cid)
{
uint8_t result[SACN_MTU] = {0};
uint8_t expected[SACN_MTU] = {0};
int result_length = pack_sacn_root_layer(result, pdu_length, extended, &source_cid);
int expected_length = (int)(InitRootLayer(expected, pdu_length, extended, source_cid) - expected);
EXPECT_EQ(result_length, expected_length);
EXPECT_EQ(memcmp(result, expected, result_length), 0);
}
void TestPackDataFramingLayer(uint16_t slot_count, uint32_t vector, const char* source_name, uint8_t priority,
uint16_t sync_address, uint8_t seq_num, bool preview, bool terminated, bool force_sync,
uint16_t universe_id)
{
uint8_t result[SACN_MTU] = {0};
uint8_t expected[SACN_MTU] = {0};
int result_length = pack_sacn_data_framing_layer(result, slot_count, vector, source_name, priority, sync_address,
seq_num, preview, terminated, force_sync, universe_id);
int expected_length = (int)(InitFramingLayer(expected, slot_count, vector, source_name, priority, seq_num, preview,
terminated, universe_id) -
expected);
EXPECT_EQ(result_length, expected_length);
EXPECT_EQ(memcmp(result, expected, result_length), 0);
}
void TestPackDmpLayerHeader(uint8_t start_code, uint16_t slot_count)
{
uint8_t result[SACN_MTU] = {0};
uint8_t expected[SACN_MTU] = {0};
int result_length = pack_sacn_dmp_layer_header(result, start_code, slot_count);
int expected_length = (int)(InitDmpLayer(expected, start_code, slot_count, nullptr) - expected);
EXPECT_EQ(result_length, expected_length);
EXPECT_EQ(memcmp(result, expected, result_length), 0);
}
uint8_t test_buffer_[SACN_MTU];
};
TEST_F(TestPdu, SetSequenceWorks)
{
static constexpr uint8_t kTestSeqNum = 123u;
uint8_t old_buf[SACN_MTU];
memcpy(old_buf, test_buffer_, SACN_MTU);
SET_SEQUENCE(test_buffer_, kTestSeqNum);
EXPECT_EQ(test_buffer_[SACN_SEQ_OFFSET], kTestSeqNum);
SET_SEQUENCE(test_buffer_, 0u);
EXPECT_EQ(memcmp(test_buffer_, old_buf, SACN_MTU), 0);
}
TEST_F(TestPdu, SetTerminatedOptWorks)
{
uint8_t old_buf[SACN_MTU];
memcpy(old_buf, test_buffer_, SACN_MTU);
SET_TERMINATED_OPT(test_buffer_, true);
EXPECT_GT(test_buffer_[SACN_OPTS_OFFSET] & SACN_OPTVAL_TERMINATED, 0u);
SET_TERMINATED_OPT(test_buffer_, false);
EXPECT_EQ(memcmp(test_buffer_, old_buf, SACN_MTU), 0);
}
TEST_F(TestPdu, TerminatedOptSetWorks)
{
test_buffer_[SACN_OPTS_OFFSET] |= SACN_OPTVAL_TERMINATED;
EXPECT_TRUE(TERMINATED_OPT_SET(test_buffer_));
test_buffer_[SACN_OPTS_OFFSET] = 0u;
EXPECT_FALSE(TERMINATED_OPT_SET(test_buffer_));
}
TEST_F(TestPdu, SetPreviewOptWorks)
{
uint8_t old_buf[SACN_MTU];
memcpy(old_buf, test_buffer_, SACN_MTU);
SET_PREVIEW_OPT(test_buffer_, true);
EXPECT_GT(test_buffer_[SACN_OPTS_OFFSET] & SACN_OPTVAL_PREVIEW, 0u);
SET_PREVIEW_OPT(test_buffer_, false);
EXPECT_EQ(memcmp(test_buffer_, old_buf, SACN_MTU), 0);
}
TEST_F(TestPdu, SetPriorityWorks)
{
static constexpr uint8_t kTestPriority = 64u;
uint8_t old_buf[SACN_MTU];
memcpy(old_buf, test_buffer_, SACN_MTU);
SET_PRIORITY(test_buffer_, kTestPriority);
EXPECT_EQ(test_buffer_[SACN_PRI_OFFSET], kTestPriority);
SET_PRIORITY(test_buffer_, 0u);
EXPECT_EQ(memcmp(test_buffer_, old_buf, SACN_MTU), 0);
}
TEST_F(TestPdu, SetDataSlotCountWorks)
{
uint16_t test_count = 256;
SET_DATA_SLOT_COUNT(test_buffer_, test_count);
EXPECT_EQ(ACN_PDU_LENGTH((&test_buffer_[ACN_UDP_PREAMBLE_SIZE])),
static_cast<uint32_t>(SACN_DATA_HEADER_SIZE + test_count - ACN_UDP_PREAMBLE_SIZE));
EXPECT_EQ(ACN_PDU_LENGTH((&test_buffer_[SACN_FRAMING_OFFSET])),
static_cast<uint32_t>(SACN_DATA_HEADER_SIZE + test_count - SACN_FRAMING_OFFSET));
EXPECT_EQ(ACN_PDU_LENGTH((&test_buffer_[SACN_DMP_OFFSET])),
static_cast<uint32_t>(SACN_DATA_HEADER_SIZE + test_count - SACN_DMP_OFFSET));
SET_DATA_SLOT_COUNT(test_buffer_, 0u);
EXPECT_EQ(ACN_PDU_LENGTH((&test_buffer_[ACN_UDP_PREAMBLE_SIZE])),
static_cast<uint32_t>(SACN_DATA_HEADER_SIZE - ACN_UDP_PREAMBLE_SIZE));
EXPECT_EQ(ACN_PDU_LENGTH((&test_buffer_[SACN_FRAMING_OFFSET])),
static_cast<uint32_t>(SACN_DATA_HEADER_SIZE - SACN_FRAMING_OFFSET));
EXPECT_EQ(ACN_PDU_LENGTH((&test_buffer_[SACN_DMP_OFFSET])),
static_cast<uint32_t>(SACN_DATA_HEADER_SIZE - SACN_DMP_OFFSET));
}
TEST_F(TestPdu, SetUniverseCountWorks)
{
uint16_t test_count = 256;
SET_UNIVERSE_COUNT(test_buffer_, test_count);
EXPECT_EQ(ACN_PDU_LENGTH((&test_buffer_[ACN_UDP_PREAMBLE_SIZE])),
static_cast<uint32_t>(SACN_UNIVERSE_DISCOVERY_HEADER_SIZE + (test_count * 2u) - ACN_UDP_PREAMBLE_SIZE));
EXPECT_EQ(ACN_PDU_LENGTH((&test_buffer_[SACN_FRAMING_OFFSET])),
static_cast<uint32_t>(SACN_UNIVERSE_DISCOVERY_HEADER_SIZE + (test_count * 2u) - SACN_FRAMING_OFFSET));
EXPECT_EQ(
ACN_PDU_LENGTH((&test_buffer_[SACN_UNIVERSE_DISCOVERY_OFFSET])),
static_cast<uint32_t>(SACN_UNIVERSE_DISCOVERY_HEADER_SIZE + (test_count * 2u) - SACN_UNIVERSE_DISCOVERY_OFFSET));
SET_UNIVERSE_COUNT(test_buffer_, 0u);
EXPECT_EQ(ACN_PDU_LENGTH((&test_buffer_[ACN_UDP_PREAMBLE_SIZE])),
static_cast<uint32_t>(SACN_UNIVERSE_DISCOVERY_HEADER_SIZE - ACN_UDP_PREAMBLE_SIZE));
EXPECT_EQ(ACN_PDU_LENGTH((&test_buffer_[SACN_FRAMING_OFFSET])),
static_cast<uint32_t>(SACN_UNIVERSE_DISCOVERY_HEADER_SIZE - SACN_FRAMING_OFFSET));
EXPECT_EQ(ACN_PDU_LENGTH((&test_buffer_[SACN_UNIVERSE_DISCOVERY_OFFSET])),
static_cast<uint32_t>(SACN_UNIVERSE_DISCOVERY_HEADER_SIZE - SACN_UNIVERSE_DISCOVERY_OFFSET));
}
TEST_F(TestPdu, SetPageWorks)
{
static constexpr uint8_t kTestPage = 12u;
uint8_t old_buf[SACN_MTU];
memcpy(old_buf, test_buffer_, SACN_MTU);
SET_PAGE(test_buffer_, kTestPage);
EXPECT_EQ(test_buffer_[SACN_UNIVERSE_DISCOVERY_PAGE_OFFSET], kTestPage);
SET_PAGE(test_buffer_, 0u);
EXPECT_EQ(memcmp(test_buffer_, old_buf, SACN_MTU), 0);
}
TEST_F(TestPdu, SetLastPageWorks)
{
static constexpr uint8_t kTestPage = 12u;
uint8_t old_buf[SACN_MTU];
memcpy(old_buf, test_buffer_, SACN_MTU);
SET_LAST_PAGE(test_buffer_, kTestPage);
EXPECT_EQ(test_buffer_[SACN_UNIVERSE_DISCOVERY_LAST_PAGE_OFFSET], kTestPage);
SET_LAST_PAGE(test_buffer_, 0u);
EXPECT_EQ(memcmp(test_buffer_, old_buf, SACN_MTU), 0);
}
TEST_F(TestPdu, ParseSacnDataPacketWorks)
{
std::vector<uint8_t> data1 = {1u, 2u, 3u};
SacnRemoteSource source_info;
SacnRecvUniverseData universe_data;
source_info.cid = kEtcPalNullUuid;
strcpy(source_info.name, "Test Name");
universe_data.universe_id = 1u;
universe_data.priority = 100u;
universe_data.preview = true;
universe_data.start_code = SACN_STARTCODE_DMX;
universe_data.slot_range.address_count = static_cast<uint16_t>(data1.size());
universe_data.slots = data1.data();
TestParseDataPacket(source_info, universe_data, 1u, false);
std::vector<uint8_t> data2 = {7u, 6u, 5u, 4u, 3u};
source_info.cid = kEtcPalNullUuid;
strcpy(source_info.name, "Name Test");
universe_data.universe_id = 123u;
universe_data.priority = 64;
universe_data.preview = false;
universe_data.start_code = SACN_STARTCODE_PRIORITY;
universe_data.slot_range.address_count = static_cast<uint16_t>(data2.size());
universe_data.slots = data2.data();
TestParseDataPacket(source_info, universe_data, 10u, true);
std::vector<uint8_t> max_data;
for (int i = 0; i < DMX_ADDRESS_COUNT; ++i)
max_data.push_back(static_cast<uint8_t>(i));
source_info.cid = kEtcPalNullUuid;
strcpy(source_info.name, "012345678901234567890123456789012345678901234567890123456789012");
universe_data.universe_id = 0xFFFFu;
universe_data.priority = 0xFF;
universe_data.preview = true;
universe_data.start_code = 0xFF;
universe_data.slot_range.address_count = DMX_ADDRESS_COUNT;
universe_data.slots = max_data.data();
TestParseDataPacket(source_info, universe_data, 0xFFu, true);
}
TEST_F(TestPdu, ParseSacnDataPacketHandlesInvalid)
{
static const std::vector<uint8_t> kValidData = {1u, 2u, 3u};
static const SacnRemoteSource kValidSourceInfo = {1u, kEtcPalNullUuid, "Test Name"};
static const SacnRecvUniverseData kValidUniverseData = {
1u, 100u, true, false, SACN_STARTCODE_DMX, {1, 3}, kValidData.data()};
static constexpr size_t kBufLenTooShort = 87u;
static constexpr uint32_t kNonDataVector = (VECTOR_E131_DATA_PACKET + 123u);
static constexpr uint8_t kInvalidDmpVector = 0x04;
static constexpr uint8_t kInvalidAddressDataType = 0x12;
static constexpr uint16_t kInvalidFirstPropertyAddr = 0x9876;
static constexpr uint16_t kInvalidAddrIncrement = 0x1234;
static const size_t kValidBufferLength = (SACN_DATA_HEADER_SIZE + kValidData.size() - SACN_FRAMING_OFFSET);
SacnRemoteSource source_info_out;
SacnRecvUniverseData universe_data_out;
uint8_t seq_out;
bool terminated_out;
uint8_t valid_data[SACN_MTU];
InitDataPacket(valid_data, kValidSourceInfo, kValidUniverseData, 1u, false);
EXPECT_TRUE(parse_sacn_data_packet(&valid_data[SACN_FRAMING_OFFSET], kValidBufferLength, &source_info_out, &seq_out,
&terminated_out, &universe_data_out));
// Start with null pointers and short buffer length
EXPECT_FALSE(parse_sacn_data_packet(nullptr, kValidBufferLength, &source_info_out, &seq_out, &terminated_out,
&universe_data_out));
EXPECT_FALSE(parse_sacn_data_packet(&valid_data[SACN_FRAMING_OFFSET], kBufLenTooShort, &source_info_out, &seq_out,
&terminated_out, &universe_data_out));
EXPECT_FALSE(parse_sacn_data_packet(&valid_data[SACN_FRAMING_OFFSET], kValidBufferLength, nullptr, &seq_out,
&terminated_out, &universe_data_out));
EXPECT_FALSE(parse_sacn_data_packet(&valid_data[SACN_FRAMING_OFFSET], kValidBufferLength, &source_info_out, nullptr,
&terminated_out, &universe_data_out));
EXPECT_FALSE(parse_sacn_data_packet(&valid_data[SACN_FRAMING_OFFSET], kValidBufferLength, &source_info_out, &seq_out,
nullptr, &universe_data_out));
EXPECT_FALSE(parse_sacn_data_packet(&valid_data[SACN_FRAMING_OFFSET], kValidBufferLength, &source_info_out, &seq_out,
&terminated_out, nullptr));
// Now test buffer defects
uint8_t vector_not_data[SACN_MTU];
InitDataPacket(vector_not_data, kValidSourceInfo, kValidUniverseData, 1u, false);
etcpal_pack_u32b(&vector_not_data[SACN_FRAMING_OFFSET + 2], kNonDataVector);
EXPECT_FALSE(parse_sacn_data_packet(&vector_not_data[SACN_FRAMING_OFFSET], kValidBufferLength, &source_info_out,
&seq_out, &terminated_out, &universe_data_out));
uint8_t invalid_dmp_vector[SACN_MTU];
InitDataPacket(invalid_dmp_vector, kValidSourceInfo, kValidUniverseData, 1u, false);
invalid_dmp_vector[SACN_FRAMING_OFFSET + 79] = kInvalidDmpVector;
EXPECT_FALSE(parse_sacn_data_packet(&invalid_dmp_vector[SACN_FRAMING_OFFSET], kValidBufferLength, &source_info_out,
&seq_out, &terminated_out, &universe_data_out));
uint8_t invalid_address_data_type[SACN_MTU];
InitDataPacket(invalid_address_data_type, kValidSourceInfo, kValidUniverseData, 1u, false);
invalid_address_data_type[SACN_FRAMING_OFFSET + 80] = kInvalidAddressDataType;
EXPECT_FALSE(parse_sacn_data_packet(&invalid_address_data_type[SACN_FRAMING_OFFSET], kValidBufferLength,
&source_info_out, &seq_out, &terminated_out, &universe_data_out));
uint8_t invalid_first_property_addr[SACN_MTU];
InitDataPacket(invalid_first_property_addr, kValidSourceInfo, kValidUniverseData, 1u, false);
etcpal_pack_u16b(&invalid_first_property_addr[SACN_FRAMING_OFFSET + 81], kInvalidFirstPropertyAddr);
EXPECT_FALSE(parse_sacn_data_packet(&invalid_first_property_addr[SACN_FRAMING_OFFSET], kValidBufferLength,
&source_info_out, &seq_out, &terminated_out, &universe_data_out));
uint8_t invalid_addr_increment[SACN_MTU];
InitDataPacket(invalid_addr_increment, kValidSourceInfo, kValidUniverseData, 1u, false);
etcpal_pack_u16b(&invalid_addr_increment[SACN_FRAMING_OFFSET + 83], kInvalidAddrIncrement);
EXPECT_FALSE(parse_sacn_data_packet(&invalid_addr_increment[SACN_FRAMING_OFFSET], kValidBufferLength,
&source_info_out, &seq_out, &terminated_out, &universe_data_out));
uint8_t data_too_big[SACN_MTU];
InitDataPacket(data_too_big, kValidSourceInfo, kValidUniverseData, 1u, false);
etcpal_pack_u16b(&data_too_big[SACN_FRAMING_OFFSET + 85], static_cast<uint16_t>(kValidData.size() + 2u));
EXPECT_FALSE(parse_sacn_data_packet(&data_too_big[SACN_FRAMING_OFFSET], kValidBufferLength, &source_info_out,
&seq_out, &terminated_out, &universe_data_out));
}
TEST_F(TestPdu, PackSacnRootLayerWorks)
{
TestPackRootLayer(1234u, false, etcpal::Uuid::V4().get());
TestPackRootLayer(9876u, true, etcpal::Uuid::V4().get());
TestPackRootLayer(0xFFFFu, true, etcpal::Uuid().get());
}
TEST_F(TestPdu, PackSacnDataFramingLayerWorks)
{
TestPackDataFramingLayer(0x1234, 0x56789ABC, "A Test Name", 0xDE, 0xF012, 0x34, false, true, false, 0x5678);
TestPackDataFramingLayer(0xFEDC, 0xBA987654, "Another Test Name", 0x32, 0x10FE, 0xDC, true, false, true, 0xBA98);
TestPackDataFramingLayer(0xFFFF, 0xFFFFFFFF, "012345678901234567890123456789012345678901234567890123456789012", 0xFF,
0xFFFF, 0xFF, true, true, true, 0xFFFF);
}
TEST_F(TestPdu, PackSacnDmpLayerHeaderWorks)
{
TestPackDmpLayerHeader(0x12, 0x3456);
TestPackDmpLayerHeader(0xFE, 0xDCBA);
TestPackDmpLayerHeader(0xFF, 0xFFFF);
}
| 43.20332
| 121
| 0.72354
|
ETCLabs
|
fabf0ccfe8b774815ce0642000249c3ab15da1a2
| 723
|
cpp
|
C++
|
Kattis/Week2/Wk2b_height.cpp
|
Frodocz/CS2040C
|
d2e132a2f3cf56eef3f725990c7ffcf71a6a76d5
|
[
"MIT"
] | null | null | null |
Kattis/Week2/Wk2b_height.cpp
|
Frodocz/CS2040C
|
d2e132a2f3cf56eef3f725990c7ffcf71a6a76d5
|
[
"MIT"
] | null | null | null |
Kattis/Week2/Wk2b_height.cpp
|
Frodocz/CS2040C
|
d2e132a2f3cf56eef3f725990c7ffcf71a6a76d5
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <vector>
using namespace std;
void insertionSort(vector<int> &a) {
int n = a.size(), cnt = 0;
for (int i = 1; i < n; ++i) {
int j = i - 1, tmp = a[i];
for (; j >= 0 && a[j] > tmp; --j) {
a[j + 1] = a[j];
++cnt;
}
a[j + 1] = tmp;
}
cout << cnt << "\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, dataset;
cin >> n;
while (n--) {
cin >> dataset;
vector<int> a(20);
int h;
for (int i = 0; i < 20; i++) {
cin >> h;
a[i] = h;
}
cout << dataset << " ";
insertionSort(a);
}
return 0;
}
| 17.634146
| 43
| 0.391425
|
Frodocz
|
facc3ef96373a65ab1db80f8e76107a0a83577c9
| 16,030
|
cpp
|
C++
|
src/rpc/client.cpp
|
IntegralTeam/bitcoin-sv
|
fa3bfb58862262bd2eb8233fd65aee4a36eece28
|
[
"MIT"
] | null | null | null |
src/rpc/client.cpp
|
IntegralTeam/bitcoin-sv
|
fa3bfb58862262bd2eb8233fd65aee4a36eece28
|
[
"MIT"
] | null | null | null |
src/rpc/client.cpp
|
IntegralTeam/bitcoin-sv
|
fa3bfb58862262bd2eb8233fd65aee4a36eece28
|
[
"MIT"
] | null | null | null |
// Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2016 The Bitcoin Core developers
// Copyright (c) 2019 Bitcoin Association
// Distributed under the Open BSV software license, see the accompanying file LICENSE.
#include "rpc/client.h"
#include "rpc/protocol.h"
#include "util.h"
#include "support/events.h"
#include "chainparamsbase.h"
#include "utilstrencodings.h"
#include "clientversion.h"
#include <cstdint>
#include <set>
#include <boost/algorithm/string/case_conv.hpp> // for to_lower()
#include <univalue.h>
#include <event2/buffer.h>
#include <event2/keyvalq_struct.h>
class CRPCConvertParam {
public:
std::string methodName; //!< method whose params want conversion
int paramIdx; //!< 0-based idx of param to convert
std::string paramName; //!< parameter name
};
/**
* Specifiy a (method, idx, name) here if the argument is a non-string RPC
* argument and needs to be converted from JSON.
*
* @note Parameter indexes start from 0.
*/
static const CRPCConvertParam vRPCConvertParams[] = {
{"setmocktime", 0, "timestamp"},
{"generate", 0, "nblocks"},
{"generate", 1, "maxtries"},
{"generatetoaddress", 0, "nblocks"},
{"generatetoaddress", 2, "maxtries"},
{"getnetworkhashps", 0, "nblocks"},
{"getnetworkhashps", 1, "height"},
{"sendtoaddress", 1, "amount"},
{"sendtoaddress", 4, "subtractfeefromamount"},
{"settxfee", 0, "amount"},
{"getreceivedbyaddress", 1, "minconf"},
{"getreceivedbyaccount", 1, "minconf"},
{"listreceivedbyaddress", 0, "minconf"},
{"listreceivedbyaddress", 1, "include_empty"},
{"listreceivedbyaddress", 2, "include_watchonly"},
{"listreceivedbyaccount", 0, "minconf"},
{"listreceivedbyaccount", 1, "include_empty"},
{"listreceivedbyaccount", 2, "include_watchonly"},
{"getbalance", 1, "minconf"},
{"getbalance", 2, "include_watchonly"},
{"getblockhash", 0, "height"},
{"waitforblockheight", 0, "height"},
{"waitforblockheight", 1, "timeout"},
{"waitforblock", 1, "timeout"},
{"waitfornewblock", 0, "timeout"},
{"move", 2, "amount"},
{"move", 3, "minconf"},
{"sendfrom", 2, "amount"},
{"sendfrom", 3, "minconf"},
{"listtransactions", 1, "count"},
{"listtransactions", 2, "skip"},
{"listtransactions", 3, "include_watchonly"},
{"listaccounts", 0, "minconf"},
{"listaccounts", 1, "include_watchonly"},
{"walletpassphrase", 1, "timeout"},
{"getblocktemplate", 0, "template_request"},
{"listsinceblock", 1, "target_confirmations"},
{"listsinceblock", 2, "include_watchonly"},
{"sendmany", 1, "amounts"},
{"sendmany", 2, "minconf"},
{"sendmany", 4, "subtractfeefrom"},
{"addmultisigaddress", 0, "nrequired"},
{"addmultisigaddress", 1, "keys"},
{"createmultisig", 0, "nrequired"},
{"createmultisig", 1, "keys"},
{"listunspent", 0, "minconf"},
{"listunspent", 1, "maxconf"},
{"listunspent", 2, "addresses"},
{"getblock", 1, "verbose"},
{"getblockheader", 1, "verbose"},
{"getchaintxstats", 0, "nblocks"},
{"gettransaction", 1, "include_watchonly"},
{"getrawtransaction", 1, "verbose"},
{"createrawtransaction", 0, "inputs"},
{"createrawtransaction", 1, "outputs"},
{"createrawtransaction", 2, "locktime"},
{"signrawtransaction", 1, "prevtxs"},
{"signrawtransaction", 2, "privkeys"},
{"sendrawtransaction", 1, "allowhighfees"},
{"fundrawtransaction", 1, "options"},
{"gettxout", 1, "n"},
{"gettxout", 2, "include_mempool"},
{"gettxoutproof", 0, "txids"},
{"lockunspent", 0, "unlock"},
{"lockunspent", 1, "transactions"},
{"importprivkey", 2, "rescan"},
{"importaddress", 2, "rescan"},
{"importaddress", 3, "p2sh"},
{"importpubkey", 2, "rescan"},
{"importmulti", 0, "requests"},
{"importmulti", 1, "options"},
{"verifychain", 0, "checklevel"},
{"verifychain", 1, "nblocks"},
{"pruneblockchain", 0, "height"},
{"keypoolrefill", 0, "newsize"},
{"getrawmempool", 0, "verbose"},
{"estimatefee", 0, "nblocks"},
{"prioritisetransaction", 1, "priority_delta"},
{"prioritisetransaction", 2, "fee_delta"},
{"setban", 2, "bantime"},
{"setban", 3, "absolute"},
{"setnetworkactive", 0, "state"},
{"getmempoolancestors", 1, "verbose"},
{"getmempooldescendants", 1, "verbose"},
{"disconnectnode", 1, "nodeid"},
{"getminingcandidate", 0, "coinbase"},
// Echo with conversion (For testing only)
{"echojson", 0, "arg0"},
{"echojson", 1, "arg1"},
{"echojson", 2, "arg2"},
{"echojson", 3, "arg3"},
{"echojson", 4, "arg4"},
{"echojson", 5, "arg5"},
{"echojson", 6, "arg6"},
{"echojson", 7, "arg7"},
{"echojson", 8, "arg8"},
{"echojson", 9, "arg9"},
};
class CRPCConvertTable {
private:
std::set<std::pair<std::string, int>> members;
std::set<std::pair<std::string, std::string>> membersByName;
public:
CRPCConvertTable();
bool convert(const std::string &method, int idx) {
return (members.count(std::make_pair(method, idx)) > 0);
}
bool convert(const std::string &method, const std::string &name) {
return (membersByName.count(std::make_pair(method, name)) > 0);
}
};
CRPCConvertTable::CRPCConvertTable() {
const unsigned int n_elem =
(sizeof(vRPCConvertParams) / sizeof(vRPCConvertParams[0]));
for (unsigned int i = 0; i < n_elem; i++) {
members.insert(std::make_pair(vRPCConvertParams[i].methodName,
vRPCConvertParams[i].paramIdx));
membersByName.insert(std::make_pair(vRPCConvertParams[i].methodName,
vRPCConvertParams[i].paramName));
}
}
static CRPCConvertTable rpcCvtTable;
/**
* Non-RFC4627 JSON parser, accepts internal values (such as numbers, true,
* false, null) as well as objects and arrays.
*/
UniValue ParseNonRFCJSONValue(const std::string &strVal) {
UniValue jVal;
if (!jVal.read(std::string("[") + strVal + std::string("]")) ||
!jVal.isArray() || jVal.size() != 1)
throw std::runtime_error(std::string("Error parsing JSON:") + strVal);
return jVal[0];
}
UniValue RPCConvertValues(const std::string &strMethod,
const std::vector<std::string> &strParams) {
UniValue params(UniValue::VARR);
for (unsigned int idx = 0; idx < strParams.size(); idx++) {
const std::string &strVal = strParams[idx];
if (!rpcCvtTable.convert(strMethod, idx)) {
// insert string value directly
params.push_back(strVal);
} else {
// parse string as JSON, insert bool/number/object/etc. value
params.push_back(ParseNonRFCJSONValue(strVal));
}
}
return params;
}
UniValue RPCConvertNamedValues(const std::string &strMethod,
const std::vector<std::string> &strParams) {
UniValue params(UniValue::VOBJ);
for (const std::string &s : strParams) {
size_t pos = s.find("=");
if (pos == std::string::npos) {
throw(std::runtime_error("No '=' in named argument '" + s +
"', this needs to be present for every "
"argument (even if it is empty)"));
}
std::string name = s.substr(0, pos);
std::string value = s.substr(pos + 1);
if (!rpcCvtTable.convert(strMethod, name)) {
// insert string value directly
params.pushKV(name, value);
} else {
// parse string as JSON, insert bool/number/object/etc. value
params.pushKV(name, ParseNonRFCJSONValue(value));
}
}
return params;
}
const char *http_errorstring(int code)
{
switch (code)
{
#if LIBEVENT_VERSION_NUMBER >= 0x02010300
case EVREQ_HTTP_TIMEOUT:
return "timeout reached";
case EVREQ_HTTP_EOF:
return "EOF reached";
case EVREQ_HTTP_INVALID_HEADER:
return "error while reading header, or invalid header";
case EVREQ_HTTP_BUFFER_ERROR:
return "error encountered while reading or writing";
case EVREQ_HTTP_REQUEST_CANCEL:
return "request was canceled";
case EVREQ_HTTP_DATA_TOO_LONG:
return "response body is larger than allowed";
#endif
default:
return "unknown";
}
}
#if LIBEVENT_VERSION_NUMBER >= 0x02010300
static void http_error_cb(enum evhttp_request_error err, void *ctx) {
HTTPReply *reply = static_cast<HTTPReply *>(ctx);
reply->error = err;
}
#endif
void http_request_done(struct evhttp_request *req, void *ctx)
{
HTTPReply *reply = static_cast<HTTPReply *>(ctx);
if (req == nullptr)
{
/**
* If req is nullptr, it means an error occurred while connecting: the
* error code will have been passed to http_error_cb.
*/
reply->status = 0;
return;
}
reply->status = evhttp_request_get_response_code(req);
struct evbuffer *buf = evhttp_request_get_input_buffer(req);
if (buf)
{
size_t size = evbuffer_get_length(buf);
const char *data = (const char *)evbuffer_pullup(buf, size);
if (data) reply->body = std::string(data, size);
evbuffer_drain(buf, size);
}
}
UniValue CallRPC(const std::string &strMethod, const UniValue ¶ms)
{
std::string host;
// In preference order, we choose the following for the port:
// 1. -rpcport
// 2. port in -rpcconnect (ie following : in ipv4 or ]: in ipv6)
// 3. default port for chain
int port = BaseParams().RPCPort();
SplitHostPort(gArgs.GetArg("-rpcconnect", DEFAULT_RPCCONNECT), port, host);
port = gArgs.GetArg("-rpcport", port);
// Obtain event base
raii_event_base base = obtain_event_base();
// Synchronously look up hostname
raii_evhttp_connection evcon =
obtain_evhttp_connection_base(base.get(), host, port);
evhttp_connection_set_timeout(
evcon.get(),
gArgs.GetArg("-rpcclienttimeout", DEFAULT_HTTP_CLIENT_TIMEOUT));
HTTPReply response;
raii_evhttp_request req =
obtain_evhttp_request(http_request_done, (void *)&response);
if (req == nullptr) throw std::runtime_error("create http request failed");
#if LIBEVENT_VERSION_NUMBER >= 0x02010300
evhttp_request_set_error_cb(req.get(), http_error_cb);
#endif
// Get credentials
std::string strRPCUserColonPass;
if (gArgs.GetArg("-rpcpassword", "") == "")
{
// Try fall back to cookie-based authentication if no password is
// provided
if (!GetAuthCookie(&strRPCUserColonPass))
{
throw std::runtime_error(strprintf(
_("Could not locate RPC credentials. No authentication cookie "
"could be found, and RPC password is not set. See "
"-rpcpassword and -stdinrpcpass. Configuration file: (%s)"),
GetConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME)).string().c_str()));
}
}
else
{
strRPCUserColonPass = gArgs.GetArg("-rpcuser", "") + ":" + gArgs.GetArg("-rpcpassword", "");
}
struct evkeyvalq *output_headers = evhttp_request_get_output_headers(req.get());
assert(output_headers);
evhttp_add_header(output_headers, "Host", host.c_str());
evhttp_add_header(output_headers, "Connection", "close");
evhttp_add_header( output_headers, "Authorization", (std::string("Basic ") + EncodeBase64(strRPCUserColonPass)).c_str());
// Attach request data
std::string strRequest = JSONRPCRequestObj(strMethod, params, 1).write() + "\n";
struct evbuffer *output_buffer = evhttp_request_get_output_buffer(req.get());
assert(output_buffer);
evbuffer_add(output_buffer, strRequest.data(), strRequest.size());
// check if we should use a special wallet endpoint
std::string endpoint = "/";
std::string walletName = gArgs.GetArg("-rpcwallet", "");
if (!walletName.empty())
{
char *encodedURI = evhttp_uriencode(walletName.c_str(), walletName.size(), false);
if (encodedURI)
{
endpoint = "/wallet/" + std::string(encodedURI);
free(encodedURI);
}
else
{
throw CConnectionFailed("uri-encode failed");
}
}
int r = evhttp_make_request(evcon.get(), req.get(), EVHTTP_REQ_POST, endpoint.c_str());
// ownership moved to evcon in above call
req.release();
if (r != 0)
{
throw CConnectionFailed("send http request failed");
}
event_base_dispatch(base.get());
if (response.status == 0)
{
throw CConnectionFailed(strprintf(
"couldn't connect to server: %s (code %d)\n(make sure server is "
"running and you are connecting to the correct RPC port)",
http_errorstring(response.error), response.error));
}
else if (response.status == HTTP_UNAUTHORIZED)
{
throw std::runtime_error("incorrect rpcuser or rpcpassword (authorization failed)");
}
else if (response.status >= 400 && response.status != HTTP_BAD_REQUEST &&
response.status != HTTP_NOT_FOUND &&
response.status != HTTP_INTERNAL_SERVER_ERROR)
{
throw std::runtime_error(strprintf("server returned HTTP error %d", response.status));
}
else if (response.body.empty())
{
throw std::runtime_error("no response from server");
}
// Parse reply
UniValue valReply(UniValue::VSTR);
if (!valReply.read(response.body))
{
throw std::runtime_error("couldn't parse reply from server");
}
const UniValue &reply = valReply.get_obj();
if (reply.empty())
{
throw std::runtime_error("expected reply to have result, error and id properties");
}
return reply;
}
//
// This function returns either one of EXIT_ codes when it's expected to stop
// the process or CONTINUE_EXECUTION when it's expected to continue further.
//
int AppInitRPC(int argc, char *argv[], const std::string& usage_format, std::function<std::string(void)> help_message)
{
try
{
gArgs.ParseParameters(argc, argv);
}
catch(const std::exception& e)
{
fprintf(stderr, "Error parsing program options: %s\n", e.what());
return EXIT_FAILURE;
}
if (gArgs.IsArgSet("-?") || gArgs.IsArgSet("-h") || gArgs.IsArgSet("-help") || gArgs.IsArgSet("-version"))
{
std::string usage = strprintf(_("%s RPC client version"), _(PACKAGE_NAME)) + " " + FormatFullVersion() + "\n";
if (!gArgs.IsArgSet("-version"))
usage += usage_format + "\n" + help_message();
fprintf(stdout, "%s", usage.c_str());
if (argc < 2)
{
fprintf(stderr, "Error: too few parameters\n");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
if (!fs::is_directory(GetDataDir(false)))
{
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "").c_str());
return EXIT_FAILURE;
}
try
{
gArgs.ReadConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME));
}
catch (const std::exception &e)
{
fprintf(stderr, "Error reading configuration file: %s\n", e.what());
return EXIT_FAILURE;
}
// Check for -testnet or -regtest parameter (BaseParams() calls are only
// valid after this clause)
try
{
SelectBaseParams(ChainNameFromCommandLine());
}
catch (const std::exception &e)
{
fprintf(stderr, "Error: %s\n", e.what());
return EXIT_FAILURE;
}
if (gArgs.GetBoolArg("-rpcssl", false))
{
fprintf(stderr, "Error: SSL mode for RPC (-rpcssl) is no longer supported.\n");
return EXIT_FAILURE;
}
return CONTINUE_EXECUTION;
}
| 34.252137
| 125
| 0.61441
|
IntegralTeam
|
fadb733bcf9a30f11760de8fb5e92107df4ace98
| 3,885
|
hpp
|
C++
|
include/ShaderAST/Visitors/CloneExpr.hpp
|
Praetonus/ShaderWriter
|
1c5b3961e3e1b91cb7158406998519853a4add07
|
[
"MIT"
] | null | null | null |
include/ShaderAST/Visitors/CloneExpr.hpp
|
Praetonus/ShaderWriter
|
1c5b3961e3e1b91cb7158406998519853a4add07
|
[
"MIT"
] | null | null | null |
include/ShaderAST/Visitors/CloneExpr.hpp
|
Praetonus/ShaderWriter
|
1c5b3961e3e1b91cb7158406998519853a4add07
|
[
"MIT"
] | null | null | null |
/*
See LICENSE file in root folder
*/
#ifndef ___SDW_CloneExpr_H___
#define ___SDW_CloneExpr_H___
#pragma once
#include "ShaderAST/Expr/ExprVisitor.hpp"
namespace ast
{
class ExprCloner
: public expr::Visitor
{
public:
static expr::ExprPtr submit( expr::Expr * expr );
static expr::ExprPtr submit( expr::ExprPtr const & expr );
protected:
ExprCloner( expr::ExprPtr & result );
private:
virtual expr::ExprPtr doSubmit( expr::Expr * expr );
expr::ExprPtr doSubmit( expr::ExprPtr const & expr );
protected:
void visitAddExpr( expr::Add * expr )override;
void visitAddAssignExpr( expr::AddAssign * expr )override;
void visitAggrInitExpr( expr::AggrInit * expr )override;
void visitAliasExpr( expr::Alias * expr )override;
void visitAndAssignExpr( expr::AndAssign * expr )override;
void visitArrayAccessExpr( expr::ArrayAccess * expr )override;
void visitAssignExpr( expr::Assign * expr )override;
void visitBitAndExpr( expr::BitAnd * expr )override;
void visitBitNotExpr( expr::BitNot * expr )override;
void visitBitOrExpr( expr::BitOr * expr )override;
void visitBitXorExpr( expr::BitXor * expr )override;
void visitCastExpr( expr::Cast * expr )override;
void visitCommaExpr( expr::Comma * expr )override;
void visitCompositeConstructExpr( expr::CompositeConstruct * expr )override;
void visitDivideExpr( expr::Divide * expr )override;
void visitDivideAssignExpr( expr::DivideAssign * expr )override;
void visitEqualExpr( expr::Equal * expr )override;
void visitFnCallExpr( expr::FnCall * expr )override;
void visitGreaterExpr( expr::Greater * expr )override;
void visitGreaterEqualExpr( expr::GreaterEqual * expr )override;
void visitIdentifierExpr( expr::Identifier * expr )override;
void visitImageAccessCallExpr( expr::ImageAccessCall * expr )override;
void visitInitExpr( expr::Init * expr )override;
void visitIntrinsicCallExpr( expr::IntrinsicCall * expr )override;
void visitLessExpr( expr::Less * expr )override;
void visitLessEqualExpr( expr::LessEqual * expr )override;
void visitLiteralExpr( expr::Literal * expr )override;
void visitLogAndExpr( expr::LogAnd * expr )override;
void visitLogNotExpr( expr::LogNot * expr )override;
void visitLogOrExpr( expr::LogOr * expr )override;
void visitLShiftExpr( expr::LShift * expr )override;
void visitLShiftAssignExpr( expr::LShiftAssign * expr )override;
void visitMbrSelectExpr( expr::MbrSelect * expr )override;
void visitMinusExpr( expr::Minus * expr )override;
void visitMinusAssignExpr( expr::MinusAssign * expr )override;
void visitModuloExpr( expr::Modulo * expr )override;
void visitModuloAssignExpr( expr::ModuloAssign * expr )override;
void visitNotEqualExpr( expr::NotEqual * expr )override;
void visitOrAssignExpr( expr::OrAssign * expr )override;
void visitPostDecrementExpr( expr::PostDecrement * expr )override;
void visitPostIncrementExpr( expr::PostIncrement * expr )override;
void visitPreDecrementExpr( expr::PreDecrement * expr )override;
void visitPreIncrementExpr( expr::PreIncrement * expr )override;
void visitQuestionExpr( expr::Question * expr )override;
void visitRShiftExpr( expr::RShift * expr )override;
void visitRShiftAssignExpr( expr::RShiftAssign * expr )override;
void visitSwitchCaseExpr( expr::SwitchCase * expr )override;
void visitSwitchTestExpr( expr::SwitchTest * expr )override;
void visitSwizzleExpr( expr::Swizzle * expr )override;
void visitTextureAccessCallExpr( expr::TextureAccessCall * expr )override;
void visitTimesExpr( expr::Times * expr )override;
void visitTimesAssignExpr( expr::TimesAssign * expr )override;
void visitUnaryMinusExpr( expr::UnaryMinus * expr )override;
void visitUnaryPlusExpr( expr::UnaryPlus * expr )override;
void visitXorAssignExpr( expr::XorAssign * expr )override;
protected:
expr::ExprPtr & m_result;
};
}
#endif
| 43.651685
| 78
| 0.758559
|
Praetonus
|
fadbd5bf79c03e167658347a73c2102ca685c543
| 6,290
|
cpp
|
C++
|
Sail/src/Sail/entities/systems/Gameplay/candles/CandlePlacementSystem.cpp
|
BTH-StoraSpel-DXR/SPLASH
|
1bf4c9b96cbcce570ed3a97f30a556a992e1ad08
|
[
"MIT"
] | 12
|
2019-09-11T15:52:31.000Z
|
2021-11-14T20:33:35.000Z
|
Sail/src/Sail/entities/systems/Gameplay/candles/CandlePlacementSystem.cpp
|
BTH-StoraSpel-DXR/Game
|
1bf4c9b96cbcce570ed3a97f30a556a992e1ad08
|
[
"MIT"
] | 227
|
2019-09-11T08:40:24.000Z
|
2020-06-26T14:12:07.000Z
|
Sail/src/Sail/entities/systems/Gameplay/candles/CandlePlacementSystem.cpp
|
BTH-StoraSpel-DXR/Game
|
1bf4c9b96cbcce570ed3a97f30a556a992e1ad08
|
[
"MIT"
] | 2
|
2020-10-26T02:35:18.000Z
|
2020-10-26T02:36:01.000Z
|
#include "pch.h"
#include "CandlePlacementSystem.h"
#include "Sail/entities/components/Components.h"
#include "Network/NWrapperSingleton.h"
#include "Sail/utils/GameDataTracker.h"
#include "Sail/entities/ECS.h"
#include "Sail/entities/systems/physics/UpdateBoundingBoxSystem.h"
#include "Sail/events/EventDispatcher.h"
#include "Sail/events/types/HoldingCandleToggleEvent.h"
#include "Sail/events/types/TorchNotHeldEvent.h"
CandlePlacementSystem::CandlePlacementSystem() {
registerComponent<CandleComponent>(true, true, true);
registerComponent<TransformComponent>(true, true, true);
registerComponent<NetworkSenderComponent>(false, true, false);
registerComponent<AnimationComponent>(false, true, true);
registerComponent<CollisionComponent>(false, true, true);
EventDispatcher::Instance().subscribe(Event::Type::HOLDING_CANDLE_TOGGLE, this);
}
CandlePlacementSystem::~CandlePlacementSystem() {
EventDispatcher::Instance().unsubscribe(Event::Type::HOLDING_CANDLE_TOGGLE, this);
}
void CandlePlacementSystem::update(float dt) {
for (auto e : entities) {
if (e->isAboutToBeDestroyed()) {
continue;
}
auto candle = e->getComponent<CandleComponent>();
if (candle->isCarried != candle->wasCarriedLastUpdate) {
toggleCandlePlacement(e);
} else if (!candle->isLit && !candle->isCarried) {
candle->isCarried = true;
toggleCandlePlacement(e);
}
candle->wasCarriedLastUpdate = candle->isCarried;
constexpr float candleHeight = 0.37f;
glm::vec3 flamePos = e->getComponent<TransformComponent>()->getMatrixWithUpdate() * glm::vec4(0, candleHeight, 0, 1);
e->getComponent<LightComponent>()->currentPos = flamePos;
if (!candle->isCarried && e->getParent() && e->getParent()->hasComponent<NetworkReceiverComponent>()) {
EventDispatcher::Instance().emit(TorchNotHeldEvent(e->getParent()->getComponent<NetworkReceiverComponent>()->m_id));
}
}
}
void CandlePlacementSystem::toggleCandlePlacement(Entity* e) {
auto candleComp = e->getComponent<CandleComponent>();
auto candleTransComp = e->getComponent<TransformComponent>();
auto parentTransComp = e->getParent()->getComponent<TransformComponent>();
if (candleComp->isCarried) {
// Pick up the candle
if (glm::length(parentTransComp->getTranslation() - candleTransComp->getTranslation()) < 2.0f || !candleComp->isLit) {
candleTransComp->setParent(parentTransComp);
e->getParent()->getComponent<AnimationComponent>()->rightHandEntity = e;
e->removeComponent<CollisionComponent>();
if (e->hasComponent<MovementComponent>()) {
auto moveC = e->getComponent<MovementComponent>();
moveC->constantAcceleration = glm::vec3(0.f);
moveC->velocity = glm::vec3(0.f);
moveC->oldVelocity = glm::vec3(0.f);
}
candleTransComp->setCenter(glm::vec3(0.0f));
} else {
candleComp->isCarried = false;
}
}
// Only send the message if we actually did something to the candle
if (candleComp->isCarried != candleComp->wasCarriedLastUpdate) {
// Inform other players that we've put down our candle
if (e->getParent()->getComponent<LocalOwnerComponent>()) {
NWrapperSingleton::getInstance().queueGameStateNetworkSenderEvent(
Netcode::MessageType::CANDLE_HELD_STATE,
SAIL_NEW Netcode::MessageCandleHeldState{
e->getParent()->getComponent<NetworkSenderComponent>()->m_id,
candleComp->isCarried,
e->getComponent<TransformComponent>()->getTranslation()
},
false // We've already put down our own candle so no need to do it again
);
auto senderC = e->getComponent<NetworkSenderComponent>();
if (candleComp->isCarried) {
// If we're holding the candle it will be attached to our animation so don't send its
// position and rotation.
senderC->removeMessageType(Netcode::MessageType::CHANGE_LOCAL_POSITION);
senderC->removeMessageType(Netcode::MessageType::CHANGE_LOCAL_ROTATION);
NWrapperSingleton::getInstance().queueGameStateNetworkSenderEvent(
Netcode::MessageType::SET_CENTER,
SAIL_NEW Netcode::MessageSetCenter{
e->getComponent<NetworkReceiverComponent>()->m_id,
glm::vec3(0.0f)
}, false
);
} else {
// If we're no longer holding the candle then start sending its position and rotation
// so that other people will be able to see it when we throw it.
senderC->addMessageType(Netcode::MessageType::CHANGE_LOCAL_POSITION);
senderC->addMessageType(Netcode::MessageType::CHANGE_LOCAL_ROTATION);
}
}
}
}
bool CandlePlacementSystem::onEvent(const Event& event) {
auto onHoldingCandleToggle = [&](const HoldingCandleToggleEvent& e) {
Entity* player = nullptr;
Entity* candle = nullptr;
// Find the candle whose parent has the correct ID
for (auto candleEntity : entities) {
if (auto parentEntity = candleEntity->getParent(); parentEntity) {
if (parentEntity->getComponent<NetworkReceiverComponent>()->m_id == e.netCompID) {
player = parentEntity;
candle = candleEntity;
break;
}
}
}
// candle exists => player exists (only need to check candle)
if (!candle) {
SAIL_LOG_WARNING("Holding candle toggled but no matching entity found");
return;
}
auto candleComp = candle->getComponent<CandleComponent>();
auto candleTransComp = candle->getComponent<TransformComponent>();
candleComp->isCarried = e.isHeld;
candleComp->wasCarriedLastUpdate = e.isHeld;
if (e.isHeld) {
candleTransComp->setTranslation(glm::vec3(10.f, 2.0f, 0.f));
candleTransComp->setParent(player->getComponent<TransformComponent>());
player->getComponent<AnimationComponent>()->rightHandEntity = candle;
if (candle->hasComponent<MovementComponent>()) {
if (candle->hasComponent<MovementComponent>()) {
auto moveC = candle->getComponent<MovementComponent>();
moveC->constantAcceleration = glm::vec3(0.f);
moveC->velocity = glm::vec3(0.f);
moveC->oldVelocity = glm::vec3(0.f);
}
}
} else {
candleTransComp->removeParent();
player->getComponent<AnimationComponent>()->rightHandEntity = nullptr;
// Might be needed
ECS::Instance()->getSystem<UpdateBoundingBoxSystem>()->update(0.0f);
}
};
switch (event.type) {
case Event::Type::HOLDING_CANDLE_TOGGLE: onHoldingCandleToggle((const HoldingCandleToggleEvent&)event); break;
default: break;
}
return true;
}
| 35.942857
| 120
| 0.728299
|
BTH-StoraSpel-DXR
|
fadd48712932fb683728a410f11816edaf6fbaab
| 3,107
|
cpp
|
C++
|
Samples/JapanesePhoneticAnalysis/cpp/Scenario1_Analyze.xaml.cpp
|
dujianxin/Windows-universal-samples
|
d4e95ff0ac408c5d4d980bb18d53fb2c6556a273
|
[
"MIT"
] | 2,504
|
2019-05-07T06:56:42.000Z
|
2022-03-31T19:37:59.000Z
|
Samples/JapanesePhoneticAnalysis/cpp/Scenario1_Analyze.xaml.cpp
|
dujianxin/Windows-universal-samples
|
d4e95ff0ac408c5d4d980bb18d53fb2c6556a273
|
[
"MIT"
] | 314
|
2019-05-08T16:56:30.000Z
|
2022-03-21T07:13:45.000Z
|
Samples/JapanesePhoneticAnalysis/cpp/Scenario1_Analyze.xaml.cpp
|
dujianxin/Windows-universal-samples
|
d4e95ff0ac408c5d4d980bb18d53fb2c6556a273
|
[
"MIT"
] | 2,219
|
2019-05-07T00:47:26.000Z
|
2022-03-30T21:12:31.000Z
|
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#include "pch.h"
#include "MainPage.xaml.h"
#include "Scenario1_Analyze.xaml.h"
using namespace Platform;
using namespace SDKTemplate;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::Globalization;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;
Scenario1_Analyze::Scenario1_Analyze()
{
InitializeComponent();
}
void Scenario1_Analyze::AnalyzeButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
String^ input = InputTextBox->Text;
String^ output = L"";
// monoRuby = false means that each element in the result corresponds to a single Japanese word.
// monoRuby = true means that each element in the result corresponds to one or more characters which are pronounced as a single unit.
bool monoRuby = MonoRubyRadioButton->IsChecked->Value;
// Analyze the Japanese text according to the specified algorithm.
// The maximum length of the input string is 100 characters.
IVectorView<JapanesePhoneme^>^ words = JapanesePhoneticAnalyzer::GetWords(input, monoRuby);
for (JapanesePhoneme^ word : words)
{
// Put each phrase on its own line.
if (output->Length() != 0 && word->IsPhraseStart)
{
output += L"\r\n";
}
// DisplayText is the display text of the word, which has same characters as the input of GetWords().
// YomiText is the reading text of the word, as known as Yomi, which typically consists of Hiragana characters.
// However, please note that the reading can contains some non-Hiragana characters for some display texts such as emoticons or symbols.
output += word->DisplayText + L"(" + word->YomiText + L")";
}
// Display the result.
OutputTextBlock->Text = output;
if (input != L"" && output == L"")
{
// If the result from GetWords() is empty but the input is not empty,
// it means the given input is too long to analyze.
MainPage::Current->NotifyUser("Failed to get words from the input text. The input text is too long to analyze.", NotifyType::ErrorMessage);
}
else
{
// Otherwise, the analysis has been done successfully.
MainPage::Current->NotifyUser("Got words from the input text successfully.", NotifyType::StatusMessage);
}
}
| 43.760563
| 149
| 0.663663
|
dujianxin
|
fae2971ceeb3d2c00f22cb689232717f6b6027fb
| 24,677
|
cpp
|
C++
|
Source/Core/Main.cpp
|
HuCoco/RayTracing
|
e1d620a2d263a986a3557379588b72aea01f9181
|
[
"MIT"
] | null | null | null |
Source/Core/Main.cpp
|
HuCoco/RayTracing
|
e1d620a2d263a986a3557379588b72aea01f9181
|
[
"MIT"
] | null | null | null |
Source/Core/Main.cpp
|
HuCoco/RayTracing
|
e1d620a2d263a986a3557379588b72aea01f9181
|
[
"MIT"
] | null | null | null |
//============================================================
// STUDENT NAME: HU KE
// NUS User ID.: NUSRI1613
// COMMENTS TO GRADER:
//
//
// ============================================================
//
// FILE: Main.cpp
#include <Platform/Platform.h>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include "Util.h"
#include "Vector3d.h"
#include "Color.h"
#include "Image.h"
#include "Ray.h"
#include "Camera.h"
#include "Material.h"
#include "Light.h"
#include "Surface.h"
#include "Sphere.h"
#include "Plane.h"
#include "Triangle.h"
#include "Scene.h"
#include "Raytrace.h"
#include "ImGui/imgui.h"
#include "ImGui/imgui_impl_glfw_gl3.h"
#include <stdio.h>
#include <GL/gl3w.h> // This example is using gl3w to access OpenGL functions (because it is small). You may use glew/glad/glLoadGen/etc. whatever already works for you.
#include <GLFW/glfw3.h>
#include <Renderer/AsynRenderer.h>
#include <Core/Texture.h>
#include "Renderer/ComputeShaderRenderer.h"
#include "UI/RenderUI.h"
using namespace std;
// Constants for Scene 1.
static const uint32_t imageWidth1 = 640;
static const uint32_t imageHeight1 = 480;
static const uint32_t reflectLevels1 = 2; // 0 -- object does not reflect scene.
static const uint32_t numSample1 = 100;
static const bool hasShadow1 = true;
// Constants for Scene 2.
static const uint32_t imageWidth2 = 640;
static const uint32_t imageHeight2 = 480;
static const uint32_t reflectLevels2 = 2; // 0 -- object does not reflect scene.
static const uint32_t numSample2 = 100;
static const bool hasShadow2 = true;
static const uint32_t imageWidth3 = 640;
static const uint32_t imageHeight3 = 480;
static const uint32_t reflectLevels3 = 0; // 0 -- object does not reflect scene.
static const uint32_t numSample3 = 200;
static const bool hasShadow3 = false;
Image gImage;
Texture lut_tex;
///////////////////////////////////////////////////////////////////////////
// Raytrace the whole image of the scene and write it to a file.
///////////////////////////////////////////////////////////////////////////
//template<class T>
//void RenderImage( const char *imageFilename, const Scene &scene, int reflectLevels, bool hasShadow )
//{
// int imgWidth = scene.camera.getImageWidth();
// int imgHeight = scene.camera.getImageHeight();
//
// //Image image( imgWidth, imgHeight ); // To store the result of ray tracing.
// gImage.setImage(imgWidth, imgHeight);
// double startTime = Util::GetCurrRealTime();
// double startCPUTime = Util::GetCurrCPUTime();
//
// // Generate image.
// for ( int y = 0; y < imgHeight; y++ )
// {
// double pixelPosY = y + 0.5;
//
// for ( int x = 0; x < imgWidth; x++ )
// {
// double pixelPosX = x + 0.5;
// Ray ray = scene.camera.getRay( pixelPosX, pixelPosY );
// Color pixelColor = T::TraceRay( ray, scene, reflectLevels, hasShadow );
// pixelColor.clamp();
// gImage.setPixel( x, y, pixelColor );
// }
// // printf( "%d ", y );
// }
// double stopCPUTime = Util::GetCurrCPUTime();
// double stopTime = Util::GetCurrRealTime();
// printf( "CPU time taken = %.1f sec\n", stopCPUTime - startCPUTime );
// printf( "Real time taken = %.1f sec\n", stopTime - startTime );
//
// // Write image to file.
// //image.writeToFile( imageFilename );
//}
// Forward declarations. These functions are defined later in the file.
namespace PBR
{
void DefineScene1(Scene &scene, int imageWidth, int imageHeight);
void DefineScene2(Scene &scene, int imageWidth, int imageHeight);
void DefineScene3(Scene &scene, int imageWidth, int imageHeight);
}
namespace Phong
{
void DefineScene1(Scene &scene, int imageWidth, int imageHeight);
void DefineScene2(Scene &scene, int imageWidth, int imageHeight);
void DefineScene3(Scene &scene, int imageWidth, int imageHeight);
}
static void glfw_error_callback(int error, const char* description)
{
fprintf(stderr, "Error %d: %s\n", error, description);
}
Texture tex;
#include <SceneViewer/PBRViewer.h>
#include <UI/RenderUI.h>
int main()
{
RenderUI::GetInstance()->Initialize();
PBR::AsynRenderer::GetInstance()->Initialize();
Phong::AsynRenderer::GetInstance()->Initialize();
Phong::Scene scene1;
DefineScene1( scene1, imageWidth1, imageHeight1 );
Phong::Scene scene2;
DefineScene2( scene2, imageWidth2, imageHeight2 );
PBR::Scene scene3;
DefineScene3(scene3, imageWidth3, imageHeight3);
glfwSetErrorCallback(glfw_error_callback);
if (!glfwInit())
return 1;
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui GLFW+OpenGL3 example", NULL, NULL);
glfwMakeContextCurrent(window);
glfwSwapInterval(1); // Enable vsync
gl3wInit();
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
ImGui_ImplGlfwGL3_Init(window, true);
ImGui::StyleColorsDark();
io.Fonts->AddFontFromFileTTF("Resource/Fonts/Roboto-Medium.ttf", 16.0f);
gImage.setImage(scene2.camera.getImageWidth(), scene2.camera.getImageHeight());
PBRSceneViewer Viewer;
ViewWindow view("test");
Viewer.Initialize();
Viewer.SetScene(&scene3);
Viewer.SetViewWindow(&view);
lut_tex.Load("D:/RayTracing/Resource/Textures/pbdf_lut/ibl_brdf_lut.png");
PBR::ComputeShaderRenderer::GetInstance()->Initialize();
PBR::ComputeShaderRenderer::GetInstance()->CreateOutputImage(640, 480);
PBR::ComputeShaderRenderer::GetInstance()->GenerateShaderData(scene3);
PBR::ComputeShaderRenderer::GetInstance()->PrepareShaderData();
//RenderImage("C:/Users/Huke/Desktop/ImageTest/out2.tga", scene2, reflectLevels2, hasShadow2);
while (!glfwWindowShouldClose(window))
{
glfwPollEvents();
ImGui_ImplGlfwGL3_NewFrame();
RenderUI::GetInstance()->Update();
Viewer.Update();
//ImGui::End();
//ImGui::ShowDemoWindow();
//gImage.UpdateTexture();
//{
// static uint32_t aaa = 0;
// ImGui::Begin("Option");
// if (ImGui::Button("Start"))
// {
// //AsynRenderer::GetInstance()->RenderScene(&scene3, &gImage, 8, hasShadow3, reflectLevels3, numSample3);
// }
// if (ImGui::Button("Start2"))
// {
// // AsynRenderer::GetInstance()->RenderScene(&scene2, &gImage, 8, hasShadow2, reflectLevels2, numSample2);
// }
// if (ImGui::Button("Gamma"))
// {
// gImage.gammaCorrect();
// }
// ImGui::End();
//}
//{
// ImGui::Begin("Option");
// PBR::ComputeShaderRenderer::GetInstance()->GenerateShaderData(scene3);
// PBR::ComputeShaderRenderer::GetInstance()->PassShaderData();
// PBR::ComputeShaderRenderer::GetInstance()->Render();
// glBindTexture(GL_TEXTURE_2D, PBR::ComputeShaderRenderer::GetInstance()->GetOutputImageHandle());
// ImTextureID my_tex_id = reinterpret_cast<ImTextureID>(PBR::ComputeShaderRenderer::GetInstance()->GetOutputImageHandle());// (gImage.GetGLTextureHandle());//io.Fonts->TexID;
// ImTextureID my_tex_id = reinterpret_cast<ImTextureID>(gImage.GetGLTextureHandle());
// float my_tex_w = (float)gImage.GetWidth();//(float)io.Fonts->TexWidth;
// float my_tex_h = (float)gImage.GetHeight();//(float)io.Fonts->TexHeight;
// ImVec2 pos = ImGui::GetCursorScreenPos();
// ImGui::Image(my_tex_id, ImVec2(my_tex_w, my_tex_h), ImVec2(0, 0), ImVec2(1, 1), ImColor(255, 255, 255, 255), ImColor(255, 255, 255, 128));
//
// if (ImGui::IsItemHovered())
// {
// ImGui::BeginTooltip();
// float region_sz = 32.0f;
// float region_x = io.MousePos.x - pos.x - region_sz * 0.5f;
// if (region_x < 0.0f)
// region_x = 0.0f;
// else if (region_x > my_tex_w - region_sz)
// region_x = my_tex_w - region_sz;
// float region_y = io.MousePos.y - pos.y - region_sz * 0.5f;
// if (region_y < 0.0f)
// region_y = 0.0f;
// else if (region_y > my_tex_h - region_sz)
// region_y = my_tex_h - region_sz;
// float zoom = 4.0f;
// ImGui::Text("Min: (%.2f, %.2f)", region_x, region_y);
// ImGui::Text("Max: (%.2f, %.2f)", region_x + region_sz, region_y + region_sz);
// ImVec2 uv0 = ImVec2((region_x) / my_tex_w, (region_y) / my_tex_h);
// ImVec2 uv1 = ImVec2((region_x + region_sz) / my_tex_w, (region_y + region_sz) / my_tex_h);
// ImGui::Text("uv: (%.2f, %.2f)", uv0.x, uv0.y);
// ImGui::Image(my_tex_id, ImVec2(region_sz * zoom, region_sz * zoom), uv0, uv1, ImColor(255, 255, 255, 255), ImColor(255, 255, 255, 128));
// ImGui::EndTooltip();
// }
// ImGui::End();
//}
// Rendering
int display_w, display_h;
glfwGetFramebufferSize(window, &display_w, &display_h);
glViewport(0, 0, display_w, display_h);
glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
ImGui::Render();
ImGui_ImplGlfwGL3_RenderDrawData(ImGui::GetDrawData());
glfwSwapBuffers(window);
if (PBR::AsynRenderer::GetInstance()->IsFinishAllTask())
{
PBR::AsynRenderer::GetInstance()->ClearTasks();
}
}
PBR::AsynRenderer::GetInstance()->Finalize();
PBR::ComputeShaderRenderer::GetInstance()->Finalize();
RenderUI::GetInstance()->Finalize();
// Cleanup
ImGui_ImplGlfwGL3_Shutdown();
ImGui::DestroyContext();
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}
///////////////////////////////////////////////////////////////////////////
// Modeling of Scene 1.
///////////////////////////////////////////////////////////////////////////
namespace Phong
{
void DefineScene1(Scene &scene, int imageWidth, int imageHeight)
{
scene.backgroundColor = Color(0.2f, 0.3f, 0.5f);
scene.amLight.I_a = Color(1.0f, 1.0f, 1.0f) * 0.25f;
// Define materials.
scene.numMaterials = 5;
scene.material = new Material[scene.numMaterials];
Material* mat = reinterpret_cast<Material*>(scene.material);
// Light red.
scene.material[0].diffuse = Color(0.8f, 0.4f, 0.4f);
scene.material[0].ambient = Color(0.8f, 0.4f, 0.4f);
scene.material[0].specluar = Color(0.8f, 0.8f, 0.8f) / 1.5f;
scene.material[0].reflection = Color(0.8f, 0.8f, 0.8f) / 3.0f;
scene.material[0].shininess = 32.0f;
// Light green.
scene.material[1].diffuse = Color(0.4f, 0.8f, 0.4f);
scene.material[1].ambient = Color(0.4f, 0.8f, 0.4f);
scene.material[1].specluar = Color(0.8f, 0.8f, 0.8f) / 1.5f;
scene.material[1].reflection = Color(0.8f, 0.8f, 0.8f) / 3.0f;
scene.material[1].shininess = 64.0f;
// Light blue.
scene.material[2].diffuse = Color(0.4f, 0.4f, 0.8f) * 0.9f;
scene.material[2].ambient = Color(0.4f, 0.4f, 0.8f) * 0.9f;
scene.material[2].specluar = Color(0.8f, 0.8f, 0.8f) / 1.5f;
scene.material[2].reflection = Color(0.8f, 0.8f, 0.8f) / 2.5f;
scene.material[2].shininess = 64.0f;
// Yellow.
scene.material[3].diffuse = Color(0.6f, 0.6f, 0.2f);
scene.material[3].ambient = Color(0.6f, 0.6f, 0.2f);
scene.material[3].specluar = Color(0.8f, 0.8f, 0.8f) / 1.5f;
scene.material[3].reflection = Color(0.8f, 0.8f, 0.8f) / 3.0f;
scene.material[3].shininess = 64.0f;
// Gray.
scene.material[4].diffuse = Color(0.6f, 0.6f, 0.6f);
scene.material[4].ambient = Color(0.6f, 0.6f, 0.6f);
scene.material[4].specluar = Color(0.6f, 0.6f, 0.6f);
scene.material[4].reflection = Color(0.8f, 0.8f, 0.8f) / 3.0f;
scene.material[4].shininess = 128.0f;
// Define point light sources.
scene.numPtLights = 2;
scene.ptLight = new PointLightSource[scene.numPtLights];
scene.ptLight[0].I_source = Color(1.0f, 1.0f, 1.0f) * 0.6f;
scene.ptLight[0].position = Vector3d(100.0, 120.0, 10.0);
scene.ptLight[1].I_source = Color(1.0f, 1.0f, 1.0f) * 0.6f;
scene.ptLight[1].position = Vector3d(5.0, 80.0, 60.0);
// Define surface primitives.
scene.numSurfaces = 15;
scene.surfacep = new SurfacePtr[scene.numSurfaces];
scene.surfacep[0] = new Plane(0.0, 1.0, 0.0, 0.0, 2); // Horizontal plane.
scene.surfacep[1] = new Plane(1.0, 0.0, 0.0, 0.0, 4); // Left vertical plane.
scene.surfacep[2] = new Plane(0.0, 0.0, 1.0, 0.0, 4); // Right vertical plane.
scene.surfacep[3] = new Sphere(Vector3d(40.0, 20.0, 42.0), 22.0, 0); // Big sphere.
scene.surfacep[4] = new Sphere(Vector3d(75.0, 10.0, 40.0), 12.0, 1); // Small sphere.
// Cube +y face.
scene.surfacep[5] = new Triangle(Vector3d(50.0, 20.0, 90.0), Vector3d(50.0, 20.0, 70.0),
Vector3d(30.0, 20.0, 70.0), 3);
scene.surfacep[6] = new Triangle(Vector3d(50.0, 20.0, 90.0), Vector3d(30.0, 20.0, 70.0),
Vector3d(30.0, 20.0, 90.0), 3);
// Cube +x face.
scene.surfacep[7] = new Triangle(Vector3d(50.0, 0.0, 70.0), Vector3d(50.0, 20.0, 70.0),
Vector3d(50.0, 20.0, 90.0), 3);
scene.surfacep[8] = new Triangle(Vector3d(50.0, 0.0, 70.0), Vector3d(50.0, 20.0, 90.0),
Vector3d(50.0, 0.0, 90.0), 3);
// Cube -x face.
scene.surfacep[9] = new Triangle(Vector3d(30.0, 0.0, 90.0), Vector3d(30.0, 20.0, 90.0),
Vector3d(30.0, 20.0, 70.0), 3);
scene.surfacep[10] = new Triangle(Vector3d(30.0, 0.0, 90.0), Vector3d(30.0, 20.0, 70.0),
Vector3d(30.0, 0.0, 70.0),3);
// Cube +z face.
scene.surfacep[11] = new Triangle(Vector3d(50.0, 0.0, 90.0), Vector3d(50.0, 20.0, 90.0),
Vector3d(30.0, 20.0, 90.0), 3);
scene.surfacep[12] = new Triangle(Vector3d(50.0, 0.0, 90.0), Vector3d(30.0, 20.0, 90.0),
Vector3d(30.0, 0.0, 90.0), 3);
// Cube -z face.
scene.surfacep[13] = new Triangle(Vector3d(30.0, 0.0, 70.0), Vector3d(30.0, 20.0, 70.0),
Vector3d(50.0, 20.0, 70.0), 3);
scene.surfacep[14] = new Triangle(Vector3d(30.0, 0.0, 70.0), Vector3d(50.0, 20.0, 70.0),
Vector3d(50.0, 0.0, 70.0),3);
// Define camera.
scene.camera = Camera(Vector3d(150.0, 120.0, 150.0), Vector3d(45.0, 22.0, 55.0), Vector3d(0.0, 1.0, 0.0),
(-1.0 * imageWidth) / imageHeight, (1.0 * imageWidth) / imageHeight, -1.0, 1.0, 3.0,
imageWidth, imageHeight);
}
void DefineScene2(Scene &scene, int imageWidth, int imageHeight)
{
//***********************************************
//*********** WRITE YOUR CODE HERE **************
scene.backgroundColor = Color(0.2f, 0.3f, 0.5f);
scene.amLight.I_a = Color(1.0f, 1.0f, 1.0f) * 0.35f;
scene.numMaterials = 5;
scene.material = new Material[scene.numMaterials];
// Light red.
scene.material[0].diffuse = Color(0.8f, 0.4f, 0.4f);
scene.material[0].ambient = Color(0.8f, 0.4f, 0.4f);
scene.material[0].specluar = Color(0.8f, 0.8f, 0.8f) / 1.5f;
scene.material[0].reflection = Color(0.8f, 0.8f, 0.8f) / 3.0f;
scene.material[0].shininess = 32.0f;
// Light green.
scene.material[1].diffuse = Color(0.4f, 0.8f, 0.4f);
scene.material[1].ambient = Color(0.4f, 0.8f, 0.4f);
scene.material[1].specluar = Color(0.8f, 0.8f, 0.8f) / 1.5f;
scene.material[1].reflection = Color(0.8f, 0.8f, 0.8f) / 3.0f;
scene.material[1].shininess = 64.0f;
// Light blue.
scene.material[2].diffuse = Color(0.4f, 0.4f, 0.8f) * 0.9f;
scene.material[2].ambient = Color(0.4f, 0.4f, 0.8f) * 0.9f;
scene.material[2].specluar = Color(0.8f, 0.8f, 0.8f) / 1.5f;
scene.material[2].reflection = Color(0.8f, 0.8f, 0.8f) / 2.5f;
scene.material[2].shininess = 64.0f;
// Yellow.
scene.material[3].diffuse = Color(0.6f, 0.6f, 0.2f);
scene.material[3].ambient = Color(0.6f, 0.6f, 0.2f);
scene.material[3].specluar = Color(0.8f, 0.8f, 0.8f) / 1.5f;
scene.material[3].reflection = Color(0.8f, 0.8f, 0.8f) / 3.0f;
scene.material[3].shininess = 64.0f;
// Gray.
scene.material[4].diffuse = Color(0.6f, 0.6f, 0.6f);
scene.material[4].ambient = Color(0.6f, 0.6f, 0.6f);
scene.material[4].specluar = Color(0.6f, 0.6f, 0.6f);
scene.material[4].reflection = Color(0.8f, 0.8f, 0.8f) / 3.0f;
scene.material[4].shininess = 128.0f;
scene.numPtLights = 2;
scene.ptLight = new PointLightSource[scene.numPtLights];
scene.ptLight[0].I_source = Color(1.0f, 1.0f, 1.0f) * 0.6f;
scene.ptLight[0].position = Vector3d(40.0, 220.0, 10.0);
scene.ptLight[1].I_source = Color(1.0f, 1.0f, 1.0f) * 0.6f;
scene.ptLight[1].position = Vector3d(175.0, 80.0, 60.0);
scene.numSurfaces = 20;
scene.surfacep = new SurfacePtr[scene.numSurfaces];
scene.surfacep[0] = new Plane(0.0, 1.0, 0.0, 0.0, 3);
scene.surfacep[1] = new Plane(0.0, 0.0, 1.0, 0.0, 3);
for (int i = 0; i < 14; i++)
{
scene.surfacep[2 + i] = new Sphere(Vector3d(-320 + 40 * i, 20.0, 80.0 + 20 * sin(M_PI / 1.8 * i)), 20.0, rand() % scene.numMaterials);
}
scene.surfacep[16] = new Triangle(Vector3d(0.0, 50.0, 0.0), Vector3d(50.0, 0.0, 0.0),
Vector3d(0.0, 0.0, 50.0), 0);
scene.surfacep[17] = new Triangle(Vector3d(0.0, 50.0, 0.0), Vector3d(-50.0, 0.0, 0.0),
Vector3d(0.0, 0.0, 50.0), 0);
scene.surfacep[18] = new Triangle(Vector3d(0.0, 50.0, 0.0), Vector3d(-50.0, 0.0, 0.0),
Vector3d(50.0, 0.0, 0.0), 0);
scene.surfacep[19] = new Triangle(Vector3d(0.0, 0.0, 50.0), Vector3d(-50.0, 0.0, 0.0),
Vector3d(50.0, 0.0, 0.0), 0);
scene.camera = Camera(Vector3d(300.0, 240.0, 300.0), Vector3d(45.0, 22.0, 55.0), Vector3d(0.0, 1.0, 0.0),
(-1.0 * imageWidth) / imageHeight, (1.0 * imageWidth) / imageHeight, -1.0, 1.0, 3.0,
imageWidth, imageHeight);;
//***********************************************
}
}
///////////////////////////////////////////////////////////////////////////
// Modeling of Scene 2.
///////////////////////////////////////////////////////////////////////////
namespace PBR
{
void DefineScene3(Scene &scene, int imageWidth, int imageHeight)
{
scene.backgroundColor = Color(0.2f, 0.3f, 0.5f);
scene.amLight.I_a = Color(1.0f, 1.0f, 1.0f) * 0.25f;
scene.amLight.direction = Vector3d(1.0f, 1.0f, 0.0f);
// Define materials.
scene.numMaterials = 5;
scene.material = new Material[scene.numMaterials];
Material* mat = reinterpret_cast<Material*>(scene.material);
// Light red.
scene.material[0].albedo = Color(0.8f, 0.4f, 0.4f);
scene.material[0].roughness = 0.15;
scene.material[0].metallic = 0.55;
//scene.material[0].ambient = Color(0.8f, 0.4f, 0.4f);
//scene.material[0].specluar = Color(0.8f, 0.8f, 0.8f) / 1.5f;
//scene.material[0].reflection = Color(0.8f, 0.8f, 0.8f) / 3.0f;
//scene.material[0].shininess = 32.0f;
// Light green.
scene.material[1].albedo = Color(0.4f, 0.8f, 0.4f);
scene.material[1].roughness = 0.75;
scene.material[1].metallic = 0.25;
//scene.material[1].ambient = Color(0.4f, 0.8f, 0.4f);
//scene.material[1].specluar = Color(0.8f, 0.8f, 0.8f) / 1.5f;
//scene.material[1].reflection = Color(0.8f, 0.8f, 0.8f) / 3.0f;
//scene.material[1].shininess = 64.0f;
// Light blue.
scene.material[2].albedo = Color(0.4f, 0.4f, 0.8f) * 0.9f;
scene.material[2].roughness = 0.75;
scene.material[2].metallic = 0.25;
//scene.material[2].ambient = Color(0.4f, 0.4f, 0.8f) * 0.9f;
//scene.material[2].specluar = Color(0.8f, 0.8f, 0.8f) / 1.5f;
//scene.material[2].reflection = Color(0.8f, 0.8f, 0.8f) / 2.5f;
//scene.material[2].shininess = 64.0f;
// Yellow.
scene.material[3].albedo = Color(0.6f, 0.6f, 0.2f);
scene.material[3].roughness = 0.75;
scene.material[3].metallic = 0.25;
//scene.material[3].ambient = Color(0.6f, 0.6f, 0.2f);
//scene.material[3].specluar = Color(0.8f, 0.8f, 0.8f) / 1.5f;
//scene.material[3].reflection = Color(0.8f, 0.8f, 0.8f) / 3.0f;
//scene.material[3].shininess = 64.0f;
// Gray.
scene.material[4].albedo = Color(0.6f, 0.6f, 0.6f);
scene.material[4].roughness = 0.75;
scene.material[4].metallic = 0.25;
//scene.material[4].ambient = Color(0.6f, 0.6f, 0.6f);
//scene.material[4].specluar = Color(0.6f, 0.6f, 0.6f);
//scene.material[4].reflection = Color(0.8f, 0.8f, 0.8f) / 3.0f;
//scene.material[4].shininess = 128.0f;
scene.numPtLights = 2;
scene.ptLight = new PointLightSource[scene.numPtLights];
scene.ptLight[0].I_source = Color(1300.0f, 300.0f, 300.0f);
scene.ptLight[0].position = Vector3d(100.0, 120.0, 10.0);
scene.ptLight[1].I_source = Color(300.0f, 300.0f, 300.0f);
scene.ptLight[1].position = Vector3d(5.0, 80.0, 60.0);
// Define surface primitives.
scene.numSurfaces = 15;
scene.surfacep = new SurfacePtr[scene.numSurfaces];
scene.surfacep[0] = new Plane(0.0, 1.0, 0.0, 0.0, 2); // Horizontal plane.
scene.surfacep[1] = new Plane(1.0, 0.0, 0.0, 0.0, 3); // Left vertical plane.
scene.surfacep[2] = new Plane(0.0, 0.0, 1.0, 0.0, 3); // Right vertical plane.
scene.surfacep[3] = new Sphere(Vector3d(40.0, 20.0, 42.0), 22.0, 0); // Big sphere.
scene.surfacep[4] = new Sphere(Vector3d(75.0, 10.0, 40.0), 12.0, 1); // Small sphere.
// Cube +y face.
scene.surfacep[5] = new Triangle(Vector3d(50.0, 20.0, 90.0), Vector3d(50.0, 20.0, 70.0),
Vector3d(30.0, 20.0, 70.0), 3);
scene.surfacep[6] = new Triangle(Vector3d(50.0, 20.0, 90.0), Vector3d(30.0, 20.0, 70.0),
Vector3d(30.0, 20.0, 90.0), 3);
// Cube +x face.
scene.surfacep[7] = new Triangle(Vector3d(50.0, 0.0, 70.0), Vector3d(50.0, 20.0, 70.0),
Vector3d(50.0, 20.0, 90.0), 3);
scene.surfacep[8] = new Triangle(Vector3d(50.0, 0.0, 70.0), Vector3d(50.0, 20.0, 90.0),
Vector3d(50.0, 0.0, 90.0), 3);
// Cube -x face.
scene.surfacep[9] = new Triangle(Vector3d(30.0, 0.0, 90.0), Vector3d(30.0, 20.0, 90.0),
Vector3d(30.0, 20.0, 70.0), 3);
scene.surfacep[10] = new Triangle(Vector3d(30.0, 0.0, 90.0), Vector3d(30.0, 20.0, 70.0),
Vector3d(30.0, 0.0, 70.0), 3);
// Cube +z face.
scene.surfacep[11] = new Triangle(Vector3d(50.0, 0.0, 90.0), Vector3d(50.0, 20.0, 90.0),
Vector3d(30.0, 20.0, 90.0), 3);
scene.surfacep[12] = new Triangle(Vector3d(50.0, 0.0, 90.0), Vector3d(30.0, 20.0, 90.0),
Vector3d(30.0, 0.0, 90.0), 3);
// Cube -z face.
scene.surfacep[13] = new Triangle(Vector3d(30.0, 0.0, 70.0), Vector3d(30.0, 20.0, 70.0),
Vector3d(50.0, 20.0, 70.0), 3);
scene.surfacep[14] = new Triangle(Vector3d(30.0, 0.0, 70.0), Vector3d(50.0, 20.0, 70.0),
Vector3d(50.0, 0.0, 70.0), 3);
//scene.camera = Camera(Vector3d(0.0, 0.0, 0.0), Vector3d(0.0, 0.0, 10.0), Vector3d(0.0, 1.0, 0.0),
// (-1.0 * imageWidth) / imageHeight, (1.0 * imageWidth) / imageHeight, -1.0, 1.0, 3.0,
// imageWidth, imageHeight);;
scene.camera = Camera(Vector3d(150.0, 120.0, 150.0), Vector3d(45.0, 22.0, 55.0), Vector3d(0.0, 1.0, 0.0),
(-1.0 * imageWidth) / imageHeight, (1.0 * imageWidth) / imageHeight, -1.0, 1.0, 3.0,
imageWidth, imageHeight);
}
}
| 39.546474
| 186
| 0.568627
|
HuCoco
|
fae5e30f76170ab17e3504fc5740c20e0de08435
| 6,769
|
hpp
|
C++
|
include/codegen/include/System/IO/MemoryStream.hpp
|
Futuremappermydud/Naluluna-Modifier-Quest
|
bfda34370764b275d90324b3879f1a429a10a873
|
[
"MIT"
] | 1
|
2021-11-12T09:29:31.000Z
|
2021-11-12T09:29:31.000Z
|
include/codegen/include/System/IO/MemoryStream.hpp
|
Futuremappermydud/Naluluna-Modifier-Quest
|
bfda34370764b275d90324b3879f1a429a10a873
|
[
"MIT"
] | null | null | null |
include/codegen/include/System/IO/MemoryStream.hpp
|
Futuremappermydud/Naluluna-Modifier-Quest
|
bfda34370764b275d90324b3879f1a429a10a873
|
[
"MIT"
] | 2
|
2021-10-03T02:14:20.000Z
|
2021-11-12T09:29:36.000Z
|
// Autogenerated from CppHeaderCreator on 7/27/2020 3:09:44 PM
// Created by Sc2ad
// =========================================================================
#pragma once
#pragma pack(push, 8)
// Begin includes
#include "utils/typedefs.h"
// Including type: System.IO.Stream
#include "System/IO/Stream.hpp"
#include "utils/il2cpp-utils.hpp"
// Completed includes
// Begin forward declares
// Forward declaring namespace: System::Threading::Tasks
namespace System::Threading::Tasks {
// Forward declaring type: Task`1<TResult>
template<typename TResult>
class Task_1;
}
// Forward declaring namespace: System::IO
namespace System::IO {
// Forward declaring type: SeekOrigin
struct SeekOrigin;
}
// Completed forward declares
// Type namespace: System.IO
namespace System::IO {
// Autogenerated type: System.IO.MemoryStream
class MemoryStream : public System::IO::Stream {
public:
// private System.Byte[] _buffer
// Offset: 0x28
::Array<uint8_t>* buffer;
// private System.Int32 _origin
// Offset: 0x30
int origin;
// private System.Int32 _position
// Offset: 0x34
int position;
// private System.Int32 _length
// Offset: 0x38
int length;
// private System.Int32 _capacity
// Offset: 0x3C
int capacity;
// private System.Boolean _expandable
// Offset: 0x40
bool expandable;
// private System.Boolean _writable
// Offset: 0x41
bool writable;
// private System.Boolean _exposable
// Offset: 0x42
bool exposable;
// private System.Boolean _isOpen
// Offset: 0x43
bool isOpen;
// private System.Threading.Tasks.Task`1<System.Int32> _lastReadTask
// Offset: 0x48
System::Threading::Tasks::Task_1<int>* lastReadTask;
// public System.Void .ctor(System.Int32 capacity)
// Offset: 0x1124474
static MemoryStream* New_ctor(int capacity);
// public System.Void .ctor(System.Byte[] buffer)
// Offset: 0x112457C
static MemoryStream* New_ctor(::Array<uint8_t>* buffer);
// public System.Void .ctor(System.Byte[] buffer, System.Boolean writable)
// Offset: 0x1124584
static MemoryStream* New_ctor(::Array<uint8_t>* buffer, bool writable);
// private System.Void EnsureWriteable()
// Offset: 0x11246A4
void EnsureWriteable();
// private System.Boolean EnsureCapacity(System.Int32 value)
// Offset: 0x112475C
bool EnsureCapacity(int value);
// public System.Byte[] GetBuffer()
// Offset: 0x1124858
::Array<uint8_t>* GetBuffer();
// System.Byte[] InternalGetBuffer()
// Offset: 0x11248F4
::Array<uint8_t>* InternalGetBuffer();
// System.Int32 InternalGetPosition()
// Offset: 0x11179AC
int InternalGetPosition();
// System.Int32 InternalReadInt32()
// Offset: 0x1116E44
int InternalReadInt32();
// System.Int32 InternalEmulateRead(System.Int32 count)
// Offset: 0x11179DC
int InternalEmulateRead(int count);
// public System.Int32 get_Capacity()
// Offset: 0x11248FC
int get_Capacity();
// public System.Void set_Capacity(System.Int32 value)
// Offset: 0x1124934
void set_Capacity(int value);
// public System.Byte[] ToArray()
// Offset: 0x112506C
::Array<uint8_t>* ToArray();
// public System.Void .ctor()
// Offset: 0x112446C
// Implemented from: System.IO.Stream
// Base method: System.Void Stream::.ctor()
// Base method: System.Void MarshalByRefObject::.ctor()
// Base method: System.Void Object::.ctor()
static MemoryStream* New_ctor();
// public override System.Boolean get_CanRead()
// Offset: 0x112468C
// Implemented from: System.IO.Stream
// Base method: System.Boolean Stream::get_CanRead()
bool get_CanRead();
// public override System.Boolean get_CanSeek()
// Offset: 0x1124694
// Implemented from: System.IO.Stream
// Base method: System.Boolean Stream::get_CanSeek()
bool get_CanSeek();
// public override System.Boolean get_CanWrite()
// Offset: 0x112469C
// Implemented from: System.IO.Stream
// Base method: System.Boolean Stream::get_CanWrite()
bool get_CanWrite();
// protected override System.Void Dispose(System.Boolean disposing)
// Offset: 0x11246D0
// Implemented from: System.IO.Stream
// Base method: System.Void Stream::Dispose(System.Boolean disposing)
void Dispose(bool disposing);
// public override System.Void Flush()
// Offset: 0x1124854
// Implemented from: System.IO.Stream
// Base method: System.Void Stream::Flush()
void Flush();
// public override System.Int64 get_Length()
// Offset: 0x1124AB0
// Implemented from: System.IO.Stream
// Base method: System.Int64 Stream::get_Length()
int64_t get_Length();
// public override System.Int64 get_Position()
// Offset: 0x1124AEC
// Implemented from: System.IO.Stream
// Base method: System.Int64 Stream::get_Position()
int64_t get_Position();
// public override System.Void set_Position(System.Int64 value)
// Offset: 0x1124B24
// Implemented from: System.IO.Stream
// Base method: System.Void Stream::set_Position(System.Int64 value)
void set_Position(int64_t value);
// public override System.Int32 Read(System.Byte[] buffer, System.Int32 offset, System.Int32 count)
// Offset: 0x1124C04
// Implemented from: System.IO.Stream
// Base method: System.Int32 Stream::Read(System.Byte[] buffer, System.Int32 offset, System.Int32 count)
int Read(::Array<uint8_t>*& buffer, int offset, int count);
// public override System.Int32 ReadByte()
// Offset: 0x1124E54
// Implemented from: System.IO.Stream
// Base method: System.Int32 Stream::ReadByte()
int ReadByte();
// public override System.Int64 Seek(System.Int64 offset, System.IO.SeekOrigin loc)
// Offset: 0x1124ECC
// Implemented from: System.IO.Stream
// Base method: System.Int64 Stream::Seek(System.Int64 offset, System.IO.SeekOrigin loc)
int64_t Seek(int64_t offset, System::IO::SeekOrigin loc);
// public override System.Void Write(System.Byte[] buffer, System.Int32 offset, System.Int32 count)
// Offset: 0x1125124
// Implemented from: System.IO.Stream
// Base method: System.Void Stream::Write(System.Byte[] buffer, System.Int32 offset, System.Int32 count)
void Write(::Array<uint8_t>* buffer, int offset, int count);
// public override System.Void WriteByte(System.Byte value)
// Offset: 0x1125434
// Implemented from: System.IO.Stream
// Base method: System.Void Stream::WriteByte(System.Byte value)
void WriteByte(uint8_t value);
}; // System.IO.MemoryStream
}
DEFINE_IL2CPP_ARG_TYPE(System::IO::MemoryStream*, "System.IO", "MemoryStream");
#pragma pack(pop)
| 38.68
| 108
| 0.684592
|
Futuremappermydud
|
fae74ef5c8696a64df54c136f27a86b36f484544
| 4,586
|
cpp
|
C++
|
src/fit_nfw_mass.cpp
|
sjtuzyk/chandra-acis-analysis
|
8d194c8107ba2e91b35eba95c044ac238ce03229
|
[
"MIT"
] | 3
|
2016-05-28T00:32:55.000Z
|
2022-02-28T13:36:04.000Z
|
src/fit_nfw_mass.cpp
|
sjtuzyk/chandra-acis-analysis
|
8d194c8107ba2e91b35eba95c044ac238ce03229
|
[
"MIT"
] | null | null | null |
src/fit_nfw_mass.cpp
|
sjtuzyk/chandra-acis-analysis
|
8d194c8107ba2e91b35eba95c044ac238ce03229
|
[
"MIT"
] | 1
|
2018-10-09T16:42:18.000Z
|
2018-10-09T16:42:18.000Z
|
/*
Fitting nfw mass profile model
Author: Junhua Gu
Last modification 20120721
*/
#include "nfw.hpp"
#include <core/optimizer.hpp>
#include <core/fitter.hpp>
#include <data_sets/default_data_set.hpp>
#include "chisq.hpp"
#include <methods/powell/powell_method.hpp>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
using namespace opt_utilities;
using namespace std;
const double cm=1;
const double kpc=3.08568e+21*cm;
const double pi=4*atan(1);
static double calc_critical_density(double z,
const double H0=2.3E-18,
const double Omega_m=.27)
{
const double G=6.673E-8;//cm^3 g^-1 s^2
const double E=std::sqrt(Omega_m*(1+z)*(1+z)*(1+z)+1-Omega_m);
const double H=H0*E;
return 3*H*H/8/pi/G;
}
int main(int argc,char* argv[])
{
if(argc<3)
{
cerr<<"Usage:"<<argv[0]<<" <data file with 4 columns of x, xe, y, ye> <z> [rmin in kpc]"<<endl;
return -1;
}
double rmin_kpc=1;
if(argc>=4)
{
rmin_kpc=atof(argv[3]);
}
double z=0;
z=atof(argv[2]);
//define the fitter
fitter<double,double,vector<double>,double,std::string> fit;
//define the data set
default_data_set<double,double> ds;
//open the data file
ifstream ifs(argv[1]);
//cout<<"read serr 2"<<endl;
ofstream ofs_fit_result("nfw_fit_result.qdp");
ofs_fit_result<<"read serr 1 2"<<endl;
ofs_fit_result<<"skip single"<<endl;
ofs_fit_result<<"line off"<<endl;
ofs_fit_result<<"li on 2"<<endl;
ofs_fit_result<<"li on 4"<<endl;
ofs_fit_result<<"ls 2 on 4"<<endl;
ofs_fit_result<<"win 1"<<endl;
ofs_fit_result<<"yplot 1 2"<<endl;
ofs_fit_result<<"loc 0 0 1 1"<<endl;
ofs_fit_result<<"vie .1 .4 .9 .9"<<endl;
ofs_fit_result<<"la y Mass (solar)"<<endl;
ofs_fit_result<<"log x"<<endl;
ofs_fit_result<<"log y"<<endl;
ofs_fit_result<<"win 2"<<endl;
ofs_fit_result<<"yplot 3 4"<<endl;
ofs_fit_result<<"loc 0 0 1 1"<<endl;
ofs_fit_result<<"vie .1 .1 .9 .4"<<endl;
ofs_fit_result<<"la x radius (kpc)"<<endl;
ofs_fit_result<<"la y chi"<<endl;
ofs_fit_result<<"log x"<<endl;
ofs_fit_result<<"log y off"<<endl;
for(;;)
{
//read radius, temperature and error
double r,re,m,me;
ifs>>r>>re>>m>>me;
if(!ifs.good())
{
break;
}
if(r<rmin_kpc)
{
continue;
}
data<double,double> d(r,m,me,me,re,re);
ofs_fit_result<<r<<"\t"<<re<<"\t"<<m<<"\t"<<me<<endl;
ds.add_data(d);
}
ofs_fit_result<<"no no no"<<endl;
//load data
fit.load_data(ds);
//define the optimization method
fit.set_opt_method(powell_method<double,vector<double> >());
//use chi^2 statistic
fit.set_statistic(chisq<double,double,vector<double>,double,std::string>());
fit.set_model(nfw<double>());
//fit.set_param_value("rs",4);
//fit.set_param_value("rho0",100);
fit.fit();
fit.fit();
vector<double> p=fit.fit();
//output parameters
ofstream ofs_param("nfw_param.txt");
for(size_t i=0;i<fit.get_num_params();++i)
{
cout<<fit.get_param_info(i).get_name()<<"\t"<<fit.get_param_info(i).get_value()<<endl;
ofs_param<<fit.get_param_info(i).get_name()<<"\t"<<fit.get_param_info(i).get_value()<<endl;
}
cout<<"reduced chi^2="<<fit.get_statistic_value()<<endl;
ofs_param<<"reduced chi^2="<<fit.get_statistic_value()<<endl;
ofstream ofs_model("nfw_dump.qdp");
ofstream ofs_overdensity("overdensity.qdp");
//const double G=6.673E-8;//cm^3 g^-1 s^-2
//static const double mu=1.4074;
//static const double mp=1.67262158E-24;//g
static const double M_sun=1.98892E33;//g
//static const double k=1.38E-16;
double xmax=0;
for(double x=std::max(rmin_kpc,ds.get_data(0).get_x());;x+=1)
{
double model_value=fit.eval_model(x,p);
ofs_model<<x<<"\t"<<model_value<<endl;
ofs_fit_result<<x<<"\t0\t"<<model_value<<"\t0"<<endl;
double V=4./3.*pi*pow(x*kpc,3);
double m=model_value*M_sun;
double rho=m/V;//g/cm^3
double over_density=rho/calc_critical_density(z);
ofs_overdensity<<x<<"\t"<<over_density<<endl;
xmax=x;
if(over_density<100)
{
break;
}
}
ofs_fit_result<<"no no no"<<endl;
for(size_t i=0;i<ds.size();++i)
{
data<double,double> d=ds.get_data(i);
double x=d.get_x();
double y=d.get_y();
double ye=d.get_y_lower_err();
double ym=fit.eval_model(x,p);
ofs_fit_result<<x<<"\t"<<0<<"\t"<<(y-ym)/ye<<"\t"<<1<<endl;
}
ofs_fit_result<<"no no no"<<endl;
for(double x=std::max(rmin_kpc,ds.get_data(0).get_x());x<xmax;x+=1)
{
ofs_fit_result<<x<<"\t"<<0<<"\t"<<0<<"\t"<<0<<endl;
}
}
| 28.6625
| 101
| 0.635194
|
sjtuzyk
|
fae829b646f33987f6861dfb4ed9ba638c78fc09
| 6,365
|
cpp
|
C++
|
core/src/cubos/core/data/yaml_deserializer.cpp
|
GameDevTecnico/cubos
|
51f89c9f3afc8afe502d167dadecab7dfe5b1c7b
|
[
"MIT"
] | 2
|
2021-09-28T14:13:27.000Z
|
2022-03-26T11:36:48.000Z
|
core/src/cubos/core/data/yaml_deserializer.cpp
|
GameDevTecnico/cubos
|
51f89c9f3afc8afe502d167dadecab7dfe5b1c7b
|
[
"MIT"
] | 72
|
2021-09-29T08:55:26.000Z
|
2022-03-29T21:21:00.000Z
|
core/src/cubos/core/data/yaml_deserializer.cpp
|
GameDevTecnico/cubos
|
51f89c9f3afc8afe502d167dadecab7dfe5b1c7b
|
[
"MIT"
] | null | null | null |
#include <cubos/core/data/yaml_deserializer.hpp>
using namespace cubos::core::data;
YAMLDeserializer::YAMLDeserializer(memory::Stream& stream) : Deserializer(stream)
{
this->loadDocument();
this->frame.push({Mode::Object, this->document.begin(), false});
}
#define READ_PRIMITIVE(T, value) \
do \
{ \
auto iter = this->get(); \
if (this->frame.top().mode == Mode::Dictionary) \
{ \
if (this->frame.top().key) \
value = iter->first.as<T>(T()); \
else \
value = iter->second.as<T>(T()); \
this->frame.top().key = !this->frame.top().key; \
} \
else if (this->frame.top().mode == Mode::Object) \
value = iter->second.as<T>(T()); \
else \
value = iter->as<T>(T()); \
} while (false)
void YAMLDeserializer::readI8(int8_t& value)
{
int16_t v;
READ_PRIMITIVE(int16_t, v);
if (v < INT8_MIN || v > INT8_MAX)
value = 0;
else
value = v;
}
void YAMLDeserializer::readI16(int16_t& value)
{
READ_PRIMITIVE(int16_t, value);
}
void YAMLDeserializer::readI32(int32_t& value)
{
READ_PRIMITIVE(int32_t, value);
}
void YAMLDeserializer::readI64(int64_t& value)
{
READ_PRIMITIVE(int64_t, value);
}
void YAMLDeserializer::readU8(uint8_t& value)
{
uint16_t v;
READ_PRIMITIVE(uint16_t, v);
if (v > UINT8_MAX)
value = 0;
else
value = v;
}
void YAMLDeserializer::readU16(uint16_t& value)
{
READ_PRIMITIVE(uint16_t, value);
}
void YAMLDeserializer::readU32(uint32_t& value)
{
READ_PRIMITIVE(uint32_t, value);
}
void YAMLDeserializer::readU64(uint64_t& value)
{
READ_PRIMITIVE(uint64_t, value);
}
void YAMLDeserializer::readF32(float& value)
{
READ_PRIMITIVE(float, value);
}
void YAMLDeserializer::readF64(double& value)
{
READ_PRIMITIVE(double, value);
}
void YAMLDeserializer::readBool(bool& value)
{
READ_PRIMITIVE(bool, value);
}
void YAMLDeserializer::readString(std::string& value)
{
READ_PRIMITIVE(std::string, value);
}
void YAMLDeserializer::beginObject()
{
auto iter = this->get();
if (this->frame.top().mode == Mode::Array)
{
assert(iter->IsMap());
this->frame.push({Mode::Object, iter->begin(), false});
}
else
{
// Objects can't be used as keys in dictionaries.
assert(this->frame.top().mode != Mode::Dictionary || !this->frame.top().key);
assert(iter->second.IsMap());
this->frame.push({Mode::Object, iter->second.begin(), false});
}
}
void YAMLDeserializer::endObject()
{
assert(this->frame.size() > 1);
this->frame.pop();
this->frame.top().key = true;
}
size_t YAMLDeserializer::beginArray()
{
auto iter = this->get();
if (this->frame.top().mode == Mode::Array)
{
assert(iter->IsSequence());
this->frame.push({Mode::Array, iter->begin(), false});
return iter->size();
}
else
{
// Arrays can't be used as keys in dictionaries.
assert(this->frame.top().mode != Mode::Dictionary || !this->frame.top().key);
assert(iter->second.IsSequence());
this->frame.push({Mode::Array, iter->second.begin(), false});
return iter->second.size();
}
}
void YAMLDeserializer::endArray()
{
assert(this->frame.size() > 1);
this->frame.pop();
this->frame.top().key = true;
}
size_t YAMLDeserializer::beginDictionary()
{
auto iter = this->get();
if (this->frame.top().mode == Mode::Array)
{
assert(iter->IsMap());
this->frame.push({Mode::Dictionary, iter->begin(), true});
return iter->size();
}
else
{
// Dictionaries can't be used as keys in dictionaries.
assert(this->frame.top().mode != Mode::Dictionary || !this->frame.top().key);
if (iter->second.IsNull())
{
this->frame.push({Mode::Dictionary, iter->second.begin(), true});
return 0;
}
else
{
assert(iter->second.IsMap());
this->frame.push({Mode::Dictionary, iter->second.begin(), true});
return iter->second.size();
}
}
}
void YAMLDeserializer::endDictionary()
{
assert(this->frame.size() > 1);
this->frame.pop();
this->frame.top().key = true;
}
void YAMLDeserializer::loadDocument()
{
std::string content;
this->stream.readUntil(content, "...");
this->document = YAML::Load(content);
}
YAML::const_iterator YAMLDeserializer::get()
{
// If this is the top frame and there aren't more elements to read, read another document.
if (this->frame.size() == 1 && this->frame.top().iter == this->document.end())
{
this->loadDocument();
this->frame.top().iter = this->document.begin();
}
if (this->frame.top().mode != Mode::Dictionary || !this->frame.top().key)
return this->frame.top().iter++;
else
return this->frame.top().iter;
}
| 31.20098
| 120
| 0.462215
|
GameDevTecnico
|
faf21d027e876586b1746651ccc97ca55b23cc10
| 3,232
|
cc
|
C++
|
sparselets/tile_sparselet_resps_sse_hos.cc
|
rksltnl/sparselet-release1
|
bf7977c2b886961c35506184796b04021206b62b
|
[
"BSD-2-Clause"
] | 4
|
2015-03-23T05:55:23.000Z
|
2019-03-05T02:18:39.000Z
|
sparselets/tile_sparselet_resps_sse_hos.cc
|
rksltnl/sparselet-release1
|
bf7977c2b886961c35506184796b04021206b62b
|
[
"BSD-2-Clause"
] | null | null | null |
sparselets/tile_sparselet_resps_sse_hos.cc
|
rksltnl/sparselet-release1
|
bf7977c2b886961c35506184796b04021206b62b
|
[
"BSD-2-Clause"
] | 10
|
2015-03-23T05:55:24.000Z
|
2019-03-05T02:18:51.000Z
|
#include <sys/types.h>
#include "mex.h"
#include <xmmintrin.h>
const int S = 3;
const int NUM_SUB_FILTERS = 4;
/*
* Hyun Oh Song (song@eecs.berkeley.edu)
* Part filter tiling
*/
static inline void do_sum_sse(double *dst, const double *src, const double *src_end) {
while (src != src_end) {
_mm_storeu_pd(dst, _mm_add_pd(_mm_loadu_pd(dst), _mm_loadu_pd(src)));
src += 2;
dst += 2;
}
}
static inline void do_sum(double *dst, const double *src_begin, size_t size) {
if ((size % 2) == 0)
return do_sum_sse(dst, src_begin, src_begin+size);
size_t size2 = (size/2)*2;
do_sum_sse(dst, src_begin, src_begin+size2);
for (size_t i = size2; i < size; i++)
dst[i] += src_begin[i];
}
void tile_sparselets(double* Q_ptr, double* P_ptr, int s_dimy, int s_dimx, int out_dimy, int out_dimx, int i){
// Q_ptr points to head of ith filter response
// P_ptr points to head of temp array for tiled filter response
// 0 | 1
// --+--
// 2 | 3
const int NUM_SUBFILTERS_X = 2;
const int NUM_SUBFILTERS_Y = 2;
for (int dy = 0; dy < NUM_SUBFILTERS_Y; dy++) {
for (int dx = 0; dx < NUM_SUBFILTERS_X; dx++) {
double *dst = P_ptr;
for (int col = dx*S; col < dx*S + out_dimx; col++) {
double *col_ptr = Q_ptr + col*s_dimy + dy*S;
#if 1
// SSE version
do_sum(dst, col_ptr, out_dimy);
dst += out_dimy;
#else
// Non-SSE version
double *col_end = col_ptr + out_dimy;
while (col_ptr != col_end)
*(dst++) += *(col_ptr++);
#endif
}
Q_ptr += (s_dimy * s_dimx); // Point Q_ptr to next sub-filter
}
}
}
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
if (nrhs != 6)
mexErrMsgTxt("Wrong number of inputs");
if (nlhs != 1)
mexErrMsgTxt("Wrong number of outputs");
if (mxGetClassID(prhs[0]) != mxDOUBLE_CLASS)
mexErrMsgTxt("Invalid input");
const int* Q_dims = mxGetDimensions( prhs[0]);
double* Q_ptr = (double*)mxGetPr(prhs[0]);
int s_dimy = mxGetScalar(prhs[1]);
int s_dimx = mxGetScalar(prhs[2]);
int out_dimy = mxGetScalar(prhs[3]);
int out_dimx = mxGetScalar(prhs[4]);
int num_sub_filters_roots = mxGetScalar(prhs[5]);
// Cell array of tiled filter response
const int num_filters = (Q_dims[1] - num_sub_filters_roots) / NUM_SUB_FILTERS;
mxArray *cell_array_ptr = mxCreateCellArray(1, &num_filters);
int numel_ith_filter = Q_dims[0] * NUM_SUB_FILTERS;
// Offset the Q pointer to where part filter begins (after roots)
Q_ptr += Q_dims[0] * num_sub_filters_roots;
// Temp array to hold tiled filter response
const int P_dims[2] = {out_dimy, out_dimx};
mxArray* mxP = mxCreateNumericArray(2, P_dims, mxDOUBLE_CLASS, mxREAL);
double* P_ptr_init = (double*)mxGetPr(mxP);
double* P_ptr = P_ptr_init;
for (int i=0; i < num_filters; i++){
tile_sparselets(Q_ptr, P_ptr, s_dimy, s_dimx, out_dimy, out_dimx, i);
P_ptr = P_ptr_init; // point back to origin
mxSetCell(cell_array_ptr, i, mxDuplicateArray(mxP));
Q_ptr += numel_ith_filter;
}
plhs[0] = cell_array_ptr;
}
| 30.490566
| 110
| 0.625
|
rksltnl
|
faf383ac145713f5dcfd96f09c5a453b058f5fff
| 15,661
|
cpp
|
C++
|
slyedit/src/main.cpp
|
Gibbeon/sly
|
9216cf04a78f1d41af01186489ba6680b9641229
|
[
"MIT"
] | null | null | null |
slyedit/src/main.cpp
|
Gibbeon/sly
|
9216cf04a78f1d41af01186489ba6680b9641229
|
[
"MIT"
] | null | null | null |
slyedit/src/main.cpp
|
Gibbeon/sly
|
9216cf04a78f1d41af01186489ba6680b9641229
|
[
"MIT"
] | null | null | null |
#include "sly.h"
#include "sly/d3d12.h"
#include "sly/engine.h"
#include "sly/scene.h"
//#include "sly/d3d12/gfx/commandlist.h"
#include "sly/io/memorystream.h"
#include "sly/runtime/serialization/json/jsondeserializer.h"
#include "sly/runtime/serialization/json/jsonserializer.h"
#if !_WIN32
// MacOS shader
const char shadersSrc[] = R"""(
#include <metal_stdlib>
using namespace metal;
vertex float4 VSMain(
const device packed_float3* vertexArray [[buffer(0)]],
unsigned int vID[[vertex_id]])
{
return float4(vertexArray[vID], 1.0);
}
fragment half4 PSMain()
{
return half4(1.0, 0.0, 0.0, 1.0);
}
)""";
#else
const char shadersSrc[] = R"""(
struct PSInput
{
float4 position : SV_POSITION;
float4 color : COLOR;
};
PSInput VSMain(float4 position : POSITION, float4 color : COLOR)
{
PSInput result;
result.position = position;
result.color = color;
return result;
}
float4 PSMain(PSInput input) : SV_TARGET
{
return input.color;
}
)""";
#endif
struct Vec3 {
float x, y, z;
};
struct Vertex {
Vec3 position;
sly::gfx::color_t color;
};
void configureRenderInterfaces(const sly::Engine& engine) {
#ifdef _WIN32
engine.kernel().graphics().interfaces().push_back(
sly::d3d12::gfx::GetRenderInterface());
#else
engine.kernel().gfx().interfaces().push_back(
sly::gfx::METAL::GetRenderInterface());
#endif
}
#ifdef _WIN32
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR pszArgs, int nCmdShow)
#else
int main()
#endif
{
sly::Engine* engine = &sly::Engine();
// load configuration, plugins, etc
Ensures(engine->init().succeeded());
configureRenderInterfaces(*engine);
// get the first interface
auto gfxapi = engine->kernel().graphics().interfaces().at(0);
auto window =
engine->kernel().windows().create(sly::os::WindowBuilder()
.setHeight(768)
.setWidth(1024)
.setTitle("Hi!")
.build()); // window desc
auto device = gfxapi->createDevice(); // device desc
auto context = device->createRenderContext(*window.result());
window->setVisible(true);
engine->activator().add<sly::Entity>();
engine->resources().mount("slyedit/data");
std::shared_ptr<sly::Scene> scene;
auto value = engine->resources().find("scene")->create<sly::Scene>();
scene = value.result();
while (true) {
// engine->begin();
engine->update();
scene->update();
scene->draw(context);
window->processMessages();
context->present();
// engine->draw();
// engine->present();
// engine->end();
}
// scene->release();
/*auto list = device->createCommandList();
auto vsshader = device->createShader(
sly::gfx::ShaderBuilder()
.setData((vptr_t)shadersSrc, sizeof(shadersSrc))
.setEntryPoint("VSMain")
.setTarget("vs_5_0")
.build()
);
auto psshader = device->createShader(
sly::gfx::ShaderBuilder()
.setData((vptr_t)shadersSrc, sizeof(shadersSrc))
.setEntryPoint("PSMain")
.setTarget("ps_5_0")
.build()
);
auto pVertexData = engine->kernel().filesystem().open("vertex.dat");
size_t vtxsize = pVertexData->stream()->size();
std::unique_ptr<Vertex[]> triangleVertices =
std::make_unique<Vertex[]>(vtxsize/sizeof(Vertex));
pVertexData->stream()->read(triangleVertices.get(), vtxsize);
pVertexData->close();
auto vertexBuffer = device->createVertexBuffer(
sly::gfx::VertexBufferBuilder()
.setData(triangleVertices.get(), vtxsize / sizeof(Vertex),
sizeof(Vertex)) .build()
);
auto rsState = device->createRenderState(
sly::gfx::RenderStateBuilder()
.setVSShader(vsshader)
//renderPipelineDesc.SetVertexFunction(vertFunc); .setPSShader(psshader)
//renderPipelineDesc.SetFragmentFunction(fragFunc);
.setPrimitiveType(sly::gfx::ePrimitiveType_Triangle)
.setRTVFormats(0, sly::gfx::eDataFormat_R8G8B8A8_UNORM)
//renderPipelineDesc.GetColorAttachments()[0].SetPixelFormat(mtlpp::PixelFormat::BGRA8Unorm);
.addInputElementDesriptor(
sly::gfx::InputElementBuilder()
.setSemanticName("POSITION")
.setFormat(sly::gfx::eDataFormat_R32G32B32_FLOAT)
.build()
)
.addInputElementDesriptor(
sly::gfx::InputElementBuilder()
.setSemanticName("COLOR")
.setFormat(sly::gfx::eDataFormat_R32G32B32A32_FLOAT)
.setOffset(12)
.build()
)
.build()
);
sly::gfx::Viewport viewport(0, 0, 1024, 768);
sly::rect_t<> scissorRect(0, 0, 1024, 768);
sly::gfx::color_t clearColor(.4f, .4f, .4f, 0.5f);
std::vector<sly::gfx::ICommandList*> lists;
lists.push_back(list);
while(true) {
//scene->update();
//list->begin();
//list->setRenderState(rsState);
//list->setRenderTarget(context->getDrawBuffer());
//list->clear(clearColor);
//list->setViewport(viewport);
//list->setScissorRect(scissorRect);
//list->setVertexBuffer(vertexBuffer);
//list->draw(3, 1, 0, 0);
//list->end();
context->update();
context->commandQueue().executeCommandLists(lists);
context->commandQueue().flush();
context->present();
}
*/
// rsState->release();
// psshader->release();
// vsshader->release();
// list->release();
context->release();
device->release();
window->release();
engine->release();
return 0;
#ifdef NO
engine->filesystem().mount("/data");
sly::Scene* scene = &sly::Scene(engine, context);
scene->load("scene");
sly::Stopwatch stopwatch(true);
while (true) {
delta = stopwatch.reset();
scene->update(delta);
context->draw();
context->present();
}
stopwatch.stop();
scene->release();
engine->filesystem().unmount("/data");
device->release();
window->release();
gfxapi->release();
engine->release();
// create a device context, this managers resources for the render system
auto renderDevice =
engine.graphics().createDevice(sly::gfx::DeviceBuilder().build());
if (renderDevice.failed()) {
return renderDevice.statusCode();
}
sly::gfx::IRenderContext* context = nullptr;
renderDevice->createRenderContext(&context,
sly::gfx::RenderContextBuilder().build());
// create 1 or more windows
// renderDevice->setRender(&window, winBuilder.build());
// create a command list to draw an object
sly::gfx::ICommandList* list = nullptr;
renderDevice->createCommandList(&list,
sly::gfx::CommandListBuilder().build());
sly::gfx::ShaderBuilder psspBuilder;
sly::gfx::ShaderBuilder vsspBuilder;
sly::gfx::VertexBufferBuilder vbBuilder;
sly::gfx::InputElementBuilder posBuilder1;
posBuilder1.setSemanticName("POSITION")
.setFormat(sly::gfx::eDataFormat_R32G32B32_FLOAT)
.setInputScope(sly::gfx::eDataInputClassification_PerVertex);
sly::gfx::InputElementBuilder posBuilder2;
posBuilder2.setSemanticName("COLOR")
.setFormat(sly::gfx::eDataFormat_R32G32B32A32_FLOAT)
.setInputScope(sly::gfx::eDataInputClassification_PerVertex)
.setOffset(12);
Vertex* triangleVertices = nullptr;
auto pVertexData = engine.filesystem().open("vertex.dat");
if (pVertexData.failed()) {
throw;
}
size_t vtxsize = pVertexData->stream()->getSize();
triangleVertices = (Vertex*)malloc(vtxsize);
pVertexData->stream()->read(triangleVertices, vtxsize);
// pVertexData->close();
vbBuilder.setData(triangleVertices, vtxsize / sizeof(Vertex),
sizeof(Vertex));
vsspBuilder.setData((vptr_t)shadersSrc, sizeof(shadersSrc))
.setEntryPoint("VSMain")
.setName("shaders")
.setTarget("vs_5_0");
psspBuilder.setData((vptr_t)shadersSrc, sizeof(shadersSrc))
.setEntryPoint("PSMain")
.setName("shaders")
.setTarget("ps_5_0");
sly::gfx::IVertexBuffer* vertexBuffer = nullptr;
renderDevice->createVertexBuffer(&vertexBuffer, vbBuilder.build());
sly::gfx::IShader* psshader = nullptr;
sly::gfx::IShader* vsshader = nullptr;
renderDevice->createShader(&vsshader, vsspBuilder.build());
renderDevice->createShader(&psshader, psspBuilder.build());
// render state
sly::gfx::RenderStateBuilder rstBuilder;
rstBuilder
.setVSShader(
*vsshader) // renderPipelineDesc.SetVertexFunction(vertFunc);
.setPSShader(
*psshader) // renderPipelineDesc.SetFragmentFunction(fragFunc);
.setSampleMax(UINT_MAX)
.setPrimitiveType(sly::gfx::ePrimitiveType_Triangle)
.setNumberRenderTargets(1)
.setRTVFormats(
0,
sly::gfx::
eDataFormat_R8G8B8A8_UNORM) // renderPipelineDesc.GetColorAttachments()[0].SetPixelFormat(mtlpp::PixelFormat::BGRA8Unorm);
.setSampleDesc(1)
.addInputElementDesriptor(posBuilder1.build())
.addInputElementDesriptor(posBuilder2.build());
// render state
// mtlpp::RenderPipelineDescriptor renderPipelineDesc;
sly::gfx::IRenderState* rsState = nullptr;
renderDevice->createRenderState(
&rsState,
rstBuilder
.build()); // g_renderPipelineState =
// g_device.NewRenderPipelineState(renderPipelineDesc,
// nullptr);
// mtlpp::CommandBuffer commandBuffer = g_commandQueue.CommandBuffer(); //
// to get list loop list->begin(); // mtlpp::RenderCommandEncoder
// renderCommandEncoder =
// commandBuffer.RenderCommandEncoder(renderPassDesc);
// list->setRenderState(*rsState); //
// renderCommandEncoder.SetRenderPipelineState(g_renderPipelineState);
// list->setRenderTarget(context->getDrawBuffer());
// list->setViewport(viewport);
// list->setScissorRect(scissorRect);
// list->clear(clearColor);
// list->setVertexBuffer(*vertexBuffer); //
// renderCommandEncoder.SetVertexBuffer(g_vertexBuffer, 0, 0); list->draw(3,
// 1, 0, 0); // renderCommandEncoder.Draw(mtlpp::PrimitiveType::Triangle,
// 0, 3); list->end(); // renderCommandEncoder.EndEncoding();
// context->processMessages();
// context->getDirectCommandQueue().executeCommandList(list); //
// commandBuffer.Present(m_view.GetDrawable());
// context->getDirectCommandQueue().flush(); //commandBuffer.Commit();
// context->swapBuffers();
// commandBuffer.WaitUntilCompleted();
// state
sly::gfx::Viewport viewport(0, 0, 1024, 768);
sly::rect_t scissorRect(0, 0, 1024, 768);
sly::gfx::color_t clearColor(.4f, .4f, .4f, 1.0f);
while (true) {
#if _WIN32
// loop
list->begin();
list->setRenderState(*rsState);
list->setRenderTarget(context->getDrawBuffer());
list->setViewport(viewport);
list->setScissorRect(scissorRect);
list->clear(clearColor);
list->setVertexBuffer(*vertexBuffer);
list->draw(3, 1, 0, 0);
list->end();
context->processMessages();
context->getDirectCommandQueue().executeCommandList(list);
context->getDirectCommandQueue().flush();
context->swapBuffers();
#else // 01 - mtlpp::CommandBuffer commandBuffer = \
// g_commandQueue.CommandBuffer(); \
// loop //02 - \
// mtlpp::RenderPassDescriptor renderPassDesc = \
// m_view.GetRenderPassDescriptor(); \
// list->begin(); //03 - mtlpp::RenderCommandEncoder renderCommandEncoder = \
// commandBuffer.RenderCommandEncoder(renderPassDesc); \
// list->setRenderState(*rsState); //04 - \
// renderCommandEncoder.SetRenderPipelineState(g_renderPipelineState); \
// list->setRenderTarget(context->getDrawBuffer()); //08 - \
// commandBuffer.Present(m_view.GetDrawable()); \
// list->setVertexBuffer(*vertexBuffer); //05 - \
// renderCommandEncoder.SetVertexBuffer(g_vertexBuffer, 0, 0); \
// list->draw(3, 1, 0, 0); //06 - \
// renderCommandEncoder.Draw(mtlpp::PrimitiveType::Triangle, 0, 3);
// list->end(); //07 - renderCommandEncoder.EndEncoding();
// 09 - commandBuffer.Commit();
context->processMessages();
// context->getDirectCommandQueue().executeCommandList(list);
// context->getDirectCommandQueue().flush(); //09 -
// commandBuffer.Commit();
context->swapBuffers(); // 10 - commandBuffer.WaitUntilCompleted();
#endif
}
return 0;
#define TEST_ASSETREADER 1
#if !TEST_ASSETREADER
#else
sly::IInputStream* pShaderJson;
sly::Engine::OS().FileSystem().open(&pShaderJson, "shaders.json");
sly::TextReader reader(*pShaderJson);
auto j3 = json::parse((const char_t*)reader.readAll());
sly::IInputStream* pShaderFile;
sly::Engine::OS().FileSystem().open(
&pShaderFile, j3[0]["file"].get<std::string>().c_str());
size_t vssize = pShaderFile->getSize();
char* vsbuf = (char*)malloc(vssize);
pShaderFile->read(vsbuf, vssize);
vsspBuilder.setData(vsbuf, vssize)
.setEntryPoint(j3[0]["entryPoint"].get<std::string>().c_str())
.setName(j3[0]["name"].get<std::string>().c_str())
.setTarget(j3[0]["target"].get<std::string>().c_str());
psspBuilder.setData(vsbuf, vssize)
.setEntryPoint(j3[1]["entryPoint"].get<std::string>().c_str())
.setName(j3[1]["name"].get<std::string>().c_str())
.setTarget(j3[1]["target"].get<std::string>().c_str());
/*sly::TypeActivator activator;
sly::IInputStream* pVertexData;
sly::Engine::OS().FileSystem().open(&pVertexData, "vertex.json");
sly::JSONDeserializer vbReader(pVertexData, activator);
sly::gfx::VertexBufferDesc vbDesc =
vbReader.read<sly::gfx::VertexBufferDesc>(); pVertexData->close();
vbBuilder.init(vbDesc);
sly::IInputStream* pShaderData;
sly::Engine::OS().FileSystem().open(&pShaderData, "shaders.json");
sly::JSONDeserializer shaderReader(pShaderData, activator);
sly::gfx::ShaderBuilder vsspDesc =
shaderReader.read<sly::gfx::ShaderBuilder>(); sly::gfx::ShaderBuilder psspDesc
= shaderReader.read<sly::gfx::ShaderBuilder>(); pShaderData->close();
psspBuilder.init(psspDesc);
vsspBuilder.init(vsspDesc);*/
#endif
while (true) {
// loop
list->begin();
list->setRenderState(*rsState);
list->setRenderTarget(context->getDrawBuffer());
list->setViewport(viewport);
list->setScissorRect(scissorRect);
list->clear(clearColor);
list->setVertexBuffer(*vertexBuffer);
list->draw(3, 1, 0, 0);
list->end();
context->processMessages();
context->getDirectCommandQueue().executeCommandList(list);
context->getDirectCommandQueue().flush();
context->swapBuffers();
}
return 0;
#endif
}
| 32.092213
| 138
| 0.616627
|
Gibbeon
|
faf7f48d652d6bf1a536d50b2b6d9cfd801a8b60
| 1,794
|
cpp
|
C++
|
Practice/2018/2018.6.13/POJ1568.cpp
|
SYCstudio/OI
|
6e9bfc17dbd4b43467af9b19aa2aed41e28972fa
|
[
"MIT"
] | 4
|
2017-10-31T14:25:18.000Z
|
2018-06-10T16:10:17.000Z
|
Practice/2018/2018.6.13/POJ1568.cpp
|
SYCstudio/OI
|
6e9bfc17dbd4b43467af9b19aa2aed41e28972fa
|
[
"MIT"
] | null | null | null |
Practice/2018/2018.6.13/POJ1568.cpp
|
SYCstudio/OI
|
6e9bfc17dbd4b43467af9b19aa2aed41e28972fa
|
[
"MIT"
] | null | null | null |
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define mem(Arr,x) memset(Arr,x,sizeof(Arr))
const int maxN=5;
const int inf=2147483647;
int mcnt,Win[11];
int Map[4][4];
int dfs(int k1,int k2,int opt);
int check(int key);
int main()
{
char opt;
for (int cnt=0,i=0;i<4;i++)
for (int j=0;j<4;j++)
Map[i][j]=(1<<(cnt++));
mcnt=-1;
for (int i=0;i<=3;i++) Win[++mcnt]=Map[i][0]|Map[i][1]|Map[i][2]|Map[i][3],Win[++mcnt]=Map[0][i]|Map[1][i]|Map[2][i]|Map[3][i];
Win[++mcnt]=Map[0][0]|Map[1][1]|Map[2][2]|Map[3][3];
Win[++mcnt]=Map[0][3]|Map[1][2]|Map[2][1]|Map[3][0];
while (cin>>opt)
{
if (opt=='$') break;
int key1=0,key2=0;
char mp[5];
int cnt=0;
for (int i=0;i<=3;i++)
{
cin>>mp;
for (int j=0;j<=3;j++)
if (mp[j]=='x') key1|=Map[i][j],cnt++;
else if (mp[j]=='o') key2|=Map[i][j],cnt++;
}
if (cnt<=4)
{
printf("#####\n");
continue;
}
bool flag=0;
for (int i=0;i<=15;i++)
if (((key1&(1<<i))==0)&&((key2&(1<<i))==0))
if (dfs(key1|(1<<i),key2,1)==1){
printf("(%d,%d)\n",i/4,i%4);flag=1;break;
}
if (flag==0) printf("#####\n");
}
return 0;
}
int dfs(int k1,int k2,int opt)
{
if ((opt==1)&&(check(k1)==1)) return 1;
if ((opt==0)&&(check(k2)==1)) return -1;
if ((k1|k2)==(1<<16)-1) return 0;
//cout<<"dfs:"<<k1<<" "<<k2<<" "<<opt<<endl;
for (int i=0;i<=15;i++)
if ( ((k1&(1<<i))==0) && ((k2&(1<<i))==0) )
{
if (opt==0)
if (dfs(k1|(1<<i),k2,opt^1)==1) return 1;
if (opt==1)
{
int ret=dfs(k1,k2|(1<<i),opt^1);
if ((ret==-1)||(ret==0)) return -1;
}
}
if (opt==0) return -1;
if (opt==1) return 1;
}
int check(int key)
{
for (int i=0;i<=mcnt;i++)
if ((key&Win[i])==Win[i]) return 1;
return 0;
}
| 20.62069
| 128
| 0.506689
|
SYCstudio
|
fafd3b66b9deceb94bc9b26a7e498f09b611c710
| 447
|
cpp
|
C++
|
cppcode/cpp execise/day08/polycond.cpp
|
jiedou/study
|
606676ebc3d1fb1a87de26b6609307d71dafec22
|
[
"Apache-2.0"
] | null | null | null |
cppcode/cpp execise/day08/polycond.cpp
|
jiedou/study
|
606676ebc3d1fb1a87de26b6609307d71dafec22
|
[
"Apache-2.0"
] | null | null | null |
cppcode/cpp execise/day08/polycond.cpp
|
jiedou/study
|
606676ebc3d1fb1a87de26b6609307d71dafec22
|
[
"Apache-2.0"
] | null | null | null |
#include <iostream>
using namespace std;
class A {
public:
A (void) {
foo (); // this->foo ();
}
~A (void) {
foo (); // this->foo ();
}
virtual void foo (void) {
cout << "A::foo(void)" << endl;
}
void bar (void) {
foo (); // this->foo ();
}
};
class B : public A {
public:
void foo (void) {
cout << "B::foo(void)" << endl;
}
};
int main (void) {
B b;
/*
A a = b;
a.foo ();
A& r = b;
r.foo ();
b.bar ();
*/
return 0;
}
| 12.771429
| 33
| 0.47651
|
jiedou
|
4f0177135e5ddd67ef2580a8c0183714d0763353
| 1,737
|
cpp
|
C++
|
CreateStruct/CreateStruct.cpp
|
100dlswjd/test
|
5cada91ebc5154017ece501e581b2106c72a6e4e
|
[
"MIT"
] | 1
|
2022-01-25T10:43:28.000Z
|
2022-01-25T10:43:28.000Z
|
CreateStruct/CreateStruct.cpp
|
100dlswjd/test
|
5cada91ebc5154017ece501e581b2106c72a6e4e
|
[
"MIT"
] | 1
|
2021-07-14T01:23:54.000Z
|
2021-07-14T11:26:06.000Z
|
CreateStruct/CreateStruct.cpp
|
100dlswjd/test
|
5cada91ebc5154017ece501e581b2106c72a6e4e
|
[
"MIT"
] | 1
|
2021-07-12T16:37:14.000Z
|
2021-07-12T16:37:14.000Z
|
#include<windows.h>
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
HINSTANCE g_hInst;
HWND hWndMain;
LPCTSTR lpszClass = TEXT("CreateStruct");
struct tag_Param {
int x;
int y;
TCHAR mes[128];
};
tag_Param Param = { 100,100,TEXT("Create Parameter") };
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdParam, int nCmdShow) {
HWND hWnd;
MSG Message;
WNDCLASS WndClass;
g_hInst = hInstance;
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
WndClass.hbrBackground = (HBRUSH)GetStockObject(COLOR_WINDOW + 1);
WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WndClass.hInstance = hInstance;
WndClass.lpfnWndProc = WndProc;
WndClass.lpszClassName = lpszClass;
WndClass.lpszMenuName = NULL;
WndClass.style = CS_HREDRAW | CS_VREDRAW;
RegisterClass(&WndClass);
hWnd = CreateWindow(lpszClass, lpszClass, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, (HMENU)NULL, hInstance, NULL);
ShowWindow(hWnd, nCmdShow);
while (GetMessage(&Message, NULL, 0, 0)) {
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return (int)Message.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) {
HDC hdc;
PAINTSTRUCT ps;
CREATESTRUCT cs;
static tag_Param WndParam;
switch (iMessage) {
cs = *(LPCREATESTRUCT)lParam;
WndParam = *((tag_Param*)(cs.lpCreateParams));
return 0;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
TextOut(hdc, WndParam.x, WndParam.y, WndParam.mes, lstrlen(WndParam.mes));
EndPaint(hWnd, &ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return(DefWindowProc(hWnd, iMessage, wParam, lParam));
}
| 25.544118
| 160
| 0.743235
|
100dlswjd
|
4f01cee9cf6141458ffc1d75a0393c42fbb0d752
| 2,466
|
cpp
|
C++
|
Jni/Main.cpp
|
Cos8o/DroidNong
|
40d5bcb580c20293c50a434f1095340c5c37995b
|
[
"MIT"
] | 1
|
2021-01-15T11:26:02.000Z
|
2021-01-15T11:26:02.000Z
|
Jni/Main.cpp
|
Cos8o/DroidNong
|
40d5bcb580c20293c50a434f1095340c5c37995b
|
[
"MIT"
] | 1
|
2021-01-04T17:01:26.000Z
|
2021-01-04T17:01:26.000Z
|
Jni/Main.cpp
|
Cos8o/DroidNong
|
40d5bcb580c20293c50a434f1095340c5c37995b
|
[
"MIT"
] | 2
|
2020-08-01T03:38:18.000Z
|
2020-10-25T14:53:01.000Z
|
#include <jni.h>
#include <dirent.h>
#include <vector>
#include <string>
#include <algorithm>
#include <fstream>
#include <sstream>
static std::string const LOCAL_PATH("/sdcard/nong");
static std::string const GAME_PATH("/data/data/com.cos8oxx.geometrynong/files");
bool copyFile(
std::string const& srcPath,
std::string const& dstPath)
{
std::ifstream src(srcPath, std::ios::binary);
std::ofstream dst(dstPath, std::ios::binary);
dst << src.rdbuf();
return src && dst;
}
void removeFile(std::string const& path)
{
system(("rm " + path).c_str());
}
inline std::string getStem(std::string const& path)
{
std::string filename;
auto pos = path.rfind('.');
if (pos != std::string::npos)
filename = path.substr(0, pos);
return filename;
}
inline bool isMp3(std::string const& path)
{
std::string s;
std::stringstream ss(path);
while (std::getline(ss, s, '.'));
return s == "mp3";
}
inline bool validNong(std::string const& path)
{
if (isMp3(path))
{
auto const filename = getStem(path);
return std::find_if(
filename.begin(),
filename.end(),
[](char c)
{
return !std::isdigit(c);
}) == filename.end();
}
return false;
}
std::vector<std::string> getNongs()
{
std::vector<std::string> nongList;
auto dir = opendir(LOCAL_PATH.c_str());
if (dir)
{
auto info = readdir(dir);
while (info)
{
if (validNong(info->d_name))
nongList.push_back(info->d_name);
info = readdir(dir);
}
}
closedir(dir);
return nongList;
}
JNIEXPORT jint JNI_OnLoad(JavaVM*, void*)
{
std::ofstream log(LOCAL_PATH + "/log.txt");
auto nongList = getNongs();
if (nongList.size())
{
uint32_t nongCounter = 0;
for (auto const& path : nongList)
{
if (copyFile(
LOCAL_PATH + '/' + path,
GAME_PATH + '/' + path))
{
++nongCounter;
}
else
{
log << "Failed to copy nong \"" << path << "\"\n";
}
removeFile(LOCAL_PATH + '/' + path);
}
log << nongCounter << (nongCounter == 1 ? " nong " : " nongs ") << "copied.";
}
else
{
log << "No nongs found.";
}
return JNI_VERSION_1_4;
}
| 19.417323
| 85
| 0.523925
|
Cos8o
|
4f08d2975084b75570b155e52fcb43e15b6ecf01
| 12,124
|
c++
|
C++
|
src/extern/inventor/apps/samples/manip/constrainManip.c++
|
OpenXIP/xip-libraries
|
9f0fef66038b20ff0c81c089d7dd0038e3126e40
|
[
"Apache-2.0"
] | 2
|
2020-05-21T07:06:07.000Z
|
2021-06-28T02:14:34.000Z
|
src/extern/inventor/apps/samples/manip/constrainManip.c++
|
OpenXIP/xip-libraries
|
9f0fef66038b20ff0c81c089d7dd0038e3126e40
|
[
"Apache-2.0"
] | null | null | null |
src/extern/inventor/apps/samples/manip/constrainManip.c++
|
OpenXIP/xip-libraries
|
9f0fef66038b20ff0c81c089d7dd0038e3126e40
|
[
"Apache-2.0"
] | 6
|
2016-03-21T19:53:18.000Z
|
2021-06-08T18:06:03.000Z
|
/*
*
* Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* Further, this software is distributed without any warranty that it is
* free of the rightful claim of any third person regarding infringement
* or the like. Any license provided herein, whether implied or
* otherwise, applies only to this software file. Patent licenses, if
* any, provided herein do not apply to combinations of this program with
* other software, or any other product whatsoever.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
* Mountain View, CA 94043, or:
*
* http://www.sgi.com
*
* For further information regarding this notice, see:
*
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
/*----------------------------------------------------------------
*
* Read in a scene. Search for draggers and manipulators,
* adding constraints to them when found.
*
* Display the scene in a viewer.
*----------------------------------------------------------------*/
#include <stdlib.h>
#include <Inventor/SoDB.h>
#include <Inventor/actions/SoSearchAction.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoTransform.h>
#include <Inventor/Xt/SoXt.h>
#include <Inventor/Xt/viewers/SoXtExaminerViewer.h>
#include <Inventor/draggers/SoDragger.h>
#include <Inventor/draggers/SoCenterballDragger.h>
#include <Inventor/manips/SoTransformManip.h>
#include <Inventor/manips/SoCenterballManip.h>
#include <Inventor/nodekits/SoSceneKit.h>
typedef struct MyCBStruct {
SbVec3f translateMin;
SbVec3f translateMax;
SbVec3f scaleMin;
SbVec3f scaleMax;
float rotateMin;
float rotateMax;
float prevAngle;
SbVec3f axis;
SbRotation startRotation;
SoTransformManip *manip;
};
#define CLAMP(v,min,max) v = (v < min) ? min : ((v > max) ? max : v)
// Limits translation between translateMin and translateMax
void
limitTranslation( SoSFVec3f *translation, MyCBStruct *stuff )
{
SbVec3f xl = translation->getValue();
CLAMP( xl[0], stuff->translateMin[0], stuff->translateMax[0] );
CLAMP( xl[1], stuff->translateMin[1], stuff->translateMax[1] );
CLAMP( xl[2], stuff->translateMin[2], stuff->translateMax[2] );
if ( xl != translation->getValue() )
(*translation) = xl;
}
// Limits center between translateMin and translateMax
void
limitCenter( SoSFVec3f *center, MyCBStruct *stuff )
{
SbVec3f xl = center->getValue();
CLAMP( xl[0], stuff->translateMin[0], stuff->translateMax[0] );
CLAMP( xl[1], stuff->translateMin[1], stuff->translateMax[1] );
CLAMP( xl[2], stuff->translateMin[2], stuff->translateMax[2] );
if ( xl != center->getValue() )
(*center) = xl;
}
// Limits scale between scaleMin and scaleMax
// Also doesn't let scale go below 0.0
void
limitScale( SoSFVec3f *scaleFactor, MyCBStruct *stuff )
{
SbVec3f scl = scaleFactor->getValue();
CLAMP( scl[0], stuff->scaleMin[0], stuff->scaleMax[0] );
CLAMP( scl[1], stuff->scaleMin[1], stuff->scaleMax[1] );
CLAMP( scl[2], stuff->scaleMin[2], stuff->scaleMax[2] );
CLAMP( scl[0], 0, stuff->scaleMax[0] );
CLAMP( scl[1], 0, stuff->scaleMax[1] );
CLAMP( scl[2], 0, stuff->scaleMax[2] );
if ( scl != scaleFactor->getValue() )
(*scaleFactor) = scl;
}
// Constrains the rotation to go around the initial direction of rotation
// until the dragging is complete.
// Limits amount of rotation from starting point to within range
// rotateMin < theta < rotateMax
void
limitRotate( SoSFRotation *rotation, MyCBStruct *stuff )
{
// First, see if we need to determine the axis of rotation.
// We need to do this the first time the dragger rotates, when axis==(0,0,0)
if ( stuff->axis == SbVec3f(0,0,0) ) {
SbRotation increment
= stuff->startRotation.inverse() * rotation->getValue();
increment.getValue( stuff->axis, stuff->prevAngle );
if (stuff->prevAngle == 0.0) {
stuff->axis.setValue(0,0,0);
return;
}
}
// Now we have an axis of rotation.
// Constrain whatever the rotation is to be a rotation about this axis.
SbBool madeAChange = FALSE;
SbRotation rotSinceStart
= stuff->startRotation.inverse() * rotation->getValue();
SbRotation newRotSinceStart;
// First, append a rotation that will undo any wobble of our axis.
SbVec3f wobbledAxis;
rotSinceStart.multVec( stuff->axis, wobbledAxis );
SbRotation undoWobble( wobbledAxis, stuff->axis );
float testAngle;
SbVec3f testAxis;
undoWobble.getValue( testAxis, testAngle );
if (testAngle > .001) {
newRotSinceStart = rotSinceStart * undoWobble;
madeAChange = TRUE;
}
else
newRotSinceStart = rotSinceStart;
// Next, see what the angle of rotation has been.
newRotSinceStart.getValue( testAxis, testAngle );
if ( testAxis.dot( stuff->axis ) < 0.0 )
testAngle *= -1.0;
// Make this angle as close as possible to prevAngle
while ( stuff->prevAngle - testAngle > 2 * M_PI )
testAngle += M_PI;
while ( testAngle - stuff->prevAngle > 2 * M_PI )
testAngle -= M_PI;
float clampAngle = testAngle;
CLAMP( clampAngle, stuff->rotateMin, stuff->rotateMax );
if ( clampAngle != testAngle ) {
newRotSinceStart.setValue( stuff->axis, clampAngle );
madeAChange = TRUE;
}
stuff->prevAngle = clampAngle;
if ( madeAChange ) {
SbRotation newFinalRot = stuff->startRotation * newRotSinceStart;
(*rotation) = newFinalRot;
}
}
// Dragger Start CB
// If there's a rotation field, records the starting rotation.
// Clears out the axis.
void
dragStartCB( void *stuff, SoDragger *dragger )
{
MyCBStruct *myStuff = (MyCBStruct *) stuff;
myStuff->axis.setValue(0,0,0);
myStuff->prevAngle = 0.0;
SoField *rotField = dragger->getField( "rotation" );
if ( rotField != NULL )
myStuff->startRotation = ((SoSFRotation *) rotField)->getValue();
else
myStuff->startRotation = SbRotation::identity();
}
// Manip Value Changed CB
// Tells the dragger to limit each of the parent manip's fields:
// translation, scaleFactor, and rotation.
void
manipValueChangedCB( void *stuff, SoDragger *)
{
MyCBStruct *myStuff = (MyCBStruct *) stuff;
SoTransformManip *m = myStuff->manip;
if ( !m->isOfType( SoCenterballManip::getClassTypeId() ))
limitTranslation( &(m->translation), myStuff );
else
limitCenter( &(m->center), myStuff );
limitScale( &(m->scaleFactor), myStuff );
limitRotate( &(m->rotation), myStuff );
}
// Dragger Value Changed CB
// Limits each of the fields: translation, scaleFactor, and rotation
// if they are present.
void
valueChangedCB( void *stuff, SoDragger *dragger )
{
MyCBStruct *myStuff = (MyCBStruct *) stuff;
SoField *myField;
if ( !dragger->isOfType( SoCenterballDragger::getClassTypeId() )) {
myField = dragger->getField( "translation" );
if ( myField != NULL )
limitTranslation( (SoSFVec3f *)myField, myStuff );
}
else {
myField = dragger->getField( "center" );
if ( myField != NULL )
limitCenter( (SoSFVec3f *)myField, myStuff );
}
myField = dragger->getField( "scaleFactor" );
if ( myField != NULL )
limitScale( (SoSFVec3f *)myField, myStuff );
myField = dragger->getField( "rotation" );
if ( myField != NULL )
limitRotate( (SoSFRotation *)myField, myStuff );
}
void
main(int argc, char **argv)
{
int curArg = 0;
SbBool doConstraints = TRUE;
float translateMin = -3.0;
float translateMax = 3.0;
float scaleMin = 0.0001;
float scaleMax = 3.0;
float rotateMin = -2.0;
float rotateMax = 2.0;
char *fileName = NULL;
// Try to read the command line...
curArg = 1;
while (curArg < argc ) {
if ( !strcmp(argv[curArg], "-noConstraints")) {
curArg++;
doConstraints = FALSE;
}
else if ( !strcmp(argv[curArg], "-translateMin")) {
curArg++;
sscanf( argv[curArg++], "%f", &translateMin );
}
else if ( !strcmp(argv[curArg], "-translateMax")) {
curArg++;
sscanf( argv[curArg++], "%f", &translateMax );
}
else if ( !strcmp(argv[curArg], "-scaleMin")) {
curArg++;
sscanf( argv[curArg++], "%f", &scaleMin );
}
else if ( !strcmp(argv[curArg], "-scaleMax")) {
curArg++;
sscanf( argv[curArg++], "%f", &scaleMax );
}
else {
// get the filename
fileName = argv[curArg++];
}
}
Widget myWindow = SoXt::init(argv[0]);
if (myWindow == NULL) exit(1);
SoSeparator *root = new SoSeparator;
root->ref();
SoInput myInput;
if (fileName == NULL)
fileName = "simpleDraggers.iv";
if ( !myInput.openFile( fileName ) ) {
fprintf(stderr, "ERROR - could not open file %s\n", fileName );
fprintf(stderr, "usage-- constrainManip [-noConstraints] ] [-translateMin x] [-translateMax x] [-scaleMin x] [-scaleMax x] [-rotateMin] [-rotateMax] fileName\n");
fprintf(stderr, " where translateMin, translateMax, scaleMin, scaleMax, rotateMin, and rotateMax are constraints to be put on the draggers and manips.\n");
exit(1);
}
SoSeparator *fileContents = SoDB::readAll( &myInput );
root->addChild(fileContents);
// Search for draggers and add constraints.
SoSearchAction sa;
SoPathList pathList;
int i;
// Set up values for callback.
MyCBStruct *myCBStruct = new MyCBStruct;
myCBStruct->translateMin.setValue( translateMin, translateMin, translateMin);
myCBStruct->translateMax.setValue( translateMax, translateMax, translateMax);
myCBStruct->scaleMin.setValue( scaleMin, scaleMin, scaleMin);
myCBStruct->scaleMax.setValue( scaleMax, scaleMax, scaleMax);
myCBStruct->rotateMin = rotateMin;
myCBStruct->rotateMax = rotateMax;
if (doConstraints) {
// Add callbacks to all draggers that constrain motion:
sa.setType( SoDragger::getClassTypeId() );
sa.setInterest( SoSearchAction::ALL );
sa.apply( root );
pathList = sa.getPaths();
for ( i = 0; i < pathList.getLength(); i++ ) {
SoDragger *d = (SoDragger *) (pathList[i])->getTail();
d->addStartCallback(&dragStartCB, myCBStruct);
d->addValueChangedCallback(&valueChangedCB, myCBStruct);
}
// Add callbacks to all transform manips that constrain motion:
sa.setType( SoTransformManip::getClassTypeId() );
sa.setInterest( SoSearchAction::ALL );
sa.apply( root );
pathList = sa.getPaths();
for ( i = 0; i < pathList.getLength(); i++ ) {
SoTransformManip *m = (SoTransformManip *) (pathList[i])->getTail();
MyCBStruct *cbs = new MyCBStruct;
cbs->translateMin.setValue( translateMin, translateMin, translateMin);
cbs->translateMax.setValue( translateMax, translateMax, translateMax);
cbs->scaleMin.setValue( scaleMin, scaleMin, scaleMin);
cbs->scaleMax.setValue( scaleMax, scaleMax, scaleMax);
cbs->rotateMin = rotateMin;
cbs->rotateMax = rotateMax;
cbs->manip = m;
SoDragger *d = m->getDragger();
d->addStartCallback(&dragStartCB, cbs);
d->addValueChangedCallback(&manipValueChangedCB, cbs);
}
}
SoXtExaminerViewer *myVwr = new SoXtExaminerViewer(myWindow);
myVwr->setSceneGraph(root);
myVwr->setTitle("Manip Test");
myVwr->viewAll();
myVwr->show();
SoXt::show(myWindow);
SoXt::mainLoop();
}
| 33.216438
| 168
| 0.661003
|
OpenXIP
|
4f0bb04a4738f1b7b3ca330886ad4b893655850e
| 4,468
|
cpp
|
C++
|
ProjectGenesis/cloth.cpp
|
ConspiracyHu/2012SourcePack
|
e878e3a2ecece26931ad23416d4f856fd5d33540
|
[
"BSD-2-Clause"
] | 115
|
2015-04-25T14:18:22.000Z
|
2022-03-31T13:12:00.000Z
|
ProjectGenesis/cloth.cpp
|
ConspiracyHu/2012SourcePack
|
e878e3a2ecece26931ad23416d4f856fd5d33540
|
[
"BSD-2-Clause"
] | null | null | null |
ProjectGenesis/cloth.cpp
|
ConspiracyHu/2012SourcePack
|
e878e3a2ecece26931ad23416d4f856fd5d33540
|
[
"BSD-2-Clause"
] | 13
|
2015-10-21T02:17:05.000Z
|
2021-12-01T20:13:52.000Z
|
#include "cloth.h"
struct clothpoint
{
vector3 position;
vector3 speed;
vector3 force;
vector3 normal;
};
clothpoint cloth[15][10];
vector3 Gravity;
vector3 wind;
int xrez=14,yrez=9,mod=8;
void initcloth()
{
Gravity.x=-0.0007f;
Gravity.y=-0.0008f;
Gravity.z=0.0001f;
wind.x=-0.00033f;
wind.y=-0.0001f;
wind.z=-0.00015f;
for (int x=0; x<xrez; x++)
for (int y=0; y<yrez; y++)
{
cloth[x][y].position.x=(float)x;
cloth[x][y].position.y=(float)y;
cloth[x][y].position.z=0;
cloth[x][y].speed.x=0;
cloth[x][y].speed.y=0;
cloth[x][y].speed.z=0;
}
}
void checkspring(int x1,int y1,int x2,int y2,float defaultdistance)
{
if (x1>=0 && x1<xrez && y1>=0 && y1<yrez &&
x2>=0 && x2<xrez && y2>=0 && y2<yrez)
{
float Ks=0.324f;
float Kd=0.04f;
vector3 p1 = cloth[x1][y1].position;
vector3 p2 = cloth[x2][y2].position;
vector3 deltaP=v3_sub(p1,p2);
float dist=v3_len(deltaP);
float Hterm = (dist - defaultdistance) * Ks;
vector3 deltaV = v3_sub(cloth[x1][y1].speed,cloth[x2][y2].speed);
float Dterm = (v3_dot(deltaV,deltaP) * Kd) / dist;
vector3 springForce = v3_normalize(deltaP);
float multiplier=-(Hterm+Dterm);
if (fabs(multiplier)>=0.0001)
{
springForce = v3_mults(springForce,multiplier);
cloth[x1][y1].force=v3_add(cloth[x1][y1].force,springForce);
cloth[x2][y2].force=v3_sub(cloth[x2][y2].force,springForce);
}
}
}
void countnormal(int x1, int y1, int x2, int y2, int x3, int y3)
{
vector3 normal=v3_cross(v3_sub(cloth[x1][y1].position,cloth[x2][y2].position),v3_sub(cloth[x1][y1].position,cloth[x3][y3].position));
vector3 force=v3_mults(v3_normalize(normal),v3_dot(normal,wind));
cloth[x1][y1].force=v3_add(cloth[x1][y1].force,force);
cloth[x2][y2].force=v3_add(cloth[x2][y2].force,force);
cloth[x3][y3].force=v3_add(cloth[x3][y3].force,force);
cloth[x1][y1].normal=v3_add(cloth[x1][y1].normal,normal);
cloth[x2][y2].normal=v3_add(cloth[x2][y2].normal,normal);
cloth[x3][y3].normal=v3_add(cloth[x3][y3].normal,normal);
}
void calculatecloth()
{
int x;
for (x=0; x<xrez; x++)
for (int y=0; y<yrez; y++)
{
memset(&cloth[x][y].normal,0,sizeof(vector3));
if (!(x==xrez-1 && y%mod==0))
{
cloth[x][y].force=Gravity;
cloth[x][y].force=v3_add(cloth[x][y].force,v3_mults(cloth[x][y].speed,-0.002f));
}
}
for (x=0; x<xrez-1; x++)
for (int y=0; y<yrez-1; y++)
{
countnormal(x,y,x+1,y+1,x+1,y);
countnormal(x,y,x,y+1,x+1,y+1);
}
for (x=0; x<xrez; x++)
for (int y=0; y<yrez; y++)
cloth[x][y].normal=v3_normalize(cloth[x][y].normal);
for (x=0; x<xrez; x++)
for (int y=0; y<yrez; y++)
{
checkspring(x,y,x+1,y,1);
checkspring(x,y,x,y+1,1);
if (x%2==0) checkspring(x,y,x+2,y,2);
if (y%2==0) checkspring(x,y,x,y+2,2);
checkspring(x,y,x+1,y+1,(float)sqrt(2.0f));
checkspring(x,y+1,x+1,y,(float)sqrt(2.0f));
}
for (x=0; x<xrez; x++)
for (int y=0; y<yrez; y++)
{
if (!(x==xrez-1 && y%mod==0))
cloth[x][y].speed=v3_add(cloth[x][y].speed,cloth[x][y].force);
else
memset(&cloth[x][y].speed,0,sizeof(vector3));
cloth[x][y].position=v3_add(cloth[x][y].position,cloth[x][y].speed);
}
}
void drawcloth()
{
float color[4];
glBegin(GL_QUADS);
for (int x=0; x<xrez-1; x++)
for (int y=0; y<yrez-1; y++)
{
if (y<=yrez/3)
{
color[0]=0; color[1]=0.6f; color[2]=0; color[3]=0;
}
if (y>=yrez/3 && y<=yrez*2/3)
{
color[0]=1; color[1]=1; color[2]=1; color[3]=0;
}
if (y>=yrez*2/3)
{
color[0]=0.8f; color[1]=0; color[2]=0; color[3]=0;
}
glMaterialfv(GL_FRONT,GL_DIFFUSE,color);
glNormal3f(cloth[x ][y ].normal.x,-cloth[x ][y ].normal.y,cloth[x ][y ].normal.z);
glVertex3d(-(cloth[x ][y ].position.x-xrez+1)/4,-(cloth[x ][y ].position.y)/4+1.8,(cloth[x ][y ].position.z)/4);
glNormal3f(cloth[x+1][y ].normal.x,-cloth[x+1][y ].normal.y,cloth[x+1][y ].normal.z);
glVertex3d(-(cloth[x+1][y ].position.x-xrez+1)/4,-(cloth[x+1][y ].position.y)/4+1.8,(cloth[x+1][y ].position.z)/4);
glNormal3f(cloth[x+1][y+1].normal.x,-cloth[x+1][y+1].normal.y,cloth[x+1][y+1].normal.z);
glVertex3d(-(cloth[x+1][y+1].position.x-xrez+1)/4,-(cloth[x+1][y+1].position.y)/4+1.8,(cloth[x+1][y+1].position.z)/4);
glNormal3f(cloth[x ][y+1].normal.x,-cloth[x ][y+1].normal.y,cloth[x ][y+1].normal.z);
glVertex3d(-(cloth[x ][y+1].position.x-xrez+1)/4,-(cloth[x ][y+1].position.y)/4+1.8,(cloth[x ][y+1].position.z)/4);
}
glEnd();
}
| 27.243902
| 134
| 0.60385
|
ConspiracyHu
|
4f0f3a2012533b4f9164a4622fe18c65a035b028
| 7,630
|
cpp
|
C++
|
2019/17/main.cpp
|
adrian-stanciu/adventofcode
|
47b3d12226b0c71fff485ef140cd7731c9a5d72f
|
[
"MIT"
] | null | null | null |
2019/17/main.cpp
|
adrian-stanciu/adventofcode
|
47b3d12226b0c71fff485ef140cd7731c9a5d72f
|
[
"MIT"
] | null | null | null |
2019/17/main.cpp
|
adrian-stanciu/adventofcode
|
47b3d12226b0c71fff485ef140cd7731c9a5d72f
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include "int_computer.h"
using Map = std::vector<std::vector<char>>;
auto read_map(const std::vector<long long>& prog)
{
IntComputer ic(prog);
Map map;
std::vector<char> row;
while (ic.run()) {
auto out = *ic.get_last_output();
if (out != '\n')
row.push_back(out);
else if (!row.empty()) {
map.push_back(std::move(row));
row.clear();
}
}
return map;
}
auto compute_map_csum(const Map& map)
{
auto s = 0;
for (auto i = 1U; i < map.size() - 1; ++i)
for (auto j = 1U; j < map[i].size() - 1; ++j)
if (map[i][j] == '#') {
if (map[i - 1][j] != '#')
continue;
if (map[i + 1][j] != '#')
continue;
if (map[i][j - 1] != '#')
continue;
if (map[i][j + 1] != '#')
continue;
s += i * j;
}
return s;
}
auto find_start(const Map& map)
{
auto r = 0;
auto c = 0;
for (auto i = 0U; i < map.size(); ++i)
for (auto j = 0U; j < map[i].size(); ++j)
if (map[i][j] == '^' || map[i][j] == 'v' ||
map[i][j] == '<' || map[i][j] == '>') {
r = i;
c = j;
}
auto dr = 0;
auto dc = 0;
switch (map[r][c]) {
case '^':
dr = -1;
dc = 0;
break;
case 'v':
dr = 1;
dc = 0;
break;
case '<':
dr = 0;
dc = -1;
break;
case '>':
dr = 0;
dc = 1;
break;
}
return std::make_tuple(r, c, dr, dc);
}
auto get_dir(int r, int c, int next_r, int next_c, int& dr, int& dc)
{
auto new_dr = next_r - r;
auto new_dc = next_c - c;
char dir = '?';
if (dr == -1) {
if (new_dc == -1)
dir = 'L';
else
dir = 'R';
} else if (dr == 1) {
if (new_dc == -1)
dir = 'R';
else
dir = 'L';
} else if (dc == -1) {
if (new_dr == -1)
dir = 'R';
else
dir = 'L';
} else if (dc == 1) {
if (new_dr == -1)
dir = 'L';
else
dir = 'R';
}
dr = new_dr;
dc = new_dc;
return dir;
}
using Path = std::vector<std::pair<char, int>>;
auto compute_path(const Map& map)
{
const auto map_sz = static_cast<int>(map.size());
// direction is represented as deltas on rows and columns
auto [r, c, dr, dc] = find_start(map);
Path path;
while (true) {
const auto map_r_sz = static_cast<int>(map[r].size());
auto next_r = r;
auto next_c = c;
if (r - 1 >= 0 && map[r - 1][c] == '#' && dr == 0)
next_r = r - 1;
else if (r + 1 < map_sz && map[r + 1][c] == '#' && dr == 0)
next_r = r + 1;
else if (c - 1 >= 0 && map[r][c - 1] == '#' && dc == 0)
next_c = c - 1;
else if (c + 1 < map_r_sz && map[r][c + 1] == '#' && dc == 0)
next_c = c + 1;
// check end of line
if (next_r == r && next_c == c)
break;
auto dir = get_dir(r, c, next_r, next_c, dr, dc);
r = next_r;
c = next_c;
auto len = 1;
while (true) {
if (r + dr < 0 || r + dr == map_sz)
break;
if (c + dc < 0 || c + dc == map_r_sz)
break;
if (map[r + dr][c + dc] != '#')
break;
r += dr;
c += dc;
++len;
}
path.emplace_back(dir, len);
}
return path;
}
auto extract_instruction_block(const std::string& path,
unsigned int num_instructions, const std::set<char>& skip_chars)
{
auto i = 0UL;
while (i < path.size())
if (skip_chars.count(path[i]) > 0)
i += 2; // skip that char and the following comma
else
break;
std::string block;
while (i < path.size()) {
if (skip_chars.count(path[i]) > 0)
break;
block.push_back(path[i]);
if (path[i] == ',') { // a new instruction was added
--num_instructions;
if (num_instructions == 0)
return block;
}
++i;
}
return std::string();
}
void replace(std::string& where, const std::string& what, const std::string& with)
{
auto i = 0UL;
while (true) {
i = where.find(what, i);
if (i == std::string::npos)
break;
where.replace(i, what.size(), with);
i += with.size();
}
}
auto is_valid_main(const std::string& main, unsigned int max_fct_len)
{
for (auto c : main)
if (c != 'A' && c != 'B' && c != 'C' && c != ',')
return false;
return main.size() <= max_fct_len;
}
auto split_path(const Path& path, unsigned int max_fct_len)
{
std::string path_s;
for (const auto& p : path) {
path_s.push_back(p.first);
path_s.push_back(',');
path_s.append(std::to_string(p.second));
path_s.push_back(',');
}
auto max_instr_cnt = max_fct_len / 2;
for (auto a_len = 1U; a_len <= max_instr_cnt; ++a_len) {
auto path_a = path_s;
auto a = extract_instruction_block(path_a, a_len, {});
if (a.empty() || a.size() > max_fct_len)
continue;
replace(path_a, a, "A,");
for (auto b_len = 1U; b_len <= max_instr_cnt; ++b_len) {
auto path_ab = path_a;
auto b = extract_instruction_block(path_ab, b_len, {'A'});
if (b.empty() || b.size() > max_fct_len)
continue;
replace(path_ab, b, "B,");
for (auto c_len = 1U; c_len <= max_instr_cnt; ++c_len) {
auto path_abc = path_ab;
auto c = extract_instruction_block(path_abc, c_len, {'A', 'B'});
if (c.empty() || c.size() > max_fct_len)
continue;
replace(path_abc, c, "C,");
if (is_valid_main(path_abc, max_fct_len)) {
path_abc.pop_back();
a.pop_back();
b.pop_back();
c.pop_back();
return make_tuple(path_abc, a, b, c);
}
}
}
}
return make_tuple(std::string(), std::string(), std::string(), std::string());
}
void fill_input(IntComputer& ic, const Path& path, unsigned int max_fct_len)
{
auto [main, a, b, c] = split_path(path, max_fct_len);
auto encode_function = [&] (const auto& f) {
for (auto i : f)
ic.append_input(i);
ic.append_input('\n');
};
encode_function(main);
encode_function(a);
encode_function(b);
encode_function(c);
ic.append_input('n');
ic.append_input('\n');
}
auto traverse_path(const std::vector<long long>& prog, const Path& path,
unsigned int max_fct_len)
{
IntComputer ic(prog);
ic.set_mem(0, 2);
fill_input(ic, path, max_fct_len);
while (ic.run());
return *ic.get_last_output();
}
int main()
{
std::vector<long long> prog;
std::string line;
while (getline(std::cin, line, ','))
prog.push_back(strtoll(line.data(), nullptr, 10));
auto map = read_map(prog);
std::cout << compute_map_csum(map) << "\n";
auto path = compute_path(map);
std::cout << traverse_path(prog, path, 20) << "\n";
return 0;
}
| 22.115942
| 82
| 0.457012
|
adrian-stanciu
|
4f16d39e7f1386337a63339050e2b5ad800d088c
| 2,438
|
cxx
|
C++
|
Readers/FDEM/FDEMCrackJoint.cxx
|
ObjectivitySRC/PVGPlugins
|
5e24150262af751159d719cc810620d1770f2872
|
[
"BSD-2-Clause"
] | 4
|
2016-01-21T21:45:43.000Z
|
2021-07-31T19:24:09.000Z
|
Readers/FDEM/FDEMCrackJoint.cxx
|
ObjectivitySRC/PVGPlugins
|
5e24150262af751159d719cc810620d1770f2872
|
[
"BSD-2-Clause"
] | null | null | null |
Readers/FDEM/FDEMCrackJoint.cxx
|
ObjectivitySRC/PVGPlugins
|
5e24150262af751159d719cc810620d1770f2872
|
[
"BSD-2-Clause"
] | 6
|
2015-08-31T06:21:03.000Z
|
2021-07-31T19:24:10.000Z
|
#include "FDEMCrackJoint.h"
#include "vtkDoubleArray.h"
#include "vtkPoints.h"
#include "vtkCellArray.h"
#include "vtkCellData.h"
#include "vtkPolyData.h"
#define ZLEVEL 0.00001
#define MODE_CRACK 0
#define MODE_JOINT 1
// --------------------------------------
FDEMCrackJoint::FDEMCrackJoint( char* Name, int mode, double NormCoord)
{
this->HasData = false;
this->Mode = mode;
this->Name = Name;
this->NormCoord = NormCoord;
}
// --------------------------------------
void FDEMCrackJoint::Add( double block[100] )
{
const vtkIdType size = 4; //joints have 4
vtkIdType *Id = new vtkIdType[size] ;
float x[size], y[size], z=ZLEVEL; //2nd image, dont need more than 1 z
float damage;
//read in the info for the cracks / joints
for(int i=0; i<size; i++)
{
x[i] =(float)block[3+i] * this->NormCoord;
y[i] =(float)block[7+i] * this->NormCoord;
}
//grab the damage entry for this crack or joint
damage = (float) block[11];
if ( damage < 0.0 )
{
//change null values to -1
damage = -1;
}
else if ( damage > 0.0)
{
//calcualte out the damage, and make sure it falls in the range
//of -1 to 1
damage = ( (float)block[11] + (float)block[13] ) * 0.5;
if (damage > 1.0)
{
damage = 1.0;
}
else if (damage < -1.0)
{
damage = -1.0;
}
}
//set the points and cells
if ( ( damage < 0.0 && this->Mode == MODE_CRACK ) || ( damage > 0.0 && this->Mode >= MODE_JOINT ) )
{
this->HasData = true; //only place we really know the block is damaged
for (int i=0; i < size; i++)
{
Id[i] = this->Points->InsertNextPoint(x[i], y[i], z);
}
for (int i=0; i < 4; i+=2)
{
this->Cells->InsertNextCell(2); //drawing lines
this->Cells->InsertCellPoint(Id[i]);
this->Cells->InsertCellPoint(Id[i+1]);
this->Properties->AddDamage( damage );
}
}
}
// --------------------------------------
void FDEMCrackJoint::AddProperties( double block[100] )
{
//not used in this class
}
// --------------------------------------
vtkPolyData* FDEMCrackJoint::GetOutput()
{
this->Output->SetPoints( this->Points );
this->Output->SetLines( this->Cells );
this->Properties->PushToObject( this->Output->GetCellData() );
return this->Output;
}
#undef ZLEVL
| 24.38
| 104
| 0.535275
|
ObjectivitySRC
|
4f1a3b0a9da6e509f700595b59c4698cbb8f870c
| 1,145
|
cpp
|
C++
|
src/gl/glshaderprogram.cpp
|
helloer/polybobin
|
63b2cea40d3afcfc9d6f62f49acbfacf6a8783e1
|
[
"MIT"
] | 8
|
2016-10-06T11:49:14.000Z
|
2021-11-06T21:06:36.000Z
|
src/gl/glshaderprogram.cpp
|
helloer/polybobin
|
63b2cea40d3afcfc9d6f62f49acbfacf6a8783e1
|
[
"MIT"
] | 20
|
2017-04-25T14:23:02.000Z
|
2018-12-04T22:46:04.000Z
|
src/gl/glshaderprogram.cpp
|
helloer/polybobin
|
63b2cea40d3afcfc9d6f62f49acbfacf6a8783e1
|
[
"MIT"
] | 4
|
2016-11-22T16:06:18.000Z
|
2021-05-28T21:53:52.000Z
|
#include "glshaderprogram.hpp"
#include <system_error>
void GLShaderProgram::AddShader(GLenum type, const GLchar *code)
{
GLShader shader(type, code);
m_shaders.push_back(shader);
}
GLuint GLShaderProgram::GetUniformLocation(const GLchar *name)
{
return glGetUniformLocation(m_id, name);
}
void GLShaderProgram::Init()
{
for (auto &shader : m_shaders)
{
shader.Create();
shader.Compile();
}
m_id = glCreateProgram();
for (auto &shader : m_shaders)
{
glAttachShader(m_id, shader.GetId());
}
Link();
for (auto &shader : m_shaders)
{
shader.Delete();
}
}
void GLShaderProgram::StopUse()
{
glUseProgram(0);
}
void GLShaderProgram::Use()
{
glUseProgram(m_id);
}
void GLShaderProgram::Link()
{
GLint success;
char infoLog[512];
glLinkProgram(m_id);
glGetProgramiv(m_id, GL_LINK_STATUS, &success);
if (!success)
{
glGetProgramInfoLog(m_id, sizeof(infoLog), NULL, infoLog);
throw std::runtime_error("An error occurred when linking an OpenGL shader program : \n" + std::string(infoLog));
}
}
| 19.083333
| 120
| 0.639301
|
helloer
|
b7b767f3dc8042bb09e74f3acd7217f1c93de2b6
| 12,939
|
cc
|
C++
|
projects/S0009D/code/object.cc
|
Syrdni/S0009D
|
b159b3c73cc975885a7ce204c3d60f6d776f8654
|
[
"MIT"
] | null | null | null |
projects/S0009D/code/object.cc
|
Syrdni/S0009D
|
b159b3c73cc975885a7ce204c3d60f6d776f8654
|
[
"MIT"
] | null | null | null |
projects/S0009D/code/object.cc
|
Syrdni/S0009D
|
b159b3c73cc975885a7ce204c3d60f6d776f8654
|
[
"MIT"
] | null | null | null |
#include "object.h"
Object::Object(){}
Object::Object(MeshResource* mr, ShaderObject* so, TextureResource* tr, LightingNode* ln, Vector4D& cameraPos, std::string texturePath, Vector4D scale, float mass, bool unmovable)
{
this->scale = scale;
setupGraphicsNode(mr, so, tr, ln, cameraPos, texturePath);
rb = Rigidbody(originalAABB, mass, totalRotation, getReferenceToPosition(), unmovable);
setScaleMatrix(Matrix4D::getScaleMatrix(scale));
}
Object::~Object(){}
void Object::setupGraphicsNode(MeshResource* mr, ShaderObject* so, TextureResource* tr, LightingNode* ln, Vector4D& cameraPos, std::string texturePath)
{
graphicsNode.setMeshResource(mr);
graphicsNode.setShaderObject(so);
graphicsNode.setTextureResource(tr);
graphicsNode.setlightingNode(ln);
graphicsNode.setCameraPosition(cameraPos);
graphicsNode.loadTexture(texturePath.c_str());
graphicsNode.preDrawSetup();
setupFirstAABB(graphicsNode.getMeshResource()->getVertexBuffer());
}
void Object::setViewMatrix(Matrix4D viewmatrix)
{
this->viewmatrix = viewmatrix;
}
void Object::setupFirstAABB(std::vector<Vertex> vertices)
{
//Create the original AABB with mesh data
for (int i = 0; i < vertices.size(); i++)
{
if (vertices[i].pos[0] > originalAABB.maxPoint[0])
originalAABB.maxPoint[0] = vertices[i].pos[0];
else if (vertices[i].pos[0] < originalAABB.minPoint[0])
originalAABB.minPoint[0] = vertices[i].pos[0];
if (vertices[i].pos[1] > originalAABB.maxPoint[1])
originalAABB.maxPoint[1] = vertices[i].pos[1];
else if (vertices[i].pos[1] < originalAABB.minPoint[1])
originalAABB.minPoint[1] = vertices[i].pos[1];
if (vertices[i].pos[2] > originalAABB.maxPoint[2])
originalAABB.maxPoint[2] = vertices[i].pos[2];
else if (vertices[i].pos[2] < originalAABB.minPoint[2])
originalAABB.minPoint[2] = vertices[i].pos[2];
}
//Convert to worldspace
originalAABB.minPoint[0] += position[0];
originalAABB.minPoint[1] += position[1];
originalAABB.minPoint[2] += position[2];
originalAABB.maxPoint[0] += position[0];
originalAABB.maxPoint[1] += position[1];
originalAABB.maxPoint[2] += position[2];
originalAABB.maxPoint = Matrix4D::getScaleMatrix(scale) * originalAABB.maxPoint;
originalAABB.minPoint = Matrix4D::getScaleMatrix(scale) * originalAABB.minPoint;
//Set current AABB to the original
currentAABB = originalAABB;
//Debug things
Vector4D dimentions = Vector4D(originalAABB.maxPoint[0]-originalAABB.minPoint[0], originalAABB.maxPoint[1]-originalAABB.minPoint[1], originalAABB.maxPoint[2]-originalAABB.minPoint[2], 1);
Vector4D pos = Vector4D(originalAABB.minPoint[0] + (dimentions[0]/2),
originalAABB.minPoint[1] + (dimentions[1]/2),
originalAABB.minPoint[2] + (dimentions[2]/2),
1);
//DebugManager::getInstance()->createSingleFrameCube(pos, dimentions[0], dimentions[1], dimentions[2], colorOnAABB, true);
}
void Object::updateAABB()
{
//Reset AABB
currentAABB.maxPoint = Vector4D(-99999, -99999, -99999, 1);
currentAABB.minPoint = Vector4D(99999, 99999, 99999, 1);
//Create a vector that will contain all the points for the AABB
std::vector<Vector4D> pointVector;
//Create the combinedMatrix with rotation and scale
Matrix4D combinedMatrix = totalRotation;
//Apply the matrix to the original AABB and add the new points to the vector
pointVector.push_back(combinedMatrix * Vector4D(originalAABB.maxPoint[0], originalAABB.maxPoint[1], originalAABB.maxPoint[2], 1));
pointVector.push_back(combinedMatrix * Vector4D(originalAABB.maxPoint[0], originalAABB.minPoint[1], originalAABB.maxPoint[2], 1));
pointVector.push_back(combinedMatrix * Vector4D(originalAABB.minPoint[0], originalAABB.minPoint[1], originalAABB.maxPoint[2], 1));
pointVector.push_back(combinedMatrix * Vector4D(originalAABB.minPoint[0], originalAABB.maxPoint[1], originalAABB.maxPoint[2], 1));
pointVector.push_back(combinedMatrix * Vector4D(originalAABB.maxPoint[0], originalAABB.maxPoint[1], originalAABB.minPoint[2], 1));
pointVector.push_back(combinedMatrix * Vector4D(originalAABB.maxPoint[0], originalAABB.minPoint[1], originalAABB.minPoint[2], 1));
pointVector.push_back(combinedMatrix * Vector4D(originalAABB.minPoint[0], originalAABB.minPoint[1], originalAABB.minPoint[2], 1));
pointVector.push_back(combinedMatrix * Vector4D(originalAABB.minPoint[0], originalAABB.maxPoint[1], originalAABB.minPoint[2], 1));
//Find the min and max
for (int i = 0; i < pointVector.size(); i++)
{
if (pointVector[i][0] >= currentAABB.maxPoint[0]) currentAABB.maxPoint[0] = pointVector[i][0];
if (pointVector[i][1] >= currentAABB.maxPoint[1]) currentAABB.maxPoint[1] = pointVector[i][1];
if (pointVector[i][2] >= currentAABB.maxPoint[2]) currentAABB.maxPoint[2] = pointVector[i][2];
if (pointVector[i][0] <= currentAABB.minPoint[0]) currentAABB.minPoint[0] = pointVector[i][0];
if (pointVector[i][1] <= currentAABB.minPoint[1]) currentAABB.minPoint[1] = pointVector[i][1];
if (pointVector[i][2] <= currentAABB.minPoint[2]) currentAABB.minPoint[2] = pointVector[i][2];
}
//Apply position matrix to the new AABB
currentAABB.minPoint = Matrix4D::getPositionMatrix(position) * currentAABB.minPoint;
currentAABB.maxPoint = Matrix4D::getPositionMatrix(position) * currentAABB.maxPoint;
//Debug thingy
Vector4D dimentions = Vector4D(currentAABB.maxPoint[0]-currentAABB.minPoint[0], currentAABB.maxPoint[1]-currentAABB.minPoint[1], currentAABB.maxPoint[2]-currentAABB.minPoint[2], 1);
Vector4D pos = Vector4D(currentAABB.minPoint[0] + (dimentions[0]/2),
currentAABB.minPoint[1] + (dimentions[1]/2),
currentAABB.minPoint[2] + (dimentions[2]/2),
1);
//DebugManager::getInstance()->createSingleFrameCube(pos, dimentions[0], dimentions[1], dimentions[2], colorOnAABB, true);
}
void Object::draw()
{
//Debug thiny for AABB
Vector4D dimentions = Vector4D(currentAABB.maxPoint[0]-currentAABB.minPoint[0], currentAABB.maxPoint[1]-currentAABB.minPoint[1], currentAABB.maxPoint[2]-currentAABB.minPoint[2], 1);
Vector4D pos = Vector4D(currentAABB.minPoint[0] + (dimentions[0]/2),
currentAABB.minPoint[1] + (dimentions[1]/2),
currentAABB.minPoint[2] + (dimentions[2]/2),
1);
//DebugManager::getInstance()->createSingleFrameCube(pos, dimentions[0], dimentions[1], dimentions[2], colorOnAABB, true);
colorOnAABB = Vector4D(0, 0, 1, 0);
Matrix4D rotationX = Matrix4D::rotX(rotation[0]);
Matrix4D rotationY = Matrix4D::rotY(rotation[1]);
Matrix4D rotationZ = Matrix4D::rotZ(rotation[2]);
totalRotation = rb.getRotation();
Vector4D center = rb.getCenterPoint();
Vector4D mcenter = center * -1;
totalRotation = Matrix4D::getPositionMatrix(center) * totalRotation * Matrix4D::getPositionMatrix(mcenter);
// graphicsNode.setTransform(viewmatrix * Matrix4D::getPositionMatrix(position) * totalRotation * Matrix4D::getScaleMatrix(scale));
// graphicsNode.setPosition(Matrix4D::getPositionMatrix(position) * totalRotation * Matrix4D::getScaleMatrix(scale));
graphicsNode.setTransform(viewmatrix * rb.worldTransform);
graphicsNode.setPosition(rb.worldTransform);
graphicsNode.draw();
}
void Object::update()
{
position = rb.getPosition();
totalRotation = rb.getRotation();
rb.update();
updateAABB();
draw();
}
AABB Object::getAABB()
{
return currentAABB;
}
PointAndDistance Object::checkIfRayIntersects(Ray ray)
{
if (rb.unmovable)
{
return PointAndDistance(Vector4D(0, 0, 0, -1), -1, {});
}
std::vector<PointAndDistance> intersectionPoints;
Vector4D normal1, normal2, normal3;
//Get the combined matrix of scale and rotation
Matrix4D combinedMatrix = rb.worldTransform;// Matrix4D::getPositionMatrix(position) * totalRotation * Matrix4D::getScaleMatrix(scale);
//Get the Vertex and index buffer
std::vector<Vertex> vertBuffer = graphicsNode.getMeshResource()->getVertexBuffer();
std::vector<int> indBuffer = graphicsNode.getMeshResource()->getIndexBuffer();
//Save origin for so we can use it to calculate distance
Vector4D originOriginal = ray.getOrigin();
//Convert the ray into the localspace of the model
ray.setOrigin(Vector4D(ray.getOrigin()[0], ray.getOrigin()[1], ray.getOrigin()[2], 1)); //Set 4 coord to 1 or else...
ray.setOrigin(Matrix4D::inverse(combinedMatrix) * ray.getOrigin());
ray.setDirection(Matrix4D::inverse(combinedMatrix) * ray.getDirection());
ray.setDirection(Vector4D(ray.getDirection()[0], ray.getDirection()[1], ray.getDirection()[2], 0)); //Same here
//Loop through all the triangles
for (int i = 0; i < indBuffer.size(); i += 3)
{
//Calculate the normal for the triangle
Vector4D pos1, pos2, pos3;
pos1[0] = vertBuffer[indBuffer[i]].pos[0]; pos1[1] = vertBuffer[indBuffer[i]].pos[1]; pos1[2] = vertBuffer[indBuffer[i]].pos[2];
pos2[0] = vertBuffer[indBuffer[i+1]].pos[0]; pos2[1] = vertBuffer[indBuffer[i+1]].pos[1]; pos2[2] = vertBuffer[indBuffer[i+1]].pos[2];
pos3[0] = vertBuffer[indBuffer[i+2]].pos[0]; pos3[1] = vertBuffer[indBuffer[i+2]].pos[1]; pos3[2] = vertBuffer[indBuffer[i+2]].pos[2];
Vector4D normal = (pos2 - pos1).crossProduct(pos3 - pos1);
normal = normal.normalize();
//Cehck if we hit the triangle
if (Vector4D::dotProduct(normal, ray.getDirection()) < 0)
{
//Construct the vectors we need to check if our point is inside the plane
Vector4D v2v1 = pos2-pos1; Vector4D v3v2 = pos3-pos2; Vector4D v1v3 = pos1-pos3;
//Find the point where we intersected with the plane
PointAndDistance temp = ray.intersect(mPlane((pos1 + pos2 + pos3)*(1.0/3.0), normal));
if (temp.distance == -1)
continue;
temp.point[3] = 1;
//Calculate vetors towards the point from all corners of the triangle
Vector4D PV0 = temp.point - pos1; Vector4D PV1 = temp.point - pos2; Vector4D PV2 = temp.point - pos3;
//Check if we are inside the triangle
if (Vector4D::dotProduct(normal, v2v1.crossProduct(PV0)) > 0 &&
Vector4D::dotProduct(normal, v3v2.crossProduct(PV1)) > 0 &&
Vector4D::dotProduct(normal, v1v3.crossProduct(PV2)) > 0)
{
//DebugManager::getInstance()->createCube((combinedMatrix * temp.point), 0.5, 0.5, 0.5, Vector4D(1, 0, 0, 1));
//Add the intersection point to the vector
intersectionPoints.push_back(PointAndDistance(combinedMatrix * temp.point, temp.distance, temp.normal));
}
}
}
//If we didnt intersect with the mesh return with distance of -1
if (intersectionPoints.size() <= 0)
return PointAndDistance(Vector4D(0, 0, 0, -1), -1, {});
//Else find the closest point of intersection and return it
PointAndDistance closest = PointAndDistance(Vector4D(0, 0, 0, -1), 999999, {});
for (int i = 0; i < intersectionPoints.size(); i++)
{
if (closest.distance > intersectionPoints[i].distance)
closest = intersectionPoints[i];
}
return closest;
}
Vector4D& Object::getReferenceToPosition()
{
return rb.getPosition();
}
Vector4D& Object::getReferenceToRotation()
{
return rotation;
}
Vector4D& Object::getReferenceToScale()
{
return scale;
}
Rigidbody& Object::getReferenceToRigidbody()
{
return rb;
}
AABB& Object::getReferenceToAABB()
{
return currentAABB;
}
GraphicsNode Object::getGraphicsNode()
{
return graphicsNode;
}
Matrix4D Object::getRotation()
{
return totalRotation;
}
Vector4D Object::indexOfFurthestPoint(Vector4D direction)
{
int index = 0;
std::vector<Vertex> vertexBuffer = graphicsNode.getMeshResource()->getVertexBuffer();
float maxProduct = direction.dotProduct(rb.worldTransform * Vector4D(vertexBuffer[0].pos, 1));
float product = 0;
for (int i = 1; i < vertexBuffer.size(); i++)
{
product = direction.dotProduct(rb.worldTransform * Vector4D(vertexBuffer[i].pos, 1));
if (product > maxProduct)
{
maxProduct = product;
index = i;
}
}
return rb.worldTransform * Vector4D(vertexBuffer[index].pos, 1);
}
void Object::setScaleMatrix(Matrix4D scale)
{
rb.scale = scale;
rb.worldTransform = rb.worldTransform * scale;
}
| 41.471154
| 191
| 0.668831
|
Syrdni
|
b7babcfe588e74cd23e0dc673d1100756a6ecaa4
| 20,579
|
cpp
|
C++
|
cpp/KineticGas.cpp
|
vegardjervell/Kineticgas
|
5897dceb767802c4ec08b975fec216fe498aaf6e
|
[
"MIT"
] | 1
|
2022-01-28T16:14:06.000Z
|
2022-01-28T16:14:06.000Z
|
cpp/KineticGas.cpp
|
vegardjervell/Kineticgas
|
5897dceb767802c4ec08b975fec216fe498aaf6e
|
[
"MIT"
] | null | null | null |
cpp/KineticGas.cpp
|
vegardjervell/Kineticgas
|
5897dceb767802c4ec08b975fec216fe498aaf6e
|
[
"MIT"
] | null | null | null |
/*
Author : Vegard Gjeldvik Jervell
Contains :
Major base-functions for KineticGas. These functions are required for all versions, regardless of what
potential model they use. Contains summational expressions for the bracket integrals, and iterfaces to
get the matrices and vectors required to evaluate diffusion coefficients.
*/
#include "KineticGas.h"
#include <vector>
#include <algorithm>
#include <thread>
#include <functional>
#include <math.h>
#include <iostream>
#include "pybind11/pybind11.h"
#include <chrono>
#ifdef DEBUG
#define _LIBCPP_DEBUG 1
#endif
#define pprintf(flt) std::printf("%f", flt); std::printf("\n")
#define pprinti(i) std::printf("%i", i); std::printf("\n")
#pragma region // Global helper functions
int min(int a, int b){
if (a <= b){
return a;
}
return b;
}
double min(double a, double b){
if (a <= b){
return a;
}
return b;
}
int max(int a, int b){
if (a >= b){
return a;
}
return b;
}
double max(double a, double b){
if (a >= b){
return a;
}
return b;
}
int delta(int i, int j){ // Kronecker delta
if (i == j){
return 1;
}
return 0;
}
std::vector<double> logspace(const double& lmin, const double& lmax, const int& N_gridpoints){
std::vector<double> grid(N_gridpoints);
double dx = (lmax - lmin) / (N_gridpoints - 1);
// Making a logarithmic grid
// List is inverted when going from lin to log (so that numbers are more closely spaced at the start)
// Therefore: Count "backwards" to invert the list again so that the smallest r is at r_grid[0]
// Take a linear grid on (a, b), take log(grid) to get logarithmically spaced grid on (log(a), log(b))
// Make a linear map from (log(a), log(b)) to (b, a). Because spacing is bigger at the start of the log-grid
// Map the points on (log(a), log(b)) to (b, a), count backwards such that smaller numbers come first in the returned list
double A = (lmin - lmax) / log(lmax / lmin);
double B = lmin - A * log(lmax);
for (int i = 0; i < N_gridpoints; i++){
double x = log(lmax - dx * i); // Counting backwards linearly, mapping linear grid to logspace
grid[i] = A * x + B; // Using linear map from log
}
return grid;
}
double erfspace_func(const double& x, const double& lmin, const double& lmax, const double& a, const double& b){
double r = erf(a * (pow(x, b) - pow(lmin, b)) / (pow(lmax, b) - pow(lmin, b)));
return r;
}
std::vector<double> erfspace(const double& lmin, const double& lmax, const int& N_gridpoints, double& a, double& b){
std::vector<double> grid(N_gridpoints);
double dx = (lmax - lmin) / (N_gridpoints - 1);
// Making a f(x) grid where f(x) = erf(A * (x^b - lmin) / (lmax^b - lmin))
double A = (lmin - lmax) / (erfspace_func(lmax, lmin, lmax, a, b) - erfspace_func(lmin, lmin, lmax, a, b));
double B = lmin - A * erfspace_func(lmax, lmin, lmax, a, b);
for (int i = 0; i < N_gridpoints; i++){
double x = lmax - dx * i; // Counting backwards linearly (making linear grid)
double f = erfspace_func(x, lmin, lmax, a, b); // Mapping linear grid to f-space
grid[i] = A * f + B; // Linear map from f to lin
}
return grid;
}
#pragma endregion
#pragma endregion
#pragma region // Constructor
KineticGas::KineticGas(std::vector<double> init_mole_weights,
std::vector<std::vector<double>> init_sigmaij,
std::vector<std::vector<double>> init_epsij,
std::vector<std::vector<double>> init_la,
std::vector<std::vector<double>> init_lr,
int potential_mode)
: mole_weights{init_mole_weights},
sigmaij{init_sigmaij},
epsij{init_epsij},
la_ij{init_la},
lr_ij{init_lr},
m0{0.0},
potential_mode{potential_mode}
{
#ifdef DEBUG
std::printf("This is a Debug build!\nWith %i, %E, %E\n\n", potential_mode, mole_weights[0], mole_weights[1]);
#endif
for (int i = 0; i < sigmaij.size(); i++){
sigma.push_back(sigmaij[i][i]);
m0 += mole_weights[i];
}
sigma1 = sigma[0];
sigma2 = sigma[1];
sigma12 = sigmaij[0][1];
sigma_map[1] = sigma1;
sigma_map[2] = sigma2;
sigma_map[12] = sigma12;
sigma_map[21] = sigma12;
eps1 = epsij[0][0];
eps2 = epsij[1][1];
eps12 = epsij[0][1];
eps_map[1] = eps1;
eps_map[2] = eps2;
eps_map[12] = eps12;
eps_map[21] = eps12;
la1 = la_ij[0][0];
la2 = la_ij[1][1];
la12 = la_ij[0][1];
la_map[1] = la1;
la_map[2] = la2;
la_map[12] = la12;
la_map[21] = la12;
lr1 = lr_ij[0][0];
lr2 = lr_ij[1][1];
lr12 = lr_ij[0][1];
lr_map[1] = lr1;
lr_map[2] = lr2;
lr_map[12] = lr12;
lr_map[21] = lr12;
C1 = (lr1 / (lr1 - la1)) * pow(lr1 / la1, (la1 / (lr1 - la1)));
C2 = (lr2 / (lr2 - la2)) * pow(lr2 / la2, (la2 / (lr2 - la2)));
C12 = (lr12 / (lr12 - la12)) * pow(lr12 / la12, (la12 / (lr12 - la12)));
C_map[1] = C1;
C_map[2] = C2;
C_map[12] = C12;
C_map[21] = C12;
m1 = mole_weights[0];
m2 = mole_weights[1];
M1 = mole_weights[0] / m0;
M2 = mole_weights[1] / m0;
w_spherical_integrand_export = std::bind(&KineticGas::w_spherical_integrand, this,
std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3, std::placeholders::_4,
std::placeholders::_5, std::placeholders::_6);
switch (potential_mode)
{
case HS_potential_idx:
w_p = &KineticGas::w_HS;
potential_p = &KineticGas::HS_potential;
p_potential_derivative_r = &KineticGas::HS_potential_derivative;
p_potential_dblderivative_rr = &KineticGas::HS_potential_dblderivative_rr;
break;
case mie_potential_idx:
w_p = &KineticGas::w_spherical;
potential_p = &KineticGas::mie_potential;
p_potential_derivative_r = &KineticGas::mie_potential_derivative;
p_potential_dblderivative_rr = &KineticGas::mie_potential_dblderivative_rr;
break;
default:
throw "Invalid potential mode!";
}
}
KineticGas::KineticGas(std::vector<double> init_mole_weights,
std::vector<std::vector<double>> init_sigmaij,
std::vector<std::vector<double>> init_epsij,
std::vector<std::vector<double>> init_la,
std::vector<std::vector<double>> init_lr,
int potential_mode,
std::vector<std::vector<int>> omega_points,
std::vector<double> omega_vals)
: KineticGas(init_mole_weights, init_sigmaij, init_epsij, init_la, init_lr, potential_mode)
{
std::vector<double>::iterator v_it = omega_vals.begin();
for (std::vector<std::vector<int>>::iterator k_it = omega_points.begin();
k_it != omega_points.end();
k_it++, v_it++){
omega_map[OmegaPoint(*k_it)] = *v_it;
}
#ifdef DEBUG
std::printf("Initialized with omega_db\n");
for (std::map<OmegaPoint, double>::iterator it = omega_map.begin(); it != omega_map.end(); it++){
std::printf("ij = %i, r = %i, l = %i, T_cK = %i, omega = %E\n", it->first.ij, it->first.r, it->first.l, it->first.T_dK, it->second);
}
std::printf("\n");
#endif
}
#pragma endregion
#pragma region // Helper functions
std::vector<std::vector<double>> KineticGas::get_A_matrix(
const double& T,
const std::vector<double>& mole_fracs,
const int& N)
{
std::vector<std::vector<double>> A_matrix(2 * N + 1, std::vector<double>(2 * N + 1));
// fill_A_matrix(T, mole_fracs, N, A_matrix);
// std::thread t1(&KineticGas::fill_A_matrix_14, this, std::ref(T), std::ref(mole_fracs), std::ref(N), std::ref(A_matrix));
// std::thread t2(&KineticGas::fill_A_matrix_24, this, std::ref(T), std::ref(mole_fracs), std::ref(N), std::ref(A_matrix));
// std::thread t3(&KineticGas::fill_A_matrix_34, this, std::ref(T), std::ref(mole_fracs), std::ref(N), std::ref(A_matrix));
// fill_A_matrix_44(T, mole_fracs, N, A_matrix);
// t1.join(); t2.join(); t3.join();
std::thread t1(&KineticGas::fill_A_matrix_12, this, std::ref(T), std::ref(mole_fracs), std::ref(N), std::ref(A_matrix));
fill_A_matrix_22(T, mole_fracs, N, A_matrix);
t1.join();
return A_matrix;
}
void KineticGas::fill_A_matrix( // Fill entire A_matrix
const double& T,
const std::vector<double>& mole_fracs,
const int& N,
std::vector<std::vector<double>>& A_matrix){
for (int p = - N; p <= N; p++){
for (int q = - N; q <= p; q++){
A_matrix[p + N][q + N] = a(p, q, T, mole_fracs);
A_matrix[q + N][p + N] = A_matrix[p + N][q + N];
}
}
}
void KineticGas::fill_A_matrix_12( // Fill part of the A-matrix (as indicated by crosses), used in combination with *_22
const double& T, // x - - - -
const std::vector<double>& mole_fracs, // x x - - -
const int& N, // x x x - -
std::vector<std::vector<double>>& A_matrix){ // x x - - -
// x - - - -
for (int p = - N; p <= N; p++){
for (int q = - N; q <= - abs(p); q++){
A_matrix[p + N][q + N] = a(p, q, T, mole_fracs);
A_matrix[q + N][p + N] = A_matrix[p + N][q + N]; // Matrix is symmetric
}
}
}
void KineticGas::fill_A_matrix_22( // Fill part of the A-matrix (as indicated by crosses), used in combination with *_12
const double& T, // - - - - -
const std::vector<double>& mole_fracs, // - - - - -
const int& N, // - - - - -
std::vector<std::vector<double>>& A_matrix){ // - - x x -
// - x x x x
for (int p = 1 ; p <= N; p++){
for (int q = - p + 1 ; q <= p; q++){
A_matrix[p + N][q + N] = a(p, q, T, mole_fracs);
A_matrix[q + N][p + N] = A_matrix[p + N][q + N]; // Matrix is symmetric
}
}
}
void KineticGas::fill_A_matrix_14( // Fill part of the A-matrix (as indicated by crosses), used in combination with *_24, *_34 and *_44
const double& T, // x - - - -
const std::vector<double>& mole_fracs, // x x - - -
const int& N, // - - - - -
std::vector<std::vector<double>>& A_matrix){ // - - - - -
// - - - - -
for (int p = - N; p < 0; p++){
for (int q = - N; q <= - abs(p); q++){
A_matrix[p + N][q + N] = a(p, q, T, mole_fracs);
A_matrix[q + N][p + N] = A_matrix[p + N][q + N]; // Matrix is symmetric
}
}
}
void KineticGas::fill_A_matrix_24( // Fill part of the A-matrix (as indicated by crosses), used in combination with *_14, *_34 and *_44
const double& T, // - - - - -
const std::vector<double>& mole_fracs, // - - - - -
const int& N, // x x x - -
std::vector<std::vector<double>>& A_matrix){ // x x - - -
// x - - - -
for (int p = 0; p <= N; p++){
for (int q = - N; q <= - abs(p); q++){
double val = a(p, q, T, mole_fracs);
A_matrix[p + N][q + N] = val;
A_matrix[q + N][p + N] = A_matrix[p + N][q + N]; // Matrix is symmetric
}
}
}
void KineticGas::fill_A_matrix_34( // Fill part of the A-matrix (as indicated by crosses), used in combination with *_14, *_24 and *_44
const double& T, // - - - - -
const std::vector<double>& mole_fracs, // - - - - -
const int& N, // - - - - -
std::vector<std::vector<double>>& A_matrix){ // - - x - -
// - x x - -
for (int p = 1; p <= N; p++){
for (int q = - p + 1; q < 0; q++){
A_matrix[p + N][q + N] = a(p, q, T, mole_fracs);
A_matrix[q + N][p + N] = A_matrix[p + N][q + N]; // Matrix is symmetric
}
}
}
void KineticGas::fill_A_matrix_44( // Fill part of the A-matrix (as indicated by crosses), used in combination with *_14, *_24 and *_34
const double& T, // - - - - -
const std::vector<double>& mole_fracs, // - - - - -
const int& N, // - - - - -
std::vector<std::vector<double>>& A_matrix){ // - - - x -
// - - - x x
for (int p = 1; p <= N; p++){
for (int q = 0; q <= p; q++){
A_matrix[p + N][q + N] = a(p, q, T, mole_fracs);
A_matrix[q + N][p + N] = A_matrix[p + N][q + N];
}
}
}
std::vector<double> KineticGas::get_delta_vector(
const double& T,
const double& particle_density,
const int& N)
{
std::vector<double> delta_vector(2 * N + 1);
delta_vector[N] = (3.0 / (particle_density * 2.0)) * sqrt(2 * BOLTZMANN * T / m0);
return delta_vector;
}
std::vector<std::vector<double>> KineticGas::get_reduced_A_matrix(
const double& T,
const std::vector<double>& mole_fracs,
const int& N)
{
// Get A-matrix, exluding central row and column, where (p == 0 or q == 0)
std::vector<std::vector<double>> reduced_A(2*N, std::vector<double>(2 * N));
// Upper left block
for (int p = - N; p < 0; p++){
for (int q = - N; q <= p; q++){
reduced_A[p + N][q + N] = a(p, q, T, mole_fracs);
reduced_A[q + N][p + N] = reduced_A[p + N][q + N]; // Matrix is symmetric
}
}
//Lower left block (and upper right by symmetry)
for (int p = 1; p <= N; p++){
for (int q = - N; q < 0; q++){
reduced_A[p + N - 1][q + N] = a(p, q, T, mole_fracs);
reduced_A[q + N][p + N - 1] = reduced_A[p + N - 1][q + N]; // Matrix is symmetric
}
}
//Lower right block
for (int p = 1; p <= N; p++){
for (int q = 1; q <= p; q++){
reduced_A[p + N - 1][q + N - 1] = a(p, q, T, mole_fracs);
reduced_A[q + N - 1][p + N - 1] = reduced_A[p + N - 1][q + N - 1]; // Matrix is symmetric
}
}
return reduced_A;
}
std::vector<double> KineticGas::get_alpha_vector(
const double& T,
const double& particle_density,
const std::vector<double>& in_mole_fracs,
const int& N)
{
std::vector<double> alpha_vector(2 * N);
alpha_vector[N - 1] = - (15.0 / 4.0) * (in_mole_fracs[1] / particle_density) * sqrt(2 * BOLTZMANN * T / m2);
alpha_vector[N] = - (15.0 / 4.0) * (in_mole_fracs[0] / particle_density) * sqrt(2 * BOLTZMANN * T / m1);
return alpha_vector;
}
#pragma endregion
#pragma region // A-functions
double KineticGas::A(const int& p, const int& q, const int& r, const int& l){
double value{0.0};
int max_i = min(min(p, q), min(r, p + q + 1 - r));
for (int i = l - 1; i <= max_i; i++){
value += ((ipow(8, i) * Fac(p + q - 2 * i) * ipow(-1, l + r + i) * Fac(r + 1) * Fac(2 * (p + q + 2 - i)) * ipow(4, r)) /
(Fac(p - i) * Fac(q - i) * Fac(l) * Fac(i + 1 - l) * Fac(r - i) * Fac(p + q + 1 - i - r) * Fac(2 * r + 2)
* Fac(p + q + 2 - i) * ipow(4, p + q + 1))) * ((i + 1 - l) * (p + q + 1 - i - r) - l * (r - i));
}
return value;
}
double KineticGas::A_prime(const int& p, const int& q, const int& r, const int& l,
const double& tmp_M1, const double& tmp_M2){
double F = (pow(tmp_M1, 2) + pow(tmp_M2, 2)) / (2 * tmp_M1 * tmp_M2);
double G = (tmp_M1 - tmp_M2) / tmp_M2;
int max_i = min(p, min(q, min(r, p + q + 1 - r)));
int max_k;
int max_w;
Product p1{1}, p2{1};
double value{0.0};
for (int i = l - 1; i <= max_i; i++ ){
max_w = min(p, min(q, p + q + 1 - r)) - i;
max_k = min(l, i);
for (int k = l - 1; k <= max_k; k++){
for (int w = 0; w <= max_w; w++){
p1 = ((ipow(8, i) * Fac(p + q - 2 * i - w) * ipow(-1, r + i) * Fac(r + 1) * Fac(2 * (p + q + 2 - i - w)) * ipow(2, 2 * r) * pow(F, i - k) * pow(G, w)
* ((ipow(2, 2 * w - 1) * pow(tmp_M1, i) * pow(tmp_M2, p + q - i - w)) * 2)
* (tmp_M1 * (p + q + 1 - i - r - w) * delta(k, l) - tmp_M2 * (r - i) * delta(k, l - 1))
));
p2 = (Fac(p - i - w) * Fac(q - i - w) * Fac(r - i) * Fac(p + q + 1 - i - r - w) * Fac(2 * r + 2) * Fac(p + q + 2 - i - w) * ipow(4, p + q + 1) * Fac(k) * Fac(i - k) * Fac(w));
value += p1 / p2; // NB: Gives Bus error if unless v1 and v2 are initialized before adding to value... pls help
}
}
}
return value;
}
double KineticGas::A_trippleprime(const int& p, const int& q, const int& r, const int& l){
if (p * q == 0 || l % 2 ){
return 0.0;
}
double value{0.0};
int max_i = min(p, min(q, min(r, p + q + 1 - r)));
for (int i = l - 1; i <= max_i; i++){
value += ((ipow(8, i) * Fac(p + q - (2 * i)) * 2 * ipow(-1, r + i) * Fac(r + 1) * Fac(2 * (p + q + 2 - i)) * ipow(2, 2 * r) * (((i + 1 - l) * (p + q + 1 - i - r)) - l * (r - i))) /
(Fac(p - i) * Fac(q - i) * Fac(l) * Fac(i + 1 - l) * Fac(r - i) * Fac(p + q + 1 - i - r) * Fac(2 * r + 2) * Fac(p + q + 2 - i) * ipow(4, p + q + 1)));
}
value *= pow(0.5, p + q + 1);
return value;
}
#pragma endregion
#pragma region // H-integrals and a(p, q)
double KineticGas::H_ij(const int& p, const int& q, const int& ij, const double& T){
double tmp_M1{M1}, tmp_M2{M2};
if (ij == 21){ // swap indices
tmp_M1 = M2;
tmp_M2 = M1;
}
double value{0.0};
int max_l = min(p, q) + 1;
int max_r;
for (int l = 1; l <= max_l; l++){
max_r = p + q + 2 - l;
for (int r = l; r <= max_r; r++){
value += A(p, q, r, l) * omega(12, l, r, T);
}
}
value *= 8 * pow(tmp_M2, p + 0.5) * pow(tmp_M1, q + 0.5);
return value;
}
double KineticGas::H_i(const int& p, const int& q, const int& ij, const double& T){
double tmp_M1{M1}, tmp_M2{M2};
if (ij == 21){ // swap indices
tmp_M1 = M2;
tmp_M2 = M1;
}
double value{0.0};
int max_l = min(p, q) + 1;
int max_r;
for (int l = 1; l <= max_l; l++){
max_r = p + q + 2 - l;
for (int r = l; r <= max_r; r++){
value += A_prime(p, q, r, l, tmp_M1, tmp_M2) * omega(12, l, r, T);
}
}
value *= 8;
return value;
}
double KineticGas::H_simple(const int& p, const int& q, const int& i, const double& T){
double value{0.0};
int max_l = min(p,q) + 1;
int max_r;
for (int l = 2; l <= max_l; l += 2){
max_r = p + q + 2 - l;
for (int r = l; r <= max_r; r++){
value += A_trippleprime(p, q, r, l) * omega(i, l, r, T);
}
}
value *= 8;
return value;
}
double KineticGas::a(const int& p, const int& q, const double& T, const std::vector<double>& mole_fracs){
double x1{mole_fracs[0]}, x2{mole_fracs[1]};
if (p == 0 || q == 0){
if (p > 0) return pow(M1, 0.5) * x1 * x2 * H_i(p, q, 12, T);
else if (p < 0) return - pow(M2, 0.5) * x1 * x2 * H_i(-p, q, 21, T);
else if (q > 0) return pow(M1, 0.5) * x1 * x2 * H_i(p, q, 12, T);
else if (q < 0) return - pow(M2, 0.5) * x1 * x2 * H_i(p, -q, 21, T);
else{ // p == 0 and q == 0
return M1 * x1 * x2 * H_i(p, q, 12, T);
}
}
else if (p > 0 and q > 0) return pow(x1, 2) * (H_simple(p, q, 1, T)) + x1 * x2 * H_i(p, q, 12, T);
else if (p > 0 and q < 0) return x1 * x2 * H_ij(p, -q, 12, T);
else if (p < 0 and q > 0) return x1 * x2 * H_ij(-p, q, 21, T);
else{ // p < 0 and q < 0
return pow(x2, 2) * H_simple(-p, -q, 2, T) + x1 * x2 * H_i(-p, -q, 21, T);
}
}
#pragma endregion
| 37.690476
| 191
| 0.501093
|
vegardjervell
|
b7bb33a392540db3d08fa93fb9aa4ae7bdf78059
| 1,772
|
cpp
|
C++
|
KEngine/Internal/KRenderDocCapture.cpp
|
King19931229/KApp
|
f7f855b209348f835de9e5f57844d4fb6491b0a1
|
[
"MIT"
] | 13
|
2019-10-19T17:41:19.000Z
|
2021-11-04T18:50:03.000Z
|
KEngine/Internal/KRenderDocCapture.cpp
|
King19931229/KApp
|
f7f855b209348f835de9e5f57844d4fb6491b0a1
|
[
"MIT"
] | 3
|
2019-12-09T06:22:43.000Z
|
2020-05-28T09:33:44.000Z
|
KEngine/Internal/KRenderDocCapture.cpp
|
King19931229/KApp
|
f7f855b209348f835de9e5f57844d4fb6491b0a1
|
[
"MIT"
] | null | null | null |
#include "KRenderDocCapture.h"
#include "KBase/Publish/KSystem.h"
#include "KBase/Publish/KFileTool.h"
#include "KBase/Interface/IKLog.h"
#include <assert.h>
#ifdef _WIN32
#include <Windows.h>
#endif
KRenderDocCapture::KRenderDocCapture()
: m_Module(nullptr),
m_rdoc_api(nullptr)
{
}
KRenderDocCapture::~KRenderDocCapture()
{
ASSERT_RESULT(m_Module == NULL);
ASSERT_RESULT(m_rdoc_api == nullptr);
}
bool KRenderDocCapture::Init()
{
UnInit();
#ifdef _WIN32
std::string renderDocPath;
if (KSystem::QueryRegistryKey("SOFTWARE\\Classes\\RenderDoc.RDCCapture.1\\DefaultIcon\\", "", renderDocPath))
{
std::string renderDocFolder;
ASSERT_RESULT(KFileTool::ParentFolder(renderDocPath, renderDocFolder));
std::string renderDocDLL;
ASSERT_RESULT(KFileTool::PathJoin(renderDocFolder, "renderdoc.dll", renderDocDLL));
m_Module = LoadLibraryA(renderDocDLL.c_str());
if (GetModuleHandleA(renderDocDLL.c_str()))
{
pRENDERDOC_GetAPI RENDERDOC_GetAPI = (pRENDERDOC_GetAPI)GetProcAddress((HMODULE)m_Module, "RENDERDOC_GetAPI");
int ret = RENDERDOC_GetAPI(eRENDERDOC_API_Version_1_4_1, (void**)&m_rdoc_api);
if (ret == 0)
{
m_rdoc_api = nullptr;
}
if (m_rdoc_api)
{
m_rdoc_api->MaskOverlayBits(eRENDERDOC_Overlay_None, eRENDERDOC_Overlay_None);
int MajorVersion(0), MinorVersion(0), PatchVersion(0);
m_rdoc_api->GetAPIVersion(&MajorVersion, &MinorVersion, &PatchVersion);
KG_LOGD(LM_RENDER, "RenderDoc Capture Init %d.%d.%d", MajorVersion, MinorVersion, PatchVersion);
}
}
}
#endif
return m_rdoc_api != nullptr;
}
bool KRenderDocCapture::UnInit()
{
#ifdef _WIN32
if (m_Module != NULL)
{
FreeLibrary((HMODULE)m_Module);
m_Module = nullptr;
}
#endif
m_Module = nullptr;
m_rdoc_api = nullptr;
return true;
}
| 25.681159
| 113
| 0.740971
|
King19931229
|
b7bbf23d8de0122178f3f6bfb9419e4dafbddaea
| 2,900
|
cpp
|
C++
|
GlNddiDisplay.cpp
|
dave-estes-UNC/nddi
|
4b38e8155bd29201152f8fa8d356e97371c60d90
|
[
"Apache-2.0"
] | null | null | null |
GlNddiDisplay.cpp
|
dave-estes-UNC/nddi
|
4b38e8155bd29201152f8fa8d356e97371c60d90
|
[
"Apache-2.0"
] | null | null | null |
GlNddiDisplay.cpp
|
dave-estes-UNC/nddi
|
4b38e8155bd29201152f8fa8d356e97371c60d90
|
[
"Apache-2.0"
] | null | null | null |
#include <iostream>
#include <stdio.h>
#include <sys/time.h>
#include "Features.h"
#include "GlNddiDisplay.h"
// public
GlNddiDisplay::GlNddiDisplay(vector<unsigned int> &frameVolumeDimensionalSizes,
unsigned int numCoefficientPlanes, unsigned int inputVectorSize,
bool headless, unsigned char logcosts, bool fixed8x8Macroblocks, bool useSingleCoefficientPlane) {
texture_ = 0;
GlNddiDisplay(frameVolumeDimensionalSizes, 320, 240, numCoefficientPlanes, inputVectorSize);
}
GlNddiDisplay::GlNddiDisplay(vector<unsigned int> &frameVolumeDimensionalSizes,
unsigned int displayWidth, unsigned int displayHeight,
unsigned int numCoefficientPlanes, unsigned int inputVectorSize,
bool headless, unsigned char logcosts, bool fixed8x8Macroblocks, bool useSingleCoefficientPlane)
: SimpleNddiDisplay(frameVolumeDimensionalSizes, displayWidth, displayHeight, numCoefficientPlanes, inputVectorSize, headless, logcosts, fixed8x8Macroblocks, useSingleCoefficientPlane) {
// allocate a texture name
glGenTextures( 1, &texture_ );
}
// TODO(CDE): Why is the destructor for GlNddiDisplay being called when we're using a ClNddiDisplay?
GlNddiDisplay::~GlNddiDisplay() {
glDeleteTextures(1, &texture_);
}
// Private
GLuint GlNddiDisplay::GetFrameBufferTex() {
return GetFrameBufferTex(0, 0, displayWidth_, displayHeight_);
}
GLuint GlNddiDisplay::GetFrameBufferTex(unsigned int sub_x, unsigned int sub_y, unsigned int sub_w, unsigned int sub_h) {
#ifdef SUPRESS_EXCESS_RENDERING
if (changed_)
Render(sub_x, sub_y, sub_w, sub_h);
#endif
// TODO(CDE): Temporarily putting this here until GlNddiDisplay and ClNddiDisplay
// are using the exact same kind of GL textures
#ifndef USE_CL
// select our current texture
glBindTexture( GL_TEXTURE_2D, texture_ );
// select modulate to mix texture with color for shading
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
// when texture area is small, bilinear filter the closest mipmap
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_NEAREST );
// when texture area is large, bilinear filter the first mipmap
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
// if wrap is true, the texture wraps over at the edges (repeat)
// ... false, the texture ends at the edges (clamp)
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
GL_CLAMP );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
GL_CLAMP );
// build our texture mipmaps
gluBuild2DMipmaps( GL_TEXTURE_2D, 3, displayWidth_, displayHeight_,
GL_RGBA, GL_UNSIGNED_BYTE, frameBuffer_ );
#endif
return texture_;
}
| 39.189189
| 186
| 0.713793
|
dave-estes-UNC
|
b7bf6c77995df451e0600e946a9fafccab530e6f
| 413
|
hpp
|
C++
|
include/lug/Graphics/Vulkan/Builder/Texture.hpp
|
Lugdunum3D/Lugdunum3D
|
b6d6907d034fdba1ffc278b96598eba1d860f0d4
|
[
"MIT"
] | 275
|
2016-10-08T15:33:17.000Z
|
2022-03-30T06:11:56.000Z
|
include/lug/Graphics/Vulkan/Builder/Texture.hpp
|
Lugdunum3D/Lugdunum3D
|
b6d6907d034fdba1ffc278b96598eba1d860f0d4
|
[
"MIT"
] | 24
|
2016-09-29T20:51:20.000Z
|
2018-05-09T21:41:36.000Z
|
include/lug/Graphics/Vulkan/Builder/Texture.hpp
|
Lugdunum3D/Lugdunum3D
|
b6d6907d034fdba1ffc278b96598eba1d860f0d4
|
[
"MIT"
] | 37
|
2017-02-25T05:03:48.000Z
|
2021-05-10T19:06:29.000Z
|
#pragma once
#include <lug/Graphics/Render/Texture.hpp>
#include <lug/Graphics/Resource.hpp>
namespace lug {
namespace Graphics {
namespace Builder {
class Texture;
} // Builder
namespace Vulkan {
namespace Builder {
namespace Texture {
Resource::SharedPtr<lug::Graphics::Render::Texture> build(const ::lug::Graphics::Builder::Texture& builder);
} // Texture
} // Builder
} // Vulkan
} // Graphics
} // lug
| 17.208333
| 108
| 0.72155
|
Lugdunum3D
|
b7c29be2afd91b746cc69d39d0e9fde9e25bf38c
| 1,850
|
cpp
|
C++
|
lib/iri/test/iri_gen_test.cpp
|
zmij/wire
|
9981eb9ea182fc49ef7243eed26b9d37be70a395
|
[
"Artistic-2.0"
] | 5
|
2016-04-07T19:49:39.000Z
|
2021-08-03T05:24:11.000Z
|
lib/iri/test/iri_gen_test.cpp
|
zmij/wire
|
9981eb9ea182fc49ef7243eed26b9d37be70a395
|
[
"Artistic-2.0"
] | null | null | null |
lib/iri/test/iri_gen_test.cpp
|
zmij/wire
|
9981eb9ea182fc49ef7243eed26b9d37be70a395
|
[
"Artistic-2.0"
] | 1
|
2020-12-27T11:47:31.000Z
|
2020-12-27T11:47:31.000Z
|
/*
* iri_gen_test.cpp
*
* Created on: Aug 19, 2015
* Author: zmij
*/
#include "grammar/grammar_gen_test.hpp"
#include <tip/iri/grammar/iri_generate.hpp>
namespace gen = tip::iri::grammar::gen;
GRAMMAR_GEN_TEST(gen::sub_delims_grammar, SubDelims, char,
::testing::Values(
GenerateSubDelims::make_test_data('!', "!"),
GenerateSubDelims::make_test_data('$', "$")
)
);
GRAMMAR_GEN_TEST(gen::gen_delims_grammar, GenDelims, char,
::testing::Values(
GenerateSubDelims::make_test_data(':', ":"),
GenerateSubDelims::make_test_data('?', "?")
)
);
GRAMMAR_GEN_TEST(gen::reserved_grammar, Reserved, char,
::testing::Values(
GenerateReserved::make_test_data('!', "!"),
GenerateReserved::make_test_data('$', "$"),
GenerateReserved::make_test_data(':', ":"),
GenerateReserved::make_test_data('?', "?")
)
);
GRAMMAR_GEN_TEST(gen::unreserved_grammar, Unreserved, std::string,
::testing::Values(
GenerateUnreserved::make_test_data("a", "a"),
GenerateUnreserved::make_test_data("0", "0"),
GenerateUnreserved::make_test_data("-", "-")
)
);
GRAMMAR_GEN_TEST(gen::pct_encoded_grammar, PCT, char,
::testing::Values(
GeneratePCT::make_test_data( ' ', "%20" ),
GeneratePCT::make_test_data( '~', "%7e" ),
GeneratePCT::make_test_data( 9, "%09" )
)
);
GRAMMAR_GEN_TEST(gen::iunreserved_grammar, IUnreserved, std::string,
::testing::Values(
GenerateUnreserved::make_test_data("a", "a"),
GenerateUnreserved::make_test_data("0", "0"),
GenerateUnreserved::make_test_data("-", "-"),
GenerateUnreserved::make_test_data("%xa0", "%xa0")
)
);
GRAMMAR_GEN_TEST(gen::ipath_grammar, Path, tip::iri::path,
::testing::Values(
GeneratePath::make_test_data( {false, { "foo", "bar" }}, "foo/bar" ),
GeneratePath::make_test_data( {true, { "foo", "bar" }}, "/foo/bar" ),
GeneratePath::make_test_data( {true}, "/" )
)
);
| 26.811594
| 71
| 0.681622
|
zmij
|
b7c3b9cdef4002b8b538298e2973aad88e6f5a94
| 3,790
|
hpp
|
C++
|
include/saci/tree/model/branch_impl.hpp
|
ricardocosme/saci
|
2a6a134f63b6e69fde452e0fe9bb5acfd149a6e4
|
[
"BSL-1.0"
] | 1
|
2020-07-29T20:42:58.000Z
|
2020-07-29T20:42:58.000Z
|
include/saci/tree/model/branch_impl.hpp
|
ricardocosme/saci
|
2a6a134f63b6e69fde452e0fe9bb5acfd149a6e4
|
[
"BSL-1.0"
] | null | null | null |
include/saci/tree/model/branch_impl.hpp
|
ricardocosme/saci
|
2a6a134f63b6e69fde452e0fe9bb5acfd149a6e4
|
[
"BSL-1.0"
] | null | null | null |
#pragma once
#include "saci/tree/model/detail/apply_node_impl.hpp"
#include "saci/tree/model/detail/node_impl_fwd.hpp"
#include "saci/tree/model/detail/visibility.hpp"
#include "saci/tree/model/node_base.hpp"
#include <boost/fusion/include/as_vector.hpp>
#include <boost/fusion/include/for_each.hpp>
#include <boost/fusion/include/mpl.hpp>
#include <boost/mpl/transform.hpp>
#include <boost/mpl/vector.hpp>
#include <coruja/observer_class.hpp>
#include <type_traits>
namespace saci { namespace tree {
namespace detail {
template<typename Self>
struct sync_with_domain_t;
template<typename Parent>
struct update_parent_ptr;
}
template<typename T,
typename CheckPolicy,
typename Children,
typename Parent,
typename EnableIfChildren = void>
struct branch_impl;
template<typename T,
typename CheckPolicy,
typename Children,
typename Parent>
struct branch_impl<
T,
CheckPolicy,
Children,
Parent,
typename std::enable_if<boost::mpl::size<Children>::value >= 2>::type
> : coruja::observer_class<
branch_impl<T, CheckPolicy, Children, Parent>,
node_base<T, CheckPolicy, detail::Expandable, Parent>
>
{
using base = coruja::observer_class<
branch_impl,
node_base<T, CheckPolicy, detail::Expandable, Parent>>;
using ctx_t = void;
using children_t = typename boost::fusion::result_of::as_vector<
typename boost::mpl::transform<
Children, detail::apply_node_impl<branch_impl>>::type
>::type;
branch_impl() = default;
branch_impl(typename base::type& o, Parent& p) : base(o, p)
{
boost::fusion::for_each(children, detail::sync_with_domain_t<branch_impl>{*this});
}
branch_impl(branch_impl&&) = delete;
branch_impl& operator=(branch_impl&& rhs) {
base::operator=(std::move(rhs));
children = std::move(rhs.children);
boost::fusion::for_each
(children, detail::update_parent_ptr<branch_impl>{*this});
return *this;
}
void update_parent_ptr(Parent& p) {
base::update_parent_ptr(p);
boost::fusion::for_each
(children, detail::update_parent_ptr<branch_impl>{*this});
}
children_t children;
};
template<typename T,
typename CheckPolicy,
typename Children,
typename Parent>
struct branch_impl<
T,
CheckPolicy,
Children,
Parent,
typename std::enable_if<boost::mpl::size<Children>::value == 1>::type
> : coruja::observer_class<
branch_impl<T, CheckPolicy, Children, Parent>,
node_base<T, CheckPolicy, detail::Expandable, Parent>
>
{
using base = coruja::observer_class<
branch_impl,
node_base<T, CheckPolicy, detail::Expandable, Parent>>;
using ctx_t = void;
using children_t = typename detail::node_impl<
branch_impl, typename boost::mpl::front<Children>::type
>::type;
branch_impl() = default;
branch_impl(typename base::type& o, Parent& p) : base(o, p)
{
detail::sync_with_domain_t<branch_impl>{*this}(children);
}
branch_impl(branch_impl&&) = delete;
branch_impl& operator=(branch_impl&& rhs) {
base::operator=(std::move(rhs));
children = std::move(rhs.children);
detail::update_parent_ptr<branch_impl>{*this}(children);
return *this;
}
void update_parent_ptr(Parent& p) {
base::update_parent_ptr(p);
detail::update_parent_ptr<branch_impl>{*this}(children);
}
children_t children;
};
}}
#include "saci/tree/model/detail/branch.hpp"
#include "saci/tree/model/detail/update_parent_ptr.hpp"
#include "saci/tree/model/detail/sync_with_domain.hpp"
| 26.879433
| 90
| 0.656201
|
ricardocosme
|
b7c3c039334d9b923f1e737af3dd25ea9d5ff85a
| 909
|
ipp
|
C++
|
implement/oalplus/context.ipp
|
Extrunder/oglplus
|
c7c8266a1571d0b4c8b02d9c8ca6a7b6a6f51791
|
[
"BSL-1.0"
] | 459
|
2016-03-16T04:11:37.000Z
|
2022-03-31T08:05:21.000Z
|
implement/oalplus/context.ipp
|
Extrunder/oglplus
|
c7c8266a1571d0b4c8b02d9c8ca6a7b6a6f51791
|
[
"BSL-1.0"
] | 4
|
2015-08-21T02:29:15.000Z
|
2020-05-02T13:50:36.000Z
|
implement/oalplus/context.ipp
|
Extrunder/oglplus
|
c7c8266a1571d0b4c8b02d9c8ca6a7b6a6f51791
|
[
"BSL-1.0"
] | 47
|
2016-05-31T15:55:52.000Z
|
2022-03-28T14:49:40.000Z
|
/**
* @file oalplus/context.ipp
* @brief Implementation of Context functions
*
* @author Matus Chochlik
*
* Copyright 2010-2014 Matus Chochlik. 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)
*/
namespace oalplus {
OALPLUS_LIB_FUNC
ContextOps ContextOps::
Current(void)
{
::ALCcontext* context = OALPLUS_ALFUNC(alc,GetCurrentContext)();
OALPLUS_HANDLE_ERROR_IF(
!context,
ALC_INVALID_CONTEXT,
"Failed to get current AL context",
Error,
ALLib("alc").
ALFunc("GetCurrentContext")
);
::ALCdevice* device = OALPLUS_ALFUNC(alc,GetContextsDevice)(context);
OALPLUS_HANDLE_ERROR_IF(
!device,
ALC_INVALID_DEVICE,
"Failed to get AL context's device",
Error,
ALLib("alc").
ALFunc("GetContextsDevice")
);
return ContextOps(device, context);
}
} // namespace oalplus
| 21.642857
| 70
| 0.728273
|
Extrunder
|
b7c4cc1029ec3ce05380092ae644a9095ba94d95
| 95
|
cpp
|
C++
|
Society2.0/Society2.0/CityGroup.cpp
|
simsim314/Society2.0
|
a95e42122e2541b7544dd641247681996f1e625a
|
[
"Unlicense"
] | 1
|
2019-07-11T13:10:43.000Z
|
2019-07-11T13:10:43.000Z
|
Society2.0/Society2.0/CityGroup.cpp
|
mdheller/Society2.0
|
a95e42122e2541b7544dd641247681996f1e625a
|
[
"Unlicense"
] | 1
|
2019-02-19T12:32:52.000Z
|
2019-03-07T20:49:50.000Z
|
Society2.0/Society2.0/CityGroup.cpp
|
mdheller/Society2.0
|
a95e42122e2541b7544dd641247681996f1e625a
|
[
"Unlicense"
] | 1
|
2020-01-10T12:37:30.000Z
|
2020-01-10T12:37:30.000Z
|
#include "CityGroup.h"
CityGroup::CityGroup()
{
}
CityGroup::~CityGroup()
{
}
| 7.307692
| 24
| 0.557895
|
simsim314
|
b7c763c2ff0d1fa284137d82f57e42af6a7ce245
| 75,437
|
cpp
|
C++
|
MultiPlane/lens_halos.cpp
|
glenco/SLsimLib
|
fb7a3c450d2487a823fa3f0ae8c8ecf7945c3ebb
|
[
"MIT"
] | 2
|
2017-03-22T13:18:32.000Z
|
2021-05-01T01:54:31.000Z
|
MultiPlane/lens_halos.cpp
|
glenco/SLsimLib
|
fb7a3c450d2487a823fa3f0ae8c8ecf7945c3ebb
|
[
"MIT"
] | 49
|
2016-10-05T03:08:38.000Z
|
2020-11-03T15:39:26.000Z
|
MultiPlane/lens_halos.cpp
|
glenco/SLsimLib
|
fb7a3c450d2487a823fa3f0ae8c8ecf7945c3ebb
|
[
"MIT"
] | 1
|
2017-07-10T08:52:53.000Z
|
2017-07-10T08:52:53.000Z
|
/*
* lens_halos.cpp
*
* Created on: 06.05.2013
* Author: mpetkova
*/
#include "slsimlib.h"
using namespace std;
/// Shell constructor
LensHalo::LensHalo(){
rscale = 1.0;
mass = Rsize = Rmax = xmax = posHalo[0] = posHalo[1] = 0.0;
stars_implanted = false;
elliptical_flag = false;
Dist = -1;
stars_N =0.0;
zlens = 0.0;
}
LensHalo::LensHalo(PosType z,const COSMOLOGY &cosmo){
rscale = 1.0;
mass = Rsize = Rmax = xmax = posHalo[0] = posHalo[1] = 0.0;
stars_implanted = false;
elliptical_flag = false;
Dist = cosmo.angDist(z);
stars_N =0.0;
zlens = z;
}
//LensHalo::LensHalo(InputParams& params,COSMOLOGY &cosmo,bool needRsize){
// Dist = -1;
// assignParams(params,needRsize);
// stars_implanted = false;
// posHalo[0] = posHalo[1] = 0.0;
// elliptical_flag = false;
// setDist(cosmo);
//}
//LensHalo::LensHalo(InputParams& params,bool needRsize){
// Dist = -1;
// assignParams(params,needRsize);
// stars_implanted = false;
// posHalo[0] = posHalo[1] = 0.0;
// elliptical_flag = false;
//}
LensHalo::LensHalo(const LensHalo &h){
idnumber = h.idnumber; /// Identification number of halo. It is not always used.
Dist = h.Dist;
posHalo[0] = h.posHalo[0]; posHalo[1] = h.posHalo[1];
zlens = h. zlens;
mass = h.mass;
Rsize = h.Rsize;
mnorm = h.mnorm;
Rmax = h.Rmax;
stars_index = h.stars_index;
stars_xp = h.stars_xp;
stars_N = h.stars_N;
star_theta_force = h.star_theta_force;
if(stars_N > 1){
star_tree = new TreeQuadParticles<StarType>(stars_xp.data(),stars_N
,false,false,0,4,star_theta_force);
}else{
star_tree = nullptr;
}
star_massscale = h.star_massscale;
star_fstars = h.star_fstars;
star_Nregions = h.star_Nregions;
star_region = h.star_region;
beta = h.beta;
Rmax_to_Rsize_ratio = h.Rmax_to_Rsize_ratio;
rscale = h.rscale;
stars_implanted = h.stars_implanted;
main_stars_imf_type = h.main_stars_imf_type;
main_stars_min_mass = h. main_stars_min_mass;
main_stars_max_mass = h.main_stars_max_mass;
main_ellip_method = h.main_ellip_method;
bend_mstar =h.bend_mstar;
lo_mass_slope = h.lo_mass_slope;
hi_mass_slope = h.hi_mass_slope;
star_Sigma = h.star_Sigma;
star_xdisk = h.star_xdisk;
xmax = h.xmax;
mass_norm_factor = h.mass_norm_factor;
pa = h.pa;
fratio = h.fratio;
elliptical_flag = h.elliptical_flag;
switch_flag = h.switch_flag;
//Nmod = h.Nmod;
};
LensHalo & LensHalo::operator=(LensHalo &&h){
if (this != &h){
idnumber = h.idnumber; /// Identification number of halo. It is not always used.
Dist = h.Dist;
posHalo[0] = h.posHalo[0]; posHalo[1] = h.posHalo[1];
zlens = h. zlens;
mass = h.mass;
Rsize = h.Rsize;
mnorm = h.mnorm;
Rmax = h.Rmax;
stars_index = h.stars_index;
stars_xp = h.stars_xp;
stars_N = h.stars_N;
star_theta_force = h.star_theta_force;
delete star_tree;
star_tree = h.star_tree;
h.star_tree = nullptr;
star_massscale = h.star_massscale;
star_fstars = h.star_fstars;
star_Nregions = h.star_Nregions;
star_region = h.star_region;
beta = h.beta;
Rmax_to_Rsize_ratio = h.Rmax_to_Rsize_ratio;
rscale = h.rscale;
stars_implanted = h.stars_implanted;
main_stars_imf_type = h.main_stars_imf_type;
main_stars_min_mass = h. main_stars_min_mass;
main_stars_max_mass = h.main_stars_max_mass;
main_ellip_method = h.main_ellip_method;
bend_mstar =h.bend_mstar;
lo_mass_slope = h.lo_mass_slope;
hi_mass_slope = h.hi_mass_slope;
star_Sigma = h.star_Sigma;
star_xdisk = h.star_xdisk;
xmax = h.xmax;
mass_norm_factor = h.mass_norm_factor;
pa = h.pa;
fratio = h.fratio;
elliptical_flag = h.elliptical_flag;
switch_flag = h.switch_flag;
//Nmod = h.Nmod;
}
return *this;
};
LensHalo & LensHalo::operator=(const LensHalo &h){
if(this == &h) return *this;
idnumber = h.idnumber; /// Identification number of halo. It is not always used.
Dist = h.Dist;
posHalo[0] = h.posHalo[0]; posHalo[1] = h.posHalo[1];
zlens = h. zlens;
mass = h.mass;
Rsize = h.Rsize;
mnorm = h.mnorm;
Rmax = h.Rmax;
stars_index = h.stars_index;
stars_xp = h.stars_xp;
stars_N = h.stars_N;
star_theta_force = h.star_theta_force;
if(stars_N > 1){
star_tree = new TreeQuadParticles<StarType>(stars_xp.data(),stars_N
,false,false,0,4,star_theta_force);
}else{
star_tree = nullptr;
}
star_massscale = h.star_massscale;
star_fstars = h.star_fstars;
star_Nregions = h.star_Nregions;
star_region = h.star_region;
beta = h.beta;
Rmax_to_Rsize_ratio = h.Rmax_to_Rsize_ratio;
rscale = h.rscale;
stars_implanted = h.stars_implanted;
main_stars_imf_type = h.main_stars_imf_type;
main_stars_min_mass = h. main_stars_min_mass;
main_stars_max_mass = h.main_stars_max_mass;
main_ellip_method = h.main_ellip_method;
bend_mstar =h.bend_mstar;
lo_mass_slope = h.lo_mass_slope;
hi_mass_slope = h.hi_mass_slope;
star_Sigma = h.star_Sigma;
star_xdisk = h.star_xdisk;
xmax = h.xmax;
mass_norm_factor = h.mass_norm_factor;
pa = h.pa;
fratio = h.fratio;
elliptical_flag = h.elliptical_flag;
switch_flag = h.switch_flag;
//Nmod = h.Nmod;
return *this;
};
void LensHalo::initFromMassFunc(float my_mass, float my_Rsize, float my_rscale
, PosType my_slope, long *seed){
mass = my_mass;
Rsize = my_Rsize;
rscale = my_rscale;
xmax = Rsize/rscale;
}
void LensHalo::error_message1(std::string parameter,std::string file){
ERROR_MESSAGE();
std::cout << "Parameter " << parameter << " is needed to construct a LensHalo. It needs to be set in parameter file " << file << "!" << std::endl;
throw std::runtime_error(parameter);
}
void LensHalo::assignParams(InputParams& params,bool needRsize){
if(!params.get("main_mass",mass)) error_message1("main_mass",params.filename());
if(needRsize){ // this might not be required for lenses like NSIE
if(!params.get("main_Rsize",Rsize)) error_message1("main_Rsize",params.filename());
}
if(!params.get("main_zlens",zlens)) error_message1("main_zlens",params.filename());
}
void LensHalo::PrintStars(bool show_stars)
{
std::cout << std::endl << "Nstars "<<stars_N << std::endl << std::endl;
if(stars_N>0){
if(star_Nregions > 0)
std::cout << "stars_Nregions "<<star_Nregions << std::endl;
std::cout << "stars_massscale "<<star_massscale << std::endl;
std::cout << "stars_fstars "<<star_fstars << std::endl;
std::cout << "stars_theta_force "<<star_theta_force << std::endl;
if(show_stars){
if(stars_implanted){
for(int i=0 ; i < stars_N ; ++i) std::cout << " x["<<i<<"]="
<< stars_xp[i][0] << " " << stars_xp[i][1] << std::endl;
}else std::cout << "stars are not implanted yet" << std::endl;
}
}
}
PixelMap LensHalo::map_variables(
LensingVariable lensvar /// lensing variable - KAPPA, ALPHA1, ALPHA2, GAMMA1, GAMMA2 or PHI
,size_t Nx
,size_t Ny
,double res /// resolution in physical Mpc on the lens plane
){
Point_2d center;
PixelMap map(center.data(),Nx,Ny,res);
Point_2d x,alpha;
size_t N = Nx*Ny;
KappaType kappa,phi,gamma[3];
for(size_t i = 0 ; i < N ; ++i){
map.find_position(x.data(),i);
force_halo(alpha.data(),&kappa,gamma,&phi,x.data());
switch (lensvar) {
case ALPHA1:
map[i] = alpha[0];
break;
case ALPHA2:
map[i] = alpha[1];
break;
case GAMMA1:
map[i] = gamma[0];
break;
case GAMMA2:
map[i] = gamma[1];
break;
case KAPPA:
map[i] = kappa;
break;
case PHI:
map[i] = phi;
break;
default:
break;
}
}
return map;
}
/// calculates the deflection etc. caused by stars alone
void LensHalo::force_stars(
PosType *alpha /// mass/Mpc
,KappaType *kappa
,KappaType *gamma
,PosType const *xcm /// physical position on lens plane
)
{
PosType alpha_tmp[2];
KappaType gamma_tmp[3], tmp = 0;
KappaType phi;
gamma_tmp[0] = gamma_tmp[1] = gamma_tmp[2] = 0.0;
alpha_tmp[0] = alpha_tmp[1] = 0.0;
substract_stars_disks(xcm,alpha,kappa,gamma);
// do stars with tree code
star_tree->force2D_recur(xcm,alpha_tmp,&tmp,gamma_tmp,&phi);
alpha[0] -= star_massscale*alpha_tmp[0];
alpha[1] -= star_massscale*alpha_tmp[1];
{
*kappa += star_massscale*tmp;
gamma[0] -= star_massscale*gamma_tmp[0];
gamma[1] -= star_massscale*gamma_tmp[1];
}
}
LensHalo::~LensHalo()
{
}
const long LensHaloNFW::NTABLE = 10000;
const PosType LensHaloNFW::maxrm = 100.0;
int LensHaloNFW::count = 0;
PosType* LensHaloNFW::xtable = NULL;
PosType* LensHaloNFW::ftable = NULL;
PosType* LensHaloNFW::gtable = NULL;
PosType* LensHaloNFW::g2table = NULL;
PosType* LensHaloNFW::htable = NULL;
PosType* LensHaloNFW::xgtable = NULL;
PosType*** LensHaloNFW::modtable= NULL; // was used for Ansatz IV
LensHaloNFW::LensHaloNFW()
: LensHalo(), gmax(0)
{
LensHalo::setRsize(1.0);
Rmax = LensHalo::getRsize();
LensHalo::setMass(0.0);
LensHalo::setZlens(0,COSMOLOGY(Planck18));
LensHalo::Dist = -1; // to be set later
fratio=1;
pa = stars_N = 0;
stars_implanted = false;
rscale = LensHalo::getRsize()/5;
xmax = LensHalo::getRsize()/rscale;
make_tables();
gmax = InterpolateFromTable(gtable, xmax);
set_flag_elliptical(false);
}
LensHaloNFW::LensHaloNFW(float my_mass,float my_Rsize,PosType my_zlens,float my_concentration
,float my_fratio,float my_pa,int my_stars_N,const COSMOLOGY &cosmo
,EllipMethod my_ellip_method
){
LensHalo::setRsize(my_Rsize);
LensHalo::setMass(my_mass);
LensHalo::setZlens(my_zlens,cosmo);
fratio=my_fratio, pa=my_pa, stars_N=my_stars_N, main_ellip_method=my_ellip_method;
stars_implanted = false;
rscale = LensHalo::getRsize()/my_concentration;
xmax = LensHalo::getRsize()/rscale;
make_tables();
gmax = InterpolateFromTable(gtable, xmax);
set_slope(1);
/// If the axis ratio given in the parameter file is set to 1 all ellipticizing routines are skipped.
if(fratio!=1){
Rmax = Rmax_to_Rsize_ratio*LensHalo::getRsize();
//std::cout << getEllipMethod() << " method to ellipticise" << std::endl;
if(getEllipMethod()==Fourier){
std::cout << "NFW constructor: slope set to " << get_slope() << std::endl;
calcModes(fratio, get_slope(), pa, mod); // to ellipticize potential instead of kappa take calcModes(fratio, 2-get_slope(), pa, mod);
std::cout << "NFW constructor: Fourier modes computed" << std::endl;
for(int i=1;i<Nmod;i++){
if(mod[i]!=0){set_flag_elliptical(true);};
}
}else set_flag_elliptical(true);
if (getEllipMethod()==Pseudo or getEllipMethod()==Fourier){
set_norm_factor();
set_switch_flag(true);
}
}else{
set_flag_elliptical(false);
Rmax = LensHalo::getRsize();
}
}
/* LensHalo::LensHalo(mass,Rsize,zlens, // base
rscale,fratio,pa,stars_N, //NFW,Hernquist, Jaffe
rscale,fratio,pa,beta // Pseudo NFW
rscale,fratio,pa,sigma,rcore // NSIE
zlens,stars_N // dummy
){
stars_implanted = false;
posHalo[0] = posHalo[1] = 0.0;
}*/
//LensHaloNFW::LensHaloNFW(InputParams& params):LensHalo(params)
//{
// assignParams(params);
// make_tables();
// gmax = InterpolateFromTable(gtable, xmax);
//
// mnorm = renormalization(LensHalo::getRsize());
//
// std::cout << "mass normalization: " << mnorm << std::endl;
//
// // If the 2nd argument in calcModes(fratio, slope, pa, mod), the slope, is set to 1 it yields an elliptical kappa contour of given axis ratio (fratio) at the radius where the slope of the 3D density profile is -2, which is defined as the scale radius for the NFW profile. To ellipticize the potential instead of the convergence use calcModes(fratio, 2-get_slope(), pa, mod), this produces also an ellipse in the convergence map, but at the radius where the slope is 2-get_slope().
// set_slope(1);
// // If the axis ratio given in the parameter file is set to 1 all ellipticizing routines are skipped.
// if(fratio!=1){
// Rmax = Rmax_to_Rsize_ratio*LensHalo::getRsize();
// //std::cout << getEllipMethod() << " method to ellipticise" << std::endl;
// if(getEllipMethod()==Fourier){
// std::cout << "NFW constructor: slope set to " << get_slope() << std::endl;
// //for(int i=1;i<20;i++){
// // calcModes(fratio, 0.1*i, pa, mod);
// //}
// //calcModes(fratio, get_slope()-0.5, pa, mod); // to ellipticize potential instead of kappa take calcModes(fratio, 2-get_slope(), pa, mod);
// calcModes(fratio, get_slope(), pa, mod); // to ellipticize potential instead of kappa take calcModes(fratio, 2-get_slope(), pa, mod);
// //calcModes(fratio, get_slope()+0.5, pa, mod); // to ellipticize potential instead of kappa take calcModes(fratio, 2-get_slope(), pa, mod);
//
// for(int i=1;i<Nmod;i++){
// if(mod[i]!=0){set_flag_elliptical(true);};
// }
// }else set_flag_elliptical(true);
// if (getEllipMethod()==Pseudo){
// set_norm_factor();
// }
// }else{
// set_flag_elliptical(false);
// Rmax = LensHalo::getRsize();
// }
//}
void LensHaloNFW::make_tables(){
if(count == 0){
int i;
//struct Ig_func g(*this);
PosType x, dx = maxrm/(PosType)NTABLE;
xtable = new PosType[NTABLE];
ftable = new PosType[NTABLE];
gtable = new PosType[NTABLE];
g2table = new PosType[NTABLE];
htable = new PosType[NTABLE];
xgtable = new PosType[NTABLE];
for(i = 0 ; i< NTABLE; i++){
x = i*dx;
xtable[i] = x;
ftable[i] = ffunction(x);
gtable[i] = gfunction(x);
g2table[i] = g2function(x);
htable[i] = hfunction(x);
if(i==0){xgtable[i]=0;}
if(i!=0){
xgtable[i] = alpha_int(x);
//Utilities::nintegrate<Ig_func>(g,1E-4,x,dx/10.);
}
}
// modtable[axis ratio 100][potential slope beta 1000][Nmods 32] for Ansatz IV
int j;
modtable = new PosType**[100];
for(i = 0; i < 100; i++){
modtable[i] = new PosType*[200];
for(j = 0; j< 200; j++){
modtable[i][j] = new PosType[Nmod];
}
}
/*
for(i = 0; i<99; i++){
std::cout<< i << std::endl;
PosType iq=0.01*(i+1);
for(j = 0; j< 200; j++){
PosType beta_r=0.01*(j+1);
calcModesC(beta_r, iq, pa, mod);
for(k=0;k<Nmod;k++){
modtable[i][j][k]=mod[k];
}
}
}
*/
}
count++;
}
// InterpolateModes was used for Ansatz IV and is an efficient way to calculate the Fourier modes used for elliptisizing the isotropic profiles before the program starts
PosType LensHaloNFW::InterpolateModes(int whichmod, PosType q, PosType b){
PosType x1,x2,y1,y2,f11,f12,f21,f22;
int i,j,k;
int NTABLEB=200;
int NTABLEQ=99;
PosType const maxb=2.0;
PosType const maxq=0.99;
k=whichmod;
j=(int)(b/maxb*NTABLEB);
i=(int)(q/maxq*NTABLEQ);
f11=modtable[i][j][k];
f12=modtable[i][j+1][k];
f21=modtable[i+1][j][k];
f22=modtable[i+1][j+1][k];
x1=i*maxq/NTABLEQ;
x2=(i+1)*maxq/NTABLEQ;
y1=j*maxb/NTABLEB;
y2=(j+1)*maxb/NTABLEB;
//std::cout << "x12y12: " << q << " " << x1 << " " << x2 << " "<< b << " " << y1 << " " << y2 << " " << std::endl;
//std::cout << "IM: " << f11 << " " << f12 << " " << f21 << " " << f22 << " " << res << std::endl;
return 1.0/(x2-x1)/(y2-y1)*(f11*(x2-q)*(y2-b)+f21*(q-x1)*(y2-b)+f12*(x2-q)*(b-y1)+f22*(q-x1)*(b-y1));
}
PosType LensHaloNFW::InterpolateFromTable(PosType *table, PosType y) const{
int j;
j=(int)(y/maxrm*NTABLE);
//std::cout << "Interp: " << std::setprecision(7) << y-0.95 << " " << std::setprecision(7) << xtable[j]-0.95 << " " << xtable[j+1] <<std::endl;
assert(y>=xtable[j] && y<=xtable[j+1]);
if (j==0)
{
if (table==ftable) return ffunction(y);
if (table==gtable) return gfunction(y);
if (table==g2table) return g2function(y);
if (table==htable) return hfunction(y);
if (table==xgtable) return alpha_int(y);
}
return (table[j+1]-table[j])/(xtable[j+1]-xtable[j])*(y-xtable[j]) + table[j];
}
void LensHaloNFW::assignParams(InputParams& params){
PosType tmp;
if(!params.get("main_zlens",tmp)) error_message1("main_zlens",params.filename());
if(!params.get("main_concentration",rscale)) error_message1("main_concentration",params.filename());
if(!params.get("main_axis_ratio",fratio)){fratio=1; std::cout << "main_axis_ratio not defined in file " << params.filename() << ", hence set to 1." << std::endl;};
if(!params.get("main_pos_angle",pa)){pa=0; std::cout << "main_pos_angle not defined in file " << params.filename() << ", hence set to 0." << std::endl;};
if(!params.get("main_ellip_method",main_ellip_method)){if(fratio!=1){main_ellip_method=Pseudo;std::cout << "main_ellip_method is not defined in file " << params.filename() << ", hence set to Pseudo." << endl;};};
rscale = LensHalo::getRsize()/rscale; // was the concentration
xmax = LensHalo::getRsize()/rscale;
}
LensHaloNFW::~LensHaloNFW(){
--count;
if(count == 0){
delete[] xtable;
delete[] gtable;
delete[] ftable;
delete[] g2table;
delete[] htable;
delete[] xgtable;
// was used for Ansatz IV
for(int i=0; i<99; i++){
for(int j=0; j<200; j++){
delete[] modtable[i][j];
}
delete[] modtable[i];
}
delete[] modtable;
}
}
/// Sets the profile to match the mass, Vmax and R_halfmass
void LensHaloNFW::initFromFile(float my_mass, long *seed, float vmax, float r_halfmass){
LensHalo::setMass(my_mass);
NFW_Utility nfw_util;
// Find the NFW profile with the same mass, Vmax and R_halfmass
nfw_util.match_nfw(vmax,r_halfmass,LensHalo::get_mass(),&rscale,&Rmax);
LensHalo::setRsize(Rmax);
rscale = LensHalo::getRsize()/rscale; // Was the concentration
xmax = LensHalo::getRsize()/rscale;
gmax = InterpolateFromTable(gtable,xmax);
// std::cout << Rmax_halo << " " << LensHalo::getRsize() << std::endl;
}
void LensHaloNFW::initFromMassFunc(float my_mass, float my_Rsize, float my_rscale, PosType my_slope, long* seed)
{
LensHalo::initFromMassFunc(my_mass, my_Rsize, my_rscale, my_slope, seed);
gmax = InterpolateFromTable(gtable,xmax);
}
const long LensHaloPseudoNFW::NTABLE = 10000;
const PosType LensHaloPseudoNFW::maxrm = 100.0;
int LensHaloPseudoNFW::count = 0;
PosType* LensHaloPseudoNFW::xtable = NULL;
PosType* LensHaloPseudoNFW::mhattable = NULL;
LensHaloPseudoNFW::LensHaloPseudoNFW()
: LensHalo()
{
}
/// constructor
LensHaloPseudoNFW::LensHaloPseudoNFW(
float my_mass /// mass in solar masses
,float my_Rsize /// maximum radius in Mpc
,PosType my_zlens /// redshift
,float my_concentration /// Rsize/rscale
,PosType my_beta /// large r slope, see class description
,float my_fratio /// axis ratio
,float my_pa /// position angle
,int my_stars_N /// number of stars, not yet implanted
,const COSMOLOGY &cosmo
,EllipMethod my_ellip_method /// ellipticizing method
)
{
LensHalo::setMass(my_mass);
LensHalo::setZlens(my_zlens,cosmo);
LensHalo::setRsize(my_Rsize);
beta = my_beta;
fratio = my_fratio;
pa = my_pa;
stars_N = my_stars_N;
stars_implanted = false;
rscale = LensHalo::getRsize()/my_concentration;
xmax = LensHalo::getRsize()/rscale;
make_tables();
if(fratio!=1){
Rmax = Rmax_to_Rsize_ratio*LensHalo::getRsize();
//std::cout << getEllipMethod() << " method to ellipticise" << std::endl;
if(getEllipMethod()==Fourier){
std::cout << "Note: Fourier modes set to ellipticize kappa at slope main_slope+0.5, i.e. "<< get_slope()+0.5 << std::endl;
calcModes(fratio, get_slope()+0.5, pa, mod);
for(int i=1;i<Nmod;i++){
if(mod[i]!=0){set_flag_elliptical(true);};
}
}else set_flag_elliptical(true);
if (getEllipMethod()==Pseudo){
set_norm_factor();
}
}else{
set_flag_elliptical(false);
Rmax = LensHalo::getRsize();
}
}
// The Fourier modes set to ellipticize kappa at slope main_slope+0.5, i.e. e.g. 1.5 for main_slope = 1. Note that set_slope is overridden for PseudoNFW to recalculate tables for different beta. But only fixed values of beta, i.e. 1,2 and >=3 are allowed!
//LensHaloPseudoNFW::LensHaloPseudoNFW(InputParams& params):LensHalo(params)
//{
// assignParams(params);
// make_tables();
// if(fratio!=1){
// Rmax = Rmax_to_Rsize_ratio*LensHalo::getRsize();
// //std::cout << getEllipMethod() << " method to ellipticise" << std::endl;
// if(getEllipMethod()==Fourier){
// std::cout << "Note: Fourier modes set to ellipticize kappa at slope main_slope+0.5, i.e. "<< get_slope()+0.5 << std::endl;
// calcModes(fratio, get_slope()+0.5, pa, mod);
// for(int i=1;i<Nmod;i++){
// //std::cout << mod[i] << std::endl;
// if(mod[i]!=0){set_flag_elliptical(true);};
// }
// }else set_flag_elliptical(true);
// if (getEllipMethod()==Pseudo){
// set_norm_factor();
// }
// }else{
// set_flag_elliptical(false);
// Rmax = LensHalo::getRsize();
// }
//}
/// Auxiliary function for PseudoNFW profile
// previously defined in tables.cpp
PosType LensHaloPseudoNFW::mhat(PosType y, PosType beta) const{
if(y==0) y=1e-5;
if(beta == 1.0) return y - log(1+y);
if(beta == 2.0) return log(1+y) - y/(1+y);
if(beta>=3.0) return ( (1 - beta)*y + pow(1+y,beta-1) - 1)/(beta-2)/(beta-1)/pow(1+y,beta-1);
ERROR_MESSAGE();
std::cout << "Only beta ==1, ==2 and >=3 are valid" << std::endl;
exit(1);
return 0.0;
}
void LensHaloPseudoNFW::make_tables(){
if(count == 0){
int i;
PosType x, dx = maxrm/(PosType)NTABLE;
xtable = new PosType[NTABLE];
mhattable = new PosType[NTABLE];
for(i = 0 ; i< NTABLE; i++){
x = i*dx;
xtable[i] = x;
mhattable[i] = mhat(x,beta);
}
count++;
}
}
PosType LensHaloPseudoNFW::gfunction(PosType y) const{
int j;
j=(int)(y/maxrm*NTABLE);
assert(y>=xtable[j] && y<=xtable[j+1]);
if (j==0) return mhat(y,beta);
return ((mhattable[j+1]-mhattable[j])/(xtable[j+1]-xtable[j])*(y-xtable[j]) + mhattable[j]);
}
PosType LensHaloPseudoNFW::InterpolateFromTable(PosType y) const{
int j;
j=(int)(y/maxrm*NTABLE);
assert(y>=xtable[j] && y<=xtable[j+1]);
if (j==0) return mhat(y,beta);
return (mhattable[j+1]-mhattable[j])/(xtable[j+1]-xtable[j])*(y-xtable[j]) + mhattable[j];
}
void LensHaloPseudoNFW::initFromMassFunc(float my_mass, float my_Rsize, float my_rscale, PosType my_slope, long *seed){
LensHalo::initFromMassFunc(my_mass,my_Rsize,my_rscale,my_slope,seed);
beta = my_slope;
xmax = my_Rsize/my_rscale;
make_tables();
}
void LensHaloPseudoNFW::assignParams(InputParams& params){
if(!params.get("main_concentration",rscale)) error_message1("main_concentration",params.filename());
if(!params.get("main_slope",beta)) error_message1("main_slope",params.filename());
if(!params.get("main_axis_ratio",fratio)){fratio=1; std::cout << "main_axis_ratio not defined in file " << params.filename() << ", hence set to 1." << std::endl;};
if(!params.get("main_pos_angle",pa)){pa=0; std::cout << "main_pos_angle not defined in file " << params.filename() << ", hence set to 0." << std::endl;};
if(!params.get("main_ellip_method",main_ellip_method)){if(fratio!=1){main_ellip_method=Pseudo;std::cout << "main_ellip_method is not defined in file " << params.filename() << ", hence set to Pseudo. CAUTION: Ellipticizing methods have not been tested with PseudoNFW yet!" << endl;};};
rscale = LensHalo::getRsize()/rscale; // was the concentration
xmax = LensHalo::getRsize()/rscale;
}
LensHaloPseudoNFW::~LensHaloPseudoNFW(){
--count;
if(count == 0){
delete[] xtable;
delete[] mhattable;
}
}
LensHaloPowerLaw::LensHaloPowerLaw() : LensHalo(){
beta = 1;
fratio = 1;
rscale = xmax = 1.0;
}
/// constructor
LensHaloPowerLaw::LensHaloPowerLaw(
float my_mass /// mass of halo in solar masses
,float my_Rsize /// maximum radius of halo in Mpc
,PosType my_zlens /// redshift of halo
,PosType my_beta /// logarithmic slop of surface density, kappa \propto r^{-beta}
,float my_fratio /// axis ratio in asymetric case
,float my_pa /// position angle
,int my_stars_N /// number of stars, not yet implanted
,const COSMOLOGY &cosmo
,EllipMethod my_ellip_method /// ellipticizing method
){
LensHalo::setMass(my_mass);
LensHalo::setZlens(my_zlens,cosmo);
LensHalo::setRsize(my_Rsize);
beta=my_beta;
fratio=my_fratio, pa=my_pa, main_ellip_method=my_ellip_method, stars_N=my_stars_N;
stars_implanted = false;
rscale = 1;
xmax = LensHalo::getRsize()/rscale ; /// xmax needs to be in initialized before the mass_norm_factor for Pseudo ellip method is calculated via set_norm_factor()
//mnorm = renormalization(get_Rmax());
//std::cout << "PA in PowerLawConstructor: " << pa << std::endl;
if(fratio!=1){
Rmax = Rmax_to_Rsize_ratio*LensHalo::getRsize();
//std::cout << getEllipMethod() << " method to ellipticise" << std::endl;
if(getEllipMethod()==Fourier){
calcModes(fratio, beta, pa, mod);
for(int i=1;i<Nmod;i++){
//std::cout << i << " " << mod[i] << std::endl;
if(mod[i]!=0){set_flag_elliptical(true);};
}
}else set_flag_elliptical(true);
if (getEllipMethod()==Pseudo){
fratio=0.00890632+0.99209115*pow(fratio,0.33697702); /// translate fratio's needed for kappa into fratio used for potential
//std::cout << "Pseudo-elliptical method requires fratio transformation, new fratio=" << fratio << std::endl;
set_norm_factor();
}
}else{
set_flag_elliptical(false);
Rmax = LensHalo::getRsize();
}
}
//LensHaloPowerLaw::LensHaloPowerLaw(InputParams& params):LensHalo(params)
//{
// assignParams(params);
// /// If the 2nd argument in calcModes(fratio, slope, pa, mod), the slope, is set to 1 it yields an elliptical kappa contour of given axis ratio (fratio) at the radius where the slope of the 3D density profile is -2, which is defined as the scale radius for the NFW profile. To ellipticize the potential instead of the convergence use calcModes(fratio, 2-get_slope(), pa, mod), this produces also an ellipse in the convergence map, but at the radius where the slope is 2-get_slope().
// /// If the axis ratio given in the parameter file is set to 1 all ellipticizing routines are skipped.
//
// // rscale = xmax = 1.0; // Commented in order to have a correct computation of the potential term in the time delay.
// // Replacing it by :
// rscale = 1;
// xmax = LensHalo::getRsize()/rscale;
//
// if(fratio!=1){
// Rmax = Rmax_to_Rsize_ratio*LensHalo::getRsize();
//
// //std::cout << getEllipMethod() << " method to ellipticise" << std::endl;
// if(getEllipMethod()==Fourier){
// calcModes(fratio, beta, pa, mod);
// for(int i=1;i<Nmod;i++){
// //std::cout << i << " " << mod[i] << " " << fratio << " " << beta << " " << pa << " " << std::endl;
// if(mod[i]!=0){set_flag_elliptical(true);};
// }
// }else set_flag_elliptical(true);
// if (getEllipMethod()==Pseudo){
// set_norm_factor();
// }
// }else{
// set_flag_elliptical(false);
// Rmax = LensHalo::getRsize();
// }
// // rscale = xmax = 1.0;
// // mnorm = renormalization(get_Rmax());
// mnorm = 1.;
//}
void LensHaloPowerLaw::initFromMassFunc(float my_mass, float my_Rsize, float my_rscale, PosType my_slope, long *seed){
LensHalo::initFromMassFunc(my_mass,my_Rsize,my_rscale,my_slope,seed);
beta = my_slope;
xmax = my_Rsize/my_rscale;
}
void LensHaloPowerLaw::assignParams(InputParams& params){
if(!params.get("main_slope",beta)) error_message1("main_slope, example 1",params.filename());
//if(beta>=2.0) error_message1("main_slope < 2",params.filename());
if(!params.get("main_axis_ratio",fratio)){fratio=1; std::cout << "main_axis_ratio not defined in file " << params.filename() << ", hence set to 1." << std::endl;};
if(!params.get("main_pos_angle",pa)){pa=0.0; std::cout << "main_pos_angle not defined in file " << params.filename() << ", hence set to 0." << std::endl;};
if(!params.get("main_ellip_method",main_ellip_method)){if(fratio!=1){main_ellip_method=Pseudo;std::cout << "main_ellip_method is not defined in file " << params.filename() << ", hence set to Pseudo." << endl;};};
if(!params.get("main_stars_N",stars_N)) error_message1("main_stars_N",params.filename());
else if(stars_N){
assignParams_stars(params);
}
}
LensHaloPowerLaw::~LensHaloPowerLaw(){
}
LensHaloTNSIE::LensHaloTNSIE(
float my_mass
,PosType my_zlens
,float my_sigma
,float my_rcore
,float my_fratio
,float my_pa
,const COSMOLOGY &cosmo
,float f)
:LensHalo(),sigma(my_sigma),fratio(my_fratio)
,pa(PI/2 - my_pa),rcore(my_rcore)
{
rscale=1.0;
LensHalo::setMass(my_mass);
LensHalo::setZlens(my_zlens,cosmo);
if(fratio > 1.0 || fratio < 0.01) throw std::invalid_argument("invalid fratio");
units = sigma*sigma/lightspeed/lightspeed/Grav;///sqrt(fratio); // mass/distance(physical);
rtrunc = my_mass*sqrt(my_fratio)/units/PI + rcore;
Rmax = f * rtrunc;
LensHalo::setRsize(Rmax);
}
void LensHaloTNSIE::force_halo(
PosType *alpha
,KappaType *kappa
,KappaType *gamma
,KappaType *phi
,PosType const *xcm
,bool subtract_point /// if true contribution from a point mass is subtracted
,PosType screening /// the factor by which to scale the mass for screening of the point mass subtraction
)
{
PosType rcm2 = xcm[0]*xcm[0] + xcm[1]*xcm[1];
if(rcm2 < 1e-20) rcm2 = 1e-20;
if(rcm2 < Rmax*Rmax){
PosType tmp[2]={0,0};
alphaNSIE(tmp,xcm,fratio,rcore,pa);
alpha[0] += units*tmp[0];
alpha[1] += units*tmp[1];
alphaNSIE(tmp,xcm,fratio,rtrunc,pa);
alpha[0] -= units*tmp[0];
alpha[1] -= units*tmp[1];
{
KappaType tmp[2]={0,0};
*kappa += units*(kappaNSIE(xcm,fratio,rcore,pa) - kappaNSIE(xcm,fratio,rtrunc,pa) );
gammaNSIE(tmp,xcm,fratio,rcore,pa);
gamma[0] += units*tmp[0];
gamma[1] += units*tmp[1];
gammaNSIE(tmp,xcm,fratio,rtrunc,pa);
gamma[0] -= units*tmp[0];
gamma[1] -= units*tmp[1];
}
if(subtract_point)
{
PosType fac = screening*LensHalo::get_mass()/rcm2/PI;
alpha[0] += fac*xcm[0];
alpha[1] += fac*xcm[1];
{
fac = 2.0*fac/rcm2;
gamma[0] += 0.5*(xcm[0]*xcm[0]-xcm[1]*xcm[1])*fac;
gamma[1] += xcm[0]*xcm[1]*fac;
}
}
}
else
{
// outside of the halo
if (subtract_point == false)
{
PosType prefac = LensHalo::get_mass()/rcm2/PI;
alpha[0] += -1.0*prefac*xcm[0];
alpha[1] += -1.0*prefac*xcm[1];
{
PosType tmp = -2.0*prefac/rcm2;
gamma[0] += 0.5*(xcm[0]*xcm[0]-xcm[1]*xcm[1])*tmp;
gamma[1] += xcm[0]*xcm[1]*tmp;
}
}
}
return;
}
/*
LensHaloRealNSIE::LensHaloRealNSIE(float my_mass,float my_Rsize,PosType my_zlens,float my_rscale,float my_sigma
, float my_rcore,float my_fratio,float my_pa,int my_stars_N){
mass=my_mass, Rsize=my_Rsize, zlens=my_zlens, rscale=my_rscale;
sigma=my_sigma, rcore=my_rcore;
fratio=my_fratio, pa=my_pa, stars_N=my_stars_N;
stars_implanted = false;
Rsize = rmaxNSIE(sigma,mass,fratio,rcore);
Rsize = MAX(1.0,1.0/fratio)*Rsize; // redefine
assert(Rmax >= Rsize);
}
*/
size_t LensHaloRealNSIE::objectCount = 0;
std::vector<double> LensHaloRealNSIE::q_table;
std::vector<double> LensHaloRealNSIE::Fofq_table;
LensHaloRealNSIE::LensHaloRealNSIE(
float my_mass /// mass, sets truncation radius
,PosType my_zlens /// redshift
,float my_sigma /// in km/s
,float my_rcore /// core radius
,float my_fratio /// axis ratio
,float my_pa /// postion angle
,int my_stars_N
,const COSMOLOGY &cosmo)
:LensHalo(){
rscale=1.0;
LensHalo::setMass(my_mass);
LensHalo::setZlens(my_zlens,cosmo);
sigma=my_sigma, rcore=my_rcore;
fratio=my_fratio, pa = PI/2 - my_pa, stars_N=my_stars_N;
stars_implanted = false;
if(fratio != 1.0) elliptical_flag = true;
else elliptical_flag = false;
++objectCount;
if(objectCount == 1){ // make table for calculating elliptical integrale
construct_ellip_tables();
}
LensHalo::setRsize(rmax_calc());
//std::cout << "NSIE " << Rsize << std::endl;
Rmax = Rmax_to_Rsize_ratio*LensHalo::getRsize();
if(fratio > 1.0 || fratio < 0.01) throw std::invalid_argument("invalid fratio");
if(rcore > 0.0){
LensHalo::setMass(MassBy1DIntegation(LensHalo::getRsize()));
}
units = pow(sigma/lightspeed,2)/Grav;///sqrt(fratio); // mass/distance(physical);
}
//LensHaloRealNSIE::LensHaloRealNSIE(InputParams& params):LensHalo(params,false){
// sigma = 0.;
// fratio = 0.;
// pa = 0.;
// rcore = 0.;
//
// assignParams(params);
//
// if(fratio != 1.0) elliptical_flag = true;
// else elliptical_flag = false;
// ++objectCount;
// if(objectCount == 1){ // make table for calculating elliptical integrale
// construct_ellip_tables();
// }
// //Rsize = rmaxNSIE(sigma,mass,fratio,rcore);
// //Rmax = MAX(1.0,1.0/fratio)*Rsize; // redefine
// LensHalo::setRsize(rmax_calc());
// Rmax = Rmax_to_Rsize_ratio*LensHalo::getRsize();
//
// if(fratio > 1.0 || fratio < 0.01) throw std::invalid_argument("invalid fratio");
//
// if(rcore > 0.0){
// LensHalo::setMass(MassBy1DIntegation(LensHalo::getRsize()) );
// }
//
// units = pow(sigma/lightspeed,2)/Grav;///sqrt(fratio); // mass/distance(physical)
//}
void LensHaloRealNSIE::assignParams(InputParams& params){
if(!params.get("main_sigma",sigma)) error_message1("main_sigma",params.filename());
if(!params.get("main_core",rcore)) error_message1("main_core",params.filename());
if(!params.get("main_axis_ratio",fratio)) error_message1("main_axis_ratio",params.filename());
else if(fratio > 1){
ERROR_MESSAGE();
std::cout << "parameter main_axis_ratio must be < 1 in file " << params.filename() << ". Use main_pos_angle to rotate the halo." << std::endl;
exit(1);
}
if(!params.get("main_pos_angle",pa)) error_message1("main_pos_angle",params.filename());
if(params.get("main_ellip_method",main_ellip_method)){std::cout << "main_ellip_method is NOT needed in file " << params.filename() << ". RealNSIE produces parametric ellipses!" << endl;};
if(!params.get("main_stars_N",stars_N)) error_message1("main_stars_N",params.filename());
else if(stars_N){
assignParams_stars(params);
}
}
LensHaloRealNSIE::~LensHaloRealNSIE(){
--objectCount;
if(objectCount == 0){
q_table.resize(0);
Fofq_table.resize(0);
}
}
void LensHaloRealNSIE::construct_ellip_tables(){
int N = 200;
q_table.resize(N);
Fofq_table.resize(N);
q_table[0] = 0.01;
NormFuncer funcer(q_table[0]);
Fofq_table[0] = Utilities::nintegrate<NormFuncer,double>(funcer,0.0,PI/2,1.0e-6)*2/PI;
for(int i=1 ; i < N-1 ; ++i){
q_table[i] = i*1.0/(N-1) + 0.;
NormFuncer funcer(q_table[i]);
Fofq_table[i] = Utilities::nintegrate<NormFuncer,double>(funcer,0.0,PI/2,1.0e-6)*2/PI;
}
q_table.back() = 1.0;
Fofq_table.back() = 1.0;
}
PosType LensHaloRealNSIE::rmax_calc(){
if(fratio == 1.0 || rcore > 0.0)
return sqrt( pow( LensHalo::get_mass()*Grav*lightspeed*lightspeed
*sqrt(fratio)/PI/sigma/sigma + rcore,2)
- rcore*rcore );
// This is because there is no easy way of finding the circular Rmax for a fixed mass when rcore != 0
//if(rcore > 0.0) throw std::runtime_error("rcore must be zero for this constructor");
// asymmetric case
//NormFuncer funcer(fratio);
//double ellipticint = Utilities::nintegrate<NormFuncer,double>(funcer,0.0,PI/2,1.0e-6)*2/PI;
double ellipticint = Utilities::InterpolateYvec(q_table,Fofq_table,fratio)*sqrt(fratio);
return LensHalo::get_mass()*Grav*lightspeed*lightspeed/PI/sigma/sigma/ellipticint;
}
/*
void LensHaloRealNSIE::initFromMass(float my_mass, long *seed){
mass = my_mass;
rcore = 0.0;
sigma = 126*pow(mass/1.0e10,0.25); // From Tully-Fisher and Bell & de Jong 2001
//std::cout << "Warning: All galaxies are spherical" << std::endl;
fratio = (ran2(seed)+1)*0.5; //TODO: Ben change this! This is a kluge.
pa = 2*pi*ran2(seed); //TODO: This is a kluge.
Rsize = rmaxNSIE(sigma,mass,fratio,rcore);
Rmax = MAX(1.0,1.0/fratio)*Rsize; // redefine
assert(Rmax >= Rsize);
}
void LensHaloRealNSIE::initFromFile(float my_mass, long *seed, float vmax, float r_halfmass){
initFromMass(my_mass,seed);
}
void LensHaloRealNSIE::initFromMassFunc(float my_mass, float my_Rmax, float my_rscale, PosType my_slope, long *seed){
initFromMass(my_mass,seed);
}
*/
/** \brief returns the lensing quantities of a ray in center of mass coordinates.
*
* Warning: This adds to input value of alpha, kappa, gamma, and phi. They need
* to be zeroed out if the contribution of just this halo is wanted.
*/
void LensHalo::force_halo(
PosType *alpha /// deflection solar mass/Mpc
,KappaType *kappa /// surface density in Msun/Mpc^2 (?)
,KappaType *gamma /// three components of shear
,KappaType *phi /// potential in solar masses
,PosType const *xcm /// position relative to center (Mpc?)
,bool subtract_point /// if true contribution from a point mass is subtracted
,PosType screening /// the factor by which to scale the mass for screening of the point mass subtraction
)
{
if (elliptical_flag){
force_halo_asym(alpha,kappa,gamma,phi,xcm,subtract_point,screening);
//assert(!isinf(*kappa) );
}else{
force_halo_sym(alpha,kappa,gamma,phi,xcm,subtract_point,screening);
//assert(!isinf(*kappa) );
}
}
/** \brief returns the lensing quantities of a ray in center of mass coordinates for a symmetric halo
*
* phi is defined here in such a way that it differs from alpha by a sign (as we should have alpha = \nabla_x phi)
* but alpha agrees with the rest of the lensing quantities (kappa and gammas).
* Warning : Be careful, the sign of alpha is changed in LensPlaneSingular::force !
*
*/
void LensHalo::force_halo_sym(
PosType *alpha /// solar mass/Mpc
,KappaType *kappa /// convergence
,KappaType *gamma /// three components of shear
,KappaType *phi /// potential solar masses
,PosType const *xcm /// position relative to center (Mpc)
,bool subtract_point /// if true contribution from a point mass is subtracted
,PosType screening /// the factor by which to scale the mass for screening of the point mass subtraction
)
{
PosType rcm2 = xcm[0]*xcm[0] + xcm[1]*xcm[1];
if(rcm2 < 1e-20) rcm2 = 1e-20;
/// intersecting, subtract the point particle
if(rcm2 < Rmax*Rmax)
{
PosType prefac = mass/rcm2/PI;
PosType x = sqrt(rcm2)/rscale;
// PosType xmax = Rmax/rscale;
PosType tmp = (alpha_h(x) + 1.0*subtract_point)*prefac;
alpha[0] += tmp*xcm[0];
alpha[1] += tmp*xcm[1];
*kappa += kappa_h(x)*prefac;
tmp = (gamma_h(x) + 2.0*subtract_point) * prefac / rcm2; // ;
gamma[0] += 0.5*(xcm[0]*xcm[0]-xcm[1]*xcm[1])*tmp;
gamma[1] += xcm[0]*xcm[1]*tmp;
*phi += phi_h(x) * mass / PI ;
if(subtract_point) *phi -= 0.5 * log(rcm2) * mass / PI;
}
else // the point particle is not subtracted
{
if (subtract_point == false)
{
PosType prefac = screening*mass/rcm2/PI;
alpha[0] += -1.0 * prefac * xcm[0];
alpha[1] += -1.0 * prefac * xcm[1];
//std::cout << "rcm2 = " << rcm2 << std::endl;
//std::cout << "prefac = " << prefac << std::endl;
//std::cout << "xcm = " << xcm[0] << " " << xcm[1] << std::endl;
PosType tmp = -2.0*prefac/rcm2;
// kappa is equal to 0 in the point mass case.
gamma[0] += 0.5*(xcm[0]*xcm[0]-xcm[1]*xcm[1])*tmp;
gamma[1] += xcm[0]*xcm[1]*tmp;
*phi += 0.5 * log(rcm2) * mass / PI ;
}
}
/// add stars for microlensing
if(stars_N > 0 && stars_implanted)
{
force_stars(alpha,kappa,gamma,xcm);
}
//(alpha[0] == alpha[0] && alpha[1] == alpha[1]);
return;
}
// TODO: put in some comments about the units used
void LensHalo::force_halo_asym(
PosType *alpha /// mass/Mpc
,KappaType *kappa
,KappaType *gamma
,KappaType *phi /// potential solar masses
,PosType const *xcm
,bool subtract_point /// if true contribution from a point mass is subtracted
,PosType screening /// the factor by which to scale the mass for screening of the point mass subtraction
){
//float r_size=get_rsize()*Rmax;
//Rmax=r_size*1.2;
PosType rcm2 = xcm[0]*xcm[0] + xcm[1]*xcm[1];
PosType alpha_tmp[2],kappa_tmp,gamma_tmp[2],phi_tmp;
if(rcm2 < 1e-20) rcm2 = 1e-20;
//std::cout << "rsize , rmax, mass_norm =" << Rsize << " , " << Rmax << " , " << mass_norm_factor << std::endl;
//std::cout << subtract_point << std::endl;
/// intersecting, subtract the point particle
if(rcm2 < Rmax*Rmax){
double r = sqrt(rcm2); // devision by rscale for isotropic halos (see above) here taken out because not used for any halo. it should be taken out for the isotropic case too, if others not affected / make use of it ;
double theta;
if(xcm[0] == 0.0 && xcm[1] == 0.0) theta = 0.0;
else theta=atan2(xcm[1],xcm[0]);
if(rcm2 > LensHalo::getRsize()*LensHalo::getRsize()){
PosType alpha_iso[2],alpha_ellip[2];
alpha_ellip[0] = alpha_ellip[1] = 0;
if(main_ellip_method==Pseudo){alphakappagamma_asym(LensHalo::getRsize(),theta, alpha_tmp,&kappa_tmp,gamma_tmp,&phi_tmp);}
if(main_ellip_method==Fourier){alphakappagamma1asym(LensHalo::getRsize(),theta, alpha_tmp,&kappa_tmp,gamma_tmp,&phi_tmp);}
if(main_ellip_method==Schramm){alphakappagamma2asym(LensHalo::getRsize(),theta, alpha_tmp,&kappa_tmp,gamma_tmp,&phi_tmp);}
if(main_ellip_method==Keeton){alphakappagamma3asym(LensHalo::getRsize(),theta, alpha_tmp,&kappa_tmp,gamma_tmp,&phi_tmp);}
alpha_ellip[0]=alpha_tmp[0]*mass_norm_factor;
alpha_ellip[1]=alpha_tmp[1]*mass_norm_factor;
double f1 = (Rmax - r)/(Rmax - LensHalo::getRsize()),f2 = (r - LensHalo::getRsize())/(Rmax - LensHalo::getRsize());
// PosType tmp = mass/Rmax/PI/r;
PosType tmp = mass/rcm2/PI;
alpha_iso[0] = -1.0*tmp*xcm[0];
alpha_iso[1] = -1.0*tmp*xcm[1];
alpha[0] += alpha_iso[0]*f2 + alpha_ellip[0]*f1;
alpha[1] += alpha_iso[1]*f2 + alpha_ellip[1]*f1;
{
PosType tmp = -2.0*mass/rcm2/PI/rcm2;
gamma[0] += 0.5*(xcm[0]*xcm[0]-xcm[1]*xcm[1])*tmp;
gamma[1] += xcm[0]*xcm[1]*tmp;
//gamma[0] += 0.5*gamma_tmp[0]*mass_norm_factor;
//gamma[1] += 0.5*gamma_tmp[1]*mass_norm_factor;
*phi += phi_tmp;
}
}else{
if(main_ellip_method==Pseudo){alphakappagamma_asym(r,theta, alpha_tmp,&kappa_tmp,gamma_tmp,&phi_tmp);}
if(main_ellip_method==Fourier){alphakappagamma1asym(r,theta, alpha_tmp,&kappa_tmp,gamma_tmp,&phi_tmp);}
if(main_ellip_method==Schramm){alphakappagamma2asym(r,theta, alpha_tmp,&kappa_tmp,gamma_tmp,&phi_tmp);}
if(main_ellip_method==Keeton){alphakappagamma3asym(r,theta, alpha_tmp,&kappa_tmp,gamma_tmp,&phi_tmp);}
alpha[0] += alpha_tmp[0]*mass_norm_factor;//-1.0*subtract_point*mass/rcm2/PI*xcm[0];
alpha[1] += alpha_tmp[1]*mass_norm_factor;//-1.0*subtract_point*mass/rcm2/PI*xcm[1];
if(get_switch_flag()==true){ /// case distinction used for elliptical NFWs (true) only (get_switch_flag==true)
*kappa += kappa_tmp*mass_norm_factor*mass_norm_factor;
gamma[0] += 0.5*gamma_tmp[0]*mass_norm_factor*mass_norm_factor;
gamma[1] += 0.5*gamma_tmp[1]*mass_norm_factor*mass_norm_factor;
}else{
*kappa += kappa_tmp*mass_norm_factor;
gamma[0] += 0.5*gamma_tmp[0]*mass_norm_factor;//+1.0*subtract_point*mass/rcm2/PI/rcm2*0.5*(xcm[0]*xcm[0]-xcm[1]*xcm[1]);
gamma[1] += 0.5*gamma_tmp[1]*mass_norm_factor;//-1.0*subtract_point*mass/rcm2/PI/rcm2*(xcm[0]*xcm[1]);
//if(theta < 0.660 && theta> 0.659){
//assert(mass_norm_factor==1);
//std::cout << theta << " , " << 0.5*gamma_tmp[0]*mass_norm_factor << " , " << 0.5*gamma_tmp[1]*mass_norm_factor << " , " << kappa_tmp*mass_norm_factor << " , " << alpha_tmp[0]*mass_norm_factor << " , " << alpha_tmp[1]*mass_norm_factor << std::endl;
//}
}
/*if (rcm2 < 1E-6){
std::cout << kappa_tmp*mass_norm_factor << " " << 0.5*gamma_tmp[0]*mass_norm_factor<< " " << 0.5*gamma_tmp[1]*mass_norm_factor << " " <<rcm2 << " " << alpha_tmp[0]*mass_norm_factor << " " << alpha_tmp[1]*mass_norm_factor << std::endl;
}
*/
*phi += phi_tmp;
}
if(subtract_point){
//std::cout << "DO WE EVEN GET HERE??" << std::endl;
PosType tmp = screening*mass/PI/rcm2; // *mass_norm_factor
alpha[0] += tmp*xcm[0];
alpha[1] += tmp*xcm[1];
tmp = 2.0*tmp/rcm2;
gamma[0] += 0.5*(xcm[0]*xcm[0]-xcm[1]*xcm[1])*tmp;
gamma[1] += xcm[0]*xcm[1]*tmp;
*phi -= 0.5 * log(rcm2) * mass / PI ; // *mass_norm_factor
}
}
else // the point particle is not subtracted
{
if (subtract_point == false)
{
PosType prefac = mass/rcm2/PI;
alpha[0] += -1.0 * prefac * xcm[0];
alpha[1] += -1.0 * prefac * xcm[1];
//if(rcm2==1.125){
//std::cout << "rcm2 = " << rcm2 << std::endl;
//std::cout << "prefac = " << prefac << std::endl;
//std::cout << "xcm = " << xcm[0] << " " << xcm[1] << std::endl;
//}
PosType tmp = -2.0*prefac/rcm2;
// kappa is equal to 0 in the point mass case.
gamma[0] += 0.5*(xcm[0]*xcm[0]-xcm[1]*xcm[1])*tmp;
gamma[1] += xcm[0]*xcm[1]*tmp;
*phi += 0.5 * log(rcm2) * mass / PI ;
}
}
/// add stars for microlensing
if(stars_N > 0 && stars_implanted)
{
force_stars(alpha,kappa,gamma,xcm);
}
//assert(alpha[0] == alpha[0] && alpha[1] == alpha[1]);
return;
}
/* *
void LensHaloRealNSIE::force_halo(
PosType *alpha
,KappaType *kappa
,KappaType *gamma
,KappaType *phi
,PosType const *xcm
,bool subtract_point /// if true contribution from a point mass is subtracted
,PosType screening /// the factor by which to scale the mass for screening of the point mass subtraction
){
PosType rcm2 = xcm[0]*xcm[0] + xcm[1]*xcm[1];
if(rcm2 < 1e-20) rcm2 = 1e-20;
// **** test line
if(rcm2 < Rmax*Rmax){
PosType ellipR = ellipticRadiusNSIE(xcm,fratio,pa);
if(ellipR > LensHalo::getRsize()){
// This is the case when the ray is within the NSIE's circular region of influence but outside its elliptical truncation
PosType alpha_out[2],alpha_in[2],rin,x_in[2];
PosType prefac = -1.0*mass/Rmax/PI;
PosType r = sqrt(rcm2);
float units = pow(sigma/lightspeed,2)/Grav/sqrt(fratio); // mass/distance(physical)
alpha_in[0] = alpha_in[1] = 0;
rin = r*LensHalo::getRsize()/ellipR;
alpha_out[0] = prefac*xcm[0]/r;
alpha_out[1] = prefac*xcm[1]/r;
x_in[0] = rin*xcm[0]/r;
x_in[1] = rin*xcm[1]/r;
alphaNSIE(alpha_in,x_in,fratio,rcore,pa);
alpha_in[0] *= units; // minus sign removed because already included in alphaNSIE
alpha_in[1] *= units;
alpha[0] += (r - rin)*(alpha_out[0] - alpha_in[0])/(Rmax - rin) + alpha_in[0];
alpha[1] += (r - rin)*(alpha_out[1] - alpha_in[1])/(Rmax - rin) + alpha_in[1];
//alpha[0] -= (r - rin)*(alpha_out[0] - alpha_in[0])/(Rmax - rin) + alpha_in[0];
//alpha[1] -= (r - rin)*(alpha_out[1] - alpha_in[1])/(Rmax - rin) + alpha_in[1];
{
// TODO: this makes the kappa and gamma disagree with the alpha as calculated above
KappaType tmp[2]={0,0};
PosType xt[2]={0,0};
float units = pow(sigma/lightspeed,2)/Grav/sqrt(fratio); // mass/distance(physical)
xt[0]=xcm[0];
xt[1]=xcm[1];
*kappa += units*kappaNSIE(xt,fratio,rcore,pa);
gammaNSIE(tmp,xt,fratio,rcore,pa);
gamma[0] += units*tmp[0];
gamma[1] += units*tmp[1];
}
}else{
PosType xt[2]={0,0},tmp[2]={0,0};
float units = pow(sigma/lightspeed,2)/Grav/sqrt(fratio); // mass/distance(physical)
xt[0]=xcm[0];
xt[1]=xcm[1];
alphaNSIE(tmp,xt,fratio,rcore,pa);
//alpha[0] = units*tmp[0]; // minus sign removed because already included in alphaNSIE
//alpha[1] = units*tmp[1]; // Why was the "+=" removed?
alpha[0] += units*tmp[0];
alpha[1] += units*tmp[1];
{
KappaType tmp[2]={0,0};
*kappa += units*kappaNSIE(xt,fratio,rcore,pa);
gammaNSIE(tmp,xt,fratio,rcore,pa);
gamma[0] += units*tmp[0];
gamma[1] += units*tmp[1];
}
}
}
else
{
if (subtract_point == false)
{
PosType prefac = mass/rcm2/PI;
alpha[0] += -1.0*prefac*xcm[0];
alpha[1] += -1.0*prefac*xcm[1];
// can turn off kappa and gamma calculations to save times
{
PosType tmp = -2.0*prefac/rcm2;
gamma[0] += 0.5*(xcm[0]*xcm[0]-xcm[1]*xcm[1])*tmp;
gamma[1] += xcm[0]*xcm[1]*tmp;
}
}
}
if(subtract_point){
PosType fac = mass/rcm2/PI;
alpha[0] += fac*xcm[0];
alpha[1] += fac*xcm[1];
// can turn off kappa and gamma calculations to save times
{
fac = 2.0*fac/rcm2;
gamma[0] += 0.5*(xcm[0]*xcm[0]-xcm[1]*xcm[1])*fac;
gamma[1] += xcm[0]*xcm[1]*fac;
}
}
// add stars for microlensing
if(stars_N > 0 && stars_implanted){
force_stars(alpha,kappa,gamma,xcm);
}
return;
}
*/
void LensHaloRealNSIE::force_halo(
PosType *alpha
,KappaType *kappa
,KappaType *gamma
,KappaType *phi
,PosType const *xcm
,bool subtract_point /// if true contribution from a point mass is subtracted
,PosType screening /// the factor by which to scale the mass for screening of the point mass subtraction
)
{
PosType rcm2 = xcm[0]*xcm[0] + xcm[1]*xcm[1];
if(rcm2 < 1e-20) rcm2 = 1e-20;
if(rcm2 < Rmax*Rmax){
//PosType ellipR = ellipticRadiusNSIE(xcm,fratio,pa);
// std::cout << "rsize , rmax, mass_norm =" << LensHalo::getRsize() << " , " << Rmax << " , " << mass_norm_factor << std::endl;
if(rcm2 > LensHalo::getRsize()*LensHalo::getRsize())
//if(ellipR > LensHalo::getRsize()*LensHalo::getRsize())
{
// This is the case when the ray is within the NSIE's circular region of influence but outside its elliptical truncation
PosType alpha_iso[2],alpha_ellip[2];
//PosType prefac = -1.0*mass/Rmax/PI;
PosType r = sqrt(rcm2);
//double Rin = sqrt(rcm2)*LensHalo::getRsize()/ellipR;
//std::cout << Rmax << " " << LensHalo::getRsize() << " " << Rmax/LensHalo::getRsize() << std::endl;
double f1 = (Rmax - r)/(Rmax - LensHalo::getRsize()),f2 = (r - LensHalo::getRsize())/(Rmax - LensHalo::getRsize());
//double f1 = (Rmax - r)/(Rmax - Rin),f2 = (r - Rin)/(Rmax - Rin);
// SIE solution
alpha_ellip[0] = alpha_ellip[1] = 0;
alphaNSIE(alpha_ellip,xcm,fratio,rcore,pa);
alpha_ellip[0] *= units;
alpha_ellip[1] *= units;
// SIS solution
//alpha_iso[0] = alpha_iso[1] = 0;
//alphaNSIE(alpha_iso,xcm,1,rcore,pa);
//alpha_iso[0] *= units;
//alpha_iso[1] *= units;
//
// point mass solution
// PosType tmp = mass/rcm2/PI;
PosType tmp = LensHalo::get_mass()/rcm2/PI;
alpha_iso[0] = -1.0*tmp*xcm[0];
alpha_iso[1] = -1.0*tmp*xcm[1];
alpha[0] += alpha_iso[0]*f2 + alpha_ellip[0]*f1;
alpha[1] += alpha_iso[1]*f2 + alpha_ellip[1]*f1;
{
PosType tmp = -2.0*LensHalo::get_mass()/rcm2/PI/rcm2;
gamma[0] += 0.5*(xcm[0]*xcm[0]-xcm[1]*xcm[1])*tmp;
gamma[1] += xcm[0]*xcm[1]*tmp;
}
}else{
PosType xt[2]={0,0},tmp[2]={0,0};
xt[0]=xcm[0];
xt[1]=xcm[1];
alphaNSIE(tmp,xt,fratio,rcore,pa);
//alpha[0] = units*tmp[0]; // minus sign removed because already included in alphaNSIE
//alpha[1] = units*tmp[1]; // Why was the "+=" removed?
alpha[0] += units*tmp[0];//*sqrt(fratio);
alpha[1] += units*tmp[1];//*sqrt(fratio);
{
KappaType tmp[2]={0,0};
*kappa += units*kappaNSIE(xt,fratio,rcore,pa);///sqrt(fratio);
gammaNSIE(tmp,xt,fratio,rcore,pa);
gamma[0] += units*tmp[0];
gamma[1] += units*tmp[1];
}
}
if(subtract_point)
{
PosType fac = screening*LensHalo::get_mass()/rcm2/PI;
alpha[0] += fac*xcm[0];
alpha[1] += fac*xcm[1];
{
fac = 2.0*fac/rcm2;
gamma[0] += 0.5*(xcm[0]*xcm[0]-xcm[1]*xcm[1])*fac;
gamma[1] += xcm[0]*xcm[1]*fac;
}
}
}
else
{
// outside of the halo
if (subtract_point == false)
{
PosType prefac = LensHalo::get_mass()/rcm2/PI;
alpha[0] += -1.0*prefac*xcm[0];
alpha[1] += -1.0*prefac*xcm[1];
{
PosType tmp = -2.0*prefac/rcm2;
gamma[0] += 0.5*(xcm[0]*xcm[0]-xcm[1]*xcm[1])*tmp;
gamma[1] += xcm[0]*xcm[1]*tmp;
}
}
}
// add stars for microlensing
if(stars_N > 0 && stars_implanted)
{
force_stars(alpha,kappa,gamma,xcm);
}
//assert(alpha[0] == alpha[0] && alpha[1] == alpha[1]);
return;
}
/**/
const long LensHaloHernquist::NTABLE = 100000;
const PosType LensHaloHernquist::maxrm = 100.0;
int LensHaloHernquist::count = 0;
PosType* LensHaloHernquist::xtable = NULL;
PosType* LensHaloHernquist::ftable = NULL;
PosType* LensHaloHernquist::gtable = NULL;
PosType* LensHaloHernquist::g2table = NULL;
PosType* LensHaloHernquist::htable = NULL;
PosType* LensHaloHernquist::xgtable = NULL;
/*
LensHaloHernquist::LensHaloHernquist()
: LensHalo(), gmax(0)
{
make_tables();
gmax = InterpolateFromTable(gtable,xmax);
}
*/
LensHaloHernquist::LensHaloHernquist(float my_mass,float my_Rsize,PosType my_zlens,float my_rscale,float my_fratio,float my_pa,int my_stars_N,const COSMOLOGY &cosmo, EllipMethod my_ellip_method){
LensHalo::setMass(my_mass);
LensHalo::setZlens(my_zlens,cosmo);
LensHalo::setRsize(my_Rsize);
rscale=my_rscale;
fratio=my_fratio, pa=my_pa, stars_N=my_stars_N;
stars_implanted = false;
xmax = LensHalo::getRsize()/rscale;
make_tables();
gmax = InterpolateFromTable(gtable,xmax);
set_slope(1);
/// If the axis ratio given in the parameter file is set to 1 all ellipticizing routines are skipped.
if(fratio!=1){
Rmax = Rmax_to_Rsize_ratio*LensHalo::getRsize();
//std::cout << getEllipMethod() << " method to ellipticise" << std::endl;
if(getEllipMethod()==Fourier){
//std::cout << "Hernquist constructor: slope set to " << get_slope() << std::endl;
calcModes(fratio, get_slope(), pa, mod); // to ellipticize potential instead of kappa use (fratio, get_slope()-2, pa, mod)
for(int i=1;i<Nmod;i++){
if(mod[i]!=0){set_flag_elliptical(true);};
}
}else set_flag_elliptical(true);
if (getEllipMethod()==Pseudo){
fratio=0.00890632+0.99209115*pow(fratio,0.33697702);
set_norm_factor();
}
}else{
set_flag_elliptical(false);
Rmax = LensHalo::getRsize();
}
}
//LensHaloHernquist::LensHaloHernquist(InputParams& params): LensHalo(params)
//{
// assignParams(params);
// make_tables();
// gmax = InterpolateFromTable(gtable,xmax);
//
// set_slope(1);
// /// If the axis ratio given in the parameter file is set to 1 all ellipticizing routines are skipped.
// if(fratio!=1){
// //std::cout << getEllipMethod() << " method to ellipticise" << std::endl;
// if(getEllipMethod()==Fourier){
// std::cout << "Hernquist constructor: slope set to " << get_slope() << std::endl;
// calcModes(fratio, get_slope(), pa, mod); // to ellipticize potential instead of kappa use (fratio, get_slope()-2, pa, mod)
// for(int i=1;i<Nmod;i++){
// if(mod[i]!=0){set_flag_elliptical(true);};
// }
// }else set_flag_elliptical(true);
// if (getEllipMethod()==Pseudo){
// set_norm_factor();
// }
// }else set_flag_elliptical(false);
//}
void LensHaloHernquist::make_tables(){
if(count == 0){
int i;
PosType x, dx = maxrm/(PosType)NTABLE;
xtable = new PosType[NTABLE];
ftable = new PosType[NTABLE];
gtable = new PosType[NTABLE];
htable = new PosType[NTABLE];
g2table = new PosType[NTABLE];
xgtable = new PosType[NTABLE];
for(i = 0 ; i< NTABLE; i++){
x = i*dx;
xtable[i] = x;
ftable[i] = ffunction(x);
gtable[i] = gfunction(x);
htable[i] = hfunction(x);
g2table[i] = g2function(x);
if(i==0){xgtable[i]=0;}
if(i!=0){
xgtable[i] = alpha_int(x);
}
}
}
count++;
}
PosType LensHaloHernquist::InterpolateFromTable(PosType *table, PosType y) const{
int j;
j=(int)(y/maxrm*NTABLE);
assert(y>=xtable[j] && y<=xtable[j+1]);
if (j==0)
{
if (table==ftable) return ffunction(y);
if (table==gtable) return gfunction(y);
if (table==g2table) return g2function(y);
if (table==htable) return hfunction(y);
if (table==xgtable) return alpha_int(y);
}
return (table[j+1]-table[j])/(xtable[j+1]-xtable[j])*(y-xtable[j]) + table[j];
}
void LensHaloHernquist::assignParams(InputParams& params){
if(!params.get("main_rscale",rscale)) error_message1("main_rscale",params.filename());
xmax = LensHalo::getRsize()/rscale;
if(!params.get("main_axis_ratio",fratio)){fratio=1; std::cout << "main_axis_ratio not defined in file " << params.filename() << ", hence set to 1." << std::endl;};
if(!params.get("main_pos_angle",pa)){pa=0; std::cout << "main_pos_angle not defined in file " << params.filename() << ", hence set to 0." << std::endl;};
if(!params.get("main_ellip_method",main_ellip_method)){if(fratio!=1){main_ellip_method=Pseudo;std::cout << "main_ellip_method is not defined in file " << params.filename() << ", hence set to Pseudo." << endl;};};
if(!params.get("main_stars_N",stars_N)) error_message1("main_stars_N",params.filename());
else if(stars_N){
assignParams_stars(params);
std::cout << "LensHalo::getRsize() " << LensHalo::getRsize() <<std::endl;
}
}
LensHaloHernquist::~LensHaloHernquist(){
--count;
if(count == 0){
delete[] xtable;
delete[] gtable;
delete[] ftable;
delete[] htable;
delete[] g2table;
delete[] xgtable;
}
}
const long LensHaloJaffe::NTABLE = 100000;
const PosType LensHaloJaffe::maxrm = 100.0;
int LensHaloJaffe::count = 0;
PosType* LensHaloJaffe::xtable = NULL;
PosType* LensHaloJaffe::ftable = NULL;
PosType* LensHaloJaffe::gtable = NULL;
PosType* LensHaloJaffe::g2table = NULL;
PosType* LensHaloJaffe::xgtable = NULL;
//PosType* LensHaloJaffe::htable = NULL;
/*
LensHaloJaffe::LensHaloJaffe()
: LensHalo(), gmax(0)
{
make_tables();
gmax = InterpolateFromTable(gtable,xmax);
}
*/
LensHaloJaffe::LensHaloJaffe(float my_mass,float my_Rsize,PosType my_zlens,float my_rscale,float my_fratio,float my_pa,int my_stars_N,const COSMOLOGY &cosmo, EllipMethod my_ellip_method){
LensHalo::setMass(my_mass);
LensHalo::setZlens(my_zlens,cosmo);
LensHalo::setRsize(my_Rsize);
rscale=my_rscale;
fratio=my_fratio, pa=my_pa, stars_N=my_stars_N;
stars_implanted = false;
xmax = LensHalo::getRsize()/rscale;
make_tables();
gmax = InterpolateFromTable(gtable,xmax);
set_slope(1);
if(fratio!=1){
Rmax = Rmax_to_Rsize_ratio*LensHalo::getRsize();
//std::cout << getEllipMethod() << " method to ellipticise" << std::endl;
if(getEllipMethod()==Fourier){
//std::cout << "Jaffe constructor: slope set to " << get_slope() << std::endl;
calcModes(fratio, get_slope(), pa, mod);
for(int i=1;i<Nmod;i++){
if(mod[i]!=0){set_flag_elliptical(true);};
}
}else set_flag_elliptical(true);
if (getEllipMethod()==Pseudo){
fratio=0.00890632+0.99209115*pow(fratio,0.33697702);
set_norm_factor();
}
}else{
set_flag_elliptical(false);
Rmax = LensHalo::getRsize();
}
}
//LensHaloJaffe::LensHaloJaffe(InputParams& params): LensHalo(params)
//{
// assignParams(params);
// make_tables();
// gmax = InterpolateFromTable(gtable,xmax);
//
// set_slope(1);
//
// /// If the axis ratio given in the parameter file is set to 1 all ellipticizing routines are skipped.
// if(fratio!=1){
// //std::cout << getEllipMethod() << " method to ellipticise" << std::endl;
// if(getEllipMethod()==Fourier){
// std::cout << "Jaffe constructor: slope set to " << get_slope() << std::endl;
// calcModes(fratio, get_slope(), pa, mod);
// for(int i=1;i<Nmod;i++){
// if(mod[i]!=0){set_flag_elliptical(true);};
// }
// }else set_flag_elliptical(true);
// if (getEllipMethod()==Pseudo){
// set_norm_factor();
// }
// }else set_flag_elliptical(false);
//}
void LensHaloJaffe::make_tables(){
if(count == 0){
int i;
PosType x, dx = maxrm/(PosType)NTABLE;
xtable = new PosType[NTABLE];
ftable = new PosType[NTABLE];
gtable = new PosType[NTABLE];
g2table = new PosType[NTABLE];
xgtable = new PosType[NTABLE];
for(i = 0 ; i< NTABLE; i++){
x = i*dx;
xtable[i] = x;
ftable[i] = ffunction(x);
gtable[i] = gfunction(x);
g2table[i] = g2function(x);
if(i==0){xgtable[i]=0;}
if(i!=0){
xgtable[i] = alpha_int(x);
}
}
}
count++;
}
PosType LensHaloJaffe::InterpolateFromTable(PosType *table, PosType y) const{
int j;
j=(int)(y/maxrm*NTABLE);
assert(y>=xtable[j] && y<=xtable[j+1]);
if (j==0)
{
if (table==ftable) return ffunction(y);
if (table==gtable) return gfunction(y);
if (table==g2table) return g2function(y);
if (table==xgtable) return alpha_int(y);
}
return (table[j+1]-table[j])/(xtable[j+1]-xtable[j])*(y-xtable[j]) + table[j];
}
void LensHaloJaffe::assignParams(InputParams& params){
if(!params.get("main_rscale",rscale)) error_message1("main_rscale",params.filename());
xmax = LensHalo::getRsize()/rscale;
if(!params.get("main_axis_ratio",fratio)){fratio=1; std::cout << "main_axis_ratio not defined in file " << params.filename() << ", hence set to 1." << std::endl;};
if(!params.get("main_pos_angle",pa)){pa=0; std::cout << "main_pos_angle not defined in file " << params.filename() << ", hence set to 0." << std::endl;};
if(!params.get("main_ellip_method",main_ellip_method)){if(fratio!=1){main_ellip_method=Pseudo;std::cout << "main_ellip_method is not defined in file " << params.filename() << ", hence set to Pseudo." << endl;};};
if(!params.get("main_stars_N",stars_N)) error_message1("main_stars_N",params.filename());
else if(stars_N){
assignParams_stars(params);
}
}
LensHaloJaffe::~LensHaloJaffe(){
--count;
if(count == 0){
delete[] xtable;
delete[] gtable;
delete[] ftable;
delete[] g2table;
delete[] xgtable;
}
}
LensHaloDummy::LensHaloDummy()
: LensHalo()
{
// mass = 0.;
}
LensHaloDummy::LensHaloDummy(float my_mass,float my_Rsize,PosType my_zlens,float my_rscale, int my_stars_N,const COSMOLOGY &cosmo){
LensHalo::setMass(my_mass);
LensHalo::setZlens(my_zlens,cosmo);
LensHalo::setRsize(my_Rsize);
rscale=my_rscale;
stars_N=my_stars_N;
stars_implanted = false;
setTheta(0.0,0.0);
}
//LensHaloDummy::LensHaloDummy(InputParams& params): LensHalo(params)
//{
// assignParams(params);
// // mass = 0.;
//}
void LensHaloDummy::initFromMassFunc(float my_mass, float my_Rsize, float my_rscale, PosType my_slope, long *seed){
LensHalo::setMass(1.e-10);
LensHalo::setRsize(my_Rsize);
rscale = my_rscale;
xmax = LensHalo::getRsize()/rscale;
Rmax = LensHalo::getRsize();
}
void LensHaloDummy::force_halo(PosType *alpha
,KappaType *kappa
,KappaType *gamma
,KappaType *phi
,PosType const *xcm
,bool subtract_point
,PosType screening /// the factor by which to scale the mass for screening of the point mass subtraction
)
{
PosType rcm2 = xcm[0]*xcm[0] + xcm[1]*xcm[1];
PosType prefac = LensHalo::get_mass()/rcm2/PI;
PosType tmp = subtract_point*prefac;
alpha[0] += tmp*xcm[0];
alpha[1] += tmp*xcm[1];
// intersecting, subtract the point particle
if(subtract_point)
{
PosType x = screening*sqrt(rcm2)/rscale;
*kappa += kappa_h(x)*prefac;
tmp = (gamma_h(x) + 2.0*subtract_point)*prefac/rcm2;
gamma[0] += 0.5*(xcm[0]*xcm[0]-xcm[1]*xcm[1])*tmp;
gamma[1] += xcm[0]*xcm[1]*tmp;
*phi += phi_h(x);
}
// add stars for microlensing
if(stars_N > 0 && stars_implanted)
{
force_stars(alpha,kappa,gamma,xcm);
}
//assert(alpha[0] == alpha[0] && alpha[1] == alpha[1]);
}
void LensHaloDummy::assignParams(InputParams& params)
{
if(params.get("main_ellip_method",main_ellip_method)){std::cout << "main_ellip_method is NOT needed in file " << params.filename() << ". LensHaloDummy does not require ellipticity!" << endl;};
}
std::size_t LensHalo::Nparams() const
{
return 0;
}
PosType LensHalo::getParam(std::size_t p) const
{
switch(p)
{
default:
throw std::invalid_argument("bad parameter index for getParam()");
}
}
PosType LensHalo::setParam(std::size_t p, PosType val)
{
switch(p)
{
default:
throw std::invalid_argument("bad parameter index for setParam()");
}
}
void LensHalo::printCSV(std::ostream&, bool header) const
{
const std::type_info& type = typeid(*this);
std::cerr << "LensHalo subclass " << type.name() << " does not implement printCSV()" << std::endl;
std::exit(1);
}
/// calculates the mass within radius R by integating kappa in theta and R, used only for testing
PosType LensHalo::MassBy2DIntegation(PosType R){
LensHalo::DMDR dmdr(this);
return Utilities::nintegrate<LensHalo::DMDR,PosType>(dmdr,-12,log(R),1.0e-5);
}
/// calculates the mass within radius R by integating alpha on a ring and using Gauss' law, used only for testing
PosType LensHalo::MassBy1DIntegation(PosType R){
LensHalo::DMDTHETA dmdtheta(R,this);
return R*Utilities::nintegrate<LensHalo::DMDTHETA,PosType>(dmdtheta, 0, 2*PI, 1.0e-6)/2;
}
/// calculates the average gamma_t for LensHalo::test()
double LensHalo::test_average_gt(PosType R){
struct test_gt_func f(R,this);
return Utilities::nintegrate<test_gt_func>(f,0.0,2.*PI,1.0e-3);
}
// returns <kappa> x 2PI on a ring at R
double LensHalo::test_average_kappa(PosType R){
struct test_kappa_func f(R,this);
return Utilities::nintegrate<test_kappa_func>(f,0.0,2.*PI,1.0e-3);
}
/// Three tests: 1st - Mass via 1D integration vs mass via 2D integration. 2nd: gamma_t=alpha/r - kappa(R) which can be used for spherical distributions. Deviations are expected for axis ratios <1. For the latter case we use the next test. 3rd: The average along a circular aperture of gamma_t should be equal to <kappa(<R)> minus the average along a circular aperture over kappa. Note that also alpha/r - kappa is checked for consistency with kappa(<R)-<kappa(R)>. For axis ratios < 1 the factor between the two is expected to be of order O(10%).
bool LensHalo::test(){
std::cout << "test alpha's consistance with kappa by comparing mass interior to a radius by 1D integration and Gauss' law and by 2D integration" << std::endl << " The total internal mass is " << mass << std::endl;
std::cout << "R/Rmax R/Rsize Mass 1 D (from alpha) Mass 2 D (m1 - m2)/m1 m2/m1" << std::endl;
int N=25;
PosType m1,m2;
for(int i=1;i<N;++i){
m1 = MassBy1DIntegation(LensHalo::getRsize()*i/(N-4));
m2 = MassBy2DIntegation(LensHalo::getRsize()*i/(N-4));
std::cout << i*1./(N-4) << " " << i/(N-4) << " " << m1 << " "
<< m2 << " "<< (m1-m2)/m1 << " " << m2/m1 << std::endl;
}
PosType r;
std::cout << "test gamma_t's consistance with kappa and alpha by comparing gamma_t to alpha/r - kappa along the x-axis" << std::endl
<< "Not expected to be equal for asymmetric cases."<< std::endl;
std::cout << std::endl <<"R/Rmax R/Rsize gamma_t alpha/r - kappa alpha/r kappa delta/gt " << std::endl;
for(int i=1;i<N;++i){
r = Rsize*i/(N-2);
PosType alpha[2] = {0,0},x[2] = {0,0};
KappaType kappa = 0,gamma[3] = {0,0,0} ,phi=0;
x[0] = r;
x[1] = 0;
force_halo(alpha,&kappa,gamma,&phi,x);
std::cout << r/Rmax << " " << r/Rsize << " " << -gamma[0] << " " << -alpha[0]/r - kappa << " " << -alpha[0]/r << " " << kappa << " " << (alpha[0]/r + kappa)/gamma[0] <<std::endl;
}
std::cout << "test average tangential shear's, gamma_t's, consistance with the average convergence at a radius, kappa(r) and average kappa within a radius calculated using alpha and Gauss' law. gamma_t should be equal to <kappa>_R - kappa(R)" << std::endl;
std::cout << std::endl <<"R/Rmax R/Rsize gamma_t <kappa>_R-kappa(R) <kappa>_R kappa(R) [<kappa>_R-kappa(R)]/gt " << std::endl;
for(int i=1;i<N;++i){
r = Rsize*i/(N-2);
//integrate over t
PosType average_gt, average_kappa;
average_gt=test_average_gt(r)/2/PI;
average_kappa=test_average_kappa(r)/2/PI;
m1 = MassBy1DIntegation(r)/PI/r/r;
std::cout << r/Rmax << " " << r/Rsize << " " << -1.0*average_gt << " " << m1-average_kappa << " " << m1 << " " << average_kappa << " " << -1.0*(m1-average_kappa)/average_gt << std::endl;
PosType alpha[2] = {0,0},x[2] = {0,0};
KappaType kappa = 0,gamma[3] = {0,0,0} ,phi=0;
x[0] = r;
x[1] = 0;
force_halo(alpha,&kappa,gamma,&phi,x);
/*
assert( abs(-1.0*(m1-average_kappa)/average_gt-1.) < 1e-2 ); // <g_t> = <k(<R)>-<kappa(R)> test
if(!elliptical_flag){
assert( abs(abs(-alpha[0]/r)/m1-1.) < 1e-1 ); // alpha/r ~ <kappa(R)>
assert( abs(abs(alpha[0]/r + kappa)/gamma[0])-1.0 < 1e-2); // g_t = alpha/r - kappa test
}
*/
// This is a list of possible assertion test that can be made
//if(!elliptical_flag){
//std::cout << abs(abs(-alpha[0]/r)/m1-1.) << std::endl;
//assert( abs(abs(-alpha[0]/r)/m1-1.) < 1e-1 ); // alpha/r ~ <kappa(R)>
//std::cout << abs(abs(alpha[0]/r + kappa)/gamma[0])-1.0 << std::endl;
//assert( abs(abs(alpha[0]/r + kappa)/gamma[0])-1.0 < 1e-2); // g_t = alpha/r - kappa test
//}
//std::cout << abs(-1.0*(m1-average_kappa)/average_gt-1.) << std::endl;
//std::cout << abs( -alpha[0]/r - kappa ) / abs(m1-average_kappa ) -1. << std::endl;
//assert( abs( -alpha[0]/r - kappa ) / abs(m1-average_kappa ) -1. < 1 ); // alpha/r ~ <kappa(R)>
}
return true;
};
/// The following functions calculate the integrands of the Schramm 1990 method to obtain elliptical halos
PosType LensHalo::DALPHAXDM::operator()(PosType m){
double ap = m*m*a2 + lambda,bp = m*m*b2 + lambda;
double p2 = x[0]*x[0]/ap/ap/ap/ap + x[1]*x[1]/bp/bp/bp/bp; // actually the inverse of equation (5) in Schramm 1990
PosType tmp = m*(isohalo->getRsize());
KappaType kappa=0;
double xiso=tmp/isohalo->rscale;
//PosType alpha[2]={0,0},tm[2] = {m*(isohalo->getRsize()),0};
//KappaType kappam=0,gamma[2]={0,0},phi;
kappa=isohalo->kappa_h(xiso)/PI/xiso/xiso*isohalo->mass;
//isohalo->force_halo_sym(alpha,&kappam,gamma,&phi,tm);
//std::cout << "kappa: " << kappa << " " << kappam << " " << kappa/kappam << std::endl;
assert(kappa >= 0.0);
std::cout << "output x: " << m << " " << m*kappa/(ap*ap*ap*bp*p2) << std::endl;
return m*kappa/(ap*ap*ap*bp*p2); // integrand of equation (28) in Schramm 1990
}
PosType LensHalo::DALPHAYDM::operator()(PosType m){
double ap = m*m*a2 + lambda,bp = m*m*b2 + lambda;
double p2 = x[0]*x[0]/ap/ap/ap/ap + x[1]*x[1]/bp/bp/bp/bp; // actually the inverse of equation (5) in Schramm 1990
PosType tmp = m*(isohalo->getRsize());
KappaType kappa=0;
double xiso=tmp/isohalo->rscale;
//PosType alpha[2]={0,0},tm[2] = {m*(isohalo->getRsize()),0};
//KappaType kappam=0,gamma[2]={0,0},phi;
kappa=isohalo->kappa_h(xiso)/PI/xiso/xiso*isohalo->mass;
//isohalo->force_halo_sym(alpha,&kappam,gamma,&phi,tm);
//std::cout << "kappa: " << kappa << " " << kappam << " " << kappa/kappam << std::endl;
assert(kappa >= 0.0);
return m*kappa/(ap*bp*bp*bp*p2); // integrand of equation (29) in Schramm 1990
}
//bool LensHaloZcompare(LensHalo *lh1,LensHalo *lh2){return (lh1->getZlens() < lh2->getZlens());}
//bool compare(LensHalo *lh1,LensHalo *lh2){return (lh1->getZlens() < lh2->getZlens());}
| 34.072719
| 548
| 0.610973
|
glenco
|
b7cc0d9b469bff0ae0c501c7300849fefcb3d237
| 122,267
|
cpp
|
C++
|
ios/Classes/Native/Bulk_System_2.cpp
|
ShearerAWS/mini-mafia-release
|
1a97656538fe24c015efbfc7954a66065139c34a
|
[
"MIT"
] | 149
|
2017-06-25T04:03:31.000Z
|
2022-02-24T19:31:06.000Z
|
ios/Classes/Native/Bulk_System_2.cpp
|
ShearerAWS/mini-mafia-release
|
1a97656538fe24c015efbfc7954a66065139c34a
|
[
"MIT"
] | 9
|
2017-06-24T23:23:11.000Z
|
2019-01-16T15:22:13.000Z
|
ios/Classes/Native/Bulk_System_2.cpp
|
ShearerAWS/mini-mafia-release
|
1a97656538fe24c015efbfc7954a66065139c34a
|
[
"MIT"
] | 29
|
2017-06-28T17:57:06.000Z
|
2021-06-27T12:26:44.000Z
|
#include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <cstring>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <limits>
#include <assert.h>
#include <stdint.h>
#include "il2cpp-class-internals.h"
#include "codegen/il2cpp-codegen.h"
#include "il2cpp-object-internals.h"
template <typename T1, typename T2>
struct VirtActionInvoker2
{
typedef void (*Action)(void*, T1, T2, const RuntimeMethod*);
static inline void Invoke (Il2CppMethodSlot slot, RuntimeObject* obj, T1 p1, T2 p2)
{
const VirtualInvokeData& invokeData = il2cpp_codegen_get_virtual_invoke_data(slot, obj);
((Action)invokeData.methodPtr)(obj, p1, p2, invokeData.method);
}
};
template <typename R, typename T1>
struct VirtFuncInvoker1
{
typedef R (*Func)(void*, T1, const RuntimeMethod*);
static inline R Invoke (Il2CppMethodSlot slot, RuntimeObject* obj, T1 p1)
{
const VirtualInvokeData& invokeData = il2cpp_codegen_get_virtual_invoke_data(slot, obj);
return ((Func)invokeData.methodPtr)(obj, p1, invokeData.method);
}
};
// System.Byte[]
struct ByteU5BU5D_t4116647657;
// System.Char[]
struct CharU5BU5D_t3528271667;
// System.Collections.ArrayList
struct ArrayList_t2718874744;
// System.Collections.Generic.Dictionary`2<System.Int32,System.Int32>
struct Dictionary_2_t1839659084;
// System.Collections.Generic.Dictionary`2<System.String,System.Int32>
struct Dictionary_2_t2736202052;
// System.Collections.Hashtable
struct Hashtable_t1853889766;
// System.Collections.Hashtable/HashKeys
struct HashKeys_t1568156503;
// System.Collections.Hashtable/HashValues
struct HashValues_t618387445;
// System.Collections.Hashtable/Slot[]
struct SlotU5BU5D_t2994659099;
// System.Collections.IComparer
struct IComparer_t1540313114;
// System.Collections.IDictionary
struct IDictionary_t1363984059;
// System.Collections.IEqualityComparer
struct IEqualityComparer_t1493878338;
// System.Collections.IHashCodeProvider
struct IHashCodeProvider_t267601189;
// System.DefaultUriParser
struct DefaultUriParser_t95882050;
// System.Exception
struct Exception_t;
// System.FormatException
struct FormatException_t154580423;
// System.Globalization.Calendar
struct Calendar_t1661121569;
// System.Globalization.Calendar[]
struct CalendarU5BU5D_t3985046076;
// System.Globalization.CompareInfo
struct CompareInfo_t1092934962;
// System.Globalization.CultureInfo
struct CultureInfo_t4157843068;
// System.Globalization.DateTimeFormatInfo
struct DateTimeFormatInfo_t2405853701;
// System.Globalization.NumberFormatInfo
struct NumberFormatInfo_t435877138;
// System.Globalization.TextInfo
struct TextInfo_t3810425522;
// System.Int32
struct Int32_t2950945753;
// System.Int32[]
struct Int32U5BU5D_t385246372;
// System.IntPtr[]
struct IntPtrU5BU5D_t4013366056;
// System.Runtime.Serialization.IFormatterConverter
struct IFormatterConverter_t2171992254;
// System.Runtime.Serialization.SerializationInfo
struct SerializationInfo_t950877179;
// System.String
struct String_t;
// System.String[]
struct StringU5BU5D_t1281789340;
// System.Text.RegularExpressions.FactoryCache
struct FactoryCache_t2327118887;
// System.Text.RegularExpressions.IMachineFactory
struct IMachineFactory_t1209798546;
// System.Text.RegularExpressions.Regex
struct Regex_t3657309853;
// System.Uri
struct Uri_t100236324;
// System.Uri/UriScheme[]
struct UriSchemeU5BU5D_t2082808316;
// System.UriFormatException
struct UriFormatException_t953270471;
// System.UriParser
struct UriParser_t3890150400;
// System.Void
struct Void_t1185182177;
extern RuntimeClass* CultureInfo_t4157843068_il2cpp_TypeInfo_var;
extern RuntimeClass* DefaultUriParser_t95882050_il2cpp_TypeInfo_var;
extern RuntimeClass* GenericUriParser_t1141496137_il2cpp_TypeInfo_var;
extern RuntimeClass* Hashtable_t1853889766_il2cpp_TypeInfo_var;
extern RuntimeClass* Regex_t3657309853_il2cpp_TypeInfo_var;
extern RuntimeClass* RuntimeObject_il2cpp_TypeInfo_var;
extern RuntimeClass* String_t_il2cpp_TypeInfo_var;
extern RuntimeClass* UriFormatException_t953270471_il2cpp_TypeInfo_var;
extern RuntimeClass* UriParser_t3890150400_il2cpp_TypeInfo_var;
extern RuntimeClass* Uri_t100236324_il2cpp_TypeInfo_var;
extern String_t* _stringLiteral2140524769;
extern String_t* _stringLiteral2864059369;
extern String_t* _stringLiteral3452614534;
extern String_t* _stringLiteral3698381084;
extern String_t* _stringLiteral4255182569;
extern String_t* _stringLiteral528199797;
extern const uint32_t UriFormatException__ctor_m1115096473_MetadataUsageId;
extern const uint32_t UriParser_CreateDefaults_m404296154_MetadataUsageId;
extern const uint32_t UriParser_GetParser_m544052729_MetadataUsageId;
extern const uint32_t UriParser_InitializeAndValidate_m2008117311_MetadataUsageId;
extern const uint32_t UriParser_InternalRegister_m3643767086_MetadataUsageId;
extern const uint32_t UriParser__cctor_m3655686731_MetadataUsageId;
#ifndef RUNTIMEOBJECT_H
#define RUNTIMEOBJECT_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Object
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // RUNTIMEOBJECT_H
struct Il2CppArrayBounds;
#ifndef RUNTIMEARRAY_H
#define RUNTIMEARRAY_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Array
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // RUNTIMEARRAY_H
#ifndef HASHTABLE_T1853889766_H
#define HASHTABLE_T1853889766_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Collections.Hashtable
struct Hashtable_t1853889766 : public RuntimeObject
{
public:
// System.Int32 System.Collections.Hashtable::inUse
int32_t ___inUse_1;
// System.Int32 System.Collections.Hashtable::modificationCount
int32_t ___modificationCount_2;
// System.Single System.Collections.Hashtable::loadFactor
float ___loadFactor_3;
// System.Collections.Hashtable/Slot[] System.Collections.Hashtable::table
SlotU5BU5D_t2994659099* ___table_4;
// System.Int32[] System.Collections.Hashtable::hashes
Int32U5BU5D_t385246372* ___hashes_5;
// System.Int32 System.Collections.Hashtable::threshold
int32_t ___threshold_6;
// System.Collections.Hashtable/HashKeys System.Collections.Hashtable::hashKeys
HashKeys_t1568156503 * ___hashKeys_7;
// System.Collections.Hashtable/HashValues System.Collections.Hashtable::hashValues
HashValues_t618387445 * ___hashValues_8;
// System.Collections.IHashCodeProvider System.Collections.Hashtable::hcpRef
RuntimeObject* ___hcpRef_9;
// System.Collections.IComparer System.Collections.Hashtable::comparerRef
RuntimeObject* ___comparerRef_10;
// System.Runtime.Serialization.SerializationInfo System.Collections.Hashtable::serializationInfo
SerializationInfo_t950877179 * ___serializationInfo_11;
// System.Collections.IEqualityComparer System.Collections.Hashtable::equalityComparer
RuntimeObject* ___equalityComparer_12;
public:
inline static int32_t get_offset_of_inUse_1() { return static_cast<int32_t>(offsetof(Hashtable_t1853889766, ___inUse_1)); }
inline int32_t get_inUse_1() const { return ___inUse_1; }
inline int32_t* get_address_of_inUse_1() { return &___inUse_1; }
inline void set_inUse_1(int32_t value)
{
___inUse_1 = value;
}
inline static int32_t get_offset_of_modificationCount_2() { return static_cast<int32_t>(offsetof(Hashtable_t1853889766, ___modificationCount_2)); }
inline int32_t get_modificationCount_2() const { return ___modificationCount_2; }
inline int32_t* get_address_of_modificationCount_2() { return &___modificationCount_2; }
inline void set_modificationCount_2(int32_t value)
{
___modificationCount_2 = value;
}
inline static int32_t get_offset_of_loadFactor_3() { return static_cast<int32_t>(offsetof(Hashtable_t1853889766, ___loadFactor_3)); }
inline float get_loadFactor_3() const { return ___loadFactor_3; }
inline float* get_address_of_loadFactor_3() { return &___loadFactor_3; }
inline void set_loadFactor_3(float value)
{
___loadFactor_3 = value;
}
inline static int32_t get_offset_of_table_4() { return static_cast<int32_t>(offsetof(Hashtable_t1853889766, ___table_4)); }
inline SlotU5BU5D_t2994659099* get_table_4() const { return ___table_4; }
inline SlotU5BU5D_t2994659099** get_address_of_table_4() { return &___table_4; }
inline void set_table_4(SlotU5BU5D_t2994659099* value)
{
___table_4 = value;
Il2CppCodeGenWriteBarrier((&___table_4), value);
}
inline static int32_t get_offset_of_hashes_5() { return static_cast<int32_t>(offsetof(Hashtable_t1853889766, ___hashes_5)); }
inline Int32U5BU5D_t385246372* get_hashes_5() const { return ___hashes_5; }
inline Int32U5BU5D_t385246372** get_address_of_hashes_5() { return &___hashes_5; }
inline void set_hashes_5(Int32U5BU5D_t385246372* value)
{
___hashes_5 = value;
Il2CppCodeGenWriteBarrier((&___hashes_5), value);
}
inline static int32_t get_offset_of_threshold_6() { return static_cast<int32_t>(offsetof(Hashtable_t1853889766, ___threshold_6)); }
inline int32_t get_threshold_6() const { return ___threshold_6; }
inline int32_t* get_address_of_threshold_6() { return &___threshold_6; }
inline void set_threshold_6(int32_t value)
{
___threshold_6 = value;
}
inline static int32_t get_offset_of_hashKeys_7() { return static_cast<int32_t>(offsetof(Hashtable_t1853889766, ___hashKeys_7)); }
inline HashKeys_t1568156503 * get_hashKeys_7() const { return ___hashKeys_7; }
inline HashKeys_t1568156503 ** get_address_of_hashKeys_7() { return &___hashKeys_7; }
inline void set_hashKeys_7(HashKeys_t1568156503 * value)
{
___hashKeys_7 = value;
Il2CppCodeGenWriteBarrier((&___hashKeys_7), value);
}
inline static int32_t get_offset_of_hashValues_8() { return static_cast<int32_t>(offsetof(Hashtable_t1853889766, ___hashValues_8)); }
inline HashValues_t618387445 * get_hashValues_8() const { return ___hashValues_8; }
inline HashValues_t618387445 ** get_address_of_hashValues_8() { return &___hashValues_8; }
inline void set_hashValues_8(HashValues_t618387445 * value)
{
___hashValues_8 = value;
Il2CppCodeGenWriteBarrier((&___hashValues_8), value);
}
inline static int32_t get_offset_of_hcpRef_9() { return static_cast<int32_t>(offsetof(Hashtable_t1853889766, ___hcpRef_9)); }
inline RuntimeObject* get_hcpRef_9() const { return ___hcpRef_9; }
inline RuntimeObject** get_address_of_hcpRef_9() { return &___hcpRef_9; }
inline void set_hcpRef_9(RuntimeObject* value)
{
___hcpRef_9 = value;
Il2CppCodeGenWriteBarrier((&___hcpRef_9), value);
}
inline static int32_t get_offset_of_comparerRef_10() { return static_cast<int32_t>(offsetof(Hashtable_t1853889766, ___comparerRef_10)); }
inline RuntimeObject* get_comparerRef_10() const { return ___comparerRef_10; }
inline RuntimeObject** get_address_of_comparerRef_10() { return &___comparerRef_10; }
inline void set_comparerRef_10(RuntimeObject* value)
{
___comparerRef_10 = value;
Il2CppCodeGenWriteBarrier((&___comparerRef_10), value);
}
inline static int32_t get_offset_of_serializationInfo_11() { return static_cast<int32_t>(offsetof(Hashtable_t1853889766, ___serializationInfo_11)); }
inline SerializationInfo_t950877179 * get_serializationInfo_11() const { return ___serializationInfo_11; }
inline SerializationInfo_t950877179 ** get_address_of_serializationInfo_11() { return &___serializationInfo_11; }
inline void set_serializationInfo_11(SerializationInfo_t950877179 * value)
{
___serializationInfo_11 = value;
Il2CppCodeGenWriteBarrier((&___serializationInfo_11), value);
}
inline static int32_t get_offset_of_equalityComparer_12() { return static_cast<int32_t>(offsetof(Hashtable_t1853889766, ___equalityComparer_12)); }
inline RuntimeObject* get_equalityComparer_12() const { return ___equalityComparer_12; }
inline RuntimeObject** get_address_of_equalityComparer_12() { return &___equalityComparer_12; }
inline void set_equalityComparer_12(RuntimeObject* value)
{
___equalityComparer_12 = value;
Il2CppCodeGenWriteBarrier((&___equalityComparer_12), value);
}
};
struct Hashtable_t1853889766_StaticFields
{
public:
// System.Int32[] System.Collections.Hashtable::primeTbl
Int32U5BU5D_t385246372* ___primeTbl_13;
public:
inline static int32_t get_offset_of_primeTbl_13() { return static_cast<int32_t>(offsetof(Hashtable_t1853889766_StaticFields, ___primeTbl_13)); }
inline Int32U5BU5D_t385246372* get_primeTbl_13() const { return ___primeTbl_13; }
inline Int32U5BU5D_t385246372** get_address_of_primeTbl_13() { return &___primeTbl_13; }
inline void set_primeTbl_13(Int32U5BU5D_t385246372* value)
{
___primeTbl_13 = value;
Il2CppCodeGenWriteBarrier((&___primeTbl_13), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // HASHTABLE_T1853889766_H
#ifndef TYPECONVERTER_T2249118273_H
#define TYPECONVERTER_T2249118273_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.ComponentModel.TypeConverter
struct TypeConverter_t2249118273 : public RuntimeObject
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // TYPECONVERTER_T2249118273_H
#ifndef EXCEPTION_T_H
#define EXCEPTION_T_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Exception
struct Exception_t : public RuntimeObject
{
public:
// System.IntPtr[] System.Exception::trace_ips
IntPtrU5BU5D_t4013366056* ___trace_ips_0;
// System.Exception System.Exception::inner_exception
Exception_t * ___inner_exception_1;
// System.String System.Exception::message
String_t* ___message_2;
// System.String System.Exception::help_link
String_t* ___help_link_3;
// System.String System.Exception::class_name
String_t* ___class_name_4;
// System.String System.Exception::stack_trace
String_t* ___stack_trace_5;
// System.String System.Exception::_remoteStackTraceString
String_t* ____remoteStackTraceString_6;
// System.Int32 System.Exception::remote_stack_index
int32_t ___remote_stack_index_7;
// System.Int32 System.Exception::hresult
int32_t ___hresult_8;
// System.String System.Exception::source
String_t* ___source_9;
// System.Collections.IDictionary System.Exception::_data
RuntimeObject* ____data_10;
public:
inline static int32_t get_offset_of_trace_ips_0() { return static_cast<int32_t>(offsetof(Exception_t, ___trace_ips_0)); }
inline IntPtrU5BU5D_t4013366056* get_trace_ips_0() const { return ___trace_ips_0; }
inline IntPtrU5BU5D_t4013366056** get_address_of_trace_ips_0() { return &___trace_ips_0; }
inline void set_trace_ips_0(IntPtrU5BU5D_t4013366056* value)
{
___trace_ips_0 = value;
Il2CppCodeGenWriteBarrier((&___trace_ips_0), value);
}
inline static int32_t get_offset_of_inner_exception_1() { return static_cast<int32_t>(offsetof(Exception_t, ___inner_exception_1)); }
inline Exception_t * get_inner_exception_1() const { return ___inner_exception_1; }
inline Exception_t ** get_address_of_inner_exception_1() { return &___inner_exception_1; }
inline void set_inner_exception_1(Exception_t * value)
{
___inner_exception_1 = value;
Il2CppCodeGenWriteBarrier((&___inner_exception_1), value);
}
inline static int32_t get_offset_of_message_2() { return static_cast<int32_t>(offsetof(Exception_t, ___message_2)); }
inline String_t* get_message_2() const { return ___message_2; }
inline String_t** get_address_of_message_2() { return &___message_2; }
inline void set_message_2(String_t* value)
{
___message_2 = value;
Il2CppCodeGenWriteBarrier((&___message_2), value);
}
inline static int32_t get_offset_of_help_link_3() { return static_cast<int32_t>(offsetof(Exception_t, ___help_link_3)); }
inline String_t* get_help_link_3() const { return ___help_link_3; }
inline String_t** get_address_of_help_link_3() { return &___help_link_3; }
inline void set_help_link_3(String_t* value)
{
___help_link_3 = value;
Il2CppCodeGenWriteBarrier((&___help_link_3), value);
}
inline static int32_t get_offset_of_class_name_4() { return static_cast<int32_t>(offsetof(Exception_t, ___class_name_4)); }
inline String_t* get_class_name_4() const { return ___class_name_4; }
inline String_t** get_address_of_class_name_4() { return &___class_name_4; }
inline void set_class_name_4(String_t* value)
{
___class_name_4 = value;
Il2CppCodeGenWriteBarrier((&___class_name_4), value);
}
inline static int32_t get_offset_of_stack_trace_5() { return static_cast<int32_t>(offsetof(Exception_t, ___stack_trace_5)); }
inline String_t* get_stack_trace_5() const { return ___stack_trace_5; }
inline String_t** get_address_of_stack_trace_5() { return &___stack_trace_5; }
inline void set_stack_trace_5(String_t* value)
{
___stack_trace_5 = value;
Il2CppCodeGenWriteBarrier((&___stack_trace_5), value);
}
inline static int32_t get_offset_of__remoteStackTraceString_6() { return static_cast<int32_t>(offsetof(Exception_t, ____remoteStackTraceString_6)); }
inline String_t* get__remoteStackTraceString_6() const { return ____remoteStackTraceString_6; }
inline String_t** get_address_of__remoteStackTraceString_6() { return &____remoteStackTraceString_6; }
inline void set__remoteStackTraceString_6(String_t* value)
{
____remoteStackTraceString_6 = value;
Il2CppCodeGenWriteBarrier((&____remoteStackTraceString_6), value);
}
inline static int32_t get_offset_of_remote_stack_index_7() { return static_cast<int32_t>(offsetof(Exception_t, ___remote_stack_index_7)); }
inline int32_t get_remote_stack_index_7() const { return ___remote_stack_index_7; }
inline int32_t* get_address_of_remote_stack_index_7() { return &___remote_stack_index_7; }
inline void set_remote_stack_index_7(int32_t value)
{
___remote_stack_index_7 = value;
}
inline static int32_t get_offset_of_hresult_8() { return static_cast<int32_t>(offsetof(Exception_t, ___hresult_8)); }
inline int32_t get_hresult_8() const { return ___hresult_8; }
inline int32_t* get_address_of_hresult_8() { return &___hresult_8; }
inline void set_hresult_8(int32_t value)
{
___hresult_8 = value;
}
inline static int32_t get_offset_of_source_9() { return static_cast<int32_t>(offsetof(Exception_t, ___source_9)); }
inline String_t* get_source_9() const { return ___source_9; }
inline String_t** get_address_of_source_9() { return &___source_9; }
inline void set_source_9(String_t* value)
{
___source_9 = value;
Il2CppCodeGenWriteBarrier((&___source_9), value);
}
inline static int32_t get_offset_of__data_10() { return static_cast<int32_t>(offsetof(Exception_t, ____data_10)); }
inline RuntimeObject* get__data_10() const { return ____data_10; }
inline RuntimeObject** get_address_of__data_10() { return &____data_10; }
inline void set__data_10(RuntimeObject* value)
{
____data_10 = value;
Il2CppCodeGenWriteBarrier((&____data_10), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // EXCEPTION_T_H
#ifndef CULTUREINFO_T4157843068_H
#define CULTUREINFO_T4157843068_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Globalization.CultureInfo
struct CultureInfo_t4157843068 : public RuntimeObject
{
public:
// System.Boolean System.Globalization.CultureInfo::m_isReadOnly
bool ___m_isReadOnly_7;
// System.Int32 System.Globalization.CultureInfo::cultureID
int32_t ___cultureID_8;
// System.Int32 System.Globalization.CultureInfo::parent_lcid
int32_t ___parent_lcid_9;
// System.Int32 System.Globalization.CultureInfo::specific_lcid
int32_t ___specific_lcid_10;
// System.Int32 System.Globalization.CultureInfo::datetime_index
int32_t ___datetime_index_11;
// System.Int32 System.Globalization.CultureInfo::number_index
int32_t ___number_index_12;
// System.Boolean System.Globalization.CultureInfo::m_useUserOverride
bool ___m_useUserOverride_13;
// System.Globalization.NumberFormatInfo modreq(System.Runtime.CompilerServices.IsVolatile) System.Globalization.CultureInfo::numInfo
NumberFormatInfo_t435877138 * ___numInfo_14;
// System.Globalization.DateTimeFormatInfo modreq(System.Runtime.CompilerServices.IsVolatile) System.Globalization.CultureInfo::dateTimeInfo
DateTimeFormatInfo_t2405853701 * ___dateTimeInfo_15;
// System.Globalization.TextInfo modreq(System.Runtime.CompilerServices.IsVolatile) System.Globalization.CultureInfo::textInfo
TextInfo_t3810425522 * ___textInfo_16;
// System.String System.Globalization.CultureInfo::m_name
String_t* ___m_name_17;
// System.String System.Globalization.CultureInfo::displayname
String_t* ___displayname_18;
// System.String System.Globalization.CultureInfo::englishname
String_t* ___englishname_19;
// System.String System.Globalization.CultureInfo::nativename
String_t* ___nativename_20;
// System.String System.Globalization.CultureInfo::iso3lang
String_t* ___iso3lang_21;
// System.String System.Globalization.CultureInfo::iso2lang
String_t* ___iso2lang_22;
// System.String System.Globalization.CultureInfo::icu_name
String_t* ___icu_name_23;
// System.String System.Globalization.CultureInfo::win3lang
String_t* ___win3lang_24;
// System.String System.Globalization.CultureInfo::territory
String_t* ___territory_25;
// System.Globalization.CompareInfo modreq(System.Runtime.CompilerServices.IsVolatile) System.Globalization.CultureInfo::compareInfo
CompareInfo_t1092934962 * ___compareInfo_26;
// System.Int32* System.Globalization.CultureInfo::calendar_data
int32_t* ___calendar_data_27;
// System.Void* System.Globalization.CultureInfo::textinfo_data
void* ___textinfo_data_28;
// System.Globalization.Calendar[] System.Globalization.CultureInfo::optional_calendars
CalendarU5BU5D_t3985046076* ___optional_calendars_29;
// System.Globalization.CultureInfo System.Globalization.CultureInfo::parent_culture
CultureInfo_t4157843068 * ___parent_culture_30;
// System.Int32 System.Globalization.CultureInfo::m_dataItem
int32_t ___m_dataItem_31;
// System.Globalization.Calendar System.Globalization.CultureInfo::calendar
Calendar_t1661121569 * ___calendar_32;
// System.Boolean System.Globalization.CultureInfo::constructed
bool ___constructed_33;
// System.Byte[] System.Globalization.CultureInfo::cached_serialized_form
ByteU5BU5D_t4116647657* ___cached_serialized_form_34;
public:
inline static int32_t get_offset_of_m_isReadOnly_7() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___m_isReadOnly_7)); }
inline bool get_m_isReadOnly_7() const { return ___m_isReadOnly_7; }
inline bool* get_address_of_m_isReadOnly_7() { return &___m_isReadOnly_7; }
inline void set_m_isReadOnly_7(bool value)
{
___m_isReadOnly_7 = value;
}
inline static int32_t get_offset_of_cultureID_8() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___cultureID_8)); }
inline int32_t get_cultureID_8() const { return ___cultureID_8; }
inline int32_t* get_address_of_cultureID_8() { return &___cultureID_8; }
inline void set_cultureID_8(int32_t value)
{
___cultureID_8 = value;
}
inline static int32_t get_offset_of_parent_lcid_9() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___parent_lcid_9)); }
inline int32_t get_parent_lcid_9() const { return ___parent_lcid_9; }
inline int32_t* get_address_of_parent_lcid_9() { return &___parent_lcid_9; }
inline void set_parent_lcid_9(int32_t value)
{
___parent_lcid_9 = value;
}
inline static int32_t get_offset_of_specific_lcid_10() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___specific_lcid_10)); }
inline int32_t get_specific_lcid_10() const { return ___specific_lcid_10; }
inline int32_t* get_address_of_specific_lcid_10() { return &___specific_lcid_10; }
inline void set_specific_lcid_10(int32_t value)
{
___specific_lcid_10 = value;
}
inline static int32_t get_offset_of_datetime_index_11() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___datetime_index_11)); }
inline int32_t get_datetime_index_11() const { return ___datetime_index_11; }
inline int32_t* get_address_of_datetime_index_11() { return &___datetime_index_11; }
inline void set_datetime_index_11(int32_t value)
{
___datetime_index_11 = value;
}
inline static int32_t get_offset_of_number_index_12() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___number_index_12)); }
inline int32_t get_number_index_12() const { return ___number_index_12; }
inline int32_t* get_address_of_number_index_12() { return &___number_index_12; }
inline void set_number_index_12(int32_t value)
{
___number_index_12 = value;
}
inline static int32_t get_offset_of_m_useUserOverride_13() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___m_useUserOverride_13)); }
inline bool get_m_useUserOverride_13() const { return ___m_useUserOverride_13; }
inline bool* get_address_of_m_useUserOverride_13() { return &___m_useUserOverride_13; }
inline void set_m_useUserOverride_13(bool value)
{
___m_useUserOverride_13 = value;
}
inline static int32_t get_offset_of_numInfo_14() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___numInfo_14)); }
inline NumberFormatInfo_t435877138 * get_numInfo_14() const { return ___numInfo_14; }
inline NumberFormatInfo_t435877138 ** get_address_of_numInfo_14() { return &___numInfo_14; }
inline void set_numInfo_14(NumberFormatInfo_t435877138 * value)
{
___numInfo_14 = value;
Il2CppCodeGenWriteBarrier((&___numInfo_14), value);
}
inline static int32_t get_offset_of_dateTimeInfo_15() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___dateTimeInfo_15)); }
inline DateTimeFormatInfo_t2405853701 * get_dateTimeInfo_15() const { return ___dateTimeInfo_15; }
inline DateTimeFormatInfo_t2405853701 ** get_address_of_dateTimeInfo_15() { return &___dateTimeInfo_15; }
inline void set_dateTimeInfo_15(DateTimeFormatInfo_t2405853701 * value)
{
___dateTimeInfo_15 = value;
Il2CppCodeGenWriteBarrier((&___dateTimeInfo_15), value);
}
inline static int32_t get_offset_of_textInfo_16() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___textInfo_16)); }
inline TextInfo_t3810425522 * get_textInfo_16() const { return ___textInfo_16; }
inline TextInfo_t3810425522 ** get_address_of_textInfo_16() { return &___textInfo_16; }
inline void set_textInfo_16(TextInfo_t3810425522 * value)
{
___textInfo_16 = value;
Il2CppCodeGenWriteBarrier((&___textInfo_16), value);
}
inline static int32_t get_offset_of_m_name_17() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___m_name_17)); }
inline String_t* get_m_name_17() const { return ___m_name_17; }
inline String_t** get_address_of_m_name_17() { return &___m_name_17; }
inline void set_m_name_17(String_t* value)
{
___m_name_17 = value;
Il2CppCodeGenWriteBarrier((&___m_name_17), value);
}
inline static int32_t get_offset_of_displayname_18() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___displayname_18)); }
inline String_t* get_displayname_18() const { return ___displayname_18; }
inline String_t** get_address_of_displayname_18() { return &___displayname_18; }
inline void set_displayname_18(String_t* value)
{
___displayname_18 = value;
Il2CppCodeGenWriteBarrier((&___displayname_18), value);
}
inline static int32_t get_offset_of_englishname_19() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___englishname_19)); }
inline String_t* get_englishname_19() const { return ___englishname_19; }
inline String_t** get_address_of_englishname_19() { return &___englishname_19; }
inline void set_englishname_19(String_t* value)
{
___englishname_19 = value;
Il2CppCodeGenWriteBarrier((&___englishname_19), value);
}
inline static int32_t get_offset_of_nativename_20() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___nativename_20)); }
inline String_t* get_nativename_20() const { return ___nativename_20; }
inline String_t** get_address_of_nativename_20() { return &___nativename_20; }
inline void set_nativename_20(String_t* value)
{
___nativename_20 = value;
Il2CppCodeGenWriteBarrier((&___nativename_20), value);
}
inline static int32_t get_offset_of_iso3lang_21() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___iso3lang_21)); }
inline String_t* get_iso3lang_21() const { return ___iso3lang_21; }
inline String_t** get_address_of_iso3lang_21() { return &___iso3lang_21; }
inline void set_iso3lang_21(String_t* value)
{
___iso3lang_21 = value;
Il2CppCodeGenWriteBarrier((&___iso3lang_21), value);
}
inline static int32_t get_offset_of_iso2lang_22() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___iso2lang_22)); }
inline String_t* get_iso2lang_22() const { return ___iso2lang_22; }
inline String_t** get_address_of_iso2lang_22() { return &___iso2lang_22; }
inline void set_iso2lang_22(String_t* value)
{
___iso2lang_22 = value;
Il2CppCodeGenWriteBarrier((&___iso2lang_22), value);
}
inline static int32_t get_offset_of_icu_name_23() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___icu_name_23)); }
inline String_t* get_icu_name_23() const { return ___icu_name_23; }
inline String_t** get_address_of_icu_name_23() { return &___icu_name_23; }
inline void set_icu_name_23(String_t* value)
{
___icu_name_23 = value;
Il2CppCodeGenWriteBarrier((&___icu_name_23), value);
}
inline static int32_t get_offset_of_win3lang_24() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___win3lang_24)); }
inline String_t* get_win3lang_24() const { return ___win3lang_24; }
inline String_t** get_address_of_win3lang_24() { return &___win3lang_24; }
inline void set_win3lang_24(String_t* value)
{
___win3lang_24 = value;
Il2CppCodeGenWriteBarrier((&___win3lang_24), value);
}
inline static int32_t get_offset_of_territory_25() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___territory_25)); }
inline String_t* get_territory_25() const { return ___territory_25; }
inline String_t** get_address_of_territory_25() { return &___territory_25; }
inline void set_territory_25(String_t* value)
{
___territory_25 = value;
Il2CppCodeGenWriteBarrier((&___territory_25), value);
}
inline static int32_t get_offset_of_compareInfo_26() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___compareInfo_26)); }
inline CompareInfo_t1092934962 * get_compareInfo_26() const { return ___compareInfo_26; }
inline CompareInfo_t1092934962 ** get_address_of_compareInfo_26() { return &___compareInfo_26; }
inline void set_compareInfo_26(CompareInfo_t1092934962 * value)
{
___compareInfo_26 = value;
Il2CppCodeGenWriteBarrier((&___compareInfo_26), value);
}
inline static int32_t get_offset_of_calendar_data_27() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___calendar_data_27)); }
inline int32_t* get_calendar_data_27() const { return ___calendar_data_27; }
inline int32_t** get_address_of_calendar_data_27() { return &___calendar_data_27; }
inline void set_calendar_data_27(int32_t* value)
{
___calendar_data_27 = value;
}
inline static int32_t get_offset_of_textinfo_data_28() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___textinfo_data_28)); }
inline void* get_textinfo_data_28() const { return ___textinfo_data_28; }
inline void** get_address_of_textinfo_data_28() { return &___textinfo_data_28; }
inline void set_textinfo_data_28(void* value)
{
___textinfo_data_28 = value;
}
inline static int32_t get_offset_of_optional_calendars_29() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___optional_calendars_29)); }
inline CalendarU5BU5D_t3985046076* get_optional_calendars_29() const { return ___optional_calendars_29; }
inline CalendarU5BU5D_t3985046076** get_address_of_optional_calendars_29() { return &___optional_calendars_29; }
inline void set_optional_calendars_29(CalendarU5BU5D_t3985046076* value)
{
___optional_calendars_29 = value;
Il2CppCodeGenWriteBarrier((&___optional_calendars_29), value);
}
inline static int32_t get_offset_of_parent_culture_30() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___parent_culture_30)); }
inline CultureInfo_t4157843068 * get_parent_culture_30() const { return ___parent_culture_30; }
inline CultureInfo_t4157843068 ** get_address_of_parent_culture_30() { return &___parent_culture_30; }
inline void set_parent_culture_30(CultureInfo_t4157843068 * value)
{
___parent_culture_30 = value;
Il2CppCodeGenWriteBarrier((&___parent_culture_30), value);
}
inline static int32_t get_offset_of_m_dataItem_31() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___m_dataItem_31)); }
inline int32_t get_m_dataItem_31() const { return ___m_dataItem_31; }
inline int32_t* get_address_of_m_dataItem_31() { return &___m_dataItem_31; }
inline void set_m_dataItem_31(int32_t value)
{
___m_dataItem_31 = value;
}
inline static int32_t get_offset_of_calendar_32() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___calendar_32)); }
inline Calendar_t1661121569 * get_calendar_32() const { return ___calendar_32; }
inline Calendar_t1661121569 ** get_address_of_calendar_32() { return &___calendar_32; }
inline void set_calendar_32(Calendar_t1661121569 * value)
{
___calendar_32 = value;
Il2CppCodeGenWriteBarrier((&___calendar_32), value);
}
inline static int32_t get_offset_of_constructed_33() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___constructed_33)); }
inline bool get_constructed_33() const { return ___constructed_33; }
inline bool* get_address_of_constructed_33() { return &___constructed_33; }
inline void set_constructed_33(bool value)
{
___constructed_33 = value;
}
inline static int32_t get_offset_of_cached_serialized_form_34() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068, ___cached_serialized_form_34)); }
inline ByteU5BU5D_t4116647657* get_cached_serialized_form_34() const { return ___cached_serialized_form_34; }
inline ByteU5BU5D_t4116647657** get_address_of_cached_serialized_form_34() { return &___cached_serialized_form_34; }
inline void set_cached_serialized_form_34(ByteU5BU5D_t4116647657* value)
{
___cached_serialized_form_34 = value;
Il2CppCodeGenWriteBarrier((&___cached_serialized_form_34), value);
}
};
struct CultureInfo_t4157843068_StaticFields
{
public:
// System.Globalization.CultureInfo modreq(System.Runtime.CompilerServices.IsVolatile) System.Globalization.CultureInfo::invariant_culture_info
CultureInfo_t4157843068 * ___invariant_culture_info_4;
// System.Object System.Globalization.CultureInfo::shared_table_lock
RuntimeObject * ___shared_table_lock_5;
// System.Int32 System.Globalization.CultureInfo::BootstrapCultureID
int32_t ___BootstrapCultureID_6;
// System.String System.Globalization.CultureInfo::MSG_READONLY
String_t* ___MSG_READONLY_35;
// System.Collections.Hashtable System.Globalization.CultureInfo::shared_by_number
Hashtable_t1853889766 * ___shared_by_number_36;
// System.Collections.Hashtable System.Globalization.CultureInfo::shared_by_name
Hashtable_t1853889766 * ___shared_by_name_37;
// System.Collections.Generic.Dictionary`2<System.String,System.Int32> System.Globalization.CultureInfo::<>f__switch$map19
Dictionary_2_t2736202052 * ___U3CU3Ef__switchU24map19_38;
// System.Collections.Generic.Dictionary`2<System.String,System.Int32> System.Globalization.CultureInfo::<>f__switch$map1A
Dictionary_2_t2736202052 * ___U3CU3Ef__switchU24map1A_39;
public:
inline static int32_t get_offset_of_invariant_culture_info_4() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068_StaticFields, ___invariant_culture_info_4)); }
inline CultureInfo_t4157843068 * get_invariant_culture_info_4() const { return ___invariant_culture_info_4; }
inline CultureInfo_t4157843068 ** get_address_of_invariant_culture_info_4() { return &___invariant_culture_info_4; }
inline void set_invariant_culture_info_4(CultureInfo_t4157843068 * value)
{
___invariant_culture_info_4 = value;
Il2CppCodeGenWriteBarrier((&___invariant_culture_info_4), value);
}
inline static int32_t get_offset_of_shared_table_lock_5() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068_StaticFields, ___shared_table_lock_5)); }
inline RuntimeObject * get_shared_table_lock_5() const { return ___shared_table_lock_5; }
inline RuntimeObject ** get_address_of_shared_table_lock_5() { return &___shared_table_lock_5; }
inline void set_shared_table_lock_5(RuntimeObject * value)
{
___shared_table_lock_5 = value;
Il2CppCodeGenWriteBarrier((&___shared_table_lock_5), value);
}
inline static int32_t get_offset_of_BootstrapCultureID_6() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068_StaticFields, ___BootstrapCultureID_6)); }
inline int32_t get_BootstrapCultureID_6() const { return ___BootstrapCultureID_6; }
inline int32_t* get_address_of_BootstrapCultureID_6() { return &___BootstrapCultureID_6; }
inline void set_BootstrapCultureID_6(int32_t value)
{
___BootstrapCultureID_6 = value;
}
inline static int32_t get_offset_of_MSG_READONLY_35() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068_StaticFields, ___MSG_READONLY_35)); }
inline String_t* get_MSG_READONLY_35() const { return ___MSG_READONLY_35; }
inline String_t** get_address_of_MSG_READONLY_35() { return &___MSG_READONLY_35; }
inline void set_MSG_READONLY_35(String_t* value)
{
___MSG_READONLY_35 = value;
Il2CppCodeGenWriteBarrier((&___MSG_READONLY_35), value);
}
inline static int32_t get_offset_of_shared_by_number_36() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068_StaticFields, ___shared_by_number_36)); }
inline Hashtable_t1853889766 * get_shared_by_number_36() const { return ___shared_by_number_36; }
inline Hashtable_t1853889766 ** get_address_of_shared_by_number_36() { return &___shared_by_number_36; }
inline void set_shared_by_number_36(Hashtable_t1853889766 * value)
{
___shared_by_number_36 = value;
Il2CppCodeGenWriteBarrier((&___shared_by_number_36), value);
}
inline static int32_t get_offset_of_shared_by_name_37() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068_StaticFields, ___shared_by_name_37)); }
inline Hashtable_t1853889766 * get_shared_by_name_37() const { return ___shared_by_name_37; }
inline Hashtable_t1853889766 ** get_address_of_shared_by_name_37() { return &___shared_by_name_37; }
inline void set_shared_by_name_37(Hashtable_t1853889766 * value)
{
___shared_by_name_37 = value;
Il2CppCodeGenWriteBarrier((&___shared_by_name_37), value);
}
inline static int32_t get_offset_of_U3CU3Ef__switchU24map19_38() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068_StaticFields, ___U3CU3Ef__switchU24map19_38)); }
inline Dictionary_2_t2736202052 * get_U3CU3Ef__switchU24map19_38() const { return ___U3CU3Ef__switchU24map19_38; }
inline Dictionary_2_t2736202052 ** get_address_of_U3CU3Ef__switchU24map19_38() { return &___U3CU3Ef__switchU24map19_38; }
inline void set_U3CU3Ef__switchU24map19_38(Dictionary_2_t2736202052 * value)
{
___U3CU3Ef__switchU24map19_38 = value;
Il2CppCodeGenWriteBarrier((&___U3CU3Ef__switchU24map19_38), value);
}
inline static int32_t get_offset_of_U3CU3Ef__switchU24map1A_39() { return static_cast<int32_t>(offsetof(CultureInfo_t4157843068_StaticFields, ___U3CU3Ef__switchU24map1A_39)); }
inline Dictionary_2_t2736202052 * get_U3CU3Ef__switchU24map1A_39() const { return ___U3CU3Ef__switchU24map1A_39; }
inline Dictionary_2_t2736202052 ** get_address_of_U3CU3Ef__switchU24map1A_39() { return &___U3CU3Ef__switchU24map1A_39; }
inline void set_U3CU3Ef__switchU24map1A_39(Dictionary_2_t2736202052 * value)
{
___U3CU3Ef__switchU24map1A_39 = value;
Il2CppCodeGenWriteBarrier((&___U3CU3Ef__switchU24map1A_39), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // CULTUREINFO_T4157843068_H
#ifndef SERIALIZATIONINFO_T950877179_H
#define SERIALIZATIONINFO_T950877179_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Runtime.Serialization.SerializationInfo
struct SerializationInfo_t950877179 : public RuntimeObject
{
public:
// System.Collections.Hashtable System.Runtime.Serialization.SerializationInfo::serialized
Hashtable_t1853889766 * ___serialized_0;
// System.Collections.ArrayList System.Runtime.Serialization.SerializationInfo::values
ArrayList_t2718874744 * ___values_1;
// System.String System.Runtime.Serialization.SerializationInfo::assemblyName
String_t* ___assemblyName_2;
// System.String System.Runtime.Serialization.SerializationInfo::fullTypeName
String_t* ___fullTypeName_3;
// System.Runtime.Serialization.IFormatterConverter System.Runtime.Serialization.SerializationInfo::converter
RuntimeObject* ___converter_4;
public:
inline static int32_t get_offset_of_serialized_0() { return static_cast<int32_t>(offsetof(SerializationInfo_t950877179, ___serialized_0)); }
inline Hashtable_t1853889766 * get_serialized_0() const { return ___serialized_0; }
inline Hashtable_t1853889766 ** get_address_of_serialized_0() { return &___serialized_0; }
inline void set_serialized_0(Hashtable_t1853889766 * value)
{
___serialized_0 = value;
Il2CppCodeGenWriteBarrier((&___serialized_0), value);
}
inline static int32_t get_offset_of_values_1() { return static_cast<int32_t>(offsetof(SerializationInfo_t950877179, ___values_1)); }
inline ArrayList_t2718874744 * get_values_1() const { return ___values_1; }
inline ArrayList_t2718874744 ** get_address_of_values_1() { return &___values_1; }
inline void set_values_1(ArrayList_t2718874744 * value)
{
___values_1 = value;
Il2CppCodeGenWriteBarrier((&___values_1), value);
}
inline static int32_t get_offset_of_assemblyName_2() { return static_cast<int32_t>(offsetof(SerializationInfo_t950877179, ___assemblyName_2)); }
inline String_t* get_assemblyName_2() const { return ___assemblyName_2; }
inline String_t** get_address_of_assemblyName_2() { return &___assemblyName_2; }
inline void set_assemblyName_2(String_t* value)
{
___assemblyName_2 = value;
Il2CppCodeGenWriteBarrier((&___assemblyName_2), value);
}
inline static int32_t get_offset_of_fullTypeName_3() { return static_cast<int32_t>(offsetof(SerializationInfo_t950877179, ___fullTypeName_3)); }
inline String_t* get_fullTypeName_3() const { return ___fullTypeName_3; }
inline String_t** get_address_of_fullTypeName_3() { return &___fullTypeName_3; }
inline void set_fullTypeName_3(String_t* value)
{
___fullTypeName_3 = value;
Il2CppCodeGenWriteBarrier((&___fullTypeName_3), value);
}
inline static int32_t get_offset_of_converter_4() { return static_cast<int32_t>(offsetof(SerializationInfo_t950877179, ___converter_4)); }
inline RuntimeObject* get_converter_4() const { return ___converter_4; }
inline RuntimeObject** get_address_of_converter_4() { return &___converter_4; }
inline void set_converter_4(RuntimeObject* value)
{
___converter_4 = value;
Il2CppCodeGenWriteBarrier((&___converter_4), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // SERIALIZATIONINFO_T950877179_H
#ifndef STRING_T_H
#define STRING_T_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.String
struct String_t : public RuntimeObject
{
public:
// System.Int32 System.String::length
int32_t ___length_0;
// System.Char System.String::start_char
Il2CppChar ___start_char_1;
public:
inline static int32_t get_offset_of_length_0() { return static_cast<int32_t>(offsetof(String_t, ___length_0)); }
inline int32_t get_length_0() const { return ___length_0; }
inline int32_t* get_address_of_length_0() { return &___length_0; }
inline void set_length_0(int32_t value)
{
___length_0 = value;
}
inline static int32_t get_offset_of_start_char_1() { return static_cast<int32_t>(offsetof(String_t, ___start_char_1)); }
inline Il2CppChar get_start_char_1() const { return ___start_char_1; }
inline Il2CppChar* get_address_of_start_char_1() { return &___start_char_1; }
inline void set_start_char_1(Il2CppChar value)
{
___start_char_1 = value;
}
};
struct String_t_StaticFields
{
public:
// System.String System.String::Empty
String_t* ___Empty_2;
// System.Char[] System.String::WhiteChars
CharU5BU5D_t3528271667* ___WhiteChars_3;
public:
inline static int32_t get_offset_of_Empty_2() { return static_cast<int32_t>(offsetof(String_t_StaticFields, ___Empty_2)); }
inline String_t* get_Empty_2() const { return ___Empty_2; }
inline String_t** get_address_of_Empty_2() { return &___Empty_2; }
inline void set_Empty_2(String_t* value)
{
___Empty_2 = value;
Il2CppCodeGenWriteBarrier((&___Empty_2), value);
}
inline static int32_t get_offset_of_WhiteChars_3() { return static_cast<int32_t>(offsetof(String_t_StaticFields, ___WhiteChars_3)); }
inline CharU5BU5D_t3528271667* get_WhiteChars_3() const { return ___WhiteChars_3; }
inline CharU5BU5D_t3528271667** get_address_of_WhiteChars_3() { return &___WhiteChars_3; }
inline void set_WhiteChars_3(CharU5BU5D_t3528271667* value)
{
___WhiteChars_3 = value;
Il2CppCodeGenWriteBarrier((&___WhiteChars_3), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // STRING_T_H
#ifndef URI_T100236324_H
#define URI_T100236324_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Uri
struct Uri_t100236324 : public RuntimeObject
{
public:
// System.Boolean System.Uri::isUnixFilePath
bool ___isUnixFilePath_1;
// System.String System.Uri::source
String_t* ___source_2;
// System.String System.Uri::scheme
String_t* ___scheme_3;
// System.String System.Uri::host
String_t* ___host_4;
// System.Int32 System.Uri::port
int32_t ___port_5;
// System.String System.Uri::path
String_t* ___path_6;
// System.String System.Uri::query
String_t* ___query_7;
// System.String System.Uri::fragment
String_t* ___fragment_8;
// System.String System.Uri::userinfo
String_t* ___userinfo_9;
// System.Boolean System.Uri::isUnc
bool ___isUnc_10;
// System.Boolean System.Uri::isOpaquePart
bool ___isOpaquePart_11;
// System.Boolean System.Uri::isAbsoluteUri
bool ___isAbsoluteUri_12;
// System.String[] System.Uri::segments
StringU5BU5D_t1281789340* ___segments_13;
// System.Boolean System.Uri::userEscaped
bool ___userEscaped_14;
// System.String System.Uri::cachedAbsoluteUri
String_t* ___cachedAbsoluteUri_15;
// System.String System.Uri::cachedToString
String_t* ___cachedToString_16;
// System.String System.Uri::cachedLocalPath
String_t* ___cachedLocalPath_17;
// System.Int32 System.Uri::cachedHashCode
int32_t ___cachedHashCode_18;
// System.UriParser System.Uri::parser
UriParser_t3890150400 * ___parser_32;
public:
inline static int32_t get_offset_of_isUnixFilePath_1() { return static_cast<int32_t>(offsetof(Uri_t100236324, ___isUnixFilePath_1)); }
inline bool get_isUnixFilePath_1() const { return ___isUnixFilePath_1; }
inline bool* get_address_of_isUnixFilePath_1() { return &___isUnixFilePath_1; }
inline void set_isUnixFilePath_1(bool value)
{
___isUnixFilePath_1 = value;
}
inline static int32_t get_offset_of_source_2() { return static_cast<int32_t>(offsetof(Uri_t100236324, ___source_2)); }
inline String_t* get_source_2() const { return ___source_2; }
inline String_t** get_address_of_source_2() { return &___source_2; }
inline void set_source_2(String_t* value)
{
___source_2 = value;
Il2CppCodeGenWriteBarrier((&___source_2), value);
}
inline static int32_t get_offset_of_scheme_3() { return static_cast<int32_t>(offsetof(Uri_t100236324, ___scheme_3)); }
inline String_t* get_scheme_3() const { return ___scheme_3; }
inline String_t** get_address_of_scheme_3() { return &___scheme_3; }
inline void set_scheme_3(String_t* value)
{
___scheme_3 = value;
Il2CppCodeGenWriteBarrier((&___scheme_3), value);
}
inline static int32_t get_offset_of_host_4() { return static_cast<int32_t>(offsetof(Uri_t100236324, ___host_4)); }
inline String_t* get_host_4() const { return ___host_4; }
inline String_t** get_address_of_host_4() { return &___host_4; }
inline void set_host_4(String_t* value)
{
___host_4 = value;
Il2CppCodeGenWriteBarrier((&___host_4), value);
}
inline static int32_t get_offset_of_port_5() { return static_cast<int32_t>(offsetof(Uri_t100236324, ___port_5)); }
inline int32_t get_port_5() const { return ___port_5; }
inline int32_t* get_address_of_port_5() { return &___port_5; }
inline void set_port_5(int32_t value)
{
___port_5 = value;
}
inline static int32_t get_offset_of_path_6() { return static_cast<int32_t>(offsetof(Uri_t100236324, ___path_6)); }
inline String_t* get_path_6() const { return ___path_6; }
inline String_t** get_address_of_path_6() { return &___path_6; }
inline void set_path_6(String_t* value)
{
___path_6 = value;
Il2CppCodeGenWriteBarrier((&___path_6), value);
}
inline static int32_t get_offset_of_query_7() { return static_cast<int32_t>(offsetof(Uri_t100236324, ___query_7)); }
inline String_t* get_query_7() const { return ___query_7; }
inline String_t** get_address_of_query_7() { return &___query_7; }
inline void set_query_7(String_t* value)
{
___query_7 = value;
Il2CppCodeGenWriteBarrier((&___query_7), value);
}
inline static int32_t get_offset_of_fragment_8() { return static_cast<int32_t>(offsetof(Uri_t100236324, ___fragment_8)); }
inline String_t* get_fragment_8() const { return ___fragment_8; }
inline String_t** get_address_of_fragment_8() { return &___fragment_8; }
inline void set_fragment_8(String_t* value)
{
___fragment_8 = value;
Il2CppCodeGenWriteBarrier((&___fragment_8), value);
}
inline static int32_t get_offset_of_userinfo_9() { return static_cast<int32_t>(offsetof(Uri_t100236324, ___userinfo_9)); }
inline String_t* get_userinfo_9() const { return ___userinfo_9; }
inline String_t** get_address_of_userinfo_9() { return &___userinfo_9; }
inline void set_userinfo_9(String_t* value)
{
___userinfo_9 = value;
Il2CppCodeGenWriteBarrier((&___userinfo_9), value);
}
inline static int32_t get_offset_of_isUnc_10() { return static_cast<int32_t>(offsetof(Uri_t100236324, ___isUnc_10)); }
inline bool get_isUnc_10() const { return ___isUnc_10; }
inline bool* get_address_of_isUnc_10() { return &___isUnc_10; }
inline void set_isUnc_10(bool value)
{
___isUnc_10 = value;
}
inline static int32_t get_offset_of_isOpaquePart_11() { return static_cast<int32_t>(offsetof(Uri_t100236324, ___isOpaquePart_11)); }
inline bool get_isOpaquePart_11() const { return ___isOpaquePart_11; }
inline bool* get_address_of_isOpaquePart_11() { return &___isOpaquePart_11; }
inline void set_isOpaquePart_11(bool value)
{
___isOpaquePart_11 = value;
}
inline static int32_t get_offset_of_isAbsoluteUri_12() { return static_cast<int32_t>(offsetof(Uri_t100236324, ___isAbsoluteUri_12)); }
inline bool get_isAbsoluteUri_12() const { return ___isAbsoluteUri_12; }
inline bool* get_address_of_isAbsoluteUri_12() { return &___isAbsoluteUri_12; }
inline void set_isAbsoluteUri_12(bool value)
{
___isAbsoluteUri_12 = value;
}
inline static int32_t get_offset_of_segments_13() { return static_cast<int32_t>(offsetof(Uri_t100236324, ___segments_13)); }
inline StringU5BU5D_t1281789340* get_segments_13() const { return ___segments_13; }
inline StringU5BU5D_t1281789340** get_address_of_segments_13() { return &___segments_13; }
inline void set_segments_13(StringU5BU5D_t1281789340* value)
{
___segments_13 = value;
Il2CppCodeGenWriteBarrier((&___segments_13), value);
}
inline static int32_t get_offset_of_userEscaped_14() { return static_cast<int32_t>(offsetof(Uri_t100236324, ___userEscaped_14)); }
inline bool get_userEscaped_14() const { return ___userEscaped_14; }
inline bool* get_address_of_userEscaped_14() { return &___userEscaped_14; }
inline void set_userEscaped_14(bool value)
{
___userEscaped_14 = value;
}
inline static int32_t get_offset_of_cachedAbsoluteUri_15() { return static_cast<int32_t>(offsetof(Uri_t100236324, ___cachedAbsoluteUri_15)); }
inline String_t* get_cachedAbsoluteUri_15() const { return ___cachedAbsoluteUri_15; }
inline String_t** get_address_of_cachedAbsoluteUri_15() { return &___cachedAbsoluteUri_15; }
inline void set_cachedAbsoluteUri_15(String_t* value)
{
___cachedAbsoluteUri_15 = value;
Il2CppCodeGenWriteBarrier((&___cachedAbsoluteUri_15), value);
}
inline static int32_t get_offset_of_cachedToString_16() { return static_cast<int32_t>(offsetof(Uri_t100236324, ___cachedToString_16)); }
inline String_t* get_cachedToString_16() const { return ___cachedToString_16; }
inline String_t** get_address_of_cachedToString_16() { return &___cachedToString_16; }
inline void set_cachedToString_16(String_t* value)
{
___cachedToString_16 = value;
Il2CppCodeGenWriteBarrier((&___cachedToString_16), value);
}
inline static int32_t get_offset_of_cachedLocalPath_17() { return static_cast<int32_t>(offsetof(Uri_t100236324, ___cachedLocalPath_17)); }
inline String_t* get_cachedLocalPath_17() const { return ___cachedLocalPath_17; }
inline String_t** get_address_of_cachedLocalPath_17() { return &___cachedLocalPath_17; }
inline void set_cachedLocalPath_17(String_t* value)
{
___cachedLocalPath_17 = value;
Il2CppCodeGenWriteBarrier((&___cachedLocalPath_17), value);
}
inline static int32_t get_offset_of_cachedHashCode_18() { return static_cast<int32_t>(offsetof(Uri_t100236324, ___cachedHashCode_18)); }
inline int32_t get_cachedHashCode_18() const { return ___cachedHashCode_18; }
inline int32_t* get_address_of_cachedHashCode_18() { return &___cachedHashCode_18; }
inline void set_cachedHashCode_18(int32_t value)
{
___cachedHashCode_18 = value;
}
inline static int32_t get_offset_of_parser_32() { return static_cast<int32_t>(offsetof(Uri_t100236324, ___parser_32)); }
inline UriParser_t3890150400 * get_parser_32() const { return ___parser_32; }
inline UriParser_t3890150400 ** get_address_of_parser_32() { return &___parser_32; }
inline void set_parser_32(UriParser_t3890150400 * value)
{
___parser_32 = value;
Il2CppCodeGenWriteBarrier((&___parser_32), value);
}
};
struct Uri_t100236324_StaticFields
{
public:
// System.String System.Uri::hexUpperChars
String_t* ___hexUpperChars_19;
// System.String System.Uri::SchemeDelimiter
String_t* ___SchemeDelimiter_20;
// System.String System.Uri::UriSchemeFile
String_t* ___UriSchemeFile_21;
// System.String System.Uri::UriSchemeFtp
String_t* ___UriSchemeFtp_22;
// System.String System.Uri::UriSchemeGopher
String_t* ___UriSchemeGopher_23;
// System.String System.Uri::UriSchemeHttp
String_t* ___UriSchemeHttp_24;
// System.String System.Uri::UriSchemeHttps
String_t* ___UriSchemeHttps_25;
// System.String System.Uri::UriSchemeMailto
String_t* ___UriSchemeMailto_26;
// System.String System.Uri::UriSchemeNews
String_t* ___UriSchemeNews_27;
// System.String System.Uri::UriSchemeNntp
String_t* ___UriSchemeNntp_28;
// System.String System.Uri::UriSchemeNetPipe
String_t* ___UriSchemeNetPipe_29;
// System.String System.Uri::UriSchemeNetTcp
String_t* ___UriSchemeNetTcp_30;
// System.Uri/UriScheme[] System.Uri::schemes
UriSchemeU5BU5D_t2082808316* ___schemes_31;
// System.Collections.Generic.Dictionary`2<System.String,System.Int32> System.Uri::<>f__switch$map12
Dictionary_2_t2736202052 * ___U3CU3Ef__switchU24map12_33;
// System.Collections.Generic.Dictionary`2<System.String,System.Int32> System.Uri::<>f__switch$map13
Dictionary_2_t2736202052 * ___U3CU3Ef__switchU24map13_34;
// System.Collections.Generic.Dictionary`2<System.String,System.Int32> System.Uri::<>f__switch$map14
Dictionary_2_t2736202052 * ___U3CU3Ef__switchU24map14_35;
// System.Collections.Generic.Dictionary`2<System.String,System.Int32> System.Uri::<>f__switch$map15
Dictionary_2_t2736202052 * ___U3CU3Ef__switchU24map15_36;
// System.Collections.Generic.Dictionary`2<System.String,System.Int32> System.Uri::<>f__switch$map16
Dictionary_2_t2736202052 * ___U3CU3Ef__switchU24map16_37;
public:
inline static int32_t get_offset_of_hexUpperChars_19() { return static_cast<int32_t>(offsetof(Uri_t100236324_StaticFields, ___hexUpperChars_19)); }
inline String_t* get_hexUpperChars_19() const { return ___hexUpperChars_19; }
inline String_t** get_address_of_hexUpperChars_19() { return &___hexUpperChars_19; }
inline void set_hexUpperChars_19(String_t* value)
{
___hexUpperChars_19 = value;
Il2CppCodeGenWriteBarrier((&___hexUpperChars_19), value);
}
inline static int32_t get_offset_of_SchemeDelimiter_20() { return static_cast<int32_t>(offsetof(Uri_t100236324_StaticFields, ___SchemeDelimiter_20)); }
inline String_t* get_SchemeDelimiter_20() const { return ___SchemeDelimiter_20; }
inline String_t** get_address_of_SchemeDelimiter_20() { return &___SchemeDelimiter_20; }
inline void set_SchemeDelimiter_20(String_t* value)
{
___SchemeDelimiter_20 = value;
Il2CppCodeGenWriteBarrier((&___SchemeDelimiter_20), value);
}
inline static int32_t get_offset_of_UriSchemeFile_21() { return static_cast<int32_t>(offsetof(Uri_t100236324_StaticFields, ___UriSchemeFile_21)); }
inline String_t* get_UriSchemeFile_21() const { return ___UriSchemeFile_21; }
inline String_t** get_address_of_UriSchemeFile_21() { return &___UriSchemeFile_21; }
inline void set_UriSchemeFile_21(String_t* value)
{
___UriSchemeFile_21 = value;
Il2CppCodeGenWriteBarrier((&___UriSchemeFile_21), value);
}
inline static int32_t get_offset_of_UriSchemeFtp_22() { return static_cast<int32_t>(offsetof(Uri_t100236324_StaticFields, ___UriSchemeFtp_22)); }
inline String_t* get_UriSchemeFtp_22() const { return ___UriSchemeFtp_22; }
inline String_t** get_address_of_UriSchemeFtp_22() { return &___UriSchemeFtp_22; }
inline void set_UriSchemeFtp_22(String_t* value)
{
___UriSchemeFtp_22 = value;
Il2CppCodeGenWriteBarrier((&___UriSchemeFtp_22), value);
}
inline static int32_t get_offset_of_UriSchemeGopher_23() { return static_cast<int32_t>(offsetof(Uri_t100236324_StaticFields, ___UriSchemeGopher_23)); }
inline String_t* get_UriSchemeGopher_23() const { return ___UriSchemeGopher_23; }
inline String_t** get_address_of_UriSchemeGopher_23() { return &___UriSchemeGopher_23; }
inline void set_UriSchemeGopher_23(String_t* value)
{
___UriSchemeGopher_23 = value;
Il2CppCodeGenWriteBarrier((&___UriSchemeGopher_23), value);
}
inline static int32_t get_offset_of_UriSchemeHttp_24() { return static_cast<int32_t>(offsetof(Uri_t100236324_StaticFields, ___UriSchemeHttp_24)); }
inline String_t* get_UriSchemeHttp_24() const { return ___UriSchemeHttp_24; }
inline String_t** get_address_of_UriSchemeHttp_24() { return &___UriSchemeHttp_24; }
inline void set_UriSchemeHttp_24(String_t* value)
{
___UriSchemeHttp_24 = value;
Il2CppCodeGenWriteBarrier((&___UriSchemeHttp_24), value);
}
inline static int32_t get_offset_of_UriSchemeHttps_25() { return static_cast<int32_t>(offsetof(Uri_t100236324_StaticFields, ___UriSchemeHttps_25)); }
inline String_t* get_UriSchemeHttps_25() const { return ___UriSchemeHttps_25; }
inline String_t** get_address_of_UriSchemeHttps_25() { return &___UriSchemeHttps_25; }
inline void set_UriSchemeHttps_25(String_t* value)
{
___UriSchemeHttps_25 = value;
Il2CppCodeGenWriteBarrier((&___UriSchemeHttps_25), value);
}
inline static int32_t get_offset_of_UriSchemeMailto_26() { return static_cast<int32_t>(offsetof(Uri_t100236324_StaticFields, ___UriSchemeMailto_26)); }
inline String_t* get_UriSchemeMailto_26() const { return ___UriSchemeMailto_26; }
inline String_t** get_address_of_UriSchemeMailto_26() { return &___UriSchemeMailto_26; }
inline void set_UriSchemeMailto_26(String_t* value)
{
___UriSchemeMailto_26 = value;
Il2CppCodeGenWriteBarrier((&___UriSchemeMailto_26), value);
}
inline static int32_t get_offset_of_UriSchemeNews_27() { return static_cast<int32_t>(offsetof(Uri_t100236324_StaticFields, ___UriSchemeNews_27)); }
inline String_t* get_UriSchemeNews_27() const { return ___UriSchemeNews_27; }
inline String_t** get_address_of_UriSchemeNews_27() { return &___UriSchemeNews_27; }
inline void set_UriSchemeNews_27(String_t* value)
{
___UriSchemeNews_27 = value;
Il2CppCodeGenWriteBarrier((&___UriSchemeNews_27), value);
}
inline static int32_t get_offset_of_UriSchemeNntp_28() { return static_cast<int32_t>(offsetof(Uri_t100236324_StaticFields, ___UriSchemeNntp_28)); }
inline String_t* get_UriSchemeNntp_28() const { return ___UriSchemeNntp_28; }
inline String_t** get_address_of_UriSchemeNntp_28() { return &___UriSchemeNntp_28; }
inline void set_UriSchemeNntp_28(String_t* value)
{
___UriSchemeNntp_28 = value;
Il2CppCodeGenWriteBarrier((&___UriSchemeNntp_28), value);
}
inline static int32_t get_offset_of_UriSchemeNetPipe_29() { return static_cast<int32_t>(offsetof(Uri_t100236324_StaticFields, ___UriSchemeNetPipe_29)); }
inline String_t* get_UriSchemeNetPipe_29() const { return ___UriSchemeNetPipe_29; }
inline String_t** get_address_of_UriSchemeNetPipe_29() { return &___UriSchemeNetPipe_29; }
inline void set_UriSchemeNetPipe_29(String_t* value)
{
___UriSchemeNetPipe_29 = value;
Il2CppCodeGenWriteBarrier((&___UriSchemeNetPipe_29), value);
}
inline static int32_t get_offset_of_UriSchemeNetTcp_30() { return static_cast<int32_t>(offsetof(Uri_t100236324_StaticFields, ___UriSchemeNetTcp_30)); }
inline String_t* get_UriSchemeNetTcp_30() const { return ___UriSchemeNetTcp_30; }
inline String_t** get_address_of_UriSchemeNetTcp_30() { return &___UriSchemeNetTcp_30; }
inline void set_UriSchemeNetTcp_30(String_t* value)
{
___UriSchemeNetTcp_30 = value;
Il2CppCodeGenWriteBarrier((&___UriSchemeNetTcp_30), value);
}
inline static int32_t get_offset_of_schemes_31() { return static_cast<int32_t>(offsetof(Uri_t100236324_StaticFields, ___schemes_31)); }
inline UriSchemeU5BU5D_t2082808316* get_schemes_31() const { return ___schemes_31; }
inline UriSchemeU5BU5D_t2082808316** get_address_of_schemes_31() { return &___schemes_31; }
inline void set_schemes_31(UriSchemeU5BU5D_t2082808316* value)
{
___schemes_31 = value;
Il2CppCodeGenWriteBarrier((&___schemes_31), value);
}
inline static int32_t get_offset_of_U3CU3Ef__switchU24map12_33() { return static_cast<int32_t>(offsetof(Uri_t100236324_StaticFields, ___U3CU3Ef__switchU24map12_33)); }
inline Dictionary_2_t2736202052 * get_U3CU3Ef__switchU24map12_33() const { return ___U3CU3Ef__switchU24map12_33; }
inline Dictionary_2_t2736202052 ** get_address_of_U3CU3Ef__switchU24map12_33() { return &___U3CU3Ef__switchU24map12_33; }
inline void set_U3CU3Ef__switchU24map12_33(Dictionary_2_t2736202052 * value)
{
___U3CU3Ef__switchU24map12_33 = value;
Il2CppCodeGenWriteBarrier((&___U3CU3Ef__switchU24map12_33), value);
}
inline static int32_t get_offset_of_U3CU3Ef__switchU24map13_34() { return static_cast<int32_t>(offsetof(Uri_t100236324_StaticFields, ___U3CU3Ef__switchU24map13_34)); }
inline Dictionary_2_t2736202052 * get_U3CU3Ef__switchU24map13_34() const { return ___U3CU3Ef__switchU24map13_34; }
inline Dictionary_2_t2736202052 ** get_address_of_U3CU3Ef__switchU24map13_34() { return &___U3CU3Ef__switchU24map13_34; }
inline void set_U3CU3Ef__switchU24map13_34(Dictionary_2_t2736202052 * value)
{
___U3CU3Ef__switchU24map13_34 = value;
Il2CppCodeGenWriteBarrier((&___U3CU3Ef__switchU24map13_34), value);
}
inline static int32_t get_offset_of_U3CU3Ef__switchU24map14_35() { return static_cast<int32_t>(offsetof(Uri_t100236324_StaticFields, ___U3CU3Ef__switchU24map14_35)); }
inline Dictionary_2_t2736202052 * get_U3CU3Ef__switchU24map14_35() const { return ___U3CU3Ef__switchU24map14_35; }
inline Dictionary_2_t2736202052 ** get_address_of_U3CU3Ef__switchU24map14_35() { return &___U3CU3Ef__switchU24map14_35; }
inline void set_U3CU3Ef__switchU24map14_35(Dictionary_2_t2736202052 * value)
{
___U3CU3Ef__switchU24map14_35 = value;
Il2CppCodeGenWriteBarrier((&___U3CU3Ef__switchU24map14_35), value);
}
inline static int32_t get_offset_of_U3CU3Ef__switchU24map15_36() { return static_cast<int32_t>(offsetof(Uri_t100236324_StaticFields, ___U3CU3Ef__switchU24map15_36)); }
inline Dictionary_2_t2736202052 * get_U3CU3Ef__switchU24map15_36() const { return ___U3CU3Ef__switchU24map15_36; }
inline Dictionary_2_t2736202052 ** get_address_of_U3CU3Ef__switchU24map15_36() { return &___U3CU3Ef__switchU24map15_36; }
inline void set_U3CU3Ef__switchU24map15_36(Dictionary_2_t2736202052 * value)
{
___U3CU3Ef__switchU24map15_36 = value;
Il2CppCodeGenWriteBarrier((&___U3CU3Ef__switchU24map15_36), value);
}
inline static int32_t get_offset_of_U3CU3Ef__switchU24map16_37() { return static_cast<int32_t>(offsetof(Uri_t100236324_StaticFields, ___U3CU3Ef__switchU24map16_37)); }
inline Dictionary_2_t2736202052 * get_U3CU3Ef__switchU24map16_37() const { return ___U3CU3Ef__switchU24map16_37; }
inline Dictionary_2_t2736202052 ** get_address_of_U3CU3Ef__switchU24map16_37() { return &___U3CU3Ef__switchU24map16_37; }
inline void set_U3CU3Ef__switchU24map16_37(Dictionary_2_t2736202052 * value)
{
___U3CU3Ef__switchU24map16_37 = value;
Il2CppCodeGenWriteBarrier((&___U3CU3Ef__switchU24map16_37), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // URI_T100236324_H
#ifndef URIPARSER_T3890150400_H
#define URIPARSER_T3890150400_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.UriParser
struct UriParser_t3890150400 : public RuntimeObject
{
public:
// System.String System.UriParser::scheme_name
String_t* ___scheme_name_2;
// System.Int32 System.UriParser::default_port
int32_t ___default_port_3;
public:
inline static int32_t get_offset_of_scheme_name_2() { return static_cast<int32_t>(offsetof(UriParser_t3890150400, ___scheme_name_2)); }
inline String_t* get_scheme_name_2() const { return ___scheme_name_2; }
inline String_t** get_address_of_scheme_name_2() { return &___scheme_name_2; }
inline void set_scheme_name_2(String_t* value)
{
___scheme_name_2 = value;
Il2CppCodeGenWriteBarrier((&___scheme_name_2), value);
}
inline static int32_t get_offset_of_default_port_3() { return static_cast<int32_t>(offsetof(UriParser_t3890150400, ___default_port_3)); }
inline int32_t get_default_port_3() const { return ___default_port_3; }
inline int32_t* get_address_of_default_port_3() { return &___default_port_3; }
inline void set_default_port_3(int32_t value)
{
___default_port_3 = value;
}
};
struct UriParser_t3890150400_StaticFields
{
public:
// System.Object System.UriParser::lock_object
RuntimeObject * ___lock_object_0;
// System.Collections.Hashtable System.UriParser::table
Hashtable_t1853889766 * ___table_1;
// System.Text.RegularExpressions.Regex System.UriParser::uri_regex
Regex_t3657309853 * ___uri_regex_4;
// System.Text.RegularExpressions.Regex System.UriParser::auth_regex
Regex_t3657309853 * ___auth_regex_5;
public:
inline static int32_t get_offset_of_lock_object_0() { return static_cast<int32_t>(offsetof(UriParser_t3890150400_StaticFields, ___lock_object_0)); }
inline RuntimeObject * get_lock_object_0() const { return ___lock_object_0; }
inline RuntimeObject ** get_address_of_lock_object_0() { return &___lock_object_0; }
inline void set_lock_object_0(RuntimeObject * value)
{
___lock_object_0 = value;
Il2CppCodeGenWriteBarrier((&___lock_object_0), value);
}
inline static int32_t get_offset_of_table_1() { return static_cast<int32_t>(offsetof(UriParser_t3890150400_StaticFields, ___table_1)); }
inline Hashtable_t1853889766 * get_table_1() const { return ___table_1; }
inline Hashtable_t1853889766 ** get_address_of_table_1() { return &___table_1; }
inline void set_table_1(Hashtable_t1853889766 * value)
{
___table_1 = value;
Il2CppCodeGenWriteBarrier((&___table_1), value);
}
inline static int32_t get_offset_of_uri_regex_4() { return static_cast<int32_t>(offsetof(UriParser_t3890150400_StaticFields, ___uri_regex_4)); }
inline Regex_t3657309853 * get_uri_regex_4() const { return ___uri_regex_4; }
inline Regex_t3657309853 ** get_address_of_uri_regex_4() { return &___uri_regex_4; }
inline void set_uri_regex_4(Regex_t3657309853 * value)
{
___uri_regex_4 = value;
Il2CppCodeGenWriteBarrier((&___uri_regex_4), value);
}
inline static int32_t get_offset_of_auth_regex_5() { return static_cast<int32_t>(offsetof(UriParser_t3890150400_StaticFields, ___auth_regex_5)); }
inline Regex_t3657309853 * get_auth_regex_5() const { return ___auth_regex_5; }
inline Regex_t3657309853 ** get_address_of_auth_regex_5() { return &___auth_regex_5; }
inline void set_auth_regex_5(Regex_t3657309853 * value)
{
___auth_regex_5 = value;
Il2CppCodeGenWriteBarrier((&___auth_regex_5), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // URIPARSER_T3890150400_H
#ifndef VALUETYPE_T3640485471_H
#define VALUETYPE_T3640485471_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.ValueType
struct ValueType_t3640485471 : public RuntimeObject
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// Native definition for P/Invoke marshalling of System.ValueType
struct ValueType_t3640485471_marshaled_pinvoke
{
};
// Native definition for COM marshalling of System.ValueType
struct ValueType_t3640485471_marshaled_com
{
};
#endif // VALUETYPE_T3640485471_H
#ifndef BOOLEAN_T97287965_H
#define BOOLEAN_T97287965_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Boolean
struct Boolean_t97287965
{
public:
// System.Boolean System.Boolean::m_value
bool ___m_value_2;
public:
inline static int32_t get_offset_of_m_value_2() { return static_cast<int32_t>(offsetof(Boolean_t97287965, ___m_value_2)); }
inline bool get_m_value_2() const { return ___m_value_2; }
inline bool* get_address_of_m_value_2() { return &___m_value_2; }
inline void set_m_value_2(bool value)
{
___m_value_2 = value;
}
};
struct Boolean_t97287965_StaticFields
{
public:
// System.String System.Boolean::FalseString
String_t* ___FalseString_0;
// System.String System.Boolean::TrueString
String_t* ___TrueString_1;
public:
inline static int32_t get_offset_of_FalseString_0() { return static_cast<int32_t>(offsetof(Boolean_t97287965_StaticFields, ___FalseString_0)); }
inline String_t* get_FalseString_0() const { return ___FalseString_0; }
inline String_t** get_address_of_FalseString_0() { return &___FalseString_0; }
inline void set_FalseString_0(String_t* value)
{
___FalseString_0 = value;
Il2CppCodeGenWriteBarrier((&___FalseString_0), value);
}
inline static int32_t get_offset_of_TrueString_1() { return static_cast<int32_t>(offsetof(Boolean_t97287965_StaticFields, ___TrueString_1)); }
inline String_t* get_TrueString_1() const { return ___TrueString_1; }
inline String_t** get_address_of_TrueString_1() { return &___TrueString_1; }
inline void set_TrueString_1(String_t* value)
{
___TrueString_1 = value;
Il2CppCodeGenWriteBarrier((&___TrueString_1), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // BOOLEAN_T97287965_H
#ifndef DEFAULTURIPARSER_T95882050_H
#define DEFAULTURIPARSER_T95882050_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.DefaultUriParser
struct DefaultUriParser_t95882050 : public UriParser_t3890150400
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // DEFAULTURIPARSER_T95882050_H
#ifndef ENUM_T4135868527_H
#define ENUM_T4135868527_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Enum
struct Enum_t4135868527 : public ValueType_t3640485471
{
public:
public:
};
struct Enum_t4135868527_StaticFields
{
public:
// System.Char[] System.Enum::split_char
CharU5BU5D_t3528271667* ___split_char_0;
public:
inline static int32_t get_offset_of_split_char_0() { return static_cast<int32_t>(offsetof(Enum_t4135868527_StaticFields, ___split_char_0)); }
inline CharU5BU5D_t3528271667* get_split_char_0() const { return ___split_char_0; }
inline CharU5BU5D_t3528271667** get_address_of_split_char_0() { return &___split_char_0; }
inline void set_split_char_0(CharU5BU5D_t3528271667* value)
{
___split_char_0 = value;
Il2CppCodeGenWriteBarrier((&___split_char_0), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// Native definition for P/Invoke marshalling of System.Enum
struct Enum_t4135868527_marshaled_pinvoke
{
};
// Native definition for COM marshalling of System.Enum
struct Enum_t4135868527_marshaled_com
{
};
#endif // ENUM_T4135868527_H
#ifndef GENERICURIPARSER_T1141496137_H
#define GENERICURIPARSER_T1141496137_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.GenericUriParser
struct GenericUriParser_t1141496137 : public UriParser_t3890150400
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // GENERICURIPARSER_T1141496137_H
#ifndef INT32_T2950945753_H
#define INT32_T2950945753_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Int32
struct Int32_t2950945753
{
public:
// System.Int32 System.Int32::m_value
int32_t ___m_value_2;
public:
inline static int32_t get_offset_of_m_value_2() { return static_cast<int32_t>(offsetof(Int32_t2950945753, ___m_value_2)); }
inline int32_t get_m_value_2() const { return ___m_value_2; }
inline int32_t* get_address_of_m_value_2() { return &___m_value_2; }
inline void set_m_value_2(int32_t value)
{
___m_value_2 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // INT32_T2950945753_H
#ifndef SYSTEMEXCEPTION_T176217640_H
#define SYSTEMEXCEPTION_T176217640_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.SystemException
struct SystemException_t176217640 : public Exception_t
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // SYSTEMEXCEPTION_T176217640_H
#ifndef URISCHEME_T722425697_H
#define URISCHEME_T722425697_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Uri/UriScheme
struct UriScheme_t722425697
{
public:
// System.String System.Uri/UriScheme::scheme
String_t* ___scheme_0;
// System.String System.Uri/UriScheme::delimiter
String_t* ___delimiter_1;
// System.Int32 System.Uri/UriScheme::defaultPort
int32_t ___defaultPort_2;
public:
inline static int32_t get_offset_of_scheme_0() { return static_cast<int32_t>(offsetof(UriScheme_t722425697, ___scheme_0)); }
inline String_t* get_scheme_0() const { return ___scheme_0; }
inline String_t** get_address_of_scheme_0() { return &___scheme_0; }
inline void set_scheme_0(String_t* value)
{
___scheme_0 = value;
Il2CppCodeGenWriteBarrier((&___scheme_0), value);
}
inline static int32_t get_offset_of_delimiter_1() { return static_cast<int32_t>(offsetof(UriScheme_t722425697, ___delimiter_1)); }
inline String_t* get_delimiter_1() const { return ___delimiter_1; }
inline String_t** get_address_of_delimiter_1() { return &___delimiter_1; }
inline void set_delimiter_1(String_t* value)
{
___delimiter_1 = value;
Il2CppCodeGenWriteBarrier((&___delimiter_1), value);
}
inline static int32_t get_offset_of_defaultPort_2() { return static_cast<int32_t>(offsetof(UriScheme_t722425697, ___defaultPort_2)); }
inline int32_t get_defaultPort_2() const { return ___defaultPort_2; }
inline int32_t* get_address_of_defaultPort_2() { return &___defaultPort_2; }
inline void set_defaultPort_2(int32_t value)
{
___defaultPort_2 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// Native definition for P/Invoke marshalling of System.Uri/UriScheme
struct UriScheme_t722425697_marshaled_pinvoke
{
char* ___scheme_0;
char* ___delimiter_1;
int32_t ___defaultPort_2;
};
// Native definition for COM marshalling of System.Uri/UriScheme
struct UriScheme_t722425697_marshaled_com
{
Il2CppChar* ___scheme_0;
Il2CppChar* ___delimiter_1;
int32_t ___defaultPort_2;
};
#endif // URISCHEME_T722425697_H
#ifndef URITYPECONVERTER_T3695916615_H
#define URITYPECONVERTER_T3695916615_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.UriTypeConverter
struct UriTypeConverter_t3695916615 : public TypeConverter_t2249118273
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // URITYPECONVERTER_T3695916615_H
#ifndef VOID_T1185182177_H
#define VOID_T1185182177_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Void
struct Void_t1185182177
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // VOID_T1185182177_H
#ifndef FORMATEXCEPTION_T154580423_H
#define FORMATEXCEPTION_T154580423_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.FormatException
struct FormatException_t154580423 : public SystemException_t176217640
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // FORMATEXCEPTION_T154580423_H
#ifndef STREAMINGCONTEXTSTATES_T3580100459_H
#define STREAMINGCONTEXTSTATES_T3580100459_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Runtime.Serialization.StreamingContextStates
struct StreamingContextStates_t3580100459
{
public:
// System.Int32 System.Runtime.Serialization.StreamingContextStates::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(StreamingContextStates_t3580100459, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // STREAMINGCONTEXTSTATES_T3580100459_H
#ifndef REGEXOPTIONS_T92845595_H
#define REGEXOPTIONS_T92845595_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Text.RegularExpressions.RegexOptions
struct RegexOptions_t92845595
{
public:
// System.Int32 System.Text.RegularExpressions.RegexOptions::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(RegexOptions_t92845595, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // REGEXOPTIONS_T92845595_H
#ifndef URIHOSTNAMETYPE_T881866241_H
#define URIHOSTNAMETYPE_T881866241_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.UriHostNameType
struct UriHostNameType_t881866241
{
public:
// System.Int32 System.UriHostNameType::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(UriHostNameType_t881866241, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // URIHOSTNAMETYPE_T881866241_H
#ifndef URIKIND_T3816567336_H
#define URIKIND_T3816567336_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.UriKind
struct UriKind_t3816567336
{
public:
// System.Int32 System.UriKind::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(UriKind_t3816567336, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // URIKIND_T3816567336_H
#ifndef URIPARTIAL_T1736313903_H
#define URIPARTIAL_T1736313903_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.UriPartial
struct UriPartial_t1736313903
{
public:
// System.Int32 System.UriPartial::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(UriPartial_t1736313903, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // URIPARTIAL_T1736313903_H
#ifndef STREAMINGCONTEXT_T3711869237_H
#define STREAMINGCONTEXT_T3711869237_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Runtime.Serialization.StreamingContext
struct StreamingContext_t3711869237
{
public:
// System.Runtime.Serialization.StreamingContextStates System.Runtime.Serialization.StreamingContext::state
int32_t ___state_0;
// System.Object System.Runtime.Serialization.StreamingContext::additional
RuntimeObject * ___additional_1;
public:
inline static int32_t get_offset_of_state_0() { return static_cast<int32_t>(offsetof(StreamingContext_t3711869237, ___state_0)); }
inline int32_t get_state_0() const { return ___state_0; }
inline int32_t* get_address_of_state_0() { return &___state_0; }
inline void set_state_0(int32_t value)
{
___state_0 = value;
}
inline static int32_t get_offset_of_additional_1() { return static_cast<int32_t>(offsetof(StreamingContext_t3711869237, ___additional_1)); }
inline RuntimeObject * get_additional_1() const { return ___additional_1; }
inline RuntimeObject ** get_address_of_additional_1() { return &___additional_1; }
inline void set_additional_1(RuntimeObject * value)
{
___additional_1 = value;
Il2CppCodeGenWriteBarrier((&___additional_1), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// Native definition for P/Invoke marshalling of System.Runtime.Serialization.StreamingContext
struct StreamingContext_t3711869237_marshaled_pinvoke
{
int32_t ___state_0;
Il2CppIUnknown* ___additional_1;
};
// Native definition for COM marshalling of System.Runtime.Serialization.StreamingContext
struct StreamingContext_t3711869237_marshaled_com
{
int32_t ___state_0;
Il2CppIUnknown* ___additional_1;
};
#endif // STREAMINGCONTEXT_T3711869237_H
#ifndef REGEX_T3657309853_H
#define REGEX_T3657309853_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Text.RegularExpressions.Regex
struct Regex_t3657309853 : public RuntimeObject
{
public:
// System.Text.RegularExpressions.IMachineFactory System.Text.RegularExpressions.Regex::machineFactory
RuntimeObject* ___machineFactory_1;
// System.Collections.IDictionary System.Text.RegularExpressions.Regex::mapping
RuntimeObject* ___mapping_2;
// System.Int32 System.Text.RegularExpressions.Regex::group_count
int32_t ___group_count_3;
// System.Int32 System.Text.RegularExpressions.Regex::gap
int32_t ___gap_4;
// System.Boolean System.Text.RegularExpressions.Regex::refsInitialized
bool ___refsInitialized_5;
// System.String[] System.Text.RegularExpressions.Regex::group_names
StringU5BU5D_t1281789340* ___group_names_6;
// System.Int32[] System.Text.RegularExpressions.Regex::group_numbers
Int32U5BU5D_t385246372* ___group_numbers_7;
// System.String System.Text.RegularExpressions.Regex::pattern
String_t* ___pattern_8;
// System.Text.RegularExpressions.RegexOptions System.Text.RegularExpressions.Regex::roptions
int32_t ___roptions_9;
// System.Collections.Generic.Dictionary`2<System.String,System.Int32> System.Text.RegularExpressions.Regex::capnames
Dictionary_2_t2736202052 * ___capnames_10;
// System.Collections.Generic.Dictionary`2<System.Int32,System.Int32> System.Text.RegularExpressions.Regex::caps
Dictionary_2_t1839659084 * ___caps_11;
// System.Int32 System.Text.RegularExpressions.Regex::capsize
int32_t ___capsize_12;
// System.String[] System.Text.RegularExpressions.Regex::capslist
StringU5BU5D_t1281789340* ___capslist_13;
public:
inline static int32_t get_offset_of_machineFactory_1() { return static_cast<int32_t>(offsetof(Regex_t3657309853, ___machineFactory_1)); }
inline RuntimeObject* get_machineFactory_1() const { return ___machineFactory_1; }
inline RuntimeObject** get_address_of_machineFactory_1() { return &___machineFactory_1; }
inline void set_machineFactory_1(RuntimeObject* value)
{
___machineFactory_1 = value;
Il2CppCodeGenWriteBarrier((&___machineFactory_1), value);
}
inline static int32_t get_offset_of_mapping_2() { return static_cast<int32_t>(offsetof(Regex_t3657309853, ___mapping_2)); }
inline RuntimeObject* get_mapping_2() const { return ___mapping_2; }
inline RuntimeObject** get_address_of_mapping_2() { return &___mapping_2; }
inline void set_mapping_2(RuntimeObject* value)
{
___mapping_2 = value;
Il2CppCodeGenWriteBarrier((&___mapping_2), value);
}
inline static int32_t get_offset_of_group_count_3() { return static_cast<int32_t>(offsetof(Regex_t3657309853, ___group_count_3)); }
inline int32_t get_group_count_3() const { return ___group_count_3; }
inline int32_t* get_address_of_group_count_3() { return &___group_count_3; }
inline void set_group_count_3(int32_t value)
{
___group_count_3 = value;
}
inline static int32_t get_offset_of_gap_4() { return static_cast<int32_t>(offsetof(Regex_t3657309853, ___gap_4)); }
inline int32_t get_gap_4() const { return ___gap_4; }
inline int32_t* get_address_of_gap_4() { return &___gap_4; }
inline void set_gap_4(int32_t value)
{
___gap_4 = value;
}
inline static int32_t get_offset_of_refsInitialized_5() { return static_cast<int32_t>(offsetof(Regex_t3657309853, ___refsInitialized_5)); }
inline bool get_refsInitialized_5() const { return ___refsInitialized_5; }
inline bool* get_address_of_refsInitialized_5() { return &___refsInitialized_5; }
inline void set_refsInitialized_5(bool value)
{
___refsInitialized_5 = value;
}
inline static int32_t get_offset_of_group_names_6() { return static_cast<int32_t>(offsetof(Regex_t3657309853, ___group_names_6)); }
inline StringU5BU5D_t1281789340* get_group_names_6() const { return ___group_names_6; }
inline StringU5BU5D_t1281789340** get_address_of_group_names_6() { return &___group_names_6; }
inline void set_group_names_6(StringU5BU5D_t1281789340* value)
{
___group_names_6 = value;
Il2CppCodeGenWriteBarrier((&___group_names_6), value);
}
inline static int32_t get_offset_of_group_numbers_7() { return static_cast<int32_t>(offsetof(Regex_t3657309853, ___group_numbers_7)); }
inline Int32U5BU5D_t385246372* get_group_numbers_7() const { return ___group_numbers_7; }
inline Int32U5BU5D_t385246372** get_address_of_group_numbers_7() { return &___group_numbers_7; }
inline void set_group_numbers_7(Int32U5BU5D_t385246372* value)
{
___group_numbers_7 = value;
Il2CppCodeGenWriteBarrier((&___group_numbers_7), value);
}
inline static int32_t get_offset_of_pattern_8() { return static_cast<int32_t>(offsetof(Regex_t3657309853, ___pattern_8)); }
inline String_t* get_pattern_8() const { return ___pattern_8; }
inline String_t** get_address_of_pattern_8() { return &___pattern_8; }
inline void set_pattern_8(String_t* value)
{
___pattern_8 = value;
Il2CppCodeGenWriteBarrier((&___pattern_8), value);
}
inline static int32_t get_offset_of_roptions_9() { return static_cast<int32_t>(offsetof(Regex_t3657309853, ___roptions_9)); }
inline int32_t get_roptions_9() const { return ___roptions_9; }
inline int32_t* get_address_of_roptions_9() { return &___roptions_9; }
inline void set_roptions_9(int32_t value)
{
___roptions_9 = value;
}
inline static int32_t get_offset_of_capnames_10() { return static_cast<int32_t>(offsetof(Regex_t3657309853, ___capnames_10)); }
inline Dictionary_2_t2736202052 * get_capnames_10() const { return ___capnames_10; }
inline Dictionary_2_t2736202052 ** get_address_of_capnames_10() { return &___capnames_10; }
inline void set_capnames_10(Dictionary_2_t2736202052 * value)
{
___capnames_10 = value;
Il2CppCodeGenWriteBarrier((&___capnames_10), value);
}
inline static int32_t get_offset_of_caps_11() { return static_cast<int32_t>(offsetof(Regex_t3657309853, ___caps_11)); }
inline Dictionary_2_t1839659084 * get_caps_11() const { return ___caps_11; }
inline Dictionary_2_t1839659084 ** get_address_of_caps_11() { return &___caps_11; }
inline void set_caps_11(Dictionary_2_t1839659084 * value)
{
___caps_11 = value;
Il2CppCodeGenWriteBarrier((&___caps_11), value);
}
inline static int32_t get_offset_of_capsize_12() { return static_cast<int32_t>(offsetof(Regex_t3657309853, ___capsize_12)); }
inline int32_t get_capsize_12() const { return ___capsize_12; }
inline int32_t* get_address_of_capsize_12() { return &___capsize_12; }
inline void set_capsize_12(int32_t value)
{
___capsize_12 = value;
}
inline static int32_t get_offset_of_capslist_13() { return static_cast<int32_t>(offsetof(Regex_t3657309853, ___capslist_13)); }
inline StringU5BU5D_t1281789340* get_capslist_13() const { return ___capslist_13; }
inline StringU5BU5D_t1281789340** get_address_of_capslist_13() { return &___capslist_13; }
inline void set_capslist_13(StringU5BU5D_t1281789340* value)
{
___capslist_13 = value;
Il2CppCodeGenWriteBarrier((&___capslist_13), value);
}
};
struct Regex_t3657309853_StaticFields
{
public:
// System.Text.RegularExpressions.FactoryCache System.Text.RegularExpressions.Regex::cache
FactoryCache_t2327118887 * ___cache_0;
public:
inline static int32_t get_offset_of_cache_0() { return static_cast<int32_t>(offsetof(Regex_t3657309853_StaticFields, ___cache_0)); }
inline FactoryCache_t2327118887 * get_cache_0() const { return ___cache_0; }
inline FactoryCache_t2327118887 ** get_address_of_cache_0() { return &___cache_0; }
inline void set_cache_0(FactoryCache_t2327118887 * value)
{
___cache_0 = value;
Il2CppCodeGenWriteBarrier((&___cache_0), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // REGEX_T3657309853_H
#ifndef URIFORMATEXCEPTION_T953270471_H
#define URIFORMATEXCEPTION_T953270471_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.UriFormatException
struct UriFormatException_t953270471 : public FormatException_t154580423
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // URIFORMATEXCEPTION_T953270471_H
// System.Void System.Uri/UriScheme::.ctor(System.String,System.String,System.Int32)
extern "C" IL2CPP_METHOD_ATTR void UriScheme__ctor_m1399779782 (UriScheme_t722425697 * __this, String_t* ___s0, String_t* ___d1, int32_t ___p2, const RuntimeMethod* method);
// System.String Locale::GetText(System.String)
extern "C" IL2CPP_METHOD_ATTR String_t* Locale_GetText_m3875126938 (RuntimeObject * __this /* static, unused */, String_t* ___msg0, const RuntimeMethod* method);
// System.Void System.FormatException::.ctor(System.String)
extern "C" IL2CPP_METHOD_ATTR void FormatException__ctor_m4049685996 (FormatException_t154580423 * __this, String_t* p0, const RuntimeMethod* method);
// System.Void System.FormatException::.ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)
extern "C" IL2CPP_METHOD_ATTR void FormatException__ctor_m3747066592 (FormatException_t154580423 * __this, SerializationInfo_t950877179 * p0, StreamingContext_t3711869237 p1, const RuntimeMethod* method);
// System.Void System.Exception::GetObjectData(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)
extern "C" IL2CPP_METHOD_ATTR void Exception_GetObjectData_m1103241326 (Exception_t * __this, SerializationInfo_t950877179 * p0, StreamingContext_t3711869237 p1, const RuntimeMethod* method);
// System.Void System.Object::.ctor()
extern "C" IL2CPP_METHOD_ATTR void Object__ctor_m297566312 (RuntimeObject * __this, const RuntimeMethod* method);
// System.Void System.Text.RegularExpressions.Regex::.ctor(System.String)
extern "C" IL2CPP_METHOD_ATTR void Regex__ctor_m897876424 (Regex_t3657309853 * __this, String_t* ___pattern0, const RuntimeMethod* method);
// System.String System.Uri::get_Scheme()
extern "C" IL2CPP_METHOD_ATTR String_t* Uri_get_Scheme_m2109479391 (Uri_t100236324 * __this, const RuntimeMethod* method);
// System.Boolean System.String::op_Inequality(System.String,System.String)
extern "C" IL2CPP_METHOD_ATTR bool String_op_Inequality_m215368492 (RuntimeObject * __this /* static, unused */, String_t* p0, String_t* p1, const RuntimeMethod* method);
// System.Void System.UriFormatException::.ctor(System.String)
extern "C" IL2CPP_METHOD_ATTR void UriFormatException__ctor_m3083316541 (UriFormatException_t953270471 * __this, String_t* ___message0, const RuntimeMethod* method);
// System.Void System.Collections.Hashtable::.ctor()
extern "C" IL2CPP_METHOD_ATTR void Hashtable__ctor_m1815022027 (Hashtable_t1853889766 * __this, const RuntimeMethod* method);
// System.Void System.DefaultUriParser::.ctor()
extern "C" IL2CPP_METHOD_ATTR void DefaultUriParser__ctor_m2377995797 (DefaultUriParser_t95882050 * __this, const RuntimeMethod* method);
// System.Void System.UriParser::InternalRegister(System.Collections.Hashtable,System.UriParser,System.String,System.Int32)
extern "C" IL2CPP_METHOD_ATTR void UriParser_InternalRegister_m3643767086 (RuntimeObject * __this /* static, unused */, Hashtable_t1853889766 * ___table0, UriParser_t3890150400 * ___uriParser1, String_t* ___schemeName2, int32_t ___defaultPort3, const RuntimeMethod* method);
// System.Void System.Threading.Monitor::Enter(System.Object)
extern "C" IL2CPP_METHOD_ATTR void Monitor_Enter_m2249409497 (RuntimeObject * __this /* static, unused */, RuntimeObject * p0, const RuntimeMethod* method);
// System.Void System.Threading.Monitor::Exit(System.Object)
extern "C" IL2CPP_METHOD_ATTR void Monitor_Exit_m3585316909 (RuntimeObject * __this /* static, unused */, RuntimeObject * p0, const RuntimeMethod* method);
// System.Void System.UriParser::set_SchemeName(System.String)
extern "C" IL2CPP_METHOD_ATTR void UriParser_set_SchemeName_m266448765 (UriParser_t3890150400 * __this, String_t* ___value0, const RuntimeMethod* method);
// System.Void System.UriParser::set_DefaultPort(System.Int32)
extern "C" IL2CPP_METHOD_ATTR void UriParser_set_DefaultPort_m4007715058 (UriParser_t3890150400 * __this, int32_t ___value0, const RuntimeMethod* method);
// System.Void System.UriParser::CreateDefaults()
extern "C" IL2CPP_METHOD_ATTR void UriParser_CreateDefaults_m404296154 (RuntimeObject * __this /* static, unused */, const RuntimeMethod* method);
// System.Globalization.CultureInfo System.Globalization.CultureInfo::get_InvariantCulture()
extern "C" IL2CPP_METHOD_ATTR CultureInfo_t4157843068 * CultureInfo_get_InvariantCulture_m3532445182 (RuntimeObject * __this /* static, unused */, const RuntimeMethod* method);
// System.String System.String::ToLower(System.Globalization.CultureInfo)
extern "C" IL2CPP_METHOD_ATTR String_t* String_ToLower_m3490221821 (String_t* __this, CultureInfo_t4157843068 * p0, const RuntimeMethod* method);
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// Conversion methods for marshalling of: System.Uri/UriScheme
extern "C" void UriScheme_t722425697_marshal_pinvoke(const UriScheme_t722425697& unmarshaled, UriScheme_t722425697_marshaled_pinvoke& marshaled)
{
marshaled.___scheme_0 = il2cpp_codegen_marshal_string(unmarshaled.get_scheme_0());
marshaled.___delimiter_1 = il2cpp_codegen_marshal_string(unmarshaled.get_delimiter_1());
marshaled.___defaultPort_2 = unmarshaled.get_defaultPort_2();
}
extern "C" void UriScheme_t722425697_marshal_pinvoke_back(const UriScheme_t722425697_marshaled_pinvoke& marshaled, UriScheme_t722425697& unmarshaled)
{
unmarshaled.set_scheme_0(il2cpp_codegen_marshal_string_result(marshaled.___scheme_0));
unmarshaled.set_delimiter_1(il2cpp_codegen_marshal_string_result(marshaled.___delimiter_1));
int32_t unmarshaled_defaultPort_temp_2 = 0;
unmarshaled_defaultPort_temp_2 = marshaled.___defaultPort_2;
unmarshaled.set_defaultPort_2(unmarshaled_defaultPort_temp_2);
}
// Conversion method for clean up from marshalling of: System.Uri/UriScheme
extern "C" void UriScheme_t722425697_marshal_pinvoke_cleanup(UriScheme_t722425697_marshaled_pinvoke& marshaled)
{
il2cpp_codegen_marshal_free(marshaled.___scheme_0);
marshaled.___scheme_0 = NULL;
il2cpp_codegen_marshal_free(marshaled.___delimiter_1);
marshaled.___delimiter_1 = NULL;
}
// Conversion methods for marshalling of: System.Uri/UriScheme
extern "C" void UriScheme_t722425697_marshal_com(const UriScheme_t722425697& unmarshaled, UriScheme_t722425697_marshaled_com& marshaled)
{
marshaled.___scheme_0 = il2cpp_codegen_marshal_bstring(unmarshaled.get_scheme_0());
marshaled.___delimiter_1 = il2cpp_codegen_marshal_bstring(unmarshaled.get_delimiter_1());
marshaled.___defaultPort_2 = unmarshaled.get_defaultPort_2();
}
extern "C" void UriScheme_t722425697_marshal_com_back(const UriScheme_t722425697_marshaled_com& marshaled, UriScheme_t722425697& unmarshaled)
{
unmarshaled.set_scheme_0(il2cpp_codegen_marshal_bstring_result(marshaled.___scheme_0));
unmarshaled.set_delimiter_1(il2cpp_codegen_marshal_bstring_result(marshaled.___delimiter_1));
int32_t unmarshaled_defaultPort_temp_2 = 0;
unmarshaled_defaultPort_temp_2 = marshaled.___defaultPort_2;
unmarshaled.set_defaultPort_2(unmarshaled_defaultPort_temp_2);
}
// Conversion method for clean up from marshalling of: System.Uri/UriScheme
extern "C" void UriScheme_t722425697_marshal_com_cleanup(UriScheme_t722425697_marshaled_com& marshaled)
{
il2cpp_codegen_marshal_free_bstring(marshaled.___scheme_0);
marshaled.___scheme_0 = NULL;
il2cpp_codegen_marshal_free_bstring(marshaled.___delimiter_1);
marshaled.___delimiter_1 = NULL;
}
// System.Void System.Uri/UriScheme::.ctor(System.String,System.String,System.Int32)
extern "C" IL2CPP_METHOD_ATTR void UriScheme__ctor_m1399779782 (UriScheme_t722425697 * __this, String_t* ___s0, String_t* ___d1, int32_t ___p2, const RuntimeMethod* method)
{
{
String_t* L_0 = ___s0;
__this->set_scheme_0(L_0);
String_t* L_1 = ___d1;
__this->set_delimiter_1(L_1);
int32_t L_2 = ___p2;
__this->set_defaultPort_2(L_2);
return;
}
}
extern "C" void UriScheme__ctor_m1399779782_AdjustorThunk (RuntimeObject * __this, String_t* ___s0, String_t* ___d1, int32_t ___p2, const RuntimeMethod* method)
{
UriScheme_t722425697 * _thisAdjusted = reinterpret_cast<UriScheme_t722425697 *>(__this + 1);
UriScheme__ctor_m1399779782(_thisAdjusted, ___s0, ___d1, ___p2, method);
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Void System.UriFormatException::.ctor()
extern "C" IL2CPP_METHOD_ATTR void UriFormatException__ctor_m1115096473 (UriFormatException_t953270471 * __this, const RuntimeMethod* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (UriFormatException__ctor_m1115096473_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
String_t* L_0 = Locale_GetText_m3875126938(NULL /*static, unused*/, _stringLiteral2864059369, /*hidden argument*/NULL);
FormatException__ctor_m4049685996(__this, L_0, /*hidden argument*/NULL);
return;
}
}
// System.Void System.UriFormatException::.ctor(System.String)
extern "C" IL2CPP_METHOD_ATTR void UriFormatException__ctor_m3083316541 (UriFormatException_t953270471 * __this, String_t* ___message0, const RuntimeMethod* method)
{
{
String_t* L_0 = ___message0;
FormatException__ctor_m4049685996(__this, L_0, /*hidden argument*/NULL);
return;
}
}
// System.Void System.UriFormatException::.ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)
extern "C" IL2CPP_METHOD_ATTR void UriFormatException__ctor_m3466512970 (UriFormatException_t953270471 * __this, SerializationInfo_t950877179 * ___info0, StreamingContext_t3711869237 ___context1, const RuntimeMethod* method)
{
{
SerializationInfo_t950877179 * L_0 = ___info0;
StreamingContext_t3711869237 L_1 = ___context1;
FormatException__ctor_m3747066592(__this, L_0, L_1, /*hidden argument*/NULL);
return;
}
}
// System.Void System.UriFormatException::System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)
extern "C" IL2CPP_METHOD_ATTR void UriFormatException_System_Runtime_Serialization_ISerializable_GetObjectData_m3030326401 (UriFormatException_t953270471 * __this, SerializationInfo_t950877179 * ___info0, StreamingContext_t3711869237 ___context1, const RuntimeMethod* method)
{
{
SerializationInfo_t950877179 * L_0 = ___info0;
StreamingContext_t3711869237 L_1 = ___context1;
Exception_GetObjectData_m1103241326(__this, L_0, L_1, /*hidden argument*/NULL);
return;
}
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Void System.UriParser::.ctor()
extern "C" IL2CPP_METHOD_ATTR void UriParser__ctor_m2454688443 (UriParser_t3890150400 * __this, const RuntimeMethod* method)
{
{
Object__ctor_m297566312(__this, /*hidden argument*/NULL);
return;
}
}
// System.Void System.UriParser::.cctor()
extern "C" IL2CPP_METHOD_ATTR void UriParser__cctor_m3655686731 (RuntimeObject * __this /* static, unused */, const RuntimeMethod* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (UriParser__cctor_m3655686731_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
RuntimeObject * L_0 = (RuntimeObject *)il2cpp_codegen_object_new(RuntimeObject_il2cpp_TypeInfo_var);
Object__ctor_m297566312(L_0, /*hidden argument*/NULL);
((UriParser_t3890150400_StaticFields*)il2cpp_codegen_static_fields_for(UriParser_t3890150400_il2cpp_TypeInfo_var))->set_lock_object_0(L_0);
Regex_t3657309853 * L_1 = (Regex_t3657309853 *)il2cpp_codegen_object_new(Regex_t3657309853_il2cpp_TypeInfo_var);
Regex__ctor_m897876424(L_1, _stringLiteral528199797, /*hidden argument*/NULL);
((UriParser_t3890150400_StaticFields*)il2cpp_codegen_static_fields_for(UriParser_t3890150400_il2cpp_TypeInfo_var))->set_uri_regex_4(L_1);
Regex_t3657309853 * L_2 = (Regex_t3657309853 *)il2cpp_codegen_object_new(Regex_t3657309853_il2cpp_TypeInfo_var);
Regex__ctor_m897876424(L_2, _stringLiteral3698381084, /*hidden argument*/NULL);
((UriParser_t3890150400_StaticFields*)il2cpp_codegen_static_fields_for(UriParser_t3890150400_il2cpp_TypeInfo_var))->set_auth_regex_5(L_2);
return;
}
}
// System.Void System.UriParser::InitializeAndValidate(System.Uri,System.UriFormatException&)
extern "C" IL2CPP_METHOD_ATTR void UriParser_InitializeAndValidate_m2008117311 (UriParser_t3890150400 * __this, Uri_t100236324 * ___uri0, UriFormatException_t953270471 ** ___parsingError1, const RuntimeMethod* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (UriParser_InitializeAndValidate_m2008117311_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
{
Uri_t100236324 * L_0 = ___uri0;
NullCheck(L_0);
String_t* L_1 = Uri_get_Scheme_m2109479391(L_0, /*hidden argument*/NULL);
String_t* L_2 = __this->get_scheme_name_2();
IL2CPP_RUNTIME_CLASS_INIT(String_t_il2cpp_TypeInfo_var);
bool L_3 = String_op_Inequality_m215368492(NULL /*static, unused*/, L_1, L_2, /*hidden argument*/NULL);
if (!L_3)
{
goto IL_003c;
}
}
{
String_t* L_4 = __this->get_scheme_name_2();
IL2CPP_RUNTIME_CLASS_INIT(String_t_il2cpp_TypeInfo_var);
bool L_5 = String_op_Inequality_m215368492(NULL /*static, unused*/, L_4, _stringLiteral3452614534, /*hidden argument*/NULL);
if (!L_5)
{
goto IL_003c;
}
}
{
UriFormatException_t953270471 ** L_6 = ___parsingError1;
UriFormatException_t953270471 * L_7 = (UriFormatException_t953270471 *)il2cpp_codegen_object_new(UriFormatException_t953270471_il2cpp_TypeInfo_var);
UriFormatException__ctor_m3083316541(L_7, _stringLiteral2140524769, /*hidden argument*/NULL);
*((RuntimeObject **)(L_6)) = (RuntimeObject *)L_7;
Il2CppCodeGenWriteBarrier((RuntimeObject **)(L_6), (RuntimeObject *)L_7);
goto IL_003f;
}
IL_003c:
{
UriFormatException_t953270471 ** L_8 = ___parsingError1;
*((RuntimeObject **)(L_8)) = (RuntimeObject *)NULL;
Il2CppCodeGenWriteBarrier((RuntimeObject **)(L_8), (RuntimeObject *)NULL);
}
IL_003f:
{
return;
}
}
// System.Void System.UriParser::OnRegister(System.String,System.Int32)
extern "C" IL2CPP_METHOD_ATTR void UriParser_OnRegister_m3283921560 (UriParser_t3890150400 * __this, String_t* ___schemeName0, int32_t ___defaultPort1, const RuntimeMethod* method)
{
{
return;
}
}
// System.Void System.UriParser::set_SchemeName(System.String)
extern "C" IL2CPP_METHOD_ATTR void UriParser_set_SchemeName_m266448765 (UriParser_t3890150400 * __this, String_t* ___value0, const RuntimeMethod* method)
{
{
String_t* L_0 = ___value0;
__this->set_scheme_name_2(L_0);
return;
}
}
// System.Int32 System.UriParser::get_DefaultPort()
extern "C" IL2CPP_METHOD_ATTR int32_t UriParser_get_DefaultPort_m2544851211 (UriParser_t3890150400 * __this, const RuntimeMethod* method)
{
{
int32_t L_0 = __this->get_default_port_3();
return L_0;
}
}
// System.Void System.UriParser::set_DefaultPort(System.Int32)
extern "C" IL2CPP_METHOD_ATTR void UriParser_set_DefaultPort_m4007715058 (UriParser_t3890150400 * __this, int32_t ___value0, const RuntimeMethod* method)
{
{
int32_t L_0 = ___value0;
__this->set_default_port_3(L_0);
return;
}
}
// System.Void System.UriParser::CreateDefaults()
extern "C" IL2CPP_METHOD_ATTR void UriParser_CreateDefaults_m404296154 (RuntimeObject * __this /* static, unused */, const RuntimeMethod* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (UriParser_CreateDefaults_m404296154_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
Hashtable_t1853889766 * V_0 = NULL;
RuntimeObject * V_1 = NULL;
Exception_t * __last_unhandled_exception = 0;
NO_UNUSED_WARNING (__last_unhandled_exception);
Exception_t * __exception_local = 0;
NO_UNUSED_WARNING (__exception_local);
int32_t __leave_target = -1;
NO_UNUSED_WARNING (__leave_target);
{
IL2CPP_RUNTIME_CLASS_INIT(UriParser_t3890150400_il2cpp_TypeInfo_var);
Hashtable_t1853889766 * L_0 = ((UriParser_t3890150400_StaticFields*)il2cpp_codegen_static_fields_for(UriParser_t3890150400_il2cpp_TypeInfo_var))->get_table_1();
if (!L_0)
{
goto IL_000b;
}
}
{
return;
}
IL_000b:
{
Hashtable_t1853889766 * L_1 = (Hashtable_t1853889766 *)il2cpp_codegen_object_new(Hashtable_t1853889766_il2cpp_TypeInfo_var);
Hashtable__ctor_m1815022027(L_1, /*hidden argument*/NULL);
V_0 = L_1;
Hashtable_t1853889766 * L_2 = V_0;
DefaultUriParser_t95882050 * L_3 = (DefaultUriParser_t95882050 *)il2cpp_codegen_object_new(DefaultUriParser_t95882050_il2cpp_TypeInfo_var);
DefaultUriParser__ctor_m2377995797(L_3, /*hidden argument*/NULL);
IL2CPP_RUNTIME_CLASS_INIT(Uri_t100236324_il2cpp_TypeInfo_var);
String_t* L_4 = ((Uri_t100236324_StaticFields*)il2cpp_codegen_static_fields_for(Uri_t100236324_il2cpp_TypeInfo_var))->get_UriSchemeFile_21();
IL2CPP_RUNTIME_CLASS_INIT(UriParser_t3890150400_il2cpp_TypeInfo_var);
UriParser_InternalRegister_m3643767086(NULL /*static, unused*/, L_2, L_3, L_4, (-1), /*hidden argument*/NULL);
Hashtable_t1853889766 * L_5 = V_0;
DefaultUriParser_t95882050 * L_6 = (DefaultUriParser_t95882050 *)il2cpp_codegen_object_new(DefaultUriParser_t95882050_il2cpp_TypeInfo_var);
DefaultUriParser__ctor_m2377995797(L_6, /*hidden argument*/NULL);
String_t* L_7 = ((Uri_t100236324_StaticFields*)il2cpp_codegen_static_fields_for(Uri_t100236324_il2cpp_TypeInfo_var))->get_UriSchemeFtp_22();
UriParser_InternalRegister_m3643767086(NULL /*static, unused*/, L_5, L_6, L_7, ((int32_t)21), /*hidden argument*/NULL);
Hashtable_t1853889766 * L_8 = V_0;
DefaultUriParser_t95882050 * L_9 = (DefaultUriParser_t95882050 *)il2cpp_codegen_object_new(DefaultUriParser_t95882050_il2cpp_TypeInfo_var);
DefaultUriParser__ctor_m2377995797(L_9, /*hidden argument*/NULL);
String_t* L_10 = ((Uri_t100236324_StaticFields*)il2cpp_codegen_static_fields_for(Uri_t100236324_il2cpp_TypeInfo_var))->get_UriSchemeGopher_23();
UriParser_InternalRegister_m3643767086(NULL /*static, unused*/, L_8, L_9, L_10, ((int32_t)70), /*hidden argument*/NULL);
Hashtable_t1853889766 * L_11 = V_0;
DefaultUriParser_t95882050 * L_12 = (DefaultUriParser_t95882050 *)il2cpp_codegen_object_new(DefaultUriParser_t95882050_il2cpp_TypeInfo_var);
DefaultUriParser__ctor_m2377995797(L_12, /*hidden argument*/NULL);
String_t* L_13 = ((Uri_t100236324_StaticFields*)il2cpp_codegen_static_fields_for(Uri_t100236324_il2cpp_TypeInfo_var))->get_UriSchemeHttp_24();
UriParser_InternalRegister_m3643767086(NULL /*static, unused*/, L_11, L_12, L_13, ((int32_t)80), /*hidden argument*/NULL);
Hashtable_t1853889766 * L_14 = V_0;
DefaultUriParser_t95882050 * L_15 = (DefaultUriParser_t95882050 *)il2cpp_codegen_object_new(DefaultUriParser_t95882050_il2cpp_TypeInfo_var);
DefaultUriParser__ctor_m2377995797(L_15, /*hidden argument*/NULL);
String_t* L_16 = ((Uri_t100236324_StaticFields*)il2cpp_codegen_static_fields_for(Uri_t100236324_il2cpp_TypeInfo_var))->get_UriSchemeHttps_25();
UriParser_InternalRegister_m3643767086(NULL /*static, unused*/, L_14, L_15, L_16, ((int32_t)443), /*hidden argument*/NULL);
Hashtable_t1853889766 * L_17 = V_0;
DefaultUriParser_t95882050 * L_18 = (DefaultUriParser_t95882050 *)il2cpp_codegen_object_new(DefaultUriParser_t95882050_il2cpp_TypeInfo_var);
DefaultUriParser__ctor_m2377995797(L_18, /*hidden argument*/NULL);
String_t* L_19 = ((Uri_t100236324_StaticFields*)il2cpp_codegen_static_fields_for(Uri_t100236324_il2cpp_TypeInfo_var))->get_UriSchemeMailto_26();
UriParser_InternalRegister_m3643767086(NULL /*static, unused*/, L_17, L_18, L_19, ((int32_t)25), /*hidden argument*/NULL);
Hashtable_t1853889766 * L_20 = V_0;
DefaultUriParser_t95882050 * L_21 = (DefaultUriParser_t95882050 *)il2cpp_codegen_object_new(DefaultUriParser_t95882050_il2cpp_TypeInfo_var);
DefaultUriParser__ctor_m2377995797(L_21, /*hidden argument*/NULL);
String_t* L_22 = ((Uri_t100236324_StaticFields*)il2cpp_codegen_static_fields_for(Uri_t100236324_il2cpp_TypeInfo_var))->get_UriSchemeNetPipe_29();
UriParser_InternalRegister_m3643767086(NULL /*static, unused*/, L_20, L_21, L_22, (-1), /*hidden argument*/NULL);
Hashtable_t1853889766 * L_23 = V_0;
DefaultUriParser_t95882050 * L_24 = (DefaultUriParser_t95882050 *)il2cpp_codegen_object_new(DefaultUriParser_t95882050_il2cpp_TypeInfo_var);
DefaultUriParser__ctor_m2377995797(L_24, /*hidden argument*/NULL);
String_t* L_25 = ((Uri_t100236324_StaticFields*)il2cpp_codegen_static_fields_for(Uri_t100236324_il2cpp_TypeInfo_var))->get_UriSchemeNetTcp_30();
UriParser_InternalRegister_m3643767086(NULL /*static, unused*/, L_23, L_24, L_25, (-1), /*hidden argument*/NULL);
Hashtable_t1853889766 * L_26 = V_0;
DefaultUriParser_t95882050 * L_27 = (DefaultUriParser_t95882050 *)il2cpp_codegen_object_new(DefaultUriParser_t95882050_il2cpp_TypeInfo_var);
DefaultUriParser__ctor_m2377995797(L_27, /*hidden argument*/NULL);
String_t* L_28 = ((Uri_t100236324_StaticFields*)il2cpp_codegen_static_fields_for(Uri_t100236324_il2cpp_TypeInfo_var))->get_UriSchemeNews_27();
UriParser_InternalRegister_m3643767086(NULL /*static, unused*/, L_26, L_27, L_28, ((int32_t)119), /*hidden argument*/NULL);
Hashtable_t1853889766 * L_29 = V_0;
DefaultUriParser_t95882050 * L_30 = (DefaultUriParser_t95882050 *)il2cpp_codegen_object_new(DefaultUriParser_t95882050_il2cpp_TypeInfo_var);
DefaultUriParser__ctor_m2377995797(L_30, /*hidden argument*/NULL);
String_t* L_31 = ((Uri_t100236324_StaticFields*)il2cpp_codegen_static_fields_for(Uri_t100236324_il2cpp_TypeInfo_var))->get_UriSchemeNntp_28();
UriParser_InternalRegister_m3643767086(NULL /*static, unused*/, L_29, L_30, L_31, ((int32_t)119), /*hidden argument*/NULL);
Hashtable_t1853889766 * L_32 = V_0;
DefaultUriParser_t95882050 * L_33 = (DefaultUriParser_t95882050 *)il2cpp_codegen_object_new(DefaultUriParser_t95882050_il2cpp_TypeInfo_var);
DefaultUriParser__ctor_m2377995797(L_33, /*hidden argument*/NULL);
UriParser_InternalRegister_m3643767086(NULL /*static, unused*/, L_32, L_33, _stringLiteral4255182569, ((int32_t)389), /*hidden argument*/NULL);
RuntimeObject * L_34 = ((UriParser_t3890150400_StaticFields*)il2cpp_codegen_static_fields_for(UriParser_t3890150400_il2cpp_TypeInfo_var))->get_lock_object_0();
V_1 = L_34;
RuntimeObject * L_35 = V_1;
Monitor_Enter_m2249409497(NULL /*static, unused*/, L_35, /*hidden argument*/NULL);
}
IL_00e6:
try
{ // begin try (depth: 1)
{
IL2CPP_RUNTIME_CLASS_INIT(UriParser_t3890150400_il2cpp_TypeInfo_var);
Hashtable_t1853889766 * L_36 = ((UriParser_t3890150400_StaticFields*)il2cpp_codegen_static_fields_for(UriParser_t3890150400_il2cpp_TypeInfo_var))->get_table_1();
if (L_36)
{
goto IL_00fb;
}
}
IL_00f0:
{
Hashtable_t1853889766 * L_37 = V_0;
IL2CPP_RUNTIME_CLASS_INIT(UriParser_t3890150400_il2cpp_TypeInfo_var);
((UriParser_t3890150400_StaticFields*)il2cpp_codegen_static_fields_for(UriParser_t3890150400_il2cpp_TypeInfo_var))->set_table_1(L_37);
goto IL_00fd;
}
IL_00fb:
{
V_0 = (Hashtable_t1853889766 *)NULL;
}
IL_00fd:
{
IL2CPP_LEAVE(0x109, FINALLY_0102);
}
} // end try (depth: 1)
catch(Il2CppExceptionWrapper& e)
{
__last_unhandled_exception = (Exception_t *)e.ex;
goto FINALLY_0102;
}
FINALLY_0102:
{ // begin finally (depth: 1)
RuntimeObject * L_38 = V_1;
Monitor_Exit_m3585316909(NULL /*static, unused*/, L_38, /*hidden argument*/NULL);
IL2CPP_END_FINALLY(258)
} // end finally (depth: 1)
IL2CPP_CLEANUP(258)
{
IL2CPP_JUMP_TBL(0x109, IL_0109)
IL2CPP_RETHROW_IF_UNHANDLED(Exception_t *)
}
IL_0109:
{
return;
}
}
// System.Void System.UriParser::InternalRegister(System.Collections.Hashtable,System.UriParser,System.String,System.Int32)
extern "C" IL2CPP_METHOD_ATTR void UriParser_InternalRegister_m3643767086 (RuntimeObject * __this /* static, unused */, Hashtable_t1853889766 * ___table0, UriParser_t3890150400 * ___uriParser1, String_t* ___schemeName2, int32_t ___defaultPort3, const RuntimeMethod* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (UriParser_InternalRegister_m3643767086_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
DefaultUriParser_t95882050 * V_0 = NULL;
{
UriParser_t3890150400 * L_0 = ___uriParser1;
String_t* L_1 = ___schemeName2;
NullCheck(L_0);
UriParser_set_SchemeName_m266448765(L_0, L_1, /*hidden argument*/NULL);
UriParser_t3890150400 * L_2 = ___uriParser1;
int32_t L_3 = ___defaultPort3;
NullCheck(L_2);
UriParser_set_DefaultPort_m4007715058(L_2, L_3, /*hidden argument*/NULL);
UriParser_t3890150400 * L_4 = ___uriParser1;
if (!((GenericUriParser_t1141496137 *)IsInstClass((RuntimeObject*)L_4, GenericUriParser_t1141496137_il2cpp_TypeInfo_var)))
{
goto IL_0026;
}
}
{
Hashtable_t1853889766 * L_5 = ___table0;
String_t* L_6 = ___schemeName2;
UriParser_t3890150400 * L_7 = ___uriParser1;
NullCheck(L_5);
VirtActionInvoker2< RuntimeObject *, RuntimeObject * >::Invoke(25 /* System.Void System.Collections.Hashtable::Add(System.Object,System.Object) */, L_5, L_6, L_7);
goto IL_0042;
}
IL_0026:
{
DefaultUriParser_t95882050 * L_8 = (DefaultUriParser_t95882050 *)il2cpp_codegen_object_new(DefaultUriParser_t95882050_il2cpp_TypeInfo_var);
DefaultUriParser__ctor_m2377995797(L_8, /*hidden argument*/NULL);
V_0 = L_8;
DefaultUriParser_t95882050 * L_9 = V_0;
String_t* L_10 = ___schemeName2;
NullCheck(L_9);
UriParser_set_SchemeName_m266448765(L_9, L_10, /*hidden argument*/NULL);
DefaultUriParser_t95882050 * L_11 = V_0;
int32_t L_12 = ___defaultPort3;
NullCheck(L_11);
UriParser_set_DefaultPort_m4007715058(L_11, L_12, /*hidden argument*/NULL);
Hashtable_t1853889766 * L_13 = ___table0;
String_t* L_14 = ___schemeName2;
DefaultUriParser_t95882050 * L_15 = V_0;
NullCheck(L_13);
VirtActionInvoker2< RuntimeObject *, RuntimeObject * >::Invoke(25 /* System.Void System.Collections.Hashtable::Add(System.Object,System.Object) */, L_13, L_14, L_15);
}
IL_0042:
{
UriParser_t3890150400 * L_16 = ___uriParser1;
String_t* L_17 = ___schemeName2;
int32_t L_18 = ___defaultPort3;
NullCheck(L_16);
VirtActionInvoker2< String_t*, int32_t >::Invoke(5 /* System.Void System.UriParser::OnRegister(System.String,System.Int32) */, L_16, L_17, L_18);
return;
}
}
// System.UriParser System.UriParser::GetParser(System.String)
extern "C" IL2CPP_METHOD_ATTR UriParser_t3890150400 * UriParser_GetParser_m544052729 (RuntimeObject * __this /* static, unused */, String_t* ___schemeName0, const RuntimeMethod* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (UriParser_GetParser_m544052729_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
String_t* V_0 = NULL;
{
String_t* L_0 = ___schemeName0;
if (L_0)
{
goto IL_0008;
}
}
{
return (UriParser_t3890150400 *)NULL;
}
IL_0008:
{
IL2CPP_RUNTIME_CLASS_INIT(UriParser_t3890150400_il2cpp_TypeInfo_var);
UriParser_CreateDefaults_m404296154(NULL /*static, unused*/, /*hidden argument*/NULL);
String_t* L_1 = ___schemeName0;
IL2CPP_RUNTIME_CLASS_INIT(CultureInfo_t4157843068_il2cpp_TypeInfo_var);
CultureInfo_t4157843068 * L_2 = CultureInfo_get_InvariantCulture_m3532445182(NULL /*static, unused*/, /*hidden argument*/NULL);
NullCheck(L_1);
String_t* L_3 = String_ToLower_m3490221821(L_1, L_2, /*hidden argument*/NULL);
V_0 = L_3;
Hashtable_t1853889766 * L_4 = ((UriParser_t3890150400_StaticFields*)il2cpp_codegen_static_fields_for(UriParser_t3890150400_il2cpp_TypeInfo_var))->get_table_1();
String_t* L_5 = V_0;
NullCheck(L_4);
RuntimeObject * L_6 = VirtFuncInvoker1< RuntimeObject *, RuntimeObject * >::Invoke(22 /* System.Object System.Collections.Hashtable::get_Item(System.Object) */, L_4, L_5);
return ((UriParser_t3890150400 *)CastclassClass((RuntimeObject*)L_6, UriParser_t3890150400_il2cpp_TypeInfo_var));
}
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
#ifdef __clang__
#pragma clang diagnostic pop
#endif
| 42.601742
| 276
| 0.813817
|
ShearerAWS
|
b7cdd8fee874cc7a0fa0bd6c3cfee1eeeee26a58
| 414
|
hpp
|
C++
|
include/RED4ext/Scripting/Natives/Generated/tools/JiraService.hpp
|
jackhumbert/RED4ext.SDK
|
2c55eccb83beabbbe02abae7945af8efce638fca
|
[
"MIT"
] | 1
|
2022-03-18T17:22:09.000Z
|
2022-03-18T17:22:09.000Z
|
include/RED4ext/Scripting/Natives/Generated/tools/JiraService.hpp
|
jackhumbert/RED4ext.SDK
|
2c55eccb83beabbbe02abae7945af8efce638fca
|
[
"MIT"
] | null | null | null |
include/RED4ext/Scripting/Natives/Generated/tools/JiraService.hpp
|
jackhumbert/RED4ext.SDK
|
2c55eccb83beabbbe02abae7945af8efce638fca
|
[
"MIT"
] | 1
|
2022-02-13T01:44:55.000Z
|
2022-02-13T01:44:55.000Z
|
#pragma once
// This file is generated from the Game's Reflection data
#include <cstdint>
#include <RED4ext/Common.hpp>
namespace RED4ext
{
namespace tools {
struct JiraService
{
static constexpr const char* NAME = "toolsJiraService";
static constexpr const char* ALIAS = NAME;
uint8_t unk00[0xE8 - 0x0]; // 0
};
RED4EXT_ASSERT_SIZE(JiraService, 0xE8);
} // namespace tools
} // namespace RED4ext
| 19.714286
| 59
| 0.724638
|
jackhumbert
|
b7ce190ef178fda1e18a4ba7c521aa1f5c7484d6
| 7,947
|
cpp
|
C++
|
ModuleGOManager.cpp
|
N4bi/SahelanthropusEngine
|
e64c1e2a544b7f2c4e3bf50b027ef3914443ef55
|
[
"MIT"
] | null | null | null |
ModuleGOManager.cpp
|
N4bi/SahelanthropusEngine
|
e64c1e2a544b7f2c4e3bf50b027ef3914443ef55
|
[
"MIT"
] | 1
|
2016-12-03T20:51:15.000Z
|
2016-12-03T20:51:15.000Z
|
ModuleGOManager.cpp
|
N4bi/Sahelanthropus_Engine
|
e64c1e2a544b7f2c4e3bf50b027ef3914443ef55
|
[
"MIT"
] | null | null | null |
#include "Application.h"
#include "ModuleGOManager.h"
#include "GameObject.h"
#include "Component.h"
#include "ComponentTransform.h"
#include "Quadtree.h"
#include "Imgui\imgui.h"
#include <algorithm>
using namespace std;
ModuleGOManager::ModuleGOManager(Application * app, const char* name, bool start_enabled) : Module(app, name, start_enabled)
{
}
ModuleGOManager::~ModuleGOManager()
{
}
bool ModuleGOManager::Init(Json& config)
{
bool ret = true;
LOG("Init Game Object Manager");
root = new GameObject(nullptr, "root");
root->AddComponent(Component::TRANSFORM);
quad.Create(100.0f);
return ret;
}
bool ModuleGOManager::Start(float dt)
{
bool ret = true;
LOG("Start Game Object Manager");
return false;
}
update_status ModuleGOManager::PreUpdate(float dt)
{
//Delete game objects in the vector to delete
vector<GameObject*>::iterator it = to_delete.begin();
while (it != to_delete.end())
{
delete(*it);
++it;
}
to_delete.clear();
if (root)
{
DoPreUpdate(dt, root);
}
return UPDATE_CONTINUE;
}
update_status ModuleGOManager::Update(float dt)
{
if (root)
{
UpdateChilds(dt, root);
}
HierarchyInfo();
EditorWindow();
if (App->input->GetMouseButton(SDL_BUTTON_RIGHT) == KEY_DOWN)
{
LineSegment raycast = App->editor->main_camera_component->CastRay();
game_object_on_editor = SelectGameObject(raycast, CollectHits(raycast));
}
quad.Render();
return UPDATE_CONTINUE;
}
bool ModuleGOManager::CleanUp()
{
bool ret = true;
delete root;
game_object_on_editor = nullptr;
root = nullptr;
return ret;
}
GameObject* ModuleGOManager::CreateGameObject(GameObject* parent, const char* name)
{
GameObject* ret = new GameObject(parent, name);
if (parent == nullptr)
{
parent = root;
}
parent->childs.push_back(ret);
return ret;
}
void ModuleGOManager::DeleteGameObject(GameObject * go)
{
if (go != nullptr)
{
if (go->GetParent() != nullptr)
{
go->GetParent()->DeleteChilds(go);
}
go->DeleteAllChildren();
to_delete.push_back(go);
}
}
void ModuleGOManager::HierarchyInfo()
{
ImGui::Begin("Hierarchy");
ShowGameObjectsOnEditor(root->GetChilds());
ImGui::End();
}
void ModuleGOManager::ShowGameObjectsOnEditor(const vector<GameObject*>* childs)
{
vector<GameObject*>::const_iterator it = (*childs).begin();
while (it != (*childs).end())
{
uint flags = 0;
if ((*it) == game_object_on_editor)
{
flags = ImGuiTreeNodeFlags_Selected;
}
if ((*it)->childs.size() > 0)
{
if (ImGui::TreeNodeEx((*it)->name_object.data(), ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_DefaultOpen))
{
if (ImGui::IsItemClicked())
{
game_object_on_editor = (*it);
}
ShowGameObjectsOnEditor((*it)->GetChilds());
ImGui::TreePop();
}
}
else
{
if (ImGui::TreeNodeEx((*it)->name_object.data(), flags | ImGuiTreeNodeFlags_Leaf))
{
if (ImGui::IsItemClicked())
{
game_object_on_editor = (*it);
}
ImGui::TreePop();
}
}
++it;
}
}
void ModuleGOManager::EditorWindow()
{
ImGui::Begin("Editor");
if (game_object_on_editor)
{
bool is_enabled = game_object_on_editor->isEnabled();
if (ImGui::Checkbox(game_object_on_editor->name_object._Myptr(),&is_enabled))
{
if (is_enabled)
{
game_object_on_editor->Enable();
}
else
{
game_object_on_editor->Disable();
}
}
ImGui::SameLine();
bool wire_enabled = App->renderer3D->wireframe;
if (ImGui::Checkbox("Wireframe", &wire_enabled))
{
if (wire_enabled)
{
App->renderer3D->wireframe = true;
}
else
{
App->renderer3D->wireframe = false;
}
}
ImGui::SameLine();
ImGui::TextColored(IMGUI_GREEN,"ID object: ");
ImGui::SameLine();
ImGui::Text("%d", game_object_on_editor->GetID());
const vector<Component*>* components = game_object_on_editor->GetComponents();
for (vector<Component*>::const_iterator component = (*components).begin(); component != (*components).end(); ++component)
{
(*component)->ShowOnEditor();
}
}
ImGui::End();
}
int CheckDistance(const GameObject* go1, const GameObject* go2)
{
if (go1->distance_hit.Length() < go2->distance_hit.Length())
{
return 0;
}
}
GameObject * ModuleGOManager::SelectGameObject(const LineSegment & ray, const vector<GameObject*> hits)
{
GameObject* game_object_picked = nullptr;
float distance = App->editor->main_camera_component->frustum.farPlaneDistance;
vector<GameObject*>::const_iterator it = hits.begin();
while (it != hits.end())
{
if ((*it)->CheckHits(ray,distance))
{
game_object_picked = (*it);
}
++it;
}
return game_object_picked;
}
vector<GameObject*> ModuleGOManager::CollectHits(const LineSegment & ray) const
{
vector<GameObject*> objects_hit;
root->CollectRayHits(root, ray, objects_hit);
sort(objects_hit.begin(), objects_hit.end(), CheckDistance);
return objects_hit;
}
void ModuleGOManager::SaveGameObjectsOnScene(const char* name_file) const
{
Json data;
data.AddArray("Game Objects");
root->Save(data);
char* buff;
size_t size = data.Save(&buff);
App->fs->Save(name_file, buff, size);
delete[] buff;
}
GameObject * ModuleGOManager::LoadGameObjectsOnScene(Json & game_objects)
{
const char* name = game_objects.GetString("Name");
int id = game_objects.GetInt("ID Game Object");
int parent_id = game_objects.GetInt("ID Parent");
bool enabled = game_objects.GetBool("enabled");
//Search the parent of the game object
GameObject* parent = nullptr;
if (parent_id != 0 && root != nullptr)
{
parent = SearchGameObjectsByID(root, parent_id);
}
//Create the childs
GameObject* child = new GameObject(parent, name, id, enabled);
if (parent != nullptr)
{
parent->childs.push_back(child);
}
//Attach the components
Json component_data;
int component_array_size = game_objects.GetArraySize("Components");
for (uint i = 0; i < component_array_size; i++)
{
component_data = game_objects.GetArray("Components", i);
int type = component_data.GetInt("type");
Component* cmp_go = child->AddComponent((Component::Types)(type));
cmp_go->ToLoad(component_data);
}
return child;
}
GameObject * ModuleGOManager::SearchGameObjectsByID(GameObject * first_go, int id) const
{
GameObject* ret = nullptr;
if (first_go != nullptr)
{
if (first_go->id == id)
{
ret = first_go;
}
else
{
const std::vector<GameObject*>* game_objects = first_go->GetChilds();
vector<GameObject*>::const_iterator it = game_objects->begin();
while (it != game_objects->end())
{
ret = SearchGameObjectsByID((*it), id);
if (ret != nullptr)
{
break;
}
++it;
}
}
}
return ret;
}
void ModuleGOManager::InsertObjects()
{
if (root->childs.empty() == false)
{
root->InsertNode();
}
}
void ModuleGOManager::LoadScene(const char * directory)
{
char* buff;
uint size = App->fs->Load(directory, &buff);
Json scene(buff);
Json root;
root = scene.GetArray("Game Objects",0);
uint scene_size = scene.GetArraySize("Game Objects");
for (uint i = 0; i < scene_size; i++)
{
//the first one will be the root node, always.
if (i == 0)
{
this->root = LoadGameObjectsOnScene(scene.GetArray("Game Objects", i));
}
else
{
LoadGameObjectsOnScene(scene.GetArray("Game Objects", i));
}
}
delete[] buff;
}
void ModuleGOManager::DeleteScene()
{
DeleteGameObject(root);
game_object_on_editor = nullptr;
root = nullptr;
}
GameObject* ModuleGOManager::GetRoot() const
{
return root;
}
void ModuleGOManager::DoPreUpdate(float dt ,GameObject * go)
{
if (root != go)
{
go->PreUpdate(dt);
}
vector<GameObject*>::const_iterator it = go->childs.begin();
while (it != go->childs.end())
{
DoPreUpdate(dt, (*it));
++it;
}
}
void ModuleGOManager::UpdateChilds(float dt, GameObject * go)
{
if (root != go)
{
go->Update(dt);
}
vector<GameObject*>::const_iterator it = go->childs.begin();
while (it != go->childs.end())
{
UpdateChilds(dt, (*it));
++it;
}
}
| 19.011962
| 124
| 0.677866
|
N4bi
|
b7d0f2b6c1f9e4ab5607d5a7cba3237bc92f4d23
| 39,461
|
cpp
|
C++
|
Source/AllProjects/CIDBuild/CIDBuild_ProjectInfo.cpp
|
eudora-jia/CIDLib
|
02795d283d95f8a5a4fafa401b6189851901b81b
|
[
"MIT"
] | 1
|
2019-05-28T06:33:01.000Z
|
2019-05-28T06:33:01.000Z
|
Source/AllProjects/CIDBuild/CIDBuild_ProjectInfo.cpp
|
eudora-jia/CIDLib
|
02795d283d95f8a5a4fafa401b6189851901b81b
|
[
"MIT"
] | null | null | null |
Source/AllProjects/CIDBuild/CIDBuild_ProjectInfo.cpp
|
eudora-jia/CIDLib
|
02795d283d95f8a5a4fafa401b6189851901b81b
|
[
"MIT"
] | null | null | null |
//
// FILE NAME: CIDBuild_ProjectInfo.Cpp
//
// AUTHOR: Dean Roddey
//
// CREATED: 08/21/1998
//
// COPYRIGHT: Charmed Quark Systems, Ltd @ 2019
//
// This software is copyrighted by 'Charmed Quark Systems, Ltd' and
// the author (Dean Roddey.) It is licensed under the MIT Open Source
// license:
//
// https://opensource.org/licenses/MIT
//
// DESCRIPTION:
//
// This file implements the TProjectInfo class, which represents the
// platform independent settings for a single facility, plus some info
// that is collected and cached away during processing.
//
// CAVEATS/GOTCHAS:
//
// LOG:
//
// $_CIDLib_Log_$
//
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include "CIDBuild.hpp"
// ---------------------------------------------------------------------------
// CLASS: TProjFileCopy
// PREFIX: pfc
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// TProjFileCopy: Constructors and Destructor
// ---------------------------------------------------------------------------
TProjFileCopy::TProjFileCopy(const TBldStr& strOutPath) :
m_strOutPath(strOutPath)
{
}
TProjFileCopy::~TProjFileCopy()
{
}
// ---------------------------------------------------------------------------
// TProjFileCopy: Public, non-virtual methods
// ---------------------------------------------------------------------------
tCIDLib::TVoid TProjFileCopy::AddSrcFile(const TBldStr& strToAdd)
{
m_listSrcFiles.Add(new TBldStr(strToAdd));
}
const TList<TBldStr>& TProjFileCopy::listSrcFiles() const
{
return m_listSrcFiles;
}
tCIDLib::TVoid TProjFileCopy::RemoveAll()
{
m_listSrcFiles.RemoveAll();
}
const TBldStr& TProjFileCopy::strOutPath() const
{
return m_strOutPath;
}
TBldStr& TProjFileCopy::strOutPath(const TBldStr& strToSet)
{
m_strOutPath = strToSet;
return m_strOutPath;
}
// ---------------------------------------------------------------------------
// CLASS: TProjectInfo
// PREFIX: proj
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// TProjectInfo: Constructors and Destructor
// ---------------------------------------------------------------------------
TProjectInfo::TProjectInfo(const TBldStr& strName) :
m_bIsSample(kCIDLib::False)
, m_bMsgFile(kCIDLib::False)
, m_bNeedsAdminPrivs(kCIDLib::False)
, m_bPlatformDir(kCIDLib::False)
, m_bPlatformInclude(kCIDLib::False)
, m_bResFile(kCIDLib::False)
, m_bUseSysLibs(kCIDLib::False)
, m_bVarArgs(kCIDLib::False)
, m_bVersioned(kCIDLib::False)
, m_eDisplayType(tCIDBuild::EDisplayTypes::Console)
, m_eRTLMode(tCIDBuild::ERTLModes::MultiDynamic)
, m_eType(tCIDBuild::EProjTypes::Executable)
, m_strProjectName(strName)
, m_c4Base(0)
, m_c4DepIndex(0xFFFFFFFF)
{
//
// !NOTE: We cannot initialize a lot of stuff yet because its not known
// until we parse out our content from the .Projects file.
//
}
TProjectInfo::~TProjectInfo()
{
}
// ---------------------------------------------------------------------------
// TProjectInfo: Public, non-virtual methods
// ---------------------------------------------------------------------------
tCIDLib::TVoid TProjectInfo::AddToDepGraph(TDependGraph& depgTarget)
{
//
// Add ourself to the dependency graph object, and save away the
// index at which it added us.
//
m_c4DepIndex = depgTarget.c4AddNewElement(m_strProjectName);
}
tCIDLib::TBoolean TProjectInfo::bDefineExists(const TBldStr& strToFind) const
{
TList<TKeyValuePair>::TCursor cursDefs(&m_listDefs);
if (cursDefs.bResetIter())
{
do
{
if (cursDefs.tCurElement().strKey() == strToFind)
return kCIDLib::True;
} while (cursDefs.bNext());
}
return kCIDLib::False;
}
tCIDLib::TBoolean TProjectInfo::bHasIDLFiles() const
{
return !m_listIDLFiles.bEmpty();
}
tCIDLib::TBoolean TProjectInfo::bHasMsgFile() const
{
return m_bMsgFile;
}
tCIDLib::TBoolean TProjectInfo::bHasResFile() const
{
return m_bResFile;
}
tCIDLib::TBoolean TProjectInfo::bIsSample() const
{
return m_bIsSample;
}
tCIDLib::TBoolean TProjectInfo::bMakeOutDir() const
{
// If a group type, nothing to do
if (m_eType == tCIDBuild::EProjTypes::Group)
return kCIDLib::True;
// If not exists, try to create it and return that result
if (!TUtils::bExists(m_strOutDir))
return TUtils::bMakeDir(m_strOutDir);
// Else nothing to do so return true
return kCIDLib::True;
}
tCIDLib::TBoolean TProjectInfo::bNeedsAdminPrivs() const
{
return m_bNeedsAdminPrivs;
}
tCIDLib::TBoolean TProjectInfo::bPlatformDir() const
{
return m_bPlatformDir;
}
tCIDLib::TBoolean
TProjectInfo::bSupportsPlatform(const TBldStr& strToCheck) const
{
//
// If m_bPlatformInclude is true, we see if this project is in our list.
// Else we see if it not in our list.
//
tCIDLib::TBoolean bInList = kCIDLib::False;
TList<TBldStr>::TCursor cursPlatforms(&m_listPlatforms);
if (cursPlatforms.bResetIter())
{
do
{
if (cursPlatforms.tCurElement().bIEquals(strToCheck))
{
bInList = kCIDLib::True;
break;
}
} while (cursPlatforms.bNext());
}
//
// If the flags are equal, taht means that either in the list and we are in
// include mode, or not in the list and we are in ignore mode, so either is
// what we are looking for.
//
return (bInList == m_bPlatformInclude);
}
tCIDLib::TBoolean TProjectInfo::bUseSysLibs() const
{
return m_bUseSysLibs;
}
tCIDLib::TBoolean
TProjectInfo::bUsesExtLib(const TBldStr& strToCheck) const
{
// Search the external libs list for this one.
TList<TBldStr>::TCursor cursLibs(&m_listExtLibs);
if (!cursLibs.bResetIter())
return kCIDLib::True;
do
{
if (cursLibs.tCurElement() == strToCheck)
return kCIDLib::True;
} while (cursLibs.bNext());
return kCIDLib::False;
}
tCIDLib::TBoolean TProjectInfo::bVarArgs() const
{
return m_bVarArgs;
}
tCIDLib::TBoolean TProjectInfo::bVersioned() const
{
return m_bVersioned;
}
tCIDLib::TCard4 TProjectInfo::c4Base() const
{
return m_c4Base;
}
tCIDLib::TCard4 TProjectInfo::c4CppCount() const
{
return m_listCpps.c4ElemCount();
}
tCIDLib::TCard4 TProjectInfo::c4DefCount() const
{
return m_listDefs.c4ElemCount();
}
tCIDLib::TCard4 TProjectInfo::c4DepCount() const
{
return m_listDeps.c4ElemCount();
}
tCIDLib::TCard4 TProjectInfo::c4DepIndex() const
{
return m_c4DepIndex;
}
tCIDLib::TCard4 TProjectInfo::c4HppCount() const
{
return m_listDefs.c4ElemCount();
}
tCIDLib::TVoid TProjectInfo::DumpSettings() const
{
stdOut << L"\n----------------------------------------------\n"
<< L"Settings for project: " << m_strProjectName << L"\n"
<< L"----------------------------------------------\n"
<< L" Name: " << m_strProjectName << L"\n"
<< L" Project Type: " << m_eType << L"\n"
<< L" Directory: " << m_strDirectory << L"\n"
<< L" Base: " << m_c4Base << L"\n"
<< L" Message File: " << (m_bMsgFile ? L"Yes\n" : L"No\n")
<< L" Admin Privs: " << (m_bNeedsAdminPrivs ? L"Yes\n" : L"No\n")
<< L" Resource File: " << (m_bResFile ? L"Yes\n" : L"No\n")
<< L" Platform Dir: " << (m_bPlatformDir ? L"Yes\n" : L"No\n")
<< L" Use Sys Libs: " << (m_bUseSysLibs ? L"Yes\n" : L"No\n")
<< L" Var Args: " << (m_bVarArgs ? L"Yes\n" : L"No\n")
<< L" RTL Mode: " << m_eRTLMode << L"\n"
<< L" Sample: " << (m_bIsSample ? L"Yes\n" : L"No\n");
stdOut << L" Platforms: ";
TList<TBldStr>::TCursor cursPlatforms(&m_listPlatforms);
if (!cursPlatforms.bResetIter())
{
stdOut << L"All";
}
else
{
do
{
stdOut << cursPlatforms.tCurElement() << L" ";
} while (cursPlatforms.bNext());
}
stdOut << kCIDBuild::EndLn;
}
tCIDBuild::EDisplayTypes TProjectInfo::eDisplayType() const
{
return m_eDisplayType;
}
tCIDBuild::ERTLModes TProjectInfo::eRTLMode() const
{
return m_eRTLMode;
}
tCIDBuild::EProjTypes TProjectInfo::eType() const
{
return m_eType;
}
const TList<TFindInfo>& TProjectInfo::listCpps() const
{
return m_listCpps;
}
const TList<TBldStr>& TProjectInfo::listCustomCmds() const
{
return m_listCustomCmds;
}
const TList<TBldStr>& TProjectInfo::listDeps() const
{
return m_listDeps;
}
const TList<TBldStr>& TProjectInfo::listExtLibs() const
{
return m_listExtLibs;
}
const TList<TProjFileCopy>& TProjectInfo::listFileCopies() const
{
return m_listFileCopies;
}
const TList<TFindInfo>& TProjectInfo::listHpps() const
{
return m_listHpps;
}
const TList<TIDLInfo>& TProjectInfo::listIDLFiles() const
{
return m_listIDLFiles;
}
const TList<TBldStr>& TProjectInfo::listIncludePaths() const
{
return m_listIncludePaths;
}
tCIDLib::TVoid TProjectInfo::LoadFileLists()
{
// If a group type, nothing to do
if (m_eType == tCIDBuild::EProjTypes::Group)
return;
// Change to this project's directory
if (!TUtils::bChangeDir(m_strProjectDir))
{
stdOut << L"Could not change to project directory: "
<< m_strProjectDir << kCIDBuild::EndLn;
throw tCIDBuild::EErrors::Internal;
}
// Load up all of the H
TBldStr strSearch(m_strProjectDir);
strSearch.Append(kCIDBuild::pszAllHFiles);
TFindInfo::c4FindFiles(strSearch, m_listHpps);
// And Hpp files
strSearch = m_strProjectDir;
strSearch.Append(kCIDBuild::pszAllHppFiles);
TFindInfo::c4FindFiles(strSearch, m_listHpps);
// Load up all of the C files
strSearch = m_strProjectDir;
strSearch.Append(kCIDBuild::pszAllCFiles);
TFindInfo::c4FindFiles(strSearch, m_listCpps);
// And the Cpp files
strSearch = m_strProjectDir;
strSearch.Append(kCIDBuild::pszAllCppFiles);
TFindInfo::c4FindFiles(strSearch, m_listCpps);
//
// But, if this project has a per-platform directory, then we have to
// also do those files, which means we have to append onto the stuff we
// already got.
//
// For the Cpp files we tell it to return the relative path component.
// Since we give it only "platdir\*.XXX", we will get back just what we
// want, which is a path relative to the project directory.
//
if (m_bPlatformDir)
{
strSearch = kCIDBuild::pszPlatformDir;
strSearch.Append(L"\\", kCIDBuild::pszAllHFiles);
TFindInfo::c4FindFiles(strSearch, m_listHpps, tCIDBuild::EPathModes::Relative);
strSearch = kCIDBuild::pszPlatformDir;
strSearch.Append(L"\\", kCIDBuild::pszAllHppFiles);
TFindInfo::c4FindFiles(strSearch, m_listHpps, tCIDBuild::EPathModes::Relative);
strSearch = kCIDBuild::pszPlatformDir;
strSearch.Append(L"\\", kCIDBuild::pszAllCFiles);
TFindInfo::c4FindFiles(strSearch, m_listCpps, tCIDBuild::EPathModes::Relative);
strSearch = kCIDBuild::pszPlatformDir;
strSearch.Append(L"\\", kCIDBuild::pszAllCppFiles);
TFindInfo::c4FindFiles(strSearch, m_listCpps, tCIDBuild::EPathModes::Relative);
}
}
// Used by per-platform tools drivers to check for
const TKeyValuePair*
TProjectInfo::pkvpFindPlatOpt(const TBldStr& strPlatform, const TBldStr& strOption) const
{
//
// Loop through the list of lists. The key of the first entry in each one is
// platform name.
//
TPlatOptList::TCursor cursPlatOpts(&m_listPlatOpts);
if (!cursPlatOpts.bResetIter())
return nullptr;
do
{
TKVPList::TCursor cursPlat(&cursPlatOpts.tCurElement());
if (cursPlat.bResetIter())
{
if (cursPlat->strKey().bIEquals(strPlatform))
{
//
// This is the right platform, so check it's entries, move past the first one
// before we start.
//
if (!cursPlat.bNext())
break;
do
{
if (cursPlat->strKey().bIEquals(strOption))
return &cursPlat.tCurElement();
} while (cursPlat.bNext());
}
}
} while (cursPlatOpts.bNext());
return nullptr;
}
// This is called to let us parse our contents out of the project definition file
tCIDLib::TVoid TProjectInfo::ParseContent(TLineSpooler& lsplSource)
{
//
// Ok, lets go into a line reading loop and pull out or information
// we find the major sections here and then pass them off to private
// methods to deal with the details.
//
tCIDLib::TBoolean bSeenPlats = kCIDLib::False;
tCIDLib::TBoolean bDone = kCIDLib::False;
TBldStr strReadBuf;
while (!bDone)
{
// Get the next line. If end of file, that's an error here
if (!lsplSource.bReadLine(strReadBuf))
{
stdOut << L"(Line " << lsplSource.c4CurLine()
<< L") Expected SETTINGS, DEPENDENTS, DEFINES, or END PROJECT"
<< kCIDBuild::EndLn;
throw tCIDBuild::EErrors::UnexpectedEOF;
}
if (strReadBuf == L"SETTINGS")
{
ParseSettings(lsplSource);
}
else if (strReadBuf == L"DEPENDENTS")
{
ParseDependents(lsplSource);
}
else if (strReadBuf == L"DEFINES")
{
ParseDefines(lsplSource);
}
else if (strReadBuf == L"EXCLUDEPLATS")
{
if (bSeenPlats)
{
stdOut << L"(Line " << lsplSource.c4CurLine()
<< L") Only one of include/exclude platforms can be used"
<< kCIDBuild::EndLn;
throw tCIDBuild::EErrors::UnexpectedEOF;
}
bSeenPlats = kCIDLib::True;
m_bPlatformInclude = kCIDLib::False;
ParsePlatforms(lsplSource);
}
else if (strReadBuf == L"EXTLIBS")
{
ParseExtLibs(lsplSource);
}
else if (strReadBuf == L"IDLFILES")
{
ParseIDLFiles(lsplSource);
}
else if (strReadBuf == L"INCLUDEPATHS")
{
ParseIncludePaths(lsplSource);
}
else if (strReadBuf == L"INCLUDEPLATS")
{
if (bSeenPlats)
{
stdOut << L"(Line " << lsplSource.c4CurLine()
<< L") Only one of include/exclude platforms can be used"
<< kCIDBuild::EndLn;
throw tCIDBuild::EErrors::UnexpectedEOF;
}
m_bPlatformInclude = kCIDLib::True;
ParsePlatforms(lsplSource);
}
else if (strReadBuf == L"END PROJECT")
{
bDone = kCIDLib::True;
}
else if (strReadBuf.bStartsWith(L"CUSTOMCMDS"))
{
ParseCustCmds(lsplSource);
}
else if (strReadBuf.bStartsWith(L"FILECOPIES"))
{
//
// It's a file copy block. Is can be followed by the target
// path for this block of copies.
//
strReadBuf.Cut(10);
strReadBuf.StripWhitespace();
if (strReadBuf[0] == L'=')
{
strReadBuf.Cut(1);
strReadBuf.StripWhitespace();
}
ParseFileCopies(lsplSource, strReadBuf);
}
else if (strReadBuf == L"PLATFORMOPTS")
{
ParsePlatOpts(lsplSource);
}
else
{
stdOut << L"(Line " << lsplSource.c4CurLine()
<< L") Expected SETTINGS, DEPENDENTS, EXTLIBS, DEFINES, or END PROJECT"
<< kCIDBuild::EndLn;
throw tCIDBuild::EErrors::FileFormat;
}
}
// Only do this stuff if not a group
if (m_eType != tCIDBuild::EProjTypes::Group)
{
// Build up a path the project's output
m_strOutDir = facCIDBuild.strOutDir();
m_strOutDir.Append(m_strProjectName);
m_strOutDir.Append(L".Out");
m_strOutDir.Append(L"\\");
// Build the name to the error ids header, which goes to the include dir
m_strOutErrHpp = m_strProjectDir; // facCIDBuild.strIncludeDir();
m_strOutErrHpp.Append(m_strProjectName);
m_strOutErrHpp.Append(L"_ErrorIds.hpp");
// Build the name to the message ids header, which goes to the include dir
m_strOutMsgHpp = m_strProjectDir; // facCIDBuild.strIncludeDir();
m_strOutMsgHpp.Append(m_strProjectName);
m_strOutMsgHpp.Append(L"_MessageIds.hpp");
// Bulld the name to the message text source, if any
m_strMsgSrc = m_strProjectDir;
m_strMsgSrc.Append(m_strProjectName);
m_strMsgSrc.Append(L"_");
m_strMsgSrc.Append(facCIDBuild.strLangSuffix());
m_strMsgSrc.Append(L".MsgText");
// Bulld the name to the GUI resource source, if any
m_strResSrc = m_strProjectDir;
m_strResSrc.Append(m_strProjectName);
m_strResSrc.Append(L".CIDRC");
//
// Build up the output binary message file name. If this project is
// versioned, then append the version postfix. And its language specific
// so add the language suffix.
//
m_strOutMsgs = facCIDBuild.strOutDir();
m_strOutMsgs.Append(m_strProjectName);
if (m_bVersioned)
m_strOutMsgs.Append(facCIDBuild.strVersionSuffix());
m_strOutMsgs.Append(L"_");
m_strOutMsgs.Append(facCIDBuild.strLangSuffix());
m_strOutMsgs.Append(L".CIDMsg");
//
// And do the same for the resource file. Its version specific, but not
// language specific.
//
m_strOutRes = facCIDBuild.strOutDir();
m_strOutRes.Append(m_strProjectName);
if (m_bVersioned)
m_strOutRes.Append(facCIDBuild.strVersionSuffix());
m_strOutRes.Append(L".CIDRes");
// And the resource header file
m_strOutResHpp = m_strProjectDir; // facCIDBuild.strIncludeDir();
m_strOutResHpp.Append(m_strProjectName);
m_strOutResHpp.Append(L"_ResourceIds.hpp");
//
// Allow the per-platform code to build up the paths to the primary
// output file.
//
BuildOutputFileName();
}
}
const TBldStr& TProjectInfo::strDirectory() const
{
return m_strDirectory;
}
const TBldStr& TProjectInfo::strExportKeyword() const
{
return m_strExportKeyword;
}
const TBldStr& TProjectInfo::strMsgSrc() const
{
return m_strMsgSrc;
}
const TBldStr& TProjectInfo::strResSrc() const
{
return m_strResSrc;
}
const TBldStr& TProjectInfo::strOutDir() const
{
return m_strOutDir;
}
const TBldStr& TProjectInfo::strOutErrHpp() const
{
return m_strOutErrHpp;
}
const TBldStr& TProjectInfo::strOutMsgHpp() const
{
return m_strOutMsgHpp;
}
const TBldStr& TProjectInfo::strOutMsgs() const
{
return m_strOutMsgs;
}
const TBldStr& TProjectInfo::strOutBin() const
{
return m_strOutBin;
}
const TBldStr& TProjectInfo::strOutRes() const
{
return m_strOutRes;
}
const TBldStr& TProjectInfo::strOutResHpp() const
{
return m_strOutResHpp;
}
const TBldStr& TProjectInfo::strProjectName() const
{
return m_strProjectName;
}
const TBldStr& TProjectInfo::strProjectDir() const
{
return m_strProjectDir;
}
// ---------------------------------------------------------------------------
// TProjectInfo: Private, non-virtual methods
// ---------------------------------------------------------------------------
tCIDLib::TBoolean
TProjectInfo::bSetSetting(const TBldStr& strName, const TBldStr& strValue)
{
if (strName == L"BASE")
{
//
// This is a number so it must convert correctly. Its just a simple
// decimal value.
//
if (!TRawStr::bXlatCard4(strValue.pszBuffer(), m_c4Base, 10))
return kCIDLib::False;
}
else if (strName == L"DIRECTORY")
{
// Store the raw directory
m_strDirectory = strValue;
// Build up the path to the directory and store it.
m_strProjectDir = facCIDBuild.strRootDir();
m_strProjectDir.Append(L"Source", L"\\");
m_strProjectDir.Append(L"AllProjects", L"\\");
// If it's not empty (i.e. top level), then add it, and end with a slash
if (!m_strDirectory.bEmpty())
{
m_strProjectDir.Append(m_strDirectory);
m_strProjectDir.Append(L"\\");
}
}
else if (strName == L"DISPLAY")
{
if (strValue == L"N/A")
m_eDisplayType = tCIDBuild::EDisplayTypes::NotApplicable;
else if (strValue == L"Console")
m_eDisplayType = tCIDBuild::EDisplayTypes::Console;
else if (strValue == L"GUI")
m_eDisplayType = tCIDBuild::EDisplayTypes::GUI;
else
return kCIDLib::False;
}
else if (strName == L"EXPORT")
{
m_strExportKeyword = strValue;
}
else if (strName == L"MSGFILE")
{
if (strValue == L"No")
{
m_bMsgFile = kCIDLib::False;
}
else if (strValue == L"Yes")
{
m_bMsgFile = kCIDLib::True;
}
else
{
// It's not valid
return kCIDLib::False;
}
}
else if (strName == L"RESFILE")
{
if (strValue == L"No")
{
m_bResFile = kCIDLib::False;
}
else if (strValue == L"Yes")
{
m_bResFile = kCIDLib::True;
}
else
{
// It's not valid
return kCIDLib::False;
}
}
else if (strName == L"ADMINPRIVS")
{
if (!TRawStr::bXlatBoolean(strValue.pszBuffer(), m_bNeedsAdminPrivs))
return kCIDLib::False;
}
else if (strName == L"PLATFORMDIR")
{
if (!TRawStr::bXlatBoolean(strValue.pszBuffer(), m_bPlatformDir))
return kCIDLib::False;
}
else if (strName == L"RTL")
{
if (strValue == L"Single/Static")
m_eRTLMode = tCIDBuild::ERTLModes::SingleStatic;
else if (strValue == L"Single/Dynamic")
m_eRTLMode = tCIDBuild::ERTLModes::SingleStatic;
else if (strValue == L"Multi/Static")
m_eRTLMode = tCIDBuild::ERTLModes::MultiStatic;
else if (strValue == L"Multi/Dynamic")
m_eRTLMode = tCIDBuild::ERTLModes::MultiDynamic;
else
return kCIDLib::False;
}
else if (strName == L"TYPE")
{
if (strValue == L"SharedObj")
m_eType = tCIDBuild::EProjTypes::SharedObj;
else if (strValue == L"SharedLib")
m_eType = tCIDBuild::EProjTypes::SharedLib;
else if (strValue == L"StaticLib")
m_eType = tCIDBuild::EProjTypes::StaticLib;
else if (strValue == L"Executable")
m_eType = tCIDBuild::EProjTypes::Executable;
else if (strValue == L"Service")
m_eType = tCIDBuild::EProjTypes::Service;
else if (strValue == L"FileCopy")
m_eType = tCIDBuild::EProjTypes::FileCopy;
else if (strValue == L"Group")
m_eType = tCIDBuild::EProjTypes::Group;
else
return kCIDLib::False;
}
else if (strName == L"VARARGS")
{
if (!TUtils::bXlatBool(strValue, m_bVarArgs))
return kCIDLib::False;
}
else if (strName == L"VERSIONED")
{
if (!TUtils::bXlatBool(strValue, m_bVersioned))
return kCIDLib::False;
}
else if (strName == L"USESYSLIBS")
{
if (!TUtils::bXlatBool(strValue, m_bUseSysLibs))
return kCIDLib::False;
}
else if (strName == L"SAMPLE")
{
if (!TRawStr::bXlatBoolean(strValue.pszBuffer(), m_bIsSample))
return kCIDLib::False;
}
else
{
// Don't know what this setting is
return kCIDLib::False;
}
return kCIDLib::True;
}
// Called to parse the contents of the custom commands block
tCIDLib::TVoid TProjectInfo::ParseCustCmds(TLineSpooler& lsplSource)
{
TBldStr strReadBuf;
while (kCIDLib::True)
{
// Get the next line. If end of file, that's an error here
if (!lsplSource.bReadLine(strReadBuf))
{
stdOut << L"(Line " << lsplSource.c4CurLine()
<< L") Expected 'custom command line' or END CUSTOMCMDS"
<< kCIDBuild::EndLn;
throw tCIDBuild::EErrors::UnexpectedEOF;
}
if (strReadBuf == L"END CUSTOMCMDS")
break;
// Just add it to our custom commands list
m_listCustomCmds.Add(new TBldStr(strReadBuf));
}
}
tCIDLib::TVoid TProjectInfo::ParseDefines(TLineSpooler& lsplSource)
{
TBldStr strName;
TBldStr strReadBuf;
TBldStr strValue;
while (kCIDLib::True)
{
// Get the next line. If end of file, that's an error here
if (!lsplSource.bReadLine(strReadBuf))
{
stdOut << L"(Line " << lsplSource.c4CurLine()
<< L") Expected 'name=value' or END DEFINES"
<< kCIDBuild::EndLn;
throw tCIDBuild::EErrors::UnexpectedEOF;
}
if (strReadBuf == L"END DEFINES")
break;
// Have to assume its a define so pull it out
if (!TUtils::bFindNVParts(strReadBuf, strName, strValue))
{
stdOut << L"(Line " << lsplSource.c4CurLine()
<< L") Badly formed DEFINE statement" << kCIDBuild::EndLn;
throw tCIDBuild::EErrors::FileFormat;
}
// Add a new define, if it does not already exist
if (bDefineExists(strName))
{
stdOut << L"(Line " << lsplSource.c4CurLine()
<< L") Define '" << strName
<< L"' already exists" << kCIDBuild::EndLn;
throw tCIDBuild::EErrors::AlreadyExists;
}
// Ok we can add it
m_listDefs.Add(new TKeyValuePair(strName, strValue));
}
}
tCIDLib::TVoid TProjectInfo::ParseDependents(TLineSpooler& lsplSource)
{
TBldStr strReadBuf;
while (kCIDLib::True)
{
// Get the next line. If end of file, that's an error here
if (!lsplSource.bReadLine(strReadBuf))
{
stdOut << L"(Line " << lsplSource.c4CurLine()
<< L") Expected 'dependent name' or END DEPENDENTS"
<< kCIDBuild::EndLn;
throw tCIDBuild::EErrors::UnexpectedEOF;
}
if (strReadBuf == L"END DEPENDENTS")
break;
// Have to assume its the name of a dependent
m_listDeps.Add(new TBldStr(strReadBuf));
}
}
tCIDLib::TVoid TProjectInfo::ParseExtLibs(TLineSpooler& lsplSource)
{
// Only valid for code type projects
if (m_eType > tCIDBuild::EProjTypes::MaxCodeType)
{
stdOut << L"(Line " << lsplSource.c4CurLine()
<< L") Not valid for this type of project"
<< kCIDBuild::EndLn;
throw tCIDBuild::EErrors::NotSupported;
}
TBldStr strReadBuf;
while (kCIDLib::True)
{
// Get the next line. If end of file, that's an error here
if (!lsplSource.bReadLine(strReadBuf))
{
stdOut << L"(Line " << lsplSource.c4CurLine()
<< L") Expected include path or END EXTLIBS"
<< kCIDBuild::EndLn;
throw tCIDBuild::EErrors::UnexpectedEOF;
}
if (strReadBuf == L"END EXTLIBS")
break;
//
// Have to assume its a lib path. It can start with the project dir
// macro, which we have to expand, else we take it as is.
//
if (strReadBuf.bStartsWith(L"$(ProjDir)\\"))
{
TBldStr strTmp(m_strProjectDir);
strTmp.AppendAt(strReadBuf, 11);
m_listExtLibs.Add(new TBldStr(strTmp));
}
else
{
m_listExtLibs.Add(new TBldStr(strReadBuf));
}
}
}
tCIDLib::TVoid
TProjectInfo::ParseFileCopies(TLineSpooler& lsplSource, const TBldStr& strTarPath)
{
// Add a new file copy object to the list, setting the passed target path
TProjFileCopy* pfcNew = new TProjFileCopy(strTarPath);
m_listFileCopies.Add(pfcNew);
TBldStr strReadBuf;
while (kCIDLib::True)
{
// Get the next line. If end of file, that's an error here
if (!lsplSource.bReadLine(strReadBuf))
{
stdOut << L"(Line " << lsplSource.c4CurLine()
<< L") Expected include path or END FILECOPIES"
<< kCIDBuild::EndLn;
throw tCIDBuild::EErrors::UnexpectedEOF;
}
if (strReadBuf == L"END FILECOPIES")
break;
// Have to assume its a file name to copy
pfcNew->AddSrcFile(strReadBuf);
}
//
// If there's one entry and it is in the form *, then we get the source
// directory and add all the files in that directory to the list.
//
if (pfcNew->listSrcFiles().c4ElemCount() == 1)
{
TListCursor<TBldStr> cursOrgList(&pfcNew->listSrcFiles());
if (cursOrgList.bResetIter())
{
if (cursOrgList.tCurElement() == L"*")
{
strReadBuf = strProjectDir();
strReadBuf.Append(L"\\*");
pfcNew->RemoveAll();
TList<TFindInfo> listNewList;
TFindInfo::c4FindFiles(strReadBuf, listNewList);
TListCursor<TFindInfo> cursNewList(&listNewList);
if (cursNewList.bResetIter())
{
do
{
if (!cursNewList.tCurElement().bIsDirectory())
pfcNew->AddSrcFile(cursNewList.tCurElement().strFileName());
} while (cursNewList.bNext());
}
}
}
}
}
tCIDLib::TVoid TProjectInfo::ParseIDLFiles(TLineSpooler& lsplSource)
{
// Only valid for code type projects
if (m_eType > tCIDBuild::EProjTypes::MaxCodeType)
{
stdOut << L"(Line " << lsplSource.c4CurLine()
<< L") Not valid for a 'filecopy' project"
<< kCIDBuild::EndLn;
throw tCIDBuild::EErrors::NotSupported;
}
TIDLInfo idliTmp;
TBldStr strReadBuf;
while (kCIDLib::True)
{
// Get the next line. If end of file, that's an error here
if (!lsplSource.bReadLine(strReadBuf))
{
stdOut << L"(Line " << lsplSource.c4CurLine()
<< L") Expected IDLFILE or END IDLFILES"
<< kCIDBuild::EndLn;
throw tCIDBuild::EErrors::UnexpectedEOF;
}
if (strReadBuf == L"END IDLFILES")
break;
// It must be IDLFILE
if (strReadBuf != L"IDLFILE")
{
stdOut << L"(Line " << lsplSource.c4CurLine()
<< L") Expected IDLFILE" << kCIDBuild::EndLn;
throw tCIDBuild::EErrors::FileFormat;
}
//
// Ok, parse out the fields for this entry. It just has a few
// fields, the source IDL file path, the gen mode, and an optional
// name extension. We just create a new TIDLInfo object and let
// it parse itself out.
//
idliTmp.Parse(lsplSource);
// It worked, so add it to the list
m_listIDLFiles.Add(new TIDLInfo(idliTmp));
}
}
tCIDLib::TVoid TProjectInfo::ParseIncludePaths(TLineSpooler& lsplSource)
{
// Only valid for code type projects
if (m_eType > tCIDBuild::EProjTypes::MaxCodeType)
{
stdOut << L"(Line " << lsplSource.c4CurLine()
<< L") Not valid for a 'filecopy' project"
<< kCIDBuild::EndLn;
throw tCIDBuild::EErrors::NotSupported;
}
TBldStr strReadBuf;
while (kCIDLib::True)
{
// Get the next line. If end of file, that's an error here
if (!lsplSource.bReadLine(strReadBuf))
{
stdOut << L"(Line " << lsplSource.c4CurLine()
<< L") Expected include path or END INCLUDEPATHS"
<< kCIDBuild::EndLn;
throw tCIDBuild::EErrors::UnexpectedEOF;
}
if (strReadBuf == L"END INCLUDEPATHS")
break;
//
// Have to assume its an include path. If it isn't fully qualified,
// then assume it is relative to the project source path. If if
// starts with $(ProjDir), replace that with the project directory.
//
if (TUtils::bIsFQPath(strReadBuf))
{
m_listIncludePaths.Add(new TBldStr(strReadBuf));
}
else if (strReadBuf.bStartsWith(L"$(ProjDir)\\"))
{
TBldStr strTmp(m_strProjectDir);
strTmp.AppendAt(strReadBuf, 11);
m_listIncludePaths.Add(new TBldStr(strTmp));
}
else
{
TBldStr strTmp(m_strProjectDir);
strTmp.Append(strReadBuf);
m_listIncludePaths.Add(new TBldStr(strTmp));
}
}
}
tCIDLib::TVoid TProjectInfo::ParsePlatforms(TLineSpooler& lsplSource)
{
TBldStr strReadBuf;
while (kCIDLib::True)
{
// Get the next line. If end of file, that's an error here
if (!lsplSource.bReadLine(strReadBuf))
{
stdOut << L"(Line " << lsplSource.c4CurLine()
<< L") Expected 'platform name' or end of platforms"
<< kCIDBuild::EndLn;
throw tCIDBuild::EErrors::UnexpectedEOF;
}
if (((strReadBuf == L"END INCLUDEPLATS") && m_bPlatformInclude)
|| ((strReadBuf == L"END EXPLUDEPLATS") && !m_bPlatformInclude))
{
break;
}
// Have to assume its the name of a support platform
m_listPlatforms.Add(new TBldStr(strReadBuf));
}
}
tCIDLib::TVoid TProjectInfo::ParsePlatOpts(TLineSpooler& lsplSource)
{
TBldStr strOptName;
TBldStr strOptValue;
TBldStr strPlatName;
TBldStr strReadBuf;
while (kCIDLib::True)
{
// Get the next line. If end of file, that's an error here
if (!lsplSource.bReadLine(strReadBuf))
{
stdOut << L"(Line " << lsplSource.c4CurLine()
<< L") Expected END PLATFORMOPTS or PLATFORM="
<< kCIDBuild::EndLn;
throw tCIDBuild::EErrors::UnexpectedEOF;
}
if (strReadBuf == L"END PLATFORMOPTS")
{
break;
}
// It should start with PLATFORM= and the platform name
if (!strReadBuf.bStartsWith(L"PLATFORM="))
{
stdOut << L"(Line " << lsplSource.c4CurLine()
<< L") Expected END PLATFORMOPTS or PLATFORM="
<< kCIDBuild::EndLn;
throw tCIDBuild::EErrors::FileFormat;
}
// Next should be the platform name so get that out
strPlatName = strReadBuf;
strPlatName.Cut(9);
//
// Add a new list for this platform and a first entry with the key being
// the platform name.
//
TKVPList* plistNew = new TKVPList();
plistNew->Add(new TKeyValuePair(strPlatName, L""));
m_listPlatOpts.Add(plistNew);
//
// Now we loop till we see the end of this block, pulling out lines
// each of which is either a value or a key=value pair.
//
while (kCIDLib::True)
{
// Get the next line. If end of file, that's an error here
if (!lsplSource.bReadLine(strReadBuf))
{
stdOut << L"(Line " << lsplSource.c4CurLine()
<< L") Expected END PLATFORM or a platform option="
<< kCIDBuild::EndLn;
throw tCIDBuild::EErrors::UnexpectedEOF;
}
if (strReadBuf == L"END PLATFORM")
break;
// It has to be in our standard key=value format
if (!TUtils::bFindNVParts(strReadBuf, strOptName, strOptValue))
{
stdOut << L"(Line " << lsplSource.c4CurLine()
<< L") Badly formed platform option statement" << kCIDBuild::EndLn;
throw tCIDBuild::EErrors::FileFormat;
}
// Add a new pair for this guy
plistNew->Add(new TKeyValuePair(strOptName, strOptValue));
}
}
}
tCIDLib::TVoid TProjectInfo::ParseSettings(TLineSpooler& lsplSource)
{
TBldStr strName;
TBldStr strReadBuf;
TBldStr strValue;
while (kCIDLib::True)
{
// Get the next line. If end of file, that's an error here
if (!lsplSource.bReadLine(strReadBuf))
{
stdOut << L"(Line " << lsplSource.c4CurLine()
<< L") Expected 'setting=value' or END SETTINGS"
<< kCIDBuild::EndLn;
throw tCIDBuild::EErrors::UnexpectedEOF;
}
if (strReadBuf == L"END SETTINGS")
break;
//
// Have to assume its a setting value, so lets see if we can
// recognize it. We use a utility function that will find the
// name/value parts of a string divided by an '=' sign.
//
if (!TUtils::bFindNVParts(strReadBuf, strName, strValue))
{
stdOut << L"(Line " << lsplSource.c4CurLine()
<< L") Badly formed SETTING statement" << kCIDBuild::EndLn;
throw tCIDBuild::EErrors::FileFormat;
}
// Find out which one it is and check the value
if (!bSetSetting(strName, strValue))
{
stdOut << L"(Line " << lsplSource.c4CurLine()
<< L") Unknown SETTING name or bad value. Name="
<< strName << kCIDBuild::EndLn;
throw tCIDBuild::EErrors::FileFormat;
}
}
//
// Insure that we got any settings that must have been provided. If not, that's
// an error. The directory can be empty if it's a group
//
if (m_strProjectName.bEmpty())
{
stdOut << L"Project settings at line " << lsplSource.c4CurLine()
<< L" failed to define a project name"
<< kCIDBuild::EndLn;
throw tCIDBuild::EErrors::FileFormat;
}
if (m_strDirectory.bEmpty() && (m_eType != tCIDBuild::EProjTypes::Group))
{
stdOut << L"Project settings at line " << lsplSource.c4CurLine()
<< L" failed to define a project name"
<< kCIDBuild::EndLn;
throw tCIDBuild::EErrors::FileFormat;
}
}
| 29.273739
| 93
| 0.563772
|
eudora-jia
|
b7d35659ef2060ce2c97f553eae81ce927254b82
| 729
|
cpp
|
C++
|
Source/USemLog/Private/ROSProlog/SLROSServiceClient.cpp
|
Leusmann/USemLog
|
3492a4fd55a524433785802c77444982e57f2e0a
|
[
"BSD-3-Clause"
] | 7
|
2017-10-05T09:47:40.000Z
|
2020-10-15T04:02:07.000Z
|
Source/USemLog/Private/ROSProlog/SLROSServiceClient.cpp
|
Leusmann/USemLog
|
3492a4fd55a524433785802c77444982e57f2e0a
|
[
"BSD-3-Clause"
] | 11
|
2017-08-10T10:01:55.000Z
|
2020-12-31T13:02:33.000Z
|
Source/USemLog/Private/ROSProlog/SLROSServiceClient.cpp
|
Leusmann/USemLog
|
3492a4fd55a524433785802c77444982e57f2e0a
|
[
"BSD-3-Clause"
] | 19
|
2017-03-07T08:18:43.000Z
|
2021-11-09T10:58:04.000Z
|
// Copyright 2020, Institute for Artificial Intelligence - University of Bremen
// Author: Jose Rojas
#include "ROSProlog/SLROSServiceClient.h"
#include "ROSProlog/SLPrologClient.h"
// Constructor
SLROSServiceClient::SLROSServiceClient()
{
}
// Destructor
SLROSServiceClient::~SLROSServiceClient()
{
}
#if SL_WITH_ROSBRIDGE
// Init constructor
SLROSServiceClient::SLROSServiceClient(UObject *InOwner, FString InName, FString InType)
{
Owner = InOwner;
Name = InName;
Type = InType;
}
// Callback to ProcessResponse in owner
void SLROSServiceClient::Callback(TSharedPtr<FROSBridgeSrv::SrvResponse> InResponse)
{
USLPrologClient *Logger = Cast<USLPrologClient>(Owner);
Logger->ProcessResponse(InResponse, Type);
}
#endif
| 22.090909
| 88
| 0.784636
|
Leusmann
|
b7d80910df3a3500ed9e6b8c74b25b38b73214ec
| 2,465
|
cpp
|
C++
|
node_modules/pxt-common-packages/libs/core/spi.cpp
|
johnwing/music2
|
a8940cd3e53061d7ca0461811f9ffb2440b586a1
|
[
"MIT"
] | null | null | null |
node_modules/pxt-common-packages/libs/core/spi.cpp
|
johnwing/music2
|
a8940cd3e53061d7ca0461811f9ffb2440b586a1
|
[
"MIT"
] | null | null | null |
node_modules/pxt-common-packages/libs/core/spi.cpp
|
johnwing/music2
|
a8940cd3e53061d7ca0461811f9ffb2440b586a1
|
[
"MIT"
] | null | null | null |
#include "pxt.h"
#include "ErrorNo.h"
namespace pins {
class CodalSPIProxy {
private:
DevicePin* mosi;
DevicePin* miso;
DevicePin* sck;
CODAL_SPI spi;
public:
CodalSPIProxy* next;
public:
CodalSPIProxy(DevicePin* _mosi, DevicePin* _miso, DevicePin* _sck)
: mosi(_mosi)
, miso(_miso)
, sck(_sck)
, spi(*_mosi, *_miso, *_sck)
, next(NULL)
{
}
CODAL_SPI* getSPI() {
return &spi;
}
bool matchPins(DevicePin* mosi, DevicePin* miso, DevicePin* sck) {
return this->mosi == mosi && this->miso == miso && this->sck == sck;
}
int write(int value) {
return spi.write(value);
}
void transfer(Buffer command, Buffer response) {
auto cdata = NULL == command ? NULL : command->data;
auto clength = NULL == command ? 0 : command->length;
auto rdata = NULL == response ? NULL : response->data;
auto rlength = NULL == response ? 0 : response->length;
spi.transfer(cdata, clength, rdata, rlength);
}
void setFrequency(int frequency) {
spi.setFrequency(frequency);
}
void setMode(int mode) {
spi.setMode(mode);
}
};
SPI_ spis(NULL);
/**
* Opens a SPI driver
*/
//% help=pins/create-spi
//% parts=spi
SPI_ createSPI(DigitalInOutPin mosiPin, DigitalInOutPin misoPin, DigitalInOutPin sckPin) {
auto dev = spis;
while(dev) {
if (dev->matchPins(mosiPin, misoPin, sckPin))
return dev;
dev = dev->next;
}
auto ser = new CodalSPIProxy(mosiPin, misoPin, sckPin);
ser->next = spis;
spis = ser;
return ser;
}
}
namespace pxt {
CODAL_SPI* getSPI(DigitalInOutPin mosiPin, DigitalInOutPin misoPin, DigitalInOutPin sckPin) {
auto spi = pins::createSPI(mosiPin, misoPin, sckPin);
return spi->getSPI();
}
}
namespace SPIMethods {
/**
* Write to the SPI bus
*/
//%
int write(SPI_ device, int value) {
return device->write(value);
}
/**
* Transfer buffers over the SPI bus
*/
//% argsNullable
void transfer(SPI_ device, Buffer command, Buffer response) {
if (!device)
target_panic(PANIC_CAST_FROM_NULL);
if (!command && !response)
return;
device->transfer(command, response);
}
/**
* Sets the SPI clock frequency
*/
//%
void setFrequency(SPI_ device, int frequency) {
device->setFrequency(frequency);
}
/**
* Sets the SPI bus mode
*/
//%
void setMode(SPI_ device, int mode) {
device->setMode(mode);
}
}
| 19.72
| 93
| 0.622718
|
johnwing
|
b7dad7284b176e251ba382227bed98e79260bec6
| 106
|
hpp
|
C++
|
fft/ft_grid_helpers.hpp
|
simonpp/2dRidgeletBTE
|
5d08cbb5c57fc276c7a528f128615d23c37ef6a0
|
[
"BSD-3-Clause"
] | 1
|
2019-11-08T03:15:56.000Z
|
2019-11-08T03:15:56.000Z
|
fft/ft_grid_helpers.hpp
|
simonpp/2dRidgeletBTE
|
5d08cbb5c57fc276c7a528f128615d23c37ef6a0
|
[
"BSD-3-Clause"
] | null | null | null |
fft/ft_grid_helpers.hpp
|
simonpp/2dRidgeletBTE
|
5d08cbb5c57fc276c7a528f128615d23c37ef6a0
|
[
"BSD-3-Clause"
] | 1
|
2019-11-08T03:15:56.000Z
|
2019-11-08T03:15:56.000Z
|
#pragma once
#include "ft_grid_helpers_impl/fourier_modes.hpp"
#include "ft_grid_helpers_impl/ftcut.hpp"
| 21.2
| 49
| 0.830189
|
simonpp
|
b7e878d6e6a49c3035795f494392cce1e16853c1
| 1,128
|
cpp
|
C++
|
Build/src/src/Scene/Courier.cpp
|
maz8569/OpenGLPAG
|
3c470a6824c0d3169fdc65691f697c2af39a6442
|
[
"MIT"
] | null | null | null |
Build/src/src/Scene/Courier.cpp
|
maz8569/OpenGLPAG
|
3c470a6824c0d3169fdc65691f697c2af39a6442
|
[
"MIT"
] | null | null | null |
Build/src/src/Scene/Courier.cpp
|
maz8569/OpenGLPAG
|
3c470a6824c0d3169fdc65691f697c2af39a6442
|
[
"MIT"
] | null | null | null |
#include "Scene/Courier.h"
GameEngine::Courier::Courier(Ref<MousePicker> mousePicker, Ref<Model> model, std::shared_ptr<Shader> shader, std::shared_ptr<Collision> colMan)
: Entity(model, shader, colMan), m_mousePicker(mousePicker)
{
m_inputManager = mousePicker->getInputManager();
Entity::Update();
}
void GameEngine::Courier::render()
{
Entity::render();
}
void GameEngine::Courier::Update()
{
//if (get_transform().m_position.y > 10 || get_transform().m_position.y < -10)
//speed *= -1;
//get_transform().m_position.y += 0.01 * speed;
//update(get_parent()->get_transform(), true);
if (m_inputManager->m_isRclicked)
{
glm::vec3 start = m_mousePicker->getCameraPos();
glm::vec3 dir = m_mousePicker->getCurrentRay();
//std::cout << dir.x << " " << dir.y << " " << dir.z << " " << std::endl;
glm::vec3 end = dir *40.f + start;
get_transform().m_position = end;
update(get_parent()->get_transform(), true);
//std::cout << end.x << " " << end.y << " " << end.z << " " << std::endl;
}
Entity::Update();
}
void GameEngine::Courier::reactOnCollision(GObject* other)
{
//std::cout << "end";
}
| 24.521739
| 144
| 0.646277
|
maz8569
|
b7eac2e350570f6a4631b596fd22d2f531d58abc
| 3,280
|
hpp
|
C++
|
include/wiztk/gui/theme.hpp
|
wiztk/framework
|
179baf8a24406b19d3f4ea28e8405358b21f8446
|
[
"Apache-2.0"
] | 37
|
2017-11-22T14:15:33.000Z
|
2021-11-25T20:39:39.000Z
|
include/wiztk/gui/theme.hpp
|
wiztk/framework
|
179baf8a24406b19d3f4ea28e8405358b21f8446
|
[
"Apache-2.0"
] | 3
|
2018-03-01T12:44:22.000Z
|
2021-01-04T23:14:41.000Z
|
include/wiztk/gui/theme.hpp
|
wiztk/framework
|
179baf8a24406b19d3f4ea28e8405358b21f8446
|
[
"Apache-2.0"
] | 10
|
2017-11-25T19:09:11.000Z
|
2020-12-02T02:05:47.000Z
|
/*
* Copyright 2017 - 2018 The WizTK 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.
*/
#ifndef WIZTK_GUI_THEME_HPP_
#define WIZTK_GUI_THEME_HPP_
#include "wiztk/base/color.hpp"
#include "wiztk/base/thickness.hpp"
#include "wiztk/base/point.hpp"
#include "wiztk/graphics/shader.hpp"
#include "wiztk/graphics/font.hpp"
#include "wiztk/graphics/pixmap.hpp"
#include <vector>
#include <string>
class SkPixmap;
namespace wiztk {
namespace gui {
typedef void *(*ThemeCreateHandle)();
typedef void(*ThemeDestroyHandle)(void *p);
/**
* @ingroup gui
* @brief The global theme manager
*/
class WIZTK_EXPORT Theme {
friend class Application;
public:
using ColorF = base::ColorF;
using Margin = base::ThicknessI;
Theme(const Theme &) = delete;
Theme &operator=(const Theme &) = delete;
struct Schema {
struct Style {
ColorF foreground;
ColorF background;
ColorF outline;
};
Schema() {
active.foreground = 0xFF000000; // black
active.background = 0xFFFFFFFF; // white
active.outline = 0xFF000000; // black
inactive = active;
highlight = active;
}
~Schema() = default;
// TODO: use image
Style active;
Style inactive;
Style highlight;
};
struct Data {
Data();
std::string name;
Schema window;
Schema title_bar;
graphics::Font title_bar_font;
Schema button;
graphics::Font default_font;
};
static void Load(const char *name = nullptr);
static inline int GetShadowRadius() {
return kShadowRadius;
}
static inline int GetShadowOffsetX() {
return kShadowOffsetX;
}
static inline int GetShadowOffsetY() {
return kShadowOffsetY;
}
static inline const Margin &GetShadowMargin() {
return kShadowMargin;
}
static inline const graphics::Pixmap *GetShadowPixmap() {
return kShadowPixmap;
}
static const int kShadowImageWidth = 250;
static const int kShadowImageHeight = 250;
static const Data &GetData() { return kTheme->data_; }
protected:
Theme();
virtual ~Theme();
Data &data() { return data_; }
private:
/**
* @brief Initialize static properties
*
* This method is called only in Application
*/
static void Initialize();
/**
* @brief Release the memory allocated for theme
*
* This method is called only in Application
*/
static void Release();
static void GenerateShadowImage();
static int kShadowRadius;
static int kShadowOffsetX;
static int kShadowOffsetY;
static Margin kShadowMargin;
static std::vector<uint32_t> kShadowPixels;
static graphics::Pixmap *kShadowPixmap;
static Theme *kTheme;
Data data_;
};
} // namespace gui
} // namespace wiztk
#endif // WIZTK_GUI_THEME_HPP_
| 18.531073
| 75
| 0.68689
|
wiztk
|
b7ee91b261ce90ea20e87d53e1ddee4b85c6cebb
| 911
|
cpp
|
C++
|
src/mxml/parsing/BackupHandler.cpp
|
dkun7944/mxml
|
6450e7cab88eb6ee0ac469f437047072e1868ea4
|
[
"MIT"
] | 18
|
2016-05-22T00:55:28.000Z
|
2021-03-29T08:44:23.000Z
|
src/mxml/parsing/BackupHandler.cpp
|
dkun7944/mxml
|
6450e7cab88eb6ee0ac469f437047072e1868ea4
|
[
"MIT"
] | 6
|
2017-05-17T13:20:09.000Z
|
2018-10-22T20:00:57.000Z
|
src/mxml/parsing/BackupHandler.cpp
|
dkun7944/mxml
|
6450e7cab88eb6ee0ac469f437047072e1868ea4
|
[
"MIT"
] | 14
|
2016-05-12T22:54:34.000Z
|
2021-10-19T12:43:16.000Z
|
// Copyright © 2016 Venture Media Labs.
//
// This file is part of mxml. The full mxml copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.
#include "BackupHandler.h"
namespace mxml {
using dom::Backup;
using lxml::QName;
static const char* kDurationTag = "duration";
void BackupHandler::startElement(const QName& qname, const AttributeMap& attributes) {
_result.reset(new Backup());
}
lxml::RecursiveHandler* BackupHandler::startSubElement(const QName& qname) {
if (strcmp(qname.localName(), kDurationTag) == 0)
return &_integerHandler;
return 0;
}
void BackupHandler::endSubElement(const QName& qname, RecursiveHandler* parser) {
if (strcmp(qname.localName(), kDurationTag) == 0)
_result->setDuration(_integerHandler.result());
}
} // namespace mxml
| 28.46875
| 86
| 0.731065
|
dkun7944
|
b7f3356d2e71d6734f46b3d88fcccf7bcd40ff47
| 287
|
cpp
|
C++
|
framework/src/Core/Network/Tcp/TcpClient.cpp
|
gautier-lefebvre/cppframework
|
bc1c3405913343274d79240b17ab75ae3f2adf56
|
[
"MIT"
] | null | null | null |
framework/src/Core/Network/Tcp/TcpClient.cpp
|
gautier-lefebvre/cppframework
|
bc1c3405913343274d79240b17ab75ae3f2adf56
|
[
"MIT"
] | 3
|
2015-12-21T09:04:49.000Z
|
2015-12-21T19:22:47.000Z
|
framework/src/Core/Network/Tcp/TcpClient.cpp
|
gautier-lefebvre/cppframework
|
bc1c3405913343274d79240b17ab75ae3f2adf56
|
[
"MIT"
] | null | null | null |
#include "Core/Network/Tcp/TcpClient.hh"
using namespace fwk;
TcpClient::TcpClient(const std::string& hostname, uint16_t port, TcpSocketStream* socket):
Lockable(),
hostname(hostname),
port(port),
socket(socket),
active(false),
events()
{}
TcpClient::~TcpClient(void) {}
| 19.133333
| 90
| 0.714286
|
gautier-lefebvre
|
b7f4b488d5a57aa67fba4e99201a3bf0ded49aab
| 1,650
|
cpp
|
C++
|
potrace/src/ossimPotraceToolFactory.cpp
|
dardok/ossim-plugins
|
3406ffed9fcab88fe4175b845381611ac4122c81
|
[
"MIT"
] | 12
|
2016-09-09T01:24:12.000Z
|
2022-01-09T21:45:58.000Z
|
potrace/src/ossimPotraceToolFactory.cpp
|
dardok/ossim-plugins
|
3406ffed9fcab88fe4175b845381611ac4122c81
|
[
"MIT"
] | 5
|
2016-02-04T16:10:40.000Z
|
2021-06-29T05:00:29.000Z
|
potrace/src/ossimPotraceToolFactory.cpp
|
dardok/ossim-plugins
|
3406ffed9fcab88fe4175b845381611ac4122c81
|
[
"MIT"
] | 20
|
2015-11-17T11:46:22.000Z
|
2021-11-12T19:23:54.000Z
|
//**************************************************************************************************
//
// OSSIM Open Source Geospatial Data Processing Library
// See top level LICENSE.txt file for license information
//
//**************************************************************************************************
#include <ossim/util/ossimToolRegistry.h>
#include <potrace/src/ossimPotraceTool.h>
#include <potrace/src/ossimPotraceToolFactory.h>
using namespace std;
ossimPotraceToolFactory* ossimPotraceToolFactory::s_instance = 0;
ossimPotraceToolFactory* ossimPotraceToolFactory::instance()
{
if (!s_instance)
s_instance = new ossimPotraceToolFactory;
return s_instance;
}
ossimPotraceToolFactory::ossimPotraceToolFactory()
{
}
ossimPotraceToolFactory::~ossimPotraceToolFactory()
{
ossimToolRegistry::instance()->unregisterFactory(this);
}
ossimTool* ossimPotraceToolFactory::createTool(const std::string& argName) const
{
ossimString utilName (argName);
utilName.downcase();
if ((utilName == "potrace") || (argName == "ossimPotraceTool"))
return new ossimPotraceTool;
return 0;
}
void ossimPotraceToolFactory::getCapabilities(std::map<std::string, std::string>& capabilities) const
{
capabilities.insert(pair<string, string>("potrace", ossimPotraceTool::DESCRIPTION));
}
std::map<std::string, std::string> ossimPotraceToolFactory::getCapabilities() const
{
std::map<std::string, std::string> result;
getCapabilities(result);
return result;
}
void ossimPotraceToolFactory::getTypeNameList(vector<ossimString>& typeList) const
{
typeList.push_back("ossimPotraceTool");
}
| 27.966102
| 101
| 0.666061
|
dardok
|
b7f5a6353f521eeca03324ef9ee2f41d8efe1c7a
| 2,578
|
cpp
|
C++
|
Practice/2018/2018.12.6/Luogu3835.cpp
|
SYCstudio/OI
|
6e9bfc17dbd4b43467af9b19aa2aed41e28972fa
|
[
"MIT"
] | 4
|
2017-10-31T14:25:18.000Z
|
2018-06-10T16:10:17.000Z
|
Practice/2018/2018.12.6/Luogu3835.cpp
|
SYCstudio/OI
|
6e9bfc17dbd4b43467af9b19aa2aed41e28972fa
|
[
"MIT"
] | null | null | null |
Practice/2018/2018.12.6/Luogu3835.cpp
|
SYCstudio/OI
|
6e9bfc17dbd4b43467af9b19aa2aed41e28972fa
|
[
"MIT"
] | null | null | null |
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define mem(Arr,x) memset(Arr,x,sizeof(Arr))
const int maxN=505000*50;
const int inf=2147483647;
class Treap
{
public:
int key,size,ch[2];
};
int nodecnt;
Treap T[maxN];
int root[maxN];
int random(int l,int r);
int Newnode(int key);
int Copynode(int id);
void Init();
void Update(int x);
void Split(int now,int k,int &x,int &y);
int Merge(int x,int y);
int main(){
freopen("td.in","r",stdin);
srand(20010622);
int TTT;scanf("%d",&TTT);
Init();
for (int ti=1;ti<=TTT;ti++){
int vi,opt,key;scanf("%d%d%d",&vi,&opt,&key);
if (opt==1){
int x,y;Split(root[vi],key,x,y);
int z=Newnode(key);
root[ti]=Merge(Merge(x,z),y);
}
if (opt==2){
int x,y,z;Split(root[vi],key,x,z);
Split(x,key-1,x,y);
root[ti]=Merge(Merge(x,Merge(T[y].ch[0],T[y].ch[1])),z);
}
if (opt==3){
int x,y;Split(root[vi],key-1,x,y);
printf("%d\n",T[x].size);
root[ti]=Merge(x,y);
}
if (opt==4){
int now=root[vi];++key;
do{
if (T[T[now].ch[0]].size>=key) now=T[now].ch[0];
else if (T[T[now].ch[0]].size+1==key) break;
else key-=T[T[now].ch[0]].size+1,now=T[now].ch[1];
}
while (1);
printf("%d\n",T[now].key);
root[ti]=root[vi];
}
if (opt==5){
int x,y;Split(root[vi],key-1,x,y);
int now=x;while (T[now].ch[1]) now=T[now].ch[1];
printf("%d\n",T[now].key);root[ti]=Merge(x,y);
}
if (opt==6){
int x,y;Split(root[vi],key,x,y);
int now=y;while (T[now].ch[0]) now=T[now].ch[0];
printf("%d\n",T[now].key);root[ti]=Merge(x,y);
}
}
return 0;
}
int random(int l,int r){
double dou=1.0*rand()/RAND_MAX;
return min(r,(int)(dou*(r-l+1))+l);
}
int Newnode(int key){
int id=++nodecnt;
T[id].ch[0]=T[id].ch[1]=0;T[id].size=1;
T[id].key=key;return id;
}
int Copynode(int id){
T[++nodecnt]=T[id];return nodecnt;
}
void Init(){
int x=Newnode(-2147483647),y=Newnode(2147483647);
root[0]=x;T[x].ch[1]=y;Update(x);return;
}
void Update(int x){
T[x].size=T[T[x].ch[0]].size+T[T[x].ch[1]].size+1;
return;
}
void Split(int now,int k,int &x,int &y){
if (now==0){
x=y=0;return;
}
if (T[now].key<=k){
x=Copynode(now);Split(T[now].ch[1],k,T[x].ch[1],y);Update(x);
}
else{
y=Copynode(now);Split(T[now].ch[0],k,x,T[y].ch[0]);Update(y);
}
return;
}
int Merge(int x,int y){
if ((x==0)||(y==0)) return x+y;
int z;
if (random(1,T[x].size+T[y].size)<=T[x].size){
z=x;T[z].ch[1]=Merge(T[x].ch[1],y);
}
else{
z=y;T[z].ch[0]=Merge(x,T[y].ch[0]);
}
Update(z);return z;
}
| 20.140625
| 63
| 0.579131
|
SYCstudio
|
b7f66fd8067cc2de00df33f7a1c7dc50d7ca966a
| 5,096
|
cpp
|
C++
|
RX64M/rx64m_DA_sample/main.cpp
|
hirakuni45/RX
|
3fb91bfc8d5282cde7aa00b8bd37f4aad32582d0
|
[
"BSD-3-Clause"
] | 56
|
2015-06-04T14:15:38.000Z
|
2022-03-01T22:58:49.000Z
|
RX64M/rx64m_DA_sample/main.cpp
|
hirakuni45/RX
|
3fb91bfc8d5282cde7aa00b8bd37f4aad32582d0
|
[
"BSD-3-Clause"
] | 30
|
2019-07-27T11:03:14.000Z
|
2021-12-14T09:59:57.000Z
|
RX64M/rx64m_DA_sample/main.cpp
|
hirakuni45/RX
|
3fb91bfc8d5282cde7aa00b8bd37f4aad32582d0
|
[
"BSD-3-Clause"
] | 15
|
2017-06-24T11:33:39.000Z
|
2021-12-07T07:26:58.000Z
|
//=====================================================================//
/*! @file
@brief RX64M D/A 出力サンプル @n
・P07(176) ピンに赤色LED(VF:1.9V)を吸い込みで接続する。@n
・DA0(P03)、DA1(P05) からアナログ出力する。@n
・サンプリング間隔は 48KHz @n
・コンソールから、周波数を入力すると、その周波数で sin/cos @n
を出力する。
@author 平松邦仁 (hira@rvf-rc45.net)
@copyright Copyright (C) 2018 Kunihito Hiramatsu @n
Released under the MIT license @n
https://github.com/hirakuni45/RX/blob/master/LICENSE
*/
//=====================================================================//
#include "common/renesas.hpp"
#include "common/sci_io.hpp"
#include "common/cmt_mgr.hpp"
#include "common/fixed_fifo.hpp"
#include "common/format.hpp"
#include "common/input.hpp"
#include "common/delay.hpp"
#include "common/command.hpp"
#include "common/tpu_io.hpp"
#include "common/intmath.hpp"
// ソフトウェアー(タイマー割り込みタスク)で転送を行う場合に有効にする。
// ※無効にした場合、DMA転送で行われる。
// #define SOFT_TRANS
namespace {
typedef device::PORT<device::PORT0, device::bitpos::B7> LED;
typedef device::cmt_mgr<device::CMT0> CMT;
CMT cmt_;
typedef utils::fixed_fifo<char, 128> BUFFER;
typedef device::sci_io<device::SCI1, BUFFER, BUFFER> SCI;
SCI sci_;
utils::command<256> cmd_;
/// DMAC 終了割り込み
class dmac_term_task {
volatile uint32_t count_;
public:
dmac_term_task() : count_(0) { }
void operator() () {
// DMA を再スタート
device::DMAC0::DMCNT.DTE = 1; // DMA 再開
++count_;
}
uint32_t get_count() const { return count_; }
};
typedef device::dmac_mgr<device::DMAC0, dmac_term_task> DMAC_MGR;
DMAC_MGR dmac_mgr_;
typedef device::R12DA DAC;
typedef device::dac_out<DAC> DAC_OUT;
DAC_OUT dac_out_;
struct wave_t {
uint16_t l; ///< D/A CH0
uint16_t r; ///< D/A CH1
};
static const uint32_t WAVE_NUM = 1024;
wave_t wave_[WAVE_NUM];
// 48KHz サンプリング割り込み
class timer_task {
uint16_t pos_;
public:
timer_task() : pos_(0) { }
void operator() () {
const wave_t& w = wave_[pos_];
dac_out_.out0(w.l);
dac_out_.out1(w.r);
++pos_;
pos_ %= WAVE_NUM;
}
uint16_t get_pos() const { return pos_; }
};
#ifdef SOFT_TRANS
typedef device::tpu_io<device::TPU0, timer_task> TPU0;
#else
typedef device::tpu_io<device::TPU0, utils::null_task> TPU0;
#endif
TPU0 tpu0_;
bool init_ = false;
float freq_ = 100.0f;
uint32_t wpos_ = 0;
intmath::sincos_t sico_(0);
void service_sin_cos_()
{
uint32_t pos = (dmac_mgr_.get_count() & 0x3ff) ^ 0x3ff;
int32_t gain_shift = 16;
if(!init_) {
sico_.x = static_cast<int64_t>(32767) << gain_shift;
sico_.y = 0;
wpos_ = pos & 0x3ff;
init_ = true;
}
int32_t dt = static_cast<int32_t>(48000.0f / freq_);
uint32_t d = pos - wpos_;
if(d >= WAVE_NUM) d += WAVE_NUM;
for(uint32_t i = 0; i < d; ++i) {
wave_t w;
w.l = (sico_.x >> gain_shift) + 32768;
w.r = (sico_.y >> gain_shift) + 32768;
wave_[(wpos_ + (WAVE_NUM / 2)) & (WAVE_NUM - 1)] = w;
++wpos_;
wpos_ &= WAVE_NUM - 1;
intmath::build_sincos(sico_, dt);
}
}
}
extern "C" {
void sci_putch(char ch)
{
sci_.putch(ch);
}
char sci_getch(void)
{
return sci_.getch();
}
void sci_puts(const char *str)
{
sci_.puts(str);
}
uint16_t sci_length(void)
{
return sci_.recv_length();
}
}
int main(int argc, char** argv);
int main(int argc, char** argv)
{
device::system_io<>::boost_master_clock();
{ // タイマー設定(100Hz)
uint8_t intr_level = 4;
cmt_.start(100, intr_level);
}
{ // SCI 設定
uint8_t intr_level = 2;
sci_.start(115200, intr_level);
}
{ // サンプリング・タイマー設定
uint8_t intr_level = 5;
if(!tpu0_.start(48000, intr_level)) {
utils::format("TPU0 start error...\n");
}
}
{ // 内臓12ビット D/A の設定
bool amp_ena = true;
dac_out_.start(DAC_OUT::output::CH0_CH1, amp_ena);
dac_out_.out0(32767);
dac_out_.out1(32767);
#if 0
int32_t gain_shift = 16;
intmath::sincos_t sico(static_cast<int64_t>(32767) << gain_shift);
for(uint32_t i = 0; i < WAVE_NUM; ++i) {
wave_t w;
#if 0
if(i & 1) {
w.l = 0xffff;
w.r = 0x0000;
} else {
w.l = 0x0000;
w.r = 0xffff;
}
#else
w.l = (sico.x >> gain_shift) + 32768;
w.r = (sico.y >> gain_shift) + 32768;
intmath::build_sincos(sico, WAVE_NUM / 4);
#endif
wave_[i] = w;
}
#endif
}
#ifndef SOFT_TRANS
{ // DMAC マネージャー開始
uint8_t intr_level = 4;
bool cpu_intr = true;
auto ret = dmac_mgr_.start(tpu0_.get_intr_vec(), DMAC_MGR::trans_type::SP_DN_32,
reinterpret_cast<uint32_t>(wave_), DAC::DADR0.address(), WAVE_NUM, intr_level, cpu_intr);
if(!ret) {
utils::format("DMAC Not start...\n");
}
}
#endif
utils::format("RX64M Internal D/A stream sample start\n");
cmd_.set_prompt("# ");
LED::DIR = 1;
uint32_t cnt = 0;
while(1) {
cmt_.sync();
service_sin_cos_();
// uint32_t pos = dmac_mgr_.get_count() & 0x3ff;
// utils::format("WP: %d\n") % pos;
if(cmd_.service()) {
char tmp[32];
if(cmd_.get_word(0, tmp, sizeof(tmp))) {
float freq = 0.0f;
if((utils::input("%f", tmp) % freq).status()) {
freq_ = freq;
init_ = false;
}
}
}
++cnt;
if(cnt >= 30) {
cnt = 0;
}
LED::P = (cnt < 10) ? 0 : 1;
}
}
| 20.465863
| 92
| 0.616366
|
hirakuni45
|
b7fa247532e41f32d46e4fe210c23a69688f4f49
| 6,175
|
cc
|
C++
|
libmemcached/touch.cc
|
bureado/libmemcached
|
3f27e2b935a0580ff3fa7c098040ce96083fa70f
|
[
"BSD-3-Clause"
] | null | null | null |
libmemcached/touch.cc
|
bureado/libmemcached
|
3f27e2b935a0580ff3fa7c098040ce96083fa70f
|
[
"BSD-3-Clause"
] | 1
|
2021-03-09T05:01:19.000Z
|
2021-03-09T05:01:19.000Z
|
libmemcached/touch.cc
|
bureado/libmemcached
|
3f27e2b935a0580ff3fa7c098040ce96083fa70f
|
[
"BSD-3-Clause"
] | 2
|
2015-02-03T02:37:59.000Z
|
2020-10-20T09:12:02.000Z
|
/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
*
* Libmemcached library
*
* Copyright (C) 2011 Data Differential, http://datadifferential.com/
* Copyright (C) 2006-2009 Brian Aker 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.
*
* * The names of its contributors may not be used to endorse or
* promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <libmemcached/common.h>
#include <libmemcached/memcached/protocol_binary.h>
static memcached_return_t ascii_touch(memcached_server_write_instance_st instance,
const char *key, size_t key_length,
time_t expiration)
{
char expiration_buffer[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1];
int expiration_buffer_length= snprintf(expiration_buffer, sizeof(expiration_buffer), " %llu", (unsigned long long)expiration);
if (size_t(expiration_buffer_length) >= sizeof(expiration_buffer) or expiration_buffer_length < 0)
{
return memcached_set_error(*instance, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT,
memcached_literal_param("snprintf(MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH)"));
}
libmemcached_io_vector_st vector[]=
{
{ NULL, 0 },
{ memcached_literal_param("touch ") },
{ memcached_array_string(instance->root->_namespace), memcached_array_size(instance->root->_namespace) },
{ key, key_length },
{ expiration_buffer, expiration_buffer_length },
{ memcached_literal_param("\r\n") }
};
memcached_return_t rc;
if (memcached_failed(rc= memcached_vdo(instance, vector, 6, true)))
{
memcached_io_reset(instance);
return memcached_set_error(*instance, MEMCACHED_WRITE_FAILURE, MEMCACHED_AT);
}
return rc;
}
static memcached_return_t binary_touch(memcached_server_write_instance_st instance,
const char *key, size_t key_length,
time_t expiration)
{
protocol_binary_request_touch request= {}; //{.bytes= {0}};
request.message.header.request.magic= PROTOCOL_BINARY_REQ;
request.message.header.request.opcode= PROTOCOL_BINARY_CMD_TOUCH;
request.message.header.request.extlen= 4;
request.message.header.request.keylen= htons((uint16_t)(key_length +memcached_array_size(instance->root->_namespace)));
request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
request.message.header.request.bodylen= htonl((uint32_t)(key_length +memcached_array_size(instance->root->_namespace) +request.message.header.request.extlen));
request.message.body.expiration= htonl((uint32_t) expiration);
libmemcached_io_vector_st vector[]=
{
{ NULL, 0 },
{ request.bytes, sizeof(request.bytes) },
{ memcached_array_string(instance->root->_namespace), memcached_array_size(instance->root->_namespace) },
{ key, key_length }
};
memcached_return_t rc;
if (memcached_failed(rc= memcached_vdo(instance, vector, 4, true)))
{
memcached_io_reset(instance);
return memcached_set_error(*instance, MEMCACHED_WRITE_FAILURE, MEMCACHED_AT);
}
return rc;
}
memcached_return_t memcached_touch(memcached_st *ptr,
const char *key, size_t key_length,
time_t expiration)
{
return memcached_touch_by_key(ptr, key, key_length, key, key_length, expiration);
}
memcached_return_t memcached_touch_by_key(memcached_st *ptr,
const char *group_key, size_t group_key_length,
const char *key, size_t key_length,
time_t expiration)
{
LIBMEMCACHED_MEMCACHED_TOUCH_START();
memcached_return_t rc;
if (memcached_failed(rc= initialize_query(ptr, true)))
{
return rc;
}
if (memcached_failed(rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol)))
{
return rc;
}
uint32_t server_key= memcached_generate_hash_with_redistribution(ptr, group_key, group_key_length);
memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, server_key);
if (ptr->flags.binary_protocol)
{
rc= binary_touch(instance, key, key_length, expiration);
}
else
{
rc= ascii_touch(instance, key, key_length, expiration);
}
if (memcached_failed(rc))
{
return memcached_set_error(*instance, rc, MEMCACHED_AT, memcached_literal_param("Error occcured while writing touch command to server"));
}
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
rc= memcached_response(instance, buffer, sizeof(buffer), NULL);
if (rc == MEMCACHED_SUCCESS or rc == MEMCACHED_NOTFOUND)
{
return rc;
}
return memcached_set_error(*instance, rc, MEMCACHED_AT, memcached_literal_param("Error occcured while reading response"));
}
| 39.583333
| 161
| 0.717733
|
bureado
|
b7fbc13163bcf254debfd31d029e3753edf16856
| 1,161
|
hpp
|
C++
|
include/States/SaveState.hpp
|
thibautcornolti/IndieStudio
|
1d0b76b1ca7b4e35b7c9d251fdb3f7ff96debfd7
|
[
"MIT"
] | null | null | null |
include/States/SaveState.hpp
|
thibautcornolti/IndieStudio
|
1d0b76b1ca7b4e35b7c9d251fdb3f7ff96debfd7
|
[
"MIT"
] | null | null | null |
include/States/SaveState.hpp
|
thibautcornolti/IndieStudio
|
1d0b76b1ca7b4e35b7c9d251fdb3f7ff96debfd7
|
[
"MIT"
] | null | null | null |
/*
** EPITECH PROJECT, 2018
** bomberman
** File description:
** SaveState.hpp
*/
#ifndef BOMBERMAN_SAVESTATE_HPP
#define BOMBERMAN_SAVESTATE_HPP
#include <time.h>
#include "../Abstracts/AState.hpp"
#include "../Abstracts/AMenuSound.hpp"
#define SAVE_BUTTON_NUMBER 2
class SaveState : public AState, public AMenuSound {
public:
explicit SaveState(AStateShare &_share);
~SaveState();
enum Actions {
SAVE = 800,
CANCEL
};
const std::string getName() const override;
void loadButtons();
void unloadButtons();
void load() override;
void unload() override;
void update() override;
void draw() override;
bool applyEventButton(const irr::SEvent &ev, SaveState::Actions id);
irr::gui::IGUIButton *getButton(SaveState::Actions) const;
struct ButtonsDesc {
irr::core::rect<irr::s32> pos;
std::string name;
std::function<bool(SaveState *)> fct;
};
void eventsSetup();
void eventsClean();
void externalEventsClean();
private:
std::vector<irr::gui::IGUIButton *> _buttons;
static const std::map<SaveState::Actions, ButtonsDesc> _descs;
irr::gui::IGUIButton *_name;
bool _eventsActivate;
};
#endif /* !BOMBERMAN_SAVESTATE_HPP */
| 19.677966
| 69
| 0.723514
|
thibautcornolti
|
b7fcce7a23b53ad27b52bffb490cfaeac7acb822
| 1,400
|
cpp
|
C++
|
PAT_B/B1055|集体照|e.g.cpp
|
FunamiYui/PAT_Code_Akari
|
52e06689b6bf8177c43ab9256719258c47e80b25
|
[
"MIT"
] | null | null | null |
PAT_B/B1055|集体照|e.g.cpp
|
FunamiYui/PAT_Code_Akari
|
52e06689b6bf8177c43ab9256719258c47e80b25
|
[
"MIT"
] | null | null | null |
PAT_B/B1055|集体照|e.g.cpp
|
FunamiYui/PAT_Code_Akari
|
52e06689b6bf8177c43ab9256719258c47e80b25
|
[
"MIT"
] | null | null | null |
//example
//对于某一排来说,每次都是左右交替进行人的放置,因此按此排内部的序号来说一定是一侧奇数一侧偶数
//最后从后排往前排一依次输出每排的人的姓名
//将所有人按身高从高到低排序,身高相同时按照姓名字典序从小到大排序
//定义变量num表示当前排的人数,初值为n - (k - 1) * (n / k),即最后一排人数
//再定义变量leftPos表示该排身高最高的人在数组中的编号,于是该排所有人在数组中的编号范围是[leftPos, leftPos + num - 1]
//当处理完一排后,将leftPos加上num即可得到前一排身高最高的人在数组中的编号
//本题必须在最后一行输出换行,否则会有若干组数据"格式错误"
//姓名的数组大小至少需要开9
//本体也可以用双端队列解决,或是使用数组模拟双端队列来实现
//直接做法
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 10010;
struct Person {
char name[10]; //姓名
int height; //身高
} person[maxn];
bool cmp(Person a, Person b) { //先按身高从高到低,再按姓名字典序从小到大
if(a.height != b.height) return a.height > b.height;
else return strcmp(a.name, b.name) < 0;
}
int main() {
int n, k; //n为人数,k为排数
scanf("%d%d", &n, &k);
for(int i = 0; i < n; i++) { //输入每个人的姓名和身高
scanf("%s%d", person[i].name, &person[i].height);
}
sort(person, person + n, cmp); //排序
//num为当前排人数,leftPos为当前排的身高最高者的位置
int num = n - (k - 1) * (n / k), leftPos = 0;
while(leftPos < n) { //每次处理一排
for(int i = (num % 2) ? (num - 2) : (num - 1); i >= 1; i -= 2) {
printf("%s ", person[leftPos + i].name); //从最大奇数到最小奇数输出
}
for(int i = 0; i < num; i += 2) {
printf("%s", person[leftPos + i].name); //从最小偶数到最大偶数
if(i < num - 2) printf(" ");
else printf("\n"); //本题必须换行
}
leftPos += num; //前一排的身高最高者的位置
num = n / k; //除最后一排外,前面所有排的人数都是n / k
}
return 0;
}
| 27.45098
| 77
| 0.637857
|
FunamiYui
|
4d001073e89c0ca5b69ecdd0dc73a9c6bba32baf
| 1,318
|
cpp
|
C++
|
src/Core/Scripting/ScriptAssembly.cpp
|
lauriscx/DEngine
|
2e64c91f64715dd730f21f27355c3efa7faff85f
|
[
"MIT"
] | null | null | null |
src/Core/Scripting/ScriptAssembly.cpp
|
lauriscx/DEngine
|
2e64c91f64715dd730f21f27355c3efa7faff85f
|
[
"MIT"
] | null | null | null |
src/Core/Scripting/ScriptAssembly.cpp
|
lauriscx/DEngine
|
2e64c91f64715dd730f21f27355c3efa7faff85f
|
[
"MIT"
] | null | null | null |
#include "ScriptAssembly.h"
ScriptAssembly::ScriptAssembly(const std::string& Name, const std::string& AssemblyName) {
//Examples https://cpp.hotexamples.com/examples/-/-/mono_add_internal_call/cpp-mono_add_internal_call-function-examples.html
mono_set_dirs(".", ".");//Set where to search for assembly file.(Location is project file whihc is has kind application or console application(exe)).
m_AssemblyName = AssemblyName;
m_PtrMonoDomain = mono_jit_init(Name.c_str());//Unknow why here we neeed provide this string.
if (m_PtrMonoDomain) {
//Information which is usefull to implement load dll from VFS https://stackoverflow.com/questions/36094802/embeded-mono-load-assemblies-from-memory
m_PtrAssembly = mono_domain_assembly_open(m_PtrMonoDomain, (AssemblyName + std::string(".dll")).c_str());//In feature need change to us VFS
if (m_PtrAssembly) {
m_PtrAssemblyImage = mono_assembly_get_image(m_PtrAssembly);
}
}
}
Class * ScriptAssembly::GetClass(std::string className) {
if (m_PtrAssemblyImage) {
m_Classes[className] = Class(m_PtrAssemblyImage, className, m_AssemblyName);
return &m_Classes[className];
}
return nullptr;
}
ScriptAssembly::~ScriptAssembly() {
if (m_PtrMonoDomain) {
mono_jit_cleanup(m_PtrMonoDomain);//if used mono_jit_init need use mono_jit_clean (probably).
}
}
| 43.933333
| 150
| 0.773141
|
lauriscx
|
4d002074e04e0dc695f191346860b577a64b5373
| 964
|
hpp
|
C++
|
sdl2-sonic-drivers/src/drivers/midi/devices/ScummVM.hpp
|
Raffaello/sdl2-sonic-drivers
|
20584f100ddd7c61f584deaee0b46c5228d8509d
|
[
"Apache-2.0"
] | 3
|
2021-10-31T14:24:00.000Z
|
2022-03-16T08:15:31.000Z
|
sdl2-sonic-drivers/src/drivers/midi/devices/ScummVM.hpp
|
Raffaello/sdl2-sonic-drivers
|
20584f100ddd7c61f584deaee0b46c5228d8509d
|
[
"Apache-2.0"
] | 48
|
2020-06-05T11:11:29.000Z
|
2022-02-27T23:58:44.000Z
|
sdl2-sonic-drivers/src/drivers/midi/devices/ScummVM.hpp
|
Raffaello/sdl2-sonic-drivers
|
20584f100ddd7c61f584deaee0b46c5228d8509d
|
[
"Apache-2.0"
] | null | null | null |
#pragma once
#include <drivers/midi/Device.hpp>
#include <drivers/midi/scummvm/MidiDriver_ADLIB.hpp>
#include <memory>
#include <cstdint>
#include <hardware/opl/OPL.hpp>
namespace drivers
{
namespace midi
{
namespace devices
{
/**
* @brief Wrapper around ScummVM MidiDriver
* At the moment support only OPL
* Better rename to OPL?
*/
class ScummVM : public Device
{
public:
explicit ScummVM(std::shared_ptr<hardware::opl::OPL> opl, const bool opl3mode);
~ScummVM();
inline void sendEvent(const audio::midi::MIDIEvent& e) const noexcept override;
inline void sendMessage(const uint8_t msg[], const uint8_t size) const noexcept override;
private:
std::shared_ptr<drivers::midi::scummvm::MidiDriver_ADLIB> _adlib;
};
}
}
}
| 26.777778
| 105
| 0.570539
|
Raffaello
|
4d013bb873fed2521820894736d56ec8300f55e1
| 5,608
|
hpp
|
C++
|
src/math/TEuler.hpp
|
Tonvey/ceramics
|
9735b7579c7970155f4b72b9c8a55f920800f186
|
[
"MIT"
] | null | null | null |
src/math/TEuler.hpp
|
Tonvey/ceramics
|
9735b7579c7970155f4b72b9c8a55f920800f186
|
[
"MIT"
] | null | null | null |
src/math/TEuler.hpp
|
Tonvey/ceramics
|
9735b7579c7970155f4b72b9c8a55f920800f186
|
[
"MIT"
] | null | null | null |
#pragma once
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <initializer_list>
#include "../utils/TProperty.hpp"
#include "TMathUtils.hpp"
#include "../CeramicsPrerequisites.h"
#include "ERotationOrder.h"
CERAMICS_NAMESPACE_BEGIN
template <class T>
struct TEuler
{
typedef T value_type;
typedef TEuler<T> type;
static RotationOrder DefaultOrder;
T x, y, z;
RotationOrder order = XYZ;
TEuler(T x = 0, T y = 0, T z = 0, RotationOrder order = DefaultOrder)
{
this->x = x;
this->y = y;
this->z = z;
this->order = order;
}
void set(T x, T y, T z, RotationOrder order)
{
this->x = x;
this->y = y;
this->z = z;
this->order = order;
// TODO change callback
}
type &operator=(const type &other)
{
this->set(other.x, other.y, other.z, other.order);
return *this;
}
void setFromRotationMatrix(TMatrix<T, 4, 4> m, RotationOrder order = XYZ)
{
auto clamp = TMathUtils<T>::clamp;
// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
auto &te = m.elements;
auto m11 = te[0], m12 = te[1], m13 = te[2];
auto m21 = te[4], m22 = te[5], m23 = te[6];
auto m31 = te[8], m32 = te[9], m33 = te[10];
switch (order)
{
case RotationOrder::XYZ:
this->y = std::asin(clamp(m13, -1, 1));
if (std::abs(m13) < 0.9999999)
{
this->x = std::atan2(-m23, m33);
this->z = std::atan2(-m12, m11);
}
else
{
this->x = std::atan2(m32, m22);
this->z = 0;
}
break;
case RotationOrder::YXZ:
this->x = std::asin(-clamp(m23, -1, 1));
if (std::abs(m23) < 0.9999999)
{
this->y = std::atan2(m13, m33);
this->z = std::atan2(m21, m22);
}
else
{
this->y = std::atan2(-m31, m11);
this->z = 0;
}
break;
case RotationOrder::ZXY:
this->x = std::asin(clamp(m32, -1, 1));
if (std::abs(m32) < 0.9999999)
{
this->y = std::atan2(-m31, m33);
this->z = std::atan2(-m12, m22);
}
else
{
this->y = 0;
this->z = std::atan2(m21, m11);
}
break;
case RotationOrder::ZYX:
this->y = std::asin(-clamp(m31, -1, 1));
if (std::abs(m31) < 0.9999999)
{
this->x = std::atan2(m32, m33);
this->z = std::atan2(m21, m11);
}
else
{
this->x = 0;
this->z = std::atan2(-m12, m22);
}
break;
case RotationOrder::YZX:
this->z = std::asin(clamp(m21, -1, 1));
if (std::abs(m21) < 0.9999999)
{
this->x = std::atan2(-m23, m22);
this->y = std::atan2(-m31, m11);
}
else
{
this->x = 0;
this->y = std::atan2(m13, m33);
}
break;
case RotationOrder::XZY:
this->z = std::asin(-clamp(m12, -1, 1));
if (std::abs(m12) < 0.9999999)
{
this->x = std::atan2(m32, m22);
this->y = std::atan2(m13, m11);
}
else
{
this->x = std::atan2(-m23, m33);
this->y = 0;
}
break;
default:
// TODO
// console.warn( 'CERAMICS.Euler: .setFromRotationMatrix()
// encountered an unknown order: ' + order );
break;
}
this->order = order;
}
void setFromQuaternion(TQuaternion<T> q, RotationOrder order = XYZ)
{
auto matrix = TMatrix<T, 4, 4>::makeRotationFromQuaternion(q);
return this->setFromRotationMatrix(matrix, order);
}
void setFromVector3(TVector<T, 3> v, RotationOrder order = XYZ)
{
return this->set(v.x(), v.y(), v.z(), order);
}
void reorder(RotationOrder newOrder)
{
// WARNING: this discards revolution information -bhouston
TQuaternion<T> _quaternion;
_quaternion.setFromEuler(this);
return this->setFromQuaternion(_quaternion, newOrder);
}
bool equals(const type &euler)
{
return (euler->x == this->x) && (euler->y == this->y) &&
(euler->z == this->z) && (euler.order == this->order);
}
template <class array_t>
type &fromArray(array_t array)
{
this->x = array[0];
this->y = array[1];
this->z = array[2];
// if ( array[ 3 ] !== undefined )
this->order = array[3];
return *this;
}
template <class array_t>
array_t toArray(array_t array, int offset)
{
// if ( array === undefined ) array = [];
// if ( offset === undefined ) offset = 0;
array[offset] = this->x;
array[offset + 1] = this->y;
array[offset + 2] = this->z;
array[offset + 3] = this->order;
return array;
}
TVector<T, 3> toVector3()
{
return TVector<T, 3>(this->x, this->y, this->z);
}
};
template <class T>
RotationOrder TEuler<T>::DefaultOrder = XYZ;
CERAMICS_NAMESPACE_END
| 23.464435
| 79
| 0.460057
|
Tonvey
|
4d034b5a6ae599a2d21dbd7aedc042bcbe70203c
| 1,528
|
cpp
|
C++
|
source/Library.Shared/ModelManager.cpp
|
DakkyDaWolf/OpenGL
|
628e9aed116022175cc0c59c88ace7688309628c
|
[
"MIT"
] | null | null | null |
source/Library.Shared/ModelManager.cpp
|
DakkyDaWolf/OpenGL
|
628e9aed116022175cc0c59c88ace7688309628c
|
[
"MIT"
] | null | null | null |
source/Library.Shared/ModelManager.cpp
|
DakkyDaWolf/OpenGL
|
628e9aed116022175cc0c59c88ace7688309628c
|
[
"MIT"
] | null | null | null |
#include "pch.h"
#include "ModelManager.h"
using namespace std;
namespace Library
{
pair<Model, vector<MeshResource>>& ModelManager::LoadModel(const std::string& fileName)
{
Model loadedModel(fileName, true);
auto assembledEntry = make_pair(fileName, make_pair(move(loadedModel), vector<MeshResource>()));
for (auto& mesh : assembledEntry.second.first.Meshes())
{
assembledEntry.second.second.push_back(MeshResource(*mesh));
}
++ModelsLoaded;
return RegisteredModels.emplace(move(assembledEntry)).first->second;
}
Model& ModelManager::GetModel(const std::string& fileName)
{
if (fileName.empty()) throw runtime_error("invalid filename: empty");
if (!RegisteredModels.count(fileName)) return LoadModel(fileName).first;
return RegisteredModels.at(fileName).first;
}
MeshResource& ModelManager::GetMesh(const std::string& fileName, size_t index)
{
if (fileName.empty()) throw runtime_error("invalid filename: empty");
if (!RegisteredModels.count(fileName)) return LoadModel(fileName).second[index];
return RegisteredModels.at(fileName).second[index];
}
std::vector<MeshResource>& ModelManager::GetMeshes(const std::string& fileName)
{
if (fileName.empty()) throw runtime_error("invalid filename: empty");
if (!RegisteredModels.count(fileName)) return LoadModel(fileName).second;
return RegisteredModels.at(fileName).second;
}
}
| 29.960784
| 104
| 0.679319
|
DakkyDaWolf
|
4d07adfd12de072911c72e3c60f3882768d05cbd
| 740
|
hpp
|
C++
|
src/public/GpuGeometry.hpp
|
linuxaged/gfx
|
5ec841ddabca5ce589cd1ca095ce81ec52b438ee
|
[
"MIT"
] | null | null | null |
src/public/GpuGeometry.hpp
|
linuxaged/gfx
|
5ec841ddabca5ce589cd1ca095ce81ec52b438ee
|
[
"MIT"
] | null | null | null |
src/public/GpuGeometry.hpp
|
linuxaged/gfx
|
5ec841ddabca5ce589cd1ca095ce81ec52b438ee
|
[
"MIT"
] | null | null | null |
#pragma once
#include "GpuBuffer.hpp"
#include "GpuVertexAttribute.hpp"
namespace lxd
{
class GpuGeometry
{
public:
GpuGeometry( GpuContext* context, const GpuVertexAttributeArrays* attribs,
const GpuTriangleIndexArray* indices, const bool dynamic = false );
~GpuGeometry();
public:
const GpuVertexAttribute* layout;
int vertexAttribsFlags;
int instanceAttribsFlags;
int vertexCount;
int instanceCount;
int indexCount;
GpuBuffer vertexBuffer;
GpuBuffer instanceBuffer;
GpuBuffer indexBuffer;
};
} // namespace lxd
| 27.407407
| 84
| 0.564865
|
linuxaged
|
4d0b7b1b15d31050b49ce1c05cde7361f680d6d3
| 7,086
|
hpp
|
C++
|
boost/hash/block_cyphers/basic_shacal.hpp
|
dillonl/boost-cmake
|
7204d4c68345a0b26e24f51fa46a04b1d2bda3e7
|
[
"BSL-1.0"
] | null | null | null |
boost/hash/block_cyphers/basic_shacal.hpp
|
dillonl/boost-cmake
|
7204d4c68345a0b26e24f51fa46a04b1d2bda3e7
|
[
"BSL-1.0"
] | null | null | null |
boost/hash/block_cyphers/basic_shacal.hpp
|
dillonl/boost-cmake
|
7204d4c68345a0b26e24f51fa46a04b1d2bda3e7
|
[
"BSL-1.0"
] | null | null | null |
//
// Copyright 2010 Scott McMurray.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_HASH_BLOCK_CYPHERS_BASIC_SHACAL_HPP
#define BOOST_HASH_BLOCK_CYPHERS_BASIC_SHACAL_HPP
#include <boost/hash/block_cyphers/detail/shacal_policy.hpp>
#include <boost/hash/block_cyphers/detail/shacal1_policy.hpp>
#include <boost/static_assert.hpp>
#ifdef BOOST_HASH_SHOW_PROGRESS
#include <cstdio>
#endif
//
// Encrypt implemented directly from the SHA standard as found at
// http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf
//
// Decrypt is a straight-forward inverse
//
// In SHA terminology:
// - plaintext = H^(i-1)
// - cyphertext = H^(i)
// - key = M^(i)
// - schedule = W
//
namespace boost {
namespace hashes {
namespace block_cyphers {
//
// The algorithms for SHA(-0) and SHA-1 are identical apart from the
// key scheduling, so encapsulate that as a class that takes an
// already-prepared schedule. (Constructor is protected to help keep
// people from accidentally giving it just a key in a schedule.)
//
class basic_shacal {
public:
typedef detail::shacal_policy policy_type;
static unsigned const word_bits = policy_type::word_bits;
typedef policy_type::word_type word_type;
static unsigned const key_bits = policy_type::key_bits;
static unsigned const key_words = policy_type::key_words;
typedef policy_type::key_type key_type;
static unsigned const block_bits = policy_type::block_bits;
static unsigned const block_words = policy_type::block_words;
typedef policy_type::block_type block_type;
static unsigned const rounds = policy_type::rounds;
typedef policy_type::schedule_type schedule_type;
protected:
basic_shacal(schedule_type const &s) : schedule(s) {}
private:
schedule_type const schedule;
public:
block_type
encypher(block_type const &plaintext) {
return encypher_block(plaintext);
}
private:
block_type
encypher_block(block_type const &plaintext) {
return encypher_block(schedule, plaintext);
}
static block_type
encypher_block(schedule_type const &schedule,
block_type const &plaintext) {
#ifdef BOOST_HASH_SHOW_PROGRESS
for (unsigned t = 0; t < block_words; ++t) {
std::printf(word_bits == 32 ?
"H[%d] = %.8x\n" :
"H[%d] = %.16lx\n",
t, plaintext[t]);
}
#endif
// Initialize working variables with block
word_type a = plaintext[0], b = plaintext[1],
c = plaintext[2], d = plaintext[3],
e = plaintext[4];
// Encypher block
#ifdef BOOST_HASH_NO_OPTIMIZATION
for (unsigned t = 0; t < rounds; ++t) {
word_type T = policy_type::ROTL<5>(a)
+ policy_type::f(t,b,c,d)
+ e
+ policy_type::constant(t)
+ schedule[t];
e = d;
d = c;
c = policy_type::ROTL<30>(b);
b = a;
a = T;
#ifdef BOOST_HASH_SHOW_PROGRESS
printf(word_bits == 32 ?
"t = %2d: %.8x %.8x %.8x %.8x %.8x\n" :
"t = %2d: %.16lx %.16lx %.16lx %.16lx %.16lx\n",
t, a, b, c, d, e);
#endif
}
#else // BOOST_HASH_NO_OPTIMIZATION
# ifdef BOOST_HASH_SHOW_PROGRESS
# define BOOST_HASH_SHACAL1_TRANSFORM_PROGRESS \
printf(word_bits == 32 ? \
"t = %2d: %.8x %.8x %.8x %.8x %.8x\n" : \
"t = %2d: %.16lx %.16lx %.16lx %.16lx %.16lx\n", \
t, a, b, c, d, e);
# else
# define BOOST_HASH_SHACAL1_TRANSFORM_PROGRESS
# endif
# define BOOST_HASH_SHACAL1_TRANSFORM \
word_type T = policy_type::ROTL<5>(a) \
+ policy_type::f(t,b,c,d) \
+ e \
+ policy_type::constant(t) \
+ schedule[t]; \
e = d; \
d = c; \
c = policy_type::ROTL<30>(b); \
b = a; \
a = T; \
BOOST_HASH_SHACAL1_TRANSFORM_PROGRESS
BOOST_STATIC_ASSERT(rounds == 80);
BOOST_STATIC_ASSERT(rounds % block_words == 0);
for (unsigned t = 0; t < 20; ) {
for (int n = block_words; n--; ++t) {
BOOST_HASH_SHACAL1_TRANSFORM
}
}
for (unsigned t = 20; t < 40; ) {
for (int n = block_words; n--; ++t) {
BOOST_HASH_SHACAL1_TRANSFORM
}
}
for (unsigned t = 40; t < 60; ) {
for (int n = block_words; n--; ++t) {
BOOST_HASH_SHACAL1_TRANSFORM
}
}
for (unsigned t = 60; t < 80; ) {
for (int n = block_words; n--; ++t) {
BOOST_HASH_SHACAL1_TRANSFORM
}
}
#endif
block_type cyphertext = {{a, b, c, d, e}};
return cyphertext;
}
public:
block_type
decypher(block_type const &plaintext) {
return decypher_block(plaintext);
}
private:
block_type
decypher_block(block_type const &plaintext) {
return decypher_block(schedule, plaintext);
}
static block_type
decypher_block(schedule_type const &schedule,
block_type const &cyphertext) {
#ifdef BOOST_HASH_SHOW_PROGRESS
for (unsigned t = 0; t < block_words; ++t) {
std::printf(word_bits == 32 ?
"H[%d] = %.8x\n" :
"H[%d] = %.16lx\n",
t, cyphertext[t]);
}
#endif
// Initialize working variables with block
word_type a = cyphertext[0], b = cyphertext[1],
c = cyphertext[2], d = cyphertext[3],
e = cyphertext[4];
// Decypher block
for (unsigned t = rounds; t--; ) {
word_type T = a;
a = b;
b = policy_type::ROTR<30>(c);
c = d;
d = e;
e = T
- policy_type::ROTL<5>(a)
- policy_type::f(t, b, c, d)
- policy_type::constant(t)
- schedule[t];
#ifdef BOOST_HASH_SHOW_PROGRESS
std::printf(word_bits == 32 ?
"t = %2d: %.8x %.8x %.8x %.8x %.8x\n" :
"t = %2d: %.16lx %.16lx %.16lx %.16lx %.16lx\n",
t, a, b, c, d, e);
#endif
}
block_type plaintext = {{a, b, c, d, e}};
return plaintext;
}
};
} // namespace block_cyphers
} // namespace hashes
} // namespace boost
#endif // BOOST_HASH_BLOCK_CYPHERS_BASIC_SHACAL_HPP
| 30.282051
| 73
| 0.52639
|
dillonl
|
4d0bda3f477f32cc21f869ba4521bb21ab99bed7
| 1,571
|
cpp
|
C++
|
Solitaire/game.cpp
|
LazyMechanic/Solitaire
|
7e6e72cf32695267e7ec7fa5c8bd366b0553b439
|
[
"Apache-2.0"
] | null | null | null |
Solitaire/game.cpp
|
LazyMechanic/Solitaire
|
7e6e72cf32695267e7ec7fa5c8bd366b0553b439
|
[
"Apache-2.0"
] | null | null | null |
Solitaire/game.cpp
|
LazyMechanic/Solitaire
|
7e6e72cf32695267e7ec7fa5c8bd366b0553b439
|
[
"Apache-2.0"
] | null | null | null |
#include <iostream>
#include "game.h"
short Game::g_gameCondition = Condition::Nothing;
Game::~Game()
{
}
bool Game::Init()
{
// Check files
if (!m_cardsImage.loadFromFile("data/cards.png") || !m_backgroundImage.loadFromFile("data/background.png") || !m_windowIcon.loadFromFile("data/ico.png") || !Timer::SetTimerText() || !EndGame::Init(m_backgroundImage) || !Config::Init()) {
return false;
}
// Create window
m_window.create(sf::VideoMode(800, 600), "Solitaire", sf::Style::Titlebar | sf::Style::Close);
m_window.setIcon(32, 32, m_windowIcon.getPixelsPtr());
m_window.setVerticalSyncEnabled(true);
// Init gaming table, his constans and Input
Input::Init(this);
m_gamingTable.Init(m_cardsImage, m_backgroundImage, m_window);
m_gamingTable.InitOffset(m_window.getSize());
return true;
}
void Game::Run()
{
sf::Clock timer;
while (m_window.isOpen() && Game::g_gameCondition == Condition::Nothing && Timer::GetCurrentTime() > 0) {
auto dt = timer.restart();
// Update scene
Input::Update();
Timer::Update(dt.asMilliseconds() > 100 ? 100 : dt.asMilliseconds());
m_gamingTable.Update(dt.asSeconds());
m_window.clear(sf::Color(0, 128, 0));
// Draw scene
m_gamingTable.Draw(m_window);
// Display scene
m_window.display();
}
// Check loss time
if (Timer::GetCurrentTime() < 1) {
Game::g_gameCondition = Condition::Lose;
Config::Update(-300);
}
// Draw last scene - end game
EndGame::Draw(m_window, Game::g_gameCondition);
// closing waiting
while (m_window.isOpen()) Input::Update();
// Save score
Config::Save();
}
| 26.183333
| 238
| 0.694462
|
LazyMechanic
|
4d108ef626f44e7134ef6d8bf438b938a501a2cd
| 693
|
hpp
|
C++
|
engine/actions/include/HelpAction.hpp
|
sidav/shadow-of-the-wyrm
|
747afdeebed885b1a4f7ab42f04f9f756afd3e52
|
[
"MIT"
] | 60
|
2019-08-21T04:08:41.000Z
|
2022-03-10T13:48:04.000Z
|
engine/actions/include/HelpAction.hpp
|
cleancoindev/shadow-of-the-wyrm
|
51b23e98285ecb8336324bfd41ebf00f67b30389
|
[
"MIT"
] | 3
|
2021-03-18T15:11:14.000Z
|
2021-10-20T12:13:07.000Z
|
engine/actions/include/HelpAction.hpp
|
cleancoindev/shadow-of-the-wyrm
|
51b23e98285ecb8336324bfd41ebf00f67b30389
|
[
"MIT"
] | 8
|
2019-11-16T06:29:05.000Z
|
2022-01-23T17:33:43.000Z
|
#pragma once
#include "IActionManager.hpp"
class HelpAction : public IActionManager
{
public:
ActionCostValue help(CreaturePtr creature) const;
ActionCostValue keybindings() const;
ActionCostValue introduction_roguelikes() const;
ActionCostValue game_history() const;
ActionCostValue strategy_basics() const;
ActionCostValue casino_games() const;
ActionCostValue get_action_cost_value(CreaturePtr creature) const override;
protected:
friend class ActionManager;
friend class HelpCommandProcessor;
HelpAction();
ActionCostValue display_text(const std::string& title_sid, const std::string& text_sid, const bool maintain_formatting) const;
};
| 30.130435
| 130
| 0.776335
|
sidav
|
4d16b136a894f70a6cffc9c0fa53590f89c3be6f
| 1,194
|
cpp
|
C++
|
ige/src/ecs/Entity.cpp
|
Arcahub/ige
|
b9f61209c924c7b683d2429a07e76251e6eb7b1b
|
[
"MIT"
] | 3
|
2021-06-05T00:36:50.000Z
|
2022-02-27T10:23:53.000Z
|
ige/src/ecs/Entity.cpp
|
Arcahub/ige
|
b9f61209c924c7b683d2429a07e76251e6eb7b1b
|
[
"MIT"
] | 11
|
2021-05-08T22:00:24.000Z
|
2021-11-11T22:33:43.000Z
|
ige/src/ecs/Entity.cpp
|
Arcahub/ige
|
b9f61209c924c7b683d2429a07e76251e6eb7b1b
|
[
"MIT"
] | 4
|
2021-05-20T12:41:23.000Z
|
2021-11-09T14:19:18.000Z
|
#include "igepch.hpp"
#include "ige/ecs/Entity.hpp"
#include <cstddef>
#include <cstdint>
using ige::ecs::EntityId;
using ige::ecs::EntityPool;
EntityId::EntityId(std::size_t index, std::uint64_t gen)
: m_index(index)
, m_generation(gen)
{
}
std::size_t EntityId::index() const
{
return m_index;
}
std::uint64_t EntityId::generation() const
{
return m_generation;
}
EntityId EntityId::next_gen() const
{
return { m_index, m_generation + 1 };
}
EntityId EntityPool::allocate()
{
auto it_available = m_released.begin();
if (it_available != m_released.end()) {
EntityId entity = it_available->next_gen();
m_released.erase(it_available);
m_entities.insert(entity);
return entity;
} else {
EntityId entity { m_size++, 0 };
m_entities.insert(entity);
return entity;
}
}
bool EntityPool::release(EntityId entity)
{
auto iter = m_entities.find(entity);
if (iter != m_entities.end()) {
m_released.insert(entity);
m_entities.erase(iter);
return true;
}
return false;
}
bool EntityPool::exists(EntityId entity) const
{
return m_entities.contains(entity);
}
| 18.65625
| 56
| 0.649079
|
Arcahub
|
4d16d978af99044cd4ad2b4654a67b9e32983efc
| 623
|
cpp
|
C++
|
usaco/CountingLiars2022Bronze.cpp
|
datpq/competitive-programming
|
ed5733cc55fa4167c4a2e828894b044ea600dcac
|
[
"MIT"
] | 1
|
2022-02-24T21:35:18.000Z
|
2022-02-24T21:35:18.000Z
|
usaco/CountingLiars2022Bronze.cpp
|
datpq/competitive-programming
|
ed5733cc55fa4167c4a2e828894b044ea600dcac
|
[
"MIT"
] | null | null | null |
usaco/CountingLiars2022Bronze.cpp
|
datpq/competitive-programming
|
ed5733cc55fa4167c4a2e828894b044ea600dcac
|
[
"MIT"
] | 1
|
2022-02-12T14:40:21.000Z
|
2022-02-12T14:40:21.000Z
|
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main() {
int n; cin >> n;
map<int, pair<int, int>> m;
int G = 0, L = 0;
while (n--) {
char c; int p; cin >> c >> p;
if (!m.count(p)) m[p] = { 0, 0 };
if (c == 'G') {
m[p].second++; G++;
}
else {
m[p].first++; L++;
}
}
int best = G;
int ans = best;
int lastL = 0;
for (auto& x : m) {
ans -= (x.second.second - lastL);
lastL = x.second.first;
best = min(best, ans);
}
cout << best << endl;
return 0;
}
| 20.096774
| 41
| 0.41573
|
datpq
|
4d1c9ed2f5b09a76c4ea8b8c399d060f47dbaf87
| 10,555
|
cpp
|
C++
|
src/apps/webpositive/support/FontSelectionView.cpp
|
axeld/haiku
|
e3becd53eef5c093ee8c8f32bab51d40b0f2b8d4
|
[
"MIT"
] | 4
|
2016-03-29T21:45:21.000Z
|
2016-12-20T00:50:38.000Z
|
src/apps/webpositive/support/FontSelectionView.cpp
|
axeld/haiku
|
e3becd53eef5c093ee8c8f32bab51d40b0f2b8d4
|
[
"MIT"
] | null | null | null |
src/apps/webpositive/support/FontSelectionView.cpp
|
axeld/haiku
|
e3becd53eef5c093ee8c8f32bab51d40b0f2b8d4
|
[
"MIT"
] | 3
|
2018-12-17T13:07:38.000Z
|
2021-09-08T13:07:31.000Z
|
/*
* Copyright 2001-2010, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Mark Hogben
* DarkWyrm <bpmagic@columbus.rr.com>
* Axel Dörfler, axeld@pinc-software.de
* Philippe Saint-Pierre, stpere@gmail.com
* Stephan Aßmus <superstippi@gmx.de>
*/
#include "FontSelectionView.h"
#include <Box.h>
#include <Catalog.h>
#include <Locale.h>
#include <Looper.h>
#include <MenuField.h>
#include <MenuItem.h>
#include <PopUpMenu.h>
#include <String.h>
#include <StringView.h>
#include <LayoutItem.h>
#include <GroupLayoutBuilder.h>
#include <stdio.h>
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "Font Selection view"
static const float kMinSize = 8.0;
static const float kMaxSize = 18.0;
static const int32 kMsgSetFamily = 'fmly';
static const int32 kMsgSetStyle = 'styl';
static const int32 kMsgSetSize = 'size';
// #pragma mark -
FontSelectionView::FontSelectionView(const char* name, const char* label,
bool separateStyles, const BFont* currentFont)
:
BHandler(name),
fMessage(NULL),
fTarget(NULL)
{
if (currentFont == NULL)
fCurrentFont = _DefaultFont();
else
fCurrentFont = *currentFont;
fSavedFont = fCurrentFont;
fSizesMenu = new BPopUpMenu("size menu");
fFontsMenu = new BPopUpMenu("font menu");
// font menu
fFontsMenuField = new BMenuField("fonts", label, fFontsMenu, B_WILL_DRAW);
fFontsMenuField->SetFont(be_bold_font);
// styles menu, if desired
if (separateStyles) {
fStylesMenu = new BPopUpMenu("styles menu");
fStylesMenuField = new BMenuField("styles", B_TRANSLATE("Style:"),
fStylesMenu, B_WILL_DRAW);
} else {
fStylesMenu = NULL;
fStylesMenuField = NULL;
}
// size menu
fSizesMenuField = new BMenuField("size", B_TRANSLATE("Size:"), fSizesMenu,
B_WILL_DRAW);
fSizesMenuField->SetAlignment(B_ALIGN_RIGHT);
// preview
fPreviewText = new BStringView("preview text",
B_TRANSLATE_COMMENT("The quick brown fox jumps over the lazy dog.",
"Don't translate this literally ! Use a phrase showing all "
"chars from A to Z."));
fPreviewText->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED,
B_SIZE_UNLIMITED));
fPreviewText->SetHighUIColor(B_PANEL_BACKGROUND_COLOR, 1.65);
fPreviewText->SetAlignment(B_ALIGN_RIGHT);
_UpdateFontPreview();
}
FontSelectionView::~FontSelectionView()
{
// Some controls may not have been attached...
if (!fPreviewText->Window())
delete fPreviewText;
if (!fSizesMenuField->Window())
delete fSizesMenuField;
if (fStylesMenuField && !fStylesMenuField->Window())
delete fStylesMenuField;
if (!fFontsMenuField->Window())
delete fFontsMenuField;
delete fMessage;
}
void
FontSelectionView::AttachedToLooper()
{
_BuildSizesMenu();
UpdateFontsMenu();
}
void
FontSelectionView::MessageReceived(BMessage* message)
{
switch (message->what) {
case kMsgSetSize:
{
int32 size;
if (message->FindInt32("size", &size) != B_OK
|| size == fCurrentFont.Size())
break;
fCurrentFont.SetSize(size);
_UpdateFontPreview();
_Invoke();
break;
}
case kMsgSetFamily:
{
const char* family;
if (message->FindString("family", &family) != B_OK)
break;
font_style style;
fCurrentFont.GetFamilyAndStyle(NULL, &style);
BMenuItem* familyItem = fFontsMenu->FindItem(family);
if (familyItem != NULL) {
_SelectCurrentFont(false);
BMenuItem* styleItem;
if (fStylesMenuField != NULL)
styleItem = fStylesMenuField->Menu()->FindMarked();
else {
styleItem = familyItem->Submenu()->FindItem(style);
if (styleItem == NULL)
styleItem = familyItem->Submenu()->ItemAt(0);
}
if (styleItem != NULL) {
styleItem->SetMarked(true);
fCurrentFont.SetFamilyAndStyle(family, styleItem->Label());
_UpdateFontPreview();
}
if (fStylesMenuField != NULL)
_AddStylesToMenu(fCurrentFont, fStylesMenuField->Menu());
}
_Invoke();
break;
}
case kMsgSetStyle:
{
const char* family;
const char* style;
if (message->FindString("family", &family) != B_OK
|| message->FindString("style", &style) != B_OK)
break;
BMenuItem *familyItem = fFontsMenu->FindItem(family);
if (!familyItem)
break;
_SelectCurrentFont(false);
familyItem->SetMarked(true);
fCurrentFont.SetFamilyAndStyle(family, style);
_UpdateFontPreview();
_Invoke();
break;
}
default:
BHandler::MessageReceived(message);
}
}
void
FontSelectionView::SetMessage(BMessage* message)
{
delete fMessage;
fMessage = message;
}
void
FontSelectionView::SetTarget(BHandler* target)
{
fTarget = target;
}
// #pragma mark -
void
FontSelectionView::SetFont(const BFont& font, float size)
{
BFont resizedFont(font);
resizedFont.SetSize(size);
SetFont(resizedFont);
}
void
FontSelectionView::SetFont(const BFont& font)
{
if (font == fCurrentFont && font == fSavedFont)
return;
_SelectCurrentFont(false);
fSavedFont = fCurrentFont = font;
_UpdateFontPreview();
_SelectCurrentFont(true);
_SelectCurrentSize(true);
}
void
FontSelectionView::SetSize(float size)
{
SetFont(fCurrentFont, size);
}
const BFont&
FontSelectionView::Font() const
{
return fCurrentFont;
}
void
FontSelectionView::SetDefaults()
{
BFont defaultFont = _DefaultFont();
if (defaultFont == fCurrentFont)
return;
_SelectCurrentFont(false);
fCurrentFont = defaultFont;
_UpdateFontPreview();
_SelectCurrentFont(true);
_SelectCurrentSize(true);
}
void
FontSelectionView::Revert()
{
if (!IsRevertable())
return;
_SelectCurrentFont(false);
fCurrentFont = fSavedFont;
_UpdateFontPreview();
_SelectCurrentFont(true);
_SelectCurrentSize(true);
}
bool
FontSelectionView::IsDefaultable()
{
return fCurrentFont != _DefaultFont();
}
bool
FontSelectionView::IsRevertable()
{
return fCurrentFont != fSavedFont;
}
void
FontSelectionView::UpdateFontsMenu()
{
int32 numFamilies = count_font_families();
fFontsMenu->RemoveItems(0, fFontsMenu->CountItems(), true);
BFont font = fCurrentFont;
font_family currentFamily;
font_style currentStyle;
font.GetFamilyAndStyle(¤tFamily, ¤tStyle);
for (int32 i = 0; i < numFamilies; i++) {
font_family family;
uint32 flags;
if (get_font_family(i, &family, &flags) != B_OK)
continue;
// if we're setting the fixed font, we only want to show fixed fonts
if (!strcmp(Name(), "fixed") && (flags & B_IS_FIXED) == 0)
continue;
font.SetFamilyAndFace(family, B_REGULAR_FACE);
BMessage* message = new BMessage(kMsgSetFamily);
message->AddString("family", family);
message->AddString("name", Name());
BMenuItem* familyItem;
if (fStylesMenuField != NULL) {
familyItem = new BMenuItem(family, message);
} else {
// Each family item has a submenu with all styles for that font.
BMenu* stylesMenu = new BMenu(family);
_AddStylesToMenu(font, stylesMenu);
familyItem = new BMenuItem(stylesMenu, message);
}
familyItem->SetMarked(strcmp(family, currentFamily) == 0);
fFontsMenu->AddItem(familyItem);
familyItem->SetTarget(this);
}
// Separate styles menu for only the current font.
if (fStylesMenuField != NULL)
_AddStylesToMenu(fCurrentFont, fStylesMenuField->Menu());
}
// #pragma mark - private
BLayoutItem*
FontSelectionView::CreateSizesLabelLayoutItem()
{
return fSizesMenuField->CreateLabelLayoutItem();
}
BLayoutItem*
FontSelectionView::CreateSizesMenuBarLayoutItem()
{
return fSizesMenuField->CreateMenuBarLayoutItem();
}
BLayoutItem*
FontSelectionView::CreateFontsLabelLayoutItem()
{
return fFontsMenuField->CreateLabelLayoutItem();
}
BLayoutItem*
FontSelectionView::CreateFontsMenuBarLayoutItem()
{
return fFontsMenuField->CreateMenuBarLayoutItem();
}
BLayoutItem*
FontSelectionView::CreateStylesLabelLayoutItem()
{
if (fStylesMenuField)
return fStylesMenuField->CreateLabelLayoutItem();
return NULL;
}
BLayoutItem*
FontSelectionView::CreateStylesMenuBarLayoutItem()
{
if (fStylesMenuField)
return fStylesMenuField->CreateMenuBarLayoutItem();
return NULL;
}
BView*
FontSelectionView::PreviewBox() const
{
return fPreviewText;
}
// #pragma mark - private
void
FontSelectionView::_Invoke()
{
if (fTarget != NULL && fTarget->Looper() != NULL && fMessage != NULL) {
BMessage message(*fMessage);
fTarget->Looper()->PostMessage(&message, fTarget);
}
}
BFont
FontSelectionView::_DefaultFont() const
{
if (strcmp(Name(), "bold") == 0)
return *be_bold_font;
if (strcmp(Name(), "fixed") == 0)
return *be_fixed_font;
else
return *be_plain_font;
}
void
FontSelectionView::_SelectCurrentFont(bool select)
{
font_family family;
font_style style;
fCurrentFont.GetFamilyAndStyle(&family, &style);
BMenuItem *item = fFontsMenu->FindItem(family);
if (item != NULL) {
item->SetMarked(select);
if (item->Submenu() != NULL) {
item = item->Submenu()->FindItem(style);
if (item != NULL)
item->SetMarked(select);
}
}
}
void
FontSelectionView::_SelectCurrentSize(bool select)
{
char label[16];
snprintf(label, sizeof(label), "%" B_PRId32, (int32)fCurrentFont.Size());
BMenuItem* item = fSizesMenu->FindItem(label);
if (item != NULL)
item->SetMarked(select);
}
void
FontSelectionView::_UpdateFontPreview()
{
fPreviewText->SetFont(&fCurrentFont);
}
void
FontSelectionView::_BuildSizesMenu()
{
const int32 sizes[] = {7, 8, 9, 10, 11, 12, 13, 14, 18, 21, 24, 0};
// build size menu
for (int32 i = 0; sizes[i]; i++) {
int32 size = sizes[i];
if (size < kMinSize || size > kMaxSize)
continue;
char label[32];
snprintf(label, sizeof(label), "%" B_PRId32, size);
BMessage* message = new BMessage(kMsgSetSize);
message->AddInt32("size", size);
message->AddString("name", Name());
BMenuItem* item = new BMenuItem(label, message);
if (size == fCurrentFont.Size())
item->SetMarked(true);
fSizesMenu->AddItem(item);
item->SetTarget(this);
}
}
void
FontSelectionView::_AddStylesToMenu(const BFont& font, BMenu* stylesMenu) const
{
stylesMenu->RemoveItems(0, stylesMenu->CountItems(), true);
stylesMenu->SetRadioMode(true);
font_family family;
font_style style;
font.GetFamilyAndStyle(&family, &style);
BString currentStyle(style);
int32 numStyles = count_font_styles(family);
for (int32 j = 0; j < numStyles; j++) {
if (get_font_style(family, j, &style) != B_OK)
continue;
BMessage* message = new BMessage(kMsgSetStyle);
message->AddString("family", (char*)family);
message->AddString("style", (char*)style);
BMenuItem* item = new BMenuItem(style, message);
item->SetMarked(currentStyle == style);
stylesMenu->AddItem(item);
item->SetTarget(this);
}
}
| 20.028463
| 79
| 0.714543
|
axeld
|
4d2112cc143eb22dbf48e50678e77ceb984a7d5c
| 3,255
|
cpp
|
C++
|
GUIWidgets/BasicStreamEditor/DDTable.cpp
|
gladk/Dyssol-open
|
53eb7b589ad03eb477d743ee6a90ee10297a9366
|
[
"BSD-3-Clause"
] | 1
|
2020-07-31T07:10:11.000Z
|
2020-07-31T07:10:11.000Z
|
GUIWidgets/BasicStreamEditor/DDTable.cpp
|
gladk/Dyssol-open
|
53eb7b589ad03eb477d743ee6a90ee10297a9366
|
[
"BSD-3-Clause"
] | null | null | null |
GUIWidgets/BasicStreamEditor/DDTable.cpp
|
gladk/Dyssol-open
|
53eb7b589ad03eb477d743ee6a90ee10297a9366
|
[
"BSD-3-Clause"
] | 1
|
2021-03-04T06:44:38.000Z
|
2021-03-04T06:44:38.000Z
|
/* Copyright (c) 2020, Dyssol Development Team. All rights reserved. This file is part of Dyssol. See LICENSE file for license information. */
#include "DDTable.h"
#include <QHeaderView>
CDDTable::CDDTable( QWidget *parent, Qt::WindowFlags flags ) : QWidget(parent, flags)
{
m_pData = NULL;
m_bNormalize = false;
m_pTable = new CQtTable( this );
layout = new QHBoxLayout;
layout->addWidget(m_pTable);
setLayout(layout);
m_pTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
QObject::connect( m_pTable, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(ItemWasChanged(QTableWidgetItem*)) );
}
CDDTable::~CDDTable()
{
m_pData = NULL;
}
void CDDTable::SetDistribution( CDenseDistr2D* _pDistribution )
{
m_pData = _pDistribution;
m_pTable->setColumnCount( m_pData->GetDimensionsNumber() + 1 );
SetHeaders();
UpdateWholeView();
}
void CDDTable::SetNormalizationCheck( bool _bAnalyse )
{
m_bNormalize = _bAnalyse;
UpdateWholeView();
}
void CDDTable::SetEditable(bool _bEditable)
{
m_pTable->SetEditable(_bEditable);
}
void CDDTable::SetHeaders()
{
if( m_pData == NULL ) return;
m_pTable->setHorizontalHeaderItem( 0, new QTableWidgetItem("Time [s]") );
for( int i=0; i<(int)m_pData->GetDimensionsNumber(); ++i )
{
if( m_pTable->columnCount() < i+2 )
m_pTable->insertColumn( i+2 );
m_pTable->setHorizontalHeaderItem( i+1, new QTableWidgetItem( QString::fromUtf8( m_pData->GetLabel(i).c_str() ) ) );
}
}
void CDDTable::CheckNormalization()
{
for( unsigned i=0; i<m_pData->GetTimePointsNumber(); ++i )
{
std::vector<double> vTemp = m_pData->GetValueForIndex(i);
double dSum = 0;
for( unsigned j=0; j<vTemp.size(); ++j )
dSum += vTemp[j];
if( dSum != 1 )
for( int j=0; j<m_pTable->columnCount(); ++j )
m_pTable->item( i, j )->setBackground( Qt::lightGray );
else
for( int j=0; j<m_pTable->columnCount(); ++j )
m_pTable->item( i, j )->setBackground( Qt::white );
}
}
void CDDTable::UpdateWholeView()
{
if( m_pData == NULL ) return;
m_bAvoidSignal = true;
int iRow;
for( iRow=0; iRow<(int)m_pData->GetTimePointsNumber(); ++iRow )
{
if( iRow >= m_pTable->rowCount() )
m_pTable->insertRow(iRow);
std::vector<double> vTemp = m_pData->GetValueForIndex( iRow );
m_pTable->setItem( iRow, 0, new QTableWidgetItem( QString::number( m_pData->GetTimeForIndex( iRow ) ) ));
m_pTable->item( iRow, 0 )->setFlags( m_pTable->item( iRow, 0 )->flags() & ~Qt::ItemIsEditable );
for( unsigned i=0; i<vTemp.size(); ++i )
m_pTable->setItem( iRow, i+1, new QTableWidgetItem( QString::number( vTemp[i] ) ));
}
while( m_pTable->rowCount() > (int)m_pData->GetTimePointsNumber())
m_pTable->removeRow( m_pTable->rowCount()-1 );
if( m_bNormalize )
CheckNormalization();
m_bAvoidSignal = false;
}
//void CDDTable::setVisible( bool _bVisible )
//{
// if ( _bVisible )
// UpdateWholeView();
// QWidget::setVisible( _bVisible );
//}
void CDDTable::ItemWasChanged( QTableWidgetItem* _pItem )
{
if( m_bAvoidSignal ) return;
unsigned nTimeIndex = _pItem->row();
unsigned nDimIndex = _pItem->column() - 1;
double dVal = _pItem->text().toDouble();
if( dVal < 0 ) dVal = 0;
m_pData->SetValue( nTimeIndex, nDimIndex, dVal );
UpdateWholeView();
emit DataChanged();
}
| 26.25
| 142
| 0.691859
|
gladk
|
4d24dba9103c6edaab819e7c275ffc14e2841f72
| 1,852
|
hpp
|
C++
|
include/enum_tools.hpp
|
upobir/Enum_Tools
|
3b99d4853d4d4a23b9254bc9b7a6530b9d0e19e8
|
[
"MIT"
] | null | null | null |
include/enum_tools.hpp
|
upobir/Enum_Tools
|
3b99d4853d4d4a23b9254bc9b7a6530b9d0e19e8
|
[
"MIT"
] | null | null | null |
include/enum_tools.hpp
|
upobir/Enum_Tools
|
3b99d4853d4d4a23b9254bc9b7a6530b9d0e19e8
|
[
"MIT"
] | null | null | null |
#ifdef GENERATE_DECLARATION_FOR
#define __SIGNATURE GENERATE_DECLARATION_FOR
#define __IMPL_DECLARATION(name, ...) \
{ \
__VA_ARGS__ \
}; \
char const * enumString(name e); \
template<typename T> \
std::vector<T> const enumValues(); \
template<typename T> \
int enumCount();
#define ENUM_CLASS(name, ...) \
enum class name __IMPL_DECLARATION(name, __VA_ARGS__)
#define ENUM_CLASS_WITH_TYPE(name, type, ...) \
enum class name : type __IMPL_DECLARATION(name, __VA_ARGS__)
#define ENUM_PLAIN(name) \
name,
#define ENUM_VALUE(name, value) \
name = value,
__SIGNATURE
#undef __IMPL_DECLARATION
#undef ENUM_CLASS
#undef ENUM_CLASS_WITH_TYPE
#undef ENUM_PLAIN
#undef ENUM_VALUE
#undef __SIGNATURE
#undef GENERATE_DECLARATION_FOR
#endif
#ifdef GENERATE_DEFINITION_FOR
#define __SIGNATURE GENERATE_DEFINITION_FOR
#define ENUM_CLASS_WITH_TYPE(name, type, ...) \
ENUM_CLASS(name, __VA_ARGS__)
#define ENUM_VALUE(name, value) \
ENUM_PLAIN(name)
#define ENUM_CLASS(name, ...) \
char const * enumString(name e){ \
using enumtype = name; \
switch(e){ \
__VA_ARGS__ \
} \
throw "Invalid enum value"; \
return 0; \
}
#define ENUM_PLAIN(name) \
case enumtype :: name : \
return #name ; \
__SIGNATURE
#undef ENUM_CLASS
#undef ENUM_PLAIN
// TODO maybe consider a global vector?
#define ENUM_CLASS(name, ...) \
template<> \
std::vector<name> const enumValues<name>() { \
using enumtype = name; \
return { __VA_ARGS__ }; \
}
#define ENUM_PLAIN(name) \
enumtype :: name ,
__SIGNATURE
#undef ENUM_CLASS
#undef ENUM_PLAIN
#define ENUM_CLASS(name, ...) \
template<> \
int enumCount<name>() { \
return 0 __VA_ARGS__ ; \
}
#define ENUM_PLAIN(name) \
+ 1
__SIGNATURE
#undef ENUM_CLASS
#undef ENUM_PLAIN
#undef ENUM_CLASS_WITH_TYPE
#undef ENUM_VALUE
#undef __SIGNATURE
#undef GENERATE_DEFINITION_FOR
#endif
| 17.980583
| 60
| 0.721382
|
upobir
|
4d2699f1db5c4f512e3eb5c6a710a8ff327426e5
| 742
|
hpp
|
C++
|
src/preprocess/mt-metis-0.7.2/wildriver/src/VectorReaderFactory.hpp
|
curiosityyy/SubgraphMatchGPU
|
7089496084d94a72693dca230ed5165cb94ae4a4
|
[
"MIT"
] | 2
|
2017-07-25T19:46:52.000Z
|
2018-02-13T15:24:02.000Z
|
external/mt-metis-0.7.2/wildriver/src/VectorReaderFactory.hpp
|
yfg/GDSP
|
56fe2242b32d3a1efd24733d0ab30242ee3df2ba
|
[
"MIT"
] | 25
|
2017-07-20T02:35:49.000Z
|
2018-12-21T01:43:42.000Z
|
external/mt-metis-0.7.2/wildriver/src/VectorReaderFactory.hpp
|
yfg/GDSP
|
56fe2242b32d3a1efd24733d0ab30242ee3df2ba
|
[
"MIT"
] | null | null | null |
/**
* @file VectorReaderFactory.hpp
* @brief Class for instantiating vector readers.
* @author Dominique LaSalle <wildriver@domnet.org>
* Copyright 2015-2016
* @version 1
* @date 2015-02-07
*/
#ifndef WILDRIVER_VECTORREADERFACTORY_HPP
#define WILDRIVER_VECTORREADERFACTORY_HPP
#include <memory>
#include <string>
#include "IVectorReader.hpp"
namespace WildRiver
{
class VectorReaderFactory
{
public:
/**
* @brief Allocate a new vector readder subclass based on teh file
* extension.
*
* @param name The filename/path to open.
*
* @return The newly opened vector reader.
*/
static std::unique_ptr<IVectorReader> make(
std::string const & name);
};
}
#endif
| 13.017544
| 70
| 0.672507
|
curiosityyy
|
4d2c203b5abe796346d389d430964b001bd6a2be
| 4,672
|
cpp
|
C++
|
SharedCode/SMbbox3d.cpp
|
timskillman/raspberrypi
|
bf5ce1fe98f2b6571a05da2e92a7b783441ac692
|
[
"MIT"
] | 17
|
2018-11-17T14:41:54.000Z
|
2021-12-07T17:01:21.000Z
|
SharedCode/SMbbox3d.cpp
|
timskillman/raspberrypi
|
bf5ce1fe98f2b6571a05da2e92a7b783441ac692
|
[
"MIT"
] | 4
|
2018-10-18T05:43:57.000Z
|
2020-10-01T22:03:08.000Z
|
SharedCode/SMbbox3d.cpp
|
timskillman/raspberrypi
|
bf5ce1fe98f2b6571a05da2e92a7b783441ac692
|
[
"MIT"
] | 4
|
2018-10-18T05:15:57.000Z
|
2020-11-04T04:13:46.000Z
|
#include "SMbbox3d.h"
#ifdef __WINDOWS__
#include <cmath>
#endif
void SMbbox3d::init()
{
min = vec3f(1e8, 1e8, 1e8);
max = vec3f(-1e8, -1e8, -1e8);
radius = 0;
}
SMbbox3d::SMbbox3d(vec3f _min, vec3f _max)
{
init();
}
void SMbbox3d::update(vec3f point)
{
if (point.x < min.x) min.x = point.x;
if (point.x > max.x) max.x = point.x;
if (point.y < min.y) min.y = point.y;
if (point.y > max.y) max.y = point.y;
if (point.z < min.z) min.z = point.z;
if (point.z > max.z) max.z = point.z;
//approximate radius from bbox ..
vec3f d = max - center();
float r = sqrtf(d.x*d.x + d.y*d.y + d.z*d.z);
if (r > radius) radius = r;
}
void SMbbox3d::update(SMbbox3d box, SMmatrix* mtx)
{
update(mtx->transformVec(vec3f(box.min.x, box.min.y, box.min.z)));
update(mtx->transformVec(vec3f(box.max.x, box.min.y, box.min.z)));
update(mtx->transformVec(vec3f(box.max.x, box.max.y, box.min.z)));
update(mtx->transformVec(vec3f(box.min.x, box.max.y, box.min.z)));
update(mtx->transformVec(vec3f(box.min.x, box.min.y, box.max.z)));
update(mtx->transformVec(vec3f(box.max.x, box.min.y, box.max.z)));
update(mtx->transformVec(vec3f(box.max.x, box.max.y, box.max.z)));
update(mtx->transformVec(vec3f(box.min.x, box.max.y, box.max.z)));
}
void SMbbox3d::update(SMbbox3d box)
{
update(vec3f(box.min.x, box.min.y, box.min.z));
update(vec3f(box.max.x, box.min.y, box.min.z));
update(vec3f(box.max.x, box.max.y, box.min.z));
update(vec3f(box.min.x, box.max.y, box.min.z));
update(vec3f(box.min.x, box.min.y, box.max.z));
update(vec3f(box.max.x, box.min.y, box.max.z));
update(vec3f(box.max.x, box.max.y, box.max.z));
update(vec3f(box.min.x, box.max.y, box.max.z));
}
void SMbbox3d::set(SMbbox3d box, SMmatrix* mtx)
{
init();
update(box, mtx);
}
void SMbbox3d::bboxFromVerts(std::vector<float> &verts, uint32_t start, uint32_t vsize, uint32_t stride)
{
min.x = verts[start]; max.x = min.x;
min.y = verts[start + 1]; max.y = min.y;
min.z = verts[start + 2]; max.z = min.z;
for (uint32_t i = 0; i < vsize; i += stride) {
if (verts[i] < min.x) min.x = verts[i]; else if (verts[i] > max.x) max.x = verts[i];
if (verts[i + 1] < min.y) min.y = verts[i + 1]; else if (verts[i + 1] > max.y) max.y = verts[i + 1];
if (verts[i + 2] < min.z) min.z = verts[i + 2]; else if (verts[i + 2] > max.z) max.z = verts[i + 2];
}
}
void SMbbox3d::radiusFromVerts(std::vector<float> &verts, vec3f centre, uint32_t start, uint32_t size, uint32_t stride)
{
uint32_t st = start*stride;
uint32_t sz = size*stride;
//Works out the bounding radius of the vertices
radius = 0;
//TODO: This should strictly determine bounds by vertices 'used' in the scene according to polygon indices.
for (std::size_t i = st; i < (st+sz); i=stride) {
vec3f d = vec3f(verts[i], verts[i+1], verts[i+2]) - centre;
float r = sqrtf(d.x*d.x + d.y*d.y + d.z*d.z);
if (r > radius) radius = r;
}
}
float SMbbox3d::radiusFromTVerts(std::vector<float> &verts, vec3f centre, SMmatrix* mtx, uint32_t start, uint32_t size, uint32_t stride)
{
uint32_t st = start*stride;
uint32_t sz = size*stride;
//Works out the bounding radius of the vertices
float rad = 0;
//TODO: This should strictly determine bounds by vertices 'used' in the scene according to polygon indices.
for (std::size_t i = st; i < (st + sz); i = stride) {
vec3f d = mtx->transformVec(vec3f(verts[i], verts[i + 1], verts[i + 2])) - centre;
float r = sqrtf(d.x*d.x + d.y*d.y + d.z*d.z);
if (r > rad) rad = r;
}
return rad;
}
SMbbox3d SMbbox3d::bboxFromTVerts(SMmatrix* mtx)
{
//Transforms a bounding box with a matrix
SMbbox3d tbox;
tbox.update(*this);
return tbox;
}
void SMbbox3d::bboxFromTVerts(std::vector<float> &verts, SMmatrix* mtx, uint32_t start, uint32_t size, uint32_t stride)
{
uint32_t st = start*stride;
uint32_t sz = size*stride;
//Assumes first three values of the vertex element is position data
min = mtx->transformVec(vec3f(verts[st], verts[st+1], verts[st+2]));
max = min;
//TODO: This should strictly determine bounds by vertices 'used' in the scene according to polygon indices.
for (std::size_t i = st; i < (st+sz); i += stride) {
vec3f tvec = mtx->transformVec(vec3f(verts[i], verts[i + 1], verts[i + 2]));
if (tvec.x < min.x) min.x = tvec.x; else if (tvec.x > max.x) max.x = tvec.x;
if (tvec.y < min.y) min.y = tvec.y; else if (tvec.y > max.y) max.y = tvec.y;
if (tvec.z < min.z) min.z = tvec.z; else if (tvec.z > max.z) max.z = tvec.z;
}
radius = radiusFromTVerts(verts, center(), mtx, start, size, stride);
}
void SMbbox3d::translate(vec3f t)
{
min += t; max += t;
}
void SMbbox3d::moveto(vec3f p)
{
vec3f bc = center();
min = (min-bc)+p;
max = (max-bc)+p;
}
| 32.22069
| 136
| 0.648545
|
timskillman
|
4d2cd2c663b134e7f69151b525afbc5308ac77b0
| 571
|
hpp
|
C++
|
include/mgard-x/MDR/Writer/WriterInterface.hpp
|
JieyangChen7/MGARD
|
acec8facae1e2767a3adff2bb3c30f3477e69bdb
|
[
"Apache-2.0"
] | null | null | null |
include/mgard-x/MDR/Writer/WriterInterface.hpp
|
JieyangChen7/MGARD
|
acec8facae1e2767a3adff2bb3c30f3477e69bdb
|
[
"Apache-2.0"
] | null | null | null |
include/mgard-x/MDR/Writer/WriterInterface.hpp
|
JieyangChen7/MGARD
|
acec8facae1e2767a3adff2bb3c30f3477e69bdb
|
[
"Apache-2.0"
] | null | null | null |
#ifndef _MDR_WRITER_INTERFACE_HPP
#define _MDR_WRITER_INTERFACE_HPP
namespace MDR {
namespace concepts {
// Refactored data writer
class WriterInterface {
public:
virtual ~WriterInterface() = default;
virtual std::vector<uint32_t> write_level_components(
const std::vector<std::vector<uint8_t *>> &level_components,
const std::vector<std::vector<uint32_t>> &level_sizes) const = 0;
virtual void write_metadata(uint8_t const *metadata, uint32_t size) const = 0;
virtual void print() const = 0;
};
} // namespace concepts
} // namespace MDR
#endif
| 24.826087
| 80
| 0.744308
|
JieyangChen7
|
4d32964fecfdc00c83931a8d29dc1b4f3875822b
| 491
|
cpp
|
C++
|
src/main.cpp
|
electromaggot/HelloVulkanSDL
|
9f63569f1b902ec761d855d6829beead01e8f72b
|
[
"Unlicense"
] | 3
|
2019-12-05T04:46:47.000Z
|
2021-09-04T23:14:27.000Z
|
src/main.cpp
|
electromaggot/HelloVulkanSDL
|
9f63569f1b902ec761d855d6829beead01e8f72b
|
[
"Unlicense"
] | 2
|
2022-02-18T10:40:12.000Z
|
2022-02-20T16:29:37.000Z
|
src/main.cpp
|
electromaggot/HelloVulkanSDL
|
9f63569f1b902ec761d855d6829beead01e8f72b
|
[
"Unlicense"
] | null | null | null |
//
// main.cpp
//
// Created 1/27/19 by Tadd Jensen
// © 0000 (uncopyrighted; use at will)
//
#include "HelloTriangle.h"
#include "AppConstants.h"
#include "Logging.h"
int main(int argc, char* argv[])
{
AppConstants.setExePath(argv[0]);
LogStartup();
HelloApplication app;
try {
app.Init();
app.Run();
} catch (const exception& e) {
const char* message = e.what();
app.DialogBox(message);
Log(RAW, "FAIL: %s", message);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
| 15.34375
| 38
| 0.653768
|
electromaggot
|
2ec179ff2601e6190d42b11645f386ca07d2a501
| 3,190
|
cpp
|
C++
|
backends/analysis/ub/ControlLattice.cpp
|
dragosdmtrsc/bf4
|
2e15e50acc4314737d99093b3d900fa44d795958
|
[
"Apache-2.0"
] | 10
|
2020-08-05T12:52:37.000Z
|
2021-05-20T02:15:04.000Z
|
backends/analysis/ub/ControlLattice.cpp
|
shellqiqi/bf4
|
6c99c8f5b0dc61cf2cb7602c9f13ada7b651703f
|
[
"Apache-2.0"
] | 4
|
2020-09-28T12:17:50.000Z
|
2021-11-23T12:23:38.000Z
|
backends/analysis/ub/ControlLattice.cpp
|
shellqiqi/bf4
|
6c99c8f5b0dc61cf2cb7602c9f13ada7b651703f
|
[
"Apache-2.0"
] | 2
|
2020-10-13T07:59:42.000Z
|
2021-12-08T21:35:05.000Z
|
//
// Created by dragos on 17.12.2019.
//
#include "ControlLattice.h"
#include "AnalysisContext.h"
namespace analysis {
ControlLattice::ControlLattice(ReferenceMap *refMap, TypeMap *typeMap,
const CFG *g, NodeToFunctionMap *funmap)
: refMap(refMap), typeMap(typeMap), cfg(g), funmap(funmap) {}
NodeValues<control_struct> ControlLattice::run() {
DefaultDiscipline dd(&cfg->holder, cfg->start_node);
auto init = this->operator()();
init.control_nodes.emplace();
NodeValues<control_struct> res({{cfg->start_node, init}});
auto rr = std::ref(*this);
WorklistAlgo<control_struct, decltype(rr), DefaultDiscipline, decltype(rr),
decltype(rr)>
algo(*cfg, rr, dd, rr, rr);
algo(cfg->start_node, res);
return std::move(res);
}
ControlLattice::Lattice ControlLattice::operator()() {
return analysis::ControlLattice::Lattice();
}
ControlLattice::Lattice ControlLattice::
operator()(node_t n, const Edge &, const ControlLattice::Lattice &l) {
if (std::any_of(instructions(n).begin(), instructions(n).end(),
[this](const IR::Node *n) {
return is_controlled(node_t(n), refMap, typeMap);
})) {
control_struct cpy;
for (auto path : l.control_nodes) {
path.push_back(n);
cpy.control_nodes.emplace(path);
}
return std::move(cpy);
}
return l;
}
ControlLattice::Lattice ControlLattice::
operator()(node_t, const Edge &, const ControlLattice::Lattice &,
const ControlLattice::Lattice &) {
BUG("should not reach this point");
}
ControlLattice::Lattice ControlLattice::
operator()(const ControlLattice::Lattice &l, ControlLattice::Lattice r) {
if (l.control_nodes.empty())
return std::move(r);
if (r.control_nodes.empty())
return l;
for (const auto &x : l.control_nodes)
r.control_nodes.emplace(x);
return std::move(r);
}
NodeValues<control_struct>
ControlLattice::controlPaths(ReferenceMap *refMap, TypeMap *typeMap,
const CFG *g, NodeToFunctionMap *funmap) {
ControlLattice controlLattice(refMap, typeMap, g, funmap);
return controlLattice.run();
}
NodeValues<control_struct>
ControlLattice::controlPaths(ReferenceMap *refMap, TypeMap *typeMap,
EdgeHolder &g, const node_t &start,
NodeToFunctionMap *funmap) {
auto cfg = new CFG(nullptr, std::move(g));
cfg->start_node = start;
auto ret = controlPaths(refMap, typeMap, cfg, funmap);
g = std::move(cfg->holder);
return std::move(ret);
}
NodeValues<NodeSet> ReachControls::run() {
DefaultDiscipline dd(&cfg->holder, cfg->start_node);
auto init = this->operator()();
NodeValues<Lattice> res({{cfg->start_node, init}});
auto rr = std::ref(*this);
WorklistAlgo<Lattice, decltype(rr), DefaultDiscipline, decltype(rr),
decltype(rr)>
algo(*cfg, rr, dd, rr, rr);
algo(cfg->start_node, res);
return std::move(res);
}
ReachControls::ReachControls(ReferenceMap *refMap, TypeMap *typeMap,
const CFG *cfg, NodeToFunctionMap *funmap)
: refMap(refMap), typeMap(typeMap), cfg(cfg), funmap(funmap) {}
}
| 32.886598
| 77
| 0.655799
|
dragosdmtrsc
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.