blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
201
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
85
| license_type
stringclasses 2
values | repo_name
stringlengths 7
100
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 260
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 11.4k
681M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 17
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 80
values | src_encoding
stringclasses 28
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 8
9.86M
| extension
stringclasses 52
values | content
stringlengths 8
9.86M
| authors
sequencelengths 1
1
| author
stringlengths 0
119
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3caaa9e04fc0ad71dd2ef571ea20460971f79668 | 844969bd953d7300f02172c867725e27b518c08e | /SDK/BP_MA_Rank12_RankDesc_functions.cpp | b1a082ecb81affa7056f6dc1331042e6c0d8b3e7 | [] | no_license | zanzo420/SoT-Python-Offset-Finder | 70037c37991a2df53fa671e3c8ce12c45fbf75a5 | d881877da08b5c5beaaca140f0ab768223b75d4d | refs/heads/main | 2023-07-18T17:25:01.596284 | 2021-09-09T12:31:51 | 2021-09-09T12:31:51 | 380,604,174 | 0 | 0 | null | 2021-06-26T22:07:04 | 2021-06-26T22:07:03 | null | UTF-8 | C++ | false | false | 546 | cpp | // Name: SoT, Version: 2.2.1.1
#include "../pch.h"
/*!!DEFINE!!*/
/*!!HELPER_DEF!!*/
/*!!HELPER_INC!!*/
#ifdef _MSC_VER
#pragma pack(push, 0x01)
#endif
namespace CG
{
//---------------------------------------------------------------------------
// Functions
//---------------------------------------------------------------------------
void UBP_MA_Rank12_RankDesc_C::AfterRead()
{
URankDesc::AfterRead();
}
void UBP_MA_Rank12_RankDesc_C::BeforeDelete()
{
URankDesc::BeforeDelete();
}
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"[email protected]"
] | |
3da6a66854aa4e5373599bf34acc9fb66300235a | 8c13efdfe4b6b3a3275c3b0fc19d0e19d2883cbf | /Competitive Programing/CodeForces/Practice/StonesOnTheTable.cpp | 63b25f9a2a378a16ef28e1d110a0e797c059534e | [] | no_license | dhananjay8968/yo-yo | e770f30a61085718ae13df6c1e6f20cb3393b575 | 5d9c9e96236d0ae20d8691697823c1f5a980ff31 | refs/heads/main | 2023-08-11T05:06:36.533040 | 2021-09-28T09:18:03 | 2021-09-28T09:18:03 | 414,197,558 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 291 | cpp | #include <bits/stdc++.h>
using namespace std ;
int main(){
int n ;
string s ;
cin>>n>>s ;
int ans,flag ;
flag = 0;
ans = 0 ;
for(int i = 1 ; i< n ; i++){
if(s[i] == s[flag]){
ans += 1 ;
}else{
flag = i ;
}
}
cout<<ans<<endl ;
return 0 ;
} | [
"[email protected]"
] | |
a28a3a01e5e9dcad87d0569e1c0c59c0e865cce7 | a4c9f0b429cc716b00caa3d78d53b59a9c02f9d6 | /DrunkenInsomnia/Scripts/BaseScript.h | 340018ef6704815edcaa2bf38b66629b9bf07c5f | [] | no_license | Zac-hills/Game_Engine | 678f12ef4fac87b9e2a08ac41b7c4edc7805b9c9 | 2ddb8cff0da3a9c9976a5be811426a4962af5a63 | refs/heads/master | 2020-08-22T18:03:29.133483 | 2020-01-01T04:30:38 | 2020-01-01T04:30:38 | 211,736,077 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 393 | h | #pragma once
#include <string>
#include <typeinfo>
class BaseScript
{
public:
virtual ~BaseScript() {};
virtual void Start() = 0;
virtual void Update() = 0;
virtual void Oncollision() {};
virtual void OnDestroy() {};
std::string ScriptName()
{
std::string Result(typeid(*this).name());
std::size_t pos = Result.find(" ");
Result = Result.substr(pos + 1);
return Result;
}
}; | [
"[email protected]"
] | |
703f73afc08cac57c6d7e08b34214e07bb36176f | aa5e9defea373d64d75336fc6c5a03124e24abbd | /tools/python/Helpers/GILHelpers.h | 2772b510abc4d0845c69acbeb7d2b180e49161c0 | [
"MIT"
] | permissive | esayui/mworks | e8ae5d8b07d36d5bbdec533a932d29641f000eb9 | 0522e5afc1e30fdbf1e67cedd196ee50f7924499 | refs/heads/master | 2022-02-18T03:47:49.858282 | 2019-09-04T16:42:52 | 2019-09-05T13:55:06 | 208,943,825 | 0 | 0 | MIT | 2019-09-17T02:43:38 | 2019-09-17T02:43:38 | null | UTF-8 | C++ | false | false | 849 | h | //
// GILHelpers.h
// PythonTools
//
// Created by Christopher Stawarz on 11/15/12.
// Copyright (c) 2012 MWorks Project. All rights reserved.
//
#ifndef PythonTools_GILHelpers_h
#define PythonTools_GILHelpers_h
BEGIN_NAMESPACE_MW_PYTHON
class ScopedGILAcquire : boost::noncopyable {
private:
PyGILState_STATE state;
public:
ScopedGILAcquire() :
state(PyGILState_Ensure())
{ }
~ScopedGILAcquire() {
PyGILState_Release(state);
}
};
class ScopedGILRelease : boost::noncopyable {
private:
PyThreadState *state;
public:
ScopedGILRelease() :
state(PyEval_SaveThread())
{ }
~ScopedGILRelease() {
PyEval_RestoreThread(state);
}
};
END_NAMESPACE_MW_PYTHON
#endif /* !defined(PythonTools_GILHelpers_h) */
| [
"[email protected]"
] | |
9a321a8e0a54fec00d97fa082ed499d7d268c2a7 | 15a108da5fa29094b79574bbadb6d8a0b5b7d202 | /avinash/Untitled1.cpp | 122103f62180f093d2210f979c12812bbf18f9dc | [] | no_license | deepak12cs46/Data-Structure-Lab | fdaf938c5992f37af983941e042d92a8aa2c2302 | 3c58cd91d21d186459df7d732415e9767ff4b1d0 | refs/heads/master | 2016-09-12T10:16:00.136740 | 2016-04-23T13:56:02 | 2016-04-23T13:56:02 | 56,920,734 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 579 | cpp | #include<stdio.h>
void bs(int n,int *k);
void main()
{
int n,i,j,k[50];
printf("\n total no of elements=\t");
scanf("%d",&n);
i=0;
while(i<n)
{
printf("\n element\t=");
scanf("%d",&k[i]);
i++;
}
printf("\n the elements obtained after sorting are:");
bs(n,k);
i=0;
while(i<n)
{
printf("%d\t",k[i]);
i++;
}
}
void bs(int n, int *k)
{
int temp,i=0;
int last=n,flag=0,pass=1;
while(i<=last-2)
{
if(k[i]>k[i+1])
{
temp=k[i];
k[i]=k[i+1];
k[i+1]=temp;
flag=flag+1;
}
i++;
}
if(flag!=0)
{
last=last-1;
flag=0;
}
pass=pass+1;
}
| [
"[email protected]"
] | |
74491e5800dc1c11e96b598a2f4a41b06fdc5681 | c91601bc25d1aeacde85f540765cc01c185f6a75 | /.scripts/node_modules/nodegit/include/oid.h | 2ce3a9e5c034f916e4afe355edaf3ffc2373900a | [
"MIT"
] | permissive | imjorge/dotfiles-1 | 4cff4f7618302019fd41ef6231b711265f48d52f | bb231a2b4ac5fa4eac2955210f115551c02d7943 | refs/heads/master | 2021-01-16T21:56:22.599455 | 2015-05-16T21:37:18 | 2015-05-16T21:37:22 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 717 | h | /**
* This code is auto-generated; unless you know what you're doing, do not modify!
**/
#ifndef GITOID_H
#define GITOID_H
#include <v8.h>
#include <node.h>
#include <string>
#include "git2.h"
using namespace node;
using namespace v8;
class GitOid : public ObjectWrap {
public:
static Persistent<Function> constructor_template;
static void Initialize (Handle<v8::Object> target);
git_oid *GetValue();
static Handle<Value> New(void *raw);
private:
GitOid(git_oid *raw);
~GitOid();
static Handle<Value> New(const Arguments& args);
static Handle<Value> FromString(const Arguments& args);
static Handle<Value> Sha(const Arguments& args);
git_oid *raw;
};
#endif
| [
"[email protected]"
] | |
a42824e7d1d794ff083b73d45c6acdf2c18a8cc7 | 942b88e59417352fbbb1a37d266fdb3f0f839d27 | /src/XP/tilemap.hxx | b11c6d99b1072bcf581468f5b899124a10c33247 | [
"BSD-2-Clause"
] | permissive | take-cheeze/ARGSS... | 2c1595d924c24730cc714d017edb375cfdbae9ef | 2f2830e8cc7e9c4a5f21f7649287cb6a4924573f | refs/heads/master | 2016-09-05T15:27:26.319404 | 2010-12-13T09:07:24 | 2010-12-13T09:07:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,675 | hxx | //////////////////////////////////////////////////////////////////////////////////
/// ARGSS - Copyright (c) 2009 - 2010, Alejandro Marzini (vgvgf)
/// 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.
///
/// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''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 AUTHOR BE LIABLE FOR ANY
/// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
/// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
/// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
/// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
/// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
/// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//////////////////////////////////////////////////////////////////////////////////
#ifndef _TILEMAP_XP_HXX_
#define _TILEMAP_XP_HXX_
////////////////////////////////////////////////////////////
/// Headers
////////////////////////////////////////////////////////////
#include <boost/ptr_container/ptr_map.hpp>
#include <map>
#include <string>
#include <vector>
#include "bitmap.hxx"
#include "drawable.hxx"
////////////////////////////////////////////////////////////
/// Tilemap class
////////////////////////////////////////////////////////////
class Tilemap : public Drawable
{
public:
Tilemap(VALUE iid);
~Tilemap();
static void Init();
static bool IsDisposed(VALUE id);
static void New(VALUE id);
static Tilemap& get(VALUE id);
static void Dispose(VALUE id);
void RefreshBitmaps();
void draw(long z);
void draw(long z, Bitmap const& dst_bitmap);
void RefreshData();
void Update();
VALUE getViewport() const { return viewport; }
void setViewport(VALUE nviewport);
VALUE getTileset() const { return tileset; }
void setTileset(VALUE ntileset) { tileset = ntileset; }
VALUE getMapData() const { return map_data; }
void setMapData(VALUE nmap_data);
VALUE getFlashData() const { return flash_data; }
void setFlashData(VALUE nflash_data) { flash_data = nflash_data; }
VALUE getPriorities() const { return priorities; }
void setPriorities(VALUE npriorities);
bool getVisible() const { return visible; }
void setVisible(bool nvisible) { visible = nvisible; }
int getOx() const { return ox_; }
int getOy() const { return oy_; }
void setOx(int nox) { ox_ = nox; }
void setOy(int noy) { oy_ = noy; }
private:
VALUE id;
VALUE viewport;
VALUE tileset;
VALUE autotiles;
VALUE map_data;
VALUE flash_data;
VALUE priorities;
bool visible;
int ox_;
int oy_;
int autotile_frame;
int autotile_time;
std::map< VALUE, std::map< int, boost::ptr_map<int, Bitmap> > > autotiles_cache;
static int autotiles_id[6][8][4];
struct TileData {
int id;
int priority;
};
std::vector< std::vector< std::vector<TileData> > > data_cache;
}; // class Tilemap
#endif // _TILEMAP_XP_HXX_
| [
"[email protected]"
] | |
84e734d28b21bf3e6e76ded47baeb249c59932b1 | 32c08e26251826be78ac341835b7f7730f4f9d5a | /Robot/Arduino/motorAndPing/motorAndPing.ino | b0a5cbfb70f2ffd8419ae590eb97b249025a8f07 | [] | no_license | loenne/homeAutomation | 06e416e434be81abdff660ebff286a8e479b5e12 | a0f7263c6f5ebecf13101279340564ec3e2377de | refs/heads/master | 2023-01-13T19:47:14.367615 | 2018-12-25T13:16:38 | 2019-05-21T19:24:48 | 62,961,917 | 0 | 1 | null | 2022-12-21T06:58:30 | 2016-07-09T17:52:25 | Python | UTF-8 | C++ | false | false | 2,568 | ino | #include <Servo.h> // Use Servo library, included with IDE
Servo myServo; // Create Servo object to control the servo
// pin number of the ping sensor's output:
const int pingPin = 7;
// pin number of the server motor output:
const int motorPin = 3;
//Number of positions to measure
const int noOfPositions = 4;
void setup() {
// initialize serial communication:
Serial.begin(9600);
// Servo is connected to digital pin 9
myServo.attach(motorPin);
}
void loop() {
int times = noOfPositions;
myLoop(times);
}
void myLoop(int times)
{
// Servo rotation sequence.
long values[] = {90,180,90,0};
for (int i=0; i < times; i++)
{
measureDistance();
rotate(values[i]);
}
}
void rotate(long angle)
{
myServo.write(angle); // Rotate servo counter clockwise
delay(1000); // Wait 2 seconds
}
void measureDistance()
{
long duration;
duration = fetchValues();
printValues(duration);
delay(1000);
}
void printValues(long duration)
{
long inches, cm;
// convert the time into a distance
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
}
long fetchValues()
{
// The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin, LOW);
// The same pin is used to read the signal from the PING))): a HIGH
// pulse whose duration is the time (in microseconds) from the sending
// of the ping to the reception of its echo off of an object.
pinMode(pingPin, INPUT);
return pulseIn(pingPin, HIGH);
}
long microsecondsToInches(long microseconds)
{
// According to Parallax's datasheet for the PING))), there are
// 73.746 microseconds per inch (i.e. sound travels at 1130 feet per
// second). This gives the distance travelled by the ping, outbound
// and return, so we divide by 2 to get the distance of the obstacle.
// See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf
return microseconds / 74 / 2;
}
long microsecondsToCentimeters(long microseconds)
{
// The speed of sound is 340 m/s or 29 microseconds per centimeter.
// The ping travels out and back, so to find the distance of the
// object we take half of the distance travelled.
return microseconds / 29 / 2;
}
| [
"[email protected]"
] | |
ee3688c7188579b913c4db05685d2964358ea3d9 | d25d74bad8c68ac8f2a29a22c6d6860290185254 | /lc1281prdSum.cpp | 3182a7f09b35bbbf7d65228c7676e87daff18a4c | [] | no_license | ZhongZeng/Leetcode | 9b7e71838ff4ad80a6b85f680f449e53df24c5d2 | a16f8ea31c8af1a3275efcf234989da19ba1581e | refs/heads/master | 2021-07-14T19:32:49.911530 | 2021-03-29T04:25:54 | 2021-03-29T04:25:54 | 83,813,978 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 574 | cpp | /*
1281. Subtract the Product and Sum of Digits of an Integer
Ranking of Weekly Contest 166
Rank Name Score Finish Time Q1 (3) Q2 (4) Q3 (5) Q4 (6)
1318 / 5585 zhongzeng 12 0:41:49 0:02:21 0:11:25 0:36:49 1
Companies Quora
Related Topics Math
Test Cases:
234
4421
Runtime: 4 ms
Memory Usage: 8.1 MB
*/
class Solution {
public:
int subtractProductAndSum(int n) {
int pd=1, sum=0;
for( int m=n; 0<m; m=m/10){
int d=m%10;
pd*=d;
sum+=d;
}
return pd-sum;
}
}; | [
"[email protected]"
] | |
da4331b55a3700531852dcb3ac18c4dacc7f8037 | 0efeeca80d27807904878094a955c86c7a548520 | /DFS/Tree/Programs/MINHEAP.CPP | 2f8d118a028bfd16819b84e1da0abd15bf833e9f | [] | no_license | dhruv7294/DataStructure | d5bdd33336812d63dc36cd748579232cd64fedf0 | afa967a333d48bebdc0bcce02a24c0d814e797f5 | refs/heads/master | 2016-08-11T11:28:54.260844 | 2016-01-12T00:14:31 | 2016-01-12T00:14:31 | 49,409,574 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,107 | cpp | /* Program togenerate MIN Heap (insertion and deletion) */
#include <stdio.h>
#include<conio.h>
#include<stdlib.h>
int arr[100],n;
void insert(int,int);
void display();
void del(int);
void main()
{
int choice,num;
n=0;/*Represents number of nodes in the heap*/
while(1)
{
clrscr();
printf("1.Insert\n");
printf("2.Delete\n");
printf("3.Display\n");
printf("4.Quit\n");
printf("Enter your choice : ");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("Enter the number to be inserted : ");
scanf("%d",&num);
insert(num,n);
n=n+1;
break;
case 2:
printf("Enter the number to be deleted : ");
scanf("%d",&num);
del(num);
getch();
break;
case 3:
display();
getch();
break;
case 4:
exit(0);
default:
printf("Wrong choice\n");
}/*End of switch */
}/*End of while */
}/*End of main()*/
void display()
{ int i;
if(n==0)
{
printf("Heap is empty\n");
return;
}
for(i=0;i<n;i++)
printf("%d ",arr[i]);
printf("\n");
}/*End of display()*/
void insert(int num,int loc)
{
int par;
while(loc>0)
{
par=(loc-1)/2;
if(num>=arr[par])
{
arr[loc]=num;
return;
}
arr[loc]=arr[par];
loc=par;
}/*End of while*/
arr[0]=num; /*assign num to the root node */
}/*End of insert()*/
void del(int num)
{
int left,right,i,temp,par;
for(i=0;i<n;i++)
{
if(num==arr[i])
break;
}
if( num!=arr[i] )
{
printf("%d not found in heap\n",num);
return;
}
arr[i]=arr[n-1];
n=n-1;
par=(i-1)/2; /*find parent of node i */
if(arr[i] < arr[par])
{
insert( arr[i],i);
return;
}
left=2*i+1; /*left child of i*/
right=2*i+2; /* right child of i*/
while(right < n)
{
if( arr[i]<=arr[left] && arr[i]<=arr[right] )
return;
if( arr[right]>=arr[left] )
{
temp=arr[i];
arr[i]=arr[left];
arr[left]=temp;
i=left;
}
else
{
temp=arr[i];
arr[i]=arr[right];
arr[right]=temp;
i=right;
}
left=2*i+1;
right=2*i+2;
}/*End of while*/
if( left==n-1 && arr[i]>arr[left] ) /* right==n */
{ temp=arr[i];
arr[i]=arr[left];
arr[left]=temp;
}
}/*End of del()*/
| [
"[email protected]"
] | |
ba798b9a9b02ba311494b2d01a76cb171ef1bac7 | c820ba679d2834d73375bd85f6195e4cbcec347c | /Engine/Renderer/OpenGL/Renderer.cpp | c077fafccf961c4525186462b59c962b48ffdb10 | [
"MIT"
] | permissive | oTreasureo47/ZeloEngine | fe5c24e96d0270d846b6d94a197f768c29010aa6 | 806d12c3de7eb7f8dbe46a2d0a9679d0fcdd453f | refs/heads/master | 2023-06-02T23:40:53.590661 | 2021-06-27T17:30:20 | 2021-06-27T17:30:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 116 | cpp | // Renderer.cpp
// created on 2021/4/3
// author @zoloypzuo
#include "ZeloPreCompiledHeader.h"
#include "Renderer.h" | [
"[email protected]"
] | |
e094f5b9c77e5acf82e7c783ed48ee97d40fc04a | a46bd784eb64b40226108a628d89ecf03511be8b | /Matrix.h | 8ff9e218020eefe5f121371e9a69d63ab9d11021 | [] | no_license | sanjitmuth/Matrix | 09034039d73dda1612a9c946155823642b0a47da | 634ee4a142be5d5b3af25be0a856ac78bace652b | refs/heads/master | 2023-06-18T20:42:35.358333 | 2021-07-15T20:41:09 | 2021-07-15T20:41:09 | 386,418,547 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,797 | h | #ifndef MATRIX_H
#define MATRIX_H
#include <ostream>
#include <cstdlib>
typedef unsigned int uint;
using namespace std;
class Matrix {
public:
Matrix(uint rows, uint cols);
Matrix(double** values, int w, int h);
Matrix(const Matrix & m);
~Matrix();
Matrix add(double s) const;
Matrix add(const Matrix & m) const;
Matrix subtract(double s) const;
Matrix subtract(const Matrix & m) const;
Matrix multiply(double s) const;
Matrix multiply(const Matrix & m) const;
Matrix divide(double s) const;
Matrix t() const;
const uint numRows() const;
const uint numCols() const;
double & at(uint row, uint col); // get/set element at row,col
const double & at (uint row, uint col) const; // get element at row,col (when using a const object)
double & operator()(uint row, uint col);
Matrix & operator=(const Matrix & param);
Matrix operator-();
friend Matrix operator+(const Matrix& left, double right);
friend Matrix operator+(double left, const Matrix& right);
friend Matrix operator+(const Matrix& left, const Matrix& right);
friend Matrix operator-(const Matrix& left, double right);
friend Matrix operator-(double left, const Matrix& right);
friend Matrix operator-(const Matrix& left, const Matrix& right);
friend Matrix operator*(const Matrix& left, double right);
friend Matrix operator*(double left, const Matrix& right);
friend Matrix operator*(const Matrix& left, const Matrix& right);
friend Matrix operator/(const Matrix& left, double right);
friend Matrix operator/(double left, const Matrix& right);
friend ostream& operator<<(ostream& output, const Matrix& right);
private:
uint rows;
uint cols;
double ** values;
}; // Matrix
#endif
| [
"[email protected]"
] | |
96630429bd44d0ab1bd9804e6978d778c5ee1827 | b090f823c5ac849cddd9d2eae089240c2f37ca1c | /LINT_00201_SegmentTreeBuild.cpp | 6a796891d9640c21d0c9242cff4a448e242cd463 | [] | no_license | jordandong/mylintcodes | e7766eb93ca3dbde250173e0dd41f59fe1cd95a6 | 11fdca00ef7c41872819f603850fce531c6ab13e | refs/heads/master | 2021-04-19T01:47:00.794336 | 2018-02-10T05:40:49 | 2018-02-10T05:40:49 | 27,663,620 | 3 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 2,051 | cpp | /*
The structure of Segment Tree is a binary tree which each node has two attributes start and end denote an segment / interval.
start and end are both integers, they should be assigned in following rules:
The root's start and end is given by build method.
The left child of node A has start=A.left, end=(A.left + A.right) / 2.
The right child of node A has start=(A.left + A.right) / 2, end=A.right.
if start equals to end, there will be no children for this node.
Implement a build method with two parameters start and end, so that we can create a corresponding segment tree with every node has the correct start and end value, return the root of this segment tree.
Example
Given start=1, end=6. The segment tree will be:
[1, 6]
/ \
[1, 3] [4, 6]
/ \ / \
[1, 2] [3,3] [4, 5] [6,6]
/ \ / \
[1,1] [2,2] [4,4] [5,5]
Clarification
Segment Tree (a.k.a Interval Tree) is an advanced data structure which can support queries like:
which of these intervals contain a given point
which of these points are in a given interval
See wiki: Segment Tree Interval Tree
Tags Expand
LintCode Copyright Binary Tree Segment Tree
*/
/**
* Definition of SegmentTreeNode:
* class SegmentTreeNode {
* public:
* int start, end;
* SegmentTreeNode *left, *right;
* SegmentTreeNode(int start, int end) {
* this->start = start, this->end = end;
* this->left = this->right = NULL;
* }
* }
*/
class Solution {
public:
/**
*@param start, end: Denote an segment / interval
*@return: The root of Segment Tree
*/
SegmentTreeNode * build(int start, int end) {
// write your code here
if(start > end)
return NULL;
SegmentTreeNode *s = new SegmentTreeNode(start, end);
if(start == end)
return s;
s->left = build(start, start + (end - start)/2);
s->right = build(start + (end - start)/2 + 1, end);
return s;
}
};
| [
"[email protected]"
] | |
fa7a3534440e798e6d941a0e0b1e30bec59e52f2 | 302f4bda84739593ab952f01c9e38d512b0a7d73 | /ext/Vc-1.3.2/avx/simd_cast_caller.tcc | 405abce186a9df016dc134a7c27a925bb13e188c | [
"BSD-3-Clause",
"LicenseRef-scancode-free-unknown",
"Apache-2.0",
"ICU",
"BSL-1.0",
"X11",
"Beerware"
] | permissive | thomaskrause/graphANNIS | 649ae23dd74b57bcd8a699c1e309e74096be9db2 | 66d12bcfb0e0b9bfcdc2df8ffaa5ae8c84cc569c | refs/heads/develop | 2020-04-11T01:28:47.589724 | 2018-03-15T18:16:50 | 2018-03-15T18:16:50 | 40,169,698 | 9 | 3 | Apache-2.0 | 2018-07-28T20:18:41 | 2015-08-04T07:24:49 | C++ | UTF-8 | C++ | false | false | 2,211 | tcc | /* This file is part of the Vc library. {{{
Copyright © 2014-2015 Matthias Kretz <[email protected]>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the names of contributing organizations nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
}}}*/
#ifndef Vc_AVX_SIMD_CAST_CALLER_TCC_
#define Vc_AVX_SIMD_CAST_CALLER_TCC_
#include "macros.h"
namespace Vc_VERSIONED_NAMESPACE
{
#if Vc_IS_VERSION_1
template <typename T>
template <typename U, typename>
Vc_INTRINSIC Vector<T, VectorAbi::Avx>::Vector(U &&x)
: d(simd_cast<Vector>(std::forward<U>(x)).data())
{
}
template <typename T>
template <typename U>
Vc_INTRINSIC Mask<T, VectorAbi::Avx>::Mask(U &&rhs,
Common::enable_if_mask_converts_explicitly<T, U>)
: Mask(simd_cast<Mask>(std::forward<U>(rhs)))
{
}
#endif // Vc_IS_VERSION_1
}
#endif // Vc_AVX_SIMD_CAST_CALLER_TCC_
// vim: foldmethod=marker
| [
"[email protected]"
] | |
ccea4194ffb6d9043b994483585f14822dde85ff | 36eb2f9d3ffad120a0f731b0ca049bda76fab1c6 | /GNS Wyd Server/Source GNS Wyd Server/oxablod1/Fix_AddPoint.cpp | e3f6e3c4b78ca7e48b1b9a28c8405ec354fe3bc6 | [] | no_license | reon/GnsWydServer | 01032b7ed89827088319168d214a6ef639aa3a7c | 33168296c8a764d31a03436635e2d642686e0f88 | refs/heads/master | 2021-01-22T17:02:58.861541 | 2015-01-27T03:13:57 | 2015-01-27T03:13:57 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,715 | cpp | #include "Stdafx.h"
int PontosADC(char *Data)
{
if(*(short*)&Data[0] != 0x14)
{
return FALSE;
}
if(*(short*)&Data[11] != 0x10 && *(short*)&Data[12] != 0x0 && *(short*)&Data[13] != 0x0)
{
return FALSE;
}
if(*(short*)&Data[15] != 0x0 && *(short*)&Data[16] != 0x0 && *(short*)&Data[17] != 0x0)
{
return FALSE;
}
p277 *p = (p277*)Data; WORD clientid;
memcpy(&clientid, &Data[6], 2);
st_Mob *player = (st_Mob*)GetMobFromIndex(clientid);
WORD Info;
memcpy(&Info,&Data[14],2);
switch(p->Mode)
{
case 0:
switch(Info)
{
case 00: // STR
if(player->StatusPoint >= 201)
{
player->StatusPoint -= 99;
player->bStatus.STR += 99;
GetHPMP(clientid);
GetCurrentScore(clientid);
SendStats(clientid);
SendScore(clientid);
return TRUE;
}
break;
case 01: // INT
if(player->StatusPoint >= 201)
{
player->StatusPoint -= 99;
player->bStatus.INT += 99;
GetHPMP(clientid);
GetCurrentScore(clientid);
SendStats(clientid);
SendScore(clientid);
return TRUE;
}
break;
case 02://DEX
if(player->StatusPoint >= 201)
{
player->StatusPoint -= 99;
player->bStatus.DEX += 99;
player->bStatus.Attack += 100 / 4;
GetHPMP(clientid);
GetCurrentScore(clientid);
SendStats(clientid);
SendScore(clientid);
return TRUE;
}
if(player->bStatus.DEX % 4 == 0) player->bStatus.Attack += 1;
break;
case 03://CON
if(player->StatusPoint >= 201)
{
player->StatusPoint -= 99;
player->bStatus.CON += 99;
GetHPMP(clientid);
GetCurrentScore(clientid);
SendStats(clientid);
SendScore(clientid);
return TRUE;
}
break;
}
}
return FALSE;
} | [
"[email protected]"
] | |
1009358deb1a6f27c810b467c209b807330c48fa | 25079f11aa1b0a60e254a8cac274caad22514cc9 | /d_lake2.0/Player.h | 4efc4dd5e3ce61244cbab8d929512bdf8e16cc7a | [] | no_license | marchenko2k16/DLAKE2 | df7e03dcebd38af569cdbcbe188c7c33e6ac09c7 | 13988fef7cd9503137a79f320007c6fad26d867c | refs/heads/master | 2020-04-11T17:15:22.957471 | 2018-12-21T00:47:00 | 2018-12-21T00:47:00 | 161,953,662 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 348 | h | #pragma once
#include "VisibleObject.h"
#include "Gun.h"
class Player :
public VisibleObject
{
public:
enum { ALIVE, DEAD } State;
void move(float _dirX, float _dirY, float _dTime) override;
void update(float _dirX, float _dirY, float _dTime) override;
Player(Sprite* _sprite, float _currentX, float _currentY, float _speed);
~Player();
};
| [
"[email protected]"
] | |
dbb913aacc553b5b8658781f3a99a959a37b2162 | 8f85caef333269bbe561cc86912cc5bc57fb80e7 | /tools/editor/spatial_editor_gizmos.cpp | 8ec291406105a3749ae8212e87e212242865115d | [
"MIT"
] | permissive | x1212/godot4pandora | 737d1b46398fbaff0edb5665c62e9fe540f2dfcd | 06714f02d1214f78853ceaf44d48974c38d524fd | refs/heads/master | 2021-01-10T20:47:56.355013 | 2014-02-28T17:02:11 | 2014-02-28T17:02:11 | 17,290,821 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 59,757 | cpp | /*************************************************************************/
/* spatial_editor_gizmos.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 "spatial_editor_gizmos.h"
#include "geometry.h"
#include "scene/3d/camera.h"
#include "scene/resources/surface_tool.h"
#include "scene/resources/sphere_shape.h"
#include "scene/resources/box_shape.h"
#include "scene/resources/capsule_shape.h"
#include "scene/resources/ray_shape.h"
#include "scene/resources/convex_polygon_shape.h"
#include "scene/resources/plane_shape.h"
#include "editor_shape_gizmos.h"
// Keep small children away from this file.
// It's so ugly it will eat them alive
#define HANDLE_HALF_SIZE 0.05
void SpatialGizmoTool::clear() {
for(int i=0;i<instances.size();i++) {
if (instances[i].instance.is_valid())
VS::get_singleton()->free(instances[i].instance);
}
collision_segments.clear();
collision_mesh=Ref<TriangleMesh>();
instances.clear();
handles.clear();
secondary_handles.clear();
}
void SpatialGizmoTool::Instance::create_instance(Spatial *p_base) {
instance = VS::get_singleton()->instance_create2(mesh->get_rid(),p_base->get_world()->get_scenario());
VS::get_singleton()->instance_attach_object_instance_ID(instance,p_base->get_instance_ID());
if (billboard)
VS::get_singleton()->instance_geometry_set_flag(instance,VS::INSTANCE_FLAG_BILLBOARD,true);
if (unscaled)
VS::get_singleton()->instance_geometry_set_flag(instance,VS::INSTANCE_FLAG_DEPH_SCALE,true);
if (skeleton.is_valid())
VS::get_singleton()->instance_attach_skeleton(instance,skeleton);
if (extra_margin)
VS::get_singleton()->instance_set_extra_visibility_margin(instance,1);
VS::get_singleton()->instance_geometry_set_flag(instance,VS::INSTANCE_FLAG_CAST_SHADOW,false);
VS::get_singleton()->instance_geometry_set_flag(instance,VS::INSTANCE_FLAG_RECEIVE_SHADOWS,false);
}
void SpatialGizmoTool::add_mesh(const Ref<Mesh>& p_mesh,bool p_billboard, const RID &p_skeleton) {
ERR_FAIL_COND(!spatial_node);
Instance ins;
ins.billboard=p_billboard;
ins.mesh=p_mesh;
ins.skeleton=p_skeleton;
if (valid) {
ins.create_instance(spatial_node);
VS::get_singleton()->instance_set_transform(ins.instance,spatial_node->get_global_transform());
}
instances.push_back(ins);
}
void SpatialGizmoTool::add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material,bool p_billboard){
ERR_FAIL_COND(!spatial_node);
Instance ins;
Ref<Mesh> mesh = memnew( Mesh );
Array a;
a.resize(Mesh::ARRAY_MAX);
a[Mesh::ARRAY_VERTEX]=p_lines;
mesh->add_surface(Mesh::PRIMITIVE_LINES,a);
mesh->surface_set_material(0,p_material);
ins.billboard=p_billboard;
ins.mesh=mesh;
if (valid) {
ins.create_instance(spatial_node);
VS::get_singleton()->instance_set_transform(ins.instance,spatial_node->get_global_transform());
}
instances.push_back(ins);
}
void SpatialGizmoTool::add_unscaled_billboard(const Ref<Material>& p_material,float p_scale) {
ERR_FAIL_COND(!spatial_node);
Instance ins;
Vector<Vector3 > vs;
Vector<Vector2 > uv;
vs.push_back(Vector3(-p_scale,p_scale,0));
vs.push_back(Vector3(p_scale,p_scale,0));
vs.push_back(Vector3(p_scale,-p_scale,0));
vs.push_back(Vector3(-p_scale,-p_scale,0));
uv.push_back(Vector2(1,0));
uv.push_back(Vector2(0,0));
uv.push_back(Vector2(0,1));
uv.push_back(Vector2(1,1));
Ref<Mesh> mesh = memnew( Mesh );
Array a;
a.resize(Mesh::ARRAY_MAX);
a[Mesh::ARRAY_VERTEX]=vs;
a[Mesh::ARRAY_TEX_UV]=uv;
mesh->add_surface(Mesh::PRIMITIVE_TRIANGLE_FAN,a);
mesh->surface_set_material(0,p_material);
ins.mesh=mesh;
ins.unscaled=true;
ins.billboard=true;
if (valid) {
ins.create_instance(spatial_node);
VS::get_singleton()->instance_set_transform(ins.instance,spatial_node->get_global_transform());
}
instances.push_back(ins);
}
void SpatialGizmoTool::add_collision_triangles(const Ref<TriangleMesh>& p_tmesh) {
collision_mesh=p_tmesh;
}
void SpatialGizmoTool::add_collision_segments(const Vector<Vector3> &p_lines) {
int from=collision_segments.size();
collision_segments.resize(from+p_lines.size());
for(int i=0;i<p_lines.size();i++) {
collision_segments[from+i]=p_lines[i];
}
}
void SpatialGizmoTool::add_handles(const Vector<Vector3> &p_handles, bool p_billboard,bool p_secondary){
ERR_FAIL_COND(!spatial_node);
ERR_FAIL_COND(!spatial_node);
Instance ins;
billboard_handle=p_billboard;
Ref<Mesh> mesh = memnew( Mesh );
#if 1
Array a;
a.resize(VS::ARRAY_MAX);
a[VS::ARRAY_VERTEX]=p_handles;
mesh->add_surface(Mesh::PRIMITIVE_POINTS,a);
mesh->surface_set_material(0,SpatialEditorGizmos::singleton->handle2_material);
#else
for(int ih=0;ih<p_handles.size();ih++) {
Vector<Vector3> vertices;
Vector<Vector3> normals;
int vtx_idx=0;
#define ADD_VTX(m_idx);\
vertices.push_back( (face_points[m_idx]*HANDLE_HALF_SIZE+p_handles[ih]) );\
normals.push_back( normal_points[m_idx] );\
vtx_idx++;\
for (int i=0;i<6;i++) {
Vector3 face_points[4];
Vector3 normal_points[4];
float uv_points[8]={0,0,0,1,1,1,1,0};
for (int j=0;j<4;j++) {
float v[3];
v[0]=1.0;
v[1]=1-2*((j>>1)&1);
v[2]=v[1]*(1-2*(j&1));
for (int k=0;k<3;k++) {
if (i<3)
face_points[j][(i+k)%3]=v[k]*(i>=3?-1:1);
else
face_points[3-j][(i+k)%3]=v[k]*(i>=3?-1:1);
}
normal_points[j]=Vector3();
normal_points[j][i%3]=(i>=3?-1:1);
}
//tri 1
ADD_VTX(0);
ADD_VTX(1);
ADD_VTX(2);
//tri 2
ADD_VTX(2);
ADD_VTX(3);
ADD_VTX(0);
}
Array d;
d.resize(VS::ARRAY_MAX);
d[VisualServer::ARRAY_NORMAL]= normals ;
d[VisualServer::ARRAY_VERTEX]= vertices ;
mesh->add_surface(Mesh::PRIMITIVE_TRIANGLES,d);
mesh->surface_set_material(ih,SpatialEditorGizmos::singleton->handle_material);
}
#endif
ins.mesh=mesh;
ins.billboard=p_billboard;
ins.extra_margin=true;
if (valid) {
ins.create_instance(spatial_node);
VS::get_singleton()->instance_set_transform(ins.instance,spatial_node->get_global_transform());
}
instances.push_back(ins);
if (!p_secondary) {
int chs=handles.size();
handles.resize(chs+p_handles.size());
for(int i=0;i<p_handles.size();i++) {
handles[i+chs]=p_handles[i];
}
} else {
int chs=secondary_handles.size();
secondary_handles.resize(chs+p_handles.size());
for(int i=0;i<p_handles.size();i++) {
secondary_handles[i+chs]=p_handles[i];
}
}
}
void SpatialGizmoTool::set_spatial_node(Spatial *p_node){
spatial_node=p_node;
}
bool SpatialGizmoTool::intersect_frustum(const Camera *p_camera,const Vector<Plane> &p_frustum) {
ERR_FAIL_COND_V(!spatial_node,false);
ERR_FAIL_COND_V(!valid,false);
if (collision_segments.size()) {
const Plane *p=p_frustum.ptr();
int fc=p_frustum.size();
int vc=collision_segments.size();
const Vector3* vptr=collision_segments.ptr();
Transform t = spatial_node->get_global_transform();
for(int i=0;i<vc/2;i++) {
Vector3 a=t.xform(vptr[i*2+0]);
Vector3 b=t.xform(vptr[i*2+1]);
bool any_out=false;
for(int j=0;j<fc;j++) {
if (p[j].distance_to(a) > 0 && p[j].distance_to(b) >0) {
any_out=true;
break;
}
}
if (!any_out)
return true;
}
return false;
}
return false;
}
bool SpatialGizmoTool::intersect_ray(const Camera *p_camera,const Point2& p_point, Vector3& r_pos, Vector3& r_normal,int *r_gizmo_handle,bool p_sec_first) {
ERR_FAIL_COND_V(!spatial_node,false);
ERR_FAIL_COND_V(!valid,false);
if (r_gizmo_handle) {
Transform t = spatial_node->get_global_transform();
t.orthonormalize();
if (billboard_handle) {
t.set_look_at(t.origin,t.origin+p_camera->get_transform().basis.get_axis(2),p_camera->get_transform().basis.get_axis(1));
}
Transform ti=t.affine_inverse();
Vector3 ray_from=ti.xform(p_camera->project_ray_origin(p_point));
Vector3 ray_dir=t.basis.xform_inv(p_camera->project_ray_normal(p_point)).normalized();
Vector3 ray_to = ray_from+ray_dir*4096;
float min_d=1e20;
int idx=-1;
for(int i=0;i<secondary_handles.size();i++) {
#if 1
Vector3 hpos = t.xform(secondary_handles[i]);
Vector2 p = p_camera->unproject_position(hpos);
if (p.distance_to(p_point)<SpatialEditorGizmos::singleton->handle_t->get_width()*0.6) {
real_t dp = p_camera->get_transform().origin.distance_to(hpos);
if (dp<min_d) {
r_pos=t.xform(hpos);
r_normal=p_camera->get_transform().basis.get_axis(2);
min_d=dp;
idx=i+handles.size();
}
}
#else
AABB aabb;
aabb.pos=Vector3(-1,-1,-1)*HANDLE_HALF_SIZE;
aabb.size=aabb.pos*-2;
aabb.pos+=secondary_handles[i];
Vector3 rpos,rnorm;
if (aabb.intersects_segment(ray_from,ray_to,&rpos,&rnorm)) {
real_t dp = ray_dir.dot(rpos);
if (dp<min_d) {
r_pos=t.xform(rpos);
r_normal=ti.basis.xform_inv(rnorm).normalized();
min_d=dp;
idx=i+handles.size();
}
}
#endif
}
if (p_sec_first && idx!=-1) {
*r_gizmo_handle=idx;
return true;
}
min_d=1e20;
for(int i=0;i<handles.size();i++) {
#if 1
Vector3 hpos = t.xform(handles[i]);
Vector2 p = p_camera->unproject_position(hpos);
if (p.distance_to(p_point)<SpatialEditorGizmos::singleton->handle_t->get_width()*0.6) {
real_t dp = p_camera->get_transform().origin.distance_to(hpos);
if (dp<min_d) {
r_pos=t.xform(hpos);
r_normal=p_camera->get_transform().basis.get_axis(2);
min_d=dp;
idx=i;
}
}
#else
AABB aabb;
aabb.pos=Vector3(-1,-1,-1)*HANDLE_HALF_SIZE;
aabb.size=aabb.pos*-2;
aabb.pos+=handles[i];
Vector3 rpos,rnorm;
if (aabb.intersects_segment(ray_from,ray_to,&rpos,&rnorm)) {
real_t dp = ray_dir.dot(rpos);
if (dp<min_d) {
r_pos=t.xform(rpos);
r_normal=ti.basis.xform_inv(rnorm).normalized();
min_d=dp;
idx=i;
}
}
#endif
}
if (idx>=0) {
*r_gizmo_handle=idx;
return true;
}
}
if (collision_segments.size()) {
Plane camp(p_camera->get_transform().origin,(-p_camera->get_transform().basis.get_axis(2)).normalized());
int vc=collision_segments.size();
const Vector3* vptr=collision_segments.ptr();
Transform t = spatial_node->get_global_transform();
Vector3 cp;
float cpd=1e20;
for(int i=0;i<vc/2;i++) {
Vector3 a=t.xform(vptr[i*2+0]);
Vector3 b=t.xform(vptr[i*2+1]);
Vector2 s[2];
s[0] = p_camera->unproject_position(a);
s[1] = p_camera->unproject_position(b);
Vector2 p = Geometry::get_closest_point_to_segment_2d(p_point,s);
float pd = p.distance_to(p_point);
if (pd<cpd) {
float d = s[0].distance_to(s[1]);
Vector3 tcp;
if (d>0) {
float d2=s[0].distance_to(p)/d;
tcp = a+(b-a)*d2;
} else {
tcp=a;
}
if (camp.distance_to(tcp)<p_camera->get_znear())
continue;
cp=tcp;
cpd=pd;
}
}
if (cpd<5) {
r_pos=cp;
r_normal=-p_camera->project_ray_normal(p_point);
return true;
}
return false;
}
if (collision_mesh.is_valid()) {
Transform gt = spatial_node->get_global_transform();
Transform ai=gt.affine_inverse();
Vector3 ray_from = ai.xform(p_camera->project_ray_origin(p_point));
Vector3 ray_dir=ai.basis.xform(p_camera->project_ray_normal(p_point)).normalized();
Vector3 rpos,rnorm;
#if 1
if (collision_mesh->intersect_ray(ray_from,ray_dir,rpos,rnorm)) {
r_pos=gt.xform(rpos);
r_normal=gt.basis.xform(rnorm).normalized();
return true;
}
#else
if (collision_mesh->intersect_segment(ray_from,ray_from+ray_dir*4906.0,rpos,rnorm)) {
r_pos=gt.xform(rpos);
r_normal=gt.basis.xform(rnorm).normalized();
return true;
}
#endif
}
return false;
}
void SpatialGizmoTool::create() {
ERR_FAIL_COND(!spatial_node);
ERR_FAIL_COND(valid);
valid=true;
for(int i=0;i<instances.size();i++) {
instances[i].create_instance(spatial_node);
}
transform();
}
void SpatialGizmoTool::transform(){
ERR_FAIL_COND(!spatial_node);
ERR_FAIL_COND(!valid);
for(int i=0;i<instances.size();i++) {
VS::get_singleton()->instance_set_transform(instances[i].instance,spatial_node->get_global_transform());
}
}
void SpatialGizmoTool::free(){
ERR_FAIL_COND(!spatial_node);
ERR_FAIL_COND(!valid);
for(int i=0;i<instances.size();i++) {
if (instances[i].instance.is_valid())
VS::get_singleton()->free(instances[i].instance);
instances[i].instance=RID();
}
valid=false;
}
SpatialGizmoTool::SpatialGizmoTool() {
valid=false;
billboard_handle=false;
}
SpatialGizmoTool::~SpatialGizmoTool(){
clear();
}
Vector3 SpatialGizmoTool::get_handle_pos(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx,handles.size(),Vector3());
return handles[p_idx];
}
//// light gizmo
String LightSpatialGizmo::get_handle_name(int p_idx) const {
if (p_idx==0)
return "Radius";
else
return "Aperture";
}
Variant LightSpatialGizmo::get_handle_value(int p_idx) const{
if (p_idx==0)
return light->get_parameter(Light::PARAM_RADIUS);
if (p_idx==1)
return light->get_parameter(Light::PARAM_SPOT_ANGLE);
return Variant();
}
static float _find_closest_angle_to_half_pi_arc(const Vector3& p_from, const Vector3& p_to, float p_arc_radius,const Transform& p_arc_xform) {
//bleh, discrete is simpler
static const int arc_test_points=64;
float min_d = 1e20;
Vector3 min_p;
for(int i=0;i<arc_test_points;i++) {
float a = i*Math_PI*0.5/arc_test_points;
float an = (i+1)*Math_PI*0.5/arc_test_points;
Vector3 p=Vector3( Math::cos(a), 0, -Math::sin(a) )*p_arc_radius;
Vector3 n=Vector3( Math::cos(an), 0,- Math::sin(an) )*p_arc_radius;
Vector3 ra,rb;
Geometry::get_closest_points_between_segments(p,n,p_from,p_to,ra,rb);
float d = ra.distance_to(rb);
if (d<min_d) {
min_d=d;
min_p=ra;
}
}
//min_p = p_arc_xform.affine_inverse().xform(min_p);
float a = Vector2(min_p.x,-min_p.z).atan2();
return a*180.0/Math_PI;
}
void LightSpatialGizmo::set_handle(int p_idx,Camera *p_camera, const Point2& p_point) {
Transform gt = light->get_global_transform();
gt.orthonormalize();
Transform gi = gt.affine_inverse();
Vector3 ray_from = p_camera->project_ray_origin(p_point);
Vector3 ray_dir = p_camera->project_ray_normal(p_point);
Vector3 s[2]={gi.xform(ray_from),gi.xform(ray_from+ray_dir*4096)};
if (p_idx==0) {
if (light->cast_to<SpotLight>()) {
Vector3 ra,rb;
Geometry::get_closest_points_between_segments(Vector3(),Vector3(0,0,-4096),s[0],s[1],ra,rb);
float d = -ra.z;
if (d<0)
d=0;
light->set_parameter(Light::PARAM_RADIUS,d);
} else if (light->cast_to<OmniLight>()) {
Plane cp=Plane( gt.origin, p_camera->get_transform().basis.get_axis(2));
Vector3 inters;
if (cp.intersects_ray(ray_from,ray_dir,&inters)) {
float r = inters.distance_to(gt.origin);
light->set_parameter(Light::PARAM_RADIUS,r);
}
}
} else if (p_idx==1) {
float a = _find_closest_angle_to_half_pi_arc(s[0],s[1],light->get_parameter(Light::PARAM_RADIUS),gt);
light->set_parameter(Light::PARAM_SPOT_ANGLE,CLAMP(a,0.01,89.99));
}
}
void LightSpatialGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_cancel){
if (p_cancel) {
light->set_parameter(p_idx==0?Light::PARAM_RADIUS:Light::PARAM_SPOT_ANGLE,p_restore);
} else if (p_idx==0) {
UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
ur->create_action("Change Light Radius");
ur->add_do_method(light,"set_parameter",Light::PARAM_RADIUS,light->get_parameter(Light::PARAM_RADIUS));
ur->add_undo_method(light,"set_parameter",Light::PARAM_RADIUS,p_restore);
ur->commit_action();
} else if (p_idx==1) {
UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
ur->create_action("Change Light Radius");
ur->add_do_method(light,"set_parameter",Light::PARAM_SPOT_ANGLE,light->get_parameter(Light::PARAM_SPOT_ANGLE));
ur->add_undo_method(light,"set_parameter",Light::PARAM_SPOT_ANGLE,p_restore);
ur->commit_action();
}
}
void LightSpatialGizmo::redraw() {
if (light->cast_to<DirectionalLight>()) {
const int arrow_points=5;
Vector3 arrow[arrow_points]={
Vector3(0,0,2),
Vector3(1,1,2),
Vector3(1,1,-1),
Vector3(2,2,-1),
Vector3(0,0,-3)
};
int arrow_sides=4;
Vector<Vector3> lines;
for(int i = 0; i < arrow_sides ; i++) {
Matrix3 ma(Vector3(0,0,1),Math_PI*2*float(i)/arrow_sides);
Matrix3 mb(Vector3(0,0,1),Math_PI*2*float(i+1)/arrow_sides);
for(int j=1;j<arrow_points-1;j++) {
if (j!=2) {
lines.push_back(ma.xform(arrow[j]));
lines.push_back(ma.xform(arrow[j+1]));
}
if (j<arrow_points-1) {
lines.push_back(ma.xform(arrow[j]));
lines.push_back(mb.xform(arrow[j]));
}
}
}
add_lines(lines,SpatialEditorGizmos::singleton->light_material);
add_collision_segments(lines);
add_unscaled_billboard(SpatialEditorGizmos::singleton->light_material_directional_icon,0.05);
}
if (light->cast_to<OmniLight>()) {
clear();
OmniLight *on = light->cast_to<OmniLight>();
float r = on->get_parameter(Light::PARAM_RADIUS);
Vector<Vector3> points;
for(int i=0;i<=360;i++) {
float ra=Math::deg2rad(i);
float rb=Math::deg2rad(i+1);
Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*r;
Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*r;
/*points.push_back(Vector3(a.x,0,a.y));
points.push_back(Vector3(b.x,0,b.y));
points.push_back(Vector3(0,a.x,a.y));
points.push_back(Vector3(0,b.x,b.y));*/
points.push_back(Vector3(a.x,a.y,0));
points.push_back(Vector3(b.x,b.y,0));
}
add_lines(points,SpatialEditorGizmos::singleton->light_material,true);
add_unscaled_billboard(SpatialEditorGizmos::singleton->light_material_omni_icon,0.05);
Vector<Vector3> handles;
handles.push_back(Vector3(r,0,0));
add_handles(handles,true);
}
if (light->cast_to<SpotLight>()) {
clear();
Vector<Vector3> points;
SpotLight *on = light->cast_to<SpotLight>();
float r = on->get_parameter(Light::PARAM_RADIUS);
float w = r*Math::sin(Math::deg2rad(on->get_parameter(Light::PARAM_SPOT_ANGLE)));
float d = r*Math::cos(Math::deg2rad(on->get_parameter(Light::PARAM_SPOT_ANGLE)));
for(int i=0;i<360;i++) {
float ra=Math::deg2rad(i);
float rb=Math::deg2rad(i+1);
Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*w;
Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*w;
/*points.push_back(Vector3(a.x,0,a.y));
points.push_back(Vector3(b.x,0,b.y));
points.push_back(Vector3(0,a.x,a.y));
points.push_back(Vector3(0,b.x,b.y));*/
points.push_back(Vector3(a.x,a.y,-d));
points.push_back(Vector3(b.x,b.y,-d));
if (i%90==0) {
points.push_back(Vector3(a.x,a.y,-d));
points.push_back(Vector3());
}
}
points.push_back(Vector3(0,0,-r));
points.push_back(Vector3());
add_lines(points,SpatialEditorGizmos::singleton->light_material);
Vector<Vector3> handles;
handles.push_back(Vector3(0,0,-r));
Vector<Vector3> collision_segments;
for(int i=0;i<64;i++) {
float ra=i*Math_PI*2.0/64.0;
float rb=(i+1)*Math_PI*2.0/64.0;
Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*w;
Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*w;
collision_segments.push_back(Vector3(a.x,a.y,-d));
collision_segments.push_back(Vector3(b.x,b.y,-d));
if (i%16==0) {
collision_segments.push_back(Vector3(a.x,a.y,-d));
collision_segments.push_back(Vector3());
}
if (i==16) {
handles.push_back(Vector3(a.x,a.y,-d));
}
}
collision_segments.push_back(Vector3(0,0,-r));
collision_segments.push_back(Vector3());
add_handles(handles);
add_collision_segments(collision_segments);
add_unscaled_billboard(SpatialEditorGizmos::singleton->light_material_omni_icon,0.05);
}
}
LightSpatialGizmo::LightSpatialGizmo(Light* p_light){
light=p_light;
set_spatial_node(p_light);
}
//////
String CameraSpatialGizmo::get_handle_name(int p_idx) const {
if (camera->get_projection()==Camera::PROJECTION_PERSPECTIVE) {
return "FOV";
} else {
return "Size";
}
}
Variant CameraSpatialGizmo::get_handle_value(int p_idx) const{
if (camera->get_projection()==Camera::PROJECTION_PERSPECTIVE) {
return camera->get_fov();
} else {
return camera->get_size();
}
}
void CameraSpatialGizmo::set_handle(int p_idx,Camera *p_camera, const Point2& p_point){
Transform gt = camera->get_global_transform();
gt.orthonormalize();
Transform gi = gt.affine_inverse();
Vector3 ray_from = p_camera->project_ray_origin(p_point);
Vector3 ray_dir = p_camera->project_ray_normal(p_point);
Vector3 s[2]={gi.xform(ray_from),gi.xform(ray_from+ray_dir*4096)};
if (camera->get_projection()==Camera::PROJECTION_PERSPECTIVE) {
Transform gt=camera->get_global_transform();
float a = _find_closest_angle_to_half_pi_arc(s[0],s[1],1.0,gt);
camera->set("fov",a);
} else {
Vector3 ra,rb;
Geometry::get_closest_points_between_segments(Vector3(0,0,-1),Vector3(4096,0,-1),s[0],s[1],ra,rb);
float d = ra.x * 2.0;
if (d<0)
d=0;
camera->set("size",d);
}
}
void CameraSpatialGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_cancel){
if (camera->get_projection()==Camera::PROJECTION_PERSPECTIVE) {
if (p_cancel) {
camera->set("fov",p_restore);
} else {
UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
ur->create_action("Change Camera FOV");
ur->add_do_property(camera,"fov",camera->get_fov());
ur->add_undo_property(camera,"fov",p_restore);
ur->commit_action();
}
} else {
if (p_cancel) {
camera->set("size",p_restore);
} else {
UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
ur->create_action("Change Camera Size");
ur->add_do_property(camera,"size",camera->get_size());
ur->add_undo_property(camera,"size",p_restore);
ur->commit_action();
}
}
}
void CameraSpatialGizmo::redraw(){
clear();
Vector<Vector3> lines;
Vector<Vector3> handles;
switch(camera->get_projection()) {
case Camera::PROJECTION_PERSPECTIVE: {
float fov = camera->get_fov();
Vector3 side=Vector3( Math::sin(Math::deg2rad(fov)), 0, -Math::cos(Math::deg2rad(fov)) );
Vector3 nside=side;
nside.x=-nside.x;
Vector3 up=Vector3(0,side.x,0);
#define ADD_TRIANGLE( m_a, m_b, m_c)\
{\
lines.push_back(m_a);\
lines.push_back(m_b);\
lines.push_back(m_b);\
lines.push_back(m_c);\
lines.push_back(m_c);\
lines.push_back(m_a);\
}
ADD_TRIANGLE( Vector3(), side+up, side-up );
ADD_TRIANGLE( Vector3(), nside+up, nside-up );
ADD_TRIANGLE( Vector3(), side+up, nside+up );
ADD_TRIANGLE( Vector3(), side-up, nside-up );
handles.push_back(side);
side.x*=0.25;
nside.x*=0.25;
Vector3 tup( 0, up.y*3/2,side.z);
ADD_TRIANGLE( tup, side+up, nside+up );
} break;
case Camera::PROJECTION_ORTHOGONAL: {
#define ADD_QUAD( m_a, m_b, m_c, m_d)\
{\
lines.push_back(m_a);\
lines.push_back(m_b);\
lines.push_back(m_b);\
lines.push_back(m_c);\
lines.push_back(m_c);\
lines.push_back(m_d);\
lines.push_back(m_d);\
lines.push_back(m_a);\
}
float size = camera->get_size();
float hsize=size*0.5;
Vector3 right(hsize,0,0);
Vector3 up(0,hsize,0);
Vector3 back(0,0,-1.0);
Vector3 front(0,0,0);
ADD_QUAD( -up-right,-up+right,up+right,up-right);
ADD_QUAD( -up-right+back,-up+right+back,up+right+back,up-right+back);
ADD_QUAD( up+right,up+right+back,up-right+back,up-right);
ADD_QUAD( -up+right,-up+right+back,-up-right+back,-up-right);
handles.push_back(right+back);
right.x*=0.25;
Vector3 tup( 0, up.y*3/2,back.z );
ADD_TRIANGLE( tup, right+up+back, -right+up+back );
} break;
}
add_lines(lines,SpatialEditorGizmos::singleton->camera_material);
add_collision_segments(lines);
add_handles(handles);
}
CameraSpatialGizmo::CameraSpatialGizmo(Camera* p_camera){
camera=p_camera;
set_spatial_node(camera);
}
//////
void MeshInstanceSpatialGizmo::redraw() {
Ref<Mesh> m = mesh->get_mesh();
if (!m.is_valid())
return; //none
Ref<TriangleMesh> tm = m->generate_triangle_mesh();
if (tm.is_valid())
add_collision_triangles(tm);
}
MeshInstanceSpatialGizmo::MeshInstanceSpatialGizmo(MeshInstance* p_mesh) {
mesh=p_mesh;
set_spatial_node(p_mesh);
}
/////
void Position3DSpatialGizmo::redraw() {
clear();
add_mesh(SpatialEditorGizmos::singleton->pos3d_mesh);
Vector<Vector3> cursor_points;
float cs = 0.25;
cursor_points.push_back(Vector3(+cs,0,0));
cursor_points.push_back(Vector3(-cs,0,0));
cursor_points.push_back(Vector3(0,+cs,0));
cursor_points.push_back(Vector3(0,-cs,0));
cursor_points.push_back(Vector3(0,0,+cs));
cursor_points.push_back(Vector3(0,0,-cs));
add_collision_segments(cursor_points);
}
Position3DSpatialGizmo::Position3DSpatialGizmo(Position3D* p_p3d) {
p3d=p_p3d;
set_spatial_node(p3d);
}
/////
void SkeletonSpatialGizmo::redraw() {
clear();
Ref<SurfaceTool> surface_tool( memnew( SurfaceTool ));
surface_tool->begin(Mesh::PRIMITIVE_LINES);
surface_tool->set_material(SpatialEditorGizmos::singleton->skeleton_material);
Vector<Transform> grests;
grests.resize(skel->get_bone_count());
Vector<int> bones;
Vector<float> weights;
bones.resize(4);
weights.resize(4);
for(int i=0;i<4;i++) {
bones[i]=0;
weights[i]=0;
}
weights[0]=1;
for (int i=0;i<skel->get_bone_count();i++) {
int parent = skel->get_bone_parent(i);
if (parent>=0) {
grests[i]=grests[parent] * skel->get_bone_rest(i);
Vector3 v0 = grests[parent].origin;
Vector3 v1 = grests[i].origin;
bones[0]=parent;
surface_tool->add_bones(bones);
surface_tool->add_weights(weights);
surface_tool->add_color(Color(0.4,1,0.4,0.4));
surface_tool->add_vertex(v0);
bones[0]=i;
surface_tool->add_bones(bones);
surface_tool->add_weights(weights);
surface_tool->add_color(Color(0.4,1,0.4,0.4));
surface_tool->add_vertex(v1);
} else {
grests[i]=skel->get_bone_rest(i);
bones[0]=i;
}
Transform t = grests[i];
t.orthonormalize();
for (int i=0;i<6;i++) {
Vector3 face_points[4];
for (int j=0;j<4;j++) {
float v[3];
v[0]=1.0;
v[1]=1-2*((j>>1)&1);
v[2]=v[1]*(1-2*(j&1));
for (int k=0;k<3;k++) {
if (i<3)
face_points[j][(i+k)%3]=v[k]*(i>=3?-1:1);
else
face_points[3-j][(i+k)%3]=v[k]*(i>=3?-1:1);
}
}
for(int j=0;j<4;j++) {
surface_tool->add_bones(bones);
surface_tool->add_weights(weights);
surface_tool->add_color(Color(1.0,0.4,0.4,0.4));
surface_tool->add_vertex(t.xform(face_points[j]*0.04));
surface_tool->add_bones(bones);
surface_tool->add_weights(weights);
surface_tool->add_color(Color(1.0,0.4,0.4,0.4));
surface_tool->add_vertex(t.xform(face_points[(j+1)%4]*0.04));
}
}
}
Ref<Mesh> m = surface_tool->commit();
add_mesh(m,false,skel->get_skeleton());
}
SkeletonSpatialGizmo::SkeletonSpatialGizmo(Skeleton* p_skel) {
skel=p_skel;
set_spatial_node(p_skel);
}
/////
void SpatialPlayerSpatialGizmo::redraw() {
clear();
if (splayer->cast_to<SpatialStreamPlayer>()) {
add_unscaled_billboard(SpatialEditorGizmos::singleton->stream_player_icon,0.05);
} else if (splayer->cast_to<SpatialSamplePlayer>()) {
add_unscaled_billboard(SpatialEditorGizmos::singleton->sample_player_icon,0.05);
}
}
SpatialPlayerSpatialGizmo::SpatialPlayerSpatialGizmo(SpatialPlayer* p_splayer){
set_spatial_node(p_splayer);
splayer=p_splayer;
}
/////
void RoomSpatialGizmo::redraw() {
clear();
Ref<RoomBounds> roomie = room->get_room();
if (roomie.is_null())
return;
DVector<Face3> faces = roomie->get_geometry_hint();
Vector<Vector3> lines;
int fc=faces.size();
DVector<Face3>::Read r =faces.read();
Map<_EdgeKey,Vector3> edge_map;
for(int i=0;i<fc;i++) {
Vector3 fn = r[i].get_plane().normal;
for(int j=0;j<3;j++) {
_EdgeKey ek;
ek.from=r[i].vertex[j].snapped(CMP_EPSILON);
ek.to=r[i].vertex[(j+1)%3].snapped(CMP_EPSILON);
if (ek.from<ek.to)
SWAP(ek.from,ek.to);
Map<_EdgeKey,Vector3>::Element *E=edge_map.find(ek);
if (E) {
if (E->get().dot(fn) >0.9) {
E->get()=Vector3();
}
} else {
edge_map[ek]=fn;
}
}
}
for(Map<_EdgeKey,Vector3>::Element *E=edge_map.front();E;E=E->next()) {
if (E->get()!=Vector3()) {
lines.push_back(E->key().from);
lines.push_back(E->key().to);
}
}
add_lines(lines,SpatialEditorGizmos::singleton->room_material);
add_collision_segments(lines);
}
RoomSpatialGizmo::RoomSpatialGizmo(Room* p_room){
set_spatial_node(p_room);
room=p_room;
}
/////
void PortalSpatialGizmo::redraw() {
clear();
Vector<Point2> points = portal->get_shape();
if (points.size()==0) {
return;
}
Vector<Vector3> lines;
Vector3 center;
for(int i=0;i<points.size();i++) {
Vector3 f;
f.x=points[i].x;
f.y=points[i].y;
Vector3 fn;
fn.x=points[(i+1)%points.size()].x;
fn.y=points[(i+1)%points.size()].y;
center+=f;
lines.push_back(f);
lines.push_back(fn);
}
center/=points.size();
lines.push_back(center);
lines.push_back(center+Vector3(0,0,1));
add_lines(lines,SpatialEditorGizmos::singleton->portal_material);
add_collision_segments(lines);
}
PortalSpatialGizmo::PortalSpatialGizmo(Portal* p_portal){
set_spatial_node(p_portal);
portal=p_portal;
}
/////
void RayCastSpatialGizmo::redraw() {
clear();
Vector<Vector3> lines;
lines.push_back(Vector3());
lines.push_back(raycast->get_cast_to());
add_lines(lines,SpatialEditorGizmos::singleton->raycast_material);
add_collision_segments(lines);
}
RayCastSpatialGizmo::RayCastSpatialGizmo(RayCast* p_raycast){
set_spatial_node(p_raycast);
raycast=p_raycast;
}
/////
void CarWheelSpatialGizmo::redraw() {
clear();
Vector<Vector3> points;
float r = car_wheel->get_radius();
const int skip=10;
for(int i=0;i<=360;i+=skip) {
float ra=Math::deg2rad(i);
float rb=Math::deg2rad(i+skip);
Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*r;
Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*r;
points.push_back(Vector3(0,a.x,a.y));
points.push_back(Vector3(0,b.x,b.y));
const int springsec=4;
for(int j=0;j<springsec;j++) {
float t = car_wheel->get_travel()*5;
points.push_back(Vector3(a.x,i/360.0*t/springsec+j*(t/springsec),a.y)*0.2);
points.push_back(Vector3(b.x,(i+skip)/360.0*t/springsec+j*(t/springsec),b.y)*0.2);
}
}
//travel
points.push_back(Vector3(0,0,0));
points.push_back(Vector3(0,car_wheel->get_travel(),0));
//axis
points.push_back(Vector3(r*0.2,car_wheel->get_travel(),0));
points.push_back(Vector3(-r*0.2,car_wheel->get_travel(),0));
//axis
points.push_back(Vector3(r*0.2,0,0));
points.push_back(Vector3(-r*0.2,0,0));
//forward line
points.push_back(Vector3(0,-r,0));
points.push_back(Vector3(0,-r,r*2));
points.push_back(Vector3(0,-r,r*2));
points.push_back(Vector3(r*2*0.2,-r,r*2*0.8));
points.push_back(Vector3(0,-r,r*2));
points.push_back(Vector3(-r*2*0.2,-r,r*2*0.8));
add_lines(points,SpatialEditorGizmos::singleton->car_wheel_material);
add_collision_segments(points);
}
CarWheelSpatialGizmo::CarWheelSpatialGizmo(CarWheel* p_car_wheel){
set_spatial_node(p_car_wheel);
car_wheel=p_car_wheel;
}
///
void TestCubeSpatialGizmo::redraw() {
clear();
add_collision_triangles(SpatialEditorGizmos::singleton->test_cube_tm);
}
TestCubeSpatialGizmo::TestCubeSpatialGizmo(TestCube* p_tc) {
tc=p_tc;
set_spatial_node(p_tc);
}
///////////
String CollisionShapeSpatialGizmo::get_handle_name(int p_idx) const {
Ref<Shape> s = cs->get_shape();
if (s.is_null())
return "";
if (s->cast_to<SphereShape>()) {
return "Radius";
}
if (s->cast_to<BoxShape>()) {
return "Extents";
}
if (s->cast_to<CapsuleShape>()) {
return p_idx==0?"Radius":"Height";
}
if (s->cast_to<RayShape>()) {
return "Length";
}
return "";
}
Variant CollisionShapeSpatialGizmo::get_handle_value(int p_idx) const{
Ref<Shape> s = cs->get_shape();
if (s.is_null())
return Variant();
if (s->cast_to<SphereShape>()) {
Ref<SphereShape> ss = s;
return ss->get_radius();
}
if (s->cast_to<BoxShape>()) {
Ref<BoxShape> bs = s;
return bs->get_extents();
}
if (s->cast_to<CapsuleShape>()) {
Ref<CapsuleShape> cs = s;
return p_idx==0?cs->get_radius():cs->get_height();
}
if (s->cast_to<RayShape>()) {
Ref<RayShape> cs = s;
return cs->get_length();
}
return Variant();
}
void CollisionShapeSpatialGizmo::set_handle(int p_idx,Camera *p_camera, const Point2& p_point){
Ref<Shape> s = cs->get_shape();
if (s.is_null())
return;
Transform gt = cs->get_global_transform();
gt.orthonormalize();
Transform gi = gt.affine_inverse();
Vector3 ray_from = p_camera->project_ray_origin(p_point);
Vector3 ray_dir = p_camera->project_ray_normal(p_point);
Vector3 sg[2]={gi.xform(ray_from),gi.xform(ray_from+ray_dir*4096)};
if (s->cast_to<SphereShape>()) {
Ref<SphereShape> ss = s;
Vector3 ra,rb;
Geometry::get_closest_points_between_segments(Vector3(),Vector3(4096,0,0),sg[0],sg[1],ra,rb);
float d = ra.x;
if (d<0.001)
d=0.001;
ss->set_radius(d);
}
if (s->cast_to<RayShape>()) {
Ref<RayShape> rs = s;
Vector3 ra,rb;
Geometry::get_closest_points_between_segments(Vector3(),Vector3(0,0,4096),sg[0],sg[1],ra,rb);
float d = ra.z;
if (d<0.001)
d=0.001;
rs->set_length(d);
}
if (s->cast_to<BoxShape>()) {
Vector3 axis;
axis[p_idx]=1.0;
Ref<BoxShape> bs = s;
Vector3 ra,rb;
Geometry::get_closest_points_between_segments(Vector3(),axis*4096,sg[0],sg[1],ra,rb);
float d = ra[p_idx];
if (d<0.001)
d=0.001;
Vector3 he = bs->get_extents();
he[p_idx]=d;
bs->set_extents(he);
}
if (s->cast_to<CapsuleShape>()) {
Vector3 axis;
axis[p_idx==0?0:2]=1.0;
Ref<CapsuleShape> cs = s;
Vector3 ra,rb;
Geometry::get_closest_points_between_segments(Vector3(),axis*4096,sg[0],sg[1],ra,rb);
float d = ra[p_idx];
if (p_idx==1)
d-=cs->get_radius();
if (d<0.001)
d=0.001;
if (p_idx==0)
cs->set_radius(d);
else if (p_idx==1)
cs->set_height(d*2.0);
}
}
void CollisionShapeSpatialGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_cancel){
Ref<Shape> s = cs->get_shape();
if (s.is_null())
return;
if (s->cast_to<SphereShape>()) {
Ref<SphereShape> ss=s;
if (p_cancel) {
ss->set_radius(p_restore);
return;
}
UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
ur->create_action("Change Sphere Shape Radius");
ur->add_do_method(ss.ptr(),"set_radius",ss->get_radius());
ur->add_undo_method(ss.ptr(),"set_radius",p_restore);
ur->commit_action();
}
if (s->cast_to<BoxShape>()) {
Ref<BoxShape> ss=s;
if (p_cancel) {
ss->set_extents(p_restore);
return;
}
UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
ur->create_action("Change Box Shape Extents");
ur->add_do_method(ss.ptr(),"set_extents",ss->get_extents());
ur->add_undo_method(ss.ptr(),"set_extents",p_restore);
ur->commit_action();
}
if (s->cast_to<CapsuleShape>()) {
Ref<CapsuleShape> ss=s;
if (p_cancel) {
if (p_idx==0)
ss->set_radius(p_restore);
else
ss->set_height(p_restore);
return;
}
UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
if (p_idx==0) {
ur->create_action("Change Capsule Shape Radius");
ur->add_do_method(ss.ptr(),"set_radius",ss->get_radius());
ur->add_undo_method(ss.ptr(),"set_radius",p_restore);
} else {
ur->create_action("Change Capsule Shape Height");
ur->add_do_method(ss.ptr(),"set_height",ss->get_height());
ur->add_undo_method(ss.ptr(),"set_height",p_restore);
}
ur->commit_action();
}
if (s->cast_to<RayShape>()) {
Ref<RayShape> ss=s;
if (p_cancel) {
ss->set_length(p_restore);
return;
}
UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
ur->create_action("Change Ray Shape Length");
ur->add_do_method(ss.ptr(),"set_length",ss->get_length());
ur->add_undo_method(ss.ptr(),"set_length",p_restore);
ur->commit_action();
}
}
void CollisionShapeSpatialGizmo::redraw(){
clear();
Ref<Shape> s = cs->get_shape();
if (s.is_null())
return;
if (s->cast_to<SphereShape>()) {
Ref<SphereShape> sp= s;
float r=sp->get_radius();
Vector<Vector3> points;
for(int i=0;i<=360;i++) {
float ra=Math::deg2rad(i);
float rb=Math::deg2rad(i+1);
Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*r;
Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*r;
points.push_back(Vector3(a.x,0,a.y));
points.push_back(Vector3(b.x,0,b.y));
points.push_back(Vector3(0,a.x,a.y));
points.push_back(Vector3(0,b.x,b.y));
points.push_back(Vector3(a.x,a.y,0));
points.push_back(Vector3(b.x,b.y,0));
}
Vector<Vector3> collision_segments;
for(int i=0;i<64;i++) {
float ra=i*Math_PI*2.0/64.0;
float rb=(i+1)*Math_PI*2.0/64.0;
Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*r;
Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*r;
collision_segments.push_back(Vector3(a.x,0,a.y));
collision_segments.push_back(Vector3(b.x,0,b.y));
collision_segments.push_back(Vector3(0,a.x,a.y));
collision_segments.push_back(Vector3(0,b.x,b.y));
collision_segments.push_back(Vector3(a.x,a.y,0));
collision_segments.push_back(Vector3(b.x,b.y,0));
}
add_lines(points,SpatialEditorGizmos::singleton->shape_material);
add_collision_segments(collision_segments);
Vector<Vector3> handles;
handles.push_back(Vector3(r,0,0));
add_handles(handles);
}
if (s->cast_to<BoxShape>()) {
Ref<BoxShape> bs=s;
Vector<Vector3> lines;
AABB aabb;
aabb.pos=-bs->get_extents();
aabb.size=aabb.pos*-2;
for(int i=0;i<12;i++) {
Vector3 a,b;
aabb.get_edge(i,a,b);
lines.push_back(a);
lines.push_back(b);
}
Vector<Vector3> handles;
for(int i=0;i<3;i++) {
Vector3 ax;
ax[i]=bs->get_extents()[i];
handles.push_back(ax);
}
add_lines(lines,SpatialEditorGizmos::singleton->shape_material);
add_collision_segments(lines);
add_handles(handles);
}
if (s->cast_to<CapsuleShape>()) {
Ref<CapsuleShape> cs=s;
float radius = cs->get_radius();
float height = cs->get_height();
Vector<Vector3> points;
Vector3 d(0,0,height*0.5);
for(int i=0;i<360;i++) {
float ra=Math::deg2rad(i);
float rb=Math::deg2rad(i+1);
Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*radius;
Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*radius;
points.push_back(Vector3(a.x,a.y,0)+d);
points.push_back(Vector3(b.x,b.y,0)+d);
points.push_back(Vector3(a.x,a.y,0)-d);
points.push_back(Vector3(b.x,b.y,0)-d);
if (i%90==0) {
points.push_back(Vector3(a.x,a.y,0)+d);
points.push_back(Vector3(a.x,a.y,0)-d);
}
Vector3 dud = i<180?d:-d;
points.push_back(Vector3(0,a.y,a.x)+dud);
points.push_back(Vector3(0,b.y,b.x)+dud);
points.push_back(Vector3(a.y,0,a.x)+dud);
points.push_back(Vector3(b.y,0,b.x)+dud);
}
add_lines(points,SpatialEditorGizmos::singleton->shape_material);
Vector<Vector3> collision_segments;
for(int i=0;i<64;i++) {
float ra=i*Math_PI*2.0/64.0;
float rb=(i+1)*Math_PI*2.0/64.0;
Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*radius;
Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*radius;
collision_segments.push_back(Vector3(a.x,a.y,0)+d);
collision_segments.push_back(Vector3(b.x,b.y,0)+d);
collision_segments.push_back(Vector3(a.x,a.y,0)-d);
collision_segments.push_back(Vector3(b.x,b.y,0)-d);
if (i%16==0) {
collision_segments.push_back(Vector3(a.x,a.y,0)+d);
collision_segments.push_back(Vector3(a.x,a.y,0)-d);
}
Vector3 dud = i<32?d:-d;
collision_segments.push_back(Vector3(0,a.y,a.x)+dud);
collision_segments.push_back(Vector3(0,b.y,b.x)+dud);
collision_segments.push_back(Vector3(a.y,0,a.x)+dud);
collision_segments.push_back(Vector3(b.y,0,b.x)+dud);
}
add_collision_segments(collision_segments);
Vector<Vector3> handles;
handles.push_back(Vector3(cs->get_radius(),0,0));
handles.push_back(Vector3(0,0,cs->get_height()*0.5+cs->get_radius()));
add_handles(handles);
}
if (s->cast_to<PlaneShape>()) {
Ref<PlaneShape> ps=s;
Plane p = ps->get_plane();
Vector<Vector3> points;
Vector3 n1 = p.get_any_perpendicular_normal();
Vector3 n2 = p.normal.cross(n1).normalized();
Vector3 pface[4]={
p.normal*p.d+n1*10.0+n2*10.0,
p.normal*p.d+n1*10.0+n2*-10.0,
p.normal*p.d+n1*-10.0+n2*-10.0,
p.normal*p.d+n1*-10.0+n2*10.0,
};
points.push_back(pface[0]);
points.push_back(pface[1]);
points.push_back(pface[1]);
points.push_back(pface[2]);
points.push_back(pface[2]);
points.push_back(pface[3]);
points.push_back(pface[3]);
points.push_back(pface[0]);
points.push_back(p.normal*p.d);
points.push_back(p.normal*p.d+p.normal*3);
add_lines(points,SpatialEditorGizmos::singleton->shape_material);
add_collision_segments(points);
}
if (s->cast_to<RayShape>()) {
Ref<RayShape> rs=s;
Vector<Vector3> points;
points.push_back(Vector3());
points.push_back(Vector3(0,0,rs->get_length()));
add_lines(points,SpatialEditorGizmos::singleton->shape_material);
add_collision_segments(points);
Vector<Vector3> handles;
handles.push_back(Vector3(0,0,rs->get_length()));
add_handles(handles);
}
}
CollisionShapeSpatialGizmo::CollisionShapeSpatialGizmo(CollisionShape* p_cs) {
cs=p_cs;
set_spatial_node(p_cs);
}
String VisibilityNotifierGizmo::get_handle_name(int p_idx) const {
switch(p_idx) {
case 0: return "X";
case 1: return "Y";
case 2: return "Z";
}
return "";
}
Variant VisibilityNotifierGizmo::get_handle_value(int p_idx) const{
return notifier->get_aabb();
}
void VisibilityNotifierGizmo::set_handle(int p_idx,Camera *p_camera, const Point2& p_point){
Transform gt = notifier->get_global_transform();
//gt.orthonormalize();
Transform gi = gt.affine_inverse();
AABB aabb = notifier->get_aabb();
Vector3 ray_from = p_camera->project_ray_origin(p_point);
Vector3 ray_dir = p_camera->project_ray_normal(p_point);
Vector3 sg[2]={gi.xform(ray_from),gi.xform(ray_from+ray_dir*4096)};
Vector3 ofs = aabb.pos+aabb.size*0.5;;
Vector3 axis;
axis[p_idx]=1.0;
Vector3 ra,rb;
Geometry::get_closest_points_between_segments(ofs,ofs+axis*4096,sg[0],sg[1],ra,rb);
float d = ra[p_idx];
if (d<0.001)
d=0.001;
Vector3 he = aabb.size;
aabb.pos[p_idx]=(aabb.pos[p_idx]+aabb.size[p_idx]*0.5)-d;
aabb.size[p_idx]=d*2;
notifier->set_aabb(aabb);
}
void VisibilityNotifierGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_cancel){
if (p_cancel) {
notifier->set_aabb(p_restore);
return;
}
UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
ur->create_action("Change Notifier Extents");
ur->add_do_method(notifier,"set_aabb",notifier->get_aabb());
ur->add_undo_method(notifier,"set_aabb",p_restore);
ur->commit_action();
}
void VisibilityNotifierGizmo::redraw(){
clear();
Vector<Vector3> lines;
AABB aabb = notifier->get_aabb();
for(int i=0;i<12;i++) {
Vector3 a,b;
aabb.get_edge(i,a,b);
lines.push_back(a);
lines.push_back(b);
}
Vector<Vector3> handles;
for(int i=0;i<3;i++) {
Vector3 ax;
ax[i]=aabb.pos[i]+aabb.size[i];
handles.push_back(ax);
}
add_lines(lines,SpatialEditorGizmos::singleton->visibility_notifier_material);
//add_unscaled_billboard(SpatialEditorGizmos::singleton->visi,0.05);
add_collision_segments(lines);
add_handles(handles);
}
VisibilityNotifierGizmo::VisibilityNotifierGizmo(VisibilityNotifier* p_notifier){
notifier=p_notifier;
set_spatial_node(p_notifier);
}
////////
SpatialEditorGizmos *SpatialEditorGizmos::singleton=NULL;
Ref<SpatialEditorGizmo> SpatialEditorGizmos::get_gizmo(Spatial *p_spatial) {
if (p_spatial->cast_to<Light>()) {
Ref<LightSpatialGizmo> lsg = memnew( LightSpatialGizmo(p_spatial->cast_to<Light>()) );
return lsg;
}
if (p_spatial->cast_to<Camera>()) {
Ref<CameraSpatialGizmo> lsg = memnew( CameraSpatialGizmo(p_spatial->cast_to<Camera>()) );
return lsg;
}
if (p_spatial->cast_to<Skeleton>()) {
Ref<SkeletonSpatialGizmo> lsg = memnew( SkeletonSpatialGizmo(p_spatial->cast_to<Skeleton>()) );
return lsg;
}
if (p_spatial->cast_to<Position3D>()) {
Ref<Position3DSpatialGizmo> lsg = memnew( Position3DSpatialGizmo(p_spatial->cast_to<Position3D>()) );
return lsg;
}
if (p_spatial->cast_to<MeshInstance>()) {
Ref<MeshInstanceSpatialGizmo> misg = memnew( MeshInstanceSpatialGizmo(p_spatial->cast_to<MeshInstance>()) );
return misg;
}
if (p_spatial->cast_to<Room>()) {
Ref<RoomSpatialGizmo> misg = memnew( RoomSpatialGizmo(p_spatial->cast_to<Room>()) );
return misg;
}
if (p_spatial->cast_to<RayCast>()) {
Ref<RayCastSpatialGizmo> misg = memnew( RayCastSpatialGizmo(p_spatial->cast_to<RayCast>()) );
return misg;
}
if (p_spatial->cast_to<Portal>()) {
Ref<PortalSpatialGizmo> misg = memnew( PortalSpatialGizmo(p_spatial->cast_to<Portal>()) );
return misg;
}
if (p_spatial->cast_to<TestCube>()) {
Ref<TestCubeSpatialGizmo> misg = memnew( TestCubeSpatialGizmo(p_spatial->cast_to<TestCube>()) );
return misg;
}
if (p_spatial->cast_to<SpatialPlayer>()) {
Ref<SpatialPlayerSpatialGizmo> misg = memnew( SpatialPlayerSpatialGizmo(p_spatial->cast_to<SpatialPlayer>()) );
return misg;
}
if (p_spatial->cast_to<CollisionShape>()) {
Ref<CollisionShapeSpatialGizmo> misg = memnew( CollisionShapeSpatialGizmo(p_spatial->cast_to<CollisionShape>()) );
return misg;
}
if (p_spatial->cast_to<VisibilityNotifier>()) {
Ref<VisibilityNotifierGizmo> misg = memnew( VisibilityNotifierGizmo(p_spatial->cast_to<VisibilityNotifier>()) );
return misg;
}
if (p_spatial->cast_to<EditableShape>()) {
Ref<EditableShapeSpatialGizmo> misg = memnew( EditableShapeSpatialGizmo(p_spatial->cast_to<EditableShape>()) );
return misg;
}
if (p_spatial->cast_to<CarWheel>()) {
Ref<CarWheelSpatialGizmo> misg = memnew( CarWheelSpatialGizmo(p_spatial->cast_to<CarWheel>()) );
return misg;
}
return Ref<SpatialEditorGizmo>();
}
SpatialEditorGizmos::SpatialEditorGizmos() {
singleton=this;
handle_material = Ref<FixedMaterial>( memnew( FixedMaterial ));
handle_material->set_flag(Material::FLAG_UNSHADED, true);
handle_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(0.8,0.8,0.8));
handle2_material = Ref<FixedMaterial>( memnew( FixedMaterial ));
handle2_material->set_flag(Material::FLAG_UNSHADED, true);
handle2_material->set_fixed_flag(FixedMaterial::FLAG_USE_POINT_SIZE, true);
handle_t = SpatialEditor::get_singleton()->get_icon("Editor3DHandle","EditorIcons");
handle2_material->set_point_size(handle_t->get_width());
handle2_material->set_texture(FixedMaterial::PARAM_DIFFUSE,handle_t);
handle2_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1));
handle2_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
light_material = Ref<FixedMaterial>( memnew( FixedMaterial ));
light_material->set_flag(Material::FLAG_UNSHADED, true);
light_material->set_line_width(3.0);
light_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
light_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,0.2,0.3));
light_material_omni_icon = Ref<FixedMaterial>( memnew( FixedMaterial ));
light_material_omni_icon->set_flag(Material::FLAG_UNSHADED, true);
light_material_omni_icon->set_flag(Material::FLAG_DOUBLE_SIDED, true);
light_material_omni_icon->set_hint(Material::HINT_NO_DEPTH_DRAW, true);
light_material_omni_icon->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
light_material_omni_icon->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1,0.9));
light_material_omni_icon->set_texture(FixedMaterial::PARAM_DIFFUSE,SpatialEditor::get_singleton()->get_icon("GizmoLight","EditorIcons"));
light_material_directional_icon = Ref<FixedMaterial>( memnew( FixedMaterial ));
light_material_directional_icon->set_flag(Material::FLAG_UNSHADED, true);
light_material_directional_icon->set_flag(Material::FLAG_DOUBLE_SIDED, true);
light_material_directional_icon->set_hint(Material::HINT_NO_DEPTH_DRAW, true);
light_material_directional_icon->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
light_material_directional_icon->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1,0.9));
light_material_directional_icon->set_texture(FixedMaterial::PARAM_DIFFUSE,SpatialEditor::get_singleton()->get_icon("GizmoDirectionalLight","EditorIcons"));
camera_material = Ref<FixedMaterial>( memnew( FixedMaterial ));
camera_material->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(1.0,0.5,1.0,0.7) );
camera_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
camera_material->set_line_width(3);
camera_material->set_flag(Material::FLAG_DOUBLE_SIDED,true);
camera_material->set_flag(Material::FLAG_UNSHADED,true);
camera_material->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
skeleton_material=Ref<FixedMaterial>( memnew( FixedMaterial ));
//skeleton_material->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.6,1.0,0.3,0.1) );
skeleton_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
skeleton_material->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY, true);
skeleton_material->set_line_width(3);
skeleton_material->set_flag(Material::FLAG_DOUBLE_SIDED,true);
skeleton_material->set_flag(Material::FLAG_UNSHADED,true);
skeleton_material->set_flag(Material::FLAG_ONTOP,true);
skeleton_material->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
//position 3D Shared mesh
pos3d_mesh = Ref<Mesh>( memnew( Mesh ) );
{
DVector<Vector3> cursor_points;
DVector<Color> cursor_colors;
float cs = 0.25;
cursor_points.push_back(Vector3(+cs,0,0));
cursor_points.push_back(Vector3(-cs,0,0));
cursor_points.push_back(Vector3(0,+cs,0));
cursor_points.push_back(Vector3(0,-cs,0));
cursor_points.push_back(Vector3(0,0,+cs));
cursor_points.push_back(Vector3(0,0,-cs));
cursor_colors.push_back(Color(1,0.5,0.5,0.7));
cursor_colors.push_back(Color(1,0.5,0.5,0.7));
cursor_colors.push_back(Color(0.5,1,0.5,0.7));
cursor_colors.push_back(Color(0.5,1,0.5,0.7));
cursor_colors.push_back(Color(0.5,0.5,1,0.7));
cursor_colors.push_back(Color(0.5,0.5,1,0.7));
Ref<FixedMaterial> mat = memnew( FixedMaterial );
mat->set_flag(Material::FLAG_UNSHADED,true);
mat->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY,true);
mat->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA,true);
mat->set_line_width(3);
Array d;
d.resize(VS::ARRAY_MAX);
d[Mesh::ARRAY_VERTEX]=cursor_points;
d[Mesh::ARRAY_COLOR]=cursor_colors;
pos3d_mesh->add_surface(Mesh::PRIMITIVE_LINES,d);
pos3d_mesh->surface_set_material(0,mat);
}
sample_player_icon = Ref<FixedMaterial>( memnew( FixedMaterial ));
sample_player_icon->set_flag(Material::FLAG_UNSHADED, true);
sample_player_icon->set_flag(Material::FLAG_DOUBLE_SIDED, true);
sample_player_icon->set_hint(Material::HINT_NO_DEPTH_DRAW, true);
sample_player_icon->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
sample_player_icon->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1,0.9));
sample_player_icon->set_texture(FixedMaterial::PARAM_DIFFUSE,SpatialEditor::get_singleton()->get_icon("GizmoSpatialSamplePlayer","EditorIcons"));
room_material = Ref<FixedMaterial>( memnew( FixedMaterial ));
room_material->set_flag(Material::FLAG_UNSHADED, true);
room_material->set_flag(Material::FLAG_DOUBLE_SIDED, true);
//room_material->set_hint(Material::HINT_NO_DEPTH_DRAW, true);
room_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
room_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1.0,0.6,0.9,0.8));
room_material->set_line_width(3);
portal_material = Ref<FixedMaterial>( memnew( FixedMaterial ));
portal_material->set_flag(Material::FLAG_UNSHADED, true);
portal_material->set_flag(Material::FLAG_DOUBLE_SIDED, true);
//portal_material->set_hint(Material::HINT_NO_DEPTH_DRAW, true);
portal_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
portal_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1.0,0.8,0.6,0.8));
portal_material->set_line_width(3);
raycast_material = Ref<FixedMaterial>( memnew( FixedMaterial ));
raycast_material->set_flag(Material::FLAG_UNSHADED, true);
raycast_material->set_flag(Material::FLAG_DOUBLE_SIDED, true);
//raycast_material->set_hint(Material::HINT_NO_DEPTH_DRAW, true);
raycast_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
raycast_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1.0,0.8,0.6,0.8));
raycast_material->set_line_width(3);
car_wheel_material = Ref<FixedMaterial>( memnew( FixedMaterial ));
car_wheel_material->set_flag(Material::FLAG_UNSHADED, true);
car_wheel_material->set_flag(Material::FLAG_DOUBLE_SIDED, true);
//car_wheel_material->set_hint(Material::HINT_NO_DEPTH_DRAW, true);
car_wheel_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
car_wheel_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(0.6,0.8,1.0,0.8));
car_wheel_material->set_line_width(3);
visibility_notifier_material = Ref<FixedMaterial>( memnew( FixedMaterial ));
visibility_notifier_material->set_flag(Material::FLAG_UNSHADED, true);
visibility_notifier_material->set_flag(Material::FLAG_DOUBLE_SIDED, true);
//visibility_notifier_material->set_hint(Material::HINT_NO_DEPTH_DRAW, true);
visibility_notifier_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
visibility_notifier_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1.0,0.5,1.0,0.8));
visibility_notifier_material->set_line_width(3);
stream_player_icon = Ref<FixedMaterial>( memnew( FixedMaterial ));
stream_player_icon->set_flag(Material::FLAG_UNSHADED, true);
stream_player_icon->set_flag(Material::FLAG_DOUBLE_SIDED, true);
stream_player_icon->set_hint(Material::HINT_NO_DEPTH_DRAW, true);
stream_player_icon->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
stream_player_icon->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1,0.9));
stream_player_icon->set_texture(FixedMaterial::PARAM_DIFFUSE,SpatialEditor::get_singleton()->get_icon("GizmoSpatialStreamPlayer","EditorIcons"));
visibility_notifier_icon = Ref<FixedMaterial>( memnew( FixedMaterial ));
visibility_notifier_icon->set_flag(Material::FLAG_UNSHADED, true);
visibility_notifier_icon->set_flag(Material::FLAG_DOUBLE_SIDED, true);
visibility_notifier_icon->set_hint(Material::HINT_NO_DEPTH_DRAW, true);
visibility_notifier_icon->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
visibility_notifier_icon->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1,0.9));
visibility_notifier_icon->set_texture(FixedMaterial::PARAM_DIFFUSE,SpatialEditor::get_singleton()->get_icon("Visible","EditorIcons"));
{
DVector<Vector3> vertices;
#undef ADD_VTX
#define ADD_VTX(m_idx);\
vertices.push_back( face_points[m_idx] );
for (int i=0;i<6;i++) {
Vector3 face_points[4];
for (int j=0;j<4;j++) {
float v[3];
v[0]=1.0;
v[1]=1-2*((j>>1)&1);
v[2]=v[1]*(1-2*(j&1));
for (int k=0;k<3;k++) {
if (i<3)
face_points[j][(i+k)%3]=v[k]*(i>=3?-1:1);
else
face_points[3-j][(i+k)%3]=v[k]*(i>=3?-1:1);
}
}
//tri 1
ADD_VTX(0);
ADD_VTX(1);
ADD_VTX(2);
//tri 2
ADD_VTX(2);
ADD_VTX(3);
ADD_VTX(0);
}
test_cube_tm = Ref<TriangleMesh>( memnew( TriangleMesh ) );
test_cube_tm->create(vertices);
}
shape_material = Ref<FixedMaterial>( memnew( FixedMaterial ));
shape_material->set_flag(Material::FLAG_UNSHADED, true);
shape_material->set_line_width(3.0);
shape_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
shape_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(0.2,1,1.0,0.3));
}
| [
"[email protected]"
] | |
061c92d0b506e13c6f6be8c3f4e1b102578df644 | 6ebedfb375b77eb9515fb0df0dfc635e14c24f27 | /EliminationPlane/Classes/CGun.h | fce2a0db50bb21dd7470ea73fa9cb075471148c0 | [] | no_license | raymondma/EliminationPlane | 5421741188986c748f065c2cb39538095011b39f | 0d8ed58d89bf3581279c53ce759a4cb8f10be162 | refs/heads/master | 2021-01-10T21:35:31.830973 | 2013-06-06T04:07:38 | 2013-06-06T04:07:38 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,305 | h | //
// CGun.h
// TheForce
//
// Created by 马 俊 on 13-2-3.
// Copyright (c) 2013年 Tencent. All rights reserved.
//
#ifndef __TheForce__TFGun__
#define __TheForce__TFGun__
#include "cocos2d.h"
#include <vector>
#include <string>
#include "TFNodeContainer.h"
#include "CObjectBase.h"
#include "TFBatchNodeObject.h"
using namespace std;
USING_NS_CC;
class CRole;
class CBulletBase;
class CGun : public CObjectBase, public TFBatchNodeObject
{
friend class CObjectBase;
public:
FACTORY_CREATE_FUNC(CGun);
virtual ~CGun();
virtual bool init(CCDictionary* pObjectDict);
virtual void setOwner(CRole* role);
virtual void update(float dt);
virtual void shoot(float dt);
virtual void clearAll();
virtual bool addBulletRow();
virtual bool removeBulletRow();
virtual bool changeBullet(const string& name);
DECLARE_DICTFUNC(CCString*, BulletName);
DECLARE_DICTFUNC(int, MaxLevel);
DECLARE_DICTFUNC(int, CacheNum);
DECLARE_DICTFUNC(float, Frequency);
protected:
CGun();
void clearThis();
virtual GameArts getBatchNodeName();
CRole* m_pRole;
float m_lastShootTime;
float m_frequency;
bool m_isDoubleBullet;
private:
TFNodeContainer container_;
};
#endif /* defined(__TheForce__TFGun__) */
| [
"[email protected]"
] | |
6c02775ca1795633f92846d66699ef751377b4b7 | 5417bd385c453f9b9c8279d8325b62c70277e34b | /common_helper/common_helper.cpp | bafd44a8993732517af2b9afb7aee1878b13161f | [
"Apache-2.0",
"BSD-3-Clause",
"MIT"
] | permissive | dlyshare/play_with_mnn | 88bd8a06397370465d25fe8bd919b1f2d11d8a5b | 560c0ba38ce50f7b55213e544c809f5fd766b5ca | refs/heads/master | 2023-08-13T22:21:21.899226 | 2021-09-14T11:26:28 | 2021-09-14T11:26:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 637 | cpp | /* Copyright 2021 iwatake2222
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.
==============================================================================*/
| [
"[email protected]"
] | |
e96084e8a0123c407a35d3b7ceba2585f26fc498 | deef545fb64f73770ef44ce35577831048c11311 | /src/main.cpp | 3d1bd62c5a9e2427efd652f5a50eda554e3c19c7 | [] | no_license | PeteE/arduinopixed | ad0199628e705a58c3e4e524cc75f7a525bcb294 | b11cc3ef086c62ffa41c1e8a25f57522232b19b0 | refs/heads/master | 2020-12-01T14:41:48.094989 | 2019-12-28T21:18:03 | 2019-12-28T21:18:03 | 230,664,434 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 439 | cpp | #include "Arduino.h"
#define THERM_PIN A7
int senseVal = 0, outputVal = 0;
void setup() {
pinMode(6, OUTPUT);
Serial.begin(9600);
}
void loop() {
digitalWrite(6, HIGH);
delay(500);
digitalWrite(6, LOW);
delay(500);
int senseVal = analogRead(THERM_PIN);
int outputVal = map(senseVal, 0, 1023, 0, 255);
Serial.print("sensor = ");
Serial.print(senseVal);
Serial.print("\t output = ");
Serial.println(outputVal);
}
| [
"[email protected]"
] | |
29608e1845d726a1221cf8cb85faa728ca195a22 | 634120df190b6262fccf699ac02538360fd9012d | /Develop/Server/GameServer/unittest/GUTHelper_Etc.h | d4480fb5b3b20844468e468ed14ca4e6937e52bc | [] | no_license | ktj007/Raiderz_Public | c906830cca5c644be384e68da205ee8abeb31369 | a71421614ef5711740d154c961cbb3ba2a03f266 | refs/heads/master | 2021-06-08T03:37:10.065320 | 2016-11-28T07:50:57 | 2016-11-28T07:50:57 | 74,959,309 | 6 | 4 | null | 2016-11-28T09:53:49 | 2016-11-28T09:53:49 | null | UTF-8 | C++ | false | false | 60 | h | #pragma once
class GNPCShopInfo;
class GUTHelper_Etc
{
};
| [
"[email protected]"
] | |
e36661fbee39d6b21ff690f5bbb68b75f8613cf0 | a2203e266a4b0919fbde02e79ed63059b804052c | /C and C++/Competitive Problem Solutions/Codeforces/fibonacci native.cpp | b078f4096bc12a857c952ed32f7f9576c4b18fd0 | [] | no_license | bhavnagit/Hacktoberfest2020 | e5abfc4f4d5a48720f5f6c9c61cd5967846fe6fb | 24c76f186e1998d47d1654aaa2e9470a9968292f | refs/heads/master | 2022-12-20T03:24:14.712763 | 2020-10-04T14:38:59 | 2020-10-04T14:38:59 | 300,847,284 | 1 | 0 | null | 2020-10-03T10:08:33 | 2020-10-03T09:50:59 | null | UTF-8 | C++ | false | false | 380 | cpp | #include<bits\stdc++.h>
using namespace std;
int main(){
int n;
cout<<"enter n:";
cin>>n;
if (n<=1){
return n;
}
else{
int a,b,current;
a = 0;
b = 1;
for (int i=2; i<n+1;i++){
current=a+b;
a=b;
b=current;
}
cout<<current;
}
return 0;
}
| [
"[email protected]"
] | |
79aa2643b034e19cdeb240da043941ff4d8217cd | f6ad1c5e9736c548ee8d41a7aca36b28888db74a | /others/POJ/1821.cpp | 1fc7fce386e6d08a1e9303bdea58433f43f01949 | [] | no_license | cnyali-czy/code | 7fabf17711e1579969442888efe3af6fedf55469 | a86661dce437276979e8c83d8c97fb72579459dd | refs/heads/master | 2021-07-22T18:59:15.270296 | 2021-07-14T08:01:13 | 2021-07-14T08:01:13 | 122,709,732 | 0 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 1,645 | cpp | #define DREP(i, s, e) for(register int i = s; i >= e ;i--)
#define REP(i, s, e) for(register int i = s; i <= e ;i++)
#define DEBUG fprintf(stderr, "Passing [%s] in Line %d\n", __FUNCTION__, __LINE__)
#define chkmax(a, b) a = max(a, b)
#define chkmin(a, b) a = min(a, b)
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
const int maxn = 100 + 5, maxm = 16000 + 10;
template <typename T> inline T read()
{
T ans(0), p(1);
char c = getchar();
while (!isdigit(c))
{
if (c == '-') p = -1;
c = getchar();
}
while (isdigit(c))
{
ans = ans * 10 + c - 48;
c = getchar();
}
return ans * p;
}
template <typename T> void write(T x)
{
if (x < 0) putchar('-'), write(-x);
else if (x / 10) write(x / 10);
putchar(x % 10 + '0');
}
int m, n, k;
struct Worker
{
int l, p, s;
bool operator < (Worker B) const {return s < B.s;}
}w[maxn];
int dp[maxn][maxm], q[maxm];
int calc(int i, int k) {return dp[i-1][k] - w[i].p * k;}
int main()
{
#ifdef CraZYali
freopen("1821.in", "r", stdin);
freopen("1821.out", "w", stdout);
#endif
cin >> m >> n;
REP(i, 1, n)
scanf("%d%d%d", &w[i].l, &w[i].p, &w[i].s);
sort(w + 1, w + 1 + n);
REP(i, 1, n)
{
register int l = 1, r = 0;
for (register int k = max(0, w[i].s - w[i].l) ; k <= w[i].s - 1; k++)
{
while (l <= r && calc(i, q[r]) <= calc(i, k)) r--;
q[++r] = k;
}
REP(j, 1, m)
{
dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
if (j >= w[i].s)
{
while (l <= r && q[l] < j - w[i].l) l++;
if (l <= r) chkmax(dp[i][j], calc(i, q[l]) + w[i].p * j);
}
}
}
cout << dp[n][m];
return 0;
}
| [
"[email protected]"
] | |
febebca396935f480fbde51224c98a36a17fb2b7 | 79039cdd2eb596dc6652c063004bd7598b6fef1f | /chrome/browser/browser_switcher/bho/mini_bho.cc | 54a6d3101d869ef149abac18361e34cc9f4a0829 | [
"BSD-3-Clause"
] | permissive | Aayaam-AI/chromium | e81a2500b03eb793083ed228c16fcbcc1a0ba2f8 | 9f70fea8672cc395f6453477a411a1eb5de2318b | refs/heads/master | 2023-03-02T10:53:32.344257 | 2019-09-04T18:42:41 | 2019-09-04T18:42:41 | 206,393,619 | 1 | 0 | BSD-3-Clause | 2019-09-04T19:08:18 | 2019-09-04T19:08:17 | null | UTF-8 | C++ | false | false | 26,199 | cc | // Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <windows.h>
#include <combaseapi.h>
#include <exdisp.h>
#include <exdispid.h>
#include <guiddef.h>
#include <objbase.h>
#include <oleauto.h>
#include <processthreadsapi.h>
#include <shellapi.h>
#include <shlobj.h>
#include <shlwapi.h>
#include <strsafe.h>
#include <wininet.h>
#include "chrome/browser/browser_switcher/bho/ie_bho_idl.h"
#include "chrome/browser/browser_switcher/bho/mini_bho_util.h"
// memset() and memcmp() needed for debug builds.
void* memset(void* ptr, int value, size_t num) {
// Naive, but only used in debug builds.
char* bytes = (char*)ptr;
for (size_t i = 0; i < num; i++)
bytes[i] = value;
return ptr;
}
int memcmp(const void* p1, const void* p2, size_t num) {
// Naive, but only used in debug builds.
char* bytes1 = (char*)p1;
char* bytes2 = (char*)p2;
for (size_t i = 0; i < num; i++) {
if (bytes1[i] != bytes2[i])
return bytes1[i] - bytes2[i];
}
return 0;
}
void* operator new(size_t num) {
return ::HeapAlloc(::GetProcessHeap(), 0, num);
}
void* operator new[](size_t num) {
return operator new(num);
}
void operator delete(void* ptr) {
::HeapFree(::GetProcessHeap(), 0, ptr);
}
void operator delete[](void* ptr) {
return operator delete(ptr);
}
const wchar_t kHttpPrefix[] = L"http://";
const wchar_t kHttpsPrefix[] = L"https://";
const wchar_t kFilePrefix[] = L"file://";
const wchar_t kChromeKey[] =
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\chrome.exe";
// TODO(crbug/950039): Add other varnames (${firefox}, ${opera}, ...)
const wchar_t kChromeVarName[] = L"${chrome}";
const wchar_t kUrlVarName[] = L"${url}";
const char kWildcardUrl[] = "*";
const int kMinSupportedFileVersion = 1;
const int kCurrentFileVersion = 1;
// Puts "AppData\Local\Google\BrowserSwitcher" in |out|. Returns false on
// failure.
//
// Make sure |out| is at least |MAX_PATH| long.
bool GetConfigPath(wchar_t* out) {
if (!::SHGetSpecialFolderPath(0, out, CSIDL_LOCAL_APPDATA, false)) {
util::puts("Error locating %LOCAL_APPDATA%!");
return false;
}
return S_OK == ::StringCchCatW(out, MAX_PATH, L"\\Google\\BrowserSwitcher");
}
// Puts "<config_path>\cache.dat" in |out|. Returns false on failure.
//
// Make sure |out| is at least |MAX_PATH| long.
bool GetConfigFileLocation(wchar_t* out) {
if (!GetConfigPath(out))
return false;
return S_OK == ::StringCchCatW(out, MAX_PATH, L"\\cache.dat");
}
// Puts "<config_path>\sitelistcache.dat" in |out|. Returns false on failure.
//
// Make sure |out| is at least |MAX_PATH| long.
bool GetIESitelistCacheLocation(wchar_t* out) {
if (!GetConfigPath(out))
return false;
return S_OK == ::StringCchCatW(out, MAX_PATH, L"\\sitelistcache.dat");
}
// Reads the contents of the text file and returns them as a null-terminated
// string.
//
// Returns an empty string (with capacity=1 and str[0]='\0') if the file is
// empty or doesn't exist.
util::string ReadFileToString(const wchar_t* path) {
HANDLE file = ::CreateFile(path, GENERIC_READ, FILE_SHARE_READ, nullptr,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
size_t file_size = 0;
if (file != INVALID_HANDLE_VALUE)
file_size = GetFileSize(file, nullptr);
util::string contents(file_size + 1);
contents[file_size] = '\0';
if (file_size != 0)
::ReadFile(file, contents.data(), file_size, nullptr, nullptr);
return contents;
}
// Checks if the omitted prefix for a non-fully specified prefix rule is one of
// the expected parts that are allowed to be omitted.
bool IsValidPrefix(const char* prefix, size_t prefix_len) {
static const char* kValidPrefixes[] = {
"https://", "https:", "http://", "http:", "file://", "file:",
};
for (const char* candidate : kValidPrefixes) {
if (!::StrCmpNA(prefix, candidate, prefix_len))
return true;
}
return false;
}
bool StringContainsInsensitiveASCII(const char* str, const char* target) {
size_t len = ::lstrlenA(target);
while (*str) {
if (!::StrCmpNA(str, target, len))
return true;
str++;
}
return false;
}
bool UrlMatchesPattern(const char* url,
const char* hostname,
const char* pattern) {
if (!::StrCmpA(pattern, kWildcardUrl)) {
// Wildcard, always match.
return true;
}
if (::StrChrA(pattern, '/') != nullptr) {
// Check prefix using the normalized URL. Case sensitive, but with
// case-insensitive scheme/hostname.
const char* pos = ::StrStrA(url, pattern);
if (pos == nullptr)
return false;
return IsValidPrefix(url, (pos - url));
}
// Compare hosts, case-insensitive.
return StringContainsInsensitiveASCII(hostname, pattern);
}
bool IsInverted(const char* rule) {
return *rule == '!';
}
util::wstring ReadRegValue(HKEY key, const wchar_t* name) {
DWORD length = 0;
if (ERROR_SUCCESS !=
::RegQueryValueEx(key, name, nullptr, nullptr, nullptr, &length)) {
util::printf(ERR, "Could not get the size of the value! %d\n",
::GetLastError());
return util::empty_wstring();
}
util::wstring value(length);
if (ERROR_SUCCESS != ::RegQueryValueEx(key, name, nullptr, nullptr,
reinterpret_cast<LPBYTE>(value.data()),
&length)) {
util::printf(ERR, "Could not get the value! %d\n", ::GetLastError());
return util::empty_wstring();
}
return value;
}
util::wstring GetChromeLocation() {
HKEY key;
if (ERROR_SUCCESS != ::RegOpenKey(HKEY_LOCAL_MACHINE, kChromeKey, &key) &&
ERROR_SUCCESS != ::RegOpenKey(HKEY_CURRENT_USER, kChromeKey, &key)) {
util::printf(ERR, "Could not open registry key %S! Error Code: %d\n",
kChromeKey, ::GetLastError());
return util::empty_wstring();
}
return ReadRegValue(key, nullptr);
}
util::wstring SanitizeUrl(const wchar_t* url) {
// In almost every case should this be enough for the sanitization because
// any ASCII char will expand to at most 3 chars - %[0-9A-F][0-9A-F].
const wchar_t untranslated_chars[] = L".:/\\_-@~();";
util::wstring sanitized_url(::lstrlenW(url) * 3 + 1);
const wchar_t* it = url;
wchar_t* output = sanitized_url.data();
while (*it) {
if (::IsCharAlphaNumeric(*it) ||
::StrChrW(untranslated_chars, *it) != nullptr) {
*output++ = *it;
} else {
// Will only work for ASCII chars but hey it's at least something.
// Any unicode char will be truncated to its first 8 bits and encoded.
*output++ = '%';
int nibble = (*it & 0xf0) >> 4;
*output++ = nibble > 9 ? nibble - 10 + 'A' : nibble + '0';
nibble = *it & 0xf;
*output++ = nibble > 9 ? nibble - 10 + 'A' : nibble + '0';
}
it++;
}
*output = '\0';
return sanitized_url;
}
util::wstring ExpandEnvironmentVariables(const wchar_t* str) {
util::wstring output;
DWORD expanded_size = 0;
expanded_size = ::ExpandEnvironmentStrings(str, nullptr, expanded_size);
if (expanded_size != 0) {
// The expected buffer length as defined in MSDN is chars + null + 1.
output = util::wstring(util::max(expanded_size, ::lstrlenW(str)) + 2);
expanded_size =
::ExpandEnvironmentStrings(str, output.data(), expanded_size);
}
return output;
}
util::wstring CanonicalizeUrl(const wchar_t* url) {
// In almost every case should this be enough for the sanitization because
// any ASCII char will expand to at most 3 chars - %[0-9A-F][0-9A-F].
DWORD capacity = static_cast<DWORD>(::lstrlenW(url) * 3 + 1);
util::wstring sanitized_url(capacity);
if (!::InternetCanonicalizeUrl(url, sanitized_url.data(), &capacity, 0)) {
DWORD error = ::GetLastError();
if (error == ERROR_INSUFFICIENT_BUFFER) {
// If we get this error it means that the buffer is too small to hold
// the canoncial url. In that case resize the buffer to what the
// requested size is (returned in |capacity|) and try again.
sanitized_url = util::wstring(capacity);
if (!::InternetCanonicalizeUrl(url, sanitized_url.data(), &capacity, 0))
sanitized_url = util::empty_wstring();
}
}
// If the API failed, do some poor man's sanitizing at least.
if (sanitized_url[0] == '\0') {
util::printf(WARNING, "::InternetCanonicalizeUrl failed : %d\n",
::GetLastError());
sanitized_url = SanitizeUrl(url);
}
return sanitized_url;
}
util::wstring CompileCommandLine(const wchar_t* raw_command_line,
const wchar_t* url) {
util::wstring sanitized_url = CanonicalizeUrl(url);
// +2 for the extra space we might insert, plus the terminating null char.
const size_t max_possible_size =
::lstrlenW(sanitized_url.data()) + ::lstrlenW(raw_command_line) + 2;
util::wstring command_line(max_possible_size);
::StringCchCopyW(command_line.data(), max_possible_size, raw_command_line);
bool had_url_placeholder = util::wcs_replace_s(
command_line.data(), max_possible_size, kUrlVarName, url);
if (!had_url_placeholder) {
if (*raw_command_line == '\0') {
::StringCchCatW(command_line.data(), max_possible_size,
sanitized_url.data());
} else {
::StringCchCatW(command_line.data(), max_possible_size, L" ");
::StringCchCatW(command_line.data(), max_possible_size,
sanitized_url.data());
}
}
return ExpandEnvironmentVariables(command_line.data());
}
util::wstring ExpandChromePath(const char* orig) {
util::wstring path = util::utf8_to_utf16(orig);
if (path[0] == '\0' || !::StrCmpW(path.data(), kChromeVarName))
path = GetChromeLocation();
path = ExpandEnvironmentVariables(path.data());
return path;
}
enum TransitionDecision {
NONE,
CHROME,
ALT_BROWSER,
};
class BrowserSwitcherCore {
public:
// Initializes configuration by parsing the file contents.
explicit BrowserSwitcherCore(util::string&& cache_file_contents,
util::string&& sitelistcache_file_contents) {
cache_file_contents_ = std::move(cache_file_contents);
sitelistcache_file_contents_ = std::move(sitelistcache_file_contents);
ParseCacheFile();
ParseSitelistCacheFile();
util::printf(DEBUG, "configuration_valid = %s\n",
(configuration_valid_ ? "true" : "false"));
}
bool ShouldOpenInChrome(const wchar_t* url) {
return (GetDecision(url) == CHROME);
}
bool InvokeChrome(const wchar_t* url) {
util::wstring path = ExpandChromePath(chrome_path_);
util::wstring command_line = util::utf8_to_utf16(chrome_parameters_);
command_line = CompileCommandLine(command_line.data(), url);
HINSTANCE browser_instance =
::ShellExecute(nullptr, nullptr, path.data(), command_line.data(),
nullptr, SW_SHOWNORMAL);
if (reinterpret_cast<int>(browser_instance) <= 32) {
util::printf(ERR, "Could not start Chrome! Handle: %d %d\n",
reinterpret_cast<int>(browser_instance), ::GetLastError());
return false;
}
return true;
}
private:
// Initiates the parsing of |str| and returns the first line of the file, as a
// null-terminated string (without LF/CRLF).
//
// If there is no such line, returns nullptr and flips |configuration_valid_|
// to false.
char* GetFirstLine(char* str) {
char* line = util::strtok(str, "\n");
if (!line)
configuration_valid_ = false;
size_t len = ::lstrlenA(line);
// Remove '\r' if it was '\r\n'.
if (line[len - 1] == '\r')
line[len - 1] = '\0';
return line;
}
// Like GetNextLine(char*), but gets the next line instead of the first one.
char* GetNextLine() { return GetNextLine(nullptr); }
// Read a line that contains a number, and then read that number of lines into
// a vector (one element for each line).
util::vector<const char*> ReadList() {
char* line = GetNextLine();
if (!line)
return util::vector<const char*>();
int list_size;
bool success = ::StrToIntExA(line, 0, &list_size);
if (!success) {
configuration_valid_ = false;
return util::vector<const char*>();
}
util::printf(INFO, "list size : '%d'\n", list_size);
util::vector<const char*> list = util::vector<const char*>(list_size);
for (int i = 0; i < list_size; i++) {
list[i] = GetNextLine();
util::printf(INFO, "url : '%s'\n", list[i]);
}
return list;
}
// Parses cache.dat. Sets |configuration_valid_| to false if it fails.
void ParseCacheFile() {
util::puts(INFO, "Loading cache.dat");
char* line = GetFirstLine(cache_file_contents_.data());
if (!line)
return;
int version;
bool success = ::StrToIntExA(line, 0, &version);
if (!success || version < kMinSupportedFileVersion ||
version > kCurrentFileVersion) {
configuration_valid_ = false;
return;
}
GetNextLine(); // Skip IE path.
GetNextLine(); // Skip IE parameters.
chrome_path_ = GetNextLine();
util::printf(INFO, "chrome_path : '%s'\n", chrome_path_);
chrome_parameters_ = GetNextLine();
util::printf(INFO, "chrome_parameters : '%s'\n", chrome_parameters_);
util::puts(INFO, "Reading url list...");
cache_.sitelist = ReadList();
util::puts(INFO, "Reading grey list...");
cache_.greylist = ReadList();
}
// Parses |sitelistcache.dat|. Sets |configuration_valid_| to false if it
// fails.
void ParseSitelistCacheFile() {
util::puts(INFO, "Loading sitelistcache.dat");
// Special case: don't set |configuration_valid_| to false if the file is
// straight-up empty or doesn't exist.
if (sitelistcache_file_contents_[0] == '\0')
return;
char* line = GetFirstLine(sitelistcache_file_contents_.data());
if (!line)
return;
int version;
bool success = StrToIntExA(line, 0, &version);
if (!success || version < kMinSupportedFileVersion ||
version > kCurrentFileVersion) {
configuration_valid_ = false;
return;
}
sitelistcache_.sitelist = ReadList();
sitelistcache_.greylist = util::vector<const char*>();
}
TransitionDecision GetDecision(const wchar_t* url) {
// Switch to Chrome by default.
TransitionDecision decision = CHROME;
// Since we cannot decide in this case we should assume it is ok to use
// Chrome.
//
// XXX: this might be incorrect, and cause redirect loops...
if (!configuration_valid_)
return ALT_BROWSER;
// Only verify the url if is http[s] or file link.
if (::StrCmpNW(url, kHttpPrefix, ::lstrlenW(kHttpPrefix)) &&
::StrCmpNW(url, kHttpsPrefix, ::lstrlenW(kHttpsPrefix)) &&
::StrCmpNW(url, kFilePrefix, ::lstrlenW(kFilePrefix))) {
return NONE;
}
util::string utf8_url = util::utf16_to_utf8(url);
util::string hostname(utf8_url.capacity());
::StringCchCopyA(hostname.data(), hostname.capacity(), utf8_url.data());
URL_COMPONENTS parsed_url = {0};
parsed_url.dwStructSize = sizeof(parsed_url);
parsed_url.dwHostNameLength = static_cast<DWORD>(-1);
parsed_url.dwSchemeLength = static_cast<DWORD>(-1);
parsed_url.dwUrlPathLength = static_cast<DWORD>(-1);
parsed_url.dwExtraInfoLength = static_cast<DWORD>(-1);
if (::InternetCrackUrl(url, 0, 0, &parsed_url)) {
hostname = util::utf16_to_utf8(parsed_url.lpszHostName);
hostname[parsed_url.dwHostNameLength] = '\0';
} else {
util::puts(ERR, "URL Parsing failed!");
}
const RuleSet* rulesets[] = {&cache_, &sitelistcache_};
size_t decision_rule_length = 0;
for (const auto* ruleset : rulesets) {
for (const char* pattern : ruleset->sitelist) {
size_t pattern_length = ::lstrlenA(pattern);
if (pattern_length <= decision_rule_length)
continue;
bool inverted = IsInverted(pattern);
// Skip "!" in the pattern.
if (inverted)
pattern++;
if (UrlMatchesPattern(utf8_url.data(), hostname.data(), pattern)) {
decision = (inverted ? CHROME : ALT_BROWSER);
decision_rule_length = pattern_length;
}
}
}
// If the sitelist matches, no need to check the greylist.
if (decision == ALT_BROWSER)
return decision;
for (const auto* ruleset : rulesets) {
for (const char* pattern : ruleset->greylist) {
size_t pattern_length = ::lstrlenA(pattern);
if (pattern_length <= decision_rule_length)
continue;
if (UrlMatchesPattern(utf8_url.data(), hostname.data(), pattern)) {
decision = NONE;
decision_rule_length = pattern_length;
}
}
}
return decision;
}
// Buffers containing the contents of the config files. Other fields are
// pointers inside these strings, so keep them in memory.
util::string cache_file_contents_;
util::string sitelistcache_file_contents_;
const char* chrome_path_;
const char* chrome_parameters_;
// Each rule is a pointer to a null-terminated string inside
// |[sitelist_]cache_file_contents_|.
struct RuleSet {
util::vector<const char*> sitelist;
util::vector<const char*> greylist;
};
RuleSet cache_;
RuleSet sitelistcache_;
// Tracks the validity of the cached configuration. Gets flipped to false if
// parsing fails during construction.
bool configuration_valid_ = true;
};
class CBrowserSwitcherBHO final : public IBrowserSwitcherBHO,
public IObjectWithSite {
public:
explicit CBrowserSwitcherBHO(BrowserSwitcherCore* core) : core_(core) {
util::puts(DEBUG, "CBrowserSwitcherBHO()");
}
~CBrowserSwitcherBHO() {
// Useful for finding leaks.
util::puts(DEBUG, "~CBrowserSwitcherBHO()");
}
//////////////////////////////
// IDispatch:
//////////////////////////////
HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT* pctinfo) override {
// TypeInfo is for chumps.
*pctinfo = 0;
return S_OK;
}
HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT iTInfo,
LCID lcid,
ITypeInfo** ppTInfo) override {
if (iTInfo != 0)
return DISP_E_BADINDEX;
*ppTInfo = nullptr;
return S_OK;
}
HRESULT STDMETHODCALLTYPE GetIDsOfNames(REFIID riid,
LPOLESTR* rgszNames,
UINT cNames,
LCID lcid,
DISPID* rgDispId) override {
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember,
REFIID riid,
LCID lcid,
WORD wFlags,
DISPPARAMS* pDispParams,
VARIANT* pVarResult,
EXCEPINFO* pExcepInfo,
UINT* puArgErr) override {
if (dispIdMember != DISPID_BEFORENAVIGATE2)
return S_OK;
BeforeNavigate(
pDispParams->rgvarg[6].pdispVal, pDispParams->rgvarg[5].pvarVal,
pDispParams->rgvarg[4].pvarVal, pDispParams->rgvarg[3].pvarVal,
pDispParams->rgvarg[2].pvarVal, pDispParams->rgvarg[1].pvarVal,
pDispParams->rgvarg[0].pboolVal);
return S_OK;
}
//////////////////////////////
// IObjectWithSite:
//////////////////////////////
STDMETHODIMP(SetSite(IUnknown* site)) override {
HRESULT hr = S_OK;
if (site != nullptr) {
hr = site->QueryInterface(IID_IWebBrowser2,
reinterpret_cast<void**>(&web_browser_));
if (SUCCEEDED(hr))
hr = Advise();
} else {
Unadvise();
web_browser_->Release();
}
if (site_ != nullptr)
site_->Release();
site_ = site;
if (site_ != nullptr)
site_->AddRef();
return hr;
}
STDMETHODIMP(GetSite(REFIID riid, void** ppvSite)) override {
if (site_ == nullptr) {
*ppvSite = nullptr;
return E_FAIL;
}
return site_->QueryInterface(riid, ppvSite);
}
//////////////////////////////
// IUnknown:
//////////////////////////////
STDMETHODIMP(QueryInterface)(REFIID riid, LPVOID* ppv) override {
if (ppv == nullptr)
return E_POINTER;
if (IsEqualIID(riid, IID_IUnknown) ||
IsEqualIID(riid, IID_IBrowserSwitcherBHO)) {
*ppv = this;
AddRef();
return S_OK;
}
if (IsEqualIID(riid, IID_IDispatch)) {
*ppv = static_cast<IDispatch*>(this);
AddRef();
return S_OK;
}
if (IsEqualIID(riid, IID_IObjectWithSite)) {
*ppv = static_cast<IObjectWithSite*>(this);
AddRef();
return S_OK;
}
*ppv = nullptr;
return E_NOINTERFACE;
}
ULONG STDMETHODCALLTYPE AddRef() override { return ++refcount_; }
ULONG STDMETHODCALLTYPE Release() override {
refcount_--;
if (refcount_ <= 0)
delete this;
return refcount_;
}
private:
void STDMETHODCALLTYPE BeforeNavigate(IDispatch* disp,
VARIANT* url,
VARIANT* flags,
VARIANT* target_frame_name,
VARIANT* post_data,
VARIANT* headers,
VARIANT_BOOL* cancel) {
if (web_browser_ == nullptr || disp == nullptr)
return;
IUnknown* unknown1 = nullptr;
IUnknown* unknown2 = nullptr;
if (SUCCEEDED(web_browser_->QueryInterface(
IID_IUnknown, reinterpret_cast<void**>(&unknown1))) &&
SUCCEEDED(disp->QueryInterface(IID_IUnknown,
reinterpret_cast<void**>(&unknown2)))) {
// Check if this is the outer frame.
if (unknown1 == unknown2) {
bool result = core_->ShouldOpenInChrome(url->bstrVal);
if (result) {
if (!core_->InvokeChrome(url->bstrVal)) {
util::puts(ERR,
"Could not invoke alternative browser! "
"Will resume loading in IE!");
} else {
*cancel = VARIANT_TRUE;
web_browser_->Quit();
}
}
}
}
if (unknown1)
unknown1->Release();
if (unknown2)
unknown2->Release();
}
HRESULT GetConnectionPoint(IConnectionPoint** cp) {
IConnectionPointContainer* cp_container;
HRESULT hr = web_browser_->QueryInterface(
IID_IConnectionPointContainer, reinterpret_cast<void**>(&cp_container));
if (SUCCEEDED(hr))
hr = cp_container->FindConnectionPoint(DIID_DWebBrowserEvents2, cp);
return hr;
}
HRESULT Advise() {
IConnectionPoint* cp;
HRESULT hr = GetConnectionPoint(&cp);
if (SUCCEEDED(hr))
hr = cp->Advise(
static_cast<IUnknown*>(static_cast<IObjectWithSite*>(this)),
&event_cookie_);
advised_ = true;
return hr;
}
void Unadvise() {
if (!advised_)
return;
IConnectionPoint* cp;
HRESULT hr = GetConnectionPoint(&cp);
if (SUCCEEDED(hr))
hr = cp->Unadvise(event_cookie_);
advised_ = false;
}
BrowserSwitcherCore* core_;
DWORD event_cookie_;
bool advised_ = false;
IWebBrowser2* web_browser_ = nullptr;
IUnknown* site_ = nullptr;
size_t refcount_ = 0;
};
BrowserSwitcherCore* g_browser_switcher_core = nullptr;
class CBrowserSwitcherBHOClass final : public IClassFactory {
public:
static CBrowserSwitcherBHOClass* GetInstance() { return &instance_; }
//////////////////////////////
// IClassFactory:
//////////////////////////////
STDMETHODIMP(CreateInstance)
(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObject) override {
if (ppvObject == nullptr)
return E_POINTER;
auto* bho = new CBrowserSwitcherBHO(g_browser_switcher_core);
return bho->QueryInterface(riid, ppvObject);
}
STDMETHODIMP(LockServer)(BOOL fLock) override { return S_OK; }
//////////////////////////////
// IUnknown:
//////////////////////////////
STDMETHODIMP(QueryInterface)(REFIID riid, LPVOID* ppv) override {
if (ppv == nullptr)
return E_POINTER;
if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory)) {
*ppv = this;
return S_OK;
}
*ppv = nullptr;
return E_NOINTERFACE;
}
ULONG STDMETHODCALLTYPE AddRef() override {
// Not actually refcounted, just a singleton.
return 1;
}
ULONG STDMETHODCALLTYPE Release() override { return 1; }
private:
CBrowserSwitcherBHOClass() = default;
static CBrowserSwitcherBHOClass instance_;
};
CBrowserSwitcherBHOClass CBrowserSwitcherBHOClass::instance_;
extern "C" BOOL WINAPI DllMain(HINSTANCE instance,
DWORD reason,
LPVOID reserved) {
switch (reason) {
case DLL_PROCESS_ATTACH:
util::InitLog();
util::puts(DEBUG, "DLL_PROCESS_ATTACH");
{
wchar_t config_file[MAX_PATH];
GetConfigFileLocation(config_file);
wchar_t sitelist_file[MAX_PATH];
GetIESitelistCacheLocation(sitelist_file);
if (g_browser_switcher_core != nullptr)
delete g_browser_switcher_core;
g_browser_switcher_core = new BrowserSwitcherCore(
ReadFileToString(config_file), ReadFileToString(sitelist_file));
}
break;
case DLL_PROCESS_DETACH:
util::puts(DEBUG, "DLL_PROCESS_DETACH");
util::CloseLog();
delete g_browser_switcher_core;
g_browser_switcher_core = nullptr;
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
default:
break;
}
return true;
}
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) {
if (ppv == nullptr)
return E_POINTER;
if (!IsEqualCLSID(rclsid, CLSID_BrowserSwitcherBHO))
return E_INVALIDARG;
*ppv = nullptr;
return CBrowserSwitcherBHOClass::GetInstance()->QueryInterface(riid, ppv);
}
| [
"[email protected]"
] | |
572e8bcea89b587f66337b21442df4a477e71141 | 600df3590cce1fe49b9a96e9ca5b5242884a2a70 | /third_party/WebKit/Source/core/animation/SVGTransformListInterpolationType.h | 63b619f6a21dafba593fbd981f7a8d2ce6507cd0 | [
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"MIT",
"Apache-2.0",
"BSD-2-Clause",
"LGPL-2.1-only",
"LGPL-2.0-only",
"BSD-3-Clause",
"LicenseRef-scancode-warranty-disclaimer",
"GPL-2.0-only",
"LicenseRef-scancode-other-copyleft"
] | permissive | metux/chromium-suckless | efd087ba4f4070a6caac5bfbfb0f7a4e2f3c438a | 72a05af97787001756bae2511b7985e61498c965 | refs/heads/orig | 2022-12-04T23:53:58.681218 | 2017-04-30T10:59:06 | 2017-04-30T23:35:58 | 89,884,931 | 5 | 3 | BSD-3-Clause | 2022-11-23T20:52:53 | 2017-05-01T00:09:08 | null | UTF-8 | C++ | false | false | 1,626 | h | // Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SVGTransformListInterpolationType_h
#define SVGTransformListInterpolationType_h
#include "core/animation/SVGInterpolationType.h"
#include "core/svg/SVGTransform.h"
namespace blink {
class SVGTransformListInterpolationType : public SVGInterpolationType {
public:
SVGTransformListInterpolationType(const QualifiedName& attribute)
: SVGInterpolationType(attribute) {}
private:
InterpolationValue maybeConvertNeutral(const InterpolationValue&,
ConversionCheckers&) const final;
InterpolationValue maybeConvertSVGValue(
const SVGPropertyBase& svgValue) const final;
InterpolationValue maybeConvertSingle(const PropertySpecificKeyframe&,
const InterpolationEnvironment&,
const InterpolationValue& underlying,
ConversionCheckers&) const final;
SVGPropertyBase* appliedSVGValue(const InterpolableValue&,
const NonInterpolableValue*) const final;
PairwiseInterpolationValue maybeMergeSingles(
InterpolationValue&& start,
InterpolationValue&& end) const final;
void composite(UnderlyingValueOwner&,
double underlyingFraction,
const InterpolationValue&,
double interpolationFraction) const final;
};
} // namespace blink
#endif // SVGTransformListInterpolationType_h
| [
"[email protected]"
] | |
b9dd20452f4fe1ea2095d16591b5d00ce95ed29e | a2d1df88f38ed21ff42f8f56c63031ac5cc49abe | /abc164/a.cpp | a3cd5bcb9c68581eb3073d8325bd3b6ac79f4ca7 | [] | no_license | honyacho/atcoder_excercise | 70831d77a328cae82b0594da4bb3f04e995ef001 | aa119994e53abb0bb0f47e0002704e48984ffb38 | refs/heads/master | 2021-06-14T02:26:51.918702 | 2021-03-15T05:48:56 | 2021-03-15T05:48:56 | 173,929,129 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,334 | cpp | #include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;
int main(int argc, char const *argv[])
{
ll S,W; cin >> S >> W;
cout << (W >= S ? "unsafe" : "safe") << endl;
return 0;
}
| [
"[email protected]"
] | |
e95a6f7eb7f59d0982efa9550a4f8ea27384b03d | d78083416302e74b9c5232066422cf3800406903 | /GxFramework/cocos2d-x/templates/lua-template-default/frameworks/runtime-src/proj.linux/main.cpp | 5204bcc1a56cd215e7801527406b4ebe789a12db | [
"MIT"
] | permissive | Gui-X/CocosLuaGame | 4e82fd617e2e43d1173006f5d36e56e33c9a17a9 | c9e943db17b91a5d4448e727f27bd463275ec2df | refs/heads/master | 2020-03-27T08:43:18.234358 | 2018-09-12T05:40:18 | 2018-09-12T05:40:18 | 146,281,470 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,616 | cpp | /****************************************************************************
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
http://www.cocos2d-x.org
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 "../Classes/AppDelegate.h"
#include "cocos2d.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string>
USING_NS_CC;
int main(int argc, char **argv)
{
// create the application instance
AppDelegate app;
return Application::getInstance()->run();
}
| [
"[email protected]"
] | |
75b199ec3c1adf86e30ca79dbbdd4a88990e0921 | 4610baf9a7e81cad6e52fe49289a5f234861732b | /libraries/kdtree/src/bucket.cpp | 7cb7e8cf9fb019aa7f0a73bfc26cf0041b7db7a4 | [] | no_license | kuasha/stanley | 07f924f6ff61413f5baabd5b6605d4289e93c68d | b6b6d3a9efd4611258b2a6337ef25007f406bd80 | refs/heads/master | 2021-01-19T00:57:09.752337 | 2016-08-15T02:36:18 | 2016-08-15T02:36:18 | 65,698,509 | 6 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,980 | cpp | /********************************************************
Stanford Driving Software
Copyright (c) 2011 Stanford University
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 the 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 <global.h>
#include "bucket.h"
using namespace dgc;
bucket_grid::bucket_grid(double resolution, double width, double height)
{
int i, j;
this->resolution = resolution;
x_size = (int)ceil(width / resolution);
y_size = (int)ceil(height / resolution);
grid = (bucket_t **)calloc(x_size, sizeof(bucket_t *));
dgc_test_alloc(grid);
for(i = 0; i < x_size; i++) {
grid[i] = (bucket_t *)calloc(y_size, sizeof(bucket_t));
dgc_test_alloc(grid[i]);
for(j = 0; j < y_size; j++) {
grid[i][j].num_points = 0;
grid[i][j].max_points = 0;
grid[i][j].point = NULL;
}
}
}
bucket_grid::~bucket_grid()
{
int x, y;
for(x = 0; x < x_size; x++) {
for(y = 0; y < y_size; y++)
if(grid[x][y].point != NULL)
free(grid[x][y].point);
free(grid[x]);
}
free(grid);
}
void bucket_grid::clear(void)
{
int x, y;
for(x = 0; x < x_size; x++)
for(y = 0; y < y_size; y++)
grid[x][y].num_points = 0;
}
void bucket_grid::build_grid(double *x, double *y, int num_points)
{
int i, xi, yi;
bucket_t *bucket;
bucket_point *p;
clear();
if(num_points == 0) {
this->min_x = 0;
this->min_y = 0;
}
else {
this->min_x = x[0];
this->min_y = y[0];
for(i = 0; i < num_points; i++) {
if(x[i] < this->min_x)
this->min_x = x[i];
if(y[i] < this->min_y)
this->min_y = y[i];
}
for(i = 0; i < num_points; i++) {
xi = (int)floor((x[i] - min_x) / resolution);
yi = (int)floor((y[i] - min_y) / resolution);
if(xi >= 0 && yi >= 0 && xi < x_size && yi < y_size) {
bucket = grid[xi] + yi;
if(bucket->num_points == bucket->max_points) {
bucket->max_points += 100;
bucket->point = (bucket_point *)
realloc(bucket->point, bucket->max_points *
sizeof(bucket_point));
}
p = bucket->point + bucket->num_points;
p->x = x[i];
p->y = y[i];
p->id = i;
bucket->num_points++;
}
}
}
}
void bucket_grid::build_grid(double *x, double *y, int num_points,
double min_x, double min_y)
{
int i, xi, yi;
bucket_t *bucket;
bucket_point *p;
clear();
this->min_x = min_x;
this->min_y = min_y;
for(i = 0; i < num_points; i++) {
xi = (int)floor((x[i] - min_x) / resolution);
yi = (int)floor((y[i] - min_y) / resolution);
if(xi >= 0 && yi >= 0 && xi < x_size && yi < y_size) {
bucket = grid[xi] + yi;
if(bucket->num_points == bucket->max_points) {
bucket->max_points += 100;
bucket->point = (bucket_point *)
realloc(bucket->point, bucket->max_points *
sizeof(bucket_point));
}
p = bucket->point + bucket->num_points;
p->x = x[i];
p->y = y[i];
p->id = i;
bucket->num_points++;
}
}
}
#ifdef blah
void bucket_grid::sync_to_map(dgc_grid_p obstacle_grid)
{
int n, i, xi, yi;
dgc_perception_map_grid_p cell;
bucket_t *bucket;
if(obstacle_grid != NULL) {
min_x = obstacle_grid->map_c0 * obstacle_grid->resolution;
min_y = obstacle_grid->map_r0 * obstacle_grid->resolution;
cell = (dgc_perception_map_grid_p)obstacle_grid->cell;
n = obstacle_grid->rows * obstacle_grid->cols;
for(i = 0; i < n; i++) {
if(cell->type != PERCEPTION_MAP_OBSTACLE_FREE &&
(cell->type == PERCEPTION_MAP_OBSTACLE_HIGH ||
cell->type == PERCEPTION_MAP_OBSTACLE_LOW)) {
xi = (int)floor((cell->x - min_x) / resolution);
yi = (int)floor((cell->y - min_y) / resolution);
if(xi >= 0 && yi >= 0 && xi < x_size && yi < y_size) {
bucket = grid[xi] + yi;
if(bucket->num_cells == bucket->max_cells) {
bucket->max_cells += 100;
bucket->cell = (dgc_perception_map_grid_p *)
realloc(bucket->cell, bucket->max_cells *
sizeof(dgc_perception_map_grid_p));
}
bucket->cell[bucket->num_cells] = cell;
bucket->num_cells++;
}
}
cell++;
}
}
}
#endif
inline void dgc_neighbor_list_add(dgc_neighbor_list_p *list,
double x, double y, int id, double distance)
{
dgc_neighbor_list_p temp;
temp = (dgc_neighbor_list_p)calloc(1, sizeof(dgc_neighbor_list_t));
temp->x = x;
temp->y = y;
temp->id = id;
temp->distance = distance;
temp->next = *list;
*list = temp;
}
void dgc_neighbor_list_free(dgc_neighbor_list_p *list)
{
dgc_neighbor_list_p temp;
while(*list != NULL) {
temp = *list;
*list = (*list)->next;
free(temp);
}
}
inline int dgc_neighbor_list_length(dgc_neighbor_list_p list)
{
int count = 0;
while(list != NULL) {
count++;
list = list->next;
}
return count;
}
void dgc_neighbor_list_print(dgc_neighbor_list_p list)
{
int i = 0;
fprintf(stderr, "Point list : \n");
while(list != NULL) {
fprintf(stderr, "%d : %.2f, %.2f %d - %.2f\n", i,
list->x, list->y, list->id, list->distance);
list = list->next;
i++;
}
fprintf(stderr, "\n");
}
void bucket_grid::nearest_neighbor(double x, double y, double max_range,
double *closest_x, double *closest_y,
int *which, double *distance)
{
double range_sq = max_range * max_range, d_sq, min_d_sq;
int xi1, xi2, yi1, yi2, r, c, i, n;
bucket_t *bucket;
bucket_point *p;
xi1 = (int)floor((x - max_range - min_x) / resolution);
yi1 = (int)floor((y - max_range - min_y) / resolution);
xi2 = (int)floor((x + max_range - min_x) / resolution);
yi2 = (int)floor((y + max_range - min_y) / resolution);
min_d_sq = range_sq;
*which = -1;
for(c = xi1; c <= xi2; c++)
for(r = yi1; r <= yi2; r++) {
if(c < 0 || r < 0 || c >= x_size || r >= y_size)
continue;
bucket = grid[c] + r;
n = bucket->num_points;
for(i = 0; i < n; i++) {
p = bucket->point + i;
d_sq = (p->x - x) * (p->x - x) + (p->y - y) * (p->y - y);
if(d_sq <= min_d_sq) {
min_d_sq = d_sq;
*closest_x = p->x;
*closest_y = p->y;
*which = p->id;
}
}
}
if(*which != -1)
*distance = sqrt(min_d_sq);
}
dgc_neighbor_list_p bucket_grid::range_search(double x, double y, double range)
{
double range_sq = range * range, d_sq;
int xi1, xi2, yi1, yi2, r, c, i, n;
dgc_neighbor_list_p neighbor_list = NULL;
bucket_point *p;
bucket_t *bucket;
xi1 = (int)floor((x - range - min_x) / resolution);
yi1 = (int)floor((y - range - min_y) / resolution);
xi2 = (int)floor((x + range - min_x) / resolution);
yi2 = (int)floor((y + range - min_y) / resolution);
for(c = xi1; c <= xi2; c++)
for(r = yi1; r <= yi2; r++) {
if(c < 0 || r < 0 || c >= x_size || r >= y_size)
continue;
bucket = grid[c] + r;
n = bucket->num_points;
for(i = 0; i < n; i++) {
p = bucket->point + i;
d_sq = (p->x - x) * (p->x - x) + (p->y - y) * (p->y - y);
if(d_sq <= range_sq)
dgc_neighbor_list_add(&neighbor_list, p->x, p->y, p->id, sqrt(d_sq));
}
}
return neighbor_list;
}
void bucket_grid::range_search(double x, double y, double range,
bucket_point **neighbor_list,
int *max_n)
{
double range_sq = range * range;
int xi1 = (int)floor((x - range - min_x) / resolution);
int yi1 = (int)floor((y - range - min_y) / resolution);
int xi2 = (int)floor((x + range - min_x) / resolution);
int yi2 = (int)floor((y + range - min_y) / resolution);
int list_n = 0;
for(int c = xi1; c <= xi2; c++) {
for(int r = yi1; r <= yi2; r++) {
if(c < 0 || r < 0 || c >= x_size || r >= y_size)
continue;
bucket_t *bucket = grid[c] + r;
int n = bucket->num_points;
for (int i = 0; i < n && list_n < *max_n; i++) {
bucket_point *p = bucket->point + i;
double d_sq = (p->x - x) * (p->x - x) + (p->y - y) * (p->y - y);
if (d_sq <= range_sq)
neighbor_list[list_n++] = p;
}
}
}
*max_n = list_n;
}
void bucket_grid::print_stats(void)
{
int x, y;
int max_points = 0, total_points = 0;
bucket_t *bucket;
for(x = 0; x < x_size; x++)
for(y = 0; y < y_size; y++) {
bucket = grid[x] + y;
if(bucket->num_points > max_points)
max_points = bucket->num_points;
total_points += bucket->num_points;
}
fprintf(stderr, "Num buckets : %d\n", x_size * y_size);
fprintf(stderr, "Total points in buckets : %d\n", total_points);
fprintf(stderr, "Maximum number of points per cell : %d\n", max_points);
fprintf(stderr, "Average number of points per cell : %.2f\n",
total_points / (double)(x_size * y_size));
}
| [
"[email protected]"
] | |
a94943c20821c0f6985b1c921772f552b944be4e | 0a846bc85ecc6ecab462cfae5db84a54c9defa4a | /applications/popart/transformer_transducer/custom_ops/feat_augmentation/gen_random.hpp | febac2923364fc5e70a66ddc4d0effd241e304dd | [
"MIT"
] | permissive | payoto/graphcore_examples | c7d4d931dc3649567f8023279842345aa50cc3b3 | 46d2b7687b829778369fc6328170a7b14761e5c6 | refs/heads/master | 2022-02-08T20:00:55.182795 | 2021-12-21T11:38:07 | 2021-12-21T11:38:07 | 251,254,539 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 309 | hpp | // Copyright (c) 2021 Graphcore Ltd. All rights reserved.
#pragma once
#include <cstdint>
struct IRndGenerator {
virtual ~IRndGenerator() = default;
virtual void setRandomSeed(uint64_t seed) = 0;
virtual uint32_t getRandom() = 0;
virtual int32_t getRandom(int32_t from, int32_t to) = 0;
};
| [
"[email protected]"
] | |
a7939481a46b1fca27a76437585b5e20346ca950 | efe1131a33ee82e7c46b5af4cf200dcae8eb4add | /samples/MFC32/GENERAL/TRACKER/TRACKVW.H | e4b8c97cc40bf31de05ee25ee8a4e064b17c232e | [
"BSL-1.0"
] | permissive | ALEHACKsp/dmc | 819398bbb46e8b5a8ef5c344ef2a0f8b4ee8903c | 9478d25a677f70dbe4fc0ed317cc5a5e5050ef8b | refs/heads/master | 2022-12-28T13:36:57.721262 | 2020-10-11T07:47:16 | 2020-10-11T07:47:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,841 | h | // trackvw.h : interface of the CTrackerView class
//
// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (C) 1992-1995 Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
/////////////////////////////////////////////////////////////////////////////
class CTrackerView : public CView
{
protected: // create from serialization only
CTrackerView();
DECLARE_DYNCREATE(CTrackerView)
// Attributes
public:
CTrackerDoc* GetDocument();
// Operations
public:
// Implementation
public:
virtual ~CTrackerView();
virtual void OnDraw(CDC* pDC); // overridden to draw this view
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);
// Printing support
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
// Generated message map functions
protected:
//{{AFX_MSG(CTrackerView)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
afx_msg void OnViewSethandlesize();
afx_msg void OnViewSetminimumsize();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in trackvw.cpp
inline CTrackerDoc* CTrackerView::GetDocument()
{ return (CTrackerDoc*) m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////
| [
"[email protected]"
] | |
f170cdea3d8676a6d04f1d144dbc896b831356fd | db1b16bdd08a8cbcd6b676b151805d68d4bf6684 | /lib/DS1307RTC/examples/SetTime/SetTime.ino | 446af87cea8239fc4f1393e2438f31ebf91910ed | [] | no_license | Storfoten/Watering | c96f892ff010b5fccd9e02413966c981a1f1eae2 | f6be84c82f03a9b787c98cef99413e360e3d805e | refs/heads/master | 2021-01-17T23:31:01.736338 | 2016-12-21T18:39:03 | 2016-12-21T18:39:03 | 60,149,504 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,676 | ino | #include <Wire.h>
#include <Time.h>
#include "DS1307RTC.h"
const char *monthName[12] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
tmElements_t tm;
void setup() {
bool parse=false;
bool config=false;
// get the date and time the compiler was run
if (getDate(__DATE__) && getTime(__TIME__)) {
parse = true;
// and configure the RTC with this info
if (RTC.write(tm)) {
config = true;
}
}
Serial.begin(9600);
while (!Serial) ; // wait for Arduino Serial Monitor
delay(200);
if (parse && config) {
Serial.print("DS1307 configured Time=");
Serial.print(__TIME__);
Serial.print(", Date=");
Serial.println(__DATE__);
} else if (parse) {
Serial.println("DS1307 Communication Error :-{");
Serial.println("Please check your circuitry");
} else {
Serial.print("Could not parse info from the compiler, Time=\"");
Serial.print(__TIME__);
Serial.print("\", Date=\"");
Serial.print(__DATE__);
Serial.println("\"");
}
}
void loop() {
}
bool getTime(const char *str)
{
int Hour, Min, Sec;
if (sscanf(str, "%d:%d:%d", &Hour, &Min, &Sec) != 3) return false;
tm.Hour = Hour;
tm.Minute = Min;
tm.Second = Sec;
return true;
}
bool getDate(const char *str)
{
char Month[12];
int Day, Year;
uint8_t monthIndex;
if (sscanf(str, "%s %d %d", Month, &Day, &Year) != 3) return false;
for (monthIndex = 0; monthIndex < 12; monthIndex++) {
if (strcmp(Month, monthName[monthIndex]) == 0) break;
}
if (monthIndex >= 12) return false;
tm.Day = Day;
tm.Month = monthIndex + 1;
tm.Year = CalendarYrToTm(Year);
return true;
}
| [
"[email protected]"
] | |
c39ccf7ed12348ce0c04000327bfb3dee80a10bb | 179ffb8f2137307583a23cb6826d720974fc9784 | /Unit04/DefaultConstructor/DefaultConstructor.cpp | 7651fb23a93b0c91ca1410b1a763c781907192ca | [] | no_license | Sheepypy/MOOC | e59f85732e225cc0f6059e46b0620dd34869faa8 | 258b178481419dcea1dc32f07aab4536f606205c | refs/heads/master | 2023-08-13T23:14:52.245101 | 2021-09-14T09:57:46 | 2021-09-14T09:57:46 | 392,976,556 | 2 | 0 | null | null | null | null | GB18030 | C++ | false | false | 837 | cpp | #include <iostream>
using std::cout;
using std::cin;
using std::endl;
class Circle
{
public:
Circle();
~Circle();
Circle(double r) {
radius = r;
}
double getArea() {
return 3.14 * radius * radius;
}
private:
double radius;
};
Circle::Circle()
{
radius = 1;
}
Circle::~Circle()
{
}
class Square
{
public:
Square();
~Square();
Square(double side_) : side{ side_ } { }
double getArea() {
return side * side;
}
private:
double side;
};
Square::Square()
{
side = 1;
}
Square::~Square()
{
}
class Combo
{
public:
Combo();
~Combo();
Circle c;
Square s;
private:
};
Combo::Combo() :c{ 2 }, s{ 2 }//初始化列表
{
c = { 4 };//此处不能列表初始化,只能赋值
s = { 4 };
}
Combo::~Combo()
{
}
int main() {
Combo o{};
cout << o.c.getArea() << endl;
cout << o.s.getArea() << endl;
return 0;
}
| [
"[email protected]"
] | |
2e172b04074b30a8c9c5591123a8efeebf641132 | 80e348416fbd1b0d788fc6ce8e7386c854ec35bb | /Source.cpp | 23a491dc12ab7931b797abc6e07955caae863712 | [] | no_license | sujhan/RearLightsDetection | e9f84253596dccb82ae490780049e795add0edc5 | 86d885fbb9545981bc78e2a974691f0ed81f74de | refs/heads/master | 2020-04-23T22:15:16.341645 | 2018-04-29T12:35:26 | 2018-04-29T12:35:26 | 171,495,710 | 1 | 0 | null | 2019-02-19T15:12:18 | 2019-02-19T15:12:14 | null | UTF-8 | C++ | false | false | 2,983 | cpp | #include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <sstream> // ostringstream
#include <iomanip> // std::setprecision()
#include "RedColorSegmentation.h"
#include "OtsusThreshold.h"
#include "HorizontalEdgeBoundaries.h"
#include "FastRadialSymmetryTransform.h"
#include "MorphologicalLightsPairing.h"
#include "HypothesisVerification.h"
int main() {
// Open test video
const std::string folder_pos = "cars_markus/";
int samples_num;
// vectors to store all filenames of images
std::vector<std::string> test_samples;
// Get all filenames for testing images from folder
cv::glob(folder_pos, test_samples, true);
// Get number of images
samples_num = static_cast<int>(test_samples.size());
// Create a window for display.
cv::namedWindow("Display window", cv::WINDOW_AUTOSIZE);
for (int loop = 0; loop < samples_num; ++loop) {
// Read image
cv::Mat image = cv::imread(test_samples[loop]);
// -----------------------------------------
// Resize but keep ratio
double ratio = static_cast<double>(image.rows) / image.cols;
if (ratio < 1) {
int x = static_cast<int>(360 * ratio);
cv::resize(image, image, cv::Size(360, x));
}
else {
int x = static_cast<int>(360 * (1.0 / ratio));
cv::resize(image, image, cv::Size(x, 360));
}
// -----------------------------------------
// Keep only red subspace of image
cv::Mat redI = RedColorSegmentation(image);
// -----------------------------------------
// Apply Fast Radial Symmetry Transform
int mode = 2;
int alpha = 1;
int radiusMin = 5, radiusMax = 21;
double gradientThreshold = 0.2;
cv::Mat myR = FastRadialSymmetryTransform(redI, mode, alpha, gradientThreshold, radiusMin, radiusMax);
// -----------------------------------------
// Change range to 0-255 and apply Otsu's threshold
double min, max;
cv::minMaxIdx(myR, &min, &max);
cv::Mat adjMap;
myR.convertTo(adjMap, CV_8UC1, 255 / (max - min), -min);
OtsusThreshold(adjMap);
// -----------------------------------------
// Morphological Lights Pairing
std::vector<cv::Rect> ROI = MorphologicalLightsPairing(adjMap, image);
// -----------------------------------------
// Find top and bottom boundaries of candidate vehicle
//for (size_t i = 0; i < ROI.size(); ++i)
//HorizontalEdgeBoundaries(image, ROI[i]);
// -----------------------------------------
// Apply SymmetryCheck on candidate areas
std::vector<std::pair<int, int>> maxROIs = HypothesisVerification(image, ROI);
// -----------------------------------------
// Draw rectangles of found vehicles
std::vector<std::pair<int, int>>::iterator it;
for (it = maxROIs.begin(); it != maxROIs.end(); ++it)
cv::rectangle(image, ROI[it->second], cv::Scalar(0, 255, 255), 4);
// -------------------------------------------------------------------------
std::cout << "\rCompleted " << loop+1 << "/" << samples_num;
cv::imshow("Display window", image);
cv::waitKey(1);
}
return 0;
} | [
"[email protected]"
] | |
04cb769c780167c6f420b7e7ece7e54f6ceb5e81 | c9aa8a27fbebc03abd937b630030fc17e64112a4 | /reaper.h | 20af11132a0ba8bbd23ba44373e1535adeecd627 | [] | no_license | 223323/ns3-nodes | 0908756ff5d4397471bc0b39d6ee22e56873b45f | 4dddfa83e3e8e40008e389cbe438afe881453f00 | refs/heads/master | 2020-05-22T16:12:44.207502 | 2019-07-05T13:28:51 | 2019-07-05T13:28:51 | 186,425,299 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,406 | h | #ifndef REAPER_H
#define REAPER_H
#include <iostream>
#include <sstream>
#include "ns3/core-module.h"
//#include "ns3/simulator-module.h"
//#include "ns3/node-module.h"
#include "ns3/network-module.h"
//#include "ns3/helper-module.h"
#include "ns3/point-to-point-dumbbell.h"
#include "ns3/on-off-helper.h"
//#include "ns3/random-variable.h"
#include "ns3/animation-interface.h"
#include "ns3/ipv4-global-routing-helper.h"
#include "ns3/packet-sink-helper.h"
using namespace ns3;
namespace Sim {
class Api;
class MyApp;
class Reaper {
friend class Node;
public:
Reaper(Ptr<ns3::Node> node) : m_node(node) { }
void AssignIpv4Addresses(ns3::Ipv4AddressHelper& Ips);
void AssignIpv6Addresses(ns3::Ipv6AddressHelper& Ips);
Ptr<ns3::Node> GetNode() { return m_node; }
void PrintIps(std::ostream& o=std::cout, int indent=0);
ns3::Ipv4Address GetAddress(int i);
ns3::Ipv6Address GetAddressV6(int i);
ns3::Ipv4Address GetWNAddress(int i);
ns3::Ipv6Address GetWNAddressV6(int i);
uint32_t GetChannelId(int i);
uint32_t GetWNChannelId(int i);
int GetAddressNum();
int GetWNAddressNum();
int GetWNAddressNumV6();
ns3::Ipv4InterfaceContainer GetInterfaces();
ns3::Ipv4InterfaceContainer GetWNInterfaces();
ns3::Ipv6InterfaceContainer GetInterfacesV6();
ns3::Ipv6InterfaceContainer GetWNInterfacesV6();
void AddInterface(ns3::Ipv4InterfaceContainer::Iterator it);
void AddInterfaceV6(ns3::Ipv6InterfaceContainer::Iterator it);
void AddWNInterface(ns3::Ipv4InterfaceContainer::Iterator it);
void AddWNInterfaceV6(ns3::Ipv6InterfaceContainer::Iterator it);
void AddDevice(Ptr<ns3::NetDevice> dev, bool isLeft);
void AddSwitchDevice(Ptr<ns3::NetDevice> dev);
void AddWNDevice(Ptr<ns3::NetDevice> dev);
void MapChirplets();
int GetChirplet(uint32_t ip);
private:
Ptr<ns3::Node> m_node;
ns3::NetDeviceContainer m_devices;
ns3::NetDeviceContainer m_left_devices;
ns3::NetDeviceContainer m_right_devices;
ns3::NetDeviceContainer m_switch_devices;
ns3::NetDeviceContainer m_wn_devices;
ns3::Ipv4InterfaceContainer m_interfaces;
ns3::Ipv6InterfaceContainer m_interfaces_v6;
ns3::Ipv4InterfaceContainer m_wn_interfaces;
ns3::Ipv6InterfaceContainer m_wn_interfaces_v6;
std::map<uint32_t,int> m_map_ipv4_to_chirplet;
};
}
#endif
| [
"[email protected]"
] | |
2cacb2e2ad9a1547408e7aafdff3b9b95f823148 | 0dca3325c194509a48d0c4056909175d6c29f7bc | /nlp-automl/include/alibabacloud/nlp-automl/model/CreateDatasetRecordRequest.h | 169554baf6e3fe09c157982a3ce1be5b5549dcdd | [
"Apache-2.0"
] | permissive | dingshiyu/aliyun-openapi-cpp-sdk | 3eebd9149c2e6a2b835aba9d746ef9e6bef9ad62 | 4edd799a79f9b94330d5705bb0789105b6d0bb44 | refs/heads/master | 2023-07-31T10:11:20.446221 | 2021-09-26T10:08:42 | 2021-09-26T10:08:42 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,589 | h | /*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ALIBABACLOUD_NLP_AUTOML_MODEL_CREATEDATASETRECORDREQUEST_H_
#define ALIBABACLOUD_NLP_AUTOML_MODEL_CREATEDATASETRECORDREQUEST_H_
#include <string>
#include <vector>
#include <alibabacloud/core/RpcServiceRequest.h>
#include <alibabacloud/nlp-automl/Nlp_automlExport.h>
namespace AlibabaCloud
{
namespace Nlp_automl
{
namespace Model
{
class ALIBABACLOUD_NLP_AUTOML_EXPORT CreateDatasetRecordRequest : public RpcServiceRequest
{
public:
CreateDatasetRecordRequest();
~CreateDatasetRecordRequest();
std::string getDatasetRecord()const;
void setDatasetRecord(const std::string& datasetRecord);
long getDatasetId()const;
void setDatasetId(long datasetId);
long getProjectId()const;
void setProjectId(long projectId);
private:
std::string datasetRecord_;
long datasetId_;
long projectId_;
};
}
}
}
#endif // !ALIBABACLOUD_NLP_AUTOML_MODEL_CREATEDATASETRECORDREQUEST_H_ | [
"[email protected]"
] | |
51262286f71c385e65b1c4a9acfd4be1e1b34248 | 9ffa9051ff99e534f09950d34ac3b69c17690ae2 | /libraries/Adafruit_Arcada_GifDecoder/src/GifDecoder_Impl.h | b57ced5b6f68f20c720649ee75a9591197c1a097 | [] | no_license | mathu-makes/GifPlayerMCU | a23102e4139b312258951b2abc56963ac0e2f68e | bfb7943a51792b2361627c6b7b7e3dbdcb1580ef | refs/heads/master | 2022-11-08T10:36:08.533363 | 2020-06-29T04:35:06 | 2020-06-29T04:35:06 | 275,421,123 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 31,142 | h | /*
Animated GIFs Display Code for SmartMatrix and 32x32 RGB LED Panels
This file contains code to parse animated GIF files
Written by: Craig A. Lindley
Copyright (c) 2014 Craig A. Lindley
Minor modifications by Louis Beaudoin (pixelmatix)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define GIFDEBUG 2
#if defined (ARDUINO)
#include <Arduino.h>
#elif defined (SPARK)
#include "application.h"
#endif
#include "GifDecoder.h"
#if GIFDEBUG == 1
#define DEBUG_SCREEN_DESCRIPTOR 1
#define DEBUG_GLOBAL_COLOR_TABLE 1
#define DEBUG_PROCESSING_PLAIN_TEXT_EXT 1
#define DEBUG_PROCESSING_GRAPHIC_CONTROL_EXT 1
#define DEBUG_PROCESSING_APP_EXT 1
#define DEBUG_PROCESSING_COMMENT_EXT 0
#define DEBUG_PROCESSING_FILE_TERM 1
#define DEBUG_PROCESSING_TABLE_IMAGE_DESC 1
#define DEBUG_PROCESSING_TBI_DESC_START 1
#define DEBUG_PROCESSING_TBI_DESC_INTERLACED 0
#define DEBUG_PROCESSING_TBI_DESC_LOCAL_COLOR_TABLE 1
#define DEBUG_PROCESSING_TBI_DESC_LZWCODESIZE 1
#define DEBUG_PROCESSING_TBI_DESC_DATABLOCKSIZE 0
#define DEBUG_PROCESSING_TBI_DESC_LZWIMAGEDATA_OVERFLOW 1
#define DEBUG_PROCESSING_TBI_DESC_LZWIMAGEDATA_SIZE 1
#define DEBUG_PARSING_DATA 1
#define DEBUG_DECOMPRESS_AND_DISPLAY 1
#define DEBUG_WAIT_FOR_KEY_PRESS 0
#endif
#include "GifDecoder.h"
// Error codes
#define ERROR_NONE 0
#define ERROR_DONE_PARSING 1
#define ERROR_WAITING 2
#define ERROR_FILEOPEN -1
#define ERROR_FILENOTGIF -2
#define ERROR_BADGIFFORMAT -3
#define ERROR_UNKNOWNCONTROLEXT -4
#define GIFHDRTAGNORM "GIF87a" // tag in valid GIF file
#define GIFHDRTAGNORM1 "GIF89a" // tag in valid GIF file
#define GIFHDRSIZE 6
// Global GIF specific definitions
#define COLORTBLFLAG 0x80
#define INTERLACEFLAG 0x40
#define TRANSPARENTFLAG 0x01
#define NO_TRANSPARENT_INDEX -1
// Disposal methods
#define DISPOSAL_NONE 0
#define DISPOSAL_LEAVE 1
#define DISPOSAL_BACKGROUND 2
#define DISPOSAL_RESTORE 3
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
void GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::setStartDrawingCallback(callback f) {
startDrawingCallback = f;
}
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
void GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::setUpdateScreenCallback(callback f) {
updateScreenCallback = f;
}
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
void GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::setDrawPixelCallback(pixel_callback f) {
drawPixelCallback = f;
}
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
void GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::setDrawLineCallback(line_callback f) {
drawLineCallback = f;
}
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
void GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::setScreenClearCallback(callback f) {
screenClearCallback = f;
}
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
void GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::setFileSeekCallback(file_seek_callback f) {
fileSeekCallback = f;
}
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
void GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::setFilePositionCallback(file_position_callback f) {
filePositionCallback = f;
}
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
void GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::setFileReadCallback(file_read_callback f) {
fileReadCallback = f;
}
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
void GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::setFileReadBlockCallback(file_read_block_callback f) {
fileReadBlockCallback = f;
}
// Backup the read stream by n bytes
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
void GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::backUpStream(int n) {
fileSeekCallback(filePositionCallback() - n);
}
// Read a file byte
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
int GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::readByte() {
int b = fileReadCallback();
if (b == -1) {
#if GIFDEBUG == 1
Serial.println("Read error or EOF occurred");
#endif
}
return b;
}
// Read a file word
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
int GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::readWord() {
int b0 = readByte();
int b1 = readByte();
return (b1 << 8) | b0;
}
// Read the specified number of bytes into the specified buffer
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
int GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::readIntoBuffer(void *buffer, int numberOfBytes) {
int result = fileReadBlockCallback(buffer, numberOfBytes);
if (result == -1) {
Serial.println("Read error or EOF occurred");
}
#if defined(USE_PALETTE565)
if (buffer == palette) {
for (int i = 0; i < 256; i++) {
#if !defined(ARCADA_TFT_D0) && !defined(USE_SPI_DMA)
uint8_t r = palette[i].red;
uint8_t g = palette[i].green;
uint8_t b = palette[i].blue;
palette565[i] = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3);
#else
// Pre-endian-swap in the palette
palette565[i] = __builtin_bswap16(
((palette[i].red & 0xF8) << 8) |
((palette[i].green & 0xFC) << 3) |
((palette[i].blue ) >> 3));
#endif
}
}
#endif
return result;
}
// Fill a portion of imageData buffer with a color index
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
void GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::fillImageDataRect(uint8_t colorIndex, int x, int y, int width, int height) {
#if NO_IMAGEDATA < 2
int yOffset = 0;
for (int yy = y; yy < height + y; yy++) {
yOffset = yy * maxGifWidth;
for (int xx = x; xx < width + x; xx++) {
imageData[yOffset + xx] = colorIndex;
}
}
#endif
}
// Fill entire imageData buffer with a color index
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
void GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::fillImageData(uint8_t colorIndex) {
#if NO_IMAGEDATA < 2
memset(imageData, colorIndex, sizeof(imageData));
#endif
}
// Copy image data in rect from a src to a dst
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
void GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::copyImageDataRect(uint8_t *dst, uint8_t *src, int x, int y, int width, int height) {
int yOffset, offset;
for (int yy = y; yy < height + y; yy++) {
yOffset = yy * maxGifWidth;
for (int xx = x; xx < width + x; xx++) {
offset = yOffset + xx;
dst[offset] = src[offset];
}
}
}
// Make sure the file is a Gif file
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
bool GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::parseGifHeader() {
char buffer[10];
readIntoBuffer(buffer, GIFHDRSIZE);
if ((strncmp(buffer, GIFHDRTAGNORM, GIFHDRSIZE) != 0) &&
(strncmp(buffer, GIFHDRTAGNORM1, GIFHDRSIZE) != 0)) {
return false;
}
else {
return true;
}
}
// Parse the logical screen descriptor
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
void GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::parseLogicalScreenDescriptor() {
lsdWidth = readWord();
lsdHeight = readWord();
lsdPackedField = readByte();
lsdBackgroundIndex = readByte();
lsdAspectRatio = readByte();
frameCount = (cycleNo) ? frameNo : 0; //.kbv
cycleNo++; //.kbv
#if GIFDEBUG == 1 && DEBUG_SCREEN_DESCRIPTOR == 1
Serial.print("lsdWidth: ");
Serial.println(lsdWidth);
Serial.print("lsdHeight: ");
Serial.println(lsdHeight);
Serial.print("lsdPackedField: ");
Serial.println(lsdPackedField, HEX);
Serial.print("lsdBackgroundIndex: ");
Serial.println(lsdBackgroundIndex);
Serial.print("lsdAspectRatio: ");
Serial.println(lsdAspectRatio);
#endif
}
// Parse the global color table
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
void GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::parseGlobalColorTable() {
// Does a global color table exist?
if (lsdPackedField & COLORTBLFLAG) {
// A GCT was present determine how many colors it contains
colorCount = 1 << ((lsdPackedField & 7) + 1);
#if GIFDEBUG == 1 && DEBUG_GLOBAL_COLOR_TABLE == 1
Serial.print("Global color table with ");
Serial.print(colorCount);
Serial.println(" colors present");
#endif
// Read color values into the palette array
int colorTableBytes = sizeof(rgb_24) * colorCount;
readIntoBuffer(palette, colorTableBytes);
}
}
// Parse plain text extension and dispose of it
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
void GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::parsePlainTextExtension() {
#if GIFDEBUG == 1 && DEBUG_PROCESSING_PLAIN_TEXT_EXT == 1
Serial.println("\nProcessing Plain Text Extension");
#endif
// Read plain text header length
uint8_t len = readByte();
// Consume plain text header data
readIntoBuffer(tempBuffer, len);
// Consume the plain text data in blocks
len = readByte();
while (len != 0) {
readIntoBuffer(tempBuffer, len);
len = readByte();
}
}
// Parse a graphic control extension
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
void GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::parseGraphicControlExtension() {
#if GIFDEBUG == 1 && DEBUG_PROCESSING_GRAPHIC_CONTROL_EXT == 1
Serial.println("\nProcessing Graphic Control Extension");
#endif
int len = readByte(); // Check length
if (len != 4) {
Serial.println("Bad graphic control extension");
}
int packedBits = readByte();
frameDelay = readWord(); // hundredths of a second
transparentColorIndex = readByte();
if ((packedBits & TRANSPARENTFLAG) == 0) {
// Indicate no transparent index
transparentColorIndex = NO_TRANSPARENT_INDEX;
}
disposalMethod = (packedBits >> 2) & 7;
if (disposalMethod > 3) {
disposalMethod = 0;
Serial.println("Invalid disposal value");
}
readByte(); // Toss block end
#if GIFDEBUG == 1 && DEBUG_PROCESSING_GRAPHIC_CONTROL_EXT == 1
Serial.print("PacketBits: ");
Serial.println(packedBits, HEX);
Serial.print("Frame delay: ");
Serial.println(frameDelay);
Serial.print("transparentColorIndex: ");
Serial.println(transparentColorIndex);
Serial.print("disposalMethod: ");
Serial.println(disposalMethod);
#endif
}
// Parse application extension
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
void GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::parseApplicationExtension() {
memset(tempBuffer, 0, sizeof(tempBuffer));
#if GIFDEBUG == 1 && DEBUG_PROCESSING_APP_EXT == 1
Serial.println("\nProcessing Application Extension");
#endif
// Read block length
uint8_t len = readByte();
// Read app data
readIntoBuffer(tempBuffer, len);
#if GIFDEBUG == 1 && DEBUG_PROCESSING_APP_EXT == 1
// Conditionally display the application extension string
if (strlen(tempBuffer) != 0) {
Serial.print("Application Extension: ");
Serial.println(tempBuffer);
}
#endif
// Consume any additional app data
len = readByte();
while (len != 0) {
readIntoBuffer(tempBuffer, len);
len = readByte();
}
}
// Parse comment extension
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
void GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::parseCommentExtension() {
#if GIFDEBUG == 1 && DEBUG_PROCESSING_COMMENT_EXT == 1
Serial.println("\nProcessing Comment Extension");
#endif
// Read block length
uint8_t len = readByte();
while (len != 0) {
// Clear buffer
memset(tempBuffer, 0, sizeof(tempBuffer));
// Read len bytes into buffer
readIntoBuffer(tempBuffer, len);
#if GIFDEBUG == 1 && DEBUG_PROCESSING_COMMENT_EXT == 1
// Display the comment extension string
if (strlen(tempBuffer) != 0) {
Serial.print("Comment Extension: ");
Serial.println(tempBuffer);
}
#endif
// Read the new block length
len = readByte();
}
}
// Parse file terminator
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
int GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::parseGIFFileTerminator() {
#if GIFDEBUG == 1 && DEBUG_PROCESSING_FILE_TERM == 1
Serial.println("\nProcessing file terminator");
#endif
uint8_t b = readByte();
if (b != 0x3B) {
#if GIFDEBUG == 1 && DEBUG_PROCESSING_FILE_TERM == 1
Serial.print("Terminator byte: ");
Serial.println(b, HEX);
#endif
Serial.println("Bad GIF file format - Bad terminator");
return ERROR_BADGIFFORMAT;
}
else {
return ERROR_NONE;
}
}
// Parse table based image data
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
void GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::parseTableBasedImage() {
#if GIFDEBUG == 1 && DEBUG_PROCESSING_TBI_DESC_START == 1
Serial.println("\nProcessing Table Based Image Descriptor");
#endif
#if GIFDEBUG == 1 && DEBUG_PARSING_DATA == 1
Serial.println("File Position: ");
Serial.println(filePositionCallback());
Serial.println("File Size: ");
//Serial.println(file.size());
#endif
// Parse image descriptor
tbiImageX = readWord();
tbiImageY = readWord();
tbiWidth = readWord();
tbiHeight = readWord();
tbiPackedBits = readByte();
#if GIFDEBUG == 1
Serial.print("tbiImageX: ");
Serial.println(tbiImageX);
Serial.print("tbiImageY: ");
Serial.println(tbiImageY);
Serial.print("tbiWidth: ");
Serial.println(tbiWidth);
Serial.print("tbiHeight: ");
Serial.println(tbiHeight);
Serial.print("PackedBits: ");
Serial.println(tbiPackedBits, HEX);
#endif
// Is this image interlaced ?
tbiInterlaced = ((tbiPackedBits & INTERLACEFLAG) != 0);
#if GIFDEBUG == 1 && DEBUG_PROCESSING_TBI_DESC_INTERLACED == 1
Serial.print("Image interlaced: ");
Serial.println((tbiInterlaced != 0) ? "Yes" : "No");
#endif
// Does this image have a local color table ?
bool localColorTable = ((tbiPackedBits & COLORTBLFLAG) != 0);
if (localColorTable) {
int colorBits = ((tbiPackedBits & 7) + 1);
colorCount = 1 << colorBits;
#if GIFDEBUG == 1 && DEBUG_PROCESSING_TBI_DESC_LOCAL_COLOR_TABLE == 1
Serial.print("Local color table with ");
Serial.print(colorCount);
Serial.println(" colors present");
#endif
// Read colors into palette
int colorTableBytes = sizeof(rgb_24) * colorCount;
readIntoBuffer(palette, colorTableBytes);
}
// One time initialization of imageData before first frame
if (keyFrame) {
frameNo = 0; //.kbv
if (transparentColorIndex == NO_TRANSPARENT_INDEX) {
fillImageData(lsdBackgroundIndex);
}
else {
fillImageData(transparentColorIndex);
}
keyFrame = false;
rectX = 0;
rectY = 0;
rectWidth = maxGifWidth;
rectHeight = maxGifHeight;
}
// Don't clear matrix screen for these disposal methods
if ((prevDisposalMethod != DISPOSAL_NONE) && (prevDisposalMethod != DISPOSAL_LEAVE)) {
if (screenClearCallback)
(*screenClearCallback)();
}
// Process previous disposal method
if (prevDisposalMethod == DISPOSAL_BACKGROUND) {
// Fill portion of imageData with previous background color
fillImageDataRect(prevBackgroundIndex, rectX, rectY, rectWidth, rectHeight);
}
else if (prevDisposalMethod == DISPOSAL_RESTORE) {
#if NO_IMAGEDATA < 1
copyImageDataRect(imageData, imageDataBU, rectX, rectY, rectWidth, rectHeight);
#endif
}
// Save disposal method for this frame for next time
prevDisposalMethod = disposalMethod;
if (disposalMethod != DISPOSAL_NONE) {
// Save dimensions of this frame
rectX = tbiImageX;
rectY = tbiImageY;
rectWidth = tbiWidth;
rectHeight = tbiHeight;
// limit rectangle to the bounds of maxGifWidth*maxGifHeight
if (rectX + rectWidth > maxGifWidth)
rectWidth = maxGifWidth - rectX;
if (rectY + rectHeight > maxGifHeight)
rectHeight = maxGifHeight - rectY;
if (rectX >= maxGifWidth || rectY >= maxGifHeight) {
rectX = rectY = rectWidth = rectHeight = 0;
}
if (disposalMethod == DISPOSAL_BACKGROUND) {
if (transparentColorIndex != NO_TRANSPARENT_INDEX) {
prevBackgroundIndex = transparentColorIndex;
}
else {
prevBackgroundIndex = lsdBackgroundIndex;
}
}
else if (disposalMethod == DISPOSAL_RESTORE) {
#if NO_IMAGEDATA < 1
copyImageDataRect(imageDataBU, imageData, rectX, rectY, rectWidth, rectHeight);
#endif
}
}
// Read the min LZW code size
lzwCodeSize = readByte();
#if GIFDEBUG == 1 && DEBUG_PROCESSING_TBI_DESC_LZWCODESIZE == 1
Serial.print("LzwCodeSize: ");
Serial.println(lzwCodeSize);
Serial.println("File Position Before: ");
Serial.println(filePositionCallback());
#endif
unsigned long filePositionBefore = filePositionCallback();
// Gather the lzw image data
// NOTE: the dataBlockSize byte is left in the data as the lzw decoder needs it
int offset = 0;
int dataBlockSize = readByte();
while (dataBlockSize != 0) {
#if GIFDEBUG == 1 && DEBUG_PROCESSING_TBI_DESC_DATABLOCKSIZE == 1
Serial.print("dataBlockSize: ");
Serial.println(dataBlockSize);
#endif
backUpStream(1);
dataBlockSize++;
fileSeekCallback(filePositionCallback() + dataBlockSize);
offset += dataBlockSize;
dataBlockSize = readByte();
}
#if GIFDEBUG == 1 && DEBUG_PROCESSING_TBI_DESC_LZWIMAGEDATA_SIZE == 1
Serial.print("total lzwImageData Size: ");
Serial.println(offset);
Serial.println("File Position Test: ");
Serial.println(filePositionCallback());
#endif
// this is the position where GIF decoding needs to pick up after decompressing frame
unsigned long filePositionAfter = filePositionCallback();
fileSeekCallback(filePositionBefore);
// Process the animation frame for display
// Initialize the LZW decoder for this frame
lzw_decode_init(lzwCodeSize);
lzw_setTempBuffer((uint8_t*)tempBuffer);
// Make sure there is at least some delay between frames
// if (frameDelay < 1) {
// frameDelay = 1;
// }
// Decompress LZW data and display the frame
decompressAndDisplayFrame(filePositionAfter);
// Graphic control extension is for a single frame
transparentColorIndex = NO_TRANSPARENT_INDEX;
disposalMethod = DISPOSAL_NONE;
}
// Parse gif data
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
int GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::parseData() {
// if (nextFrameTime_ms > millis())
// return ERROR_WAITING;
#if GIFDEBUG == 1 && DEBUG_PARSING_DATA == 1
Serial.println("\nParsing Data Block");
#endif
bool parsedFrame = false;
while (!parsedFrame) {
#if GIFDEBUG == 1 && DEBUG_WAIT_FOR_KEY_PRESS == 1
Serial.println("\nPress Key For Next");
while (Serial.read() <= 0);
#endif
// Determine what kind of data to process
uint8_t b = readByte();
if (b == 0x2c) {
// Parse table based image
#if GIFDEBUG == 1 && DEBUG_PARSING_DATA == 1
Serial.println("\nParsing Table Based");
#endif
parseTableBasedImage();
parsedFrame = true;
}
else if (b == 0x21) {
// Parse extension
b = readByte();
#if GIFDEBUG == 1 && DEBUG_PARSING_DATA == 1
Serial.println("\nParsing Extension");
#endif
// Determine which kind of extension to parse
switch (b) {
case 0x01:
// Plain test extension
parsePlainTextExtension();
break;
case 0xf9:
// Graphic control extension
parseGraphicControlExtension();
break;
case 0xfe:
// Comment extension
parseCommentExtension();
break;
case 0xff:
// Application extension
parseApplicationExtension();
break;
default:
Serial.print("Unknown control extension: ");
Serial.println(b, HEX);
return ERROR_UNKNOWNCONTROLEXT;
}
}
else {
#if GIFDEBUG == 1 && DEBUG_PARSING_DATA == 1
Serial.println("\nParsing Done");
#endif
// Push unprocessed byte back into the stream for later processing
backUpStream(1);
return ERROR_DONE_PARSING;
}
}
return ERROR_NONE;
}
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
int GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::startDecoding(void) {
// Initialize variables
keyFrame = true;
cycleNo = 0;
prevDisposalMethod = DISPOSAL_NONE;
transparentColorIndex = NO_TRANSPARENT_INDEX;
frameStartTime = micros();
fileSeekCallback(0);
// Validate the header
if (! parseGifHeader()) {
Serial.println("Not a GIF file");
return ERROR_FILENOTGIF;
}
// If we get here we have a gif file to process
// Parse the logical screen descriptor
parseLogicalScreenDescriptor();
// Parse the global color table
parseGlobalColorTable();
return ERROR_NONE;
}
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
int GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::decodeFrame(bool delayAfterDecode) {
// Parse gif data
_delayAfterDecode = delayAfterDecode;
int result = parseData();
if (result < ERROR_NONE) {
Serial.println("Error: ");
Serial.println(result);
Serial.println(" occurred during parsing of data");
return result;
}
if (result == ERROR_DONE_PARSING) {
//startDecoding();
// Initialize variables like with a new file
keyFrame = true;
prevDisposalMethod = DISPOSAL_NONE;
transparentColorIndex = NO_TRANSPARENT_INDEX;
frameStartTime = micros();
fileSeekCallback(0);
// parse Gif Header like with a new file
parseGifHeader();
// Parse the logical screen descriptor
parseLogicalScreenDescriptor();
// Parse the global color table
parseGlobalColorTable();
}
return result;
}
// Decompress LZW data and display animation frame
template <int maxGifWidth, int maxGifHeight, int lzwMaxBits>
void GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits>::decompressAndDisplayFrame(unsigned long filePositionAfter) {
// frameDelay is time to wait AFTER the frame is drawn...so, use value
// from prior pass. It's converted to microseconds here for better timing.
uint32_t priorFrameDelay = frameDelay * 10000;
// Each pixel of image is 8 bits and is an index into the palette
// How the image is decoded depends upon whether it is interlaced or not
// Decode the interlaced LZW data into the image buffer
#if NO_IMAGEDATA < 2
uint8_t *p = imageData + tbiImageX;
if (tbiInterlaced) {
// Decode every 8th line starting at line 0
for (int line = tbiImageY + 0; line < tbiHeight + tbiImageY; line += 8) {
lzw_decode(p + (line * maxGifWidth), tbiWidth, min(imageData + (line * maxGifWidth) + maxGifWidth, imageData + sizeof(imageData)));
}
// Decode every 8th line starting at line 4
for (int line = tbiImageY + 4; line < tbiHeight + tbiImageY; line += 8) {
lzw_decode(p + (line * maxGifWidth), tbiWidth, min(imageData + (line * maxGifWidth) + maxGifWidth, imageData + sizeof(imageData)));
}
// Decode every 4th line starting at line 2
for (int line = tbiImageY + 2; line < tbiHeight + tbiImageY; line += 4) {
lzw_decode(p + (line * maxGifWidth), tbiWidth, min(imageData + (line * maxGifWidth) + maxGifWidth, imageData + sizeof(imageData)));
}
// Decode every 2nd line starting at line 1
for (int line = tbiImageY + 1; line < tbiHeight + tbiImageY; line += 2) {
lzw_decode(p + (line * maxGifWidth), tbiWidth, min(imageData + (line * maxGifWidth) + maxGifWidth, imageData + sizeof(imageData)));
}
}
else {
// Decode the non interlaced LZW data into the image data buffer
for (int line = tbiImageY; line < tbiHeight + tbiImageY; line++) {
lzw_decode(p + (line * maxGifWidth), tbiWidth, imageData + sizeof(imageData));
}
}
#if GIFDEBUG == 1 && DEBUG_DECOMPRESS_AND_DISPLAY == 1
Serial.println("File Position After: ");
Serial.println(filePositionCallback());
#endif
#if GIFDEBUG == 1 && DEBUG_WAIT_FOR_KEY_PRESS == 1
Serial.println("\nPress Key For Next");
while (Serial.read() <= 0);
#endif
// LZW doesn't parse through all the data, manually set position
fileSeekCallback(filePositionAfter);
// Optional callback can be used to get drawing routines ready
if (startDrawingCallback)
(*startDrawingCallback)();
// Image data is decompressed, now display portion of image affected by frame
int yOffset, pixel;
for (int y = tbiImageY; y < tbiHeight + tbiImageY; y++) {
yOffset = y * maxGifWidth;
for (int x = tbiImageX; x < tbiWidth + tbiImageX; x++) {
// Get the next pixel
pixel = imageData[yOffset + x];
// Check pixel transparency
if (pixel == transparentColorIndex) {
continue;
}
// Pixel not transparent so get color from palette and draw the pixel
if (drawPixelCallback)
(*drawPixelCallback)(x, y, palette[pixel].red, palette[pixel].green, palette[pixel].blue);
}
}
#else
#define GSZ maxGifWidth
//#define GSZ 221 //llama fails on 220
uint8_t imageBuf[GSZ];
// memset(imageBuf, 0, GSZ);
int starts[] = {0, 4, 2, 1, 0};
int incs[] = {8, 8, 4, 2, 1};
frameNo++;
#if GIFDEBUG > 1
char buf[80];
if (frameNo == 1) {
sprintf(buf, "Logical Screen [LZW=%d %dx%d P:0x%02X B:%d A:%d F:%dms] frames:%d pass=%d",
lzwCodeSize, lsdWidth, lsdHeight, lsdPackedField, lsdBackgroundIndex, lsdAspectRatio,
frameDelay * 10, frameCount, cycleNo);
Serial.println(buf);
}
#if GIFDEBUG > 2
unsigned long filePositionBefore = filePositionCallback();
sprintf(buf, "Frame %2d: [=%6ld P:0x%02X B:%d F:%dms] @ %d,%d %dx%d ms:",
frameNo, filePositionBefore, tbiPackedBits, transparentColorIndex, frameDelay * 10,
tbiImageX, tbiImageY, tbiWidth, tbiHeight);
Serial.print(buf);
delay(10); //allow Serial to complete @ 115200 baud
int32_t t = millis();
#endif
#endif
for (int state = 0; state < 4; state++) {
if (tbiInterlaced == 0) state = 4; //regular does one pass
for (int line = starts[state]; line < tbiHeight; line += incs[state]) {
if (disposalMethod == DISPOSAL_BACKGROUND) memset(imageBuf, prevBackgroundIndex, maxGifWidth);
// int align = (lsdWidth > maxGifWidth) ? lsdWidth - maxGifWidth : 0;
// int ofs = tbiImageX - align;
// uint8_t *dst = (ofs < 0) ? imageBuf : imageBuf + ofs;
// align = (ofs < 0) ? -ofs : 0;
int align = 0;
int len = lzw_decode(imageBuf + tbiImageX, tbiWidth, imageBuf + maxGifWidth - 1, align);
if (len != tbiWidth) Serial.println(len);
int xofs = (disposalMethod == DISPOSAL_BACKGROUND) ? 0 : tbiImageX;
int wid = (disposalMethod == DISPOSAL_BACKGROUND) ? lsdWidth : tbiWidth;
int skip = (disposalMethod == DISPOSAL_BACKGROUND) ? -1 : transparentColorIndex;;
if (drawLineCallback) {
(*drawLineCallback)(xofs, line + tbiImageY, imageBuf + xofs, wid, palette565, skip);
} else if (drawPixelCallback) {
for (int x = 0; x < wid; x++) {
uint8_t pixel = imageBuf[x + xofs];
if ((pixel != skip))
(*drawPixelCallback)(x + xofs, line + tbiImageY,
palette[pixel].red, palette[pixel].green, palette[pixel].blue);
}
}
}
}
// LZW doesn't parse through all the data, manually set position
fileSeekCallback(filePositionAfter);
#if GIFDEBUG > 2
Serial.println(millis() - t);
#endif
#endif
// Make animation frame visible
// swapBuffers() call can take up to 1/framerate seconds to return (it waits until a buffer copy is complete)
// note the time before calling
// Hold until time to display new frame (see comment at start of function)
if (_delayAfterDecode) {
uint32_t t;
while(((t = micros()) - frameStartTime) < priorFrameDelay);
cycleTime += frameDelay * 10;
if(updateScreenCallback) {
(*updateScreenCallback)();
}
frameStartTime = t;
}
}
| [
"[email protected]"
] | |
d96986285338748d322808fd3b86da2d05a1ae81 | 91535f5b6ad4477a00a65a1c73495f571b2ef95d | /qt/GoL/GoL_000/main.cpp | 5eb8f39cb0e05349c362c626535d5d839e9c4e20 | [] | no_license | dsyleixa/RaspberryPi | 4e7bab79567d6333739b67cb13da6f5a71caeb5b | b287e027f10e60733d36dde7966e5ab21ca1694b | refs/heads/master | 2023-08-19T17:54:34.829011 | 2023-08-05T09:39:27 | 2023-08-05T09:39:27 | 193,234,687 | 4 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 521 | cpp | // main.cpp
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <gameoflifemodel.h>
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
qmlRegisterType<GameOfLifeModel>("GameOfLifeModel", 1, 0, "GameOfLifeModel");
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}
| [
"[email protected]"
] | |
e182ac50e012e2d3d64581129375fa71cd199615 | 5ac878fd58f97a9747ec21c8a149691f9c35046b | /cgCircle.cpp | 269029212c476c0346eb217e9cc739b7866bbf00 | [] | no_license | 474176409/MFC_GraphicsEditor | 90cf61d0c0ba17c10e9f960768a7db185e5322ee | 016c507b1c467945ff94f0c1aeb9cb3aec9838f0 | refs/heads/master | 2021-05-04T09:01:57.412611 | 2016-11-13T12:21:38 | 2016-11-13T12:21:38 | 70,387,840 | 1 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,146 | cpp | // cgCircle.cpp: implementation of the cgCircle class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "GraphicsEditor.h"
#include "cgCircle.h"
#include "cgPoint.h"
#include "math.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
cgCircle::cgCircle()
{
R=0;
m_first=false;
}
cgCircle::~cgCircle()
{
}
void cgCircle::Darw()
{
int i=0;
int n=100;
float x=(x1+x2)/2.0;
float y=(y1+y2)/2.0;
R=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))/2;
glColor3f(m_fR,m_fG,m_fB);
glBegin(GL_LINE_LOOP);
for(i=0; i<n; ++i)
glVertex2f(x+R*cos(2*3.1415926/n*i), y+R*sin(2*3.1415926/n*i));
glEnd();
//画矩形
if (m_eStatus == Selected || m_eStatus == Moving)
{
//绘制矩形
glColor3f(0,1,0);
glBegin(GL_LINE_LOOP);
glVertex2f(x+R,y+R);
glVertex2f(x+R,y-R);
glVertex2f(x-R,y-R);
glVertex2f(x-R,y+R);
glEnd();
}
}
void cgCircle::CalBox()
{
}
BOOL cgCircle::HitTest(float x, float y)
{
float x0=(x1+x2)/2.0;
float y0=(y1+y2)/2.0;
if(sqrt((x-x0)*(x-x0)+(y-y0)*(y-y0))<R)
return true;
return false;
}
void cgCircle::OnLButtonDown(UINT nFlags, CPoint point)
{
if(!m_first)
{
x1=point.x;
y1=point.y;
m_first=true;
}
else
{
x2=point.x;
y2=point.y;
m_eStatus = InputingEnd;
}
}
void cgCircle::OnMouseMove(UINT nFlags, CPoint point)
{
if(m_first && m_eStatus == Inputing)
{
x2=point.x;
y2=point.y;
}
if (nFlags == MK_LBUTTON && m_eStatus == Selected)//移动图形
{
m_eStatus = Moving;
m_tempPoint = point;
}
if (nFlags == MK_LBUTTON && m_eStatus == Moving)//移动图形
{
int dx = point.x - m_tempPoint.x;
int dy = point.y - m_tempPoint.y;
x1 += dx; y1 -= dy;
x2 += dx; y2 -= dy;
m_tempPoint = point;
}
}
void cgCircle::OnRButtonDown(UINT nFlags, CPoint point)
{
}
| [
"[email protected]"
] | |
55e99a6fec8347d849ddd3da0d4cca629b21d241 | 41b05710409003277a03d782693f2c202e6bf7f7 | /server/view_breakpoint_download.h | bfa53a3125fb5146a9e5a6720e9847df05678b45 | [] | no_license | lipengxiao/cloud_disk | 0a6f5b307997bb550ac0687d079c656401a8d57f | f704430ced2ccc06a2f033ee7ac44770ff65273b | refs/heads/master | 2020-03-22T12:57:22.289175 | 2018-07-10T06:46:02 | 2018-07-10T06:46:02 | 140,073,070 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 241 | h | #ifndef _VIEW_BREAKPOINT_TRANS_H
#define _VIEW_BREAKPOINT_TRANS_H
#include"view.h"
using namespace std;
class view_breakpoint_download:public view
{
public:
void process(Json::Value val,int cli_fd);
private:
int _cli_fd;
};
#endif
| [
"[email protected]"
] | |
734fdc8ff6cb9f0bfaca11f907c8c5e854a6b42b | 950b506e3f8fd978f076a5b9a3a950f6f4d5607b | /cf/361-div2/E.cpp | 68a5e524a16f7db1973197cbe89a6a9b8d3226ca | [] | no_license | Mityai/contests | 2e130ebb8d4280b82e7e017037fc983063228931 | 5b406b2a94cc487b0c71cb10386d1b89afd1e143 | refs/heads/master | 2021-01-09T06:09:17.441079 | 2019-01-19T12:47:20 | 2019-01-19T12:47:20 | 80,909,953 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,557 | cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int N = 2e5 + 1;
ll fact[N];
ll bp(ll x, ll n) {
if (n == 0) return 1LL;
ll b = bp(x, n / 2);
b = (b * b) % MOD;
if (n & 1) b = (b * x) % MOD;
return b;
}
ll cnk(ll n, ll k) {
if (k < 0 || k > n) return 0;
ll m = (fact[n] * bp(fact[k], MOD - 2)) % MOD;
m = (m * bp(fact[n - k], MOD - 2)) % MOD;
return m;
}
int main() {
fact[0] = 1;
for (ll i = 1; i < N; i++) {
fact[i] = (fact[i - 1] * i) % MOD;
}
int n, k;
scanf("%d%d", &n, &k);
vector<int> op(n), cl(n);
vector<int> all;
for (int i = 0; i < n; i++) {
scanf("%d%d", &op[i], &cl[i]);
all.push_back(op[i]);
all.push_back(cl[i]);
}
sort(all.begin(), all.end());
all.erase(unique(all.begin(), all.end()), all.end());
vector<int> hp;
for (int i = 1; i < (int)all.size(); i++) {
if (all[i] - all[i - 1] >= 2) hp.push_back(all[i] - 1);
}
int m = hp.size();
for (int x : hp) all.push_back(x);
sort(all.begin(), all.end());
sort(op.begin(), op.end());
sort(cl.begin(), cl.end());
ll ans = 0;
int i = 0, j = 0, z = 0;
int cnt = 0;
for (int cur : all) {
while (i < n && op[i] <= cur) i++, cnt++;
ans = (ans + cnk(cnt, k)) % MOD;
while (j < n && cl[j] <= cur) j++, cnt--;
while (z < m && hp[z] < cur) z++;
if (z < m && hp[z] == cur) {
int prev = max(op[i - 1], (j == 0 ? op[i - 1] : cl[j - 1]));
ans = (ans + (hp[z] - prev - 1) * cnk(cnt, k)) % MOD;
}
}
printf("%lld\n", ans);
}
| [
"[email protected]"
] | |
ad2286dab3fada28f098ea35f6fd53ac09065c04 | 3591d9986aeb633de14da54a84ef80e2958067d7 | /2A-Solutions/Problems 40-49/Problem 42.cpp | 95c0afcab80cbb57d1a6049a8dc5c6c3cacbc565 | [] | no_license | Anshul1507/a2oj-Ladder | 3fb05befce2d5b11381a09d29b8c77b968f6bfcb | 1203aad05595093ded7818d68942bc816e7d4651 | refs/heads/master | 2022-07-28T23:00:18.390815 | 2020-05-23T15:42:52 | 2020-05-23T15:42:52 | 214,992,394 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,045 | cpp | //A - Valera and X (C++)
#include<bits/stdc++.h>
#define ll unsigned long long int
#define HACKS std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
int main()
{
HACKS
int n;
cin >> n;
string arr[n];
for(int i=0;i<n;i++){
cin >> arr[i];
}
char c = arr[0][0];
char o = arr[0][1];
int j=0,flag = 0;
if(o!=c){
for(int i=0;i<n;i++){
if(i != n/2){
if(arr[i][i] != arr[i][n-i-1]){
flag = 1;
break;
}
}else{
if(arr[i][i] != c){
flag = 1;
break;
}
}
}
if(flag != 1){
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(arr[i][j] != o){
if(j != i && j != (n-i-1)){
flag = 1;
break;
}
}
}
if(flag == 1){
break;
}
}
}
}
else{
flag = 1;
}
if(flag == 1){
cout << "NO";
}else{
cout << "YES";
}
return 0;
}
| [
"[email protected]"
] | |
11588d5964b0e9246fcdf50ce481ed1f0bb37e44 | d2d687fc9ffc6ab904c6ec829f2a7d5ccea51b3a | /Source/CurseOfTime/Components/DashComponent.h | 7bbd69457c7fc2702118827ac2972b7ceee8bb76 | [] | no_license | EnriqueBrosse/CurseOfTime | 01f2ef7c17af796cbc2e1080f4b53afe7191fe63 | 034a9e80432026ea7b96478a9785c7c39e743348 | refs/heads/main | 2023-08-20T05:51:14.431537 | 2021-10-20T17:26:35 | 2021-10-20T17:26:35 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 994 | h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "DashComponent.generated.h"
class UStaminaComponent;
class UHealthComponent;
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class CURSEOFTIME_API UDashComponent : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UDashComponent();
void Dash();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
private:
UPROPERTY(EditAnywhere, meta = (AllowPrivateAccess = "true"))
int MaxAmountOfDashes;
int CurrentAmountOfDashes;
UPROPERTY(EditAnywhere, meta = (AllowPrivateAccess = "true"))
float DashDelay;
UPROPERTY(EditAnywhere, meta = (AllowPrivateAccess = "true"))
float DashVelocity;
UStaminaComponent* StaminaComponent;
UHealthComponent* HealthComponent;
UFUNCTION()
void AddDash();
};
| [
"[email protected]"
] | |
53fa00faab1713e88145a1b72ccbb9eda8c66272 | cd73a0b631d8e6fcd60ef609bffeaa3960967713 | /src/SwerveModuleV2.cpp | 1c148f28b317d5803a7b0e535a4ed263dcbd75ae | [] | no_license | Frc2481/frc-2017-swerve | 72763d3937758b83c3b2185c1997c085f7f163c0 | 136c1545e358b337e8c3334891ec3667e0181cf7 | refs/heads/master | 2021-09-03T23:44:24.695885 | 2018-01-12T23:29:13 | 2018-01-12T23:29:13 | 113,689,540 | 4 | 0 | null | 2018-01-12T23:29:14 | 2017-12-09T17:55:35 | C++ | UTF-8 | C++ | false | false | 5,271 | cpp | /*
* SwerveModuleV2.cpp
*
* Created on: Jul 17, 2017
* Author: Team2481
*/
#include <SwerveModuleV2.h>
#include <Components\SwerveModuleV2Constants.h>
#include <math.h>
#include <sstream>
#include <CTREMagEncoder.h>
#include <GreyhillEncoder.h>
//#include <RoboUtils.h>
SwerveModuleV2::SwerveModuleV2(uint32_t driveID, uint32_t steerID,
const std::string name) {
m_name = name;
std::stringstream ss;
ss << name << "_STEER_ENCODER";
m_steerMotor = new TalonSRX(steerID);
m_steerEncoder = new CTREMagEncoder(m_steerMotor, ss.str());
ss.str("");
ss << name << "_DRIVE_ENCODER";
m_driveMotor = new TalonSRX(driveID);
m_driveEncoder = new GreyhillEncoder(m_driveMotor, ss.str(),
SwerveModuleV2Constants::k_ticksPerRev,
SwerveModuleV2Constants::k_inchesPerRev);
m_isCloseLoopControl = false;
m_angleOptimized = false;
m_optimizationEnabled = true;
m_isMoving = false;
m_motionMagic = false;
m_driveMotor->SelectProfileSlot(0, 0);
m_driveMotor->Set(ControlMode::PercentOutput, 0);
m_driveMotor->Config_kP(0, SwerveModuleV2Constants::k_speedP, 0);
m_driveMotor->Config_kI(0, SwerveModuleV2Constants::k_speedI, 0);
m_driveMotor->Config_kD(0, SwerveModuleV2Constants::k_speedD, 0);
m_driveMotor->Config_kF(0, 0.1722, 0);
m_driveMotor->Config_IntegralZone(0, 200, 0);
m_driveMotor->SetSensorPhase(true);
m_driveMotor->SetInverted(true);
m_driveMotor->ConfigNominalOutputForward(0.0, 0.0);
m_driveMotor->ConfigNominalOutputReverse(0.0, 0.0);
m_driveMotor->ConfigPeakOutputForward(12.0, 0.0);
m_driveMotor->ConfigPeakOutputReverse(-12.0, 0.0);
// m_driveMotor->SetMotionMagicAcceleration(m_accel);
// m_driveMotor->SetMotionMagicCruiseVelocity(m_velocity);
m_driveMotor->SetNeutralMode(Brake);
m_steerMotor->SelectProfileSlot(0, 0.0); //Profile 1 PIDf are P = 0.2 f = 1.1
m_steerMotor->ConfigNominalOutputForward(0,0);
m_steerMotor->ConfigNominalOutputReverse(0,0);
m_steerMotor->Set(ControlMode::Position, 0);
m_steerMotor->SetNeutralMode(Brake);
m_steerMotor->Config_kP(0, SwerveModuleV2Constants::k_steerP, 0);
m_steerMotor->Config_kI(0, SwerveModuleV2Constants::k_steerI, 0);
m_steerMotor->Config_kD(0, SwerveModuleV2Constants::k_steerD, 0);
m_steerMotor->SetSensorPhase(true);
m_steerMotor->SetInverted(false);
m_steerMotor->SetSelectedSensorPosition(0, 0, 0);
m_steerMotor->ConfigAllowableClosedloopError(0, 40, 0);
m_steerMotor->SetStatusFramePeriod(Status_2_Feedback0, 10, 0);
// m_steerMotor->SetStatusFrameRateMs(TalonSRX::StatusFrameRateGeneral, 10);
}
SwerveModuleV2::~SwerveModuleV2() {
// TODO Auto-generated destructor stub
}
Rotation2D SwerveModuleV2::GetAngle() const {
return m_steerEncoder->GetAngle();
}
void SwerveModuleV2::SetOptimized(bool isOptimized) {
m_optimizationEnabled = isOptimized;
}
void SwerveModuleV2::SetAngle(Rotation2D angle, bool force) {
if(m_isMoving || force) {
Rotation2D currentAngle = m_steerEncoder->GetAngle();
Rotation2D deltaAngle = currentAngle.rotateBy(angle.inverse());
if(m_optimizationEnabled &&
deltaAngle.getRadians() > M_PI_2 &&
deltaAngle.getRadians() < 3 * M_PI_2) {
angle = angle.rotateBy(Rotation2D::fromRadians(M_PI));
m_angleOptimized = true;
}
else {
m_angleOptimized = false;
}
int setpoint = m_steerEncoder->ConvertAngleToSetpoint(angle);
m_steerMotor->Set(ControlMode::Position, setpoint / 4096.0);
SmartDashboard::PutNumber("CurrentAngle", currentAngle.getDegrees());
SmartDashboard::PutNumber("DeltaAngle", deltaAngle.getDegrees());
SmartDashboard::PutNumber("Setpoint", setpoint);
}
SmartDashboard::PutNumber("ActualAngle", GetAngle().getDegrees());
SmartDashboard::PutNumber("SetAngle", angle.getDegrees());
SmartDashboard::PutNumber("EncoderTicks", m_steerEncoder->GetEncoderTicks(true));
}
bool SwerveModuleV2::IsSteerOnTarget() const {
return fabs(m_steerMotor->GetClosedLoopError(0)) <= 20;
}
void SwerveModuleV2::SetOpenLoopSpeed(double speed) {
if(m_angleOptimized) {
speed *= -1;
}
m_driveMotor->Set(ControlMode::PercentOutput, speed);
m_isMoving = fabs(speed) > .05;
m_isCloseLoopControl = false;
}
double SwerveModuleV2::GetSpeed()const {
return m_driveEncoder->GetSpeed();
}
void SwerveModuleV2::SetCloseLoopDriveDistance(Translation2D distance) {
double distInches = distance.getX();
if(m_angleOptimized) {
distInches *= -1;
}
m_driveMotor->Set(ControlMode::MotionMagic, distInches);
m_isMoving = true;
m_isCloseLoopControl = true;
}
void SwerveModuleV2::DisableCloseLoopDrive() {
SetOpenLoopSpeed(0);
}
Translation2D SwerveModuleV2::GetDistance() const {
return m_driveEncoder->GetDistance();
}
void SwerveModuleV2::ZeroDriveDistance() {
m_driveEncoder->Reset();
}
double SwerveModuleV2::GetDistanceError() const {
return m_driveMotor->GetClosedLoopError(0);
}
bool SwerveModuleV2::IsDriveOnTarget() const {
return GetDistanceError() < 4; //absolute value?
}
void SwerveModuleV2::Set(double speed, Rotation2D angle) {
if(m_isCloseLoopControl){
SetAngle(angle, true);
}
else {
SetOpenLoopSpeed(speed);
SetAngle(angle, false);
}
}
void SwerveModuleV2::SetBrake(bool brake) {
m_driveMotor->SetNeutralMode(brake ? Brake : Coast);
}
void SwerveModuleV2::SetMagicAccel(double accel) {
m_driveMotor->ConfigMotionAcceleration(accel, 0);
}
| [
"[email protected]"
] | |
2fe1f12927b86537688a1e634acb181fe6e0d149 | 03c6d91afa813b32aa0c0f5710c8ccc68e5d7c05 | /codeforces 869 B. The Eternal Immortality.cpp | a4b0ce302c1e0d815472b12a32b48f125b95c38f | [] | no_license | DorianBajorek/Codeforces-solutions | 96fe6c54b55681fe030f3e9015367d2176d10daf | d8e936de286342fef7230da2afbc50dd13164c93 | refs/heads/master | 2023-05-29T00:52:16.680588 | 2020-10-05T16:33:52 | 2020-10-05T16:33:52 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,349 | cpp |
// Problem : B. The Eternal Immortality
// Contest : Codeforces - Codeforces Round #439 (Div. 2)
// URL : https://codeforces.com/contest/869/problem/B
// Memory Limit : 256.000000 MB
// Time Limit : 1000.000000 milisec
// Powered by CP Editor (https://github.com/coder3101/cp-editor)
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define MOD 1000000007
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(p) p.begin(),p.end()
#define mid(s,e) (s+(e-s)/2)
#define eb emplace_back
#define ull unsigned long long
#define bug(x) cout<<" [ "#x<<" = "<<x<<" ]"<<endl;
#define KAMEHAMEHA ios_base::sync_with_stdio(0);
#define RASENGAN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
KAMEHAMEHA
ull n,m,ans=1;
cin>>n>>m;
for(ull i=m;i>n;i--)
{
ans=(ans*i)%10;
if(ans==0)
break;
}
cout<<ans<<endl;
return 0;
}
| [
"[email protected]"
] | |
31c418045f3e6546f02ec9e369b88f3dfa8371d4 | 6c0f8abb26f9832eb7ab00901f470d001be4af32 | /util/Integrator.h | 3741c258cd56e28e5178277e737e197dd110efb3 | [
"MIT"
] | permissive | erikleitch/climax | 146a6bf69b04f0df8879e77ea4529b4c269015a5 | 66ce64b0ab9f3a3722d3177cc5215ccf59369e88 | refs/heads/master | 2021-07-19T17:17:22.524714 | 2021-02-02T17:17:35 | 2021-02-02T17:17:35 | 57,599,379 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,684 | h | #ifndef GCP_UTIL_INTEGRATOR_H
#define GCP_UTIL_INTEGRATOR_H
/**
* @file Integrator.h
*
* Tagged: Wed Oct 23 16:47:33 PDT 2013
*
* @version: $Revision: $, $Date: $
*
* @author Erik Leitch
*/
#include "gsl/gsl_integration.h"
#define INT_FN(fn) double (fn)(double x, void* params)
namespace gcp {
namespace util {
class Integrator {
public:
/**
* Constructor.
*/
Integrator();
/**
* Destructor.
*/
virtual ~Integrator();
void initializeGslMembers();
void installGslFn(INT_FN(*gslIntFn), void* params);
double integrateFromLowlimToHighlim(double lowLim, double highLim);
double integrateFromNegInftyToPosInfty();
double integrateFromLowlimToInfty(double lowLim);
double integrateFromNegInftyToHighlim(double highLim);
double integrateFromLowlimToHighlim(INT_FN(*gslIntFn), void* params, double lowLim, double highLim);
double integrateFromNegInftyToPosInfty(INT_FN(*gslIntFn), void* params);
double integrateFromLowlimToInfty(INT_FN(*gslIntFn), void* params, double lowLim);
double integrateFromNegInftyToHighlim(INT_FN(*gslIntFn), void* params, double highLim);
//------------------------------------------------------------
// Parameters needed to pass to the GSL integration routines
//------------------------------------------------------------
double gslEpsAbs_;
double gslEpsRel_;
gsl_integration_workspace* gslWork_;
size_t gslLimit_;
gsl_function gslFn_;
}; // End class Integrator
} // End namespace util
} // End namespace gcp
#endif // End #ifndef GCP_UTIL_INTEGRATOR_H
| [
"[email protected]"
] | |
dd3a67e6591d10221dfec4f25823592980afb7e2 | 38b7c79c386f46f53be75df5f4003ba4b2b8f1f8 | /LeetCode/Array/2D Array/FindDiagonalOrder.cpp | 36637626126bec2e1c87655053fbdb1ba1c12ae9 | [] | no_license | inioluwaa/Problem-Solving | 28c5c6e644583fc83847c597654004145688c080 | 77482ac0b0224af626bcd329a4f091058f635e73 | refs/heads/master | 2020-04-09T08:09:18.675605 | 2019-07-05T06:20:35 | 2019-07-05T06:20:35 | 158,824,806 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,002 | cpp | #include <iostream>
#include <vector>
using namespace std;
vector<int> findDiagonalOrder2(vector<vector<int>>& matrix);
int main() {
vector<vector<int>> vect{ {1, 2, 3}, {4, 5, 6}, {7, 8, 9} };
// vector<vector<int>> vect{{6, 9, 7}};
vector<int> u = findDiagonalOrder2(vect);
for (auto i : u) {
cout << i << " ";
}
}
vector<int> findDiagonalOrder(vector<vector<int>>& matrix) {
if(matrix.empty()) return {};
int i = 0, j = 0;
vector<int> result;
bool isUp = true;
int row = matrix.size();
int column = matrix[0].size();
for (int k(0); k < row * column;) {
if (isUp) {
for (; i >= 0 && j < column; ++j, --i) {
result.emplace_back(matrix[i][j]);
++k;
}
if (i < 0 && j < column)
i = 0;
if (j == column)
i = i + 2, j--;
}
else {
for (; j >= 0 && i < row; ++i, --j) {
result.emplace_back(matrix[i][j]);
++k;
}
if (j < 0 && i < row)
j = 0;
if (i == row)
j = j + 2, i--;
}
isUp = !isUp;
}
return result;
}
vector<int> findDiagonalOrder2(vector<vector<int>>& matrix) {
vector<int> result;
if (matrix.empty()) return {};
int row = matrix.size();
int col = matrix[0].size();
int m = 0, n = 0, dir = 1;
for (int i(0); i < row * col; ++i) {
result.emplace_back(matrix[m][n]);
m -= dir;
n += dir;
// Out of bottom order.
if (m >= row) {
m--; n += 2; dir = -dir;
}
// Out of right order.
if (n >= col) {
n--, m += 2; dir = -dir;
}
// Out of top order.
if (m < 0) {
m = 0;
dir = -dir;
}
// Out of left order.
if (n < 0) {
n = 0;
dir = -dir;
}
}
return result;
} | [
"[email protected]"
] | |
a16b7e43c88076b8e6af5b06fb3b6826dcf9e2f2 | 0a7c20991b0d63561a144e27b646520c45c154c7 | /RTSPServer/Src/V4L2FramedSource.cpp | 66ca896a5c893d1fe3824f9c9a333bc0d3fd3c5d | [] | no_license | jweih/v4l2-2 | 406d8cce11215f21d69c4e136b496f0e8ab38077 | e69f3ab31f2a35376a5f658884318dd855e214f5 | refs/heads/master | 2021-01-23T05:36:05.184728 | 2014-12-10T11:24:30 | 2014-12-10T11:24:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,600 | cpp | #include <V4L2FramedSource.h>
int V4L2FramedSource::nalIndex = 0;
V4L2* V4L2FramedSource::v4l2 = new V4L2();
V4L2FramedSource::V4L2FramedSource(UsageEnvironment & env) :
FramedSource(env)
{
output_bufsize = 128 * 1024;
outbuf = malloc(output_bufsize);
//v4l2 = new V4L2();
pEncode = new H264Encode();
mp_token = NULL;
m_started = 0;
printf("creater\n");
v4l2->initDev("/dev/video0", 320, 240);
avpicture_alloc(&Picture, PIX_FMT_YUV420P, v4l2->getWidth(),
v4l2->getHeight());
v4l2->startStream();
pEncode->x264_init(Picture, 320, 240);
signal(SIGINT, V4L2FramedSource::stop);
}
V4L2FramedSource::~V4L2FramedSource()
{
}
unsigned V4L2FramedSource::maxFrameSize() const
{
return 100 * 1024;
}
void V4L2FramedSource::doGetNextFrame()
{
/*printf("m_started = %d\n", m_started);
if(m_started) return;
m_started = 1;
double delay = 1000.0 / 5;
int to_delay = delay * 1000; // us
mp_token = envir().taskScheduler().scheduleDelayedTask(to_delay,
getNextFrame, this);
printf("doGetNextFrame\n");*/
if (V4L2FramedSource::nalIndex == pEncode->nnal)
{
v4l2->readFrame(Picture, PIX_FMT_YUV420P, v4l2->getWidth(),
v4l2->getHeight());
pEncode->x264_encode();
V4L2FramedSource::nalIndex = 0;
gettimeofday(&fPresentationTime, NULL);
}
memmove(fTo, pEncode->nals[V4L2FramedSource::nalIndex].p_payload,
pEncode->nals[V4L2FramedSource::nalIndex].i_payload);
printf("head[0]=%x\n",pEncode->nals[V4L2FramedSource::nalIndex].p_payload[4]);
fFrameSize = pEncode->nals[V4L2FramedSource::nalIndex].i_payload;
V4L2FramedSource::nalIndex++;
afterGetting(this); //通知RTPSink数据获取完成
}
void V4L2FramedSource::getNextFrame1()
{
int res = v4l2->readFrame(Picture, PIX_FMT_YUV420P, v4l2->getWidth(),
v4l2->getHeight());
if(res < 1){
m_started = 0;
printf("failed to readframe\n");
return;
}
pEncode->x264_encode();
int output_datasize = 0;
char *pout = (char*)outbuf;
for(int i=0;i<pEncode->nnal;i++){
if(output_datasize + pEncode->nals[i].i_payload > output_bufsize){
output_bufsize = (output_datasize + pEncode->nals[i].i_payload + 4095)/4096 * 4096;
outbuf = realloc(outbuf, output_bufsize);
}
memcpy(pout + output_datasize, pEncode->nals[i].p_payload, pEncode->nals[i].i_payload);
output_datasize += pEncode->nals[i].i_payload;
}
gettimeofday(&fPresentationTime, NULL);
fFrameSize = output_datasize;
if(fFrameSize > fMaxSize){
fNumTruncatedBytes = fFrameSize - fMaxSize;
fFrameSize = fMaxSize;
}else{
fNumTruncatedBytes = 0;
}
memmove(fTo, outbuf, fFrameSize);
afterGetting(this);
m_started = 0;
}
| [
"[email protected]"
] | |
aa47118ba19df716d394f5ffc2954e5634dc6266 | fb14da294e8c6f2b0576e16aa6e48b6957965c8b | /src/qt/clientmodel.cpp | a29d8a3884441603ef83fa15e97dc29862578648 | [
"MIT"
] | permissive | Mitracore/Mitracore | c1d960e95115df701528f9043756d772e813bbdf | aff4bcd53d3d31f6ae327477738a3a356d3f89eb | refs/heads/master | 2020-03-15T10:02:52.708394 | 2018-05-04T05:13:49 | 2018-05-04T05:13:49 | 132,046,562 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,921 | cpp | // Copyright (c) 2011-2014 The Bitcoin developers
// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2017 The PIVX developers
// Copyright (c) 2017 The Mitra developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "clientmodel.h"
#include "guiconstants.h"
#include "peertablemodel.h"
#include "alert.h"
#include "chainparams.h"
#include "checkpoints.h"
#include "clientversion.h"
#include "main.h"
#include "masternode-sync.h"
#include "masternodeman.h"
#include "net.h"
#include "ui_interface.h"
#include "util.h"
#include <stdint.h>
#include <QDateTime>
#include <QDebug>
#include <QTimer>
static const int64_t nClientStartupTime = GetTime();
ClientModel::ClientModel(OptionsModel* optionsModel, QObject* parent) : QObject(parent),
optionsModel(optionsModel),
peerTableModel(0),
cachedNumBlocks(0),
cachedMasternodeCountString(""),
cachedReindexing(0), cachedImporting(0),
numBlocksAtStartup(-1), pollTimer(0)
{
peerTableModel = new PeerTableModel(this);
pollTimer = new QTimer(this);
connect(pollTimer, SIGNAL(timeout()), this, SLOT(updateTimer()));
pollTimer->start(MODEL_UPDATE_DELAY);
pollMnTimer = new QTimer(this);
connect(pollMnTimer, SIGNAL(timeout()), this, SLOT(updateMnTimer()));
// no need to update as frequent as data for balances/txes/blocks
pollMnTimer->start(MODEL_UPDATE_DELAY * 4);
subscribeToCoreSignals();
}
ClientModel::~ClientModel()
{
unsubscribeFromCoreSignals();
}
int ClientModel::getNumConnections(unsigned int flags) const
{
LOCK(cs_vNodes);
if (flags == CONNECTIONS_ALL) // Shortcut if we want total
return vNodes.size();
int nNum = 0;
BOOST_FOREACH (CNode* pnode, vNodes)
if (flags & (pnode->fInbound ? CONNECTIONS_IN : CONNECTIONS_OUT))
nNum++;
return nNum;
}
QString ClientModel::getMasternodeCountString() const
{
return tr("Total: %1 (OBF compatible: %2 / Enabled: %3)").arg(QString::number((int)mnodeman.size())).arg(QString::number((int)mnodeman.CountEnabled(ActiveProtocol()))).arg(QString::number((int)mnodeman.CountEnabled()));
}
int ClientModel::getNumBlocks() const
{
LOCK(cs_main);
return chainActive.Height();
}
int ClientModel::getNumBlocksAtStartup()
{
if (numBlocksAtStartup == -1) numBlocksAtStartup = getNumBlocks();
return numBlocksAtStartup;
}
quint64 ClientModel::getTotalBytesRecv() const
{
return CNode::GetTotalBytesRecv();
}
quint64 ClientModel::getTotalBytesSent() const
{
return CNode::GetTotalBytesSent();
}
QDateTime ClientModel::getLastBlockDate() const
{
LOCK(cs_main);
if (chainActive.Tip())
return QDateTime::fromTime_t(chainActive.Tip()->GetBlockTime());
else
return QDateTime::fromTime_t(Params().GenesisBlock().GetBlockTime()); // Genesis block's time of current network
}
double ClientModel::getVerificationProgress() const
{
LOCK(cs_main);
return Checkpoints::GuessVerificationProgress(chainActive.Tip());
}
void ClientModel::updateTimer()
{
// Get required lock upfront. This avoids the GUI from getting stuck on
// periodical polls if the core is holding the locks for a longer time -
// for example, during a wallet rescan.
TRY_LOCK(cs_main, lockMain);
if (!lockMain)
return;
// Some quantities (such as number of blocks) change so fast that we don't want to be notified for each change.
// Periodically check and update with a timer.
int newNumBlocks = getNumBlocks();
static int prevAttempt = -1;
static int prevAssets = -1;
// check for changed number of blocks we have, number of blocks peers claim to have, reindexing state and importing state
if (cachedNumBlocks != newNumBlocks ||
cachedReindexing != fReindex || cachedImporting != fImporting ||
masternodeSync.RequestedMasternodeAttempt != prevAttempt || masternodeSync.RequestedMasternodeAssets != prevAssets) {
cachedNumBlocks = newNumBlocks;
cachedReindexing = fReindex;
cachedImporting = fImporting;
prevAttempt = masternodeSync.RequestedMasternodeAttempt;
prevAssets = masternodeSync.RequestedMasternodeAssets;
emit numBlocksChanged(newNumBlocks);
}
emit bytesChanged(getTotalBytesRecv(), getTotalBytesSent());
}
void ClientModel::updateMnTimer()
{
// Get required lock upfront. This avoids the GUI from getting stuck on
// periodical polls if the core is holding the locks for a longer time -
// for example, during a wallet rescan.
TRY_LOCK(cs_main, lockMain);
if (!lockMain)
return;
QString newMasternodeCountString = getMasternodeCountString();
if (cachedMasternodeCountString != newMasternodeCountString) {
cachedMasternodeCountString = newMasternodeCountString;
emit strMasternodesChanged(cachedMasternodeCountString);
}
}
void ClientModel::updateNumConnections(int numConnections)
{
emit numConnectionsChanged(numConnections);
}
void ClientModel::updateAlert(const QString& hash, int status)
{
// Show error message notification for new alert
if (status == CT_NEW) {
uint256 hash_256;
hash_256.SetHex(hash.toStdString());
CAlert alert = CAlert::getAlertByHash(hash_256);
if (!alert.IsNull()) {
emit message(tr("Network Alert"), QString::fromStdString(alert.strStatusBar), CClientUIInterface::ICON_ERROR);
}
}
emit alertsChanged(getStatusBarWarnings());
}
bool ClientModel::inInitialBlockDownload() const
{
return IsInitialBlockDownload();
}
enum BlockSource ClientModel::getBlockSource() const
{
if (fReindex)
return BLOCK_SOURCE_REINDEX;
else if (fImporting)
return BLOCK_SOURCE_DISK;
else if (getNumConnections() > 0)
return BLOCK_SOURCE_NETWORK;
return BLOCK_SOURCE_NONE;
}
QString ClientModel::getStatusBarWarnings() const
{
return QString::fromStdString(GetWarnings("statusbar"));
}
OptionsModel* ClientModel::getOptionsModel()
{
return optionsModel;
}
PeerTableModel* ClientModel::getPeerTableModel()
{
return peerTableModel;
}
QString ClientModel::formatFullVersion() const
{
return QString::fromStdString(FormatFullVersion());
}
QString ClientModel::formatBuildDate() const
{
return QString::fromStdString(CLIENT_DATE);
}
bool ClientModel::isReleaseVersion() const
{
return CLIENT_VERSION_IS_RELEASE;
}
QString ClientModel::clientName() const
{
return QString::fromStdString(CLIENT_NAME);
}
QString ClientModel::formatClientStartupTime() const
{
return QDateTime::fromTime_t(nClientStartupTime).toString();
}
// Handlers for core signals
static void ShowProgress(ClientModel* clientmodel, const std::string& title, int nProgress)
{
// emits signal "showProgress"
QMetaObject::invokeMethod(clientmodel, "showProgress", Qt::QueuedConnection,
Q_ARG(QString, QString::fromStdString(title)),
Q_ARG(int, nProgress));
}
static void NotifyNumConnectionsChanged(ClientModel* clientmodel, int newNumConnections)
{
// Too noisy: qDebug() << "NotifyNumConnectionsChanged : " + QString::number(newNumConnections);
QMetaObject::invokeMethod(clientmodel, "updateNumConnections", Qt::QueuedConnection,
Q_ARG(int, newNumConnections));
}
static void NotifyAlertChanged(ClientModel* clientmodel, const uint256& hash, ChangeType status)
{
qDebug() << "NotifyAlertChanged : " + QString::fromStdString(hash.GetHex()) + " status=" + QString::number(status);
QMetaObject::invokeMethod(clientmodel, "updateAlert", Qt::QueuedConnection,
Q_ARG(QString, QString::fromStdString(hash.GetHex())),
Q_ARG(int, status));
}
void ClientModel::subscribeToCoreSignals()
{
// Connect signals to client
uiInterface.ShowProgress.connect(boost::bind(ShowProgress, this, _1, _2));
uiInterface.NotifyNumConnectionsChanged.connect(boost::bind(NotifyNumConnectionsChanged, this, _1));
uiInterface.NotifyAlertChanged.connect(boost::bind(NotifyAlertChanged, this, _1, _2));
}
void ClientModel::unsubscribeFromCoreSignals()
{
// Disconnect signals from client
uiInterface.ShowProgress.disconnect(boost::bind(ShowProgress, this, _1, _2));
uiInterface.NotifyNumConnectionsChanged.disconnect(boost::bind(NotifyNumConnectionsChanged, this, _1));
uiInterface.NotifyAlertChanged.disconnect(boost::bind(NotifyAlertChanged, this, _1, _2));
}
| [
"[email protected]"
] | |
6485690449b734db1c9de4a674a7405998160adb | 6226b0d300d2fec931c0da9b872b0f5e132b4e3e | /include/serial/objectinfo.hpp | afc4b231ff2bb622552dba9970e2715ad8e3dcb5 | [] | no_license | public-domain/ncbi_cxx | 19f7eb61e9d428953ae677252be14324db696032 | 6bbd03af3d07f279f64adab9edfc9eefe7866d88 | refs/heads/master | 2021-02-09T01:18:32.894918 | 2020-03-01T20:48:19 | 2020-03-01T20:48:19 | 244,221,269 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 16,960 | hpp | #ifndef OBJECTINFO__HPP
#define OBJECTINFO__HPP
/* $Id: objectinfo.hpp 143121 2008-10-15 16:18:21Z vasilche $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
* National Center for Biotechnology Information
*
* This software/database is a "United States Government Work" under the
* terms of the United States Copyright Act. It was written as part of
* the author's official duties as a United States Government employee and
* thus cannot be copyrighted. This software/database is freely available
* to the public for use. The National Library of Medicine and the U.S.
* Government have not placed any restriction on its use or reproduction.
*
* Although all reasonable efforts have been taken to ensure the accuracy
* and reliability of the software and data, the NLM and the U.S.
* Government do not and cannot warrant the performance or results that
* may be obtained by using this software or data. The NLM and the U.S.
* Government disclaim all warranties, express or implied, including
* warranties of performance, merchantability or fitness for any particular
* purpose.
*
* Please cite the author in any work or product based on this material.
*
* ===========================================================================
*
* Author: Eugene Vasilchenko
*
* File Description:
* Object information classes
*/
#include <corelib/ncbistd.hpp>
#include <corelib/ncbiobj.hpp>
#include <serial/serialdef.hpp>
#include <serial/impl/continfo.hpp>
#include <serial/impl/ptrinfo.hpp>
#include <serial/impl/stdtypes.hpp>
#include <serial/impl/classinfo.hpp>
#include <serial/impl/choice.hpp>
#include <serial/impl/enumerated.hpp>
#include <vector>
#include <memory>
/** @addtogroup ObjStreamSupport
*
* @{
*/
BEGIN_NCBI_SCOPE
class CObjectTypeInfo;
class CConstObjectInfo;
class CObjectInfo;
class CPrimitiveTypeInfo;
class CClassTypeInfoBase;
class CClassTypeInfo;
class CChoiceTypeInfo;
class CContainerTypeInfo;
class CPointerTypeInfo;
class CMemberId;
class CItemInfo;
class CMemberInfo;
class CVariantInfo;
class CReadContainerElementHook;
class CObjectTypeInfoMI;
class CObjectTypeInfoVI;
class CObjectTypeInfoCV;
class CConstObjectInfoMI;
class CConstObjectInfoCV;
class CConstObjectInfoEI;
class CObjectInfoMI;
class CObjectInfoCV;
class CObjectInfoEI;
/// Facilitate access to the data type information.
/// No concrete object is referenced.
class NCBI_XSERIAL_EXPORT CObjectTypeInfo
{
public:
typedef CObjectTypeInfoMI CMemberIterator;
typedef CObjectTypeInfoVI CVariantIterator;
typedef CObjectTypeInfoCV CChoiceVariant;
CObjectTypeInfo(TTypeInfo typeinfo = 0);
/// Get type name
const string& GetName(void) const
{
return GetTypeInfo()->GetName();
}
/// Get data type family
ETypeFamily GetTypeFamily(void) const;
bool Valid(void) const
{
return m_TypeInfo != 0;
}
DECLARE_OPERATOR_BOOL_PTR(m_TypeInfo);
bool operator==(const CObjectTypeInfo& type) const;
bool operator!=(const CObjectTypeInfo& type) const;
// primitive type interface
// only when GetTypeFamily() == eTypeFamilyPrimitive
EPrimitiveValueType GetPrimitiveValueType(void) const;
bool IsPrimitiveValueSigned(void) const;
// only when GetPrimitiveValueType() == ePrimitiveValueEnum
const CEnumeratedTypeValues& GetEnumeratedTypeValues(void) const;
// container interface
// only when GetTypeFamily() == eTypeFamilyContainer
CObjectTypeInfo GetElementType(void) const;
// class interface
// only when GetTypeFamily() == eTypeFamilyClass
CMemberIterator BeginMembers(void) const;
CMemberIterator FindMember(const string& memberName) const;
CMemberIterator FindMemberByTag(int memberTag) const;
// choice interface
// only when GetTypeFamily() == eTypeFamilyChoice
CVariantIterator BeginVariants(void) const;
CVariantIterator FindVariant(const string& memberName) const;
CVariantIterator FindVariantByTag(int memberTag) const;
// pointer interface
// only when GetTypeFamily() == eTypeFamilyPointer
CObjectTypeInfo GetPointedType(void) const;
/// Set local (for the specified stream) read hook
/// @param stream
/// Input data stream reader
/// @param hook
/// Pointer to hook object
void SetLocalReadHook(CObjectIStream& stream,
CReadObjectHook* hook) const;
/// Set global (for all streams) read hook
/// @param hook
/// Pointer to hook object
void SetGlobalReadHook(CReadObjectHook* hook) const;
/// Reset local read hook
/// @param stream
/// Input data stream reader
void ResetLocalReadHook(CObjectIStream& stream) const;
/// Reset global read hooks
void ResetGlobalReadHook(void) const;
/// Set local context-specific read hook
/// @param stream
/// Input data stream reader
/// @param path
/// Context (stack path)
/// @param hook
/// Pointer to hook object
void SetPathReadHook(CObjectIStream* stream, const string& path,
CReadObjectHook* hook) const;
/// Set local (for the specified stream) write hook
/// @param stream
/// Output data stream writer
/// @param hook
/// Pointer to hook object
void SetLocalWriteHook(CObjectOStream& stream,
CWriteObjectHook* hook) const;
/// Set global (for all streams) write hook
/// @param hook
/// Pointer to hook object
void SetGlobalWriteHook(CWriteObjectHook* hook) const;
/// Reset local write hook
/// @param stream
/// Output data stream writer
void ResetLocalWriteHook(CObjectOStream& stream) const;
/// Reset global write hooks
void ResetGlobalWriteHook(void) const;
/// Set local context-specific write hook
/// @param stream
/// Output data stream writer
/// @param path
/// Context (stack path)
/// @param hook
/// Pointer to hook object
void SetPathWriteHook(CObjectOStream* stream, const string& path,
CWriteObjectHook* hook) const;
/// Set local (for the specified stream) skip hook
/// @param stream
/// Input data stream reader
/// @param hook
/// Pointer to hook object
void SetLocalSkipHook(CObjectIStream& stream,
CSkipObjectHook* hook) const;
/// Set global (for all streams) skip hook
/// @param hook
/// Pointer to hook object
void SetGlobalSkipHook(CSkipObjectHook* hook) const;
/// Reset local skip hook
/// @param stream
/// Input data stream reader
void ResetLocalSkipHook(CObjectIStream& stream) const;
/// Reset global skip hooks
void ResetGlobalSkipHook(void) const;
/// Set local context-specific skip hook
/// @param stream
/// Input data stream reader
/// @param path
/// Context (stack path)
/// @param hook
/// Pointer to hook object
void SetPathSkipHook(CObjectIStream* stream, const string& path,
CSkipObjectHook* hook) const;
/// Set local (for the specified stream) copy hook
/// @param stream
/// Data copier
/// @param hook
/// Pointer to hook object
void SetLocalCopyHook(CObjectStreamCopier& stream,
CCopyObjectHook* hook) const;
/// Set global (for all streams) copy hook
/// @param hook
/// Pointer to hook object
void SetGlobalCopyHook(CCopyObjectHook* hook) const;
/// Reset local copy hook
/// @param stream
/// Data copier
void ResetLocalCopyHook(CObjectStreamCopier& stream) const;
/// Reset global read hooks
void ResetGlobalCopyHook(void) const;
/// Set local context-specific copy hook
/// @param stream
/// Data copier
/// @param path
/// Context (stack path)
/// @param hook
/// Pointer to hook object
void SetPathCopyHook(CObjectStreamCopier* stream, const string& path,
CCopyObjectHook* hook) const;
public: // mostly for internal use
TTypeInfo GetTypeInfo(void) const;
const CPrimitiveTypeInfo* GetPrimitiveTypeInfo(void) const;
const CEnumeratedTypeInfo* GetEnumeratedTypeInfo(void) const;
const CClassTypeInfo* GetClassTypeInfo(void) const;
const CChoiceTypeInfo* GetChoiceTypeInfo(void) const;
const CContainerTypeInfo* GetContainerTypeInfo(void) const;
const CPointerTypeInfo* GetPointerTypeInfo(void) const;
TMemberIndex FindMemberIndex(const string& name) const;
TMemberIndex FindMemberIndex(int tag) const;
TMemberIndex FindVariantIndex(const string& name) const;
TMemberIndex FindVariantIndex(int tag) const;
CMemberIterator GetMemberIterator(TMemberIndex index) const;
CVariantIterator GetVariantIterator(TMemberIndex index) const;
protected:
void ResetTypeInfo(void);
void SetTypeInfo(TTypeInfo typeinfo);
void CheckTypeFamily(ETypeFamily family) const;
void WrongTypeFamily(ETypeFamily needFamily) const;
private:
TTypeInfo m_TypeInfo;
private:
CTypeInfo* GetNCTypeInfo(void) const;
};
/// Facilitate read access to a particular instance of an object
/// of the specified type.
class NCBI_XSERIAL_EXPORT CConstObjectInfo : public CObjectTypeInfo
{
public:
typedef TConstObjectPtr TObjectPtrType;
typedef CConstObjectInfoEI CElementIterator;
typedef CConstObjectInfoMI CMemberIterator;
typedef CConstObjectInfoCV CChoiceVariant;
enum ENonCObject {
eNonCObject
};
/// Create empty CObjectInfo
CConstObjectInfo(void);
/// Initialize CObjectInfo
CConstObjectInfo(TConstObjectPtr objectPtr, TTypeInfo typeInfo);
CConstObjectInfo(pair<TConstObjectPtr, TTypeInfo> object);
CConstObjectInfo(pair<TObjectPtr, TTypeInfo> object);
/// Initialize CObjectInfo when we are sure that object
/// is not inherited from CObject (for efficiency)
CConstObjectInfo(TConstObjectPtr objectPtr, TTypeInfo typeInfo,
ENonCObject nonCObject);
/// Reset CObjectInfo to empty state
void Reset(void);
/// Set CObjectInfo
CConstObjectInfo& operator=(pair<TConstObjectPtr, TTypeInfo> object);
CConstObjectInfo& operator=(pair<TObjectPtr, TTypeInfo> object);
/// Check if CObjectInfo initialized with valid object
bool Valid(void) const
{
return m_ObjectPtr != 0;
}
DECLARE_OPERATOR_BOOL_PTR(m_ObjectPtr);
bool operator==(const CConstObjectInfo& obj) const
{
return m_ObjectPtr == obj.m_ObjectPtr;
}
bool operator!=(const CConstObjectInfo& obj) const
{
return m_ObjectPtr != obj.m_ObjectPtr;
}
void ResetObjectPtr(void);
/// Get pointer to object
TConstObjectPtr GetObjectPtr(void) const;
pair<TConstObjectPtr, TTypeInfo> GetPair(void) const;
// primitive type interface
bool GetPrimitiveValueBool(void) const;
char GetPrimitiveValueChar(void) const;
Int4 GetPrimitiveValueInt4(void) const;
Uint4 GetPrimitiveValueUint4(void) const;
Int8 GetPrimitiveValueInt8(void) const;
Uint8 GetPrimitiveValueUint8(void) const;
int GetPrimitiveValueInt(void) const;
unsigned GetPrimitiveValueUInt(void) const;
long GetPrimitiveValueLong(void) const;
unsigned long GetPrimitiveValueULong(void) const;
double GetPrimitiveValueDouble(void) const;
void GetPrimitiveValueString(string& value) const;
string GetPrimitiveValueString(void) const;
void GetPrimitiveValueOctetString(vector<char>& value) const;
void GetPrimitiveValueBitString(CBitString& value) const;
void GetPrimitiveValueAnyContent(CAnyContentObject& value) const;
// class interface
CMemberIterator GetMember(CObjectTypeInfo::CMemberIterator m) const;
CMemberIterator BeginMembers(void) const;
CMemberIterator GetClassMemberIterator(TMemberIndex index) const;
CMemberIterator FindClassMember(const string& memberName) const;
CMemberIterator FindClassMemberByTag(int memberTag) const;
// choice interface
TMemberIndex GetCurrentChoiceVariantIndex(void) const;
CChoiceVariant GetCurrentChoiceVariant(void) const;
// pointer interface
CConstObjectInfo GetPointedObject(void) const;
// container interface
CElementIterator BeginElements(void) const;
protected:
void Set(TConstObjectPtr objectPtr, TTypeInfo typeInfo);
private:
TConstObjectPtr m_ObjectPtr; // object pointer
CConstRef<CObject> m_Ref; // hold reference to CObject for correct removal
};
/// Facilitate read/write access to a particular instance of an object
/// of the specified type.
class NCBI_XSERIAL_EXPORT CObjectInfo : public CConstObjectInfo
{
typedef CConstObjectInfo CParent;
public:
typedef TObjectPtr TObjectPtrType;
typedef CObjectInfoEI CElementIterator;
typedef CObjectInfoMI CMemberIterator;
typedef CObjectInfoCV CChoiceVariant;
/// Create empty CObjectInfo
CObjectInfo(void);
/// Initialize CObjectInfo
CObjectInfo(TObjectPtr objectPtr, TTypeInfo typeInfo);
CObjectInfo(pair<TObjectPtr, TTypeInfo> object);
/// Initialize CObjectInfo when we are sure that object
/// is not inherited from CObject (for efficiency)
CObjectInfo(TObjectPtr objectPtr, TTypeInfo typeInfo,
ENonCObject nonCObject);
/// Create CObjectInfo with new object
explicit CObjectInfo(TTypeInfo typeInfo);
explicit CObjectInfo(const CObjectTypeInfo& type);
/// Set CObjectInfo to point to another object
CObjectInfo& operator=(pair<TObjectPtr, TTypeInfo> object);
/// Get pointer to object
TObjectPtr GetObjectPtr(void) const;
pair<TObjectPtr, TTypeInfo> GetPair(void) const;
// primitive type interface
void SetPrimitiveValueBool(bool value);
void SetPrimitiveValueChar(char value);
void SetPrimitiveValueInt4(Int4 value);
void SetPrimitiveValueUint4(Uint4 value);
void SetPrimitiveValueInt8(Int8 value);
void SetPrimitiveValueUint8(Uint8 value);
void SetPrimitiveValueInt(int value);
void SetPrimitiveValueUInt(unsigned value);
void SetPrimitiveValueLong(long value);
void SetPrimitiveValueULong(unsigned long value);
void SetPrimitiveValueDouble(double value);
void SetPrimitiveValueString(const string& value);
void SetPrimitiveValueOctetString(const vector<char>& value);
void SetPrimitiveValueBitString(const CBitString& value);
void SetPrimitiveValueAnyContent(const CAnyContentObject& value);
// class interface
CMemberIterator GetMember(CObjectTypeInfo::CMemberIterator m) const;
CMemberIterator BeginMembers(void) const;
CMemberIterator GetClassMemberIterator(TMemberIndex index) const;
CMemberIterator FindClassMember(const string& memberName) const;
CMemberIterator FindClassMemberByTag(int memberTag) const;
// create if necessary and return member object
CObjectInfo SetClassMember(TMemberIndex index) const;
// choice interface
CChoiceVariant GetCurrentChoiceVariant(void) const;
// select if necessary and return variant object
CObjectInfo SetChoiceVariant(TMemberIndex index) const;
// pointer interface
CObjectInfo GetPointedObject(void) const;
// create if necessary and return pointed object
CObjectInfo SetPointedObject(void) const;
// container interface
CElementIterator BeginElements(void) const;
void ReadContainer(CObjectIStream& in, CReadContainerElementHook& hook);
// add and return new element object
CObjectInfo AddNewElement(void) const;
// add new pointer element, create new pointed object and return it
CObjectInfo AddNewPointedElement(void) const;
};
// get starting point of object hierarchy
template<class C>
inline
TTypeInfo ObjectType(const C& /*obj*/)
{
return C::GetTypeInfo();
}
template<class C>
inline
pair<TObjectPtr, TTypeInfo> ObjectInfo(C& obj)
{
return pair<TObjectPtr, TTypeInfo>(&obj, C::GetTypeInfo());
}
// get starting point of non-modifiable object hierarchy
template<class C>
inline
pair<TConstObjectPtr, TTypeInfo> ConstObjectInfo(const C& obj)
{
return pair<TConstObjectPtr, TTypeInfo>(&obj, C::GetTypeInfo());
}
template<class C>
inline
pair<TConstObjectPtr, TTypeInfo> ObjectInfo(const C& obj)
{
return pair<TConstObjectPtr, TTypeInfo>(&obj, C::GetTypeInfo());
}
template<class C>
inline
pair<TObjectPtr, TTypeInfo> RefChoiceInfo(CRef<C>& obj)
{
return pair<TObjectPtr, TTypeInfo>(&obj, C::GetRefChoiceTypeInfo());
}
template<class C>
inline
pair<TConstObjectPtr, TTypeInfo> ConstRefChoiceInfo(const CRef<C>& obj)
{
return pair<TConstObjectPtr, TTypeInfo>(&obj, C::GetRefChoiceTypeInfo());
}
/* @} */
#include <serial/impl/objectinfo.inl>
END_NCBI_SCOPE
#endif /* OBJECTINFO__HPP */
| [
"[email protected]"
] | |
4d7219f128a342d893b2a80cbb2c5438d4a629b0 | 54f352a242a8ad6ff5516703e91da61e08d9a9e6 | /Source Codes/CodeJamData/14/33/15.cpp | 358b0ae6f801cc1d640ad29203569ac591dfb85e | [] | no_license | Kawser-nerd/CLCDSA | 5cbd8a4c3f65173e4e8e0d7ed845574c4770c3eb | aee32551795763b54acb26856ab239370cac4e75 | refs/heads/master | 2022-02-09T11:08:56.588303 | 2022-01-26T18:53:40 | 2022-01-26T18:53:40 | 211,783,197 | 23 | 9 | null | null | null | null | UTF-8 | C++ | false | false | 1,475 | cpp | #include <cstdio>
#include <algorithm>
using namespace std;
#define INF 1000000000
int n, m, k, T;
int calc1(int a, int b, int c1, int c2, int c3, int c4) {
int c = a + c1 + c2 - c3 - c4, d = b + c1 + c3 - c2 - c4;
if (c < 0 || d < 0) return -1;
if (a + c1 + c2 > m) return -1;
if (b + c1 + c3 > n) return -1;
if (a + c1 + c2 == 0) return -1;
if (b + c1 + c3 == 0) return -1;
int now = a + 1, sum = 0;
for (int i = 0; i <= c1 + b + c3; i++) {
sum += now;
if (0 <= i && i < c1) now++;
if (0 <= i && i < c2) now++;
if (c1 + b <= i && i < c1 + b + c3) now--;
if (c2 + d <= i && i < c2 + d + c4) now--;
}
return sum;
}
int calc2(int a, int b, int c1, int c2, int c3, int c4) {
int c = a + c1 + c2 - c3 - c4, d = b + c1 + c3 - c2 - c4;
return a + b + c + d + c1 + c2 + c3 + c4;
}
int main() {
freopen("C-large.in", "r", stdin);
freopen("C.out", "w", stdout);
scanf("%d", &T);
for (int Case = 1; Case <= T; Case++) {
scanf("%d%d%d", &n, &m, &k);
if (n < m) swap(n, m);
n--; m--;
int ans = k;
for (int a = 0; a <= m; a++)
for (int b = 0; b <= n; b++)
for (int c1 = 0; c1 <= m; c1++)
for (int c2 = max(0, c1 - 1); c2 <= c1 + 1; c2++)
for (int c3 = max(0, c1 - 1); c3 <= c1 + 1; c3++)
for (int c4 = max(0, c1 - 1); c4 <= c1 + 1; c4++)
if (calc1(a, b, c1, c2, c3, c4) >= k) ans = min(ans, calc2(a, b, c1, c2, c3, c4));
printf("Case #%d: %d\n", Case, ans);
}
}
| [
"[email protected]"
] | |
62946b398ae0d68ecd8fa3370a856de05e3b9437 | bf21ed931975ff7bd1ce622260caeda7e87b8162 | /thirdparty/clbool/src/coo/coo_kronecker_product.hpp | 37bb35a4911dace9bf1f6212ffd6315766402192 | [
"MIT"
] | permissive | nikitavlaev/SpBench | 5da00e853c03857952a4219e6bb4aca7f22e4e2d | 8e9d22d250c7d13e61c183ee289d57563c3a462c | refs/heads/main | 2023-04-04T05:57:06.427102 | 2021-04-19T11:14:48 | 2021-04-19T11:14:48 | 357,865,123 | 0 | 0 | MIT | 2021-04-14T10:29:46 | 2021-04-14T10:29:45 | null | UTF-8 | C++ | false | false | 255 | hpp | #pragma once
#include "../library_classes/matrix_coo.hpp"
void kronecker_product(Controls &controls,
matrix_coo &matrix_out,
const matrix_coo &matrix_a,
const matrix_coo &matrix_b
);
| [
"[email protected]"
] | |
44856ff82e39e9682eadbdfff32776f4c5290592 | 78bb158c8376185ec61cbac27e755fbcb7f0e33f | /36/copy1.cc | d3b32e2494250ade189b8bfbaedfe892cd9d5129 | [] | no_license | lchorbadjiev/teach2014-2015 | 4ba083b0e827ca388f712bfd68874b814948aa33 | 4c4cd0e0351e5c744b2fd336d92fb749fd77ed61 | refs/heads/master | 2016-09-11T04:08:03.235490 | 2015-05-12T15:52:57 | 2015-05-12T15:52:57 | 24,597,161 | 2 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 565 | cc | #include <iostream>
using namespace std;
void copy1(int dst[], int src[], int size) {
for(int i=0;i<size; ++i) {
dst[i] = src[i];
}
}
void copy1(double dst[], double src[], int size) {
for(int i=0;i<size; ++i) {
dst[i] = src[i];
}
}
int main() {
int a[] = {0,1,2,3,4,5,6,7,8,9};
int b[10];
copy1(b,a,10);
for(int i=0;i<10;++i) {
cout << b[i] << ' ';
}
cout << endl;
double c[10], d[10];
for(int i=0;i<10;++i) {
c[i] = i*3.14;
}
copy1(d, c, 10);
for(int i=0;i<10;++i) {
cout << d[i] << ' ';
}
cout << endl;
return 0;
}
| [
"[email protected]"
] | |
ba2b2f66797a772c7313ae9fef5273f2dab0ea32 | 8f506513cb73d9bdb5dbdd9084aaba020b1efbea | /Course_2-Data_Structures/Week-3/Excercise_Challenges/1_make_heap/build_heap.cpp | baa1216f22e09c22a3a3c316bcaf9eb51d1ba69b | [] | no_license | KhanAjmal007/Data-Structures-and-Algorithms-Specialization-Coursera | 1255ecf877ecd4a91bda8b85e9c96566fe6d5e4d | ab6e618c5d8077febb072091e80c16f5f1a15465 | refs/heads/master | 2023-03-21T04:18:04.580423 | 2020-07-11T07:18:06 | 2020-07-11T07:18:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,616 | cpp | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class HeapBuilder{
private:
vector<int> data_;
vector<pair<int, int> > swaps_;
void ReadData(void)
{
int n;
cin >> n;
data_.resize(n);
for(int i = 0; i < n; ++i)
cin >> data_[i];
}
int LeftChild(int index)
{
return 2 * index + 1;
}
int RightChild(int index)
{
return 2 * index + 2;
}
void ShiftDown(int index)
{
int n = data_.size();
int min_index = index;
int l = LeftChild(index);
if(l < n && data_[l] < data_[min_index])
min_index = l;
int r = RightChild(index);
if(r < n && data_[r] < data_[min_index])
min_index = r;
if(index != min_index){
swaps_.push_back(make_pair(index, min_index));
swap(data_[index], data_[min_index]);
ShiftDown(min_index);
}
}
void GenerateSwaps(void)
{
swaps_.clear();
int n = data_.size();
for(int i = n / 2; i >= 0; --i){
ShiftDown(i);
}
}
void WriteResponse(void)
{
cout << swaps_.size() << "\n";
for(int i = 0; i < swaps_.size(); ++i){
cout << swaps_[i].first << " " << swaps_[i].second << "\n";
}
}
public:
void Solve(void)
{
ReadData();
GenerateSwaps();
WriteResponse();
}
};
int main(void)
{
ios_base::sync_with_stdio(false);
HeapBuilder heap_builder;
heap_builder.Solve();
return 0;
}
| [
"[email protected]"
] | |
be30cb76a44755b2f90a5bbc1a6492f1753220e0 | 6af6cc7123c61a87a4effab57453654b02cd0aad | /Source/VRProject/CustomActor.cpp | 21293d5fc539ade6102c1ea216d22b76387cb5bd | [] | no_license | Monkscape/VRCapstoneProject | 65d096ea322c18c44030e4e415a4e83c6f681380 | 3bd07f7cd99d54c4ade84388a21aba9ac248bf1b | refs/heads/master | 2020-05-09T15:55:38.878283 | 2019-05-03T23:24:42 | 2019-05-03T23:24:42 | 181,248,637 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 701 | cpp | // Fill out your copyright notice in the Description page of Project Settings.
#include "CustomActor.h"
#include "Classes/Components/StaticMeshComponent.h"
// Sets default values
ACustomActor::ACustomActor()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
StaticMesh = CreateDefaultSubobject<UStaticMeshComponent>("StaticMeshComponent");
}
// Called when the game starts or when spawned
void ACustomActor::BeginPlay()
{
Super::BeginPlay();
StaticMesh->SetWorldScale3D(FMath::VRand());
}
// Called every frame
void ACustomActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
| [
"[email protected]"
] | |
d941dabc0e274166484601bd3bfdd8f4f34aa264 | dd24eb17296c204d9860f51f7040ae61d1e60d46 | /Source/D2/MissionActor.h | c593d2e68379ea3494596d039bbc35dba2eb3e84 | [] | no_license | RonakFabian/Destiny-2-Prototype | b6cc8597415a673f4126231496b2611028220030 | 51997efd0c07037b55b56f4990c65f18c4b24e74 | refs/heads/master | 2023-01-06T18:28:38.151373 | 2020-11-10T14:42:08 | 2020-11-10T14:42:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 644 | h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MissionActor.generated.h"
UCLASS()
class D2_API AMissionActor : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AMissionActor();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
UFUNCTION(BlueprintCallable,BlueprintImplementableEvent)
void BeginExecuteMissionEvent();
};
| [
"[email protected]"
] | |
475e0c6218da801d01c070cc6494f5451068faa3 | 647cb038a31c44adc0a6f2df82399a808502d9de | /385B.cpp | b90897a2cb369d1e164b287465362b3267598884 | [] | no_license | sankalp29/Competitve-Programming-Codes | 82f93a58be1c696328bd83fa207408d744f7ae78 | 09aa08eab0e7e4e9be6979ad5c6cc938e8a39e57 | refs/heads/master | 2020-07-24T22:12:02.823345 | 2020-02-18T13:50:23 | 2020-02-18T13:50:23 | 208,064,985 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 741 | cpp | #include<bits/stdc++.h>
typedef long long ll;
typedef double ld;
#define vll vector<ll>
#define vvll vector< vll >
#define vld vector< ld >
#define vvld vector< vld >
#define pll pair<ll ,ll >
#define nl <<endl
#define vllp vector< pll >
#define MOD 1000000007
#define endl "\n"
#define MAX 1000000007
#define f(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
int main()
{
string s;
cin>>s;
ll i=0,j=0,ans=0,l=s.length();
for(ll i = 0; i<l; ++i)
{
string s1;
if(i+3<l)
{
s1=s[i];
s1+=s[i+1];s1+=s[i+2];s1+=s[i+3];
}
if(s1=="bear")
{
ans=ans+(i-j+1)*(l-i-3);
j=i+1;
i+=3;
}
}
cout<<ans;
} | [
"[email protected]"
] | |
174dc821cf3974936ca51164c99d4182f4c33c36 | 9e6eeb8dc4703d0927d0029b3600f87e137e4e91 | /Source/Hooks/Falcom/EDAO/edao.h | 65d0a626332513cbd848df43b7c399cc5abf6b9e | [] | no_license | uvbs/Arianrhod | cef0173ca993e700331ba4abc761a4a0351effdd | 7a5fb53f89f7f362ea74cee6da5b97b4d3382f8c | refs/heads/master | 2021-01-15T14:38:02.118196 | 2014-12-18T16:05:48 | 2014-12-18T16:05:48 | 28,196,882 | 1 | 0 | null | null | null | null | GB18030 | C++ | false | false | 35,405 | h | #ifndef _EDAO_H_5c8a3013_4334_4138_9413_3d0209da878e_
#define _EDAO_H_5c8a3013_4334_4138_9413_3d0209da878e_
#define DIRECTINPUT_VERSION 0x800
#include "MyLibrary.h"
#include <GdiPlus.h>
#include <dinput.h>
#if D3D9_VER
#define NtGetTickCount (ULONG64)GetTickCount
#endif
#if 0
#undef DebugPrint
#define DebugPrint(...) { AllocConsole(); PrintConsoleW(__VA_ARGS__); PrintConsoleW(L"\n"); }
#endif
ML_OVERLOAD_NEW
class EDAO;
class CGlobal;
class CBattle;
#define INIT_STATIC_MEMBER(x) DECL_SELECTANY TYPE_OF(x) x = nullptr
#define DECL_STATIC_METHOD_POINTER(cls, method) static TYPE_OF(&cls::method) Stub##method
#define DETOUR_METHOD(cls, method, addr, ...) TYPE_OF(&cls::method) (method); *(PULONG_PTR)&(method) = addr; return (this->*method)(__VA_ARGS__)
#define MINIMUM_CUSTOM_CHAR_ID 0xB0
#define MINIMUM_CUSTOM_CRAFT_INDEX 0x3E8
#define MAXIMUM_CHR_NUMBER_IN_BATTLE 0x16
#define PSP_WIDTH_F 480.f
#define PSP_HEIGHT_F 272.f
#pragma pack(push, 1)
typedef struct
{
ULONG Magic;
ULONG CompressedSize;
} UCL_COMPRESS_HEADER;
ML_NAMESPACE_BEGIN(CraftConditions)
static const ULONG_PTR Poison = 0x00000001;
static const ULONG_PTR Frozen = 0x00000002;
static const ULONG_PTR Landification = 0x00000004;
static const ULONG_PTR Sleeping = 0x00000008;
static const ULONG_PTR BanArts = 0x00000010;
static const ULONG_PTR Darkness = 0x00000020;
static const ULONG_PTR BanCraft = 0x00000040;
static const ULONG_PTR Confusion = 0x00000080;
static const ULONG_PTR Stun = 0x00000100;
static const ULONG_PTR OnehitKill = 0x00000200;
static const ULONG_PTR Burning = 0x00000400;
static const ULONG_PTR Rage = 0x00000800;
static const ULONG_PTR ArtsGuard = 0x00001000;
static const ULONG_PTR CraftGuard = 0x00002000;
static const ULONG_PTR MaxGuard = 0x00004000;
static const ULONG_PTR Vanish = 0x00008000;
static const ULONG_PTR StrUp = 0x00010000;
static const ULONG_PTR DefUp = 0x00020000;
static const ULONG_PTR AtsUp = 0x00040000;
static const ULONG_PTR AdfUp = 0x00080000;
static const ULONG_PTR DexUp = 0x00100000;
static const ULONG_PTR AglUp = 0x00200000;
static const ULONG_PTR MovUp = 0x00400000;
static const ULONG_PTR SpdUp = 0x00800000;
static const ULONG_PTR HPRecovery = 0x01000000;
static const ULONG_PTR CPRecovery = 0x02000000;
static const ULONG_PTR Stealth = 0x04000000;
static const ULONG_PTR ArtsReflect = 0x08000000;
static const ULONG_PTR Boost = 0x10000000;
static const ULONG_PTR CraftReflect = 0x20000000;
static const ULONG_PTR Reserve_2 = 0x20000000;
static const ULONG_PTR GreenPepper = 0x40000000;
static const ULONG_PTR Dead = 0x80000000;
ML_NAMESPACE_END
typedef struct // 0x18
{
BYTE Condition;
BYTE Probability;
BYTE Target;
BYTE TargetCondition;
BYTE AriaActionIndex;
BYTE ActionIndex;
USHORT CraftIndex;
ULONG Parameter[4];
} CRAFT_AI_INFO, *PCRAFT_AI_INFO;
ML_NAMESPACE_BEGIN(CraftInfoTargets)
enum
{
OtherSide = 0x10,
SelfSide = 0x80,
};
ML_NAMESPACE_END
typedef struct
{
USHORT ActionIndex;
BYTE Target;
BYTE Unknown_3;
BYTE Attribute;
BYTE RangeType;
BYTE State1;
BYTE State2;
BYTE RNG;
BYTE RangeSize;
BYTE AriaTime;
BYTE SkillTime;
USHORT EP_CP;
USHORT RangeSize2;
USHORT State1Parameter;
USHORT State1Time;
USHORT State2Parameter;
USHORT State2Time;
DUMMY_STRUCT(4);
} CRAFT_INFO, *PCRAFT_INFO;
typedef struct
{
CHAR Description[0x100];
CHAR Name[0x20];
} CRAFT_DESCRIPTION;
enum
{
ACTION_ATTACK = 0,
ACTION_MOVE = 1,
ACTION_ARTS = 2,
ACTION_CRAFT = 3,
ACTION_SCRAFT = 4,
ACTION_ITEM = 5,
ACTION_ARIA_ARTS = 6,
ACTION_CAST_ARTS = 7,
ACTION_ARIA_CRAFT = 8,
ACTION_CAST_CRAFT = 9,
};
enum
{
BattleStatusRaw,
BattleStatusFinal,
};
typedef union
{
DUMMY_STRUCT(0x34);
struct
{
ULONG MaximumHP; // 0x234
ULONG InitialHP; // 0x238
USHORT Level; // 0x23C
USHORT MaximumEP; // 0x23E
USHORT InitialEP; // 0x240
USHORT InitialCP; // 0x242
USHORT EXP; // 0x244
DUMMY_STRUCT(2);
SHORT STR; // 0x248
SHORT DEF; // 0x24A
SHORT ATS; // 0x24C
SHORT ADF; // 0x24E
SHORT DEX; // 0x250
SHORT AGL; // 0x252
SHORT MOV; // 0x254
SHORT SPD; // 0x256
SHORT DEXRate; // 0x258
SHORT AGLRate; // 0x25A
USHORT MaximumCP; // 0x25C
DUMMY_STRUCT(2); // 0x25E
SHORT RNG; // 0x260
DUMMY_STRUCT(2);
ULONG ConditionFlags; // 0x264
};
} CHAR_STATUS, *PCHAR_STATUS;
typedef struct
{
ULONG ConditionFlags;
PVOID Effect;
BYTE CounterType;
BYTE Flags;
SHORT ConditionRate;
LONG ATLeft;
LONG Unknown4;
enum CounterTypes
{
ByRounds = 1,
ByTimes = 2,
ByActions = 3,
Infinite = 4,
};
} MS_EFFECT_INFO, *PMS_EFFECT_INFO;
enum
{
CHR_FLAG_ENEMY = 0x1000,
CHR_FLAG_NPC = 0x2000,
CHR_FLAG_PARTY = 0x4000,
CHR_FLAG_EMPTY = 0x8000,
};
typedef union MONSTER_STATUS
{
DUMMY_STRUCT(0x2424);
BOOL IsChrEnemy(BOOL CheckAIType = TRUE)
{
if (CheckAIType && AiType == 0xFF)
return FALSE;
return FLAG_OFF(State, CHR_FLAG_NPC | CHR_FLAG_PARTY | CHR_FLAG_EMPTY);
}
BOOL IsChrCanThinkSCraft(BOOL CheckAiType = FALSE)
{
if (!IsChrEnemy())
return FALSE;
if (AiType == 0xFF)
return FALSE;
if (!CheckAiType)
return TRUE;
switch (AiType)
{
case 0x00:
case 0x02:
case 0x1F:
return TRUE;
}
return FALSE;
}
struct
{
USHORT CharPosition; // 0x00
USHORT State; // 0x02
USHORT State2; // 0x04
DUMMY_STRUCT(4); // 0x06
USHORT CharID; // 0x0A
DUMMY_STRUCT(4); // 0x0C
ULONG SymbolIndex; // 0x10
ULONG MSFileIndex; // 0x14
DUMMY_STRUCT(0x16C - 0x18);
USHORT CurrentActionType; // 0x16C
DUMMY_STRUCT(2);
USHORT PreviousActionType; // 0x170
USHORT SelectedActionType; // 0x172
USHORT Unknown_174;
USHORT Unknown_176;
USHORT Unknown_178;
USHORT Unknown_17A;
USHORT WhoAttackMe; // 0x17C
USHORT CurrentCraftIndex; // 0x17E
USHORT LastActionIndex; // 0x180
USHORT CurrentAiIndex; // 0x182
DUMMY_STRUCT(0x1AA - 0x184);
USHORT Target[0x10]; // 0x1AA
BYTE TargetCount; // 0x1CA
BYTE SelectedTargetIndex; // 0x1CB
COORD SelectedTargetPos; // 0x1CC
DUMMY_STRUCT(0x234 - 0x1D0);
CHAR_STATUS ChrStatus[2]; // 0x234
// 0x268
USHORT MoveSPD; // 0x29C
DUMMY_STRUCT(2);
MS_EFFECT_INFO EffectInfo[32]; // 0x2A0
DUMMY_STRUCT(0x538 - (0x2A0 + sizeof(MS_EFFECT_INFO) * 32));
ULONG AT; // 0x538
ULONG AT2; // 0x53C
USHORT AiType; // 0x540
USHORT EXPGet; // 0x542
USHORT DropItem[2]; // 0x544
BYTE DropRate[2]; // 0x548
DUMMY_STRUCT(2);
USHORT Equipment[5]; // 0x54C
USHORT Orbment[7]; // 0x556
CRAFT_AI_INFO Attack; // 0x564
CRAFT_AI_INFO ArtsAiInfo[80]; // 0x57C
CRAFT_AI_INFO CraftAiInfo[15]; // 0xCFC
CRAFT_AI_INFO SCraftAiInfo[5]; // 0xE64
CRAFT_AI_INFO SupportAiInfo[3]; // 0xEDC
struct
{
USHORT CraftIndex; // 0xF24
BYTE AriaActionIndex; // 0xF26
BYTE ActionIndex; // 0xF27
} SelectedCraft;
DUMMY_STRUCT(4); // 0xF28
CRAFT_INFO CraftInfo[16]; // 0xF2C
CRAFT_DESCRIPTION CraftDescription[10]; // 0x10EC
DUMMY_STRUCT(0x2408 - 0x10EC - sizeof(CRAFT_DESCRIPTION) * 10);
ULONG SummonCount; // 0x2408
};
} MONSTER_STATUS, *PMONSTER_STATUS;
#pragma pack(pop)
class CSSaveData
{
public:
VOID SaveData2SystemData();
VOID SystemData2SaveData();
public:
PUSHORT GetPartyChipMap()
{
return (PUSHORT)PtrAdd(this, 0x6140);
}
PUSHORT GetPartyList()
{
return (PUSHORT)PtrAdd(this, 0x2CC);
}
PUSHORT GetPartyListSaved()
{
return (PUSHORT)PtrAdd(this, 0x2DC);
}
BOOL IsCustomChar(ULONG_PTR ChrId)
{
return ChrId >= 0xC ? FALSE : GetPartyChipMap()[ChrId] >= MINIMUM_CUSTOM_CHAR_ID;
}
PUSHORT GetChrMagicList()
{
return (PUSHORT)PtrAdd(this, 0x5D4);
}
PBYTE GetScenaFlags()
{
return (PBYTE)PtrAdd(this, 0x9C);
}
BOOL IsYinRixia()
{
return FLAG_ON(GetScenaFlags()[0x165], 1 << 5);
}
BOOL IsLazyKnight()
{
return FLAG_ON(GetScenaFlags()[0x1A0], 1);
}
ULONG FASTCALL GetTeamAttackMemberId(ULONG ChrId);
};
typedef union
{
ULONG Flags;
struct
{
UCHAR HP : 1; // 0x00000001
UCHAR Level : 1; // 0x00000002
UCHAR EXP : 1; // 0x00000004
UCHAR Information : 1;
UCHAR Resist : 1; // 0x00000020
UCHAR AttributeRate : 1; // 0x00000040
// 0x10000000 orb
};
BOOL AllValid()
{
ULONG AllFlags = 0x01 | 0x02 | 0x04 | 0x20 | 0x40;
return (Flags & AllFlags) == AllFlags;
}
BOOL IsShowByOrbment()
{
return FLAG_ON(Flags, 0x10000000);
}
} MONSTER_INFO_FLAGS, *PMONSTER_INFO_FLAGS;
enum
{
COLOR_WHITE = 0,
COLOR_ORANGE = 1,
COLOR_RED = 2,
COLOR_BLUE = 3,
COLOR_YELLOW = 4,
COLOR_GREEN = 5,
COLOR_GRAY = 6,
COLOR_PINK = 7,
COLOR_GOLD = 8,
COLOR_BLACK = 9,
COLOR_YELLOWB = 10,
COLOR_MAXIMUM = 21,
};
class CBattleInfoBox
{
public:
EDAO* GetEDAO()
{
return *(EDAO **)PtrAdd(this, 0xC);
}
CBattle* GetBattle()
{
return (CBattle *)PtrSub(this, 0xF0D24);
}
PCOORD GetUpperLeftCoord()
{
return (PCOORD)PtrAdd(*(PULONG_PTR)PtrAdd(this, 0x20), 0xF2);
}
ULONG_PTR GetBackgroundColor()
{
return *(PULONG)PtrAdd(*(PULONG_PTR)PtrAdd(this, 0x20), 0x100);
}
VOID SetTargetIsEnemy(BOOL Is)
{
*(PULONG)PtrAdd(*(PULONG_PTR)PtrAdd(this, 0x20), 0xEC) = Is ? 0 : 1;
}
ULONG_PTR IsTargetEnemy()
{
return *(PULONG)PtrAdd(*(PULONG_PTR)PtrAdd(this, 0x20), 0xEC) != 1;
}
VOID SetMonsterInfoFlags(ULONG_PTR Flags)
{
*(PULONG_PTR)PtrAdd(this, 0x1028) = Flags;
}
MONSTER_INFO_FLAGS GetMonsterInfoFlags()
{
return *(PMONSTER_INFO_FLAGS)PtrAdd(this, 0x1028);
}
NoInline VOID DrawSimpleText(LONG X, LONG Y, PCSTR Text, ULONG ColorIndex, LONG Weight = FW_NORMAL, ULONG ZeroU1 = 1, FLOAT ZeroF1 = 1)
{
TYPE_OF(&CBattleInfoBox::DrawSimpleText) StubDrawSimpleText;
*(PVOID *)&StubDrawSimpleText = (PVOID)0x67A101;
return (this->*StubDrawSimpleText)(X, Y, Text, ColorIndex, Weight, ZeroU1, ZeroF1);
}
public:
VOID THISCALL SetMonsterInfoBoxSize(LONG X, LONG Y, LONG Width, LONG Height);
VOID THISCALL DrawMonsterStatus();
DECL_STATIC_METHOD_POINTER(CBattleInfoBox, DrawMonsterStatus);
};
INIT_STATIC_MEMBER(CBattleInfoBox::StubDrawMonsterStatus);
typedef union
{
DUMMY_STRUCT(0x78);
struct
{
DUMMY_STRUCT(0x60);
PMONSTER_STATUS MSData; // 0x60
DUMMY_STRUCT(4);
ULONG IconAT; // 0x68 不含20 空; 含10 AT条移动; 含04 行动、delay后的([20A]0销毁); 含40 当前行动的(1销毁)
USHORT Flags; // 0x6C
DUMMY_STRUCT(3);
BYTE RNo; // 0x71
DUMMY_STRUCT(1);
BYTE sequence; // 0x73
BOOLEAN IsSBreaking;
DUMMY_STRUCT(3);
};
} AT_BAR_ENTRY, *PAT_BAR_ENTRY;
class CBattleATBar
{
public:
AT_BAR_ENTRY Entry[0x3C];
PAT_BAR_ENTRY EntryPointer[0x3C]; // 0x1C20
BOOL IsCurrentChrSBreak()
{
return EntryPointer[0]->IsSBreaking;
}
// -1 for null
BYTE THISCALL GetChrAT0()
{
TYPE_OF(&CBattleATBar::GetChrAT0) f;
*(PVOID *)&f = (PVOID)0x00677230;
return (this->*f)();
}
VOID AdvanceChrInATBar(PMONSTER_STATUS MSData, BOOL InsertToFirstPos)
{
TYPE_OF(&CBattleATBar::AdvanceChrInATBar) AdvanceChrInATBar;
*(PVOID *)&AdvanceChrInATBar = (PVOID)0x676D3F;
return (this->*AdvanceChrInATBar)(MSData, InsertToFirstPos);
}
NoInline PAT_BAR_ENTRY FindATBarEntry(PMONSTER_STATUS MSData)
{
PAT_BAR_ENTRY *Entry;
FOR_EACH(Entry, EntryPointer, countof(EntryPointer))
{
if (Entry[0]->MSData == MSData)
return Entry[0];
}
return nullptr;
}
PAT_BAR_ENTRY THISCALL LookupReplaceAtBarEntry(PMONSTER_STATUS MSData, BOOL IsFirst);
};
ML_NAMESPACE_BEGIN(ArtsPage)
enum ArtsPageType
{
Attack = 0,
Recovery = 1,
Debuff = 2,
Auxiliary = 3,
Master = 4,
};
ML_NAMESPACE_END
class CArtsNameWindow
{
public:
READONLY_PROPERTY(ULONG_PTR, SelectedArtsIndex)
{
return *(PULONG)PtrAdd(this, 0xBC);
}
READONLY_PROPERTY(ArtsPage::ArtsPageType, ArtsType)
{
return (ArtsPage::ArtsPageType)*(PULONG)PtrAdd(this, 0xDC);
}
};
class CBattle
{
public:
VOID THISCALL SetSelectedAttack(PMONSTER_STATUS MSData);
VOID THISCALL SetSelectedMagic(PMONSTER_STATUS MSData, USHORT CraftIndex, USHORT CurrentCraftIndex);
VOID THISCALL SetSelectedCraft(PMONSTER_STATUS MSData, USHORT CraftIndex, USHORT AiIndex);
VOID THISCALL SetSelectedSCraft(PMONSTER_STATUS MSData, USHORT CraftIndex, USHORT AiIndex);
CSSaveData* GetSaveData()
{
return *(CSSaveData **)PtrAdd(this, 0x38D28);
}
READONLY_PROPERTY(CArtsNameWindow*, ArtsNameWindow)
{
return *(CArtsNameWindow **)PtrAdd(this, 0xFF59C);
}
CBattleInfoBox* GetBattleInfoBox()
{
return (CBattleInfoBox *)PtrAdd(this, 0xF0D24);
}
EDAO* GetEDAO()
{
return *(EDAO **)PtrAdd(this, 0x38D24);
}
CBattleATBar* GetBattleATBar()
{
return (CBattleATBar *)PtrAdd(this, 0x103148);
}
BOOL IsCustomChar(ULONG_PTR ChrId)
{
return GetSaveData()->IsCustomChar(ChrId);
}
BOOL IsForceInsertToFirst()
{
return *(PBOOL)PtrAdd(this, 0x3A7B0);
}
PVOID GetMSFileBuffer()
{
return PtrAdd(this, 0x114ED0);
}
PMONSTER_STATUS GetMonsterStatus()
{
return (PMONSTER_STATUS)PtrAdd(this, 0x4DE4);
}
LONG_PTR GetCurrentChrIndex()
{
return *(PLONG)PtrAdd(this, 0x113080);
}
LONG_PTR GetCurrentTargetIndex()
{
return *(PLONG)PtrAdd(this, 0x113090);
}
VOID ShowConditionText(PMONSTER_STATUS MSData, PCSTR Text, ULONG Color = RGBA(255, 136, 0, 255), ULONG Unknown = 0)
{
TYPE_OF(&CBattle::ShowConditionText) ShowConditionText;
*(PULONG_PTR)&ShowConditionText = 0xA17420;
return (this->*ShowConditionText)(MSData, Text, Color, Unknown);
}
PMS_EFFECT_INFO THISCALL FindEffectInfoByCondition(PMONSTER_STATUS MSData, ULONG_PTR Condition, ULONG_PTR TimeLeft = 0)
{
TYPE_OF(&CBattle::FindEffectInfoByCondition) FindEffectInfoByCondition;
*(PULONG_PTR)&FindEffectInfoByCondition = 0x9E34A0;
return (this->*FindEffectInfoByCondition)(MSData, Condition, TimeLeft);
}
VOID THISCALL ShowSkipAnimeButton()
{
DETOUR_METHOD(CBattle, ShowSkipAnimeButton, 0x673513);
}
VOID THISCALL CancelAria(PMONSTER_STATUS MSData, BOOL Reset)
{
DETOUR_METHOD(CBattle, CancelAria, 0x99DDC0, MSData, Reset);
}
VOID THISCALL UpdateHP(PMONSTER_STATUS MSData, LONG Increment, LONG Initial, BOOL What = TRUE)
{
TYPE_OF(&CBattle::UpdateHP) UpdateHP;
*(PULONG_PTR)&UpdateHP = 0x9ED1F0;
return (this->*UpdateHP)(MSData, Increment, Initial, What);
}
VOID THISCALL UpdateEffectLeftTime(PMONSTER_STATUS MSData, LONG LeftTime, BYTE CounterType, ULONG ConditionFlag)
{
DETOUR_METHOD(CBattle, UpdateEffectLeftTime, 0x9E3570, MSData, LeftTime, CounterType, ConditionFlag);
}
/************************************************************************
bug fix
************************************************************************/
VOID
THISCALL
ExecuteActionScript(
PMONSTER_STATUS MSData,
PBYTE ActionScript,
BYTE ChrThreadId,
USHORT ScriptOffset,
ULONG Unknown1,
ULONG Unknown2,
ULONG Unknown3
);
/************************************************************************
tweak
************************************************************************/
VOID NakedNoResistConditionUp();
static LONG CDECL FormatBattleChrAT(PSTR Buffer, PCSTR Format, LONG Index, LONG No, LONG IcoAT, LONG ObjAT, LONG Pri);
static LONG CDECL ShowSkipCraftAnimeButton(...);
/************************************************************************
hack for use enemy
************************************************************************/
PMONSTER_STATUS FASTCALL OverWriteBattleStatusWithChrStatus(PMONSTER_STATUS MSData, PCHAR_STATUS ChrStatus);
VOID NakedOverWriteBattleStatusWithChrStatus();
VOID NakedIsChrStatusNeedRefresh();
BOOL FASTCALL IsChrStatusNeedRefresh(ULONG_PTR ChrPosition, PCHAR_STATUS CurrentStatus, LONG_PTR PrevLevel);
ULONG NakedGetChrIdForSCraft();
VOID NakedGetTurnVoiceChrId();
VOID NakedGetReplySupportVoiceChrId();
VOID NakedGetRunawayVoiceChrId();
VOID NakedGetTeamRushVoiceChrId();
VOID NakedGetUnderAttackVoiceChrId();
VOID NakedGetUnderAttackVoiceChrId2();
VOID NakedGetSBreakVoiceChrId();
ULONG FASTCALL GetVoiceChrIdWorker(PMONSTER_STATUS MSData);
VOID NakedCopyMagicAndCraftData();
VOID FASTCALL CopyMagicAndCraftData(PMONSTER_STATUS MSData);
VOID NakedFindReplaceChr();
VOID NakedCheckCraftTargetBits();
VOID THISCALL GetConditionIconPosByIndex(Gdiplus::PointF *Position, PMS_EFFECT_INFO EffectInfo, ULONG_PTR ConditionIndex);
BOOL THISCALL IsTargetCraftReflect(PMONSTER_STATUS Self, PMONSTER_STATUS Target, ULONG_PTR ActionType = 0xFFFF);
VOID THISCALL OnSetChrConditionFlag(PMONSTER_STATUS MSData, ULONG Param2, ULONG ConditionFlag, USHORT Param4, USHORT Param5);
BOOL FASTCALL UpdateCraftReflectLeftTime(BOOL CanNotReflect, PMONSTER_STATUS MSData);
VOID NakedUpdateCraftReflectLeftTime();
typedef struct
{
BYTE OpCode;
BYTE Function;
union
{
ULONG Param[4];
};
} AS_8D_PARAM, *PAS_8D_PARAM;
enum
{
AS_8D_FUNCTION_MINIMUM = 0x70,
AS_8D_FUNCTION_REI_JI_MAI_GO = AS_8D_FUNCTION_MINIMUM,
};
VOID NakedAS8DDispatcher();
VOID FASTCALL AS8DDispatcher(PMONSTER_STATUS MSData, PAS_8D_PARAM ASBuffer);
/************************************************************************
enemy sbreak
************************************************************************/
#define THINK_SBREAK_FILTER TAG4('THSB')
VOID NakedGetBattleState();
VOID FASTCALL HandleBattleState(ULONG_PTR CurrentState);
VOID THISCALL SetCurrentActionChrInfo(USHORT Type, PMONSTER_STATUS MSData);
LONG NakedEnemyThinkAction();
BOOL FASTCALL EnemyThinkAction(PMONSTER_STATUS MSData);
BOOL THISCALL ThinkRunaway(PMONSTER_STATUS MSData);
BOOL THISCALL ThinkSCraft(PMONSTER_STATUS MSData);
BOOL ThinkSBreak(PMONSTER_STATUS MSData, PAT_BAR_ENTRY Entry);
/************************************************************************
acgn beg
************************************************************************/
VOID THISCALL LoadMSFile(PMONSTER_STATUS MSData, ULONG MSFileIndex);
VOID THISCALL LoadMonsterIt3(ULONG CharPosition, ULONG par2, PSTR it3Path);
VOID NakedAS_8D_5F();
VOID THISCALL AS_8D_5F(PMONSTER_STATUS);
VOID THISCALL UnsetCondition(PMONSTER_STATUS MSData, ULONG condition)
{
TYPE_OF(&CBattle::UnsetCondition) f;
*(PVOID *)&f = (PVOID)0x672AE1;
return (this->*f)(MSData, condition);
}
VOID THISCALL SetCondition(PMONSTER_STATUS MSData, ULONG par2, ULONG condition, ULONG par4, ULONG par5)
{
TYPE_OF(&CBattle::SetCondition) f;
*(PVOID *)&f = (PVOID)0x676EA2;
return (this->*f)(MSData, par2, condition, par4, par5);
}
BOOL CheckCondition(PMONSTER_STATUS MSData, ULONG condition, ULONG par3=0)
{
return FindEffectInfoByCondition(MSData, condition, par3) != nullptr;
}
DECL_STATIC_METHOD_POINTER(CBattle, LoadMSFile);
/************************************************************************
acgn end
************************************************************************/
DECL_STATIC_METHOD_POINTER(CBattle, SetCurrentActionChrInfo);
DECL_STATIC_METHOD_POINTER(CBattle, ThinkRunaway);
DECL_STATIC_METHOD_POINTER(CBattle, ThinkSCraft);
DECL_STATIC_METHOD_POINTER(CBattle, ExecuteActionScript);
DECL_STATIC_METHOD_POINTER(CBattle, IsTargetCraftReflect);
DECL_STATIC_METHOD_POINTER(CBattle, OnSetChrConditionFlag);
};
INIT_STATIC_MEMBER(CBattle::StubSetCurrentActionChrInfo);
INIT_STATIC_MEMBER(CBattle::StubThinkRunaway);
INIT_STATIC_MEMBER(CBattle::StubThinkSCraft);
INIT_STATIC_MEMBER(CBattle::StubLoadMSFile);
INIT_STATIC_MEMBER(CBattle::StubExecuteActionScript);
INIT_STATIC_MEMBER(CBattle::StubIsTargetCraftReflect);
INIT_STATIC_MEMBER(CBattle::StubOnSetChrConditionFlag);
class CSound
{
public:
VOID THISCALL PlaySound(ULONG SeIndex, ULONG v1 = 1, ULONG v2 = 0, ULONG v3 = 100, ULONG v4 = 0, ULONG v5 = 35, ULONG v6 = 0)
{
TYPE_OF(&CSound::PlaySound) PlaySound;
*(PVOID *)&PlaySound = (PVOID)0x677271;
return (this->*PlaySound)(SeIndex, v1, v2, v3, v4, v5, v6);
}
};
typedef struct
{
DUMMY_STRUCT(0x30);
FLOAT Vertical; // 0x30
FLOAT Obliquity; // 0x34
FLOAT Horizon; // 0x38
DUMMY_STRUCT(0x54 - 0x38 - sizeof(FLOAT));
FLOAT Distance; // 0x54
} CAMERA_INFO, *PCAMERA_INFO;
class CCamera
{
public:
PCAMERA_INFO GetCameraInfo()
{
return (PCAMERA_INFO)*(PVOID *)PtrAdd(this, 0xB88);
}
};
typedef struct
{
USHORT State;
BYTE ScenaIndex;
DUMMY_STRUCT(1);
ULONG FunctionOffset;
ULONG CurrentOffset;
} *PSCENA_ENV_BLOCK;
class CScript
{
public:
EDAO* GetEDAO()
{
return (EDAO *)PtrSub(this, 0x384EC);
}
CCamera* GetCamera()
{
return *(CCamera **)PtrAdd(this, 0x524);
}
CSSaveData* GetSaveData()
{
return *(CSSaveData **)this;
}
PBYTE* GetScenaTable()
{
return (PBYTE *)PtrAdd(this, 0x7D4);
}
BOOL THISCALL ScpSaveRestoreParty(PSCENA_ENV_BLOCK Block);
VOID FASTCALL InheritSaveData(PBYTE ScenarioFlags);
VOID NakedInheritSaveData();
DECL_STATIC_METHOD_POINTER(CScript, InheritSaveData);
DECL_STATIC_METHOD_POINTER(CScript, ScpSaveRestoreParty);
};
INIT_STATIC_MEMBER(CScript::StubInheritSaveData);
INIT_STATIC_MEMBER(CScript::StubScpSaveRestoreParty);
class CMap
{
public:
PULONG GetFrameNumber()
{
return (PULONG)PtrAdd(this, 0x1C7C);
}
};
class CInput
{
public:
BOOL UseJoyStick()
{
return *(PBOOL)this;
}
LPDIRECTINPUTDEVICE8A GetDInputDevice()
{
return *(LPDIRECTINPUTDEVICE8A *)PtrAdd(this, 0x218);
}
VOID THISCALL HandleMainInterfaceInputState(PVOID Parameter1, CInput *Input, PVOID Parameter3);
DECL_STATIC_METHOD_POINTER(CInput, HandleMainInterfaceInputState);
};
INIT_STATIC_MEMBER(CInput::StubHandleMainInterfaceInputState);
class EDAO
{
// battle
public:
static EDAO* GlobalGetEDAO()
{
return *(EDAO **)0xC29988;
}
static VOID JumpToMap()
{
return ((TYPE_OF(&EDAO::JumpToMap))0x6A0DF0)();
}
CMap* GetMap()
{
return (CMap *)PtrAdd(this, 0x141C);
}
CGlobal* GetGlobal()
{
return (CGlobal *)PtrAdd(this, 0x4D3E8);
}
CBattle* GetBattle()
{
return *(CBattle **)PtrAdd(this, 0x82BA4);
}
CSound* GetSound()
{
return (CSound *)PtrAdd(this, 0x3A628);
}
CScript* GetScript()
{
return (CScript *)PtrAdd(this, 0x384EC);
}
CSSaveData* GetSaveData()
{
return GetScript()->GetSaveData();
}
BOOL IsCustomChar(ULONG_PTR ChrId)
{
return GetSaveData()->IsCustomChar(ChrId);
}
PUSHORT GetSBreakList()
{
return (PUSHORT)PtrAdd(this, 0x7EE10);
}
PFLOAT GetChrCoord()
{
return (PFLOAT)(*(PULONG_PTR)PtrAdd(EDAO::GlobalGetEDAO(), 0x78CB8 + 0x2BC));
}
VOID UpdateChrCoord(PVOID Parameter)
{
DETOUR_METHOD(EDAO, UpdateChrCoord, 0x74F490, Parameter);
}
ULONG_PTR GetLayer()
{
return *(PUSHORT)PtrAdd(this, 0xA6FA8);
}
PSIZE GetWindowSize()
{
return (PSIZE)PtrAdd(this, 0x3084);
}
VOID LoadFieldAttackData(ULONG_PTR Dummy = 0)
{
TYPE_OF(&EDAO::LoadFieldAttackData) LoadFieldAttackData;
*(PULONG_PTR)&LoadFieldAttackData = 0x6F8D30;
return (this->*LoadFieldAttackData)(Dummy);
}
LONG THISCALL AoMessageBox(PCSTR Text, BOOL CanUseCancelButton = TRUE)
{
typedef struct
{
PVOID Callbacks[4];
} MSGBOX_CALLBACK;
LONG (FASTCALL *AoMessageBoxWorker)(EDAO*, PVOID, BOOL CanUseCancelButton, PCSTR Text, MSGBOX_CALLBACK, ULONG, ULONG, ULONG);
MSGBOX_CALLBACK cb = { (PVOID)0x676056, nullptr, nullptr, nullptr };
*(PULONG_PTR)&AoMessageBoxWorker = 0x67A4D5;
return AoMessageBoxWorker(this, 0, CanUseCancelButton, Text, cb, 0, 0, -1);
}
VOID StubDrawNumber(LONG X, LONG Y, PCSTR Text, ULONG OneU1, ULONG Color, ULONG ZeroU1);
NoInline VOID DrawNumber(LONG X, LONG Y, PCSTR Text, ULONG_PTR Color, ULONG OneU1 = 1, ULONG ZeroU1 = 0)
{
TYPE_OF(&EDAO::StubDrawNumber) StubDrawNumber;
*(PVOID *)&StubDrawNumber = (PVOID)0x734A00;
return (this->*StubDrawNumber)(X, Y, Text, OneU1, Color, ZeroU1);
}
VOID DrawText(PCSTR Text, LONG X, LONG Y, LONG FontSize, BYTE Red, BYTE Green, BYTE Blue)
{
DETOUR_METHOD(EDAO, DrawText, 0x87D710, Text, X, Y, FontSize, Red, Green, Blue);
}
VOID THISCALL StubDrawRectangle(USHORT Layer, LONG Left, LONG Top, LONG Right, LONG Bottom, FLOAT ZeroF1, FLOAT ZeroF2, FLOAT ZeroF3, FLOAT ZeroF4, ULONG UpperLeftColor, ULONG UpperRightColor, ULONG ZeroU1,ULONG ZeroU2,ULONG ZeroU3,ULONG ZeroU4,ULONG ZeroU5,ULONG ZeroU6,FLOAT ZeroF5);
NoInline
VOID
THISCALL
DrawRectangle(
/* USHORT Layer */
LONG Left,
LONG Top,
LONG Right,
LONG Bottom,
ULONG UpperLeftColor,
ULONG UpperRightColor,
FLOAT ZeroF1 = 0,
FLOAT ZeroF2 = 0,
FLOAT ZeroF3 = 0,
FLOAT ZeroF4 = 0,
ULONG ZeroU1 = 0,
ULONG ZeroU2 = 0,
ULONG ZeroU3 = 0,
ULONG ZeroU4 = 0,
ULONG ZeroU5 = 0,
ULONG ZeroU6 = 0,
FLOAT ZeroF5 = 0
)
{
TYPE_OF(&EDAO::StubDrawRectangle) StubDrawRectangle;
*(PVOID *)&StubDrawRectangle = (PVOID)0x6726EA;
return (PtrAdd(this, 0x254)->*StubDrawRectangle)(
GetLayer(),
Left,
Top,
Right,
Bottom,
ZeroF1,
ZeroF2,
ZeroF3,
ZeroF4,
UpperLeftColor,
UpperRightColor,
ZeroU1,
ZeroU2,
ZeroU3,
ZeroU4,
ZeroU5,
ZeroU6,
ZeroF5
);
}
VOID CalcChrRawStatusFromLevel(ULONG ChrId, ULONG Level, ULONG Unknown = 0)
{
TYPE_OF(&EDAO::CalcChrRawStatusFromLevel) f;
*(PVOID *)&f = (PVOID)0x675FF7;
return (this->*f)(ChrId, Level, Unknown);
}
ArtsPage::ArtsPageType THISCALL GetCraftType(PCRAFT_INFO StateCraftInfo, PCRAFT_INFO EPCPCraftInfo = nullptr)
{
DETOUR_METHOD(EDAO, GetCraftType, 0x97F100, StateCraftInfo, EPCPCraftInfo);
}
/************************************************************************
hack for boss
************************************************************************/
VOID NakedGetChrSBreak();
VOID FASTCALL GetChrSBreak(PMONSTER_STATUS MSData);
LONG FASTCALL GetStatusIcon(ULONG ChrId);
LONG FASTCALL GetCFace(ULONG ChrId);
LONG FASTCALL GetLeaderChangeVoice(ULONG ChrId);
static LONG CDECL GetCampImage(PSTR Buffer, PCSTR Format, LONG ChrId);
static LONG CDECL GetBattleFace(PSTR Buffer, PCSTR Format, PCSTR DataPath, LONG ChrId);
static LONG CDECL GetFieldAttackChr(PSTR Buffer, PCSTR Format, LONG ChrId);
/************************************************************************
tweak
************************************************************************/
static VOID NakedLoadSaveDataThumb();
static VOID NakedSetSaveDataScrollStep();
// hook
public:
VOID THISCALL Fade(ULONG Param1, ULONG Param2, ULONG Param3, ULONG Param4, ULONG Param5, ULONG Param6);
BOOL THISCALL CheckItemEquipped(ULONG ItemId, PULONG EquippedIndex);
DECL_STATIC_METHOD_POINTER(EDAO, CheckItemEquipped);
};
DECL_SELECTANY TYPE_OF(EDAO::StubCheckItemEquipped) EDAO::StubCheckItemEquipped = nullptr;
class CCoordConverter
{
public:
VOID MapPSPCoordToPC(Gdiplus::PointF Source[2], Gdiplus::PointF Target[2], PFLOAT Transform = nullptr)
{
DETOUR_METHOD(CCoordConverter, MapPSPCoordToPC, 0x6A7030, Source, Target, Transform);
}
};
class CMiniGame
{
public:
static VOID FASTCALL HorrorHouse_GetMonsterPosition(CCoordConverter *Converter, PVOID, Gdiplus::PointF *PSPCoord, Gdiplus::PointF *PCCoord, PFLOAT Transform)
{
EDAO *edao = EDAO::GlobalGetEDAO();
Converter->MapPSPCoordToPC(PSPCoord, PCCoord, Transform);
PCCoord->X *= PSP_WIDTH_F / edao->GetWindowSize()->cx;
PCCoord->Y *= PSP_HEIGHT_F / edao->GetWindowSize()->cy;
}
};
class CGlobal
{
public:
PCRAFT_INFO THISCALL GetMagicData(USHORT MagicId);
PCSTR THISCALL GetMagicDescription(USHORT MagicId);
PBYTE THISCALL GetMagicQueryTable(USHORT MagicId);
EDAO* GetEDAO()
{
return (EDAO *)PtrSub(this, 0x4D3E8);
}
BOOL IsCustomChar(ULONG_PTR ChrId)
{
return GetEDAO()->GetSaveData()->IsCustomChar(ChrId);
}
PCHAR_STATUS GetChrStatus(ULONG_PTR ChrId)
{
return &((PCHAR_STATUS)PtrAdd(this, 0x2BBBC))[ChrId];
}
VOID CalcChrFinalStatus(ULONG ChrId, PCHAR_STATUS FinalStatus, PCHAR_STATUS RawStatus)
{
TYPE_OF(&CGlobal::CalcChrFinalStatus) f;
*(PVOID *)&f = (PVOID)0x677B36;
return (this->*f)(ChrId, FinalStatus, RawStatus);
}
PBYTE THISCALL FixWeaponShapeAndRange(USHORT ItemId);
DECL_STATIC_METHOD_POINTER(CGlobal, FixWeaponShapeAndRange);
static TYPE_OF(&CGlobal::GetMagicData) StubGetMagicData;
static TYPE_OF(&CGlobal::GetMagicDescription) StubGetMagicDescription;
static TYPE_OF(&CGlobal::GetMagicQueryTable) StubGetMagicQueryTable;
};
DECL_SELECTANY TYPE_OF(CGlobal::StubGetMagicData) CGlobal::StubGetMagicData = nullptr;
DECL_SELECTANY TYPE_OF(CGlobal::StubGetMagicDescription) CGlobal::StubGetMagicDescription = nullptr;
DECL_SELECTANY TYPE_OF(CGlobal::StubGetMagicQueryTable) CGlobal::StubGetMagicQueryTable = nullptr;
INIT_STATIC_MEMBER(CGlobal::StubFixWeaponShapeAndRange);
BOOL AoIsFileExist(PCSTR FileName);
#endif // _EDAO_H_5c8a3013_4334_4138_9413_3d0209da878e_
| [
"[email protected]"
] | |
0aade6ac3e836d2ff40b628b10361ae91e1c8a95 | 8f29598dfa2737f01ecd8470c7e9182c34fcd7d2 | /src/common/exprvalue.h | 201620e88260bbeb3381a6da43192c5fff3ac504 | [] | no_license | yedan2010/omnetpp | 8b8f7370dcaf5aeac340865d8d116029213a1d0c | aba1f0c3eeb02bbb65ccecf6f9a21e9ffbc4b003 | refs/heads/master | 2020-06-02T03:37:02.011659 | 2019-06-04T10:06:19 | 2019-06-04T10:06:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,558 | h | //==========================================================================
// EXPRVALUE.H - part of
// OMNeT++/OMNEST
// Discrete System Simulation in C++
//
//==========================================================================
/*--------------------------------------------------------------*
Copyright (C) 1992-2017 Andras Varga
Copyright (C) 2006-2017 OpenSim Ltd.
This file is distributed WITHOUT ANY WARRANTY. See the file
`license' for details on this and other legal matters.
*--------------------------------------------------------------*/
#ifndef __OMNETPP_COMMON_EXPRVALUE_H
#define __OMNETPP_COMMON_EXPRVALUE_H
#include <string>
#include "commondefs.h"
#include "intutil.h"
#include "stringutil.h"
namespace omnetpp { class cObject; }
namespace omnetpp {
namespace common {
class MatchExpression;
namespace expression {
/**
* @brief Value used during evaluating expressions.
*
* See notes below.
*
* <b>Measurement unit strings:</b>
*
* For performance reasons, the functions that store a measurement unit
* will only store the <tt>const char *</tt> pointer and not copy the
* string itself. Consequently, the passed unit pointers must stay valid
* at least during the lifetime of the ExprValue object, or even longer
* if the same pointer propagates to other ExprValue objects. It is recommended
* that you only pass pointers that stay valid during the entire simulation.
* It is safe to use: (1) string constants from the code; (2) units strings
* from other ExprValue's; and (3) stringpooled strings, e.g. from the
* getPooled() method or from StringPool.
*/
class COMMON_API ExprValue
{
friend class ExprNode;
friend class NegateNode;
friend class NotNode;
friend class BitwiseNotNode;
friend class AddNode;
friend class SubNode;
friend class MulNode;
friend class DivNode;
friend class ModNode;
friend class PowNode;
friend class CompareNode;
friend class MatchNode;
friend class MatchConstPatternNode;
friend class InlineIfNode;
friend class LogicalInfixOperatorNode;
friend class BitwiseInfixOperatorNode;
friend class MathFunc1Node;
friend class MathFunc2Node;
friend class MathFunc3Node;
friend class MathFunc4Node;
friend class FunctionNode;
friend class omnetpp::common::MatchExpression;
public:
enum Type {UNDEF=0, BOOL='B', INT='L', DOUBLE='D', STRING='S', OBJECT='O'};
private:
Type type = UNDEF;
union {
bool bl;
intpar_t intv;
double dbl;
cObject *obj;
const char *s; // non-nullptr, dynamically allocated
};
const char *unit=nullptr; // for INT/DOUBLE; must point to string constant or pooled string; may be nullptr
static std::string (*objectToString)(cObject *); // method to print info about cObjects
private:
#ifdef NDEBUG
void assertType(Type) const {}
#else
void assertType(Type t) const {if (type!=t) cannotCastError(t);}
#endif
char *strdup(const char *s) {char *p = new char[strlen(s)+1]; strcpy(p,s); return p;}
void deleteOld() {if (type==STRING) delete[] s;}
[[noreturn]] void cannotCastError(Type t) const;
public:
/** @name Constructors */
//@{
ExprValue() {}
ExprValue(const ExprValue& other) {operator=(other);}
ExprValue(ExprValue&& other) {operator=(other);}
ExprValue(bool b) {operator=(b);}
ExprValue(intpar_t l) {operator=(l);}
ExprValue(intpar_t l, const char *unit) {setQuantity(l, unit);}
ExprValue(double d) {operator=(d);}
ExprValue(double d, const char *unit) {setQuantity(d,unit);}
ExprValue(const char *s) {operator=(s);}
ExprValue(const std::string& s) {operator=(s);}
ExprValue(cObject *x) {operator=(x);}
~ExprValue() {if (type==STRING) delete[] s;}
//@}
/**
* Assignment
*/
void operator=(const ExprValue& other);
void operator=(ExprValue&& other);
/** @name Misc access. */
//@{
/**
* Returns the value type.
*/
Type getType() const {return type;}
/**
* Returns the given type as a string.
*/
static const char *getTypeName(Type t);
/**
* Returns true if the stored value is of a numeric type.
*/
bool isNumeric() const {return type==DOUBLE || type==INT;}
/**
* Returns the value in text form.
*/
std::string str() const;
/**
* Returns a copy of the string that is guaranteed to stay valid
* until the program exits. Multiple calls with identical strings as
* parameter will return the same copy. Useful for getting measurement
* unit strings suitable for ExprValue; see related class comment.
*
* @see StringPool, setUnit(), convertTo()
*/
static const char *getPooled(const char *s);
/**
* Sets method to print info about cObjects. This needs to be called
* once on startup from the simulation library which defines cObject.
*/
static void setObjectStrFunction(std::string (*f)(cObject *)) {objectToString = f;}
//@}
/** @name Setting the value. */
//@{
/**
* Sets the value to the given bool value.
*/
/**
* Sets the value to the given bool value.
*/
ExprValue& operator=(bool b) {deleteOld(); type=BOOL; bl=b; return *this;}
/**
* Sets the value to the given integer value.
*/
ExprValue& operator=(intpar_t d) {deleteOld(); type=INT; intv=d; unit=nullptr; return *this;}
/**
* Sets the value to the given double value.
*/
ExprValue& operator=(double d) {deleteOld(); type=DOUBLE; dbl=d; unit=nullptr;; return *this;}
/**
* Sets the value to the given string value. nullptr is not accepted.
*/
ExprValue& operator=(const char *s) {Assert(s); deleteOld(); type=STRING; this->s=strdup(s); return *this;}
/**
* Sets the value to the given string value.
*/
ExprValue& operator=(const std::string& s) {deleteOld(); type=STRING; this->s=strdup(s.c_str()); return *this;}
/**
* Sets the value to the given cObject.
*/
ExprValue& operator=(cObject *x) {deleteOld(); type=OBJECT; obj=x; return *this;}
/**
* Sets the value to the given integer value and measurement unit.
* The unit string pointer is expected to stay valid during the entire
* duration of the simulation (see related class comment).
*/
void setQuantity(intpar_t d, const char *unit) {deleteOld(); type=INT; intv=d; this->unit=unit;}
/**
* Sets the value to the given double value and measurement unit.
* The unit string pointer is expected to stay valid during the entire
* duration of the simulation (see related class comment).
*/
void setQuantity(double d, const char *unit) {deleteOld(); type=DOUBLE; dbl=d; this->unit=unit;}
/**
* Sets the value to the given integer value, preserving the current
* measurement unit. The object must already have the INT type.
*/
void setPreservingUnit(intpar_t d) {assertType(INT); intv=d;}
/**
* Sets the value to the given double value, preserving the current
* measurement unit. The object must already have the DOUBLE type.
*/
void setPreservingUnit(double d) {assertType(DOUBLE); dbl=d;}
/**
* Sets the measurement unit to the given value, leaving the numeric part
* of the quantity unchanged. The object must already have the DOUBLE type.
* The unit string pointer is expected to stay valid during the entire
* duration of the simulation (see related class comment).
*/
void setUnit(const char *unit);
/**
* Permanently converts this value to the given unit. The value must
* already have the type DOUBLE. If the current unit cannot be converted
* to the given one, an error will be thrown. The unit string pointer
* is expected to stay valid during the entire simulation (see related
* class comment).
*
* @see doubleValueInUnit()
*/
void convertTo(const char *unit);
/**
* If this value is of type INT, converts it into DOUBLE; has no effect if
* it is already a DOUBLE; and throws an error otherwise.
*/
void convertToDouble();
//@}
/** @name Accessing the value. */
//@{
/**
* Returns value as a boolean. The type must be BOOL.
*/
bool boolValue() const {assertType(BOOL); return bl;}
/**
* Returns value as integer. The type must be INT.
*/
intpar_t intValue() const;
/**
* Returns the numeric value as an integer converted to the given unit.
* If the current unit cannot be converted to the given one, an error
* will be thrown. The type must be INT.
*/
intpar_t intValueInUnit(const char *targetUnit) const;
/**
* Returns value as double. The type must be DOUBLE or INT.
*/
double doubleValue() const;
/**
* Returns the numeric value as a double converted to the given unit.
* If the current unit cannot be converted to the given one, an error
* will be thrown. The type must be DOUBLE or INT.
*/
double doubleValueInUnit(const char *targetUnit) const;
/**
* Returns the unit ("s", "mW", "Hz", "bps", etc), or nullptr if there was no
* unit was specified. Unit is only valid for the DOUBLE and INT types.
*/
const char *getUnit() const {return (type==DOUBLE || type==INT) ? unit : nullptr;}
/**
* Returns value as const char *. The type must be STRING.
*/
const char *stringValue() const {assertType(STRING); return s;}
/**
* Returns value as pointer to cObject. The type must be OBJECT.
*/
cObject *objectValue() const {assertType(OBJECT); return obj;}
/**
* Equivalent to boolValue().
*/
operator bool() const {return boolValue();}
/**
* Equivalent to intValue().
* Calls intValue() and converts the result to unsigned long long.
* An exception is thrown if the conversion would result in a data loss,
*/
operator intpar_t() const {return intValue();}
/**
* Equivalent to doubleValue().
*/
operator double() const {return doubleValue();}
/**
* Equivalent to stringValue().
*/
operator const char *() const {return stringValue();}
/**
* Equivalent to objectValue().
*/
operator cObject *() const {return objectValue();}
//@}
};
} // namespace expression
} // namespace common
} // namespace omnetpp
#endif
| [
"[email protected]"
] | |
9fe5c41fef7a54d8323db7dbb667be6f5107e02b | 4bab98acf65c4625a8b3c757327a8a386f90dd32 | /ros2-windows/include/geometry_msgs/msg/detail/inertia__struct.hpp | 0ab7c5ac8f6bfb87ced89df038eeb0e270cb6333 | [] | no_license | maojoejoe/Peach-Thinning-GTRI-Agricultural-Robotics-VIP | e2afb08b8d7b3ac075e071e063229f76b25f883a | 8ed707edb72692698f270317113eb215b57ae9f9 | refs/heads/master | 2023-01-15T06:00:22.844468 | 2020-11-25T04:16:15 | 2020-11-25T04:16:15 | 289,108,482 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,659 | hpp | // generated from rosidl_generator_cpp/resource/idl__struct.hpp.em
// with input from geometry_msgs:msg\Inertia.idl
// generated code does not contain a copyright notice
#ifndef GEOMETRY_MSGS__MSG__DETAIL__INERTIA__STRUCT_HPP_
#define GEOMETRY_MSGS__MSG__DETAIL__INERTIA__STRUCT_HPP_
#include <rosidl_runtime_cpp/bounded_vector.hpp>
#include <rosidl_runtime_cpp/message_initialization.hpp>
#include <algorithm>
#include <array>
#include <memory>
#include <string>
#include <vector>
// Include directives for member types
// Member 'com'
#include "geometry_msgs/msg/detail/vector3__struct.hpp"
#ifndef _WIN32
# define DEPRECATED__geometry_msgs__msg__Inertia __attribute__((deprecated))
#else
# define DEPRECATED__geometry_msgs__msg__Inertia __declspec(deprecated)
#endif
namespace geometry_msgs
{
namespace msg
{
// message struct
template<class ContainerAllocator>
struct Inertia_
{
using Type = Inertia_<ContainerAllocator>;
explicit Inertia_(rosidl_runtime_cpp::MessageInitialization _init = rosidl_runtime_cpp::MessageInitialization::ALL)
: com(_init)
{
if (rosidl_runtime_cpp::MessageInitialization::ALL == _init ||
rosidl_runtime_cpp::MessageInitialization::ZERO == _init)
{
this->m = 0.0;
this->ixx = 0.0;
this->ixy = 0.0;
this->ixz = 0.0;
this->iyy = 0.0;
this->iyz = 0.0;
this->izz = 0.0;
}
}
explicit Inertia_(const ContainerAllocator & _alloc, rosidl_runtime_cpp::MessageInitialization _init = rosidl_runtime_cpp::MessageInitialization::ALL)
: com(_alloc, _init)
{
if (rosidl_runtime_cpp::MessageInitialization::ALL == _init ||
rosidl_runtime_cpp::MessageInitialization::ZERO == _init)
{
this->m = 0.0;
this->ixx = 0.0;
this->ixy = 0.0;
this->ixz = 0.0;
this->iyy = 0.0;
this->iyz = 0.0;
this->izz = 0.0;
}
}
// field types and members
using _m_type =
double;
_m_type m;
using _com_type =
geometry_msgs::msg::Vector3_<ContainerAllocator>;
_com_type com;
using _ixx_type =
double;
_ixx_type ixx;
using _ixy_type =
double;
_ixy_type ixy;
using _ixz_type =
double;
_ixz_type ixz;
using _iyy_type =
double;
_iyy_type iyy;
using _iyz_type =
double;
_iyz_type iyz;
using _izz_type =
double;
_izz_type izz;
// setters for named parameter idiom
Type & set__m(
const double & _arg)
{
this->m = _arg;
return *this;
}
Type & set__com(
const geometry_msgs::msg::Vector3_<ContainerAllocator> & _arg)
{
this->com = _arg;
return *this;
}
Type & set__ixx(
const double & _arg)
{
this->ixx = _arg;
return *this;
}
Type & set__ixy(
const double & _arg)
{
this->ixy = _arg;
return *this;
}
Type & set__ixz(
const double & _arg)
{
this->ixz = _arg;
return *this;
}
Type & set__iyy(
const double & _arg)
{
this->iyy = _arg;
return *this;
}
Type & set__iyz(
const double & _arg)
{
this->iyz = _arg;
return *this;
}
Type & set__izz(
const double & _arg)
{
this->izz = _arg;
return *this;
}
// constant declarations
// pointer types
using RawPtr =
geometry_msgs::msg::Inertia_<ContainerAllocator> *;
using ConstRawPtr =
const geometry_msgs::msg::Inertia_<ContainerAllocator> *;
using SharedPtr =
std::shared_ptr<geometry_msgs::msg::Inertia_<ContainerAllocator>>;
using ConstSharedPtr =
std::shared_ptr<geometry_msgs::msg::Inertia_<ContainerAllocator> const>;
template<typename Deleter = std::default_delete<
geometry_msgs::msg::Inertia_<ContainerAllocator>>>
using UniquePtrWithDeleter =
std::unique_ptr<geometry_msgs::msg::Inertia_<ContainerAllocator>, Deleter>;
using UniquePtr = UniquePtrWithDeleter<>;
template<typename Deleter = std::default_delete<
geometry_msgs::msg::Inertia_<ContainerAllocator>>>
using ConstUniquePtrWithDeleter =
std::unique_ptr<geometry_msgs::msg::Inertia_<ContainerAllocator> const, Deleter>;
using ConstUniquePtr = ConstUniquePtrWithDeleter<>;
using WeakPtr =
std::weak_ptr<geometry_msgs::msg::Inertia_<ContainerAllocator>>;
using ConstWeakPtr =
std::weak_ptr<geometry_msgs::msg::Inertia_<ContainerAllocator> const>;
// pointer types similar to ROS 1, use SharedPtr / ConstSharedPtr instead
// NOTE: Can't use 'using' here because GNU C++ can't parse attributes properly
typedef DEPRECATED__geometry_msgs__msg__Inertia
std::shared_ptr<geometry_msgs::msg::Inertia_<ContainerAllocator>>
Ptr;
typedef DEPRECATED__geometry_msgs__msg__Inertia
std::shared_ptr<geometry_msgs::msg::Inertia_<ContainerAllocator> const>
ConstPtr;
// comparison operators
bool operator==(const Inertia_ & other) const
{
if (this->m != other.m) {
return false;
}
if (this->com != other.com) {
return false;
}
if (this->ixx != other.ixx) {
return false;
}
if (this->ixy != other.ixy) {
return false;
}
if (this->ixz != other.ixz) {
return false;
}
if (this->iyy != other.iyy) {
return false;
}
if (this->iyz != other.iyz) {
return false;
}
if (this->izz != other.izz) {
return false;
}
return true;
}
bool operator!=(const Inertia_ & other) const
{
return !this->operator==(other);
}
}; // struct Inertia_
// alias to use template instance with default allocator
using Inertia =
geometry_msgs::msg::Inertia_<std::allocator<void>>;
// constant definitions
} // namespace msg
} // namespace geometry_msgs
#endif // GEOMETRY_MSGS__MSG__DETAIL__INERTIA__STRUCT_HPP_
| [
"[email protected]"
] | |
7910356737ffbbf082cca8ce97095064506b46e6 | fc7d5b988d885bd3a5ca89296a04aa900e23c497 | /Programming/mbed-os-example-sockets/mbed-os/features/frameworks/utest/source/utest_print.cpp | 57c0224c53e18e897d5513432dce8595276ad2b8 | [
"Apache-2.0"
] | permissive | AlbinMartinsson/master_thesis | 52746f035bc24e302530aabde3cbd88ea6c95b77 | 495d0e53dd00c11adbe8114845264b65f14b8163 | refs/heads/main | 2023-06-04T09:31:45.174612 | 2021-06-29T16:35:44 | 2021-06-29T16:35:44 | 334,069,714 | 3 | 1 | Apache-2.0 | 2021-03-16T16:32:16 | 2021-01-29T07:28:32 | C++ | UTF-8 | C++ | false | false | 1,770 | cpp | /****************************************************************************
* Copyright (c) 2019, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
****************************************************************************
*/
#include <stdio.h>
#include <string.h>
#include <cstdarg>
#include "greentea-client/test_env.h"
#include "platform/mbed_retarget.h"
#define STRING_STACK_LIMIT 120
static int utest_vprintf(const char *format, std::va_list arg)
{
// ARMCC microlib does not properly handle a size of 0.
// As a workaround supply a dummy buffer with a size of 1.
char dummy_buf[1];
int len = vsnprintf(dummy_buf, sizeof(dummy_buf), format, arg);
if (len < STRING_STACK_LIMIT) {
char temp[STRING_STACK_LIMIT];
vsprintf(temp, format, arg);
greentea_write_string(temp);
} else {
char *temp = new char[len + 1];
vsprintf(temp, format, arg);
greentea_write_string(temp);
delete[] temp;
}
return len;
}
extern "C" int utest_printf(const char *format, ...)
{
std::va_list args;
va_start(args, format);
int len = utest_vprintf(format, args);
va_end(args);
return len;
}
| [
"[email protected]"
] | |
3a73ab70586e009c7a486511452c7f4b7328b411 | 867aeda5172bc44c2f08543668dedd9a472d7307 | /src/Beam.cpp | 7082e141dbb47bae70c39057420e9a6736589c6c | [] | no_license | Heart-Under-Blade/BS_visual | a0a10257919204022f1013047068adaebb567dba | 7dfbc097441e878afc4571c20432eae106d2c240 | refs/heads/master | 2021-08-11T18:26:53.262010 | 2017-09-27T10:10:05 | 2017-09-27T10:10:05 | 104,302,724 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,938 | cpp | #include "Beam.h"
#include <float.h>
#include <math.h>
#include <assert.h>
#include <list>
#include "macro.h"
#include "geometry_lib.h"
std::ostream& operator << (std::ostream &os, const Beam &beam)
{
using namespace std;
os << Polygon(beam);
os << "level: " << beam.level << endl
<< "last facet: " << beam.lastFacetID << endl
<< "location: " << beam.location << endl
<< "id: " << beam.id << endl
<< "D: " << beam.D << endl
<< "direction: "
<< beam.direction.cx << ", "
<< beam.direction.cy << ", "
<< beam.direction.cz << ", "
<< beam.direction.d_param << endl << endl;
return os;
}
Point3d Proj(const Point3d& Tx, const Point3d& Ty, const Point3d& r, const Point3d& pnt)
{
const Point3d p_pr = pnt - r*DotProductD(r, pnt); // расчёт коор-т в СК наблюдателя
return Point3d(DotProductD(p_pr, Tx), DotProductD(p_pr, Ty), 0); //*/
}
Point3d Proj(const Point3d& _r, const Point3d &pnt)
{
Point3d _Tx, // условная горизонталь СК экрана в СК тела
_Ty; // третья ось (условная вертикаль СК экрана)
const double tmp = sqrt(SQR(_r.x)+SQR(_r.y));
(fabs(_r.z)>1-DBL_EPSILON) ? (_Tx=Point3d(0,-_r.z,0), _Ty=Point3d(1,0,0))
: (_Tx=Point3d(_r.y/tmp,-_r.x/tmp,0), _Ty=CrossProductD(_r,_Tx));
return Proj(_Tx, _Ty, _r, pnt);
}
Beam::Beam()
{
opticalPath = 0;
e = Point3f(0, 1, 0);
}
void Beam::Copy(const Beam &other)
{
opticalPath = other.opticalPath;
D = other.D;
e = other.e;
direction = other.direction;
Polygon::operator =(other);
lastFacetID = other.lastFacetID;
level = other.level;
location = other.location;
#ifdef _TRACK_ALLOW
id = other.id;
#endif
}
Beam::Beam(const Beam &other)
: J(other.J)
{
Copy(other);
}
Beam::Beam(const Polygon &other)
: Polygon(other)
{
}
Beam::Beam(Beam &&other)
: Polygon(other)
{
opticalPath = other.opticalPath;
D = other.D;
e = other.e;
direction = other.direction;
lastFacetID = other.lastFacetID;
level = other.level;
location = other.location;
#ifdef _TRACK_ALLOW
id = other.id;
#endif
other.opticalPath = 0;
other.D = 0;
other.e = Point3f(0, 0, 0);
other.direction = Point3f(0, 0, 0);
other.lastFacetID = 0;
other.level = 0;
other.location = Location::Out;
#ifdef _TRACK_ALLOW
other.id = 0;
#endif
}
void Beam::RotateSpherical(const Point3f &dir, const Point3f &polarBasis)
{
Point3f newBasis;
double cs = DotProduct(dir, direction);
if (fabs(1.0 - cs) <= DBL_EPSILON)
{
newBasis = -polarBasis;
}
else
{
if (fabs(1.0 + cs) <= DBL_EPSILON)
{
newBasis = polarBasis;
}
else
{
double fi, teta;
GetSpherical(fi, teta);
newBasis = Point3f(-sin(fi),cos(fi), 0);
}
}
RotateJMatrix(newBasis);
}
void Beam::GetSpherical(double &fi, double &teta) const
{
const float &x = direction.cx;
const float &y = direction.cy;
const float &z = direction.cz;
if (fabs(z + 1.0) < DBL_EPSILON) // forward
{
fi = 0;
teta = M_PI;
return;
}
if (fabs(z - 1.0) < DBL_EPSILON) // bacward
{
fi = 0;
teta = 0;
return;
}
double tmp = y*y;
if (tmp < DBL_EPSILON)
{
tmp = (x > 0) ? 0 : M_PI;
}
else
{
tmp = acos(x/sqrt(x*x + tmp));
if (y < 0)
{
tmp = M_2PI - tmp;
}
}
fi = (tmp < M_2PI) ? tmp : 0;
teta = acos(z);
}
Beam & Beam::operator = (const Beam &other)
{
if (this != &other)
{
Copy(other);
J = other.J;
}
return *this;
}
Beam &Beam::operator =(const Polygon &other)
{
Polygon::operator =(other);
}
Beam &Beam::operator = (Beam &&other)
{
if (this != &other)
{
Polygon::operator =(other);
opticalPath = other.opticalPath;
D = other.D;
e = other.e;
direction = other.direction;
lastFacetID = other.lastFacetID;
level = other.level;
location = other.location;
J = other.J;
#ifdef _TRACK_ALLOW
id = other.id;
#endif
other.opticalPath = 0;
other.D = 0;
other.e = Point3f(0, 0, 0);
other.direction = Point3f(0, 0, 0);
other.lastFacetID = 0;
other.level = 0;
other.location = Location::Out;
#ifdef _TRACK_ALLOW
other.id = id;
#endif
}
return *this;
}
void Beam::SetTracingParams(int facetID, int lvl, Location loc)
{
lastFacetID = facetID;
level = lvl;
location = loc;
}
void Beam::SetJonesMatrix(const Beam &other, const complex &coef1, const complex &coef2)
{
J.m11 = coef1 * other.J.m11;
J.m12 = coef1 * other.J.m12;
J.m21 = coef2 * other.J.m21;
J.m22 = coef2 * other.J.m22;
}
complex Beam::DiffractionIncline(const Point3d &pt, double wavelength) const
{
const double eps1 = /*1e9**/100*FLT_EPSILON;
const double eps2 = /*1e6**/FLT_EPSILON;
Point3f _n = Normal();
int begin, startIndex, endIndex;
bool order = (DotProduct(_n, direction) < 0);
if (order)
{
begin = 0;
startIndex = size-1;
endIndex = -1;
}
else
{
begin = size-1;
startIndex = 0;
endIndex = size;
}
Point3d n = Point3d(_n.cx, _n.cy, _n.cz);
Point3d k_k0 = -pt + Point3d(direction.cx, direction.cy, direction.cz);
Point3f cntr = Center();
Point3d center = Proj(n, Point3d(cntr.cx, cntr.cy, cntr.cz));
Point3d pt_proj = Proj(n, k_k0);
const double
A = pt_proj.x,
B = pt_proj.y;
complex one(0, -1);
const double k = M_2PI/wavelength;
if (fabs(A) < eps2 && fabs(B) < eps2)
{
return -one/wavelength*Area();
}
complex s(0, 0);
// std::list<Point3d>::const_iterator p = polygon.arrthis->v.begin();
// Point3d p1 = Proj(this->N, *p++)-cnt, p2; // переводим вершины в систему координат грани
Point3d p1 = Proj(n, arr[begin]) - center;
Point3d p2;
if (fabs(B) > fabs(A))
{
for (int i = startIndex; i != endIndex;)
{
p2 = Proj(n, arr[i]) - center;
if (fabs(p1.x - p2.x) < eps1)
{
p1 = p2;
if (order)
{
--i;
}
else
{
++i;
}
continue;
}
const double
ai = (p1.y-p2.y)/(p1.x-p2.x),
bi = p1.y - ai*p1.x,
Ci = A+ai*B;
complex tmp;
if (fabs(Ci) < eps1)
{
tmp = complex(-k*k*Ci*(p2.x*p2.x-p1.x*p1.x)/2.0,k*(p2.x-p1.x));
}
else
{
tmp = (exp_im(k*Ci*p2.x) - exp_im(k*Ci*p1.x))/Ci;
}
s += exp_im(k*B*bi) * tmp;
p1 = p2;
if (order)
{
--i;
}
else
{
++i;
}
}
s /= B;
}
else
{
for (int i = startIndex; i != endIndex;)
{
p2 = Proj(n, arr[i]) - center;
if (fabs(p1.y - p2.y)<eps1)
{
p1 = p2;
if (order)
{
--i;
}
else
{
++i;
}
continue;
}
const double ci = (p1.x-p2.x)/(p1.y-p2.y),
di = p1.x - ci*p1.y,
Ei = A*ci+B;
s += exp_im(k*A*di) * (fabs(Ei)<eps1 ? complex(-k*k*Ei*(p2.y*p2.y-p1.y*p1.y)/2.0,k*(p2.y-p1.y))
: (exp_im(k*Ei*p2.y) - exp_im(k*Ei*p1.y))/Ei);
p1 = p2;
if (order)
{
--i;
}
else
{
++i;
}
}
s /= -A;
}
return one*wavelength*s/SQR(M_2PI);
}
void Beam::RotatePlane(const Point3f &newBasis)
{
RotateJMatrix(newBasis);
}
void Beam::RotateJMatrix(const Point3f &newBasis)
{
const double eps = 1e2 * FLT_EPSILON/*DBL_EPSILON*/; // acceptable precision
double cs = DotProduct(newBasis, e);
if (fabs(1.0 - cs) < eps)
{
return;
}
if (fabs(1.0 + cs) < eps)
{
J.m11 = -J.m11;
J.m12 = -J.m12;
J.m21 = -J.m21;
J.m22 = -J.m22;
}
else
{
// LOG_ASSERT(fabs(cs) <= 1.0+DBL_EPSILON);
Point3f k;
CrossProduct(e, newBasis, k);
Normalize(k);
double angle = acos(cs);
Point3f r = k + direction;
if (Norm(r) <= 0.5)
{
angle = -angle;
}
double sn = sin(angle); // the rotation of matrix "m"
complex b00 = J.m11*cs + J.m21*sn; // first row of the result
complex b01 = J.m12*cs + J.m22*sn;
J.m21 = J.m21*cs - J.m11*sn;
J.m22 = J.m22*cs - J.m12*sn;
J.m11 = b00;
J.m12 = b01;
}
e = newBasis;
}
void Beam::AddVertex(const Point3f &vertex)
{
arr[size++] = vertex;
}
void Beam::SetPolygon(const Polygon &other)
{
size = other.size;
for (int i = 0; i < other.size; ++i)
{
arr[i] = other.arr[i];
}
}
| [
"[email protected]"
] | |
414729b3caacba4eca10661e3165964eb4378ffe | d87370a13a42fff0cc2a4b2866b100974a4ade17 | /6/6.cpp | 58fab12bc76ac655187438fa3442330bd9be6941 | [] | no_license | PanchLine/-3 | 3dceb02bc0abe4c3420512fdd176a571183ec521 | d014242f5d837925546134b6132f3ed2b80dfd4c | refs/heads/master | 2023-01-15T11:44:44.468914 | 2020-11-25T11:47:15 | 2020-11-25T11:47:15 | 315,899,200 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,878 | cpp | // 6.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
//
#include <iostream>
using namespace std;
int main()
{
setlocale(NULL, "rus");
int x, y, z=1, k=0;
cout << "Введите 2 числа";
cin >> x >> y;
while (z<=x && z<=y)
{
if (x % z == 0 && y % z == 0) k = z;
z++;
}
cout << k;
system("pause");
}
// Запуск программы: CTRL+F5 или меню "Отладка" > "Запуск без отладки"
// Отладка программы: F5 или меню "Отладка" > "Запустить отладку"
// Советы по началу работы
// 1. В окне обозревателя решений можно добавлять файлы и управлять ими.
// 2. В окне Team Explorer можно подключиться к системе управления версиями.
// 3. В окне "Выходные данные" можно просматривать выходные данные сборки и другие сообщения.
// 4. В окне "Список ошибок" можно просматривать ошибки.
// 5. Последовательно выберите пункты меню "Проект" > "Добавить новый элемент", чтобы создать файлы кода, или "Проект" > "Добавить существующий элемент", чтобы добавить в проект существующие файлы кода.
// 6. Чтобы снова открыть этот проект позже, выберите пункты меню "Файл" > "Открыть" > "Проект" и выберите SLN-файл.
| [
"[email protected]"
] | |
fbc60497041fccf058d274c7d5170465a91176ab | 4d4822b29e666cea6b2d99d5b9d9c41916b455a9 | /Example/Pods/Headers/Private/GeoFeatures/boost/intrusive/detail/size_holder.hpp | 89bc0f7c8ac1fe40bfa66fb0e34d9b0a9901919d | [
"BSL-1.0",
"Apache-2.0"
] | permissive | eswiss/geofeatures | 7346210128358cca5001a04b0e380afc9d19663b | 1ffd5fdc49d859b829bdb8a9147ba6543d8d46c4 | refs/heads/master | 2020-04-05T19:45:33.653377 | 2016-01-28T20:11:44 | 2016-01-28T20:11:44 | 50,859,811 | 0 | 0 | null | 2016-02-01T18:12:28 | 2016-02-01T18:12:28 | null | UTF-8 | C++ | false | false | 74 | hpp | ../../../../../../../../GeoFeatures/boost/intrusive/detail/size_holder.hpp | [
"[email protected]"
] | |
06ac0804485dc9ce927ce6c3c93a4cff0fcd7538 | 092627da4daaea29e171ac65a539dae29f047525 | /template.cpp | ce6aec50b9a880de89bdf1b11a9d102351b3781f | [] | no_license | Bhutanisachin19/C-and-C-College-Codes | 03105db049a98b188ba6589c14c73f9c64b194a2 | 84435d0dd73e0012a2c707abf3b83a35d9fac782 | refs/heads/master | 2023-07-31T05:34:14.424960 | 2021-09-28T08:59:16 | 2021-09-28T08:59:16 | 411,207,513 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 562 | cpp | #include<iostream>
using namespace std;
template < class T >
void sort_arr(T arr)
{
int i,j;
T a;
for (i = 0; i < 5; ++i)
{
for (j = i + 1; j < 5; ++j)
{
if (arr[i] > arr[j])
{
a = arr[i];
arr[i] = arr[j];
arr[j] = a;
}
}
}
cout<<"Sorted array is :"<<endl;
for(i=0;i<5;i++)
{
cout<<arr[i]<<endl;
}
}
int main()
{
int arr[]={9,3,10,0,8};
sort_arr(arr);
}
| [
"[email protected]"
] | |
fbb69635b815c0e76056b67d88b9cd99418fdcfc | d092cde037d32efe117668aec994cb5b4516fa2e | /BackToWar_135/addon_2_project/ADDON_2_PROJECT/ADDON_PROJECT_130/Hint.cpp | 5e2cac06960dbd30afb0035223cf15ff9c44a462 | [] | no_license | Kright/Cossacks-back-to-war | ba16da5e7994ba066f9f0387c3907a9239d3441a | 01c4726312717b04c9f4cc4e17810e31d5f5521d | refs/heads/master | 2020-12-30T15:55:13.769763 | 2016-10-21T19:18:31 | 2016-10-21T19:18:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,228 | cpp | #include "ddini.h"
#include "ResFile.h"
#include "FastDraw.h"
#include "mgraph.h"
#include "mouse.h"
#include "menu.h"
#include "MapDiscr.h"
#include "multipl.h"
#include "fog.h"
#include "walls.h"
#include "Nature.h"
#include <time.h>
#include "Nucl.h"
#include "TopZones.h"
#include "Megapolis.h"
#include "Fonts.h"
#include "recorder.h"
static int HintTime;
//static int HintTime1;
void ResFon(int x,int y,int Lx,int Ly);
void ScrCopy(int x,int y,int Lx,int Ly);
#define NHINT 4
char HintStr[256];
char HintStrLo[256];
char HintStr1[NHINT][256];
byte HintOpt[NHINT];//(0)-usual,(16+x)-in national bar,32-red
static int HintTime1[NHINT];
int HintX;
int HintY;
int HintLx;
int HintLy;
void SetupHint(){
HintY=smapy+smaply*32-20;
HintX=smapx;
HintLx=720;
HintLy=16;
HintTime=0;
};
extern byte PlayGameMode;
void ShowHint(){
if(PlayGameMode==1)return;
//ResFon(HintX,HintY,HintLx,HintLy);
if(HintTime){
ShowString(HintX+2,HintY+2,HintStr,&BlackFont);
ShowString(HintX,HintY,HintStr,&WhiteFont);
ShowString(HintX+2,HintY+20+2,HintStrLo,&BlackFont);
ShowString(HintX,HintY+20,HintStrLo,&WhiteFont);
};
int yy=HintY-20;
for(int i=0;i<NHINT;i++){
if(HintTime1[i]){
ShowString(HintX+2,yy+2,HintStr1[i],&BlackFont);
byte opt=HintOpt[i];
byte opp=opt>>4;
if(opp==2){
int tt=(GetTickCount()/300)&1;
if(tt)ShowString(HintX,yy,HintStr1[i],&WhiteFont);
else ShowString(HintX,yy,HintStr1[i],&RedFont);
}else
if(opp==1){
ShowString(HintX,yy,HintStr1[i],&WhiteFont);
Xbar(HintX-2,yy,GetRLCStrWidth(HintStr1[i],&WhiteFont)+5,GetRLCHeight(WhiteFont.RLC,'y')+1,0xD0+((opt&7)<<2));
}else{
ShowString(HintX,yy,HintStr1[i],&WhiteFont);
};
};
yy-=20;
};
//ScrCopy(HintX,HintY,HintLx,HintLy);
};
void ClearHints(){
for(int i=0;i<NHINT;i++)HintStr1[i][0]=0;
HintStrLo[0]=0;
};
void HideHint(){
//ResFon(HintX,HintY,HintLx,HintLy);
//ScrCopy(HintX,HintY,HintLx,HintLy);
};
void AssignHint(char* s,int time){
strcpy(HintStr,s);
//ShowHint();
HintTime=time;
HintStrLo[0]=0;
};
void AssignHintLo(char* s,int time){
strcpy(HintStrLo,s);
//ShowHint();
HintTime=time;
};
void AssignHint1(char* s,int time){
if(!strcmp(s,HintStr1[0])){
HintTime1[0]=time;
HintOpt[0]=0;
return;
};
for(int i=NHINT-1;i>0;i--){
strcpy(HintStr1[i],HintStr1[i-1]);
HintTime1[i]=HintTime1[i-1];
HintOpt[i]=HintOpt[i-1];
};
strcpy(HintStr1[0],s);
HintTime1[0]=time;
HintOpt[0]=0;
};
extern bool RecordMode;
extern byte PlayGameMode;
extern char LASTCHATSTR[512];
extern byte CHOPT;
void AssignHint1(char* s,int time,byte opt){
if(opt>=16){
if(RecordMode&&!PlayGameMode){
strcpy(LASTCHATSTR,s);
CHOPT=opt;
};
};
if(!strcmp(s,HintStr1[0])){
HintTime1[0]=time;
HintOpt[0]=opt;
return;
};
for(int i=NHINT-1;i>0;i--){
strcpy(HintStr1[i],HintStr1[i-1]);
HintTime1[i]=HintTime1[i-1];
HintOpt[i]=HintOpt[i-1];
};
strcpy(HintStr1[0],s);
HintTime1[0]=time;
HintOpt[0]=opt;
};
void GetChar(GeneralObject* GO,char* s){
Visuals* VS=(Visuals*)GO;
strcpy(s,VS->Message);
};
void GetMonsterCapsString(char* st);
void ProcessHint(){
ShowHint();
if(HintTime){
HintTime--;
};
for(int i=0;i<NHINT;i++){
if(HintTime1[i]){
HintTime1[i]--;
};
};
};
| [
"[email protected]"
] | |
8f9416bd8ad63091367cb56bfdb958a0aad9888e | 9a3ec3eb5371a0e719b50bbf832a732e829b1ce4 | /GameOps/NPCForestGuardian.cpp | e61eb6505e8bd4699c6b98e1ad58b04e09513be0 | [] | no_license | elestranobaron/T4C-Serveur-Multiplateformes | 5cb4dac8b8bd79bfd2bbd2be2da6914992fa7364 | f4a5ed21db1cd21415825cc0e72ddb57beee053e | refs/heads/master | 2022-10-01T20:13:36.217655 | 2022-09-22T02:43:33 | 2022-09-22T02:43:33 | 96,352,559 | 12 | 8 | null | null | null | null | UTF-8 | C++ | false | false | 980 | cpp | /////////////////////////////////////////////////////////////////////////////
#pragma hdrstop
#include "NPCForestGuardian.H"
NPCForestGuardian::NPCForestGuardian()
{}
NPCForestGuardian::~NPCForestGuardian()
{}
extern NPCstructure::NPC _NPCForestGuardian;
void NPCForestGuardian::Create( void )
{
npc = ( _NPCForestGuardian );
SET_NPC_NAME( "[87]Forest Guardian" );
npc.InitialPos.X = 0;
npc.InitialPos.Y = 0;
npc.InitialPos.world = 0;
}
void NPCForestGuardian::OnDeath( UNIT_FUNC_PROTOTYPE )
{
if( target != NULL )
{
TFormat FORMAT;
GiveFlag( __GUARDIANS_KILLED, CheckFlag(__GUARDIANS_KILLED) + 1)
IF (CheckFlag( __GUARDIANS_KILLED) == 1)
PRIVATE_SYSTEM_MESSAGE(FORMAT(INTL( 7362, "You have killed %u forest guardian!"), CheckFlag(__GUARDIANS_KILLED)))
ELSE
PRIVATE_SYSTEM_MESSAGE(FORMAT(INTL( 7363, "You have killed %u forest guardians!"), CheckFlag(__GUARDIANS_KILLED)))
ENDIF
}
NPCstructure::OnDeath( UNIT_FUNC_PARAM );
}
| [
"[email protected]"
] | |
3d3350e2f8ee6486f13222e8e1177793856ec588 | 715d33bc9331414ccd9d13a93aec0e6a82e6baca | /benzene_predictor/uTensor-mbed/predictor.cpp | 5e377e41045727eccc1fc288942b1228b7178558 | [] | no_license | antoninus96/Air_Quality_Monitoring_IoT | beb6a3c3e47109ee59a4510d323af2f66b672db6 | 89f0125c4324da80040de2f028fc957a9f0edeae | refs/heads/master | 2020-05-07T13:22:17.426927 | 2019-04-15T20:41:03 | 2019-04-15T20:41:03 | 180,546,841 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 553 | cpp | #include "predictor.h"
float predict(float* values){
Context ctx; //creating the context class, the stage where inferences take place
//wrapping the input data in a tensor class
Tensor* input_x = new WrappedRamTensor<float>({1, 3}, values);
get_predictor_ctx(ctx, input_x); // pass the tensor to the context
S_TENSOR pred_tensor = ctx.get("y_pred:0"); // getting a reference to the output tensor
ctx.eval(); //trigger the inference
float pred_label = *(pred_tensor->read<float>(0, 0)); //getting the result back
return pred_label;
}
| [
"[email protected]"
] | |
b760c2b4afe37fa780dd740641005cd5756d01ba | 7f01ac465a22a8d128a42a9278c27405e8ede392 | /lab3/tests/test_SphereObject.cc | 4bdfc79f978d06416716f0c94f402c06f7e3eb22 | [] | no_license | vertz/cs11-advcpp | 324e4337e895c83c92c27170c59c9ca511ba6d93 | f0aa96f4723a6f3299edb33387129022f7612dd2 | HEAD | 2016-09-05T11:51:36.918876 | 2014-01-11T00:05:46 | 2014-01-11T00:05:46 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,643 | cc | #include "SphereObject.hh"
#include "Vector3F.hh"
#include "Ray.hh"
#include <gtest/gtest.h>
#include <iostream>
// This is the namespace that the Google C++ Testing Framework uses.
using namespace testing;
TEST(TestSphereObject, intersection)
{
// shooting a ray from (0,0,0)
// at a sphere of radius 1 at (2,0,0)
// making sure you get back a result of (1,0,0)
Vector3F center(2,0,0), P(0,0,0);
Ray r(P, center, false);
SphereObject sObj (center, 1);
float t = sObj.intersection(r);
Vector3F intersectionPoint = r.getPointAtT(t);
EXPECT_FLOAT_EQ(intersectionPoint(0), 1);
EXPECT_FLOAT_EQ(intersectionPoint(1), 0);
EXPECT_FLOAT_EQ(intersectionPoint(2), 0);
}
TEST(TestSphereObject, getIntersections)
{
// shooting a ray from (0,0,0)
// at a sphere of radius 1 at (2,0,0)
//sphere-intersection helper function, and check that you get both (1, 0, 0) and (3, 0, 0)
Vector3F center(2,0,0), P(0,0,0);
Ray r(P, center, false);
SphereObject sObj (center, 1);
float t1, t2;
int count = sObj.getIntersections(r, t1, t2);
ASSERT_EQ(count, 2);
Vector3F intersectionPoint = r.getPointAtT(t1);
EXPECT_FLOAT_EQ(intersectionPoint(0), 1);
EXPECT_FLOAT_EQ(intersectionPoint(1), 0);
EXPECT_FLOAT_EQ(intersectionPoint(2), 0);
intersectionPoint = r.getPointAtT(t2);
EXPECT_FLOAT_EQ(intersectionPoint(0), 3);
EXPECT_FLOAT_EQ(intersectionPoint(1), 0);
EXPECT_FLOAT_EQ(intersectionPoint(2), 0);
}
int main(int argc, char **argv) {
InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
| [
"[email protected]"
] | |
2d8d59e907f989bc042baf8d77a7ed7c88be2e99 | 9347848790b55807cee048d3cf34d24123c32287 | /Graphs/myHop.cpp | 2e28cceca144aec2f9ca14f0201b93e9c3d28198 | [] | no_license | andpodob/CSstudy | 5a1c2960c43860d3d17c24ef410357f03ad84f76 | 229805851c64d3c701dace5780a620848f09af8f | refs/heads/master | 2022-04-10T09:58:58.722939 | 2020-03-08T13:26:19 | 2020-03-08T13:26:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,808 | cpp | #include <bits/stdc++.h>
using namespace std;
#define NIL 0
bool bipartite(vector<vector<int>>& adj, vector<int>& color){
queue<int> q;
int v;
int u;
for(int i = 0; i < color.size(); i++){
if(color[i] == 0){
color[i] = 1;
q.push(i);
while (!q.empty())
{
v = q.front(); q.pop();
for(int j = 0; j < adj[v].size(); j++){
u = adj[v][j];
if(color[u] == color[v]) return false;
if(color[u] == 0){
color[u] = -color[v];
q.push(u);
}
}
}
}
}
return true;
}
bool BFS(vector<int>& U, vector<int>& Pair_U, vector<int>& Pair_V, vector<int>& dist, vector<vector<int>>& adj){
int u, v;
queue<int> q;
for(int i = 0; i < U.size(); i++){
u = U[i];
if(Pair_U[u] == NIL){
dist[u] = 0;
q.push(u);
}else{
dist[u] = INT_MAX;
}
}
dist[NIL] = INT_MAX;
while (!q.empty())
{
u = q.front(); q.pop();
if(dist[u] < dist[NIL]){
for(int i = 0; i < adj[u].size(); i++){
v = adj[u][i];
if(dist[Pair_V[v]] == INT_MAX){
dist[Pair_V[v]] = dist[u] + 1;
q.push(Pair_V[v]);
}
}
}
}
return dist[NIL] != INT_MAX;
}
bool DFS(int u,vector<int>& Pair_U,vector<int>& Pair_V, vector<vector<int>>& adj, vector<int>& dist){
int v;
if(u != NIL){
for(int i = 0; i < adj[u].size(); i++){
v = adj[u][i];
if(dist[Pair_V[v]] == dist[u]+1){
if(DFS(Pair_V[v], Pair_U, Pair_V, adj, dist)){
Pair_V[v] = u;
Pair_U[u] = v;
return true;
}
}
dist[u] = INT_MAX;
return false;
}
}
return true;
}
int Hopcroft_Karp(vector<vector<int>>& adj, int n){
vector<int> color(n+1, 0);
vector<int> dist(n+1);
vector<int> U;
vector<int> V;
int matching = 0;
if(bipartite(adj, color)){
for(int i = 1; i < color.size(); i++){
if(color[i] == -1){
U.push_back(i);
}
else
{
V.push_back(i);
}
}
vector<int> Pair_V(n+1);
vector<int> Pair_U(n+1);
for(int i = 1; i < U.size(); i++){
Pair_U[U[i]] = NIL;
}
for(int i = 1; i < V.size(); i++){
Pair_V[V[i]] = NIL;
}
int u = 0;
while (BFS(U, Pair_U, Pair_V, dist, adj) == true){
for(int i = 0; i < U.size(); i++){
u = U[i];
if(Pair_U[u] == NIL){
if(DFS(u,Pair_U, Pair_V,adj, dist)){
matching++;
}
}
}
}
}
return matching;
}
int main(){
int tmp;
string BWA;
cin>>BWA;
int n;
cin>>n;
int k;
cin>>k;
for(int i = 0; i < k; i++){
cin>>tmp;
}
int m;
int a, b;
cin>>m;
vector<pair<int, int>> edges;
vector<vector<int>> adj(n+1);
for(int i = 0; i < m; i++){
cin>>a; cin>>b;
adj[a+1].push_back(b+1);
adj[b+1].push_back(a+1);
}
cout<<Hopcroft_Karp(adj, n)<<endl;
}
// function Hopcroft-Karp
// for each u in U
// Pair_U[u] = NIL
// for each v in V
// Pair_V[v] = NIL
// matching = 0
// while BFS() == true
// for each u in U
// if Pair_U[u] == NIL
// if DFS(u) == true
// matching = matching + 1
// return matching
// function DFS (u)
// if u != NIL
// for each v in Adj[u]
// if Dist[ Pair_V[v] ] == Dist[u] + 1
// if DFS(Pair_V[v]) == true
// Pair_V[v] = u
// Pair_U[u] = v
// return true
// Dist[u] = ∞
// return false
// return true
// function BFS ()
// for each u in U
// if Pair_U[u] == NIL
// Dist[u] = 0
// Enqueue(Q,u)
// else
// Dist[u] = ∞
// Dist[NIL] = ∞
// while Empty(Q) == false
// u = Dequeue(Q)
// if Dist[u] < Dist[NIL]
// for each v in Adj[u]
// if Dist[ Pair_V[v] ] == ∞
// Dist[ Pair_V[v] ] = Dist[u] + 1
// Enqueue(Q,Pair_V[v])
// return Dist[NIL] != ∞
| [
"[email protected]"
] | |
de8e889c5a4ad5e44e33569c7a14cf73ab03ec50 | fee832dbf12036e3b892f07c825b26bd1402d1aa | /URI/uri2807.cpp | 2d3c3277dee306ee9048eadc02bb6d5d354c0c5d | [] | no_license | Iftekhar79/Competitve-Programming | 4e026f1d1a3dc707a4fd267cb2e45ae29a94a4b0 | f3125b9d652e13bd5811f9f900057a2ed6fb0c0d | refs/heads/master | 2020-05-01T06:39:48.560553 | 2020-04-11T08:45:32 | 2020-04-11T08:45:32 | 177,332,831 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 288 | cpp | #include<iostream>
using namespace std;
int main() {
int t,i;
cin>>t;
int v[t];
v[0]=1;
v[1]=1;
for(i=2;i<t;i++) {
v[i]=v[i-1]+v[i-2];
}
for(i=t-1;i>=0;i--)
cout<<v[i]<<" ";
cout<<endl;
return 0; }
| [
"[email protected]"
] | |
e48b87a59f5c323da5f234e54e743c80029404ca | f29c7a3851ca30ba2d7fcae88152151a47500a9e | /km.cpp | ea26ec6704a0550028e26ab3b5b6732a02ad8d84 | [] | no_license | EricAugusto769/C-_projects | e8e365d4621d429c023b04374827266578362f6b | 8942f1843322253e8bdc675d21878153fdd12467 | refs/heads/master | 2022-12-18T11:02:37.220214 | 2020-09-29T01:14:02 | 2020-09-29T01:14:02 | 299,468,636 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 650 | cpp | #include <stdio.h>
#include <stdlib.h>
main(){
float km,gas;
int tipo;
printf("Quantos km foram percorridos?:");
scanf("%f",&km);
printf("Qual tipo de carro foi utilizado? Digite 1 para carro A 2 para o B e 3 para o C: ");
scanf("%d",&tipo);
if (tipo==1){
gas=0.0833333333333333*km;
printf("Vpcê irá gastar aproximadamente nessa viagem %.2f litros\n",gas);
}
else if (tipo==2){
gas=0.1111111111111111*km;
printf("Você irá gastar aproximadamente nessa viagem %.2f litros\n",gas);
}
else if (tipo==3){
gas=0.125*km;
printf("Você irá gastar aproximadamente nessa viagem %.2f litros\n",gas);
}
system("pause");
}
| [
"[email protected]"
] | |
aef6da1461c896abb9e70ecfb16685d0b81c3bb5 | 90998e90caebf9514f727a3a6ae5310aaf4f5369 | /core/src/wallet/bitcoin/explorers/api/TransactionsParser.cpp | 5dcd57e60fe55c3ded54113fbdddc15ac2870b14 | [
"MIT"
] | permissive | luchenyuxx/lib-ledger-core | cdf527a025ee5ea0d3106a509ed11dc7614ff70e | c77c75ac2785b16fc6d4c6760dabc9ceabad8942 | refs/heads/master | 2020-04-08T15:39:28.054230 | 2018-10-22T16:06:34 | 2018-10-22T16:24:10 | 159,486,913 | 0 | 0 | MIT | 2018-11-28T10:50:10 | 2018-11-28T10:50:09 | null | UTF-8 | C++ | false | false | 4,114 | cpp | /*
*
* TransactionsParser
* ledger-core
*
* Created by Pierre Pollastri on 13/04/2017.
*
* The MIT License (MIT)
*
* Copyright (c) 2016 Ledger
*
* 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 "TransactionsParser.hpp"
#define PROXY_PARSE(method, ...) \
if (_arrayDepth > 0) { \
return _transactionParser.method(__VA_ARGS__); \
} else { \
return true; \
}
bool ledger::core::TransactionsParser::Null() {
PROXY_PARSE(Null)
}
bool ledger::core::TransactionsParser::Bool(bool b) {
PROXY_PARSE(Bool, b)
}
bool ledger::core::TransactionsParser::Int(int i) {
PROXY_PARSE(Int, i)
}
bool ledger::core::TransactionsParser::Uint(unsigned i) {
PROXY_PARSE(Uint, i)
}
bool ledger::core::TransactionsParser::Int64(int64_t i) {
PROXY_PARSE(Int64, i)
}
bool ledger::core::TransactionsParser::Uint64(uint64_t i) {
PROXY_PARSE(Uint64, i)
}
bool ledger::core::TransactionsParser::Double(double d) {
PROXY_PARSE(Double, d)
}
bool
ledger::core::TransactionsParser::RawNumber(const rapidjson::Reader::Ch *str, rapidjson::SizeType length, bool copy) {
PROXY_PARSE(RawNumber, str, length, copy)
}
bool ledger::core::TransactionsParser::String(const rapidjson::Reader::Ch *str, rapidjson::SizeType length, bool copy) {
PROXY_PARSE(String, str, length, copy)
}
bool ledger::core::TransactionsParser::StartObject() {
_objectDepth += 1;
if (_arrayDepth == 1 && _objectDepth == 1) {
BitcoinLikeBlockchainExplorer::Transaction transaction;
_transactions->push_back(transaction);
_transactionParser.init(&_transactions->back());
}
PROXY_PARSE(StartObject)
}
bool ledger::core::TransactionsParser::Key(const rapidjson::Reader::Ch *str, rapidjson::SizeType length, bool copy) {
PROXY_PARSE(Key, str, length, copy)
}
bool ledger::core::TransactionsParser::EndObject(rapidjson::SizeType memberCount) {
if (_arrayDepth > 0) {
_objectDepth -= 1;
auto result = _transactionParser.EndObject(memberCount);
return result;
} else {
return true;
}
}
bool ledger::core::TransactionsParser::StartArray() {
if (_arrayDepth > 0) {
_arrayDepth = _arrayDepth + 1;
return _transactionParser.StartArray();
} else {
_arrayDepth = _arrayDepth + 1;
return true;
}
}
bool ledger::core::TransactionsParser::EndArray(rapidjson::SizeType elementCount) {
_arrayDepth -= 1;
PROXY_PARSE(EndArray, elementCount)
return true;
}
ledger::core::TransactionsParser::TransactionsParser(std::string& lastKey) : _lastKey(lastKey), _transactionParser(lastKey) {
_arrayDepth = 0;
_objectDepth = 0;
}
void ledger::core::TransactionsParser::init(
std::vector<ledger::core::BitcoinLikeBlockchainExplorer::Transaction> *transactions) {
_transactions = transactions;
}
| [
"[email protected]"
] | |
ef8e832d42a6815f42513ab975fe6c408f7a0f3c | 729bd86b650644cb4dea77ca5f01c3b602223f9e | /src/problems/MagicSquare.hpp | 134d83be44c8ff5a4c1fbdaf36573003b8fbd760 | [] | no_license | sitrakafidi/CSPSolverCpp | 2e8042b606fd45d66a0252b955891cd458a004c9 | 7fecdf8f162819dc49fbf6b49dc30ebaa6859510 | refs/heads/master | 2021-01-19T10:19:38.965016 | 2017-03-26T11:34:48 | 2017-03-26T11:34:48 | 82,176,012 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 585 | hpp | #ifndef MAGICSQUARE_H
#define MAGICSQUARE_H
#include <vector>
#include "Problem.hpp"
#include "../solver/Solver.hpp"
#include "../constraints/AllDifferent.hpp"
#include "../constraints/Equation.hpp"
using namespace std;
class MagicSquare : public Problem{
private :
int N;
vector<string> variables;
vector<Constraint*> constraints;
Node* initialNode;
void initProblem();
public :
MagicSquare(int n);
void showSolutions(vector<Node> solutions);
virtual vector<string>* getVariables();
virtual vector<Constraint*>* getConstraints();
virtual Node* getInitialNode();
};
#endif | [
"[email protected]"
] | |
222249ffa265290461e6b441af9314020263e0d5 | 5ec0a5e4795919c58fda73ed0ad38c4ee3a9bb50 | /Step_10/spec/VoidPointersSpec.cpp | 3131e892ddc381f8c185ecd043a2ebf94d7cf58a | [] | no_license | ankitsumitg/mrnd-c | ff1d20f15291db010c7553fb454a9b2e6514ff4f | 2df73b1216937519dbf9848dffce89b0f16d6f47 | refs/heads/main | 2023-03-24T07:16:35.767485 | 2021-03-22T19:15:57 | 2021-03-22T19:15:57 | 350,459,436 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,376 | cpp | #include "stdafx.h"
#include "./../src/VoidPointers.cpp"
using namespace System;
using namespace System::Text;
using namespace System::Collections::Generic;
using namespace Microsoft::VisualStudio::TestTools::UnitTesting;
namespace spec
{
[TestClass]
public ref class VoidPointersSpec
{
private:
TestContext^ testContextInstance;
public:
/// <summary>
///Gets or sets the test context which provides
///information about and functionality for the current test run.
///</summary>
property Microsoft::VisualStudio::TestTools::UnitTesting::TestContext^ TestContext
{
Microsoft::VisualStudio::TestTools::UnitTesting::TestContext^ get()
{
return testContextInstance;
}
System::Void set(Microsoft::VisualStudio::TestTools::UnitTesting::TestContext^ value)
{
testContextInstance = value;
}
};
#pragma region Additional test attributes
#pragma endregion
[TestMethod(), Timeout(3000)]
void typeCastVoidToInt_Test()
{
int expected = 10;
void * ptr = (void *)&expected;
int actual = typeCastVoidToInt(ptr);
Assert::AreEqual(expected, actual, L"typeCastVoidToInt_Test 10 failed", 1, 2);
}
[TestMethod(), Timeout(3000)]
void typeCastVoidToInt_Test2()
{
int expected = 99923;
void * ptr = (void *)&expected;
int actual = typeCastVoidToInt(ptr);
Assert::AreEqual(expected, actual, L"typeCastVoidToInt_Test 99923 failed", 1, 2);
}
[TestMethod(), Timeout(3000)]
void compareIntTest()
{
int a1 = 999;
int a2 = 998;
int check = compareInt((void *)&a1, (void *)&a2);
Assert::AreEqual(1, check, L"999,998 shoudld return 1", 1, 2);
int a3 = 999;
int a4 = 999;
int check2 = compareInt((void *)&a3, (void *)&a4);
Assert::AreEqual(0, check2, L"999,999 shoudld return 0", 1, 2);
int a5 = 499;
int a6 = 998;
int check3 = compareInt((void *)&a5, (void *)&a6);
Assert::AreEqual(-1, check3, L"499,998 shoudld return -1", 1, 2);
}
[TestMethod(), Timeout(3000)]
void compareFloatTest()
{
float a1 = 999.98;
float a2 = 998.99;
int check = compareInt((void *)&a1, (void *)&a2);
Assert::AreEqual(1, check, L"999.98,998.99 shoudld return 1", 1, 2);
float a3 = 49.999;
float a4 = 49.999;
int check2 = compareInt((void *)&a3, (void *)&a4);
Assert::AreEqual(0, check2, L"49.999,49.999 shoudld return 0", 1, 2);
float a5 = 0.499;
float a6 = 45.345;
int check3 = compareInt((void *)&a5, (void *)&a6);
Assert::AreEqual(-1, check3, L"0.499,45.345 shoudld return -1", 1, 2);
}
[TestMethod(), Timeout(3000)]
void compareCharTest()
{
char a1 = 'z';
char a2 = 'a';
int check = compareInt((void *)&a1, (void *)&a2);
Assert::AreEqual(1, check, L"z,a shoudld return 1", 1, 2);
char a3 = 'b';
char a4 = 'b';
int check2 = compareInt((void *)&a3, (void *)&a4);
Assert::AreEqual(0, check2, L"b,b shoudld return 0", 1, 2);
char a5 = 'x';
char a6 = 'y';
int check3 = compareInt((void *)&a5, (void *)&a6);
Assert::AreEqual(-1, check3, L"x,y shoudld return -1", 1, 2);
}
[TestMethod(), Timeout(3000)]
void getGreater_TestUsingInts() {
int a1 = 999;
int a2 = 1998;
void * greater = getGreater((void *)&a1, (void *)&a2, &compareInt);
if (greater != (void *)&a2) {
//Intentionally failing test
Assert::AreEqual(1, 2, L"getGreater when passed 2 ints, is not returning correct address of greater value.Check type casting etc", 1, 2);
}
}
[TestMethod(), Timeout(3000)]
void getGreater_TestUsingFloats() {
float a1 = 9.99;
float a2 = 1.998;
void * greater = getGreater((void *)&a1, (void *)&a2, &compareFloat);
if (greater != (void *)&a1) {
//Intentionally failing test
Assert::AreEqual(1, 2, L"getGreater when passed 2 floats, is not returning correct address of greater value.Check type casting etc", 1, 2);
}
}
[TestMethod(), Timeout(30000)]
void getTwoGreater_TestUsingInts() {
int a1 = 999;
int a2 = 1998;
int a3 = 9999;
void * greatest = (void *)&a3;
void * greatest2 = (void *)&a2;
void ** result = getTwoGreater((void *)&a1, (void *)&a2,(void *)&a3, &compareInt);
if (result[0] != greatest) {
//Intentionally failing test
Assert::AreEqual(1, 2, L"getTWoGreater when passed 3 ints, is not returning correct address of greatest value for result[0].Assign correct addresses", 1, 2);
}
if (result[1] != greatest2) {
//Intentionally failing test
Assert::AreEqual(1, 2, L"getTWoGreater when passed 3 ints, is not returning correct address of 2nd greatest value for result[0].Assign correct addresses", 1, 2);
}
}
[TestMethod(), Timeout(30000)]
void getTwoGreater_TestUsingChars() {
char a1 = 'b';
char a2 = 'z';
char a3 = 'a';
void * greatest = (void *)&a2;
void * greatest2 = (void *)&a1;
void ** result = getTwoGreater((void *)&a1, (void *)&a2, (void *)&a3, &compareChar);
if (result[0] != greatest) {
//Intentionally failing test
Assert::AreEqual(1, 2, L"getTWoGreater when passed 3 chars, is not returning correct address of greatest value for result[0].Assign correct addresses", 1, 2);
}
if (result[1] != greatest2) {
//Intentionally failing test
Assert::AreEqual(1, 2, L"getTWoGreater when passed 3 chars, is not returning correct address of 2nd greatest value for result[0].Assign correct addresses", 1, 2);
}
}
};
}
| [
"[email protected]"
] | |
2dd3e236973bc438188bed0fc9793ab422a01e5e | 334c25f2cff04138756a12160c1e8211f977ef4d | /Calculator/Calculator/Operand.cpp | 302e9024ea0f476543bb14f38b7c41974a57e67c | [] | no_license | dlakwwkd/VisualCalculator | 717d1a92d797080f8f0246c2084c306f9af8d404 | 87de67c97059e862c7fe0387f98f41488c54c504 | refs/heads/master | 2021-01-18T18:41:50.982719 | 2017-03-20T17:38:44 | 2017-03-20T17:38:44 | 62,564,728 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,530 | cpp | #include "stdafx.h"
#include "Operand.h"
Operand::Operand(char _name)
: Object(_name)
{
}
Operand::~Operand()
{
}
double Operand::GetValue() const
{
auto number = const_cast<Operand*>(this);
if (number->IsInteger())
return static_cast<Int*>(number)->GetValue();
else
return static_cast<Float*>(number)->GetValue();
}
Int::Int(char _name, int _value)
: Operand(_name)
, value_(_value)
{
}
Int::Int(const std::shared_ptr<Operand>& _obj)
: Operand(_obj->GetName())
{
auto obj = dynamic_cast<Int*>(_obj.get());
value_ = obj->value_;
}
Int::~Int()
{
}
void Int::SetValue(const std::shared_ptr<Operand>& _source)
{
if (_source->IsInteger())
value_ = static_cast<Int*>(_source.get())->GetValue();
else
value_ = static_cast<int>(static_cast<Float*>(_source.get())->GetValue());
}
std::istream& Int::SetValue(std::istream& _input)
{
return _input >> value_;
}
Float::Float(char _name, float _value)
: Operand(_name)
, value_(_value)
{
}
Float::Float(const std::shared_ptr<Operand>& _obj)
: Operand(_obj->GetName())
{
auto obj = dynamic_cast<Float*>(_obj.get());
value_ = obj->value_;
}
Float::~Float()
{
}
void Float::SetValue(const std::shared_ptr<Operand>& _source)
{
if (_source->IsInteger())
value_ = static_cast<float>(static_cast<Int*>(_source.get())->GetValue());
else
value_ = static_cast<Float*>(_source.get())->GetValue();
}
std::istream& Float::SetValue(std::istream& _input)
{
return _input >> value_;
}
| [
"[email protected]"
] | |
a60332cf8b5a651eee213571509e6486957f841a | b7266f76ed29f8d40bdd0bbcf7b9fc1eceea4258 | /C++练习/仿函数.cpp | b58b385def85c4f14f19837af3398d642950393b | [] | no_license | Super-long/C- | 070eccb7961a1709278b7b0b8a1313a1b0740fe6 | 300ee60f3a75577e9e089431628c79fae76af55b | refs/heads/master | 2023-03-24T06:58:38.688174 | 2021-03-27T11:59:06 | 2021-03-27T11:59:06 | 197,859,951 | 6 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 600 | cpp | #include<bits/stdc++.h>
using namespace std;
class hello{
public:
int n =0;
void operator()(int &count){
n++;
cout << "n : " << n << " " << count << endl;
}
friend hello operator+(const int &a,const hello &b){
cout << a << endl;
return b;
}
};
int main(){
vector<int>vec = {1,2,3};
int x = vec.back();
int &d = vec.front();
cout << x << endl;
hello a;
auto dd = 5+a;
sort(vec.begin(),vec.end(),greater<int>());
hello h;
for_each(vec.begin(),vec.end(),h);
return 0;
} | [
"[email protected]"
] | |
49d58a7edda0d0bf611199d5cd78ca406a606d61 | 9999d3e61d598298a678424b034993ff146f1c9a | /Mirage/Pd/miragebox/Thread.cpp | 269b888229aec1c2dff2898ddf6aa6231f86aaac | [] | no_license | CICM/PotPourri | f5d467bc485c8c340b49bd894086460a8fa20b7d | a8257a0435fe9f45c2f45a696fe47107806b625b | refs/heads/master | 2020-04-09T19:11:20.822706 | 2014-07-12T06:42:48 | 2014-07-12T06:42:48 | 21,761,349 | 2 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 3,931 | cpp | /*
Copyright (c) 2009 Remy Muller.
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.
Any person wishing to distribute modifications to the Software is
requested to send the modifications to the original developer so that
they can be incorporated into the canonical version.
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 "Thread.h"
#include <cassert>
using namespace ZeroConf;
#ifdef WIN32
#undef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <process.h>
static unsigned int __stdcall threadEntryPoint (void* userData)
{
Thread::threadEntryPoint((Thread*)userData);
_endthreadex (0);
return 0;
}
static void *createThread(void *pUser)
{
unsigned int threadId;
return (void*) _beginthreadex (0, 0, &threadEntryPoint, pUser, 0, &threadId);
}
static void killThread(void *pHandle)
{
if (pHandle != 0)
{
TerminateThread (pHandle, 0);
}
}
static void threadSleep(int ms)
{
Sleep(ms);
}
static void closeThread(void *pHandle)
{
CloseHandle ((HANDLE) pHandle);
}
#else
static void *threadEntryPoint(void *pUser)
{
//const ScopedAutoReleasePool pool;
Thread::threadEntryPoint((Thread*)pUser);
return NULL;
}
static void *createThread(void *pUser)
{
pthread_t handle = 0;
if (pthread_create (&handle, 0, threadEntryPoint, pUser) == 0)
{
pthread_detach (handle);
return (void*) handle;
}
return 0;
}
static void killThread(void *pHandle)
{
if (pHandle != NULL)
pthread_cancel ((pthread_t) pHandle);
}
static void threadSleep(int ms)
{
struct timespec time;
time.tv_sec = ms / 1000;
time.tv_nsec = (ms % 1000) * 1000000;
nanosleep (&time, 0);
}
static void closeThread(void *pHandle)
{
// nothing to do on posix
}
#endif
Thread::Thread()
: mpThreadHandle(NULL)
, mShouldExit(false)
{
}
Thread::~Thread()
{
stopThread(100);
}
void Thread::startThread()
{
const ScopedLock lock(mCriticalSection);
mShouldExit = false;
if(mpThreadHandle == NULL)
{
mpThreadHandle = createThread(this);
}
}
void Thread::stopThread(const int timeOut)
{
const ScopedLock lock(mCriticalSection);
if(isThreadRunning())
{
setThreadShouldExit();
// notify
if(timeOut != 0)
waitForThreadToExit(timeOut);
if(isThreadRunning())
{
killThread(mpThreadHandle);
mpThreadHandle = NULL;
}
}
}
bool Thread::isThreadRunning() const
{
return mpThreadHandle != NULL;
}
bool Thread::threadShouldExit() const
{
return mShouldExit;
}
void Thread::setThreadShouldExit()
{
mShouldExit = true;
}
bool Thread::waitForThreadToExit(const int timeOut)
{
int count = timeOut;
while (isThreadRunning()) {
if(timeOut>0 && --count < 0)
return false;
sleep(1);
}
return true;
}
void Thread::sleep(int ms)
{
threadSleep(ms);
}
void Thread::threadEntryPoint(Thread *pThread)
{
pThread->run();
closeThread(pThread->mpThreadHandle);
pThread->mpThreadHandle = NULL;
}
| [
"[email protected]"
] | |
9698ad4e6619d222d9fb7da003cd02cab6e682b0 | cb10193095b0658cd6041c0a1048abd82103ce91 | /examples/pppbayestree/gpstk/PhaseCodeAlignment.cpp | c260f9ca9c17ca68366515bb3db5a1713d09b8e3 | [
"BSD-3-Clause",
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | chengwei920412/minisam_lib | 41c810471306badf862cecd2a4d1f1b383aa54a0 | e2e904d1b6753976de1dee102f0b53e778c0f880 | refs/heads/master | 2023-03-17T09:36:35.679579 | 2020-03-15T05:52:35 | 2020-03-15T05:52:35 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,472 | cpp | //============================================================================
//
// This file is part of GPSTk, the GPS Toolkit.
//
// The GPSTk is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 3.0 of the License, or
// any later version.
//
// The GPSTk is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with GPSTk; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
//
// Copyright 2004, The University of Texas at Austin
// Dagoberto Salazar - gAGE ( http://www.gage.es ). 2007, 2008, 2011
//
//============================================================================
//============================================================================
//
//This software developed by Applied Research Laboratories at the University of
//Texas at Austin, under contract to an agency or agencies within the U.S.
//Department of Defense. The U.S. Government retains all rights to use,
//duplicate, distribute, disclose, or release this software.
//
//Pursuant to DoD Directive 523024
//
// DISTRIBUTION STATEMENT A: This software has been approved for public
// release, distribution is unlimited.
//
//=============================================================================
/**
* @file PhaseCodeAlignment.cpp
* This class aligns phase with code measurements.
*/
#include "../gpstk/PhaseCodeAlignment.hpp"
namespace gpstk
{
// Returns a string identifying this object.
std::string PhaseCodeAlignment::getClassName() const
{
return "PhaseCodeAlignment";
}
/* Common constructor
*
* @param phase Phase TypeID.
* @param code Code TypeID.
* @param wavelength Phase wavelength, in meters.
* @param useArc Whether satellite arcs will be used or not.
*/
PhaseCodeAlignment::PhaseCodeAlignment( const TypeID& phase,
const TypeID& code,
const double wavelength,
bool useArc )
: phaseType(phase), codeType(code), useSatArcs(useArc),
watchCSFlag(TypeID::CSL1)
{
// Set the wavelength
setPhaseWavelength(wavelength);
} // End of 'PhaseCodeAlignment::PhaseCodeAlignment()'
/* Method to set the phase wavelength to be used.
*
* @param wavelength Phase wavelength, in meters.
*/
PhaseCodeAlignment& PhaseCodeAlignment::setPhaseWavelength(double wavelength)
{
// Check that wavelength is bigger than zero
if (wavelength > 0.0)
{
phaseWavelength = wavelength;
}
else
{
phaseWavelength = 0.1069533781421467; // Be default, LC wavelength
}
return (*this);
} // End of 'PhaseCodeAlignment::setPhaseWavelength()'
/* Returns a satTypeValueMap object, adding the new data generated
* when calling this object.
*
* @param epoch Time of observations.
* @param gData Data object holding the data.
*/
satTypeValueMap& PhaseCodeAlignment::Process( const CommonTime& epoch,
satTypeValueMap& gData )
throw(ProcessingException)
{
try
{
SatIDSet satRejectedSet;
// Loop through all the satellites
for( satTypeValueMap::iterator it = gData.begin();
it != gData.end();
++it )
{
// Check if satellite currently has entries
std::map<SatID, alignData>::const_iterator itDat(
svData.find( (*it).first ) );
if( itDat == svData.end() )
{
// If it doesn't have an entry, insert one
alignData aData;
svData[ (*it).first ] = aData;
}
// Place to store if there was a cycle slip. False by default
bool csflag(false);
// Check if we want to use satellite arcs of cycle slip flags
if(useSatArcs)
{
double arcN(0.0);
try
{
// Try to extract the satellite arc value
arcN = (*it).second(TypeID::satArc);
}
catch(...)
{
// If satellite arc is missing, then schedule this
// satellite for removal
satRejectedSet.insert( (*it).first );
continue;
}
// Check if satellite arc has changed
if( svData[(*it).first].arcNumber != arcN )
{
// Set flag
csflag = true;
// Update satellite arc information
svData[(*it).first].arcNumber = arcN;
}
} // End of first part of 'if(useSatArcs)'
else
{
double flag(0.0);
try
{
// Try to extract the CS flag value
flag = (*it).second(watchCSFlag);
}
catch(...)
{
// If flag is missing, then schedule this satellite
// for removal
satRejectedSet.insert( (*it).first );
continue;
}
// Check if there was a cycle slip
if( flag > 0.0)
{
// Set flag
csflag = true;
}
} // End of second part of 'if(useSatArcs)...'
// If there was an arc change or cycle slip, let's
// compute the new offset
if(csflag)
{
// Compute difference between code and phase measurements
double diff( (*it).second(codeType) - (*it).second(phaseType) );
// Convert 'diff' to cycles
diff = diff/phaseWavelength;
// Convert 'diff' to an INTEGER number of cycles
diff = std::floor(diff);
// The new offset is the INTEGER number of cycles, in meters
svData[(*it).first].offset = diff * phaseWavelength;
}
// Let's align the phase measurement using the
// corresponding offset
(*it).second[phaseType] = (*it).second[phaseType]
+ svData[(*it).first].offset;
}
// Remove satellites with missing data
gData.removeSatID(satRejectedSet);
return gData;
}
catch(Exception& u)
{
// Throw an exception if something unexpected happens
ProcessingException e( getClassName() + ":"
+ u.what() );
GPSTK_THROW(e);
}
} // End of 'PhaseCodeAlignment::Process()'
/* Returns a gnnsSatTypeValue object, adding the new data generated
* when calling this object.
*
* @param gData Data object holding the data.
*/
gnssSatTypeValue& PhaseCodeAlignment::Process(gnssSatTypeValue& gData)
throw(ProcessingException)
{
try
{
Process(gData.header.epoch, gData.body);
return gData;
}
catch(Exception& u)
{
// Throw an exception if something unexpected happens
ProcessingException e( getClassName() + ":"
+ u.what() );
GPSTK_THROW(e);
}
} // End of 'PhaseCodeAlignment::Process()'
/* Returns a gnnsRinex object, adding the new data generated when
* calling this object.
*
* @param gData Data object holding the data.
*/
gnssRinex& PhaseCodeAlignment::Process(gnssRinex& gData)
throw(ProcessingException)
{
try
{
Process(gData.header.epoch, gData.body);
return gData;
}
catch(Exception& u)
{
// Throw an exception if something unexpected happens
ProcessingException e( getClassName() + ":"
+ u.what() );
GPSTK_THROW(e);
}
} // End of 'PhaseCodeAlignment::Process()'
} // End of namespace gpstk
| [
"[email protected]"
] | |
db6a7a5aae42ea1bd3cf0363a4aec911ece7f9b6 | a1fbf16243026331187b6df903ed4f69e5e8c110 | /cs/engine/xrGame/UI.h | feba4a5d4ff8345568853c30cfdd74ba6891cc71 | [
"LicenseRef-scancode-warranty-disclaimer",
"BSD-2-Clause"
] | permissive | OpenXRay/xray-15 | ca0031cf1893616e0c9795c670d5d9f57ca9beff | 1390dfb08ed20997d7e8c95147ea8e8cb71f5e86 | refs/heads/xd_dev | 2023-07-17T23:42:14.693841 | 2021-09-01T23:25:34 | 2021-09-01T23:25:34 | 23,224,089 | 64 | 23 | NOASSERTION | 2019-04-03T17:50:18 | 2014-08-22T12:09:41 | C++ | UTF-8 | C++ | false | false | 1,149 | h | #pragma once
#include "UICursor.h"
#include "UIDialogHolder.h"
// refs
class CHUDManager;
class CUIGameCustom;
class CUIMainIngameWnd;
class CUIMessagesWindow;
struct SDrawStaticStruct;
class CUI : public CDialogHolder
{
CUIGameCustom* pUIGame;
bool m_bShowGameIndicators;
public:
CHUDManager* m_Parent;
CUIMainIngameWnd* UIMainIngameWnd;
CUIMessagesWindow* m_pMessagesWnd;
public:
CUI (CHUDManager* p);
virtual ~CUI ();
bool Render ();
void UIOnFrame ();
void Load (CUIGameCustom* pGameUI);
void UnLoad ();
bool IR_OnKeyboardHold (int dik);
bool IR_OnKeyboardPress (int dik);
bool IR_OnKeyboardRelease (int dik);
bool IR_OnMouseMove (int,int);
bool IR_OnMouseWheel (int direction);
CUIGameCustom* UIGame () {return pUIGame;}
void ShowGameIndicators (bool b);
bool GameIndicatorsShown () {return m_bShowGameIndicators;};
void ShowCrosshair (bool b);
bool CrosshairShown ();
SDrawStaticStruct* AddInfoMessage (LPCSTR message);
void OnConnected ();
void UpdatePda ();
};
| [
"[email protected]"
] | |
8fd5372a54b50f7c7d20eb75d37f7004303616a4 | 5e8d200078e64b97e3bbd1e61f83cb5bae99ab6e | /main/source/src/protocols/ligand_docking/Rotates.fwd.hh | 0041a1ef0c2b545ccf109cb89fdc1f4eb2f4f880 | [] | no_license | MedicaicloudLink/Rosetta | 3ee2d79d48b31bd8ca898036ad32fe910c9a7a28 | 01affdf77abb773ed375b83cdbbf58439edd8719 | refs/heads/master | 2020-12-07T17:52:01.350906 | 2020-01-10T08:24:09 | 2020-01-10T08:24:09 | 232,757,729 | 2 | 6 | null | null | null | null | UTF-8 | C++ | false | false | 1,229 | hh | // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
// vi: set ts=2 noet:
//
// (c) Copyright Rosetta Commons Member Institutions.
// (c) This file is part of the Rosetta software suite and is made available under license.
// (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
// (c) For more information, see http://www.rosettacommons.org. Questions about this can be
// (c) addressed to University of Washington CoMotion, email: [email protected].
/// @file protocols/ligand_docking/Rotates.hh
///
/// @brief
/// @author Ian W. Davis
#ifndef INCLUDED_protocols_ligand_docking_Rotates_fwd_hh
#define INCLUDED_protocols_ligand_docking_Rotates_fwd_hh
#include <utility/pointer/owning_ptr.hh>
#include <utility/vector1.hh>
namespace protocols {
namespace ligand_docking {
class Rotates; // fwd declaration
typedef utility::pointer::shared_ptr< Rotates > RotatesOP;
typedef utility::pointer::shared_ptr< Rotates const > RotatesCOP;
typedef utility::vector1<RotatesOP> RotatesOPs;
typedef utility::vector1<RotatesCOP> RotatesCOPs;
} // namespace ligand_docking
} // namespace protocols
#endif // INCLUDED_protocols_ligand_docking_Rotates_HH
| [
"[email protected]"
] | |
ef5410f741b6375816d7fe32aa9e5f86efb20235 | 094d51676ae6ef83fcc67381b5c9dfa92243cf3f | /Win32Project1/inputclass.h | 099249e3b4b9fab9fc589019608a193d01703a6f | [] | no_license | jobsanta/LeapCalibration | e1ae0a4101646a154716cc008748ce80a4e0896a | cdc61c99b9d65f64663479a4dee8795d3c2600d9 | refs/heads/master | 2020-04-06T06:25:39.898449 | 2017-08-30T07:26:47 | 2017-08-30T07:26:47 | 73,818,076 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,079 | h | ////////////////////////////////////////////////////////////////////////////////
// Filename: inputclass.h
////////////////////////////////////////////////////////////////////////////////
#ifndef _INPUTCLASS_H_
#define _INPUTCLASS_H_
///////////////////////////////
// PRE-PROCESSING DIRECTIVES //
///////////////////////////////
#define DIRECTINPUT_VERSION 0x0800
/////////////
// LINKING //
/////////////
#pragma comment(lib, "dinput8.lib")
#pragma comment(lib, "dxguid.lib")
//////////////
// INCLUDES //
//////////////
#include <dinput.h>
////////////////////////////////////////////////////////////////////////////////
// Class name: InputClass
////////////////////////////////////////////////////////////////////////////////
class InputClass
{
public:
InputClass();
InputClass(const InputClass&);
~InputClass();
bool Initialize(HINSTANCE, HWND, int, int);
void Shutdown();
bool Frame();
bool IsCPressed();
bool IsPPressed();
bool IsBPressed();
bool IsQPressed();
bool IsOPressed();
bool IsEscapePressed();
bool IsUpPressed();
bool IsDownPressed();
bool IsPageDownPressed();
bool IsNumpad1Pressed();
bool IsNumpad2Pressed();
bool IsNumpad3Pressed();
bool IsNumpad4Pressed();
bool IsNumpad6Pressed();
bool IsNumpad7Pressed();
bool IsNumpad8Pressed();
bool IsNumpad9Pressed();
bool IsaltPressed();
bool IsPageUpPressed();
bool IsIPressed();
bool IsMPressed();
bool IsLessPressed();
bool IsGPressed();
bool IsOnePressed();
bool IsTwoPressed();
bool IsThreePressed();
bool IsFourPressed();
bool IsFivePressed();
bool IsSixPressed();
bool IsSevenPressed();
bool IsSpacePressed();
bool IsLeftPressed();
bool IsRightPressed();
bool IsLeftMouseButtonDown();
void GetMouseLocation(int&, int&);
private:
bool ReadKeyboard();
bool ReadMouse();
void ProcessInput();
private:
IDirectInput8* m_directInput;
IDirectInputDevice8* m_keyboard;
IDirectInputDevice8* m_mouse;
unsigned char m_keyboardState[256];
DIMOUSESTATE m_mouseState;
int m_screenWidth, m_screenHeight;
int m_mouseX, m_mouseY;
WORD pressKey = 0;
};
#endif | [
"[email protected]"
] | |
db54efd12dc275b1e3b42f6674dfae8bdd3b8c5d | c61fbe2225ff24b61a93ad354bf248f67a09c49d | /src/iostreams.cpp | 1554e5feb81ec3eae54c7b33bb4b022c1b0153a6 | [] | no_license | Diyuse/learning-cpp | 4e383007b7080bf682eb9188c6496d42ddb8a0e8 | 55f0b2252ca711d9235c0f7189c2339adf6b2c93 | refs/heads/master | 2023-06-19T12:08:16.605605 | 2021-07-19T00:53:45 | 2021-07-19T00:53:45 | 245,736,846 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,658 | cpp | #include <cstdlib> // Import c standard library
#include <iostream> // Import read and write data
#include <string> // Import working with strings
#include <limits> // Import to get min and max values of datatypes
#include <vector> // Import vectors
#include <sstream> // Import string streams
#include <numeric> // Import working with sequences of values
#include <ctime> // Import working with time
#include <cmath> // Import math functions
#include <fstream> // Import for files
#include <algorithm> // Need to include this for sort
#include "../inc/TestHeader.h"
using namespace std;
int main(int argc, char** argv){
ofstream writeToFile;
ifstream readFromFile;
string txtToWrite = "";
string txtFromFile = "";
// Looks for or creates the "text.txt" file.
// ios_base::app, appends to the end of the file.
// ios_base::trunc, if file already exists, deletes content and overwrite.
// ios_base::in, open as read mode.
// ios_base::ate, At The End, moves cursor to EOF.
// ios_base::out, open as write mode.
writeToFile.open("text.txt", ios_base::out | ios_base::trunc);
if(writeToFile.is_open()){
writeToFile << "Beginning of File\n";
cout << "Enter data to write: ";
getline(cin, txtToWrite);
writeToFile << txtToWrite;
writeToFile.close(); // Close file when done.
}
readFromFile.open("text.txt", ios_base::in);
if(readFromFile.is_open()){
while(readFromFile.good()){
getline(readFromFile, txtFromFile);
cout << txtFromFile << endl;
}
readFromFile.close();
}
WaitForInput();
return 0;
} | [
"[email protected]"
] | |
9bb24279290619c833df93dc1214fe43730be5b1 | 1341ebf56cee66f15431236c74e8bb1db02558ac | /ash/wm/desks/desk_mini_view.h | faeb7ea8d6fe327558c6fb1f481f6bfff3f9f2c0 | [
"BSD-3-Clause"
] | permissive | nerdooit/chromium | 41584349b52e0b941ec45ebb5ba5695268e5872f | de77d445d3428ef72455c3b0d9be7e050d447135 | refs/heads/master | 2023-01-11T20:03:40.846099 | 2020-01-25T12:45:08 | 2020-01-25T12:45:08 | 236,195,538 | 1 | 0 | BSD-3-Clause | 2020-01-25T16:25:12 | 2020-01-25T16:25:11 | null | UTF-8 | C++ | false | false | 4,222 | h | // Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_WM_DESKS_DESK_MINI_VIEW_H_
#define ASH_WM_DESKS_DESK_MINI_VIEW_H_
#include <memory>
#include "ash/ash_export.h"
#include "ash/wm/desks/desk.h"
#include "ash/wm/overview/overview_highlight_controller.h"
#include "base/macros.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/label.h"
namespace ash {
class CloseDeskButton;
class DesksBarView;
class DeskPreviewView;
// A view that acts as a mini representation (a.k.a. desk thumbnail) of a
// virtual desk in the desk bar view when overview mode is active. This view
// shows a preview of the contents of the associated desk, its title, and
// supports desk activation and removal.
class ASH_EXPORT DeskMiniView
: public views::Button,
public views::ButtonListener,
public Desk::Observer,
public OverviewHighlightController::OverviewHighlightableView {
public:
DeskMiniView(DesksBarView* owner_bar,
aura::Window* root_window,
Desk* desk,
const base::string16& title);
~DeskMiniView() override;
aura::Window* root_window() { return root_window_; }
Desk* desk() { return desk_; }
const CloseDeskButton* close_desk_button() const {
return close_desk_button_;
}
void SetTitle(const base::string16& title);
// Returns the associated desk's container window on the display this
// mini_view resides on.
aura::Window* GetDeskContainer() const;
// Updates the visibility state of the close button depending on whether this
// view is mouse hovered.
void OnHoverStateMayHaveChanged();
// Gesture tapping may affect the visibility of the close button. There's only
// one mini_view that shows the close button on long press at any time.
// This is useful for touch-only UIs.
void OnWidgetGestureTap(const gfx::Rect& screen_rect, bool is_long_gesture);
// Updates the border color of the DeskPreviewView based on the activation
// state of the corresponding desk.
void UpdateBorderColor();
// views::Button:
const char* GetClassName() const override;
void Layout() override;
gfx::Size CalculatePreferredSize() const override;
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
// views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
// Desk::Observer:
void OnContentChanged() override;
void OnDeskDestroyed(const Desk* desk) override;
// OverviewHighlightController::OverviewHighlightableView:
views::View* GetView() override;
void MaybeActivateHighlightedView() override;
void MaybeCloseHighlightedView() override;
void OnViewHighlighted() override;
void OnViewUnhighlighted() override;
bool IsPointOnMiniView(const gfx::Point& screen_location) const;
// Gets the minimum width of this view to properly lay out all its contents in
// default layout.
// The view containing this object can use the width returned from this
// function to decide its own proper size or layout.
int GetMinWidthForDefaultLayout() const;
bool IsLabelVisibleForTesting() const { return label_->GetVisible(); }
const DeskPreviewView* GetDeskPreviewForTesting() const {
return desk_preview_.get();
}
private:
void OnCloseButtonPressed();
DesksBarView* const owner_bar_;
// The root window on which this mini_view is created.
aura::Window* root_window_;
// The associated desk. Can be null when the desk is deleted before this
// mini_view completes its removal animation. See comment above
// OnDeskRemoved().
Desk* desk_; // Not owned.
// The view that shows a preview of the desk contents.
std::unique_ptr<DeskPreviewView> desk_preview_;
// The desk title.
views::Label* label_;
// The close button that shows on hover.
CloseDeskButton* close_desk_button_;
// We force showing the close button when the mini_view is long pressed or
// tapped using touch gestures.
bool force_show_close_button_ = false;
DISALLOW_COPY_AND_ASSIGN(DeskMiniView);
};
} // namespace ash
#endif // ASH_WM_DESKS_DESK_MINI_VIEW_H_
| [
"[email protected]"
] | |
4c1bc68b9797bd41f2641b4dc2bdd073f8ea9fc2 | b28305dab0be0e03765c62b97bcd7f49a4f8073d | /content/common/origin_util.cc | 2b15f6177758eb41cf3ea4dddfdad967d0458a64 | [
"BSD-3-Clause"
] | permissive | svarvel/browser-android-tabs | 9e5e27e0a6e302a12fe784ca06123e5ce090ced5 | bd198b4c7a1aca2f3e91f33005d881f42a8d0c3f | refs/heads/base-72.0.3626.105 | 2020-04-24T12:16:31.442851 | 2019-08-02T19:15:36 | 2019-08-02T19:15:36 | 171,950,555 | 1 | 2 | NOASSERTION | 2019-08-02T19:15:37 | 2019-02-21T21:47:44 | null | UTF-8 | C++ | false | false | 2,709 | cc | // Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/public/common/origin_util.h"
#include "base/lazy_instance.h"
#include "base/macros.h"
#include "base/stl_util.h"
#include "base/strings/pattern.h"
#include "content/common/url_schemes.h"
#include "net/base/url_util.h"
#include "url/gurl.h"
#include "url/url_util.h"
namespace {
// This function partially reflects the result from SecurityOrigin::isUnique,
// not its actual implementation. It takes into account how
// SecurityOrigin::create might return unique origins for URLs whose schemes are
// included in SchemeRegistry::shouldTreatURLSchemeAsNoAccess.
bool IsOriginUnique(const url::Origin& origin) {
return origin.opaque() ||
base::ContainsValue(url::GetNoAccessSchemes(), origin.scheme());
}
bool IsWhitelistedSecureOrigin(const url::Origin& origin) {
if (base::ContainsValue(content::GetSecureOriginsAndPatterns(),
origin.Serialize()))
return true;
for (const auto& origin_or_pattern : content::GetSecureOriginsAndPatterns()) {
if (base::MatchPattern(origin.host(), origin_or_pattern))
return true;
}
return false;
}
} // namespace
namespace content {
bool IsOriginSecure(const GURL& url) {
if (url.SchemeIsCryptographic() || url.SchemeIsFile())
return true;
if (url.SchemeIsFileSystem() && url.inner_url() &&
IsOriginSecure(*url.inner_url())) {
return true;
}
if (net::IsLocalhost(url))
return true;
if (base::ContainsValue(url::GetSecureSchemes(), url.scheme()))
return true;
return IsWhitelistedSecureOrigin(url::Origin::Create(url));
}
bool OriginCanAccessServiceWorkers(const GURL& url) {
if (url.SchemeIsHTTPOrHTTPS() && IsOriginSecure(url))
return true;
if (base::ContainsValue(GetServiceWorkerSchemes(), url.scheme())) {
return true;
}
return false;
}
bool IsPotentiallyTrustworthyOrigin(const url::Origin& origin) {
// Note: Considering this mirrors SecurityOrigin::isPotentiallyTrustworthy, it
// assumes m_isUniqueOriginPotentiallyTrustworthy is set to false. This
// implementation follows Blink's default behavior but in the renderer it can
// be changed per instance by calls to
// SecurityOrigin::setUniqueOriginIsPotentiallyTrustworthy.
if (IsOriginUnique(origin))
return false;
if (base::ContainsValue(url::GetSecureSchemes(), origin.scheme()) ||
base::ContainsValue(url::GetLocalSchemes(), origin.scheme()) ||
net::IsLocalhost(origin.GetURL())) {
return true;
}
return IsWhitelistedSecureOrigin(origin);
}
} // namespace content
| [
"[email protected]"
] | |
ce823bf1ac1899a68f75171ddfcc2448d8755f59 | 9d76a11f9420d8e08d5f2a8474b17df0f38bab2e | /p2psh/xshcli.h | 3e6ee643de38227f866d90ffe262ab12e499bb80 | [] | no_license | luhan/doxsh | e0555a2e8125dcddf828371ddba1fcc6b2eb12e0 | ba27702e98719fbaeec9dbac0ec9dff70798dc21 | refs/heads/master | 2021-05-11T04:11:02.395589 | 2016-05-21T03:55:40 | 2016-05-21T03:55:40 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,122 | h | #ifndef _XSHCLI_H_
#define _XSHCLI_H_
#include <QtCore>
#include <QtNetwork>
#include "peersrv.h"
class Srudp;
class XshCli : public PeerSrv
{
Q_OBJECT;
public:
XshCli();
virtual ~XshCli();
virtual void init();
public slots:
virtual void onRelayReadyRead();
void onAllocateDone(QString relayed_addr);
void onCreatePermissionDone();
// void onChannelBindDone(QString relayed_addr);
void onPacketRecieved(QByteArray pkt, QHostAddress host, quint16 port);
void onPacketReadyRead();
void onNewBackendConnection();
void onBackendReadyRead();
void onBackendDisconnected();
void onRudpConnected();
void onRudpConnectError();
protected:
virtual QString getRegCmd();
private:
QTcpServer *m_backend_sock = NULL;
QTcpSocket *m_conn_sock = NULL;
QString m_relayed_addr = NULL;
QString m_peer_addr;
// QString m_peer_relayed_addr;
// bool m_channel_done = false;
bool m_perm_done = false;
Srudp *m_rudp = NULL;
// for backend
qint64 m_send_data_len = 0;
qint64 m_recv_data_len = 0;
};
#endif /* _XSHCLI_H_ */
| [
"[email protected]"
] | |
c34870e02f68c8bd03f15ac1cff976a2bfd23c06 | 8200360b14e7bdcf9e1ecd025b755dafc33dc592 | /src/openanim/Hierarchy.h | e5328ea8467838c427c209e6eed0bddd9a7cc400 | [
"MIT"
] | permissive | mcanthony/openanim | 6ea1511c459db91e33d04c1e3b8352fb22e0a6d4 | 760695a37d8d592dbf3fd5f7f1506f6e7de2fc88 | refs/heads/develop | 2020-12-03T03:36:33.900464 | 2015-09-30T21:49:16 | 2015-09-30T21:49:16 | 43,944,335 | 2 | 0 | null | 2015-10-09T08:57:56 | 2015-10-09T08:57:55 | C++ | UTF-8 | C++ | false | false | 1,195 | h | #pragma once
#include <vector>
#include <string>
#include <boost/noncopyable.hpp>
#include "Children.h"
namespace openanim {
/// Hierarchy class describes a hierarchy of transformations (skeleton) as a flat array of named Joint
/// objects. It guarantees that the index of parent joint is always lower than index of children joints,
/// allowing for replacing recursive operations (e.g, world-to-local conversion) to simple iterations.
/// The internal representation of joint data might change in the future (the interface will probably not).
class Hierarchy {
public:
struct Item {
std::string name;
int parent;
std::size_t children_begin, children_end;
};
const Item& operator[](std::size_t index) const;
bool empty() const;
size_t size() const;
void addRoot(const std::string& name);
std::size_t addChild(const Item& i, const std::string& name);
typedef std::vector<Item>::const_iterator const_iterator;
const_iterator begin() const;
const_iterator end() const;
typedef std::vector<Item>::iterator iterator;
iterator begin();
iterator end();
protected:
private:
std::size_t indexOf(const Item& j) const;
std::vector<Item> m_items;
};
}
| [
"[email protected]"
] | |
601b2aab750b2a2425968e8482459d96ca10c9a5 | 38b2802949f93896c8d1c6ad920a3c7f63dceb88 | /Math/Vector/Vector.h | 90162aa86df7ef3db0df98cb06bb25c4ca3dbfa8 | [] | no_license | zarath8128/NumericalAnalysis | 327b8fa665621fd1c492e9cf3af20877dd43cf31 | 792f18df9bcc4aa4f02cc02ef3a722065673096e | refs/heads/master | 2020-05-31T05:46:57.769023 | 2013-12-01T05:29:00 | 2013-12-01T05:29:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 482 | h | #ifndef ZARATH_MATH_VECTOR_VECTOR_H
#define ZARATH_MATH_VECTOR_VECTOR_H
#include "Vector_base.hpp"
#include <iostream>
namespace zarath
{
namespace Vector
{
class Vector
:Vector_base<double>
{
public:
Vector(unsigned int len):len(len), buf(new double[len]){}
double &operator()(int i){return buf[i];}
int length(){return len;}
private:
double *buf;
const unsigned int len;
};
std::ostream &operator<<(std::ostream &dest, Vector &v);
}
}
#endif
| [
"okamoto@portable-debian"
] | okamoto@portable-debian |
77f261c2459d874a80a72ed450687c327d1f7131 | c1fbfe0f0739c30ef103a9b6189bcb00c0e099c2 | /IoT/mqtt/bedroom2_node/bedroom2_node.ino | 303ba21d1427d549fec57ae1a6f65e8634d69d11 | [] | no_license | aditya6700/smart_home | c530558af15f137c03192b5082cecd090600a203 | a9919dd065184bd6868ae467a283f61829ca509e | refs/heads/master | 2023-02-06T10:45:32.871294 | 2020-12-27T08:42:16 | 2020-12-27T08:42:16 | 298,300,612 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,423 | ino | /******************** NodeMCU **********************/
/************ Including Libraries *************/
#include <ESP8266WiFi.h>
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"
#include <ArduinoJson.h>
//#include <TaskScheduler.h>
#include <DHT.h>
/*************************** Custom Functions Defined ************************************/
void MQTT_connect(); // mqtt connection
void SendData(); // user defined function for taaskscheduler
float Humidity();
float Teperature();
int Sensor1();
int Sensor2();
void SubData();
/**************** Task Scheduler *****************/
//Scheduler runner; // We create the Scheduler that will be in charge of managing the tasks
//#define TimeInterval 3
//Scheduler runner2; // We create the Scheduler that will be in charge of managing the tasks
//#define TimeInterval2 1
//#define _TASK_SLEEP_ON_IDLE_RUN // energy saving mode
// We create the task indicating that it runs every 3 minutes, forever, and call the SendData function
//Task living(TASK_MINUTE * TimeInterval , TASK_FOREVER, &SendData);
//Task living1(TASK_SECOND * TimeInterval2 , TASK_FOREVER, &Subdata);
/**************** DHT Sensor *****************/
#define DHTPIN 5 //D1 //pin where the dht11 is connected
DHT dht(DHTPIN, DHT11);
/************************* WiFi Access Point and MQTT server *********************************/
#define WLAN_SSID "Area 51"
#define WLAN_PASS "WF647241BB1"
#define MQTT_SERVER "192.168.0.193" // static ip address of Raspi
#define MQTT_PORT 1883
#define MQTT_USERNAME ""
#define MQTT_PASSWORD ""
/************ Global State ******************/
// Create an ESP8266 WiFiClient class to connect to the MQTT server.
WiFiClient client;
// Setup the MQTT client class by passing in the WiFi client and MQTT server and login details.
Adafruit_MQTT_Client mqtt(&client, MQTT_SERVER, MQTT_PORT, MQTT_USERNAME, MQTT_PASSWORD);
/****************************** Feeds ***************************************/
// Notice MQTT paths for AIO follow the form: <username>/feeds/<feedname>
Adafruit_MQTT_Publish bedroom2_pub = Adafruit_MQTT_Publish(&mqtt, MQTT_USERNAME "/pi/bedroom2");
// Setup a feed called 'esp8266_con' for subscribing to changes.
Adafruit_MQTT_Subscribe esp8266_con = Adafruit_MQTT_Subscribe(&mqtt, MQTT_USERNAME "/esp8266/bedroom2");
/**************** Pin Definitions *****************/
#define LIGHT1 12 // D6
#define LIGHT2 13 // D7
#define FAN1 14 // D5
#define AC 0 // D3
#define GasPin A0
unsigned long previousMillis_pub = 0;
const long period_pub = 120000;
unsigned long previousMillis_sub = 0;
const long period_sub = 4000;
void setup() {
Serial.begin(115200);
delay(10);
/**************** Pin Setup *****************/
pinMode(LIGHT1, OUTPUT);
pinMode(LIGHT2, OUTPUT);
pinMode(FAN1, OUTPUT);
pinMode(AC, OUTPUT);
pinMode(GasPin,INPUT);
digitalWrite(LIGHT1, HIGH);
digitalWrite(LIGHT2, LOW);
digitalWrite(FAN1, HIGH);
digitalWrite(AC, HIGH);
/**************** Task Scheduler *****************/
// runner.addTask(living); // add the task to the task scheduler
// living.enable(); // activate the task
// living1.enable();
/**************** DHT Sensor *****************/
dht.begin();
/**************** WiFi Connection *****************/
Serial.println(F("RPi-ESP-MQTT"));
Serial.println(); Serial.println();
Serial.print("Connecting to ");
Serial.println(WLAN_SSID);
WiFi.begin(WLAN_SSID, WLAN_PASS);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println();
Serial.println("WiFi connected");
Serial.println("IP address: "); Serial.println(WiFi.localIP());
// Setup MQTT subscription for esp8266_con feed.
mqtt.subscribe(&esp8266_con);
}
void loop() {
MQTT_connect();
unsigned long currentMillis = millis();
if(currentMillis - previousMillis_sub >= period_sub){
previousMillis_sub = currentMillis;
SubData();
}
if(currentMillis - previousMillis_pub >= period_pub){
previousMillis_pub = currentMillis;
SendData();
}
}
void SubData(){
// Serial.println("entered");
/**************** MQTT Subscription *****************/
Adafruit_MQTT_Subscribe *subscription;
while ((subscription = mqtt.readSubscription())) {
if (subscription == &esp8266_con) {
// Serial.println("subcribed!!");
char *message = (char *)esp8266_con.lastread;
Serial.print(F("Got: "));
Serial.println(message);
DynamicJsonDocument doc(200); // Create a JSON document
DeserializationError error = deserializeJson(doc, message); // Deserialize the data
// parse the parameters we expect to receive (TO-DO: error handling)
// Test if parsing succeeds.
if (error) {
Serial.print("deserializeJson() failed: ");
Serial.println(error.c_str());
return;
}
String DeviceType = doc["device"];
uint8_t DeviceStatus = doc["status"];
if ( DeviceType == "Light 1" )
digitalWrite(LIGHT1,DeviceStatus);
else if ( DeviceType == "Light 2" )
digitalWrite(LIGHT2,DeviceStatus);
else if ( DeviceType == "Fan 1" )
digitalWrite(FAN1,(DeviceStatus == 1) ? 0 : 1);
else if ( DeviceType == "Air Conditioner" )
digitalWrite(AC,DeviceStatus);
}
}
delay(20);
}
float Humidity(){
float hum = dht.readHumidity();
return hum;
}
float Temperature(){
float temp = dht.readTemperature();
return temp;
}
int Sensor1(){
// int sensor_1 = random(200, 900);
// return sensor_1;
int gasval = analogRead(GasPin);
return gasval;
}
int Sensor2(){
int sensor_2 = random(400, 1200);
return sensor_2;
}
void SendData(){
DynamicJsonDocument doc1(1024);
JsonArray array1 = doc1.to<JsonArray>();
JsonObject obj1 = array1.createNestedObject();
obj1["room"] = "bedroom2";
obj1["type"] = "Applaince";
obj1["device"] = "Fan 1";
obj1["status"] = digitalRead(FAN1)? "ON" : "OFF";
obj1["readings"] = NULL;
JsonObject obj2 = array1.createNestedObject();
obj2["room"] = "bedroom2";
obj2["type"] = "Applaince";
obj2["device"] = "Light 2";
obj2["status"] = digitalRead(LIGHT1)? "ON" : "OFF";
obj2["readings"] = NULL;
DynamicJsonDocument doc2(1024);
JsonArray array2 = doc2.to<JsonArray>();
JsonObject obj3 = array2.createNestedObject();
obj3["room"] = "bedroom2";
obj3["type"] = "Applaince";
obj3["device"] = "Light 2";
obj3["status"] = digitalRead(LIGHT2)? "ON" : "OFF";
obj3["readings"] = NULL;
JsonObject obj4 = array2.createNestedObject();
obj4["room"] = "bedroom2";
obj4["type"] = "Applaince";
obj4["device"] = "Air Conditioner";
obj4["status"] = digitalRead(AC) ? "ON" : "OFF";
obj4["readings"] = NULL;
DynamicJsonDocument doc3(1024);
JsonArray array3 = doc3.to<JsonArray>();
JsonObject obj5 = array3.createNestedObject();
obj5["room"] = "bedroom2";
obj5["type"] = "Sensor";
obj5["device"] = "Humidity";
obj5["status"] = "ON";
obj5["readings"] = Humidity();
JsonObject obj6 = array3.createNestedObject();
obj6["room"] = "bedroom2";
obj6["type"] = "Sensor";
obj6["device"] = "Temperature";
obj6["status"] = "ON";
obj6["readings"] = Temperature();
DynamicJsonDocument doc4(1024);
JsonArray array4 = doc4.to<JsonArray>();
JsonObject obj7 = array4.createNestedObject();
obj7["room"] = "bedroom2";
obj7["type"] = "Sensor";
obj7["device"] = "Gas";
obj7["status"] = "ON";
obj7["readings"] = Sensor1();
JsonObject obj8 = array4.createNestedObject();
obj8["room"] = "bedroom2";
obj8["type"] = "Sensor";
obj8["device"] = "Smoke";
obj8["status"] = "ON";
obj8["readings"] = Sensor2();
// serializing data
char json_string1[512], json_string2[512], json_string3[512], json_string4[512];
serializeJson(array1, json_string1); serializeJson(array2, json_string2);
serializeJson(array3, json_string3); serializeJson(array4, json_string4);
// Serial.println(json_string1); Serial.println(json_string2);
// Serial.println(json_string3); Serial.println(json_string4);
// publishing data to bedroom2
bool p1 = bedroom2_pub.publish(json_string1); delay(1000);
bool p2 = bedroom2_pub.publish(json_string2); delay(1000);
bool p3 = bedroom2_pub.publish(json_string3); delay(1000);
bool p4 = bedroom2_pub.publish(json_string4);
if( p1 && p2 && p3 && p4)
Serial.println("published");
delay(20);
}
// Function to connect and reconnect as necessary to the MQTT server.
void MQTT_connect() {
int8_t ret;
// Stop if already connected.
if (mqtt.connected()) {
return;
}
Serial.print("Connecting to MQTT... ");
uint8_t retries = 3;
while ((ret = mqtt.connect()) != 0) { // connect will return 0 for connected
Serial.println(mqtt.connectErrorString(ret));
Serial.println("Retrying MQTT connection in 5 seconds...");
mqtt.disconnect();
delay(5000); // wait 5 seconds
retries--;
if (retries == 0) {
// basically die and wait for WDT to reset me
while (1);
}
}
Serial.println("MQTT Connected!");
}
| [
"[email protected]"
] | |
e0be8336fd80935bb49fedb573344f45edb5954d | 346fde289e5cfc890496635d62e891ec180cd38b | /Beginner/Patterns/pattern_17.cpp | 34bdab8bb2317abdc99b78f6de5ee1666bdf1670 | [] | no_license | robin025/DSAlgo-CPlusPlus | 71f78dd4b70ae5293363b27c898bf443b8f7f848 | 1e7d84fa4ff3d28e3bb694c53fb1c1eec9c30ad6 | refs/heads/master | 2023-02-05T21:11:51.418109 | 2021-01-01T17:22:21 | 2021-01-01T17:22:21 | 313,063,952 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,236 | cpp | /*Pattern 17 : Star Pattern
Example:
*
* * *
* * * * *
* * * * * * *
* * * * * * *
* * * * *
* * *
*
*/
#include <iostream>
using namespace std;
int main()
{
int n;
cout << "Enter number of rows";
cin >> n;
for (int i = 1; i <= n; i++)
{
for (int j = 0; j <= n; j++)
{
if (j < n - i)
{
cout << " ";
}
}
for (int k = i; k >= 1; k--)
{
cout << "* ";
}
for (int k = 2; k <= i; k++)
{
cout << "* ";
}
cout << endl;
}
/*Same as above but in this we have changed the iterator values from 1 to n and we are also decrementing the values of the iterator to get and inverted pyrmid*/
for (int i = n; i >= 1; i--)
/*-----------Main Line Above-------------*/
{
for (int j = 0; j <= n; j++)
{
if (j < n - i)
{
cout << " ";
}
}
for (int k = i; k >= 1; k--)
{
cout << "* ";
}
for (int k = 2; k <= i; k++)
{
cout << "* ";
}
cout << endl;
}
return 0;
} | [
"[email protected]"
] | |
4a0afdba4c31b0c9b337eb0503b72526bcab40af | 92e67b30497ffd29d3400e88aa553bbd12518fe9 | /assignment2/part6/Re=110/68.7/U | 922eb9639d207a5f9d7b7ff0fb82b1b209295165 | [] | no_license | henryrossiter/OpenFOAM | 8b89de8feb4d4c7f9ad4894b2ef550508792ce5c | c54b80dbf0548b34760b4fdc0dc4fb2facfdf657 | refs/heads/master | 2022-11-18T10:05:15.963117 | 2020-06-28T15:24:54 | 2020-06-28T15:24:54 | 241,991,470 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 63,736 | /*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "68.7";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField nonuniform List<vector>
2000
(
(-0.000123202 -0.00731063 -3.06205e-22)
(7.91658e-05 -0.0156826 0)
(0.000907231 -0.0193894 0)
(0.00238503 -0.0192705 -1.56749e-21)
(0.00447856 -0.0158113 5.03123e-22)
(0.00715586 -0.00932024 1.56303e-23)
(0.0103758 -4.35626e-05 -8.6542e-22)
(0.0140646 0.0117489 0)
(0.0180766 0.0257029 0)
(0.0221996 0.0413466 0)
(0.000454843 -0.00707616 0)
(0.00148316 -0.0157369 -1.2003e-21)
(0.00283918 -0.0199034 1.10692e-21)
(0.00449492 -0.0203642 2.0916e-21)
(0.00645601 -0.0175957 0)
(0.00873716 -0.011902 1.89485e-21)
(0.0113518 -0.00350063 -1.76207e-21)
(0.014286 0.00740055 0)
(0.0174551 0.0205407 3.1943e-21)
(0.0206662 0.0355667 -6.14801e-21)
(0.0010624 -0.0068569 0)
(0.00311448 -0.0157731 9.64649e-21)
(0.00525136 -0.0203191 0)
(0.0073242 -0.0212763 8.58254e-21)
(0.00937067 -0.0191324 0)
(0.0114422 -0.0142079 -7.68504e-21)
(0.0136 -0.00670911 0)
(0.0158873 0.00320908 6.86944e-21)
(0.0182876 0.0153842 -6.43359e-21)
(0.020616 0.0295964 -6.27043e-21)
(0.00173097 -0.00669431 -2.52301e-21)
(0.00502686 -0.0158327 -4.80162e-21)
(0.00820514 -0.0206515 -2.25709e-21)
(0.0109406 -0.0219778 -4.21532e-21)
(0.0132992 -0.0203353 -4.03387e-21)
(0.0153655 -0.0160821 3.78224e-21)
(0.0172425 -0.00943577 3.62901e-21)
(0.0190255 -0.000517298 4.78355e-24)
(0.0207712 0.0106034 6.52468e-21)
(0.0222961 0.0238423 6.2692e-21)
(0.00250323 -0.00662562 -2.50195e-21)
(0.00728302 -0.0159547 -4.93096e-21)
(0.0117535 -0.0209129 -9.3507e-21)
(0.0153839 -0.022447 4.29738e-21)
(0.0182712 -0.0211362 0)
(0.0205361 -0.0173953 0)
(0.0223226 -0.0114761 -7.45807e-21)
(0.0237728 -0.00349073 -7.04805e-21)
(0.0250197 0.00656721 6.65538e-21)
(0.0258858 0.0187353 1.90725e-20)
(0.00342813 -0.00667639 2.53896e-21)
(0.00994443 -0.0161618 2.54985e-21)
(0.0159304 -0.0211095 -1.39362e-20)
(0.0206504 -0.022672 2.20618e-20)
(0.0242465 -0.0214983 -4.10615e-21)
(0.0268866 -0.0180725 0)
(0.0287607 -0.0126987 0)
(0.0300572 -0.00550661 3.53888e-20)
(0.0309864 0.00356278 -3.33226e-20)
(0.0313956 0.014642 6.30447e-21)
(0.00455837 -0.00685707 1.99595e-20)
(0.0130624 -0.0164531 0)
(0.0207385 -0.021237 1.85969e-20)
(0.0266802 -0.0226512 -1.76169e-20)
(0.0311 -0.0214236 0)
(0.0342318 -0.0181116 7.99804e-21)
(0.0363241 -0.0130816 -2.24571e-20)
(0.0376164 -0.00650313 -2.8402e-20)
(0.0383975 0.00170932 1.33424e-20)
(0.0385681 0.011757 1.28213e-20)
(0.00594327 -0.0071569 -3.99067e-20)
(0.0166682 -0.0168005 -5.01955e-21)
(0.0261385 -0.0212775 -9.44957e-21)
(0.0333492 -0.0223912 -2.22206e-20)
(0.0386176 -0.0209527 -8.50139e-21)
(0.0422682 -0.017588 -8.05283e-21)
(0.0446247 -0.0127256 -7.35776e-24)
(0.045988 -0.00658874 0)
(0.046729 0.00090943 0)
(0.0468352 0.0100262 1.5092e-22)
(0.00762096 -0.00754248 1.99476e-20)
(0.0207617 -0.0171488 -2.00132e-20)
(0.0320424 -0.0211981 1.40498e-20)
(0.0404694 -0.0219049 3.12934e-20)
(0.0465068 -0.02016 -8.35455e-21)
(0.0505979 -0.0166444 8.00992e-21)
(0.0531578 -0.0118362 7.56664e-21)
(0.0545562 -0.00601368 0)
(0.0552454 0.000892623 0)
(0.0553456 0.00917446 -2.67949e-22)
(0.00961135 -0.00796036 -2.50072e-21)
(0.0253012 -0.0174186 2.51081e-20)
(0.0383082 -0.0209553 -4.69516e-21)
(0.0477942 -0.0212116 0)
(0.0544194 -0.0191468 0)
(0.058777 -0.0154738 1.59465e-20)
(0.0613904 -0.0106942 0)
(0.0627 -0.00511844 -1.40821e-20)
(0.0632022 0.0012835 -2.14589e-23)
(0.0631486 0.00874051 1.26344e-20)
(0.0317733 0.0788865 2.40386e-22)
(0.047083 0.149665 -2.43208e-22)
(0.0517637 0.210699 -2.8492e-22)
(0.0501348 0.266254 -3.27606e-22)
(0.0436174 0.323965 -4.04075e-22)
(0.0384943 0.387441 -1.41196e-23)
(0.0258801 0.458704 2.13736e-22)
(0.0224913 0.545664 7.58837e-22)
(0.00126944 0.668231 0)
(0.00710798 0.814887 -5.56968e-22)
(0.0279179 0.0724534 9.09278e-22)
(0.0428483 0.144674 -1.0623e-21)
(0.0484484 0.208796 1.9108e-21)
(0.047504 0.266179 3.28159e-22)
(0.0415116 0.324829 7.12447e-22)
(0.0367941 0.388932 1.22761e-21)
(0.0247461 0.460711 -4.61002e-22)
(0.021534 0.548123 -5.08746e-22)
(0.00121248 0.670345 1.00114e-21)
(0.00664859 0.815696 5.55648e-22)
(0.0252445 0.0653644 0)
(0.0390494 0.138199 -9.99447e-22)
(0.0454628 0.205547 -5.56622e-22)
(0.0451566 0.264978 0)
(0.0396434 0.32469 -2.19379e-21)
(0.0353095 0.389514 6.84295e-22)
(0.0237655 0.461889 7.76554e-22)
(0.0206879 0.549803 2.74616e-21)
(0.00119912 0.672028 -9.97904e-22)
(0.00623283 0.816311 2.00757e-21)
(0.0240795 0.0579805 0)
(0.0357369 0.130325 1.00787e-21)
(0.0427995 0.200922 0)
(0.0430699 0.262619 2.53058e-21)
(0.0379953 0.323536 -2.54368e-21)
(0.034022 0.389164 -1.564e-21)
(0.0229254 0.462157 -9.97196e-23)
(0.0199645 0.55056 -2.6816e-21)
(0.00123431 0.672942 -4.40134e-22)
(0.00584186 0.816534 -2.46998e-21)
(0.0247873 0.0507283 4.86783e-23)
(0.0330242 0.121264 -2.87374e-21)
(0.0404514 0.194915 1.47202e-22)
(0.0412208 0.259082 -2.21248e-21)
(0.0365466 0.321393 0)
(0.0329077 0.387969 -1.49423e-21)
(0.0222013 0.461713 -1.29417e-22)
(0.0193314 0.55077 3.37777e-21)
(0.00128068 0.673599 4.49075e-22)
(0.00547834 0.816693 -4.507e-22)
(0.0276378 0.044036 -7.86424e-21)
(0.0311044 0.111375 4.9622e-21)
(0.038417 0.187556 2.15734e-21)
(0.0395914 0.254352 -2.15624e-21)
(0.0352833 0.318207 -1.20955e-21)
(0.031957 0.385771 0)
(0.0215992 0.460236 -2.99841e-21)
(0.0188172 0.549849 1.49159e-21)
(0.00137353 0.673177 1.64131e-21)
(0.00512487 0.816353 1.70953e-21)
(0.0326113 0.0382538 -9.57737e-22)
(0.0302296 0.101168 0)
(0.0367092 0.178922 0)
(0.0381593 0.248474 0)
(0.0341807 0.314177 -1.29624e-21)
(0.0311402 0.38302 2.50188e-21)
(0.0210732 0.458486 2.92416e-21)
(0.0183374 0.548964 -4.55283e-21)
(0.00142865 0.673094 8.0876e-22)
(0.00479901 0.816217 -2.49408e-21)
(0.0392162 0.0335445 6.03519e-21)
(0.0306081 0.0911627 4.07505e-21)
(0.035361 0.169207 -4.03827e-21)
(0.0369289 0.241317 4.44916e-21)
(0.0332289 0.308774 -5.53502e-21)
(0.0304686 0.378744 0)
(0.0206825 0.455006 -1.31747e-21)
(0.0180194 0.546097 6.49167e-23)
(0.00157404 0.671123 -1.46353e-21)
(0.00446927 0.815297 -1.53281e-21)
(0.0463599 0.0296134 -5.16739e-21)
(0.0322109 0.0812581 0)
(0.0343756 0.158491 -4.60894e-21)
(0.0358557 0.233673 8.40158e-21)
(0.0324184 0.303679 -3.14837e-21)
(0.0298701 0.375418 -5.91387e-22)
(0.0202711 0.452948 1.31465e-21)
(0.0175947 0.545093 7.90355e-24)
(0.00156885 0.671012 2.1133e-21)
(0.00417315 0.815099 2.22828e-21)
(0.0522328 0.026389 -4.17017e-21)
(0.0345731 0.0713291 4.07156e-21)
(0.0339326 0.145078 5.03549e-22)
(0.0349288 0.221748 0)
(0.0316553 0.293749 0)
(0.0294933 0.367131 5.76497e-22)
(0.0201695 0.445872 2.46699e-21)
(0.017569 0.539044 -2.39627e-21)
(0.00182416 0.66674 -6.47707e-22)
(0.00385382 0.813482 6.27193e-22)
(0.0568816 0.0291448 0)
(0.038116 0.0659783 0)
(0.0343896 0.135967 0)
(0.0343608 0.216791 0)
(0.0304692 0.292631 0)
(0.0276596 0.368358 0)
(0.0186484 0.448272 0)
(0.015937 0.542664 0)
(0.00127486 0.66978 0)
(0.00321598 0.813797 0)
(0.061536 0.0531923 0)
(0.0424304 0.0871942 0)
(0.0332323 0.144656 0)
(0.0319252 0.220708 0)
(0.0283898 0.296953 0)
(0.0255638 0.374068 0)
(0.0174192 0.455555 0)
(0.0144902 0.551507 0)
(0.00118148 0.67785 0)
(0.0026517 0.81685 0)
(0.0615491 0.0634696 0)
(0.0465768 0.101184 0)
(0.034026 0.153016 0)
(0.0305356 0.225404 0)
(0.026792 0.301465 0)
(0.0234807 0.378698 0)
(0.0158189 0.460605 0)
(0.012816 0.556946 0)
(0.000841399 0.682304 0)
(0.0021428 0.817229 0)
(0.0583983 0.0701023 0)
(0.0484978 0.113073 0)
(0.0352534 0.16162 0)
(0.0294561 0.230142 0)
(0.0255343 0.306483 0)
(0.0224076 0.385021 0)
(0.0153626 0.468371 0)
(0.0120951 0.565891 0)
(0.00109797 0.690261 0)
(0.00186904 0.82017 0)
(0.053886 0.073552 0)
(0.0483781 0.123061 0)
(0.0364814 0.170867 0)
(0.0293343 0.23524 0)
(0.0245698 0.310137 0)
(0.0208479 0.388494 0)
(0.0142031 0.472094 0)
(0.0109913 0.569818 0)
(0.000945203 0.69334 0)
(0.00154758 0.820007 0)
(0.0481771 0.0740583 0)
(0.0464038 0.130351 0)
(0.0363498 0.179412 0)
(0.0286974 0.240872 0)
(0.0243076 0.315314 0)
(0.020787 0.394851 0)
(0.0143771 0.479853 0)
(0.0107841 0.578666 0)
(0.00140167 0.70099 0)
(0.00142884 0.822793 0)
(0.041592 0.0718233 0)
(0.0434833 0.13527 0)
(0.0366116 0.188282 0)
(0.028554 0.247138 0)
(0.0231536 0.318606 0)
(0.0194306 0.397172 0)
(0.0135443 0.482197 0)
(0.0100834 0.581065 0)
(0.00133908 0.702771 0)
(0.00124129 0.822301 0)
(0.03407 0.0664667 0)
(0.0386932 0.135202 0)
(0.0350061 0.193075 0)
(0.0287106 0.253444 0)
(0.0239057 0.325326 0)
(0.020045 0.404745 0)
(0.0141111 0.490841 0)
(0.0101853 0.590566 0)
(0.00192921 0.710756 0)
(0.00122505 0.825305 0)
(0.028252 0.0615029 0)
(0.0360198 0.136707 0)
(0.0349141 0.199358 0)
(0.0284199 0.258185 0)
(0.0228903 0.327271 0)
(0.0190959 0.405792 0)
(0.0135878 0.49196 0)
(0.00979309 0.591635 0)
(0.00189071 0.711566 0)
(0.00112907 0.824896 0)
(0.0192432 0.0444647 0)
(0.0298165 0.124965 0)
(0.0339195 0.198756 0)
(0.0308233 0.265451 0)
(0.0254136 0.336385 0)
(0.0206478 0.415247 0)
(0.0146469 0.50209 0)
(0.0101854 0.602453 0)
(0.00263609 0.720444 0)
(0.00117772 0.828417 0)
(0.0694488 0.019483 3.7765e-21)
(0.0695968 0.0321745 -3.71284e-21)
(0.0654749 0.0363099 3.29516e-22)
(0.0599379 0.0377861 0)
(0.0536487 0.0368391 0)
(0.0462321 0.0339195 1.04657e-22)
(0.0380221 0.0291565 -1.39188e-22)
(0.0292506 0.0221138 1.36821e-22)
(0.0218087 0.0158486 -1.50543e-23)
(0.013145 3.56276e-05 1.47987e-23)
(0.0722037 0.0155263 -4.92325e-21)
(0.0699854 0.0232451 0)
(0.0646308 0.0245205 1.87328e-21)
(0.0585101 0.0238673 -3.74871e-21)
(0.0518415 0.0212159 1.8808e-21)
(0.0441192 0.0170225 -1.02484e-22)
(0.0356652 0.0113346 9.17051e-23)
(0.0268486 0.00376138 2.85099e-23)
(0.0189084 -0.00295302 -2.92561e-23)
(0.0104666 -0.0177665 -3.41981e-23)
(0.0736878 0.0109175 5.55576e-21)
(0.0695731 0.0141424 -2.64103e-21)
(0.063456 0.0127858 2.61561e-21)
(0.0569113 0.0100776 -1.48562e-21)
(0.0499108 0.00574968 1.16067e-21)
(0.0419098 0.000301035 0)
(0.0332434 -0.00627675 -9.19146e-23)
(0.0244232 -0.0142216 -2.03353e-24)
(0.0161497 -0.0212137 6.74124e-24)
(0.00843476 -0.0344216 4.94169e-23)
(0.0741933 0.00485607 -8.51857e-22)
(0.0684537 0.00413175 0)
(0.0618611 0.000552563 0)
(0.0550032 -0.00393356 0)
(0.0477521 -0.00971435 7.4488e-22)
(0.0395768 -0.0162143 -4.59537e-22)
(0.0307812 -0.0234894 3.20246e-23)
(0.0219967 -0.0315768 1.24161e-23)
(0.0136562 -0.0385844 1.13125e-23)
(0.00662486 -0.049869 2.34339e-23)
(0.0736 -0.00274947 -5.39293e-22)
(0.066546 -0.00681961 -2.26761e-21)
(0.0597304 -0.0122358 -9.34098e-22)
(0.0526785 -0.0181745 9.33422e-22)
(0.0452792 -0.0251278 -2.81773e-22)
(0.037036 -0.0323998 0)
(0.0282451 -0.0401048 -8.32359e-23)
(0.0195935 -0.0480827 2.85842e-23)
(0.0114313 -0.0548124 -8.73347e-24)
(0.00506334 -0.064105 -3.51146e-23)
(0.0720004 -0.0117026 -6.18914e-21)
(0.063997 -0.0184732 1.02143e-21)
(0.0571704 -0.0254066 2.5916e-22)
(0.0500171 -0.0324754 9.10067e-22)
(0.0425785 -0.0403087 0)
(0.0343495 -0.0480605 0)
(0.0256964 -0.0559225 0)
(0.0172896 -0.0635523 2.93784e-23)
(0.00948969 -0.0697544 0)
(0.00380097 -0.0771504 0)
(0.069529 -0.0217023 0)
(0.0609445 -0.0305044 1.77795e-21)
(0.0542787 -0.0386945 -1.14824e-21)
(0.0471045 -0.0465841 -6.56316e-22)
(0.0397305 -0.0550258 6.59682e-22)
(0.0316209 -0.0629837 1.30441e-22)
(0.0232128 -0.0707556 -1.64013e-22)
(0.0151533 -0.0778453 -1.38412e-22)
(0.00784105 -0.0833519 1.10272e-23)
(0.0028194 -0.0890502 1.13672e-23)
(0.066268 -0.0324446 0)
(0.0575101 -0.0425758 -6.30151e-22)
(0.0511314 -0.0518185 -2.55269e-22)
(0.0440306 -0.0602377 0)
(0.0368171 -0.0690464 8.57911e-23)
(0.0289299 -0.0769739 -3.17557e-22)
(0.0208575 -0.0844561 1.29631e-22)
(0.0132292 -0.090879 2.07106e-24)
(0.00647629 -0.0956122 -8.00612e-24)
(0.00207583 -0.099867 -1.2693e-23)
(0.0623392 -0.0435389 8.26408e-22)
(0.0538038 -0.0543988 5.69485e-22)
(0.0478103 -0.0645166 -1.90975e-22)
(0.0408772 -0.0731984 9.89147e-23)
(0.0339126 -0.0821692 1.39334e-22)
(0.0263402 -0.0898792 1.38319e-22)
(0.0186759 -0.0969305 -2.85095e-23)
(0.0115387 -0.10263 -1.4141e-23)
(0.00536996 -0.106591 8.0323e-24)
(0.00152491 -0.109672 -1.09581e-25)
(0.0579228 -0.0546802 -1.74788e-22)
(0.0499217 -0.065734 1.76358e-22)
(0.0443911 -0.0765703 -1.2871e-22)
(0.0377207 -0.085279 -9.87639e-23)
(0.0310801 -0.094246 6.09125e-23)
(0.0239015 -0.101606 -1.09229e-22)
(0.016695 -0.108144 3.98323e-23)
(0.010083 -0.113125 2.73962e-24)
(0.00448653 -0.116373 0)
(0.0011236 -0.118537 1.09809e-25)
(0.0532141 -0.0656198 1.78881e-22)
(0.0459765 -0.0764063 -1.80394e-22)
(0.0409617 -0.0878181 -1.35023e-22)
(0.0346442 -0.0963574 -1.04783e-22)
(0.0283784 -0.105191 -6.40864e-23)
(0.021653 -0.112125 1.04987e-23)
(0.0149275 -0.118117 2.19209e-23)
(0.00884894 -0.122433 3.25888e-23)
(0.00378717 -0.12506 0)
(0.000833766 -0.126535 -2.31938e-24)
(0.0484181 -0.0761779 0)
(0.0420945 -0.0863095 -6.0725e-22)
(0.0376141 -0.098158 1.02637e-21)
(0.0317286 -0.10638 1.04937e-22)
(0.025857 -0.11498 1.63875e-22)
(0.0196211 -0.121462 1.69891e-22)
(0.0133742 -0.126911 -3.46866e-23)
(0.00781441 -0.130648 -1.96728e-23)
(0.00323495 -0.13276 2.31172e-23)
(0.000624453 -0.133734 2.31377e-24)
(0.0437015 -0.0862443 0)
(0.0383767 -0.0954077 -7.01944e-22)
(0.0344122 -0.107543 -2.80008e-22)
(0.0290275 -0.115358 0)
(0.0235427 -0.123641 -4.50915e-22)
(0.0178123 -0.129689 1.7303e-22)
(0.0120231 -0.134623 1.02522e-22)
(0.00695216 -0.137883 1.65516e-22)
(0.00279747 -0.139577 -2.30417e-23)
(0.000472031 -0.140204 1.69156e-23)
(0.0391875 -0.0957682 0)
(0.0348929 -0.103735 7.07758e-22)
(0.0313919 -0.115978 0)
(0.0265663 -0.123361 8.16786e-22)
(0.0214423 -0.131249 -8.21027e-22)
(0.0162168 -0.136916 -2.13557e-22)
(0.0108546 -0.141369 4.88606e-23)
(0.00623348 -0.144256 -1.73064e-22)
(0.00244815 -0.14562 -3.17291e-23)
(0.000359035 -0.146018 -2.62701e-23)
(0.0349694 -0.104744 7.26509e-21)
(0.0316989 -0.111393 -2.72207e-21)
(0.0285784 -0.123507 -2.63758e-22)
(0.024355 -0.130505 -1.10612e-21)
(0.0195549 -0.13791 0)
(0.0148171 -0.143272 -2.29135e-22)
(0.00984733 -0.147279 7.75649e-23)
(0.00563204 -0.149891 2.64974e-22)
(0.00216669 -0.150992 1.07096e-23)
(0.000273094 -0.151253 -1.06966e-23)
(0.0311045 -0.113183 6.2425e-22)
(0.0288413 -0.11854 4.24814e-21)
(0.0259955 -0.130206 1.15802e-21)
(0.022394 -0.136933 -1.15732e-21)
(0.0178794 -0.143756 -4.02906e-22)
(0.0135941 -0.148899 0)
(0.00898246 -0.152486 -3.72555e-22)
(0.00512605 -0.154908 1.99182e-22)
(0.00193859 -0.155799 9.98105e-23)
(0.000205775 -0.155992 2.53881e-23)
(0.0276311 -0.121086 -1.02311e-21)
(0.0263778 -0.125385 0)
(0.0236856 -0.136173 0)
(0.020687 -0.142803 0)
(0.0164225 -0.148933 -3.17762e-22)
(0.0125345 -0.153941 7.1987e-22)
(0.00824719 -0.157125 3.84504e-22)
(0.00469986 -0.159428 -4.54543e-22)
(0.00175446 -0.160145 2.59699e-23)
(0.000151339 -0.160324 -5.08369e-23)
(0.0245535 -0.128394 -2.36701e-21)
(0.0243379 -0.132165 3.16816e-21)
(0.0216807 -0.141524 -3.13829e-21)
(0.0192157 -0.148267 2.0163e-21)
(0.0151814 -0.15359 -2.44615e-21)
(0.0116188 -0.158536 0)
(0.00762718 -0.161326 -2.35615e-22)
(0.00433939 -0.163565 -1.09671e-23)
(0.00160703 -0.164133 -8.67987e-23)
(0.000105041 -0.16434 -2.95637e-23)
(0.0215466 -0.134927 -1.11181e-21)
(0.0224263 -0.139108 0)
(0.0198241 -0.146396 -3.10575e-21)
(0.0178122 -0.153463 4.82075e-21)
(0.0140538 -0.157882 -1.65612e-21)
(0.0107653 -0.162818 -1.76669e-22)
(0.0070729 -0.165215 2.35078e-22)
(0.00401424 -0.167428 2.88208e-23)
(0.0014833 -0.167865 1.79012e-22)
(6.36447e-05 -0.168135 5.86344e-23)
(0.0185663 -0.140215 -4.50809e-21)
(0.0204806 -0.146426 4.40459e-21)
(0.0181269 -0.150988 4.01806e-22)
(0.0164469 -0.158537 0)
(0.013021 -0.16198 0)
(0.00996618 -0.16693 1.8194e-22)
(0.00657618 -0.168926 4.38652e-22)
(0.00372209 -0.17113 -4.30454e-22)
(0.00138241 -0.171442 -3.25624e-23)
(4.09531e-05 -0.171806 3.18516e-23)
(0.0188359 -0.147646 0)
(0.0208293 -0.163763 0)
(0.0179141 -0.161369 0)
(0.0158952 -0.170386 0)
(0.0124997 -0.171618 0)
(0.00938097 -0.176711 0)
(0.0062063 -0.17776 0)
(0.00348969 -0.17994 0)
(0.00135733 -0.179899 0)
(7.69669e-05 -0.18044 0)
(0.0163092 -0.174395 0)
(0.0143893 -0.191224 0)
(0.012518 -0.184648 0)
(0.0105173 -0.193607 0)
(0.00835427 -0.192002 0)
(0.00619783 -0.196807 0)
(0.00416234 -0.196268 0)
(0.00238137 -0.19831 0)
(0.000991719 -0.197579 0)
(9.75882e-05 -0.198282 0)
(0.0166138 -0.205253 0)
(0.0135418 -0.222731 0)
(0.011271 -0.213257 0)
(0.00894061 -0.222547 0)
(0.00698193 -0.218767 0)
(0.0050191 -0.223746 0)
(0.0034207 -0.221904 0)
(0.00197933 -0.224111 0)
(0.000910619 -0.222707 0)
(0.000109924 -0.223667 0)
(0.0162844 -0.243445 0)
(0.0124522 -0.262119 0)
(0.0101957 -0.250479 0)
(0.00768022 -0.260642 0)
(0.00600013 -0.255054 0)
(0.00419118 -0.260652 0)
(0.0029544 -0.257628 0)
(0.0017254 -0.260294 0)
(0.000881424 -0.258177 0)
(0.000111148 -0.259546 0)
(0.0157594 -0.291183 0)
(0.0115663 -0.310509 0)
(0.00936299 -0.297948 0)
(0.00672178 -0.308985 0)
(0.00528165 -0.302235 0)
(0.00355501 -0.308632 0)
(0.00260064 -0.30469 0)
(0.00148141 -0.307988 0)
(0.000820902 -0.305227 0)
(8.07962e-05 -0.307157 0)
(0.0146177 -0.347327 0)
(0.0104063 -0.365349 0)
(0.00841342 -0.353997 0)
(0.00576324 -0.364932 0)
(0.00457895 -0.358263 0)
(0.00290667 -0.364972 0)
(0.00218217 -0.360754 0)
(0.00111069 -0.364468 0)
(0.000642376 -0.361399 0)
(5.70187e-07 -0.363804 0)
(0.0124784 -0.405634 0)
(0.0087045 -0.420154 0)
(0.00703259 -0.412167 0)
(0.00463254 -0.421459 0)
(0.00369455 -0.416341 0)
(0.00215986 -0.422293 0)
(0.00160444 -0.418712 0)
(0.000611912 -0.422154 0)
(0.000346706 -0.419372 0)
(-9.79186e-05 -0.421801 0)
(0.0094399 -0.456585 0)
(0.00650275 -0.466626 0)
(0.00521712 -0.462931 0)
(0.00333942 -0.469507 0)
(0.00263045 -0.466762 0)
(0.00139062 -0.470999 0)
(0.000960501 -0.468706 0)
(0.000154447 -0.471146 0)
(5.99353e-05 -0.469162 0)
(-0.000150598 -0.471002 0)
(0.00582593 -0.492594 0)
(0.00395139 -0.498833 0)
(0.00315504 -0.498733 0)
(0.00197537 -0.502708 0)
(0.00153742 -0.502116 0)
(0.000728426 -0.504512 0)
(0.000447074 -0.503517 0)
(-7.90011e-05 -0.504761 0)
(-7.67965e-05 -0.503676 0)
(-0.000130958 -0.504663 0)
(0.00196083 -0.510708 0)
(0.00129628 -0.514981 0)
(0.00104651 -0.516828 0)
(0.000641461 -0.519303 0)
(0.000505358 -0.519896 0)
(0.000218373 -0.521167 0)
(0.000125204 -0.520933 0)
(-6.23128e-05 -0.521419 0)
(-4.59369e-05 -0.520898 0)
(-5.23386e-05 -0.521305 0)
(0.0181184 -0.158275 5.29369e-21)
(0.0177768 -0.186207 -5.18979e-21)
(0.0188254 -0.218855 6.71672e-22)
(0.0186823 -0.258293 0)
(0.0181833 -0.305867 0)
(0.0167874 -0.359762 7.78267e-22)
(0.0143163 -0.413905 -3.34608e-21)
(0.0108959 -0.460106 3.30311e-21)
(0.00681594 -0.492282 8.99701e-22)
(0.00232136 -0.508368 -8.85734e-22)
(0.0182215 -0.163502 -6.2318e-21)
(0.0186612 -0.191181 0)
(0.0198699 -0.223914 4.56149e-21)
(0.0197687 -0.26341 -1.05273e-20)
(0.0192519 -0.310671 6.75956e-21)
(0.0177376 -0.363618 -7.16795e-22)
(0.0151287 -0.416247 1.59779e-21)
(0.0115478 -0.460838 3.37257e-21)
(0.00726005 -0.491786 9.51162e-22)
(0.00247726 -0.50728 9.22779e-22)
(0.0187084 -0.168924 7.28753e-21)
(0.0199341 -0.196458 -5.03546e-21)
(0.0211864 -0.228997 4.98781e-21)
(0.0210788 -0.26826 -5.58835e-21)
(0.020491 -0.315003 4.13587e-21)
(0.0188128 -0.366881 0)
(0.0160175 -0.417998 -1.60169e-21)
(0.0122237 -0.46109 8.40169e-23)
(0.00768738 -0.490968 -1.77138e-21)
(0.00261273 -0.505978 -1.81009e-21)
(0.0195966 -0.173759 -1.1802e-21)
(0.02152 -0.201357 0)
(0.0227564 -0.233792 0)
(0.0226136 -0.272837 0)
(0.0219131 -0.319055 4.61013e-21)
(0.0200392 -0.369876 -3.0825e-21)
(0.0170178 -0.419529 -2.07596e-23)
(0.01296 -0.461161 -1.89321e-21)
(0.00813019 -0.489975 -9.71573e-22)
(0.00274356 -0.504459 -1.03996e-21)
(0.0209559 -0.178098 1.25418e-22)
(0.0233868 -0.205623 -3.56977e-21)
(0.0245478 -0.237955 -2.73458e-21)
(0.0243463 -0.276822 2.73288e-21)
(0.0235018 -0.322566 -1.50694e-21)
(0.0214148 -0.372427 0)
(0.0181447 -0.420752 -1.76616e-21)
(0.0137888 -0.461041 3.86548e-21)
(0.00862715 -0.488838 -1.97827e-21)
(0.00289086 -0.50278 2.03525e-21)
(0.0228302 -0.182039 -9.49848e-21)
(0.0255568 -0.209289 1.02532e-21)
(0.0265729 -0.241399 -2.01596e-22)
(0.0262745 -0.28005 2.80949e-21)
(0.025252 -0.325332 0)
(0.0229341 -0.374327 0)
(0.0193976 -0.421492 0)
(0.0147194 -0.460614 2.07156e-21)
(0.00919458 -0.487518 0)
(0.00306551 -0.500971 0)
(0.0252327 -0.185487 0)
(0.0280513 -0.212345 3.93362e-21)
(0.028862 -0.24412 -2.65849e-21)
(0.0284173 -0.282495 -3.15491e-21)
(0.0271784 -0.327302 3.17134e-21)
(0.024605 -0.375505 1.88808e-21)
(0.0207777 -0.421664 -1.87344e-21)
(0.0157505 -0.459807 -7.39998e-21)
(0.00983179 -0.485975 5.26879e-22)
(0.00326911 -0.49903 -1.80288e-21)
(0.0281712 -0.188305 0)
(0.0308779 -0.214712 -1.27819e-21)
(0.0314371 -0.246085 -7.22891e-22)
(0.0307936 -0.284154 0)
(0.0293012 -0.328486 9.20947e-22)
(0.0264433 -0.375972 -2.78046e-21)
(0.0222935 -0.42127 3.09239e-21)
(0.0168832 -0.458603 1.10293e-21)
(0.0105352 -0.484188 -1.20697e-21)
(0.00350049 -0.496942 2.39192e-21)
(0.0316564 -0.190383 1.14868e-21)
(0.0340414 -0.216315 1.38934e-21)
(0.0343111 -0.247238 -3.07759e-22)
(0.0334146 -0.285002 4.13289e-22)
(0.0316362 -0.328885 8.77929e-22)
(0.0284638 -0.37575 1.47218e-21)
(0.0239561 -0.420333 -5.53316e-22)
(0.0181226 -0.457019 -5.97696e-22)
(0.0113044 -0.482157 1.21095e-21)
(0.00375933 -0.494692 6.56255e-22)
(0.0356989 -0.191629 -3.20757e-22)
(0.0375472 -0.217114 3.2369e-22)
(0.0374941 -0.24753 -3.72262e-22)
(0.0362869 -0.285015 -4.12759e-22)
(0.0341946 -0.328486 4.89429e-22)
(0.0306773 -0.374844 -9.98991e-22)
(0.0257765 -0.418866 8.46658e-22)
(0.0194774 -0.455065 3.02611e-22)
(0.0121437 -0.479883 0)
(0.00404727 -0.492275 -6.57719e-22)
(0.0403068 -0.191972 3.28919e-22)
(0.0413984 -0.217102 -3.32047e-22)
(0.0409963 -0.246937 -4.00003e-22)
(0.0394154 -0.284189 -4.46201e-22)
(0.0369854 -0.327284 -5.10794e-22)
(0.0330911 -0.373261 -3.54742e-23)
(0.0277619 -0.416881 2.98421e-22)
(0.020953 -0.452752 9.63171e-22)
(0.0130557 -0.477369 0)
(0.0043654 -0.489685 -7.17845e-22)
(0.0454852 -0.191392 0)
(0.0455949 -0.216279 -1.53068e-21)
(0.0448253 -0.245471 2.77495e-21)
(0.0428018 -0.28253 4.46959e-22)
(0.0400177 -0.325283 1.0374e-21)
(0.0357124 -0.370996 1.70088e-21)
(0.0299226 -0.414366 -6.04645e-22)
(0.0225601 -0.450067 -6.53397e-22)
(0.0140482 -0.474609 1.44508e-21)
(0.00471621 -0.486919 7.1617e-22)
(0.0512353 -0.189934 0)
(0.0501358 -0.214637 -1.50966e-21)
(0.0489852 -0.243171 -8.34507e-22)
(0.0464514 -0.28006 0)
(0.0432971 -0.322521 -3.26623e-21)
(0.0385445 -0.368081 1.09198e-21)
(0.0322601 -0.411353 1.29832e-21)
(0.0242964 -0.447036 4.19108e-21)
(0.0151177 -0.4716 -1.44039e-21)
(0.00509763 -0.483964 3.10917e-21)
(0.0575536 -0.18772 0)
(0.0550235 -0.212165 1.52255e-21)
(0.0534638 -0.240187 0)
(0.0503638 -0.276767 4.17668e-21)
(0.0468305 -0.319012 -4.1981e-21)
(0.0415984 -0.364497 -2.5617e-21)
(0.0347866 -0.40781 -5.66979e-23)
(0.0261821 -0.443622 -4.31315e-21)
(0.0162813 -0.468313 -7.18941e-22)
(0.00551355 -0.480797 -3.86733e-21)
(0.0644167 -0.184867 1.10125e-20)
(0.0602577 -0.208836 -4.22304e-21)
(0.058268 -0.236501 4.50941e-22)
(0.0545723 -0.272659 -3.90438e-21)
(0.0506065 -0.314792 0)
(0.0448744 -0.360303 -2.67169e-21)
(0.0374954 -0.403802 -2.22251e-22)
(0.0282054 -0.439879 5.85838e-21)
(0.0175274 -0.4648 8.03005e-22)
(0.00595741 -0.477449 -8.06076e-22)
(0.0717608 -0.18137 -1.11884e-21)
(0.0658717 -0.204704 7.89891e-21)
(0.0633591 -0.232093 4.06258e-21)
(0.0590652 -0.267875 -4.0598e-21)
(0.0546321 -0.309875 -2.44359e-21)
(0.0483872 -0.355454 0)
(0.0404135 -0.399242 -5.98415e-21)
(0.0303997 -0.435721 3.00097e-21)
(0.0188846 -0.461003 3.2041e-21)
(0.00644123 -0.473878 3.43958e-21)
(0.0795146 -0.177273 -1.51756e-21)
(0.071861 -0.199932 0)
(0.0687056 -0.227118 0)
(0.0638242 -0.262569 0)
(0.0588952 -0.304481 -2.81704e-21)
(0.0521069 -0.350236 5.25151e-21)
(0.0434892 -0.394427 6.09616e-21)
(0.0326999 -0.431378 -9.59748e-21)
(0.0202989 -0.457046 1.71746e-21)
(0.00693794 -0.470152 -5.10865e-21)
(0.0875513 -0.172677 -2.2843e-21)
(0.0782215 -0.194464 7.79194e-21)
(0.0742981 -0.221483 -7.71751e-21)
(0.0688651 -0.256486 9.89154e-21)
(0.0634421 -0.298205 -1.24386e-20)
(0.0561235 -0.344093 0)
(0.046859 -0.388777 -3.18716e-21)
(0.0352604 -0.426411 -1.31096e-22)
(0.0218933 -0.452683 -3.56951e-21)
(0.00750156 -0.466111 -3.63724e-21)
(0.0956668 -0.168229 -1.61301e-21)
(0.0848503 -0.18895 0)
(0.0799945 -0.216033 -1.03008e-20)
(0.0740252 -0.250743 1.93889e-20)
(0.0680702 -0.292485 -7.50267e-21)
(0.0601674 -0.338639 -1.50906e-21)
(0.0501899 -0.383761 3.18027e-21)
(0.0377429 -0.42183 -1.60571e-22)
(0.0234151 -0.44843 5.21028e-21)
(0.00801412 -0.462049 5.3827e-21)
(0.104224 -0.161735 -7.24579e-21)
(0.0927314 -0.180915 7.10088e-21)
(0.0865656 -0.207892 1.09631e-21)
(0.0799808 -0.242053 0)
(0.0734599 -0.283611 0)
(0.065008 -0.330144 1.47865e-21)
(0.0543204 -0.376285 6.76318e-21)
(0.040932 -0.415643 -6.61421e-21)
(0.0254284 -0.443295 -1.8102e-21)
(0.00872675 -0.457357 1.77979e-21)
(0.115341 -0.162405 0)
(0.109815 -0.17805 0)
(0.100294 -0.206071 0)
(0.0921824 -0.239601 0)
(0.0841487 -0.280165 0)
(0.0740296 -0.325083 0)
(0.0615305 -0.36931 0)
(0.0461861 -0.406903 0)
(0.0285931 -0.433481 0)
(0.00961539 -0.447357 0)
(0.135444 -0.14763 0)
(0.139017 -0.168443 0)
(0.124328 -0.199725 0)
(0.115514 -0.232863 0)
(0.10478 -0.272439 0)
(0.0916732 -0.314902 0)
(0.07583 -0.355847 0)
(0.0567715 -0.389982 0)
(0.0352185 -0.413383 0)
(0.0122364 -0.424615 0)
(0.163362 -0.133431 0)
(0.170352 -0.15653 0)
(0.15034 -0.187835 0)
(0.141591 -0.2196 0)
(0.127198 -0.257641 0)
(0.1106 -0.297001 0)
(0.0907415 -0.33465 0)
(0.0674285 -0.366257 0)
(0.0414452 -0.388792 0)
(0.0136636 -0.401168 0)
(0.197951 -0.123545 0)
(0.206352 -0.146557 0)
(0.180824 -0.176595 0)
(0.172693 -0.207162 0)
(0.153358 -0.243516 0)
(0.133034 -0.279239 0)
(0.108459 -0.313238 0)
(0.08025 -0.341071 0)
(0.0494377 -0.359808 0)
(0.0173456 -0.367952 0)
(0.238788 -0.11104 0)
(0.245392 -0.132103 0)
(0.214817 -0.159713 0)
(0.206364 -0.187804 0)
(0.179742 -0.220116 0)
(0.155093 -0.250656 0)
(0.124544 -0.280689 0)
(0.0910679 -0.30575 0)
(0.0551485 -0.324581 0)
(0.0173689 -0.336729 0)
(0.286476 -0.101696 0)
(0.289412 -0.120082 0)
(0.25483 -0.145835 0)
(0.244312 -0.170455 0)
(0.209288 -0.198506 0)
(0.181383 -0.224809 0)
(0.144261 -0.251616 0)
(0.105218 -0.272813 0)
(0.0641665 -0.287394 0)
(0.0236919 -0.291244 0)
(0.335846 -0.0834011 0)
(0.33098 -0.0977486 0)
(0.293465 -0.119212 0)
(0.277354 -0.13778 0)
(0.233989 -0.160237 0)
(0.202474 -0.180995 0)
(0.155603 -0.202435 0)
(0.110972 -0.219987 0)
(0.064204 -0.237475 0)
(0.0161799 -0.256141 0)
(0.38586 -0.0706726 0)
(0.373805 -0.0807642 0)
(0.336648 -0.0984216 0)
(0.313454 -0.111998 0)
(0.267016 -0.131227 0)
(0.231049 -0.147853 0)
(0.17736 -0.166925 0)
(0.129086 -0.18389 0)
(0.0768168 -0.200738 0)
(0.036631 -0.198242 0)
(0.425109 -0.0385902 0)
(0.407734 -0.0432103 0)
(0.360248 -0.0538369 0)
(0.329311 -0.0602846 0)
(0.272439 -0.0718772 0)
(0.227376 -0.0796209 0)
(0.160144 -0.0905064 0)
(0.10143 -0.100269 0)
(0.0378515 -0.120466 0)
(-0.0313845 -0.170752 0)
(0.661901 -0.0196911 0)
(0.63922 -0.0227794 0)
(0.596899 -0.0275185 0)
(0.561682 -0.0317715 0)
(0.507687 -0.0383131 0)
(0.45781 -0.0449411 0)
(0.387836 -0.0553655 0)
(0.314617 -0.0701437 0)
(0.217218 -0.0991514 0)
(0.154331 -0.156641 0)
(0.13851 -0.145092 7.413e-21)
(0.161467 -0.129807 -7.30264e-21)
(0.189634 -0.116199 1.19138e-21)
(0.223969 -0.10664 0)
(0.264635 -0.0953385 0)
(0.310286 -0.0868895 1.81875e-21)
(0.358235 -0.0707471 -8.69134e-21)
(0.405045 -0.0604832 8.58146e-21)
(0.451978 -0.0324792 2.45182e-21)
(0.683281 -0.0171389 -2.47862e-21)
(0.145991 -0.137705 -6.90696e-21)
(0.168788 -0.122209 0)
(0.196232 -0.109143 8.4942e-21)
(0.230585 -0.0999068 -2.05356e-20)
(0.271356 -0.0891027 1.38493e-20)
(0.316882 -0.0810393 -1.68946e-21)
(0.364799 -0.0657043 3.69066e-21)
(0.411374 -0.0564404 8.31585e-21)
(0.461833 -0.0300677 2.27505e-21)
(0.691574 -0.0160489 2.25397e-21)
(0.152536 -0.129505 7.98698e-21)
(0.174794 -0.114198 -7.99432e-21)
(0.201497 -0.101905 7.9187e-21)
(0.235552 -0.0931316 -1.09314e-20)
(0.276226 -0.082907 7.92788e-21)
(0.321747 -0.0753399 0)
(0.369725 -0.0608997 -3.6996e-21)
(0.416647 -0.0526989 -7.23696e-23)
(0.47041 -0.027908 -4.29399e-21)
(0.699271 -0.0150057 -4.50632e-21)
(0.15909 -0.120733 -1.37639e-21)
(0.181211 -0.105939 0)
(0.207482 -0.0945207 0)
(0.241148 -0.0862849 0)
(0.281594 -0.0767218 8.99145e-21)
(0.326986 -0.0697522 -6.12475e-21)
(0.374856 -0.0562939 -2.37951e-22)
(0.422005 -0.0491671 -4.22831e-21)
(0.478422 -0.0259655 -2.15575e-21)
(0.706624 -0.0140412 -2.20092e-21)
(0.165098 -0.111566 1.37772e-21)
(0.187307 -0.0975764 -4.35681e-21)
(0.213305 -0.0870858 -4.49544e-21)
(0.246809 -0.0794296 4.49265e-21)
(0.287017 -0.0705852 -2.82625e-21)
(0.33237 -0.0642843 0)
(0.380105 -0.0518465 -3.60864e-21)
(0.427425 -0.0457595 8.06523e-21)
(0.486052 -0.0241704 -4.05702e-21)
(0.713629 -0.0131535 4.39877e-21)
(0.170335 -0.102039 -1.02926e-20)
(0.192621 -0.0891386 5.33856e-22)
(0.218328 -0.0796478 -7.09164e-22)
(0.251789 -0.0726141 4.39449e-21)
(0.291806 -0.0645329 0)
(0.337284 -0.0589707 0)
(0.384872 -0.0475596 0)
(0.432551 -0.0424583 3.85887e-21)
(0.493148 -0.0224835 0)
(0.720185 -0.0123316 0)
(0.17474 -0.0921717 0)
(0.1971 -0.0806102 5.17673e-21)
(0.22251 -0.0721861 -3.5908e-21)
(0.255866 -0.0658452 -5.02591e-21)
(0.295782 -0.0585843 5.05204e-21)
(0.341417 -0.0537932 3.27225e-21)
(0.388864 -0.0434374 -3.08808e-21)
(0.437113 -0.0392855 -1.32938e-20)
(0.499515 -0.0208871 9.41587e-22)
(0.726214 -0.0115732 -3.15461e-21)
(0.178215 -0.0819985 0)
(0.200722 -0.0719832 -1.59114e-21)
(0.225896 -0.0646757 -9.57443e-22)
(0.259082 -0.0591081 0)
(0.298947 -0.0527208 1.52535e-21)
(0.344698 -0.0487263 -4.38962e-21)
(0.392139 -0.0394645 5.22994e-21)
(0.440967 -0.0362364 2.00734e-21)
(0.505081 -0.0193756 -1.98266e-21)
(0.731675 -0.0108782 4.21752e-21)
(0.180637 -0.0715509 9.95749e-22)
(0.203419 -0.0632542 1.71194e-21)
(0.228455 -0.0571054 -3.01566e-22)
(0.261457 -0.0523868 5.62309e-22)
(0.301302 -0.0469136 1.32279e-21)
(0.347147 -0.0437499 2.26913e-21)
(0.394732 -0.0356103 -8.38956e-22)
(0.444088 -0.0332894 -9.26227e-22)
(0.509882 -0.0179449 1.9892e-21)
(0.736567 -0.0102429 1.02456e-21)
(0.181884 -0.0608534 -3.28966e-22)
(0.20512 -0.0544159 3.3316e-22)
(0.230121 -0.0494671 -4.69921e-22)
(0.262952 -0.0456657 -5.61577e-22)
(0.302803 -0.0411374 6.95353e-22)
(0.348767 -0.0388432 -1.45221e-21)
(0.396612 -0.0318434 1.27643e-21)
(0.446491 -0.0304272 4.86189e-22)
(0.513899 -0.0165823 0)
(0.740857 -0.00965362 -1.02679e-21)
(0.18189 -0.0499269 3.2385e-22)
(0.205803 -0.0454593 -3.27996e-22)
(0.230859 -0.0417479 -4.59893e-22)
(0.263535 -0.0389252 -5.5159e-22)
(0.303413 -0.0353696 -6.89783e-22)
(0.349548 -0.0339825 -4.25952e-23)
(0.397742 -0.0281357 3.9248e-22)
(0.448189 -0.0276341 1.34711e-21)
(0.51712 -0.0152699 0)
(0.744558 -0.00909913 -1.00573e-21)
(0.18066 -0.0388062 0)
(0.205491 -0.0363735 -1.64934e-21)
(0.230671 -0.0339288 3.03756e-21)
(0.263204 -0.0321409 5.52519e-22)
(0.303116 -0.0295856 1.28119e-21)
(0.349471 -0.0291408 2.20985e-21)
(0.398088 -0.0244604 -8.2549e-22)
(0.44916 -0.024893 -9.09099e-22)
(0.519492 -0.0139888 1.91864e-21)
(0.74766 -0.00856629 1.00338e-21)
(0.178227 -0.0275561 0)
(0.204206 -0.0271446 -1.45818e-21)
(0.229573 -0.0259856 -9.17835e-22)
(0.261976 -0.0252844 0)
(0.301918 -0.0237559 -4.02405e-21)
(0.348531 -0.0242873 1.28782e-21)
(0.397651 -0.0207906 1.56555e-21)
(0.44941 -0.0221858 5.33107e-21)
(0.521045 -0.0127261 -1.91242e-21)
(0.750201 -0.00805413 3.96399e-21)
(0.17462 -0.0162633 0)
(0.201933 -0.0177611 1.4706e-21)
(0.22757 -0.017897 0)
(0.259859 -0.0183277 4.74932e-21)
(0.299824 -0.0178498 -4.77368e-21)
(0.346715 -0.0193901 -3.09986e-21)
(0.396403 -0.017096 -1.61545e-22)
(0.448895 -0.019489 -5.34754e-21)
(0.521707 -0.011464 -8.86564e-22)
(0.752147 -0.00754875 -4.90503e-21)
(0.169913 -0.00503597 8.68303e-21)
(0.198664 -0.00821786 -3.27479e-21)
(0.224676 -0.0096487 7.35887e-22)
(0.256881 -0.0112459 -4.04505e-21)
(0.296862 -0.0118381 0)
(0.344066 -0.014421 -3.11034e-21)
(0.394411 -0.0133557 -3.11666e-22)
(0.447696 -0.0167915 7.02264e-21)
(0.521644 -0.0101984 9.62242e-22)
(0.753575 -0.00705884 -9.6164e-22)
(0.164253 0.00598655 -1.49639e-21)
(0.194407 0.00148082 6.59188e-21)
(0.220917 -0.00123578 4.06922e-21)
(0.253053 -0.00401718 -4.06641e-21)
(0.29301 -0.00569189 -2.5958e-21)
(0.340515 -0.00934539 0)
(0.391548 -0.00952871 -6.75051e-21)
(0.445663 -0.0140576 3.36406e-21)
(0.520601 -0.0089024 3.68252e-21)
(0.754388 -0.00655723 3.90813e-21)
(0.157859 0.0166233 -1.0742e-21)
(0.189229 0.01132 0)
(0.216399 0.00733562 0)
(0.248505 0.00337076 0)
(0.28845 0.000599784 -3.0059e-21)
(0.336328 -0.00416103 5.59205e-21)
(0.388141 -0.00562958 6.76661e-21)
(0.443153 -0.0113147 -1.06593e-20)
(0.519157 -0.00758921 1.91899e-21)
(0.754764 -0.00606904 -5.76435e-21)
(0.150991 0.0266354 -1.46925e-21)
(0.183093 0.0212644 6.79422e-21)
(0.211 0.0160661 -6.72946e-21)
(0.243025 0.0109581 9.88624e-21)
(0.282824 0.00710078 -1.24525e-20)
(0.330954 0.00122617 0)
(0.383507 -0.0015387 -3.36286e-21)
(0.439487 -0.00845955 -4.50183e-23)
(0.516313 -0.00619902 -3.79696e-21)
(0.754451 -0.00553764 -3.89787e-21)
(0.144244 0.0357719 -1.1026e-21)
(0.176787 0.031192 0)
(0.205636 0.0247954 -9.46333e-21)
(0.237714 0.0185762 1.84512e-20)
(0.277525 0.0136284 -7.24403e-21)
(0.326067 0.00661282 -1.5351e-21)
(0.379375 0.00251839 3.35558e-21)
(0.436199 -0.00568748 -1.1617e-22)
(0.514134 -0.00479087 5.51518e-21)
(0.753857 -0.00502086 5.73311e-21)
(0.13447 0.0447728 -5.23223e-21)
(0.16694 0.0423761 5.11774e-21)
(0.196892 0.0346439 9.63958e-22)
(0.229088 0.027136 0)
(0.268722 0.0209568 0)
(0.31762 0.0126948 1.50675e-21)
(0.372006 0.00717884 6.94955e-21)
(0.43024 -0.00253846 -6.77959e-21)
(0.508782 -0.00322729 -1.85174e-21)
(0.752424 -0.004414 1.76485e-21)
(0.137598 0.0668543 0)
(0.166517 0.0672184 0)
(0.195865 0.055376 0)
(0.227347 0.045591 0)
(0.265994 0.0366449 0)
(0.313807 0.0256322 0)
(0.366927 0.0168738 0)
(0.424647 0.00388792 0)
(0.505433 0.000620836 0)
(0.748948 -0.0030145 0)
(0.129557 0.101014 0)
(0.157708 0.107688 0)
(0.187074 0.0893248 0)
(0.21833 0.0774089 0)
(0.257209 0.0640092 0)
(0.304451 0.0483924 0)
(0.357292 0.0339433 0)
(0.417306 0.0155909 0)
(0.506945 0.00717483 0)
(0.75532 -0.000444496 0)
(0.118038 0.141384 0)
(0.1438 0.150106 0)
(0.1708 0.124785 0)
(0.200811 0.112158 0)
(0.23887 0.0939517 0)
(0.283887 0.0736341 0)
(0.334472 0.0530705 0)
(0.393966 0.0288397 0)
(0.487582 0.0139555 0)
(0.739006 0.00108094 0)
(0.108043 0.187156 0)
(0.129506 0.195806 0)
(0.154537 0.163676 0)
(0.183897 0.151828 0)
(0.221137 0.127474 0)
(0.263842 0.102193 0)
(0.313733 0.0747264 0)
(0.376456 0.0440109 0)
(0.481285 0.0216376 0)
(0.740027 0.00366279 0)
(0.0933746 0.240202 0)
(0.109919 0.24677 0)
(0.132945 0.209658 0)
(0.159375 0.198614 0)
(0.191954 0.165922 0)
(0.229092 0.136077 0)
(0.275049 0.101102 0)
(0.336262 0.0630646 0)
(0.444315 0.0320207 0)
(0.70736 0.00576762 0)
(0.0820211 0.300805 0)
(0.0939523 0.304719 0)
(0.116007 0.263256 0)
(0.13757 0.251291 0)
(0.166399 0.208959 0)
(0.199842 0.17703 0)
(0.244658 0.133928 0)
(0.308735 0.0889258 0)
(0.427777 0.047586 0)
(0.69919 0.0111024 0)
(0.0574255 0.371253 0)
(0.065298 0.370004 0)
(0.0824977 0.32668 0)
(0.0971851 0.312419 0)
(0.120357 0.263956 0)
(0.146634 0.232935 0)
(0.185015 0.181075 0)
(0.243965 0.130967 0)
(0.361505 0.0774957 0)
(0.634155 0.0188238 0)
(0.0488888 0.453864 0)
(0.0539512 0.449897 0)
(0.0679832 0.405439 0)
(0.0782755 0.389306 0)
(0.0978017 0.338121 0)
(0.118674 0.30854 0)
(0.155083 0.250075 0)
(0.213872 0.201528 0)
(0.333418 0.132816 0)
(0.597771 0.0384675 0)
(0.00789531 0.589759 0)
(0.00804685 0.584448 0)
(0.0132911 0.5464 0)
(0.0161662 0.531729 0)
(0.0253859 0.487523 0)
(0.0366019 0.461628 0)
(0.0622757 0.405926 0)
(0.107728 0.357934 0)
(0.20548 0.258934 0)
(0.437936 0.076024 0)
(0.0151628 0.783064 0)
(0.0190454 0.775894 0)
(0.0239886 0.755889 0)
(0.0306284 0.743198 0)
(0.0399229 0.715016 0)
(0.0532642 0.690088 0)
(0.0741244 0.64214 0)
(0.107698 0.579881 0)
(0.169466 0.440825 0)
(0.311104 0.150498 0)
(0.110441 0.0821959 5.05578e-21)
(0.111655 0.125617 -4.9973e-21)
(0.102748 0.168628 8.53107e-22)
(0.093689 0.215513 0)
(0.0805734 0.269311 0)
(0.0702728 0.328495 1.37687e-21)
(0.04884 0.398191 -6.59731e-21)
(0.0414585 0.479931 6.54583e-21)
(0.00604522 0.611665 1.83998e-21)
(0.0138806 0.793351 -1.85409e-21)
(0.0998517 0.0870771 -4.77515e-21)
(0.104052 0.13326 0)
(0.0966416 0.176581 6.15284e-21)
(0.0881886 0.223781 -1.49896e-20)
(0.0756712 0.277913 1.01774e-20)
(0.0657984 0.337265 -1.27547e-21)
(0.045505 0.407091 2.70752e-21)
(0.0385287 0.489218 6.11792e-21)
(0.00532918 0.619864 1.59788e-21)
(0.0133351 0.796086 1.61501e-21)
(0.0897592 0.0904237 5.58826e-21)
(0.0963214 0.139357 -5.57768e-21)
(0.0905466 0.183249 5.52395e-21)
(0.0828364 0.230619 -7.92374e-21)
(0.0709819 0.284829 5.72124e-21)
(0.0616121 0.344543 0)
(0.0424208 0.414511 -2.7141e-21)
(0.0358725 0.497425 -1.08026e-22)
(0.00454735 0.627196 -3.10882e-21)
(0.0126375 0.797951 -3.25261e-21)
(0.0802387 0.0929153 -9.4563e-22)
(0.0887414 0.144936 0)
(0.0845822 0.190086 0)
(0.0776578 0.237717 0)
(0.0664987 0.292025 6.42991e-21)
(0.0576846 0.351989 -4.40052e-21)
(0.0395722 0.421964 -2.03972e-22)
(0.0334731 0.505488 -3.02277e-21)
(0.00375133 0.634264 -1.52393e-21)
(0.0118309 0.800311 -1.54888e-21)
(0.0713531 0.0943898 6.78404e-22)
(0.0815159 0.149541 -3.03335e-21)
(0.0788717 0.196394 -3.12207e-21)
(0.0727431 0.244534 3.11989e-21)
(0.0622924 0.299118 -2.00034e-21)
(0.0540359 0.359405 0)
(0.0369437 0.429417 -2.54103e-21)
(0.0312987 0.513366 5.62995e-21)
(0.00303678 0.641096 -2.79867e-21)
(0.0110058 0.803181 3.10926e-21)
(0.0630965 0.0947582 -7.55131e-21)
(0.0747022 0.152907 4.67836e-22)
(0.0734777 0.201641 -4.95542e-22)
(0.0681459 0.250647 3.00245e-21)
(0.0584091 0.305468 0)
(0.0507065 0.366228 0)
(0.0345464 0.436386 0)
(0.0293449 0.520701 2.58679e-21)
(0.00246652 0.647446 0)
(0.0102234 0.806083 0)
(0.0554688 0.0939765 0)
(0.0683097 0.154995 3.50119e-21)
(0.0684382 0.205756 -2.42264e-21)
(0.063871 0.255839 -3.36425e-21)
(0.0548384 0.31091 3.38163e-21)
(0.0477174 0.37221 2.16704e-21)
(0.0323832 0.442564 -2.00241e-21)
(0.0276098 0.527277 -8.75398e-21)
(0.00204749 0.653132 6.1639e-22)
(0.0095012 0.808653 -2.02212e-21)
(0.0484857 0.0919972 0)
(0.0623488 0.155774 -1.08174e-21)
(0.0637507 0.208764 -6.27076e-22)
(0.0599311 0.260007 0)
(0.0515746 0.315524 1.00287e-21)
(0.0450323 0.377356 -2.83479e-21)
(0.0304442 0.447826 3.36489e-21)
(0.0260851 0.533015 1.32944e-21)
(0.00175542 0.658024 -1.20205e-21)
(0.00883073 0.810738 2.71055e-21)
(0.0421726 0.0887952 8.72933e-22)
(0.0568266 0.155182 1.13552e-21)
(0.0594103 0.210631 -2.17094e-22)
(0.0563325 0.263143 3.54358e-22)
(0.0486268 0.319277 8.47427e-22)
(0.0426077 0.381647 1.43253e-21)
(0.028712 0.452223 -5.06916e-22)
(0.024747 0.538049 -5.62736e-22)
(0.00154349 0.662175 1.20602e-21)
(0.00820299 0.812423 6.14284e-22)
(0.0365738 0.0843928 -2.41331e-22)
(0.0517406 0.153159 2.44142e-22)
(0.0554158 0.211294 -3.02559e-22)
(0.0530714 0.265233 -3.53898e-22)
(0.0459819 0.322104 4.22682e-22)
(0.0404294 0.385013 -8.89369e-22)
(0.0271947 0.455849 7.67043e-22)
(0.0235626 0.542282 3.01124e-22)
(0.00138272 0.665496 0)
(0.00762245 0.813754 -6.15633e-22)
(0.0119107 -0.00834127 0)
(0.0301986 -0.0175149 0)
(0.0447426 -0.0205016 -1.93216e-20)
(0.0550328 -0.0203388 0)
(0.0619799 -0.0180342 8.54896e-21)
(0.0663628 -0.0143037 -7.92243e-21)
(0.0688396 -0.0096354 0)
(0.0699591 -0.00433626 0)
(0.07029 0.00150944 -1.29819e-20)
(0.0704045 0.00767541 2.46592e-20)
(0.0144744 -0.00859797 0)
(0.035307 -0.0173341 -1.55428e-20)
(0.0511008 -0.0197945 -5.05045e-21)
(0.0618627 -0.0193265 -1.83573e-20)
(0.0688091 -0.0169556 -8.56176e-21)
(0.0729343 -0.0133706 -2.38537e-20)
(0.0750413 -0.00902125 0)
(0.0757748 -0.00418928 0)
(0.0757381 0.00102094 0)
(0.0754155 0.00638291 -3.0691e-22)
(0.0172086 -0.00864162 0)
(0.040413 -0.0167891 -5.69516e-21)
(0.057093 -0.0188168 9.5253e-21)
(0.0679523 -0.0182345 1.37819e-20)
(0.0745614 -0.0160441 -1.14705e-22)
(0.0781504 -0.012875 -1.9516e-23)
(0.0796661 -0.00911578 1.47037e-20)
(0.0798314 -0.00500009 -1.35529e-20)
(0.0792666 -0.000584421 2.50159e-20)
(0.0784145 0.00400684 -2.36117e-20)
(0.0199943 -0.0084058 -2.67363e-21)
(0.0452724 -0.0158315 1.57664e-20)
(0.0624251 -0.0175871 2.48777e-20)
(0.0730044 -0.0171423 -2.82225e-20)
(0.0789706 -0.0154238 1.72587e-20)
(0.0817966 -0.0129667 1.60073e-20)
(0.0825653 -0.0100775 -7.32363e-21)
(0.0820625 -0.00692455 2.69371e-20)
(0.0809132 -0.0034982 -3.86239e-22)
(0.0795469 0.000154719 -1.17742e-20)
(0.0226849 -0.00784866 -2.82707e-21)
(0.049621 -0.0144572 2.68597e-21)
(0.0668188 -0.0161618 0)
(0.07678 -0.0161457 2.36106e-20)
(0.0818686 -0.0152031 -4.38595e-21)
(0.0837921 -0.0137418 -1.05895e-22)
(0.0837511 -0.0119715 -7.40655e-21)
(0.0825771 -0.00998957 -1.99973e-20)
(0.0808867 -0.00773188 7.73952e-23)
(0.0790971 -0.00520842 1.69327e-20)
(0.0251139 -0.00696016 0)
(0.0531962 -0.012713 -1.72184e-20)
(0.0700367 -0.0146341 5.24466e-21)
(0.0791165 -0.015351 -1.4669e-20)
(0.083191 -0.0154689 4.46669e-21)
(0.0841739 -0.0152436 4.44804e-23)
(0.0833544 -0.0147826 4.39854e-23)
(0.0815843 -0.0141191 1.33415e-20)
(0.0794542 -0.013162 -1.82654e-20)
(0.0773702 -0.0119025 1.69587e-20)
(0.0271094 -0.00576814 1.51466e-21)
(0.05576 -0.0106967 1.15307e-20)
(0.0719013 -0.013128 0)
(0.079936 -0.0148666 1.47781e-20)
(0.0829668 -0.0162835 -1.37485e-20)
(0.0830673 -0.0174695 -4.06374e-21)
(0.0815769 -0.0184352 1.11992e-20)
(0.0793388 -0.0191653 0)
(0.0768891 -0.0195733 0)
(0.0745883 -0.0196248 0)
(0.0285072 -0.00433957 -1.60134e-21)
(0.0571199 -0.00855165 -4.71393e-21)
(0.0723072 -0.0117876 5.72281e-21)
(0.0792411 -0.0147955 7.74376e-21)
(0.0812985 -0.0176851 6.83505e-21)
(0.0806523 -0.0203838 4.24622e-21)
(0.0786497 -0.0228207 0)
(0.0760981 -0.0249462 6.71564e-21)
(0.0734736 -0.0266751 -3.18042e-21)
(0.0710591 -0.0280616 0)
(0.0291651 -0.00277794 0)
(0.0571458 -0.00645662 9.48842e-21)
(0.0712242 -0.0107668 -5.72179e-21)
(0.0771048 -0.0152307 -5.20486e-21)
(0.0783392 -0.0196924 6.9776e-23)
(0.0771328 -0.0239317 -2.06558e-21)
(0.0747994 -0.02782 1.95386e-21)
(0.0720873 -0.0312977 0)
(0.0694089 -0.0343159 -3.10924e-21)
(0.0670023 -0.0369828 -2.82292e-21)
(0.0289931 -0.00121842 2.23351e-22)
(0.0557885 -0.0046128 -3.66617e-21)
(0.0686997 -0.0102192 -3.68347e-22)
(0.0736574 -0.0162521 1.63927e-23)
(0.0742729 -0.0223088 -1.79846e-21)
(0.0727169 -0.0280505 0)
(0.0702347 -0.0333162 -1.95343e-21)
(0.067501 -0.0380597 0)
(0.0648633 -0.0422804 0)
(0.0625073 -0.046108 0)
(0.0280098 0.000190053 -4.71978e-22)
(0.053102 -0.00322017 0)
(0.0648565 -0.0102834 0)
(0.0690741 -0.0179214 -2.18228e-21)
(0.0693001 -0.0255268 6.01794e-22)
(0.0676069 -0.0326774 -4.21347e-23)
(0.0651455 -0.0392058 -1.03434e-21)
(0.0625125 -0.0450947 0)
(0.0599951 -0.0503914 0)
(0.0577287 -0.0552316 0)
(0.0262324 0.00131396 0)
(0.0491801 -0.00244257 -1.79246e-21)
(0.0598512 -0.0110714 1.65313e-21)
(0.0635421 -0.0202866 2.8792e-21)
(0.0636121 -0.0293388 0)
(0.0619821 -0.0377641 2.28632e-21)
(0.0596935 -0.0454118 -2.12619e-21)
(0.0572681 -0.0523042 0)
(0.0549432 -0.0585296 3.26619e-21)
(0.0528121 -0.064221 -3.1685e-21)
(0.0236621 0.00201206 0)
(0.0441348 -0.00244654 1.53474e-20)
(0.0538603 -0.012686 0)
(0.0572612 -0.0233858 1.2269e-20)
(0.0574038 -0.0337341 0)
(0.0560182 -0.0432678 -9.71012e-21)
(0.0540331 -0.0518726 0)
(0.0519062 -0.059615 7.47991e-21)
(0.0498378 -0.066615 -7.00554e-21)
(0.0478882 -0.0729963 -6.44437e-21)
(0.0203918 0.00215224 -4.24127e-21)
(0.0381575 -0.00337718 -7.46766e-21)
(0.0471044 -0.0152083 -3.55059e-21)
(0.0504458 -0.0272444 -6.16306e-21)
(0.050865 -0.0386996 -5.64085e-21)
(0.0498767 -0.0491533 4.89437e-21)
(0.0483012 -0.0585423 4.47865e-21)
(0.046547 -0.0669773 2.55066e-22)
(0.0447904 -0.0745999 7.17978e-21)
(0.0430663 -0.0815168 6.45183e-21)
(0.0165667 0.00162915 -4.52938e-21)
(0.0314861 -0.00534142 -7.92321e-21)
(0.0398261 -0.0186912 -1.42794e-20)
(0.0433142 -0.0318723 6.50542e-21)
(0.0441802 -0.0442184 0)
(0.0437087 -0.0553901 0)
(0.0426224 -0.0653855 -8.77454e-21)
(0.0412971 -0.0743574 -7.82222e-21)
(0.0398976 -0.0824584 7.26261e-21)
(0.0384382 -0.0897693 -6.35119e-21)
(0.0123619 0.000371249 4.50413e-21)
(0.0243856 -0.00840324 3.82482e-21)
(0.0322798 -0.0231579 -2.25414e-20)
(0.0360857 -0.0372639 3.25921e-20)
(0.037529 -0.0502686 -5.89137e-21)
(0.0376587 -0.0619489 0)
(0.0371127 -0.0723711 0)
(0.0362508 -0.0817276 4.05806e-20)
(0.0352385 -0.0901736 -3.66578e-20)
(0.034073 -0.0977529 -2.0135e-20)
(0.00797217 -0.00165412 3.82969e-20)
(0.0171362 -0.0125807 0)
(0.0247234 -0.0286012 2.95995e-20)
(0.0289771 -0.0433982 -2.62164e-20)
(0.0310883 -0.0568231 0)
(0.0318694 -0.0688004 1.01886e-20)
(0.031885 -0.079469 -2.81326e-20)
(0.0314933 -0.089059 -3.27737e-20)
(0.0308734 -0.0977248 1.52611e-20)
(0.0300162 -0.105461 1.38971e-20)
(0.00360097 -0.00443818 -7.68494e-20)
(0.0100213 -0.0178449 -8.30313e-21)
(0.0174112 -0.0349835 -1.50491e-20)
(0.0222007 -0.0502389 -3.34385e-20)
(0.0250348 -0.0638515 -1.15694e-20)
(0.0264901 -0.0759191 -1.03329e-20)
(0.0270616 -0.0866539 -1.74983e-22)
(0.0271132 -0.0963225 0)
(0.0268556 -0.105085 0)
(0.0263011 -0.112875 2.84669e-20)
(-0.000551819 -0.0079313 3.85533e-20)
(0.00331394 -0.0241206 -3.36581e-20)
(0.0105848 -0.0422373 2.27002e-20)
(0.0159593 -0.0577375 4.65296e-20)
(0.0195461 -0.0713256 -1.20834e-20)
(0.02169 -0.0832937 1.0303e-20)
(0.0228119 -0.0939206 9.19879e-21)
(0.0232768 -0.103502 0)
(0.0233387 -0.112223 0)
(0.0230321 -0.119955 -1.44015e-20)
(-0.00430202 -0.0120468 -4.7845e-21)
(-0.00273475 -0.0312896 4.19072e-20)
(0.00446345 -0.0502669 -7.60314e-21)
(0.010436 -0.0658347 0)
(0.0147907 -0.0792305 0)
(0.0176593 -0.0909603 2.11174e-20)
(0.0193999 -0.101356 0)
(0.0203871 -0.110712 -1.68092e-20)
(0.0208952 -0.119217 4.90287e-22)
(0.0207997 -0.12666 1.48522e-20)
(-0.00749221 -0.0166694 0)
(-0.00790828 -0.0391977 0)
(-0.000768413 -0.0589491 -2.91033e-20)
(0.00577462 -0.074458 0)
(0.0108836 -0.0875679 1.15418e-20)
(0.0145084 -0.0990578 -1.06965e-20)
(0.0169701 -0.109388 0)
(0.0186609 -0.11898 0)
(0.0198118 -0.12825 -1.55759e-20)
(0.0200981 -0.137419 3.03166e-20)
(-0.0099823 -0.0216451 0)
(-0.0120187 -0.0476478 -2.35502e-20)
(-0.00495834 -0.0681212 -6.52123e-21)
(0.00207392 -0.0834853 -2.54595e-20)
(0.00785245 -0.0962402 -1.1508e-20)
(0.0121481 -0.107463 -3.13344e-20)
(0.0152115 -0.117725 0)
(0.0173827 -0.127436 0)
(0.018819 -0.136871 0)
(0.0192682 -0.145882 4.27655e-23)
(-0.0116622 -0.0267776 0)
(-0.014918 -0.0563897 -6.36458e-21)
(-0.00798726 -0.0775722 1.49245e-20)
(-0.000591734 -0.0927373 1.91027e-20)
(0.00571916 -0.105061 4.87879e-22)
(0.0105439 -0.115917 3.13804e-22)
(0.0140475 -0.125937 1.87041e-20)
(0.016516 -0.135445 -1.72057e-20)
(0.0181033 -0.144532 3.17496e-20)
(0.0187499 -0.152932 -3.06901e-20)
(-0.0124753 -0.0318665 -4.15366e-21)
(-0.0165163 -0.0651567 2.28629e-20)
(-0.00977533 -0.0870703 3.41286e-20)
(-0.00216494 -0.102012 -3.6011e-20)
(0.00452127 -0.113828 2.26121e-20)
(0.00973115 -0.124181 2.05785e-20)
(0.0135513 -0.133753 -9.3439e-21)
(0.0162351 -0.142784 3.429e-20)
(0.0179724 -0.151261 -1.35445e-22)
(0.0188546 -0.158955 -1.54411e-20)
(-0.0124121 -0.0367104 -3.78613e-21)
(-0.0167767 -0.0736729 3.5977e-21)
(-0.0102781 -0.0963712 0)
(-0.00260506 -0.111099 2.9763e-20)
(0.00429727 -0.122352 -5.40139e-21)
(0.00975806 -0.132085 9.59523e-23)
(0.0137968 -0.141045 -9.19343e-21)
(0.0166468 -0.149438 -2.54777e-20)
(0.0185348 -0.157227 1.49929e-23)
(0.0196407 -0.164265 2.31624e-20)
(-0.0115076 -0.0411156 0)
(-0.015715 -0.0816636 -1.91365e-20)
(-0.00948839 -0.105229 6.0398e-21)
(-0.00189338 -0.119795 -1.65729e-20)
(0.0050738 -0.130467 5.19313e-21)
(0.0106615 -0.139503 1.12786e-22)
(0.0148326 -0.147751 7.55219e-23)
(0.0178013 -0.155433 1.69207e-20)
(0.0198161 -0.162534 -2.37974e-20)
(0.0211016 -0.168995 2.32111e-20)
(-0.00983865 -0.0449076 1.65835e-21)
(-0.0133991 -0.0888687 1.25868e-20)
(-0.00743752 -0.113405 0)
(-3.68786e-05 -0.127904 1.63282e-20)
(0.0068598 -0.138022 -1.47727e-20)
(0.0124619 -0.146334 -4.72321e-21)
(0.0166862 -0.153826 1.33149e-20)
(0.0197237 -0.160774 0)
(0.0218261 -0.167212 0)
(0.023234 -0.173148 0)
(-0.00751882 -0.0479375 -1.48563e-21)
(-0.0099465 -0.0950531 -3.91801e-21)
(-0.00419598 -0.120675 5.11861e-21)
(0.00292968 -0.135242 7.46935e-21)
(0.00964357 -0.144881 7.4364e-21)
(0.0151614 -0.152489 4.48146e-21)
(0.0193664 -0.159222 0)
(0.022422 -0.165444 8.31373e-21)
(0.0245686 -0.171245 -3.86417e-21)
(0.0260426 -0.176683 0)
(-0.00469163 -0.0500843 0)
(-0.00552038 -0.100013 7.75127e-21)
(0.000127547 -0.126836 -5.11733e-21)
(0.00694278 -0.141639 -4.9069e-21)
(0.0133915 -0.150918 -9.41156e-23)
(0.0187437 -0.157885 -2.31621e-21)
(0.0228652 -0.163891 2.09325e-21)
(0.0258911 -0.169411 0)
(0.0280411 -0.174598 -3.92164e-21)
(0.0295322 -0.179543 -3.93301e-21)
(-0.0015252 -0.0512879 1.4977e-22)
(-0.000328474 -0.103596 -2.71963e-21)
(0.00538485 -0.131713 -3.12057e-22)
(0.0119084 -0.146937 -3.43608e-23)
(0.0180468 -0.156013 -1.70893e-21)
(0.023174 -0.162438 0)
(0.0271594 -0.167776 -2.09256e-21)
(0.0301143 -0.172631 0)
(0.0322345 -0.177223 0)
(0.0337061 -0.18167 0)
(0.00180933 -0.0516598 -2.65139e-22)
(0.0053965 -0.105798 0)
(0.0113952 -0.135229 0)
(0.0177041 -0.15104 -1.48351e-21)
(0.0235313 -0.160079 5.74184e-22)
(0.0284012 -0.166086 6.13493e-23)
(0.0322131 -0.170834 -9.84631e-22)
(0.0350652 -0.175067 0)
(0.037134 -0.179081 0)
(0.0385672 -0.183013 0)
(0.0051839 -0.0512344 0)
(0.0114633 -0.106561 -9.83285e-22)
(0.0179794 -0.137283 9.06808e-22)
(0.0241898 -0.153828 2.02684e-21)
(0.029743 -0.163013 0)
(0.0343524 -0.168748 2.05959e-21)
(0.0379734 -0.173005 -1.91532e-21)
(0.0407047 -0.176675 0)
(0.0427159 -0.180133 3.97559e-21)
(0.0441158 -0.183535 -3.83254e-21)
(0.00846311 -0.04998 0)
(0.0176525 -0.105859 6.31233e-21)
(0.0249351 -0.137793 0)
(0.0312148 -0.15521 7.08148e-21)
(0.036568 -0.164728 0)
(0.0409431 -0.170355 -7.57309e-21)
(0.0443758 -0.174238 0)
(0.0469807 -0.177417 8.01317e-21)
(0.0489383 -0.180352 -7.50492e-21)
(0.050334 -0.183224 -7.91114e-21)
(0.0115123 -0.0479647 -1.4761e-21)
(0.0237427 -0.103733 -3.30224e-21)
(0.0320449 -0.136725 -1.48237e-21)
(0.0385919 -0.155119 -3.42631e-21)
(0.043868 -0.165152 -3.3761e-21)
(0.0480691 -0.170845 3.67003e-21)
(0.0513386 -0.174488 3.62914e-21)
(0.0538245 -0.177265 -3.15145e-22)
(0.0557338 -0.179725 7.45857e-21)
(0.0571722 -0.182085 7.90297e-21)
(0.0142218 -0.0453003 -1.19763e-21)
(0.0295203 -0.10027 -2.91154e-21)
(0.0390891 -0.134112 -6.11626e-21)
(0.0461262 -0.153526 2.94266e-21)
(0.0514853 -0.16423 0)
(0.0556074 -0.170161 0)
(0.0587629 -0.173708 -7.79595e-21)
(0.0611508 -0.176188 -7.94107e-21)
(0.0630131 -0.178244 7.69073e-21)
(0.0645239 -0.180097 -8.55523e-21)
(0.0165079 -0.0421136 1.14475e-21)
(0.0347932 -0.0956071 1.56092e-21)
(0.045849 -0.130023 -7.16825e-21)
(0.0536156 -0.150438 1.49272e-20)
(0.0592493 -0.161932 -3.02105e-21)
(0.0634196 -0.168259 0)
(0.0665333 -0.171854 0)
(0.0688592 -0.174153 3.82624e-20)
(0.070711 -0.175876 -3.83621e-20)
(0.0723164 -0.177259 -2.51384e-20)
(0.0183136 -0.0385389 6.77966e-21)
(0.0393987 -0.089915 0)
(0.0521173 -0.124569 1.03352e-20)
(0.0608541 -0.145896 -1.16569e-20)
(0.0669781 -0.158249 0)
(0.0713544 -0.165106 7.22887e-21)
(0.0745252 -0.168887 -2.09015e-20)
(0.0768377 -0.171121 -3.05757e-20)
(0.0786983 -0.172608 1.46101e-20)
(0.0804469 -0.173602 1.59005e-20)
(0.0196089 -0.0347122 -1.28238e-20)
(0.0432097 -0.0833917 -2.24526e-21)
(0.0577073 -0.117898 -4.30266e-21)
(0.0676397 -0.139983 -1.28192e-20)
(0.0744835 -0.153205 -6.54417e-21)
(0.07925 -0.160687 -6.89269e-21)
(0.0826019 -0.164771 2.78531e-22)
(0.0849581 -0.167049 0)
(0.0868189 -0.168397 0)
(0.0887209 -0.169079 3.25335e-20)
(0.0203899 -0.0307644 6.04424e-21)
(0.0461378 -0.076251 -7.25521e-21)
(0.0624604 -0.110198 6.5137e-21)
(0.0737825 -0.132817 1.83482e-20)
(0.0815777 -0.146858 -5.22606e-21)
(0.0869416 -0.155013 7.25418e-21)
(0.0906333 -0.159485 7.49944e-21)
(0.0931233 -0.161893 0)
(0.0949553 -0.163202 0)
(0.0969282 -0.163724 -1.58349e-20)
(0.0206768 -0.0268179 -6.63646e-22)
(0.0481357 -0.0687139 9.25611e-21)
(0.0662521 -0.10168 -1.8441e-21)
(0.0791119 -0.12456 0)
(0.0880785 -0.139304 0)
(0.0942583 -0.148127 1.25886e-20)
(0.0984648 -0.153013 0)
(0.101168 -0.155527 -1.52139e-20)
(0.102751 -0.156657 -1.50937e-21)
(0.104193 -0.156832 1.51095e-20)
(0.0205107 -0.0229781 0)
(0.0491963 -0.0609907 0)
(0.068995 -0.0925691 -7.87639e-21)
(0.0834807 -0.115398 0)
(0.0938177 -0.130677 5.93454e-21)
(0.101065 -0.140109 -5.49977e-21)
(0.106102 -0.14538 0)
(0.109579 -0.147872 0)
(0.111995 -0.148674 -1.5944e-20)
(0.11483 -0.148821 3.1295e-20)
(0.0199249 -0.0193159 0)
(0.0493285 -0.0532634 -4.8506e-21)
(0.070628 -0.0830881 -1.60185e-21)
(0.086763 -0.105544 -8.97388e-21)
(0.0986265 -0.121163 -4.52505e-21)
(0.107169 -0.131156 -1.68815e-20)
(0.113299 -0.136921 0)
(0.117832 -0.139744 0)
(0.12144 -0.140939 0)
(0.125282 -0.141839 3.42827e-22)
(0.0189547 -0.0158929 0)
(0.0485671 -0.0457171 -1.95348e-21)
(0.0711253 -0.073477 3.93829e-21)
(0.0888591 -0.0952368 6.98472e-21)
(0.102337 -0.110972 2.70369e-22)
(0.11234 -0.121441 3.34814e-22)
(0.119731 -0.127759 1.23183e-20)
(0.125391 -0.131098 -1.32983e-20)
(0.130082 -0.132791 2.93934e-20)
(0.134701 -0.134028 -3.05159e-20)
(0.0176628 -0.0127714 -6.52844e-22)
(0.0469853 -0.0385214 4.91686e-21)
(0.0705054 -0.0639655 9.44676e-21)
(0.0897121 -0.0847143 -1.35654e-20)
(0.104817 -0.100308 9.05489e-21)
(0.116375 -0.111098 1.02429e-20)
(0.125141 -0.117913 -6.72416e-21)
(0.131964 -0.121763 2.72961e-20)
(0.137612 -0.123889 1.26501e-21)
(0.142842 -0.125296 -1.41568e-20)
(0.0161187 -0.00999688 -8.08765e-22)
(0.0446814 -0.0318176 7.68384e-22)
(0.068827 -0.0547627 0)
(0.089312 -0.0742076 1.11062e-20)
(0.105982 -0.089377 -2.21143e-21)
(0.119131 -0.100279 5.32236e-22)
(0.129349 -0.107465 -5.43891e-21)
(0.137398 -0.111756 -1.98458e-20)
(0.143997 -0.114258 -1.04225e-21)
(0.149801 -0.115816 2.22617e-20)
(0.0143902 -0.00759538 0)
(0.0417689 -0.0257149 -5.78872e-21)
(0.066182 -0.0460511 1.84372e-21)
(0.0876946 -0.0639363 -6.74339e-21)
(0.105803 -0.0783967 2.19611e-21)
(0.120516 -0.0891698 -3.80792e-22)
(0.132227 -0.0965534 -3.50856e-22)
(0.141563 -0.101177 1.28507e-20)
(0.149169 -0.10398 -2.01107e-20)
(0.1556 -0.105673 2.0868e-20)
(0.0125411 -0.00557699 3.99321e-22)
(0.0383704 -0.0202914 3.78913e-21)
(0.0626893 -0.0379834 0)
(0.0849371 -0.0541024 6.74243e-21)
(0.104293 -0.0675824 -6.93487e-21)
(0.120487 -0.0779674 -2.78273e-21)
(0.133683 -0.0853428 8.23627e-21)
(0.144348 -0.0901506 0)
(0.153021 -0.0931555 0)
(0.160163 -0.0949488 0)
(0.0106302 -0.00393879 -4.8374e-22)
(0.0346112 -0.0155959 -1.64172e-21)
(0.0584876 -0.0306796 2.16157e-21)
(0.0811524 -0.0448838 3.44528e-21)
(0.101517 -0.0571402 3.63422e-21)
(0.119045 -0.0668763 2.52328e-21)
(0.13367 -0.0740131 0)
(0.145667 -0.0788264 6.21106e-21)
(0.155457 -0.0819065 -2.7654e-21)
(0.163392 -0.0837463 0)
(0.00870933 -0.00266733 0)
(0.0306134 -0.0116504 3.21064e-21)
(0.0537256 -0.0242269 -2.16111e-21)
(0.0764799 -0.0364296 -2.24928e-21)
(0.0975743 -0.0472596 -7.65145e-23)
(0.11624 -0.0560986 -1.34629e-21)
(0.132181 -0.0627563 1.3235e-21)
(0.145478 -0.0673727 0)
(0.156405 -0.0703774 -3.05142e-21)
(0.165197 -0.0721808 -3.37693e-21)
(0.00682924 -0.0017411 6.33892e-23)
(0.0264994 -0.00845385 -1.25832e-21)
(0.0485622 -0.0186814 -1.63902e-22)
(0.0710829 -0.0288592 -2.97735e-23)
(0.0926032 -0.0381102 -9.08597e-22)
(0.112163 -0.0458303 0)
(0.129259 -0.0517707 -1.32313e-21)
(0.143773 -0.0559734 0)
(0.155821 -0.0587271 0)
(0.165503 -0.0603748 0)
(0.00505864 -0.00113122 -1.37115e-22)
(0.0224177 -0.00598338 0)
(0.0431951 -0.0140689 0)
(0.0651797 -0.022261 -9.05841e-22)
(0.0868119 -0.0298381 3.49733e-22)
(0.106987 -0.0362573 6.72745e-23)
(0.125025 -0.0412589 -6.14126e-22)
(0.140621 -0.0448267 0)
(0.153724 -0.047133 0)
(0.164288 -0.0484633 0)
(0.00342434 -0.000800961 0)
(0.0184552 -0.00418856 -6.57761e-22)
(0.0377622 -0.0103674 6.06554e-22)
(0.0589378 -0.0166629 1.22008e-21)
(0.0803725 -0.0225277 0)
(0.100866 -0.0275131 1.31846e-21)
(0.119599 -0.031387 -1.22607e-21)
(0.136101 -0.0341126 0)
(0.150155 -0.0357721 2.9512e-21)
(0.161559 -0.036596 -2.81736e-21)
(0.00192721 -0.000715148 0)
(0.0146673 -0.00301473 5.4961e-21)
(0.0323749 -0.00754218 0)
(0.0525138 -0.012074 5.2084e-21)
(0.0734673 -0.0162425 0)
(0.0939834 -0.0197134 -5.08397e-21)
(0.113145 -0.0223118 0)
(0.130346 -0.0240133 5.5653e-21)
(0.145209 -0.024837 -5.21228e-21)
(0.157374 -0.024956 -5.7406e-21)
(0.000580799 -0.000840104 -1.41034e-21)
(0.0111168 -0.00240206 -2.71283e-21)
(0.0271485 -0.00554284 -1.33092e-21)
(0.0460692 -0.00847741 -2.48688e-21)
(0.066289 -0.0110148 -2.51383e-21)
(0.0865446 -0.0129444 2.42572e-21)
(0.10586 -0.0141675 2.47188e-21)
(0.123528 -0.0146984 -2.69671e-22)
(0.139025 -0.014519 5.14431e-21)
(0.151827 -0.0137381 5.74134e-21)
(-0.000601887 -0.00114246 -1.42411e-21)
(0.00785821 -0.00228462 -3.01536e-21)
(0.0221856 -0.00430203 -5.92569e-21)
(0.0397534 -0.00582909 2.67827e-21)
(0.0590248 -0.0068422 0)
(0.0787574 -0.00725547 0)
(0.0979547 -0.00705665 -5.36614e-21)
(0.115845 -0.00631691 -5.4158e-21)
(0.131779 -0.00500157 5.28088e-21)
(0.145066 -0.00314288 -6.33322e-21)
(-0.00161313 -0.00158975 1.56191e-21)
(0.00493218 -0.00259261 1.65969e-21)
(0.0175694 -0.00373942 -9.1512e-21)
(0.033695 -0.0040612 1.4387e-20)
(0.0518437 -0.00368935 -2.66434e-21)
(0.0708204 -0.00265816 0)
(0.0896412 -0.00104557 0)
(0.107508 0.00100892 2.63849e-20)
(0.123675 0.00354165 -2.63419e-20)
(0.137283 0.00661754 -1.74766e-20)
(-0.00244952 -0.00215049 1.29771e-20)
(0.00236654 -0.00325376 0)
(0.0133634 -0.00376452 1.20539e-20)
(0.0279985 -0.00308543 -1.15032e-20)
(0.0448907 -0.00148938 0)
(0.0629109 0.000875795 5.50234e-21)
(0.0811161 0.00384148 -1.56651e-20)
(0.0987208 0.00719109 -2.11366e-20)
(0.114922 0.0109494 1.00645e-20)
(0.128698 0.0153125 1.0807e-20)
(-0.00311079 -0.00279395 -2.65698e-20)
(0.000178024 -0.00419434 -3.39586e-21)
(0.00961238 -0.0042792 -6.58778e-21)
(0.0227435 -0.00279608 -1.52226e-20)
(0.0382815 -0.000145662 -5.81755e-21)
(0.0551737 0.00341745 -5.68061e-21)
(0.0725402 0.00763314 -1.38176e-22)
(0.0896475 0.0121949 0)
(0.105692 0.0170894 0)
(0.119525 0.0226949 2.16596e-20)
(-0.00359933 -0.00349012 1.3593e-20)
(-0.00162653 -0.00534044 -1.41371e-20)
(0.00634416 -0.00518057 9.61442e-21)
(0.017987 -0.00307358 2.1612e-20)
(0.0321035 0.00046703 -5.81072e-21)
(0.0477171 0.00508628 5.44831e-21)
(0.0640158 0.0104287 5.39775e-21)
(0.0803416 0.0160711 0)
(0.0959622 0.0218809 0)
(0.109736 0.0284688 -1.0447e-20)
(-0.00392023 -0.00421008 -1.81201e-21)
(-0.00304902 -0.0066198 1.77809e-20)
(0.00357236 -0.00636507 -3.35788e-21)
(0.0137679 -0.00379002 0)
(0.0264262 0.000500628 0)
(0.0406319 0.00606745 1.13145e-20)
(0.0556061 0.0124674 0)
(0.0706985 0.0191368 -1.08476e-20)
(0.0852044 0.0256009 -4.17276e-22)
(0.098145 0.0324276 1.01236e-20)
(-0.00408118 -0.004927 0)
(-0.00409946 -0.00796527 0)
(0.00129754 -0.00773589 -1.42367e-20)
(0.0101122 -0.00482379 0)
(0.0213193 0.000109821 6.25884e-21)
(0.034053 0.00659296 -5.80015e-21)
(0.0475264 0.0142043 0)
(0.06099 0.0225314 0)
(0.0737764 0.0312732 -1.11135e-20)
(0.0855329 0.0413207 2.17169e-20)
(-0.00408958 -0.00561287 0)
(-0.0047935 -0.00931559 -1.17114e-20)
(-0.000489877 -0.00920933 -3.99499e-21)
(0.00703538 -0.00607889 -1.37523e-20)
(0.0168567 -0.000611876 -6.48078e-21)
(0.0281848 0.00672085 -1.81071e-20)
(0.0402989 0.0155416 0)
(0.0525486 0.0255606 0)
(0.0645691 0.0365733 0)
(0.0763332 0.0488728 2.7059e-22)
(-0.00395572 -0.00623733 0)
(-0.00515484 -0.0106126 -4.45412e-21)
(-0.00181088 -0.0107138 7.01938e-21)
(0.00453239 -0.00748414 1.02991e-20)
(0.0130628 -0.00161904 -3.39186e-22)
(0.0230874 0.00641885 -3.0165e-22)
(0.0339842 0.0162679 1.18075e-20)
(0.0452213 0.0276451 -1.13139e-20)
(0.0565454 0.0402841 2.22463e-20)
(0.0677913 0.054006 -2.20669e-20)
(-0.00369629 -0.00677595 -2.09479e-21)
(-0.00521482 -0.0118082 1.19494e-20)
(-0.0026972 -0.0121917 1.88632e-20)
(0.00257677 -0.0089851 -2.17095e-20)
(0.00991501 -0.00288017 1.31495e-20)
(0.0187243 0.00566757 1.23604e-20)
(0.0284753 0.0162899 -5.89181e-21)
(0.0387202 0.0286537 2.29337e-20)
(0.0492194 0.0423766 5.75863e-22)
(0.0596759 0.0570093 -1.08516e-20)
(-0.00333142 -0.00720921 -2.17944e-21)
(-0.00500923 -0.0128649 2.07075e-21)
(-0.00318586 -0.0135981 0)
(0.00113335 -0.0105388 1.81986e-20)
(0.00737739 -0.00436455 -3.41548e-21)
(0.0150505 0.00447719 -2.8758e-23)
(0.023706 0.0156067 -6.06046e-21)
(0.0329585 0.0286381 -1.77015e-20)
(0.0425576 0.0430952 -8.50042e-23)
(0.0521404 0.0583772 1.69783e-20)
(-0.00288319 -0.00752288 0)
(-0.00457495 -0.0137563 -1.29882e-20)
(-0.00331318 -0.0149005 3.983e-21)
(0.00016893 -0.0121105 -1.13989e-20)
(0.00541787 -0.00604064 3.49983e-21)
(0.0120314 0.00287488 -1.28864e-22)
(0.0196383 0.0142514 -1.20698e-22)
(0.0279034 0.0276684 1.19018e-20)
(0.0365635 0.0425961 -1.72198e-20)
(0.04524 0.0583574 1.69565e-20)
(-0.00237417 -0.00770845 1.13973e-21)
(-0.0039469 -0.0144685 8.6687e-21)
(-0.0031091 -0.0160766 0)
(-0.000339563 -0.0136711 1.14874e-20)
(0.00401764 -0.00787411 -1.08839e-20)
(0.00964886 0.000900431 -3.41673e-21)
(0.0162538 0.0122751 9.50479e-21)
(0.0235431 0.025819 0)
(0.0312493 0.0409849 0)
(0.0390116 0.0570732 0)
(-0.00182677 -0.00776448 -1.17161e-21)
(-0.00315448 -0.015 -3.40442e-21)
(-0.00259156 -0.0171142 4.23339e-21)
(-0.000398394 -0.0151943 5.95346e-21)
(0.00317949 -0.00982455 5.47e-21)
(0.00791134 -0.0013916 3.51061e-21)
(0.013565 0.00974819 0)
(0.0198984 0.0231774 6.25686e-21)
(0.0266534 0.0383622 -2.87656e-21)
(0.0335054 0.0546183 0)
(-0.00126098 -0.00769867 0)
(-0.00221731 -0.0153606 6.815e-21)
(-0.00176278 -0.0180085 -4.23249e-21)
(7.38112e-06 -0.0166547 -3.97094e-21)
(0.00293349 -0.0118426 4.07678e-24)
(0.00686036 -0.00392877 -1.74957e-21)
(0.0116222 0.00676312 1.69207e-21)
(0.0170289 0.0198506 0)
(0.0228462 0.0348386 -2.98305e-21)
(0.0287917 0.0510878 -2.9675e-21)
(-0.000691434 -0.00753195 1.5108e-22)
(-0.00114247 -0.0155735 -2.58955e-21)
(-0.000607713 -0.0187633 -2.79038e-22)
(0.000915416 -0.0180244 -9.66232e-24)
(0.0033385 -0.0138656 -1.42711e-21)
(0.00657271 -0.00661505 0)
(0.0105165 0.00344272 -1.69159e-21)
(0.0150363 0.0159766 0)
(0.0199363 0.0305528 0)
(0.0249734 0.0466031 0)
)
;
boundaryField
{
inlet
{
type uniformFixedValue;
uniformValue constant (1 0 0);
value uniform (1 0 0);
}
outlet
{
type pressureInletOutletVelocity;
value nonuniform List<vector>
40
(
(0.0192432 0.0444647 0)
(0.0298165 0.124965 0)
(0.0339195 0.198756 0)
(0.0308233 0.265451 0)
(0.0254136 0.336385 0)
(0.0206478 0.415247 0)
(0.0146469 0.50209 0)
(0.0101854 0.602453 0)
(0.00263609 0.720444 0)
(0.00117772 0.828417 0)
(0 3.56276e-05 0)
(0 -0.0177665 0)
(0 -0.0344216 0)
(0 -0.049869 0)
(0 -0.064105 0)
(0 -0.0771504 0)
(0 -0.0890502 0)
(0 -0.099867 0)
(0 -0.109672 0)
(0 -0.118537 0)
(0 -0.126535 0)
(0 -0.133734 0)
(0 -0.140204 0)
(0 -0.146018 0)
(0 -0.151253 0)
(0 -0.155992 0)
(0 -0.160324 0)
(0 -0.16434 0)
(0 -0.168135 0)
(0 -0.171806 0)
(0 -0.18044 0)
(0 -0.198282 0)
(0 -0.223667 0)
(0 -0.259546 0)
(0 -0.307157 0)
(0 -0.363804 0)
(0 -0.421801 0)
(0 -0.471002 0)
(0 -0.504663 0)
(0 -0.521305 0)
)
;
}
cylinder
{
type fixedValue;
value uniform (0 0 0);
}
top
{
type symmetryPlane;
}
bottom
{
type symmetryPlane;
}
defaultFaces
{
type empty;
}
}
// ************************************************************************* //
| [
"[email protected]"
] | ||
5288b4cc39075b43d83ffaef09b91b8c45268cbb | a426b23e859afa7a696f9a7b004d56c5e1123e96 | /设计模式/模板方法/Template Method.cpp | 400fc39f84c3d7efdfe206573457b10139911f30 | [] | no_license | hustjlshi/c-file | da855abdc7fb0a8dd3905f05ce85626f491cc2f5 | 35d6f5526ce1e0d3bd5e96970de38be8efe7251c | refs/heads/master | 2020-06-17T11:58:54.879733 | 2019-07-09T02:25:31 | 2019-07-09T02:25:31 | 195,917,511 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 916 | cpp | #include<bits/stdc++.h>
using namespace std;
class Resume{
protected:
virtual void setperson(){}
virtual void seteducation(){}
virtual void setwork(){}
public:
void File(){
setperson();
seteducation();
setwork();
}
};
class ResumeA : public Resume{
protected:
virtual void setperson(){
cout << "setpersonA" << endl;
}
virtual void seteducation(){
cout << "seteducationA" << endl;
}
virtual void setwork(){
cout << "setworkA" << endl;
}
};
class ResumeB : public Resume{
protected:
virtual void setperson(){
cout << "setpersonB" << endl;
}
virtual void seteducation(){
cout << "seteducationB" << endl;
}
virtual void setwork(){
cout << "setworkB" << endl;
}
};
int main(){
Resume *p = new ResumeA;
p -> File();
p = new ResumeB;
p -> File();
delete p;
}
| [
"[email protected]"
] | |
d4fbacd93fb94bc62c05b2794168240770ba8294 | 94dcc118f9492896d6781e5a3f59867eddfbc78a | /llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | a4a52b7c87958d59b6825006f1b831684927b4fa | [
"Apache-2.0",
"NCSA"
] | permissive | vusec/safeinit | 43fd500b5a832cce2bd87696988b64a718a5d764 | 8425bc49497684fe16e0063190dec8c3c58dc81a | refs/heads/master | 2021-07-07T11:46:25.138899 | 2021-05-05T10:40:52 | 2021-05-05T10:40:52 | 76,794,423 | 22 | 5 | null | null | null | null | UTF-8 | C++ | false | false | 97,336 | cpp | //===-- AddressSanitizer.cpp - memory error detector ------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file is a part of AddressSanitizer, an address sanity checker.
// Details of the algorithm:
// http://code.google.com/p/address-sanitizer/wiki/AddressSanitizerAlgorithm
//
//===----------------------------------------------------------------------===//
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Analysis/MemoryBuiltins.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/DIBuilder.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/InstVisitor.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/MC/MCSectionMachO.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/SwapByteOrder.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Instrumentation.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/ASanStackFrameLayout.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
#include "llvm/Transforms/Utils/PromoteMemToReg.h"
#include <algorithm>
#include <string>
#include <system_error>
using namespace llvm;
#define DEBUG_TYPE "asan"
static const uint64_t kDefaultShadowScale = 3;
static const uint64_t kDefaultShadowOffset32 = 1ULL << 29;
static const uint64_t kDefaultShadowOffset64 = 1ULL << 44;
static const uint64_t kIOSShadowOffset32 = 1ULL << 30;
static const uint64_t kIOSShadowOffset64 = 0x120200000;
static const uint64_t kIOSSimShadowOffset32 = 1ULL << 30;
static const uint64_t kIOSSimShadowOffset64 = kDefaultShadowOffset64;
static const uint64_t kSmallX86_64ShadowOffset = 0x7FFF8000; // < 2G.
static const uint64_t kLinuxKasan_ShadowOffset64 = 0xdffffc0000000000;
static const uint64_t kPPC64_ShadowOffset64 = 1ULL << 41;
static const uint64_t kSystemZ_ShadowOffset64 = 1ULL << 52;
static const uint64_t kMIPS32_ShadowOffset32 = 0x0aaa0000;
static const uint64_t kMIPS64_ShadowOffset64 = 1ULL << 37;
static const uint64_t kAArch64_ShadowOffset64 = 1ULL << 36;
static const uint64_t kFreeBSD_ShadowOffset32 = 1ULL << 30;
static const uint64_t kFreeBSD_ShadowOffset64 = 1ULL << 46;
static const uint64_t kWindowsShadowOffset32 = 3ULL << 28;
static const size_t kMinStackMallocSize = 1 << 6; // 64B
static const size_t kMaxStackMallocSize = 1 << 16; // 64K
static const uintptr_t kCurrentStackFrameMagic = 0x41B58AB3;
static const uintptr_t kRetiredStackFrameMagic = 0x45E0360E;
static const char *const kAsanModuleCtorName = "asan.module_ctor";
static const char *const kAsanModuleDtorName = "asan.module_dtor";
static const uint64_t kAsanCtorAndDtorPriority = 1;
static const char *const kAsanReportErrorTemplate = "__asan_report_";
static const char *const kAsanRegisterGlobalsName = "__asan_register_globals";
static const char *const kAsanUnregisterGlobalsName =
"__asan_unregister_globals";
static const char *const kAsanRegisterImageGlobalsName =
"__asan_register_image_globals";
static const char *const kAsanUnregisterImageGlobalsName =
"__asan_unregister_image_globals";
static const char *const kAsanPoisonGlobalsName = "__asan_before_dynamic_init";
static const char *const kAsanUnpoisonGlobalsName = "__asan_after_dynamic_init";
static const char *const kAsanInitName = "__asan_init";
static const char *const kAsanVersionCheckName =
"__asan_version_mismatch_check_v8";
static const char *const kAsanPtrCmp = "__sanitizer_ptr_cmp";
static const char *const kAsanPtrSub = "__sanitizer_ptr_sub";
static const char *const kAsanHandleNoReturnName = "__asan_handle_no_return";
static const int kMaxAsanStackMallocSizeClass = 10;
static const char *const kAsanStackMallocNameTemplate = "__asan_stack_malloc_";
static const char *const kAsanStackFreeNameTemplate = "__asan_stack_free_";
static const char *const kAsanGenPrefix = "__asan_gen_";
static const char *const kODRGenPrefix = "__odr_asan_gen_";
static const char *const kSanCovGenPrefix = "__sancov_gen_";
static const char *const kAsanPoisonStackMemoryName =
"__asan_poison_stack_memory";
static const char *const kAsanUnpoisonStackMemoryName =
"__asan_unpoison_stack_memory";
static const char *const kAsanGlobalsRegisteredFlagName =
"__asan_globals_registered";
static const char *const kAsanOptionDetectUAR =
"__asan_option_detect_stack_use_after_return";
static const char *const kAsanAllocaPoison = "__asan_alloca_poison";
static const char *const kAsanAllocasUnpoison = "__asan_allocas_unpoison";
// Accesses sizes are powers of two: 1, 2, 4, 8, 16.
static const size_t kNumberOfAccessSizes = 5;
static const unsigned kAllocaRzSize = 32;
// Command-line flags.
static cl::opt<bool> ClEnableKasan(
"asan-kernel", cl::desc("Enable KernelAddressSanitizer instrumentation"),
cl::Hidden, cl::init(false));
static cl::opt<bool> ClRecover(
"asan-recover",
cl::desc("Enable recovery mode (continue-after-error)."),
cl::Hidden, cl::init(false));
// This flag may need to be replaced with -f[no-]asan-reads.
static cl::opt<bool> ClInstrumentReads("asan-instrument-reads",
cl::desc("instrument read instructions"),
cl::Hidden, cl::init(true));
static cl::opt<bool> ClInstrumentWrites(
"asan-instrument-writes", cl::desc("instrument write instructions"),
cl::Hidden, cl::init(true));
static cl::opt<bool> ClInstrumentAtomics(
"asan-instrument-atomics",
cl::desc("instrument atomic instructions (rmw, cmpxchg)"), cl::Hidden,
cl::init(true));
static cl::opt<bool> ClAlwaysSlowPath(
"asan-always-slow-path",
cl::desc("use instrumentation with slow path for all accesses"), cl::Hidden,
cl::init(false));
// This flag limits the number of instructions to be instrumented
// in any given BB. Normally, this should be set to unlimited (INT_MAX),
// but due to http://llvm.org/bugs/show_bug.cgi?id=12652 we temporary
// set it to 10000.
static cl::opt<int> ClMaxInsnsToInstrumentPerBB(
"asan-max-ins-per-bb", cl::init(10000),
cl::desc("maximal number of instructions to instrument in any given BB"),
cl::Hidden);
// This flag may need to be replaced with -f[no]asan-stack.
static cl::opt<bool> ClStack("asan-stack", cl::desc("Handle stack memory"),
cl::Hidden, cl::init(true));
static cl::opt<bool> ClUseAfterReturn("asan-use-after-return",
cl::desc("Check stack-use-after-return"),
cl::Hidden, cl::init(true));
static cl::opt<bool> ClUseAfterScope("asan-use-after-scope",
cl::desc("Check stack-use-after-scope"),
cl::Hidden, cl::init(false));
// This flag may need to be replaced with -f[no]asan-globals.
static cl::opt<bool> ClGlobals("asan-globals",
cl::desc("Handle global objects"), cl::Hidden,
cl::init(true));
static cl::opt<bool> ClInitializers("asan-initialization-order",
cl::desc("Handle C++ initializer order"),
cl::Hidden, cl::init(true));
static cl::opt<bool> ClInvalidPointerPairs(
"asan-detect-invalid-pointer-pair",
cl::desc("Instrument <, <=, >, >=, - with pointer operands"), cl::Hidden,
cl::init(false));
static cl::opt<unsigned> ClRealignStack(
"asan-realign-stack",
cl::desc("Realign stack to the value of this flag (power of two)"),
cl::Hidden, cl::init(32));
static cl::opt<int> ClInstrumentationWithCallsThreshold(
"asan-instrumentation-with-call-threshold",
cl::desc(
"If the function being instrumented contains more than "
"this number of memory accesses, use callbacks instead of "
"inline checks (-1 means never use callbacks)."),
cl::Hidden, cl::init(7000));
static cl::opt<std::string> ClMemoryAccessCallbackPrefix(
"asan-memory-access-callback-prefix",
cl::desc("Prefix for memory access callbacks"), cl::Hidden,
cl::init("__asan_"));
static cl::opt<bool> ClInstrumentAllocas("asan-instrument-allocas",
cl::desc("instrument dynamic allocas"),
cl::Hidden, cl::init(true));
static cl::opt<bool> ClSkipPromotableAllocas(
"asan-skip-promotable-allocas",
cl::desc("Do not instrument promotable allocas"), cl::Hidden,
cl::init(true));
// These flags allow to change the shadow mapping.
// The shadow mapping looks like
// Shadow = (Mem >> scale) + offset
static cl::opt<int> ClMappingScale("asan-mapping-scale",
cl::desc("scale of asan shadow mapping"),
cl::Hidden, cl::init(0));
static cl::opt<unsigned long long> ClMappingOffset(
"asan-mapping-offset",
cl::desc("offset of asan shadow mapping [EXPERIMENTAL]"), cl::Hidden,
cl::init(0));
// Optimization flags. Not user visible, used mostly for testing
// and benchmarking the tool.
static cl::opt<bool> ClOpt("asan-opt", cl::desc("Optimize instrumentation"),
cl::Hidden, cl::init(true));
static cl::opt<bool> ClOptSameTemp(
"asan-opt-same-temp", cl::desc("Instrument the same temp just once"),
cl::Hidden, cl::init(true));
static cl::opt<bool> ClOptGlobals("asan-opt-globals",
cl::desc("Don't instrument scalar globals"),
cl::Hidden, cl::init(true));
static cl::opt<bool> ClOptStack(
"asan-opt-stack", cl::desc("Don't instrument scalar stack variables"),
cl::Hidden, cl::init(false));
static cl::opt<bool> ClDynamicAllocaStack(
"asan-stack-dynamic-alloca",
cl::desc("Use dynamic alloca to represent stack variables"), cl::Hidden,
cl::init(true));
static cl::opt<uint32_t> ClForceExperiment(
"asan-force-experiment",
cl::desc("Force optimization experiment (for testing)"), cl::Hidden,
cl::init(0));
static cl::opt<bool>
ClUsePrivateAliasForGlobals("asan-use-private-alias",
cl::desc("Use private aliases for global"
" variables"),
cl::Hidden, cl::init(false));
// Debug flags.
static cl::opt<int> ClDebug("asan-debug", cl::desc("debug"), cl::Hidden,
cl::init(0));
static cl::opt<int> ClDebugStack("asan-debug-stack", cl::desc("debug stack"),
cl::Hidden, cl::init(0));
static cl::opt<std::string> ClDebugFunc("asan-debug-func", cl::Hidden,
cl::desc("Debug func"));
static cl::opt<int> ClDebugMin("asan-debug-min", cl::desc("Debug min inst"),
cl::Hidden, cl::init(-1));
static cl::opt<int> ClDebugMax("asan-debug-max", cl::desc("Debug man inst"),
cl::Hidden, cl::init(-1));
STATISTIC(NumInstrumentedReads, "Number of instrumented reads");
STATISTIC(NumInstrumentedWrites, "Number of instrumented writes");
STATISTIC(NumOptimizedAccessesToGlobalVar,
"Number of optimized accesses to global vars");
STATISTIC(NumOptimizedAccessesToStackVar,
"Number of optimized accesses to stack vars");
namespace {
/// Frontend-provided metadata for source location.
struct LocationMetadata {
StringRef Filename;
int LineNo;
int ColumnNo;
LocationMetadata() : Filename(), LineNo(0), ColumnNo(0) {}
bool empty() const { return Filename.empty(); }
void parse(MDNode *MDN) {
assert(MDN->getNumOperands() == 3);
MDString *DIFilename = cast<MDString>(MDN->getOperand(0));
Filename = DIFilename->getString();
LineNo =
mdconst::extract<ConstantInt>(MDN->getOperand(1))->getLimitedValue();
ColumnNo =
mdconst::extract<ConstantInt>(MDN->getOperand(2))->getLimitedValue();
}
};
/// Frontend-provided metadata for global variables.
class GlobalsMetadata {
public:
struct Entry {
Entry() : SourceLoc(), Name(), IsDynInit(false), IsBlacklisted(false) {}
LocationMetadata SourceLoc;
StringRef Name;
bool IsDynInit;
bool IsBlacklisted;
};
GlobalsMetadata() : inited_(false) {}
void reset() {
inited_ = false;
Entries.clear();
}
void init(Module &M) {
assert(!inited_);
inited_ = true;
NamedMDNode *Globals = M.getNamedMetadata("llvm.asan.globals");
if (!Globals) return;
for (auto MDN : Globals->operands()) {
// Metadata node contains the global and the fields of "Entry".
assert(MDN->getNumOperands() == 5);
auto *GV = mdconst::extract_or_null<GlobalVariable>(MDN->getOperand(0));
// The optimizer may optimize away a global entirely.
if (!GV) continue;
// We can already have an entry for GV if it was merged with another
// global.
Entry &E = Entries[GV];
if (auto *Loc = cast_or_null<MDNode>(MDN->getOperand(1)))
E.SourceLoc.parse(Loc);
if (auto *Name = cast_or_null<MDString>(MDN->getOperand(2)))
E.Name = Name->getString();
ConstantInt *IsDynInit =
mdconst::extract<ConstantInt>(MDN->getOperand(3));
E.IsDynInit |= IsDynInit->isOne();
ConstantInt *IsBlacklisted =
mdconst::extract<ConstantInt>(MDN->getOperand(4));
E.IsBlacklisted |= IsBlacklisted->isOne();
}
}
/// Returns metadata entry for a given global.
Entry get(GlobalVariable *G) const {
auto Pos = Entries.find(G);
return (Pos != Entries.end()) ? Pos->second : Entry();
}
private:
bool inited_;
DenseMap<GlobalVariable *, Entry> Entries;
};
/// This struct defines the shadow mapping using the rule:
/// shadow = (mem >> Scale) ADD-or-OR Offset.
struct ShadowMapping {
int Scale;
uint64_t Offset;
bool OrShadowOffset;
};
static ShadowMapping getShadowMapping(Triple &TargetTriple, int LongSize,
bool IsKasan) {
bool IsAndroid = TargetTriple.isAndroid();
bool IsIOS = TargetTriple.isiOS() || TargetTriple.isWatchOS();
bool IsFreeBSD = TargetTriple.isOSFreeBSD();
bool IsLinux = TargetTriple.isOSLinux();
bool IsPPC64 = TargetTriple.getArch() == llvm::Triple::ppc64 ||
TargetTriple.getArch() == llvm::Triple::ppc64le;
bool IsSystemZ = TargetTriple.getArch() == llvm::Triple::systemz;
bool IsX86 = TargetTriple.getArch() == llvm::Triple::x86;
bool IsX86_64 = TargetTriple.getArch() == llvm::Triple::x86_64;
bool IsMIPS32 = TargetTriple.getArch() == llvm::Triple::mips ||
TargetTriple.getArch() == llvm::Triple::mipsel;
bool IsMIPS64 = TargetTriple.getArch() == llvm::Triple::mips64 ||
TargetTriple.getArch() == llvm::Triple::mips64el;
bool IsAArch64 = TargetTriple.getArch() == llvm::Triple::aarch64;
bool IsWindows = TargetTriple.isOSWindows();
ShadowMapping Mapping;
if (LongSize == 32) {
// Android is always PIE, which means that the beginning of the address
// space is always available.
if (IsAndroid)
Mapping.Offset = 0;
else if (IsMIPS32)
Mapping.Offset = kMIPS32_ShadowOffset32;
else if (IsFreeBSD)
Mapping.Offset = kFreeBSD_ShadowOffset32;
else if (IsIOS)
// If we're targeting iOS and x86, the binary is built for iOS simulator.
Mapping.Offset = IsX86 ? kIOSSimShadowOffset32 : kIOSShadowOffset32;
else if (IsWindows)
Mapping.Offset = kWindowsShadowOffset32;
else
Mapping.Offset = kDefaultShadowOffset32;
} else { // LongSize == 64
if (IsPPC64)
Mapping.Offset = kPPC64_ShadowOffset64;
else if (IsSystemZ)
Mapping.Offset = kSystemZ_ShadowOffset64;
else if (IsFreeBSD)
Mapping.Offset = kFreeBSD_ShadowOffset64;
else if (IsLinux && IsX86_64) {
if (IsKasan)
Mapping.Offset = kLinuxKasan_ShadowOffset64;
else
Mapping.Offset = kSmallX86_64ShadowOffset;
} else if (IsMIPS64)
Mapping.Offset = kMIPS64_ShadowOffset64;
else if (IsIOS)
// If we're targeting iOS and x86, the binary is built for iOS simulator.
Mapping.Offset = IsX86_64 ? kIOSSimShadowOffset64 : kIOSShadowOffset64;
else if (IsAArch64)
Mapping.Offset = kAArch64_ShadowOffset64;
else
Mapping.Offset = kDefaultShadowOffset64;
}
Mapping.Scale = kDefaultShadowScale;
if (ClMappingScale.getNumOccurrences() > 0) {
Mapping.Scale = ClMappingScale;
}
if (ClMappingOffset.getNumOccurrences() > 0) {
Mapping.Offset = ClMappingOffset;
}
// OR-ing shadow offset if more efficient (at least on x86) if the offset
// is a power of two, but on ppc64 we have to use add since the shadow
// offset is not necessary 1/8-th of the address space. On SystemZ,
// we could OR the constant in a single instruction, but it's more
// efficient to load it once and use indexed addressing.
Mapping.OrShadowOffset = !IsAArch64 && !IsPPC64 && !IsSystemZ
&& !(Mapping.Offset & (Mapping.Offset - 1));
return Mapping;
}
static size_t RedzoneSizeForScale(int MappingScale) {
// Redzone used for stack and globals is at least 32 bytes.
// For scales 6 and 7, the redzone has to be 64 and 128 bytes respectively.
return std::max(32U, 1U << MappingScale);
}
/// AddressSanitizer: instrument the code in module to find memory bugs.
struct AddressSanitizer : public FunctionPass {
explicit AddressSanitizer(bool CompileKernel = false, bool Recover = false)
: FunctionPass(ID), CompileKernel(CompileKernel || ClEnableKasan),
Recover(Recover || ClRecover) {
initializeAddressSanitizerPass(*PassRegistry::getPassRegistry());
}
const char *getPassName() const override {
return "AddressSanitizerFunctionPass";
}
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addRequired<DominatorTreeWrapperPass>();
AU.addRequired<TargetLibraryInfoWrapperPass>();
}
uint64_t getAllocaSizeInBytes(AllocaInst *AI) const {
Type *Ty = AI->getAllocatedType();
uint64_t SizeInBytes =
AI->getModule()->getDataLayout().getTypeAllocSize(Ty);
return SizeInBytes;
}
/// Check if we want (and can) handle this alloca.
bool isInterestingAlloca(AllocaInst &AI);
// Check if we have dynamic alloca.
bool isDynamicAlloca(AllocaInst &AI) const {
return AI.isArrayAllocation() || !AI.isStaticAlloca();
}
/// If it is an interesting memory access, return the PointerOperand
/// and set IsWrite/Alignment. Otherwise return nullptr.
Value *isInterestingMemoryAccess(Instruction *I, bool *IsWrite,
uint64_t *TypeSize, unsigned *Alignment);
void instrumentMop(ObjectSizeOffsetVisitor &ObjSizeVis, Instruction *I,
bool UseCalls, const DataLayout &DL);
void instrumentPointerComparisonOrSubtraction(Instruction *I);
void instrumentAddress(Instruction *OrigIns, Instruction *InsertBefore,
Value *Addr, uint32_t TypeSize, bool IsWrite,
Value *SizeArgument, bool UseCalls, uint32_t Exp);
void instrumentUnusualSizeOrAlignment(Instruction *I, Value *Addr,
uint32_t TypeSize, bool IsWrite,
Value *SizeArgument, bool UseCalls,
uint32_t Exp);
Value *createSlowPathCmp(IRBuilder<> &IRB, Value *AddrLong,
Value *ShadowValue, uint32_t TypeSize);
Instruction *generateCrashCode(Instruction *InsertBefore, Value *Addr,
bool IsWrite, size_t AccessSizeIndex,
Value *SizeArgument, uint32_t Exp);
void instrumentMemIntrinsic(MemIntrinsic *MI);
Value *memToShadow(Value *Shadow, IRBuilder<> &IRB);
bool runOnFunction(Function &F) override;
bool maybeInsertAsanInitAtFunctionEntry(Function &F);
void markEscapedLocalAllocas(Function &F);
bool doInitialization(Module &M) override;
bool doFinalization(Module &M) override;
static char ID; // Pass identification, replacement for typeid
DominatorTree &getDominatorTree() const { return *DT; }
private:
void initializeCallbacks(Module &M);
bool LooksLikeCodeInBug11395(Instruction *I);
bool GlobalIsLinkerInitialized(GlobalVariable *G);
bool isSafeAccess(ObjectSizeOffsetVisitor &ObjSizeVis, Value *Addr,
uint64_t TypeSize) const;
/// Helper to cleanup per-function state.
struct FunctionStateRAII {
AddressSanitizer *Pass;
FunctionStateRAII(AddressSanitizer *Pass) : Pass(Pass) {
assert(Pass->ProcessedAllocas.empty() &&
"last pass forgot to clear cache");
}
~FunctionStateRAII() { Pass->ProcessedAllocas.clear(); }
};
LLVMContext *C;
Triple TargetTriple;
int LongSize;
bool CompileKernel;
bool Recover;
Type *IntptrTy;
ShadowMapping Mapping;
DominatorTree *DT;
Function *AsanCtorFunction = nullptr;
Function *AsanInitFunction = nullptr;
Function *AsanHandleNoReturnFunc;
Function *AsanPtrCmpFunction, *AsanPtrSubFunction;
// This array is indexed by AccessIsWrite, Experiment and log2(AccessSize).
Function *AsanErrorCallback[2][2][kNumberOfAccessSizes];
Function *AsanMemoryAccessCallback[2][2][kNumberOfAccessSizes];
// This array is indexed by AccessIsWrite and Experiment.
Function *AsanErrorCallbackSized[2][2];
Function *AsanMemoryAccessCallbackSized[2][2];
Function *AsanMemmove, *AsanMemcpy, *AsanMemset;
InlineAsm *EmptyAsm;
GlobalsMetadata GlobalsMD;
DenseMap<AllocaInst *, bool> ProcessedAllocas;
friend struct FunctionStackPoisoner;
};
class AddressSanitizerModule : public ModulePass {
public:
explicit AddressSanitizerModule(bool CompileKernel = false,
bool Recover = false)
: ModulePass(ID), CompileKernel(CompileKernel || ClEnableKasan),
Recover(Recover || ClRecover) {}
bool runOnModule(Module &M) override;
static char ID; // Pass identification, replacement for typeid
const char *getPassName() const override { return "AddressSanitizerModule"; }
private:
void initializeCallbacks(Module &M);
bool InstrumentGlobals(IRBuilder<> &IRB, Module &M);
bool ShouldInstrumentGlobal(GlobalVariable *G);
bool ShouldUseMachOGlobalsSection() const;
void poisonOneInitializer(Function &GlobalInit, GlobalValue *ModuleName);
void createInitializerPoisonCalls(Module &M, GlobalValue *ModuleName);
size_t MinRedzoneSizeForGlobal() const {
return RedzoneSizeForScale(Mapping.Scale);
}
GlobalsMetadata GlobalsMD;
bool CompileKernel;
bool Recover;
Type *IntptrTy;
LLVMContext *C;
Triple TargetTriple;
ShadowMapping Mapping;
Function *AsanPoisonGlobals;
Function *AsanUnpoisonGlobals;
Function *AsanRegisterGlobals;
Function *AsanUnregisterGlobals;
Function *AsanRegisterImageGlobals;
Function *AsanUnregisterImageGlobals;
};
// Stack poisoning does not play well with exception handling.
// When an exception is thrown, we essentially bypass the code
// that unpoisones the stack. This is why the run-time library has
// to intercept __cxa_throw (as well as longjmp, etc) and unpoison the entire
// stack in the interceptor. This however does not work inside the
// actual function which catches the exception. Most likely because the
// compiler hoists the load of the shadow value somewhere too high.
// This causes asan to report a non-existing bug on 453.povray.
// It sounds like an LLVM bug.
struct FunctionStackPoisoner : public InstVisitor<FunctionStackPoisoner> {
Function &F;
AddressSanitizer &ASan;
DIBuilder DIB;
LLVMContext *C;
Type *IntptrTy;
Type *IntptrPtrTy;
ShadowMapping Mapping;
SmallVector<AllocaInst *, 16> AllocaVec;
SmallSetVector<AllocaInst *, 16> NonInstrumentedStaticAllocaVec;
SmallVector<Instruction *, 8> RetVec;
unsigned StackAlignment;
Function *AsanStackMallocFunc[kMaxAsanStackMallocSizeClass + 1],
*AsanStackFreeFunc[kMaxAsanStackMallocSizeClass + 1];
Function *AsanPoisonStackMemoryFunc, *AsanUnpoisonStackMemoryFunc;
Function *AsanAllocaPoisonFunc, *AsanAllocasUnpoisonFunc;
// Stores a place and arguments of poisoning/unpoisoning call for alloca.
struct AllocaPoisonCall {
IntrinsicInst *InsBefore;
AllocaInst *AI;
uint64_t Size;
bool DoPoison;
};
SmallVector<AllocaPoisonCall, 8> AllocaPoisonCallVec;
SmallVector<AllocaInst *, 1> DynamicAllocaVec;
SmallVector<IntrinsicInst *, 1> StackRestoreVec;
AllocaInst *DynamicAllocaLayout = nullptr;
IntrinsicInst *LocalEscapeCall = nullptr;
// Maps Value to an AllocaInst from which the Value is originated.
typedef DenseMap<Value *, AllocaInst *> AllocaForValueMapTy;
AllocaForValueMapTy AllocaForValue;
bool HasNonEmptyInlineAsm = false;
bool HasReturnsTwiceCall = false;
std::unique_ptr<CallInst> EmptyInlineAsm;
FunctionStackPoisoner(Function &F, AddressSanitizer &ASan)
: F(F),
ASan(ASan),
DIB(*F.getParent(), /*AllowUnresolved*/ false),
C(ASan.C),
IntptrTy(ASan.IntptrTy),
IntptrPtrTy(PointerType::get(IntptrTy, 0)),
Mapping(ASan.Mapping),
StackAlignment(1 << Mapping.Scale),
EmptyInlineAsm(CallInst::Create(ASan.EmptyAsm)) {}
bool runOnFunction() {
if (!ClStack) return false;
// Collect alloca, ret, lifetime instructions etc.
for (BasicBlock *BB : depth_first(&F.getEntryBlock())) visit(*BB);
if (AllocaVec.empty() && DynamicAllocaVec.empty()) return false;
initializeCallbacks(*F.getParent());
poisonStack();
if (ClDebugStack) {
DEBUG(dbgs() << F);
}
return true;
}
// Finds all Alloca instructions and puts
// poisoned red zones around all of them.
// Then unpoison everything back before the function returns.
void poisonStack();
void createDynamicAllocasInitStorage();
// ----------------------- Visitors.
/// \brief Collect all Ret instructions.
void visitReturnInst(ReturnInst &RI) { RetVec.push_back(&RI); }
void unpoisonDynamicAllocasBeforeInst(Instruction *InstBefore,
Value *SavedStack) {
IRBuilder<> IRB(InstBefore);
Value *DynamicAreaPtr = IRB.CreatePtrToInt(SavedStack, IntptrTy);
// When we insert _asan_allocas_unpoison before @llvm.stackrestore, we
// need to adjust extracted SP to compute the address of the most recent
// alloca. We have a special @llvm.get.dynamic.area.offset intrinsic for
// this purpose.
if (!isa<ReturnInst>(InstBefore)) {
Function *DynamicAreaOffsetFunc = Intrinsic::getDeclaration(
InstBefore->getModule(), Intrinsic::get_dynamic_area_offset,
{IntptrTy});
Value *DynamicAreaOffset = IRB.CreateCall(DynamicAreaOffsetFunc, {});
DynamicAreaPtr = IRB.CreateAdd(IRB.CreatePtrToInt(SavedStack, IntptrTy),
DynamicAreaOffset);
}
IRB.CreateCall(AsanAllocasUnpoisonFunc,
{IRB.CreateLoad(DynamicAllocaLayout), DynamicAreaPtr});
}
// Unpoison dynamic allocas redzones.
void unpoisonDynamicAllocas() {
for (auto &Ret : RetVec)
unpoisonDynamicAllocasBeforeInst(Ret, DynamicAllocaLayout);
for (auto &StackRestoreInst : StackRestoreVec)
unpoisonDynamicAllocasBeforeInst(StackRestoreInst,
StackRestoreInst->getOperand(0));
}
// Deploy and poison redzones around dynamic alloca call. To do this, we
// should replace this call with another one with changed parameters and
// replace all its uses with new address, so
// addr = alloca type, old_size, align
// is replaced by
// new_size = (old_size + additional_size) * sizeof(type)
// tmp = alloca i8, new_size, max(align, 32)
// addr = tmp + 32 (first 32 bytes are for the left redzone).
// Additional_size is added to make new memory allocation contain not only
// requested memory, but also left, partial and right redzones.
void handleDynamicAllocaCall(AllocaInst *AI);
/// \brief Collect Alloca instructions we want (and can) handle.
void visitAllocaInst(AllocaInst &AI) {
if (!ASan.isInterestingAlloca(AI)) {
if (AI.isStaticAlloca()) NonInstrumentedStaticAllocaVec.insert(&AI);
return;
}
StackAlignment = std::max(StackAlignment, AI.getAlignment());
if (ASan.isDynamicAlloca(AI))
DynamicAllocaVec.push_back(&AI);
else
AllocaVec.push_back(&AI);
}
/// \brief Collect lifetime intrinsic calls to check for use-after-scope
/// errors.
void visitIntrinsicInst(IntrinsicInst &II) {
Intrinsic::ID ID = II.getIntrinsicID();
if (ID == Intrinsic::stackrestore) StackRestoreVec.push_back(&II);
if (ID == Intrinsic::localescape) LocalEscapeCall = &II;
if (!ClUseAfterScope) return;
if (ID != Intrinsic::lifetime_start && ID != Intrinsic::lifetime_end)
return;
// Found lifetime intrinsic, add ASan instrumentation if necessary.
ConstantInt *Size = dyn_cast<ConstantInt>(II.getArgOperand(0));
// If size argument is undefined, don't do anything.
if (Size->isMinusOne()) return;
// Check that size doesn't saturate uint64_t and can
// be stored in IntptrTy.
const uint64_t SizeValue = Size->getValue().getLimitedValue();
if (SizeValue == ~0ULL ||
!ConstantInt::isValueValidForType(IntptrTy, SizeValue))
return;
// Find alloca instruction that corresponds to llvm.lifetime argument.
AllocaInst *AI = findAllocaForValue(II.getArgOperand(1));
if (!AI) return;
bool DoPoison = (ID == Intrinsic::lifetime_end);
AllocaPoisonCall APC = {&II, AI, SizeValue, DoPoison};
AllocaPoisonCallVec.push_back(APC);
}
void visitCallSite(CallSite CS) {
Instruction *I = CS.getInstruction();
if (CallInst *CI = dyn_cast<CallInst>(I)) {
HasNonEmptyInlineAsm |=
CI->isInlineAsm() && !CI->isIdenticalTo(EmptyInlineAsm.get());
HasReturnsTwiceCall |= CI->canReturnTwice();
}
}
// ---------------------- Helpers.
void initializeCallbacks(Module &M);
bool doesDominateAllExits(const Instruction *I) const {
for (auto Ret : RetVec) {
if (!ASan.getDominatorTree().dominates(I, Ret)) return false;
}
return true;
}
/// Finds alloca where the value comes from.
AllocaInst *findAllocaForValue(Value *V);
void poisonRedZones(ArrayRef<uint8_t> ShadowBytes, IRBuilder<> &IRB,
Value *ShadowBase, bool DoPoison);
void poisonAlloca(Value *V, uint64_t Size, IRBuilder<> &IRB, bool DoPoison);
void SetShadowToStackAfterReturnInlined(IRBuilder<> &IRB, Value *ShadowBase,
int Size);
Value *createAllocaForLayout(IRBuilder<> &IRB, const ASanStackFrameLayout &L,
bool Dynamic);
PHINode *createPHI(IRBuilder<> &IRB, Value *Cond, Value *ValueIfTrue,
Instruction *ThenTerm, Value *ValueIfFalse);
};
} // anonymous namespace
char AddressSanitizer::ID = 0;
INITIALIZE_PASS_BEGIN(
AddressSanitizer, "asan",
"AddressSanitizer: detects use-after-free and out-of-bounds bugs.", false,
false)
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
INITIALIZE_PASS_END(
AddressSanitizer, "asan",
"AddressSanitizer: detects use-after-free and out-of-bounds bugs.", false,
false)
FunctionPass *llvm::createAddressSanitizerFunctionPass(bool CompileKernel,
bool Recover) {
assert(!CompileKernel || Recover);
return new AddressSanitizer(CompileKernel, Recover);
}
char AddressSanitizerModule::ID = 0;
INITIALIZE_PASS(
AddressSanitizerModule, "asan-module",
"AddressSanitizer: detects use-after-free and out-of-bounds bugs."
"ModulePass",
false, false)
ModulePass *llvm::createAddressSanitizerModulePass(bool CompileKernel,
bool Recover) {
assert(!CompileKernel || Recover);
return new AddressSanitizerModule(CompileKernel, Recover);
}
static size_t TypeSizeToSizeIndex(uint32_t TypeSize) {
size_t Res = countTrailingZeros(TypeSize / 8);
assert(Res < kNumberOfAccessSizes);
return Res;
}
// \brief Create a constant for Str so that we can pass it to the run-time lib.
static GlobalVariable *createPrivateGlobalForString(Module &M, StringRef Str,
bool AllowMerging) {
Constant *StrConst = ConstantDataArray::getString(M.getContext(), Str);
// We use private linkage for module-local strings. If they can be merged
// with another one, we set the unnamed_addr attribute.
GlobalVariable *GV =
new GlobalVariable(M, StrConst->getType(), true,
GlobalValue::PrivateLinkage, StrConst, kAsanGenPrefix);
if (AllowMerging) GV->setUnnamedAddr(true);
GV->setAlignment(1); // Strings may not be merged w/o setting align 1.
return GV;
}
/// \brief Create a global describing a source location.
static GlobalVariable *createPrivateGlobalForSourceLoc(Module &M,
LocationMetadata MD) {
Constant *LocData[] = {
createPrivateGlobalForString(M, MD.Filename, true),
ConstantInt::get(Type::getInt32Ty(M.getContext()), MD.LineNo),
ConstantInt::get(Type::getInt32Ty(M.getContext()), MD.ColumnNo),
};
auto LocStruct = ConstantStruct::getAnon(LocData);
auto GV = new GlobalVariable(M, LocStruct->getType(), true,
GlobalValue::PrivateLinkage, LocStruct,
kAsanGenPrefix);
GV->setUnnamedAddr(true);
return GV;
}
static bool GlobalWasGeneratedByAsan(GlobalVariable *G) {
return G->getName().find(kAsanGenPrefix) == 0 ||
G->getName().find(kSanCovGenPrefix) == 0 ||
G->getName().find(kODRGenPrefix) == 0;
}
Value *AddressSanitizer::memToShadow(Value *Shadow, IRBuilder<> &IRB) {
// Shadow >> scale
Shadow = IRB.CreateLShr(Shadow, Mapping.Scale);
if (Mapping.Offset == 0) return Shadow;
// (Shadow >> scale) | offset
if (Mapping.OrShadowOffset)
return IRB.CreateOr(Shadow, ConstantInt::get(IntptrTy, Mapping.Offset));
else
return IRB.CreateAdd(Shadow, ConstantInt::get(IntptrTy, Mapping.Offset));
}
// Instrument memset/memmove/memcpy
void AddressSanitizer::instrumentMemIntrinsic(MemIntrinsic *MI) {
IRBuilder<> IRB(MI);
if (isa<MemTransferInst>(MI)) {
IRB.CreateCall(
isa<MemMoveInst>(MI) ? AsanMemmove : AsanMemcpy,
{IRB.CreatePointerCast(MI->getOperand(0), IRB.getInt8PtrTy()),
IRB.CreatePointerCast(MI->getOperand(1), IRB.getInt8PtrTy()),
IRB.CreateIntCast(MI->getOperand(2), IntptrTy, false)});
} else if (isa<MemSetInst>(MI)) {
IRB.CreateCall(
AsanMemset,
{IRB.CreatePointerCast(MI->getOperand(0), IRB.getInt8PtrTy()),
IRB.CreateIntCast(MI->getOperand(1), IRB.getInt32Ty(), false),
IRB.CreateIntCast(MI->getOperand(2), IntptrTy, false)});
}
MI->eraseFromParent();
}
/// Check if we want (and can) handle this alloca.
bool AddressSanitizer::isInterestingAlloca(AllocaInst &AI) {
auto PreviouslySeenAllocaInfo = ProcessedAllocas.find(&AI);
if (PreviouslySeenAllocaInfo != ProcessedAllocas.end())
return PreviouslySeenAllocaInfo->getSecond();
bool IsInteresting =
(AI.getAllocatedType()->isSized() &&
// alloca() may be called with 0 size, ignore it.
getAllocaSizeInBytes(&AI) > 0 &&
// We are only interested in allocas not promotable to registers.
// Promotable allocas are common under -O0.
(!ClSkipPromotableAllocas || !isAllocaPromotable(&AI)) &&
// inalloca allocas are not treated as static, and we don't want
// dynamic alloca instrumentation for them as well.
!AI.isUsedWithInAlloca());
ProcessedAllocas[&AI] = IsInteresting;
return IsInteresting;
}
/// If I is an interesting memory access, return the PointerOperand
/// and set IsWrite/Alignment. Otherwise return nullptr.
Value *AddressSanitizer::isInterestingMemoryAccess(Instruction *I,
bool *IsWrite,
uint64_t *TypeSize,
unsigned *Alignment) {
// Skip memory accesses inserted by another instrumentation.
if (I->getMetadata("nosanitize")) return nullptr;
Value *PtrOperand = nullptr;
const DataLayout &DL = I->getModule()->getDataLayout();
if (LoadInst *LI = dyn_cast<LoadInst>(I)) {
if (!ClInstrumentReads) return nullptr;
*IsWrite = false;
*TypeSize = DL.getTypeStoreSizeInBits(LI->getType());
*Alignment = LI->getAlignment();
PtrOperand = LI->getPointerOperand();
} else if (StoreInst *SI = dyn_cast<StoreInst>(I)) {
if (!ClInstrumentWrites) return nullptr;
*IsWrite = true;
*TypeSize = DL.getTypeStoreSizeInBits(SI->getValueOperand()->getType());
*Alignment = SI->getAlignment();
PtrOperand = SI->getPointerOperand();
} else if (AtomicRMWInst *RMW = dyn_cast<AtomicRMWInst>(I)) {
if (!ClInstrumentAtomics) return nullptr;
*IsWrite = true;
*TypeSize = DL.getTypeStoreSizeInBits(RMW->getValOperand()->getType());
*Alignment = 0;
PtrOperand = RMW->getPointerOperand();
} else if (AtomicCmpXchgInst *XCHG = dyn_cast<AtomicCmpXchgInst>(I)) {
if (!ClInstrumentAtomics) return nullptr;
*IsWrite = true;
*TypeSize = DL.getTypeStoreSizeInBits(XCHG->getCompareOperand()->getType());
*Alignment = 0;
PtrOperand = XCHG->getPointerOperand();
}
// Treat memory accesses to promotable allocas as non-interesting since they
// will not cause memory violations. This greatly speeds up the instrumented
// executable at -O0.
if (ClSkipPromotableAllocas)
if (auto AI = dyn_cast_or_null<AllocaInst>(PtrOperand))
return isInterestingAlloca(*AI) ? AI : nullptr;
return PtrOperand;
}
static bool isPointerOperand(Value *V) {
return V->getType()->isPointerTy() || isa<PtrToIntInst>(V);
}
// This is a rough heuristic; it may cause both false positives and
// false negatives. The proper implementation requires cooperation with
// the frontend.
static bool isInterestingPointerComparisonOrSubtraction(Instruction *I) {
if (ICmpInst *Cmp = dyn_cast<ICmpInst>(I)) {
if (!Cmp->isRelational()) return false;
} else if (BinaryOperator *BO = dyn_cast<BinaryOperator>(I)) {
if (BO->getOpcode() != Instruction::Sub) return false;
} else {
return false;
}
return isPointerOperand(I->getOperand(0)) &&
isPointerOperand(I->getOperand(1));
}
bool AddressSanitizer::GlobalIsLinkerInitialized(GlobalVariable *G) {
// If a global variable does not have dynamic initialization we don't
// have to instrument it. However, if a global does not have initializer
// at all, we assume it has dynamic initializer (in other TU).
return G->hasInitializer() && !GlobalsMD.get(G).IsDynInit;
}
void AddressSanitizer::instrumentPointerComparisonOrSubtraction(
Instruction *I) {
IRBuilder<> IRB(I);
Function *F = isa<ICmpInst>(I) ? AsanPtrCmpFunction : AsanPtrSubFunction;
Value *Param[2] = {I->getOperand(0), I->getOperand(1)};
for (int i = 0; i < 2; i++) {
if (Param[i]->getType()->isPointerTy())
Param[i] = IRB.CreatePointerCast(Param[i], IntptrTy);
}
IRB.CreateCall(F, Param);
}
void AddressSanitizer::instrumentMop(ObjectSizeOffsetVisitor &ObjSizeVis,
Instruction *I, bool UseCalls,
const DataLayout &DL) {
bool IsWrite = false;
unsigned Alignment = 0;
uint64_t TypeSize = 0;
Value *Addr = isInterestingMemoryAccess(I, &IsWrite, &TypeSize, &Alignment);
assert(Addr);
// Optimization experiments.
// The experiments can be used to evaluate potential optimizations that remove
// instrumentation (assess false negatives). Instead of completely removing
// some instrumentation, you set Exp to a non-zero value (mask of optimization
// experiments that want to remove instrumentation of this instruction).
// If Exp is non-zero, this pass will emit special calls into runtime
// (e.g. __asan_report_exp_load1 instead of __asan_report_load1). These calls
// make runtime terminate the program in a special way (with a different
// exit status). Then you run the new compiler on a buggy corpus, collect
// the special terminations (ideally, you don't see them at all -- no false
// negatives) and make the decision on the optimization.
uint32_t Exp = ClForceExperiment;
if (ClOpt && ClOptGlobals) {
// If initialization order checking is disabled, a simple access to a
// dynamically initialized global is always valid.
GlobalVariable *G = dyn_cast<GlobalVariable>(GetUnderlyingObject(Addr, DL));
if (G && (!ClInitializers || GlobalIsLinkerInitialized(G)) &&
isSafeAccess(ObjSizeVis, Addr, TypeSize)) {
NumOptimizedAccessesToGlobalVar++;
return;
}
}
if (ClOpt && ClOptStack) {
// A direct inbounds access to a stack variable is always valid.
if (isa<AllocaInst>(GetUnderlyingObject(Addr, DL)) &&
isSafeAccess(ObjSizeVis, Addr, TypeSize)) {
NumOptimizedAccessesToStackVar++;
return;
}
}
if (IsWrite)
NumInstrumentedWrites++;
else
NumInstrumentedReads++;
unsigned Granularity = 1 << Mapping.Scale;
// Instrument a 1-, 2-, 4-, 8-, or 16- byte access with one check
// if the data is properly aligned.
if ((TypeSize == 8 || TypeSize == 16 || TypeSize == 32 || TypeSize == 64 ||
TypeSize == 128) &&
(Alignment >= Granularity || Alignment == 0 || Alignment >= TypeSize / 8))
return instrumentAddress(I, I, Addr, TypeSize, IsWrite, nullptr, UseCalls,
Exp);
instrumentUnusualSizeOrAlignment(I, Addr, TypeSize, IsWrite, nullptr,
UseCalls, Exp);
}
Instruction *AddressSanitizer::generateCrashCode(Instruction *InsertBefore,
Value *Addr, bool IsWrite,
size_t AccessSizeIndex,
Value *SizeArgument,
uint32_t Exp) {
IRBuilder<> IRB(InsertBefore);
Value *ExpVal = Exp == 0 ? nullptr : ConstantInt::get(IRB.getInt32Ty(), Exp);
CallInst *Call = nullptr;
if (SizeArgument) {
if (Exp == 0)
Call = IRB.CreateCall(AsanErrorCallbackSized[IsWrite][0],
{Addr, SizeArgument});
else
Call = IRB.CreateCall(AsanErrorCallbackSized[IsWrite][1],
{Addr, SizeArgument, ExpVal});
} else {
if (Exp == 0)
Call =
IRB.CreateCall(AsanErrorCallback[IsWrite][0][AccessSizeIndex], Addr);
else
Call = IRB.CreateCall(AsanErrorCallback[IsWrite][1][AccessSizeIndex],
{Addr, ExpVal});
}
// We don't do Call->setDoesNotReturn() because the BB already has
// UnreachableInst at the end.
// This EmptyAsm is required to avoid callback merge.
IRB.CreateCall(EmptyAsm, {});
return Call;
}
Value *AddressSanitizer::createSlowPathCmp(IRBuilder<> &IRB, Value *AddrLong,
Value *ShadowValue,
uint32_t TypeSize) {
size_t Granularity = static_cast<size_t>(1) << Mapping.Scale;
// Addr & (Granularity - 1)
Value *LastAccessedByte =
IRB.CreateAnd(AddrLong, ConstantInt::get(IntptrTy, Granularity - 1));
// (Addr & (Granularity - 1)) + size - 1
if (TypeSize / 8 > 1)
LastAccessedByte = IRB.CreateAdd(
LastAccessedByte, ConstantInt::get(IntptrTy, TypeSize / 8 - 1));
// (uint8_t) ((Addr & (Granularity-1)) + size - 1)
LastAccessedByte =
IRB.CreateIntCast(LastAccessedByte, ShadowValue->getType(), false);
// ((uint8_t) ((Addr & (Granularity-1)) + size - 1)) >= ShadowValue
return IRB.CreateICmpSGE(LastAccessedByte, ShadowValue);
}
void AddressSanitizer::instrumentAddress(Instruction *OrigIns,
Instruction *InsertBefore, Value *Addr,
uint32_t TypeSize, bool IsWrite,
Value *SizeArgument, bool UseCalls,
uint32_t Exp) {
IRBuilder<> IRB(InsertBefore);
Value *AddrLong = IRB.CreatePointerCast(Addr, IntptrTy);
size_t AccessSizeIndex = TypeSizeToSizeIndex(TypeSize);
if (UseCalls) {
if (Exp == 0)
IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][0][AccessSizeIndex],
AddrLong);
else
IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][1][AccessSizeIndex],
{AddrLong, ConstantInt::get(IRB.getInt32Ty(), Exp)});
return;
}
Type *ShadowTy =
IntegerType::get(*C, std::max(8U, TypeSize >> Mapping.Scale));
Type *ShadowPtrTy = PointerType::get(ShadowTy, 0);
Value *ShadowPtr = memToShadow(AddrLong, IRB);
Value *CmpVal = Constant::getNullValue(ShadowTy);
Value *ShadowValue =
IRB.CreateLoad(IRB.CreateIntToPtr(ShadowPtr, ShadowPtrTy));
Value *Cmp = IRB.CreateICmpNE(ShadowValue, CmpVal);
size_t Granularity = 1ULL << Mapping.Scale;
TerminatorInst *CrashTerm = nullptr;
if (ClAlwaysSlowPath || (TypeSize < 8 * Granularity)) {
// We use branch weights for the slow path check, to indicate that the slow
// path is rarely taken. This seems to be the case for SPEC benchmarks.
TerminatorInst *CheckTerm = SplitBlockAndInsertIfThen(
Cmp, InsertBefore, false, MDBuilder(*C).createBranchWeights(1, 100000));
assert(cast<BranchInst>(CheckTerm)->isUnconditional());
BasicBlock *NextBB = CheckTerm->getSuccessor(0);
IRB.SetInsertPoint(CheckTerm);
Value *Cmp2 = createSlowPathCmp(IRB, AddrLong, ShadowValue, TypeSize);
if (Recover) {
CrashTerm = SplitBlockAndInsertIfThen(Cmp2, CheckTerm, false);
} else {
BasicBlock *CrashBlock =
BasicBlock::Create(*C, "", NextBB->getParent(), NextBB);
CrashTerm = new UnreachableInst(*C, CrashBlock);
BranchInst *NewTerm = BranchInst::Create(CrashBlock, NextBB, Cmp2);
ReplaceInstWithInst(CheckTerm, NewTerm);
}
} else {
CrashTerm = SplitBlockAndInsertIfThen(Cmp, InsertBefore, !Recover);
}
Instruction *Crash = generateCrashCode(CrashTerm, AddrLong, IsWrite,
AccessSizeIndex, SizeArgument, Exp);
Crash->setDebugLoc(OrigIns->getDebugLoc());
}
// Instrument unusual size or unusual alignment.
// We can not do it with a single check, so we do 1-byte check for the first
// and the last bytes. We call __asan_report_*_n(addr, real_size) to be able
// to report the actual access size.
void AddressSanitizer::instrumentUnusualSizeOrAlignment(
Instruction *I, Value *Addr, uint32_t TypeSize, bool IsWrite,
Value *SizeArgument, bool UseCalls, uint32_t Exp) {
IRBuilder<> IRB(I);
Value *Size = ConstantInt::get(IntptrTy, TypeSize / 8);
Value *AddrLong = IRB.CreatePointerCast(Addr, IntptrTy);
if (UseCalls) {
if (Exp == 0)
IRB.CreateCall(AsanMemoryAccessCallbackSized[IsWrite][0],
{AddrLong, Size});
else
IRB.CreateCall(AsanMemoryAccessCallbackSized[IsWrite][1],
{AddrLong, Size, ConstantInt::get(IRB.getInt32Ty(), Exp)});
} else {
Value *LastByte = IRB.CreateIntToPtr(
IRB.CreateAdd(AddrLong, ConstantInt::get(IntptrTy, TypeSize / 8 - 1)),
Addr->getType());
instrumentAddress(I, I, Addr, 8, IsWrite, Size, false, Exp);
instrumentAddress(I, I, LastByte, 8, IsWrite, Size, false, Exp);
}
}
void AddressSanitizerModule::poisonOneInitializer(Function &GlobalInit,
GlobalValue *ModuleName) {
// Set up the arguments to our poison/unpoison functions.
IRBuilder<> IRB(&GlobalInit.front(),
GlobalInit.front().getFirstInsertionPt());
// Add a call to poison all external globals before the given function starts.
Value *ModuleNameAddr = ConstantExpr::getPointerCast(ModuleName, IntptrTy);
IRB.CreateCall(AsanPoisonGlobals, ModuleNameAddr);
// Add calls to unpoison all globals before each return instruction.
for (auto &BB : GlobalInit.getBasicBlockList())
if (ReturnInst *RI = dyn_cast<ReturnInst>(BB.getTerminator()))
CallInst::Create(AsanUnpoisonGlobals, "", RI);
}
void AddressSanitizerModule::createInitializerPoisonCalls(
Module &M, GlobalValue *ModuleName) {
GlobalVariable *GV = M.getGlobalVariable("llvm.global_ctors");
ConstantArray *CA = cast<ConstantArray>(GV->getInitializer());
for (Use &OP : CA->operands()) {
if (isa<ConstantAggregateZero>(OP)) continue;
ConstantStruct *CS = cast<ConstantStruct>(OP);
// Must have a function or null ptr.
if (Function *F = dyn_cast<Function>(CS->getOperand(1))) {
if (F->getName() == kAsanModuleCtorName) continue;
ConstantInt *Priority = dyn_cast<ConstantInt>(CS->getOperand(0));
// Don't instrument CTORs that will run before asan.module_ctor.
if (Priority->getLimitedValue() <= kAsanCtorAndDtorPriority) continue;
poisonOneInitializer(*F, ModuleName);
}
}
}
bool AddressSanitizerModule::ShouldInstrumentGlobal(GlobalVariable *G) {
Type *Ty = G->getValueType();
DEBUG(dbgs() << "GLOBAL: " << *G << "\n");
if (GlobalsMD.get(G).IsBlacklisted) return false;
if (!Ty->isSized()) return false;
if (!G->hasInitializer()) return false;
if (GlobalWasGeneratedByAsan(G)) return false; // Our own global.
// Touch only those globals that will not be defined in other modules.
// Don't handle ODR linkage types and COMDATs since other modules may be built
// without ASan.
if (G->getLinkage() != GlobalVariable::ExternalLinkage &&
G->getLinkage() != GlobalVariable::PrivateLinkage &&
G->getLinkage() != GlobalVariable::InternalLinkage)
return false;
if (G->hasComdat()) return false;
// Two problems with thread-locals:
// - The address of the main thread's copy can't be computed at link-time.
// - Need to poison all copies, not just the main thread's one.
if (G->isThreadLocal()) return false;
// For now, just ignore this Global if the alignment is large.
if (G->getAlignment() > MinRedzoneSizeForGlobal()) return false;
if (G->hasSection()) {
StringRef Section = G->getSection();
// Globals from llvm.metadata aren't emitted, do not instrument them.
if (Section == "llvm.metadata") return false;
// Do not instrument globals from special LLVM sections.
if (Section.find("__llvm") != StringRef::npos || Section.find("__LLVM") != StringRef::npos) return false;
// Do not instrument function pointers to initialization and termination
// routines: dynamic linker will not properly handle redzones.
if (Section.startswith(".preinit_array") ||
Section.startswith(".init_array") ||
Section.startswith(".fini_array")) {
return false;
}
// Callbacks put into the CRT initializer/terminator sections
// should not be instrumented.
// See https://code.google.com/p/address-sanitizer/issues/detail?id=305
// and http://msdn.microsoft.com/en-US/en-en/library/bb918180(v=vs.120).aspx
if (Section.startswith(".CRT")) {
DEBUG(dbgs() << "Ignoring a global initializer callback: " << *G << "\n");
return false;
}
if (TargetTriple.isOSBinFormatMachO()) {
StringRef ParsedSegment, ParsedSection;
unsigned TAA = 0, StubSize = 0;
bool TAAParsed;
std::string ErrorCode = MCSectionMachO::ParseSectionSpecifier(
Section, ParsedSegment, ParsedSection, TAA, TAAParsed, StubSize);
assert(ErrorCode.empty() && "Invalid section specifier.");
// Ignore the globals from the __OBJC section. The ObjC runtime assumes
// those conform to /usr/lib/objc/runtime.h, so we can't add redzones to
// them.
if (ParsedSegment == "__OBJC" ||
(ParsedSegment == "__DATA" && ParsedSection.startswith("__objc_"))) {
DEBUG(dbgs() << "Ignoring ObjC runtime global: " << *G << "\n");
return false;
}
// See http://code.google.com/p/address-sanitizer/issues/detail?id=32
// Constant CFString instances are compiled in the following way:
// -- the string buffer is emitted into
// __TEXT,__cstring,cstring_literals
// -- the constant NSConstantString structure referencing that buffer
// is placed into __DATA,__cfstring
// Therefore there's no point in placing redzones into __DATA,__cfstring.
// Moreover, it causes the linker to crash on OS X 10.7
if (ParsedSegment == "__DATA" && ParsedSection == "__cfstring") {
DEBUG(dbgs() << "Ignoring CFString: " << *G << "\n");
return false;
}
// The linker merges the contents of cstring_literals and removes the
// trailing zeroes.
if (ParsedSegment == "__TEXT" && (TAA & MachO::S_CSTRING_LITERALS)) {
DEBUG(dbgs() << "Ignoring a cstring literal: " << *G << "\n");
return false;
}
}
}
return true;
}
// On Mach-O platforms, we emit global metadata in a separate section of the
// binary in order to allow the linker to properly dead strip. This is only
// supported on recent versions of ld64.
bool AddressSanitizerModule::ShouldUseMachOGlobalsSection() const {
if (!TargetTriple.isOSBinFormatMachO())
return false;
if (TargetTriple.isMacOSX() && !TargetTriple.isMacOSXVersionLT(10, 11))
return true;
if (TargetTriple.isiOS() /* or tvOS */ && !TargetTriple.isOSVersionLT(9))
return true;
if (TargetTriple.isWatchOS() && !TargetTriple.isOSVersionLT(2))
return true;
return false;
}
void AddressSanitizerModule::initializeCallbacks(Module &M) {
IRBuilder<> IRB(*C);
// Declare our poisoning and unpoisoning functions.
AsanPoisonGlobals = checkSanitizerInterfaceFunction(M.getOrInsertFunction(
kAsanPoisonGlobalsName, IRB.getVoidTy(), IntptrTy, nullptr));
AsanPoisonGlobals->setLinkage(Function::ExternalLinkage);
AsanUnpoisonGlobals = checkSanitizerInterfaceFunction(M.getOrInsertFunction(
kAsanUnpoisonGlobalsName, IRB.getVoidTy(), nullptr));
AsanUnpoisonGlobals->setLinkage(Function::ExternalLinkage);
// Declare functions that register/unregister globals.
AsanRegisterGlobals = checkSanitizerInterfaceFunction(M.getOrInsertFunction(
kAsanRegisterGlobalsName, IRB.getVoidTy(), IntptrTy, IntptrTy, nullptr));
AsanRegisterGlobals->setLinkage(Function::ExternalLinkage);
AsanUnregisterGlobals = checkSanitizerInterfaceFunction(
M.getOrInsertFunction(kAsanUnregisterGlobalsName, IRB.getVoidTy(),
IntptrTy, IntptrTy, nullptr));
AsanUnregisterGlobals->setLinkage(Function::ExternalLinkage);
// Declare the functions that find globals in a shared object and then invoke
// the (un)register function on them.
AsanRegisterImageGlobals = checkSanitizerInterfaceFunction(
M.getOrInsertFunction(kAsanRegisterImageGlobalsName,
IRB.getVoidTy(), IntptrTy, nullptr));
AsanRegisterImageGlobals->setLinkage(Function::ExternalLinkage);
AsanUnregisterImageGlobals = checkSanitizerInterfaceFunction(
M.getOrInsertFunction(kAsanUnregisterImageGlobalsName,
IRB.getVoidTy(), IntptrTy, nullptr));
AsanUnregisterImageGlobals->setLinkage(Function::ExternalLinkage);
}
// This function replaces all global variables with new variables that have
// trailing redzones. It also creates a function that poisons
// redzones and inserts this function into llvm.global_ctors.
bool AddressSanitizerModule::InstrumentGlobals(IRBuilder<> &IRB, Module &M) {
GlobalsMD.init(M);
SmallVector<GlobalVariable *, 16> GlobalsToChange;
for (auto &G : M.globals()) {
if (ShouldInstrumentGlobal(&G)) GlobalsToChange.push_back(&G);
}
size_t n = GlobalsToChange.size();
if (n == 0) return false;
// A global is described by a structure
// size_t beg;
// size_t size;
// size_t size_with_redzone;
// const char *name;
// const char *module_name;
// size_t has_dynamic_init;
// void *source_location;
// size_t odr_indicator;
// We initialize an array of such structures and pass it to a run-time call.
StructType *GlobalStructTy =
StructType::get(IntptrTy, IntptrTy, IntptrTy, IntptrTy, IntptrTy,
IntptrTy, IntptrTy, IntptrTy, nullptr);
SmallVector<Constant *, 16> Initializers(n);
bool HasDynamicallyInitializedGlobals = false;
// We shouldn't merge same module names, as this string serves as unique
// module ID in runtime.
GlobalVariable *ModuleName = createPrivateGlobalForString(
M, M.getModuleIdentifier(), /*AllowMerging*/ false);
auto &DL = M.getDataLayout();
for (size_t i = 0; i < n; i++) {
static const uint64_t kMaxGlobalRedzone = 1 << 18;
GlobalVariable *G = GlobalsToChange[i];
auto MD = GlobalsMD.get(G);
StringRef NameForGlobal = G->getName();
// Create string holding the global name (use global name from metadata
// if it's available, otherwise just write the name of global variable).
GlobalVariable *Name = createPrivateGlobalForString(
M, MD.Name.empty() ? NameForGlobal : MD.Name,
/*AllowMerging*/ true);
Type *Ty = G->getValueType();
uint64_t SizeInBytes = DL.getTypeAllocSize(Ty);
uint64_t MinRZ = MinRedzoneSizeForGlobal();
// MinRZ <= RZ <= kMaxGlobalRedzone
// and trying to make RZ to be ~ 1/4 of SizeInBytes.
uint64_t RZ = std::max(
MinRZ, std::min(kMaxGlobalRedzone, (SizeInBytes / MinRZ / 4) * MinRZ));
uint64_t RightRedzoneSize = RZ;
// Round up to MinRZ
if (SizeInBytes % MinRZ) RightRedzoneSize += MinRZ - (SizeInBytes % MinRZ);
assert(((RightRedzoneSize + SizeInBytes) % MinRZ) == 0);
Type *RightRedZoneTy = ArrayType::get(IRB.getInt8Ty(), RightRedzoneSize);
StructType *NewTy = StructType::get(Ty, RightRedZoneTy, nullptr);
Constant *NewInitializer =
ConstantStruct::get(NewTy, G->getInitializer(),
Constant::getNullValue(RightRedZoneTy), nullptr);
// Create a new global variable with enough space for a redzone.
GlobalValue::LinkageTypes Linkage = G->getLinkage();
if (G->isConstant() && Linkage == GlobalValue::PrivateLinkage)
Linkage = GlobalValue::InternalLinkage;
GlobalVariable *NewGlobal =
new GlobalVariable(M, NewTy, G->isConstant(), Linkage, NewInitializer,
"", G, G->getThreadLocalMode());
NewGlobal->copyAttributesFrom(G);
NewGlobal->setAlignment(MinRZ);
Value *Indices2[2];
Indices2[0] = IRB.getInt32(0);
Indices2[1] = IRB.getInt32(0);
G->replaceAllUsesWith(
ConstantExpr::getGetElementPtr(NewTy, NewGlobal, Indices2, true));
NewGlobal->takeName(G);
G->eraseFromParent();
Constant *SourceLoc;
if (!MD.SourceLoc.empty()) {
auto SourceLocGlobal = createPrivateGlobalForSourceLoc(M, MD.SourceLoc);
SourceLoc = ConstantExpr::getPointerCast(SourceLocGlobal, IntptrTy);
} else {
SourceLoc = ConstantInt::get(IntptrTy, 0);
}
Constant *ODRIndicator = ConstantExpr::getNullValue(IRB.getInt8PtrTy());
GlobalValue *InstrumentedGlobal = NewGlobal;
bool CanUsePrivateAliases = TargetTriple.isOSBinFormatELF();
if (CanUsePrivateAliases && ClUsePrivateAliasForGlobals) {
// Create local alias for NewGlobal to avoid crash on ODR between
// instrumented and non-instrumented libraries.
auto *GA = GlobalAlias::create(GlobalValue::InternalLinkage,
NameForGlobal + M.getName(), NewGlobal);
// With local aliases, we need to provide another externally visible
// symbol __odr_asan_XXX to detect ODR violation.
auto *ODRIndicatorSym =
new GlobalVariable(M, IRB.getInt8Ty(), false, Linkage,
Constant::getNullValue(IRB.getInt8Ty()),
kODRGenPrefix + NameForGlobal, nullptr,
NewGlobal->getThreadLocalMode());
// Set meaningful attributes for indicator symbol.
ODRIndicatorSym->setVisibility(NewGlobal->getVisibility());
ODRIndicatorSym->setDLLStorageClass(NewGlobal->getDLLStorageClass());
ODRIndicatorSym->setAlignment(1);
ODRIndicator = ODRIndicatorSym;
InstrumentedGlobal = GA;
}
Initializers[i] = ConstantStruct::get(
GlobalStructTy,
ConstantExpr::getPointerCast(InstrumentedGlobal, IntptrTy),
ConstantInt::get(IntptrTy, SizeInBytes),
ConstantInt::get(IntptrTy, SizeInBytes + RightRedzoneSize),
ConstantExpr::getPointerCast(Name, IntptrTy),
ConstantExpr::getPointerCast(ModuleName, IntptrTy),
ConstantInt::get(IntptrTy, MD.IsDynInit), SourceLoc,
ConstantExpr::getPointerCast(ODRIndicator, IntptrTy), nullptr);
if (ClInitializers && MD.IsDynInit) HasDynamicallyInitializedGlobals = true;
DEBUG(dbgs() << "NEW GLOBAL: " << *NewGlobal << "\n");
}
GlobalVariable *AllGlobals = nullptr;
GlobalVariable *RegisteredFlag = nullptr;
// On recent Mach-O platforms, we emit the global metadata in a way that
// allows the linker to properly strip dead globals.
if (ShouldUseMachOGlobalsSection()) {
// RegisteredFlag serves two purposes. First, we can pass it to dladdr()
// to look up the loaded image that contains it. Second, we can store in it
// whether registration has already occurred, to prevent duplicate
// registration.
//
// Common linkage allows us to coalesce needles defined in each object
// file so that there's only one per shared library.
RegisteredFlag = new GlobalVariable(
M, IntptrTy, false, GlobalVariable::CommonLinkage,
ConstantInt::get(IntptrTy, 0), kAsanGlobalsRegisteredFlagName);
// We also emit a structure which binds the liveness of the global
// variable to the metadata struct.
StructType *LivenessTy = StructType::get(IntptrTy, IntptrTy, nullptr);
for (size_t i = 0; i < n; i++) {
GlobalVariable *Metadata = new GlobalVariable(
M, GlobalStructTy, false, GlobalVariable::InternalLinkage,
Initializers[i], "");
Metadata->setSection("__DATA,__asan_globals,regular");
Metadata->setAlignment(1); // don't leave padding in between
auto LivenessBinder = ConstantStruct::get(LivenessTy,
Initializers[i]->getAggregateElement(0u),
ConstantExpr::getPointerCast(Metadata, IntptrTy),
nullptr);
GlobalVariable *Liveness = new GlobalVariable(
M, LivenessTy, false, GlobalVariable::InternalLinkage,
LivenessBinder, "");
Liveness->setSection("__DATA,__asan_liveness,regular,live_support");
}
} else {
// On all other platfoms, we just emit an array of global metadata
// structures.
ArrayType *ArrayOfGlobalStructTy = ArrayType::get(GlobalStructTy, n);
AllGlobals = new GlobalVariable(
M, ArrayOfGlobalStructTy, false, GlobalVariable::InternalLinkage,
ConstantArray::get(ArrayOfGlobalStructTy, Initializers), "");
}
// Create calls for poisoning before initializers run and unpoisoning after.
if (HasDynamicallyInitializedGlobals)
createInitializerPoisonCalls(M, ModuleName);
// Create a call to register the globals with the runtime.
if (ShouldUseMachOGlobalsSection()) {
IRB.CreateCall(AsanRegisterImageGlobals,
{IRB.CreatePointerCast(RegisteredFlag, IntptrTy)});
} else {
IRB.CreateCall(AsanRegisterGlobals,
{IRB.CreatePointerCast(AllGlobals, IntptrTy),
ConstantInt::get(IntptrTy, n)});
}
// We also need to unregister globals at the end, e.g., when a shared library
// gets closed.
Function *AsanDtorFunction =
Function::Create(FunctionType::get(Type::getVoidTy(*C), false),
GlobalValue::InternalLinkage, kAsanModuleDtorName, &M);
BasicBlock *AsanDtorBB = BasicBlock::Create(*C, "", AsanDtorFunction);
IRBuilder<> IRB_Dtor(ReturnInst::Create(*C, AsanDtorBB));
if (ShouldUseMachOGlobalsSection()) {
IRB_Dtor.CreateCall(AsanUnregisterImageGlobals,
{IRB.CreatePointerCast(RegisteredFlag, IntptrTy)});
} else {
IRB_Dtor.CreateCall(AsanUnregisterGlobals,
{IRB.CreatePointerCast(AllGlobals, IntptrTy),
ConstantInt::get(IntptrTy, n)});
}
appendToGlobalDtors(M, AsanDtorFunction, kAsanCtorAndDtorPriority);
DEBUG(dbgs() << M);
return true;
}
bool AddressSanitizerModule::runOnModule(Module &M) {
C = &(M.getContext());
int LongSize = M.getDataLayout().getPointerSizeInBits();
IntptrTy = Type::getIntNTy(*C, LongSize);
TargetTriple = Triple(M.getTargetTriple());
Mapping = getShadowMapping(TargetTriple, LongSize, CompileKernel);
initializeCallbacks(M);
bool Changed = false;
// TODO(glider): temporarily disabled globals instrumentation for KASan.
if (ClGlobals && !CompileKernel) {
Function *CtorFunc = M.getFunction(kAsanModuleCtorName);
assert(CtorFunc);
IRBuilder<> IRB(CtorFunc->getEntryBlock().getTerminator());
Changed |= InstrumentGlobals(IRB, M);
}
return Changed;
}
void AddressSanitizer::initializeCallbacks(Module &M) {
IRBuilder<> IRB(*C);
// Create __asan_report* callbacks.
// IsWrite, TypeSize and Exp are encoded in the function name.
for (int Exp = 0; Exp < 2; Exp++) {
for (size_t AccessIsWrite = 0; AccessIsWrite <= 1; AccessIsWrite++) {
const std::string TypeStr = AccessIsWrite ? "store" : "load";
const std::string ExpStr = Exp ? "exp_" : "";
const std::string SuffixStr = CompileKernel ? "N" : "_n";
const std::string EndingStr = Recover ? "_noabort" : "";
Type *ExpType = Exp ? Type::getInt32Ty(*C) : nullptr;
AsanErrorCallbackSized[AccessIsWrite][Exp] =
checkSanitizerInterfaceFunction(M.getOrInsertFunction(
kAsanReportErrorTemplate + ExpStr + TypeStr + SuffixStr + EndingStr,
IRB.getVoidTy(), IntptrTy, IntptrTy, ExpType, nullptr));
AsanMemoryAccessCallbackSized[AccessIsWrite][Exp] =
checkSanitizerInterfaceFunction(M.getOrInsertFunction(
ClMemoryAccessCallbackPrefix + ExpStr + TypeStr + "N" + EndingStr,
IRB.getVoidTy(), IntptrTy, IntptrTy, ExpType, nullptr));
for (size_t AccessSizeIndex = 0; AccessSizeIndex < kNumberOfAccessSizes;
AccessSizeIndex++) {
const std::string Suffix = TypeStr + itostr(1ULL << AccessSizeIndex);
AsanErrorCallback[AccessIsWrite][Exp][AccessSizeIndex] =
checkSanitizerInterfaceFunction(M.getOrInsertFunction(
kAsanReportErrorTemplate + ExpStr + Suffix + EndingStr,
IRB.getVoidTy(), IntptrTy, ExpType, nullptr));
AsanMemoryAccessCallback[AccessIsWrite][Exp][AccessSizeIndex] =
checkSanitizerInterfaceFunction(M.getOrInsertFunction(
ClMemoryAccessCallbackPrefix + ExpStr + Suffix + EndingStr,
IRB.getVoidTy(), IntptrTy, ExpType, nullptr));
}
}
}
const std::string MemIntrinCallbackPrefix =
CompileKernel ? std::string("") : ClMemoryAccessCallbackPrefix;
AsanMemmove = checkSanitizerInterfaceFunction(M.getOrInsertFunction(
MemIntrinCallbackPrefix + "memmove", IRB.getInt8PtrTy(),
IRB.getInt8PtrTy(), IRB.getInt8PtrTy(), IntptrTy, nullptr));
AsanMemcpy = checkSanitizerInterfaceFunction(M.getOrInsertFunction(
MemIntrinCallbackPrefix + "memcpy", IRB.getInt8PtrTy(),
IRB.getInt8PtrTy(), IRB.getInt8PtrTy(), IntptrTy, nullptr));
AsanMemset = checkSanitizerInterfaceFunction(M.getOrInsertFunction(
MemIntrinCallbackPrefix + "memset", IRB.getInt8PtrTy(),
IRB.getInt8PtrTy(), IRB.getInt32Ty(), IntptrTy, nullptr));
AsanHandleNoReturnFunc = checkSanitizerInterfaceFunction(
M.getOrInsertFunction(kAsanHandleNoReturnName, IRB.getVoidTy(), nullptr));
AsanPtrCmpFunction = checkSanitizerInterfaceFunction(M.getOrInsertFunction(
kAsanPtrCmp, IRB.getVoidTy(), IntptrTy, IntptrTy, nullptr));
AsanPtrSubFunction = checkSanitizerInterfaceFunction(M.getOrInsertFunction(
kAsanPtrSub, IRB.getVoidTy(), IntptrTy, IntptrTy, nullptr));
// We insert an empty inline asm after __asan_report* to avoid callback merge.
EmptyAsm = InlineAsm::get(FunctionType::get(IRB.getVoidTy(), false),
StringRef(""), StringRef(""),
/*hasSideEffects=*/true);
}
// virtual
bool AddressSanitizer::doInitialization(Module &M) {
// Initialize the private fields. No one has accessed them before.
GlobalsMD.init(M);
C = &(M.getContext());
LongSize = M.getDataLayout().getPointerSizeInBits();
IntptrTy = Type::getIntNTy(*C, LongSize);
TargetTriple = Triple(M.getTargetTriple());
if (!CompileKernel) {
std::tie(AsanCtorFunction, AsanInitFunction) =
createSanitizerCtorAndInitFunctions(
M, kAsanModuleCtorName, kAsanInitName,
/*InitArgTypes=*/{}, /*InitArgs=*/{}, kAsanVersionCheckName);
appendToGlobalCtors(M, AsanCtorFunction, kAsanCtorAndDtorPriority);
}
Mapping = getShadowMapping(TargetTriple, LongSize, CompileKernel);
return true;
}
bool AddressSanitizer::doFinalization(Module &M) {
GlobalsMD.reset();
return false;
}
bool AddressSanitizer::maybeInsertAsanInitAtFunctionEntry(Function &F) {
// For each NSObject descendant having a +load method, this method is invoked
// by the ObjC runtime before any of the static constructors is called.
// Therefore we need to instrument such methods with a call to __asan_init
// at the beginning in order to initialize our runtime before any access to
// the shadow memory.
// We cannot just ignore these methods, because they may call other
// instrumented functions.
if (F.getName().find(" load]") != std::string::npos) {
IRBuilder<> IRB(&F.front(), F.front().begin());
IRB.CreateCall(AsanInitFunction, {});
return true;
}
return false;
}
void AddressSanitizer::markEscapedLocalAllocas(Function &F) {
// Find the one possible call to llvm.localescape and pre-mark allocas passed
// to it as uninteresting. This assumes we haven't started processing allocas
// yet. This check is done up front because iterating the use list in
// isInterestingAlloca would be algorithmically slower.
assert(ProcessedAllocas.empty() && "must process localescape before allocas");
// Try to get the declaration of llvm.localescape. If it's not in the module,
// we can exit early.
if (!F.getParent()->getFunction("llvm.localescape")) return;
// Look for a call to llvm.localescape call in the entry block. It can't be in
// any other block.
for (Instruction &I : F.getEntryBlock()) {
IntrinsicInst *II = dyn_cast<IntrinsicInst>(&I);
if (II && II->getIntrinsicID() == Intrinsic::localescape) {
// We found a call. Mark all the allocas passed in as uninteresting.
for (Value *Arg : II->arg_operands()) {
AllocaInst *AI = dyn_cast<AllocaInst>(Arg->stripPointerCasts());
assert(AI && AI->isStaticAlloca() &&
"non-static alloca arg to localescape");
ProcessedAllocas[AI] = false;
}
break;
}
}
}
bool AddressSanitizer::runOnFunction(Function &F) {
if (&F == AsanCtorFunction) return false;
if (F.getLinkage() == GlobalValue::AvailableExternallyLinkage) return false;
DEBUG(dbgs() << "ASAN instrumenting:\n" << F << "\n");
initializeCallbacks(*F.getParent());
DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
// If needed, insert __asan_init before checking for SanitizeAddress attr.
maybeInsertAsanInitAtFunctionEntry(F);
if (!F.hasFnAttribute(Attribute::SanitizeAddress)) return false;
if (!ClDebugFunc.empty() && ClDebugFunc != F.getName()) return false;
FunctionStateRAII CleanupObj(this);
// We can't instrument allocas used with llvm.localescape. Only static allocas
// can be passed to that intrinsic.
markEscapedLocalAllocas(F);
// We want to instrument every address only once per basic block (unless there
// are calls between uses).
SmallSet<Value *, 16> TempsToInstrument;
SmallVector<Instruction *, 16> ToInstrument;
SmallVector<Instruction *, 8> NoReturnCalls;
SmallVector<BasicBlock *, 16> AllBlocks;
SmallVector<Instruction *, 16> PointerComparisonsOrSubtracts;
int NumAllocas = 0;
bool IsWrite;
unsigned Alignment;
uint64_t TypeSize;
// Fill the set of memory operations to instrument.
for (auto &BB : F) {
AllBlocks.push_back(&BB);
TempsToInstrument.clear();
int NumInsnsPerBB = 0;
for (auto &Inst : BB) {
if (LooksLikeCodeInBug11395(&Inst)) return false;
if (Value *Addr = isInterestingMemoryAccess(&Inst, &IsWrite, &TypeSize,
&Alignment)) {
if (ClOpt && ClOptSameTemp) {
if (!TempsToInstrument.insert(Addr).second)
continue; // We've seen this temp in the current BB.
}
} else if (ClInvalidPointerPairs &&
isInterestingPointerComparisonOrSubtraction(&Inst)) {
PointerComparisonsOrSubtracts.push_back(&Inst);
continue;
} else if (isa<MemIntrinsic>(Inst)) {
// ok, take it.
} else {
if (isa<AllocaInst>(Inst)) NumAllocas++;
CallSite CS(&Inst);
if (CS) {
// A call inside BB.
TempsToInstrument.clear();
if (CS.doesNotReturn()) NoReturnCalls.push_back(CS.getInstruction());
}
continue;
}
ToInstrument.push_back(&Inst);
NumInsnsPerBB++;
if (NumInsnsPerBB >= ClMaxInsnsToInstrumentPerBB) break;
}
}
bool UseCalls =
CompileKernel ||
(ClInstrumentationWithCallsThreshold >= 0 &&
ToInstrument.size() > (unsigned)ClInstrumentationWithCallsThreshold);
const TargetLibraryInfo *TLI =
&getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
const DataLayout &DL = F.getParent()->getDataLayout();
ObjectSizeOffsetVisitor ObjSizeVis(DL, TLI, F.getContext(),
/*RoundToAlign=*/true);
// Instrument.
int NumInstrumented = 0;
for (auto Inst : ToInstrument) {
if (ClDebugMin < 0 || ClDebugMax < 0 ||
(NumInstrumented >= ClDebugMin && NumInstrumented <= ClDebugMax)) {
if (isInterestingMemoryAccess(Inst, &IsWrite, &TypeSize, &Alignment))
instrumentMop(ObjSizeVis, Inst, UseCalls,
F.getParent()->getDataLayout());
else
instrumentMemIntrinsic(cast<MemIntrinsic>(Inst));
}
NumInstrumented++;
}
FunctionStackPoisoner FSP(F, *this);
bool ChangedStack = FSP.runOnFunction();
// We must unpoison the stack before every NoReturn call (throw, _exit, etc).
// See e.g. http://code.google.com/p/address-sanitizer/issues/detail?id=37
for (auto CI : NoReturnCalls) {
IRBuilder<> IRB(CI);
IRB.CreateCall(AsanHandleNoReturnFunc, {});
}
for (auto Inst : PointerComparisonsOrSubtracts) {
instrumentPointerComparisonOrSubtraction(Inst);
NumInstrumented++;
}
bool res = NumInstrumented > 0 || ChangedStack || !NoReturnCalls.empty();
DEBUG(dbgs() << "ASAN done instrumenting: " << res << " " << F << "\n");
return res;
}
// Workaround for bug 11395: we don't want to instrument stack in functions
// with large assembly blobs (32-bit only), otherwise reg alloc may crash.
// FIXME: remove once the bug 11395 is fixed.
bool AddressSanitizer::LooksLikeCodeInBug11395(Instruction *I) {
if (LongSize != 32) return false;
CallInst *CI = dyn_cast<CallInst>(I);
if (!CI || !CI->isInlineAsm()) return false;
if (CI->getNumArgOperands() <= 5) return false;
// We have inline assembly with quite a few arguments.
return true;
}
void FunctionStackPoisoner::initializeCallbacks(Module &M) {
IRBuilder<> IRB(*C);
for (int i = 0; i <= kMaxAsanStackMallocSizeClass; i++) {
std::string Suffix = itostr(i);
AsanStackMallocFunc[i] = checkSanitizerInterfaceFunction(
M.getOrInsertFunction(kAsanStackMallocNameTemplate + Suffix, IntptrTy,
IntptrTy, nullptr));
AsanStackFreeFunc[i] = checkSanitizerInterfaceFunction(
M.getOrInsertFunction(kAsanStackFreeNameTemplate + Suffix,
IRB.getVoidTy(), IntptrTy, IntptrTy, nullptr));
}
AsanPoisonStackMemoryFunc = checkSanitizerInterfaceFunction(
M.getOrInsertFunction(kAsanPoisonStackMemoryName, IRB.getVoidTy(),
IntptrTy, IntptrTy, nullptr));
AsanUnpoisonStackMemoryFunc = checkSanitizerInterfaceFunction(
M.getOrInsertFunction(kAsanUnpoisonStackMemoryName, IRB.getVoidTy(),
IntptrTy, IntptrTy, nullptr));
AsanAllocaPoisonFunc = checkSanitizerInterfaceFunction(M.getOrInsertFunction(
kAsanAllocaPoison, IRB.getVoidTy(), IntptrTy, IntptrTy, nullptr));
AsanAllocasUnpoisonFunc =
checkSanitizerInterfaceFunction(M.getOrInsertFunction(
kAsanAllocasUnpoison, IRB.getVoidTy(), IntptrTy, IntptrTy, nullptr));
}
void FunctionStackPoisoner::poisonRedZones(ArrayRef<uint8_t> ShadowBytes,
IRBuilder<> &IRB, Value *ShadowBase,
bool DoPoison) {
size_t n = ShadowBytes.size();
size_t i = 0;
// We need to (un)poison n bytes of stack shadow. Poison as many as we can
// using 64-bit stores (if we are on 64-bit arch), then poison the rest
// with 32-bit stores, then with 16-byte stores, then with 8-byte stores.
for (size_t LargeStoreSizeInBytes = ASan.LongSize / 8;
LargeStoreSizeInBytes != 0; LargeStoreSizeInBytes /= 2) {
for (; i + LargeStoreSizeInBytes - 1 < n; i += LargeStoreSizeInBytes) {
uint64_t Val = 0;
for (size_t j = 0; j < LargeStoreSizeInBytes; j++) {
if (F.getParent()->getDataLayout().isLittleEndian())
Val |= (uint64_t)ShadowBytes[i + j] << (8 * j);
else
Val = (Val << 8) | ShadowBytes[i + j];
}
if (!Val) continue;
Value *Ptr = IRB.CreateAdd(ShadowBase, ConstantInt::get(IntptrTy, i));
Type *StoreTy = Type::getIntNTy(*C, LargeStoreSizeInBytes * 8);
Value *Poison = ConstantInt::get(StoreTy, DoPoison ? Val : 0);
IRB.CreateStore(Poison, IRB.CreateIntToPtr(Ptr, StoreTy->getPointerTo()));
}
}
}
// Fake stack allocator (asan_fake_stack.h) has 11 size classes
// for every power of 2 from kMinStackMallocSize to kMaxAsanStackMallocSizeClass
static int StackMallocSizeClass(uint64_t LocalStackSize) {
assert(LocalStackSize <= kMaxStackMallocSize);
uint64_t MaxSize = kMinStackMallocSize;
for (int i = 0;; i++, MaxSize *= 2)
if (LocalStackSize <= MaxSize) return i;
llvm_unreachable("impossible LocalStackSize");
}
// Set Size bytes starting from ShadowBase to kAsanStackAfterReturnMagic.
// We can not use MemSet intrinsic because it may end up calling the actual
// memset. Size is a multiple of 8.
// Currently this generates 8-byte stores on x86_64; it may be better to
// generate wider stores.
void FunctionStackPoisoner::SetShadowToStackAfterReturnInlined(
IRBuilder<> &IRB, Value *ShadowBase, int Size) {
assert(!(Size % 8));
// kAsanStackAfterReturnMagic is 0xf5.
const uint64_t kAsanStackAfterReturnMagic64 = 0xf5f5f5f5f5f5f5f5ULL;
for (int i = 0; i < Size; i += 8) {
Value *p = IRB.CreateAdd(ShadowBase, ConstantInt::get(IntptrTy, i));
IRB.CreateStore(
ConstantInt::get(IRB.getInt64Ty(), kAsanStackAfterReturnMagic64),
IRB.CreateIntToPtr(p, IRB.getInt64Ty()->getPointerTo()));
}
}
PHINode *FunctionStackPoisoner::createPHI(IRBuilder<> &IRB, Value *Cond,
Value *ValueIfTrue,
Instruction *ThenTerm,
Value *ValueIfFalse) {
PHINode *PHI = IRB.CreatePHI(IntptrTy, 2);
BasicBlock *CondBlock = cast<Instruction>(Cond)->getParent();
PHI->addIncoming(ValueIfFalse, CondBlock);
BasicBlock *ThenBlock = ThenTerm->getParent();
PHI->addIncoming(ValueIfTrue, ThenBlock);
return PHI;
}
Value *FunctionStackPoisoner::createAllocaForLayout(
IRBuilder<> &IRB, const ASanStackFrameLayout &L, bool Dynamic) {
AllocaInst *Alloca;
if (Dynamic) {
Alloca = IRB.CreateAlloca(IRB.getInt8Ty(),
ConstantInt::get(IRB.getInt64Ty(), L.FrameSize),
"MyAlloca");
} else {
Alloca = IRB.CreateAlloca(ArrayType::get(IRB.getInt8Ty(), L.FrameSize),
nullptr, "MyAlloca");
assert(Alloca->isStaticAlloca());
}
assert((ClRealignStack & (ClRealignStack - 1)) == 0);
size_t FrameAlignment = std::max(L.FrameAlignment, (size_t)ClRealignStack);
Alloca->setAlignment(FrameAlignment);
return IRB.CreatePointerCast(Alloca, IntptrTy);
}
void FunctionStackPoisoner::createDynamicAllocasInitStorage() {
BasicBlock &FirstBB = *F.begin();
IRBuilder<> IRB(dyn_cast<Instruction>(FirstBB.begin()));
DynamicAllocaLayout = IRB.CreateAlloca(IntptrTy, nullptr);
IRB.CreateStore(Constant::getNullValue(IntptrTy), DynamicAllocaLayout);
DynamicAllocaLayout->setAlignment(32);
}
void FunctionStackPoisoner::poisonStack() {
assert(AllocaVec.size() > 0 || DynamicAllocaVec.size() > 0);
// Insert poison calls for lifetime intrinsics for alloca.
bool HavePoisonedAllocas = false;
for (const auto &APC : AllocaPoisonCallVec) {
assert(APC.InsBefore);
assert(APC.AI);
IRBuilder<> IRB(APC.InsBefore);
poisonAlloca(APC.AI, APC.Size, IRB, APC.DoPoison);
HavePoisonedAllocas |= APC.DoPoison;
}
if (ClInstrumentAllocas && DynamicAllocaVec.size() > 0) {
// Handle dynamic allocas.
createDynamicAllocasInitStorage();
for (auto &AI : DynamicAllocaVec) handleDynamicAllocaCall(AI);
unpoisonDynamicAllocas();
}
if (AllocaVec.empty()) return;
int StackMallocIdx = -1;
DebugLoc EntryDebugLocation;
if (auto SP = F.getSubprogram())
EntryDebugLocation = DebugLoc::get(SP->getScopeLine(), 0, SP);
Instruction *InsBefore = AllocaVec[0];
IRBuilder<> IRB(InsBefore);
IRB.SetCurrentDebugLocation(EntryDebugLocation);
// Make sure non-instrumented allocas stay in the entry block. Otherwise,
// debug info is broken, because only entry-block allocas are treated as
// regular stack slots.
auto InsBeforeB = InsBefore->getParent();
assert(InsBeforeB == &F.getEntryBlock());
for (BasicBlock::iterator I(InsBefore); I != InsBeforeB->end(); ++I)
if (auto *AI = dyn_cast<AllocaInst>(I))
if (NonInstrumentedStaticAllocaVec.count(AI) > 0)
AI->moveBefore(InsBefore);
// If we have a call to llvm.localescape, keep it in the entry block.
if (LocalEscapeCall) LocalEscapeCall->moveBefore(InsBefore);
SmallVector<ASanStackVariableDescription, 16> SVD;
SVD.reserve(AllocaVec.size());
for (AllocaInst *AI : AllocaVec) {
ASanStackVariableDescription D = {AI->getName().data(),
ASan.getAllocaSizeInBytes(AI),
AI->getAlignment(), AI, 0};
SVD.push_back(D);
}
// Minimal header size (left redzone) is 4 pointers,
// i.e. 32 bytes on 64-bit platforms and 16 bytes in 32-bit platforms.
size_t MinHeaderSize = ASan.LongSize / 2;
ASanStackFrameLayout L;
ComputeASanStackFrameLayout(SVD, 1ULL << Mapping.Scale, MinHeaderSize, &L);
DEBUG(dbgs() << L.DescriptionString << " --- " << L.FrameSize << "\n");
uint64_t LocalStackSize = L.FrameSize;
bool DoStackMalloc = ClUseAfterReturn && !ASan.CompileKernel &&
LocalStackSize <= kMaxStackMallocSize;
bool DoDynamicAlloca = ClDynamicAllocaStack;
// Don't do dynamic alloca or stack malloc if:
// 1) There is inline asm: too often it makes assumptions on which registers
// are available.
// 2) There is a returns_twice call (typically setjmp), which is
// optimization-hostile, and doesn't play well with introduced indirect
// register-relative calculation of local variable addresses.
DoDynamicAlloca &= !HasNonEmptyInlineAsm && !HasReturnsTwiceCall;
DoStackMalloc &= !HasNonEmptyInlineAsm && !HasReturnsTwiceCall;
Value *StaticAlloca =
DoDynamicAlloca ? nullptr : createAllocaForLayout(IRB, L, false);
Value *FakeStack;
Value *LocalStackBase;
if (DoStackMalloc) {
// void *FakeStack = __asan_option_detect_stack_use_after_return
// ? __asan_stack_malloc_N(LocalStackSize)
// : nullptr;
// void *LocalStackBase = (FakeStack) ? FakeStack : alloca(LocalStackSize);
Constant *OptionDetectUAR = F.getParent()->getOrInsertGlobal(
kAsanOptionDetectUAR, IRB.getInt32Ty());
Value *UARIsEnabled =
IRB.CreateICmpNE(IRB.CreateLoad(OptionDetectUAR),
Constant::getNullValue(IRB.getInt32Ty()));
Instruction *Term =
SplitBlockAndInsertIfThen(UARIsEnabled, InsBefore, false);
IRBuilder<> IRBIf(Term);
IRBIf.SetCurrentDebugLocation(EntryDebugLocation);
StackMallocIdx = StackMallocSizeClass(LocalStackSize);
assert(StackMallocIdx <= kMaxAsanStackMallocSizeClass);
Value *FakeStackValue =
IRBIf.CreateCall(AsanStackMallocFunc[StackMallocIdx],
ConstantInt::get(IntptrTy, LocalStackSize));
IRB.SetInsertPoint(InsBefore);
IRB.SetCurrentDebugLocation(EntryDebugLocation);
FakeStack = createPHI(IRB, UARIsEnabled, FakeStackValue, Term,
ConstantInt::get(IntptrTy, 0));
Value *NoFakeStack =
IRB.CreateICmpEQ(FakeStack, Constant::getNullValue(IntptrTy));
Term = SplitBlockAndInsertIfThen(NoFakeStack, InsBefore, false);
IRBIf.SetInsertPoint(Term);
IRBIf.SetCurrentDebugLocation(EntryDebugLocation);
Value *AllocaValue =
DoDynamicAlloca ? createAllocaForLayout(IRBIf, L, true) : StaticAlloca;
IRB.SetInsertPoint(InsBefore);
IRB.SetCurrentDebugLocation(EntryDebugLocation);
LocalStackBase = createPHI(IRB, NoFakeStack, AllocaValue, Term, FakeStack);
} else {
// void *FakeStack = nullptr;
// void *LocalStackBase = alloca(LocalStackSize);
FakeStack = ConstantInt::get(IntptrTy, 0);
LocalStackBase =
DoDynamicAlloca ? createAllocaForLayout(IRB, L, true) : StaticAlloca;
}
// Replace Alloca instructions with base+offset.
for (const auto &Desc : SVD) {
AllocaInst *AI = Desc.AI;
Value *NewAllocaPtr = IRB.CreateIntToPtr(
IRB.CreateAdd(LocalStackBase, ConstantInt::get(IntptrTy, Desc.Offset)),
AI->getType());
replaceDbgDeclareForAlloca(AI, NewAllocaPtr, DIB, /*Deref=*/true);
AI->replaceAllUsesWith(NewAllocaPtr);
}
// The left-most redzone has enough space for at least 4 pointers.
// Write the Magic value to redzone[0].
Value *BasePlus0 = IRB.CreateIntToPtr(LocalStackBase, IntptrPtrTy);
IRB.CreateStore(ConstantInt::get(IntptrTy, kCurrentStackFrameMagic),
BasePlus0);
// Write the frame description constant to redzone[1].
Value *BasePlus1 = IRB.CreateIntToPtr(
IRB.CreateAdd(LocalStackBase,
ConstantInt::get(IntptrTy, ASan.LongSize / 8)),
IntptrPtrTy);
GlobalVariable *StackDescriptionGlobal =
createPrivateGlobalForString(*F.getParent(), L.DescriptionString,
/*AllowMerging*/ true);
Value *Description = IRB.CreatePointerCast(StackDescriptionGlobal, IntptrTy);
IRB.CreateStore(Description, BasePlus1);
// Write the PC to redzone[2].
Value *BasePlus2 = IRB.CreateIntToPtr(
IRB.CreateAdd(LocalStackBase,
ConstantInt::get(IntptrTy, 2 * ASan.LongSize / 8)),
IntptrPtrTy);
IRB.CreateStore(IRB.CreatePointerCast(&F, IntptrTy), BasePlus2);
// Poison the stack redzones at the entry.
Value *ShadowBase = ASan.memToShadow(LocalStackBase, IRB);
poisonRedZones(L.ShadowBytes, IRB, ShadowBase, true);
// (Un)poison the stack before all ret instructions.
for (auto Ret : RetVec) {
IRBuilder<> IRBRet(Ret);
// Mark the current frame as retired.
IRBRet.CreateStore(ConstantInt::get(IntptrTy, kRetiredStackFrameMagic),
BasePlus0);
if (DoStackMalloc) {
assert(StackMallocIdx >= 0);
// if FakeStack != 0 // LocalStackBase == FakeStack
// // In use-after-return mode, poison the whole stack frame.
// if StackMallocIdx <= 4
// // For small sizes inline the whole thing:
// memset(ShadowBase, kAsanStackAfterReturnMagic, ShadowSize);
// **SavedFlagPtr(FakeStack) = 0
// else
// __asan_stack_free_N(FakeStack, LocalStackSize)
// else
// <This is not a fake stack; unpoison the redzones>
Value *Cmp =
IRBRet.CreateICmpNE(FakeStack, Constant::getNullValue(IntptrTy));
TerminatorInst *ThenTerm, *ElseTerm;
SplitBlockAndInsertIfThenElse(Cmp, Ret, &ThenTerm, &ElseTerm);
IRBuilder<> IRBPoison(ThenTerm);
if (StackMallocIdx <= 4) {
int ClassSize = kMinStackMallocSize << StackMallocIdx;
SetShadowToStackAfterReturnInlined(IRBPoison, ShadowBase,
ClassSize >> Mapping.Scale);
Value *SavedFlagPtrPtr = IRBPoison.CreateAdd(
FakeStack,
ConstantInt::get(IntptrTy, ClassSize - ASan.LongSize / 8));
Value *SavedFlagPtr = IRBPoison.CreateLoad(
IRBPoison.CreateIntToPtr(SavedFlagPtrPtr, IntptrPtrTy));
IRBPoison.CreateStore(
Constant::getNullValue(IRBPoison.getInt8Ty()),
IRBPoison.CreateIntToPtr(SavedFlagPtr, IRBPoison.getInt8PtrTy()));
} else {
// For larger frames call __asan_stack_free_*.
IRBPoison.CreateCall(
AsanStackFreeFunc[StackMallocIdx],
{FakeStack, ConstantInt::get(IntptrTy, LocalStackSize)});
}
IRBuilder<> IRBElse(ElseTerm);
poisonRedZones(L.ShadowBytes, IRBElse, ShadowBase, false);
} else if (HavePoisonedAllocas) {
// If we poisoned some allocas in llvm.lifetime analysis,
// unpoison whole stack frame now.
poisonAlloca(LocalStackBase, LocalStackSize, IRBRet, false);
} else {
poisonRedZones(L.ShadowBytes, IRBRet, ShadowBase, false);
}
}
// We are done. Remove the old unused alloca instructions.
for (auto AI : AllocaVec) AI->eraseFromParent();
}
void FunctionStackPoisoner::poisonAlloca(Value *V, uint64_t Size,
IRBuilder<> &IRB, bool DoPoison) {
// For now just insert the call to ASan runtime.
Value *AddrArg = IRB.CreatePointerCast(V, IntptrTy);
Value *SizeArg = ConstantInt::get(IntptrTy, Size);
IRB.CreateCall(
DoPoison ? AsanPoisonStackMemoryFunc : AsanUnpoisonStackMemoryFunc,
{AddrArg, SizeArg});
}
// Handling llvm.lifetime intrinsics for a given %alloca:
// (1) collect all llvm.lifetime.xxx(%size, %value) describing the alloca.
// (2) if %size is constant, poison memory for llvm.lifetime.end (to detect
// invalid accesses) and unpoison it for llvm.lifetime.start (the memory
// could be poisoned by previous llvm.lifetime.end instruction, as the
// variable may go in and out of scope several times, e.g. in loops).
// (3) if we poisoned at least one %alloca in a function,
// unpoison the whole stack frame at function exit.
AllocaInst *FunctionStackPoisoner::findAllocaForValue(Value *V) {
if (AllocaInst *AI = dyn_cast<AllocaInst>(V))
// We're intested only in allocas we can handle.
return ASan.isInterestingAlloca(*AI) ? AI : nullptr;
// See if we've already calculated (or started to calculate) alloca for a
// given value.
AllocaForValueMapTy::iterator I = AllocaForValue.find(V);
if (I != AllocaForValue.end()) return I->second;
// Store 0 while we're calculating alloca for value V to avoid
// infinite recursion if the value references itself.
AllocaForValue[V] = nullptr;
AllocaInst *Res = nullptr;
if (CastInst *CI = dyn_cast<CastInst>(V))
Res = findAllocaForValue(CI->getOperand(0));
else if (PHINode *PN = dyn_cast<PHINode>(V)) {
for (Value *IncValue : PN->incoming_values()) {
// Allow self-referencing phi-nodes.
if (IncValue == PN) continue;
AllocaInst *IncValueAI = findAllocaForValue(IncValue);
// AI for incoming values should exist and should all be equal.
if (IncValueAI == nullptr || (Res != nullptr && IncValueAI != Res))
return nullptr;
Res = IncValueAI;
}
}
if (Res) AllocaForValue[V] = Res;
return Res;
}
void FunctionStackPoisoner::handleDynamicAllocaCall(AllocaInst *AI) {
IRBuilder<> IRB(AI);
const unsigned Align = std::max(kAllocaRzSize, AI->getAlignment());
const uint64_t AllocaRedzoneMask = kAllocaRzSize - 1;
Value *Zero = Constant::getNullValue(IntptrTy);
Value *AllocaRzSize = ConstantInt::get(IntptrTy, kAllocaRzSize);
Value *AllocaRzMask = ConstantInt::get(IntptrTy, AllocaRedzoneMask);
// Since we need to extend alloca with additional memory to locate
// redzones, and OldSize is number of allocated blocks with
// ElementSize size, get allocated memory size in bytes by
// OldSize * ElementSize.
const unsigned ElementSize =
F.getParent()->getDataLayout().getTypeAllocSize(AI->getAllocatedType());
Value *OldSize =
IRB.CreateMul(IRB.CreateIntCast(AI->getArraySize(), IntptrTy, false),
ConstantInt::get(IntptrTy, ElementSize));
// PartialSize = OldSize % 32
Value *PartialSize = IRB.CreateAnd(OldSize, AllocaRzMask);
// Misalign = kAllocaRzSize - PartialSize;
Value *Misalign = IRB.CreateSub(AllocaRzSize, PartialSize);
// PartialPadding = Misalign != kAllocaRzSize ? Misalign : 0;
Value *Cond = IRB.CreateICmpNE(Misalign, AllocaRzSize);
Value *PartialPadding = IRB.CreateSelect(Cond, Misalign, Zero);
// AdditionalChunkSize = Align + PartialPadding + kAllocaRzSize
// Align is added to locate left redzone, PartialPadding for possible
// partial redzone and kAllocaRzSize for right redzone respectively.
Value *AdditionalChunkSize = IRB.CreateAdd(
ConstantInt::get(IntptrTy, Align + kAllocaRzSize), PartialPadding);
Value *NewSize = IRB.CreateAdd(OldSize, AdditionalChunkSize);
// Insert new alloca with new NewSize and Align params.
AllocaInst *NewAlloca = IRB.CreateAlloca(IRB.getInt8Ty(), NewSize);
NewAlloca->setAlignment(Align);
// NewAddress = Address + Align
Value *NewAddress = IRB.CreateAdd(IRB.CreatePtrToInt(NewAlloca, IntptrTy),
ConstantInt::get(IntptrTy, Align));
// Insert __asan_alloca_poison call for new created alloca.
IRB.CreateCall(AsanAllocaPoisonFunc, {NewAddress, OldSize});
// Store the last alloca's address to DynamicAllocaLayout. We'll need this
// for unpoisoning stuff.
IRB.CreateStore(IRB.CreatePtrToInt(NewAlloca, IntptrTy), DynamicAllocaLayout);
Value *NewAddressPtr = IRB.CreateIntToPtr(NewAddress, AI->getType());
// Replace all uses of AddessReturnedByAlloca with NewAddressPtr.
AI->replaceAllUsesWith(NewAddressPtr);
// We are done. Erase old alloca from parent.
AI->eraseFromParent();
}
// isSafeAccess returns true if Addr is always inbounds with respect to its
// base object. For example, it is a field access or an array access with
// constant inbounds index.
bool AddressSanitizer::isSafeAccess(ObjectSizeOffsetVisitor &ObjSizeVis,
Value *Addr, uint64_t TypeSize) const {
SizeOffsetType SizeOffset = ObjSizeVis.compute(Addr);
if (!ObjSizeVis.bothKnown(SizeOffset)) return false;
uint64_t Size = SizeOffset.first.getZExtValue();
int64_t Offset = SizeOffset.second.getSExtValue();
// Three checks are required to ensure safety:
// . Offset >= 0 (since the offset is given from the base ptr)
// . Size >= Offset (unsigned)
// . Size - Offset >= NeededSize (unsigned)
return Offset >= 0 && Size >= uint64_t(Offset) &&
Size - uint64_t(Offset) >= TypeSize / 8;
}
| [
"[email protected]"
] | |
07181445c10a396d58c0561f846a56c7affed79b | 45bebb1cf4e951d673755e5700a9e30b27b1c3ae | /Testing/Interaction/mafGUITransformTextEntriesTest.cpp | 43723e5a57d306c93fa9683077563b5901b49ae8 | [] | no_license | besoft/MAF2 | 1a26bfbb4bedb036741941a43b135162448bbf33 | b576955f4f6b954467021f12baedfebcaf79a382 | refs/heads/master | 2020-04-13T13:58:44.609511 | 2019-07-31T13:56:54 | 2019-07-31T13:56:54 | 31,658,947 | 1 | 3 | null | 2015-03-04T13:41:48 | 2015-03-04T13:41:48 | null | UTF-8 | C++ | false | false | 4,305 | cpp | /*=========================================================================
Program: MAF2
Module: mafGUITransformTextEntriesTest
Authors: Stefano Perticoni
Copyright (c) B3C
All rights reserved. See Copyright.txt or
http://www.scsitaly.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "mafDefines.h"
//----------------------------------------------------------------------------
// NOTE: Every CPP file in the MAF must include "mafDefines.h" as first.
// This force to include Window,wxWidgets and VTK exactly in this order.
// Failing in doing this will result in a run-time error saying:
// "Failure#0: The value of ESP was not properly saved across a function call"
//----------------------------------------------------------------------------
#include <cppunit/config/SourcePrefix.h>
#include "mafGUITransformTextEntriesTest.h"
#include "mafVMESurface.h"
#include "mafDecl.h"
#include "mafGUITransformTextEntries.h"
#include "vtkSphereSource.h"
#include <iostream>
void DummyObserver::OnEvent(mafEventBase *maf_event)
{
m_LastReceivedEventID = maf_event->GetId();
}
int DummyObserver::GetLastReceivedEventID()
{
return m_LastReceivedEventID;
}
//----------------------------------------------------------------------------
void mafGUITransformTextEntriesTest::TestFixture()
//----------------------------------------------------------------------------
{
}
//----------------------------------------------------------------------------
void mafGUITransformTextEntriesTest::setUp()
//----------------------------------------------------------------------------
{
m_VMESphere = mafVMESurface::New();
m_VMESphere->SetName("m_VMESphere");
m_VTKSphere = vtkSphereSource::New();
m_VMESphere->SetData(m_VTKSphere->GetOutput(), -1);
}
//----------------------------------------------------------------------------
void mafGUITransformTextEntriesTest::tearDown()
//----------------------------------------------------------------------------
{
mafDEL(m_VMESphere);
vtkDEL(m_VTKSphere);
}
//----------------------------------------------------------------------------
void mafGUITransformTextEntriesTest::TestConstructorDestructor()
//----------------------------------------------------------------------------
{
mafGUITransformTextEntries *guiTransformTextEntries = new mafGUITransformTextEntries(m_VMESphere, NULL, true, true);
cppDEL(guiTransformTextEntries);
}
//----------------------------------------------------------------------------
void mafGUITransformTextEntriesTest::TestSetAbsPose()
//----------------------------------------------------------------------------
{
mafGUITransformTextEntries *guiTransformTextEntries = new mafGUITransformTextEntries(m_VMESphere, NULL, true, true);
mafMatrix absPose;
absPose.SetElement(0,3, 0);
absPose.SetElement(1,3, 10);
absPose.SetElement(2,3, 20);
guiTransformTextEntries->SetAbsPose(&absPose);
CPPUNIT_ASSERT_EQUAL(guiTransformTextEntries->m_Position[0], 0.0);
CPPUNIT_ASSERT_EQUAL(guiTransformTextEntries->m_Position[1], 10.0);
CPPUNIT_ASSERT_EQUAL(guiTransformTextEntries->m_Position[2], 20.0);
cppDEL(guiTransformTextEntries);
}
//----------------------------------------------------------------------------
void mafGUITransformTextEntriesTest::TestOnEvent()
//----------------------------------------------------------------------------
{
DummyObserver *dummyObserver = new DummyObserver();
mafGUITransformTextEntries *guiTransformTextEntries = new mafGUITransformTextEntries(m_VMESphere, dummyObserver, true, true);
// in response to an ID_TRANSLATE_X event from GUI...(*)
mafEvent eventSent(this, mafGUITransformTextEntries::ID_TRANSLATE_X);
guiTransformTextEntries->OnEvent(&eventSent);
int dummyReceivedEventID = dummyObserver->GetLastReceivedEventID();
// (*)... the observer is notified with a ID_TRANSFORM event
// containing the already set VME ABS matrix
CPPUNIT_ASSERT(dummyReceivedEventID == ID_TRANSFORM);
cppDEL(guiTransformTextEntries);
cppDEL(dummyObserver);
}
| [
"[email protected]"
] | |
d07efe70fbd8f36160e7cffcb05e0f5f27d2a502 | 94146da4b034fe6df42a5c5783d0e2cde39d96ef | /592-Logic-Island.cpp | 2ac5d700a45ab77c1f11e1a9928b956d334fe005 | [] | no_license | gitqwerty777/Online-Judge-Code | f9fac8227b1b522d15a318a60a82d287fdc04755 | 5d7e62a1ff62d5f079b5db6b21e9a1acdfc6f15b | refs/heads/master | 2022-05-14T16:17:44.452807 | 2017-12-23T04:16:19 | 2017-12-23T04:16:19 | 16,976,298 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,311 | cpp | #include <cstdio>
#include <cstring>
#include <map>
#include <string>
#include <vector>
using namespace std;
const int maxstatement = 50;
//name, his statement, day, type(-> lie),
char possiblestr[][3][15] = {{"divine", "human", "evil"}, {"day", "night"}, {"is lie", "is not lie"}};
enum STATE{UNKNOWN=-1, COMFIRMED=1, BUSTED=0};
enum TYPE{UNKNOWNTYPE=-1, DIVINE=0, HUMAN=1, EVIL=2};
enum LIE{UNKNOWNLIE=-1, ISLIE=0, NOTLIE=1};
enum DAY{UNKNOWNDAY=-1, ISDAY=0, NIGHT=1};
struct State{//statement of a person stated by a person
bool isTrue;
STATE isLie;
STATE isType[3];
STATE isDay[2];
State(){
init();
}
void init(){
isLie = UNKNOWN;
isType[0] = isType[1] = isType[2] = UNKNOWN;
isDay[0] = isDay[1] = UNKNOWN;
}
void setType(int index, bool b){
if(b){
for(int i = 0; i < 3; i++)
if(i == index)
isType[i] = COMFIRMED;
else
isType[i] = BUSTED;
} else {
isType[index] = BUSTED;
}
}
void setLie(bool b){
if(b)
isLie = COMFIRMED;
else
isLie = BUSTED;
}
void print(){
for(int i = 0; i < 3; i++)
if(isType[i] == COMFIRMED)
printf("%s is true\n", possiblestr[0][i]);
else if(isType[i] == BUSTED)
printf("%s is false\n", possiblestr[0][i]);
//
if(isLie == COMFIRMED)
printf("%s is true\n", possiblestr[2][0]);
else if(isLie == BUSTED)
printf("%s is false\n", possiblestr[2][1]);
}
bool fill(State s){
for(int i = 0; i < 3; i++)
if(s.isType[i] == COMFIRMED && isType[i] == BUSTED || s.isType[i] == BUSTED && isType[i] == COMFIRMED)
return false;
else if(s.isType[i] != UNKNOWN)
isType[i] = s.isType[i];
if(s.isLie == COMFIRMED && isLie == BUSTED || s.isLie == BUSTED && isLie == COMFIRMED)
return false;
else if(s.isLie != UNKNOWN)
isLie = s.isLie;
return true;
}
bool checkTrue(int day){
if(isType[EVIL] == COMFIRMED || (isType[DIVINE] == BUSTED && day == NIGHT) || isLie == COMFIRMED || isType[HUMAN] == COMFIRMED && day == NIGHT)
return false;
return true;
}
bool checkFalse(int day){
if(isType[DIVINE] == COMFIRMED || (isType[HUMAN] == COMFIRMED && day == ISDAY) || isLie == BUSTED || isType[EVIL] == BUSTED && day == ISDAY)
return false;
return true;
}
void reverse(){
if(isLie == COMFIRMED)
isLie = BUSTED;
else if(isLie == BUSTED)
isLie = COMFIRMED;
//COMFIRMED -> BUSTED, BUSTED -> UNKNOWN, UNKNOWN -> COMFIRMED;
//if true statement -> cbbbbbb, false -> uuuubuu
// reversed -> buuuuuu, false -> bbbbcbb
if(isComfirmedType()){
for(int i = 0; i < 3; i++){
if(isType[i] == COMFIRMED)
isType[i] = BUSTED;
else
isType[i] = UNKNOWN;
}
} else {
for(int i = 0; i < 3; i++){
if(isType[i] == BUSTED)
isType[i] = COMFIRMED;
else
isType[i] = BUSTED;
}
}
}
bool isComfirmedType(){
for(int i = 0; i < 3; i++)
if(isType[i] == COMFIRMED)
return true;
return false;
}
};
struct MyState{//statement of all people and day which stated by a person
int day;//SHOULD put in State
struct State state[5];
MyState(){
day = UNKNOWNDAY;
}
void init(){
day = UNKNOWNDAY;
for(int i = 0; i < 5; i++)
state[i].init();
}
void setType(int subject, int type, bool istrue){
printf("set type %d -> %d, (%s)\n", subject, type, istrue?"true":"false");
state[subject].setType(type, istrue);
}
void setLie(int subject, bool istrue){
state[subject].setLie(istrue);
}
void setDay(int type, bool istrue){
if(istrue){
if(type == ISDAY)
day = ISDAY;
else
day = NIGHT;
} else{
if(type == ISDAY)
day = NIGHT;
else
day = ISDAY;
}
}
void print(){
if(day != UNKNOWN)
printf("day = %d\n", day);
for(int i = 0; i < 5; i++){
printf("person %c:\n", 'A'+i);
state[i].print();
}
}
bool fill(MyState s){
if(day != UNKNOWN && s.day != UNKNOWN && day != s.day){
return false;
}
for(int i = 0; i < 5; i++)
if(!state[i].fill(s.state[i]))
return false;
}
bool checkPossible(bool isTrue[]){
bool isPossible = true;
for(int i = 0; i < 5 && isPossible; i++){
if(isTrue[i])
isPossible = isPossible && state[i].checkTrue(day);
else
isPossible = isPossible && state[i].checkFalse(day);
}
return isPossible;
}
MyState reverse(){
MyState newState = *this;
if(newState.day != UNKNOWN){
if(newState.day == ISDAY)
newState.day = NIGHT;
else
newState.day = ISDAY ;
}
for(int i = 0; i < 5; i++)
newState.state[i].reverse();
}
void ComfirmedInit(){
day = ISDAY;
for(int i = 0; i < 5; i++)
state[i].init();
}
void fillComfirmed(MyState& s){//TODO:
if(s.day == UNKNOWN)
return;
}
};
struct TotalState{
TotalState(){
pnum = 0;
nowTableIndex = 0;
}
bool isTrue[5];
int nowTableIndex;
int pnum;
MyState personalState[5];//for A, B, C, D, E
void init();
bool inference();
void parse(char s[]);
bool fillTruthTable(int pnum);
};
void TotalState::init(){
}
void TotalState::parse(char s[]){
/*
X: I am [not] ( divine | human | evil | lying ).
X: X is [not] ( divine | human | evil | lying ).
X: It is ( day | night ).
*/
char *p = strtok(s, ":"); puts(p);
int claimer = p[0] - 'A';
p = strtok(NULL, " "); puts(p);
int subject;
if(p[0] != 'I')
subject = p[0] - 'A';
else {
if(p[1] != 't')//I
subject = claimer;
else//It
subject = 0;//no need to set
}
bool isTrue = true;
p = strtok(NULL, ". ");
MyState mystate = personalState[claimer];
while(p != NULL){
puts(p);
if(strcmp(p, "not") == 0)
isTrue = false;
else if(strcmp(p, "divine") == 0)
mystate.setType(subject, DIVINE, isTrue);
else if(strcmp(p, "human") == 0)
mystate.setType(subject, HUMAN, isTrue);
else if(strcmp(p, "evil") == 0)
mystate.setType(subject, EVIL, isTrue);
else if(strcmp(p, "lying") == 0)
mystate.setLie(subject, isTrue);
else if(strcmp(p, "day") == 0)
mystate.setDay(ISDAY, isTrue);
else if(strcmp(p, "night") == 0)
mystate.setDay(NIGHT, isTrue);
p = strtok(NULL, ". ");
}
mystate.print();
}
bool TotalState::fillTruthTable(int pnum){
int num = nowTableIndex;
for(int i = 0; i < pnum; i++){
isTrue[i] = (num%2 == 0);
num /= 2;
}
nowTableIndex++;
}
bool TotalState::inference(){// if only one possible type/lie/day, print it
int pnum = 5;
nowTableIndex = 0;
MyState comfirmedState;
MyState testState;
while(fillTruthTable(pnum)){
bool isPossible = true;
testState.init();
for(int i = 0; i < pnum && isPossible; i++){
if(isTrue[i]){
isPossible = isPossible && testState.fill(personalState[i]);
} else {
isPossible = isPossible && testState.fill(personalState[i].reverse());//he is liar
}
}
if(isPossible && testState.checkPossible(isTrue)){
comfirmedState.fillComfirmed(testState);
}
}
}
bool TotalState::checkPossible(){
return true;
}
int N;
char s[100];
TotalState state;
int main(){
while(scanf("%d\n", &N) == 1 && N){
state.init();
for(int i = 0; i < N; i++){
gets(s);
state.parse(s);
}
state.inference();
}
}
| [
"[email protected]"
] | |
a245bb44b94335c8ff2d43cde432b591c0ef1c3e | 1bb7b76e49f47f65caccc504b58c45e49fbc5975 | /Castlevania/MeleeWeapon.h | d8eace7a6e3be6b5fb49a88e33f90f6a2e4ee857 | [] | no_license | mrtanloveoflife/Castlevania | b0e64091ced12cf4632f256edeedfb2e08650ad0 | b3eb5c7e0d4154bce2b511add45735c420e4a324 | refs/heads/master | 2020-04-15T00:04:59.630498 | 2019-01-05T15:41:56 | 2019-01-05T15:41:56 | 164,095,564 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,360 | h | #pragma once
#include "Textures.h"
#include "Candle.h"
#include "Simon.h"
#include "Item.h"
#include "Zombie.h"
#include "Bat.h"
#include "Panther.h"
#include "Effect.h"
#include "Sound.h"
#define MELEE_WEAPON_TYPE_0_BBOX_WIDTH 23
#define MELEE_WEAPON_TYPE_0_BBOX_HEIGHT 8
#define MELEE_WEAPON_TYPE_1_BBOX_WIDTH 23
#define MELEE_WEAPON_TYPE_1_BBOX_HEIGHT 6
#define MELEE_WEAPON_TYPE_2_BBOX_WIDTH 44
#define MELEE_WEAPON_TYPE_2_BBOX_HEIGHT 6
#define SOUND_HIT "Sounds\\sound\\hit.wav"
class MeleeWeapon : public CGameObject
{
static MeleeWeapon * __instance;
CTextures * textures;
int ID_TEX;
int type;
DWORD attackingTime;
DWORD startAttackTime;
Sound *hitSound;
public:
static MeleeWeapon * GetInstance();
static MeleeWeapon * GetInstance(int ID_TEX_MELEE_WEAPONS, LPCWSTR MELEE_WEAPONS_TEXTURE_PATH, D3DCOLOR MELEE_WEAPONS_TEXTURE_BACKGROUND_COLOR);
MeleeWeapon(int ID_TEX_MELEE_WEAPONS, LPCWSTR MELEE_WEAPONS_TEXTURE_PATH, D3DCOLOR MELEE_WEAPONS_TEXTURE_BACKGROUND_COLOR);
void LoadWeaponTextures();
void LoadWeapon();
void Upgrade();
int GetType() { return type; }
void ResetStartAttackingTime() { startAttackTime = GetTickCount(); }
virtual void Render();
virtual void Update(DWORD dt, vector<vector<LPGAMEOBJECT>> *colliable_objects = NULL);
virtual void GetBoundingBox(float &left, float &top, float &right, float &bottom);
}; | [
"mrtanloveoflife"
] | mrtanloveoflife |
758db7e00724c927f88c30f20807dcd9863d0cd1 | 1d422ee4c2ca924b89e0a6053825057a61e62a97 | /Libraries/MyImgui/src/Utils.h | 7dfb96353ad77e3274f7bc939a4fe19b1b787b99 | [] | no_license | KawBuma/Buma3DSamples2 | 10696deebc586ae69956d95a2c61f2d432f4dd40 | cf7cabb75e196544e478db8af2df04cb652a12fd | refs/heads/main | 2023-06-26T11:54:08.063792 | 2021-08-02T01:52:48 | 2021-08-02T01:52:48 | 380,735,955 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,995 | h | #pragma once
#include <Buma3D/Util/Buma3DPtr.h>
#include <Buma3DHelpers/B3DDescHelpers.h>
#include <Buma3DHelpers/FormatUtils.h>
#include <DeviceResources/DeviceResources.h>
#include <utility>
#include <cassert>
#define BMR_RET_IF_FAILED(x) if (x >= buma3d::BMRESULT_FAILED) { assert(false && #x); return false; }
#define RET_IF_FAILED(x) if (!(x)) { assert(false && #x); return false; }
namespace buma
{
class DeviceResources;
class CommandQueue;
class Texture;
namespace gui
{
struct RENDER_RESOURCE
{
struct tex_deleter {
constexpr tex_deleter() noexcept = default;
tex_deleter(DeviceResources* _dr) noexcept : dr{ _dr } {}
tex_deleter(const tex_deleter& _d) noexcept { dr = _d.dr; }
void operator()(Texture * _tex) const noexcept { dr->DestroyTexture(_tex); }
DeviceResources* dr = nullptr;
};
using MYIMGUI_CREATE_FLAGS = uint32_t;
MYIMGUI_CREATE_FLAGS flags;
DeviceResources* dr;
buma3d::util::Ptr<buma3d::IDevice> device;
CommandQueue* queue;
util::PipelineBarrierDesc barriers;
buma3d::util::Ptr<buma3d::ISamplerView> sampler;
std::unique_ptr<Texture, tex_deleter> font_texture;
buma3d::util::Ptr<buma3d::IShaderResourceView> font_srv;
buma3d::util::Ptr<buma3d::IShaderModule> vs;
buma3d::util::Ptr<buma3d::IShaderModule> ps;
buma3d::util::Ptr<buma3d::IDescriptorSetLayout> sampler_layout;
buma3d::util::Ptr<buma3d::IDescriptorSetLayout> texture_layout;
buma3d::util::Ptr<buma3d::IPipelineLayout> pipeline_layout;
buma3d::util::Ptr<buma3d::IPipelineState> pipeline_state_load;
buma3d::util::Ptr<buma3d::IRenderPass> render_pass_load;
buma3d::util::Ptr<buma3d::IRenderPass> render_pass_clear;
};
inline void GetSurfaceInfo(
size_t _width
, size_t _height
, buma3d::RESOURCE_FORMAT _fmt
, size_t* _out_num_bytes
, size_t* _out_row_bytes
, size_t* _out_num_rows)
{
size_t num_bytes = 0;
size_t row_bytes = 0;
size_t num_rows = 0;
bool is_bc = false;
bool is_packed = false;
bool is_planar = false;
size_t bpe = 0;
switch (_fmt)
{
case buma3d::RESOURCE_FORMAT_BC1_TYPELESS:
case buma3d::RESOURCE_FORMAT_BC1_UNORM:
case buma3d::RESOURCE_FORMAT_BC1_UNORM_SRGB:
case buma3d::RESOURCE_FORMAT_BC4_TYPELESS:
case buma3d::RESOURCE_FORMAT_BC4_UNORM:
case buma3d::RESOURCE_FORMAT_BC4_SNORM:
is_bc = true;
bpe = 8;
break;
case buma3d::RESOURCE_FORMAT_BC2_TYPELESS:
case buma3d::RESOURCE_FORMAT_BC2_UNORM:
case buma3d::RESOURCE_FORMAT_BC2_UNORM_SRGB:
case buma3d::RESOURCE_FORMAT_BC3_TYPELESS:
case buma3d::RESOURCE_FORMAT_BC3_UNORM:
case buma3d::RESOURCE_FORMAT_BC3_UNORM_SRGB:
case buma3d::RESOURCE_FORMAT_BC5_TYPELESS:
case buma3d::RESOURCE_FORMAT_BC5_UNORM:
case buma3d::RESOURCE_FORMAT_BC5_SNORM:
case buma3d::RESOURCE_FORMAT_BC6H_TYPELESS:
case buma3d::RESOURCE_FORMAT_BC6H_UF16:
case buma3d::RESOURCE_FORMAT_BC6H_SF16:
case buma3d::RESOURCE_FORMAT_BC7_TYPELESS:
case buma3d::RESOURCE_FORMAT_BC7_UNORM:
case buma3d::RESOURCE_FORMAT_BC7_UNORM_SRGB:
is_bc = true;
bpe = 16;
break;
default:
break;
}
if (is_bc)
{
size_t num_blocks_wide = 0;
if (_width > 0)
{
num_blocks_wide = std::max<size_t>(1, (_width + 3) / 4);
}
size_t num_blocks_high = 0;
if (_height > 0)
{
num_blocks_high = std::max<size_t>(1, (_height + 3) / 4);
}
row_bytes = num_blocks_wide * bpe;
num_rows = num_blocks_high;
num_bytes = row_bytes * num_blocks_high;
}
else if (is_packed)
{
row_bytes = ((_width + 1) >> 1) * bpe;
num_rows = _height;
num_bytes = row_bytes * _height;
}
else if (is_planar)
{
row_bytes = ((_width + 1) >> 1) * bpe;
num_bytes = (row_bytes * _height) + ((row_bytes * _height + 1) >> 1);
num_rows = _height + ((_height + 1) >> 1);
}
else
{
auto size = util::GetFormatSize(_fmt);
size_t bpp = (size / util::CalcTexelsPerBlock(_fmt)) * 8;
row_bytes = (_width * bpp + 7) / 8; // round up to nearest byte
num_rows = _height;
num_bytes = row_bytes * _height;
}
if (_out_num_bytes)
*_out_num_bytes = num_bytes;
if (_out_row_bytes)
*_out_row_bytes = row_bytes;
if (_out_num_rows)
*_out_num_rows = num_rows;
}
}// namespace gui
}// namespace buma
| [
"[email protected]"
] | |
e59c1e30c75cee87bd1d074e5575aa71f34aec20 | e7ab2404056f7dff5dc0483448ab846905eb0ad5 | /verf_service/src/middleserver.cpp | 31df5a271b548ce7efaae24fd68094753ee115d9 | [] | no_license | Omen1312/Node-Verificator | a7541f3cff427c0dcb74adaa18491ecaa8d9105d | d890f9b548fb0a93faa0ab0864c3b6993c11e7ac | refs/heads/master | 2021-01-04T03:04:07.472153 | 2020-01-22T06:56:05 | 2020-01-22T06:56:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,420 | cpp | #include "middleserver.h"
#include <meta_log.hpp>
#include <open_ssl_decor.h>
#include <statics.hpp>
#include <utility>
MIDDLE_SERVER::MIDDLE_SERVER(int _port, std::function<std::string(const std::string&, const std::string&)> func)
: processor(std::move(func))
{
set_port(_port);
set_threads(std::thread::hardware_concurrency());
}
MIDDLE_SERVER::~MIDDLE_SERVER() = default;
bool MIDDLE_SERVER::run(int /*thread_number*/, mh::mhd::MHD::Request& mhd_req, mh::mhd::MHD::Response& mhd_resp)
{
std::string resp = processor(mhd_req.post, mhd_req.url);
if (resp.empty()) {
mhd_resp.data = "ok";
} else {
mhd_resp.data = std::move(resp);
}
return true;
}
bool MIDDLE_SERVER::init()
{
return true;
}
bool KeyManager::parse(const std::string& line)
{
std::vector<unsigned char> priv_k = hex2bin(line);
PrivKey.insert(PrivKey.end(), priv_k.begin(), priv_k.end());
if (!generate_public_key(PubKey, PrivKey)) {
return false;
}
Text_PubKey = "0x" + bin2hex(PubKey);
std::array<char, 25> addres = get_address(PubKey);
Bin_addr.insert(Bin_addr.end(), addres.begin(), addres.end());
Text_addres = "0x" + bin2hex(Bin_addr);
return true;
}
std::string KeyManager::make_req_url(std::string& data)
{
std::vector<char> sign;
sign_data(data, sign, PrivKey);
return "/?pubk=" + Text_PubKey + "&sign=" + bin2hex(sign);
} | [
"[email protected]"
] | |
9ce735dc2240cac1fea5c01171b93f09fe2081f1 | a67c8f4fc7f8b5a807263eefbf4d24e41f938ec9 | /2_sem/lab1_2sem/mainwindow.h | 46f6ba8c303efb87cb61e686ab45d5155d9afe9b | [] | no_license | DanilaShmakov/181-351_Shmakov | f0f2a9cdf5dedcaf445f5db28afd41edd6f89f28 | c64e833a2d31c624fb50e2d7425c56d93bea0bae | refs/heads/master | 2021-07-13T21:26:31.676918 | 2021-06-23T20:16:36 | 2021-06-23T20:16:36 | 148,887,617 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 426 | h | #ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow();
private slots:
void on_pushButton_Authorize_clicked();
void on_pushButton_SignUP_clicked();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
| [
"[email protected]"
] | |
4773cd808294650e3c2e92f5435338233ac4d84b | 1093782b8a6a8630de8d7366954275e4e0384f64 | /playercard.h | 77e053f06b55ae78d2e8f010c13eb1e783441262 | [] | no_license | twantonie/ERC69Accounting | da1a6025d5567c09b920fada1d4db9090706bf30 | a39a1116f811ea5ad3e11fc6ad1c03575f376790 | refs/heads/master | 2021-06-25T17:45:33.189457 | 2017-09-11T21:54:23 | 2017-09-11T21:54:23 | 103,190,219 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 923 | h | #ifndef PLAYERCARD_H
#define PLAYERCARD_H
#include <QVector>
class PlayerCard
{
public:
enum Cards {Senior, Recreant, Colt, Junior, Cub, Mini, Benjamin, Turf, Ten, Nothing};
PlayerCard() {}
PlayerCard(QString firstName, QString lastName, Cards card) : mFirstName(firstName), mLastName(lastName), mCard(card) {}
QString getFirstName(){return mFirstName;}
QString getLastName(){return mLastName;}
Cards getCard(){return mCard;}
static QVector<PlayerCard*> importPlayerCardsFromExcel(QString fileName);
static const char * getCardString(int enumVal){return CardStrings[enumVal];}
QString getAmount();
QString getDutchDescription();
QString getEnglishDescription();
QString getDutchMessage(bool sepa);
QString getEnglishMessage(bool sepa);
private:
static const char * CardStrings[];
QString mFirstName;
QString mLastName;
Cards mCard;
};
#endif // PLAYERCARD_H
| [
"[email protected]"
] | |
3dae21c20b4419b1a6b63ea8426821152771b31d | c776476e9d06b3779d744641e758ac3a2c15cddc | /examples/litmus/c/run-scripts/tmp_1/R+dmb.stlp+dmb.sylp.c.cbmc_out.cpp | bcdb16b9812a096502868437285a7bfcc9ac5ae4 | [] | no_license | ashutosh0gupta/llvm_bmc | aaac7961c723ba6f7ffd77a39559e0e52432eade | 0287c4fb180244e6b3c599a9902507f05c8a7234 | refs/heads/master | 2023-08-02T17:14:06.178723 | 2023-07-31T10:46:53 | 2023-07-31T10:46:53 | 143,100,825 | 3 | 4 | null | 2023-05-25T05:50:55 | 2018-08-01T03:47:00 | C++ | UTF-8 | C++ | false | false | 26,605 | cpp | // 0:vars:2
// 2:atom_1_X2_0:1
// 3:thr0:1
// 4:thr1:1
#define ADDRSIZE 5
#define NPROC 3
#define NCONTEXT 1
#define ASSUME(stmt) __CPROVER_assume(stmt)
#define ASSERT(stmt) __CPROVER_assert(stmt, "error")
#define max(a,b) (a>b?a:b)
char __get_rng();
char get_rng( char from, char to ) {
char ret = __get_rng();
ASSUME(ret >= from && ret <= to);
return ret;
}
char get_rng_th( char from, char to ) {
char ret = __get_rng();
ASSUME(ret >= from && ret <= to);
return ret;
}
int main(int argc, char **argv) {
// declare arrays for intial value version in contexts
int meminit_[ADDRSIZE*NCONTEXT];
#define meminit(x,k) meminit_[(x)*NCONTEXT+k]
int coinit_[ADDRSIZE*NCONTEXT];
#define coinit(x,k) coinit_[(x)*NCONTEXT+k]
int deltainit_[ADDRSIZE*NCONTEXT];
#define deltainit(x,k) deltainit_[(x)*NCONTEXT+k]
// declare arrays for running value version in contexts
int mem_[ADDRSIZE*NCONTEXT];
#define mem(x,k) mem_[(x)*NCONTEXT+k]
int co_[ADDRSIZE*NCONTEXT];
#define co(x,k) co_[(x)*NCONTEXT+k]
int delta_[ADDRSIZE*NCONTEXT];
#define delta(x,k) delta_[(x)*NCONTEXT+k]
// declare arrays for local buffer and observed writes
int buff_[NPROC*ADDRSIZE];
#define buff(x,k) buff_[(x)*ADDRSIZE+k]
int pw_[NPROC*ADDRSIZE];
#define pw(x,k) pw_[(x)*ADDRSIZE+k]
// declare arrays for context stamps
char cr_[NPROC*ADDRSIZE];
#define cr(x,k) cr_[(x)*ADDRSIZE+k]
char iw_[NPROC*ADDRSIZE];
#define iw(x,k) iw_[(x)*ADDRSIZE+k]
char cw_[NPROC*ADDRSIZE];
#define cw(x,k) cw_[(x)*ADDRSIZE+k]
char cx_[NPROC*ADDRSIZE];
#define cx(x,k) cx_[(x)*ADDRSIZE+k]
char is_[NPROC*ADDRSIZE];
#define is(x,k) is_[(x)*ADDRSIZE+k]
char cs_[NPROC*ADDRSIZE];
#define cs(x,k) cs_[(x)*ADDRSIZE+k]
char crmax_[NPROC*ADDRSIZE];
#define crmax(x,k) crmax_[(x)*ADDRSIZE+k]
char sforbid_[ADDRSIZE*NCONTEXT];
#define sforbid(x,k) sforbid_[(x)*NCONTEXT+k]
// declare arrays for synchronizations
int cl[NPROC];
int cdy[NPROC];
int cds[NPROC];
int cdl[NPROC];
int cisb[NPROC];
int caddr[NPROC];
int cctrl[NPROC];
int cstart[NPROC];
int creturn[NPROC];
// declare arrays for contexts activity
int active[NCONTEXT];
int ctx_used[NCONTEXT];
int r0= 0;
char creg_r0;
int r1= 0;
char creg_r1;
int r2= 0;
char creg_r2;
int r3= 0;
char creg_r3;
int r4= 0;
char creg_r4;
int r5= 0;
char creg_r5;
int r6= 0;
char creg_r6;
int r7= 0;
char creg_r7;
char old_cctrl= 0;
char old_cr= 0;
char old_cdy= 0;
char old_cw= 0;
char new_creg= 0;
buff(0,0) = 0;
pw(0,0) = 0;
cr(0,0) = 0;
iw(0,0) = 0;
cw(0,0) = 0;
cx(0,0) = 0;
is(0,0) = 0;
cs(0,0) = 0;
crmax(0,0) = 0;
buff(0,1) = 0;
pw(0,1) = 0;
cr(0,1) = 0;
iw(0,1) = 0;
cw(0,1) = 0;
cx(0,1) = 0;
is(0,1) = 0;
cs(0,1) = 0;
crmax(0,1) = 0;
buff(0,2) = 0;
pw(0,2) = 0;
cr(0,2) = 0;
iw(0,2) = 0;
cw(0,2) = 0;
cx(0,2) = 0;
is(0,2) = 0;
cs(0,2) = 0;
crmax(0,2) = 0;
buff(0,3) = 0;
pw(0,3) = 0;
cr(0,3) = 0;
iw(0,3) = 0;
cw(0,3) = 0;
cx(0,3) = 0;
is(0,3) = 0;
cs(0,3) = 0;
crmax(0,3) = 0;
buff(0,4) = 0;
pw(0,4) = 0;
cr(0,4) = 0;
iw(0,4) = 0;
cw(0,4) = 0;
cx(0,4) = 0;
is(0,4) = 0;
cs(0,4) = 0;
crmax(0,4) = 0;
cl[0] = 0;
cdy[0] = 0;
cds[0] = 0;
cdl[0] = 0;
cisb[0] = 0;
caddr[0] = 0;
cctrl[0] = 0;
cstart[0] = get_rng(0,NCONTEXT-1);
creturn[0] = get_rng(0,NCONTEXT-1);
buff(1,0) = 0;
pw(1,0) = 0;
cr(1,0) = 0;
iw(1,0) = 0;
cw(1,0) = 0;
cx(1,0) = 0;
is(1,0) = 0;
cs(1,0) = 0;
crmax(1,0) = 0;
buff(1,1) = 0;
pw(1,1) = 0;
cr(1,1) = 0;
iw(1,1) = 0;
cw(1,1) = 0;
cx(1,1) = 0;
is(1,1) = 0;
cs(1,1) = 0;
crmax(1,1) = 0;
buff(1,2) = 0;
pw(1,2) = 0;
cr(1,2) = 0;
iw(1,2) = 0;
cw(1,2) = 0;
cx(1,2) = 0;
is(1,2) = 0;
cs(1,2) = 0;
crmax(1,2) = 0;
buff(1,3) = 0;
pw(1,3) = 0;
cr(1,3) = 0;
iw(1,3) = 0;
cw(1,3) = 0;
cx(1,3) = 0;
is(1,3) = 0;
cs(1,3) = 0;
crmax(1,3) = 0;
buff(1,4) = 0;
pw(1,4) = 0;
cr(1,4) = 0;
iw(1,4) = 0;
cw(1,4) = 0;
cx(1,4) = 0;
is(1,4) = 0;
cs(1,4) = 0;
crmax(1,4) = 0;
cl[1] = 0;
cdy[1] = 0;
cds[1] = 0;
cdl[1] = 0;
cisb[1] = 0;
caddr[1] = 0;
cctrl[1] = 0;
cstart[1] = get_rng(0,NCONTEXT-1);
creturn[1] = get_rng(0,NCONTEXT-1);
buff(2,0) = 0;
pw(2,0) = 0;
cr(2,0) = 0;
iw(2,0) = 0;
cw(2,0) = 0;
cx(2,0) = 0;
is(2,0) = 0;
cs(2,0) = 0;
crmax(2,0) = 0;
buff(2,1) = 0;
pw(2,1) = 0;
cr(2,1) = 0;
iw(2,1) = 0;
cw(2,1) = 0;
cx(2,1) = 0;
is(2,1) = 0;
cs(2,1) = 0;
crmax(2,1) = 0;
buff(2,2) = 0;
pw(2,2) = 0;
cr(2,2) = 0;
iw(2,2) = 0;
cw(2,2) = 0;
cx(2,2) = 0;
is(2,2) = 0;
cs(2,2) = 0;
crmax(2,2) = 0;
buff(2,3) = 0;
pw(2,3) = 0;
cr(2,3) = 0;
iw(2,3) = 0;
cw(2,3) = 0;
cx(2,3) = 0;
is(2,3) = 0;
cs(2,3) = 0;
crmax(2,3) = 0;
buff(2,4) = 0;
pw(2,4) = 0;
cr(2,4) = 0;
iw(2,4) = 0;
cw(2,4) = 0;
cx(2,4) = 0;
is(2,4) = 0;
cs(2,4) = 0;
crmax(2,4) = 0;
cl[2] = 0;
cdy[2] = 0;
cds[2] = 0;
cdl[2] = 0;
cisb[2] = 0;
caddr[2] = 0;
cctrl[2] = 0;
cstart[2] = get_rng(0,NCONTEXT-1);
creturn[2] = get_rng(0,NCONTEXT-1);
// Dumping initializations
mem(0+0,0) = 0;
mem(0+1,0) = 0;
mem(2+0,0) = 0;
mem(3+0,0) = 0;
mem(4+0,0) = 0;
// Dumping context matching equalities
co(0,0) = 0;
delta(0,0) = -1;
co(1,0) = 0;
delta(1,0) = -1;
co(2,0) = 0;
delta(2,0) = -1;
co(3,0) = 0;
delta(3,0) = -1;
co(4,0) = 0;
delta(4,0) = -1;
// Dumping thread 1
int ret_thread_1 = 0;
cdy[1] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[1] >= cstart[1]);
T1BLOCK0:
// call void @llvm.dbg.value(metadata i8* %arg, metadata !33, metadata !DIExpression()), !dbg !42
// br label %label_1, !dbg !43
goto T1BLOCK1;
T1BLOCK1:
// call void @llvm.dbg.label(metadata !41), !dbg !44
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0), metadata !34, metadata !DIExpression()), !dbg !45
// call void @llvm.dbg.value(metadata i64 1, metadata !37, metadata !DIExpression()), !dbg !45
// store atomic i64 1, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0) release, align 8, !dbg !46
// ST: Guess
// : Release
iw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW
old_cw = cw(1,0);
cw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM
// Check
ASSUME(active[iw(1,0)] == 1);
ASSUME(active[cw(1,0)] == 1);
ASSUME(sforbid(0,cw(1,0))== 0);
ASSUME(iw(1,0) >= 0);
ASSUME(iw(1,0) >= 0);
ASSUME(cw(1,0) >= iw(1,0));
ASSUME(cw(1,0) >= old_cw);
ASSUME(cw(1,0) >= cr(1,0));
ASSUME(cw(1,0) >= cl[1]);
ASSUME(cw(1,0) >= cisb[1]);
ASSUME(cw(1,0) >= cdy[1]);
ASSUME(cw(1,0) >= cdl[1]);
ASSUME(cw(1,0) >= cds[1]);
ASSUME(cw(1,0) >= cctrl[1]);
ASSUME(cw(1,0) >= caddr[1]);
ASSUME(cw(1,0) >= cr(1,0+0));
ASSUME(cw(1,0) >= cr(1,0+1));
ASSUME(cw(1,0) >= cr(1,2+0));
ASSUME(cw(1,0) >= cr(1,3+0));
ASSUME(cw(1,0) >= cr(1,4+0));
ASSUME(cw(1,0) >= cw(1,0+0));
ASSUME(cw(1,0) >= cw(1,0+1));
ASSUME(cw(1,0) >= cw(1,2+0));
ASSUME(cw(1,0) >= cw(1,3+0));
ASSUME(cw(1,0) >= cw(1,4+0));
// Update
caddr[1] = max(caddr[1],0);
buff(1,0) = 1;
mem(0,cw(1,0)) = 1;
co(0,cw(1,0))+=1;
delta(0,cw(1,0)) = -1;
is(1,0) = iw(1,0);
cs(1,0) = cw(1,0);
ASSUME(creturn[1] >= cw(1,0));
// call void (...) @dmbst(), !dbg !47
// dumbst: Guess
cds[1] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cds[1] >= cdy[1]);
ASSUME(cds[1] >= cw(1,0+0));
ASSUME(cds[1] >= cw(1,0+1));
ASSUME(cds[1] >= cw(1,2+0));
ASSUME(cds[1] >= cw(1,3+0));
ASSUME(cds[1] >= cw(1,4+0));
ASSUME(creturn[1] >= cds[1]);
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1), metadata !38, metadata !DIExpression()), !dbg !48
// call void @llvm.dbg.value(metadata i64 1, metadata !40, metadata !DIExpression()), !dbg !48
// store atomic i64 1, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !49
// ST: Guess
iw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW
old_cw = cw(1,0+1*1);
cw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM
// Check
ASSUME(active[iw(1,0+1*1)] == 1);
ASSUME(active[cw(1,0+1*1)] == 1);
ASSUME(sforbid(0+1*1,cw(1,0+1*1))== 0);
ASSUME(iw(1,0+1*1) >= 0);
ASSUME(iw(1,0+1*1) >= 0);
ASSUME(cw(1,0+1*1) >= iw(1,0+1*1));
ASSUME(cw(1,0+1*1) >= old_cw);
ASSUME(cw(1,0+1*1) >= cr(1,0+1*1));
ASSUME(cw(1,0+1*1) >= cl[1]);
ASSUME(cw(1,0+1*1) >= cisb[1]);
ASSUME(cw(1,0+1*1) >= cdy[1]);
ASSUME(cw(1,0+1*1) >= cdl[1]);
ASSUME(cw(1,0+1*1) >= cds[1]);
ASSUME(cw(1,0+1*1) >= cctrl[1]);
ASSUME(cw(1,0+1*1) >= caddr[1]);
// Update
caddr[1] = max(caddr[1],0);
buff(1,0+1*1) = 1;
mem(0+1*1,cw(1,0+1*1)) = 1;
co(0+1*1,cw(1,0+1*1))+=1;
delta(0+1*1,cw(1,0+1*1)) = -1;
ASSUME(creturn[1] >= cw(1,0+1*1));
// ret i8* null, !dbg !50
ret_thread_1 = (- 1);
// Dumping thread 2
int ret_thread_2 = 0;
cdy[2] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[2] >= cstart[2]);
T2BLOCK0:
// call void @llvm.dbg.value(metadata i8* %arg, metadata !53, metadata !DIExpression()), !dbg !67
// br label %label_2, !dbg !49
goto T2BLOCK1;
T2BLOCK1:
// call void @llvm.dbg.label(metadata !66), !dbg !69
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1), metadata !54, metadata !DIExpression()), !dbg !70
// call void @llvm.dbg.value(metadata i64 2, metadata !56, metadata !DIExpression()), !dbg !70
// store atomic i64 2, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1) release, align 8, !dbg !52
// ST: Guess
// : Release
iw(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW
old_cw = cw(2,0+1*1);
cw(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM
// Check
ASSUME(active[iw(2,0+1*1)] == 2);
ASSUME(active[cw(2,0+1*1)] == 2);
ASSUME(sforbid(0+1*1,cw(2,0+1*1))== 0);
ASSUME(iw(2,0+1*1) >= 0);
ASSUME(iw(2,0+1*1) >= 0);
ASSUME(cw(2,0+1*1) >= iw(2,0+1*1));
ASSUME(cw(2,0+1*1) >= old_cw);
ASSUME(cw(2,0+1*1) >= cr(2,0+1*1));
ASSUME(cw(2,0+1*1) >= cl[2]);
ASSUME(cw(2,0+1*1) >= cisb[2]);
ASSUME(cw(2,0+1*1) >= cdy[2]);
ASSUME(cw(2,0+1*1) >= cdl[2]);
ASSUME(cw(2,0+1*1) >= cds[2]);
ASSUME(cw(2,0+1*1) >= cctrl[2]);
ASSUME(cw(2,0+1*1) >= caddr[2]);
ASSUME(cw(2,0+1*1) >= cr(2,0+0));
ASSUME(cw(2,0+1*1) >= cr(2,0+1));
ASSUME(cw(2,0+1*1) >= cr(2,2+0));
ASSUME(cw(2,0+1*1) >= cr(2,3+0));
ASSUME(cw(2,0+1*1) >= cr(2,4+0));
ASSUME(cw(2,0+1*1) >= cw(2,0+0));
ASSUME(cw(2,0+1*1) >= cw(2,0+1));
ASSUME(cw(2,0+1*1) >= cw(2,2+0));
ASSUME(cw(2,0+1*1) >= cw(2,3+0));
ASSUME(cw(2,0+1*1) >= cw(2,4+0));
// Update
caddr[2] = max(caddr[2],0);
buff(2,0+1*1) = 2;
mem(0+1*1,cw(2,0+1*1)) = 2;
co(0+1*1,cw(2,0+1*1))+=1;
delta(0+1*1,cw(2,0+1*1)) = -1;
is(2,0+1*1) = iw(2,0+1*1);
cs(2,0+1*1) = cw(2,0+1*1);
ASSUME(creturn[2] >= cw(2,0+1*1));
// call void (...) @dmbsy(), !dbg !53
// dumbsy: Guess
old_cdy = cdy[2];
cdy[2] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[2] >= old_cdy);
ASSUME(cdy[2] >= cisb[2]);
ASSUME(cdy[2] >= cdl[2]);
ASSUME(cdy[2] >= cds[2]);
ASSUME(cdy[2] >= cctrl[2]);
ASSUME(cdy[2] >= cw(2,0+0));
ASSUME(cdy[2] >= cw(2,0+1));
ASSUME(cdy[2] >= cw(2,2+0));
ASSUME(cdy[2] >= cw(2,3+0));
ASSUME(cdy[2] >= cw(2,4+0));
ASSUME(cdy[2] >= cr(2,0+0));
ASSUME(cdy[2] >= cr(2,0+1));
ASSUME(cdy[2] >= cr(2,2+0));
ASSUME(cdy[2] >= cr(2,3+0));
ASSUME(cdy[2] >= cr(2,4+0));
ASSUME(creturn[2] >= cdy[2]);
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0), metadata !59, metadata !DIExpression()), !dbg !73
// %0 = load atomic i64, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !55
// LD: Guess
old_cr = cr(2,0);
cr(2,0) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM
// Check
ASSUME(active[cr(2,0)] == 2);
ASSUME(cr(2,0) >= iw(2,0));
ASSUME(cr(2,0) >= 0);
ASSUME(cr(2,0) >= cdy[2]);
ASSUME(cr(2,0) >= cisb[2]);
ASSUME(cr(2,0) >= cdl[2]);
ASSUME(cr(2,0) >= cl[2]);
// Update
creg_r0 = cr(2,0);
crmax(2,0) = max(crmax(2,0),cr(2,0));
caddr[2] = max(caddr[2],0);
if(cr(2,0) < cw(2,0)) {
r0 = buff(2,0);
} else {
if(pw(2,0) != co(0,cr(2,0))) {
ASSUME(cr(2,0) >= old_cr);
}
pw(2,0) = co(0,cr(2,0));
r0 = mem(0,cr(2,0));
}
ASSUME(creturn[2] >= cr(2,0));
// call void @llvm.dbg.value(metadata i64 %0, metadata !61, metadata !DIExpression()), !dbg !73
// %conv = trunc i64 %0 to i32, !dbg !56
// call void @llvm.dbg.value(metadata i32 %conv, metadata !57, metadata !DIExpression()), !dbg !67
// %cmp = icmp eq i32 %conv, 0, !dbg !57
// %conv1 = zext i1 %cmp to i32, !dbg !57
// call void @llvm.dbg.value(metadata i32 %conv1, metadata !62, metadata !DIExpression()), !dbg !67
// call void @llvm.dbg.value(metadata i64* @atom_1_X2_0, metadata !63, metadata !DIExpression()), !dbg !77
// %1 = zext i32 %conv1 to i64
// call void @llvm.dbg.value(metadata i64 %1, metadata !65, metadata !DIExpression()), !dbg !77
// store atomic i64 %1, i64* @atom_1_X2_0 seq_cst, align 8, !dbg !59
// ST: Guess
iw(2,2) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW
old_cw = cw(2,2);
cw(2,2) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM
// Check
ASSUME(active[iw(2,2)] == 2);
ASSUME(active[cw(2,2)] == 2);
ASSUME(sforbid(2,cw(2,2))== 0);
ASSUME(iw(2,2) >= max(creg_r0,0));
ASSUME(iw(2,2) >= 0);
ASSUME(cw(2,2) >= iw(2,2));
ASSUME(cw(2,2) >= old_cw);
ASSUME(cw(2,2) >= cr(2,2));
ASSUME(cw(2,2) >= cl[2]);
ASSUME(cw(2,2) >= cisb[2]);
ASSUME(cw(2,2) >= cdy[2]);
ASSUME(cw(2,2) >= cdl[2]);
ASSUME(cw(2,2) >= cds[2]);
ASSUME(cw(2,2) >= cctrl[2]);
ASSUME(cw(2,2) >= caddr[2]);
// Update
caddr[2] = max(caddr[2],0);
buff(2,2) = (r0==0);
mem(2,cw(2,2)) = (r0==0);
co(2,cw(2,2))+=1;
delta(2,cw(2,2)) = -1;
ASSUME(creturn[2] >= cw(2,2));
// ret i8* null, !dbg !60
ret_thread_2 = (- 1);
// Dumping thread 0
int ret_thread_0 = 0;
cdy[0] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[0] >= cstart[0]);
T0BLOCK0:
// %thr0 = alloca i64, align 8
// %thr1 = alloca i64, align 8
// call void @llvm.dbg.value(metadata i32 %argc, metadata !87, metadata !DIExpression()), !dbg !113
// call void @llvm.dbg.value(metadata i8** %argv, metadata !88, metadata !DIExpression()), !dbg !113
// %0 = bitcast i64* %thr0 to i8*, !dbg !65
// call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #6, !dbg !65
// call void @llvm.dbg.declare(metadata i64* %thr0, metadata !89, metadata !DIExpression()), !dbg !115
// %1 = bitcast i64* %thr1 to i8*, !dbg !67
// call void @llvm.lifetime.start.p0i8(i64 8, i8* %1) #6, !dbg !67
// call void @llvm.dbg.declare(metadata i64* %thr1, metadata !93, metadata !DIExpression()), !dbg !117
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1), metadata !94, metadata !DIExpression()), !dbg !118
// call void @llvm.dbg.value(metadata i64 0, metadata !96, metadata !DIExpression()), !dbg !118
// store atomic i64 0, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !70
// ST: Guess
iw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW
old_cw = cw(0,0+1*1);
cw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM
// Check
ASSUME(active[iw(0,0+1*1)] == 0);
ASSUME(active[cw(0,0+1*1)] == 0);
ASSUME(sforbid(0+1*1,cw(0,0+1*1))== 0);
ASSUME(iw(0,0+1*1) >= 0);
ASSUME(iw(0,0+1*1) >= 0);
ASSUME(cw(0,0+1*1) >= iw(0,0+1*1));
ASSUME(cw(0,0+1*1) >= old_cw);
ASSUME(cw(0,0+1*1) >= cr(0,0+1*1));
ASSUME(cw(0,0+1*1) >= cl[0]);
ASSUME(cw(0,0+1*1) >= cisb[0]);
ASSUME(cw(0,0+1*1) >= cdy[0]);
ASSUME(cw(0,0+1*1) >= cdl[0]);
ASSUME(cw(0,0+1*1) >= cds[0]);
ASSUME(cw(0,0+1*1) >= cctrl[0]);
ASSUME(cw(0,0+1*1) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0+1*1) = 0;
mem(0+1*1,cw(0,0+1*1)) = 0;
co(0+1*1,cw(0,0+1*1))+=1;
delta(0+1*1,cw(0,0+1*1)) = -1;
ASSUME(creturn[0] >= cw(0,0+1*1));
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0), metadata !97, metadata !DIExpression()), !dbg !120
// call void @llvm.dbg.value(metadata i64 0, metadata !99, metadata !DIExpression()), !dbg !120
// store atomic i64 0, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !72
// ST: Guess
iw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW
old_cw = cw(0,0);
cw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM
// Check
ASSUME(active[iw(0,0)] == 0);
ASSUME(active[cw(0,0)] == 0);
ASSUME(sforbid(0,cw(0,0))== 0);
ASSUME(iw(0,0) >= 0);
ASSUME(iw(0,0) >= 0);
ASSUME(cw(0,0) >= iw(0,0));
ASSUME(cw(0,0) >= old_cw);
ASSUME(cw(0,0) >= cr(0,0));
ASSUME(cw(0,0) >= cl[0]);
ASSUME(cw(0,0) >= cisb[0]);
ASSUME(cw(0,0) >= cdy[0]);
ASSUME(cw(0,0) >= cdl[0]);
ASSUME(cw(0,0) >= cds[0]);
ASSUME(cw(0,0) >= cctrl[0]);
ASSUME(cw(0,0) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0) = 0;
mem(0,cw(0,0)) = 0;
co(0,cw(0,0))+=1;
delta(0,cw(0,0)) = -1;
ASSUME(creturn[0] >= cw(0,0));
// call void @llvm.dbg.value(metadata i64* @atom_1_X2_0, metadata !100, metadata !DIExpression()), !dbg !122
// call void @llvm.dbg.value(metadata i64 0, metadata !102, metadata !DIExpression()), !dbg !122
// store atomic i64 0, i64* @atom_1_X2_0 monotonic, align 8, !dbg !74
// ST: Guess
iw(0,2) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW
old_cw = cw(0,2);
cw(0,2) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM
// Check
ASSUME(active[iw(0,2)] == 0);
ASSUME(active[cw(0,2)] == 0);
ASSUME(sforbid(2,cw(0,2))== 0);
ASSUME(iw(0,2) >= 0);
ASSUME(iw(0,2) >= 0);
ASSUME(cw(0,2) >= iw(0,2));
ASSUME(cw(0,2) >= old_cw);
ASSUME(cw(0,2) >= cr(0,2));
ASSUME(cw(0,2) >= cl[0]);
ASSUME(cw(0,2) >= cisb[0]);
ASSUME(cw(0,2) >= cdy[0]);
ASSUME(cw(0,2) >= cdl[0]);
ASSUME(cw(0,2) >= cds[0]);
ASSUME(cw(0,2) >= cctrl[0]);
ASSUME(cw(0,2) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,2) = 0;
mem(2,cw(0,2)) = 0;
co(2,cw(0,2))+=1;
delta(2,cw(0,2)) = -1;
ASSUME(creturn[0] >= cw(0,2));
// %call = call i32 @pthread_create(i64* noundef %thr0, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t0, i8* noundef null) #6, !dbg !75
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,2+0));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,2+0));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cstart[1] >= cdy[0]);
// %call5 = call i32 @pthread_create(i64* noundef %thr1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t1, i8* noundef null) #6, !dbg !76
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,2+0));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,2+0));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cstart[2] >= cdy[0]);
// %2 = load i64, i64* %thr0, align 8, !dbg !77, !tbaa !78
// LD: Guess
old_cr = cr(0,3);
cr(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM
// Check
ASSUME(active[cr(0,3)] == 0);
ASSUME(cr(0,3) >= iw(0,3));
ASSUME(cr(0,3) >= 0);
ASSUME(cr(0,3) >= cdy[0]);
ASSUME(cr(0,3) >= cisb[0]);
ASSUME(cr(0,3) >= cdl[0]);
ASSUME(cr(0,3) >= cl[0]);
// Update
creg_r2 = cr(0,3);
crmax(0,3) = max(crmax(0,3),cr(0,3));
caddr[0] = max(caddr[0],0);
if(cr(0,3) < cw(0,3)) {
r2 = buff(0,3);
} else {
if(pw(0,3) != co(3,cr(0,3))) {
ASSUME(cr(0,3) >= old_cr);
}
pw(0,3) = co(3,cr(0,3));
r2 = mem(3,cr(0,3));
}
ASSUME(creturn[0] >= cr(0,3));
// %call6 = call i32 @pthread_join(i64 noundef %2, i8** noundef null), !dbg !82
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,2+0));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,2+0));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cdy[0] >= creturn[1]);
// %3 = load i64, i64* %thr1, align 8, !dbg !83, !tbaa !78
// LD: Guess
old_cr = cr(0,4);
cr(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM
// Check
ASSUME(active[cr(0,4)] == 0);
ASSUME(cr(0,4) >= iw(0,4));
ASSUME(cr(0,4) >= 0);
ASSUME(cr(0,4) >= cdy[0]);
ASSUME(cr(0,4) >= cisb[0]);
ASSUME(cr(0,4) >= cdl[0]);
ASSUME(cr(0,4) >= cl[0]);
// Update
creg_r3 = cr(0,4);
crmax(0,4) = max(crmax(0,4),cr(0,4));
caddr[0] = max(caddr[0],0);
if(cr(0,4) < cw(0,4)) {
r3 = buff(0,4);
} else {
if(pw(0,4) != co(4,cr(0,4))) {
ASSUME(cr(0,4) >= old_cr);
}
pw(0,4) = co(4,cr(0,4));
r3 = mem(4,cr(0,4));
}
ASSUME(creturn[0] >= cr(0,4));
// %call7 = call i32 @pthread_join(i64 noundef %3, i8** noundef null), !dbg !84
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,2+0));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,2+0));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cdy[0] >= creturn[2]);
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1), metadata !104, metadata !DIExpression()), !dbg !134
// %4 = load atomic i64, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1) seq_cst, align 8, !dbg !86
// LD: Guess
old_cr = cr(0,0+1*1);
cr(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM
// Check
ASSUME(active[cr(0,0+1*1)] == 0);
ASSUME(cr(0,0+1*1) >= iw(0,0+1*1));
ASSUME(cr(0,0+1*1) >= 0);
ASSUME(cr(0,0+1*1) >= cdy[0]);
ASSUME(cr(0,0+1*1) >= cisb[0]);
ASSUME(cr(0,0+1*1) >= cdl[0]);
ASSUME(cr(0,0+1*1) >= cl[0]);
// Update
creg_r4 = cr(0,0+1*1);
crmax(0,0+1*1) = max(crmax(0,0+1*1),cr(0,0+1*1));
caddr[0] = max(caddr[0],0);
if(cr(0,0+1*1) < cw(0,0+1*1)) {
r4 = buff(0,0+1*1);
} else {
if(pw(0,0+1*1) != co(0+1*1,cr(0,0+1*1))) {
ASSUME(cr(0,0+1*1) >= old_cr);
}
pw(0,0+1*1) = co(0+1*1,cr(0,0+1*1));
r4 = mem(0+1*1,cr(0,0+1*1));
}
ASSUME(creturn[0] >= cr(0,0+1*1));
// call void @llvm.dbg.value(metadata i64 %4, metadata !106, metadata !DIExpression()), !dbg !134
// %conv = trunc i64 %4 to i32, !dbg !87
// call void @llvm.dbg.value(metadata i32 %conv, metadata !103, metadata !DIExpression()), !dbg !113
// %cmp = icmp eq i32 %conv, 2, !dbg !88
// %conv8 = zext i1 %cmp to i32, !dbg !88
// call void @llvm.dbg.value(metadata i32 %conv8, metadata !107, metadata !DIExpression()), !dbg !113
// call void @llvm.dbg.value(metadata i64* @atom_1_X2_0, metadata !109, metadata !DIExpression()), !dbg !138
// %5 = load atomic i64, i64* @atom_1_X2_0 seq_cst, align 8, !dbg !90
// LD: Guess
old_cr = cr(0,2);
cr(0,2) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM
// Check
ASSUME(active[cr(0,2)] == 0);
ASSUME(cr(0,2) >= iw(0,2));
ASSUME(cr(0,2) >= 0);
ASSUME(cr(0,2) >= cdy[0]);
ASSUME(cr(0,2) >= cisb[0]);
ASSUME(cr(0,2) >= cdl[0]);
ASSUME(cr(0,2) >= cl[0]);
// Update
creg_r5 = cr(0,2);
crmax(0,2) = max(crmax(0,2),cr(0,2));
caddr[0] = max(caddr[0],0);
if(cr(0,2) < cw(0,2)) {
r5 = buff(0,2);
} else {
if(pw(0,2) != co(2,cr(0,2))) {
ASSUME(cr(0,2) >= old_cr);
}
pw(0,2) = co(2,cr(0,2));
r5 = mem(2,cr(0,2));
}
ASSUME(creturn[0] >= cr(0,2));
// call void @llvm.dbg.value(metadata i64 %5, metadata !111, metadata !DIExpression()), !dbg !138
// %conv12 = trunc i64 %5 to i32, !dbg !91
// call void @llvm.dbg.value(metadata i32 %conv12, metadata !108, metadata !DIExpression()), !dbg !113
// %and = and i32 %conv8, %conv12, !dbg !92
creg_r6 = max(max(creg_r4,0),creg_r5);
ASSUME(active[creg_r6] == 0);
r6 = (r4==2) & r5;
// call void @llvm.dbg.value(metadata i32 %and, metadata !112, metadata !DIExpression()), !dbg !113
// %cmp13 = icmp eq i32 %and, 1, !dbg !93
// br i1 %cmp13, label %if.then, label %if.end, !dbg !95
old_cctrl = cctrl[0];
cctrl[0] = get_rng(0,NCONTEXT-1);
ASSUME(cctrl[0] >= old_cctrl);
ASSUME(cctrl[0] >= creg_r6);
ASSUME(cctrl[0] >= 0);
if((r6==1)) {
goto T0BLOCK1;
} else {
goto T0BLOCK2;
}
T0BLOCK1:
// call void @__assert_fail(i8* noundef getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([104 x i8], [104 x i8]* @.str.1, i64 0, i64 0), i32 noundef 53, i8* noundef getelementptr inbounds ([23 x i8], [23 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #7, !dbg !96
// unreachable, !dbg !96
r7 = 1;
T0BLOCK2:
// %6 = bitcast i64* %thr1 to i8*, !dbg !99
// call void @llvm.lifetime.end.p0i8(i64 8, i8* %6) #6, !dbg !99
// %7 = bitcast i64* %thr0 to i8*, !dbg !99
// call void @llvm.lifetime.end.p0i8(i64 8, i8* %7) #6, !dbg !99
// ret i32 0, !dbg !100
ret_thread_0 = 0;
ASSERT(r7== 0);
}
| [
"[email protected]"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.