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
317ef60dda790568307d55f2c856a5336e928369
e3cee45fbe869a5239de195027bce663aca55020
/w3/G2/1.cpp
e5ede2a301152a52e5d972ebe8af593b8a4fba5b
[]
no_license
bobur554396/PPI2020FALL
dd354724c9b530652d81436791d8e2526a5fb478
8e55ec56a899ceb94ca9d9cc247f67c189110bf3
refs/heads/master
2023-01-20T04:58:30.129991
2020-12-05T09:23:01
2020-12-05T09:23:01
294,113,060
0
0
null
null
null
null
UTF-8
C++
false
false
354
cpp
1.cpp
#include <iostream> using namespace std; int main(){ // - [ ] loop operators: for, while, do while /* for(initialize iterator; condition; inc/dec iterator) { expression / instructions; } */ cout << "loop started\n"; for(int i = 0; i < 10; i = i + 1){ cout << i << " "; } cout << "\nloop ended"; return 0; }
1cd7177f29a12ae715e59b85aae5ad24f6739bf4
2c6a29560e7012032fbb81ab717fa04f2905caaf
/proyecto/compiler/src/codegen.h
96da979f96b33a5873f02b576552fa1254693c3e
[]
no_license
Erick-ECE/ArquitecturaDeComputadoras
aeac77745d0bba7fe5b617101fb81e109329a1af
de2de9d473a14f0ccc1b80a64aca8fc2da749381
refs/heads/master
2020-03-22T04:04:37.890519
2018-07-02T17:15:13
2018-07-02T17:15:13
139,471,443
0
0
null
null
null
null
UTF-8
C++
false
false
1,103
h
codegen.h
#ifndef CODEGEN_H #define CODEGEN_H #include "procentry.h" #include "strentry.h" #include "instr.h" #include <deque> using std::deque; #include <fstream> using std::ofstream; using std::ios; #include <iostream> using std::cerr; using std::endl; class AsmCodeGen { public: AsmCodeGen(deque<Instr>& code, deque<int>& deferred, deque<char*>& deferredid, deque<ProcEntry>& proc, deque<StrEntry>& strings, int codeSize); void compile(const char* filename); bool cgenErrors() const; deque<StrEntry> strings; bool codeGenErrors() const; private: deque<Instr> code; deque<int> deferred; deque<char*> deferredid; deque<ProcEntry> proc; char *strSection; char *codeSection; int strSectionSize; int codeSectionSize; int mainAddr; bool errors; Instr current; void calculateProcAddresses(); void nextInstr(); int lookup(char *id); void write(ostream& out); void cgenErr(const char *msg, bool showLine); void buildDataSection(); void buildCodeSection(); void writeCode(const char* filename); bool findMain(); }; #endif
de16ba1d1e48041f37843564167d7fca578c0743
f0ec6e201a1399704656829293b5284c7f655cff
/abc131/e.cpp
5e8a73f66d8a8b56218963f033f2cb92c9e5177a
[]
no_license
kenta-s/atcoder
b7134787618eeacda99ded8f8eb3c18a77e57bad
d88bf1196d3fa1024384369609c4bf9ec3b3bca0
refs/heads/master
2021-06-21T19:16:31.289686
2021-01-23T04:46:31
2021-01-23T04:46:31
172,304,475
0
0
null
null
null
null
UTF-8
C++
false
false
448
cpp
e.cpp
#include <iostream> #include <vector> using namespace std; int main(){ int N, K; int ans; vector<vector<int>> b; cin >> N >> K; int MAX = ((N-2) * (N-1))/2; if(K>MAX){ cout << "-1" << endl; return 0; } int bridges = N-1; bridges += MAX-K-1; cout << bridges << endl; for(int i=0; i<N-1; i++){ cout << 1 << ' ' << i+2 << endl; } for(int i=0; i<bridges-(N-1); i++){ cout << i+2 << ' ' << i+3 << endl; } }
6402b564382fac27530ce6e2d8ea43da2dab6d2a
d9c17dedd03c5c52db536a9dc7890339cf927472
/EXE8/ofstream.cpp
dc568046b7c3d22db47a9335830aaecfaa7418b1
[]
no_license
qiuliwang/hello-world
349c401cea8324afeae7af1dd6c73dc5f8af5472
807223972a80267b8ce1c6b41f2b9d386b32000f
refs/heads/master
2021-07-09T05:56:59.144041
2017-10-09T01:39:49
2017-10-09T01:39:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
277
cpp
ofstream.cpp
#include <iostream> #include <fstream> using namespace std; int main() { ofstream outfile("test2.txt"); outfile << "this is test2\nand hello again"; //return 0; outfile.close(); fstream file("test2.txt", ofstream::out | ofstream::app); file << "append"; file.close(); }
644051cab1905b2b25dc06dc27c19e6357280e00
52e7857bc79dc810fb5a8718d988af58f8254a9a
/depth2color.cpp
638aad56a9be895b6c60deb7621a9a05ce4608b4
[]
no_license
wf-hahaha/depth2color
e5a1302c3fafa7c8079ec1c24e5fed02e4d92fb5
846bb2b995167ebc5735bee5459b899cc31553e3
refs/heads/master
2022-01-04T23:28:57.482744
2018-05-08T11:55:58
2018-05-08T11:55:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,314
cpp
depth2color.cpp
#include <iostream> #include <string> #include <sstream> #include <opencv2/opencv.hpp> using namespace std; void depth2color(cv::Mat & color, const cv::Mat & depth, const double max, const double min) { cv::Mat grayImage; double alpha = 255.0 / (max - min); depth.convertTo(grayImage, CV_8UC1, alpha, -alpha * min);// expand your range to 0..255. Similar to histEq(); cv::applyColorMap(grayImage, color, cv::COLORMAP_JET);// this is great. It converts your grayscale image into a tone-mapped one, much more pleasing for the eye function is found in contrib module, so include contrib.hpp and link accordingly } void getDepthMinMax(const cv::Mat & depthTmp, double &imax, double &imin) { int imrow = depthTmp.rows; int imcol = depthTmp.cols * depthTmp.channels(); for (int i = 0; i < imrow; i++) { for (int j = 0; j < imcol; j++) { ushort data = depthTmp.at<ushort>(i, j); if (imin >= data && data != 0) { imin = data; } if (imax <= data) { imax = data; } } } } int main() { int count = 182; double imax = 0, imin = 70000; cv::Mat colorimg; char colorname[100], rgbname[100], depthname[100]; string in_imgpath = "geely/05/"; string out_imgpath = "geelypart/"; for (int i = 0; i <= 142; ++i) { ostringstream ss; ss << i; cv::Mat depthimg = cv::imread(in_imgpath + "depth/depth"+ss.str()+".png", cv::IMREAD_UNCHANGED); cv::Mat rgbimg = cv::imread(in_imgpath + "rgb/rgb"+ss.str()+".png", cv::IMREAD_UNCHANGED); if (depthimg.empty() || rgbimg.empty()) { cout << "read img failed\n"; system("pause"); return -1; } sprintf_s(colorname, sizeof(colorname), (out_imgpath + "color/color%03d.png").c_str(), count); sprintf_s(rgbname, sizeof(rgbname), (out_imgpath + "rgb/rgb%03d.png").c_str(), count); sprintf_s(depthname, sizeof(depthname), (out_imgpath + "depth/depth%03d.png").c_str(), count++); getDepthMinMax(depthimg, imax, imin); depth2color(colorimg, depthimg, imax, imin); //cv::imshow("depth2color", colorimg); cv::imwrite(colorname, colorimg); cv::imwrite(rgbname, rgbimg); cv::imwrite(depthname, depthimg); } //cv::waitKey(0); cout << "depth2color finished!\n"; cout << "the image count is " << count << endl; system("pause"); return 0; }
58616899e6471737ea74e6f13cddceae8f0a735f
bc5f13db933cb00d8e6d24769a7990d52e65ca2f
/src/input.h
a07e0fd0d02624dd1d98e74c2f0c5c72f60a31a6
[]
no_license
chrismacdermaid/LJMD-LAMMPS
3c866933735d31c07a7b2b60b2018de646e19351
b6ad40aa34183f02cfcd2bf989b69514e397a99a
refs/heads/master
2021-01-18T15:16:43.439629
2011-02-04T17:22:32
2011-02-04T17:22:32
2,943,490
7
0
null
null
null
null
UTF-8
C++
false
false
1,214
h
input.h
/* *********************************************************** * JLMD++ A C++ version of LJMD motived by LAMMPS. * * http://sites.google.com/site/akohlmey/software/ljmd * and http://lammps.sandia.gov/ * * Some routines are taken in whole or in part from LJMD * or LAMMPS. This software is distributed under the * GNU General Public License. * * Written by Chris MacDermaid; chris.macdermaid@gmail.com * * Basic goal: Write LJMD in CPP, but designed like LAMMPS * to illustrate the LAMMPS implementation without all the * other stuff. * * This code is intended for educational use only * and should not be used in a production type environment. * Results should not be trusted. You've been warned. ********************************************************** */ /* Parses input file and reads restarts */ #ifndef LJMD_INPUT_H #define LJMD_INPUT_H #include "stdio.h" #include "pointers.h" namespace LJMD_NS { class Input : protected Pointers { public: char *restfile; // Restart filename // Constructor & Destructor Input(class LJMD *); ~Input(); void read_restart(); // Read the restart file private: FILE *fp; // File Pointer }; } #endif
40fa558997c90840c398039a5d6049005d2e6263
579512224c0bcd397467e23e2e4fa8c51b732e26
/src/tf_camera.cpp
f6d3a416c99495de103f0ea44e18112ef82feec1
[]
no_license
hubertkarbowy/whackamole
d6a34cc292ddda1417c4aa090550bf809681ba3e
31c79477915ba6d6965b2bcf8a18b16964368f67
refs/heads/master
2023-02-25T07:25:19.302548
2021-02-01T22:52:24
2021-02-01T22:52:24
324,822,728
0
0
null
2021-02-01T22:52:25
2020-12-27T18:22:30
C++
UTF-8
C++
false
false
1,682
cpp
tf_camera.cpp
#include <tf_camera.hpp> #include <whackrealtime.hpp> #include <helpers.hpp> /** Fake camera thread * * Captures a camera image in regular intervals, detects the LEDs pattern, saves the * pattern in an ugly global variable @OBSERVED_BOARD_STATE and notifies other threads after * completing these actions. */ void run_camera() { int num_states = 1; for (int i=0; i<NUM_HOLES; i++) num_states *= 3; while (supporting_threads_active) { #ifdef COMPILE_FOR_PC // _D << "Camera scanning for new states...\n"; sleep_for_noarch(CAMERA_SCAN_INTERVAL); if (TRUE_BOARD_STATE > num_states) continue; // undefined camera state, e.g. 9999 // _D << "Camera + TF ready \n"; // set observed board state global variable here just before calling notify //if (OBSERVED_BOARD_STATE != TRUE_BOARD_STATE) { OBSERVED_BOARD_STATE = TRUE_BOARD_STATE; // cheating just for simulation notify_single_thread_noarch(CAMERA_THREAD); // } #else #ifdef COMPILE_FOR_DUINO // _D << "Camera scanning for new states...\n"; sleep_for_noarch(CAMERA_SCAN_INTERVAL); if (TRUE_BOARD_STATE > num_states) continue; // undefined camera state, e.g. 9999 // _D << "Camera + TF ready \n"; // set observed board state global variable here just before calling notify //if (OBSERVED_BOARD_STATE != TRUE_BOARD_STATE) { OBSERVED_BOARD_STATE = TRUE_BOARD_STATE; // on Arduino we would set OBSERVED_BOARD_STATE to the output of TensorFlow's model notify_single_thread_noarch(CAMERA_THREAD); // } #endif #endif } _D << "Exiting camera thread\n"; }
1beb6d3bb9ba30ca8b02270caf7ae6eed2f54bf4
44346fab250714f05cd2a30a3f47cbb9543f41a6
/hdu/树形dp hdu 4003.cxx
79e0249b9f5efa6b15975baa07da336220c01589
[]
no_license
vapour18/acm_code
b925258c04d81da4d1e7be9c4a268a1268b645f6
46d6dc3c6fcf11a2703744d05443ce50b9fa5e75
refs/heads/master
2020-12-24T13:28:32.633089
2013-05-08T10:15:36
2013-05-08T10:15:36
7,303,255
1
0
null
null
null
null
UTF-8
C++
false
false
1,540
cxx
树形dp hdu 4003.cxx
//题意:给一棵有根树,每条边与有边权.在根上放k个机器人,问遍历这棵树的最小边权和是多少 //贪心的方法想了很多都不行,只能是树形dp //dp[i][j]表示以i为根的子树有j个机器人遍历的最小代价,dp[i][0]表示这棵子树只有一个机器人经过并且会回去 //然后按分组背包的形式去做,dp[i][j] = min(dp[i][j],dp[i][j-k]+dp[v][k]+w*2),其中v为i的儿子 //初始化的条件为dp[i][j] = dp[v][0] + 2*w,这样就可以保证树被遍历 #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> using namespace std; const int maxn = 10005; struct Edge{ int v,next,w; }edge[maxn*3]; int head[maxn],en,n,s,m; int dp[maxn][15]; void addedge(int u,int v,int w) { edge[en].v = v,edge[en].w = w; edge[en].next = head[u]; head[u] = en++; swap(u,v); edge[en].v = v,edge[en].w = w; edge[en].next = head[u]; head[u] = en++; } void init() { en = 0; memset(head, -1 ,sizeof(head)); memset(dp,0,sizeof(dp)); } void dfs(int u,int pre) { for(int i = head[u]; i != -1; i = edge[i].next) { int v = edge[i].v; if(v == pre) continue; dfs(v,u); for(int k = m; k >=0; k--)//分组背包 { dp[u][k] += dp[v][0] + 2*edge[i].w; for(int j= 1; j <= k;j++) dp[u][k] = min(dp[u][k],dp[u][k-j]+dp[v][j]+j*edge[i].w); } } } int main() { int u,v,w; while(scanf("%d%d%d",&n,&s,&m)!=EOF) { init(); for(int i = 1; i < n; i++) { scanf("%d%d%d",&u,&v,&w); addedge(u,v,w); } dfs(s,-1); printf("%d\n",dp[s][m]); } return 0; }
cfeca17b175174c105f57c5efa72d7a74a256c78
4bfcee530252964efb193cc3f3ca08d91b80524a
/OI/VIII/mro.cpp
1474d946fff4983027754181138f149a1b4a0603
[]
no_license
Neverous/individual
63e1bcd12e54f4871d06036f3af31da2e56c40bc
bc16b259d16b09526ed39217eca4a3122d3e0466
refs/heads/master
2021-05-04T10:17:43.557190
2016-09-07T19:09:08
2016-09-07T19:09:08
54,484,436
0
0
null
null
null
null
UTF-8
C++
false
false
2,798
cpp
mro.cpp
/* 2010 * Maciej Szeptuch * XIV LO Wrocław */ #include<cstdio> #include<vector> #include<queue> #include<cstring> //#define DEBUG(args...) fprintf(stderr, args) #define DEBUG(args...) int verts, start, end, ants, ladybug, landplace, antToVert[1010], vertToAnt[5050], direction[5050], score[1010]; bool moved[1010], state[5050]; std::vector<int> tree[5050]; std::queue<int> que; inline static void simulate(int landing); inline static void directTree(int root); inline static void moveAnts(void); inline static void floodAgainst(void); inline static void floodAgainst(int root); int main(void) { scanf("%d", &verts); for(int e = 1; e < verts; ++ e) { scanf("%d %d", &start, &end); -- start; -- end; tree[start].push_back(end); tree[end].push_back(start); vertToAnt[start] = vertToAnt[end] = -1; } scanf("%d", &ants); for(int a = 0; a < ants; ++ a) { scanf("%d", &antToVert[a]); -- antToVert[a]; state[antToVert[a]] = true; vertToAnt[antToVert[a]] = a; score[a] = 0; } scanf("%d", &ladybug); for(int l = 0; l < ladybug; ++ l) { scanf("%d", &landplace); -- landplace; simulate(landplace); } for(int a = 0; a < ants; ++ a) printf("%d %d\n", antToVert[a] + 1, score[a]); return 0; } inline static void simulate(int landing) { for(int v = 0; v < verts; ++ v) if(vertToAnt[v] == -1) state[v] = false; directTree(landing); while(state[landing] != true) { moveAnts(); floodAgainst(); } ++ score[vertToAnt[landing]]; } inline static void directTree(int root) { memset(moved, 0, sizeof(bool) * 1010); int act; que.push(root); direction[root] = -1; while(!que.empty()) { act = que.front(); que.pop(); if(state[act] == true) { moved[vertToAnt[act]] = true; continue; } for(unsigned int n = 0; n < tree[act].size(); ++ n) { if(tree[act][n] == direction[act]) continue; direction[tree[act][n]] = act; que.push(tree[act][n]); } } } inline static void moveAnts(void) { for(int a = 0; a < ants; ++ a) { if(!moved[a]) continue; if(state[direction[antToVert[a]]] != false) { moved[a] = false; continue; } state[direction[antToVert[a]]] = true; vertToAnt[direction[antToVert[a]]] = a; vertToAnt[antToVert[a]] = -1; antToVert[a] = direction[antToVert[a]]; } } inline static void floodAgainst(void) { for(int a = 0; a < ants; ++ a) { if(!moved[a]) continue; floodAgainst(antToVert[a]); } } inline static void floodAgainst(int root) { int act; que.push(root); while(!que.empty()) { act = que.front(); que.pop(); for(unsigned int n = 0; n < tree[act].size(); ++ n) { if(tree[act][n] == direction[act]) continue; if(state[tree[act][n]] == false) { que.push(tree[act][n]); state[tree[act][n]] = true; } } } }
3510b4a123b2d15b0a512f5598209f1286b41752
e83e18bfb42e0feab5146233e6df04a58e2841a7
/ui/ontology/treeview/OntologyTreeViewController.h
354df658cf4bd331c1158b3e96c256219a10d201
[]
no_license
bobrnor/OntoEditor
492ddf12de19c5c8e67cdf882f202a2bbcdad641
7c0ac34be6f4332c06644c3a433a9f5fdd44ea42
refs/heads/master
2020-06-07T10:17:25.726717
2013-06-30T21:41:22
2013-06-30T21:41:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,260
h
OntologyTreeViewController.h
#ifndef ONTOLOGYTREEVIEWCONTROLLER_H #define ONTOLOGYTREEVIEWCONTROLLER_H #include <QtGui> #include "../../../core/OntologyDataController.h" struct TVNodeData { NodeData *nodeData; QMap<QString, QList<TVNodeData> > *childNodes; }; class OntologyTreeViewController : public QObject { Q_OBJECT private: QTreeView *m_objectsTreeView; QStandardItemModel *m_objectsModel; OntologyDataController *m_dataController; QMap<long, TVNodeData> m_treeData; bool m_dragEnabled; void updateTreeDataBottomToTop(); void updateTreeDataTopToBottom(); void buildNodesTree(QStandardItem *rootItem, QList<TVNodeData> nodes, QSet<long> *seenNodeIds); void clearTreeView(); public: OntologyTreeViewController(); ~OntologyTreeViewController(); QTreeView *treeView() const; void setDataController(OntologyDataController *dataController); OntologyDataController *dataController() const; void setDragEnabled(bool enabled); bool isDragEnabled() const; void updateData(); signals: void dataChangedSignal(); void itemSelectedSignal(long id); public slots: void dataChangedSlot(); void itemSelectedSlot(const QModelIndex &index); }; #endif // ONTOLOGYTREEVIEWCONTROLLER_H
0cc496fed1922e0318d63d8d13c58c7e88298be1
bc997f47b4cffef395f0ce85d72f113ceb1466e6
/POI/ONTAK/ontak16_bar.cpp
f8b3e31b2cb3a488bbb2b922f1a1f12aa2368672
[ "LicenseRef-scancode-public-domain" ]
permissive
koosaga/olympiad
1f069dd480004c9df033b73d87004b765d77d622
fcb87b58dc8b5715b3ae2fac788bd1b7cac9bffe
refs/heads/master
2023-09-01T07:37:45.168803
2023-08-31T14:18:03
2023-08-31T14:18:03
45,691,895
246
49
null
2020-10-20T16:52:45
2015-11-06T16:01:57
C++
UTF-8
C++
false
false
575
cpp
ontak16_bar.cpp
#include <bits/stdc++.h> using namespace std; typedef long long lint; typedef long double llf; typedef pair<int, int> pi; int n, a[1000005]; char str[1000005]; int main(){ scanf("%d",&n); for(int i=1; i<=n; i++) scanf("%d",&a[i]); scanf("%s", str); priority_queue<pi, vector<pi>, greater<pi> > pq; int p = 0, b = 0, f = 0; for(int i=1; i<=n; i++){ if(i + f <= n) pq.push(pi(a[i + f], i + f)); while(i + b < pq.top().first){ if(str[p] == 'B') b++; else{ f++; if(i + f <= n) pq.push(pi(a[i + f], i + f)); } p++; } pq.pop(); } cout << p; }
6d2d959e81d902acf7b3c1c8c48c9c0f006e1b85
888c6e3645b9852502b6dbf59bf8cfcdff1253ae
/A2.cpp
33e8358355411173ffbe73b404926fe8a941d424
[]
no_license
ptd910/baitapltnctuan10
eb2d254132d6747f98ccd83ff70dc388e34dc4ce
6708a49d4d4fd904dc51c87f150ab5945185adee
refs/heads/main
2023-04-25T01:57:01.580288
2021-05-21T04:37:50
2021-05-21T04:37:50
369,414,374
0
0
null
null
null
null
UTF-8
C++
false
false
262
cpp
A2.cpp
#include<iostream> using namespace std; struct point { double x,y; }; void thamtri(point a) { cout<<&a; } void thamchieu(point &a) { cout<<&a; } int main() { point a; cout<<&a<<endl; thamtri(a);cout<<"\n"; thamchieu(a); return 0; }
cb2d16c8ab79bc79ac83b5d3eb601786b8ac9aea
788f85c38005a4c006417cd3e53e4780eaa80fb8
/snegoviki/Texture.h
7e10ee31d654df5589a55b0a961e2d019333f19f
[]
no_license
skautman21/Snegoviki
7ac1216820c5d9a68940daa6b34cb4424ba4cd00
6f0969886e45b0d2135ce859c9aea102bead73ba
refs/heads/master
2023-03-29T01:56:24.759157
2021-03-31T06:21:54
2021-03-31T06:21:54
352,985,528
1
0
null
null
null
null
WINDOWS-1251
C++
false
false
334
h
Texture.h
/* * Texture.h * * Created on: 16 нояб. 2020 г. * Author: unyuu */ #ifndef TEXTURE_H_ #define TEXTURE_H_ #include <GL/gl.h> #include <GL/glu.h> class Texture { protected: GLuint _tex; public: Texture(const char * filename); virtual ~Texture(); void bind(); }; #endif /* TEXTURE_H_ */
ca2994d1db22b57e0ab3da02637a0ea6a3aa47e7
c51b650b4c69417f83e363ef24489aac44d4e871
/include/cpo/core/Parsers.hpp
f402f8276c45b577c6ad1119b84d4f9787adce07
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
yanxicheung/cut
90417fe4276fafa892e81606a8899018d8f8756a
7aee0c03ecbccf1bd2c2c0552bfaaf0a52078c5c
refs/heads/master
2020-03-29T04:35:33.923846
2018-09-19T07:16:30
2018-09-19T07:16:30
149,538,521
1
0
MIT
2018-09-20T02:17:26
2018-09-20T02:17:26
null
UTF-8
C++
false
false
869
hpp
Parsers.hpp
#ifndef PARSERS_Thu_Apr_16_23_57_14_2015_H #define PARSERS_Thu_Apr_16_23_57_14_2015_H #include <cpo/core/OptionsDescription.hpp> #include <cpo/core/Cmdline.hpp> #include <cpo/core/Option.hpp> #include <cui/dci/__Role__.h> CPO_NS_BEGIN struct OptionsDescription; __TRAIT__(ParsedOptions) { __ABSTRACT__(const std::vector<Option>& options() const); __ABSTRACT__(const OptionsDescription& description() const); }; struct CommandLineParser : private Cmdline, ParsedOptions{ CommandLineParser( int argc, const char** argv , const OptionsDescription& desc); const ParsedOptions& run(); private: __OVERRIDE__(const std::vector<Option>& options() const); __OVERRIDE__(const OptionsDescription& description() const); private: std::vector<Option> parsedOptions; const OptionsDescription& desc; }; CPO_NS_END #endif
3adc78d7a313ea1df1295276b2fbc20fc5cad9bf
7a6e2a3492b6e237a70b12d75fd05b7a77472af3
/cplus/begin/for_sum_while.cpp
3bace324ee2cbb72d13fb5d467effadc48208727
[]
no_license
timtingwei/prac
e44b7e4634a931d36ed7e09770447f5dba5f25e6
ae77fa781934226ab1e22d6aba6dba152dd15bfe
refs/heads/master
2020-05-21T17:53:07.144037
2017-10-10T14:55:52
2017-10-10T14:55:52
63,440,125
3
0
null
null
null
null
UTF-8
C++
false
false
369
cpp
for_sum_while.cpp
#include <iostream> int for_sum_while() { int sum = 0; for (int i = 50; i <= 100; ++i) sum += i; std::cout << "Sum of 50 to 100 is:" << sum << std::endl; system("pause"); return 0; } /*int main() { int i = 50, sum = 0; while (i <= 100){ sum += i; ++i; } std::cout << "Sum of 50 to 100 inclusive is" << sum << std::endl; system("pause"); return 0; }*/
8b84c8badddaee1a23b5137f70dd8104be4aea41
960c0ac49a5763e27f178cded2c41a8947fde21e
/Mathlab C++/CMatrix.cpp
a402749e3b5b65a00787f6a12ca3742b0ef8fb04
[]
no_license
Eslammedhat22/Mathlab-C-
4163693938d0629e317934e7791e4065b0ee2b4a
3e397c617d327cdfa5b4938be7eec1d03fe51110
refs/heads/master
2020-04-30T08:31:16.643813
2019-03-20T11:28:43
2019-03-20T11:28:43
176,716,659
0
0
null
null
null
null
UTF-8
C++
false
false
30,429
cpp
CMatrix.cpp
/////////////////////////////////////////////////* Functions Definition */////////////////////////////////////////// #include "CMatrix.h" #include <iostream> #include <exception> #include <string> #include <string.h> #include <stdarg.h> #include <algorithm> #include <cstdio> #include <math.h> ////////////////////////////////////////////////* default Constructor */////////////////////////////////// CMatrix::CMatrix() { nR = 0; nC = 0; values = NULL; } ///////////////////////////////////////////////////* Constructor *///////////////////////////////////////////////// /*CMatrix::CMatrix(int nR, int nC) { if (nR <= 0 || nC <= 0){ throw(" error:you try to define a matrix have a negtive dimensions or zero dimensions "); } else { this->nR = nR; this->nC = nC; values = new double*[nR]; for (int row = 0; row < nR; row++) { values[row] = new double[nC]; for (int col = 0; col < nC; col++) values[row][col] = 0; } } }*/ //////////////////////////////////////////////////* Copy Constructor *////////////////////////////////////////// CMatrix::CMatrix(const CMatrix &m) { nR = 0; nC = 0; values = NULL; copy(m); } //////////////////////////////////////////////////////* Destructor */////////////////////////////////////////// CMatrix::~CMatrix() { reset(); } ////////////////////////////////////////////////////////* Reset *//////////////////////////////////////////// void CMatrix::reset() { if (values) { for (int i = 0; i<nR; i++) delete[] values[i]; delete[] values; } nR = nC = 0; values = NULL; } /////////////////////////////////////* to get an element with given coordinates from a matrix *//////////////////////////////// double CMatrix::getElement(int r, int c) { if (r >= nR || r < 0 || c >= nC || c <0){ throw(" error:you try to access element out of matrix by getElement() function "); } else return values[r][c]; } ////////////////////////////////////* to set an element with given coordinates & value to a matrix */////////////////////////////// void CMatrix::setElement(int r, int c, double v) { if (r >= nR || r < 0 || c >= nC || c <0){ throw(" error:you try to set element out of matrix by setElement() function "); } else values[r][c] = v; } ////////////////////////////////////////////////////////* Copy function *//////////////////////////////////////////// void CMatrix::copy(const CMatrix& m) { reset(); this->nR = m.nR; this->nC = m.nC; if ((nR*nC) == 0) { values = NULL; return; } values = new double*[nR]; for (int iR = 0; iR<nR; iR++) { values[iR] = new double[nC]; for (int iC = 0; iC<nC; iC++) { values[iR][iC] = m.values[iR][iC]; } } } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// CMatrix::CMatrix(int nR, int nC, int initialization, double initializationValue) { this->nR = nR; this->nC = nC; if ((nR*nC) == 0) { values = NULL; return; } values = new double*[nR]; for (int iR = 0; iR<nR; iR++) { values[iR] = new double[nC]; for (int iC = 0; iC<nC; iC++) { switch (initialization) { case MI_ZEROS: values[iR][iC] = 0; break; case MI_ONES: values[iR][iC] = 1; break; case MI_EYE: values[iR][iC] = (iR == iC) ? 1 : 0; break; case MI_RAND: values[iR][iC] = (rand() % 1000000) / 1000000.0; break; case MI_VALUE: values[iR][iC] = initializationValue; break; } } } } //////////////////////////////////////////////////////////////////////// CMatrix::CMatrix(int nR, int nC, double first, ...) { this->nR = nR; this->nC = nC; if ((nR*nC) == 0){ values = NULL; return; } values = new double*[nR]; va_list va; va_start(va, first); for (int iR = 0; iR<nR; iR++) { values[iR] = new double[nC]; for (int iC = 0; iC<nC; iC++) { values[iR][iC] = (iC == 0 && iR == 0) ? first : va_arg(va, double); } } va_end(va); } ///////////////////////////////////////////////////////////////////////// CMatrix::CMatrix(string s) { nR = nC = 0; values = NULL; copy(s); } //////////////////////////////////////////////////////////////////////// CMatrix::CMatrix(double d) { nR = nC = 1; values = new double*[nR]; for (int row = 0; row < nR; row++) { values[row] = new double[nC]; for (int col = 0; col < nC; col++) values[row][col] = d; } } ///////////////////////////////////////////* to get the Minor of an element */////////////////////////////////////// CMatrix CMatrix::getMinor(int r, int c) { if (nR == 1 || nC == 1) throw(" error:Invalid matrix dimension(1x1) in getMinor()function "); if (nR == 0 && nC == 0)throw(" error:undefined matrix(0x0) in getMinor()function "); if ((nR == 1 && nC > 1) || (nR > 1 && nC == 1))throw("error:Can't get a minor to a vector (must be 2D dimension) "); if (r >= nR || r < 0 || c >= nC || c <0){ throw("error:you try to getminor of element out of matrix by getMinor() function "); } else { CMatrix m(nR - 1, nC - 1); for (int iR = 0; iR<m.nR; iR++) for (int iC = 0; iC<m.nC; iC++) { int sR = (iR<r) ? iR : iR + 1; int sC = (iC<c) ? iC : iC + 1; m.values[iR][iC] = values[sR][sC]; } return m; } } /////////////////////////////////////////* to calculate the DETERMINANT of the matrix *//////////////////////////// int CMatrix::checkzero(int r, int c) { int flag=0; if(values[r][c]==0) { for(int x=r+1;x<nR;x++) { if(values[x][c]!=0) { for(int k=0;k<nC;k++) { values[r][k]=values[r][k]+values[x][k]; flag=1; } } if(flag==1){return 1 ; break;} } } else { return 1; } if (flag==0)return 0; } double CMatrix::getDeterminant() { if (nR != nC)throw(" error:Invalid matrix dimension(not square matrix) in getDeterminant() function "); if (nR == 0 && nC == 0)throw(" error:undefined matrix(0x0) in getDeterminant()nfunction "); else { CMatrix m=*this; for(int i=0;i<(m.nR-1);i++) { if(m.values[i][i]==0) { int v=m.checkzero(i,i); if(v==0) return 0; } double k; for(int j=i+1;j<m.nR;j++) { k=(-1*m.values[j][i])/m.values[i][i]; for(int x=0;x<m.nC;x++) { m.values[j][x]=m.values[j][x]+(k*m.values[i][x]); } } } /*for(int i=1;i<m.nR;i++) { for(int j=0;j<i;j++) { double k; if(m.values[j][j]==0) { int v=m.checkzero(j,j); if(v==0) return 0; } k=(-1*m.values[i][j])/m.values[j][j]; for(int x=0;x<m.nC;x++) { m.values[i][x]=m.values[i][x]+(k*m.values[j][x]); } } }*/ double det =1.0; for (int u=0;u<m.nR;u++) { det=det*m.values[u][u]; } return det; } } ////////////////////////////////////////////////* to get the COFACTOR of the matrix *//////////////////////////////////// CMatrix CMatrix::getCofactor() { if (nR != nC)throw(" error:Invalid matrix dimension(not square matrix) in getCofactor() function "); if (nR == 1 && nC == 1)throw(" error:Invalid matrix dimension(1*1) in getCofactor()function "); if (nR == 0 && nC == 0)throw(" error:undefined matrix(0x0) in getCofactor() function "); else { CMatrix m(nR, nC); int k = 1; int v; for (int row = 0; row < nR; row++) { for (int col = 0; col < nC; col++) { if (col == 0) v = k; m.values[row][col] = v *getMinor(row, col).getDeterminant(); v *= -1; } k *= -1; } return m; } } /////////////////////////////////////////////* to get the total number of ELEMENTS inside the matrix */////////////////////////// int CMatrix::getn() { return nR*nC; } ///////////////////////////////////////////* to get the number of ROWS inside the matrix */////////////////////////////////////// int CMatrix::getnR() { return nR; } ////////////////////////////////////////////* to get the number of COLOUMS inside the matrix *//////////////////////////////// int CMatrix::getnC() { return nC; } ////////////////////////////////////////////* to get the TRANSPOSE of the matrix *///////////////////////////////////// CMatrix CMatrix::getTranspose() { if (nR == 0 && nC == 0)throw(" error:undefined matrix(0x0) in getTranspose()function "); else { CMatrix m(nC, nR); for (int i = 0; i<nR; i++) { for (int j = 0; j<nC; j++) { m.values[j][i] = values[i][j]; } } return m; } } /////////////////////////////////////////////////* to get the INVERSE of the matrix *////////////////////////////// CMatrix CMatrix::getInverse() { if (nR != nC) throw(" error:Invalid matrix dimension(not square matrix) in getInverse() function "); if (nR == 0 && nC == 0)throw(" error:undefined matrix(0x0) in getInverse() function "); double det = getDeterminant(); CMatrix m(nR, nC); if (det == 0){ throw(" error:can't get inverse to a singluar matrix "); } else { m = getCofactor(); m = m.getTranspose(); for (int i = 0; i < nR; i++) { for (int j = 0; j < nC; j++) { m.values[i][j] /= det; } } return m; } } ////////////////////////////////////////////////////* Equal ("=") operator *//////////////////////////////////// CMatrix CMatrix::operator=(const CMatrix& m) { copy(m); return *this; } ////////////////////////////////////////////* []operator to get an element with a given index *//////////////// double CMatrix:: operator [] (int index) { if (nR == 0 && nC == 0)throw(" error: you try to access element of undefined matrix(0x0) by [] operator "); if (index >= nR*nC || index < 0){ throw(" error:you try to access element out of matrix by [] operator"); } else { int r, c; r = index / nC; c = index % nC; return values[r][c]; } } /////////////////////////////////////////* ()operator to get an element with a given Coordinates *//////////////////// double CMatrix:: operator () (int r, int c) { if (nR == 0 && nC == 0)throw(" error: you try to access element of undefined matrix(0x0) by () operator "); if (r >= nR || r < 0 || c >= nC || c <0){ throw("error:you try to access element out of matrix by() operator"); } else { return values[r][c]; } } ///////////////////////////////////////* ()operator to get an element with a given index *///////////////////////// double CMatrix:: operator () (int index) { if (index >= nR*nC || index < 0){ throw("error:you try to access element out of matrix by () operator"); } else { int r, c; r = index / nC; c = index % nC; return values[r][c]; } } /////////////////////////////////////////////////////////////////////////////////////// istream& operator >> (istream &is, CMatrix& m) { string s; getline(is, s, ']'); s += "]"; m = CMatrix(s); return is; } ////////////////////////////////////////////////////////////////////////////////////// ostream& operator << (ostream &os, CMatrix& m) { os << m.getString(); return os; } ///////////////////////////////////////////////////////////////////// void CMatrix::add(const CMatrix& m) { if ((nR == 0 && nC == 0) || (m.nR == 0 && m.nC == 0))throw(" error: you try to add undefined matrix(0x0) by add() function "); if ((nR != m.nR) || (nC != m.nC))throw ("error:you try to add two matrices have different size by add()function"); else { for (int iR = 0; iR < nR; iR++) { for (int iC = 0; iC < nC; iC++) { values[iR][iC] += m.values[iR][iC]; } } } } /////////////////////////////////////////////////////////////////////////////// void CMatrix::add(double c) { if (nR == 0 && nC == 0)throw(" error: you try to add undefined matrix(0x0) by add() function "); else { for (int iR = 0; iR < nR; iR++) { for (int iC = 0; iC < nC; iC++) { values[iR][iC] += c; } } } } ///////////////////////////////////////////////////////////////////// void CMatrix::operator+=(const CMatrix& m) { if ((nR == 0 && nC == 0) || (m.nR == 0 && m.nC == 0))throw(" error: you try to add undefined matrix(0x0) by += operator "); if ((nR != m.nR) || (nC != m.nC)) throw ("error:you try to add two matrices have different size by += operator"); else add(m); } ///////////////////////////////////////////////////////////////////// void CMatrix::operator+=(double c) { if ((nR == 0 && nC == 0))throw(" error: you try to add undefined matrix(0x0) by += operator "); else add(c); } ///////////////////////////////////////////////////////////////////// CMatrix CMatrix::operator+(const CMatrix &m) { if ((nR == 0 && nC == 0) || (m.nR == 0 && m.nC == 0))throw(" error: you try to add undefined matrix(0x0) by + operator "); if ((nR != m.nR) || (nC != m.nC))throw ("error:you try to add two matrices have different size by + operator"); else { CMatrix s = *this; s += m; return s; } } //////////////////////////////////////////////////////////////////// CMatrix CMatrix::operator+(double c) { if ((nR == 0 && nC == 0))throw(" error: you try to add undefined matrix(0x0) by + operator "); else { CMatrix s = *this; s += c; return s; } } /////////////////////////////////////////////////////////////////// void CMatrix::sub(const CMatrix& m) { if ((nR == 0 && nC == 0) || (m.nR == 0 && m.nC == 0))throw(" error: you try to sub undefined matrix(0x0) by sub() function "); if ((nR != m.nR) || (nC != m.nC))throw ("error:you try to sub two matrices have different size by sub()function"); for (int iR = 0; iR < nR; iR++) { for (int iC = 0; iC < nC; iC++) values[iR][iC] -= m.values[iR][iC]; } } ////////////////////////////////////////////////////////////////// void CMatrix::sub(double c) { if ((nR == 0 && nC == 0))throw(" error: you try to sub undefined matrix(0x0) by sub() function "); for (int iR = 0; iR < nR; iR++) { for (int iC = 0; iC < nC; iC++) values[iR][iC] -= c; } } ////////////////////////////////////////////////////////////////// void CMatrix::operator-=(const CMatrix& m) { if ((nR == 0 && nC == 0) || (m.nR == 0 && m.nC == 0))throw(" error: you try to sub undefined matrix(0x0) by -= operator "); if ((nR != m.nR) || (nC != m.nC)) throw ("error:you try to sub two matrices have different size by -= operator"); sub(m); } ////////////////////////////////////////////////////////////////// void CMatrix::operator-=(double c) { if ((nR == 0 && nC == 0))throw(" error: you try to sub undefined matrix(0x0) by -= operator "); else sub(c); } ///////////////////////////////////////////////////////////////// CMatrix CMatrix::operator-(CMatrix m) { if ((nR == 0 && nC == 0) || (m.nR == 0 && m.nC == 0))throw(" error: you try to sub undefined matrix(0x0) by - operator "); if ((nR != m.nR) || (nC != m.nC))throw ("error:you try to sub two matrices have different size by - operator"); else { CMatrix s = *this; s -= m; return s; } } //////////////////////////////////////////////////////////////// CMatrix CMatrix::operator-(double c) { if ((nR == 0 && nC == 0))throw(" error: you try to sub undefined matrix(0x0) by - operator "); else { CMatrix s = *this; s -= c; return s; } } //////////////////////////////////////////////////////////////// void CMatrix::mul(const CMatrix &m) { if ((nR == 0 && nC == 0) || (m.nR == 0 && m.nC == 0))throw(" error: you try to multiply undefined matrix(0x0) by mul() function "); if ((nC != m.nR))throw ("error:you try to multiply two matrices have invalid dimension by mul() function"); else { CMatrix Result(nR, m.nC); for (int iR = 0; iR<Result.nR; iR++) for (int iC = 0; iC<Result.nC; iC++) { Result.values[iR][iC] = 0; for (int k = 0; k<m.nC; k++) Result.values[iR][iC] += values[iR][k] * m.values[k][iC]; } copy(Result); } } ////////////////////////////////////////////////////////////////////////// void CMatrix::mul(double c) { if (nR == 0 && nC == 0)throw(" error: you try to multiply undefined matrix(0x0) by mul() function "); else { for (int iR = 0; iR < nR; iR++) { for (int iC = 0; iC < nC; iC++) { values[iR][iC] *= c; } } } } ////////////////////////////////////////////////////////////////////////// void CMatrix::operator*=(const CMatrix& m) { if ((nR == 0 && nC == 0) || (m.nR == 0 && m.nC == 0))throw(" error: you try to multiply undefined matrix(0x0) by *= operator "); if ((nC != m.nR))throw ("error:you try to multiply two matrices have invalid dimension by *= operator"); else mul(m); } ///////////////////////////////////////////////////////////////////////// void CMatrix::operator*=(double d) { if ((nR == 0 && nC == 0))throw(" error: you try to multiply undefined matrix(0x0) by *= operator "); else { mul(d); } } ///////////////////////////////////////////////////////////////////////// CMatrix CMatrix::operator*(const CMatrix& m) { if ((nR == 0 && nC == 0) || (m.nR == 0 && m.nC == 0))throw(" error: you try to multiply undefined matrix(0x0) by * operator "); if ((nC != m.nR))throw ("error:you try to multiply two matrices have invalid dimension by * operator"); else { CMatrix r = *this; r *= m; return r; } } //////////////////////////////////////////////////////////////////////// CMatrix CMatrix::operator*(double d) { if ((nR == 0 && nC == 0))throw(" error: you try to multiply undefined matrix(0x0) by * operator "); else { CMatrix r = *this; r *= d; return r; } } /////////////////////////////////////////////////////////////////////////////////////////////////// void CMatrix::addColumn(CMatrix& m) { CMatrix n(max(nR, m.nR), nC + m.nC); n.setSubMatrix(0, 0, *this); n.setSubMatrix(0, nC, m); *this = n; } ///////////////////////////////////////////////////////////////////////////// void CMatrix::addRow(CMatrix& m) { CMatrix n(nR + m.nR, max(nC, m.nC)); n.setSubMatrix(0, 0, *this); n.setSubMatrix(nR, 0, m); *this = n; } ///////////////////////////////////////////////////////////////////////////// void CMatrix::copy(double d) { for (int i = 0; i < nR; i++) for (int j = 0; j < nC; j++) values[i][j] = d; } //////////////////////////////////////////////////////////////////////////////// void CMatrix::copy(string s) { reset(); char* buffer = new char[s.length() + 1]; strcpy(buffer,s.c_str()); char* lineContext; char* lineSeparators = ";\r\n"; char* line = strtok_r(buffer, lineSeparators, &lineContext); char* context; char* separators = " []"; while (line) { CMatrix row; char* token = strtok_r(line, separators, &context); while (token) { CMatrix item = atof(token); row.addColumn(item); token = strtok_r(NULL, separators, &context); } if (row.nC>0 && (row.nC == nC || nR == 0)) addRow(row); line = strtok_r(NULL, lineSeparators, &lineContext); if ((row.nC != nC)&&(row.nC!=0)) ///////// edit///////////////// { reset(); throw("error:invalid matrix"); } } delete[] buffer; } ////////////////////////////////////////////////////////////////////////////////// string CMatrix::getString() { string s; for (int iR = 0; iR<nR; iR++) { for (int iC = 0; iC<nC; iC++) { char buffer[50]; snprintf(buffer,50, "%g\t", values[iR][iC]); s += buffer; } s += "\n"; } if (nR>0 && nC>0 )return s; ///////// edit///////////////// else throw("empty matrix"); } //////////////////////////////////////////////////////////////////////////////// CMatrix CMatrix::operator=(double d) { copy(d); return *this; } //////////////////////////////////////////////////////////////////////////////// CMatrix CMatrix::operator=(string s) { copy(s); return *this; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// basma & mohamed CMatrix CMatrix::operator++() //pre-increment -> ++a { add(1.0); return *this; } /////////////////////////////////////////////////////////////////////////// CMatrix CMatrix::operator++(int) //post-increment -> a++ { CMatrix C = *this; add(1.0); return C; } /////////////////////////////////////////////////////////////////////// CMatrix CMatrix::operator--() //pre-decrement -> --a { add(-1.0); return *this; } ////////////////////////////////////////////////////////////////////////// CMatrix CMatrix::operator--(int) //post-decrement -> a-- { CMatrix r = *this; add(-1.0); return r; } /////////////////////////////////////////////////////////////////////////// CMatrix CMatrix::operator-() //negative { for (int iR = 0; iR<nR; iR++) { for (int iC = 0; iC<nC; iC++) values[iR][iC] = -values[iR][iC]; } return *this; } /////////////////////////////////////////////////////////////////////////////// CMatrix CMatrix::operator+() //positive { return *this; } ////////////////////////////////////////////////////////////////////////// setSubMatrix void CMatrix::setSubMatrix(int r, int c, CMatrix& m) { if ((r + m.nR)>nR || (c + m.nC)>nC)throw("Invalid matrix dimension"); for (int iR = 0; iR<m.nR; iR++) for (int iC = 0; iC<m.nC; iC++) values[r + iR][c + iC] = m.values[iR][iC]; } //////////////////////////////////////////////////////////////////// getSubMatrix CMatrix CMatrix::getSubMatrix(int r, int c, int nr, int nc) { if ((r + nr)>nR || (c + nc)>nC)throw("Invalid matrix dimension"); CMatrix m(nr, nc); for (int iR = 0; iR<m.nR; iR++) for (int iC = 0; iC<m.nC; iC++) m.values[iR][iC] = values[r + iR][c + iC]; return m; } /////////////////////////////////////////////////////////////////// division void CMatrix::div(const CMatrix& m) { if (m.nR != m.nC) throw("Invalid matrix dimension"); if (nC != m.nR)throw("Invalid matrix dimension"); else { CMatrix r = m; r = r.getInverse(); mul(r); } } /////////////////////////////////////////////////////////////// division over matrix void CMatrix::operator/=(const CMatrix& m) { div(m); } ///////////////////////////////////////////////////////////// division over value void CMatrix::operator/=(double d) { for (int iR = 0; iR<nR; iR++) for (int iC = 0; iC<nC; iC++) values[iR][iC] /= d; } //////////////////////////////////////////////////////////// division over matrix returns matrix CMatrix CMatrix::operator/(const CMatrix& m) { CMatrix r = *this; r /= m; return r; } //////////////////////////////////////////////////////// division over value returns matrix CMatrix CMatrix::operator/(double d) { CMatrix r = *this; r /= d; return r; } ///////////////////////////////////////////////////////////////////////////////// CMatrix CMatrix::elementDiv(double d) { CMatrix m(nR, nC); for (int i = 0; i<nR; i++) for (int j = 0; j < nC; j++) { double v = getElement(i, j); m.setElement(i, j, (d / v)); } return m; } ////////////////////////////////mohammed w basma w rbna ystor /////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// trigonometric fns CMatrix sin(CMatrix &m) ////////////////////// gets sin matrix { CMatrix n(m.nR, m.nC); for (int i = 0; i < n.nR;i++) for (int j = 0; j < n.nC; j++) n.values[i][j] = sin(m.values[i][j]); return n; } CMatrix asin(CMatrix &m) ////////////////////// gets asin matrix { CMatrix n(m.nR, m.nC); for (int i = 0; i < n.nR;i++) for (int j = 0; j < n.nC; j++) n.values[i][j] = asin(m.values[i][j]); return n; } CMatrix acos(CMatrix &m) ////////////////////// gets asin matrix { CMatrix n(m.nR, m.nC); for (int i = 0; i < n.nR;i++) for (int j = 0; j < n.nC; j++) n.values[i][j] = acos(m.values[i][j]); return n; } CMatrix atan(CMatrix &m) ////////////////////// gets asin matrix { CMatrix n(m.nR, m.nC); for (int i = 0; i < n.nR;i++) for (int j = 0; j < n.nC; j++) n.values[i][j] = atan(m.values[i][j]); return n; } CMatrix cos(CMatrix &m) ////////////////////// gets cos matrix { CMatrix n(m.nR, m.nC); for (int i = 0; i < n.nR;i++) for (int j = 0; j < n.nC; j++) n.values[i][j] = cos(m.values[i][j]); return n; } CMatrix tan(CMatrix &m) ////////////////////// gets tan matrix { CMatrix n(m.nR, m.nC); for (int i = 0; i < n.nR;i++) for (int j = 0; j < n.nC; j++) n.values[i][j] = tan(m.values[i][j]); return n; } CMatrix sinh(CMatrix &m) ////////////////////// gets sinh matrix { CMatrix n(m.nR, m.nC); for (int i = 0; i < n.nR;i++) for (int j = 0; j < n.nC; j++) n.values[i][j] = sinh(m.values[i][j]); return n; } CMatrix cosh(CMatrix &m) ////////////////////// gets cosh matrix { CMatrix n(m.nR, m.nC); for (int i = 0; i < n.nR;i++) for (int j = 0; j < n.nC; j++) n.values[i][j] = cosh(m.values[i][j]); return n; } CMatrix tanh(CMatrix &m) ////////////////////// gets tanh matrix { CMatrix n(m.nR, m.nC); for (int i = 0; i < n.nR;i++) for (int j = 0; j < n.nC; j++) n.values[i][j] = tanh(m.values[i][j]); return n; } CMatrix sech(CMatrix &m) ////////////////////// gets sinh matrix { CMatrix n(m.nR, m.nC); for (int i = 0; i < n.nR;i++) for (int j = 0; j < n.nC; j++) n.values[i][j] = 1/cosh(m.values[i][j]); return n; } CMatrix csch(CMatrix &m) ////////////////////// gets sinh matrix { CMatrix n(m.nR, m.nC); for (int i = 0; i < n.nR;i++) for (int j = 0; j < n.nC; j++) n.values[i][j] = 1/sinh(m.values[i][j]); return n; } CMatrix coth(CMatrix &m) ////////////////////// gets sinh matrix { CMatrix n(m.nR, m.nC); for (int i = 0; i < n.nR;i++) for (int j = 0; j < n.nC; j++) n.values[i][j] = 1/tanh(m.values[i][j]); return n; } CMatrix sec(CMatrix &m) ////////////////////// gets sec matrix { CMatrix n(m.nR, m.nC); for (int i = 0; i < n.nR;i++) for (int j = 0; j < n.nC; j++) { if(cos(m.values[i][j])==0) throw ("Marh Error .. Invalid matrix"); n.values[i][j] = 1/(cos(m.values[i][j])); } return n; } CMatrix csc(CMatrix &m) ////////////////////// gets csc matrix { CMatrix n(m.nR, m.nC); for (int i = 0; i < n.nR;i++) for (int j = 0; j < n.nC; j++) { if (sin(m.values[i][j]) ==0) throw ("Marh Error .. Invalid matrix"); n.values[i][j] = 1/(sin(m.values[i][j])); } return n; } CMatrix cot(CMatrix &m) ////////////////////// gets cot matrix { CMatrix n(m.nR, m.nC); for (int i = 0; i < n.nR;i++) for (int j = 0; j < n.nC; j++) { if (tan(m.values[i][j]) ==0) throw ("Marh Error .. Invalid matrix"); n.values[i][j] = 1/(tan(m.values[i][j])); } return n; } /////////////////////////////////////////////////////////////////////////////////////////// Roots CMatrix sqrt(CMatrix &m) ////////////////////// gets sqrt matrix { CMatrix n(m.nR, m.nC); for (int i = 0; i < n.nR;i++) for (int j = 0; j < n.nC; j++) { if (m.values[i][j] <=0) throw ("Marh Error .. Invalid matrix"); n.values[i][j] = sqrt(m.values[i][j]); } return n; } ///////////////////////////////////////////////////////////////////////////////////////////////////////powers CMatrix CMatrix :: powElement(double p) ///////////////////power each element { CMatrix r = *this; for (int iR=0 ; iR<nR ; iR++) for (int iC=0 ; iC<nC ; iC++) { r.values[iR][iC]=pow(r.values[iR][iC],p); } return r; } CMatrix CMatrix :: pow_1x1_matrix(double p) /////////////////// fraction power for 1x1 matrix { CMatrix r = *this; r.values[0][0] = pow(values[0][0] , p) ; return r; } int binary(int number ,int location) { if((1 &(number>>location))==0) return 0; else return 1; } CMatrix CMatrix :: pow_matrix(int p) /////////////////// power for matrix { CMatrix result (nR , nC ,2,0); CMatrix y = *this ; int flag=0; if (p<0) { p*= -1; flag =1 ; } double h = log10(2) ; int k=((log10(p))/h) +1; for ( int i=0 ; i<k ; i++ ) { if (binary (p,i)==1) result = result * y; y = y*y; } if (flag == 1) return result.getInverse(); return result ; } /////////////////////////////////////////////////////////////////////////////////////////logarithmic CMatrix log(CMatrix &m) ////////////////////// gets log matrix { CMatrix n(m.nR, m.nC); for (int i = 0; i < n.nR;i++) for (int j = 0; j < n.nC; j++) { if (m.values[i][j] <= 0) throw ("Math Error .. Invalid matrix "); n.values[i][j] = log10 (m.values[i][j]); } return n; } CMatrix ln(CMatrix &m) ////////////////////// gets ln matrix { CMatrix n(m.nR, m.nC); for (int i = 0; i < n.nR;i++) for (int j = 0; j < n.nC; j++) { if (m.values[i][j] <= 0) throw ("Math Error .. Invalid matrix "); n.values[i][j] = log(m.values[i][j]); } return n; } CMatrix exp(CMatrix &m) ////////////////////// gets exp matrix { CMatrix n(m.nR, m.nC); for (int i = 0; i < n.nR;i++) for (int j = 0; j < n.nC; j++) n.values[i][j] = exp(m.values[i][j]); return n; } ////////////////////////////////////////////////////////////////////////////////// CMatrix asec(CMatrix &m) ////////////////////// gets asec matrix { CMatrix n(m.nR, m.nC); for (int i = 0; i < n.nR;i++) for (int j = 0; j < n.nC; j++) n.values[i][j] = acos(1/m.values[i][j]); return n; } CMatrix acsc(CMatrix &m) ////////////////////// gets acsc matrix { CMatrix n(m.nR, m.nC); for (int i = 0; i < n.nR;i++) for (int j = 0; j < n.nC; j++) n.values[i][j] = asin(1/m.values[i][j]); return n; } CMatrix acot(CMatrix &m) ////////////////////// gets acot matrix { CMatrix n(m.nR, m.nC); for (int i = 0; i < n.nR;i++) for (int j = 0; j < n.nC; j++) n.values[i][j] = atan(1/m.values[i][j]) ; return n; } ////////////////////////////////////medhat &amira &aya/////////////////////////////////// string CMatrix::sendString() { string s = "["; for (int iR = 0; iR < nR; iR++) { for (int iC = 0; iC < nC; iC++) { char buffer[50]; if (iC < nC - 1) { snprintf(buffer, 50, "%g ", values[iR][iC]); s += buffer; } else if (iC == nC - 1) { snprintf(buffer, 50, "%g", values[iR][iC]); s += buffer; } } if (iR != nR - 1) { s += ";"; } } s += "]"; if (nR>0 && nC>0 )return s; else throw("empty matrix sendstring"); } ////////////////////////////////////////////////////////////////////////////////////// void CMatrix::concatinate(CMatrix& m) { if (nR != m.nR)throw("Invalid matrix dimension"); CMatrix n(nR, nC + m.nC); n.setSubMatrix(0, 0, *this); int r = 0; int c = nC; n.setSubMatrix(r, c, m); copy(n); }
c5b2940db8bb19f0b00bcef0b98f337a98e4b1a0
a5dc88f5c69f418ec0fc2c44ecfccdf99bf2b0e3
/cl.cpp
21de5f3adf85ac6925a3d7e53fea837d40acb5c6
[]
no_license
Paulboca/ConnectFour
059fb26430cab970229571283a3f4950c35cbc34
214aed3cdb2659ac48cf47807a787b618f499f0e
refs/heads/main
2023-04-18T06:39:11.548482
2021-03-31T17:00:22
2021-03-31T17:00:22
353,429,232
0
0
null
null
null
null
UTF-8
C++
false
false
9,314
cpp
cl.cpp
#include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <errno.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <netdb.h> #include <string.h> #include <arpa/inet.h> #include <iostream> using namespace std; extern int errno; char tabla[6][7]; int i, j, win; int lib[8] = {5, 5, 5, 5, 5, 5, 5, 5}; //lib = casute libere pe coloana char simbol, a_d = 'd' ; int poz = 0; void head1() { printf ("\n ⟱\n"); } void head2() { printf ("\n ⟱\n"); } void head3() { printf ("\n ⟱\n"); } void head4() { printf ("\n ⟱\n"); } void head5() { printf ("\n ⟱\n"); } void head6() { printf ("\n ⟱\n"); } void head7() { printf ("\n ⟱ \n"); } void afisare() { for (i=0; i<6; i++) { printf("|===|===|===|===|===|===|===|\n"); for (j=0; j<7; j++) { printf("| "); printf("%c ", tabla [i] [j] ); } printf("|\n" ); } printf("|===|===|===|===|===|===|===|\n"); printf(" 1 2 3 4 5 6 7 \n"); } void joc(int sd) { switch (poz) //afisare initiala a indicatorului (sageata in jos) { case 1: head1(); break; case 2: head2(); break; case 3: head3(); break; case 4: head4(); break; case 5: head5(); break; case 6: head6(); break; case 7: head7(); break; default: head1(); break; } afisare(); if ((a_d == 'a' || a_d == 'A') && poz > 1) poz --; if ((a_d == 'd' || a_d == 'D') && poz < 7) poz ++; while (1) //schimbam pozitia curenta { if (lib[poz] == 0) cout << "Coloana plina" << endl; cout << "A = move left, D = move right, S = drop disc: "; cin >> a_d; if ((a_d == 'a' || a_d == 'A') && poz > 1) poz --; if ((a_d == 'd' || a_d == 'D') && poz < 7) poz ++; if (a_d == 's' || a_d == 'S') if (lib[poz] > 0) break; system ("clear"); switch (poz) //afisare indicator { case 1: head1(); break; case 2: head2(); break; case 3: head3(); break; case 4: head4(); break; case 5: head5(); break; case 6: head6(); break; case 7: head7(); break; default: break; } afisare(); //afisare tabla } switch (poz) //completare matrice pe pozitia selectata { case 1: if (lib[1] >= 0 && tabla [lib[1]-1][poz-1] == ' ') { tabla [lib[1]-1][poz-1] = simbol; lib[1]--; a_d = 'w'; } head1(); afisare(); break; case 2: if (lib[2] >= 0 && tabla [lib[2]-1][poz-1] == ' ') { tabla [lib[2]-1][poz-1] = simbol; lib[2]--; a_d = 'w'; } head2(); afisare(); break; case 3: if (lib[3] >= 0 && tabla [lib[3]-1][poz-1] == ' ') { tabla [lib[3]-1][poz-1] = simbol; lib[3]--; a_d = 'w'; } head3(); afisare(); break; case 4: if (lib[4] >= 0 && tabla [lib[4]-1][poz-1] == ' ') { tabla [lib[4]-1][poz-1] = simbol; lib[4]--; a_d = 'w'; } head4(); afisare(); break; case 5: if (lib[5] >= 0 && tabla [lib[5]-1][poz-1] == ' ') { tabla [lib[5]-1][poz-1] = simbol; lib[5]--; a_d = 'w'; } head5(); afisare(); break; case 6: if (lib[6] >= 0 && tabla [lib[6]-1][poz-1] == ' ') { tabla [lib[6]-1][poz-1] = simbol; lib[6]--; a_d = 'w'; } head6(); afisare(); break; case 7: if (lib[7] >= 0 && tabla [lib[7]-1][poz-1] == ' ') { tabla [lib[7]-1][poz-1] = simbol; lib[7]--; a_d = 'w'; } head7(); afisare(); break; default: break; } } void ifwin() { // diagonala for (int linie = 0; linie < 4; linie++) for (int coloana = 6; coloana > 2; coloana--) if (tabla[linie][coloana] == simbol) if (tabla[linie + 1][coloana - 1] == simbol) if (tabla[linie + 2][coloana - 2] == simbol) if (tabla[linie + 3][coloana - 3] == simbol) win = 1; // diagonala for (int linie = 0; linie < 4; linie++) for (int coloana = 6; coloana > 2; coloana--) if (tabla[linie][coloana - 3] == simbol) if (tabla[linie + 1][coloana - 2] == simbol) if (tabla[linie + 2][coloana - 1] == simbol) if (tabla[linie + 3][coloana] == simbol) win = 1; // orizontala for (int linie = 0; linie < 7; linie++) for (int coloana = 6; coloana > 2; coloana--) if (tabla[linie][coloana] == simbol) if (tabla[linie][coloana - 1] == simbol) if (tabla[linie][coloana - 2] == simbol) if (tabla[linie][coloana - 3] == simbol) win = 1; // verticala for (int coloana = 0; coloana < 7; coloana++) for (int linie = 6; linie > 2; linie--) if (tabla[linie][coloana] == simbol) if (tabla[linie - 1][coloana] == simbol) if (tabla[linie - 2][coloana] == simbol) if (tabla[linie - 3][coloana] == simbol) win = 1; } void getMatrix(int sd) { char x; for ( i=0; i < 6; i++) for (j = 0; j < 7; j++) { recv(sd, &x, 1, 0); tabla[i][j] = x; } } void sendMatrix(int sd) { char x; for ( i=0; i < 6; i++) for (j = 0; j < 7; j++) { x = tabla[i][j]; send (sd, &x, 1, 0); } } void sendLib(int sd, int lib[8]) { char x; for (i = 0; i < 8; i++) { x = char(lib[i]); send (sd, &x, 1, 0); } } void getLib(int sd, int lib[8]) { char x; for (i = 0; i < 8; i++) { recv(sd, &x, 1, 0); lib[i] = int(x); } } int main (int argc, char *argv[]) { if (argc != 3) { printf ("Sintaxa: %s <adresa_server> <port>\n", argv[0]); return -1; } struct sockaddr_in server; int sd; if ((sd = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) { perror ("Eroare la socket().\n"); return errno; } int opt = 1; setsockopt (sd, SOL_SOCKET, SO_REUSEADDR, (void *) &opt, sizeof (opt)); server.sin_family = AF_INET; server.sin_port = htons (atoi (argv[2])); server.sin_addr.s_addr = inet_addr(argv[1]); if (connect (sd, (struct sockaddr *) &server,sizeof (struct sockaddr)) == -1) { perror ("[client]Eroare la connect().\n"); return errno; } int run = 1; recv (sd, &simbol, 1, 0); while (run) { char winner = ' '; char scor_x, scor_0; while (win == 0){ getMatrix(sd); // primeste matricea de la server getLib(sd, lib); joc(sd); // apel catre functia care permite player-ului sa puna o piesa in tabla afisare(); sendMatrix(sd); // trimite matricea cu piesa pusa de player sendLib(sd, lib); ifwin (); recv (sd, &winner, 1, 0); if (winner == '0' || winner == 'X') { win = 1; } if (win == 1 && winner != '0' && winner != 'X') { winner = simbol; } send (sd, &winner, 1, 0); recv (sd, &scor_x, 1, 0); recv (sd, &scor_0, 1, 0); system("clear"); } if(win == 1) { cout << "a castigat " << winner << endl; cout << "X: " << int(scor_x) << "-" << int(scor_0) << " :0" << endl; } cout << "Play again ? Y/N: "; char confirmare[2]; char confirmare2[2]; cin >> confirmare; while(strcmp(confirmare, "N") != 0 && strcmp(confirmare, "n") != 0 && strcmp(confirmare, "Y") != 0 && strcmp(confirmare, "y") != 0) { cout << "Introduceti Y sau N:"; cin >> confirmare; } send (sd, &confirmare, 1, 0); recv (sd, &confirmare2, 1, 0); if (strcmp(confirmare, "N") == 0 || strcmp(confirmare, "n") == 0 || strcmp(confirmare2, "N") == 0 || strcmp(confirmare2, "n") == 0) run = 0;cout<<endl; if (strcmp(confirmare, "Y") == 0 || strcmp(confirmare, "y") == 0) win = 0; poz = 1; } close (sd); }
4ffb42d22b4f70ce16fd63c9c5a3ca2e36eecd66
31324ccac17f94884ffcd9c041d19e8f01c8fd6f
/rclient.cpp
80445bd1123b034712bb0c57ac1e4691c955f9ff
[]
no_license
vsklamm/os-net
aaa4f0c14aa30459660e45182be75e775828d5c8
6c801651cb8d5a392d2713ae5b87f8f0f094f980
refs/heads/master
2020-05-18T07:48:05.353519
2019-06-14T14:24:02
2019-06-14T14:24:02
184,275,355
0
0
null
2019-04-30T14:17:14
2019-04-30T14:17:14
null
UTF-8
C++
false
false
460
cpp
rclient.cpp
#include <cstdlib> #include <iostream> #include <string> #include "client.h" int main(int argc, char *argv[]) { if (argc != 4) { std::cerr << "Client usage: <address> <port> <message>" << std::endl; exit(EXIT_FAILURE); } try { client cl({argv[1]}, {argv[2]}); cl.connect_to_server(); cl.work(std::string(argv[3])); } catch (std::runtime_error &e) { std::cerr << e.what() << std::endl; } }
8be97032970e7091dd00b5ceb67e99d87d6fea96
4a9213bf83760ceb50a1dc2cfd973f28339e1127
/Code/Engine/resource/resource_system.cpp
6fe3f4b44823bf768aa9dc7becd1df15d047392a
[ "MIT" ]
permissive
wkigen/WingEngine
dd094cda9f08edc2d3bfd14195b2ae2de0657d7f
5f0da3b26e11977d0205ecbd6e093c5846f26210
refs/heads/master
2020-04-17T20:34:55.556595
2017-10-18T02:50:51
2017-10-18T02:50:51
66,062,913
2
0
null
null
null
null
UTF-8
C++
false
false
1,333
cpp
resource_system.cpp
#include "resource_system.h" #include "mesh\mesh_reader.h" #include "image_reader.h" #include "font\font_reader.h" namespace WingEngine { ResourceSystem::ResourceSystem() { } ResourceSystem::~ResourceSystem() { } bool ResourceSystem::create() { if (mCreate) { WING_LOG_WARN("ResourceSystem has been create"); return false; } mCreate = true; SmartPtr<MeshReader> meshReader = WING_NEW MeshReader(); SmartPtr<ImageReader> imageReader = WING_NEW ImageReader(); SmartPtr<FontReader> fontReader = WING_NEW FontReader(); addReader(ResourceTypeMesh, meshReader); addReader(ResourceTypeImage, imageReader); addReader(ResourceTypeFont, fontReader); return true; } void ResourceSystem::destroy() { } void ResourceSystem::addWriter(uint32 type, ResourceWriter* writer) { std::map<uint32, SmartPtr<ResourceWriter>>::iterator itor = mResourceWriters.find(type); if (itor == mResourceWriters.end()) WING_LOG_WARN("is exist writer of type[%d]",type); mResourceWriters[type] = writer; } void ResourceSystem::addReader(uint32 type, ResourceReader* reader) { std::map<uint32, SmartPtr<ResourceReader>>::iterator itor = mResourceReaders.find(type); if (itor != mResourceReaders.end()) WING_LOG_WARN("is exist reader of type[%d]", type); mResourceReaders[type] = reader; } }
a555f0f376db09ca11cfefbec24d641d0845df31
ef356dbd697546b63c1c4c866db4f410ecf1c226
/xml/dom/mxml/mxmlXMLString.hpp
741895f75ae363852405a1110f6fc4bb211e17b0
[]
no_license
jondos/Mix
d5e7ab0f6ca4858b300341fb17e56af9106ffb65
8e0ebd9490542472197eca4b7c9974618df6f1de
refs/heads/master
2023-09-03T12:55:23.983398
2010-01-04T14:52:26
2010-01-04T14:52:26
425,933,032
0
0
null
null
null
null
UTF-8
C++
false
false
1,304
hpp
mxmlXMLString.hpp
#ifndef __MXML_XML_STRING__ #define __MXML_XML_STRING__ #include "mxmlDOMTypeDef.hpp" class XMLString { public: static char* transcode ( const XMLCh *const toTranscode) { UINT32 len=strlen((char*)toTranscode)+1; char* newBuf=new char[len]; memcpy(newBuf,toTranscode,len); return newBuf; } static XMLCh* transcode ( const char *const toTranscode) { UINT32 len=strlen(toTranscode)+1; XMLCh* newBuf=new XMLCh[len]; memcpy(newBuf,toTranscode,len); return newBuf; } static void release ( XMLCh ** buf) { delete[] *buf; *buf = NULL; } static void release ( char ** buf) { delete[] *buf; *buf = NULL; } static bool equals ( const XMLCh *const str1, const XMLCh *const str2) { return strcmp((char*)str1,(char*)str2)==0; } static void trim(XMLCh* const toTrim); static XMLCh* replicate(const XMLCh* const toRep) { UINT32 len=XMLString::stringLen(toRep)+1; XMLCh* c=new XMLCh[len]; memcpy(c,toRep,len); return c; } static UINT32 stringLen(const XMLCh* const src) { return strlen((char*)src); } static SINT32 compareString(const XMLCh *const str1, const XMLCh *const str2); }; #endif //__MXML_XML_STRING__
81b73a990e628a6bac61110e4ea394a3287a1388
ad48cfc1724d38903994b0dfb7cce1a396d51aa4
/Seanet/evaluator.hpp
d01b5b7e1cdfbdfcb62e88672a37b318cd73bfaa
[]
no_license
uhsprogrammingclub/Seanet
49207f7ce5a2029121cb8a043925465972e6688a
d78b9d68f61165167e7cc57856229105bd9c5d34
refs/heads/master
2021-01-01T05:22:21.763670
2016-06-03T23:30:44
2016-06-03T23:30:44
58,693,721
0
0
null
null
null
null
UTF-8
C++
false
false
1,062
hpp
evaluator.hpp
// // evaluator.hpp // Seanet // // Created by Nathaniel Corley on 5/16/16. // // #ifndef __Seanet__evaluator__ #define __Seanet__evaluator__ #include "board.hpp" #include "util.hpp" #include <stdio.h> #include <vector> int calculatePhase(State &state); int calculateMaterial(State &state); int evaluate(State &state); int evaluateGameOver(State &state, int contempt); bool isGameOver(State &state); bool isGameOver(State &state, std::vector<Move> moves); bool isThreeFoldRepetition(State &state); int evaluateDraw(State &state, int contempt); bool isIsolatedPawn(State &state, int index); bool isIsolaniPawn(State &state, int index); bool isDoubledPawn(State &state, int index); bool isConnectedPawn(State &state, int index); bool isBackwardPawn(State &state, int index); bool isBlockedPawn(State &state, int index); bool isPassedPawn(State &state, int index); int countHoles(State &state); int countKingPawnShields(State &state); FList getInitialFeatures(State &state); float getPhaseFactor(State &state); #endif /* defined(__Seanet__evaluator__) */
649b619a418775b4c497fe3720f2f5ff6836e2a2
a9341245fe25aa1bb9902a7ec387ac472a43c3f8
/plugins/graphics/src/core/GraphicsScriptBinding.cpp
7c6eb0f785431950e5fe1e3101bb867c6db07074
[]
no_license
mgottschlag/PeakEngineNew
c1287d86f52a6a8c92c6a87482a63d991236df38
271df91bf7982016d25b928ebd9872a2ab933966
refs/heads/master
2020-08-05T22:12:49.701966
2010-04-12T17:01:45
2010-04-12T17:01:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,819
cpp
GraphicsScriptBinding.cpp
/* Copyright (c) 2010, Mathias Gottschlag Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "peakgraphics/core/GraphicsScriptBinding.hpp" #include "peakgraphics/core/GraphicsEntityComponent.hpp" #include "peakgraphics/core/Graphics.hpp" #include "peakgraphics/scene/SceneNode.hpp" #include "peakgraphics/scene/CameraSceneNode.hpp" #include "peakgraphics/scene/ModelSceneNode.hpp" #include "peakgraphics/scene/LightSceneNode.hpp" #include "peakgraphics/scene/GUISceneNode.hpp" #include "peakgraphics/gui/ButtonElement.hpp" #include "peakgraphics/gui/FrameElement.hpp" #include "peakgraphics/gui/ListBoxElement.hpp" #include "peakengine/core/Engine.hpp" #include <luabind/operator.hpp> #include <luabind/adopt_policy.hpp> namespace peak { namespace graphics { template<class T> static T *get_pointer(const SharedPointer<T> &p) { return p.get(); } template<class A> static SharedPointer<A const> *get_const_holder(SharedPointer<A>*) { return 0; } void GraphicsScriptBinding::apply(Script *script) { lua_State *state = script->getState(); luabind::module(state, "peak") [ luabind::namespace_("graphics") [ // Graphics luabind::class_<Graphics>("Graphics") .def("loadAll", &Graphics::loadAll) .def("getRootSceneNode", &Graphics::getRootSceneNode) .def("setDefaultCamera", &Graphics::setDefaultCamera) .def("getEngine", &Graphics::getEngine) .def("getMouseMoveEvent", &Graphics::getMouseMoveEvent) .def("getMousePositionEvent", &Graphics::getMousePositionEvent) .def("getMouseButtonEvent", &Graphics::getMouseButtonEvent) .def("getKeyboardEvent", &Graphics::getKeyboardEvent) .def("getCharEvent", &Graphics::getCharEvent), // GraphicsEntityComponent luabind::class_<GraphicsEntityComponent, EntityComponent>("GraphicsEntityComponent") .def("addSceneNode", &GraphicsEntityComponent::addSceneNode, luabind::adopt(_3)) .def("getSceneNode", &GraphicsEntityComponent::getSceneNode) .def("getGraphics", &GraphicsEntityComponent::getGraphics), // SceneNode luabind::class_<SceneNode>("SceneNode") .def("setPosition", &SceneNode::setPosition) .def("getPosition", &SceneNode::getPosition) .def("setRotation", &SceneNode::setRotation) .def("getRotation", &SceneNode::getRotation) .def("setScale", &SceneNode::setScale) .def("getScale", &SceneNode::getScale) .def("setVisible", &SceneNode::setVisible) .def("isVisible", &SceneNode::isVisible) .def("setParent", &SceneNode::setParent) .def("getParent", &SceneNode::getParent), // CameraSceneNode luabind::class_<CameraSceneNode, SceneNode>("CameraSceneNode"), // ModelSceneNode luabind::class_<ModelSceneNode, SceneNode>("ModelSceneNode"), // LightSceneNode luabind::class_<LightSceneNode, SceneNode>("LightSceneNode"), // GUISceneNode luabind::class_<GUISceneNode, SceneNode>("GUISceneNode") .def("injectMousePosition", &GUISceneNode::injectMousePosition) .def("injectMouseButton", &GUISceneNode::injectMouseButton) .def("injectChar", &GUISceneNode::injectChar) .def("injectKeyboard", &GUISceneNode::injectKeyboard) .def("getActionEvent", &GUISceneNode::getActionEvent) .def("getRootElement", &GUISceneNode::getRootElement), // GUIElement luabind::class_<GUIElement, Loadable, SharedPointer<GUIElement> >("GUIElement") .def("setPosition", &GUIElement::setPosition) .def("getPosition", &GUIElement::getPosition) .def("setSize", &GUIElement::setSize) .def("getSize", &GUIElement::getSize) .def("setVisible", &GUIElement::setVisible) .def("isVisible", &GUIElement::isVisible) .def("setBackground", &GUIElement::setBackground) .def("setActionID", &GUIElement::setActionID) .def("getActionID", &GUIElement::getActionID), // ButtonElement luabind::class_<ButtonElement, GUIElement, SharedPointer<ButtonElement> >("ButtonElement") .def(luabind::constructor<GUISceneNode*, GUIElement*, std::string>()) .def("setLabel", (void (ButtonElement::*)(const std::string&))&ButtonElement::setLabel) .def("getLabel", &ButtonElement::getLabel), // FrameElement luabind::class_<FrameElement, GUIElement, SharedPointer<FrameElement> >("FrameElement") .def(luabind::constructor<GUISceneNode*, GUIElement*, std::string>()), // ListBoxElement luabind::class_<ListBoxElement, GUIElement, SharedPointer<ListBoxElement> >("ListBoxElement") .def(luabind::constructor<GUISceneNode*, GUIElement*, std::string>()) .def("setTitle", &ListBoxElement::setTitle) .def("getTitle", &ListBoxElement::getTitle) .def("addRow", &ListBoxElement::addRow) .def("getRow", &ListBoxElement::getRow) .def("setRow", &ListBoxElement::setRow) .def("deleteRow", &ListBoxElement::deleteRow) .def("getRowCount", &ListBoxElement::getRowCount) .def("clearRows", &ListBoxElement::clearRows) .def("getSelection", &ListBoxElement::getSelection) .def("setSelection", &ListBoxElement::setSelection) ] ]; } } }
373dca4bbe26e7010a0fc74ecdf1c38dbb73d99f
a02d4b3c879c047082ccc295607d6ec8d1130039
/Procedurals/speedtreeKit/speedtreeOp/source/op.cpp
b58bc18512963b7ffe9b23889d3633c0f0006615
[ "Apache-2.0" ]
permissive
iceprincefounder/selected-sources
4fa97e439248d1b4bd9e6e59d0f80a7c33752761
b225c529e02009b5f44bfb2891ef8f039b9a6d80
refs/heads/master
2022-05-22T03:24:45.329292
2022-03-13T09:22:12
2022-03-13T09:22:12
149,724,714
17
3
null
null
null
null
UTF-8
C++
false
false
7,972
cpp
op.cpp
#include <iostream> #include <sstream> #include <sys/stat.h> #include <unistd.h> #include <string> #include <FnAttribute/FnAttribute.h> #include <FnAttribute/FnGroupBuilder.h> #include <FnPluginSystem/FnPlugin.h> #include <FnGeolib/op/FnGeolibOp.h> #include <FnGeolib/util/Path.h> #include <FnGeolibServices/FnGeolibCookInterfaceUtilsService.h> namespace { //anonymous inline bool doesExists (const std::string& name) { struct stat buffer; return (stat (name.c_str(), &buffer) == 0); } class SpeedTreeInOp : public Foundry::Katana::GeolibOp { public: static void setup(Foundry::Katana::GeolibSetupInterface &interface) { interface.setThreading( Foundry::Katana::GeolibSetupInterface::ThreadModeConcurrent); } static void cook(Foundry::Katana::GeolibCookInterface &interface) { if (interface.atRoot()) { interface.stopChildTraversal(); } // Look for a 'c' Op argument, representing an element in the // hierarchy leading to the base scene graph location that will // contain the spheres FnAttribute::GroupAttribute cGrpAttr = interface.getOpArg("c"); if (cGrpAttr.isValid()) { const int64_t numChildren = cGrpAttr.getNumberOfChildren(); if (numChildren != 1) { // We expected exactly one child attribute in 'c', if it's not // the case we notify the user with an error Foundry::Katana::ReportError(interface, "Unsupported attributes convention."); interface.stopChildTraversal(); return; } const std::string childName = FnAttribute::DelimiterDecode(cGrpAttr.getChildName(0)); FnAttribute::GroupAttribute childArgs = cGrpAttr.getChildByIndex(0); // Create a child location using the attribute name and forwarding // the hierarchy information interface.createChild(childName, "", childArgs); // Ignore other arguments as we've already found the 'c' group return; } // Look for a 'leaf' Op argument FnAttribute::GroupAttribute leaf = interface.getOpArg("leaf"); if (!leaf.isValid()) { FnAttribute::StringAttribute srtFileAttr = interface.getOpArg("srtFile"); std::string srtFilePath = srtFileAttr.getValue(); std::string abcProxyPath = srtFilePath.substr(0,srtFilePath.find_last_of('.'))+".abc"; if (doesExists(abcProxyPath)) { interface.setAttr("proxies.viewer.Proxy_Op0.opType", FnAttribute::StringAttribute("AlembicIn")); interface.setAttr("proxies.viewer.Proxy_Op0.opArgs.fileName", FnAttribute::StringAttribute(abcProxyPath)); } FnAttribute::IntAttribute useGlobalMotionAttr = interface.getOpArg("useGlobalMotion"); FnAttribute::FloatAttribute currentFrameAttr = interface.getOpArg("currentFrame"); FnAttribute::IntAttribute enableMotionBlurAttr = interface.getOpArg("enableMotionBlur"); FnAttribute::Attribute motionSamplesAttr = interface.getOpArg("motionSamples"); FnAttribute::FloatAttribute fpsAttr = interface.getOpArg("fps"); FnAttribute::FloatAttribute globalFrequencyAttr = interface.getOpArg("globalFrequency"); FnAttribute::FloatAttribute gustFrequencyAttr = interface.getOpArg("gustFrequency"); FnAttribute::FloatAttribute windSpeedAttr = interface.getOpArg("windSpeed"); FnAttribute::FloatAttribute windDirectionxAttr = interface.getOpArg("windDirection.x"); FnAttribute::FloatAttribute windDirectionyAttr = interface.getOpArg("windDirection.y"); FnAttribute::FloatAttribute windDirectionzAttr = interface.getOpArg("windDirection.z"); FnAttribute::IntAttribute windTypeAttr = interface.getOpArg("windType"); FnAttribute::IntAttribute LODTypeAttr = interface.getOpArg("LODType"); FnAttribute::IntAttribute LODSmoothTypeAttr = interface.getOpArg("LODSmoothType"); FnAttribute::Attribute speedKeyFrameAttr = interface.getOpArg("speedKeyFrame"); FnAttribute::Attribute speedResponseTimeAttr = interface.getOpArg("speedResponseTime"); FnAttribute::Attribute speedKeyValueAttr = interface.getOpArg("speedKeyValue"); FnAttribute::Attribute direKeyFrameFrameAttr = interface.getOpArg("direKeyFrame"); FnAttribute::Attribute direResponseTimeAttr = interface.getOpArg("direResponseTime"); FnAttribute::Attribute direKeyValueAttr = interface.getOpArg("direKeyValue"); interface.setAttr("rendererProcedural.args.srtFile", srtFileAttr); interface.setAttr("rendererProcedural.args.useGlobalMotion", useGlobalMotionAttr); interface.setAttr("rendererProcedural.args.currentFrame", currentFrameAttr); interface.setAttr("rendererProcedural.args.enableMotionBlur", enableMotionBlurAttr); interface.setAttr("rendererProcedural.args.motionSamples", motionSamplesAttr); interface.setAttr("rendererProcedural.args.fps", fpsAttr); interface.setAttr("rendererProcedural.args.globalFrequency", globalFrequencyAttr); interface.setAttr("rendererProcedural.args.gustFrequency", gustFrequencyAttr); interface.setAttr("rendererProcedural.args.windSpeed", windSpeedAttr); interface.setAttr("rendererProcedural.args.windDirection_x", windDirectionxAttr); interface.setAttr("rendererProcedural.args.windDirection_y", windDirectionyAttr); interface.setAttr("rendererProcedural.args.windDirection_z", windDirectionzAttr); interface.setAttr("rendererProcedural.args.windType", windTypeAttr); interface.setAttr("rendererProcedural.args.LODType", LODTypeAttr); interface.setAttr("rendererProcedural.args.LODSmoothType", LODSmoothTypeAttr); interface.setAttr("rendererProcedural.args.speedKeyFrame", speedKeyFrameAttr); interface.setAttr("rendererProcedural.args.speedResponseTime", speedResponseTimeAttr); interface.setAttr("rendererProcedural.args.speedKeyValue", speedKeyValueAttr); interface.setAttr("rendererProcedural.args.direKeyFrame", direKeyFrameFrameAttr); interface.setAttr("rendererProcedural.args.direResponseTime", direResponseTimeAttr); interface.setAttr("rendererProcedural.args.direKeyValue", direKeyValueAttr); interface.setAttr("type", FnAttribute::StringAttribute("renderer procedural")); interface.setAttr("rendererProcedural.procedural", FnAttribute::StringAttribute("speedtree_procedural")); interface.setAttr("rendererProcedural.node", FnAttribute::StringAttribute("speedtree_procedural")); // Suppress Katana outputting automatic args for the camera interface.setAttr("rendererProcedural.includeCameraInfo", FnAttribute::StringAttribute("None")); // classic, scenegraphAttr, typedArguments; default to typedArguments interface.setAttr("rendererProcedural.args.__outputStyle", FnAttribute::StringAttribute("typedArguments")); // Skip builtin parameters from Katana; the plugin doesn't use them interface.setAttr("rendererProcedural.args.__skipBuiltins", FnAttribute::IntAttribute(1)); // Don't worry about bounds, let the procedural take care of that for its children interface.setAttr("rendererProcedural.useInfiniteBounds", FnAttribute::IntAttribute(1)); interface.stopChildTraversal(); } } protected: }; DEFINE_GEOLIBOP_PLUGIN(SpeedTreeInOp) } // anonymous void registerPlugins() { REGISTER_PLUGIN(SpeedTreeInOp, "SpeedTreeIn", 0, 1); }
510345bc79a9d918e102eda61447da06b4a6d5ef
de24316f6319d7e62faa57115a92eece7f765fa1
/src/mesh3.cpp
b7ccf3e75f8eeb7de8b93a6447b90af972b5c853
[ "MIT" ]
permissive
PeterZhouSZ/mandoline
bbfd048dca6e3cb01b60a323b8a68268d1d8342a
79438c5b210a2ca4b9f72cbfd2879a9ae6a665da
refs/heads/master
2023-05-22T06:55:28.676188
2021-03-31T14:47:17
2021-03-31T14:47:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
22,188
cpp
mesh3.cpp
#include "mandoline/mesh3.hpp" #include <mtao/iterator/enumerate.hpp> #include <mtao/geometry/bounding_box.hpp> #include <mtao/geometry/volume.h> #include <mtao/logging/logger.hpp> #include <mtao/geometry/mesh/halfedge.hpp> #include <mtao/geometry/prune_vertices.hpp> #include <mtao/geometry/mesh/separate_elements.hpp> #include <mtao/geometry/kdtree.hpp> #include <mtao/iterator/range.hpp> #include <igl/winding_number.h> #include "mandoline/diffgeo_utils.hpp" #include "mandoline/proto_util.hpp" #include "mandoline/operators/interpolation3.hpp" #include "mandoline/operators/boundary3.hpp" #include "mandoline/operators/volume3.hpp" #include "mandoline/operators/masks.hpp" namespace mandoline { size_t CutCellMesh<3>::cell_size() const { return m_exterior_grid.num_cells() + m_cells.size(); } size_t CutCellMesh<3>::cut_face_size() const { return m_faces.size(); } size_t CutCellMesh<3>::num_cells() const { return m_exterior_grid.num_cells() + num_cut_cells(); } size_t CutCellMesh<3>::cut_cell_size() const { return m_cells.size(); } size_t CutCellMesh<3>::num_cut_cells() const { return m_cells.size(); } size_t CutCellMesh<3>::face_size() const { return m_exterior_grid.num_faces() + cut_face_size(); } size_t CutCellMesh<3>::num_faces() const { return m_exterior_grid.num_faces() + cut_face_size(); } size_t CutCellMesh<3>::num_cut_faces() const { return m_faces.size(); } bool CutCellMesh<3>::is_cut_face(size_t index) const { return index < num_cut_faces(); } bool CutCellMesh<3>::is_cut_cell(int index) const { return index >= 0 && index < m_cells.size(); } bool CutCellMesh<3>::is_exterior_cell(int index) const { return index >= 0 && index >= m_cells.size(); } bool CutCellMesh<3>::is_mesh_face(int idx) const { return m_mesh_cut_faces.find(idx) != m_mesh_cut_faces.end(); } auto CutCellMesh<3>::cell_volumes() const -> VecX { return operators::cell_volumes(*this); } auto CutCellMesh<3>::face_centroids() const -> mtao::ColVecs3d { /* VecX V(cell_size()); V.topRows(StaggeredGrid::cell_size()).array() = dx().prod(); */ mtao::ColVecs3d ret(3, m_faces.size()); auto Vs = vertices(); for (auto &&[i, f] : mtao::iterator::enumerate(m_faces)) { auto v = ret.col(i); v.setZero(); int count = 0; for (auto &&ind : f.indices) { for (auto &&j : ind) { v += Vs.col(j); count++; } } if (count > 0) { v /= count; } } auto r = exterior_grid().boundary_centroids(); return mtao::eigen::hstack(ret, r); } auto CutCellMesh<3>::cell_centroids() const -> mtao::ColVecs3d { /* VecX V(cell_size()); V.topRows(StaggeredGrid::cell_size()).array() = dx().prod(); */ mtao::ColVecs3d face_brep_cents(3, face_size()); auto Vs = vertices(); for (auto &&[i, f] : mtao::iterator::enumerate(m_faces)) { face_brep_cents.col(i) = f.brep_centroid(Vs); //face_brep_cents.col(i) = f.brep_volume(Vs) * f.brep_centroid(Vs); } mtao::ColVecs3d V(3, cell_size()); V.setZero(); auto vols = cell_volumes(); for (auto &&[k, c] : mtao::iterator::enumerate(m_cells)) { V.col(k) = c.moment(face_brep_cents); //V.col(k) = c.moment(face_brep_cents) / vols(k); } exterior_grid().cell_centroids(V); return V; } auto CutCellMesh<3>::dual_vertices() const -> ColVecs { return cell_centroids(); } int CutCellMesh<3>::local_grid_cell_index(const VecCRef &p) const { auto [c, q] = StaggeredGrid::coord(p); if (!StaggeredGrid::cell_grid().valid_index(c)) { return -1; } return -1; } int CutCellMesh<3>::world_grid_cell_index(const VecCRef &p) const { return local_grid_cell_index(vertex_grid().local_coord(p)); } std::vector<std::set<int>> CutCellMesh<3>::cell_faces() const { std::vector<std::set<int>> ret(m_cells.size()); std::transform(m_cells.begin(), m_cells.end(), ret.begin(), [](auto &&V) { std::set<int> ret; std::transform(V.begin(), V.end(), std::inserter(ret, ret.end()), [](auto &&v) { return std::get<0>(v); }); return ret; }); return ret; } std::set<int> CutCellMesh<3>::cell_faces(int index) const { auto &V = m_cells.at(index); std::set<int> ret; std::transform(V.begin(), V.end(), std::inserter(ret, ret.end()), [](auto &&v) { return std::get<0>(v); }); return ret; } void CutCellMesh<3>::write(const std::string &prefix) const { GOOGLE_PROTOBUF_VERIFY_VERSION; std::stringstream ss; auto CS = StaggeredGrid::cell_shape(); { ss << prefix << "." << CS[0] << "_" << CS[1] << "_" << CS[2]; ss << ".cutmesh"; } //std::cout << "Output filename: " << ss.str() << std::endl; std::ofstream ofs(ss.str(), std::ios::binary); protobuf::CutMeshProto cmp; serialize(cmp); cmp.SerializeToOstream(&ofs); } std::vector<bool> CutCellMesh<3>::boundary_faces() const { std::vector<bool> ret(m_faces.size(), false); for (auto &&[m, _] : m_mesh_cut_faces) { ret[m] = true; } return ret; } std::vector<int> CutCellMesh<3>::regions(bool boundary_sign_regions) const { std::vector<int> ret(cell_size(), 1); if (boundary_sign_regions) { for (auto &&[idx, c] : mtao::iterator::enumerate(m_cells)) { Edge counts{ { 0, 0 } };// 1 -1 for (auto &&[f, b] : c) { if (is_mesh_face(f)) { counts[b ? 0 : 1]++; } } if (counts[0] + counts[1] > 0) { if (counts[0] > counts[1]) { ret[idx] = 2; } else { ret[idx] = 3; } } } } else { for (int i = 0; i < m_cells.size(); ++i) { ret[i] = m_cells[i].region; } for (auto &&[c, r] : m_adaptive_grid_regions) { ret[c] = r; } } return ret; } std::vector<std::array<std::set<int>, 2>> CutCellMesh<3>::face_regions() const { auto R = regions(); std::copy(R.begin(), R.end(), std::ostream_iterator<int>(std::cout, ",")); std::vector<std::array<std::set<int>, 2>> ret(*std::max_element(R.begin(), R.end()) + 1); for (auto &&[cidx, c] : mtao::iterator::enumerate(cells())) { for (auto &&[fidx, s] : c) { auto &f = faces()[fidx]; int region = R[cidx]; auto &rset = ret[region]; if (f.is_mesh_face()) { rset[s ? 0 : 1].insert(fidx); } } } return ret; } std::vector<std::array<std::set<int>, 2>> CutCellMesh<3>::orig_face_regions() const { auto R = face_regions(); std::vector<std::array<std::set<int>, 2>> ret(R.size()); for (auto &&[Fsp, OFsp] : mtao::iterator::zip(R, ret)) { for (auto &&[Fs, OFs] : mtao::iterator::zip(Fsp, OFsp)) { for (auto &&f : Fs) { assert(faces()[f].is_mesh_face()); OFs.insert(faces()[f].as_face_id()); } } } return ret; } mtao::ColVecs3d CutCellMesh<3>::region_centroids() const { //delay dividing by 3 until the very end... auto R = orig_face_regions(); mtao::ColVecs3d Cs(3, origF().cols()); mtao::VecXd vols(origF().cols()); for (int i = 0; i < Cs.cols(); ++i) { auto f = origF().col(i); auto c = Cs.col(i); mtao::Mat3d A; for (int j = 0; j < 3; ++j) { A.col(j) = origV().col(f(j)); } vols(i) = A.determinant(); c = vols(i) * A.rowwise().sum(); } mtao::ColVecs3d C(3, R.size()); mtao::VecXd V(R.size()); C.setZero(); V.setZero(); for (auto &&[rid, rp] : mtao::iterator::enumerate(R)) { auto c = C.col(rid); auto &&v = V(rid); for (auto &&nf : rp[1]) { c -= Cs.col(nf); v -= vols(nf); } for (auto &&pf : rp[0]) { c += Cs.col(pf); v += vols(pf); } } V = (V.array().abs() > 1e-8).select(V, 1); //TODO: handle outside boundaries of the grid using the adaptive grid! auto bb = bbox(); double gv = bb.sizes().prod(); mtao::Vec3d gc = 1.5 * (bb.min() + bb.min()) * gv; C.col(0) += gc; V(0) += gv; for (int i = 0; i < C.cols(); ++i) { C.col(i) /= 3 * V(i); } return C; } CutCellMesh<3> CutCellMesh<3>::from_file(const std::string &filename) { return from_proto(filename); } void CutCellMesh<3>::serialize(protobuf::CutMeshProto &cmp) const { protobuf::serialize(origin(), *cmp.mutable_origin()); protobuf::serialize(dx(), *cmp.mutable_dx()); protobuf::serialize(vertex_shape(), *cmp.mutable_shape()); for (int i = 0; i < cut_vertex_size(); ++i) { protobuf::serialize(cut_vertex(i), *cmp.add_vertices()); } // TODO: Add back in after upgrading proto /* for(int i = 0; i < cut_edge_size(); ++i) { protobuf::serialize(m_cut_edges.col(i),*cmp.add_edges()); } */ for (int i = 0; i < m_origV.cols(); ++i) { protobuf::serialize(m_origV.col(i), *cmp.add_origv()); } for (int i = 0; i < m_origF.cols(); ++i) { protobuf::serialize(m_origF.col(i), *cmp.add_origf()); } for (auto &&f : m_faces) { f.serialize(*cmp.add_faces()); } for (auto &&c : m_cells) { c.serialize(*cmp.add_cells()); } for (auto &&i : m_folded_faces) { cmp.add_foldedfaces(i); } auto &&mf = *cmp.mutable_mesh_faces(); for (auto &&[idx, bmf] : m_mesh_cut_faces) { auto &b = mf[idx]; b.set_parent_id(bmf.parent_fid); for (int j = 0; j < bmf.barys.cols(); ++j) { protobuf::serialize(bmf.barys.col(j), *b.add_barycentric_coordinates()); } } { auto &cmap = *cmp.mutable_cubes(); for (auto &&[c, cell] : m_exterior_grid.cells()) { cell.serialize(cmap[c]); } auto &rmap = *cmp.mutable_cube_regions(); for (auto &&[a, b] : m_adaptive_grid_regions) { rmap[a] = b; } } } CutCellMesh<3> CutCellMesh<3>::from_proto(const std::string &filename) { std::ifstream ifs(filename, std::ios::binary); if (ifs.good()) { protobuf::CutMeshProto cmp; if (cmp.ParseFromIstream(&ifs)) { return from_proto(cmp); } } return {}; } CutCellMesh<3> CutCellMesh<3>::from_proto(const protobuf::CutMeshProto &cmp) { mtao::Vec3d o, dx; std::array<int, 3> s; o = protobuf::deserialize(cmp.origin()); dx = protobuf::deserialize(cmp.dx()); protobuf::deserialize(cmp.shape(), s); //s should be the vertex shape CutCellMesh<3> ret = CutCellMesh<3>::StaggeredGrid(GridType(s, dx, o)); //ret.m_face_volumes.resize(20); ret.m_cut_vertices.resize(cmp.vertices().size()); for (int i = 0; i < ret.cut_vertex_size(); ++i) { protobuf::deserialize(cmp.vertices(i), ret.m_cut_vertices[i]); } // TODO: Add back in after updating proto /* ret.m_cut_edges.resize(2,cmp.edges().size()); for(int i = 0; i < ret.cut_edge_size(); ++i) { ret.m_cut_edges.col(i) = protobuf::deserialize(cmp.edges(i)); } */ ret.m_origV.resize(3, cmp.origv().size()); for (int i = 0; i < ret.m_origV.cols(); ++i) { ret.m_origV.col(i) = protobuf::deserialize(cmp.origv(i)); } ret.m_origF.resize(3, cmp.origf().size()); for (int i = 0; i < ret.m_origF.cols(); ++i) { ret.m_origF.col(i) = protobuf::deserialize(cmp.origf(i)); } ret.m_faces.resize(cmp.faces().size()); for (int i = 0; i < cmp.faces().size(); ++i) { ret.m_faces[i] = CutFace<3>::from_proto(cmp.faces(i)); ret.m_faces[i].update_mask(ret.cut_vertices(), ret.vertex_grid()); } ret.m_cells.resize(cmp.cells().size()); for (int i = 0; i < cmp.cells().size(); ++i) { ret.m_cells[i] = CutCell::from_proto(cmp.cells(i)); } std::copy(cmp.foldedfaces().begin(), cmp.foldedfaces().end(), std::inserter(ret.m_folded_faces, ret.m_folded_faces.end())); for (auto &&[idx, btf] : cmp.mesh_faces()) { int pid = btf.parent_id(); size_t bssize = btf.barycentric_coordinates_size(); mtao::ColVecs3d B(3, bssize); for (int i = 0; i < bssize; ++i) { B.col(i) = protobuf::deserialize(btf.barycentric_coordinates(i)); } ret.m_mesh_cut_faces[idx] = { B, pid }; } for (auto &&[a, b] : cmp.cubes()) { ret.m_exterior_grid.m_cells[a] = AdaptiveGrid::Cell::from_proto(b); } ret.m_exterior_grid.make_faces(); for (auto &&[a, b] : cmp.cube_regions()) { ret.m_adaptive_grid_regions[a] = b; } return ret; } std::array<mtao::ColVecs2d, 3> CutCellMesh<3>::compute_subVs() const { auto V = vertices(); std::array<mtao::ColVecs2d, 3> subVs; for (int d = 0; d < 3; ++d) { int n0 = (d + 1) % 3; int n1 = (d + 2) % 3; auto &&subV = subVs[d]; subV.resize(2, V.cols()); subV.row(0) = V.row(n0); subV.row(1) = V.row(n1); } return subVs; } std::tuple<mtao::ColVecs3d, mtao::ColVecs3i> CutCellMesh<3>::triangulate_face(int face_index) const { mtao::logging::warn() << "Inefficient use of triangulation! try caching your triangulations"; std::array<mtao::ColVecs2d, 3> subVs = compute_subVs(); auto [V, F] = m_faces[face_index].triangulate(subVs, true); if (V.cols() > 0) { return { vertex_grid().world_coord(V), F }; } else { return { mtao::ColVecs3d{}, F }; } } void CutCellMesh<3>::triangulate_faces(bool add_verts) { std::array<mtao::ColVecs2d, 3> subVs = compute_subVs(); int i = 0; #pragma omp parallel for for (i = 0; i < m_faces.size(); ++i) { auto &&face = m_faces[i]; face.cache_triangulation(subVs, add_verts); } } mtao::VecXd CutCellMesh<3>::dual_edge_lengths() const { return operators::dual_edge_lengths(*this); } auto CutCellMesh<3>::face_volumes(bool from_triangulation) const -> VecX { return operators::face_volumes(*this, from_triangulation); } mtao::VecXd CutCellMesh<3>::mesh_face_mask() const { return operators::mesh_face_mask(*this); } std::set<int> CutCellMesh<3>::grid_boundary_faces() const { return operators::grid_boundary_faces(*this); } mtao::VecXd CutCellMesh<3>::primal_hodge2() const { return operators::primal_hodge2(*this); } mtao::VecXd CutCellMesh<3>::dual_hodge2() const { return operators::dual_hodge2(*this); } mtao::VecXd CutCellMesh<3>::dual_hodge3() const { return operators::dual_hodge3(*this); } mtao::VecXd CutCellMesh<3>::primal_hodge3() const { return operators::primal_hodge3(*this); } Eigen::SparseMatrix<double> CutCellMesh<3>::trilinear_matrix() const { return operators::trilinear_matrix(*this); } Eigen::SparseMatrix<double> CutCellMesh<3>::face_grid_volume_matrix() const { return operators::face_grid_volume_matrix(*this); } Eigen::SparseMatrix<double> CutCellMesh<3>::barycentric_matrix() const { return operators::barycentric_matrix(*this); } Eigen::SparseMatrix<double> CutCellMesh<3>::face_barycentric_volume_matrix() const { return operators::face_barycentric_volume_matrix(*this); } Eigen::SparseMatrix<double> CutCellMesh<3>::boundary(bool include_grid_boundary_faces) const { return operators::boundary(*this, include_grid_boundary_faces); } Eigen::SparseMatrix<double> CutCellMesh<3>::face_boundary() const { Eigen::SparseMatrix<double> B(edge_size(), face_size()); /* auto trips = m_exterior_grid.face_boundary_triplets(m_edges.size()); auto g = exterior_grid().grid(); for(auto&& c: cells()) { int region = c.region; for(auto&& [fidx,s]: c) { auto& f = faces()[fidx]; if(f.is_axial_face()) { int a = cell_shape()[f.as_axial_axis()]; int v = f.as_axial_coord(); if(v > 0 && v < a) { trips.emplace_back(fidx,c.index, s?1:-1); } } else { trips.emplace_back(fidx,c.index, s?1:-1); } } } for(auto&& [fidx,f]: mtao::iterator::enumerate(faces())) { if(f.external_boundary) { auto [c,s] = *f.external_boundary; trips.emplace_back(fidx,g.get(c), s?-1:1); } } B.setFromTriplets(trips.begin(),trips.end()); */ return B; } auto CutCellMesh<3>::active_cell_mask() const -> GridDatab { auto mask = GridDatab::Constant(true, StaggeredGrid::cell_shape()); auto C = cell_centroids(); for (auto &&[i, cell] : mtao::iterator::enumerate(m_cells)) { auto cent = C.col(i); auto [c, q] = coord(cent); mask(c) = false; } return mask; } auto CutCellMesh<3>::active_cells() const -> std::set<coord_type> { auto C = cell_centroids(); std::set<coord_type> ret; for (auto &&[i, cell] : mtao::iterator::enumerate(m_cells)) { auto cent = C.col(i); auto [c, q] = coord(cent); ret.insert(c); } return ret; } size_t CutCellMesh<3>::active_cell_count() const { return active_cells().size(); } std::tuple<mtao::ColVecs3d, mtao::ColVecs3i> CutCellMesh<3>::triangulated_cell(int idx, bool use_base, bool use_flap) const { if (is_cut_cell(idx)) { std::vector<mtao::ColVecs3d> mVs; std::vector<mtao::ColVecs3i> mFs; for (auto &&[fidx, b] : m_cells[idx]) { bool is_flap = m_folded_faces.find(fidx) != m_folded_faces.end(); bool is_base = !is_flap; if ((use_flap && is_flap) || (use_base && !is_flap)) { auto &tri = m_faces[fidx].triangulation; mtao::ColVecs3d V; mtao::ColVecs3i F; if (tri) { F = *tri; auto &vert = m_faces[fidx].triangulated_vertices; if (vert) { V = *vert; } } else { std::tie(V, F) = triangulate_face(fidx); } if (!b) { auto tmp = F.row(0).eval(); F.row(0) = F.row(1); F.row(1) = tmp; } mVs.emplace_back(std::move(V)); mFs.emplace_back(std::move(F)); } } return { mtao::eigen::hstack_iter(mVs.begin(), mVs.end()), mtao::eigen::hstack_iter(mFs.begin(), mFs.end()) }; /* if(mFs.size() > 0) { return {mtao::eigen::hstack_iter(mVs.begin(),mVs.end()),mtao::eigen::hstack_iter(mFs.begin(),mFs.end())}; if(mVs.size() > 0) { return {mtao::eigen::hstack_iter(mVs.begin(),mVs.end()),mtao::eigen::hstack_iter(mFs.begin(),mFs.end())}; } else { return {{},mtao::eigen::hstack_iter(mFs.begin(),mFs.end())}; } } */ } else { if (use_base) { return { mtao::ColVecs3d{}, m_exterior_grid.triangulated(idx) }; } } return {}; } std::tuple<mtao::ColVecs3d, mtao::ColVecs3i> CutCellMesh<3>::compact_triangulated_cell(int cell_index) const { auto [V, F] = triangulated_cell(cell_index, true, true); return mtao::geometry::mesh::compactify(mtao::eigen::hstack(vertices(), V), F); } std::tuple<mtao::ColVecs3d, mtao::ColVecs3i> CutCellMesh<3>::compact_triangulated_face(int face_index, bool flip) const { auto &f = m_faces[face_index]; if (!f.triangulation) { mtao::logging::warn() << "Triangulate mesh first!"; return {}; } else { mtao::ColVecs3d V; mtao::ColVecs3i F; if (f.triangulated_vertices) { std::tie(V, F) = mtao::geometry::mesh::compactify(mtao::eigen::hstack(vertices(), vertex_grid().world_coord(*f.triangulated_vertices)), *f.triangulation); } else { std::tie(V, F) = mtao::geometry::mesh::compactify(vertices(), *f.triangulation); } if (flip) { auto R = F.row(0).eval(); F.row(0) = F.row(1); F.row(1) = R; } return {V,F}; } } auto CutCellMesh<3>::cells_by_grid_cell() const -> std::map<coord_type, std::set<int>> { std::map<coord_type, std::set<int>> R; for (auto &&[i, c] : mtao::iterator::enumerate(cells())) { R[c.grid_cell].insert(i); } return R; } std::set<int> CutCellMesh<3>::cells_in_grid_cell(const coord_type &c) const { std::set<int> R; for (auto &&[i, cell] : mtao::iterator::enumerate(cells())) { if (cell.grid_cell == c) { R.insert(i); } } return R; } int CutCellMesh<3>::get_cell_index(const VecCRef &p) const { auto v = vertex_grid().local_coord(p); //check if its in an adaptive grid cell, tehn we can just use that cell // if the grid returns -2 we pass that through if (int ret = m_exterior_grid.get_cell_index(v); ret != -1) { if (ret == -2) { mtao::logging::warn() << "Point lies outside the grid"; } return ret; } else { auto [c, q] = vertex_grid().coord(p); auto cell_indices = cells_in_grid_cell(c); auto V = vertices(); for (auto &&ci : cell_indices) { auto &&cell = cells().at(ci); if (cell.contains(V, faces(), p)) { std::cout << std::endl; return ci; } } //TODO //if I haven't returned yet then either this ccm is bad //or i'm too close to an edge. lets not assume that for now mtao::logging::warn() << "There are CCM in this grid cell but I failed to find it!" << c[0] << " " << c[1] << " " << c[2]; } return -1; } auto CutCellMesh<3>::edges() const -> Edges { return Base::edges(); } }// namespace mandoline
a9aac2aac5f7790ffb1908111c9008ef10a7c701
dede18db20fd47c3059bcbf74562e8773096821e
/advent/2018/1_day/xmas2.cpp
69982535de4a0c4230248c50495cc57391dc51a6
[]
no_license
conradoboeira/CP
a70232d916c04d81c93f84de70afb2f252cff4ad
675b098a1c62c7d9bcfa5d8d9a2d7e359b24eef2
refs/heads/master
2020-03-31T19:55:21.417786
2020-02-18T03:56:40
2020-02-18T03:56:40
152,518,258
1
0
null
null
null
null
UTF-8
C++
false
false
603
cpp
xmas2.cpp
#include <iostream> #include <vector> using namespace std; bool vec_handler(int freq, vector<int> &vec){ int i; for(i = 0; i < vec.size(); i ++){ if( vec[i] == freq) return true; } vec.push_back(freq); return false; } int main(){ int freq, val, i; freq = 0; vector <int> freq_vec, val_vec; while(cin>>val) val_vec.push_back(val); i = 0; while(true){ if(i >= val_vec.size()) i = 0; freq += val_vec[i]; if(vec_handler(freq, freq_vec)) break; i ++; } cout << freq << endl; }
979f74b9f7062f566f8e90da14e7659aecdaf621
5a7f86738e996e54c0614feabda805bdd7e4ecfe
/Ball.h
c632ee1569395f7c195fe73a0a6945eed9522af5
[]
no_license
Robin-Works/Pong
022e8e9209f4cae105ea533c869796044a830c65
6ce142b6fefbd72dd024780382060e70f410e97c
refs/heads/main
2023-03-25T22:34:19.039426
2021-03-23T20:27:39
2021-03-23T20:27:39
350,840,950
0
0
null
null
null
null
UTF-8
C++
false
false
1,103
h
Ball.h
#ifndef BALL_H #define BALL_H #include "Texture.h" #include "Collider.h" #include <iostream> #include <sstream> #include "Particle.h" class Ball { public: static const int BALL_WIDTH = 16; static const int BALL_HEIGHT = 16; static const int DOT_VEL = 5; Ball(int x, int y); ~Ball(); void render(); void handleEvents(SDL_Event &e); void move(); void setPlayerCount(int players); int getPlayerCount(); bool hitLeftWall(); bool hitRightWall(); private: int mPosX; int mPosY; int mVelX; int mVelY; bool mLeftWall, mRightWall; int mPlayerCount; Texture mBallTexture; SDL_Rect clipRect; Collider *mCollider; Texture mScoreTexture; int mScore; bool updateScoreTexture; static const int mNumParticles = 20; Particle* mParticles[mNumParticles]; SDL_Color mPColor; void createParticles(const std::string &name, const std::string &path); void renderParticles(const std::string &name, const std::string &path); }; #endif
aca5a78b6ebff56c17ee128bf4fc47a22039d34b
c274a8d9d44b0dc52537f01b39e99ba57e780450
/CS205Project/build-UIDesign2-Desktop_Qt_5_14_1_MinGW_64_bit-Debug/ui_museummain.h
b502bacd6a1a64e7d4ed3ce6fe93723a3c9e1d63
[]
no_license
nelsomic/CS205
e2db52408dfed2f879a06e9eea0634a3d02c6e1d
567e09ff051d91b6d2422b22d3660a74e72d222a
refs/heads/master
2021-05-20T14:22:44.874165
2020-05-08T00:50:18
2020-05-08T00:50:18
252,329,956
0
0
null
2020-04-02T01:53:25
2020-04-02T01:53:25
null
UTF-8
C++
false
false
10,036
h
ui_museummain.h
/******************************************************************************** ** Form generated from reading UI file 'museummain.ui' ** ** Created by: Qt User Interface Compiler version 5.14.1 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ #ifndef UI_MUSEUMMAIN_H #define UI_MUSEUMMAIN_H #include <QtCore/QVariant> #include <QtWidgets/QApplication> #include <QtWidgets/QDialog> #include <QtWidgets/QGridLayout> #include <QtWidgets/QHBoxLayout> #include <QtWidgets/QLabel> #include <QtWidgets/QPushButton> #include <QtWidgets/QWidget> QT_BEGIN_NAMESPACE class Ui_MuseumMain { public: QLabel *label; QLabel *logoMM; QWidget *layoutWidget; QGridLayout *gridLayout; QLabel *mName1; QLabel *description1; QLabel *image1_1; QLabel *image2_1; QLabel *image3_1; QLabel *mName2; QLabel *description2; QLabel *image1_2; QLabel *image2_2; QLabel *image3_2; QLabel *mName3; QLabel *description3; QLabel *image1_3; QLabel *image2_3; QLabel *image3_3; QPushButton *visit1; QPushButton *visit2; QPushButton *visit3; QWidget *layoutWidget1; QHBoxLayout *horizontalLayout; QPushButton *homeButton; QPushButton *mListButton; QPushButton *itemsViewedButton; QPushButton *myCommentsButton; QPushButton *accountButton; void setupUi(QDialog *MuseumMain) { if (MuseumMain->objectName().isEmpty()) MuseumMain->setObjectName(QString::fromUtf8("MuseumMain")); MuseumMain->resize(820, 600); label = new QLabel(MuseumMain); label->setObjectName(QString::fromUtf8("label")); label->setGeometry(QRect(10, 10, 291, 61)); QFont font; font.setFamily(QString::fromUtf8("Avenir Next Condensed")); font.setPointSize(25); font.setItalic(false); label->setFont(font); logoMM = new QLabel(MuseumMain); logoMM->setObjectName(QString::fromUtf8("logoMM")); logoMM->setGeometry(QRect(700, 0, 111, 71)); layoutWidget = new QWidget(MuseumMain); layoutWidget->setObjectName(QString::fromUtf8("layoutWidget")); layoutWidget->setGeometry(QRect(10, 110, 791, 481)); gridLayout = new QGridLayout(layoutWidget); gridLayout->setObjectName(QString::fromUtf8("gridLayout")); gridLayout->setContentsMargins(0, 0, 0, 0); mName1 = new QLabel(layoutWidget); mName1->setObjectName(QString::fromUtf8("mName1")); QFont font1; font1.setFamily(QString::fromUtf8("Skia")); font1.setPointSize(20); mName1->setFont(font1); gridLayout->addWidget(mName1, 0, 0, 1, 1); description1 = new QLabel(layoutWidget); description1->setObjectName(QString::fromUtf8("description1")); gridLayout->addWidget(description1, 1, 0, 1, 1); image1_1 = new QLabel(layoutWidget); image1_1->setObjectName(QString::fromUtf8("image1_1")); gridLayout->addWidget(image1_1, 1, 1, 1, 1); image2_1 = new QLabel(layoutWidget); image2_1->setObjectName(QString::fromUtf8("image2_1")); gridLayout->addWidget(image2_1, 1, 2, 1, 1); image3_1 = new QLabel(layoutWidget); image3_1->setObjectName(QString::fromUtf8("image3_1")); gridLayout->addWidget(image3_1, 1, 3, 1, 1); mName2 = new QLabel(layoutWidget); mName2->setObjectName(QString::fromUtf8("mName2")); mName2->setFont(font1); gridLayout->addWidget(mName2, 2, 0, 1, 1); description2 = new QLabel(layoutWidget); description2->setObjectName(QString::fromUtf8("description2")); gridLayout->addWidget(description2, 3, 0, 1, 1); image1_2 = new QLabel(layoutWidget); image1_2->setObjectName(QString::fromUtf8("image1_2")); gridLayout->addWidget(image1_2, 3, 1, 1, 1); image2_2 = new QLabel(layoutWidget); image2_2->setObjectName(QString::fromUtf8("image2_2")); gridLayout->addWidget(image2_2, 3, 2, 1, 1); image3_2 = new QLabel(layoutWidget); image3_2->setObjectName(QString::fromUtf8("image3_2")); gridLayout->addWidget(image3_2, 3, 3, 1, 1); mName3 = new QLabel(layoutWidget); mName3->setObjectName(QString::fromUtf8("mName3")); mName3->setFont(font1); gridLayout->addWidget(mName3, 4, 0, 1, 1); description3 = new QLabel(layoutWidget); description3->setObjectName(QString::fromUtf8("description3")); gridLayout->addWidget(description3, 5, 0, 1, 1); image1_3 = new QLabel(layoutWidget); image1_3->setObjectName(QString::fromUtf8("image1_3")); gridLayout->addWidget(image1_3, 5, 1, 1, 1); image2_3 = new QLabel(layoutWidget); image2_3->setObjectName(QString::fromUtf8("image2_3")); gridLayout->addWidget(image2_3, 5, 2, 1, 1); image3_3 = new QLabel(layoutWidget); image3_3->setObjectName(QString::fromUtf8("image3_3")); gridLayout->addWidget(image3_3, 5, 3, 1, 1); visit1 = new QPushButton(layoutWidget); visit1->setObjectName(QString::fromUtf8("visit1")); gridLayout->addWidget(visit1, 0, 1, 1, 1); visit2 = new QPushButton(layoutWidget); visit2->setObjectName(QString::fromUtf8("visit2")); gridLayout->addWidget(visit2, 2, 1, 1, 1); visit3 = new QPushButton(layoutWidget); visit3->setObjectName(QString::fromUtf8("visit3")); gridLayout->addWidget(visit3, 4, 1, 1, 1); layoutWidget1 = new QWidget(MuseumMain); layoutWidget1->setObjectName(QString::fromUtf8("layoutWidget1")); layoutWidget1->setGeometry(QRect(10, 70, 791, 32)); horizontalLayout = new QHBoxLayout(layoutWidget1); horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); horizontalLayout->setContentsMargins(0, 0, 0, 0); homeButton = new QPushButton(layoutWidget1); homeButton->setObjectName(QString::fromUtf8("homeButton")); horizontalLayout->addWidget(homeButton); mListButton = new QPushButton(layoutWidget1); mListButton->setObjectName(QString::fromUtf8("mListButton")); horizontalLayout->addWidget(mListButton); itemsViewedButton = new QPushButton(layoutWidget1); itemsViewedButton->setObjectName(QString::fromUtf8("itemsViewedButton")); horizontalLayout->addWidget(itemsViewedButton); myCommentsButton = new QPushButton(layoutWidget1); myCommentsButton->setObjectName(QString::fromUtf8("myCommentsButton")); horizontalLayout->addWidget(myCommentsButton); accountButton = new QPushButton(layoutWidget1); accountButton->setObjectName(QString::fromUtf8("accountButton")); horizontalLayout->addWidget(accountButton); QWidget::setTabOrder(homeButton, mListButton); QWidget::setTabOrder(mListButton, itemsViewedButton); QWidget::setTabOrder(itemsViewedButton, myCommentsButton); QWidget::setTabOrder(myCommentsButton, accountButton); QWidget::setTabOrder(accountButton, visit1); QWidget::setTabOrder(visit1, visit2); QWidget::setTabOrder(visit2, visit3); retranslateUi(MuseumMain); QMetaObject::connectSlotsByName(MuseumMain); } // setupUi void retranslateUi(QDialog *MuseumMain) { MuseumMain->setWindowTitle(QCoreApplication::translate("MuseumMain", "Dialog", nullptr)); label->setText(QCoreApplication::translate("MuseumMain", "<h1>Museum Main</h1>", nullptr)); logoMM->setText(QString()); mName1->setText(QCoreApplication::translate("MuseumMain", "Museum 1", nullptr)); description1->setText(QCoreApplication::translate("MuseumMain", "Description", nullptr)); image1_1->setText(QCoreApplication::translate("MuseumMain", "image 1", nullptr)); image2_1->setText(QCoreApplication::translate("MuseumMain", "image 2", nullptr)); image3_1->setText(QCoreApplication::translate("MuseumMain", "image 3", nullptr)); mName2->setText(QCoreApplication::translate("MuseumMain", "Museum 2", nullptr)); description2->setText(QCoreApplication::translate("MuseumMain", "Description", nullptr)); image1_2->setText(QCoreApplication::translate("MuseumMain", "Image 1", nullptr)); image2_2->setText(QCoreApplication::translate("MuseumMain", "Image 2", nullptr)); image3_2->setText(QCoreApplication::translate("MuseumMain", "Image 3", nullptr)); mName3->setText(QCoreApplication::translate("MuseumMain", "Museum 3", nullptr)); description3->setText(QCoreApplication::translate("MuseumMain", "Description", nullptr)); image1_3->setText(QCoreApplication::translate("MuseumMain", "Image 1", nullptr)); image2_3->setText(QCoreApplication::translate("MuseumMain", "Image 2", nullptr)); image3_3->setText(QCoreApplication::translate("MuseumMain", "Image 3", nullptr)); visit1->setText(QCoreApplication::translate("MuseumMain", "Visit Museum1", nullptr)); visit2->setText(QCoreApplication::translate("MuseumMain", "Visit Museum 2", nullptr)); visit3->setText(QCoreApplication::translate("MuseumMain", "Visit Museum 3", nullptr)); homeButton->setText(QCoreApplication::translate("MuseumMain", "Home", nullptr)); mListButton->setText(QCoreApplication::translate("MuseumMain", "Museum list", nullptr)); itemsViewedButton->setText(QCoreApplication::translate("MuseumMain", "Items Viewed", nullptr)); myCommentsButton->setText(QCoreApplication::translate("MuseumMain", "My Comments", nullptr)); accountButton->setText(QCoreApplication::translate("MuseumMain", "Account", nullptr)); } // retranslateUi }; namespace Ui { class MuseumMain: public Ui_MuseumMain {}; } // namespace Ui QT_END_NAMESPACE #endif // UI_MUSEUMMAIN_H
fd299776d38e29ab0c74621ebede75d0a95c1e3e
514412f8372198e3a55c13aa0f889a624e8893e3
/src/core/Entity.hh
e16c7f3265652c52f843936b6bfb26f5681c6534
[ "MIT" ]
permissive
eddiehoyle/sevengine
ade6c37cb5a4eaf9814fadb1a92ab1f7e6a3c9f8
4f5bd2b16b1179784c831ef8a0d57ccecee0a92e
refs/heads/master
2020-07-12T18:41:20.753290
2017-04-04T05:36:27
2017-04-04T05:36:27
68,410,565
1
0
null
null
null
null
UTF-8
C++
false
false
600
hh
Entity.hh
// // Created by Eddie Hoyle on 4/09/16. // #ifndef SEV_ENTITY_HH #define SEV_ENTITY_HH #include "Transform.hh" #include "Mesh.hh" #include "Rect.hh" #include "BoundingBox.hh" #include "event/AbstractEvent.hh" class Entity { public: Entity(); virtual ~Entity(); virtual void listen( AbstractEvent* event ); virtual void update( double elapsed ); virtual void draw(); // Shader* getShader() const; Mesh* getModel() const; Transform* getTransform() const; private: Mesh* m_model; Transform* m_transform; Quad* m_rect; }; #endif //SEV_ENTITY_HH
df066a4022a449ab5413f4b7c8d1021ce70395b8
cb6f5a87532f363887514bbe2ac7186b0ceb4c68
/lab_04/exceptions/loadexception.h
b862a129036b8d8b8164c26341bf72571f6c9404
[]
no_license
AnaNek/Object_oriented_programming
e1e4a2e983c6eb7c6e445d9a7554de952a396485
65dbd5013fa1bab030d419b55287815f59cc1677
refs/heads/master
2022-12-11T14:10:25.371138
2020-08-27T17:57:31
2020-08-27T17:57:31
290,791,761
2
0
null
null
null
null
UTF-8
C++
false
false
959
h
loadexception.h
#ifndef IOEXCEPTION_H #define IOEXCEPTION_H #include "baseexception.h" class OpenFileException : public BaseException { public: explicit OpenFileException() : BaseException(msg) {} explicit OpenFileException(const std::string& message) : BaseException(msg + message) {} private: static constexpr const char* msg = "Opening file error"; }; class CloseFileException : public BaseException { public: explicit CloseFileException() : BaseException(msg) {} explicit CloseFileException(const std::string& message) : BaseException(msg + message) {} private: static constexpr const char* msg = "Closing file error"; }; class ReadFileException : public BaseException { public: explicit ReadFileException() : BaseException(msg) {} explicit ReadFileException(const std::string& message) : BaseException(msg + message) {} private: static constexpr const char* msg = "Reading file error"; }; #endif
7044adbd4de0b1ba6033854bb52aef327600a5e0
7ef665a3d59f743e1f14dcc10cf9cda7774625d8
/pre.parser.imp.cpp
c5d00a4b996818c4fd7f7fe86c589002caf40c19
[]
no_license
muradkarakas/SodiumCompiler
a3d3b0ac07f618cecd42bc59aea9e761a0146bfa
02428f1224ccd645a1b76b0d8a625dd4ce5279e7
refs/heads/master
2022-11-09T01:38:13.757066
2020-06-26T21:45:02
2020-06-26T21:45:02
269,479,195
1
0
null
null
null
null
ISO-8859-13
C++
false
false
917
cpp
pre.parser.imp.cpp
/** * This file is part of Sodium Language project * * Copyright © 2020 Murad Karakaž <muradkarakas@gmail.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License v3.0 * as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * https://choosealicense.com/licenses/gpl-3.0/ */ #include "pch.h" using namespace Sodium; void preTokenDestructor( Token* token) { /*if (token) { if (token->tokenId == 1 && token->tokenCode != PRE_ENTER) { printf("\n%4d:", token->line); } if (token) { if (token->tokenCode == PRE_ENTER) { printf("\n%4d:", token->line); } else { printf("%.*s", token->tokenStrLength, token->tokenStr); } } }*/ }
4aaa9f8481420f9781c98de50b51b1e32b59bf90
c92c71071d3d6615765786ecf08386918c6a2349
/CodeForces/CF482-D1-B.cpp
45c3b99a4e6947cddd114782c3f7ed159d33e37a
[]
no_license
3agwa/CompetitiveProgramming
ef757ede03c00e4a47a1629cec2fe862cc7b871d
532eb309ffeb2901d1af90fc46ce7ad904f0cbc6
refs/heads/master
2021-01-19T22:16:49.231249
2019-03-12T17:13:50
2019-03-12T17:13:50
88,785,488
4
2
null
null
null
null
UTF-8
C++
false
false
3,626
cpp
CF482-D1-B.cpp
#include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define vll vector<ll> #define pii pair<int, int> #define vii vector<pii> #define vs vector<string> #define vb vector<bool> #define vi vector<int> #define vd vector<double> #define vvi vector< vector<int> > #define vvii vector< vector< pii > > #define ld long double #define mapii map<int, int> #define mapsi map<string, int> #define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++) #define rep(i, x, n) for(auto i = x; i<(ll)(n); i++) //#define INF LLONG_MAX #define all(v) ((v).begin()), ((v).end()) #define sz(v) ((int)((v).size())) #define pie acos(-1) #define mod(n,m) ((n % m + m) % m) #define eps (1e-9) #define reset(n, m) memset(n, m, sizeof n) #define endl '\n' #define output freopen("output.txt", "w", stdout) #define mp(x, y, z) {{x, y}, z} int arr[200001], tree[600000][2], lazy[600000]; void build(int node, int st, int en) { if (st > en) return; if (st == en) { tree[node][0] = arr[st]; return; } int mid = (st+en)/2; build(2*node, st, mid); build(2*node + 1, mid + 1, en); tree[node][0] = tree[2*node][0] & tree[2*node + 1][0]; } void update(int node, int st, int en, int shemal, int yemeen, int val) { if (lazy[node]) { tree[node][1] |= lazy[node]; if (st != en) { lazy[2*node] |= lazy[node]; lazy[2*node + 1] |= lazy[node]; } lazy[node] = 0; } if (st > en || st > yemeen || en < shemal) return; if (shemal <= st && en <= yemeen) { tree[node][1] |= val; if (st != en) lazy[2*node] |= val, lazy[2*node+1] |= val; return; } int mid = (st+en)/2; update(2*node, st, mid, shemal, yemeen, val); update(2*node+1, mid+1, en, shemal, yemeen, val); tree[node][1] = tree[2*node][1] | tree[2*node+1][1]; } int query_or(int node, int st, int en, int shemal, int yemeen) { if (lazy[node]) { tree[node][1] |= lazy[node]; if (st != en) { lazy[2*node] |= lazy[node]; lazy[2*node + 1] |= lazy[node]; } lazy[node] = 0; } if (st > en || st > yemeen || en < shemal) return 0; if (shemal <= st && en <= yemeen) return tree[node][1]; int mid = (st+en)/2; return query_or(2*node, st, mid, shemal, yemeen) | query_or(2*node + 1, mid + 1, en, shemal, yemeen); } int query_and(int node, int st, int en, int shemal, int yemeen) { if (st > en || st > yemeen || en < shemal) return INT_MAX; // kefaya copying conditions :) if (shemal <= st && en <= yemeen) return tree[node][0]; int mid = (st+en)/2; return query_and(2*node, st, mid, shemal, yemeen) & query_and(2*node + 1, mid + 1, en, shemal, yemeen); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; vector< pair< pii, int > > queries; rep(i, 0, m) { int x, y, z; cin >> x >> y >> z; queries.push_back(mp(x-1, y-1, z)); update(1, 0, n-1, x-1, y-1, z); } rep(i, 0, n) arr[i] = query_or(1, 0, n-1, i, i); build(1, 0, n-1); rep(i, 0, sz(queries)) { int x = queries[i].first.first, y = queries[i].first.second, z = queries[i].second; if (query_and(1, 0, n-1, x, y) != z) { cout << "NO"; return 0; } } cout << "YES\n"; rep(i, 0, n) cout << arr[i] << " "; return 0; }
4ba44ea9c6c36df5f1579de40df99980421de59a
e000dfb2e1ddfe62598da937d2e0d40d6efff61b
/venusmmi/app/Cosmos/Email/vapp_email_msg_list.cpp
3fccf64017e4f6edb5bbe0af170e4b9af3c38219
[]
no_license
npnet/KJX_K7
9bc11e6cd1d0fa5996bb20cc6f669aa087bbf592
35dcd3de982792ae4d021e0e94ca6502d1ff876e
refs/heads/master
2023-02-06T09:17:46.582670
2020-12-24T02:55:29
2020-12-24T02:55:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
126,625
cpp
vapp_email_msg_list.cpp
/***************************************************************************** * Copyright Statement: * -------------------- * This software is protected by Copyright and the information contained * herein is confidential. The software may not be copied and the information * contained herein may not be used or disclosed except with the written * permission of MediaTek Inc. (C) 2005 * * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. * * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. * * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). * *****************************************************************************/ /***************************************************************************** * * Filename: * --------- * Vapp_email_msg_list.cpp * * Project: * -------- * * * Description: * ------------ * * * Author: * ------- * ------- * *============================================================================ * HISTORY * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! *---------------------------------------------------------------------------- *---------------------------------------------------------------------------- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! *============================================================================ ****************************************************************************/ #include "MMI_features.h" #include "Vapp_Email_Main.h" #include "Vapp_Email_Msg_List.h" #include "Vapp_Email_Msg_View.h" #include "vapp_email_util.h" extern "C" { #include "emailsrvgprot.h" #include "emailappmem.h" /* long tapped feedback */ #include "vfx_adp_device.h" #include "mmi_rp_app_cosmos_global_def.h" } /* exter "C" */ extern EMAIL_SRV_HANDLE gEmailSrvHandle; extern VfxU32 gScrnWidth; extern VfxU32 gScrnHeight; typedef struct { srv_email_fldr_create_info_struct info; EMAIL_FLDR_HANDLE handle; } email_app_curr_fldr_info_struct; static email_app_curr_fldr_info_struct gCurrFldrInfo; void vapp_email_reset_curr_fldr_info(void) { if (gCurrFldrInfo.handle != EMAIL_FLDR_INVALID_ID) { srv_email_fldr_destroy(gCurrFldrInfo.handle); } memset(&gCurrFldrInfo, 0, sizeof(email_app_curr_fldr_info_struct)); } void vapp_email_reset_fldr_info(EMAIL_ACCT_ID acctId) { if (gCurrFldrInfo.info.acct_id == acctId) { vapp_email_reset_curr_fldr_info(); } } void VappEmailMsgListMenuCell::onCreateElements() { VcpListMenuCellTripleTextFrameEx::onCreateElements(); VfxBool isUnread = VFX_FALSE; VappEmailMsgListProvider *contentProvider = (VappEmailMsgListProvider*)(((VcpListMenu*)getMenu())->getContentProvider()); srv_email_fldr_msg_info_struct *msgInfo = (srv_email_fldr_msg_info_struct*)get_ctrl_buffer(sizeof(srv_email_fldr_msg_info_struct)); U32 msgCount = 1; srv_email_fldr_get_msg_list(contentProvider->getFldrHandle(), (U32)m_index, &msgCount, msgInfo); if (!(msgInfo->flag & EMAIL_MSG_FLAG_SEEN)) { isUnread = VFX_TRUE; } free_ctrl_buffer(msgInfo); if (isUnread == VFX_TRUE) { VFX_OBJ_CREATE(m_iconImage, VfxImageFrame, this); m_iconImage->setResId(IMG_EMAIL_FTO_UNREAD_ID); m_iconImage->setPos(0, 0); m_iconImage->setSize(EMAIL_MSG_LIST_UNREAD_ICON_SIZE, EMAIL_MSG_LIST_UNREAD_ICON_SIZE); } } //void VappEmailMsgListMenuCell::onCloseElements() //{ // VcpListMenuCellTripleTextFrameEx::onCloseElements(); //} // // //void VappEmailMsgListMenuCell::onLayoutElements() //{ // VcpListMenuCellTripleTextFrameEx::onLayoutElements(); //} // // void VappEmailMsgListMenuCell::onUpdateElements() { VcpListMenuCellTripleTextFrameEx::onUpdateElements(); VfxBool isUnread = VFX_FALSE; VappEmailMsgListProvider *contentProvider = (VappEmailMsgListProvider*)(((VcpListMenu*)getMenu())->getContentProvider()); srv_email_fldr_msg_info_struct *msgInfo = (srv_email_fldr_msg_info_struct*)get_ctrl_buffer(sizeof(srv_email_fldr_msg_info_struct)); U32 msgCount = 1; srv_email_fldr_get_msg_list(contentProvider->getFldrHandle(), (U32)m_index, &msgCount, msgInfo); if (!(msgInfo->flag & EMAIL_MSG_FLAG_SEEN)) { isUnread = VFX_TRUE; } free_ctrl_buffer(msgInfo); if (isUnread == VFX_TRUE) { if (m_iconImage == NULL) { VFX_OBJ_CREATE(m_iconImage, VfxImageFrame, this); m_iconImage->setPos(0, 0); m_iconImage->setSize(EMAIL_MSG_LIST_UNREAD_ICON_SIZE, EMAIL_MSG_LIST_UNREAD_ICON_SIZE); } m_iconImage->setResId(IMG_EMAIL_FTO_UNREAD_ID); } else { if (m_iconImage != NULL) { VFX_OBJ_CLOSE(m_iconImage); m_iconImage = NULL; } } } VappEmailMsgListPage::VappEmailMsgListPage( EMAIL_ACCT_ID acctID, EMAIL_FLDR_ID fldrID, srv_email_fldr_type_enum fldrType, VfxBool showTitleBarBtn) :m_listProvider(NULL), mToolbar(NULL), m_listMenu(NULL), m_titleBar(NULL), m_loadingPopup(NULL), m_acctID(acctID), m_fldrID(fldrID), m_fldrType(fldrType), m_index(0), m_multiSelection(VFX_FALSE), m_allSelected(VFX_FALSE), m_reqID(0), m_TBType(MSG_LIST_PAGE_TB_TYPE_NONE), m_showTitleBarBtn(showTitleBarBtn), m_bgTitleBar(NULL), m_longTappedMsgID(EMAIL_MSG_INVALID_ID), m_selectPopup(NULL), m_deleteConfirmPopup(NULL), m_isDeleteOutboxMsg(VFX_FALSE), m_errorPopup(NULL), m_needUpdate(VFX_FALSE) { } VappEmailMsgListPage::VappEmailMsgListPage() :m_listProvider(NULL), mToolbar(NULL), m_listMenu(NULL), m_titleBar(NULL), m_loadingPopup(NULL), m_acctID(EMAIL_ACCT_INVALID_ID), m_fldrID(EMAIL_FLDR_INVALID_ID), m_fldrType(SRV_EMAIL_FLDR_TYPE_INVALID), m_index(0), m_multiSelection(VFX_FALSE), m_allSelected(VFX_FALSE), m_reqID(0), m_TBType(MSG_LIST_PAGE_TB_TYPE_NONE), m_showTitleBarBtn(VFX_FALSE), m_bgTitleBar(NULL), m_longTappedMsgID(EMAIL_MSG_INVALID_ID), m_selectPopup(NULL), m_deleteConfirmPopup(NULL), m_isDeleteOutboxMsg(VFX_FALSE), m_errorPopup(NULL), m_needUpdate(VFX_FALSE) { } void VappEmailMsgListPage::onInit() { MMI_TRACE(MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_PAGE_INIT); VfxPage::onInit(); VappEmailMgr *emailMgrInst = VappEmailMgr::getInstance(); emailMgrInst->enterAcct(m_acctID); VFX_OBJ_CREATE(m_listMenu, VcpListMenu, this); VFX_OBJ_CREATE_EX(m_listProvider, VappEmailMsgListProvider, this, (m_acctID, m_fldrID)); VfxSize pageSize = getSize(); m_listMenu->setRect(0, 0, pageSize.width, pageSize.height); m_listMenu->setCellStyle(VCP_LIST_MENU_CELL_STYLE_TRIPLE_TEXT_EX); m_listMenu->setMenuMode(VCP_LIST_MENU_MODE_NORMAL, VFX_TRUE); m_listMenu->m_signalItemTapped.connect(this, &VappEmailMsgListPage::onItemClick); m_listMenu->m_signalItemLongTapped.connect(this, &VappEmailMsgListPage::onItemLongTapped); m_listProvider->setMenu(m_listMenu); m_listMenu->setAlignParent( VFX_FRAME_ALIGNER_MODE_SIDE, VFX_FRAME_ALIGNER_MODE_SIDE, VFX_FRAME_ALIGNER_MODE_SIDE, VFX_FRAME_ALIGNER_MODE_SIDE); updateTitleBar(); updateToolbar(); emailMgrInst->m_signalFldrMsgNumChange.connect(this, &VappEmailMsgListPage::onFldrMsgNumChange); emailMgrInst->m_signalMsgChange.connect(this, &VappEmailMsgListPage::onMsgChange); emailMgrInst->m_signalAcctNwkDone.connect(this, &VappEmailMsgListPage::onAcctNwkDone); emailMgrInst->m_signalMsgDelete.connect(this, &VappEmailMsgListPage::onMsgDelete); emailMgrInst->m_signalAcctStateChange.connect(this, &VappEmailMsgListPage::onAcctStateChange); /* only for outbox */ emailMgrInst->m_signalMsgStateChange.connect(this, &VappEmailMsgListPage::onMsgStateChange); registerKeyHandler(VFX_KEY_CODE_ARROW_LEFT); registerKeyHandler(VFX_KEY_CODE_ARROW_RIGHT); } void VappEmailMsgListPage::onDeinit() { MMI_TRACE(MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_PAGE_DEINIT); VfxPage::onDeinit(); VappEmailMgr::getInstance()->editFldrStop(m_acctID, m_fldrID); VappEmailMgr::getInstance()->exitAcct(m_acctID); } void VappEmailMsgListPage::onEnter(VfxBool isBackward) { VfxPage::onEnter(isBackward); if (m_needUpdate) { updatePage(); m_needUpdate = VFX_FALSE; } if (isBackward) { if (m_showTitleBarBtn) { m_titleBar->getLeftButton()->setState(VCP_IMAGE_BUTTON_STATE_NORMAL); m_titleBar->getRightButton()->setState(VCP_IMAGE_BUTTON_STATE_NORMAL); } } } void VappEmailMsgListPage::onEntered() { m_listMenu->setContentProvider(m_listProvider); } VfxBool VappEmailMsgListPage::onKeyInput(VfxKeyEvent &event) { if (m_showTitleBarBtn) { /* follow BD's rule, handle key event down and long press */ if (event.specialKeyFlag == 0 && (event.type == VFX_KEY_EVENT_TYPE_DOWN || event.type == VFX_KEY_EVENT_TYPE_LONG_PRESS || event.type == VFX_KEY_EVENT_TYPE_REPEAT)) { if (event.keyCode == VFX_KEY_CODE_ARROW_LEFT) { onTitleBarLBtnClick(NULL, 0); } else if (event.keyCode == VFX_KEY_CODE_ARROW_RIGHT) { onTitleBarRBtnClick(NULL, 0); } } if (event.specialKeyFlag == 0) { if (event.type == VFX_KEY_EVENT_TYPE_DOWN) { if (event.keyCode == VFX_KEY_CODE_ARROW_LEFT) { m_titleBar->getLeftButton()->setState(VCP_IMAGE_BUTTON_STATE_PRESSED); } else if (event.keyCode == VFX_KEY_CODE_ARROW_RIGHT) { m_titleBar->getRightButton()->setState(VCP_IMAGE_BUTTON_STATE_PRESSED); } } else if (event.type == VFX_KEY_EVENT_TYPE_UP) { if (event.keyCode == VFX_KEY_CODE_ARROW_LEFT) { m_titleBar->getLeftButton()->setState(VCP_IMAGE_BUTTON_STATE_NORMAL); } else if (event.keyCode == VFX_KEY_CODE_ARROW_RIGHT) { m_titleBar->getRightButton()->setState(VCP_IMAGE_BUTTON_STATE_NORMAL); } } } } /* do not stop route key event to let other CP have opportunity to handle key event */ return VfxPage::onKeyInput(event); } void VappEmailMsgListPage::onBack() { MMI_TRACE(MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_PAGE_ON_BACK, m_fldrType); if (m_multiSelection == VFX_TRUE) { onTBClick(NULL, MSG_LIST_PAGE_TB_CANCEL); return; } if (m_fldrType == SRV_EMAIL_FLDR_TYPE_INBOX) { VappEmailMgr::getInstance()->exitAcct(m_acctID); VfxPage::onBack(); } else { onMoreFolderClick(NULL, MSG_LIST_PAGE_MORE_BOXES_TYPE_INBOX); } } void VappEmailMsgListPage::onRotate(const VfxScreenRotateParam &param) { if (param.rotateTo == VFX_SCR_ROTATE_TYPE_90 || param.rotateTo == VFX_SCR_ROTATE_TYPE_270 || param.rotateTo == VFX_SCR_ROTATE_TYPE_LANDSCAPE) { gScrnWidth = LCD_HEIGHT; gScrnHeight = LCD_WIDTH; } else { gScrnWidth = LCD_WIDTH; gScrnHeight = LCD_HEIGHT; } //updateTitleBarText(); } void VappEmailMsgListPage::updatePage() { updateMsgList(); updateTitleBar(); updateToolbar(); } void VappEmailMsgListPage::resetPage( EMAIL_ACCT_ID acctID, EMAIL_FLDR_ID fldrID, srv_email_fldr_type_enum fldrType) { MMI_TRACE(MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_PAGE_RESET_PAGE, acctID, fldrID, fldrType); if (m_acctID != acctID) { VappEmailMgr::getInstance()->exitAcct(m_acctID); VappEmailMgr::getInstance()->enterAcct(acctID); m_acctID = acctID; } m_fldrID = fldrID; m_fldrType = fldrType; m_isDeleteOutboxMsg = VFX_FALSE; m_listProvider->resetProvider(m_acctID, m_fldrID); m_needUpdate = VFX_FALSE; } void VappEmailMsgListPage::updateTitleBar() { MMI_TRACE(MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_UPDATE_TITLEBAR); if (m_titleBar == NULL) { VFX_OBJ_CREATE_EX(m_titleBar, VappEmailMsgListTitleBar, this, (m_showTitleBarBtn)); setTopBar(m_titleBar); } updateTitleBarText(); VcpImageButton *btn = NULL; btn = m_titleBar->getLeftButton(); if (btn != NULL) { btn->m_signalClicked.connect(this, &VappEmailMsgListPage::onTitleBarLBtnClick); } btn = m_titleBar->getRightButton(); if (btn != NULL) { btn->m_signalClicked.connect(this, &VappEmailMsgListPage::onTitleBarRBtnClick); } } void VappEmailMsgListPage::onErrorPopupClicked(VfxObject*, VfxId) { m_errorPopup = NULL; } void VappEmailMsgListPage::updateTitleBarText() { if (m_titleBar == NULL) { return; } VfxWString tbText; VfxWString numString; VfxWString numtext; VfxU32 unreadMsgNum; VfxU32 msgNum; srv_email_result_enum result = SRV_EMAIL_RESULT_SUCC; m_listProvider->getMsgNum(unreadMsgNum, msgNum); MMI_TRACE(MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_UPDATE_TITLEBAR_TEXT, m_acctID, unreadMsgNum, msgNum); numString += VFX_WSTR(" "); numString += VFX_WSTR_RES(STR_EMAIL_FTO_LEFT_PARENTHESES); switch (m_fldrType) { case SRV_EMAIL_FLDR_TYPE_INBOX: { tbText.loadFromRes(STR_GLOBAL_INBOX); if (unreadMsgNum == 0) { numtext.format("%d", msgNum); } else { numtext.format("%d/%d", unreadMsgNum, msgNum); } break; } case SRV_EMAIL_FLDR_TYPE_OUTBOX: { tbText.loadFromRes(STR_GLOBAL_OUTBOX); numtext.format("%d", msgNum); break; } case SRV_EMAIL_FLDR_TYPE_SENT: { tbText.loadFromRes(STR_EMAIL_SENT_ID); numtext.format("%d", msgNum); break; } case SRV_EMAIL_FLDR_TYPE_DRAFT: { tbText.loadFromRes(STR_GLOBAL_DRAFTS); numtext.format("%d", msgNum); break; } case SRV_EMAIL_FLDR_TYPE_REMOTE: { EMAIL_ACCT_HANDLE acctHandle = EMAIL_ACCT_INVALID_HANDLE; srv_email_acct_folder_struct *fldrInfo = NULL; do { result = srv_email_acct_create(gEmailSrvHandle, &acctHandle); if (result != SRV_EMAIL_RESULT_SUCC) { break; } result = srv_email_acct_open(acctHandle, m_acctID); if (result != SRV_EMAIL_RESULT_SUCC) { break; } if (result != SRV_EMAIL_RESULT_SUCC) { break; } fldrInfo = (srv_email_acct_folder_struct*)get_ctrl_buffer(sizeof(srv_email_acct_folder_struct)); result = srv_email_acct_get_fldr_info( acctHandle, m_fldrID, fldrInfo); if (result != SRV_EMAIL_RESULT_SUCC) { break; } tbText.loadFromMem((VfxWChar*)(fldrInfo->folder_name)); } while(0); if (acctHandle != EMAIL_ACCT_INVALID_HANDLE) { srv_email_acct_destroy(acctHandle); } if (fldrInfo != NULL) { free_ctrl_buffer(fldrInfo); } if (unreadMsgNum == 0) { numtext.format("%d", msgNum); } else { numtext.format("%d/%d", unreadMsgNum, msgNum); } if (result != SRV_EMAIL_RESULT_SUCC) { VappEmailErrorPopup *errorPopup; VFX_OBJ_CREATE(errorPopup, VappEmailErrorPopup, getMainScr()); errorPopup->showErrorPopup(result); } break; } default: return; } numString += numtext; numString += VFX_WSTR_RES(STR_EMAIL_FTO_RIGHT_PARENTHESES); tbText += numString; VfxWString acctName; S32 acctNameLength = SRV_EMAIL_MAX_ACCT_NAME_LEN + 1; WCHAR *textCont = (WCHAR*)get_ctrl_buffer(acctNameLength * 2); result = srv_email_acct_get_name(m_acctID, textCont, acctNameLength); acctName.loadFromMem(textCont); free_ctrl_buffer(textCont); m_titleBar->updateTitleText(tbText, acctName); m_titleBar->updateButtons(m_showTitleBarBtn); if (result != SRV_EMAIL_RESULT_SUCC) { VappEmailErrorPopup *errorPopup; VFX_OBJ_CREATE(errorPopup, VappEmailErrorPopup, getMainScr()); errorPopup->showErrorPopup(result); } } void VappEmailMsgListPage::updateToolbar() { MMI_TRACE(MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_UPDATE_TOOLBAR, mToolbar, m_fldrType); if (mToolbar == NULL) { VFX_OBJ_CREATE(mToolbar, VcpToolBar, this); mToolbar->m_signalButtonTap.connect(this, &VappEmailMsgListPage::onTBClick); setBottomBar(mToolbar); } if (m_multiSelection == VFX_FALSE) { updateToolbarItems(); } } void VappEmailMsgListPage::updateToolbarItems() { switch (m_fldrType) { case SRV_EMAIL_FLDR_TYPE_INBOX: case SRV_EMAIL_FLDR_TYPE_REMOTE: { setInboxToolbar(); } break; case SRV_EMAIL_FLDR_TYPE_OUTBOX: { setOutboxToolbar(); } break; case SRV_EMAIL_FLDR_TYPE_SENT: { setSentToolbar(); } break; case SRV_EMAIL_FLDR_TYPE_DRAFT: { setDraftToolbar(); } break; default: return; } } EMAIL_MSG_ID VappEmailMsgListPage::getNextMsgID(EMAIL_MSG_ID currMsgID, VfxU32 &index, VfxU32 &total) { return m_listProvider->getNextMsgID(currMsgID, index, total); } EMAIL_MSG_ID VappEmailMsgListPage::getPrevMsgID(EMAIL_MSG_ID currMsgID, VfxU32 &index, VfxU32 &total) { return m_listProvider->getPrevMsgID(currMsgID, index, total); } void VappEmailMsgListPage::getMsgIndex(EMAIL_MSG_ID currMsgID, VfxU32 &index, VfxU32 &total) { m_listProvider->getMsgIndex(currMsgID, index, total); } void VappEmailMsgListPage::onMsgListUpdate() { updatePage(); } void VappEmailMsgListPage::generalAsyncCallback(srv_email_result_struct *result, EMAIL_REQ_ID req_id, void *user_data) { MMI_TRACE(MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_ASYNC_CALLBACK, result->result, result->major, result->minor); if (m_showTitleBarBtn) { m_titleBar->getLeftButton()->setState(VCP_IMAGE_BUTTON_STATE_NORMAL); m_titleBar->getRightButton()->setState(VCP_IMAGE_BUTTON_STATE_NORMAL); } closeLoading(); if (m_multiSelection) { m_multiSelection = VFX_FALSE; VappEmailMgr::getInstance()->editFldrStop(m_acctID, m_fldrID); } if (!result->result) { if (result->major == SRV_EMAIL_MAIL_ERROR) { VappEmailErrorPopup *errorPopup; VFX_OBJ_CREATE(errorPopup, VappEmailErrorPopup, getParent()); /* should also handle srv_email_result_struct */ errorPopup->showErrorPopup((srv_email_result_enum)result->minor); } return; } onMsgListUpdate(); } void VappEmailMsgListPage::providerUpdated(srv_email_result_enum result, VfxBool isDeleteMsg) { MMI_TRACE(MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_PROVIDER_UPDATED, result, isDeleteMsg); if (result == SRV_EMAIL_RESULT_SUCC) { onMsgListUpdate(); } else if (result == SRV_EMAIL_RESULT_WOULDBLOCK) { if (isDeleteMsg) { VfxWString text; text.loadFromRes(STR_GLOBAL_DELETING); showLoadingPopup(text.getBuf()); } m_listMenu->resetAllItems(VFX_TRUE); } else { VappEmailErrorPopup *errorPopup; VFX_OBJ_CREATE(errorPopup, VappEmailErrorPopup, getMainScr()); errorPopup->showErrorPopup(result); } } void VappEmailMsgListPage::showLoadingPopup(const VfxWChar *textPtr) { MMI_TRACE(MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MAIN_SHOW_LOADING); if (m_loadingPopup == NULL) { VFX_OBJ_CREATE(m_loadingPopup, VcpIndicatorPopup, this); m_loadingPopup->setInfoType(VCP_INDICATOR_POPUP_STYLE_ACTIVITY); VfxWString text; if (textPtr == NULL) { text.loadFromRes(STR_GLOBAL_LOADING); } else { text.loadFromMem(textPtr); } m_loadingPopup->setText(text); m_loadingPopup->setAutoDestory(VFX_FALSE); m_loadingPopup->show(VFX_TRUE); } } srv_email_result_enum VappEmailMsgListPage::setSingleMsgFlag() { return SRV_EMAIL_RESULT_SUCC; } void VappEmailMsgListPage::onFldrMsgNumChange(EMAIL_ACCT_ID acctID, EMAIL_FLDR_ID fldrID, VappEmailFldrMsgNumStruct numChange) { if (acctID != m_acctID || fldrID != m_fldrID) { return; } if (m_multiSelection == VFX_TRUE) { return; } if (getMainScr()->getTopPageId() != EMAIL_PAGE_TYPE_MSG_LIST) { m_needUpdate = VFX_TRUE; return; } updateTitleBar(); updateToolbar(); if (m_listMenu != NULL) { m_listMenu->resetAllItems(VFX_TRUE); if (m_isDeleteOutboxMsg && m_listProvider->getCount() == 0) { m_isDeleteOutboxMsg = VFX_FALSE; //onTBClick(NULL, MSG_LIST_PAGE_TB_RESEND); VfxWString tbText; if (VappEmailMgr::getInstance()->getAcctState(m_acctID) == VAPP_EMAIL_ACCT_STATE_NETWORK_SENDING || VappEmailMgr::getInstance()->getAcctState(m_acctID) == VAPP_EMAIL_ACCT_STATE_NETWORK_SEND_WAITING) { VappEmailMgr::getInstance()->cancelSendOutbox(m_acctID); tbText.loadFromRes(STR_EMAIL_FTO_RESEND_MAIL_ID); mToolbar->changeItem( MSG_LIST_PAGE_TB_RESEND, tbText, VfxResId(VCP_IMG_TOOL_BAR_COMMON_ITEM_SEND)); } } } } void VappEmailMsgListPage::onMsgChange(EMAIL_MSG_ID msgID, srv_email_om_notify_msg_struct) { if (srv_email_msg_id_to_acct_id(msgID) != m_acctID || srv_email_msg_id_to_fldr_id(msgID) != m_fldrID) { return; } /* it can be NULL entry Inbox when refreshing background if some message's state change */ if (m_listMenu != NULL) { /* list menu item count not change updateAllItems will be ok */ m_listMenu->resetAllItems(VFX_TRUE); } } void VappEmailMsgListPage::onAcctNwkDone(EMAIL_ACCT_ID acctID, VappEmailNwkDoneEnum operation, VappEmailResStruct result) { if (acctID != m_acctID) { return; } MMI_TRACE(MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_ACCT_NWK_DONE, acctID, operation, result.result); if (srv_email_fldr_id_to_fldr_type(m_acctID, m_fldrID) == SRV_EMAIL_FLDR_TYPE_OUTBOX) { m_listProvider->resetSendFailNum(); m_listMenu->resetAllItems(VFX_TRUE); } srv_email_fldr_type_enum fldrType = srv_email_fldr_id_to_fldr_type(m_acctID, m_fldrID); if (fldrType == SRV_EMAIL_FLDR_TYPE_SENT && m_multiSelection == VFX_TRUE) { return; } /* no need to update draft when account network done */ if (fldrType != SRV_EMAIL_FLDR_TYPE_DRAFT) { updateToolbar(); } } void VappEmailMsgListPage::onMsgStateChange(EMAIL_MSG_ID msgID, VappEmailMsgStateEnum msgState) { if (srv_email_msg_id_to_acct_id(msgID) != m_acctID || srv_email_msg_id_to_fldr_id(msgID) != m_fldrID) { return; } if (msgState == VAPP_EMAIL_MSG_STATE_NETWORK_SENDING) { /* close option menu or delete confirm popup when message's status changes to sending */ if (msgID == m_longTappedMsgID) { if (m_selectPopup != NULL) { VFX_OBJ_CLOSE(m_selectPopup); m_selectPopup = NULL; } if (m_deleteConfirmPopup != NULL) { VFX_OBJ_CLOSE(m_deleteConfirmPopup); m_deleteConfirmPopup = NULL; } m_longTappedMsgID = EMAIL_MSG_INVALID_ID; } } if (msgState == VAPP_EMAIL_MSG_STATE_NETWORK_SEND_FAIL) { if (m_listProvider != NULL) { m_listProvider->increaseSendFailNum(); } } if (m_listMenu != NULL) { m_listMenu->resetAllItems(VFX_TRUE); } } void VappEmailMsgListPage::onMsgDelete(EMAIL_MSG_ID msgID) { if (msgID == m_longTappedMsgID) { /* close option menu or delete confirm popup when message is delete by updating */ if (m_selectPopup != NULL) { VFX_OBJ_CLOSE(m_selectPopup); m_selectPopup = NULL; } if (m_deleteConfirmPopup != NULL) { VFX_OBJ_CLOSE(m_deleteConfirmPopup); m_deleteConfirmPopup = NULL; } m_longTappedMsgID = EMAIL_MSG_INVALID_ID; } if (srv_email_fldr_id_to_fldr_type(m_acctID, m_fldrID) == SRV_EMAIL_FLDR_TYPE_OUTBOX && m_errorPopup != NULL) { VFX_OBJ_CLOSE(m_errorPopup); m_errorPopup = NULL; } } void VappEmailMsgListPage::onAcctStateChange(EMAIL_ACCT_ID acctID, VappEmailAcctStateEnum state) { if (acctID != m_acctID) { return; } updateToolbar(); if (state == VAPP_EMAIL_ACCT_STATE_NETWORK_SEND_WAITING && m_listMenu != NULL) { m_listMenu->resetAllItems(VFX_TRUE); } } void VappEmailMsgListPage::setInboxToolbar() { if (m_TBType != MSG_LIST_PAGE_TB_TYPE_INBOX) { m_TBType = MSG_LIST_PAGE_TB_TYPE_INBOX; for (VfxU32 i = 0; i < MSG_LIST_PAGE_TB_TOTAL; i++) { mToolbar->removeItem(i); } VfxWString tbText; tbText.loadFromRes(STR_EMAIL_FTO_NEW_EMAIL_ID); mToolbar->addItem(MSG_LIST_PAGE_TB_NEW_MAIL, tbText, VfxResId(IMG_EMAIL_FTO_TB_NEW_MAIL)); tbText.loadFromRes(STR_GLOBAL_REFRESH); mToolbar->addItem(MSG_LIST_PAGE_TB_REFRESH, tbText, VfxResId(VCP_IMG_TOOL_BAR_COMMON_ITEM_REFRESH)); tbText.loadFromRes(STR_EMAIL_FTO_MAIL_BOXES_ID); mToolbar->addItem(MSG_LIST_PAGE_TB_MORE_FOLDERS, tbText, VfxResId(IMG_EMAIL_FTO_TB_MAILBOXES)); tbText.loadFromRes(STR_GLOBAL_DELETE); mToolbar->addItem(MSG_LIST_PAGE_TB_DELETE, tbText, VfxResId(IMG_EMAIL_FTO_DELETE)); tbText.loadFromRes(STR_GLOBAL_SORT); mToolbar->addItem(MSG_LIST_PAGE_TB_SORT, tbText, VfxResId(IMG_EMAIL_FTO_TB_SORT)); } mToolbar->setDisableItem(MSG_LIST_PAGE_TB_DELETE, VFX_FALSE); mToolbar->setDisableItem(MSG_LIST_PAGE_TB_SORT, VFX_FALSE); VfxWString tbText; if (VappEmailMgr::getInstance()->getAcctState(m_acctID) == VAPP_EMAIL_ACCT_STATE_NETWORK_REFRESHING || VappEmailMgr::getInstance()->getAcctState(m_acctID) == VAPP_EMAIL_ACCT_STATE_NETWORK_REFRESH_WAITING) { tbText.loadFromRes(STR_EMAIL_FTO_STOP_REFRESH_ID); mToolbar->changeItem( MSG_LIST_PAGE_TB_REFRESH, tbText, VfxResId(IMG_EMAIL_FTO_TB_STOP)); } else { tbText.loadFromRes(STR_GLOBAL_REFRESH); mToolbar->changeItem( MSG_LIST_PAGE_TB_REFRESH, tbText, VfxResId(VCP_IMG_TOOL_BAR_COMMON_ITEM_REFRESH)); } if(m_listProvider->getCount() == 0) { mToolbar->setDisableItem(MSG_LIST_PAGE_TB_SORT, VFX_TRUE); mToolbar->setDisableItem(MSG_LIST_PAGE_TB_DELETE, VFX_TRUE); } VappEmailStateEnum emailState; if (VappEmailMgr::getInstance()->isNetworkReady(emailState)) { mToolbar->setDisableItem(MSG_LIST_PAGE_TB_REFRESH, VFX_FALSE); } else { mToolbar->setDisableItem(MSG_LIST_PAGE_TB_REFRESH, VFX_TRUE); } } void VappEmailMsgListPage::setOutboxToolbar() { if (m_TBType != MSG_LIST_PAGE_TB_TYPE_OUTBOX) { m_TBType = MSG_LIST_PAGE_TB_TYPE_OUTBOX; for (VfxU32 i = 0; i < MSG_LIST_PAGE_TB_TOTAL; i++) { mToolbar->removeItem(i); } VfxWString tbText; tbText.loadFromRes(STR_EMAIL_FTO_NEW_EMAIL_ID); mToolbar->addItem(MSG_LIST_PAGE_TB_NEW_MAIL, tbText, VfxResId(IMG_EMAIL_FTO_TB_NEW_MAIL)); tbText.loadFromRes(STR_EMAIL_FTO_RESEND_MAIL_ID); mToolbar->addItem(MSG_LIST_PAGE_TB_RESEND, tbText, VfxResId(VCP_IMG_TOOL_BAR_COMMON_ITEM_SEND)); tbText.loadFromRes(STR_EMAIL_FTO_MAIL_BOXES_ID); mToolbar->addItem(MSG_LIST_PAGE_TB_MORE_FOLDERS, tbText, VfxResId(IMG_EMAIL_FTO_TB_MAILBOXES)); tbText.loadFromRes(STR_GLOBAL_DELETE); mToolbar->addItem(MSG_LIST_PAGE_TB_DELETE, tbText, VfxResId(IMG_EMAIL_FTO_DELETE)); } if(m_listProvider->getCount() == 0) { VfxWString tbText; tbText.loadFromRes(STR_EMAIL_FTO_RESEND_MAIL_ID); mToolbar->changeItem( MSG_LIST_PAGE_TB_RESEND, tbText, VfxResId(VCP_IMG_TOOL_BAR_COMMON_ITEM_SEND)); mToolbar->setDisableItem(MSG_LIST_PAGE_TB_RESEND, VFX_TRUE); mToolbar->setDisableItem(MSG_LIST_PAGE_TB_DELETE, VFX_TRUE); } else { mToolbar->setDisableItem(MSG_LIST_PAGE_TB_DELETE, VFX_FALSE); VappEmailStateEnum emailState; if (VappEmailMgr::getInstance()->isNetworkReady(emailState)) { mToolbar->setDisableItem(MSG_LIST_PAGE_TB_RESEND, VFX_FALSE); } else { mToolbar->setDisableItem(MSG_LIST_PAGE_TB_RESEND, VFX_TRUE); } VfxWString tbText; if (VappEmailMgr::getInstance()->getAcctState(m_acctID) == VAPP_EMAIL_ACCT_STATE_NETWORK_REFRESHING || VappEmailMgr::getInstance()->getAcctState(m_acctID) == VAPP_EMAIL_ACCT_STATE_NETWORK_REFRESH_WAITING) { #ifdef __MMI_EMAIL_IMAP_PUSH__ if (!VappEmailMgr::getInstance()->isPushRefreshing(m_acctID)) /* not disable resent when push refreshing */ #endif { mToolbar->setDisableItem(MSG_LIST_PAGE_TB_RESEND, VFX_TRUE); } } else { mToolbar->setDisableItem(MSG_LIST_PAGE_TB_RESEND, VFX_FALSE); if (VappEmailMgr::getInstance()->getAcctState(m_acctID) == VAPP_EMAIL_ACCT_STATE_NETWORK_SENDING || VappEmailMgr::getInstance()->getAcctState(m_acctID) == VAPP_EMAIL_ACCT_STATE_NETWORK_SEND_WAITING) { tbText.loadFromRes(STR_EMAIL_FTO_STOP_SEND_ID); mToolbar->changeItem( MSG_LIST_PAGE_TB_RESEND, tbText, VfxResId(IMG_EMAIL_FTO_TB_STOP)); } else { tbText.loadFromRes(STR_EMAIL_FTO_RESEND_MAIL_ID); mToolbar->changeItem( MSG_LIST_PAGE_TB_RESEND, tbText, VfxResId(VCP_IMG_TOOL_BAR_COMMON_ITEM_SEND)); } } } } void VappEmailMsgListPage::setSentToolbar() { if (m_TBType != MSG_LIST_PAGE_TB_TYPE_SENT) { m_TBType = MSG_LIST_PAGE_TB_TYPE_SENT; for (VfxU32 i = 0; i < MSG_LIST_PAGE_TB_TOTAL; i++) { mToolbar->removeItem(i); } VfxWString tbText; tbText.loadFromRes(STR_EMAIL_FTO_NEW_EMAIL_ID); mToolbar->addItem(MSG_LIST_PAGE_TB_NEW_MAIL, tbText, VfxResId(IMG_EMAIL_FTO_TB_NEW_MAIL)); tbText.loadFromRes(STR_GLOBAL_DELETE); mToolbar->addItem(MSG_LIST_PAGE_TB_DELETE, tbText, VfxResId(IMG_EMAIL_FTO_DELETE)); tbText.loadFromRes(STR_EMAIL_FTO_MAIL_BOXES_ID); mToolbar->addItem(MSG_LIST_PAGE_TB_MORE_FOLDERS, tbText, VfxResId(IMG_EMAIL_FTO_TB_MAILBOXES)); tbText.loadFromRes(STR_GLOBAL_SORT); mToolbar->addItem(MSG_LIST_PAGE_TB_SORT, tbText, VfxResId(IMG_EMAIL_FTO_TB_SORT)); } if(m_listProvider->getCount() == 0) { mToolbar->setDisableItem(MSG_LIST_PAGE_TB_SORT, VFX_TRUE); mToolbar->setDisableItem(MSG_LIST_PAGE_TB_DELETE, VFX_TRUE); } else { mToolbar->setDisableItem(MSG_LIST_PAGE_TB_SORT, VFX_FALSE); mToolbar->setDisableItem(MSG_LIST_PAGE_TB_DELETE, VFX_FALSE); } } void VappEmailMsgListPage::setDraftToolbar() { if (m_TBType != MSG_LIST_PAGE_TB_TYPE_DRAFT) { m_TBType = MSG_LIST_PAGE_TB_TYPE_DRAFT; for (VfxU32 i = 0; i < MSG_LIST_PAGE_TB_TOTAL; i++) { mToolbar->removeItem(i); } VfxWString tbText; tbText.loadFromRes(STR_EMAIL_FTO_NEW_EMAIL_ID); mToolbar->addItem(MSG_LIST_PAGE_TB_NEW_MAIL, tbText, VfxResId(IMG_EMAIL_FTO_TB_NEW_MAIL)); tbText.loadFromRes(STR_GLOBAL_DELETE); mToolbar->addItem(MSG_LIST_PAGE_TB_DELETE, tbText, VfxResId(IMG_EMAIL_FTO_DELETE)); tbText.loadFromRes(STR_EMAIL_FTO_MAIL_BOXES_ID); mToolbar->addItem(MSG_LIST_PAGE_TB_MORE_FOLDERS, tbText, VfxResId(IMG_EMAIL_FTO_TB_MAILBOXES)); tbText.loadFromRes(STR_GLOBAL_SORT); mToolbar->addItem(MSG_LIST_PAGE_TB_SORT, tbText, VfxResId(IMG_EMAIL_FTO_TB_SORT)); } if(m_listProvider->getCount() == 0) { mToolbar->setDisableItem(MSG_LIST_PAGE_TB_SORT, VFX_TRUE); mToolbar->setDisableItem(MSG_LIST_PAGE_TB_DELETE, VFX_TRUE); } else { mToolbar->setDisableItem(MSG_LIST_PAGE_TB_SORT, VFX_FALSE); mToolbar->setDisableItem(MSG_LIST_PAGE_TB_DELETE, VFX_FALSE); } } srv_email_result_enum VappEmailMsgListPage::getFldrIDandTypeByBtn(MsgListPageMoreBoxesTypeEnum btnType) { EMAIL_ACCT_HANDLE acctHandle = EMAIL_ACCT_INVALID_HANDLE; srv_email_result_enum result; EMAIL_FLDR_ID fldrIDArray[4]; S32 fldrCount = 4; do { result = srv_email_acct_create(gEmailSrvHandle, &acctHandle); if (result != SRV_EMAIL_RESULT_SUCC) { break; } result = srv_email_acct_open(acctHandle, m_acctID); result = srv_email_acct_get_fldr_id( acctHandle, SRV_EMAIL_ACCT_FLDR_TYPE_BASIC, 0, &fldrCount, fldrIDArray); if (result != SRV_EMAIL_RESULT_SUCC) { break; } switch (btnType) { case MSG_LIST_PAGE_MORE_BOXES_TYPE_INBOX: m_fldrType = SRV_EMAIL_FLDR_TYPE_INBOX; m_fldrID = fldrIDArray[0]; break; case MSG_LIST_PAGE_MORE_BOXES_TYPE_DRAFTS: m_fldrType = SRV_EMAIL_FLDR_TYPE_DRAFT; m_fldrID = fldrIDArray[3]; break; case MSG_LIST_PAGE_MORE_BOXES_TYPE_OUTBOX: m_fldrType = SRV_EMAIL_FLDR_TYPE_OUTBOX; m_fldrID = fldrIDArray[1]; break; case MSG_LIST_PAGE_MORE_BOXES_TYPE_SENT: m_fldrType = SRV_EMAIL_FLDR_TYPE_SENT; m_fldrID = fldrIDArray[2]; break; default: break; } } while(0); if (acctHandle != EMAIL_ACCT_INVALID_HANDLE) { srv_email_acct_destroy(acctHandle); } return result; } void VappEmailMsgListPage::updateMultiSelectToolbar() { VfxU32 checkedNum = m_listProvider->getCheckedItemNum(); if (checkedNum == 0) { mToolbar->setDisableItem(MSG_LIST_PAGE_TB_SELECT_DELETE, VFX_TRUE); } else { mToolbar->setDisableItem(MSG_LIST_PAGE_TB_SELECT_DELETE, VFX_FALSE); } if (checkedNum == m_listProvider->getCount()) { m_allSelected = VFX_TRUE; mToolbar->changeItem( MSG_LIST_PAGE_TB_SELECT_ALL, VFX_WSTR_RES(STR_GLOBAL_UNMARK_ALL), VCP_IMG_TOOL_BAR_COMMON_ITEM_UNSELECT_ALL); } else { m_allSelected = VFX_FALSE; mToolbar->changeItem( MSG_LIST_PAGE_TB_SELECT_ALL, VFX_WSTR_RES(STR_GLOBAL_MARK_ALL), VCP_IMG_TOOL_BAR_COMMON_ITEM_SELECT_ALL); } } void VappEmailMsgListPage::onTBClick(VfxObject *object, VfxId tbIndex) { MMI_TRACE(MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_TOOLBAR_CLICK, tbIndex, m_fldrType); m_listMenu->stopScrolling(); VfxRect bounds = getBounds(); switch (tbIndex) { case MSG_LIST_PAGE_TB_NEW_MAIL: { VappEmailMainScrn *mainScr = (VappEmailMainScrn*)getMainScr(); mainScr->launchComposer(m_acctID, EMAIL_MSG_INVALID_ID, VappEmailComp::EMAIL_MODE_NEW); } break; case MSG_LIST_PAGE_TB_REFRESH: { if (m_fldrType != SRV_EMAIL_FLDR_TYPE_INBOX && m_fldrType != SRV_EMAIL_FLDR_TYPE_REMOTE) { return; } if (VappEmailMgr::getInstance()->getEmailAppState() == VAPP_EMAIL_STATE_FLIGHT_MODE) { mmi_frm_nmgr_balloon( MMI_SCENARIO_ID_DEFAULT, MMI_EVENT_INFO_BALLOON, MMI_NMGR_BALLOON_TYPE_INFO, (WCHAR*)GetString(STR_GLOBAL_UNAVAILABLE_IN_FLIGHT_MODE)); return; } if (VappEmailMgr::getInstance()->getAcctState(m_acctID) == VAPP_EMAIL_ACCT_STATE_NETWORK_SENDING || VappEmailMgr::getInstance()->getAcctState(m_acctID) == VAPP_EMAIL_ACCT_STATE_NETWORK_SEND_WAITING) { mmi_frm_nmgr_balloon( MMI_SCENARIO_ID_DEFAULT, MMI_EVENT_INFO_BALLOON, MMI_NMGR_BALLOON_TYPE_INFO, (WCHAR*)GetString(STR_EMAIL_FTO_SENDING_CANNOT_REFRESH)); return; } VfxWString tbText; if (VappEmailMgr::getInstance()->getAcctState(m_acctID) == VAPP_EMAIL_ACCT_STATE_NETWORK_REFRESHING || VappEmailMgr::getInstance()->getAcctState(m_acctID) == VAPP_EMAIL_ACCT_STATE_NETWORK_REFRESH_WAITING) { VappEmailMgr::getInstance()->cancelAcctRefresh(m_acctID); tbText.loadFromRes(STR_GLOBAL_REFRESH); mToolbar->changeItem( MSG_LIST_PAGE_TB_REFRESH, tbText, VfxResId(VCP_IMG_TOOL_BAR_COMMON_ITEM_REFRESH)); } else { if (VappEmailMgr::getInstance()->refreshAcct(m_acctID) == VAPP_EMAIL_RES_WOULDBLOCK) { tbText.loadFromRes(STR_EMAIL_FTO_STOP_REFRESH_ID); mToolbar->changeItem( MSG_LIST_PAGE_TB_REFRESH, tbText, VfxResId(IMG_EMAIL_FTO_TB_STOP)); } else { /* popup */ } } } break; case MSG_LIST_PAGE_TB_MORE_FOLDERS: { srv_email_result_enum result = SRV_EMAIL_RESULT_SUCC; VcpCommandPopup *moreFolderPopup; VFX_OBJ_CREATE(moreFolderPopup, VcpCommandPopup, this); VfxWString text; text.loadFromRes(STR_EMAIL_FTO_MAIL_BOXES_ID); moreFolderPopup->setText(text); if (m_fldrType != SRV_EMAIL_FLDR_TYPE_INBOX) { text.loadFromRes(STR_GLOBAL_INBOX); moreFolderPopup->addItem(MSG_LIST_PAGE_MORE_BOXES_TYPE_INBOX, text); } if (m_fldrType != SRV_EMAIL_FLDR_TYPE_DRAFT) { text.loadFromRes(STR_GLOBAL_DRAFTS); moreFolderPopup->addItem(MSG_LIST_PAGE_MORE_BOXES_TYPE_DRAFTS, text); } if (m_fldrType != SRV_EMAIL_FLDR_TYPE_OUTBOX) { text.loadFromRes(STR_GLOBAL_OUTBOX); moreFolderPopup->addItem(MSG_LIST_PAGE_MORE_BOXES_TYPE_OUTBOX, text); } if (m_fldrType != SRV_EMAIL_FLDR_TYPE_SENT) { text.loadFromRes(STR_EMAIL_SENT_ID); moreFolderPopup->addItem(MSG_LIST_PAGE_MORE_BOXES_TYPE_SENT, text); } #ifdef __MMI_EMAIL_REMOTE_FOLDER__ S32 remoteNum = 0; EMAIL_ACCT_HANDLE acctHandle = EMAIL_ACCT_INVALID_HANDLE; do { result = srv_email_acct_create(gEmailSrvHandle, &acctHandle); if (result != SRV_EMAIL_RESULT_SUCC) { break; } result = srv_email_acct_open(acctHandle, m_acctID); if (result != SRV_EMAIL_RESULT_SUCC) { break; } result = srv_email_acct_get_fldr_num( acctHandle, SRV_EMAIL_ACCT_FLDR_TYPE_LOCAL, &remoteNum); if (result != SRV_EMAIL_RESULT_SUCC) { break; } } while(0); if (acctHandle != EMAIL_ACCT_INVALID_HANDLE) { srv_email_acct_destroy(acctHandle); } if (result == SRV_EMAIL_RESULT_SUCC && remoteNum != 0) { text.loadFromRes(STR_EMAIL_FTO_REMOTE_FOLDER); moreFolderPopup->addItem(MSG_LIST_PAGE_MORE_BOXES_TYPE_REMOTE_FOLDER, text); } #endif /* __MMI_EMAIL_REMOTE_FOLDER__ */ text.loadFromRes(STR_GLOBAL_CANCEL); moreFolderPopup->addItem(MSG_LIST_PAGE_MORE_BOXES_TYPE_CANCEL, text, VCP_POPUP_BUTTON_TYPE_CANCEL); moreFolderPopup->m_signalButtonClicked.connect(this, &VappEmailMsgListPage::onMoreFolderClick); moreFolderPopup->show(VFX_TRUE); } while(0); break; case MSG_LIST_PAGE_TB_SORT: { // no sort toolbar item in outbox if ((m_fldrType == SRV_EMAIL_FLDR_TYPE_INBOX || m_fldrType == SRV_EMAIL_FLDR_TYPE_REMOTE) && (VappEmailMgr::getInstance()->getFldrState(m_acctID, m_fldrID) == VAPP_EMAIL_FLDR_STATE_NETWORK_RECEIVING || VappEmailMgr::getInstance()->getFldrState(m_acctID, m_fldrID) == VAPP_EMAIL_FLDR_STATE_NETWORK_RECEIVE_WAITING)) { mmi_frm_nmgr_balloon( MMI_SCENARIO_ID_DEFAULT, MMI_EVENT_INFO_BALLOON, MMI_NMGR_BALLOON_TYPE_INFO, (WCHAR*)GetString(STR_EMAIL_REFRESHING_CANNOT_SORT)); return; } /* when refresh or send this account, could not sort * in case of message number chanegs of this folder */ if (m_fldrType == SRV_EMAIL_FLDR_TYPE_SENT) { VappEmailAcctStateEnum acctState = VappEmailMgr::getInstance()->getAcctState(m_acctID); if (acctState == VAPP_EMAIL_ACCT_STATE_NETWORK_REFRESHING || acctState == VAPP_EMAIL_ACCT_STATE_NETWORK_REFRESH_WAITING) { mmi_frm_nmgr_balloon( MMI_SCENARIO_ID_DEFAULT, MMI_EVENT_INFO_BALLOON, MMI_NMGR_BALLOON_TYPE_INFO, (WCHAR*)GetString(STR_EMAIL_REFRESHING_CANNOT_SORT)); return; } else if (acctState == VAPP_EMAIL_ACCT_STATE_NETWORK_SENDING || acctState == VAPP_EMAIL_ACCT_STATE_NETWORK_SEND_WAITING) { mmi_frm_nmgr_balloon( MMI_SCENARIO_ID_DEFAULT, MMI_EVENT_INFO_BALLOON, MMI_NMGR_BALLOON_TYPE_INFO, (WCHAR*)GetString(STR_EMAIL_SENDING_CANNOT_SORT)); return; } } VcpCommandPopup *sortPopup; VFX_OBJ_CREATE(sortPopup, VcpCommandPopup, this); VfxWString text; text.loadFromRes(STR_GLOBAL_SORT); sortPopup->setText(text); text.loadFromRes(STR_EMAIL_FTO_FOLDER_SORT_SIZE_ID); sortPopup->addItem(MSG_LIST_PAGE_SORT_TYPE_SIZE, text); if (m_fldrType == SRV_EMAIL_FLDR_TYPE_INBOX || m_fldrType == SRV_EMAIL_FLDR_TYPE_REMOTE) { text.loadFromRes(STR_EMAIL_FTO_FOLDER_SORT_SENDER_ID); } else { text.loadFromRes(STR_EMAIL_FTO_FOLDER_SORT_RECIPIENT_ID); } sortPopup->addItem(MSG_LIST_PAGE_SORT_TYPE_RECIPIENT, text); text.loadFromRes(STR_EMAIL_FTO_FOLDER_SORT_SUBJECT_ID); sortPopup->addItem(MSG_LIST_PAGE_SORT_TYPE_SUBJECT, text); if (m_fldrType == SRV_EMAIL_FLDR_TYPE_INBOX || m_fldrType == SRV_EMAIL_FLDR_TYPE_REMOTE) { text.loadFromRes(STR_EMAIL_FTO_FOLDER_SORT_READ_STAUTS_ID); sortPopup->addItem(MSG_LIST_PAGE_SORT_TYPE_READ_STATUS, text); } text.loadFromRes(STR_EMAIL_FTO_FOLDER_SORT_TIME_ID); sortPopup->addItem(MSG_LIST_PAGE_SORT_TYPE_TIME, text); text.loadFromRes(STR_GLOBAL_CANCEL); sortPopup->addItem(MSG_LIST_PAGE_SORT_TYPE_CANCEL, text, VCP_POPUP_BUTTON_TYPE_CANCEL); sortPopup->m_signalButtonClicked.connect(this, &VappEmailMsgListPage::onSortTypeClick); sortPopup->show(VFX_TRUE); } break; case MSG_LIST_PAGE_TB_RESEND: { if (m_fldrType != SRV_EMAIL_FLDR_TYPE_OUTBOX) { return; } if (VappEmailMgr::getInstance()->getEmailAppState() == VAPP_EMAIL_STATE_FLIGHT_MODE) { mmi_frm_nmgr_balloon( MMI_SCENARIO_ID_DEFAULT, MMI_EVENT_INFO_BALLOON, MMI_NMGR_BALLOON_TYPE_INFO, (WCHAR*)GetString(STR_GLOBAL_UNAVAILABLE_IN_FLIGHT_MODE)); return; } if (VappEmailMgr::getInstance()->getAcctState(m_acctID) == VAPP_EMAIL_ACCT_STATE_NETWORK_REFRESHING || VappEmailMgr::getInstance()->getAcctState(m_acctID) == VAPP_EMAIL_ACCT_STATE_NETWORK_REFRESH_WAITING) { #ifdef __MMI_EMAIL_IMAP_PUSH__ if (!VappEmailMgr::getInstance()->isPushRefreshing(m_acctID)) /* not disable resent when push refreshing */ #endif { mmi_frm_nmgr_balloon( MMI_SCENARIO_ID_DEFAULT, MMI_EVENT_INFO_BALLOON, MMI_NMGR_BALLOON_TYPE_INFO, (WCHAR*)GetString(STR_EMAIL_REFRESHING_CANNOT_SEND)); return; } } VfxWString tbText; if (VappEmailMgr::getInstance()->getAcctState(m_acctID) == VAPP_EMAIL_ACCT_STATE_NETWORK_SENDING || VappEmailMgr::getInstance()->getAcctState(m_acctID) == VAPP_EMAIL_ACCT_STATE_NETWORK_SEND_WAITING) { VappEmailMgr::getInstance()->cancelSendOutbox(m_acctID); tbText.loadFromRes(STR_EMAIL_FTO_RESEND_MAIL_ID); mToolbar->changeItem( MSG_LIST_PAGE_TB_RESEND, tbText, VfxResId(VCP_IMG_TOOL_BAR_COMMON_ITEM_SEND)); } else { if (VappEmailMgr::getInstance()->sendOutbox(m_acctID) == VAPP_EMAIL_RES_WOULDBLOCK) { tbText.loadFromRes(STR_EMAIL_FTO_STOP_SEND_ID); mToolbar->changeItem( MSG_LIST_PAGE_TB_RESEND, tbText, VfxResId(IMG_EMAIL_FTO_TB_STOP)); } else { /* popup */ } } m_listMenu->resetAllItems(VFX_TRUE); } break; case MSG_LIST_PAGE_TB_DELETE: { if (m_fldrType == SRV_EMAIL_FLDR_TYPE_OUTBOX && (VappEmailMgr::getInstance()->getFldrState(m_acctID, m_fldrID) == VAPP_EMAIL_FLDR_STATE_NETWORK_SENDING || VappEmailMgr::getInstance()->getFldrState(m_acctID, m_fldrID) == VAPP_EMAIL_FLDR_STATE_NETWORK_SEND_WAITING)) { mmi_frm_nmgr_balloon( MMI_SCENARIO_ID_DEFAULT, MMI_EVENT_INFO_BALLOON, MMI_NMGR_BALLOON_TYPE_INFO, (WCHAR*)GetString(STR_EMAIL_SENDING_CANNOT_DELETE)); return; } if ((m_fldrType == SRV_EMAIL_FLDR_TYPE_INBOX || m_fldrType == SRV_EMAIL_FLDR_TYPE_REMOTE) && (VappEmailMgr::getInstance()->getFldrState(m_acctID, m_fldrID) == VAPP_EMAIL_FLDR_STATE_NETWORK_RECEIVING || VappEmailMgr::getInstance()->getFldrState(m_acctID, m_fldrID) == VAPP_EMAIL_FLDR_STATE_NETWORK_RECEIVE_WAITING)) { mmi_frm_nmgr_balloon( MMI_SCENARIO_ID_DEFAULT, MMI_EVENT_INFO_BALLOON, MMI_NMGR_BALLOON_TYPE_INFO, (WCHAR*)GetString(STR_EMAIL_REFRESHING_CANNOT_DELETE)); return; } /* when refresh or send this account, could not multi selection delete * in case of message number chanegs of this folder */ if (m_fldrType == SRV_EMAIL_FLDR_TYPE_SENT) { VappEmailAcctStateEnum acctState = VappEmailMgr::getInstance()->getAcctState(m_acctID); if (acctState == VAPP_EMAIL_ACCT_STATE_NETWORK_REFRESHING || acctState == VAPP_EMAIL_ACCT_STATE_NETWORK_REFRESH_WAITING) { mmi_frm_nmgr_balloon( MMI_SCENARIO_ID_DEFAULT, MMI_EVENT_INFO_BALLOON, MMI_NMGR_BALLOON_TYPE_INFO, (WCHAR*)GetString(STR_EMAIL_REFRESHING_CANNOT_DELETE)); return; } else if (acctState == VAPP_EMAIL_ACCT_STATE_NETWORK_SENDING || acctState == VAPP_EMAIL_ACCT_STATE_NETWORK_SEND_WAITING) { mmi_frm_nmgr_balloon( MMI_SCENARIO_ID_DEFAULT, MMI_EVENT_INFO_BALLOON, MMI_NMGR_BALLOON_TYPE_INFO, (WCHAR*)GetString(STR_EMAIL_SENDING_CANNOT_DELETE)); return; } } VappEmailResEnum mgrResult = VappEmailMgr::getInstance()->editFldrStart(m_acctID, m_fldrID); if (mgrResult != VAPP_EMAIL_RES_SUCC) { /* popup */ break; } m_TBType = MSG_LIST_PAGE_TB_TYPE_NONE; m_allSelected = VFX_FALSE; m_multiSelection = VFX_TRUE; m_listProvider->getCheckBoxList(); m_listMenu->setMenuMode(VCP_LIST_MENU_MODE_MULTI_SELECTION, VFX_TRUE); m_listMenu->resetAllItems(VFX_TRUE); for (VfxU32 i = 0; i < MSG_LIST_PAGE_TB_TOTAL; i++) { mToolbar->removeItem(i); } VfxWString tbText; tbText.loadFromRes(STR_GLOBAL_MARK_ALL); mToolbar->addItem(MSG_LIST_PAGE_TB_SELECT_ALL, tbText, VfxResId(VCP_IMG_TOOL_BAR_COMMON_ITEM_SELECT_ALL)); tbText.loadFromRes(STR_GLOBAL_DELETE); mToolbar->addItem(MSG_LIST_PAGE_TB_SELECT_DELETE, tbText, VfxResId(IMG_EMAIL_FTO_DELETE)); mToolbar->setDisableItem(MSG_LIST_PAGE_TB_SELECT_DELETE, VFX_TRUE); tbText.loadFromRes(STR_GLOBAL_CANCEL); mToolbar->addItem(MSG_LIST_PAGE_TB_CANCEL, tbText, VfxResId(VCP_IMG_TOOL_BAR_COMMON_ITEM_CANCEL)); } break; case MSG_LIST_PAGE_TB_SELECT_ALL: { VfxWString text; VfxU8 check = 0; VfxResId imageID = VCP_IMG_TOOL_BAR_COMMON_ITEM_UNSELECT_ALL; if (m_allSelected) { imageID = VCP_IMG_TOOL_BAR_COMMON_ITEM_SELECT_ALL; text.loadFromRes(STR_GLOBAL_MARK_ALL); m_allSelected = VFX_FALSE; check = 0; } else { text.loadFromRes(STR_GLOBAL_UNMARK_ALL); m_allSelected = VFX_TRUE; check = 1; } m_listProvider->selectAllCheckBox(check); mToolbar->changeItem(MSG_LIST_PAGE_TB_SELECT_ALL, text, imageID); m_listMenu->resetAllItems(VFX_TRUE); updateMultiSelectToolbar(); } break; case MSG_LIST_PAGE_TB_SELECT_DELETE: { VFX_OBJ_CREATE(m_deleteConfirmPopup, VcpConfirmPopup, this); m_deleteConfirmPopup->setInfoType(VCP_POPUP_TYPE_WARNING); m_deleteConfirmPopup->setButtonSet(VCP_CONFIRM_BUTTON_SET_USER_DEFINE); VfxU32 checkedNum = m_listProvider->getCheckedItemNum(); VfxWString text; VfxWString countText; VfxWString questionMarkText; if (checkedNum == 1) { text.loadFromRes(STR_EMAIL_FTO_DEL_SELECTED_MAIL_ID); } else { text.loadFromRes(STR_EMAIL_FTO_DEL_SELECTED_MAILS_ID); } countText.format("%d", checkedNum); questionMarkText.loadFromRes(STR_EMAIL_FTO_QUESTION_MARK_ID); text += countText; text += questionMarkText; m_deleteConfirmPopup->setText(text); VfxWString btnText1; btnText1.loadFromRes(STR_GLOBAL_DELETE); VfxWString btnText2; btnText2.loadFromRes((VfxResId)STR_GLOBAL_CANCEL); m_deleteConfirmPopup->setCustomButton( btnText1, btnText2, VCP_POPUP_BUTTON_TYPE_WARNING, VCP_POPUP_BUTTON_TYPE_CANCEL); m_deleteConfirmPopup->m_signalButtonClicked.connect( this, &VappEmailMsgListPage::onDeleteConfirmBtnClick); m_deleteConfirmPopup->setAutoDestory(VFX_FALSE); m_deleteConfirmPopup->show(VFX_TRUE); } break; case MSG_LIST_PAGE_TB_CANCEL: { VappEmailMgr::getInstance()->editFldrStop(m_acctID, m_fldrID); m_allSelected = VFX_FALSE; m_multiSelection = VFX_FALSE; m_listProvider->freeCheckBoxList(); m_listMenu->setMenuMode(VCP_LIST_MENU_MODE_NORMAL, VFX_TRUE); m_listMenu->resetAllItems(VFX_TRUE); updateToolbar(); } break; default: return; } } void VappEmailMsgListPage::onItemClick(VcpListMenu *menu, VfxU32 index) { MMI_TRACE(MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_ITEM_CLICK, index, m_multiSelection); if (m_multiSelection) { m_listProvider->checkBoxClick(index); updateMultiSelectToolbar(); return; } m_index = m_listProvider->getIndexMap(index); EMAIL_MSG_ID msgID = EMAIL_MSG_INVALID_ID; kal_bool isValid; srv_email_fldr_msg_info_struct *msgInfo = (srv_email_fldr_msg_info_struct*)get_ctrl_buffer(sizeof(srv_email_fldr_msg_info_struct)); srv_email_result_enum result; U32 msgCount = 1; do { result = srv_email_fldr_get_msg_list(m_listProvider->getFldrHandle(), (U32)m_index, &msgCount, msgInfo); if (result != SRV_EMAIL_RESULT_SUCC) { break; } msgID = msgInfo->msg_id; result = srv_email_msg_check_valid(msgID, &isValid); if (result != SRV_EMAIL_RESULT_SUCC) { break; } } while(0); free_ctrl_buffer(msgInfo); if (result == SRV_EMAIL_RESULT_SUCC && isValid) { if (m_fldrType == SRV_EMAIL_FLDR_TYPE_DRAFT) { msgID = m_listProvider->getMsgIDByIndex(m_index); VappEmailMainScrn *mainScr = (VappEmailMainScrn*)getMainScr(); mainScr->launchComposer(EMAIL_ACCT_INVALID_ID, msgID, VappEmailComp::EMAIL_MODE_EDIT); } else { if (m_fldrType == SRV_EMAIL_FLDR_TYPE_OUTBOX) { VappEmailMsgStateEnum msgState = VappEmailMgr::getInstance()->getMsgState(msgID); if (msgState == VAPP_EMAIL_MSG_STATE_NETWORK_SENDING || msgState == VAPP_EMAIL_MSG_STATE_NETWORK_WAITING) { VFX_OBJ_CREATE(m_errorPopup, VappEmailErrorPopup, this); m_errorPopup->m_signalButtonClicked.connect( this, &VappEmailMsgListPage::onErrorPopupClicked); m_errorPopup->showErrorPopup(STR_EMAIL_FTO_SENDING_CANNOT_OPEN_ID); return; } } VfxMainScr *mainScr = getMainScr(); VappEmailMsgViewPage *msgViewPage; VFX_OBJ_CREATE_EX(msgViewPage, VappEmailMsgViewPage, mainScr, (m_acctID, m_fldrID, msgID)); VfxU32 unreadMsgNum; VfxU32 msgNum; m_listProvider->getMsgNum(unreadMsgNum, msgNum); mainScr->pushPage(EMAIL_PAGE_TYPE_MSG_VIEW, msgViewPage); } } else { if (isValid == KAL_FALSE) { /* to delete right msg */ m_longTappedMsgID = msgID; VFX_OBJ_CREATE(m_deleteConfirmPopup, VcpConfirmPopup, this); m_deleteConfirmPopup->setInfoType(VCP_POPUP_TYPE_WARNING); m_deleteConfirmPopup->setButtonSet(VCP_CONFIRM_BUTTON_SET_USER_DEFINE); m_deleteConfirmPopup->setText(VFX_WSTR_RES(STR_EMAIL_FTO_BROKEN_EMAIL_DELETE_ID)); VfxWString btnText1; btnText1.loadFromRes((VfxResId)STR_GLOBAL_DELETE); VfxWString btnText2; btnText2.loadFromRes((VfxResId)STR_GLOBAL_CANCEL); m_deleteConfirmPopup->setCustomButton( btnText1, btnText2, VCP_POPUP_BUTTON_TYPE_WARNING, VCP_POPUP_BUTTON_TYPE_CANCEL); m_deleteConfirmPopup->m_signalButtonClicked.connect( this, &VappEmailMsgListPage::onDeleteConfirmBtnClick); m_deleteConfirmPopup->setAutoDestory(VFX_FALSE); m_deleteConfirmPopup->show(VFX_TRUE); return; } if (result != SRV_EMAIL_RESULT_SUCC) { VappEmailErrorPopup *errorPopup; VFX_OBJ_CREATE(errorPopup, VappEmailErrorPopup, getMainScr()); errorPopup->showErrorPopup(result); } } } void VappEmailMsgListPage::onItemLongTapped(VcpListMenu *listMenu, VfxU32 index) { if (m_multiSelection == VFX_TRUE) { return; } EMAIL_MSG_ID currSendingMsgID = EMAIL_MSG_INVALID_ID; VfxBool isSendingMsg = VappEmailMgr::getInstance()->getCurrSendingMsg(currSendingMsgID); MMI_TRACE( MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_ITEM_LONG_TAP, index, m_fldrType, isSendingMsg, currSendingMsgID); if (m_fldrType == SRV_EMAIL_FLDR_TYPE_OUTBOX && index == 0 && isSendingMsg == VFX_TRUE) { /* The first mail in outbox is sending, can't delete */ return; } m_index = m_listProvider->getIndexMap(index); MMI_TRACE(MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_ITEM_LONG_TAP, m_index); VFX_OBJ_CREATE(m_selectPopup, VcpMenuPopup, this); m_selectPopup->setTitle(VFX_WSTR_RES(STR_EMAIL_FTO_EMAIL_OPTIONS_ID)); m_selectPopup->setIsAutoClose(VFX_TRUE); VappEmailStateEnum emailState; srv_email_fldr_msg_info_struct *msgInfo = (srv_email_fldr_msg_info_struct*)get_ctrl_buffer(sizeof(srv_email_fldr_msg_info_struct));; srv_email_result_enum result = SRV_EMAIL_RESULT_SUCC; U32 msgCount = 1; result = srv_email_fldr_get_msg_list(m_listProvider->getFldrHandle(), (U32)index, &msgCount, msgInfo); if (result != SRV_EMAIL_RESULT_SUCC) { free_ctrl_buffer(msgInfo); return; } m_longTappedMsgID = msgInfo->msg_id; VfxWString text; switch (m_fldrType) { case SRV_EMAIL_FLDR_TYPE_INBOX: case SRV_EMAIL_FLDR_TYPE_REMOTE: { VfxBool hasSender = VFX_FALSE; if (msgInfo->addr.disp_name != 0 || msgInfo->addr.email_addr[0] != 0) { hasSender = VFX_TRUE; } if (VappEmailMgr::getInstance()->isNetworkReady(emailState)) { if (hasSender) { text.loadFromRes(STR_GLOBAL_REPLY); m_selectPopup->addItem(MSG_LIST_PAGE_LONG_TAP_REPLY, text); } text.loadFromRes(STR_GLOBAL_FORWARD); m_selectPopup->addItem(MSG_LIST_PAGE_LONG_TAP_FORWARD, text); } text.loadFromRes(STR_GLOBAL_DELETE); m_selectPopup->addItem(MSG_LIST_PAGE_LONG_TAP_DELETE, text); if (msgInfo->flag & EMAIL_MSG_FLAG_SEEN) { text.loadFromRes(STR_EMAIL_FTO_MARK_UNREAD_ID); m_selectPopup->addItem(MSG_LIST_PAGE_LONG_TAP_MARK_AS_UNREAD, text); } } break; case SRV_EMAIL_FLDR_TYPE_OUTBOX: text.loadFromRes((VfxResId)STR_GLOBAL_DELETE); m_selectPopup->addItem(MSG_LIST_PAGE_LONG_TAP_DELETE, text); break; case SRV_EMAIL_FLDR_TYPE_SENT: text.loadFromRes((VfxResId)STR_GLOBAL_FORWARD); m_selectPopup->addItem(MSG_LIST_PAGE_LONG_TAP_FORWARD, text); text.loadFromRes((VfxResId)STR_GLOBAL_DELETE); m_selectPopup->addItem(MSG_LIST_PAGE_LONG_TAP_DELETE, text); break; case SRV_EMAIL_FLDR_TYPE_DRAFT: { srv_email_msg_get_basic_info_struct *basicInfo = NULL; VfxBool hasRecipient = VFX_FALSE; do { EMAIL_MSG_HANDLE msgHandle = EMAIL_MSG_INVALID_HANDLE; result = srv_email_msg_create(gEmailSrvHandle, &msgHandle); if (result != SRV_EMAIL_RESULT_SUCC) { break; } result = srv_email_msg_open(msgHandle, m_acctID, m_fldrID, msgInfo->msg_id); if (result != SRV_EMAIL_RESULT_SUCC) { break; } basicInfo = (srv_email_msg_get_basic_info_struct*)get_ctrl_buffer(sizeof(srv_email_msg_get_basic_info_struct)); result = srv_email_msg_get_basic_info(msgHandle, basicInfo); srv_email_msg_destroy(msgHandle); if (result != SRV_EMAIL_RESULT_SUCC) { break; } if (basicInfo->to_addr_num != 0 || basicInfo->cc_addr_num != 0 || basicInfo->bcc_addr_num != 0) { hasRecipient = VFX_TRUE; } } while (0); if (msgInfo != NULL) { /* there is "return" after */ free_ctrl_buffer(msgInfo); msgInfo = NULL; } if (basicInfo != NULL) { free_ctrl_buffer(basicInfo); } if (result != SRV_EMAIL_RESULT_SUCC) { return; } if (VappEmailMgr::getInstance()->isNetworkReady(emailState) && VappEmailMgr::getInstance()->getEmailAppState() != VAPP_EMAIL_STATE_FLIGHT_MODE && hasRecipient == VFX_TRUE) { text.loadFromRes((VfxResId)STR_GLOBAL_SEND); m_selectPopup->addItem(MSG_LIST_PAGE_LONG_TAP_SEND, text); } text.loadFromRes((VfxResId)STR_GLOBAL_DELETE); m_selectPopup->addItem(MSG_LIST_PAGE_LONG_TAP_DELETE, text); } break; default: return; } if (msgInfo != NULL) { free_ctrl_buffer(msgInfo); msgInfo = NULL; } m_selectPopup->m_signalMenuCallback.connect(this, &VappEmailMsgListPage::onLongTapMenuItemClick); m_selectPopup->showMenu(); vfx_adp_touch_fb_play(VFX_ADP_TOUCH_FB_TYPE_HOLD); } void VappEmailMsgListPage::onLongTapMenuItemClick( VcpMenuPopup *menu, VcpMenuPopupEventEnum eventType, VcpMenuPopupItem *item) { MMI_TRACE(MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_ITEM_LONG_TAP_MENU_CLICK, eventType); if (eventType == VCP_MENU_POPUP_EVENT_ITEM_SELECTED) { VfxId id = item->getId(); MMI_TRACE(MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_ITEM_LONG_TAP_MENU_CLICK_2, id); switch (id) { case MSG_LIST_PAGE_LONG_TAP_REPLY: { //EMAIL_MSG_ID msgID = m_listProvider->getMsgIDByIndex(m_index); VappEmailMainScrn *mainScr = (VappEmailMainScrn*)getMainScr(); mainScr->launchComposer(EMAIL_ACCT_INVALID_ID, m_longTappedMsgID, VappEmailComp::EMAIL_MODE_REPLY); } break; case MSG_LIST_PAGE_LONG_TAP_FORWARD: { //EMAIL_MSG_ID msgID = m_listProvider->getMsgIDByIndex(m_index); VappEmailMainScrn *mainScr = (VappEmailMainScrn*)getMainScr(); mainScr->launchComposer(EMAIL_ACCT_INVALID_ID, m_longTappedMsgID, VappEmailComp::EMAIL_MODE_FWD); } break; case MSG_LIST_PAGE_LONG_TAP_DELETE: { VFX_OBJ_CREATE(m_deleteConfirmPopup, VcpConfirmPopup, this); m_deleteConfirmPopup->setInfoType(VCP_POPUP_TYPE_WARNING); m_deleteConfirmPopup->setButtonSet(VCP_CONFIRM_BUTTON_SET_USER_DEFINE); m_deleteConfirmPopup->setText(VFX_WSTR_RES(STR_EMAIL_FTO_DEL_SEL_MAIL_ID)); VfxWString btnText1; btnText1.loadFromRes((VfxResId)STR_GLOBAL_DELETE); VfxWString btnText2; btnText2.loadFromRes((VfxResId)STR_GLOBAL_CANCEL); m_deleteConfirmPopup->setCustomButton( btnText1, btnText2, VCP_POPUP_BUTTON_TYPE_WARNING, VCP_POPUP_BUTTON_TYPE_CANCEL); m_deleteConfirmPopup->m_signalButtonClicked.connect( this, &VappEmailMsgListPage::onDeleteConfirmBtnClick); m_deleteConfirmPopup->setAutoDestory(VFX_FALSE); m_deleteConfirmPopup->show(VFX_TRUE); } break; case MSG_LIST_PAGE_LONG_TAP_MARK_AS_UNREAD: { /* should handle return value */ m_listProvider->markAsUnread(m_longTappedMsgID); } break; case MSG_LIST_PAGE_LONG_TAP_MOVE_TO_DRAFT: { srv_email_result_enum result; EMAIL_FLDR_ID fldrID = EMAIL_FLDR_INVALID_ID; fldrID = srv_email_fldr_type_to_fldr_id(m_acctID, SRV_EMAIL_FLDR_TYPE_DRAFT); result = m_listProvider->moveMsgToFolder(fldrID, m_longTappedMsgID); if (result != SRV_EMAIL_RESULT_SUCC) { vapp_email_alert_cfm(vapp_email_util_get_err_code(SRV_EMAIL_MAIL_ERROR, result)); return; } m_listMenu->resetAllItems(VFX_TRUE); } break; case MSG_LIST_PAGE_LONG_TAP_SEND: { /* in drafts, first move message to outbox then send outbox */ srv_email_result_enum result; EMAIL_FLDR_ID fldrID = EMAIL_FLDR_INVALID_ID; fldrID = srv_email_fldr_type_to_fldr_id(m_acctID, SRV_EMAIL_FLDR_TYPE_OUTBOX); result = m_listProvider->moveMsgToFolder(fldrID, m_longTappedMsgID); if (result != SRV_EMAIL_RESULT_SUCC) { vapp_email_alert_cfm(vapp_email_util_get_err_code(SRV_EMAIL_MAIL_ERROR, result)); return; } m_listMenu->resetAllItems(VFX_TRUE); VappEmailMgr::getInstance()->sendOutbox(m_acctID); } break; default: return; } if (id != MSG_LIST_PAGE_LONG_TAP_DELETE) { m_longTappedMsgID = EMAIL_MSG_INVALID_ID; } } else if (eventType == VCP_MENU_POPUP_EVENT_MENU_CANCEL) { m_longTappedMsgID = EMAIL_MSG_INVALID_ID; } //VFX_OBJ_CLOSE(m_selectPopup); m_selectPopup = NULL; } void VappEmailMsgListPage::onSortTypeClick(VfxObject *, VfxId id) { m_listProvider->sortMsg((MsgListPageSortTypeEnum)id); } void VappEmailMsgListPage::onMoreFolderClick(VfxObject *, VfxId id) { MMI_TRACE(MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_MORE_FOLDER_CLICK, m_fldrType, id); if (id >= MSG_LIST_PAGE_MORE_BOXES_TYPE_CANCEL) { return; } if (id == MSG_LIST_PAGE_MORE_BOXES_TYPE_REMOTE_FOLDER) { VappEmailMsgListRemoteFolderPage *remoteFolderListPage; VappEmailMainScrn *mainScr = (VappEmailMainScrn*)getMainScr(); VFX_OBJ_CREATE_EX(remoteFolderListPage, VappEmailMsgListRemoteFolderPage, mainScr, (m_acctID)); mainScr->pushPage(EMAIL_PAGE_TYPE_REMOTE_FOLDER_LIST, remoteFolderListPage); return; } srv_email_result_enum result = getFldrIDandTypeByBtn((MsgListPageMoreBoxesTypeEnum)id); if (result != SRV_EMAIL_RESULT_SUCC) { /* should not failed */ VappEmailErrorPopup *errorPopup; VFX_OBJ_CREATE(errorPopup, VappEmailErrorPopup, getMainScr()); errorPopup->showErrorPopup(result, getMainScr(), EMAIL_PAGE_TYPE_REMOTE_FOLDER_LIST); } ((VappEmailMainScrn*)getMainScr())->setCurrFldr(m_fldrID); m_isDeleteOutboxMsg = VFX_FALSE; m_listProvider->resetProvider(m_acctID, m_fldrID); if (m_listMenu != NULL) { m_listMenu->setMenuMode(VCP_LIST_MENU_MODE_NORMAL, VFX_TRUE); } updateTitleBarText(); } void VappEmailMsgListPage::updateMsgList() { if (m_listMenu == NULL) { VFX_OBJ_CREATE(m_listMenu, VcpListMenu, this); VfxSize pageSize = getSize(); m_listMenu->setContentProvider(m_listProvider); m_listMenu->setRect(0, 0, pageSize.width, pageSize.height); m_listMenu->setCellStyle(VCP_LIST_MENU_CELL_STYLE_TRIPLE_TEXT_EX); m_listMenu->setMenuMode(VCP_LIST_MENU_MODE_NORMAL, VFX_TRUE); m_listMenu->m_signalItemTapped.connect(this, &VappEmailMsgListPage::onItemClick); m_listMenu->m_signalItemLongTapped.connect(this, &VappEmailMsgListPage::onItemLongTapped); m_listProvider->setMenu(m_listMenu); m_listMenu->setAlignParent( VFX_FRAME_ALIGNER_MODE_SIDE, VFX_FRAME_ALIGNER_MODE_SIDE, VFX_FRAME_ALIGNER_MODE_SIDE, VFX_FRAME_ALIGNER_MODE_SIDE); } else { m_listMenu->setMenuMode(VCP_LIST_MENU_MODE_NORMAL, VFX_TRUE); m_listMenu->resetAllItems(VFX_TRUE); } } void VappEmailMsgListPage::onTitleBarLBtnClick(VfxObject *, VfxId) { EMAIL_ACCT_ID acctID; EMAIL_FLDR_ID fldrID; VappEmailMainScrn *mainScrn = (VappEmailMainScrn*)getMainScr(); mainScrn->getPrevAcctnFldr(acctID, fldrID); /* clear multi selection check box */ onTBClick(NULL, MSG_LIST_PAGE_TB_CANCEL); MMI_TRACE( MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_TITLE_LBTN_CLICK, acctID, fldrID, srv_email_fldr_id_to_fldr_type(acctID, fldrID)); resetPage(acctID, fldrID, srv_email_fldr_id_to_fldr_type(acctID, fldrID)); } void VappEmailMsgListPage::onTitleBarRBtnClick(VfxObject *, VfxId) { EMAIL_ACCT_ID acctID; EMAIL_FLDR_ID fldrID; VappEmailMainScrn *mainScrn = (VappEmailMainScrn*)getMainScr(); mainScrn->getNextAcctnFldr(acctID, fldrID); /* clear multi selection check box */ onTBClick(NULL, MSG_LIST_PAGE_TB_CANCEL); MMI_TRACE( MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_TITLE_RBTN_CLICK, acctID, fldrID, srv_email_fldr_id_to_fldr_type(acctID, fldrID)); resetPage(acctID, fldrID, srv_email_fldr_id_to_fldr_type(acctID, fldrID)); } void VappEmailMsgListPage::onDeleteConfirmBtnClick(VfxObject *obj, VfxId id) { MMI_TRACE(MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_DELETE_CONFIRM_CLICK, id); if (id == VCP_CONFIRM_POPUP_BUTTON_USER_1 || id == VCP_CONFIRM_POPUP_BUTTON_USER_2) { VappEmailMgr::getInstance()->editFldrStop(m_acctID, m_fldrID); if (id == VCP_CONFIRM_POPUP_BUTTON_USER_2) { return; } if (srv_email_fldr_id_to_fldr_type(m_acctID, m_fldrID) == SRV_EMAIL_FLDR_TYPE_OUTBOX) { m_isDeleteOutboxMsg = VFX_TRUE; } srv_email_result_enum result; if (m_multiSelection) { m_allSelected = VFX_FALSE; m_multiSelection = VFX_FALSE; result = m_listProvider->markMsg(VFX_TRUE); m_listProvider->freeCheckBoxList(); m_listMenu->setMenuMode(VCP_LIST_MENU_MODE_NORMAL, VFX_TRUE); if (result == SRV_EMAIL_RESULT_SUCC) { result = m_listProvider->deleteMsg(); } } else { result = m_listProvider->deleteMsg(m_longTappedMsgID); } providerUpdated(result, VFX_TRUE); } m_longTappedMsgID = EMAIL_MSG_INVALID_ID; VFX_OBJ_CLOSE(m_deleteConfirmPopup); m_deleteConfirmPopup = NULL; } void VappEmailMsgListProvider::generalAsyncCallback( srv_email_result_struct *result, EMAIL_REQ_ID req_id, void *user_data) { VappEmailMsgListProvider *currObj = (VappEmailMsgListProvider*)user_data; currObj->m_isReady = VFX_TRUE; VappEmailMsgListPage *msgListPage = (VappEmailMsgListPage*)(currObj->getParent()); msgListPage->generalAsyncCallback(result, req_id, user_data); } VappEmailMsgListProvider::VappEmailMsgListProvider(EMAIL_ACCT_ID acctID, EMAIL_FLDR_ID fldrID) :m_fldrHandle(EMAIL_FLDR_INVALID_HANDLE), m_acctID(acctID), m_fldrID(fldrID), m_checkBoxList(NULL), m_sendFailMsgNum(0), m_currMsgNum(0), m_isReady(VFX_FALSE) { } void VappEmailMsgListProvider::onInit() { initProvider(m_acctID, m_fldrID); } void VappEmailMsgListProvider::onDeinit() { if (m_checkBoxList != NULL) { free_ctrl_buffer(m_checkBoxList); m_checkBoxList = NULL; } if (m_fldrHandle) { srv_email_fldr_clear_callback(m_fldrHandle); } } void VappEmailMsgListProvider::setMenu(VcpListMenu* listMenu) { m_listMenu = listMenu; } VfxBool VappEmailMsgListProvider::getItemText( VfxU32 index, VcpListMenuFieldEnum fieldType, VfxWString &textString, VcpListMenuTextColorEnum &textColor) { switch(fieldType) { case VCP_LIST_MENU_FIELD_TEXT: { srv_email_fldr_msg_info_struct *msgInfo = (srv_email_fldr_msg_info_struct*)get_ctrl_buffer(sizeof(srv_email_fldr_msg_info_struct)); srv_email_result_enum result; U32 msgCount = 1; do { result = srv_email_fldr_get_msg_list(m_fldrHandle, (U32)getIndexMap(index), &msgCount, msgInfo); if (result != SRV_EMAIL_RESULT_SUCC) { break; } if (msgInfo->addr.disp_name_len != 0) { textString.loadFromMem((VfxWChar*)msgInfo->addr.disp_name); } else if (msgInfo->addr.email_addr[0] != 0) { textString.loadFromMem((VfxWChar*)msgInfo->addr.email_addr); } else { if (srv_email_fldr_id_to_fldr_type(m_acctID, m_fldrID) != SRV_EMAIL_FLDR_TYPE_INBOX) { textString.loadFromRes(STR_EMAIL_FTO_NO_RECIPIENT); } } }while(0); free_ctrl_buffer(msgInfo); } break; case VCP_LIST_MENU_FIELD_SUB_TEXT1: { srv_email_fldr_msg_info_struct *msgInfo = (srv_email_fldr_msg_info_struct*)get_ctrl_buffer(sizeof(srv_email_fldr_msg_info_struct)); srv_email_result_enum result; U32 msgCount = 1; do { result = srv_email_fldr_get_msg_list(m_fldrHandle, (U32)getIndexMap(index), &msgCount, msgInfo); if (result != SRV_EMAIL_RESULT_SUCC) { break; } if (msgInfo->buff[0] == 0) { textString.loadFromRes(STR_EMAIL_FTO_COMMON_NO_SUBJECT_ID); } else { textString.loadFromMem((VfxWChar*)msgInfo->buff); } } while(0); free_ctrl_buffer(msgInfo); } break; case VCP_LIST_MENU_FIELD_SUB_TEXT2: { srv_email_fldr_msg_info_struct *msgInfo = (srv_email_fldr_msg_info_struct*)get_ctrl_buffer(sizeof(srv_email_fldr_msg_info_struct)); srv_email_result_enum result; U32 msgCount = 1; U32 currTime; U32 localTime; applib_time_struct timeInfo = {0}; applib_time_struct currTimeInfo = {0}; result = srv_email_fldr_get_msg_list(m_fldrHandle, (U32)getIndexMap(index), &msgCount, msgInfo); if (result != SRV_EMAIL_RESULT_SUCC) { free_ctrl_buffer(msgInfo); return VFX_FALSE; } localTime = applib_dt_sec_utc_to_local(msgInfo->time); free_ctrl_buffer(msgInfo); applib_dt_utc_sec_2_mytime(localTime, &timeInfo, MMI_FALSE); currTime = app_getcurrtime(); applib_dt_utc_sec_2_mytime(currTime, &currTimeInfo, MMI_FALSE); VfxDateTime dateTime; dateTime.setDateTime(&timeInfo); if (currTimeInfo.nYear == timeInfo.nYear && currTimeInfo.nMonth == timeInfo.nMonth && currTimeInfo.nDay == timeInfo.nDay) { textString = dateTime.getDateTimeString( VFX_DATE_TIME_TIME_HOUR | VFX_DATE_TIME_TIME_MINUTE); } else { textString = dateTime.getDateTimeString( VFX_DATE_TIME_DATE_MONTH | VFX_DATE_TIME_DATE_DAY); } } break; default: return VFX_FALSE; } return VFX_TRUE; } VfxBool VappEmailMsgListProvider::getMenuEmptyText(VfxWString &text, VcpListMenuTextColorEnum &color) { if (m_isReady) { text.loadFromRes(STR_EMAIL_FTO_NO_EMAILS_ID); } else { text.loadFromRes(STR_GLOBAL_LOADING); } return VFX_TRUE; } VfxBool VappEmailMsgListProvider::getItemImage( VfxU32 index, VcpListMenuFieldEnum fieldType, VfxImageSrc &imageSrc) { U16 iconID = getMsgStatusIcon(fieldType, index); imageSrc.setResId(iconID); if (iconID == 0) { return VFX_FALSE; } else { return VFX_TRUE; } } void VappEmailMsgListProvider::closeItemImage( VfxU32 index, VcpListMenuFieldEnum fieldEnum, VfxImageSrc imageSrc) { } VfxU32 VappEmailMsgListProvider::getCount(void) const { if (m_checkBoxList != NULL) { return m_currMsgNum; } else { if (!m_isReady) { return 0; } VfxU32 msgNun = 0; srv_email_fldr_get_msg_num(m_fldrHandle, SRV_EMAIL_FLDR_MSG, (S32*)(&msgNun)); return msgNun; } } VcpListMenuItemStateEnum VappEmailMsgListProvider::getItemState(VfxU32 index) const { if (m_checkBoxList != NULL) { if (m_checkBoxList[index]) { return VCP_LIST_MENU_ITEM_STATE_SELECTED; } else { return VCP_LIST_MENU_ITEM_STATE_UNSELECTED; } } return VCP_LIST_MENU_ITEM_STATE_NONE; } VfxBool VappEmailMsgListProvider::swapItem(VfxU32 first, VfxU32 second) { return VFX_FALSE; } VcpListMenuCellClientBaseFrame *VappEmailMsgListProvider::getItemCustomContentFrame( VfxU32 index, VfxFrame *frame) { VappEmailMsgListMenuCell *msgListItem = NULL; VFX_OBJ_CREATE_EX(msgListItem, VappEmailMsgListMenuCell, frame, (index)); return msgListItem; } void VappEmailMsgListProvider::closeItemCustomContentFrame( VfxU32 index, VcpListMenuCellClientBaseFrame *baseFrame) { } VcpListMenu *VappEmailMsgListProvider::getListMenu() { return m_listMenu; } VfxBool VappEmailMsgListProvider::getItemTextFrameFormat( VfxU32 index, VcpListMenuFieldEnum fieldType, VfxTextFrame *frame) { return VFX_FALSE; #if 0 /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ #endif } U16 VappEmailMsgListProvider::getMsgStatusIcon(VcpListMenuFieldEnum fieldType, VfxU32 index) { srv_email_result_enum result = SRV_EMAIL_RESULT_SUCC; U32 msgCount = 1; U16 iconID = 0; srv_email_fldr_msg_info_struct *msgInfo = (srv_email_fldr_msg_info_struct*)get_ctrl_buffer(sizeof(srv_email_fldr_msg_info_struct)); result = srv_email_fldr_get_msg_list(m_fldrHandle, getIndexMap(index), &msgCount, msgInfo); if (result != SRV_EMAIL_RESULT_SUCC) { free_ctrl_buffer(msgInfo); return iconID; } if (fieldType == VCP_LIST_MENU_FIELD_ICON_EXTRA2) { if (msgInfo->has_attach) { if (msgInfo->priority == EMAIL_MSG_PRIO_MED) { iconID = IMG_EMAIL_FTO_LIST_ATTCH; } else if (msgInfo->priority == EMAIL_MSG_PRIO_LOW) { iconID = IMG_EMAIL_FTO_LIST_PRIO_LOW_ATT; } else /* EMAIL_MSG_PRIO_HIGH */ { iconID = IMG_EMAIL_FTO_LIST_PRIO_HIGH_ATT; } } else { if (msgInfo->priority == EMAIL_MSG_PRIO_MED) { iconID = 0; } else if (msgInfo->priority == EMAIL_MSG_PRIO_LOW) { iconID = IMG_EMAIL_FTO_LIST_PRIO_LOW; } else /* EMAIL_MSG_PRIO_HIGH */ { iconID = IMG_EMAIL_FTO_LIST_PRIO_HIGH; } } } else { if (srv_email_fldr_id_to_fldr_type(m_acctID, m_fldrID) == SRV_EMAIL_FLDR_TYPE_INBOX) { if (msgInfo->state & SRV_EMAIL_MSG_STATE_HEADER_ONLY) { iconID = IMG_EMAIL_FTO_LIST_HEADER_ONLY; } else if (msgInfo->state & SRV_EMAIL_MSG_STATE_DOWN_NOT_FINISH) { iconID = IMG_EMAIL_FTO_LIST_UNFINISH; } } else if (srv_email_fldr_id_to_fldr_type(m_acctID, m_fldrID) == SRV_EMAIL_FLDR_TYPE_OUTBOX) { VappEmailMsgStateEnum msgState = VappEmailMgr::getInstance()->getMsgState(msgInfo->msg_id); if (msgState == VAPP_EMAIL_MSG_STATE_NETWORK_SENDING) { iconID = IMG_EMAIL_FTO_LIST_MSG_SENDING; } else if (msgState == VAPP_EMAIL_MSG_STATE_NETWORK_WAITING) { iconID = IMG_EMAIL_FTO_LIST_MSG_WAITING; } else if (msgState == VAPP_EMAIL_MSG_STATE_NETWORK_SEND_FAIL) { iconID = IMG_EMAIL_FTO_LIST_MSG_SEND_FAIL; } } } free_ctrl_buffer(msgInfo); return iconID; } void VappEmailMsgListProvider::setProvider(EMAIL_ACCT_ID acctID, EMAIL_FLDR_ID fldrID) { MMI_TRACE( MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_SET_PROVIDER, acctID, fldrID, srv_email_fldr_id_to_fldr_type(acctID, fldrID)); m_acctID = acctID; m_fldrID = fldrID; srv_email_result_enum result; srv_email_fldr_create_info_struct fldrCreateInfo; fldrCreateInfo.acct_id = acctID; fldrCreateInfo.fldr_id = fldrID; fldrCreateInfo.list_field = 0; fldrCreateInfo.sort_mode = SRV_EMAIL_FLDR_SORT_MSG_MODE_NONE; /* cause of SRV_EMAIL_FLDR_SORT_MSG_MODE_NONE sort_order has no effect */ if (srv_email_fldr_id_to_fldr_type(acctID, fldrID) == SRV_EMAIL_FLDR_TYPE_OUTBOX) { fldrCreateInfo.sort_order = MMI_TRUE; } else { fldrCreateInfo.sort_order = MMI_FALSE; } if (fldrCreateInfo.acct_id != gCurrFldrInfo.info.acct_id || fldrCreateInfo.fldr_id != gCurrFldrInfo.info.fldr_id || fldrCreateInfo.sort_mode != gCurrFldrInfo.info.sort_mode || fldrCreateInfo.sort_order != gCurrFldrInfo.info.sort_order || fldrCreateInfo.list_field != gCurrFldrInfo.info.list_field ) { /* enter a new folder */ if (gCurrFldrInfo.handle != EMAIL_FLDR_INVALID_HANDLE) { srv_email_fldr_destroy(gCurrFldrInfo.handle); gCurrFldrInfo.handle = EMAIL_FLDR_INVALID_HANDLE; } memcpy(&gCurrFldrInfo.info, &fldrCreateInfo, sizeof(srv_email_fldr_create_info_struct)); do { result = srv_email_fldr_create(gEmailSrvHandle, &fldrCreateInfo, &m_fldrHandle); if (result != SRV_EMAIL_RESULT_SUCC) { break; } gCurrFldrInfo.handle = m_fldrHandle; result = srv_email_fldr_regist_callback(m_fldrHandle, &VappEmailMsgListProvider::generalAsyncCallback, this); if (result != SRV_EMAIL_RESULT_SUCC) { break; } result = srv_email_fldr_list_msg_ext( m_fldrHandle, SRV_EMAIL_MSG_TEXT_SUBJ, SRV_EMAIL_MSG_CREATED_DATE, &m_listReqID); if (result == SRV_EMAIL_RESULT_SUCC) { m_isReady = VFX_TRUE; } else { m_isReady = VFX_FALSE; } ((VappEmailMsgListPage*)getParent())->providerUpdated(result); } while(0); } else { m_fldrHandle = gCurrFldrInfo.handle; srv_email_fldr_regist_callback(m_fldrHandle, &VappEmailMsgListProvider::generalAsyncCallback, this); m_isReady = VFX_TRUE; } } VfxU32 VappEmailMsgListProvider::getIndexMap(VfxU32 orgIndex) { if (srv_email_fldr_id_to_fldr_type(m_acctID, m_fldrID) != SRV_EMAIL_FLDR_TYPE_OUTBOX) { return orgIndex; } srv_email_result_enum result; VfxU32 dstIndex = orgIndex; VfxU32 totalMsg = 0; result = srv_email_fldr_get_msg_num(m_fldrHandle, SRV_EMAIL_FLDR_MSG, (S32*)&totalMsg); if (result != SRV_EMAIL_RESULT_SUCC) { return dstIndex; } VfxU32 getCount = 1; srv_email_fldr_msg_info_struct *msgInfo = (srv_email_fldr_msg_info_struct*)get_ctrl_buffer(sizeof(srv_email_fldr_msg_info_struct)); EMAIL_MSG_ID currSendingMsg; if (VappEmailMgr::getInstance()->getCurrSendingMsg(currSendingMsg) == VFX_TRUE) { if (orgIndex == 0) { for (VfxU16 i = 0; i < totalMsg; i++) { result = srv_email_fldr_get_msg_list(m_fldrHandle, (U32)i, (U32*)&getCount, msgInfo); if (result != SRV_EMAIL_RESULT_SUCC || getCount != 1) { return dstIndex; } if (VappEmailMgr::getInstance()->getMsgState(msgInfo->msg_id) == VAPP_EMAIL_MSG_STATE_NETWORK_SENDING) { dstIndex = i; break; } } } else { VfxU32 counter = 1; VappEmailMsgStateEnum findState = VAPP_EMAIL_MSG_STATE_NETWORK_WAITING; if (orgIndex >= totalMsg - m_sendFailMsgNum) { findState = VAPP_EMAIL_MSG_STATE_NETWORK_SEND_FAIL; counter = m_sendFailMsgNum - (totalMsg - orgIndex) + 1; } else { counter = orgIndex; } for (VfxU16 i = 0; i < totalMsg; i++) { result = srv_email_fldr_get_msg_list(m_fldrHandle, (U32)i, (U32*)&getCount, msgInfo); if (result != SRV_EMAIL_RESULT_SUCC || getCount != 1) { return dstIndex; } if (VappEmailMgr::getInstance()->getMsgState(msgInfo->msg_id) == findState) { counter--; if (counter == 0) { dstIndex = i; break; } } } } } else { VfxU32 counter = 1; VappEmailMsgStateEnum findState = VAPP_EMAIL_MSG_STATE_NETWORK_WAITING; if (orgIndex >= totalMsg - m_sendFailMsgNum) { findState = VAPP_EMAIL_MSG_STATE_NETWORK_SEND_FAIL; counter = m_sendFailMsgNum - (totalMsg - orgIndex) + 1; } else { counter = orgIndex + 1; } for (VfxU16 i = 0; i < totalMsg; i++) { result = srv_email_fldr_get_msg_list(m_fldrHandle, (U32)i, (U32*)&getCount, msgInfo); if (result != SRV_EMAIL_RESULT_SUCC || getCount != 1) { return dstIndex; } if (VappEmailMgr::getInstance()->getMsgState(msgInfo->msg_id) == findState) { counter--; if (counter == 0) { dstIndex = i; break; } } } } free_ctrl_buffer(msgInfo); return dstIndex; } void VappEmailMsgListProvider::sortMsg(MsgListPageSortTypeEnum sortType) { /* when long time no operation page will be locked and this api will be called by sortType == -1 */ if ((signed int)sortType < MSG_LIST_PAGE_SORT_TYPE_SIZE || sortType >= MSG_LIST_PAGE_SORT_TYPE_CANCEL) { return; } srv_email_fldr_sort_msg_struct *sortInfo = (srv_email_fldr_sort_msg_struct*)get_ctrl_buffer(sizeof(srv_email_fldr_sort_msg_struct)); sortInfo->sort_order = MMI_FALSE; sortInfo->msg_index = 0; sortInfo->msg_id = 0; srv_email_result_enum result = SRV_EMAIL_RESULT_SUCC; srv_email_fldr_basic_info_struct basicInfo; result = srv_email_fldr_get_basic_info(m_fldrHandle, &basicInfo); if (result != SRV_EMAIL_RESULT_SUCC) { VappEmailErrorPopup *errorPopup; VFX_OBJ_CREATE(errorPopup, VappEmailErrorPopup, this); errorPopup->showErrorPopup(result); return; } switch (sortType) { case MSG_LIST_PAGE_SORT_TYPE_SIZE: sortInfo->sort_mode = SRV_EMAIL_FLDR_SORT_MSG_MODE_SERVER_SIZE; break; case MSG_LIST_PAGE_SORT_TYPE_RECIPIENT: sortInfo->sort_mode = SRV_EMAIL_FLDR_SORT_MSG_MODE_ADDR; break; case MSG_LIST_PAGE_SORT_TYPE_SUBJECT: sortInfo->sort_mode = SRV_EMAIL_FLDR_SORT_MSG_MODE_BUFFER; break; case MSG_LIST_PAGE_SORT_TYPE_READ_STATUS: sortInfo->sort_mode = SRV_EMAIL_FLDR_SORT_MSG_MODE_FLAG; break; case MSG_LIST_PAGE_SORT_TYPE_TIME: sortInfo->sort_mode = SRV_EMAIL_FLDR_SORT_MSG_MODE_TIME; break; default: break; } if (sortInfo->sort_mode == basicInfo.sort_mode) { sortInfo->sort_order = (MMI_BOOL)!basicInfo.sort_order; } MMI_TRACE( MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_SORT, basicInfo.sort_mode, basicInfo.sort_order, sortInfo->sort_mode, sortInfo->sort_order); srv_email_fldr_sort_msg(m_fldrHandle, sortInfo); free_ctrl_buffer(sortInfo); m_listMenu->resetAllItems(VFX_TRUE); } EMAIL_MSG_ID VappEmailMsgListProvider::getNextMsgID(EMAIL_MSG_ID currMsgID, VfxU32 &index, VfxU32 &total) { srv_email_result_enum result; S32 msgNumber = 0; EMAIL_MSG_ID msgID = EMAIL_MSG_INVALID_ID; srv_email_fldr_msg_info_struct *msgInfo = NULL; U32 msgCount = 1; total = 0; index = 0; do { result = srv_email_fldr_get_msg_num(m_fldrHandle, SRV_EMAIL_FLDR_MSG, &msgNumber); if (result != SRV_EMAIL_RESULT_SUCC) { break; } if (result != SRV_EMAIL_RESULT_SUCC) { break; } total = msgNumber; if (msgNumber == 0) { break; } msgInfo = (srv_email_fldr_msg_info_struct*)get_ctrl_buffer(sizeof(srv_email_fldr_msg_info_struct)); for (S32 i = 0; i < msgNumber; i++) { result = srv_email_fldr_get_msg_list(m_fldrHandle, getIndexMap(i), &msgCount, msgInfo); if (result != SRV_EMAIL_RESULT_SUCC || msgCount != 1) { break; } if (msgInfo->msg_id == currMsgID) { i = (i + 1) % msgNumber; index = i; result = srv_email_fldr_get_msg_list(m_fldrHandle, getIndexMap(i), &msgCount, msgInfo); if (result != SRV_EMAIL_RESULT_SUCC || msgCount != 1) { break; } msgID = msgInfo->msg_id; break; } } } while(0); if (msgInfo != NULL) { free_ctrl_buffer(msgInfo); } return msgID; } EMAIL_MSG_ID VappEmailMsgListProvider::getPrevMsgID(EMAIL_MSG_ID currMsgID, VfxU32 &index, VfxU32 &total) { srv_email_result_enum result; S32 msgNumber = 0; EMAIL_MSG_ID msgID = EMAIL_MSG_INVALID_ID; srv_email_fldr_msg_info_struct *msgInfo = NULL; U32 msgCount = 1; total = 0; index = 0; do { result = srv_email_fldr_get_msg_num(m_fldrHandle, SRV_EMAIL_FLDR_MSG, &msgNumber); if (result != SRV_EMAIL_RESULT_SUCC) { break; } total = msgNumber; if (msgNumber == 0) { break; } msgInfo = (srv_email_fldr_msg_info_struct*)get_ctrl_buffer(sizeof(srv_email_fldr_msg_info_struct)); for (S32 i = 0; i < msgNumber; i++) { result = srv_email_fldr_get_msg_list(m_fldrHandle, getIndexMap(i), &msgCount, msgInfo); if (result != SRV_EMAIL_RESULT_SUCC || msgCount != 1) { break; } if (msgInfo->msg_id == currMsgID) { i = (i + msgNumber - 1) % msgNumber; index = i; result = srv_email_fldr_get_msg_list(m_fldrHandle, getIndexMap(i), &msgCount, msgInfo); if (result != SRV_EMAIL_RESULT_SUCC || msgCount != 1) { break; } msgID = msgInfo->msg_id; break; } } } while(0); if (msgInfo != NULL) { free_ctrl_buffer(msgInfo); } return msgID; } void VappEmailMsgListProvider::getMsgIndex(EMAIL_MSG_ID currMsgID, VfxU32 &index, VfxU32 &total) { srv_email_result_enum result; S32 msgNumber = 0; srv_email_fldr_msg_info_struct *msgInfo = NULL; U32 msgCount = 1; total = 0; index = 0; do { result = srv_email_fldr_get_msg_num(m_fldrHandle, SRV_EMAIL_FLDR_MSG, &msgNumber); if (result != SRV_EMAIL_RESULT_SUCC) { break; } total = msgNumber; if (msgNumber == 0) { break; } msgInfo = (srv_email_fldr_msg_info_struct*)get_ctrl_buffer(sizeof(srv_email_fldr_msg_info_struct)); for (S32 i = 0; i < msgNumber; i++) { result = srv_email_fldr_get_msg_list(m_fldrHandle, getIndexMap(i), &msgCount, msgInfo); if (result != SRV_EMAIL_RESULT_SUCC || msgCount != 1) { break; } if (msgInfo->msg_id == currMsgID) { index = i; break; } } } while(0); if (msgInfo != NULL) { free_ctrl_buffer(msgInfo); } } EMAIL_FLDR_HANDLE VappEmailMsgListProvider::getFldrHandle() { return m_fldrHandle; } void VappEmailMsgListProvider::resetProvider(EMAIL_ACCT_ID acctID, EMAIL_FLDR_ID fldrID) { freeCheckBoxList(); setProvider(acctID, fldrID); } void VappEmailMsgListProvider::initProvider(EMAIL_ACCT_ID acctID, EMAIL_FLDR_ID fldrID) { setProvider(acctID, fldrID); } void VappEmailMsgListProvider::getMsgNum(VfxU32 &unreadMsgNum, VfxU32 &msgNum) { unreadMsgNum = 0; msgNum = 0; srv_email_result_enum result; result = srv_email_fldr_get_msg_num(m_fldrHandle, SRV_EMAIL_FLDR_MSG, (S32*)(&msgNum)); if (result != SRV_EMAIL_RESULT_SUCC) { return; } result = srv_email_fldr_get_msg_num(m_fldrHandle, SRV_EMAIL_FLDR_MSG_UNREAD, (S32*)(&unreadMsgNum)); if (result != SRV_EMAIL_RESULT_SUCC) { unreadMsgNum = 0; msgNum = 0; } } void VappEmailMsgListProvider::onMsgListUpdate(srv_email_om_notify_struct *notify_data, void *user_data) { VappEmailMsgListProvider* provider = (VappEmailMsgListProvider*)user_data; ((VappEmailMsgListPage*)(provider->getParent()))->onMsgListUpdate(); } srv_email_result_enum VappEmailMsgListProvider::markMsg(VfxBool markMsg) { U32 msgCount = 1; srv_email_result_enum result = SRV_EMAIL_RESULT_SUCC; EMAIL_MSG_ID msgID = EMAIL_MSG_INVALID_ID; VfxU32 totalMsgNum = getCount(); srv_email_fldr_msg_info_struct *msgInfo = (srv_email_fldr_msg_info_struct*)get_ctrl_buffer(sizeof(srv_email_fldr_msg_info_struct)); for (U32 i = 0; i < totalMsgNum; i++) { if (!m_checkBoxList[i]) { continue; } result = srv_email_fldr_get_msg_list(m_fldrHandle , getIndexMap(i), &msgCount, msgInfo); if (result != SRV_EMAIL_RESULT_SUCC) { /* memory operation, should not be failed */ VappEmailErrorPopup *errorPopup; VFX_OBJ_CREATE(errorPopup, VappEmailErrorPopup, getParent()); errorPopup->showErrorPopup(result); break; } msgID = msgInfo->msg_id; result = srv_email_fldr_mark_msg(m_fldrHandle, MMI_FALSE, msgID, (MMI_BOOL)markMsg); if (result != SRV_EMAIL_RESULT_SUCC) { /* memory operation, should not be failed */ VappEmailErrorPopup *errorPopup; VFX_OBJ_CREATE(errorPopup, VappEmailErrorPopup, getParent()); errorPopup->showErrorPopup(result); break; } } free_ctrl_buffer(msgInfo); return result; } srv_email_result_enum VappEmailMsgListProvider::markAsUnread(EMAIL_MSG_ID msgID) { srv_email_fldr_set_msg_flag_struct setFlagInfo; memset(&setFlagInfo, 0, sizeof(srv_email_fldr_set_msg_flag_struct)); setFlagInfo.msg_id = msgID; setFlagInfo.set_all = MMI_FALSE; setFlagInfo.set_all_marked = MMI_FALSE; setFlagInfo.msg_flag = !EMAIL_MSG_FLAG_SEEN; setFlagInfo.flag_mask = EMAIL_MSG_FLAG_SEEN; return srv_email_fldr_set_msg_flag(m_fldrHandle, &setFlagInfo, NULL); } srv_email_result_enum VappEmailMsgListProvider::moveMsgToFolder(EMAIL_FLDR_ID fldrID, EMAIL_MSG_ID msgID) { EMAIL_MSG_HANDLE msgHandle = EMAIL_MSG_INVALID_HANDLE; srv_email_result_enum result; EMAIL_MSG_ID msgIDTemp = msgID; do { result = srv_email_msg_create(gEmailSrvHandle, &msgHandle); if (result != SRV_EMAIL_RESULT_SUCC) { break; } result = srv_email_msg_open(msgHandle, m_acctID, m_fldrID, msgIDTemp); if (result != SRV_EMAIL_RESULT_SUCC) { break; } result = srv_email_msg_move(msgHandle, m_acctID, fldrID, &msgIDTemp); if (result != SRV_EMAIL_RESULT_SUCC) { break; } srv_email_msg_destroy(msgHandle); } while(0); if (msgHandle != EMAIL_MSG_INVALID_HANDLE) { srv_email_msg_destroy(msgHandle); } MMI_TRACE( MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_MOVE_MSG_TO_FOLDER, 0, msgIDTemp, fldrID, result); return result; } srv_email_result_enum VappEmailMsgListProvider::deleteMsg(EMAIL_MSG_ID msgID) { srv_email_fldr_delete_msg_struct deleteMsgInfo; if (srv_email_fldr_id_to_fldr_type(m_acctID, m_fldrID) == SRV_EMAIL_FLDR_TYPE_INBOX || srv_email_fldr_id_to_fldr_type(m_acctID, m_fldrID) == SRV_EMAIL_FLDR_TYPE_REMOTE) { deleteMsgInfo.delete_header = MMI_FALSE; } else { deleteMsgInfo.delete_header = MMI_TRUE; } deleteMsgInfo.delete_server = MMI_TRUE; deleteMsgInfo.delete_all = MMI_FALSE; if (msgID == EMAIL_MSG_INVALID_ID) { deleteMsgInfo.delete_all_marked = MMI_TRUE; } else { deleteMsgInfo.delete_all_marked = MMI_FALSE; deleteMsgInfo.msg_id = msgID; } return srv_email_fldr_delete_msg(m_fldrHandle, &deleteMsgInfo, NULL); } void VappEmailMsgListProvider::getCheckBoxList() { S32 msgNumber = 0; srv_email_fldr_get_msg_num(m_fldrHandle, SRV_EMAIL_FLDR_MSG, &msgNumber); m_checkBoxList = (VfxU8*)get_ctrl_buffer(sizeof(VfxU8) * msgNumber); memset(m_checkBoxList, 0, sizeof(VfxU8) * msgNumber); m_checkedMsg = 0; m_currMsgNum = msgNumber; } void VappEmailMsgListProvider::selectAllCheckBox(VfxU8 select) { VfxU32 msgNumber = getCount(); for (VfxU32 i = 0; i < msgNumber; i++) { m_checkBoxList[i] = select; } if (select == 1) { m_checkedMsg = msgNumber; } else { m_checkedMsg = 0; } } EMAIL_MSG_ID VappEmailMsgListProvider::getMsgIDByIndex(VfxU32 index) { EMAIL_MSG_ID msgID = EMAIL_MSG_INVALID_ID; srv_email_fldr_msg_info_struct *msgInfo = (srv_email_fldr_msg_info_struct*)get_ctrl_buffer(sizeof(srv_email_fldr_msg_info_struct)); srv_email_result_enum result; U32 msgCount = 1; do { result = srv_email_fldr_get_msg_list(m_fldrHandle, (U32)index, &msgCount, msgInfo); if (result != SRV_EMAIL_RESULT_SUCC) { break; } msgID = msgInfo->msg_id; } while(0); MMI_TRACE( MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_GET_ID_BY_INDEX, index, msgID); free_ctrl_buffer(msgInfo); return msgID; } void VappEmailMsgListTitleBar::onInit() { VfxPageBar::onInit(); if (m_bgImageFrame == NULL) { VFX_OBJ_CREATE(m_bgImageFrame, VfxImageFrame, this); m_bgImageFrame->setResId(IMG_EMAIL_FTO_TITLEBAR_BG_ID); m_bgImageFrame->setContentPlacement(VFX_FRAME_CONTENT_PLACEMENT_TYPE_RESIZE); m_bgImageFrame->setRect(0, 0, gScrnWidth, EMAIL_MSG_VIEW_HEADER_ITEM_HEIGHT); } } void VappEmailMsgListTitleBar::onSetRotate(VfxScrRotateTypeEnum rotation) { if(m_rotation == rotation) { return; } m_rotation = rotation; updateTitleTextLayout(); updateTitleBtnLayout(); } void VappEmailMsgListTitleBar::updateButtons(VfxBool showSwitchBtn) { MMI_TRACE(MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_TITLEBAR_UPDATE_BTN, showSwitchBtn); VfxU32 btnTopGap = (EMAIL_MSG_VIEW_HEADER_ITEM_HEIGHT - VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH) / 2; if (showSwitchBtn) { if (m_leftButton == NULL) { VFX_OBJ_CREATE(m_leftButton, VcpImageButton, this); m_leftButton->setImage( VcpStateImage( IMG_EMAIL_FTO_LEFT_ID, IMG_EMAIL_FTO_LEFT_ID, IMG_EMAIL_FTO_LEFT_ID, IMG_EMAIL_FTO_LEFT_ID)); m_leftButton->setIsEffect(VFX_TRUE); m_leftButton->setEffectRatio(1.2f); m_leftButton->setEffectOffset( VfxPoint( EMAIL_MSG_VIEW_HEADER_LEFT_GAP - 1, btnTopGap - 1)); } if (m_rightButton == NULL) { VFX_OBJ_CREATE(m_rightButton, VcpImageButton, this); m_rightButton->setImage( VcpStateImage( IMG_EMAIL_FTO_RIGHT_ID, IMG_EMAIL_FTO_RIGHT_ID, IMG_EMAIL_FTO_RIGHT_ID, IMG_EMAIL_FTO_RIGHT_ID)); m_rightButton->setIsEffect(VFX_TRUE); m_rightButton->setEffectRatio(1.2f); m_rightButton->setEffectOffset( VfxPoint( gScrnWidth - VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH - EMAIL_MSG_VIEW_HEADER_RIGHT_GAP - 2, btnTopGap - 1)); } VfxU32 btnTopGap = (EMAIL_MSG_VIEW_HEADER_ITEM_HEIGHT - VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH) / 2; m_leftButton->setPos(EMAIL_MSG_VIEW_HEADER_LEFT_GAP, btnTopGap); m_leftButton->setBounds( VfxRect( EMAIL_MSG_VIEW_HEADER_LEFT_GAP, btnTopGap, VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH, VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH)); m_rightButton->setPos( gScrnWidth - VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH - EMAIL_MSG_VIEW_HEADER_LEFT_GAP, btnTopGap); m_rightButton->setBounds( VfxRect( gScrnWidth - VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH - EMAIL_MSG_VIEW_HEADER_LEFT_GAP, btnTopGap, VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH, VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH)); } else { if (m_leftButton != NULL) { VFX_OBJ_CLOSE(m_leftButton); m_leftButton = NULL; } if (m_rightButton != NULL) { VFX_OBJ_CLOSE(m_rightButton); m_rightButton = NULL; } } } void VappEmailMsgListTitleBar::updateTitleText(VfxWString &fldrNameText, VfxWString &acctNameText) { MMI_TRACE(MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_TITLEBAR_UPDATE_TEXT); if (m_fldrNameText == NULL) { VFX_OBJ_CREATE(m_fldrNameText, VfxTextFrame, this); } if (m_acctNameText == NULL) { VFX_OBJ_CREATE(m_acctNameText, VfxTextFrame, this); } VfxWString emptyText; emptyText.setEmpty(); setSize(gScrnWidth, EMAIL_MSG_VIEW_HEADER_ITEM_HEIGHT); // adjust postion of two line m_acctNameText->setString(acctNameText); //m_acctNameText->setString(acctNameText); m_acctNameText->setFont(VfxFontDesc(EMAIL_MSG_VIEW_FONT_MEDIUM)); m_acctNameText->setColor(VFX_COLOR_WHITE); m_acctNameText->setAlignMode(VfxTextFrame::ALIGN_MODE_CENTER); m_acctNameText->setTruncateMode(VfxTextFrame::TRUNCATE_MODE_END); //m_acctNameText->forceUpdate(); m_acctNameText->setPos( VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH + EMAIL_MSG_VIEW_HEADER_LEFT_GAP * 2, EMAIL_MSG_VIEW_HEADER_TOP_GAP); m_acctNameText->setBounds( VfxRect( VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH + EMAIL_MSG_VIEW_HEADER_LEFT_GAP * 2, EMAIL_MSG_VIEW_HEADER_TOP_GAP, gScrnWidth - VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH * 2 - EMAIL_MSG_VIEW_HEADER_LEFT_GAP * 4, m_acctNameText->getBounds().getHeight())); // adjust postion of two line m_fldrNameText->setString(fldrNameText); //m_fldrNameText->setString(fldrNameText); m_fldrNameText->setFont(VfxFontDesc(EMAIL_MSG_VIEW_FONT_SMALL)); m_fldrNameText->setColor(VFX_COLOR_WHITE); m_fldrNameText->setAlignMode(VfxTextFrame::ALIGN_MODE_CENTER); m_fldrNameText->setTruncateMode(VfxTextFrame::TRUNCATE_MODE_END); //m_fldrNameText->forceUpdate(); m_fldrNameText->setPos( VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH + EMAIL_MSG_VIEW_HEADER_LEFT_GAP * 2, EMAIL_MSG_VIEW_HEADER_ITEM_HEIGHT - EMAIL_MSG_VIEW_HEADER_TOP_GAP - m_fldrNameText->getBounds().getHeight()); m_fldrNameText->setBounds( VfxRect( VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH + EMAIL_MSG_VIEW_HEADER_LEFT_GAP * 2, EMAIL_MSG_VIEW_HEADER_ITEM_HEIGHT - EMAIL_MSG_VIEW_HEADER_TOP_GAP - m_fldrNameText->getBounds().getHeight(), gScrnWidth - VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH * 2 - EMAIL_MSG_VIEW_HEADER_LEFT_GAP * 4, m_fldrNameText->getBounds().getHeight())); } void VappEmailMsgListTitleBar::updateTitleTextLayout() { VfxU32 screennWidth; MMI_TRACE(MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_TITLEBAR_UPDATE_TEXT_LAYOUT); if (m_rotation == VFX_SCR_ROTATE_TYPE_90 || m_rotation == VFX_SCR_ROTATE_TYPE_270) { screennWidth = LCD_HEIGHT; } else { screennWidth = LCD_WIDTH; } setSize(screennWidth, EMAIL_MSG_VIEW_HEADER_ITEM_HEIGHT); m_bgImageFrame->setBounds(VfxRect(0, 0, screennWidth, EMAIL_MSG_VIEW_HEADER_ITEM_HEIGHT)); m_acctNameText->setPos( VfxPoint( VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH + EMAIL_MSG_VIEW_HEADER_LEFT_GAP * 2, EMAIL_MSG_VIEW_HEADER_TOP_GAP)); m_acctNameText->setBounds( VfxRect( VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH + EMAIL_MSG_VIEW_HEADER_LEFT_GAP * 2, EMAIL_MSG_VIEW_HEADER_TOP_GAP, screennWidth - VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH * 2 - EMAIL_MSG_VIEW_HEADER_LEFT_GAP * 4, m_acctNameText->getBounds().getHeight())); //m_acctNameText->forceUpdate(); m_fldrNameText->setPos( VfxPoint( VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH + EMAIL_MSG_VIEW_HEADER_LEFT_GAP * 2, EMAIL_MSG_VIEW_HEADER_ITEM_HEIGHT - m_fldrNameText->getBounds().getHeight() - EMAIL_MSG_VIEW_HEADER_TOP_GAP)); m_fldrNameText->setBounds( VfxRect( VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH + EMAIL_MSG_VIEW_HEADER_LEFT_GAP * 2, EMAIL_MSG_VIEW_HEADER_ITEM_HEIGHT - m_fldrNameText->getBounds().getHeight() - EMAIL_MSG_VIEW_HEADER_TOP_GAP, screennWidth - VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH * 2 - EMAIL_MSG_VIEW_HEADER_LEFT_GAP * 4, m_fldrNameText->getBounds().getHeight())); //m_fldrNameText->forceUpdate(); } void VappEmailMsgListTitleBar::updateTitleBtnLayout() { VfxU32 screennWidth; MMI_TRACE(MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_TITLEBAR_UPDATE_BTN_LAYOUT); if (m_rotation == VFX_SCR_ROTATE_TYPE_90 || m_rotation == VFX_SCR_ROTATE_TYPE_270) { screennWidth = LCD_HEIGHT; } else { screennWidth = LCD_WIDTH; } setSize(screennWidth, EMAIL_MSG_VIEW_HEADER_ITEM_HEIGHT); VfxU32 btnTopGap = (EMAIL_MSG_VIEW_HEADER_ITEM_HEIGHT - VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH) / 2; if (m_leftButton != NULL) { m_leftButton->setPos(EMAIL_MSG_VIEW_HEADER_LEFT_GAP, btnTopGap); m_leftButton->setBounds( VfxRect( EMAIL_MSG_VIEW_HEADER_LEFT_GAP, btnTopGap, VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH, VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH)); m_leftButton->setEffectOffset( VfxPoint( EMAIL_MSG_VIEW_HEADER_LEFT_GAP - 1, btnTopGap - 1)); } if (m_rightButton != NULL) { m_rightButton->setPos( screennWidth - VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH - EMAIL_MSG_VIEW_HEADER_LEFT_GAP, btnTopGap); m_rightButton->setBounds( VfxRect( screennWidth - VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH - EMAIL_MSG_VIEW_HEADER_LEFT_GAP, btnTopGap, VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH, VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH)); m_rightButton->setEffectOffset( VfxPoint( screennWidth - EMAIL_MSG_VIEW_HEADER_RIGHT_GAP - VAPP_EMAIL_TITLE_BAR_BUTTON_WIDTH - 2, btnTopGap - 1)); } } VappEmailMsgListRemoteFolderListProvider::VappEmailMsgListRemoteFolderListProvider(EMAIL_ACCT_ID acctID) :m_acctID(acctID) { memset(m_fldrIDMsgNumMap, 0, sizeof(FldrIDMsgNumMap) * 20); EMAIL_ACCT_HANDLE acctHandle = EMAIL_ACCT_INVALID_HANDLE; srv_email_result_enum result = SRV_EMAIL_RESULT_SUCC; S32 getFldrIDCount = 1; EMAIL_FLDR_ID fldrID = EMAIL_FLDR_INVALID_ID; srv_email_acct_folder_struct *fldrInfo = NULL; S32 remoteNum = 0; do { result = srv_email_acct_create(gEmailSrvHandle, &acctHandle); if (result != SRV_EMAIL_RESULT_SUCC) { break; } result = srv_email_acct_open(acctHandle, m_acctID); if (result != SRV_EMAIL_RESULT_SUCC) { break; } result = srv_email_acct_get_fldr_num( acctHandle, SRV_EMAIL_ACCT_FLDR_TYPE_LOCAL, &remoteNum); if (result != SRV_EMAIL_RESULT_SUCC) { break; } fldrInfo = (srv_email_acct_folder_struct*)get_ctrl_buffer(sizeof(srv_email_acct_folder_struct)); for (VfxS32 index = 0; index < remoteNum; index++) { result = srv_email_acct_get_fldr_id( acctHandle, SRV_EMAIL_ACCT_FLDR_TYPE_LOCAL, (S32)index, &getFldrIDCount, &fldrID); if (result != SRV_EMAIL_RESULT_SUCC) { break; } result = srv_email_acct_get_fldr_info( acctHandle, fldrID, fldrInfo); if (result != SRV_EMAIL_RESULT_SUCC) { break; } m_fldrIDMsgNumMap[index].fldrID = fldrID; m_fldrIDMsgNumMap[index].msgNum = fldrInfo->msg_count; m_fldrIDMsgNumMap[index].unreadMsgNum = fldrInfo->unread_count; } } while(0); if (acctHandle != EMAIL_ACCT_INVALID_HANDLE) { srv_email_acct_destroy(acctHandle); } if (fldrInfo != NULL) { free_ctrl_buffer(fldrInfo); } } VfxBool VappEmailMsgListRemoteFolderListProvider::getItemText( VfxU32 index, VcpListMenuFieldEnum fieldType, VfxWString &textString, VcpListMenuTextColorEnum &color) { if (fieldType != VCP_LIST_MENU_FIELD_TEXT) { return VFX_FALSE; } EMAIL_ACCT_HANDLE acctHandle = EMAIL_ACCT_INVALID_HANDLE; srv_email_result_enum result = SRV_EMAIL_RESULT_SUCC; S32 getFldrIDCount = 1; EMAIL_FLDR_ID fldrID = EMAIL_FLDR_INVALID_ID; srv_email_acct_folder_struct *fldrInfo = NULL; do { result = srv_email_acct_create(gEmailSrvHandle, &acctHandle); if (result != SRV_EMAIL_RESULT_SUCC) { break; } result = srv_email_acct_open(acctHandle, m_acctID); if (result != SRV_EMAIL_RESULT_SUCC) { break; } result = srv_email_acct_get_fldr_id( acctHandle, SRV_EMAIL_ACCT_FLDR_TYPE_LOCAL, (S32)index, &getFldrIDCount, &fldrID); if (result != SRV_EMAIL_RESULT_SUCC) { break; } fldrInfo = (srv_email_acct_folder_struct*)get_ctrl_buffer(sizeof(srv_email_acct_folder_struct)); result = srv_email_acct_get_fldr_info( acctHandle, fldrID, fldrInfo); if (result != SRV_EMAIL_RESULT_SUCC) { break; } textString.loadFromMem((VfxWChar*)(fldrInfo->folder_name)); VfxWString numString; VfxWString temp; numString += VFX_WSTR(" "); numString += VFX_WSTR_RES(STR_EMAIL_FTO_LEFT_PARENTHESES); if (fldrInfo->unread_count != 0) { temp.format("%d/%d", m_fldrIDMsgNumMap[index].unreadMsgNum, m_fldrIDMsgNumMap[index].msgNum); color = VCP_LIST_MENU_TEXT_COLOR_HIGHLIGHT; } else { temp.format("%d", m_fldrIDMsgNumMap[index].msgNum); color = VCP_LIST_MENU_TEXT_COLOR_NORMAL; } numString += temp; numString += VFX_WSTR_RES(STR_EMAIL_FTO_RIGHT_PARENTHESES); textString += numString; } while(0); if (acctHandle != EMAIL_ACCT_INVALID_HANDLE) { srv_email_acct_destroy(acctHandle); } if (fldrInfo != NULL) { free_ctrl_buffer(fldrInfo); } if (result == SRV_EMAIL_RESULT_SUCC) { return VFX_TRUE; } else { return VFX_FALSE; } } VfxBool VappEmailMsgListRemoteFolderListProvider::getItemTextFrameFormat( VfxU32 index, VcpListMenuFieldEnum fieldType, VfxTextFrame *frame) { switch(fieldType) { case VCP_LIST_MENU_FIELD_TEXT: { if (m_fldrIDMsgNumMap[index].unreadMsgNum != NULL) { VfxFontDesc font = frame->getFont(); font.setAttr(VFX_FONT_DESC_ATTR_BOLD); frame->setFont(font); } } break; default: return VFX_FALSE; } return VFX_TRUE; } VfxBool VappEmailMsgListRemoteFolderListProvider::getItemImage( VfxU32 index, VcpListMenuFieldEnum fieldType, VfxImageSrc &imageSrc) { return VFX_FALSE; } void VappEmailMsgListRemoteFolderListProvider::closeItemImage( VfxU32 index, VcpListMenuFieldEnum fieldType, VfxImageSrc imageSrc) { } VfxU32 VappEmailMsgListRemoteFolderListProvider::getCount(void) const { S32 remoteNum = 0; EMAIL_ACCT_HANDLE acctHandle = EMAIL_ACCT_INVALID_HANDLE; do { srv_email_result_enum result = SRV_EMAIL_RESULT_SUCC; result = srv_email_acct_create(gEmailSrvHandle, &acctHandle); if (result != SRV_EMAIL_RESULT_SUCC) { break; } result = srv_email_acct_open(acctHandle, m_acctID); if (result != SRV_EMAIL_RESULT_SUCC) { break; } result = srv_email_acct_get_fldr_num( acctHandle, SRV_EMAIL_ACCT_FLDR_TYPE_LOCAL, &remoteNum); if (result != SRV_EMAIL_RESULT_SUCC) { break; } } while(0); if (acctHandle != EMAIL_ACCT_INVALID_HANDLE) { srv_email_acct_destroy(acctHandle); } return remoteNum; } VcpListMenuItemStateEnum VappEmailMsgListRemoteFolderListProvider::getItemState(VfxU32) const { return VCP_LIST_MENU_ITEM_STATE_NONE; } VfxBool VappEmailMsgListRemoteFolderListProvider::swapItem(VfxU32 first, VfxU32 second) { return VFX_FALSE; } VcpListMenuCellClientBaseFrame *VappEmailMsgListRemoteFolderListProvider::getItemCustomContentFrame( VfxU32 index, VfxFrame *frame) { return NULL; } void VappEmailMsgListRemoteFolderListProvider::closeItemCustomContentFrame( VfxU32 index, VcpListMenuCellClientBaseFrame *baseFrame) { } void VappEmailMsgListRemoteFolderListProvider::updateFldrMsgNum( EMAIL_FLDR_ID fldrID, VfxU32 unreadMsgNum, VfxU32 msgNum) { for (VfxU32 index = 0; index < 20; index++) { if (fldrID == m_fldrIDMsgNumMap[index].fldrID) { m_fldrIDMsgNumMap[index].msgNum = msgNum; m_fldrIDMsgNumMap[index].unreadMsgNum = unreadMsgNum; } } } void VappEmailMsgListRemoteFolderPage::onInit() { VfxPage::onInit(); VFX_OBJ_CREATE(m_titleBar, VcpTitleBar, this); m_titleBar->setTitleStyle(VCP_TITLE_BAR_STYLE_BASE); setTopBar(m_titleBar); m_titleBar->setTitle(VFX_WSTR_RES(STR_EMAIL_FTO_REMOTE_FOLDER)); VFX_OBJ_CREATE_EX(m_listProvider, VappEmailMsgListRemoteFolderListProvider, this, (m_acctID)); VFX_OBJ_CREATE(m_listMenu, VcpListMenu, this); m_listProvider->setMenu(m_listMenu); VfxSize pageSize = getSize(); m_listMenu->setContentProvider(m_listProvider); m_listMenu->setRect(0, 0, pageSize.width, pageSize.height); m_listMenu->setCellStyle(VCP_LIST_MENU_CELL_STYLE_SINGLE_TEXT); m_listMenu->setMenuMode(VCP_LIST_MENU_MODE_NORMAL, VFX_TRUE); m_listMenu->m_signalItemTapped.connect(this, &VappEmailMsgListRemoteFolderPage::onItemClick); m_listMenu->setAlignParent( VFX_FRAME_ALIGNER_MODE_SIDE, VFX_FRAME_ALIGNER_MODE_SIDE, VFX_FRAME_ALIGNER_MODE_SIDE, VFX_FRAME_ALIGNER_MODE_SIDE); VappEmailMgr::getInstance()->m_signalFldrMsgNumChange.connect(this, &VappEmailMsgListRemoteFolderPage::onAcctMsgNumChange); } void VappEmailMsgListRemoteFolderPage::onRotate(const VfxScreenRotateParam &param) { if (param.rotateTo == VFX_SCR_ROTATE_TYPE_90 || param.rotateTo == VFX_SCR_ROTATE_TYPE_270 || param.rotateTo == VFX_SCR_ROTATE_TYPE_LANDSCAPE) { gScrnWidth = LCD_HEIGHT; gScrnHeight = LCD_WIDTH; } else { gScrnWidth = LCD_WIDTH; gScrnHeight = LCD_HEIGHT; } } VappEmailMsgListRemoteFolderPage::VappEmailMsgListRemoteFolderPage() { } void VappEmailMsgListRemoteFolderPage::onItemClick(VcpListMenu *, VfxU32 index) { S32 getRemoteNum = 1; EMAIL_ACCT_HANDLE acctHandle = EMAIL_ACCT_INVALID_HANDLE; srv_email_result_enum result = SRV_EMAIL_RESULT_SUCC; EMAIL_FLDR_ID fldrID = EMAIL_FLDR_INVALID_ID; do { result = srv_email_acct_create(gEmailSrvHandle, &acctHandle); if (result != SRV_EMAIL_RESULT_SUCC) { break; } result = srv_email_acct_open(acctHandle, m_acctID); if (result != SRV_EMAIL_RESULT_SUCC) { break; } result = srv_email_acct_get_fldr_id( acctHandle, SRV_EMAIL_ACCT_FLDR_TYPE_LOCAL, (S32)index, &getRemoteNum, &fldrID); if (result != SRV_EMAIL_RESULT_SUCC) { break; } } while(0); if (acctHandle != EMAIL_ACCT_INVALID_HANDLE) { srv_email_acct_destroy(acctHandle); } VappEmailMainScrn *mainScrn = (VappEmailMainScrn*)getMainScr(); mainScrn->popPage(); mainScrn->setCurrFldr(fldrID); VfxId msgListPageID = mainScrn->getTopPageId(); VappEmailMsgListPage *msgListPage = (VappEmailMsgListPage*)(mainScrn->getPage(msgListPageID)); MMI_TRACE( MMI_INET_TRC_G9_EMAIL, TRC_VEMAIL_MSG_LIST_REMOTE_FOLDER_ITEM_CLICK, index, fldrID); msgListPage->resetPage(m_acctID, fldrID, SRV_EMAIL_FLDR_TYPE_REMOTE); msgListPage->updateTitleBar(); } void VappEmailMsgListRemoteFolderPage::onAcctMsgNumChange( EMAIL_ACCT_ID acctID, EMAIL_FLDR_ID fldrID, VappEmailFldrMsgNumStruct msgNumInfo) { if (acctID != m_acctID) { return; } m_listProvider->updateFldrMsgNum(fldrID, msgNumInfo.unreadNum, msgNumInfo.totalNum); m_listMenu->resetAllItems(VFX_TRUE); }
ad28ba1ac439eccec3aaa26cf157da7728973bad
c857705f993939f6d97a0fbe5b5607771943189c
/Codes/Graph/HLD.cpp
90fb5b2b34d6626cc546115850b6b918aa3c46b4
[]
no_license
MarcosJLR/CP-Library
966a23afffc75a71ff5b416a8da842ce93e49440
69dab485a63e479d7d09420cae377b6d43256952
refs/heads/master
2023-03-26T10:40:20.545988
2021-03-27T23:00:40
2021-03-27T23:00:40
199,491,894
1
0
null
null
null
null
UTF-8
C++
false
false
550
cpp
HLD.cpp
int t; // Timer int in[MAXN], out[MAXN], nxt[MAXN], sz[MAXN]; void dfsSz(int v = 0, int p = -1){ sz[v] = 1; for(auto &u : G[v]) if(u != p){ dfsSz(u); sz[v] += sz[u]; if(sz[u] > sz[G[v][0]]) swap(u, G[v][0]); } } void dfsHLD(int v = 0, int p = -1){ in[v] = t++; for(auto u : G[v]) if(u != p){ nxt[u] = (u == G[v][0] ? nxt[v] : u); dfsHLD(u); } out[v] = t; } // [in[v], out[v]) corresponds to v's subtree // [in[nxt[v]], in[v]] path from v to last // vertex in ascending heavy path
3c631e1fc6e73ef4ec0b3df3d4d8f28ad3c56c0b
feff7acb239ae449c861cb75b892755e7935ebcd
/JagunParser/jagunparsermessageinformation.h
789202d7572dc943457455b8139b6e95cb4e58d8
[]
no_license
adysonmaia/jagunmsn
f9dd4bee4be60c9d1271153c81071d50f7c42712
43b1b8db6271a18e2dda9c07534a6e8d9c9dd5da
refs/heads/main
2023-03-29T20:33:37.197608
2021-04-06T10:10:03
2021-04-06T10:10:03
355,139,934
0
0
null
null
null
null
UTF-8
C++
false
false
1,893
h
jagunparsermessageinformation.h
#ifndef JAGUNPARSERMESSAGEINFORMATION_H #define JAGUNPARSERMESSAGEINFORMATION_H class JagunParserMessageInformation { public: JagunParserMessageInformation(); enum ETypeMessage { ETPNewUser = 0, // mensagem para criar novo usuario ETPUserCreated = 1, // mensagem de usuario cadastrado ETPError = 2, // mensagem de erro ETPLoginUser = 3, // mensagem logar usuario ETPLogOn = 4, // mensagem usuario logado ETPAddContact = 5, // mensagem de adicionar contato ETPRequestAddContact = 6, // mensagem de pedido para adicionar contato ETPAddContactConfirmation = 7, // mensagem de resposta ao pedido de adicionar contato ETPRequestContactList = 8, // mensagem de requisicao da lista de contatos ETPApprovedAddContact = 9, // mensagem de adicionar contato aceito ETPContactList = 10, // mensagem lista de contatos ETPRemoveContact = 11, // mensagem remover contato ETPBlockOrUnblock = 12, // mensagem bloquear ou desbloquear contato ETPChangeStatus = 13, // mensagem mudanca de status do usuario ETPGetStatusContact = 14, // mensagem requisitar status de um contato ETPChangeStatusContact = 15, // mensagem mudança no status do cantato ETPKeepAlive = 16, // mensagem keep alive ETPSendMessage = 17, // mensagem enviar mensagem ETPReceiveMessage = 18, // mensagem receber mensagem }; enum EErrorCode { EECNewUser = 0, // erro no cadastro do usuario EECLoginUser = 1, // erro ao logar usuario EECAddContact = 2 // erro ao adicionar contato }; }; #endif // JAGUNPARSERMESSAGEINFORMATION_H
4afe25adacf2e4992affd68743ccf3eef18c67ae
492976adfdf031252c85de91a185bfd625738a0c
/src/Game/AI/Action/actionForkEmitChmField.h
cdc8288433563069ce5ce65abd71a876e83fcb03
[]
no_license
zeldaret/botw
50ccb72c6d3969c0b067168f6f9124665a7f7590
fd527f92164b8efdb746cffcf23c4f033fbffa76
refs/heads/master
2023-07-21T13:12:24.107437
2023-07-01T20:29:40
2023-07-01T20:29:40
288,736,599
1,350
117
null
2023-09-03T14:45:38
2020-08-19T13:16:30
C++
UTF-8
C++
false
false
671
h
actionForkEmitChmField.h
#pragma once #include "Game/AI/Action/actionForkEmitExpandField.h" #include "KingSystem/ActorSystem/actAiAction.h" namespace uking::action { class ForkEmitChmField : public ForkEmitExpandField { SEAD_RTTI_OVERRIDE(ForkEmitChmField, ForkEmitExpandField) public: explicit ForkEmitChmField(const InitArg& arg); ~ForkEmitChmField() override; bool init_(sead::Heap* heap) override; void enter_(ksys::act::ai::InlineParamPack* params) override; void leave_() override; void loadParams_() override; protected: void calc_() override; // static_param at offset 0x90 const int* mEmitIntervalTime_s{}; }; } // namespace uking::action
5080513ecc790a40607ee341ba845716236f04f8
28a2db9e767451b4beeab506679cb462a2fb6ffa
/Plus_one.cpp
c85b56809ce54dd31879bb1210c7f7a5965d1e0f
[]
no_license
Mehuli-Ruh11/C-exercise
ad8900faf62c8b6a9dba768232c1b29be3d5ec66
40be88db4413d7573823e691a5650bf81ba4f0dd
refs/heads/master
2020-03-09T07:18:43.845613
2018-12-08T07:41:22
2018-12-08T07:41:22
128,661,770
0
0
null
null
null
null
UTF-8
C++
false
false
589
cpp
Plus_one.cpp
class Solution { public: vector<int> plusOne(vector<int>& digits) { int n=digits.size(); int i =n-1; digits[n-1]=digits[n-1]+1; while(i>=0 & digits[i]>9) { if(i==0) { digits[i]=0; digits.insert(digits.begin(),1); return digits; } digits[i]=0; digits[i-1]= digits[i-1]+1; i--; } return digits; } };
74f44fa253e4500fecf5bfd39b693935739077d1
42811e7629f0ef9b57682b5252d070be1ea7a25e
/include/sliding_bitmap.h
d60964a842e5392bb437cf85344c39e1699281bc
[]
no_license
zhoujie3/knlib
88a79c3a2bf2e5eb8b2380346ae987ee2d152d27
c23a4be1fc4db0cc21b4de715467f6919cc0f93a
refs/heads/master
2021-05-28T20:05:43.500503
2015-04-10T07:37:07
2015-04-10T07:37:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,670
h
sliding_bitmap.h
/*************************************************************************** * * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved * $Id$ * **************************************************************************/ /** * @file sliding_window/dev/sliding_bitmap.h * @author knzeus(zhou_jie@baidu.com) * @date 2015/03/31 23:33:51 * @version $Revision$ * @brief: a bitmap but support sliding bit * for SlidingWindow * **/ #ifndef ANTI_THEMIS_SLIDING_WINDOW_DEV_SLIDING_BITMAP_H #define ANTI_THEMIS_SLIDING_WINDOW_DEV_SLIDING_BITMAP_H #include <bitset> namespace anti { namespace themis { namespace common_lib { // use two bitset to simulate the sliding bitset template<int bit_size> class SlidingBitmap { typedef std::bitset<bit_size> Bitmap; public: SlidingBitmap(); ~SlidingBitmap(); bool init(int valid_size); // @param pos: start with zero bool set(int pos); // @param pos: start with zero bool operator[](int pos); int size() const { return _valid_size; } bool any() const { return _bitmap[0]->any() || _bitmap[1]->any(); } void slide_one_bit(); void slide(int bits); void clear() { _reset_all(); } private: bool _find_pos(const int pos_in, Bitmap** p_map, int* pos_out) const; void _swap_bitmap(); void _reset_all(); private: Bitmap* _bitmap[2]; // start with zero int _start_pos; int _valid_size; }; } // namespace common_lib } // namespace themis } // namespace anti #include "sliding_bitmap.hpp" #endif // ANTI_THEMIS_SLIDING_WINDOW_DEV_SLIDING_BITMAP_H /* vim: set ts=4 sw=4 sts=4 tw=100 */
07c409a7d31b88ae7bc7974ebe825b1f89d4fe7c
dc680f2f9238de259b9e55aa32aadf243211462a
/Template/string/Quick3String.cpp
f62ee86c76b37a9b1d99de6bfe36ac43cacde477
[]
no_license
zhaoyewei/OJ
cc112cb603acd213add7e107b24d53cafb27ae52
0c2962cab5ae62c4ccb3ace3851cdd129d890799
refs/heads/master
2022-05-07T09:40:58.467922
2019-04-21T05:44:37
2019-04-21T05:44:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,309
cpp
Quick3String.cpp
#include <iostream> #include <cstdio> #include <cstring> #include <string> #include <vector> #include <queue> #include <algorithm> #include <cmath> #include <set> #include <list> #include <iomanip> using namespace std; #define DEBUG int charAt(std::string s, int index) { if (index < s.length()) return s.at(index); else return -1; } void exch(std::string s[], int x, int y) { std::string st = s[x]; s[x] = s[y]; s[y] = st; } void sort(std::string s[], int lo, int hi, int d) { if (hi <= lo) return; int lt = lo, gt = hi; int v = charAt(s[lo], d); int i = lo + 1; while (i <= gt) { int t = charAt(s[i], d); if (t < v) exch(s, lt++, i++); else if (t > v) exch(s, i, gt--); else i++; } sort(s, lo, lt - 1, d); if (v >= 0) sort(s, lt, gt, d + 1); sort(s, gt + 1, hi, d); } void sort(std::string s[]) { sort(s, 0, s->size(), 0); } int main() { std::string s[] = {"dfghjk", "abklsdgjalkbgjka", "ajsdobvr", "skjhjfhivt", "pohbjtkh", "jilnclisksj"}; printf("size is:%d\n", s->size()); sort(s); for (int i = 0; i < s->size(); i++) { printf("%s\n", s[i].c_str()); } #ifdef DEBUG system("pause"); #endif return 0; }
1a0ed89663f66b3f0ed91f312e5f0e51e9324268
a8d0bb2f9a42320be0aa5e383f1ce67e5e44d2c6
/Algorithms/DP/017 longestIncreasingSubsequence.cpp
4588f4b9ebab3807c021b926fdc0c7e55cd57edd
[]
no_license
camperjett/DSA_dups
f5728e06f1874bafbaf8561752e8552fee2170fa
f20fb4be1463398f568dbf629a597d8d0ae92e8f
refs/heads/main
2023-04-19T18:18:55.674116
2021-05-15T12:51:21
2021-05-15T12:51:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
580
cpp
017 longestIncreasingSubsequence.cpp
class Solution { public: int lengthOfLIS(vector<int>& nums) { if(nums.size()==0) return 0; vector<int> dp(nums.size()); dp[0] = 1; int ans = INT_MIN; for(int i=1; i<nums.size(); i++){ int j=i-1; dp[i] = 1; while(j>=0){ if(nums[i]>nums[j]){ dp[i] = max(dp[i], dp[j]+1); } j--; } ans = max(ans, dp[i-1]); } ans = max(ans, dp[nums.size()-1]); return ans; } };
7a2f326e2e142b3535b16266711aaf4ecd07b28e
07b26489226755b5c746c8f9163b6f9873c9ab67
/LAG-Util.cpp
7a87b972d778dfc6d89b58d33980fe5826b204ce
[ "MIT" ]
permissive
LAG-Comp/LAG-Compiler-I
44b891594465c7fafe6a79f5d8330a33ebf38f08
e00c8ddd2fc4b08a1f8b7880d492d3956a9a0187
refs/heads/master
2021-01-01T10:36:52.646656
2014-12-08T17:53:07
2014-12-08T17:53:07
26,452,422
0
1
null
null
null
null
UTF-8
C++
false
false
9,802
cpp
LAG-Util.cpp
#include "LAG-Util.h" bool is_number(const std::string& s) { std::string::const_iterator it = s.begin(); while (it != s.end() && std::isdigit(*it)) ++it; return !s.empty() && it == s.end(); } int toInt( string n ) { int integer = 0; sscanf( n.c_str(), "%d", &integer ); return integer; } string toStr( int n ) { char buf[1024] = ""; sprintf( buf, "%d", n ); return buf; } string new_label( string cmd, map<string,int> &label_counter ) { return "L_" + cmd +"_" + toStr( ++label_counter[cmd] ); } void init_c_operands_table(map<string,string> &c_op) { c_op["+"] = "+"; c_op["-"] = "-"; c_op["*"] = "*"; c_op["/"] = "/"; c_op["modulo"] = "%"; c_op["and"] = "&&"; c_op["or"] = "||"; c_op["is equal to"] = "=="; c_op["is different from"] = "!="; c_op["is greater than or equals"] = ">="; c_op["is lesser than or equals"] = "<="; c_op["is greater than"] = ">"; c_op["is lesser than"] = "<"; } void init_type_names(map<string,Type> &type_names) { type_names["<string>"] = Type("string"); type_names["<integer>"] = Type("int"); type_names["<boolean>"] = Type("bool"); type_names["<character>"] = Type("char"); type_names["<double_precision>"] = Type("double"); type_names["<floating_point>"] = Type("float"); } void init_operation_results(map<string,Type> &operation_results) { operation_results["<integer>+<integer>"] = Type( "<integer>" ); operation_results["<integer>-<integer>"] = Type( "<integer>" ); operation_results["<integer>*<integer>"] = Type( "<integer>" ); operation_results["<integer>is equal to<integer>"] = Type( "<boolean>" ); operation_results["<integer>modulo<integer>"] = Type( "<integer>" ); operation_results["<integer>/<integer>"] = Type( "<integer>" ); operation_results["<integer>is lesser than<integer>"] = Type( "<boolean>" ); operation_results["<integer>is greater than<integer>"] = Type( "<boolean>" ); operation_results["<integer>is lesser than or equals<integer>"] = Type( "<boolean>" ); operation_results["<integer>is greater than or equals<integer>"] = Type( "<boolean>" ); operation_results["<double_precision>+<double_precision>"] = Type( "<double_precision>" ); operation_results["<double_precision>-<double_precision>"] = Type( "<double_precision>" ); operation_results["<double_precision>*<double_precision>"] = Type( "<double_precision>" ); operation_results["<double_precision>is equal to<double_precision>"] = Type( "<boolean>" ); operation_results["<double_precision>modulo<double_precision>"] = Type( "<double_precision>" ); operation_results["<double_precision>/<double_precision>"] = Type( "<double_precision>" ); operation_results["<double_precision>is lesser than<double_precision>"] = Type( "<boolean>" ); operation_results["<double_precision>is greater than<double_precision>"] = Type( "<boolean>" ); operation_results["<double_precision>is lesser than or equals<double_precision>"] = Type( "<boolean>" ); operation_results["<double_precision>is greater than or equals<double_precision>"] = Type( "<boolean>" ); operation_results["<floating_point>+<floating_point>"] = Type( "<floating_point>" ); operation_results["<floating_point>-<floating_point>"] = Type( "<floating_point>" ); operation_results["<floating_point>*<floating_point>"] = Type( "<floating_point>" ); operation_results["<floating_point>is equal to<floating_point>"] = Type( "<boolean>" ); operation_results["<floating_point>modulo<floating_point>"] = Type( "<floating_point>" ); operation_results["<floating_point>/<floating_point>"] = Type( "<floating_point>" ); operation_results["<floating_point>is lesser than<floating_point>"] = Type( "<boolean>" ); operation_results["<floating_point>is greater than<floating_point>"] = Type( "<boolean>" ); operation_results["<floating_point>is lesser than or equals<floating_point>"] = Type( "<boolean>" ); operation_results["<floating_point>is greater than or equals<floating_point>"] = Type( "<boolean>" ); operation_results["<integer>+<double_precision>"] = Type( "<double_precision>" ); operation_results["<integer>+<floating_point>"] = Type( "<floating_point>" ); operation_results["<double_precision>+<floating_point>"] = Type( "<floating_point>" ); operation_results["<double_precision>+<integer>"] = Type( "<double_precision>" ); operation_results["<floating_point>+<integer>"] = Type( "<floating_point>" ); operation_results["<floating_point>+<double_precision>"] = Type( "<floating_point>" ); operation_results["<integer>-<double_precision>"] = Type( "<double_precision>" ); operation_results["<integer>-<floating_point>"] = Type( "<floating_point>" ); operation_results["<double_precision>-<floating_point>"] = Type( "<floating_point>" ); operation_results["<double_precision>-<integer>"] = Type( "<double_precision>" ); operation_results["<floating_point>-<integer>"] = Type( "<floating_point>" ); operation_results["<floating_point>-<double_precision>"] = Type( "<floating_point>" ); operation_results["<integer>*<double_precision>"] = Type( "<double_precision>" ); operation_results["<integer>*<floating_point>"] = Type( "<floating_point>" ); operation_results["<double_precision>*<floating_point>"] = Type( "<floating_point>" ); operation_results["<double_precision>*<integer>"] = Type( "<double_precision>" ); operation_results["<floating_point>*<integer>"] = Type( "<floating_point>" ); operation_results["<floating_point>*<double_precision>"] = Type( "<floating_point>" ); operation_results["<integer>is equal to<double_precision>"] = Type( "<boolean>" ); operation_results["<integer>is equal to<floating_point>"] = Type( "<boolean>" ); operation_results["<double_precision>is equal to<floating_point>"] = Type( "<boolean>" ); operation_results["<double_precision>is equal to<integer>"] = Type( "<boolean>" ); operation_results["<floating_point>is equal to<integer>"] = Type( "<boolean>" ); operation_results["<floating_point>is equal to<double_precision>"] = Type( "<boolean>" ); operation_results["<integer>modulo<double_precision>"] = Type( "<double_precision>" ); operation_results["<integer>modulo<floating_point>"] = Type( "<floating_point>" ); operation_results["<double_precision>modulo<floating_point>"] = Type( "<floating_point>" ); operation_results["<double_precision>modulo<integer>"] = Type( "<double_precision>" ); operation_results["<floating_point>modulo<integer>"] = Type( "<floating_point>" ); operation_results["<floating_point>modulo<double_precision>"] = Type( "<floating_point>" ); operation_results["<integer>/<double_precision>"] = Type( "<double_precision>" ); operation_results["<integer>/<floating_point>"] = Type( "<floating_point>" ); operation_results["<double_precision>/<floating_point>"] = Type( "<floating_point>" ); operation_results["<double_precision>/<integer>"] = Type( "<double_precision>" ); operation_results["<floating_point>/<integer>"] = Type( "<floating_point>" ); operation_results["<floating_point>/<double_precision>"] = Type( "<floating_point>" ); operation_results["<integer>is lesser than<double_precision>"] = Type( "<boolean>" ); operation_results["<integer>is lesser than<floating_point>"] = Type( "<boolean>t" ); operation_results["<double_precision>is lesser than<floating_point>"] = Type( "<boolean>" ); operation_results["<double_precision>is lesser than<integer>"] = Type( "<boolean>" ); operation_results["<floating_point>is lesser than<integer>"] = Type( "<boolean>" ); operation_results["<floating_point>is lesser than<double_precision>"] = Type( "<boolean>" ); operation_results["<integer>is greater than<double_precision>"] = Type( "<boolean>" ); operation_results["<integer>is greater than<floating_point>"] = Type( "<boolean>" ); operation_results["<double_precision>is greater than<floating_point>"] = Type( "<boolean>" ); operation_results["<double_precision>is greater than<integer>"] = Type( "<boolean>" ); operation_results["<floating_point>is greater than<integer>"] = Type( "<boolean>" ); operation_results["<floating_point>is greater than<double_precision>"] = Type( "<boolean>" ); operation_results["<integer>is lesser than or equals<double_precision>"] = Type( "<boolean>" ); operation_results["<integer>is lesser than or equals<floating_point>"] = Type( "<boolean>t" ); operation_results["<double_precision>is lesser than or equals<floating_point>"] = Type( "<boolean>" ); operation_results["<double_precision>is lesser than or equals<integer>"] = Type( "<boolean>" ); operation_results["<floating_point>is lesser than or equals<integer>"] = Type( "<boolean>" ); operation_results["<floating_point>is lesser than or equals<double_precision>"] = Type( "<boolean>" ); operation_results["<integer>is greater than or equals<double_precision>"] = Type( "<boolean>" ); operation_results["<integer>is greater than or equals<floating_point>"] = Type( "<boolean>" ); operation_results["<double_precision>is greater than or equals<floating_point>"] = Type( "<boolean>" ); operation_results["<double_precision>is greater than or equals<integer>"] = Type( "<boolean>" ); operation_results["<floating_point>is greater than or equals<integer>"] = Type( "<boolean>" ); operation_results["<floating_point>is greater than or equals<double_precision>"] = Type( "<boolean>" ); operation_results["<string>+<string>"] = Type( "<string>" ); operation_results["<character>+<character>"] = Type( "<string>" ); operation_results["<string>+<character>"] = Type( "<string>" ); operation_results["<character>+<string>"] = Type( "<string>" ); operation_results["not<boolean>"] = Type( "<boolean>" ); operation_results["<boolean>and<boolean>"] = Type( "<boolean>" ); operation_results["<boolean>or<boolean>"] = Type( "<boolean>" ); }
ad643742f21079b8115b06ac7b62511bfb8a0e63
30bdd8ab897e056f0fb2f9937dcf2f608c1fd06a
/contest/1542581639.cpp
86c65d8f90f8d448934a7b4a3e218913386a5da4
[]
no_license
thegamer1907/Code_Analysis
0a2bb97a9fb5faf01d983c223d9715eb419b7519
48079e399321b585efc8a2c6a84c25e2e7a22a61
refs/heads/master
2020-05-27T01:20:55.921937
2019-11-20T11:15:11
2019-11-20T11:15:11
188,403,594
2
1
null
null
null
null
UTF-8
C++
false
false
1,440
cpp
1542581639.cpp
/* Cerberus97 Hanit Banga */ #include <iostream> #include <iomanip> #include <cmath> #include <cstdio> #include <cstring> #include <cstdlib> #include <map> #include <set> #include <queue> #include <stack> #include <vector> #include <algorithm> using namespace std; #define pb push_back #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL) typedef long long ll; typedef pair <int, int> pii; typedef pair <ll, ll> pll; const int kN = 18, kK = 6; int a[kN]; int main() { int n, k; cin >> n >> k; for (int i = 1; i <= n; ++i) { int temp = 0; for (int j = 0; j < k; ++j) { int x; cin >> x; temp |= (x << j); } a[temp]++; } int types = (1 << k); int subsets = (1 << types); bool ans = false; for (int i = 1; i < subsets; ++i) { int ctr[kK] = {0}, total = 0; bool temp = true; for (int j = 0; j < types; ++j) { if (i & (1 << j)) { if (!a[j]) { temp = false; break; } ++total; for (int l = 0; l < k; ++l) { if (j & (1 << l)) { ctr[l]++; } } } } if (temp) { ans = true; for (int l = 0; l < k; ++l) { if (2 * ctr[l] > total) { ans = false; break; } } if (ans) { break; } } } if (ans) { cout << "YES"; } else { cout << "NO"; } }
a4cb79df14d547467cfed11d42537561ab32d80c
128c175be7f895a04aff9ea2e7f0a97313753e5d
/Engine/PoisonField.cpp
966a05f7f0f1d47ce9ca727aaa766cb3d8c29f12
[]
no_license
m1zu/snekGeM
3974d2ac9c9dbb107c575cb9a4477329e2c37466
866c23cddbc97a5b97fcd32248bc2da8a68e9627
refs/heads/master
2020-03-19T03:45:14.559420
2018-06-23T16:44:52
2018-06-23T16:44:52
135,758,661
0
0
null
null
null
null
UTF-8
C++
false
false
586
cpp
PoisonField.cpp
#include "PoisonField.h" #include "Snake.h" Poisionfield::Poisionfield(Board& brd) : brd(brd) { for(int i=0; i< nPoisonGrids; ++i) poisonField[brd.GetRandom_1Dmapped_gridPos()]=true; } bool Poisionfield::collisionWith(const Snake & snake) { const int snake1DmappedPos = snake.GetSegmentLocation(0).y*brd.width + snake.GetSegmentLocation(0).x; return poisonField[snake1DmappedPos]; } void Poisionfield::Draw(const Board & brd) { for (int i = 0; i < nMappedGrid; ++i) if(poisonField[i]) brd.DrawCell(Location(i%brd.width, i / brd.width), Colors::MakeRGB(100, 20, 100)); }
69bb05966bf5f084d7941b0b37114fc66727c14d
1384d971c64e5fee731baaccc5bc9d836314630e
/test/uno/action/card_mock.h
9ed2e20111788434543a55d96f5770f480dc6829
[]
no_license
erenon/casino
c346495a91797d3706684670cf99320cea47e82c
de39cccdb70f9d8f7d8457dfb162b6751c2dd359
refs/heads/master
2020-05-31T23:41:28.741917
2012-01-24T17:28:30
2012-01-24T17:28:30
1,942,661
0
1
null
null
null
null
UTF-8
C++
false
false
474
h
card_mock.h
#ifndef CTU_CARD_MOCK_H_ #define CTU_CARD_MOCK_H_ #include "gmock/gmock.h" #include "../../../src/uno/action/card.h" #include "../../../src/uno/game/game.h" namespace Casino { namespace Test { namespace Uno { namespace Action { using ::Casino::Uno::Action::Card; using ::Casino::Uno::Game::Game; class CardMock :public Card { public: MOCK_METHOD0(isDisposeable, bool()); MOCK_METHOD1(takeAction, void(Game* game)); }; }}}} //namespace #endif /* CTU_CARD_MOCK_H_ */
943e0f954c9498168c9476183e6126df3288c3dd
129cdb6bce9b9dbb8e3b6447cd55dbe332d6b5bd
/Visitor.cpp
aa4699e7b0a09ff2c2f3e5373c44e0a9873be5ab
[]
no_license
tclin914/mj2MIPS
b072fde978996b2496abbaa8ccf64ee05929fcd4
e436f8c7b85dc1696911a657b99e27e0a6b9261e
refs/heads/master
2020-05-17T22:24:36.175466
2015-05-11T03:24:18
2015-05-11T03:24:18
28,191,309
0
0
null
null
null
null
UTF-8
C++
false
false
138
cpp
Visitor.cpp
#include "Visitor.h" #include "Node.h" void Visitor::SetSymbolTable(SymbolTable* symbolTable) { this -> symbolTable = symbolTable; }
2b194bfb470ee2fae350a3cdb2f414a878267631
9954eadf2758b386eedf7711105636f20e98a716
/woah_scheme/src/transform.cc
5cdbbe61149be258df9bdbd7857468175cb94098
[]
no_license
UML-Robotics-Club/igvc-2012
1b95dce98a95d8821632d9bea02308038bb7270a
aadab8c9bcc143e990c564ac22c20c25bb859396
refs/heads/master
2021-01-20T05:07:46.893070
2012-06-13T15:37:48
2012-06-13T15:37:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
701
cc
transform.cc
#include "woah_scheme/transform.hh" void getTransform(std::string to, std::string from, ros::Time time, ros::Duration duration, double& x, double& y, double& yaw) // <- return values { static tf::TransformListener* tfListener = new tf::TransformListener(); tf::StampedTransform transform; try { tfListener->waitForTransform(to, from, time, duration); tfListener->lookupTransform(to, from, time, transform); } catch (tf::TransformException ex) { ROS_ERROR("%s",ex.what()); } double r, p; btMatrix3x3(transform.getRotation()).getRPY(r, p, yaw); x = transform.getOrigin().x(); y = transform.getOrigin().y(); }
b8c28e1256717020de632c5c89d3f3b975235c5d
b68741df720668a54b3d0896f4a350d6654ac095
/src/utils/FileUtils.h
8422cceaf1714cc93d8150ea95d696281993d3e1
[ "BSD-2-Clause-Views" ]
permissive
ls1mardyn/ls1-mardyn
93a3f1b95b3b4fb06800dd9a2a2a2cc33fe7648a
af5365a92dc5960a19bc35128bf9c38eb1c260a6
refs/heads/master
2023-08-28T14:40:36.574730
2023-08-09T10:04:34
2023-08-09T10:04:34
152,977,725
23
19
NOASSERTION
2023-09-08T08:55:34
2018-10-14T13:38:41
C++
UTF-8
C++
false
false
2,499
h
FileUtils.h
/* * FileUtils.h * * @Date: 26.08.2010 * @Author: Wolfgang Eckhardt */ #ifndef FILEUTILS_H_ #define FILEUTILS_H_ #include <string> #include <cstddef> #include <limits> #include <cstdint> // write out data in scientific format with max. number of digits #define FORMAT_SCI_MAX_DIGITS std::setw(24) << std::scientific << std::setprecision(std::numeric_limits<double>::digits10) #define FORMAT_SCI_MAX_DIGITS_WIDTH_21 std::setw(21) << std::scientific << std::setprecision(std::numeric_limits<double>::digits10) /** * Check if a file exists. */ bool fileExists(const char* fileName); /* * Get the file name extension marked by the last '.' in the filename. */ std::string getFileExtension(const char* fileName); /** @brief check, if a filepath is an absolute path * * @return bool is absolute path */ bool isAbsolutePath(const std::string& path); /** * Delete a file from the system. */ void removeFile(const char* fileName); /** * Retrieve the size of a file. * * @return 0 if an error occurred retrieving the size, so the user has to check * if the file exists. */ unsigned int getFileSize(const char* fileName); /** * Adding string of numbers with leading zeros to stream (e.g. simstep in output filename) */ struct fill_width { fill_width( char f, std::uint8_t w ) : fill(f), width(w) {} char fill; int width; }; std::ostream& operator<<( std::ostream& o, const fill_width& a ); /* * Split / Tokenize a string * copied from here: http://www.cplusplus.com/faq/sequences/strings/split/ * * call e.g. like this: * * std::vector<string> fields; * std::string str = "split:this:string"; * fields = split( fields, str, ":", split_type::no_empties ); * */ struct split_type { enum empties_t { empties_ok, no_empties }; }; template <typename Container> Container& split( Container& result, const typename Container::value_type& s, const typename Container::value_type& delimiters, split_type::empties_t empties = split_type::empties_ok ) { result.clear(); size_t current; size_t next = -1; do { if (empties == split_type::no_empties) { next = s.find_first_not_of( delimiters, next + 1 ); if (next == Container::value_type::npos) break; next -= 1; } current = next + 1; next = s.find_first_of( delimiters, current ); result.push_back( s.substr( current, next - current ) ); } while (next != Container::value_type::npos); return result; } #endif /* FILEUTILS_H_ */
b329576fc48f58fe6ebded5005794b21c4759cab
ab83d87c6ca30e045ce4da856d6d3f291bb54061
/GameObjects/Actors/enemy.cpp
33b63d7b7e03e3ec1f4deb4ab20dc52b34c06074
[]
no_license
spen-mosk/polandball-game
872a6ef545db7b3993ccbf7a1e7263350a099ef3
ba6113556399964860aa27a87e6f14377fd23c83
refs/heads/master
2022-11-06T17:29:52.653817
2017-07-09T19:51:00
2017-07-09T19:51:00
61,672,130
0
1
null
2022-10-30T11:41:13
2016-06-21T22:44:06
Python
UTF-8
C++
false
false
7,637
cpp
enemy.cpp
#include "enemy.h" #include "ourmath.h" #include "astargraph.h" #include <cmath> using namespace std; Enemy::Enemy(int x, int y, EnemyStatistics* stat): Actor(x,y,stat, stat->getAwarenessRange()) { this->stats = stat; this->verticalSpeed = 3; this->lockedOn = false; } //(int radius, int speed, int maxhealth, bool ally, int grav,AttackStatistics* atk, int jumps, int aware) //(int h, int w, int d, bool allied, int dmg, int speed, bool isMelee, int dlay) void Enemy::write(FILE *stream){ std::string string = "enemy\t"; AttackStatistics * attak = stats->getAttackInfo(); string += std::to_string(this->x()) + "\t" + std::to_string(this->y()) + "\t" + std::to_string(stats->getRadius()) + "\t" + std::to_string(stats->getSpeed()) + "\t" + std::to_string(stats->getMaxHealth()) + "\t" + std::to_string(stats->isAlly() ? 1 : 0) + "\t" + std::to_string(stats->getGravity()) + "\t" + std::to_string(attak->getHeight()) + "\t" + std::to_string(attak->getWidth()) + "\t" + std::to_string(attak->getDuration()) +"\t" + std::to_string(attak->isAlly() ? 1 : 0) + "\t" + std::to_string(attak->getDamage()) + "\t" + std::to_string(attak->getSpeed()) + "\t" + std::to_string(attak->isMelee() ? 1 : 0) + "\t" + std::to_string(attak->getDelay()) + "\n"; fprintf(stream, "%s", string.c_str()); } void Enemy::update(){ /* if(lockedOn){ //stuff if(canAttack()){ //stuff }else{ //stuff } } */ //check lockedIn here Actor::update(); if(nextPoint == NULL && this->path.size() != 0){ nextPoint = *(this->path.begin()); this->path.erase(this->path.begin()); } if(!this->getGrav()){ resetJump(); } if(canAttack()){ printf("powpow"); //DO we want to move if we canAttack? //Probably not } //if we can't attack, we may want to move else //if we are where we want to be, nextPoint will be null if(nextPoint != NULL && abs(this->getCenter()->y() - nextPoint->y()) < this->getRadius()){ if(nextPoint->x() < this->x()){ this->updateLocation(-this->stats->getSpeed(), 0); } else{ this->updateLocation(this->stats->getSpeed(), 0); } } //this means some jumping or descending is involved, and means changing platforms //we need to do calculations to see if we can make it //Its 5:00 am, I don't feel like doing those right now else if(nextPoint != NULL){ int realMax = stats->getMaxJumps() - this->jumpCount; int jumpHeight = (verticalSpeed - stats->getGravity()) * realMax; int xDist = abs(nextPoint->x() - this->x()); int cycles = xDist / this->stats->getSpeed(); int descent = stats->getGravity() * (cycles - realMax); int yHeight = jumpHeight - descent; if(this->jumpCount > stats->getMaxJumps() || yHeight > nextPoint->y()){ this->jump(); if(this->x() < nextPoint->x()){ this->updateLocation(this->stats->getSpeed(), 0); } else if(this->x() > nextPoint->x()){ this->updateLocation(-this->stats->getSpeed(), 0); } } } if(nextPoint != NULL && distance(nextPoint, new QPoint(this->x(), this->y())) <= 1 && this->path.size() > 0){ nextPoint = *(this->path.begin()); this->path.erase(this->path.begin()); } else if(this->path.size() == 0){ nextPoint = NULL; } //printf("ENEMY X: %d, ENEMY Y %d\n", this->x(), this->y()); this->setGrav(true); } void Enemy::draw(QPainter * p){ p->setBrush(Qt::red); p->drawEllipse(drawingX, drawingY, drawingHeight, drawingWidth); } void Enemy::handleCollision(GameObject * obj){ if(Player * act = dynamic_cast<Player*>(obj)){ //TODO this is actually wrong, but it works for now if(act->isAlly() == this->isAlly()){ this->lockOn(act); } } } void Enemy::jump(){ if(this->jumpCount++ < this->stats->getMaxJumps()){ this->updateLocation(0, this->verticalSpeed); } } void Enemy::maximizeJump(){ } void Enemy::resetJump(){ this->jumpCount = 0; } void Enemy::lockOn(Actor* p){ AstarGraph& graph = AstarGraph::getInstance(); if(!lockedOn){ this->lockedOn = true; this->lock = p; //instead of passing in coords of lock, determine optimal attack position this->path = graph.findPath(new QPoint(this->x(), this->y()), new QPoint(p->x(), p->y())); } //always lock onto the closest adversary else{ if(distance(this, p) < distance(this, lock)){ this->lock = p; //change this so instead of generating a new path, we modify the existing path //instead of passing in coords of enemy, determine optimal attack position this->path = graph.findPath(new QPoint(this->x(), this->y()), new QPoint(p->x(), p->y())); } else if(distance(this, p) == distance(this, lock) && this->path.size() > 0){ this->path = graph.modifyPath(this->path, new QPoint(p->x(), p->y())); /* if(this->path.size() > 1){ QPoint * last = this->path[this->path.size()-1]; QPoint * second = this->path[this->path.size()-2]; QPoint target = QPoint(p->x(), p->y()); if((target.x() < last->x() && target.x() > second->x()) || (target.x() > last->x() && target.x() < second->x())){ this->path.erase(--(this->path.end())); } this->path.push_back(&target); } */ } else if(this->path.size() == 0){ this->path = graph.findPath(new QPoint(this->x(), this->y()), new QPoint(p->x(), p->y())); /* if(this->path.size() > 1){ QPoint * last = this->path[this->path.size()-1]; QPoint * second = this->path[this->path.size()-2]; QPoint target = QPoint(p->x(), p->y()); if((target.x() < last->x() && target.x() > second->x()) || (target.x() > last->x() && target.x() < second->x())){ this->path.erase(--(this->path.end())); } this->path.push_back(&target); } */ } } } void Enemy::cancelLock(){ this->lockedOn = false; } bool Enemy::canAttack(){ if(lockedOn == false){ return false; }else{ int eBot = this->getCenter()->y() + this->getRadius(); int tBot = this->lock->getCenter()->y() + this->lock->getRadius(); if(eBot != tBot){ return false; } AttackStatistics *myatk = stats->getAttackInfo(); if(myatk->isMelee()){ return distance(this,lock) < myatk->getWidth(); } else{ return distance(this,lock) < myatk->getSpeed()*myatk->getDuration(); } } //bool stuff based on player's position, speed, and size of enemy's attack //this will be more if we are not locked in return lockedOn && false; } Attack* Enemy::generateAttack(){ AttackStatistics *myatk = stats->getAttackInfo(); Attack* attack; if(myatk->isMelee()){ attack = new MeleeAttack(this->getCenter()->x(),this->getCenter()->y() + myatk->getHeight()/2, myatk, this); } else{ attack = new RangedAttack(this->getCenter()->x(),this->getCenter()->y() + myatk->getHeight()/2, this->facingLeft(), myatk); } return attack; }
cff9349a64013f72f601cd5501932266a5f3d2ab
a03167bc03d1a9f0949c3c7b0e428246bce1afcd
/wydatnik.h
f0dbbd245c3bcf927d4233e8c1b3d6b1636ceb3a
[]
no_license
peter890/Wydatnik
86b5a2c0a1c79e4afe130a66ab6aa710ba6b480a
ddd23e479e1560af2883a7bf17dbc8140d4fe0cb
refs/heads/master
2016-09-06T15:06:43.532374
2011-10-02T17:43:10
2011-10-02T17:43:10
1,944,069
0
0
null
null
null
null
UTF-8
C++
false
false
3,000
h
wydatnik.h
#ifndef WYDATNIK_H #define WYDATNIK_H #include <QtGui> #include <QMainWindow> #include <QSqlDatabase> #include <QSqlQuery> #include <QSqlQueryModel> #include <QSqlError> #include<QtSql> #include <QDebug> #include <QMessageBox> #include <QTextCodec> #include <QDate> #include <QCalendarWidget> #include <QDateEdit> #include <QSignalMapper> #include <QSettings> #include <vector> #include <QList> #include "login.h" #include "registration.h" #include "rozchody.h" #include "wykres.h" #include "obserwator.h" #include "obserwowany.h" #include "mycheckbox.h" #include "editdata.h" using namespace std; namespace Ui { class Wydatnik; } class Login; class Registration; class Rozchody; class EditData; class Wydatnik : public QMainWindow , public Obserwowany { Q_OBJECT public: static Wydatnik* getInstance(); bool zalogowany(); bool zaloguj(QString _login, QString _haslo); int getUserid(); QSqlDatabase* db; QSignalMapper* signalMapper; QSignalMapper* signalMapper2; bool connectDB(QString _hostname, QString _username, QString _password, QString _dbname, int _port); void DBError(QSqlError _error); void Error(QString _error); void exec(QString _query); void zaladujDane(QSqlQuery zapytanie); virtual void dodajObserwatora(Obserwator *); virtual void usunObserwatora(Obserwator *); vector<Dane*> getData(); ~Wydatnik(); private: Ui::Wydatnik *ui; explicit Wydatnik(QWidget *parent = 0); static Wydatnik* instance; QList<Obserwator*>Obserwatorzy; int userid; bool connected; QSqlQueryModel *queryModel; Login* login; QString userName; Registration* registration; Rozchody* rozchody; vector<Dane*> dane; QCalendarWidget* calendar; EditData* editData; QStringList lista; QList<QWidget*> lista_zaznaczone; //lista ktora przechowuje informacje o zaznaczonych MyCheckBoxach. mozna wysciagnac info ktory wiersz i jakie id z mysql. void zaladujPolaczenia(); vector<Pamiatka*> historia; //vektor ktory zapamietuje ostatnio wykonanie operacje(zapytania sql odwrotne do wykonanych, tak zeby dało sie odwrócić czynnosc) QToolBar* fileToolBar; QToolBar* editToolBar; protected: virtual void keyPressEvent(QKeyEvent *); virtual void contextMenuEvent(QContextMenuEvent *event); public slots: void wyloguj(); void zaloguj(); void rejestracja(); void dodajWydatek(); void ustawDate(QWidget* o); void RefreshData(Obserwowany *o); void zaznaczenie(QWidget*); void ZapiszStan(QString); void OdtworzStan(); void aktualizujSaldo(); void wyszukaj(); private slots: void changeConnection(bool _connected); void zmienStan(bool); void edytuj(); void createMenu(); signals: void changedConnection(bool _connected); }; #endif // WYDATNIK_H
5fceae30904144c6231e52bfb2ea53426225bae5
72dbcd4364b1d1fd96e418f05d72f2b38c8693e4
/src-tex/tex_demo.cpp
4dd835c584b2e4d6c5f52b1fc7bdd4ff5329afd6
[ "MIT" ]
permissive
magicmoremagic/bengine-demos-gfx
baf641c448871b420dfb82ac24f33d8fe50776a7
688e81ad5289c99a38dda50f04a465798815c4c0
refs/heads/master
2021-01-19T08:46:00.320698
2018-01-06T06:41:20
2018-01-06T06:41:20
87,671,887
0
0
null
null
null
null
UTF-8
C++
false
false
25,989
cpp
tex_demo.cpp
#include "tex_demo.hpp" #include <be/core/logging.hpp> #include <be/core/version.hpp> #include <be/core/stack_trace.hpp> #include <be/core/alg.hpp> #include <be/util/keyword_parser.hpp> #include <be/util/get_file_contents.hpp> #include <be/gfx/version.hpp> #include <be/gfx/tex/pixel_access_norm.hpp> #include <be/gfx/tex/make_texture.hpp> #include <be/gfx/tex/visit_texture.hpp> #include <be/gfx/tex/convert_colorspace_static.hpp> #include <be/gfx/tex/image_format_gl.hpp> #include <be/gfx/tex/texture_reader.hpp> #include <be/gfx/tex/blit_pixels.hpp> #include <be/gfx/tex/log_texture_info.hpp> #include <be/cli/cli.hpp> #include <be/gfx/bgl.hpp> #include <glm/gtx/norm.hpp> #include <glm/common.hpp> #include <sstream> #include <string> using namespace be; using namespace be::gfx; using namespace be::gfx::gl; using namespace be::gfx::tex; /////////////////////////////////////////////////////////////////////////////// TexDemo::TexDemo(int argc, char** argv) { default_log().verbosity_mask(v::info_or_worse); try { using namespace cli; using namespace color; using namespace ct; Processor proc; bool show_version = false; bool show_help = false; bool verbose = false; S help_query; format_ = canonical_format(GL_SRGB_ALPHA); proc (prologue(Table() << header << "be::gfx::tex Demo").query()) (synopsis(Cell() << fg_dark_gray << "[ " << fg_cyan << "OPTIONS" << fg_dark_gray << " ] " << fg_cyan << "DEMO")) (summary(Table() << header << "Demo Name" << cell << "Description" << row << "ub" << cell << "Displays uninitialized texture data. Technically this is undefined behavior." << row << "whitenoise" << cell << "." << row << "rgbnoise" << cell << "." << row << "gradient" << cell << "Draws a gradient on the texture with random colors at each corner and interpolates linearly between them." << row << "sinc" << cell << "Draws a gray field, perturbed towards white and black based on a sinc filter. Use " << fg_yellow << "--effect-scale" << reset << " to change the 'zoom' factor." << row << "cosdst2" << cell << "Draws a texture where each pixel's value is the cosine of the square of its distance form the center of the texture. Use " << fg_yellow << "--effect-scale" << reset << " to change the 'zoom' factor." << row << "pinwheel" << cell << "Draws a texture where each pixel's hue is determined by its angle around the center. Use " << fg_yellow << "--effect-scale" << reset << " to change the frequency of color change." << row << "pinwheel-r" << cell << "Like pinwheel, but discards the blue/green channels and uses red instead." << row << "view" << cell << "Attempt to load the image file specified by " << fg_yellow<< "--file" << reset << " and display it." )) (any( [this](const S& arg) { S demo = arg; std::transform(demo.begin(), demo.end(), demo.begin(), [](char c) { return (char)tolower(c); }); if (demo == "ub") { generator_ = []() { }; } else if (demo == "whitenoise") { generator_ = [this]() { auto put = put_pixel_norm_func<ivec2>(tex_.view.image()); visit_texture_pixels<ivec2>(tex_.view, [=](ImageView& view, ivec2 pc) { F32 val = fdist_(rnd_); vec4 pixel_norm = vec4(val); put(view, pc, pixel_norm); }); }; } else if (demo == "rgbnoise") { generator_ = [this]() { auto put = put_pixel_norm_func<ivec2>(tex_.view.image()); visit_texture_pixels<ivec2>(tex_.view, [=](ImageView& view, ivec2 pc) { vec4 pixel_norm = vec4(fdist_(rnd_), fdist_(rnd_), fdist_(rnd_), 1.f); put(view, pc, pixel_norm); }); }; } else if (demo == "gradient") { setup_ = [this]() { for (int i = 0; i < 8; ++i) { data_[i] = vec4(fdist_(rnd_), fdist_(rnd_), fdist_(rnd_), 1.f); } }; generator_ = [this]() { if (time_ > 1.f) { time_ = 0; for (int i = 0; i < 4; ++i) { data_[i] = data_[4 + i]; } for (int i = 4; i < 8; ++i) { data_[i] = vec4(fdist_(rnd_), fdist_(rnd_), fdist_(rnd_), 1.f); } } F32 f = glm::smoothstep(0.f, 1.f, F32(time_)); vec4 a = glm::mix(data_[0], data_[4], f); vec4 b = glm::mix(data_[1], data_[5], f); vec4 c = glm::mix(data_[2], data_[6], f); vec4 d = glm::mix(data_[3], data_[7], f); auto put = put_pixel_norm_func<ivec2>(tex_.view.image()); visit_texture_pixels<ivec2>(tex_.view, [=](ImageView& view, ivec2 pc) { vec4 ab = glm::mix(a, b, (pc.x + 0.5f) / view.dim().x); vec4 cd = glm::mix(c, d, (pc.x + 0.5f) / view.dim().x); vec4 pixel_norm = glm::mix(ab, cd, (pc.y + 0.5f) / view.dim().y); put(view, pc, pixel_norm); }); }; } else if (demo == "sinc") { generator_ = [this]() { auto put = put_pixel_norm_func<ivec2>(tex_.view.image()); visit_texture_pixels<ivec2>(tex_.view, [=](ImageView& view, ivec2 pc) { vec2 center = vec2(view.dim()) / 2.f; vec2 pixel_center = vec2(pc) + 0.5f; vec2 offset = pixel_center - center; F32 dst = glm::length(offset); F32 val = 0.5f * (1.f + sinf(dst / effect_scale_) / (dst / effect_scale_)); vec4 pixel_norm = vec4(val); put(view, pc, pixel_norm); }); }; } else if (demo == "cosdst2") { generator_ = [this]() { auto put = put_pixel_norm_func<ivec2>(tex_.view.image()); visit_texture_pixels<ivec2>(tex_.view, [=](ImageView& view, ivec2 pc) { vec2 center = vec2(view.dim()) / 2.f; vec2 pixel_center = vec2(pc) + 0.5f; vec2 offset = pixel_center - center; F32 dst2 = glm::length2(offset); F32 val = 0.5f * (1.f + cosf(dst2 / effect_scale_)); vec4 pixel_norm = vec4(val); put(view, pc, pixel_norm); }); }; } else if (demo == "pinwheel") { generator_ = [this]() { auto put = put_pixel_norm_func<ivec2>(tex_.view.image()); visit_texture_pixels<ivec2>(tex_.view, [=](ImageView& view, ivec2 pc) { vec2 center = vec2(view.dim()) / 2.f; vec2 pixel_center = vec2(pc) + 0.5f; vec2 offset = pixel_center - center; F32 angle = atan2f(offset.y, offset.x) + glm::pi<F32>(); vec4 pixel_norm = convert_colorspace<Colorspace::bt709_linear_hsl, Colorspace::srgb>( vec4((angle * effect_scale_ + 2.f * (sin_time_ + 1.f)) / (glm::pi<F32>() * 2.f), 0.5f, 0.5f, 1.f)); put(view, pc, pixel_norm); }); }; } else if (demo == "pinwheel-r") { generator_ = [this]() { auto put = put_pixel_norm_func<ivec2>(tex_.view.image()); visit_texture_pixels<ivec2>(tex_.view, [=](ImageView& view, ivec2 pc) { vec2 center = vec2(view.dim()) / 2.f; vec2 pixel_center = vec2(pc) + 0.5f; vec2 offset = pixel_center - center; F32 angle = atan2f(offset.y, offset.x) + glm::pi<F32>(); vec4 pixel_norm = convert_colorspace<Colorspace::bt709_linear_hsl, Colorspace::srgb>( vec4((angle * effect_scale_ + 2.f * (sin_time_ + 1.f)) / (glm::pi<F32>() * 2.f), 0.5f, 0.5f, 1.f)); pixel_norm = vec4(pixel_norm.r); put(view, pc, pixel_norm); }); }; } else if (demo == "view") { generator_ = [this]() { TextureReader reader; reader.read(file_); Texture tex = reader.texture(); gfx::tex::log_texture_info(tex.view, file_.string()); //tex_ = std::move(tex); dim_ = tex.view.dim(0); tex_ = make_planar_texture(format_, dim_, 1); auto dest = tex_.view.image(0,0,0); be::gfx::tex::blit_pixels(tex.view.image(0, 0, 0), dest); }; } else if (demo == "view-na") { generator_ = [this]() { TextureReader reader; reader.read(file_); Texture tex = reader.texture(); be::gfx::tex::visit_texture_pixels<ivec2>(tex.view, [](be::gfx::tex::ImageView& v, ivec2 pc) { RGBA p = be::gfx::tex::get_block<RGBA>(v, pc); p.a = 255; be::gfx::tex::put_block(v, pc, p); }); dim_ = tex.view.dim(0); tex_ = make_planar_texture(format_, dim_, 1); auto dest = tex_.view.image(0,0,0); be::gfx::tex::blit_pixels(tex.view.image(0, 0, 0), dest); }; } else { return false; } return true; })) (param({ "w", "x" },{ "width" }, "Set the width of the texture.", [this](const S& value) { std::istringstream iss(value); iss >> dim_.x; return true; })) (param({ "h", "y" },{ "height" }, "Set the height of the texture.", [this](const S& value) { std::istringstream iss(value); iss >> dim_.y; return true; })) (flag({ "r" },{ "resizable" }, resizable_).desc("Make the window resizable.")) (param({ "s" },{ "scale" }, "SCALE", [this](const S& value) { std::istringstream iss(value); iss >> scale_; return true; }).desc("Set the scale at which to show the texture.")) (param({ "f" },{ "format" }, "FORMAT", [this](const S& value) { using namespace gl; util::KeywordParser<gl::GLenum> parser(GL_SRGB_ALPHA); parser /*!! register_template_string([[`with each $ using # { `(GL_`$`, "GL_`$`", "`$`")` nl }]], 'kw') write_template('kw', { 'R8', 'R16', 'R8_SNORM', 'R16_SNORM', 'R8UI', 'R16UI', 'R32UI', 'R8I', 'R16I', 'R32I', 'R16F', 'R32F', 'RG8', 'RG16', 'RG8_SNORM', 'RG16_SNORM', 'RG8UI', 'RG16UI', 'RG32UI', 'RG8I', 'RG16I', 'RG32I', 'RG16F', 'RG32F', 'SRGB8', 'RGB8', 'RGB16', 'R3_G3_B2', --[['RGB565',]] 'RGB4', 'RGB5', 'RGB8_SNORM', 'RGB16_SNORM', 'RGB8UI', 'RGB16UI', 'RGB32UI', 'RGB8I', 'RGB16I', 'RGB32I', 'R11F_G11F_B10F', 'RGB16F', 'RGB32F', 'RGB9_E5', 'RGBA16', 'RGBA4', 'RGB5_A1', 'RGB10_A2', 'RGBA8_SNORM', 'RGBA16_SNORM', 'RGBA8UI', 'RGBA16UI', 'RGBA32UI', 'RGB10_A2UI', 'RGBA8I', 'RGBA16I', 'RGBA32I', 'RGBA16F', 'RGBA32F', 'SRGB8_ALPHA8', 'RGBA8' }) !! 63 */ /* ################# !! GENERATED CODE -- DO NOT MODIFY !! ################# */ (GL_R8, "GL_R8", "R8") (GL_R16, "GL_R16", "R16") (GL_R8_SNORM, "GL_R8_SNORM", "R8_SNORM") (GL_R16_SNORM, "GL_R16_SNORM", "R16_SNORM") (GL_R8UI, "GL_R8UI", "R8UI") (GL_R16UI, "GL_R16UI", "R16UI") (GL_R32UI, "GL_R32UI", "R32UI") (GL_R8I, "GL_R8I", "R8I") (GL_R16I, "GL_R16I", "R16I") (GL_R32I, "GL_R32I", "R32I") (GL_R16F, "GL_R16F", "R16F") (GL_R32F, "GL_R32F", "R32F") (GL_RG8, "GL_RG8", "RG8") (GL_RG16, "GL_RG16", "RG16") (GL_RG8_SNORM, "GL_RG8_SNORM", "RG8_SNORM") (GL_RG16_SNORM, "GL_RG16_SNORM", "RG16_SNORM") (GL_RG8UI, "GL_RG8UI", "RG8UI") (GL_RG16UI, "GL_RG16UI", "RG16UI") (GL_RG32UI, "GL_RG32UI", "RG32UI") (GL_RG8I, "GL_RG8I", "RG8I") (GL_RG16I, "GL_RG16I", "RG16I") (GL_RG32I, "GL_RG32I", "RG32I") (GL_RG16F, "GL_RG16F", "RG16F") (GL_RG32F, "GL_RG32F", "RG32F") (GL_SRGB8, "GL_SRGB8", "SRGB8") (GL_RGB8, "GL_RGB8", "RGB8") (GL_RGB16, "GL_RGB16", "RGB16") (GL_R3_G3_B2, "GL_R3_G3_B2", "R3_G3_B2") (GL_RGB4, "GL_RGB4", "RGB4") (GL_RGB5, "GL_RGB5", "RGB5") (GL_RGB8_SNORM, "GL_RGB8_SNORM", "RGB8_SNORM") (GL_RGB16_SNORM, "GL_RGB16_SNORM", "RGB16_SNORM") (GL_RGB8UI, "GL_RGB8UI", "RGB8UI") (GL_RGB16UI, "GL_RGB16UI", "RGB16UI") (GL_RGB32UI, "GL_RGB32UI", "RGB32UI") (GL_RGB8I, "GL_RGB8I", "RGB8I") (GL_RGB16I, "GL_RGB16I", "RGB16I") (GL_RGB32I, "GL_RGB32I", "RGB32I") (GL_R11F_G11F_B10F, "GL_R11F_G11F_B10F", "R11F_G11F_B10F") (GL_RGB16F, "GL_RGB16F", "RGB16F") (GL_RGB32F, "GL_RGB32F", "RGB32F") (GL_RGB9_E5, "GL_RGB9_E5", "RGB9_E5") (GL_RGBA16, "GL_RGBA16", "RGBA16") (GL_RGBA4, "GL_RGBA4", "RGBA4") (GL_RGB5_A1, "GL_RGB5_A1", "RGB5_A1") (GL_RGB10_A2, "GL_RGB10_A2", "RGB10_A2") (GL_RGBA8_SNORM, "GL_RGBA8_SNORM", "RGBA8_SNORM") (GL_RGBA16_SNORM, "GL_RGBA16_SNORM", "RGBA16_SNORM") (GL_RGBA8UI, "GL_RGBA8UI", "RGBA8UI") (GL_RGBA16UI, "GL_RGBA16UI", "RGBA16UI") (GL_RGBA32UI, "GL_RGBA32UI", "RGBA32UI") (GL_RGB10_A2UI, "GL_RGB10_A2UI", "RGB10_A2UI") (GL_RGBA8I, "GL_RGBA8I", "RGBA8I") (GL_RGBA16I, "GL_RGBA16I", "RGBA16I") (GL_RGBA32I, "GL_RGBA32I", "RGBA32I") (GL_RGBA16F, "GL_RGBA16F", "RGBA16F") (GL_RGBA32F, "GL_RGBA32F", "RGBA32F") (GL_SRGB8_ALPHA8, "GL_SRGB8_ALPHA8", "SRGB8_ALPHA8") (GL_RGBA8, "GL_RGBA8", "RGBA8") /* ######################### END OF GENERATED CODE ######################### */ ; std::error_code ec; format_ = canonical_format(parser.parse(value, ec)); if (ec) { throw RecoverableError(ec); } }).desc("Set OpenGL internal format.")) (param({ }, { "file" }, "PATH", [&](const S& value) { file_ = value; }).desc("Specifies the path to an image file for demos that require an input image.")) (numeric_param({ "e" }, { "effect-scale" }, "X", effect_scale_).desc("Set the scale for effects (exact meaning depends on demo).")) (numeric_param({ "t" }, { "time-scale" }, "X", time_scale_).desc("Sets the time scale. Higher numbers mean faster.")) (flag({ }, { "linear" }, linear_scaling_).desc("Use linear scaling instead of nearest-neighbor.")) (flag({ "a" }, { "animate" }, animate_).desc("Enables animation.")) (end_of_options()) (verbosity_param({ "v" }, { "verbosity" }, "LEVEL", default_log().verbosity_mask())) (flag({ "V" }, { "version" }, show_version).desc("Prints version information to standard output.")) (param({ "?" }, { "help" }, "OPTION", [&](const S& value) { show_help = true; help_query = value; }).default_value(S()) .allow_options_as_values(true) .desc(Cell() << "Outputs this help message. For more verbose help, use " << fg_yellow << "--help") .extra(Cell() << nl << "If " << fg_cyan << "OPTION" << reset << " is provided, the options list will be filtered to show only options that contain that string.")) (flag({ }, { "help" }, verbose).ignore_values(true)) (exit_code(0, "There were no errors.")) (exit_code(1, "An unknown error occurred.")) (exit_code(2, "There was a problem parsing the command line arguments.")) ; proc.process(argc, argv); if (!show_help && !show_version && !generator_) { show_help = true; show_version = true; status_ = 1; } if (show_version) { proc (prologue(BE_CORE_VERSION_STRING).query()) (prologue(BE_GFX_VERSION_STRING).query()) (license(BE_LICENSE).query()) (license(BE_COPYRIGHT).query()) ; } if (show_help) { proc.describe(std::cout, verbose, help_query); } else if (show_version) { proc.describe(std::cout, verbose, ids::cli_describe_section_prologue); proc.describe(std::cout, verbose, ids::cli_describe_section_license); } } catch (const cli::OptionError& e) { status_ = 2; be_error() << S(e.what()) & attr(ids::log_attr_index) << e.raw_position() & attr(ids::log_attr_argument) << S(e.argument()) & attr(ids::log_attr_option) << S(e.option()) | default_log(); } catch (const cli::ArgumentError& e) { status_ = 2; be_error() << S(e.what()) & attr(ids::log_attr_index) << e.raw_position() & attr(ids::log_attr_argument) << S(e.argument()) | default_log(); } catch (const FatalTrace& e) { status_ = 2; be_error() << "Fatal error while parsing command line!" & attr(ids::log_attr_message) << S(e.what()) & attr(ids::log_attr_trace) << StackTrace(e.trace()) | default_log(); } catch (const std::exception& e) { status_ = 2; be_error() << "Unexpected exception parsing command line!" & attr(ids::log_attr_message) << S(e.what()) | default_log(); } } /////////////////////////////////////////////////////////////////////////////// int TexDemo::operator()() { if (status_ != 0) { return status_; } try { run_(); } catch (const FatalTrace& e) { status_ = std::max(status_, (I8)1); be_error() << "Unexpected fatal error!" & attr(ids::log_attr_message) << S(e.what()) & attr(ids::log_attr_trace) << StackTrace(e.trace()) | default_log(); } catch (const fs::filesystem_error& e) { status_ = std::max(status_, (I8)1); be_error() << "Unexpected error!" & attr(ids::log_attr_message) << S(e.what()) & attr(ids::log_attr_category) << e.code().category().name() & attr(ids::log_attr_error_code) << e.code().value() & attr(ids::log_attr_error) << e.code().message() & attr(ids::log_attr_path) << e.path1().generic_string() & attr(ids::log_attr_path) << e.path2().generic_string() | default_log(); } catch (const std::system_error& e) { status_ = std::max(status_, (I8)1); be_error() << "Unexpected error!" & attr(ids::log_attr_message) << S(e.what()) & attr(ids::log_attr_category) << e.code().category().name() & attr(ids::log_attr_error_code) << e.code().value() & attr(ids::log_attr_error) << e.code().message() | default_log(); } catch (const std::exception& e) { status_ = std::max(status_, (I8)1); be_error() << "Unexpected exception!" & attr(ids::log_attr_message) << S(e.what()) | default_log(); } return status_; } namespace { /////////////////////////////////////////////////////////////////////////////// void GLAPIENTRY check_errors(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam) { be_warn() << "OpenGL Error" & attr("Source") << source & attr("Type") << type & attr("ID") << id & attr("Severity") << severity & attr("Message") << message & attr("Trace") << get_stack_trace() | default_log(); } } // ::() /////////////////////////////////////////////////////////////////////////////// void TexDemo::run_() { glfwWindowHint(GLFW_RESIZABLE, resizable_ ? 1 : 0); GLFWwindow* wnd = glfwCreateWindow((int)(dim_.x * scale_), (int)(dim_.y * scale_), "be::gfx::tex Demo", nullptr, nullptr); glfwMakeContextCurrent(wnd); glfwSwapInterval(1); glfwSetWindowUserPointer(wnd, this); gl::init_context(); if (GL_KHR_debug) { //#bgl checked(GL_KHR_debug) glEnable(GL_DEBUG_OUTPUT); glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); glDebugMessageCallback(check_errors, nullptr); //#bgl unchecked } tex_ = make_planar_texture(format_, dim_, 1); rnd_.seed(perf_now()); glClearColor(0.0, 0.0, 0.0, 0.0); glGenTextures(1, &tex_id_); glBindTexture(GL_TEXTURE_2D, tex_id_); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, linear_scaling_ ? GL_LINEAR : GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, linear_scaling_ ? GL_LINEAR : GL_NEAREST); glPixelStorei(GL_UNPACK_ALIGNMENT, 8); if (setup_) { setup_(); } if (generator_) { generator_(); } upload_(); glfwSetWindowSizeCallback(wnd, [](GLFWwindow* wnd, int w, int h) { TexDemo& demo = *static_cast<TexDemo*>(glfwGetWindowUserPointer(wnd)); ivec2 new_size((int)round(w / demo.scale_), (int)round(h / demo.scale_)); ivec2 new_wnd_size = ivec2(vec2(new_size) * demo.scale_); ivec2 old_wnd_size; glfwGetWindowSize(wnd, &old_wnd_size.x, &old_wnd_size.y); if (old_wnd_size != new_wnd_size) { glfwSetWindowSize(wnd, new_wnd_size.x, new_wnd_size.y); } glViewport(0, 0, new_wnd_size.x, new_wnd_size.y); if (new_size != demo.dim_ && new_size.x * new_size.y > 0) { demo.dim_ = new_size; demo.tex_ = make_planar_texture(demo.format_, demo.dim_, 1); if (demo.generator_) { demo.generator_(); } demo.upload_(); glfwPostEmptyEvent(); } }); glEnable(GL_TEXTURE_2D); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); while (!glfwWindowShouldClose(wnd)) { if (animate_) { glfwPollEvents(); } else { glfwWaitEvents(); } glClear(GL_COLOR_BUFFER_BIT); if (animate_ && generator_) { last_ = now_; now_ = ts_now(); time_ += tu_to_seconds(now_ - last_) / time_scale_; sin_time_ = (F32)sin(time_ * 2.0 * glm::pi<F64>()); generator_(); upload_(); } glBegin(GL_QUADS); glColor3fv(glm::value_ptr(glm::vec3(1.f))); glTexCoord2fv(glm::value_ptr(glm::vec2(0.0f, 0.f))); glVertex2f(-1.f, 1.f); glTexCoord2fv(glm::value_ptr(glm::vec2(1.0f, 0.f))); glVertex2f(1.f, 1.f); glTexCoord2fv(glm::value_ptr(glm::vec2(1.0f, 1.f))); glVertex2f(1.f, -1.f); glTexCoord2fv(glm::value_ptr(glm::vec2(0.0f, 1.f))); glVertex2f(-1.f, -1.f); glEnd(); glfwSwapBuffers(wnd); } glDeleteTextures(1, &tex_id_); glfwDestroyWindow(wnd); } /////////////////////////////////////////////////////////////////////////////// void TexDemo::upload_() { auto f = to_gl_format(tex_.view.format()); glPixelStorei(GL_UNPACK_ALIGNMENT, (GLint) tex_.storage->line_alignment()); be_verbose() << "Uploading image" & attr("Internal Format") << enum_name(f.internal_format) & attr("Data Format") << enum_name(f.data_format) & attr("Data Type") << enum_name(f.data_type) | default_log(); //glCompressedTexImage2D(GL_TEXTURE_2D, 0, f.internal_format, tex_.view.dim(0).x, tex_.view.dim(0).y, 0, (GLsizei)tex_.view.image().size(), tex_.view.image().data()); glTexImage2D(GL_TEXTURE_2D, 0, f.internal_format, tex_.view.dim(0).x, tex_.view.dim(0).y, 0, f.data_format, f.data_type, tex_.view.image().data()); }
bdd76a83abcffeda75f11560396bf63190c7984e
4118f8eba9c1073074087cdaffebb95e0c1166cb
/src/search.cpp
bc24622f9c0485524a9a1e25532f035c639121b5
[]
no_license
rajtyagi2718/tetris
08a402462dd06b070edc80e231b95df559a404e0
362c66473d9724662efecd98190159879cba9a6e
refs/heads/main
2023-07-14T17:24:50.175357
2021-08-31T16:51:28
2021-08-31T16:51:28
336,360,820
0
0
null
null
null
null
UTF-8
C++
false
false
4,623
cpp
search.cpp
#include "../include/search.h" #include "../include/board.h" #include "../include/graph.h" #include "../include/features.h" // values #include "../include/ids.h" // Action #include <boost/multiprecision/cpp_int.hpp> // uint256_t #include <vector> #include <queue> #include <utility> // pair #include <algorithm> // max #include <cassert> // assert #include <fstream> // ifstream #include <iostream> #include <sstream> #include <string> using boost::multiprecision::uint256_t; Search::Search() : board{}, graph{}, weights{}, cur_after_states{}, cur_terminal_states{}, nex_after_states{}, nex_terminal_states{}, pre_after_states{}, pre_terminal_states{}, best_value{}, best_terminal_state{} { std::ifstream file {"../src/weights.txt"}; if (file.is_open()) { std::string line; std::getline(file, line); std::istringstream iss {line}; double weight; while (iss >> weight) { weights.push_back(weight); } file.close(); } else { assert(false && "cannot open weights.txt file"); } } void Search::run(uint256_t board_state, std::pair<uint256_t, int> cur_piece, std::pair<uint256_t, int> nex_piece, std::vector<int>& actions) { reset(board_state, cur_piece, nex_piece); explore(); std::cout << "search value: " << best_value << std::endl; backtrack(actions); } void Search::reset(uint256_t board_state, std::pair<uint256_t, int> cur_piece, std::pair<uint256_t, int> nex_piece) { board.reset(board_state); board.remove(cur_piece.first); this->board_state = board.get_state(); this->cur_piece = cur_piece; if (cur_after_states.empty()) { cur_after_states.clear(); cur_terminal_states.clear(); bfs(cur_piece, cur_after_states, cur_terminal_states); } else { cur_after_states = std::move(pre_after_states); cur_terminal_states = std::move(pre_terminal_states); } this->nex_piece = nex_piece; nex_after_states.clear(); nex_terminal_states.clear(); best_value = -1e6; best_terminal_state = 0; } void Search::explore() { for (auto cur_terminal_state : cur_terminal_states) { board.reset(board_state); board.add(cur_terminal_state); int lines = board.clear_lines(); nex_after_states.clear(); nex_terminal_states.clear(); bfs(nex_piece, nex_after_states, nex_terminal_states); update_best(cur_terminal_state, lines); } } void Search::bfs(std::pair<uint256_t, int>& piece, std::map<uint256_t, int>& after_states, std::vector<uint256_t>& terminal_states) { auto [state, id] = piece; std::queue<uint256_t> states; states.push(state); while (!states.empty()) { uint256_t state = states.front(); states.pop(); // assert(board.is_valid(state)); uint256_t after_state; for (int action = 1; action < Action_END-1; ++action) { after_state = graph.get_after_state(state, id, action); if (board.is_valid(after_state) && !after_states.count(after_state)) { after_states[after_state] = action; states.push(after_state); } } after_state = graph.get_after_state(state, id, 0); if (board.is_valid(after_state)) { after_states[after_state] = 0; states.push(after_state); } else { terminal_states.push_back(state); } } } void Search::update_best(uint256_t& cur_terminal_state, int lines) { double value = -1e6; for (auto& nex_terminal_state : nex_terminal_states) { value = std::max(value, evaluate(board.get_after_state(nex_terminal_state), lines)); } if (value > best_value) { best_value = value; best_terminal_state = cur_terminal_state; pre_after_states = std::move(nex_after_states); pre_terminal_states = std::move(nex_terminal_states); } } void Search::backtrack(std::vector<int>& actions) { uint256_t state = best_terminal_state; auto& [start_state, id] = cur_piece; int action = down; actions.push_back(action); while (state != start_state) { action = cur_after_states[state]; state = graph.get_before_state(state, id, action); actions.push_back(action); } } double Search::evaluate(uint256_t board_state, int cur_line_clear) { std::vector<double> values = features::values(board_state, cur_line_clear); auto it = weights.cbegin(); auto jt = values.cbegin(); double ret = 0.0; while (it != weights.cend()) { ret += *it * *jt; it++; jt++; } return ret; }
9caf359ebe5d24647e1ea1cdfb256092622ff27c
10864f8b8367f7159a115b63ce5e0de815e98a3f
/Dragon/AnimationClipManager.h
7cc1563e3b6cff22591d925534096c777e5cae3e
[]
no_license
cctvbtx/gameEngine-DragonEngine
be42001ead707ec3a36cd18200b3df7075115607
d3197183998e4a81f223f6ee4d1fe1c9527da79e
refs/heads/master
2023-03-16T13:14:36.580307
2017-05-05T07:03:02
2017-05-05T07:03:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
482
h
AnimationClipManager.h
#pragma once #include <string> #include <vector> using std::string; using std::vector; struct AnimationClip { string m_clipName; float m_startKey; float m_endKey; }; class AnimationClipManager { public: void AddClip(AnimationClip *clip) { m_clips.push_back(clip); }; void ExportXML(string path); void ImportXML(string path); AnimationClip* GetAnimationClip(string clipName); int GetClipCount(void) { return m_clips.size(); } private: vector<AnimationClip*> m_clips; };
fb4547eeda015757d3c5da5a1cb3bbb94c20692a
ee92057a8ebc91ba90d8055a9bece25d24211499
/kattis/lektira/lektira.cpp
4cc07eb8168850ffa2afd8d7a33567ee82774a50
[]
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
963
cpp
lektira.cpp
#include <string> #include <algorithm> #include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string input; cin >> input; string smallest = input; for (int i = 1; i < input.size(); i++) { for (int j = i+1; j < input.size(); j++) { string a = input.substr(0, i); string b = input.substr(i, j-i); string c = input.substr(j); // cout << a << " " << b << " " << c << endl; reverse(a.begin(), a.end()); reverse(b.begin(), b.end()); reverse(c.begin(), c.end()); string newStr = a + b + c; // cout << "new string: " << newStr << endl; if (lexicographical_compare(newStr.begin(), newStr.end(), smallest.begin(), smallest.end())) { smallest = newStr; } } } cout << smallest << endl; }
ae650151a87a725a31388e243621f9eacf889fcd
376b2937e47a362db7b64fa30eafd71aacbf3a3c
/test_contest/P320A.cpp
aa11783c463ecb2bad206fede4e15716c3163ca7
[]
no_license
arceus6666/competitive-programming-upb-2021
b1577fd1df93bb3d82705fbce70d0b513aab2436
48e35bdf0ad9d068f2c38c15ce605e7edccba495
refs/heads/main
2023-06-30T06:10:56.803915
2021-08-02T19:29:55
2021-08-02T19:29:55
391,476,410
0
0
null
null
null
null
UTF-8
C++
false
false
459
cpp
P320A.cpp
#include <iostream> #include <bits/stdc++.h> using namespace std; int main() { int n, c = 0; cin >> n; while (n > 0) { int d = n % 10; if (d == 4) { if (c <= 1) { c++; } else { cout << "NO"; exit(0); } } else if (d == 1) { c = 0; } else { cout << "NO"; exit(0); } n /= 10; } cout << (c == 0 ? "YES" : "NO"); return 0; }
06052b10d4dabd215f7cf9960d09c43579b8de10
347c92873d53b6261cc6b1e2bc070ebded62c702
/WINDOW_XP/pir/pir-sensor-ws2812-neo-xmas/pir-sensor-ws2812-neo-xmas.ino
2e680d7a8c88358e868b434928193824eca4b372
[]
no_license
ironheartbj18/vanVlymenArduino
0383159732e3aa2120a5b985d37cbcdc6606592c
d3e9158ccc88891ab215eff9b03c91628cc7ad39
refs/heads/master
2020-06-12T14:00:37.392006
2017-07-10T21:51:05
2017-07-10T21:51:05
75,807,238
0
0
null
null
null
null
UTF-8
C++
false
false
6,435
ino
pir-sensor-ws2812-neo-xmas.ino
#include <Adafruit_NeoPixel.h> #ifdef __AVR__ #include <avr/power.h> #endif #define PIN 2 // Parameter 1 = number of pixels in strip // Parameter 2 = Arduino pin number (most are valid) // Parameter 3 = pixel type flags, add together as needed: Adafruit_NeoPixel strip = Adafruit_NeoPixel(150, PIN, NEO_GRB + NEO_KHZ800); /* * How to use a PIR sensor with the Arduino http://www.electronicslovers.com/2015/08/how-to-use-pir-sensor-with-arduino.html * The sensor's output pin goes to HIGH if motion is present. * However, even if motion is present it goes to LOW from time to time, * which might give the impression no motion is present. * This program deals with this issue by ignoring LOW-phases shorter than a given time, * assuming continuous motion is present during these phases. */ //the time we give the sensor to calibrate (10-60 secs according to the datasheet) int calibrationTime = 10; //the time when the sensor outputs a low impulse long unsigned int lowIn; //the amount of milliseconds the sensor has to be low //before we assume all motion has stopped long unsigned int pause = 5000; boolean lockLow = true; boolean takeLowTime; int pirPin = 7; //the digital pin connected to the PIR sensor's output int ledPin = 8; void setup(){ Serial.begin(9600); strip.begin(); strip.show(); pinMode(pirPin, INPUT); pinMode(ledPin, OUTPUT); digitalWrite(pirPin, LOW); //give the sensor some time to calibrate Serial.print("calibrating sensor please wait for 10 secs "); for(int i = 0; i < calibrationTime; i++){ Serial.print("."); delay(1000); } Serial.println(" done"); Serial.println("SENSOR ACTIVE"); delay(50); } //////////////////////////// //LOOP void loop(){ if(digitalRead(pirPin) == HIGH){ digitalWrite(ledPin, HIGH); //the led visualizes the sensors output pin state colorWipe(strip.Color(255, 0, 0), 50); // Red colorWipe(strip.Color(0, 255, 0), 50); // Green colorWipe(strip.Color(255, 0, 0), 20); // Red colorWipe(strip.Color(0, 255, 0), 20); // Green colorWipe(strip.Color(255, 0, 0), 50); // Red colorWipe(strip.Color(0, 255, 0), 50); // Green colorWipe(strip.Color(255, 0, 0), 20); // Red colorWipe(strip.Color(0, 255, 0), 20); // Green // Send a theater pixel chase in... theaterChase(strip.Color(127, 127, 127), 50); // White theaterChase(strip.Color(127, 0, 0), 50); // Red theaterChase(strip.Color(0, 127, 0), 50); // Green theaterChase(strip.Color(127, 127, 127), 50); // White theaterChase(strip.Color(127, 0, 0), 50); // Red theaterChase(strip.Color(0, 127, 0), 50); // Green // theaterChase(strip.Color(0, 0, 127), 50); // Blue rainbow(20); rainbowCycle(20); theaterChaseRainbow(50); // delay(100); if(lockLow){ //makes sure we wait for a transition to LOW before any further output is made: lockLow = false; Serial.println("---"); Serial.print("motion detected at "); Serial.print(millis()/1000); Serial.println(" sec"); delay(50); } takeLowTime = true; } if(digitalRead(pirPin) == LOW){ digitalWrite(ledPin, LOW); //the led visualizes the sensors output pin state if(takeLowTime){ colorWipe(strip.Color(0, 0, 0), 20); // OFF lowIn = millis(); //save the time of the transition from high to LOW takeLowTime = false; //make sure this is only done at the start of a LOW phase } //if the sensor is low for more than the given pause, //we assume that no more motion is going to happen if(!lockLow && millis() - lowIn > pause){ //makes sure this block of code is only executed again after //a new motion sequence has been detected lockLow = true; Serial.print("motion ended at "); //output Serial.print((millis() - pause)/1000); Serial.println(" secs "); delay(50); } } } // Fill the dots one after the other with a color void colorWipe(uint32_t c, uint8_t wait) { for(uint16_t i=0; i<strip.numPixels(); i++) { strip.setPixelColor(i, c); strip.show(); delay(wait); } } void rainbow(uint8_t wait) { uint16_t i, j; for(j=0; j<256; j++) { for(i=0; i<strip.numPixels(); i++) { strip.setPixelColor(i, Wheel((i+j) & 255)); } strip.show(); delay(wait); } } // Slightly different, this makes the rainbow equally distributed throughout void rainbowCycle(uint8_t wait) { uint16_t i, j; for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel for(i=0; i< strip.numPixels(); i++) { strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255)); } strip.show(); delay(wait); } } //Theatre-style crawling lights. void theaterChase(uint32_t c, uint8_t wait) { for (int j=0; j<10; j++) { //do 10 cycles of chasing for (int q=0; q < 3; q++) { for (int i=0; i < strip.numPixels(); i=i+3) { strip.setPixelColor(i+q, c); //turn every third pixel on } strip.show(); delay(wait); for (int i=0; i < strip.numPixels(); i=i+3) { strip.setPixelColor(i+q, 0); //turn every third pixel off } } } } //Theatre-style crawling lights with rainbow effect void theaterChaseRainbow(uint8_t wait) { for (int j=0; j < 256; j++) { // cycle all 256 colors in the wheel for (int q=0; q < 3; q++) { for (int i=0; i < strip.numPixels(); i=i+3) { strip.setPixelColor(i+q, Wheel( (i+j) % 255)); //turn every third pixel on } strip.show(); delay(wait); for (int i=0; i < strip.numPixels(); i=i+3) { strip.setPixelColor(i+q, 0); //turn every third pixel off } } } } // Input a value 0 to 255 to get a color value. // The colours are a transition r - g - b - back to r. uint32_t Wheel(byte WheelPos) { WheelPos = 255 - WheelPos; if(WheelPos < 85) { return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3); } if(WheelPos < 170) { WheelPos -= 85; return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3); } WheelPos -= 170; return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0); }
dc8fb475869d1fd1192d0e85ea0a523d1addce9a
71a3c40523c8e774213605d4a55fb91b86c63afb
/Paladin/TemplateManager.h
3ebba0a8d9f08ebecfe23e3c42d9c9fc155f16a8
[ "MIT" ]
permissive
HaikuArchives/Paladin
caf6f40a812a918f0512cdbfd4e39730417fd344
402d53a4258d5b44269fbdfe4935700b249a8649
refs/heads/develop
2023-04-29T07:50:43.809813
2023-04-15T20:18:09
2023-04-15T20:18:09
14,755,074
11
10
MIT
2023-05-22T19:41:31
2013-11-27T18:13:02
C++
UTF-8
C++
false
false
1,095
h
TemplateManager.h
#ifndef TEMPLATE_MANAGER_H #define TEMPLATE_MANAGER_H #include "ObjectList.h" #include <Entry.h> #include <String.h> class ProjectTemplate { public: ProjectTemplate(entry_ref ref); status_t InitCheck(void) const; int32 CountFiles(void) const; entry_ref * FileAt(int32 index); const char *ProjectFileName(void) const; int32 TargetType(void) const; entry_ref GetRef(void) const; void PrintToStream(void); int32 CountLibs(void) const; entry_ref * LibAt(int32 index); private: void Load(entry_ref ref); entry_ref RefForLib(const BString &path); status_t fStatus; BObjectList<entry_ref> fRefList; BString fProjFileName; int32 fTargetType; BObjectList<entry_ref> fLibList; entry_ref fRef; }; class TemplateManager { public: TemplateManager(void); void ScanFolder(const char *path); ProjectTemplate * TemplateAt(int32 index); void AddTemplate(entry_ref ref); void RemoveTemplateAt(int32 index); int32 CountTemplates(void) const; private: BObjectList<ProjectTemplate> fList; }; #endif
9dd9c447ef38984f8730a3bdca53281e64f2eef2
979e8cbdae0a72350906960896f2dfc421c0e80f
/src/pcd_saver.cpp
655d9a0cec3374393d3758eeae74c57f6d80aca1
[]
no_license
zorosmith/my_pcl_tutorial
88e494b903e3f650e072e909f6931e19f309e555
e6281a3cac9cac680698bd532ee6aac9850a558a
refs/heads/master
2020-06-18T04:06:05.241781
2017-03-17T07:46:27
2017-03-17T07:46:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
23,520
cpp
pcd_saver.cpp
#include <iostream> #include <cstdlib> #include <chrono> #include <boost/make_shared.hpp> #include <ros/ros.h> #include <ros/package.h> #include <sensor_msgs/PointCloud2.h> #include <pcl/point_cloud.h> #include <pcl/point_types.h> #include <pcl_conversions/pcl_conversions.h> #include <pcl/common/transforms.h> #include <pcl/io/io.h> #include <pcl/io/pcd_io.h> #include <pcl/io/ply_io.h> #include <pcl/io/obj_io.h> #include <pcl/visualization/cloud_viewer.h> #include <pcl/kdtree/kdtree_flann.h> #include <pcl/features/normal_3d.h> #include <pcl/surface/gp3.h> #include <pcl/registration/icp.h> #include <pcl/registration/icp_nl.h> #include <pcl/registration/gicp.h> #include <pcl/registration/transforms.h> #include <pcl/point_representation.h> #include <pcl/registration/lum.h> #include <opencv2/opencv.hpp> #include "4pcs.h" #include "io/io.h" using std::cout; using std::endl; using std::stringstream; using std::string; using namespace pcl; using namespace match_4pcs; unsigned int filesNum = 0; bool saveCloud(false); bool combineCloud(false); bool loadCloud(false); bool saveAll(false); boost::shared_ptr<visualization::CloudViewer> viewer; pcl::PointCloud<pcl::PointXYZRGBA> g_cloud; pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudw(new pcl::PointCloud<pcl::PointXYZRGB>); //pcl::PointCloud<pcl::PointXYZRGB> cloudw; pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr cloudwn(new pcl::PointCloud<pcl::PointXYZRGBNormal>); #define _LOAD_POSE_ int LoadPoseArray(const char *filename, double** (&Rot), double** (&Tran)) { int num = 0; //FILE *file = fopen("data\\pose_data.txt", "r"); FILE *file = fopen(filename, "r"); fscanf(file, "%d\n", &num); if (num > 0) { Rot = new double*[num]; Tran = new double*[num]; for (int i = 0; i < num; ++i) { Rot[i] = new double[9]; Tran[i] = new double[3]; #ifdef _LOAD_POSE_ fscanf(file, "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf \n", &Rot[i][0], &Rot[i][1], &Rot[i][2], &Rot[i][3], &Rot[i][4], &Rot[i][5], &Rot[i][6], &Rot[i][7], &Rot[i][8], &Tran[i][0], &Tran[i][1], &Tran[i][2]); Tran[i][0] /= 1000.0; Tran[i][1] /= 1000.0; Tran[i][2] /= 1000.0; #else double Rx = 0, Ry = 10 * (i + 1), Rz = 0; Rx = Rx * M_PI / 180.0; Ry = Ry * M_PI / 180.0; Rz = Rz * M_PI / 180.0; double cx = cos(Rx), sx = sin(Rx), cy = cos(Ry), sy = sin(Ry), cz = cos(Rz), sz = sin(Rz); Rot[i][0] = cx * cy; Rot[i][1] = cx * sy * sz - sx * cz; Rot[i][2] = sx * sz + cx * sy * cz; Rot[i][3] = sx * cy; Rot[i][4] = sx * sy * sz + cx * cz; Rot[i][5] = sx * sy * cz - cx * sz; Rot[i][6] = -sy; Rot[i][7] = cy * sz; Rot[i][8] = cy * cz; #endif } fclose(file); return num; } fclose(file); return 0; } void CleanInvalidNormals( vector<Point3D> &v, vector<cv::Point3f> &normals){ if (v.size() == normals.size()){ vector<Point3D>::iterator itV = v.begin(); vector<cv::Point3f>::iterator itN = normals.begin(); float norm; unsigned int nb = 0; for( ; itV != v.end(); ){ norm = cv::norm((*itV).normal()); if (norm < 0.1){ itN = normals.erase(itN); itV = v.erase(itV); nb++; }else{ if (norm != 1.){ (*itN).x /= norm; (*itN).y /= norm; (*itN).z /= norm; } itV++; itN++; } } if (nb != 0){ cout << "Removed " << nb << " invalid points/normals" << endl; } } } bool is_nan(double dVal) { return !(dVal == dVal); } #if 0 int isNumber(double d) { return (d==d); } #else int isNumber(double d) { return (d==d)&&(d<=DBL_MAX&&d>=-DBL_MAX); } #endif int isFiniteNumber(double d) { return (d<=DBL_MAX&&d>=-DBL_MAX); } int data_num = 0; int data_size = 0; double **Rot, **Tran; int LoadPCDandCombineCloud() { std::string path = ros::package::getPath("my_pcl_tutorial"); std::string data_path = path + "/data/"; //std::string planeinfo_path = data_path + "cloud"; //std::string camera_mat_path = data_path + "pose_0000000"; char cloud_data[256]; char obj_data[256]; char pose_data[256]; sprintf(&cloud_data[0], "%scloud%d.pcd", data_path.c_str(), data_num); sprintf(&obj_data[0], "%scloud%d.obj", data_path.c_str(), data_num); //sprintf(&pose_data[0], "%spose_%08d.txt", data_path.c_str(), data_num); sprintf(&pose_data[0], "%spose_data.txt", data_path.c_str()); if (data_num == 0) data_size = LoadPoseArray(pose_data, Rot, Tran); //pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGBA); pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudl (new pcl::PointCloud<pcl::PointXYZRGB>); pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudt (new pcl::PointCloud<pcl::PointXYZRGB>); pcl::registration::LUM<pcl::PointXYZRGB> lum; if (data_size > 0) { if(pcl::io::loadPCDFile<pcl::PointXYZRGB> (cloud_data, *cloudl) == -1) { PCL_ERROR("Couldn't read file %s", cloud_data); return -1; } for (pcl::PointCloud<pcl::PointXYZRGB>::iterator it = cloudl->end(); it != cloudl->begin(); --it) { #if 1 //new nan and inf number check if (!(isNumber(it->x)) || !(isNumber(it->y)) || !(isNumber(it->z))) cloudl->erase(it); #else if (is_nan(it->x) || is_nan(it->y) || is_nan(it->z)) cloudl->erase(it); #endif //new nan and inf number check } cloudl->erase(cloudl->begin()); Eigen::Matrix4f transform_1;// = Eigen::Matrix4f::Identity(); Eigen::Matrix4f transform_tmp = Eigen::Matrix4f::Identity();; #if 1 // global registration #if 1 // camera extrinsic parameters to transform //pcl::copyPointCloud(*cloudl, *cloudt); //4pcs std::chrono::_V2::steady_clock::time_point t3 = std::chrono::_V2::steady_clock::now(); transform_1 << Rot[data_num][0], Rot[data_num][1], Rot[data_num][2], Tran[data_num][0], Rot[data_num][3], Rot[data_num][4], Rot[data_num][5], Tran[data_num][1], Rot[data_num][6], Rot[data_num][7], Rot[data_num][8], Tran[data_num][2], 0, 0, 0, 1; std::cout << transform_1 << std::endl; #if 1 pcl::transformPointCloud(*cloudl, *cloudt, transform_1); #else pcl::transformPointCloud(*cloudl, *cloudl, transform_1); #endif std::chrono::_V2::steady_clock::time_point t4 = std::chrono::_V2::steady_clock::now(); printf("our time: %lld\n", std::chrono::duration_cast<std::chrono::nanoseconds>(t4 - t3).count()); #endif // camera extrinsic parameters to transform #if 0 // LUM algorithm pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudtmp (new pcl::PointCloud<pcl::PointXYZRGB>(cloudl[i])); lum.addPointCould(cloudtmp); std::cout << transform_1 << std::endl; pcl::transformPointCloud(*cloudl, *cloudt, transform_1); #endif // LUM algorithm #else pcl::copyPointCloud(*cloudl, *cloudt); #endif // global registration // Create the normal estimation class, and pass the input dataset to it pcl::NormalEstimation<pcl::PointXYZRGB, pcl::PointXYZRGBNormal> ne; ne.setInputCloud (cloudt); // Create an empty kdtree representation, and pass it to the normal estimation object. // Its content will be filled inside the object, based on the given input dataset (as no other search surface is given). pcl::search::KdTree<pcl::PointXYZRGB>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZRGB> ()); //pcl::KdTreeFLANN<pcl::PointXYZRGB>::Ptr tree (new pcl::KdTreeFLANN<pcl::PointXYZRGB> ()); ne.setSearchMethod (tree); // Output datasets pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr cloud_normals (new pcl::PointCloud<pcl::PointXYZRGBNormal>); // Use all neighbors in a sphere of radius 3cm ne.setRadiusSearch (0.03); // Compute the features ne.compute (*cloud_normals); pcl::copyPointCloud(*cloudt, *cloud_normals); // cloud_normals->points.size () should have the same size as the input cloud->points.size ()* char cloud_data[256]; #if 0 //save single frame pcd (removal nan) sprintf(&cloud_data[0], "%strans_cloud%d.pcd", data_path.c_str(), data_num); //pcl::io::savePCDFile(cloud_data, *cloud_normals); pcl::io::savePCDFile(cloud_data, *cloudt); #endif //save single frame pcd (removal nan) #if 1 // save single frame obj pcl::PolygonMesh mesh; //pcl::toPCLPointCloud2(*cloud_normals, mesh.cloud); pcl::toPCLPointCloud2(*cloud_normals, mesh.cloud); sprintf(&cloud_data[0], "%scloud%d.obj", data_path.c_str(), data_num); pcl::io::saveOBJFile(cloud_data, mesh); #endif // save single frame obj pcl::registration::LUM<pcl::PointXYZRGB> lum; vector<Point3D> set1, set2; vector<cv::Point2f> tex_coords1, tex_coords2; vector<cv::Point3f> normals1, normals2; vector<tripple> tris1, tris2; vector<std::string> mtls1, mtls2; //pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr cloudgicp(new pcl::PointCloud<pcl::PointXYZRGBNormal>); if (data_num > 0) { //std::string input1 = data_path char input1[256]; char input2[256]; #if 1 //registration method /* pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_temp (new pcl::PointCloud<pcl::PointXYZRGB>); pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_in (new pcl::PointCloud<pcl::PointXYZRGB>); pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_out (new pcl::PointCloud<pcl::PointXYZRGB>); sprintf(&input1[0], "%strans_cloud%d.pcd", data_path.c_str(), data_num-1); sprintf(&input2[0], "%strans_cloud%d.pcd", data_path.c_str(), data_num); if(pcl::io::loadPCDFile<pcl::PointXYZRGB> (input1, *cloud_temp) == -1) { PCL_ERROR("Couldn't read file %s", cloud_data); return -1; } pcl::copyPointCloud(*cloud_temp, *cloud_in); if(pcl::io::loadPCDFile<pcl::PointXYZRGB> (input2, *cloud_temp) == -1) { PCL_ERROR("Couldn't read file %s", cloud_data); return -1; } pcl::copyPointCloud(*cloud_temp, *cloud_out);*/ /* for (unsigned int i = 0; i < cloudt->size(); i++) { if(!isFiniteNumber((*cloudt)[i].x) || !isFiniteNumber((*cloudt)[i].y) || !isFiniteNumber((*cloudt)[i].z)) { cloudt->erase(cloudt->begin() + i); i--; } }*/ #if 0 //erase points #if 1 //direct erase cloud_in->erase(cloud_in->begin()); cloud_out->erase(cloud_out->begin()); #else unsigned int nCount1 = 0, nCount2 = 0; for (unsigned int i = 0; i < cloud_in->size(); i++) { if(!isFiniteNumber((*cloud_in)[i].x) || !isFiniteNumber((*cloud_in)[i].y) || !isFiniteNumber((*cloud_in)[i].z)) { cout << i << "not nuber 1: " << (*cloud_in)[i].x << ", " << (*cloud_in)[i].y << ", " << (*cloud_in)[i].z << endl; nCount1++; cloud_in->erase(cloud_in->begin() + i); } } for (unsigned int i = 0; i < cloud_out->size(); i++) { if(!isFiniteNumber((*cloud_out)[i].x) || !isFiniteNumber((*cloud_out)[i].y) || !isFiniteNumber((*cloud_out)[i].z)) { cout << i << "not nuber 2: " << (*cloud_out)[i].x << ", " << (*cloud_out)[i].y << ", " << (*cloud_out)[i].z << endl; nCount2++; cloud_out->erase(cloud_out->begin() + i); } } cout << "not number size: " << nCount1 << ", " << nCount2 << endl; #endif #endif //erase points //cout << "pre frame size: " << cloud_in->size() << endl; //cout << "cur frame size: " << cloud_out->size() << endl; #if 1 // global algorithm #if 0 // LUM algorithm corrs = pcl::someAlgo(lum.getPointCloud(data_num-1), lum.getPointCloud(data_num)); lum.setCorrespondences (data_num-1, data_num, corrs); #endif // LUM algorithm #if 0 // 4PCS algorithm float score = 0; #if 1 // with ICP sprintf(&input1[0], "%sicp_trans_cloud%d.obj", data_path.c_str(), data_num-1); #else sprintf(&input1[0], "%strans_cloud%d.obj", data_path.c_str(), data_num-1); #endif // with ICP sprintf(&input2[0], "%scloud%d.obj", data_path.c_str(), data_num); IOManager iomananger; iomananger.ReadObject(&input1[0], set1, tex_coords1, normals1, tris1, mtls1); iomananger.ReadObject(&input2[0], set2, tex_coords2, normals2, tris2, mtls2); printf("num 1: %lu %lu %lu %lu %lu\n", set1.size(), tex_coords1.size(), normals1.size(), tris1.size(), mtls1.size()); printf("num 2: %lu %lu %lu %lu %lu\n", set2.size(), tex_coords2.size(), normals2.size(), tris2.size(), mtls2.size()); cv::Mat mat = cv::Mat::eye(4, 4, CV_64F); if (tris1.size() == 0) CleanInvalidNormals(set1, normals1); if (tris2.size() == 0) CleanInvalidNormals(set2, normals2); std::chrono::_V2::steady_clock::time_point t1 = std::chrono::_V2::steady_clock::now(); Match4PCSOptions options; #if 0 // 4PCS parameters setting options.overlap_estimation = 0.45; options.sample_size = 2000; options.max_normal_difference = 90.0; options.max_color_distance = 150; options.max_time_seconds = 1000; options.delta = 0.01; #else options.overlap_estimation = 0.45; options.sample_size = 2000; options.max_normal_difference = 90.0; options.max_color_distance = 150; options.max_time_seconds = 1000; options.delta = 0.01; #endif // 4PCS parameters setting #if 1 //seletion Super4PCS or 4PCS MatchSuper4PCS matcher(options); //score = matcher.ComputeTransformation(set1, &set2, &mat); score = matcher.ComputeTransformation(set1, &set2, &mat); #else Match4PCS matcher(options); score = matcher.ComputeTransformation(set1, &set2, &mat); #endif //seletion Super4PCS or 4PCS Eigen::Matrix4f transform_2;// = Eigen::Matrix4f::Identity(); transform_2 << mat.at<double>(0, 0), mat.at<double>(0, 1), mat.at<double>(0, 2), mat.at<double>(0, 3), mat.at<double>(1, 0), mat.at<double>(1, 1), mat.at<double>(1, 2), mat.at<double>(1, 3), mat.at<double>(2, 0), mat.at<double>(2, 1), mat.at<double>(2, 2), mat.at<double>(2, 3), 0, 0, 0, 1; pcl::transformPointCloud(*cloud_normals, *cloud_normals, transform_2); std::chrono::_V2::steady_clock::time_point t2 = std::chrono::_V2::steady_clock::now(); printf("4PCS time: %lld\n", std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1).count()); pcl::transformPointCloud(*cloudt, *cloudt, transform_2); cout << "score: " << score << endl; cout << "super4pcs: " << endl << mat << endl; #if 1 // save single frame obj pcl::PolygonMesh meshw; pcl::toPCLPointCloud2(*cloud_normals, meshw.cloud); sprintf(&cloud_data[0], "%strans_cloud%d.obj", data_path.c_str(), data_num); pcl::io::saveOBJFile(cloud_data, meshw); #endif // save single frame obj #endif // 4PCS algorithm #endif // global algorithm #if 1 // ICP std::cout << "ICP begin " << data_num << endl; std::chrono::_V2::steady_clock::time_point t5 = std::chrono::_V2::steady_clock::now(); pcl::IterativeClosestPoint<PointXYZRGB, PointXYZRGB> icp; /*icpn.setMaxCorrespondenceDistance(0.01); icpn.setTransformationEpsilon(1e-8); icpn.setEuclideanFitnessEpsilon(0.01); icpn.setMaximumIterations (100); icpn.setRANSACOutlierRejectionThreshold(1.5);*/ icp.setMaxCorrespondenceDistance(0.03); icp.setTransformationEpsilon(1e-10); icp.setEuclideanFitnessEpsilon(0.001); icp.setMaximumIterations (500); icp.setRANSACOutlierRejectionThreshold(1.5); // set the input point cloud to align icp.setInputCloud(cloudt); // set the input reference point cloud icp.setInputTarget(cloudw); // compte the point cloud registration pcl::PointCloud<pcl::PointXYZRGB> Final; icp.align(Final); std::chrono::_V2::steady_clock::time_point t6 = std::chrono::_V2::steady_clock::now(); printf("ICP time: %lld\n", std::chrono::duration_cast<std::chrono::milliseconds>(t6 - t5).count()); // print if it the algorithm converged and its fitness score std::cout << "has converged:" << icp.hasConverged() << " score: " << icp.getFitnessScore() << std::endl; // print the output transformation std::cout << icp.getFinalTransformation() << std::endl; //*cloud_normals = Final; *cloudt = Final; std::chrono::_V2::steady_clock::time_point t7 = std::chrono::_V2::steady_clock::now(); #if 0 transform_tmp = icp.getFinalTransformation() * transform_tmp; pcl::transformPointCloud(*cloud_normals, *cloud_normals, transform_tmp); #else pcl::transformPointCloud(*cloud_normals, *cloud_normals, icp.getFinalTransformation()); #endif std::chrono::_V2::steady_clock::time_point t8 = std::chrono::_V2::steady_clock::now(); printf("ICP transformation time: %lld\n", std::chrono::duration_cast<std::chrono::nanoseconds>(t8 - t7).count()); //pcl::transformPointCloud(*cloudt, *cloudt, icp.getFinalTransformation()); #if 0 //save single frame pcd (removal nan) char cloud_data_re[256]; sprintf(&cloud_data_re[0], "%strans_cloud%d_re.pcd", data_path.c_str(), data_num); pcl::io::savePCDFile(cloud_data_re, Final); #endif //save single frame pcd (removal nan) #if 1 // save single frame obj pcl::PolygonMesh meshicp; pcl::toPCLPointCloud2(*cloud_normals, meshicp.cloud); sprintf(&cloud_data[0], "%sicp_trans_cloud%d.obj", data_path.c_str(), data_num); pcl::io::saveOBJFile(cloud_data, meshicp); #endif // save single frame obj std::cout << "ICP end " << data_num << endl; #endif // ICP #if 0 // GICP method std::cout << "GICP begin " << data_num << endl; // create the object implementing ICP algorithm pcl::GeneralizedIterativeClosestPoint<pcl::PointXYZRGBNormal, pcl::PointXYZRGBNormal> gicp; /* gicp.setMaxCorrespondenceDistance(0.05);cpptools gicp.setTransformationEpsilon(1e-8); gicp.setEuclideanFitnessEpsilon(1); gicp.setMaximumIterations (50); //gicp.setRANSACOutlierRejectionThreshold(1.5); */ gicp.setMaxCorrespondenceDistance(0.01); gicp.setTransformationEpsilon(1e-10); gicp.setEuclideanFitnessEpsilon(0.0001); gicp.setMaximumIterations (500); gicp.setRANSACOutlierRejectionThreshold(1.5); // set the input point cloud to align gicp.setInputCloud(cloud_normals); // set the input reference point cloud gicp.setInputTarget(cloudwn); // compte the point cloud registration pcl::PointCloud<pcl::PointXYZRGBNormal> Final; gicp.align(Final); // print if it the algorithm converged and its fitness score std::cout << "has converged:" << gicp.hasConverged() << " score: " << gicp.getFitnessScore() << std::endl; // print the output transformation std::cout << gicp.getFinalTransformation() << std::endl; //*cloud_normals = Final; //*cloudt = Final; pcl::transformPointCloud(*cloudt, *cloudt, gicp.getFinalTransformation()); #if 1 //save single frame pcd (removal nan) char cloud_data_re[256]; sprintf(&cloud_data_re[0], "%strans_cloud%d_re.pcd", data_path.c_str(), data_num); pcl::io::savePCDFile(cloud_data_re, Final); #endif //save single frame pcd (removal nan) std::cout << "GICP end " << data_num << endl; #endif // GICP method #if 0 // ICPNL method std::cout << "ICPNL begin " << data_num << endl; pcl::IterativeClosestPointNonLinear<PointXYZRGB, PointXYZRGB> icpn; /*icpn.setMaxCorrespondenceDistance(0.01); icpn.setTransformationEpsilon(1e-8); icpn.setEuclideanFitnessEpsilon(0.01); icpn.setMaximumIterations (100); icpn.setRANSACOutlierRejectionThreshold(1.5);*/ icpn.setMaxCorrespondenceDistance(0.03); icpn.setTransformationEpsilon(1e-10); icpn.setEuclideanFitnessEpsilon(0.001); icpn.setMaximumIterations (500); icpn.setRANSACOutlierRejectionThreshold(1.5); // set the input point cloud to align icpn.setInputCloud(cloudt); // set the input reference point cloud icpn.setInputTarget(cloudw); // compte the point cloud registration pcl::PointCloud<pcl::PointXYZRGB> Final; icpn.align(Final); // print if it the algorithm converged and its fitness score std::cout << "has converged:" << icpn.hasConverged() << " score: " << icpn.getFitnessScore() << std::endl; // print the output transformation std::cout << icpn.getFinalTransformation() << std::endl; //*cloud_normals = Final; *cloudt = Final; //pcl::transformPointCloud(*cloudt, *cloudt, gicp.getFinalTransformation()); #if 1 //save single frame pcd (removal nan) char cloud_data_re[256]; sprintf(&cloud_data_re[0], "%strans_cloud%d_re.pcd", data_path.c_str(), data_num); pcl::io::savePCDFile(cloud_data_re, Final); #endif //save single frame pcd (removal nan) std::cout << "ICPNL end " << data_num << endl; #endif // ICPNL method #endif //registration method } else { #if 1 // save single frame obj pcl::PolygonMesh meshw; pcl::toPCLPointCloud2(*cloud_normals, meshw.cloud); sprintf(&cloud_data[0], "%sicp_trans_cloud%d.obj", data_path.c_str(), data_num); pcl::io::saveOBJFile(cloud_data, meshw); #endif // save single frame obj } *cloudwn += *cloud_normals; *cloudw += *cloudt; #if 0 // save single frame obj pcl::PolygonMesh meshw; pcl::toPCLPointCloud2(*cloudwn, meshw.cloud); sprintf(&cloud_data[0], "%scloud0.obj", data_path.c_str()); pcl::io::saveOBJFile(cloud_data, meshw); #endif // save single frame obj data_num++; } else { data_num = -1; } return data_num; } //void cloudCB(const sensor_msgs::PointCloud2& input) void cloudCB(const sensor_msgs::ImageConstPtr& msg) { pcl::PointCloud<pcl::PointXYZRGBA> cloud; // With color //pcl::fromROSMsg(input, cloud); // sensor_msgs::PointCloud2 ----> pcl::PointCloud<T> //if(! viewer->wasStopped()) viewer->showCloud(g_cloud.makeShared()); if(! viewer->wasStopped() && !loadCloud) viewer->showCloud(cloudw->makeShared()); if(saveCloud) { stringstream stream; stream << "inputCloud"<< filesNum<< ".pcd"; string filename = stream.str(); if(io::savePCDFile(filename, cloud, true) == 0) { //registration method filesNum++; cout << filename<<" Saved."<<endl; } else PCL_ERROR("Problem saving %s.\n", filename.c_str()); saveCloud = false; } if(loadCloud) { LoadPCDandCombineCloud(); if (data_num >= 10) loadCloud = false; } if(saveAll) { ROS_INFO("Save Obj file."); char obj_data[256] = "/home/kuku/catkin_ws/src/my_pcl_tutorial/data/finalcloud.obj"; pcl::PolygonMesh mesh; pcl::toPCLPointCloud2(*cloudw, mesh.cloud); pcl::io::saveOBJFile(obj_data, mesh); char pcd_data[256] = "/home/kuku/catkin_ws/src/my_pcl_tutorial/data/finalcloud.pcd"; pcl::io::savePCDFile(pcd_data, *cloudw); saveAll = false; ROS_INFO("end Obj file."); } } void keyboardEventOccured(const visualization::KeyboardEvent& event, void* nothing) { if(event.getKeySym() == "space"&& event.keyDown()) saveCloud = true; if((event.getKeySym() == "s" || event.getKeySym() == "S") && event.keyDown()) combineCloud = true; if((event.getKeySym() == "l" || event.getKeySym() == "L") && event.keyDown()) loadCloud = true; if((event.getKeySym() == "a" || event.getKeySym() == "A") && event.keyDown()) saveAll = true; } // Creates, initializes and returns a new viewer. boost::shared_ptr<visualization::CloudViewer> createViewer() { boost::shared_ptr<visualization::CloudViewer> v(new visualization::CloudViewer("OpenNI viewer")); v->registerKeyboardCallback(keyboardEventOccured); return(v); } int main (int argc, char** argv) { ros::init(argc, argv, "pcl_write"); ros::NodeHandle nh; cout<< "Press space to record point cloud to a file."<<endl; viewer = createViewer(); //ros::Subscriber pcl_sub = nh.subscribe("/camera/depth_registered/points", 1, cloudCB); ros::Subscriber pcl_sub = nh.subscribe("usb_cam/image_raw", 1, cloudCB); ros::Rate rate(30.0); while (ros::ok() && ! viewer->wasStopped()) { ros::spinOnce(); rate.sleep(); } return 0; }
cda0de53186ac48cfc717a67b42dfd42d827f2f9
7c2ebc0bebe40645049ca9b2414cfa1f8082d5dd
/6week/6week/student_list.cpp
dffb68c523f16f9b0750ed8dd053106903e491ef
[]
no_license
boyunjjang1/OOP_Cpp
d21cd54f1fac77026a813b2efe0deae7f9a1071f
92b0481cb4f741707f3270211165e3b67c9b38d9
refs/heads/master
2020-04-03T16:08:43.284686
2018-11-11T01:53:57
2018-11-11T01:53:57
155,392,968
0
0
null
null
null
null
UHC
C++
false
false
935
cpp
student_list.cpp
#include "pch.h" #include <iostream> #include <string> #include <fstream> using namespace std; class Student { public: Student() : name(""), grade("") {}; void setName(string n) { name = n; } string getName() { return name; } void setGrade(string g) { grade = g; } string getGrade() { return grade; } private: string name; string grade; }; int main() { ifstream studentInfo; studentInfo.open("student_info.txt", ios::in); Student stuArray[4]; if (studentInfo.is_open()) { int count = 0; while (!studentInfo.eof()) { string name, grade; studentInfo >> name >> grade; stuArray[count].setName(name); stuArray[count].setGrade(grade); count++; } } else { cout << "파일 경로를 확인하세요,"; } for (int i = 0; i < 4; i++) { cout << stuArray[i].getName() << " " << stuArray[i].getGrade() << endl; } studentInfo.close(); return 0; }
c04f83a7f8f62639d859b532b83d29c7cada1c50
d6680029814adad504535efe799de90eb80403ad
/shared/math3d.cpp
79d59c4c2e98086a5369c92b7565a93f1c8e1bb9
[]
no_license
m2aadhil/OpenGL-3D-Space-Game
341b6d1087fe76d1840b4544e7a60d80f77366f0
29dbf8abc51c19357986fdbb292975bab40e9eb7
refs/heads/master
2022-06-15T13:57:31.901553
2020-05-05T08:26:51
2020-05-05T08:26:51
234,931,267
6
0
null
null
null
null
UTF-8
C++
false
false
33,464
cpp
math3d.cpp
// Math3d.c // Implementation of non-inlined functions in the Math3D Library // Richard S. Wright Jr. // These are pretty portable #include <math.h> #include "math3d.h" //////////////////////////////////////////////////////////// // LoadIdentity // For 3x3 and 4x4 float and double matricies. // 3x3 float void m3dLoadIdentity33(M3DMatrix33f m) { // Don't be fooled, this is still column major static M3DMatrix33f identity = { 1.0f, 0.0f, 0.0f , 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f }; memcpy(m, identity, sizeof(M3DMatrix33f)); } // 3x3 double void m3dLoadIdentity33(M3DMatrix33d m) { // Don't be fooled, this is still column major static M3DMatrix33d identity = { 1.0, 0.0, 0.0 , 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 }; memcpy(m, identity, sizeof(M3DMatrix33d)); } // 4x4 float void m3dLoadIdentity44(M3DMatrix44f m) { // Don't be fooled, this is still column major static M3DMatrix44f identity = { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }; memcpy(m, identity, sizeof(M3DMatrix44f)); } // 4x4 double void m3dLoadIdentity44(M3DMatrix44d m) { static M3DMatrix44d identity = { 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 }; memcpy(m, identity, sizeof(M3DMatrix44d)); } //////////////////////////////////////////////////////////////////////// // Return the square of the distance between two points // Should these be inlined...? float m3dGetDistanceSquared(const M3DVector3f u, const M3DVector3f v) { float x = u[0] - v[0]; x = x*x; float y = u[1] - v[1]; y = y*y; float z = u[2] - v[2]; z = z*z; return (x + y + z); } // Ditto above, but for doubles double m3dGetDistanceSquared(const M3DVector3d u, const M3DVector3d v) { double x = u[0] - v[0]; x = x*x; double y = u[1] - v[1]; y = y*y; double z = u[2] - v[2]; z = z*z; return (x + y + z); } #define A(row,col) a[(col<<2)+row] #define B(row,col) b[(col<<2)+row] #define P(row,col) product[(col<<2)+row] /////////////////////////////////////////////////////////////////////////////// // Multiply two 4x4 matricies void m3dMatrixMultiply44(M3DMatrix44f product, const M3DMatrix44f a, const M3DMatrix44f b ) { for (int i = 0; i < 4; i++) { float ai0=A(i,0), ai1=A(i,1), ai2=A(i,2), ai3=A(i,3); P(i,0) = ai0 * B(0,0) + ai1 * B(1,0) + ai2 * B(2,0) + ai3 * B(3,0); P(i,1) = ai0 * B(0,1) + ai1 * B(1,1) + ai2 * B(2,1) + ai3 * B(3,1); P(i,2) = ai0 * B(0,2) + ai1 * B(1,2) + ai2 * B(2,2) + ai3 * B(3,2); P(i,3) = ai0 * B(0,3) + ai1 * B(1,3) + ai2 * B(2,3) + ai3 * B(3,3); } } // Ditto above, but for doubles void m3dMatrixMultiply(M3DMatrix44d product, const M3DMatrix44d a, const M3DMatrix44d b ) { for (int i = 0; i < 4; i++) { double ai0=A(i,0), ai1=A(i,1), ai2=A(i,2), ai3=A(i,3); P(i,0) = ai0 * B(0,0) + ai1 * B(1,0) + ai2 * B(2,0) + ai3 * B(3,0); P(i,1) = ai0 * B(0,1) + ai1 * B(1,1) + ai2 * B(2,1) + ai3 * B(3,1); P(i,2) = ai0 * B(0,2) + ai1 * B(1,2) + ai2 * B(2,2) + ai3 * B(3,2); P(i,3) = ai0 * B(0,3) + ai1 * B(1,3) + ai2 * B(2,3) + ai3 * B(3,3); } } #undef A #undef B #undef P #define A33(row,col) a[(col*3)+row] #define B33(row,col) b[(col*3)+row] #define P33(row,col) product[(col*3)+row] /////////////////////////////////////////////////////////////////////////////// // Multiply two 3x3 matricies void m3dMatrixMultiply33(M3DMatrix33f product, const M3DMatrix33f a, const M3DMatrix33f b ) { for (int i = 0; i < 3; i++) { float ai0=A33(i,0), ai1=A33(i,1), ai2=A33(i,2); P33(i,0) = ai0 * B33(0,0) + ai1 * B33(1,0) + ai2 * B33(2,0); P33(i,1) = ai0 * B33(0,1) + ai1 * B33(1,1) + ai2 * B33(2,1); P33(i,2) = ai0 * B33(0,2) + ai1 * B33(1,2) + ai2 * B33(2,2); } } // Ditto above, but for doubles void m3dMatrixMultiply44(M3DMatrix33d product, const M3DMatrix33d a, const M3DMatrix33d b ) { for (int i = 0; i < 3; i++) { double ai0=A33(i,0), ai1=A33(i,1), ai2=A33(i,2); P33(i,0) = ai0 * B33(0,0) + ai1 * B33(1,0) + ai2 * B33(2,0); P33(i,1) = ai0 * B33(0,1) + ai1 * B33(1,1) + ai2 * B33(2,1); P33(i,2) = ai0 * B33(0,2) + ai1 * B33(1,2) + ai2 * B33(2,2); } } #undef A33 #undef B33 #undef P33 #define M33(row,col) m[col*3+row] /////////////////////////////////////////////////////////////////////////////// // Creates a 3x3 rotation matrix, takes radians NOT degrees void m3dRotationMatrix33(M3DMatrix33f m, float angle, float x, float y, float z) { float mag, s, c; float xx, yy, zz, xy, yz, zx, xs, ys, zs, one_c; s = float(sin(angle)); c = float(cos(angle)); mag = float(sqrt( x*x + y*y + z*z )); // Identity matrix if (mag == 0.0f) { m3dLoadIdentity33(m); return; } // Rotation matrix is normalized x /= mag; y /= mag; z /= mag; xx = x * x; yy = y * y; zz = z * z; xy = x * y; yz = y * z; zx = z * x; xs = x * s; ys = y * s; zs = z * s; one_c = 1.0f - c; M33(0,0) = (one_c * xx) + c; M33(0,1) = (one_c * xy) - zs; M33(0,2) = (one_c * zx) + ys; M33(1,0) = (one_c * xy) + zs; M33(1,1) = (one_c * yy) + c; M33(1,2) = (one_c * yz) - xs; M33(2,0) = (one_c * zx) - ys; M33(2,1) = (one_c * yz) + xs; M33(2,2) = (one_c * zz) + c; } #undef M33 /////////////////////////////////////////////////////////////////////////////// // Creates a 4x4 rotation matrix, takes radians NOT degrees void m3dRotationMatrix44(M3DMatrix44f m, float angle, float x, float y, float z) { float mag, s, c; float xx, yy, zz, xy, yz, zx, xs, ys, zs, one_c; s = float(sin(angle)); c = float(cos(angle)); mag = float(sqrt( x*x + y*y + z*z )); // Identity matrix if (mag == 0.0f) { m3dLoadIdentity44(m); return; } // Rotation matrix is normalized x /= mag; y /= mag; z /= mag; #define M(row,col) m[col*4+row] xx = x * x; yy = y * y; zz = z * z; xy = x * y; yz = y * z; zx = z * x; xs = x * s; ys = y * s; zs = z * s; one_c = 1.0f - c; M(0,0) = (one_c * xx) + c; M(0,1) = (one_c * xy) - zs; M(0,2) = (one_c * zx) + ys; M(0,3) = 0.0f; M(1,0) = (one_c * xy) + zs; M(1,1) = (one_c * yy) + c; M(1,2) = (one_c * yz) - xs; M(1,3) = 0.0f; M(2,0) = (one_c * zx) - ys; M(2,1) = (one_c * yz) + xs; M(2,2) = (one_c * zz) + c; M(2,3) = 0.0f; M(3,0) = 0.0f; M(3,1) = 0.0f; M(3,2) = 0.0f; M(3,3) = 1.0f; #undef M } /////////////////////////////////////////////////////////////////////////////// // Ditto above, but for doubles void m3dRotationMatrix33(M3DMatrix33d m, double angle, double x, double y, double z) { double mag, s, c; double xx, yy, zz, xy, yz, zx, xs, ys, zs, one_c; s = sin(angle); c = cos(angle); mag = sqrt( x*x + y*y + z*z ); // Identity matrix if (mag == 0.0) { m3dLoadIdentity33(m); return; } // Rotation matrix is normalized x /= mag; y /= mag; z /= mag; #define M(row,col) m[col*3+row] xx = x * x; yy = y * y; zz = z * z; xy = x * y; yz = y * z; zx = z * x; xs = x * s; ys = y * s; zs = z * s; one_c = 1.0 - c; M(0,0) = (one_c * xx) + c; M(0,1) = (one_c * xy) - zs; M(0,2) = (one_c * zx) + ys; M(1,0) = (one_c * xy) + zs; M(1,1) = (one_c * yy) + c; M(1,2) = (one_c * yz) - xs; M(2,0) = (one_c * zx) - ys; M(2,1) = (one_c * yz) + xs; M(2,2) = (one_c * zz) + c; #undef M } /////////////////////////////////////////////////////////////////////////////// // Creates a 4x4 rotation matrix, takes radians NOT degrees void m3dRotationMatrix44(M3DMatrix44d m, double angle, double x, double y, double z) { double mag, s, c; double xx, yy, zz, xy, yz, zx, xs, ys, zs, one_c; s = sin(angle); c = cos(angle); mag = sqrt( x*x + y*y + z*z ); // Identity matrix if (mag == 0.0) { m3dLoadIdentity44(m); return; } // Rotation matrix is normalized x /= mag; y /= mag; z /= mag; #define M(row,col) m[col*4+row] xx = x * x; yy = y * y; zz = z * z; xy = x * y; yz = y * z; zx = z * x; xs = x * s; ys = y * s; zs = z * s; one_c = 1.0f - c; M(0,0) = (one_c * xx) + c; M(0,1) = (one_c * xy) - zs; M(0,2) = (one_c * zx) + ys; M(0,3) = 0.0; M(1,0) = (one_c * xy) + zs; M(1,1) = (one_c * yy) + c; M(1,2) = (one_c * yz) - xs; M(1,3) = 0.0; M(2,0) = (one_c * zx) - ys; M(2,1) = (one_c * yz) + xs; M(2,2) = (one_c * zz) + c; M(2,3) = 0.0; M(3,0) = 0.0; M(3,1) = 0.0; M(3,2) = 0.0; M(3,3) = 1.0; #undef M } // Lifted from Mesa /* * Compute inverse of 4x4 transformation matrix. * Code contributed by Jacques Leroy jle@star.be * Return GL_TRUE for success, GL_FALSE for failure (singular matrix) */ bool m3dInvertMatrix44(M3DMatrix44f dst, const M3DMatrix44f src ) { #define SWAP_ROWS(a, b) { float *_tmp = a; (a)=(b); (b)=_tmp; } #define MAT(m,r,c) (m)[(c)*4+(r)] float wtmp[4][8]; float m0, m1, m2, m3, s; float *r0, *r1, *r2, *r3; r0 = wtmp[0], r1 = wtmp[1], r2 = wtmp[2], r3 = wtmp[3]; r0[0] = MAT(src,0,0), r0[1] = MAT(src,0,1), r0[2] = MAT(src,0,2), r0[3] = MAT(src,0,3), r0[4] = 1.0, r0[5] = r0[6] = r0[7] = 0.0, r1[0] = MAT(src,1,0), r1[1] = MAT(src,1,1), r1[2] = MAT(src,1,2), r1[3] = MAT(src,1,3), r1[5] = 1.0, r1[4] = r1[6] = r1[7] = 0.0, r2[0] = MAT(src,2,0), r2[1] = MAT(src,2,1), r2[2] = MAT(src,2,2), r2[3] = MAT(src,2,3), r2[6] = 1.0, r2[4] = r2[5] = r2[7] = 0.0, r3[0] = MAT(src,3,0), r3[1] = MAT(src,3,1), r3[2] = MAT(src,3,2), r3[3] = MAT(src,3,3), r3[7] = 1.0, r3[4] = r3[5] = r3[6] = 0.0; /* choose pivot - or die */ if (fabs(r3[0])>fabs(r2[0])) SWAP_ROWS(r3, r2); if (fabs(r2[0])>fabs(r1[0])) SWAP_ROWS(r2, r1); if (fabs(r1[0])>fabs(r0[0])) SWAP_ROWS(r1, r0); if (0.0 == r0[0]) return false; /* eliminate first variable */ m1 = r1[0]/r0[0]; m2 = r2[0]/r0[0]; m3 = r3[0]/r0[0]; s = r0[1]; r1[1] -= m1 * s; r2[1] -= m2 * s; r3[1] -= m3 * s; s = r0[2]; r1[2] -= m1 * s; r2[2] -= m2 * s; r3[2] -= m3 * s; s = r0[3]; r1[3] -= m1 * s; r2[3] -= m2 * s; r3[3] -= m3 * s; s = r0[4]; if (s != 0.0) { r1[4] -= m1 * s; r2[4] -= m2 * s; r3[4] -= m3 * s; } s = r0[5]; if (s != 0.0) { r1[5] -= m1 * s; r2[5] -= m2 * s; r3[5] -= m3 * s; } s = r0[6]; if (s != 0.0) { r1[6] -= m1 * s; r2[6] -= m2 * s; r3[6] -= m3 * s; } s = r0[7]; if (s != 0.0) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; } /* choose pivot - or die */ if (fabs(r3[1])>fabs(r2[1])) SWAP_ROWS(r3, r2); if (fabs(r2[1])>fabs(r1[1])) SWAP_ROWS(r2, r1); if (0.0 == r1[1]) return false; /* eliminate second variable */ m2 = r2[1]/r1[1]; m3 = r3[1]/r1[1]; r2[2] -= m2 * r1[2]; r3[2] -= m3 * r1[2]; r2[3] -= m2 * r1[3]; r3[3] -= m3 * r1[3]; s = r1[4]; if (0.0 != s) { r2[4] -= m2 * s; r3[4] -= m3 * s; } s = r1[5]; if (0.0 != s) { r2[5] -= m2 * s; r3[5] -= m3 * s; } s = r1[6]; if (0.0 != s) { r2[6] -= m2 * s; r3[6] -= m3 * s; } s = r1[7]; if (0.0 != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; } /* choose pivot - or die */ if (fabs(r3[2])>fabs(r2[2])) SWAP_ROWS(r3, r2); if (0.0 == r2[2]) return false; /* eliminate third variable */ m3 = r3[2]/r2[2]; r3[3] -= m3 * r2[3], r3[4] -= m3 * r2[4], r3[5] -= m3 * r2[5], r3[6] -= m3 * r2[6], r3[7] -= m3 * r2[7]; /* last check */ if (0.0 == r3[3]) return false; s = 1.0f/r3[3]; /* now back substitute row 3 */ r3[4] *= s; r3[5] *= s; r3[6] *= s; r3[7] *= s; m2 = r2[3]; /* now back substitute row 2 */ s = 1.0f/r2[2]; r2[4] = s * (r2[4] - r3[4] * m2), r2[5] = s * (r2[5] - r3[5] * m2), r2[6] = s * (r2[6] - r3[6] * m2), r2[7] = s * (r2[7] - r3[7] * m2); m1 = r1[3]; r1[4] -= r3[4] * m1, r1[5] -= r3[5] * m1, r1[6] -= r3[6] * m1, r1[7] -= r3[7] * m1; m0 = r0[3]; r0[4] -= r3[4] * m0, r0[5] -= r3[5] * m0, r0[6] -= r3[6] * m0, r0[7] -= r3[7] * m0; m1 = r1[2]; /* now back substitute row 1 */ s = 1.0f/r1[1]; r1[4] = s * (r1[4] - r2[4] * m1), r1[5] = s * (r1[5] - r2[5] * m1), r1[6] = s * (r1[6] - r2[6] * m1), r1[7] = s * (r1[7] - r2[7] * m1); m0 = r0[2]; r0[4] -= r2[4] * m0, r0[5] -= r2[5] * m0, r0[6] -= r2[6] * m0, r0[7] -= r2[7] * m0; m0 = r0[1]; /* now back substitute row 0 */ s = 1.0f/r0[0]; r0[4] = s * (r0[4] - r1[4] * m0), r0[5] = s * (r0[5] - r1[5] * m0), r0[6] = s * (r0[6] - r1[6] * m0), r0[7] = s * (r0[7] - r1[7] * m0); MAT(dst,0,0) = r0[4]; MAT(dst,0,1) = r0[5], MAT(dst,0,2) = r0[6]; MAT(dst,0,3) = r0[7], MAT(dst,1,0) = r1[4]; MAT(dst,1,1) = r1[5], MAT(dst,1,2) = r1[6]; MAT(dst,1,3) = r1[7], MAT(dst,2,0) = r2[4]; MAT(dst,2,1) = r2[5], MAT(dst,2,2) = r2[6]; MAT(dst,2,3) = r2[7], MAT(dst,3,0) = r3[4]; MAT(dst,3,1) = r3[5], MAT(dst,3,2) = r3[6]; MAT(dst,3,3) = r3[7]; return true; #undef MAT #undef SWAP_ROWS } // Ditto above, but for doubles bool m3dInvertMatrix44(M3DMatrix44d dst, const M3DMatrix44d src) { #define SWAP_ROWS(a, b) { double *_tmp = a; (a)=(b); (b)=_tmp; } #define MAT(m,r,c) (m)[(c)*4+(r)] double wtmp[4][8]; double m0, m1, m2, m3, s; double *r0, *r1, *r2, *r3; r0 = wtmp[0], r1 = wtmp[1], r2 = wtmp[2], r3 = wtmp[3]; r0[0] = MAT(src,0,0), r0[1] = MAT(src,0,1), r0[2] = MAT(src,0,2), r0[3] = MAT(src,0,3), r0[4] = 1.0, r0[5] = r0[6] = r0[7] = 0.0, r1[0] = MAT(src,1,0), r1[1] = MAT(src,1,1), r1[2] = MAT(src,1,2), r1[3] = MAT(src,1,3), r1[5] = 1.0, r1[4] = r1[6] = r1[7] = 0.0, r2[0] = MAT(src,2,0), r2[1] = MAT(src,2,1), r2[2] = MAT(src,2,2), r2[3] = MAT(src,2,3), r2[6] = 1.0, r2[4] = r2[5] = r2[7] = 0.0, r3[0] = MAT(src,3,0), r3[1] = MAT(src,3,1), r3[2] = MAT(src,3,2), r3[3] = MAT(src,3,3), r3[7] = 1.0, r3[4] = r3[5] = r3[6] = 0.0; // choose pivot - or die if (fabs(r3[0])>fabs(r2[0])) SWAP_ROWS(r3, r2); if (fabs(r2[0])>fabs(r1[0])) SWAP_ROWS(r2, r1); if (fabs(r1[0])>fabs(r0[0])) SWAP_ROWS(r1, r0); if (0.0 == r0[0]) return false; // eliminate first variable m1 = r1[0]/r0[0]; m2 = r2[0]/r0[0]; m3 = r3[0]/r0[0]; s = r0[1]; r1[1] -= m1 * s; r2[1] -= m2 * s; r3[1] -= m3 * s; s = r0[2]; r1[2] -= m1 * s; r2[2] -= m2 * s; r3[2] -= m3 * s; s = r0[3]; r1[3] -= m1 * s; r2[3] -= m2 * s; r3[3] -= m3 * s; s = r0[4]; if (s != 0.0) { r1[4] -= m1 * s; r2[4] -= m2 * s; r3[4] -= m3 * s; } s = r0[5]; if (s != 0.0) { r1[5] -= m1 * s; r2[5] -= m2 * s; r3[5] -= m3 * s; } s = r0[6]; if (s != 0.0) { r1[6] -= m1 * s; r2[6] -= m2 * s; r3[6] -= m3 * s; } s = r0[7]; if (s != 0.0) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; } // choose pivot - or die if (fabs(r3[1])>fabs(r2[1])) SWAP_ROWS(r3, r2); if (fabs(r2[1])>fabs(r1[1])) SWAP_ROWS(r2, r1); if (0.0 == r1[1]) return false; // eliminate second variable m2 = r2[1]/r1[1]; m3 = r3[1]/r1[1]; r2[2] -= m2 * r1[2]; r3[2] -= m3 * r1[2]; r2[3] -= m2 * r1[3]; r3[3] -= m3 * r1[3]; s = r1[4]; if (0.0 != s) { r2[4] -= m2 * s; r3[4] -= m3 * s; } s = r1[5]; if (0.0 != s) { r2[5] -= m2 * s; r3[5] -= m3 * s; } s = r1[6]; if (0.0 != s) { r2[6] -= m2 * s; r3[6] -= m3 * s; } s = r1[7]; if (0.0 != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; } // choose pivot - or die if (fabs(r3[2])>fabs(r2[2])) SWAP_ROWS(r3, r2); if (0.0 == r2[2]) return false; // eliminate third variable m3 = r3[2]/r2[2]; r3[3] -= m3 * r2[3], r3[4] -= m3 * r2[4], r3[5] -= m3 * r2[5], r3[6] -= m3 * r2[6], r3[7] -= m3 * r2[7]; // last check if (0.0 == r3[3]) return false; s = 1.0f/r3[3]; // now back substitute row 3 r3[4] *= s; r3[5] *= s; r3[6] *= s; r3[7] *= s; m2 = r2[3]; // now back substitute row 2 s = 1.0f/r2[2]; r2[4] = s * (r2[4] - r3[4] * m2), r2[5] = s * (r2[5] - r3[5] * m2), r2[6] = s * (r2[6] - r3[6] * m2), r2[7] = s * (r2[7] - r3[7] * m2); m1 = r1[3]; r1[4] -= r3[4] * m1, r1[5] -= r3[5] * m1, r1[6] -= r3[6] * m1, r1[7] -= r3[7] * m1; m0 = r0[3]; r0[4] -= r3[4] * m0, r0[5] -= r3[5] * m0, r0[6] -= r3[6] * m0, r0[7] -= r3[7] * m0; m1 = r1[2]; // now back substitute row 1 s = 1.0f/r1[1]; r1[4] = s * (r1[4] - r2[4] * m1), r1[5] = s * (r1[5] - r2[5] * m1), r1[6] = s * (r1[6] - r2[6] * m1), r1[7] = s * (r1[7] - r2[7] * m1); m0 = r0[2]; r0[4] -= r2[4] * m0, r0[5] -= r2[5] * m0, r0[6] -= r2[6] * m0, r0[7] -= r2[7] * m0; m0 = r0[1]; // now back substitute row 0 s = 1.0f/r0[0]; r0[4] = s * (r0[4] - r1[4] * m0), r0[5] = s * (r0[5] - r1[5] * m0), r0[6] = s * (r0[6] - r1[6] * m0), r0[7] = s * (r0[7] - r1[7] * m0); MAT(dst,0,0) = r0[4]; MAT(dst,0,1) = r0[5], MAT(dst,0,2) = r0[6]; MAT(dst,0,3) = r0[7], MAT(dst,1,0) = r1[4]; MAT(dst,1,1) = r1[5], MAT(dst,1,2) = r1[6]; MAT(dst,1,3) = r1[7], MAT(dst,2,0) = r2[4]; MAT(dst,2,1) = r2[5], MAT(dst,2,2) = r2[6]; MAT(dst,2,3) = r2[7], MAT(dst,3,0) = r3[4]; MAT(dst,3,1) = r3[5], MAT(dst,3,2) = r3[6]; MAT(dst,3,3) = r3[7]; return true; #undef MAT #undef SWAP_ROWS return true; } /////////////////////////////////////////////////////////////////////////////////////// // Get Window coordinates, discard Z... void m3dProjectXY(const M3DMatrix44f mModelView, const M3DMatrix44f mProjection, const int iViewPort[4], const M3DVector3f vPointIn, M3DVector2f vPointOut) { M3DVector4f vBack, vForth; memcpy(vBack, vPointIn, sizeof(float)*3); vBack[3] = 1.0f; m3dTransformVector4(vForth, vBack, mModelView); m3dTransformVector4(vBack, vForth, mProjection); if(!m3dCloseEnough(vBack[3], 0.0f, 0.000001f)) { float div = 1.0f / vBack[3]; vBack[0] *= div; vBack[1] *= div; } vPointOut[0] = vBack[0] * 0.5f + 0.5f; vPointOut[1] = vBack[1] * 0.5f + 0.5f; /* Map x,y to viewport */ vPointOut[0] = (vPointOut[0] * iViewPort[2]) + iViewPort[0]; vPointOut[1] = (vPointOut[1] * iViewPort[3]) + iViewPort[1]; } /////////////////////////////////////////////////////////////////////////////////////// // Get window coordinates, we also want Z.... void m3dProjectXYZ(const M3DMatrix44f mModelView, const M3DMatrix44f mProjection, const int iViewPort[4], const M3DVector3f vPointIn, M3DVector3f vPointOut) { M3DVector4f vBack, vForth; memcpy(vBack, vPointIn, sizeof(float)*3); vBack[3] = 1.0f; m3dTransformVector4(vForth, vBack, mModelView); m3dTransformVector4(vBack, vForth, mProjection); if(!m3dCloseEnough(vBack[3], 0.0f, 0.000001f)) { float div = 1.0f / vBack[3]; vBack[0] *= div; vBack[1] *= div; vBack[2] *= div; } vPointOut[0] = vBack[0] * 0.5f + 0.5f; vPointOut[1] = vBack[1] * 0.5f + 0.5f; vPointOut[2] = vBack[2] * 0.5f + 0.5f; /* Map x,y to viewport */ vPointOut[0] = (vPointOut[0] * iViewPort[2]) + iViewPort[0]; vPointOut[1] = (vPointOut[1] * iViewPort[3]) + iViewPort[1]; } /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// // Misc. Utilities /////////////////////////////////////////////////////////////////////////////// // Calculates the normal of a triangle specified by the three points // p1, p2, and p3. Each pointer points to an array of three floats. The // triangle is assumed to be wound counter clockwise. void m3dFindNormal(M3DVector3f result, const M3DVector3f point1, const M3DVector3f point2, const M3DVector3f point3) { M3DVector3f v1,v2; // Temporary vectors // Calculate two vectors from the three points. Assumes counter clockwise // winding! v1[0] = point1[0] - point2[0]; v1[1] = point1[1] - point2[1]; v1[2] = point1[2] - point2[2]; v2[0] = point2[0] - point3[0]; v2[1] = point2[1] - point3[1]; v2[2] = point2[2] - point3[2]; // Take the cross product of the two vectors to get // the normal vector. m3dCrossProduct(result, v1, v2); } // Ditto above, but for doubles void m3dFindNormal(M3DVector3d result, const M3DVector3d point1, const M3DVector3d point2, const M3DVector3d point3) { M3DVector3d v1,v2; // Temporary vectors // Calculate two vectors from the three points. Assumes counter clockwise // winding! v1[0] = point1[0] - point2[0]; v1[1] = point1[1] - point2[1]; v1[2] = point1[2] - point2[2]; v2[0] = point2[0] - point3[0]; v2[1] = point2[1] - point3[1]; v2[2] = point2[2] - point3[2]; // Take the cross product of the two vectors to get // the normal vector. m3dCrossProduct(result, v1, v2); } ///////////////////////////////////////////////////////////////////////////////////////// // Calculate the plane equation of the plane that the three specified points lay in. The // points are given in clockwise winding order, with normal pointing out of clockwise face // planeEq contains the A,B,C, and D of the plane equation coefficients void m3dGetPlaneEquation(M3DVector4f planeEq, const M3DVector3f p1, const M3DVector3f p2, const M3DVector3f p3) { // Get two vectors... do the cross product M3DVector3f v1, v2; // V1 = p3 - p1 v1[0] = p3[0] - p1[0]; v1[1] = p3[1] - p1[1]; v1[2] = p3[2] - p1[2]; // V2 = P2 - p1 v2[0] = p2[0] - p1[0]; v2[1] = p2[1] - p1[1]; v2[2] = p2[2] - p1[2]; // Unit normal to plane - Not sure which is the best way here m3dCrossProduct(planeEq, v1, v2); m3dNormalizeVector(planeEq); // Back substitute to get D planeEq[3] = -(planeEq[0] * p3[0] + planeEq[1] * p3[1] + planeEq[2] * p3[2]); } // Ditto above, but for doubles void m3dGetPlaneEquation(M3DVector4d planeEq, const M3DVector3d p1, const M3DVector3d p2, const M3DVector3d p3) { // Get two vectors... do the cross product M3DVector3d v1, v2; // V1 = p3 - p1 v1[0] = p3[0] - p1[0]; v1[1] = p3[1] - p1[1]; v1[2] = p3[2] - p1[2]; // V2 = P2 - p1 v2[0] = p2[0] - p1[0]; v2[1] = p2[1] - p1[1]; v2[2] = p2[2] - p1[2]; // Unit normal to plane - Not sure which is the best way here m3dCrossProduct(planeEq, v1, v2); m3dNormalizeVector(planeEq); // Back substitute to get D planeEq[3] = -(planeEq[0] * p3[0] + planeEq[1] * p3[1] + planeEq[2] * p3[2]); } ////////////////////////////////////////////////////////////////////////////////////////////////// // This function does a three dimensional Catmull-Rom curve interpolation. Pass four points, and a // floating point number between 0.0 and 1.0. The curve is interpolated between the middle two points. // Coded by RSW // http://www.mvps.org/directx/articles/catmull/ void m3dCatmullRom3(M3DVector3f vOut, M3DVector3f vP0, M3DVector3f vP1, M3DVector3f vP2, M3DVector3f vP3, float t) { // Unrolled loop to speed things up a little bit... float t2 = t * t; float t3 = t2 * t; // X vOut[0] = 0.5f * ( ( 2.0f * vP1[0]) + (-vP0[0] + vP2[0]) * t + (2.0f * vP0[0] - 5.0f *vP1[0] + 4.0f * vP2[0] - vP3[0]) * t2 + (-vP0[0] + 3.0f*vP1[0] - 3.0f *vP2[0] + vP3[0]) * t3); // Y vOut[1] = 0.5f * ( ( 2.0f * vP1[1]) + (-vP0[1] + vP2[1]) * t + (2.0f * vP0[1] - 5.0f *vP1[1] + 4.0f * vP2[1] - vP3[1]) * t2 + (-vP0[1] + 3.0f*vP1[1] - 3.0f *vP2[1] + vP3[1]) * t3); // Z vOut[2] = 0.5f * ( ( 2.0f * vP1[2]) + (-vP0[2] + vP2[2]) * t + (2.0f * vP0[2] - 5.0f *vP1[2] + 4.0f * vP2[2] - vP3[2]) * t2 + (-vP0[2] + 3.0f*vP1[2] - 3.0f *vP2[2] + vP3[2]) * t3); } ////////////////////////////////////////////////////////////////////////////////////////////////// // This function does a three dimensional Catmull-Rom curve interpolation. Pass four points, and a // floating point number between 0.0 and 1.0. The curve is interpolated between the middle two points. // Coded by RSW // http://www.mvps.org/directx/articles/catmull/ void m3dCatmullRom3(M3DVector3d vOut, M3DVector3d vP0, M3DVector3d vP1, M3DVector3d vP2, M3DVector3d vP3, double t) { // Unrolled loop to speed things up a little bit... double t2 = t * t; double t3 = t2 * t; // X vOut[0] = 0.5 * ( ( 2.0 * vP1[0]) + (-vP0[0] + vP2[0]) * t + (2.0 * vP0[0] - 5.0 *vP1[0] + 4.0 * vP2[0] - vP3[0]) * t2 + (-vP0[0] + 3.0*vP1[0] - 3.0 *vP2[0] + vP3[0]) * t3); // Y vOut[1] = 0.5 * ( ( 2.0 * vP1[1]) + (-vP0[1] + vP2[1]) * t + (2.0 * vP0[1] - 5.0 *vP1[1] + 4.0 * vP2[1] - vP3[1]) * t2 + (-vP0[1] + 3*vP1[1] - 3.0 *vP2[1] + vP3[1]) * t3); // Z vOut[2] = 0.5 * ( ( 2.0 * vP1[2]) + (-vP0[2] + vP2[2]) * t + (2.0 * vP0[2] - 5.0 *vP1[2] + 4.0 * vP2[2] - vP3[2]) * t2 + (-vP0[2] + 3.0*vP1[2] - 3.0 *vP2[2] + vP3[2]) * t3); } /////////////////////////////////////////////////////////////////////////////// // Determine if the ray (starting at point) intersects the sphere centered at // sphereCenter with radius sphereRadius // Return value is < 0 if the ray does not intersect // Return value is 0.0 if ray is tangent // Positive value is distance to the intersection point // Algorithm from "3D Math Primer for Graphics and Game Development" double m3dRaySphereTest(const M3DVector3d point, const M3DVector3d ray, const M3DVector3d sphereCenter, double sphereRadius) { //m3dNormalizeVector(ray); // Make sure ray is unit length M3DVector3d rayToCenter; // Ray to center of sphere rayToCenter[0] = sphereCenter[0] - point[0]; rayToCenter[1] = sphereCenter[1] - point[1]; rayToCenter[2] = sphereCenter[2] - point[2]; // Project rayToCenter on ray to test double a = m3dDotProduct(rayToCenter, ray); // Distance to center of sphere double distance2 = m3dDotProduct(rayToCenter, rayToCenter); // Or length double dRet = (sphereRadius * sphereRadius) - distance2 + (a*a); if(dRet > 0.0) // Return distance to intersection dRet = a - sqrt(dRet); return dRet; } /////////////////////////////////////////////////////////////////////////////// // Determine if the ray (starting at point) intersects the sphere centered at // ditto above, but uses floating point math float m3dRaySphereTest(const M3DVector3f point, const M3DVector3f ray, const M3DVector3f sphereCenter, float sphereRadius) { //m3dNormalizeVectorf(ray); // Make sure ray is unit length M3DVector3f rayToCenter; // Ray to center of sphere rayToCenter[0] = sphereCenter[0] - point[0]; rayToCenter[1] = sphereCenter[1] - point[1]; rayToCenter[2] = sphereCenter[2] - point[2]; // Project rayToCenter on ray to test float a = m3dDotProduct(rayToCenter, ray); // Distance to center of sphere float distance2 = m3dDotProduct(rayToCenter, rayToCenter); // Or length float dRet = (sphereRadius * sphereRadius) - distance2 + (a*a); if(dRet > 0.0) // Return distance to intersection dRet = a - sqrtf(dRet); return dRet; } /////////////////////////////////////////////////////////////////////////////////////////////////// // Calculate the tangent basis for a triangle on the surface of a model // This vector is needed for most normal mapping shaders void m3dCalculateTangentBasis(const M3DVector3f vTriangle[3], const M3DVector2f vTexCoords[3], const M3DVector3f N, M3DVector3f vTangent) { M3DVector3f dv2v1, dv3v1; float dc2c1t, dc2c1b, dc3c1t, dc3c1b; float M; m3dSubtractVectors3(dv2v1, vTriangle[1], vTriangle[0]); m3dSubtractVectors3(dv3v1, vTriangle[2], vTriangle[0]); dc2c1t = vTexCoords[1][0] - vTexCoords[0][0]; dc2c1b = vTexCoords[1][1] - vTexCoords[0][1]; dc3c1t = vTexCoords[2][0] - vTexCoords[0][0]; dc3c1b = vTexCoords[2][1] - vTexCoords[0][1]; M = (dc2c1t * dc3c1b) - (dc3c1t * dc2c1b); M = 1.0f / M; m3dScaleVector3(dv2v1, dc3c1b); m3dScaleVector3(dv3v1, dc2c1b); m3dSubtractVectors3(vTangent, dv2v1, dv3v1); m3dScaleVector3(vTangent, M); // This potentially changes the direction of the vector m3dNormalizeVector(vTangent); M3DVector3f B; m3dCrossProduct(B, N, vTangent); m3dCrossProduct(vTangent, B, N); m3dNormalizeVector(vTangent); } //////////////////////////////////////////////////////////////////////////// // Smoothly step between 0 and 1 between edge1 and edge 2 double m3dSmoothStep(double edge1, double edge2, double x) { double t; t = (x - edge1) / (edge2 - edge1); if(t > 1.0) t = 1.0; if(t < 0.0) t = 0.0f; return t * t * ( 3.0 - 2.0 * t); } //////////////////////////////////////////////////////////////////////////// // Smoothly step between 0 and 1 between edge1 and edge 2 float m3dSmoothStep(float edge1, float edge2, float x) { float t; t = (x - edge1) / (edge2 - edge1); if(t > 1.0f) t = 1.0f; if(t < 0.0) t = 0.0f; return t * t * ( 3.0f - 2.0f * t); } /////////////////////////////////////////////////////////////////////////// // Creae a projection to "squish" an object into the plane. // Use m3dGetPlaneEquationf(planeEq, point1, point2, point3); // to get a plane equation. void m3dMakePlanarShadowMatrix(M3DMatrix44f proj, const M3DVector4f planeEq, const M3DVector3f vLightPos) { // These just make the code below easier to read. They will be // removed by the optimizer. float a = planeEq[0]; float b = planeEq[1]; float c = planeEq[2]; float d = planeEq[3]; float dx = -vLightPos[0]; float dy = -vLightPos[1]; float dz = -vLightPos[2]; // Now build the projection matrix proj[0] = b * dy + c * dz; proj[1] = -a * dy; proj[2] = -a * dz; proj[3] = 0.0; proj[4] = -b * dx; proj[5] = a * dx + c * dz; proj[6] = -b * dz; proj[7] = 0.0; proj[8] = -c * dx; proj[9] = -c * dy; proj[10] = a * dx + b * dy; proj[11] = 0.0; proj[12] = -d * dx; proj[13] = -d * dy; proj[14] = -d * dz; proj[15] = a * dx + b * dy + c * dz; // Shadow matrix ready } /////////////////////////////////////////////////////////////////////////// // Creae a projection to "squish" an object into the plane. // Use m3dGetPlaneEquationd(planeEq, point1, point2, point3); // to get a plane equation. void m3dMakePlanarShadowMatrix(M3DMatrix44d proj, const M3DVector4d planeEq, const M3DVector3f vLightPos) { // These just make the code below easier to read. They will be // removed by the optimizer. double a = planeEq[0]; double b = planeEq[1]; double c = planeEq[2]; double d = planeEq[3]; double dx = -vLightPos[0]; double dy = -vLightPos[1]; double dz = -vLightPos[2]; // Now build the projection matrix proj[0] = b * dy + c * dz; proj[1] = -a * dy; proj[2] = -a * dz; proj[3] = 0.0; proj[4] = -b * dx; proj[5] = a * dx + c * dz; proj[6] = -b * dz; proj[7] = 0.0; proj[8] = -c * dx; proj[9] = -c * dy; proj[10] = a * dx + b * dy; proj[11] = 0.0; proj[12] = -d * dx; proj[13] = -d * dy; proj[14] = -d * dz; proj[15] = a * dx + b * dy + c * dz; // Shadow matrix ready } ///////////////////////////////////////////////////////////////////////////// // I want to know the point on a ray, closest to another given point in space. // As a bonus, return the distance squared of the two points. // In: vRayOrigin is the origin of the ray. // In: vUnitRayDir is the unit vector of the ray // In: vPointInSpace is the point in space // Out: vPointOnRay is the poing on the ray closest to vPointInSpace // Return: The square of the distance to the ray double m3dClosestPointOnRay(M3DVector3d vPointOnRay, const M3DVector3d vRayOrigin, const M3DVector3d vUnitRayDir, const M3DVector3d vPointInSpace) { M3DVector3d v; m3dSubtractVectors3(v, vPointInSpace, vRayOrigin); double t = m3dDotProduct(vUnitRayDir, v); // This is the point on the ray vPointOnRay[0] = vRayOrigin[0] + (t * vUnitRayDir[0]); vPointOnRay[1] = vRayOrigin[1] + (t * vUnitRayDir[1]); vPointOnRay[2] = vRayOrigin[2] + (t * vUnitRayDir[2]); return m3dGetDistanceSquared(vPointOnRay, vPointInSpace); } // ditto above... but with floats float m3dClosestPointOnRay(M3DVector3f vPointOnRay, const M3DVector3f vRayOrigin, const M3DVector3f vUnitRayDir, const M3DVector3f vPointInSpace) { M3DVector3f v; m3dSubtractVectors3(v, vPointInSpace, vRayOrigin); float t = m3dDotProduct(vUnitRayDir, v); // This is the point on the ray vPointOnRay[0] = vRayOrigin[0] + (t * vUnitRayDir[0]); vPointOnRay[1] = vRayOrigin[1] + (t * vUnitRayDir[1]); vPointOnRay[2] = vRayOrigin[2] + (t * vUnitRayDir[2]); return m3dGetDistanceSquared(vPointOnRay, vPointInSpace); }
5c80c447401baff0c1cc53a9b42f8167a204ef1c
4781374c5507d9ab81d8e7493bcf60c19988371b
/Source/AProject/Frame/Table/DataTable/MyDataTableSet.cpp
1ce200f36c0380b501bc6de59ab719a37d27bef0
[]
no_license
bohyun43/AProjectstart
f4f1362f617c371386489fdcd3f3d0be18d1a40f
5d2f7f72d588190ef3de9c0ed2a14bdce5977a7b
refs/heads/master
2020-12-03T16:15:03.396674
2020-01-02T14:01:48
2020-01-02T14:01:48
231,385,614
0
0
null
null
null
null
UHC
C++
false
false
4,113
cpp
MyDataTableSet.cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "MyDataTableSet.h" #include "MyTableSetBase.h" #include "Engine/DataTable.h" // UDataTable 지원 // DataTable Test... #include "MyTableManager.h" #include "Struct/MyDTRecordTemplate.h" #include "Struct/MyDTRecordSound.h" #include "Struct/MyDTRecordStage.h" UMyDataTableSet::UMyDataTableSet() { My_LOGCALLF(Log_Base, Log); // 데이터 연결 방법 1 : 생성자에서 데이터 연결 처리 Example /* FString TemplateTablePath = TEXT("Game/Resources/Table/xxx.xxx"); static ConstructorHelpers::FObjectFinder<UDataTable> DT_Template(*TemplateTablePath); My_CHECK(DT_Template.Succeeded() == true); DataTableSet.Add(EDataTypeTable::DTT_Temp, DT_Template.Object); */ // 데이터 연결 방법 2 : Blueprint로 파생 클래스 생성하여 DataTableSet에 등록 } void UMyDataTableSet::FinishDestroy() { My_LOGCALLF(Log_Base, Log); Super::FinishDestroy(); } void UMyDataTableSet::TableInit(class UMyTableManager* parent) { My_LOGCALLF(Log_Frame, Log); Super::TableInit(parent); // Todo } void UMyDataTableSet::TableRelease() { // Todo for (auto& tableHolder : DataTableHolder) { SAFE_DELETE(tableHolder.Value); } DataTableHolder.Empty(); Super::TableRelease(); My_LOGCALLF(Log_Frame, Log); } bool UMyDataTableSet::TableLoad() { // LoadTableHolder(); My_LOGCALLF(Log_Frame, Log); return true; } bool UMyDataTableSet::TableSave() { My_LOGCALLF(Log_Frame, Log); return true; } void UMyDataTableSet::TableBegin() { // DataTable Test... /*if (UFSBlueprintFuncLibrary::IsFrame() == true) { UMySystemSingleton* pFrame = FS_FRMAE(); if (pFrame != nullptr) { UMyDataTableSet* dataTableSet = pFrame->GetTable()->GetTableSet<UMyDataTableSet>(ETableSetType::TT_DataTable); if (dataTableSet != nullptr) { int32 templateIndex = 1; FMyDTRecordTemplate* templateRecord = dataTableSet->GetTableRecord<FMyDTRecordTemplate>(EDataTypeTable::DTT_Template, templateIndex); if (templateRecord != nullptr) { My_LOG(Log_Print, Log, TEXT("UMyDataTableSet:BeginPlay() Template Table > %d %s"), templateIndex, *templateRecord->TempString.ToString()) } int32 soundIndex = 2000; FMyDTRecordSound* soundRecord = dataTableSet->GetTableRecord<FMyDTRecordSound>(EDataTypeTable::DTT_Sound, soundIndex); if (soundRecord != nullptr) { My_LOG(Log_Print, Log, TEXT("UMyDataTableSet:BeginPlay() Sound Table > %d %s"), soundIndex, *soundRecord->SoundCueName) } } } }*/ } void UMyDataTableSet::TableEnd() { // Todo } // DataTable 접근 UDataTable* UMyDataTableSet::GetTable(EDataTypeTable tableType) { UDataTable** findedElem = DataTableSet.Find(tableType); if (findedElem != nullptr) { UDataTable* dataTable = *findedElem; if (dataTable != nullptr) { return dataTable; } } return nullptr; } // DataTable 등록되어 있는지 판단. bool UMyDataTableSet::HasTable(const EDataTypeTable tableType) { return DataTableSet.Contains(tableType); } // DataTableHolder 접근 UDataTable* UMyDataTableSet::GetTableHolder(EDataTypeTable tableType) { UDataTable* retValue = nullptr; UMyDataTableSet::MyDataTableHolder** findedElem = DataTableHolder.Find(tableType); if (findedElem != nullptr) { UMyDataTableSet::MyDataTableHolder* dataTableHolder = *findedElem; if (dataTableHolder != nullptr) { retValue = dataTableHolder->GetDataTable(); } } return retValue; } // DataTableHolder에 등록되어 있는지 판단. bool UMyDataTableSet::HasTableHolder(const EDataTypeTable tableType) { return DataTableHolder.Contains(tableType); } // UDataTable을 Holder에 등록 하기 bool UMyDataTableSet::LoadTableHolder(EDataTypeTable tableType, FString assetName) { // DataTable Asset 읽기. UDataTable* dataTable = Cast<UDataTable>(StaticLoadObject(UDataTable::StaticClass(), nullptr, *assetName)); if (dataTable != nullptr) { if (DataTableHolder.Contains(tableType) == false) { DataTableHolder.Add(tableType, new UMyDataTableSet::MyDataTableHolder(dataTable)); return true; } } return false; }
7ce9b6f0dcd937c5428c2f0c9183f837eaf241ba
3ac34c8d3d9ec507e91d0aec4a35141b19c49698
/maximum subarray sum.cpp
74d70d95d7fc1110578266b3ae3ada35321f984a
[]
no_license
aradhna7/MSIThactkober
b54beae556bccaab91da168c10f455d5bd5b2510
970a0141df85ec7d8766f71b4a24fdaaca681306
refs/heads/master
2023-09-03T20:22:20.736014
2021-10-25T13:15:08
2021-10-25T13:15:08
300,803,918
0
6
null
2020-10-26T13:14:51
2020-10-03T05:30:34
Jupyter Notebook
UTF-8
C++
false
false
431
cpp
maximum subarray sum.cpp
#include<iostream> using namespace std; int main() { //no. of testcases int t; cin>>t; for(int i=1;i<=t;i++){ int n; cin>>n; int a[n]={0}; //arrary input for(int j=0;j<n;j++){ cin>>a[j]; } //kadane's algorithm int ms=0; int cs=0; for(int j=0;j<n;j++){ cs=cs+a[j]; if(cs<0){ cs=0; } ms=max(cs,ms); } cout<<ms<<endl; } return 0; }
9037e2afbb6473f819ede46f6280f2f9c1a12adb
d20cf7de868dfb2c53578a70d0dda21306167d72
/data/raw/train/student_14/1411/1406/While.h
b8900cd33fc56ca86ec7a98f83ebeccd76738457
[]
no_license
bulacu-magda/Alemia
905a84ca79157fb657eb424e337b0303fd3323bd
0fd019c4517064d300399feb94dbcb0f467e8d48
refs/heads/main
2023-03-01T17:41:08.788500
2021-02-05T08:00:35
2021-02-05T08:00:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
31
h
While.h
#pragma once class While { };
9fcb63699676f374fc6ea7f132af5430deb6d330
b7a0ac5d1db9d54fa67a49147ef2350f07ccf857
/tests/Core/OutCircularPointerFilter.cpp
c94da180e876190fa13ad7f8645619f4804f6fb7
[ "BSD-3-Clause" ]
permissive
xinsuinizhuan/AudioTK
a14e8812145d2e7da0fa02209805441e66255a14
dba42eea68534501efe74692b74edf4792cca231
refs/heads/main
2023-04-16T04:36:09.831280
2021-02-18T19:53:58
2021-02-18T19:53:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,692
cpp
OutCircularPointerFilter.cpp
/** * \ file OutCircularPointerFilter.cpp */ #include <cmath> #include <boost/math/constants/constants.hpp> #include <ATK/Core/InPointerFilter.h> #include <ATK/Core/OutCircularPointerFilter.h> #include <gtest/gtest.h> constexpr gsl::index PROCESSSIZE = 512; TEST(OutCircularPointerFloat, sin1k_test) { std::array<float, PROCESSSIZE*200> data; for(gsl::index i = 0; i < PROCESSSIZE*200; ++i) { data[i] = std::sin(2 * boost::math::constants::pi<float>() * (i+1.)/48000 * 1000); } ATK::InPointerFilter<float> generator(data.data(), 1, data.size(), false); generator.set_output_sampling_rate(48000); ATK::OutCircularPointerFilter<float> output; output.set_input_sampling_rate(48000); output.set_input_port(0, &generator, 0); auto nb_iterations = 4 + ATK::OutCircularPointerFilter<float>::slice_size * ATK::OutCircularPointerFilter<float>::nb_slices / PROCESSSIZE; auto max_zero = std::max(gsl::index(0), gsl::index(ATK::OutCircularPointerFilter<float>::out_slice_size)); gsl::index offset = 0; for(int i = 0; i < nb_iterations; ++i) { output.process(PROCESSSIZE); bool process; const auto& outdata = output.get_last_slice(process); if(process && i!=0) { max_zero = std::max( gsl::index(0), gsl::index(ATK::OutCircularPointerFilter<float>::out_slice_size - (i + 1) * PROCESSSIZE)); offset = std::max(gsl::index(0), (i + 1) * PROCESSSIZE - gsl::index(ATK::OutCircularPointerFilter<float>::out_slice_size)) - max_zero; } for(gsl::index j = 0; j < max_zero; ++j) { ASSERT_EQ(outdata[j], 0); } for(gsl::index j = max_zero; j < outdata.size(); ++j) { ASSERT_EQ(outdata[j], data[j + offset]); } } } TEST(OutCircularPointerFloat, sin1k_full_setup_test) { std::array<float, PROCESSSIZE*200> data; for(gsl::index i = 0; i < PROCESSSIZE*200; ++i) { data[i] = std::sin(2 * boost::math::constants::pi<float>() * (i+1.)/48000 * 1000); } ATK::InPointerFilter<float> generator(data.data(), 1, data.size(), false); generator.set_output_sampling_rate(48000); ATK::OutCircularPointerFilter<float> output; output.set_input_sampling_rate(48000); output.set_input_port(0, &generator, 0); auto nb_iterations = 4 + ATK::OutCircularPointerFilter<float>::slice_size * ATK::OutCircularPointerFilter<float>::nb_slices / PROCESSSIZE; for(int i = 0; i < nb_iterations; ++i) { output.process(PROCESSSIZE); output.full_setup(); bool process; const auto& outdata = output.get_last_slice(process); for(gsl::index j = 0; j < outdata.size(); ++j) { ASSERT_EQ(outdata[j], 0); } } }
4ad9872788ef9861a259d55675689c87946ae64b
2d75b502d8a212edd8bd9d737cc73f57b9d355f1
/src/main.cpp
2805f3b94f1adb6ce584cb234f18995d86fc6548
[ "MIT" ]
permissive
baatochan/TerminalSnake
dad4b1554b3ce765f555f659f015c52444c59b3a
de72c8eaf238f6bb2b072faa6cdaa3add96f164c
refs/heads/master
2020-05-14T14:09:51.165287
2019-04-30T11:19:04
2019-04-30T11:19:04
181,827,323
0
0
null
null
null
null
UTF-8
C++
false
false
160
cpp
main.cpp
#include "Game.hpp" int main() { auto UI = std::unique_ptr<UserInterfaceI>(new UserInterface); Game game(std::move(UI), 3, 3); game.start(); return 0; }
f3c9079bb32e69ed03ef8db8242ca11323dd1fb5
0ad1616843a4da2ec701f069d31a71c502862b9e
/CS2420 - Algorithms and Data Structures (C++, Spring 2017)/myWork/2 - Recursive List/RecursiveList/RecursiveList/List.h
9c2636599fededd1d9559298739eeeee56555f9f
[]
no_license
shanewazhere/UVU-CS
268c4df9a3829dea40296bdf4af7edace5f8bba7
1066374243d1f870b99b123f9e84d9b117d594fa
refs/heads/master
2021-06-24T23:04:14.647903
2017-09-13T17:12:35
2017-09-13T17:12:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,899
h
List.h
//Recursive List - 01/24/2017 //Max Nelson //Section 002 //List.h //I Max Nelson have not used any code other than my own(or that in the textbook) for this project. //I also have not used any function or data - structure from the Standard - Template Library. //The standard library for C++ is fine.I also have not shared my code with any student in this class. //I understand that any violation of this disclaimer will result in a 0 for the project. #pragma once #include <cstdlib> #include <iostream> #include "Node.h" namespace list_2 { class List { Node *head; int listSize; // helper function for the destructor // add other helper functions here to complete your program. // they should all contain one or more Node* as parameters void destroy(Node *n); //helper function for addEnd void addEndHelper(int d, Node* temp); //helper function for print void printHelper(Node* temp); //helper function for insert void insertHelper(int d, Node* temp); //helper function for find bool findHelper(int d, Node* temp); //helper function for size int sizeHelper(Node* temp); public: // postcondition: list is initialized List(); // postcondition: all nodes are destroyed using recursion ~List(); // postcondition: add element d at the end of the list // using recursion void addEnd(int d); // postcondition: print the list ussing recursion void print(); // precondition: list is in sorted order // (don't use addEnd with this function) // postcondition: d is inserted into the list so the list maintains // sorted order. using recursison. void insert(int d); // postcondition: if d is in the list then find returns true // else find returns false bool find(int d); // postcondition: size is returned. Must be calculated using recursion. int size(); }; }
8b9133a40fa11b4d1fa6cf3ff57e1be8aa5f614a
e85a38922bbc04a13ee90a970fd1a4962742813a
/ShaderEffect/StrokeNoise/src/Snake.cpp
7088682c01a932a5760ba795f0af3b9c4a312a30
[ "MIT" ]
permissive
kynd/apps_of0081_osx
cb75b9067ebea648ffbe5ee96428e5ed5e169ebb
16a7ec7623893f31d4dec3f4571203dce468e6d2
refs/heads/master
2021-01-01T18:03:05.692620
2014-07-02T17:07:47
2014-07-02T17:07:47
21,432,386
1
0
null
null
null
null
UTF-8
C++
false
false
3,178
cpp
Snake.cpp
#include "Snake.h" Snake::Snake(float l, float w, int _dl, int _dw) { length = l; width = w; dl = _dl; dw = _dw; shader.load("shaders/phong/shader.vert", "shaders/phong/shader.frag"); // center points for (int i = 0; i < dl; i ++) { points.push_back(ofVec3f(i * 30, 0,0)); } // ball head = ofMesh::sphere(w); // tube for (int i = 0; i < dl; i ++) { for (int j = 0; j < dw; j ++) { int p0 = (i - 1) * dw + j - 1; int p1 = (i - 1) * dw + j - 0; int p2 = (i - 1) * dw + j + 1; int p3 = i * dw + j - 1; int p4 = i * dw + j - 0; int p5 = i * dw + j + 1; mesh.addVertex(ofVec3f()); mesh.addNormal(ofVec3f()); if (i > 0) { if (j < dw - 1) { mesh.addIndex(p4); mesh.addIndex(p2); mesh.addIndex(p1); } if (j > 0) { mesh.addIndex(p4); mesh.addIndex(p1); mesh.addIndex(p3); } if (j == dw -1) { mesh.addIndex(p4); mesh.addIndex((i - 1) * dw); mesh.addIndex(p1); mesh.addIndex(i * dw); mesh.addIndex((i - 1) * dw); mesh.addIndex(p4); } } } } mesh.setMode(OF_PRIMITIVE_TRIANGLES); } Snake::~Snake() {} void Snake::update(float x, float y) { x -= ofGetWidth() / 2; y -= ofGetHeight() / 2; x *= -1; float dist = headPos.distance(ofVec3f(x,y,0)); headPos.x += (x - headPos.x) / 2; headPos.y += (y - headPos.y) / 2; headPos *= 0.99; //center points points[0] += (headPos - points[0]) * 0.4; for (int i = 1; i < dl; i ++) { points[i] += (points[i - 1] - points[i]) * 0.5; } // tube for (int i = 0; i < dl; i ++) { ofVec3f direc = ((i == 0) ? points[i] - points [i + 1] : points[i - 1] - points[i]).normalize(); ofVec3f rad = direc.getCrossed(ofVec3f(0,0,1)); float dist = (i == 0) ? points[i].distance(points [i + 1]) : points[i].distance(points[i - 1] - points[i]); float ratio = pow(abs((float) i / (dl - 1) - 0.5) + 0.5, 3.5); for (int j = 0; j < dw; j ++) { mesh.getVertices()[i * dw + j].set(points[i] + rad * width * ratio); mesh.getNormals()[i * dw + j].set(rad); rad.rotate(360.f / dw, direc); } } } void Snake::draw() { ofClear(0,0,255); glEnable(GL_DEPTH_TEST); shader.begin(); shader.setUniform3f("lightDir", 1,1,1); shader.setUniform3f("ambientColor", 0.5, 0.5, 0.5); shader.setUniform4f("diffuseColor", 1,1,1,1); shader.setUniform4f("specularColor", 1,1,1,1); mesh.draw(); ofPushMatrix(); ofTranslate(points[0]);head.draw(); ofPopMatrix(); ofPushMatrix(); ofTranslate(points[points.size() - 1]);head.draw(); ofPopMatrix(); shader.end(); glDisable(GL_DEPTH_TEST); }
d67fa4f991ee1952f97c843cdd916e1db2f06b11
c537f83fea715f4f1a1ba0eba40b6bf04ce10c56
/project 1/project1_modeldata.cc
68373dafc1030e960a25a4c01099d8f993fcbe4c
[]
no_license
sluu3/ECGR4090-ML-IoT
c39da81ef6246527eca9ac051cd75ae628ebe4a2
49b5fc0f3a8564d287cf39e8f24fe4d4ebe9994e
refs/heads/main
2023-04-22T12:36:03.372485
2021-05-13T19:47:50
2021-05-13T19:47:50
334,307,826
1
0
null
2021-01-30T02:06:16
2021-01-30T02:06:16
null
UTF-8
C++
false
false
67,728
cc
project1_modeldata.cc
unsigned char project1_model_tflite[] = { 0x1c, 0x00, 0x00, 0x00, 0x54, 0x46, 0x4c, 0x33, 0x14, 0x00, 0x20, 0x00, 0x1c, 0x00, 0x18, 0x00, 0x14, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00, 0x14, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x10, 0x1d, 0x00, 0x00, 0x20, 0x1d, 0x00, 0x00, 0xd0, 0x29, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x6d, 0x69, 0x6e, 0x5f, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x00, 0x16, 0x00, 0x00, 0x00, 0xc0, 0x1c, 0x00, 0x00, 0xb8, 0x1c, 0x00, 0x00, 0xa0, 0x1c, 0x00, 0x00, 0x6c, 0x1c, 0x00, 0x00, 0x4c, 0x1c, 0x00, 0x00, 0x38, 0x1c, 0x00, 0x00, 0x24, 0x1c, 0x00, 0x00, 0xc4, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x06, 0xe3, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x31, 0x2e, 0x31, 0x34, 0x2e, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xd7, 0xff, 0xff, 0x1c, 0xd7, 0xff, 0xff, 0x20, 0xd7, 0xff, 0xff, 0x24, 0xd7, 0xff, 0xff, 0x28, 0xd7, 0xff, 0xff, 0x2c, 0xd7, 0xff, 0xff, 0x30, 0xd7, 0xff, 0xff, 0x34, 0xd7, 0xff, 0xff, 0x38, 0xd7, 0xff, 0xff, 0x3c, 0xd7, 0xff, 0xff, 0x4a, 0xe3, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x2d, 0xff, 0xff, 0xff, 0xd3, 0x00, 0x00, 0x00, 0x5e, 0xe3, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x7f, 0x20, 0x85, 0x3a, 0xad, 0xe9, 0xe0, 0x77, 0x72, 0xe3, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0xdc, 0xfb, 0xff, 0xff, 0xd5, 0xfb, 0xff, 0xff, 0xa9, 0x03, 0x00, 0x00, 0x2d, 0x07, 0x00, 0x00, 0x8e, 0xe3, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0x50, 0x1b, 0x00, 0x00, 0x02, 0xed, 0xc6, 0x29, 0x1a, 0xfa,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 0xfc, 0x0f, 0xe0, 0xfa, 0xc4, 0x18, 0x09, 0xe4, 0x43, 0x1d, 0xd4, 0xd8, 0xef, 0xca, 0xf8, 0x47, 0x48, 0xfe, 0x61, 0x56, 0x1f, 0x48, 0x4a, 0x0d, 0x40, 0x48, 0x4d, 0x2d, 0x01, 0x52, 0x50, 0x00, 0x11, 0x72, 0x24, 0x2a, 0x00, 0x1c, 0x05, 0xfc, 0x66, 0x45, 0x25, 0x1d, 0x5d, 0x42, 0x21, 0x45, 0x03, 0x09, 0x17, 0x26, 0x6d, 0xce, 0x29, 0x50, 0x2c, 0x02, 0xfe, 0xee, 0x51, 0x50, 0x5b, 0xf0, 0x56, 0xc6, 0x13, 0x38, 0xfa, 0x18, 0x1e, 0xe1, 0x67, 0xbf, 0xde, 0xde, 0x1a, 0x46, 0x26, 0x2c, 0x21, 0x01, 0x47, 0xc5, 0x29, 0x41, 0xe2, 0xdb, 0x29, 0xf4, 0x41, 0x66, 0x64, 0xfd, 0x1f, 0x24, 0x13, 0x23, 0xdd, 0x2e, 0xd8, 0x17, 0x15, 0x06, 0x21, 0xcc, 0xfb, 0x54, 0x11, 0xde, 0x36, 0x18, 0x18, 0x24, 0x2d, 0x37, 0xe5, 0x34, 0x27, 0x33, 0x59, 0xe9, 0xeb, 0x53, 0x18, 0xee, 0x2c, 0x1c, 0x15, 0x19, 0x3f, 0x15, 0x4d, 0x45, 0x02, 0xeb, 0xdf, 0x0d, 0xf7, 0xef, 0x32, 0x0e, 0x27, 0x6e, 0x36, 0xd1, 0xfe, 0x69, 0x2a, 0x3b, 0x0c, 0x15, 0x09, 0x26, 0xec, 0xfb, 0xc3, 0xfe, 0x31, 0x14, 0x08, 0xc1, 0xec, 0xcb, 0xad, 0xe1, 0xe4, 0x57, 0x20, 0x44, 0xf1, 0x4d, 0x14, 0xd9, 0x02, 0xee, 0xfd, 0x09, 0x3f, 0x36, 0xeb, 0x49, 0x1a, 0xec, 0x55, 0x2d, 0xe5, 0x3a, 0x44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, 0xcd, 0xa1, 0x35, 0x32, 0xd4, 0xcf, 0xde, 0xed, 0x02, 0xba, 0xf3, 0xc2, 0xc7, 0x33, 0xe8, 0xb1, 0xb6, 0x12, 0xc9, 0x3a, 0xce, 0xb6, 0xfe, 0xb4, 0xd5, 0xea, 0xfe, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x9f, 0x87, 0x80, 0x99, 0xfa, 0xfe, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x7f, 0x4a, 0xff, 0xb7, 0x0a, 0xff, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0xff, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x3b, 0x45, 0xd7, 0x97, 0xd6, 0x9e, 0x7f, 0x64, 0x18, 0x03, 0x7f, 0x12, 0x0f, 0x9f, 0x90, 0x22, 0x7a, 0x42, 0x76, 0x7c, 0xc1, 0x42, 0xef, 0x14, 0x24, 0x81, 0x49, 0xbc, 0x4e, 0x3e, 0x6e, 0x75, 0x7f, 0x5d, 0x00, 0x70, 0x56, 0xff, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xd4, 0x06, 0x00, 0x00, 0x60, 0xf3, 0xff, 0xff, 0x64, 0xf3, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x4d, 0x4c, 0x49, 0x52, 0x20, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x64, 0x2e, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x18, 0x00, 0x14, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x28, 0x02, 0x00, 0x00, 0x2c, 0x02, 0x00, 0x00, 0x30, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0xbc, 0x01, 0x00, 0x00, 0x58, 0x01, 0x00, 0x00, 0x24, 0x01, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x72, 0xfe, 0xff, 0xff, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x1c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x01, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0xaa, 0xfe, 0xff, 0xff, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2c, 0xf4, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0xde, 0xfe, 0xff, 0xff, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x07, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4e, 0xff, 0xff, 0xff, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xd0, 0xf4, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x7e, 0xff, 0xff, 0xff, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf5, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xae, 0xff, 0xff, 0xff, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x34, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x18, 0x00, 0x17, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x18, 0x00, 0x14, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x0b, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x2c, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x14, 0x00, 0x13, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x07, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x0c, 0x0a, 0x00, 0x00, 0x58, 0x09, 0x00, 0x00, 0x78, 0x08, 0x00, 0x00, 0xf4, 0x07, 0x00, 0x00, 0x78, 0x07, 0x00, 0x00, 0x0c, 0x07, 0x00, 0x00, 0x88, 0x06, 0x00, 0x00, 0x1c, 0x06, 0x00, 0x00, 0x98, 0x05, 0x00, 0x00, 0x1c, 0x05, 0x00, 0x00, 0x10, 0x04, 0x00, 0x00, 0x84, 0x03, 0x00, 0x00, 0xe0, 0x02, 0x00, 0x00, 0x3c, 0x02, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x0c, 0x01, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1c, 0xfb, 0xff, 0xff, 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x44, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x02, 0x00, 0x00, 0x00, 0xfc, 0xf6, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3b, 0x09, 0x00, 0x00, 0x00, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x31, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x84, 0xfb, 0xff, 0xff, 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x74, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x02, 0x00, 0x00, 0x00, 0x64, 0xf7, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xae, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x34, 0x1e, 0x52, 0x3d, 0x38, 0x00, 0x00, 0x00, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x63, 0x6e, 0x6e, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x31, 0x34, 0x31, 0x2f, 0x4d, 0x61, 0x74, 0x4d, 0x75, 0x6c, 0x3b, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x63, 0x6e, 0x6e, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x31, 0x34, 0x31, 0x2f, 0x42, 0x69, 0x61, 0x73, 0x41, 0x64, 0x64, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1c, 0xfc, 0xff, 0xff, 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x8c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0xfc, 0xf7, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xab, 0x90, 0xee, 0x3d, 0x52, 0x00, 0x00, 0x00, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x63, 0x6e, 0x6e, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x31, 0x34, 0x30, 0x2f, 0x4d, 0x61, 0x74, 0x4d, 0x75, 0x6c, 0x3b, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x63, 0x6e, 0x6e, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x31, 0x34, 0x30, 0x2f, 0x42, 0x69, 0x61, 0x73, 0x41, 0x64, 0x64, 0x3b, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x63, 0x6e, 0x6e, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x31, 0x34, 0x30, 0x2f, 0x52, 0x65, 0x6c, 0x75, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xcc, 0xfc, 0xff, 0xff, 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x54, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xd4, 0x06, 0x00, 0x00, 0xac, 0xf8, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xab, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x4f, 0xf9, 0xcd, 0x3c, 0x1d, 0x00, 0x00, 0x00, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x63, 0x6e, 0x6e, 0x2f, 0x66, 0x6c, 0x61, 0x74, 0x74, 0x65, 0x6e, 0x5f, 0x37, 0x30, 0x2f, 0x52, 0x65, 0x73, 0x68, 0x61, 0x70, 0x65, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xd4, 0x06, 0x00, 0x00, 0x44, 0xfd, 0xff, 0xff, 0x18, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x74, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x17, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x2c, 0xf9, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xab, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x4f, 0xf9, 0xcd, 0x3c, 0x34, 0x00, 0x00, 0x00, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x63, 0x6e, 0x6e, 0x2f, 0x62, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x31, 0x39, 0x36, 0x2f, 0x46, 0x75, 0x73, 0x65, 0x64, 0x42, 0x61, 0x74, 0x63, 0x68, 0x4e, 0x6f, 0x72, 0x6d, 0x56, 0x33, 0x33, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xe4, 0xfd, 0xff, 0xff, 0x18, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x74, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x17, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xcc, 0xf9, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x97, 0xd2, 0xc9, 0x3c, 0x34, 0x00, 0x00, 0x00, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x63, 0x6e, 0x6e, 0x2f, 0x62, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x31, 0x39, 0x36, 0x2f, 0x46, 0x75, 0x73, 0x65, 0x64, 0x42, 0x61, 0x74, 0x63, 0x68, 0x4e, 0x6f, 0x72, 0x6d, 0x56, 0x33, 0x32, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x84, 0xfe, 0xff, 0xff, 0x18, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x5c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x17, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6c, 0xfa, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xc8, 0xf6, 0x85, 0x40, 0x18, 0x00, 0x00, 0x00, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x63, 0x6e, 0x6e, 0x2f, 0x70, 0x6f, 0x6f, 0x6c, 0x32, 0x2f, 0x4d, 0x61, 0x78, 0x50, 0x6f, 0x6f, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0c, 0xff, 0xff, 0xff, 0x18, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0xc8, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x2f, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xf4, 0xfa, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0xc8, 0xf6, 0x85, 0x40, 0x8b, 0x00, 0x00, 0x00, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x63, 0x6e, 0x6e, 0x2f, 0x63, 0x6f, 0x6e, 0x76, 0x32, 0x64, 0x5f, 0x32, 0x31, 0x31, 0x2f, 0x52, 0x65, 0x6c, 0x75, 0x3b, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x63, 0x6e, 0x6e, 0x2f, 0x63, 0x6f, 0x6e, 0x76, 0x32, 0x64, 0x5f, 0x32, 0x31, 0x31, 0x2f, 0x42, 0x69, 0x61, 0x73, 0x41, 0x64, 0x64, 0x3b, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x63, 0x6e, 0x6e, 0x2f, 0x63, 0x6f, 0x6e, 0x76, 0x32, 0x64, 0x5f, 0x32, 0x31, 0x31, 0x2f, 0x43, 0x6f, 0x6e, 0x76, 0x32, 0x44, 0x3b, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x63, 0x6e, 0x6e, 0x2f, 0x63, 0x6f, 0x6e, 0x76, 0x32, 0x64, 0x5f, 0x32, 0x31, 0x31, 0x2f, 0x42, 0x69, 0x61, 0x73, 0x41, 0x64, 0x64, 0x2f, 0x52, 0x65, 0x61, 0x64, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x4f, 0x70, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x14, 0x00, 0x1c, 0x00, 0x18, 0x00, 0x17, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x14, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x4c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x31, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xfc, 0xfb, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0xb1, 0xb0, 0x30, 0x40, 0x0c, 0x00, 0x00, 0x00, 0x74, 0x66, 0x6c, 0x2e, 0x71, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x7a, 0x65, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xba, 0xfb, 0xff, 0xff, 0x14, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x64, 0x00, 0x00, 0x00, 0x5c, 0xfc, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x50, 0x7a, 0xdd, 0x39, 0x34, 0x00, 0x00, 0x00, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x63, 0x6e, 0x6e, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x31, 0x34, 0x31, 0x2f, 0x42, 0x69, 0x61, 0x73, 0x41, 0x64, 0x64, 0x2f, 0x52, 0x65, 0x61, 0x64, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x4f, 0x70, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3a, 0xfc, 0xff, 0xff, 0x14, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x48, 0x00, 0x00, 0x00, 0xdc, 0xfc, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xf5, 0xa9, 0x6d, 0x3b, 0x1b, 0x00, 0x00, 0x00, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x63, 0x6e, 0x6e, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x31, 0x34, 0x31, 0x2f, 0x4d, 0x61, 0x74, 0x4d, 0x75, 0x6c, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa2, 0xfc, 0xff, 0xff, 0x14, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x64, 0x00, 0x00, 0x00, 0x44, 0xfd, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa7, 0x03, 0xa6, 0x37, 0x34, 0x00, 0x00, 0x00, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x63, 0x6e, 0x6e, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x31, 0x34, 0x30, 0x2f, 0x42, 0x69, 0x61, 0x73, 0x41, 0x64, 0x64, 0x2f, 0x52, 0x65, 0x61, 0x64, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x4f, 0x70, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x22, 0xfd, 0xff, 0xff, 0x14, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x48, 0x00, 0x00, 0x00, 0xc4, 0xfd, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xce, 0x55, 0x4e, 0x3a, 0x1b, 0x00, 0x00, 0x00, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x63, 0x6e, 0x6e, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x31, 0x34, 0x30, 0x2f, 0x4d, 0x61, 0x74, 0x4d, 0x75, 0x6c, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xd4, 0x06, 0x00, 0x00, 0x8a, 0xfd, 0xff, 0xff, 0x14, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x5c, 0x00, 0x00, 0x00, 0x2c, 0xfe, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0xaf, 0x89, 0x3b, 0x33, 0x00, 0x00, 0x00, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x63, 0x6e, 0x6e, 0x2f, 0x62, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x31, 0x39, 0x36, 0x2f, 0x46, 0x75, 0x73, 0x65, 0x64, 0x42, 0x61, 0x74, 0x63, 0x68, 0x4e, 0x6f, 0x72, 0x6d, 0x56, 0x33, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0xfe, 0xff, 0xff, 0x14, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x64, 0x00, 0x00, 0x00, 0xa4, 0xfe, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x56, 0x75, 0x38, 0x34, 0x00, 0x00, 0x00, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x63, 0x6e, 0x6e, 0x2f, 0x62, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x31, 0x39, 0x36, 0x2f, 0x46, 0x75, 0x73, 0x65, 0x64, 0x42, 0x61, 0x74, 0x63, 0x68, 0x4e, 0x6f, 0x72, 0x6d, 0x56, 0x33, 0x31, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x82, 0xfe, 0xff, 0xff, 0x14, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xc0, 0x00, 0x00, 0x00, 0x24, 0xff, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xad, 0xb0, 0xe4, 0x3b, 0xa4, 0xec, 0xd4, 0x3b, 0xf2, 0x5b, 0xf3, 0x3b, 0x7f, 0xa3, 0xe2, 0x3b, 0x70, 0x00, 0x00, 0x00, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x63, 0x6e, 0x6e, 0x2f, 0x63, 0x6f, 0x6e, 0x76, 0x32, 0x64, 0x5f, 0x32, 0x31, 0x31, 0x2f, 0x42, 0x69, 0x61, 0x73, 0x41, 0x64, 0x64, 0x3b, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x63, 0x6e, 0x6e, 0x2f, 0x63, 0x6f, 0x6e, 0x76, 0x32, 0x64, 0x5f, 0x32, 0x31, 0x31, 0x2f, 0x43, 0x6f, 0x6e, 0x76, 0x32, 0x44, 0x3b, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x63, 0x6e, 0x6e, 0x2f, 0x63, 0x6f, 0x6e, 0x76, 0x32, 0x64, 0x5f, 0x32, 0x31, 0x31, 0x2f, 0x42, 0x69, 0x61, 0x73, 0x41, 0x64, 0x64, 0x2f, 0x52, 0x65, 0x61, 0x64, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x4f, 0x70, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x5e, 0xff, 0xff, 0xff, 0x20, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x78, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa0, 0xab, 0x25, 0x3b, 0xcb, 0x3f, 0x1a, 0x3b, 0x10, 0x4c, 0x30, 0x3b, 0x2b, 0x2f, 0x24, 0x3b, 0x1c, 0x00, 0x00, 0x00, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x63, 0x6e, 0x6e, 0x2f, 0x63, 0x6f, 0x6e, 0x76, 0x32, 0x64, 0x5f, 0x32, 0x31, 0x31, 0x2f, 0x43, 0x6f, 0x6e, 0x76, 0x32, 0x44, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x18, 0x00, 0x14, 0x00, 0x13, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x2c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x63, 0x6e, 0x6e, 0x2f, 0x66, 0x6c, 0x61, 0x74, 0x74, 0x65, 0x6e, 0x5f, 0x37, 0x30, 0x2f, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0xc4, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x88, 0xff, 0xff, 0xff, 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x98, 0xff, 0xff, 0xff, 0x19, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0xa8, 0xff, 0xff, 0xff, 0x09, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x0c, 0x00, 0x0a, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x16, 0x0a, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x12, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0xf0, 0xff, 0xff, 0xff, 0x11, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x0c, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0c, 0x00, 0x0c, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x72 }; unsigned int project1_model_tflite_len = 10968;
7aeb119514d657ec5916118891c5f685f8cdda31
bac200b5d9aa4244e7ff8e8d690f1d96fd76c9fc
/tutorial8/GameObject.cpp
3205387529bafd9f9b377e873c60c155d5629e60
[ "LicenseRef-scancode-public-domain" ]
permissive
jeag2002/SpaceShooter2D-EngineTest
54bd99a82ffe9cd7c0c215fb3c335344c979d0fe
1afdbc6da0860e20cfa09c64aecc5054c235023b
refs/heads/master
2021-06-02T21:31:44.027559
2020-05-30T10:41:34
2020-05-30T10:41:34
95,495,632
0
0
null
null
null
null
UTF-8
C++
false
false
1,187
cpp
GameObject.cpp
/****************************************************************************** * OpenGLES Tutorial Code - 2008/2009 - Pete Covert * * This code is public domain, do with it what you will. If you make * something interesting with it, let me know at satacoy@gmail.com! *****************************************************************************/ #include "GameObject.h" #include "FixedTrig.h" GameObject::GameObject(void) : dead(false), x(0), y(0), type(OBJ_NONE), angle(0), hitRadius(0) { fixedTrig = FixedTrig::GetInstance(); } // Uses object's angle and passed in x and y values to calculate offset void GameObject::CalcOffset(GLfixed dist, GLfixed &lx, GLfixed &ly) { ly += ((dist >> 8) * fixedTrig->Sinx(angle)) >> 8; lx += ((dist >> 8) * fixedTrig->Cosx(angle)) >> 8; } // Uses object's angle and passed in x and y values to calculate offset void GameObject::CalcOffset(GLfixed xDist, GLfixed yDist, GLfixed &lx, GLfixed &ly) { lx += (((xDist >> 8) * fixedTrig->Cosx(angle)) >> 8) - (((yDist >> 8) * fixedTrig->Sinx(angle)) >> 8); ly += (((xDist >> 8) * fixedTrig->Sinx(angle)) >> 8) + (((yDist >> 8) * fixedTrig->Cosx(angle)) >> 8); }
eecf47a7c526708e755644a5e2387ae5a3efaf96
b7f1b4df5d350e0edf55521172091c81f02f639e
/chrome/browser/ui/views/media_router/media_router_ui_browsertest.cc
0eb39914a69a0ce57f56dabbc22d57a0aa85b960
[ "BSD-3-Clause" ]
permissive
blusno1/chromium-1
f13b84547474da4d2702341228167328d8cd3083
9dd22fe142b48f14765a36f69344ed4dbc289eb3
refs/heads/master
2023-05-17T23:50:16.605396
2018-01-12T19:39:49
2018-01-12T19:39:49
117,339,342
4
2
NOASSERTION
2020-07-17T07:35:37
2018-01-13T11:48:57
null
UTF-8
C++
false
false
15,206
cc
media_router_ui_browsertest.cc
// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/bind.h" #include "base/run_loop.h" #include "base/threading/thread_task_runner_handle.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/extensions/browser_action_test_util.h" #include "chrome/browser/prefs/browser_prefs.h" #include "chrome/browser/renderer_context_menu/render_view_context_menu_test_util.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h" #include "chrome/browser/ui/toolbar/media_router_action.h" #include "chrome/browser/ui/toolbar/media_router_action_controller.h" #include "chrome/browser/ui/toolbar/toolbar_action_view_delegate.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/toolbar/app_menu.h" #include "chrome/browser/ui/views/toolbar/app_menu_button.h" #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" #include "chrome/browser/ui/views/toolbar/toolbar_action_view.h" #include "chrome/browser/ui/views/toolbar/toolbar_view.h" #include "chrome/browser/ui/webui/media_router/media_router_dialog_controller_impl.h" #include "chrome/browser/ui/webui/media_router/media_router_ui_service.h" #include "chrome/common/url_constants.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/web_contents.h" #include "content/public/common/context_menu_params.h" #include "content/public/test/test_navigation_observer.h" #include "content/public/test/test_utils.h" #include "ui/views/widget/widget.h" namespace { constexpr char kToolbarMigratedComponentActionStatus[] = "toolbar_migrated_component_action_status"; } namespace media_router { class MediaRouterUIBrowserTest : public InProcessBrowserTest { public: MediaRouterUIBrowserTest() : issue_(IssueInfo("title notification", IssueInfo::Action::DISMISS, IssueInfo::Severity::NOTIFICATION)) {} ~MediaRouterUIBrowserTest() override {} void SetUpOnMainThread() override { BrowserActionsContainer* browser_actions_container = BrowserView::GetBrowserViewForBrowser(browser()) ->toolbar() ->browser_actions(); ASSERT_TRUE(browser_actions_container); toolbar_actions_bar_ = browser_actions_container->toolbar_actions_bar(); action_controller_ = MediaRouterUIService::Get(browser()->profile())->action_controller(); routes_ = {MediaRoute("routeId1", MediaSource("sourceId"), "sinkId1", "description", true, true)}; } void OpenMediaRouterDialogAndWaitForNewWebContents() { content::TestNavigationObserver nav_observer(NULL); nav_observer.StartWatchingNewWebContents(); AppMenuButton* app_menu_button = GetAppMenuButton(); // When the Media Router Action executes, it opens a dialog with web // contents to chrome://media-router. base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::BindOnce(&MediaRouterUIBrowserTest::ExecuteMediaRouterAction, base::Unretained(this), app_menu_button)); base::RunLoop run_loop; app_menu_button->ShowMenu(false); run_loop.RunUntilIdle(); nav_observer.Wait(); EXPECT_FALSE(app_menu_button->IsMenuShowing()); ASSERT_EQ(chrome::kChromeUIMediaRouterURL, nav_observer.last_navigation_url().spec()); nav_observer.StopWatchingNewWebContents(); } MediaRouterAction* GetMediaRouterAction() { return MediaRouterDialogControllerImpl::GetOrCreateForWebContents( browser()->tab_strip_model()->GetActiveWebContents()) ->action(); } ui::SimpleMenuModel* GetActionContextMenu() { return static_cast<ui::SimpleMenuModel*>( GetMediaRouterAction()->GetContextMenu()); } void ExecuteMediaRouterAction(AppMenuButton* app_menu_button) { EXPECT_TRUE(app_menu_button->IsMenuShowing()); GetMediaRouterAction()->ExecuteAction(true); } bool ActionExists() { return ToolbarActionsModel::Get(browser()->profile()) ->HasComponentAction( ComponentToolbarActionsFactory::kMediaRouterActionId); } void SetAlwaysShowActionPref(bool always_show) { MediaRouterActionController::SetAlwaysShowActionPref(browser()->profile(), always_show); } AppMenuButton* GetAppMenuButton() { return BrowserView::GetBrowserViewForBrowser(browser()) ->toolbar() ->app_menu_button(); } // Sets the old preference to show the toolbar action icon to |always_show|, // and migrates the preference. void MigrateToolbarIconPref(bool always_show) { { DictionaryPrefUpdate update(browser()->profile()->GetPrefs(), kToolbarMigratedComponentActionStatus); update->SetBoolean(ComponentToolbarActionsFactory::kMediaRouterActionId, always_show); } MigrateObsoleteProfilePrefs(browser()->profile()); } protected: ToolbarActionsBar* toolbar_actions_bar_ = nullptr; Issue issue_; // A vector of MediaRoutes that includes a local route. std::vector<MediaRoute> routes_; MediaRouterActionController* action_controller_ = nullptr; }; #if defined(OS_CHROMEOS) || defined(OS_LINUX) || defined(OS_WIN) // Flaky on chromeos, linux, win: https://crbug.com/658005 #define MAYBE_OpenDialogWithMediaRouterAction \ DISABLED_OpenDialogWithMediaRouterAction #else #define MAYBE_OpenDialogWithMediaRouterAction OpenDialogWithMediaRouterAction #endif IN_PROC_BROWSER_TEST_F(MediaRouterUIBrowserTest, MAYBE_OpenDialogWithMediaRouterAction) { // We start off at about:blank page. // Make sure there is 1 tab and media router is enabled. ASSERT_EQ(1, browser()->tab_strip_model()->count()); SetAlwaysShowActionPref(true); EXPECT_TRUE(ActionExists()); OpenMediaRouterDialogAndWaitForNewWebContents(); // Reload the browser and wait. content::TestNavigationObserver reload_observer( browser()->tab_strip_model()->GetActiveWebContents()); chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB); reload_observer.Wait(); // The reload should have removed the previously created dialog. // We expect a new dialog WebContents to be created by calling this. OpenMediaRouterDialogAndWaitForNewWebContents(); // Navigate away. ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); // The navigation should have removed the previously created dialog. // We expect a new dialog WebContents to be created by calling this. OpenMediaRouterDialogAndWaitForNewWebContents(); SetAlwaysShowActionPref(false); } IN_PROC_BROWSER_TEST_F(MediaRouterUIBrowserTest, OpenDialogFromContextMenu) { // Start with one tab showing about:blank. ASSERT_EQ(1, browser()->tab_strip_model()->count()); content::WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); MediaRouterDialogController* dialog_controller = MediaRouterDialogController::GetOrCreateForWebContents( browser()->tab_strip_model()->GetActiveWebContents()); content::ContextMenuParams params; params.page_url = web_contents->GetController().GetActiveEntry()->GetURL(); TestRenderViewContextMenu menu(web_contents->GetMainFrame(), params); menu.Init(); ASSERT_TRUE(menu.IsItemPresent(IDC_ROUTE_MEDIA)); ASSERT_FALSE(dialog_controller->IsShowingMediaRouterDialog()); menu.ExecuteCommand(IDC_ROUTE_MEDIA, 0); EXPECT_TRUE(dialog_controller->IsShowingMediaRouterDialog()); // Executing the command again should be a no-op, and there should only be one // dialog opened per tab. menu.ExecuteCommand(IDC_ROUTE_MEDIA, 0); EXPECT_TRUE(dialog_controller->IsShowingMediaRouterDialog()); dialog_controller->HideMediaRouterDialog(); EXPECT_FALSE(dialog_controller->IsShowingMediaRouterDialog()); } IN_PROC_BROWSER_TEST_F(MediaRouterUIBrowserTest, OpenDialogFromAppMenu) { // Start with one tab showing about:blank. ASSERT_EQ(1, browser()->tab_strip_model()->count()); AppMenuButton* menu_button = GetAppMenuButton(); base::RunLoop run_loop; menu_button->ShowMenu(false); run_loop.RunUntilIdle(); MediaRouterDialogController* dialog_controller = MediaRouterDialogController::GetOrCreateForWebContents( browser()->tab_strip_model()->GetActiveWebContents()); AppMenu* menu = menu_button->app_menu_for_testing(); ASSERT_FALSE(dialog_controller->IsShowingMediaRouterDialog()); menu->ExecuteCommand(IDC_ROUTE_MEDIA, 0); EXPECT_TRUE(dialog_controller->IsShowingMediaRouterDialog()); // Executing the command again should be a no-op, and there should only be one // dialog opened per tab. menu->ExecuteCommand(IDC_ROUTE_MEDIA, 0); EXPECT_TRUE(dialog_controller->IsShowingMediaRouterDialog()); dialog_controller->HideMediaRouterDialog(); EXPECT_FALSE(dialog_controller->IsShowingMediaRouterDialog()); } IN_PROC_BROWSER_TEST_F(MediaRouterUIBrowserTest, OpenDialogsInMultipleTabs) { // Start with two tabs. chrome::NewTab(browser()); ASSERT_EQ(2, browser()->tab_strip_model()->count()); MediaRouterDialogController* dialog_controller1 = MediaRouterDialogController::GetOrCreateForWebContents( browser()->tab_strip_model()->GetWebContentsAt(0)); MediaRouterDialogController* dialog_controller2 = MediaRouterDialogController::GetOrCreateForWebContents( browser()->tab_strip_model()->GetWebContentsAt(1)); // Show the media router action on the toolbar. SetAlwaysShowActionPref(true); // Open a dialog in the first tab using the toolbar action. browser()->tab_strip_model()->ActivateTabAt(0, true); EXPECT_FALSE(dialog_controller1->IsShowingMediaRouterDialog()); GetMediaRouterAction()->ExecuteAction(true); EXPECT_TRUE(dialog_controller1->IsShowingMediaRouterDialog()); // Move to the second tab, which shouldn't have a dialog at first. Open and // close a dialog in that tab. browser()->tab_strip_model()->ActivateTabAt(1, true); EXPECT_FALSE(dialog_controller2->IsShowingMediaRouterDialog()); GetMediaRouterAction()->ExecuteAction(true); EXPECT_TRUE(dialog_controller2->IsShowingMediaRouterDialog()); GetMediaRouterAction()->ExecuteAction(true); EXPECT_FALSE(dialog_controller2->IsShowingMediaRouterDialog()); // Move back to the first tab, whose dialog should still be open. Hide the // dialog. browser()->tab_strip_model()->ActivateTabAt(0, true); EXPECT_TRUE(dialog_controller1->IsShowingMediaRouterDialog()); GetMediaRouterAction()->ExecuteAction(true); EXPECT_FALSE(dialog_controller1->IsShowingMediaRouterDialog()); // Reset the preference showing the toolbar action. SetAlwaysShowActionPref(false); } IN_PROC_BROWSER_TEST_F(MediaRouterUIBrowserTest, EphemeralToolbarIconForRoutesAndIssues) { action_controller_->OnIssue(issue_); EXPECT_TRUE(ActionExists()); action_controller_->OnIssuesCleared(); EXPECT_FALSE(ActionExists()); action_controller_->OnRoutesUpdated(routes_, std::vector<MediaRoute::Id>()); EXPECT_TRUE(ActionExists()); action_controller_->OnRoutesUpdated(std::vector<MediaRoute>(), std::vector<MediaRoute::Id>()); EXPECT_FALSE(ActionExists()); SetAlwaysShowActionPref(true); EXPECT_TRUE(ActionExists()); SetAlwaysShowActionPref(false); EXPECT_FALSE(ActionExists()); } IN_PROC_BROWSER_TEST_F(MediaRouterUIBrowserTest, EphemeralToolbarIconForDialog) { MediaRouterDialogController* dialog_controller = MediaRouterDialogController::GetOrCreateForWebContents( browser()->tab_strip_model()->GetActiveWebContents()); EXPECT_FALSE(ActionExists()); dialog_controller->ShowMediaRouterDialog(); EXPECT_TRUE(ActionExists()); dialog_controller->HideMediaRouterDialog(); EXPECT_FALSE(ActionExists()); dialog_controller->ShowMediaRouterDialog(); EXPECT_TRUE(ActionExists()); // Clicking on the toolbar icon should hide both the dialog and the icon. GetMediaRouterAction()->ExecuteAction(true); EXPECT_FALSE(dialog_controller->IsShowingMediaRouterDialog()); EXPECT_FALSE(ActionExists()); dialog_controller->ShowMediaRouterDialog(); SetAlwaysShowActionPref(true); // When the pref is set to true, hiding the dialog shouldn't hide the icon. dialog_controller->HideMediaRouterDialog(); EXPECT_TRUE(ActionExists()); dialog_controller->ShowMediaRouterDialog(); // While the dialog is showing, setting the pref to false shouldn't hide the // icon. SetAlwaysShowActionPref(false); EXPECT_TRUE(ActionExists()); dialog_controller->HideMediaRouterDialog(); EXPECT_FALSE(ActionExists()); } IN_PROC_BROWSER_TEST_F(MediaRouterUIBrowserTest, EphemeralToolbarIconWithMultipleWindows) { action_controller_->OnRoutesUpdated(routes_, std::vector<MediaRoute::Id>()); EXPECT_TRUE(ActionExists()); // Opening and closing a window shouldn't affect the state of the ephemeral // icon. Creating and removing the icon with multiple windows open should also // work. Browser* browser2 = CreateBrowser(browser()->profile()); EXPECT_TRUE(ActionExists()); action_controller_->OnRoutesUpdated(std::vector<MediaRoute>(), std::vector<MediaRoute::Id>()); EXPECT_FALSE(ActionExists()); action_controller_->OnRoutesUpdated(routes_, std::vector<MediaRoute::Id>()); EXPECT_TRUE(ActionExists()); browser2->window()->Close(); EXPECT_TRUE(ActionExists()); } IN_PROC_BROWSER_TEST_F(MediaRouterUIBrowserTest, UpdateActionLocation) { SetAlwaysShowActionPref(true); // Get the index for "Hide in Chrome menu" / "Show in toolbar" menu item. const int command_index = GetActionContextMenu()->GetIndexOfCommandId( IDC_MEDIA_ROUTER_SHOW_IN_TOOLBAR); // Start out with the action visible on the main bar. EXPECT_TRUE( toolbar_actions_bar_->IsActionVisibleOnMainBar(GetMediaRouterAction())); GetActionContextMenu()->ActivatedAt(command_index); // The action should get hidden in the overflow menu. EXPECT_FALSE( toolbar_actions_bar_->IsActionVisibleOnMainBar(GetMediaRouterAction())); GetActionContextMenu()->ActivatedAt(command_index); // The action should be back on the main bar. EXPECT_TRUE( toolbar_actions_bar_->IsActionVisibleOnMainBar(GetMediaRouterAction())); } IN_PROC_BROWSER_TEST_F(MediaRouterUIBrowserTest, MigrateToolbarIconShownPref) { MigrateToolbarIconPref(true); EXPECT_TRUE(MediaRouterActionController::GetAlwaysShowActionPref( browser()->profile())); } IN_PROC_BROWSER_TEST_F(MediaRouterUIBrowserTest, MigrateToolbarIconUnshownPref) { MigrateToolbarIconPref(false); EXPECT_FALSE(MediaRouterActionController::GetAlwaysShowActionPref( browser()->profile())); } } // namespace media_router
e92db7f10d99807e925f876d77ecf2cc05a864ae
0fa23591f7c5b78b1a0a4005b201e5c2b3e7ce70
/BC/src/MyLazyCallback.h
55d39258eb61bcaf49b9c88f096816f44459ac73
[]
no_license
srtjanuario/kit-opt
8750b153634e5ab42faac670014088f7820745cf
2ee2e774681a53b0baaeeca364ef373115c713bd
refs/heads/master
2022-10-19T23:50:04.584292
2020-05-29T01:35:41
2020-05-29T01:35:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,270
h
MyLazyCallback.h
#ifndef MY_LAZY_CALLBACK_H #define MY_LAZY_CALLBACK_H #include <ilcplex/ilocplex.h> #include <vector> #include "Graph.h" #include "Util.h" #include <list> #include <mutex> //guarda os vertices de um p3 que não foi adicionado ao modelo. Esse P3 é x[i][j] <= x[i][l] + x[j][l]. Portanto, i < j < l. typedef struct { int i,j,l; int n; }t_p3; /** Lazy callback */ class MyLazyCallback : public IloCplex::LazyConstraintCallbackI { public: //construtor da classe: recebe o environmet, a referencia da variavel e o numero de clusters MyLazyCallback(IloEnv env, const IloArray<IloBoolVarArray>& x_ref, const IloBoolVarArray& y_ref, int k, bool use_y = true); //metodo que retorna uma copia do calback. Cplex exige este método. IloCplex::CallbackI* duplicateCallback() const; //insere um p3 a lista de p3s nao adicionados no modelo e que devem ser checados pelos LazyCallbacks. Lista é compatilhada por todos os callbacks. Por //isso, é acessada de forma mutuamente exclusiva void static addLazyP3(int i, int j, int l, int n); //no método main do callback está o código que será executado pelo cplex. void main(); static double getP3SeparatingTime(); static double getP3RootSeparatingTime(); static int getNAddedP3(); static int getNAddedP3Root(); static int getNCalls(); static int getNCallsAtRoot(); private: //quando da construcao do objeto desta classe, x é usado para colocar todas as variaveis no vetor x_vars. IloArray<IloBoolVarArray> x; //x_vars contem as variaveis x. Com esse vetor, peço todos os valores das variaveis x de uma vez só para o CPLEX. Isso é muito mais rápido que pedir cada valor //de uma vez. IloNumVarArray x_vars; IloBoolVarArray y; IloNumVarArray y_vars; int k; //quando o callback é usado no hibrido, nao ha variaveis y. Esse flag diz se o lazy deve considerar ou nao variaveis y. bool use_y; static int n_calls; //numero de vezes que o lazyCallback foi executado em toda a arvore static int n_calls_root; static double p3_root_separating_time; static double p3_separating_time; static int n_added_p3; static int n_added_p3_root; //lista estatica que contem os p3s que ainda nao foram adicionados ao modelo. Todos os p3s sao adicionados de forma global. Por isso, //uma lista é suficiente. Ele deve ser acessada de forma exclusiva pelas threads. Isso é feito com o mutex definido abaixo. static list<t_p3> notAddedP3; static std::mutex lazyMutex; bool isIntegerFeasible(); void incNCalls(); void incNCallsAtRoot(); void addToP3SeparatingTime(double); void addToP3RootSeparatingTime(double); static void addToNAddedP3(int n); static void addToNAddedP3Root(int n); //separa P3 atraves de força bruta: enumera todas as inequacoes. Isso leva tempo O(n^3). //O parametro allInequalities diz se todas as violacoes serao retornadas. Se for false, apenas uma inequacao por aresta violada é retornada std::vector<IloConstraint>* separateP3(int max_p3_edge = -1); }; #endif
01d3f5e0b8962e17138036d44c6a08c5061718ad
bc7bed87f9f71bfd64c3bf8544f67c5c11441af4
/CPP04/ex00/Sorcerer.cpp
6e0b472f4cc392ca6b5572450288dcdc0245a769
[]
no_license
InigoRomero/CPP-Modules
fb294834a5f207af16369f09c984368170efb1c9
d356f7781c17abd0b758113238687cab9517f243
refs/heads/main
2023-02-04T19:11:40.435583
2020-12-13T17:37:39
2020-12-13T17:37:39
318,598,072
1
0
null
null
null
null
UTF-8
C++
false
false
1,222
cpp
Sorcerer.cpp
#include "Sorcerer.hpp" Sorcerer::Sorcerer() : _name(""), _title("") {} Sorcerer::Sorcerer(std::string name, std::string title) : _name(name), _title(title) { std::cout << name << ", " << title << ", is born!" << std::endl; } Sorcerer::Sorcerer(const Sorcerer& copy) { *this = copy; } Sorcerer::~Sorcerer() { std::cout << this->_name << ", " << this->_title << ", is dead. Consequences will never be the same!" << std::endl; } Sorcerer &Sorcerer::operator=(const Sorcerer& op) { if (this == &op) return (*this); this->_name = op._name; this->_title = op._title; return (*this); } void Sorcerer::polymorph(Victim const & victim) { victim.getPolymorphed(); } std::ostream &operator<<(std::ostream & out, const Sorcerer & sorcerer) { out << "I am " << sorcerer.getName() << ", " << sorcerer.getTitle() << ", and I like ponies!" << std::endl; return (out); } // Getter - Setter std::string Sorcerer::getName() const {return (this->_name);} std::string Sorcerer::getTitle() const {return (this->_title);} void Sorcerer::setName(std::string name) { this->_name = name; } void Sorcerer::setTitle(std::string title) { this->_title = title; }
eafeb59d503172f4f76168c862677f618803f000
6b265b404d74b09e1b1e3710e8ea872cd50f4263
/CPlusPlus/Algorithms/permutations.cpp
3442151572799a3ab125b8054528cf58f13f3325
[ "CC-BY-4.0" ]
permissive
gjbex/training-material
cdc189469ae2c7d43784ecdcb4bcca10ecbc21ae
e748466a2af9f3388a8b0ed091aa061dbfc752d6
refs/heads/master
2023-08-17T11:02:27.322865
2023-04-27T14:42:55
2023-04-27T14:42:55
18,587,808
130
60
CC-BY-4.0
2023-08-03T07:07:25
2014-04-09T06:35:58
Jupyter Notebook
UTF-8
C++
false
false
356
cpp
permutations.cpp
#include <algorithm> #include <iostream> #include <vector> int main() { std::vector<std::string> v = {{"a", "b", "c", "d"}}; int i {0}; do { std::cout << ++i << ": "; for (auto str: v) std::cout << str << " "; std::cout << std::endl; } while (std::next_permutation(v.begin(), v.end())); return 0; }
b1a6525820ab68ceb14607d50c6a7d979b7d1f31
93320ab0e4174142eb7e07956dea7e90e601e457
/练习/ID1045/ID1045.cpp
68932b26b3efc2393441235f69d99eb76e64875e
[]
no_license
xianzheTM/Test_Cpp
c302f6f2e6d276ee4b6985dc80d385c8cea8aa0d
ab9368c5f022c59e2111c934e35252c3d2d3c496
refs/heads/master
2021-04-06T07:10:44.958263
2019-06-17T07:49:40
2019-06-17T07:49:40
124,899,813
0
0
null
null
null
null
UTF-8
C++
false
false
270
cpp
ID1045.cpp
//http://222.22.91.42/view/practice/display.aspx?qid=1045#flag ID1045 一般 #include <iostream> using namespace std; int main() { int n, sum=0; cin >> n; for (int j=2;j<n;j++) { if (n%j==0) { sum = sum + j; } } cout << sum; system("pause"); return 0; }
b404fa9c51a07f636f34786b4aa6c1fde50cd145
492976adfdf031252c85de91a185bfd625738a0c
/src/Game/AI/Action/actionWaterExplode.cpp
3d4300eb611575ca4ea7ec53b700ed1f0b45f2bb
[]
no_license
zeldaret/botw
50ccb72c6d3969c0b067168f6f9124665a7f7590
fd527f92164b8efdb746cffcf23c4f033fbffa76
refs/heads/master
2023-07-21T13:12:24.107437
2023-07-01T20:29:40
2023-07-01T20:29:40
288,736,599
1,350
117
null
2023-09-03T14:45:38
2020-08-19T13:16:30
C++
UTF-8
C++
false
false
694
cpp
actionWaterExplode.cpp
#include "Game/AI/Action/actionWaterExplode.h" namespace uking::action { WaterExplode::WaterExplode(const InitArg& arg) : ksys::act::ai::Action(arg) {} WaterExplode::~WaterExplode() = default; bool WaterExplode::init_(sead::Heap* heap) { return ksys::act::ai::Action::init_(heap); } void WaterExplode::enter_(ksys::act::ai::InlineParamPack* params) { ksys::act::ai::Action::enter_(params); } void WaterExplode::leave_() { ksys::act::ai::Action::leave_(); } void WaterExplode::loadParams_() { getStaticParam(&mRadius_s, "Radius"); getStaticParam(&mSpeed_s, "Speed"); } void WaterExplode::calc_() { ksys::act::ai::Action::calc_(); } } // namespace uking::action
dbd5f70cc7f8494caab778336952fb0d212763ba
064abbecba64dce378ad4e1990178843007c923e
/Framework/Source/Entity/ComponentStateManager.h
2426020253476ce273ce3eb61d79b9881ac5a22d
[]
no_license
NEEC-KAMATA-D3Software/2017Summer_Gr9_UtaWima
ff14c7399b1ccf3511ef73077d171235d0050706
82707cbe50f04d07e14f9524f78107298868c830
refs/heads/master
2021-03-27T15:08:25.583959
2017-07-30T11:21:29
2017-07-30T11:21:29
98,611,581
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
1,051
h
ComponentStateManager.h
#pragma once #include<unordered_map> #include<Source\Component\Component.h> #include<memory> /** * @file ComponentStateManager.h * @brief コンポーネントの状態を記憶するクラス * @authro 高須優輝 * @date 2017/02/23 */ namespace framework { enum class ComponentState { deActive = 0, active = 1, notFind, }; class ComponentStateManager { public: ComponentStateManager(); ~ComponentStateManager(); /** * @brief 状態を保持させるコンポーネント登録 * @param component 状態を保持させるコンポーネントの弱参照 */ void registComponent(std::weak_ptr<Component> component); /** * @brief 状態を保持させたコンポーネント破棄と状態取得 * @param component 状態を保持させたコンポーネントの弱参照 * @return 状態 */ ComponentState popComponentState(std::weak_ptr<Component> component); void clear(); private: //コンポーネント状態キュー std::unordered_map<Component*,bool> m_ComponentMemory; }; }
537526c96a4fddcf31d66a191da0911bddc83653
192fd5f3d735289a4f6ab6428195af1dc66389fa
/CSymbolengineOpenPPLBoard.cpp
e54f933b502f65be3ef8629d65e767473753bf4a
[]
no_license
evcoin/OpenHoldem
4ef8c51cd67e6e10c3c912e385665c6b049ca035
97622fa4db958337b072d03d16e1ff0eff2b5cbd
refs/heads/master
2021-01-23T00:01:48.472372
2015-02-02T11:24:11
2015-02-02T11:24:11
29,695,581
0
0
null
null
null
null
UTF-8
C++
false
false
5,624
cpp
CSymbolengineOpenPPLBoard.cpp
//***************************************************************************** // // This file is part of the OpenHoldem project // Download page: http://code.google.com/p/openholdembot/ // Forums: http://www.maxinmontreal.com/forums/index.php // Licensed under GPL v3: http://www.gnu.org/licenses/gpl.html // //***************************************************************************** // // Purpose: // //***************************************************************************** #include "stdafx.h" #include "CSymbolEngineOpenPPLBoard.h" #include "CPreferences.h" #include "CScraper.h" #include "CScraperAccess.h" #include "CStringMatch.h" #include "CSymbolEnginePokerval.h" #include "MagicNumbers.h" #include "NumericalFunctions.h" /* ##f$OpenPPL_RankOfFirstHoleCard## ##f$OpenPPL_RankOfSecondHoleCard## ##f$OpenPPL_FirstFlopCard## ##f$OpenPPL_SecondFlopCard## ##f$OpenPPL_ThirdFlopCard## ##f$OpenPPL_TurnCard## ##f$OpenPPL_RiverCard## ##f$OpenPPL_2ndBestBoardCard## ##f$OpenPPL_AcePresentOnFlop## ##f$OpenPPL_AcePresentOnTurn## ##f$OpenPPL_BestBoardCard## ##f$OpenPPL_DoubleGutShotOnBoard## ##f$OpenPPL_ExactlyOneStraightPossibleOnFlop## ##f$OpenPPL_FlopCardPairedonTurn## ##f$OpenPPL_FlushPossible## ##f$OpenPPL_FlushOnBoard## ##f$OpenPPL_FlushPossibleOnFlop## ##f$OpenPPL_FlushPossibleOnTurn## ##f$OpenPPL_FourCardsToWheelOnBoard## ##f$OpenPPL_FourOf1SuiteOnTurn## ##f$OpenPPL_FullHouseOnBoard## ##f$OpenPPL_HighestRankOnFlop## ##f$OpenPPL_KingPresentOnFlop## ##f$OpenPPL_LowCardsOnBoard## ##f$OpenPPL_MoreThanOneStraightPossibleOnFlop## ##f$OpenPPL_MoreThanOneStraightPossibleOnRiver## ##f$OpenPPL_RankBitsCommonRiver## ##f$OpenPPL_NumberOfStraightsPossibleOnTurn## ##f$OpenPPL_NumberOfStraightsPossibleOnRiver## ##f$OpenPPL_MoreThanOneOneCardStraightPossible## ##f$OpenPPL_MoreThanOneStraightPossibleOnTurn## ##f$OpenPPL_NumberOfOneCardStraightsPossibleOnTurn## ##f$OpenPPL_OneCardFlushPossible## ##f$OpenPPL_OneCardStraightFlushPossible## ##f$OpenPPL_StraightFlushOnBoard## ##f$OpenPPL_OneCardStraightPossible## ##f$OpenPPL_OneCardStraightPossibleOnTurn_AceHigh## ##f$OpenPPL_OneCardStraightPossibleOnTurn_KingHigh## ##f$OpenPPL_OneCardStraightPossibleOnTurn_QueenHigh## ##f$OpenPPL_OneCardStraightPossibleOnTurn_JackHigh## ##f$OpenPPL_OneCardStraightPossibleOnTurn_TenHigh## ##f$OpenPPL_OneCardStraightPossibleOnTurn_NineHigh## ##f$OpenPPL_OneCardStraightPossibleOnTurn_EightHigh## ##f$OpenPPL_OneCardStraightPossibleOnTurn_SevenHigh## ##f$OpenPPL_OneCardStraightPossibleOnTurn_SixHigh## ##f$OpenPPL_OneCardStraightPossibleOnTurn_FiveHigh## ##f$OpenPPL_OneCardStraightPossibleOnTurn## ##f$OpenPPL_Only1OneCardStraightPossible## ##f$OpenPPL_OpenEndedStraightDrawOnBoard## ##f$OpenPPL_OpenEndedStraightDrawPossibleOnFlop## ##f$OpenPPL_IndividualOverCardsOnBoard## ##f$OpenPPL_OvercardsOnBoard## ##f$OpenPPL_PairOnBoard## ##f$OpenPPL_PairOnFlop## ##f$OpenPPL_LowestFlopCard## ##f$OpenPPL_LowestFlopCardPairedOnTurn## ##f$OpenPPL_OnlyOneStraightPossible## ##f$OpenPPL_PairOnTurn## ##f$OpenPPL_QuadsOnBoard## ##f$OpenPPL_QueenPresentOnFlop## ##f$OpenPPL_RankBitsCommonLowCardsOnly## ##f$OpenPPL_RiverCardisOvercardToBoard## ##f$OpenPPL_2ndTopFlopCard## ##f$OpenPPL_2ndTopFlopCard_UnpairedFlop## ##f$OpenPPL_2ndTopFlopCard_PairOnFlop## ##f$OpenPPL_SecondTopFlopCardPairedOnRiver## ##f$OpenPPL_SecondTopFlopCardPairedOnTurn## ##f$OpenPPL_2ndTopFlopCardPairedOnRiver## ##f$OpenPPL_2ndTopFlopCardPairedOnTurn## ##f$OpenPPL_srankbitshero## ##f$OpenPPL_srankavailable## ##f$OpenPPL_StraightFlushPossibleByOthers## ##f$OpenPPL_SuitsOnBoard## ##f$OpenPPL_SuitsOnFlop## ##f$OpenPPL_SuitsOnRiver## ##f$OpenPPL_SuitsOnTurn## ##f$OpenPPL_StraightFlushPossible## ##f$OpenPPL_StraightOnBoard## ##f$OpenPPL_StraightPossible## ##f$OpenPPL_RankBitsCommOnFlop## ##f$OpenPPL_RankBitsCommonTurn## ##f$OpenPPL_StraightPossibleOnFlop## ##f$OpenPPL_StraightPossibleOnTurn## ##f$OpenPPL_ThreeCardStraightOnBoard## ##f$OpenPPL_TopFlopCard## ##f$OpenPPL_TopFlopCardPairedonRiver## ##f$OpenPPL_TopFlopCardPairedonTurn## ##f$OpenPPL_TripsOnBoard## ##f$OpenPPL_TripsOnBoardOnTurn## ##f$OpenPPL_TurnCardisOvercardToBoard## ##f$OpenPPL_TurnCardPaired## ##f$OpenPPL_TwoOfOneSuitPresentOnFlop## ##f$OpenPPL_TwoPairOnBoard## ##f$OpenPPL_TwoPairOnBoardOnTurn## ##f$OpenPPL_UncoordinatedFlop## ##f$OpenPPL_WheelPossible## */ CSymbolEngineOpenPPLBoard *p_symbol_engine_open_ppl_board = NULL; CSymbolEngineOpenPPLBoard::CSymbolEngineOpenPPLBoard() { // The values of some symbol-engines depend on other engines. // As the engines get later called in the order of initialization // we assure correct ordering by checking if they are initialized. assert(p_symbol_engine_pokerval != NULL); } CSymbolEngineOpenPPLBoard::~CSymbolEngineOpenPPLBoard() {} void CSymbolEngineOpenPPLBoard::InitOnStartup() { ResetOnConnection(); } void CSymbolEngineOpenPPLBoard::ResetOnConnection() {} void CSymbolEngineOpenPPLBoard::ResetOnHandreset() { _wheel_possible = false; } void CSymbolEngineOpenPPLBoard::ResetOnNewRound() {} void CSymbolEngineOpenPPLBoard::ResetOnMyTurn() { _wheel_possible = WheelPossible(); } void CSymbolEngineOpenPPLBoard::ResetOnHeartbeat() {} bool CSymbolEngineOpenPPLBoard::WheelPossible() { const int kRankbits_A2345 = 0x1F; // 0b111110 return (bitcount( p_symbol_engine_pokerval->rankbitscommon() & kRankbits_A2345) >= 3); } bool CSymbolEngineOpenPPLBoard::EvaluateSymbol(const char *name, double *result) { if (memcmp(name, "wheelpossible", 13)==0 && strlen(name)==13) { *result = _wheel_possible; return true; } // Symbol of a different symbol-engine return false; }
a07a2f227c7384d957c74bdbc4c9c37b8d1dad5b
68582f0bfeaeb6f22f19033080e4574bd35015da
/sketch_mar25b/echo/echo.ino
f16936b70f3684cf5f7aeb9e9e0e18ab7cb213e9
[]
no_license
TahzidMahmud/Arduino_collection
53404931fa03c1c7f7c42bc5ca936a4ec5ed5825
85cc971c71725916ceaba743970e6f1456e1b2ee
refs/heads/main
2023-01-19T10:59:00.770602
2020-11-28T10:16:08
2020-11-28T10:16:08
316,705,890
1
0
null
null
null
null
UTF-8
C++
false
false
2,162
ino
echo.ino
const int trigPin = 12; const int echoPin = 13; long duration; int distance; int dist(); int dis1; int dis2; int dis; void stopm(void); void forward(void); void inputs(void); void sharpright(void); void sharprleft(void); void backward(void); void servocon(); void setup() { servo.attach(7); servo.write(0); pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output pinMode(echoPin, INPUT); // Sets the echoPin as an Input digitalWrite(ENA,75); digitalWrite(ENB,75); //pinMode(SENSOROUTPUT, INPUT); Serial.begin(9600); // Starts the serial communication } void loop() { dis==dist(); delay(500); if(dis<=danger){ stopm(); delay(300); backward(); delay(100); //servocon(); sharpleft(); delay(100); forward(); } else{ servo.write(90); forward(); } } int dist(){ // Clears the trigPin digitalWrite(trigPin, LOW); delayMicroseconds(2); // Sets the trigPin on HIGH state for 10 micro seconds digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); // Reads the echoPin, returns the sound wave travel time in microseconds duration = pulseIn(echoPin, HIGH); // Calculating the distance distance= duration*0.034/2; // Prints the distance on the Serial Monitor Serial.print("Distance: "); Serial.println(distance); } void forward(void) { digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW); digitalWrite(IN3, LOW); digitalWrite(IN4, HIGH); } void backward(void){ digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW); digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW); } void sharpright() { digitalWrite(IN1, LOW); digitalWrite(IN2, LOW); digitalWrite(IN3, LOW); digitalWrite(IN4, HIGH); } void sharpleft() { digitalWrite(IN1, LOW); digitalWrite(IN2, HIGH); digitalWrite(IN3, LOW); digitalWrite(IN4, LOW); } void stopm(void) { digitalWrite(IN1, LOW); digitalWrite(IN2, LOW); digitalWrite(IN3, LOW); digitalWrite(IN4, LOW); } void servocon(){ servo.write(14); delay(500); dis1=dist(); servo.write(144); delay(500); dis2=dist(); if(dis1<dis2){ sharpleft(); delay(500); forward(); } else{ sharpright(); delay(500); forward(); } }
be8d691472bc27cfafac1b5c2b1a91c390db5835
4e697961037240ad357a5ddd6a1365f588a4969c
/Helper/MathTools.cpp
84158c3c4b5e2c9e2e421bdff9e8879e2aa00381
[]
no_license
szakeetm/shared_sources
7dc94ba25b5828cf1993f4ea4790e88e8a067ca1
1fba669e8b3c6ba0cd89c1c2084a235dfd02ee74
refs/heads/master
2023-09-05T12:05:45.179173
2023-08-18T13:54:30
2023-08-18T13:54:30
140,718,435
0
0
null
null
null
null
UTF-8
C++
false
false
9,655
cpp
MathTools.cpp
/* Program: MolFlow+ / Synrad+ Description: Monte Carlo simulator for ultra-high vacuum and synchrotron radiation Authors: Jean-Luc PONS / Roberto KERSEVAN / Marton ADY / Pascal BAEHR Copyright: E.S.R.F / CERN Website: https://cern.ch/molflow This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Full license text: https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html */ #include "MathTools.h" #include "Random.h" #include <cstdio> #include <algorithm> //std::Lower_bound #include <iterator> #include <chrono> #include <cstring> //strdup bool IsEqual(const double a, const double b, double toleranceRatio) { return std::abs(a - b) < std::max(1E-99, std::max(std::abs(a),std::abs(b))*toleranceRatio); } size_t IDX(const int i, const size_t nb) { //Return circular index restrained within [0..nb[, allows negative index (Python logics: -1=last) int ret = i%(int)nb; return (ret>=0)?(ret):(ret+nb); } size_t IDX(const size_t i, const size_t nb) { //Return circular index restrained within [0..nb[ return i%nb; } size_t Next(const int i, const size_t nb, const bool inverseDir) { //Returns the next element of a circular index (next of last is first) //inverseDir is a helper: when true, returns the previous return Next((size_t)i,nb,inverseDir); } size_t Next(const size_t i, const size_t nb, const bool inverseDir) { //Returns the next element of a circular index (next of last is first) //inverseDir is a helper: when true, returns the previous if (!inverseDir) { size_t next=i+1; if (next==nb) next = 0; return next; } else return Previous(i,nb,false); } size_t Previous(const size_t i, const size_t nb, const bool inverseDir) { //Returns the previous element of a circular index (previous of first is last) //inverseDir is a helper: when true, returns the next if (!inverseDir) { if (i==0) return nb-1; else return i-1; } else return Next(i,nb,false); } size_t Previous(const int i, const size_t nb, const bool inverseDir) { return Previous((size_t)i,nb,inverseDir); } size_t GetPower2(size_t n) { // Return a power of 2 which is greater or equal than n if((n & (n-1))==0) { // already a power of 2 return n; } else { // Get the power of 2 above int p = 0; while(n!=0) { n = n >> 1; p++; } return (size_t)1 << p; } } double RoundAngle(double a) { // Return a in [-PI,PI] double r=a; while(r<-PI) r+=2.0*PI; while(r> PI) r-=2.0*PI; return r; } char* FormatMemory(size_t size) { return FormatMemoryLL((long long)size); } char* FormatMemoryLL(long long size) { static char ret[256]; const char *suffixStr[] = { "KB", "MB", "GB", "TB", "PB" }; auto dSize = static_cast<double>(size); int suffix = 0; while (dSize >= 1024.0 && suffix < 4) { dSize /= 1024.0; suffix++; } if (suffix == 0) { sprintf(ret, "%u bytes", static_cast<unsigned int>(size)); } else { if (fabs(dSize - floor(dSize)) < 1e-3) sprintf(ret, "%.0f%s", dSize, suffixStr[suffix - 1]); else sprintf(ret, "%.2f%s", dSize, suffixStr[suffix - 1]); } return ret; } double Weigh(const double a, const double b, const double weigh) { return a + (b - a)*weigh; } std::vector<double> InterpolateVectorY(const double x, const std::vector<std::pair<double, std::vector<double>>>& table, const bool logX, const bool logY, const bool allowExtrapolate) { //Same as InterpolateY but returns a vector. //Must repeat most of code because C++ doesn't allow runtime evaluated return-type (and only 'bool first' decides what to return) if (table.size() == 1) return table[0].second; int lowerIndex = lower_index(x, table); int tableSize = static_cast<int>(table.size()); if (lowerIndex == -1) { lowerIndex = 0; if (!allowExtrapolate) return table[lowerIndex].second; //return first element } else if (lowerIndex == (tableSize - 1)) { if (allowExtrapolate) { lowerIndex = tableSize - 2; } else return table[lowerIndex].second; //return last element } double lowerFirst = (logX) ? log10(table[lowerIndex].first) : table[lowerIndex].first; double lowerFirstNext = (logX) ? log10(table[lowerIndex + 1].first) : table[lowerIndex + 1].first; double xValue = (logX) ? log10(x) : x; double delta = lowerFirstNext - lowerFirst; double overshoot = xValue - lowerFirst; size_t distrYsize = table[0].second.size(); std::vector<double> result(distrYsize); for (size_t e = 0; e < distrYsize; e++) { double lowerSecond = (logY) ? log10(table[lowerIndex].second[e]) : table[lowerIndex].second[e]; double lowerSecondNext = (logY) ? log10(table[lowerIndex + 1].second[e]) : table[lowerIndex + 1].second[e]; result[e] = (logY) ? Pow10(Weigh(lowerSecond, lowerSecondNext, overshoot / delta)) : Weigh(lowerSecond, lowerSecondNext, overshoot / delta); } return result; } //An overload of the function above that accepts C-style arrays as data int lower_index(double key, const double* data, size_t array_size) { const double* it = std::lower_bound(data, data + array_size, key); return static_cast<int>(std::distance(data, it))-1; //off by one, see lower_index_universal for explanation } int lower_index(const double key, const std::vector<double>& data) { auto it = std::lower_bound(data.begin(), data.end(), key); return static_cast<int>(std::distance(data.begin(), it)) - 1; } int lower_index(const double key, const std::vector<std::pair<double, double>>& data, const bool first) { auto it = std::lower_bound(data.begin(), data.end(), key, [&](const std::pair<double, double>& pair, double val) { return first ? pair.first < val : pair.second < val; }); return static_cast<int>(std::distance(data.begin(), it))-1; } int weighed_lower_index_X(const double key, const double weigh, double * A, double * B, const size_t size) { //interpolates among two lines of a cumulative distribution //all elements of line 1 and line 2 must be monotonously increasing (except equal consecutive values) //key: lookup value //weigh: between 0 and 1 (0: only first distribution, 1: only second distribution) //A* and B* : pointers to arrays of 'size' number of CDF values. The first value (not included) is assumed to be 0, the last (not included) is assumed to be 1 //return value: lower index. If -1, then key is smaller than first element, if 'size-1', then key is larger than last element if (size == 0) return -1; // Handles the case when size is 1 if (size == 1) { double weighed = Weigh(A[0], B[0], weigh); return (key < weighed) ? -1 : 0; } int left = 0; int right = static_cast<int>(size - 1); int mid; double weighed, nextWeighed; // Binary search while (left <= right) { mid = (left + right) / 2; weighed = Weigh(A[mid], B[mid], weigh); nextWeighed = Weigh(A[mid + 1], B[mid + 1], weigh); if (weighed <= key && key < nextWeighed) { // key found at index mid return mid; } else if (weighed < key) { left = mid + 1; } else { right = mid - 1; } } // Key not found. Check if it is out of the bounds. return (mid == 0) ? -1 : static_cast<int>(size - 1); } double Pow10(const double a) { return pow(10,a); } std::tuple<double, double> CartesianToPolar(const Vector3d& incidentDir, const Vector3d& normU, const Vector3d& normV, const Vector3d& normN) { // Ensure all input vectors are normalized. // Convert Cartesian (x,y,z) coordinates to polar coordinates in the (nU,nV,N) basis. // Note: The facet is parallel to (U,V), and we use its (nU,nV,N) orthonormal basis. // Both (nU,nV,N) and (x,y,z) are left-handed. // Perform basis change from (x,y,z) to (nU,nV,N). // This leverages the fact that (nU,nV,N) is a member of the Special Orthogonal Group (SO(3)). // Calculate the dot product of the incident direction with the orthonormal basis. double uComponent = Dot(incidentDir, normU); double vComponent = Dot(incidentDir, normV); double nComponent = Dot(incidentDir, normN); // Handle any rounding errors that could cause issues with the 'acos' function. Saturate(nComponent, -1.0, 1.0); // Convert from (u,v,n) to polar coordinates (inTheta, inPhi). double inTheta = acos(nComponent); // The angle between the incident direction and the normal vector. Ranges from PI/2 to PI. double inPhi = atan2(vComponent, uComponent); // The angle between the projection of the incident direction in the (U,V) plane and the U axis. Ranges from -PI to PI. return { inTheta, inPhi }; } Vector3d PolarToCartesian(const Vector3d& normU, const Vector3d& normV, const Vector3d& normN, const double theta, const double phi, const bool reverse) { // This function converts polar coordinates to Cartesian coordinates in the (normU,normV,normN) basis. // Note: (normU,normV,normN) and (x,y,z) are both left-handed. // theta is the angle to the normal of the facet normN, phi to normU // Convert from polar coordinates (theta, phi) to Cartesian coordinates (u,v,n). const double u = sin(theta) * cos(phi); const double v = sin(theta) * sin(phi); const double n = cos(theta); // Get the (normU,normV,normN) orthonormal basis of the facet Vector3d U = normU; Vector3d V = normV; Vector3d N = reverse ? -1.0 * normN : normN; // Perform basis change from (normU,normV,normN) to (x,y,z) return u * U + v * V + n * N; }
222bfe1e5634fc88ff4cfcd8cecdee76fc3c91aa
0a3c46807db866cb7f28bedd942d4698f1d988e7
/embedded/stm32_midiplayer/src/player.h
c998b5f83807c2a1cdb477f590dba64a7b43a2da
[]
no_license
gproskurin/learning
86fc33e3936bbfb50dfbcec1888b5274f53cef74
06c4a93492614bf400e81d4d220c57010875205e
refs/heads/master
2023-08-31T10:27:13.468867
2023-08-28T18:01:35
2023-08-28T18:01:35
33,450,249
0
0
null
null
null
null
UTF-8
C++
false
false
1,799
h
player.h
#ifndef _my_player_h_included_ #define _my_player_h_included_ #include "FreeRTOS.h" #include "queue.h" #include "task.h" namespace notes { enum sym_t { C0 = 0, C0s, D0f = C0s, D0, D0s, E0f = D0s, E0, F0, F0s, G0f = F0s, G0, G0s, A0f = G0s, A0, A0s,B0f = A0s, B0, C1, C1s, D1f = C1s, D1, D1s, E1f = D1s, E1, F1, F1s, G1f = F1s, G1, G1s, A1f = G1s, A1, A1s, B1f = A1s, B1, C2, C2s, D2f = C2s, D2, D2s, E2f = D2s, E2, F2, F2s, G2f = F2s, G2, G2s, A2f = G2s, A2, A2s, B2f = A2s, B2, C3, C3s, D3f = C3s, D3, D3s, E3f = D3s, E3, F3, F3s, G3f = F3s, G3, G3s, A3f = G3s, A3, A3s, B3f = A3s, B3, C4, C4s, D4f = C4s, D4, D4s, E4f = D4s, E4, F4, F4s, G4f = F4s, G4, G4s, A4f = G4s, A4, A4s, B4f = A4s, B4, C5, C5s, D5f = C5s, D5, D5s, E5f = D5s, E5, F5, F5s, G5f = F5s, G5, G5s, A5f = G5s, A5, A5s, B5f = A5s, B5, C6, C6s, D6f = C6s, D6, D6s, E6f = D6s, E6, F6, F6s, G6f = F6s, G6, G6s, A6f = G6s, A6, A6s, B6f = A6s, B6, C7, C7s, D7f = C7s, D7, D7s, E7f = D7s, E7, F7, F7s, G7f = F7s, G7, G7s, A7f = G7s, A7, A7s, B7f = A7s, B7, C8, C8s, D8f = C8s, D8, D8s, E8f = D8s, E8, F8, F8s, G8f = F8s, G8, G8s, A8f = G8s, A8, A8s, B8f = A8s, B8 }; static_assert(sym_t::B8 <= 255); enum duration_t { l1 = 64, l2 = 32, l2d = 48, l4 = 16, l8 = 8, l16 = 4 }; enum instrument_t { sq, sin3, sin4, sin5, sin10, sin12 }; } // namespace notes namespace player { QueueHandle_t create_queue(); void create_task(const char* task_name, UBaseType_t prio, QueueHandle_t queue); void enqueue_note(QueueHandle_t, notes::sym_t, notes::duration_t, notes::instrument_t); } #endif
1aca0a3a5acfb85cea98880d182e77ac93b27a82
536a53a689a36a50ac840fe581581f8703936e16
/chessmaster/Queen_rule.cpp
105be4e27beb907b688bbbff7a71bef574c30aed
[]
no_license
torn4/Chess
fac9a696a411b4ed87595a10436d3dff7b85be95
e32de38593a602ad839cf5fcb1001d24a049864d
refs/heads/master
2020-03-28T03:47:55.383614
2018-09-13T09:13:45
2018-09-13T09:13:45
147,672,059
0
0
null
null
null
null
UTF-8
C++
false
false
201
cpp
Queen_rule.cpp
#include "rook_rule.h" #include "bishop_rule.h" #include "Queen_rule.h" #include <iostream> bool queen_rule::queenrule(std::string piece_name, std::map<std::string,int> memory_map,int move) { };
4723ee2b2ad053f86d50bfe97e86b6c9f516150b
b67c43b9f4ea2cd3bfd588b7c1b238e0a6d5f3f6
/RV/SpeechRecognition/voiceCapture.cpp
8d80b10705be78ab7c2dd716c8e19b8db9f0f32e
[]
no_license
ttune/dayz_0-45-124252
64327b4f6026cf48aa70dd64b76ca0797c4ef945
89821d85c45bb327da4f1ac8abee65f5010b178d
refs/heads/master
2018-04-15T07:13:49.289724
2017-05-06T03:55:37
2017-05-06T03:55:37
90,435,280
1
0
null
null
null
null
UTF-8
C++
false
false
4,065
cpp
voiceCapture.cpp
#include <El/elementpch.hpp> #pragma comment(lib,"dsound") #include "voiceCapture.hpp" const DWORD VOICE_SAMPLE_RATE = 16000; const DWORD BYTES_PER_SAMPLE = 2; #define NUM_REC_NOTIFICATIONS 16 VoiceCapture::VoiceCapture() { _notifySize = 0; _bufferSize = 0; _bufferOffset = 0; _capturing = false; // Create IDirectSoundCapture using the preferred capture device HRESULT result = DirectSoundCaptureCreate(NULL, _capture.Init(), NULL); if (FAILED(result)) { _capture.Free(); return; } // Waveform format: WAVEFORMATEX fmt; fmt.wFormatTag = WAVE_FORMAT_PCM; fmt.nChannels = 1; fmt.nSamplesPerSec = VOICE_SAMPLE_RATE; fmt.wBitsPerSample = BYTES_PER_SAMPLE * 8; fmt.nBlockAlign = fmt.nChannels * fmt.wBitsPerSample / 8; fmt.nAvgBytesPerSec = fmt.nBlockAlign * fmt.nSamplesPerSec; fmt.cbSize = 0; // Set the notification size [NOTE: Must be an even multiple of 320 (i.e., an even multiple of a 10ms frame)], // or recognition accuracy might suffer. -drw _notifySize = 4 * 160 * sizeof(short); // 4 frames; 10ms*16kHz=160 samples; one short per sample. _notifySize -= _notifySize % fmt.nBlockAlign; // Set the buffer sizes _bufferSize = _notifySize * NUM_REC_NOTIFICATIONS; // Sound-buffer description: DSCBUFFERDESC desc; memset(&desc, 0, sizeof(desc)); desc.dwSize = sizeof(desc); desc.dwFlags = 0; desc.dwBufferBytes = _bufferSize; desc.lpwfxFormat = &fmt; desc.dwReserved = 0; result = _capture->CreateCaptureBuffer(&desc, _buffer.Init(), NULL); if (FAILED(result)) { _buffer.Free(); _capture.Free(); return; } ComRef<IDirectSoundNotify> notify; result = _buffer->QueryInterface(IID_IDirectSoundNotify, (LPVOID *)notify.Init()); if (FAILED(result)) { _buffer.Free(); _capture.Free(); return; } _notificationEvent = CreateEvent(NULL, FALSE, FALSE, NULL); // Setup the notification positions DSBPOSITIONNOTIFY pos[NUM_REC_NOTIFICATIONS]; for (int i=0; i<NUM_REC_NOTIFICATIONS; i++) { pos[i].dwOffset = _notifySize * i + (_notifySize - 1); pos[i].hEventNotify = _notificationEvent; } // Tell DirectSound when to notify us result = notify->SetNotificationPositions(NUM_REC_NOTIFICATIONS, pos); if (FAILED(result)) { _buffer.Free(); _capture.Free(); return; } } VoiceCapture::~VoiceCapture() { CloseHandle(_notificationEvent); } bool VoiceCapture::GetData(AutoArray<char> &data) { if (WaitForSingleObject(_notificationEvent, 0) != WAIT_OBJECT_0) return false; if (_buffer == NULL) return false; // extract data DWORD readPos; DWORD capturePos; HRESULT result = _buffer->GetCurrentPosition(&readPos, &capturePos); if (FAILED(result)) return false; // calculate data size LONG size = readPos - _bufferOffset; if (size < 0) size += _bufferSize; // block align lock size so that we are always write on a boundary size -= (size % _notifySize); if (size == 0) return false; // lock the capture buffer down VOID *data1 = NULL; DWORD length1; VOID *data2 = NULL; DWORD length2; result = _buffer->Lock(_bufferOffset, size, &data1, &length1, &data2, &length2, 0); if (FAILED(result)) return false; // copy data DWORD length = length1; if (data2) length += length2; data.Realloc(length); data.Resize(length); memcpy(data.Data(), data1, length1); if (data2) memcpy(data.Data() + length1, data2, length2); _bufferOffset += length; _bufferOffset %= _bufferSize; // Circular buffer // unlock the capture buffer _buffer->Unlock(data1, length1, data2, length2); return true; } void VoiceCapture::Start() { if (_buffer && !_capturing) { HRESULT result = _buffer->Start(DSCBSTART_LOOPING); if (SUCCEEDED(result)) { _capturing = true; LogF("Voice capturing started."); } } } void VoiceCapture::Stop() { if (_buffer) { if (_capturing) { _buffer->Stop(); _capturing = false; LogF("Voice capturing stopped."); } } else _capturing = false; }
b47e75e7987708765c8e7ec00e24abd2afc13355
e12264c9052df7d548300af5879e74939aaf834e
/db_gen/run_db_gen.cpp
d80efcf886be115c3a3fa06b1ddcbe888d774c7c
[]
no_license
jevgienij/sim_map
df0c85c5f731f546c18b5ae3901bd115187f7e27
1cffc0e002394c88ced4b3b75abe0381fa8f62a3
refs/heads/master
2021-01-23T21:38:40.636460
2014-03-11T18:28:25
2014-03-11T18:28:25
null
0
0
null
null
null
null
UTF-8
C++
false
false
306
cpp
run_db_gen.cpp
#include <db_gen.h> using namespace std; int main(int argc, char** argv) { if (argc != 2) { cout << " Usage: db_gen dirPath" << endl; return -1; } // 1st argument - path to the dir containing all the tiles auto vecImageDatabase = generateDB(argv[1]); return 0; }
b19670bc4915cdb8ab434eb7835ea326856fe9cb
794ec36417d1f5fe9f8a8dfefee17169ba346447
/ACM-ICPC-Contests/2018CCPC网络赛/HDU6438.cpp
d4e03c09feb682e0b17e6a506eb10ce5e09cb7ee
[]
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
937
cpp
HDU6438.cpp
#include <bits/stdc++.h> using namespace std; #define mem(a, b) memset(a, b, sizeof(a)) typedef long long ll; const ll N = 1e5 + 40; priority_queue<ll, vector<ll>, greater<ll>> q; unordered_map<ll, ll> mp; void solve() { while (!q.empty()) q.pop(); mp.clear(); ll n, x, ans = 0, cnt = 0; scanf("%lld", &n); for (ll i = 1; i <= n; i++) { scanf("%lld", &x); if (q.empty() || x <= q.top()) { q.push(x); } else { ans += x - q.top(); cnt++; if (mp[q.top()] != 0) { cnt--; mp[q.top()]--; } q.pop(); q.push(x), q.push(x); mp[x]++; } } printf("%lld %lld\n", ans, cnt * 2); } int main() { // freopen("in.txt", "r", stdin); ll t; scanf("%lld", &t); while (t--) solve(); return 0; }
e34bbdd7505b1fcfa8bba263f031a150ca46c5cd
920b640a434592cce0e3dd9f15df4aab84c6c6d7
/src/StringUtil.cc
b01c16d72c1cd3511b8347d2243f345d192d3c9d
[]
no_license
gaoxinbo/logger
7b0c9f00968f2001f19436d762b0fef914ab3c81
d912cd1e9c30f2ca6831417a7bce7512641c2a02
refs/heads/master
2021-01-19T19:35:35.808477
2014-06-10T13:35:38
2014-06-10T13:35:38
2,609,856
0
0
null
null
null
null
UTF-8
C++
false
false
762
cc
StringUtil.cc
// Copyright 2014, Xinbo Gao. All rights reserved. // Author: Xinbo Gao gaoxinbo1984@gmail.com #include "StringUtil.h" using namespace std; namespace logger { StringUtil::StringUtil() { } StringUtil::~StringUtil() { } string StringUtil::trim(const string &s){ string::size_type first,last; first = last = 0; first = s.find_first_not_of(" "); last = s.find_last_not_of(" "); if(first == string::npos || last == string::npos) return ""; return s.substr(first,last-first+1); } bool StringUtil::split(const string &s, string &key, string &value){ string::size_type pos = 0; pos=s.find_first_of("="); if(pos==string::npos) return false; key = s.substr(0,pos); value = s.substr(pos+1); return true; } } // namespace logger
ab2d1fecbcf224ecf5b927cd577d6350d6153a2a
eb8edc04a84653cc1623b3c2da685506a5bd7c5b
/MuxerPcm/src/MuxerPcm/MuxerPcm.h
f71782b4f5c000b63aa6740f38e6fffbd518f8b9
[]
no_license
cugxchen/MuxerAudio
989d78e678c36282d7fe11854df17541964753a5
3e0e26471aa5bfd572b502dc8ec34e4e2980df68
refs/heads/master
2020-03-17T23:17:53.994683
2018-05-19T07:58:30
2018-05-19T07:58:30
134,038,815
0
1
null
null
null
null
GB18030
C++
false
false
1,202
h
MuxerPcm.h
// // Created by 909845 on 2018/5/19. // #ifndef MUXERPCM_MUXERPCM_H #define MUXERPCM_MUXERPCM_H #include <cstdio> #include "../Public/Type.h" using namespace std; class MuxerPcm { public: MuxerPcm(); virtual ~MuxerPcm(); public: void Muxer(); private: /* * 限制幅值到 16位有符号数 */ Int16 LimAmp(Int32 nSum); /* * 直接叠加法 */ Int32 Sum(Int16 nSrc1, Int16 nSrc2, Int16 nSrc3, Int16 nSrc4); /* * 加权平均法 */ Int32 AAW(Int16 nSrc1, Int16 nSrc2, Int16 nSrc3, Int16 nSrc4); /* * 自对齐权重法 (参考文献 <<多媒体会议中的快速实时自适应混音方案研究>> 樊星、顾伟康、叶秀清, 2005 软件学报) * * 公式:y = (sgn(a)*a^2 + sgn(b)*b^2 + sgn(c)*c^2 )/(abs(a) + abs(b) + ads(c)) * 其中 sgn(a)表示数字a的符号,abs(a)表示a的绝对值 */ Int32 ASW(Int16 nSrc1, Int16 nSrc2, Int16 nSrc3, Int16 nSrc4); private: FILE* pF1 = nullptr; FILE* pF2 = nullptr; FILE* pF3 = nullptr; FILE* pF4 = nullptr; FILE* pMux = nullptr; }; #endif //MUXERPCM_MUXERPCM_H
581d9c017a9139a9028cf4b8858cbf7f498f72d6
5d83739af703fb400857cecc69aadaf02e07f8d1
/Archive/f47668cc0c7e3c7614903f1f2421d131-16ccd8065d089fe1982fc39c3a92e82f/main.cpp
6f31032efda44380eae72a2646469fdd3931e15b
[]
no_license
WhiZTiM/coliru
3a6c4c0bdac566d1aa1c21818118ba70479b0f40
2c72c048846c082f943e6c7f9fa8d94aee76979f
refs/heads/master
2021-01-01T05:10:33.812560
2015-08-24T19:09:22
2015-08-24T19:09:22
56,789,706
3
0
null
null
null
null
UTF-8
C++
false
false
315
cpp
main.cpp
#include <iostream> struct Number { int n; Number(int a):n(a){} Number operator++(int i)& { ++n; return *this; } Number operator++(int i)&& { ++n; return std::move(*this); } }; int main() { Number x(5); x++; x++++++++++; std::cout << x.n; }
981fd55256fdf42bff59826283894337d05876df
9b96faaf9d97aa5a3d63a4370f331eafb929b0c1
/Prac4OpenCLMatrix/MatrixOperations.cpp
76499af7558af8622a0c43c8d33e3a4c3a5678dd
[]
no_license
ZalkinV/MTP.Labs
aef87aa674a33b93e65964dcf872e2bb1b76d448
73f13acadb786218be7242a7088befcaa4d881ed
refs/heads/main
2023-08-01T08:06:07.129105
2021-09-18T14:43:49
2021-09-18T14:43:49
345,351,085
0
0
null
null
null
null
UTF-8
C++
false
false
1,741
cpp
MatrixOperations.cpp
#include "MatrixOperations.h" #include <stdio.h> int** multiply(int** matrixA, int** matrixB, int rowsCount, int colsCount, int elsCount) { int** matrixRes = new int* [rowsCount]; for (int iRow = 0; iRow < rowsCount; iRow++) matrixRes[iRow] = new int[colsCount]; for (int iRow = 0; iRow < rowsCount; iRow++) { for (int iCol = 0; iCol < colsCount; iCol++) { int elSum = 0; for (int iEl = 0; iEl < elsCount; iEl++) { int elMul = matrixA[iRow][iEl] * matrixB[iEl][iCol]; elSum += elMul; } matrixRes[iRow][iCol] = elSum; } } return matrixRes; } int* multiply(int* matrixA, int* matrixB, int rowsCount, int colsCount, int elsCount) { int* matrixRes = new int[rowsCount * colsCount]; for (int iRow = 0; iRow < rowsCount; iRow++) { for (int iCol = 0; iCol < colsCount; iCol++) { int elSum = 0; for (int iEl = 0; iEl < elsCount; iEl++) { int indexA = iRow * elsCount + iEl; int indexB = iEl * colsCount + iCol; int elMul = matrixA[indexA] * matrixB[indexB]; elSum += elMul; } int indexRes = iRow * colsCount + iCol; matrixRes[indexRes] = elSum; } } return matrixRes; } int* convertTo1D(int** matrix, int rowsCount, int colsCount) { int* matrix1D = new int[rowsCount * colsCount]; for (int iRow = 0; iRow < rowsCount; iRow++) { for (int iCol = 0; iCol < colsCount; iCol++) { int index1D = iRow * colsCount + iCol; matrix1D[index1D] = matrix[iRow][iCol]; } } return matrix1D; } void printMatrix(int* matrix, int rowsCount, int colsCount) { for (int iRow = 0; iRow < rowsCount; iRow++) { for (int iCol = 0; iCol < colsCount; iCol++) { int indexC = iRow * colsCount + iCol; printf("%i ", matrix[indexC]); } printf("\n"); } }
3c52ee3a38f46dfbf2429894e0516ff48264fb6c
8d8b618bed48595e2475cfef3ddc502810024026
/Stack/Special_Stack.cpp
7a95f39250eb2423adabc6d9aadd5dba45440087
[ "MIT" ]
permissive
AABHINAAV/InterviewPrep
acef002b69be61ca1ff0858559f1b4bd24ce2203
22a7574206ddc63eba89517f7b68a3d2f4d467f5
refs/heads/master
2022-01-09T20:06:41.828170
2019-05-21T09:33:52
2019-05-21T09:33:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,266
cpp
Special_Stack.cpp
//Special stack ADT with added features like: //getMiddle():returns middle element //deleteMiddle():as the name suggests //All these in O(1) /* see count of elements .If the count becomes odd then move the middle pointer otherwise on pop if the count becomes even then move the middle backwards */ #include<iostream> using namespace std; struct Node{ int data; Node* next; Node* prev; }; class SpecialStack{ public: Node* head; Node* middle; int c; SpecialStack(){ head = middle = NULL; c = 0; } Node* createNode(int); void push(int data); void pop(); int getMiddle(); void deleteMiddle(); void disp(); }; void SpecialStack::disp(){ Node* t = head; while(t){ cout<<t->data<<" " ; t = t->next; } cout<<endl; } Node* SpecialStack::createNode(int data){ Node* node = new Node; node->next = node->prev = NULL; node->data = data; return node; } //insertion is done at the begining ,so the middle element gets //one step farther than it should so we move the middle ptr //backwards if the size becomes even void SpecialStack::push(int data){ Node* node = createNode(data); if(head == NULL){ head = node; c = 1; middle = head; } else{ node->next = head; head->prev = node; ++c; head = node; //move the middle pointer only when the total count gets even if(c % 2 == 0){ middle = middle->prev; } } } void SpecialStack::pop(){ if(head == NULL){ cout<<"Underflow\n"; return; } else{ Node* t = head; head = head->next; head->prev = NULL; --c; delete t; //update middle only when the count gets even if(c%2 == 0){ middle = middle->next; } } } void SpecialStack::deleteMiddle(){ if(c == 1){ Node *t = head; head = middle = NULL; delete t; } else if(c>1){ Node* t = middle; if(middle->prev){ middle->prev->next = middle->next; } middle->next->prev = middle->prev; middle = middle->next; delete t; } } int SpecialStack::getMiddle(){ return middle?middle->data:NULL; } main(){ SpecialStack s; s.push(1); s.push(2); s.push(3); s.push(4); s.push(5); s.push(6); s.disp(); cout<<s.getMiddle()<<endl; s.deleteMiddle(); s.disp(); cout<<s.getMiddle()<<endl; s.disp(); s.pop(); s.disp(); cout<<s.getMiddle()<<endl; s.disp(); //s.disp(); }
805605b87535908606b83e3840767cff544a9274
d7d17131a5e7bf990599e29751ab038c957ceb75
/loan.cpp
567ffa56d9305ac83fffa66e63a30f75dececc74
[]
no_license
ksmail13/Algorithm
a3b76c651b125e4bd69353673b92e3edf04fec90
1a9970b0cd4395a4e29c042f49ed6af7e89c51d3
refs/heads/master
2021-01-16T00:28:30.366247
2018-09-04T17:24:25
2018-09-04T17:24:25
21,740,346
0
0
null
null
null
null
UTF-8
C++
false
false
1,017
cpp
loan.cpp
#include <iostream> #include <cstdio> using namespace std; double balance(double n, double m, double p, double c) { double temp = n; //printf("n %lf m %lf p %lf c %lf\n", temp, m, p, c); for(int i=0;i<m;i++) { temp *= (1+p/1200.0); temp -= c; } //printf("result %lf\n", temp); return temp; } double find(double n, double m, double p) { double low = n/m, high = n*(1+p/1200.0), mid; double res = 0.0; for(int i=0;i<=101;i++) { mid = (low+high)/2.0; res = balance(n, m, p, mid); if(res > 0) { low = mid; } else if(res<0){ high = mid; } else { return mid; } //printf("curr mid:%lf res:%lf\n", mid, res); } return mid; } int main() { int tcase; cin >> tcase; while(tcase--) { double n, m, p; cin >> n >> m >> p; printf("%lf\n", find(n,m,p)); //cout << find(n, m, p) << endl; } return 0; }
24703f5d747310b85cd8b96b2f17a5bba72c2780
a4ace471f3a34bfe7bd9aa57470aaa6e131012a9
/LintCode/1479_Can-Reach-The-Endpoint/1479_Can-Reach-The-Endpoint_V3.cpp
4a9a7b129b5d9c6bb05f6b37fe2403e182c1b50c
[]
no_license
luqian2017/Algorithm
52beca787056e8418f74d383f4ea697f5f8934b7
17f281fb1400f165b4c5f8bdd3e0500f6c765b45
refs/heads/master
2023-08-17T05:37:14.886220
2023-08-08T06:10:28
2023-08-08T06:10:28
143,100,735
1
3
null
2020-10-19T07:05:21
2018-08-01T03:45:48
C++
UTF-8
C++
false
false
529
cpp
1479_Can-Reach-The-Endpoint_V3.cpp
class Solution { public: /** * @param map: the map * @return: can you reach the endpoint */ bool reachEndpoint(vector<vector<int>> &grid) { return helper(grid, 0, 0); } private: bool helper(vector<vector<int>> &grid, int x, int y) { if ((x == grid.size()) || (y == grid[0].size())) return false; if (grid[x][y] == 9) return true; if (grid[x][y] == 0) return false; return helper(grid, x + 1, y) || helper(grid, x, y + 1); } };
98089864b517a48aa404df216431b487d6c01375
1a8e271b380222eb0f56424eaf8407c21cd0e2cc
/easy/linked_list/21_Merge_Two_Sorted_Lists.cpp
c72cc0e138dd5918a2aba3fac74b263c3ab0bd8a
[]
no_license
Ruoyiran/LeetCodeSolution
ea32645f818e21aa83f2ecd2cef63fffe95551b9
d374950d039e92ef8b2abab20626fd8d22e271be
refs/heads/master
2022-06-10T10:04:58.569158
2020-05-07T07:36:22
2020-05-07T07:36:22
258,119,025
0
0
null
null
null
null
UTF-8
C++
false
false
1,582
cpp
21_Merge_Two_Sorted_Lists.cpp
// // Created by ranpeng on 2020/4/12. // #include "common.h" // 将已排好序的两个链表连接到一起,返回连接的链表。 class Solution { public: ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) { if (l1 == NULL) { return l2; } if (l2 == NULL) { return l1; } ListNode* dummyNode = new ListNode(0); ListNode* pHead = dummyNode; while (l1 != NULL && l2 != NULL) { if (l1->val < l2->val) { pHead->next = new ListNode(l1->val); pHead = pHead->next; l1 = l1->next; } else if (l1->val > l2->val) { pHead->next = new ListNode(l2->val); pHead = pHead->next; l2 = l2->next; } else { pHead->next = new ListNode(l1->val); pHead->next->next = new ListNode(l2->val); pHead = pHead->next->next; l1 = l1->next; l2 = l2->next; } } if (l1 != NULL) { pHead->next = l1; } if (l2 != NULL) { pHead->next = l2; } pHead = dummyNode->next; delete dummyNode; return pHead; } }; int main() { ListNode *l1 = buildList({1, 2, 4, 9, 100}); ListNode *l2 = buildList({1, 3, 4, 8, 91}); Solution solution; ListNode* l3 = solution.mergeTwoLists(l1, l2); printList(l1); printList(l2); printList(l3); destroyList(l1); destroyList(l2); destroyList(l3); }
1502e6efa14b762c8b22e0caa72830db283569e1
c043c8e5b58dea9ccc9e1be27b2b561c4de98e3e
/planning/scenario_planning/lane_driving/behavior_planning/turn_signal_decider/src/turn_signal_decider_core.cpp
3153448fff0b7518a951b4ef7754cd35a3fab366
[ "Apache-2.0" ]
permissive
nisailhan/AutowareArchitectureProposal.iv
f726ee44ae92797f46934cbe302d81846f18cb09
7333a054008968b026771c62d24a940e06869467
refs/heads/main
2023-08-14T04:17:48.720996
2021-09-14T08:14:32
2021-09-14T08:14:32
406,666,056
1
0
Apache-2.0
2021-09-15T08:00:41
2021-09-15T08:00:41
null
UTF-8
C++
false
false
9,961
cpp
turn_signal_decider_core.cpp
// Copyright 2020 Tier IV, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include <limits> #include <memory> #include <string> #include <utility> #include "turn_signal_decider/turn_signal_decider.hpp" using autoware_planning_msgs::msg::PathWithLaneId; using autoware_vehicle_msgs::msg::TurnSignal; using namespace std::placeholders; namespace { double getDistance3d(const geometry_msgs::msg::Point & p1, const geometry_msgs::msg::Point & p2) { return std::sqrt(std::pow(p1.x - p2.x, 2) + std::pow(p1.y - p2.y, 2) + std::pow(p1.z - p2.z, 2)); } } // namespace namespace turn_signal_decider { TurnSignalDecider::TurnSignalDecider(const rclcpp::NodeOptions & node_options) : rclcpp::Node("turn_signal_decider", node_options), data_(this) { // setup data manager constexpr double vehicle_pose_update_period = 0.1; auto vehicle_pose_timer_callback = std::bind(&DataManager::onVehiclePoseUpdate, &data_); auto vehicle_pose_timer_period = std::chrono::duration_cast<std::chrono::nanoseconds>( std::chrono::duration<double>(vehicle_pose_update_period)); vehicle_pose_timer_ = std::make_shared<rclcpp::GenericTimer<decltype(vehicle_pose_timer_callback)>>( this->get_clock(), vehicle_pose_timer_period, std::move(vehicle_pose_timer_callback), this->get_node_base_interface()->get_context()); this->get_node_timers_interface()->add_timer(vehicle_pose_timer_, nullptr); path_subscription_ = this->create_subscription<autoware_planning_msgs::msg::PathWithLaneId>( "input/path_with_lane_id", rclcpp::QoS{1}, std::bind(&DataManager::onPathWithLaneId, &data_, _1)); map_subscription_ = this->create_subscription<autoware_lanelet2_msgs::msg::MapBin>( "input/vector_map", rclcpp::QoS{1}.transient_local(), std::bind(&DataManager::onLaneletMap, &data_, _1)); // get ROS parameters parameters_.lane_change_search_distance = this->declare_parameter("lane_change_search_distance", static_cast<double>(30)); parameters_.intersection_search_distance = this->declare_parameter("intersection_search_distance", static_cast<double>(30)); const auto vehicle_info = vehicle_info_util::VehicleInfoUtil(*this).getVehicleInfo(); parameters_.base_link2front = vehicle_info.wheel_base_m + vehicle_info.front_overhang_m; // set publishers turn_signal_publisher_ = this->create_publisher<TurnSignal>("output/turn_signal_cmd", rclcpp::QoS{1}); constexpr double turn_signal_update_period = 0.1; auto turn_signal_timer_callback = std::bind(&TurnSignalDecider::onTurnSignalTimer, this); auto turn_signal_timer_period = std::chrono::duration_cast<std::chrono::nanoseconds>( std::chrono::duration<double>(turn_signal_update_period)); turn_signal_timer_ = std::make_shared<rclcpp::GenericTimer<decltype(turn_signal_timer_callback)>>( this->get_clock(), turn_signal_timer_period, std::move(turn_signal_timer_callback), this->get_node_base_interface()->get_context()); this->get_node_timers_interface()->add_timer(turn_signal_timer_, nullptr); } void TurnSignalDecider::onTurnSignalTimer() { // wait for mandatory topics if (!data_.isDataReady()) { return; } // setup const auto path = data_.getPath(); FrenetCoordinate3d vehicle_pose_frenet; if (!convertToFrenetCoordinate3d( path, data_.getVehiclePoseStamped().pose.position, &vehicle_pose_frenet)) { RCLCPP_ERROR_THROTTLE( get_logger(), *get_clock(), std::chrono::milliseconds(5000).count(), "failed to convert vehicle pose into frenet coordinate"); return; } // set turn signals according to closest maneuvers TurnSignal turn_signal, lane_change_signal, intersection_signal; double distance_to_lane_change, distance_to_intersection; double min_distance = std::numeric_limits<double>::max(); if (isChangingLane(path, vehicle_pose_frenet, &lane_change_signal, &distance_to_lane_change)) { if (min_distance > distance_to_lane_change) { min_distance = distance_to_lane_change; turn_signal = lane_change_signal; } } if (isTurning(path, vehicle_pose_frenet, &intersection_signal, &distance_to_intersection)) { if (min_distance > distance_to_intersection) { turn_signal = intersection_signal; } } turn_signal.header.stamp = this->now(); turn_signal.header.frame_id = "base_link"; turn_signal_publisher_->publish(turn_signal); } lanelet::routing::RelationType TurnSignalDecider::getRelation( const lanelet::ConstLanelet & prev_lane, const lanelet::ConstLanelet & next_lane) const { const auto routing_graph_ptr = data_.getRoutingGraphPtr(); if (prev_lane == next_lane) { return lanelet::routing::RelationType::None; } const auto & relation = routing_graph_ptr->routingRelation(prev_lane, next_lane); if (relation) { return relation.get(); } // check if lane change extends across multiple lanes const auto shortest_path = routing_graph_ptr->shortestPath(prev_lane, next_lane); if (shortest_path) { auto prev_llt = shortest_path->front(); for (const auto & llt : shortest_path.get()) { if (prev_llt == llt) { continue; } const auto & relation = routing_graph_ptr->routingRelation(prev_llt, llt); if (!relation) { continue; } if ( relation.get() == lanelet::routing::RelationType::Left || relation.get() == lanelet::routing::RelationType::Right) { return relation.get(); } prev_llt = llt; } } return lanelet::routing::RelationType::None; } bool TurnSignalDecider::isChangingLane( const autoware_planning_msgs::msg::PathWithLaneId & path, const FrenetCoordinate3d & vehicle_pose_frenet, TurnSignal * signal_state_ptr, double * distance_ptr) const { if (signal_state_ptr == nullptr || distance_ptr == nullptr) { RCLCPP_ERROR(this->get_logger(), "Given argument is nullptr."); return false; } if (path.points.empty()) { return false; } double accumulated_distance = 0; auto prev_point = path.points.front(); auto prev_lane_id = path.points.front().lane_ids.front(); for (const auto & path_point : path.points) { accumulated_distance += getDistance3d(prev_point.point.pose.position, path_point.point.pose.position); prev_point = path_point; const double distance_from_vehicle_front = accumulated_distance - vehicle_pose_frenet.length - parameters_.base_link2front; if (distance_from_vehicle_front < 0.0) { continue; } for (const auto & lane_id : path_point.lane_ids) { if (lane_id == prev_lane_id) { continue; } const auto & prev_lane = data_.getLaneFromId(prev_lane_id); const auto & lane = data_.getLaneFromId(lane_id); prev_lane_id = lane_id; // check lane change relation const auto relation = getRelation(prev_lane, lane); if (relation == lanelet::routing::RelationType::Left) { signal_state_ptr->data = TurnSignal::LEFT; *distance_ptr = distance_from_vehicle_front; return true; } if (relation == lanelet::routing::RelationType::Right) { signal_state_ptr->data = TurnSignal::RIGHT; *distance_ptr = distance_from_vehicle_front; return true; } } if (distance_from_vehicle_front > parameters_.lane_change_search_distance) { return false; } } return false; } bool TurnSignalDecider::isTurning( const autoware_planning_msgs::msg::PathWithLaneId & path, const FrenetCoordinate3d & vehicle_pose_frenet, TurnSignal * signal_state_ptr, double * distance_ptr) const { if (signal_state_ptr == nullptr || distance_ptr == nullptr) { RCLCPP_ERROR(this->get_logger(), "Given argument is nullptr."); return false; } if (path.points.empty()) { return false; } double accumulated_distance = 0; auto prev_point = path.points.front(); auto prev_lane_id = lanelet::InvalId; for (const auto & path_point : path.points) { accumulated_distance += getDistance3d(prev_point.point.pose.position, path_point.point.pose.position); prev_point = path_point; const double distance_from_vehicle_front = accumulated_distance - vehicle_pose_frenet.length - parameters_.base_link2front; if (distance_from_vehicle_front < 0.0) { continue; } for (const auto & lane_id : path_point.lane_ids) { if (lane_id == prev_lane_id) { continue; } prev_lane_id = lane_id; const auto & lane = data_.getLaneFromId(lane_id); if ( lane.attributeOr("turn_signal_distance", std::numeric_limits<double>::max()) < distance_from_vehicle_front) { if (1 < path_point.lane_ids.size() && lane_id == path_point.lane_ids.back()) {continue;} } if (lane.attributeOr("turn_direction", std::string("none")) == "left") { signal_state_ptr->data = TurnSignal::LEFT; *distance_ptr = distance_from_vehicle_front; return true; } if (lane.attributeOr("turn_direction", std::string("none")) == "right") { signal_state_ptr->data = TurnSignal::RIGHT; *distance_ptr = distance_from_vehicle_front; return true; } } if (distance_from_vehicle_front > parameters_.intersection_search_distance) { return false; } } return false; } } // namespace turn_signal_decider #include "rclcpp_components/register_node_macro.hpp" RCLCPP_COMPONENTS_REGISTER_NODE(turn_signal_decider::TurnSignalDecider)
debbf28b527d0a462e97f512009fdf317664086f
8c1e0392515f7d16cc988a6fdaf576bc25fde4eb
/tfp/include/tfp/math/CoefficientPolynomial.hpp
f69586c368aa32ccbaf849ef3303ff8981a913b7
[]
no_license
TheComet/tfp
97a252c6512e9ff94d4a515b335904aecec5ec1a
a4d4e42ba97130ea3d7dc0cbe229e4c8fb79d742
refs/heads/master
2021-09-24T07:28:26.644360
2017-11-18T09:04:49
2017-11-18T09:04:49
95,609,729
3
0
null
null
null
null
UTF-8
C++
false
false
3,547
hpp
CoefficientPolynomial.hpp
#pragma once #include "tfp/math/CoefficientPolynomial.hxx" #include "tfp/math/RootPolynomial.hpp" namespace tfp { // ---------------------------------------------------------------------------- template <class T> CoefficientPolynomial<T>::CoefficientPolynomial() { } // ---------------------------------------------------------------------------- template <class T> CoefficientPolynomial<T>::CoefficientPolynomial(int size) : coefficients_(size, 1) { } // ---------------------------------------------------------------------------- template <class T> CoefficientPolynomial<T>::CoefficientPolynomial(const typename Type<T>::RealVector& coeffs) : coefficients_(coeffs) { } // ---------------------------------------------------------------------------- template <class T> CoefficientPolynomial<T>::CoefficientPolynomial(const RootPolynomial<T>& polynomial) : coefficients_(polynomial.poly().coefficients_) { } // ---------------------------------------------------------------------------- template <class T> void CoefficientPolynomial<T>::resize(int size) { coefficients_.resize(size, Eigen::NoChange); } // ---------------------------------------------------------------------------- template <class T> int CoefficientPolynomial<T>::size() const { return coefficients_.size(); } // ---------------------------------------------------------------------------- template <class T> void CoefficientPolynomial<T>::setCoefficient(int index, T coefficient) { coefficients_(index, 0) = coefficient; } // ---------------------------------------------------------------------------- template <class T> T CoefficientPolynomial<T>::coefficient(int index) const { return coefficients_(index, 0); } // ---------------------------------------------------------------------------- template <class T> RootPolynomial<T> CoefficientPolynomial<T>::roots() const { // Companion matrix is a square m x m matrix, where m = polynomial order int size = coefficients_.rows() - 1; if (size < 0) return RootPolynomial<T>(); // Each coefficient is divided by this factor to make it a monic polynomial T factor = coefficients_(size); // Zero-order polynomial has no roots, but it still has a factor equal to // the largest coefficient if (size == 0) return RootPolynomial<T>(typename Type<T>::ComplexVector(), factor); if (companionMatrix_.rows() != coefficients_.rows()) companionMatrix_ = CompanionMatrixType::Zero(size, size); // Has to be a monic polynomial (this is also why we pass by value instead of by const reference) typename Type<T>::RealVector monicCoeffs = coefficients_ / factor; for (int row = 1; row < size; ++row) { int column = row - 1; companionMatrix_(row, size-1) = -monicCoeffs(size - row); companionMatrix_(row, column) = 1; } companionMatrix_(0, size-1) = -monicCoeffs(size); EigensolverType solver; solver.compute(companionMatrix_, false); return RootPolynomial<T>(solver.eigenvalues(), factor); } // ---------------------------------------------------------------------------- template <class T> typename Type<T>::Complex CoefficientPolynomial<T>::evaluate(const typename Type<T>::Complex& value) const { return 0; } // ---------------------------------------------------------------------------- template <class U> std::ostream& operator<<(std::ostream& os, const CoefficientPolynomial<U>& polynomial) { os << polynomial.coefficients_; return os; } } // namespace tfp
e193ccf2efbdb3246be82c40a9d981e6836e8918
57dc76ec9bd6464d68c49c152183ecba2833067c
/src/gui/video_window/VideoWindow.h
c36cbc3bab3ec771c3fc6c9485665ebd059d3dfa
[ "MIT" ]
permissive
SyllogismRXS/opencv-workbench
bb737754c05631a3057891a945483b572aee26f9
2fb5b0d67589642d438f21f1cf58aaa761d15757
refs/heads/master
2020-04-06T07:01:50.398354
2017-07-10T21:16:28
2017-07-10T21:16:28
13,833,724
7
12
null
null
null
null
UTF-8
C++
false
false
4,749
h
VideoWindow.h
/**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names ** of its contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef VIDEOWINDOW_H #define VIDEOWINDOW_H #include <map> // OpenCV headers #include <cv.h> //#include <highgui.h> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/contrib/contrib.hpp> #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <video_window/ui_VideoWindow.h> #include <opencv_workbench/utils/Stream.h> #include <opencv_workbench/gui/cut/cut.h> #include <QtGui> #include <QResource> #include <QSettings> #include <QTextStream> #include <QShortcut> class VideoWindow : public QWidget { Q_OBJECT public: typedef enum{ img = 0, avi, mp4, wmv, usb_cam, sonar }Media_t; typedef enum{ none = 0, paused, playing, }State_t; VideoWindow(QWidget *parent = 0); void add_shortcut(std::string name, const QKeySequence & key, QWidget * parent, const char * member); //QSize sizeHint() const; QSize GoodSize(); void open(QString fileName); void open_camera(int id); private slots: void tooltip_enabled(); void mouseMoved(QMouseEvent * event); void about(); void open(); void timer_video_loop(); void timer_refresh_loop(); void space_bar(); void draw(); void get_video_frame(); virtual void before_display(cv::Mat &img); virtual void before_next_frame(); void play(); void pause(); void display_image(const cv::Mat &img); void step_one_frame(); void back_one_frame(); void double_frame_rate(); void divide_frame_rate(); void set_fps(double fps); void set_frame_num_from_slider(int frame_num); void set_frame_num_from_spinbox(); void slider_released(); void draw_tooltip(cv::Mat &img); protected: Ui::VideoWindow ui; QTimer *timer_video_; QTimer *timer_refresh_; QImage q_image; QString filename_; syllo::Stream stream_; void readSettings(); void writeSettings(); QString m_sSettingsFile; QString prev_open_path_; QDialog * cut_dialog_; CutForm *cut_; State_t state_; double fps_; double timer_refresh_fps_; void closeEvent(QCloseEvent *event); //virtual void resizeEvent(QResizeEvent *); cv::Mat curr_image_; cv::Mat visible_img_; bool tooltip_enabled_; QPoint mouse_pos_; virtual void on_open(); virtual void on_mouseMoved(QMouseEvent * event); private: std::map<std::string, QShortcut*> shortcuts_; }; #endif
bca0e03950c3f9a67f507ea674d1e4c6510e28a4
56e615c555c423a3bc68ad0e9a5677c7c94960ef
/libi2pd/LittleBigEndian.h
8c081187d3a2fde822c027e9618c852f8fb44ef9
[ "BSD-3-Clause", "OpenSSL" ]
permissive
PurpleI2P/i2pd
bc1f5c2513e3f0b7a51b274001e343142c403f79
7b6aa41ca8dc3ca2a0c9d01ff9870794ad98e403
refs/heads/openssl
2023-09-04T04:44:21.112974
2023-08-31T16:52:51
2023-08-31T16:52:51
12,522,239
2,642
540
BSD-3-Clause
2023-09-07T14:25:41
2013-09-01T15:09:28
C++
UTF-8
C++
false
false
4,147
h
LittleBigEndian.h
/* * Copyright (c) 2013-2020, The PurpleI2P Project * * This file is part of Purple i2pd project and licensed under BSD3 * * See full license text in LICENSE file at top of project tree */ // LittleBigEndian.h fixed for 64-bits added union // #ifndef LITTLEBIGENDIAN_H #define LITTLEBIGENDIAN_H // Determine Little-Endian or Big-Endian #define CURRENT_BYTE_ORDER (*(int *)"\x01\x02\x03\x04") #define LITTLE_ENDIAN_BYTE_ORDER 0x04030201 #define BIG_ENDIAN_BYTE_ORDER 0x01020304 #define PDP_ENDIAN_BYTE_ORDER 0x02010403 #define IS_LITTLE_ENDIAN (CURRENT_BYTE_ORDER == LITTLE_ENDIAN_BYTE_ORDER) #define IS_BIG_ENDIAN (CURRENT_BYTE_ORDER == BIG_ENDIAN_BYTE_ORDER) #define IS_PDP_ENDIAN (CURRENT_BYTE_ORDER == PDP_ENDIAN_BYTE_ORDER) // Forward declaration template<typename T> struct LittleEndian; template<typename T> struct BigEndian; // Little-Endian template #pragma pack(push,1) template<typename T> struct LittleEndian { union { unsigned char bytes[sizeof(T)]; T raw_value; }; LittleEndian(T t = T()) { operator =(t); } LittleEndian(const LittleEndian<T> & t) { raw_value = t.raw_value; } LittleEndian(const BigEndian<T> & t) { for (unsigned i = 0; i < sizeof(T); i++) bytes[i] = t.bytes[sizeof(T)-1-i]; } operator const T() const { T t = T(); for (unsigned i = 0; i < sizeof(T); i++) t |= T(bytes[i]) << (i << 3); return t; } const T operator = (const T t) { for (unsigned i = 0; i < sizeof(T); i++) bytes[sizeof(T)-1 - i] = static_cast<unsigned char>(t >> (i << 3)); return t; } // operators const T operator += (const T t) { return (*this = *this + t); } const T operator -= (const T t) { return (*this = *this - t); } const T operator *= (const T t) { return (*this = *this * t); } const T operator /= (const T t) { return (*this = *this / t); } const T operator %= (const T t) { return (*this = *this % t); } LittleEndian<T> operator ++ (int) { LittleEndian<T> tmp(*this); operator ++ (); return tmp; } LittleEndian<T> & operator ++ () { for (unsigned i = 0; i < sizeof(T); i++) { ++bytes[i]; if (bytes[i] != 0) break; } return (*this); } LittleEndian<T> operator -- (int) { LittleEndian<T> tmp(*this); operator -- (); return tmp; } LittleEndian<T> & operator -- () { for (unsigned i = 0; i < sizeof(T); i++) { --bytes[i]; if (bytes[i] != (T)(-1)) break; } return (*this); } }; #pragma pack(pop) // Big-Endian template #pragma pack(push,1) template<typename T> struct BigEndian { union { unsigned char bytes[sizeof(T)]; T raw_value; }; BigEndian(T t = T()) { operator =(t); } BigEndian(const BigEndian<T> & t) { raw_value = t.raw_value; } BigEndian(const LittleEndian<T> & t) { for (unsigned i = 0; i < sizeof(T); i++) bytes[i] = t.bytes[sizeof(T)-1-i]; } operator const T() const { T t = T(); for (unsigned i = 0; i < sizeof(T); i++) t |= T(bytes[sizeof(T) - 1 - i]) << (i << 3); return t; } const T operator = (const T t) { for (unsigned i = 0; i < sizeof(T); i++) bytes[sizeof(T) - 1 - i] = t >> (i << 3); return t; } // operators const T operator += (const T t) { return (*this = *this + t); } const T operator -= (const T t) { return (*this = *this - t); } const T operator *= (const T t) { return (*this = *this * t); } const T operator /= (const T t) { return (*this = *this / t); } const T operator %= (const T t) { return (*this = *this % t); } BigEndian<T> operator ++ (int) { BigEndian<T> tmp(*this); operator ++ (); return tmp; } BigEndian<T> & operator ++ () { for (unsigned i = 0; i < sizeof(T); i++) { ++bytes[sizeof(T) - 1 - i]; if (bytes[sizeof(T) - 1 - i] != 0) break; } return (*this); } BigEndian<T> operator -- (int) { BigEndian<T> tmp(*this); operator -- (); return tmp; } BigEndian<T> & operator -- () { for (unsigned i = 0; i < sizeof(T); i++) { --bytes[sizeof(T) - 1 - i]; if (bytes[sizeof(T) - 1 - i] != (T)(-1)) break; } return (*this); } }; #pragma pack(pop) #endif // LITTLEBIGENDIAN_H
c60818665285f3b3b54f6f6ebe6f46d34394800e
084d470c89c1afdc00d9109af4b7a0f58e542fec
/minidump/cpp/data_structures.h
9474002841034372a2e85a6b91ca992c040dc814
[ "MIT", "Apache-2.0" ]
permissive
robopsi/symbolic
fc8673031f8a816fac2cc13bcff076f351fb84a9
58ba344d74eac6ca69e28b6b7ee4853293616248
refs/heads/master
2020-03-19T07:18:43.379580
2018-05-30T06:10:17
2018-05-30T06:10:17
136,103,804
0
1
null
2018-06-05T01:43:23
2018-06-05T01:43:23
null
UTF-8
C++
false
false
10,041
h
data_structures.h
#ifndef SENTRY_DATA_STRUCTURES_H #define SENTRY_DATA_STRUCTURES_H #include <cstdbool> #include <cstddef> #include <cstdint> #ifdef __cplusplus extern "C" { #endif /// Structure holding all stack frames in a certain thread. Use the call_stack_* /// family of functions to interact with a call stack. struct call_stack_t; /// Carries information about the code module loaded into the process. The field /// debug_identifier contains the UUID of this module. Use the code_module_* /// family of functions to interact with a code module. struct code_module_t; /// Snapshot of the state of a process during its crash. This object is obtained /// by processing Minidumps using the process_* family of functions. To interact /// with ProcessStates use the process_state_* family of functions. struct process_state_t; /// Contains information from the stackdump, especially the frame's instruction /// pointer. After being processed by a resolver, this struct also contains /// source code locations and code offsets. struct stack_frame_t; /// Information about the CPU and OS on which a minidump was generated. struct system_info_t; /// Releases memory of a process state struct. Assumes ownership of the pointer. void process_state_delete(process_state_t *state); /// Returns a weak pointer to the list of threads in the minidump. Each thread /// is represented by the call stack structure. The number of threads is /// returned in the size_out parameter. call_stack_t *const *process_state_threads(process_state_t *state, size_t *size_out); /// The index of the thread that requested a dump be written in the /// threads vector. If a dump was produced as a result of a crash, this /// will point to the thread that crashed. If the dump was produced as /// by user code without crashing, and the dump contains extended Breakpad /// information, this will point to the thread that requested the dump. /// If the dump was not produced as a result of an exception and no /// extended Breakpad information is present, this field will be set to -1, /// indicating that the dump thread is not available. int32_t process_state_requesting_thread(const process_state_t *state); /// The time-date stamp of the minidump (time_t format) uint64_t process_state_timestamp(const process_state_t *state); /// True if the process crashed, false if the dump was produced outside /// of an exception handler. bool process_state_crashed(const process_state_t *state); /// If the process crashed, and if crash_reason implicates memory, /// the memory address that caused the crash. For data access errors, /// this will be the data address that caused the fault. For code errors, /// this will be the address of the instruction that caused the fault. uint64_t process_state_crash_address(const process_state_t *state); /// If the process crashed, the type of crash. OS- and possibly CPU- /// specific. For example, "EXCEPTION_ACCESS_VIOLATION" (Windows), /// "EXC_BAD_ACCESS / KERN_INVALID_ADDRESS" (Mac OS X), "SIGSEGV" /// (other Unix). /// /// The return value is an owning pointer. Release memory with string_delete. char *process_state_crash_reason(const process_state_t *state); /// If there was an assertion that was hit, a textual representation /// of that assertion, possibly including the file and line at which /// it occurred. /// /// The return value is an owning pointer. Release memory with string_delete. char *process_state_assertion(const process_state_t *state); /// Returns a weak pointer to OS and CPU information. const system_info_t *process_state_system_info(const process_state_t *state); /// A string identifying the operating system, such as "Windows NT", /// "Mac OS X", or "Linux". If the information is present in the dump but /// its value is unknown, this field will contain a numeric value. If /// the information is not present in the dump, this field will be empty. /// /// The return value is an owning pointer. Release memory with string_delete. char *system_info_os_name(const system_info_t *info); /// A string identifying the version of the operating system, such as /// "5.1.2600 Service Pack 2" or "10.4.8 8L2127". If the dump does not /// contain this information, this field will be empty. /// /// The return value is an owning pointer. Release memory with string_delete. char *system_info_os_version(const system_info_t *info); /// A string identifying the basic CPU family, such as "x86" or "ppc". /// If this information is present in the dump but its value is unknown, /// this field will contain a numeric value. If the information is not /// present in the dump, this field will be empty. The values stored in /// this field should match those used by MinidumpSystemInfo::GetCPU. /// /// The return value is an owning pointer. Release memory with string_delete. char *system_info_cpu_family(const system_info_t *info); /// A string further identifying the specific CPU, such as /// "GenuineIntel level 6 model 13 stepping 8". If the information is not /// present in the dump, or additional identifying information is not /// defined for the CPU family, this field will be empty. /// /// The return value is an owning pointer. Release memory with string_delete. char *system_info_cpu_info(const system_info_t *info); /// The number of processors in the system. Will be greater than one for /// multi-core systems. uint32_t system_info_cpu_count(const system_info_t *info); /// Returns the thread identifier of this callstack. uint32_t call_stack_thread_id(const call_stack_t *stack); /// Returns a weak pointer to the list of frames in a call stack. Each frame is /// represented by the stack frame structure. The number of frames is returned /// in the size_out parameter. stack_frame_t *const *call_stack_frames(const call_stack_t *stack, size_t *size_out); // Return the actual return address, as saved on the stack or in a // register. See the comments for 'stack_frameinstruction', below, // for details. uint64_t stack_frame_return_address(const stack_frame_t *frame); /// Returns the program counter location as an absolute virtual address. /// /// - For the innermost called frame in a stack, this will be an exact /// program counter or instruction pointer value. /// /// - For all other frames, this address is within the instruction that /// caused execution to branch to this frame's callee (although it may /// not point to the exact beginning of that instruction). This ensures /// that, when we look up the source code location for this frame, we /// get the source location of the call, not of the point at which /// control will resume when the call returns, which may be on the next /// line. (If the compiler knows the callee never returns, it may even /// place the call instruction at the very end of the caller's machine /// code, such that the "return address" (which will never be used) /// immediately after the call instruction is in an entirely different /// function, perhaps even from a different source file.) /// /// On some architectures, the return address as saved on the stack or in /// a register is fine for looking up the point of the call. On others, it /// requires adjustment. ReturnAddress returns the address as saved by the /// machine. /// /// Use stack_frame_trust to obtain how trustworthy this instruction is. uint64_t stack_frame_instruction(const stack_frame_t *frame); /// Returns a weak pointer to the code module that hosts the instruction of the /// stack framme. This function can return null for some frames. const code_module_t *stack_frame_module(const stack_frame_t *frame); /// Returns how well the instruction pointer derived during /// stack walking is trusted. Since the stack walker can resort to /// stack scanning, it can wind up with dubious frames. /// In rough order of "trust metric". int stack_frame_trust(const stack_frame_t *frame); /// Returns the base address of this code module as it was loaded by the /// process. (uint64_t)-1 on error. uint64_t code_module_base_address(const code_module_t *module); /// The size of the code module. 0 on error. uint64_t code_module_size(const code_module_t *module); /// Returns the path or file name that the code module was loaded from. /// /// The return value is an owning pointer. Release memory with string_delete. char *code_module_code_file(const code_module_t *module); /// An identifying string used to discriminate between multiple versions and /// builds of the same code module. This may contain a uuid, timestamp, /// version number, or any combination of this or other information, in an /// implementation-defined format. /// /// The return value is an owning pointer. Release memory with string_delete. char *code_module_code_identifier(const code_module_t *module); /// Returns the filename containing debugging information of this code /// module. If debugging information is stored in a file separate from the /// code module itself (as is the case when .pdb or .dSYM files are used), /// this will be different from code_file. If debugging information is /// stored in the code module itself (possibly prior to stripping), this /// will be the same as code_file. /// /// The return value is an owning pointer. Release memory with string_delete. char *code_module_debug_file(const code_module_t *module); /// Returns a string identifying the specific version and build of the /// associated debug file. This may be the same as code_identifier when /// the debug_file and code_file are identical or when the same identifier /// is used to identify distinct debug and code files. /// /// It usually comprises the library's UUID and an age field. On Windows, the /// age field is a generation counter, on all other platforms it is mostly /// zero. /// /// The return value is an owning pointer. Release memory with string_delete. char *code_module_debug_identifier(const code_module_t *module); #ifdef __cplusplus } #endif #endif
360f4cd0ae9407d39317cacd590a48d04410408e
7b8c4576fd8582d1b5bce56f38b4cc06902a8020
/main.cpp
d210ed2d2f436c5787995401d7bdce3db3ad4bbc
[]
no_license
MaxCarlson/SimpleNeuralNet
3773251ffdc45057edcd199e4bdd10baee893499
c10064f4c8ba7eab21fc9b1fa5948f13f8e3b448
refs/heads/master
2021-01-06T20:40:01.995746
2017-08-07T05:45:39
2017-08-07T05:45:39
99,540,947
0
0
null
null
null
null
UTF-8
C++
false
false
4,211
cpp
main.cpp
#include <iostream> #include <vector> #include <random> #include <stdlib.h> using namespace std; //using vector vector<float> inputSet { 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1 }; vector<float> rOutPut { 1, 1, 0, 1 }; vector<float> iWeights { 0.5, 0.5, 0.5, 0.5 }; vector<float> X { 5.1, 3.5, 1.4, 0.2, 4.9, 3.0, 1.4, 0.2, 6.2, 3.4, 5.4, 2.3, 5.9, 3.0, 5.1, 1.8 }; vector<float> y { 0, 0, 1, 1 }; vector<float> W { 0.5, 0.5, 0.5, 0.5}; vector <float> sigmoid(const vector <float> &m1){ /* Returns the value of the sigmoid function f(x) = 1/(1 + e^-x). Input: m1, a vector. Output: 1/(1 + e^-x) for every element of the input matrix m1. */ const unsigned long VECTOR_SIZE = m1.size(); vector <float> output (VECTOR_SIZE); for(unsigned i = 0; i != VECTOR_SIZE; ++i){ output[i] = 1 / (1 + exp(-m1[i])); } return output; } vector <float> sigmoid_d(const vector <float> &m1){ //returns the sigmoid function derivative f'(x) = f(x)(1 - f(x)), //of the values in vector m1 const unsigned long VECTOR_SIZE = m1.size(); vector <float> output (VECTOR_SIZE); for(unsigned i = 0; i != VECTOR_SIZE; ++i){ output[i] = m1[i] * (1 - m1[i]); } return output; } vector <float> vecAdd(const vector <float> &m1, const vector <float> &m2){ //returns the elementwise sum of two vectors const unsigned long VECTOR_SIZE = m1.size(); vector <float> sum (VECTOR_SIZE); for(unsigned i = 0; i != VECTOR_SIZE; ++i){ sum [i] = m1[i] + m2[i]; } return sum; } vector <float> vecSub(const vector <float> &m1, const vector <float> &m2){ //returns the difference between two vectors (elementwise) const unsigned long VECTOR_SIZE = m1.size(); vector <float> difference (VECTOR_SIZE); for(unsigned i = 0; i != VECTOR_SIZE; ++i){ difference [i] = m1[i] - m2[i]; } return difference; } vector <float> vecMult(const vector <float> &m1, const vector <float> &m2){ //returns the product of two vectors (elementwise) const unsigned long VECTOR_SIZE = m1.size(); vector <float> product (VECTOR_SIZE); for(unsigned i = 0; i != VECTOR_SIZE; ++i){ product [i] = m1[i] * m2[i]; } return product; } vector <float> transpose (float *m, const int C, const int R) { //Returns a transpose matrix of input matrix. vector <float> mT (C*R); for(unsigned n = 0; n != C*R; n++) { unsigned i = n/C; unsigned j = n%C; mT[n] = m[R*j + i]; } return mT; } vector <float> dot(const vector<float> &m1, const vector<float> &m2, const int m1Rows, const int m1Cols, const int m2Cols){ //returns the product of two matrices m1 x m2 vector <float> output (m1Rows * m2Cols); for(int row = 0; row != m1Rows; ++row){ for(int col = 0; col != m2Cols; ++col){ output[row * m2Cols + col] = 0.f; for(int k = 0; k != m1Cols; ++k){ output[ row * m2Cols + col ] += m1[ row * m1Cols + k ] * m2[ k * m2Cols + col ]; } } } return output; } void print ( const vector <float>& m, int n_rows, int n_columns ) { /* "Couts" the input vector as n_rows x n_columns matrix. Inputs: m: vector, matrix of size n_rows x n_columns n_rows: int, number of rows in the left matrix m1 n_columns: int, number of columns in the left matrix m1 */ for( int i = 0; i != n_rows; ++i ) { for( int j = 0; j != n_columns; ++j ) { cout << m[ i * n_columns + j ] << " "; } cout << '\n'; } cout << endl; } int main() { for(unsigned i = 0; i != 100000; ++i){ vector<float> pred = sigmoid(dot(inputSet, W, 4, 4, 1)); vector<float> pred_error = vecSub(rOutPut, pred); vector<float> pred_delta = vecMult(pred_error, sigmoid_d(pred)); vector<float> W_delta = dot(transpose(&inputSet[0], 4, 4), pred_delta, 4, 4, 1); W = vecAdd(W, W_delta); if (i == 99999){ print ( pred, 4, 1); } } return 0; }
5bb44bd3a6380af251f173b143beaa68eef921aa
6952e2b2b753a3130cdaa7b820a4f610a897aadf
/1197.cpp
3893c48d5a031c181ce705bda4270d9e4a4cff54
[]
no_license
ytw0728/BOJ
37abf996565d53b75ce328daab5b2b8af2f8550f
261170ab8b607338949ae3df008da223f4d359b5
refs/heads/master
2021-09-17T09:59:08.632207
2018-06-30T13:27:35
2018-06-30T13:27:35
112,865,184
0
0
null
null
null
null
UTF-8
C++
false
false
1,819
cpp
1197.cpp
/* #include <stdio.h> #include <vector> #include <algorithm> using namespace std; vector<pair<int,int>> adj[10001]; int v, e, s; vector<int> routePoint; bool chk[10001]; int main() { scanf("%d %d", &v, &e); for (int i = 0; i < e; i++) { int a, b, c; scanf("%d %d %d", &a, &b, &c); adj[a].push_back(make_pair(b,c)); adj[b].push_back(make_pair(a,c)); if (!s) s = a; } routePoint.push_back(s); long long result = 0; while (routePoint.size() < v) { int minC = 987654321; int minIdx = 0, start = 0; for( auto p : routePoint ){ chk[p] = true; for (auto i : adj[p]) { if ( !chk[i.first] && minC > i.second) { minC = i.second; start = p; minIdx = i.first; } } } if (minIdx && start) { chk[minIdx] = true; result += minC; //adj[start].erase( find(adj[start].begin(), adj[start].end(), minIdx) ); routePoint.push_back(minIdx); } else { break; } } printf("%lld", result); return 0; } */ #include <stdio.h> #include <vector> #include <algorithm> using namespace std; const int n_ = 1e4 + 1; const int m_ = 1e5 + 1; struct node { int u, v, c; bool operator <(node A)const { return c < A.c; } } edg[m_]; int n, m; int parent[n_]; int find(int u) { if (u == parent[u]) return u; return parent[u] = find(parent[u]); } void uni(int u, int v) { u = find(u), v = find(v); if (u > v) swap(u, v); if (u == v) return; parent[u] = v; } int main() { int i; scanf("%d %d", &n, &m); for (i = 1; i <= m; i++) scanf("%d %d %d", &edg[i].u, &edg[i].v, &edg[i].c); sort(edg + 1, edg + m + 1); long long ans = 0; for (i = 1; i <= n; i++) parent[i] = i; for (i = 1; i <= m; i++) { int u = find(edg[i].u), v = find(edg[i].v); if (parent[u] == parent[v]) continue; uni(u, v); ans += edg[i].c; } printf("%lld", ans); return 0; }
19518d4166d3c83454d9d033daba1dde085392c8
1dbded85668100d2f6946dc72f8780458e3e22e5
/test/test.cpp
f316d3c86f128f5105c2a4065a9100564b64bc66
[ "MIT" ]
permissive
harish1696/Midterm-Project
b7dc43a77c62fc1b936e48e98b9fd25285ed0bab
dd67226577243a81ff89d9ef7953fc93a178e4a1
refs/heads/master
2021-05-16T04:36:10.456038
2017-10-18T03:58:30
2017-10-18T03:58:30
106,120,485
0
1
null
null
null
null
UTF-8
C++
false
false
6,483
cpp
test.cpp
/** * @file detectQRcode.cpp * @author Harish Sampathkumar * @copyright MIT License * * @brief Warehouse Robot - Stock Tracking and Counting Module * * @section Description * * Test cases * * */ #include <gtest/gtest.h> #include <detectQRcode.hpp> #include <decodeQRcode.hpp> #include <countID.hpp> #include <opencv2/opencv.hpp> #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/imgcodecs/imgcodecs.hpp> using std::vector; using cv::Mat; using cv::cvtColor; using cv::adaptiveThreshold; using cv::resize; TEST(findMethod, should_pass) { detectQRcode qr; String imageName1("../testfiles/100.JPG"); String imageName2("../testfiles/Lenna.png"); Mat img = imread(imageName1, IMREAD_COLOR); resize(img, img, Size(375, 500), 0, 0, CV_INTER_AREA); Mat imgBW; cvtColor(img, imgBW, CV_BGR2GRAY); adaptiveThreshold(imgBW, imgBW, 255, CV_ADAPTIVE_THRESH_GAUSSIAN_C, CV_THRESH_BINARY, 51, 0); bool found = qr.find(imgBW); EXPECT_TRUE(found); EXPECT_EQ(1, qr.centers[0].x < qr.centers[1].x); EXPECT_EQ(1, qr.centers[0].y < qr.centers[2].y); EXPECT_EQ(0, qr.centers[2].x > qr.centers[1].x); EXPECT_EQ(0, qr.centers[1].y > qr.centers[2].y); img = imread(imageName2, IMREAD_COLOR); resize(img, img, Size(375, 500), 0, 0, CV_INTER_AREA); cvtColor(img, imgBW, CV_BGR2GRAY); adaptiveThreshold(imgBW, imgBW, 255, CV_ADAPTIVE_THRESH_GAUSSIAN_C, CV_THRESH_BINARY, 51, 0); found = qr.find(imgBW); EXPECT_FALSE(found); } TEST(drawBoundaryMethod, should_pass) { detectQRcode qr; String imageName1("../testfiles/100.JPG"); String imageName2("../testfiles/Lenna.png"); Mat img = imread(imageName1, IMREAD_COLOR); resize(img, img, Size(375, 500), 0, 0, CV_INTER_AREA); Mat imgBW; cvtColor(img, imgBW, CV_BGR2GRAY); adaptiveThreshold(imgBW, imgBW, 255, CV_ADAPTIVE_THRESH_GAUSSIAN_C, CV_THRESH_BINARY, 51, 0); bool found = qr.find(imgBW); ASSERT_TRUE(found); qr.drawBoundary(img); } TEST(extractQRcodeMethod, should_pass) { detectQRcode qr; String imageName1("../testfiles/100.JPG"); String imageName2("../testfiles/Lenna.png"); Mat img = imread(imageName1, IMREAD_COLOR); resize(img, img, Size(375, 500), 0, 0, CV_INTER_AREA); Mat imgBW; cvtColor(img, imgBW, CV_BGR2GRAY); adaptiveThreshold(imgBW, imgBW, 255, CV_ADAPTIVE_THRESH_GAUSSIAN_C, CV_THRESH_BINARY, 51, 0); bool found = qr.find(imgBW); ASSERT_TRUE(found); qr.drawBoundary(img); found = qr.extractQRcode(img); ASSERT_TRUE(found); EXPECT_EQ(420, img.rows); EXPECT_EQ(420, img.cols); } TEST(extractBitsMethod, should_pass) { detectQRcode qr; String imageName1("../testfiles/100.JPG"); String imageName2("../testfiles/100.JPG"); Mat img = imread(imageName1, IMREAD_COLOR); resize(img, img, Size(375, 500), 0, 0, CV_INTER_AREA); Mat imgBW; cvtColor(img, imgBW, CV_BGR2GRAY); adaptiveThreshold(imgBW, imgBW, 255, CV_ADAPTIVE_THRESH_GAUSSIAN_C, CV_THRESH_BINARY, 51, 0); bool found = qr.find(imgBW); ASSERT_TRUE(found); qr.drawBoundary(img); found = qr.extractQRcode(img); ASSERT_TRUE(found); cvtColor(img, imgBW, CV_BGR2GRAY); adaptiveThreshold(imgBW, imgBW, 255, CV_ADAPTIVE_THRESH_GAUSSIAN_C, CV_THRESH_BINARY, 51, 0); decodeQRcode qr1, qr2; qr1.extractBits(imgBW); img = imread(imageName2, IMREAD_COLOR); resize(img, img, Size(375, 500), 0, 0, CV_INTER_AREA); cvtColor(img, imgBW, CV_BGR2GRAY); adaptiveThreshold(imgBW, imgBW, 255, CV_ADAPTIVE_THRESH_GAUSSIAN_C, CV_THRESH_BINARY, 51, 0); found = qr.find(imgBW); ASSERT_TRUE(found); qr.drawBoundary(img); found = qr.extractQRcode(img); ASSERT_TRUE(found); cvtColor(img, imgBW, CV_BGR2GRAY); adaptiveThreshold(imgBW, imgBW, 255, CV_ADAPTIVE_THRESH_GAUSSIAN_C, CV_THRESH_BINARY, 51, 0); qr2.extractBits(imgBW); for (int i = 0; i < qr1.bits.rows; i++) for (int j = 0; j < qr1.bits.cols; j++) EXPECT_EQ(qr1.bits.at<uchar>(i, j), qr2.bits.at<uchar>(i, j)); } TEST(getIDMethod, should_pass) { detectQRcode qr; String imageName1("../testfiles/100.JPG"); String imageName2("../testfiles/100.JPG"); String imageName3("../testfiles/1101.JPG"); Mat img = imread(imageName1, IMREAD_COLOR); resize(img, img, Size(375, 500), 0, 0, CV_INTER_AREA); Mat imgBW; cvtColor(img, imgBW, CV_BGR2GRAY); adaptiveThreshold(imgBW, imgBW, 255, CV_ADAPTIVE_THRESH_GAUSSIAN_C, CV_THRESH_BINARY, 51, 0); bool found = qr.find(imgBW); ASSERT_TRUE(found); qr.drawBoundary(img); found = qr.extractQRcode(img); ASSERT_TRUE(found); cvtColor(img, imgBW, CV_BGR2GRAY); adaptiveThreshold(imgBW, imgBW, 255, CV_ADAPTIVE_THRESH_GAUSSIAN_C, CV_THRESH_BINARY, 51, 0); decodeQRcode qr1, qr2, qr3; qr1.extractBits(imgBW); qr1.getData(); int iD1 = qr1.getID(); img = imread(imageName2, IMREAD_COLOR); resize(img, img, Size(375, 500), 0, 0, CV_INTER_AREA); cvtColor(img, imgBW, CV_BGR2GRAY); adaptiveThreshold(imgBW, imgBW, 255, CV_ADAPTIVE_THRESH_GAUSSIAN_C, CV_THRESH_BINARY, 51, 0); found = qr.find(imgBW); ASSERT_TRUE(found); qr.drawBoundary(img); found = qr.extractQRcode(img); ASSERT_TRUE(found); cvtColor(img, imgBW, CV_BGR2GRAY); adaptiveThreshold(imgBW, imgBW, 255, CV_ADAPTIVE_THRESH_GAUSSIAN_C, CV_THRESH_BINARY, 51, 0); qr2.extractBits(imgBW); qr2.getData(); int iD2 = qr2.getID(); img = imread(imageName3, IMREAD_COLOR); resize(img, img, Size(375, 500), 0, 0, CV_INTER_AREA); cvtColor(img, imgBW, CV_BGR2GRAY); adaptiveThreshold(imgBW, imgBW, 255, CV_ADAPTIVE_THRESH_GAUSSIAN_C, CV_THRESH_BINARY, 51, 0); found = qr.find(imgBW); ASSERT_TRUE(found); qr.drawBoundary(img); found = qr.extractQRcode(img); ASSERT_TRUE(found); cvtColor(img, imgBW, CV_BGR2GRAY); adaptiveThreshold(imgBW, imgBW, 255, CV_ADAPTIVE_THRESH_GAUSSIAN_C, CV_THRESH_BINARY, 51, 0); qr3.extractBits(imgBW); qr3.getData(); int iD3 = qr3.getID(); EXPECT_EQ(iD1, iD2); EXPECT_NE(iD1, iD3); } TEST(getCountMethod, should_pass) { vector<int> test, sample;; sample = {44, 532, 100, 2, 7, 1100}; int pID; ifstream input; input.open("../testfiles/rawIDs.txt"); while (!input.eof()) { input >> pID; test.push_back(pID); } input.close(); countID qr; qr.getCount(test); EXPECT_EQ(sample, qr.ID); }
206afb6fe847118b75c19183db35cd1e585fe82c
78801fff0194d10740cc200f6291ec02fbb6b56d
/DBSCAN-master/Damp/vect3d.cpp
0671ae374091704e31e2054928531d7e18b70847
[ "MIT" ]
permissive
NikitaMushchak/DBSCAN
f51f7bdd3bc192fa33b8fc6e2f0a9108ecf79ac8
73616381c8778da8b047cab44c50d9465bcb0f0d
refs/heads/master
2020-04-21T13:07:16.497335
2019-04-11T07:03:42
2019-04-11T07:03:42
169,587,809
0
0
null
null
null
null
UTF-8
C++
false
false
2,329
cpp
vect3d.cpp
//----------------------------------------------------------------------------------- // // 3D Vector class // // Anton M. Krivtsov // // 11.04.2001 // //----------------------------------------------------------------------------------- #include "vect3d.h" //#include "util.h" inline double rand(const double min, const double max) // Random double value from min to max { return min + (max - min) * (double)rand() / RAND_MAX; } //----------------------------------------------------------------------------------- double Vect3D::Abs() const { return sqrt(Sqr()); } //----------------------------------------------------------------------------------- void Vect3D::Swap(int mode) // mode = 0,1,2; default mode = 1 { if (!mode) return; double zz = z; if (mode == 1) { z = x; x = y; y = zz; return; } if (mode == 2) { z = y; y = x; x = zz; return; } } Vect3D Vect3D::GetSwapped(int mode) const // mode = 0,1,2; default mode = 1 { Vect3D r = *this; r.Swap(mode); return r; } //----------------------------------------------------------------------------------- void Vect3D::SetRand(const double x_min, const double y_min, const double z_min, const double x_max, const double y_max, const double z_max) { x = rand(x_min, x_max); y = rand(y_min, y_max); z = rand(z_min, z_max); } //----------------------------------------------------------------------------------- void Vect3D::SetRand(const double r_max) { double rr_max = r_max * r_max; do SetRand(-r_max, -r_max,0 , r_max,r_max , 0); while (Sqr() > rr_max); } //----------------------------------------------------------------------------------- // private //----------------------------------------------------------------------------------- void Vect3D::Rotate(double &x, double &y, const double sin_f, const double cos_f) { double x1; x1 = x * cos_f - y * sin_f; y = x * sin_f + y * cos_f; x = x1; } //----------------------------------------------------------------------------------- Vect3D ConvertXY(double ro,double fi,double zz) { long double x,y,z; x=ro*cos(fi); y=ro*sin(fi); z=zz; Vect3D A(x,y,z); return A; } //-----------------------------------------------------------------------------------
c3af7421ed66f6b357ead558e648fe583e59e5d9
88ae8695987ada722184307301e221e1ba3cc2fa
/v8/src/heap/objects-visiting-inl.h
c8af4430acbc7e9202e18a6749db6002dbd425b9
[ "BSD-3-Clause", "SunPro", "Apache-2.0" ]
permissive
iridium-browser/iridium-browser
71d9c5ff76e014e6900b825f67389ab0ccd01329
5ee297f53dc7f8e70183031cff62f37b0f19d25f
refs/heads/master
2023-08-03T16:44:16.844552
2023-07-20T15:17:00
2023-07-23T16:09:30
220,016,632
341
40
BSD-3-Clause
2021-08-13T13:54:45
2019-11-06T14:32:31
null
UTF-8
C++
false
false
15,254
h
objects-visiting-inl.h
// Copyright 2012 the V8 project 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 V8_HEAP_OBJECTS_VISITING_INL_H_ #define V8_HEAP_OBJECTS_VISITING_INL_H_ #include "src/base/logging.h" #include "src/heap/mark-compact.h" #include "src/heap/object-lock.h" #include "src/heap/objects-visiting.h" #include "src/objects/arguments.h" #include "src/objects/data-handler-inl.h" #include "src/objects/free-space-inl.h" #include "src/objects/js-array-buffer-inl.h" #include "src/objects/js-weak-refs-inl.h" #include "src/objects/module-inl.h" #include "src/objects/objects-body-descriptors-inl.h" #include "src/objects/objects-inl.h" #include "src/objects/oddball.h" #include "src/objects/ordered-hash-table.h" #include "src/objects/shared-function-info.h" #include "src/objects/synthetic-module-inl.h" #include "src/objects/torque-defined-classes.h" #include "src/objects/visitors.h" #if V8_ENABLE_WEBASSEMBLY #include "src/wasm/wasm-objects.h" #endif // V8_ENABLE_WEBASSEMBLY namespace v8 { namespace internal { template <VisitorId visitor_id> inline bool ContainsReadOnlyMap(PtrComprCageBase, HeapObject) { return false; } // List of visitor ids that can only appear in read-only maps. Unfortunately, // these are generally contained in all other lists. Adding an instance type // here optimizes handling in visitors that do not need to Map objects with such // visitor ids. #define READ_ONLY_MAPS_VISITOR_ID_LIST(V) \ V(AccessorInfo) \ V(AllocationSite) \ V(BigInt) \ V(BytecodeArray) \ V(ByteArray) \ V(CallHandlerInfo) \ V(Cell) \ V(Code) \ V(DataHandler) \ V(DataObject) \ V(DescriptorArray) \ V(EmbedderDataArray) \ V(ExternalString) \ V(FeedbackCell) \ V(FeedbackMetadata) \ V(FeedbackVector) \ V(FixedArray) \ V(FixedDoubleArray) \ V(InstructionStream) \ V(PreparseData) \ V(PropertyArray) \ V(PropertyCell) \ V(PrototypeInfo) \ V(ScopeInfo) \ V(SeqOneByteString) \ V(SeqTwoByteString) \ V(SharedFunctionInfo) \ V(ShortcutCandidate) \ V(SlicedString) \ V(SloppyArgumentsElements) \ V(Symbol) \ V(ThinString) \ V(TransitionArray) \ V(UncompiledDataWithoutPreparseData) \ V(UncompiledDataWithPreparseData) \ V(WeakArrayList) \ V(WeakFixedArray) #define DEFINE_READ_ONLY_MAP_SPECIALIZATION(VisitorIdType) \ template <> \ inline bool ContainsReadOnlyMap<VisitorId::kVisit##VisitorIdType>( \ PtrComprCageBase cage_base, HeapObject object) { \ /* If you see this DCHECK fail we encountered a Map with a VisitorId that \ * should have only ever appeared in read-only space. */ \ DCHECK(object.map(cage_base).InReadOnlySpace()); \ return true; \ } READ_ONLY_MAPS_VISITOR_ID_LIST(DEFINE_READ_ONLY_MAP_SPECIALIZATION) #undef DEFINE_READ_ONLY_MAP_SPECIALIZATION #undef READ_ONLY_MAPS_VISITOR_ID_LIST template <typename ResultType, typename ConcreteVisitor> HeapVisitor<ResultType, ConcreteVisitor>::HeapVisitor( PtrComprCageBase cage_base, PtrComprCageBase code_cage_base) : ObjectVisitorWithCageBases(cage_base, code_cage_base) {} template <typename ResultType, typename ConcreteVisitor> HeapVisitor<ResultType, ConcreteVisitor>::HeapVisitor(Isolate* isolate) : ObjectVisitorWithCageBases(isolate) {} template <typename ResultType, typename ConcreteVisitor> HeapVisitor<ResultType, ConcreteVisitor>::HeapVisitor(Heap* heap) : ObjectVisitorWithCageBases(heap) {} template <typename ResultType, typename ConcreteVisitor> template <typename T> T HeapVisitor<ResultType, ConcreteVisitor>::Cast(HeapObject object) { return T::cast(object); } template <typename ResultType, typename ConcreteVisitor> ResultType HeapVisitor<ResultType, ConcreteVisitor>::Visit(HeapObject object) { return Visit(object.map(cage_base()), object); } template <typename ResultType, typename ConcreteVisitor> ResultType HeapVisitor<ResultType, ConcreteVisitor>::Visit(Map map, HeapObject object) { ConcreteVisitor* visitor = static_cast<ConcreteVisitor*>(this); switch (map.visitor_id()) { #define CASE(TypeName) \ case kVisit##TypeName: \ return visitor->Visit##TypeName( \ map, ConcreteVisitor::template Cast<TypeName>(object)); TYPED_VISITOR_ID_LIST(CASE) TORQUE_VISITOR_ID_LIST(CASE) #undef CASE case kVisitShortcutCandidate: return visitor->VisitShortcutCandidate( map, ConcreteVisitor::template Cast<ConsString>(object)); case kVisitDataObject: return visitor->VisitDataObject(map, object); case kVisitJSObjectFast: return visitor->VisitJSObjectFast( map, ConcreteVisitor::template Cast<JSObject>(object)); case kVisitJSApiObject: return visitor->VisitJSApiObject( map, ConcreteVisitor::template Cast<JSObject>(object)); case kVisitStruct: return visitor->VisitStruct(map, object); case kVisitFreeSpace: return visitor->VisitFreeSpace(map, FreeSpace::cast(object)); case kDataOnlyVisitorIdCount: case kVisitorIdCount: UNREACHABLE(); } UNREACHABLE(); // Make the compiler happy. return ResultType(); } template <typename ResultType, typename ConcreteVisitor> template <VisitorId visitor_id> void HeapVisitor<ResultType, ConcreteVisitor>::VisitMapPointerIfNeeded( HeapObject host) { DCHECK(!host.map_word(cage_base(), kRelaxedLoad).IsForwardingAddress()); if constexpr (!ConcreteVisitor::ShouldVisitMapPointer()) { return; } if constexpr (!ConcreteVisitor::ShouldVisitReadOnlyMapPointer()) { if (ContainsReadOnlyMap<visitor_id>(cage_base(), host)) { return; } } static_cast<ConcreteVisitor*>(this)->VisitMapPointer(host); } #define VISIT(TypeName) \ template <typename ResultType, typename ConcreteVisitor> \ ResultType HeapVisitor<ResultType, ConcreteVisitor>::Visit##TypeName( \ Map map, TypeName object) { \ ConcreteVisitor* visitor = static_cast<ConcreteVisitor*>(this); \ /* If you see the following DCHECK fail, then the size computation of \ * BodyDescriptor doesn't match the size return via obj.Size(). This is \ * problematic as the GC requires those sizes to match for accounting \ * reasons. The fix likely involves adding a padding field in the object \ * defintions. */ \ DCHECK_EQ(object.SizeFromMap(map), \ TypeName::BodyDescriptor::SizeOf(map, object)); \ visitor->template VisitMapPointerIfNeeded<VisitorId::kVisit##TypeName>( \ object); \ const int size = TypeName::BodyDescriptor::SizeOf(map, object); \ TypeName::BodyDescriptor::IterateBody(map, object, size, visitor); \ return static_cast<ResultType>(size); \ } TYPED_VISITOR_ID_LIST(VISIT) TORQUE_VISITOR_ID_LIST(VISIT) #undef VISIT template <typename ResultType, typename ConcreteVisitor> ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitShortcutCandidate( Map map, ConsString object) { return static_cast<ConcreteVisitor*>(this)->VisitConsString(map, object); } template <typename ResultType, typename ConcreteVisitor> ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitDataObject( Map map, HeapObject object) { ConcreteVisitor* visitor = static_cast<ConcreteVisitor*>(this); int size = map.instance_size(); visitor->template VisitMapPointerIfNeeded<VisitorId::kVisitDataObject>( object); #ifdef V8_ENABLE_SANDBOX // The following types have external pointers, which must be visited. // TODO(v8:10391) Consider adding custom visitor IDs for these and making // this block not depend on V8_ENABLE_SANDBOX. if (object.IsForeign(cage_base())) { Foreign::BodyDescriptor::IterateBody(map, object, size, visitor); } #endif // V8_ENABLE_SANDBOX return static_cast<ResultType>(size); } template <typename ResultType, typename ConcreteVisitor> ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitJSObjectFast( Map map, JSObject object) { return VisitJSObjectSubclass<JSObject, JSObject::FastBodyDescriptor>(map, object); } template <typename ResultType, typename ConcreteVisitor> ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitJSApiObject( Map map, JSObject object) { return VisitJSObjectSubclass<JSObject, JSObject::BodyDescriptor>(map, object); } template <typename ResultType, typename ConcreteVisitor> ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitStruct( Map map, HeapObject object) { ConcreteVisitor* visitor = static_cast<ConcreteVisitor*>(this); int size = map.instance_size(); visitor->template VisitMapPointerIfNeeded<VisitorId::kVisitStruct>(object); StructBodyDescriptor::IterateBody(map, object, size, visitor); return static_cast<ResultType>(size); } template <typename ResultType, typename ConcreteVisitor> ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitFreeSpace( Map map, FreeSpace object) { ConcreteVisitor* visitor = static_cast<ConcreteVisitor*>(this); visitor->template VisitMapPointerIfNeeded<VisitorId::kVisitFreeSpace>(object); return static_cast<ResultType>(object.size(kRelaxedLoad)); } template <typename ResultType, typename ConcreteVisitor> template <typename T, typename TBodyDescriptor> ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitJSObjectSubclass( Map map, T object) { ConcreteVisitor* visitor = static_cast<ConcreteVisitor*>(this); visitor->template VisitMapPointerIfNeeded<VisitorId::kVisitJSObject>(object); const int size = TBodyDescriptor::SizeOf(map, object); const int used_size = map.UsedInstanceSize(); DCHECK_LE(used_size, size); DCHECK_GE(used_size, JSObject::GetHeaderSize(map)); // It is important to visit only the used field and ignore the slack fields // because the slack fields may be trimmed concurrently. For non-concurrent // visitors this merely is an optimization in that we only visit the actually // used fields. TBodyDescriptor::IterateBody(map, object, used_size, visitor); return size; } template <typename ResultType, typename ConcreteVisitor> ConcurrentHeapVisitor<ResultType, ConcreteVisitor>::ConcurrentHeapVisitor( Isolate* isolate) : HeapVisitor<ResultType, ConcreteVisitor>(isolate) {} template <typename T> struct ConcurrentVisitorCastHelper { static V8_INLINE T Cast(HeapObject object) { return T::cast(object); } }; #define UNCHECKED_CAST(VisitorId, TypeName) \ template <> \ V8_INLINE TypeName ConcurrentVisitorCastHelper<TypeName>::Cast( \ HeapObject object) { \ return TypeName::unchecked_cast(object); \ } SAFE_STRING_TRANSITION_SOURCES(UNCHECKED_CAST) // Casts are also needed for unsafe ones for the initial dispatch in // HeapVisitor. UNSAFE_STRING_TRANSITION_SOURCES(UNCHECKED_CAST) #undef UNCHECKED_CAST template <typename ResultType, typename ConcreteVisitor> template <typename T> T ConcurrentHeapVisitor<ResultType, ConcreteVisitor>::Cast(HeapObject object) { if constexpr (ConcreteVisitor::EnableConcurrentVisitation()) { return ConcurrentVisitorCastHelper<T>::Cast(object); } return T::cast(object); } #define VISIT_AS_LOCKED_STRING(VisitorId, TypeName) \ template <typename ResultType, typename ConcreteVisitor> \ ResultType \ ConcurrentHeapVisitor<ResultType, ConcreteVisitor>::Visit##TypeName( \ Map map, TypeName object) { \ if constexpr (ConcreteVisitor::EnableConcurrentVisitation()) { \ return VisitStringLocked(object); \ } \ return HeapVisitor<ResultType, ConcreteVisitor>::Visit##TypeName(map, \ object); \ } UNSAFE_STRING_TRANSITION_SOURCES(VISIT_AS_LOCKED_STRING) #undef VISIT_AS_LOCKED_STRING template <typename ResultType, typename ConcreteVisitor> template <typename T> ResultType ConcurrentHeapVisitor<ResultType, ConcreteVisitor>::VisitStringLocked(T object) { ConcreteVisitor* visitor = static_cast<ConcreteVisitor*>(this); SharedObjectLockGuard guard(object); // The object has been locked. At this point shared read access is // guaranteed but we must re-read the map and check whether the string has // transitioned. Map map = object.map(visitor->cage_base()); int size; switch (map.visitor_id()) { #define UNSAFE_STRING_TRANSITION_TARGET_CASE(VisitorIdType, TypeName) \ case kVisit##VisitorIdType: \ visitor \ ->template VisitMapPointerIfNeeded<VisitorId::kVisit##VisitorIdType>( \ object); \ size = TypeName::BodyDescriptor::SizeOf(map, object); \ TypeName::BodyDescriptor::IterateBody( \ map, TypeName::unchecked_cast(object), size, visitor); \ break; UNSAFE_STRING_TRANSITION_TARGETS(UNSAFE_STRING_TRANSITION_TARGET_CASE) #undef UNSAFE_STRING_TRANSITION_TARGET_CASE default: UNREACHABLE(); } return static_cast<ResultType>(size); ; } template <typename ConcreteVisitor> NewSpaceVisitor<ConcreteVisitor>::NewSpaceVisitor(Isolate* isolate) : ConcurrentHeapVisitor<int, ConcreteVisitor>(isolate) {} } // namespace internal } // namespace v8 #endif // V8_HEAP_OBJECTS_VISITING_INL_H_