blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 4 201 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 7 100 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 260
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 11.4k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 17
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 80
values | src_encoding stringclasses 28
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 8 9.86M | extension stringclasses 52
values | content stringlengths 8 9.86M | authors listlengths 1 1 | author stringlengths 0 119 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
189f72a20911629acc9d120c680eb6d0d8d95fb0 | 6d7ea0644846eefac0c13f5310fd4cd0cebb782a | /taskServer/taskServer/MgrMessage.cpp | c70f434f96324791e39823f234674a0fb42e8951 | [] | no_license | loyoen/Jet | a54a7120a8b8cafdb361fd68abe70204fe801bc0 | 37b64513a54a04d1803c2a9cc0803ba2ebf79a73 | refs/heads/master | 2016-09-06T11:44:16.061983 | 2014-09-22T13:37:44 | 2014-09-22T13:37:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,131 | cpp | #include "StdAfx.h"
#include "MgrMessage.h"
#include "Resource.h"
CMgrMessage* CMgrMessage::pThis = NULL;
CMgrMessage* CMgrMessage::getManager ( )
{
if ( NULL == pThis )
{
pThis = new CMgrMessage;
pThis->m_hWndGUI = NULL;
}
return pThis;
}
void CMgrMessage::postMsgToGUI ( UINT msgID, int wParam, char *pMsg )
{
if ( NULL == pThis )
return;
if ( NULL == pThis->m_hWndGUI )
{
// recycle the message space
if ( NULL != pMsg )
{
pThis->InsertMessageEntity ( pMsg );
}
return;
}
::PostMessage ( pThis->m_hWndGUI, msgID, (WPARAM)wParam, (LPARAM)pMsg );
}
void CMgrMessage::setWndGUI ( HWND hWnd )
{
CMgrMessage *p;
p = getManager ();
p->m_hWndGUI = hWnd;
}
CMgrMessage::CMgrMessage ( )
{
}
CMgrMessage::~CMgrMessage ( )
{
POSITION pos;
char * p = NULL;
if( !m_lstMsg.IsEmpty() )
{
for ( pos=m_lstMsg.GetHeadPosition(); pos!=NULL; )
{
p = (char*)m_lstMsg.GetNext(pos);
delete[] p;
}
m_lstMsg.RemoveAll();
}
if( !m_lstMsgAllocated.IsEmpty() )
{
for ( pos=m_lstMsgAllocated.GetHeadPosition(); pos!=NULL; )
{
p = (char*)m_lstMsgAllocated.GetNext(pos);
TRACE1("CMgrMessage Memory Leak Detected 0x%X\n",(void*)p);
delete[] p;
}
m_lstMsgAllocated.RemoveAll();
}
}
void CMgrMessage::InsertMessageEntity ( char *p )
{
if ( NULL == p )
return;
// initialzie buffer
ZeroMemory ( p, GUI_MSG_LENGTH );
// add to list
m_csMsg.Lock();
POSITION pos = m_lstMsgAllocated.Find((void*)p);
if ( NULL != pos )
m_lstMsgAllocated.RemoveAt(pos);
else
{
TRACE0("CMgrMessage::InsertMessageEntity recycle a message space that never allocated be4\n");
}
m_lstMsg.AddTail((void*)p);
m_csMsg.Unlock();
}
char* CMgrMessage::GetMessageEntity ( )
{
if ( NULL == pThis )
return NULL;
m_csMsg.Lock();
if ( pThis->m_lstMsg.IsEmpty() )
{
char *pMsg = new char[GUI_MSG_LENGTH];
if ( NULL != pMsg )
{
m_lstMsgAllocated.AddTail ( (void*)pMsg );
}
m_csMsg.Unlock();
return pMsg;
}
char *p = NULL;
p = (char*)pThis->m_lstMsg.RemoveHead();
m_lstMsgAllocated.AddTail ( (void*)p );
m_csMsg.Unlock();
return p;
}
| [
"loyoen@loyoen-PC.(none)"
] | loyoen@loyoen-PC.(none) |
0f0e74ede2a4fdd087511efbb003160d0fb0cf09 | 74583447ccdf3db61aebf5f1ad0ca3293584c46a | /src/Searcher.cpp | 7c46b2ae4d6948f675605069ff415285fde48029 | [] | no_license | aecio/RI-TP1 | 3acb14619798d797ef09cccc60dade8154100201 | d3dd254c10c81124f3fffd8234cf425712e8b086 | refs/heads/master | 2016-09-06T07:19:24.248154 | 2012-04-28T08:42:38 | 2012-04-28T08:42:38 | 1,616,980 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,345 | cpp | /*
* Searcher.cpp
*
* Created on: 18/04/2011
* Author: aecio
*/
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include "search/IndexSearcher.h"
#include "search/BooleanIndexSearcher.h"
#include "search/VSMIndexSearcher.h"
#include "search/BM25IndexSearcher.h"
#include "search/MultiFieldIndexSearcher.h"
#include "search/Hit.h"
#include "index/Pair.h"
#include "index/Doc.h"
using namespace std;
int main(int argc, char* argv[]){
enum IRModel {BM25, VECTOR, BOOLEAN, MULTIFIELD};
int maxHits = 10;
string directory = ".";
IndexSearcher* searcher;
IRModel model = MULTIFIELD;
//Parse comand line arguments
for(int i=0; i<argc; i++){
string param(argv[i]);
if(param == "--directory" || param == "-d"){
i++;
directory = string(argv[i]);
}
if(param == "--model" || param == "-m"){
i++;
string modelStr(argv[i]);
if(modelStr == "vector" || modelStr == "Vector" )
model = VECTOR;
else if(modelStr == "bm25" || modelStr == "BM25")
model = BM25;
}
if(param == "--maxHits" || param == "-h"){
i++;
maxHits = atoi(argv[i]);
}
}
cout << "Loading index...";
switch(model){
case VECTOR:
cout << "(using Vector Spacel Model)" << endl;
searcher = new VSMIndexSearcher(directory);
break;
case BM25:
cout << "(using BM25 Model)" << endl;
searcher = new BM25IndexSearcher(directory);
break;
default:
cout << "(using BM25 Model with MultiFieldSearcher)" << endl;
searcher = new MultiFieldIndexSearcher(directory);
break;
}
string query;
cout << "Type you query (and press ENTER): ";
getline(cin, query);
while(query != "sair"){
vector<Hit> hits = searcher->search(query, maxHits);
if(hits.size() == 0){
cout << endl << "Documents not found for your query. Try again." << endl;
} else {
cout << "Search results for: " << query << endl;
vector<Hit>::iterator it = hits.begin();
for(; it != hits.end(); it++){
cout << endl;
cout << it->doc.title << endl;
cout << it->doc.url << endl;
cout << "score: " << it->score << "\t";
cout << "docId: " << it->doc.id << "\t";
cout << "docLength: " << it->length << endl;
}
}
cout << "___________________________________________" << endl;
cout << endl << "Type you query (and press ENTER): ";
getline(cin, query);
}
return 0;
}
| [
"aecio.solando@gmail.com"
] | aecio.solando@gmail.com |
7a1d0f5659ac32b355cbdffea173df0f7f65ec73 | d25d74bad8c68ac8f2a29a22c6d6860290185254 | /lc649dota.cpp | 0a0c4d3a56856dc37378dc5b77c8126c5edb0aed | [] | no_license | ZhongZeng/Leetcode | 9b7e71838ff4ad80a6b85f680f449e53df24c5d2 | a16f8ea31c8af1a3275efcf234989da19ba1581e | refs/heads/master | 2021-07-14T19:32:49.911530 | 2021-03-29T04:25:54 | 2021-03-29T04:25:54 | 83,813,978 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 781 | cpp |
/*
Leetcode 649. Dota2 Senate
Related Topics
Greedy
Similar Questions
Teemo Attacking
Next challenges: Patching Array,
Find Permutation, Monotone Increasing Digits
Test Cases:
"RD"
"DR"
"RDDR"
"RDDDR"
"RDDDDRR"
"RRDDD"
Runtime: 6 ms
Your runtime beats 83.85 % of cpp submissions.
*/
class Solution {
public:
string predictPartyVictory(string senate) {
// greedy, 2-pointer
int r=senate[0]!='D'?1:-1;
for(string::iterator it=senate.begin()+1; it<senate.end(); it++){
if(*it!='D'){ // 'R'
if(0<r) r++;
r++;
}else{ // 'D'
if(r<0) r--;
r--;
}
}
return 0<r?"Radiant":"Dire";
}
};
| [
"noreply@github.com"
] | noreply@github.com |
f8492a7447d9f8645cfdde2d9d15cb54b4a8d4b6 | 86c531e1156d302cfa1b5fa85cd138e08da2a7a2 | /MATRIX.cpp | 0cda64320c97ad609c5236abe4b7adc83eedc5c7 | [] | no_license | phatbs21/Thuat-Toan | 397faed3e8b2a51e7a982dc4278362396a48335c | 684d30243be100ef558e252277e28c16e8bcf884 | refs/heads/main | 2023-08-30T20:43:36.115540 | 2021-09-01T15:55:21 | 2021-09-01T15:55:21 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,168 | cpp | #include <bits/stdc++.h>
#define nmax 40007
using namespace std;
long long n,k,st[nmax],ans=0,dem0=0;
long long a[nmax];
string s;
map <long long,long long> M;
int main()
{
ios_base::sync_with_stdio(0);
freopen("MATRIX.inp","r",stdin);
freopen("MATRIX.out","w",stdout);
cin >> k;
cin >> s;
n=s.size();
for (long i=0; i<n; i++)
{
a[i+1]=s[i]-48;
if (a[i+1]==0) dem0++;
st[i+1]=st[i]+a[i+1];
}
if (k==0)
{
long long dd=((n-1)*(n-1)+(n-1))/2;
ans=2*n*dem0-dem0*dem0+dem0*2*dd;
long long dem=0;
for (long i=1; i<=n-1; i++)
for (long j=i+1; j<=n; j++)
if (st[j]-st[i-1]==0) dem++;
dd=(n*n+n)/2-dem0;
ans=ans+2*dem*dd-dem*dem;
cout << ans;
return 0;
}
for (long i=1; i<=n; i++)
for (long j=i; j<=n; j++)
{
long long sum=st[j]-st[i-1];
if (sum!=0)
if (k%sum==0) M[sum]++;
}
for (long i=1; i<=n; i++)
for (long j=i; j<=n; j++)
{
long long sum=st[j]-st[i-1];
if (sum!=0)
if (k%sum==0) ans+=M[k/sum];
}
cout << ans;
}
| [
"53256916+phatbs21@users.noreply.github.com"
] | 53256916+phatbs21@users.noreply.github.com |
5c3afba302d1d12422780aecf140a3cf40ff45ad | 8ee5416ec56b9cc1d9ad2ce48cf690fa012c5ce4 | /PhysX.Net-3/Source/DebugTriangle.h | 4e35d6366b899deac9f260c27fd25e4526663aea | [] | no_license | HalcyonGrid/PhysX.net | a573e0ceb9153c3777e71cb9d1434c5d74589df6 | 2a4bfc7a6619091bb3be20cb058f65306e4d8bac | refs/heads/master | 2020-03-26T12:30:31.701484 | 2015-09-10T04:24:00 | 2015-09-10T04:24:00 | 144,896,344 | 3 | 2 | null | 2018-08-15T19:44:31 | 2018-08-15T19:44:30 | null | UTF-8 | C++ | false | false | 386 | h | #pragma once
namespace PhysX
{
[StructLayout(LayoutKind::Sequential)]
public value class DebugTriangle
{
public:
DebugTriangle(Vector3 point0, int color0, Vector3 point1, int color1, Vector3 point2, int color2);
property Vector3 Point0;
property int Color0;
property Vector3 Point1;
property int Color1;
property Vector3 Point2;
property int Color2;
};
}; | [
"david.daeschler@gmail.com"
] | david.daeschler@gmail.com |
f1efd7013ee7d7c545f6ad5ad7502a628015fac3 | 5c5ebf470edb69cc2bdfc63e725e6f162a37f80c | /OpenGLEngine/src/Mesh.cpp | 9f591b22a21a4c07431c56fd40b96b9b84741bfe | [] | no_license | nduplessis11/OpenGLEngine | 4cc037c01e2ebac91be8083b651359ceec7e0ceb | 93d3082285d3b4264406a627d4eb4a39982aadf7 | refs/heads/master | 2020-03-14T03:17:56.734947 | 2018-05-20T22:04:45 | 2018-05-20T22:04:45 | 131,416,843 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 478 | cpp | #include "Mesh.h"
Mesh::Mesh(const GLfloat* data, GLuint count, const GLuint* indices, GLuint indexCount, GLenum mode, const VertexLayout & vertexLayout)
: m_VertexBuffer(data, count), m_IndexBuffer(indices, indexCount)
{
m_VertexArray.AddIndexedVertexBuffer(m_VertexBuffer, m_IndexBuffer, vertexLayout);
m_DrawMode = mode;
m_IndexCount = indexCount;
}
Mesh::~Mesh()
{
}
void Mesh::SetDraw()
{
m_VertexArray.Bind();
}
void Mesh::UnsetDraw()
{
m_VertexArray.Unbind();
} | [
"nduplessis11@gmail.com"
] | nduplessis11@gmail.com |
d7be60adec29334b0cf51b4144738d07859e9479 | aa3dae78f12be4d281a9d5f9a3d094cbbac0e533 | /src/FELIX/evaluators/FELIX_Elliptic2DResidual_Def.hpp | d92395735fec88fab5a69d909955485dd42da488 | [
"BSD-2-Clause"
] | permissive | spectm2/Albany | 8e7c1006a89b570de2603fa8470d5682cf6677bf | fc2420c22e9ec9cc3e1a565fec891814a6c7e280 | refs/heads/master | 2020-09-24T23:04:29.741173 | 2016-07-20T16:23:30 | 2016-07-20T16:23:30 | 67,741,594 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 6,752 | hpp | //*****************************************************************//
// Albany 2.0: Copyright 2012 Sandia Corporation //
// This Software is released under the BSD license detailed //
// in the file "license.txt" in the top-level Albany directory //
//*****************************************************************//
#include "Phalanx_DataLayout.hpp"
#include "Phalanx_TypeStrings.hpp"
#include "FELIX_HomotopyParameter.hpp"
//uncomment the following line if you want debug output to be printed to screen
#define OUTPUT_TO_SCREEN
namespace FELIX {
//**********************************************************************
template<typename EvalT, typename Traits>
Elliptic2DResidual<EvalT, Traits>::Elliptic2DResidual (const Teuchos::ParameterList& p,
const Teuchos::RCP<Albany::Layouts>& dl) :
u (p.get<std::string> ("Solution QP Variable Name"), dl->qp_scalar),
grad_u (p.get<std::string> ("Solution Gradient QP Variable Name"), dl->qp_gradient),
BF (p.get<std::string> ("BF Variable Name"), dl->node_qp_scalar),
GradBF (p.get<std::string> ("Gradient BF Variable Name"), dl->node_qp_gradient),
coords (p.get<std::string> ("Coordinate Vector Variable Name"),dl->vertices_vector),
residual (p.get<std::string> ("Residual Variable Name"),dl->node_scalar),
w_measure (p.get<std::string> ("Weighted Measure Variable Name"), dl->qp_scalar)
{
sideSetEquation = p.get<bool>("Side Equation");
if (sideSetEquation)
{
TEUCHOS_TEST_FOR_EXCEPTION (!dl->isSideLayouts, Teuchos::Exceptions::InvalidParameter,
"Error! The layout structure does not appear to be that of a side set.\n");
inv_metric = PHX::MDField<RealType,Cell,Side,QuadPoint,Dim,Dim>(p.get<std::string> ("Inverse Metric Name"), dl->qp_tensor);
this->addDependentField(inv_metric);
sideSetName = p.get<std::string>("Side Set Name");
int numSides = dl->cell_gradient->dimension(1);
numNodes = dl->node_scalar->dimension(2);
numQPs = dl->qp_scalar->dimension(2);
int sideDim = dl->cell_gradient->dimension(2);
// Index of the nodes on the sides in the numeration of the cell
Teuchos::RCP<shards::CellTopology> cellType;
cellType = p.get<Teuchos::RCP <shards::CellTopology> > ("Cell Type");
sideNodes.resize(numSides);
for (int side=0; side<numSides; ++side)
{
sideNodes[side].resize(numNodes);
for (int node=0; node<numNodes; ++node)
sideNodes[side][node] = cellType->getNodeMap(sideDim,side,node);
}
}
else
{
numNodes = dl->node_scalar->dimension(1);
numQPs = dl->qp_scalar->dimension(1);
}
gradDim = 2;
this->addDependentField(u);
this->addDependentField(grad_u);
this->addDependentField(BF);
this->addDependentField(GradBF);
this->addDependentField(coords);
this->addEvaluatedField(residual);
this->setName("Elliptic2DResidual"+PHX::typeAsString<EvalT>());
}
//**********************************************************************
template<typename EvalT, typename Traits>
void Elliptic2DResidual<EvalT, Traits>::
postRegistrationSetup(typename Traits::SetupData d,
PHX::FieldManager<Traits>& fm)
{
if (sideSetEquation)
{
this->utils.setFieldData(inv_metric,fm);
}
this->utils.setFieldData(coords,fm);
this->utils.setFieldData(u,fm);
this->utils.setFieldData(grad_u,fm);
this->utils.setFieldData(BF,fm);
this->utils.setFieldData(GradBF,fm);
this->utils.setFieldData(w_measure,fm);
this->utils.setFieldData(residual,fm);
}
//**********************************************************************
template<typename EvalT, typename Traits>
void Elliptic2DResidual<EvalT, Traits>::evaluateFields (typename Traits::EvalData workset)
{
for (int cell(0); cell<workset.numCells; ++cell)
{
for (int node(0); node<numNodes; ++node)
{
residual(cell,node) = 0;
}
}
if (sideSetEquation)
{
const Albany::SideSetList& ssList = *(workset.sideSets);
Albany::SideSetList::const_iterator it_ss = ssList.find(sideSetName);
if (it_ss==ssList.end())
return;
const std::vector<Albany::SideStruct>& sideSet = it_ss->second;
std::vector<Albany::SideStruct>::const_iterator iter_s;
for (iter_s=sideSet.begin(); iter_s!=sideSet.end(); ++iter_s)
{
// Get the local data of side and cell
const int cell = iter_s->elem_LID;
const int side = iter_s->side_local_id;
std::vector<ScalarT> f_qp(numQPs,0);
for (int qp=0; qp<numQPs; ++qp)
{
for (int idim=0; idim<gradDim; ++idim)
{
MeshScalarT x_qp = 0;
for (int node=0; node<numNodes; ++node)
x_qp += coords(cell,sideNodes[side][node],idim)*BF(cell,side,node,qp);
f_qp[qp] += std::pow(x_qp-0.5,2);
}
f_qp[qp] -= 4.0;
}
for (int node=0; node<numNodes; ++node)
{
for (int qp=0; qp<numQPs; ++qp)
{
for (int idim(0); idim<gradDim; ++idim)
{
for (int jdim(0); jdim<gradDim; ++jdim)
{
residual(cell,sideNodes[side][node]) -= grad_u(cell,side,qp,idim)
* inv_metric(cell,side,qp,idim,jdim)
* GradBF(cell,side,node,qp,jdim)
* w_measure(cell,side,qp);
}
}
residual(cell,sideNodes[side][node]) -= u(cell,side,qp) * BF(cell,side,node,qp) * w_measure(cell,side,qp);
residual(cell,sideNodes[side][node]) += f_qp[qp] * BF(cell,side,node,qp) * w_measure(cell,side,qp);
}
}
}
}
else
{
for (int cell(0); cell<workset.numCells; ++cell)
{
std::vector<ScalarT> f_qp(numQPs,0);
for (int qp=0; qp<numQPs; ++qp)
{
for (int idim=0; idim<gradDim; ++idim)
{
MeshScalarT x_qp = 0;
for (int node=0; node<numNodes; ++node)
x_qp += coords(cell,node,idim)*BF(cell,node,qp);
f_qp[qp] += std::pow(x_qp-0.5,2);
}
f_qp[qp] -= 4.0;
}
for (int node(0); node<numNodes; ++node)
{
residual(cell,node) = 0;
for (int qp=0; qp<numQPs; ++qp)
{
for (int idim(0); idim<gradDim; ++idim)
{
residual(cell,node) -= grad_u(cell,qp,idim)*GradBF(cell,node,qp,idim)*w_measure(cell,qp);
}
residual(cell,node) -= u(cell,qp)*BF(cell,node,qp)*w_measure(cell,qp);
residual(cell,node) += f_qp[qp]*BF(cell,node,qp)*w_measure(cell,qp);
}
}
}
}
}
} // Namespace FELIX
| [
"luca.bertagna84@gmail.com"
] | luca.bertagna84@gmail.com |
f42015fac3cee2370751d54184c0424b015e9faa | 3478ccef99c85458a9043a1040bc91e6817cc136 | /HFrame/HModule/events/broadcasters/ActionBroadcaster.cpp | f79da0a98a1e412076e0d1a2079c6c91917b366b | [] | no_license | gybing/Hackett | a1183dada6eff28736ebab52397c282809be0e7b | f2b47d8cc3d8fa9f0d9cd9aa71b707c2a01b8a50 | refs/heads/master | 2020-07-25T22:58:59.712615 | 2019-07-09T09:40:00 | 2019-07-09T09:40:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,866 | cpp |
class ActionBroadcaster::ActionMessage : public MessageManager::MessageBase
{
public:
ActionMessage (const ActionBroadcaster* ab,
const String& messageText, ActionListener* l) noexcept
: broadcaster (const_cast<ActionBroadcaster*> (ab)),
message (messageText),
listener (l)
{}
void messageCallback() override
{
if (auto b = broadcaster.get())
if (b->actionListeners.contains (listener))
listener->actionListenerCallback (message);
}
private:
WeakReference<ActionBroadcaster> broadcaster;
const String message;
ActionListener* const listener;
HDECLARE_NON_COPYABLE (ActionMessage)
};
//==============================================================================
ActionBroadcaster::ActionBroadcaster()
{
// are you trying to create this object before or after H has been intialised??
HASSERT_MESSAGE_MANAGER_EXISTS
}
ActionBroadcaster::~ActionBroadcaster()
{
// all event-based objects must be deleted BEFORE H is shut down!
HASSERT_MESSAGE_MANAGER_EXISTS
}
void ActionBroadcaster::addActionListener (ActionListener* const listener)
{
const ScopedLock sl (actionListenerLock);
if (listener != nullptr)
actionListeners.add (listener);
}
void ActionBroadcaster::removeActionListener (ActionListener* const listener)
{
const ScopedLock sl (actionListenerLock);
actionListeners.removeValue (listener);
}
void ActionBroadcaster::removeAllActionListeners()
{
const ScopedLock sl (actionListenerLock);
actionListeners.clear();
}
void ActionBroadcaster::sendActionMessage (const String& message) const
{
const ScopedLock sl (actionListenerLock);
for (int i = actionListeners.size(); --i >= 0;)
(new ActionMessage (this, message, actionListeners.getUnchecked(i)))->post();
}
| [
"23925493@qq.com"
] | 23925493@qq.com |
932e4a198ae4912832342050581d5372e9d3b247 | e9d6b85cb8f16678e45f2493922b9ef53dd0197a | /sources/trabajo_practico_06/main.cpp | 2878fb8aa381013119c9c2b208eac8e10851028f | [] | no_license | dqmdz/Computacion.2018.Quinteros.Daniel | 2c1e0fe725ceb454e954d2bde128907c24cd469f | 8bcd56dbd6db5f95d9878d8c0da78b9913187b0d | refs/heads/master | 2021-04-06T08:52:02.223958 | 2018-06-28T18:36:24 | 2018-06-28T18:36:24 | 125,375,003 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 495 | cpp | /*
* main.cpp
*
* Created on: 3 may. 2018
* Author: dquinteros
*/
#include "Stack.h"
#include <iostream>
using namespace std;
int main() {
Stack p;
cout << "Test pop " << p.pop() << endl << endl;
p.push(2);
p.show();
cout << endl;
p.push(7);
p.show();
cout << endl;
p.push(1);
p.show();
cout << endl;
cout << "Pop: " << p.pop() << endl;
cout << "Pop: " << p.pop() << endl;
cout << "Pop: " << p.pop() << endl;
cout << "Pop: " << p.pop() << endl;
return 0;
}
| [
"daniel.quinterospinto@gmail.com"
] | daniel.quinterospinto@gmail.com |
185c5d6a985826ee59715f43efcd38df94e5d72e | 030c53fc0047f3882f7b1be97634f0dee95d75d1 | /OpenBMP/BmpUtil/BmpUtil/main.cpp | 8c43409255d9ae99db3b56cace9828a07d99a581 | [] | no_license | shaobozhong/MyImageprocessCode | a05f57877a44be776e65466ccb9968592af578fd | 09ccc6a28ca113daa61c0d0e8a3355dd4bc5c709 | refs/heads/master | 2020-12-24T15:13:39.344390 | 2014-04-23T12:07:35 | 2014-04-23T12:07:35 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,000 | cpp |
#include<stdio.h>
#include "BmpUtil.h"
#include <stdlib.h>
int main(){
char filename[] = "C:\\lena\\4.bmp";
char savename[] = "C:\\lena\\4_save.bmp";
printf("%s\n",filename);
printf("%s\n",savename);
BITMAPFILEHEADER bf;
BITMAPINFOHEADER bi;
byte** data = 0;
int ret = 0;
ret = loadBitmap(filename, &bf, &bi, &data);
if( ret != 0 ){
printf("load bitmap failed! error:%d\n", ret );
return -1;
}else{
printf("load bitmap success!\n" );
}
/*
int width = bi._bm_image_width;
int height = bi._bm_image_height;
for(int i=0; i<height; i++){
for( int j=0; j<width ; j++){
printf("%d ",data[i][j]);
}
printf("\n");
}
*/
ret = saveBitmap(savename, &bf, &bi, data );
if( ret != 0 ){
printf("save bitmap failed! error:%d\n", ret );
return -1;
}else{
printf("save bitmap success!\n" );
}
int height = bi._bm_image_height;
for(int i=0; i<height; i++){
free(data[i]);
}
free(data);
data = 0;
return 0;
} | [
"bozhongshao@gmail.com"
] | bozhongshao@gmail.com |
6d4a72164c44b633e8038bdfe093a1cd7d158b87 | 323f421ebf607f491d080caca78ce4a1f9ba97ad | /src/rosThread.h | 77f28276782f05617e470b5aafd45fd9416bad16 | [] | no_license | hlkbyrm/taskObserverISLH | e6a9f435dd77723635eead26f135501fc20e21c9 | 388ec79d4e5121271cd7b85d9d5726e4a532f9cc | refs/heads/master | 2020-05-20T11:30:08.715857 | 2014-10-26T14:59:30 | 2014-10-26T14:59:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,133 | h | #include <ros/ros.h>
#include <QTimer>
#include <QVector>
#include <QThread>
#include <QObject>
#include <QTime>
#include <QString>
#include <QtCore/QString>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
#include <ISLH_msgs/newTaskInfoMessage.h>
#include "std_msgs/UInt8.h"
#include <QUuid>
// task properties
struct taskProp{
QString taskID;
int handlingDuration; // in seconds - "the required time to handle the task"
int timeOutDuration; // in seconds - "the timed-out duration for the task"
QString requiredResources;
};
class RosThread:public QObject
{
Q_OBJECT
public:
RosThread();
private:
bool shutdown;
ros::NodeHandle n;
ros::Publisher messageNewTaskInfoPub;
ros::Subscriber messageTaskObserveOKSub;
bool taskObserveOK;
double taskLambda;
int numTasks;
QVector <taskProp> tasksList;
bool readConfigFile(QString filename);
void handleTaskObserveOK(std_msgs::UInt8 msg);
int queueSize;
public slots:
void work();
void shutdownROS();
signals:
void rosFinished();
void rosStarted();
void rosStartFailed();
};
| [
"haluk61@yahoo.com"
] | haluk61@yahoo.com |
29b899740b78785f807fb840f272fdf79c6a0aab | 181844929687fc3a8461965744b7adee3c7548b2 | /src/bvals/fc/bvals_fc.hpp | e5cd60d88386209e2ea1d64ab2e5b5bfa878daea | [
"BSD-3-Clause"
] | permissive | jzuhone/athena-public-version | d7111a49aade6f69f8b500d873f4acb2ac1f3d67 | fb7931cf59510f6823ca0548fe91e32fd6aecbf8 | refs/heads/master | 2023-02-08T01:50:11.100579 | 2021-01-02T03:16:59 | 2021-01-02T03:16:59 | 286,030,268 | 0 | 0 | BSD-3-Clause | 2020-08-08T11:28:42 | 2020-08-08T11:28:42 | null | UTF-8 | C++ | false | false | 8,013 | hpp | #ifndef BVALS_FC_BVALS_FC_HPP_
#define BVALS_FC_BVALS_FC_HPP_
//========================================================================================
// Athena++ astrophysical MHD code
// Copyright(C) 2014 James M. Stone <jmstone@princeton.edu> and other code contributors
// Licensed under the 3-clause BSD License, see LICENSE file for details
//========================================================================================
//! \file bvals_fc.hpp
// \brief handle boundaries for any FaceField type variable that represents a physical
// quantity indexed along / located around face-centers of cells
// C headers
// C++ headers
// Athena++ classes headers
#include "../../athena.hpp"
#include "../../athena_arrays.hpp"
#include "../bvals.hpp"
#include "../bvals_interfaces.hpp"
// MPI headers
#ifdef MPI_PARALLEL
#include <mpi.h>
#endif
//----------------------------------------------------------------------------------------
//! \class FaceCenteredBoundaryVariable
// \brief
class FaceCenteredBoundaryVariable : public BoundaryVariable {
public:
FaceCenteredBoundaryVariable(MeshBlock *pmb, FaceField *var, FaceField &coarse_buf,
EdgeField &var_flux);
~FaceCenteredBoundaryVariable();
// may want to rebind var_fc to b, b1, b2, etc. Hence ptr member, not reference
FaceField *var_fc;
// unlke Hydro cons vs. prim, never need to rebind FaceCentered coarse_buf, so it can be
// a reference member: ---> must be initialized in initializer list; cannot pass nullptr
FaceField &coarse_buf;
AthenaArray<Real> &e1, &e2, &e3; // same for EdgeField
// maximum number of reserved unique "physics ID" component of MPI tag bitfield
// must correspond to the # of "int *phys_id_" private members, below. Convert to array?
static constexpr int max_phys_id = 5;
// BoundaryVariable:
int ComputeVariableBufferSize(const NeighborIndexes& ni, int cng) override;
int ComputeFluxCorrectionBufferSize(const NeighborIndexes& ni, int cng) override;
// BoundaryCommunication:
void SetupPersistentMPI() override;
void StartReceiving(BoundaryCommSubset phase) override;
void ClearBoundary(BoundaryCommSubset phase) override;
void StartReceivingShear(BoundaryCommSubset phase) override;
void ComputeShear(const Real time) override;
// BoundaryBuffer:
void ReceiveAndSetBoundariesWithWait() override;
void SetBoundaries() override;
void SendFluxCorrection() override;
bool ReceiveFluxCorrection() override;
// Shearing box Field
void SendShearingBoxBoundaryBuffers();
bool ReceiveShearingBoxBoundaryBuffers();
// Shearing box EMF
void SendEMFShearingBoxBoundaryCorrection();
bool ReceiveEMFShearingBoxBoundaryCorrection();
void RemapEMFShearingBoxBoundary();
// BoundaryPhysics:
void ReflectInnerX1(Real time, Real dt,
int il, int jl, int ju, int kl, int ku, int ngh) override;
void ReflectOuterX1(Real time, Real dt,
int iu, int jl, int ju, int kl, int ku, int ngh) override;
void ReflectInnerX2(Real time, Real dt,
int il, int iu, int jl, int kl, int ku, int ngh) override;
void ReflectOuterX2(Real time, Real dt,
int il, int iu, int ju, int kl, int ku, int ngh) override;
void ReflectInnerX3(Real time, Real dt,
int il, int iu, int jl, int ju, int kl, int ngh) override;
void ReflectOuterX3(Real time, Real dt,
int il, int iu, int jl, int ju, int ku, int ngh) override;
void OutflowInnerX1(Real time, Real dt,
int il, int jl, int ju, int kl, int ku, int ngh) override;
void OutflowOuterX1(Real time, Real dt,
int iu, int jl, int ju, int kl, int ku, int ngh) override;
void OutflowInnerX2(Real time, Real dt,
int il, int iu, int jl, int kl, int ku, int ngh) override;
void OutflowOuterX2(Real time, Real dt,
int il, int iu, int ju, int kl, int ku, int ngh) override;
void OutflowInnerX3(Real time, Real dt,
int il, int iu, int jl, int ju, int kl, int ngh) override;
void OutflowOuterX3(Real time, Real dt,
int il, int iu, int jl, int ju, int ku, int ngh) override;
void PolarWedgeInnerX2(Real time, Real dt,
int il, int iu, int jl, int kl, int ku, int ngh) override;
void PolarWedgeOuterX2(Real time, Real dt,
int il, int iu, int ju, int kl, int ku, int ngh) override;
//protected:
private:
BoundaryStatus *flux_north_flag_;
BoundaryStatus *flux_south_flag_;
Real **flux_north_send_, **flux_north_recv_;
Real **flux_south_send_, **flux_south_recv_;
const bool *flip_across_pole_;
bool edge_flag_[12];
int nedge_fine_[12];
// variable switch used in 2x functions, ReceiveFluxCorrection() and StartReceiving():
// ready to recv flux from same level and apply correction? false= 2nd pass for fine lvl
bool recv_flx_same_lvl_;
#ifdef MPI_PARALLEL
int fc_phys_id_, fc_flx_phys_id_, fc_flx_pole_phys_id_;
MPI_Request *req_flux_north_send_, *req_flux_north_recv_;
MPI_Request *req_flux_south_send_, *req_flux_south_recv_;
#endif
// BoundaryBuffer:
int LoadBoundaryBufferSameLevel(Real *buf, const NeighborBlock& nb) override;
void SetBoundarySameLevel(Real *buf, const NeighborBlock& nb) override;
int LoadBoundaryBufferToCoarser(Real *buf, const NeighborBlock& nb) override;
int LoadBoundaryBufferToFiner(Real *buf, const NeighborBlock& nb) override;
void SetBoundaryFromCoarser(Real *buf, const NeighborBlock& nb) override;
void SetBoundaryFromFiner(Real *buf, const NeighborBlock& nb) override;
void PolarBoundarySingleAzimuthalBlock() override;
// Face-centered/Field/EMF unique class methods:
// called in SetBoundaries() and ReceiveAndSetBoundariesWithWait()
void PolarFieldBoundaryAverage();
// all 3x only called in SendFluxCorrection():
int LoadFluxBoundaryBufferSameLevel(Real *buf, const NeighborBlock& nb);
int LoadFluxBoundaryBufferToCoarser(Real *buf, const NeighborBlock& nb);
int LoadFluxBoundaryBufferToPolar(Real *buf, const SimpleNeighborBlock &nb,
bool is_north);
// all 7x only called in ReceiveFluxCorrection():
void SetFluxBoundarySameLevel(Real *buf, const NeighborBlock& nb);
void SetFluxBoundaryFromFiner(Real *buf, const NeighborBlock& nb);
void SetFluxBoundaryFromPolar(Real **buf_list, int num_bufs, bool is_north);
void ClearCoarseFluxBoundary();
void AverageFluxBoundary(); // average flux from fine and equal lvls
void PolarFluxBoundarySingleAzimuthalBlock();
void CountFineEdges(); // called in SetupPersistentMPI()
void CopyPolarBufferSameProcess(const SimpleNeighborBlock& nb, int ssize,
int polar_block_index, bool is_north);
// Shearing box Field
FaceField shear_fc_[2];
FaceField shear_flx_fc_[2];
int shear_send_count_fc_[2][4], shear_recv_count_fc_[2][4];
#ifdef MPI_PARALLEL
int shear_fc_phys_id_;
#endif
void LoadShearing(FaceField &src, Real *buf, int nb);
void SetShearingBoxBoundarySameLevel(Real *buf, const int nb);
void RemapFlux(const int k, const int jinner, const int jouter, const int i,
const Real eps, const AthenaArray<Real> &var,
AthenaArray<Real> &flux);
// Shearing box EMF correction
EdgeField shear_var_emf_[2];
EdgeField shear_map_emf_[2];
EdgeField shear_flx_emf_[2];
int shear_send_count_emf_[2][4], shear_recv_count_emf_[2][4];
#ifdef MPI_PARALLEL
int shear_emf_phys_id_;
#endif
void LoadEMFShearing(EdgeField &src, Real *buf, const int nb);
void SetEMFShearingBoxBoundarySameLevel(EdgeField &dst, Real *buf, const int nb);
void ClearEMFShearing(EdgeField &work);
void RemapFluxEMF(const int k, const int jinner, const int jouter, const Real eps,
const AthenaArray<Real> &var, AthenaArray<Real> &flux);
};
#endif // BVALS_FC_BVALS_FC_HPP_
| [
"jmstone@admins-mbp.campus.ias.edu"
] | jmstone@admins-mbp.campus.ias.edu |
b2150420e4677cd88c24c476883d1aed55395625 | 29739cac274b681566c34bcf309a058d0622dfb8 | /test_server/test_server.cpp | d2d0d771b68e93afb1ac06fbab0f9c09ecddcf46 | [] | no_license | nkyriazis/net_message_exchange | 7139200e054d49408c41a55c1a91c9b756fd4fdd | e63077a4bc0a8c7f1b6291e2fee6804be9d81cd0 | refs/heads/master | 2021-03-24T09:29:37.686458 | 2009-06-30T21:59:04 | 2009-06-30T21:59:04 | 78,957,143 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,285 | cpp | // test_server.cpp : Defines the entry point for the console application.
//
#include "../net_message_exchange/net_message_exchange.h"
#include <iostream>
#include <boost/asio.hpp>
using namespace std;
struct message_dispatcher :
public net_message_exchange::message_const_visitor
{
bool visit(const net_message_exchange::message_name &msg)
{
cout << "Received : " << msg.name << endl;
return true;
}
bool visit(const net_message_exchange::message_time &msg)
{
cout << "Received : " << msg.hours << " : " << msg.minutes << " : " << msg.seconds << endl;
return true;
}
};
int main(int argc, char* argv[])
{
try
{
net_message_exchange::message_stream stream;
message_dispatcher visitor;
stream.receive_message()->accept(visitor);
stream.receive_message()->accept(visitor);
// boost::asio::io_service io;
// boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::tcp::v4(), 12345);
// boost::asio::ip::tcp::acceptor acceptor(io, endpoint);
// boost::asio::ip::tcp::iostream stream;
// acceptor.accept(*stream.rdbuf());
//
// string line;
// while(!getline(stream, line).eof())
// {
// cout << line << endl;
// }
}
catch(exception &e)
{
cout << e.what() << endl;
}
return 0;
}
| [
"kyriazis@0508e60b-1d6a-8a4c-990d-504edc3ad7b7"
] | kyriazis@0508e60b-1d6a-8a4c-990d-504edc3ad7b7 |
6594aebdd0a7494f541504e28fd7937200be0db3 | 8aa8d4fcfc2a988d7c3ea2f93844fb8c7604cb4f | /tryiing.cpp | 12308fa5c8642bc141ee5e77a88de03c1b09a452 | [] | no_license | i-arihant/binarysearch.com | 660f874beecc3ada9a2d73d4a02d666f4ad38bb0 | 7b06d4b3f4a812e25832f164450c53b3b12dcc09 | refs/heads/master | 2023-07-25T23:58:12.938780 | 2021-09-06T12:25:10 | 2021-09-06T12:25:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 567 | cpp | #include<bits/stdc++.h>
using namespace std;
static bool comp(pair<int,int> &a,pair<int,int> &b)
{
if(a.second==b.second)
return a.first<b.first;
else
return a.second>b.second;
}
vector<int> frequency(vector<int>& A)
{
unordered_map<int,int> nums;
for(int num:A)
nums[num]++;
vector<pair<int,int>> vec;
for(auto p:nums)
vec.push_back(p);
sort(vec.begin(),vec.end(),comp);
vector<int> ans{};
for(auto p:vec)
{
while(p.second--)
ans.push_back(p.first);
}
return ans;
} | [
"arihant.jain@thriwe.com"
] | arihant.jain@thriwe.com |
98f9670d26999f28ef3f9f0311b84d559070da8c | 45c84e64a486a3c48bd41a78e28252acbc0cc1b0 | /src/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_handler.h | 54adcf0577d445a03131a53de8e529423778a736 | [
"BSD-3-Clause",
"MIT"
] | permissive | stanleywxc/chromium-noupdator | 47f9cccc6256b1e5b0cb22c598b7a86f5453eb42 | 637f32e9bf9079f31430c9aa9c64a75247993a71 | refs/heads/master | 2022-12-03T22:00:20.940455 | 2019-10-04T16:29:31 | 2019-10-04T16:29:31 | 212,851,250 | 1 | 2 | MIT | 2022-11-17T09:51:04 | 2019-10-04T15:49:33 | null | UTF-8 | C++ | false | false | 1,895 | h | // Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_WEBUI_BLUETOOTH_INTERNALS_BLUETOOTH_INTERNALS_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_BLUETOOTH_INTERNALS_BLUETOOTH_INTERNALS_HANDLER_H_
#include "base/macros.h"
#include "chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals.mojom.h"
#include "device/bluetooth/bluetooth_adapter.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#if defined(OS_CHROMEOS)
class DebugLogsManager;
#endif
// Handles API requests from chrome://bluetooth-internals page by implementing
// mojom::BluetoothInternalsHandler.
class BluetoothInternalsHandler : public mojom::BluetoothInternalsHandler {
public:
explicit BluetoothInternalsHandler(
mojo::PendingReceiver<mojom::BluetoothInternalsHandler> receiver);
~BluetoothInternalsHandler() override;
#if defined(OS_CHROMEOS)
void set_debug_logs_manager(DebugLogsManager* debug_logs_manager) {
debug_logs_manager_ = debug_logs_manager;
}
#endif
// mojom::BluetoothInternalsHandler:
void GetAdapter(GetAdapterCallback callback) override;
void GetDebugLogsChangeHandler(
GetDebugLogsChangeHandlerCallback callback) override;
private:
void OnGetAdapter(GetAdapterCallback callback,
scoped_refptr<device::BluetoothAdapter> adapter);
mojo::Receiver<mojom::BluetoothInternalsHandler> receiver_;
#if defined(OS_CHROMEOS)
DebugLogsManager* debug_logs_manager_ = nullptr;
#endif
base::WeakPtrFactory<BluetoothInternalsHandler> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(BluetoothInternalsHandler);
};
#endif // CHROME_BROWSER_UI_WEBUI_BLUETOOTH_INTERNALS_BLUETOOTH_INTERNALS_HANDLER_H_
| [
"stanley@moon.lan"
] | stanley@moon.lan |
735ad1b28979ebe3e563b8fb057c1b215c08f288 | 02d9ea3dddc1b14b69d06c67f5973b98772fbcdc | /Legolas/BlockMatrix/Structures/Banded/BandedGaussSeidelSolver.cxx | 1515a74a1f9d49eded05ee9659b210bc4cae33d3 | [
"MIT"
] | permissive | LaurentPlagne/Legolas | 6c656e4e7dd478a77a62fc76f7c1c9101f48f61c | fdf533528baf7ab5fcb1db15d95d2387b3e3723c | refs/heads/master | 2023-03-05T07:19:43.167114 | 2020-01-26T13:44:05 | 2020-01-26T13:44:05 | 338,055,388 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,228 | cxx | #include "Legolas/BlockMatrix/Structures/Banded/BandedBlockMatrix.hxx"
#include "Legolas/BlockMatrix/Structures/Banded/BandedGaussSeidelSolver.hxx"
namespace Legolas{
BandedGaussSeidelSolver::BandedGaussSeidelSolver( void ):accumulatorPtr_(0){}
BandedGaussSeidelSolver::BandedGaussSeidelSolver(const BandedGaussSeidelSolver & source):accumulatorPtr_(0){}
BandedGaussSeidelSolver::~BandedGaussSeidelSolver( void ){
if (accumulatorPtr_){
delete accumulatorPtr_;
accumulatorPtr_=0;
}
}
void BandedGaussSeidelSolver::solve(const BandedVirtualBlockMatrix & A, const VirtualVector & B, VirtualVector & X){
this->iterationControler().initialize(A,X);
do {
const VirtualVector & B0=B.getElement(0);
VirtualVector & accumulator=VirtualVector::getClone(accumulatorPtr_,B0);
for (int i=A.beginRow() ; i < A.endRow() ; i++ ){
accumulator.copy(B.getElement(i));
for (int j=A.beginColInRow(i) ; j < A.endColInRow(i) ; j=A.nextColInRow(i,j) ){
if (i!=j) A.bandedGetElement(i,j).addMult(-1.0,X.getElement(j),accumulator);
}
A.bandedGetElement(i,i).solve(accumulator,X.getElement(i));
}
}while(!this->iterationControler().end(X));
}
}
| [
"laurent.plagne@gmail.com"
] | laurent.plagne@gmail.com |
173952e9fbbd101484bf491cc5d216a2016e30a9 | 971713859cee54860e32dce538a7d5e796487c68 | /unisim/unisim_docs/tms320c3x/registers_interface.cpp | b354a0b52f633e153a8cddd786057f99470c5baf | [] | no_license | binsec/cav2021-artifacts | 3d790f1e067d1ca9c4123010e3af522b85703e54 | ab9e387122968f827f7d4df696c2ca3d56229594 | refs/heads/main | 2023-04-15T17:10:10.228821 | 2021-04-26T15:10:20 | 2021-04-26T15:10:20 | 361,684,640 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 104 | cpp | class Registers
{
public:
virtual unisim::util::debug::Register *GetRegister(const char *name) = 0;
};
| [
"guillaume.girol@cea.fr"
] | guillaume.girol@cea.fr |
e124665055872439f7f06bf1fc718b9071406a76 | d7a5d1ce3bb7fbeb2031fa128acb994329ef6139 | /devel/include/agitr/WordCountResponse.h | da587bf5cabc40c79841d3a9e939eed8a5d6334f | [] | no_license | nitesh4146/ros-programs | c153e01a056f638f45b8889270e39b7ce57015ac | 00860998ad1ce658cb01d9b227e8633687ce557d | refs/heads/master | 2020-05-23T10:20:30.865792 | 2017-03-03T06:38:31 | 2017-03-03T06:38:31 | 80,420,908 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,966 | h | // Generated by gencpp from file agitr/WordCountResponse.msg
// DO NOT EDIT!
#ifndef AGITR_MESSAGE_WORDCOUNTRESPONSE_H
#define AGITR_MESSAGE_WORDCOUNTRESPONSE_H
#include <string>
#include <vector>
#include <map>
#include <ros/types.h>
#include <ros/serialization.h>
#include <ros/builtin_message_traits.h>
#include <ros/message_operations.h>
namespace agitr
{
template <class ContainerAllocator>
struct WordCountResponse_
{
typedef WordCountResponse_<ContainerAllocator> Type;
WordCountResponse_()
: count(0) {
}
WordCountResponse_(const ContainerAllocator& _alloc)
: count(0) {
(void)_alloc;
}
typedef uint32_t _count_type;
_count_type count;
typedef boost::shared_ptr< ::agitr::WordCountResponse_<ContainerAllocator> > Ptr;
typedef boost::shared_ptr< ::agitr::WordCountResponse_<ContainerAllocator> const> ConstPtr;
}; // struct WordCountResponse_
typedef ::agitr::WordCountResponse_<std::allocator<void> > WordCountResponse;
typedef boost::shared_ptr< ::agitr::WordCountResponse > WordCountResponsePtr;
typedef boost::shared_ptr< ::agitr::WordCountResponse const> WordCountResponseConstPtr;
// constants requiring out of line definition
template<typename ContainerAllocator>
std::ostream& operator<<(std::ostream& s, const ::agitr::WordCountResponse_<ContainerAllocator> & v)
{
ros::message_operations::Printer< ::agitr::WordCountResponse_<ContainerAllocator> >::stream(s, "", v);
return s;
}
} // namespace agitr
namespace ros
{
namespace message_traits
{
// BOOLTRAITS {'IsFixedSize': True, 'IsMessage': True, 'HasHeader': False}
// {'actionlib_msgs': ['/opt/ros/indigo/share/actionlib_msgs/cmake/../msg'], 'std_msgs': ['/opt/ros/indigo/share/std_msgs/cmake/../msg'], 'agitr': ['/home/nitish/Documents/ros-programs/devel/share/agitr/msg']}
// !!!!!!!!!!! ['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_parsed_fields', 'constants', 'fields', 'full_name', 'has_header', 'header_present', 'names', 'package', 'parsed_fields', 'short_name', 'text', 'types']
template <class ContainerAllocator>
struct IsFixedSize< ::agitr::WordCountResponse_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct IsFixedSize< ::agitr::WordCountResponse_<ContainerAllocator> const>
: TrueType
{ };
template <class ContainerAllocator>
struct IsMessage< ::agitr::WordCountResponse_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct IsMessage< ::agitr::WordCountResponse_<ContainerAllocator> const>
: TrueType
{ };
template <class ContainerAllocator>
struct HasHeader< ::agitr::WordCountResponse_<ContainerAllocator> >
: FalseType
{ };
template <class ContainerAllocator>
struct HasHeader< ::agitr::WordCountResponse_<ContainerAllocator> const>
: FalseType
{ };
template<class ContainerAllocator>
struct MD5Sum< ::agitr::WordCountResponse_<ContainerAllocator> >
{
static const char* value()
{
return "ac8b22eb02c1f433e0a55ee9aac59a18";
}
static const char* value(const ::agitr::WordCountResponse_<ContainerAllocator>&) { return value(); }
static const uint64_t static_value1 = 0xac8b22eb02c1f433ULL;
static const uint64_t static_value2 = 0xe0a55ee9aac59a18ULL;
};
template<class ContainerAllocator>
struct DataType< ::agitr::WordCountResponse_<ContainerAllocator> >
{
static const char* value()
{
return "agitr/WordCountResponse";
}
static const char* value(const ::agitr::WordCountResponse_<ContainerAllocator>&) { return value(); }
};
template<class ContainerAllocator>
struct Definition< ::agitr::WordCountResponse_<ContainerAllocator> >
{
static const char* value()
{
return "uint32 count\n\
\n\
";
}
static const char* value(const ::agitr::WordCountResponse_<ContainerAllocator>&) { return value(); }
};
} // namespace message_traits
} // namespace ros
namespace ros
{
namespace serialization
{
template<class ContainerAllocator> struct Serializer< ::agitr::WordCountResponse_<ContainerAllocator> >
{
template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m)
{
stream.next(m.count);
}
ROS_DECLARE_ALLINONE_SERIALIZER
}; // struct WordCountResponse_
} // namespace serialization
} // namespace ros
namespace ros
{
namespace message_operations
{
template<class ContainerAllocator>
struct Printer< ::agitr::WordCountResponse_<ContainerAllocator> >
{
template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::agitr::WordCountResponse_<ContainerAllocator>& v)
{
s << indent << "count: ";
Printer<uint32_t>::stream(s, indent + " ", v.count);
}
};
} // namespace message_operations
} // namespace ros
#endif // AGITR_MESSAGE_WORDCOUNTRESPONSE_H
| [
"nitesh4146@gmail.com"
] | nitesh4146@gmail.com |
97d598b618583ced236fe384ffc4ebe8b02305b6 | da4a516d0be3eff27dd24028350d161164c1e62a | /include/Projector.h | 073edf1bd4c31287809af8d4130fea063848ccc0 | [] | no_license | gaoyuankidult/RLLib | c08ed237055a63c8e65eae0c4e69a6af42f97d6b | 059f5ea18067226462271bb3bdaaec63eb24ee43 | refs/heads/master | 2020-05-20T23:08:36.434139 | 2014-12-14T10:31:37 | 2014-12-14T10:31:37 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,848 | h | /*
* Copyright 2014 Saminda Abeyruwan (saminda@cs.miami.edu)
*
* 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.
*
* Projector.h
*
* Created on: Aug 18, 2012
* Author: sam
*/
#ifndef PROJECTOR_H_
#define PROJECTOR_H_
#include "Tiles.h"
#include "Vector.h"
#include "Action.h"
namespace RLLib
{
/**
* Feature extractor for function approximation.
* @class T feature type
*/
template<class T>
class Projector
{
public:
virtual ~Projector()
{
}
virtual const Vector<T>* project(const Vector<T>* x, const int& h1) =0;
virtual const Vector<T>* project(const Vector<T>* x) =0;
virtual T vectorNorm() const =0;
virtual int dimension() const =0;
};
/**
* @use
* http://incompleteideas.net/rlai.cs.ualberta.ca/RLAI/RLtoolkit/tiles.html
*/
template<class T>
class TileCoder: public Projector<T>
{
protected:
bool includeActiveFeature;
Vector<T>* vector;
int nbTilings;
public:
TileCoder(const int& memorySize, const int& nbTilings, bool includeActiveFeature = true) :
includeActiveFeature(includeActiveFeature), vector(
new SVector<T>(includeActiveFeature ? memorySize + 1 : memorySize)), nbTilings(
nbTilings)
{
}
virtual ~TileCoder()
{
delete vector;
}
virtual void coder(const Vector<T>* x) =0;
virtual void coder(const Vector<T>* x, const int& h1) =0;
const Vector<T>* project(const Vector<T>* x, const int& h1)
{
vector->clear();
if (x->empty())
return vector;
if (includeActiveFeature)
{
coder(x, h1);
vector->setEntry(vector->dimension() - 1, 1.0);
}
else
coder(x, h1);
return vector;
}
const Vector<T>* project(const Vector<T>* x)
{
vector->clear();
if (x->empty())
return vector;
if (includeActiveFeature)
{
coder(x);
vector->setEntry(vector->dimension() - 1, 1.0);
}
else
coder(x);
return vector;
}
T vectorNorm() const
{
return includeActiveFeature ? nbTilings + 1 : nbTilings;
}
int dimension() const
{
return vector->dimension();
}
};
template<class T>
class TileCoderHashing: public TileCoder<T>
{
private:
typedef TileCoder<T> Base;
Vector<T>* gridResolutions;
Vector<T>* inputs;
Tiles<T>* tiles;
public:
TileCoderHashing(Hashing<T>* hashing, const int& nbInputs, const T& gridResolution,
const int& nbTilings, const bool& includeActiveFeature = true) :
TileCoder<T>(hashing->getMemorySize(), nbTilings, includeActiveFeature), gridResolutions(
new PVector<T>(nbInputs)), inputs(new PVector<T>(nbInputs)), tiles(
new Tiles<T>(hashing))
{
gridResolutions->set(gridResolution);
}
TileCoderHashing(Hashing<T>* hashing, const int& nbInputs, Vector<T>* gridResolutions,
const int& nbTilings, const bool& includeActiveFeature = true) :
TileCoder<T>(hashing->getMemorySize(), nbTilings, includeActiveFeature), gridResolutions(
new PVector<T>(nbInputs)), inputs(new PVector<T>(nbInputs)), tiles(
new Tiles<T>(hashing))
{
this->gridResolutions->set(gridResolutions);
}
virtual ~TileCoderHashing()
{
delete inputs;
delete tiles;
}
void coder(const Vector<T>* x)
{
inputs->clear();
inputs->addToSelf(x)->ebeMultiplyToSelf(gridResolutions);
tiles->tiles(Base::vector, Base::nbTilings, inputs);
}
void coder(const Vector<T>* x, const int& h1)
{
inputs->clear();
inputs->addToSelf(x)->ebeMultiplyToSelf(gridResolutions);
tiles->tiles(Base::vector, Base::nbTilings, inputs, h1);
}
};
template<class T>
class FourierBasis: public Projector<T>
{
protected:
Vector<T>* featureVector;
std::vector<Vector<T>*> coefficientVectors;
public:
FourierBasis(const int& nbInputs, const int& order, const Actions<T>* actions)
{
computeFourierCoefficients(nbInputs, order);
featureVector = new PVector<T>(coefficientVectors.size() * actions->dimension());
}
virtual ~FourierBasis()
{
delete featureVector;
for (typename std::vector<Vector<T>*>::iterator iter = coefficientVectors.begin();
iter != coefficientVectors.end(); ++iter)
delete *iter;
}
/**
* x must be unit normalized [0, 1)
*/
const Vector<T>* project(const Vector<T>* x, const int& h1)
{
featureVector->clear();
if (x->empty())
return featureVector;
// FixMe: SIMD
const int stripWidth = coefficientVectors.size() * h1;
for (size_t i = 0; i < coefficientVectors.size(); i++)
featureVector->setEntry(i + stripWidth, std::cos(M_PI * x->dot(coefficientVectors[i])));
return featureVector;
}
const Vector<T>* project(const Vector<T>* x)
{
return project(x, 0);
}
T vectorNorm() const
{
return T(1); //FixMe:
}
int dimension() const
{
return featureVector->dimension();
}
const std::vector<Vector<T>*>& getCoefficientVectors() const
{
return coefficientVectors;
}
private:
inline void nextCoefficientVector(Vector<T>* coefficientVector, const int& nbInputs,
const int& order)
{
coefficientVector->setEntry(nbInputs - 1, coefficientVector->getEntry(nbInputs - 1) + 1);
if (coefficientVector->getEntry(nbInputs - 1) > order)
{
if (nbInputs > 1)
{
coefficientVector->setEntry(nbInputs - 1, 0);
nextCoefficientVector(coefficientVector, nbInputs - 1, order);
}
}
}
inline void computeFourierCoefficients(const int& nbInputs, const int& order)
{
Vector<T>* coefficientVector = new PVector<T>(nbInputs);
do
{
Vector<T>* newCoefficientVector = new PVector<T>(nbInputs);
newCoefficientVector->set(coefficientVector);
coefficientVectors.push_back(newCoefficientVector);
nextCoefficientVector(coefficientVector, nbInputs, order);
} while (coefficientVector->getEntry(0) <= order);
ASSERT(coefficientVectors.size() == std::pow(order + 1, nbInputs));
delete coefficientVector;
}
};
} // namespace RLLib
#endif /* PROJECTOR_H_ */
| [
"samindaa@gmail.com"
] | samindaa@gmail.com |
e1fcc386f6c9630a27577be3d794e8518b73b9fa | 7d2f9baf6f91dd95882e367eab0e565a311c71c3 | /2/2-13.cpp | f20cdadaf70b80f0b18a124cda01ccf54d0f2907 | [] | no_license | WillAlso/C-Practice | 969738b4900d843cb7acef06b949c61fd68bfcba | 5af26be8492d9068ac0ef99092630af9478e22c6 | refs/heads/master | 2021-04-27T04:03:48.553617 | 2018-04-28T13:34:11 | 2018-04-28T13:34:11 | 122,724,712 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 254 | cpp | #include <iostream>
#include <cmath>
using namespace std;
int main()
{
int i;
for(i = 2;i <= 10000;i++)
{
int sum = 0;
for(int m = 1;m < i;m++)
{
if(i % m == 0)
{
sum += m;
}
}
if(sum == i)
cout << i << endl;
}
return 0;
}
| [
"1481660657@qq.com"
] | 1481660657@qq.com |
8912469ebc3944cd5413a0fa62351228804d3213 | f6f15809ac70089ef4cfb1ade40e2dc58d239f81 | /depends/x86_64-w64-mingw32/include/QtNetwork/qnetworkaccessmanager.h | 84c78b1a6f70a116032cb5a5b6259c5ddd943e60 | [
"MIT"
] | permissive | lamyaim/bitgesell | fcc96f6765d3907ce923f411a1b2c6c4de9d55d6 | 64c24348f1ba8788fbffaf663b3df38d9b49a5d1 | refs/heads/master | 2023-04-30T08:16:40.735496 | 2020-12-10T05:23:08 | 2020-12-10T05:23:08 | 369,859,996 | 1 | 0 | MIT | 2021-05-22T16:50:56 | 2021-05-22T16:48:32 | null | UTF-8 | C++ | false | false | 7,957 | h | /****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QNETWORKACCESSMANAGER_H
#define QNETWORKACCESSMANAGER_H
#include <QtNetwork/qtnetworkglobal.h>
#include <QtNetwork/qnetworkrequest.h>
#include <QtCore/QVector>
#include <QtCore/QObject>
#ifndef QT_NO_SSL
#include <QtNetwork/QSslConfiguration>
#include <QtNetwork/QSslPreSharedKeyAuthenticator>
#endif
QT_BEGIN_NAMESPACE
class QIODevice;
class QAbstractNetworkCache;
class QAuthenticator;
class QByteArray;
template<typename T> class QList;
class QNetworkCookie;
class QNetworkCookieJar;
class QNetworkReply;
class QNetworkProxy;
class QNetworkProxyFactory;
class QSslError;
class QHstsPolicy;
#ifndef QT_NO_BEARERMANAGEMENT
class QNetworkConfiguration;
#endif
class QHttpMultiPart;
class QNetworkReplyImplPrivate;
class QNetworkAccessManagerPrivate;
class Q_NETWORK_EXPORT QNetworkAccessManager: public QObject
{
Q_OBJECT
#ifndef QT_NO_BEARERMANAGEMENT
Q_PROPERTY(NetworkAccessibility networkAccessible READ networkAccessible WRITE setNetworkAccessible NOTIFY networkAccessibleChanged)
#endif
public:
enum Operation {
HeadOperation = 1,
GetOperation,
PutOperation,
PostOperation,
DeleteOperation,
CustomOperation,
UnknownOperation = 0
};
#ifndef QT_NO_BEARERMANAGEMENT
enum NetworkAccessibility {
UnknownAccessibility = -1,
NotAccessible = 0,
Accessible = 1
};
Q_ENUM(NetworkAccessibility)
#endif
explicit QNetworkAccessManager(QObject *parent = Q_NULLPTR);
~QNetworkAccessManager();
// ### Qt 6: turn into virtual
QStringList supportedSchemes() const;
void clearAccessCache();
void clearConnectionCache();
#ifndef QT_NO_NETWORKPROXY
QNetworkProxy proxy() const;
void setProxy(const QNetworkProxy &proxy);
QNetworkProxyFactory *proxyFactory() const;
void setProxyFactory(QNetworkProxyFactory *factory);
#endif
QAbstractNetworkCache *cache() const;
void setCache(QAbstractNetworkCache *cache);
QNetworkCookieJar *cookieJar() const;
void setCookieJar(QNetworkCookieJar *cookieJar);
void setStrictTransportSecurityEnabled(bool enabled);
bool isStrictTransportSecurityEnabled() const;
void addStrictTransportSecurityHosts(const QVector<QHstsPolicy> &knownHosts);
QVector<QHstsPolicy> strictTransportSecurityHosts() const;
QNetworkReply *head(const QNetworkRequest &request);
QNetworkReply *get(const QNetworkRequest &request);
QNetworkReply *post(const QNetworkRequest &request, QIODevice *data);
QNetworkReply *post(const QNetworkRequest &request, const QByteArray &data);
QNetworkReply *put(const QNetworkRequest &request, QIODevice *data);
QNetworkReply *put(const QNetworkRequest &request, const QByteArray &data);
QNetworkReply *deleteResource(const QNetworkRequest &request);
QNetworkReply *sendCustomRequest(const QNetworkRequest &request, const QByteArray &verb, QIODevice *data = Q_NULLPTR);
QNetworkReply *sendCustomRequest(const QNetworkRequest &request, const QByteArray &verb, const QByteArray &data);
#if QT_CONFIG(http)
QNetworkReply *post(const QNetworkRequest &request, QHttpMultiPart *multiPart);
QNetworkReply *put(const QNetworkRequest &request, QHttpMultiPart *multiPart);
QNetworkReply *sendCustomRequest(const QNetworkRequest &request, const QByteArray &verb, QHttpMultiPart *multiPart);
#endif
#ifndef QT_NO_BEARERMANAGEMENT
void setConfiguration(const QNetworkConfiguration &config);
QNetworkConfiguration configuration() const;
QNetworkConfiguration activeConfiguration() const;
void setNetworkAccessible(NetworkAccessibility accessible);
NetworkAccessibility networkAccessible() const;
#endif
#ifndef QT_NO_SSL
void connectToHostEncrypted(const QString &hostName, quint16 port = 443,
const QSslConfiguration &sslConfiguration = QSslConfiguration::defaultConfiguration());
#endif
void connectToHost(const QString &hostName, quint16 port = 80);
void setRedirectPolicy(QNetworkRequest::RedirectPolicy policy);
QNetworkRequest::RedirectPolicy redirectPolicy() const;
Q_SIGNALS:
#ifndef QT_NO_NETWORKPROXY
void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator);
#endif
void authenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator);
void finished(QNetworkReply *reply);
#ifndef QT_NO_SSL
void encrypted(QNetworkReply *reply);
void sslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
void preSharedKeyAuthenticationRequired(QNetworkReply *reply, QSslPreSharedKeyAuthenticator *authenticator);
#endif
#ifndef QT_NO_BEARERMANAGEMENT
void networkSessionConnected();
void networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility accessible);
#endif
protected:
virtual QNetworkReply *createRequest(Operation op, const QNetworkRequest &request,
QIODevice *outgoingData = Q_NULLPTR);
protected Q_SLOTS:
QStringList supportedSchemesImplementation() const;
private:
friend class QNetworkReplyImplPrivate;
friend class QNetworkReplyHttpImpl;
friend class QNetworkReplyHttpImplPrivate;
friend class QNetworkReplyFileImpl;
Q_DECLARE_PRIVATE(QNetworkAccessManager)
Q_PRIVATE_SLOT(d_func(), void _q_replyFinished())
Q_PRIVATE_SLOT(d_func(), void _q_replyEncrypted())
Q_PRIVATE_SLOT(d_func(), void _q_replySslErrors(QList<QSslError>))
Q_PRIVATE_SLOT(d_func(), void _q_replyPreSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*))
#ifndef QT_NO_BEARERMANAGEMENT
Q_PRIVATE_SLOT(d_func(), void _q_networkSessionClosed())
Q_PRIVATE_SLOT(d_func(), void _q_networkSessionStateChanged(QNetworkSession::State))
Q_PRIVATE_SLOT(d_func(), void _q_onlineStateChanged(bool))
Q_PRIVATE_SLOT(d_func(), void _q_configurationChanged(const QNetworkConfiguration &))
Q_PRIVATE_SLOT(d_func(), void _q_networkSessionFailed(QNetworkSession::SessionError))
#endif
};
QT_END_NAMESPACE
#endif
| [
"quentin.neveu@hotmail.ca"
] | quentin.neveu@hotmail.ca |
4673b48843a6dbb7aeaaf5c82af0600ed5806bc9 | a4a8b5555a2807a8ec76e1ab343eb087c02d8cff | /LeetCode/54_Spiral_Matrix.cpp | 9b5a612395be66bbb50ac25f17135aca00c30dab | [] | no_license | ZSShen/IntrospectiveProgramming | 83267843d0d70d8f1882e29aff0c395ff2c3f7bc | 011954e2b1bf3cf9d0495100d4b2053f89b7ac64 | refs/heads/master | 2020-12-03T05:24:28.529360 | 2019-12-13T07:24:48 | 2019-12-13T07:24:48 | 37,024,879 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,841 | cpp | class Solution {
public:
vector<int> spiralOrder(vector<vector<int>>& matrix) {
std::vector<int> ans;
int m = matrix.size();
if (m == 0) {
return ans;
}
int n = matrix[0].size();
if (n == 0) {
return ans;
}
int bound_l = 0;
int bound_r = n - 1;
int bound_u = 0;
int bound_d = m - 1;
int r = 0, c = 0;
Direct direct = Direct::R;
for (int i = 0 ; i < m * n ; ++i) {
ans.push_back(matrix[r][c]);
switch (direct) {
case Direct::R:
++c;
if (c > bound_r) {
--c;
++r;
direct = Direct::D;
++bound_u;
}
break;
case Direct::D:
++r;
if (r > bound_d) {
--r;
--c;
direct = Direct::L;
--bound_r;
}
break;
case Direct::L:
--c;
if (c < bound_l) {
++c;
--r;
direct = Direct::U;
--bound_d;
}
break;
case Direct::U:
--r;
if (r < bound_u) {
++r;
++c;
direct = Direct::R;
++bound_l;
}
break;
}
}
return ans;
}
private:
enum Direct {
L,
R,
U,
D
};
};
| [
"andy.zsshen@gmail.com"
] | andy.zsshen@gmail.com |
7a59c44b8fb4f663b0fe1491b2f1ba674111e6e3 | 46f53e9a564192eed2f40dc927af6448f8608d13 | /net/quic/quic_write_blocked_list_test.cc | ec59268f00ae918ba5c30106575657637752a7fd | [
"BSD-3-Clause"
] | permissive | sgraham/nope | deb2d106a090d71ae882ac1e32e7c371f42eaca9 | f974e0c234388a330aab71a3e5bbf33c4dcfc33c | refs/heads/master | 2022-12-21T01:44:15.776329 | 2015-03-23T17:25:47 | 2015-03-23T17:25:47 | 32,344,868 | 2 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 5,139 | cc | // Copyright 2014 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 "net/quic/quic_write_blocked_list.h"
#include "net/quic/test_tools/quic_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace net {
namespace test {
namespace {
TEST(QuicWriteBlockedListTest, PriorityOrder) {
QuicWriteBlockedList write_blocked_list(true);
// Mark streams blocked in roughly reverse priority order, and
// verify that streams are sorted.
write_blocked_list.PushBack(40,
QuicWriteBlockedList::kLowestPriority);
write_blocked_list.PushBack(23,
QuicWriteBlockedList::kHighestPriority);
write_blocked_list.PushBack(17,
QuicWriteBlockedList::kHighestPriority);
write_blocked_list.PushBack(kHeadersStreamId,
QuicWriteBlockedList::kHighestPriority);
write_blocked_list.PushBack(kCryptoStreamId,
QuicWriteBlockedList::kHighestPriority);
EXPECT_EQ(5u, write_blocked_list.NumBlockedStreams());
EXPECT_TRUE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream());
EXPECT_TRUE(write_blocked_list.HasWriteBlockedDataStreams());
// The Crypto stream is highest priority.
EXPECT_EQ(kCryptoStreamId, write_blocked_list.PopFront());
// Followed by the Headers stream.
EXPECT_EQ(kHeadersStreamId, write_blocked_list.PopFront());
// Streams with same priority are popped in the order they were inserted.
EXPECT_EQ(23u, write_blocked_list.PopFront());
EXPECT_EQ(17u, write_blocked_list.PopFront());
// Low priority stream appears last.
EXPECT_EQ(40u, write_blocked_list.PopFront());
EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams());
EXPECT_FALSE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream());
EXPECT_FALSE(write_blocked_list.HasWriteBlockedDataStreams());
}
TEST(QuicWriteBlockedListTest, CryptoStream) {
QuicWriteBlockedList write_blocked_list(true);
write_blocked_list.PushBack(kCryptoStreamId,
QuicWriteBlockedList::kHighestPriority);
EXPECT_EQ(1u, write_blocked_list.NumBlockedStreams());
EXPECT_TRUE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream());
EXPECT_EQ(kCryptoStreamId, write_blocked_list.PopFront());
EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams());
EXPECT_FALSE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream());
}
TEST(QuicWriteBlockedListTest, HeadersStream) {
QuicWriteBlockedList write_blocked_list(true);
write_blocked_list.PushBack(kHeadersStreamId,
QuicWriteBlockedList::kHighestPriority);
EXPECT_EQ(1u, write_blocked_list.NumBlockedStreams());
EXPECT_TRUE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream());
EXPECT_EQ(kHeadersStreamId, write_blocked_list.PopFront());
EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams());
EXPECT_FALSE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream());
}
TEST(QuicWriteBlockedListTest, VerifyHeadersStream) {
QuicWriteBlockedList write_blocked_list(true);
write_blocked_list.PushBack(5,
QuicWriteBlockedList::kHighestPriority);
write_blocked_list.PushBack(kHeadersStreamId,
QuicWriteBlockedList::kHighestPriority);
EXPECT_EQ(2u, write_blocked_list.NumBlockedStreams());
EXPECT_TRUE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream());
EXPECT_TRUE(write_blocked_list.HasWriteBlockedDataStreams());
// In newer QUIC versions, there is a headers stream which is
// higher priority than data streams.
EXPECT_EQ(kHeadersStreamId, write_blocked_list.PopFront());
EXPECT_EQ(5u, write_blocked_list.PopFront());
EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams());
EXPECT_FALSE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream());
EXPECT_FALSE(write_blocked_list.HasWriteBlockedDataStreams());
}
TEST(QuicWriteBlockedListTest, NoDuplicateEntries) {
// Test that QuicWriteBlockedList doesn't allow duplicate entries.
QuicWriteBlockedList write_blocked_list(true);
// Try to add a stream to the write blocked list multiple times at the same
// priority.
const QuicStreamId kBlockedId = kClientDataStreamId1;
write_blocked_list.PushBack(kBlockedId,
QuicWriteBlockedList::kHighestPriority);
write_blocked_list.PushBack(kBlockedId,
QuicWriteBlockedList::kHighestPriority);
write_blocked_list.PushBack(kBlockedId,
QuicWriteBlockedList::kHighestPriority);
// This should only result in one blocked stream being added.
EXPECT_EQ(1u, write_blocked_list.NumBlockedStreams());
EXPECT_TRUE(write_blocked_list.HasWriteBlockedDataStreams());
// There should only be one stream to pop off the front.
EXPECT_EQ(kBlockedId, write_blocked_list.PopFront());
EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams());
EXPECT_FALSE(write_blocked_list.HasWriteBlockedDataStreams());
}
} // namespace
} // namespace test
} // namespace net
| [
"scottmg@chromium.org"
] | scottmg@chromium.org |
a57743421643c995ddc65514517136fc323a1986 | 8134e49b7c40c1a489de2cd4e7b8855f328b0fac | /utility/io/json_serializer.h | cb741613c8127819f3ddc42cb557c822f43cce1d | [
"Apache-2.0"
] | permissive | BeamMW/beam | 3efa193b22965397da26c1af2aebb2c045194d4d | 956a71ad4fedc5130cbbbced4359d38534f8a7a5 | refs/heads/master | 2023-09-01T12:00:09.204471 | 2023-08-31T09:22:40 | 2023-08-31T09:22:40 | 125,412,400 | 671 | 233 | Apache-2.0 | 2023-08-18T12:47:41 | 2018-03-15T18:49:06 | C++ | UTF-8 | C++ | false | false | 835 | h | // Copyright 2018 The Beam Team
//
// 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.
#pragma once
#include "utility/io/fragment_writer.h"
#include "nlohmann/json_fwd.hpp"
namespace beam {
// appends json msg to out by fragment writer
bool serialize_json_msg(io::FragmentWriter& packer, const nlohmann::json& o);
} //namespace
| [
"artem@beam-mw.com"
] | artem@beam-mw.com |
04a622e5f691dd66af370dfcf482bd51e82e63db | 7aed437c9e37a8d755c4d95f76a603f77d41d789 | /SharePic/MonitorProcess.h | a506db2d6b57cc090b906b8e1c9e30d371bdbe13 | [] | no_license | romatrix/SharePic | 6f46437169f914c3b77602aca65c02f4d9e7fea5 | 04e54ed7e603744b338b898c87e521969b03c18a | refs/heads/master | 2021-01-13T01:09:24.845710 | 2017-02-12T02:28:35 | 2017-02-12T02:28:35 | 81,480,405 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 552 | h | #include <Windows.h>
#include <thread>
#include <functional>
#pragma once
class MonitorProcess
{
public:
enum class ThreadState
{
eRunning,
eStopping,
eStopped
};
public:
MonitorProcess();
~MonitorProcess();
void start(HANDLE processHandle, std::function<void(void)> processEndNotifier);
void stop();
void terminateProcess();
private:
void runningThread();
private:
HANDLE mProcessHandle = nullptr;
std::thread mThread;
volatile ThreadState mThreadState = ThreadState::eStopped;
std::function<void(void)> mProcessEndNotifier;
};
| [
"roman.szul@gmail.com"
] | roman.szul@gmail.com |
4eb9a720b59787cda13934f46a23e5a810731dc3 | aaeb153afec0540401cdd4b6708bc8c938890f4c | /inc/device_driver/mpu6050.h | 78137fd7c02002edb0ffc16ceb1b9f94b7869ff5 | [] | no_license | hkust-smartcar/RTLib | e51a34a0823900be9b601838c95484252e64583a | dc538d776ccf8e158c5f4209bd5ce78a8e208692 | refs/heads/master | 2020-04-12T02:16:37.085303 | 2018-12-18T08:08:55 | 2018-12-18T08:08:55 | 162,243,857 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,896 | h | /*
* mpu6050.h
*
* Created on: Sep 21, 2018
* Author: LeeChunHei
*/
#ifndef INC_DEVICE_DRIVER_MPU6050_H_
#define INC_DEVICE_DRIVER_MPU6050_H_
#include "driver/i2c_master.h"
#include <array>
namespace DeviceDriver {
class MPU6050 {
public:
struct Config {
enum struct Range {
kSmall, kMid, kLarge, kExtreme,
};
uint8_t id;
// kSmall -> kExtreme = ±250°/s, ±500°/s, ±1000°/s, ±2000°/s
Range gyro_range;
// kSmall -> kExtreme = ±2g, ±4g, ±8g, ±16g
Range accel_range;
/// Calibrate the gyroscope while initializing
bool cal_drift = false;
Driver::I2CMaster* i2c_master = nullptr;
};
MPU6050(Config& config);
bool Update(bool clamp_ = true);
bool UpdateF(bool clamp_ = true);
const int32_t* GetAccel() const {
return accel;
}
const float* GetAccelF() const {
return accel_f;
}
const int32_t* GetOmega() const {
return omega;
}
const float* GetOmegaF() const {
return omega_f;
}
float GetCelsius() const {
return temp;
}
bool IsCalibrated() const {
return is_calibrated;
}
const int32_t* GetOffset() const {
return omega_offset;
}
const float* GetOffsetF() const {
return omega_offset_f;
}
bool Verify();
Driver::I2CMaster* GetI2cMaster() {
return i2c_master;
}
const uint16_t GetGyroScaleFactor(void) const {
return gyro_scale_factor;
}
const uint16_t GetAccelScaleFactor(void) const {
return accel_scale_factor;
}
private:
void Calibrate();
void CalibrateF();
uint16_t GetGyroScaleFactor();
uint16_t GetAccelScaleFactor();
Driver::I2CMaster* i2c_master;
int32_t accel[3];
int32_t omega[3];
float accel_f[3];
float omega_f[3];
int32_t omega_offset[3];
float omega_offset_f[3];
float temp;
bool is_calibrated;
uint16_t gyro_scale_factor;
uint16_t accel_scale_factor;
Config::Range gyro_range;
Config::Range accel_range;
};
}
#endif /* INC_DEVICE_DRIVER_MPU6050_H_ */
| [
"lch19980829@gmail.com"
] | lch19980829@gmail.com |
120805e98dba06ab4ed04d7492b2a9e68416462c | 70c37aa4bf9d06fa78c8ae1b0fb376cfa90aa95d | /Dynamic_programming/dynamic_programming.cpp | d2359498453e71429e354ce670ec904c5fb80b66 | [] | no_license | rohitsharmaj7/Summer_DP_codes | 23ae824f404c29cc47e9abbee8672885ae56dc97 | 251de211945dee6cc8ff22285a5210ec0f0d064d | refs/heads/master | 2020-06-11T05:44:24.231032 | 2019-06-26T08:49:01 | 2019-06-26T08:49:01 | 193,866,116 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 429 | cpp | //Dynamic programming
#include<iostream>
using namespace std;
int dp[100]={0};
int p=0;
int rec(int answer,int N,int step1,int step2)
{
if(answer==N)
{
return 1;
}
if(answer>N)
return 0;
if(dp[answer]!=0)
{
return dp[answer];
}
int l=rec(answer+step1,N,step1,step2);
int r=rec(answer+step2,N,step1,step2);
dp[answer]=l+r;
return l+r;
}
int main()
{
int n,s1,s2;
cin>>n>>s1>>s2;
cout<<rec(0,n,s1,s2);
}
| [
"rohitsharmaj7@gmail.com"
] | rohitsharmaj7@gmail.com |
25bc6ef35d4b477b5ecf619b3f6b4ca0cb48808a | f1fc349f2d4e876a070561a4c4d71c5e95fd33a4 | /ch09/9_24_access.cpp | a853f48c8832c025b3daf684747ac6ea6c50a875 | [] | no_license | sytu/cpp_primer | 9daccddd815fc0968008aa97e6bcfb36bbccd83d | 6cfb14370932e93c796290f40c70c153cc15db44 | refs/heads/master | 2021-01-17T19:03:48.738381 | 2017-04-13T10:35:43 | 2017-04-13T10:35:43 | 71,568,597 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 420 | cpp | #include <iostream>
#include <vector>
using std::cout; using std::cin; using std::endl; using std::string;
using std::vector;
int main(void) {
vector<int> ivec;
cout << ivec.at(0) << endl; // libc++abi.dylib: terminating with uncaught exception of type std::out_of_range: vector
cout << ivec[0] << endl;
cout << ivec.front() << endl; // segmentation fault
cout << *ivec.begin() << endl; // segmentation fault
} | [
"imsytu@163.com"
] | imsytu@163.com |
f9089e3ef03915084b2c85a4f6c59f9f8cd5f681 | aea7799cdf8ecb7b9304c8898767e91949f71d4b | /round3/construct-btree-from-preorder-inorder.cpp | 274c2c5c3e79ca547820940b5ae8486bf231d68e | [] | no_license | elsucai/LC | e2baab13168761519ae537176e42fa04607de88a | d5915a4efb6e16e2cea5f8d448ca72c2f8edcc9b | refs/heads/master | 2016-09-08T02:05:30.401990 | 2014-04-01T22:50:23 | 2014-04-01T22:50:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 902 | cpp | /**
* Definition for binary tree
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
TreeNode* helper(vector<int> &preorder, int ps, int pe, vector<int> &inorder, int is, int ie){
if(ps > pe)
return NULL;
int x;
int rootval = preorder[ps];
for(x = is; x <= ie; x++){
if(inorder[x] == rootval)
break;
}
int lsize = x-is;
TreeNode* root = new TreeNode(rootval);
root->left = helper(preorder, ps+1, ps+lsize, inorder, is, x-1);
root->right = helper(preorder, ps+lsize+1, pe, inorder, x+1, ie);
return root;
}
TreeNode *buildTree(vector<int> &preorder, vector<int> &inorder) {
if(preorder.empty() || preorder.size() != inorder.size())
return NULL;
return helper(preorder, 0, preorder.size()-1, inorder, 0, inorder.size()-1);
}
};
| [
"elsu@arcticfox"
] | elsu@arcticfox |
a798085054d9d0a588cef1ac2c9c5f8f7541c13f | f4ed037c807aecbb4d2f097503afc4fd9324c6fb | /CPP/C5/ex03/RobotomyRequestForm.hpp | ddd03ae9e4b2536b7d33f98a112f72080dc89ba3 | [] | no_license | Ukheon/42cursus | 0dd33e0bd77cee43299a5b4c02501c0c9f325f14 | bfc517834311d98243a9fd6e6a73fe936e63d719 | refs/heads/master | 2023-03-25T18:07:28.168106 | 2022-02-01T15:49:20 | 2022-02-01T15:49:20 | 307,604,142 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 560 | hpp | #ifndef ROBOTOMYREQUESTFORM_HPP
# define ROBOTOMYREQUESTFORM_HPP
# include "Form.hpp"
class Form;
class Bureaucrat;
class RobotomyRequestForm : public Form
{
private:
RobotomyRequestForm();
const std::string target;
public:
static const std::string name;
RobotomyRequestForm(RobotomyRequestForm const &type);
virtual ~RobotomyRequestForm();
RobotomyRequestForm(std::string const &target);
Form *clone(std::string const &target);
RobotomyRequestForm &operator=(RobotomyRequestForm const &type);
void execute(Bureaucrat const &type) const;
};
#endif
| [
"dnrgjs33@naver.com"
] | dnrgjs33@naver.com |
d500a2b30f86b3619304366f8617a31880e958fd | 6ae1aa70d46788fcfce031f51733b3c18715b45d | /src/tests/unit_tests/sph_kernels_tests.cpp | 198c96f407a43b404e89bfa9f2b168c12b399d2b | [
"BSD-3-Clause",
"MIT",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause"
] | permissive | dokipen3d/fluid-engine-dev | 3d4f3e4bb907feb00734e0fc1d47d2e86a89e3f0 | 0e26fbc19195ce4a21fb529a3de2d15b46c93050 | refs/heads/master | 2021-01-11T06:50:38.790287 | 2016-10-08T04:55:39 | 2016-10-08T04:55:39 | 72,378,941 | 4 | 1 | null | 2016-10-30T22:16:28 | 2016-10-30T22:16:28 | null | UTF-8 | C++ | false | false | 3,390 | cpp | // Copyright (c) 2016 Doyub Kim
#include <jet/sph_kernels2.h>
#include <jet/sph_kernels3.h>
#include <gtest/gtest.h>
using namespace jet;
TEST(SphStdKernel2, Constructors)
{
SphStdKernel2 kernel;
EXPECT_DOUBLE_EQ(0.0, kernel.h);
SphStdKernel2 kernel2(3.0);
EXPECT_DOUBLE_EQ(3.0, kernel2.h);
}
TEST(SphStdKernel2, KernelFunction)
{
SphStdKernel2 kernel(10.0);
double prevValue = kernel(0.0);
for (int i = 1; i <= 10; ++i)
{
double value = kernel(static_cast<double>(i));
EXPECT_LT(value, prevValue);
}
}
TEST(SphStdKernel2, FirstDerivative)
{
SphStdKernel2 kernel(10.0);
double value0 = kernel.firstDerivative(0.0);
double value1 = kernel.firstDerivative(5.0);
double value2 = kernel.firstDerivative(10.0);
EXPECT_DOUBLE_EQ(0.0, value0);
EXPECT_DOUBLE_EQ(0.0, value2);
EXPECT_LT(value1, value0);
}
TEST(SphSpikyKernel2, Constructors)
{
SphSpikyKernel2 kernel;
EXPECT_DOUBLE_EQ(0.0, kernel.h);
SphSpikyKernel2 kernel2(3.0);
EXPECT_DOUBLE_EQ(3.0, kernel2.h);
}
TEST(SphSpikyKernel2, KernelFunction)
{
SphSpikyKernel2 kernel(10.0);
double prevValue = kernel(0.0);
for (int i = 1; i <= 10; ++i)
{
double value = kernel(static_cast<double>(i));
EXPECT_LT(value, prevValue);
}
}
TEST(SphSpikyKernel2, FirstDerivative)
{
SphSpikyKernel2 kernel(10.0);
double value0 = kernel.firstDerivative(0.0);
double value1 = kernel.firstDerivative(5.0);
double value2 = kernel.firstDerivative(10.0);
EXPECT_LT(value0, value1);
EXPECT_LT(value1, value2);
}
TEST(SphSpikyKernel2, SecondDerivative)
{
SphSpikyKernel2 kernel(10.0);
double value0 = kernel.secondDerivative(0.0);
double value1 = kernel.secondDerivative(5.0);
double value2 = kernel.secondDerivative(10.0);
EXPECT_LT(value1, value0);
EXPECT_LT(value2, value1);
}
TEST(SphStdKernel3, Constructors)
{
SphStdKernel3 kernel;
EXPECT_DOUBLE_EQ(0.0, kernel.h);
SphStdKernel3 kernel2(3.0);
EXPECT_DOUBLE_EQ(3.0, kernel2.h);
}
TEST(SphStdKernel3, KernelFunction)
{
SphStdKernel3 kernel(10.0);
double prevValue = kernel(0.0);
for (int i = 1; i <= 10; ++i)
{
double value = kernel(static_cast<double>(i));
EXPECT_LT(value, prevValue);
}
}
TEST(SphStdKernel3, FirstDerivative)
{
SphStdKernel3 kernel(10.0);
double value0 = kernel.firstDerivative(0.0);
double value1 = kernel.firstDerivative(5.0);
double value2 = kernel.firstDerivative(10.0);
EXPECT_DOUBLE_EQ(0.0, value0);
EXPECT_DOUBLE_EQ(0.0, value2);
EXPECT_LT(value1, value0);
}
TEST(SphSpikyKernel3, Constructors)
{
SphSpikyKernel3 kernel;
EXPECT_DOUBLE_EQ(0.0, kernel.h);
SphSpikyKernel3 kernel2(3.0);
EXPECT_DOUBLE_EQ(3.0, kernel2.h);
}
TEST(SphSpikyKernel3, KernelFunction)
{
SphSpikyKernel3 kernel(10.0);
double prevValue = kernel(0.0);
for (int i = 1; i <= 10; ++i)
{
double value = kernel(static_cast<double>(i));
EXPECT_LT(value, prevValue);
}
}
TEST(SphSpikyKernel3, FirstDerivative)
{
SphSpikyKernel3 kernel(10.0);
double value0 = kernel.firstDerivative(0.0);
double value1 = kernel.firstDerivative(5.0);
double value2 = kernel.firstDerivative(10.0);
EXPECT_LT(value0, value1);
EXPECT_LT(value1, value2);
}
TEST(SphSpikyKernel3, SecondDerivative)
{
SphSpikyKernel3 kernel(10.0);
double value0 = kernel.secondDerivative(0.0);
double value1 = kernel.secondDerivative(5.0);
double value2 = kernel.secondDerivative(10.0);
EXPECT_LT(value1, value0);
EXPECT_LT(value2, value1);
}
| [
"doyubkim@gmail.com"
] | doyubkim@gmail.com |
85a091d0d73068cd315d9d9d4667c937f01b6256 | edc6bb870a453226cebed8e82ff421351cdf1778 | /cplusplus/C++API设计/07_Performance/redundant_includes/src_fast_100/inc21.h | de119d9443103ec8b0547974be5c435ec40b750f | [] | no_license | evelio521/Books | 6984b6364c227154acae149e05c9a2f6e5d6be2c | 558fd6da4392ae08a379c52ac7a658212240112f | refs/heads/master | 2022-03-23T08:05:51.121884 | 2019-12-08T12:23:40 | 2019-12-08T12:23:40 | 193,418,837 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 5,568 | h | #ifndef INC21_H
#define INC21_H
#ifndef INC0_H
#include "inc0.h"
#endif
#ifndef INC1_H
#include "inc1.h"
#endif
#ifndef INC2_H
#include "inc2.h"
#endif
#ifndef INC3_H
#include "inc3.h"
#endif
#ifndef INC4_H
#include "inc4.h"
#endif
#ifndef INC5_H
#include "inc5.h"
#endif
#ifndef INC6_H
#include "inc6.h"
#endif
#ifndef INC7_H
#include "inc7.h"
#endif
#ifndef INC8_H
#include "inc8.h"
#endif
#ifndef INC9_H
#include "inc9.h"
#endif
#ifndef INC10_H
#include "inc10.h"
#endif
#ifndef INC11_H
#include "inc11.h"
#endif
#ifndef INC12_H
#include "inc12.h"
#endif
#ifndef INC13_H
#include "inc13.h"
#endif
#ifndef INC14_H
#include "inc14.h"
#endif
#ifndef INC15_H
#include "inc15.h"
#endif
#ifndef INC16_H
#include "inc16.h"
#endif
#ifndef INC17_H
#include "inc17.h"
#endif
#ifndef INC18_H
#include "inc18.h"
#endif
#ifndef INC19_H
#include "inc19.h"
#endif
#ifndef INC20_H
#include "inc20.h"
#endif
#ifndef INC22_H
#include "inc22.h"
#endif
#ifndef INC23_H
#include "inc23.h"
#endif
#ifndef INC24_H
#include "inc24.h"
#endif
#ifndef INC25_H
#include "inc25.h"
#endif
#ifndef INC26_H
#include "inc26.h"
#endif
#ifndef INC27_H
#include "inc27.h"
#endif
#ifndef INC28_H
#include "inc28.h"
#endif
#ifndef INC29_H
#include "inc29.h"
#endif
#ifndef INC30_H
#include "inc30.h"
#endif
#ifndef INC31_H
#include "inc31.h"
#endif
#ifndef INC32_H
#include "inc32.h"
#endif
#ifndef INC33_H
#include "inc33.h"
#endif
#ifndef INC34_H
#include "inc34.h"
#endif
#ifndef INC35_H
#include "inc35.h"
#endif
#ifndef INC36_H
#include "inc36.h"
#endif
#ifndef INC37_H
#include "inc37.h"
#endif
#ifndef INC38_H
#include "inc38.h"
#endif
#ifndef INC39_H
#include "inc39.h"
#endif
#ifndef INC40_H
#include "inc40.h"
#endif
#ifndef INC41_H
#include "inc41.h"
#endif
#ifndef INC42_H
#include "inc42.h"
#endif
#ifndef INC43_H
#include "inc43.h"
#endif
#ifndef INC44_H
#include "inc44.h"
#endif
#ifndef INC45_H
#include "inc45.h"
#endif
#ifndef INC46_H
#include "inc46.h"
#endif
#ifndef INC47_H
#include "inc47.h"
#endif
#ifndef INC48_H
#include "inc48.h"
#endif
#ifndef INC49_H
#include "inc49.h"
#endif
#ifndef INC50_H
#include "inc50.h"
#endif
#ifndef INC51_H
#include "inc51.h"
#endif
#ifndef INC52_H
#include "inc52.h"
#endif
#ifndef INC53_H
#include "inc53.h"
#endif
#ifndef INC54_H
#include "inc54.h"
#endif
#ifndef INC55_H
#include "inc55.h"
#endif
#ifndef INC56_H
#include "inc56.h"
#endif
#ifndef INC57_H
#include "inc57.h"
#endif
#ifndef INC58_H
#include "inc58.h"
#endif
#ifndef INC59_H
#include "inc59.h"
#endif
#ifndef INC60_H
#include "inc60.h"
#endif
#ifndef INC61_H
#include "inc61.h"
#endif
#ifndef INC62_H
#include "inc62.h"
#endif
#ifndef INC63_H
#include "inc63.h"
#endif
#ifndef INC64_H
#include "inc64.h"
#endif
#ifndef INC65_H
#include "inc65.h"
#endif
#ifndef INC66_H
#include "inc66.h"
#endif
#ifndef INC67_H
#include "inc67.h"
#endif
#ifndef INC68_H
#include "inc68.h"
#endif
#ifndef INC69_H
#include "inc69.h"
#endif
#ifndef INC70_H
#include "inc70.h"
#endif
#ifndef INC71_H
#include "inc71.h"
#endif
#ifndef INC72_H
#include "inc72.h"
#endif
#ifndef INC73_H
#include "inc73.h"
#endif
#ifndef INC74_H
#include "inc74.h"
#endif
#ifndef INC75_H
#include "inc75.h"
#endif
#ifndef INC76_H
#include "inc76.h"
#endif
#ifndef INC77_H
#include "inc77.h"
#endif
#ifndef INC78_H
#include "inc78.h"
#endif
#ifndef INC79_H
#include "inc79.h"
#endif
#ifndef INC80_H
#include "inc80.h"
#endif
#ifndef INC81_H
#include "inc81.h"
#endif
#ifndef INC82_H
#include "inc82.h"
#endif
#ifndef INC83_H
#include "inc83.h"
#endif
#ifndef INC84_H
#include "inc84.h"
#endif
#ifndef INC85_H
#include "inc85.h"
#endif
#ifndef INC86_H
#include "inc86.h"
#endif
#ifndef INC87_H
#include "inc87.h"
#endif
#ifndef INC88_H
#include "inc88.h"
#endif
#ifndef INC89_H
#include "inc89.h"
#endif
#ifndef INC90_H
#include "inc90.h"
#endif
#ifndef INC91_H
#include "inc91.h"
#endif
#ifndef INC92_H
#include "inc92.h"
#endif
#ifndef INC93_H
#include "inc93.h"
#endif
#ifndef INC94_H
#include "inc94.h"
#endif
#ifndef INC95_H
#include "inc95.h"
#endif
#ifndef INC96_H
#include "inc96.h"
#endif
#ifndef INC97_H
#include "inc97.h"
#endif
#ifndef INC98_H
#include "inc98.h"
#endif
#ifndef INC99_H
#include "inc99.h"
#endif
class Foo21_0
{
public:
Foo21_0();
~Foo21_0();
int GetValue() const;
void SetValue(int val);
private:
int mValue;
};
class Foo21_1
{
public:
Foo21_1();
~Foo21_1();
int GetValue() const;
void SetValue(int val);
private:
int mValue;
};
class Foo21_2
{
public:
Foo21_2();
~Foo21_2();
int GetValue() const;
void SetValue(int val);
private:
int mValue;
};
class Foo21_3
{
public:
Foo21_3();
~Foo21_3();
int GetValue() const;
void SetValue(int val);
private:
int mValue;
};
class Foo21_4
{
public:
Foo21_4();
~Foo21_4();
int GetValue() const;
void SetValue(int val);
private:
int mValue;
};
class Foo21_5
{
public:
Foo21_5();
~Foo21_5();
int GetValue() const;
void SetValue(int val);
private:
int mValue;
};
class Foo21_6
{
public:
Foo21_6();
~Foo21_6();
int GetValue() const;
void SetValue(int val);
private:
int mValue;
};
class Foo21_7
{
public:
Foo21_7();
~Foo21_7();
int GetValue() const;
void SetValue(int val);
private:
int mValue;
};
class Foo21_8
{
public:
Foo21_8();
~Foo21_8();
int GetValue() const;
void SetValue(int val);
private:
int mValue;
};
class Foo21_9
{
public:
Foo21_9();
~Foo21_9();
int GetValue() const;
void SetValue(int val);
private:
int mValue;
};
#endif
| [
"evelio@126.com"
] | evelio@126.com |
dc0e996a98d2087c791f5716d12c9e91d1347b87 | 043160352216a7fc21be4c8a44507e00f523bf80 | /src/masternode-budget.cpp | 94e6a5cbeb29d9173e1f7b5dda0354e7b910770a | [
"MIT"
] | permissive | odinyblockchain/odinycoin | 5ef2a1bca374230882c91e8c6717bbb8faf889ad | 183751aac9357455913f1d8a415b1dcb04225ee0 | refs/heads/master | 2022-12-18T14:14:02.535216 | 2020-09-20T22:05:14 | 2020-09-20T22:05:14 | 295,208,711 | 0 | 2 | MIT | 2020-09-18T10:33:17 | 2020-09-13T18:06:52 | C++ | UTF-8 | C++ | false | false | 87,875 | cpp | // Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2020 The Odinycoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "init.h"
#include "main.h"
#include "addrman.h"
#include "chainparams.h"
#include "masternode-budget.h"
#include "masternode-sync.h"
#include "masternode.h"
#include "masternodeman.h"
#include "obfuscation.h"
#include "util.h"
#include <boost/filesystem.hpp>
CBudgetManager budget;
CCriticalSection cs_budget;
std::map<uint256, int64_t> askedForSourceProposalOrBudget;
std::vector<CBudgetProposalBroadcast> vecImmatureBudgetProposals;
std::vector<CFinalizedBudgetBroadcast> vecImmatureFinalizedBudgets;
int nSubmittedFinalBudget;
bool IsBudgetCollateralValid(uint256 nTxCollateralHash, uint256 nExpectedHash, std::string& strError, int64_t& nTime, int& nConf, bool fBudgetFinalization)
{
CTransaction txCollateral;
uint256 nBlockHash;
if (!GetTransaction(nTxCollateralHash, txCollateral, nBlockHash, true)) {
strError = strprintf("Can't find collateral tx %s", txCollateral.ToString());
LogPrint("mnbudget","CBudgetProposalBroadcast::IsBudgetCollateralValid - %s\n", strError);
return false;
}
if (txCollateral.vout.size() < 1) return false;
if (txCollateral.nLockTime != 0) return false;
CScript findScript;
findScript << OP_RETURN << ToByteVector(nExpectedHash);
bool foundOpReturn = false;
for (const CTxOut &o : txCollateral.vout) {
if (!o.scriptPubKey.IsNormalPaymentScript() && !o.scriptPubKey.IsUnspendable()) {
strError = strprintf("Invalid Script %s", txCollateral.ToString());
LogPrint("mnbudget","CBudgetProposalBroadcast::IsBudgetCollateralValid - %s\n", strError);
return false;
}
if (fBudgetFinalization) {
// Collateral for budget finalization
// Note: there are still old valid budgets out there, but the check for the new 5 ODC finalization collateral
// will also cover the old 50 ODC finalization collateral.
LogPrint("mnbudget", "Final Budget: o.scriptPubKey(%s) == findScript(%s) ?\n", o.scriptPubKey.ToString(), findScript.ToString());
if (o.scriptPubKey == findScript) {
LogPrint("mnbudget", "Final Budget: o.nValue(%ld) >= BUDGET_FEE_TX(%ld) ?\n", o.nValue, BUDGET_FEE_TX);
if(o.nValue >= BUDGET_FEE_TX) {
foundOpReturn = true;
}
}
}
else {
// Collateral for normal budget proposal
LogPrint("mnbudget", "Normal Budget: o.scriptPubKey(%s) == findScript(%s) ?\n", o.scriptPubKey.ToString(), findScript.ToString());
if (o.scriptPubKey == findScript) {
LogPrint("mnbudget", "Normal Budget: o.nValue(%ld) >= PROPOSAL_FEE_TX(%ld) ?\n", o.nValue, PROPOSAL_FEE_TX);
if(o.nValue >= PROPOSAL_FEE_TX) {
foundOpReturn = true;
}
}
}
}
if (!foundOpReturn) {
strError = strprintf("Couldn't find opReturn %s in %s", nExpectedHash.ToString(), txCollateral.ToString());
LogPrint("mnbudget","CBudgetProposalBroadcast::IsBudgetCollateralValid - %s\n", strError);
return false;
}
// RETRIEVE CONFIRMATIONS AND NTIME
/*
- nTime starts as zero and is passed-by-reference out of this function and stored in the external proposal
- nTime is never validated via the hashing mechanism and comes from a full-validated source (the blockchain)
*/
int conf = GetIXConfirmations(nTxCollateralHash);
if (nBlockHash != uint256(0)) {
BlockMap::iterator mi = mapBlockIndex.find(nBlockHash);
if (mi != mapBlockIndex.end() && (*mi).second) {
CBlockIndex* pindex = (*mi).second;
if (chainActive.Contains(pindex)) {
conf += chainActive.Height() - pindex->nHeight + 1;
nTime = pindex->nTime;
}
}
}
nConf = conf;
//if we're syncing we won't have swiftTX information, so accept 1 confirmation
if (conf >= Params().Budget_Fee_Confirmations()) {
return true;
} else {
strError = strprintf("Collateral requires at least %d confirmations - %d confirmations", Params().Budget_Fee_Confirmations(), conf);
LogPrint("mnbudget","CBudgetProposalBroadcast::IsBudgetCollateralValid - %s - %d confirmations\n", strError, conf);
return false;
}
}
void CBudgetManager::CheckOrphanVotes()
{
LOCK(cs);
std::string strError = "";
std::map<uint256, CBudgetVote>::iterator it1 = mapOrphanMasternodeBudgetVotes.begin();
while (it1 != mapOrphanMasternodeBudgetVotes.end()) {
if (budget.UpdateProposal(((*it1).second), NULL, strError)) {
LogPrint("mnbudget","CBudgetManager::CheckOrphanVotes - Proposal/Budget is known, activating and removing orphan vote\n");
mapOrphanMasternodeBudgetVotes.erase(it1++);
} else {
++it1;
}
}
std::map<uint256, CFinalizedBudgetVote>::iterator it2 = mapOrphanFinalizedBudgetVotes.begin();
while (it2 != mapOrphanFinalizedBudgetVotes.end()) {
if (budget.UpdateFinalizedBudget(((*it2).second), NULL, strError)) {
LogPrint("mnbudget","CBudgetManager::CheckOrphanVotes - Proposal/Budget is known, activating and removing orphan vote\n");
mapOrphanFinalizedBudgetVotes.erase(it2++);
} else {
++it2;
}
}
LogPrint("mnbudget","CBudgetManager::CheckOrphanVotes - Done\n");
}
void CBudgetManager::SubmitFinalBudget()
{
static int nSubmittedHeight = 0; // height at which final budget was submitted last time
int nCurrentHeight;
{
TRY_LOCK(cs_main, locked);
if (!locked) return;
if (!chainActive.Tip()) return;
nCurrentHeight = chainActive.Height();
}
int nBlockStart = nCurrentHeight - nCurrentHeight % Params().GetBudgetCycleBlocks() + Params().GetBudgetCycleBlocks();
if (nSubmittedHeight >= nBlockStart){
LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - nSubmittedHeight(=%ld) < nBlockStart(=%ld) condition not fulfilled.\n", nSubmittedHeight, nBlockStart);
return;
}
// Submit final budget during the last 2 days (2880 blocks) before payment for Mainnet, about 9 minutes (9 blocks) for Testnet
int finalizationWindow = ((Params().GetBudgetCycleBlocks() / 30) * 2);
if (Params().NetworkID() == CBaseChainParams::TESTNET) {
// NOTE: 9 blocks for testnet is way to short to have any masternode submit an automatic vote on the finalized(!) budget,
// because those votes are only submitted/relayed once every 56 blocks in CFinalizedBudget::AutoCheck()
finalizationWindow = 64; // 56 + 4 finalization confirmations + 4 minutes buffer for propagation
}
int nFinalizationStart = nBlockStart - finalizationWindow;
int nOffsetToStart = nFinalizationStart - nCurrentHeight;
if (nBlockStart - nCurrentHeight > finalizationWindow) {
LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Too early for finalization. Current block is %ld, next Superblock is %ld.\n", nCurrentHeight, nBlockStart);
LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - First possible block for finalization: %ld. Last possible block for finalization: %ld. You have to wait for %ld block(s) until Budget finalization will be possible\n", nFinalizationStart, nBlockStart, nOffsetToStart);
return;
}
std::vector<CBudgetProposal*> vBudgetProposals = budget.GetBudget();
std::string strBudgetName = "main";
std::vector<CTxBudgetPayment> vecTxBudgetPayments;
for (unsigned int i = 0; i < vBudgetProposals.size(); i++) {
CTxBudgetPayment txBudgetPayment;
txBudgetPayment.nProposalHash = vBudgetProposals[i]->GetHash();
txBudgetPayment.payee = vBudgetProposals[i]->GetPayee();
txBudgetPayment.nAmount = vBudgetProposals[i]->GetAllotted();
vecTxBudgetPayments.push_back(txBudgetPayment);
}
if (vecTxBudgetPayments.size() < 1) {
LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Found No Proposals For Period\n");
return;
}
CFinalizedBudgetBroadcast tempBudget(strBudgetName, nBlockStart, vecTxBudgetPayments, 0);
if (mapSeenFinalizedBudgets.count(tempBudget.GetHash())) {
LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Budget already exists - %s\n", tempBudget.GetHash().ToString());
nSubmittedHeight = nCurrentHeight;
return; //already exists
}
//create fee tx
CTransaction tx;
uint256 txidCollateral;
if (!mapCollateralTxids.count(tempBudget.GetHash())) {
CWalletTx wtx;
if (!pwalletMain->GetBudgetFinalizationCollateralTX(wtx, tempBudget.GetHash(), false)) {
LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Can't make collateral transaction\n");
return;
}
// Get our change address
CReserveKey reservekey(pwalletMain);
// Send the tx to the network. Do NOT use SwiftTx, locking might need too much time to propagate, especially for testnet
pwalletMain->CommitTransaction(wtx, reservekey, "NO-ix");
tx = (CTransaction)wtx;
txidCollateral = tx.GetHash();
mapCollateralTxids.insert(std::make_pair(tempBudget.GetHash(), txidCollateral));
} else {
txidCollateral = mapCollateralTxids[tempBudget.GetHash()];
}
int conf = GetIXConfirmations(txidCollateral);
CTransaction txCollateral;
uint256 nBlockHash;
if (!GetTransaction(txidCollateral, txCollateral, nBlockHash, true)) {
LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Can't find collateral tx %s", txidCollateral.ToString());
return;
}
if (nBlockHash != uint256(0)) {
BlockMap::iterator mi = mapBlockIndex.find(nBlockHash);
if (mi != mapBlockIndex.end() && (*mi).second) {
CBlockIndex* pindex = (*mi).second;
if (chainActive.Contains(pindex)) {
conf += chainActive.Height() - pindex->nHeight + 1;
}
}
}
/*
Wait will we have 1 extra confirmation, otherwise some clients might reject this feeTX
-- This function is tied to NewBlock, so we will propagate this budget while the block is also propagating
*/
if (conf < Params().Budget_Fee_Confirmations() + 1) {
LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Collateral requires at least %d confirmations - %s - %d confirmations\n", Params().Budget_Fee_Confirmations() + 1, txidCollateral.ToString(), conf);
return;
}
//create the proposal incase we're the first to make it
CFinalizedBudgetBroadcast finalizedBudgetBroadcast(strBudgetName, nBlockStart, vecTxBudgetPayments, txidCollateral);
std::string strError = "";
if (!finalizedBudgetBroadcast.IsValid(strError)) {
LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Invalid finalized budget - %s \n", strError);
return;
}
LOCK(cs);
mapSeenFinalizedBudgets.insert(std::make_pair(finalizedBudgetBroadcast.GetHash(), finalizedBudgetBroadcast));
finalizedBudgetBroadcast.Relay();
budget.AddFinalizedBudget(finalizedBudgetBroadcast);
nSubmittedHeight = nCurrentHeight;
LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Done! %s\n", finalizedBudgetBroadcast.GetHash().ToString());
}
//
// CBudgetDB
//
CBudgetDB::CBudgetDB()
{
pathDB = GetDataDir() / "budget.dat";
strMagicMessage = "MasternodeBudget";
}
bool CBudgetDB::Write(const CBudgetManager& objToSave)
{
LOCK(objToSave.cs);
int64_t nStart = GetTimeMillis();
// serialize, checksum data up to that point, then append checksum
CDataStream ssObj(SER_DISK, CLIENT_VERSION);
ssObj << strMagicMessage; // masternode cache file specific magic message
ssObj << FLATDATA(Params().MessageStart()); // network specific magic number
ssObj << objToSave;
uint256 hash = Hash(ssObj.begin(), ssObj.end());
ssObj << hash;
// open output file, and associate with CAutoFile
FILE* file = fopen(pathDB.string().c_str(), "wb");
CAutoFile fileout(file, SER_DISK, CLIENT_VERSION);
if (fileout.IsNull())
return error("%s : Failed to open file %s", __func__, pathDB.string());
// Write and commit header, data
try {
fileout << ssObj;
} catch (const std::exception& e) {
return error("%s : Serialize or I/O error - %s", __func__, e.what());
}
fileout.fclose();
LogPrint("mnbudget","Written info to budget.dat %dms\n", GetTimeMillis() - nStart);
return true;
}
CBudgetDB::ReadResult CBudgetDB::Read(CBudgetManager& objToLoad, bool fDryRun)
{
LOCK(objToLoad.cs);
int64_t nStart = GetTimeMillis();
// open input file, and associate with CAutoFile
FILE* file = fopen(pathDB.string().c_str(), "rb");
CAutoFile filein(file, SER_DISK, CLIENT_VERSION);
if (filein.IsNull()) {
error("%s : Failed to open file %s", __func__, pathDB.string());
return FileError;
}
// use file size to size memory buffer
int fileSize = boost::filesystem::file_size(pathDB);
int dataSize = fileSize - sizeof(uint256);
// Don't try to resize to a negative number if file is small
if (dataSize < 0)
dataSize = 0;
std::vector<unsigned char> vchData;
vchData.resize(dataSize);
uint256 hashIn;
// read data and checksum from file
try {
filein.read((char*)&vchData[0], dataSize);
filein >> hashIn;
} catch (const std::exception& e) {
error("%s : Deserialize or I/O error - %s", __func__, e.what());
return HashReadError;
}
filein.fclose();
CDataStream ssObj(vchData, SER_DISK, CLIENT_VERSION);
// verify stored checksum matches input data
uint256 hashTmp = Hash(ssObj.begin(), ssObj.end());
if (hashIn != hashTmp) {
error("%s : Checksum mismatch, data corrupted", __func__);
return IncorrectHash;
}
unsigned char pchMsgTmp[4];
std::string strMagicMessageTmp;
try {
// de-serialize file header (masternode cache file specific magic message) and ..
ssObj >> strMagicMessageTmp;
// ... verify the message matches predefined one
if (strMagicMessage != strMagicMessageTmp) {
error("%s : Invalid masternode cache magic message", __func__);
return IncorrectMagicMessage;
}
// de-serialize file header (network specific magic number) and ..
ssObj >> FLATDATA(pchMsgTmp);
// ... verify the network matches ours
if (memcmp(pchMsgTmp, Params().MessageStart(), sizeof(pchMsgTmp))) {
error("%s : Invalid network magic number", __func__);
return IncorrectMagicNumber;
}
// de-serialize data into CBudgetManager object
ssObj >> objToLoad;
} catch (const std::exception& e) {
objToLoad.Clear();
error("%s : Deserialize or I/O error - %s", __func__, e.what());
return IncorrectFormat;
}
LogPrint("mnbudget","Loaded info from budget.dat %dms\n", GetTimeMillis() - nStart);
LogPrint("mnbudget"," %s\n", objToLoad.ToString());
if (!fDryRun) {
LogPrint("mnbudget","Budget manager - cleaning....\n");
objToLoad.CheckAndRemove();
LogPrint("mnbudget","Budget manager - result:\n");
LogPrint("mnbudget"," %s\n", objToLoad.ToString());
}
return Ok;
}
void DumpBudgets()
{
int64_t nStart = GetTimeMillis();
CBudgetDB budgetdb;
CBudgetManager tempBudget;
LogPrint("mnbudget","Verifying budget.dat format...\n");
CBudgetDB::ReadResult readResult = budgetdb.Read(tempBudget, true);
// there was an error and it was not an error on file opening => do not proceed
if (readResult == CBudgetDB::FileError)
LogPrint("mnbudget","Missing budgets file - budget.dat, will try to recreate\n");
else if (readResult != CBudgetDB::Ok) {
LogPrint("mnbudget","Error reading budget.dat: ");
if (readResult == CBudgetDB::IncorrectFormat)
LogPrint("mnbudget","magic is ok but data has invalid format, will try to recreate\n");
else {
LogPrint("mnbudget","file format is unknown or invalid, please fix it manually\n");
return;
}
}
LogPrint("mnbudget","Writting info to budget.dat...\n");
budgetdb.Write(budget);
LogPrint("mnbudget","Budget dump finished %dms\n", GetTimeMillis() - nStart);
}
bool CBudgetManager::AddFinalizedBudget(CFinalizedBudget& finalizedBudget)
{
std::string strError = "";
if (!finalizedBudget.IsValid(strError)) return false;
if (mapFinalizedBudgets.count(finalizedBudget.GetHash())) {
return false;
}
mapFinalizedBudgets.insert(std::make_pair(finalizedBudget.GetHash(), finalizedBudget));
return true;
}
bool CBudgetManager::AddProposal(CBudgetProposal& budgetProposal)
{
LOCK(cs);
std::string strError = "";
if (!budgetProposal.IsValid(strError)) {
LogPrint("mnbudget","CBudgetManager::AddProposal - invalid budget proposal - %s\n", strError);
return false;
}
if (mapProposals.count(budgetProposal.GetHash())) {
return false;
}
mapProposals.insert(std::make_pair(budgetProposal.GetHash(), budgetProposal));
LogPrint("mnbudget","CBudgetManager::AddProposal - proposal %s added\n", budgetProposal.GetName ().c_str ());
return true;
}
void CBudgetManager::CheckAndRemove()
{
int nHeight = 0;
// Add some verbosity once loading blocks from files has finished
{
TRY_LOCK(cs_main, locked);
if ((locked) && (chainActive.Tip() != NULL)) {
CBlockIndex* pindexPrev = chainActive.Tip();
if (pindexPrev) {
nHeight = pindexPrev->nHeight;
}
}
}
LogPrint("mnbudget", "CBudgetManager::CheckAndRemove at Height=%d\n", nHeight);
std::map<uint256, CFinalizedBudget> tmpMapFinalizedBudgets;
std::map<uint256, CBudgetProposal> tmpMapProposals;
std::string strError = "";
LogPrint("mnbudget", "CBudgetManager::CheckAndRemove - mapFinalizedBudgets cleanup - size before: %d\n", mapFinalizedBudgets.size());
std::map<uint256, CFinalizedBudget>::iterator it = mapFinalizedBudgets.begin();
while (it != mapFinalizedBudgets.end()) {
CFinalizedBudget* pfinalizedBudget = &((*it).second);
pfinalizedBudget->fValid = pfinalizedBudget->IsValid(strError);
if (!strError.empty ()) {
LogPrint("mnbudget","CBudgetManager::CheckAndRemove - Invalid finalized budget: %s\n", strError);
}
else {
LogPrint("mnbudget","CBudgetManager::CheckAndRemove - Found valid finalized budget: %s %s\n",
pfinalizedBudget->strBudgetName.c_str(), pfinalizedBudget->nFeeTXHash.ToString().c_str());
}
if (pfinalizedBudget->fValid) {
pfinalizedBudget->CheckAndVote();
tmpMapFinalizedBudgets.insert(std::make_pair(pfinalizedBudget->GetHash(), *pfinalizedBudget));
}
++it;
}
LogPrint("mnbudget", "CBudgetManager::CheckAndRemove - mapProposals cleanup - size before: %d\n", mapProposals.size());
std::map<uint256, CBudgetProposal>::iterator it2 = mapProposals.begin();
while (it2 != mapProposals.end()) {
CBudgetProposal* pbudgetProposal = &((*it2).second);
pbudgetProposal->fValid = pbudgetProposal->IsValid(strError);
if (!strError.empty ()) {
LogPrint("mnbudget","CBudgetManager::CheckAndRemove - Invalid budget proposal - %s\n", strError);
strError = "";
}
else {
LogPrint("mnbudget","CBudgetManager::CheckAndRemove - Found valid budget proposal: %s %s\n",
pbudgetProposal->strProposalName.c_str(), pbudgetProposal->nFeeTXHash.ToString().c_str());
}
if (pbudgetProposal->fValid) {
tmpMapProposals.insert(std::make_pair(pbudgetProposal->GetHash(), *pbudgetProposal));
}
++it2;
}
// Remove invalid entries by overwriting complete map
mapFinalizedBudgets.swap(tmpMapFinalizedBudgets);
mapProposals.swap(tmpMapProposals);
// clang doesn't accept copy assignemnts :-/
// mapFinalizedBudgets = tmpMapFinalizedBudgets;
// mapProposals = tmpMapProposals;
LogPrint("mnbudget", "CBudgetManager::CheckAndRemove - mapFinalizedBudgets cleanup - size after: %d\n", mapFinalizedBudgets.size());
LogPrint("mnbudget", "CBudgetManager::CheckAndRemove - mapProposals cleanup - size after: %d\n", mapProposals.size());
LogPrint("mnbudget","CBudgetManager::CheckAndRemove - PASSED\n");
}
void CBudgetManager::FillBlockPayee(CMutableTransaction& txNew, CAmount nFees, bool fProofOfStake)
{
LOCK(cs);
CBlockIndex* pindexPrev = chainActive.Tip();
if (!pindexPrev) return;
int nHighestCount = 0;
CScript payee;
CAmount nAmount = 0;
// ------- Grab The Highest Count
std::map<uint256, CFinalizedBudget>::iterator it = mapFinalizedBudgets.begin();
while (it != mapFinalizedBudgets.end()) {
CFinalizedBudget* pfinalizedBudget = &((*it).second);
if (pfinalizedBudget->GetVoteCount() > nHighestCount &&
pindexPrev->nHeight + 1 >= pfinalizedBudget->GetBlockStart() &&
pindexPrev->nHeight + 1 <= pfinalizedBudget->GetBlockEnd() &&
pfinalizedBudget->GetPayeeAndAmount(pindexPrev->nHeight + 1, payee, nAmount)) {
nHighestCount = pfinalizedBudget->GetVoteCount();
}
++it;
}
CAmount blockValue = GetBlockValue(pindexPrev->nHeight);
if (fProofOfStake) {
if (nHighestCount > 0) {
unsigned int i = txNew.vout.size();
txNew.vout.resize(i + 1);
txNew.vout[i].scriptPubKey = payee;
txNew.vout[i].nValue = nAmount;
CTxDestination address1;
ExtractDestination(payee, address1);
CBitcoinAddress address2(address1);
LogPrint("mnbudget","CBudgetManager::FillBlockPayee - Budget payment to %s for %lld, nHighestCount = %d\n", address2.ToString(), nAmount, nHighestCount);
}
else {
LogPrint("mnbudget","CBudgetManager::FillBlockPayee - No Budget payment, nHighestCount = %d\n", nHighestCount);
}
} else {
//miners get the full amount on these blocks
txNew.vout[0].nValue = blockValue;
if (nHighestCount > 0) {
txNew.vout.resize(2);
//these are super blocks, so their value can be much larger than normal
txNew.vout[1].scriptPubKey = payee;
txNew.vout[1].nValue = nAmount;
CTxDestination address1;
ExtractDestination(payee, address1);
CBitcoinAddress address2(address1);
LogPrint("mnbudget","CBudgetManager::FillBlockPayee - Budget payment to %s for %lld\n", address2.ToString(), nAmount);
}
}
}
CFinalizedBudget* CBudgetManager::FindFinalizedBudget(uint256 nHash)
{
if (mapFinalizedBudgets.count(nHash))
return &mapFinalizedBudgets[nHash];
return NULL;
}
CBudgetProposal* CBudgetManager::FindProposal(const std::string& strProposalName)
{
//find the prop with the highest yes count
int nYesCount = -99999;
CBudgetProposal* pbudgetProposal = NULL;
std::map<uint256, CBudgetProposal>::iterator it = mapProposals.begin();
while (it != mapProposals.end()) {
if ((*it).second.strProposalName == strProposalName && (*it).second.GetYeas() > nYesCount) {
pbudgetProposal = &((*it).second);
nYesCount = pbudgetProposal->GetYeas();
}
++it;
}
if (nYesCount == -99999) return NULL;
return pbudgetProposal;
}
CBudgetProposal* CBudgetManager::FindProposal(uint256 nHash)
{
LOCK(cs);
if (mapProposals.count(nHash))
return &mapProposals[nHash];
return NULL;
}
bool CBudgetManager::IsBudgetPaymentBlock(int nBlockHeight)
{
int nHighestCount = -1;
int nFivePercent = mnodeman.CountEnabled(ActiveProtocol()) / 20;
std::map<uint256, CFinalizedBudget>::iterator it = mapFinalizedBudgets.begin();
while (it != mapFinalizedBudgets.end()) {
CFinalizedBudget* pfinalizedBudget = &((*it).second);
if (pfinalizedBudget->GetVoteCount() > nHighestCount &&
nBlockHeight >= pfinalizedBudget->GetBlockStart() &&
nBlockHeight <= pfinalizedBudget->GetBlockEnd()) {
nHighestCount = pfinalizedBudget->GetVoteCount();
}
++it;
}
LogPrint("mnbudget","CBudgetManager::IsBudgetPaymentBlock() - nHighestCount: %lli, 5%% of Masternodes: %lli. Number of finalized budgets: %lli\n",
nHighestCount, nFivePercent, mapFinalizedBudgets.size());
// If budget doesn't have 5% of the network votes, then we should pay a masternode instead
if (nHighestCount > nFivePercent) return true;
return false;
}
TrxValidationStatus CBudgetManager::IsTransactionValid(const CTransaction& txNew, int nBlockHeight)
{
LOCK(cs);
TrxValidationStatus transactionStatus = TrxValidationStatus::InValid;
int nHighestCount = 0;
int nFivePercent = mnodeman.CountEnabled(ActiveProtocol()) / 20;
std::vector<CFinalizedBudget*> ret;
LogPrint("mnbudget","CBudgetManager::IsTransactionValid - checking %lli finalized budgets\n", mapFinalizedBudgets.size());
// ------- Grab The Highest Count
std::map<uint256, CFinalizedBudget>::iterator it = mapFinalizedBudgets.begin();
while (it != mapFinalizedBudgets.end()) {
CFinalizedBudget* pfinalizedBudget = &((*it).second);
if (pfinalizedBudget->GetVoteCount() > nHighestCount &&
nBlockHeight >= pfinalizedBudget->GetBlockStart() &&
nBlockHeight <= pfinalizedBudget->GetBlockEnd()) {
nHighestCount = pfinalizedBudget->GetVoteCount();
}
++it;
}
LogPrint("mnbudget","CBudgetManager::IsTransactionValid() - nHighestCount: %lli, 5%% of Masternodes: %lli mapFinalizedBudgets.size(): %ld\n",
nHighestCount, nFivePercent, mapFinalizedBudgets.size());
/*
If budget doesn't have 5% of the network votes, then we should pay a masternode instead
*/
if (nHighestCount < nFivePercent) return TrxValidationStatus::InValid;
// check the highest finalized budgets (+/- 10% to assist in consensus)
std::string strProposals = "";
int nCountThreshold = nHighestCount - mnodeman.CountEnabled(ActiveProtocol()) / 10;
bool fThreshold = false;
it = mapFinalizedBudgets.begin();
while (it != mapFinalizedBudgets.end()) {
CFinalizedBudget* pfinalizedBudget = &((*it).second);
strProposals = pfinalizedBudget->GetProposals();
LogPrint("mnbudget","CBudgetManager::IsTransactionValid - checking budget (%s) with blockstart %lli, blockend %lli, nBlockHeight %lli, votes %lli, nCountThreshold %lli\n",
strProposals.c_str(), pfinalizedBudget->GetBlockStart(), pfinalizedBudget->GetBlockEnd(),
nBlockHeight, pfinalizedBudget->GetVoteCount(), nCountThreshold);
if (pfinalizedBudget->GetVoteCount() > nCountThreshold) {
fThreshold = true;
LogPrint("mnbudget","CBudgetManager::IsTransactionValid - GetVoteCount() > nCountThreshold passed\n");
if (nBlockHeight >= pfinalizedBudget->GetBlockStart() && nBlockHeight <= pfinalizedBudget->GetBlockEnd()) {
LogPrint("mnbudget","CBudgetManager::IsTransactionValid - GetBlockStart() passed\n");
transactionStatus = pfinalizedBudget->IsTransactionValid(txNew, nBlockHeight);
if (transactionStatus == TrxValidationStatus::Valid) {
LogPrint("mnbudget","CBudgetManager::IsTransactionValid - pfinalizedBudget->IsTransactionValid() passed\n");
return TrxValidationStatus::Valid;
}
else {
LogPrint("mnbudget","CBudgetManager::IsTransactionValid - pfinalizedBudget->IsTransactionValid() error\n");
}
}
else {
LogPrint("mnbudget","CBudgetManager::IsTransactionValid - GetBlockStart() failed, budget is outside current payment cycle and will be ignored.\n");
}
}
++it;
}
// If not enough masternodes autovoted for any of the finalized budgets pay a masternode instead
if(!fThreshold) {
transactionStatus = TrxValidationStatus::VoteThreshold;
}
// We looked through all of the known budgets
return transactionStatus;
}
std::vector<CBudgetProposal*> CBudgetManager::GetAllProposals()
{
LOCK(cs);
std::vector<CBudgetProposal*> vBudgetProposalRet;
std::map<uint256, CBudgetProposal>::iterator it = mapProposals.begin();
while (it != mapProposals.end()) {
(*it).second.CleanAndRemove();
CBudgetProposal* pbudgetProposal = &((*it).second);
vBudgetProposalRet.push_back(pbudgetProposal);
++it;
}
return vBudgetProposalRet;
}
//
// Sort by votes, if there's a tie sort by their feeHash TX
//
struct sortProposalsByVotes {
bool operator()(const std::pair<CBudgetProposal*, int>& left, const std::pair<CBudgetProposal*, int>& right)
{
if (left.second != right.second)
return (left.second > right.second);
return (left.first->nFeeTXHash > right.first->nFeeTXHash);
}
};
//Need to review this function
std::vector<CBudgetProposal*> CBudgetManager::GetBudget()
{
LOCK(cs);
// ------- Sort budgets by Yes Count
std::vector<std::pair<CBudgetProposal*, int> > vBudgetPorposalsSort;
std::map<uint256, CBudgetProposal>::iterator it = mapProposals.begin();
while (it != mapProposals.end()) {
(*it).second.CleanAndRemove();
vBudgetPorposalsSort.push_back(std::make_pair(&((*it).second), (*it).second.GetYeas() - (*it).second.GetNays()));
++it;
}
std::sort(vBudgetPorposalsSort.begin(), vBudgetPorposalsSort.end(), sortProposalsByVotes());
// ------- Grab The Budgets In Order
std::vector<CBudgetProposal*> vBudgetProposalsRet;
CAmount nBudgetAllocated = 0;
CBlockIndex* pindexPrev;
{
LOCK(cs_main);
pindexPrev = chainActive.Tip();
}
if (pindexPrev == NULL) return vBudgetProposalsRet;
int nBlockStart = pindexPrev->nHeight - pindexPrev->nHeight % Params().GetBudgetCycleBlocks() + Params().GetBudgetCycleBlocks();
int nBlockEnd = nBlockStart + Params().GetBudgetCycleBlocks() - 1;
int mnCount = mnodeman.CountEnabled(ActiveProtocol());
CAmount nTotalBudget = GetTotalBudget(nBlockStart);
std::vector<std::pair<CBudgetProposal*, int> >::iterator it2 = vBudgetPorposalsSort.begin();
while (it2 != vBudgetPorposalsSort.end()) {
CBudgetProposal* pbudgetProposal = (*it2).first;
LogPrint("mnbudget","CBudgetManager::GetBudget() - Processing Budget %s\n", pbudgetProposal->strProposalName.c_str());
//prop start/end should be inside this period
if (pbudgetProposal->IsPassing(pindexPrev, nBlockStart, nBlockEnd, mnCount)) {
LogPrint("mnbudget","CBudgetManager::GetBudget() - Check 1 passed: valid=%d | %ld <= %ld | %ld >= %ld | Yeas=%d Nays=%d Count=%d | established=%d\n",
pbudgetProposal->fValid, pbudgetProposal->nBlockStart, nBlockStart, pbudgetProposal->nBlockEnd,
nBlockEnd, pbudgetProposal->GetYeas(), pbudgetProposal->GetNays(), mnCount / 10,
pbudgetProposal->IsEstablished());
if (pbudgetProposal->GetAmount() + nBudgetAllocated <= nTotalBudget) {
pbudgetProposal->SetAllotted(pbudgetProposal->GetAmount());
nBudgetAllocated += pbudgetProposal->GetAmount();
vBudgetProposalsRet.push_back(pbudgetProposal);
LogPrint("mnbudget","CBudgetManager::GetBudget() - Check 2 passed: Budget added\n");
} else {
pbudgetProposal->SetAllotted(0);
LogPrint("mnbudget","CBudgetManager::GetBudget() - Check 2 failed: no amount allotted\n");
}
}
else {
LogPrint("mnbudget","CBudgetManager::GetBudget() - Check 1 failed: valid=%d | %ld <= %ld | %ld >= %ld | Yeas=%d Nays=%d Count=%d | established=%d\n",
pbudgetProposal->fValid, pbudgetProposal->nBlockStart, nBlockStart, pbudgetProposal->nBlockEnd,
nBlockEnd, pbudgetProposal->GetYeas(), pbudgetProposal->GetNays(), mnodeman.CountEnabled(ActiveProtocol()) / 10,
pbudgetProposal->IsEstablished());
}
++it2;
}
return vBudgetProposalsRet;
}
// Sort by votes, if there's a tie sort by their feeHash TX
struct sortFinalizedBudgetsByVotes {
bool operator()(const std::pair<CFinalizedBudget*, int>& left, const std::pair<CFinalizedBudget*, int>& right)
{
if (left.second != right.second)
return left.second > right.second;
return (left.first->nFeeTXHash > right.first->nFeeTXHash);
}
};
std::vector<CFinalizedBudget*> CBudgetManager::GetFinalizedBudgets()
{
LOCK(cs);
std::vector<CFinalizedBudget*> vFinalizedBudgetsRet;
std::vector<std::pair<CFinalizedBudget*, int> > vFinalizedBudgetsSort;
// ------- Grab The Budgets In Order
std::map<uint256, CFinalizedBudget>::iterator it = mapFinalizedBudgets.begin();
while (it != mapFinalizedBudgets.end()) {
CFinalizedBudget* pfinalizedBudget = &((*it).second);
vFinalizedBudgetsSort.push_back(std::make_pair(pfinalizedBudget, pfinalizedBudget->GetVoteCount()));
++it;
}
std::sort(vFinalizedBudgetsSort.begin(), vFinalizedBudgetsSort.end(), sortFinalizedBudgetsByVotes());
std::vector<std::pair<CFinalizedBudget*, int> >::iterator it2 = vFinalizedBudgetsSort.begin();
while (it2 != vFinalizedBudgetsSort.end()) {
vFinalizedBudgetsRet.push_back((*it2).first);
++it2;
}
return vFinalizedBudgetsRet;
}
std::string CBudgetManager::GetRequiredPaymentsString(int nBlockHeight)
{
LOCK(cs);
std::string ret = "unknown-budget";
std::map<uint256, CFinalizedBudget>::iterator it = mapFinalizedBudgets.begin();
while (it != mapFinalizedBudgets.end()) {
CFinalizedBudget* pfinalizedBudget = &((*it).second);
if (nBlockHeight >= pfinalizedBudget->GetBlockStart() && nBlockHeight <= pfinalizedBudget->GetBlockEnd()) {
CTxBudgetPayment payment;
if (pfinalizedBudget->GetBudgetPaymentByBlock(nBlockHeight, payment)) {
if (ret == "unknown-budget") {
ret = payment.nProposalHash.ToString();
} else {
ret += ",";
ret += payment.nProposalHash.ToString();
}
} else {
LogPrint("mnbudget","CBudgetManager::GetRequiredPaymentsString - Couldn't find budget payment for block %d\n", nBlockHeight);
}
}
++it;
}
return ret;
}
CAmount CBudgetManager::GetTotalBudget(int nHeight)
{
if (chainActive.Tip() == NULL) return 0;
if (Params().NetworkID() == CBaseChainParams::TESTNET) {
CAmount nSubsidy = 500 * COIN;
return ((nSubsidy / 100) * 10) * 146;
}
//get block value and calculate from that
CAmount nSubsidy = 0;
if (nHeight <= Params().LAST_POW_BLOCK() && nHeight >= 151200) {
nSubsidy = 50 * COIN;
} else if (nHeight <= 302399 && nHeight > Params().LAST_POW_BLOCK()) {
nSubsidy = 50 * COIN;
} else if (nHeight <= 345599 && nHeight >= 302400) {
nSubsidy = 45 * COIN;
} else if (nHeight <= 388799 && nHeight >= 345600) {
nSubsidy = 40 * COIN;
} else if (nHeight <= 431999 && nHeight >= 388800) {
nSubsidy = 35 * COIN;
} else if (nHeight <= 475199 && nHeight >= 432000) {
nSubsidy = 30 * COIN;
} else if (nHeight <= 518399 && nHeight >= 475200) {
nSubsidy = 25 * COIN;
} else if (nHeight <= 561599 && nHeight >= 518400) {
nSubsidy = 20 * COIN;
} else if (nHeight <= 604799 && nHeight >= 561600) {
nSubsidy = 15 * COIN;
} else if (nHeight <= 647999 && nHeight >= 604800) {
nSubsidy = 10 * COIN;
} else if (nHeight >= Params().Zerocoin_Block_V2_Start()) {
nSubsidy = 10 * COIN;
} else {
nSubsidy = 5 * COIN;
}
// Amount of blocks in a months period of time (using 1 minutes per) = (60*24*30)
if (nHeight <= 172800) {
return 648000 * COIN;
} else {
return ((nSubsidy / 100) * 10) * 1440 * 30;
}
}
void CBudgetManager::NewBlock()
{
TRY_LOCK(cs, fBudgetNewBlock);
if (!fBudgetNewBlock) return;
if (masternodeSync.RequestedMasternodeAssets <= MASTERNODE_SYNC_BUDGET) return;
if (strBudgetMode == "suggest") { //suggest the budget we see
SubmitFinalBudget();
}
//this function should be called 1/14 blocks, allowing up to 100 votes per day on all proposals
if (chainActive.Height() % 14 != 0) return;
// incremental sync with our peers
if (masternodeSync.IsSynced()) {
LogPrint("mnbudget","CBudgetManager::NewBlock - incremental sync started\n");
if (chainActive.Height() % 1440 == rand() % 1440) {
ClearSeen();
ResetSync();
}
LOCK(cs_vNodes);
for (CNode* pnode : vNodes)
if (pnode->nVersion >= ActiveProtocol())
Sync(pnode, 0, true);
MarkSynced();
}
CheckAndRemove();
//remove invalid votes once in a while (we have to check the signatures and validity of every vote, somewhat CPU intensive)
LogPrint("mnbudget","CBudgetManager::NewBlock - askedForSourceProposalOrBudget cleanup - size: %d\n", askedForSourceProposalOrBudget.size());
std::map<uint256, int64_t>::iterator it = askedForSourceProposalOrBudget.begin();
while (it != askedForSourceProposalOrBudget.end()) {
if ((*it).second > GetTime() - (60 * 60 * 24)) {
++it;
} else {
askedForSourceProposalOrBudget.erase(it++);
}
}
LogPrint("mnbudget","CBudgetManager::NewBlock - mapProposals cleanup - size: %d\n", mapProposals.size());
std::map<uint256, CBudgetProposal>::iterator it2 = mapProposals.begin();
while (it2 != mapProposals.end()) {
(*it2).second.CleanAndRemove();
++it2;
}
LogPrint("mnbudget","CBudgetManager::NewBlock - mapFinalizedBudgets cleanup - size: %d\n", mapFinalizedBudgets.size());
std::map<uint256, CFinalizedBudget>::iterator it3 = mapFinalizedBudgets.begin();
while (it3 != mapFinalizedBudgets.end()) {
(*it3).second.CleanAndRemove();
++it3;
}
LogPrint("mnbudget","CBudgetManager::NewBlock - vecImmatureBudgetProposals cleanup - size: %d\n", vecImmatureBudgetProposals.size());
std::vector<CBudgetProposalBroadcast>::iterator it4 = vecImmatureBudgetProposals.begin();
while (it4 != vecImmatureBudgetProposals.end()) {
std::string strError = "";
int nConf = 0;
if (!IsBudgetCollateralValid((*it4).nFeeTXHash, (*it4).GetHash(), strError, (*it4).nTime, nConf)) {
++it4;
continue;
}
if (!(*it4).IsValid(strError)) {
LogPrint("mnbudget","mprop (immature) - invalid budget proposal - %s\n", strError);
it4 = vecImmatureBudgetProposals.erase(it4);
continue;
}
CBudgetProposal budgetProposal((*it4));
if (AddProposal(budgetProposal)) {
(*it4).Relay();
}
LogPrint("mnbudget","mprop (immature) - new budget - %s\n", (*it4).GetHash().ToString());
it4 = vecImmatureBudgetProposals.erase(it4);
}
LogPrint("mnbudget","CBudgetManager::NewBlock - vecImmatureFinalizedBudgets cleanup - size: %d\n", vecImmatureFinalizedBudgets.size());
std::vector<CFinalizedBudgetBroadcast>::iterator it5 = vecImmatureFinalizedBudgets.begin();
while (it5 != vecImmatureFinalizedBudgets.end()) {
std::string strError = "";
int nConf = 0;
if (!IsBudgetCollateralValid((*it5).nFeeTXHash, (*it5).GetHash(), strError, (*it5).nTime, nConf, true)) {
++it5;
continue;
}
if (!(*it5).IsValid(strError)) {
LogPrint("mnbudget","fbs (immature) - invalid finalized budget - %s\n", strError);
it5 = vecImmatureFinalizedBudgets.erase(it5);
continue;
}
LogPrint("mnbudget","fbs (immature) - new finalized budget - %s\n", (*it5).GetHash().ToString());
CFinalizedBudget finalizedBudget((*it5));
if (AddFinalizedBudget(finalizedBudget)) {
(*it5).Relay();
}
it5 = vecImmatureFinalizedBudgets.erase(it5);
}
LogPrint("mnbudget","CBudgetManager::NewBlock - PASSED\n");
}
void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv)
{
// lite mode is not supported
if (fLiteMode) return;
if (!masternodeSync.IsBlockchainSynced()) return;
LOCK(cs_budget);
if (strCommand == "mnvs") { //Masternode vote sync
uint256 nProp;
vRecv >> nProp;
if (Params().NetworkID() == CBaseChainParams::MAIN) {
if (nProp == 0) {
if (pfrom->HasFulfilledRequest("mnvs")) {
LogPrint("mnbudget","mnvs - peer already asked me for the list\n");
Misbehaving(pfrom->GetId(), 20);
return;
}
pfrom->FulfilledRequest("mnvs");
}
}
Sync(pfrom, nProp);
LogPrint("mnbudget", "mnvs - Sent Masternode votes to peer %i\n", pfrom->GetId());
}
if (strCommand == "mprop") { //Masternode Proposal
CBudgetProposalBroadcast budgetProposalBroadcast;
vRecv >> budgetProposalBroadcast;
if (mapSeenMasternodeBudgetProposals.count(budgetProposalBroadcast.GetHash())) {
masternodeSync.AddedBudgetItem(budgetProposalBroadcast.GetHash());
return;
}
std::string strError = "";
int nConf = 0;
if (!IsBudgetCollateralValid(budgetProposalBroadcast.nFeeTXHash, budgetProposalBroadcast.GetHash(), strError, budgetProposalBroadcast.nTime, nConf)) {
LogPrint("mnbudget","Proposal FeeTX is not valid - %s - %s\n", budgetProposalBroadcast.nFeeTXHash.ToString(), strError);
if (nConf >= 1) vecImmatureBudgetProposals.push_back(budgetProposalBroadcast);
return;
}
mapSeenMasternodeBudgetProposals.insert(std::make_pair(budgetProposalBroadcast.GetHash(), budgetProposalBroadcast));
if (!budgetProposalBroadcast.IsValid(strError)) {
LogPrint("mnbudget","mprop - invalid budget proposal - %s\n", strError);
return;
}
CBudgetProposal budgetProposal(budgetProposalBroadcast);
if (AddProposal(budgetProposal)) {
budgetProposalBroadcast.Relay();
}
masternodeSync.AddedBudgetItem(budgetProposalBroadcast.GetHash());
LogPrint("mnbudget","mprop - new budget - %s\n", budgetProposalBroadcast.GetHash().ToString());
//We might have active votes for this proposal that are valid now
CheckOrphanVotes();
}
if (strCommand == "mvote") { //Masternode Vote
CBudgetVote vote;
vRecv >> vote;
vote.fValid = true;
if (mapSeenMasternodeBudgetVotes.count(vote.GetHash())) {
masternodeSync.AddedBudgetItem(vote.GetHash());
return;
}
CMasternode* pmn = mnodeman.Find(vote.vin);
if (pmn == NULL) {
LogPrint("mnbudget","mvote - unknown masternode - vin: %s\n", vote.vin.prevout.hash.ToString());
mnodeman.AskForMN(pfrom, vote.vin);
return;
}
mapSeenMasternodeBudgetVotes.insert(std::make_pair(vote.GetHash(), vote));
if (!vote.CheckSignature()) {
if (masternodeSync.IsSynced()) {
LogPrintf("CBudgetManager::ProcessMessage() : mvote - signature invalid\n");
Misbehaving(pfrom->GetId(), 20);
}
// it could just be a non-synced masternode
mnodeman.AskForMN(pfrom, vote.vin);
return;
}
std::string strError = "";
if (UpdateProposal(vote, pfrom, strError)) {
vote.Relay();
masternodeSync.AddedBudgetItem(vote.GetHash());
}
LogPrint("mnbudget","mvote - new budget vote for budget %s - %s\n", vote.nProposalHash.ToString(), vote.GetHash().ToString());
}
if (strCommand == "fbs") { //Finalized Budget Suggestion
CFinalizedBudgetBroadcast finalizedBudgetBroadcast;
vRecv >> finalizedBudgetBroadcast;
if (mapSeenFinalizedBudgets.count(finalizedBudgetBroadcast.GetHash())) {
masternodeSync.AddedBudgetItem(finalizedBudgetBroadcast.GetHash());
return;
}
std::string strError = "";
int nConf = 0;
if (!IsBudgetCollateralValid(finalizedBudgetBroadcast.nFeeTXHash, finalizedBudgetBroadcast.GetHash(), strError, finalizedBudgetBroadcast.nTime, nConf, true)) {
LogPrint("mnbudget","fbs - Finalized Budget FeeTX is not valid - %s - %s\n", finalizedBudgetBroadcast.nFeeTXHash.ToString(), strError);
if (nConf >= 1) vecImmatureFinalizedBudgets.push_back(finalizedBudgetBroadcast);
return;
}
mapSeenFinalizedBudgets.insert(std::make_pair(finalizedBudgetBroadcast.GetHash(), finalizedBudgetBroadcast));
if (!finalizedBudgetBroadcast.IsValid(strError)) {
LogPrint("mnbudget","fbs - invalid finalized budget - %s\n", strError);
return;
}
LogPrint("mnbudget","fbs - new finalized budget - %s\n", finalizedBudgetBroadcast.GetHash().ToString());
CFinalizedBudget finalizedBudget(finalizedBudgetBroadcast);
if (AddFinalizedBudget(finalizedBudget)) {
finalizedBudgetBroadcast.Relay();
}
masternodeSync.AddedBudgetItem(finalizedBudgetBroadcast.GetHash());
//we might have active votes for this budget that are now valid
CheckOrphanVotes();
}
if (strCommand == "fbvote") { //Finalized Budget Vote
CFinalizedBudgetVote vote;
vRecv >> vote;
vote.fValid = true;
if (mapSeenFinalizedBudgetVotes.count(vote.GetHash())) {
masternodeSync.AddedBudgetItem(vote.GetHash());
return;
}
CMasternode* pmn = mnodeman.Find(vote.vin);
if (pmn == NULL) {
LogPrint("mnbudget", "fbvote - unknown masternode - vin: %s\n", vote.vin.prevout.hash.ToString());
mnodeman.AskForMN(pfrom, vote.vin);
return;
}
mapSeenFinalizedBudgetVotes.insert(std::make_pair(vote.GetHash(), vote));
if (!vote.CheckSignature()) {
if (masternodeSync.IsSynced()) {
LogPrintf("CBudgetManager::ProcessMessage() : fbvote - signature from masternode %s invalid\n", HexStr(pmn->pubKeyMasternode));
Misbehaving(pfrom->GetId(), 20);
}
// it could just be a non-synced masternode
mnodeman.AskForMN(pfrom, vote.vin);
return;
}
std::string strError = "";
if (UpdateFinalizedBudget(vote, pfrom, strError)) {
vote.Relay();
masternodeSync.AddedBudgetItem(vote.GetHash());
LogPrint("mnbudget","fbvote - new finalized budget vote - %s from masternode %s\n", vote.GetHash().ToString(), HexStr(pmn->pubKeyMasternode));
} else {
LogPrint("mnbudget","fbvote - rejected finalized budget vote - %s from masternode %s - %s\n", vote.GetHash().ToString(), HexStr(pmn->pubKeyMasternode), strError);
}
}
}
bool CBudgetManager::PropExists(uint256 nHash)
{
if (mapProposals.count(nHash)) return true;
return false;
}
//mark that a full sync is needed
void CBudgetManager::ResetSync()
{
LOCK(cs);
std::map<uint256, CBudgetProposalBroadcast>::iterator it1 = mapSeenMasternodeBudgetProposals.begin();
while (it1 != mapSeenMasternodeBudgetProposals.end()) {
CBudgetProposal* pbudgetProposal = FindProposal((*it1).first);
if (pbudgetProposal && pbudgetProposal->fValid) {
//mark votes
std::map<uint256, CBudgetVote>::iterator it2 = pbudgetProposal->mapVotes.begin();
while (it2 != pbudgetProposal->mapVotes.end()) {
(*it2).second.fSynced = false;
++it2;
}
}
++it1;
}
std::map<uint256, CFinalizedBudgetBroadcast>::iterator it3 = mapSeenFinalizedBudgets.begin();
while (it3 != mapSeenFinalizedBudgets.end()) {
CFinalizedBudget* pfinalizedBudget = FindFinalizedBudget((*it3).first);
if (pfinalizedBudget && pfinalizedBudget->fValid) {
//send votes
std::map<uint256, CFinalizedBudgetVote>::iterator it4 = pfinalizedBudget->mapVotes.begin();
while (it4 != pfinalizedBudget->mapVotes.end()) {
(*it4).second.fSynced = false;
++it4;
}
}
++it3;
}
}
void CBudgetManager::MarkSynced()
{
LOCK(cs);
/*
Mark that we've sent all valid items
*/
std::map<uint256, CBudgetProposalBroadcast>::iterator it1 = mapSeenMasternodeBudgetProposals.begin();
while (it1 != mapSeenMasternodeBudgetProposals.end()) {
CBudgetProposal* pbudgetProposal = FindProposal((*it1).first);
if (pbudgetProposal && pbudgetProposal->fValid) {
//mark votes
std::map<uint256, CBudgetVote>::iterator it2 = pbudgetProposal->mapVotes.begin();
while (it2 != pbudgetProposal->mapVotes.end()) {
if ((*it2).second.fValid)
(*it2).second.fSynced = true;
++it2;
}
}
++it1;
}
std::map<uint256, CFinalizedBudgetBroadcast>::iterator it3 = mapSeenFinalizedBudgets.begin();
while (it3 != mapSeenFinalizedBudgets.end()) {
CFinalizedBudget* pfinalizedBudget = FindFinalizedBudget((*it3).first);
if (pfinalizedBudget && pfinalizedBudget->fValid) {
//mark votes
std::map<uint256, CFinalizedBudgetVote>::iterator it4 = pfinalizedBudget->mapVotes.begin();
while (it4 != pfinalizedBudget->mapVotes.end()) {
if ((*it4).second.fValid)
(*it4).second.fSynced = true;
++it4;
}
}
++it3;
}
}
void CBudgetManager::Sync(CNode* pfrom, uint256 nProp, bool fPartial)
{
LOCK(cs);
/*
Sync with a client on the network
--
This code checks each of the hash maps for all known budget proposals and finalized budget proposals, then checks them against the
budget object to see if they're OK. If all checks pass, we'll send it to the peer.
*/
int nInvCount = 0;
std::map<uint256, CBudgetProposalBroadcast>::iterator it1 = mapSeenMasternodeBudgetProposals.begin();
while (it1 != mapSeenMasternodeBudgetProposals.end()) {
CBudgetProposal* pbudgetProposal = FindProposal((*it1).first);
if (pbudgetProposal && pbudgetProposal->fValid && (nProp == 0 || (*it1).first == nProp)) {
pfrom->PushInventory(CInv(MSG_BUDGET_PROPOSAL, (*it1).second.GetHash()));
nInvCount++;
//send votes
std::map<uint256, CBudgetVote>::iterator it2 = pbudgetProposal->mapVotes.begin();
while (it2 != pbudgetProposal->mapVotes.end()) {
if ((*it2).second.fValid) {
if ((fPartial && !(*it2).second.fSynced) || !fPartial) {
pfrom->PushInventory(CInv(MSG_BUDGET_VOTE, (*it2).second.GetHash()));
nInvCount++;
}
}
++it2;
}
}
++it1;
}
pfrom->PushMessage("ssc", MASTERNODE_SYNC_BUDGET_PROP, nInvCount);
LogPrint("mnbudget", "CBudgetManager::Sync - sent %d items\n", nInvCount);
nInvCount = 0;
std::map<uint256, CFinalizedBudgetBroadcast>::iterator it3 = mapSeenFinalizedBudgets.begin();
while (it3 != mapSeenFinalizedBudgets.end()) {
CFinalizedBudget* pfinalizedBudget = FindFinalizedBudget((*it3).first);
if (pfinalizedBudget && pfinalizedBudget->fValid && (nProp == 0 || (*it3).first == nProp)) {
pfrom->PushInventory(CInv(MSG_BUDGET_FINALIZED, (*it3).second.GetHash()));
nInvCount++;
//send votes
std::map<uint256, CFinalizedBudgetVote>::iterator it4 = pfinalizedBudget->mapVotes.begin();
while (it4 != pfinalizedBudget->mapVotes.end()) {
if ((*it4).second.fValid) {
if ((fPartial && !(*it4).second.fSynced) || !fPartial) {
pfrom->PushInventory(CInv(MSG_BUDGET_FINALIZED_VOTE, (*it4).second.GetHash()));
nInvCount++;
}
}
++it4;
}
}
++it3;
}
pfrom->PushMessage("ssc", MASTERNODE_SYNC_BUDGET_FIN, nInvCount);
LogPrint("mnbudget", "CBudgetManager::Sync - sent %d items\n", nInvCount);
}
bool CBudgetManager::UpdateProposal(CBudgetVote& vote, CNode* pfrom, std::string& strError)
{
LOCK(cs);
if (!mapProposals.count(vote.nProposalHash)) {
if (pfrom) {
// only ask for missing items after our syncing process is complete --
// otherwise we'll think a full sync succeeded when they return a result
if (!masternodeSync.IsSynced()) return false;
LogPrint("mnbudget","CBudgetManager::UpdateProposal - Unknown proposal %d, asking for source proposal\n", vote.nProposalHash.ToString());
mapOrphanMasternodeBudgetVotes[vote.nProposalHash] = vote;
if (!askedForSourceProposalOrBudget.count(vote.nProposalHash)) {
pfrom->PushMessage("mnvs", vote.nProposalHash);
askedForSourceProposalOrBudget[vote.nProposalHash] = GetTime();
}
}
strError = "Proposal not found!";
return false;
}
return mapProposals[vote.nProposalHash].AddOrUpdateVote(vote, strError);
}
bool CBudgetManager::UpdateFinalizedBudget(CFinalizedBudgetVote& vote, CNode* pfrom, std::string& strError)
{
LOCK(cs);
if (!mapFinalizedBudgets.count(vote.nBudgetHash)) {
if (pfrom) {
// only ask for missing items after our syncing process is complete --
// otherwise we'll think a full sync succeeded when they return a result
if (!masternodeSync.IsSynced()) return false;
LogPrint("mnbudget","CBudgetManager::UpdateFinalizedBudget - Unknown Finalized Proposal %s, asking for source budget\n", vote.nBudgetHash.ToString());
mapOrphanFinalizedBudgetVotes[vote.nBudgetHash] = vote;
if (!askedForSourceProposalOrBudget.count(vote.nBudgetHash)) {
pfrom->PushMessage("mnvs", vote.nBudgetHash);
askedForSourceProposalOrBudget[vote.nBudgetHash] = GetTime();
}
}
strError = "Finalized Budget " + vote.nBudgetHash.ToString() + " not found!";
return false;
}
LogPrint("mnbudget","CBudgetManager::UpdateFinalizedBudget - Finalized Proposal %s added\n", vote.nBudgetHash.ToString());
return mapFinalizedBudgets[vote.nBudgetHash].AddOrUpdateVote(vote, strError);
}
CBudgetProposal::CBudgetProposal()
{
strProposalName = "unknown";
nBlockStart = 0;
nBlockEnd = 0;
nAmount = 0;
nTime = 0;
fValid = true;
}
CBudgetProposal::CBudgetProposal(std::string strProposalNameIn, std::string strURLIn, int nBlockStartIn, int nBlockEndIn, CScript addressIn, CAmount nAmountIn, uint256 nFeeTXHashIn)
{
strProposalName = strProposalNameIn;
strURL = strURLIn;
nBlockStart = nBlockStartIn;
nBlockEnd = nBlockEndIn;
address = addressIn;
nAmount = nAmountIn;
nFeeTXHash = nFeeTXHashIn;
fValid = true;
}
CBudgetProposal::CBudgetProposal(const CBudgetProposal& other)
{
strProposalName = other.strProposalName;
strURL = other.strURL;
nBlockStart = other.nBlockStart;
nBlockEnd = other.nBlockEnd;
address = other.address;
nAmount = other.nAmount;
nTime = other.nTime;
nFeeTXHash = other.nFeeTXHash;
mapVotes = other.mapVotes;
fValid = true;
}
bool CBudgetProposal::IsValid(std::string& strError, bool fCheckCollateral)
{
if (GetNays() - GetYeas() > mnodeman.CountEnabled(ActiveProtocol()) / 10) {
strError = "Proposal " + strProposalName + ": Active removal";
return false;
}
if (nBlockStart < 0) {
strError = "Invalid Proposal";
return false;
}
if (nBlockEnd < nBlockStart) {
strError = "Proposal " + strProposalName + ": Invalid nBlockEnd (end before start)";
return false;
}
if (nAmount < 10 * COIN) {
strError = "Proposal " + strProposalName + ": Invalid nAmount";
return false;
}
if (address == CScript()) {
strError = "Proposal " + strProposalName + ": Invalid Payment Address";
return false;
}
if (fCheckCollateral) {
int nConf = 0;
if (!IsBudgetCollateralValid(nFeeTXHash, GetHash(), strError, nTime, nConf)) {
strError = "Proposal " + strProposalName + ": Invalid collateral";
return false;
}
}
/*
TODO: There might be an issue with multisig in the coinbase on mainnet, we will add support for it in a future release.
*/
if (address.IsPayToScriptHash()) {
strError = "Proposal " + strProposalName + ": Multisig is not currently supported.";
return false;
}
//if proposal doesn't gain traction within 2 weeks, remove it
// nTime not being saved correctly
// -- TODO: We should keep track of the last time the proposal was valid, if it's invalid for 2 weeks, erase it
// if(nTime + (60*60*24*2) < GetAdjustedTime()) {
// if(GetYeas()-GetNays() < (mnodeman.CountEnabled(ActiveProtocol())/10)) {
// strError = "Not enough support";
// return false;
// }
// }
//can only pay out 10% of the possible coins (min value of coins)
if (nAmount > budget.GetTotalBudget(nBlockStart)) {
strError = "Proposal " + strProposalName + ": Payment more than max";
return false;
}
CBlockIndex* pindexPrev = chainActive.Tip();
if (pindexPrev == NULL) {
strError = "Proposal " + strProposalName + ": Tip is NULL";
return true;
}
// Calculate maximum block this proposal will be valid, which is start of proposal + (number of payments * cycle)
int nProposalEnd = GetBlockStart() + (Params().GetBudgetCycleBlocks() * GetTotalPaymentCount());
// if (GetBlockEnd() < pindexPrev->nHeight - GetBudgetPaymentCycleBlocks() / 2) {
if(nProposalEnd < pindexPrev->nHeight){
strError = "Proposal " + strProposalName + ": Invalid nBlockEnd (" + std::to_string(nProposalEnd) + ") < current height (" + std::to_string(pindexPrev->nHeight) + ")";
return false;
}
return true;
}
bool CBudgetProposal::IsEstablished()
{
return nTime < GetAdjustedTime() - Params().GetProposalEstablishmentTime();
}
bool CBudgetProposal::IsPassing(const CBlockIndex* pindexPrev, int nBlockStartBudget, int nBlockEndBudget, int mnCount)
{
if (!fValid)
return false;
if (!pindexPrev)
return false;
if (this->nBlockStart > nBlockStartBudget)
return false;
if (this->nBlockEnd < nBlockEndBudget)
return false;
if (GetYeas() - GetNays() <= mnCount / 10)
return false;
if (!IsEstablished())
return false;
return true;
}
bool CBudgetProposal::AddOrUpdateVote(CBudgetVote& vote, std::string& strError)
{
std::string strAction = "New vote inserted:";
LOCK(cs);
uint256 hash = vote.vin.prevout.GetHash();
if (mapVotes.count(hash)) {
if (mapVotes[hash].nTime > vote.nTime) {
strError = strprintf("new vote older than existing vote - %s\n", vote.GetHash().ToString());
LogPrint("mnbudget", "CBudgetProposal::AddOrUpdateVote - %s\n", strError);
return false;
}
if (vote.nTime - mapVotes[hash].nTime < BUDGET_VOTE_UPDATE_MIN) {
strError = strprintf("time between votes is too soon - %s - %lli sec < %lli sec\n", vote.GetHash().ToString(), vote.nTime - mapVotes[hash].nTime,BUDGET_VOTE_UPDATE_MIN);
LogPrint("mnbudget", "CBudgetProposal::AddOrUpdateVote - %s\n", strError);
return false;
}
strAction = "Existing vote updated:";
}
if (vote.nTime > GetTime() + (60 * 60)) {
strError = strprintf("new vote is too far ahead of current time - %s - nTime %lli - Max Time %lli\n", vote.GetHash().ToString(), vote.nTime, GetTime() + (60 * 60));
LogPrint("mnbudget", "CBudgetProposal::AddOrUpdateVote - %s\n", strError);
return false;
}
mapVotes[hash] = vote;
LogPrint("mnbudget", "CBudgetProposal::AddOrUpdateVote - %s %s\n", strAction.c_str(), vote.GetHash().ToString().c_str());
return true;
}
// If masternode voted for a proposal, but is now invalid -- remove the vote
void CBudgetProposal::CleanAndRemove()
{
std::map<uint256, CBudgetVote>::iterator it = mapVotes.begin();
while (it != mapVotes.end()) {
CMasternode* pmn = mnodeman.Find((*it).second.GetVin());
(*it).second.fValid = (pmn != nullptr);
++it;
}
}
double CBudgetProposal::GetRatio()
{
int yeas = 0;
int nays = 0;
std::map<uint256, CBudgetVote>::iterator it = mapVotes.begin();
while (it != mapVotes.end()) {
if ((*it).second.nVote == VOTE_YES) yeas++;
if ((*it).second.nVote == VOTE_NO) nays++;
++it;
}
if (yeas + nays == 0) return 0.0f;
return ((double)(yeas) / (double)(yeas + nays));
}
int CBudgetProposal::GetYeas() const
{
int ret = 0;
std::map<uint256, CBudgetVote>::const_iterator it = mapVotes.begin();
while (it != mapVotes.end()) {
if ((*it).second.nVote == VOTE_YES && (*it).second.fValid) ret++;
++it;
}
return ret;
}
int CBudgetProposal::GetNays() const
{
int ret = 0;
std::map<uint256, CBudgetVote>::const_iterator it = mapVotes.begin();
while (it != mapVotes.end()) {
if ((*it).second.nVote == VOTE_NO && (*it).second.fValid) ret++;
++it;
}
return ret;
}
int CBudgetProposal::GetAbstains() const
{
int ret = 0;
std::map<uint256, CBudgetVote>::const_iterator it = mapVotes.begin();
while (it != mapVotes.end()) {
if ((*it).second.nVote == VOTE_ABSTAIN && (*it).second.fValid) ret++;
++it;
}
return ret;
}
int CBudgetProposal::GetBlockStartCycle()
{
//end block is half way through the next cycle (so the proposal will be removed much after the payment is sent)
return nBlockStart - nBlockStart % Params().GetBudgetCycleBlocks();
}
int CBudgetProposal::GetBlockCurrentCycle()
{
CBlockIndex* pindexPrev = chainActive.Tip();
if (pindexPrev == NULL) return -1;
if (pindexPrev->nHeight >= GetBlockEndCycle()) return -1;
return pindexPrev->nHeight - pindexPrev->nHeight % Params().GetBudgetCycleBlocks();
}
int CBudgetProposal::GetBlockEndCycle()
{
// Right now single payment proposals have nBlockEnd have a cycle too early!
// switch back if it break something else
// end block is half way through the next cycle (so the proposal will be removed much after the payment is sent)
// return nBlockEnd - GetBudgetPaymentCycleBlocks() / 2;
// End block is half way through the next cycle (so the proposal will be removed much after the payment is sent)
return nBlockEnd;
}
int CBudgetProposal::GetTotalPaymentCount()
{
return (GetBlockEndCycle() - GetBlockStartCycle()) / Params().GetBudgetCycleBlocks();
}
int CBudgetProposal::GetRemainingPaymentCount()
{
// If this budget starts in the future, this value will be wrong
int nPayments = (GetBlockEndCycle() - GetBlockCurrentCycle()) / Params().GetBudgetCycleBlocks() - 1;
// Take the lowest value
return std::min(nPayments, GetTotalPaymentCount());
}
CBudgetProposalBroadcast::CBudgetProposalBroadcast(std::string strProposalNameIn, std::string strURLIn, int nPaymentCount, CScript addressIn, CAmount nAmountIn, int nBlockStartIn, uint256 nFeeTXHashIn)
{
strProposalName = strProposalNameIn;
strURL = strURLIn;
nBlockStart = nBlockStartIn;
int nCycleStart = nBlockStart - nBlockStart % Params().GetBudgetCycleBlocks();
// Right now single payment proposals have nBlockEnd have a cycle too early!
// switch back if it break something else
// calculate the end of the cycle for this vote, add half a cycle (vote will be deleted after that block)
// nBlockEnd = nCycleStart + GetBudgetPaymentCycleBlocks() * nPaymentCount + GetBudgetPaymentCycleBlocks() / 2;
// Calculate the end of the cycle for this vote, vote will be deleted after next cycle
nBlockEnd = nCycleStart + (Params().GetBudgetCycleBlocks() + 1) * nPaymentCount;
address = addressIn;
nAmount = nAmountIn;
nFeeTXHash = nFeeTXHashIn;
}
void CBudgetProposalBroadcast::Relay()
{
CInv inv(MSG_BUDGET_PROPOSAL, GetHash());
RelayInv(inv);
}
CBudgetVote::CBudgetVote() :
CSignedMessage(),
fValid(true),
fSynced(false),
vin(),
nProposalHash(0),
nVote(VOTE_ABSTAIN),
nTime(0)
{ }
CBudgetVote::CBudgetVote(CTxIn vinIn, uint256 nProposalHashIn, int nVoteIn) :
CSignedMessage(),
fValid(true),
fSynced(false),
vin(vinIn),
nProposalHash(nProposalHashIn),
nVote(nVoteIn)
{
nTime = GetAdjustedTime();
}
void CBudgetVote::Relay()
{
CInv inv(MSG_BUDGET_VOTE, GetHash());
RelayInv(inv);
}
uint256 CBudgetVote::GetHash() const
{
CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
ss << vin;
ss << nProposalHash;
ss << nVote;
ss << nTime;
return ss.GetHash();
}
std::string CBudgetVote::GetStrMessage() const
{
return vin.prevout.ToStringShort() + nProposalHash.ToString() +
std::to_string(nVote) + std::to_string(nTime);
}
CFinalizedBudget::CFinalizedBudget() :
fAutoChecked(false),
fValid(true),
strBudgetName(""),
nBlockStart(0),
vecBudgetPayments(),
mapVotes(),
nFeeTXHash(0),
nTime(0)
{ }
CFinalizedBudget::CFinalizedBudget(const CFinalizedBudget& other) :
fAutoChecked(false),
fValid(true),
strBudgetName(other.strBudgetName),
nBlockStart(other.nBlockStart),
vecBudgetPayments(other.vecBudgetPayments),
mapVotes(other.mapVotes),
nFeeTXHash(other.nFeeTXHash),
nTime(other.nTime)
{ }
bool CFinalizedBudget::AddOrUpdateVote(CFinalizedBudgetVote& vote, std::string& strError)
{
LOCK(cs);
uint256 hash = vote.vin.prevout.GetHash();
std::string strAction = "New vote inserted:";
if (mapVotes.count(hash)) {
if (mapVotes[hash].nTime > vote.nTime) {
strError = strprintf("new vote older than existing vote - %s\n", vote.GetHash().ToString());
LogPrint("mnbudget", "CFinalizedBudget::AddOrUpdateVote - %s\n", strError);
return false;
}
if (vote.nTime - mapVotes[hash].nTime < BUDGET_VOTE_UPDATE_MIN) {
strError = strprintf("time between votes is too soon - %s - %lli sec < %lli sec\n", vote.GetHash().ToString(), vote.nTime - mapVotes[hash].nTime,BUDGET_VOTE_UPDATE_MIN);
LogPrint("mnbudget", "CFinalizedBudget::AddOrUpdateVote - %s\n", strError);
return false;
}
strAction = "Existing vote updated:";
}
if (vote.nTime > GetTime() + (60 * 60)) {
strError = strprintf("new vote is too far ahead of current time - %s - nTime %lli - Max Time %lli\n", vote.GetHash().ToString(), vote.nTime, GetTime() + (60 * 60));
LogPrint("mnbudget", "CFinalizedBudget::AddOrUpdateVote - %s\n", strError);
return false;
}
mapVotes[hash] = vote;
LogPrint("mnbudget", "CFinalizedBudget::AddOrUpdateVote - %s %s\n", strAction.c_str(), vote.GetHash().ToString().c_str());
return true;
}
// Sort budget proposals by hash
struct sortProposalsByHash {
bool operator()(const CBudgetProposal* left, const CBudgetProposal* right)
{
return (left->GetHash() < right->GetHash());
}
};
// Sort budget payments by hash
struct sortPaymentsByHash {
bool operator()(const CTxBudgetPayment& left, const CTxBudgetPayment& right)
{
return (left.nProposalHash < right.nProposalHash);
}
};
// Check finalized budget and vote on it if correct. Masternodes only
void CFinalizedBudget::CheckAndVote()
{
LOCK(cs);
CBlockIndex* pindexPrev = chainActive.Tip();
if (!pindexPrev) return;
LogPrint("mnbudget","CFinalizedBudget::AutoCheck - %lli - %d\n", pindexPrev->nHeight, fAutoChecked);
if (!fMasterNode || fAutoChecked) {
LogPrint("mnbudget","CFinalizedBudget::AutoCheck fMasterNode=%d fAutoChecked=%d\n", fMasterNode, fAutoChecked);
return;
}
// Do this 1 in 4 blocks -- spread out the voting activity
// -- this function is only called every fourteenth block, so this is really 1 in 56 blocks
if (rand() % 4 != 0) {
LogPrint("mnbudget","CFinalizedBudget::AutoCheck - waiting\n");
return;
}
fAutoChecked = true; //we only need to check this once
if (strBudgetMode == "auto") //only vote for exact matches
{
std::vector<CBudgetProposal*> vBudgetProposals = budget.GetBudget();
// We have to resort the proposals by hash (they are sorted by votes here) and sort the payments
// by hash (they are not sorted at all) to make the following tests deterministic
// We're working on copies to avoid any side-effects by the possibly changed sorting order
// Sort copy of proposals by hash
std::vector<CBudgetProposal*> vBudgetProposalsSortedByHash(vBudgetProposals);
std::sort(vBudgetProposalsSortedByHash.begin(), vBudgetProposalsSortedByHash.end(), sortProposalsByHash());
// Sort copy payments by hash
std::vector<CTxBudgetPayment> vecBudgetPaymentsSortedByHash(vecBudgetPayments);
std::sort(vecBudgetPaymentsSortedByHash.begin(), vecBudgetPaymentsSortedByHash.end(), sortPaymentsByHash());
for (unsigned int i = 0; i < vecBudgetPaymentsSortedByHash.size(); i++) {
LogPrint("mnbudget","CFinalizedBudget::AutoCheck Budget-Payments - nProp %d %s\n", i, vecBudgetPaymentsSortedByHash[i].nProposalHash.ToString());
LogPrint("mnbudget","CFinalizedBudget::AutoCheck Budget-Payments - Payee %d %s\n", i, vecBudgetPaymentsSortedByHash[i].payee.ToString());
LogPrint("mnbudget","CFinalizedBudget::AutoCheck Budget-Payments - nAmount %d %lli\n", i, vecBudgetPaymentsSortedByHash[i].nAmount);
}
for (unsigned int i = 0; i < vBudgetProposalsSortedByHash.size(); i++) {
LogPrint("mnbudget","CFinalizedBudget::AutoCheck Budget-Proposals - nProp %d %s\n", i, vBudgetProposalsSortedByHash[i]->GetHash().ToString());
LogPrint("mnbudget","CFinalizedBudget::AutoCheck Budget-Proposals - Payee %d %s\n", i, vBudgetProposalsSortedByHash[i]->GetPayee().ToString());
LogPrint("mnbudget","CFinalizedBudget::AutoCheck Budget-Proposals - nAmount %d %lli\n", i, vBudgetProposalsSortedByHash[i]->GetAmount());
}
if (vBudgetProposalsSortedByHash.size() == 0) {
LogPrint("mnbudget","CFinalizedBudget::AutoCheck - No Budget-Proposals found, aborting\n");
return;
}
if (vBudgetProposalsSortedByHash.size() != vecBudgetPaymentsSortedByHash.size()) {
LogPrint("mnbudget","CFinalizedBudget::AutoCheck - Budget-Proposal length (%ld) doesn't match Budget-Payment length (%ld).\n",
vBudgetProposalsSortedByHash.size(), vecBudgetPaymentsSortedByHash.size());
return;
}
for (unsigned int i = 0; i < vecBudgetPaymentsSortedByHash.size(); i++) {
if (i > vBudgetProposalsSortedByHash.size() - 1) {
LogPrint("mnbudget","CFinalizedBudget::AutoCheck - Proposal size mismatch, i=%d > (vBudgetProposals.size() - 1)=%d\n", i, vBudgetProposalsSortedByHash.size() - 1);
return;
}
if (vecBudgetPaymentsSortedByHash[i].nProposalHash != vBudgetProposalsSortedByHash[i]->GetHash()) {
LogPrint("mnbudget","CFinalizedBudget::AutoCheck - item #%d doesn't match %s %s\n", i, vecBudgetPaymentsSortedByHash[i].nProposalHash.ToString(), vBudgetProposalsSortedByHash[i]->GetHash().ToString());
return;
}
// if(vecBudgetPayments[i].payee != vBudgetProposals[i]->GetPayee()){ -- triggered with false positive
if (vecBudgetPaymentsSortedByHash[i].payee.ToString() != vBudgetProposalsSortedByHash[i]->GetPayee().ToString()) {
LogPrint("mnbudget","CFinalizedBudget::AutoCheck - item #%d payee doesn't match %s %s\n", i, vecBudgetPaymentsSortedByHash[i].payee.ToString(), vBudgetProposalsSortedByHash[i]->GetPayee().ToString());
return;
}
if (vecBudgetPaymentsSortedByHash[i].nAmount != vBudgetProposalsSortedByHash[i]->GetAmount()) {
LogPrint("mnbudget","CFinalizedBudget::AutoCheck - item #%d payee doesn't match %lli %lli\n", i, vecBudgetPaymentsSortedByHash[i].nAmount, vBudgetProposalsSortedByHash[i]->GetAmount());
return;
}
}
LogPrint("mnbudget","CFinalizedBudget::AutoCheck - Finalized Budget Matches! Submitting Vote.\n");
SubmitVote();
}
}
// Remove votes from masternodes which are not valid/existent anymore
void CFinalizedBudget::CleanAndRemove()
{
std::map<uint256, CFinalizedBudgetVote>::iterator it = mapVotes.begin();
while (it != mapVotes.end()) {
CMasternode* pmn = mnodeman.Find((*it).second.GetVin());
(*it).second.fValid = (pmn != nullptr);
++it;
}
}
CAmount CFinalizedBudget::GetTotalPayout()
{
CAmount ret = 0;
for (unsigned int i = 0; i < vecBudgetPayments.size(); i++) {
ret += vecBudgetPayments[i].nAmount;
}
return ret;
}
std::string CFinalizedBudget::GetProposals()
{
LOCK(cs);
std::string ret = "";
for (CTxBudgetPayment& budgetPayment : vecBudgetPayments) {
CBudgetProposal* pbudgetProposal = budget.FindProposal(budgetPayment.nProposalHash);
std::string token = budgetPayment.nProposalHash.ToString();
if (pbudgetProposal) token = pbudgetProposal->GetName();
if (ret == "") {
ret = token;
} else {
ret += "," + token;
}
}
return ret;
}
std::string CFinalizedBudget::GetStatus()
{
std::string retBadHashes = "";
std::string retBadPayeeOrAmount = "";
for (int nBlockHeight = GetBlockStart(); nBlockHeight <= GetBlockEnd(); nBlockHeight++) {
CTxBudgetPayment budgetPayment;
if (!GetBudgetPaymentByBlock(nBlockHeight, budgetPayment)) {
LogPrint("mnbudget","CFinalizedBudget::GetStatus - Couldn't find budget payment for block %lld\n", nBlockHeight);
continue;
}
CBudgetProposal* pbudgetProposal = budget.FindProposal(budgetPayment.nProposalHash);
if (!pbudgetProposal) {
if (retBadHashes == "") {
retBadHashes = "Unknown proposal hash! Check this proposal before voting: " + budgetPayment.nProposalHash.ToString();
} else {
retBadHashes += "," + budgetPayment.nProposalHash.ToString();
}
} else {
if (pbudgetProposal->GetPayee() != budgetPayment.payee || pbudgetProposal->GetAmount() != budgetPayment.nAmount) {
if (retBadPayeeOrAmount == "") {
retBadPayeeOrAmount = "Budget payee/nAmount doesn't match our proposal! " + budgetPayment.nProposalHash.ToString();
} else {
retBadPayeeOrAmount += "," + budgetPayment.nProposalHash.ToString();
}
}
}
}
if (retBadHashes == "" && retBadPayeeOrAmount == "") return "OK";
return retBadHashes + retBadPayeeOrAmount;
}
bool CFinalizedBudget::IsValid(std::string& strError, bool fCheckCollateral)
{
// All(!) finalized budgets have the name "main", so get some additional information about them
std::string strProposals = GetProposals();
// Must be the correct block for payment to happen (once a month)
if (nBlockStart % Params().GetBudgetCycleBlocks() != 0) {
strError = "Invalid BlockStart";
return false;
}
// The following 2 checks check the same (basically if vecBudgetPayments.size() > 100)
if (GetBlockEnd() - nBlockStart > 100) {
strError = "Invalid BlockEnd";
return false;
}
if ((int)vecBudgetPayments.size() > 100) {
strError = "Invalid budget payments count (too many)";
return false;
}
if (strBudgetName == "") {
strError = "Invalid Budget Name";
return false;
}
if (nBlockStart == 0) {
strError = "Budget " + strBudgetName + " (" + strProposals + ") Invalid BlockStart == 0";
return false;
}
if (nFeeTXHash == 0) {
strError = "Budget " + strBudgetName + " (" + strProposals + ") Invalid FeeTx == 0";
return false;
}
// Can only pay out 10% of the possible coins (min value of coins)
if (GetTotalPayout() > budget.GetTotalBudget(nBlockStart)) {
strError = "Budget " + strBudgetName + " (" + strProposals + ") Invalid Payout (more than max)";
return false;
}
std::string strError2 = "";
if (fCheckCollateral) {
int nConf = 0;
if (!IsBudgetCollateralValid(nFeeTXHash, GetHash(), strError2, nTime, nConf, true)) {
{
strError = "Budget " + strBudgetName + " (" + strProposals + ") Invalid Collateral : " + strError2;
return false;
}
}
}
// Remove obsolete finalized budgets after some time
CBlockIndex* pindexPrev = chainActive.Tip();
if (pindexPrev == NULL) return true;
// Get start of current budget-cycle
int nCurrentHeight = chainActive.Height();
int nBlockStart = nCurrentHeight - nCurrentHeight % Params().GetBudgetCycleBlocks() + Params().GetBudgetCycleBlocks();
// Remove budgets where the last payment (from max. 100) ends before 2 budget-cycles before the current one
int nMaxAge = nBlockStart - (2 * Params().GetBudgetCycleBlocks());
if (GetBlockEnd() < nMaxAge) {
strError = strprintf("Budget " + strBudgetName + " (" + strProposals + ") (ends at block %ld) too old and obsolete", GetBlockEnd());
return false;
}
return true;
}
bool CFinalizedBudget::IsPaidAlready(uint256 nProposalHash, int nBlockHeight)
{
// Remove budget-payments from former/future payment cycles
std::map<uint256, int>::iterator it = mapPayment_History.begin();
int nPaidBlockHeight = 0;
uint256 nOldProposalHash;
for(it = mapPayment_History.begin(); it != mapPayment_History.end(); /* No incrementation needed */ ) {
nPaidBlockHeight = (*it).second;
if((nPaidBlockHeight < GetBlockStart()) || (nPaidBlockHeight > GetBlockEnd())) {
nOldProposalHash = (*it).first;
LogPrint("mnbudget", "CFinalizedBudget::IsPaidAlready - Budget Proposal %s, Block %d from old cycle deleted\n",
nOldProposalHash.ToString().c_str(), nPaidBlockHeight);
mapPayment_History.erase(it++);
}
else {
++it;
}
}
// Now that we only have payments from the current payment cycle check if this budget was paid already
if(mapPayment_History.count(nProposalHash) == 0) {
// New proposal payment, insert into map for checks with later blocks from this cycle
mapPayment_History.insert(std::pair<uint256, int>(nProposalHash, nBlockHeight));
LogPrint("mnbudget", "CFinalizedBudget::IsPaidAlready - Budget Proposal %s, Block %d added to payment history\n",
nProposalHash.ToString().c_str(), nBlockHeight);
return false;
}
// This budget was paid already -> reject transaction so it gets paid to a masternode instead
return true;
}
TrxValidationStatus CFinalizedBudget::IsTransactionValid(const CTransaction& txNew, int nBlockHeight)
{
TrxValidationStatus transactionStatus = TrxValidationStatus::InValid;
int nCurrentBudgetPayment = nBlockHeight - GetBlockStart();
if (nCurrentBudgetPayment < 0) {
LogPrint("mnbudget","CFinalizedBudget::IsTransactionValid - Invalid block - height: %d start: %d\n", nBlockHeight, GetBlockStart());
return TrxValidationStatus::InValid;
}
if (nCurrentBudgetPayment > (int)vecBudgetPayments.size() - 1) {
LogPrint("mnbudget","CFinalizedBudget::IsTransactionValid - Invalid last block - current budget payment: %d of %d\n", nCurrentBudgetPayment + 1, (int)vecBudgetPayments.size());
return TrxValidationStatus::InValid;
}
bool paid = false;
for (CTxOut out : txNew.vout) {
LogPrint("mnbudget","CFinalizedBudget::IsTransactionValid - nCurrentBudgetPayment=%d, payee=%s == out.scriptPubKey=%s, amount=%ld == out.nValue=%ld\n",
nCurrentBudgetPayment, vecBudgetPayments[nCurrentBudgetPayment].payee.ToString().c_str(), out.scriptPubKey.ToString().c_str(),
vecBudgetPayments[nCurrentBudgetPayment].nAmount, out.nValue);
if (vecBudgetPayments[nCurrentBudgetPayment].payee == out.scriptPubKey && vecBudgetPayments[nCurrentBudgetPayment].nAmount == out.nValue) {
// Check if this proposal was paid already. If so, pay a masternode instead
paid = IsPaidAlready(vecBudgetPayments[nCurrentBudgetPayment].nProposalHash, nBlockHeight);
if(paid) {
LogPrint("mnbudget","CFinalizedBudget::IsTransactionValid - Double Budget Payment of %d for proposal %d detected. Paying a masternode instead.\n",
vecBudgetPayments[nCurrentBudgetPayment].nAmount, vecBudgetPayments[nCurrentBudgetPayment].nProposalHash.Get32());
// No matter what we've found before, stop all checks here. In future releases there might be more than one budget payment
// per block, so even if the first one was not paid yet this one disables all budget payments for this block.
transactionStatus = TrxValidationStatus::DoublePayment;
break;
}
else {
transactionStatus = TrxValidationStatus::Valid;
LogPrint("mnbudget","CFinalizedBudget::IsTransactionValid - Found valid Budget Payment of %d for proposal %d\n",
vecBudgetPayments[nCurrentBudgetPayment].nAmount, vecBudgetPayments[nCurrentBudgetPayment].nProposalHash.Get32());
}
}
}
if (transactionStatus == TrxValidationStatus::InValid) {
CTxDestination address1;
ExtractDestination(vecBudgetPayments[nCurrentBudgetPayment].payee, address1);
CBitcoinAddress address2(address1);
LogPrint("mnbudget","CFinalizedBudget::IsTransactionValid - Missing required payment - %s: %d c: %d\n",
address2.ToString(), vecBudgetPayments[nCurrentBudgetPayment].nAmount, nCurrentBudgetPayment);
}
return transactionStatus;
}
void CFinalizedBudget::SubmitVote()
{
std::string strError = "";
CPubKey pubKeyMasternode;
CKey keyMasternode;
bool fNewSigs = false;
{
LOCK(cs_main);
fNewSigs = chainActive.NewSigsActive();
}
if (!CMessageSigner::GetKeysFromSecret(strMasterNodePrivKey, keyMasternode, pubKeyMasternode)) {
LogPrint("mnbudget","CFinalizedBudget::SubmitVote - Error upon calling GetKeysFromSecret\n");
return;
}
CFinalizedBudgetVote vote(activeMasternode.vin, GetHash());
if (!vote.Sign(keyMasternode, pubKeyMasternode, fNewSigs)) {
LogPrint("mnbudget","CFinalizedBudget::SubmitVote - Failure to sign.");
return;
}
if (budget.UpdateFinalizedBudget(vote, NULL, strError)) {
LogPrint("mnbudget","CFinalizedBudget::SubmitVote - new finalized budget vote - %s\n", vote.GetHash().ToString());
budget.mapSeenFinalizedBudgetVotes.insert(std::make_pair(vote.GetHash(), vote));
vote.Relay();
} else {
LogPrint("mnbudget","CFinalizedBudget::SubmitVote : Error submitting vote - %s\n", strError);
}
}
CFinalizedBudgetBroadcast::CFinalizedBudgetBroadcast() :
CFinalizedBudget()
{ }
CFinalizedBudgetBroadcast::CFinalizedBudgetBroadcast(const CFinalizedBudget& other) :
CFinalizedBudget(other)
{ }
CFinalizedBudgetBroadcast::CFinalizedBudgetBroadcast(std::string strBudgetNameIn,
int nBlockStartIn,
std::vector<CTxBudgetPayment> vecBudgetPaymentsIn,
uint256 nFeeTXHashIn)
{
strBudgetName = strBudgetNameIn;
nBlockStart = nBlockStartIn;
for (CTxBudgetPayment out : vecBudgetPaymentsIn)
vecBudgetPayments.push_back(out);
nFeeTXHash = nFeeTXHashIn;
}
void CFinalizedBudgetBroadcast::Relay()
{
CInv inv(MSG_BUDGET_FINALIZED, GetHash());
RelayInv(inv);
}
CFinalizedBudgetVote::CFinalizedBudgetVote() :
CSignedMessage(),
fValid(true),
fSynced(false),
vin(),
nBudgetHash(0),
nTime(0)
{ }
CFinalizedBudgetVote::CFinalizedBudgetVote(CTxIn vinIn, uint256 nBudgetHashIn) :
CSignedMessage(),
fValid(true),
fSynced(false),
vin(vinIn),
nBudgetHash(nBudgetHashIn)
{
nTime = GetAdjustedTime();
}
void CFinalizedBudgetVote::Relay()
{
CInv inv(MSG_BUDGET_FINALIZED_VOTE, GetHash());
RelayInv(inv);
}
uint256 CFinalizedBudgetVote::GetHash() const
{
CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
ss << vin;
ss << nBudgetHash;
ss << nTime;
return ss.GetHash();
}
std::string CFinalizedBudgetVote::GetStrMessage() const
{
return vin.prevout.ToStringShort() + nBudgetHash.ToString() + std::to_string(nTime);
}
std::string CBudgetManager::ToString() const
{
std::ostringstream info;
info << "Proposals: " << (int)mapProposals.size() << ", Budgets: " << (int)mapFinalizedBudgets.size() << ", Seen Budgets: " << (int)mapSeenMasternodeBudgetProposals.size() << ", Seen Budget Votes: " << (int)mapSeenMasternodeBudgetVotes.size() << ", Seen Final Budgets: " << (int)mapSeenFinalizedBudgets.size() << ", Seen Final Budget Votes: " << (int)mapSeenFinalizedBudgetVotes.size();
return info.str();
}
| [
"71228635+odinyblockchain@users.noreply.github.com"
] | 71228635+odinyblockchain@users.noreply.github.com |
4b4066a6d90d5038b3989b9013a371f84a69a026 | 2e03a084b065b8ccadcb08f1f95ff1bb408c0613 | /CrapGL/RayTracer.cpp | 30547e35ac025a499508fa03c0f9eb682a57d4f1 | [] | no_license | solitaryzero/myCrapGL | 4c7042d4840ab2511e634048fe0bb595a6bdb30b | 852ff0ca6a0848e6aab09a7a3281a935fca33b43 | refs/heads/master | 2021-01-16T19:14:20.926105 | 2017-08-13T05:58:08 | 2017-08-13T05:58:08 | 100,156,656 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,286 | cpp | #include "stdafx.h"
#include "RayTracer.h"
#define MATH_E 2.718281828459
RayTracer::RayTracer()
{
}
Vector3 RayTracer::calRefract(Vector3 l, Vector3 n, double refractiveness)
{
double tmp = double(1) / refractiveness;
double cosL = l.dot(n);
double cosT = 1 - tmp*tmp*(1 - cosL*cosL);
if (cosT <= 0) return Vector3::zeros;
return (l*tmp - n*(cosL*tmp + std::sqrt(cosT))).normalize();
}
myColor RayTracer::RayTracing(scene *_scene, std::vector<LightSource*> lights, ray _ray, int maxReflection, std::vector<CameraRayPoint> &rayPoints, int x, int y, double modifier, Geometry *dst)
{
if (maxReflection == 0) return myColor::myBlack;
IntersectInfo info = _scene->intersection(_ray);
if (info.geometry != nullptr)
{
double a_ref = info.geometry->mat->alt_reflectiveness;
double ref = info.geometry->mat->reflectiveness;
double refra = info.geometry->mat->refractiveness;
double trans = info.geometry->mat->transparency;
myColor absorbance = info.geometry->mat->absorbance;
myColor color;
myColor ans = myColor::myBlack;
Vector3 r, r2;
LightSample smp;
if (info.isOutside == -1)
modifier = modifier*exp(-info.distance*absorbance.r*0.01f);
rayPoints.push_back(CameraRayPoint(x, y, modifier, _ray, info));
for (unsigned int i = 0; i < lights.size(); i++)
{
smp = lights[i]->sample(_scene, info.position);
color = info.geometry->mat->sample(_ray, info.position, info.normal, smp.c , smp.l);
ans = ans+color*a_ref*info.normal.dot(smp.l);
r = _ray.direction - (info.normal * 2 * (info.normal.dot(_ray.direction)));
if ((info.isOutside == 1) && (info.geometry->mat->transparency > 1e-3))
{
r2 = calRefract(_ray.direction.normalize(), info.normal, refra);
}
else
{
r2 = calRefract(_ray.direction.normalize(), info.normal, double(1) / refra);
}
ray reflectRay(info.position, r.normalize());
ray refractRay(info.position, r2);
if (info.geometry->mat->reflectiveness > 1e-3)
ans = ans + RayTracing(_scene, lights, reflectRay, maxReflection - 1, rayPoints, x, y, modifier*ref,dst);
if (info.geometry->mat->transparency > 1e-3)
ans = ans + RayTracing(_scene, lights, refractRay, maxReflection - 1, rayPoints, x, y, modifier*trans,dst);
}
return ans*modifier;
}
return myColor::myBlack;
}
| [
"zfw15@mails.tsinghua.edu.cn"
] | zfw15@mails.tsinghua.edu.cn |
2f69210a389bfd13a0291d3c119128f522dbd65a | 9128a48a9d196690e8e3e3b734a28364c923dcd9 | /Engine/source/UISystem/CKLBLabelNode.cpp | a9407f454c07dc82d1e72657cc99e459efdf05f5 | [] | no_license | donghlcxx/SpineACT_PlaygroundOSS | 94ce25745cafc625f4108967d94f5d548b8a53c3 | 7a73614ba3adf7e72520839b1e862324527e29fb | refs/heads/master | 2022-11-10T04:17:42.933846 | 2020-06-24T02:43:18 | 2020-06-24T02:43:18 | 270,545,386 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,311 | cpp | /*
Copyright 2013 KLab 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 "CKLBLabelNode.h"
#include "CPFInterface.h"
#include "CKLBLanguageDatabase.h"
const char * CKLBLabelNode::ms_default_font = NULL;
bool
CKLBLabelNode::setDefaultFont(const char * fontname)
{
char * name = NULL;
if(fontname) {
name = KLBNEWA(char, strlen(fontname) + 1);
strcpy(name, fontname);
if(!name) return false;
}
KLBDELETEA(ms_default_font);
ms_default_font = (const char *)name;
return true;
}
void
CKLBLabelNode::release()
{
KLBDELETEA(ms_default_font);
ms_default_font = NULL; // 2012.12.11 Reboot時に値が残ったままになり。↑のsetDefaultFont()で変なアドレスが解放される
}
CKLBLabelNode::CKLBLabelNode(int fontsize, const char * fontname, const char * text)
:m_pLabel (NULL)
,m_fontname (NULL)
,m_fontsize (-1)
,m_width (0)
,m_height (0)
,m_textLen (0)
,m_textBuf (NULL)
,m_align (0)
,m_alignX (0.0f)
,m_alignY (0.0f)
,m_tx (0.0f)
,m_ty (0.0f)
,m_lock (false)
,m_changed (false)
,m_useTextSize (true) // Must be true by default.
{
// klb_assert(m_pLabel, "could not create label.");
lock(true);
setFont (fontsize, fontname);
setText ((char *)text);
// Trick : do not force creation of object here.
m_lock = false;
m_changed = false;
m_format = TexturePacker::getCurrentModeTexture();
}
CKLBLabelNode::~CKLBLabelNode() {
//
KLBDELETE(m_pLabel);
// Call Interface to release the input box
KLBDELETEA(m_textBuf);
KLBDELETEA(m_fontname);
}
/*virtual*/
void CKLBLabelNode::recomputeCustom() {
CKLBUIElement::recomputeCustom();
}
/*virtual*/
void CKLBLabelNode::setAsset(CKLBAsset* /*pAsset*/, ASSET_TYPE /*mode*/) {
// Do nothing, no asset display.
}
/*virtual*/
bool CKLBLabelNode::processAction (CKLBAction* /*pAction*/) {
// Do nothing for now, may implement call back.
return false;
}
void CKLBLabelNode::lock (bool stop) {
if (stop != m_lock) {
if (!stop) {
if (m_changed) {
updateLabel();
m_changed = false;
}
}
m_lock = stop;
}
}
bool CKLBLabelNode::setFont (int fontsize, const char * fontname) {
if(!fontname) fontname = ms_default_font;
bool allow = (fontsize != m_fontsize);
if (fontname) {
if (m_fontname) {
allow |= (strcmp(m_fontname, fontname) != 0);
}
if (allow) {
char * buf = KLBNEWA(char, strlen(fontname) + 1);
if (buf) {
KLBDELETEA(m_fontname);
strcpy(buf, fontname);
m_fontname = (const char *)buf;
m_fontsize = fontsize;
if (!m_lock) { updateLabel(); } else { m_changed = true; }
return true;
} else {
return false;
}
} else {
// No changes
return true;
}
} else {
if (m_fontname) {
KLBDELETEA(m_fontname);
allow = true;
}
if (allow) {
m_fontname = NULL;
m_fontsize = fontsize;
if (!m_lock) { updateLabel(); } else { m_changed = true; }
}
return true;
}
}
void CKLBLabelNode::setWidth (u32 width) {
if (width != m_width) {
m_width = width;
if (!m_lock) { updateLabel(); } else { m_changed = true; }
}
}
void CKLBLabelNode::setHeight (u32 height) {
if (height != m_height) {
m_height = height;
if (!m_lock) { updateLabel(); } else { m_changed = true; }
}
}
void CKLBLabelNode::setAlign(u32 align) {
if (align != m_align) {
m_align = align;
if (!m_lock) { updateLabel(); } else { m_changed = true; }
}
}
void CKLBLabelNode::setTextColor(u32 color) {
if (color != m_color) {
m_color = color;
if (!m_lock) { updateLabel(); } else { m_changed = true; }
}
}
void CKLBLabelNode::setText(const char* text) {
if (text) {
text = CKLBLanguageDatabase::getInstance().getString(text);
size_t len = strlen(text);
bool allow = len != m_textLen;
if (m_textBuf) {
allow |= (strcmp(text, m_textBuf) != 0);
} else {
allow = true;
}
if (allow) {
KLBDELETEA(m_textBuf);
m_textBuf = KLBNEWA(char, len + 1);
m_textLen = len;
strcpy(m_textBuf, text);
if (!m_lock) {
updateLabel();
} else {
m_changed = true;
}
}
}
}
const char* CKLBLabelNode::getText() {
return m_textBuf;
}
void CKLBLabelNode::setUseTextSize(bool autoSize) {
m_useTextSize = autoSize;
}
void CKLBLabelNode::updateLabel()
{
if(!m_textBuf || ((!m_width || !m_height) && !m_useTextSize)) {
KLBDELETE(m_pLabel);
m_pLabel = NULL;
return;
}
// 本来VDocは動作中にプロパティを変更するような作りになっていないため、
// プロパティ変更が生じたときは改めて VDOCを作り直す。
if (!m_pLabel) {
CKLBNodeVirtualDocument * pNewNode = KLBNEW(CKLBNodeVirtualDocument);
if(!pNewNode) return;
if(m_pLabel) KLBDELETE(m_pLabel);
m_pLabel = pNewNode;
this->addNode(m_pLabel);
}
// 描画コマンド数は固定。文字列一つだけの表示なので。
m_pLabel->createDocument(1,m_format);
IPlatformRequest& pForm = CPFInterface::getInstance().platform();
// 指定されている文字列とフォント、フォントサイズでの表示に必要な幅と高さを取得する。
void * pFont = pForm.getFont(m_fontsize, m_fontname);
STextInfo txinfo;
pForm.getTextInfo(m_textBuf ? m_textBuf : " ",pFont, &txinfo);
// CKLBLabelNode の場合は、実際に文字列描画が必要とする面積がどうあれ、
// 指定された幅と高さで VirtualDocumentを生成する
u32 width = m_useTextSize ? txinfo.width : m_width;
u32 height = m_useTextSize ? txinfo.height : m_height;
m_pLabel->setDocumentSize(width, height);
float x;
float y;
// X align
switch(m_align & 3) {
default:
case 0: x = 0.0f; break;
case 1: x = -(txinfo.width / 2.0f); break;
case 2: x = -txinfo.width; break;
}
// Y align
switch(m_align >> 2) {
default:
case 0: y = 0.0f; break;
case 1: y = -(txinfo.height / 2.0f); break;
case 2: y = -txinfo.height; break;
}
m_alignX = x;
m_alignY = y;
m_pLabel->setViewPortSize(width, height, x, y,m_renderPrio, false);
// font index = 0 で、指定されている文字列を描画
m_pLabel->setFont(0, m_fontname, m_fontsize); // 指定フォントをindex=0に指定
m_pLabel->clear(0);
m_pLabel->lockDocument();
if (m_textBuf) {
m_pLabel->drawText(0, txinfo.top, m_textBuf, m_color, 0);
}
m_pLabel->unlockDocument();
// Optimize font cache by deleting after.
pForm.deleteFont(pFont);
/*
//
// Update translation here directly.
// ----------------------------------
m_status |= MATRIX_CHANGE;
markUpTree();
m_matrix.m_matrix[MAT_TX] = m_tx + m_alignX;
m_matrix.m_matrix[MAT_TY] = m_ty + m_alignY;
if (m_matrix.m_type == MATRIX_ID) {
m_matrix.m_type = MATRIX_T;
}
// ----------------------------------
m_pLabel->setViewPortPos(0, 0); // ViewPort とDocumentのサイズが同じで、かつ表示位置を(0,0)で固定
m_pLabel->markUpMatrix();
*/
m_status |= MATRIX_CHANGE;
m_pLabel->setViewPortPos(0, 0);
m_pLabel->setPriority(m_renderPrio);
markUpTree();
}
void CKLBLabelNode::setPriority(u32 renderPriority)
{
m_renderPrio = renderPriority;
if(m_pLabel) m_pLabel->setPriority(renderPriority);
}
/*
void CKLBLabelNode::setTranslateVirtual (float x, float y) {
// --> Not possible anymore : if ((x != m_matrix.m_matrix[MAT_TX]) || (y != m_matrix.m_matrix[MAT_TY])) {
m_status |= MATRIX_CHANGE;
markUpTree();
m_tx = x;
m_ty = y;
m_matrix.m_matrix[MAT_TX] = m_tx + m_alignX;
m_matrix.m_matrix[MAT_TY] = m_ty + m_alignY;
if (m_matrix.m_type == MATRIX_ID) {
m_matrix.m_type = MATRIX_T;
}
// }
}
*/
| [
"261709905@qq.com"
] | 261709905@qq.com |
48b430b90e16aba8d4aa8381a0ec38f2123824bc | 32815cd1de61cfa78fd025486ba74249c08b009a | /college_life/algorithms/sqrt_decompostion/range-sum.cpp | 3a9e30e90fbe56a80f2034242ff8b1cd65da0234 | [] | no_license | krshubham/compete | c09d4662eaee9f24df72059d67058e7564a4bc10 | d16b0f820fa50f8a7f686a7f93cab7f9914a3f9d | refs/heads/master | 2020-12-25T09:09:10.484045 | 2020-10-31T07:46:39 | 2020-10-31T07:46:39 | 60,250,510 | 2 | 1 | null | 2020-10-31T07:46:40 | 2016-06-02T09:25:15 | C++ | UTF-8 | C++ | false | false | 2,166 | cpp | #pragma comment (linker, "/stack:20000000")
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define bye return 0
#define pb push_back
#define mp make_pair
#define mod(n) (n) % 1000000007
#define e_val 2.718281828
#define stp(a,b) a.push(b)
#define all(a) a.begin(),a.end()
#define PI 3.1415926535897932384626433832795
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for(int i = n - 1 ; i >= 0 ; i--)
#define crep(i,a,b) for( int i = a; i <= b; i++ )
#define endl '\n'
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define MAXN 100005
#define SQRSIZE 100
typedef long long int lli;
typedef long long ll;
typedef unsigned long long int ulli;
typedef unsigned long long ull;
typedef pair<lli,lli> plli;
typedef vector<lli> vlli;
typedef map<string,lli> mslli;
typedef map<lli,lli> mlli;
typedef vector<pair<lli,lli> > vplli;
inline bool isPrime(lli n){
if (n <= 1) {
return false;
}
if (n <= 3) {
return true;
}
if (n%2 == 0 || n%3 == 0) {
return false;
}
for (int i=5; i*i<=n; i=i+6){
if (n%i == 0 || n%(i+2) == 0){
return false;
}
}
return true;
}
/**
We have two types of queries:
U x y : Update the value of number at index x to y
Q l r: Find the range sum from the index l to r
I know segment tree is the fastest approach here, but let's give sqrt decomposition a shot.
*/
lli arr[MAXN];
lli block[SQRSIZE];
lli bs;
void update(lli x, lli y){
lli block_num = x/bs;
block[block_num] += y - arr[x-1];
arr[x-1] = y;
}
lli query(lli l, lli r){
lli sum = 0;
while (l<r and l%bs!=0 and l!=0){
sum += arr[l];
l++;
}
while (l+bs <= r){
sum += block[l/bs];
l += bs;
}
while (l<=r){
sum += arr[l];
l++;
}
return sum;
}
void preprocess(lli n){
lli bp = -1;
bs = sqrt(n);
for (int i = 0; i < n; ++i){
if(i%bs == 0){
bp++;
}
block[bp] += arr[i];
}
}
int main(){
ios_base::sync_with_stdio(0);
lli t,n,a,b,c,d,e,f,x,y;
cin>>n;
rep(i,n){
cin>>arr[i];
}
preprocess(n);
cout<<query(3,8)<<endl;
bye;
}
| [
"kumar.shubham2015@vit.ac.in"
] | kumar.shubham2015@vit.ac.in |
3c643736e72047c2e95c1cb722c27725b7587ed1 | fdc79bb98eb474c00f6867fa5a26ab1315110b20 | /opencv_version/WMM/source/TurboWMMHermite.cpp | da77e37b752ba78a47f53428249d546af44a8f8c | [] | no_license | braisCB/WMM_ICCV | 2eb0b9ad1eda4e95b3985ea28b18d25b94dc800b | 16c72c415d0617b701e5eac160fbe4f7e0fa1129 | refs/heads/master | 2021-05-30T06:37:47.392714 | 2015-09-11T11:56:34 | 2015-09-11T11:56:34 | 41,853,869 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 43,476 | cpp | #include "../header/TurboWMMHermite.h"
#include <opencv/cv.h>
#include <map>
#define MAX_VAL 100000
#define P_FAR 0
#define P_ALIVE 1
#define P_TRIAL 2
#define RESPHI (sqrt(5.0)-1.0)/2.0
#define TAU 1e-03
#define timageH(p,k) reinterpret_cast<double *>(image.data)[(int) (p.y + image.rows*(p.x + image.cols*k))]
#define tdistanceH(p) reinterpret_cast<double *>(u_surface.data)[(int) (p.y + u_surface.rows*p.x)]
TurboWMMHermite::TurboWMMHermite() {
this->yarray[0] = -1; this->yarray[1] = -1; this->yarray[2] = -1; this->yarray[3] = 0;
this->yarray[4] = 1; this->yarray[5] = 1; this->yarray[6] = 1; this->yarray[7] = 0;
this->xarray[0] = -1; this->xarray[1] = 0; this->xarray[2] = 1; this->xarray[3] = 1;
this->xarray[4] = 1; this->xarray[5] = 0; this->xarray[6] = -1; this->xarray[7] = -1;
}
cv::Mat TurboWMMHermite::AniSurfaceGrad(cv::Mat& image, cv::vector<cv::Point>& initials, cv::Point2d &h) {
cv::Mat u_surface = MAX_VAL*cv::Mat::ones(image.rows, image.cols, CV_64FC1);
cv::Mat state = cv::Mat::zeros(image.rows, image.cols, CV_8UC1);
std::multimap<double, TIsoWavefrontH> trial_set;
std::map<int, std::multimap<double, TIsoWavefrontH>::iterator> mapa_trial;
std::multimap<double, TIsoWavefrontH>::iterator trial_set_it;
std::map<int, std::multimap<double, TIsoWavefrontH>::iterator>::iterator mapa_trial_it;
std::pair<double, TIsoWavefrontH> pr_trial;
std::pair<int, std::multimap<double, TIsoWavefrontH>::iterator> pr_mapa;
int key, i;
TIsoWavefrontH winner, new_w;
cv::Point neigh;
cv::Rect imagerect(0, 0, image.cols, image.rows);
// Initialization
for (i = 0; i < (int) initials.size(); i++) {
key = initials[i].y*u_surface.cols + initials[i].x;
if (mapa_trial.find(key) == mapa_trial.end() && imagerect.contains(initials[i])) {
tdistanceH(initials[i]) = 0.0;
winner.dir = -1;
winner.v0 = 0.0;
winner.p = initials[i];
state.at<unsigned char>(initials[i]) = P_TRIAL;
pr_trial = std::pair<double, TIsoWavefrontH >(0.0, winner);
trial_set_it = trial_set.insert(pr_trial);
pr_mapa = std::pair<int, std::multimap<double, TIsoWavefrontH >::iterator>(key, trial_set_it);
mapa_trial.insert(pr_mapa);
}
}
while (!trial_set.empty()) {
trial_set_it = trial_set.begin();
key = trial_set_it->second.p.y*u_surface.cols + trial_set_it->second.p.x;
mapa_trial_it = mapa_trial.find(key);
if (mapa_trial_it == mapa_trial.end()) {
printf("ERROR: bad map alloc");
exit(-1);
}
if (mapa_trial_it->second != trial_set_it) {
printf("ERROR: bad trial/map alloc");
exit(-1);
}
winner = trial_set_it->second;
trial_set.erase(trial_set_it);
mapa_trial.erase(mapa_trial_it);
state.at<unsigned char>(winner.p) = P_ALIVE;
for (int i=0; i < 8; i++) {
neigh = winner.p + cv::Point(this->xarray[i], this->yarray[i]);
isnewpos[i] = false;
this->valcenter[i] = imagerect.contains(neigh) ? tdistanceH(neigh) : MAX_VAL;
this->imcenter[i] = imagerect.contains(neigh) ? cv::norm(cv::Point2d(timageH(neigh,0), timageH(neigh,1))) : MAX_VAL;
if (imagerect.contains(neigh) && state.at<unsigned char>(neigh) != P_ALIVE) {
double val_neigh = this->Gradient(image, u_surface, winner, neigh, h);
if (val_neigh < this->valcenter[i]) {
this->valcenter[i] = val_neigh;
this->isnewpos[i] = true;
}
}
}
for (int i=0; i < 8; i++) {
if (this->isnewpos[i]) {
new_w.p = cv::Point(winner.p.x + this->xarray[i], winner.p.y + this->yarray[i]);
if (this->valcenter[i] <= winner.v0 && this->valcenter[i] <= this->valcenter[(i+1)%8] && this->valcenter[i] <= this->valcenter[(i+7)%8] &&
(i%2 == 0 || (this->valcenter[i] <= this->valcenter[(i+2)%8] && this->valcenter[i] <= this->valcenter[(i+6)%8]))) {
double val_neigh = this->Gradient(image, u_surface, winner, new_w.p, h, true);
this->valcenter[i] = tdistanceH(new_w.p);
if (val_neigh < this->valcenter[i]) {
this->isnewpos[i] = true;
this->valcenter[i] = val_neigh;
}
}
}
}
// Pchips
for (int i=0; i < 8; i+=2) {
this->getHermite(this->valcenter, this->ms, i);
this->getHermite(this->imcenter, this->ms2, i);
}
// Update
for (int i=0; i < 8; i++) {
if (isnewpos[i]) {
neigh = winner.p + cv::Point(this->xarray[i], this->yarray[i]);
key = neigh.y*u_surface.cols + neigh.x;
if (state.at<unsigned char>(neigh) == P_TRIAL) {
mapa_trial_it = mapa_trial.find(key);
trial_set.erase(mapa_trial_it->second);
mapa_trial.erase(mapa_trial_it);
}
else {
state.at<unsigned char>(neigh) = P_TRIAL;
}
new_w.p = neigh;
new_w.dir = i;
new_w.v0 = this->valcenter[i];
new_w.v1 = this->valcenter[(i+1)%8];
new_w.v2 = this->valcenter[(i+7)%8];
new_w.m0 = this->ms[i].first;
new_w.m1 = this->ms[i].second;
new_w.m2 = -this->ms[(i+7)%8].second;
new_w.m3 = -this->ms[(i+7)%8].first;
new_w.fm0 = this->ms2[i].first;
new_w.fm1 = this->ms2[i].second;
new_w.fm2 = -this->ms2[(i+7)%8].second;
new_w.fm3 = -this->ms2[(i+7)%8].first;
pr_trial = std::pair<double, TIsoWavefrontH>(valcenter[i], new_w);
trial_set_it = trial_set.insert(pr_trial);
pr_mapa = std::pair<int, std::multimap<double, TIsoWavefrontH>::iterator>(key, trial_set_it);
mapa_trial.insert(pr_mapa);
tdistanceH(new_w.p) = valcenter[i];
}
}
}
return u_surface;
}
cv::Mat TurboWMMHermite::AniSurfaceHL(cv::Mat& image, cv::vector<cv::Point>& initials, cv::Point2d &h) {
cv::Mat u_surface = MAX_VAL*cv::Mat::ones(image.rows, image.cols, CV_64FC1);
cv::Mat state = cv::Mat::zeros(image.rows, image.cols, CV_8UC1);
std::multimap<double, TIsoWavefrontH> trial_set;
std::map<int, std::multimap<double, TIsoWavefrontH>::iterator> mapa_trial;
std::multimap<double, TIsoWavefrontH>::iterator trial_set_it;
std::map<int, std::multimap<double, TIsoWavefrontH>::iterator>::iterator mapa_trial_it;
std::pair<double, TIsoWavefrontH> pr_trial;
std::pair<int, std::multimap<double, TIsoWavefrontH>::iterator> pr_mapa;
int key, i;
TIsoWavefrontH winner, new_w;
cv::Point neigh;
cv::Rect imagerect(0, 0, image.cols, image.rows);
// Initialization
for (i = 0; i < (int) initials.size(); i++) {
key = initials[i].y*u_surface.cols + initials[i].x;
if (mapa_trial.find(key) == mapa_trial.end() && imagerect.contains(initials[i])) {
tdistanceH(initials[i]) = 0.0;
winner.dir = -1;
winner.v0 = 0.0;
winner.p = initials[i];
state.at<unsigned char>(initials[i]) = P_TRIAL;
pr_trial = std::pair<double, TIsoWavefrontH >(0.0, winner);
trial_set_it = trial_set.insert(pr_trial);
pr_mapa = std::pair<int, std::multimap<double, TIsoWavefrontH >::iterator>(key, trial_set_it);
mapa_trial.insert(pr_mapa);
}
}
while (!trial_set.empty()) {
trial_set_it = trial_set.begin();
key = trial_set_it->second.p.y*u_surface.cols + trial_set_it->second.p.x;
mapa_trial_it = mapa_trial.find(key);
if (mapa_trial_it == mapa_trial.end()) {
printf("ERROR: bad map alloc");
exit(-1);
}
if (mapa_trial_it->second != trial_set_it) {
printf("ERROR: bad trial/map alloc");
exit(-1);
}
winner = trial_set_it->second;
trial_set.erase(trial_set_it);
mapa_trial.erase(mapa_trial_it);
state.at<unsigned char>(winner.p) = P_ALIVE;
for (int i=0; i < 8; i++) {
neigh = winner.p + cv::Point(this->xarray[i], this->yarray[i]);
isnewpos[i] = false;
this->valcenter[i] = imagerect.contains(neigh) ? tdistanceH(neigh) : MAX_VAL;
this->imcenter[i] = imagerect.contains(neigh) ? cv::norm(cv::Point2d(timageH(neigh,0), timageH(neigh,1))) : MAX_VAL;
if (imagerect.contains(neigh) && state.at<unsigned char>(neigh) != P_ALIVE) {
double val_neigh = this->HopfLax(image, u_surface, winner, neigh, h);
if (val_neigh < this->valcenter[i]) {
this->valcenter[i] = val_neigh;
this->isnewpos[i] = true;
}
}
}
for (int i=0; i < 8; i++) {
if (this->isnewpos[i]) {
new_w.p = cv::Point(winner.p.x + this->xarray[i], winner.p.y + this->yarray[i]);
if (this->valcenter[i] <= winner.v0 && this->valcenter[i] <= this->valcenter[(i+1)%8] && this->valcenter[i] <= this->valcenter[(i+7)%8] &&
(i%2 == 0 || (this->valcenter[i] <= this->valcenter[(i+2)%8] && this->valcenter[i] <= this->valcenter[(i+6)%8]))) {
double val_neigh = this->HopfLax(image, u_surface, winner, new_w.p, h, true);
this->valcenter[i] = tdistanceH(new_w.p);
if (val_neigh < this->valcenter[i]) {
this->isnewpos[i] = true;
this->valcenter[i] = val_neigh;
}
}
}
}
// Pchips
for (int i=0; i < 8; i+=2) {
this->getHermite(this->valcenter, this->ms, i);
this->getHermite(this->imcenter, this->ms2, i);
}
// Update
for (int i=0; i < 8; i++) {
if (isnewpos[i]) {
neigh = winner.p + cv::Point(this->xarray[i], this->yarray[i]);
key = neigh.y*u_surface.cols + neigh.x;
if (state.at<unsigned char>(neigh) == P_TRIAL) {
mapa_trial_it = mapa_trial.find(key);
trial_set.erase(mapa_trial_it->second);
mapa_trial.erase(mapa_trial_it);
}
else {
state.at<unsigned char>(neigh) = P_TRIAL;
}
new_w.p = neigh;
new_w.dir = i;
new_w.v0 = this->valcenter[i];
new_w.v1 = this->valcenter[(i+1)%8];
new_w.v2 = this->valcenter[(i+7)%8];
new_w.m0 = this->ms[i].first;
new_w.m1 = this->ms[i].second;
new_w.m2 = -this->ms[(i+7)%8].second;
new_w.m3 = -this->ms[(i+7)%8].first;
new_w.fm0 = this->ms2[i].first;
new_w.fm1 = this->ms2[i].second;
new_w.fm2 = -this->ms2[(i+7)%8].second;
new_w.fm3 = -this->ms2[(i+7)%8].first;
pr_trial = std::pair<double, TIsoWavefrontH>(valcenter[i], new_w);
trial_set_it = trial_set.insert(pr_trial);
pr_mapa = std::pair<int, std::multimap<double, TIsoWavefrontH>::iterator>(key, trial_set_it);
mapa_trial.insert(pr_mapa);
tdistanceH(new_w.p) = valcenter[i];
}
}
}
return u_surface;
}
cv::Mat TurboWMMHermite::AniSurfaceGS(cv::Mat& image, cv::vector<cv::Point>& initials, cv::Point2d &h) {
cv::Mat u_surface = MAX_VAL*cv::Mat::ones(image.rows, image.cols, CV_64FC1);
cv::Mat state = cv::Mat::zeros(image.rows, image.cols, CV_8UC1);
std::multimap<double, TIsoWavefrontH> trial_set;
std::map<int, std::multimap<double, TIsoWavefrontH>::iterator> mapa_trial;
std::multimap<double, TIsoWavefrontH>::iterator trial_set_it;
std::map<int, std::multimap<double, TIsoWavefrontH>::iterator>::iterator mapa_trial_it;
std::pair<double, TIsoWavefrontH> pr_trial;
std::pair<int, std::multimap<double, TIsoWavefrontH>::iterator> pr_mapa;
int key, i;
TIsoWavefrontH winner, new_w;
cv::Point neigh;
cv::Rect imagerect(0, 0, image.cols, image.rows);
// Initialization
for (i = 0; i < (int) initials.size(); i++) {
key = initials[i].y*u_surface.cols + initials[i].x;
if (mapa_trial.find(key) == mapa_trial.end() && imagerect.contains(initials[i])) {
tdistanceH(initials[i]) = 0.0;
winner.dir = -1;
winner.v0 = 0.0;
winner.p = initials[i];
state.at<unsigned char>(initials[i]) = P_TRIAL;
pr_trial = std::pair<double, TIsoWavefrontH >(0.0, winner);
trial_set_it = trial_set.insert(pr_trial);
pr_mapa = std::pair<int, std::multimap<double, TIsoWavefrontH >::iterator>(key, trial_set_it);
mapa_trial.insert(pr_mapa);
}
}
while (!trial_set.empty()) {
trial_set_it = trial_set.begin();
key = trial_set_it->second.p.y*u_surface.cols + trial_set_it->second.p.x;
mapa_trial_it = mapa_trial.find(key);
if (mapa_trial_it == mapa_trial.end()) {
printf("ERROR: bad map alloc");
exit(-1);
}
if (mapa_trial_it->second != trial_set_it) {
printf("ERROR: bad trial/map alloc");
exit(-1);
}
winner = trial_set_it->second;
trial_set.erase(trial_set_it);
mapa_trial.erase(mapa_trial_it);
state.at<unsigned char>(winner.p) = P_ALIVE;
for (int i=0; i < 8; i++) {
neigh = winner.p + cv::Point(this->xarray[i], this->yarray[i]);
isnewpos[i] = false;
this->valcenter[i] = imagerect.contains(neigh) ? tdistanceH(neigh) : MAX_VAL;
this->imcenter[i] = imagerect.contains(neigh) ? cv::norm(cv::Point2d(timageH(neigh,0), timageH(neigh,1))) : MAX_VAL;
if (imagerect.contains(neigh) && state.at<unsigned char>(neigh) != P_ALIVE) {
double val_neigh = this->GoldenSearch(image, u_surface, winner, neigh, h);
if (val_neigh < this->valcenter[i]) {
this->valcenter[i] = val_neigh;
this->isnewpos[i] = true;
}
}
}
for (int i=0; i < 8; i++) {
if (this->isnewpos[i]) {
new_w.p = cv::Point(winner.p.x + this->xarray[i], winner.p.y + this->yarray[i]);
if (this->valcenter[i] <= winner.v0 && this->valcenter[i] <= this->valcenter[(i+1)%8] && this->valcenter[i] <= this->valcenter[(i+7)%8] &&
(i%2 == 0 || (this->valcenter[i] <= this->valcenter[(i+2)%8] && this->valcenter[i] <= this->valcenter[(i+6)%8]))) {
double val_neigh = this->GoldenSearch(image, u_surface, winner, new_w.p, h, true);
this->valcenter[i] = tdistanceH(new_w.p);
if (val_neigh < this->valcenter[i]) {
this->isnewpos[i] = true;
this->valcenter[i] = val_neigh;
}
}
}
}
// Pchips
for (int i=0; i < 8; i+=2) {
this->getHermite(this->valcenter, this->ms, i);
this->getHermite(this->imcenter, this->ms2, i);
}
// Update
for (int i=0; i < 8; i++) {
if (isnewpos[i]) {
neigh = winner.p + cv::Point(this->xarray[i], this->yarray[i]);
key = neigh.y*u_surface.cols + neigh.x;
if (state.at<unsigned char>(neigh) == P_TRIAL) {
mapa_trial_it = mapa_trial.find(key);
trial_set.erase(mapa_trial_it->second);
mapa_trial.erase(mapa_trial_it);
}
else {
state.at<unsigned char>(neigh) = P_TRIAL;
}
new_w.p = neigh;
new_w.dir = i;
new_w.v0 = this->valcenter[i];
new_w.v1 = this->valcenter[(i+1)%8];
new_w.v2 = this->valcenter[(i+7)%8];
new_w.m0 = this->ms[i].first;
new_w.m1 = this->ms[i].second;
new_w.m2 = -this->ms[(i+7)%8].second;
new_w.m3 = -this->ms[(i+7)%8].first;
new_w.fm0 = this->ms2[i].first;
new_w.fm1 = this->ms2[i].second;
new_w.fm2 = -this->ms2[(i+7)%8].second;
new_w.fm3 = -this->ms2[(i+7)%8].first;
pr_trial = std::pair<double, TIsoWavefrontH>(valcenter[i], new_w);
trial_set_it = trial_set.insert(pr_trial);
pr_mapa = std::pair<int, std::multimap<double, TIsoWavefrontH>::iterator>(key, trial_set_it);
mapa_trial.insert(pr_mapa);
tdistanceH(new_w.p) = valcenter[i];
}
}
}
return u_surface;
}
double TurboWMMHermite::Gradient(cv::Mat &image, cv::Mat &u_surface, TIsoWavefrontH &wave, cv::Point &neigh, cv::Point2d &h, bool forced) {
cv::Point2d f0(timageH(wave.p, 1), timageH(wave.p, 0)), fn(timageH(neigh, 1), timageH(neigh, 0));
double y0 = wave.v0;
if (std::isinf(cv::norm(f0)) || std::isnan(cv::norm(f0)))
f0 = fn;
double val = MAX_VAL;
if (wave.dir < 0) {
cv::Point2d diff(h.x*(neigh.x - wave.p.x), h.y*(neigh.y - wave.p.y));
val = y0 + cv::norm(diff)*(cv::norm(f0) + cv::norm(fn))/2.0;
}
else {
cv::Rect imagerect(0, 0, image.cols, image.rows);
cv::Point p(wave.p.x + this->xarray[(wave.dir+1)%8] - this->xarray[wave.dir],
wave.p.y + this->yarray[(wave.dir+1)%8] - this->yarray[wave.dir]);
double res1 = MAX_VAL;
cv::Point2d dp(h.x*wave.p.x, h.y*wave.p.y), dn(h.x*neigh.x, h.y*neigh.y);
if (imagerect.contains(p)) {
double y1 = wave.v1;
cv::Point2d dd(h.x*(this->xarray[(wave.dir+1)%8] - this->xarray[wave.dir]), h.y*(this->yarray[(wave.dir+1)%8] - this->yarray[wave.dir]));
if (forced && cv::norm(dn - dp - dd) - cv::norm(h) > TAU ) {
res1 = y0 + cv::norm(dn - dp)*(cv::norm(f0) + cv::norm(fn))/2.0;
}
else {
cv::Point2d f1(timageH(p, 1), timageH(p, 0));
if (std::isinf(cv::norm(f1)) || std::isnan(cv::norm(f1)))
f1 = fn;
double A = -dd.y, B = dd.x, C = dd.y*dp.x - dd.x*dp.y;
double den = A*fn.x + B*fn.y;
double t = (A*dn.x + B*dn.y + C)/den, epsilon;
cv::Point2d x(dn.x - t*fn.x, dn.y - t*fn.y);
if (fabs(dd.x) > 0.0 && fabs(den) > 0.0)
epsilon = (x.x - dp.x)/dd.x;
else if (fabs(dd.y) > 0.0 && fabs(den) > 0.0)
epsilon = (x.y - dp.y)/dd.y;
else if (fabs(den) == 0.0 && cv::norm(dd) > 0.0) {
double dist = fabs(A*dn.x + B*dn.y + C)/sqrt(A*A + B*B);
epsilon = (cv::norm(dn - dp) - dist)/(fabs(dd.x) + fabs(dd.y));
}
else
epsilon = 0.0;
if (epsilon < 0.0)
epsilon = 0.0;
else if (epsilon > 1.0)
epsilon = 1.0;
cv::Point2d wp1 = dp + epsilon*dd;
double t_2 = epsilon*epsilon;
double t_3 = epsilon*t_2;
double ft = (2.0*t_3 - 3.0*t_2 + 1.0)*cv::norm(f0) +
(t_3 - 2.0*t_2 + epsilon)*wave.fm0 +
(-2.0*t_3 + 3.0*t_2)*cv::norm(f1) +
(t_3 - t_2)*wave.fm1;
res1 = (2.0*t_3 - 3.0*t_2 + 1.0)*y0 +
(t_3 - 2.0*t_2 + epsilon)*wave.m0 +
(-2.0*t_3 + 3.0*t_2)*y1 +
(t_3 - t_2)*wave.m1 +
cv::norm(dn - wp1)*(ft+cv::norm(fn))/2.0;
if (res1 < y0) res1 = (1.0 - epsilon)*y0 + epsilon*y1 + cv::norm(dn - wp1)*((1.0 - epsilon)*cv::norm(f0) + epsilon*cv::norm(f1)+cv::norm(fn))/2.0;
}
}
p = cv::Point(wave.p.x + this->xarray[(wave.dir+7)%8] - this->xarray[wave.dir],
wave.p.y + this->yarray[(wave.dir+7)%8] - this->yarray[wave.dir]);
double res2 = MAX_VAL;
if (imagerect.contains(p)) {
double y1 = wave.v2;
cv::Point2d dd(h.x*(this->xarray[(wave.dir+7)%8] - this->xarray[wave.dir]), h.y*(this->yarray[(wave.dir+7)%8] - this->yarray[wave.dir]));
if (forced && cv::norm(dn - dp - dd) - cv::norm(h) > TAU ) {
res2 = y0 + cv::norm(dn - dp)*(cv::norm(f0) + cv::norm(fn))/2.0;
}
else {
cv::Point2d f1(timageH(p, 1), timageH(p, 0));
if (std::isinf(cv::norm(f1)) || std::isnan(cv::norm(f1)))
f1 = fn;
double A = -dd.y, B = dd.x, C = dd.y*dp.x - dd.x*dp.y;
double den = A*fn.x + B*fn.y;
double t = (A*dn.x + B*dn.y + C)/den, epsilon;
cv::Point2d x(dn.x - t*fn.x, dn.y - t*fn.y);
if (fabs(dd.x) > 0.0 && fabs(den) > 0.0)
epsilon = (x.x - dp.x)/dd.x;
else if (fabs(dd.y) > 0.0 && fabs(den) > 0.0)
epsilon = (x.y - dp.y)/dd.y;
else if (fabs(den) == 0.0 && cv::norm(dd) > 0.0) {
double dist = fabs(A*dn.x + B*dn.y + C)/sqrt(A*A + B*B);
epsilon = (cv::norm(dn - dp) - dist)/(fabs(dd.x) + fabs(dd.y));
}
else
epsilon = 0.0;
if (epsilon < 0.0)
epsilon = 0.0;
else if (epsilon > 1.0)
epsilon = 1.0;
cv::Point2d wp1 = dp + epsilon*dd;
double t_2 = epsilon*epsilon;
double t_3 = epsilon*t_2;
double ft = (2.0*t_3 - 3.0*t_2 + 1.0)*cv::norm(f0) +
(t_3 - 2.0*t_2 + epsilon)*wave.fm2 +
(-2.0*t_3 + 3.0*t_2)*cv::norm(f1) +
(t_3 - t_2)*wave.fm3;
res2 = (2.0*t_3 - 3.0*t_2 + 1.0)*y0 +
(t_3 - 2.0*t_2 + epsilon)*wave.m2 +
(-2.0*t_3 + 3.0*t_2)*y1 +
(t_3 - t_2)*wave.m3 +
cv::norm(dn - wp1)*(ft+cv::norm(fn))/2.0;
if (res2 < y0) res2 = (1.0 - epsilon)*y0 + epsilon*y1 + cv::norm(dn - wp1)*((1.0 - epsilon)*cv::norm(f0) + epsilon*cv::norm(f1)+cv::norm(fn))/2.0;
}
}
val = std::min(res1, res2);
}
return val;
}
double TurboWMMHermite::HopfLax(cv::Mat &image, cv::Mat &u_surface, TIsoWavefrontH &wave, cv::Point &neigh, cv::Point2d &h, bool forced) {
cv::Point2d f0(timageH(wave.p, 1), timageH(wave.p, 0)), fn(timageH(neigh, 1), timageH(neigh, 0));
double y0 = wave.v0;
if (std::isinf(cv::norm(f0)) || std::isnan(cv::norm(f0)))
f0 = fn;
double val = MAX_VAL;
if (wave.dir == -1) {
cv::Point2d diff(h.x*(neigh.x - wave.p.x), h.y*(neigh.y - wave.p.y));
val = y0 + cv::norm(diff)*(cv::norm(f0) + cv::norm(fn))/2.0;
}
else {
cv::Rect imagerect(0, 0, image.cols, image.rows);
cv::Point p(wave.p.x + this->xarray[(wave.dir+1)%8] - this->xarray[wave.dir],
wave.p.y + this->yarray[(wave.dir+1)%8] - this->yarray[wave.dir]);
double res1 = MAX_VAL;
cv::Point2d dp(h.x*wave.p.x, h.y*wave.p.y), dn(h.x*neigh.x, h.y*neigh.y);
if (imagerect.contains(p)) {
double y1 = wave.v1;
cv::Point2d dd(h.x*(this->xarray[(wave.dir+1)%8] - this->xarray[wave.dir]), h.y*(this->yarray[(wave.dir+1)%8] - this->yarray[wave.dir]));
if (forced && cv::norm(dn - dp - dd) - cv::norm(h) > TAU ) {
res1 = y0 + cv::norm(dn - dp)*(cv::norm(f0) + cv::norm(fn))/2.0;
}
else {
cv::Point2d f1(timageH(p, 1), timageH(p, 0));
if (std::isinf(cv::norm(f1)) || std::isnan(cv::norm(f1)))
f1 = fn;
if (cv::norm(dn - dp - dd) < TAU) {
double res = y0 + cv::norm(dd)*(cv::norm(fn) + cv::norm(f0))/2.0;
res1 = std::min(y1, res);
}
else if (cv::norm(dn - dp) < TAU) {
double res = y1 + cv::norm(dd)*(cv::norm(fn) + cv::norm(f1))/2.0;
res1 = std::min(y0, res);
}
else {
cv::Point2d xy = dn - dp;
double nxy = cv::norm(xy);
double nyz = cv::norm(dd);
double c_alpha = (xy.x*dd.x + xy.y*dd.y)/(nxy*nyz);
double c_delta = (y1 - y0)/nyz;
if (nyz == 0.0 || c_alpha <= c_delta || c_alpha == 1.0) {
res1 = y0 + nxy*(cv::norm(fn) + cv::norm(f0))/2.0;
}
else {
cv::Point2d xz = dn - dp - dd;
double nxz = cv::norm(xz);
double c_beta = (xz.x*dd.x + xz.y*dd.y)/(nxz*nyz);
if (c_delta <= c_beta) {
res1 = y1 + nxz*(cv::norm(fn) + cv::norm(f1))/2.0;
}
else {
double s_delta = sqrt(1.0 - c_delta*c_delta);
double dist = (c_alpha*c_delta + sqrt(1.0 - c_alpha*c_alpha)*s_delta)*nxy;
double yzdist = sqrt(nxy*nxy - dist*dist);
double t = yzdist/(s_delta*nyz);
cv::Point2d respos = dp + t*dd;
double t_2 = t*t;
double t_3 = t*t_2;
double ft = (2.0*t_3 - 3.0*t_2 + 1.0)*cv::norm(f0) +
(t_3 - 2.0*t_2 + t)*wave.fm0 +
(-2.0*t_3 + 3.0*t_2)*cv::norm(f1) +
(t_3 - t_2)*wave.fm1;
res1 = (2.0*t_3 - 3.0*t_2 + 1.0)*y0 +
(t_3 - 2.0*t_2 + t)*wave.m0 +
(-2.0*t_3 + 3.0*t_2)*y1 +
(t_3 - t_2)*wave.m1 +
cv::norm(dn - respos)*(ft+cv::norm(fn))/2.0;
if (res1 < y0) res1 = (1.0 - t)*y0 + t*y1 + cv::norm(dn - respos)*((1.0 - t)*cv::norm(f0) + t*cv::norm(f1)+cv::norm(fn))/2.0;
}
}
}
}
}
p = cv::Point(wave.p.x + this->xarray[(wave.dir+7)%8] - this->xarray[wave.dir],
wave.p.y + this->yarray[(wave.dir+7)%8] - this->yarray[wave.dir]);
double res2 = MAX_VAL;
if (imagerect.contains(p)) {
double y1 = wave.v2;
cv::Point2d dd(h.x*(this->xarray[(wave.dir+7)%8] - this->xarray[wave.dir]), h.y*(this->yarray[(wave.dir+7)%8] - this->yarray[wave.dir]));
if (forced && cv::norm(dn - dp - dd) - cv::norm(h) > TAU ) {
res2 = y0 + cv::norm(dn - dp)*(cv::norm(f0) + cv::norm(fn))/2.0;
}
else {
cv::Point2d f1(timageH(p, 1), timageH(p, 0));
if (std::isinf(cv::norm(f1)) || std::isnan(cv::norm(f1)))
f1 = fn;
if (cv::norm(dn - dp - dd) < TAU) {
double res = y0 + cv::norm(dd)*(cv::norm(fn) + cv::norm(f0))/2.0;
res2 = std::min(y1, res);
}
else if (cv::norm(dn - dp) < TAU) {
double res = y1 + cv::norm(dd)*(cv::norm(fn) + cv::norm(f1))/2.0;
res2 = std::min(y0, res);
}
else {
cv::Point2d xy = dn - dp;
double nxy = cv::norm(xy);
double nyz = cv::norm(dd);
double c_alpha = (xy.x*dd.x + xy.y*dd.y)/(nxy*nyz);
double c_delta = (y1 - y0)/nyz;
if (nyz == 0.0 || c_alpha <= c_delta || c_alpha == 1.0) {
res2 = y0 + nxy*(cv::norm(fn) + cv::norm(f0))/2.0;
}
else {
cv::Point2d xz = dn - dp - dd;
double nxz = cv::norm(xz);
double c_beta = (xz.x*dd.x + xz.y*dd.y)/(nxz*nyz);
if (c_delta <= c_beta) {
res2 = y1 + nxz*(cv::norm(fn) + cv::norm(f1))/2.0;
}
else {
double s_delta = sqrt(1.0 - c_delta*c_delta);
double dist = (c_alpha*c_delta + sqrt(1.0 - c_alpha*c_alpha)*s_delta)*nxy;
double yzdist = sqrt(nxy*nxy - dist*dist);
double t = yzdist/(s_delta*nyz);
cv::Point2d respos = dp + t*dd;
double t_2 = t*t;
double t_3 = t*t_2;
double ft = (2.0*t_3 - 3.0*t_2 + 1.0)*cv::norm(f0) +
(t_3 - 2.0*t_2 + t)*wave.fm2 +
(-2.0*t_3 + 3.0*t_2)*cv::norm(f1) +
(t_3 - t_2)*wave.fm3;
res2 = (2.0*t_3 - 3.0*t_2 + 1.0)*y0 +
(t_3 - 2.0*t_2 + t)*wave.m2 +
(-2.0*t_3 + 3.0*t_2)*y1 +
(t_3 - t_2)*wave.m3 +
cv::norm(dn - respos)*(ft+cv::norm(fn))/2.0;
if (res2 < y0) res2 = (1.0 - t)*y0 + t*y1 + cv::norm(dn - respos)*((1.0 - t)*cv::norm(f0) + t*cv::norm(f1)+cv::norm(fn))/2.0;
}
}
}
}
}
val = std::min(res1, res2);
}
return val;
}
double TurboWMMHermite::GoldenSearch(cv::Mat &image, cv::Mat &u_surface, TIsoWavefrontH &wave, cv::Point &neigh, cv::Point2d &h, bool forced) {
cv::Point2d f0(timageH(wave.p, 1), timageH(wave.p, 0)), fn(timageH(neigh, 1), timageH(neigh, 0));
double y0 = wave.v0;
if (std::isinf(cv::norm(f0)) || std::isnan(cv::norm(f0)))
f0 = fn;
double val = MAX_VAL;
if (wave.dir == -1) {
cv::Point2d diff(h.x*(neigh.x - wave.p.x), h.y*(neigh.y - wave.p.y));
val = y0 + cv::norm(diff)*(cv::norm(f0) + cv::norm(fn))/2.0;
}
else {
cv::Rect imagerect(0, 0, image.cols, image.rows);
cv::Point p(wave.p.x + this->xarray[(wave.dir+1)%8] - this->xarray[wave.dir],
wave.p.y + this->yarray[(wave.dir+1)%8] - this->yarray[wave.dir]);
double res1 = MAX_VAL;
cv::Point2d dp(h.x*wave.p.x, h.y*wave.p.y), dn(h.x*neigh.x, h.y*neigh.y);
if (imagerect.contains(p)) {
double y1 = wave.v1;
cv::Point2d dd(h.x*(this->xarray[(wave.dir+1)%8] - this->xarray[wave.dir]), h.y*(this->yarray[(wave.dir+1)%8] - this->yarray[wave.dir]));
if (forced && cv::norm(dn - dp - dd) - cv::norm(h) > TAU ) {
res1 = y0 + cv::norm(dn - dp)*(cv::norm(f0) + cv::norm(fn))/2.0;
}
else {
cv::Point2d f1(timageH(p, 1), timageH(p, 0));
if (std::isinf(cv::norm(f1)) || std::isnan(cv::norm(f1)))
f1 = fn;
double a = 0.0, b = 1.0, x1 = a + (1-RESPHI)*(b - a), x2 = a + RESPHI*(b - a),
f_x1 = MAX_VAL, f_x2 = MAX_VAL, i1, i2;
cv::Point2d xtreme = dp + dd;
cv::Point2d F_x1, F_x2;
double f_a = y0 + cv::norm(dn - dp)*(cv::norm(f0) + cv::norm(fn))/2.0;
double f_b = y1 + cv::norm(dn - xtreme)*(cv::norm(f1) + cv::norm(fn))/2.0;
res1 = (f_a < f_b) ? f_a : f_b;
F_x1 = (1.0 - x1)*f0 + x1*f1;
F_x2 = (1.0 - x2)*f0 + x2*f1;
double x1_2 = x1*x1, x1_3 = x1_2*x1;
i1 = (2.0*x1_3 - 3.0*x1_2 + 1.0)*cv::norm(f0) +
(x1_3 - 2.0*x1_2 + x1)*wave.fm0 +
(-2.0*x1_3 + 3.0*x1_2)*cv::norm(f1) +
(x1_3 - x1_2)*wave.fm1;
f_x1 = (2.0*x1_3 - 3.0*x1_2 + 1.0)*y0 +
(x1_3 - 2.0*x1_2 + x1)*wave.m0 +
(-2.0*x1_3 + 3.0*x1_2)*y1 +
(x1_3 - x1_2)*wave.m1 + cv::norm(dn - (1.0 - x1)*dp - x1*xtreme)*(i1 + cv::norm(fn))/2.0;
if (f_x1 < y0) f_x1 = (1.0 - x1)*y0 + x1*y1 +
cv::norm(dn - (1.0 - x1)*dp - x1*xtreme)*((1.0 - x1)*cv::norm(f0) + x1*cv::norm(f1) + cv::norm(fn))/2.0;
double x2_2 = x2*x2, x2_3 = x2_2*x2;
i2 = (2.0*x2_3 - 3.0*x2_2 + 1.0)*cv::norm(f0) +
(x2_3 - 2.0*x2_2 + x2)*wave.fm0 +
(-2.0*x2_3 + 3.0*x2_2)*cv::norm(f1) +
(x2_3 - x2_2)*wave.fm1;
f_x2 = (2.0*x2_3 - 3.0*x2_2 + 1.0)*y0 +
(x2_3 - 2.0*x2_2 + x2)*wave.m0 +
(-2.0*x2_3 + 3.0*x2_2)*y1 +
(x2_3 - x2_2)*wave.m1 + cv::norm(dn - (1.0 - x2)*dp - x2*xtreme)*(i2 + cv::norm(fn))/2.0;
if (f_x2 < y0) f_x2 = (1.0 - x2)*y0 + x2*y1 +
cv::norm(dn - (1.0 - x2)*dp - x2*xtreme)*((1.0 - x2)*cv::norm(f0) + x2*cv::norm(f1) + cv::norm(fn))/2.0;
while (fabs(b - a) > TAU) {
if(f_x1 < f_x2) {
b = x2; x2 = x1; f_x2 = f_x1; x1 = a + (1 - RESPHI)*(b - a);
F_x2 = F_x1;
F_x1 = (1.0 - x1)*f0 + x1*f1;
x1_2 = x1*x1; x1_3 = x1_2*x1;
i1 = (2.0*x1_3 - 3.0*x1_2 + 1.0)*cv::norm(f0) +
(x1_3 - 2.0*x1_2 + x1)*wave.fm0 +
(-2.0*x1_3 + 3.0*x1_2)*cv::norm(f1) +
(x1_3 - x1_2)*wave.fm1;
f_x1 = (2.0*x1_3 - 3.0*x1_2 + 1.0)*y0 +
(x1_3 - 2.0*x1_2 + x1)*wave.m0 +
(-2.0*x1_3 + 3.0*x1_2)*y1 +
(x1_3 - x1_2)*wave.m1 + cv::norm(dn - (1.0 - x1)*dp - x1*xtreme)*(i1 + cv::norm(fn))/2.0;
if (f_x1 < y0) f_x1 = (1.0 - x1)*y0 + x1*y1 +
cv::norm(dn - (1.0 - x1)*dp - x1*xtreme)*((1.0 - x1)*cv::norm(f0) + x1*cv::norm(f1) + cv::norm(fn))/2.0;
}
else {
a = x1; x1 = x2; f_x1 = f_x2; x2 = a + RESPHI*(b - a);
F_x1 = F_x2;
F_x2 = (1.0 - x2)*f0 + x2*f1;
x2_2 = x2*x2; x2_3 = x2_2*x2;
i2 = (2.0*x2_3 - 3.0*x2_2 + 1.0)*cv::norm(f0) +
(x2_3 - 2.0*x2_2 + x2)*wave.fm0 +
(-2.0*x2_3 + 3.0*x2_2)*cv::norm(f1) +
(x2_3 - x2_2)*wave.fm1;
f_x2 = (2.0*x2_3 - 3.0*x2_2 + 1.0)*y0 +
(x2_3 - 2.0*x2_2 + x2)*wave.m0 +
(-2.0*x2_3 + 3.0*x2_2)*y1 +
(x2_3 - x2_2)*wave.m1 + cv::norm(dn - (1.0 - x2)*dp - x2*xtreme)*(i2 + cv::norm(fn))/2.0;
if (f_x2 < y0) f_x2 = (1.0 - x2)*y0 + x2*y1 +
cv::norm(dn - (1.0 - x2)*dp - x2*xtreme)*((1.0 - x2)*cv::norm(f0) + x2*cv::norm(f1) + cv::norm(fn))/2.0;
}
}
res1 = std::min(res1, std::min(f_x1, f_x2));
}
}
p = cv::Point(wave.p.x + this->xarray[(wave.dir+7)%8] - this->xarray[wave.dir],
wave.p.y + this->yarray[(wave.dir+7)%8] - this->yarray[wave.dir]);
double res2 = MAX_VAL;
if (imagerect.contains(p)) {
double y1 = wave.v2;
cv::Point2d dd(h.x*(this->xarray[(wave.dir+7)%8] - this->xarray[wave.dir]), h.y*(this->yarray[(wave.dir+7)%8] - this->yarray[wave.dir]));
if (forced && cv::norm(dn - dp - dd) - cv::norm(h) > TAU ) {
res2 = y0 + cv::norm(dn - dp)*(cv::norm(f0) + cv::norm(fn))/2.0;
}
else {
cv::Point2d f1(timageH(p, 1), timageH(p, 0));
if (std::isinf(cv::norm(f1)) || std::isnan(cv::norm(f1)))
f1 = fn;
double a = 0.0, b = 1.0, x1 = a + (1-RESPHI)*(b - a), x2 = a + RESPHI*(b - a),
f_x1 = MAX_VAL, f_x2 = MAX_VAL, i1, i2;
cv::Point2d xtreme = dp + dd;
cv::Point2d F_x1, F_x2;
double f_a = y0 + cv::norm(dn - dp)*(cv::norm(f0) + cv::norm(fn))/2.0;
double f_b = y1 + cv::norm(dn - xtreme)*(cv::norm(f1) + cv::norm(fn))/2.0;
res2 = (f_a < f_b) ? f_a : f_b;
F_x1 = (1.0 - x1)*f0 + x1*f1;
F_x2 = (1.0 - x2)*f0 + x2*f1;
double x1_2 = x1*x1, x1_3 = x1_2*x1;
i1 = (2.0*x1_3 - 3.0*x1_2 + 1.0)*cv::norm(f0) +
(x1_3 - 2.0*x1_2 + x1)*wave.fm2 +
(-2.0*x1_3 + 3.0*x1_2)*cv::norm(f1) +
(x1_3 - x1_2)*wave.fm3;
f_x1 = (2.0*x1_3 - 3.0*x1_2 + 1.0)*y0 +
(x1_3 - 2.0*x1_2 + x1)*wave.m2 +
(-2.0*x1_3 + 3.0*x1_2)*y1 +
(x1_3 - x1_2)*wave.m3 + cv::norm(dn - (1.0 - x1)*dp - x1*xtreme)*(i1 + cv::norm(fn))/2.0;
if (f_x1 < y0) f_x1 = (1.0 - x1)*y0 + x1*y1 +
cv::norm(dn - (1.0 - x1)*dp - x1*xtreme)*((1.0 - x1)*cv::norm(f0) + x1*cv::norm(f1) + cv::norm(fn))/2.0;
double x2_2 = x2*x2, x2_3 = x2_2*x2;
i2 = (2.0*x2_3 - 3.0*x2_2 + 1.0)*cv::norm(f0) +
(x2_3 - 2.0*x2_2 + x2)*wave.fm2 +
(-2.0*x2_3 + 3.0*x2_2)*cv::norm(f1) +
(x2_3 - x2_2)*wave.fm3;
f_x2 = (2.0*x2_3 - 3.0*x2_2 + 1.0)*y0 +
(x2_3 - 2.0*x2_2 + x2)*wave.m2 +
(-2.0*x2_3 + 3.0*x2_2)*y1 +
(x2_3 - x2_2)*wave.m3 + cv::norm(dn - (1.0 - x2)*dp - x2*xtreme)*(i2 + cv::norm(fn))/2.0;
if (f_x2 < y0) f_x2 = (1.0 - x2)*y0 + x2*y1 +
cv::norm(dn - (1.0 - x2)*dp - x2*xtreme)*((1.0 - x2)*cv::norm(f0) + x2*cv::norm(f1) + cv::norm(fn))/2.0;
while (fabs(b - a) > TAU) {
if(f_x1 < f_x2) {
b = x2; x2 = x1; f_x2 = f_x1; x1 = a + (1 - RESPHI)*(b - a);
F_x2 = F_x1;
F_x1 = (1.0 - x1)*f0 + x1*f1;
x1_2 = x1*x1; x1_3 = x1_2*x1;
i1 = (2.0*x1_3 - 3.0*x1_2 + 1.0)*cv::norm(f0) +
(x1_3 - 2.0*x1_2 + x1)*wave.fm2 +
(-2.0*x1_3 + 3.0*x1_2)*cv::norm(f1) +
(x1_3 - x1_2)*wave.fm3;
f_x1 = (2.0*x1_3 - 3.0*x1_2 + 1.0)*y0 +
(x1_3 - 2.0*x1_2 + x1)*wave.m2 +
(-2.0*x1_3 + 3.0*x1_2)*y1 +
(x1_3 - x1_2)*wave.m3 + cv::norm(dn - (1.0 - x1)*dp - x1*xtreme)*(i1 + cv::norm(fn))/2.0;
if (f_x1 < y0) f_x1 = (1.0 - x1)*y0 + x1*y1 +
cv::norm(dn - (1.0 - x1)*dp - x1*xtreme)*((1.0 - x1)*cv::norm(f0) + x1*cv::norm(f1) + cv::norm(fn))/2.0;
}
else {
a = x1; x1 = x2; f_x1 = f_x2; x2 = a + RESPHI*(b - a);
F_x1 = F_x2;
F_x2 = (1.0 - x2)*f0 + x2*f1;
x2_2 = x2*x2; x2_3 = x2_2*x2;
i2 = (2.0*x2_3 - 3.0*x2_2 + 1.0)*cv::norm(f0) +
(x2_3 - 2.0*x2_2 + x2)*wave.fm2 +
(-2.0*x2_3 + 3.0*x2_2)*cv::norm(f1) +
(x2_3 - x2_2)*wave.fm3;
f_x2 = (2.0*x2_3 - 3.0*x2_2 + 1.0)*y0 +
(x2_3 - 2.0*x2_2 + x2)*wave.m2 +
(-2.0*x2_3 + 3.0*x2_2)*y1 +
(x2_3 - x2_2)*wave.m3 + cv::norm(dn - (1.0 - x2)*dp - x2*xtreme)*(i2 + cv::norm(fn))/2.0;
if (f_x2 < y0) f_x2 = (1.0 - x2)*y0 + x2*y1 +
cv::norm(dn - (1.0 - x2)*dp - x2*xtreme)*((1.0 - x2)*cv::norm(f0) + x2*cv::norm(f1) + cv::norm(fn))/2.0;
}
}
res2 = std::min(res2, std::min(f_x1, f_x2));
}
}
val = std::min(res1, res2);
}
return val;
}
void TurboWMMHermite::getHermite(double *y, std::pair<double, double> *m, int pos) {
double d0 = y[(pos+1)%8] - y[pos], d1 = y[(pos+2)%8] - y[(pos+1)%8];
double y0 = y[pos] - d0, y1 = y[(pos+2)%8] + d1;
/*m[pos].first = (3.0*d0 - d1)/2.0;
if (fabs(m[pos].first) > fabs(3.0*d0))
m[pos].first = 3.0*d0;*/
m[pos].first = 1.0/2.0*(y[(pos+1)%8] - y0);
m[pos].second = 1.0/2.0*(y[(pos+2)%8] - y[pos]);
m[(pos+1)%8].first = m[pos].second;
m[(pos+1)%8].second = 1.0/2.0*(y1 - y[(pos+1)%8]);
/*m[(pos+1)%8].second = (3.0*d1 - d0)/2.0;
if (fabs(m[(pos+1)%8].second) > fabs(3.0*d1))
m[(pos+1)%8].second = 3.0*d1;*/
}
TurboWMMHermite::~TurboWMMHermite() {
}
| [
"brais@magni.varpa.org"
] | brais@magni.varpa.org |
026280d40548bcefecdb7b3d13eae332fb3db19d | 3ea34c23f90326359c3c64281680a7ee237ff0f2 | /Data/1963/H | 47a8d610eefd886e03243b4070c5514694fcdea5 | [] | no_license | lcnbr/EM | c6b90c02ba08422809e94882917c87ae81b501a2 | aec19cb6e07e6659786e92db0ccbe4f3d0b6c317 | refs/heads/master | 2023-04-28T20:25:40.955518 | 2020-02-16T23:14:07 | 2020-02-16T23:14:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 92,300 | /*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | foam-extend: Open Source Cstd::filesystem::create_directory();FD |
| \\ / O peration | Version: 4.0 |
| \\ / A nd | Web: http://www.foam-extend.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "Data/1963";
object H;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField nonuniform List<vector>
4096
(
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-1.27125709081701e-12,-6.69758357994622e-12,7.63863870758918e-12)
(-2.92031925353812e-12,-1.61767973319783e-11,7.49357818858032e-12)
(-3.49889328988e-12,-2.97459603012069e-11,7.07551841110729e-12)
(-2.85469906805432e-12,-4.88500696051852e-11,5.84557962295344e-12)
(-1.78664754570145e-12,-7.6699384993509e-11,4.25885026532615e-12)
(1.64920969447835e-13,-1.21136760947889e-10,2.88206617984079e-12)
(1.67795559859368e-12,-1.92211697649979e-10,1.77143381967543e-12)
(1.10299259440052e-12,-3.0919409214798e-10,1.40043352694566e-12)
(-1.11833291801076e-13,-5.03742313411179e-10,1.13832066795135e-12)
(-5.96011468912437e-14,-7.75343085948042e-10,4.09589447026991e-13)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-2.94463253858005e-12,-6.3413960219759e-12,1.81600743231032e-11)
(-5.05467857079304e-12,-1.56809449112698e-11,1.73057130299232e-11)
(-5.65798387050272e-12,-2.88595638204947e-11,1.61590382289437e-11)
(-5.15057227149903e-12,-4.75909769404932e-11,1.40014428123223e-11)
(-3.20058334966652e-12,-7.55489660199099e-11,1.10933258158626e-11)
(-2.61467442392765e-13,-1.20120736584604e-10,8.0253069056203e-12)
(2.39156768596622e-12,-1.91690094043478e-10,5.04978495828934e-12)
(3.10916869693218e-12,-3.09344448931473e-10,3.44328261491007e-12)
(2.69018163550609e-12,-5.03870883862707e-10,2.40283680429235e-12)
(3.04768140732164e-12,-7.75549027010526e-10,1.17580034760951e-12)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-4.42689187235945e-12,-5.84117796902338e-12,3.28124216097624e-11)
(-6.93218763376476e-12,-1.47041040314555e-11,3.16037016252713e-11)
(-7.73538041271041e-12,-2.69676438803757e-11,2.98799055669323e-11)
(-6.97860946176194e-12,-4.47546045422179e-11,2.71070219068302e-11)
(-4.15398862129738e-12,-7.23581624757653e-11,2.27114777747701e-11)
(-9.85030205722951e-13,-1.17263941127061e-10,1.77466744978063e-11)
(2.58627801139503e-12,-1.90130858082613e-10,1.26251571308913e-11)
(5.74066902198367e-12,-3.09097097719339e-10,8.8166392286167e-12)
(6.44856136485893e-12,-5.03745615299566e-10,5.88548689304642e-12)
(7.00391812131123e-12,-7.75035892231036e-10,3.06411608655972e-12)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-4.8796107736143e-12,-5.35053957798192e-12,5.20025743324486e-11)
(-8.3270064510909e-12,-1.33560046227402e-11,5.10784474962114e-11)
(-9.15907351782045e-12,-2.42609950626012e-11,4.89533455163138e-11)
(-8.35727868121767e-12,-4.02898810773695e-11,4.57014161833234e-11)
(-5.41468077842447e-12,-6.68958552386952e-11,4.06182139607988e-11)
(-5.52879138697253e-13,-1.11947487140957e-10,3.44482318658257e-11)
(4.70611838453253e-12,-1.86557295527217e-10,2.79291118610414e-11)
(9.69857925833743e-12,-3.07680556548905e-10,2.15480125824239e-11)
(1.20167921918967e-11,-5.02777776488488e-10,1.48354285030741e-11)
(1.28460981682795e-11,-7.734379251625e-10,7.4817943477122e-12)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-4.85789944174084e-12,-4.807315952892e-12,7.84698060025618e-11)
(-8.0228466102301e-12,-1.15070503595236e-11,7.78911121967908e-11)
(-8.03756564536654e-12,-2.06850098672044e-11,7.61230133161374e-11)
(-7.04993452848907e-12,-3.44992691109095e-11,7.3532107146189e-11)
(-3.63279163869168e-12,-5.90613438786241e-11,6.89208635784916e-11)
(2.49772462967499e-12,-1.03175437431811e-10,6.25363508503364e-11)
(9.6107443806671e-12,-1.79056845933528e-10,5.5615788549944e-11)
(1.55580766230632e-11,-3.0247908628136e-10,4.53445341042462e-11)
(1.97387983984306e-11,-4.9760104588994e-10,3.22004819325079e-11)
(2.21869772573531e-11,-7.67986306815299e-10,1.65950810352092e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-3.9220657907947e-12,-3.95336369432585e-12,1.19833459569776e-10)
(-6.00989506602988e-12,-9.17971698844026e-12,1.19653111769495e-10)
(-5.39384186242065e-12,-1.6669941255329e-11,1.18305523786626e-10)
(-3.52285890532969e-12,-2.8193381563295e-11,1.1598961016391e-10)
(2.88700747095641e-13,-4.99442541065681e-11,1.12098454647405e-10)
(7.21539226975486e-12,-9.24313932851263e-11,1.05996325452e-10)
(1.45391276336565e-11,-1.68961317656673e-10,9.70604048179111e-11)
(2.04623135391915e-11,-2.91435417211083e-10,8.19779477425211e-11)
(2.53074250595585e-11,-4.84562038841343e-10,5.97656043360696e-11)
(2.85459938662239e-11,-7.53854741041695e-10,3.17795037087705e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-3.3177682614645e-12,-3.08999977716673e-12,1.88217322231647e-10)
(-4.33845171835281e-12,-6.67550879584819e-12,1.87774392309809e-10)
(-2.02092068907798e-12,-1.26863678247505e-11,1.8632031139847e-10)
(1.9268635469161e-12,-2.264024712013e-11,1.84172699502403e-10)
(6.35566497384456e-12,-4.13779946712385e-11,1.80821835021589e-10)
(1.34201792454803e-11,-8.00814063949905e-11,1.74793074920268e-10)
(1.96484862535709e-11,-1.53411854867383e-10,1.62272571092526e-10)
(2.51460701856337e-11,-2.70925001994763e-10,1.40477813165625e-10)
(2.9954919466913e-11,-4.58856360265386e-10,1.04905640758724e-10)
(3.32303520346801e-11,-7.24336663796482e-10,5.70204590082273e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-1.87564868819138e-12,-2.10805061410565e-12,3.02329225591349e-10)
(-1.69302171709776e-12,-4.27312794798443e-12,3.0137031732546e-10)
(2.00048417019378e-12,-8.98447931138789e-12,3.00011828639827e-10)
(6.81540706820935e-12,-1.75331109201425e-11,2.981769503477e-10)
(1.10439996813627e-11,-3.39667264154237e-11,2.94986665603099e-10)
(1.59651955073551e-11,-6.77700137296719e-11,2.8798701097847e-10)
(2.13054201677437e-11,-1.3114177200149e-10,2.71388325101953e-10)
(2.73913304379646e-11,-2.35802485413459e-10,2.38808343925421e-10)
(3.2734905831092e-11,-4.11818448108714e-10,1.84690644819236e-10)
(3.63206315020158e-11,-6.68542697039727e-10,1.04552487372289e-10)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(8.39670113602078e-13,-1.04394571172855e-12,4.93523533046068e-10)
(2.03883186699896e-12,-2.44577741825343e-12,4.92820905877037e-10)
(4.94182720745015e-12,-5.60495558653841e-12,4.9181065221836e-10)
(8.84278655077145e-12,-1.20696803297429e-11,4.90170023644635e-10)
(1.34074677686138e-11,-2.49386363870123e-11,4.86368949295474e-10)
(1.79757301447228e-11,-5.07196023729772e-11,4.76783979170472e-10)
(2.31951979506087e-11,-9.86290191505414e-11,4.54685911554799e-10)
(2.90901880072057e-11,-1.8192802015012e-10,4.10695917603668e-10)
(3.40860585313936e-11,-3.31983586699114e-10,3.32280393774966e-10)
(3.71678487426037e-11,-5.64546928902228e-10,1.99833423079652e-10)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(2.97181256004528e-12,-3.12084389335061e-13,7.64485200734834e-10)
(5.26823788804371e-12,-1.23966904845819e-12,7.64207915854868e-10)
(7.68135343511263e-12,-3.01658136653537e-12,7.63405565563324e-10)
(1.01570372468967e-11,-6.49683421199577e-12,7.61534704970771e-10)
(1.40614578180814e-11,-1.33657721444751e-11,7.56730753306521e-10)
(1.89206703701052e-11,-2.73528726984175e-11,7.45105454630233e-10)
(2.48800114936928e-11,-5.4002636110211e-11,7.19243898043677e-10)
(3.04995860438147e-11,-1.03144851470861e-10,6.66498735387715e-10)
(3.52136904632161e-11,-1.99347753224605e-10,5.64257284495446e-10)
(3.79886701062073e-11,-3.64675598358301e-10,3.65210093631144e-10)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-1.48238412978187e-12,-1.30636093425154e-11,1.53135582632066e-11)
(-2.9981118967754e-12,-3.0568413702221e-11,1.49241754859811e-11)
(-3.15535098246072e-12,-5.52681131809799e-11,1.34801852552823e-11)
(-2.52706237512055e-12,-8.91766897425056e-11,1.11336574152674e-11)
(-1.56028243386204e-12,-1.38868260258522e-10,7.70344302716765e-12)
(2.59528966352363e-13,-2.15659216503418e-10,4.14184745132819e-12)
(1.52735228488974e-12,-3.36098567769794e-10,1.5350407309539e-12)
(1.51546223672081e-12,-5.40314542499176e-10,5.382586888561e-13)
(7.45468380314063e-13,-9.30566240936189e-10,1.59358001108775e-13)
(5.55929362175113e-13,-1.82344572442577e-09,-1.89917489880091e-13)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-2.59048929835156e-12,-1.27742183359153e-11,3.53031072587166e-11)
(-4.88484464962426e-12,-2.96045061249076e-11,3.39933139771492e-11)
(-5.39230839399182e-12,-5.33888317258581e-11,3.12918788104375e-11)
(-5.07882767332188e-12,-8.61006566441248e-11,2.68422146409731e-11)
(-3.3233679835714e-12,-1.35511003333101e-10,2.01818298515171e-11)
(-1.4274095262949e-13,-2.13257169336836e-10,1.22816771497759e-11)
(2.43883406838787e-12,-3.35892392028878e-10,5.3404823697449e-12)
(3.90226329563351e-12,-5.41545974862259e-10,2.32191379248756e-12)
(3.79194952944319e-12,-9.31770811791755e-10,1.3923892813531e-12)
(3.71034697566789e-12,-1.82480821924266e-09,6.92174749081118e-13)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-3.708810278909e-12,-1.19856761966916e-11,6.15062320173832e-11)
(-6.55649098413584e-12,-2.76580357347504e-11,5.96252601758417e-11)
(-7.66914557036715e-12,-4.95977399136049e-11,5.58026235158494e-11)
(-7.04778879454519e-12,-8.01475478046049e-11,4.95723976864779e-11)
(-4.65149258145612e-12,-1.27848127692464e-10,4.00401272986385e-11)
(-1.17996682491607e-12,-2.06375136939958e-10,2.79902620308404e-11)
(2.82123335830204e-12,-3.33480675830915e-10,1.5876356617118e-11)
(7.25528018697529e-12,-5.42491398417693e-10,9.7954175351039e-12)
(8.30209336004665e-12,-9.33248555693995e-10,7.1091642469124e-12)
(8.4700671391499e-12,-1.82601352245295e-09,4.02604575564388e-12)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-4.49870756246773e-12,-1.05546822993803e-11,9.49056321790604e-11)
(-8.05085873441295e-12,-2.41415632156137e-11,9.30363694127635e-11)
(-9.48312938023437e-12,-4.32363233535553e-11,8.87273820035717e-11)
(-9.06468842514805e-12,-7.05040182303251e-11,8.17931270283157e-11)
(-7.07921004352962e-12,-1.15108737871419e-10,7.12987954057038e-11)
(-2.8058088430463e-12,-1.92992289287401e-10,5.72328135836607e-11)
(3.58676806944514e-12,-3.26538211745388e-10,4.19503850803667e-11)
(1.12096930702223e-11,-5.4238090207811e-10,3.18583633260635e-11)
(1.41936957491464e-11,-9.33862153977895e-10,2.31417027136455e-11)
(1.48762741696375e-11,-1.82572627555964e-09,1.22904673617967e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-5.13315789453611e-12,-8.76932865937451e-12,1.42169248234316e-10)
(-8.58208110066227e-12,-1.95028940698795e-11,1.40353688996813e-10)
(-9.46172808729433e-12,-3.51224054702678e-11,1.36748277599436e-10)
(-8.74457850840974e-12,-5.80294864367641e-11,1.31035367235849e-10)
(-6.36536868258268e-12,-9.75250643859635e-11,1.22257698737401e-10)
(-1.32575721662094e-12,-1.71568836494298e-10,1.11126162245533e-10)
(9.78647054951382e-12,-3.09761334618021e-10,1.01620467630576e-10)
(1.765845972472e-11,-5.36964938791812e-10,7.97984389342507e-11)
(2.23051922470885e-11,-9.27885710333715e-10,5.58438576686378e-11)
(2.46504925185386e-11,-1.81809464088311e-09,2.87920901320644e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-4.60508190767184e-12,-6.60353459686658e-12,2.13301392905848e-10)
(-7.16651527575434e-12,-1.49833487552189e-11,2.12300978188425e-10)
(-7.06150167028765e-12,-2.75267263603255e-11,2.09615500123148e-10)
(-5.18483783198007e-12,-4.56695689709382e-11,2.04998693598429e-10)
(-2.17542949281561e-12,-7.9192918642429e-11,1.98892864213073e-10)
(3.80132601367327e-12,-1.49985457273482e-10,1.902018394166e-10)
(1.40721219197976e-11,-2.94982917073483e-10,1.7779036103438e-10)
(2.2164241729353e-11,-5.20872057858241e-10,1.49004796302331e-10)
(2.75878471107817e-11,-9.06733633731885e-10,1.06807311127423e-10)
(3.08074203298967e-11,-1.79352054315443e-09,5.60663536273038e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-3.8567875026882e-12,-4.55186811198599e-12,3.28421083254733e-10)
(-5.28675165487597e-12,-1.06600487537549e-11,3.2758031291089e-10)
(-3.57519730637297e-12,-2.03942341104173e-11,3.25318002681173e-10)
(1.70591827735583e-13,-3.49733069584447e-11,3.22298663113542e-10)
(4.97315681937046e-12,-6.23352873279762e-11,3.1910132408229e-10)
(1.36292904079277e-11,-1.25132839686417e-10,3.12560398465188e-10)
(1.9173161314632e-11,-2.68020159092201e-10,2.89973642707245e-10)
(2.55957260110537e-11,-4.84830786371029e-10,2.54978222003414e-10)
(3.08021890604355e-11,-8.60858669854276e-10,1.87620391006059e-10)
(3.44568442867117e-11,-1.74056563521168e-09,1.00797277911635e-10)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-1.9808453246799e-12,-3.04727188984811e-12,5.25869812762872e-10)
(-2.16188356119581e-12,-7.20593208249041e-12,5.25109743295896e-10)
(4.5583873747511e-13,-1.46365243561924e-11,5.23615928017045e-10)
(4.54226122241065e-12,-2.73184571710655e-11,5.21642643564765e-10)
(9.01556427755537e-12,-5.29567355387557e-11,5.18741989737102e-10)
(1.5513470027204e-11,-1.11286390169787e-10,5.10909390548881e-10)
(2.13726484933557e-11,-2.31990076903848e-10,4.85949722411653e-10)
(2.76345642806313e-11,-4.1997941654349e-10,4.27297999632792e-10)
(3.30382018686233e-11,-7.76591566502819e-10,3.28318699580805e-10)
(3.68773507362207e-11,-1.64156108203459e-09,1.86316355944097e-10)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(8.10435960239536e-13,-1.88884488085114e-12,9.10269253228091e-10)
(1.84297715588198e-12,-4.92207880936461e-12,9.1010112839079e-10)
(3.9940815611732e-12,-9.90526567987909e-12,9.09151101510811e-10)
(7.07101478218979e-12,-1.98129495749094e-11,9.07261245199766e-10)
(1.14195736510914e-11,-4.09854827660919e-11,9.02093856959058e-10)
(1.6707068085816e-11,-8.58476157250213e-11,8.87897437404475e-10)
(2.25588088614124e-11,-1.72759285452209e-10,8.52228769959863e-10)
(2.87225431566415e-11,-3.22055034390505e-10,7.75061445603643e-10)
(3.38971957521801e-11,-6.3561526969431e-10,6.36414643973082e-10)
(3.71299412784572e-11,-1.45614926676173e-09,3.97550659681212e-10)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(2.93701305067635e-12,-9.19294833576114e-13,1.80343175919686e-09)
(4.83091913112855e-12,-2.9078945203122e-12,1.8037353714636e-09)
(6.5356326611284e-12,-5.68786664262109e-12,1.80266159463039e-09)
(8.46415469915145e-12,-1.0972307362377e-11,1.7998304696639e-09)
(1.23209843498864e-11,-2.26284516703268e-11,1.79236871518709e-09)
(1.74293542582331e-11,-4.69900823673258e-11,1.77344516112682e-09)
(2.36225380394291e-11,-9.39272916341267e-11,1.72960664187614e-09)
(2.95961854652701e-11,-1.83067923396979e-10,1.63759438758745e-09)
(3.49131281029142e-11,-3.9678523796093e-10,1.45537273357114e-09)
(3.8523165379145e-11,-1.05886094096125e-09,1.05899216887738e-09)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-1.38239235916757e-12,-1.83345853029749e-11,2.13595574908373e-11)
(-2.51802924367414e-12,-4.15805013997746e-11,2.06010609965956e-11)
(-2.68810459696671e-12,-7.28547443632504e-11,1.82896936312574e-11)
(-2.17288108516659e-12,-1.15901883609153e-10,1.4579738461082e-11)
(-1.355943783713e-12,-1.76859897368175e-10,9.02722144198738e-12)
(4.64288520306293e-13,-2.666325487525e-10,2.48067758242748e-12)
(2.31795858556632e-12,-3.96824491055266e-10,-2.83433457845184e-12)
(3.12579528759845e-12,-5.84749884404271e-10,-3.7896664182207e-12)
(2.29931472695105e-12,-8.52398862167018e-10,-2.45705157446334e-12)
(1.72850668899093e-12,-1.17704200864203e-09,-1.18331642739895e-12)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-2.06923815633119e-12,-1.78541881509743e-11,4.7309053474462e-11)
(-4.12987987379086e-12,-3.97052858366818e-11,4.5571331161657e-11)
(-4.73373603775604e-12,-6.96115074656579e-11,4.15397967730134e-11)
(-4.37155172242824e-12,-1.10675732005196e-10,3.45395676882548e-11)
(-3.08609092259814e-12,-1.70636950736623e-10,2.34768211100963e-11)
(-8.35785693723639e-14,-2.61966100016184e-10,9.01946246134037e-12)
(3.04568644663066e-12,-3.96886232642576e-10,-4.49114961500133e-12)
(5.77721136340466e-12,-5.87627594233094e-10,-7.10971186154738e-12)
(5.96990796391683e-12,-8.55378127407491e-10,-4.28588768086582e-12)
(5.60782493529253e-12,-1.17999172609924e-09,-1.64406051836232e-12)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-3.25883233662115e-12,-1.62250577038691e-11,8.10332057069572e-11)
(-6.25032684219357e-12,-3.60118777293636e-11,7.85354627857332e-11)
(-7.80033630044847e-12,-6.28974227453695e-11,7.27938678890374e-11)
(-7.15904798161364e-12,-1.00179298917963e-10,6.28091728283557e-11)
(-5.34101713477489e-12,-1.570215507527e-10,4.64989598081852e-11)
(-2.44890906378108e-12,-2.49593078645824e-10,2.28719303672741e-11)
(1.95970835573222e-12,-3.95793032914925e-10,-3.35020909578682e-12)
(9.83103713453419e-12,-5.93563860396354e-10,-6.2544902795161e-12)
(1.19988101362231e-11,-8.61257761839194e-10,-1.31777646601129e-12)
(1.22088660007677e-11,-1.18480798928445e-09,8.78798117906346e-13)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-4.41479843687923e-12,-1.37347864694135e-11,1.24195381461783e-10)
(-8.38054046978479e-12,-3.04421573870501e-11,1.21136245766034e-10)
(-1.06627922889129e-11,-5.27122677707577e-11,1.14584273680442e-10)
(-1.10448885967466e-11,-8.39425342961497e-11,1.03447463664408e-10)
(-1.05969017062442e-11,-1.3362880116313e-10,8.46698420454548e-11)
(-8.94683313344884e-12,-2.22942295757881e-10,5.51740593385512e-11)
(-3.0980873033638e-12,-3.90089770135333e-10,1.53862550074456e-11)
(1.45103903967148e-11,-6.04151238189755e-10,1.4226213031097e-11)
(1.90684874571936e-11,-8.69127202885841e-10,1.60677956593998e-11)
(1.95351068542547e-11,-1.18862966069666e-09,1.04266944670167e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-5.4833927199577e-12,-1.065135378719e-11,1.81918076713521e-10)
(-9.49621501697657e-12,-2.35245444799148e-11,1.78957840331399e-10)
(-1.13444968348783e-11,-4.05201897632779e-11,1.73257465138271e-10)
(-1.23268274755855e-11,-6.3672338042224e-11,1.64038687715134e-10)
(-1.35659779332656e-11,-1.00725581162204e-10,1.49238942591912e-10)
(-1.34034418234454e-11,-1.72530909924643e-10,1.31924060578743e-10)
(1.68300817003985e-11,-3.44699068317947e-10,1.43248293271507e-10)
(2.55201600567589e-11,-6.14600609656554e-10,9.44645563658707e-11)
(2.82048831834423e-11,-8.72246371582206e-10,6.37544939146965e-11)
(2.88684849214498e-11,-1.18443131002936e-09,3.30353568828937e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-5.65633367455547e-12,-7.63174049229861e-12,2.63567108787114e-10)
(-8.80433721224291e-12,-1.71292700176246e-11,2.61459223126107e-10)
(-9.57718739567751e-12,-2.93442154222474e-11,2.57384134597145e-10)
(-9.77527045787583e-12,-4.42099938605364e-11,2.51172974154167e-10)
(-1.03420360118219e-11,-6.95177885321478e-11,2.42954543307196e-10)
(-8.63981319104964e-12,-1.3432883194006e-10,2.33075607648562e-10)
(1.58949286709685e-11,-3.47262616669303e-10,2.37952947376769e-10)
(2.83204554163642e-11,-6.05879695723423e-10,1.91540975073314e-10)
(3.24538407339934e-11,-8.52183136058113e-10,1.32449067688339e-10)
(3.39188660135378e-11,-1.15745445911666e-09,6.79305654216263e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-4.52061338039571e-12,-5.12836613973823e-12,3.84523654305778e-10)
(-6.47855809698106e-12,-1.16963547533739e-11,3.82796066599079e-10)
(-6.3135674929069e-12,-1.96122286565789e-11,3.8016673038443e-10)
(-4.28691892832578e-12,-2.81651457429239e-11,3.78786795912313e-10)
(2.13553064751296e-12,-4.03962749128975e-11,3.81704389767884e-10)
(2.2369596649021e-11,-7.90675923423103e-11,3.90265296030717e-10)
(1.81384998302854e-11,-3.1548776546325e-10,3.44313486743647e-10)
(2.81021871803432e-11,-5.65478501951167e-10,3.33526913475289e-10)
(3.33581988038306e-11,-7.97032069297665e-10,2.30225859673855e-10)
(3.62495690217913e-11,-1.09421831228722e-09,1.1777678487567e-10)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-2.37920286642161e-12,-3.0624146950297e-12,5.62378882013076e-10)
(-2.95192155535043e-12,-7.59285994147041e-12,5.61409542093372e-10)
(-2.3021354873369e-12,-1.37709178014951e-11,5.60049174689484e-10)
(-6.25925448479507e-14,-2.28896717276593e-11,5.60488609743402e-10)
(4.87691069232229e-12,-4.25005426405242e-11,5.64616601412543e-10)
(1.50343637199797e-11,-1.03977887408929e-10,5.71781013971239e-10)
(2.07935798206083e-11,-2.87926619105255e-10,5.62328507572383e-10)
(2.86894821784854e-11,-4.67507768257523e-10,4.7945084467758e-10)
(3.40642486971656e-11,-6.88996771119769e-10,3.48091311571229e-10)
(3.77818914080846e-11,-9.78513081072166e-10,1.86974541349495e-10)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(9.01075012433054e-15,-1.54920569303808e-12,8.21931816755772e-10)
(7.78819746615036e-13,-4.62938063670107e-12,8.21889827278535e-10)
(1.66653883560431e-12,-9.6885219155102e-12,8.21559072183669e-10)
(3.39776081044746e-12,-1.91750645582406e-11,8.2143772076845e-10)
(7.25896211029265e-12,-3.99423755759542e-11,8.19921872632231e-10)
(1.35182021724238e-11,-9.19563036063408e-11,8.11767027873702e-10)
(2.0894139399357e-11,-2.03035618432658e-10,7.78906910594335e-10)
(2.83822337926728e-11,-3.38102152864647e-10,6.84712301361185e-10)
(3.39311483114769e-11,-5.29235982568643e-10,5.29033160267283e-10)
(3.7392275159007e-11,-7.91297665509561e-10,3.03242592196813e-10)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(1.71410594976704e-12,-5.80436253174313e-13,1.1448545095999e-09)
(2.99680144366212e-12,-2.4327429506724e-12,1.14538455708744e-09)
(3.67889098543928e-12,-5.59371948830597e-12,1.14496623549849e-09)
(4.95360181324652e-12,-1.14006338111635e-11,1.14319095545266e-09)
(8.61608674021749e-12,-2.38951096218467e-11,1.13722607871675e-09)
(1.42777911410146e-11,-5.23896116609429e-11,1.11949552878584e-09)
(2.17075006944085e-11,-1.0617876146972e-10,1.07239350281238e-09)
(2.87499160834194e-11,-1.82240682718263e-10,9.68858526860898e-10)
(3.45084548362693e-11,-3.03214326259689e-10,7.87470375853798e-10)
(3.86543932959257e-11,-4.86987039534245e-10,4.8523214216825e-10)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-1.10429301691169e-12,-2.18098446013435e-11,2.49828032142668e-11)
(-2.08187744145192e-12,-4.8019599064762e-11,2.42679758215161e-11)
(-2.22138632436668e-12,-8.32840541918566e-11,2.19114184420422e-11)
(-1.84651567001764e-12,-1.29551141548059e-10,1.69020348246752e-11)
(-1.03234655570443e-12,-1.91955709384024e-10,9.17723448242893e-12)
(1.11285194488762e-12,-2.80333643980139e-10,-6.71326758745955e-13)
(3.33503201262796e-12,-3.98500557455498e-10,-9.66439354598674e-12)
(4.67089027266494e-12,-5.45705599309358e-10,-1.00324570218236e-11)
(4.00484482031053e-12,-7.12320999853737e-10,-6.13477391844064e-12)
(3.49490771881804e-12,-8.53153753895765e-10,-2.67821979499096e-12)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-1.96064629062665e-12,-2.12313162053941e-11,5.57684848250755e-11)
(-3.79175359245425e-12,-4.5729913104587e-11,5.35830283621691e-11)
(-4.44759167330933e-12,-7.87641745546764e-11,4.87819845965022e-11)
(-3.80523823145762e-12,-1.2229147922728e-10,3.88107142844652e-11)
(-2.2441322577897e-12,-1.82703904540709e-10,2.25695140160556e-11)
(1.05401213662691e-12,-2.72737219543921e-10,-4.01605921731946e-13)
(4.57104896551028e-12,-4.00017715518638e-10,-2.53794655455247e-11)
(8.88965334604432e-12,-5.51407044702878e-10,-2.49498066759002e-11)
(9.20771523313522e-12,-7.17462477077174e-10,-1.43293036857146e-11)
(8.78002760204364e-12,-8.57602266972413e-10,-5.68855062453306e-12)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-3.25136064985784e-12,-1.88575990336365e-11,9.43605888895566e-11)
(-6.07845228782452e-12,-4.07109687021962e-11,9.10015108746801e-11)
(-8.00079621438043e-12,-6.93386759205266e-11,8.37078331921588e-11)
(-7.08559958323908e-12,-1.07159622717075e-10,6.91674801132268e-11)
(-5.10673728342717e-12,-1.61868828471743e-10,4.40988834190057e-11)
(-2.87755248876263e-12,-2.52050276077281e-10,1.6029384096422e-12)
(-8.39273239999929e-13,-4.06907413989329e-10,-6.29493981312384e-11)
(1.5481701114279e-11,-5.67938329165602e-10,-4.8199351842742e-11)
(1.76716765988683e-11,-7.30493641213159e-10,-2.15230499706613e-11)
(1.69093355312464e-11,-8.67163165272714e-10,-6.50152989040867e-12)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-4.43909542331356e-12,-1.55421829604427e-11,1.41632844937885e-10)
(-8.74618129132603e-12,-3.35883231735388e-11,1.3766869791304e-10)
(-1.17180602803617e-11,-5.57625882656819e-11,1.29058958770718e-10)
(-1.25374632317449e-11,-8.39257993480411e-11,1.12416020200769e-10)
(-1.40043390002598e-11,-1.23808698263828e-10,8.17117099322869e-11)
(-1.9570414635595e-11,-1.9975172054642e-10,1.83512744437205e-11)
(-4.73287471443588e-11,-4.42747648905304e-10,-1.59958902351041e-10)
(2.3118179235069e-11,-6.11890601427757e-10,-6.55652411923757e-11)
(2.7828757346026e-11,-7.5407037781686e-10,-1.39728351402084e-11)
(2.57634506537369e-11,-8.78956452725672e-10,9.90904089484038e-13)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-5.54276963272367e-12,-1.16611883096467e-11,2.0025786371616e-10)
(-1.01911142861345e-11,-2.49449395650951e-11,1.96360272667683e-10)
(-1.33016937527863e-11,-3.9634787227089e-11,1.88252160390825e-10)
(-1.69894265340612e-11,-5.49986172160833e-11,1.73723498076495e-10)
(-2.74588885501235e-11,-6.82055993565888e-11,1.47340055537526e-10)
(-6.29297525008472e-11,-6.2095059266621e-11,9.75436965511126e-11)
(6.81773669574245e-11,-8.53732981146e-10,-6.30982163952516e-18)
(4.75093085747486e-11,-7.18818342836705e-10,7.2335589267364e-11)
(3.88607846911313e-11,-7.84732582017031e-10,5.0042556632175e-11)
(3.49269908919348e-11,-8.84788287534005e-10,2.81489401809439e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-6.05182236608328e-12,-7.82669087488363e-12,2.7796377464759e-10)
(-1.01621639475397e-11,-1.65198572897292e-11,2.75075742801872e-10)
(-1.30980137183344e-11,-2.43899885650321e-11,2.69530041938752e-10)
(-1.76016877285446e-11,-2.74691726899303e-11,2.6019468418073e-10)
(-2.95846139724721e-11,-1.95140353491599e-11,2.44455948042202e-10)
(-6.87783925170356e-11,1.0485181325265e-11,2.04628889807869e-10)
(3.05320497683907e-11,-8.5789119370594e-10,-8.10919672990623e-17)
(4.70111690291516e-11,-7.3159297832707e-10,1.99845897865079e-10)
(4.18212762402805e-11,-7.74856302083972e-10,1.33237274751618e-10)
(3.8613284605524e-11,-8.61841484520079e-10,6.77721976196549e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-4.85897711835272e-12,-4.91572355597649e-12,3.82260686674092e-10)
(-7.95271669427227e-12,-1.01248329692742e-11,3.80505019588499e-10)
(-1.07749438758588e-11,-1.21735314743674e-11,3.78416138905677e-10)
(-1.24799867991543e-11,-4.27812407560609e-12,3.78889390208885e-10)
(-4.3211078878e-12,3.89266255765976e-11,3.95335759919118e-10)
(9.32317010027481e-11,2.43321270286409e-10,4.9876659036331e-10)
(1.36392674082331e-12,-1.02720512286117e-09,1.11926890215414e-09)
(3.34325072880463e-11,-7.19976701537618e-10,4.985920005575e-10)
(3.77719754240589e-11,-7.21796205278953e-10,2.61491694268592e-10)
(3.83211226825047e-11,-7.98005279891825e-10,1.2118481148666e-10)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-2.92307194868868e-12,-2.56955256854388e-12,5.16431682446102e-10)
(-4.5550334562549e-12,-6.12021980689857e-12,5.15894922996578e-10)
(-6.8239664272063e-12,-7.42133191179522e-12,5.15680271558683e-10)
(-7.9051913835561e-12,-4.13582656963705e-12,5.19391365522389e-10)
(-4.84566893078364e-12,5.00461588887342e-12,5.36426296786183e-10)
(1.24652863160117e-11,-1.17321392336365e-11,5.91388972359419e-10)
(1.87802420430111e-11,-4.05164307795599e-10,7.13859265315201e-10)
(3.06433998918902e-11,-5.0364137539136e-10,5.20421673980941e-10)
(3.54202303679509e-11,-5.86262338419473e-10,3.36827917915849e-10)
(3.75410171946446e-11,-6.77964020308519e-10,1.68974728750972e-10)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-9.17769212624762e-13,-9.87214878895022e-13,6.73062384481592e-10)
(-1.08706284452489e-12,-3.43272498476848e-12,6.73354325403407e-10)
(-2.30691217627143e-12,-5.84555401139659e-12,6.73944877758502e-10)
(-2.86082180049646e-12,-9.22464048432721e-12,6.76355382665893e-10)
(-6.33459085323928e-13,-1.96267082031132e-11,6.82237772197952e-10)
(6.81162750632438e-12,-6.58357328353081e-11,6.92625747339559e-10)
(1.82318916695162e-11,-2.21010045638939e-10,6.90001402108912e-10)
(2.81999047403203e-11,-3.24537230421841e-10,5.77020860136467e-10)
(3.37000600729339e-11,-4.18978501080302e-10,4.16560876533769e-10)
(3.63242413804968e-11,-5.07734714887142e-10,2.22817115481057e-10)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(6.03622209046399e-13,-3.89707945846568e-13,8.10549903604365e-10)
(9.82380081945373e-13,-1.82468104345864e-12,8.10841571339758e-10)
(-1.39548457038213e-13,-3.79327142634482e-12,8.10969271337704e-10)
(-4.82155262007964e-13,-7.35307137334628e-12,8.1113158623555e-10)
(2.45152704927897e-12,-1.69226954430231e-11,8.09558079889897e-10)
(8.99020545361749e-12,-4.49139367523147e-11,7.99979566345199e-10)
(1.90637151759998e-11,-1.05486715872547e-10,7.63311645438448e-10)
(2.78973843724297e-11,-1.63343616429733e-10,6.61701617719489e-10)
(3.35323622619616e-11,-2.23917307903897e-10,5.00522764877928e-10)
(3.68994959300269e-11,-2.82567960023711e-10,2.79014697495556e-10)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-9.67994020103252e-13,-2.45340021931773e-11,2.84574845664369e-11)
(-2.01500602214184e-12,-5.20619574267202e-11,2.729344235199e-11)
(-1.73188234418267e-12,-8.83303113668403e-11,2.42386046837457e-11)
(-1.38137764854383e-12,-1.33247042939338e-10,1.80977540705607e-11)
(-4.35590157849231e-13,-1.91676966416477e-10,8.85414999506229e-12)
(2.50949429593002e-12,-2.7125371027615e-10,-3.65367436241509e-12)
(5.22025355157765e-12,-3.71998117289232e-10,-1.61064580630491e-11)
(6.47465256280173e-12,-4.84329024685212e-10,-1.62658241067641e-11)
(5.68976792029731e-12,-5.92043578882223e-10,-1.01470395176227e-11)
(5.26520100053908e-12,-6.64782007035846e-10,-4.59912258139467e-12)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-2.1489069994419e-12,-2.34690057711805e-11,6.14625108919323e-11)
(-4.00965422919595e-12,-4.89810962734094e-11,5.82328931107507e-11)
(-3.90181999540982e-12,-8.21099404976408e-11,5.1964707255513e-11)
(-2.69589447328815e-12,-1.23987916283888e-10,3.99858785651133e-11)
(-1.08088388922381e-13,-1.79472635563031e-10,2.02964558752403e-11)
(5.34492829378952e-12,-2.5931442811635e-10,-9.66984007529252e-12)
(1.10310885666068e-11,-3.72889058688849e-10,-4.84809648856824e-11)
(1.4800434818476e-11,-4.91164395630921e-10,-4.5712566478355e-11)
(1.35981263079921e-11,-5.983009661642e-10,-2.62490042974496e-11)
(1.26523752778513e-11,-6.7016053334244e-10,-1.09471420954044e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-3.20769870820405e-12,-2.07378922694689e-11,1.0107943394037e-10)
(-5.90742013393226e-12,-4.3025856496532e-11,9.64321042219919e-11)
(-7.03653079028584e-12,-7.04378668251771e-11,8.71048262576871e-11)
(-5.25082625810488e-12,-1.04875764156708e-10,6.97331091453419e-11)
(-6.70922482001741e-13,-1.50785041960229e-10,3.97579331976261e-11)
(9.37622852130688e-12,-2.22544488864185e-10,-1.56535337988438e-11)
(2.02509153875598e-11,-3.81087042378571e-10,-1.43211975143204e-10)
(3.27576715043185e-11,-5.13999191155355e-10,-1.0930362841652e-10)
(2.62268931222792e-11,-6.15846888755341e-10,-4.80517651197591e-11)
(2.22010930939248e-11,-6.8281924201895e-10,-1.61641469196158e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-4.35594304927354e-12,-1.66560055071283e-11,1.47855869392241e-10)
(-8.77982575743265e-12,-3.4317885624272e-11,1.42756146479219e-10)
(-1.12029227489923e-11,-5.42949534882954e-11,1.31919556204881e-10)
(-1.07603350952075e-11,-7.63779502692166e-11,1.12553981204364e-10)
(-6.24700241893367e-12,-9.70635637578399e-11,8.05224374701354e-11)
(2.10831008793178e-11,-9.76132235776304e-11,3.31739503582798e-11)
(2.69262923937672e-10,-4.36864962542534e-10,2.42354358860488e-17)
(7.84535145918737e-11,-5.8351568057429e-10,-2.56747647861106e-10)
(4.35272223164395e-11,-6.51107559070555e-10,-6.45326840181825e-11)
(3.25861895512839e-11,-7.00711392766548e-10,-1.34247209930279e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-5.47967601901741e-12,-1.2260964935438e-11,2.01761107503616e-10)
(-1.05080842846429e-11,-2.46907798640169e-11,1.96764500815669e-10)
(-1.40178301005159e-11,-3.66195630213191e-11,1.86153572431336e-10)
(-1.81354285212537e-11,-4.611249372588e-11,1.68049346532208e-10)
(-2.63540935711295e-11,-4.98168050245979e-11,1.3651802398017e-10)
(-3.79662902317348e-11,-4.39765317154164e-11,8.21771963813615e-11)
(-1.60598202899217e-17,1.00176672633372e-16,-4.08591285372001e-18)
(8.25769767003234e-11,-7.85534283775291e-10,8.29537761246874e-18)
(5.08781212092756e-11,-7.04862113865488e-10,1.57794522384102e-11)
(4.01291280590714e-11,-7.14956835584659e-10,1.58386266392083e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-6.07475783927721e-12,-7.88257421562211e-12,2.68942209653711e-10)
(-1.10114874048619e-11,-1.53789724278771e-11,2.65127696818438e-10)
(-1.59791130509967e-11,-1.97810824474523e-11,2.57172377569687e-10)
(-2.50540002043138e-11,-1.69205408232054e-11,2.43141396700069e-10)
(-4.81982166639175e-11,-2.63176562019305e-12,2.16230258296639e-10)
(-9.69855105782684e-11,2.32471617336073e-11,1.53069323706877e-10)
(-3.34245497623741e-20,7.5901336380844e-17,-7.46789682423845e-18)
(1.02003515353071e-10,-7.79709710990413e-10,-3.69825559018017e-17)
(5.42262565672849e-11,-6.99754081796919e-10,8.62808699007146e-11)
(4.25492775967912e-11,-6.96883900883081e-10,5.39169189712889e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-5.44948102021514e-12,-4.40729010686669e-12,3.52825511657136e-10)
(-9.86844917379408e-12,-8.06421274117039e-12,3.50676668346708e-10)
(-1.60003947416424e-11,-6.25889584007029e-12,3.46522203238845e-10)
(-2.9068654015378e-11,7.71994581945869e-12,3.40642256419688e-10)
(-7.38299286442564e-11,4.81822771241832e-11,3.30925675535626e-10)
(-2.7221720126814e-10,1.34639664806115e-10,2.89533468771795e-10)
(1.3272017286829e-17,1.04536265220598e-16,-1.29276466687542e-16)
(5.41974874306533e-11,-8.27661572578146e-10,5.17284217673031e-10)
(4.25449913465629e-11,-6.56571308555139e-10,2.47916494603842e-10)
(3.94646745857959e-11,-6.37697923238546e-10,1.10077293642483e-10)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-3.96865018890191e-12,-1.92148022142558e-12,4.4957113118398e-10)
(-7.02787684042255e-12,-3.51354462271654e-12,4.49382178139855e-10)
(-1.21108382913609e-11,-2.25822196529025e-13,4.48677594424824e-10)
(-1.98513087326138e-11,1.55339298488194e-11,4.50819132477097e-10)
(-3.51770204120646e-11,6.79486545249704e-11,4.66730545601772e-10)
(-5.59014130380797e-11,2.55139742744885e-10,5.34235760972121e-10)
(2.80635712206823e-11,-5.17284234192186e-10,8.33672513754786e-10)
(3.51330109873746e-11,-5.15699478290184e-10,5.17085849013421e-10)
(3.5989582193666e-11,-5.06511145439032e-10,3.06528562789527e-10)
(3.62864405243366e-11,-5.21704898369272e-10,1.46511471253938e-10)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-1.80721706747262e-12,-7.91036980480273e-13,5.45770128701861e-10)
(-3.28565914098548e-12,-1.4391750690691e-12,5.46700323425328e-10)
(-6.76969966865212e-12,-5.00659761987512e-13,5.47755559165218e-10)
(-1.06147804435822e-11,3.1773895156812e-12,5.50728650297184e-10)
(-1.37254469870163e-11,9.22646608796825e-12,5.5978065012687e-10)
(-1.14858233460302e-11,-6.87924720951961e-12,5.82525974678613e-10)
(1.56891038755691e-11,-2.21586697645244e-10,6.16144764929602e-10)
(2.74662743509238e-11,-2.99867108768198e-10,4.90681740799072e-10)
(3.23826279492657e-11,-3.41174520728532e-10,3.35798216248664e-10)
(3.39746019981512e-11,-3.7079965700321e-10,1.71876446396922e-10)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-7.77534721926404e-14,-6.23147053316207e-13,6.15211850025482e-10)
(-9.70000959459817e-13,-8.42946783991195e-13,6.15652545247682e-10)
(-4.09513478122936e-12,-8.36955384437879e-13,6.16262846553639e-10)
(-6.26172028970034e-12,-1.74667216213251e-12,6.17726920006779e-10)
(-4.89265484904799e-12,-6.65768011415492e-12,6.19192289647941e-10)
(7.44189608053744e-13,-2.91799661596054e-11,6.17056055914228e-10)
(1.51870270224119e-11,-9.68276500061474e-11,5.93600355731557e-10)
(2.57326207842612e-11,-1.42182726703684e-10,4.9967027934478e-10)
(3.11231217404598e-11,-1.73524792730095e-10,3.60514671377647e-10)
(3.33462334018301e-11,-1.9495559454872e-10,1.9061500055412e-10)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-8.6894822764681e-13,-2.59138083084431e-11,3.04929014362631e-11)
(-2.04102950720841e-12,-5.39916865606729e-11,2.88349147000442e-11)
(-1.81140260019172e-12,-8.95652944672463e-11,2.52089595197023e-11)
(-1.39690022850605e-12,-1.31270250042286e-10,1.86742257006895e-11)
(-1.32096653807363e-13,-1.84043113589056e-10,8.94638859614591e-12)
(3.02299583673617e-12,-2.52874143190687e-10,-3.96060516574372e-12)
(6.27056099496641e-12,-3.36477704495981e-10,-1.68010575403219e-11)
(7.19123891928851e-12,-4.22523262129064e-10,-1.7789963566911e-11)
(6.39923826610867e-12,-4.96315041217464e-10,-1.17644418358183e-11)
(6.0446047257923e-12,-5.39896819204787e-10,-5.48475951234001e-12)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-1.6504027199555e-12,-2.4371997511316e-11,6.2995687574586e-11)
(-3.69670815085296e-12,-5.06110249313238e-11,5.9572439462916e-11)
(-3.59506497746022e-12,-8.29008852155748e-11,5.2498737095245e-11)
(-2.11862391061314e-12,-1.21592026676022e-10,4.00359496434223e-11)
(1.17061395881715e-12,-1.71304492951464e-10,1.98719311261952e-11)
(7.38611385198826e-12,-2.39500141631077e-10,-1.04078723873026e-11)
(1.64606738489753e-11,-3.34568641546853e-10,-4.95878359978155e-11)
(1.81716681620358e-11,-4.27612688238744e-10,-4.89544676230003e-11)
(1.58421866969955e-11,-5.0228375610184e-10,-2.94755687509077e-11)
(1.43639418589887e-11,-5.45583296533588e-10,-1.28767943825003e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-2.64225575216122e-12,-2.13011074155497e-11,1.00942870049486e-10)
(-5.28811304187999e-12,-4.41657553172027e-11,9.63506163813233e-11)
(-5.80772701483195e-12,-7.07200624698074e-11,8.6071193651976e-11)
(-3.773464197875e-12,-1.01659482617425e-10,6.82078386077113e-11)
(1.01906631203221e-12,-1.40931880464921e-10,3.82933637943333e-11)
(1.20034045791184e-11,-1.99172376644272e-10,-1.57672500402774e-11)
(4.21204888248475e-11,-3.33796791341689e-10,-1.38884636450863e-10)
(4.10222976264131e-11,-4.44831309161738e-10,-1.1420514946923e-10)
(2.95999452373348e-11,-5.17308003878459e-10,-5.33375985789457e-11)
(2.39290969217517e-11,-5.57171395879944e-10,-1.93284858574374e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-3.65126070792826e-12,-1.68969686831183e-11,1.44861116926421e-10)
(-7.57034124334949e-12,-3.4674949423773e-11,1.39690099860103e-10)
(-9.51273821541895e-12,-5.40252758213946e-11,1.27837338548809e-10)
(-8.99424790431912e-12,-7.27858891927222e-11,1.07759418641917e-10)
(-6.14527404031353e-12,-8.67340205851433e-11,7.68642681090928e-11)
(6.20335139942758e-13,-7.42318660303698e-11,3.43050303464861e-11)
(8.91455333150089e-11,-3.59618745896676e-10,1.36070266055543e-17)
(8.82571539499546e-11,-5.00212110539558e-10,-2.57311130029658e-10)
(4.61738140862493e-11,-5.46864918539871e-10,-7.23655992098472e-11)
(3.34069113764055e-11,-5.72698257580202e-10,-1.80494968227938e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-4.86146005090842e-12,-1.21551231045715e-11,1.92957376905688e-10)
(-9.20896333643073e-12,-2.45404846093533e-11,1.87989182253247e-10)
(-1.27520847752814e-11,-3.623444842446e-11,1.76605898824676e-10)
(-1.57960588718621e-11,-4.42328303971341e-11,1.56998257778448e-10)
(-1.91983053767513e-11,-4.60669500302238e-11,1.24720885600982e-10)
(-2.30127832134881e-11,-3.95699121997794e-11,7.3200822167333e-11)
(-4.16577450358194e-18,5.04729764103678e-17,-3.83972283059433e-18)
(6.09729599724143e-11,-6.73741280494432e-10,9.44650379174343e-18)
(4.57109147399342e-11,-5.92200981863405e-10,5.6170128902205e-12)
(3.78948199967125e-11,-5.84086742831773e-10,9.45425456634704e-12)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-5.73552911273547e-12,-7.76127960533466e-12,2.49655328819226e-10)
(-1.0370927842856e-11,-1.50830312874476e-11,2.45862295376024e-10)
(-1.54703187887081e-11,-1.95138701787211e-11,2.37117344706112e-10)
(-2.27833484436247e-11,-1.70713815293227e-11,2.20563000181569e-10)
(-3.5851324818519e-11,-5.36921087265118e-12,1.89476742885506e-10)
(-5.53086824760043e-11,1.35784642421339e-11,1.25623223337145e-10)
(8.46305688046552e-19,2.98825901613038e-17,-6.3553269613311e-18)
(6.36744700575343e-11,-6.50988634403818e-10,-2.74620297071251e-17)
(4.34074342549198e-11,-5.8279570076334e-10,6.73131825247842e-11)
(3.72802189235175e-11,-5.66220586378605e-10,4.30885379866141e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-5.78644759525758e-12,-4.44933386199124e-12,3.16513120218728e-10)
(-1.02646521843549e-11,-7.84317118154443e-12,3.13893566040679e-10)
(-1.61535215660087e-11,-6.16187113840879e-12,3.08179853826505e-10)
(-2.71660571606796e-11,6.27996368848625e-12,2.98140017484625e-10)
(-5.22040992812326e-11,3.8741711766625e-11,2.78290928350865e-10)
(-1.03183681158674e-10,9.79110491054973e-11,2.20344066120962e-10)
(5.05097196894764e-18,4.81707015958046e-17,-6.49107389873969e-17)
(1.16031162118523e-11,-6.86511173147366e-10,4.34811910259354e-10)
(3.03240291918265e-11,-5.43599078795653e-10,2.07207935549819e-10)
(3.35489433590023e-11,-5.13523854184115e-10,9.16195628563415e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-4.91014038571853e-12,-2.10515857422601e-12,3.86641915845727e-10)
(-8.39766267905877e-12,-3.06170663597524e-12,3.86140872823291e-10)
(-1.39775387781747e-11,8.83945834915715e-13,3.8440322675337e-10)
(-2.34061815241303e-11,1.76228655867526e-11,3.83192209131754e-10)
(-4.39600473454149e-11,7.15417073811492e-11,3.91016910306612e-10)
(-9.33191758662906e-11,2.53612864262782e-10,4.41261765915771e-10)
(4.89526994150978e-11,-4.34811924973919e-10,7.01994331434243e-10)
(2.98579276892645e-11,-4.3581551335079e-10,4.33386190696613e-10)
(3.06700490188053e-11,-4.16445649679993e-10,2.53988258904878e-10)
(3.18926704121831e-11,-4.13782208301253e-10,1.20060739927104e-10)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-2.90530171803381e-12,-1.47904828596352e-12,4.49940913695552e-10)
(-4.93712316594314e-12,-1.51049072708058e-12,4.50583718100887e-10)
(-9.40649517826773e-12,4.17061607979182e-13,4.51075951261562e-10)
(-1.47427185954476e-11,5.9276178272303e-12,4.51765449899772e-10)
(-2.05866253366237e-11,1.57664696102257e-11,4.56714976196093e-10)
(-2.28038946469602e-11,8.10336715922819e-12,4.73950125430271e-10)
(1.63930803670224e-11,-1.8636901752165e-10,5.03979641550661e-10)
(2.46654168368128e-11,-2.51668604203562e-10,3.97444792223206e-10)
(2.86546698025746e-11,-2.7556700512428e-10,2.67262434874382e-10)
(3.00069859406523e-11,-2.87198566540848e-10,1.34526385406802e-10)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-1.14159574770863e-12,-1.22884341885475e-12,4.89797045199497e-10)
(-2.42324904940809e-12,-1.11818601919432e-12,4.90315535345978e-10)
(-6.39616361880673e-12,-4.29602383489497e-13,4.90960819398602e-10)
(-9.47376209299494e-12,-2.49292050133347e-13,4.91112714167406e-10)
(-9.41410122948872e-12,-2.87722682749195e-12,4.90415606986533e-10)
(-4.98007636888269e-12,-2.06134587242252e-11,4.8738769885154e-10)
(1.22894534030423e-11,-8.09857892920156e-11,4.67590813586021e-10)
(2.27055020477107e-11,-1.17773318350473e-10,3.88366387188488e-10)
(2.74979998338933e-11,-1.37269767849474e-10,2.74324376668943e-10)
(2.90056394071996e-11,-1.46775012724841e-10,1.41846052606833e-10)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-7.52772288491731e-13,-2.68244610841379e-11,3.10896627864711e-11)
(-1.79573595624528e-12,-5.48929947847775e-11,2.9401815100412e-11)
(-1.94107803285016e-12,-8.92238872020731e-11,2.60377221396451e-11)
(-1.3472864902371e-12,-1.28194268385522e-10,1.96653065335909e-11)
(3.62764704924641e-14,-1.75647252621228e-10,1.07612301377685e-11)
(2.48944665170354e-12,-2.34050313438589e-10,-2.5236624631849e-13)
(5.35040407240619e-12,-3.02102746516963e-10,-1.08949286489375e-11)
(6.25514329789166e-12,-3.69579164969323e-10,-1.28359244273785e-11)
(6.08827082704073e-12,-4.24042898294049e-10,-8.60809869680197e-12)
(6.24632254228486e-12,-4.54748296929125e-10,-3.74783541138782e-12)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-1.29804470405083e-12,-2.50438147739041e-11,6.36746922261003e-11)
(-3.06827539732081e-12,-5.16782538746911e-11,6.06505823431368e-11)
(-3.313100271382e-12,-8.31463101601928e-11,5.36672936117713e-11)
(-1.88714945198066e-12,-1.19468126283656e-10,4.12663610002439e-11)
(1.07780498575847e-12,-1.64149882946479e-10,2.28456907805512e-11)
(6.23831247566988e-12,-2.21748846408617e-10,-2.42041021755244e-12)
(1.50554552689957e-11,-2.97084994179525e-10,-3.24224440791434e-11)
(1.59113902129302e-11,-3.70970466778157e-10,-3.48339013854159e-11)
(1.42676601052107e-11,-4.27236877223173e-10,-2.13801106335779e-11)
(1.30752468226964e-11,-4.57611362459991e-10,-9.0984583452517e-12)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-2.45414081643778e-12,-2.21118819828606e-11,9.94954306773026e-11)
(-4.49949620596533e-12,-4.53784341815892e-11,9.53126516180134e-11)
(-4.63915861897112e-12,-7.13975010802487e-11,8.52714925756616e-11)
(-2.73258280920485e-12,-1.00848420541067e-10,6.8188232438312e-11)
(8.81820266896431e-13,-1.37105058729102e-10,4.17852361568054e-11)
(1.01802803757663e-11,-1.86854710287789e-10,-1.26028202327641e-12)
(4.3262956398219e-11,-2.83340168557815e-10,-8.55938157507085e-11)
(3.5535548113954e-11,-3.75807179231651e-10,-7.80490168833494e-11)
(2.51477471773275e-11,-4.34588784915423e-10,-3.7590606069939e-11)
(2.01274727645758e-11,-4.63601323665835e-10,-1.34756098882874e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-3.22208922016259e-12,-1.82048461281927e-11,1.40021862580705e-10)
(-5.8520447464587e-12,-3.66181983376444e-11,1.35022253674507e-10)
(-7.22564570549605e-12,-5.57470023118031e-11,1.23360378727546e-10)
(-6.65215616704876e-12,-7.47407577907736e-11,1.04139368685504e-10)
(-4.253106832648e-12,-9.16555715708216e-11,7.61782678168483e-11)
(2.63398048792358e-13,-9.10269211604356e-11,3.85119027466215e-11)
(-1.31621194179596e-11,-2.43275305289926e-10,9.47344516925628e-12)
(7.68407930850196e-11,-3.90754168988314e-10,-1.69379729658021e-10)
(3.71937750227166e-11,-4.47264082546087e-10,-4.76119253974891e-11)
(2.67458998051459e-11,-4.70776466285029e-10,-1.13105464858626e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-4.28710889773974e-12,-1.34693481288207e-11,1.83413982781961e-10)
(-7.28313322974262e-12,-2.68626832743035e-11,1.78328301714128e-10)
(-9.86502197478043e-12,-3.9348146944907e-11,1.66825437964789e-10)
(-1.06801355622099e-11,-4.92614355887626e-11,1.47813158278306e-10)
(-8.37598110067566e-12,-5.48117649706915e-11,1.18724463912429e-10)
(-2.96033364832811e-12,-5.19588393208082e-11,7.39160326052761e-11)
(3.13838512314426e-18,5.12114387445551e-17,-1.4226813932141e-17)
(3.26033104380893e-11,-4.40730011151583e-10,1.75261594114116e-11)
(3.24683919638023e-11,-4.62257646736834e-10,1.29736358579908e-11)
(2.94829181099807e-11,-4.71997431082967e-10,1.0783535094263e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-5.2544414128937e-12,-8.78368192087035e-12,2.32244887850145e-10)
(-8.86583727883188e-12,-1.74201929414572e-11,2.28078299078882e-10)
(-1.22679733045039e-11,-2.4114671960614e-11,2.18834673685577e-10)
(-1.50484363653299e-11,-2.61871518227901e-11,2.02282897404395e-10)
(-1.61087279094478e-11,-2.15336668887552e-11,1.73558042420522e-10)
(-1.40180376468987e-11,-9.69358815205907e-12,1.186209715657e-10)
(3.66489699933927e-18,3.43501762899583e-17,-1.88986061678561e-17)
(3.18837988142686e-11,-4.1081742663587e-10,4.47531957799687e-11)
(2.84354568254638e-11,-4.44612089967802e-10,6.33230336927733e-11)
(2.76720247156111e-11,-4.51199333202773e-10,3.73486155627682e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-5.51106870501192e-12,-5.30517410180217e-12,2.86321835315198e-10)
(-9.33240451574674e-12,-1.02832303309484e-11,2.83095262914825e-10)
(-1.31595021974335e-11,-1.19752434618421e-11,2.76284528615016e-10)
(-1.86598699252084e-11,-6.75411569536281e-12,2.64636782718804e-10)
(-2.70572326658338e-11,1.1635581671506e-11,2.43007093498294e-10)
(-3.8541365284273e-11,4.7944325167844e-11,1.8928292232244e-10)
(3.02549633261595e-18,4.2957094995334e-17,-5.95217213669499e-17)
(-1.14885688751727e-11,-4.00454885878253e-10,2.61378565396518e-10)
(1.875897276957e-11,-4.0545477369002e-10,1.51771320187699e-10)
(2.54268603324638e-11,-4.04664286543961e-10,7.17948830481292e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-5.03520765154936e-12,-2.98766609420131e-12,3.38496529004225e-10)
(-8.2112325180347e-12,-5.39407783941413e-12,3.37160930868113e-10)
(-1.22996369296024e-11,-4.43977124857619e-12,3.33709042886416e-10)
(-1.95356349394991e-11,4.07253971569814e-12,3.2844115177477e-10)
(-3.8429665183638e-11,3.40002729425652e-11,3.23855555040134e-10)
(-1.08542244281215e-10,1.32861525754162e-10,3.28012161045081e-10)
(6.91179327004794e-11,-2.64863784784969e-10,3.69449146155679e-10)
(2.51089503337508e-11,-3.07604279028252e-10,2.95124897057748e-10)
(2.37189234408307e-11,-3.209771663569e-10,1.9104052845325e-10)
(2.53697685788146e-11,-3.25939449297599e-10,9.35157353910164e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-3.79831099048153e-12,-2.18407136760026e-12,3.83335483015402e-10)
(-5.82166103449212e-12,-3.11857194980348e-12,3.82501809398708e-10)
(-9.24932982502295e-12,-2.54779589116409e-12,3.80729188000816e-10)
(-1.35153350144195e-11,-6.01603689363704e-13,3.77611553450604e-10)
(-1.91780781330637e-11,2.27476551713848e-12,3.74131293039706e-10)
(-2.4116584883901e-11,-9.2105965475072e-12,3.71934099867587e-10)
(1.75447014647955e-11,-1.37426066659029e-10,3.64840766018077e-10)
(2.0952488332544e-11,-1.92917320457509e-10,2.99385618339749e-10)
(2.3093481995346e-11,-2.16103517704062e-10,2.0607303333136e-10)
(2.41098175314777e-11,-2.25263013360387e-10,1.04459599221188e-10)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-2.8889293130445e-12,-1.51023185590403e-12,4.09423204973482e-10)
(-4.18671912122582e-12,-1.82460920243663e-12,4.08469967309398e-10)
(-6.9776607711002e-12,-1.6546686571781e-12,4.06940402197946e-10)
(-9.0259469622547e-12,-2.56791360202517e-12,4.03926492210131e-10)
(-9.2634199219885e-12,-6.06449440424238e-12,3.97822623737586e-10)
(-5.79664982758885e-12,-2.06750983754702e-11,3.87161805607112e-10)
(1.05280905085601e-11,-6.39608917300767e-11,3.61887639042976e-10)
(1.8974194216784e-11,-9.29413704808744e-11,3.00197200835391e-10)
(2.27065560465107e-11,-1.07971009976803e-10,2.11801882688033e-10)
(2.40766792891807e-11,-1.14180689748134e-10,1.09007376908533e-10)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-8.45570912615191e-13,-2.78212336613613e-11,3.16493564046235e-11)
(-1.64638390561614e-12,-5.56470672068619e-11,2.97192773322624e-11)
(-1.64623946863438e-12,-8.91000543749489e-11,2.64948948923235e-11)
(-1.16935219629865e-12,-1.26298376783266e-10,2.10340940970903e-11)
(-4.47496820177446e-13,-1.69972134857623e-10,1.40066552611064e-11)
(8.30542024351404e-13,-2.2157010206066e-10,5.40326785809722e-12)
(2.27364751338148e-12,-2.77636148138439e-10,-2.72969585876913e-12)
(3.41861937618857e-12,-3.3121796694838e-10,-5.5018882186133e-12)
(4.42198647071643e-12,-3.74159950961138e-10,-4.01209085200073e-12)
(5.36155266175468e-12,-3.98607758698523e-10,-1.68488752448132e-12)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-1.2058676121152e-12,-2.63304879487633e-11,6.36386478276999e-11)
(-2.38480635904517e-12,-5.30384432551428e-11,6.06150892053177e-11)
(-2.6609767398322e-12,-8.4103633183688e-11,5.4124967874042e-11)
(-2.08618497486852e-12,-1.19111667173449e-10,4.31409318647299e-11)
(-7.00918233502225e-13,-1.60855852722241e-10,2.81368569401992e-11)
(1.34621021641672e-12,-2.12312311600735e-10,9.14044258662591e-12)
(3.72208695357566e-12,-2.73136076578667e-10,-1.01468087675591e-11)
(7.29431191458317e-12,-3.30942878619765e-10,-1.4398255944594e-11)
(9.33791550917062e-12,-3.74822696849984e-10,-9.49591112715985e-12)
(9.96674968331764e-12,-3.98494582548266e-10,-4.1081728259773e-12)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-2.17839761180544e-12,-2.35764603583843e-11,9.75452627960642e-11)
(-3.21857300756566e-12,-4.71596538220324e-11,9.35152922180592e-11)
(-3.20639725004137e-12,-7.36833164925917e-11,8.45356500675081e-11)
(-2.43724927796573e-12,-1.03874276895486e-10,6.95427596797778e-11)
(-1.52214871133616e-12,-1.41060539528272e-10,4.80413723814406e-11)
(-1.31397502417056e-12,-1.91152925646057e-10,1.70017892057053e-11)
(-4.34670573701579e-12,-2.65511977814196e-10,-2.50656099667929e-11)
(1.0024127057191e-11,-3.31374706825983e-10,-2.70138237166282e-11)
(1.37080486263377e-11,-3.76305346792209e-10,-1.40495518817277e-11)
(1.38270054954549e-11,-3.98836874966869e-10,-4.90963960793144e-12)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-2.95797831334724e-12,-1.97341405124228e-11,1.3515815899742e-10)
(-3.94568486285169e-12,-3.89115793888917e-11,1.30214312741664e-10)
(-4.40349103033525e-12,-5.96215323084783e-11,1.19781440905729e-10)
(-4.17037750041745e-12,-8.25916079442461e-11,1.02845621693704e-10)
(-3.43054836253666e-12,-1.09677554476027e-10,7.85430896437608e-11)
(-9.76622621347055e-12,-1.47970261920578e-10,3.92981388749042e-11)
(-7.75843010920031e-11,-2.640550488865e-10,-5.4514331787448e-11)
(5.04883098777962e-12,-3.36899189393849e-10,-3.31319117631493e-11)
(1.58859603018112e-11,-3.78871472452925e-10,-9.10915333615883e-12)
(1.66563181171816e-11,-3.98284305068291e-10,-4.60493134430561e-13)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-3.88709403785123e-12,-1.51998103669111e-11,1.75942531068487e-10)
(-5.22275981326756e-12,-2.98245026854097e-11,1.70797669940011e-10)
(-6.08621727259277e-12,-4.48426265682543e-11,1.60219673089359e-10)
(-4.66572496230599e-12,-5.99399981241429e-11,1.43820146049181e-10)
(3.15435212454921e-12,-7.16908819352836e-11,1.22234399378844e-10)
(2.86904620150309e-11,-5.93416656283979e-11,9.80385514285482e-11)
(-1.75261536385782e-11,-3.46665681785376e-10,9.89748523539139e-11)
(7.24324947575384e-12,-3.55625450949044e-10,4.49501631952622e-11)
(1.70129359583866e-11,-3.78876468446208e-10,2.86823686532278e-11)
(1.94683553240753e-11,-3.91857021456816e-10,1.58842786825816e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-4.56636046074168e-12,-1.08479424126337e-11,2.19502993982727e-10)
(-6.75917449600383e-12,-2.10404959778173e-11,2.15071169342252e-10)
(-7.85562552208807e-12,-3.12774692358438e-11,2.06114070394796e-10)
(-5.75661750888109e-12,-4.04514957482668e-11,1.91790285798561e-10)
(5.65909438510624e-12,-4.54749646736111e-11,1.72722638849704e-10)
(4.69650394975292e-11,-3.70556853785042e-11,1.51343198208219e-10)
(-4.47532196205964e-11,-3.04485535903843e-10,1.42951627252469e-10)
(2.9514201438406e-12,-3.3418102499069e-10,9.86517660720388e-11)
(1.52525586777551e-11,-3.57696165853109e-10,6.8617637324624e-11)
(1.84855936195921e-11,-3.68289838158392e-10,3.56334169740388e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-4.60200431223825e-12,-7.20333776515851e-12,2.6415258286452e-10)
(-7.4108227075377e-12,-1.40356181218986e-11,2.60687195167563e-10)
(-9.04722851444999e-12,-2.03907535540992e-11,2.53693536378755e-10)
(-7.85683611576195e-12,-2.45189770278217e-11,2.42938468254377e-10)
(4.30224723897948e-12,-2.14771305002562e-11,2.30313924250367e-10)
(6.58244159735752e-11,7.31889632664767e-12,2.26996271400971e-10)
(3.48520584933204e-12,-2.99336216444493e-10,3.14327367952824e-10)
(5.26806948361371e-12,-3.03366681353492e-10,1.93124914242683e-10)
(1.42578025760231e-11,-3.18006659532176e-10,1.19206238166581e-10)
(1.84969061341935e-11,-3.2543252501888e-10,5.79134540758798e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-4.50320424202375e-12,-4.67181353651978e-12,3.05369850412224e-10)
(-7.03485042600506e-12,-9.18590154220123e-12,3.0289981063295e-10)
(-8.92372117532016e-12,-1.31610125893716e-11,2.97731606492912e-10)
(-1.0275894799833e-11,-1.58264832247353e-11,2.90159814657694e-10)
(-1.08607637631481e-11,-1.64072227662436e-11,2.81743530415116e-10)
(-7.90710709015376e-12,-2.89962413377942e-11,2.76305893673484e-10)
(1.60044636725125e-11,-1.7951062490712e-10,2.79865320769887e-10)
(1.45063603675007e-11,-2.2982670801833e-10,2.20179585163616e-10)
(1.63700678502447e-11,-2.51986261819102e-10,1.47474534453922e-10)
(1.82090680326365e-11,-2.60799893062877e-10,7.35595155785186e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-3.63847688545415e-12,-3.0878209697817e-12,3.38561031899654e-10)
(-5.34300238396778e-12,-5.67482657356497e-12,3.36211552221024e-10)
(-7.02482250879196e-12,-8.60226049208139e-12,3.32189429383948e-10)
(-8.06876469086536e-12,-1.24291537279601e-11,3.25996755173911e-10)
(-8.64162503957543e-12,-1.90011159450063e-11,3.17446897939726e-10)
(-5.55874920646049e-12,-4.1770279710747e-11,3.05443120618281e-10)
(9.53467421421756e-12,-1.10241905420101e-10,2.84647861426404e-10)
(1.42891233643048e-11,-1.51009228079536e-10,2.32543617804516e-10)
(1.65744083782504e-11,-1.72131875363445e-10,1.61964164392794e-10)
(1.74870931404199e-11,-1.80818224287379e-10,8.27339991573466e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-3.44592350486428e-12,-1.45300406463729e-12,3.56933007689819e-10)
(-4.48176321221057e-12,-2.59244912111025e-12,3.54606081787596e-10)
(-5.61841944046293e-12,-4.38423796083174e-12,3.50997720050437e-10)
(-5.48999209173475e-12,-7.60893672719246e-12,3.45128779761652e-10)
(-4.66709619575751e-12,-1.26606742296747e-11,3.34946026139734e-10)
(-1.19758163892714e-12,-2.65367007006966e-11,3.1888213927157e-10)
(8.25763698606739e-12,-5.41827576979534e-11,2.90006637384197e-10)
(1.44281418832631e-11,-7.48966612135256e-11,2.38052428410834e-10)
(1.75300518491953e-11,-8.70396498396727e-11,1.67963441868427e-10)
(1.89033664495758e-11,-9.22391208483844e-11,8.66328249548471e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-4.06237552829737e-13,-2.85213613413689e-11,3.41072907769271e-11)
(-1.0306254173912e-12,-5.65037650923677e-11,3.18765805558859e-11)
(-1.18185986467648e-12,-8.94442112146891e-11,2.851485491573e-11)
(-1.32862297012093e-12,-1.25739030797767e-10,2.33740469261136e-11)
(-9.60391552569904e-13,-1.6717039339968e-10,1.67313096739434e-11)
(-2.94284718666493e-13,-2.14331678792456e-10,9.31033045860139e-12)
(5.45768313455774e-13,-2.62938418753147e-10,2.74414642929903e-12)
(1.65373368091042e-12,-3.07760343363907e-10,-5.07155226502572e-13)
(2.75752903205967e-12,-3.42756584793507e-10,-8.51121919826894e-13)
(3.56348898704598e-12,-3.61878038789629e-10,-3.91738779482443e-13)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-9.36336580117269e-13,-2.67839945813248e-11,6.56871228223113e-11)
(-1.7734744609012e-12,-5.38433710784459e-11,6.21863583761668e-11)
(-2.09725742161178e-12,-8.49973862256987e-11,5.59140741933419e-11)
(-2.31950032827592e-12,-1.19831019296472e-10,4.62093465306841e-11)
(-1.4998170739101e-12,-1.60386274803003e-10,3.32317733234737e-11)
(-5.25924384097579e-13,-2.07826090213327e-10,1.85892340610417e-11)
(3.49435366186286e-13,-2.59129881233089e-10,5.30363362110501e-12)
(2.8237953033499e-12,-3.06394289601844e-10,-7.19238198268289e-13)
(5.43282715020982e-12,-3.41744311802815e-10,-1.33321390485046e-12)
(6.20086927597155e-12,-3.60544344851222e-10,-4.37600407603197e-13)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-1.9907468797628e-12,-2.39994390159964e-11,9.83790202469418e-11)
(-2.48700529015714e-12,-4.85551868908071e-11,9.40232937906413e-11)
(-2.27529104641058e-12,-7.63543072138051e-11,8.5659819016064e-11)
(-2.21853093088102e-12,-1.08030990066575e-10,7.27510313056061e-11)
(-1.86555058785704e-12,-1.4660331279686e-10,5.53099829755529e-11)
(-2.42923957711221e-12,-1.94598523660033e-10,3.39809091993907e-11)
(-3.85542091499114e-12,-2.52401344941158e-10,1.17192601138979e-11)
(2.5843377902226e-12,-3.03690176947417e-10,2.56603450656074e-12)
(7.13426201324862e-12,-3.39608007814644e-10,1.35152757061278e-12)
(8.36479598893812e-12,-3.57628357133989e-10,1.08036162797111e-12)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-2.54846220312077e-12,-2.05535723868634e-11,1.34312514975498e-10)
(-2.599889730395e-12,-4.13575029725378e-11,1.29142959541785e-10)
(-2.2465775585029e-12,-6.45572321236488e-11,1.19648017370666e-10)
(-2.51945527056793e-12,-9.16659089760984e-11,1.05351215112759e-10)
(-2.17227013445664e-12,-1.26174388239838e-10,8.59570592338962e-11)
(-4.58235184331891e-12,-1.73281215130882e-10,6.05796771879717e-11)
(-1.63560882174211e-11,-2.45268690200101e-10,2.8212478150769e-11)
(-2.47665884039168e-13,-3.00160052905622e-10,1.64759201016611e-11)
(7.242296093328e-12,-3.3516251904338e-10,1.17143259092575e-11)
(9.76854137130186e-12,-3.51879039115248e-10,6.42427832684431e-12)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-3.09410086365504e-12,-1.66834019258398e-11,1.72858014385458e-10)
(-3.42876967021171e-12,-3.32781510545555e-11,1.67247168054946e-10)
(-3.2518475648115e-12,-5.16201031184636e-11,1.57401849760491e-10)
(-2.56848066786093e-12,-7.35651831928515e-11,1.4346508386003e-10)
(1.13428281317601e-12,-1.01999301987474e-10,1.25574193274287e-10)
(5.46818083981204e-12,-1.43816373343634e-10,1.04769899696476e-10)
(-5.68161036149195e-12,-2.46127060954478e-10,8.50847730873497e-11)
(2.06661805946942e-12,-2.95323382841819e-10,5.81151709638557e-11)
(8.6307233360283e-12,-3.25626103048271e-10,3.76458276736887e-11)
(1.17854507082107e-11,-3.40260270703652e-10,1.89481487856654e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-3.77914046771428e-12,-1.26565599267688e-11,2.13356366220942e-10)
(-4.80695340446645e-12,-2.51653768700014e-11,2.08103452085031e-10)
(-4.41855660760301e-12,-3.94910296323612e-11,1.98940359727267e-10)
(-2.62148928045795e-12,-5.68796647628824e-11,1.86117510519133e-10)
(3.04070085324063e-12,-8.02589292185698e-11,1.70206960908015e-10)
(1.09820287481341e-11,-1.19779975639989e-10,1.52272896676997e-10)
(-5.60267789948974e-12,-2.23491778540591e-10,1.34181101470096e-10)
(2.17120525398333e-12,-2.73555415639595e-10,1.0091174904517e-10)
(8.54727270743031e-12,-3.0206442944809e-10,6.74032321215348e-11)
(1.12616974541676e-11,-3.15161191802802e-10,3.3797969013439e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-3.66814084396085e-12,-8.91698808517655e-12,2.52635334435149e-10)
(-5.26688049841224e-12,-1.80973714592511e-11,2.48218023514694e-10)
(-5.52190135481337e-12,-2.90167387783389e-11,2.40318445272269e-10)
(-3.92478591484971e-12,-4.22348473534139e-11,2.29125526762665e-10)
(2.54999235439539e-12,-6.01530980237763e-11,2.16054587908883e-10)
(1.48084570861525e-11,-9.3366559311874e-11,2.03991122257882e-10)
(4.86206802216284e-12,-1.95558106654826e-10,1.98275354471093e-10)
(5.64677222458478e-12,-2.39267149846781e-10,1.49863567251254e-10)
(9.53018895365116e-12,-2.63838553227731e-10,9.90288735912373e-11)
(1.17777282540502e-11,-2.7525266023463e-10,4.91444456317003e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-3.61715702946533e-12,-5.89926605195897e-12,2.8725475956927e-10)
(-5.37772125461796e-12,-1.25385215861682e-11,2.83443054767717e-10)
(-5.91068143737525e-12,-2.07273529196532e-11,2.76471943497283e-10)
(-5.25694005403369e-12,-3.11424711274911e-11,2.66696559739379e-10)
(-2.82923384275261e-12,-4.62103148714752e-11,2.54642670389703e-10)
(1.30750418648226e-12,-7.6549408216424e-11,2.40309777096307e-10)
(6.42147979168056e-12,-1.44963292725436e-10,2.21137923098052e-10)
(8.39393113841378e-12,-1.861161177858e-10,1.76796321369233e-10)
(1.04307002699986e-11,-2.09348410044215e-10,1.21007458502183e-10)
(1.17869148356486e-11,-2.19794780250114e-10,6.10036911334938e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-2.92381411197254e-12,-3.73905121925941e-12,3.12690850808789e-10)
(-4.40325699933302e-12,-8.02875048202906e-12,3.09478832089257e-10)
(-5.0501708300006e-12,-1.39613587946682e-11,3.03518390093844e-10)
(-4.33912445743865e-12,-2.19340175177624e-11,2.94303144948458e-10)
(-2.97828943350462e-12,-3.38909726781184e-11,2.81862242029736e-10)
(2.9309753523204e-15,-5.71112407270101e-11,2.63935196633923e-10)
(5.57977011401014e-12,-9.68281762559387e-11,2.36476014983246e-10)
(8.75600991000342e-12,-1.25789051291512e-10,1.91599162556661e-10)
(1.07123480899463e-11,-1.4412343731827e-10,1.34275123319344e-10)
(1.16419888587754e-11,-1.52810777750531e-10,6.89981516282232e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-2.57200166727969e-12,-1.91214184489693e-12,3.26288219773303e-10)
(-3.46585059616161e-12,-4.00157243618338e-12,3.22785023624636e-10)
(-4.13371711250929e-12,-7.14970780789123e-12,3.16942515599754e-10)
(-2.91617519700769e-12,-1.1872799393285e-11,3.07973122451029e-10)
(-1.26388355726738e-12,-1.81721138001366e-11,2.94650405930107e-10)
(1.14121954775145e-12,-3.04728898117318e-11,2.75247267892245e-10)
(6.02908826147214e-12,-4.89426057416422e-11,2.44596124104604e-10)
(9.62046721214827e-12,-6.35722363858594e-11,1.98494413635769e-10)
(1.18210189230925e-11,-7.34098039763595e-11,1.39929184180189e-10)
(1.32970705560238e-11,-7.83521246706457e-11,7.23972373221267e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(8.710590819357e-14,-2.90156139929258e-11,3.46905957615386e-11)
(-3.29293791169884e-13,-5.77470827775325e-11,3.26707494258277e-11)
(-4.87876864053833e-13,-9.08851740303251e-11,2.9276947191549e-11)
(-5.93897219225675e-13,-1.27169618581551e-10,2.41174979034844e-11)
(-3.23530933928216e-13,-1.66670421060934e-10,1.77388629052271e-11)
(-2.33689268480868e-13,-2.10273910471341e-10,1.15631783972729e-11)
(-1.14675508107226e-14,-2.555254662767e-10,5.90156544823078e-12)
(6.31646612175717e-13,-2.9706246022258e-10,2.19009143227519e-12)
(1.28587290100284e-12,-3.28247219069681e-10,5.99115649805346e-13)
(1.83805626915127e-12,-3.4398442415756e-10,-7.81028193103495e-14)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-2.20127699305203e-13,-2.69086617490058e-11,6.65958020992163e-11)
(-7.89374465691043e-13,-5.46825743344209e-11,6.34797173362468e-11)
(-1.03560877082378e-12,-8.621360160636e-11,5.73691721178966e-11)
(-1.14195635100389e-12,-1.21384880802491e-10,4.82441960417405e-11)
(-6.40239817610582e-13,-1.608182674869e-10,3.64001508811329e-11)
(-4.67890497460782e-13,-2.04845986790752e-10,2.43001698614672e-11)
(-3.56229106387398e-13,-2.51825459811583e-10,1.33296665637748e-11)
(7.33658355508144e-13,-2.9483983782793e-10,5.9300093982224e-12)
(2.40090966478583e-12,-3.26284127699559e-10,2.26225675938284e-12)
(2.84728115114593e-12,-3.42224470707718e-10,9.89732031332107e-13)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-1.08088705255892e-12,-2.40127046853424e-11,9.95458082731622e-11)
(-1.32121443385682e-12,-4.93614035817573e-11,9.55009778637568e-11)
(-1.16357842614432e-12,-7.81242343010196e-11,8.74386414894934e-11)
(-1.14256369129841e-12,-1.1068279199288e-10,7.54475896970134e-11)
(-9.65401368710443e-13,-1.49358526284844e-10,5.99724518134593e-11)
(-1.4848990207731e-12,-1.94343373990541e-10,4.30666729080971e-11)
(-1.83485004868796e-12,-2.44782031752419e-10,2.67674262080197e-11)
(2.68720684353516e-13,-2.90438426833575e-10,1.52437776001857e-11)
(2.95993918462307e-12,-3.22610693306718e-10,8.24293861019035e-12)
(3.69583959816653e-12,-3.38387457525243e-10,3.85237900894692e-12)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-1.24907723041643e-12,-2.10487613285078e-11,1.34948789875977e-10)
(-1.18429947727597e-12,-4.26202816413314e-11,1.29961782773334e-10)
(-8.86904305759665e-13,-6.72967609346924e-11,1.20911610538779e-10)
(-1.22602517494385e-12,-9.63502178006225e-11,1.07860310164787e-10)
(-9.69974340889664e-13,-1.33418148748198e-10,9.07050136220107e-11)
(-1.67999459333964e-12,-1.79529026311227e-10,7.07489403594765e-11)
(-3.76115941388255e-12,-2.35093233193278e-10,4.95057615912404e-11)
(-3.22741755493704e-13,-2.83168867159227e-10,3.30078396582077e-11)
(2.99592768064257e-12,-3.15260194520853e-10,2.02643221421385e-11)
(4.57405128655079e-12,-3.30839238918136e-10,9.7825461113773e-12)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-1.51009653217604e-12,-1.73108314562765e-11,1.72137253138227e-10)
(-1.69622556030161e-12,-3.47544088840484e-11,1.66280430322628e-10)
(-1.44415515050051e-12,-5.51323648664742e-11,1.56646387255767e-10)
(-1.36310851206555e-12,-8.04209464327774e-11,1.43759287193294e-10)
(1.98203622084726e-13,-1.14432049826549e-10,1.27121085486133e-10)
(1.11690974529233e-12,-1.59965842136338e-10,1.07869829491703e-10)
(-1.34729065187267e-12,-2.22356470674154e-10,8.70175663080894e-11)
(7.67994147345913e-13,-2.70748091398609e-10,6.40579837259027e-11)
(3.76672862386952e-12,-3.01782490809464e-10,4.16415457150111e-11)
(5.63452059303126e-12,-3.16482641520214e-10,2.04735181968214e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-2.26579817338917e-12,-1.2964105172859e-11,2.10076121944832e-10)
(-2.71186645745084e-12,-2.68165913775025e-11,2.04395721580407e-10)
(-2.06999825347928e-12,-4.36894199544968e-11,1.95201893754856e-10)
(-1.35575707882198e-12,-6.51458532376592e-11,1.83206749442309e-10)
(8.68933889439648e-13,-9.49825902100567e-11,1.67757684490788e-10)
(2.6604076269115e-12,-1.37996669207403e-10,1.49667477969892e-10)
(-2.66997360307599e-13,-2.00744178743846e-10,1.28252554466833e-10)
(1.39145638484682e-12,-2.47563659240388e-10,9.91116165980215e-11)
(3.92665959513835e-12,-2.76847734667388e-10,6.64693852901674e-11)
(5.15113489938491e-12,-2.9037460273036e-10,3.31832229538731e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-2.26855195670599e-12,-9.54950298182812e-12,2.46894956840104e-10)
(-2.92615212907363e-12,-2.03346300093904e-11,2.41807273280395e-10)
(-2.61836870385712e-12,-3.37642738954389e-11,2.33335834032368e-10)
(-1.9462232870264e-12,-5.10525453649715e-11,2.21861858995693e-10)
(6.70674853095862e-13,-7.6023449799681e-11,2.07282069706811e-10)
(3.70707377754316e-12,-1.13921338077467e-10,1.90510957778549e-10)
(2.67904131251716e-12,-1.71870238235315e-10,1.6936807728797e-10)
(3.33043382360945e-12,-2.13529971547709e-10,1.33376077611491e-10)
(4.92447372971017e-12,-2.39634912735945e-10,9.05896220045119e-11)
(5.46429390123272e-12,-2.52040244877101e-10,4.57255415019612e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-1.96566706057615e-12,-6.73037137881897e-12,2.78935903798578e-10)
(-2.91638108834779e-12,-1.47893428904351e-11,2.74204538563277e-10)
(-2.90129180444811e-12,-2.49086675626132e-11,2.6591180054893e-10)
(-2.41150431408387e-12,-3.84189793631076e-11,2.55002268748946e-10)
(-8.15682742725028e-13,-5.85816630183011e-11,2.4061149358254e-10)
(1.04119069531075e-12,-8.90713838094044e-11,2.22281086090092e-10)
(2.62796505102902e-12,-1.33199197246301e-10,1.96988596102705e-10)
(3.85572751114886e-12,-1.67413082117113e-10,1.57867775819925e-10)
(5.20949491274369e-12,-1.89846358503671e-10,1.08858103998255e-10)
(5.80660346954863e-12,-2.00850409473905e-10,5.53340735915997e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-1.53870476680547e-12,-3.96467320408604e-12,3.00547169891755e-10)
(-2.46999304975861e-12,-9.41298596445822e-12,2.97271765196421e-10)
(-2.64657667139262e-12,-1.69004275670631e-11,2.90260663061837e-10)
(-1.95943966320514e-12,-2.6439708510784e-11,2.79318530608701e-10)
(-7.70102915676299e-13,-4.10669382685802e-11,2.64590917351259e-10)
(8.23761710764772e-13,-6.27377031267124e-11,2.43806368447082e-10)
(2.57105202629399e-12,-9.14504119125089e-11,2.14315907758254e-10)
(3.86323424167501e-12,-1.14547682784281e-10,1.72410702732956e-10)
(5.27568643916016e-12,-1.31112833184274e-10,1.20445923187331e-10)
(6.18148740711491e-12,-1.39709732412752e-10,6.17290277928818e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(-9.809473635098e-13,-2.22797327554655e-12,3.1147806201064e-10)
(-1.62491500746419e-12,-4.87187687963266e-12,3.08269141371584e-10)
(-2.31403177167383e-12,-8.60487178531535e-12,3.01772349484487e-10)
(-1.4662580693712e-12,-1.36715349165501e-11,2.90853445927498e-10)
(-3.28593195385569e-14,-2.10524922800976e-11,2.75715652941576e-10)
(1.31947352365279e-12,-3.24234807270985e-11,2.5463030134194e-10)
(3.18819298867278e-12,-4.69741548609253e-11,2.23526294138494e-10)
(4.6134602818687e-12,-5.87196689969817e-11,1.79740332266242e-10)
(5.94316180479305e-12,-6.71202513506641e-11,1.25634123551129e-10)
(7.34218320750066e-12,-7.17992172127582e-11,6.44570340052575e-11)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
)
;
boundaryField
{
fuel
{
type fixedValue;
value uniform (0.1 0 0);
}
air
{
type fixedValue;
value uniform (-0.1 0 0);
}
outlet
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
| [
"huberlulu@gmail.com"
] | huberlulu@gmail.com | |
9ad8cbacabdc8ad23bcdf4c71e4b5433fe3a1de1 | 4da71f205f39b8c5c5db1ba9ae665efb52e5696c | /StrokeMask.cpp | a09210e7761df51e3a9b06030a5c766d17318671 | [] | no_license | daviddoria/Mask | 5319a07c980be832ba01c5df617792facf4d7871 | de3cac8623ee5ac45f1290a83b5393b666dfbc51 | refs/heads/master | 2016-08-05T09:11:31.028844 | 2015-05-18T14:41:30 | 2015-05-18T14:41:30 | 3,869,503 | 2 | 4 | null | 2014-05-04T00:25:26 | 2012-03-29T19:10:58 | C++ | UTF-8 | C++ | false | false | 3,064 | cpp | /*=========================================================================
*
* Copyright David Doria 2012 daviddoria@gmail.com
*
* 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.txt
*
* 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 "StrokeMask.h"
// Submodules
#include <Helpers/Helpers.h>
#include <ITKHelpers/ITKHelpers.h>
void StrokeMask::Read(const std::string& filename)
{
/**
* The format of the .stroke file is:
* stroke 255
* Mask.png
*/
std::string extension = Helpers::GetFileExtension(filename);
if(extension != "stroke")
{
std::stringstream ss;
ss << "StrokeMask cannot read files with extension other than .stroke! Specified file had extension ." << extension
<< " You might want ReadFromImage instead.";
throw std::runtime_error(ss.str());
}
//Create an input stream for file
std::ifstream fin(filename.c_str());
if(!fin )
{
throw std::runtime_error("File not found!");
}
std::string line;
std::stringstream linestream;
std::string strokeString;
int strokeValue;
getline(fin, line);
linestream.clear();
linestream << line;
linestream >> strokeString >> strokeValue;
if(strokeString != "stroke")
{
throw std::runtime_error("Invalid .stroke file!");
}
std::cout << "strokeValue: " << strokeValue << std::endl;
std::string imageFileName;
getline(fin, imageFileName);
if(imageFileName.length() == 0)
{
throw std::runtime_error("Image file name was empty!");
}
std::string path = Helpers::GetPath(filename);
std::string fullImageFileName = path + imageFileName;
ReadFromImage(fullImageFileName, strokeValue);
}
bool StrokeMask::IsStroke(const itk::Index<2>& index) const
{
if(this->GetPixel(index) == StrokeMaskPixelTypeEnum::STROKE)
{
return true;
}
return false;
}
unsigned int StrokeMask::CountStrokePixels() const
{
std::vector<itk::Index<2> > foregroundPixels =
ITKHelpers::GetPixelsWithValueInRegion(this, this->GetLargestPossibleRegion(),
StrokeMaskPixelTypeEnum::STROKE);
return foregroundPixels.size();
}
std::ostream& operator<<(std::ostream& output,
const StrokeMaskPixelTypeEnum &pixelType)
{
if(pixelType == StrokeMaskPixelTypeEnum::STROKE)
{
output << "StrokeMaskPixelTypeEnum::STROKE" << std::endl;
}
else if(pixelType == StrokeMaskPixelTypeEnum::NOTSTROKE)
{
output << "StrokeMaskPixelTypeEnum::NOTSTROKE" << std::endl;
}
return output;
}
| [
"daviddoria@gmail.com"
] | daviddoria@gmail.com |
a74316da3610aff79bbda4faf70f416d1b7fb11c | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_5652388522229760_1/C++/tonyk/A1.cpp | 2215bed9ef07a03f9d07b0e955cf7f500c0f96d6 | [] | no_license | alexandraback/datacollection | 0bc67a9ace00abbc843f4912562f3a064992e0e9 | 076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf | refs/heads/master | 2021-01-24T18:27:24.417992 | 2017-05-23T09:23:38 | 2017-05-23T09:23:38 | 84,313,442 | 2 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 987 | cpp | #include <iostream>
#include <string>
using namespace std;
int main(){
int i;
int t;
long long n;
cin >> t;
for (i = 0; i < t; i++){
cin >> n;
if (n == 0) {
cout << "Case #" << i+1 << ": " << "INSOMNIA" << endl;
continue;
}
int a[10] = {0};
long long nn = 0;
long long tmp;
bool stop;
while (true) {
nn += n;
tmp = nn;
while (tmp > 0) {
a[tmp % 10] = 1;
tmp /= 10;
}
stop = true;
for (int j = 0; j < 10; j++) {
if (a[j] == 0) {
stop = false;
break;
}
}
if (stop) break;
}
cout << "Case #" << i+1 << ": " << nn << endl;
}
return 0;
}
| [
"alexandra1.back@gmail.com"
] | alexandra1.back@gmail.com |
c55b102439b9631477be28d10fdf99ce0c65cb1e | a7d9a44ba58a964158780184ea9935abd3ab2ea9 | /PCLP/c/tema/laborator 2/exemplu_2_3.cpp | 34f2d2603505d2c5654923eafe581169a06c159b | [] | no_license | DonKokosh/programare | 13266370ac3102139a3d578b4a12c75156c2d8b4 | 7af3caef17cabd9e614cf0aadfce03b7eb2e6d53 | refs/heads/main | 2023-08-25T08:34:52.293945 | 2021-10-27T06:16:18 | 2021-10-27T06:16:18 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 502 | cpp | #include <stdio.h>
#include <conio.h>
int a = 5;
int f1(void)
{
printf("\na = %d" , a);
}
int f2(void)
{
int a = 7;
printf("\na = %d" , a);
}
int main()
{
int b = 10, c = 20;
printf("\na = %d, b = %d, c = %d" , a, b, c);
{
int b = 100, d = 1000;
printf("\na = %d, b = %d, c = %d, d = %d" , a, b, c, d);
}
printf("\na = %d, b = %d, c = %d" , a, b, c);
puts("\nSe executa functia f1");
f1();
puts("\nSe executa functia f2");
f2();
} | [
"ghostraider632@gmail.com"
] | ghostraider632@gmail.com |
90a645da508840925d35425a714ab521a8ca4837 | 1e9ba268815b7cd908006a45940fbe1043df5755 | /src/presentation/forms/generatepassworddialog.cpp | f098f0b1dd135d95b69ba53de16cfc5f1cf771ba | [
"Apache-2.0"
] | permissive | karagog/Gryptonite | 41501c5f36deb2b9c02bae56bc57f209cc755da7 | e2d0ec0761d81568d41ab4bc13a6bcdfce77a0a1 | refs/heads/master | 2021-06-03T02:07:27.346582 | 2019-09-15T03:10:00 | 2019-09-15T03:54:10 | 23,114,233 | 16 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 4,003 | cpp | /*Copyright 2014-2015 George Karagoulis
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 "generatepassworddialog.h"
#include "ui_generatepassworddialog.h"
#include <grypto/common.h>
#include <gutil/cryptopp_rng.h>
#include <cmath>
USING_NAMESPACE_GUTIL;
NAMESPACE_GRYPTO;
static const char *lower_case = "abcdefghijklmnopqrstuvwxyz";
static const char *upper_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static const char *numbers = "0123456789";
static const char *default_special_chars = ".,<>/\\!@#$%^&*(){}[];:'\"+-_=";
GeneratePasswordDialog::GeneratePasswordDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::GeneratePasswordDialog)
{
ui->setupUi(this);
ui->le_specialChars->setText(default_special_chars);
generate();
}
GeneratePasswordDialog::~GeneratePasswordDialog()
{
delete ui;
}
void GeneratePasswordDialog::accept()
{
password = ui->lbl_value->text();
QDialog::accept();
}
void GeneratePasswordDialog::generate()
{
GUtil::CryptoPP::RNG rng;
int n = ui->spn_numChars->value();
ui->lbl_value->clear();
// First pick numbers of the right kind:
// 2/3 alphabet chars, 1/3 nums and special chars
int n_3 = floor((float)n / 3.0);
int n_lcase = 0;
int n_ucase = 0;
int n_num = 0;
int n_spec = 0;
if((ui->chk_specialChars->isChecked() && !ui->le_specialChars->text().isEmpty()) ||
ui->chk_numbers->isChecked())
{
if((ui->chk_specialChars->isChecked() && !ui->le_specialChars->text().isEmpty()) &&
ui->chk_numbers->isChecked())
{
n_num = n_3 >> 1;
n_spec = n_3 - n_num;
}
else if(ui->chk_numbers->isChecked())
n_num = n_3;
else
n_spec = n_3;
}
else
{
n_3 = n >> 1;
}
if(ui->chk_lcase->isChecked() || ui->chk_ucase->isChecked())
{
if(ui->chk_lcase->isChecked() && ui->chk_ucase->isChecked())
n_lcase = n_ucase = n_3;
else if(ui->chk_lcase->isChecked())
n_lcase = n_3 << 1;
else
n_ucase = n_3 << 1;
}
// Distribute the remaining characters randomly
int diff = n - (n_lcase + n_ucase + n_num + n_spec);
if(diff > 0)
{
QList<int *> srcs;
if(ui->chk_lcase->isChecked())
srcs.append(&n_lcase);
if(ui->chk_ucase->isChecked())
srcs.append(&n_ucase);
if(ui->chk_specialChars->isChecked() && !ui->le_specialChars->text().isEmpty())
srcs.append(&n_spec);
if(ui->chk_numbers->isChecked())
srcs.append(&n_num);
while(diff-- > 0)
++(*srcs[rng.U_Discrete(0, srcs.length() - 1)]);
}
QString s;
for(int i = 0; i < n_lcase; ++i)
s.append(QChar::fromLatin1(lower_case[rng.U_Discrete(0, 25)]));
for(int i = 0; i < n_ucase; ++i)
s.append(QChar::fromLatin1(upper_case[rng.U_Discrete(0, 25)]));
for(int i = 0; i < n_num; ++i)
s.append(QChar::fromLatin1(numbers[rng.U_Discrete(0, 9)]));
for(int i = 0; i < n_spec; ++i)
s.append(ui->le_specialChars->text()[rng.U_Discrete(0, ui->le_specialChars->text().length() - 1)]);
if(!s.isEmpty())
{
// Shuffle the chars into the result string
QString news;
while(!s.isEmpty()){
int idx = rng.U_Discrete(0, s.length() - 1);
news.append(s[idx]);
s.remove(idx, 1);
}
ui->lbl_value->setText(news);
}
}
END_NAMESPACE_GRYPTO;
| [
"karagog@gmail.com"
] | karagog@gmail.com |
4d081fd70c374707673a31b483f465696bb5a5c1 | 2990e333261daf3d212ad6a78a02fce03f4c6347 | /LoginScene.h | 7013a9e94ea4c6d9a839f22e6fd5b90831449aac | [] | no_license | qingnia/ShenWu | 855e4301c99e87527a72fe969fff898816b3c494 | 4bc92765271a4c96038a267b477c0bea9a7dfb3c | refs/heads/master | 2021-01-10T04:52:13.441620 | 2015-12-29T14:08:45 | 2015-12-29T14:08:45 | 48,750,048 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,119 | h | #ifndef _LOGINSCENE__
#define _LOGINSCENE__
#include "cocos2d.h"
#include "cocostudio/CocoStudio.h"
#include "cocostudio/WidgetCallBackHandlerProtocol.h"
class LoginScene:
public cocos2d::Node, public cocostudio::WidgetCallBackHandlerProtocol
{
public:
CREATE_FUNC(LoginScene)
LoginScene();
~LoginScene();
void MakeUserXml();
void fetUserXmlData();
static Scene* createScene();
private:
virtual cocos2d::ui::Widget::ccWidgetTouchCallback
onLocateTouchCallback(const std::string &callBackName);
virtual cocos2d::ui::Widget::ccWidgetClickCallback
onLocateClickCallback(const std::string &callBackName);
virtual cocos2d::ui::Widget::ccWidgetEventCallback
onLocateEventCallback(const std::string &callBackName);
void onTouch(cocos2d::Ref* sender, cocos2d::ui::Widget::TouchEventType type);
void onClick(cocos2d::Ref* sender);
void onEvent(cocos2d::Ref* sender, int eventType);
std::vector<std::string> _touchTypes;
std::string _click;
std::vector<std::string> _eventTypes;
bool UserCompare(std::string user, std::string pwd);
bool UserCompareByDB(std::string uer, std::string pwd);
};
#endif | [
"1284530619@qq.com"
] | 1284530619@qq.com |
ee1a1891bdeb7e0c9775427dfbdf4b242ecdf1c4 | ef85c7bb57412c86d9ab28a95fd299e8411c316e | /inference-engine/thirdparty/clDNN/api/cldnn/primitives/loop.hpp | b888f1f9f7df57fbd7f99473d5cbbc4ec2d91129 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | SDxKeeper/dldt | 63bf19f01d8021c4d9d7b04bec334310b536a06a | a7dff0d0ec930c4c83690d41af6f6302b389f361 | refs/heads/master | 2023-01-08T19:47:29.937614 | 2021-10-22T15:56:53 | 2021-10-22T15:56:53 | 202,734,386 | 0 | 1 | Apache-2.0 | 2022-12-26T13:03:27 | 2019-08-16T13:41:06 | C++ | UTF-8 | C++ | false | false | 9,050 | hpp | // Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <vector>
#include <functional>
#include "primitive.hpp"
#include "cldnn/graph/topology.hpp"
#define DEFAULT_MAX_NUM_ITERATION 256
namespace cldnn {
/// @addtogroup cpp_api C++ API
/// @{
/// @addtogroup cpp_topology Network Topology
/// @{
/// @addtogroup cpp_primitives Primitives
/// @{
///
/// @brief Adds primitive which performs recurrent execution of the topology.
///
/// @details
/// @n The body topology for recurrent execution is described in the body
/// @n The execution of the body topology iterates through the data in the given axis.
/// @n Note: that only loops with fixed iteration count are being validated and supported currently.
/// @n
/// @n\b Example:
/// \code{.cpp}
/// topology body(
/// data("eltwise_operand", operand_mem),
/// eltwise("eltwise", "input", "eltwise_operand", eltwise_mode::sum)
/// );
///
/// std::vector<loop::io_primitive_map> input_primitive_maps { loop::io_primitive_map("input", "input") };
/// std::vector<loop::io_primitive_map> output_primitive_maps { loop::io_primitive_map("loop", "eltwise") };
///
/// std::vector<loop::backedge_mapping> back_edges {
/// loop::backedge_mapping("eltwise", "input")
/// };
///
/// topology topology(
/// input_layout("input", input_mem.get_layout()),
/// input_layout("trip_count", trip_count_mem.get_layout()),
/// input_layout("initial_condition", initial_condition_mem.get_layout()),
/// mutable_data("num_iteration", num_iteration_mem),
/// loop("loop", {"input"}, body,
/// "trip_count", "initial_condition", "num_iteration",
/// input_primitive_maps, output_primitive_maps, back_edges)
/// );
///
/// network network(engine, topology);
/// network.set_input_data("input", input_mem);
/// network.set_input_data("trip_count", trip_count_mem);
/// network.set_input_data("initial_condition", initial_condition_mem);
/// \endcode
struct loop : public primitive_base<loop> {
CLDNN_DECLARE_PRIMITIVE(loop)
struct io_primitive_map {
/// @brief Constructs a mapping from external input/output primitive to input/output primitive in body topology
///
/// @param external_id Primitive id of input of loop or output of body network.
/// @param internal_id Primitive id of input of body network.
/// @param axis Axis to iterate through. Negative value means the axis will not iterate through and start, end, stride arguments will be ignored.
/// @param start Index where the iteration starts from. Applies only when axis >=0.
/// @param end Index where iteration ends. Negative value means counting indexes from the end. Applies only when axis >=0.
/// @param stride Step of iteration. Negative value means backward iteration. Applies only when axis >=0.
io_primitive_map(primitive_id external_id, primitive_id internal_id,
int64_t axis = -1, int64_t start = 0, int64_t end = -1, int64_t stride = 1) :
external_id(external_id),
internal_id(internal_id),
axis(axis),
start(start),
end(end),
stride(stride)
{}
primitive_id external_id;
primitive_id internal_id;
int64_t axis;
int64_t start;
int64_t end;
int64_t stride;
};
struct backedge_mapping {
/// @brief Constructs a mapping from output of body topology to input of body topology for the next iteration
///
/// @param from Output data primitive id of body topology
/// @param to Input data primitive id of body topology
backedge_mapping(primitive_id from, primitive_id to)
: from(from), to(to) {}
primitive_id from;
primitive_id to;
};
/// @brief Constructs loop primitive.
///
/// @param id This primitive id.
/// @param inputs Input data primitive ids.
/// @param body Topology to be recurrently executed.
/// @param trip_count_id Data primitive id in external topology specifying maximum number of iterations.
/// Its data primitive should have 1 integer element. Negative value means infinite
/// number of iteration.
/// @param initial_condition_id Data primitive id in external topology specifying initial execution
/// condition. Its data primitive should have 1 integer element. Zero means
/// loop will not be executed, otherwise loop will be executed.
/// @param num_iteration_id mutable_data primitive id to get the actual number of loop iterations.
/// @param current_iteration_id Optional data primitive id in the body network to specify current iteration.
/// If current_iteration_id is specified but body does not have data whose primitive
/// id is same as current_iteration_id, data primitive will be added in the body network.
/// @param condition_id Optional data primitive id in the body network to specify execution condition
/// for the next iteration. Its data primitive should have 1 integer element. Zero means
/// loop will not be executed, otherwise loop will be executed. If condition_id
/// is specified but body does not have data whose primitive id is same as condition_id,
/// data primitive will be added in the body network.
/// @param primitive_map Rules to map input of loop or output of body topology to input of the body topology
/// @param back_edges Output data primitive id.
/// @param output_padding Optional padding for output from primitive.
loop(const primitive_id& id,
const std::vector<primitive_id>& inputs,
const topology& body,
const primitive_id& trip_count_id,
const primitive_id& initial_condition_id,
const primitive_id& num_iteration_id,
const std::vector<io_primitive_map>& input_primitive_maps,
const std::vector<io_primitive_map>& output_primitive_maps,
const std::vector<backedge_mapping>& back_edges,
int64_t max_iteration = -1,
const primitive_id& current_iteration_id = primitive_id(),
const primitive_id& condition_id = primitive_id(),
const primitive_id& ext_prim_id = "",
const padding& output_padding = padding())
: primitive_base(id, inputs, ext_prim_id, output_padding),
body(body),
trip_count_id(trip_count_id),
initial_execution_id(initial_condition_id),
num_iteration_id(num_iteration_id),
current_iteration_id(current_iteration_id),
condition_id(condition_id),
input_primitive_maps(input_primitive_maps),
output_primitive_maps(output_primitive_maps),
back_edges(back_edges),
max_iteration(max_iteration)
{}
/// @brief Topology to be recurrently executed.
topology body;
/// @brief Data primitive id in external topology specifying maximum number of iterations.
primitive_id trip_count_id;
/// @brief Data primitive id in external topology specifying initial execution condition.
primitive_id initial_execution_id;
/// @brief mutable_data primitive id to get the actual number of loop iterations.
primitive_id num_iteration_id;
/// @brief Data primitive id in the body network to store current iteration
primitive_id current_iteration_id;
/// @brief Data primitive id in the body network to store execution condition
primitive_id condition_id;
/// @brief Rules to map input or output data of loop layer onto input or output data of body topology.
std::vector<io_primitive_map> input_primitive_maps;
std::vector<io_primitive_map> output_primitive_maps;
/// @brief Rules to transfer data from body outputs at one iteration to body input at the next iteration.
std::vector<backedge_mapping> back_edges;
int64_t max_iteration;
protected:
std::vector<std::reference_wrapper<const primitive_id>> get_dependencies() const override {
std::vector<std::reference_wrapper<const primitive_id>> ret{
std::ref(trip_count_id), std::ref(initial_execution_id), std::ref(num_iteration_id)
};
// add external_id in dependencies if not exist
for (const auto& mapping : input_primitive_maps) {
auto target = std::find(input.begin(), input.end(), mapping.external_id);
if (target == input.end()) {
ret.push_back(std::ref(mapping.external_id));
}
}
return ret;
}
};
/// @}
/// @}
/// @}
} // namespace cldnn
| [
"noreply@github.com"
] | noreply@github.com |
4c921fd850218594ede819eae2dcb85f8389878e | c9959a974e44c4fb4758c493617884d7c071dfe1 | /InstrumentUtility/InstrumentUtility/RS_NRT.cpp | c86dfa89ace69797bf2fa1a6dad9e9cefee39e5b | [] | no_license | dowerwang/InstrumentUtilityDLL | af40bf61387a2d2cda940ee108793b6249a91507 | 452f0ed2dbb5a5c70328fb759656ed8f72f2a336 | refs/heads/master | 2023-01-06T03:05:35.013198 | 2020-11-11T08:01:59 | 2020-11-11T08:01:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 605 | cpp | #include "stdafx.h"
#include "RS_NRT.h"
RS_NRT::RS_NRT()
{
}
RS_NRT::~RS_NRT()
{
}
char * RS_NRT::GetID()
{
char* sendMsg = "*IDN ?;";
char* recvMsg = "";
try
{
bool res = WriteAndReadString(sendMsg, recvMsg);
return recvMsg;
}
catch (char *str)
{
throw(str);
}
return nullptr;
}
bool RS_NRT::Reset()
{
char* sendMsg = "IP;";
try
{
WriteString(sendMsg);
return true;
}
catch (char *str)
{
throw(str);
}
return false;
}
bool RS_NRT::PowerUnitChange(PowerUnit unit)
{
return false;
}
bool RS_NRT::GetPower(int sensorNum, double* avg, double* swr)
{
return false;
}
| [
"409192622@qq.com"
] | 409192622@qq.com |
5c23d87b961c7a40587a3862e80aa7b5f198576e | 2ba94892764a44d9c07f0f549f79f9f9dc272151 | /Engine/Source/ThirdParty/Oculus/LibOVRMobile/LibOVRMobile_050/VRLib/jni/EyeBuffers.h | 3d50ca585a3867790d167782adb2186b5fcfa8c9 | [
"LicenseRef-scancode-proprietary-license",
"LicenseRef-scancode-unknown-license-reference",
"BSD-2-Clause"
] | permissive | PopCap/GameIdea | 934769eeb91f9637f5bf205d88b13ff1fc9ae8fd | 201e1df50b2bc99afc079ce326aa0a44b178a391 | refs/heads/master | 2021-01-25T00:11:38.709772 | 2018-09-11T03:38:56 | 2018-09-11T03:38:56 | 37,818,708 | 0 | 0 | BSD-2-Clause | 2018-09-11T03:39:05 | 2015-06-21T17:36:44 | null | UTF-8 | C++ | false | false | 6,478 | h | /************************************************************************************
Filename : EyeBuffers.h
Content : Handling of different eye buffer formats
Created : March 7, 2014
Authors : John Carmack
Copyright : Copyright 2014 Oculus VR, LLC. All Rights reserved.
*************************************************************************************/
#ifndef OVR_EyeBuffers_h
#define OVR_EyeBuffers_h
#include <jni.h>
#include "Android/GlUtils.h" // GLuint
#include "Android/LogUtils.h"
namespace OVR {
enum colorFormat_t
{
COLOR_565,
COLOR_5551, // single bit alpha useful for overlay planes
COLOR_4444,
COLOR_8888,
COLOR_8888_sRGB
// We may eventually want high dynamic range and MRT formats.
// Should we include an option for getting a full mip
// chain on the frame buffer object color buffer instead of
// just a single level, allowing the application to call
// glGenerateMipmap for distortion effects or use supersampling
// for the final presentation?
// This would not be possible for ANativeWindow based surfaces.
};
enum depthFormat_t
{
DEPTH_0, // useful for overlay planes
DEPTH_16,
DEPTH_24,
DEPTH_24_STENCIL_8
// For dimshadow rendering, we would need an option to
// make the depth buffer a texture instead of a renderBufferStorage,
// which requires an extension on Gl ES 2.0, but would be fine on 3.0.
// It would also require a flag to allow the resolve of depth instead
// of invalidating it.
};
enum textureFilter_t
{
TEXTURE_FILTER_NEAREST, // Causes significant aliasing, only for performance testing.
TEXTURE_FILTER_BILINEAR, // This should be used under almost all circumstances.
TEXTURE_FILTER_ANISO_2, // Anisotropic filtering can in some cases reduce aliasing.
TEXTURE_FILTER_ANISO_4
};
struct EyeParms
{
EyeParms() :
resolution( 1024 ),
WidthScale( 1 ),
multisamples( 2 ),
colorFormat( COLOR_8888 ),
depthFormat( DEPTH_24 ),
textureFilter( TEXTURE_FILTER_BILINEAR )
{
}
// Setting the resolution higher than necessary will cause aliasing
// when presented to the screen, since we do not currently generate
// mipmaps for the eye buffers, but lowering the resolution can
// significantly improve the application frame rate.
int resolution;
// For double wide UE4
int WidthScale;
// Multisample anti-aliasing is almost always desirable for VR, even
// if it requires a drop in resolution.
int multisamples;
// 16 bit color eye buffers can improve performance noticeably, but any
// dithering effects will be distorted by the warp to screen.
//
// Defaults to FMT_8888.
colorFormat_t colorFormat;
// Adreno and Tegra benefit from 16 bit depth buffers
depthFormat_t depthFormat;
// Determines how the time warp samples the eye buffers.
// Defaults to TEXTURE_FILTER_BILINEAR.
textureFilter_t textureFilter;
};
enum multisample_t
{
MSAA_OFF,
MSAA_RENDER_TO_TEXTURE, // GL_multisampled_render_to_texture_IMG / EXT
MSAA_BLIT // GL ES 3.0 explicit resolve
};
// Things are a bit more convenient with a separate
// target for each eye, but if we want to use GPU primitive
// amplification to render both eyes at once, they will
// need to be packed into a single buffer and use independent
// viewports. This is not going to be available soon on mobile GPUs.
struct EyeBuffer
{
EyeBuffer() :
Texture( 0 ),
DepthBuffer( 0 ),
MultisampleColorBuffer( 0 ),
RenderFrameBuffer( 0 ),
ResolveFrameBuffer( 0 )
{
}
~EyeBuffer()
{
Delete();
}
// Free all resources.
// Any background time warping from the buffers must be already stopped!
void Delete();
void Allocate( const EyeParms & bufferParms,
multisample_t multisampleMode );
GLuint Texture;
// This may be a normal or multisample buffer
GLuint DepthBuffer;
// This is not used for single sample rendering or glFramebufferTexture2DMultisampleEXT
GLuint MultisampleColorBuffer;
// For non-MSAA or glFramebufferTexture2DMultisampleEXT,
// Texture will be attached to the color buffer.
GLuint RenderFrameBuffer;
// These framebuffers are the target of the resolve blit
// for MSAA without glFramebufferTexture2DMultisampleEXT.
// The only attachment will be textures[] to the color
// buffer.
GLuint ResolveFrameBuffer;
};
struct EyePairs
{
EyePairs() : MultisampleMode( MSAA_OFF ) {}
EyeParms BufferParms;
multisample_t MultisampleMode;
EyeBuffer Eyes[2];
};
enum EyeIndex
{
EYE_LEFT = 0,
EYE_RIGHT = 1
};
// This is handed off to TimeWarp
struct CompletedEyes
{
// Needed to determine sRGB conversions.
colorFormat_t ColorFormat;
// For GPU time warp
// This will be the MSAA resolved buffer if a blit was done.
GLuint Textures[2];
};
class EyeBuffers
{
public:
EyeBuffers();
// Note the pose information for this frame and
// Possibly reconfigure the buffer.
void BeginFrame( const EyeParms & bufferParms_ );
// Handles binding the FBO or making the surface current,
// and setting up the viewport.
//
// We might need a "return to eye" call if eye rendering
// ever needs to change to a different FBO and come back,
// but that is a bad idea on tiled GPUs anyway.
void BeginRenderingEye( const int eyeNum );
// Handles resolving multisample if necessary, and adding
// a fence object for tracking completion.
void EndRenderingEye( const int eyeNum );
// Thread safe call that returns the most recent completed
// eye buffer set for TimeWarp to use.
CompletedEyes GetCompletedEyes();
// Create a screenshot and a thumbnail from the undistorted left eye view
void ScreenShot();
// GPU time queries around eye scene rendering.
LogGpuTime<2> LogEyeSceneGpuTime;
// SGX wants a clear, Adreno wants a discard, not sure what Mali wants.
bool DiscardInsteadOfClear;
// Current settings
// If this just changed, not all eye buffers will
// necessarily have been reallocated yet.
EyeParms BufferParms;
// For asynchronous time warp, we need to
// triple buffer the eye pairs:
// Commands are being written for one set
// GPU is rendering a second set
// Time Warp is using a third set
//
// If we knew the driver wasn't going to do any interlocks,
// we could get by with two.
//
// We should consider sharing the depth buffers.
static const int MAX_EYE_SETS = 3;
long SwapCount; // continuously increasing
EyePairs BufferData[MAX_EYE_SETS];
};
} // namespace OVR
#endif // OVR_EyeBuffers_h
| [
"dkroell@acm.org"
] | dkroell@acm.org |
326474f27cf311d02bb9b041c588c85512b684d5 | 8c9318b0da460603ca4e782cc6d16be0d6443f29 | /Ex/CMatchImg.cpp | 5e642ece253bfe9d8207a7d91f9fc47ffdb322a8 | [] | no_license | JAEFAL0111/Ex | c0d998c2aa8e929ff8c189daffb6ecb798e7e8f8 | 05c8e90b4204c448c71327758ee4b3e2a24a1bbf | refs/heads/master | 2020-09-16T07:18:43.986017 | 2019-11-24T05:03:52 | 2019-11-24T05:03:52 | 223,695,203 | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 5,635 | cpp | #define _CRT_SECURE_NO_WARNINGS
#include "CMatchImg.h"
class Object
{
public:
Object() {};
~Object() {};
int area = 0;
int center_x = 0;
int center_y = 0;
int left = 0;
int top = 0;
int width = 0;
int height = 0;
};
int CMatchImg::getDiffImg()
{
int width = imgEmpty.cols;
int height = imgEmpty.rows;
cv::Mat diffImg = cv::Mat(height, width, CV_8UC3, cv::Scalar(0));
diffImg = imgOri - imgEmpty;
cv::GaussianBlur(diffImg, diffImg, cv::Size(gaussianMaskSize, gaussianMaskSize), 0);
cv::threshold(diffImg, diffImg, thresholdValue, 255, cv::THRESH_BINARY);
cv::Mat mask = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3), cv::Point(1, 1));
cv::erode(diffImg, diffImg, mask, cv::Point(-1, -1), erodeValue);
cv::dilate(diffImg, diffImg, mask, cv::Point(-1, -1), dilateValue);
//cv::Canny(diffImg, diffImg, 50, 150);
std::vector<std::vector<cv::Point>> contours;
cv::findContours(diffImg.clone(), contours, cv::RETR_LIST, cv::CHAIN_APPROX_SIMPLE);
cv::drawContours(diffImg, contours, -1, cv::Scalar(255, 255, 255), drawContoursLineThickness);
cv::Mat labels, stats, centroids;
int nlabels = cv::connectedComponentsWithStats(diffImg, labels, stats, centroids);
std::vector<Object> objects(nlabels);
for (int i = 0; i < nlabels; i++)
{
if (i < 1) continue;
int area = stats.at<int>(i, cv::CC_STAT_AREA);
int center_x = centroids.at<double>(i, 0);
int center_y = centroids.at<double>(i, 1);
int left = stats.at<int>(i, cv::CC_STAT_LEFT);
int top = stats.at<int>(i, cv::CC_STAT_TOP);
int width = stats.at<int>(i, cv::CC_STAT_WIDTH);
int height = stats.at<int>(i, cv::CC_STAT_HEIGHT);
if (area > NoisFilterSize)
{
//cv::rectangle(drawImg, cv::Point(left, top), cv::Point(left + width, top + height), cv::Scalar(0, 0, 255), 1);
//cv::circle(drawImg, cv::Point(center_x, center_y), 5, (255, 0, 0), 1);
//cv::putText(drawImg, std::to_string(i), cv::Point(left + 20, top + 20), cv::FONT_HERSHEY_SIMPLEX, 1, cv::Scalar(255, 0, 0), 2);
objects[i].area = area;
objects[i].center_x = center_x;
objects[i].center_y = center_y;
objects[i].left = left;
objects[i].top = top;
objects[i].width = width;
objects[i].height = height;
cv::Rect roi;
roi.x = left;
roi.y = top;
roi.width = width;
roi.height = height;
subImgs.push_back(imgOri(roi));
//std::string strPath = "C:\\";
//strPath += std::to_string(i);
//strPath += ".jpg";
//cv::imwrite(strPath, subImg);
}
}
return 1;
}
int CMatchImg::getMatchedImg()
{
int i;
Mat imgMatch;
for (i = 0; i < subImgs.size(); i++)
{
imgMatchs.push_back(imgMatch);
findMatchedImg(subImgs[i], imgOri, imgMatchs[i]);
}
return i;
}
void CMatchImg::printMatchImgs()
{
char tempbuff[WINDOW_BUFF_SIZE];
for (int i = 0; i < subImgs.size(); i++)
{
sprintf(tempbuff, "Àνİá°ú%d", i);
namedWindow(tempbuff);
imshow(tempbuff, imgMatchs[i]);
}
}
int CMatchImg::findMatchedImg(Mat& imgModel, Mat& imgScene, Mat& imgMatched)
{
if (imgModel.empty() || imgScene.empty())
{
cout << "Could not open or find the image!\n" << endl;
return -1;
}
//-- Step 1: Detect the keypoints using SURF Detector, compute the descriptors
Ptr<SURF> detector = SURF::create(minHessian);
std::vector<KeyPoint> keypoints1, keypoints2;
Mat descriptors1, descriptors2;
detector->detectAndCompute(imgModel, noArray(), keypoints1, descriptors1);
detector->detectAndCompute(imgScene, noArray(), keypoints2, descriptors2);
//-- Step 2: Matching descriptor vectors with a FLANN based matcher
// Since SURF is a floating-point descriptor NORM_L2 is used
Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create(DescriptorMatcher::FLANNBASED);
std::vector< std::vector<DMatch> > knn_matches;
matcher->knnMatch(descriptors1, descriptors2, knn_matches, 2);
//-- Filter matches using the Lowe's ratio test
std::vector<DMatch> good_matches;
for (size_t i = 0; i < knn_matches.size(); i++)
{
if (knn_matches[i][0].distance < ratio_thresh * knn_matches[i][1].distance)
{
good_matches.push_back(knn_matches[i][0]);
}
}
//-- Draw matches
drawMatches(imgModel, keypoints1, imgScene, keypoints2, good_matches, imgMatched, Scalar::all(-1),
Scalar::all(-1), std::vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS);
drawRectsMatchImg(imgModel, imgMatched, good_matches, keypoints1, keypoints2);
return 1;
}
int CMatchImg::drawRectsMatchImg(Mat& imgModel, Mat& imgMatched, std::vector<DMatch>& good_matches, std::vector<KeyPoint>& keypoints1, std::vector<KeyPoint>& keypoints2)
{
std::vector<Point2f> model_pt;
std::vector<Point2f> scene_pt;
for (int i = 0; i < good_matches.size(); i++)
{
model_pt.push_back(keypoints1[good_matches[i].queryIdx].pt);
scene_pt.push_back(keypoints2[good_matches[i].trainIdx].pt);
}
if (model_pt.size() == 0)
{
cout << "Could not find match point!\n" << endl;
return -1;
}
std::vector<Point2f> model_corner(4);
model_corner[0] = Point(0, 0);
model_corner[1] = Point(imgModel.cols, 0);
model_corner[2] = Point(imgModel.cols, imgModel.rows);
model_corner[3] = Point(0, imgModel.rows);
std::vector<Point2f> scene_corner(4);
Mat H = findHomography(model_pt, scene_pt, cv::RANSAC);
perspectiveTransform(model_corner, scene_corner, H);
Point2f p(imgModel.cols, 0);
line(imgMatched, scene_corner[0] + p, scene_corner[1] + p, Scalar(0, 0, 255), 3);
line(imgMatched, scene_corner[1] + p, scene_corner[2] + p, Scalar(0, 0, 255), 3);
line(imgMatched, scene_corner[2] + p, scene_corner[3] + p, Scalar(0, 0, 255), 3);
line(imgMatched, scene_corner[3] + p, scene_corner[0] + p, Scalar(0, 0, 255), 3);
return 1;
}
| [
"jaefal950111@gmail.com"
] | jaefal950111@gmail.com |
7a3d05171967af04ad07687143ac32b1e3067d4b | e14ee255199d6e35163b45912f20b8611f89d138 | /google-sheets-relay/google-sheets-relay.ino | 7a3c92392dbc4f26b43f850eb459367f3fe33653 | [] | no_license | sreenadhan/esp32 | c89587a73c7014655b8815a96aec9a502b209a2f | 983b5e7226706728270f3d62ae2364c81f7d4494 | refs/heads/main | 2023-08-23T00:52:07.709585 | 2021-10-06T18:59:01 | 2021-10-06T18:59:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,210 | ino | /************************************************************************************
* Created By: Tauseef Ahmad
* Created On: 9 October, 2021
*
* Tutorial Video: https://youtu.be/yem5EysVloc
* My Channel: https://www.youtube.com/channel/UCOXYfOHgu-C-UfGyDcu5sYw/
*
* *********************************************************************************
* Preferences--> Aditional boards Manager URLs :
* For ESP32:
* https://dl.espressif.com/dl/package_esp32_index.json
*
**********************************************************************************/
#include <WiFi.h>
#include <HTTPClient.h>
//---------------------------------------------------------------------
const char * ssid = "ENTER_YOUR_WIFI_SSID";
const char * password = "ENTER_YOUR_WIFI_PASSWORD";
String GOOGLE_SCRIPT_ID = "ENTER_GOOGLE_DEPLOYMENT_ID";
//---------------------------------------------------------------------
//-----------------------------
#define relay1_pin 13
#define relay2_pin 12
#define relay3_pin 14
#define relay4_pin 27
//-----------------------------
const int sendInterval = 2000;
WiFiClientSecure client;
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
void setup() {
//--------------------------------------------
pinMode(relay1_pin, OUTPUT);
pinMode(relay2_pin, OUTPUT);
pinMode(relay3_pin, OUTPUT);
pinMode(relay4_pin, OUTPUT);
//--------------------------------------------
Serial.begin(115200);
delay(10);
//--------------------------------------------
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.print("Connecting to Wi-Fi");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("OK");
//--------------------------------------------
}
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
void loop() {
read_google_sheet();
delay(sendInterval);
}
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
void read_google_sheet(void) {
//-----------------------------------------------------------------------------------
HTTPClient http;
String url="https://script.google.com/macros/s/"+GOOGLE_SCRIPT_ID+"/exec?read";
//Serial.print(url);
Serial.println("Reading Data From Google Sheet.....");
http.begin(url.c_str());
//-----------------------------------------------------------------------------------
//Remove this error "302 Moved Temporarily Error"
http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
//-----------------------------------------------------------------------------------
//Get the returning HTTP status code
int httpCode = http.GET();
Serial.print("HTTP Status Code: ");
Serial.println(httpCode);
//-----------------------------------------------------------------------------------
if(httpCode <= 0){Serial.println("Error on HTTP request"); http.end(); return;}
//-----------------------------------------------------------------------------------
//reading data comming from Google Sheet
String payload = http.getString();
Serial.println("Payload: "+payload);
//-----------------------------------------------------------------------------------
if(httpCode == 200){
//=====================================================================
//get relay number from payload variable
String temp = payload.substring(0, 1);
int relay_number = temp.toInt();
//=====================================================================
//get the command comming from Google Sheet
//i.e ON or OFF
payload.remove(0, 1);
payload.toLowerCase();
payload.trim();
Serial.println("Payload - Command: "+payload);
//=====================================================================
if(payload != "on" && payload != "off")
{Serial.println("Invalid Command"); http.end(); return;}
//=====================================================================
if(relay_number < 1 || relay_number > 4)
{Serial.println("Invalid Relay Number"); http.end(); return;}
//=====================================================================
int relay_state = control_relay(relay_number, payload);
write_google_sheet( "relay_number="+String(relay_number)+"&relay_state="+String(relay_state) );
//=====================================================================
}
//-------------------------------------------------------------------------------------
http.end();
}
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
void write_google_sheet(String params) {
HTTPClient http;
String url="https://script.google.com/macros/s/"+GOOGLE_SCRIPT_ID+"/exec?"+params;
//Serial.print(url);
Serial.println("Updating Status of Relay");
http.begin(url.c_str());
http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
int httpCode = http.GET();
Serial.print("HTTP Status Code: ");
Serial.println(httpCode);
String payload;
if (httpCode > 0) {
payload = http.getString();
Serial.println("Payload: "+payload);
}
http.end();
}
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
int control_relay(int relay, String command){
switch (relay) {
//------------------------------------------------
case 1:
if(command == "on"){
digitalWrite(relay1_pin, HIGH);
Serial.println("Relay 1 is ON");
return 1;
} else {
digitalWrite(relay1_pin, LOW);
Serial.println("Relay 1 is OFF");
return 0;
}
break;
//------------------------------------------------
case 2:
if(command == "on"){
digitalWrite(relay2_pin, HIGH);
return 1;
} else {
digitalWrite(relay2_pin, LOW);
return 0;
}
break;
//------------------------------------------------
case 3:
if(command == "on"){
digitalWrite(relay3_pin, HIGH);
return 1;
} else {
digitalWrite(relay3_pin, LOW);
return 0;
}
break;
//------------------------------------------------
case 4:
if(command == "on"){
digitalWrite(relay4_pin, HIGH);
return 1;
} else {
digitalWrite(relay4_pin, LOW);
return 0;
}
break;
//------------------------------------------------
default:
return -1;
break;
}
}
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
| [
"noreply@github.com"
] | noreply@github.com |
477a2fd8eb81bf2ef4d3d7b169474f04290d8edc | e539d650bb16c248a342e2a8adf91dae8515173e | /Controller/ClientChartDlg.cpp | 155a8d781695276393f20fd764de35ba74596c0b | [] | no_license | progmalover/vc-mgcview | 8a2671ebd8c35ed8ba4c6d0a6a2c6abb66ff3fbb | cf04e9b1b83cb36ed4a6386ae1b10097e29eae99 | refs/heads/master | 2021-04-29T04:27:26.134036 | 2017-01-04T08:38:42 | 2017-01-04T08:38:42 | 77,996,977 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 67,782 | cpp | // UserMonitorChartDlg.cpp :
//
#include "stdafx.h"
#include "Controller.h"
#include "ClientChartDlg.h"
#include "afxdialogex.h"
#include "Graph.h"
#include "GraphSeries.h"
#include "GraphLegend.h"
#include "DatetimeCheck.h"
#define INVALID_DATA_VAL -1
#ifndef _OLD_CLIENT_CHART_VER_
// CUserMonitorChartDlg
IMPLEMENT_DYNAMIC(CClientChartDlg, CDialogEx)
#define Translate(x) x
CString mDataTypeTitleName[DATATYPE_MAX_NUM] =
{
Translate(_T("CpuUsage")),
Translate(_T("MemUsage")),
Translate(_T("Free Disk")),
Translate(_T("fps")),
Translate(_T("Fan Speed")),
Translate(_T("CPU Temperature")),
Translate(_T("MotherBoard Temperature")),
Translate(_T("HDD Temperature")),
Translate(_T("GPU Temperature")),
};
#undef Translate
CClientChartDlg::CClientChartDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(CClientChartDlg::IDD, pParent)
{
m_nInitFlag = FALSE;
m_nScale = 1;
m_nRecordNum = 0;
m_Span.SetDateTimeSpan(7,0,0,0);
m_dcWidth = 2000;
//m_dcHeight = 350 * DATATYPE_MAX_NUM;
m_dcHeight = 700;
for(int ii = 0;ii< DATATYPE_MAX_NUM ; ii++)
{
MyGraph[ii] = NULL;
}
}
CClientChartDlg::~CClientChartDlg()
{
dcMem.DeleteDC(); //delete DC
bmp.DeleteObject(); //delete bitmap
}
void CClientChartDlg::SetClientId(int id)
{
m_ClientId = id;
}
int CClientChartDlg::GetClientId()
{
return m_ClientId;
}
void CClientChartDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
/*DDX_Control(pDX, IDC_DATETIMEPICKER1, m_datatimectrl);*/
DDX_Control(pDX, IDC_COMBO_TYPE, m_ComboType);
/*DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER4, m_starttime);*/
/*DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER5, m_endtime);*/
}
BEGIN_MESSAGE_MAP(CClientChartDlg, CDialogEx)
ON_WM_CLOSE()
ON_WM_PAINT()
ON_WM_SIZE()
ON_WM_HSCROLL()
ON_WM_VSCROLL()
ON_WM_MOUSEWHEEL()
ON_BN_CLICKED(IDC_BUTTON1, &CClientChartDlg::OnBnClickedButton1)
ON_BN_CLICKED(IDC_BUTTON3, &CClientChartDlg::OnBnClickedButton3)
/*ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATETIMEPICKER1, &CClientChartDlg::OnDtnDatetimechangeDatetimepicker1)*/
ON_MESSAGE(USER_MSG_GET_CLIENT_HISTORY, &CClientChartDlg::UpdateClientHistoryData)
ON_CBN_SELCHANGE(IDC_COMBO_TYPE, &CClientChartDlg::OnCbnSelchangeComboType)
ON_BN_CLICKED(IDC_RADIO_ONE_WEEK, &CClientChartDlg::OnBnClickedRadioOneWeek)
ON_BN_CLICKED(IDC_RADIO_ONE_MONTH, &CClientChartDlg::OnBnClickedRadioOneMonth)
ON_BN_CLICKED(IDC_RADIO_THREE_MONTH, &CClientChartDlg::OnBnClickedRadioThreeMonth)
ON_BN_CLICKED(IDC_RADIO_USER_DEFINE, &CClientChartDlg::OnBnClickedRadioUserDefine)
ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATETIMEPICKER4, &CClientChartDlg::OnDtnDatetimechangeDatetimepicker4)
ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATETIMEPICKER5, &CClientChartDlg::OnDtnDatetimechangeDatetimepicker5)
ON_BN_CLICKED(IDC_BTN_SEARCH, &CClientChartDlg::OnBnClickedBtnSearch)
END_MESSAGE_MAP()
BEGIN_EASYSIZE_MAP(CClientChartDlg)
//EASYSIZE(IDC_STATIC_BACKGROUND,ES_BORDER,ES_BORDER,ES_BORDER,ES_KEEPSIZE,0)
//EASYSIZE(IDC_STATIC_FOREGROUND,ES_BORDER,ES_BORDER,ES_BORDER,ES_BORDER,0)
EASYSIZE(IDC_STATIC_BACKGROUND,ES_BORDER,ES_BORDER,ES_BORDER,ES_BORDER,0)
END_EASYSIZE_MAP
// CUserMonitorChartDlg
void CClientChartDlg::OnCancel()
{
}
void CClientChartDlg::OnOK()
{
}
void CClientChartDlg::OnClose()
{
/*
CClientStateTab* parent = (CClientStateTab*)GetParent();
parent->RemoveTab(parent->GetActiveTab());
*/
CDialogEx::OnClose();
}
int CClientChartDlg::GetTypeData(PerfStatus it,int dataTypeID)
{
int rtn = INVALID_DATA_VAL;
int data;
if(dataTypeID == (int)DATATYPE_CPU_USAGE)
{
//rtn = it.GetCpuUsage()%100;
data = it.GetCpuUsage();
if(data < 0 || data > 100)
{
}
else
{
rtn = data;
}
}
else if(dataTypeID == (int)DATATYPE_MEM_USAGE)
{
//rtn = it.GetMemUsage()%100;
data = it.GetMemUsage();
if(data < 0 || data > 100)
{
}
else
{
rtn = data;
}
}
else if(dataTypeID == (int)DATATYPE_DISK_USAGE)
{
//rtn = it.GetHarddiskUsage()%100;
data = it.GetHarddiskUsage();
if(data < 0 || data > 100)
{
}
else
{
rtn = data;
}
}
else if(dataTypeID == (int)DATATYPE_FPS)
{
//rtn = it.GetFPS()%60;
data = it.GetFPS();
if(data < 0 || data > 60)
{
}
else
{
rtn = data;
}
}
else if(dataTypeID == (int)DATATYPE_FAN_SPEED)
{
data = it.GetFanSpeed();
if(data < 0 || data > 10000)
{
}
else
{
rtn = data;
}
//rtn = it.GetFanSpeed()%10000;
}
else if(dataTypeID == (int)DATATYPE_CPU_TEMP)
{
//rtn = it.GetCPUTemperature()%100;
data = it.GetCPUTemperature();
if(data < 0 || data > 100)
{
}
else
{
rtn = data;
}
}
else if(dataTypeID == (int)DATATYPE_MOTHERBOARD_TEMP)
{
//rtn = it.GetMBTemperature()%100;
data = it.GetMBTemperature();
if(data < 0 || data > 100)
{
}
else
{
rtn = data;
}
}
else if(dataTypeID == (int)DATATYPE_HDD_TEMP)
{
//rtn = it.GetHDDTemperature()%100;
data = it.GetHDDTemperature();
if(data < 0 || data > 100)
{
}
else
{
rtn = data;
}
}
else //if(typeid == (int)DATATYPE_GPU_TEMP)
{
//rtn = it.GetGPUTemperature()%100;
data = it.GetGPUTemperature();
if(data < 0 || data > 100)
{
}
else
{
rtn = data;
}
}
return rtn;
}
LRESULT CClientChartDlg::UpdateClientHistoryData(WPARAM wp,LPARAM lp)
{
//////////////////////////////////////////////////////////////////////////
// How to get a buf
UINT nMessageBufID = (UINT)wp;
//retrieve data finish
bIsRetrievingData = false;
((CButton *)GetDlgItem(IDC_COMBO_TYPE))->EnableWindow(true);
((CButton *)GetDlgItem(IDC_RADIO_ONE_WEEK))->EnableWindow(true);
((CButton *)GetDlgItem(IDC_RADIO_ONE_MONTH))->EnableWindow(true);
((CButton *)GetDlgItem(IDC_RADIO_THREE_MONTH))->EnableWindow(true);
((CButton *)GetDlgItem(IDC_RADIO_USER_DEFINE))->EnableWindow(true);
if(m_nLastRadioBoxIdx == 3)
{
((CButton *)GetDlgItem(IDC_DATETIMEPICKER4))->EnableWindow(true);
((CButton *)GetDlgItem(IDC_DATETIMEPICKER5))->EnableWindow(true);
((CButton *)GetDlgItem(IDC_BTN_SEARCH))->EnableWindow(true);
}
else
{
((CButton *)GetDlgItem(IDC_DATETIMEPICKER4))->EnableWindow(false);
((CButton *)GetDlgItem(IDC_DATETIMEPICKER5))->EnableWindow(false);
((CButton *)GetDlgItem(IDC_BTN_SEARCH))->EnableWindow(false);
}
DataBuf< ClientStatus> MessageBuf;
if (!WorkThreadDataManager< ClientStatus >
::GetDataBuf(nMessageBufID, MessageBuf))
{
return 1;
}
ClientStatus *pClientStatus = (ClientStatus *)MessageBuf.Get();
pClientStatus->GetPerfHistory(m_ClientRTStatisticsList);
//set current data start time
m_CurDataStartTime = m_LastRetrieveStartTime ;
m_nRecordNum = m_ClientRTStatisticsList.size();
//release graphic data object
ReleaseGraphicsData();
//create graphic data object to show chart
int ii = 0;
MyGraph[ii] = new CGraph();
MyGraph[ii]->SetGraphTitle(Translate(mDataTypeTitleName[ii]));
MyGraph[ii]->SetGraphType(1);
MyGraph[ii]->SetScale(m_nScale);
MyGraph[ii]->SetTickSpace(20);
MyGraph[ii]->SetTickRange(100);
MyGraph[ii]->SetCurColorIndex(0);
MyGraph[ii]->SetXAxisAlignment(300);
MyGraph[ii]->SetXAxisLabel(_T("T"));
MyGraph[ii]->SetYAxisLabel(_T("%"));
ii++;
MyGraph[ii] = new CGraph();
MyGraph[ii]->SetGraphTitle(Translate(mDataTypeTitleName[ii]));
MyGraph[ii]->SetGraphType(1);
MyGraph[ii]->SetScale(m_nScale);
MyGraph[ii]->SetTickSpace(20);
MyGraph[ii]->SetTickRange(100);
MyGraph[ii]->SetCurColorIndex(1);
MyGraph[ii]->SetXAxisAlignment(300);
MyGraph[ii]->SetXAxisLabel(_T("T"));
MyGraph[ii]->SetYAxisLabel(_T("%"));
ii++;
MyGraph[ii] = new CGraph();
MyGraph[ii]->SetGraphTitle(Translate(mDataTypeTitleName[ii]));
MyGraph[ii]->SetGraphType(1);
MyGraph[ii]->SetScale(m_nScale);
MyGraph[ii]->SetTickSpace(20);
MyGraph[ii]->SetTickRange(100);
MyGraph[ii]->SetCurColorIndex(2);
MyGraph[ii]->SetXAxisAlignment(300);
MyGraph[ii]->SetXAxisLabel(_T("T"));
MyGraph[ii]->SetYAxisLabel(_T("%"));
ii++;
MyGraph[ii] = new CGraph();
MyGraph[ii]->SetGraphTitle(Translate(mDataTypeTitleName[ii]));
MyGraph[ii]->SetGraphType(1);
MyGraph[ii]->SetScale(m_nScale);
MyGraph[ii]->SetTickSpace(10);
MyGraph[ii]->SetTickRange(60);
MyGraph[ii]->SetCurColorIndex(3);
MyGraph[ii]->SetXAxisAlignment(300);
MyGraph[ii]->SetXAxisLabel(_T("T"));
MyGraph[ii]->SetYAxisLabel(_T("fps"));
ii++;
MyGraph[ii] = new CGraph();
MyGraph[ii]->SetGraphTitle(Translate(mDataTypeTitleName[ii]));
MyGraph[ii]->SetGraphType(1);
MyGraph[ii]->SetScale(m_nScale);
MyGraph[ii]->SetTickSpace(1000);
MyGraph[ii]->SetTickRange(10000);
MyGraph[ii]->SetCurColorIndex(4);
MyGraph[ii]->SetXAxisAlignment(300);
MyGraph[ii]->SetXAxisLabel(_T("T"));
MyGraph[ii]->SetYAxisLabel(_T("RPM"));
for (int i = 0; i < 4; ++i)
{
ii++;
MyGraph[ii] = new CGraph();
MyGraph[ii]->SetGraphTitle(Translate(mDataTypeTitleName[ii]));
MyGraph[ii]->SetGraphType(1);
MyGraph[ii]->SetScale(m_nScale);
MyGraph[ii]->SetTickSpace(10);
MyGraph[ii]->SetTickRange(100);
MyGraph[ii]->SetCurColorIndex(5 + i);
MyGraph[ii]->SetXAxisAlignment(300);
MyGraph[ii]->SetXAxisLabel(_T("T"));
// MyGraph[ii]->SetYAxisLabel(_T("¡æ"));
MyGraph[ii]->SetYAxisLabel(_T("\x2103"));
}
int mm;
if(m_nRecordNum > 0x00)
{
//int j = 0;
S3Time rdtime(0,0,0,0,0,0);
const COleDateTime oletime;
CString tickLabel;
//SYSTEM_STATUS_DESC stSystemStatusDesc;
CGraphSeries* tmpSeries;
std::vector<PerfStatus>::iterator it;
int nAverageArray[DATATYPE_MAX_NUM];
//memset(nAverageArray,0,sizeof(nAverageArray));
// calculate the average
for( mm = 0; mm< DATATYPE_MAX_NUM ; mm++)
{
nAverageArray[mm] = INVALID_DATA_VAL;
}
for(it = m_ClientRTStatisticsList.begin(); it < m_ClientRTStatisticsList.end(); ++it)
{
for( mm = 0; mm< DATATYPE_MAX_NUM ; mm++)
{
int data = GetTypeData(*it,mm);
if(data != INVALID_DATA_VAL)
{
if(nAverageArray[mm] == INVALID_DATA_VAL)
{
nAverageArray[mm] = data;
}
else
{
nAverageArray[mm] += data;
nAverageArray[mm] /= 2;
}
}
}
}
COleDateTime comparetime = m_LastRetrieveStartTime;
COleDateTimeSpan onedayspan;
onedayspan.SetDateTimeSpan(1,0,0,0);
#define DATA_MAX_NUM 10
int nDataNum[DATATYPE_MAX_NUM];
int nData[DATATYPE_MAX_NUM][DATA_MAX_NUM];
int nDataIndex[DATATYPE_MAX_NUM] ;
int nDataArray[DATATYPE_MAX_NUM][DATA_MAX_NUM];
memset(nDataNum,0,sizeof(nDataNum));
memset(nDataIndex,0,sizeof(nDataIndex));
for( mm = 0; mm< DATATYPE_MAX_NUM ; mm++)
{
for(int mmm = 0; mmm < DATA_MAX_NUM ; mmm++)
nDataArray[mm][mmm] = INVALID_DATA_VAL;//nAverageArray[mm];
}
for(it = m_ClientRTStatisticsList.begin(); it < m_ClientRTStatisticsList.end(); ++it)
{
rdtime = it->GetSubmitTime();
const COleDateTime oletime = rdtime.ToCOleDateTime();
//tickLabel.Format(_T("%02d-%02d %02d:%02d"), oletime.GetMonth(),oletime.GetDay(),oletime.GetHour(),oletime.GetMinute());
if(oletime < comparetime )
{
continue;
}
while(oletime >= comparetime + onedayspan /*|| nDataIndex >= 10-1*/)
{
tickLabel.Format(_T("%02d-%02d"), comparetime.GetMonth(),comparetime.GetDay());
for(int nType = 0; nType < DATATYPE_MAX_NUM ; nType++)
{
tmpSeries = new CGraphSeries();
tmpSeries->SetLabel(tickLabel);
if(nDataNum[nType] == 0)
{
for(int jj = 0; jj < DATA_MAX_NUM ; jj++)
{
tmpSeries->SetData(jj, INVALID_DATA_VAL);
}
}
else if (nDataNum[nType] > 0 && nDataNum[nType] < DATA_MAX_NUM)
{
for(int jj = 0; jj < nDataNum[nType] ; jj++)
{
tmpSeries->SetData(jj, nData[nType][jj]);
}
}
else
{
int jj;
for(jj = 0; jj< DATA_MAX_NUM - nDataIndex[nType];jj++)
{
tmpSeries->SetData(jj, nData[nType][jj]);
}
for(int kk = 0; kk < nDataIndex[nType] ; kk++)
{
tmpSeries->SetData(jj, nDataArray[nType][kk]);
jj++;
}
}
MyGraph[nType]->AddSeries(tmpSeries);
}
//nDataIndex = 0;
memset(nDataNum,0,sizeof(nDataNum));
memset(nDataIndex,0,sizeof(nDataIndex));
//memset(nDataArray,-1,sizeof(nDataArray));
for(int kk = 0; kk< DATATYPE_MAX_NUM ; kk++)
{
for(int kkk = 0; kkk < DATA_MAX_NUM ; kkk++)
nDataArray[kk][kkk] = INVALID_DATA_VAL;//nAverageArray[kk];
}
comparetime += onedayspan;
if(comparetime >= m_LastRetrieveEndTime)
{
break;
}
}
int LastVal;
for(int nn = 0; nn < DATATYPE_MAX_NUM ; nn++)
{
int nCurVal = GetTypeData(*it,nn);
if(nCurVal != INVALID_DATA_VAL && nDataNum[nn] < DATA_MAX_NUM )
{
nData[nn][nDataNum[nn]] = nCurVal;
nDataNum[nn] ++ ;//suppose never exceed
}
if(nCurVal != INVALID_DATA_VAL && nDataNum[nn] >= DATA_MAX_NUM )
{
if(nDataIndex[nn] < DATA_MAX_NUM)
{
if(nDataIndex[nn] == 0)
{
LastVal = nAverageArray[nn];
}
else
{
LastVal = nDataArray[nn][nDataIndex[nn]-1];
}
//int nCurVal = GetTypeData(*it,nn);
//if( abs(nCurVal - LastVal) * 20 > LastVal )
if( abs(nCurVal - LastVal) * 20 > nAverageArray[nn] )
{
nDataArray[nn][nDataIndex[nn]] = nCurVal;
nDataIndex[nn]++;
}
}
}
}
}
while(comparetime < m_LastRetrieveEndTime)
{
tickLabel.Format(_T("%02d-%02d"), comparetime.GetMonth(),comparetime.GetDay());
for(int nType = 0; nType < DATATYPE_MAX_NUM ; nType++)
{
tmpSeries = new CGraphSeries();
tmpSeries->SetLabel(tickLabel);
if(nDataNum[nType] == 0)
{
for(int jj = 0; jj < DATA_MAX_NUM ; jj++)
{
tmpSeries->SetData(jj, INVALID_DATA_VAL);
}
}
else if (nDataNum[nType] > 0 && nDataNum[nType] < DATA_MAX_NUM)
{
int jj;
for(jj = 0; jj < nDataNum[nType] ; jj++)
{
tmpSeries->SetData(jj, nData[nType][jj]);
}
for(jj = nDataNum[nType]; jj< DATA_MAX_NUM ;jj++)
{
tmpSeries->SetData(jj, INVALID_DATA_VAL);
}
}
else
{
int jj;
for(jj = 0; jj< DATA_MAX_NUM - nDataIndex[nType];jj++)
{
tmpSeries->SetData(jj, nData[nType][jj]);
}
for(int kk = 0; kk < nDataIndex[nType] ; kk++)
{
tmpSeries->SetData(jj, nDataArray[nType][kk]);
jj++;
}
}
MyGraph[nType]->AddSeries(tmpSeries);
}
memset(nDataNum,0,sizeof(nDataNum));
memset(nDataIndex,0,sizeof(nDataIndex));
//memset(nDataArray,-1,sizeof(nDataArray));
comparetime += onedayspan;
}
}
DrawGraphicBackBuffer();
UpdateGraphicsDisplay();
return 0x01;
}
void CClientChartDlg::RetrieveBufferedData(const COleDateTime & starttime, const COleDateTime & endtime )
{
m_nRecordNum = m_ClientRTStatisticsList.size();
//release graphic data object
ReleaseGraphicsData();
//create graphic data object to show chart
int ii = 0;
MyGraph[ii] = new CGraph();
MyGraph[ii]->SetGraphTitle(Translate(mDataTypeTitleName[ii]));
MyGraph[ii]->SetGraphType(1);
MyGraph[ii]->SetScale(m_nScale);
MyGraph[ii]->SetTickSpace(20);
MyGraph[ii]->SetTickRange(100);
MyGraph[ii]->SetCurColorIndex(0);
MyGraph[ii]->SetXAxisAlignment(300);
MyGraph[ii]->SetXAxisLabel(_T("T"));
MyGraph[ii]->SetYAxisLabel(_T("%"));
ii++;
MyGraph[ii] = new CGraph();
MyGraph[ii]->SetGraphTitle(Translate(mDataTypeTitleName[ii]));
MyGraph[ii]->SetGraphType(1);
MyGraph[ii]->SetScale(m_nScale);
MyGraph[ii]->SetTickSpace(20);
MyGraph[ii]->SetTickRange(100);
MyGraph[ii]->SetCurColorIndex(1);
MyGraph[ii]->SetXAxisAlignment(300);
MyGraph[ii]->SetXAxisLabel(_T("T"));
MyGraph[ii]->SetYAxisLabel(_T("%"));
ii++;
MyGraph[ii] = new CGraph();
MyGraph[ii]->SetGraphTitle(Translate(mDataTypeTitleName[ii]));
MyGraph[ii]->SetGraphType(1);
MyGraph[ii]->SetScale(m_nScale);
MyGraph[ii]->SetTickSpace(20);
MyGraph[ii]->SetTickRange(100);
MyGraph[ii]->SetCurColorIndex(2);
MyGraph[ii]->SetXAxisAlignment(300);
MyGraph[ii]->SetXAxisLabel(_T("T"));
MyGraph[ii]->SetYAxisLabel(_T("%"));
ii++;
MyGraph[ii] = new CGraph();
MyGraph[ii]->SetGraphTitle(Translate(mDataTypeTitleName[ii]));
MyGraph[ii]->SetGraphType(1);
MyGraph[ii]->SetScale(m_nScale);
MyGraph[ii]->SetTickSpace(10);
MyGraph[ii]->SetTickRange(60);
MyGraph[ii]->SetCurColorIndex(3);
MyGraph[ii]->SetXAxisAlignment(300);
MyGraph[ii]->SetXAxisLabel(_T("T"));
MyGraph[ii]->SetYAxisLabel(_T("fps"));
ii++;
MyGraph[ii] = new CGraph();
MyGraph[ii]->SetGraphTitle(Translate(mDataTypeTitleName[ii]));
MyGraph[ii]->SetGraphType(1);
MyGraph[ii]->SetScale(m_nScale);
MyGraph[ii]->SetTickSpace(1000);
MyGraph[ii]->SetTickRange(10000);
MyGraph[ii]->SetCurColorIndex(4);
MyGraph[ii]->SetXAxisAlignment(300);
MyGraph[ii]->SetXAxisLabel(_T("T"));
MyGraph[ii]->SetYAxisLabel(_T("RPM"));
for (int i = 0; i < 4; ++i)
{
ii++;
MyGraph[ii] = new CGraph();
MyGraph[ii]->SetGraphTitle(Translate(mDataTypeTitleName[ii]));
MyGraph[ii]->SetGraphType(1);
MyGraph[ii]->SetScale(m_nScale);
MyGraph[ii]->SetTickSpace(10);
MyGraph[ii]->SetTickRange(100);
MyGraph[ii]->SetCurColorIndex(5 + i);
MyGraph[ii]->SetXAxisAlignment(300);
MyGraph[ii]->SetXAxisLabel(_T("T"));
// MyGraph[ii]->SetYAxisLabel(_T("¡æ"));
MyGraph[ii]->SetYAxisLabel(_T("\x2103"));
}
int mm;
if(m_nRecordNum > 0x00)
{
//int j = 0;
S3Time rdtime(0,0,0,0,0,0);
const COleDateTime oletime;
CString tickLabel;
//SYSTEM_STATUS_DESC stSystemStatusDesc;
CGraphSeries* tmpSeries;
std::vector<PerfStatus>::iterator it;
int nAverageArray[DATATYPE_MAX_NUM];
//memset(nAverageArray,0,sizeof(nAverageArray));
// calculate the average
for( mm = 0; mm< DATATYPE_MAX_NUM ; mm++)
{
nAverageArray[mm] = INVALID_DATA_VAL;
}
for(it = m_ClientRTStatisticsList.begin(); it < m_ClientRTStatisticsList.end(); ++it)
{
for( mm = 0; mm< DATATYPE_MAX_NUM ; mm++)
{
int data = GetTypeData(*it,mm);
if(data != INVALID_DATA_VAL)
{
if(nAverageArray[mm] == INVALID_DATA_VAL)
{
nAverageArray[mm] = data;
}
else
{
nAverageArray[mm] += data;
nAverageArray[mm] /= 2;
}
}
}
}
COleDateTime comparetime = starttime;
COleDateTimeSpan onedayspan;
onedayspan.SetDateTimeSpan(1,0,0,0);
#define DATA_MAX_NUM 10
int nDataNum[DATATYPE_MAX_NUM];
int nData[DATATYPE_MAX_NUM][DATA_MAX_NUM];
int nDataIndex[DATATYPE_MAX_NUM] ;
int nDataArray[DATATYPE_MAX_NUM][DATA_MAX_NUM];
memset(nDataNum,0,sizeof(nDataNum));
memset(nDataIndex,0,sizeof(nDataIndex));
for( mm = 0; mm< DATATYPE_MAX_NUM ; mm++)
{
for(int mmm = 0; mmm < DATA_MAX_NUM ; mmm++)
nDataArray[mm][mmm] = INVALID_DATA_VAL;//nAverageArray[mm];
}
for(it = m_ClientRTStatisticsList.begin(); it < m_ClientRTStatisticsList.end(); ++it)
{
rdtime = it->GetSubmitTime();
const COleDateTime oletime = rdtime.ToCOleDateTime();
if(oletime < comparetime )
{
continue;
}
//tickLabel.Format(_T("%02d-%02d %02d:%02d"), oletime.GetMonth(),oletime.GetDay(),oletime.GetHour(),oletime.GetMinute());
while(oletime >= comparetime + onedayspan /*|| nDataIndex >= 10-1*/)
{
tickLabel.Format(_T("%02d-%02d"), comparetime.GetMonth(),comparetime.GetDay());
for(int nType = 0; nType < DATATYPE_MAX_NUM ; nType++)
{
tmpSeries = new CGraphSeries();
tmpSeries->SetLabel(tickLabel);
if(nDataNum[nType] == 0)
{
for(int jj = 0; jj < DATA_MAX_NUM ; jj++)
{
tmpSeries->SetData(jj, INVALID_DATA_VAL);
}
}
else if (nDataNum[nType] > 0 && nDataNum[nType] < DATA_MAX_NUM)
{
for(int jj = 0; jj < nDataNum[nType] ; jj++)
{
tmpSeries->SetData(jj, nData[nType][jj]);
}
}
else
{
int jj;
for(jj = 0; jj< DATA_MAX_NUM - nDataIndex[nType];jj++)
{
tmpSeries->SetData(jj, nData[nType][jj]);
}
for(int kk = 0; kk < nDataIndex[nType] ; kk++)
{
tmpSeries->SetData(jj, nDataArray[nType][kk]);
jj++;
}
}
MyGraph[nType]->AddSeries(tmpSeries);
}
//nDataIndex = 0;
memset(nDataNum,0,sizeof(nDataNum));
memset(nDataIndex,0,sizeof(nDataIndex));
//memset(nDataArray,-1,sizeof(nDataArray));
for(int kk = 0; kk< DATATYPE_MAX_NUM ; kk++)
{
for(int kkk = 0; kkk < DATA_MAX_NUM ; kkk++)
nDataArray[kk][kkk] = INVALID_DATA_VAL;//nAverageArray[kk];
}
comparetime += onedayspan;
if(comparetime >= endtime)
{
break;
}
}
int LastVal;
for(int nn = 0; nn < DATATYPE_MAX_NUM ; nn++)
{
int nCurVal = GetTypeData(*it,nn);
if(nCurVal != INVALID_DATA_VAL && nDataNum[nn] < DATA_MAX_NUM )
{
nData[nn][nDataNum[nn]] = nCurVal;
nDataNum[nn] ++ ;//suppose never exceed
}
if(nCurVal != INVALID_DATA_VAL && nDataNum[nn] >= DATA_MAX_NUM )
{
if(nDataIndex[nn] < DATA_MAX_NUM)
{
if(nDataIndex[nn] == 0)
{
LastVal = nAverageArray[nn];
}
else
{
LastVal = nDataArray[nn][nDataIndex[nn]-1];
}
//int nCurVal = GetTypeData(*it,nn);
//if( abs(nCurVal - LastVal) * 20 > LastVal )
if( abs(nCurVal - LastVal) * 20 > nAverageArray[nn] )
{
nDataArray[nn][nDataIndex[nn]] = nCurVal;
nDataIndex[nn]++;
}
}
}
}
}
while(comparetime < endtime)
{
tickLabel.Format(_T("%02d-%02d"), comparetime.GetMonth(),comparetime.GetDay());
for(int nType = 0; nType < DATATYPE_MAX_NUM ; nType++)
{
tmpSeries = new CGraphSeries();
tmpSeries->SetLabel(tickLabel);
if(nDataNum[nType] == 0)
{
for(int jj = 0; jj < DATA_MAX_NUM ; jj++)
{
tmpSeries->SetData(jj, INVALID_DATA_VAL);
}
}
else if (nDataNum[nType] > 0 && nDataNum[nType] < DATA_MAX_NUM)
{
int jj;
for(jj = 0; jj < nDataNum[nType] ; jj++)
{
tmpSeries->SetData(jj, nData[nType][jj]);
}
for(jj = nDataNum[nType]; jj< DATA_MAX_NUM ;jj++)
{
tmpSeries->SetData(jj, INVALID_DATA_VAL);
}
}
else
{
int jj;
for(jj = 0; jj< DATA_MAX_NUM - nDataIndex[nType];jj++)
{
tmpSeries->SetData(jj, nData[nType][jj]);
}
for(int kk = 0; kk < nDataIndex[nType] ; kk++)
{
tmpSeries->SetData(jj, nDataArray[nType][kk]);
jj++;
}
}
MyGraph[nType]->AddSeries(tmpSeries);
}
memset(nDataNum,0,sizeof(nDataNum));
memset(nDataIndex,0,sizeof(nDataIndex));
//memset(nDataArray,-1,sizeof(nDataArray));
comparetime += onedayspan;
}
}
DrawGraphicBackBuffer();
UpdateGraphicsDisplay();
return ;
}
LRESULT CClientChartDlg::UpdatePartialClientHistoryData(COleDateTime starttime,bool bFreshFlag)
{
return 0x01;
}
void CClientChartDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO:
AfxGetMainWnd()->Invalidate();
AfxGetMainWnd()->UpdateWindow();
UpdateGraphicsDisplay();
}
void CClientChartDlg::DrawGraphicBackBuffer()
{
CWnd *hwnd;
CRect rect;
int nWidth,nHeight;
int StartYPos = 0;
int nGraphHeight;
hwnd = GetDlgItem(IDC_STATIC_BACKGROUND);
hwnd->GetWindowRect(&rect);
#if 0
nWidth = rect.Width();
nGraphHeight = m_dcHeight/DATATYPE_MAX_NUM ;
dcMem.FillSolidRect(0,0,m_dcWidth,m_dcHeight,afxGlobalData.GetColor(COLOR_BTNFACE));
for(int ii = 0 ; ii< DATATYPE_MAX_NUM;ii++)
{
MyGraph[ii]->DrawGraph(&dcMem,0,StartYPos, nWidth,nGraphHeight);
StartYPos += nGraphHeight;
}
#else
nWidth = rect.Width();
nHeight = rect.Height();
dcMem.FillSolidRect(0,0,nWidth,nHeight,afxGlobalData.GetColor(COLOR_BTNFACE));
int curDataTypeIdx = m_ComboType.GetCurSel();
MyGraph[curDataTypeIdx]->DrawGraph(&dcMem,0,0, nWidth,nHeight);
#endif
}
void CClientChartDlg::RetrieveGraphicsData()
{
#if 0
//COleDateTime olestarttime;
//COleDateTime oleendtime;
COleDateTimeSpan timespan; // days,hours,minutes,seconds
timespan.SetDateTimeSpan(7,0,0,0); //retrive 7-days data
//m_datatimectrl.GetTime(oleendtime);
//olestarttime = oleendtime - timespan;
DWORD MessageID = USER_MSG_GET_CLIENT_HISTORY;
ST_CLIENT_RT_STA_PARA * stParameter = new ST_CLIENT_RT_STA_PARA;
stParameter->clientid = m_ClientId;
m_datatimectrl.GetTime(stParameter->endtime);
stParameter->starttime = stParameter->endtime - timespan;
m_LastRetrieveStartTime = stParameter->starttime;
if(!PostThreadMessage(GetControllerApp->m_WorkThread.m_nThreadID, MessageID, (WPARAM)this->GetSafeHwnd(), (LPARAM)stParameter))
{
TRACE1("post message failed,errno:%d\n",::GetLastError());
}
#endif
}
void CClientChartDlg::RetrieveGraphicsDataNew(const COleDateTime & starttime, const COleDateTime & endtime )
{
if(starttime >= m_LastRetrieveStartTime && endtime <= m_LastRetrieveEndTime)
{
bIsRetrievingData = true;
((CButton *)GetDlgItem(IDC_RADIO_ONE_WEEK))->EnableWindow(false);
((CButton *)GetDlgItem(IDC_RADIO_ONE_MONTH))->EnableWindow(false);
((CButton *)GetDlgItem(IDC_RADIO_THREE_MONTH))->EnableWindow(false);
((CButton *)GetDlgItem(IDC_RADIO_USER_DEFINE))->EnableWindow(false);
((CButton *)GetDlgItem(IDC_DATETIMEPICKER4))->EnableWindow(false);
((CButton *)GetDlgItem(IDC_DATETIMEPICKER5))->EnableWindow(false);
((CButton *)GetDlgItem(IDC_BTN_SEARCH))->EnableWindow(false);
RetrieveBufferedData(starttime,endtime);
bIsRetrievingData = false;
((CButton *)GetDlgItem(IDC_RADIO_ONE_WEEK))->EnableWindow(true);
((CButton *)GetDlgItem(IDC_RADIO_ONE_MONTH))->EnableWindow(true);
((CButton *)GetDlgItem(IDC_RADIO_THREE_MONTH))->EnableWindow(true);
((CButton *)GetDlgItem(IDC_RADIO_USER_DEFINE))->EnableWindow(true);
if(m_nLastRadioBoxIdx == 3)
{
((CButton *)GetDlgItem(IDC_DATETIMEPICKER4))->EnableWindow(true);
((CButton *)GetDlgItem(IDC_DATETIMEPICKER5))->EnableWindow(true);
((CButton *)GetDlgItem(IDC_BTN_SEARCH))->EnableWindow(true);
}
m_starttime = starttime;
m_endtime = endtime;
UpdateData(FALSE);
return;
}
DWORD MessageID = USER_MSG_GET_CLIENT_HISTORY;
ST_CLIENT_RT_STA_PARA * stParameter = new ST_CLIENT_RT_STA_PARA;
stParameter->clientid = m_ClientId;
stParameter->starttime = starttime;
stParameter->endtime = endtime;
m_LastRetrieveStartTime = starttime;
m_LastRetrieveEndTime = endtime;
m_starttime = starttime;
m_endtime = endtime;
UpdateData(FALSE);
if(!PostThreadMessage(GetControllerApp->m_WorkThread.m_nThreadID, MessageID, (WPARAM)this->GetSafeHwnd(), (LPARAM)stParameter))
{
TRACE1("post message failed,errno:%d\n",::GetLastError());
}
else
{
//retrieve data begin
bIsRetrievingData = true;
((CButton *)GetDlgItem(IDC_COMBO_TYPE))->EnableWindow(false);
((CButton *)GetDlgItem(IDC_RADIO_ONE_WEEK))->EnableWindow(false);
((CButton *)GetDlgItem(IDC_RADIO_ONE_MONTH))->EnableWindow(false);
((CButton *)GetDlgItem(IDC_RADIO_THREE_MONTH))->EnableWindow(false);
((CButton *)GetDlgItem(IDC_RADIO_USER_DEFINE))->EnableWindow(false);
((CButton *)GetDlgItem(IDC_DATETIMEPICKER4))->EnableWindow(false);
((CButton *)GetDlgItem(IDC_DATETIMEPICKER5))->EnableWindow(false);
((CButton *)GetDlgItem(IDC_BTN_SEARCH))->EnableWindow(false);
}
}
void CClientChartDlg::ReleaseGraphicsData()
{
for(int ii = 0;ii < DATATYPE_MAX_NUM; ii++)
{
if(MyGraph[ii])
{
delete MyGraph[ii];
MyGraph[ii] = NULL;
}
}
}
void CClientChartDlg::UpdateGraphicsDisplay()
{
CWnd *hwnd;
CDC *mydc;
CRect rect;
hwnd = GetDlgItem(IDC_STATIC_BACKGROUND);
mydc = hwnd->GetDC();
hwnd->GetWindowRect(&rect);
ScreenToClient(&rect);
#if 0
mydc->BitBlt(2,2,rect.Width()-4,rect.Height()-4,&dcMem,0,m_StartY,SRCCOPY);
#else
mydc->BitBlt(2,2,rect.Width()-4,rect.Height()-4,&dcMem,0,0,SRCCOPY);
#endif
}
void CClientChartDlg::OnSize(UINT nType, int cx, int cy)
{
CDialogEx::OnSize(nType, cx, cy);
UPDATE_EASYSIZE;
if(m_nInitFlag)
{
CalcLayout();
//modified by LiuSong
//DrawGraphicBackBuffer();
//UpdateGraphicsDisplay();
}
// TODO:
}
void CClientChartDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
/*
int nCurPos = GetScrollPos(SB_HORZ);
int nPrevHScrollBarPos = nPos;
*/
#if 0
int nCurPos = m_nCurHScrollBarPos;
SCROLLINFO Info;
GetScrollInfo(SB_HORZ, &Info, SIF_ALL);
switch (nSBCode)
{
case SB_TOP:
nCurPos = Info.nMin;
break;
case SB_BOTTOM:
nCurPos = Info.nMax;
break;
case SB_LINELEFT:
nCurPos = max(Info.nMin, nCurPos - 10);
break;
case SB_LINERIGHT:
nCurPos = min(Info.nMax, nCurPos + 10);
break;
case SB_PAGELEFT:
nCurPos = max(Info.nMin, nCurPos - (int)Info.nPage);
break;
case SB_PAGERIGHT:
nCurPos = min(Info.nMax, nCurPos + (int)Info.nPage);
break;
//case SB_THUMBPOSITION:
// nCurPos = nPos;
// break;
case SB_THUMBTRACK:
nCurPos = nPos;
break;
case SB_ENDSCROLL:
break;
}
// TODO:
COleDateTime endtime;
COleDateTime starttime;
COleDateTimeSpan timespan;//(2,0,0,0); // days,hours,minutes,seconds
COleDateTimeSpan span(7,0,0,0);
DWORD dwResult = m_datatimectrl.GetTime(endtime);
//if (dwResult == GDT_VALID)
{
if(nCurPos > m_nCurHScrollBarPos)
{
timespan.SetDateTimeSpan((nCurPos-m_nCurHScrollBarPos)/24,0,0,0);
endtime += timespan;
m_datatimectrl.SetTime(endtime);
starttime = endtime - m_Span;
if(starttime - m_CurDataStartTime <= span)
{
UpdatePartialClientHistoryData(starttime,true);
}
else
{
starttime.SetDateTime(0,0,0,0,0,0);
UpdatePartialClientHistoryData(starttime,false);
}
}
else if(nCurPos < m_nCurHScrollBarPos)
{
timespan.SetDateTimeSpan((m_nCurHScrollBarPos - nCurPos)/24,0,0,0);
endtime -= timespan;
m_datatimectrl.SetTime(endtime);
starttime = endtime - m_Span;
if( m_CurDataStartTime - endtime <= span)
{
UpdatePartialClientHistoryData(starttime,true);
}
else
{
starttime.SetDateTime(0,0,0,0,0,0);
UpdatePartialClientHistoryData(starttime,false);
}
}
}
switch (nSBCode)
{
case SB_THUMBTRACK:
m_nCurHScrollBarPos = nCurPos;
break;
case SB_ENDSCROLL:
RetrieveGraphicsData();
break;
default:
m_nCurHScrollBarPos = Info.nMax/2;
break;
}
//SetScrollPos(SB_HORZ, nCurPos);
#endif
CDialogEx::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CClientChartDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
#if 0
int nCurPos = GetScrollPos(SB_VERT);
SCROLLINFO Info;
GetScrollInfo(SB_VERT, &Info, SIF_ALL);
switch (nSBCode)
{
case SB_TOP:
nCurPos = Info.nMin;
break;
case SB_BOTTOM:
nCurPos = Info.nMax;
break;
case SB_ENDSCROLL:
break;
case SB_LINEUP:
nCurPos = max(Info.nMin, nCurPos - 10);
break;
case SB_LINEDOWN:
nCurPos = min(Info.nMax, nCurPos + 10);
break;
case SB_PAGEUP:
nCurPos = max(Info.nMin, nCurPos - (int)Info.nPage);
break;
case SB_PAGEDOWN:
nCurPos = min(Info.nMax, nCurPos + (int)Info.nPage);
break;
case SB_THUMBPOSITION:
nCurPos = nPos;
break;
case SB_THUMBTRACK:
nCurPos = nPos;
break;
}
SetScrollPos(SB_VERT, nCurPos);
if (m_StartY != nCurPos)
{
m_StartY = nCurPos;
CalcLayout();
UpdateGraphicsDisplay();
}
#endif
CDialogEx::OnVScroll(nSBCode, nPos, pScrollBar);
}
VOID CClientChartDlg::CalcLayout()
{
#if 0
CRect ClientRect,Rect;
//GetClientRect(&ClientRect);
//GetDlgItem(IDC_STATIC_BACKGROUND)->GetWindowRect(ClientRect);
//ScreenToClient(&ClientRect);
GetDlgItem(IDC_STATIC_FOREGROUND)->GetWindowRect(Rect);
ScreenToClient(&Rect);
int TotalLength = m_dcHeight;
int nCurPos = GetScrollPos(SB_VERT);
//m_StartY = -nCurPos;
m_StartY = nCurPos;
if(TotalLength > Rect.Height())
{
EnableScrollBarCtrl(SB_VERT, TRUE);
EnableScrollBar(SB_VERT, ESB_ENABLE_BOTH );
SCROLLINFO ScrollInfo;
ScrollInfo.cbSize = sizeof(SCROLLINFO);
ScrollInfo.nMin = 0;
ScrollInfo.nMax = TotalLength;
ScrollInfo.nPage = Rect.Height();
ScrollInfo.fMask = SIF_RANGE | SIF_PAGE;
SetScrollInfo(SB_VERT,&ScrollInfo);
//m_StartY = max(m_StartY, Rect.Height() - TotalLength );
m_StartY = min(m_StartY, TotalLength - Rect.Height());
}
else
{
EnableScrollBarCtrl(SB_VERT, FALSE);
m_StartY = 0;
}
#else
m_StartY = 0;
#endif
}
BOOL CClientChartDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO:
INIT_EASYSIZE;
SCROLLINFO ScrollInfo;
ScrollInfo.cbSize = sizeof(SCROLLINFO);
ScrollInfo.nMin = 0;
ScrollInfo.nMax = 24*365*2;//can get two year's data
ScrollInfo.nPage = 24; //24 hours
ScrollInfo.fMask = SIF_RANGE | SIF_PAGE;
SetScrollInfo(SB_HORZ,&ScrollInfo);
//SetScrollRange (SB_HORZ, 0, 50, FALSE);
SetScrollPos(SB_HORZ,ScrollInfo.nMax/2);
m_nCurHScrollBarPos = GetScrollPos(SB_HORZ);
for(int ii = 0; ii < DATATYPE_MAX_NUM ; ii++)
{
m_ComboType.AddString(Translate(mDataTypeTitleName[ii]));
}
m_ComboType.SetCurSel(0);
((CButton *)GetDlgItem(IDC_RADIO_ONE_WEEK))->SetWindowText(Translate(_T("7 Days")));
((CButton *)GetDlgItem(IDC_RADIO_ONE_MONTH))->SetWindowText(Translate(_T("30 Days")));
((CButton *)GetDlgItem(IDC_RADIO_THREE_MONTH))->SetWindowText(Translate(_T("90 Days")));
((CButton *)GetDlgItem(IDC_RADIO_USER_DEFINE))->SetWindowText(Translate(_T("User Define")));
((CButton *)GetDlgItem(IDC_BTN_SEARCH))->SetWindowText(Translate(_T("Search")));
bIsRetrievingData = false;
m_nLastRadioBoxIdx = 0;
((CButton *)GetDlgItem(IDC_RADIO_ONE_WEEK))->SetCheck(true);
((CButton *)GetDlgItem(IDC_RADIO_ONE_MONTH))->SetCheck(false);
((CButton *)GetDlgItem(IDC_RADIO_THREE_MONTH))->SetCheck(false);
((CButton *)GetDlgItem(IDC_DATETIMEPICKER4))->EnableWindow(false);
((CButton *)GetDlgItem(IDC_DATETIMEPICKER5))->EnableWindow(false);
((CButton *)GetDlgItem(IDC_BTN_SEARCH))->EnableWindow(false);
m_LastRetrieveStartTime.SetDate(1970,1,1);
m_LastRetrieveEndTime.SetDate(1970,1,1);
COleDateTime tmp = COleDateTime::GetCurrentTime() ;
//tmp += 1;
COleDateTime starttime,endtime;
COleDateTimeSpan timespan; // days,hours,minutes,seconds
timespan.SetDateTimeSpan(6,23,59,59); //retrive 7-days data
endtime.SetDateTime(tmp.GetYear(),tmp.GetMonth(),tmp.GetDay(),23,59,59);
starttime = endtime - timespan;
RetrieveGraphicsDataNew(starttime,endtime);
CWnd *hwnd;
CDC *mydc;
CRect rect;
hwnd = GetDlgItem(IDC_STATIC_BACKGROUND);
hwnd->GetWindowRect(&rect);
mydc = hwnd->GetDC();
dcMem.CreateCompatibleDC(mydc);
bmp.CreateCompatibleBitmap(mydc,m_dcWidth,m_dcHeight);
dcMem.SelectObject(&bmp);
dcMem.FillSolidRect(0,0,m_dcWidth,m_dcHeight,afxGlobalData.GetColor(COLOR_BTNFACE));
GetDlgItem(IDC_BUTTON1)->SetWindowText(Translate(_T("zoom in")));
GetDlgItem(IDC_BUTTON3)->SetWindowText(Translate(_T("zoom out")));
CalcLayout();
UpdateGraphicsDisplay();
m_nInitFlag = true;
return TRUE; // return TRUE unless you set the focus to a control
}
BOOL CClientChartDlg::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
// TODO:
#if 0
if(zDelta < 0)
{
OnVScroll(SB_LINEDOWN, GetScrollPos(SB_VERT), GetScrollBarCtrl(SB_VERT));
}
else if (zDelta > 0)
{
OnVScroll(SB_LINEUP, GetScrollPos(SB_VERT), GetScrollBarCtrl(SB_VERT));
}
#endif
return CDialogEx::OnMouseWheel(nFlags, zDelta, pt);
}
void CClientChartDlg::OnBnClickedButton1()
{
int nCount = m_ClientRTStatisticsList.size();
if(nCount /m_nScale > 10)
{
m_nScale *=2;
for(int ii=0;ii<DATATYPE_MAX_NUM;ii++)
{
MyGraph[ii]->SetScale(m_nScale);
}
DrawGraphicBackBuffer();
UpdateGraphicsDisplay();
}
}
void CClientChartDlg::OnBnClickedButton3()
{
// TODO:
if(m_nScale >= 2)
{
m_nScale /= 2;
for(int ii=0;ii<DATATYPE_MAX_NUM;ii++)
{
MyGraph[ii]->SetScale(m_nScale);
}
DrawGraphicBackBuffer();
UpdateGraphicsDisplay();
}
}
void CClientChartDlg::OnDtnDatetimechangeDatetimepicker1(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMDATETIMECHANGE pDTChange = reinterpret_cast<LPNMDATETIMECHANGE>(pNMHDR);
// TODO:
*pResult = 0;
#if 0
RetrieveGraphicsData();
#endif
}
void CClientChartDlg::OnCbnSelchangeComboType()
{
// TODO: Add your control notification handler code here
DrawGraphicBackBuffer();
UpdateGraphicsDisplay();
}
void CClientChartDlg::OnBnClickedRadioOneWeek()
{
// TODO: Add your control notification handler code here
if(bIsRetrievingData)
{
return;
}
if( m_nLastRadioBoxIdx != 0)
{
m_nLastRadioBoxIdx = 0;
((CButton *)GetDlgItem(IDC_RADIO_ONE_WEEK))->SetCheck(true);
((CButton *)GetDlgItem(IDC_RADIO_ONE_MONTH))->SetCheck(false);
((CButton *)GetDlgItem(IDC_RADIO_THREE_MONTH))->SetCheck(false);
((CButton *)GetDlgItem(IDC_DATETIMEPICKER4))->EnableWindow(false);
((CButton *)GetDlgItem(IDC_DATETIMEPICKER5))->EnableWindow(false);
((CButton *)GetDlgItem(IDC_BTN_SEARCH))->EnableWindow(false);
COleDateTime tmp = COleDateTime::GetCurrentTime();
//tmp += 1;
COleDateTime starttime,endtime;
COleDateTimeSpan timespan; // days,hours,minutes,seconds
timespan.SetDateTimeSpan(6,23,59,59); //retrieve 7-days data
endtime.SetDateTime(tmp.GetYear(),tmp.GetMonth(),tmp.GetDay(),23,59,59);
starttime = endtime - timespan ;
RetrieveGraphicsDataNew(starttime,endtime);
}
}
void CClientChartDlg::OnBnClickedRadioOneMonth()
{
// TODO: Add your control notification handler code here
if(bIsRetrievingData)
{
return;
}
if( m_nLastRadioBoxIdx != 1)
{
m_nLastRadioBoxIdx = 1;
((CButton *)GetDlgItem(IDC_RADIO_ONE_WEEK))->SetCheck(false);
((CButton *)GetDlgItem(IDC_RADIO_ONE_MONTH))->SetCheck(true);
((CButton *)GetDlgItem(IDC_RADIO_THREE_MONTH))->SetCheck(false);
((CButton *)GetDlgItem(IDC_DATETIMEPICKER4))->EnableWindow(false);
((CButton *)GetDlgItem(IDC_DATETIMEPICKER5))->EnableWindow(false);
((CButton *)GetDlgItem(IDC_BTN_SEARCH))->EnableWindow(false);
COleDateTime tmp = COleDateTime::GetCurrentTime();
//tmp += 1;
COleDateTime starttime,endtime;
COleDateTimeSpan timespan; // days,hours,minutes,seconds
timespan.SetDateTimeSpan(29,23,59,59); //retrieve 1-month data
endtime.SetDateTime(tmp.GetYear(),tmp.GetMonth(),tmp.GetDay(),23,59,59);
starttime = endtime - timespan;
RetrieveGraphicsDataNew(starttime,endtime);
}
}
void CClientChartDlg::OnBnClickedRadioThreeMonth()
{
// TODO: Add your control notification handler code here
if(bIsRetrievingData)
{
return;
}
if( m_nLastRadioBoxIdx != 2)
{
m_nLastRadioBoxIdx = 2;
((CButton *)GetDlgItem(IDC_RADIO_ONE_WEEK))->SetCheck(false);
((CButton *)GetDlgItem(IDC_RADIO_ONE_MONTH))->SetCheck(false);
((CButton *)GetDlgItem(IDC_RADIO_THREE_MONTH))->SetCheck(true);
((CButton *)GetDlgItem(IDC_DATETIMEPICKER4))->EnableWindow(false);
((CButton *)GetDlgItem(IDC_DATETIMEPICKER5))->EnableWindow(false);
((CButton *)GetDlgItem(IDC_BTN_SEARCH))->EnableWindow(false);
COleDateTime tmp = COleDateTime::GetCurrentTime();
//tmp += 1;
COleDateTime starttime,endtime;
COleDateTimeSpan timespan; // days,hours,minutes,seconds
timespan.SetDateTimeSpan(89,23,59,59); //retrieve 3-months data
endtime.SetDateTime(tmp.GetYear(),tmp.GetMonth(),tmp.GetDay(),23,59,59);
starttime = endtime - timespan;
RetrieveGraphicsDataNew(starttime,endtime);
}
}
void CClientChartDlg::OnBnClickedRadioUserDefine()
{
// TODO: Add your control notification handler code here
if(bIsRetrievingData)
{
return;
}
if( m_nLastRadioBoxIdx != 3)
{
m_nLastRadioBoxIdx = 3;
((CButton *)GetDlgItem(IDC_RADIO_ONE_WEEK))->SetCheck(false);
((CButton *)GetDlgItem(IDC_RADIO_ONE_MONTH))->SetCheck(false);
((CButton *)GetDlgItem(IDC_RADIO_THREE_MONTH))->SetCheck(false);
((CButton *)GetDlgItem(IDC_DATETIMEPICKER4))->EnableWindow(true);
((CButton *)GetDlgItem(IDC_DATETIMEPICKER5))->EnableWindow(true);
((CButton *)GetDlgItem(IDC_BTN_SEARCH))->EnableWindow(true);
}
}
/*COleDateTime tmpStartTime,tmpEndTime;*/
void CClientChartDlg::OnDtnDatetimechangeDatetimepicker4(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMDATETIMECHANGE pDTChange = reinterpret_cast<LPNMDATETIMECHANGE>(pNMHDR);
// TODO: Add your control notification handler code here
COleDateTime date(pDTChange->st.wYear, pDTChange->st.wMonth, pDTChange->st.wDay, 0, 0, 0);
CheckDateTime(this, IDC_DATETIMEPICKER4, IDC_DATETIMEPICKER5, date, true);
/*
COleDateTime starttime,endtime;
//((CDateTimeCtrl *)GetDlgItem(IDC_DATETIMEPICKER4))->GetTime(starttime);
starttime.SetDate(pDTChange->st.wYear, pDTChange->st.wMonth, pDTChange->st.wDay);
((CDateTimeCtrl *)GetDlgItem(IDC_DATETIMEPICKER5))->GetTime(endtime);
if(starttime == tmpStartTime)
return;
tmpStartTime = starttime;
COleDateTimeSpan timespan; // days,hours,minutes,seconds
timespan.SetDateTimeSpan(90,0,0,0); //retrieve 3-months data
if(endtime > starttime + timespan)
{
AfxMessageBox(Translate(_T("The period between start time and end time must less than 90 days!")));
((CDateTimeCtrl *)GetDlgItem(IDC_DATETIMEPICKER4))->SetTime(m_starttime);
//UpdateData(FALSE);
return;
}
else if (endtime <= starttime)
{
AfxMessageBox(Translate(_T("start time must less than end time!")));
((CDateTimeCtrl *)GetDlgItem(IDC_DATETIMEPICKER4))->SetTime(m_starttime);
//UpdateData(FALSE);
return;
}
else
{
m_starttime = starttime;
//UpdateData(TRUE);
}
*/
*pResult = 0;
//((CButton *)GetDlgItem(IDC_DATETIMEPICKER5))->SetFocus();
}
void CClientChartDlg::OnDtnDatetimechangeDatetimepicker5(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMDATETIMECHANGE pDTChange = reinterpret_cast<LPNMDATETIMECHANGE>(pNMHDR);
// TODO: Add your control notification handler code here
COleDateTime date(pDTChange->st.wYear, pDTChange->st.wMonth, pDTChange->st.wDay, 0, 0, 0);
CheckDateTime(this, IDC_DATETIMEPICKER4, IDC_DATETIMEPICKER5, date, false);
/*
COleDateTime starttime,endtime;
((CDateTimeCtrl *)GetDlgItem(IDC_DATETIMEPICKER4))->GetTime(starttime);
//((CDateTimeCtrl *)GetDlgItem(IDC_DATETIMEPICKER5))->GetTime(endtime);
endtime.SetDate(pDTChange->st.wYear, pDTChange->st.wMonth, pDTChange->st.wDay);
if(endtime == tmpEndTime)
return;
tmpEndTime = endtime;
COleDateTimeSpan timespan; // days,hours,minutes,seconds
timespan.SetDateTimeSpan(90,0,0,0); //retrieve 3-months data
if(endtime > starttime + timespan)
{
AfxMessageBox(Translate(_T("The period between start time and end time must less than 90 days!")));
((CDateTimeCtrl *)GetDlgItem(IDC_DATETIMEPICKER5))->SetTime(m_endtime);
//UpdateData(FALSE);
}
else if (endtime <= starttime)
{
AfxMessageBox(Translate(_T("start time must less than end time!")));
((CDateTimeCtrl *)GetDlgItem(IDC_DATETIMEPICKER5))->SetTime(m_endtime);
//UpdateData(FALSE);
}
else
{
m_endtime = endtime;
//UpdateData(TRUE);
}
*/
*pResult = 0;
}
void CClientChartDlg::OnBnClickedBtnSearch()
{
// TODO: Add your control notification handler code here
COleDateTime starttime,endtime;
((CDateTimeCtrl *)GetDlgItem(IDC_DATETIMEPICKER4))->GetTime(starttime);
((CDateTimeCtrl *)GetDlgItem(IDC_DATETIMEPICKER5))->GetTime(endtime);
COleDateTimeSpan timespan; // days,hours,minutes,seconds
timespan.SetDateTimeSpan(89,23,59,59); //retrieve 3-months data
endtime.SetDateTime(endtime.GetYear(),endtime.GetMonth(),endtime.GetDay(),23,59,59);
//starttime = endtime - timespan;
if(starttime < endtime - timespan)
{
MessageBox(Translate(_T("The period between start time and end time must less than 90 days!")), Translate(_T("Warning:Client monitor")), MB_OK|MB_ICONEXCLAMATION);
return;
}
/*
COleDateTimeSpan timespan; // days,hours,minutes,seconds
timespan.SetDateTimeSpan(90,0,0,0); //retrieve 3-months data
if(endtime > starttime + timespan)
{
AfxMessageBox(Translate(_T("The period between start time and end time must less than 90 days!")));
return;
}*/
else if (endtime <= starttime)
{
MessageBox(Translate(_T("start time must less than end time!")), Translate(_T("Warning:Client monitor")), MB_OK|MB_ICONEXCLAMATION);
return;
}
else
{
starttime.SetDate(starttime.GetYear(),starttime.GetMonth(),starttime.GetDay());
//endtime += 1;
endtime.SetDateTime(endtime.GetYear(),endtime.GetMonth(),endtime.GetDay(),23,59,59);
RetrieveGraphicsDataNew(starttime,endtime);
}
}
#else
IMPLEMENT_DYNAMIC(CClientChartDlg, CDialogEx)
CString mDataTypeTitleName[MY_GRAPH_NUM]=
{
_T("CpuUsage"),_T("MemUsage"),_T("DiskUsage"),_T("fps"),
_T("Fan Speed"), _T("CPU Temperature"), _T("MotherBoard Temperature"),
_T("HDD Temperature"), _T("GPU Temperature"),
};
CClientChartDlg::CClientChartDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(CClientChartDlg::IDD, pParent)
{
m_nInitFlag = FALSE;
m_nScale = 1;
m_nRecordNum = 0;
m_Span.SetDateTimeSpan(7,0,0,0);
m_dcWidth = 2000;
m_dcHeight = 350 * MY_GRAPH_NUM;
for(int ii = 0;ii< MY_GRAPH_NUM ; ii++)
{
MyGraph[ii] = NULL;
}
}
CClientChartDlg::~CClientChartDlg()
{
dcMem.DeleteDC(); //delete DC
bmp.DeleteObject(); //delete bitmap
}
void CClientChartDlg::SetClientId(int id)
{
m_ClientId = id;
}
int CClientChartDlg::GetClientId()
{
return m_ClientId;
}
void CClientChartDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_DATETIMEPICKER1, m_datatimectrl);
}
BEGIN_MESSAGE_MAP(CClientChartDlg, CDialogEx)
ON_WM_CLOSE()
ON_WM_PAINT()
ON_WM_SIZE()
ON_WM_HSCROLL()
ON_WM_VSCROLL()
ON_WM_MOUSEWHEEL()
ON_BN_CLICKED(IDC_BUTTON1, &CClientChartDlg::OnBnClickedButton1)
ON_BN_CLICKED(IDC_BUTTON3, &CClientChartDlg::OnBnClickedButton3)
ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATETIMEPICKER1, &CClientChartDlg::OnDtnDatetimechangeDatetimepicker1)
ON_MESSAGE(USER_MSG_GET_CLIENT_HISTORY, &CClientChartDlg::UpdateClientHistoryData)
END_MESSAGE_MAP()
BEGIN_EASYSIZE_MAP(CClientChartDlg)
EASYSIZE(IDC_STATIC_BACKGROUND,ES_BORDER,ES_BORDER,ES_BORDER,ES_KEEPSIZE,0)
EASYSIZE(IDC_STATIC_FOREGROUND,ES_BORDER,ES_BORDER,ES_BORDER,ES_BORDER,0)
END_EASYSIZE_MAP
// CUserMonitorChartDlg
void CClientChartDlg::OnCancel()
{
}
void CClientChartDlg::OnOK()
{
}
void CClientChartDlg::OnClose()
{
/*
CClientStateTab* parent = (CClientStateTab*)GetParent();
parent->RemoveTab(parent->GetActiveTab());
*/
CDialogEx::OnClose();
}
LRESULT CClientChartDlg::UpdateClientHistoryData(WPARAM wp,LPARAM lp)
{
//////////////////////////////////////////////////////////////////////////
// How to get a buf
UINT nMessageBufID = (UINT)wp;
DataBuf< ClientStatus> MessageBuf;
if (!WorkThreadDataManager< ClientStatus >
::GetDataBuf(nMessageBufID, MessageBuf))
{
return 1;
}
ClientStatus *pClientStatus = (ClientStatus *)MessageBuf.Get();
pClientStatus->GetPerfHistory(m_ClientRTStatisticsList);
//set current data start time
m_CurDataStartTime = m_LastRetrieveStartTime ;
m_nRecordNum = m_ClientRTStatisticsList.size();
//release graphic data object
ReleaseGraphicsData();
//create graphic data object to show chart
int ii = 0;
MyGraph[ii] = new CGraph();
MyGraph[ii]->SetGraphTitle(Translate(mDataTypeTitleName[ii]));
MyGraph[ii]->SetGraphType(1);
MyGraph[ii]->SetScale(m_nScale);
MyGraph[ii]->SetTickSpace(20);
MyGraph[ii]->SetTickRange(100);
MyGraph[ii]->SetCurColorIndex(0);
MyGraph[ii]->SetXAxisAlignment(270);
MyGraph[ii]->SetXAxisLabel(_T("T"));
MyGraph[ii]->SetYAxisLabel(_T("%"));
ii++;
MyGraph[ii] = new CGraph();
MyGraph[ii]->SetGraphTitle(Translate(mDataTypeTitleName[ii]));
MyGraph[ii]->SetGraphType(1);
MyGraph[ii]->SetScale(m_nScale);
MyGraph[ii]->SetTickSpace(20);
MyGraph[ii]->SetTickRange(100);
MyGraph[ii]->SetCurColorIndex(1);
MyGraph[ii]->SetXAxisAlignment(270);
MyGraph[ii]->SetXAxisLabel(_T("T"));
MyGraph[ii]->SetYAxisLabel(_T("%"));
ii++;
MyGraph[ii] = new CGraph();
MyGraph[ii]->SetGraphTitle(Translate(mDataTypeTitleName[ii]));
MyGraph[ii]->SetGraphType(1);
MyGraph[ii]->SetScale(m_nScale);
MyGraph[ii]->SetTickSpace(20);
MyGraph[ii]->SetTickRange(100);
MyGraph[ii]->SetCurColorIndex(2);
MyGraph[ii]->SetXAxisAlignment(270);
MyGraph[ii]->SetXAxisLabel(_T("T"));
MyGraph[ii]->SetYAxisLabel(_T("%"));
ii++;
MyGraph[ii] = new CGraph();
MyGraph[ii]->SetGraphTitle(Translate(mDataTypeTitleName[ii]));
MyGraph[ii]->SetGraphType(1);
MyGraph[ii]->SetScale(m_nScale);
MyGraph[ii]->SetTickSpace(10);
MyGraph[ii]->SetTickRange(60);
MyGraph[ii]->SetCurColorIndex(3);
MyGraph[ii]->SetXAxisAlignment(270);
MyGraph[ii]->SetXAxisLabel(_T("T"));
MyGraph[ii]->SetYAxisLabel(_T("fps"));
ii++;
MyGraph[ii] = new CGraph();
MyGraph[ii]->SetGraphTitle(Translate(mDataTypeTitleName[ii]));
MyGraph[ii]->SetGraphType(1);
MyGraph[ii]->SetScale(m_nScale);
MyGraph[ii]->SetTickSpace(1000);
MyGraph[ii]->SetTickRange(10000);
MyGraph[ii]->SetCurColorIndex(4);
MyGraph[ii]->SetXAxisAlignment(270);
MyGraph[ii]->SetXAxisLabel(_T("T"));
MyGraph[ii]->SetYAxisLabel(_T("RPM"));
for (int i = 0; i < 4; ++i)
{
ii++;
MyGraph[ii] = new CGraph();
MyGraph[ii]->SetGraphTitle(Translate(mDataTypeTitleName[ii]));
MyGraph[ii]->SetGraphType(1);
MyGraph[ii]->SetScale(m_nScale);
MyGraph[ii]->SetTickSpace(10);
MyGraph[ii]->SetTickRange(100);
MyGraph[ii]->SetCurColorIndex(5 + i);
MyGraph[ii]->SetXAxisAlignment(270);
MyGraph[ii]->SetXAxisLabel(_T("T"));
// MyGraph[ii]->SetYAxisLabel(_T("¡æ"));
MyGraph[ii]->SetYAxisLabel(_T("\x2103"));
}
if(m_nRecordNum > 0x00)
{
int j = 0;
S3Time rdtime(0,0,0,0,0,0);
const COleDateTime oletime;
CString tickLabel;
//SYSTEM_STATUS_DESC stSystemStatusDesc;
CGraphSeries* tmpSeries;
std::vector<PerfStatus>::iterator it;
for(it=m_ClientRTStatisticsList.begin(); it< m_ClientRTStatisticsList.end(); ++it,j++)
{
rdtime = it->GetSubmitTime();
const COleDateTime oletime = rdtime.ToCOleDateTime();
tickLabel.Format(_T("%02d-%02d %02d:%02d"), oletime.GetMonth(),oletime.GetDay(),oletime.GetHour(),oletime.GetMinute());
tmpSeries = new CGraphSeries();
//CString tickLabel;
//tickLabel.Format(_T("%d"), j);
tmpSeries->SetLabel(tickLabel);
//tmpSeries->SetLabel(_T("day"));
tmpSeries->SetData(0,it->GetCpuUsage()%100);
MyGraph[0]->AddSeries(tmpSeries);
tmpSeries = new CGraphSeries();
//CString tickLabel;
//tickLabel.Format(_T("%d"), j);
tmpSeries->SetLabel(tickLabel);
//tmpSeries->SetLabel(_T("day"));
tmpSeries->SetData(0, it->GetMemUsage() %100);
MyGraph[1]->AddSeries(tmpSeries);
tmpSeries = new CGraphSeries();
//CString tickLabel;
//tickLabel.Format(_T("%d"), j);
tmpSeries->SetLabel(tickLabel);
//tmpSeries->SetLabel(_T("day"));
tmpSeries->SetData(0, it->GetHarddiskUsage() %100);
MyGraph[2]->AddSeries(tmpSeries);
tmpSeries = new CGraphSeries();
//CString tickLabel;
//tickLabel.Format(_T("%d"), j);
tmpSeries->SetLabel(tickLabel);
//tmpSeries->SetLabel(_T("day"));
tmpSeries->SetData(0, it->GetFPS() % 60);
MyGraph[3]->AddSeries(tmpSeries);
tmpSeries = new CGraphSeries();
tmpSeries->SetLabel(tickLabel);
tmpSeries->SetData(0, it->GetFanSpeed() % 10000);
MyGraph[4]->AddSeries(tmpSeries);
tmpSeries = new CGraphSeries();
tmpSeries->SetLabel(tickLabel);
tmpSeries->SetData(0, it->GetCPUTemperature() % 100);
MyGraph[5]->AddSeries(tmpSeries);
tmpSeries = new CGraphSeries();
tmpSeries->SetLabel(tickLabel);
tmpSeries->SetData(0, it->GetMBTemperature() % 100);
MyGraph[6]->AddSeries(tmpSeries);
tmpSeries = new CGraphSeries();
tmpSeries->SetLabel(tickLabel);
tmpSeries->SetData(0, it->GetHDDTemperature() % 100);
MyGraph[7]->AddSeries(tmpSeries);
tmpSeries = new CGraphSeries();
tmpSeries->SetLabel(tickLabel);
tmpSeries->SetData(0, it->GetGPUTemperature() % 100);
MyGraph[8]->AddSeries(tmpSeries);
}
}
DrawGraphicBackBuffer();
UpdateGraphicsDisplay();
return 0x01;
}
LRESULT CClientChartDlg::UpdatePartialClientHistoryData(COleDateTime starttime,bool bFreshFlag)
{
S3Time stTime = S3Time::CreateTime(starttime);
if(m_nRecordNum <= 0x00)
{
return 0x00;
}
//release graphic data object
ReleaseGraphicsData();
//create graphic data object to show chart
int ii = 0;
MyGraph[ii] = new CGraph();
MyGraph[ii]->SetGraphTitle(Translate(mDataTypeTitleName[ii]));
MyGraph[ii]->SetGraphType(1);
MyGraph[ii]->SetScale(m_nScale);
MyGraph[ii]->SetTickSpace(10);
MyGraph[ii]->SetTickRange(100);
MyGraph[ii]->SetCurColorIndex(0);
MyGraph[ii]->SetXAxisAlignment(270);
MyGraph[ii]->SetXAxisLabel(_T("T"));
MyGraph[ii]->SetYAxisLabel(_T("%"));
ii++;
MyGraph[ii] = new CGraph();
MyGraph[ii]->SetGraphTitle(Translate(mDataTypeTitleName[ii]));
MyGraph[ii]->SetGraphType(1);
MyGraph[ii]->SetScale(m_nScale);
MyGraph[ii]->SetTickSpace(10);
MyGraph[ii]->SetTickRange(100);
MyGraph[ii]->SetCurColorIndex(1);
MyGraph[ii]->SetXAxisAlignment(270);
MyGraph[ii]->SetXAxisLabel(_T("T"));
MyGraph[ii]->SetYAxisLabel(_T("%"));
ii++;
MyGraph[ii] = new CGraph();
MyGraph[ii]->SetGraphTitle(Translate(mDataTypeTitleName[ii]));
MyGraph[ii]->SetGraphType(1);
MyGraph[ii]->SetScale(m_nScale);
MyGraph[ii]->SetTickSpace(10);
MyGraph[ii]->SetTickRange(100);
MyGraph[ii]->SetCurColorIndex(2);
MyGraph[ii]->SetXAxisAlignment(270);
MyGraph[ii]->SetXAxisLabel(_T("T"));
MyGraph[ii]->SetYAxisLabel(_T("%"));
ii++;
MyGraph[ii] = new CGraph();
MyGraph[ii]->SetGraphTitle(Translate(mDataTypeTitleName[ii]));
MyGraph[ii]->SetGraphType(1);
MyGraph[ii]->SetScale(m_nScale);
MyGraph[ii]->SetTickSpace(10);
MyGraph[ii]->SetTickRange(60);
MyGraph[ii]->SetCurColorIndex(3);
MyGraph[ii]->SetXAxisAlignment(270);
MyGraph[ii]->SetXAxisLabel(_T("T"));
MyGraph[ii]->SetYAxisLabel(_T("%"));
ii++;
MyGraph[ii] = new CGraph();
MyGraph[ii]->SetGraphTitle(Translate(mDataTypeTitleName[ii]));
MyGraph[ii]->SetGraphType(1);
MyGraph[ii]->SetScale(m_nScale);
MyGraph[ii]->SetTickSpace(1000);
MyGraph[ii]->SetTickRange(10000);
MyGraph[ii]->SetCurColorIndex(4);
MyGraph[ii]->SetXAxisAlignment(270);
MyGraph[ii]->SetXAxisLabel(_T("T"));
MyGraph[ii]->SetYAxisLabel(_T("RPM"));
for (int i = 0; i < 4; ++i)
{
ii++;
MyGraph[ii] = new CGraph();
MyGraph[ii]->SetGraphTitle(Translate(mDataTypeTitleName[ii]));
MyGraph[ii]->SetGraphType(1);
MyGraph[ii]->SetScale(m_nScale);
MyGraph[ii]->SetTickSpace(10);
MyGraph[ii]->SetTickRange(100);
MyGraph[ii]->SetCurColorIndex(5 + i);
MyGraph[ii]->SetXAxisAlignment(270);
MyGraph[ii]->SetXAxisLabel(_T("T"));
// MyGraph[ii]->SetYAxisLabel(_T("¡æ"));
MyGraph[ii]->SetYAxisLabel(_T("\x2103"));
}
//if(starttime.m_dt > 0)
if(true == bFreshFlag)
{
int j = 0;
S3Time rdtime(0,0,0,0,0,0);
const COleDateTime oletime;
CString tickLabel;
//SYSTEM_STATUS_DESC stSystemStatusDesc;
CGraphSeries* tmpSeries;
std::vector<PerfStatus>::iterator it;
for(it=m_ClientRTStatisticsList.begin(); it< m_ClientRTStatisticsList.end(); ++it,j++)
{
rdtime = it->GetSubmitTime();
if(rdtime < stTime)
{
continue ;// this is not what i want
}
const COleDateTime oletime = rdtime.ToCOleDateTime();
tickLabel.Format(_T("%d-%d %d:%d"), oletime.GetMonth(),oletime.GetDay(),oletime.GetHour(),oletime.GetMinute());
tmpSeries = new CGraphSeries();
//CString tickLabel;
//tickLabel.Format(_T("%d"), j);
tmpSeries->SetLabel(tickLabel);
//tmpSeries->SetLabel(_T("day"));
tmpSeries->SetData(0,it->GetCpuUsage()%100);
MyGraph[0]->AddSeries(tmpSeries);
tmpSeries = new CGraphSeries();
//CString tickLabel;
//tickLabel.Format(_T("%d"), j);
tmpSeries->SetLabel(tickLabel);
//tmpSeries->SetLabel(_T("day"));
tmpSeries->SetData(0, it->GetMemUsage() %100);
MyGraph[1]->AddSeries(tmpSeries);
tmpSeries = new CGraphSeries();
//CString tickLabel;
//tickLabel.Format(_T("%d"), j);
tmpSeries->SetLabel(tickLabel);
//tmpSeries->SetLabel(_T("day"));
tmpSeries->SetData(0, it->GetHarddiskUsage() %100);
MyGraph[2]->AddSeries(tmpSeries);
tmpSeries = new CGraphSeries();
//CString tickLabel;
//tickLabel.Format(_T("%d"), j);
tmpSeries->SetLabel(tickLabel);
//tmpSeries->SetLabel(_T("day"));
tmpSeries->SetData(0, it->GetFPS() % 60);
MyGraph[3]->AddSeries(tmpSeries);
tmpSeries = new CGraphSeries();
tmpSeries->SetLabel(tickLabel);
tmpSeries->SetData(0, it->GetFanSpeed() % 10000);
MyGraph[4]->AddSeries(tmpSeries);
tmpSeries = new CGraphSeries();
tmpSeries->SetLabel(tickLabel);
tmpSeries->SetData(0, it->GetCPUTemperature() % 100);
MyGraph[5]->AddSeries(tmpSeries);
tmpSeries = new CGraphSeries();
tmpSeries->SetLabel(tickLabel);
tmpSeries->SetData(0, it->GetMBTemperature() % 100);
MyGraph[6]->AddSeries(tmpSeries);
tmpSeries = new CGraphSeries();
tmpSeries->SetLabel(tickLabel);
tmpSeries->SetData(0, it->GetHDDTemperature() % 100);
MyGraph[7]->AddSeries(tmpSeries);
tmpSeries = new CGraphSeries();
tmpSeries->SetLabel(tickLabel);
tmpSeries->SetData(0, it->GetGPUTemperature() % 100);
MyGraph[8]->AddSeries(tmpSeries);
}
}
DrawGraphicBackBuffer();
UpdateGraphicsDisplay();
return 0x01;
}
void CClientChartDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO:
AfxGetMainWnd()->Invalidate();
AfxGetMainWnd()->UpdateWindow();
UpdateGraphicsDisplay();
}
void CClientChartDlg::DrawGraphicBackBuffer()
{
CWnd *hwnd;
CRect rect;
int nWidth,nHeight;
int StartYPos = 0;
int nGraphHeight;
hwnd = GetDlgItem(IDC_STATIC_BACKGROUND);
hwnd->GetWindowRect(&rect);
nWidth = rect.Width();
nGraphHeight = m_dcHeight/MY_GRAPH_NUM ;
dcMem.FillSolidRect(0,0,m_dcWidth,m_dcHeight,afxGlobalData.GetColor(COLOR_BTNFACE));
for(int ii = 0 ; ii< MY_GRAPH_NUM;ii++)
{
MyGraph[ii]->DrawGraph(&dcMem,0,StartYPos, nWidth,nGraphHeight);
StartYPos += nGraphHeight;
}
}
void CClientChartDlg::RetrieveGraphicsData()
{
//COleDateTime olestarttime;
//COleDateTime oleendtime;
COleDateTimeSpan timespan; // days,hours,minutes,seconds
timespan.SetDateTimeSpan(7,0,0,0); //retrive 7-days data
//m_datatimectrl.GetTime(oleendtime);
//olestarttime = oleendtime - timespan;
DWORD MessageID = USER_MSG_GET_CLIENT_HISTORY;
ST_CLIENT_RT_STA_PARA * stParameter = new ST_CLIENT_RT_STA_PARA;
stParameter->clientid = m_ClientId;
m_datatimectrl.GetTime(stParameter->endtime);
stParameter->starttime = stParameter->endtime - timespan;
m_LastRetrieveStartTime = stParameter->starttime;
if(!PostThreadMessage(GetControllerApp->m_WorkThread.m_nThreadID, MessageID, (WPARAM)this->GetSafeHwnd(), (LPARAM)stParameter))
{
TRACE1("post message failed,errno:%d\n",::GetLastError());
}
}
void CClientChartDlg::ReleaseGraphicsData()
{
for(int ii = 0;ii < MY_GRAPH_NUM; ii++)
{
if(MyGraph[ii])
{
delete MyGraph[ii];
MyGraph[ii] = NULL;
}
}
}
void CClientChartDlg::UpdateGraphicsDisplay()
{
CWnd *hwnd;
CDC *mydc;
CRect rect;
hwnd = GetDlgItem(IDC_STATIC_FOREGROUND);
mydc = hwnd->GetDC();
hwnd->GetWindowRect(&rect);
ScreenToClient(&rect);
mydc->BitBlt(2,2,rect.Width()-4,rect.Height()-4,&dcMem,0,m_StartY,SRCCOPY);//½«ÄÚ´æDCÉϵÄͼÏó¿½±´µ½Ç°Ì¨
}
void CClientChartDlg::OnSize(UINT nType, int cx, int cy)
{
CDialogEx::OnSize(nType, cx, cy);
UPDATE_EASYSIZE;
if(m_nInitFlag)
{
CalcLayout();
//modified by LiuSong
//DrawGraphicBackBuffer();
//UpdateGraphicsDisplay();
}
// TODO:
}
void CClientChartDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
/*
int nCurPos = GetScrollPos(SB_HORZ);
int nPrevHScrollBarPos = nPos;
*/
int nCurPos = m_nCurHScrollBarPos;
SCROLLINFO Info;
GetScrollInfo(SB_HORZ, &Info, SIF_ALL);
switch (nSBCode)
{
case SB_TOP:
nCurPos = Info.nMin;
break;
case SB_BOTTOM:
nCurPos = Info.nMax;
break;
case SB_LINELEFT:
nCurPos = max(Info.nMin, nCurPos - 10);
break;
case SB_LINERIGHT:
nCurPos = min(Info.nMax, nCurPos + 10);
break;
case SB_PAGELEFT:
nCurPos = max(Info.nMin, nCurPos - (int)Info.nPage);
break;
case SB_PAGERIGHT:
nCurPos = min(Info.nMax, nCurPos + (int)Info.nPage);
break;
//case SB_THUMBPOSITION:
// nCurPos = nPos;
// break;
case SB_THUMBTRACK:
nCurPos = nPos;
break;
case SB_ENDSCROLL:
break;
}
// TODO:
COleDateTime endtime;
COleDateTime starttime;
COleDateTimeSpan timespan;//(2,0,0,0); // days,hours,minutes,seconds
COleDateTimeSpan span(7,0,0,0);
DWORD dwResult = m_datatimectrl.GetTime(endtime);
//if (dwResult == GDT_VALID)
{
if(nCurPos > m_nCurHScrollBarPos)
{
timespan.SetDateTimeSpan((nCurPos-m_nCurHScrollBarPos)/24,0,0,0);
endtime += timespan;
m_datatimectrl.SetTime(endtime);
starttime = endtime - m_Span;
if(starttime - m_CurDataStartTime <= span)
{
UpdatePartialClientHistoryData(starttime,true);
}
else
{
starttime.SetDateTime(0,0,0,0,0,0);
UpdatePartialClientHistoryData(starttime,false);
}
}
else if(nCurPos < m_nCurHScrollBarPos)
{
timespan.SetDateTimeSpan((m_nCurHScrollBarPos - nCurPos)/24,0,0,0);
endtime -= timespan;
m_datatimectrl.SetTime(endtime);
starttime = endtime - m_Span;
if( m_CurDataStartTime - endtime <= span)
{
UpdatePartialClientHistoryData(starttime,true);
}
else
{
starttime.SetDateTime(0,0,0,0,0,0);
UpdatePartialClientHistoryData(starttime,false);
}
}
}
switch (nSBCode)
{
case SB_THUMBTRACK:
m_nCurHScrollBarPos = nCurPos;
break;
case SB_ENDSCROLL:
RetrieveGraphicsData();
break;
default:
m_nCurHScrollBarPos = Info.nMax/2;
break;
}
//SetScrollPos(SB_HORZ, nCurPos);
CDialogEx::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CClientChartDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
int nCurPos = GetScrollPos(SB_VERT);
SCROLLINFO Info;
GetScrollInfo(SB_VERT, &Info, SIF_ALL);
switch (nSBCode)
{
case SB_TOP:
nCurPos = Info.nMin;
break;
case SB_BOTTOM:
nCurPos = Info.nMax;
break;
case SB_ENDSCROLL:
break;
case SB_LINEUP:
nCurPos = max(Info.nMin, nCurPos - 10);
break;
case SB_LINEDOWN:
nCurPos = min(Info.nMax, nCurPos + 10);
break;
case SB_PAGEUP:
nCurPos = max(Info.nMin, nCurPos - (int)Info.nPage);
break;
case SB_PAGEDOWN:
nCurPos = min(Info.nMax, nCurPos + (int)Info.nPage);
break;
case SB_THUMBPOSITION:
nCurPos = nPos;
break;
case SB_THUMBTRACK:
nCurPos = nPos;
break;
}
SetScrollPos(SB_VERT, nCurPos);
if (m_StartY != nCurPos)
{
m_StartY = nCurPos;
CalcLayout();
UpdateGraphicsDisplay();
}
CDialogEx::OnVScroll(nSBCode, nPos, pScrollBar);
}
VOID CClientChartDlg::CalcLayout()
{
CRect ClientRect,Rect;
//GetClientRect(&ClientRect);
//GetDlgItem(IDC_STATIC_BACKGROUND)->GetWindowRect(ClientRect);
//ScreenToClient(&ClientRect);
GetDlgItem(IDC_STATIC_FOREGROUND)->GetWindowRect(Rect);
ScreenToClient(&Rect);
int TotalLength = m_dcHeight;
int nCurPos = GetScrollPos(SB_VERT);
//m_StartY = -nCurPos;
m_StartY = nCurPos;
if(TotalLength > Rect.Height())
{
EnableScrollBarCtrl(SB_VERT, TRUE);
EnableScrollBar(SB_VERT, ESB_ENABLE_BOTH );
SCROLLINFO ScrollInfo;
ScrollInfo.cbSize = sizeof(SCROLLINFO);
ScrollInfo.nMin = 0;
ScrollInfo.nMax = TotalLength;
ScrollInfo.nPage = Rect.Height();
ScrollInfo.fMask = SIF_RANGE | SIF_PAGE;
SetScrollInfo(SB_VERT,&ScrollInfo);
//m_StartY = max(m_StartY, Rect.Height() - TotalLength );
m_StartY = min(m_StartY, TotalLength - Rect.Height());
}
else
{
EnableScrollBarCtrl(SB_VERT, FALSE);
m_StartY = 0;
}
}
BOOL CClientChartDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO:
INIT_EASYSIZE;
SCROLLINFO ScrollInfo;
ScrollInfo.cbSize = sizeof(SCROLLINFO);
ScrollInfo.nMin = 0;
ScrollInfo.nMax = 24*365*2;//can get two year's data
ScrollInfo.nPage = 24; //24 hours
ScrollInfo.fMask = SIF_RANGE | SIF_PAGE;
SetScrollInfo(SB_HORZ,&ScrollInfo);
//SetScrollRange (SB_HORZ, 0, 50, FALSE);
SetScrollPos(SB_HORZ,ScrollInfo.nMax/2);
m_nCurHScrollBarPos = GetScrollPos(SB_HORZ);
RetrieveGraphicsData();
CWnd *hwnd;
CDC *mydc;
CRect rect;
hwnd = GetDlgItem(IDC_STATIC_BACKGROUND);
hwnd->GetWindowRect(&rect);
mydc = hwnd->GetDC();
dcMem.CreateCompatibleDC(mydc);
bmp.CreateCompatibleBitmap(mydc,m_dcWidth,m_dcHeight);
dcMem.SelectObject(&bmp);
dcMem.FillSolidRect(0,0,m_dcWidth,m_dcHeight,afxGlobalData.GetColor(COLOR_BTNFACE));
GetDlgItem(IDC_BUTTON1)->SetWindowText(Translate(_T("zoom in")));
GetDlgItem(IDC_BUTTON3)->SetWindowText(Translate(_T("zoom out")));
CalcLayout();
UpdateGraphicsDisplay();
m_nInitFlag = true;
return TRUE; // return TRUE unless you set the focus to a control
}
BOOL CClientChartDlg::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
// TODO:
if(zDelta < 0)
{
OnVScroll(SB_LINEDOWN, GetScrollPos(SB_VERT), GetScrollBarCtrl(SB_VERT));
}
else if (zDelta > 0)
{
OnVScroll(SB_LINEUP, GetScrollPos(SB_VERT), GetScrollBarCtrl(SB_VERT));
}
return CDialogEx::OnMouseWheel(nFlags, zDelta, pt);
}
void CClientChartDlg::OnBnClickedButton1()
{
int nCount = m_ClientRTStatisticsList.size();
if(nCount /m_nScale > 10)
{
m_nScale *=2;
for(int ii=0;ii<MY_GRAPH_NUM;ii++)
{
MyGraph[ii]->SetScale(m_nScale);
}
DrawGraphicBackBuffer();
UpdateGraphicsDisplay();
}
}
void CClientChartDlg::OnBnClickedButton3()
{
// TODO:
if(m_nScale >= 2)
{
m_nScale /= 2;
for(int ii=0;ii<MY_GRAPH_NUM;ii++)
{
MyGraph[ii]->SetScale(m_nScale);
}
DrawGraphicBackBuffer();
UpdateGraphicsDisplay();
}
}
void CClientChartDlg::OnDtnDatetimechangeDatetimepicker1(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMDATETIMECHANGE pDTChange = reinterpret_cast<LPNMDATETIMECHANGE>(pNMHDR);
// TODO:
*pResult = 0;
RetrieveGraphicsData();
}
#endif
| [
"zhangxiangyang@os-easy.com"
] | zhangxiangyang@os-easy.com |
5cee2dcc9ad924a3d6594d315765690782f40e1a | 507740298bd2705b464c6333f136c33255370b42 | /DijkstraShortestPath/DijkstraShortestPath3cpp.cpp | 2d69cd92297cef1eecdb58e29c249e9a2caba519 | [] | no_license | dhl7799/Dijkstra_shortestpath | e87ed50359f4c92f05091684838cdaaf73b1903b | 62404772a917ffaa982fb900e5759594d775da2b | refs/heads/master | 2020-12-15T19:39:37.038783 | 2020-01-21T01:42:49 | 2020-01-21T01:42:49 | 235,233,220 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,756 | cpp | #include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include<functional>
using namespace std;
//https://www.acmicpc.net/problem/1753
#define INF 100001
class Node
{
private:
int next;
int weight;
public:
Node(int n, int w)
:next(n),weight(w)
{
}
Node()
:next(0),weight(INF)
{
}
bool operator() (Node& n1) const
{
return weight > n1.weight;
}
int getnext() const {
return next;
}
int getweight() const {
return weight;
}
void setnext(int n) {
next = n;
}
void setweight(int w) {
weight = w;
}
};
struct cmp {
bool operator()(Node n1, Node n2) {
return n1.getweight() > n2.getweight();
}
};
int main()
{
vector<Node> Map[20001];
priority_queue<Node, vector<Node>,cmp> vt;
int vertex=0, edge=0;
int start=0;
int u=0, v=0, w=0;
scanf("%d", &vertex);
scanf("%d", &edge);
scanf("%d", &start);
vertex++;
vector<int> dijkstra(vertex, INF);
for (int i = 0; i < edge; i++)
{
scanf("%d", &u);
scanf("%d", &v);
scanf("%d", &w);
Map[u].push_back(Node(v,w));
}
int location=0;
int _weight=0;
int nextLocation=0;
int nextWeight=0;
dijkstra[start] = 0;
vt.push(Node(start, 0));
while (!vt.empty())
{
location = vt.top().getnext();
_weight = vt.top().getweight();
vt.pop();
if (dijkstra[location] < _weight)
continue;
for (int i = 0; i < Map[location].size(); i++) {
nextLocation = Map[location][i].getnext();
nextWeight = _weight + Map[location][i].getweight();
if (dijkstra[nextLocation] > nextWeight) {
dijkstra[nextLocation] = nextWeight;
vt.push(Node(nextLocation, nextWeight));
}
}
}
for (int i = 1; i < vertex; ++i) {
dijkstra[i] == INF ? printf("INF\n") : printf("%d\n", dijkstra[i]);
}
return 0;
} | [
"donghyundhl@naver.com"
] | donghyundhl@naver.com |
1aa8c74aca3d109b87cd738b7c63e5f50f06cdb0 | d64e8f319c51f1ae3eeda4a9a20c644e8bf84787 | /Aquarium_server/Common/S2C2S_common.h | 241807479820f01c02ceea77180c9f50625767a4 | [] | no_license | You-Yeon/Aquarium-server | 77056781462a7c4fa520d6322da1dffe333e1ce6 | 7ec449647fd5204e0618fd972e23b14030c91cad | refs/heads/master | 2022-04-02T08:40:47.799866 | 2020-02-02T06:33:20 | 2020-02-02T06:33:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,146 | h | #pragma once
namespace S2C2S {
//Message ID that replies to each RMI method.
static const ::Proud::RmiID Rmi_RequestLogin = (::Proud::RmiID)(1000+1);
static const ::Proud::RmiID Rmi_NotifyLoginSuccess = (::Proud::RmiID)(1000+2);
static const ::Proud::RmiID Rmi_NotifyLoginFailed = (::Proud::RmiID)(1000+3);
static const ::Proud::RmiID Rmi_JoinGameRoom = (::Proud::RmiID)(1000+4);
static const ::Proud::RmiID Rmi_LeaveGameRoom = (::Proud::RmiID)(1000+5);
static const ::Proud::RmiID Rmi_Room_Appear = (::Proud::RmiID)(1000+6);
static const ::Proud::RmiID Rmi_Room_Disappear = (::Proud::RmiID)(1000+7);
static const ::Proud::RmiID Rmi_GameStart = (::Proud::RmiID)(1000+8);
static const ::Proud::RmiID Rmi_PlayerInfo = (::Proud::RmiID)(1000+9);
static const ::Proud::RmiID Rmi_Player_Move = (::Proud::RmiID)(1000+10);
// List that has RMI ID.
extern ::Proud::RmiID g_RmiIDList[];
// RmiID List Count
extern int g_RmiIDListCount;
}
| [
"cyy0067@naver.com"
] | cyy0067@naver.com |
d95c21499bb4041a44e906c9f713b67cfef99931 | bcb3b228e421cf986c7d952d809515e45ffb24b5 | /Engine/Math/Vector2.cpp | 9f17dc220bcb4f950162962b06deb28d0d1b6337 | [] | no_license | HoudeNicholas/GAT150 | 6360c573dc9589582476ded1f39bc73f67aca197 | b8f1a1a1e4d9c6f245853bd0542dd1a139100e8f | refs/heads/master | 2022-12-13T21:37:33.991652 | 2020-09-02T05:40:24 | 2020-09-02T05:40:24 | 284,754,394 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 685 | cpp | #include "pch.h"
#include "Vector2.h"
#include <string>
namespace nc
{
const Vector2 Vector2::left{ -1, 0 };
const Vector2 Vector2::right{ 1, 0 };
const Vector2 Vector2::up{ 0, -1 };
const Vector2 Vector2::down{ 0, 1 };
const Vector2 Vector2::forward{ 0, -1 };
std::istream& operator >> (std::istream& stream, Vector2& v) {
std::string line;
std::getline(stream, line);
if (line.find("{") != std::string::npos) {
std::string vx = line.substr(line.find("{") + 1, line.find(",") - line.find("{") - 1);
v.x = std::stof(vx);
std::string vy = line.substr(line.find(",") + 1, line.find("}") - line.find(",") - 1);
v.y = std::stof(vy);
}
return stream;
}
} | [
"houdenicholas00@gmail.com"
] | houdenicholas00@gmail.com |
542d3d49de735ada2087d69feb2bf50c60867a42 | 455ecd26f1439cd4a44856c743b01d711e3805b6 | /java/include/android.view.ScaleGestureDetector_SimpleOnScaleGestureListener.hpp | e55ab003945a50189980b35d3e2b4ebbae156f8f | [] | no_license | lbguilherme/duvidovc-app | 00662bf024f82a842c808673109b30fe2b70e727 | f7c86ea812d2ae8dd892918b65ea429e9906531c | refs/heads/master | 2021-03-24T09:17:17.834080 | 2015-09-08T02:32:44 | 2015-09-08T02:32:44 | 33,072,192 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,229 | hpp | #pragma once
#include "../src/java-core.hpp"
#include <jni.h>
#include <cstdint>
#include <memory>
#include <vector>
#include "java.lang.Object.hpp"
#include "android.view.ScaleGestureDetector_OnScaleGestureListener.hpp"
namespace android { namespace view { class ScaleGestureDetector; } }
namespace android {
namespace view {
class ScaleGestureDetector_SimpleOnScaleGestureListener : public virtual ::java::lang::Object,
public virtual ::android::view::ScaleGestureDetector_OnScaleGestureListener {
public:
static jclass _class;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wreorder"
explicit ScaleGestureDetector_SimpleOnScaleGestureListener(jobject _obj) : ::java::lang::Object(_obj), ::android::view::ScaleGestureDetector_OnScaleGestureListener(_obj) {}
#pragma GCC diagnostic pop
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wreorder"
ScaleGestureDetector_SimpleOnScaleGestureListener(const ::android::view::ScaleGestureDetector_SimpleOnScaleGestureListener& x) : ::java::lang::Object((jobject)0), ::android::view::ScaleGestureDetector_OnScaleGestureListener((jobject)0) {obj = x.obj;}
ScaleGestureDetector_SimpleOnScaleGestureListener(::android::view::ScaleGestureDetector_SimpleOnScaleGestureListener&& x) : ::java::lang::Object((jobject)0), ::android::view::ScaleGestureDetector_OnScaleGestureListener((jobject)0) {obj = x.obj; x.obj = JavaObjectHolder((jobject)0);}
#pragma GCC diagnostic pop
::android::view::ScaleGestureDetector_SimpleOnScaleGestureListener& operator=(const ::android::view::ScaleGestureDetector_SimpleOnScaleGestureListener& x) {obj = x.obj; return *this;}
::android::view::ScaleGestureDetector_SimpleOnScaleGestureListener& operator=(::android::view::ScaleGestureDetector_SimpleOnScaleGestureListener&& x) {obj = std::move(x.obj); return *this;}
ScaleGestureDetector_SimpleOnScaleGestureListener();
bool onScale(const ::android::view::ScaleGestureDetector&) const;
bool onScaleBegin(const ::android::view::ScaleGestureDetector&) const;
void onScaleEnd(const ::android::view::ScaleGestureDetector&) const;
};
}
}
| [
"dev@lbguilherme.com"
] | dev@lbguilherme.com |
63a661367bc86e3ed2bc197f112eb77ebda74b0a | f5110c5e2540903e21fde4dcdd567bab1c77241b | /leetcode/657RobotReturnToOrigin.h | 60ab97648042f5c3a5ed8ff95d01a90342208b25 | [] | no_license | chenbloog/algorithm | 3b47ce6fb3911b2dada63fa8af6728adfb15c590 | e75e555060178253593ffde0bd18fad7cd1b5f50 | refs/heads/master | 2022-12-21T05:27:45.718359 | 2020-09-28T09:57:43 | 2020-09-28T09:57:43 | 299,147,777 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 353 | h | //657机器人能否返回原点
#include <string>
using namespace std;
bool judgeCircle(string moves)
{
int x = 0, y = 0;
int i = 0;
while (moves[i] != '\0')
{
switch (moves[i])
{
case 'R':
x++;
break;
case 'L':
x--;
break;
case 'U':
y++;
break;
case 'D':
y--;
break;
}
i++;
}
return x == 0 && y == 0;
} | [
"="
] | = |
2a87d5d6a78fcbfde9b0267826dbf0ac5dff316c | 575731c1155e321e7b22d8373ad5876b292b0b2f | /examples/native/ios/Pods/boost-for-react-native/boost/python/detail/if_else.hpp | 89df9d58aeb4b487e1cf65d9d13dff918608d0ee | [
"BSL-1.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | Nozbe/zacs | 802a84ffd47413a1687a573edda519156ca317c7 | c3d455426bc7dfb83e09fdf20781c2632a205c04 | refs/heads/master | 2023-06-12T20:53:31.482746 | 2023-06-07T07:06:49 | 2023-06-07T07:06:49 | 201,777,469 | 432 | 10 | MIT | 2023-01-24T13:29:34 | 2019-08-11T14:47:50 | JavaScript | UTF-8 | C++ | false | false | 1,474 | hpp | // Copyright David Abrahams 2002.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef IF_ELSE_DWA2002322_HPP
# define IF_ELSE_DWA2002322_HPP
# include <boost/config.hpp>
namespace boost { namespace python { namespace detail {
template <class T> struct elif_selected;
template <class T>
struct if_selected
{
template <bool b>
struct elif : elif_selected<T>
{
};
template <class U>
struct else_
{
typedef T type;
};
};
template <class T>
struct elif_selected
{
# if !(defined(__MWERKS__) && __MWERKS__ <= 0x2407)
template <class U> class then;
# else
template <class U>
struct then : if_selected<T>
{
};
# endif
};
# if !(defined(__MWERKS__) && __MWERKS__ <= 0x2407)
template <class T>
template <class U>
class elif_selected<T>::then : public if_selected<T>
{
};
# endif
template <bool b> struct if_
{
template <class T>
struct then : if_selected<T>
{
};
};
struct if_unselected
{
template <bool b> struct elif : if_<b>
{
};
template <class U>
struct else_
{
typedef U type;
};
};
template <>
struct if_<false>
{
template <class T>
struct then : if_unselected
{
};
};
}}} // namespace boost::python::detail
#endif // IF_ELSE_DWA2002322_HPP
| [
"radexpl@gmail.com"
] | radexpl@gmail.com |
c13850cc92c765fed05f5f2d6634ef987f54fb66 | b4b4e324cbc6159a02597aa66f52cb8e1bc43bc1 | /C++ code/Codeforces/610E(5).cpp | 83fe3083193a9f25e77756a22666cd123b7bcb23 | [] | no_license | fsps60312/old-C-code | 5d0ffa0796dde5ab04c839e1dc786267b67de902 | b4be562c873afe9eacb45ab14f61c15b7115fc07 | refs/heads/master | 2022-11-30T10:55:25.587197 | 2017-06-03T16:23:03 | 2017-06-03T16:23:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,720 | cpp | #include<cstdio>
#include<cassert>
#include<map>
#include<utility>
using namespace std;
int K;
namespace SegTree
{
map<int,int>D;
inline int GetC(const int i)
{
auto it=D.upper_bound(i);
assert(it!=D.begin());
return (--it)->second;
}
struct Node
{
struct AutoArray
{
map<int,int>A;
int *B;
AutoArray():B(NULL){}
inline void Clear()
{
A.clear();
delete B;
B=NULL;
}
inline int Get(const int i)const
{
if(B)return B[i];
else
{
const auto &it=A.find(i);
if(it==A.end())return 0;
else return it->second;
}
}
inline void Set(const int i,const int v)
{
if(v==0)return;
(*this)[i]=v;
}
inline int &operator[](const int i)
{
if(B)return B[i];
else
{
int &ans=A[i];
if((int)A.size()>32)
{
B=new int[K*K];
for(int j=0;j<K*K;j++)B[j]=0;
for(const auto &p:A)B[p.first]=p.second;
map<int,int>().swap(A);
return B[i];
}
else return ans;
}
}
}C;
int TAG;
inline void Rebuild(const int loc)
{
TAG=-1;
C.Clear();
++C[GetC(loc)*K+GetC(loc+1)];
}
inline void SetTag(const int c,const int cnt)
{
TAG=c;
C.Clear();
C[c*K+c]=cnt;
}
};
inline Node Merge(const Node &a,const Node &b)
{
Node o;
o.TAG=-1;
if(a.C.B==NULL&&b.C.B==NULL)
{
for(const auto &p:a.C.A)o.C[p.first]+=p.second;
for(const auto &p:b.C.A)o.C[p.first]+=p.second;
}
else
{
for(int i=0;i<K*K;i++)o.C.Set(i,a.C.Get(i)+b.C.Get(i));
}
return o;
}
Node S[800000];
int N;
void Build(const int id,const int l,const int r)
{
if(l==r)
{
S[id].Rebuild(r);
return;
}
else
{
const int mid=(l+r)/2;
Build(id*2,l,mid),Build(id*2+1,mid+1,r);
S[id]=Merge(S[id*2],S[id*2+1]);
}
}
void Build(const int _N,const char *str)
{
N=_N;
D.clear();
for(int i=0;i<N;i++)D[i]=str[i]-'a';
Build(1,0,N-2);
}
void PutDown(const int id,const int l,const int mid,const int r)
{
if(S[id].TAG==-1)return;
const int c=S[id].TAG;S[id].TAG=-1;
S[id*2].SetTag(c,mid-l+1),S[id*2+1].SetTag(c,r-mid);
}
void ModifyOne(const int id,const int l,const int r,const int loc)
{
if(l==r)
{
assert(loc==r);
S[id].Rebuild(loc);
return;
}
else
{
const int mid=(l+r)/2;
PutDown(id,l,mid,r);
if(loc<=mid)ModifyOne(id*2,l,mid,loc);
else ModifyOne(id*2+1,mid+1,r,loc);
S[id]=Merge(S[id*2],S[id*2+1]);
}
}
void ModifyToSame(const int id,const int l,const int r,const int bl,const int br,const int c)
{
if(r<bl||br<l)return;
if(bl<=l&&r<=br)
{
S[id].SetTag(c,r-l+1);
return;
}
const int mid=(l+r)/2;
PutDown(id,l,mid,r);
ModifyToSame(id*2,l,mid,bl,br,c),ModifyToSame(id*2+1,mid+1,r,bl,br,c);
S[id]=Merge(S[id*2],S[id*2+1]);
}
void Modify(const int l,const int r,const int c)
{
if(r+1<N)
{
const int t=GetC(r+1);
D[r+1]=t;
}
D[l]=c;
auto it=D.find(l);
for(++it;it!=D.end()&&it->first<=r;)D.erase(it++);
if(l-1>=0)ModifyOne(1,0,N-2,l-1);
if(r+1<N)ModifyOne(1,0,N-2,r);
ModifyToSame(1,0,N-2,l,r-1,c);
}
};
int N,M;
char S[200001];
int main()
{
// freopen("in.txt","r",stdin);
while(scanf("%d%d%d",&N,&M,&K)==3)
{
scanf("%s",S);
SegTree::Build(N,S);
for(int type;M--;)
{
scanf("%d",&type);
if(type==1)
{
int l,r;
static char c[2];
scanf("%d%d%s",&l,&r,c),--l,--r;
SegTree::Modify(l,r,c[0]-'a');
}
else if(type==2)
{
static char s[11];
scanf("%s",s);
const auto &result=SegTree::S[1];
static int loc[11];
for(int i=0;i<K;i++)loc[s[i]-'a']=i;
int ans=1;
for(int i=0;i<K*K;i++)if(loc[i/K]>=loc[i%K])ans+=result.C.Get(i);
printf("%d\n",ans);
}
else assert(0);
}
}
}
| [
"fsps60312@yahoo.com.tw"
] | fsps60312@yahoo.com.tw |
4bc3580b23f24fef12befdefff7404b07e1d0384 | a41c0e9452ffa2f22991fb2d0335ea319d26e0ec | /nodes/UDPClient.hpp | 576fd041ae6bc8605b5775d9cfa742a1754d930e | [
"MIT"
] | permissive | cvra/LIDAR-Simulation | ed56cb51d88b146a3d64b7831c80bf330c06dbc8 | a1230aed2d17d313cc9f027f557c0b85512439d1 | refs/heads/master | 2016-08-11T14:13:19.375337 | 2016-03-29T14:50:01 | 2016-03-29T14:50:01 | 44,811,060 | 3 | 2 | null | 2016-03-29T14:50:01 | 2015-10-23T12:12:42 | Protocol Buffer | UTF-8 | C++ | false | false | 831 | hpp | #include <iostream>
#include <boost/array.hpp>
#include <boost/asio.hpp>
using boost::asio::ip::udp;
class UDPClient
{
public:
UDPClient(
boost::asio::io_service& io_service,
const std::string& host,
const std::string& port
) : io_service_(io_service), socket_(io_service, udp::endpoint(udp::v4(), 0))
{
udp::resolver resolver(io_service_);
udp::resolver::query query(udp::v4(), host, port);
udp::resolver::iterator iter = resolver.resolve(query);
endpoint_ = *iter;
}
~UDPClient()
{
socket_.close();
}
void send(const uint8_t *msg, uint32_t len) {
socket_.send_to(boost::asio::buffer(msg, len), endpoint_);
}
private:
boost::asio::io_service& io_service_;
udp::socket socket_;
udp::endpoint endpoint_;
};
| [
"missrisalaheddine@gmail.com"
] | missrisalaheddine@gmail.com |
b132345d5e389e224bf3590db0fa25750583f8e7 | affbe202218f92bb908ea32bf0fdfde7528df065 | /LeetCode 100 Same Tree.cpp | 00cb551198bec38fdec84cdea424e1c60e4a4159 | [] | no_license | GengchenXU/LeetCode-2 | fddc92f8d230da6f3e860dd103cf34e187832ec0 | 431f7f9cc6dac91b9cccf853906e91ba2f7892d4 | refs/heads/master | 2020-12-21T02:32:08.446814 | 2019-12-22T14:14:57 | 2019-12-22T14:14:57 | 236,279,461 | 1 | 0 | null | 2020-01-26T07:12:31 | 2020-01-26T07:12:30 | null | UTF-8 | C++ | false | false | 486 | cpp | // LeetCode 100 Same Tree.cpp
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
bool isSameTree(TreeNode* p, TreeNode* q) {
if (!p) return !q;
if (!q) return !p;
return p->val == q->val &&
isSameTree(p->left, q->left) &&
isSameTree(p->right, q->right);
}
}; | [
"gremist@163.com"
] | gremist@163.com |
bb390815f0f021d9c6daeb043c100b12ff6fe5a4 | 1041010e246e5b82cda964553dcdf6346fdcbb05 | /Sumita and equal array.cpp | 4b08b765bb1b1bac6c4282a1c24e0ac2dd146915 | [] | no_license | guptaa98/HackerEarth | a754fcfb6bbaa60f5189ab90aaf40aac3af88d60 | 7faa54ab7f69aae63433f8021bbda755c16fc765 | refs/heads/master | 2023-01-19T10:58:30.845832 | 2020-10-25T17:30:53 | 2020-10-25T17:30:53 | 277,335,305 | 0 | 0 | null | 2020-08-26T12:30:45 | 2020-07-05T15:57:27 | C++ | UTF-8 | C++ | false | false | 769 | cpp | #include<bits/stdc++.h>
using namespace std;
int main()
{
int t,n,x,y,z,i;
cin>>t;
while(t--)
{
cin>>n>>x>>y>>z;
vector<long int>a;
long int num;
for(i=0;i<n;i++)
{
cin>>num;
a.push_back(num);
}
for(i=0;i<n;i++)
{
while(a[i]%x==0)
{
a[i]/=x;
}
while(a[i]%y==0)
{
a[i]/=y;
}
while(a[i]%z==0)
{
a[i]/=z;
}
if(a[i]!=a[0])
{
cout<<"She can't"<<endl;
break;
}
}
if(i==n)
{
cout<<"She can"<<endl;
}
}
}
| [
"noreply@github.com"
] | noreply@github.com |
55d4dabadf267c3211d6ff82038b7edc74c1d97c | 2748d0af8c89e0975bdfde2a24b5e567bfcac0ab | /motion_control/Control_Interface.cpp | 0ce43b52b6035450a45085b664965fc10f8188b0 | [] | no_license | shenglixu/golems | 184384574958112690719c9295e9c08b75ccb093 | ae516ce6d70cfd07e8806f243686536ca42d662d | refs/heads/master | 2021-01-22T21:37:32.705276 | 2016-11-14T23:44:29 | 2016-11-14T23:44:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,527 | cpp | /**
* @function Control_Interface.cpp
*/
#include "Control_Interface.h"
/**
* @function Control_Interface
* @brief Constructor
*/
Control_Interface::Control_Interface() {
mVALID_NS = (int64_t)((1000000000)/5);
}
/**
* @function Control_Interface
* @brief Destructor
*/
Control_Interface::~Control_Interface() {
}
/**
* @function set_numJoints
* @brief Set number of drives in the message
*/
void Control_Interface::set_numJoints( int _N ) {
mN = _N;
mq.resize( mN );
mdq.resize( mN );
}
/**
* @function set_channels
*/
void Control_Interface::set_channels( ach_channel_t* _chan_state,
ach_channel_t* _chan_output ) {
mChan_state = _chan_state;
mChan_output = _chan_output;
}
/**
* @function update
*/
bool Control_Interface::update() {
if( clock_gettime( ACH_DEFAULT_CLOCK, &mNow ) ) {
SNS_LOG( LOG_ERR, "clock_gettime failed: '%s' \n", strerror(errno) );
return false;
}
struct timespec timeout = sns_time_add_ns( mNow, 1000*1000*1 );
return update_n( mN,
mq, mdq, mChan_state, &timeout );
}
/**
* @function get_state
*/
bool Control_Interface::get_state( Eigen::VectorXd &_q,
Eigen::VectorXd &_dq ) {
// while( !this->update() ) {}
this->update(); // CHANGE ONLY MONDAY TO DEBUG IK ISSUE
_q = mq;
_dq = mdq;
return true;
}
////////////////////////////////////////////////////
/**
* @function update_n
* @brief
*/
bool Control_Interface::update_n( size_t n,
Eigen::VectorXd &_q,
Eigen::VectorXd &_dq,
ach_channel_t* chan,
struct timespec *ts ) {
size_t frame_size;
void* buf = NULL;
ach_status_t r = sns_msg_local_get( chan, &buf,
&frame_size,
ts,
ACH_O_LAST | (ts ? ACH_O_WAIT|ACH_O_ABSTIME : 0) );
switch(r) {
case ACH_OK:
case ACH_MISSED_FRAME: {
struct sns_msg_motor_state *msg = (struct sns_msg_motor_state*) buf;
if( n == msg->header.n &&
frame_size == sns_msg_motor_state_size_n((uint32_t)n) ) {
for( size_t j = 0; j < n; ++j ) {
_q(j) = msg->X[j].pos;
_dq(j) = msg->X[j].vel;
}
return true;
} else {
SNS_LOG( LOG_ERR, "[update_n] Invalid motor_state \n" );
return false;
}
} break;
case ACH_TIMEOUT:
case ACH_STALE_FRAMES:
case ACH_CANCELED:
break;
default:
SNS_LOG( LOG_ERR, "Failed ach_get: %s \n", ach_result_to_string(r) );
} // end switch
return false;
}
/**
* @function control_n
*/
bool Control_Interface::control_n( size_t n,
const Eigen::VectorXd &_x,
double tsec,
ach_channel_t* chan,
int mode ) {
// Safety check
if( _x.size() != n ) {
printf("\t [control_n] Size of control vector is diff than expected \n");
return false;
}
// Create the message
struct sns_msg_motor_ref* msg = sns_msg_motor_ref_local_alloc( n );
sns_msg_header_fill( &msg->header );
switch( mode ) {
case SNS_MOTOR_MODE_POS:
msg->mode = SNS_MOTOR_MODE_POS;
break;
case SNS_MOTOR_MODE_VEL:
msg->mode = SNS_MOTOR_MODE_VEL;
break;
default:
return false;
}
msg->header.n = n;
AA_MEM_CPY( msg->u, _x.data(), n );
// Set time duration
if( clock_gettime( ACH_DEFAULT_CLOCK, &mNow ) ) {
SNS_LOG( LOG_ERR, "Clock_gettime failed: %s \n", strerror(errno) );
}
sns_msg_set_time( &msg->header, &mNow, mVALID_NS ); // mVALID_NS value taken from piranha/src/pirctrl.c
// Send
ach_status_t r;
r = ach_put( chan, msg, sns_msg_motor_ref_size(msg) );
return (r == ACH_OK);
}
| [
"ahuaman3@gatech.edu"
] | ahuaman3@gatech.edu |
bcaaadc91d50a39adabfda50f58cedcb3c4ae3cb | 43c798c3cf8b5d6c96f594f865f4787dfcbf282f | /src/cube.cpp | 428c69883b938354603a068b79f4f810b29055f9 | [] | no_license | snakes10/sickle | 7a2926b7a9a57c510fffa8c405018d36d45e6376 | 4a4e068d1885aab03912cfcf1a12c8fbaf428ff9 | refs/heads/master | 2021-05-29T17:44:53.853856 | 2015-06-15T13:12:06 | 2015-06-15T13:12:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,347 | cpp | // Copyright 2015 PsychoLama
#include <cube.hpp>
#include <vector>
template<>
int Cube::tBase::s_instances = 0;
Cube::Cube(QObject* parent) : Geometry(parent) {
setObjectName(QString(tr("Cube %1")).arg(Cube::tBase::s_instances));
colors({
QColor(255, 0, 0),
QColor(255, 255, 0),
QColor(0, 255, 0),
QColor(0, 255, 255),
QColor(0, 0, 255),
QColor(255, 0, 255)
});
}
QVector<GLfloat> calcCubeUVs() {
QVector<GLfloat> UVs;
UVs.reserve(6 * 4 * 2);
for (int face = 0; face < 6; face++) {
UVs.append(0.0f); UVs.append(0.0f);
UVs.append(0.0f); UVs.append(1.0f);
UVs.append(1.0f); UVs.append(1.0f);
UVs.append(1.0f); UVs.append(0.0f);
}
return UVs;
}
QVector<GLfloat> calcCubeColors() {
QVector<GLfloat> colors;
colors.reserve(6 * 4);
for (GLfloat face = 0; face < 6; face++) for (int vert = 0; vert < 4; vert++) {
colors.append(face);
}
return colors;
}
QVector<quint32> calcCubeIndices() {
QVector<quint32> indices;
indices.reserve(6 * 2 * 3);
for (GLfloat face = 0; face < 6; face++) {
GLfloat f = face * 4;
indices.append(f + 0);
indices.append(f + 1);
indices.append(f + 3);
indices.append(f + 3);
indices.append(f + 1);
indices.append(f + 2);
}
return indices;
}
template<>
QOpenGLVertexArrayObject* Cube::tBase::s_vao = nullptr;
template<>
ProgramList Cube::tBase::s_programList = {};
template<>
QHash<QString, QOpenGLBuffer*> Cube::tBase::s_buffers = {};
template<>
QVector<quint32> Cube::tBase::s_indexBuffer = calcCubeIndices();
template<>
QHash<QString, QVector<GLfloat>> Cube::tBase::s_buffersData = {
{"Position", {
-1.0f, -1.0f, -1.0f, // Face 1
-1.0f, -1.0f, 1.0f, //
-1.0f, 1.0f, 1.0f, //
-1.0f, 1.0f, -1.0f, //
1.0f, -1.0f, -1.0f, // Face 2
1.0f, 1.0f, -1.0f, //
1.0f, 1.0f, 1.0f, //
1.0f, -1.0f, 1.0f, //
-1.0f, -1.0f, -1.0f, // Face 3
1.0f, -1.0f, -1.0f, //
1.0f, -1.0f, 1.0f, //
-1.0f, -1.0f, 1.0f, //
-1.0f, 1.0f, -1.0f, // Face 4
-1.0f, 1.0f, 1.0f, //
1.0f, 1.0f, 1.0f, //
1.0f, 1.0f, -1.0f, //
-1.0f, -1.0f, -1.0f, // Face 5
-1.0f, 1.0f, -1.0f, //
1.0f, 1.0f, -1.0f, //
1.0f, -1.0f, -1.0f, //
-1.0f, -1.0f, 1.0f, // Face 6
1.0f, -1.0f, 1.0f, //
1.0f, 1.0f, 1.0f, //
-1.0f, 1.0f, 1.0f, //
}},
{"Color", calcCubeColors()},
{"UV", calcCubeUVs()}
};
| [
"leopaul3@gmail.com"
] | leopaul3@gmail.com |
c0367412386658172fe4092425010056738be6f5 | 1e17f6f0f9756d6043eb2a2d71dfd0e6c09590b2 | /périmé/scripts/pycsw/geos-3.3.3/src/operation/union/CascadedUnion.cpp | 3bd4a9befdb67112479cae3ffe95e854b3f5f76e | [
"LGPL-2.1-only",
"MIT"
] | permissive | federal-geospatial-platform/fgp-metadata-proxy | 20e300b68eedfb29eed3e1cd24a69cf3c52898c3 | 82368614a2658260c0f09a1b5d341918310626e5 | refs/heads/master | 2023-08-09T14:03:35.522230 | 2023-08-03T15:10:11 | 2023-08-03T15:10:11 | 160,414,397 | 10 | 7 | MIT | 2023-05-01T23:16:00 | 2018-12-04T20:24:01 | C++ | UTF-8 | C++ | false | false | 6,156 | cpp | /**********************************************************************
* $Id$
*
* GEOS - Geometry Engine Open Source
* http://trac.osgeo.org/geos
*
* Copyright (C) 2011 Sandro Santilli <strk@keybit.net>
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************
*
* Last port: ORIGINAL WORK, generalization of CascadedPolygonUnion
*
**********************************************************************/
#include <geos/operation/union/CascadedUnion.h>
#include <geos/geom/Geometry.h>
#include <geos/geom/GeometryFactory.h>
#include <geos/geom/Geometry.h>
#include <geos/geom/util/GeometryCombiner.h>
#include <geos/index/strtree/STRtree.h>
// std
#include <cassert>
#include <cstddef>
#include <memory>
#include <vector>
namespace geos {
namespace operation { // geos.operation
namespace geounion { // geos.operation.geounion
geom::Geometry* CascadedUnion::Union(std::vector<geom::Geometry*>* polys)
{
CascadedUnion op (polys);
return op.Union();
}
geom::Geometry* CascadedUnion::Union()
{
if (inputGeoms->empty())
return NULL;
geomFactory = inputGeoms->front()->getFactory();
/**
* A spatial index to organize the collection
* into groups of close geometries.
* This makes unioning more efficient, since vertices are more likely
* to be eliminated on each round.
*/
index::strtree::STRtree index(STRTREE_NODE_CAPACITY);
typedef std::vector<geom::Geometry*>::const_iterator iterator_type;
iterator_type end = inputGeoms->end();
for (iterator_type i = inputGeoms->begin(); i != end; ++i) {
geom::Geometry* g = *i;
index.insert(g->getEnvelopeInternal(), g);
}
std::auto_ptr<index::strtree::ItemsList> itemTree (index.itemsTree());
return unionTree(itemTree.get());
}
geom::Geometry* CascadedUnion::unionTree(
index::strtree::ItemsList* geomTree)
{
/**
* Recursively unions all subtrees in the list into single geometries.
* The result is a list of Geometry's only
*/
std::auto_ptr<GeometryListHolder> geoms(reduceToGeometries(geomTree));
return binaryUnion(geoms.get());
}
geom::Geometry* CascadedUnion::binaryUnion(GeometryListHolder* geoms)
{
return binaryUnion(geoms, 0, geoms->size());
}
geom::Geometry* CascadedUnion::binaryUnion(GeometryListHolder* geoms,
std::size_t start, std::size_t end)
{
if (end - start <= 1) {
return unionSafe(geoms->getGeometry(start), NULL);
}
else if (end - start == 2) {
return unionSafe(geoms->getGeometry(start), geoms->getGeometry(start + 1));
}
else {
// recurse on both halves of the list
std::size_t mid = (end + start) / 2;
std::auto_ptr<geom::Geometry> g0 (binaryUnion(geoms, start, mid));
std::auto_ptr<geom::Geometry> g1 (binaryUnion(geoms, mid, end));
return unionSafe(g0.get(), g1.get());
}
}
GeometryListHolder*
CascadedUnion::reduceToGeometries(index::strtree::ItemsList* geomTree)
{
std::auto_ptr<GeometryListHolder> geoms (new GeometryListHolder());
typedef index::strtree::ItemsList::iterator iterator_type;
iterator_type end = geomTree->end();
for (iterator_type i = geomTree->begin(); i != end; ++i) {
if ((*i).get_type() == index::strtree::ItemsListItem::item_is_list) {
std::auto_ptr<geom::Geometry> geom (unionTree((*i).get_itemslist()));
geoms->push_back_owned(geom.get());
geom.release();
}
else if ((*i).get_type() == index::strtree::ItemsListItem::item_is_geometry) {
geoms->push_back(reinterpret_cast<geom::Geometry*>((*i).get_geometry()));
}
else {
assert(!"should never be reached");
}
}
return geoms.release();
}
geom::Geometry*
CascadedUnion::unionSafe(geom::Geometry* g0, geom::Geometry* g1)
{
if (g0 == NULL && g1 == NULL)
return NULL;
if (g0 == NULL)
return g1->clone();
if (g1 == NULL)
return g0->clone();
return unionOptimized(g0, g1);
}
geom::Geometry*
CascadedUnion::unionOptimized(geom::Geometry* g0, geom::Geometry* g1)
{
geom::Envelope const* g0Env = g0->getEnvelopeInternal();
geom::Envelope const* g1Env = g1->getEnvelopeInternal();
if (!g0Env->intersects(g1Env))
return geom::util::GeometryCombiner::combine(g0, g1);
if (g0->getNumGeometries() <= 1 && g1->getNumGeometries() <= 1)
return unionActual(g0, g1);
geom::Envelope commonEnv;
g0Env->intersection(*g1Env, commonEnv);
return unionUsingEnvelopeIntersection(g0, g1, commonEnv);
}
geom::Geometry*
CascadedUnion::unionUsingEnvelopeIntersection(geom::Geometry* g0,
geom::Geometry* g1, geom::Envelope const& common)
{
std::vector<geom::Geometry*> disjointPolys;
std::auto_ptr<geom::Geometry> g0Int(extractByEnvelope(common, g0, disjointPolys));
std::auto_ptr<geom::Geometry> g1Int(extractByEnvelope(common, g1, disjointPolys));
std::auto_ptr<geom::Geometry> u(unionActual(g0Int.get(), g1Int.get()));
disjointPolys.push_back(u.get());
return geom::util::GeometryCombiner::combine(disjointPolys);
}
geom::Geometry*
CascadedUnion::extractByEnvelope(geom::Envelope const& env,
geom::Geometry* geom, std::vector<geom::Geometry*>& disjointGeoms)
{
std::vector<geom::Geometry*> intersectingGeoms;
for (std::size_t i = 0; i < geom->getNumGeometries(); i++) {
geom::Geometry* elem = const_cast<geom::Geometry*>(geom->getGeometryN(i));
if (elem->getEnvelopeInternal()->intersects(env))
intersectingGeoms.push_back(elem);
else
disjointGeoms.push_back(elem);
}
return geomFactory->buildGeometry(intersectingGeoms);
}
geom::Geometry*
CascadedUnion::unionActual(geom::Geometry* g0, geom::Geometry* g1)
{
return g0->Union(g1);
}
} // namespace geos.operation.union
} // namespace geos.operation
} // namespace geos
| [
"keballan@nrn.nrcan.gc.ca"
] | keballan@nrn.nrcan.gc.ca |
bf4b644e609ce399ca493c860a1a88396bc5dd75 | a7721482b639614115caf8e875afcb3dc32b4595 | /modeTutorial.h | 951ca2cdc44b62781c3b5a26f49528c2b2e062a7 | [] | no_license | nishi835/oomedama | bb6786793775e712063368eb787808a40e8bbe92 | 73b0642986b73d13dc7a992ab58fcb572a91b707 | refs/heads/master | 2020-03-27T12:07:07.396837 | 2018-08-29T01:40:46 | 2018-08-29T01:40:46 | 146,527,279 | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 1,528 | h | /*==============================================================================
modeTutorialのヘッダー [modeTutorial.h]
作成者 : 中西 祐介
作成日 :
--------------------------------------------------------------------------------
■Update :
==============================================================================*/
#ifndef _MODE_TUTORIAL_H_
#define _MODE_TUTORIAL_H_
/*------------------------------------------------------------------------------
ヘッダファイル
------------------------------------------------------------------------------*/
#include "mode.h"
#include "background.h"
/*------------------------------------------------------------------------------
マクロ定義
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
クラス
------------------------------------------------------------------------------*/
class CModeTutorial: public CMode
{
public:
CModeTutorial() {};
~CModeTutorial() ;
void Init( void)override;
void Uninit( void )override;
void Update( void )override;
void Draw( void )override;
// ゲッター
// その他のメソッド
private:
// オブジェクト
static CBackground* m_background;
// その他
int m_page; // ページ数
};
#endif | [
"noreply@github.com"
] | noreply@github.com |
aefbfbf9d21ca0c63b17271b1d9485513f23162e | cb5b061a07eaaaef65aaf674a82d82fbb4eea0c0 | /depends/sdk/include/nsIScrollable.h | acf5cafde0e704623b1b1fdf906505a2d87d9d25 | [] | no_license | shwneo/MonacoIDE | 5a5831a1553b2af10844aa5649e302c701fd4fb4 | 6d5d08733c2f144d60abc4aeb7b6a1a3d5e349d5 | refs/heads/master | 2016-09-06T07:34:03.315445 | 2014-06-01T15:06:34 | 2014-06-01T15:06:34 | 17,567,104 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,768 | h | /*
* DO NOT EDIT. THIS FILE IS GENERATED FROM d:/xulrunner-24.0.source/mozilla-release/docshell/base/nsIScrollable.idl
*/
#ifndef __gen_nsIScrollable_h__
#define __gen_nsIScrollable_h__
#ifndef __gen_nsISupports_h__
#include "nsISupports.h"
#endif
/* For IDL files that don't want to include root IDL files. */
#ifndef NS_NO_VTABLE
#define NS_NO_VTABLE
#endif
/* starting interface: nsIScrollable */
#define NS_ISCROLLABLE_IID_STR "919e792a-6490-40b8-bba5-f9e9ad5640c8"
#define NS_ISCROLLABLE_IID \
{0x919e792a, 0x6490, 0x40b8, \
{ 0xbb, 0xa5, 0xf9, 0xe9, 0xad, 0x56, 0x40, 0xc8 }}
class NS_NO_VTABLE nsIScrollable : public nsISupports {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISCROLLABLE_IID)
enum {
ScrollOrientation_X = 1,
ScrollOrientation_Y = 2
};
/* long getCurScrollPos (in long scrollOrientation); */
NS_IMETHOD GetCurScrollPos(int32_t scrollOrientation, int32_t *_retval) = 0;
/* void setCurScrollPos (in long scrollOrientation, in long curPos); */
NS_IMETHOD SetCurScrollPos(int32_t scrollOrientation, int32_t curPos) = 0;
/* void setCurScrollPosEx (in long curHorizontalPos, in long curVerticalPos); */
NS_IMETHOD SetCurScrollPosEx(int32_t curHorizontalPos, int32_t curVerticalPos) = 0;
/* void getScrollRange (in long scrollOrientation, out long minPos, out long maxPos); */
NS_IMETHOD GetScrollRange(int32_t scrollOrientation, int32_t *minPos, int32_t *maxPos) = 0;
/* void setScrollRange (in long scrollOrientation, in long minPos, in long maxPos); */
NS_IMETHOD SetScrollRange(int32_t scrollOrientation, int32_t minPos, int32_t maxPos) = 0;
/* void setScrollRangeEx (in long minHorizontalPos, in long maxHorizontalPos, in long minVerticalPos, in long maxVerticalPos); */
NS_IMETHOD SetScrollRangeEx(int32_t minHorizontalPos, int32_t maxHorizontalPos, int32_t minVerticalPos, int32_t maxVerticalPos) = 0;
enum {
Scrollbar_Auto = 1,
Scrollbar_Never = 2,
Scrollbar_Always = 3
};
/* long getDefaultScrollbarPreferences (in long scrollOrientation); */
NS_IMETHOD GetDefaultScrollbarPreferences(int32_t scrollOrientation, int32_t *_retval) = 0;
/* void setDefaultScrollbarPreferences (in long scrollOrientation, in long scrollbarPref); */
NS_IMETHOD SetDefaultScrollbarPreferences(int32_t scrollOrientation, int32_t scrollbarPref) = 0;
/* void getScrollbarVisibility (out boolean verticalVisible, out boolean horizontalVisible); */
NS_IMETHOD GetScrollbarVisibility(bool *verticalVisible, bool *horizontalVisible) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIScrollable, NS_ISCROLLABLE_IID)
/* Use this macro when declaring classes that implement this interface. */
#define NS_DECL_NSISCROLLABLE \
NS_IMETHOD GetCurScrollPos(int32_t scrollOrientation, int32_t *_retval); \
NS_IMETHOD SetCurScrollPos(int32_t scrollOrientation, int32_t curPos); \
NS_IMETHOD SetCurScrollPosEx(int32_t curHorizontalPos, int32_t curVerticalPos); \
NS_IMETHOD GetScrollRange(int32_t scrollOrientation, int32_t *minPos, int32_t *maxPos); \
NS_IMETHOD SetScrollRange(int32_t scrollOrientation, int32_t minPos, int32_t maxPos); \
NS_IMETHOD SetScrollRangeEx(int32_t minHorizontalPos, int32_t maxHorizontalPos, int32_t minVerticalPos, int32_t maxVerticalPos); \
NS_IMETHOD GetDefaultScrollbarPreferences(int32_t scrollOrientation, int32_t *_retval); \
NS_IMETHOD SetDefaultScrollbarPreferences(int32_t scrollOrientation, int32_t scrollbarPref); \
NS_IMETHOD GetScrollbarVisibility(bool *verticalVisible, bool *horizontalVisible);
/* Use this macro to declare functions that forward the behavior of this interface to another object. */
#define NS_FORWARD_NSISCROLLABLE(_to) \
NS_IMETHOD GetCurScrollPos(int32_t scrollOrientation, int32_t *_retval) { return _to GetCurScrollPos(scrollOrientation, _retval); } \
NS_IMETHOD SetCurScrollPos(int32_t scrollOrientation, int32_t curPos) { return _to SetCurScrollPos(scrollOrientation, curPos); } \
NS_IMETHOD SetCurScrollPosEx(int32_t curHorizontalPos, int32_t curVerticalPos) { return _to SetCurScrollPosEx(curHorizontalPos, curVerticalPos); } \
NS_IMETHOD GetScrollRange(int32_t scrollOrientation, int32_t *minPos, int32_t *maxPos) { return _to GetScrollRange(scrollOrientation, minPos, maxPos); } \
NS_IMETHOD SetScrollRange(int32_t scrollOrientation, int32_t minPos, int32_t maxPos) { return _to SetScrollRange(scrollOrientation, minPos, maxPos); } \
NS_IMETHOD SetScrollRangeEx(int32_t minHorizontalPos, int32_t maxHorizontalPos, int32_t minVerticalPos, int32_t maxVerticalPos) { return _to SetScrollRangeEx(minHorizontalPos, maxHorizontalPos, minVerticalPos, maxVerticalPos); } \
NS_IMETHOD GetDefaultScrollbarPreferences(int32_t scrollOrientation, int32_t *_retval) { return _to GetDefaultScrollbarPreferences(scrollOrientation, _retval); } \
NS_IMETHOD SetDefaultScrollbarPreferences(int32_t scrollOrientation, int32_t scrollbarPref) { return _to SetDefaultScrollbarPreferences(scrollOrientation, scrollbarPref); } \
NS_IMETHOD GetScrollbarVisibility(bool *verticalVisible, bool *horizontalVisible) { return _to GetScrollbarVisibility(verticalVisible, horizontalVisible); }
/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
#define NS_FORWARD_SAFE_NSISCROLLABLE(_to) \
NS_IMETHOD GetCurScrollPos(int32_t scrollOrientation, int32_t *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetCurScrollPos(scrollOrientation, _retval); } \
NS_IMETHOD SetCurScrollPos(int32_t scrollOrientation, int32_t curPos) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetCurScrollPos(scrollOrientation, curPos); } \
NS_IMETHOD SetCurScrollPosEx(int32_t curHorizontalPos, int32_t curVerticalPos) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetCurScrollPosEx(curHorizontalPos, curVerticalPos); } \
NS_IMETHOD GetScrollRange(int32_t scrollOrientation, int32_t *minPos, int32_t *maxPos) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetScrollRange(scrollOrientation, minPos, maxPos); } \
NS_IMETHOD SetScrollRange(int32_t scrollOrientation, int32_t minPos, int32_t maxPos) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetScrollRange(scrollOrientation, minPos, maxPos); } \
NS_IMETHOD SetScrollRangeEx(int32_t minHorizontalPos, int32_t maxHorizontalPos, int32_t minVerticalPos, int32_t maxVerticalPos) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetScrollRangeEx(minHorizontalPos, maxHorizontalPos, minVerticalPos, maxVerticalPos); } \
NS_IMETHOD GetDefaultScrollbarPreferences(int32_t scrollOrientation, int32_t *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetDefaultScrollbarPreferences(scrollOrientation, _retval); } \
NS_IMETHOD SetDefaultScrollbarPreferences(int32_t scrollOrientation, int32_t scrollbarPref) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetDefaultScrollbarPreferences(scrollOrientation, scrollbarPref); } \
NS_IMETHOD GetScrollbarVisibility(bool *verticalVisible, bool *horizontalVisible) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetScrollbarVisibility(verticalVisible, horizontalVisible); }
#if 0
/* Use the code below as a template for the implementation class for this interface. */
/* Header file */
class nsScrollable : public nsIScrollable
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISCROLLABLE
nsScrollable();
private:
~nsScrollable();
protected:
/* additional members */
};
/* Implementation file */
NS_IMPL_ISUPPORTS1(nsScrollable, nsIScrollable)
nsScrollable::nsScrollable()
{
/* member initializers and constructor code */
}
nsScrollable::~nsScrollable()
{
/* destructor code */
}
/* long getCurScrollPos (in long scrollOrientation); */
NS_IMETHODIMP nsScrollable::GetCurScrollPos(int32_t scrollOrientation, int32_t *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void setCurScrollPos (in long scrollOrientation, in long curPos); */
NS_IMETHODIMP nsScrollable::SetCurScrollPos(int32_t scrollOrientation, int32_t curPos)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void setCurScrollPosEx (in long curHorizontalPos, in long curVerticalPos); */
NS_IMETHODIMP nsScrollable::SetCurScrollPosEx(int32_t curHorizontalPos, int32_t curVerticalPos)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void getScrollRange (in long scrollOrientation, out long minPos, out long maxPos); */
NS_IMETHODIMP nsScrollable::GetScrollRange(int32_t scrollOrientation, int32_t *minPos, int32_t *maxPos)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void setScrollRange (in long scrollOrientation, in long minPos, in long maxPos); */
NS_IMETHODIMP nsScrollable::SetScrollRange(int32_t scrollOrientation, int32_t minPos, int32_t maxPos)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void setScrollRangeEx (in long minHorizontalPos, in long maxHorizontalPos, in long minVerticalPos, in long maxVerticalPos); */
NS_IMETHODIMP nsScrollable::SetScrollRangeEx(int32_t minHorizontalPos, int32_t maxHorizontalPos, int32_t minVerticalPos, int32_t maxVerticalPos)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* long getDefaultScrollbarPreferences (in long scrollOrientation); */
NS_IMETHODIMP nsScrollable::GetDefaultScrollbarPreferences(int32_t scrollOrientation, int32_t *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void setDefaultScrollbarPreferences (in long scrollOrientation, in long scrollbarPref); */
NS_IMETHODIMP nsScrollable::SetDefaultScrollbarPreferences(int32_t scrollOrientation, int32_t scrollbarPref)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void getScrollbarVisibility (out boolean verticalVisible, out boolean horizontalVisible); */
NS_IMETHODIMP nsScrollable::GetScrollbarVisibility(bool *verticalVisible, bool *horizontalVisible)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* End of implementation class template. */
#endif
#endif /* __gen_nsIScrollable_h__ */
| [
"shwneo@gmail.com"
] | shwneo@gmail.com |
938e562bfdc5342fc28b5c768083f1722d0e52ae | 61418f2d5ad2a04ac6dfa585d2407c5ae218a836 | /include/vsg/commands/ResolveImage.h | 5132806dfb2cea35a66960753ffe2d4fa7f53f67 | [
"MIT",
"Apache-2.0"
] | permissive | vsg-dev/VulkanSceneGraph | e6840572c6b141671f64525c37cf6929ed9fceb7 | 62b2e8e5b6886be486d5d5002b8ff7f89be089e8 | refs/heads/master | 2023-09-04T09:41:54.342443 | 2023-09-03T09:22:09 | 2023-09-03T09:22:09 | 148,609,004 | 962 | 190 | MIT | 2023-09-10T15:38:12 | 2018-09-13T08:43:58 | C++ | UTF-8 | C++ | false | false | 1,721 | h | #pragma once
/* <editor-fold desc="MIT License">
Copyright(c) 2022 Robert Osfield
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
</editor-fold> */
#include <vsg/commands/Command.h>
#include <vsg/state/Image.h>
namespace vsg
{
/// ResolveImage command encapsulates vkCmdResolveImage functionality
class VSG_DECLSPEC ResolveImage : public Inherit<Command, ResolveImage>
{
public:
ResolveImage();
ref_ptr<Image> srcImage;
VkImageLayout srcImageLayout;
ref_ptr<Image> dstImage;
VkImageLayout dstImageLayout;
std::vector<VkImageResolve> regions;
void record(CommandBuffer& commandBuffer) const override;
};
VSG_type_name(vsg::ResolveImage);
} // namespace vsg
| [
"robert@openscenegraph.com"
] | robert@openscenegraph.com |
52d1f26451a7a8bad1dc153424357655c80563a1 | ea6686aebeecf8c77b60900dbf51ddb93ab4144b | /language/c/test_libevent/lib/include/log4cplus/helpers/stringhelper.h | fd8146896ea9df9262d2f931f0c31955047d7f6d | [] | no_license | fcgll520/feelc | 74f907112df51bfa8141662c61ca13fef6a70424 | c355eddb207173e8d4a35e0239fa103f59eccc16 | refs/heads/master | 2020-06-23T05:27:45.529030 | 2018-09-21T09:28:54 | 2018-09-21T09:28:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,649 | h | // Module: Log4CPLUS
// File: stringhelper.h
// Created: 3/2003
// Author: Tad E. Smith
//
//
// Copyright (C) Tad E. Smith All rights reserved.
//
// This software is published under the terms of the Apache Software
// License version 1.1, a copy of which has been included with this
// distribution in the LICENSE.APL file.
//
/** @file */
#ifndef LOG4CPLUS_HELPERS_STRINGHELPER_HEADER_
#define LOG4CPLUS_HELPERS_STRINGHELPER_HEADER_
#include <log4cplus/config.h>
#include <log4cplus/tstring.h>
#include <algorithm>
namespace log4cplus
{
namespace helpers
{
/**
* Returns <code>s</code> in upper case.
*/
LOG4CPLUS_EXPORT log4cplus::tstring toUpper(const log4cplus::tstring &s);
/**
* Returns <code>s</code> in lower case.
*/
LOG4CPLUS_EXPORT log4cplus::tstring toLower(const log4cplus::tstring &s);
/**
* Tokenize <code>s</code> using <code>c</code> as the delimiter and
* put the resulting tokens in <code>_result</code>. If
* <code>collapseTokens</code> is false, multiple adjacent delimiters
* will result in zero length tokens.
* <p>
* <b>Example:</b>
* <pre>
* string s = // Set string with '.' as delimiters
* list<log4cplus::tstring> tokens;
* tokenize(s, '.', back_insert_iterator<list<string> >(tokens));
* </pre>
*/
template <class _StringType, class _OutputIter>
void tokenize(const _StringType &s, typename _StringType::value_type c,
_OutputIter _result, bool collapseTokens = true)
{
_StringType tmp;
for (typename _StringType::size_type i=0; i<s.length(); ++i)
{
if (s[i] == c)
{
*_result = tmp;
++_result;
tmp.erase(tmp.begin(), tmp.end());
if (collapseTokens)
while (s[i+1] == c) ++i;
}
else
tmp += s[i];
}
if (tmp.length() > 0) *_result = tmp;
}
template<class intType>
inline tstring convertIntegerToString(intType value)
{
if (value == 0)
{
return LOG4CPLUS_TEXT("0");
}
char buffer[21];
char ret[21];
unsigned int bufferPos = 0;
unsigned int retPos = 0;
if (value < 0)
{
ret[retPos++] = '-';
}
// convert to string in reverse order
while (value != 0)
{
intType mod = value % 10;
value = value / 10;
buffer[bufferPos++] = '0' + static_cast<char>(mod);
}
// now reverse the string to get it in proper order
while (bufferPos > 0)
{
ret[retPos++] = buffer[--bufferPos];
}
ret[retPos] = 0;
return LOG4CPLUS_C_STR_TO_TSTRING(ret);
}
/**
* This iterator can be used in place of the back_insert_iterator
* for compilers that don't have a std::basic_string class that
* has the <code>push_back</code> method.
*/
template <class _Container>
class string_append_iterator
{
protected:
_Container *container;
public:
typedef _Container container_type;
typedef void value_type;
typedef void difference_type;
typedef void pointer;
typedef void reference;
explicit string_append_iterator(_Container &__x) : container(&__x) {}
string_append_iterator<_Container> &
operator=(const typename _Container::value_type &__value)
{
*container += __value;
return *this;
}
string_append_iterator<_Container> &operator*()
{
return *this;
}
string_append_iterator<_Container> &operator++()
{
return *this;
}
string_append_iterator<_Container> &operator++(int)
{
return *this;
}
};
}
}
#endif // LOG4CPLUS_HELPERS_STRINGHELPER_HEADER_
| [
"634609116@qq.com"
] | 634609116@qq.com |
cced20082c49b79146558c21c38e6e17d05a7bd4 | 1615473750aa2cbeb260657c220ae9d3ebfbbed4 | /AB抓抓/stdafx.cpp | b825cd24b3c0dfc7e52398b3affc812256ac3030 | [] | no_license | JohnWilliam1988/AB | dd22ec68d23ccf36ef72232969625e0ca100b360 | 6d5429f1dbb237ae50fa603458667cb1a200b385 | refs/heads/master | 2021-01-10T16:36:46.498798 | 2015-06-05T08:08:09 | 2015-06-05T08:08:09 | 36,920,511 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 163 | cpp |
// stdafx.cpp : 只包括标准包含文件的源文件
// AB抓抓.pch 将作为预编译头
// stdafx.obj 将包含预编译类型信息
#include "stdafx.h"
| [
"johnwilliam@126.com"
] | johnwilliam@126.com |
a17f50da893eb18fa79dd79a624e30d22d9d02a9 | 3da0b0276bc8c3d7d1bcdbabfb0e763a38d3a24c | /zju.finished/2511.cpp | 095f4581d5f7fdfe04c60d69117d355d019c9be8 | [] | no_license | usherfu/zoj | 4af6de9798bcb0ffa9dbb7f773b903f630e06617 | 8bb41d209b54292d6f596c5be55babd781610a52 | refs/heads/master | 2021-05-28T11:21:55.965737 | 2009-12-15T07:58:33 | 2009-12-15T07:58:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,039 | cpp | #include<iostream>
#include<cmath>
#include<vector>
using namespace std;
const double eps = 1e-8;
struct Node {
int no;
double score;
bool operator < (const Node&rhs) const {
if( fabs(score - rhs.score) < eps)
return no < rhs.no;
return score > rhs.score;
}
};
struct cmp{
bool operator()(const Node&lhs, const Node&rhs)const {
return lhs.no > rhs.no;
}
};
int N,M,K;
vector<Node> t;
void fun(){
t.reserve(M);
for(int i=0;i<M;i++){
t[i].no = i + 1;
t[i].score = 0;
}
double s;
for(int i=0;i<N;i++){
for(int j=0;j<M;j++){
scanf("%lf",&s);
t[j].score += s;
}
}
sort(t.begin(), t.begin() + M);
sort(t.begin(), t.begin() + K, cmp());
for(int i=0;i<K;i++){
if(i==0){
printf("%d", t[i].no);
} else {
printf(" %d", t[i].no);
}
}
printf("\n");
}
int main(){
while(scanf("%d%d%d",&N,&M,&K) > 0){
fun();
}
return 0;
}
| [
"zhouweikuan@gmail.com"
] | zhouweikuan@gmail.com |
49df61653954fff6484fe3d7ea5f9272d77dab13 | a2727d3a354c96c8e3e09330b2c6ab4f2a8b5037 | /General/include/biomes/TestBiome.hpp | f1b46151091c1ce3fa780f3d47890438ee328aed | [] | no_license | Unrealf1/FreeFlight | e9f53e934c455ca3cf054043e8bf8108e582bd45 | 0656906eeeeeccc47c3f1d439c474429055097fc | refs/heads/master | 2023-07-18T04:23:51.835305 | 2021-09-04T10:31:56 | 2021-09-04T10:31:56 | 369,233,037 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,441 | hpp | #pragma once
#include "biomes/Biome.hpp"
#include "biomes/simplexnoise1234.h"
#include "render/TextureContainer.hpp"
#include <spdlog/spdlog.h>
#include <fmt/core.h>
class TestBiome: public Biome {
public:
TestBiome(const char* texname = "resources/textures/grass3.jpg") {
glGenSamplers(1, &_sampler);
glSamplerParameterf(_sampler, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
glSamplerParameterf(_sampler, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
_texture = TextureContainer::getTexture(texname);
_texHandle = TexHandleContainer::createHandle(_texture, _sampler);
glMakeTextureHandleResidentARB(_texHandle);
}
void generateVertices(TerrainChunk::vertexMap_t& vertices, const glm::vec2& near_left, float step, const std::vector<std::vector<BiomeCenter>>&) override {
std::vector<std::vector<float>> heights;
heights.resize(vertices.size());
for (size_t i = 0; i < vertices.size(); ++i) {
heights[i].resize(vertices[i].size());
}
generateHeightsLinear(heights, near_left, step);
for (size_t i = 0; i < vertices.size(); ++i) {
for (size_t j = 0; j < vertices[i].size(); ++j) {
vertices[i][j].height = heights[i][j];
vertices[i][j].texture_handler = _texHandle;
}
}
}
GLuint getTexture() {
return 0;
}
biomeId_t getId() {
return BiomeId::Test;
}
std::string name() {
return "test_biome";
}
private:
GLuint _sampler;
GLuint _texture;
GLuint64 _texHandle;
void generateHeightsNoise(std::vector<std::vector<float>>& heights, const glm::vec2& near_left, float step) {
float y = near_left.y;
for (auto& row : heights) {
float x = near_left.x;
for (auto& elem : row) {
elem = SimplexNoise1234::noise(0.0008f * x, 0.0008f * y) * 10.0f;
//elem += std::sin(0.001f * x) / 2.0f;
elem += SimplexNoise1234::noise(0.008f * (x + 777.0f), 0.008f * (y + 12345.0f)) * 5.0f;;
x += step;
}
y += step;
}
}
void generateHeightsFlat(std::vector<std::vector<float>>& heights, const glm::vec2&, float) {
for (auto& row : heights) {
for (auto& elem : row) {
elem = 0.0f;
}
}
}
void generateHeightsLinear(std::vector<std::vector<float>>& heights, const glm::vec2& near_left, float step) {
float y = near_left.y;
float alpha = 0.1f;
for (auto& row : heights) {
float x = near_left.x;
for (auto& elem : row) {
elem = (y) * alpha;
fmt::print("{} ({}, {}), ", elem, x, y);
x += step;
}
y += step;
fmt::print("\n");
}
spdlog::debug("near left is {} {}", near_left.x, near_left.y);
spdlog::debug("step is {}, size is {}", step, heights.size());
}
void generateHeightsSin(std::vector<std::vector<float>>& heights, const glm::vec2& near_left, float step) {
float y = near_left.y;
for (auto& row : heights) {
float x = near_left.x;
for (auto& elem : row) {
elem = std::sin(x) + std::cos(y * 0.001f);
x += step;
}
y += step;
}
}
}; | [
"fyodor.bukreev@yandex.ru"
] | fyodor.bukreev@yandex.ru |
c393f8cf2d5e0fb628edba91ffda891e55f2ee3f | 8e9e8d1273438e38271b4b55e87be7b91a657c5f | /src/server/scripts/EasternKingdoms/Stratholme/boss_postmaster_malown.cpp | 7fa04d693752492f105ed68a4493003200e5c8f0 | [] | no_license | kmN666/Leroy | 43df8105252851e4e756cf36e02e0ffd674cce15 | 189c990d7227d0aa4ad21f20c319d49ccaeb262e | refs/heads/master | 2020-12-24T15:23:25.403594 | 2012-08-01T08:42:58 | 2012-08-01T08:42:58 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,701 | cpp | /*
* Copyright (C) 2012 DeadCore <https://bitbucket.org/jacobcore/deadcore>
* Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* ScriptData
SDName: boss_postmaster_malown
SD%Complete: 50
SDComment:
SDCategory: Stratholme
EndScriptData */
#include "ScriptPCH.h"
//Spell ID to summon this guy is 24627 "Summon Postmaster Malown"
//He should be spawned along with three other elites once the third postbox has been opened
#define SAY_MALOWNED "You just got MALOWNED!"
#define SPELL_WAILINGDEAD 7713
#define SPELL_BACKHAND 6253
#define SPELL_CURSEOFWEAKNESS 8552
#define SPELL_CURSEOFTONGUES 12889
#define SPELL_CALLOFTHEGRAVE 17831
class boss_postmaster_malown : public CreatureScript
{
public:
boss_postmaster_malown() : CreatureScript("boss_postmaster_malown") { }
CreatureAI* GetAI(Creature* creature) const
{
return new boss_postmaster_malownAI (creature);
}
struct boss_postmaster_malownAI : public ScriptedAI
{
boss_postmaster_malownAI(Creature* creature) : ScriptedAI(creature) {}
uint32 WailingDead_Timer;
uint32 Backhand_Timer;
uint32 CurseOfWeakness_Timer;
uint32 CurseOfTongues_Timer;
uint32 CallOfTheGrave_Timer;
bool HasYelled;
void Reset()
{
WailingDead_Timer = 19000; //lasts 6 sec
Backhand_Timer = 8000; //2 sec stun
CurseOfWeakness_Timer = 20000; //lasts 2 mins
CurseOfTongues_Timer = 22000;
CallOfTheGrave_Timer = 25000;
HasYelled = false;
}
void EnterCombat(Unit* /*who*/)
{
}
void UpdateAI(const uint32 diff)
{
//Return since we have no target
if (!UpdateVictim())
return;
//WailingDead
if (WailingDead_Timer <= diff)
{
//Cast
if (rand()%100 < 65) //65% chance to cast
{
DoCast(me->getVictim(), SPELL_WAILINGDEAD);
}
//19 seconds until we should cast this again
WailingDead_Timer = 19000;
} else WailingDead_Timer -= diff;
//Backhand
if (Backhand_Timer <= diff)
{
//Cast
if (rand()%100 < 45) //45% chance to cast
{
DoCast(me->getVictim(), SPELL_BACKHAND);
}
//8 seconds until we should cast this again
Backhand_Timer = 8000;
} else Backhand_Timer -= diff;
//CurseOfWeakness
if (CurseOfWeakness_Timer <= diff)
{
//Cast
if (rand()%100 < 3) //3% chance to cast
{
DoCast(me->getVictim(), SPELL_CURSEOFWEAKNESS);
}
//20 seconds until we should cast this again
CurseOfWeakness_Timer = 20000;
} else CurseOfWeakness_Timer -= diff;
//CurseOfTongues
if (CurseOfTongues_Timer <= diff)
{
//Cast
if (rand()%100 < 3) //3% chance to cast
{
DoCast(me->getVictim(), SPELL_CURSEOFTONGUES);
}
//22 seconds until we should cast this again
CurseOfTongues_Timer = 22000;
} else CurseOfTongues_Timer -= diff;
//CallOfTheGrave
if (CallOfTheGrave_Timer <= diff)
{
//Cast
if (rand()%100 < 5) //5% chance to cast
{
DoCast(me->getVictim(), SPELL_CALLOFTHEGRAVE);
}
//25 seconds until we should cast this again
CallOfTheGrave_Timer = 25000;
} else CallOfTheGrave_Timer -= diff;
DoMeleeAttackIfReady();
}
};
};
void AddSC_boss_postmaster_malown()
{
new boss_postmaster_malown();
}
| [
"wowall@mail.com"
] | wowall@mail.com |
74c2942f0e5e499635294967c34720ca12408bad | fb021af45d166d1e9626116fb6b511dc5047c7ca | /Bloc3/Projet/Projet.ino | 448a808d5488a3c4b7008ce07e5ed6fb1f103259 | [
"MIT"
] | permissive | MrGunnery/Helha | 9c710c90ec6048120c57c43e1ba2e607d8c3d2ac | 553a73bd95bcda6c5fd329b76b39fde2df5bfd22 | refs/heads/master | 2021-05-03T06:29:38.757957 | 2019-01-24T19:58:00 | 2019-01-24T19:58:00 | 120,595,842 | 1 | 0 | MIT | 2018-04-30T14:43:20 | 2018-02-07T09:49:42 | PHP | ISO-8859-1 | C++ | false | false | 4,216 | ino | #include <Arduino.h>
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
#include <SoftwareSerial.h>
#define MIN_PULSE_WIDTH 650
#define MAX_PULSE_WIDTH 2350
#define DEFAULT_PULSE_WIDTH 1500
#define FREQUENCY 60
// appeler de cette facon, il utiliser l'addresse par default 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
// Arduino(RX, TX) - HC-05 Bluetooth (TX, RX)
SoftwareSerial Bluetooth(3, 4);
// position courrante
int servoPos[4];
// position precedente
int servoPPos[4];
// pour enregistrement de position positions/steps
int ServoSP[4][50];
int speedDelay = 20;
int index = 0;
// initialisation de datain
String dataIn = "";
void setup() {
Serial.begin(9600);
//Serial.println("16 channel Servo test!");
Serial.println("RESET");
pinMode(7, INPUT);
pwm.begin();
// set de la frequence du controleur
pwm.setPWMFreq(FREQUENCY);
// parametrage de la comunication bleuthoot
Bluetooth.begin(9600);
Bluetooth.setTimeout(1);
delay(20);
// mise en position initial des servos
servoPPos[0] = 90;
pwm.setPWM(0, 0, pulseWidth(servoPPos[0], 0));
servoPPos[1] = 150;
pwm.setPWM(1, 0, pulseWidth(servoPPos[1], 1));
servoPPos[2] = 120;
pwm.setPWM(2, 0, pulseWidth(servoPPos[2], 2));
servoPPos[3] = 25;
pwm.setPWM(3, 0, pulseWidth(servoPPos[3], 3));
}
void loop() {
// si le capteur detecte quelque chose
if (digitalRead(7)) {
Bluetooth.print("ON");
} else {
Bluetooth.print("OFF");
}
delay(20);
// si il y a des donnée a lire
if (Bluetooth.available() > 0) {
dataIn = Bluetooth.readString();
Serial.println(dataIn);
}
// verification de la validiter des donnée et interpretarion
if (dataIn.startsWith("s")) {
String dataSer = dataIn.substring(1, 2);
int numSer = dataSer.toInt();
actionServo(numSer, dataIn);
}
// Si le bouton save est preser
if (dataIn.startsWith("SAVE")) {
for (int var = 0; var < 4; var++) {
ServoSP[var][index] = servoPPos[var];
Serial.println(servoPPos[var]);
}
index++;
}
// Si bouton run est pressé
if (dataIn.startsWith("RUN")) {
runServo(); // Mode auto
}
// Si bouton reset est pressé
if (dataIn == "RESET") {
index=0;
}
dataIn = "";
}
void runServo() {
// boucle jusqu'a reset
while (dataIn != "RESET") {
// si le capteur detecte quelque chose
if (digitalRead(7)) {
Bluetooth.print("ON");
} else {
Bluetooth.print("OFF");
}
// pour toutes les potitions sauver
for (int i = 0; i <= index - 1; i++) {
// Datain disponibble ?
if (Bluetooth.available() > 0) {
dataIn = Bluetooth.readString();
// Si bouton pause est presser
if (dataIn == "PAUSE") {
// on attent Run
while (dataIn != "RUN") {
if (Bluetooth.available() > 0) {
dataIn = Bluetooth.readString();
if (dataIn == "RESET") {
break;
}
}
}
}
// Si la vitesse est changer
if (dataIn.startsWith("ss")) {
String dataInS = dataIn.substring(2, dataIn.length());
// changer la vitesse des servos (delay time)
speedDelay = dataInS.toInt();
}
}
// actione les servos.
for (int var = 0; var < 4; var++) {
String ser = "sx";
ser+=ServoSP[var][i];
Serial.println(ser);
actionServo(var, ser);
}
}
}
}
// Actione les servos
void actionServo(int i, String dataIn) {
Serial.println(dataIn);
// recuprer seulment les nombre.
String dataInS = dataIn.substring(2, dataIn.length());
// conversion en Integer
servoPos[i] = dataInS.toInt();
if (servoPPos[i] > servoPos[i]) {
for (int j = servoPPos[i]; j >= servoPos[i]; j--) {
pwm.setPWM(i, 0, pulseWidth(j, i));
// Limite la vitesse
delay(20);
}
}
if (servoPPos[i] < servoPos[i]) {
for (int j = servoPPos[i]; j <= servoPos[i]; j++) {
pwm.setPWM(i, 0, pulseWidth(j, i));
delay(20);
}
}
servoPPos[i] = servoPos[i];
}
// converti un angle en largeur d'impultion
int pulseWidth(int angle, int i) {
int pulse_wide, analog_value;
pulse_wide = map(angle, 0, 180, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
analog_value = int(float(pulse_wide) / 1000000 * FREQUENCY * 4096);
Serial.print("Servo n°");
Serial.print(i);
Serial.print(" position ");
Serial.println(analog_value);
return analog_value;
}
| [
"noreply@github.com"
] | noreply@github.com |
ef1d19542a77002bf4c7f0167442ac190ca35a4a | 157fd7fe5e541c8ef7559b212078eb7a6dbf51c6 | /TRiAS/TRiAS/TRiAS/license.hxx | 7428dd420a3ad1603ce9495a0e0283f02ca7bb4f | [] | no_license | 15831944/TRiAS | d2bab6fd129a86fc2f06f2103d8bcd08237c49af | 840946b85dcefb34efc219446240e21f51d2c60d | refs/heads/master | 2020-09-05T05:56:39.624150 | 2012-11-11T02:24:49 | 2012-11-11T02:24:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 505 | hxx | // LizenzDialog ---------------------------------------------------------------
// File: LICENSE.HXX
#if !defined(_LICENSE_HXX)
#define _LICENSE_HXX
class CLicenseDlg : public DialogWindow {
private:
SingleLineEdit m_sleLicenseKey;
FixedText m_ftLicenseText;
PushButton m_pbOK;
protected:
void ButtonClick (ControlEvt);
void EditChange (ControlEvt);
public:
CLicenseDlg (pWindow pW, string &rStr);
~CLicenseDlg (void);
BSTR GetKey (void);
};
#endif // _LICENSE_HXX
| [
"Windows Live ID\\hkaiser@cct.lsu.edu"
] | Windows Live ID\hkaiser@cct.lsu.edu |
b1f7391a215b5391a593e5ce203f790b2d8ec67b | a8a4e8369b15971322c94c73b83a07dbe0f95739 | /Day 5/wordsubset.cpp | b540e1803146ae229975fcf1b945cde50e6e2d5f | [] | no_license | pranavnkps/Coding-Practice | 81f9ecfb63f59a5fd2cd35d809623bb09f8c1489 | cc0a420e2c5fa94e12641238f1e634ccf86c3bfe | refs/heads/master | 2022-11-25T10:42:32.249028 | 2020-07-17T15:58:51 | 2020-07-17T15:58:51 | 277,604,534 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 947 | cpp | class Solution {
public:
vector<string> wordSubsets(vector<string>& A, vector<string>& B) {
vector<string> ans;
int flag;
vector<int> count(26), temp(26);
for(string word : B){
temp = countchar(word);
for(int i = 0; i<26; i++){
count[i] = max(temp[i], count[i]);
}
}
for(string word : A){
flag = 0;
temp = countchar(word);
for(int i = 0 ; i<26; ++i){
// if(count[i] == 0)
// continue;
if(temp[i] < count[i]){
flag = 1;
break;
}
}
if(flag == 0)
ans.push_back(word);
}
return ans;
}
vector<int> countchar(string str){
vector<int> cnt(26);
for(char c : str){
cnt[c-'a']++;
}
return cnt;
}
}; | [
"pranavnkps.181co239@nitk.edu.in"
] | pranavnkps.181co239@nitk.edu.in |
a21b127e02a1c130cde060e083bd1f0f9260d4ad | ecce34d0f9babd2f9bfea3a468ae9131294e4f2b | /apps/rectangle_packing/frame_buffer.cpp | 6c329af389dcd22ec35ad9ae88bc6b3cba91bb6a | [
"BSD-3-Clause"
] | permissive | gary444/lamure | 67196ecd8042dcf59fb8919fece43d0ecb76cff7 | 0b57a70d8496cd9632873628dc4064e09c57fef7 | refs/heads/master | 2020-04-04T23:33:07.927114 | 2019-04-24T07:15:11 | 2019-04-24T07:15:11 | 156,363,664 | 0 | 0 | BSD-3-Clause | 2019-02-17T17:32:14 | 2018-11-06T10:05:31 | C++ | UTF-8 | C++ | false | false | 5,213 | cpp |
#include "frame_buffer.h"
#include <iostream>
frame_buffer_t::frame_buffer_t()
: width_(0),
height_(0),
num_buffers_(0),
format_(GL_RGBA) {
}
frame_buffer_t::frame_buffer_t(
uint32_t num_buffers,
uint32_t width,
uint32_t height,
GLenum format,
GLenum interpolation)
: width_(width),
height_(height),
num_buffers_(num_buffers),
format_(format)
{
if (num_buffers >= 16) {
std::cout << "num framebuffers must not exceed 16" << std::endl;
exit(1);
}
for (uint32_t i = 0; i < num_buffers_; ++i) {
textures_.push_back(0);
glGenTextures(1, &textures_[i]);
glBindTexture(GL_TEXTURE_2D, textures_[i]);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, format_, width_, height_, 0, format_, GL_UNSIGNED_BYTE, (void*)0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, interpolation);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, interpolation);
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_WRAP_R, GL_REPEAT);
glBindTexture(GL_TEXTURE_2D, 0);
}
glGenRenderbuffers(1, &depth_);
glBindRenderbuffer(GL_RENDERBUFFER, depth_);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width_, height_);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
glGenFramebuffers(1, &buffer_);
glBindFramebuffer(GL_FRAMEBUFFER, buffer_);
uint32_t attachment = 0x8ce0;
for (uint32_t i = 0; i < num_buffers_; i++) {
glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, textures_[i], 0);
layout_[i] = attachment;
attachment++;
}
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth_);
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
std::cout << "error during framebuffer setup" << std::endl;
exit(1);
}
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
frame_buffer_t::~frame_buffer_t()
{
for (uint32_t i = 0; i < num_buffers_; i++) {
glDeleteTextures(1, &textures_[i]);
}
glDeleteRenderbuffers(1, &depth_);
glDeleteFramebuffers(1, &buffer_);
}
void
frame_buffer_t::enable()
{
glBindFramebuffer(GL_FRAMEBUFFER, buffer_);
glDrawBuffers(num_buffers_, layout_);
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
void
frame_buffer_t::disable()
{
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
void
frame_buffer_t::bind_texture(uint32_t index)
{
if (index >= num_buffers_) {
std::cout << "frame buffer index is out of bounds" << std::endl;
exit(1);
}
glActiveTexture(GL_TEXTURE0 + index);
glBindTexture(GL_TEXTURE_2D, textures_[index]);
}
void
frame_buffer_t::unbind_texture(
uint32_t index)
{
if (index >= num_buffers_) {
std::cout << "frame buffer index is out of bounds" << std::endl;
exit(1);
}
glActiveTexture(GL_TEXTURE0 + index);
glBindTexture(GL_TEXTURE_2D, 0);
}
uint32_t
frame_buffer_t::get_width() const
{
return width_;
}
uint32_t
frame_buffer_t::get_height() const
{
return height_;
}
void
frame_buffer_t::draw(
uint32_t index)
{
if (index >= num_buffers_) {
std::cout << "frame buffer index is out of bounds" << std::endl;
exit(1);
}
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textures_[index]);
//glViewport(0, 0, width_, height_);
//glDisable(GL_DEPTH_TEST);
//glDisable(GL_LIGHTING);
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, 0.0);
glTexCoord2f(1.0, 0.0); glVertex3f(1.0, -1.0, 0.0);
glTexCoord2f(1.0, 1.0); glVertex3f(1.0, 1.0, 0.0);
glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, 0.0);
glEnd();
//glDisable(GL_TEXTURE_2D);
//glEnable(GL_DEPTH_TEST);
//glEnable(GL_LIGHTING);
glBindTexture(GL_TEXTURE_2D, 0);
}
void
frame_buffer_t::get_pixels(
uint32_t index,
char** data)
{
if (index >= num_buffers_) {
std::cout << "frame buffer index is out of bounds" << std::endl;
exit(1);
}
if (data != nullptr) {
std::cout << "data must be nullptr" << std::endl;
exit(1);
}
*data = new char[4*width_*height_];
glBindTexture(GL_TEXTURE_2D, textures_[index]);
glGetTexImage(GL_TEXTURE_2D, 0, format_, GL_UNSIGNED_BYTE, *data);
glBindTexture(GL_TEXTURE_2D, 0);
}
void
frame_buffer_t::get_pixels(
uint32_t index,
std::vector<uint8_t>& image)
{
if (index >= num_buffers_) {
std::cout << "frame buffer index is out of bounds" << std::endl;
exit(1);
}
image.clear();
image.resize(4*width_*height_);
glBindTexture(GL_TEXTURE_2D, textures_[index]);
glGetTexImage(GL_TEXTURE_2D, 0, format_, GL_UNSIGNED_BYTE, &image[0]);
glBindTexture(GL_TEXTURE_2D, 0);
}
float
frame_buffer_t::read_depth(
uint32_t x, uint32_t y)
{
float depth = 0.f;
glBindFramebuffer(GL_READ_FRAMEBUFFER, buffer_);
glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
return depth;
}
| [
"pavi3478@kronos.medien.uni-weimar.de"
] | pavi3478@kronos.medien.uni-weimar.de |
74657c76862c07c6e78fe52dc7249250307704bb | 4e21f83c79df0c8d4c8a1cf5065334131e23ae68 | /130. Surrounded Regions.cpp | 49b64a8426bc6925d88367fc309697ecfb2a9d0b | [] | no_license | ravimusunuri/leeteasy | f43263932ae7013761bf1a4d34b7e8a0bfd00171 | 9097e4da17864478b7945f16713d78643c824e30 | refs/heads/master | 2020-09-20T02:06:32.721400 | 2020-01-03T05:17:33 | 2020-01-03T05:17:33 | 224,352,926 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,739 | cpp | class Solution {
public:
void solve(vector<vector<char>>& board) {
if (board.size() == 0 || board[0].size() == 0)
return;
//left border
for (int row = 0; row < board.size(); ++row)
if (board[row][0] == 'O')
floodFill(board, row, 0, 'O', 'T');
//top border
for (int col = 1; col < board[0].size(); ++col)
if (board[0][col] == 'O')
floodFill(board, 0, col, 'O', 'T');
//right border
for (int row = 1; row < board.size(); ++row)
if (board[row][board[0].size() - 1] == 'O')
floodFill(board, row, board[0].size() - 1, 'O', 'T');
//bottom border
for (int col = 1; col < board[0].size() - 1; ++col)
if (board[board.size() - 1][col] == 'O')
floodFill(board, board.size() - 1, col, 'O', 'T');
for (int row = 0; row < board.size(); ++row)
for (int col = 0; col < board[0].size(); ++col)
{
if (board[row][col] == 'T')
board[row][col] = 'O';
else
board[row][col] = 'X';
}
}
private:
void floodFill(vector<vector<char>>& board, int row, int col, char origCh, char newCh) {
if (row < 0 || row >= board.size() || col < 0 || col >= board[0].size())
return;
if (board[row][col] != origCh)
return;
board[row][col] = newCh;
floodFill(board, row, col - 1, origCh, newCh);
floodFill(board, row - 1, col, origCh, newCh);
floodFill(board, row, col + 1, origCh, newCh);
floodFill(board, row + 1, col, origCh, newCh);
};
};
| [
"noreply@github.com"
] | noreply@github.com |
9774f2072943e16f94bdee29110b210a3090cb46 | 190e614f7722b8c95a3bb76b2f702ab55ed942e6 | /PressureEngineCore/Src/Math/Vectors/Vector4f.cpp | 0470e89db57f4bb8fe01a8dd8efb251be361e731 | [
"MIT"
] | permissive | templeblock/PressureEngine | ec11ffe99bcf5e8811fd21ec5e8bccbde4219e39 | 6b023165fcaecb267e13cf5532ea26a8da3f1450 | refs/heads/master | 2020-04-17T07:15:57.032285 | 2019-01-06T12:29:57 | 2019-01-06T12:29:57 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,742 | cpp | #include <cmath>
#include "../Math.h"
#include "Vector4f.h"
namespace Pressure {
/* CONSTRUCTORS */
Vector4f::Vector4f() : x(0.f), y(0.f), z(0.f), w(0.f) { }
Vector4f::Vector4f(float d) : x(d), y(d), z(d), w(d) { }
Vector4f::Vector4f(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) { }
Vector4f::Vector4f(const Vector2f& v, float z, float w) : x(v.getX()), y(v.getY()), z(z), w(w) { }
Vector4f::Vector4f(const Vector3f& v, float w) : x(v.getX()), y(v.getY()), z(v.getZ()), w(w) { }
/* GETTERS */
float Vector4f::getX() const {
return x;
}
float Vector4f::getY() const {
return y;
}
float Vector4f::getZ() const {
return z;
}
float Vector4f::getW() const {
return w;
}
Vector2f Vector4f::getXY() const {
return Vector2f(x, y);
}
Vector3f Vector4f::getXYZ() const {
return Vector3f(x, y, z);
}
/* SETTERS */
Vector4f& Vector4f::set(float d) {
this->x = d;
this->y = d;
this->z = d;
this->w = d;
return *this;
}
Vector4f& Vector4f::set(float x, float y, float z, float w) {
this->x = x;
this->y = y;
this->z = z;
this->w = w;
return *this;
}
Vector4f& Vector4f::set(const Vector2f& v, float x, float w) {
this->x = v.getX();
this->y = v.getY();
this->z = z;
this->w = w;
return *this;
}
Vector4f& Vector4f::set(const Vector3f& v, float w) {
this->x = v.getX();
this->y = v.getY();
this->z = v.getZ();
this->w = w;
return *this;
}
Vector4f& Vector4f::set(const Vector4f& v) {
this->x = v.getX();
this->y = v.getY();
this->z = v.getZ();
this->w = v.getW();
return *this;
}
Vector4f& Vector4f::setX(float x) {
this->x = x;
return *this;
}
Vector4f& Vector4f::setY(float y) {
this->y = y;
return *this;
}
Vector4f& Vector4f::setZ(float z) {
this->z = z;
return *this;
}
Vector4f& Vector4f::setW(float w) {
this->w = w;
return *this;
}
/* ADDITION */
Vector4f& Vector4f::add(float x, float y, float z, float w) {
this->x += x;
this->y += y;
this->z += z;
this->w += w;
return *this;
}
Vector4f& Vector4f::add(float x, float y, float z, float w, Vector4f& dest) const {
dest.x = this->x + x;
dest.y = this->y + y;
dest.z = this->z + z;
dest.w = this->w + w;
return dest;
}
Vector4f& Vector4f::add(const Vector4f& v) {
this->x += v.getX();
this->y += v.getY();
this->z += v.getZ();
this->w += v.getW();
return *this;
}
Vector4f& Vector4f::add(const Vector4f& v, Vector4f& dest) const {
dest.x = this->x + v.getX();
dest.y = this->y + v.getY();
dest.z = this->z + v.getZ();
dest.w = this->w + v.getW();
return dest;
}
/* SUBTRACTION */
Vector4f& Vector4f::sub(float x, float y, float z, float w) {
this->x -= x;
this->y -= y;
this->z -= z;
this->w -= w;
return *this;
}
Vector4f& Vector4f::sub(float x, float y, float z, float w, Vector4f& dest) const {
dest.x = this->x - x;
dest.y = this->y - y;
dest.z = this->z - z;
dest.w = this->w - w;
return dest;
}
Vector4f& Vector4f::sub(const Vector4f& v) {
this->x -= v.getX();
this->y -= v.getY();
this->z -= v.getZ();
this->w -= v.getW();
return *this;
}
Vector4f& Vector4f::sub(const Vector4f& v, Vector4f& dest) const {
dest.x = this->x - v.getX();
dest.y = this->y - v.getY();
dest.z = this->z - v.getZ();
dest.w = this->w - v.getW();
return dest;
}
/* MULTIPLICATION */
Vector4f& Vector4f::mul(float scalar) {
this->x *= scalar;
this->y *= scalar;
this->z *= scalar;
this->w *= scalar;
return *this;
}
Vector4f& Vector4f::mul(float scalar, Vector4f& dest) const {
dest.x = this->x * scalar;
dest.y = this->y * scalar;
dest.z = this->z * scalar;
dest.w = this->w * scalar;
return dest;
}
Vector4f& Vector4f::mul(float x, float y, float z, float w) {
this->x *= x;
this->y *= y;
this->z *= z;
this->w *= w;
return *this;
}
Vector4f& Vector4f::mul(float x, float y, float z, float w, Vector4f& dest) const {
dest.x = this->x * x;
dest.y = this->y * y;
dest.z = this->z * z;
dest.w = this->w * w;
return dest;
}
Vector4f& Vector4f::mul(const Vector4f& v) {
this->x *= v.getX();
this->y *= v.getY();
this->z *= v.getZ();
this->w *= v.getW();
return *this;
}
Vector4f& Vector4f::mul(const Vector4f& v, Vector4f& dest) const {
dest.x = this->x * v.getX();
dest.y = this->y * v.getY();
dest.z = this->z * v.getZ();
dest.w = this->w * v.getW();
return dest;
}
/* DIVISION */
Vector4f& Vector4f::div(float scalar) {
this->x /= scalar;
this->y /= scalar;
this->z /= scalar;
this->w /= scalar;
return *this;
}
Vector4f& Vector4f::div(float scalar, Vector4f& dest) const {
dest.x = this->x / scalar;
dest.y = this->y / scalar;
dest.z = this->z / scalar;
dest.w = this->w / scalar;
return dest;
}
Vector4f& Vector4f::div(float x, float y, float z, float w) {
this->x /= x;
this->y /= y;
this->z /= z;
this->w /= w;
return *this;
}
Vector4f& Vector4f::div(float x, float y, float z, float w, Vector4f& dest) const {
dest.x = this->x / x;
dest.y = this->y / y;
dest.z = this->z / z;
dest.w = this->w / w;
return dest;
}
Vector4f& Vector4f::div(const Vector4f& v) {
this->x /= v.getX();
this->y /= v.getY();
this->z /= v.getZ();
this->w /= v.getW();
return *this;
}
Vector4f& Vector4f::div(const Vector4f& v, Vector4f& dest) const {
dest.x = this->x / v.getX();
dest.y = this->y / v.getY();
dest.z = this->z / v.getZ();
dest.w = this->w / v.getW();
return dest;
}
/* EQUALITY CHECK */
bool Vector4f::equals(const Vector4f& v) const {
return this->x == v.getX()
&& this->y == v.getY()
&& this->z == v.getZ()
&& this->w == v.getW();
}
/* TRIGONOMETRY */
float Vector4f::length() const {
return std::sqrtf(lengthSquared());
}
float Vector4f::lengthSquared() const {
return x * x + y * y + z * z + w * w;
}
float Vector4f::distance(float x, float y, float z, float w) const {
float dx = this->x - x;
float dy = this->y - y;
float dz = this->z - z;
float dw = this->w - w;
return std::sqrtf(dx * dx + dy * dy + dz * dz + dw * dw);
}
float Vector4f::distance(const Vector4f& v) const {
float dx = v.getX() - x;
float dy = v.getY() - y;
float dz = v.getZ() - z;
float dw = v.getZ() - w;
return std::sqrtf(dx * dx + dy * dy + dz * dz + dw * dw);
}
/* VECTOR MATH */
float Vector4f::dot(float x, float y, float z, float w) const {
return this->x * x + this->y * y + this->z * z + this->w * w;
}
float Vector4f::dot(const Vector4f& v) const {
return v.getX() * x + v.getY() * y + v.getZ() * z + v.getW() * w;
}
Vector4f& Vector4f::normalize() {
float invLength = 1.f / length();
x *= invLength;
y *= invLength;
z *= invLength;
w *= invLength;
return *this;
}
Vector4f& Vector4f::normalize(Vector4f& dest) const {
float invLength = 1.f / length();
dest.x = x * invLength;
dest.y = y * invLength;
dest.z = z * invLength;
dest.w = w * invLength;
return dest;
}
Vector4f& Vector4f::normalize(float length) {
float invLength = 1.f / this->length() * length;
x *= invLength;
y *= invLength;
z *= invLength;
w *= invLength;
return *this;
}
Vector4f& Vector4f::normalize(float length, Vector4f& dest) const {
float invLength = 1.f / this->length() * length;
dest.x = x * invLength;
dest.y = y * invLength;
dest.z = z * invLength;
dest.w = w * invLength;
return dest;
}
Vector4f& Vector4f::normalize3() {
float invLength = 1.f / std::sqrtf(x * x + y * y + z * z);
x *= invLength;
y *= invLength;
z *= invLength;
w *= invLength;
return *this;
}
/* ROTATION */
Vector4f& Vector4f::rotateX(float angle) {
float sin = std::sinf(angle * 0.5f);
float cos = std::cosf(angle * 0.5f);
this->y = y * cos - z * sin;
this->z = y * sin + z * cos;
return *this;
}
Vector4f& Vector4f::rotateX(float angle, Vector4f& dest) const {
float sin = std::sinf(angle * 0.5f);
float cos = std::cosf(angle * 0.5f);
dest.x = x;
dest.y = y * cos - z * sin;
dest.z = y * sin + z * cos;
dest.w = w;
return dest;
}
Vector4f& Vector4f::rotateY(float angle) {
float sin = std::sinf(angle * 0.5f);
float cos = std::cosf(angle * 0.5f);
this->x = x * cos + z * sin;
this->z = -x * sin + z * cos;
return *this;
}
Vector4f& Vector4f::rotateY(float angle, Vector4f& dest) const {
float sin = std::sinf(angle * 0.5f);
float cos = std::cosf(angle * 0.5f);
dest.x = x * cos + z * sin;
dest.y = y;
dest.z = -x * sin + z * cos;
dest.w = w;
return dest;
}
Vector4f& Vector4f::rotateZ(float angle) {
float sin = std::sinf(angle * 0.5f);
float cos = std::cosf(angle * 0.5f);
this->x = x * cos - y * sin;
this->y = x * sin + y * cos;
return *this;
}
Vector4f& Vector4f::rotateZ(float angle, Vector4f& dest) const {
float sin = std::sinf(angle * 0.5f);
float cos = std::cosf(angle * 0.5f);
dest.x = x * cos - y * sin;
dest.y = x * sin + y * cos;
dest.z = z;
dest.w = w;
return dest;
}
/* EXTRA FUNCTIONS */
Vector4f& Vector4f::negate() {
return set(-x, -y, -z, -w);
}
Vector4f& Vector4f::negate(Vector4f& dest) const {
return dest.set(-x, -y, -z, -w);
}
Vector4f& Vector4f::zero() {
return set(0);
}
/* OPERATOR OVERLOADING */
bool Vector4f::operator==(const Vector4f& other) const {
return equals(other);
}
bool Vector4f::operator!=(const Vector4f& other) const {
return !equals(other);
}
float& Vector4f::operator[](int id) {
if (id == 0) return x;
else if (id == 1) return y;
else if (id == 2) return z;
else if (id == 3) return w;
else return x;
}
std::ostream& operator<<(std::ostream& os, const Vector4f& vec) {
os << vec.x << ", " << vec.y << ", " << vec.z << ", " << vec.w;
return os;
}
} | [
"olli.larsson@hotmail.com"
] | olli.larsson@hotmail.com |
adac61de20a68a30c5dac426638004c1b0b9968b | 0f22af25d3578381744d903f0cff174cf456c4c8 | /Stats.hpp | 4a5b1db7fe76a5cc6a8e92dd1ea3e0eae33a8da4 | [
"MIT"
] | permissive | ragavsachdeva/DynTTP | 3cfaa44c2fab8a324c5456653ac6b74dad0f3cd8 | ef56359852519393366daae728965d51cea3c6a8 | refs/heads/master | 2023-01-09T08:53:26.083355 | 2020-11-14T11:52:32 | 2020-11-14T11:52:32 | 257,838,019 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,492 | hpp | #ifndef STATS_HPP
#define STATS_HPP
#include <vector>
#include <iostream>
using namespace std;
struct DataPoint {
int evalCount;
double obj;
DataPoint(int e, double o) {
evalCount = e;
obj = o;
}
};
class Experiment {
public:
static vector<vector<DataPoint>> dataPoints;
static vector<double> finalOfEachRun;
static bool firstRun;
static int disruptEvery;
static void addDataPoint(int evalCount, double obj) {
// if there is no active phase, return
if (Experiment::dataPoints.size() == 0) return;
if (Experiment::dataPoints.back().size() != 0 &&
Experiment::dataPoints.back().back().evalCount == evalCount) return;
Experiment::dataPoints.back().push_back({evalCount, obj});
}
static void flushBuffer() {
if (dataPoints.size() > 0) {
// put a comma at the start, if it is not the first run.
if (!firstRun) cout << ",";
else firstRun = false;
cout << "[";
for (int phase = 0; phase < Experiment::dataPoints.size(); phase++) {
cout << "[";
for (int i = 0; i < Experiment::dataPoints[phase].size(); i++) {
cout << "[" << Experiment::dataPoints[phase][i].evalCount << "," << Experiment::dataPoints[phase][i].obj << "]";
if (i!=Experiment::dataPoints[phase].size()-1) cout << ",";
}
cout << "]";
if (phase!=Experiment::dataPoints.size()-1) cout << ",";
}
cout << "]";
}
}
static void startNewPhase() {
Experiment::dataPoints.push_back({});
}
static void startNewRun() {
if (Experiment::dataPoints.size() > 0) Experiment::finalOfEachRun.push_back(Experiment::dataPoints.back().back().obj);
Experiment::flushBuffer();
Experiment::dataPoints = {};
}
static void start() {
cout << "[";
Experiment::firstRun = true;
Experiment::finalOfEachRun = {};
Experiment::dataPoints = {};
}
static void finish() {
Experiment::flushBuffer();
cout << "]" << endl;
}
};
vector<vector<DataPoint>> Experiment::dataPoints = {};
bool Experiment::firstRun = true;
int Experiment::disruptEvery = 0;
vector<double> Experiment::finalOfEachRun = {};
bool disrupt() {
return Experiment::disruptEvery && ((Solution::evalCount+1) % Experiment::disruptEvery == 0);
}
#endif
| [
"ragdevsachdeva007@gmail.com"
] | ragdevsachdeva007@gmail.com |
99a5e50dae737071d1fb8015055b8787d970ae44 | a279380cd5053ffc145cac6542d41a8e0af1fc4e | /Contador_de_personas/Contador_de_personas.ino | 11c74f1ebf9c5fb6d5e06f01f7bbb0ca3853e388 | [] | no_license | VladP93/ContadorPersonas_Arduino | a24e2494c303eba9a1363b584572455155e98294 | eb46f802e49b17177a6ca6061b2130b9d2ba9fbc | refs/heads/master | 2020-06-22T20:09:42.266033 | 2019-07-23T08:29:33 | 2019-07-23T08:29:33 | 198,386,730 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,122 | ino | int c=0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(A0,INPUT);
pinMode(A1,INPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if(analogRead(A0)<1000){
c++;
Serial.println(c);
digitalWrite(8,HIGH);
delay(100);
digitalWrite(8,LOW);
delay(100);
digitalWrite(8,HIGH);
delay(100);
digitalWrite(8,LOW);
delay(100);
digitalWrite(8,HIGH);
delay(100);
digitalWrite(8,LOW);
delay(500);
}
if(analogRead(A1)<1000){
c--;
Serial.println(c);
digitalWrite(8,HIGH);
delay(100);
digitalWrite(8,LOW);
delay(100);
digitalWrite(8,HIGH);
delay(100);
digitalWrite(8,LOW);
delay(100);
digitalWrite(8,HIGH);
delay(100);
digitalWrite(8,LOW);
delay(500);
}
if(c<1){
c=0;
digitalWrite(9,LOW);
} else {
digitalWrite(9,HIGH);
}
/*
Serial.print("Sensor entrada: ");
Serial.println(analogRead(A0));
Serial.print("Sensor salida: ");
Serial.println(analogRead(A1));
delay(500);
*/
}
| [
"noreply@github.com"
] | noreply@github.com |
b80bfcd674619c9eefb068512830bd1facf89020 | c702357d201235f5a76deb90133dbc3a13c64736 | /llvm/include/llvm/CodeGen/.svn/text-base/LinkAllCodegenComponents.h.svn-base | 5608c999e129065019f0ca3240f67a066893b4ed | [
"NCSA"
] | permissive | aaasz/SHP | ab77e5be297c2e23a462c385b9e7332e38765a14 | c03ee7a26a93b2396b7c4f9179b1b2deb81951d3 | refs/heads/master | 2021-01-18T11:00:14.367480 | 2010-01-17T23:10:18 | 2010-01-17T23:10:18 | 549,107 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,058 | //===- llvm/Codegen/LinkAllCodegenComponents.h ------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This header file pulls in all codegen related passes for tools like lli and
// llc that need this functionality.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CODEGEN_LINKALLCODEGENCOMPONENTS_H
#define LLVM_CODEGEN_LINKALLCODEGENCOMPONENTS_H
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/SchedulerRegistry.h"
#include "llvm/CodeGen/GCs.h"
#include "llvm/Target/TargetMachine.h"
#include <cstdlib>
namespace {
struct ForceCodegenLinking {
ForceCodegenLinking() {
// We must reference the passes in such a way that compilers will not
// delete it all as dead code, even with whole program optimization,
// yet is effectively a NO-OP. As the compiler isn't smart enough
// to know that getenv() never returns -1, this will do the job.
if (std::getenv("bar") != (char*) -1)
return;
(void) llvm::createDeadMachineInstructionElimPass();
(void) llvm::createLocalRegisterAllocator();
(void) llvm::createLinearScanRegisterAllocator();
(void) llvm::createPBQPRegisterAllocator();
(void) llvm::createSimpleRegisterCoalescer();
llvm::linkOcamlGC();
llvm::linkShadowStackGC();
(void) llvm::createBURRListDAGScheduler(NULL, llvm::CodeGenOpt::Default);
(void) llvm::createTDRRListDAGScheduler(NULL, llvm::CodeGenOpt::Default);
(void) llvm::createTDListDAGScheduler(NULL, llvm::CodeGenOpt::Default);
(void) llvm::createFastDAGScheduler(NULL, llvm::CodeGenOpt::Default);
(void) llvm::createDefaultScheduler(NULL, llvm::CodeGenOpt::Default);
}
} ForceCodegenLinking; // Force link by creating a global definition.
}
#endif
| [
"aaa.szeke@gmail.com"
] | aaa.szeke@gmail.com | |
81bb44b0f1cd4b9f44dfc619d5519869b48cdb17 | ce654d813cd148bb10223ebcbb95db4e39ae5f23 | /COMP2603Marker/comp1602-copiers/Joshua_Samm_213848_assignsubmission_file_.cpp | ef21edff71aa5cbb02a63d2fb0e59ada8a6b6cac | [] | no_license | justkrismanohar/TA_Tools | e3fc8c75f3a5f07604a87ac4033ace82a5a9fe9a | bc08da4378e5038cef8710d2792c370606ea3102 | refs/heads/master | 2022-05-26T19:40:35.501672 | 2022-05-05T01:33:40 | 2022-05-05T01:33:40 | 179,185,808 | 1 | 0 | null | 2022-05-05T02:26:57 | 2019-04-03T01:21:37 | HTML | UTF-8 | C++ | false | false | 5,942 | cpp | #include <iostream>
#include <bits/stdc++.h>
#include <fstream>
#include <cmath>
using namespace std;
const int MAX = 100;
bool isPrime (int n) {
int i;
for (i = 2; i < n; i++){
if (n % i == 0){
return false;
}
}
if (n == 1){
return false;
}
else {
return true;
}
}
bool isPerfect (int n){
int i, div, sum=0;
for (i=1; i < n; i++){
div = n % i;
if (div == 0)
sum = sum + i;
}
if (sum == n){
return true;
}
else{
return false;
}
}
bool isPerfect_Square (int n){
for (int i = 1; i <= n; i++){
if (i*i == n){
return true;
}
else if (i * i > n) {
return false;
}
}
}
bool isSphenic (int n){
int i, a, b, c;
for (i = 1; i <= n; i++){
if (isPrime(i)){
if ((i != a) || (i != b) || (i != c)){
a = i;
}
}
}
}
void inBinary (int n){
ofstream output;
int i = 0, store[7], j;
while (i <= 8){
store [ i ] = n % 2;
i++;
n = n/2;
}
output.open("output.txt");
if (!output.is_open()) {
cout << "Error opening output file. Aborting ...";
}
output << store[7] << store[6] << store[5] << store[4] << store[3] << store[2] << store[1] << store[0] << endl;
}
int Popular (int arr[], int n){
sort(arr, arr + n);
// find the max frequency using linear traversal
int max_count = 1, pop = arr[0], curr_count = 1;
for (int i = 1; i < n; i++) {
if (arr[i] == arr[i - 1]) {
curr_count++;
}
else {
if (curr_count > max_count) {
max_count = curr_count;
pop = arr[i - 1];
}
curr_count = 1;
}
}
// If last element is most frequent
if (curr_count > max_count)
{
max_count = curr_count;
pop = arr[n - 1];
}
return pop;
}
int Unpopular (int arr[], int n){
// Sort the array
sort(arr, arr + n);
// find the min frequency using linear traversal
int min_count = n+1, unpop = -1, curr_count = 1;
for (int i = 1; i < n; i++) {
if (arr[i] == arr[i - 1]) {
curr_count++;
}
else {
for (int j = 0; j <= n; j++){
if (curr_count < min_count) {
min_count = curr_count;
unpop = arr[i - 1];
break;
}
}
curr_count = 1;
}
}
// If last element is least frequent
if (curr_count < min_count)
{
min_count = curr_count;
unpop = arr[n - 1];
}
return unpop;
}
int main ()
{
ifstream input;
ofstream output;
int valid_num = 0, invalid_num = 0, blank_num = 0, num_students = 0;
int fav_num; //data entries
int post_0, post_10, post_20, post_30, post_40, post_50, post_60, post_70, post_80, post_90;
bool Prime, Perfect, Perfect_Square, Sphenic;
int Binary;
input.open("numbers.txt");
output.open("output.txt");
if (!input.is_open()) {
cout << "Error opening input file. Aborting ...";
return 0;
}
if (!output.is_open()) {
cout << "Error opening output file. Aborting ...";
return 0;
}
output << "Number" << setw(15) << "Perfect?" << setw(15) << "Prime?" << setw(15) << "Perfect Square?" << setw(20) << "Sphenic?" << setw(15) << "Binary Equiv." << endl;
output << "==============================================================================================================================" << endl;
output << "" << endl;
input >> fav_num;
while (fav_num != -1) {
if ((fav_num > 1) || (fav_num < 100)) {
valid_num++;
}
else if ((fav_num > 100 ) || (fav_num < -1)){
invalid_num++;
input >> fav_num;
num_students++;
continue;
}
else if (fav_num = 0){
blank_num++;
input >> fav_num;
num_students++;
continue;
}
}
input.close();
int invalid_set [invalid_num], chosen_set [valid_num];
for (int g = 0; g <= num_students; g++){
if ((fav_num > 100 ) || (fav_num < -1)){
invalid_num++;
input >> fav_num;
invalid_set [g] = fav_num;
}
g++;
}
for (int y = 0; y < num_students; y++){
if ((fav_num < 100 ) || (fav_num > 1)){
valid_num++;
input >> fav_num;
chosen_set [y] = fav_num;
}
y++;
}
for (int l = 0; l < valid_num; l++){
output << fav_num << setw(15);
Prime = isPrime(fav_num);
Perfect = isPerfect(fav_num);
Perfect_Square = isPerfect_Square(fav_num);
Sphenic = isSphenic(fav_num);
if (Perfect) {
output << "Y" << setw(15);
}
else {
output << "N" << setw(15);
}
if (Prime) {
output << "Y" << setw(15);
}
else {
output << "N" << setw(15);
}
if (Perfect_Square) {
output << "Y" << setw(20);
}
else {
output << "N" << setw(15);
}
if (Sphenic) {
output << "Y" << setw(15);
}
else {
output << "N" << setw(15);
}
inBinary(fav_num);
num_students++;
}
for (int k = 0; k < invalid_num; k++){
output << invalid_set[k] << " ";
if ((k + 1) % 5){
endl;
}
}
output << "Range" << setw(30) << "Histogram" << endl;
output << "========================================================================" << endl;
output << "" << endl;
for (int z = 0; z < valid_num; z++){
output << "1 - 10" << setw(30) << ":";
if ((chosen_set[z] >= 1) || (chosen_set[z] <= 100)) {
}
else{
}
}
numbers[num_students] = fav_num;
output << "" << endl;
output << "" << endl;
output << "Number of Students Specifying Valid Numbers = " << valid_num << endl;
output << "Number of Students Specifying Invalid Numbers = " << invalid_num << endl;
output << "Number of Students that didn't answer = " << blank_num << endl;
output << "The most common number/s chosen was/were " << Popular(chosen_set[], num_students) << endl;
output << "The least common number/s chosen was/were " << Unpopular(chosen_set[], num_students) << endl;
output.close();
return 0;
}
| [
"justkrismanohar@gmail.com"
] | justkrismanohar@gmail.com |
93ef5434f82ebac639afecff15ef2bfcb323152d | 452be58b4c62e6522724740cac332ed0fe446bb8 | /src/cobalt/browser/web_module.cc | 43468e00886286f087db621eac75c1d443de3273 | [
"Apache-2.0"
] | permissive | blockspacer/cobalt-clone-cab7770533804d582eaa66c713a1582f361182d3 | b6e802f4182adbf6a7451a5d48dc4e158b395107 | 0b72f93b07285f3af3c8452ae2ceaf5860ca7c72 | refs/heads/master | 2020-08-18T11:32:21.458963 | 2019-10-17T13:09:35 | 2019-10-17T13:09:35 | 215,783,613 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 68,556 | cc | // Copyright 2015 The Cobalt Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "cobalt/browser/web_module.h"
#include <memory>
#include <sstream>
#include <string>
#include "base/bind.h"
#include "base/callback.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/optional.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/waitable_event.h"
#include "base/trace_event/trace_event.h"
#include "cobalt/base/c_val.h"
#include "cobalt/base/language.h"
#include "cobalt/base/startup_timer.h"
#include "cobalt/base/tokens.h"
#include "cobalt/base/type_id.h"
#include "cobalt/browser/splash_screen_cache.h"
#include "cobalt/browser/stack_size_constants.h"
#include "cobalt/browser/switches.h"
#include "cobalt/browser/web_module_stat_tracker.h"
#include "cobalt/css_parser/parser.h"
#include "cobalt/dom/blob.h"
#include "cobalt/dom/csp_delegate_factory.h"
#include "cobalt/dom/element.h"
#include "cobalt/dom/event.h"
#include "cobalt/dom/global_stats.h"
#include "cobalt/dom/html_script_element.h"
#include "cobalt/dom/input_event.h"
#include "cobalt/dom/input_event_init.h"
#include "cobalt/dom/keyboard_event.h"
#include "cobalt/dom/keyboard_event_init.h"
#include "cobalt/dom/local_storage_database.h"
#include "cobalt/dom/mutation_observer_task_manager.h"
#include "cobalt/dom/pointer_event.h"
#include "cobalt/dom/storage.h"
#include "cobalt/dom/ui_event.h"
#include "cobalt/dom/url.h"
#include "cobalt/dom/wheel_event.h"
#include "cobalt/dom/window.h"
#include "cobalt/dom_parser/parser.h"
#include "cobalt/h5vcc/h5vcc.h"
#include "cobalt/layout/topmost_event_target.h"
#include "cobalt/loader/image/animated_image_tracker.h"
#include "cobalt/media_session/media_session_client.h"
#include "cobalt/page_visibility/visibility_state.h"
#include "cobalt/script/error_report.h"
#include "cobalt/script/javascript_engine.h"
#include "cobalt/storage/storage_manager.h"
#include "starboard/accessibility.h"
#include "starboard/common/log.h"
#if defined(ENABLE_DEBUGGER)
#include "cobalt/debug/backend/debug_module.h"
#endif // defined(ENABLE_DEBUGGER)
namespace cobalt {
namespace browser {
using cobalt::cssom::ViewportSize;
namespace {
// The maximum number of element depth in the DOM tree. Elements at a level
// deeper than this could be discarded, and will not be rendered.
const int kDOMMaxElementDepth = 32;
bool CacheUrlContent(SplashScreenCache* splash_screen_cache, const GURL& url,
const std::string& content) {
base::Optional<std::string> key = SplashScreenCache::GetKeyForStartUrl(url);
if (key) {
return splash_screen_cache->SplashScreenCache::CacheSplashScreen(*key,
content);
}
return false;
}
base::Callback<bool(const GURL&, const std::string&)> CacheUrlContentCallback(
SplashScreenCache* splash_screen_cache) {
// This callback takes in first the url, then the content string.
if (splash_screen_cache) {
return base::Bind(CacheUrlContent, base::Unretained(splash_screen_cache));
} else {
return base::Callback<bool(const GURL&, const std::string&)>();
}
}
} // namespace
// Private WebModule implementation. Each WebModule owns a single instance of
// this class, which performs all the actual work. All functions of this class
// must be called on the message loop of the WebModule thread, so they
// execute synchronously with respect to one another.
class WebModule::Impl {
public:
explicit Impl(const ConstructionData& data);
~Impl();
#if defined(ENABLE_DEBUGGER)
debug::backend::DebugDispatcher* debug_dispatcher() {
DCHECK(debug_module_);
return debug_module_->debug_dispatcher();
}
#endif // ENABLE_DEBUGGER
#if SB_HAS(ON_SCREEN_KEYBOARD)
// Injects an on screen keyboard input event into the web module. Event is
// directed at a specific element if the element is non-null. Otherwise, the
// currently focused element receives the event. If element is specified, we
// must be on the WebModule's message loop.
void InjectOnScreenKeyboardInputEvent(scoped_refptr<dom::Element> element,
base::Token type,
const dom::InputEventInit& event);
// Injects an on screen keyboard shown event into the web module. Event is
// directed at the on screen keyboard element.
void InjectOnScreenKeyboardShownEvent(int ticket);
// Injects an on screen keyboard hidden event into the web module. Event is
// directed at the on screen keyboard element.
void InjectOnScreenKeyboardHiddenEvent(int ticket);
// Injects an on screen keyboard focused event into the web module. Event is
// directed at the on screen keyboard element.
void InjectOnScreenKeyboardFocusedEvent(int ticket);
// Injects an on screen keyboard blurred event into the web module. Event is
// directed at the on screen keyboard element.
void InjectOnScreenKeyboardBlurredEvent(int ticket);
#if SB_API_VERSION >= 11
// Injects an on screen keyboard suggestions updated event into the web
// module. Event is directed at the on screen keyboard element.
void InjectOnScreenKeyboardSuggestionsUpdatedEvent(int ticket);
#endif // SB_API_VERSION >= 11
#endif // SB_HAS(ON_SCREEN_KEYBOARD)
// Injects a keyboard event into the web module. Event is directed at a
// specific element if the element is non-null. Otherwise, the currently
// focused element receives the event. If element is specified, we must be
// on the WebModule's message loop
void InjectKeyboardEvent(scoped_refptr<dom::Element> element,
base::Token type,
const dom::KeyboardEventInit& event);
// Injects a pointer event into the web module. Event is directed at a
// specific element if the element is non-null. Otherwise, the currently
// focused element receives the event. If element is specified, we must be
// on the WebModule's message loop
void InjectPointerEvent(scoped_refptr<dom::Element> element, base::Token type,
const dom::PointerEventInit& event);
// Injects a wheel event into the web module. Event is directed at a
// specific element if the element is non-null. Otherwise, the currently
// focused element receives the event. If element is specified, we must be
// on the WebModule's message loop
void InjectWheelEvent(scoped_refptr<dom::Element> element, base::Token type,
const dom::WheelEventInit& event);
// Injects a beforeunload event into the web module. If this event is not
// handled by the web application, |on_before_unload_fired_but_not_handled_|
// will be called. The event is not directed at a specific element.
void InjectBeforeUnloadEvent();
void InjectCaptionSettingsChangedEvent();
// Executes JavaScript in this WebModule. Sets the |result| output parameter
// and signals |got_result|.
void ExecuteJavascript(const std::string& script_utf8,
const base::SourceLocation& script_location,
base::WaitableEvent* got_result, std::string* result,
bool* out_succeeded);
// Clears disables timer related objects
// so that the message loop can easily exit
void ClearAllIntervalsAndTimeouts();
#if defined(ENABLE_WEBDRIVER)
// Creates a new webdriver::WindowDriver that interacts with the Window that
// is owned by this WebModule instance.
void CreateWindowDriver(
const webdriver::protocol::WindowId& window_id,
std::unique_ptr<webdriver::WindowDriver>* window_driver_out);
#endif // defined(ENABLE_WEBDRIVER)
#if defined(ENABLE_DEBUGGER)
void WaitForWebDebugger();
bool IsFinishedWaitingForWebDebugger() {
return wait_for_web_debugger_finished_.IsSignaled();
}
void FreezeDebugger(
std::unique_ptr<debug::backend::DebuggerState>* debugger_state) {
*debugger_state = debug_module_->Freeze();
}
#endif // defined(ENABLE_DEBUGGER)
void SetSize(cssom::ViewportSize window_dimensions, float video_pixel_ratio);
void SetCamera3D(const scoped_refptr<input::Camera3D>& camera_3d);
void SetWebMediaPlayerFactory(
media::WebMediaPlayerFactory* web_media_player_factory);
void SetImageCacheCapacity(int64_t bytes);
void SetRemoteTypefaceCacheCapacity(int64_t bytes);
// Sets the application state, asserts preconditions to transition to that
// state, and dispatches any precipitate web events.
void SetApplicationState(base::ApplicationState state);
// Suspension of the WebModule is a two-part process since a message loop
// gap is needed in order to give a chance to handle loader callbacks
// that were initiated from a loader thread.
//
// If |update_application_state| is false, then SetApplicationState will not
// be called, and no state transition events will be generated.
void SuspendLoaders(bool update_application_state);
void FinishSuspend();
// See LifecycleObserver. These functions do not implement the interface, but
// have the same basic function.
void Start(render_tree::ResourceProvider* resource_provider);
void Pause();
void Unpause();
void Resume(render_tree::ResourceProvider* resource_provider);
void ReduceMemory();
void GetJavaScriptHeapStatistics(
const JavaScriptHeapStatisticsCallback& callback);
void LogScriptError(const base::SourceLocation& source_location,
const std::string& error_message);
void CancelSynchronousLoads();
private:
class DocumentLoadedObserver;
// Purge all resource caches owned by the WebModule.
void PurgeResourceCaches(bool should_retain_remote_typeface_cache);
// Disable callbacks in all resource caches owned by the WebModule.
void DisableCallbacksInResourceCaches();
// Injects a list of custom window attributes into the WebModule's window
// object.
void InjectCustomWindowAttributes(
const Options::InjectedWindowAttributes& attributes);
// Called by |layout_mananger_| after it runs the animation frame callbacks.
void OnRanAnimationFrameCallbacks();
// Called by |layout_mananger_| when it produces a render tree. May modify
// the render tree (e.g. to add a debug overlay), then runs the callback
// specified in the constructor, |render_tree_produced_callback_|.
void OnRenderTreeProduced(const LayoutResults& layout_results);
// Called by the Renderer on the Renderer thread when it rasterizes a render
// tree with this callback attached. It includes the time the render tree was
// produced.
void OnRenderTreeRasterized(
scoped_refptr<base::SingleThreadTaskRunner> web_module_message_loop,
const base::TimeTicks& produced_time);
// WebModule thread handling of the OnRenderTreeRasterized() callback. It
// includes the time that the render tree was produced and the time that the
// render tree was rasterized.
void ProcessOnRenderTreeRasterized(const base::TimeTicks& produced_time,
const base::TimeTicks& rasterized_time);
void OnCspPolicyChanged();
scoped_refptr<script::GlobalEnvironment> global_environment() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
return global_environment_;
}
void OnLoadComplete(const base::Optional<std::string>& error) {
if (error) error_callback_.Run(window_->location()->url(), *error);
}
// Report an error encountered while running JS.
// Returns whether or not the error was handled.
bool ReportScriptError(const script::ErrorReport& error_report);
// Inject the DOM event object into the window or the element.
void InjectInputEvent(scoped_refptr<dom::Element> element,
const scoped_refptr<dom::Event>& event);
// Handle queued pointer events. Called by LayoutManager on_layout callback.
void HandlePointerEvents();
// Initializes the ResourceProvider and dependent resources.
void SetResourceProvider(render_tree::ResourceProvider* resource_provider);
void OnStartDispatchEvent(const scoped_refptr<dom::Event>& event);
void OnStopDispatchEvent(const scoped_refptr<dom::Event>& event);
// Thread checker ensures all calls to the WebModule are made from the same
// thread that it is created in.
THREAD_CHECKER(thread_checker_);
std::string name_;
// Simple flag used for basic error checking.
bool is_running_;
// The most recent time that a new render tree was produced.
base::TimeTicks last_render_tree_produced_time_;
// Whether or not a render tree has been produced but not yet rasterized.
base::CVal<bool, base::CValPublic> is_render_tree_rasterization_pending_;
// Object that provides renderer resources like images and fonts.
render_tree::ResourceProvider* resource_provider_;
// The type id of resource provider being used by the WebModule. Whenever this
// changes, the caches may have obsolete data and must be blown away.
base::TypeId resource_provider_type_id_;
// CSS parser.
std::unique_ptr<css_parser::Parser> css_parser_;
// DOM (HTML / XML) parser.
std::unique_ptr<dom_parser::Parser> dom_parser_;
// FetcherFactory that is used to create a fetcher according to URL.
std::unique_ptr<loader::FetcherFactory> fetcher_factory_;
// LoaderFactory that is used to acquire references to resources from a
// URL.
std::unique_ptr<loader::LoaderFactory> loader_factory_;
std::unique_ptr<loader::image::AnimatedImageTracker> animated_image_tracker_;
// ImageCache that is used to manage image cache logic.
std::unique_ptr<loader::image::ImageCache> image_cache_;
// The reduced cache capacity manager can be used to force a reduced image
// cache over periods of time where memory is known to be restricted, such
// as when a video is playing.
std::unique_ptr<loader::image::ReducedCacheCapacityManager>
reduced_image_cache_capacity_manager_;
// RemoteTypefaceCache that is used to manage loading and caching typefaces
// from URLs.
std::unique_ptr<loader::font::RemoteTypefaceCache> remote_typeface_cache_;
// MeshCache that is used to manage mesh cache logic.
std::unique_ptr<loader::mesh::MeshCache> mesh_cache_;
// Interface between LocalStorage and the Storage Manager.
std::unique_ptr<dom::LocalStorageDatabase> local_storage_database_;
// Stats for the web module. Both the dom stat tracker and layout stat
// tracker are contained within it.
std::unique_ptr<browser::WebModuleStatTracker> web_module_stat_tracker_;
// Post and run tasks to notify MutationObservers.
dom::MutationObserverTaskManager mutation_observer_task_manager_;
// JavaScript engine for the browser.
std::unique_ptr<script::JavaScriptEngine> javascript_engine_;
// JavaScript Global Object for the browser. There should be one per window,
// but since there is only one window, we can have one per browser.
scoped_refptr<script::GlobalEnvironment> global_environment_;
// Used by |Console| to obtain a JavaScript stack trace.
std::unique_ptr<script::ExecutionState> execution_state_;
// Interface for the document to execute JavaScript code.
std::unique_ptr<script::ScriptRunner> script_runner_;
// Object to register and retrieve MediaSource object with a string key.
std::unique_ptr<dom::MediaSource::Registry> media_source_registry_;
// Object to register and retrieve Blob objects with a string key.
std::unique_ptr<dom::Blob::Registry> blob_registry_;
// The Window object wraps all DOM-related components.
scoped_refptr<dom::Window> window_;
// Cache a WeakPtr in the WebModule that is bound to the Window's message loop
// so we can ensure that all subsequently created WeakPtr's are also bound to
// the same loop.
// See the documentation in base/memory/weak_ptr.h for details.
base::WeakPtr<dom::Window> window_weak_;
// Environment Settings object
std::unique_ptr<dom::DOMSettings> environment_settings_;
// Called by |OnRenderTreeProduced|.
OnRenderTreeProducedCallback render_tree_produced_callback_;
// Called by |OnError|.
OnErrorCallback error_callback_;
// Triggers layout whenever the document changes.
std::unique_ptr<layout::LayoutManager> layout_manager_;
#if defined(ENABLE_DEBUGGER)
// Allows the debugger to add render components to the web module.
// Used for DOM node highlighting and overlay messages.
std::unique_ptr<debug::backend::RenderOverlay> debug_overlay_;
// The core of the debugging system.
std::unique_ptr<debug::backend::DebugModule> debug_module_;
// Used to avoid a deadlock when running |Impl::Pause| while waiting for the
// web debugger to connect.
base::WaitableEvent wait_for_web_debugger_finished_ = {
base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED};
// Interface to report behaviour relevant to the web debugger.
debug::backend::DebuggerHooksImpl debugger_hooks_;
#else
// Null implementation used in gold builds without checking ENABLE_DEBUGGER.
base::NullDebuggerHooks debugger_hooks_;
#endif // ENABLE_DEBUGGER
// DocumentObserver that observes the loading document.
std::unique_ptr<DocumentLoadedObserver> document_load_observer_;
std::unique_ptr<media_session::MediaSessionClient> media_session_client_;
std::unique_ptr<layout::TopmostEventTarget> topmost_event_target_;
base::Closure on_before_unload_fired_but_not_handled_;
bool should_retain_remote_typeface_cache_on_suspend_;
scoped_refptr<cobalt::dom::captions::SystemCaptionSettings>
system_caption_settings_;
// This event is used to interrupt the loader when JavaScript is loaded
// synchronously. It is manually reset so that events like Suspend can be
// correctly execute, even if there are multiple synchronous loads in queue
// before the suspend (or other) event handlers.
base::WaitableEvent synchronous_loader_interrupt_ = {
base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED};
};
class WebModule::Impl::DocumentLoadedObserver : public dom::DocumentObserver {
public:
typedef std::vector<base::Closure> ClosureVector;
explicit DocumentLoadedObserver(const ClosureVector& loaded_callbacks)
: loaded_callbacks_(loaded_callbacks) {}
// Called at most once, when document and all referred resources are loaded.
void OnLoad() override {
for (size_t i = 0; i < loaded_callbacks_.size(); ++i) {
loaded_callbacks_[i].Run();
}
}
void OnMutation() override {}
void OnFocusChanged() override {}
private:
ClosureVector loaded_callbacks_;
};
WebModule::Impl::Impl(const ConstructionData& data)
: name_(data.options.name),
is_running_(false),
is_render_tree_rasterization_pending_(
base::StringPrintf("%s.IsRenderTreeRasterizationPending",
name_.c_str()),
false, "True when a render tree is produced but not yet rasterized."),
resource_provider_(data.resource_provider),
resource_provider_type_id_(data.resource_provider->GetTypeId()) {
// Currently we rely on a platform to explicitly specify that it supports
// the map-to-mesh filter via the ENABLE_MAP_TO_MESH define (and the
// 'enable_map_to_mesh' gyp variable). When we have better support for
// checking for decode to texture support, it would be nice to switch this
// logic to something like:
//
// supports_map_to_mesh =
// (resource_provider_->Supports3D() && SbPlayerSupportsDecodeToTexture()
// ? css_parser::Parser::kSupportsMapToMesh
// : css_parser::Parser::kDoesNotSupportMapToMesh);
//
// Note that it is important that we do not parse map-to-mesh filters if we
// cannot render them, since web apps may check for map-to-mesh support by
// testing whether it parses or not via the CSS.supports() Web API.
css_parser::Parser::SupportsMapToMeshFlag supports_map_to_mesh =
#if defined(ENABLE_MAP_TO_MESH)
data.options.enable_map_to_mesh_rectangular
? css_parser::Parser::kSupportsMapToMeshRectangular
: css_parser::Parser::kSupportsMapToMesh;
#else
css_parser::Parser::kDoesNotSupportMapToMesh;
#endif
css_parser_ = css_parser::Parser::Create(supports_map_to_mesh);
DCHECK(css_parser_);
dom_parser_.reset(new dom_parser::Parser(
kDOMMaxElementDepth,
base::Bind(&WebModule::Impl::OnLoadComplete, base::Unretained(this)),
data.options.require_csp));
DCHECK(dom_parser_);
blob_registry_.reset(new dom::Blob::Registry);
base::Callback<int(const std::string&, std::unique_ptr<char[]>*)>
read_cache_callback;
if (data.options.can_fetch_cache) {
read_cache_callback =
base::Bind(&browser::SplashScreenCache::ReadCachedSplashScreen,
base::Unretained(data.options.splash_screen_cache));
}
on_before_unload_fired_but_not_handled_ =
data.options.on_before_unload_fired_but_not_handled;
should_retain_remote_typeface_cache_on_suspend_ =
data.options.should_retain_remote_typeface_cache_on_suspend;
fetcher_factory_.reset(new loader::FetcherFactory(
data.network_module, data.options.extra_web_file_dir,
dom::URL::MakeBlobResolverCallback(blob_registry_.get()),
read_cache_callback));
DCHECK(fetcher_factory_);
DCHECK_LE(0, data.options.encoded_image_cache_capacity);
loader_factory_.reset(new loader::LoaderFactory(
name_.c_str(), fetcher_factory_.get(), resource_provider_,
data.options.encoded_image_cache_capacity,
data.options.loader_thread_priority));
animated_image_tracker_.reset(new loader::image::AnimatedImageTracker(
data.options.animated_image_decode_thread_priority));
DCHECK_LE(0, data.options.image_cache_capacity);
image_cache_ = loader::image::CreateImageCache(
base::StringPrintf("%s.ImageCache", name_.c_str()),
static_cast<uint32>(data.options.image_cache_capacity),
loader_factory_.get());
DCHECK(image_cache_);
reduced_image_cache_capacity_manager_.reset(
new loader::image::ReducedCacheCapacityManager(
image_cache_.get(),
data.options.image_cache_capacity_multiplier_when_playing_video));
DCHECK_LE(0, data.options.remote_typeface_cache_capacity);
remote_typeface_cache_ = loader::font::CreateRemoteTypefaceCache(
base::StringPrintf("%s.RemoteTypefaceCache", name_.c_str()),
static_cast<uint32>(data.options.remote_typeface_cache_capacity),
loader_factory_.get());
DCHECK(remote_typeface_cache_);
DCHECK_LE(0, data.options.mesh_cache_capacity);
mesh_cache_ = loader::mesh::CreateMeshCache(
base::StringPrintf("%s.MeshCache", name_.c_str()),
static_cast<uint32>(data.options.mesh_cache_capacity),
loader_factory_.get());
DCHECK(mesh_cache_);
local_storage_database_.reset(
new dom::LocalStorageDatabase(data.network_module->storage_manager()));
DCHECK(local_storage_database_);
web_module_stat_tracker_.reset(
new browser::WebModuleStatTracker(name_, data.options.track_event_stats));
DCHECK(web_module_stat_tracker_);
javascript_engine_ = script::JavaScriptEngine::CreateEngine(
data.options.javascript_engine_options);
DCHECK(javascript_engine_);
#if defined(COBALT_ENABLE_JAVASCRIPT_ERROR_LOGGING)
script::JavaScriptEngine::ErrorHandler error_handler =
base::Bind(&WebModule::Impl::LogScriptError, base::Unretained(this));
javascript_engine_->RegisterErrorHandler(error_handler);
#endif
global_environment_ = javascript_engine_->CreateGlobalEnvironment();
DCHECK(global_environment_);
execution_state_ =
script::ExecutionState::CreateExecutionState(global_environment_);
DCHECK(execution_state_);
script_runner_ =
script::ScriptRunner::CreateScriptRunner(global_environment_);
DCHECK(script_runner_);
media_source_registry_.reset(new dom::MediaSource::Registry);
media_session_client_ = media_session::MediaSessionClient::Create();
media_session_client_->SetMediaPlayerFactory(data.web_media_player_factory);
system_caption_settings_ = new cobalt::dom::captions::SystemCaptionSettings();
dom::Window::CacheCallback splash_screen_cache_callback =
CacheUrlContentCallback(data.options.splash_screen_cache);
// These members will reference other |Traceable|s, however are not
// accessible from |Window|, so we must explicitly add them as roots.
global_environment_->AddRoot(&mutation_observer_task_manager_);
global_environment_->AddRoot(media_source_registry_.get());
global_environment_->AddRoot(blob_registry_.get());
#if defined(ENABLE_DEBUGGER)
if (data.options.wait_for_web_debugger) {
// Post a task that blocks the message loop and waits for the web debugger.
// This must be posted before the the window's task to load the document.
base::MessageLoop::current()->task_runner()->PostTask(
FROM_HERE, base::Bind(&WebModule::Impl::WaitForWebDebugger,
base::Unretained(this)));
} else {
// We're not going to wait for the web debugger, so consider it finished.
wait_for_web_debugger_finished_.Signal();
}
#endif // defined(ENABLE_DEBUGGER)
bool log_tts = false;
#if defined(ENABLE_DEBUG_COMMAND_LINE_SWITCHES)
log_tts =
base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseTTS);
#endif
window_ = new dom::Window(
data.window_dimensions, data.video_pixel_ratio,
data.initial_application_state, css_parser_.get(), dom_parser_.get(),
fetcher_factory_.get(), loader_factory_.get(), &resource_provider_,
animated_image_tracker_.get(), image_cache_.get(),
reduced_image_cache_capacity_manager_.get(), remote_typeface_cache_.get(),
mesh_cache_.get(), local_storage_database_.get(),
data.can_play_type_handler, data.web_media_player_factory,
execution_state_.get(), script_runner_.get(),
global_environment_->script_value_factory(), media_source_registry_.get(),
web_module_stat_tracker_->dom_stat_tracker(), data.initial_url,
data.network_module->GetUserAgent(),
data.network_module->preferred_language(),
data.options.font_language_script_override.empty()
? base::GetSystemLanguageScript()
: data.options.font_language_script_override,
data.options.navigation_callback,
base::Bind(&WebModule::Impl::OnLoadComplete, base::Unretained(this)),
data.network_module->cookie_jar(), data.network_module->GetPostSender(),
data.options.require_csp, data.options.csp_enforcement_mode,
base::Bind(&WebModule::Impl::OnCspPolicyChanged, base::Unretained(this)),
base::Bind(&WebModule::Impl::OnRanAnimationFrameCallbacks,
base::Unretained(this)),
data.window_close_callback, data.window_minimize_callback,
data.options.on_screen_keyboard_bridge, data.options.camera_3d,
media_session_client_->GetMediaSession(),
base::Bind(&WebModule::Impl::OnStartDispatchEvent,
base::Unretained(this)),
base::Bind(&WebModule::Impl::OnStopDispatchEvent, base::Unretained(this)),
data.options.provide_screenshot_function, &synchronous_loader_interrupt_,
debugger_hooks_, data.ui_nav_root,
data.options.csp_insecure_allowed_token, data.dom_max_element_depth,
data.options.video_playback_rate_multiplier,
#if defined(ENABLE_TEST_RUNNER)
data.options.layout_trigger == layout::LayoutManager::kTestRunnerMode
? dom::Window::kClockTypeTestRunner
: (data.options.limit_performance_timer_resolution
? dom::Window::kClockTypeResolutionLimitedSystemTime
: dom::Window::kClockTypeSystemTime),
#else
dom::Window::kClockTypeSystemTime,
#endif
splash_screen_cache_callback, system_caption_settings_, log_tts);
DCHECK(window_);
window_weak_ = base::AsWeakPtr(window_.get());
DCHECK(window_weak_);
environment_settings_.reset(new dom::DOMSettings(
kDOMMaxElementDepth, fetcher_factory_.get(), data.network_module, window_,
media_source_registry_.get(), blob_registry_.get(),
data.can_play_type_handler, javascript_engine_.get(),
global_environment_.get(), &mutation_observer_task_manager_,
data.options.dom_settings_options));
DCHECK(environment_settings_);
window_->SetEnvironmentSettings(environment_settings_.get());
global_environment_->CreateGlobalObject(window_, environment_settings_.get());
render_tree_produced_callback_ = data.render_tree_produced_callback;
DCHECK(!render_tree_produced_callback_.is_null());
error_callback_ = data.error_callback;
DCHECK(!error_callback_.is_null());
layout_manager_.reset(new layout::LayoutManager(
name_, window_.get(),
base::Bind(&WebModule::Impl::OnRenderTreeProduced,
base::Unretained(this)),
base::Bind(&WebModule::Impl::HandlePointerEvents, base::Unretained(this)),
data.options.layout_trigger, data.dom_max_element_depth,
data.layout_refresh_rate, data.network_module->preferred_language(),
data.options.enable_image_animations,
web_module_stat_tracker_->layout_stat_tracker(),
data.options.clear_window_with_background_color));
DCHECK(layout_manager_);
#if !defined(COBALT_FORCE_CSP)
if (data.options.csp_enforcement_mode == dom::kCspEnforcementDisable) {
// If CSP is disabled, enable eval(). Otherwise, it will be enabled by
// a CSP directive.
global_environment_->EnableEval();
}
#endif
global_environment_->SetReportEvalCallback(
base::Bind(&dom::CspDelegate::ReportEval,
base::Unretained(window_->document()->csp_delegate())));
global_environment_->SetReportErrorCallback(
base::Bind(&WebModule::Impl::ReportScriptError, base::Unretained(this)));
InjectCustomWindowAttributes(data.options.injected_window_attributes);
if (!data.options.loaded_callbacks.empty()) {
document_load_observer_.reset(
new DocumentLoadedObserver(data.options.loaded_callbacks));
window_->document()->AddObserver(document_load_observer_.get());
}
#if defined(ENABLE_PARTIAL_LAYOUT_CONTROL)
window_->document()->SetPartialLayout(data.options.enable_partial_layout);
#endif // defined(ENABLE_PARTIAL_LAYOUT_CONTROL)
#if defined(ENABLE_DEBUGGER)
debug_overlay_.reset(
new debug::backend::RenderOverlay(render_tree_produced_callback_));
debug_module_.reset(new debug::backend::DebugModule(
&debugger_hooks_, window_->console(), global_environment_.get(),
debug_overlay_.get(), resource_provider_, window_,
data.options.debugger_state));
#endif // ENABLE_DEBUGGER
is_running_ = true;
}
WebModule::Impl::~Impl() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(is_running_);
is_running_ = false;
global_environment_->SetReportEvalCallback(base::Closure());
global_environment_->SetReportErrorCallback(
script::GlobalEnvironment::ReportErrorCallback());
window_->DispatchEvent(new dom::Event(base::Tokens::unload()));
document_load_observer_.reset();
media_session_client_.reset();
#if defined(ENABLE_DEBUGGER)
debug_module_.reset();
debug_overlay_.reset();
#endif // ENABLE_DEBUGGER
// Disable callbacks for the resource caches. Otherwise, it is possible for a
// callback to occur into a DOM object that is being kept alive by a JS engine
// reference even after the DOM tree has been destroyed. This can result in a
// crash when the callback attempts to access a stale Document pointer.
DisableCallbacksInResourceCaches();
topmost_event_target_.reset();
layout_manager_.reset();
environment_settings_.reset();
window_weak_.reset();
window_->ClearPointerStateForShutdown();
window_ = NULL;
media_source_registry_.reset();
blob_registry_.reset();
script_runner_.reset();
execution_state_.reset();
global_environment_ = NULL;
javascript_engine_.reset();
web_module_stat_tracker_.reset();
local_storage_database_.reset();
mesh_cache_.reset();
remote_typeface_cache_.reset();
image_cache_.reset();
animated_image_tracker_.reset();
fetcher_factory_.reset();
dom_parser_.reset();
css_parser_.reset();
}
void WebModule::Impl::InjectInputEvent(scoped_refptr<dom::Element> element,
const scoped_refptr<dom::Event>& event) {
TRACE_EVENT1("cobalt::browser", "WebModule::Impl::InjectInputEvent()",
"event", event->type().c_str());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(is_running_);
DCHECK(window_);
if (element) {
element->DispatchEvent(event);
} else {
if (dom::PointerState::CanQueueEvent(event)) {
// As an optimization we batch together pointer/mouse events for as long
// as we can get away with it (e.g. until a non-pointer event is received
// or whenever the next layout occurs).
window_->document()->pointer_state()->QueuePointerEvent(event);
} else {
// In order to maintain the correct input event ordering, we first
// dispatch any queued pending pointer events.
HandlePointerEvents();
window_->InjectEvent(event);
}
}
}
#if SB_HAS(ON_SCREEN_KEYBOARD)
void WebModule::Impl::InjectOnScreenKeyboardInputEvent(
scoped_refptr<dom::Element> element, base::Token type,
const dom::InputEventInit& event) {
scoped_refptr<dom::InputEvent> input_event(
new dom::InputEvent(type, window_, event));
InjectInputEvent(element, input_event);
}
void WebModule::Impl::InjectOnScreenKeyboardShownEvent(int ticket) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(is_running_);
DCHECK(window_);
DCHECK(window_->on_screen_keyboard());
window_->on_screen_keyboard()->DispatchShowEvent(ticket);
}
void WebModule::Impl::InjectOnScreenKeyboardHiddenEvent(int ticket) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(is_running_);
DCHECK(window_);
DCHECK(window_->on_screen_keyboard());
window_->on_screen_keyboard()->DispatchHideEvent(ticket);
}
void WebModule::Impl::InjectOnScreenKeyboardFocusedEvent(int ticket) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(is_running_);
DCHECK(window_);
DCHECK(window_->on_screen_keyboard());
window_->on_screen_keyboard()->DispatchFocusEvent(ticket);
}
void WebModule::Impl::InjectOnScreenKeyboardBlurredEvent(int ticket) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(is_running_);
DCHECK(window_);
DCHECK(window_->on_screen_keyboard());
window_->on_screen_keyboard()->DispatchBlurEvent(ticket);
}
#if SB_API_VERSION >= 11
void WebModule::Impl::InjectOnScreenKeyboardSuggestionsUpdatedEvent(
int ticket) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(is_running_);
DCHECK(window_);
DCHECK(window_->on_screen_keyboard());
window_->on_screen_keyboard()->DispatchSuggestionsUpdatedEvent(ticket);
}
#endif // SB_API_VERSION >= 11
#endif // SB_HAS(ON_SCREEN_KEYBOARD)
void WebModule::Impl::InjectKeyboardEvent(scoped_refptr<dom::Element> element,
base::Token type,
const dom::KeyboardEventInit& event) {
scoped_refptr<dom::KeyboardEvent> keyboard_event(
new dom::KeyboardEvent(type, window_, event));
InjectInputEvent(element, keyboard_event);
}
void WebModule::Impl::InjectPointerEvent(scoped_refptr<dom::Element> element,
base::Token type,
const dom::PointerEventInit& event) {
scoped_refptr<dom::PointerEvent> pointer_event(
new dom::PointerEvent(type, window_, event));
InjectInputEvent(element, pointer_event);
}
void WebModule::Impl::InjectWheelEvent(scoped_refptr<dom::Element> element,
base::Token type,
const dom::WheelEventInit& event) {
scoped_refptr<dom::WheelEvent> wheel_event(
new dom::WheelEvent(type, window_, event));
InjectInputEvent(element, wheel_event);
}
void WebModule::Impl::ExecuteJavascript(
const std::string& script_utf8, const base::SourceLocation& script_location,
base::WaitableEvent* got_result, std::string* result, bool* out_succeeded) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(is_running_);
DCHECK(script_runner_);
// JavaScript is being run. Track it in the global stats.
dom::GlobalStats::GetInstance()->StartJavaScriptEvent();
// This should only be called for Cobalt JavaScript, error reports are
// allowed.
*result = script_runner_->Execute(script_utf8, script_location,
false /*mute_errors*/, out_succeeded);
// JavaScript is done running. Stop tracking it in the global stats.
dom::GlobalStats::GetInstance()->StopJavaScriptEvent();
got_result->Signal();
}
void WebModule::Impl::ClearAllIntervalsAndTimeouts() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(window_);
window_->DestroyTimers();
}
void WebModule::Impl::OnRanAnimationFrameCallbacks() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(is_running_);
// Notify the stat tracker that the animation frame callbacks have finished.
// This may end the current event being tracked.
web_module_stat_tracker_->OnRanAnimationFrameCallbacks(
layout_manager_->IsRenderTreePending());
}
void WebModule::Impl::OnRenderTreeProduced(
const LayoutResults& layout_results) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(is_running_);
last_render_tree_produced_time_ = base::TimeTicks::Now();
is_render_tree_rasterization_pending_ = true;
web_module_stat_tracker_->OnRenderTreeProduced(
last_render_tree_produced_time_);
LayoutResults layout_results_with_callback(
layout_results.render_tree, layout_results.layout_time,
base::Bind(&WebModule::Impl::OnRenderTreeRasterized,
base::Unretained(this),
base::MessageLoop::current()->task_runner(),
last_render_tree_produced_time_));
#if defined(ENABLE_DEBUGGER)
debug_overlay_->OnRenderTreeProduced(layout_results_with_callback);
#else // ENABLE_DEBUGGER
render_tree_produced_callback_.Run(layout_results_with_callback);
#endif // ENABLE_DEBUGGER
}
void WebModule::Impl::OnRenderTreeRasterized(
scoped_refptr<base::SingleThreadTaskRunner> web_module_message_loop,
const base::TimeTicks& produced_time) {
web_module_message_loop->PostTask(
FROM_HERE, base::Bind(&WebModule::Impl::ProcessOnRenderTreeRasterized,
base::Unretained(this), produced_time,
base::TimeTicks::Now()));
}
void WebModule::Impl::ProcessOnRenderTreeRasterized(
const base::TimeTicks& produced_time,
const base::TimeTicks& rasterized_time) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
web_module_stat_tracker_->OnRenderTreeRasterized(produced_time,
rasterized_time);
if (produced_time >= last_render_tree_produced_time_) {
is_render_tree_rasterization_pending_ = false;
}
}
void WebModule::Impl::CancelSynchronousLoads() {
synchronous_loader_interrupt_.Signal();
}
void WebModule::Impl::OnCspPolicyChanged() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(is_running_);
DCHECK(window_);
DCHECK(window_->document());
DCHECK(window_->document()->csp_delegate());
std::string eval_disabled_message;
bool allow_eval =
window_->document()->csp_delegate()->AllowEval(&eval_disabled_message);
if (allow_eval) {
global_environment_->EnableEval();
} else {
global_environment_->DisableEval(eval_disabled_message);
}
}
bool WebModule::Impl::ReportScriptError(
const script::ErrorReport& error_report) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(is_running_);
DCHECK(window_);
return window_->ReportScriptError(error_report);
}
#if defined(ENABLE_WEBDRIVER)
void WebModule::Impl::CreateWindowDriver(
const webdriver::protocol::WindowId& window_id,
std::unique_ptr<webdriver::WindowDriver>* window_driver_out) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(is_running_);
DCHECK(window_);
DCHECK(window_weak_);
DCHECK(window_->document());
DCHECK(global_environment_);
window_driver_out->reset(new webdriver::WindowDriver(
window_id, window_weak_,
base::Bind(&WebModule::Impl::global_environment, base::Unretained(this)),
base::Bind(&WebModule::Impl::InjectKeyboardEvent, base::Unretained(this)),
base::Bind(&WebModule::Impl::InjectPointerEvent, base::Unretained(this)),
base::MessageLoop::current()->task_runner()));
}
#endif // defined(ENABLE_WEBDRIVER)
#if defined(ENABLE_DEBUGGER)
void WebModule::Impl::WaitForWebDebugger() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(debug_module_);
LOG(WARNING) << "\n-------------------------------------"
"\n Waiting for web debugger to connect "
"\n-------------------------------------";
// This blocks until the web debugger connects.
debug_module_->debug_dispatcher()->SetPaused(true);
wait_for_web_debugger_finished_.Signal();
}
#endif // defined(ENABLE_DEBUGGER)
void WebModule::Impl::InjectCustomWindowAttributes(
const Options::InjectedWindowAttributes& attributes) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(global_environment_);
for (Options::InjectedWindowAttributes::const_iterator iter =
attributes.begin();
iter != attributes.end(); ++iter) {
global_environment_->Bind(
iter->first, iter->second.Run(window_, &mutation_observer_task_manager_,
global_environment_.get()));
}
}
void WebModule::Impl::SetImageCacheCapacity(int64_t bytes) {
image_cache_->SetCapacity(static_cast<uint32>(bytes));
}
void WebModule::Impl::SetRemoteTypefaceCacheCapacity(int64_t bytes) {
remote_typeface_cache_->SetCapacity(static_cast<uint32>(bytes));
}
void WebModule::Impl::SetSize(cssom::ViewportSize window_dimensions,
float video_pixel_ratio) {
// A value of 0.0 for the video pixel ratio means that the ratio could not be
// determined. In that case it should be assumed to be the same as the
// graphics resolution, which corresponds to a device pixel ratio of 1.0.
float device_pixel_ratio =
video_pixel_ratio == 0.0f ? 1.0f : video_pixel_ratio;
window_->SetSize(window_dimensions, device_pixel_ratio);
}
void WebModule::Impl::SetCamera3D(
const scoped_refptr<input::Camera3D>& camera_3d) {
window_->SetCamera3D(camera_3d);
}
void WebModule::Impl::SetWebMediaPlayerFactory(
media::WebMediaPlayerFactory* web_media_player_factory) {
window_->set_web_media_player_factory(web_media_player_factory);
media_session_client_->SetMediaPlayerFactory(web_media_player_factory);
}
void WebModule::Impl::SetApplicationState(base::ApplicationState state) {
window_->SetApplicationState(state);
}
void WebModule::Impl::SetResourceProvider(
render_tree::ResourceProvider* resource_provider) {
resource_provider_ = resource_provider;
if (resource_provider_) {
base::TypeId resource_provider_type_id = resource_provider_->GetTypeId();
// Check for if the resource provider type id has changed. If it has, then
// anything contained within the caches is invalid and must be purged.
if (resource_provider_type_id_ != resource_provider_type_id) {
PurgeResourceCaches(false);
}
resource_provider_type_id_ = resource_provider_type_id;
loader_factory_->Resume(resource_provider_);
// Permit render trees to be generated again. Layout will have been
// invalidated with the call to Suspend(), so the layout manager's first
// task will be to perform a full re-layout.
layout_manager_->Resume();
}
}
void WebModule::Impl::OnStartDispatchEvent(
const scoped_refptr<dom::Event>& event) {
web_module_stat_tracker_->OnStartDispatchEvent(event);
}
void WebModule::Impl::OnStopDispatchEvent(
const scoped_refptr<dom::Event>& event) {
web_module_stat_tracker_->OnStopDispatchEvent(
event, window_->HasPendingAnimationFrameCallbacks(),
layout_manager_->IsRenderTreePending());
}
void WebModule::Impl::Start(render_tree::ResourceProvider* resource_provider) {
TRACE_EVENT0("cobalt::browser", "WebModule::Impl::Start()");
SetResourceProvider(resource_provider);
SetApplicationState(base::kApplicationStateStarted);
}
void WebModule::Impl::Pause() {
TRACE_EVENT0("cobalt::browser", "WebModule::Impl::Pause()");
SetApplicationState(base::kApplicationStatePaused);
}
void WebModule::Impl::Unpause() {
TRACE_EVENT0("cobalt::browser", "WebModule::Impl::Unpause()");
synchronous_loader_interrupt_.Reset();
SetApplicationState(base::kApplicationStateStarted);
}
void WebModule::Impl::SuspendLoaders(bool update_application_state) {
TRACE_EVENT0("cobalt::browser", "WebModule::Impl::SuspendLoaders()");
if (update_application_state) {
SetApplicationState(base::kApplicationStateSuspended);
}
// Purge the resource caches before running any suspend logic. This will force
// any pending callbacks that the caches are batching to run.
PurgeResourceCaches(should_retain_remote_typeface_cache_on_suspend_);
// Stop the generation of render trees.
layout_manager_->Suspend();
// Purge the cached resources prior to the suspend. That may cancel pending
// loads, allowing the suspend to occur faster and preventing unnecessary
// callbacks.
window_->document()->PurgeCachedResources();
// Clear out the loader factory's resource provider, possibly aborting any
// in-progress loads.
loader_factory_->Suspend();
// Clear out any currently tracked animating images.
animated_image_tracker_->Reset();
}
void WebModule::Impl::FinishSuspend() {
TRACE_EVENT0("cobalt::browser", "WebModule::Impl::FinishSuspend()");
DCHECK(resource_provider_);
// Ensure the document is not holding onto any more image cached resources so
// that they are eligible to be purged.
window_->document()->PurgeCachedResources();
// Clear out all resource caches. We need to do this after we abort all
// in-progress loads, and after we clear all document references, or they will
// still be referenced and won't be cleared from the cache.
PurgeResourceCaches(should_retain_remote_typeface_cache_on_suspend_);
#if defined(ENABLE_DEBUGGER)
// The debug overlay may be holding onto a render tree, clear that out.
debug_overlay_->ClearInput();
#endif
resource_provider_ = NULL;
// Force garbage collection in |javascript_engine_|.
if (javascript_engine_) {
javascript_engine_->CollectGarbage();
}
}
void WebModule::Impl::Resume(render_tree::ResourceProvider* resource_provider) {
TRACE_EVENT0("cobalt::browser", "WebModule::Impl::Resume()");
synchronous_loader_interrupt_.Reset();
SetResourceProvider(resource_provider);
SetApplicationState(base::kApplicationStatePaused);
}
void WebModule::Impl::ReduceMemory() {
TRACE_EVENT0("cobalt::browser", "WebModule::Impl::ReduceMemory()");
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (!is_running_) {
return;
}
synchronous_loader_interrupt_.Reset();
layout_manager_->Purge();
// Retain the remote typeface cache when reducing memory.
PurgeResourceCaches(true /*should_retain_remote_typeface_cache*/);
window_->document()->PurgeCachedResources();
// Force garbage collection in |javascript_engine_|.
if (javascript_engine_) {
javascript_engine_->CollectGarbage();
}
}
void WebModule::Impl::GetJavaScriptHeapStatistics(
const JavaScriptHeapStatisticsCallback& callback) {
TRACE_EVENT0("cobalt::browser",
"WebModule::Impl::GetJavaScriptHeapStatistics()");
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
script::HeapStatistics heap_statistics =
javascript_engine_->GetHeapStatistics();
callback.Run(heap_statistics);
}
void WebModule::Impl::LogScriptError(
const base::SourceLocation& source_location,
const std::string& error_message) {
std::string file_name =
base::FilePath(source_location.file_path).BaseName().value();
std::stringstream ss;
base::TimeDelta dt = base::StartupTimer::TimeElapsed();
// Create the error output.
// Example:
// JS:50250:file.js(29,80): ka(...) is not iterable
// JS:<time millis><js-file-name>(<line>,<column>):<message>
ss << "JS:" << dt.InMilliseconds() << ":" << file_name << "("
<< source_location.line_number << "," << source_location.column_number
<< "): " << error_message << "\n";
SbLogRaw(ss.str().c_str());
}
void WebModule::Impl::InjectBeforeUnloadEvent() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (window_ && window_->HasEventListener(base::Tokens::beforeunload())) {
window_->DispatchEvent(new dom::Event(base::Tokens::beforeunload()));
} else if (!on_before_unload_fired_but_not_handled_.is_null()) {
on_before_unload_fired_but_not_handled_.Run();
}
}
void WebModule::Impl::InjectCaptionSettingsChangedEvent() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
system_caption_settings_->OnCaptionSettingsChanged();
}
void WebModule::Impl::PurgeResourceCaches(
bool should_retain_remote_typeface_cache) {
image_cache_->Purge();
if (should_retain_remote_typeface_cache) {
remote_typeface_cache_->ProcessPendingCallbacks();
} else {
remote_typeface_cache_->Purge();
}
mesh_cache_->Purge();
}
void WebModule::Impl::DisableCallbacksInResourceCaches() {
image_cache_->DisableCallbacks();
remote_typeface_cache_->DisableCallbacks();
mesh_cache_->DisableCallbacks();
}
void WebModule::Impl::HandlePointerEvents() {
TRACE_EVENT0("cobalt::browser", "WebModule::Impl::HandlePointerEvents");
const scoped_refptr<dom::Document>& document = window_->document();
scoped_refptr<dom::Event> event;
do {
event = document->pointer_state()->GetNextQueuedPointerEvent();
if (event) {
SB_DCHECK(
window_ ==
base::polymorphic_downcast<const dom::UIEvent* const>(event.get())
->view());
if (!topmost_event_target_) {
topmost_event_target_.reset(new layout::TopmostEventTarget());
}
topmost_event_target_->MaybeSendPointerEvents(event);
}
} while (event && !layout_manager_->IsRenderTreePending());
}
WebModule::DestructionObserver::DestructionObserver(WebModule* web_module)
: web_module_(web_module) {}
void WebModule::DestructionObserver::WillDestroyCurrentMessageLoop() {
web_module_->impl_.reset();
}
WebModule::Options::Options()
: name("WebModule"),
layout_trigger(layout::LayoutManager::kOnDocumentMutation),
mesh_cache_capacity(COBALT_MESH_CACHE_SIZE_IN_BYTES) {}
WebModule::WebModule(
const GURL& initial_url, base::ApplicationState initial_application_state,
const OnRenderTreeProducedCallback& render_tree_produced_callback,
const OnErrorCallback& error_callback,
const CloseCallback& window_close_callback,
const base::Closure& window_minimize_callback,
media::CanPlayTypeHandler* can_play_type_handler,
media::WebMediaPlayerFactory* web_media_player_factory,
network::NetworkModule* network_module,
const ViewportSize& window_dimensions, float video_pixel_ratio,
render_tree::ResourceProvider* resource_provider, float layout_refresh_rate,
const Options& options)
: thread_(options.name.c_str()),
ui_nav_root_(new ui_navigation::NavItem(
ui_navigation::kNativeItemTypeContainer,
// Currently, events do not need to be processed for the root item.
base::Closure(), base::Closure(), base::Closure())) {
ConstructionData construction_data(
initial_url, initial_application_state, render_tree_produced_callback,
error_callback, window_close_callback, window_minimize_callback,
can_play_type_handler, web_media_player_factory, network_module,
window_dimensions, video_pixel_ratio, resource_provider,
kDOMMaxElementDepth, layout_refresh_rate, ui_nav_root_, options);
// Start the dedicated thread and create the internal implementation
// object on that thread.
base::Thread::Options thread_options(base::MessageLoop::TYPE_DEFAULT,
cobalt::browser::kWebModuleStackSize);
thread_options.priority = options.thread_priority;
thread_.StartWithOptions(thread_options);
DCHECK(message_loop());
// Block this thread until the initialization is complete.
// TODO: Figure out why this is necessary.
// It would be preferable to return immediately and let the WebModule
// continue in its own time, but without this wait there is a race condition
// such that inline scripts may be executed before the document elements they
// operate on are present.
message_loop()->task_runner()->PostBlockingTask(
FROM_HERE, base::Bind(&WebModule::Initialize, base::Unretained(this),
construction_data));
}
WebModule::~WebModule() {
DCHECK(message_loop());
// Create a destruction observer to shut down the WebModule once all pending
// tasks have been executed and the message loop is about to be destroyed.
// This allows us to safely stop the thread, drain the task queue, then
// destroy the internal components before the message loop is set to NULL.
// No posted tasks will be executed once the thread is stopped.
DestructionObserver destruction_observer(this);
message_loop()->task_runner()->PostBlockingTask(
FROM_HERE, base::Bind(&base::MessageLoop::AddDestructionObserver,
base::Unretained(message_loop()),
base::Unretained(&destruction_observer)));
// This will cancel the timers for tasks, which help the thread exit
ClearAllIntervalsAndTimeouts();
// Stop the thread. This will cause the destruction observer to be notified.
thread_.Stop();
}
void WebModule::Initialize(const ConstructionData& data) {
DCHECK_EQ(base::MessageLoop::current(), message_loop());
impl_.reset(new Impl(data));
}
#if SB_HAS(ON_SCREEN_KEYBOARD)
void WebModule::InjectOnScreenKeyboardInputEvent(
base::Token type, const dom::InputEventInit& event) {
TRACE_EVENT1("cobalt::browser",
"WebModule::InjectOnScreenKeyboardInputEvent()", "type",
type.c_str());
DCHECK(message_loop());
DCHECK(impl_);
message_loop()->task_runner()->PostTask(
FROM_HERE, base::Bind(&WebModule::Impl::InjectOnScreenKeyboardInputEvent,
base::Unretained(impl_.get()),
scoped_refptr<dom::Element>(), type, event));
}
void WebModule::InjectOnScreenKeyboardShownEvent(int ticket) {
TRACE_EVENT1("cobalt::browser",
"WebModule::InjectOnScreenKeyboardShownEvent()", "ticket",
ticket);
DCHECK(message_loop());
DCHECK(impl_);
message_loop()->task_runner()->PostTask(
FROM_HERE, base::Bind(&WebModule::Impl::InjectOnScreenKeyboardShownEvent,
base::Unretained(impl_.get()), ticket));
}
void WebModule::InjectOnScreenKeyboardHiddenEvent(int ticket) {
TRACE_EVENT1("cobalt::browser",
"WebModule::InjectOnScreenKeyboardHiddenEvent()", "ticket",
ticket);
DCHECK(message_loop());
DCHECK(impl_);
message_loop()->task_runner()->PostTask(
FROM_HERE, base::Bind(&WebModule::Impl::InjectOnScreenKeyboardHiddenEvent,
base::Unretained(impl_.get()), ticket));
}
void WebModule::InjectOnScreenKeyboardFocusedEvent(int ticket) {
TRACE_EVENT1("cobalt::browser",
"WebModule::InjectOnScreenKeyboardFocusedEvent()", "ticket",
ticket);
DCHECK(message_loop());
DCHECK(impl_);
message_loop()->task_runner()->PostTask(
FROM_HERE,
base::Bind(&WebModule::Impl::InjectOnScreenKeyboardFocusedEvent,
base::Unretained(impl_.get()), ticket));
}
void WebModule::InjectOnScreenKeyboardBlurredEvent(int ticket) {
TRACE_EVENT1("cobalt::browser",
"WebModule::InjectOnScreenKeyboardBlurredEvent()", "ticket",
ticket);
DCHECK(message_loop());
DCHECK(impl_);
message_loop()->task_runner()->PostTask(
FROM_HERE,
base::Bind(&WebModule::Impl::InjectOnScreenKeyboardBlurredEvent,
base::Unretained(impl_.get()), ticket));
}
#if SB_API_VERSION >= 11
void WebModule::InjectOnScreenKeyboardSuggestionsUpdatedEvent(int ticket) {
TRACE_EVENT1("cobalt::browser",
"WebModule::InjectOnScreenKeyboardSuggestionsUpdatedEvent()",
"ticket", ticket);
DCHECK(message_loop());
DCHECK(impl_);
message_loop()->task_runner()->PostTask(
FROM_HERE,
base::Bind(
&WebModule::Impl::InjectOnScreenKeyboardSuggestionsUpdatedEvent,
base::Unretained(impl_.get()), ticket));
}
#endif // SB_API_VERSION >= 11
#endif // SB_HAS(ON_SCREEN_KEYBOARD)
void WebModule::InjectKeyboardEvent(base::Token type,
const dom::KeyboardEventInit& event) {
TRACE_EVENT1("cobalt::browser", "WebModule::InjectKeyboardEvent()", "type",
type.c_str());
DCHECK(message_loop());
DCHECK(impl_);
message_loop()->task_runner()->PostTask(
FROM_HERE, base::Bind(&WebModule::Impl::InjectKeyboardEvent,
base::Unretained(impl_.get()),
scoped_refptr<dom::Element>(), type, event));
}
void WebModule::InjectPointerEvent(base::Token type,
const dom::PointerEventInit& event) {
TRACE_EVENT1("cobalt::browser", "WebModule::InjectPointerEvent()", "type",
type.c_str());
DCHECK(message_loop());
DCHECK(impl_);
message_loop()->task_runner()->PostTask(
FROM_HERE, base::Bind(&WebModule::Impl::InjectPointerEvent,
base::Unretained(impl_.get()),
scoped_refptr<dom::Element>(), type, event));
}
void WebModule::InjectWheelEvent(base::Token type,
const dom::WheelEventInit& event) {
TRACE_EVENT1("cobalt::browser", "WebModule::InjectWheelEvent()", "type",
type.c_str());
DCHECK(message_loop());
DCHECK(impl_);
message_loop()->task_runner()->PostTask(
FROM_HERE, base::Bind(&WebModule::Impl::InjectWheelEvent,
base::Unretained(impl_.get()),
scoped_refptr<dom::Element>(), type, event));
}
void WebModule::InjectBeforeUnloadEvent() {
TRACE_EVENT0("cobalt::browser", "WebModule::InjectBeforeUnloadEvent()");
DCHECK(message_loop());
DCHECK(impl_);
message_loop()->task_runner()->PostTask(
FROM_HERE, base::Bind(&WebModule::Impl::InjectBeforeUnloadEvent,
base::Unretained(impl_.get())));
}
void WebModule::InjectCaptionSettingsChangedEvent() {
TRACE_EVENT0("cobalt::browser",
"WebModule::InjectCaptionSettingsChangedEvent()");
DCHECK(message_loop());
DCHECK(impl_);
message_loop()->task_runner()->PostTask(
FROM_HERE, base::Bind(&WebModule::Impl::InjectCaptionSettingsChangedEvent,
base::Unretained(impl_.get())));
}
std::string WebModule::ExecuteJavascript(
const std::string& script_utf8, const base::SourceLocation& script_location,
bool* out_succeeded) {
TRACE_EVENT0("cobalt::browser", "WebModule::ExecuteJavascript()");
DCHECK(message_loop());
DCHECK(impl_);
base::WaitableEvent got_result(
base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
std::string result;
message_loop()->task_runner()->PostTask(
FROM_HERE,
base::Bind(&WebModule::Impl::ExecuteJavascript,
base::Unretained(impl_.get()), script_utf8, script_location,
&got_result, &result, out_succeeded));
got_result.Wait();
return result;
}
void WebModule::ClearAllIntervalsAndTimeouts() {
TRACE_EVENT0("cobalt::browser", "WebModule::ClearAllIntervalsAndTimeouts()");
DCHECK(message_loop());
DCHECK(impl_);
if (impl_) {
message_loop()->task_runner()->PostTask(
FROM_HERE, base::Bind(&WebModule::Impl::ClearAllIntervalsAndTimeouts,
base::Unretained(impl_.get())));
}
}
#if defined(ENABLE_WEBDRIVER)
std::unique_ptr<webdriver::WindowDriver> WebModule::CreateWindowDriver(
const webdriver::protocol::WindowId& window_id) {
DCHECK(message_loop());
DCHECK(impl_);
std::unique_ptr<webdriver::WindowDriver> window_driver;
message_loop()->task_runner()->PostBlockingTask(
FROM_HERE, base::Bind(&WebModule::Impl::CreateWindowDriver,
base::Unretained(impl_.get()), window_id,
base::Unretained(&window_driver)));
return window_driver;
}
#endif // defined(ENABLE_WEBDRIVER)
#if defined(ENABLE_DEBUGGER)
// May be called from any thread.
debug::backend::DebugDispatcher* WebModule::GetDebugDispatcher() {
DCHECK(impl_);
return impl_->debug_dispatcher();
}
std::unique_ptr<debug::backend::DebuggerState> WebModule::FreezeDebugger() {
DCHECK(message_loop());
DCHECK(impl_);
std::unique_ptr<debug::backend::DebuggerState> debugger_state;
message_loop()->task_runner()->PostBlockingTask(
FROM_HERE, base::Bind(&WebModule::Impl::FreezeDebugger,
base::Unretained(impl_.get()),
base::Unretained(&debugger_state)));
return debugger_state;
}
#endif // defined(ENABLE_DEBUGGER)
void WebModule::SetSize(const ViewportSize& viewport_size,
float video_pixel_ratio) {
message_loop()->task_runner()->PostTask(
FROM_HERE,
base::Bind(&WebModule::Impl::SetSize, base::Unretained(impl_.get()),
viewport_size, video_pixel_ratio));
}
void WebModule::SetCamera3D(const scoped_refptr<input::Camera3D>& camera_3d) {
message_loop()->task_runner()->PostTask(
FROM_HERE, base::Bind(&WebModule::Impl::SetCamera3D,
base::Unretained(impl_.get()), camera_3d));
}
void WebModule::SetWebMediaPlayerFactory(
media::WebMediaPlayerFactory* web_media_player_factory) {
message_loop()->task_runner()->PostTask(
FROM_HERE,
base::Bind(&WebModule::Impl::SetWebMediaPlayerFactory,
base::Unretained(impl_.get()), web_media_player_factory));
}
void WebModule::SetImageCacheCapacity(int64_t bytes) {
message_loop()->task_runner()->PostTask(
FROM_HERE, base::Bind(&WebModule::Impl::SetImageCacheCapacity,
base::Unretained(impl_.get()), bytes));
}
void WebModule::SetRemoteTypefaceCacheCapacity(int64_t bytes) {
message_loop()->task_runner()->PostTask(
FROM_HERE, base::Bind(&WebModule::Impl::SetRemoteTypefaceCacheCapacity,
base::Unretained(impl_.get()), bytes));
}
void WebModule::Prestart() {
// Must only be called by a thread external from the WebModule thread.
DCHECK_NE(base::MessageLoop::current(), message_loop());
// We must block here so that we don't queue the finish until after
// SuspendLoaders has run to completion, and therefore has already queued any
// precipitate tasks.
message_loop()->task_runner()->PostBlockingTask(
FROM_HERE, base::Bind(&WebModule::Impl::SuspendLoaders,
base::Unretained(impl_.get()),
false /*update_application_state*/));
// We must block here so that the call doesn't return until the web
// application has had a chance to process the whole event.
message_loop()->task_runner()->PostBlockingTask(
FROM_HERE, base::Bind(&WebModule::Impl::FinishSuspend,
base::Unretained(impl_.get())));
}
void WebModule::Start(render_tree::ResourceProvider* resource_provider) {
// Must only be called by a thread external from the WebModule thread.
DCHECK_NE(base::MessageLoop::current(), message_loop());
message_loop()->task_runner()->PostTask(
FROM_HERE, base::Bind(&WebModule::Impl::Start,
base::Unretained(impl_.get()), resource_provider));
}
void WebModule::Pause() {
// Must only be called by a thread external from the WebModule thread.
DCHECK_NE(base::MessageLoop::current(), message_loop());
impl_->CancelSynchronousLoads();
auto impl_pause =
base::Bind(&WebModule::Impl::Pause, base::Unretained(impl_.get()));
#if defined(ENABLE_DEBUGGER)
// We normally need to block here so that the call doesn't return until the
// web application has had a chance to process the whole event. However, our
// message loop is blocked while waiting for the web debugger to connect, so
// we would deadlock here if the user switches to Chrome to run devtools on
// the same machine where Cobalt is running. Therefore, while we're still
// waiting for the debugger we post the pause task without blocking on it,
// letting it eventually run when the debugger connects and the message loop
// is unblocked again.
if (!impl_->IsFinishedWaitingForWebDebugger()) {
message_loop()->task_runner()->PostTask(FROM_HERE, impl_pause);
return;
}
#endif // defined(ENABLE_DEBUGGER)
message_loop()->task_runner()->PostBlockingTask(FROM_HERE, impl_pause);
}
void WebModule::Unpause() {
// Must only be called by a thread external from the WebModule thread.
DCHECK_NE(base::MessageLoop::current(), message_loop());
message_loop()->task_runner()->PostTask(
FROM_HERE,
base::Bind(&WebModule::Impl::Unpause, base::Unretained(impl_.get())));
}
void WebModule::Suspend() {
// Must only be called by a thread external from the WebModule thread.
DCHECK_NE(base::MessageLoop::current(), message_loop());
impl_->CancelSynchronousLoads();
// We must block here so that we don't queue the finish until after
// SuspendLoaders has run to completion, and therefore has already queued any
// precipitate tasks.
message_loop()->task_runner()->PostBlockingTask(
FROM_HERE, base::Bind(&WebModule::Impl::SuspendLoaders,
base::Unretained(impl_.get()),
true /*update_application_state*/));
// We must block here so that the call doesn't return until the web
// application has had a chance to process the whole event.
message_loop()->task_runner()->PostBlockingTask(
FROM_HERE, base::Bind(&WebModule::Impl::FinishSuspend,
base::Unretained(impl_.get())));
}
void WebModule::Resume(render_tree::ResourceProvider* resource_provider) {
// Must only be called by a thread external from the WebModule thread.
DCHECK_NE(base::MessageLoop::current(), message_loop());
message_loop()->task_runner()->PostTask(
FROM_HERE, base::Bind(&WebModule::Impl::Resume,
base::Unretained(impl_.get()), resource_provider));
}
void WebModule::ReduceMemory() {
// Must only be called by a thread external from the WebModule thread.
DCHECK_NE(base::MessageLoop::current(), message_loop());
impl_->CancelSynchronousLoads();
// We block here so that we block the Low Memory event handler until we have
// reduced our memory consumption.
message_loop()->task_runner()->PostBlockingTask(
FROM_HERE, base::Bind(&WebModule::Impl::ReduceMemory,
base::Unretained(impl_.get())));
}
void WebModule::RequestJavaScriptHeapStatistics(
const JavaScriptHeapStatisticsCallback& callback) {
// Must only be called by a thread external from the WebModule thread.
DCHECK_NE(base::MessageLoop::current(), message_loop());
message_loop()->task_runner()->PostTask(
FROM_HERE, base::Bind(&WebModule::Impl::GetJavaScriptHeapStatistics,
base::Unretained(impl_.get()), callback));
}
} // namespace browser
} // namespace cobalt
| [
"trofimov_d_a@magnit.ru"
] | trofimov_d_a@magnit.ru |
6cd4fe04b4cefae46f73b63c85d7360278f9d6f2 | 8380b5eb12e24692e97480bfa8939a199d067bce | /Carberp Botnet/source - absource/pro/all source/DropSploit/src/share/splice.cpp | 429b61a14dee31e22a2172d4cdeee1ca78ec9b4f | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | RamadhanAmizudin/malware | 788ee745b5bb23b980005c2af08f6cb8763981c2 | 62d0035db6bc9aa279b7c60250d439825ae65e41 | refs/heads/master | 2023-02-05T13:37:18.909646 | 2023-01-26T08:43:18 | 2023-01-26T08:43:18 | 53,407,812 | 873 | 291 | null | 2023-01-26T08:43:19 | 2016-03-08T11:44:21 | C++ | UTF-8 | C++ | false | false | 2,181 | cpp | #include <windows.h>
#include <stdio.h>
#pragma warning(push)
#pragma warning(disable:4005)
#include "ntdll.h"
#pragma warning(pop)
#include "splice.h"
#include "zdisasm.h"
#include "utils.h"
VOID CreateJump(PVOID pvFrom,PVOID pvTo,PBYTE pbJmp)
{
pbJmp[0] = (UCHAR)0xE9;
*(PDWORD)((DWORD)pbJmp + 1) = (DWORD)pvTo - (DWORD)pvFrom - 5;
}
VOID Splice(PVOID pvAddr,PVOID pvNew,PVOID pvOldAddr)
{
BYTE bBuffer[JMP_SIZE];
DWORD dwSum = 0;
DWORD dwLen = 0;
DWORD Bytes;
VirtualProtect(pvOldAddr,OLD_BYTES_SIZE,PAGE_EXECUTE_READWRITE,&Bytes);
while (dwSum < JMP_SIZE)
{
GetInstLength((PDWORD)((DWORD)pvAddr + dwSum),&dwLen);
RtlCopyMemory((PVOID)((DWORD)pvOldAddr + dwSum),(PVOID)((DWORD)pvAddr + dwSum),dwLen);
if (*(PBYTE)((DWORD)pvOldAddr + dwSum) == 0xE8 || *(PBYTE)((DWORD)pvOldAddr + dwSum) == 0xE9)
{
*(PDWORD)((DWORD)pvOldAddr + dwSum + 1) -= ((DWORD)pvOldAddr + dwSum) - ((DWORD)pvAddr + dwSum);
}
USHORT w = MAKEWORD(*(PBYTE)((DWORD)pvOldAddr + dwSum + 1),*(PBYTE)((DWORD)pvOldAddr + dwSum));
if ((w & 0xFFF0) == 0xF80)
{
*(PDWORD)((DWORD)pvOldAddr + dwSum + 2) -= ((DWORD)pvOldAddr + dwSum) - ((DWORD)pvAddr + dwSum);
}
dwSum += dwLen;
}
CreateJump((PVOID)((DWORD)pvOldAddr + dwSum),(PVOID)((DWORD)pvAddr + dwSum),(PBYTE)((DWORD)pvOldAddr + dwSum));
CreateJump(pvAddr,pvNew,bBuffer);
if (!WriteProcessMemory(NtCurrentProcess(),pvAddr,bBuffer,JMP_SIZE,&Bytes))
{
DbgPrint(__FUNCTION__"(): WriteProcessMemory failed with error %lx\n",GetLastError());
}
}
VOID Unsplice(PVOID pvAddr,PVOID pvOldAddr)
{
if (*(PBYTE)((DWORD)pvOldAddr) == 0xE8 || *(PBYTE)((DWORD)pvOldAddr) == 0xE9)
{
*(PDWORD)((DWORD)pvOldAddr + 1) += ((DWORD)pvOldAddr) - ((DWORD)pvAddr);
}
USHORT w = MAKEWORD(*(PBYTE)((DWORD)pvOldAddr + 1),*(PBYTE)((DWORD)pvOldAddr));
if ((w & 0xFFF0) == 0xF80)
{
*(PDWORD)((DWORD)pvOldAddr + 2) += ((DWORD)pvOldAddr) - ((DWORD)pvAddr);
}
DWORD Bytes;
if (!WriteProcessMemory(NtCurrentProcess(),pvAddr,pvOldAddr,JMP_SIZE,&Bytes))
{
DbgPrint(__FUNCTION__"(): WriteProcessMemory failed with error %lx\n",GetLastError());
}
} | [
"fdiskyou@users.noreply.github.com"
] | fdiskyou@users.noreply.github.com |
cf5ef33c3afa5dd16bf641c3db77d8bcbdfe417a | a6e668c73557b1d2fb25850d54796c1a44246c25 | /KinectTable/Network/FrameType.h | f5daee173df613264c126a019072d76de1ac8e52 | [] | no_license | ricelab/KinectArms | 3a9a88b94d7c8ed7b72d5d8ccbf85b9761bc9568 | b3c927758cc5b737f48941d7c01de10459c950b4 | refs/heads/master | 2021-05-06T11:20:10.408921 | 2014-02-04T06:06:13 | 2014-02-04T06:06:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 670 | h | #ifndef NETWORK__FRAME_TYPE_H
#define NETWORK__FRAME_TYPE_H
// Module Check //
#ifndef MOD_NETWORK
#error "Files outside module cannot access file directly."
#endif
//
// These functions send and receive user requests on the network.
//
// Includes //
// Project
#include "DataTypes/DataTypes.h"
// Standard C
// Namespaces //
namespace Network
{
// Data //
struct FrameType
{
typedef char Type;
typedef enum
{
// Server
Subscribe = 0,
DataParams,
//SpecialDataRequest,
// Client
SubscribeAck,
Data,
//SpecialData,
// Common
Unsubscribe,
Info,
InfoRequest
};
private: FrameType() {}
};
}
#endif
| [
"izenja@gmail.com"
] | izenja@gmail.com |
19a68634303591cf5a347e084ffeb2804a4e5e5b | 5d45f4cebbcbe8e3b0085fe5fd3a8c645922f31f | /Applied_C++/framework/unittests/ipp/main.cpp | bdbe71a412f0e70a889d8aa1720753184899254c | [
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | SeadogAhn/EssentialCppExamples | 25553aa7d9f6068414c3a5e01d22d969badd5704 | 6a79e960a6594bc96ee6e7fd6816b6eec9404318 | refs/heads/master | 2020-04-05T16:53:50.795971 | 2019-08-27T12:35:55 | 2019-08-27T12:35:55 | 157,033,487 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 14,755 | cpp | // main.cpp
//
// Copyright (c) 2003 Philip Romanik, Amy Muntz
//
// Permission to use, copy, modify, distribute, and sell this software and
// its documentation for any purpose is hereby granted without fee, provided
// that (i) the above copyright notices and this permission notice appear in
// all copies of the software and related documentation, and (ii) the names
// of Philip Romanik and Amy Muntz may not be used in any advertising or
// publicity relating to the software without the specific, prior written
// permission of Philip Romanik and Amy Muntz.
//
// Use of this software and/or its documentation will be deemed to be
// acceptance of these terms.
//
// THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
// EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
// WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
//
// IN NO EVENT SHALL PHILIP ROMANIK OR AMY MUNTZ BE LIABLE FOR
// ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
// OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
// WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
// LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
// OF THIS SOFTWARE.
//
//
// Unit Test for Intel IPP interface class
#include "image/image.h"
#include "image/convolve.h"
#include "ipp/ippWrapper.h"
#include "fastTiming.h" // For hires timing
#include "unitTest.h"
// Ruler
// 1 2 3 4 5 6 6
//345678901234567890123456789012345678901234567890123456789012345
#ifdef RGB
#undef RGB
#endif
UTFUNC(testing)
{
apRect boundary (0, 0, 30, 30);
apImage<Pel8> image1 (boundary);
apIPP<Pel8> wrapper (image1);
}
UTFUNC (laplacian3x3dump)
{
setDescription ("laplacian3x3 dump");
apRect boundary1 (0, 0, 16, 16);
apImage<Pel8> byteImage1 (boundary1, apRectImageStorage::e16ByteAlign);
apImage<Pel8> byteImage2 (boundary1, apRectImageStorage::e16ByteAlign);
byteImage1.set (1);
byteImage1.setPixel (apPoint(8,8), 2);
byteImage2.set (255);
apImage<Pel8>::row_iterator i;
for (i=byteImage1.row_begin(); i != byteImage1.row_end(); i++) {
const Pel8* p = i->p;
std::cout << i->x << ", " << i->y << ": ";
for (unsigned int x=0; x<byteImage1.width(); x++)
std::cout << (Pel32s) *p++ << " ";
std::cout << std::endl;
}
IppStatus result = IPPLaplacian3x3<Pel8>::filter (byteImage1, byteImage2);
VERIFY (result == 0);
for (i=byteImage2.row_begin(); i != byteImage2.row_end(); i++) {
const Pel8* p = i->p;
std::cout << i->x << ", " << i->y << ": ";
for (unsigned int x=0; x<byteImage2.width(); x++)
std::cout << (Pel32s) *p++ << " ";
std::cout << std::endl;
}
}
UTFUNC (laplacian3x3colordump)
{
setDescription ("laplacian3x3 color dump");
apRect boundary1 (0, 0, 16, 16);
apImage<apRGB> colorImage1 (boundary1, apRectImageStorage::e16ByteAlign);
apImage<apRGB> colorImage2 (boundary1, apRectImageStorage::e16ByteAlign);
colorImage1.set (apRGB(1));
colorImage1.setPixel (apPoint(8,8), apRGB(2));
colorImage2.set (apRGB(255));
apImage<apRGB>::row_iterator i;
for (i=colorImage1.row_begin(); i != colorImage1.row_end(); i++) {
const apRGB* p = i->p;
std::cout << i->x << ", " << i->y << ": ";
for (unsigned int x=0; x<colorImage1.width(); x++)
std::cout << (Pel32s) *p++ << " ";
std::cout << std::endl;
}
IppStatus result = IPPLaplacian3x3<apRGB>::filter (colorImage1, colorImage2);
VERIFY (result == 0);
for (i=colorImage2.row_begin(); i != colorImage2.row_end(); i++) {
const apRGB* p = i->p;
std::cout << i->x << ", " << i->y << ": ";
for (unsigned int x=0; x<colorImage2.width(); x++)
std::cout << *p++ << " ";
std::cout << std::endl;
}
}
UTFUNC (laplacian5x5dump)
{
setDescription ("laplacian5x5 dump");
apRect boundary1 (0, 0, 16, 16);
apImage<Pel8> byteImage1 (boundary1, apRectImageStorage::e16ByteAlign);
apImage<Pel8> byteImage2 (boundary1, apRectImageStorage::e16ByteAlign);
byteImage1.set (1);
byteImage1.setPixel (apPoint(8,8), 2);
byteImage2.set (255);
apImage<Pel8>::row_iterator i;
for (i=byteImage1.row_begin(); i != byteImage1.row_end(); i++) {
const Pel8* p = i->p;
std::cout << i->x << ", " << i->y << ": ";
for (unsigned int x=0; x<byteImage1.width(); x++)
std::cout << (Pel32s) *p++ << " ";
std::cout << std::endl;
}
IppStatus result = IPPLaplacian5x5<Pel8>::filter (byteImage1, byteImage2);
VERIFY (result == 0);
for (i=byteImage2.row_begin(); i != byteImage2.row_end(); i++) {
const Pel8* p = i->p;
std::cout << i->x << ", " << i->y << ": ";
for (unsigned int x=0; x<byteImage2.width(); x++)
std::cout << (Pel32s) *p++ << " ";
std::cout << std::endl;
}
}
UTFUNC (laplacian3x3large)
{
setDescription ("laplacian3x3 large");
apRect boundary1 (0, 0, 1024, 1024);
apImage<Pel8> byteImage1 (boundary1, apRectImageStorage::e16ByteAlign);
apImage<Pel8> byteImage2 (boundary1, apRectImageStorage::e16ByteAlign);
byteImage1.set (1);
byteImage1.setPixel (apPoint(byteImage1.width()/2,byteImage1.height()/2), 2);
byteImage2.set (255);
apHiResElapsedTime timer;
IppStatus result = IPPLaplacian3x3<Pel8>::filter (byteImage1, byteImage2);
double msec = timer.msec ();
std::cout << "1024x1024 byte laplacian in " << msec << " msec" << std::endl;
// Compare results with our image
apImage<Pel8> byteImage3 (boundary1);
byteImage3.set (255);
apHiResElapsedTime timer2;
laplacian3x3<Pel32s> (byteImage1, byteImage3);
double msec2 = timer2.msec ();
std::cout << "1024x1024 byte laplacian (our version) in " << msec2 << " msec" << std::endl;
// Compare results with our image (slower way)
char kernel[] = {-1, -1, -1, -1, 8, -1, -1, -1, -1};
apImage<Pel8> byteImage4 (boundary1);
byteImage4.set (255);
apHiResElapsedTime timer3;
convolve<Pel32s> (byteImage1, kernel, 3, 1, byteImage4);
double msec3 = timer3.msec ();
std::cout << "1024x1024 byte laplacian (our convolve version) in " << msec3 << " msec" << std::endl;
VERIFY (byteImage2 == byteImage3);
VERIFY (byteImage3 == byteImage4);
VERIFY (result == 0);
}
UTFUNC (laplacian3x3colorlarge)
{
setDescription ("laplacian3x3 color large");
apRect boundary1 (0, 0, 1024, 1024);
apImage<apRGB> colorImage1 (boundary1, apRectImageStorage::e16ByteAlign);
apImage<apRGB> colorImage2 (boundary1, apRectImageStorage::e16ByteAlign);
colorImage1.set (apRGB(1));
colorImage1.setPixel (apPoint(colorImage1.width()/2,colorImage1.height()/2), apRGB(2));
colorImage2.set (apRGB(255));
apHiResElapsedTime timer;
IppStatus result = IPPLaplacian3x3<apRGB>::filter (colorImage1, colorImage2);
double msec = timer.msec ();
std::cout << "1024x1024 rgb laplacian in " << msec << " msec" << std::endl;
VERIFY (result == 0);
// Compare results with our image (slower way)
char kernel[] = {-1, -1, -1, -1, 8, -1, -1, -1, -1};
apImage<apRGB> colorImage3 (boundary1, apRectImageStorage::e16ByteAlign);
colorImage3.set (apRGB(255));
apHiResElapsedTime timer2;
convolve<apRGBPel32s> (colorImage1, kernel, 3, 1, colorImage3);
double msec2 = timer2.msec ();
apImage<apRGB> colorImage4 (boundary1, apRectImageStorage::e16ByteAlign);
colorImage4.set (apRGB(255));
apHiResElapsedTime timer3;
laplacian3x3<apRGBPel32s> (colorImage1, colorImage4);
double msec3 = timer3.msec ();
std::cout << "1024x1024 rgb laplacian (our convolve version) in " << msec2 << " msec" << std::endl;
std::cout << "1024x1024 rgb laplacian (our version) in " << msec3 << " msec" << std::endl;
VERIFY (colorImage2 == colorImage3);
VERIFY (colorImage2 == colorImage4);
}
UTFUNC (laplacian5x5large)
{
setDescription ("laplacian5x5 large");
apRect boundary1 (0, 0, 1024, 1024);
apImage<Pel8> byteImage1 (boundary1, apRectImageStorage::e16ByteAlign);
apImage<Pel8> byteImage2 (boundary1, apRectImageStorage::e16ByteAlign);
byteImage1.set (1);
byteImage1.setPixel (apPoint(byteImage1.width()/2,byteImage1.height()/2), 2);
byteImage2.set (255);
apHiResElapsedTime timer;
IppStatus result = IPPLaplacian5x5<Pel8>::filter (byteImage1, byteImage2);
double msec = timer.msec ();
std::cout << "1024x1024 byte 5x5 laplacian in " << msec << " msec" << std::endl;
VERIFY (result == 0);
}
/*
UTFUNC(testbyte)
{
setDescription ("test byte");
// This image is NOT aligned
apRect boundary (0, 0, 30, 30);
apImage<Pel8> image1 (boundary);
apImage<Pel8> image2 (boundary);
image1.set (1);
// Regular
apIPPTools<Pel8>::laplacian3x3 (image1, image2);
// Dest created
apImage<Pel8> image3 = apIPPTools<Pel8>::laplacian3x3 (image1);
// Window
apRect boundary4 (1, 10, 10, 10);
apImage<Pel8> image4 (boundary4);
apIPPTools<Pel8>::laplacian3x3 (image1, image4);
// In place
apIPPTools<Pel8>::laplacian3x3 (image1, image1);
VERIFY (image2 == image3);
apImage<Pel8>::row_iterator i;
for (i=image1.row_begin(); i != image1.row_end(); i++) {
const Pel8* p = i->p;
std::cout << i->x << ", " << i->y << ": ";
for (int x=0; x<image1.width(); x++)
std::cout << (Pel32s) *p++ << " ";
std::cout << std::endl;
}
for (i=image2.row_begin(); i != image2.row_end(); i++) {
const Pel8* p = i->p;
std::cout << i->x << ", " << i->y << ": ";
for (int x=0; x<image2.width(); x++)
std::cout << (Pel32s) *p++ << " ";
std::cout << std::endl;
}
for (i=image4.row_begin(); i != image4.row_end(); i++) {
const Pel8* p = i->p;
std::cout << i->x << ", " << i->y << ": ";
for (int x=0; x<image4.width(); x++)
std::cout << (Pel32s) *p++ << " ";
std::cout << std::endl;
}
}
UTFUNC(testbytea)
{
setDescription ("test bytea");
// This image is NOT aligned
apRect boundary (0, 0, 30, 30);
apImage<Pel8> image1 (boundary);
image1.set (1);
apRect boundary3 (1, 10, 10, 10);
apImage<Pel8> image3 = image1;
image3.window (boundary3);
// In-place to a window
apIPPTools<Pel8>::laplacian3x3 (image3, image3);
apImage<Pel8>::row_iterator i;
for (i=image1.row_begin(); i != image1.row_end(); i++) {
const Pel8* p = i->p;
std::cout << i->x << ", " << i->y << ": ";
for (int x=0; x<image1.width(); x++)
std::cout << (Pel32s) *p++ << " ";
std::cout << std::endl;
}
}
UTFUNC(testlong)
{
setDescription ("test long");
// This image is aligned
apRect boundary (0, 0, 30, 30);
apImage<Pel32s> image1 (boundary);
apImage<Pel32s> image2 (boundary);
image1.set (1);
// Regular
apIPPTools<Pel32s>::laplacian3x3 (image1, image2);
// Dest created
apImage<Pel32s> image3 = apIPPTools<Pel32s>::laplacian3x3 (image1);
// Window
apRect boundary4 (1, 10, 10, 10);
apImage<Pel32s> image4 (boundary4);
apIPPTools<Pel32s>::laplacian3x3 (image1, image4);
// In place
apIPPTools<Pel32s>::laplacian3x3 (image1, image1);
VERIFY (image2 == image3);
apImage<Pel32s>::row_iterator i;
for (i=image1.row_begin(); i != image1.row_end(); i++) {
const Pel32s* p = i->p;
std::cout << i->x << ", " << i->y << ": ";
for (int x=0; x<image1.width(); x++)
std::cout << (Pel32s) *p++ << " ";
std::cout << std::endl;
}
for (i=image2.row_begin(); i != image2.row_end(); i++) {
const Pel32s* p = i->p;
std::cout << i->x << ", " << i->y << ": ";
for (int x=0; x<image2.width(); x++)
std::cout << (Pel32s) *p++ << " ";
std::cout << std::endl;
}
for (i=image4.row_begin(); i != image4.row_end(); i++) {
const Pel32s* p = i->p;
std::cout << i->x << ", " << i->y << ": ";
for (int x=0; x<image4.width(); x++)
std::cout << (Pel32s) *p++ << " ";
std::cout << std::endl;
}
}
UTFUNC(testrgb)
{
setDescription ("test rgb");
// This image is aligned
apRect boundary (0, 0, 30, 30);
apImage<apRGB> image1 (boundary);
apImage<apRGB> image2 (boundary);
image1.set (apRGB(1));
// Regular
apIPPTools<apRGB>::laplacian3x3 (image1, image2);
// Dest created
apImage<apRGB> image3 = apIPPTools<apRGB>::laplacian3x3 (image1);
// Window
apRect boundary4 (1, 10, 10, 10);
apImage<apRGB> image4 (boundary4);
apIPPTools<apRGB>::laplacian3x3 (image1, image4);
// In place
apIPPTools<apRGB>::laplacian3x3 (image1, image1);
VERIFY (image2 == image3);
apImage<apRGB>::row_iterator i;
for (i=image1.row_begin(); i != image1.row_end(); i++) {
const apRGB* p = i->p;
std::cout << i->x << ", " << i->y << ": ";
for (int x=0; x<image1.width(); x++)
std::cout << *p++ << " ";
std::cout << std::endl;
}
for (i=image2.row_begin(); i != image2.row_end(); i++) {
const apRGB* p = i->p;
std::cout << i->x << ", " << i->y << ": ";
for (int x=0; x<image2.width(); x++)
std::cout << *p++ << " ";
std::cout << std::endl;
}
for (i=image4.row_begin(); i != image4.row_end(); i++) {
const apRGB* p = i->p;
std::cout << i->x << ", " << i->y << ": ";
for (int x=0; x<image4.width(); x++)
std::cout << *p++ << " ";
std::cout << std::endl;
}
}
UTFUNC(testrgblong)
{
setDescription ("test rgb long");
// This image is aligned
apRect boundary (0, 0, 30, 30);
apImage<apRGBPel32s> image1 (boundary);
apImage<apRGBPel32s> image2 (boundary);
image1.set (apRGBPel32s(1));
// Regular
apIPPTools<apRGBPel32s>::laplacian3x3 (image1, image2);
// Dest created
apImage<apRGBPel32s> image3 = apIPPTools<apRGBPel32s>::laplacian3x3 (image1);
// Window
apRect boundary4 (1, 10, 10, 10);
apImage<apRGBPel32s> image4 (boundary4);
apIPPTools<apRGBPel32s>::laplacian3x3 (image1, image4);
// In place
apIPPTools<apRGBPel32s>::laplacian3x3 (image1, image1);
VERIFY (image2 == image3);
apImage<apRGBPel32s>::row_iterator i;
for (i=image1.row_begin(); i != image1.row_end(); i++) {
const apRGBPel32s* p = i->p;
std::cout << i->x << ", " << i->y << ": ";
for (int x=0; x<image1.width(); x++)
std::cout << *p++ << " ";
std::cout << std::endl;
}
for (i=image2.row_begin(); i != image2.row_end(); i++) {
const apRGBPel32s* p = i->p;
std::cout << i->x << ", " << i->y << ": ";
for (int x=0; x<image2.width(); x++)
std::cout << *p++ << " ";
std::cout << std::endl;
}
for (i=image4.row_begin(); i != image4.row_end(); i++) {
const apRGBPel32s* p = i->p;
std::cout << i->x << ", " << i->y << ": ";
for (int x=0; x<image4.width(); x++)
std::cout << *p++ << " ";
std::cout << std::endl;
}
}
*/
// Our main function is trivial
int main()
{
bool state = apUnitTest::gOnly().run ();
apUnitTest::gOnly().dumpResults (std::cout);
return state;
}
| [
"seadog.ahn@gmail.com"
] | seadog.ahn@gmail.com |
0d31a146aa149af043f87fd7f0cdefcba8d28cdf | 58ff41d171b3bf5668889127234d61471d024061 | /examples/Generic/Lock/nRF52_Ethernet_Lock/nRF52_Ethernet_Lock.ino | 6fc58f3aa2578c62a190dd16347937320f0b4d21 | [
"CC-BY-4.0",
"CC-BY-2.0"
] | permissive | ivankravets/SinricPro_Generic | bfe127429e5abbedb527ad3904352f34f6fe792d | 59b2001cf9b9d5ba7e847b44f92ef307e671cbf4 | refs/heads/master | 2022-11-06T15:13:51.686961 | 2020-06-03T16:09:22 | 2020-06-03T16:09:22 | 276,103,454 | 0 | 0 | null | 2020-06-30T13:15:48 | 2020-06-30T13:15:48 | null | UTF-8 | C++ | false | false | 9,895 | ino | /****************************************************************************************************************************
nRF52_WiFiNINA_Lock.ino
For Adafruit nRF52 boards, running W5x00 or ENC28J60 Ethernet shield
Based on and modified from SinricPro libarary (https://github.com/sinricpro/)
to support other boards such as SAMD21, SAMD51, Adafruit's nRF52 boards, etc.
Built by Khoi Hoang https://github.com/khoih-prog/SinricPro_Generic
Licensed under MIT license
Version: 2.4.0
Copyright (c) 2019 Sinric. All rights reserved.
Licensed under Creative Commons Attribution-Share Alike (CC BY-SA)
This file is part of the Sinric Pro (https://github.com/sinricpro/)
Example for smart lock
Version Modified By Date Comments
------- ----------- ---------- -----------
2.4.0 K Hoang 21/05/2020 Initial porting to support SAMD21, SAMD51 nRF52 boards, such as AdaFruit Itsy-Bitsy,
Feather, Gemma, Trinket, Hallowing Metro M0/M4, NRF52840 Feather, Itsy-Bitsy, STM32, etc.
*****************************************************************************************************************************/
// Uncomment the following line to enable serial debug output
#define ENABLE_DEBUG true
#if ENABLE_DEBUG
#define DEBUG_PORT Serial
#define NODEBUG_WEBSOCKETS
#define NDEBUG
#endif
#define LOGWARN(x) if(ENABLE_DEBUG) { Serial.print("[SINRIC_PRO] "); Serial.println(x); }
#define LOGWARN1(x,y) if(ENABLE_DEBUG) { Serial.print("[SINRIC_PRO] "); Serial.print(x);\
Serial.print(" "); Serial.println(y); }
#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \
defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \
defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) | defined(NINA_B302_ublox) )
#if defined(ETHERNET_USE_NRF52)
#undef ETHERNET_USE_NRF52
#endif
#define ETHERNET_USE_NRF52 true
#else
#error This code is intended to run only on the Adafruit nRF52 boards ! Please check your Tools->Board setting.
#endif
#if defined(NRF52840_FEATHER)
#define BOARD_TYPE "NRF52840_FEATHER"
#elif defined(NRF52832_FEATHER)
#define BOARD_TYPE "NRF52832_FEATHER"
#elif defined(NRF52840_FEATHER_SENSE)
#define BOARD_TYPE "NRF52840_FEATHER_SENSE"
#elif defined(NRF52840_ITSYBITSY)
#define BOARD_TYPE "NRF52840_ITSYBITSY"
#elif defined(NRF52840_CIRCUITPLAY)
#define BOARD_TYPE "NRF52840_CIRCUITPLAY"
#elif defined(NRF52840_CLUE)
#define BOARD_TYPE "NRF52840_CLUE"
#elif defined(NRF52840_METRO)
#define BOARD_TYPE "NRF52840_METRO"
#elif defined(NRF52840_PCA10056)
#define BOARD_TYPE "NRF52840_PCA10056"
#elif defined(PARTICLE_XENON)
#define BOARD_TYPE "PARTICLE_XENON"
#elif defined(NRF52840_FEATHER)
#define BOARD_TYPE "NRF52840_FEATHER"
#elif defined(NINA_B302_ublox)
#define BOARD_TYPE "NINA_B302_ublox"
#elif defined(ARDUINO_NRF52_ADAFRUIT)
#define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT"
#elif defined(NRF52_SERIES)
#define BOARD_TYPE "NRF52_SERIES"
#else
#define BOARD_TYPE "NRF52_UNKNOWN"
#endif
// Use true for ENC28J60 and UIPEthernet library (https://github.com/UIPEthernet/UIPEthernet)
// Use false for W5x00 and Ethernetx library (https://www.arduino.cc/en/Reference/Ethernet)
//#define USE_UIP_ETHERNET true
//#define USE_UIP_ETHERNET false
#if USE_UIP_ETHERNET
#define WEBSOCKETS_NETWORK_TYPE NETWORK_ENC28J60
#endif
//#define USE_CUSTOM_ETHERNET true
// Note: To rename ESP628266 Ethernet lib files to Ethernet_ESP8266.h and Ethernet_ESP8266.cpp
// In order to USE_ETHERNET_ESP8266
#if ( !defined(USE_UIP_ETHERNET) || !USE_UIP_ETHERNET )
// To override the default CS/SS pin. Don't use unless you know exactly which pin to use
//#define USE_THIS_SS_PIN 27//22 //21 //5 //4 //2 //15
// Only one if the following to be true
#define USE_ETHERNET2 false //true
#define USE_ETHERNET3 false //true
#define USE_ETHERNET_LARGE false //true
#define USE_ETHERNET_ESP8266 false //true
#if ( USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE || USE_ETHERNET_ESP8266 )
#ifdef USE_CUSTOM_ETHERNET
#undef USE_CUSTOM_ETHERNET
#endif
#define USE_CUSTOM_ETHERNET true
#endif
#ifdef WEBSOCKETS_NETWORK_TYPE
#undef WEBSOCKETS_NETWORK_TYPE
#endif
#define WEBSOCKETS_NETWORK_TYPE NETWORK_W5100
#if USE_ETHERNET3
#include "Ethernet3.h"
#warning Use Ethernet3 lib
#elif USE_ETHERNET2
#include "Ethernet2.h"
#warning Use Ethernet2 lib
#elif USE_ETHERNET_LARGE
#include "EthernetLarge.h"
#warning Use EthernetLarge lib
#elif USE_ETHERNET_ESP8266
#include "Ethernet_ESP8266.h"
#warning Use Ethernet_ESP8266 lib
#elif USE_CUSTOM_ETHERNET
#include "Ethernet_XYZ.h"
#warning Use Custom Ethernet library from EthernetWrapper. You must include a library here or error.
#else
#define USE_ETHERNET true
#include "Ethernet.h"
#warning Use Ethernet lib
#endif
// Ethernet_Shield_W5200, EtherCard, EtherSia not supported
// Select just 1 of the following #include if uncomment #define USE_CUSTOM_ETHERNET
// Otherwise, standard Ethernet library will be used for W5x00
#endif //#if !USE_UIP_ETHERNET
// Enter a MAC address and IP address for your controller below.
#define NUMBER_OF_MAC 20
byte mac[][NUMBER_OF_MAC] =
{
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 },
};
#include "SinricPro_Generic.h"
#include "SinricProLock.h"
// Select the IP address according to your local network
IPAddress ip(192, 168, 2, 222);
#define APP_KEY "YOUR-APP-KEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx"
#define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx"
#define LOCK_ID "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx"
#define BAUD_RATE 115200 // Change baudrate to your need
bool onLockState(String deviceId, bool &lockState)
{
Serial.println("Device " + deviceId + String(lockState ? "locked" : "unlocked"));
return true;
}
// setup function for setupEthernet connection
void setupEthernet()
{
#if USE_ETHERNET
LOGWARN(F("=========== USE_ETHERNET ==========="));
#elif USE_ETHERNET2
LOGWARN(F("=========== USE_ETHERNET2 ==========="));
#elif USE_ETHERNET3
LOGWARN(F("=========== USE_ETHERNET3 ==========="));
#elif USE_ETHERNET_LARGE
LOGWARN(F("=========== USE_ETHERNET_LARGE ==========="));
#elif USE_ETHERNET_ESP8266
LOGWARN(F("=========== USE_ETHERNET_ESP8266 ==========="));
#else
LOGWARN(F("========================="));
#endif
LOGWARN(F("Default SPI pinout:"));
LOGWARN1(F("MOSI:"), MOSI);
LOGWARN1(F("MISO:"), MISO);
LOGWARN1(F("SCK:"), SCK);
LOGWARN1(F("SS:"), SS);
LOGWARN(F("========================="));
// unknown board, do nothing, use default SS = 10
#ifndef USE_THIS_SS_PIN
#define USE_THIS_SS_PIN 10 // For other boards
#endif
LOGWARN1(F("Use default CS/SS pin : "), USE_THIS_SS_PIN);
// For other boards, to change if necessary
#if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 )
// Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries
Ethernet.init (USE_THIS_SS_PIN);
#elif USE_ETHERNET3
// Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer
#ifndef ETHERNET3_MAX_SOCK_NUM
#define ETHERNET3_MAX_SOCK_NUM 4
#endif
Ethernet.setCsPin (USE_THIS_SS_PIN);
Ethernet.init (ETHERNET3_MAX_SOCK_NUM);
#endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE )
// start the ethernet connection and the server:
// Use Static IP
//Ethernet.begin(mac, ip);
// Use DHCP dynamic IP and random mac
srand(millis());
uint16_t index = rand() % NUMBER_OF_MAC;
Serial.print("Index = ");
Serial.println(index);
Ethernet.begin(mac[index]);
Serial.print("Connected!\n[Ethernet]: IP-Address is ");
Serial.println(Ethernet.localIP());
}
void setupSinricPro()
{
SinricProLock &myLock = SinricPro[LOCK_ID];
myLock.onLockState(onLockState);
// setup SinricPro
SinricPro.onConnected([]()
{
Serial.println("Connected to SinricPro");
});
SinricPro.onDisconnected([]()
{
Serial.println("Disconnected from SinricPro");
});
SinricPro.begin(APP_KEY, APP_SECRET);
}
// main setup function
void setup()
{
Serial.begin(BAUD_RATE);
while (!Serial);
#if defined(BOARD_TYPE)
Serial.println("\nStarting nRF52_Ethernet_Lock on " + String(BOARD_TYPE));
#else
Serial.println("\nStarting nRF52_Ethernet_Lock on unknown nRF52 board");
#endif
setupEthernet();
setupSinricPro();
}
void loop()
{
SinricPro.handle();
}
| [
"noreply@github.com"
] | noreply@github.com |
32bf4ee20c29cf46dd9b73a46faa4adcb56ca35d | ec531afa1332332e5b6bc95cd3de56ecc0a4092c | /Devices/UcaLightSensor/sensorservices.h | a2837bc8b2087c8afea771c5dbb951ce63e9de96 | [
"BSD-2-Clause"
] | permissive | bkmiller/uca-devices | 4d3631bd87b65d9f4fc9ab9d81455d0bac046683 | 31118b7a20b689da71722399cde2884b0a188cfb | refs/heads/master | 2021-01-21T02:23:44.956069 | 2014-12-03T13:01:47 | 2014-12-03T13:01:47 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,402 | h | #ifndef SENSORSERVICES_H
#define SENSORSERVICES_H
#include <UcaStack/iupnpservice.h>
#include <UcaStack/failable.h>
class QDir;
struct ServiceInfo;
void loadServices( QDomDocument *deviceDescription
, QHash<QString, ServiceInfo *> &infos
, const QDir &rootDirectory
);
class SensorTransportGenericService : public IUPnPService
{
private:
const QString _id;
const QString _type;
const QUrl _scdpPath;
const QUrl _controlUrl;
const QUrl _eventUrl;
const QDomDocument *_description;
const QStringList _variables;
public:
SensorTransportGenericService(const ServiceInfo *description);
/* IUPnPService implementation: */
QMap<QString, QString> handleSOAP( const QString &actionName
, const QHash<QString, QString> &arguments
);
const QDomDocument &getServiceDescription() const { return *_description; }
const QString getServiceId() const { return _id; }
const QString getServiceType() const { return _type; }
const QUrl getScdpPath() const { return _scdpPath; }
const QUrl getControlUrl() const { return _controlUrl; }
const QUrl getEventUrl() const { return _eventUrl; }
const QStringList getEventedVariableNames() const { return _variables; }
};
class ConfigurationManagementService : public IUPnPService
{
private:
const QString _id;
const QString _type;
const QUrl _scdpPath;
const QUrl _controlUrl;
const QUrl _eventUrl;
const QDomDocument *_description;
const QStringList _variables;
public:
ConfigurationManagementService(const ServiceInfo *description);
/* IUPnPService implementation: */
QMap<QString, QString> handleSOAP( const QString &actionName
, const QHash<QString, QString> &arguments
);
const QDomDocument &getServiceDescription() const { return *_description; }
const QString getServiceId() const { return _id; }
const QString getServiceType() const { return _type; }
const QUrl getScdpPath() const { return _scdpPath; }
const QUrl getControlUrl() const { return _controlUrl; }
const QUrl getEventUrl() const { return _eventUrl; }
const QStringList getEventedVariableNames() const { return _variables; }
};
#endif // SENSORSERVICES_H
| [
"comarch-technologies-github@comarch.com"
] | comarch-technologies-github@comarch.com |
761175c3c8360862752df7c8044f0ac230e5ff22 | 56b94ffc8f4dcb39908399201d38b78f4f8c2376 | /tests/parser/149.cpp | 54cf0762c8ee4680ad022e836c31db772451f401 | [] | no_license | helviett/Tiny_C_Compiler | 99f7a5187eea701bf95f090c2efbb34e6326baf9 | 0968c89884e50386911913b3c6703fe4ce31e10f | refs/heads/master | 2021-09-07T06:58:44.035998 | 2018-02-19T05:53:30 | 2018-02-19T05:53:30 | 106,104,684 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 54 | cpp | int main()
{
struct A {int a;} a;
a ? 1 : 2;
} | [
"keltarhelviett@gmail.com"
] | keltarhelviett@gmail.com |
6c273dea7695f1bd2e883a6fbf959aaaa2f01f0f | 578057387314e1796fb3b16cb95b71f7a23410d6 | /tests/unittests/lit_cases/test_tensorrt/test_range_float_type_positive_delta_expanded_tensorrt.cc | 01234ef1cbb2a8a5bfbc1f7b409d575758551a0e | [
"Apache-2.0"
] | permissive | alibaba/heterogeneity-aware-lowering-and-optimization | 986b417eb8e4d229fc8cc6e77bb4eff5c6fa654d | 966d4aa8f72f42557df58a4f56a7d44b88068e80 | refs/heads/master | 2023-08-28T22:15:13.439329 | 2023-01-06T00:39:07 | 2023-01-06T07:26:38 | 289,420,807 | 256 | 94 | Apache-2.0 | 2023-06-13T10:38:25 | 2020-08-22T04:45:46 | C++ | UTF-8 | C++ | false | false | 2,512 | cc | //===-test_range_float_type_positive_delta_expanded_tensorrt.cc-----------------------------------------------------------===//
//
// Copyright (C) 2019-2020 Alibaba Group Holding Limited.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// =============================================================================
// clang-format off
// Testing CXX Code Gen using ODLA API on tensorrt
// RUN: %halo_compiler -target cxx -o %data_path/test_range_float_type_positive_delta_expanded/test_data_set_0/input_0.cc -x onnx -emit-data-as-c %data_path/test_range_float_type_positive_delta_expanded/test_data_set_0/input_0.pb
// RUN: %halo_compiler -target cxx -o %data_path/test_range_float_type_positive_delta_expanded/test_data_set_0/output_0.cc -x onnx -emit-data-as-c %data_path/test_range_float_type_positive_delta_expanded/test_data_set_0/output_0.pb
// RUN: %halo_compiler -target cxx -o %data_path/test_range_float_type_positive_delta_expanded/test_data_set_0/input_1.cc -x onnx -emit-data-as-c %data_path/test_range_float_type_positive_delta_expanded/test_data_set_0/input_1.pb
// RUN: %halo_compiler -target cxx -o %data_path/test_range_float_type_positive_delta_expanded/test_data_set_0/input_2.cc -x onnx -emit-data-as-c %data_path/test_range_float_type_positive_delta_expanded/test_data_set_0/input_2.pb
// RUN: %halo_compiler -target cxx -batch-size 1 %halo_compile_flags %data_path/test_range_float_type_positive_delta_expanded/model.onnx -o %t.cc
// RUN: %cxx -c -fPIC -o %t.o %t.cc -I%odla_path/include
// RUN: %cxx -g %s %t.o %t.bin -I%T -I%odla_path/include -I%unittests_path -I%data_path/test_range_float_type_positive_delta_expanded/test_data_set_0 %odla_link %device_link -lodla_tensorrt -o %t_tensorrt.exe -Wno-deprecated-declarations
// RUN: %t_tensorrt.exe 0.0001 0 tensorrt %data_path/test_range_float_type_positive_delta_expanded | FileCheck %s
// CHECK: Result Pass
// clang-format on
// XFAIL: *
#include "test_range_float_type_positive_delta_expanded_tensorrt.cc.tmp.main.cc.in"
| [
"74580362+xuhongyao@users.noreply.github.com"
] | 74580362+xuhongyao@users.noreply.github.com |
167925162001b0b9103bdcbc7dad0cb0c1dfca88 | 83579fe2404fa6585ff03120d481a105417629bf | /Iyan3D/3rdParty/include/IGUITable.h | 4f271a9bba94df3e08fd26582aa9e2c890af2629 | [
"MIT"
] | permissive | codetiger/Iyan3d | c0c71d9cec522ec7b2e50a4ad4773bcbccfb2c11 | 81ac64040e839f1f3257245f0f31c4b137adafbb | refs/heads/master | 2022-11-13T00:49:32.300763 | 2022-10-29T06:50:17 | 2022-10-29T06:50:17 | 68,989,579 | 33 | 21 | MIT | 2019-07-20T03:38:48 | 2016-09-23T04:44:00 | C | UTF-8 | C++ | false | false | 6,459 | h | // Copyright (C) 2003-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_GUI_TABLE_H_INCLUDED__
#define __I_GUI_TABLE_H_INCLUDED__
#include "IGUIElement.h"
#include "irrTypes.h"
#include "SColor.h"
#include "IGUISkin.h"
namespace irr
{
namespace gui
{
//! modes for ordering used when a column header is clicked
enum EGUI_COLUMN_ORDERING
{
//! Do not use ordering
EGCO_NONE,
//! Send a EGET_TABLE_HEADER_CHANGED message when a column header is clicked.
EGCO_CUSTOM,
//! Sort it ascending by it's ascii value like: a,b,c,...
EGCO_ASCENDING,
//! Sort it descending by it's ascii value like: z,x,y,...
EGCO_DESCENDING,
//! Sort it ascending on first click, descending on next, etc
EGCO_FLIP_ASCENDING_DESCENDING,
//! Not used as mode, only to get maximum value for this enum
EGCO_COUNT
};
//! Names for EGUI_COLUMN_ORDERING types
const c8* const GUIColumnOrderingNames[] =
{
"none",
"custom",
"ascend",
"descend",
"ascend_descend",
0,
};
enum EGUI_ORDERING_MODE
{
//! No element ordering
EGOM_NONE,
//! Elements are ordered from the smallest to the largest.
EGOM_ASCENDING,
//! Elements are ordered from the largest to the smallest.
EGOM_DESCENDING,
//! this value is not used, it only specifies the amount of default ordering types
//! available.
EGOM_COUNT
};
const c8* const GUIOrderingModeNames[] =
{
"none",
"ascending",
"descending",
0
};
enum EGUI_TABLE_DRAW_FLAGS
{
EGTDF_ROWS = 1,
EGTDF_COLUMNS = 2,
EGTDF_ACTIVE_ROW = 4,
EGTDF_COUNT
};
//! Default list box GUI element.
/** \par This element can create the following events of type EGUI_EVENT_TYPE:
\li EGET_TABLE_CHANGED
\li EGET_TABLE_SELECTED_AGAIN
\li EGET_TABLE_HEADER_CHANGED
*/
class IGUITable : public IGUIElement
{
public:
//! constructor
IGUITable(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIElement(EGUIET_TABLE, environment, parent, id, rectangle) {}
//! Adds a column
/** If columnIndex is outside the current range, do push new colum at the end */
virtual void addColumn(const wchar_t* caption, s32 columnIndex=-1) = 0;
//! remove a column from the table
virtual void removeColumn(u32 columnIndex) = 0;
//! Returns the number of columns in the table control
virtual s32 getColumnCount() const = 0;
//! Makes a column active. This will trigger an ordering process.
/** \param idx: The id of the column to make active.
\param doOrder: Do also the ordering which depending on mode for active column
\return True if successful. */
virtual bool setActiveColumn(s32 idx, bool doOrder=false) = 0;
//! Returns which header is currently active
virtual s32 getActiveColumn() const = 0;
//! Returns the ordering used by the currently active column
virtual EGUI_ORDERING_MODE getActiveColumnOrdering() const = 0;
//! Set the width of a column
virtual void setColumnWidth(u32 columnIndex, u32 width) = 0;
//! Get the width of a column
virtual u32 getColumnWidth(u32 columnIndex) const = 0;
//! columns can be resized by drag 'n drop
virtual void setResizableColumns(bool resizable) = 0;
//! can columns be resized by dran 'n drop?
virtual bool hasResizableColumns() const = 0;
//! This tells the table control which ordering mode should be used when a column header is clicked.
/** \param columnIndex The index of the column header.
\param mode: One of the modes defined in EGUI_COLUMN_ORDERING */
virtual void setColumnOrdering(u32 columnIndex, EGUI_COLUMN_ORDERING mode) = 0;
//! Returns which row is currently selected
virtual s32 getSelected() const = 0;
//! set wich row is currently selected
virtual void setSelected( s32 index ) = 0;
//! Get amount of rows in the tabcontrol
virtual s32 getRowCount() const = 0;
//! adds a row to the table
/** \param rowIndex Zero based index of rows. The row will be
inserted at this position, if a row already exist there, it
will be placed after it. If the row is larger than the actual
number of row by more than one, it won't be created. Note that
if you create a row that's not at the end, there might be
performance issues.
\return index of inserted row. */
virtual u32 addRow(u32 rowIndex) = 0;
//! Remove a row from the table
virtual void removeRow(u32 rowIndex) = 0;
//! clears the table rows, but keeps the columns intact
virtual void clearRows() = 0;
//! Swap two row positions.
virtual void swapRows(u32 rowIndexA, u32 rowIndexB) = 0;
//! This tells the table to start ordering all the rows.
/** You need to explicitly tell the table to re order the rows
when a new row is added or the cells data is changed. This
makes the system more flexible and doesn't make you pay the
cost of ordering when adding a lot of rows.
\param columnIndex: When set to -1 the active column is used.
\param mode Ordering mode of the rows. */
virtual void orderRows(s32 columnIndex=-1, EGUI_ORDERING_MODE mode=EGOM_NONE) = 0;
//! Set the text of a cell
virtual void setCellText(u32 rowIndex, u32 columnIndex, const core::stringw& text) = 0;
//! Set the text of a cell, and set a color of this cell.
virtual void setCellText(u32 rowIndex, u32 columnIndex, const core::stringw& text, video::SColor color) = 0;
//! Set the data of a cell
virtual void setCellData(u32 rowIndex, u32 columnIndex, void *data) = 0;
//! Set the color of a cell text
virtual void setCellColor(u32 rowIndex, u32 columnIndex, video::SColor color) = 0;
//! Get the text of a cell
virtual const wchar_t* getCellText(u32 rowIndex, u32 columnIndex ) const = 0;
//! Get the data of a cell
virtual void* getCellData(u32 rowIndex, u32 columnIndex ) const = 0;
//! clears the table, deletes all items in the table
virtual void clear() = 0;
//! Set flags, as defined in EGUI_TABLE_DRAW_FLAGS, which influence the layout
virtual void setDrawFlags(s32 flags) = 0;
//! Get the flags, as defined in EGUI_TABLE_DRAW_FLAGS, which influence the layout
virtual s32 getDrawFlags() const = 0;
};
} // end namespace gui
} // end namespace irr
#endif
| [
"harishankar@19668fbc-42bf-4728-acef-d3afb4f12ffe"
] | harishankar@19668fbc-42bf-4728-acef-d3afb4f12ffe |
2f5930b042c464847077b8a89141760a93ce84e1 | dc10aaa23f2c3772caed6ede025525f8a40147f4 | /src/System/Config.cpp | 82f30e3bcf05ed76b9c0593fbbe151cd85c3f0e6 | [] | no_license | Bomberman3D/BomberClient | 3516a410ae0f2aa4654a55143786d5f447902fee | 209c196ff9c2adaff4abbeabb0fb7d824d3f509b | refs/heads/master | 2020-05-30T03:45:24.366103 | 2013-04-26T09:29:13 | 2013-04-26T09:30:13 | 2,949,128 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 2,879 | cpp | #include <Global.h>
#include <Config.h>
bool Config::Load()
{
char dest[200];
//Globalni uzivatelsky config
sprintf(dest,"%s/global.set",SETTINGS_PATH);
FILE* config = fopen(dest,"r");
//Pokud neexistuje, zkusit nacist defaultni config (nemenny, dodavany autory)
if (!config)
{
sprintf(dest,"%s/default_global.set",SETTINGS_PATH);
config = fopen(dest,"r");
}
//A pokud se nenacetl soubor configu, opustit
if (!config)
return false;
//Nejake pracovni promenne
char setting[50];
char value[50];
int ivalue = 0;
unsigned int i,j;
locale loc;
while (fgets(dest, 200, config))
{
i = 0;
while (dest[i] != '=' && dest[i] != '\n')
{
setting[i] = dest[i];
i++;
}
setting[i] = '\0';
i++;
j = 0;
while (dest[i] != '\n')
{
value[j] = dest[i];
i++; j++;
}
value[j] = '\0';
//Rozpoznani nastaveni
for (int k = 0; k < strlen(setting); k++)
setting[k] = std::toupper(setting[k],loc);
ivalue = atoi(value);
if (strcmp(setting,"WINDOW_WIDTH") == 0)
if (ivalue > 0)
WindowWidth = ivalue;
if (strcmp(setting,"WINDOW_HEIGHT") == 0)
if (ivalue > 0)
WindowHeight = ivalue;
if (strcmp(setting,"COLOR_DEPTH") == 0)
if (ivalue > 0)
ColorDepth = ivalue;
if (strcmp(setting,"FULLSCREEN") == 0)
fullscreen = ivalue?true:false;
if (strcmp(setting,"REFRESH_RATE") == 0)
if (ivalue > 0)
RefreshRate = ivalue;
if (strcmp(setting,"MUSIC_VOLUME") == 0)
if (ivalue > 0)
MusicVolume = ivalue;
if (strcmp(setting,"EFFECT_VOLUME") == 0)
if (ivalue > 0)
EffectVolume = ivalue;
if (strcmp(setting,"HOST") == 0)
HostName = value;
if (strcmp(setting,"PORT") == 0)
if (ivalue > 0)
NetworkPort = ivalue;
}
return true;
}
void Config::Save()
{
char dest[200];
//Globalni uzivatelsky config
sprintf(dest,"%s/global.set",SETTINGS_PATH);
FILE* config = fopen(dest,"w");
if (!config)
return;
fprintf(config, "WINDOW_WIDTH=%u\n", WindowWidth);
fprintf(config, "WINDOW_HEIGHT=%u\n", WindowHeight);
fprintf(config, "COLOR_DEPTH=%u\n", ColorDepth);
fprintf(config, "FULLSCREEN=%u\n", fullscreen?1:0);
fprintf(config, "REFRESH_RATE=%u\n", RefreshRate);
fprintf(config, "MUSIC_VOLUME=%u\n", MusicVolume);
fprintf(config, "EFFECT_VOLUME=%u\n", EffectVolume);
fprintf(config, "HOST=%s\n", HostName.c_str());
fprintf(config, "PORT=%u\n", NetworkPort);
fclose(config);
}
| [
"cmaranec@seznam.cz"
] | cmaranec@seznam.cz |
942abc0038872759f8843422d9685111182cb97e | 3a5a59bf43e0149fdf8d3b4564ee07d1a8272863 | /src/rviz/color.hh | e204b39d13ace3040b91f780df3512f1fc56c73a | [] | no_license | laas/feasibility | e987ee74600e0d3275674d4b9a15fa2874485dae | ffeb4b4211601803ff97c60429a296665a022030 | refs/heads/master | 2021-01-22T05:01:21.554728 | 2013-12-13T11:26:16 | 2013-12-13T11:26:16 | 7,941,243 | 0 | 0 | null | 2013-10-06T17:21:16 | 2013-01-31T17:09:26 | C++ | UTF-8 | C++ | false | false | 579 | hh | #pragma once
namespace ros{
struct Color{
Color();
Color(const Color&);
Color(double r, double g, double b, double a=0.9);
double r,g,b,a;
void print();
};
static Color DEFAULT(1.0,0.3,0.0,1.0);
static Color RED(1.0,0.2,0.0,1.0);
static Color BLUE(0.1,0.9,0.0,1.0);
static Color DARKGREEN(0.3,0.7,0.0,1.0);
static Color WHITE(1.0,1.0,1.0,1.0);
static Color MAGENTA(0.9,0.0,0.9,1.0);
static Color SWEPT_VOLUME(0.6,0.0,0.6,0.3);
static Color OBSTACLE(0.6,0.0,0.6,0.4);
//static Color TEXT_COLOR(0.9,0.9,0.9,1.0);
static Color TEXT_COLOR(0.1,0.1,0.1,1.0);
};
| [
"andreas.orthey@gmx.de"
] | andreas.orthey@gmx.de |
8d4fa1c3ad0ca0a8f4346cdf0febbee2e4e22be7 | e1acf4441932b9b0deab7908d9b56e86e4181de9 | /Examples/taxcode.cpp | 98588220391661287d5bd9625921dc5a1cbd42aa | [] | no_license | LCC-CIT/CS161CPP-CourseMaterials | d0e4bd4d66242edc972923dd59d22f2ab73c33b6 | df95f20c1e748ebe9dd39ef39f5c16f825ce7754 | refs/heads/master | 2021-07-12T11:57:50.070149 | 2017-10-16T18:05:42 | 2017-10-16T18:05:42 | 107,158,424 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 410 | cpp | #include <iostream>
using namespace std;
int main()
{
int taxCode = 3;
float pa = 75.89, tax = 0.0;
switch(taxCode)
{
case 1: tax = 0;
break;
case 2: tax = 0.03 * pa;
break;
case 3: tax = 0.05 * pa;
break;
case 4: tax = 0.07 * pa;
break;
default: tax = 0;
}
cout << "Tax: " << tax << endl;
return 0;
}
| [
"profbird@gmail.com"
] | profbird@gmail.com |
5a2a52360cc79ac4a3b79cc66db08cbb8d87fd04 | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_1673486_1/C++/iscsi/cookoff.cpp | 5c0fa5c8d1407d6ee362a4700ad772baff21e668 | [] | no_license | alexandraback/datacollection | 0bc67a9ace00abbc843f4912562f3a064992e0e9 | 076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf | refs/heads/master | 2021-01-24T18:27:24.417992 | 2017-05-23T09:23:38 | 2017-05-23T09:23:38 | 84,313,442 | 2 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 1,106 | cpp | #include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
typedef unsigned long long LL;
#define FOR(k,a,b) for(LL k(a); k < (b); ++k)
#define FORD(k,a,b) for(int k(b-1); k >= (a); --k)
#define REP(k,a) for(int k=0; k < (a); ++k)
#define ABS(a) ((a)>0?(a):-(a))
int main()
{
#ifdef HOME
clock_t start=clock();
freopen ("A-large.in","r",stdin);
freopen ("A-large.out","w",stdout);
#endif
int T,A,B;
double p,p2;
double res;
double d;
scanf("%d",&T);
FOR(testcase,1,T+1)
{
scanf("%d %d",&A,&B);
res=B+2;
REP(i,A)
{
scanf("%lf",&p);
if(i==0)
p2=p;
else
p2*=p;
d=A-i-1+B-i-1+1+(1-p2)*(B+1);
if(d<res)
res=d;
}
cout << "Case #" << testcase << ": ";
printf("%.10lf\n",res);
}
#ifdef HOME
fprintf(stderr,"time=%.3lfsec\n",0.001*(clock()-start));
#endif
return 0;
} | [
"eewestman@gmail.com"
] | eewestman@gmail.com |
c7b9bacdc14db296905fcbcbc97fe9a77c5e0601 | cf8ddfc720bf6451c4ef4fa01684327431db1919 | /SDK/ARKSurvivalEvolved_ProjNetGun_parameters.hpp | 3b1e27fc2092cdd2ad4b589da7b12fe0e8b9da99 | [
"MIT"
] | permissive | git-Charlie/ARK-SDK | 75337684b11e7b9f668da1f15e8054052a3b600f | c38ca9925309516b2093ad8c3a70ed9489e1d573 | refs/heads/master | 2023-06-20T06:30:33.550123 | 2021-07-11T13:41:45 | 2021-07-11T13:41:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 778 | hpp | #pragma once
// ARKSurvivalEvolved (329.9) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "ARKSurvivalEvolved_ProjNetGun_classes.hpp"
namespace sdk
{
//---------------------------------------------------------------------------
//Parameters
//---------------------------------------------------------------------------
// Function ProjNetGun.ProjNetGun_C.UserConstructionScript
struct AProjNetGun_C_UserConstructionScript_Params
{
};
// Function ProjNetGun.ProjNetGun_C.ExecuteUbergraph_ProjNetGun
struct AProjNetGun_C_ExecuteUbergraph_ProjNetGun_Params
{
int EntryPoint; // (Parm, ZeroConstructor, IsPlainOldData)
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"sergey.2bite@gmail.com"
] | sergey.2bite@gmail.com |
7a821c23b25b08d0966d0ab5b55a31a9e7018e95 | 345d9a4ad960c76aab172ea29b7134fd4d6a045c | /src/casinocoin/crypto/impl/openssl.h | 8ad955a0e624d193424d3a7e33ff4c74418b9b71 | [
"MIT-Wu",
"MIT",
"ISC",
"BSL-1.0"
] | permissive | ajochems/casinocoind | 7357ee50ad2708b22010c01981e57138806ec67a | 4ec0d39ea1687e724070ed7315c7e1115fc43bce | refs/heads/master | 2020-03-22T21:41:13.940891 | 2019-10-03T18:53:28 | 2019-10-03T18:53:28 | 140,707,219 | 1 | 0 | NOASSERTION | 2019-10-03T18:53:30 | 2018-07-12T11:58:21 | C++ | UTF-8 | C++ | false | false | 4,579 | h | //------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2014 Ripple Labs Inc.
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.
*/
//==============================================================================
//==============================================================================
/*
2017-06-30 ajochems Refactored for casinocoin
*/
//==============================================================================
#ifndef CASINOCOIN_OPENSSL_H
#define CASINOCOIN_OPENSSL_H
#include <casinocoin/basics/base_uint.h>
#include <casinocoin/crypto/impl/ec_key.h>
#include <openssl/bn.h>
#include <openssl/ec.h>
namespace casinocoin {
namespace openssl {
class bignum
{
private:
BIGNUM* ptr;
// non-copyable
bignum (bignum const&) = delete;
bignum& operator=(bignum const&) = delete;
void assign_new (uint8_t const* data, size_t size);
public:
bignum();
~bignum()
{
if ( ptr != nullptr)
{
BN_free (ptr);
}
}
bignum (uint8_t const* data, size_t size)
{
assign_new (data, size);
}
template <class T>
explicit bignum (T const& thing)
{
assign_new (thing.data(), thing.size());
}
bignum(bignum&& that) : ptr( that.ptr )
{
that.ptr = nullptr;
}
bignum& operator= (bignum&& that)
{
using std::swap;
swap( ptr, that.ptr );
return *this;
}
BIGNUM * get() { return ptr; }
BIGNUM const* get() const { return ptr; }
bool is_zero() const { return BN_is_zero (ptr); }
void clear() { BN_clear (ptr); }
void assign (uint8_t const* data, size_t size);
};
inline bool operator< (bignum const& a, bignum const& b)
{
return BN_cmp (a.get(), b.get()) < 0;
}
inline bool operator>= (bignum const& a, bignum const& b)
{
return !(a < b);
}
inline uint256 uint256_from_bignum_clear (bignum& number)
{
uint256 result;
result.zero();
BN_bn2bin (number.get(), result.end() - BN_num_bytes (number.get()));
number.clear();
return result;
}
class bn_ctx
{
private:
BN_CTX* ptr;
// non-copyable
bn_ctx (bn_ctx const&);
bn_ctx& operator=(bn_ctx const&);
public:
bn_ctx();
~bn_ctx()
{
BN_CTX_free (ptr);
}
BN_CTX * get() { return ptr; }
BN_CTX const* get() const { return ptr; }
};
bignum get_order (EC_GROUP const* group, bn_ctx& ctx);
inline void add_to (bignum const& a,
bignum& b,
bignum const& modulus,
bn_ctx& ctx)
{
BN_mod_add (b.get(), a.get(), b.get(), modulus.get(), ctx.get());
}
class ec_point
{
public:
using pointer_t = EC_POINT*;
private:
pointer_t ptr;
ec_point (pointer_t raw) : ptr(raw)
{
}
public:
static ec_point acquire (pointer_t raw)
{
return ec_point (raw);
}
ec_point (EC_GROUP const* group);
~ec_point() { EC_POINT_free (ptr); }
ec_point (ec_point const&) = delete;
ec_point& operator=(ec_point const&) = delete;
ec_point(ec_point&& that)
{
ptr = that.ptr;
that.ptr = nullptr;
}
EC_POINT * get() { return ptr; }
EC_POINT const* get() const { return ptr; }
};
void add_to (EC_GROUP const* group,
ec_point const& a,
ec_point& b,
bn_ctx& ctx);
ec_point multiply (EC_GROUP const* group,
bignum const& n,
bn_ctx& ctx);
ec_point bn2point (EC_GROUP const* group, BIGNUM const* number);
// output buffer must hold 33 bytes
void serialize_ec_point (ec_point const& point, std::uint8_t* ptr);
} // openssl
} // casinocoin
#endif
| [
"andre@jochems.com"
] | andre@jochems.com |
757f5d67524002c5effbb48eb9f392a08ab6d46e | 927f8ed962de21c20d4baae963ed8ec5fd31632a | /src/sparse/ordering/GeometricReorderingMPI.hpp | 29a39a89370ec553306610b5b01e8025eab2a5fa | [
"BSD-3-Clause-LBNL"
] | permissive | simonxuluo/STRUMPACK | b0ccc8d18fab8dbd9895fa908c4f79a6d1572486 | b6f381d6e0d1bc3a1941b52cbcc73e024a7e1662 | refs/heads/master | 2023-01-21T13:25:22.805696 | 2020-12-04T00:23:02 | 2020-12-04T00:23:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,030 | hpp | /*
* STRUMPACK -- STRUctured Matrices PACKage, Copyright (c) 2014, The
* Regents of the University of California, through Lawrence Berkeley
* National Laboratory (subject to receipt of any required approvals
* from the U.S. Dept. of Energy). All rights reserved.
*
* If you have questions about your rights to use or distribute this
* software, please contact Berkeley Lab's Technology Transfer
* Department at TTD@lbl.gov.
*
* NOTICE. This software is owned by the U.S. Department of Energy. As
* such, the U.S. Government has been granted for itself and others
* acting on its behalf a paid-up, nonexclusive, irrevocable,
* worldwide license in the Software to reproduce, prepare derivative
* works, and perform publicly and display publicly. Beginning five
* (5) years after the date permission to assert copyright is obtained
* from the U.S. Department of Energy, and subject to any subsequent
* five (5) year renewals, the U.S. Government is granted for itself
* and others acting on its behalf a paid-up, nonexclusive,
* irrevocable, worldwide license in the Software to reproduce,
* prepare derivative works, distribute copies to the public, perform
* publicly and display publicly, and to permit others to do so.
*
* Developers: Pieter Ghysels, Francois-Henry Rouet, Xiaoye S. Li.
* (Lawrence Berkeley National Lab, Computational Research
* Division).
*
*/
#ifndef GEOMETRIC_REORDERING_MPI_HPP
#define GEOMETRIC_REORDERING_MPI_HPP
#include <array>
#include "GeometricReordering.hpp"
#include "misc/MPIWrapper.hpp"
namespace strumpack {
template<typename integer_t>
std::pair<std::unique_ptr<SeparatorTree<integer_t>>,
std::unique_ptr<SeparatorTree<integer_t>>>
geometric_nested_dissection_dist
(int nx, int ny, int nz, int components, int width,
integer_t lo, integer_t hi, const MPIComm& comm,
std::vector<integer_t>& perm, std::vector<integer_t>& iperm,
int nd_param, int HSS_leaf, int min_HSS);
} // end namespace strumpack
#endif
| [
"pghysels@lbl.gov"
] | pghysels@lbl.gov |
5ea4dd2c50bbfc8007a56b0c61c2b9ecef36531b | 0a626f9383a7a9b5085f63e6ce214ae8e19203cc | /test/cctest/compiler/function-tester.cc | e5654003c33ca3edf47acf2ec86fbe2070021b7e | [
"BSD-3-Clause",
"bzip2-1.0.6",
"SunPro"
] | permissive | xtuc/v8 | 8a494f80ad65f6597f766bf8b295740ae07a4adc | 86894d98bfe79f46c51e27b0699f7bfcc07fe0b2 | refs/heads/master | 2021-09-28T21:30:37.358269 | 2018-11-20T04:58:57 | 2018-11-20T06:36:53 | 153,456,519 | 0 | 0 | NOASSERTION | 2018-11-06T14:37:55 | 2018-10-17T12:53:24 | C++ | UTF-8 | C++ | false | false | 6,110 | cc | // Copyright 2014 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.
#include "test/cctest/compiler/function-tester.h"
#include "src/api-inl.h"
#include "src/compiler.h"
#include "src/compiler/linkage.h"
#include "src/compiler/pipeline.h"
#include "src/execution.h"
#include "src/handles.h"
#include "src/objects-inl.h"
#include "src/optimized-compilation-info.h"
#include "src/parsing/parse-info.h"
#include "test/cctest/cctest.h"
namespace v8 {
namespace internal {
namespace compiler {
FunctionTester::FunctionTester(const char* source, uint32_t flags)
: isolate(main_isolate()),
canonical(isolate),
function((FLAG_allow_natives_syntax = true, NewFunction(source))),
flags_(flags) {
Compile(function);
const uint32_t supported_flags = OptimizedCompilationInfo::kInliningEnabled;
CHECK_EQ(0u, flags_ & ~supported_flags);
}
FunctionTester::FunctionTester(Graph* graph, int param_count)
: isolate(main_isolate()),
canonical(isolate),
function(NewFunction(BuildFunction(param_count).c_str())),
flags_(0) {
CompileGraph(graph);
}
FunctionTester::FunctionTester(Handle<Code> code, int param_count)
: isolate(main_isolate()),
canonical(isolate),
function((FLAG_allow_natives_syntax = true,
NewFunction(BuildFunction(param_count).c_str()))),
flags_(0) {
CHECK(!code.is_null());
Compile(function);
function->set_code(*code);
}
FunctionTester::FunctionTester(Handle<Code> code) : FunctionTester(code, 0) {}
void FunctionTester::CheckThrows(Handle<Object> a) {
TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate));
MaybeHandle<Object> no_result = Call(a);
CHECK(isolate->has_pending_exception());
CHECK(try_catch.HasCaught());
CHECK(no_result.is_null());
isolate->OptionalRescheduleException(true);
}
void FunctionTester::CheckThrows(Handle<Object> a, Handle<Object> b) {
TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate));
MaybeHandle<Object> no_result = Call(a, b);
CHECK(isolate->has_pending_exception());
CHECK(try_catch.HasCaught());
CHECK(no_result.is_null());
isolate->OptionalRescheduleException(true);
}
v8::Local<v8::Message> FunctionTester::CheckThrowsReturnMessage(
Handle<Object> a, Handle<Object> b) {
TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate));
MaybeHandle<Object> no_result = Call(a, b);
CHECK(isolate->has_pending_exception());
CHECK(try_catch.HasCaught());
CHECK(no_result.is_null());
isolate->OptionalRescheduleException(true);
CHECK(!try_catch.Message().IsEmpty());
return try_catch.Message();
}
void FunctionTester::CheckCall(Handle<Object> expected, Handle<Object> a,
Handle<Object> b, Handle<Object> c,
Handle<Object> d) {
Handle<Object> result = Call(a, b, c, d).ToHandleChecked();
CHECK(expected->SameValue(*result));
}
Handle<JSFunction> FunctionTester::NewFunction(const char* source) {
return Handle<JSFunction>::cast(v8::Utils::OpenHandle(
*v8::Local<v8::Function>::Cast(CompileRun(source))));
}
Handle<JSObject> FunctionTester::NewObject(const char* source) {
return Handle<JSObject>::cast(
v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(CompileRun(source))));
}
Handle<String> FunctionTester::Val(const char* string) {
return isolate->factory()->InternalizeUtf8String(string);
}
Handle<Object> FunctionTester::Val(double value) {
return isolate->factory()->NewNumber(value);
}
Handle<Object> FunctionTester::infinity() {
return isolate->factory()->infinity_value();
}
Handle<Object> FunctionTester::minus_infinity() { return Val(-V8_INFINITY); }
Handle<Object> FunctionTester::nan() { return isolate->factory()->nan_value(); }
Handle<Object> FunctionTester::undefined() {
return isolate->factory()->undefined_value();
}
Handle<Object> FunctionTester::null() {
return isolate->factory()->null_value();
}
Handle<Object> FunctionTester::true_value() {
return isolate->factory()->true_value();
}
Handle<Object> FunctionTester::false_value() {
return isolate->factory()->false_value();
}
Handle<JSFunction> FunctionTester::ForMachineGraph(Graph* graph,
int param_count) {
JSFunction* p = nullptr;
{ // because of the implicit handle scope of FunctionTester.
FunctionTester f(graph, param_count);
p = *f.function;
}
return Handle<JSFunction>(
p, p->GetIsolate()); // allocated in outer handle scope.
}
Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) {
Handle<SharedFunctionInfo> shared(function->shared(), isolate);
CHECK(function->is_compiled() ||
Compiler::Compile(function, Compiler::CLEAR_EXCEPTION));
Zone zone(isolate->allocator(), ZONE_NAME);
OptimizedCompilationInfo info(&zone, isolate, shared, function);
if (flags_ & OptimizedCompilationInfo::kInliningEnabled) {
info.MarkAsInliningEnabled();
}
CHECK(info.shared_info()->HasBytecodeArray());
JSFunction::EnsureFeedbackVector(function);
Handle<Code> code =
Pipeline::GenerateCodeForTesting(&info, isolate).ToHandleChecked();
info.context()->native_context()->AddOptimizedCode(*code);
function->set_code(*code);
return function;
}
// Compile the given machine graph instead of the source of the function
// and replace the JSFunction's code with the result.
Handle<JSFunction> FunctionTester::CompileGraph(Graph* graph) {
Handle<SharedFunctionInfo> shared(function->shared(), isolate);
Zone zone(isolate->allocator(), ZONE_NAME);
OptimizedCompilationInfo info(&zone, isolate, shared, function);
auto call_descriptor = Linkage::ComputeIncoming(&zone, &info);
Handle<Code> code =
Pipeline::GenerateCodeForTesting(&info, isolate, call_descriptor, graph,
AssemblerOptions::Default(isolate))
.ToHandleChecked();
function->set_code(*code);
return function;
}
} // namespace compiler
} // namespace internal
} // namespace v8
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
d84b320507306028eb9b7e01c9c150771df4b93a | 4dd69f3df7d32a35b3318c226f6765d3e9a63b0a | /book1/Ch4/4.6/285_2.cpp | 2a251527144215165daa1ce8725c87d3dcab399b | [] | no_license | dereksodo/allcode | f921294fbb824ab59e64528cd78ccc1f3fcf218d | 7d4fc735770ea5e09661824b0b0adadc7e74c762 | refs/heads/master | 2022-04-13T17:45:29.132307 | 2020-04-08T04:27:44 | 2020-04-08T04:27:44 | 197,805,259 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,262 | cpp | #include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
#include <numeric>
#include <sstream>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
#define debug printf
#else
#define debug(...)
#endif
const int maxn = 1e5 + 7;
const int mod = 1e6;
struct node{
int l,r,pri,cnt,sz,v;
#define lc(x) t[x].l
#define rc(x) t[x].r
#define p(x) t[x].pri
#define v(x) t[x].v
#define s(x) t[x].sz
#define c(x) t[x].cnt
}t[maxn];
int root,tot,delt;
void upd(int &rt)
{
s(rt) = s(lc(rt)) + s(rc(rt)) + 1;
}
void lr(int &rt)
{
int y = rc(rt);
rc(rt) = lc(y);
lc(y) = rt;
s(y) = s(rt);
upd(rt);
rt = y;
}
void rr(int &rt)
{
int y = lc(rt);
lc(rt) = rc(y);
rc(y) = rt;
s(y) = s(rt);
upd(rt);
rt = y;
}
void ins(int &rt,int w)
{
if(!rt)
{
rt = ++tot;
v(rt) = w;
s(rt) = 1;
p(rt) = (rand() << 8) % (maxn << 3);
lc(rt) = rc(rt) = 0;
return;
}
++s(rt);
if(v(rt) >= w)
{
ins(lc(rt),w);
if(p(lc(rt)) < p(rt))
{
rr(rt);
}
}
else
{
ins(rc(rt),w);
if(p(rc(rt)) < p(rt))
{
lr(rt);
}
}
}
int del(int &rt,int w)//return the sz of deleted items
{
if(rt == 0)
{
return 0;
}
if(w > v(rt))
{
int res = s(lc(rt)) + 1;
rt = rc(rt);
return res + del(rt,w);
}
else
{
int res = del(lc(rt),w);
s(rt) -= res;
return res;
}
}
int query(int rt,int x)
{
if(rt == 0)
{
return 0;
}
if(s(lc(rt)) + 1 == x)
{
return v(rt) + delt;
}
if(x <= s(lc(rt)))
{
return query(lc(rt),x);
}
else
{
return query(rc(rt),x - s(lc(rt)) - 1);
}
}
int main(int argc, char const *argv[])
{
srand(time(NULL));
int n,min_s;
scanf("%d%d",&n,&min_s);
char buf[10];
int sum = 0;
while(n--)
{
int x;
scanf(" %s %d",buf,&x);
if(buf[0] == 'I')
{
if(x >= min_s)
{
ins(root,x - delt);
}
}
else if(buf[0] == 'A')
{
delt += x;
}
else if(buf[0] == 'S')
{
delt -= x;
sum += del(root,min_s - delt);
}
else
{
if(x > s(root))
{
printf("-1\n");
}
else
{
printf("%d\n",query(root,s(root) - x + 1));
}
}
}
printf("%d\n",sum);
return 0;
} | [
"pi*7=7.17"
] | pi*7=7.17 |
5e83039b18af3887dedd92d5e72d2bdc92c3d2d9 | f6ab96101246c8764dc16073cbea72a188a0dc1a | /volume113/11380 - Down Went The Titanic.cpp | 64a35b0d9dfe57eaec654874f63e963cd590aff6 | [] | no_license | nealwu/UVa | c87ddc8a0bf07a9bd9cadbf88b7389790bc321cb | 10ddd83a00271b0c9c259506aa17d03075850f60 | refs/heads/master | 2020-09-07T18:52:19.352699 | 2019-05-01T09:41:55 | 2019-05-01T09:41:55 | 220,883,015 | 3 | 2 | null | 2019-11-11T02:14:54 | 2019-11-11T02:14:54 | null | UTF-8 | C++ | false | false | 3,686 | cpp | #include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
using namespace std;
struct Node {
int x, y, v;// x->y, v
int next;
} edge[100005];
int e, head[2048], prev[2048], record[2048];
int level[2048], visited[2048];
void addEdge(int x, int y, int v) {
edge[e].x = x, edge[e].y = y, edge[e].v = v;
edge[e].next = head[x], head[x] = e++;
edge[e].x = y, edge[e].y = x, edge[e].v = 0;
edge[e].next = head[y], head[y] = e++;
}
bool buildLevelGraph(int s, int t) {
memset(level, 0, sizeof(level));
queue<int> Q;
Q.push(s), level[s] = 1;
while(!Q.empty()) {
int tn = Q.front();
Q.pop();
for(int i = head[tn]; i != -1; i = edge[i].next) {
int y = edge[i].y;
if(edge[i].v > 0 && level[y] == 0) {
level[y] = level[tn] + 1;
Q.push(y);
}
}
}
return level[t] > 0;
}
int constructBlockingFlow(int s, int t) {
int ret = 0;
stack<int> stk;
memset(visited, 0, sizeof(visited));
stk.push(s);
while(!stk.empty()) {
int now = stk.top();
if(now != t) {
for(int i = head[now]; i != -1; i = edge[i].next) {
int y = edge[i].y;
if(visited[y] || level[y] != level[now] + 1)
continue;
if(edge[i].v > 0) {
stk.push(y), prev[y] = now, record[y] = i;
break;
}
}
if(stk.top() == now)
stk.pop(), visited[now] = 1;
} else {
int flow = 1e+9, bottleneck;
for(int i = t; i != s; i = prev[i]) {
int ri = record[i];
flow = min(flow, edge[ri].v);
}
for(int i = t; i != s; i = prev[i]) {
int ri = record[i];
edge[ri].v -= flow;
edge[ri^1].v += flow;
if(edge[ri].v == 0)
bottleneck = prev[i];
}
while(!stk.empty() && stk.top() != bottleneck)
stk.pop();
ret += flow;
}
}
return ret;
}
int maxflowDinic(int s, int t) {
int flow = 0;
while(buildLevelGraph(s, t))
flow += constructBlockingFlow(s, t);
return flow;
}
#define INF 0x3f3f3f3f
int main() {
int X, Y, P;
char g[32][32];
while(scanf("%d %d %d", &X, &Y, &P) == 3) {
e = 0;
memset(head, -1, sizeof(head));
int source = X * Y * 2 + 1, sink = source + 1;
for(int i = 0; i < X; i++)
scanf("%s", g[i]);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};
int x, y, tx, ty;
for(int i = 0; i < X; i++) {
for(int j = 0; j < Y; j++) {
if(g[i][j] == '~')
continue;
for(int k = 0; k < 4; k++) {
tx = i + dx[k], ty = j + dy[k];
if(tx < 0 || ty < 0 || tx >= X || ty >= Y)
continue;
if(g[tx][ty] == '~')
continue;
x = (i * Y + j) * 2 + 1;
y = (tx * Y + ty) * 2;
addEdge(x, y, INF);
}
x = (i * Y + j) * 2;
y = (i * Y + j) * 2 + 1;
if(g[i][j] == '*')
addEdge(source, x, 1), addEdge(x, y, 1);
else if(g[i][j] == '.')
addEdge(x, y, 1);
else if(g[i][j] == '@')
addEdge(x, y, INF);
else if(g[i][j] == '#')
addEdge(x, y, INF), addEdge(y, sink, P);
}
}
int ret = maxflowDinic(source, sink);
printf("%d\n", ret);
}
return 0;
}
| [
"morris821028@gmail.com"
] | morris821028@gmail.com |
62446698e07bdce679c4e55e0d9fa51974e85bc7 | c3d3062f0fdd751a49ccbe907cff41aa4680b42b | /include/ElephantBase/Collection.h | 78ec7d9c71c951ef9b43e5a4035105d5e85e6261 | [] | no_license | Flower35/ZookieWizard | 5a233d71f2202ae120dd7c160e8d022a40c15eeb | 1d398f194e1ad74d5b6cf7f865dc2baab33936b7 | refs/heads/master | 2023-06-07T04:34:27.333278 | 2022-08-18T17:12:13 | 2022-08-18T17:12:13 | 228,497,238 | 12 | 6 | null | null | null | null | UTF-8 | C++ | false | false | 1,529 | h | #ifndef H_KAO2_COLLECTION
#define H_KAO2_COLLECTION
#include <ElephantBase/kao2ar.h>
namespace ZookieWizard
{
class Archive;
class eRefCounter;
struct TypeInfo;
////////////////////////////////////////////////////////////////
// COLLECTION OF CLASSES
////////////////////////////////////////////////////////////////
template <void (*Func)(Archive&, eRefCounter**, const TypeInfo*)>
struct Collection
{
/*** Properties ***/
private:
int32_t count;
int32_t maxLength;
eRefCounter** children;
/*** Methods ***/
public:
Collection(int32_t new_size = 0);
~Collection();
private:
void createFromOtherObject(const Collection<Func> &other);
public:
Collection(const Collection<Func> &other);
Collection<Func>& operator = (const Collection<Func> &other);
Collection<Func>& deepCopy(const Collection<Func> &other);
/* << Collection >> */
void clear();
void serialize(Archive &ar, const TypeInfo* t);
int32_t getSize() const;
void setIthChild(int32_t i, eRefCounter* o);
eRefCounter* getIthChild(int32_t i) const;
void appendChild(eRefCounter* o);
void deleteIthChild(int32_t i);
void findAndDeleteChild(eRefCounter* o);
void swapForward(int32_t i);
void swapBackward(int32_t i);
};
}
#endif
| [
"46760021+Flower35@users.noreply.github.com"
] | 46760021+Flower35@users.noreply.github.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.