blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 2 247 | content_id stringlengths 40 40 | detected_licenses listlengths 0 57 | license_type stringclasses 2 values | repo_name stringlengths 4 111 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringlengths 4 58 | visit_date timestamp[ns]date 2015-07-25 18:16:41 2023-09-06 10:45:08 | revision_date timestamp[ns]date 1970-01-14 14:03:36 2023-09-06 06:22:19 | committer_date timestamp[ns]date 1970-01-14 14:03:36 2023-09-06 06:22:19 | github_id int64 3.89k 689M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 25 values | gha_event_created_at timestamp[ns]date 2012-06-07 00:51:45 2023-09-14 21:58:52 ⌀ | gha_created_at timestamp[ns]date 2008-03-27 23:40:48 2023-08-24 19:49:39 ⌀ | gha_language stringclasses 159 values | src_encoding stringclasses 34 values | language stringclasses 1 value | is_vendor bool 1 class | is_generated bool 2 classes | length_bytes int64 7 10.5M | extension stringclasses 111 values | filename stringlengths 1 195 | text stringlengths 7 10.5M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
a28218b47492c5ae2f084251b0bcf9c860544fb3 | 8d9a768b11adbc3357339fde03efd3d676e334b0 | /offerT9/offerT9/Solution.cpp | 86d916078facce1f6bb5dad814258d48b046760d | [] | no_license | SerCharles/LeetCode | eea6b240807f986a6638269c305652dd03d18625 | e97fd1ecb6439c1146bbd0f7397c292f4db93080 | refs/heads/master | 2022-12-19T06:58:31.651220 | 2020-09-15T13:38:11 | 2020-09-15T13:38:11 | 279,500,456 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 844 | cpp | Solution.cpp | #include <stack>
class CQueue {
public:
std::stack<int> stackMain;
std::stack<int> stackBack;
CQueue() {
while (!stackMain.empty())
{
stackMain.pop();
}
while (!stackBack.empty())
{
stackBack.pop();
}
}
void appendTail(int value)
{
stackMain.push(value);
}
int deleteHead()
{
while (!stackMain.empty())
{
int num = stackMain.top();
stackMain.pop();
stackBack.push(num);
}
if (!stackBack.empty())
{
int result = stackBack.top();
stackBack.pop();
while (!stackBack.empty()) {
int num = stackBack.top();
stackBack.pop();
stackMain.push(num);
}
return result;
}
else
{
return -1;
}
}
};
/**
* Your CQueue object will be instantiated and called as such:
* CQueue* obj = new CQueue();
* obj->appendTail(value);
* int param_2 = obj->deleteHead();
*/ |
60cd9117a1495351263c003cadf2da5ad82cfbe6 | c32ee8ade268240a8064e9b8efdbebfbaa46ddfa | /Libraries/m2sdk/ue/spatial/I_SpatialSubdivVisQuery.h | d887f9d86f463a54d92c1ea70c102f44c40b4a7f | [] | no_license | hopk1nz/maf2mp | 6f65bd4f8114fdeb42f9407a4d158ad97f8d1789 | 814cab57dc713d9ff791dfb2a2abeb6af0e2f5a8 | refs/heads/master | 2021-03-12T23:56:24.336057 | 2015-08-22T13:53:10 | 2015-08-22T13:53:10 | 41,209,355 | 19 | 21 | null | 2015-08-31T05:28:13 | 2015-08-22T13:56:04 | C++ | UTF-8 | C++ | false | false | 523 | h | I_SpatialSubdivVisQuery.h | // auto-generated file (rttidump-exporter by h0pk1nz)
#pragma once
#include <ue/spatial/I_SpatialQueryBase.h>
namespace ue
{
namespace spatial
{
/** ue::spatial::I_SpatialSubdivVisQuery (VTable=0x01E90250) */
class I_SpatialSubdivVisQuery : public I_SpatialQueryBase
{
public:
virtual void vfn_0001_0753D29E() = 0;
virtual void vfn_0002_0753D29E() = 0;
virtual void vfn_0003_0753D29E() = 0;
virtual void vfn_0004_0753D29E() = 0;
virtual void vfn_0005_0753D29E() = 0;
};
} // namespace spatial
} // namespace ue
|
bac792ccf82fd8ec81437cdd0d50ca5de6a6166e | 359a24530a98bd7717b48d9e5481523b2c6e24c5 | /04-visitors/expressions/StrExpression.cpp | 85c7fb5ffe721d57ae26584a1a74c58ba4c3b6a5 | [] | no_license | KristinaKulabuhova/Interpreter | 5537821b352e892e8742f4ee6a8bb3322e90067b | 40fe15f98d6965825a74a0d7d22d282df6537244 | refs/heads/main | 2023-03-12T01:41:01.487952 | 2021-02-10T17:39:08 | 2021-02-10T17:39:08 | 336,267,075 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 247 | cpp | StrExpression.cpp | #include "StrExpression.h"
StrExpression::StrExpression(std::string name): name_(name) {}
int StrExpression::eval() const {
return first->eval() + second->eval();
}
void StrExpression::Accept(Visitor* visitor) {
visitor->Visit(this);
}
|
d349eba0fc475b323b6f89f1ebc3c737686ca9c8 | c8b2840ea52b1dcb2009b9890cac70ccd4e30875 | /Arduino/Kiln/RTC.cpp | 913a379b481138f91838648c9c4734b9a649609d | [] | no_license | GMTEC/Kiln | 71e351ce416231aaff5a2e05b730400b0103e8e4 | 3a3130a5cdc380d2c4529371e58cbaec18bd87c4 | refs/heads/master | 2021-09-03T20:21:36.319087 | 2018-01-11T18:31:25 | 2018-01-11T18:31:25 | 106,564,047 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 387 | cpp | RTC.cpp | //
#include <RTClibExtended.h>
#include <Wire.h>
#include "RTC.h"
void RTCClass::init()
{
Wire.begin();
rtc.begin();
//rtc.adjust(DateTime(2017, 10, 22, 19, 48, 0));
}
void RTCClass::update()
{
DateTime t = rtc.now();
//Serial.println("Hours: " + String(t.hour()) + " Minutes: " + String(t.minute()) + "Seconds: " + String(t.second()));
}
RTCClass RTC;
|
85025e08f32fb1447e7ed68f4e0675c13c454d24 | 12a5b72982291ac7c074210afc2c9dfe2c389709 | /competitions/acm-icpc/2017/brazil-first-phase/C/code.cpp | 4253426fa9d6315ec41e41ee8123376bb89794de | [] | no_license | krantirk/Algorithms-and-code-for-competitive-programming. | 9b8c214758024daa246a1203e8f863fc76cfe847 | dcf29bf976024a9d1873eadc192ed59d25db968d | refs/heads/master | 2020-09-22T08:35:19.352751 | 2019-05-21T11:56:39 | 2019-05-21T11:56:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 685 | cpp | code.cpp | #include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
if(a == 0) return b;
return gcd(b%a, a);
}
int main() {
long long int n,l;
scanf(" %lld %lld", &n, &l);
long long int mmc;
scanf(" %lld", &mmc);
for(int i = 0; i < n-1; i++) {
long long int x;
scanf(" %lld", &x);
long long int tmp = gcd(mmc, x);
mmc = mmc *(x / tmp);
}
long long int mxi = 1;
long long int mx = mmc;
for(int i = 1; i <= l; i++) {
long long int newgcd = gcd(mmc, i);
long long int newmmc = mmc * (i / newgcd);
if(newmmc <= l && newmmc > mx) {
mx = newmmc;
mxi = i;
}
}
printf("%lld\n", mxi);
return 0;
}
|
55d3159ff2ba2b18bab7e69670549923078cdeef | ae90c2d6e27c544ab0579f801becd08fd0ff13d8 | /Librairies/ORPProbeManagement/ORPprobeManagement.h | 9862c4c055729423faed91ef9b5e18b253d0fcea | [] | no_license | laurentgarnier/Arduino | b801884bd71d8a352aa1dddb4c6a12312d06592f | 65cfcf4045e90c7dcc369a6de744a56d419d9db9 | refs/heads/master | 2021-01-18T14:34:32.297663 | 2020-04-18T15:18:40 | 2020-04-18T15:18:40 | 27,995,788 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 268 | h | ORPprobeManagement.h | class ORPMeasure
{
public :
float lireORP(int brocheDeLaSonde, int nombreDePointsDeMesure, int nbPasPourVRef, int vRef, float calibration);
private:
float calculerORP(float* mesures, int nombreDePointsDeMesure, int nbPasPourVRef, int vRef, float calibration);
};
|
dc11ab70ba61c1ae53b2741542ce50cd9406b8da | 63f90c1b7516359ff4b7bf913a556ffcf1798b64 | /src/nimbro_robotcontrol/hardware/servomodel/src/testbench/Keyframe.h | 7225920fa31cd8b6c854428eae70eccbee8e7d56 | [] | no_license | rokhmatf/TeenSize-HR | e721ed9e388bc30d7e328c20b55f29eed123552e | 7d942c83290f62b75a4bb08b5824e8adba03080d | refs/heads/master | 2022-12-08T23:49:14.640752 | 2020-08-20T13:59:07 | 2020-08-20T13:59:07 | 289,016,344 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 936 | h | Keyframe.h | #ifndef KEYFRAME_H_
#define KEYFRAME_H_
#include "Vec2f.h"
#include <QDebug>
class Keyframe
{
public:
Keyframe();
Keyframe(double t, double x, double v);
~Keyframe(){};
int type;
double t;
double x;
double v;
double a;
bool highlight;
enum types
{
TYPE_DEFAULT,
TYPE_AMAX,
TYPE_VMAX,
TYPE_UNREACHABLE
};
void set(double t, double x, double v);
Vec2f location();
void setLocation(Vec2f);
void relocateBy(Vec2f);
inline bool operator<(const Keyframe& v) const {return (t < v.t);}
inline bool operator<=(const Keyframe& v) const {return (t <= v.t);}
inline bool operator>(const Keyframe& v) const {return (t > v.t);}
inline bool operator>=(const Keyframe& v) const {return (t >= v.t);}
inline bool operator==(const Keyframe& v) const {return (t == v.t);}
inline bool operator!=(const Keyframe& v) const {return (t != v.t);}
};
QDebug operator<<(QDebug dbg, const Keyframe &k);
#endif /* KEYFRAME_H_ */
|
04a03430be818180b7e8cade8008a3491476397d | 0c223a66cadf2d4488a6678a8f5578c39990aaec | /CF:263:1:D/ACC.cpp | 0c6e12c3ffd1e3959cc70ecaa430c60441b37d0e | [] | no_license | prajogotio/upsolving | b71a1803b372960eec65c6effef2934065d36786 | 51078bf1118acd97af75683a53104bd59311686c | refs/heads/master | 2021-01-10T01:00:18.757460 | 2015-07-21T18:48:02 | 2015-07-21T18:48:02 | 28,124,346 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,760 | cpp | ACC.cpp | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>
#include <cstring>
using namespace std;
int N, E;
vector<pair<int,int> > eqn;
vector<int> val;
vector<vector<pair<int,int> > > adj;
int col[100005];
int f[100005];
vector<pair<int,int> > p;
bool inconsistent;
void dfs(int u, int r) {
if(inconsistent) return;
if(col[u] != -1) {
if(col[u] != r) {
inconsistent = true;
}
return;
} else {
col[u] = r;
for(int i=0;i<adj[u].size();++i) {
int v = adj[u][i].first;
int m = adj[u][i].second;
dfs(v, r^m);
if(inconsistent) return;
}
}
}
void solve() {
scanf("%d %d", &N, &E);
int u,v,k;
char ch;
for(int i=0;i<E;++i){
scanf("%d %d %c", &u, &v, &ch);
eqn.push_back(make_pair(u-1,v-1));
if(ch == 'o') val.push_back(1);
else val.push_back(0);
}
adj = vector<vector<pair<int,int> > >(N+3);
int L, R;
int even, odd;
if(N%2 == 0) {
even = N;
odd = N+1;
} else {
odd = N+1;
even = N;
}
for(int i = 0; i < E; ++i) {
u = eqn[i].first;
v = eqn[i].second;
k = val[i];
L = (u-v > 0 ? u-v : v-u);
R = (0 > u+v - N ? u+v : 2*(N-1) - (u+v));
if(R+2 == ((u+v)%2 == 0 ? even:odd)) {
adj[L].push_back(make_pair(R+2,k));
continue;
}
adj[L].push_back(make_pair(R+2,k));
adj[R+2].push_back(make_pair(L,k));
}
long long ans = 1;
int diff = 0;
memset(col, -1, sizeof(col));
inconsistent = false;
for(int i=0;i<N;++i) {
if(inconsistent) break;
if(col[i] == -1) {
col[even] = col[odd] = -1;
dfs(i,0);
if(col[even] == -1 && col[odd] == -1) ++diff;
}
}
if(inconsistent) {
printf("0\n");
return;
}
for(int i=0;i<diff;++i) {
ans = (ans * 2) % (1000000007);
}
cout << ans << endl;
}
int main() {
solve();
return 0;
} |
37b8bd5bdf75e09a9a98cb8de2da5fbae586e680 | 31207cd271e4bd3a629bb30f56ca51726b10394b | /MFCWinFormHybrid/MFCWinFormHybrid/MFCWinFormHybridView.h | d4dc62b61fd1cc25201ddbc3363638200602a181 | [
"Apache-2.0"
] | permissive | jiangsheng/Samples | 632ed699e29935b4362e03760e28c8391e62f406 | f35bcaa180fc61a5d34156e01ad2477d0b579076 | refs/heads/master | 2022-02-27T13:16:05.154344 | 2022-02-09T15:45:54 | 2022-02-09T15:45:54 | 13,873,264 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,799 | h | MFCWinFormHybridView.h | // MFCWinFormHybridView.h : interface of the CMFCWinFormHybridView class
//
#pragma once
#include <afxwinforms.h> // MFC Windows Forms support
#include "managedControls.h"
class CMFCWinFormHybridView : public CFormView
{
protected: // create from serialization only
CMFCWinFormHybridView();
DECLARE_DYNCREATE(CMFCWinFormHybridView)
public:
enum{ IDD = IDD_MFCWINFORMHYBRID_FORM };
// Attributes
public:
CMFCWinFormHybridDoc* GetDocument() const;
CWinFormsControl<MFCWinFormHybrid::managedControls> m_ctrl1;
// Operations
public:
// Overrides
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual void OnInitialUpdate(); // called first time after construct
// Implementation
public:
virtual ~CMFCWinFormHybridView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
DECLARE_MESSAGE_MAP()
public:
BEGIN_DELEGATE_MAP( CMFCWinFormHybridView )
EVENT_DELEGATE_ENTRY( OnFileExitClicked, Object^, EventArgs^ )
EVENT_DELEGATE_ENTRY( OnEditCopyClicked, Object^, EventArgs^ )
EVENT_DELEGATE_ENTRY( OnEditPasteClicked, Object^, EventArgs^ )
END_DELEGATE_MAP()
void OnFileExitClicked( System::Object^ sender, System::EventArgs^ e ) ;
void OnEditCopyClicked( System::Object^ sender, System::EventArgs^ e ) ;
void OnEditPasteClicked( System::Object^ sender, System::EventArgs^ e ) ;
afx_msg void OnEditCopy();
afx_msg void OnEditPaste();
afx_msg void OnDestroy();
};
#ifndef _DEBUG // debug version in MFCWinFormHybridView.cpp
inline CMFCWinFormHybridDoc* CMFCWinFormHybridView::GetDocument() const
{ return reinterpret_cast<CMFCWinFormHybridDoc*>(m_pDocument); }
#endif
|
78baede968ca911843c6f554c4228fe4b4ebe9c8 | ee92057a8ebc91ba90d8055a9bece25d24211499 | /kattis/piglatin/piglatin.cpp | 5e8abe3c3355f944edd32464b5239b974a3a2492 | [] | no_license | KendrickAng/competitive-programming | ce0a4f44f592f295c2f8cd7e854139f18fb8853a | f9768a2020f801b8e4787cc853398b8258a0bf09 | refs/heads/master | 2022-05-29T07:21:32.607089 | 2022-04-24T16:35:14 | 2022-04-24T16:35:14 | 254,402,307 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,475 | cpp | piglatin.cpp | #include <iostream>
#include <string>
#include <sstream>
#include <unordered_set>
using namespace std;
int main() {
unordered_set<char> vowels = {'a','e','i','o','u'};
string line;
while (getline(cin, line)) {
istringstream iss(line);
string item;
bool first = true;
while (getline(iss, item, ' ')) {
if (first) {
first = false;
} else {
cout << " ";
}
// begins with vowel
if (vowels.find(item[0]) != vowels.end()) {
item.append("yay");
cout << item;
}
// beings with consonant
else {
int idx = -1;
bool hasvowel = false;
char vowel;
for (int i = 0; i < item.size(); i++) {
if (vowels.find(item[i]) != vowels.end()) {
vowel = item[i];
hasvowel = true;
break;
}
}
if (hasvowel) {
string s2 = "";
int idx = item.find(vowel);
s2.append(item.substr(idx) + item.substr(0, idx) + "ay");
cout << s2;
} else {
cout << item + "ay";
}
}
}
cout << endl;
}
} |
5e452966cc188386c2644e5ddf4bc2e4d776fc12 | 97132c97051e09369eaecbb25ad3de70b2f3a5ab | /PAT/乙级/1007.cpp | c94133172a48c8138388b4f55327ae00cced53d6 | [] | no_license | LITturtlee/Programming-Practice | a3948c8de704ef9542d4414bbeb44db1a2772727 | 1ff744c37f21105f742b9d6864f8120591d57eae | refs/heads/main | 2023-06-18T06:13:21.172660 | 2021-07-23T09:28:26 | 2021-07-23T09:28:26 | 354,049,837 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 574 | cpp | 1007.cpp | #include <iostream>
#include <cmath>
using namespace std;
bool isPrimeNum(int& n){
int range = (int)sqrt(n);
if(n==1)return true;
for(int i=2;i<=range;i++){
if(n%i==0)return false;
}
return true;
}
int main(){
int input;
int primeNum=0,prePrimeNum=0,count=0;
cin >> input;
for(int i=1;i<input+1;i++){
if(isPrimeNum(i)){
primeNum = i;
// cout << primeNum <<endl;
if(primeNum-prePrimeNum==2)count++;
prePrimeNum = primeNum;
}
}
cout << count;
return 0;
} |
b5b571e1e635fa2c54a398052a6babf71ef3fd2f | 8d9678638ff036de2353880baccb5246417d3b03 | /EPI/Chap15_Prob4_LargestKelements.cpp | c8fcb5e162c41f33d85dff2e2da76273c40bfe56 | [] | no_license | raviswan/Elixir | ed1bb8b88d77b727ad69e85a96eb0b1f156f35d8 | 8eff68c53444b1661e5d2fe6af0aa5c5581b6f82 | refs/heads/master | 2021-07-22T18:24:05.102390 | 2017-11-02T03:47:27 | 2017-11-02T03:47:27 | 109,010,426 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 543 | cpp | Chap15_Prob4_LargestKelements.cpp | #include <iostream>
#include <memory>
#include <vector>
template<typename T>
struct TreeNode{
T data;
std::unique_ptr<TreeNode<T>> left, right;
};
void findKlargest(std::unique_ptr<TreeNode<int>>& tree, std::vector<int>* vec,int k){
if(tree && vec->size() < k){
findKlargest(tree->right,vec, k);
if(vec->size() < k){
vec->emplace_back(tree->data);
findKlargest(tree->left,vec, k);
}
}
}
std::vector<int> findK(std::unique_ptr<TreeNode<int>> root, int k){
std::vector<int> vec;
findKlargest(root,&vec,k);
return vec;
}
|
2284272dff12040ebde02cb902d2c506c96ce8c6 | aecd3b642acb8cd9c1de65a59cfed9567bdf78f1 | /examples/_5plus4WRTminus2WRT/_5plus4WRTminus2WRT.ino | 692542cc8f843505ba09ff9ff14f655941404595 | [] | no_license | Digital-Technologies-Institute/B4 | eac80098f69d9594ba69441323f69eb18db6f8ac | 779289c43dbf6865b0701b242fbfc5b0f794e0e3 | refs/heads/master | 2020-12-02T22:44:18.380941 | 2017-07-04T05:14:52 | 2017-07-04T05:14:52 | 96,174,948 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 496 | ino | _5plus4WRTminus2WRT.ino | #include <B4.h>
B4 myB4;
/*
* 5+4 WRT -2 WRT
*/
int DataRAMContent[] = {
B0101, B0100, B0000, B0010,
B0000, B0000, B0000, B0000,
B0000, B0000, B0000, B0000,
B0000, B0000, B0000, B0000,
};
int ProgramRAMContent[] = {
B0010, B0000, B0110, B1000,
B0110, B0000, B0000, B0000,
B0000, B0000, B0000, B0000,
B0000, B0000, B0000, B0000,
};
void setup()
{
myB4.loadDataAndProgram(DataRAMContent, ProgramRAMContent);
myB4.programB4();
}
void loop()
{
}
|
5cf3f145f90beb48b1cf467726e1aa686e1b628b | 4048dc505f87f5dc27fd8a8c920e51cd72e44aa2 | /applications/master_worker/advert.cpp | 4d927b2115e4a01bf03977ed550da5aa3251499a | [] | no_license | saga-project/saga-cpp-legacy-projects | 007af3860994a3f10c7163b4b271cccd7eb10eb8 | 2874ff6714776ee721a46f5b68f317e0d1dbfbf9 | refs/heads/master | 2023-04-05T00:47:38.636238 | 2023-03-31T14:47:42 | 2023-03-31T14:47:42 | 5,780,249 | 0 | 3 | null | 2023-03-31T14:47:43 | 2012-09-12T13:38:02 | TeX | UTF-8 | C++ | false | false | 9,126 | cpp | advert.cpp |
#include "advert.hpp"
namespace saga_pm
{
namespace master_worker
{
////////////////////////////////////////////////////////////////////
advert::advert (void)
: ok_ (false)
, s_ (Unknown)
, url_ ("")
, id_ (0)
{
}
////////////////////////////////////////////////////////////////////
advert::advert (saga::url url)
: ok_ (false)
, s_ (Unknown)
, url_ (url)
{
// create or reconnect to advert
try
{
// try to open. if the ad exists, it is simply being reused, and
// re-initialized. Note that this can cause race conditions if
// different runs have overlapping name spaces!
ad_ = saga::advert::entry (url_, saga::advert::ReadWrite);
id_ = ::atoi (ad_.get_attribute ("id").c_str ());
ok_ = true;
LOG << "open ad ok " << id_ << std::endl;
}
catch ( const saga::exception & e )
{
LOG << " worker: cannot open advert "
<< url_ << " : \n" << e.what () << std::endl;
exit (-1);
}
}
////////////////////////////////////////////////////////////////////
advert::advert (saga::job::service js,
saga::job::job job,
saga::url url,
id_t id)
: ok_ (false)
, s_ (Unknown)
, js_ (js)
, job_ (job)
, url_ (url)
, id_ (id)
{
try
{
// create the advert, initialize all attributes, set id and
// state (Started)
LOG << "creating ad at " << url_;
ad_ = saga::advert::entry (url_, saga::advert::ReadWrite |
saga::advert::CreateParents );
LOG << "created ad at " << url_;
std::string empty ("");
std::vector <std::string> empty_vec;
empty_vec.push_back (empty);
id_ = get_worker_id ();
ad_.set_attribute ("id", itoa (id_));
ad_.set_attribute ("task", empty);
ad_.set_attribute ("error", empty);
ad_.set_attribute ("task", empty);
ad_.set_attribute ("state", state_to_string (Unknown));
ad_.set_vector_attribute ("par_in", empty_vec);
ad_.set_vector_attribute ("par_out", empty_vec);
ok_ = true; // no exception means success :-)
}
catch ( const saga::exception & e )
{
LOG << " advert: cannot create advert "
<< url_ << " : \n" << e.what () << std::endl;
exit (-1);
}
}
////////////////////////////////////////////////////////////////////
advert::~advert (void)
{
}
////////////////////////////////////////////////////////////////////
void advert::run (std::string command,
argvec_t args)
{
if ( ! ok_ )
{
throw saga::no_success ("advert: run: not initialized");
}
if ( Idle != get_state () )
{
throw saga::no_success ("Cannot run command - worker not idle");
}
set_task (command);
set_par_in (args);
set_par_out (noargs_);
set_error ("");
set_state (Assigned);
}
////////////////////////////////////////////////////////////////////
void advert::wait (void)
{
if ( ! ok_ )
{
throw saga::no_success ("advert: wait: not initialized");
}
state s = get_state ();
while ( Done != s &&
Failed != s &&
Quit != s )
{
LOG << "waiting for worker " << get_id ();
:: sleep (1);
s = get_state ();
}
// if ( Failed == s )
// {
// throw saga::no_success ("command failed");
// }
// if ( Done != s )
// {
// throw saga::no_success ("worker in incorrect state");
// }
}
////////////////////////////////////////////////////////////////////
void advert::purge (void)
{
if ( ok_ )
{
ad_.remove ();
ok_ = false;
}
}
////////////////////////////////////////////////////////////////////
void advert::dump (void)
{
if ( ! ok_ )
{
throw saga::no_success ("advert: dump: not initialized");
}
try
{
std::vector <std::string> attribs = ad_.list_attributes ();
LOG << " -----------------------------------------------------";
LOG << " dumping worker " << get_id () << " @ " << url_;
LOG << "";
for ( unsigned int i = 0; i < attribs.size (); i++ )
{
if ( ad_.attribute_is_vector (attribs[i]) )
{
std::string val;
val += " " + attribs[i] + " \t:";
std::vector <std::string> vals = ad_.get_vector_attribute (attribs[i]);
for ( unsigned int j = 0; j < vals.size (); j++ )
{
if ( j > 0 )
{
val += ",";
}
val += " " + vals[j];
}
LOG << val;
}
else
{
LOG << " " << attribs[i] << " \t: " << ad_.get_attribute (attribs[i]) << std::endl;
}
}
}
catch ( const saga::exception & e )
{
throw saga::no_success (std::string ("advert: dump error: ") + e.what ());
}
}
////////////////////////////////////////////////////////////////////
saga::job::job advert::get_job (void)
{
return job_;
}
////////////////////////////////////////////////////////////////////
id_t advert::get_id (void)
{
if ( ! ad_.attribute_exists ("id") )
{
throw saga::no_success ("no id found");
}
id_t id = ::atoi (ad_.get_attribute ("id").c_str ());
return id;
}
////////////////////////////////////////////////////////////////////
void advert::set_state (state s)
{
if ( ! ad_.attribute_exists ("state") )
{
throw saga::no_success ("no state attribute found");
}
std::string old = ad_.get_attribute ("state");
ad_.set_attribute ("state", state_to_string (s));
}
////////////////////////////////////////////////////////////////////
state advert::get_state (void)
{
if ( ! ad_.attribute_exists ("state") )
{
throw saga::no_success ("no state found");
}
std::string s = ad_.get_attribute ("state");
return string_to_state (s);
}
////////////////////////////////////////////////////////////////////
void advert::set_error (std::string e)
{
ad_.set_attribute ("error", e);
}
////////////////////////////////////////////////////////////////////
std::string advert::get_error (void)
{
if ( ! ad_.attribute_exists ("error") )
{
return ("no error");
}
std::string error = ad_.get_attribute ("error");
return error;
}
////////////////////////////////////////////////////////////////////
argvec_t advert::get_par_in (void )
{
if ( ! ok_ )
{
throw saga::no_success ("advert: get_par_in: not initialized");
}
if ( ! ad_.attribute_exists ("par_in") )
{
throw saga::no_success ("worker does not have in parameters, yet");
// argvec_t par_in;
// return par_in;
}
return (ad_.get_vector_attribute ("par_in"));
}
////////////////////////////////////////////////////////////////////
void advert::set_par_in (argvec_t pi)
{
ad_.set_vector_attribute ("par_in", pi);
}
////////////////////////////////////////////////////////////////////
argvec_t advert::get_par_out (void )
{
if ( ! ok_ )
{
throw saga::no_success ("advert: get_par_out: not initialized");
}
if ( ! ad_.attribute_exists ("par_out") )
{
throw saga::no_success ("worker does not have out parameters, yet");
// argvec_t par_out;
// return par_out;
}
return (ad_.get_vector_attribute ("par_out"));
}
////////////////////////////////////////////////////////////////////
void advert::set_par_out (argvec_t po)
{
ad_.set_vector_attribute ("par_out", po);
}
////////////////////////////////////////////////////////////////////
std::string advert::get_task (void )
{
if ( ! ok_ )
{
throw saga::no_success ("advert: get_task: not initialized");
}
if ( ! ad_.attribute_exists ("task") )
{
throw saga::no_success ("worker does not have a task, yet");
}
std::string t = ad_.get_attribute ("task");
return t;
}
////////////////////////////////////////////////////////////////////
void advert::set_task (std::string t)
{
ad_.set_attribute ("task", t);
}
} // namespace master_worker
} // namespace saga_pm
|
8e86850d6f9c8e3206a493860b9f9bb90a6a93fd | b8376621d63394958a7e9535fc7741ac8b5c3bdc | /lib/lib_mech/src/server/TServer/TCommonClient/TServerClient_CommonHeader.h | 233bc52568a7ed0576b9306e766bf9a384b2fc28 | [] | no_license | 15831944/job_mobile | 4f1b9dad21cb7866a35a86d2d86e79b080fb8102 | ebdf33d006025a682e9f2dbb670b23d5e3acb285 | refs/heads/master | 2021-12-02T10:58:20.932641 | 2013-01-09T05:20:33 | 2013-01-09T05:20:33 | null | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 5,328 | h | TServerClient_CommonHeader.h | /* file : common_AQ_header.h
Coder : by icandoit ( mech12@nate.com)
Date : 2008-08-13 16:06:06
comp.: actoz.com
title :
desc :
*/
#ifndef __common_AQ_header_header__
#define __common_AQ_header_header__
#pragma once
#ifndef jNET_COMMON_LIB_API
#define jNET_COMMON_LIB_API T_SERVER_LIB_API
#endif
// excel StringID header용
#define jSTRING_ID_LIB_API T_SERVER_LIB_API
#pragma warning( error : 4715 )
#define jOBJECT_NAME 31 // 모든 게임 오브젝트의 이름은 32-1이다.
//! --------------------------------------------------------------------------
//! 기본 상수 선언.
//! --------------------------------------------------------------------------
#include "../TCommonClient/excel/table_const.h"
const int jMAX_TOWN_SLOT = 14;//aq_table.xls 의 EItemInventoryType참고
const int iMAX_TOWN_ITEM = 200; //소유 아이템 최대갯수
//! --------------------------------------------------------------------------
//! 기본 자료형 선언.
//! --------------------------------------------------------------------------
typedef nMech::uint32 dummy_id_t; // 테스트 더미의 고유아이디.
typedef nMech::wname64_t player_name_t;//유저 ID이름.
typedef nMech::wcstr player_name_ct;
typedef std::wstring player_name_string_t;
const size_t player_name_SIZE = 64;
typedef nMech::uint8 channelid_t; // 메모리DB에서의 index , 서버로 부터 받은 리스트에서의 인덱스.
typedef nMech::uint16 itemid_t;// 메모리DB에서의 index , 서버로 부터 받은 리스트에서의 인덱스. 인덱스는 1부터시작. 0은 사용하지 않는다.
typedef nMech::uint16 inven_slot_t;//인벤토리는 0~1000 , 창고는 1000부터...
typedef nMech::uint8 skillid_t; // skid 배열에 대해 1부터시작
typedef nMech::uint16 serverid_t;//central server에서 부여.
jLIST_TYPEDEF_vector_typedef(astring,astrings);
jLIST_TYPEDEF_vector_typedef(wstring,wstrings);
#ifdef UNICODE
jLIST_TYPEDEF_vector_typedef(tstring,wstrings);
#else
jLIST_TYPEDEF_vector_typedef(tstring,astrings);
#endif
#include "interface/db/db_uid_type.h"
#include "../TCommonClient/excel/table_type.h"
#include "../TCommonBase/player_id_t.h"
//! --------------------------------------------------------------------------
//! 기본 구조체 선언
//! --------------------------------------------------------------------------
//! W_ERROR, DC_ERROR, L_ERROR, T_ERROR, D_ERROR , U_ERROR , C_ERROR에서 사용.
enum EErrorActionType
{
eEAT_SKIP // 해당 로그만 남기고 아무 액션을 취하지 않음.
,eEAT_NOTIFY_TO_CLIENT // 유저에게 에러메시지를 전달한다.
,eEAT_NOTIFY_ALL_CLIENT // 유저에게 모든 에러메시지를 전달한다.
,eEAT_NOTIFY_AND_DISCON_USER // 에러메세지 전달후 해당 클라이언트 접속을 끊는다.
,eEAT_DISCON_USER // 이 메세지를 서버가 받으면 해당 클라이언트 접속을 즉시 끊는다.
};
struct jErrorInfo // 네트웍통신간의 에러 응답정보.
{
jError e; //에러 발생한곳에서 보내는 에러 정보.
player_id_t pid;
uint8 eAction; // EErrorActionType , 에러메시지를 받고 관련 socket에 대한 처리(disconnect or skip or log)
void SetAction(EErrorActionType e){ eAction=(EErrorActionType)e;}
EErrorActionType GetAction() { return (EErrorActionType)eAction;}
bool IsAction(EErrorActionType e){ return eAction==e;}
astring sFunction;
jErrorInfo(){}
jErrorInfo(jError _e,EErrorActionType _eAction,acstr _sFunction,player_id_t _pid):sFunction(_sFunction),e(_e),pid(_pid){SetAction(_eAction);}
jErrorInfo(jError_Creator_arg_t s, jError_Creator_arg_t c,EErrorActionType _eAction,acstr _sFunction,player_id_t _pid)
:sFunction(_sFunction),e(s,c),pid(_pid){SetAction(_eAction);}
};
struct jServerUserID // 서버간에 유저 요청을 처리할때 해당유저가 접속되어 있는 서버정보를 포함한 user id
{
player_id_t uid;
serverid_t sid;
jServerUserID(player_id_t u,serverid_t s): sid(s){uid = u;}
jServerUserID() : sid(0){uid.m_id = 0;}
};
struct jNoticeInfo
{
nMech::uint8 type; //공지 타입
nMech::uint8 color;//원하는 출력 글자 색
nMech::uint16 reserve_min; //해당 분이 지난 후 공지를 클라이언트에 출력.
nMech::uint16 repeat_count; //해당 공지를 몇번 반복해서 출력
};
//
#define for_each_USER_GPS(X)\
X(NULL , "초기화상태")\
X(L_CONNECTED,"로긴서버접속완료.인증은안되었음.")\
X(L_CERTIFICATION,"로긴서버 인증 완료.")\
X(T_USER_CONNECT,"타운서버 접속 완료.")\
X(T_PERSONALROOM,"퍼서널 룸에 입장.")\
X(T_TOWN,"마을에 입장.")\
enum EUserGPS
{
#define enum_USER_GPS23(name,help) eGPS_##name,
for_each_USER_GPS(enum_USER_GPS23)
EUserGPS_END,
};
inline nMech::tcstr ToString(EUserGPS e)
{
#define ToString_USER_GPS23(name,help) if(e==eGPS_##name) return _T(#name);
for_each_USER_GPS(ToString_USER_GPS23);
return jS(EUserGPS_Unkown);
}
struct jChannelPlayerCookie
{
player_id_t uid;
nMech::wname32_t channel_id;
};
enum EChannelPlayerMovement
{
eTPM_STOP,
eTPM_WALK,
eTPM_RUN
};
struct jWorldServerInfo
{
aname32_t szName;
uint8 iBusy;
};
inline cstr ToString(jWorldServerInfo* p, fname_t buf)
{
jt_sprintf_s(buf, 256,_T("name:%s busy:%s"), p->szName, p->iBusy);
return buf;
}
#endif // __common_AQ_header_header__
|
21eb638350d20544d05279c0cb744ef431dcbd99 | 29f7438f129bf6cdd76d9961cdac00381d16634c | /include/arepa/Attribute.h | b1b9b1fdeb6a6d5ec8b9fbdd019160c9b66867ba | [
"MIT"
] | permissive | Pikecillo/arepa | a8a975772edb79d1e6e51d7803cb1bafc13b8949 | c3baf597e8100079548388b1e93502d246fd2e5d | refs/heads/master | 2022-07-27T02:46:10.293233 | 2022-07-07T13:18:15 | 2022-07-07T13:18:15 | 71,656,450 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,271 | h | Attribute.h | #pragma once
#include <cstdint>
#include <string>
namespace arepa {
class Attribute {
public:
enum class Type { Float, Int };
Attribute(const std::string &name, Type type, std::uint8_t components,
std::uint32_t stride, std::uint32_t offset);
const std::string &name() const;
Type type() const;
std::uint8_t components() const;
std::uint32_t stride() const;
std::uint32_t offset() const;
private:
std::string m_name;
Type m_type;
std::uint8_t m_components;
std::uint32_t m_stride;
std::uint32_t m_offset;
};
inline Attribute::Attribute(const std::string &name, Type type,
std::uint8_t components, std::uint32_t stride,
std::uint32_t offset)
: m_name(name), m_type(type), m_components(components), m_stride(stride),
m_offset(offset) {
}
inline const std::string &Attribute::name() const {
return m_name;
}
inline Attribute::Type Attribute::type() const {
return m_type;
}
inline std::uint8_t Attribute::components() const {
return m_components;
}
inline std::uint32_t Attribute::stride() const {
return m_stride;
}
inline std::uint32_t Attribute::offset() const {
return m_offset;
}
} // namespace arepa
|
ddb8f6a83650ac613c79d7d2238ff3f4a36c1ef3 | de1fc8272ca500fb13a93c9d053cdd75634329cd | /LeetCode/HappyNumber/Source.cpp | 9e8a5ad0ef6e5f7410c7b864130490d37c6b818b | [] | no_license | hohaidang/CPP_Basic2Advance | ada69129123c14491c29803a3f7224b924616a80 | cdb733e9b24c7ad4927deab57fff389f521d0ea3 | refs/heads/master | 2021-05-21T10:31:46.627204 | 2021-03-29T07:16:43 | 2021-03-29T07:16:43 | 252,654,029 | 5 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 530 | cpp | Source.cpp | #include <iostream>
using namespace std;
class Solution {
public:
int getNext(int n) {
int totalSum = 0;
while (n > 0) {
int d = n % 10;
n = n / 10;
totalSum += d * d;
}
return totalSum;
}
bool isHappy(int n) {
int slowRunner = n;
int fastRunner = getNext(n);
while (fastRunner != 1 && slowRunner != fastRunner) {
slowRunner = getNext(slowRunner);
fastRunner = getNext(getNext(fastRunner));
}
return fastRunner == 1;
}
};
int main() {
Solution sol = Solution();
cout << sol.isHappy(12);
} |
3fc8bfcdf9042ce109e80e27479d798301c80e14 | c87eb5e3d54d0fde37bb89c267b3db52c0d95502 | /source/parser/paramTree.cpp | dc843ca1455454888b15c61c1af37fc22e7b10e2 | [] | no_license | icherkashin/mc-mini | 0a8424d96e30888cec40e1db4fce12a4ca70900c | 9d71308656590828beb622922720bf7df592060c | refs/heads/master | 2021-01-09T06:39:46.305796 | 2015-12-13T03:30:01 | 2015-12-13T03:30:01 | 41,170,054 | 1 | 0 | null | 2015-08-21T18:03:44 | 2015-08-21T18:03:44 | null | UTF-8 | C++ | false | false | 1,855 | cpp | paramTree.cpp | #include <iostream>
#include <string>
#include <map>
#include "parser/parserException.h"
#include "parser/paramTree.h"
using namespace std;
ParamNode::~ParamNode () {
for (map<string, ParamNode *>::iterator it = children.begin(); it != children.end(); ++it) {
delete (it->second);
}
}
ParamTree::ParamTree () {
rootNode = focusNode = new ParamNode;
focusNode->parent = NULL;
cerr << "Initialized parameter tree." << endl;
}
ParamTree::~ParamTree () {
delete rootNode;
}
void ParamTree::moveUp (string key) {
if (focusNode->children.count (key)) {
map<string, ParamNode *>::iterator iter = focusNode->children.find (key);
focusNode = iter->second;
} else {
throw child_not_found;
}
}
void ParamTree::moveDown () {
if (focusNode->parent == NULL) {
throw -1;
} else {
focusNode = focusNode->parent;
}
}
string ParamTree::getParam (string key) {
if (focusNode->params.count (key)) {
return focusNode->params[key];
} else {
throw param_not_found;
}
}
void ParamTree::addNode (string key) {
if (focusNode->children.count (key)) {
throw -1;
} else {
ParamNode * newNode = new ParamNode;
newNode->parent = focusNode;
focusNode->children.insert(pair<string, ParamNode *> (key, newNode));
}
}
void ParamTree::delNode (string key) {
if (focusNode->children.count (key)) {
ParamNode * match = focusNode->children.find (key)->second;
focusNode->children.erase (key);
delete match;
} else {
throw child_not_found;
}
}
void ParamTree::addParam (string key, string param) {
focusNode->params.insert(pair<string, string> (key, param));
cerr << "Wrote " << key << " as " << param << endl;
}
void ParamTree::delParam (string key) {
if (focusNode->params.count (key)) {
focusNode->params.erase (key);
} else {
throw param_not_found;
}
}
|
5fa8126c90b798a8d191813367180c457f207299 | 2846cd608d6dd5615fb0c40160c3a64e5dc88dd3 | /detail/Cluster.hpp | 46046d105569a37d47537a2b4b79a48b1f3d408a | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | asrivast28/ParsiMoNe | 921ffc63e863dd06394051121df3560ffb4bae9e | f702eaf8a4018476e6795e9c84193306c80de391 | refs/heads/main | 2023-04-11T13:01:35.163440 | 2021-08-10T04:09:28 | 2021-08-10T04:09:28 | 349,758,347 | 8 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,823 | hpp | Cluster.hpp | /**
* @file Cluster.hpp
* @brief Implementation of functionality for storing clusters.
* @author Ankit Srivastava <asrivast@gatech.edu>
*
* Copyright 2020 Georgia Institute of Technology
*
* 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 DETAIL_CLUSTER_HPP_
#define DETAIL_CLUSTER_HPP_
#include "common/SetUtils.hpp"
#include "utils/Logging.hpp"
#include <random>
/**
* @brief Base class that provides functionality for cluster storage.
*
* @tparam Data Type of the data provider.
* @tparam Var Type of variables stored in the cluster.
* @tparam Set Type of container used to store the clusters.
*/
template <typename Data, typename Var, typename Set>
class Cluster {
public:
Cluster(
const Data& data,
const Var max
) : m_elements(max),
m_data(data)
{
}
Cluster(
const Data& data,
const Set& elements
) : m_elements(elements),
m_data(data)
{
}
Cluster(const Cluster& other)
: m_elements(other.m_elements),
m_data(other.m_data)
{
}
Cluster(
const Cluster& first,
const Cluster& second
) : m_elements(set_union(first.m_elements, second.m_elements)),
m_data(first.m_data)
{
}
void
merge(const Cluster& other)
{
// Merge the elements from the other cluster into this cluster
m_elements = set_union(m_elements, other.m_elements);
}
void
insert(const Var e)
{
m_elements.insert(e);
}
void
erase(const Var e)
{
m_elements.erase(e);
}
void
clear()
{
m_elements.clear();
}
bool
empty() const
{
return m_elements.empty();
}
Var
max() const
{
return m_elements.max();
}
Var
size() const
{
return m_elements.size();
}
const Set&
elements() const
{
return m_elements;
}
~Cluster()
{
}
public:
template <typename D, typename V, typename S>
friend
std::ostream&
operator<<(std::ostream&, const Cluster<D, V, S>&);
protected:
Set m_elements;
const Data& m_data;
}; // class Cluster
/**
* @brief Function for getting the output represention of a cluster.
*/
template <typename Data, typename Var, typename Set>
std::ostream&
operator<<(
std::ostream& stream,
const Cluster<Data, Var, Set>& cluster
)
{
stream << cluster.m_elements;
return stream;
}
#endif // DETAIL_CLUSTER_HPP_
|
f5e0c94d9b1d4fff4bc9965748862fb28551c330 | 329fe6e05705c9647edf55ca3fb7a0d4b6cb7992 | /class/Storage.hpp | 4217fe919ff88f37fdde7bd1e11bfd53e6abec56 | [] | no_license | Chelobanov/sonyara | 167b3e09e38fc7758d05091af5b52e6e1906f604 | 15fba8cea80ac8d6bc645853e6a581b17f6d097b | refs/heads/master | 2023-01-21T16:30:03.163193 | 2020-12-02T21:28:25 | 2020-12-02T21:28:25 | 317,993,057 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,360 | hpp | Storage.hpp | #pragma once
#include "List.hpp"
#include "GameObject.hpp"
#include <vector>
#include <string>
#include "Player.hpp"
#include "Enemy.hpp"
#include "Tile.hpp"
#include "Coin.hpp"
#include <fstream>
#include <iostream>
extern const float cell_side;
int Player::totalCoins;
int Player::coinsRemaining;
std::vector<std::string> split(const std::string& s)
{
std::vector<std::string> res;
typedef std::string::size_type string_size;
string_size i = 0;
while (i != s.size())
{
while (i != s.size() && isspace(s[i]))
++i;
string_size j = i;
while (j != s.size() && !isspace(s[j]))
j++;
if (i != j)
{
res.push_back(s.substr(i, j - i));
i = j;
}
}
return res;
}
class Storage
{
public:
List<GameObject> objects;
public:
Storage ()
{
objects = List<GameObject>();
}
// ~Storage ()
// {
// delete objects;
// }
GameObject* findByName(std::string name = std::string("player"))
{
for (int i = 1;; i++)
{
if (objects[i]->_name == name)
return objects[i];
}
}
void add(GameObject* pObject) // add layers later
{
objects.pushFront(pObject);
}
void createObject(std::vector<std::string> args)
{
if (args[0] == std::string("enemy"))
{
GameObject* pObject = new Enemy (sf::Vector2f(std::stof(args[1]), std::stof(args[2])), std::stof(args[3])
, sf::Vector2f(std::stof(args[4]), std::stof(args[5])) * cell_side
, sf::Vector2f(std::stof(args[6]), std::stof(args[7])) * cell_side);
this->add(pObject);
}
else if (args[0] == std::string("enemylinear"))
{
GameObject* pObject = new EnemyLinear (sf::Vector2f(std::stof(args[1]), std::stof(args[2])), std::stof(args[3])
, sf::Vector2f(std::stof(args[4]), std::stof(args[5])) * cell_side
, sf::Vector2f(std::stof(args[6]), std::stof(args[7])) * cell_side);
this->add(pObject);
}
else if (args[0] == std::string("enemycircular"))
{
GameObject* pObject = new EnemyCircular (sf::Vector2f(std::stof(args[1]), std::stof(args[2])), std::stof(args[3])
, sf::Vector2f(std::stof(args[4]), std::stof(args[5])) * cell_side
, sf::Vector2f(std::stof(args[6]), std::stof(args[7])) * cell_side);
this->add(pObject);
}
else if (args[0] == std::string("enemysquare"))
{
GameObject* pObject = new EnemySquare (sf::Vector2f(std::stof(args[1]), std::stof(args[2])), std::stof(args[3])
, sf::Vector2f(std::stof(args[4]), std::stof(args[5])) * cell_side
, sf::Vector2f(std::stof(args[6]), std::stof(args[7])) * cell_side);
this->add(pObject);
}
else if (args[0] == std::string("finish"))
{
GameObject* pObject = new FinishTile (sf::Vector2f(std::stof(args[1]), std::stof(args[2])));
this->add(pObject);
}
else if (args[0] == std::string("standard"))
{
GameObject* pObject = new StandardTile (sf::Vector2f(std::stof(args[1]), std::stof(args[2])));
this->add(pObject);
}
else if (args[0] == std::string("boundary"))
{
GameObject* pObject = new BoundaryTile (sf::Vector2f(std::stof(args[1]), std::stof(args[2])));
this->add(pObject);
}
else if (args[0] == std::string("coin"))
{
GameObject* pObject = new Coin (sf::Vector2f(std::stof(args[1]), std::stof(args[2])));
this->add(pObject);
}
else if (args[0] == std::string("player"))
{
GameObject* pObject = new Player (sf::Vector2f(std::stof(args[1]), std::stof(args[2]))
, sf::Color(stoi(args[3]), stoi(args[4]), stoi(args[5])));
this->add(pObject);
}
else if (args[0] == std::string("start"))
{
GameObject* pObject = new StartTile (sf::Vector2f(std::stof(args[1]), std::stof(args[2])));
this->add(pObject);
}
}
void load()
{
std::string path("saves/");
std::string filename;
std::cout << "Enter File Name: ";
std::cin >> filename;
path += filename;
std::vector<std::string> buffer;
std::ifstream file(path);
for (std::string line; getline(file, line);)
{
buffer = split(line);
this->createObject(buffer);
}
file.close();
}
void loadFromFile(std::string path)
{
std::vector<std::string> buffer;
std::ifstream file(path);
for (std::string line; getline(file, line);)
{
buffer = split(line);
this->createObject(buffer);
}
file.close();
Player::totalCoins = 0;
Player::coinsRemaining = 0;
for (int i = 1; i <= this->objects.len(); i++)
{
if (this->objects[i]->_name == std::string("coin"))
{
Player::totalCoins ++;
Player::coinsRemaining ++;
}
}
}
void clear()
{
objects.clear();
}
}; |
26c8f5d5bc5c4af002cbdfbe57394a112fdb974d | f96920731e7f38ab2acb983bd1919853bc74deba | /Firebrick/Lightning.cpp | b208db1bca850f49e1d2416a4bbb20892ce804e9 | [] | no_license | JackSmurthwaite/Firebrick | 6f50fe0e2290484628a77c916c5b05f45aa37d73 | 3d29810058c16d1b71e90f8a2202d77906df28df | refs/heads/master | 2020-09-06T10:16:13.153638 | 2019-11-08T06:07:23 | 2019-11-08T06:07:23 | 220,396,437 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,228 | cpp | Lightning.cpp | #include "stdafx.h"
#include "Game.h"
#include "Player.h"
#include "Card.h"
#include "Sword.h"
#include "Armour.h"
#include "Spell.h"
#include "Bless.h"
#include "Fireball.h"
#include "Lightning.h"
#include "Minion.h"
#include "Horde.h"
#include "Leech.h"
#include "Trample.h"
#include "Vampire.h"
#include "Wall.h"
#include <string>
#include <fstream>
#include <iostream>
#include <vector>
using namespace std;
CLightning::CLightning(int type, string name, int attack): CSpell(type, name, attack)
{
}
CLightning::~CLightning()
{
}
// Action when Lightning card is played
// Attack the enemy player and all their minions
// Friendly and enemy player are passed in
void CLightning::Action(CPlayer* friendly, CPlayer* enemy)
{
int startMinionCount = 0;
cout << mName << " attacks ";
enemy->PlayerTakeDamage(mAttack); // Attack the enemy player
if (enemy->GetHealth() > 0) // If the enemy player is alive
{
for (int i = 0; i < enemy->TableCount(); i++) // Go through all the enemy minions
{
startMinionCount = enemy->TableCount();
cout << mName << " attacks ";
enemy->MinionTakeDamage(mAttack, i); // Attack the minion
if (enemy->TableCount() < startMinionCount)
{
i--;
}
}
}
} |
d825a6888cf835f10f1531c098a0876e38cca596 | b175eddaf939281f164c2fbb39b55f85cfa90be0 | /Solutions/Godsend/cpp2.cpp | b1b62b0f351f029214085cf00bc49c323e080e2f | [] | no_license | AbdelrhmanKhater/Icons | 96b3f42504157c3089ceeb708b9b92ad89c18c88 | ea43233aab70b6b931efe76e349ee0684410a766 | refs/heads/master | 2020-03-07T01:31:54.176100 | 2018-03-28T19:17:12 | 2018-03-28T19:17:12 | 127,185,831 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 315 | cpp | cpp2.cpp | #include <iostream>
using namespace std;
int n;
long long num;
bool flag = true;
int main()
{
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> num;
if (num % 2)
flag = false;
}
if (flag)
cout << "Second\n";
else
cout << "First\n";
return 0;
} |
62840d91a764c337964cd5565212772c64120863 | 48b23a49c093e8303b90ed6335e61d64362e40af | /yashchenko-oleksandr/src/yashchenko03/Button.h | 656e69f68c83aa5cf7e9d35210a31bb2b7a29815 | [
"MIT"
] | permissive | zeienko-vitalii/se-cpp | e5b7d1d8800e2a5c777e76cc9cfd30d898400282 | 54a5dfb2e98af099fbfaef129a7fe03a7b815d6f | refs/heads/master | 2021-08-15T15:22:30.559011 | 2017-11-17T22:37:45 | 2017-11-17T22:37:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,286 | h | Button.h | /**
* @file Button.h
* Declaration of class Button.
* @author Ященко Олександр
* @version 0.0.1
* @date 2017.10.20
*/
#ifndef BUTTON_H_
#define BUTTON_H_
#include "Window.h"
/**
* Stores information about button.
*/
class Button: public Window {
public:
/**
* Constructor.
*/
Button();
/**
* Constructor with parameters.
* @param aId sets Button::iId
* @param aX1 sets Button::iX1
* @param aY1 sets Button::iY1
* @param aX2 sets Button::iX2
* @param aY2 sets Button::iY2
* @param aTitle sets Button::iTitle
* @param aBorderColor sets Button::iBorderColor
*/
Button(int aId, int aX1, int aY1, int aX2, int aY2, char * aTitle,
char * aBorderColor);
/**
* Destructor.
*/
~Button();
private:
char iTitle[32]; ///< Text of button title
char iBorderColor[32]; ///< Color of button border
public:
/**
* Returns Button::iTitle.
* @return pointer to text of button title
*/
const char* getTitle() const;
/**
* Returns Button::iBorderColor.
* @return pointer to text of color of border of button
*/
const char* getBorderColor() const;
/**
* Sets Button::iTitle.
*/
void setTitle(char * aTitle);
/**
* Sets Button::iBorderColor.
*/
void setBorderColor(char * aBorderColor);
};
#endif /* BUTTON_H_ */
|
9e6fa0ee4f1c3c51b1aa504012bd90bb5a8d215d | 56abe8809cde2e59003ce4fbefc25f4271e53b68 | /Waffle/Vector.cpp | 790228e4c3042d0e7f4a8aa9f83c16bd7deeb2bd | [
"MIT"
] | permissive | Ownfos/Waffle | cfd6f3e2e1f211df768441c0335b7328520a455a | a4683a4cc5b3de3546aa9e708fe4a25849f9f0a8 | refs/heads/master | 2021-01-02T05:26:04.618888 | 2020-04-10T13:52:20 | 2020-04-10T13:52:20 | 239,507,939 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,080 | cpp | Vector.cpp | #include "Vector.h"
#include "Transform.h"
using namespace DirectX;
namespace waffle
{
Vector::Vector(float x, float y, float z)
: data(XMVectorSet(x, y, z, 0.0f))
{
}
Vector::Vector(XMVECTOR data)
: data(data)
{
}
Vector Vector::operator+(const Vector& other) const
{
return XMVectorAdd(data, other.data);
}
Vector Vector::operator-(const Vector& other) const
{
return XMVectorSubtract(data, other.data);
}
float Vector::operator*(const Vector& other) const
{
return XMVectorGetX(XMVector3Dot(data, other.data));
}
Vector Vector::operator^(const Vector& other) const
{
return XMVector3Cross(data, other.data);
}
Vector Vector::operator*(const Transform& transform) const
{
return XMVector3TransformCoord(data, transform.Data());
}
XMVECTOR Vector::Data() const
{
return data;
}
float Vector::Length() const
{
return XMVectorGetX(XMVector3Length(data));
}
float Vector::LengthSquare() const
{
return XMVectorGetX(XMVector3LengthSq(data));
}
Vector Vector::Normalized() const
{
return XMVector3Normalize(data);
}
} |
2b254f17ed10185f7749c0c7975591824e9f1f7c | bbeaadef08cccb872c9a1bb32ebac7335d196318 | /Fontes/InfoZcc/TInfoZccManager.h | e84c688c21d66637aa13996bd370859f63befd7c | [] | no_license | danilodesouzapereira/plataformasinap_exportaopendss | d0e529b493f280aefe91b37e893359a373557ef8 | c624e9e078dce4b9bcc8e5b03dd4d9ea71c29b3f | refs/heads/master | 2023-03-20T20:37:21.948550 | 2021-03-12T17:53:12 | 2021-03-12T17:53:12 | 347,150,304 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 906 | h | TInfoZccManager.h | // ---------------------------------------------------------------------------
#ifndef TInfoZccManagerH
#define TInfoZccManagerH
// arquivos incluídos-----------------------------------------------------------
#include <Classes.hpp>
#include "VTInfoZccManager.h"
// ---------------------------------------------------------------------------
class VTApl;
// ---------------------------------------------------------------------------
class TInfoZccManager : public VTInfoZccManager
{
public:
__fastcall TInfoZccManager(VTApl *apl);
__fastcall ~TInfoZccManager(void);
private:
strInfoZcc* __fastcall ExisteInfoZcc(int externIdRede);
strInfoZcc* __fastcall InsereInfoZcc(void);
bool __fastcall LeInfoZcc(void);
bool __fastcall SalvaInfoZcc(void);
public:
TList *lisINFOZCC;
private:
VTApl *apl;
};
#endif
// ---------------------------------------------------------------------------
// eof
|
aa47c9283db2c7cb5f5fc23966247dbb45d8c378 | d8dc50936a8ca5b1a222230b12d1afe9cd34d918 | /2016/Abandoned/C-Simplified/SSMAInterpreter/main.cpp | 3d10efadbe1ee7de8ad1af47d74369091a9ab4fa | [] | no_license | daiyousei-qz/Archive | d593dd9c86575e791670fa583e5a8da98c6cfa4d | 367ea433f897a13fadfec928ff4b7eeec491dce9 | refs/heads/master | 2022-05-10T02:04:22.293626 | 2018-10-09T09:19:06 | 2018-10-09T09:19:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 647 | cpp | main.cpp | #include "ssm_basic.h"
#include "ssm_vm.h"
int main()
{
uint8_t test[] = {
43, 114, 0, 0, 0, 0, 24, 3, 28, 22, 3, 3, 42, 25, 0, 21, 3, 28, 29, 43, 6, 0, 0, 0,
24, 3, 27, 21, 3, 29, 43, 6, 0, 0, 0, 24, 3, 2, 29, 44, 26, 21, 29, 44, 0, 22, 3,
24, 3, 3, 42, 3, 0, 21, 29, 44, 36, 8, 0, 21, 28, 24, 1, 32, 25, 1, 4, 0, 32, 24,
3, 22, 3, 3, 28, 42, 27, 0, 24, 1, 35, 25, 1, 4, 0, 35, 2, 25, 1, 4, 0, 35, 24, 1,
32, 25, 1, 4, 0, 32, 21, 3, 40, 225, 255, 26, 25, 1, 4, 0, 35, 29, 44, 0,
22, 10, 29, 43, 45, 0, 0, 0, 24, 3, 26, 44
};
auto module = SSMModule(test, 0);
auto vm = SSMVirtualMachine::Create(module);
vm->Run();
return 0;
} |
2a06e933a389c411691b03b191910d9d3b1e357f | 2d361696ad060b82065ee116685aa4bb93d0b701 | /include/gui/widgets/macro_edit/edit_macro_dlg.hpp | 32e3da54fdcaf15f825f19a0be41f8466d49ea0f | [
"LicenseRef-scancode-public-domain"
] | permissive | AaronNGray/GenomeWorkbench | 5151714257ce73bdfb57aec47ea3c02f941602e0 | 7156b83ec589e0de8f7b0a85699d2a657f3e1c47 | refs/heads/master | 2022-11-16T12:45:40.377330 | 2020-07-10T00:54:19 | 2020-07-10T00:54:19 | 278,501,064 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 5,243 | hpp | edit_macro_dlg.hpp | #ifndef GUI_WIDGETS_MACRO_EDIT___MACRO_EDIT_DLG__HPP
#define GUI_WIDGETS_MACRO_EDIT___MACRO_EDIT_DLG__HPP
/* $Id: edit_macro_dlg.hpp 44983 2020-05-01 15:28:14Z asztalos $
* ===========================================================================
*
* 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.
*
* ===========================================================================
*
* Authors: Roman Katargin, Anatoly Osipov
*/
#include <corelib/ncbistd.hpp>
#include <gui/gui_export.h>
#include <objmgr/seq_entry_handle.hpp>
#include <gui/widgets/wx/dialog.hpp>
#include <gui/objutils/macro_engine.hpp>
class wxTextCtrl;
class wxListBox;
/*!
* Control identifiers
*/
////@begin control identifiers
#define SYMBOL_CEDITMACRODLG_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL
#define SYMBOL_CEDITMACRODLG_TITLE _("Run Macro")
#define SYMBOL_CEDITMACRODLG_IDNAME ID_CEDITMACRODLG
#define SYMBOL_CEDITMACRODLG_SIZE wxDefaultSize
#define SYMBOL_CEDITMACRODLG_POSITION wxDefaultPosition
////@end control identifiers
BEGIN_NCBI_SCOPE
BEGIN_SCOPE(macro)
class CMacroDataException;
END_SCOPE(macro)
/*!
* CEditMacroDlg class declaration
*/
class NCBI_GUIWIDGETS_MACRO_EDIT_EXPORT CEditMacroDlg: public CDialog
{
DECLARE_DYNAMIC_CLASS( CEditMacroDlg )
DECLARE_EVENT_TABLE()
public:
/// Constructors
CEditMacroDlg();
CEditMacroDlg( wxWindow* parent,
wxWindowID id = SYMBOL_CEDITMACRODLG_IDNAME,
const wxString& caption = SYMBOL_CEDITMACRODLG_TITLE,
const wxPoint& pos = SYMBOL_CEDITMACRODLG_POSITION,
const wxSize& size = SYMBOL_CEDITMACRODLG_SIZE,
long style = SYMBOL_CEDITMACRODLG_STYLE );
void SetParams(objects::CSeq_entry_Handle TopSeqEntry, CConstRef<objects::CSeq_submit> submit, ICommandProccessor* CmdProccessor)
{
m_TopSeqEntry = TopSeqEntry;
m_SeqSubmit = submit;
m_CmdProccessor = CmdProccessor;
}
/// Creation
bool Create( wxWindow* parent,
wxWindowID id = SYMBOL_CEDITMACRODLG_IDNAME,
const wxString& caption = SYMBOL_CEDITMACRODLG_TITLE,
const wxPoint& pos = SYMBOL_CEDITMACRODLG_POSITION,
const wxSize& size = SYMBOL_CEDITMACRODLG_SIZE,
long style = SYMBOL_CEDITMACRODLG_STYLE );
/// Destructor
~CEditMacroDlg();
/// Initialises member variables
void Init();
/// Creates the controls and sizers
void CreateControls();
////@begin CEditMacroDlg event handler declarations
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON
void OnRunClick( wxCommandEvent& event );
void OnPrintClick(wxCommandEvent& event);
void OnPrintParallelClick(wxCommandEvent& event);
void OnListItemSelected( wxCommandEvent& event);
void LoadAutofix_GB( wxCommandEvent& event );
void LoadAutofix_TSA(wxCommandEvent& event);
void LoadAutofix_WGS( wxCommandEvent& event );
void LoadOtherMacros( wxCommandEvent& event );
////@end CEditMacroDlg event handler declarations
////@begin CEditMacroDlg member function declarations
/// Retrieves bitmap resources
wxBitmap GetBitmapResource( const wxString& name );
/// Retrieves icon resources
wxIcon GetIconResource( const wxString& name );
////@end CEditMacroDlg member function declarations
/// Should we show tooltips?
static bool ShowToolTips();
////@begin CEditMacroDlg member variables
wxTextCtrl* m_TextCtrl;
wxListBox* m_MacroList;
/// Control identifiers
enum {
ID_CEDITMACRODLG = wxID_HIGHEST + 100,
ID_LISTBOX,
ID_TEXTCTRL,
ID_RUN,
ID_PRINT,
ID_PRINTPARALLEL,
ID_AUTOFIXGB,
ID_AUTOFIXTSA,
ID_AUTOFIXWGS,
ID_OTHERMACROS
};
////@end CEditMacroDlg member variables
private:
void x_LoadMacroNames();
void x_LoadAutofixMacro(const string& name);
objects::CSeq_entry_Handle m_TopSeqEntry;
CConstRef<objects::CSeq_submit> m_SeqSubmit;
ICommandProccessor* m_CmdProccessor;
vector<string> m_Macros;
};
END_NCBI_SCOPE
#endif // GUI_WIDGETS_MACRO_EDIT___MACRO_EDIT_DLG__HPP
|
b7430ab4b4003aa59ead3e3f279c9239b0dccce4 | 2cfb31bf995318540bd1a7b6e19eb8b12cb8acd9 | /Codeforces/289B.cpp | 9d1a5a63e645203dd143bcfdbae3acff78f1d8fc | [] | no_license | aurko96/Competitive-Programming | cf6265456450355e04c34acf9b7500b1cc30fd58 | 7b5a22d077f29145b92caef0883734ca40096227 | refs/heads/master | 2020-03-18T15:08:14.533253 | 2018-05-25T19:07:25 | 2018-05-25T19:07:25 | 134,889,195 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 989 | cpp | 289B.cpp | #include<bits/stdc++.h>
using namespace std;
int x,d,ara[100000];
int calc(int index)
{
int val=ara[index];
int sum=0;
for(int i=0;i<x;i++)
{
int diff=abs(ara[i]-ara[index]);
sum+=diff;
}
sum/=d;
return sum;
}
int main()
{
int n,m;
cin>>n>>m>>d;
x=n*m;
bool flag=0;
for(int i=0;i<x;i++)
{
cin>>ara[i];
if(i!=0)
{
if((ara[0]-ara[i])%d!=0) flag=1;
}
}
if(flag){ cout<<-1; return 0;}
sort(ara,ara+x);
int low=0,high=x-1,diff,mid1,mid2,ans;
while(low+3<=high)
{
diff=(high-low)/3;
mid1=low+diff;
mid2=mid1+diff;
int x,y;
x=calc(mid1);
y=calc(mid2);
if(x<y)
{
ans=x;
high=mid2;
}
else if(x>y)
{
ans=y;
low=mid1;
}
else
{
ans=x;
break;
}
}
cout<<ans<<endl;
}
|
a0483df1b792b6795dca904f6ec1446bb98bdfcf | a724a2ad20e2afdb1520a98f0e18f83fc5761063 | /programs/lapindromes.cpp | 4eed7de2449b35941fb497d44586ede3d42000ee | [] | no_license | akagra/Algorithm | 235a158432877fd211c9aff711f9d9fa8cac36b7 | 32daa275c0008dacddc5efa9ca792a185ab79b29 | refs/heads/master | 2023-02-07T08:28:19.657084 | 2021-01-03T09:06:08 | 2021-01-03T09:06:08 | 326,353,855 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,167 | cpp | lapindromes.cpp | # include<bits/stdc++.h>
using namespace std;
int lapindrome(string str) {
int alpha[26],count,count2 = 0,temp,index,freq1[26],freq2[26];
for(int i = 0;i<26;i++) {
alpha[i] = 0;
freq1[i] = 0;
freq2[i] = 0;
}
if(str.length()%2 == 0) {
count = (str.length())/2;
}
else {
count = (str.length()-1)/2;
}
if(str.length()%2==0) {
temp = count + 1;
}
else {
temp = count + 2;
}
for(int i = 0;i<count;i++) {
index = str[i] - 'a';
freq1[index]++;
alpha[index] = 1;
}
for(int i =temp-1;i<=str.length();i++) {
index = str[i] - 'a';
freq2[index]++;
alpha[index] = 1;
}
for(int i = 0;i<26;i++) {
if(alpha[i] == 1){
count2++;
//cout<<count2;
}
}
//cout<<count2<<endl;
if(count2 != count){
return 0;
}
else {
for(int i =0;i<26;i++) {
if(freq1[i] != freq2[i]) {
return 0;
}
}
}
return 1;
}
int main() {
int T;
cin>>T;
// fflush(stdin);
while(T>0) {
string str;
int T2;
getline(cin,str);
T2 =lapindrome(str);
if(T2 == 1) {
cout<<"YES"<<endl;
}
else if(T2 == 0){
cout<<"NO"<<endl;
}
T--;
}
return 0;
}
|
a63fbcaf1b541fa2e59d9b4de62523acb1e868da | fadfe3ba0601045349093941dd0720dda8c99318 | /native-imagetranscoder/src/main/jni/native-imagetranscoder/jpeg/crypto/jpeg_decrypt.cpp | 6c219b286bb4bc8c5b14ae6ce9d97aefe14545d9 | [
"MIT"
] | permissive | columbia/fresco | fced850aa72edca638e79ad2c2bbe9cc7e6c9fdf | efd379d38db321fd5deddd48805247890ec076f5 | refs/heads/master | 2021-06-24T09:11:59.981196 | 2021-05-17T18:16:42 | 2021-05-17T18:16:42 | 225,449,030 | 0 | 0 | null | 2019-12-02T19:08:49 | 2019-12-02T19:08:48 | null | UTF-8 | C++ | false | false | 27,493 | cpp | jpeg_decrypt.cpp | #include <algorithm>
#include <iterator>
#include <random>
#include <stdio.h>
#include <setjmp.h>
#include <math.h>
#include <jni.h>
#include <jpeglib.h>
extern "C" {
#include "transupp.h"
}
#include <gmp.h>
#include "decoded_image.h"
#include "exceptions_handler.h"
#include "logging.h"
#include "jpeg/jpeg_error_handler.h"
#include "jpeg/jpeg_memory_io.h"
#include "jpeg/jpeg_stream_wrappers.h"
#include "jpeg/jpeg_codec.h"
#include "jpeg_crypto.h"
#include "jpeg_decrypt.h"
namespace facebook {
namespace imagepipeline {
namespace jpeg {
namespace crypto {
struct chaos_pos_jcoefptr {
unsigned int chaos_pos;
JCOEFPTR dcts;
JCOEF dc;
};
struct chaos_pos_jblockrow {
unsigned int chaos_pos;
JBLOCKROW row;
};
static void decryptByRow(
j_decompress_ptr dinfo,
jvirt_barray_ptr* src_coefs,
mpf_t x_0,
mpf_t mu) {
// Iterate over every DCT coefficient in the image, for every color component
for (int comp_i = 0; comp_i < dinfo->num_components; comp_i++) {
jpeg_component_info *comp_info = dinfo->comp_info + comp_i;
struct chaos_dc *chaotic_seq;
unsigned int width = comp_info->width_in_blocks;
unsigned int n_blocks = comp_info->width_in_blocks * comp_info->height_in_blocks;
chaotic_seq = (struct chaos_dc *) malloc(n_blocks * sizeof(struct chaos_dc));
if (chaotic_seq == NULL) {
LOGE("decryptByRow failed to alloc memory for chaotic_seq");
return;
}
gen_chaotic_per_row(chaotic_seq, width, comp_info->height_in_blocks, x_0, mu);
LOGD("decryptByRow iterating over image component %d (comp_info->height_in_blocks=%d)", comp_i, comp_info->height_in_blocks);
for (int y = 0; y < comp_info->height_in_blocks; y++) {
struct chaos_pos_jcoefptr *chaos_op;
JBLOCKARRAY mcu_buff; // Pointer to list of horizontal 8x8 blocks
mcu_buff = (dinfo->mem->access_virt_barray)((j_common_ptr) dinfo, src_coefs[comp_i], y, (JDIMENSION) 1, TRUE);
// Shuffle pointers to MCUs based on chaotic sequence
chaos_op = (struct chaos_pos_jcoefptr *) malloc(comp_info->width_in_blocks * sizeof(struct chaos_pos_jcoefptr));
if (chaos_op == NULL) {
LOGE("decryptByRow failed to alloc memory for chaos_op");
goto end_loop;
}
for (int i = 0; i < comp_info->width_in_blocks; i++) {
JCOEFPTR dct_block = mcu_buff[0][i];
JCOEFPTR dct_copy = (JCOEFPTR) malloc(DCTSIZE2 * sizeof(JCOEF));
if (dct_copy == NULL) {
LOGE("decryptByRow failed to alloc memory for dct_copy");
goto end_loop;
}
std::copy(dct_block, dct_block + DCTSIZE2, dct_copy);
chaos_op[i].dcts = dct_copy;
chaos_op[i].chaos_pos = chaotic_seq[y * width + i].chaos_pos;
}
for (int i = 0; i < comp_info->width_in_blocks; i++) {
unsigned int dest_pos = chaos_op[i].chaos_pos;
JCOEFPTR dct_block = mcu_buff[0][i];
std::copy(chaos_op[dest_pos].dcts, chaos_op[dest_pos].dcts + DCTSIZE2, dct_block);
}
LOGD("decryptByRow finished swap for component %d", comp_i);
end_loop:
if (chaos_op != NULL) {
for (int i = 0; i < comp_info->width_in_blocks; i++) {
if (chaos_op[i].dcts != NULL)
free(chaos_op[i].dcts);
}
free(chaos_op);
}
}
for (int i; i < n_blocks; i++) {
mpf_clear(chaotic_seq[i].chaos_gmp);
}
free(chaotic_seq);
}
}
static void decryptByColumn(
j_decompress_ptr dinfo,
jvirt_barray_ptr* src_coefs,
mpf_t x_n,
mpf_t mu_n) {
for (int comp_i = 0; comp_i < dinfo->num_components; comp_i++) {
jpeg_component_info *comp_info = dinfo->comp_info + comp_i;
struct chaos_dc *chaotic_seq;
struct chaos_pos_jblockrow *chaos_op;
unsigned int chaos_len = comp_info->height_in_blocks;
LOGD("decryptByColumn iterating over image component %d (comp_info->height_in_blocks=%d)", comp_i, comp_info->height_in_blocks);
chaotic_seq = (struct chaos_dc *) malloc(chaos_len * sizeof(struct chaos_dc));
if (chaotic_seq == NULL) {
LOGE("decryptByColumn failed to alloc memory for chaotic_seq");
return;
}
chaos_op = (struct chaos_pos_jblockrow *) malloc(chaos_len * sizeof(struct chaos_pos_jblockrow));
if (chaos_op == NULL) {
LOGE("decryptByColumn failed to alloc memory for chaos_op");
goto end_loop;
}
gen_chaotic_sequence(chaotic_seq, chaos_len, x_n, mu_n);
for (int y = 0; y < comp_info->height_in_blocks; y++) {
JBLOCKROW row;
JBLOCKROW row_copy;
row = (dinfo->mem->access_virt_barray)((j_common_ptr) dinfo, src_coefs[comp_i], y, (JDIMENSION) 1, TRUE)[0];
row_copy = (JBLOCKROW) malloc(comp_info->width_in_blocks * sizeof(JBLOCK));
if (row_copy == NULL) {
LOGE("decryptByColumn failed to alloc memory for row_copy");
goto end_loop;
}
// Copy each block in this row
for (int i = 0; i < comp_info->width_in_blocks; i++) {
std::copy(row[i], row[i] + DCTSIZE2, row_copy[i]);
}
chaos_op[y].row = row_copy;
chaos_op[y].chaos_pos = chaotic_seq[y].chaos_pos;
}
for (int y = 0; y < comp_info->height_in_blocks; y++) {
unsigned int dest_pos = chaos_op[y].chaos_pos;
JBLOCKROW row;
row = (dinfo->mem->access_virt_barray)((j_common_ptr) dinfo, src_coefs[comp_i], y, (JDIMENSION) 1, TRUE)[0];
// Copy each block to their correct row y
for (int i = 0; i < comp_info->width_in_blocks; i++) {
std::copy(chaos_op[dest_pos].row[i], chaos_op[dest_pos].row[i] + DCTSIZE2, row[i]);
}
}
LOGD("decryptByColumn finished swap for component %d", comp_i);
end_loop:
for (int i = 0; i < comp_info->height_in_blocks; i++) {
if (chaos_op != NULL && chaos_op[i].row != NULL)
free(chaos_op[i].row);
}
free(chaos_op);
for (int i; i < chaos_len; i++) {
mpf_clear(chaotic_seq[i].chaos_gmp);
}
free(chaotic_seq);
}
}
static void decryptDCs(
j_decompress_ptr dinfo,
jvirt_barray_ptr* src_coefs,
mpf_t x_0,
mpf_t mu) {
// Iterate over every DCT coefficient in the image, for every color component
for (int comp_i = 0; comp_i < dinfo->num_components; comp_i++) {
jpeg_component_info *comp_info = dinfo->comp_info + comp_i;
struct chaos_dc *chaotic_seq;
unsigned int width = comp_info->width_in_blocks;
unsigned int height = comp_info->height_in_blocks;
unsigned int n_blocks = width * height;
struct chaos_pos_jcoefptr *chaos_op;
int block_i = 0;
chaotic_seq = (struct chaos_dc *) malloc(n_blocks * sizeof(struct chaos_dc));
if (chaotic_seq == NULL) {
LOGE("decryptDCs failed to alloc memory for chaotic_seq");
return;
}
gen_chaotic_sequence(chaotic_seq, n_blocks, x_0, mu);
LOGD("decryptDCs iterating over image component %d (comp_info->height_in_blocks=%d)", comp_i, comp_info->height_in_blocks);
chaos_op = (struct chaos_pos_jcoefptr *) malloc(n_blocks * sizeof(struct chaos_pos_jcoefptr));
if (chaos_op == NULL) {
LOGE("decryptDCs failed to alloc memory for chaos_op");
goto end_loop;
}
for (int y = 0; y < height; y++) {
JBLOCKARRAY mcu_buff;
mcu_buff = (dinfo->mem->access_virt_barray)((j_common_ptr) dinfo, src_coefs[comp_i], y, (JDIMENSION) 1, TRUE);
for (int x = 0; x < width; x++) {
chaos_op[block_i].dc = mcu_buff[0][x][0];
chaos_op[block_i].chaos_pos = chaotic_seq[block_i].chaos_pos;
block_i++;
}
}
block_i = 0;
for (int y = 0; y < height; y++) {
JBLOCKARRAY mcu_buff;
mcu_buff = (dinfo->mem->access_virt_barray)((j_common_ptr) dinfo, src_coefs[comp_i], y, (JDIMENSION) 1, TRUE);
for (int x = 0; x < width; x++) {
unsigned int dest_pos = chaos_op[block_i].chaos_pos;
mcu_buff[0][x][0] = chaos_op[dest_pos].dc;
if (chaotic_seq[dest_pos].flip_sign)
mcu_buff[0][x][0] *= -1;
block_i++;
}
LOGD("decryptDCs finished swap for component %d", comp_i);
}
end_loop:
if (chaos_op != NULL) {
free(chaos_op);
}
for (int i; i < n_blocks; i++) {
mpf_clear(chaotic_seq[i].chaos_gmp);
}
free(chaotic_seq);
}
}
static void decryptMCUs(
j_decompress_ptr dinfo,
jvirt_barray_ptr* src_coefs,
mpf_t x_0,
mpf_t mu) {
// Iterate over every DCT coefficient in the image, for every color component
for (int comp_i = 0; comp_i < dinfo->num_components; comp_i++) {
jpeg_component_info *comp_info = dinfo->comp_info + comp_i;
struct chaos_dc *chaotic_seq;
unsigned int width = comp_info->width_in_blocks;
unsigned int height = comp_info->height_in_blocks;
unsigned int n_blocks = width * height;
struct chaos_pos_jcoefptr *chaos_op;
int block_i = 0;
chaotic_seq = (struct chaos_dc *) malloc(n_blocks * sizeof(struct chaos_dc));
if (chaotic_seq == NULL) {
LOGE("decryptDCsACsMCUs failed to alloc memory for chaotic_seq");
return;
}
gen_chaotic_sequence(chaotic_seq, n_blocks, x_0, mu);
LOGD("decryptDCsACsMCUs iterating over image component %d (comp_info->height_in_blocks=%d)", comp_i, comp_info->height_in_blocks);
chaos_op = (struct chaos_pos_jcoefptr *) malloc(n_blocks * sizeof(struct chaos_pos_jcoefptr));
if (chaos_op == NULL) {
LOGE("decryptDCsACsMCUs failed to alloc memory for chaos_op");
goto end_loop;
}
for (int y = 0; y < height; y++) {
JBLOCKARRAY mcu_buff;
mcu_buff = (dinfo->mem->access_virt_barray)((j_common_ptr) dinfo, src_coefs[comp_i], y, (JDIMENSION) 1, TRUE);
for (int x = 0; x < width; x++) {
JCOEFPTR dct_block = mcu_buff[0][x];
JCOEFPTR dct_copy = (JCOEFPTR) malloc(DCTSIZE2 * sizeof(JCOEF));
if (dct_copy == NULL) {
LOGE("decryptDCsACsMCUs failed to alloc memory for dct_copy");
goto end_loop;
}
std::copy(dct_block, dct_block + DCTSIZE2, dct_copy);
chaos_op[block_i].dcts = dct_copy;
chaos_op[block_i].chaos_pos = chaotic_seq[block_i].chaos_pos;
block_i++;
}
}
block_i = 0;
for (int y = 0; y < height; y++) {
JBLOCKARRAY mcu_buff;
mcu_buff = (dinfo->mem->access_virt_barray)((j_common_ptr) dinfo, src_coefs[comp_i], y, (JDIMENSION) 1, TRUE);
for (int x = 0; x < width; x++) {
unsigned int dest_pos = chaos_op[block_i].chaos_pos;
JCOEFPTR dct_block = mcu_buff[0][x];
//std::copy(chaos_op[dest_pos].dcts, chaos_op[dest_pos].dcts + DCTSIZE2, dct_block);
// Skip the DC coefficient
for (int i = 1; i < DCTSIZE2; i++) {
dct_block[i] = chaos_op[dest_pos].dcts[i];
}
block_i++;
}
LOGD("decryptDCsACsMCUs finished swap for component %d", comp_i);
}
end_loop:
if (chaos_op != NULL) {
for (int i = 0; i < n_blocks; i++) {
if (chaos_op[i].dcts != NULL)
free(chaos_op[i].dcts);
}
free(chaos_op);
}
for (int i; i < n_blocks; i++) {
mpf_clear(chaotic_seq[i].chaos_gmp);
}
free(chaotic_seq);
}
}
static void decryptAllACs(
j_decompress_ptr dinfo,
jvirt_barray_ptr* src_coefs,
mpf_t x_0,
mpf_t mu) {
for (int comp_i = 0; comp_i < dinfo->num_components; comp_i++) {
jpeg_component_info *comp_info = dinfo->comp_info + comp_i;
unsigned int width = comp_info->width_in_blocks;
unsigned int height = comp_info->height_in_blocks;
mpf_t last_xn;
struct chaos_dc *chaotic_seq;
unsigned int n_coefficients = DCTSIZE2 - 1;
chaotic_seq = (struct chaos_dc *) malloc(n_coefficients * sizeof(struct chaos_dc));
if (chaotic_seq == NULL) {
LOGE("permuteACs failed to alloc memory for chaotic_seq");
return;
}
mpf_init(last_xn);
LOGD("permuteACs iterating over image component %d (comp_info->height_in_blocks=%d)", comp_i, comp_info->height_in_blocks);
for (int y = 0; y < comp_info->height_in_blocks; y++) {
JBLOCKARRAY mcu_buff; // Pointer to list of horizontal 8x8 blocks
JCOEF ac_coef[DCTSIZE2];
// mcu_buff[y][x][c]
// - the cth coefficient
// - the xth horizontal block
// - the yth vertical block
mcu_buff = (dinfo->mem->access_virt_barray)((j_common_ptr)dinfo, src_coefs[comp_i], y, (JDIMENSION) 1, TRUE);
for (int x = 0; x < comp_info->width_in_blocks; x++) {
JCOEFPTR mcu_ptr; // Pointer to 8x8 block of coefficients (I think)
if (y == 0 && x == 0)
gen_chaotic_sequence(chaotic_seq, n_coefficients, x_0, mu, false);
else
gen_chaotic_sequence(chaotic_seq, n_coefficients, last_xn, mu, false);
mpf_set(last_xn, chaotic_seq[n_coefficients - 1].chaos_gmp);
std::sort(chaotic_seq, chaotic_seq + n_coefficients, &chaos_gmp_sorter);
mcu_ptr = mcu_buff[0][x];
for (int i = 0; i < n_coefficients; i++) {
ac_coef[i] = mcu_ptr[i + 1];
}
for (int i = 0; i < n_coefficients; i++) {
mcu_ptr[i + 1] = ac_coef[chaotic_seq[i].chaos_pos];
}
for (int i; i < n_coefficients; i++)
mpf_clear(chaotic_seq[i].chaos_gmp);
}
}
end_row:
free(chaotic_seq);
mpf_clear(last_xn);
}
}
static void decryptNonZeroACs(
j_decompress_ptr dinfo,
jvirt_barray_ptr* src_coefs,
mpf_t x_0,
mpf_t mu) {
for (int comp_i = 0; comp_i < dinfo->num_components; comp_i++) {
jpeg_component_info *comp_info = dinfo->comp_info + comp_i;
unsigned int width = comp_info->width_in_blocks;
unsigned int height = comp_info->height_in_blocks;
mpf_t last_xn;
struct chaos_dc *chaotic_seq;
chaotic_seq = (struct chaos_dc *) malloc(DCTSIZE2 * sizeof(struct chaos_dc));
if (chaotic_seq == NULL) {
LOGE("decryptNonZeroACs failed to alloc memory for chaotic_seq");
return;
}
mpf_init(last_xn);
LOGD("decryptNonZeroACs iterating over image component %d (comp_info->height_in_blocks=%d)", comp_i, comp_info->height_in_blocks);
for (int y = 0; y < comp_info->height_in_blocks; y++) {
JBLOCKARRAY mcu_buff; // Pointer to list of horizontal 8x8 blocks
// mcu_buff[y][x][c]
// - the cth coefficient
// - the xth horizontal block
// - the yth vertical block
mcu_buff = (dinfo->mem->access_virt_barray)((j_common_ptr)dinfo, src_coefs[comp_i], y, (JDIMENSION) 1, TRUE);
for (int x = 0; x < comp_info->width_in_blocks; x++) {
JCOEFPTR mcu_ptr; // Pointer to 8x8 block of coefficients
JCOEF ac_coef[DCTSIZE2];
int non_zero_idx[DCTSIZE2];
int non_zero_count = 0;
int processed = 0;
mcu_ptr = mcu_buff[0][x];
for (int i = 1; i < DCTSIZE2; i++) {
ac_coef[i] = mcu_ptr[i];
if (mcu_ptr[i] == 0)
continue;
non_zero_idx[non_zero_count] = i;
non_zero_count++;
}
if (y == 0 && x == 0)
gen_chaotic_sequence(chaotic_seq, non_zero_count, x_0, mu, false);
else
gen_chaotic_sequence(chaotic_seq, non_zero_count, last_xn, mu, false);
mpf_set(last_xn, chaotic_seq[non_zero_count - 1].chaos_gmp);
std::sort(chaotic_seq, chaotic_seq + non_zero_count, &chaos_gmp_sorter);
for (int i = 1; i < DCTSIZE2; i++) {
if (ac_coef[i] == 0)
continue;
mcu_ptr[i] = ac_coef[non_zero_idx[chaotic_seq[processed].chaos_pos]];
processed++;
}
// Clean up
for (int i; i < non_zero_count; i++)
mpf_clear(chaotic_seq[i].chaos_gmp);
}
}
end_row:
free(chaotic_seq);
mpf_clear(last_xn);
}
}
void decryptJpeg(
JNIEnv *env,
jobject is,
jobject os,
jstring x_0_jstr,
jstring mu_jstr) {
JpegInputStreamWrapper is_wrapper{env, is};
JpegOutputStreamWrapper os_wrapper{env, os};
JpegErrorHandler error_handler{env};
struct jpeg_source_mgr& source = is_wrapper.public_fields;
struct jpeg_destination_mgr& destination = os_wrapper.public_fields;
mpf_t x_0;
mpf_t mu;
mpf_t alpha;
mpf_t beta;
jsize x_0_len = env->GetStringUTFLength(x_0_jstr);
jsize mu_len = env->GetStringUTFLength(mu_jstr);
const char *x_0_char = env->GetStringUTFChars(x_0_jstr, (jboolean *) 0);
const char *mu_char = env->GetStringUTFChars(mu_jstr, (jboolean *) 0);
if (setjmp(error_handler.setjmpBuffer)) {
return;
}
// prepare decompress struct
struct jpeg_decompress_struct dinfo;
initDecompressStruct(dinfo, error_handler, source);
// create compress struct
struct jpeg_compress_struct cinfo;
initCompressStruct(cinfo, dinfo, error_handler, destination);
// get DCT coefficients, 64 for 8x8 DCT blocks (first is DC, remaining 63 are AC?)
jvirt_barray_ptr *src_coefs = jpeg_read_coefficients(&dinfo);
// initialize with default params, then copy the ones needed for lossless transcoding
jpeg_copy_critical_parameters(&dinfo, &cinfo);
jcopy_markers_execute(&dinfo, &cinfo, JCOPYOPT_ALL);
if (mpf_init_set_str(x_0, x_0_char, 10)) {
LOGD("decryptJpeg failed to mpf_set_str(x_0)");
goto teardown;
}
if (mpf_init_set_str(mu, mu_char, 10)) {
LOGD("decryptJpeg failed to mpf_set_str(mu)");
goto teardown;
}
mpf_inits(alpha, beta, NULL);
decryptMCUs(&dinfo, src_coefs, x_0, mu);
//decryptNonZeroACs(&dinfo, src_coefs, x_0, mu);
//decryptAllACs(&dinfo, src_coefs, x_0, mu);
construct_alpha_beta(alpha, x_0_char + (x_0_len - 2 - 16 - 1), 16);
construct_alpha_beta(beta, mu_char + (mu_len - 1 - 16 - 1), 16);
//diffuseACs(&dinfo, src_coefs, x_0, mu, alpha, beta, false);
diffuseACsFlipSigns(&dinfo, src_coefs, x_0, mu, alpha, beta);
decryptDCs(&dinfo, src_coefs, x_0, mu);
//decryptByColumn(&dinfo, src_coefs, x_0, mu);
//decryptByRow(&dinfo, src_coefs, x_0, mu);
jpeg_write_coefficients(&cinfo, src_coefs);
LOGD("decryptJpeg finished");
teardown:
env->ReleaseStringUTFChars(x_0_jstr, x_0_char);
env->ReleaseStringUTFChars(mu_jstr, mu_char);
mpf_clears(x_0, mu, alpha, beta, NULL);
jpeg_finish_compress(&cinfo);
jpeg_destroy_compress(&cinfo);
jpeg_destroy_decompress(&dinfo);
}
static int unscramble_rgb(struct rgb_block **blocks,
unsigned int rows,
unsigned int columns) {
int *indices_red;
int *indices_green;
int *indices_blue;
int *indices_inter;
std::default_random_engine gen_red;
std::default_random_engine gen_green;
std::default_random_engine gen_blue;
std::default_random_engine gen_inter;
std::uniform_int_distribution<int> inter_dist(0, 2);
gen_red.seed(10000000);
gen_green.seed(20000000);
gen_blue.seed(30000000);
gen_inter.seed(10000000 ^ 20000000 ^ 30000000);
indices_red = (int *) malloc(columns * rows * sizeof(int));
indices_green = (int *) malloc(columns * rows * sizeof(int));
indices_blue = (int *) malloc(columns * rows * sizeof(int));
indices_inter = (int *) malloc(columns * rows * sizeof(int));
if (indices_red == NULL || indices_green == NULL || indices_blue == NULL || indices_inter == NULL) {
LOGE("unscramble_rgb failed to allocate indices_red/green/blue");
return 1;
}
for (int i = columns * rows - 1; i >= 0; i--) {
std::uniform_int_distribution<int> dist(0, i);
indices_red[i] = dist(gen_red);
indices_green[i] = dist(gen_green);
indices_blue[i] = dist(gen_blue);
indices_inter[i] = inter_dist(gen_inter);
}
LOGD("unscramble_rgb rows=%d, columns=%d", rows, columns);
for (int i = 0; i < columns * rows; i++) {
int j;
int block_i_x = i % columns;
int block_i_y = i / columns;
int block_j_x;
int block_j_y;
switch (indices_inter[i]) {
case 0:
// Don't do inter-channel shuffle
break;
case 1:
// (R, B, G) -> (R, G, B) after the initial swap
std::swap(blocks[block_i_y][block_i_x].blue, blocks[block_i_y][block_i_x].green);
break;
case 2:
// (B, R, G) -> (R, G, B) after the initial swap
std::swap(blocks[block_i_y][block_i_x].red, blocks[block_i_y][block_i_x].blue);
break;
}
j = indices_red[i];
block_j_x = j % columns;
block_j_y = j / columns;
std::swap(blocks[block_i_y][block_i_x].red, blocks[block_j_y][block_j_x].red);
j = indices_green[i];
block_j_x = j % columns;
block_j_y = j / columns;
std::swap(blocks[block_i_y][block_i_x].green, blocks[block_j_y][block_j_x].green);
j = indices_blue[i];
block_j_x = j % columns;
block_j_y = j / columns;
std::swap(blocks[block_i_y][block_i_x].blue, blocks[block_j_y][block_j_x].blue);
}
free(indices_red);
free(indices_green);
free(indices_blue);
free(indices_inter);
LOGD("unscramble_rgb finished");
return 0;
}
static void do_decrypt_etc(
j_decompress_ptr dinfo_red,
j_decompress_ptr dinfo_green,
j_decompress_ptr dinfo_blue,
struct rgb_block **rgb_copy,
unsigned int rows,
unsigned int columns) {
JSAMPARRAY buffer_red;
JSAMPARRAY buffer_green;
JSAMPARRAY buffer_blue;
int row_stride;
// JSAMPLEs per row in output buffer
row_stride = dinfo_red->output_width * dinfo_red->output_components;
// Make a sample array that will go away when done with image
buffer_red = (*dinfo_red->mem->alloc_sarray)((j_common_ptr) dinfo_red, JPOOL_IMAGE, row_stride, 1);
buffer_green = (*dinfo_red->mem->alloc_sarray)((j_common_ptr) dinfo_green, JPOOL_IMAGE, row_stride, 1);
buffer_blue = (*dinfo_red->mem->alloc_sarray)((j_common_ptr) dinfo_blue, JPOOL_IMAGE, row_stride, 1);
LOGD("do_decrypt_etc rows=%d (height=%d), columns=%d (width=%d) / row_stride=%d", rows, dinfo_red->output_height, columns, dinfo_red->output_width, row_stride);
// Copy decompressed RGB values to our buffer
while (dinfo_red->output_scanline < dinfo_red->output_height) {
unsigned char *pixels_red;
unsigned char *pixels_green;
unsigned char *pixels_blue;
int block_y;
int pixel_y;
int line = dinfo_red->output_scanline;
jpeg_read_scanlines(dinfo_red, buffer_red, 1);
jpeg_read_scanlines(dinfo_green, buffer_green, 1);
jpeg_read_scanlines(dinfo_blue, buffer_blue, 1);
pixels_red = (unsigned char *) buffer_red[0];
pixels_green = (unsigned char *) buffer_green[0];
pixels_blue = (unsigned char *) buffer_blue[0];
block_y = line / BLOCK_HEIGHT;
pixel_y = line % BLOCK_HEIGHT;
for (int i = 0; i < row_stride; i += dinfo_red->output_components) {
int block_x = i / (dinfo_red->output_components * BLOCK_WIDTH);
int pixel_x = (i / dinfo_red->output_components) % BLOCK_WIDTH;
// if (block_x >= columns || block_y >= rows || pixel_x >= BLOCK_WIDTH || pixel_y >= BLOCK_HEIGHT)
//LOGD("do_encrypt_etc (%d, %d) / (%d, %d)", block_x, block_y, pixel_x, pixel_y);
rgb_copy[block_y][block_x].red[pixel_y][pixel_x] = *pixels_red;
rgb_copy[block_y][block_x].green[pixel_y][pixel_x] = *pixels_green;
rgb_copy[block_y][block_x].blue[pixel_y][pixel_x] = *pixels_blue;
// Google Photos converts 8-bit grayscale to 24-bit color so there might be 1 or 3 components
pixels_red += dinfo_red->output_components;
pixels_green += dinfo_green->output_components;
pixels_blue += dinfo_blue->output_components;
}
}
// Now scramble the copied RGB values
unscramble_rgb(rgb_copy, rows, columns);
LOGD("do_decrypt_etc finished");
}
void decryptJpegEtc(
JNIEnv *env,
jobject is_red,
jobject is_green,
jobject is_blue,
jobject os,
jstring x_0_jstr,
jstring mu_jstr) {
JpegInputStreamWrapper is_wrapper_red{env, is_red};
JpegInputStreamWrapper is_wrapper_green{env, is_green};
JpegInputStreamWrapper is_wrapper_blue{env, is_blue};
JpegOutputStreamWrapper os_wrapper{env, os};
JpegErrorHandler error_handler{env};
struct jpeg_source_mgr& src_red = is_wrapper_red.public_fields;
struct jpeg_source_mgr& src_green = is_wrapper_green.public_fields;
struct jpeg_source_mgr& src_blue = is_wrapper_blue.public_fields;
struct jpeg_destination_mgr& dest = os_wrapper.public_fields;
struct rgb_block **rgb_copy;
struct jpeg_decompress_struct dinfo_red;
struct jpeg_decompress_struct dinfo_green;
struct jpeg_decompress_struct dinfo_blue;
struct jpeg_compress_struct cinfo;
unsigned int rows;
unsigned int columns;
unsigned int row_stride;
JSAMPLE *rgb_row; // JSAMPLE is char
JSAMPROW row_pointer[1];
int rounded_width;
int rounded_height;
if (setjmp(error_handler.setjmpBuffer)) {
return;
}
LOGD("decryptJpegEtc starting");
initDecompressStruct(dinfo_red, error_handler, src_red);
initDecompressStruct(dinfo_green, error_handler, src_green);
initDecompressStruct(dinfo_blue, error_handler, src_blue);
jpeg_start_decompress(&dinfo_red);
jpeg_start_decompress(&dinfo_green);
jpeg_start_decompress(&dinfo_blue);
rounded_height = round_up_to_multiple(dinfo_red.output_height, 8);
rounded_width = round_up_to_multiple(dinfo_red.output_width, 8);
LOGD("decryptJpegEtc started decompress");
rows = ceil(rounded_height / BLOCK_HEIGHT);
columns = ceil(rounded_width / BLOCK_WIDTH);
rgb_copy = new struct rgb_block *[rows];
for (int y = 0; y < rows; ++y) {
rgb_copy[y] = new rgb_block[columns];
// Set the far right block to 0 for every row since it might be padding
memset(&rgb_copy[y][columns - 1], 0, sizeof(struct rgb_block));
// Set entire bottom-most row to 0 since it might be padding
if (y == rows - 1) {
for (int x = 0; x < columns; ++x)
memset(&rgb_copy[y][x], 0, sizeof(struct rgb_block));
}
}
do_decrypt_etc(&dinfo_red, &dinfo_green, &dinfo_blue, rgb_copy, rows, columns);
// Decrypt done, write result out
initCompressStruct(cinfo, dinfo_red, error_handler, dest);
cinfo.input_components = 3;
cinfo.in_color_space = JCS_RGB;
jpeg_set_defaults(&cinfo);
jpeg_set_quality(&cinfo, 75, TRUE);
jpeg_start_compress(&cinfo, TRUE);
// Now write the scrambled RGB channels
row_stride = cinfo.image_width * cinfo.input_components;
rgb_row = (JSAMPLE *) malloc(row_stride * sizeof(JSAMPLE));
if (rgb_row == NULL) {
LOGE("decryptJpegEtc failed to allocate rgb_row");
goto teardown;
}
LOGD("decryptJpegEtc row_stride=%d, num_components=%d", row_stride, cinfo.num_components);
while (cinfo.next_scanline < cinfo.image_height) {
int block_x;
int pixel_x;
int block_y = cinfo.next_scanline / BLOCK_HEIGHT;
int pixel_y = cinfo.next_scanline % BLOCK_HEIGHT;
for (int i = 0; i < row_stride; i++) {
block_x = i / (cinfo.input_components * BLOCK_WIDTH); // buffer is R,G,B,R,G,B,...
pixel_x = (i / cinfo.input_components) % BLOCK_WIDTH;
rgb_row[i++] = rgb_copy[block_y][block_x].red[pixel_y][pixel_x];
rgb_row[i++] = rgb_copy[block_y][block_x].green[pixel_y][pixel_x];
rgb_row[i] = rgb_copy[block_y][block_x].blue[pixel_y][pixel_x];
}
row_pointer[0] = rgb_row;
jpeg_write_scanlines(&cinfo, row_pointer, 1);
}
teardown:
for (int i = 0; i < rows; ++i)
delete[] rgb_copy[i];
delete[] rgb_copy;
if (rgb_row != NULL)
free(rgb_row);
jpeg_finish_decompress(&dinfo_red);
jpeg_finish_decompress(&dinfo_green);
jpeg_finish_decompress(&dinfo_blue);
jpeg_destroy_decompress(&dinfo_red);
jpeg_destroy_decompress(&dinfo_green);
jpeg_destroy_decompress(&dinfo_blue);
jpeg_finish_compress(&cinfo);
jpeg_destroy_compress(&cinfo);
}
} } } } |
2954c29d58029a38a11693235a19d89594fa5966 | a75ea4bde6f69e3e147a7d3c77cc371ec81da8ec | /ActionSemesetr/DirectX2DLibraryCpp/Src/Main.cpp | 202de74b26911c5ffbf1e31beb94a18b4205f029 | [] | no_license | ha-k-pg-mori/ActionSemester | c6a2cabfd51920e58ee300e4627a9f2ed0ddc035 | 711cf19a0723557bdcafc31a3eeea5fca82a19ec | refs/heads/main | 2023-02-28T15:31:19.206990 | 2021-02-03T08:44:36 | 2021-02-03T08:44:36 | 331,953,362 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,662 | cpp | Main.cpp | #define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#include <Windows.h>
#include "Engine/Engine.h"
#include "Common/Vec.h"
#include "Player.h"
<<<<<<< HEAD
#include "Map.h"
Player player;
=======
Vec2 g_Position = Vec2(300.0f, 200.0f);
Vec2 g_Scale = Vec2(1.0f, 1.0f);
float g_Angle = 0.0f;
int g_PivotType = PivotType::LeftTop;
Player player;
>>>>>>> 5eb055a1872b1da693f014074c343a5a04bbd118
// ゲーム処理
void GameProcessing();
// 描画処理
void DrawProcessing();
/*
エントリポイント
*/
int WINAPI WinMain(
_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPSTR lpCmpLine,
_In_ INT nCmdShow)
{
// エンジンの初期化
// ゲームループ開始前に1度だけ実行する
if (Engine::Initialize(640, 480, "Sample") == false)
{
return 0;
}
// テクスチャ読み込み
// 第一引数の文字列で読み込んだテクスチャを登録する
// 描画や取得は登録した文字列で指定する
Engine::LoadTexture("Enemy", "Res/Enemy.png");
Engine::LoadTexture("Dango", "Res/dango_03.png");
Engine::LoadTexture("MapChip", "Res/MapChip.png");
// サウンド読み込み
// 第一引数の文字列で読み込んだサウンドを登録する
// 描画や取得は登録した文字列で指定する
Engine::LoadSoundFile("Bgm", "Res/Bgm.wav");
Engine::LoadSoundFile("Se", "Res/Se.wav");
// サウンド再生
// 指定されたキーワードのサウンドファイルを再生する
Engine::PlaySound("Bgm", true);
while (true)
{
bool message_ret = false;
MSG msg;
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
{
break;
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
else
{
// ゲーム処理
GameProcessing();
// 描画開始
DrawProcessing();
}
}
// エンジン終了
// ゲームループ終了後に1度だけ実行する
// テクスチャとサウンドファイルも全て解放する
Engine::Release();
// メモリリーク検出
_CrtDumpMemoryLeaks();
return 0;
} // プログラム終了
void GameProcessing()
{
// 入力データの更新
Engine::Update();
<<<<<<< HEAD
player.Update();
=======
player.Update();
>>>>>>> 5eb055a1872b1da693f014074c343a5a04bbd118
}
void DrawProcessing()
{
// 描画開始
// 描画処理を実行する場合、必ず最初実行する
Engine::StartDrawing(0);
<<<<<<< HEAD
player.Draw();
=======
// 描画終了
// 描画処理を終了する場合、必ず最後に実行する
>>>>>>> 5eb055a1872b1da693f014074c343a5a04bbd118
Engine::FinishDrawing();
}
|
c10170a969346da33dd0c62bb5e7931ad491f4f0 | 0b90d18bf8e2000d3c47a17f3403be51b4a8ecd8 | /src/Core/Algorithms/Math/BiotSavartSolver/BiotSavartSolver.cc | 73d733ae1c60ff85a64b4daf822f25f3ce7676ca | [
"MIT"
] | permissive | merced317/scirun4plus | c3d8d65dd68f9d119b43cf084ea8b9d94921ce33 | f29630e03d3cf13c0ce8b327676ad202e3981af0 | refs/heads/master | 2020-12-10T19:20:18.401161 | 2018-06-27T09:21:54 | 2018-06-27T09:21:54 | 233,683,375 | 0 | 0 | null | 2020-01-13T20:09:14 | 2020-01-13T20:09:13 | null | UTF-8 | C++ | false | false | 28,884 | cc | BiotSavartSolver.cc |
#include <Core/Algorithms/Math/BiotSavartSolver/BiotSavartSolver.h>
#include <Core/Datatypes/DenseMatrix.h>
#include <Core/Math/MiscMath.h>
#include <Core/Datatypes/FieldInformation.h>
#include <Core/Thread/Barrier.h>
#include <Core/Thread/Thread.h>
#include <string>
#include <cassert>
#include <boost/lexical_cast.hpp>
//! Namespace used for SCIRun Algorithmic layer
namespace SCIRunAlgo {
using namespace SCIRun;
//! Namespace used for concrete kernel implementations
namespace details
{
class KernelBase
{
public:
KernelBase(AlgoBase* algo, int t) :
ref_cnt(0),
algo(algo),
barrier("BSV KernelBase Barrier"),
mutex("BSV KernelBase Mutex"),
typeOut(t),
matOut(0)
{
}
virtual ~KernelBase()
{
}
//! Local entry function, must be implemented by each specific kernel
virtual bool Integrate(FieldHandle& mesh, FieldHandle& coil, MatrixHandle& outdata) = 0;
//! Global reference counting
int ref_cnt;
protected:
//! ref to the executing algorithm context
AlgoBase* algo;
//! model miscs.
VMesh* vmesh;
VField* vfield;
size_type modelSize;
//! coil miscs.
VMesh* vcoil;
VField* vcoilField;
size_type coilSize;
//! parallel essential primitives
Barrier barrier;
Mutex mutex;
unsigned int numprocessors;
std::vector<bool> success;
//! output Field
int typeOut;
DenseMatrix *matOut;
MatrixHandle matOutHandle;
bool PreIntegration( FieldHandle& mesh, FieldHandle& coil )
{
this->vmesh = mesh->vmesh();
assert(vmesh);
this->vcoil = coil->vmesh();
assert(vcoil);
this->vfield = mesh->vfield();
assert(vfield);
this->vcoilField = coil->vfield();
assert(vcoilField);
this->numprocessors = Thread::numProcessors();
int numproc = this->algo->get_int("num_processors");
if (numproc > 0)
{
numprocessors = numproc;
}
#ifdef _DEBUG
//! DEBUG when we want to test with one CPU only
numprocessors = 1;
#endif
algo->remark("number of processors: " + boost::lexical_cast<std::string>(this->numprocessors));
success.resize(numprocessors,true);
//! get number of nodes for the model
modelSize = vmesh->num_nodes();
assert(modelSize > 0);
try
{
matOut = new DenseMatrix(static_cast<int>(modelSize),3);
matOutHandle = matOut;
}
catch (...)
{
algo->error("Error alocating output matrix");
return (false);
}
return (true);
}
bool PostIntegration( MatrixHandle& outdata )
{
//! check for error
for (size_t j=0; j<success.size(); j++)
{
if (success[j] == false) return (false);
}
outdata = matOutHandle;
return (true);
}
};
class CircularKernel : public KernelBase
{
public:
CircularKernel( AlgoBase* algo, int t ) : KernelBase(algo,t)
{
}
~CircularKernel()
{
}
//! Complexity O(M*N) ,where M is the number of nodes of the model and N is the numbder of nodes of the coil
virtual bool Integrate(FieldHandle& mesh, FieldHandle& coil, MatrixHandle& outdata)
{
if(!PreIntegration(mesh,coil))
{
return (false);
}
vmesh->synchronize(Mesh::NODES_E | Mesh::EDGES_E);
VMesh::Node::array_type enodes;
Point enode1;
Point enode2;
//! get number of nodes for the model
//modelSize = vmesh->num_nodes();
//! get numbder of nodes for the coil
coilSize = vcoil->num_nodes();
//! basic assumption
assert(modelSize > 0 && coilSize > 1);
coilNodes.clear();
coilNodes.reserve(coilSize);
for(VMesh::Edge::index_type i = 0; i < vcoil->num_edges(); i++)
{
vcoil->get_nodes(enodes,i);
//std::cout << enodes[0] << "; "<< enodes[1] << "; "<< enodes[2] << "; "<< enodes[3] << "; "<< enodes[4] << "; "<< enodes[5] << "; "<< enodes[6] << "; "<< enodes[7] << "; "<< enodes[8] << "; "<< enodes[9] <<"; "<< enodes[10] << std::endl;
vcoil->get_point(enode1,enodes[0]);
vcoil->get_point(enode2,enodes[1]);
coilNodes.push_back(Vector(enode1));
coilNodes.push_back(Vector(enode2));
}
//! Start the multi threaded
Thread::parallel(this, &CircularKernel::ParallelKernel, numprocessors);
return PostIntegration(outdata);
}
private:
//! integration step, will auto adapt
//double autostep;
//! integration step, externally provided
//double extstep;
//! keep nodes on the coil cached
std::vector<Vector> coilNodes;
//! buffer of points used for integration
//std::vector<Vector> integrPoints;
//! execute in parallel
void ParallelKernel(int proc_num)
{
assert(proc_num >= 0);
int cnt = 0;
double current = 1.0;
Point modelNode;
const index_type begins = (modelSize * proc_num) / numprocessors;
const index_type ends = (modelSize * (proc_num+1)) / numprocessors;
assert( begins <= ends );
//! buffer of points used for integration
//std::vector<Vector> integrPoints;
//integrPoints.reserve(256);
//! keep previous step length
//! used for optimization purpose
double prevSegLen = 123456789.12345678;
//! number of integration points
int nips = 0;
try{
for(index_type iM = begins;
iM < ends;
iM++)
{
vmesh->get_node(modelNode,iM);
// result
Vector F;
for( size_t iC0 = 0, iC1 =1, iCV = 0;
iC0 < coilNodes.size();
iC0+=2, iC1+=2, iCV++)
{
vcoilField->get_value(current,iCV);
current = current == 0.0 ? 1.0 : current;
Vector coilNodeThis;
Vector coilNodeNext;
if(current >= 0.0)
{
coilNodeThis = coilNodes[iC0];
coilNodeNext = coilNodes[iC1];
}
else
{
coilNodeThis = coilNodes[iC1];
coilNodeNext = coilNodes[iC0];
}
//std::cout << "\t coil_node: THIS[" << coilNodeThis << "] NEXT[" << coilNodeNext << "] E:" << current << std::endl;//DEBUG
//! Length of the curve element
Vector diffNodes = coilNodeNext - coilNodeThis;
double newSegLen = diffNodes.length();
//! optimization
//! only rexompute integration step only if segment length changes
if( Abs(prevSegLen - newSegLen ) > 0.00000001 )
{
prevSegLen = newSegLen;
//auto adaptive integration step calculation
nips = AdjustNumberOfIntegrationPoints(newSegLen);
//std::cout << "\t\t integration step: " << newSegLen / static_cast<double>(nips) << std::endl;//DEBUG
//algo->status( "integration step: " + boost::lexical_cast<std::string>(newSegLen / static_cast<double>(nips)) );
}
//assert( nips > 2 );
if( nips < 3 )
{
algo->warning("integration step too big");
}
Vector dir = coilNodeNext - coilNodeThis;
double l = dir.length();
double dl = l / nips;
Vector dir_norm = dir / l;
Vector ort = Cross(coilNodeThis,dir);
Vector ort_norm = ort / ort.length();
//Vector Rxyz = (integrPoints[iip] + integrPoints[iip+1] ) / 2 - Vector(modelNode);
//! integration step over line segment
for(int iip = 0; iip < nips; iip++)
{
Vector R = ( coilNodeThis + dir_norm * ( iip * dl ) ) - Vector(modelNode);
double r = R.length();
if(typeOut == 1)
{
//! Biot-Savart Magnetic Field
F += 1.0e-7 * ( ort_norm * dl ) * ( Abs(current) / (r*r*r) );
}
if(typeOut == 2)
{
//! Biot-Savart Magnetic Vector Potential Field
F += 1.0e-7 * ( dir_norm * dl) *( Abs(current) / r );
}
}
/*
std::vector<Vector> integrPoints(nips);
integrPoints.clear();
//! curve segment discretization
for(int iip = 0; iip < nips; iip++)
{
double interpolant = static_cast<double>(iip) / static_cast<double>(nips);
Vector v = Interpolate( coilNodeThis, coilNodeNext, interpolant );
integrPoints.push_back( v );
//std::cout << "\t\t integration point: " << integrPoints[iip] << std::endl;//DEBUG
}
//! integration step over line segment
for(int iip = 0; iip < nips -1; iip++)
{
//! Vector connecting the infinitesimal curve-element
Vector Rxyz = (integrPoints[iip] + integrPoints[iip+1] ) / 2 - Vector(modelNode);
//! Infinitesimal curve-element components
Vector dLxyz = integrPoints[iip+1] - integrPoints[iip];
double Rn = Rxyz.length();
//! check for distance between coil and model close to zero
//! it might cause numerical stability issues with respect to the cross-product
if(Rn < 0.00001)
{
algo->warning("coil<->model distance approaching zero!");
}
if(typeOut == 1)
{
//! Biot-Savart Magnetic Field
F += 1.0e-7 * Cross( Rxyz, dLxyz ) * ( Abs(current) / (Rn*Rn*Rn) );
//Vector dB = Cross(Rxyz,dLxyz) * ( abs(current)/4/M_PI/Rn/Rn/Rn );
}
if(typeOut == 2)
{
//! Biot-Savart Magnetic Vector Potential Field
F += 1.0e-7 * dLxyz * ( Abs(current) / (Rn) );
}
}
*/
//std::cout << "\t\t B: " << _results[iM] << std::endl;//DEBUG
}
matOut->put(iM,0, F[0]);
matOut->put(iM,1, F[1]);
matOut->put(iM,2, F[2]);
//! progress reporter
if (proc_num == 0)
{
cnt++;
if (cnt == 200)
{
cnt = 0;
algo->update_progress(iM,2*(begins-ends));
}
}
}
success[proc_num] = true;
}
catch (...)
{
algo->error(std::string("PieceWiseKernel crashed while integrating"));
success[proc_num] = false;
}
//! check point
barrier.wait(numprocessors);
// Bail out if one of the processes failed
for (size_t q=0; q<numprocessors;q++)
if (success[q] == false) return;
}
//! Auto adjust accuracy of integration
int AdjustNumberOfIntegrationPoints(double len)
{
//assert(step < len);
double autostep = 0.1d;
int minNP = 100;//more than 1 for sure
int maxNP = 200;//no more than 1000
int NP = 0;
bool over = false;
bool under = false;
do
{
NP = Ceil( len / autostep );
under = NP < minNP ? true : false;
over = NP > maxNP ? true : false;
if(under) autostep *= 0.5d;
if(over) autostep *= 1.5d;
//DEBUG
//std::cout << "\t integration step : " << step << ",for segment lenght :" << len <<", with number of points per segment :" << NP << std::endl;
}while( under || over );
return NP;
}
};
class PieceWiseKernel : public KernelBase
{
public:
PieceWiseKernel( AlgoBase* algo, int t ) : KernelBase(algo,t)
{
//we keep last calculated step
//however if segments lenght varies,
//it makes more sense to keep a look-up table of previous steps for given lenght
autostep = 0.1d;
extstep = -1.0d;
}
~PieceWiseKernel()
{
}
//! Complexity O(M*N) ,where M is the number of nodes of the model and N is the numbder of nodes of the coil
virtual bool Integrate(FieldHandle& mesh, FieldHandle& coil, MatrixHandle& outdata)
{
if(!PreIntegration(mesh,coil))
{
return (false);
}
vmesh->synchronize(Mesh::NODES_E | Mesh::EDGES_E);
VMesh::Node::array_type enodes;
Point enode1;
Point enode2;
//! get number of nodes for the model
//modelSize = vmesh->num_nodes();
//! get numbder of nodes for the coil
coilSize = vcoil->num_nodes();
//! basic assumption
assert(modelSize > 0 && coilSize > 1);
coilNodes.clear();
coilNodes.reserve(coilSize);
for(VMesh::Edge::index_type i = 0; i < vcoil->num_edges(); i++)
{
vcoil->get_nodes(enodes,i);
//std::cout << enodes[0] << "; "<< enodes[1] << "; "<< enodes[2] << "; "<< enodes[3] << "; "<< enodes[4] << "; "<< enodes[5] << "; "<< enodes[6] << "; "<< enodes[7] << "; "<< enodes[8] << "; "<< enodes[9] <<"; "<< enodes[10] << std::endl;
vcoil->get_point(enode1,enodes[0]);
vcoil->get_point(enode2,enodes[1]);
coilNodes.push_back(Vector(enode1));
coilNodes.push_back(Vector(enode2));
}
//! Start the multi threaded
Thread::parallel(this, &PieceWiseKernel::ParallelKernel, numprocessors);
return PostIntegration(outdata);
}
void SetIntegrationStep(double step)
{
assert(step >= 0.0d);
extstep = step;
}
double GetIntegrationStep() const
{
return extstep;
}
private:
//! integration step, will auto adapt
double autostep;
//! integration step, externally provided
double extstep;
//! keep nodes on the coil cached
std::vector<Vector> coilNodes;
//! buffer of points used for integration
//std::vector<Vector> integrPoints;
//! execute in parallel
void ParallelKernel(int proc_num)
{
assert(proc_num >= 0);
int cnt = 0;
double current = 1.0;
Point modelNode;
const index_type begins = (modelSize * proc_num) / numprocessors;
const index_type ends = (modelSize * (proc_num+1)) / numprocessors;
assert( begins <= ends );
//! buffer of points used for integration
std::vector<Vector> integrPoints;
integrPoints.reserve(256);
//! keep previous step length
//! used for optimization purpose
double prevSegLen = 123456789.12345678;
//! number of integration points
int nips = 0;
try{
for(index_type iM = begins;
iM < ends;
iM++)
{
vmesh->get_node(modelNode,iM);
// result
Vector F;
for( size_t iC0 = 0, iC1 =1, iCV = 0;
iC0 < coilNodes.size();
iC0+=2, iC1+=2, iCV++)
{
vcoilField->get_value(current,iCV);
current = current == 0.0 ? 1.0 : current;
Vector coilNodeThis;
Vector coilNodeNext;
if(current >= 0.0)
{
coilNodeThis = coilNodes[iC0];
coilNodeNext = coilNodes[iC1];
}
else
{
coilNodeThis = coilNodes[iC1];
coilNodeNext = coilNodes[iC0];
}
//std::cout << "\t coil_node: THIS[" << coilNodeThis << "] NEXT[" << coilNodeNext << "] E:" << current << std::endl;//DEBUG
//! Length of the curve element
Vector diffNodes = coilNodeNext - coilNodeThis;
double newSegLen = diffNodes.length();
//first check if externally suplied integration step is available and use it
if(extstep > 0)
{
nips = newSegLen / extstep;
//std::cout << "external integration" << std::endl;
}
else
{
//! optimization
//! only rexompute integration step only if segment length changes
if( Abs(prevSegLen - newSegLen ) > 0.00000001 )
{
prevSegLen = newSegLen;
//auto adaptive integration step calculation
nips = AdjustNumberOfIntegrationPoints(newSegLen);
//std::cout << "\t\t integration step: " << newSegLen / static_cast<double>(nips) << std::endl;//DEBUG
//algo->status( "integration step: " + boost::lexical_cast<std::string>(newSegLen / static_cast<double>(nips)) );
}
}
//assert( nips > 2 );
if( nips < 3 )
{
algo->warning("integration step too big");
}
//std::vector<Vector> integrPoints(nips);
integrPoints.clear();
//! curve segment discretization
for(int iip = 0; iip < nips; iip++)
{
double interpolant = static_cast<double>(iip) / static_cast<double>(nips);
Vector v = Interpolate( coilNodeThis, coilNodeNext, interpolant );
integrPoints.push_back( v );
//std::cout << "\t\t integration point: " << integrPoints[iip] << std::endl;//DEBUG
}
//! integration step over line segment
for(int iip = 0; iip < nips -1; iip++)
{
//double M_MU = 4*M_PI*1.0e-7;
//! Vector connecting the infinitesimal curve-element
Vector Rxyz = (integrPoints[iip] + integrPoints[iip+1] ) / 2 - Vector(modelNode);
//! Infinitesimal curve-element components
Vector dLxyz = integrPoints[iip+1] - integrPoints[iip];
//double dLn = dLxyz.length();
double Rn = Rxyz.length();
//double Rn = Rxyz.normalize();
//! check for distance between coil and model close to zero
//! it might cause numerical stability issues with respect to the cross-product
if(Rn < 0.00001)
{
algo->warning("coil<->model distance approaching zero!");
}
if(typeOut == 1)
{
//! Biot-Savart Magnetic Field
F += 1.0e-7 * Cross( Rxyz, dLxyz ) * ( Abs(current) / (Rn*Rn*Rn) );
//Vector dB = Cross(Rxyz,dLxyz) * ( abs(current)/4/M_PI/Rn/Rn/Rn );
}
if(typeOut == 2)
{
//! Biot-Savart Magnetic Vector Potential Field
F += 1.0e-7 * dLxyz * ( Abs(current) / (Rn) );
}
}
//std::cout << "\t\t B: " << _results[iM] << std::endl;//DEBUG
}
//std::cout << "DEBUG CUR:" << current << std::endl << std::flush;
matOut->put(iM,0, F[0]);
matOut->put(iM,1, F[1]);
matOut->put(iM,2, F[2]);
//! progress reporter
if (proc_num == 0)
{
cnt++;
if (cnt == 200)
{
cnt = 0;
algo->update_progress(iM,2*(begins-ends));
}
}
}
success[proc_num] = true;
}
catch (...)
{
algo->error(std::string("PieceWiseKernel crashed while integrating"));
success[proc_num] = false;
}
//! check point
barrier.wait(numprocessors);
// Bail out if one of the processes failed
for (size_t q=0; q<numprocessors;q++)
if (success[q] == false) return;
}
//! Auto adjust accuracy of integration
int AdjustNumberOfIntegrationPoints(double len)
{
//assert(step < len);
int minNP = 100;//more than 1 for sure
int maxNP = 200;//no more than 1000
int NP = 0;
bool over = false;
bool under = false;
do
{
NP = Ceil( len / autostep );
under = NP < minNP ? true : false;
over = NP > maxNP ? true : false;
if(under) autostep *= 0.5d;
if(over) autostep *= 1.5d;
//DEBUG
//std::cout << "\t integration step : " << autostep << ",for segment lenght :" << len <<", with number of points per segment :" << NP << std::endl;
}while( under || over );
return NP;
}
};
//! TODO
class VolumetricKernel : public KernelBase
{
public:
VolumetricKernel(AlgoBase* algo, int t) : KernelBase(algo,t)
{
}
~VolumetricKernel()
{
}
virtual bool Integrate(FieldHandle& mesh, FieldHandle& coil, MatrixHandle& outdata)
{
if(!PreIntegration(mesh,coil))
{
return (false);
}
//! get numbder of nodes for the coil
coilSize = vcoil->num_elems();
//! basic assumption
assert(modelSize > 0 && coilSize > 1);
/*
//RAAANNNNDDDD
//vcoil->get_element_center(coords_type& coords);
int basis_order = vcoilField->basis_order();
VMesh::Elem::index_type ei = 1;
double evol = vcoil->get_volume(ei);
Vector eval;
//template<class T> inline void get_value(T& val, VMesh::Elem::index_type idx) const
vcoilField->get_value(eval,ei);
Point ecenter;
Point ecenter2;
vcoil->get_center(ecenter,ei);
vcoilField->get_center(ecenter2, ei);
assert( ecenter == ecenter2 );
double elmsize = vcoil->get_element_size();
int nnodes = vcoil->num_nodes_per_elem();
//tets
//XXXXXXX 0 -0.00814513 0.166667 [-1.95129 -0.486505 -11.1097] 4
//lattice
//XXXXXXX 0 0.866878 1 [-1.06667 -6.4 -23.619] 8
//XXXXXXX 0 0.866878 1 [-1.06667 -6.4 -23.619] 8 [0 0 1]
std::cout << "XXXXXXX " << basis_order << " "<< evol << " " << elmsize << " " << ecenter << " " << nnodes << " " << eval << std::endl;
*/
vmesh->synchronize(Mesh::NODES_E | Mesh::EDGES_E);
//! Start the multi threaded
Thread::parallel(this, &VolumetricKernel::ParallelKernel, numprocessors);
return PostIntegration(outdata);
}
private:
//! execute in parallel
void ParallelKernel(int proc_num)
{
assert(proc_num >= 0);
int cnt = 0;
Point modelNode;
Point coilCenter;
Vector current;
const VMesh::Node::index_type begins = (modelSize * proc_num) / numprocessors;
const VMesh::Node::index_type ends = (modelSize * (proc_num+1)) / numprocessors;
assert( begins <= ends );
try{
for(VMesh::Node::index_type iM = begins; iM < ends; iM++)
{
vmesh->get_node(modelNode,iM);
//! accumulatedresult
Vector F;
Vector R;
double evol = 0.0;
double Rl;
for(VMesh::Elem::index_type iC = 0; iC < coilSize; iC++)
{
vcoilField->get_value(current,iC);
vcoilField->get_center(coilCenter, iC);//auto resolve based on basis_order
evol = vcoil->get_volume(iC);
R = coilCenter - modelNode;
Rl = R.length();
if(typeOut == 1)
{
//! Biot-Savart Magnetic Field
//F += Cross( Rxyz, dLxyz ) * ( std::abs(current) / (4.0*M_PI*Rn*Rn*Rn) );
F += Cross ( current , R ) * ( evol / (4.0 * M_PI * Rl) );
}
if(typeOut == 2)
{
//! Biot-Savart Magnetic Vector Potential Field
//F += dLxyz * ( std::abs(current) / (4.0*M_PI*Rn) );
F += current * ( evol / (4.0 * M_PI * Rl) );
}
}
matOut->put(iM,0, F[0]);
matOut->put(iM,1, F[1]);
matOut->put(iM,2, F[2]);
//! progress reporter
if (proc_num == 0)
{
cnt++;
if (cnt == 200)
{
cnt = 0;
algo->update_progress(iM,2*(begins-ends));
}
}
}
success[proc_num] = true;
}
catch (...)
{
algo->error(std::string("VolumetricKernel crashed while integrating"));
success[proc_num] = false;
}
//! check point
barrier.wait(numprocessors);
// Bail out if one of the processes failed
for (size_t q=0; q<numprocessors;q++)
if (success[q] == false) return;
}
};
//! Magnetic Dipoles solver
class DipolesKernel : public KernelBase
{
public:
DipolesKernel(AlgoBase* algo, int t) : KernelBase(algo,t)
{
}
~DipolesKernel()
{
}
virtual bool Integrate(FieldHandle& mesh, FieldHandle& coil, MatrixHandle& outdata)
{
if(!PreIntegration(mesh,coil))
{
return (false);
}
//algo->remark(std::string("[ Dipole Kernel ]"));
//! get numbder of nodes for the coil
coilSize = vcoil->num_elems();
//! basic assumption
assert(modelSize > 0 && coilSize > 1);
//needed?
vmesh->synchronize(Mesh::NODES_E | Mesh::EDGES_E);
//! Start the multi threaded
Thread::parallel(this, &DipolesKernel::ParallelKernel, numprocessors);
return PostIntegration(outdata);
}
private:
//! execute in parallel
void ParallelKernel(int proc_num)
{
assert(proc_num >= 0);
int cnt = 0;
Point modelNode;
Point dipoleLocation;
Vector dipoleMoment;
const VMesh::Node::index_type begins = (modelSize * proc_num) / numprocessors;
const VMesh::Node::index_type ends = (modelSize * (proc_num+1)) / numprocessors;
assert( begins <= ends );
try{
for(VMesh::Node::index_type iM = begins; iM < ends; iM++)
{
vmesh->get_node(modelNode,iM);
//! accumulated result
Vector F;
Vector R;
double Rl;
for(VMesh::Elem::index_type iC = 0; iC < coilSize; iC++)
{
vcoilField->get_value(dipoleMoment,iC);
vcoilField->get_center(dipoleLocation, iC);//auto resolve based on basis_order
R = dipoleLocation - modelNode;
Rl = R.length();
if(typeOut == 1)
{
//! Biot-Savart Magnetic Field
F += 1.0e-7 * ( 3 * R * Dot ( dipoleMoment, R ) / (Rl*Rl*Rl*Rl*Rl) - dipoleMoment / (Rl*Rl*Rl) ) ;
}
if(typeOut == 2)
{
//! Biot-Savart Magnetic Vector Potential Field
F += 1.0e-7 * Cross ( dipoleMoment , R ) / (Rl*Rl*Rl) ;
}
}
matOut->put(iM,0, F[0]);
matOut->put(iM,1, F[1]);
matOut->put(iM,2, F[2]);
//! progress reporter
if (proc_num == 0)
{
cnt++;
if (cnt == 200)
{
cnt = 0;
algo->update_progress(iM,2*(begins-ends));
}
}
}
success[proc_num] = true;
}
catch (...)
{
algo->error(std::string("DipoleKernel crashed while integrating"));
success[proc_num] = false;
}
//! check point
barrier.wait(numprocessors);
// Bail out if one of the processes failed
for (size_t q=0; q<numprocessors;q++)
if (success[q] == false) return;
}
};
}//! end namespace detail
//! Run the global algorithm routine
bool
BiotSavartSolverAlgo::
run(FieldHandle& mesh, FieldHandle& coil, int outtype, MatrixHandle& outdata)
{
algo_start("BiotSavartSolver");
//! Check whether we have domain mesh.
if (mesh.get_rep() == 0)
{
error("No input domain field");
algo_end(); return (false);
}
if (coil.get_rep() == 0)
{
error("No input coil source field");
algo_end(); return (false);
}
if (coil->vfield()->basis_order() == -1)
{
error("Need data on coil mesh.");
algo_end(); return (false);
}
using namespace details;
Handle<KernelBase> helper;
if( coil->vmesh()->is_curvemesh() )
{
if(coil->vfield()->is_constantdata() && coil->vfield()->is_scalar())
{
if (true)
{
helper = new PieceWiseKernel(this, outtype);
PieceWiseKernel* pwk = static_cast<PieceWiseKernel*>(helper.get_rep());
//! deligate the externally defined inteegration step
pwk->SetIntegrationStep(this->istep);
}
else
{
helper = new CircularKernel(this, outtype);
}
}
else
{
error("Curve mesh expected with constant scalar data.");
algo_end(); return (false);
}
}
else if(coil->vmesh()->is_pointcloudmesh())
{
if((coil->vfield()->is_lineardata() || coil->vfield()->is_constantdata() ) && coil->vfield()->is_vector())
{
helper = new DipolesKernel(this, outtype);
}
else
{
error("pointcloud expected with linear vector data.");
algo_end(); return (false);
}
}
else if( coil->vmesh()->is_volume() )
{
//if( (coil->vfield()->is_lineardata() || coil->vfield()->is_constantdata() ) && coil->vfield()->is_vector() )
if( coil->vfield()->is_constantdata() && coil->vfield()->is_vector() )
{
helper = new VolumetricKernel(this, outtype);
}
else
{
error("Volumetric mesh expected with constant vector data.");
algo_end(); return (false);
}
}
else
{
error("Unsupported mesh type! Only curve or volumetric.");
algo_end(); return (false);
}
//! do the solving
if( !helper->Integrate(mesh,coil,outdata) )
{
error("Aborted during integration");
algo_end(); return (false);
}
algo_end(); return (true);
}
} // end namespace SCIRunAlgo
|
217d3cbe865843b32bbc0c8e2aff17c4f665a27c | 3fc7e341b3b2e27d2a20a66d7dc92e2da1079a62 | /src/AABB.cpp | 76adb1f4b99dfb38eff733a27e668f963a41d6f3 | [] | no_license | semajrolyat/gwucs6555 | f142b8280af69202f978ec2b3dd477397a8615ef | bd6bfd7be1ead9c27d71e64a5a9b7695306a4fe6 | refs/heads/master | 2020-04-08T04:55:39.815971 | 2013-08-06T18:39:29 | 2013-08-06T18:39:29 | 11,558,444 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 6,052 | cpp | AABB.cpp | /*-----------------------THE GEORGE WASHINGTON UNIVERSITY-----------------------
James Taylor jrt@gwu.edu
AABB class implementation
------------------------------------------------------------------------------*/
#include <cs6555/AABB.h>
//------------------------------------------------------------------------------
// Constructors
//------------------------------------------------------------------------------
/// Default Constructor
AABB::AABB( const Vector3& center, const Vector3& extens ) {
this->center = center;
this->extens = extens;
}
//------------------------------------------------------------------------------
// Destructor
//------------------------------------------------------------------------------
/// Destructor
AABB::~AABB( void ) {
}
//------------------------------------------------------------------------------
// [Base Class] BoundingVolume::Type Queries
//------------------------------------------------------------------------------
/// BoundingVolume Type Query. Implemented by inheritor.
EBoundingVolumeType AABB::bounding_volume_type( void ) {
return BV_TYPE_AABB;
}
Vector3 AABB::normal( Vector3& point_on_aabb ) {
// check corners, if point is corner then normal is the sum of three planar normals
// check edges, if point on edge then normal is sum of two planar edges
// otherwise determine which surface the point is on
Vector3 n;
Vector3 min_p = center - extens;
Vector3 max_p = center + extens;
// bottom quad, ccw
Vector3 p1 = min_p;
Vector3 p2 = Vector3( min_p(0), min_p(1), max_p(2) );
Vector3 p3 = Vector3( max_p(0), min_p(1), max_p(2) );
Vector3 p4 = Vector3( max_p(0), min_p(1), min_p(2) );
// top quad, ccw
Vector3 p5 = Vector3( min_p(0), max_p(1), min_p(2) );
Vector3 p6 = Vector3( min_p(0), max_p(1), max_p(2) );
Vector3 p7 = max_p;
Vector3 p8 = Vector3( max_p(0), max_p(1), min_p(2) );
// check corners
if( point_on_aabb == p1 ) {
n = Vector3(-1, 0, 0) + Vector3(0, -1, 0) + Vector3(0, 0, -1);
n.normalize();
return n;
}
if( point_on_aabb == p2 ) {
n = Vector3(-1, 0, 0) + Vector3(0, -1, 0) + Vector3(0, 0, 1);
n.normalize();
return n;
}
if( point_on_aabb == p3 ) {
n = Vector3(1, 0, 0) + Vector3(0, -1, 0) + Vector3(0, 0, 1);
n.normalize();
return n;
}
if( point_on_aabb == p4 ) {
n = Vector3(1, 0, 0) + Vector3(0, -1, 0) + Vector3(0, 0, -1);
n.normalize();
return n;
}
if( point_on_aabb == p5 ) {
n = Vector3(-1, 0, 0) + Vector3(0, 1, 0) + Vector3(0, 0, -1);
n.normalize();
return n;
}
if( point_on_aabb == p6 ) {
n = Vector3(-1, 0, 0) + Vector3(0, 1, 0) + Vector3(0, 0, 1);
n.normalize();
return n;
}
if( point_on_aabb == p7 ) {
n = Vector3(1, 0, 0) + Vector3(0, 1, 0) + Vector3(0, 0, 1);
n.normalize();
return n;
}
if( point_on_aabb == p8 ) {
n = Vector3(1, 0, 0) + Vector3(0, 1, 0) + Vector3(0, 0, -1);
n.normalize();
return n;
}
// check edges
if( BoundingVolume::SqDistPointSegment( p1, p2, point_on_aabb ) == 0.0 ) {
n = Vector3(-1, 0, 0) + Vector3(0, -1, 0);
n.normalize();
return n;
}
if( BoundingVolume::SqDistPointSegment( p2, p3, point_on_aabb ) == 0.0 ) {
n = Vector3(0, -1, 0) + Vector3(0, 0, 1);
n.normalize();
return n;
}
if( BoundingVolume::SqDistPointSegment( p3, p4, point_on_aabb ) == 0.0 ) {
n = Vector3(1, 0, 0) + Vector3(0, -1, 0);
n.normalize();
return n;
}
if( BoundingVolume::SqDistPointSegment( p4, p1, point_on_aabb ) == 0.0 ) {
n = Vector3(0, -1, 0) + Vector3(0, 0, -1);
n.normalize();
return n;
}
if( BoundingVolume::SqDistPointSegment( p5, p6, point_on_aabb ) == 0.0 ) {
n = Vector3(-1, 0, 0) + Vector3(0, 1, 0);
n.normalize();
return n;
}
if( BoundingVolume::SqDistPointSegment( p6, p7, point_on_aabb ) == 0.0 ) {
n = Vector3(0, 1, 0) + Vector3(0, 0, 1);
n.normalize();
return n;
}
if( BoundingVolume::SqDistPointSegment( p7, p8, point_on_aabb ) == 0.0 ) {
n = Vector3(1, 0, 0) + Vector3(0, 1, 0);
n.normalize();
return n;
}
if( BoundingVolume::SqDistPointSegment( p8, p5, point_on_aabb ) == 0.0 ) {
n = Vector3(0, 1, 0) + Vector3(0, 0, -1);
n.normalize();
return n;
}
if( BoundingVolume::SqDistPointSegment( p1, p5, point_on_aabb ) == 0.0 ) {
n = Vector3(-1, 0, 0) + Vector3(0, 0, -1);
n.normalize();
return n;
}
if( BoundingVolume::SqDistPointSegment( p2, p6, point_on_aabb ) == 0.0 ) {
n = Vector3(-1, 0, 0) + Vector3(0, 0, 1);
n.normalize();
return n;
}
if( BoundingVolume::SqDistPointSegment( p3, p7, point_on_aabb ) == 0.0 ) {
n = Vector3(1, 0, 0) + Vector3(0, 0, 1);
n.normalize();
return n;
}
if( BoundingVolume::SqDistPointSegment( p4, p8, point_on_aabb ) == 0.0 ) {
n = Vector3(1, 0, 0) + Vector3(0, 0, -1);
n.normalize();
return n;
}
// check surfaces
if( point_on_aabb.x() == min_p.x() ) {
return Vector3(-1, 0, 0);
}
if( point_on_aabb.x() == max_p.x() ) {
return Vector3(1, 0, 0);
}
if( point_on_aabb.y() == min_p.y() ) {
return Vector3(0, -1, 0);
}
if( point_on_aabb.y() == max_p.y() ) {
return Vector3(0, 1, 0);
}
if( point_on_aabb.z() == min_p.z() ) {
return Vector3(0, 0, -1);
}
if( point_on_aabb.z() == max_p.z() ) {
return Vector3(0, 0, 1);
}
// if numerical error then can reach here.
// ok for now but added assertion to check for the case arising
assert( true );
return Vector3(0, 0, 1); // a bogus vector to resolve warning
}
|
33dde2d28b25bbf2283df5e5767286b1fe1c9b11 | 7db848aaa168efb8f21e6b25b2c968da28e9a63f | /paintmain.h | e011f29e57718925203243de3919d5cd32ed9406 | [] | no_license | JamesKerrL/PitchPainter | 2596442199b2f7b192c03fb395793785ea8f2e91 | cc5cbd06cfea1cc3a979910c220690ae6539f36c | refs/heads/master | 2022-12-20T10:00:40.342645 | 2019-10-07T00:19:26 | 2019-10-07T00:19:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 111 | h | paintmain.h | #ifndef PAINTMAIN_H
#define PAINTMAIN_H
class paintmain
{
public:
paintmain();
};
#endif // PAINTMAIN_H
|
4e5eecdfebd3130641c9c50ce05ebe12a5f13127 | 3dbb38734200935f143ea8b6446e9bf32a4a16ee | /Result/Result.h | f50a04a5faad475bc504eeb01be3e1573dac44b9 | [] | no_license | k-t-l-h/TableOfLife | 4624938a2edff3b5de336c30fec5775a5e3971cf | f0ceefe499b9a5a76b9f15201cbd409fa75f0605 | refs/heads/main | 2023-05-14T09:39:37.406622 | 2021-06-03T19:35:43 | 2021-06-03T19:35:43 | 345,408,827 | 0 | 2 | null | 2023-02-17T18:58:24 | 2021-03-07T17:26:42 | C++ | UTF-8 | C++ | false | false | 466 | h | Result.h | #ifndef TABLEOFLIFE_RESULT_H
#define TABLEOFLIFE_RESULT_H
#include <vector>
#include "../Request/Request.h"
#include <boost/uuid/uuid.hpp> // uuid class
#include <boost/uuid/uuid_generators.hpp>
namespace u = boost::uuids;
struct Result {
u::uuid id = u::nil_uuid();
std::vector<size_t> result;
std::vector<Classes> classes; // все занятия, а вних id группы
size_t ClassesNumber;
};
#endif //TABLEOFLIFE_RESULT_H
|
4a29c3a34dc54a45aa48df9e9663925fc0350f0e | 9743f2a74d8abda79a3d7524bb38fb9426d37f4e | /107_1高中職程式設計基礎課程(臺北科技大學)/107_1高中職程式設計基礎課程練習(臺北科技大學)/(Topic 0~4)-練習4(6).cpp | cec144842f754dd6f6f410d15878aceb4cc04e6d | [] | no_license | linyuting26/Programming | db455aad6f5809f1b70183bcc87b730552a6cfd6 | 21708519eec015139ed95f0edcb9a9646f37715f | refs/heads/master | 2020-12-17T07:22:19.575411 | 2020-02-22T06:08:31 | 2020-02-22T06:08:31 | 235,275,761 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 296 | cpp | (Topic 0~4)-練習4(6).cpp | #include <iostream>
int main()
{
int i = 0;
std::cin>> i;
if(i>30) std::cout<< "Out of range\n";
else
{
int Ans = 1;
for(int j=1;j<=i;j++)
{
Ans*=2;
}
std::cout<< Ans << std::endl;
}
return 0;
}
|
aa46b57bede9fe273882f36275894bb6fb89c6a2 | a9417ee33272c3f60eba5e8a2d9837d8e05a0ab8 | /src/robot/system/encoders/ARIGEncodeurs.cpp | f77b68a7b05d1c1db277e0cb7d9275115635e954 | [] | no_license | ARIG-Robotique/robot-system-lib | 6d642f1968068a2ea04e6e4aab5fdadaa80040e2 | dece6b5220a6e464982b1e2b68e9a40b0816266c | refs/heads/master | 2021-01-18T23:01:33.393872 | 2017-05-31T11:39:12 | 2017-05-31T11:39:12 | 20,418,779 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,292 | cpp | ARIGEncodeurs.cpp | /*
* ARIGEncodeurs.cpp
*
* Created on: 22 déc. 2012
* Author: mythril
*/
#include "ARIGEncodeurs.h"
#include <Wire.h>
/*
* Constructeur
*/
ARIGEncodeurs::ARIGEncodeurs(byte addressGauche, byte addressDroit) : AbstractEncodeurs() {
this->addressGauche = addressGauche;
this->addressDroit = addressDroit;
}
ARIGEncodeurs::~ARIGEncodeurs() {
}
/*
* Reset des valeurs codeurs
*/
void ARIGEncodeurs::reset() {
#ifdef DEBUG_MODE
Serial.println(" * Reset carte codeur droit");
#endif
lectureDroit();
#ifdef DEBUG_MODE
Serial.println(" * Reset carte codeur gauche");
#endif
lectureGauche();
}
/*
* Lecture de la valeur du codeur de la roue gauche
*/
double ARIGEncodeurs::lectureGauche() {
return lectureData(addressGauche);
}
/*
* Lecture de la valeur du codeur de la roue droite
*/
double ARIGEncodeurs::lectureDroit() {
return lectureData(addressDroit);
}
/*
* Fonction de lecture depuis une des carte codeurs.
* 1) On envoi la commande de lecture.
* 2) On demande la récupération de 4 octets.
*/
int ARIGEncodeurs::lectureData(int address) {
// Demande des infos sur 2 octets (int sur 2 byte avec un AVR 8 bits)
int value = 0;
Wire.requestFrom(address, 2);
while(Wire.available()){
value = value << 8;
value += Wire.read();
}
return value;
}
|
b520803765fcca4b877e2793afea66beac5f0e84 | 794ec36417d1f5fe9f8a8dfefee17169ba346447 | /NYOJ/0275.cpp | 0922afdd3859c8c87960d0c4ecd87c75fabb1139 | [] | no_license | riba2534/My_ACM_Code | 1d2f7dacb50f7e9ed719484419b3a7a41ba407cf | fa914ca98ad0794073bc1ccac8ab7dca4fe13f25 | refs/heads/master | 2020-03-24T01:19:19.889558 | 2019-03-11T03:01:09 | 2019-03-11T03:01:09 | 142,331,120 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 462 | cpp | 0275.cpp |
#include <stdio.h>
int main()
{
int a[2000], i;
long long n;
while (scanf("%lld", &n)!=EOF)
{
if(n==0)
printf("0");
else
{
i = 0;
while(n)
{
a[i++] = n % 2;
n = n / 2;
}
while(i--)
{
printf("%d",a[i]);
}
}
printf("\n");
}
} |
9dc4abd6ead59b8e1b26edca8fce742db2bd10f2 | f9d6fbdff669e642f7af458e357e35c5dea0c422 | /a5-collections/queuecoll.h | 9df7dca113fae51610e7b7c111026979a775c8bc | [] | no_license | shpp-epustovit/cs-b | 22d3d42a154b5ba82e36f1f09926180fe75102b9 | 2ce7833fea8d91ff84752f7856198d5787181be3 | refs/heads/master | 2021-01-10T03:17:14.403595 | 2016-04-03T17:51:16 | 2016-04-03T17:51:16 | 54,255,789 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,374 | h | queuecoll.h | #ifndef QUEUECOLL_H
#define QUEUECOLL_H
#include <iostream>
using namespace std;
/**
* Class QueueCOLL implements queue of ValueType elements
* based on the linked list
*/
template <typename ValueType>
class QueueCOLL{
// public functions prototypes
public:
QueueCOLL();
virtual ~QueueCOLL();
ValueType dequeue();
void enqueue (ValueType);
void clear();
int size() const;
bool isQueueEmpty() const;
ValueType initial() const;
// private functions protypes
private:
/**
* The ListNode struct for elements of the queue
*/
struct ListNode{
ValueType value;
ListNode* nextPtr;
};
ListNode* firstPtr; // a pointer to the first node
ListNode* lastPtr; // a pointer to the last node
int count; // counter for queue elements
};
/**
*Constructor: QueueCOLL
* Initializes new empty queue
*/
template <typename ValueType>
QueueCOLL<ValueType> :: QueueCOLL(){
count = 0;
firstPtr = lastPtr = NULL;
}
/**
*Destructor: QueueCOLL
* Frees memory
*/
template <typename ValueType>
QueueCOLL<ValueType> :: ~QueueCOLL(){
for(int i = 0; i < count; i++){
ListNode *tmpPtr = firstPtr;
firstPtr = firstPtr->nextPtr;
delete tmpPtr;
}
}
/**
*Function: dequeue
* Usage: value = queue.dequeue();
* -------------------------------
* remove first element of the queue
* end return it's value
*/
template<typename ValueType>
ValueType QueueCOLL<ValueType> :: dequeue(){
if (count == 0){
cout << "Queue is empty" << endl;
exit(1);
}
ListNode *tmpPtr = firstPtr;
firstPtr = firstPtr->nextPtr;
ValueType tmpValue = tmpPtr->value;
count--;
delete tmpPtr;
return tmpValue;
}
/**
*Function: enqueue
* Usage: queue.enqueue(value)
* ---------------------------
* Adds new element to the queue
*/
template<typename ValueType>
void QueueCOLL<ValueType> :: enqueue(ValueType newValue){
ListNode *newPtr = new ListNode;
newPtr->value = newValue;
newPtr->nextPtr = NULL;
if(firstPtr == NULL) { //if queue is empty
firstPtr = lastPtr = newPtr;
} else {
lastPtr->nextPtr = newPtr;
lastPtr = newPtr;
}
count++;
}
/**
*Function: clear
* Usage: queue.clear()
* ---------------------
* remove all elements of the queue
*/
template<typename ValueType>
void QueueCOLL<ValueType> :: clear(){
for(int i = 0; i < count; i++){
ListNode *tmpPtr = firstPtr;
firstPtr = firstPtr->nextPtr;
delete tmpPtr;
}
count = 0;
}
/**
*Function: size
* Usage: int size = queue.size()
* ------------------------------
* return current number of the elements
* of the queue
*/
template<typename ValueType>
int QueueCOLL<ValueType> :: size() const{
return count;
}
/**
*Function: isQueueEmpty
* Usage: if(queue.isQueueEmpty)
* --------------------------
* Returns true if queue is empty
*/
template<typename ValueType>
bool QueueCOLL<ValueType> :: isQueueEmpty() const{
return count == 0;
}
/**
*Function: initial
* Usage: value = queue.initial()
* -----------------------------
* Return value of the first element without removing it
*/
template<typename ValueType>
ValueType QueueCOLL<ValueType> :: initial() const{
return firstPtr->value;
}
#endif // QUEUECOLL
|
8a3df7d1764a1ac367c30fba35e069c0125f42dd | a548daec11dad02c401d8c9c167d083847fffc71 | /arnessrc/LQToTopMuHFLeptonPreselectionModule.cxx | 16886874fd8f64f828b3b95d9d7b30dd3ef8f4ff | [] | no_license | llpwilhelm/vectorlikeT | 4dd4548506c2470f3f2c6087ea85e39d869f817f | 30b5dbb96e9d6ba8440944867e0a578492c495d9 | refs/heads/master | 2020-07-07T00:51:05.750052 | 2019-08-19T14:13:33 | 2019-08-19T14:13:33 | 203,191,362 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,261 | cxx | LQToTopMuHFLeptonPreselectionModule.cxx | #include <iostream>
#include <memory>
#include "UHH2/core/include/AnalysisModule.h"
#include "UHH2/core/include/Event.h"
#include "UHH2/common/include/CommonModules.h"
#include "UHH2/common/include/CleaningModules.h"
#include "UHH2/common/include/JetCorrections.h"
#include "UHH2/common/include/JetHists.h"
#include "UHH2/common/include/ElectronHists.h"
#include "UHH2/common/include/ElectronIds.h"
#include "UHH2/common/include/MuonHists.h"
#include "UHH2/common/include/MuonIds.h"
#include "UHH2/common/include/EventHists.h"
#include "UHH2/common/include/LuminosityHists.h"
#include "UHH2/common/include/LumiSelection.h"
#include "UHH2/common/include/NSelections.h"
#include "UHH2/LQToTopMu/include/LQToTopMuSelections.h"
#include "UHH2/LQToTopMu/include/LQToTopMuPreselectionHists.h"
#include "UHH2/common/include/PrintingModules.h"
#include "UHH2/common/include/TriggerSelection.h"
#include "UHH2/common/include/MCWeight.h"
#include "UHH2/common/include/AdditionalSelections.h"
#include "UHH2/LQToTopMu/include/LQToTopMuModules.h"
#include "UHH2/LQToTopMu/include/HT2dHists.h"
#include "UHH2/LQToTopMu/include/LQToTopMuEfficiencyHists.h"
using namespace std;
using namespace uhh2;
namespace uhh2examples {
class LQToTopMuHFLeptonPreselectionModule: public AnalysisModule {
public:
explicit LQToTopMuHFLeptonPreselectionModule(Context & ctx);
virtual bool process(Event & event) override;
private:
unique_ptr<CommonModules> common;
// declare the Selections to use.
unique_ptr<Selection> njet_sel, nmuon_sel, nele_sel, trigger_sel1, trigger_sel2;
// store the Hists collection as member variables.
unique_ptr<Hists> h_nocuts, h_jets_nocuts, h_ele_nocuts, h_mu_nocuts, h_event_nocuts, h_topjets_nocuts, h_lumi_nocuts,
h_trigger, h_jets_trigger, h_ele_trigger, h_mu_trigger, h_event_trigger, h_topjets_trigger, h_lumi_trigger,
h_lumi, h_jets_lumi, h_ele_lumi, h_mu_lumi, h_event_lumi, h_topjets_lumi, h_lumi_lumi,
h_cleaner, h_jets_cleaner, h_ele_cleaner, h_mu_cleaner, h_event_cleaner, h_topjets_cleaner, h_lumi_cleaner,
h_1mu, h_jets_1mu, h_ele_1mu, h_mu_1mu, h_event_1mu, h_topjets_1mu, h_lumi_1mu,
h_1ele, h_jets_1ele, h_ele_1ele, h_mu_1ele, h_event_1ele, h_topjets_1ele, h_lumi_1ele,
h_2jets, h_jets_2jets, h_ele_2jets, h_mu_2jets, h_event_2jets, h_topjets_2jets, h_lumi_2jets;
MuonId MuId, MuId_Sel;
ElectronId EleId, EleId_Sel;
JetId JetID;
bool is_mc;
};
LQToTopMuHFLeptonPreselectionModule::LQToTopMuHFLeptonPreselectionModule(Context & ctx){
cout << "Hello from LQToTopMuPreselectionModule!" << endl;
for(auto & kv : ctx.get_all()){
cout << " " << kv.first << " = " << kv.second << endl;
}
EleId = AndId<Electron>(ElectronID_Spring16_tight_noIso, PtEtaCut(30.0, 2.4)); //IDs without any Iso statement for cleaners.
MuId = AndId<Muon>(MuonIDTight(), PtEtaCut(30.0, 2.4));
EleId_Sel = AndId<Electron>(ElectronID_Spring16_tight, PtEtaCut(30.0, 2.4)); // IDs for selections: going to require ==1 iso e and ==1 iso mu
MuId_Sel = AndId<Muon>(MuonIDTight(), PtEtaCut(30.0, 2.4),MuonIso(0.15));
JetID = AndId<Jet>(PtEtaCut(30.0, 2.4), JetPFID(JetPFID::WP_LOOSE));
is_mc = ctx.get("dataset_type") == "MC";
common.reset(new CommonModules());
common->switch_jetlepcleaner(true);
common->set_electron_id(EleId);
common->set_muon_id(MuId);
common->set_jet_id(JetID);
common->init(ctx);
// 2. set up selections
//Preselection
trigger_sel1.reset(new TriggerSelection("HLT_IsoMu24_v*"));
trigger_sel2.reset(new TriggerSelection("HLT_IsoTkMu24_v*"));
njet_sel.reset(new NJetSelection(2, -1));
nmuon_sel.reset(new NMuonSelection(1, 1, MuId_Sel));
nele_sel.reset(new NElectronSelection(1, 1, EleId_Sel));
// 3. Set up Hists classes:
h_nocuts.reset(new LQToTopMuPreselectionHists(ctx, "NoCuts"));
h_jets_nocuts.reset(new JetHists(ctx, "Jets_NoCuts"));
h_ele_nocuts.reset(new ElectronHists(ctx, "Ele_NoCuts"));
h_mu_nocuts.reset(new MuonHists(ctx, "Mu_NoCuts"));
h_event_nocuts.reset(new EventHists(ctx, "Event_NoCuts"));
h_topjets_nocuts.reset(new TopJetHists(ctx, "Topjets_NoCuts"));
h_lumi_nocuts.reset(new LuminosityHists(ctx, "Lumi_NoCuts"));
h_trigger.reset(new LQToTopMuPreselectionHists(ctx, "Trigger"));
h_jets_trigger.reset(new JetHists(ctx, "Jets_Trigger"));
h_ele_trigger.reset(new ElectronHists(ctx, "Ele_Trigger"));
h_mu_trigger.reset(new MuonHists(ctx, "Mu_Trigger"));
h_event_trigger.reset(new EventHists(ctx, "Event_Trigger"));
h_topjets_trigger.reset(new TopJetHists(ctx, "Topjets_Trigger"));
h_lumi_trigger.reset(new LuminosityHists(ctx, "Lumi_Trigger"));
h_cleaner.reset(new LQToTopMuPreselectionHists(ctx, "Cleaner"));
h_jets_cleaner.reset(new JetHists(ctx, "Jets_Cleaner"));
h_ele_cleaner.reset(new ElectronHists(ctx, "Ele_Cleaner"));
h_mu_cleaner.reset(new MuonHists(ctx, "Mu_Cleaner"));
h_event_cleaner.reset(new EventHists(ctx, "Event_Cleaner"));
h_topjets_cleaner.reset(new TopJetHists(ctx, "Topjets_Cleaner"));
h_lumi_cleaner.reset(new LuminosityHists(ctx, "Lumi_Cleaner"));
h_1mu.reset(new LQToTopMuPreselectionHists(ctx, "1Mu"));
h_jets_1mu.reset(new JetHists(ctx, "Jets_1Mu"));
h_ele_1mu.reset(new ElectronHists(ctx, "Ele_1Mu"));
h_mu_1mu.reset(new MuonHists(ctx, "Mu_1Mu"));
h_event_1mu.reset(new EventHists(ctx, "Event_1Mu"));
h_topjets_1mu.reset(new TopJetHists(ctx, "Topjets_1Mu"));
h_lumi_1mu.reset(new LuminosityHists(ctx, "Lumi_1Mu"));
h_1ele.reset(new LQToTopMuPreselectionHists(ctx, "1Ele"));
h_jets_1ele.reset(new JetHists(ctx, "Jets_1Ele"));
h_ele_1ele.reset(new ElectronHists(ctx, "Ele_1Ele"));
h_mu_1ele.reset(new MuonHists(ctx, "Mu_1Ele"));
h_event_1ele.reset(new EventHists(ctx, "Event_1Ele"));
h_topjets_1ele.reset(new TopJetHists(ctx, "Topjets_1Ele"));
h_lumi_1ele.reset(new LuminosityHists(ctx, "Lumi_1Ele"));
h_2jets.reset(new LQToTopMuPreselectionHists(ctx, "2Jets"));
h_jets_2jets.reset(new JetHists(ctx, "Jets_2Jets"));
h_ele_2jets.reset(new ElectronHists(ctx, "Ele_2Jets"));
h_mu_2jets.reset(new MuonHists(ctx, "Mu_2Jets"));
h_event_2jets.reset(new EventHists(ctx, "Event_2Jets"));
h_topjets_2jets.reset(new TopJetHists(ctx, "Topjets_2Jets"));
h_lumi_2jets.reset(new LuminosityHists(ctx, "Lumi_2Jets"));
}
bool LQToTopMuHFLeptonPreselectionModule::process(Event & event) {
h_nocuts->fill(event);
h_jets_nocuts->fill(event);
h_ele_nocuts->fill(event);
h_mu_nocuts->fill(event);
h_event_nocuts->fill(event);
h_topjets_nocuts->fill(event);
h_lumi_nocuts->fill(event);
// trigger
if(!(trigger_sel1->passes(event) || trigger_sel2->passes(event))) return false;
h_trigger->fill(event);
h_jets_trigger->fill(event);
h_ele_trigger->fill(event);
h_mu_trigger->fill(event);
h_event_trigger->fill(event);
h_topjets_trigger->fill(event);
h_lumi_trigger->fill(event);
bool pass_common = common->process(event);
if(!pass_common) return false;
h_cleaner->fill(event);
h_jets_cleaner->fill(event);
h_ele_cleaner->fill(event);
h_mu_cleaner->fill(event);
h_event_cleaner->fill(event);
h_topjets_cleaner->fill(event);
h_lumi_cleaner->fill(event);
if(!nmuon_sel->passes(event)) return false;
h_1mu->fill(event);
h_jets_1mu->fill(event);
h_ele_1mu->fill(event);
h_mu_1mu->fill(event);
h_event_1mu->fill(event);
h_topjets_1mu->fill(event);
h_lumi_1mu->fill(event);
if(!nele_sel->passes(event)) return false;
h_1ele->fill(event);
h_jets_1ele->fill(event);
h_ele_1ele->fill(event);
h_mu_1ele->fill(event);
h_event_1ele->fill(event);
h_topjets_1ele->fill(event);
h_lumi_1ele->fill(event);
if(!njet_sel->passes(event)) return false;
h_2jets->fill(event);
h_jets_2jets->fill(event);
h_ele_2jets->fill(event);
h_mu_2jets->fill(event);
h_event_2jets->fill(event);
h_topjets_2jets->fill(event);
h_lumi_2jets->fill(event);
return true;
}
UHH2_REGISTER_ANALYSIS_MODULE(LQToTopMuHFLeptonPreselectionModule)
}
|
42ac8ddec544b23d3e81f90a90ba0bcab0b073a8 | 1322040b4b90b91a9011fa9adc751fcf92ae9bf7 | /HW11/HW11T1/HW11T1/test.cpp | 346906057a4313b2b4a930e05f892c54497136f8 | [] | no_license | MihailBeloshapkin/HWprogramms | 2165e73a660eba4fe73c11a814c349e93443a5c7 | 9e05078e9563f8345b9c4ac2432d3a741bfb3f71 | refs/heads/master | 2021-07-22T08:18:01.119158 | 2020-09-18T11:16:02 | 2020-09-18T11:16:02 | 216,316,992 | 5 | 0 | null | 2020-09-18T11:16:03 | 2019-10-20T06:20:51 | C++ | UTF-8 | C++ | false | false | 2,066 | cpp | test.cpp | #include "test.h"
#include "list.h"
#include "alg.h"
#include <stdio.h>
List** arrayWithRightValues()
{
List** rightArray = createArrayOfLists(3);
List* firstList = nullptr;
List* secondList = nullptr;
List* thirdList = nullptr;
addToListBack(&firstList, 0);
addToListBack(&firstList, 3);
addToListBack(&firstList, 6);
addToListBack(&secondList, 2);
addToListBack(&secondList, 1);
addToListBack(&thirdList, 4);
addToListBack(&thirdList, 5);
rightArray[0] = firstList;
rightArray[1] = secondList;
rightArray[2] = thirdList;
return rightArray;
}
bool compareArraysOfList(List** firstArray, List** secondArray, int sizeOfArray)
{
for (int index = 0; index < sizeOfArray; index++)
{
if (!compareLists(firstArray[index], secondArray[index]))
{
return false;
}
}
return true;
}
bool test()
{
FILE* testFile = fopen("test.txt", "r");
int countOfCities = 0;
fscanf(testFile, "%i", &countOfCities);
int** testGraph = createMatrix(countOfCities);
int countOfRoads = 0;
fscanf(testFile, "%i", &countOfRoads);
for (int index = 0; index < countOfRoads; index++)
{
int firstVertex = 0;
int secondVertex = 0;
int lengthOfRoad = 0;
fscanf(testFile, "%i", &firstVertex);
fscanf(testFile, "%i", &secondVertex);
fscanf(testFile, "%i", &lengthOfRoad);
testGraph[firstVertex][secondVertex] = lengthOfRoad;
testGraph[secondVertex][firstVertex] = lengthOfRoad;
}
int countOfCapitals = 0;
fscanf(testFile, "%i", &countOfCapitals);
int* capitals = new int[countOfCapitals] {};
for (int index = 0; index < countOfCapitals; index++)
{
int capital = 0;
fscanf(testFile, "%i", &capital);
capitals[index] = capital;
}
fclose(testFile);
List** listsOfCities = game(testGraph, countOfCities, capitals, countOfCapitals);
List** rightArray = arrayWithRightValues();
bool resuilt = compareArraysOfList(listsOfCities, rightArray, countOfCapitals);
deleteArrayOfLists(listsOfCities, countOfCapitals);
deleteArrayOfLists(rightArray, countOfCapitals);
deleteMatrix(testGraph, countOfCities);
delete[] capitals;
return resuilt;
} |
f80c47dec3e39eb420e5abd188ff710016196432 | 3a2f616dcc2c098958fe3685f62808b00781c73b | /src/strand.hpp | a0f9e71a40e91f68974358ef36aa8b50f04b1b03 | [
"MIT"
] | permissive | shark2202/php-asio | 51b601ac2a97c2bed08af24e76534161e6bab29f | be0b4822e944689a4a9b4b105f397bc2326c422f | refs/heads/master | 2021-09-11T21:00:13.109473 | 2018-04-01T08:35:05 | 2018-04-01T08:35:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,429 | hpp | strand.hpp | /**
* php-asio/strand.hpp
*
* @author CismonX<admin@cismon.net>
*/
#pragma once
#include "common.hpp"
#include "base.hpp"
#define PHP_ASIO_DISPATCH_CALLBACK(meth) \
zval* callback; \
zval* argument = nullptr; \
ZEND_PARSE_PARAMETERS_START(1, 2) \
Z_PARAM_ZVAL(callback) \
Z_PARAM_OPTIONAL \
Z_PARAM_ZVAL(argument) \
ZEND_PARSE_PARAMETERS_END(); \
ZVAL_PTR_INIT(cb); \
ZVAL_COPY(cb, callback); \
ZVAL_PTR_INIT(args); \
if (argument) \
ZVAL_COPY(args, argument); \
else \
ZVAL_NULL(args); \
meth([this, cb, args]() { \
INIT_RETVAL(); \
call_user_function(CG(function_table), nullptr, cb, PASS_RETVAL, 1, args); \
CORO_REGISTER(retval); \
zval_ptr_dtor(cb); \
zval_ptr_dtor(args); \
efree(cb); \
efree(args); \
#ifdef ENABLE_STRAND
namespace asio
{
/// Wrapper for Boost.Asio strand.
/// Provides serialized handler execution.
class strand : public base
{
/// Boost.Asio strand instance.
boost::asio::strand strand_;
public:
/// Constructor.
explicit strand(
boost::asio::io_service& io_service
) : base(io_service), strand_(io_service) {}
/// Deleted default constructor.
strand() = delete;
/// Deleted copy constructor.
strand(const strand&) = delete;
/* {{{ proto void Strand::dispatch(callable callback, [mixed argument]);
* Request the strand to invoke the given handler. */
P3_METHOD_DECLARE(dispatch);
/* }}} */
/* {{{ proto void Strand::post(callable callback, [mixed argument]);
* Request the strand to invoke the given handler. */
P3_METHOD_DECLARE(post);
/* }}} */
/* {{{ proto bool Strand::runningInThisThread(void);
* Determine whether the strand is running in the current thread. */
P3_METHOD_DECLARE(runningInThisThread) const;
/* }}} */
/* {{{ proto WrappedHandler wrap([callable callback]);
* Create a new handler that automatically dispatches the wrapped handler on the strand. */
P3_METHOD_DECLARE(wrap);
/* }}} */
/// Returns the wrapped Boost.Asio strand.
boost::asio::strand* implmentation()
{
return &strand_;
}
PHP_ASIO_CE_DECLARE();
};
}
#endif // ENABLE_STRAND
|
a71c9bff2945784677ff214025b0f51f9095af70 | 791faf5e1bb8db6ad1765b356304ccb1e04454fb | /HackerRank/Graph/Breadth First Search - Shortest Reach.cpp | 589a7be47e10b8c6b7cc9dde1af645322b1a9604 | [] | no_license | ecojuntak/competitive-programming | 77d5977b59c2ea19d0f3e366ce2b080332d6ac53 | 2d5522d75cf3d2652cf34a040752c64047319022 | refs/heads/master | 2021-01-25T09:45:11.388531 | 2018-02-28T17:57:44 | 2018-02-28T17:57:44 | 123,317,766 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,156 | cpp | Breadth First Search - Shortest Reach.cpp | #include <bits/stdc++.h>
using namespace std;
int main(){
int q,m,n,x,u,v;
cin>>q;
while(q--){
cin>>m>>n;
vector< vector<int> > peta(m+1);
for(int i=0;i<n;i++){
cin>>u>>v;
peta[u].push_back(v);
peta[v].push_back(u);
}
cin>>x;
queue<int> q;
int dp[m+1] = {0};
int langkah = 0;
q.push(x);
dp[x] = 0;
while(!q.empty()){
int s = q.front();
q.pop();
//cout<<"yang di proses "<<s<<" dengan langkah "<<dp[s]<<endl;
for(int i=0;i<peta[s].size();i++){
if(dp[peta[s][i]] !=0) continue;
dp[peta[s][i]] = dp[s]+1;
//cout<<"\t acc "<<peta[s][i]<<" langkah "<<dp[peta[s][i]]<<endl;
q.push(peta[s][i]);
}
}
for(int i=1; i<=m ;i++){
if(i==x) continue;
else if(dp[i] != 0) cout<<dp[i]*6;
else cout<<"-1";
if(i!=m) printf(" ");
}
printf("\n");
}
return 0;
}
|
e8239313fda0355e7d648030bbc346cf4102ff2d | 4fd6e6092188f3325e134db2ac087da6f827fb80 | /ses.hpp | 64ed0327e63021d7bb8956198eb1392411f004a6 | [] | no_license | kisyr/ses | bde8493a7cbe8b2c153b4b06e56890a5b3ef3bb9 | b85146c1621800fa71af2a01a2c8cf8d529c2e5c | refs/heads/master | 2021-01-09T20:07:52.182792 | 2016-08-16T17:05:50 | 2016-08-16T17:05:50 | 65,772,681 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,719 | hpp | ses.hpp | #ifndef SES_HPP
#define SES_HPP
#include <vector>
namespace ses {
namespace detail {
/**
* Basic vector implementation for inheritance.
*/
template <class T>
struct Vector {
size_t size() const {
return vector.size();
}
bool empty() const {
return vector.empty();
}
typename std::vector<T>::iterator begin() {
return vector.begin();
}
typename std::vector<T>::iterator end() {
return vector.end();
}
typename std::vector<T>::const_iterator begin() const {
return vector.begin();
}
typename std::vector<T>::const_iterator end() const {
return vector.end();
}
void clear() {
vector.clear();
}
T& operator[](size_t index) {
return vector[index];
}
const T& operator[](size_t index) const {
return vector[index];
}
std::vector<T> vector;
};
template <class T>
struct AutoVector : Vector<T> {
T& operator[](size_t index) {
if (index + 1 > vector.size()) {
vector.resize(index + 1);
}
return vector[index];
}
};
template <class T>
struct RecycleVector : Vector<T> {
};
/**
* Type Family templates for auto incrementing a
* inheriting type's id().
*/
template <class T>
struct Family {
static size_t& counter() {
static size_t counter_ = 0;
return counter_;
}
};
template <class Family, class T>
struct Type {
static size_t& id() {
static size_t id_ = Family::counter()++;
return id_;
}
};
/**
* Templates for generating lists of type ids from
* variadic template parameters.
*/
template <class... Types>
void make_type_list(std::vector<size_t>& list) {
list.insert(list.end(), {Types::id()...});
}
template <class... Types>
struct TypeList {
static std::vector<size_t> list() {
std::vector<size_t> list_;
make_type_list<Types...>(list_);
return list_;
}
};
} // namespace detail
/**
* Component.
*/
struct ComponentFamily : detail::Family<ComponentFamily> {};
struct ComponentBase {
virtual ~ComponentBase() {}
};
template <class T>
struct Component : detail::Type<ComponentFamily, T>, ComponentBase {};
/**
* System.
*/
struct SystemFamily : detail::Family<SystemFamily> {};
struct SystemBase {
SystemBase(const std::vector<size_t>& includes, const std::vector<size_t>& excludes) :
includes(includes), excludes(excludes) {}
virtual ~SystemBase() {}
std::vector<size_t> includes;
std::vector<size_t> excludes;
};
template <class... Types>
struct Includes : detail::TypeList<Types...> {};
template <class... Types>
struct Excludes : detail::TypeList<Types...> {};
template <class T, class IncludeList = Includes<>, class ExcludeList = Excludes<>>
struct System : detail::Type<SystemFamily, T>, SystemBase {
System() : SystemBase(IncludeList::list(), ExcludeList::list()) {}
};
} // namespace ses
#endif
|
e545df873b604e6cbe55282f6fd3c842595a5c68 | 36c0e07fba5319f186a135a41f2ecd2445656894 | /tests/elab_only/test_array_of_ptr.cpp | 1e896a6c2f0f71c506040e21ad2e1a905d2ed6e0 | [
"LLVM-exception",
"Apache-2.0"
] | permissive | mfkiwl/systemc-compiler | 5f53c3dbd52439997289b3947d863d9d8b3c90b4 | 96d94cac721224745cffe3daaee35c406af36e9e | refs/heads/main | 2023-06-12T06:39:48.707703 | 2021-07-08T11:10:41 | 2021-07-08T11:10:41 | 385,031,718 | 1 | 0 | NOASSERTION | 2021-07-11T19:05:42 | 2021-07-11T19:05:42 | null | UTF-8 | C++ | false | false | 994 | cpp | test_array_of_ptr.cpp | /******************************************************************************
* Copyright (c) 2020, Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception.
*
*****************************************************************************/
//
// Created by ripopov on 3/28/18.
//
#include <systemc.h>
#include <typeinfo>
struct bundle : sc_modular_interface {
sc_vector<sc_signal<int>> **vecptr;
SC_CTOR(bundle) {
vecptr = sc_new_array< sc_vector<sc_signal<int>> *> (2);
vecptr[0] = new sc_vector<sc_signal<int>>("vecptr0",2);
vecptr[1] = new sc_vector<sc_signal<int>>("vecptr1",2);
}
};
struct top : sc_module {
bundle **vecarray;
SC_CTOR(top) {
vecarray = sc_new_array<bundle*>(2);
vecarray[0] = new bundle("bundle0");
vecarray[1] = new bundle("bundle1");
}
};
int sc_main(int argc, char** argv)
{
top top_inst{"top_inst"};
sc_start();
return 0;
}
|
9c0357740c80cfa2390f7f7ea0c0e94499c4f0fd | 3f143ff2a2bf577062c5d719128625fe3513715f | /app/src/main/cpp/dns.cpp | 926ad6d95baf050ce3411489bb075b975ea81101 | [
"MIT",
"Apache-2.0",
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | sbnewsthailand/DPITunnel | 3d155548b9d88ca0c9a59622ebf0665eda456b63 | 675db132cea249e143ab25c47582683918d719cd | refs/heads/master | 2022-12-14T05:26:02.920277 | 2022-03-11T09:25:50 | 2022-03-11T09:25:50 | 270,858,654 | 0 | 0 | null | 2020-06-08T23:55:19 | 2020-06-08T23:55:19 | null | UTF-8 | C++ | false | false | 6,052 | cpp | dns.cpp | #include "dpi-bypass.h"
#include "dns.h"
#include "hostlist.h"
extern struct Settings settings;
extern JavaVM* javaVm;
extern jclass utils_class;
extern jclass localdnsserver_class;
int resolve_host_over_doh(std::string host, std::string & ip)
{
std::string log_tag = "CPP/resolve_host_over_doh";
// Make request to DoH with Java code
// Get JNIEnv
JNIEnv* jni_env;
javaVm->GetEnv((void**) &jni_env, JNI_VERSION_1_6);
// Attach JNIEnv
javaVm->AttachCurrentThread(&jni_env, NULL);
// Find Java method
jmethodID utils_make_doh_request = jni_env->GetStaticMethodID(utils_class, "makeDOHRequest", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;");
if(utils_make_doh_request == NULL)
{
javaVm->DetachCurrentThread();
log_error(log_tag.c_str(), "Failed to find makeDOHRequest method");
return -1;
}
// Since we have some doh servers, we need to use they by turns
std::string response_string;
char delimiter = '\n';
std::string doh_server;
std::istringstream stream(settings.dns.dns_doh_servers);
bool isOK = false;
jobject response_string_object;
while (std::getline(stream, doh_server, delimiter))
{
// Call method
jobject doh_server_jstring = jni_env->NewStringUTF(doh_server.c_str());
jobject host_jstring = jni_env->NewStringUTF(host.c_str());
response_string_object = (jstring) jni_env->CallStaticObjectMethod(utils_class, utils_make_doh_request, (jstring) doh_server_jstring, (jstring) host_jstring);
const char * str = jni_env->GetStringUTFChars((jstring) response_string_object, 0);
response_string = std::string(str);
jni_env->ReleaseStringUTFChars((jstring) response_string_object, str);
// Release doh_server and host strings
jni_env->DeleteLocalRef(doh_server_jstring);
jni_env->DeleteLocalRef(host_jstring);
// Release result string
jni_env->DeleteLocalRef(response_string_object);
if(response_string.empty())
{
log_error(log_tag.c_str(), "Failed to make request to DoH server. Trying again...");
} else {
isOK = true;
break;
}
}
// Detach thread
javaVm->DetachCurrentThread();
if(!isOK)
{
log_error(log_tag.c_str(), "No request to the DoH servers was successful. Can't process client");
return -1;
}
ip = response_string;
return 0;
}
int resolve_host_over_dns(const std::string& host, std::string & ip)
{
std::string log_tag = "CPP/resolve_host_over_dns";
struct addrinfo hints, *res;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
int err;
if((err = getaddrinfo(host.c_str(), NULL, &hints, &res)) != 0)
{
log_error(log_tag.c_str(), "Failed to get host address. Error: %s, Errno: %s", gai_strerror(err), strerror(errno));
return -1;
}
while(res)
{
char addrstr[100];
inet_ntop(res->ai_family, res->ai_addr->sa_data, addrstr, sizeof(addrstr));
if(res->ai_family == AF_INET) // If current address is ipv4 address
{
void *ptr = &((struct sockaddr_in *) res->ai_addr)->sin_addr;
inet_ntop(res->ai_family, ptr, &ip[0], ip.size());
size_t first_zero_char = ip.find(' ');
ip = ip.substr(0, first_zero_char);
// Free memory
freeaddrinfo(res);
return 0;
}
res = res->ai_next;
}
// Free memory
freeaddrinfo(res);
return -1;
}
int resolve_host(const std::string& host, std::string & ip, bool hostlist_condition)
{
if (host.empty())
return -1;
// Check if host is IP
struct sockaddr_in sa;
int result = inet_pton(AF_INET, host.c_str(), &sa.sin_addr);
if(result != 0)
{
ip = host;
return 0;
}
if(settings.dns.is_use_doh && (settings.hostlist.is_use_hostlist ? (settings.dns.is_use_doh_only_for_site_in_hostlist ? hostlist_condition : true) : true))
{
return resolve_host_over_doh(host, ip);
}
else
{
return resolve_host_over_dns(host, ip);
}
}
int reverse_resolve_host(std::string & host)
{
std::string log_tag = "CPP/reverse_resolve_host";
// Check if host is IP
struct sockaddr_in sa;
int result = inet_pton(AF_INET, host.c_str(), &sa.sin_addr);
if(settings.other.is_use_vpn && result != 0)
{
// Get JNIEnv
JNIEnv* jni_env;
javaVm->GetEnv((void**) &jni_env, JNI_VERSION_1_6);
// Attach JNIEnv
javaVm->AttachCurrentThread(&jni_env, NULL);
// Find Java method
jmethodID localdnsserver_get_hostname = jni_env->GetStaticMethodID(localdnsserver_class, "getHostname", "(Ljava/lang/String;)Ljava/lang/String;");
if(localdnsserver_get_hostname == NULL)
{
javaVm->DetachCurrentThread();
log_error(log_tag.c_str(), "Failed to find getHostname method");
return -1;
}
// Call Java method
jobject host_jstring = jni_env->NewStringUTF(host.c_str());
jobject response_string_object = (jstring) jni_env->CallStaticObjectMethod(localdnsserver_class, localdnsserver_get_hostname, (jstring) host_jstring);
const char * str = jni_env->GetStringUTFChars((jstring) response_string_object, 0);
std::string buffer(str);
jni_env->ReleaseStringUTFChars((jstring) response_string_object, str);
jni_env->DeleteLocalRef(host_jstring);
if(buffer.empty())
{
jni_env->DeleteLocalRef(response_string_object);
javaVm->DetachCurrentThread();
log_error(log_tag.c_str(), "Failed to find hostname to ip");
return -1;
}
host = buffer;
// Release string
jni_env->DeleteLocalRef(response_string_object);
// Detach thread
javaVm->DetachCurrentThread();
}
return 0;
} |
0d9dc016fa2feb3fe431d633dee3cc7d7c195c85 | 5197b4aa7909b40fe90460e668048ab8a2fb661f | /include/all.hpp | 53a69958f4c2a8bbae0433dc5f51fabdd627cc13 | [
"MIT"
] | permissive | rufus-stone/cryptopals | 4c932c3771281f09bc2cd337fc02bf63e33e9656 | 6d57910c42fa0d3e343cbb71e25eb3d5e5e854d2 | refs/heads/master | 2023-07-11T11:03:28.401840 | 2021-07-08T10:35:13 | 2021-07-08T10:35:13 | 253,723,023 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 88 | hpp | all.hpp | #pragma once
#include "set_01/all_challenges.hpp"
#include "set_02/all_challenges.hpp"
|
4a0ec306ca988e586d2213ea2ce8454ad3671333 | 1dda94cd3ba12f9914166b7718f2dd9a00e068ae | /Views/HeroWidget/heroWidget.h | 721d5be3d8d71cfb7863653ee01c5ea796653a91 | [] | no_license | jeremyMontanes/JeuxDeRole | a975f65f26e88ca6ec6e2d6a28058118a4f90a34 | a5bb92dfe81dc6371108e0aaeecef31d5fee7861 | refs/heads/master | 2020-12-15T12:18:47.070848 | 2019-09-23T06:51:43 | 2019-09-23T06:51:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,382 | h | heroWidget.h | #ifndef HEROWIDGET_H
#define HEROWIDGET_H
#include <QWidget>
#include<QVBoxLayout>
#include<QLineEdit>
#include<QGridLayout>
#include "statsWidget.h"
#include "loadEditHeroWidget.h"
#include "featureHeroWidget.h"
#include "bagPackWidget.h"
#include "effectWidget.h"
#include "equipmentWidget.h"
#include "questObjectWidget.h"
#include "skillsWidget.h"
#include "questObjectWidget.h"
#include "sharedDataHero.h"
class HeroWidget : public QWidget
{
Q_OBJECT
private:
QGridLayout* m_pHeroLayout;
StatsWidget* m_pStatsWidget;
FeatureHeroWidget* m_pFeatureHeroWidget;
LoadEditHeroWidget* m_pLoadEditHeroWidget;
BagPackWidget* m_pBagPackWidget;
EffectWidget* m_pEffectWidget;
EquipmentWidget* m_pEquipmentWidget;
SkillsWidget* m_pSkillsWidget;
QuestObjectWidget* m_pQuestWidget;
QPushButton* m_pBtnPreviousHero;
QPushButton* m_pBtnNextHero;
public:
explicit HeroWidget(QWidget *parent = 0);
~HeroWidget();
LoadEditHeroWidget *getLoadEditHeroWidget();
void refreshView(Stats stats, Feature feature, Equipment equipment,
Skills skills, Effect effect, Bag bag, QuestObject questObject);
void refreshEditableView();
QPushButton* getBtnNextHero();
QPushButton* getBtnPreviousHero();
signals:
public slots:
};
#endif // HEROWIDGET_H
|
61458eb0f00f140bf3b72c64bdcce32a102154dc | aa4680154ce78d562042dd0a9a45268fbcc5d57d | /src/client/connected_client_handler.cpp | f4bc9e6a879fd50171c4f151cf00bb407181c891 | [] | no_license | AlfaroMiguel/Self-Interpreter | d93a996f446add1202260c1e3f3d617a15498b12 | 15eb13e2d0d0b2371cee74a09fa45a18497d91c2 | refs/heads/master | 2021-06-11T23:16:24.925222 | 2016-11-29T19:35:50 | 2016-11-29T19:35:50 | 70,025,005 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 306 | cpp | connected_client_handler.cpp | #include "connected_client_handler.h"
ConnectedClientHandler::ConnectedClientHandler
(ClientHandler *client_handler) : EventHandler(client_handler) {}
ConnectedClientHandler::~ConnectedClientHandler() {}
void ConnectedClientHandler::handle(const json &j) const {
client_handler->connected_client();
}
|
f86a66c8cc28477b229c0833790f652192450e57 | 504452e01e35c31896bf5e76b5c26f384dfca74c | /Source/Oubliette/Public/OublietteDoor.h | 2893f80a3b6177abfa0b257303db8526336f3d3b | [] | no_license | ConnorRowe/Oubliette | 81615293806ca736b6fa224d777f268139d41c1a | 9288cfcaa8cc473ebaf019efac9b94643a0dfbdf | refs/heads/master | 2021-06-06T08:35:43.190669 | 2020-05-06T23:32:00 | 2020-05-06T23:32:00 | 132,006,980 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,607 | h | OublietteDoor.h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "CoreUObject/Public/Uobject/ConstructorHelpers.h"
#include "Engine/Classes/Components/StaticMeshComponent.h"
#include "Selectable.h"
#include "Interactable.h"
#include "Oubliette.h"
#include "OublietteDoor.generated.h"
UCLASS()
class OUBLIETTE_API AOublietteDoor : public AActor, public ISelectable, public IInteractable
{
GENERATED_BODY()
public:
AOublietteDoor(const FObjectInitializer& ObjectInitializer);
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, BlueprintNativeEvent)
void Init(const FRotator newRotation, const FVector targetOffset);
UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
UStaticMeshComponent* DoorMesh;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
UStaticMeshComponent* SigilMesh;
UPROPERTY(BlueprintReadWrite)
FVector targetLocation = FVector(0.0f);
UPROPERTY(BlueprintReadWrite)
AOublietteDoor* linkedDoor;
UPROPERTY(BlueprintReadWrite)
ERoomTypeEnum RoomType;
UPROPERTY(BlueprintReadWrite)
FVector DoorColour;
UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
bool UpdateSelection(bool IsSelectedNew);
virtual bool UpdateSelection_Implementation(bool IsSelectedNew) override;
//Interactable interface
UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
void Interact();
virtual void Interact_Implementation() override;
};
|
8f7f3dc1302dec5cfd0469468c55f33650070cff | 5ff9d7c19b019740bf9e7b8055eacb83298d7829 | /Tarea1S2a/system/blockMeshDict | 84737d72ecf6fbec3bf0b7dd552a064bde303bc4 | [] | no_license | RobertoCruzF/Flujos-Turbulentos | a95859ff7f143e0539c552b0771d2964e8e44f87 | e349138cbb56523a1ba8f493e72942233610dcd9 | refs/heads/master | 2022-12-27T20:11:45.445791 | 2020-10-08T20:27:26 | 2020-10-08T20:27:26 | 295,454,939 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,170 | blockMeshDict | /*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 5 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 0.01;
vertices
(
(0 0 0) //vertice 0
(100 0 0) //vertice 1
(100 10 0) //vertice 2
(0 10 0) //vertice 3
(0 0 1) //vertice 4
(100 0 1) //vertice 5
(100 10 1) //vertice 6
(0 10 1) //vertice 7
);
blocks
//hexaedro con los vertices en ese orden
(
hex (0 1 2 3 4 5 6 7)
(50 20 1) // subdiviciones y celdas a lo largo del eje
simpleGrading (1 1 1) //malla homogenea, graduada equispaceadamente
);
edges
(
);
// condiciones de borde
boundary
(
inlet // se define los vertices de la cara de entrada del flujo
{
type patch;
faces
(
(0 4 7 3)
);
}
outlet // define los verices de salida del flujo
{
type patch;
faces
(
(1 2 6 5)
);
}
upperWall // vertices de la pared de arriba
{
type wall;
faces
(
(3 7 6 2)
);
}
lowerWall // vertices de la pared de abajo
{
type wall; //tipo pared
faces
(
(1 5 4 0)
);
}
frontAndBack // cara de al frente y de atras
{
type empty;
faces
(
(0 3 2 1)
(4 5 6 7)
);
}
);
// **************************************************************** // | |
b33d5f6a7bab7fca6eebd16e0cfbdf21377cbb93 | cdc952c1aaac40b204eb1a87144a36581b49c113 | /Example Code/JSON and SocketListenerGroup/messages.h | 2aed9d257391b2703ea9dbb05a629e687587e6ce | [] | no_license | r1k/libr1k | 9ea13a4d5fcb8d243949d15afb285c086cbfebf9 | 2f082ffc94aad27af64b9a830b3fb3bb453c573a | refs/heads/master | 2020-05-07T20:46:32.528345 | 2019-06-28T19:51:53 | 2019-06-28T19:51:53 | 16,492,638 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 319 | h | messages.h | #ifndef MESSAGES_H_
#define MESSAGES_H_
class client_requests_if
{
public:
typedef enum {REFRESH_ALL, GET_PIDS} request_t;
virtual ~client_requests_if() = 0;
request_t get_type() { return type; }
private:
request_t type;
};
class refresh_all_request : public client_requests_if
{
};
#endif /* MESSAGES_H_ */
|
29ad2f86726247962102685b7678e2ecdf439ab3 | efc4b3be9fd74865352809d36e00fbe72eba9b48 | /Client/Renderer/Include/BreadAnimationRun.h | 261b085cbe29f3cb06504636bc7e17ce09493983 | [] | no_license | prodongi/Bread | 3d2cc9b272b71345f777f5dc6e314b657032c530 | 07916d523f6730b4a3c9a8e2babf2f1929c3f6c6 | refs/heads/master | 2020-05-30T16:08:31.844074 | 2013-09-09T13:53:39 | 2013-09-09T13:53:39 | 12,702,338 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 492 | h | BreadAnimationRun.h |
#ifndef _BreadAnimationRun_h_
#define _BreadAnimationRun_h_
#include "BreadAnimationAction.h"
namespace Bread
{
/*
@date 2011.08.17
@auth prodongi
@desc walk action
@todo
*/
class cAnimationRun : public cAnimationAction
{
public:
cAnimationRun();
virtual ~cAnimationRun();
virtual void initialize(cEntityModel* /*entity*/) {};
virtual bool action(float /*elapsedtime*/, cEntityModel* /*entity*/);
virtual void terminate(cEntityModel* /*entity*/) {};
};
}
#endif |
7d8a250a3b890d50e2159c051a875b7feab29b2d | 5876e819f5d0f7fc5d2ae9acc7941229efd72a61 | /serv_tutorial/serv_tutorial_src/src/client.cpp | 4725d67bdc0d1c86e383538f4a45e161dad1cadc | [] | no_license | Kose-i/ros_kinetic_practice | 9cd32032132eec3306b3fe6676ad157b079c9aea | 72e35cc6f46501f62fa69590169437be40fbb860 | refs/heads/master | 2020-03-18T11:15:14.001084 | 2019-03-02T03:30:21 | 2019-03-02T03:30:21 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 709 | cpp | client.cpp | #include "ros/ros.h"
#include "serv_tutorial_srv/Add_three_int.h"
#include <cstdlib>
int main(int argc, char** argv)
{
ros::init(argc, argv, "add_three_int_client");
if (argc != 4)
{
ROS_INFO("usage: add three client X Y Z");
return 1;
}
ros::NodeHandle n;
ros::ServiceClient client = n.serviceClient<serv_tutorial_srv::Add_three_int>("Add_three_ints");
serv_tutorial_srv::Add_three_int serv;
serv.request.A = atoll(argv[1]);
serv.request.B = atoll(argv[2]);
serv.request.C = atoll(argv[3]);
if (client.call(serv))
{
ROS_INFO("Sum: %ld",(long int)serv.response.Sum);
}
else
{
ROS_ERROR("Failed to call service add_three_int");
return 1;
}
return 0;
}
|
98df63c374332b7fe356ea89005814c69cbc3096 | c983a7d121aab6765033b92a05b902f6dc210c5b | /src/utils/realfinishjobqueue.h | 0588c72edfbef02321e30cd78200bcfc2a2bae53 | [] | no_license | AlvioSim/kentosim | d77ba87a1f6d3effe8790a30124ca8e0471f9955 | faf73a743438052d5d429af30119b8a4f8d5f66f | refs/heads/master | 2016-09-02T04:09:23.509625 | 2015-01-08T13:55:26 | 2015-01-08T13:55:26 | 28,967,899 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,610 | h | realfinishjobqueue.h | #ifndef SIMULATORREALFINISHJOBQUEUE_H
#define SIMULATORREALFINISHJOBQUEUE_H
#include <scheduling/job.h>
#include <utils/jobqueue.h>
#include <assert.h>
#include <set>
#define REAL_FINISH_TIME_JOB_Qt 4
using namespace std;
using std::set;
using namespace Simulator;
namespace Utils {
/**< Comparation operation of two jobs based on it's submit time*/
struct finishtime_lt_t {
bool operator() (Job* job1, Job* job2) const {
double x = job1->getJobSimFinishTime();
double y = job2->getJobSimFinishTime();
assert( x >= 0 && y >= 0 );
if( x != y )
return x < y;
else
return job1->getJobNumber() < job2->getJobNumber();
}
};
/** Set based on the finish time for the job */
typedef set<Job*, finishtime_lt_t> RealFinishQueue;
/**
* @author Francesc Guim,C6-E201,93 401 16 50, <fguim@pcmas.ac.upc.edu>
*/
/**
* This class implements a job queue where the order of the queue is based on the real finish time for the job
*/
class RealFinishJobQueue : public JobQueue{
public:
RealFinishJobQueue();
~RealFinishJobQueue();
/* Auxiliar functions and main functions */
virtual void insert(Job* job);
virtual void erase(Job* job);
virtual Job* headJob();
virtual Job* next();
virtual Job* begin();
virtual void deleteCurrent();
virtual bool contains(Job* job);
private:
RealFinishQueue queue; /**< Contains the queue of jobs where they are sorted in the order defined in the comparaison operator */
RealFinishQueue::iterator currentIterator;/**< The iterator that points to the current position that is being queried to the queue */
};
}
#endif
|
d592485b3b3cf778c9cce2a63746edf423a00188 | c2f2d5185f9e78b19c8f5c1876eb272112c150c9 | /main.cpp | 71dc65050930d404569e9a87db4ab29baffa5617 | [] | no_license | aunesto17/Affine_Cipher | 5e39cee67c6e8d4b5477e179a73628c49e153843 | 2015a819662449301406026e02548a2a0e1495af | refs/heads/master | 2021-04-14T11:18:26.236555 | 2020-03-22T16:47:18 | 2020-03-22T16:47:18 | 249,228,174 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 574 | cpp | main.cpp | //
// main.cpp
// Cifrado_Afin
//
// Created by Alexander Arturo Baylon Ibanez on 4/13/15.
// Copyright (c) 2015 Alexander Arturo Baylon Ibanez. All rights reserved.
//
#include "afin.h"
int main(int argc, const char * argv[]) {
afin prueba;
string pru = prueba.cifrar();
cout << pru << endl;
unsigned int a = prueba.getA(),b=prueba.getB();
//string pru = "cabxydbrsmvnvmdjyrdfbmryrdoirdwmvrwbr";
//string pru = " hts";
afin prueba1(pru,a,b);
string de = prueba1.decifrar();
cout << de << endl;
return 0;
}
|
ab8b692cb10a7a735394962680ece8904e963c68 | 61e0a9ad10caf55c73d1e462fcfaca1f3abae63a | /dotNetCheck/dotNetCheck/main.cpp | 5b6f98282bcce0933d240fc8386e1e72fd24d1c3 | [] | no_license | mowglisanu/Image.Viewer | 9ca378d0bb0d667f0db9a81872f0bb7e287b2ff8 | b1038d551cb421a74427444355c6e0abcea7e5ad | refs/heads/master | 2021-01-01T05:53:55.146112 | 2012-05-01T20:45:48 | 2012-05-01T20:45:48 | 3,243,956 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,086 | cpp | main.cpp | /*#include <curl/curl.h>
#include <curl/easy.h>
int main(int argc, char *argv[]){
if (curl_global_init(CURL_GLOBAL_NOTHING) != 0){
return -1;
}
CURL* handle = curl_easy_init();
if (!handle){
return -1;
}
CURLcode ret = curl_easy_setopt(handle, CURLOPT_URL, "http://www.google.com");
}*/
#pragma comment (lib, "Winhttp.lib")
#include <cstdio>
#include <windows.h>
#include <winhttp.h>
int downloadDotNet(){
DWORD dwSize = 0;
DWORD dwDownloaded = 0;
DWORD result = 0;
LPSTR pszOutBuffer;
BOOL bResults = FALSE;
HINTERNET hSession = NULL,
hConnect = NULL,
hRequest = NULL;
// Use WinHttpOpen to obtain a session handle.
hSession = WinHttpOpen( L"Musoft Dowmloader/1.0",
WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
WINHTTP_NO_PROXY_NAME,
WINHTTP_NO_PROXY_BYPASS, 0);
// Specify an HTTP server.
if (hSession)
hConnect = WinHttpConnect( hSession, L"www.microsoft.com",
INTERNET_DEFAULT_HTTP_PORT, 0);
// Create an HTTP request handle.
if (hConnect)
hRequest = WinHttpOpenRequest( hConnect, L"GET", L"/downloads/info.aspx?na=41&SrcFamilyId=9CFB2D51-5FF4-4491-B0E5-B386F32C0992&SrcDisplayLang=en&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2f1%2fB%2fE%2f1BE39E79-7E39-46A3-96FF-047F95396215%2fdotNetFx40_Full_setup.exe",
NULL, WINHTTP_NO_REFERER,
WINHTTP_DEFAULT_ACCEPT_TYPES,
WINHTTP_FLAG_REFRESH);
// Send a request.
if (hRequest)
bResults = WinHttpSendRequest( hRequest,
WINHTTP_NO_ADDITIONAL_HEADERS,
0, WINHTTP_NO_REQUEST_DATA, 0,
0, 0);
// End the request.
if (bResults)
bResults = WinHttpReceiveResponse( hRequest, NULL);
// Keep checking for data until there is nothing left.
if (bResults){
FILE *f = fopen("dotNetFx40_Full_setup.exe", "wb");
do
{
// Check for available data.
dwSize = 0;
if (!WinHttpQueryDataAvailable( hRequest, &dwSize))
result = -1;
// Allocate space for the buffer.
pszOutBuffer = new char[dwSize];
if (!pszOutBuffer)
{
dwSize=0;
result = -1;
}
else
{
// Read the Data.
if (!WinHttpReadData( hRequest, (LPVOID)pszOutBuffer,
dwSize, &dwDownloaded))
printf( "Error %u in WinHttpReadData.\n", GetLastError());
else
fwrite(pszOutBuffer, 1, dwSize, f);
// Free the memory allocated to the buffer.
delete [] pszOutBuffer;
}
} while (dwSize > 0);
fclose(f);
}
// Report any errors.
if (!bResults)
result = -1;
// Close any open handles.
if (hRequest) WinHttpCloseHandle(hRequest);
if (hConnect) WinHttpCloseHandle(hConnect);
if (hSession) WinHttpCloseHandle(hSession);
return result;
}
int runDotNet(){
return (int)ShellExecute(0, "open", "dotNetFx40_Full_setup.exe", 0, 0, SW_SHOW)>32?0:1;
}
/*int walkDotNet(){
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
if (!CreateProcess("dotNetFx40_Full_setup.exe", NULL, NULL, NULL, false, 0, NULL, NULL, &si, &pi)){
DWORD x = GetLastError();
return -2;
}
if (WaitForSingleObject(pi.hProcess, INFINITE) == WAIT_FAILED){
return -3;
}
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
return 0;
}*/
int check(){
WIN32_FIND_DATA FindFileData;
DWORD len = 64, res;
res = GetWindowsDirectory(NULL, 0);
char *windir = new char[res+30];
res = GetWindowsDirectory(windir, 0);
strcpy(windir+res, "Microsoft.NET\\Framework\\v4.0*");
HANDLE hFind = FindFirstFile("c:\\Windows\\Microsoft.NET\\Framework\\v4.0*", &FindFileData);//v4.0.xxxxx only check for one file
if (hFind == INVALID_HANDLE_VALUE){
if (GetLastError() == ERROR_FILE_NOT_FOUND){
return 0;
}
return -1;
}
FindClose(hFind);
if (FindFileData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY){
return 1;
}
return 0;
}
int main(int argc, char* argv[]){
bool download = false;
if (argc != 2){
return -1;
}
if (strncmp(argv[1], "check", 5) == 0){
switch (check()){
case 0:
case -1:
download = true;
break;
case 1:
return 0;//.net detected - no error
break;
}
}
else if (strncmp(argv[1], "dontcheck", 9) == 0){
download = true;
}
if (download){
if (downloadDotNet() >= 0){
return runDotNet();
}
return -4;
}
return -5;
} |
56c72971fb377a6ce1fb558d09bb701fdd4dcd75 | 581d6eeb48dbd442dca27c1fa83689c58ffea2c9 | /Sources/Elastos/LibCore/src/libcore/io/CAsynchronousCloseMonitor.cpp | d8a83ad34e6f38f3e79ea85cce6a2579ca82b658 | [
"Apache-2.0"
] | permissive | TheTypoMaster/ElastosRDK5_0 | bda12b56271f38dfb0726a4b62cdacf1aa0729a7 | e59ba505e0732c903fb57a9f5755d900a33a80ab | refs/heads/master | 2021-01-20T21:00:59.528682 | 2015-09-19T21:29:08 | 2015-09-19T21:29:08 | 42,790,116 | 0 | 0 | null | 2015-09-19T21:23:27 | 2015-09-19T21:23:26 | null | UTF-8 | C++ | false | false | 515 | cpp | CAsynchronousCloseMonitor.cpp | #include "CAsynchronousCloseMonitor.h"
#include "AsynchronousCloseMonitorNative.h"
namespace Libcore {
namespace IO {
CAR_SINGLETON_IMPL(CAsynchronousCloseMonitor)
CAR_INTERFACE_IMPL(CAsynchronousCloseMonitor, Singleton, IAsynchronousCloseMonitor)
ECode CAsynchronousCloseMonitor::SignalBlockedThreads(
/* [in] */ IFileDescriptor* fd)
{
Int32 iFd;
fd->GetDescriptor(&iFd);
AsynchronousCloseMonitorNative::SignalBlockedThreads(iFd);
return NOERROR;
}
} // namespace IO
} // namespace Libcore |
a49c3ea2357390b0d0bbb74c61a6ccfff3617279 | ff3b9e017cb29bf84aaa6c5698b0b93104ac6fb4 | /SkyRewards/MockLogger.cpp | 4a5f926d6f7c4b99f2e369915c318c8cd34898f2 | [] | no_license | quantumOrange/RewardsService | b0281496420e20a9f3725dc0c18115469b70d9ec | 84cc94491e1d8656d6bb10aa9ce6456fe0706648 | refs/heads/master | 2020-05-01T12:30:58.262538 | 2019-03-25T15:04:30 | 2019-03-25T15:04:30 | 177,467,588 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 456 | cpp | MockLogger.cpp | //
// MockLogger.cpp
// SkyRewards
//
// Created by David Crooks on 24/03/2019.
// Copyright © 2019 David Crooks. All rights reserved.
//
#include "MockLogger.hpp"
#include "ILogger.hpp"
LogSeverity MockLogger::getLastSeverity(){
return lastSeverity;
}
std::string MockLogger::getLastMessage(){
return lastMessage;
}
void MockLogger::log(LogSeverity severity,std::string message){
lastMessage = message;
lastSeverity = severity;
}
|
207ef26545d37aa870a097c040f0c526084d1cfa | 9de2b3fe4c335c82ec9336d0e93eb678ba51d937 | /hydrosystems/dummy.cpp | 0269309c442694bfe4a3783378bb4ab81355aa5b | [] | no_license | envinf/teaching | 85233112b813dfe0aa9cfb65bda222745897f00b | 1787d7b2791c2a611ca3a1e9e3b5633f5e9089b7 | refs/heads/master | 2020-03-20T12:12:09.507248 | 2019-05-03T10:35:53 | 2019-05-03T10:35:53 | 137,423,528 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 41 | cpp | dummy.cpp | //Dummy file to force directory creation
|
f4a2ed6188368a52b8bfe7b074c5db02e9c65507 | 68b9e60e50796eac67ff8ee6b6dbb9e21559492b | /Exercise 7/Exercise 7_1/Main.cpp | 90ed6610d37b43deeb14766a999807d5fdae472a | [] | no_license | Hestur/SoftwareEGit | 5c27f5d466d9f20b0aecbec1182b13887fde2287 | c20b6d061ac35dfc54aa73571d36c6f02d7519dc | refs/heads/master | 2022-12-28T13:01:31.092009 | 2020-10-20T13:49:39 | 2020-10-20T13:49:39 | 291,478,119 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,119 | cpp | Main.cpp | /*
Exercise 7.1: Maksimum, minimum og middelværdi
Skriv et modul (header og source fil) med følgende tre funktioner
int maxValue( int *, const int )
int minValue( int *, const int )
double average( int [], const int )
Alle tre funktioner skal kunne ”modtage” et array og de skal kunne bestemme
hhv. den største værdi i arrayet, den mindste værdi i arrayet og gennemsnittet af alle værdier i arrayet (Hint 7A).
NB! Grunden til, at der er forskel på parameterlisten i funktionerne, er, at du
skal prøve begge dele .
Skriv derefter et lille testprogram (main) hvori du tester dine funktioner.
*/
#include <stdio.h>
#include "maxValue.h"
#include "minValue.h"
#include "avgValue.h"
#define SIZE 10
int main(void) {
int arr[SIZE] = { 100, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
for (size_t i = 0; i < SIZE; i++)
printf("%d ", arr[i]);
printf_s("\n\n");
printf("Largest in given array is %d", maxValue(arr, SIZE));
printf_s("\n\n");
printf_s("Smallest in given array is %d", minValue(arr, SIZE));
printf_s("\n\n");
printf_s("Avg value in given array is %f", avgValue(arr, SIZE));
printf_s("\n\n");
} |
b1da5d47ef5c1eee7a5204ba57aae91747adf0db | 8fff562a15b977a5b8a674fd5c7f040c8157f071 | /shapes/Star.h | 392d9c8d02a7597758d749f1d33868674fdf3f22 | [] | no_license | lbolin/OOP-shapes | 7a65ee4fd693d859d8abab80d9ff1f8dc909dcee | d31ca2744bb5eca7b548192f136ab00f1cdee746 | refs/heads/master | 2020-04-28T02:44:35.430397 | 2019-03-11T02:11:26 | 2019-03-11T02:11:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 341 | h | Star.h | #pragma once
#include "Picture.h"
#include "RGBTriple.h"
#include "shape.h"
class Star :public shape
{
public:
Star();
virtual ~Star();
virtual void initializeShape(string stbSyntax);
virtual void draw(Picture& picture);
virtual void drawShadow(Picture& basePic);
private:
int size;
//int Red, Green, Blue;
//bool isFilled;
};
|
132008e264cd916653f5a9f926fb2e33babd8c1b | a2af2873034d0c40018007d964cdb90225c3c390 | /mainwindow.h | bea2cf60b7ccca2c2450661c51c872cbee345ebf | [] | no_license | aloschilov/Proto-mni-viewer | 6121cb9b847dfe83854494e5fe789e81880adb56 | dc4f3bde5c02e8c51e7941f378bb995cee584cb5 | refs/heads/master | 2020-04-14T08:42:04.279846 | 2013-04-22T10:43:18 | 2013-04-22T10:43:18 | 5,340,924 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,361 | h | mainwindow.h | #ifndef MAINWINDOW_H
#define MAINWINDOW_H
// Qt includes section
#include <QtGui>
// VTK includes section
#include <vtkSmartPointer.h>
#include <vtkPolyDataMapper.h>
#include <vtkMNIObjectReader.h>
#include <vtkScalarBarActor.h>
#include <vtkActor.h>
#include <vtkLight.h>
#include <vtkSphereWidget.h>
#include <vtkConeSource.h>
#include <vtkDataSetMapper.h>
#include <vtkVolumePicker.h>
#include <vtkPointPicker.h>
#include <vtkWindowToImageFilter.h>
#include <vtkFFMPEGWriter.h>
#include <vtkPNGWriter.h>
#include <vtkEventQtSlotConnect.h>
#include <vtkTransform.h>
// Forward declarations section
class QVTKWidget;
class LookupTableSelectionWidget;
class ShadingModelSelectionWidget;
class LightingPropertiesWidget;
class SurfaceSelectionWidget;
class AnimationManagementWidget;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
protected:
void showEvent ( QShowEvent * event );
void resizeEvent ( QResizeEvent * event );
private slots:
void openMeshFile();
void openPerPointScalarsFile();
void openPerPointScalarsByFilename(QString fileName);
void saveCurrentTransformation();
void openTransformation();
void openTransformationByName(QString fileName);
void updateLookupTable(vtkSmartPointer<vtkLookupTable> lookupTable);
void updateDirectRgbColors(vtkSmartPointer<vtkUnsignedCharArray> colors);
void updateScalarBarActorTitleTextProperty(vtkSmartPointer<vtkTextProperty> textProperty);
void updateScalarBarActorLabelTextProperty(vtkSmartPointer<vtkTextProperty> textProperty);
void setFlatShadingModel();
void setGouraudShadingModel();
void processSphereWidgetInteractionEvent(vtkObject*, unsigned long, void*, void*, vtkCommand*);
void processMouseMoveEvent(vtkObject*, unsigned long, void*, void*, vtkCommand*);
void processLeftButtonPressEvent(vtkObject*, unsigned long, void*, void*, vtkCommand*);
void processLeftButtonReleaseEvent(vtkObject*, unsigned long, void*, void*, vtkCommand*);
void pointCone(vtkActor* actorToRotate, double nx, double ny, double nz);
void processAmbientChanged(double value);
void processSpecularChanged(double value);
void processDiffuseChanged(double value);
void processOpacityChanged(double value);
void processLightingStateChanged(int state);
void processLightingWidgetStateChanged(int state);
void openSelection();
void saveSelection();
void clearSelection();
void saveObjectStateAsFirstAnimationPoint();
void saveObjectStateAsSecondAnimationPoint();
void processCurrentTimeChanged();
void processCurrentWritingFrameChanged();
void processWritingToAviInitiated();
void processWritingToAviCompleted();
void processWritingAviFilenameChanged(QString filename);
void processWritingPngFilenameChanged(QString filename);
void processWritePng();
void processAnimationModeStateEntered();
void processAnimationModeStateExited();
void processCameraModeStateEntered();
void processCameraModeStateExited();
void processPaintModeStateEntered();
void processPaintModeStateExited();
void processSelectColorForPencil();
void processSelectBackgroundColor();
void showLegend();
void hideLegend();
void processScalarRangeChanged(double min, double max);
void processNumberOfLabelsChanged(int numberOfLabels);
void processTransformationResetion();
void processDepthSortingCheckstateChanged(int state);
void enableCpuDepthSortingPipeline();
void disableCpuDepthSortingPipeline();
void enableDepthPeeling();
void disableDepthPeeling();
private:
void createActions();
void createMenu();
void createToolbar();
void initializeVtk();
void initializeStateMachine();
void disableLighting();
void enableLighting();
void openMeshFileByName(const QString &filename);
QIcon getIconFilledWithColor(QColor color);
QAction *openMeshFileAction;
QAction *openPerPointScalarsFileAction;
QDockWidget *lookupTableSelectionDockWidget;
LookupTableSelectionWidget *lookupTableSelectionWidget;
QDockWidget *shadingModelSelectionDockWidget;
ShadingModelSelectionWidget *shadingModelSelectionWidget;
QDockWidget *lightingPropertiesDockWidget;
LightingPropertiesWidget *lightingPropertiesWidget;
QDockWidget *surfaceSelectionDockWidget;
SurfaceSelectionWidget *surfaceSelectionWidget;
QDockWidget *animationManagementDockWidget;
AnimationManagementWidget *animationManagementWidget;
QVTKWidget *qvtkWidget;
vtkSmartPointer<vtkPolyDataMapper> mapper;
vtkSmartPointer<vtkMNIObjectReader> reader;
vtkSmartPointer<vtkRenderer> ren;
vtkSmartPointer<vtkScalarBarActor > scalar_bar;
vtkSmartPointer<vtkActor> actor;
vtkSmartPointer<vtkEventQtSlotConnect> Connections;
vtkSmartPointer<vtkLight> light;
vtkSmartPointer<vtkSphereWidget> sphereWidget;
vtkFloatArray *scalars;
float min;
float max;
bool isDepthPeelingSupported;
// Vtk objects related to marking surface
vtkSmartPointer<vtkVolumePicker> volumePicker;
vtkSmartPointer<vtkPointPicker> pointPicker;
vtkSmartPointer<vtkWindowToImageFilter> windowToImageFilter;
vtkSmartPointer<vtkFFMPEGWriter> ffmpegWriter;
vtkSmartPointer<vtkPNGWriter> pngWriter;
// vtkSmartPointer<vtkConeSource> coneSource;
// vtkSmartPointer<vtkDataSetMapper> coneMapper;
// vtkSmartPointer<vtkActor> pencilActor;
// vtkSmartPointer<vtkActor> greenCone;
QStateMachine machine;
QState animationModeState;
QState cameraModeState;
QState paintModeState;
QAction *saveTransformationAction;
QAction *loadTransformationAction;
QAction *activateCameraModeAction;
QAction *activateObjectAnimationModeAction;
QAction *activatePaintModeAction;
QToolButton *selectPencilColorToolButton;
QColor pencilColor;
QToolButton *selectBackgroundColorToolButton;
bool leftMouseButtonIsPressed;
bool isInPaintMode;
vtkSmartPointer<vtkTransform> mniObjectTransfrom;
vtkSmartPointer<vtkTransform> markedAreaTransfrom;
vtkSmartPointer<vtkActor> markedAreaPinActor;
QMap<vtkIdType, vtkSmartPointer<vtkActor> > placedPoints;
QSettings settings;
};
#endif // MAINWINDOW_H
|
7c7b47e29b9a18da0e17574fcc9cc349ae78486b | 4ed7dd878a2b34bace1fd91a49106eebe570a360 | /Yandex.Algo/2016/Round1/B.cpp | 35346e9f074f4c985d1d732248a20ce7122c4396 | [] | no_license | mayukuner/AC | fb63be04a1fcf7f3af080aa50bf7c6e0e070b1b9 | c21b2970b7288d7b36cbed468101446c615e79ff | refs/heads/master | 2020-12-15T02:38:51.758676 | 2017-10-11T13:01:11 | 2017-10-11T13:01:11 | 46,971,415 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,115 | cpp | B.cpp | #include<stdio.h>
#include<algorithm>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<string>
#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,n) for(int i=1; i<=n; i++)
typedef long long LL;
using namespace std;
typedef pair<int,int> pii;
#define MP make_pair
int n = 9;
int cur[9];
char des[9];
bool check_c(int x){
return x>=0 && x<3;
}
int dx[4]= {0,0,-1,1},dy[4]={-1,1,0,0};
bool check(){
REP(i,n)
if(cur[i] != des[i]-'0' && des[i] != '?')
return false;
FOR(i,n-1)REP(x,3)REP(y,3)if(cur[x*3+y] == i){
int flag = 0;
REP(k,4)
if(check_c(x + dx[k]) && check_c(y+dy[k]) && cur[(x+dx[k])*3+y+dy[k]] == i + 1)
flag = 1;
if(!flag)
return false;
}
return true;
}
void print(){
REP(i,n)
printf("%d%s",cur[i],((i+1)%3==0)?"\n":"");
}
int main(){
#ifdef QWERTIER
freopen("in.txt","r",stdin);
#endif
REP(i,3)
scanf("%s",des+(i*3));
REP(i,n)
cur[i] = i + 1;
do{
if(check())
print();
}while(next_permutation(cur,cur+n));
return 0;
}
|
0ec0d55edfa83031e2f1d4dea2cd98e7d817f2ff | 4e5488ca16bbbbae430a87486d51ab4c9c7cc959 | /strongtalk/src/cpp/test/test/primitives/pointerAlienPrimitivesTest.cpp | a565e21cf27874468af25540da55bb77765edc9d | [] | no_license | RalfBarkow/strongtalk-2020 | 3cbf0286b18e3ac48b315509e77215e8ed4c6bcd | b51c02d5e30c0c728fece29037fdcd81f7f5803a | refs/heads/master | 2023-03-19T06:22:52.079759 | 2021-03-14T20:27:14 | 2021-03-14T20:27:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,900 | cpp | pointerAlienPrimitivesTest.cpp |
//
// (C) 1994 - 2021, The Strongtalk authors and contributors
// Refer to the "COPYRIGHTS" file at the root of this source tree for complete licence and copyright terms
//
#include "vm/oop/DoubleOopDescriptor.hpp"
#include "vm/oop/KlassOopDescriptor.hpp"
#include "vm/memory/Handle.hpp"
#include "vm/runtime/VMSymbol.hpp"
#include "vm/primitive/ByteArrayPrimitives.hpp"
#include "vm/utility/Integer.hpp"
#include "vm/utility/IntegerOps.hpp"
#include "vm/runtime/ResourceMark.hpp"
#include <gtest/gtest.h>
class PointerAlienPrimsTests : public ::testing::Test {
public:
PointerAlienPrimsTests() : ::testing::Test(), rm{ nullptr }, alien{}, invalidAlien{}, largeUnsignedInteger{}, largeSignedInteger{}, alien_byte_region{}, doubleValue{} {}
protected:
void SetUp() override {
rm = new HeapResourceMark();
PersistentHandle ah( Universe::byteArrayKlassObject()->klass_part()->allocateObjectSize( 8 ) );
PersistentHandle iah( Universe::byteArrayKlassObject()->klass_part()->allocateObjectSize( 8 ) );
PersistentHandle lu( Universe::byteArrayKlassObject()->klass_part()->allocateObjectSize( 8 ) );
PersistentHandle ls( Universe::byteArrayKlassObject()->klass_part()->allocateObjectSize( 8 ) );
largeUnsignedInteger = ByteArrayOop( lu.as_oop() );
largeSignedInteger = ByteArrayOop( ls.as_oop() );
doubleValue = DoubleOop( Universe::doubleKlassObject()->klass_part()->allocateObject() );
doubleValue->set_value( 1.625 );
IntegerOps::unsigned_int_to_Integer( (std::uint32_t) 0xFFFFFFFF, ByteArrayOop( largeUnsignedInteger )->number() );
IntegerOps::int_to_Integer( -1 << 31, ByteArrayOop( largeSignedInteger )->number() );
alien = ByteArrayOop( ah.as_oop() );
ByteArrayPrimitives::alienSetSize( smiOopFromValue( 0 ), alien );
ByteArrayPrimitives::alienSetAddress( smiOopFromValue( (std::int32_t) alien_byte_region ), alien );
memset( alien_byte_region, 0, 16 );
invalidAlien = ByteArrayOop( iah.as_oop() );
ByteArrayPrimitives::alienSetSize( smiOopFromValue( 0 ), invalidAlien );
ByteArrayPrimitives::alienSetAddress( smiOopFromValue( 0 ), invalidAlien );
}
void TearDown() override {
delete rm;
rm = nullptr;
}
HeapResourceMark *rm;
ByteArrayOop alien, invalidAlien;
ByteArrayOop largeUnsignedInteger;
ByteArrayOop largeSignedInteger;
std::uint8_t alien_byte_region[16];
DoubleOop doubleValue;
std::int32_t asInteger( Oop largeInteger, bool &ok ) {
Integer *number = &ByteArrayOop( largeInteger )->number();
return number->as_int32_t( ok );
}
void checkLargeInteger( Oop result, std::int32_t expected ) {
char message[200];
EXPECT_TRUE( result->isByteArray() ) << "Should be integer";
bool ok;
std::int32_t actual = asInteger( result, ok );
EXPECT_TRUE( ok ) << "should be integer";
sprintf( message, "wrong value. expected: 0x%08x, was: 0x%08x", expected, actual );
EXPECT_EQ( expected, actual ) << message;
}
void checkLargeUnsigned( Oop result, std::uint32_t expected ) {
char message[200];
EXPECT_TRUE( result->isByteArray() ) << "Should be integer";
bool ok;
std::uint32_t actual = ByteArrayOop( result )->number().as_uint32_t( ok );
EXPECT_TRUE( ok ) << "should be integer";
sprintf( message, "wrong value. expected: 0x%08x, was: 0x%08x", expected, actual );
EXPECT_EQ( expected, actual ) << message;
}
void checkSmallInteger( Oop result, std::int32_t expected ) {
char message[200];
EXPECT_TRUE( result->isSmallIntegerOop() ) << "Should be small integer";
std::int32_t actual = SmallIntegerOop( result )->value();
sprintf( message, "wrong value. expected: %d, was: %d", expected, actual );
EXPECT_EQ( expected, actual ) << message;
}
void checkMarkedSymbol( const char *message, Oop result, SymbolOop expected ) {
char text[200];
EXPECT_TRUE( result->isMarkOop() ) << "Should be marked";
sprintf( text, "Should be: %s, was: %s", message, unmarkSymbol( result )->as_string() );
EXPECT_TRUE( unmarkSymbol( result ) == expected ) << text;
}
};
TEST_F( PointerAlienPrimsTests, alienUnsignedByteAtPutShouldSetUnsignedByte ) {
ByteArrayPrimitives::alienUnsignedByteAtPut( smiOopFromValue( 255 ), smiOopFromValue( 1 ), alien );
Oop result = ByteArrayPrimitives::alienUnsignedByteAt( smiOopFromValue( 1 ), alien );
checkSmallInteger( result, 255 );
}
TEST_F( PointerAlienPrimsTests, alienUnsignedByteAtPutShouldReturnAssignedByte ) {
Oop result = ByteArrayPrimitives::alienUnsignedByteAtPut( smiOopFromValue( 255 ), smiOopFromValue( 1 ), alien );
checkSmallInteger( result, 255 );
}
TEST_F( PointerAlienPrimsTests, alienSignedByteAtShouldReturnCorrectByte ) {
ByteArrayPrimitives::alienUnsignedByteAtPut( smiOopFromValue( 255 ), smiOopFromValue( 1 ), alien );
Oop result = ByteArrayPrimitives::alienSignedByteAt( smiOopFromValue( 1 ), alien );
checkSmallInteger( result, -1 );
}
TEST_F( PointerAlienPrimsTests, alienSignedByteAtPutShouldSetCorrectByte ) {
ByteArrayPrimitives::alienSignedByteAtPut( smiOopFromValue( -1 ), smiOopFromValue( 1 ), alien );
Oop result = ByteArrayPrimitives::alienSignedByteAt( smiOopFromValue( 1 ), alien );
checkSmallInteger( result, -1 );
}
TEST_F( PointerAlienPrimsTests, alienUnsignedShortAtShouldReturnCorrectValue ) {
ByteArrayPrimitives::alienUnsignedByteAtPut( smiOopFromValue( 255 ), smiOopFromValue( 1 ), alien );
ByteArrayPrimitives::alienUnsignedByteAtPut( smiOopFromValue( 255 ), smiOopFromValue( 2 ), alien );
Oop result = ByteArrayPrimitives::alienUnsignedShortAt( smiOopFromValue( 1 ), alien );
checkSmallInteger( result, 65535 );
}
TEST_F( PointerAlienPrimsTests, alienUnsignedShortAtPutShouldSetCorrectValue ) {
ByteArrayPrimitives::alienUnsignedShortAtPut( smiOopFromValue( 65535 ), smiOopFromValue( 1 ), alien );
Oop result = ByteArrayPrimitives::alienUnsignedShortAt( smiOopFromValue( 1 ), alien );
checkSmallInteger( result, 65535 );
}
TEST_F( PointerAlienPrimsTests, alienSignedShortAtShouldReturnCorrectValue ) {
ByteArrayPrimitives::alienUnsignedShortAtPut( smiOopFromValue( 65535 ), smiOopFromValue( 1 ), alien );
Oop result = ByteArrayPrimitives::alienSignedShortAt( smiOopFromValue( 1 ), alien );
checkSmallInteger( result, -1 );
}
TEST_F( PointerAlienPrimsTests, alienSignedShortAtPutShouldSetCorrectValue ) {
ByteArrayPrimitives::alienSignedShortAtPut( smiOopFromValue( -1 ), smiOopFromValue( 1 ), alien );
Oop result = ByteArrayPrimitives::alienSignedShortAt( smiOopFromValue( 1 ), alien );
checkSmallInteger( result, -1 );
}
TEST_F( PointerAlienPrimsTests, alienUnsignedLongAtShouldReturnCorrectValue ) {
ByteArrayPrimitives::alienUnsignedShortAtPut( smiOopFromValue( 65535 ), smiOopFromValue( 1 ), alien );
ByteArrayPrimitives::alienUnsignedShortAtPut( smiOopFromValue( 65535 ), smiOopFromValue( 3 ), alien );
Oop result = ByteArrayPrimitives::alienUnsignedLongAt( smiOopFromValue( 1 ), alien );
checkLargeUnsigned( result, 0xFFFFFFFF );
}
TEST_F( PointerAlienPrimsTests, alienUnsignedLongAtPutShouldSetCorrectValue ) {
ByteArrayPrimitives::alienUnsignedLongAtPut( largeUnsignedInteger, smiOopFromValue( 1 ), alien );
Oop result = ByteArrayPrimitives::alienUnsignedLongAt( smiOopFromValue( 1 ), alien );
checkLargeUnsigned( result, 0xFFFFFFFF );
}
TEST_F( PointerAlienPrimsTests, alienSignedLongAtShouldReturnCorrectValue ) {
ByteArrayPrimitives::alienUnsignedLongAtPut( largeUnsignedInteger, smiOopFromValue( 1 ), alien );
Oop result = ByteArrayPrimitives::alienSignedLongAt( smiOopFromValue( 1 ), alien );
checkSmallInteger( result, -1 );
}
TEST_F( PointerAlienPrimsTests, alienSignedLongAtPutShouldSetCorrectValue ) {
ByteArrayPrimitives::alienSignedLongAtPut( largeSignedInteger, smiOopFromValue( 1 ), alien );
Oop result = ByteArrayPrimitives::alienSignedLongAt( smiOopFromValue( 1 ), alien );
checkLargeInteger( result, -1 << 31 );
}
TEST_F( PointerAlienPrimsTests, alienDoubleAtPutShouldSetValueAtSecondByte ) {
ByteArrayPrimitives::alienDoubleAtPut( doubleValue, smiOopFromValue( 2 ), alien );
Oop result = ByteArrayPrimitives::alienDoubleAt( smiOopFromValue( 2 ), alien );
EXPECT_TRUE( result->isDouble() ) << "should be double";
EXPECT_EQ( 1.625, DoubleOop( result ) -> value() ) << "wrong value";
EXPECT_EQ( 1.625, ( (double *) ( alien_byte_region + 1 ) )[ 0 ] ) << "value not set";
}
TEST_F( PointerAlienPrimsTests, alienFloatAtPutShouldSetCorrectValue ) {
ByteArrayPrimitives::alienFloatAtPut( doubleValue, smiOopFromValue( 1 ), alien );
Oop result = ByteArrayPrimitives::alienFloatAt( smiOopFromValue( 1 ), alien );
EXPECT_TRUE( result->isDouble() ) << "should be double";
EXPECT_EQ( 1.625, DoubleOop( result ) -> value() ) << "wrong value";
EXPECT_EQ( 1.625F, ( (float *) ( alien_byte_region ) )[ 0 ] ) << "value not set";
}
TEST_F( PointerAlienPrimsTests, alienUnsignedByteAtShouldReturnMarkedSymbolWhenAddressInvalid ) {
Oop result = ByteArrayPrimitives::alienUnsignedByteAt( smiOopFromValue( 1 ), invalidAlien );
checkMarkedSymbol( "invalid address", result, vmSymbols::illegal_state() );
}
TEST_F( PointerAlienPrimsTests, alienUnsignedByteAtPutShouldReturnMarkedSymbolWhenAddressInvalid ) {
Oop result = ByteArrayPrimitives::alienUnsignedByteAtPut( smiOopFromValue( 1 ), smiOopFromValue( 1 ), invalidAlien );
checkMarkedSymbol( "invalid address", result, vmSymbols::illegal_state() );
}
TEST_F( PointerAlienPrimsTests, alienSignedByteAtShouldReturnMarkedSymbolWhenAddressInvalid ) {
Oop result = ByteArrayPrimitives::alienSignedByteAt( smiOopFromValue( 1 ), invalidAlien );
checkMarkedSymbol( "invalid address", result, vmSymbols::illegal_state() );
}
TEST_F( PointerAlienPrimsTests, alienSignedByteAtPutShouldReturnMarkedSymbolWhenAddressInvalid ) {
Oop result = ByteArrayPrimitives::alienSignedByteAtPut( smiOopFromValue( 1 ), smiOopFromValue( 1 ), invalidAlien );
checkMarkedSymbol( "invalid address", result, vmSymbols::illegal_state() );
}
TEST_F( PointerAlienPrimsTests, alienUnsignedShortAtShouldReturnMarkedSymbolWhenAddressInvalid ) {
Oop result = ByteArrayPrimitives::alienUnsignedShortAt( smiOopFromValue( 1 ), invalidAlien );
checkMarkedSymbol( "invalid address", result, vmSymbols::illegal_state() );
}
TEST_F( PointerAlienPrimsTests, alienUnsignedShortAtPutShouldReturnMarkedSymbolWhenAddressInvalid ) {
Oop result = ByteArrayPrimitives::alienUnsignedShortAtPut( smiOopFromValue( 1 ), smiOopFromValue( 1 ), invalidAlien );
checkMarkedSymbol( "invalid address", result, vmSymbols::illegal_state() );
}
TEST_F( PointerAlienPrimsTests, alienSignedShortAtShouldReturnMarkedSymbolWhenAddressInvalid ) {
Oop result = ByteArrayPrimitives::alienSignedShortAt( smiOopFromValue( 1 ), invalidAlien );
checkMarkedSymbol( "invalid address", result, vmSymbols::illegal_state() );
}
TEST_F( PointerAlienPrimsTests, alienSignedShortAtPutShouldReturnMarkedSymbolWhenAddressInvalid ) {
Oop result = ByteArrayPrimitives::alienSignedShortAtPut( smiOopFromValue( 1 ), smiOopFromValue( 1 ), invalidAlien );
checkMarkedSymbol( "invalid address", result, vmSymbols::illegal_state() );
}
TEST_F( PointerAlienPrimsTests, alienUnsignedLongAtShouldReturnMarkedSymbolWhenAddressInvalid ) {
Oop result = ByteArrayPrimitives::alienUnsignedLongAt( smiOopFromValue( 1 ), invalidAlien );
checkMarkedSymbol( "invalid address", result, vmSymbols::illegal_state() );
}
TEST_F( PointerAlienPrimsTests, alienUnsignedLongAtPutShouldReturnMarkedSymbolWhenAddressInvalid ) {
Oop result = ByteArrayPrimitives::alienUnsignedLongAtPut( smiOopFromValue( 1 ), smiOopFromValue( 1 ), invalidAlien );
checkMarkedSymbol( "invalid address", result, vmSymbols::illegal_state() );
}
TEST_F( PointerAlienPrimsTests, alienSignedLongAtShouldReturnMarkedSymbolWhenAddressInvalid ) {
Oop result = ByteArrayPrimitives::alienSignedLongAt( smiOopFromValue( 1 ), invalidAlien );
checkMarkedSymbol( "invalid address", result, vmSymbols::illegal_state() );
}
TEST_F( PointerAlienPrimsTests, alienSignedLongAtPutShouldReturnMarkedSymbolWhenAddressInvalid ) {
Oop result = ByteArrayPrimitives::alienSignedLongAtPut( smiOopFromValue( 1 ), smiOopFromValue( 1 ), invalidAlien );
checkMarkedSymbol( "invalid address", result, vmSymbols::illegal_state() );
}
TEST_F( PointerAlienPrimsTests, alienDoubleAtShouldReturnMarkedSymbolWhenAddressInvalid ) {
Oop result = ByteArrayPrimitives::alienDoubleAt( smiOopFromValue( 1 ), invalidAlien );
checkMarkedSymbol( "invalid address", result, vmSymbols::illegal_state() );
}
TEST_F( PointerAlienPrimsTests, alienDoubleAtPutShouldReturnMarkedSymbolWhenAddressInvalid ) {
Oop result = ByteArrayPrimitives::alienDoubleAtPut( doubleValue, smiOopFromValue( 1 ), invalidAlien );
checkMarkedSymbol( "invalid address", result, vmSymbols::illegal_state() );
}
TEST_F( PointerAlienPrimsTests, alienFloatAtShouldReturnMarkedSymbolWhenAddressInvalid ) {
Oop result = ByteArrayPrimitives::alienFloatAt( smiOopFromValue( 1 ), invalidAlien );
checkMarkedSymbol( "invalid address", result, vmSymbols::illegal_state() );
}
TEST_F( PointerAlienPrimsTests, alienFloatAtPutShouldReturnMarkedSymbolWhenAddressInvalid ) {
Oop result = ByteArrayPrimitives::alienFloatAtPut( doubleValue, smiOopFromValue( 1 ), invalidAlien );
checkMarkedSymbol( "invalid address", result, vmSymbols::illegal_state() );
}
|
b74ad626c034b7367ee739878816facc67146af0 | a030840ceab3f20a1cbf6cc8c82fa620a48e1f96 | /flamingoserver/fileserversrc/main.cpp | 64b2dfd4d732c10e2521f30bd719c2328d63f5d7 | [] | no_license | Nuos/flamingo | 6e9cc6cfc7a72dd1c00bf65a31670e5ac26a3d6e | d49fa23be37a5d4c2ca6549c61a65fef8b580790 | refs/heads/master | 2023-03-16T11:53:31.558045 | 2017-05-26T08:45:29 | 2017-05-26T08:45:29 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,494 | cpp | main.cpp | /**
* 文件服务程序入口函数
* zhangyl 2017.03.09
**/
#include <iostream>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "../base/logging.h"
#include "../base/singleton.h"
#include "../net/eventloop.h"
#include "../net/eventloopthreadpool.h"
#include "FileManager.h"
#include "FileServer.h"
using namespace net;
EventLoop g_mainLoop;
void prog_exit(int signo)
{
std::cout << "program recv signal [" << signo << "] to exit." << std::endl;
g_mainLoop.quit();
}
void daemon_run()
{
int pid;
signal(SIGCHLD, SIG_IGN);
//1)在父进程中,fork返回新创建子进程的进程ID;
//2)在子进程中,fork返回0;
//3)如果出现错误,fork返回一个负值;
pid = fork();
if (pid < 0)
{
std::cout << "fork error" << std::endl;
exit(-1);
}
//父进程退出,子进程独立运行
else if (pid > 0) {
exit(0);
}
//之前parent和child运行在同一个session里,parent是会话(session)的领头进程,
//parent进程作为会话的领头进程,如果exit结束执行的话,那么子进程会成为孤儿进程,并被init收养。
//执行setsid()之后,child将重新获得一个新的会话(session)id。
//这时parent退出之后,将不会影响到child了。
setsid();
int fd;
fd = open("/dev/null", O_RDWR, 0);
if (fd != -1)
{
dup2(fd, STDIN_FILENO);
dup2(fd, STDOUT_FILENO);
dup2(fd, STDERR_FILENO);
}
if (fd > 2)
close(fd);
}
int main(int argc, char* argv[])
{
//设置信号处理
signal(SIGCHLD, SIG_DFL);
signal(SIGPIPE, SIG_IGN);
signal(SIGINT, prog_exit);
signal(SIGKILL, prog_exit);
signal(SIGTERM, prog_exit);
short port = 0;
int ch;
bool bdaemon = false;
while ((ch = getopt(argc, argv, "d")) != -1)
{
switch (ch)
{
case 'd':
bdaemon = true;
break;
}
}
if (bdaemon)
daemon_run();
if (port == 0)
port = 12345;
Logger::setLogLevel(Logger::DEBUG);
Singleton<FileManager>::Instance().Init("./filecache");
Singleton<EventLoopThreadPool>::Instance().Init(&g_mainLoop, 6);
Singleton<EventLoopThreadPool>::Instance().start();
Singleton<FileServer>::Instance().Init("0.0.0.0", 20001, &g_mainLoop);
g_mainLoop.loop();
return 0;
}
|
390c0ec9663e7e0de3aff3e25e1b91ee8301d406 | 5fd7ba925b2cb277f2e4fe182f28fe4df960b92d | /2064/2064.cpp | a4984fd882192f5a75cf7d7887558fbd26f7e17f | [] | no_license | htyvv/2021-BaekJun | e8c144561a2a5d80bf881427e76faaae68b4d4cf | f0c58e29ffcfc75e0463227753ffb9e03a813169 | refs/heads/main | 2023-06-20T18:02:44.026216 | 2021-08-07T14:32:26 | 2021-08-07T14:32:26 | null | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 2,468 | cpp | 2064.cpp | #include<iostream>
#include<algorithm>
#include<sstream>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;
ll n;
string input;
vector<vector<string>> ip;
vector<string> binary;
ll nIdx; // 0 ~ 3
ll mIdx; // 0 ~ 7
vector<string> split(string str, char delimeter) {
vector<string> result;
stringstream ss(str);
string token;
while (getline(ss, token, delimeter)) result.push_back(token);
return result;
}
ll toDecimal(string binary) {
ll result = 0;
for (ll i = 0; i < binary.length(); i++) {
result += (binary[i]-'0') * pow(2, binary.length() - 1 - i);
}
return result;
}
string toBinary(ll num) {
string result = "";
while (num != 0) {
result += (num % 2 == 0 ? "0" : "1");
num /= 2;
}
reverse(result.begin(), result.end());
return result;
}
int main() {
// 입력 받기
cin >> n;
for (ll i = 0; i < n; i++) {
cin >> input;
ip.push_back(split(input, '.'));
}
// nIdx 찾기
ll idx = 0;
bool isFin = false;
while (idx < 4) {
string curr = ip[0][idx];
for (ll i = 0; i < n; i++) {
if (ip[i][idx] != curr) {
nIdx = idx;
isFin = true;
}
}
if (isFin) break;
idx++;
}
// nIdx 이후의 수 이진수로 변환
for (ll i = 0; i < n; i++) {
string temp = "";
for (ll j = nIdx; j < 4; j++) temp += ip[i][j];
binary.push_back(toBinary(stoi(temp)));
}
// mIdx 찾기
idx = 0;
isFin = false;
while (true) {
char curr = binary[0][idx];
for (ll i = 0; i < n; i++) {
if (binary[i][idx] != curr) {
mIdx = idx;
isFin = true;
}
}
if (isFin) break;
idx++;
}
string nres = "", mres = "";
string tmp_str = "";
string bin = toBinary(stoi(ip[0][nIdx]));
for (ll i = 0; i < mIdx; i++) {
tmp_str += bin[i];
}
// 이후에 0 추가 개수 ( 총 0 개수 - mIdx 앞까지)
for (ll i = 0; i < ((8 * (4 - nIdx)) - mIdx); i++) tmp_str += "0";
for (ll i = 0; i < nIdx; i++) {
nres += ip[0][i];
nres += ".";
}
//cout << "tmp_str : " << tmp_str << endl;
//cout << "toDecimal(tmp_str) : " << toDecimal(tmp_str) << endl;
//string temp = to_string(toDecimal(tmp_str));
//cout << "to_string(toDecimal(tmp_str) : " << temp << endl;
nres += to_string(toDecimal(tmp_str));
for (ll i = 0; i < nIdx; i++) mres += "255.";
string mask = "";
for (ll i = 0; i < mIdx; i++) mask += "1";
for (ll i = 0; i < (8-mIdx) + (8*(3-nIdx)); i++) mask += "0";
mres += to_string(toDecimal(mask));
cout << nres << "\n" << mres;
return 0;
} |
57f4b604b1d627fdefee5eaff51af80e53f6c4f2 | 679f4fc853926e98b6b57dbaefcbac087f566f23 | /src/audiosystems/OpenSLES/OpenSLES_Player.cpp | f1fe387da496a8c962b023ffc1b480323fde02b8 | [
"BSD-3-Clause"
] | permissive | AprilAndFriends/xal | a521702a5005774291d388615442e1813e8f722f | dd0297f0010c78a0dc815ffa9024b8c4deee4cae | refs/heads/master | 2020-04-04T05:50:04.656239 | 2019-10-15T12:02:56 | 2019-10-15T12:02:56 | 38,994,297 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 13,792 | cpp | OpenSLES_Player.cpp | /// @file
/// @version 4.0
///
/// @section LICENSE
///
/// This program is free software; you can redistribute it and/or modify it under
/// the terms of the BSD license: http://opensource.org/licenses/BSD-3-Clause
#ifdef _OPENSLES
#include <stdio.h>
#include <string.h>
#include <SLES/OpenSLES.h>
#include <SLES/OpenSLES_Android.h>
#define __HL_INCLUDE_PLATFORM_HEADERS
#include <hltypes/hmutex.h>
#include <hltypes/hlog.h>
#include <hltypes/hplatform.h>
#include <hltypes/hstring.h>
#include "AudioManager.h"
#include "Buffer.h"
#include "Category.h"
#include "OpenSLES_AudioManager.h"
#include "OpenSLES_Player.h"
#include "Sound.h"
#include "Utility.h"
#include "xal.h"
#define NORMAL_BUFFER_COUNT 2
#define OPENSLES_MANAGER ((OpenSLES_AudioManager*)xal::manager)
// this is just here to improve readability of code
#define CHECK_ERROR(message) \
if (result != SL_RESULT_SUCCESS) \
{ \
hlog::error(logTag, message); \
this->player = NULL; \
this->playerVolume = NULL; \
this->playerBufferQueue = NULL; \
if (this->playerObject != NULL) \
{ \
__CPP_WRAP(this->playerObject, Destroy); \
this->playerObject = NULL; \
} \
return false; \
}
namespace xal
{
static const SLInterfaceID ids[] = { SL_IID_VOLUME, SL_IID_ANDROIDSIMPLEBUFFERQUEUE };
static const SLboolean reqs[] = { SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE };
static const int reqsSize = 2;
void OpenSLES_Player::_playCallback(SLPlayItf player, void* context, SLuint32 event)
{
if ((event & SL_PLAYEVENT_HEADATEND) != 0)
{
OpenSLES_Player* player = (OpenSLES_Player*)context;
if (!player->sound->isStreamed())
{
player->active = false;
}
}
}
OpenSLES_Player::OpenSLES_Player(Sound* sound) :
Player(sound),
playing(false),
active(false),
stillPlaying(false),
playerObject(NULL),
player(NULL),
playerVolume(NULL),
playerBufferQueue(NULL),
buffersEnqueued(0)
{
for_iter (i, 0, STREAM_BUFFER_COUNT)
{
this->streamBuffers[i] = NULL;
}
if (this->sound->isStreamed())
{
for_iter (i, 0, STREAM_BUFFER_COUNT)
{
this->streamBuffers[i] = new unsigned char[STREAM_BUFFER_SIZE];
}
}
memset(&this->playerBufferQueueState, 0, sizeof(SLAndroidSimpleBufferQueueState));
}
OpenSLES_Player::~OpenSLES_Player()
{
if (this->playerObject != NULL)
{
__CPP_WRAP(this->playerObject, Destroy);
}
for_iter (i, 0, STREAM_BUFFER_COUNT)
{
if (this->streamBuffers[i] != NULL)
{
delete[] this->streamBuffers[i];
this->streamBuffers[i] = NULL;
}
}
}
void OpenSLES_Player::_update(float timeDelta)
{
this->stillPlaying = this->active;
Player::_update(timeDelta);
if (!this->stillPlaying && this->playing)
{
this->_stop();
}
}
bool OpenSLES_Player::_systemIsPlaying() const
{
return this->playing;
}
unsigned int OpenSLES_Player::_systemGetBufferPosition() const
{
int bytes = 0;
SLmillisecond milliseconds = 0;
SLresult result = __CPP_WRAP_ARGS(this->player, GetPosition, (SLmillisecond*)&milliseconds);
if (result == SL_RESULT_SUCCESS)
{
// first comes "* 0.001", because it can cause an int overflow otherwise
bytes = (int)(milliseconds * 0.001f * this->buffer->getSamplingRate() * (this->buffer->getBitsPerSample() / 8) * this->buffer->getChannels());
if (!this->sound->isStreamed() && this->looping)
{
bytes %= this->buffer->getSize();
}
}
return bytes;
}
bool OpenSLES_Player::_systemPreparePlay()
{
if (this->playerObject != NULL)
{
return true;
}
// input / source
SLDataLocator_AndroidSimpleBufferQueue inLocator;
inLocator.locatorType = SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE;
inLocator.numBuffers = (!this->sound->isStreamed() ? NORMAL_BUFFER_COUNT : STREAM_BUFFER_COUNT);
SLDataFormat_PCM format;
format.formatType = SL_DATAFORMAT_PCM;
format.numChannels = this->buffer->getChannels();
format.samplesPerSec = this->buffer->getSamplingRate() * 1000; // in mHz, this parameter is misnamed
int bitsPerSample = this->buffer->getBitsPerSample();
if (bitsPerSample == 8)
{
format.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_8;
}
else if (bitsPerSample == 16)
{
format.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_16;
}
else if (bitsPerSample == 20)
{
format.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_20;
}
else if (bitsPerSample == 24)
{
format.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_24;
}
else if (bitsPerSample == 28)
{
format.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_28;
}
else if (bitsPerSample == 32)
{
format.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_32;
}
else
{
return false;
}
format.containerSize = (bitsPerSample + 7) / 8 * 8; // assuming all bits-per-sample formats are byte-aligned which may not be the right way to do things
if (format.numChannels == 1)
{
format.channelMask = SL_SPEAKER_FRONT_CENTER;
}
else
{
format.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
}
format.endianness = SL_BYTEORDER_LITTLEENDIAN;
SLDataSource source;
source.pLocator = &inLocator;
source.pFormat = &format;
// output / destination
SLDataLocator_OutputMix outLocator;
outLocator.locatorType = SL_DATALOCATOR_OUTPUTMIX;
outLocator.outputMix = OPENSLES_MANAGER->outputMixObject;
SLDataSink destination;
destination.pLocator = &outLocator;
destination.pFormat = NULL;
// create player
SLresult result;
result = __CPP_WRAP_ARGS(OPENSLES_MANAGER->engine, CreateAudioPlayer, &this->playerObject, &source, &destination, reqsSize, ids, reqs);
CHECK_ERROR("Could not create player object!");
result = __CPP_WRAP_ARGS(this->playerObject, Realize, SL_BOOLEAN_FALSE);
CHECK_ERROR("Could not realize player object!");
result = __CPP_WRAP_ARGS(this->playerObject, GetInterface, SL_IID_PLAY, &this->player);
CHECK_ERROR("Could not get player play interface!");
result = __CPP_WRAP_ARGS(this->playerObject, GetInterface, SL_IID_VOLUME, &this->playerVolume);
CHECK_ERROR("Could not get player volume interface!");
result = __CPP_WRAP_ARGS(this->playerObject, GetInterface, SL_IID_ANDROIDSIMPLEBUFFERQUEUE, &this->playerBufferQueue);
CHECK_ERROR("Could not get player buffer queue interface!");
result = __CPP_WRAP_ARGS(this->player, RegisterCallback, &OpenSLES_Player::_playCallback, this);
CHECK_ERROR("Could not register callback!");
result = __CPP_WRAP_ARGS(this->player, SetCallbackEventsMask, SL_PLAYEVENT_HEADATEND);
CHECK_ERROR("Could not set callback mask!");
return true;
}
void OpenSLES_Player::_systemPrepareBuffer()
{
if (!this->sound->isStreamed())
{
if (!this->looping)
{
if (!this->paused)
{
this->_enqueueBuffer(this->buffer->getStream());
}
return;
}
int count = NORMAL_BUFFER_COUNT;
if (this->paused)
{
count -= this->buffersEnqueued;
}
else
{
this->buffersEnqueued = 0;
}
for_iter (i, 0, count)
{
this->_enqueueBuffer(this->buffer->getStream());
}
return;
}
int count = STREAM_BUFFER_COUNT;
if (this->paused)
{
count -= this->buffersEnqueued;
}
else
{
this->buffersEnqueued = 0;
}
if (count > 0)
{
count = this->_fillStreamBuffers(count);
if (count > 0)
{
this->_enqueueStreamBuffers(count);
}
}
}
void OpenSLES_Player::_systemUpdateGain()
{
if (this->playerVolume != NULL)
{
float gain = this->_calcGain();
SLmillibel value = -9600; // minimum possible attenuation/volume in mB
if (gain > 0.01f)
{
value = (SLmillibel)(log10(gain) * 2000);
}
__CPP_WRAP_ARGS(this->playerVolume, SetVolumeLevel, value);
}
}
void OpenSLES_Player::_systemUpdatePitch()
{
static bool _supported = true;
if (_supported)
{
hlog::warn(logTag, "Pitch change is not supported in this implementation! This message is only logged once.");
_supported = false;
}
// even though there is no crash, it doesn't seem possible to play a sound when obtaining a playback interface so this code is disabled for now
/*
if (this->playerPlaybackRate != NULL)
{
static bool _supported = true;
if (_supported)
{
SLpermille rateMin = 0;
SLpermille rateMax = 0x7FFF; // max short
SLpermille rateStep = 0;
SLuint32 capabilities = 0;
SLresult result = __CPP_WRAP_ARGS(this->playerPlaybackRate, GetRateRange, 0, &rateMin, &rateMax, &rateStep, &capabilities);
if (result != SL_RESULT_SUCCESS)
{
hlog::warn(logTag, "Pitch change is not supported on this device! This message is only logged once.");
_supported = false;
return;
}
SLpermille value = (SLpermille)hclamp(this->pitch * 1000, (float)rateMin, (float)rateMax);
value = ((value - rateMin) / rateStep) * rateStep + rateMin; // correcting value to use "step" properly
result = __CPP_WRAP_ARGS(this->playerPlaybackRate, SetRate, value);
if (result != SL_RESULT_SUCCESS)
{
hlog::warn(logTag, "Pitch change is not supported on this device! This message is only logged once.");
_supported = false;
}
}
}
//*/
}
void OpenSLES_Player::_systemPlay()
{
SLresult result = __CPP_WRAP_ARGS(this->player, SetPlayState, SL_PLAYSTATE_PLAYING);
if (result == SL_RESULT_SUCCESS)
{
this->playing = true;
this->stillPlaying = true;
this->active = true; // required, because otherwise the buffer will think it's done
}
else
{
hlog::warn(logTag, "Could not start: " + this->sound->getFilename());
}
}
int OpenSLES_Player::_systemStop()
{
if (this->playing && this->player != NULL)
{
if (this->paused)
{
SLresult result = __CPP_WRAP_ARGS(this->player, SetPlayState, SL_PLAYSTATE_PAUSED);
if (result == SL_RESULT_SUCCESS)
{
this->buffersEnqueued -= this->_getProcessedBuffersCount();
this->playing = false;
this->stillPlaying = false;
this->active = false;
}
else
{
hlog::warn(logTag, "Could not pause: " + this->sound->getFilename());
this->paused = false;
}
}
else
{
SLresult result = __CPP_WRAP_ARGS(this->player, SetPlayState, SL_PLAYSTATE_STOPPED);
if (result == SL_RESULT_SUCCESS)
{
this->bufferIndex = 0;
this->buffer->rewind();
__CPP_WRAP(this->playerBufferQueue, Clear);
this->buffersEnqueued = 0;
this->playing = false;
this->stillPlaying = false;
this->active = false;
// destroy system stuff
this->player = NULL;
this->playerVolume = NULL;
this->playerBufferQueue = NULL;
__CPP_WRAP(this->playerObject, Destroy);
this->playerObject = NULL;
}
else
{
hlog::warn(logTag, "Could not stop: " + this->sound->getFilename());
}
}
}
return 0;
}
void OpenSLES_Player::_systemUpdateNormal()
{
if (this->looping)
{
int processed = this->_getProcessedBuffersCount();
if (processed > 0)
{
this->buffersEnqueued -= processed;
for_iter (i, 0, processed)
{
this->_enqueueBuffer(this->buffer->getStream());
}
}
this->stillPlaying = true; // in case underrun happened, sound is regarded as stopped, but this flag is required in the update loop
if (this->buffersEnqueued == 0)
{
this->_stop();
}
}
}
int OpenSLES_Player::_systemUpdateStream()
{
if (this->buffersEnqueued == 0)
{
this->_stop();
return 0;
}
int processed = this->_getProcessedBuffersCount();
if (processed == 0)
{
this->stillPlaying = true; // don't remove, it prevents streamed sounds from being stopped
return 0;
}
this->buffersEnqueued -= processed;
int count = this->_fillStreamBuffers(processed);
if (count > 0)
{
this->_enqueueStreamBuffers(count);
this->stillPlaying = true; // in case underrun happened, sound is regarded as stopped, but this flag is required in the update loop
}
if (this->buffersEnqueued == 0)
{
this->_stop();
}
return 0; // because _systemGetBufferPosition() works on this platform properly and doesn't need this
}
void OpenSLES_Player::_enqueueBuffer(hstream& stream)
{
SLresult result = __CPP_WRAP_ARGS(this->playerBufferQueue, Enqueue, (unsigned char*)stream, (int)stream.size());
if (result == SL_RESULT_SUCCESS)
{
++this->buffersEnqueued;
}
else
{
hlog::warn(logTag, "Could not enqueue buffer!");
}
}
int OpenSLES_Player::_fillStreamBuffers(int count)
{
int size = this->buffer->load(this->looping, count * STREAM_BUFFER_SIZE);
int filled = (size + STREAM_BUFFER_SIZE - 1) / STREAM_BUFFER_SIZE;
hstream& stream = this->buffer->getStream();
int currentSize = 0;
for_iter (i, 0, filled)
{
currentSize = hmin(size, STREAM_BUFFER_SIZE);
memcpy(this->streamBuffers[this->bufferIndex], &stream[i * STREAM_BUFFER_SIZE], currentSize);
if (currentSize < STREAM_BUFFER_SIZE)
{
memset(&this->streamBuffers[this->bufferIndex][currentSize], 0, STREAM_BUFFER_SIZE - currentSize);
}
this->bufferIndex = (this->bufferIndex + 1) % STREAM_BUFFER_COUNT;
size -= STREAM_BUFFER_SIZE;
}
return filled;
}
void OpenSLES_Player::_enqueueStreamBuffers(int count)
{
int queued = 0;
int index = (this->bufferIndex + STREAM_BUFFER_COUNT - count) % STREAM_BUFFER_COUNT;
for_iter (i, 0, count)
{
SLresult result = __CPP_WRAP_ARGS(this->playerBufferQueue, Enqueue, this->streamBuffers[index], STREAM_BUFFER_SIZE);
if (result != SL_RESULT_SUCCESS)
{
hlog::warn(logTag, "Could not queue streamed buffer!");
break;
}
++queued;
index = (index + 1) % STREAM_BUFFER_COUNT;
}
this->buffersEnqueued += queued;
}
int OpenSLES_Player::_getProcessedBuffersCount()
{
SLresult result = __CPP_WRAP_ARGS(this->playerBufferQueue, GetState, &this->playerBufferQueueState);
if (result != SL_RESULT_SUCCESS)
{
return 0;
}
return (this->buffersEnqueued - this->playerBufferQueueState.count);
}
}
#endif
|
ea70815e1717d152e828676d6b014b06111fcefa | 80ea5578fb22d72d9158b05237a3c99e461d1e4a | /MorphingClockRemixRemix.ino | d248f66c6b3574a9adbab3e2fecf3e8ef1a6a7ee | [] | no_license | kolle86/MorphingClockRemixRemix | 870bcdcbab468e6673434d57a8203f67c5395487 | a50321232da3e3eb702ec1b95af2d388445e2c9c | refs/heads/master | 2020-04-07T00:22:57.630720 | 2019-07-25T17:12:24 | 2019-07-25T17:12:24 | 157,901,544 | 9 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 49,745 | ino | MorphingClockRemixRemix.ino | /*
remix from HarryFun's great Morphing Digital Clock idea https://github.com/hwiguna/HariFun_166_Morphing_Clock
follow the great tutorial there and eventually use this code as alternative
provided 'AS IS', use at your own risk
* mirel.t.lazar@gmail.com
*/
#include <TimeLib.h>
#include <NtpClientLib.h>
#include <ESP8266WiFi.h>
#define double_buffer
#include <PxMatrix.h>
#include "FS.h"
#include <ArduinoJson.h>
#ifdef ESP8266
#include <Ticker.h>
Ticker display_ticker;
#define P_LAT 16
#define P_A 5
#define P_B 4
#define P_C 15
#define P_D 12
#define P_E 0
#define P_OE 2
#endif
WiFiServer httpsvr (80); //Initialize the server on Port 80
// Pins for LED MATRIX
PxMATRIX display(64, 32, P_LAT, P_OE, P_A, P_B, P_C, P_D, P_E);
#include "TinyFont.h"
//=== SEGMENTS ===
#include "Digit.h"
Digit digit0(&display, 0, 63 - 1 - 9*1, 8, display.color565(0, 0, 255));
Digit digit1(&display, 0, 63 - 1 - 9*2, 8, display.color565(0, 0, 255));
Digit digit2(&display, 0, 63 - 4 - 9*3, 8, display.color565(0, 0, 255));
Digit digit3(&display, 0, 63 - 4 - 9*4, 8, display.color565(0, 0, 255));
Digit digit4(&display, 0, 63 - 7 - 9*5, 8, display.color565(0, 0, 255));
Digit digit5(&display, 0, 63 - 7 - 9*6, 8, display.color565(0, 0, 255));
#include "params.h"
#ifdef ESP8266
// ISR for display refresh
void display_updater ()
{
display.display (70);
}
#endif
void getWeather ();
byte hh;
byte mm;
byte ss;
byte ntpsync = 1;
const char ntpsvr[] = "pool.ntp.org";
//settings
#define NVARS 15
#define LVARS 12
char c_vars [NVARS][LVARS];
typedef enum e_vars {
EV_SSID = 0,
EV_SSID2 = 0,
EV_PASS,
EV_PASS2,
EV_TZ,
EV_24H,
EV_METRIC,
EV_DATEFMT,
EV_OWMK,
EV_OWMK2,
EV_OWMK3,
EV_GEOLOC,
EV_GEOLOC2,
EV_GEOLOC3,
EV_DST,
EV_MAX
};
bool toBool (String s)
{
return s.equals ("true");
}
int vars_read ()
{
File varf = SPIFFS.open ("/vars.cfg", "r");
if (!varf)
{
Serial.println ("Failed to open config file");
return 0;
}
//read vars
for (int i = 0; i < NVARS; i++)
for (int j = 0; j < LVARS; j++)
c_vars[i][j] = (char)varf.read ();
//
for (int i = 0; i < NVARS; i++)
{
Serial.print ("var ");
Serial.print (i);
Serial.print (": ");
Serial.println (c_vars[i]);
}
//
varf.close ();
return 1;
}
int vars_write ()
{
File varf = SPIFFS.open ("/vars.cfg", "w");
if (!varf)
{
Serial.println ("Failed to open config file");
return 0;
}
//read vars
for (int i = 0; i < NVARS; i++)
for (int j = 0; j < LVARS; j++)
if (varf.write (c_vars[i][j]) != 1)
Serial.println ("error writing var");
//
varf.close ();
return 1;
}
void setup ()
{
Serial.begin (115200);
while (!Serial)
delay (500); //delay for Leonardo
//display setup
display.begin (16);
#ifdef ESP8266
display_ticker.attach (0.002, display_updater);
#endif
//
Serial.println ("");
Serial.print ("Connecting");
TFDrawText (&display, String (" CONNECTING "), 0, 13, display.color565(0, 0, 255));
//connect to wifi network
WiFi.begin (wifi_ssid, wifi_pass);
while (WiFi.status () != WL_CONNECTED)
{
delay (500);
Serial.print(".");
}
Serial.println ("success!");
Serial.print ("IP Address is: ");
Serial.println (WiFi.localIP ()); //
TFDrawText (&display, String(" ONLINE "), 0, 13, display.color565(0, 0, 255));
//
if (SPIFFS.begin ())
{
Serial.println ("SPIFFS Initialize....ok");
if (!vars_read ())
{
//init vars
strcpy (c_vars[EV_TZ], timezone);
strcpy (c_vars[EV_24H], military);
strcpy (c_vars[EV_METRIC], u_metric);
strcpy (c_vars[EV_DATEFMT], date_fmt);
strcpy (c_vars[EV_DST], "false");
}
}
else
{
Serial.println ("SPIFFS Initialization...failed");
} //
Serial.print ("timezone=");
Serial.println (c_vars[EV_TZ]);
Serial.print ("military=");
Serial.println (c_vars[EV_24H]);
Serial.print ("metric=");
Serial.println (c_vars[EV_METRIC]);
Serial.print ("date-format=");
Serial.println (c_vars[EV_DATEFMT]);
Serial.print ("dst=");
Serial.println (c_vars[EV_DST]);
//delay (1500);
getWeather ();
//start NTP
NTP.begin (ntpsvr, String (c_vars[EV_TZ]).toInt(), toBool (String (c_vars[EV_DST])));
NTP.setInterval (10);//force rapid sync in 10sec
//
NTP.onNTPSyncEvent ([](NTPSyncEvent_t ntpEvent)
{
if (ntpEvent)
{
Serial.print ("Time Sync error: ");
if (ntpEvent == noResponse)
Serial.println ("NTP server not reachable");
else if (ntpEvent == invalidAddress)
Serial.println ("Invalid NTP server address");
}
else
{
Serial.print ("Got NTP time: ");
Serial.println (NTP.getTimeDateString (NTP.getLastNTPSync ()));
ntpsync = 1;
}
});
//prep screen for clock display
display.setBrightness(50);
display.fillScreen (0);
int cc_gry = display.color565 (128, 128, 128);
//reset digits color
digit0.SetColor (cc_gry);
digit1.SetColor (cc_gry);
digit2.SetColor (cc_gry);
digit3.SetColor (cc_gry);
digit4.SetColor (cc_gry);
digit5.SetColor (cc_gry);
digit1.DrawColon (cc_gry);
digit3.DrawColon (cc_gry);
//
Serial.print ("display color range [");
Serial.print (display.color565 (0, 0, 0));
Serial.print (" .. ");
Serial.print (display.color565 (255, 255, 255));
Serial.println ("]");
//
httpsvr.begin (); // Start the HTTP Server
}
const char server[] = "api.openweathermap.org";
WiFiClient client;
int tempMin = -10000;
int tempMax = -10000;
int tempM = -10000;
int presM = -10000;
int humiM = -10000;
int condM = -1; //-1 - undefined, 0 - unk, 1 - sunny, 2 - cloudy, 3 - overcast, 4 - rainy, 5 - thunders, 6 - snow
String condS = "";
int wind_speed;
int wind_nr;
String wind_direction = "";
int gust = 0;
void getWeather ()
{
if (!apiKey.length ())
{
Serial.println ("w:missing API KEY for weather data, skipping");
return;
}
Serial.print ("i:connecting to weather server.. ");
// if you get a connection, report back via serial:
if (client.connect (server, 80))
{
Serial.println ("connected.");
// Make a HTTP request:
client.print ("GET /data/2.5/weather?");
client.print ("q="+location);
client.print ("&appid="+apiKey);
client.print ("&cnt=1");
(*u_metric=='Y')?client.println ("&units=metric"):client.println ("&units=imperial");
client.println ("Host: api.openweathermap.org");
client.println ("Connection: close");
client.println ();
}
else
{
Serial.println ("w:unable to connect");
return;
}
delay (1000);
String sval = "";
int bT, bT2;
//do your best
String line = client.readStringUntil ('\n');
if (!line.length ())
Serial.println ("w:unable to retrieve weather data");
else
{
Serial.print ("weather:");
Serial.println (line);
//weather conditions - "main":"Clear",
bT = line.indexOf ("\"icon\":\"");
if (bT > 0)
{
bT2 = line.indexOf ("\"", bT + 8);
sval = line.substring (bT + 8, bT2);
Serial.print ("cond ");
Serial.println (sval);
//0 - unk, 1 - sunny, 2 - cloudy, 3 - overcast, 4 - rainy, 5 - thunders, 6 - snow
if (sval.equals("01d"))
condM = 1; //sunny
else if (sval.equals("01n"))
condM = 8; //clear night
else if (sval.equals("02d"))
condM = 2; //partly cloudy day
else if (sval.equals("02n"))
condM = 10; //partly cloudy night
else if (sval.equals("03d"))
condM = 3; //overcast day
else if (sval.equals("03n"))
condM = 11; //overcast night
else if (sval.equals("04d"))
condM = 3;//overcast day
else if (sval.equals("04n"))
condM = 11;//overcast night
else if (sval.equals("09d"))
condM = 4; //rain
else if (sval.equals("09n"))
condM = 4;
else if (sval.equals("10d"))
condM = 4;
else if (sval.equals("10n"))
condM = 4;
else if (sval.equals("11d"))
condM = 5; //thunder
else if (sval.equals("11n"))
condM = 5;
else if (sval.equals("13d"))
condM = 6; //snow
else if (sval.equals("13n"))
condM = 6;
else if (sval.equals("50d"))
condM = 7; //haze (day)
else if (sval.equals("50n"))
condM = 9; //fog (night)
//
condS = sval;
Serial.print ("condM ");
Serial.println (condM);
}
//tempM
bT = line.indexOf ("\"temp\":");
if (bT > 0)
{
bT2 = line.indexOf (",\"", bT + 7);
sval = line.substring (bT + 7, bT2);
Serial.print ("temp: ");
Serial.println (sval);
tempM = sval.toInt ();
}
else
Serial.println ("temp NOT found!");
//pressM
bT = line.indexOf ("\"pressure\":");
if (bT > 0)
{
bT2 = line.indexOf (",\"", bT + 11);
sval = line.substring (bT + 11, bT2);
Serial.print ("press ");
Serial.println (sval);
presM = sval.toInt();
}
else
Serial.println ("pressure NOT found!");
//humiM
bT = line.indexOf ("\"humidity\":");
if (bT > 0)
{
bT2 = line.indexOf (",\"", bT + 11);
sval = line.substring (bT + 11, bT2);
Serial.print ("humi ");
Serial.println (sval);
humiM = sval.toInt();
}
else
Serial.println ("humidity NOT found!");
//gust
bT = line.indexOf ("\"gust\":");
if (bT > 0)
{
bT2 = line.indexOf (",\"", bT + 7);
sval = line.substring (bT + 7, bT2);
gust = sval.toInt();
}
else
{
Serial.println ("windspeed NOT found!");
gust = 0;
}
//wind speed
bT = line.indexOf ("\"speed\":");
if (bT > 0)
{
bT2 = line.indexOf (",\"", bT + 8);
sval = line.substring (bT + 8, bT2);
wind_speed = sval.toInt();
}
else
Serial.println ("windspeed NOT found!");
//wind direction
bT = line.indexOf ("\"deg\":");
if (bT > 0)
{
bT2 = line.indexOf (",\"", bT + 6);
sval = line.substring (bT + 6, bT2);
wind_nr = round(((sval.toInt() % 360))/45.0) + 1;
switch (wind_nr){
case 1:
wind_direction = "N";
break;
case 2:
wind_direction = "NE";
break;
case 3:
wind_direction = "E";
break;
case 4:
wind_direction = "SE";
break;
case 5:
wind_direction = "S";
break;
case 6:
wind_direction = "SW";
break;
case 7:
wind_direction = "W";
break;
case 8:
wind_direction = "NW";
break;
case 9:
wind_direction = "N";
break;
default:
wind_direction = "";
break;
}
Serial.print ("wind direction ");
Serial.println(wind_direction);
}
else
{
Serial.println ("windspeed NOT found!");
wind_direction = "";
}
}//connected
}
#include "TinyIcons.h"
//icons 10x5: 10 cols, 5 rows
int moony_ico [50] = {
//3 nuances: 0x18c3 < 0x3186 < 0x4a49
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
};
int moony1_ico [50] = {
//3 nuances: 0x18c3 < 0x3186 < 0x4a49
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0xffff, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
};
int moony2_ico [50] = {
//3 nuances: 0x18c3 < 0x3186 < 0x4a49
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xffff, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
};
int moony3_ico [50] = {
//3 nuances: 0x18c3 < 0x3186 < 0x4a49
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000, 0xffff, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
};
int moony4_ico [50] = {
//3 nuances: 0x18c3 < 0x3186 < 0x4a49
0x0000, 0x0000, 0xffff, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
};
int sunny_ico [50] = {
0x0000, 0x0000, 0x0000, 0xffe0, 0x0000, 0x0000, 0xffe0, 0x0000, 0x0000, 0x0000,
0x0000, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0x0000,
0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
0xffe0, 0x0000, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0x0000, 0xffe0,
0x0000, 0x0000, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0x0000, 0x0000,
};
int sunny1_ico [50] = {
0x0000, 0x0000, 0x0000, 0xffe0, 0x0000, 0x0000, 0xffff, 0x0000, 0x0000, 0x0000,
0x0000, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0x0000,
0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
0xffe0, 0x0000, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0x0000, 0xffff,
0x0000, 0x0000, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0x0000, 0x0000,
};
int sunny2_ico [50] = {
0x0000, 0x0000, 0x0000, 0xffff, 0x0000, 0x0000, 0xffe0, 0x0000, 0x0000, 0x0000,
0x0000, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffff, 0x0000,
0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
0xffff, 0x0000, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0x0000, 0xffe0,
0x0000, 0x0000, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0x0000, 0x0000,
};
int cloudy_ico [50] = {
0x0000, 0x0000, 0x0000, 0xffe0, 0x0000, 0x0000, 0xffe0, 0x0000, 0x0000, 0x0000,
0x0000, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffe0, 0x0000,
0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000,
0xffe0, 0x0000, 0xffe0, 0xffe0, 0xffe0, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0xffff, 0x0000, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0xffff, 0xffff, 0xffff, 0xffff,
};
int cloudy1_ico [50] = {
0x0000, 0x0000, 0x0000, 0xffe0, 0x0000, 0x0000, 0xffff, 0x0000, 0x0000, 0x0000,
0x0000, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000,
0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0xffe0, 0xffff, 0xffff, 0xffff, 0xffff,
0xffff, 0x0000, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0xffff, 0xffff, 0xffff, 0xffff,
0xffff, 0xffff, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0xffff, 0xffff, 0xffff,
};
int cloudy2_ico [50] = {
0x0000, 0x0000, 0x0000, 0xffff, 0x0000, 0x0000, 0xffe0, 0x0000, 0x0000, 0x0000,
0x0000, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff,
0xffff, 0x0000, 0x0000, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0xffff, 0xffff, 0xffff,
0xffff, 0xffff, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0xffff, 0xffff, 0xffff,
0xffff, 0xffff, 0xffff, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0xffff, 0xffff,
};
int cloudy3_ico [50] = {
0x0000, 0x0000, 0x0000, 0xffe0, 0x0000, 0x0000, 0xffff, 0x0000, 0x0000, 0x0000,
0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffff,
0xffff, 0xffff, 0x0000, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0x0000, 0xffff, 0xffff,
0xffff, 0xffff, 0xffff, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0xffff, 0xffff,
0xffff, 0xffff, 0xffff, 0xffff, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0x0000, 0xffff,
};
int cloudy4_ico [50] = {
0x0000, 0x0000, 0x0000, 0xffff, 0x0000, 0x0000, 0xffe0, 0x0000, 0x0000, 0x0000,
0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffff, 0x0000,
0xffff, 0xffff, 0xffff, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0x0000, 0x0000, 0xffff,
0xffff, 0xffff, 0xffff, 0xffff, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0x0000, 0xffff,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffe0, 0xffe0, 0xffe0, 0x0000, 0x0000,
};
int cloudy5_ico [50] = {
0x0000, 0x0000, 0x0000, 0xffe0, 0x0000, 0x0000, 0xffff, 0x0000, 0x0000, 0x0000,
0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0x0000,
0xffff, 0xffff, 0xffff, 0xffff, 0xffe0, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffe0, 0xffe0, 0xffe0, 0x0000, 0xffff,
0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffe0, 0xffe0, 0x0000, 0x0000,
};
int cloudy6_ico [50] = {
0x0000, 0x0000, 0x0000, 0xffff, 0x0000, 0x0000, 0xffe0, 0x0000, 0x0000, 0x0000,
0x0000, 0xffe0, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0xffff, 0x0000,
0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffe0, 0xffe0, 0x0000, 0xffe0,
0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffe0, 0x0000, 0x0000,
};
int cloudy7_ico [50] = {
0x0000, 0x0000, 0x0000, 0xffe0, 0x0000, 0x0000, 0xffff, 0x0000, 0x0000, 0x0000,
0x0000, 0xffff, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0xffe0, 0x0000,
0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffe0, 0x0000, 0x0000, 0x0000,
0xffe0, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffe0, 0x0000, 0xffff,
0x0000, 0x0000, 0xffe0, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000,
};
int cloudy8_ico [50] = {
0x0000, 0x0000, 0x0000, 0xffff, 0x0000, 0x0000, 0xffe0, 0x0000, 0x0000, 0x0000,
0x0000, 0xffe0, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0x0000,
0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000,
0xffff, 0x0000, 0xffe0, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0xffe0,
0x0000, 0x0000, 0xffe0, 0xffe0, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000,
};
int cloudy9_ico [50] = {
0x0000, 0x0000, 0x0000, 0xffe0, 0x0000, 0x0000, 0xffff, 0x0000, 0x0000, 0x0000,
0x0000, 0xffff, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0xffe0, 0x0000,
0x0000, 0x0000, 0x0000, 0xffe0, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000,
0xffe0, 0x0000, 0xffe0, 0xffe0, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0x0000, 0x0000, 0xffe0, 0xffe0, 0xffe0, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
};
int cloudyn_ico [50] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0xffff, 0xffff, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffff, 0xffff, 0xffff, 0xffff,
};
int cloudy1n_ico [50] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0xffff, 0xffff, 0x0000,
0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff,
0xffff, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0xffff, 0xffff, 0xffff, 0xffff,
0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0xffff, 0xffff, 0xffff,
};
int cloudy2n_ico [50] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0xffff, 0xffff,
0xffff, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff,
0xffff, 0xffff, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0xffff, 0xffff, 0xffff,
0xffff, 0xffff, 0xffff, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0xffff, 0xffff,
};
int cloudy3n_ico [50] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
0xffff, 0xffff, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000, 0xffff,
0xffff, 0xffff, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff,
0xffff, 0xffff, 0xffff, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0xffff, 0xffff,
0xffff, 0xffff, 0xffff, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0xffff,
};
int cloudy4n_ico [50] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
0xffff, 0xffff, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000,
0xffff, 0xffff, 0xffff, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000, 0xffff,
0xffff, 0xffff, 0xffff, 0xffff, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000, 0xffff,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
};
int cloudy5n_ico [50] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
0x0000, 0xffff, 0xffff, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000,
0xffff, 0xffff, 0xffff, 0xffff, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffe0, 0x0000, 0x0000, 0x0000,
};
int cloudy6n_ico [50] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xffff, 0xffff, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000,
};
int cloudy7n_ico [50] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000,
};
int cloudy8n_ico [50] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000,
};
int cloudy9n_ico [50] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0xffe0, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
};
int ovrcst_ico [50] = {
0x0000, 0x0000, 0x0000, 0xffe0, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000,
0x0000, 0xffe0, 0xffff, 0xffff, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000,
0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000,
0xffe0, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffe0,
0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000,
};
int ovrcst1_ico [50] = {
0x0000, 0x0000, 0x0000, 0xffe0, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000,
0x0000, 0xffff, 0xffff, 0xffff, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000,
0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000,
0xffe0, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000,
};
int ovrcst2_ico [50] = {
0x0000, 0x0000, 0x0000, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000,
0x0000, 0xffe0, 0xffff, 0xffff, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000,
0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffe0,
0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000,
};
int ovrcstn_ico [50] = {
0x0000, 0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0xffff, 0xffff, 0x0000, 0x0000,
0x0000, 0x0000, 0xffff, 0xffff, 0xffe0, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000,
0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000,
0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000,
0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000,
};
int thndr_ico [50] = {
0x041f, 0xc618, 0x041f, 0xc618, 0xc618, 0xc618, 0x041f, 0xc618, 0xc618, 0x041f,
0xc618, 0xc618, 0xc618, 0xc618, 0x041f, 0xc618, 0xc618, 0x041f, 0xc618, 0xc618,
0xc618, 0x041f, 0xc618, 0xc618, 0xc618, 0x041f, 0xc618, 0xc618, 0xc618, 0xc618,
0xc618, 0xc618, 0xc618, 0x041f, 0xc618, 0xc618, 0xc618, 0xc618, 0xc618, 0x041f,
0xc618, 0x041f, 0xc618, 0xc618, 0xc618, 0xc618, 0x041f, 0xc618, 0x041f, 0xc618,
};
int rain_ico [50] = {
0x041f, 0x0000, 0x041f, 0x0000, 0x0000, 0x0000, 0x041f, 0x0000, 0x0000, 0x041f,
0x0000, 0x0000, 0x0000, 0x0000, 0x041f, 0x0000, 0x0000, 0x041f, 0x0000, 0x0000,
0x0000, 0x041f, 0x0000, 0x0000, 0x0000, 0x041f, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x041f, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x041f,
0x0000, 0x041f, 0x0000, 0x0000, 0x0000, 0x0000, 0x041f, 0x0000, 0x041f, 0x0000,
};
int rain1_ico [50] = {
0x0000, 0x041f, 0x0000, 0x0000, 0x0000, 0x0000, 0x041f, 0x0000, 0x041f, 0x0000,
0x041f, 0x0000, 0x041f, 0x0000, 0x0000, 0x0000, 0x041f, 0x0000, 0x0000, 0x041f,
0x0000, 0x0000, 0x0000, 0x0000, 0x041f, 0x0000, 0x0000, 0x041f, 0x0000, 0x0000,
0x0000, 0x041f, 0x0000, 0x0000, 0x0000, 0x041f, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x041f, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x041f,
};
int rain2_ico [50] = {
0x0000, 0x0000, 0x0000, 0x041f, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x041f,
0x0000, 0x041f, 0x0000, 0x0000, 0x0000, 0x0000, 0x041f, 0x0000, 0x041f, 0x0000,
0x041f, 0x0000, 0x041f, 0x0000, 0x0000, 0x0000, 0x041f, 0x0000, 0x0000, 0x041f,
0x0000, 0x0000, 0x0000, 0x0000, 0x041f, 0x0000, 0x0000, 0x041f, 0x0000, 0x0000,
0x0000, 0x041f, 0x0000, 0x0000, 0x0000, 0x041f, 0x0000, 0x0000, 0x0000, 0x0000,
};
int rain3_ico [50] = {
0x0000, 0x041f, 0x0000, 0x0000, 0x0000, 0x041f, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x041f, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x041f,
0x0000, 0x041f, 0x0000, 0x0000, 0x0000, 0x0000, 0x041f, 0x0000, 0x041f, 0x0000,
0x041f, 0x0000, 0x041f, 0x0000, 0x0000, 0x0000, 0x041f, 0x0000, 0x0000, 0x041f,
0x0000, 0x0000, 0x0000, 0x0000, 0x041f, 0x0000, 0x0000, 0x041f, 0x0000, 0x0000,
};
int rain4_ico [50] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x041f, 0x0000, 0x0000, 0x041f, 0x0000, 0x0000,
0x0000, 0x041f, 0x0000, 0x0000, 0x0000, 0x041f, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x041f, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x041f,
0x0000, 0x041f, 0x0000, 0x0000, 0x0000, 0x0000, 0x041f, 0x0000, 0x041f, 0x0000,
0x041f, 0x0000, 0x041f, 0x0000, 0x0000, 0x0000, 0x041f, 0x0000, 0x0000, 0x041f,
};
int snow_ico [50] = {
0xc618, 0x0000, 0xc618, 0x0000, 0x0000, 0x0000, 0xc618, 0x0000, 0x0000, 0xc618,
0x0000, 0x0000, 0x0000, 0x0000, 0xc618, 0x0000, 0x0000, 0xc618, 0x0000, 0x0000,
0x0000, 0xc618, 0x0000, 0x0000, 0x0000, 0xc618, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0xc618, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xc618,
0x0000, 0xc618, 0x0000, 0x0000, 0x0000, 0x0000, 0xc618, 0x0000, 0xc618, 0x0000,
};
int snow1_ico [50] = {
0x0000, 0xc618, 0x0000, 0x0000, 0x0000, 0x0000, 0xc618, 0x0000, 0xc618, 0x0000,
0xc618, 0x0000, 0xc618, 0x0000, 0x0000, 0x0000, 0xc618, 0x0000, 0x0000, 0xc618,
0x0000, 0x0000, 0x0000, 0x0000, 0xc618, 0x0000, 0x0000, 0xc618, 0x0000, 0x0000,
0x0000, 0xc618, 0x0000, 0x0000, 0x0000, 0xc618, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0xc618, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xc618,
};
int snow2_ico [50] = {
0x0000, 0x0000, 0x0000, 0xc618, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xc618,
0x0000, 0xc618, 0x0000, 0x0000, 0x0000, 0x0000, 0xc618, 0x0000, 0xc618, 0x0000,
0xc618, 0x0000, 0xc618, 0x0000, 0x0000, 0x0000, 0xc618, 0x0000, 0x0000, 0xc618,
0x0000, 0x0000, 0x0000, 0x0000, 0xc618, 0x0000, 0x0000, 0xc618, 0x0000, 0x0000,
0x0000, 0xc618, 0x0000, 0x0000, 0x0000, 0xc618, 0x0000, 0x0000, 0x0000, 0x0000,
};
int snow3_ico [50] = {
0x0000, 0xc618, 0x0000, 0x0000, 0x0000, 0xc618, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0xc618, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xc618,
0x0000, 0xc618, 0x0000, 0x0000, 0x0000, 0x0000, 0xc618, 0x0000, 0xc618, 0x0000,
0xc618, 0x0000, 0xc618, 0x0000, 0x0000, 0x0000, 0xc618, 0x0000, 0x0000, 0xc618,
0x0000, 0x0000, 0x0000, 0x0000, 0xc618, 0x0000, 0x0000, 0xc618, 0x0000, 0x0000,
};
int snow4_ico [50] = {
0x0000, 0x0000, 0x0000, 0x0000, 0xc618, 0x0000, 0x0000, 0xc618, 0x0000, 0x0000,
0x0000, 0xc618, 0x0000, 0x0000, 0x0000, 0xc618, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0xc618, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xc618,
0x0000, 0xc618, 0x0000, 0x0000, 0x0000, 0x0000, 0xc618, 0x0000, 0xc618, 0x0000,
0xc618, 0x0000, 0xc618, 0x0000, 0x0000, 0x0000, 0xc618, 0x0000, 0x0000, 0xc618,
};
int mist_ico [50] = {
0xf81f, 0xf81f, 0x0000, 0x0000, 0xf81f, 0xf81f, 0x0000, 0x0000, 0xf81f, 0xf81f,
0x0000, 0x0000, 0xf81f, 0xf81f, 0x0000, 0x0000, 0xf81f, 0xf81f, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
0xf81f, 0xf81f, 0xffe0, 0xffe0, 0xf81f, 0xf81f, 0xffe0, 0xffe0, 0xf81f, 0xf81f,
0x0000, 0x0000, 0xf81f, 0xf81f, 0xffe0, 0xffe0, 0xf81f, 0xf81f, 0x0000, 0x0000,
};
int mist1_ico [50] = {
0x0000, 0xf81f, 0xf81f, 0x0000, 0x0000, 0xf81f, 0xf81f, 0x0000, 0x0000, 0xf81f,
0xf81f, 0x0000, 0x0000, 0xf81f, 0xf81f, 0x0000, 0x0000, 0xf81f, 0xf81f, 0x0000,
0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
0x0000, 0xf81f, 0xf81f, 0xffe0, 0xffe0, 0xf81f, 0xf81f, 0xffe0, 0x0000, 0xf81f,
0xf81f, 0x0000, 0xffe0, 0xf81f, 0xf81f, 0xffe0, 0xffe0, 0xf81f, 0xf81f, 0x0000,
};
int mist2_ico [50] = {
0x0000, 0x0000, 0xf81f, 0xf81f, 0x0000, 0x0000, 0xf81f, 0xf81f, 0x0000, 0x0000,
0xf81f, 0xf81f, 0x0000, 0x0000, 0xf81f, 0xf81f, 0x0000, 0x0000, 0xf81f, 0xf81f,
0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xf81f, 0xf81f, 0xffe0, 0xffe0, 0xf81f, 0xf81f, 0x0000, 0x0000,
0xf81f, 0xf81f, 0xffe0, 0xffe0, 0xf81f, 0xf81f, 0xffe0, 0xffe0, 0xf81f, 0xf81f,
};
int mist3_ico [50] = {
0xf81f, 0x0000, 0x0000, 0xf81f, 0xf81f, 0x0000, 0x0000, 0xf81f, 0xf81f, 0x0000,
0x0000, 0xf81f, 0xf81f, 0x0000, 0x0000, 0xf81f, 0xf81f, 0x0000, 0x0000, 0xf81f,
0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000,
0xf81f, 0x0000, 0xffe0, 0xf81f, 0xf81f, 0xffe0, 0xffe0, 0xf81f, 0xf81f, 0x0000,
0x0000, 0xf81f, 0xf81f, 0xffe0, 0xffe0, 0xf81f, 0xf81f, 0xffe0, 0x0000, 0xf81f,
};
int mistn_ico [50] = {
0xf81f, 0xf81f, 0x0000, 0x0000, 0xf81f, 0xf81f, 0xffe0, 0x0000, 0xf81f, 0xf81f,
0x0000, 0x0000, 0xf81f, 0xf81f, 0xffe0, 0xffe0, 0xf81f, 0xf81f, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0xf81f, 0xf81f, 0x0000, 0x0000, 0xf81f, 0xf81f, 0x0000, 0x0000, 0xf81f, 0xf81f,
0x0000, 0x0000, 0xf81f, 0xf81f, 0x0000, 0xffe0, 0xf81f, 0xf81f, 0x0000, 0x0000,
};
int mist1n_ico [50] = {
0x0000, 0xf81f, 0xf81f, 0x0000, 0x0000, 0xf81f, 0xf81f, 0x0000, 0x0000, 0xf81f,
0xf81f, 0x0000, 0x0000, 0xf81f, 0xf81f, 0xffe0, 0x0000, 0xf81f, 0xf81f, 0x0000,
0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0xf81f, 0xf81f, 0x0000, 0xffe0, 0xf81f, 0xf81f, 0x0000, 0x0000, 0xf81f,
0xf81f, 0x0000, 0x0000, 0xf81f, 0xf81f, 0xffe0, 0xffe0, 0xf81f, 0xf81f, 0x0000,
};
int mist2n_ico [50] = {
0x0000, 0x0000, 0xf81f, 0xf81f, 0x0000, 0xffe0, 0xf81f, 0xf81f, 0x0000, 0x0000,
0xf81f, 0xf81f, 0x0000, 0x0000, 0xf81f, 0xf81f, 0x0000, 0x0000, 0xf81f, 0xf81f,
0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xf81f, 0xf81f, 0xffe0, 0xffe0, 0xf81f, 0xf81f, 0x0000, 0x0000,
0xf81f, 0xf81f, 0x0000, 0x0000, 0xf81f, 0xf81f, 0xffe0, 0x0000, 0xf81f, 0xf81f,
};
int mist3n_ico [50] = {
0xf81f, 0x0000, 0x0000, 0xf81f, 0xf81f, 0xffe0, 0xffe0, 0xf81f, 0xf81f, 0x0000,
0x0000, 0xf81f, 0xf81f, 0x0000, 0xffe0, 0xf81f, 0xf81f, 0x0000, 0x0000, 0xf81f,
0x0000, 0x0000, 0x0000, 0xffe0, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0xf81f, 0x0000, 0x0000, 0xf81f, 0xf81f, 0xffe0, 0x0000, 0xf81f, 0xf81f, 0x0000,
0x0000, 0xf81f, 0xf81f, 0x0000, 0x0000, 0xf81f, 0xf81f, 0x0000, 0x0000, 0xf81f,
};
int *suny_ani[] = {sunny_ico, sunny1_ico, sunny2_ico, sunny1_ico, sunny2_ico};
int *clod_ani[] = {cloudy_ico, cloudy1_ico, cloudy2_ico, cloudy3_ico, cloudy4_ico, cloudy5_ico, cloudy6_ico, cloudy7_ico, cloudy8_ico, cloudy9_ico};
int *ovct_ani[] = {ovrcst_ico, ovrcst1_ico, ovrcst2_ico, ovrcst1_ico, ovrcst2_ico};
int *rain_ani[] = {rain_ico, rain1_ico, rain2_ico, rain3_ico, rain4_ico};
int *thun_ani[] = {thndr_ico, rain1_ico, rain2_ico, rain3_ico, rain4_ico};
int *snow_ani[] = {snow_ico, snow1_ico, snow2_ico, snow3_ico, snow4_ico};
int *mony_ani[] = {moony_ico, moony1_ico, moony_ico, moony_ico, moony_ico, moony2_ico, moony_ico, moony_ico, moony3_ico, moony_ico, moony_ico, moony_ico, moony_ico, moony4_ico, moony_ico, moony_ico, moony_ico};
int *mist_ani[] = {mist_ico, mist1_ico, mist2_ico, mist3_ico};
int *mistn_ani[] = {mistn_ico, mist1n_ico, mist2n_ico, mist3n_ico};
int *clodn_ani[] = {cloudyn_ico, cloudy1n_ico, cloudy2n_ico, cloudy3n_ico, cloudy4n_ico, cloudy5n_ico, cloudy6n_ico, cloudy7n_ico, cloudy8n_ico, cloudy9n_ico};
int *ovctn_ani[] = {ovrcstn_ico};
int xo = 1, yo = 26;
char use_ani = 0;
void draw_weather_conditions ()
{
//0 - unk, 1 - sunny, 2 - cloudy, 3 - overcast, 4 - rainy, 5 - thunders, 6 - snow
Serial.print ("weather conditions ");
Serial.println (condM);
//cleanup previous cond
xo = 3*TF_COLS; yo = 1;
if (condM == 0)
{
Serial.print ("!weather condition icon unknown, show: ");
Serial.println (condS);
int cc_dgr = display.color565 (30, 30, 30);
//draw the first 5 letters from the unknown weather condition
String lstr = condS.substring (0, (condS.length () > 5?5:condS.length ()));
lstr.toUpperCase ();
TFDrawText (&display, lstr, xo, yo, cc_dgr);
}
else
{
TFDrawText (&display, String(" "), xo, yo, 0);
}
//
xo = 4*TF_COLS; yo = 1;
switch (condM)
{
case 0://unk
break;
case 1://sunny
DrawIcon (&display, sunny_ico, xo, yo, 10, 5);
//DrawIcon (&display, cloudy_ico, xo, yo, 10, 5);
//DrawIcon (&display, ovrcst_ico, xo, yo, 10, 5);
//DrawIcon (&display, rain_ico, xo, yo, 10, 5);
use_ani = 1;
break;
case 2://cloudy
DrawIcon (&display, cloudy_ico, xo, yo, 10, 5);
use_ani = 1;
break;
case 3://overcast
DrawIcon (&display, ovrcst_ico, xo, yo, 10, 5);
use_ani = 1;
break;
case 4://rainy
DrawIcon (&display, rain_ico, xo, yo, 10, 5);
use_ani = 1;
break;
case 5://thunders
DrawIcon (&display, thndr_ico, xo, yo, 10, 5);
use_ani = 1;
break;
case 6://snow
DrawIcon (&display, snow_ico, xo, yo, 10, 5);
use_ani = 1;
break;
case 7://mist
DrawIcon (&display, mist_ico, xo, yo, 10, 5);
use_ani = 1;
break;
case 8://clear night
DrawIcon (&display, moony_ico, xo, yo, 10, 5);
use_ani = 1;
break;
case 9://fog night
DrawIcon (&display, mistn_ico, xo, yo, 10, 5);
use_ani = 1;
break;
case 10://partly cloudy night
DrawIcon (&display, cloudyn_ico, xo, yo, 10, 5);
use_ani = 1;
break;
case 11://cloudy night
DrawIcon (&display, ovrcstn_ico, xo, yo, 10, 5);
use_ani = 1;
break;
}
}
void draw_weather ()
{
int cc_wht = display.color565 (255, 255, 255);
int cc_red = display.color565 (255, 0, 0);
int cc_org = display.color565 (255, 165, 0);
int cc_grn = display.color565 (0, 255, 0);
int cc_blu = display.color565 (0, 128, 255);
int cc_ylw = display.color565 (255, 255, 0);
int cc_gry = display.color565 (128, 128, 128);
int cc_dgr = display.color565 (30, 30, 30);
int cc_lblu = display.color565 (0, 255, 255);
int cc_ppl = display.color565 (255, 0, 255);
int value = 0;
Serial.println ("showing the weather");
xo = 0; yo = 1;
TFDrawText (&display, String(" "), xo, yo, cc_dgr);
if (tempM == -10000 || humiM == -10000 || presM == -10000)
{
//TFDrawText (&display, String("NO WEATHER DATA"), xo, yo, cc_dgr);
Serial.println ("!no weather data available");
}
else
{
//weather below the clock
//-temperature
int lcc = cc_red;
if (*u_metric == 'Y')
{
lcc = cc_red;
if (tempM < 30)
lcc = cc_org;
if (tempM < 25)
lcc = cc_ylw;
if (tempM < 20)
lcc = cc_grn;
if (tempM < 15)
lcc = cc_blu;
if (tempM < 10)
lcc = cc_lblu;
if (tempM < 1)
lcc = cc_wht;
}
else
{
//F
if (tempM < 79)
lcc = cc_grn;
if (tempM < 64)
lcc = cc_blu;
if (tempM < 43)
lcc = cc_wht;
}
//
String lstr = String (tempM) + String((*u_metric=='Y')?"C":"F");
Serial.print ("temperature: ");
Serial.println (lstr);
TFDrawText (&display, lstr, xo, yo, lcc);
//weather conditions
//-humidity
lcc = cc_red;
if (humiM < 80)
lcc = cc_org;
if (humiM < 60)
lcc = cc_grn;
if (humiM < 40)
lcc = cc_blu;
if (humiM < 20)
lcc = cc_wht;
lstr = String (humiM) + "%";
xo = 8*TF_COLS;
TFDrawText (&display, lstr, xo, yo, lcc);
//-pressure
lstr = String (presM);
xo = 12*TF_COLS;
if(presM < 1000)
xo=13*TF_COLS;
TFDrawText (&display, lstr, xo, yo, cc_gry);
//draw wind speed and direction
if (wind_speed > -10000)
{
xo = 0*TF_COLS; yo = 26;
TFDrawText (&display, " ", xo, yo, 0);
//if there is gust, draw gust instead of wind speed
if(gust > wind_speed)
{
value = gust;
}else
{
value = wind_speed;
} //if there is gust, draw gust instead of wind speed
lstr = String (value) + String((gust>wind_speed)?"'":"");
int ct = cc_wht;
if(value>=1){
ct = cc_grn;
}
if (value >= 4)
{
ct = cc_lblu;
}
if (value >= 8)
{
ct = cc_blu;
}
if (value >= 12)
{
ct = cc_ylw;
}
if (value >= 16)
{
ct = cc_org;
}
if (value >= 20)
{
ct = cc_red;
}
Serial.print ("wind_speed: ");
Serial.println (lstr);
TFDrawText (&display, lstr, xo, yo, ct);
}
if (wind_direction)
{
xo = 14*TF_COLS; yo = 26;
TFDrawText (&display, " ", xo, yo, 0);
if(wind_direction.length() == 1)
xo=15*TF_COLS;
TFDrawText (&display, " ", xo, yo, 0);
lstr = String (wind_direction);// + String((*u_metric=='Y')?"C":"F");
Serial.print ("wind_direction: ");
Serial.println (lstr);
TFDrawText (&display, lstr, xo, yo, cc_gry);
}
//weather conditions
draw_weather_conditions ();
}
}
void draw_love ()
{
Serial.println ("showing some love");
use_ani = 0;
//love*you,boo
yo = 1;
int cc = random (255, 65535);
xo = 0; TFDrawChar (&display, 'L', xo, yo, cc); cc = random (255, 65535);
xo += 4; TFDrawChar (&display, 'O', xo, yo, cc); cc = random (255, 65535);
xo += 4; TFDrawChar (&display, 'V', xo, yo, cc); cc = random (255, 65535);
xo += 4; TFDrawChar (&display, 'E', xo, yo, cc); cc = random (255, 65535);
xo += 4; TFDrawChar (&display, ' ', xo, yo, cc); cc = random (255, 65535);
xo += 4; TFDrawChar (&display, 'h', xo, yo, display.color565 (255, 0, 0));
xo += 4; TFDrawChar (&display, 'i', xo, yo, display.color565 (255, 0, 0));
xo += 4; TFDrawChar (&display, ' ', xo, yo, cc); cc = random (255, 65535);
xo += 4; TFDrawChar (&display, 'Y', xo, yo, cc); cc = random (255, 65535);
xo += 4; TFDrawChar (&display, 'O', xo, yo, cc); cc = random (255, 65535);
xo += 4; TFDrawChar (&display, 'U', xo, yo, cc); cc = random (255, 65535);
xo += 4; TFDrawChar (&display, ',', xo, yo, cc); cc = random (255, 65535);
xo += 4; TFDrawChar (&display, ' ', xo, yo, cc); cc = random (255, 65535);
xo += 4; TFDrawChar (&display, 'B', xo, yo, cc); cc = random (255, 65535);
xo += 4; TFDrawChar (&display, 'O', xo, yo, cc); cc = random (255, 65535);
xo += 4; TFDrawChar (&display, 'O', xo, yo, cc); cc = random (255, 65535);
}
//
void draw_date ()
{
int cc_grn = display.color565 (255, 0, 255);
Serial.println ("showing the date");
//for (int i = 0 ; i < 12; i++)
//TFDrawChar (&display, '0' + i%10, xo + i * 5, yo, display.color565 (0, 255, 0));
//date below the clock
long tnow = now();
String lstr = "";
for (int i = 0; i < 5; i += 2)
{
switch (date_fmt[i])
{
case 'D':
lstr += (day(tnow) < 10 ? "0" + String(day(tnow)) : String(day(tnow)));
if (i < 4)
lstr += date_fmt[i + 1];
break;
case 'M':
lstr += (month(tnow) < 10 ? "0" + String(month(tnow)) : String(month(tnow)));
if (i < 4)
lstr += date_fmt[i + 1];
break;
case 'Y':
lstr += String(year(tnow));
if (i < 4)
lstr += date_fmt[i + 1];
break;
}
}
//
if (lstr.length())
{
//
xo = 3*TF_COLS; yo = 26;
TFDrawText (&display, lstr, xo, yo, cc_grn);
}
}
void draw_animations (int stp)
{
//weather icon animation
int xo = 4*TF_COLS;
int yo = 1;
//0 - unk, 1 - sunny, 2 - cloudy, 3 - overcast, 4 - rainy, 5 - thunders, 6 - snow
if (use_ani)
{
int *af = NULL;
switch (condM)
{
case 1:
af = suny_ani[stp%5];
break;
case 2:
af = clod_ani[stp%10];
break;
case 3:
af = ovct_ani[stp%5];
break;
case 4:
af = rain_ani[stp%5];
break;
case 5:
af = thun_ani[stp%5];
break;
case 6:
af = snow_ani[stp%5];
break;
case 7:
af = mist_ani[stp%4];
break;
case 8:
af = mony_ani[stp%17];
break;
case 9:
af = mistn_ani[stp%4];
break;
case 10:
af = clodn_ani[stp%10];
break;
case 11:
af = ovctn_ani[stp%1];
break;
}
//draw animation
if (af)
DrawIcon (&display, af, xo, yo, 10, 5);
}
}
byte prevhh = 0;
byte prevmm = 0;
byte prevss = 0;
WiFiClient httpcli;
//handle web server requests
void web_server ()
{
httpcli = httpsvr.available ();
if (httpcli)
{
char svf = 0;
//Read what the browser has sent into a String class and print the request to the monitor
String httprq = httpcli.readString ();
//Looking under the hood
Serial.println (httprq);
int pidx = -1;
//
String httprsp = "HTTP/1.1 200 OK\r\n";
httprsp += "Content-type: text/html\r\n\r\n";
httprsp += "<!DOCTYPE HTML>\r\n<html>\r\n";
if (httprq.indexOf ("/daylight/on ") != -1)
{
strcpy (c_vars[EV_DST], "true");
NTP.begin (ntpsvr, String (c_vars[EV_TZ]).toInt (), toBool(String (c_vars[EV_DST])));
httprsp += "<strong>daylight: on</strong><br>";
Serial.println ("daylight ON");
svf = 1;
}
else if (httprq.indexOf ("/daylight/off ") != -1)
{
strcpy (c_vars[EV_DST], "false");
NTP.begin (ntpsvr, String (c_vars[EV_TZ]).toInt (), toBool(String (c_vars[EV_DST])));
httprsp += "<strong>daylight: off</strong><br>";
Serial.println ("daylight OFF");
svf = 1;
}else if ((pidx = httprq.indexOf ("/brightness/")) != -1)
{
int pidx2 = httprq.indexOf (" ", pidx + 12);
if (pidx2 != -1)
{
String bri = httprq.substring (pidx + 12, pidx2);
display.setBrightness (bri.toInt ());
Serial.print (">brightness: ");
Serial.println (bri);
}
}
else if ((pidx = httprq.indexOf ("/timezone/")) != -1)
{
int pidx2 = httprq.indexOf (" ", pidx + 10);
if (pidx2 != -1)
{
String tz = httprq.substring (pidx + 10, pidx2);
//strcpy (timezone, tz.c_str ());
strcpy (c_vars[EV_TZ], tz.c_str ());
NTP.begin (ntpsvr, String (c_vars[EV_TZ]).toInt (), toBool(String (c_vars[EV_DST])));
httprsp += "<strong>timezone:" + tz + "</strong><br>";
Serial.print ("timezone: ");
Serial.println (c_vars[EV_TZ]);
svf = 1;
}
else
{
httprsp += "<strong>!invalid timezone!</strong><br>";
Serial.print ("invalid timezone");
}
}
//
httprsp += "<br><br>use the following configuration links<br>";
httprsp += "<a href='/timezone/0'>timezone 0</a><br>";
httprsp += "<a href='/timezone/1'>timezone 1</a><br>";
httprsp += "<a href='/timezone/2'>timezone 2</a><br>";
httprsp += "use /timezone/x for timezone 'x'<br>";
httprsp += "<a href='/brightness/1'>brightness 1</a><br>";
httprsp += "<a href='/brightness/10'>brightness 10</a><br>";
httprsp += "<a href='/brightness/25'>brightness 25</a><br>";
httprsp += "<a href='/brightness/50'>brightness 50</a><br>";
httprsp += "<a href='/brightness/100'>brightness 100</a><br>";
httprsp += "<a href='/brightness/200'>brightness 200</a><br>";
httprsp += "use /brightness/x for display brightness 'x' from 0 (darkest) to 255 (brightest)<br>";
httprsp += "<br><br>";
httprsp += "current configuration<br>";
httprsp += "timezone: " + String (c_vars[EV_TZ]) + "<br>";
httprsp += "<br><a href='/'>home</a><br>";
httprsp += "</html>\r\n";
httpcli.flush (); //clear previous info in the stream
httpcli.print (httprsp); // Send the response to the client
delay (1);
//save settings?
if (svf)
{
if (vars_write () > 0)
Serial.println ("variables stored");
else
Serial.println ("variables storing failed");
}
Serial.println ("Client disonnected");
}
}
void loop()
{
static int i = 0;
static int last = 0;
static int cm;
//handle web server requests
web_server ();
//animations?
cm = millis ();
if ((cm - last) > 150)
{
//Serial.println(millis() - last);
last = cm;
i++;
//
draw_animations (i);
//
}
//time changes every miliseconds, we only want to draw when digits actually change.
hh = NTP.getHour ();
mm = NTP.getMinute ();
ss = NTP.getSecond ();
//
if (ntpsync)
{
ntpsync = 0;
//
prevss = ss;
prevmm = mm;
prevhh = hh;
//we had a sync so draw without morphing
int cc_col = display.color565 (255, 255, 255);
//reset digits color
digit0.SetColor (cc_col);
digit1.SetColor (cc_col);
digit2.SetColor (cc_col);
digit3.SetColor (cc_col);
digit4.SetColor (cc_col);
digit5.SetColor (cc_col);
//clear screen
display.fillScreen (0);
//date and weather
draw_weather ();
draw_date ();
//
digit1.DrawColon (cc_col);
digit3.DrawColon (cc_col);
//military time?
if (hh > 12 && military[0] == 'N')
hh -= 12;
//
digit0.Draw (ss % 10);
digit1.Draw (ss / 10);
digit2.Draw (mm % 10);
digit3.Draw (mm / 10);
digit4.Draw (hh % 10);
digit5.Draw (hh / 10);
}
else
{
//seconds
if (ss != prevss)
{
int s0 = ss % 10;
int s1 = ss / 10;
if (s0 != digit0.Value ()) digit0.Morph (s0);
if (s1 != digit1.Value ()) digit1.Morph (s1);
//ntpClient.PrintTime();
prevss = ss;
//refresh weather every 5mins at 30sec in the minute
if (ss == 30 && ((mm % 5) == 0))
getWeather ();
}
//minutes
if (mm != prevmm)
{
int m0 = mm % 10;
int m1 = mm / 10;
if (m0 != digit2.Value ()) digit2.Morph (m0);
if (m1 != digit3.Value ()) digit3.Morph (m1);
prevmm = mm;
//
//#define SHOW_SOME_LOVE
#ifdef SHOW_SOME_LOVE
if (mm == 0)
draw_love ();
else
#endif
draw_weather ();
}
//hours
if (hh != prevhh)
{
prevhh = hh;
//
draw_date ();
//military time?
if (hh > 12 && military[0] == 'N')
hh -= 12;
//
int h0 = hh % 10;
int h1 = hh / 10;
if (h0 != digit4.Value ()) digit4.Morph (h0);
if (h1 != digit5.Value ()) digit5.Morph (h1);
}//hh changed
}
//set NTP sync interval as needed
if (NTP.getInterval() < 3600 && year(now()) > 1970)
{
//reset the sync interval if we're already in sync
NTP.setInterval (3600 * 24);//re-sync once a day
}
//
delay (0);
}
|
7d4416d2109d999c85133cd054ff9a262ee6012e | 6fd0d9f334681fc0029e80a981cebb773826301f | /MissClock/Generated/GUIFrame.h | 40aaa977257b33e5fcbb43c453ce0fd3c993f852 | [] | no_license | leoxiaofei/missclock | 64ca6889e7c36ebb4caaabe6b1cdda8027255c2e | de10f1e447c67bdb83bbd3586c50c09d93166293 | refs/heads/master | 2021-01-19T09:49:54.239594 | 2012-01-17T12:32:20 | 2012-01-17T12:32:20 | 32,333,431 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 16,156 | h | GUIFrame.h | ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Sep 8 2010)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __GUIFrame__
#define __GUIFrame__
class MissToolBook;
#include <wx/string.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/menu.h>
#include <wx/frame.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/stattext.h>
#include <wx/choice.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/checkbox.h>
#include <wx/slider.h>
#include <wx/panel.h>
#include <wx/combobox.h>
#include <wx/listctrl.h>
#include <wx/notebook.h>
#include <wx/listbook.h>
#include <wx/dialog.h>
#include <wx/datectrl.h>
#include <wx/dateevt.h>
#include <wx/spinctrl.h>
#include <wx/hyperlink.h>
#include <wx/choicebk.h>
#include <wx/radiobut.h>
#include <wx/textctrl.h>
#include <wx/filepicker.h>
#include <wx/imaglist.h>
#include <wx/statbmp.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class GUIFrame
///////////////////////////////////////////////////////////////////////////////
class GUIFrame : public wxFrame
{
private:
protected:
wxMenu* m_pMainMenu;
wxMenuItem* m_pmimPin;
wxMenuItem* m_pmimShadow;
wxMenuItem* m_pmimTop;
wxMenuItem* m_pmimShow;
// Virtual event handlers, overide them in your derived class
virtual void OnClose( wxCloseEvent& event ) { event.Skip(); }
virtual void OnLeftDown( wxMouseEvent& event ) { event.Skip(); }
virtual void OnRightUp( wxMouseEvent& event ) { event.Skip(); }
virtual void OnmimPinSelected( wxCommandEvent& event ) { event.Skip(); }
virtual void OnmimShadowSelected( wxCommandEvent& event ) { event.Skip(); }
virtual void OnmimTopSelected( wxCommandEvent& event ) { event.Skip(); }
virtual void OnmimShowSelected( wxCommandEvent& event ) { event.Skip(); }
virtual void OnmimOptionSelected( wxCommandEvent& event ) { event.Skip(); }
virtual void OnmimRemindSelected( wxCommandEvent& event ) { event.Skip(); }
virtual void OnmimCopyDateSelected( wxCommandEvent& event ) { event.Skip(); }
virtual void OnmimCopyTimeSelected( wxCommandEvent& event ) { event.Skip(); }
virtual void OnmimSetTimeSelected( wxCommandEvent& event ) { event.Skip(); }
virtual void OnAbout( wxCommandEvent& event ) { event.Skip(); }
virtual void OnExit( wxCommandEvent& event ) { event.Skip(); }
public:
GUIFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("MissClock"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 481,466 ), long style = wxFRAME_TOOL_WINDOW|wxTAB_TRAVERSAL );
~GUIFrame();
};
///////////////////////////////////////////////////////////////////////////////
/// Class MissOptionBase
///////////////////////////////////////////////////////////////////////////////
class MissOptionBase : public wxDialog
{
private:
protected:
wxListbook* m_lsbOption;
wxPanel* m_panUI;
wxStaticBoxSizer* sbSizerTheme;
wxStaticText* m_lblChoiceTheme;
wxChoice* m_choTheme;
wxButton* m_btnModifyTheme;
wxCheckBox* m_cbtnAllowZoom;
wxStaticText* m_lblZoomOut;
wxSlider* m_sldZoom;
wxStaticText* m_lblZoomIn;
wxStaticText* m_lblTransparency;
wxSlider* m_sldOpacity;
wxStaticText* m_lblOpacity;
wxPanel* m_panSys;
wxBoxSizer* m_srNTP;
wxCheckBox* m_cbtnAutoRun;
wxCheckBox* m_cbtnAudioChimer;
wxCheckBox* m_cbtnPin;
wxCheckBox* m_cbtnShadow;
wxCheckBox* m_cbtnTop;
wxCheckBox* m_cbtnShowClock;
wxButton* m_btnWeekSet;
wxButton* m_btnDateFormatSet;
wxButton* m_btnTimeFormatSet;
wxStaticText* m_lblNTP;
wxComboBox* m_cobNTP;
wxButton* m_btnNTP;
wxStaticText* m_lblNTPMessage;
wxPanel* m_panTmr;
wxButton* m_btnAddTask;
wxButton* m_btnAdditional;
wxMenu* m_mnuAdditional;
wxButton* m_btnModifyTask;
wxButton* m_btnDeleteTask;
wxNotebook* m_nbTimerSetting;
wxPanel* m_panRemind;
wxListCtrl* m_listRemind;
wxPanel* m_panMemorialDay;
wxListCtrl* m_listMemorialDay;
wxPanel* m_panBacklog;
wxListCtrl* m_listBacklog;
wxPanel* m_panTask;
wxListCtrl* m_listTask;
wxPanel* m_panOverdue;
wxListCtrl* m_listOverdue;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnInitDialog( wxInitDialogEvent& event ) { event.Skip(); }
virtual void OnLsbOptionPageChanged( wxListbookEvent& event ) { event.Skip(); }
virtual void OnThemeChoChange( wxCommandEvent& event ) { event.Skip(); }
virtual void OnModifyThemeBtnClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnZoomCbtnClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnZoomSldChanged( wxScrollEvent& event ) { event.Skip(); }
virtual void OnTransSldChanged( wxScrollEvent& event ) { event.Skip(); }
virtual void OnBtnWeekSetClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnBtnDateFormatSetClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnBtnTimeFormatSetClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnBtnNtpClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnBtnAddTaskClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnBtnAdditionaClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnMenuRemindSelection( wxCommandEvent& event ) { event.Skip(); }
virtual void OnMenuBirthdaySelection( wxCommandEvent& event ) { event.Skip(); }
virtual void OnMenuTodoSelection( wxCommandEvent& event ) { event.Skip(); }
virtual void OnBtnModifyTaskClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnBtnDeleteTaskClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnNBTimerSettingChanged( wxNotebookEvent& event ) { event.Skip(); }
virtual void OnListKeyDown( wxKeyEvent& event ) { event.Skip(); }
virtual void OnListRemindItemActivated( wxListEvent& event ) { event.Skip(); }
virtual void OnOK( wxCommandEvent& event ) { event.Skip(); }
public:
MissOptionBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("选项"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 435,419 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~MissOptionBase();
};
///////////////////////////////////////////////////////////////////////////////
/// Class MissSetTimerBase
///////////////////////////////////////////////////////////////////////////////
class MissSetTimerBase : public wxDialog
{
private:
protected:
wxChoicebook* m_cbookDate;
wxPanel* m_panAppoint;
wxStaticText* m_lblAppoint;
wxDatePickerCtrl* m_dpAppoint;
wxPanel* m_panEDay;
wxStaticText* m_lblStartDate;
wxDatePickerCtrl* m_dpEDay;
wxStaticText* m_lblE;
wxSpinCtrl* m_spEDay;
wxStaticText* m_lblEDay;
wxPanel* m_panWeek;
wxStaticText* m_lblEWeek;
wxCheckBox* m_cbtnMon;
wxCheckBox* m_cbtnTues;
wxCheckBox* m_cbtnWed;
wxCheckBox* m_cbtnThurs;
wxCheckBox* m_cbtnFri;
wxCheckBox* m_cbtnSar;
wxCheckBox* m_cbtnSun;
wxHyperlinkCtrl* m_hlWorkDay;
wxPanel* m_panMonth;
wxStaticText* m_lblEMonth;
wxSpinCtrl* m_spMonth;
wxStaticText* m_lblMonth;
wxPanel* m_panYear;
wxStaticText* m_lblYear;
wxSpinCtrl* m_spYMonth;
wxStaticText* m_lblYMonth;
wxSpinCtrl* m_spYDay;
wxStaticText* m_lblYDay;
wxRadioButton* m_rbtnAppoint;
wxSpinCtrl* m_spHour;
wxStaticText* m_lblHour;
wxSpinCtrl* m_spMin;
wxStaticText* m_lblMin;
wxCheckBox* m_cbtnRemindType;
wxRadioButton* m_rbtnPStart;
wxRadioButton* m_rbtnPClose;
wxRadioButton* m_rbtnNothing;
MissToolBook* m_tbRun;
wxPanel* m_panTextRemind;
wxTextCtrl* m_edtContent;
wxPanel* m_panProgRemind;
wxStaticText* m_lblProgram;
wxStaticText* m_lblParameter;
wxStdDialogButtonSizer* m_sdbSizer3;
wxButton* m_sdbSizer3OK;
wxButton* m_sdbSizer3Cancel;
// Virtual event handlers, overide them in your derived class
virtual void OnInitDialog( wxInitDialogEvent& event ) { event.Skip(); }
virtual void OnHLWorkDayClick( wxHyperlinkEvent& event ) { event.Skip(); }
virtual void OnRbtnNothingClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOKButtonClick( wxCommandEvent& event ) { event.Skip(); }
public:
wxFilePickerCtrl* m_fpProgram;
wxTextCtrl* m_edtParameter;
MissSetTimerBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("定时"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 407,446 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~MissSetTimerBase();
};
///////////////////////////////////////////////////////////////////////////////
/// Class MissThemeBase
///////////////////////////////////////////////////////////////////////////////
class MissThemeBase : public wxDialog
{
private:
protected:
wxNotebook* m_nbTheme;
wxPanel* m_panSkin;
wxStaticText* m_lblBGPath;
wxTextCtrl* m_edtBGPath;
wxButton* m_btnBGPath;
wxStaticText* m_lblLocale;
wxComboBox* m_cobLocale;
wxListCtrl* m_lstItem;
wxButton* m_btnAddItem;
wxButton* m_btnDeleteItem;
wxStaticText* m_lblName;
wxTextCtrl* m_edtName;
wxStaticText* m_lblShow;
wxCheckBox* m_cbtnShow;
wxStaticText* m_lblContent;
wxTextCtrl* m_edtContent;
wxButton* m_btnFont;
wxButton* m_btnColor;
wxStaticText* m_lblAlign;
wxTextCtrl* m_edtAlign;
wxSlider* m_sldAlign;
wxStaticText* m_lblPos;
wxStaticText* m_lblX;
wxSpinCtrl* m_spX;
wxStaticText* m_lblY;
wxSpinCtrl* m_spY;
wxPanel* m_panRemind;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnInitDialog( wxInitDialogEvent& event ) { event.Skip(); }
virtual void OnBtnBGPathClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCobLocaleSelect( wxCommandEvent& event ) { event.Skip(); }
virtual void OnlstItemDeselect( wxListEvent& event ) { event.Skip(); }
virtual void OnlstItemSelect( wxListEvent& event ) { event.Skip(); }
virtual void OnBtnAddItem( wxCommandEvent& event ) { event.Skip(); }
virtual void OnBtnDeleteItem( wxCommandEvent& event ) { event.Skip(); }
virtual void OnEdtNameKillFocus( wxFocusEvent& event ) { event.Skip(); }
virtual void OnCbtnShowClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnEdtContentKillFocus( wxFocusEvent& event ) { event.Skip(); }
virtual void OnBtnFont( wxCommandEvent& event ) { event.Skip(); }
virtual void OnBtnColor( wxCommandEvent& event ) { event.Skip(); }
virtual void OnSldAlignScrollThumbRelease( wxScrollEvent& event ) { event.Skip(); }
virtual void OnSpXChange( wxSpinEvent& event ) { event.Skip(); }
virtual void OnSpYChange( wxSpinEvent& event ) { event.Skip(); }
public:
MissThemeBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("修改主题"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 435,416 ), long style = wxDEFAULT_DIALOG_STYLE );
~MissThemeBase();
};
///////////////////////////////////////////////////////////////////////////////
/// Class MissFrameBase
///////////////////////////////////////////////////////////////////////////////
class MissFrameBase : public wxFrame
{
private:
protected:
wxPanel* m_pTitle;
// Virtual event handlers, overide them in your derived class
virtual void OnEraseBackground( wxEraseEvent& event ) { event.Skip(); }
virtual void OnPTitleLeftDown( wxMouseEvent& event ) { event.Skip(); }
virtual void OnPTitleOnPaint( wxPaintEvent& event ) { event.Skip(); }
public:
MissFrameBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 253,176 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL|wxTRANSPARENT_WINDOW );
~MissFrameBase();
};
///////////////////////////////////////////////////////////////////////////////
/// Class MissSetWeekDayBase
///////////////////////////////////////////////////////////////////////////////
class MissSetWeekDayBase : public wxFrame
{
private:
protected:
wxCheckBox* m_cbtnMon;
wxCheckBox* m_cbtnTues;
wxCheckBox* m_cbtnWed;
wxCheckBox* m_cbtnThurs;
wxCheckBox* m_cbtnFri;
wxCheckBox* m_cbtnSar;
wxCheckBox* m_cbtnSun;
// Virtual event handlers, overide them in your derived class
virtual void OnActivate( wxActivateEvent& event ) { event.Skip(); }
public:
MissSetWeekDayBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 250,60 ), long style = wxFRAME_FLOAT_ON_PARENT|wxFRAME_NO_TASKBAR|wxRESIZE_BORDER|wxSTAY_ON_TOP );
~MissSetWeekDayBase();
};
///////////////////////////////////////////////////////////////////////////////
/// Class MissSetDTFormatBase
///////////////////////////////////////////////////////////////////////////////
class MissSetDTFormatBase : public wxFrame
{
private:
protected:
wxChoice* m_cobDateTime;
wxTextCtrl* m_edtDateTime;
wxTextCtrl* m_edtExample;
// Virtual event handlers, overide them in your derived class
virtual void OnActivate( wxActivateEvent& event ) { event.Skip(); }
virtual void OnCobDateTime( wxCommandEvent& event ) { event.Skip(); }
virtual void OnDateTimeText( wxCommandEvent& event ) { event.Skip(); }
public:
MissSetDTFormatBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 305,95 ), long style = wxFRAME_FLOAT_ON_PARENT|wxFRAME_NO_TASKBAR|wxRESIZE_BORDER|wxSTAY_ON_TOP|wxTAB_TRAVERSAL );
~MissSetDTFormatBase();
};
///////////////////////////////////////////////////////////////////////////////
/// Class MissRemindBase
///////////////////////////////////////////////////////////////////////////////
class MissRemindBase : public wxFrame
{
private:
protected:
// Virtual event handlers, overide them in your derived class
virtual void OnClose( wxCloseEvent& event ) { event.Skip(); }
virtual void OnLeftDown( wxMouseEvent& event ) { event.Skip(); }
public:
MissRemindBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 400,300 ), long style = 0|wxTAB_TRAVERSAL );
~MissRemindBase();
};
///////////////////////////////////////////////////////////////////////////////
/// Class MissAboutBase
///////////////////////////////////////////////////////////////////////////////
class MissAboutBase : public wxDialog
{
private:
protected:
wxStaticBitmap* m_bitmapSoftIcon;
wxStaticText* m_lblSoftName;
wxStaticText* m_lblCopyright;
wxStaticText* m_lblWeb;
wxStaticText* m_lblEmail;
wxButton* m_btnUpdate;
wxStdDialogButtonSizer* m_sdbSizer4;
wxButton* m_sdbSizer4OK;
// Virtual event handlers, overide them in your derived class
virtual void OnBtnUpdateClick( wxCommandEvent& event ) { event.Skip(); }
public:
MissAboutBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("关于..."), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 267,162 ), long style = wxDEFAULT_DIALOG_STYLE );
~MissAboutBase();
};
#endif //__GUIFrame__
|
4832cb6642c232ce0ba9fc5783c5cefa20fd50c0 | 3b5b5bfd0353f0fe8bc0b5fecc44bc63d929acec | /src/chase/src/Specification/Requirement.cc | e849f2702cedc5b9060bd0e4d5140614c3f0dbb9 | [
"BSD-3-Clause"
] | permissive | pierg/chase | b79136f2f218d2d38fa912f814dd99f3f092aa01 | 80b6aae0972c79dfd4e5afe51f28395b23ca4aac | refs/heads/master | 2020-05-24T03:53:22.441125 | 2018-03-20T20:55:16 | 2018-03-20T20:55:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,218 | cc | Requirement.cc | /**
* @author <a href="mailto:michele.lora@univr.it">Michele Lora</a>
* @date 2015-2016
* @copyright Copyright (c) 2015-2017 by University of California, Berkeley.\n
* Copyright (c) 2015-2017 by University of Verona.\n
* Copyright (c) 2015-2017 by International Business Machines Corporation.\n
* Copyright (c) 2016-2017 by University of Southern California.\n
* All rights reserved.\n
* This project is released under the 3-Clause BSD License.
*
* @file chase/src/Specification/Requirement.cc
* @brief
*/
#include "Specification/Requirement.hh"
using namespace Specification;
Requirement::Requirement() :
_functionName(""),
_ariety(0),
_params()
{
}
Requirement::Requirement( std::string functionName, unsigned int ariety ) :
_functionName(functionName),
_ariety(ariety),
_params()
{
}
Requirement::Requirement(
std::string functionName, std::vector< std::string > params ) :
_functionName(functionName),
_ariety(params.size()),
_params(params)
{
}
Requirement::Requirement(
std::string functionName,
unsigned int ariety,
std::vector< std::string > params ) :
_functionName(functionName),
_ariety(ariety),
_params(params)
{
}
Requirement::~Requirement()
{
}
std::string Requirement::getFunctionName()
{
return _functionName;
}
std::string Requirement::getParameter(unsigned int position)
{
return _params[position];
}
///\todo Fix the managing of the ariety to be more strong.
unsigned int Requirement::getAriety()
{
_ariety = _params.size();
return _ariety;
}
void Requirement::setFunctionName( std::string functionName )
{
_functionName = functionName;
}
void Requirement::setAriety( unsigned int ariety )
{
/// Warning: Ariety can be set just once!
if( _ariety == 0 )
{
_ariety = ariety;
_params.resize(_ariety);
}
}
void Requirement::setParameter(unsigned int position, std::string parameter )
{
/// Warning: the element can be stored if and only if the position is
/// within the ariety constraint.
if(position < _ariety)
_params[position] = parameter;
}
|
adfff6d253a6fe88c486180fd6eb5752398fbe08 | 62c45c77da533177b2cf234733cf34f18dfaf94a | /base/bind.h | 94da5ac56a488f0fbd5b880f54705957591ac03b | [
"Apache-2.0"
] | permissive | eval1749/elang | ff76d95c0000ed1d61434b387d319f950f68509a | 5208b386ba3a3e866a5c0f0271280f79f9aac8c4 | refs/heads/master | 2020-04-29T17:44:53.579355 | 2015-12-11T18:51:34 | 2015-12-11T18:51:34 | 28,262,329 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,018 | h | bind.h | // Copyright (c) 2011 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 BASE_BIND_H_
#define BASE_BIND_H_
#include "base/bind_internal.h"
#include "base/callback_internal.h"
// -----------------------------------------------------------------------------
// Usage documentation
// -----------------------------------------------------------------------------
//
// See base/callback.h for documentation.
//
//
// -----------------------------------------------------------------------------
// Implementation notes
// -----------------------------------------------------------------------------
//
// If you're reading the implementation, before proceeding further, you should
// read the top comment of base/bind_internal.h for a definition of common
// terms and concepts.
//
// RETURN TYPES
//
// Though Bind()'s result is meant to be stored in a Callback<> type, it
// cannot actually return the exact type without requiring a large amount
// of extra template specializations. The problem is that in order to
// discern the correct specialization of Callback<>, Bind would need to
// unwrap the function signature to determine the signature's arity, and
// whether or not it is a method.
//
// Each unique combination of (arity, function_type, num_prebound) where
// function_type is one of {function, method, const_method} would require
// one specialization. We eventually have to do a similar number of
// specializations anyways in the implementation (see the Invoker<>,
// classes). However, it is avoidable in Bind if we return the result
// via an indirection like we do below.
//
// TODO(ajwong): We might be able to avoid this now, but need to test.
//
// It is possible to move most of the static_assert into BindState<>, but it
// feels a little nicer to have the asserts here so people do not need to crack
// open bind_internal.h. On the other hand, it makes Bind() harder to read.
namespace base {
template <typename Functor>
base::Callback<
typename internal::BindState<
typename internal::FunctorTraits<Functor>::RunnableType,
typename internal::FunctorTraits<Functor>::RunType,
internal::TypeList<>>::UnboundRunType>
Bind(Functor functor) {
// Typedefs for how to store and run the functor.
typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType;
typedef typename internal::FunctorTraits<Functor>::RunType RunType;
typedef internal::BindState<RunnableType, RunType,
internal::TypeList<>> BindState;
return Callback<typename BindState::UnboundRunType>(
new BindState(internal::MakeRunnable(functor)));
}
template <typename Functor, typename... Args>
base::Callback<
typename internal::BindState<
typename internal::FunctorTraits<Functor>::RunnableType,
typename internal::FunctorTraits<Functor>::RunType,
internal::TypeList<
typename internal::CallbackParamTraits<Args>::StorageType...>>
::UnboundRunType>
Bind(Functor functor, const Args&... args) {
// Typedefs for how to store and run the functor.
typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType;
typedef typename internal::FunctorTraits<Functor>::RunType RunType;
// Use RunnableType::RunType instead of RunType above because our
// checks should below for bound references need to know what the actual
// functor is going to interpret the argument as.
typedef typename RunnableType::RunType BoundRunType;
// Do not allow binding a non-const reference parameter. Non-const reference
// parameters are disallowed by the Google style guide. Also, binding a
// non-const reference parameter can make for subtle bugs because the
// invoked function will receive a reference to the stored copy of the
// argument and not the original.
static_assert(!internal::HasNonConstReferenceParam<BoundRunType>::value,
"do not bind functions with nonconst ref");
const bool is_method = internal::HasIsMethodTag<RunnableType>::value;
// For methods, we need to be careful for parameter 1. We do not require
// a scoped_refptr because BindState<> itself takes care of AddRef() for
// methods. We also disallow binding of an array as the method's target
// object.
static_assert(!internal::BindsArrayToFirstArg<is_method, Args...>::value,
"first bound argument to method cannot be array");
static_assert(
!internal::HasRefCountedParamAsRawPtr<is_method, Args...>::value,
"a parameter is a refcounted type and needs scoped_refptr");
typedef internal::BindState<
RunnableType, RunType,
internal::TypeList<
typename internal::CallbackParamTraits<Args>::StorageType...>>
BindState;
return Callback<typename BindState::UnboundRunType>(
new BindState(internal::MakeRunnable(functor), args...));
}
} // namespace base
#endif // BASE_BIND_H_
|
a64dc927c53f9875055fca32182fee5571ca67c5 | f9619bbf3d2b66bba3a84bbb0537154b50ca1c75 | /Projects/TracadorPassivo/pztracerflow.h | 23efc8f1100f8f9d9acafe02f809e05ea349cbdd | [] | no_license | mfkiwl/neopz | 6b6ce984ab7ac2a6cbe7197313ec9ec97f16cafd | 30686f7bbfeb402d40bc204012ea0077cae31d58 | refs/heads/master | 2023-03-21T00:50:52.324139 | 2021-01-29T17:38:53 | 2021-01-29T17:38:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,939 | h | pztracerflow.h | //
// pztracerflow.h
// PZ
//
// Created by Agnaldo Farias on 16/10/13.
//
//
#ifndef __PZ__pztracerflow__
#define __PZ__pztracerflow__
#include <iostream>
#include "pzdiscgal.h"
/**
* @ingroup material
* @author Agnaldo Farias
* @since 16/10/13
* @brief Contains the TPZTracerFlow class which implements a Tracer Flow Problem 2D with explicit scheme in time.
*@brief q: flow, p: pressure and s: saturation
*/
/*
* \f$ poros*ds/dt + div(q*s) = 0 (Eq. 1, transport problem) \f$
* \f$ q + (k/visc)*grad(p) = 0 (Eq. 2, elliptic system) \f$
* \f$ div(q) = 0 (Eq. 3, elliptic system) \f$
*
*/
class TPZTracerFlow : public TPZDiscontinuousGalerkin {
protected:
/** @brief Forcing function value, like source term, to flux-pressure equation */
REAL fxfPQ;
/** @brief Forcing function value, like source term, to saturation equation */
REAL fxfS;
/** @brief Permeability of the porous medium. Coeficient which multiplies the gradient operator*/
REAL fk;
/** @brief Porosity of the porous medium. Coeficient which multiplies the temporal derivative.*/
REAL fPoros;
/** @brief fluid viscosity*/
REAL fVisc;
/** @brief convection term (direction velocity) */
TPZManVector<REAL> fConvDir;
/** @brief Problem dimension */
int fDim;
//time step
REAL fTimeStep;
//time of simulation
REAL fTimeValue;
int fmatId;
bool fPressureEquationFilter;
//Second order Runge-Kutta
bool fRungeKuttaTwo;
/** @brief State: n ou n+1 */
enum EState {ELastState = 0, ECurrentState = 1};
EState gState;
public:
TPZTracerFlow();
TPZTracerFlow(int matid, int dim);
virtual ~TPZTracerFlow();
/** @brief copy constructor */
TPZTracerFlow(const TPZTracerFlow ©);
TPZTracerFlow &operator=(const TPZTracerFlow ©);
virtual void Print(std::ostream & out);
virtual std::string Name() { return "TPZTracerFlow"; }
int Dimension() const {return fDim;}
int MatId()
{
return fmatId;
}
virtual int NStateVariables() const {return 1;}
void SetForcesPressure(REAL fxfPQ);
void SetForcesSaturation(REAL fxfS);
void SetPermeability(REAL perm);
void SetViscosity(REAL visc);
void SetPorosity(REAL poros);
void GetPermeability(REAL &perm);
void SetConvectionDirection(TPZVec<REAL> convdir);
void GetConvectionDirection(TPZVec<REAL> &convdir);
void SetLastState(){
gState = ELastState;
}
void SetCurrentState(){
gState = ECurrentState;
}
void SetPressureEqFilter(){
fPressureEquationFilter = true;
}
void SetFalsePressureEqFilter(){
fPressureEquationFilter = false;
}
void SetTimeStep(REAL delt){
fTimeStep = delt;
}
void SetTimeValue(REAL TimeValue){
fTimeValue = TimeValue;
}
void GetTimeValue(REAL &TimeValue){
TimeValue = fTimeValue;
}
void SetTrueRungeKuttaTwo(){
fRungeKuttaTwo = true;
}
/** @name Contribute methods
* @{
*/
/**
* @brief It computes a contribution to the stiffness matrix and load vector at one integration point.
* @param datavec [in] stores all input data
* @param weight [in] is the weight of the integration rule
* @param ek [out] is the stiffness matrix
* @param ef [out] is the load vector
* @since March 2, 2013
*/
virtual void Contribute(TPZVec<TPZMaterialData> &datavec, REAL weight, TPZFMatrix<STATE> &ek, TPZFMatrix<STATE> &ef);
/**
* @brief It computes a contribution to the stiffness matrix and load vector at one integration point.
* @param data [in] stores all input data
* @param weight [in] is the weight of the integration rule
* @param ek [out] is the stiffness matrix
* @param ef [out] is the load vector
* @since April 16, 2007
*/
virtual void Contribute(TPZMaterialData &data, REAL weight, TPZFMatrix<STATE> &ek, TPZFMatrix<STATE> &ef) {
DebugStop();
}
/**
* @brief It computes a contribution to the stiffness matrix and load vector at one BC integration point.
* @param datavec [in] stores all input data
* @param weight [in] is the weight of the integration rule
* @param ek [out] is the stiffness matrix
* @param ef [out] is the load vector
* @param bc [in] is the boundary condition material
* @since March 04, 2013
*/
virtual void ContributeBC(TPZVec<TPZMaterialData> &datavec, REAL weight, TPZFMatrix<STATE> &ek, TPZFMatrix<STATE> &ef, TPZBndCond &bc);
/**
* @brief It computes a contribution to the stiffness matrix and load vector at one BC integration point.
* @param data [in] stores all input data
* @param weight [in] is the weight of the integration rule
* @param ek [out] is the stiffness matrix
* @param ef [out] is the load vector
* @param bc [in] is the boundary condition material
* @since October 07, 2011
*/
virtual void ContributeBC(TPZMaterialData &data, REAL weight, TPZFMatrix<STATE> &ek, TPZFMatrix<STATE> &ef, TPZBndCond &bc){
DebugStop();
}
/**
* @brief It computes a contribution to stiffness matrix and load vector at one BC integration point
* @param datavec [in]
* @param dataleft [in]
* @param weight [in]
* @param ek [out] is the stiffness matrix
* @param ef [out] is the load vector
* @param bc [in] is the boundary condition object
* @since March 04, 2013
*/
virtual void ContributeBCInterface(TPZMaterialData &data, TPZVec<TPZMaterialData> &dataleft, REAL weight, TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef,TPZBndCond &bc);
/**
* @brief It computes a contribution to stiffness matrix and load vector at one BC integration point
* @param data [in]
* @param dataleft [in]
* @param weight [in]
* @param ek [out] is the stiffness matrix
* @param ef [out] is the load vector
* @param bc [in] is the boundary condition object
* @since April 16, 2007
*/
virtual void ContributeBCInterface(TPZMaterialData &data, TPZMaterialData &dataleft, REAL weight, TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef,TPZBndCond &bc);
/**
* @brief It computes a contribution to stiffness matrix and load vector at one BC integration point
* @param datavec [in]
* @param dataleft [in]
* @param dataright [in]
* @param weight [in]
* @param ek [out] is the stiffness matrix
* @param ef [out] is the load vector
* @since March 04, 2013
*/
virtual void ContributeInterface(TPZMaterialData &data, TPZVec<TPZMaterialData> &dataleft, TPZVec<TPZMaterialData> &dataright, REAL weight, TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef);
/**
* @brief It computes a contribution to stiffness matrix and load vector at one integration point
* @param data [in]
* @param dataleft [in]
* @param dataright [in]
* @param weight [in]
* @param ek [out] is the stiffness matrix
* @param ef [out] is the load vector
* @since April 16, 2007
*/
virtual void ContributeInterface(TPZMaterialData &data, TPZMaterialData &dataleft, TPZMaterialData &dataright, REAL weight, TPZFMatrix<STATE> &ek, TPZFMatrix<STATE> &ef);
virtual int VariableIndex(const std::string &name);
virtual int NSolutionVariables(int var);
/**
* @brief It return a solution to multiphysics simulation.
* @param datavec [in] Data material vector
* @param var [in] number of solution variables. See NSolutionVariables() method
* @param Solout [out] is the solution vector
*/
virtual void Solution(TPZVec<TPZMaterialData> &datavec, int var, TPZVec<STATE> &Solout);
virtual void FillDataRequirements(TPZVec<TPZMaterialData > &datavec);
virtual void FillBoundaryConditionDataRequirement(int type,TPZVec<TPZMaterialData > &datavec);
};
#endif /* defined(__PZ__pztracerflow__) */
|
2a7dca678a2adfb9261db99e22010d76e83ac90f | e88c8793f712a248804b649a1918c66bcc4628fa | /Megaman/MegamanJumpState.h | da2f4540f5e8a25fbe627c85447ee199a698156c | [] | no_license | CyTruong/Captain-America-and-the-Avengers | b2cff669a236d7e604d4473d0c9d8f672587f270 | cdcbab988114c1028f217f2620bbfd46c7d4080e | refs/heads/master | 2020-06-24T21:26:05.603984 | 2019-08-07T12:36:35 | 2019-08-07T12:36:35 | 199,090,683 | 0 | 0 | null | 2019-08-04T07:29:17 | 2019-07-26T23:15:53 | C++ | UTF-8 | C++ | false | false | 1,006 | h | MegamanJumpState.h | #pragma once
#include "MegamanState.h"
#include "MegamanDamagedState.h"
class MegamanJumpState : public MegamanState
{
private:
bool isMoving;
bool isJumpingPress;
float speedX;
// hcmt
bool isCimping;
//float acceleration;
public:
//MegamanJumpState(MegamanData * data, bool isMoving = false , float vy =-5.0f);
// hcmt
MegamanJumpState(MegamanData *data, bool isMoving = false, float vy = -8.0f, bool isCimping = false);
~MegamanJumpState();
void onMovePressed(Direction dir);
void onMoveReleased(Direction dir);
// hcmt climping
void onJumpPressed();
void onJumpRelease();
void onSlidePressed();
void onCollision(RectF rect);
void onCollision(CollisionRectF rect);
void onDynamicObjectCollision(CollisionRectF* cRect);
void onUpdate();
void onFirePressed();
void onFireRelease();
void onVeticalDirectionPressed(Direction d);
void onVeticalDirectionReleased();
virtual void onDead();
void damaged() override {
transition(new MegamanDamagedState(this->pData));
}
};
|
4a9d1ca882a4a7b8900cb371474e110fc98df45f | 520728d62e12621a2bbe5ce7ae6b103f1827ebc2 | /BaiTapCode/BaiTapKhac/Hacker Rank/Algorithms/Warm up/Chocolate Feast/Chocolate Feast/main.cpp | eca0151ac2940df386cc6c0e52175fa927c15653 | [
"MIT"
] | permissive | hohaithuy/Training | 56bdfd49eae995bddea81af415953e4fdeb20f63 | 9c9b1ef4be455c5635edd2a4ca608732f3f65e52 | refs/heads/master | 2022-12-06T14:53:42.062512 | 2020-08-26T01:48:45 | 2020-08-26T01:48:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 426 | cpp | main.cpp | #include<iostream>
using namespace std;
int main()
{
int n;
int wallet,price,count,wrapper;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>wallet>>price>>wrapper;
count=wallet/price;
int wrap=count;
while(wrap>=wrapper)
{
count+=wrap/wrapper;
wrap=wrap/wrapper+wrap%wrapper;
cout<<wrap<<endl;
}
cout<<count<<endl;
}
}
|
6a62888625231c5fb34d814c345ff66d05ae1176 | df56c3d9f44132d636c0cef1b70e40034ff09022 | /networkcontrol/qosfwconfig/QoSTesting/umtssim/src/uscl_control.cpp | 765101a8685a62cf4826144b546ac03010d757e9 | [] | no_license | SymbianSource/oss.FCL.sf.os.networkingsrv | e6317d7ee0ebae163572127269c6cf40b98e3e1c | b283ce17f27f4a95f37cdb38c6ce79d38ae6ebf9 | refs/heads/master | 2021-01-12T11:29:50.765762 | 2010-10-14T06:50:50 | 2010-10-14T06:50:50 | 72,938,071 | 4 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,884 | cpp | uscl_control.cpp | // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Nokia Corporation - initial contribution.
//
// Contributors:
//
// Description:
//
#include "us_cliserv.h"
#include "uscl_packet.h"
#include "uscl_control.h"
//********************************
//RControl
//********************************
// construct/destruct
EXPORT_C RControl::RControl()
{
// nothing here -- constructing done in Open
}
EXPORT_C RControl::~RControl()
{
// nothing here
}
// create new subsession with the simulator server
EXPORT_C TInt RControl::Open(RUmtsSimServ &aServer )
{
// TAny* p[KMaxMessageArguments];
// TInt err = CreateSubSession(aServer,EUmtsSimServCreateControlSubSession,&p[0]);
// Changed because of migration to Client/Server V2 API
TIpcArgs args(TIpcArgs::ENothing); // No arguments
TInt err = CreateSubSession(aServer, EUmtsSimServCreateControlSubSession, args);
if(err != KErrNone) return err;
return KErrNone;
}
// close a subsession
EXPORT_C void RControl::Close()
{
RSubSessionBase::CloseSubSession(EUmtsSimServCloseControlSubSession);
}
EXPORT_C void RControl::NotifyAll(TRequestStatus& aStatus, TDes& aMsg) const
{
// TAny* p[KMaxMessageArguments];
// p[0] = &aMsg;
// SendReceive(EUmtsSimServControlNotifyAllA, &p[0], aStatus);
// Changed because of migration to Client/Server V2 API
TIpcArgs args( &aMsg );
SendReceive(EUmtsSimServControlNotifyAllA, args, aStatus);
}
EXPORT_C TInt RControl::ReconfigureSimulator(TInt aFlag) const
{
// TAny* p[KMaxMessageArguments];
// p[0] = NULL;
// p[1] = (TAny*) aFlag;
// return SendReceive(EUmtsSimServControlReconfigureSimulatorS, &p[0]);
// Changed because of migration to Client/Server V2 API
TIpcArgs args( NULL, aFlag );
return SendReceive(EUmtsSimServControlReconfigureSimulatorS, args);
}
EXPORT_C TInt RControl::ReconfigureSimulator(const TDesC& aFilename, TInt aFlag) const
{
// TAny* p[KMaxMessageArguments];
// p[0] = (TAny*) &aFilename;
// p[1] = (TAny*) aFlag;
// return SendReceive(EUmtsSimServControlReconfigureSimulatorS, &p[0]);
// Changed because of migration to Client/Server V2 API
TIpcArgs args( &aFilename, aFlag );
return SendReceive(EUmtsSimServControlReconfigureSimulatorS, args);
}
EXPORT_C TInt RControl::ConfigureRequestHandler(const TDesC& aCfgString) const
{
// TAny* p[KMaxMessageArguments];
// p[0] = (TAny*) &aCfgString;
// return SendReceive(EUmtsSimServControlConfigureRequestHandlerS, &p[0]);
// Changed because of migration to Client/Server V2 API
TIpcArgs args( &aCfgString );
return SendReceive(EUmtsSimServControlConfigureRequestHandlerS, args);
}
EXPORT_C TInt RControl::ConfigureEvent(const TDesC& aCfgString) const
{
// TAny* p[KMaxMessageArguments];
// p[0] = (TAny*) &aCfgString;
// return SendReceive(EUmtsSimServControlConfigureEventS, &p[0]);
// Changed because of migration to Client/Server V2 API
TIpcArgs args( &aCfgString );
return SendReceive(EUmtsSimServControlConfigureEventS, args);
}
EXPORT_C void RControl::CancelAsyncRequest(TInt aReqToCancel) const
{
if((aReqToCancel & KUmtsSimServRqstMask) != KUmtsSimServRqstControl
|| (aReqToCancel & KUmtsSimServRqstCancelBit) == 0)
{
User::Invariant(); // should panic thread here with reasonable reason
return;
}
// SendReceive(aReqToCancel, NULL);
// Changed because of migration to Client/Server V2 API
TIpcArgs args(TIpcArgs::ENothing); // No arguments
SendReceive(aReqToCancel, args);
}
|
767bdf26cb8716860757ea690552ff88a01be58a | de61469abf7211de3ea5ef0193e482421a6b207f | /areal.cpp | cd31712a3008b987e2d089fa880d220241371dc1 | [] | no_license | Kingston802/kattis-solutions | 825022d26df7af155b50ddc69394d87d58c36a1e | c1147cd9bf3b8010a8b2437a365f120f4fd63e60 | refs/heads/master | 2020-06-26T19:04:21.920807 | 2020-04-14T10:35:30 | 2020-04-14T10:35:30 | 199,724,568 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 137 | cpp | areal.cpp | #include <iostream>
#include <cmath>
using namespace std;
int main() {
long double n;
cin >> n;
cout << sqrt(n) * 4 << endl;
}
|
8ebf7b9d760e21d1e40c6cf9446ffbc477007731 | c8cc46a5927914ffabd35d7da8c091b90d7af9c8 | /src/test.cpp | 0e9b56aa48a450ab130a2ce6636d25455e664550 | [] | no_license | Fanssy1005/SSTE | 1a7e3aa330e608faf360e45e9a5fc8e96fe09b97 | 3306f712801ca3476ff3377522e3124c1aa36539 | refs/heads/master | 2022-04-25T11:45:29.528890 | 2020-04-23T12:34:35 | 2020-04-23T12:34:35 | 258,188,435 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 35 | cpp | test.cpp | #include<iostream>
cout<<"Hello";
|
0cca0db9ccffabde1fcdbba58426851064f5b383 | 17e7f2f8b786ee8361b9b755740e816411751b76 | /NexusNative/F3DFileHeader/VertexDefine.h | b86710774ebc076107a5712c85b66e5dc21da837 | [] | no_license | windless1015/My3DEngine2008 | 880945bd9d9f5e9a2ed30fe869ee53ec5b4fe2da | 6fffdd1b158ba9c63ffd564788fddd5706e08ac0 | refs/heads/master | 2022-11-13T17:41:46.620000 | 2020-07-02T13:31:19 | 2020-07-02T13:31:19 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,648 | h | VertexDefine.h |
#pragma once
#include "MathBaseDefine.h"
namespace F3D
{
//--所有的顶点格式都必须把Position放在第一个位置
enum EVertType
{
EVType_None,
EVType_PNT,
EVType_PT2,
EVType_PD,
EVType_PNT2,
EVType_PN,
EVType_PTp,
EVtype_PTD,
EVType_PSprite,
EVType_PtT,
EVType_Water,
EVType_Trn,
EVType_LowTrn,
EVType_T2,
EVType_PT,
EVType_PTpD,
EVType_Num,
};
struct Vert_PNT
{
Vector3 pos;
Vector3 normal;
Vector2 uv;
};
struct Vert_PT2
{
Vector3 pos;
Vector2 uv;
Vector2 uv2;
};
struct Vert_PD
{
Vector3 pos;
DWORD diffuse;
};
struct Vert_PT
{
Vector3 pos;
Vector2 uv;
}
;
struct Vert_PNT2
{
Vector3 pos;
Vector3 normal;
Vector2 uv;
Vector2 uv2;
};
struct Vert_PN
{
Vector3 pos;
Vector3 normal;
};
const int TRN_MAX_UV_SET=4;
struct Vert_T2
{
Vector2 uv[2];
};
/** 主要用于projector*/
struct Vert_PTp
{
Vector3 pos;
Vector3 uvw; //uv+透视校正因子
};
struct Vert_PTpD
{
Vector3 pos;
DWORD diffuse;
Vector3 uvw; //uv+透视校正因子
};
struct Vert_PTD//使用顶点颜色和贴图坐标,主要是特效用
{
Vector3 pos;
DWORD diffuse;
Vector2 uv;
};
struct Vert_PSprite //point sprite
{
Vector3 pos;
float size;
DWORD diffuse;
};
struct Vert_PtT
{
Vector4 pos; //经过转换的位置(屏幕坐标)
Vector2 uv;
};
struct Vert_Water//水面专用顶点格式
{
Vector3 pos;
DWORD diffuse;
Vector2 uv;
Vector4 uvw;//反射贴图坐标
};
inline UINT GetVertSize(EVertType type)
{
switch(type)
{
case EVType_PNT: return sizeof(Vert_PNT);
case EVType_PT2: return sizeof(Vert_PT2);
case EVType_PD: return sizeof(Vert_PD);
case EVType_PNT2: return sizeof(Vert_PNT2);
case EVType_PN: return sizeof(Vert_PN);
case EVType_PTp: return sizeof(Vert_PTp);
case EVtype_PTD: return sizeof(Vert_PTD);
case EVType_PSprite: return sizeof(Vert_PSprite);
case EVType_PtT: return sizeof(Vert_PtT);
case EVType_Water: return sizeof(Vert_Water);
case EVType_T2: return sizeof(Vert_T2);
case EVType_PT: return sizeof(Vert_PT);
case EVType_PTpD: return sizeof(Vert_PTpD);
}
return 0;
}
const UINT EDGE_MAX_FACE=32;
struct FaceEdge
{
WORD vert[2]; //组成此Edge的两个顶点的Index
WORD face[EDGE_MAX_FACE]; //共享此Edge的两个Face
FaceEdge()
{
memset(this,0xFF,sizeof(FaceEdge));
}
};
struct FaceTopo
{
FaceEdge edges[3];
float plane[4];
};
}//endof namespace F3D |
f801cdaf67d0427016e1ae202016cfe9dad9e09a | f308bbe9a0fcc98da52901412bca219b40dc0c9f | /projects/featurex/src/Descriptor.cpp | e8352c8ea7b6672a072d7c6ff0a8882ae3a7df56 | [
"MIT"
] | permissive | petercynthia/Mosaic | 2004b51cad64d6cb32014066efda82735c0164a6 | 5e01079eb29f82a5916dcbd8c8fd7936e322b873 | refs/heads/master | 2021-04-12T12:30:31.004598 | 2014-09-11T13:46:17 | 2014-09-11T13:46:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,325 | cpp | Descriptor.cpp | #include <sstream>
#include <fstream>
#include <featurex/Descriptor.h>
#include <featurex/Config.h>
#define ROXLU_USE_LOG
#include <tinylib.h>
namespace fex {
/* ---------------------------------------------------------------------------------- */
Descriptor::Descriptor()
:id(0)
,matched_id(0)
,row(-1)
,col(-1)
{
reset();
}
Descriptor::~Descriptor() {
reset();
row = -1;
col = -1;
}
void Descriptor::reset() {
average_color[0] = 0;
average_color[1] = 0;
average_color[2] = 0;
matched_id = 0;
}
/* ---------------------------------------------------------------------------------- */
int save_descriptors(std::string filename, std::vector<Descriptor>& descriptors) {
/* open file. */
std::ofstream ofs(filename.c_str());
if (!ofs.is_open()) {
RX_ERROR("Cannot save the descriptors; cannot open file");
return -1;
}
for (size_t i = 0; i < descriptors.size(); ++i) {
Descriptor& desc = descriptors[i];
ofs << desc.getFilename()
<< " " << desc.average_color[0]
<< " " << desc.average_color[1]
<< " " << desc.average_color[2]
<< "\n";
}
ofs.close();
return 0;
}
int load_descriptors(std::string filename, std::vector<Descriptor>& descriptors) {
/* open the file. */
std::ifstream ifs(filename.c_str());
if (!ifs.is_open()) {
RX_ERROR("Cannot load the descriptors.txt file; cannot open file %s", filename.c_str());
return -1;
}
Descriptor desc;
std::string line;
std::string fname;
std::string filepath;
while(std::getline(ifs, line)) {
std::stringstream ss(line);
/* create the descriptor. */
ss >> fname
>> desc.average_color[0]
>> desc.average_color[1]
>> desc.average_color[2];
desc.setFilename(fname);
/* check if the file still exists. */
filepath = fex::config.resized_filepath +"/" +fname;
if (false == rx_file_exists(filepath)) {
RX_ERROR("File seems to be removed, skipping descriptor: %s", fname.c_str());
continue;
}
descriptors.push_back(desc);
}
RX_VERBOSE("Loaded %lu descriptors.", descriptors.size());
ifs.close();
return 0;
}
} /* namespace fex */
|
a8f9830787a519e7a4746665891b1799e99d89f4 | e2a5dba8c142c9c67817beb8a1025248cc68792f | /Boggle/Boggle.cpp | 64635082f6fc6a590c8ae13feeff0e38eb2bd9a5 | [] | no_license | JeanArthurDeda/Boggle | 317d243ee7b975c1ad8f19b8283869c559742b8d | c4d90fa819f314a2b7d3f35e9e300b7e9ff991c2 | refs/heads/master | 2021-01-11T04:46:00.312639 | 2016-10-17T10:19:47 | 2016-10-17T10:19:47 | 71,125,448 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 854 | cpp | Boggle.cpp | #include <stdio.h>
#include "BoggleInterface.h"
#include "Core/Utils.h"
#include "Tests/TestDictonary.h"
#include "Tests/TestThreadPool.h"
#include "Tests/TestBoggleSolver.h"
#include <Windows.h>
int main()
{
HWND console = GetConsoleWindow();
RECT r;
GetWindowRect(console, &r); //stores the console's current dimensions
MoveWindow(console, 0, 0, r.right-r.left, 800, TRUE);
#if _DEBUG
LoadDictionary("english.txt");
// LoadDictionary("unity.txt");
// LoadDictionary("englishsmall.txt");
#else
LoadDictionary("english.txt");
#endif
// ~77 MB for cCItDictionaryFull
// ~68 MB for cCItDictionaryLight with hashes for WordId
// ~50 MB for a simple map with StringHash
// the StringHash has collisions on the english.txt
// Spooky hash 64 doesn't have collision
DoBoggleSolverTest ();
FreeDictionary ();
BREAKPOINT_RELEASE;
return 0x0;
} |
cc04ea62d99000ce3c28066e73d835aaa554edf9 | 1a1a10a8737d70e730acd0f5ded375357db16148 | /C++ study/상속과 포함/DocWriter.h | cd9080c90550e7a04458f55035d44860907d0f37 | [
"MIT"
] | permissive | jungmin-yoon1/TIL | 0f9b43e6ae12e06ac6466274c884a924e00dddb6 | efe733ce80941f24e8563516dbc40193537cb489 | refs/heads/main | 2023-06-14T16:37:24.105944 | 2021-07-12T07:20:42 | 2021-07-12T07:20:42 | 382,989,013 | 2 | 0 | null | null | null | null | UHC | C++ | false | false | 582 | h | DocWriter.h | #ifndef DOCWRITER_H
#define DOCWRITER_H
#include <string>
using namespace std;
//문서 저장 클래스 생성
class DocWriter
{
public:
//생성자
DocWriter();
DocWriter(const string& fileName, const string& content);
//소멸자
~DocWriter();
//파일 이름을 지정
void SetFileName(const string& fileName);
//저장할 텍스트 지정
void SetContent(const string& content);
//파일에 텍스트 저장
virtual void Write();
protected:
string _fileName; //문서를 저장할 파일의 이름 저장
string _content; //문서의 내용 저장
};
#endif |
6e549ebbcaeae16939aa8dad2d5be3e3bdd21a66 | 828ef027ebb1da770ce2aa3c11f2aa698e53c621 | /剑指offer/25.cpp | 3f4acefeab05473318054457adb8bdea29bf856f | [] | no_license | 719400737/LeetCode | 7773a1d99413c35dff48ced0506c6aea972b398d | 3c7df4253368b70e7c829bdf00dbf0aa24f339ba | refs/heads/master | 2021-02-08T03:39:51.317522 | 2020-08-25T08:54:06 | 2020-08-25T08:54:06 | 244,104,955 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 800 | cpp | 25.cpp | #include<bits/stdc++.h>
using namespace std;
struct ListNode{
int val;
ListNode* next;
ListNode(int x):val(x),next(NULL){}
};
class Solution {
public:
ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) {
ListNode* prehead=new ListNode(0);
ListNode* cur=prehead;
while(l1!=NULL && l2!=NULL){
if(l1->val < l2->val){
cur->next=l1;
l1=l1->next;
cur=cur->next;
}
else{
cur->next=l2;
l2=l2->next;
cur=cur->next;
}
}
if(l1!=NULL)
cur->next=l1;
else cur->next=l2;
ListNode* res=prehead->next;
delete prehead;
return res;
}
};
int main(){
return 1;
} |
35f13af0d81572c8e97e8b0f30527a8449d8f7f9 | 0a3f57ccc4f351723c035b67adf1909ffba06c23 | /raytracer/Materials/GlossySpecular.h | cf4077cb1b8beece12ec641517c898def1bf1cce | [] | no_license | jacksoncougar/cherenkov-radiation-ray-tracing | 3d57ae82e04a80a344e13322edaf376dda59be3b | e831c505b023c7c45da3980e72298c822d832c3b | refs/heads/master | 2022-07-06T02:44:39.076898 | 2020-05-20T14:49:15 | 2020-05-20T14:49:15 | 238,088,974 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,269 | h | GlossySpecular.h | #ifndef __MICROFACET__
#define __MICROFACET__
#include <Microfacet.h>
#include "Material.h"
#include "Lambertian.h"
//----------------------------------------------------------------------------- class Matte
class Microfacet: public Material {
public:
Microfacet(void);
Microfacet(const Microfacet& m);
virtual Material*
clone(void) const;
Microfacet&
operator=(const Microfacet& rhs);
~Microfacet(void);
void set_ka(const float k);
void set_kd(const float k);
void set_cd(const RGBColor k);
void set_specular_colour(const RGBColor);
void set_roughness(const float);
virtual RGBColor
shade(ShadeRec& sr);
private:
Lambertian* ambient_brdf;
Lambertian* diffuse_brdf;
GlossySpecularMicrofacet<DistributionFunc::TrowbridgeReitz>* specular_brdf;
};
inline void Microfacet::set_ka(const float ka) {
ambient_brdf->set_kd(ka);
}
inline void Microfacet::set_kd(const float kd) {
diffuse_brdf->set_kd(kd);
}
inline void Microfacet::set_cd(const RGBColor c) {
ambient_brdf->set_cd(c);
diffuse_brdf->set_cd(c);
}
inline void Microfacet::set_specular_colour(const RGBColor color) {
specular_brdf->setSpecularColour(color);
}
inline void Microfacet::set_roughness(const float roughness) {
specular_brdf->setRoughness(roughness);
}
#endif
|
2bcb6c12e32c65f069203793eef241abb596350e | 4f7f45c7d3b86dc440a109c9950c700b80902803 | /Viewer/src/main.cpp | 9b58ea63b6641b6496fef1d4d2962df757f0bfb9 | [] | no_license | MeshiLugasi/grafic | f7887713328557fd3300d237b819f5815169b81f | a5b5eb4eae2d45a2d8d4095b132e100bda08daf0 | refs/heads/main | 2023-05-30T09:18:45.935699 | 2021-06-16T15:43:06 | 2021-06-16T15:43:06 | 377,544,556 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 17,619 | cpp | main.cpp | #define _USE_MATH_DEFINES
#include <cmath>
#include <imgui/imgui.h>
#include <stdio.h>
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <nfd.h>
#include <iostream>
#include <InitShader.h>
#include "imgui_impl_glfw.h"
#include "imgui_impl_opengl3.h"
#include "Renderer.h"
#include "Scene.h"
#include "Utils.h"
/**
* Fields
*/
bool show_demo_window = false;
bool Local_World_Mode = false;
bool show_another_window = false;
glm::vec4 clear_color = glm::vec4(0.8f, 0.8f, 0.8f, 1.00f);
/**
* Function declarations
*/
static void GlfwErrorCallback(int error, const char* description);
GLFWwindow* SetupGlfwWindow(int w, int h, const char* window_name);
ImGuiIO& SetupDearImgui(GLFWwindow* window);
void StartFrame();
void RenderFrame(GLFWwindow* window, Scene& scene, Renderer& renderer, ImGuiIO& io);
void Cleanup(GLFWwindow* window);
void DrawImguiMenus(ImGuiIO& io, Scene& scene, Renderer& renderer);
/**
* Function implementation
*/
void ScrollCallback(GLFWwindow* window, double xoffset, double yoffset)
{
ImGui_ImplGlfw_ScrollCallback(window, xoffset, yoffset);
// TODO: Handle mouse scroll here
}
int main(int argc, char **argv)
{
std::cout << "test" << std::endl;//example
int windowWidth = 1280, windowHeight = 720;
GLFWwindow* window = SetupGlfwWindow(windowWidth, windowHeight, "Mesh Viewer");
if (!window)
return 1;
int frameBufferWidth, frameBufferHeight;
glfwMakeContextCurrent(window);
glfwGetFramebufferSize(window, &frameBufferWidth, &frameBufferHeight);
Renderer renderer = Renderer(frameBufferWidth, frameBufferHeight);
Scene scene = Scene();
ImGuiIO& io = SetupDearImgui(window);
glfwSetScrollCallback(window, ScrollCallback);
while (!glfwWindowShouldClose(window))
{
glfwPollEvents();
StartFrame();
DrawImguiMenus(io, scene,renderer);
RenderFrame(window, scene, renderer, io);
}
Cleanup(window);
return 0;
}
static void GlfwErrorCallback(int error, const char* description)
{
fprintf(stderr, "Glfw Error %d: %s\n", error, description);
}
GLFWwindow* SetupGlfwWindow(int w, int h, const char* window_name)
{
glfwSetErrorCallback(GlfwErrorCallback);
if (!glfwInit())
return NULL;
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
#if __APPLE__
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
#endif
GLFWwindow* window = glfwCreateWindow(w, h, window_name, NULL, NULL);
glfwMakeContextCurrent(window);
glfwSwapInterval(1); // Enable vsync
// very importent!! initialization of glad
// https://stackoverflow.com/questions/48582444/imgui-with-the-glad-opengl-loader-throws-segmentation-fault-core-dumped
gladLoadGLLoader((GLADloadproc)glfwGetProcAddress);
return window;
}
ImGuiIO& SetupDearImgui(GLFWwindow* window)
{
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init();
ImGui::StyleColorsDark();
return io;
}
void StartFrame()
{
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
}
void RenderFrame(GLFWwindow* window, Scene& scene, Renderer& renderer, ImGuiIO& io)
{
ImGui::Render();
int frameBufferWidth, frameBufferHeight;
glfwMakeContextCurrent(window);
glfwGetFramebufferSize(window, &frameBufferWidth, &frameBufferHeight);
if (frameBufferWidth != renderer.GetViewportWidth() || frameBufferHeight != renderer.GetViewportHeight())
{
// TODO: Set new aspect ratio
}
if (!io.WantCaptureKeyboard)
{
// TODO: Handle keyboard events here
if (io.KeysDown[65])
{
// A key is down
// Use the ASCII table for more key codes (https://www.asciitable.com/)
}
}
if (!io.WantCaptureMouse)
{
// TODO: Handle mouse events here
if (io.MouseDown[0])
{
// Left mouse button is down
}
}
renderer.ClearColorBuffer(clear_color);
renderer.Render(scene);
renderer.SwapBuffers();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
glfwMakeContextCurrent(window);
glfwSwapBuffers(window);
}
void Cleanup(GLFWwindow* window)
{
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
glfwDestroyWindow(window);
glfwTerminate();
}
void DrawImguiMenus(ImGuiIO& io, Scene& scene, Renderer& renderer)
{
/**
* MeshViewer menu
*/
ImGui::Begin("MeshViewer Menu");
// Menu Bar
if (ImGui::BeginMainMenuBar())
{
if (ImGui::BeginMenu("File"))
{
if (ImGui::MenuItem("Open", "CTRL+O"))
{
nfdchar_t* outPath = NULL;
nfdresult_t result = NFD_OpenDialog("obj;", NULL, &outPath);
if (result == NFD_OKAY)
{
scene.AddModel(Utils::LoadMeshModel(outPath));
//std::cout << scene.GetModelCount() << std::endl;
free(outPath);
}
else if (result == NFD_CANCEL)
{
}
else
{
}
}
ImGui::EndMenu();
}
// TODO: Add more menubar items (if you want to)'=
ImGui::EndMainMenuBar();
}
// Controls
ImGui::ColorEdit3("Clear Color", (float*)&clear_color);
// TODO: Add more controls as needed
ImGui::End();
/**
* Imgui demo - you can remove it once you are familiar with imgui
*/
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
if (show_demo_window)
ImGui::ShowDemoWindow(&show_demo_window);
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
{
static float f = 0.0f;
static float rotateX = 0.0f;
static float rotateY = 0.0f;
static float rotateZ = 0.0f;
static float scaleX = 100;
static float scaleY = 100;
static float scaleZ = 0.0f;
static float TranslateX = 640;
static float TranslateY = 400;
static float TranslateZ = 100;
bool Local_World_Mode;
//
static float rotateX_world = 0.0f;
static float rotateY_world = 0.0f;
static float rotateZ_world = 0.0f;
static float scaleX_world = 1.0f;
static float scaleY_world = 1.0f;
static float scaleZ_world = 1.0f;
static float TranslateX_world = 0.0f;
static float TranslateY_world = 0.0f;
static float TranslateZ_world = 0.0f;
//
static int counter = 0;
static float xCounter = 0;
static float yCounter = 0;
static float zCounter = 0;
//if(){}
ImGui::Begin("transform in world!"); // Create a window called "Hello, world!" and append into it.
//ImGui::Checkbox("World/Local Mode", &Local_World_Mode);
ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
ImGui::Checkbox("Another Window", &show_another_window);
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
//fix gui for new function tools
//rotate
ImGui::SliderFloat("Rotate X world:", &rotateX_world, 0.0f, 360.0f);
if (scene.GetModelCount() > 0)
{
//scene.GetActiveModel().set_anglex(rotateX);
scene.set_anglex(rotateX_world);
//renderer.Render(scene);
}
ImGui::SliderFloat("Rotate Y world:", &rotateY_world, 0.0f, 360.0f);
if (scene.GetModelCount() > 0)
{
//scene.GetActiveModel().set_anglex(rotateX);
scene.set_angley(rotateY_world);
//renderer.Render(scene);
}
ImGui::SliderFloat("Rotate Z world:", &rotateZ_world, 0.0f, 360.0f);
if (scene.GetModelCount() > 0)
{
//scene.GetActiveModel().set_anglex(rotateX);
scene.set_anglez(rotateZ_world);
//renderer.Render(scene);
}
//scale
ImGui::SliderFloat("Scale X world:", &scaleX_world, 0.1f, 2.0f);
if (scene.GetModelCount() > 0)
{
//scene.GetActiveModel().set_scalex(yCounter);
scene.set_scalex(scaleX_world);
//renderer.Render(scene);
}
ImGui::SliderFloat("Scale Y world:", &scaleY_world, 0.1f, 2.0f);
if (scene.GetModelCount() > 0)
{
//scene.GetActiveModel().set_scaley(yCounter);
scene.set_scaley(scaleY_world);
//renderer.Render(scene);
}
ImGui::SliderFloat("Scale Z world:", &scaleZ_world, 0.1f, 2.0f);
if (scene.GetModelCount() > 0)
{
//scene.GetActiveModel().set_scalez(yCounter);
scene.set_scalez(scaleZ_world);
//renderer.Render(scene);
}
//
//Translate
ImGui::SliderFloat("Translate X world:", &TranslateX_world, 0.0f, 1000.0f);
if (scene.GetModelCount() > 0) {
//scene.GetActiveModel().set_translatex(zCounter);
scene.set_translatex(TranslateX_world);
//renderer.Render(scene);
}
ImGui::SliderFloat("Translate Y world:", &TranslateY_world, 0.0f, 1000.0f);
if (scene.GetModelCount() > 0) {
//scene.GetActiveModel().set_translatex(zCounter);
scene.set_translatey(TranslateY_world);
//renderer.Render(scene);
}
ImGui::SliderFloat("Translate Z world:", &TranslateZ_world, 0.0f, 1000.0f);
if (scene.GetModelCount() > 0) {
//scene.GetActiveModel().set_translatex(zCounter);
scene.set_translatez(TranslateZ_world);
//renderer.Render(scene);
}
//ImGui::Text("Rotate X:");
//ImGui::Text("Rotate X:");
//ImGui::Text("X = %f", xCounter);
//if (ImGui::Button("X +1")) // Buttons return true when clicked (most widgets return true when edited/activated)
// xCounter++;
//ImGui::SameLine();
//if (ImGui::Button("X +10")) // Buttons return true when clicked (most widgets return true when edited/activated)
// xCounter += 10;
//ImGui::SameLine();
//if (ImGui::Button("X +45")) // Buttons return true when clicked (most widgets return true when edited/activated)
// xCounter += 45;
//if (scene.GetModelCount() > 0) {
// scene.GetActiveModel().set_anglex(xCounter);
// renderer.Render(scene);
//
//}
//if (ImGui::Button("X -1")) // Buttons return true when clicked (most widgets return true when edited/activated)
// xCounter--;
//ImGui::SameLine();
//if (ImGui::Button("X -10")) // Buttons return true when clicked (most widgets return true when edited/activated)
// xCounter -= 10;
//ImGui::SameLine();
//if (ImGui::Button("Y -45")) // Buttons return true when clicked (most widgets return true when edited/activated)
// xCounter -= 45;
////ImGui::Text("Rotate Y:");
//ImGui::Text("Rotate Y:");
//ImGui::Text("Y = %f", yCounter);
//if (ImGui::Button("Y +1")) // Buttons return true when clicked (most widgets return true when edited/activated)
// yCounter++;
//ImGui::SameLine();
//if (ImGui::Button("Y +10")) // Buttons return true when clicked (most widgets return true when edited/activated)
// yCounter+=10;
//ImGui::SameLine();
//if (ImGui::Button("Y +45")) // Buttons return true when clicked (most widgets return true when edited/activated)
// yCounter+=45;
//if (scene.GetModelCount() > 0) {
// scene.GetActiveModel().set_scalex(yCounter);
// renderer.Render(scene);
//}
//if (ImGui::Button("Y -1")) // Buttons return true when clicked (most widgets return true when edited/activated)
// yCounter--;
//ImGui::SameLine();
//if (ImGui::Button("Y -10")) // Buttons return true when clicked (most widgets return true when edited/activated)
// yCounter-=10;
//ImGui::SameLine();
//if (ImGui::Button("Y -45")) // Buttons return true when clicked (most widgets return true when edited/activated)
// yCounter-=45;
////ImGui::Text("Rotate Z:");
//ImGui::Text("Rotate Z:");
//ImGui::Text("Z = %f", zCounter);
//if (ImGui::Button("Z +1")) // Buttons return true when clicked (most widgets return true when edited/activated)
// zCounter++;
//ImGui::SameLine();
//if (ImGui::Button("Z +10")) // Buttons return true when clicked (most widgets return true when edited/activated)
// zCounter += 10;
//ImGui::SameLine();
//if (ImGui::Button("Z +45")) // Buttons return true when clicked (most widgets return true when edited/activated)
// zCounter += 45;
//if (scene.GetModelCount() > 0) {
// scene.GetActiveModel().set_translatex(zCounter);
// renderer.Render(scene);
//}
//if (ImGui::Button("Z -1")) // Buttons return true when clicked (most widgets return true when edited/activated)
// zCounter--;
//ImGui::SameLine();
//if (ImGui::Button("Z -10")) // Buttons return true when clicked (most widgets return true when edited/activated)
// zCounter -= 10;
//ImGui::SameLine();
//if (ImGui::Button("Z -45")) // Buttons return true when clicked (most widgets return true when edited/activated)
// zCounter -= 45;
//
if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
counter++;
ImGui::SameLine();
ImGui::Text("counter = %d", counter);
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
ImGui::End();//
ImGui::Begin("transform in local!"); // Create a window called "Hello, world!" and append into it.
ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
ImGui::Checkbox("Another Window", &show_another_window);
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
//fix gui for new function tools
//rotate
ImGui::SliderFloat("Rotate X :", &rotateX, 0.0f, 1000.0f);
if (scene.GetModelCount() > 0)
{
//scene.GetActiveModel().set_anglex(rotateX);
scene.GetModel(scene.GetModelCount() - 1).set_anglex(rotateX);
renderer.Render(scene);
}
ImGui::SliderFloat("Rotate Y:", &rotateY, 0.0f, 1000.0f);
if (scene.GetModelCount() > 0)
{
//scene.GetActiveModel().set_anglex(rotateX);
scene.GetModel(scene.GetModelCount() - 1).set_angley(rotateY);
renderer.Render(scene);
}
ImGui::SliderFloat("Rotate Z:", &rotateZ, 0.0f, 1000.0f);
if (scene.GetModelCount() > 0)
{
//scene.GetActiveModel().set_anglex(rotateX);
scene.GetModel(scene.GetModelCount() - 1).set_anglez(rotateZ);
renderer.Render(scene);
}
//scale
ImGui::SliderFloat("Scale X:", &scaleX, 0.0f, 1000.0f);
if (scene.GetModelCount() > 0)
{
//scene.GetActiveModel().set_scalex(yCounter);
scene.GetModel(scene.GetModelCount() - 1).set_scalex(scaleX);
renderer.Render(scene);
}
ImGui::SliderFloat("Scale Y:", &scaleY, 0.0f, 1000.0f);
if (scene.GetModelCount() > 0)
{
//scene.GetActiveModel().set_scaley(yCounter);
scene.GetModel(scene.GetModelCount() - 1).set_scaley(scaleY);
renderer.Render(scene);
}
ImGui::SliderFloat("Scale Z:", &scaleZ, 0.0f, 1000.0f);
if (scene.GetModelCount() > 0)
{
//scene.GetActiveModel().set_scalez(yCounter);
scene.GetModel(scene.GetModelCount() - 1).set_scalez(scaleZ);
renderer.Render(scene);
}
//
//Translate
ImGui::SliderFloat("Translate X:", &TranslateX, 0.0f, 1000.0f);
if (scene.GetModelCount() > 0) {
//scene.GetActiveModel().set_translatex(zCounter);
scene.GetModel(scene.GetModelCount() - 1).set_translatex(TranslateX);
renderer.Render(scene);
}
ImGui::SliderFloat("Translate Y:", &TranslateY, 0.0f, 1000.0f);
if (scene.GetModelCount() > 0) {
//scene.GetActiveModel().set_translatex(zCounter);
scene.GetModel(scene.GetModelCount() - 1).set_translatey(TranslateY);
renderer.Render(scene);
}
ImGui::SliderFloat("Translate Z:", &TranslateZ, 0.0f, 1000.0f);
if (scene.GetModelCount() > 0) {
//scene.GetActiveModel().set_translatex(zCounter);
scene.GetModel(scene.GetModelCount() - 1).set_translatez(TranslateZ);
renderer.Render(scene);
}
if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
counter++;
ImGui::SameLine();
ImGui::Text("counter = %d", counter);
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
ImGui::End();//
}
// 3. Show another simple window.
if (show_another_window)
{
ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
ImGui::Text("Hello from another window!");
if (ImGui::Button("Close Me"))
show_another_window = false;
ImGui::End();
}
} |
b19a4aed3512605e50a75ead3654176726e51c9f | fe4465cef4cb219ed618229aeb718c2224f937b9 | /EserciziClasse/Time/Time.cpp | ad6e4cb6b9c05d5f3de738c8075c21bde4a100fd | [] | no_license | salva00/ProgrammiCeck_P1 | 53f8eb286589c8bf673363f468664928a01cbb35 | b7a41c8d32e9c29b48516db287fa54517c151100 | refs/heads/master | 2023-06-26T10:00:28.111557 | 2021-07-30T18:27:00 | 2021-07-30T18:27:00 | 361,877,243 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,449 | cpp | Time.cpp |
#include "Time.h"
#include <iomanip> //for setw and setfill stream manipulators
#include <sstream> //for ostringstream class
void Time::setTime(int h, int m, int s) {
setHour(h);
setMinute(m);
setSecond(s);
}
std::string Time::toUniversalString() const {
std::ostringstream output;
output << std::setfill('0') << std::setw(2) << hour << ":"
<< std::setw(2) << minute << ":" << std::setw(2) << second;
return output.str();
}
std::string Time::toStandardString() const {
std::ostringstream output;
output << (( hour == 0 || hour == 12) ? 12 : hour % 12) << ":"
<< std::setfill('0') << std::setw(2) << minute << ":" << std::setw(2)
<< std::setw(2) << minute << ":" << std::setw(2) << second;
return output.str();
}
Time::Time(int hour , int minute, int second) {
setTime(hour,minute,second);
}
void Time::setHour(int hour) {
if(hour>=0 && hour<24){
this->hour=hour;
}else{
throw std::invalid_argument(
"Hours was out of range");
}
}
void Time::setMinute(int minute) {
if(minute>=0 && minute<60){
this->minute=minute;
}else{
throw std::invalid_argument(
"minute was out of range");
}
}
void Time::setSecond(int second) {
if(second>=0 && second<60){
this->second=second;
}else{
throw std::invalid_argument(
"second was out of range");
}
}
|
1a8586f975c51eb5a68333fa638162d2cd8d5116 | 6459f8e5d687f6bc3e3e49e6a5b488e93c837a65 | /Datum.h | 04e85b76c599b139e644b2b85319b784752085fa | [] | no_license | g-ben-wiz/OgreBulletMVC | 5e6f8e4c7fcb9c2f5acd56a57a8ac00c27b33749 | 8e043132918552842a29f1055a5d4b096c9a9d48 | refs/heads/master | 2021-01-20T15:37:16.767828 | 2013-06-11T12:53:16 | 2013-06-11T12:53:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,126 | h | Datum.h | #include <OgreCamera.h>
#include <OgreConfigFile.h>
#include <OgreEntity.h>
#include <OgreMeshManager.h>
#include <OgreRenderWindow.h>
#include <OgreRoot.h>
#include <OgreSceneManager.h>
#include <OgreViewport.h>
#include <OgreWindowEventUtilities.h>
#include <OISEvents.h>
#include <OISInputManager.h>
#include <OISKeyboard.h>
#include "DatumMotionState.h"
class Datum {
public:
Datum();
Datum(btScalar mass, Ogre::SceneNode* sceneNode, Ogre::Entity* ogreEntity, btCollisionShape* collisionShape, btVector3 location);
~Datum();
int id;
bool touched;
bool canJump;
bool touchingGround;
bool turningLeft;
bool turningRight;
Ogre::AnimationState* animationState;
void swat(Datum* target);
void jump();
void turn();
void walk();
bool walkingForward;
bool walkingBack;
bool walkingLeft;
bool walkingRight;
btVector3 getLocalZ();
btVector3 getLocalX();
Ogre::SceneNode* sceneNode;
Ogre::Entity* ogreEntity;
btRigidBody* physicsBody;
btCollisionShape* collisionShape;
DatumMotionState* motionState;
btScalar mass;
};
|
918907c728ca5db422711d61eca71d04c59e011b | 0eff74b05b60098333ad66cf801bdd93becc9ea4 | /second/download/git/gumtree/git_new_log_2251.cpp | 80a4818c9b7e87d7e24334693d3ebff65d46d49c | [] | no_license | niuxu18/logTracker-old | 97543445ea7e414ed40bdc681239365d33418975 | f2b060f13a0295387fe02187543db124916eb446 | refs/heads/master | 2021-09-13T21:39:37.686481 | 2017-12-11T03:36:34 | 2017-12-11T03:36:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 51 | cpp | git_new_log_2251.cpp | status_printf_ln(s, color, _("No commands done.")); |
ef3f37e53803b14897d7f87e01e1fc0e4716d123 | 3f75f8a32e05a33d3828a7ee0047fb6f466a8222 | /item6/main.cpp | 1be3af62f8688f7b4e686a251ed8db055f85af5a | [] | no_license | cona123/effectivec- | 0c2669db8b10d27603dbe2655c08cdf06b9b676d | a4f4d02df5d725934a07940a1fad4301435194c9 | refs/heads/master | 2020-12-21T00:27:07.535463 | 2020-02-18T00:17:11 | 2020-02-18T00:17:11 | 236,254,732 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 270 | cpp | main.cpp | #include "HomeForSale.h"
int main()
{
HomeForSale a;
HomeForSale b(a);//wrong:use of deleted function ‘HomeForSale::HomeForSale(const HomeForSale&)’
HomeForSale c = a;//wrong: use of deleted function ‘HomeForSale::HomeForSale(const HomeForSale&)’
} |
3d061322039463b98380d12479c23da130d5d8d7 | c8bbccd8ec055e72ef9589a8814cd5b3dc474c05 | /shocktube/openfoam3/0.0038/mag(U) | b7581e5bbfe294f5dad175b4a79d98767ad9bfa0 | [] | no_license | samtx/adv-fluids | f221253be7290a0b04a50b6fbaa9f30efc181e28 | 8baf7a4f12ed3d5bc24418fa685a9dd2c72aee61 | refs/heads/master | 2021-01-21T06:38:16.914084 | 2017-05-06T20:49:27 | 2017-05-06T20:49:27 | 82,866,684 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,511 | mag(U) | /*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0.0038";
object mag(U);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField nonuniform List<scalar>
1000
(
1.62493e-11
1.6801e-11
1.71704e-11
1.70335e-11
1.59739e-11
1.63471e-11
1.64953e-11
1.71115e-11
1.64311e-11
1.85192e-11
1.75623e-11
2.08648e-11
2.17713e-11
2.29598e-11
1.86238e-11
1.91346e-11
1.78081e-11
1.92853e-11
1.61302e-11
1.81659e-11
1.32899e-11
1.43814e-11
1.21171e-11
1.31784e-11
8.00728e-12
1.08759e-11
9.10309e-12
1.05497e-11
9.85242e-12
1.03271e-11
1.17486e-11
9.82332e-12
9.53705e-12
5.28284e-12
6.52223e-12
4.47823e-12
7.30861e-12
4.37427e-12
1.0244e-11
5.62346e-12
1.05935e-11
8.09879e-12
1.24438e-11
6.87504e-12
8.34603e-12
6.46018e-12
7.61076e-12
8.79563e-12
9.24046e-12
6.88162e-12
9.71657e-12
5.79322e-12
8.46841e-12
8.27689e-12
7.28577e-12
8.16643e-12
6.26669e-12
9.6946e-12
5.0024e-12
8.4525e-12
5.03668e-12
7.4726e-12
6.76175e-12
8.10711e-12
6.41633e-12
8.92775e-12
8.14167e-12
9.02507e-12
4.58386e-12
6.75449e-12
4.59842e-13
1.75548e-12
2.38266e-12
4.94615e-13
1.27813e-12
4.13806e-12
3.72054e-13
1.57636e-12
1.79853e-12
2.7476e-12
3.88025e-12
4.91577e-12
3.03214e-12
4.44381e-12
4.84746e-12
8.66901e-13
2.77975e-12
1.0214e-12
3.39007e-12
6.74825e-13
2.02908e-12
7.99764e-13
2.57911e-12
3.8193e-12
8.07767e-13
5.65937e-12
5.30487e-12
9.50888e-12
1.01669e-11
1.28085e-11
1.18217e-11
1.07172e-11
1.08023e-11
7.41257e-12
1.06169e-11
9.47318e-12
1.05988e-11
1.13132e-11
8.64198e-12
8.28707e-12
7.56696e-12
5.49732e-12
6.17378e-12
7.32541e-12
9.44141e-12
1.1629e-11
9.97828e-12
9.3928e-12
1.07199e-11
1.14921e-11
1.15753e-11
1.32875e-11
1.15076e-11
1.36916e-11
1.11001e-11
1.00861e-11
7.83823e-12
1.06048e-11
9.14727e-12
9.927e-12
1.00098e-11
1.06465e-11
1.01466e-11
7.07731e-12
6.8754e-12
6.20362e-12
4.31723e-12
3.04337e-12
3.72044e-12
4.33504e-12
2.68028e-12
5.06642e-12
5.54838e-12
4.68237e-12
5.0989e-12
6.89561e-12
7.35287e-12
5.4492e-12
7.42824e-12
6.76872e-12
8.82345e-12
6.61897e-12
9.01536e-12
4.42995e-12
7.60849e-12
7.36582e-12
8.4527e-12
1.01787e-11
8.10155e-12
7.01506e-12
7.8326e-12
7.27173e-12
7.45238e-12
8.2972e-12
5.0754e-12
4.77328e-12
6.13479e-12
5.6355e-12
6.96782e-12
6.96818e-12
8.91866e-12
1.13269e-11
1.03116e-11
1.24553e-11
1.31271e-11
1.34117e-11
9.6628e-12
1.22348e-11
9.90501e-12
1.23707e-11
7.87232e-12
8.71196e-12
7.77922e-12
8.53165e-12
7.26701e-12
9.6497e-12
8.86138e-12
8.74422e-12
8.70182e-12
9.02918e-12
8.85897e-12
4.63085e-12
6.52288e-12
4.03599e-12
5.45229e-12
2.86064e-12
5.40425e-12
2.6807e-12
5.28164e-12
1.31229e-12
4.84141e-12
5.73982e-13
5.57389e-12
4.11695e-12
5.32844e-12
3.96499e-12
3.99794e-12
9.31158e-13
8.15136e-13
4.23691e-12
6.2807e-12
7.26536e-12
7.1055e-12
1.05325e-11
9.9315e-12
1.07138e-11
7.27492e-12
1.27015e-11
9.15182e-12
1.51522e-11
1.18753e-11
1.45965e-11
9.76794e-12
1.3147e-11
8.09431e-12
1.29137e-11
7.27673e-12
1.28815e-11
9.16617e-12
8.47607e-12
6.62911e-12
6.34927e-12
7.76774e-12
5.6484e-12
7.99259e-12
4.30882e-12
7.32897e-12
4.14738e-12
5.70343e-12
4.18829e-12
8.14757e-12
3.60812e-12
7.33709e-12
4.90132e-13
4.70273e-12
1.26047e-12
3.70859e-12
1.89201e-12
3.11632e-12
3.74632e-12
5.61186e-12
5.26357e-12
6.93975e-12
3.88635e-12
6.79862e-12
4.36073e-12
5.23289e-12
2.63026e-12
4.88176e-12
5.79292e-12
5.88154e-12
4.35195e-12
5.0076e-12
3.8804e-12
1.68882e-12
3.94291e-13
1.38844e-12
3.55304e-12
5.15833e-13
2.1497e-12
5.19896e-12
6.04166e-12
4.90846e-12
5.64193e-12
5.6181e-12
9.53494e-12
7.63017e-12
1.27188e-11
9.041e-12
1.07259e-11
7.92641e-12
9.83796e-12
6.88535e-12
7.77762e-12
6.50152e-12
8.49076e-12
7.25574e-12
8.17777e-12
5.50029e-12
4.41041e-12
4.44817e-12
6.54976e-12
4.97979e-12
4.58912e-12
8.07346e-12
9.01436e-12
9.04408e-12
1.0562e-11
1.47497e-11
2.39968e-11
4.98467e-11
1.04679e-10
2.366e-10
5.29549e-10
1.17777e-09
2.583e-09
5.61058e-09
1.20685e-08
2.57153e-08
5.42767e-08
1.13487e-07
2.35054e-07
4.82185e-07
9.79547e-07
1.97028e-06
3.92325e-06
7.7322e-06
1.50804e-05
2.90996e-05
5.55433e-05
0.000104845
0.000195673
0.000360968
0.000658023
0.00118501
0.00210752
0.0037004
0.00641197
0.0109605
0.0184749
0.0306934
0.0502343
0.0809493
0.128359
0.200151
0.306696
0.461479
0.681305
0.986054
1.39771
1.93824
2.62564
3.46701
4.45428
5.57141
6.80415
8.14114
9.57163
11.0848
12.6701
14.3178
16.0189
17.7657
19.5517
21.3711
23.2194
25.0925
26.9872
28.9007
30.8307
32.7754
34.733
36.7022
38.6818
40.6707
42.6679
44.6728
46.6845
48.7026
50.7263
52.7553
54.789
56.827
58.869
60.9147
62.9636
65.0155
67.0701
69.1272
71.1865
73.2477
75.3107
77.3751
79.4409
81.5077
83.5754
85.6438
87.7127
89.7819
91.8512
93.9203
95.9892
98.0576
100.125
102.192
104.258
106.322
108.385
110.446
112.505
114.561
116.615
118.667
120.715
122.76
124.801
126.838
128.87
130.898
132.921
134.937
136.948
138.952
140.949
142.939
144.919
146.891
148.853
150.805
152.745
154.673
156.588
158.488
160.373
162.241
164.09
165.92
167.729
169.514
171.274
173.008
174.71
176.382
178.018
179.617
181.174
182.687
184.153
185.565
186.925
188.222
189.456
190.622
191.715
192.733
193.67
194.524
195.295
195.978
196.575
197.089
197.518
197.872
198.153
198.367
198.526
198.637
198.706
198.747
198.764
198.768
198.768
198.767
198.764
198.755
198.738
198.713
198.685
198.659
198.637
198.621
198.608
198.6
198.596
198.593
198.591
198.59
198.588
198.587
198.585
198.584
198.583
198.583
198.582
198.581
198.581
198.58
198.579
198.578
198.577
198.577
198.576
198.575
198.575
198.574
198.573
198.573
198.572
198.571
198.57
198.57
198.569
198.568
198.568
198.567
198.567
198.566
198.565
198.565
198.564
198.563
198.563
198.562
198.562
198.561
198.56
198.56
198.559
198.559
198.558
198.558
198.557
198.557
198.556
198.556
198.555
198.555
198.554
198.554
198.553
198.552
198.552
198.551
198.55
198.55
198.549
198.548
198.548
198.547
198.546
198.545
198.544
198.544
198.543
198.543
198.542
198.542
198.541
198.54
198.54
198.541
198.541
198.541
198.541
198.54
198.539
198.538
198.539
198.541
198.541
198.538
198.536
198.535
198.535
198.535
198.536
198.541
198.552
198.567
198.597
198.667
198.833
198.905
198.771
198.618
198.508
198.46
198.474
198.502
198.502
198.491
198.509
198.541
198.539
198.51
198.504
198.535
198.554
198.531
198.502
198.516
198.546
198.54
198.504
198.496
198.527
198.542
198.512
198.488
198.513
198.545
198.53
198.492
198.494
198.531
198.545
198.513
198.486
198.506
198.538
198.528
198.493
198.491
198.525
198.535
198.501
198.48
198.509
198.539
198.516
198.477
198.487
198.528
198.53
198.488
198.47
198.503
198.531
198.504
198.464
198.475
198.515
198.514
198.471
198.454
198.488
198.511
198.479
198.44
198.454
198.492
198.483
198.436
198.421
198.455
198.473
198.434
198.392
198.406
198.439
198.422
198.369
198.353
198.382
198.391
198.343
198.295
198.305
198.33
198.3
198.237
198.214
198.234
198.227
198.164
198.107
198.105
198.112
198.061
197.983
197.944
197.94
197.907
197.82
197.743
197.706
197.677
197.594
197.481
197.402
197.351
197.271
197.125
196.984
196.891
196.801
196.625
196.4
196.23
196.106
195.912
195.589
195.28
195.06
194.836
194.4
193.826
193.388
193.099
192.529
191.264
189.411
186.29
178.781
151.946
87.1516
27.3275
7.0992
1.72759
0.411306
0.0973059
0.0229848
0.00542748
0.00128158
0.000302606
7.1448e-05
1.68686e-05
3.98244e-06
9.4015e-07
2.21932e-07
5.2383e-08
1.23591e-08
2.91142e-09
6.82499e-10
1.529e-10
3.12082e-11
1.32787e-12
5.41551e-12
9.23626e-12
5.4093e-12
7.18771e-12
2.24017e-12
3.86512e-12
4.05959e-13
4.54553e-12
3.64411e-12
5.6809e-12
5.08938e-12
4.95344e-12
2.30094e-12
6.82643e-12
4.676e-13
2.11044e-12
4.85022e-12
4.87202e-12
1.30408e-12
3.18912e-12
3.22363e-12
2.38948e-12
8.32368e-13
1.91111e-12
2.75584e-12
2.63664e-13
5.78791e-12
1.05275e-12
3.24946e-12
8.97578e-13
1.70741e-12
9.06871e-13
7.3188e-13
1.54428e-12
5.56958e-12
3.23646e-12
2.16802e-12
1.25024e-12
5.26917e-12
4.43629e-12
3.86935e-12
6.18252e-12
4.34283e-12
8.14804e-12
7.42893e-12
6.3998e-12
5.04994e-12
5.18404e-12
1.85478e-12
3.80202e-12
4.47512e-12
5.03072e-12
2.5204e-12
3.08759e-12
1.13542e-12
1.30326e-12
3.05628e-12
6.5468e-13
2.68066e-12
6.61476e-13
2.46914e-12
3.49841e-12
3.90204e-12
2.22532e-12
4.01301e-12
2.84514e-12
5.55741e-13
4.11706e-12
5.51717e-13
3.49059e-12
2.51606e-12
2.00061e-13
2.48301e-12
3.97888e-12
2.24054e-12
4.4876e-12
7.56927e-12
4.64747e-12
6.27179e-12
2.73751e-12
9.31929e-12
4.07958e-12
6.54208e-12
2.02709e-12
7.7122e-12
3.40231e-12
4.43313e-12
2.10837e-12
5.78096e-13
3.29381e-12
2.63942e-12
4.73829e-12
1.09362e-12
1.2074e-12
1.58327e-12
7.85076e-13
2.62182e-12
1.60154e-12
2.56176e-12
2.82687e-12
2.37608e-12
2.22889e-12
1.5858e-12
1.48672e-12
5.22608e-13
9.82851e-13
3.99999e-12
3.67842e-12
7.85373e-12
7.36908e-12
1.0285e-11
8.54282e-12
9.45505e-12
9.15873e-12
6.65068e-12
4.91941e-12
4.52096e-12
3.75875e-12
4.44249e-12
4.96789e-12
8.25361e-12
5.04668e-12
5.95571e-12
5.86589e-12
6.59478e-12
6.48787e-12
6.82137e-12
7.74307e-12
9.92253e-12
8.79668e-12
1.06481e-11
1.11214e-11
1.13628e-11
1.03905e-11
9.3729e-12
9.5636e-12
8.01979e-12
6.30749e-12
5.13035e-12
5.04321e-12
3.00108e-12
6.81178e-12
7.07544e-12
6.15621e-12
5.49993e-12
2.7794e-12
1.32144e-12
1.66567e-12
5.19783e-14
1.19751e-12
1.74341e-12
4.29076e-13
9.2397e-13
2.84908e-12
2.74964e-12
1.66324e-12
3.33201e-13
7.78728e-13
6.98483e-13
4.62069e-14
1.42335e-12
1.42515e-12
4.65662e-12
4.97774e-12
4.92191e-12
3.50817e-12
1.12371e-12
3.31723e-12
2.48827e-12
4.99397e-12
3.76684e-12
9.42023e-13
1.46377e-12
3.74566e-12
1.51637e-12
4.0948e-13
1.36491e-12
4.31366e-13
2.49046e-12
2.86374e-12
6.55414e-12
2.8451e-13
2.82911e-12
2.54422e-12
3.13133e-12
3.00996e-13
2.51692e-12
4.13466e-12
5.44318e-12
3.05965e-12
3.3605e-12
3.92506e-12
1.36193e-12
6.82609e-12
7.52601e-12
8.36274e-12
6.14568e-12
8.08992e-12
8.86644e-12
1.13738e-11
1.17844e-11
1.44516e-11
1.45839e-11
1.3744e-11
1.0474e-11
8.93296e-12
8.74449e-12
1.02044e-11
9.72235e-12
9.64758e-12
1.03703e-11
1.3245e-11
1.39402e-11
1.38307e-11
1.36485e-11
1.58536e-11
1.67904e-11
1.76955e-11
1.88748e-11
2.25268e-11
2.0859e-11
2.30135e-11
2.3416e-11
2.8808e-11
2.86311e-11
3.05919e-11
2.93908e-11
2.94264e-11
2.87824e-11
2.89509e-11
2.57029e-11
2.43556e-11
2.40734e-11
2.38569e-11
2.32754e-11
2.36394e-11
2.41901e-11
2.16785e-11
1.93794e-11
1.74544e-11
1.9285e-11
1.46226e-11
1.46865e-11
1.41762e-11
1.67002e-11
1.60326e-11
1.66581e-11
1.59675e-11
1.97478e-11
1.66003e-11
1.70946e-11
1.39083e-11
1.40822e-11
1.44057e-11
1.6147e-11
1.81565e-11
1.97023e-11
2.13543e-11
2.0819e-11
2.16921e-11
2.24164e-11
2.40906e-11
2.18441e-11
2.20301e-11
2.08595e-11
2.18345e-11
1.83983e-11
2.27679e-11
2.03522e-11
2.35472e-11
2.03927e-11
2.213e-11
2.03475e-11
)
;
boundaryField
{
sides
{
type calculated;
value nonuniform List<scalar> 2(2.03475e-11 1.62493e-11);
}
empty
{
type empty;
}
}
// ************************************************************************* //
| |
185b66cac399cbcdb8923ca981d548649bd8e725 | 1b457f6d13b58797ab23898971b711f41b879b19 | /source/filesavemanager.cpp | b5d8305276e0f46cb859aef543065dbca59cf80c | [] | no_license | NDD86/streamfiler | dd820dd69db613f0aea1e7670802f430e4777b5f | cf75b87f572c9aece6d14354036f2531ffe93373 | refs/heads/main | 2023-06-12T01:13:21.746830 | 2021-06-30T06:40:05 | 2021-06-30T06:40:05 | 381,318,207 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 570 | cpp | filesavemanager.cpp | #include "filesavemanager.h"
#include "filesaver.h"
#include <filesystem>
FileSaveManager::FileSaveManager(std::string path):path(path){
//Ha nem létezik a megadott könyvtár struktúra létre kell hozni
std::filesystem::create_directories(path);
// Ha nincs / az elérési út végén most dateszi, hogy a kimentőnek már csak a fájl nevével keljen fogalkozni
if(path[path.size()-1] != '/') this->path += "/";
}
SaverInterface* FileSaveManager::CreateNewSaver(){
// Kérésre új kimentőt készít
return new FileSaver(path);
}
// )\) |
2157016d3591bd135fcfb23713311e312ddc5af8 | be72992ccace58f4ada7f5282f5fab6986fb2940 | /main.cpp | 127a473221dab847fb4e6b119caf146422a717c5 | [] | no_license | grumpyLemons/complex_numbers | 08e7cb2e5eeada4049bca2badd5a67cfef311871 | d33085c37cfd8243185fc002f91fd236abd39b0f | refs/heads/master | 2023-05-17T04:09:27.065585 | 2021-06-12T13:43:26 | 2021-06-12T13:43:26 | 376,299,634 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 126 | cpp | main.cpp | #include <iostream>
#include "Complex.h"
int main() {
Complex x(1, 0);
std::cout << x.Re() << std::endl << x.Im();
}
|
4757fc1c944f1dd2a6ddd2059e334122445863f1 | 5d6e432783619902d1aa76e46e9596e2019f6c35 | /MainGame/EventHandler.h | 61ce6a4d939eec2eb19748415f0e0fe184f43e2a | [] | no_license | abolshakov/Superposition | 55c322e1e13d100547bcf6647f87e386f94e146b | 687abf4e7a2ceb42518b7a5c63d633766353df9c | refs/heads/master | 2021-01-12T01:09:00.893742 | 2019-11-16T15:20:34 | 2019-11-16T15:20:34 | 78,336,283 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 192 | h | EventHandler.h | #pragma once
#ifndef EVENTHANDLER_H
#define EVENTHANDLER_H
class EventHandler
{
public:
EventHandler();
~EventHandler();
void onMouseDownInteract();
void onKeyDownInteract();
};
#endif
|
e165640d5afce572ed6571f383a46634b4961dad | 64c12e201a135255b7e251a4649c64c62e626977 | /009 - Last Digit of the Sum of Squares of Fibonacci Numbers.cpp | 18f8b5b705f4dfe275e9360d818ad6658049f6be | [] | no_license | TarekAlabd/data_structure_algorithm_california_specialization_coursera | eb78e51c240b0e8992bf3db0e4bd5d59849f3ab1 | dca62c57436f2fb46402f7e5f749267b5aa97490 | refs/heads/master | 2020-12-15T15:06:30.164266 | 2020-03-02T11:45:32 | 2020-03-02T11:45:32 | 235,150,934 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 992 | cpp | 009 - Last Digit of the Sum of Squares of Fibonacci Numbers.cpp | #include <iostream>
int fibonacci_sum_squares_naive(long long n) {
if (n <= 1)
return n;
long long previous = 0;
long long current = 1;
long long sum = 1;
for (long long i = 0; i < n - 1; ++i) {
long long tmp_previous = previous%10;
previous = current;
current = tmp_previous + current%10;
sum += current * current;
}
return sum % 10;
}
long long get_fibonacci_fast(long long n) {
if (n <= 1)
return n;
long long f1=0, f2=1, f_sum = 0;
for (long i=2; i<=n; i++) {
f_sum = f1 + f2;
f1 = f2;
f2 = f_sum;
}
return f_sum;
}
int fibonacci_sum_square_fast(long long n) {
if (n <= 1)
return n;
long long current = get_fibonacci_fast(n % 60);
long long next = get_fibonacci_fast((n+1) % 60);
return ((current % 10) * (next % 10) % 10);
}
int main() {
long long n = 0;
std::cin >> n;
std::cout << fibonacci_sum_square_fast(n);
}
|
2d619ad5d514592233b044fd7ffee78f8e8a238f | 600df3590cce1fe49b9a96e9ca5b5242884a2a70 | /third_party/skia/src/animator/SkDrawShader.h | f7ef29d7d350c1d6f023d4a065db77343129e38b | [
"BSD-3-Clause",
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"MIT",
"Apache-2.0"
] | 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 | 614 | h | SkDrawShader.h | /*
* Copyright 2006 The Android Open Source Project
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkDrawShader_DEFINED
#define SkDrawShader_DEFINED
#include "SkPaintPart.h"
#include "SkShader.h"
class SkBaseBitmap;
class SkDrawBitmapShader : public SkDrawShader {
DECLARE_DRAW_MEMBER_INFO(BitmapShader);
SkDrawBitmapShader();
bool add() override;
SkShader* getShader() override;
protected:
SkBool filterBitmap;
SkBaseBitmap* image;
private:
typedef SkDrawShader INHERITED;
};
#endif // SkDrawShader_DEFINED
|
a8099dcfe9fa2a1b29bd61175579d42139ac7408 | 09eaf2b22ad39d284eea42bad4756a39b34da8a2 | /provas/xor-e-filhos/ime/imampamento2015/s01/e02/P7/g.cpp | 372703c99f824773360e908dfda081dec7b5768e | [] | no_license | victorsenam/treinos | 186b70c44b7e06c7c07a86cb6849636210c9fc61 | 72a920ce803a738e25b6fc87efa32b20415de5f5 | refs/heads/master | 2021-01-24T05:58:48.713217 | 2018-10-14T13:51:29 | 2018-10-14T13:51:29 | 41,270,007 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,121 | cpp | g.cpp | #include<bits/stdc++.h>
#define MV 101
#define ME 10002
using namespace std;
typedef int num;
typedef int node;
typedef int edge;
num head[MV], val[MV], label[MV], n, m;
num to[ME], next[ME], es;
node final;
num dfs(node s)
{
label[s] = 1;
final = s; node toVisit;
if( head[s] == -1 )
return val[s];
else
toVisit = head[s];
for(edge e = head[s]; e>=0 ; e = next[e])
if( label[to[e]] == 0 && val[to[e]] > val[toVisit] )
toVisit = to[e];
if( label[toVisit] == 1 )
return val[s];
return val[s] + dfs(toVisit);
}
int main()
{
int tc;
scanf("%d", &tc);
for( int tcn=1; tcn < tc+1; tcn++ )
{
scanf("%d %d", &n, &m);
es = 0;
for( int i = 0; i < n; i++ )
{
scanf("%d", val+i);
head[i] = -1;
label[i] = 0;
}
for( int i = 0; i < m; i++ )
{
node u,v; scanf("%d %d", &u, &v);
to[es] = v; next[es] = head[u]; head[u] = es++;
}
num ans = dfs(0);
printf("Case %d: %d %d\n", tcn, ans, final);
}
}
|
6a60f78c1bf06ba6def90a46c6625f285110785c | e076f3c78a45beba07bce8568f42f891c8352562 | /cs-4-exercise/week02 - Structures/solutions/Library.cpp | e97e2bb338b595b92050195461e99bbec085643d | [] | no_license | snikolova27/oop-2020-21 | bc6858114c69d72178aa3e68d9b85b063f65aea0 | fd6b091d62fca315c6c92b7c99842f4dc74c40e8 | refs/heads/main | 2023-03-19T14:16:55.926741 | 2021-03-11T17:40:29 | 2021-03-11T17:40:29 | 347,015,555 | 1 | 0 | null | 2021-03-12T09:45:17 | 2021-03-12T09:45:17 | null | UTF-8 | C++ | false | false | 1,024 | cpp | Library.cpp | #include "Library.h"
#include <iostream>
void Library::create(size_t capacity) {
this->capacity = capacity;
this->size = 0;
this->books = new Book[this->capacity];
}
void Library::resize() {
this->capacity *= 2;
Book* old = this->books;
this->books = new Book[this->capacity];
for (size_t i = 0; i < this->size; i++) {
this->books[i] = old[i];
}
delete[] old;
}
void Library::addBook() {
Book book;
book.initiate();
if (this->size == this->capacity) {
resize();
}
this->books[this->size++] = book;
}
void Library::printBooks() {
std::cout << "Print Books:\n";
for (int i = 0; i < this->size; i++) {
this->books[i].print();
}
}
void Library::freeMemory() {
delete[] this->books;
}
Book& Library::getBestBook() {
int maxSales = this->books[0].sales;
int pos = 0;
for (int i = 1; i < this->size; i++) {
if (maxSales < this->books[i].sales) {
maxSales = this->books[i].sales;
pos = i;
}
}
return this->books[pos];
}
|
c539c5495dda29640ff31552300b97ffbfc750a1 | 21c4f754f45e3d2bc588bcacb0a5e5b6ca522a66 | /examples/PieChart.cxx | 47ceac1e49a8d55a25f533e202db51efd519ee89 | [] | no_license | progray/GDICanvas | 867c4017399b6691d0f34761f7c5069b99399136 | ddbefc9405b4e3af185c7fec67a439926d6d5fe0 | refs/heads/master | 2023-03-19T11:29:11.477468 | 2015-11-27T17:50:15 | 2015-11-27T17:50:15 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 993 | cxx | PieChart.cxx | #include "Canvas.h"
GC::Canvas canv(700, 700, "Pie Chart Demo");
std::map<int, int> calcDegrees(const std::vector<int> &values) {
std::map<int, int> frequency;
for (int val : values) {
frequency[val] += 1;
}
return frequency;
}
int main() {
canv.init();
std::vector<int> values = {12, 13 , 12 , 3453 , 34534, 53, 4,
34 , 45 , 76, 544, 12, 121, 13, 13, 45
};
std::map<int, int> freqs = calcDegrees(values);
int nValues = values.size();
GS::Box box = {100L, 100L, 600L, 600L};
int angle = 0;
int red = 10,
green = 40,
blue = 50;
for (auto freqStruct : freqs) {
float occurrences = freqStruct.second;
int degree = (occurrences / nValues) * 360.0;
int arcID = canv.arc(box, GS::PIE, degree, angle);
angle += degree;
canv.fillColor(arcID, red, green, blue);
green = (green + 20) % 360;
red = (red + 50) % 360;
blue = (blue + 20) % 360;
}
return canv.loop();
}
|
0e06922e3e8f2b745c777f2984bcfe1c3e47e827 | cc864efaaf645faddff55bdc5cbc59b8ef42c22c | /ChEngine/Physics/Collision/CollisionDetection.cpp | d7b2c23bc13a7453e3e7faf21e61ec0dc89315b3 | [] | no_license | Chunze/ChEngine | 67881a90f580170d0abfd9622bbd411435b84446 | 055615e3ebee60b074ecc018eae9638e059dc460 | refs/heads/master | 2021-10-24T05:10:20.070251 | 2019-03-22T07:56:46 | 2019-03-22T07:56:46 | 117,058,704 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,523 | cpp | CollisionDetection.cpp | #include "CollisionDetection.h"
#include "CollisionTestUtils.h"
#include "PhysicsManager.h"
#include <iostream>
float CollisionDetection::m_CoherencePenetrationLimit = 0.1f;
CollisionDetection::CollisionDetection(PhysicsManager* PhysicsManager)
: m_PhysicsManager(PhysicsManager),
m_BroadPhaseTest(this),
m_NarrowPhaseTest(this)
{
}
void CollisionDetection::RunCollisionDetection(CollisionInfo *Data)
{
m_BroadPhaseTest.RunTest();
m_NarrowPhaseTest.RunTest(Data);
GenerateCoherenceContact(Data);
}
void CollisionDetection::RegisterCollisionPrimitive(CollisionPrimitive_sp PrimitiveToAdd)
{
if (!PrimitiveToAdd->GetBody())
{
for (auto primitive : m_PrimitiveWithoutBody)
{
if (primitive == PrimitiveToAdd)
{
return;
}
}
m_PrimitiveWithoutBody.push_back(PrimitiveToAdd);
}
}
void CollisionDetection::GenerateCoherenceContact(CollisionInfo *Data)
{
if(Data->m_ContactFeatureList.m_ContactFeatures.size() > 0)
std::cout << "Contact Feature size: " << Data->m_ContactFeatureList.m_ContactFeatures.size() << '\n';
for (ContactFeature &Feature : Data->m_ContactFeatureList.m_ContactFeatures)
{
if (Feature.IsValid())
{
// This feature was not added this frame, generate a contact from it
BoxPrimitive* Box1 = static_cast<BoxPrimitive*>(Feature.m_Primitives[0]);
BoxPrimitive* Box2 = static_cast<BoxPrimitive*>(Feature.m_Primitives[1]);
BodyContact Contact;
float Penetration;
vec3 Axis = Box1->GetAxis(Feature.m_FeatureID[0]);
if (Feature.m_FeatureType == ContactFeatureType::FACE_VS_VERTEX)
{
Penetration = CollisionTestUtils::BoxPenetrationOnAxis(Box1, Box2, Axis);
if (Penetration < -m_CoherencePenetrationLimit)
{
continue;
}
Contact.m_Penetration = Penetration;
CollisionTestUtils::GetContactInfoFaceVsVertex(Box1, Box2, Axis, Contact);
Data->AddContact(Contact, false);
}
else if (Feature.m_FeatureType == ContactFeatureType::EDGE_VS_EDGE)
{
vec3 Axis = glm::cross(Box1->GetAxis(Feature.m_FeatureID[0]), Box2->GetAxis(Feature.m_FeatureID[1]));
Penetration = CollisionTestUtils::BoxPenetrationOnAxis(Box1, Box2, Axis);
if (Penetration < -m_CoherencePenetrationLimit)
{
continue;
}
Contact.m_Penetration = Penetration;
CollisionTestUtils::GetContactInfoEdgeVsEdge(Box1, Box2,
Feature.m_FeatureID[0],
Feature.m_FeatureID[1],
Contact);
Data->AddContact(Contact, false);
}
}
Feature.m_FramesLived++;
}
Data->CleanupFeatureList();
}
|
b38c773e74b7cb1af16e4264852ec95fa491514c | 7ea618b70e81a9478e896949ab99995b089fe8de | /libsrc/blitz/ut/state_machine_ut.cc | 3b5df79e7ebd8042194d801447c3a305f6a84f92 | [] | no_license | rickyu/mlsimgsearch | bab0cc11901ac3adf652a7f4daeaa01721b6b9e5 | 7fa89f058333af65c27e58d952a7ebbcbd94b46f | refs/heads/master | 2020-03-22T21:01:41.687118 | 2018-07-12T02:48:09 | 2018-07-12T02:48:09 | 140,650,471 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,791 | cc | state_machine_ut.cc | // Copyright 2012 meilishuo Inc.
// Author: 余佐
#include <string>
#include "gtest/gtest.h"
#include "blitz/state_machine.h"
template <typename T>
struct StateMachineCallbackParam {
T* machine;
int32_t context_id;
};
class TestStateMachine {
public:
class TInput {
public:
int a;
};
class TOutput {
public:
int b;
};
class TData;
typedef blitz::StateMachine<TInput, TData, TOutput> MyStateMachine;
class TData {
public:
void SetInput(const TInput& input) {
a = input.a;
}
void GetOutput(TOutput* output) {
output->b = b;
}
int State0Action(int context_id, MyStateMachine* ) {
a = 0;
b = a + context_id;
return 1;
}
int State1Action(int context_id, MyStateMachine* ) {
a += 5;
b = a + context_id;
return 2;
}
int State0OnEvent1(blitz::Event* event, int /* context_id */,
MyStateMachine* ) {
if (event->type != 1) { return -1; }
}
int a;
int b;
};
TestStateMachine():state_machine_("test") {
}
int Init() {
MyStateMachine::State states[] = {
{1, &TData::State0Action},
{2, &TData::State1Action},
{3, NULL}
};
return state_machine_.Init(states, 3, NULL, 0, 1, 3);
}
MyStateMachine& GetStateMachine() { return state_machine_; }
MyStateMachine state_machine_;
};
TEST(StateMachine, Init) {
TestStateMachine state_machine;
int ret = state_machine.Init();
EXPECT_EQ(ret, 0);
EXPECT_EQ(state_machine.GetStateMachine().GetStateCount(), 3);
}
TEST(StateMachine, StartOneContext) {
TestStateMachine state_machine;
int ret = state_machine.Init();
EXPECT_EQ(ret, 0);
TestStateMachine::TInput input;
input.a = 10;
// state_machine.GetStateMachine().StartOneContext(input, NULL, NULL);
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.