blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 7
109
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
3
| license_type
stringclasses 2
values | repo_name
stringlengths 9
56
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 5
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 8.26M
223M
⌀ | star_events_count
int64 0
25
| fork_events_count
int64 0
11
| gha_license_id
stringclasses 4
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 2
values | src_encoding
stringclasses 5
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 1
class | length_bytes
int64 35
345k
| extension
stringclasses 7
values | content
stringlengths 35
345k
| authors
sequencelengths 1
29
| author_lines
sequencelengths 1
29
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
819eb928fa03acd974c3e18443532022f13c2f05 | 711b11d08abdb3a7df2574b0b4c86af21c5c6750 | /dest.h | e06af74e0264187915ab70b86b0e67aa85d2a79f | [] | no_license | nflath/MSP430Emulator | 4aee9e093113cc41d9041a1728eedd742fd786b2 | a97a1b97b895b3533597bcdb69bec8b75db395df | refs/heads/master | 2021-01-13T01:54:55.258000 | 2015-08-25T05:10:04 | 2015-08-25T05:10:04 | 41,343,926 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,382 | h | #include <assert.h>
#ifndef DEST_H
#define DEST_H
#include "error.h"
// Classes representing 'Destinations' types in MSP430 - See the section
// 'MSP430 addressing modes' in https://en.wikipedia.org/wiki/TI_MSP430#MSP430_CPU
class State;
class Dest {
// Virtual base clase.
public:
virtual void set(short value) { notimplemented(); }
// Sets the value of this destination
virtual void setByte(unsigned char value) { notimplemented(); }
// Sets the value of this destination (byte addressing mode)
virtual short value() { notimplemented(); return 0;}
// Returns the value of this destination
virtual unsigned char valueByte() { notimplemented(); return 0;}
// Returns the value of this destination(byte addressing mode)
virtual std::string toString() = 0;
// Returns a string representation of this destination
virtual bool usedExtensionWord() { return false; }
// Whether an extension word was used to represent this destination
virtual unsigned char size() { return usedExtensionWord() ? 2 : 0; }
// How many extra bytes this destination took up in the assembly
};
class RegisterDest : public Dest {
// Destination representing a register (r14)
public:
virtual std::string toString();
virtual void set(short value);
virtual void setByte(unsigned char value);
virtual short value();
virtual unsigned char valueByte();
RegisterDest(unsigned short reg_) : reg(reg_) {}
unsigned short reg;
};
class RegisterOffsetDest : public RegisterDest {
// Destination representing the memory address at a register plus an offset (0x40(r14))
public:
virtual std::string toString();
virtual bool usedExtensionWord() { return true; }
virtual void set(short value);
virtual void setByte(unsigned char value);
virtual short value();
virtual unsigned char valueByte();
RegisterOffsetDest(unsigned short reg_, short offset_) :
RegisterDest(reg_),
offset(offset_) {
}
short offset;
};
class AbsoluteDest : public Dest {
// Destination that is just a memory address (&0x4400)
public:
virtual std::string toString();
virtual bool usedExtensionWord() { return true; }
virtual void set(short value);
virtual void setByte(unsigned char value);
virtual unsigned char valueByte();
AbsoluteDest(unsigned short address_) :
address(address_) {
}
unsigned short address;
};
extern State* s;
#endif
| [
"[email protected]"
] | [
[
[
1,
89
]
]
] |
06c1ab5ff8ab138987ba9ad1ed0f423d945bafe7 | 6817617489ef291d4d53ac844ba7a2b14cc17ae2 | /11942.cpp | dcc6c32bd3395a76801df96fb6b8693215e020ec | [] | no_license | Asad51/UVA-Problem-Solving | 1932f2cd73261cd702f58d4f189a4a134dbd6286 | af28ae36a2074d4e2a67670dbbbd507438c56c3e | refs/heads/master | 2020-03-23T14:52:49.420000 | 2019-10-24T17:03:37 | 2019-10-24T17:03:37 | 120,592,261 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 449 | cpp | #include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
int t;
cin>>t;
cout<<"Lumberjacks:\n";
while(t--){
bool in = true;
bool dec = true;
int p;
for(int i=0; i<10; i++){
int n;
cin>>n;
if(!i){
p = n;
continue;
}
if(n<p || !in)
in = false;
if(n>p || !dec)
dec = false;
p = n;
}
if(!in && !dec)
cout<<"Unordered\n";
else
cout<<"Ordered\n";
}
return 0;
}
| [
"[email protected]"
] | [
[
[
1,
32
]
]
] |
cbee84c2e52dc1341528f8254aaf41ac321f936c | 2869112fdc836e565f9fe68e290affc1e223c1d8 | /pythran/pythonic/include/__builtin__/set/isdisjoint.hpp | 10ac38270e03ff35d15b79143e6164321a7b5afb | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] | permissive | coyotte508/pythran | ab26e9ddb9a9e00e77b457df316aa33dc8435914 | a5da78f2aebae712a2c6260ab691dab7d09e307c | refs/heads/master | 2021-01-15T10:07:09.597000 | 2015-05-01T07:00:42 | 2015-05-01T07:00:42 | 35,020,532 | 0 | 0 | null | 2015-05-04T07:27:29 | 2015-05-04T07:27:29 | null | UTF-8 | C++ | false | false | 621 | hpp | #ifndef PYTHONIC_INCLUDE_BUILTIN_SET_ISDISJOINT_HPP
#define PYTHONIC_INCLUDE_BUILTIN_SET_ISDISJOINT_HPP
#include "pythonic/utils/proxy.hpp"
#include "pythonic/types/set.hpp"
namespace pythonic {
namespace __builtin__ {
namespace set {
template<class T, class U>
bool
isdisjoint(types::set<T> const& calling_set, U const& arg_set);
template<class U>
bool
isdisjoint(types::empty_set const& calling_set, U const& arg_set);
PROXY_DECL(pythonic::__builtin__::set, isdisjoint);
}
}
}
#endif
| [
"[email protected]"
] | [
[
[
1,
27
]
]
] |
36ffd69f21bf2277cef7fea364841c3a12967399 | d04b3793ed3611d5bdc8e3bc990bf9eb8562cece | /CheatSheet.cpp | e00970193f00ed69d57e398e36db43427aaf83b0 | [] | no_license | nebulou5/CppExamples | c7198cdc24ba1d681cc20738a3b21e2b17b98498 | 98044227b888a7f9faa8934ab76bb3cac443b75e | refs/heads/master | 2023-09-01T18:55:44.584000 | 2016-01-25T17:57:40 | 2016-01-25T17:57:40 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,222 | cpp | #include <iostream>
using namespace std;
void printI(int &i) {
cout << "Printing i: " << i << endl;
}
int main() {
// defining a basic 10 integer array
int x[10];
int xLen = sizeof(x) / sizeof(x[0]);
for (int i = 0; i < xLen; i++) {
cout << x[i] << endl;
}
// defining an array in place
float v[] = {1.1, 2.2, 3.3};
int vLen = sizeof(v) / sizeof(v[0]);
for (int i = 0; i < vLen; i++ ) {
cout << v[i] << endl;
}
// multidimensional array
float ab[3][3];
int abLen = sizeof(ab) / sizeof(ab[0]);
for (int i = 0; i < abLen; i++) {
printI(i);
for (int j = 0; j < abLen; j++) {
cout << "Element: " << i << ", " << j << ": " << ab[i][j] << endl;
}
}
// array allocated at runtime
int someUserDefinedSize = 3;
float* rta = new float[someUserDefinedSize]; // pointer dynamically allocates memory at runtime
delete[] rta; // but programmer must clean up the memory afterwards
// basic pointer usage
int i = 3;
int *j = &i; // store address of i @ "j"
int k = *j; // dereference address stored @ "j"
// initializing a nullptr
// valid in c++ 11 and beyond
int *nullPointer = nullptr;
int *nullPointerSynonymous{}; // also sets a nullptr
}
| [
"[email protected]"
] | [
[
[
1,
52
]
]
] |
73bbdcfbe50a724cb152edeb3ed8f2aed3d76d69 | 28b90ad96790edd30edc5ba95137cc20261599b5 | /nodemcu/MPU_6050_flask_json/MPU_6050_flask_json.ino | 134d2fabdbfb2a13cb534495c378ee4397e38c4e | [] | no_license | anshulahuja98/Codefundo-18-IITJ | b09e1b200a5e5d9bbe23f58addc3460a1a19d732 | bfae0dde99cd9133bdeabd06fdb73b512214b1f9 | refs/heads/master | 2020-03-30T01:52:30.166000 | 2019-02-10T04:34:35 | 2019-02-10T04:34:35 | 150,599,578 | 5 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 5,804 | ino |
#include <Wire.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h>
#include <ArduinoJson.h>
const uint8_t MPU6050SlaveAddress = 0x68;
const uint8_t scl = D1;
const uint8_t sda = D2;
const uint16_t AccelScaleFactor = 16384;
const uint16_t GyroScaleFactor = 131;
const uint8_t MPU6050_REGISTER_SMPLRT_DIV = 0x19;
const uint8_t MPU6050_REGISTER_USER_CTRL = 0x6A;
const uint8_t MPU6050_REGISTER_PWR_MGMT_1 = 0x6B;
const uint8_t MPU6050_REGISTER_PWR_MGMT_2 = 0x6C;
const uint8_t MPU6050_REGISTER_CONFIG = 0x1A;
const uint8_t MPU6050_REGISTER_GYRO_CONFIG = 0x1B;
const uint8_t MPU6050_REGISTER_ACCEL_CONFIG = 0x1C;
const uint8_t MPU6050_REGISTER_FIFO_EN = 0x23;
const uint8_t MPU6050_REGISTER_INT_ENABLE = 0x38;
const uint8_t MPU6050_REGISTER_ACCEL_XOUT_H = 0x3B;
const uint8_t MPU6050_REGISTER_SIGNAL_PATH_RESET = 0x68;
int16_t AccelX, AccelY, AccelZ, Temperature, GyroX, GyroY, GyroZ;
String flag_payload = "";
int o =0;
void setup() {
Serial.begin(115200);
Wire.begin(sda, scl);
MPU6050_Init();
WiFi.begin("null", "patanahi1");
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.println("Waiting for connection");
}
pinMode(10 , OUTPUT);
digitalWrite(10, LOW);
}
void loop() {
if (WiFi.status() == WL_CONNECTED) {
double Ax, Ay, Az, T, Gx, Gy, Gz, dev_id;
Read_RawValue(MPU6050SlaveAddress, MPU6050_REGISTER_ACCEL_XOUT_H);
//divide each with their sensititvity scale factor
Ax = (double)AccelX / AccelScaleFactor;
Ay = (double)AccelY / AccelScaleFactor;
Az = (double)AccelZ / AccelScaleFactor;
T = (double)Temperature / 340 + 36.53; //temperature formula
Gx = (double)GyroX / GyroScaleFactor;
Gy = (double)GyroY / GyroScaleFactor;
Gz = (double)GyroZ / GyroScaleFactor;
dev_id = 2222;
Serial.print("Ax: "); Serial.print(Ax);
Serial.print(" Ay: "); Serial.print(Ay);
Serial.print(" Az: "); Serial.print(Az);
Serial.print(" T: "); Serial.print(T);
Serial.print(" Gx: "); Serial.print(Gx);
Serial.print(" Gy: "); Serial.print(Gy);
Serial.print(" Gz: "); Serial.println(Gz);
StaticJsonBuffer<300> JSONbuffer; //Declaring static JSON buffer
JsonObject& JSONencoder = JSONbuffer.createObject();
JSONencoder["Sensor type"] = "Acceleration";
JSONencoder["deviceid"] = dev_id;
JsonArray& values = JSONencoder.createNestedArray("values"); //JSON array
values.add(Ax); //Add value to array
values.add(Ay); //Add value to array
values.add(Az); //Add value to array
values.add(T); //Add value to array
JsonArray& timestamps = JSONencoder.createNestedArray("direction1"); //JSON array
timestamps.add("x direction"); //Add value to array
timestamps.add("y direction"); //Add value to array
timestamps.add("z direction"); //Add value to array
timestamps.add("Temperature"); //Add vaues to array
char JSONmessageBuffer[300];
JSONencoder.prettyPrintTo(JSONmessageBuffer, sizeof(JSONmessageBuffer));
Serial.println(JSONmessageBuffer);
HTTPClient http; //Declare object of class HTTPClient
http.begin("http://192.168.43.75:8090/post"); //Specify request destination
http.addHeader("Content-Type", "application/json"); //Specify content-type header
int httpCode = http.POST(JSONmessageBuffer); //Send the request
String payload = http.getString(); //Get the response payload
Serial.println(httpCode); //Print HTTP return code
Serial.println(payload); //Print request response payload
http.end(); //Close connection
http.begin("http://192.168.43.75:8090/get");
int httpCode1 = http.GET(); //Send the request
String payload_get = http.getString();
Serial.println(httpCode1); //Print HTTP return code
Serial.println(payload_get); //Print request response payload
if (payload_get == "1")
{
Serial.println("lasjdf liasdj fli");
o = 1;
}
http.end(); //Close connection
if (o == 1)
{
digitalWrite(10, HIGH);
}
}
else
{
Serial.println("Error in WiFi connection");
}
delay(100);
}
void I2C_Write(uint8_t deviceAddress, uint8_t regAddress, uint8_t data) {
Wire.beginTransmission(deviceAddress);
Wire.write(regAddress);
Wire.write(data);
Wire.endTransmission();
}
// read all 14 register
void Read_RawValue(uint8_t deviceAddress, uint8_t regAddress) {
Wire.beginTransmission(deviceAddress);
Wire.write(regAddress);
Wire.endTransmission();
Wire.requestFrom(deviceAddress, (uint8_t)14);
AccelX = (((int16_t)Wire.read() << 8) | Wire.read());
AccelY = (((int16_t)Wire.read() << 8) | Wire.read());
AccelZ = (((int16_t)Wire.read() << 8) | Wire.read());
Temperature = (((int16_t)Wire.read() << 8) | Wire.read());
GyroX = (((int16_t)Wire.read() << 8) | Wire.read());
GyroY = (((int16_t)Wire.read() << 8) | Wire.read());
GyroZ = (((int16_t)Wire.read() << 8) | Wire.read());
}
//configure MPU6050
void MPU6050_Init() {
delay(150);
I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_SMPLRT_DIV, 0x07);
I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_PWR_MGMT_1, 0x01);
I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_PWR_MGMT_2, 0x00);
I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_CONFIG, 0x00);
I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_GYRO_CONFIG, 0x00);//set +/-250 degree/second full scale
I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_ACCEL_CONFIG, 0x00);// set +/- 2g full scale
I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_FIFO_EN, 0x00);
I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_INT_ENABLE, 0x01);
I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_SIGNAL_PATH_RESET, 0x00);
I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_USER_CTRL, 0x00);
}
| [
"[email protected]"
] | [
[
[
1,
163
]
]
] |
77e95d74adb0d91068d318a9f567bd723eb4bd30 | 8a970882a0be9f3d85edbf6ecec0050b762e8d80 | /GazEngine/gazengine/Entity.h | ded187d2149547f453fc7c141f5bfa9b3cc59aa9 | [] | no_license | simplegsb/gazengine | 472d1de8d300c8406ffec148844911fd21d5c1e0 | b0a7300aa535b14494789fb88c16d6dda1c4e622 | refs/heads/master | 2016-09-05T21:02:49.531000 | 2013-04-29T08:33:16 | 2013-04-29T08:33:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,553 | h | #ifndef ENTITY_H_
#define ENTITY_H_
#include <memory>
#include <string>
#include <vector>
class Component;
class Entity
{
public:
static const unsigned short UNCATEGORIZED = 0;
Entity(unsigned short category = UNCATEGORIZED, const std::string& name = std::string());
virtual ~Entity();
/**
* <p>
* Adds a component.
* </p>
*
* @param component The component to add.
*/
void addComponent(Component* component);
unsigned short getCategory() const;
/**
* <p>
* Retrieves the components.
* </p>
*
* @return The components.
*/
template<typename ComponentType>
std::vector<ComponentType*> getComponents() const;
unsigned int getId() const;
/**
* <p>
* Retrieves the name of this <code>Entity</code>.
* </p>
*
* @return The name of this <code>Entity</code>.
*/
const std::string& getName() const;
/**
* <p>
* Retrieves a single component.
* </p>
*
* @return The single component.
*/
template<typename ComponentType>
ComponentType* getSingleComponent() const;
/**
* <p>
* Removes a component.
* </p>
*
* @param component The component to remove.
*/
void removeComponent(const Component& component);
private:
unsigned short category;
/**
* <p>
* The components.
* </p>
*/
std::vector<Component*> components;
unsigned int id;
/**
* <p>
* The name of this <code>Entity</code>.
* </p>
*/
std::string name;
static unsigned int nextId;
};
#include "Entity.tpp"
#endif /* ENTITY_H_ */
| [
"[email protected]"
] | [
[
[
1,
94
]
]
] |
c1be7ed8331d413fbb32c4f4da225eabb0c94905 | 2d4346d0da0a4145f6bcc91a8cb2c0ab4d669d7e | /chat-up-server/src/Authentication/AuthenticationService.h | b172c8a7281e736007294715851af51947b6b669 | [] | no_license | xgallom/chat-up | 5570d069a495acf6398bdf1f62b1fb1d91289376 | 7cb664ce745cf041fb508b04165d2179563aa010 | refs/heads/master | 2020-04-18T05:40:58.487000 | 2019-01-29T22:36:04 | 2019-01-29T22:36:04 | 167,287,878 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 608 | h | //
// Created by xgallom on 1/27/19.
//
#ifndef CHAT_UP_AUTHENTICATIONSERVICE_H
#define CHAT_UP_AUTHENTICATIONSERVICE_H
#include <Messaging/Message.h>
#include <Messaging/MessageSender.h>
#include <Outcome.h>
#include <Authentication/User.h>
class AuthenticationStorage;
class AuthenticationService {
AuthenticationStorage &m_storage;
User m_user = User();
public:
AuthenticationService() noexcept;
Outcome::Enum run(MessageSender &sender, const Message &message);
bool registerUser(const User &user);
User user() const noexcept;
};
#endif //CHAT_UP_AUTHENTICATIONSERVICE_H
| [
"[email protected]"
] | [
[
[
1,
30
]
]
] |
fdb075167409c531a8ffa63f4eb5c358ff9f4c08 | 8da9d3c3e769ead17f5ad4a4cba6fb3e84a9e340 | /src/chila/lib/node/util.hpp | 51b98169af1da8738e7ec4fea35fe3d0da6b3455 | [] | no_license | blockspacer/chila | 6884a540fafa73db37f2bf0117410c33044adbcf | b95290725b54696f7cefc1c430582f90542b1dec | refs/heads/master | 2021-06-05T10:22:53.536000 | 2016-08-24T15:07:49 | 2016-08-24T15:07:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,721 | hpp | /* Copyright 2011-2015 Roberto Daniel Gimenez Gamarra ([email protected])
* (C.I.: 1.439.390 - Paraguay)
*/
#ifndef CHILA_LIB_NODE__UTIL_HPP
#define CHILA_LIB_NODE__UTIL_HPP
#include <chila/lib/misc/util.hpp>
#include "exceptions.hpp"
#define my_assert CHILA_LIB_MISC__ASSERT
#define CHILA_META_NODE__DEF_CHECK_BASES_ELEM(n, data, elem) \
chila::lib::node::checkAndAdd(list, [&]{ elem::check(newData.get()); });
#define CHILA_META_NODE__DEF_CHECK_BASES(Bases, defMyCheck) \
BOOST_PP_IF(defMyCheck, chila::lib::node::CheckDataUPtr createCheckData(chila::lib::node::CheckData *data) const;, ); \
BOOST_PP_IF(defMyCheck, void myCheck(chila::lib::node::CheckData *data = nullptr) const;, ); \
void check(chila::lib::node::CheckData *data = nullptr) const override \
{ \
chila::lib::node::CheckExceptionList list; \
auto newData = BOOST_PP_IF(defMyCheck, createCheckData(data), chila::lib::node::CheckDataUPtr()); \
BOOST_PP_SEQ_FOR_EACH(CHILA_META_NODE__DEF_CHECK_BASES_ELEM,,Bases) \
BOOST_PP_IF(defMyCheck, BOOST_PP_IDENTITY(\
chila::lib::node::checkAndAdd(list, [&]{ myCheck(newData.get()); }); \
), BOOST_PP_EMPTY)(); \
if (!list.exceptions.empty()) throw list; \
}
#define CHILA_META_NODE__DEF_CHECK \
void check(chila::lib::node::CheckData *data = nullptr) const override;
#include "nspDef.hpp"
MY_NSP_START
{
template <typename CheckFun>
void checkAndAdd(chila::lib::node::CheckExceptionList &list, const CheckFun &checkFun) try
{
checkFun();
}
catch (ExceptionWrapper &ex)
{
list.add(ex.ex);
}
catch (CheckExceptionList &ex)
{
list.add(ex);
}
catch (Exception &ex)
{
list.add(ex);
}
chila::lib::misc::Path getNodePath(const Node &node); // to avoid cyclical dependency
template <typename Fun>
inline auto catchThrow(const Node &node, const Fun &fun) -> decltype(fun()) try
{
return fun();
}
catch (const boost::exception &ex)
{
ex << chila::lib::misc::ExceptionInfo::Path(getNodePath(node));
throw;
}
template <typename ToType, typename Node>
inline const ToType &castNode(const Node &node) try
{
return catchThrow(node, [&]() -> const ToType& { return chila::lib::misc::dynamicCast<ToType>(node); });
}
catch (const boost::exception &ex)
{
InvalidNode exx;
insert_error_info(chila::lib::misc::ExceptionInfo::TypeFrom)
insert_error_info(chila::lib::misc::ExceptionInfo::TypeTo)
insert_error_info(chila::lib::misc::ExceptionInfo::ActualType)
insert_error_info(chila::lib::misc::ExceptionInfo::Path)
BOOST_THROW_EXCEPTION(exx);
}
template <typename ToType, typename Node>
inline ToType &castNode(Node &node) try
{
return catchThrow(node, [&]() -> ToType& { return chila::lib::misc::dynamicCast<ToType>(node); });
}
catch (const boost::exception &ex)
{
InvalidNode exx;
insert_error_info(chila::lib::misc::ExceptionInfo::TypeFrom)
insert_error_info(chila::lib::misc::ExceptionInfo::TypeTo)
insert_error_info(chila::lib::misc::ExceptionInfo::ActualType)
insert_error_info(chila::lib::misc::ExceptionInfo::Path)
BOOST_THROW_EXCEPTION(exx);
}
NodeWithChildren &mainParent(NodeWithChildren &node);
PathVec getReferences(
NodeWithChildren &node,
const chila::lib::misc::Path &path);
void replaceReferences(NodeWithChildren &node, const PathVec &paths, const Node &newRefNode);
}
MY_NSP_END
#include "nspUndef.hpp"
#endif
| [
"[email protected]"
] | [
[
[
1,
114
]
]
] |
f387d41d0e3251ca4e290372f77e819aa8f41c08 | 8c8ea797b0821400c3176add36dd59f866b8ac3d | /AOJ/aoj0578.cpp | 9b35642e4fd0541224a11ccbbf275376f137bc2c | [] | no_license | fushime2/competitive | d3d6d8e095842a97d4cad9ca1246ee120d21789f | b2a0f5957d8ae758330f5450306b629006651ad5 | refs/heads/master | 2021-01-21T16:00:57.337000 | 2017-05-20T06:45:46 | 2017-05-20T06:45:46 | 78,257,409 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 682 | cpp | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;
int N;
bool isName(string shop, string board) {
int m = board.length();
for(int step=1; step<=m; step++) {
for(int i=0; i<m; i++) {
string s = "";
for(int j=i; j<m; j+=step) {
s += board[j];
}
if(s.find(shop) != string::npos) return true;
}
}
return false;
}
int main(void) {
cin >> N;
string shop, board;
cin >> shop;
int ans = 0;
for(int i=0; i<N; i++) {
cin >> board;
if(isName(shop, board)) ans++;
}
cout << ans << endl;
return 0;
}
| [
"[email protected]"
] | [
[
[
1,
34
]
]
] |
6121382505592535a09b239e90ed50ff680fc2e6 | 91fcb836ee5af301a2125624ddb96cf49b19494d | /queue/restoreQueue.cpp | 2e49fc23784e34f26b2deade801fe414d1b21cb1 | [] | no_license | hellozxs/C | fe11911222595ffcdc425218407711bbe59a3b10 | 1f3815966a8d5668f149ff9957672819a2d2b57d | refs/heads/master | 2020-04-06T07:03:14.596000 | 2016-09-18T10:25:27 | 2016-09-18T10:25:27 | 65,121,708 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,272 | cpp | //对一个队列执行以下操作后,发现输出为 1,2,3,4,……,n
// 操作:(如果队列不为空)
// 1:取队头元素,放入队尾,将队头pop
// 2;输出队头,将队头pop
// 输入n,求原始队列?
//
//输入:z -> 表示将要输入的数据的个数
//输入z个n的具体值
#include <iostream>
#include <vector>
using namespace std;
typedef struct MyData
{
int _data;
bool _flag;
}MyData;
int main()
{
int z;
cin >> z;
vector<int> arr(z);
for (int i = 0; i < z; i++)
{
cin >> arr[i];
}
int i = 0;
for (i = 0; i< z; i++)
{
if (arr[i] == 1)
cout << 1 << endl;
else
{
vector<MyData> a(arr[i]);
int j = 0;
int count = arr[i];
int tmp = 1;
for (; count--; j ++)
{
int flag = 1;
while (flag)
{
if (j == arr[i])
j = 0;
if (a[j]._flag == false)
flag--;
j++;
}
if (j == arr[i])
j = 0;
while (a[j]._flag == true)
{
j++;
if (j == arr[i])
j = 0;
}
a[j]._data =tmp++;
a[j]._flag = true;
}
int k = 0;
for (; k < arr[i]; k++)
cout << a[k]._data << " ";
cout << endl;
}
}
return 0;
}
| [
"[email protected]"
] | [
[
[
1,
81
]
]
] |
19203a417004197a3b51e22fe5a3dc21d6bcd8c4 | 57f87cd5fb9448bc6cdbf10769365393efae3a00 | /firmware_v5/telelogger/teleclient.h | a6433b87bd84452fb52cfd90b903677e97fb909f | [] | no_license | NatroNx/Freematics | 6a366805aef406d6f4deae050414f9611bbe710e | 011ae3212f57fdee7648eb34171e141c55a413ed | refs/heads/master | 2020-03-25T02:15:51.919000 | 2018-07-31T13:14:23 | 2018-07-31T13:14:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,569 | h | class TeleClient
{
public:
virtual void reset()
{
txCount = 0;
txBytes = 0;
rxBytes = 0;
}
virtual bool notify(byte event, const char* serverKey, const char* payload = 0) { return true; }
virtual bool connect() { return true; }
virtual bool transmit(const char* packetBuffer, unsigned int packetSize) { return true; }
virtual void inbound() {}
virtual bool begin() { return true; }
virtual void end() {}
uint32_t txCount = 0;
uint32_t txBytes = 0;
uint32_t rxBytes = 0;
uint32_t lastSyncTime = 0;
uint32_t lastSentTime = 0;
uint16_t feedid = 0;
};
class TeleClientUDP : public TeleClient
{
public:
bool notify(byte event, const char* serverKey, const char* payload = 0);
bool connect();
bool transmit(const char* packetBuffer, unsigned int packetSize);
void inbound();
bool verifyChecksum(char* data);
#if NET_DEVICE == NET_WIFI
UDPClientWIFI net;
#elif NET_DEVICE == NET_SIM800
UDPClientSIM800 net;
#elif NET_DEVICE == NET_SIM5360
UDPClientSIM5360 net;
#elif NET_DEVICE == NET_SIM7600
UDPClientSIM7600 net;
#else
NullClient net;
#endif
};
class TeleClientHTTP : public TeleClient
{
public:
bool connect();
bool transmit(const char* packetBuffer, unsigned int packetSize);
#if NET_DEVICE == NET_WIFI
HTTPClientWIFI net;
#elif NET_DEVICE == NET_SIM800
HTTPClientSIM800 net;
#elif NET_DEVICE == NET_SIM5360
HTTPClientSIM5360 net;
#elif NET_DEVICE == NET_SIM7600
HTTPClientSIM7600 net;
#else
NullClient net;
#endif
}; | [
"[email protected]"
] | [
[
[
1,
61
]
]
] |
7ade5627a226f91a37d1e00ba158ba1f1eace614 | 6a56f4e8bfa2da98cfc51a883b7cae01736c3046 | /ovaldi-code-r1804-trunk/src/probes/unix/PasswordProbe.h | 03062e89f9d72a9942bd7a1aac071a565a9a4ae6 | [] | no_license | tmcclain-taptech/Ovaldi-Win10 | 6b11e495c8d37fd73aae6c0281287cadbc491e59 | 7214d742c66f3df808d70e880ba9dad69cea403d | refs/heads/master | 2021-07-07T09:36:30.776000 | 2019-03-28T19:11:29 | 2019-03-28T19:11:29 | 164,451,763 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,857 | h | //
//
//****************************************************************************************//
// Copyright (c) 2002-2014, The MITRE Corporation
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this list
// of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice, this
// list of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
// * Neither the name of The MITRE Corporation nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
// SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
// OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//****************************************************************************************//
#ifndef PASSWORDPROBE_H
#define PASSWORDPROBE_H
#include "AbsProbe.h"
#include "Item.h"
#include "Object.h"
#include <pwd.h>
#include <string>
/**
This class is responsible for collecting information about unix password_objects.
*/
class PasswordProbe : public AbsProbe {
public:
virtual ~PasswordProbe();
/** Get all the files on the system that match the pattern and collect their attributes. */
virtual ItemVector* CollectItems(Object* object);
/** Return a new Item created for storing file information */
virtual Item* CreateItem();
/** Ensure that the PasswordProbe is a singleton. */
static AbsProbe* Instance();
private:
PasswordProbe();
/** Creates an item from a passwd struct */
Item *CreateItemFromPasswd(struct passwd const *pwInfo);
/** Finds a single item by name. */
Item *GetSingleItem(const std::string& username);
/** Finds multiple items according to the given object entity. */
ItemVector *GetMultipleItems(Object *passwordObject);
/** Singleton instance */
static PasswordProbe* instance;
};
#endif
| [
"[email protected]"
] | [
[
[
1,
75
]
]
] |
8b494503d9bf74ff5d28e840affc467e8a440a51 | 34a3165ded55c6ac5ffe2ff17c9996c66e0e80b5 | /cpp/ETProtect.cpp | 989ebb94e3100accc0e0e0fd02bff4f34144df29 | [] | no_license | monkeyde17/et-protect-package | d806a3196c28c4176374bc21e7ec5769faa72347 | 77e04d1834d0723c2de7f424a1cbc1efd2321991 | refs/heads/master | 2016-09-06T05:53:58.824000 | 2014-12-07T02:29:37 | 2014-12-07T02:29:37 | 27,655,865 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,888 | cpp | //
// ETProtect.cpp
// testcpp
//
// Created by etond on 14/12/3.
//
//
#include "ETProtect.h"
bool ETProtect::isOriginPackage()
{
unsigned int uHashValue = calculateValueFromFile();
unsigned int uReadValue = readValueFromFile();
#if (ETPROTECTDEBUG)
CCLOG("[log] -- hash %u", uHashValue);
CCLOG("[log] -- read %u", uReadValue);
#endif
if (uReadValue == 0 || uHashValue == 0)
{
return false;
}
return uReadValue == uHashValue;
}
unsigned int ETProtect::readValueFromFile(std::string filename /* default = config.et */)
{
unsigned int uValue = 0;
Data data = FileUtils::getInstance()->getDataFromFile(filename);
if (data.getSize() > 0)
{
uValue = ((ETProtectData *)data.getBytes())->getHashValue();
}
return uValue;
}
unsigned int ETProtect::calculateValueFromFile(unsigned int seed /* default = 0x12345678 */)
{
std::string path = "";
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
JniMethodInfo minfo;
bool isHave = JniHelper::getStaticMethodInfo(minfo,
"org/cocos2dx/cpp/AppActivity",
"getPath",
"()Ljava/lang/String;");
if (isHave)
{
jobject jobj = minfo.env->CallStaticObjectMethod(minfo.classID, minfo.methodID);
/* get the return value */
path = JniHelper::jstring2string((jstring)jobj).c_str();
CCLOG("JNI SUCCESS!");
}
#endif
unsigned int value = 0;
if (path.length() > 0)
{
ssize_t len = 0;
unsigned char *buf = FileUtils::getInstance()->getFileDataFromZip(path, "classes.dex", &len);
if (buf)
{
value = XXH32(buf, len, seed);
}
delete[] buf;
}
return value;
}
| [
"[email protected]"
] | [
[
[
1,
77
]
]
] |
b13420aa4004b14e74a53305e3368b5f4ee9dc92 | 72d1b579366934a24af7aff13ebf9b8cdaf58d8c | /ReadImages.cpp | a8f247f3d5b7fd89ce0c49662b42f6ef479207a1 | [] | no_license | hgpvision/Keypoint-Matcher | 48496a59dbaffefe6e89e8e14efabdb9883848bb | bf265aba62b325fab300aba2bad357ff7321ba4a | refs/heads/master | 2021-01-15T15:05:50.913000 | 2017-08-08T14:45:53 | 2017-08-08T14:45:53 | 99,702,359 | 0 | 1 | null | null | null | null | GB18030 | C++ | false | false | 1,454 | cpp | /*
* 文件名称:ReadImages.cpp
* 摘 要:读取图片类,图片序列放入到一个文件夹中,如"C:\\imgFile",按一定格式命名,比如"0001.jpg","00010.jpg","1.jpg"
* 使用实例:
* 包含头文件: #include "ReadImages.h"
* 先声明要给读入图片类:ReadImages imageReader("C:\\imgFile", "", ".jpg");
* 读入图片: Mat prev = imageReader.loadImage(1,0); //将读入"1.jpg"图片,灰度格式
* 2016.05.23
*/
#include "ReadImages.h"
#pragma once
ReadImages::ReadImages(std::string basepath, const std::string imagename, const std::string suffix)
{
//将路径中的文件夹分隔符统一为'/'(可以不需要这个for循环,会自动统一,该语句使用的命令参考C++ Primer)
for (auto &c : basepath)
{
if (c == '\\')
{
c = '/';
}
}
_imgSource._basepath = basepath + "/"; //这里采用'/',而不是'\\'
_imgSource._imagename = imagename; //图片名(不含编号)
_imgSource._suffix = suffix; //图像扩展名
}
//读入单张图片
//输入:imgId,一般要读入序列图片,图片都有个编号
cv::Mat ReadImages::loadImage(int imgId, int imgType)
{
//将图片编号转好字符串
std::stringstream ss;
std::string imgNum;
ss << imgId;
ss >> imgNum;
//得到图片的完整绝对路径
std::string path = _imgSource._basepath + _imgSource._imagename + imgNum + _imgSource._suffix;
cv::Mat img = cv::imread(path,imgType);
return img;
} | [
"[email protected]"
] | [
[
[
1,
47
]
]
] |
82be31fc3524835f627befe774786637aae24645 | 469370ad9a81ec746270f54a6433853e517bafde | /input.h | fa59213d1dc084e2a98556a154757033ecde6c1c | [] | no_license | masaedw/landscaper | 42431ee6ea952a2476583b838b7ae31e687e6421 | 7b84f39d16a37de12d20be15e17f199737e1d6a8 | refs/heads/master | 2016-09-06T00:23:36.120000 | 2010-02-01T14:52:41 | 2010-02-01T14:52:41 | null | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 3,666 | h | #ifndef _INPUT_H_
#define _INPUT_H_
#include <map>
#include "collision.h"
namespace space{
//キーボード情報
//キーボードの値は整数に変換される。どういう変換かは使う人が考えること。
class Keyboard
{
public:
typedef std::map<unsigned short,unsigned short> KeyMap;
protected:
KeyMap keys;
public:
void clear(){keys.clear();}
Keyboard(){clear();}
~Keyboard(){}
//セット
void pushkey(unsigned short _k) { keys[_k] = _k; }
//アンセット
void pullkey(unsigned short _k) {
KeyMap::iterator it = keys.find(_k);
if( it != keys.end() ) keys.erase(it);
}
//情報をもらう
bool ispush(unsigned short _k) const{
if( keys.find(_k) == keys.end() ) return false;
return true;
}
//キーを全部丸ごとプレゼントする
const KeyMap& getkeys() const{ return keys;}
};
//ジョイスティック情報
//ボタン数は13と仮定。
class Joystick
{
bool button[13];
int x,y,z;
public:
void clear(){
x=0;y=0;z=0;
for(int i=0;i<16;i++) button[i]=false;
}
Joystick(){clear();}
~Joystick(){}
//セット(unsetの必要なし)
void setx(int _k) { x=_k; }
void sety(int _k) { y=_k; }
void setz(int _k) { z=_k; }
//ボタン系セット
void pushbutton(unsigned int _b){ if(_b>=13)return; button[_b]=true; }
//ボタン系アンセット
void pullbutton(unsigned int _b){ if(_b>=13)return; button[_b]=false; }
//情報をもらう
int getx() const { return x; }
int gety() const { return y; }
int getz() const { return z; }
bool ispush(unsigned int _b) const { if(_b>=13)return false; return button[_b]; }
};
//マウス
//4ボタン以上とか知らん。
class Mouse
{
public:
struct Button
{
private:
bool ispush;
Matrix21<int> pushpos;
Matrix21<int> pullpos;
public:
void clear(){
ispush=false;
pushpos = Matrix21<int>(0,0);
pullpos = Matrix21<int>(0,0);
}
Button(){ clear(); }
void push(const Matrix21<int>& _pos){ispush=true; pushpos=_pos;}
void pull(const Matrix21<int>& _pos){ispush=false;pullpos=_pos;}
const Matrix21<int>& getPushpos() const {return pushpos;}
const Matrix21<int>& getPullpos() const {return pullpos;}
bool isPush() const {return ispush;}
std::string output() const{
std::stringstream ss("");
ss << "::" << ispush << ":ps(" << pushpos.x << "," << pushpos.y << "):pl(" << pullpos.x << "," << pullpos.y << ")";
return ss.str();
}
};
protected:
Button left,right,middle;
Matrix21<int> nowpos;
public:
void clear(){
left.clear();
right.clear();
middle.clear();
nowpos = Matrix21<int>(0,0);
}
Mouse(){clear();}
//セット(アンセット必要なし)
void setpos(const Matrix21<int> &_pos){ nowpos=_pos; }
//ゲット
const Matrix21<int>& getpos() const { return nowpos; }
//返すだけ
const Button &getleft() const {return left;}
const Button &getmiddle() const {return middle;}
const Button &getright()const {return right;}
Button &setleft() {return left;}
Button &setmiddle() {return middle;}
Button &setright() { return right;}
std::string output() const{
std::stringstream ss("");
ss << "*l" << left.output() << "::m" << middle.output() << "::r" << right.output() << "::p(" << nowpos.x << "," << nowpos.y << ")";
return ss.str();
}
};
struct Input
{
Keyboard keyboard;
Mouse mouse;
Joystick joystick;
void clear(){
keyboard.clear();
mouse.clear();
joystick.clear();
}
std::string output() const{
std::stringstream ss("");
ss << "**ms" << mouse.output();
return ss.str();
}
};
}
#endif
| [
"[email protected]"
] | [
[
[
1,
161
]
]
] |
bba7327fa47b292b7a2a12379dbea888640a0e70 | 58790459d953a3e4b6722ed3ee939f82d9de8c3e | /my/PDF插件/sdkDC_v1_win/Adobe/Acrobat DC SDK/Version 1/PluginSupport/PIBrokerSDK/simple-ipc-lib/src/pipe_win.h | 4625bef0dc76752fdcc7b3a4966d087839cbd12f | [] | no_license | tisn05/VS | bb84deb993eb18d43d8edaf81afb753afa3d3188 | da56d392a518ba21edcb1a367b4b4378d65506f0 | refs/heads/master | 2020-09-25T05:49:31.713000 | 2016-08-22T01:22:16 | 2016-08-22T01:22:16 | 66,229,337 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,659 | h | // Copyright (c) 2010 Google 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.
#ifndef SIMPLE_IPC_PIPE_WIN_H_
#define SIMPLE_IPC_PIPE_WIN_H_
#include "os_includes.h"
#include "ipc_constants.h"
class PipePair {
public:
PipePair(bool inherit_fd2 = false);
HANDLE fd1() const { return srv_; }
HANDLE fd2() const { return cln_; }
static HANDLE OpenPipeServer(const wchar_t* name, bool low_integrity = false);
static HANDLE OpenPipeClient(const wchar_t* name, bool inherit, bool impersonate);
private:
HANDLE srv_;
HANDLE cln_;
};
class PipeWin {
public:
PipeWin();
~PipeWin();
bool OpenClient(HANDLE pipe);
bool OpenServer(HANDLE pipe, bool connect = false);
bool Write(const void* buf, size_t sz);
bool Read(void* buf, size_t* sz);
bool IsConnected() const { return INVALID_HANDLE_VALUE != pipe_; }
private:
HANDLE pipe_;
};
class PipeTransport : public PipeWin {
public:
static const size_t kBufferSz = 4096;
size_t Send(const void* buf, size_t sz) {
return Write(buf, sz) ? ipc::RcOK : ipc::RcErrTransportWrite;
}
char* Receive(size_t* size);
private:
IPCCharVector buf_;
};
#endif // SIMPLE_IPC_PIPE_WIN_H_
| [
"[email protected]"
] | [
[
[
1,
67
]
]
] |
6290623071614e1a5caf46e39ddc6e959b56f6cb | 256767f888195384e8a91bff0864d0afc3f7e4e9 | /AIS_TrackingAndDetection/tests/moc_euclideanDistance.cpp | 8e8d5da02912f8bd3b87c8b1bc3d57a65875d708 | [] | no_license | HelenHarman/AIS_Object_Tracking | a71b9c2df78c02180b7bb1ac2561a03a570ef935 | 3ec7128a739387299ac3e4a648e8c8f30274af97 | refs/heads/master | 2021-01-15T08:28:06.415000 | 2016-01-23T13:01:20 | 2016-01-23T13:01:20 | 43,375,968 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 35 | cpp | #include "moc_euclideanDistance.h"
| [
"[email protected]"
] | [
[
[
1,
1
]
]
] |
aad85aa770183929d8ccd9df0aacf59df35f147f | 465a87bdead9aee133a7b36b0c2e826ece517cbb | /ARStudy(Image processing)/ARStudy/main.cpp | 5ebb0f7ee747397046be8ca1b609d9d04b460e5c | [] | no_license | kshy9598/ARStudy | a5b55f3808d1e64cc96ee3e9266e4f4c23c3d611 | c55ce51cb595f677eb07549203d0032430a90aef | refs/heads/master | 2020-06-29T05:20:21.879000 | 2016-12-08T16:22:03 | 2016-12-08T16:22:03 | 74,446,922 | 0 | 1 | null | null | null | null | UHC | C++ | false | false | 4,927 | cpp | #include <iostream>
#include <fstream>
#include <cmath>
#include "opencv2\highgui\highgui.hpp"
#include "opencv2\opencv.hpp"
#pragma comment(lib, "opencv_world300d.lib")
const double PI = 3.14159265;
using namespace std;
using namespace cv;
bool bLBDown = false; // 마우스 버튼 눌렀는지 체크
bool checkDrag; // 드래그가 이루어졌는지 체크
CvRect box; // 드래그로 그린 박스
// 사각형 그리기
void draw_box(IplImage* img, CvRect rect)
{
cvRectangle(img, cvPoint(rect.x, rect.y),
cvPoint(rect.x + rect.width, rect.y + rect.height),
cvScalar(0xff, 0x00, 0x00));
}
// 마우스 드래그
void on_mouse(int event, int x, int y, int flag, void* params)
{
IplImage* image = (IplImage*)params;
if (event == CV_EVENT_LBUTTONDOWN){ // 왼쪽 버튼 눌렀을 시, 박스 초기화
bLBDown = true;
box = cvRect(x, y, 0, 0);
}
else if (event == CV_EVENT_LBUTTONUP){ // 왼쪽 버튼 눌렀다가 뗐을 때, 박스의 넓이, 높이를 설정한다.
bLBDown = false;
checkDrag = true;
if (box.width < 0)
{
box.x += box.width;
box.width *= -1;
}
if (box.height < 0)
{
box.y += box.height;
box.height *= -1;
}
draw_box(image, box);
}
else if (event == CV_EVENT_MOUSEMOVE && bLBDown){ // 드래그 중에는 박스의 넓이, 높이를 갱신한다.
box.width = x - box.x;
box.height = y - box.y;
}
}
// 이미지 복사
Mat copyMat(Mat source)
{
// source의 Mat을 result로 복사하는 작업
// opencv에 이미 구현이 되어있는 작업이다.
// source.copyTo(result);
Mat result = Mat::zeros(source.size(), source.type());
for (int i = 0; i < source.cols; i++){
for (int j = 0; j < source.rows; j++){
result.at<Vec3b>(j, i) = source.at<Vec3b>(j, i);
}
}
return result;
}
// 박스내 이미지 복사
Mat copyBoxMat(Mat source)
{
return source(box);
}
// y축반전
Mat yReflecting(Mat source)
{
Mat result = copyMat(source);
for (int i = 0; i < box.width; i++){
for (int j = 0; j < box.height; j++){
result.at<Vec3b>((box.y + j), (box.x + i)) = source.at<Vec3b>(box.y + j, (box.width + box.x - 1) - i);
}
}
return result;
}
// x축반전
Mat xReflecting(Mat source)
{
Mat result = copyMat(source);
for (int i = 0; i < box.width; i++){
for (int j = 0; j < box.height; j++){
result.at<Vec3b>((box.y + j), (box.x + i)) = source.at<Vec3b>((box.height + box.y - 1) - j, (box.x + i));
}
}
return result;
}
// 회전
Mat rotating(Mat source, double degree)
{
Mat result = copyMat(source);
int x0 = box.x + (box.width / 2);
int y0 = box.y + (box.height / 2);
double cosd = cos(degree*PI / 180);
double sind = sin(degree*PI / 180);
// 원본에 덮어씌우는 부분으로 인해 왼쪽 90도, 오른쪽 90도만 가능
for (int i = 0; i < box.width; i++){
for (int j = 0; j < box.height; j++){
int x1 = (box.x + i);
int y1 = (box.y + j);
int x = ((cosd * (x1 - x0)) - (sind * (y1 - y0)) + x0);
int y = ((sind * (x1 - x0)) - (cosd * (y1 - y0)) + y0);
result.at<Vec3b>(y, x) = source.at<Vec3b>((box.y + j), (box.x + i));
}
}
return result;
}
// 확대
Mat scaling(Mat source, Mat boxMat, double scale)
{
Mat result = copyMat(source);
Mat scaleBoxMat;
// 사각형 안의 Mat의 크기를 scale배 늘린다.
int boxWidth = (int)(boxMat.size().width * scale);
int boxHeight = (int)(boxMat.size().height * scale);
cv::resize(boxMat, scaleBoxMat, Size(boxWidth, boxHeight));
// 붙여넣을 때 시작 위치 정보를 갱신한다.
int x = box.x - (box.width / 2);
int y = box.y - (box.height / 2);
for (int i = 0; i < boxWidth; i++){
for (int j = 0; j < boxHeight; j++){
result.at<Vec3b>((y + j), (x + i)) = scaleBoxMat.at<Vec3b>(j, i);
}
}
return result;
}
int main()
{
IplImage copy;
IplImage * resultImage;
Mat resultMat, xReflectMat, yReflectMat, leftRotateMat, scaleMat, boxMat;
// 이미지 불러오기
Mat gMatImage = imread("./picture/pic.jpg", 1);
// Mat 이미지를 IplImage 로 복사한다.
copy = gMatImage;
resultImage = ©
checkDrag = false;
namedWindow("image");
setMouseCallback("image", on_mouse, resultImage);
cvShowImage("image", resultImage);
//드래그 대기
while (!checkDrag){
waitKey(100);
}
cvShowImage("image", resultImage);
//사각형 추가된 사진 저장
resultMat = cvarrToMat(resultImage);
boxMat = copyBoxMat(resultMat);
cout << box.x << ' ' << box.y << ' ' << box.width << ' ' << box.height << endl;
yReflectMat = yReflecting(resultMat); // y축 반전
xReflectMat = xReflecting(resultMat); // x축 반전
scaleMat = scaling(resultMat, boxMat, 1.5); // 크기 변경
leftRotateMat = rotating(resultMat, -90.0); // 90도 회전
waitKey(2000);
imshow("y반전 이미지", yReflectMat);
imshow("x반전 이미지", xReflectMat);
imshow("왼쪽 90도 회전 이미지", leftRotateMat);
imshow("1.5배 확대 이미지", scaleMat);
waitKey(0);
return 0;
} | [
"[email protected]"
] | [
[
[
1,
200
]
]
] |
9902eb5452ca24078c32fd40c10f077849f5b441 | 948d5663fe68495eb4090350e3bcfae33c3d314d | /include/forecast_io/factories/SynchronicDataPointDetailsSetter.hpp | d9eb866ded44e428527ccc44cf017d1059a870b9 | [
"Apache-2.0"
] | permissive | Crystalix007/DarkSky-CPP | b102f000f85d4413a559d79fa04b421a301bc14a | 10497ff292efdc460a67bc5dc44811b3a1459beb | refs/heads/master | 2020-06-17T04:49:55.946000 | 2019-07-08T21:17:18 | 2019-07-08T21:21:27 | 195,802,094 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,951 | hpp | #ifndef SYNCHRONICDATAPOINTDETAILSSETTER_HPP
#define SYNCHRONICDATAPOINTDETAILSSETTER_HPP
#include "../../common/InstanceReferenceHolder.hpp" // Base class: common::InstanceReferenceHolder
#include "../listeners/SynchronicDataPointDetailsListener.hpp" // Base class: forecast_io::listeners::SynchronicDataPointDetailsListener
#include "../SynchronicDataPoint.hpp"
#include "SingleDataPointDetailsSetter.hpp"
namespace forecast_io
{
namespace factories
{
class SynchronicDataPointDetailsSetter : public listeners::SynchronicDataPointDetailsListener,
public common::InstanceReferenceHolder<SynchronicDataPoint>
{
public:
SynchronicDataPointDetailsSetter(SynchronicDataPoint& instance) noexcept;
virtual void notifyApparentTemperature(double temperature);
virtual void notifyCloudCover(double cloudCover);
virtual void notifyDewPoint(double dewPoint);
virtual void notifyHumidity(double humidity);
virtual void notifyIcon(const std::string& name);
virtual void notifyNearestStormBearing(double bearing);
virtual void notifyNearestStormDistance(double distance);
virtual void notifyOzone(double ozone);
virtual void notifyPrecipitationIntensity(double intensity);
virtual void notifyPrecipitationProbability(double probability);
virtual void notifyPrecipitationType(const std::string& type);
virtual void notifyPressure(double pressure);
virtual void notifySummary(const std::string& summary);
virtual void notifyTemperature(double temperature);
virtual void notifyTime(time_t time);
virtual void notifyUVIndex(double uvIndex);
virtual void notifyVisibility(double visibility);
virtual void notifyWindBearing(double bearing);
virtual void notifyWindGust(double gust);
virtual void notifyWindSpeed(double speed);
private:
SingleDataPointDetailsSetter singleDataPointDetailsSetter;
};
} // namespace factories
} // namespace forecast_io
#endif // SYNCHRONICDATAPOINTDETAILSSETTER_HPP
| [
"[email protected]",
"[email protected]"
] | [
[
[
1,
4
],
[
6,
7
],
[
9,
15
],
[
18,
36
],
[
38,
39
],
[
41,
46
],
[
48,
48
],
[
50,
51
]
],
[
[
5,
5
],
[
8,
8
],
[
16,
17
],
[
37,
37
],
[
40,
40
],
[
47,
47
],
[
49,
49
]
]
] |
a702a5d40a3a672624e691115d63b4a004c979d0 | 7aa189c718f8a63c256685a435d027ace3833f6b | /include/ogonek/error.h++ | ca7ff1f2bc1d6ac11fcbdaacee61fbdef1c7430d | [
"CC0-1.0"
] | permissive | rmartinho/ogonek | d5523145108de1255298a17c1c25065beb19b82c | 0042f30c6c674effd21d379c53658c88054c58b9 | refs/heads/devel | 2020-05-21T15:17:39.490000 | 2019-09-29T10:58:31 | 2019-09-29T10:58:31 | 8,255,019 | 16 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 4,549 | // Ogonek
//
// Written in 2017 by Martinho Fernandes <[email protected]>
//
// To the extent possible under law, the author(s) have dedicated all copyright and related
// and neighboring rights to this software to the public domain worldwide. This software is
// distributed without any warranty.
//
// You should have received a copy of the CC0 Public Domain Dedication along with this software.
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
/**
* Error handling
* ==============
*/
#ifndef OGONEK_ERROR_HPP
#define OGONEK_ERROR_HPP
#include <ogonek/error_fwd.h++>
#include <ogonek/concepts.h++>
#include <ogonek/types.h++>
#include <ogonek/encoding.h++>
#include <range/v3/range_concepts.hpp>
#include <range/v3/range_traits.hpp>
#include <stdexcept>
namespace ogonek {
/**
* .. class:: unicode_error
*
* The base class for all Unicode-related errors.
*/
struct unicode_error
: virtual std::exception {
char const* what() const noexcept override {
return u8"Unicode error";
}
};
/**
* .. class:: template <EncodingForm Encoding>\
* encode_error : virtual unicode_error
*
* :thrown: when an error occurs during an encoding operation.
*/
template <typename Encoding>
struct encode_error
: virtual unicode_error {
CONCEPT_ASSERT(EncodingForm<Encoding>());
char const* what() const noexcept override {
return u8"encoding failed ";
}
};
/**
* .. class:: template <EncodingForm Encoding>\
* decode_error : virtual unicode_error
*
* :thrown: when an error occurs during a decoding operation.
*/
template <typename Encoding>
struct decode_error
: virtual unicode_error {
CONCEPT_ASSERT(EncodingForm<Encoding>());
char const* what() const noexcept override {
return u8"decoding failed";
}
};
/**
* .. var:: auto assume_valid
*
* A tag used to request that encoding/decoding functions assume the
* input has been validated before.
*
* .. warning::
*
* Using this tag with input that isn't actually valid yields
* undefined behavior.
*/
struct assume_valid_t {} constexpr assume_valid {};
/**
* .. var:: auto discard_errors
*
* An error handler for encoding/decoding functions that simply
* discards the portions of the input that have errors.
*/
struct discard_errors_t {
template <typename E>
optional<code_point> operator()(E) const {
return {};
}
} constexpr discard_errors {};
CONCEPT_ASSERT(EncodeErrorHandler<discard_errors_t, archetypes::EncodingForm>());
CONCEPT_ASSERT(DecodeErrorHandler<discard_errors_t, archetypes::EncodingForm>());
/**
* .. var:: auto replace_errors
*
* An error handler for encoding/decoding functions that replaces
* portions of the input that have errors with a replacement character.
* When decoding, this is |u-fffd|, but when encoding and the target
* doesn't support it, some encoding-specific character is used
* instead.
*/
struct replace_errors_t {
template <typename Encoding,
CONCEPT_REQUIRES_(EncodingForm<Encoding>())>
optional<code_point> operator()(encode_error<Encoding>) const {
return replacement_character_v<Encoding>;
}
template <typename Encoding,
CONCEPT_REQUIRES_(EncodingForm<Encoding>())>
optional<code_point> operator()(decode_error<Encoding>) const {
return { U'\uFFFD' };
}
} constexpr replace_errors {};
CONCEPT_ASSERT(EncodeErrorHandler<replace_errors_t, archetypes::EncodingForm>());
CONCEPT_ASSERT(DecodeErrorHandler<replace_errors_t, archetypes::EncodingForm>());
/**
* .. var:: auto throw_error
*
* An error handler for encoding/decoding functions that throws when an
* error is found in the input.
*/
struct throw_error_t {
template <typename E>
optional<code_point> operator()(E e) const {
throw e;
}
} constexpr throw_error {};
CONCEPT_ASSERT(EncodeErrorHandler<throw_error_t, archetypes::EncodingForm>());
CONCEPT_ASSERT(DecodeErrorHandler<throw_error_t, archetypes::EncodingForm>());
} // namespace ogonek
#endif // OGONEK_ERROR_HPP
| [
"[email protected]"
] | [
[
[
1,
148
]
]
] |
|
0293e83add680ed3f8e92ecea17c897a91d1270b | 1ca3477d99bddb6611f2feb67c8ce0c4569d8a4b | /Memendo.cc | 7ac722a8f7b952968a9ec15d38a1c9bbc3afc637 | [] | no_license | TaoJun724/DesignPattern | 0da37a3a34fba54ba21cb809875b20d9eeba3443 | b0c62668cfad5b48b85b413e78ee9334812a74b2 | refs/heads/master | 2020-06-30T08:57:32.156000 | 2019-08-07T07:42:09 | 2019-08-07T07:42:09 | 200,785,533 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,461 | cc | #include <stdio.h>
#include<string>
class Memento {
public:
Memento(int n, std::string s) {
_s = s;
_money = n;
}
void setMoney(int n) {
_money = n;
}
int getMoney() {
return _money;
}
void setState(std::string s) {
_s = s;
}
std::string getState() {
return _s;
}
private:
int _money;
std::string _s;
};
class Worker {
public:
Worker(std::string name, int money, std::string s) {
_name = name;
_money = money;
_s = s;
}
void show() {
printf("%s现在有钱%d元,生活状态%s!\n", _name.c_str(), _money, _s.c_str());
}
void setState(int money, std::string s) {
_money = money;
_s = s;
}
Memento* createMemnto() {
return new Memento(_money,_s);
}
void restoreMemnto(Memento* m) {
_money = m->getMoney();
_s = m->getState();
}
private:
std::string _name;
int _money;
std::string _s;
};
class WorkerStorage {
public:
void setMemento(Memento* m) {
_memento = m;
}
Memento* getMement() {
return _memento;
}
private:
Memento* _memento;
};
int main() {
Worker* zhangsan = new Worker("张三", 10000, "富裕");
zhangsan->show();
//记住张三现在的状态
WorkerStorage* storage = new WorkerStorage;
storage->setMemento(zhangsan->createMemnto());
//张三赌博输了钱,只剩下10元
zhangsan->setState(10, "贫困");
zhangsan->show();
//经过努力张三又回到了之前的状态。
zhangsan->restoreMemnto(storage->getMement());
zhangsan->show();
return 0;
}
| [
"[email protected]"
] | [
[
[
1,
93
]
]
] |
9b67f6e27a369c3b66f7fb8bf435dc44a8750a9f | 5dbdb28b66c4828bf83564f1cf63f82480d6395f | /HelloWorld_demo_game/Classes/DemoGame/GameClock.h | 0376404ad2fc38c0fa7670b28ad9433a96177a3c | [] | no_license | gengyu-mamba/CardGames | 87a2b8fca377a6bd3de0ba4c6fe09a9e85e22848 | d2b0133c02cc04b75a49ca164a086aaa5603715d | refs/heads/master | 2020-04-02T18:23:19.395000 | 2018-11-08T02:34:23 | 2018-11-08T02:34:23 | 154,698,113 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 487 | h | #ifndef GAME_CLOCK_H
#define GAME_CLOCK_H
#include "cocos2d.h"
USING_NS_CC;
class GameLayer;
class GameClock :public CCLayer
{
public:
GameClock(GameLayer *pGameLayer);
virtual ~GameClock();
void ShowClock(int iTime,int iTablePos);
void ResetClock();
private:
virtual void onEnter();
virtual void onExit();
void OnSecondTimer(float dt);
CCSprite *m_pSpriteBG;
CCLabelAtlas *m_pNumLable;
int m_iTime;
int m_iTablePos;
GameLayer *m_pGameLayer;
};
#endif
| [
"[email protected]"
] | [
[
[
1,
34
]
]
] |
4ff557683a174bc39aea59e06a19b563d55927d6 | cde943952b79d67f4972d180d20b97fc823db548 | /preprocesser/preprocesser/self2.hpp | 0892b2563bae695f02d2254829e81a6cb84c630e | [] | no_license | yourgracee/preprocesser | e66a0b0c9680442717652185e9ed2dc5172f7771 | 349453d4092ffe7927b0c1067d3cefc8bf2bdfff | refs/heads/master | 2020-04-09T10:52:16.135000 | 2018-12-04T02:46:03 | 2018-12-04T02:46:03 | 160,285,495 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,701 | hpp | #ifdef LIMIT_2
#include "tuple.hpp"
#define START_2 TUPLE(0, LIMIT_2)
#define FINISH_2 TUPLE(1, LIMIT_2)
#undef DEPTH
#define DEPTH 2
# if START_2 <= 0 && FINISH_2 >= 0
# define ITERATION_2 0
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 1 && FINISH_2 >= 1
# define ITERATION_2 1
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 2 && FINISH_2 >= 2
# define ITERATION_2 2
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 3 && FINISH_2 >= 3
# define ITERATION_2 3
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 4 && FINISH_2 >= 4
# define ITERATION_2 4
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 5 && FINISH_2 >= 5
# define ITERATION_2 5
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 6 && FINISH_2 >= 6
# define ITERATION_2 6
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 7 && FINISH_2 >= 7
# define ITERATION_2 7
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 8 && FINISH_2 >= 8
# define ITERATION_2 8
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 9 && FINISH_2 >= 9
# define ITERATION_2 9
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 10 && FINISH_2 >= 10
# define ITERATION_2 10
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 11 && FINISH_2 >= 11
# define ITERATION_2 11
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 12 && FINISH_2 >= 12
# define ITERATION_2 12
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 13 && FINISH_2 >= 13
# define ITERATION_2 13
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 14 && FINISH_2 >= 14
# define ITERATION_2 14
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 15 && FINISH_2 >= 15
# define ITERATION_2 15
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 16 && FINISH_2 >= 16
# define ITERATION_2 16
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 17 && FINISH_2 >= 17
# define ITERATION_2 17
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 18 && FINISH_2 >= 18
# define ITERATION_2 18
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 19 && FINISH_2 >= 19
# define ITERATION_2 19
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 20 && FINISH_2 >= 20
# define ITERATION_2 20
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 21 && FINISH_2 >= 21
# define ITERATION_2 21
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 22 && FINISH_2 >= 22
# define ITERATION_2 22
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 23 && FINISH_2 >= 23
# define ITERATION_2 23
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 24 && FINISH_2 >= 24
# define ITERATION_2 24
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 25 && FINISH_2 >= 25
# define ITERATION_2 25
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 26 && FINISH_2 >= 26
# define ITERATION_2 26
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 27 && FINISH_2 >= 27
# define ITERATION_2 27
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 28 && FINISH_2 >= 28
# define ITERATION_2 28
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 29 && FINISH_2 >= 29
# define ITERATION_2 29
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 30 && FINISH_2 >= 30
# define ITERATION_2 30
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 31 && FINISH_2 >= 31
# define ITERATION_2 31
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 32 && FINISH_2 >= 32
# define ITERATION_2 32
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 33 && FINISH_2 >= 33
# define ITERATION_2 33
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 34 && FINISH_2 >= 34
# define ITERATION_2 34
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 35 && FINISH_2 >= 35
# define ITERATION_2 35
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 36 && FINISH_2 >= 36
# define ITERATION_2 36
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 37 && FINISH_2 >= 37
# define ITERATION_2 37
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 38 && FINISH_2 >= 38
# define ITERATION_2 38
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 39 && FINISH_2 >= 39
# define ITERATION_2 39
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 40 && FINISH_2 >= 40
# define ITERATION_2 40
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 41 && FINISH_2 >= 41
# define ITERATION_2 41
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 42 && FINISH_2 >= 42
# define ITERATION_2 42
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 43 && FINISH_2 >= 43
# define ITERATION_2 43
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 44 && FINISH_2 >= 44
# define ITERATION_2 44
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 45 && FINISH_2 >= 45
# define ITERATION_2 45
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 46 && FINISH_2 >= 46
# define ITERATION_2 46
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 47 && FINISH_2 >= 47
# define ITERATION_2 47
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 48 && FINISH_2 >= 48
# define ITERATION_2 48
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 49 && FINISH_2 >= 49
# define ITERATION_2 49
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 50 && FINISH_2 >= 50
# define ITERATION_2 50
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 51 && FINISH_2 >= 51
# define ITERATION_2 51
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 52 && FINISH_2 >= 52
# define ITERATION_2 52
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 53 && FINISH_2 >= 53
# define ITERATION_2 53
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 54 && FINISH_2 >= 54
# define ITERATION_2 54
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 55 && FINISH_2 >= 55
# define ITERATION_2 55
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 56 && FINISH_2 >= 56
# define ITERATION_2 56
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 57 && FINISH_2 >= 57
# define ITERATION_2 57
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 58 && FINISH_2 >= 58
# define ITERATION_2 58
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 59 && FINISH_2 >= 59
# define ITERATION_2 59
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 60 && FINISH_2 >= 60
# define ITERATION_2 60
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 61 && FINISH_2 >= 61
# define ITERATION_2 61
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 62 && FINISH_2 >= 62
# define ITERATION_2 62
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 63 && FINISH_2 >= 63
# define ITERATION_2 63
# include FILENAME_2
# undef ITERATION_2
# endif
# if START_2 <= 64 && FINISH_2 >= 64
# define ITERATION_2 64
# include FILENAME_2
# undef ITERATION_2
# endif
#undef DEPTH
#define DEPTH 1
#endif | [
"[email protected]"
] | [
[
[
1,
336
]
]
] |
3c1b9a977eb477d5b194c9d62796fdbdb650af98 | 74b07eb2bc01383744514b70b385571fb90a1a04 | /test/test.cpp | c870d6500c7d2c64c80815743dbbe2e47990c430 | [] | no_license | yksym/x86_64_hook_without_ld_preload | 8ae067c195bf1eb0f23d67a1087ad3f8ebcfab4a | 2ed1eaf37f688199f12e3aa34a6f3435b906b932 | refs/heads/master | 2016-09-05T11:08:33.212000 | 2015-09-03T13:02:04 | 2015-09-03T13:02:04 | 40,049,578 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 742 | cpp | #include <stdio.h>
#include <stdlib.h>
#include <hook.h>
extern "C" {
void* calloc_hook(size_t n, size_t size)
{
DECL_ORG_FUNC(calloc, org_calloc);
puts( __FUNCTION__ );
return org_calloc(n, size);
}
};
void test(const char* program)
{
puts(__FILE__ ": 1st");
{
HOOK(program, calloc, calloc_hook);
void* b = calloc(1, 10);
free(b);
}
puts(__FILE__ ": 2nd");
void* c = calloc(1, 10);
free(c);
puts(__FILE__ ": 3rd");
{
HOOK(program, calloc, calloc_hook);
void* b = calloc(1, 10);
free(b);
}
}
void test2(const char* program);
int main(int argc, char** argv)
{
test(argv[0]);
test2(LIB_NAME);
return 0;
}
| [
"[email protected]"
] | [
[
[
1,
43
]
]
] |
7394745b36ae5104c00825320576a873b5d50654 | c5ed2d57496cafa1b10925814b4fc670fb9d84af | /Opensankore/build-Sankore_3.1-Unnamed-Release/build/win32/release/moc/moc_UBExportCFF.cpp | ccd670b2c223a0e089afb0adb057245688ac9bac | [] | no_license | Educabile/Ardesia | 5f5175fef5d7a15ea79469901bdd4c068cc8fec7 | 9b7b0bfe1c89e89c0ef28f93f6b1e0ac8c348230 | refs/heads/master | 2020-03-31T17:16:50.538000 | 2018-10-10T12:34:43 | 2018-10-10T12:34:43 | 152,416,207 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,429 | cpp | /****************************************************************************
** Meta object code from reading C++ file 'UBExportCFF.h'
**
** Created: Fri 4. May 12:28:36 2018
** by: The Qt Meta Object Compiler version 63 (Qt 4.8.0)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../../../../../Sankore-3.1/src/adaptors/UBExportCFF.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'UBExportCFF.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 63
#error "This file was generated using the moc from 4.8.0. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_UBExportCFF[] = {
// content:
6, // revision
0, // classname
0, 0, // classinfo
0, 0, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
0 // eod
};
static const char qt_meta_stringdata_UBExportCFF[] = {
"UBExportCFF\0"
};
void UBExportCFF::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
Q_UNUSED(_o);
Q_UNUSED(_id);
Q_UNUSED(_c);
Q_UNUSED(_a);
}
const QMetaObjectExtraData UBExportCFF::staticMetaObjectExtraData = {
0, qt_static_metacall
};
const QMetaObject UBExportCFF::staticMetaObject = {
{ &UBExportAdaptor::staticMetaObject, qt_meta_stringdata_UBExportCFF,
qt_meta_data_UBExportCFF, &staticMetaObjectExtraData }
};
#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &UBExportCFF::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION
const QMetaObject *UBExportCFF::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}
void *UBExportCFF::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_UBExportCFF))
return static_cast<void*>(const_cast< UBExportCFF*>(this));
return UBExportAdaptor::qt_metacast(_clname);
}
int UBExportCFF::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = UBExportAdaptor::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
return _id;
}
QT_END_MOC_NAMESPACE
| [
"salvatore.naddeo@€ducabile.it"
] | [
[
[
1,
81
]
]
] |
bcee12c3aa60f8c1d8f0802c1bfdfe7600a1e3ef | 067b197860f7712e3f92564d0f8d88b0cf34f9d7 | /ext/hera/wasserstein/include/dnn/parallel/tbb.h | 64c59e0ee985223027151daa201d626258eb299b | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | tgebhart/dionysus_tensorflow | be8757369beb4997b12246c5c7d3cbdbb2fd84bb | 344769bb6d5446c8fd43462b1dfd6a08d35631a8 | refs/heads/master | 2021-09-28T10:03:56.406000 | 2018-11-16T17:15:34 | 2018-11-16T17:15:34 | 112,226,756 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,126 | h | #ifndef PARALLEL_H
#define PARALLEL_H
//#include <iostream>
#include <vector>
#include <boost/range.hpp>
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
#ifdef TBB
#include <tbb/tbb.h>
#include <tbb/concurrent_hash_map.h>
#include <tbb/scalable_allocator.h>
#include <boost/serialization/split_free.hpp>
#include <boost/serialization/collections_load_imp.hpp>
#include <boost/serialization/collections_save_imp.hpp>
namespace dnn
{
using tbb::mutex;
using tbb::task_scheduler_init;
using tbb::task_group;
using tbb::task;
template<class T>
struct vector
{
typedef tbb::concurrent_vector<T> type;
};
template<class T>
struct atomic
{
typedef tbb::atomic<T> type;
static T compare_and_swap(type& v, T n, T o) { return v.compare_and_swap(n,o); }
};
template<class Iterator, class F>
void do_foreach(Iterator begin, Iterator end, const F& f) { tbb::parallel_do(begin, end, f); }
template<class Range, class F>
void for_each_range_(const Range& r, const F& f)
{
for (typename Range::iterator cur = r.begin(); cur != r.end(); ++cur)
f(*cur);
}
template<class F>
void for_each_range(size_t from, size_t to, const F& f)
{
//static tbb::affinity_partitioner ap;
//tbb::parallel_for(c.range(), boost::bind(&for_each_range_<typename Container::range_type, F>, _1, f), ap);
tbb::parallel_for(from, to, f);
}
template<class Container, class F>
void for_each_range(const Container& c, const F& f)
{
//static tbb::affinity_partitioner ap;
//tbb::parallel_for(c.range(), boost::bind(&for_each_range_<typename Container::range_type, F>, _1, f), ap);
tbb::parallel_for(c.range(), boost::bind(&for_each_range_<typename Container::const_range_type, F>, _1, f));
}
template<class Container, class F>
void for_each_range(Container& c, const F& f)
{
//static tbb::affinity_partitioner ap;
//tbb::parallel_for(c.range(), boost::bind(&for_each_range_<typename Container::range_type, F>, _1, f), ap);
tbb::parallel_for(c.range(), boost::bind(&for_each_range_<typename Container::range_type, F>, _1, f));
}
template<class ID, class NodePointer, class IDTraits, class Allocator>
struct map_traits
{
typedef tbb::concurrent_hash_map<ID, NodePointer, IDTraits, Allocator> type;
typedef typename type::range_type range;
};
struct progress_timer
{
progress_timer(): start(tbb::tick_count::now()) {}
~progress_timer()
{ std::cout << (tbb::tick_count::now() - start).seconds() << " s" << std::endl; }
tbb::tick_count start;
};
}
// Serialization for tbb::concurrent_vector<...>
namespace boost
{
namespace serialization
{
template<class Archive, class T, class A>
void save(Archive& ar, const tbb::concurrent_vector<T,A>& v, const unsigned int file_version)
{ stl::save_collection(ar, v); }
template<class Archive, class T, class A>
void load(Archive& ar, tbb::concurrent_vector<T,A>& v, const unsigned int file_version)
{
stl::load_collection<Archive,
tbb::concurrent_vector<T,A>,
stl::archive_input_seq< Archive, tbb::concurrent_vector<T,A> >,
stl::reserve_imp< tbb::concurrent_vector<T,A> >
>(ar, v);
}
template<class Archive, class T, class A>
void serialize(Archive& ar, tbb::concurrent_vector<T,A>& v, const unsigned int file_version)
{ split_free(ar, v, file_version); }
template<class Archive, class T>
void save(Archive& ar, const tbb::atomic<T>& v, const unsigned int file_version)
{ T v_ = v; ar << v_; }
template<class Archive, class T>
void load(Archive& ar, tbb::atomic<T>& v, const unsigned int file_version)
{ T v_; ar >> v_; v = v_; }
template<class Archive, class T>
void serialize(Archive& ar, tbb::atomic<T>& v, const unsigned int file_version)
{ split_free(ar, v, file_version); }
}
}
#else
#include <algorithm>
#include <map>
#include <boost/progress.hpp>
namespace dnn
{
template<class T>
struct vector
{
typedef ::std::vector<T> type;
};
template<class T>
struct atomic
{
typedef T type;
static T compare_and_swap(type& v, T n, T o) { if (v != o) return v; v = n; return o; }
};
template<class Iterator, class F>
void do_foreach(Iterator begin, Iterator end, const F& f) { std::for_each(begin, end, f); }
template<class F>
void for_each_range(size_t from, size_t to, const F& f)
{
for (size_t i = from; i < to; ++i)
f(i);
}
template<class Container, class F>
void for_each_range(Container& c, const F& f)
{
BOOST_FOREACH(const typename Container::value_type& i, c)
f(i);
}
template<class Container, class F>
void for_each_range(const Container& c, const F& f)
{
BOOST_FOREACH(const typename Container::value_type& i, c)
f(i);
}
struct mutex
{
struct scoped_lock
{
scoped_lock() {}
scoped_lock(mutex& ) {}
void acquire(mutex& ) const {}
void release() const {}
};
};
struct task_scheduler_init
{
task_scheduler_init(unsigned) {}
void initialize(unsigned) {}
static const unsigned automatic = 0;
static const unsigned deferred = 0;
};
struct task_group
{
template<class Functor>
void run(const Functor& f) const { f(); }
void wait() const {}
};
template<class ID, class NodePointer, class IDTraits, class Allocator>
struct map_traits
{
typedef std::map<ID, NodePointer,
typename IDTraits::Comparison,
Allocator> type;
typedef type range;
};
using boost::progress_timer;
}
#endif // TBB
namespace dnn
{
template<class Range, class F>
void do_foreach(const Range& range, const F& f) { do_foreach(boost::begin(range), boost::end(range), f); }
}
#endif
| [
"[email protected]"
] | [
[
[
1,
220
]
]
] |
95534aae2f06adbc3b44e859658780f8bf0cf800 | 3f9081b23333e414fb82ccb970e15b8e74072c54 | /bs2k/behaviors/skills/oneortwo_step_kick_bms.h | e7f968c14d8092e86a4e41ed23b6e7ac3a2558ab | [] | no_license | rc2dcc/Brainstormers05PublicRelease | 5c8da63ac4dd3b84985bdf791a4e5580bbf0ba59 | 2141093960fad33bf2b3186d6364c08197e9fe8e | refs/heads/master | 2020-03-22T07:32:36.757000 | 2018-07-04T18:28:32 | 2018-07-04T18:28:32 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,945 | h | /*
Brainstormers 2D (Soccer Simulation League 2D)
PUBLIC SOURCE CODE RELEASE 2005
Copyright (C) 1998-2005 Neuroinformatics Group,
University of Osnabrueck, Germany
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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _ONEORTWO_STEP_KICK_BMS_H_
#define _ONEORTWO_STEP_KICK_BMS_H_
/* This behavior is a port of Move_1or2_Step_Kick into the behavior
framework. get_cmd will try to kick in one step and otherwise return
a cmd that will start a two-step kick. There are some functions
that return information about the reachable velocities and the needed
steps, so that you can prepare in your code for what this behavior will
do.
This behavior usually takes the current player position as reference point,
but you can override this by calling set_state() prior to any other function.
This makes it possible to "fake" the player's position during the current cycle.
Use reset_state to re-read the WS information, or wait until the next cycle.
Note that kick_to_pos_with_final_vel() is rather unprecise concerning the
final velocity of the ball. I don't know how to calculate the needed starting
vel precisely, so I have taken the formula from the original Neuro_Kick2 move
(which was even more unprecise...) and tweaked it a bit, but it is still
not perfect.
Note also that this behavior, as opposed to the original move, has a working
collision check - the original move ignored the player's vel...
(w) 2002 Manuel Nickschas
*/
#include "../base_bm.h"
#include "one_step_kick_bms.h"
#include "angle.h"
#include "Vector.h"
#include "tools.h"
#include "cmd.h"
#include "n++.h"
#include "macro_msg.h"
#include "valueparser.h"
#include "options.h"
#include "ws_info.h"
#include "log_macros.h"
#include "mystate.h"
#include "../../policy/abstract_mdp.h"
class OneOrTwoStepKickItrActions {
static const Value kick_pwr_min = 20;
static const Value kick_pwr_inc = 10;
static const Value kick_pwr_max = 100;
static const Value kick_ang_min = 0;
static const Value kick_ang_inc = 2*PI/8.;
// static const Value kick_ang_inc = 2*PI/36.; // ridi: I think it should be as much! too much
static const Value kick_ang_max = 2*PI-kick_ang_inc;
static const Value dash_pwr_min = 20;
static const Value dash_pwr_inc = 20;
static const Value dash_pwr_max = 100;
static const Value turn_ang_min = 0;
static const Value turn_ang_inc = 2*PI/18.;
// static const Value turn_ang_max = 2*PI-turn_ang_inc;
static const Value turn_ang_max = 0; // ridi: do not allow turns
static const Value kick_pwr_steps = (kick_pwr_max-kick_pwr_min)/kick_pwr_inc + 1;
static const Value dash_pwr_steps = (dash_pwr_max-dash_pwr_min)/dash_pwr_inc + 1;
static const Value turn_ang_steps = (turn_ang_max-turn_ang_min)/turn_ang_inc + 1;
static const Value kick_ang_steps = (kick_ang_max-kick_ang_min)/kick_ang_inc + 1;
Cmd_Main action;
Value kick_pwr,dash_pwr;
ANGLE kick_ang,turn_ang;
int kick_pwr_done,kick_ang_done,dash_pwr_done,turn_ang_done;
public:
void reset() {
kick_pwr_done=0;kick_ang_done=0;dash_pwr_done=0;turn_ang_done=0;
kick_pwr=kick_pwr_min;kick_ang= ANGLE(kick_ang_min);dash_pwr=dash_pwr_min;
turn_ang=ANGLE(turn_ang_min);
}
Cmd_Main *next() {
if(kick_pwr_done<kick_pwr_steps && kick_ang_done<kick_ang_steps) {
action.unset_lock();
action.unset_cmd();
action.set_kick(kick_pwr,kick_ang.get_value_mPI_pPI());
kick_ang+= ANGLE(kick_ang_inc);
if(++kick_ang_done>=kick_ang_steps) {
kick_ang=ANGLE(kick_ang_min);
kick_ang_done=0;
kick_pwr+=kick_pwr_inc;
kick_pwr_done++;
}
return &action;
}
if(dash_pwr_done<dash_pwr_steps) {
action.unset_lock();
action.unset_cmd();
action.set_dash(dash_pwr);
dash_pwr+=dash_pwr_inc;
dash_pwr_done++;
return &action;
}
if(turn_ang_done<turn_ang_steps) {
action.unset_lock();
action.unset_cmd();
action.set_turn(turn_ang);
turn_ang+= ANGLE(turn_ang_inc);
turn_ang_done++;
return &action;
}
return NULL;
}
};
class OneOrTwoStepKick: public BaseBehavior {
static bool initialized;
#if 0
struct MyState {
Vector my_vel;
Vector my_pos;
ANGLE my_angle;
Vector ball_pos;
Vector ball_vel;
Vector op_pos;
ANGLE op_bodydir;
};
#endif
OneStepKick *onestepkick;
OneOrTwoStepKickItrActions itr_actions;
Cmd_Main result_cmd1,result_cmd2;
Value result_vel1,result_vel2;
bool result_status;
bool need_2_steps;
long set_in_cycle;
Vector target_pos;
ANGLE target_dir;
Value target_vel;
bool kick_to_pos;
bool calc_done;
MyState fake_state;
long fake_state_time;
void get_ws_state(MyState &state);
MyState get_cur_state();
bool calculate(const MyState &state,Value vel,const ANGLE &dir,const Vector &pos,bool to_pos,
Cmd_Main &res_cmd1,Value &res_vel1,Cmd_Main &res_cmd2,Value &res_vel2,
bool &need_2steps);
bool do_calc();
public:
/** This makes it possible to "fake" WS information.
This must be called _BEFORE_ any of the kick functions, and is valid for
the current cycle only.
*/
void set_state(const Vector &mypos,const Vector &myvel,const ANGLE &myang,
const Vector &ballpos,const Vector &ballvel,
const Vector &op_pos = Vector(1000,1000),
const ANGLE &op_bodydir = ANGLE(0),
const int op_bodydir_age = 1000);
void set_state( const AState & state );
/** Resets the current state to that found in WS.
This must be called _BEFORE_ any of the kick functions.
*/
void reset_state();
void kick_in_dir_with_initial_vel(Value vel,const ANGLE &dir);
void kick_in_dir_with_max_vel(const ANGLE &dir);
void kick_to_pos_with_initial_vel(Value vel,const Vector &point);
void kick_to_pos_with_final_vel(Value vel,const Vector &point);
void kick_to_pos_with_max_vel(const Vector &point);
/** false is returned if we do not reach our desired vel within two cycles.
Note that velocities are set to zero if the resulting pos is not ok,
meaning that even if a cmd would reach the desired vel, we will ignore
it if the resulting pos is not ok.
*/
bool get_vel(Value &vel_1step,Value &vel_2step);
bool get_cmd(Cmd &cmd_1step,Cmd &cmd_2step);
bool get_vel(Value &best_vel); // get best possible vel (1 or 2 step)
bool get_cmd(Cmd &best_cmd); // get best possible cmd (1 or 2 step)
// returns 0 if kick is not possible, 1 if kick in 1 step is possible, 2 if in 2 steps. probably modifies vel
int is_kick_possible(Value &speed,const ANGLE &dir);
bool need_two_steps();
bool can_keep_ball_in_kickrange();
static bool init(char const * conf_file, int argc, char const* const* argv) {
if(initialized) return true;
initialized = true;
if(OneStepKick::init(conf_file,argc,argv)) {
cout << "\nOneOrTwoStepKick behavior initialized.";
} else {
ERROR_OUT << "\nCould not initialize OneStepKick behavior - stop loading.";
exit(1);
}
return true;
}
OneOrTwoStepKick() {
set_in_cycle = -1;
onestepkick = new OneStepKick();
onestepkick->set_log(false); // we don't want OneStepKick-Info in our logs!
}
virtual ~OneOrTwoStepKick() {
delete onestepkick;
}
};
#endif
| [
"[email protected]"
] | [
[
[
1,
238
]
]
] |
40bc68efa1d237aacc7f1b2a5010046f0e4cf13c | 4b1289b0eb41c045a24b4626857097571c988e9b | /Least_Loose_Number_In_The_Array.cpp | 01dac7320be1eee1ec1af9b49c0962158327697f | [] | no_license | Arvy1998/Calculus-and-Play-with-New-Syntax | 136d942c1be8dc59d3b6d764881d7a9aea5a68cd | b442156a850dad2ed7c53ce86d3435fb35d78fe9 | refs/heads/master | 2021-07-11T02:05:09.180000 | 2019-03-12T22:00:42 | 2019-03-12T22:00:42 | 129,288,984 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 965 | cpp | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
long long n, seka[101], MIN_TEIG = 0, count;
vector <long long> izulus_teig_sk;
cin >> n;
for (auto x = 0; x < n; x++) {
cin >> seka[x];
}
for (auto i = 0; i < n; i++) {
if (i == 0) {
if (seka[i] > seka[i + 1]) {
izulus_teig_sk.push_back(seka[i]);
}
}
if (i > 0 && i < n - 1) {
if (seka[i] > seka[i - 1] && seka[i] > seka[i + 1]) {
izulus_teig_sk.push_back(seka[i]);
}
}
if (i == n - 1) {
if (seka[i] > seka[i - 1]) {
izulus_teig_sk.push_back(seka[i]);
}
}
}
if (izulus_teig_sk.size() == 0 || n <= 1) {
cout << "NO";
exit(0);
}
else {
sort(izulus_teig_sk.begin(), izulus_teig_sk.end());
for (size_t j = 0; j < izulus_teig_sk.size(); j++) {
if (izulus_teig_sk[j] > 0) {
MIN_TEIG = izulus_teig_sk[j];
cout << MIN_TEIG;
break;
}
}
}
if (MIN_TEIG == 0) {
cout << "NO";
}
return 0;
}
| [
"[email protected]"
] | [
[
[
1,
50
]
]
] |
0f14955c67c8ded4e0b25301b31b8648ae16b52f | 4985aad8ecfceca8027709cf488bc2c601443385 | /build/Android/Debug/app/src/main/include/Fuse.Resources.Resour-7da5075.h | bb740adfa48c8d9b5e34d9b3bf2a2c23882e8030 | [] | no_license | pacol85/Test1 | a9fd874711af67cb6b9559d9a4a0e10037944d89 | c7bb59a1b961bfb40fe320ee44ca67e068f0a827 | refs/heads/master | 2021-01-25T11:39:32.441000 | 2017-06-12T21:48:37 | 2017-06-12T21:48:37 | 93,937,614 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 883 | h | // This file was generated based on '../../AppData/Local/Fusetools/Packages/Fuse.Nodes/1.0.2/$.uno'.
// WARNING: Changes might be lost if you edit this file directly.
#pragma once
#include <Uno.h>
namespace g{namespace Fuse{namespace Resources{struct ResourceConverters;}}}
namespace g{namespace Uno{namespace Collections{struct Dictionary;}}}
namespace g{
namespace Fuse{
namespace Resources{
// internal static class ResourceConverters :3538
// {
uClassType* ResourceConverters_typeof();
void ResourceConverters__Get_fn(uType* __type, uObject** __retval);
struct ResourceConverters : uObject
{
static uSStrong< ::g::Uno::Collections::Dictionary*> _converters_;
static uSStrong< ::g::Uno::Collections::Dictionary*>& _converters() { return ResourceConverters_typeof()->Init(), _converters_; }
static uObject* Get(uType* __type);
};
// }
}}} // ::g::Fuse::Resources
| [
"[email protected]"
] | [
[
[
1,
27
]
]
] |
f45da0032ec95894d113360f36e2c7e74a3b4bd2 | be522f6110d4ed6f330da41a653460e4fb1ed3a7 | /runtime/nf/httpparser/Buffer.cc | e4717f524b583c4cfdc3f533c545bdec74c3946c | [] | no_license | yxd886/nfa | 2a796b10e6e2085470e54dd4f9a4a3721c0d27a9 | 209fd992ab931f955afea11562673fec943dd8a6 | refs/heads/master | 2020-06-17T22:09:37.259000 | 2017-03-24T03:07:38 | 2017-03-24T03:07:38 | 74,966,034 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 981 | cc |
#include "Buffer.h"
void CBuffer_Reset(struct CBuffer& Cbuf){
if(!Cbuf.buf){
Cbuf.buf = (char*) malloc(BUFFER_SIZE);
memset(Cbuf.buf,0x00,Cbuf._free);
}
if(Cbuf.len > BUFFER_SIZE * 2 && Cbuf.buf){
//如果目前buf的大小是默认值的2倍,则对其裁剪内存,保持buf的大小为默认值,减小内存耗费
char* newbuf = (char*) realloc(Cbuf.buf,BUFFER_SIZE);
if(newbuf != Cbuf.buf)
Cbuf.buf = newbuf;
}
Cbuf.len = 0;
Cbuf._free = BUFFER_SIZE;
}
bool Append(struct CBuffer& Cbuf,char* p, size_t size){
if(!p || !size)
return true;
if(size < Cbuf._free){
memcpy(Cbuf.buf + Cbuf.len, p , size);
Cbuf.len += size;
Cbuf._free -= size;
}else{
return false;
}
return true;
}
char* GetBuf(struct CBuffer Cbuf,uint32_t& size){
size = Cbuf.len;
return Cbuf.buf;
}
uint32_t GetBufLen(struct CBuffer Cbuf){
return Cbuf.len;
}
void Buf_init(struct CBuffer& Cbuf){
Cbuf.len=0;
Cbuf._free=0;
Cbuf.buf=0;
CBuffer_Reset(Cbuf);
}
| [
"[email protected]"
] | [
[
[
1,
52
]
]
] |
b7c78a511904d321aa74ab25ce20a44c3a3f0a0e | d51d72f1b6e834d89c8551bb07487bed84cdaa31 | /src/output/osg/customCode/osg/AnimationPath_pmoc.cpp | dc66ae9496a4b899d13c9038f85bec5d8cc50019 | [] | no_license | wangfeilong321/osg4noob | 221204aa15efa18f1f049548ad076ef27371ecad | 99a15c3fd2523c4bd537fa3afb0b47e15c8f335a | refs/heads/master | 2021-01-12T20:00:43.854000 | 2015-11-06T15:37:01 | 2015-11-06T15:37:01 | 48,840,543 | 0 | 1 | null | 2015-12-31T07:56:31 | 2015-12-31T07:56:31 | null | UTF-8 | C++ | false | false | 1,778 | cpp | #include <osg/AnimationPath>
//includes
#include <MetaQQuickLibraryRegistry.h>
#include <customCode/osg/AnimationPath_pmoc.hpp>
using namespace pmoc;
osg::QMLAnimationPath::QMLAnimationPath(pmoc::Instance *i,QObject* parent):QReflect_AnimationPath(i,parent){
//custom initializations
}
QQuickItem* osg::QMLAnimationPath::connect2View(QQuickItem*i){
this->_view=QReflect_AnimationPath::connect2View(i);
///connect this's signals/slot to its qml component////////////////////////////////////////////////////////////////
///CustomiZE here
return this->_view;
}
void osg::QMLAnimationPath::updateModel(){
QReflect_AnimationPath::updateModel();
///update this according to state of _model when it has been changed via pmoc/////////////////////////////////////////////
///CustomiZE here
}
#ifndef AUTOMOCCPP
#define AUTOMOCCPP 1
#include "moc_AnimationPath_pmoc.cpp"
#endif
#include <MetaQQuickLibraryRegistry.h>
#include <customCode/osg/AnimationPath_pmoc.hpp>
using namespace pmoc;
osg::QMLAnimationPathCallback::QMLAnimationPathCallback(pmoc::Instance *i,QObject* parent):QReflect_AnimationPathCallback(i,parent){
//custom initializations
}
QQuickItem* osg::QMLAnimationPathCallback::connect2View(QQuickItem*i){
this->_view=QReflect_AnimationPathCallback::connect2View(i);
///connect this's signals/slot to its qml component////////////////////////////////////////////////////////////////
///CustomiZE here
return this->_view;
}
void osg::QMLAnimationPathCallback::updateModel(){
QReflect_AnimationPathCallback::updateModel();
///update this according to state of _model when it has been changed via pmoc/////////////////////////////////////////////
///CustomiZE here
}
#ifndef AUTOMOCCPP
#define AUTOMOCCPP 1
#include "moc_AnimationPath_pmoc.cpp"
#endif
| [
"[email protected]"
] | [
[
[
1,
56
]
]
] |
58b00a4202d32fd15e1533444149d9af6d0445dd | e1cda708e5087296dab0fc224a44dc8d7368c63c | /PWGPP/TPC/AliPerformanceRes.cxx | b459e100d86013154e2bec140f3af8694d0034fa | [] | no_license | pbatzing/AliPhysics | 36039c28c9670d08bb8de2bcf369840a3a191bbb | 8f0962d72943081031580a544a17d6e52e74c481 | refs/heads/master | 2021-01-22T22:44:31.003000 | 2017-04-04T11:14:26 | 2017-04-04T11:14:26 | 85,572,640 | 0 | 0 | null | 2017-03-20T12:10:32 | 2017-03-20T12:10:32 | null | UTF-8 | C++ | false | false | 45,205 | cxx | //------------------------------------------------------------------------------
// Implementation of AliPerformanceRes class. It keeps information from
// comparison of reconstructed and MC particle tracks. In addtion,
// it keeps selection cuts used during comparison. The comparison
// information is stored in the ROOT histograms. Analysis of these
// histograms can be done by using Analyse() class function. The result of
// the analysis (histograms/graphs) are stored in the folder which is
// a data member of AliPerformanceRes.
//
// Author: J.Otwinowski 04/02/2008
//------------------------------------------------------------------------------
/*
// after running comparison task, read the file, and get component
gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/Macros/LoadMyLibs.C");
LoadMyLibs();
TFile f("Output.root");
AliPerformanceRes * compObj = (AliPerformanceRes*)coutput->FindObject("AliPerformanceRes");
// analyse comparison data
compObj->Analyse();
// the output histograms/graphs will be stored in the folder "folderRes"
compObj->GetAnalysisFolder()->ls("*");
// user can save whole comparison object (or only folder with anlysed histograms)
// in the seperate output file (e.g.)
TFile fout("Analysed_Res.root","recreate");
compObj->Write(); // compObj->GetAnalysisFolder()->Write();
fout.Close();
*/
#include "TCanvas.h"
#include "TH1.h"
#include "TH2.h"
#include "TAxis.h"
#include "TF1.h"
#include "AliPerformanceRes.h"
#include "AliESDEvent.h"
#include "AliESDVertex.h"
#include "AliESDtrack.h"
#include "AliESDfriendTrack.h"
#include "AliESDfriend.h"
#include "AliLog.h"
#include "AliMCEvent.h"
#include "AliMCParticle.h"
#include "AliHeader.h"
#include "AliGenEventHeader.h"
#include "AliStack.h"
#include "AliMCInfoCuts.h"
#include "AliRecInfoCuts.h"
#include "AliTracker.h"
#include "AliTreeDraw.h"
using namespace std;
ClassImp(AliPerformanceRes)
Double_t AliPerformanceRes::fgkMergeEntriesCut=5000000.; //5*10**6 tracks (small default to keep default memory foorprint low)
//_____________________________________________________________________________
AliPerformanceRes::AliPerformanceRes(const Char_t* name, const Char_t* title, Int_t analysisMode, Bool_t hptGenerator):
AliPerformanceObject(name,title),
fResolHisto(0),
fPullHisto(0),
// Cuts
fCutsRC(0),
fCutsMC(0),
// histogram folder
fAnalysisFolder(0)
{
// named constructor
//
SetAnalysisMode(analysisMode);
SetHptGenerator(hptGenerator);
Init();
}
//_____________________________________________________________________________
AliPerformanceRes::~AliPerformanceRes()
{
// destructor
if(fResolHisto) delete fResolHisto; fResolHisto=0;
if(fPullHisto) delete fPullHisto; fPullHisto=0;
if(fAnalysisFolder) delete fAnalysisFolder; fAnalysisFolder=0;
}
//_____________________________________________________________________________
void AliPerformanceRes::Init(){
//
// histogram bining
//
// set pt bins
Int_t nPtBins = 50;
Double_t ptMin = 1.e-1, ptMax = 20.;
Double_t *binsPt = 0;
if (IsHptGenerator()) {
ptMax = 100.;
}
binsPt = CreateLogAxis(nPtBins,ptMin,ptMax);
Double_t yMin = -0.02, yMax = 0.02;
Double_t zMin = -12.0, zMax = 12.0;
if(GetAnalysisMode() == 3) { // TrackRef coordinate system
yMin = -100.; yMax = 100.;
zMin = -100.; zMax = 100.;
}
// res_y:res_z:res_phi,res_lambda:res_pt:y:z:eta:phi:pt
Int_t binsResolHisto[10]={100,100,100,100,100,25,50,144,30,nPtBins};
Double_t minResolHisto[10]={-1.,-1.,-0.03,-0.03,-0.2, yMin, zMin, 0., -1.5, ptMin};
Double_t maxResolHisto[10]={ 1., 1., 0.03, 0.03, 0.2, yMax, zMax, 2.*TMath::Pi(), 1.5, ptMax};
fResolHisto = new THnSparseF("fResolHisto","res_y:res_z:res_phi:res_lambda:res_pt:y:z:phi:eta:pt",10,binsResolHisto,minResolHisto,maxResolHisto);
//fResolHisto->SetBinEdges(9,binsPt);
fResolHisto->GetAxis(9)->Set(nPtBins,binsPt);
fResolHisto->GetAxis(0)->SetTitle("y-y_{mc} (cm)");
fResolHisto->GetAxis(1)->SetTitle("z-z_{mc} (cm)");
fResolHisto->GetAxis(2)->SetTitle("#phi-#phi_{mc} (rad)");
fResolHisto->GetAxis(3)->SetTitle("#lambda-#lambda_{mc} (rad)");
fResolHisto->GetAxis(4)->SetTitle("(p_{T}/p_{Tmc}-1)");
fResolHisto->GetAxis(5)->SetTitle("y_{mc} (cm)");
fResolHisto->GetAxis(6)->SetTitle("z_{mc} (cm)");
fResolHisto->GetAxis(7)->SetTitle("#phi_{mc} (rad)");
fResolHisto->GetAxis(8)->SetTitle("#eta_{mc}");
fResolHisto->GetAxis(9)->SetTitle("p_{Tmc} (GeV/c)");
fResolHisto->Sumw2();
////pull_y:pull_z:pull_phi:pull_lambda:pull_1pt:y:z:eta:phi:pt
//Int_t binsPullHisto[10]={100,100,100,100,100,50,50,30,144,nPtBins};
//Double_t minPullHisto[10]={-5.,-5.,-5.,-5.,-5.,yMin, zMin,-1.5, 0., ptMin};
//Double_t maxPullHisto[10]={ 5., 5., 5., 5., 5., yMax, zMax, 1.5, 2.*TMath::Pi(),ptMax};
//fPullHisto = new THnSparseF("fPullHisto","pull_y:pull_z:pull_phi:pull_lambda:pull_1pt:y:z:eta:phi:pt",10,binsPullHisto,minPullHisto,maxPullHisto);
//pull_y:pull_z:pull_snp:pull_tgl:pull_1pt:y:z:snp:tgl:1pt
//Int_t binsPullHisto[10]={100,100,100,100,100,50,50,50,50,nPtBins};
//Double_t minPullHisto[10]={-5.,-5.,-5.,-5.,-5.,yMin, zMin,-1., -2.0, ptMin};
//Double_t maxPullHisto[10]={ 5., 5., 5., 5., 5., yMax, zMax, 1., 2.0, ptMax};
Int_t binsPullHisto[10]={100,100,100,100,100,50,50,50,50,20};
Double_t minPullHisto[10]={-5.,-5.,-5.,-5.,-5.,yMin, zMin,-1., -2.0, 0.};
Double_t maxPullHisto[10]={ 5., 5., 5., 5., 5., yMax, zMax, 1., 2.0, 10.};
fPullHisto = new THnSparseF("fPullHisto","pull_y:pull_z:pull_y:pull_z:pull_snp:pull_tgl:pull_1pt:y:z:snp:tgl:1pt",10,binsPullHisto,minPullHisto,maxPullHisto);
/*
if(!IsHptGenerator()) fPullHisto->SetBinEdges(9,bins1Pt);
fPullHisto->GetAxis(0)->SetTitle("(y-y_{mc})/#sigma");
fPullHisto->GetAxis(1)->SetTitle("(z-z_{mc})/#sigma");
fPullHisto->GetAxis(2)->SetTitle("(#phi-#phi_{mc})/#sigma");
fPullHisto->GetAxis(3)->SetTitle("(#lambda-#lambda_{mc})/#sigma");
fPullHisto->GetAxis(4)->SetTitle("(p_{Tmc}/p_{T}-1)/#sigma");
fPullHisto->GetAxis(5)->SetTitle("y_{mc} (cm)");
fPullHisto->GetAxis(6)->SetTitle("z_{mc} (cm)");
fPullHisto->GetAxis(7)->SetTitle("#eta_{mc}");
fPullHisto->GetAxis(8)->SetTitle("#phi_{mc} (rad)");
fPullHisto->GetAxis(9)->SetTitle("p_{Tmc} (GeV/c)");
fPullHisto->Sumw2();
*/
fPullHisto->GetAxis(9)->Set(nPtBins,binsPt);
fPullHisto->GetAxis(0)->SetTitle("(y-y_{mc})/#sigma");
fPullHisto->GetAxis(1)->SetTitle("(z-z_{mc})/#sigma");
fPullHisto->GetAxis(2)->SetTitle("(sin#phi-sin#phi_{mc})/#sigma");
fPullHisto->GetAxis(3)->SetTitle("(tan#lambda-tan#lambda_{mc})/#sigma");
fPullHisto->GetAxis(4)->SetTitle("(p_{Tmc}/p_{T}-1)/#sigma");
fPullHisto->GetAxis(5)->SetTitle("y_{mc} (cm)");
fPullHisto->GetAxis(6)->SetTitle("z_{mc} (cm)");
fPullHisto->GetAxis(7)->SetTitle("sin#phi_{mc}");
fPullHisto->GetAxis(8)->SetTitle("tan#lambda_{mc}");
fPullHisto->GetAxis(9)->SetTitle("1/p_{Tmc} (GeV/c)^{-1}");
fPullHisto->Sumw2();
// Init cuts
if(!fCutsMC)
AliDebug(AliLog::kError, "ERROR: Cannot find AliMCInfoCuts object");
if(!fCutsRC)
AliDebug(AliLog::kError, "ERROR: Cannot find AliRecInfoCuts object");
// init folder
fAnalysisFolder = CreateFolder("folderRes","Analysis Resolution Folder");
}
//_____________________________________________________________________________
void AliPerformanceRes::ProcessTPC(AliStack* const stack, AliESDtrack *const esdTrack, AliESDEvent* const esdEvent)
{
if(!esdEvent) return;
if(!esdTrack) return;
if( IsUseTrackVertex() )
{
// Relate TPC inner params to prim. vertex
const AliESDVertex *vtxESD = esdEvent->GetPrimaryVertexTracks();
Double_t x[3]; esdTrack->GetXYZ(x);
Double_t b[3]; AliTracker::GetBxByBz(x,b);
Bool_t isOK = esdTrack->RelateToVertexTPCBxByBz(vtxESD, b, kVeryBig);
if(!isOK) return;
/*
// JMT -- recaluclate DCA for HLT if not present
if ( dca[0] == 0. && dca[1] == 0. ) {
track->GetDZ( vtxESD->GetX(), vtxESD->GetY(), vtxESD->GetZ(), esdEvent->GetMagneticField(), dca );
}
*/
}
// Fill TPC only resolution comparison information
const AliExternalTrackParam* tmpTrack = esdTrack->GetTPCInnerParam();
if(!tmpTrack) return;
AliExternalTrackParam track = *tmpTrack;
Float_t dca[2], cov[3]; // dca_xy, dca_z, sigma_xy, sigma_xy_z, sigma_z
esdTrack->GetImpactParametersTPC(dca,cov);
//
// Fill rec vs MC information
//
if(!stack) return;
Int_t label = esdTrack->GetTPCLabel(); //Use TPC-only label for TPC-only resolution analysis
if (label <= 0) return;
TParticle* particle = stack->Particle(label);
if(!particle) return;
if(!particle->GetPDG()) return;
if(particle->GetPDG()->Charge()==0) return;
//printf("charge %d \n",particle->GetPDG()->Charge());
// Only 5 charged particle species (e,mu,pi,K,p)
if (fCutsMC->IsPdgParticle(TMath::Abs(particle->GetPdgCode())) == kFALSE) return;
// exclude electrons
if (fCutsMC->GetEM()==TMath::Abs(particle->GetPdgCode())) return;
Float_t deltaPtTPC, deltaYTPC, deltaZTPC, deltaPhiTPC, deltaLambdaTPC;
Float_t pull1PtTPC, pullYTPC, pullZTPC, pullPhiTPC, pullLambdaTPC;
Float_t mceta = particle->Eta();
Float_t mcphi = particle->Phi();
if(mcphi<0) mcphi += 2.*TMath::Pi();
Float_t mcpt = particle->Pt();
Float_t mcsnp = TMath::Sin(TMath::ATan2(particle->Py(),particle->Px()));
Float_t mctgl = TMath::Tan(TMath::ATan2(particle->Pz(),particle->Pt()));
// nb. TPC clusters cut
if (esdTrack->GetTPCNcls()<fCutsRC->GetMinNClustersTPC()) return;
// select primaries
if(TMath::Abs(dca[0])<fCutsRC->GetMaxDCAToVertexXY() && TMath::Abs(dca[1])<fCutsRC->GetMaxDCAToVertexZ())
{
if(mcpt == 0) return;
double Bz = esdEvent->GetMagneticField();
Double_t mclocal[4]; //Rotated x,y,px,py mc-coordinates - the MC data should be rotated since the track is propagated best along x
Double_t c = TMath::Cos(track.GetAlpha());
Double_t s = TMath::Sin(track.GetAlpha());
Double_t x = particle->Vx();
Double_t y = particle->Vy();
mclocal[0] = x*c + y*s;
mclocal[1] =-x*s + y*c;
Double_t px = particle->Px();
Double_t py = particle->Py();
mclocal[2] = px*c + py*s;
mclocal[3] =-px*s + py*c;
Float_t mcsnplocal = TMath::Sin(TMath::ATan2(mclocal[3],mclocal[2]));
track.AliExternalTrackParam::PropagateTo(mclocal[0],Bz);
deltaYTPC= track.GetY()-mclocal[1];
deltaZTPC = track.GetZ()-particle->Vz();
deltaLambdaTPC = TMath::ATan2(track.Pz(),track.Pt())-TMath::ATan2(particle->Pz(),particle->Pt());
//See comments in ProcessInnerTPC for remarks on local and global momentum coordinates for deltaPhi / pullSnp calculation
deltaPhiTPC = TMath::ATan2(track.Py(),track.Px())-TMath::ATan2(particle->Py(),particle->Px());
//delta1PtTPC = (track.OneOverPt()-1./mcpt)*mcpt;
deltaPtTPC = (track.Pt()-mcpt) / mcpt;
pullYTPC= deltaYTPC / TMath::Sqrt(track.GetSigmaY2());
pullZTPC = deltaZTPC / TMath::Sqrt(track.GetSigmaZ2());
//Double_t sigma_lambda = 1./(1.+track.GetTgl()*track.GetTgl()) * TMath::Sqrt(track.GetSigmaTgl2());
//Double_t sigma_phi = 1./TMath::Sqrt(1-track.GetSnp()*track.GetSnp()) * TMath::Sqrt(track.GetSigmaSnp2());
pullPhiTPC = (track.GetSnp() - mcsnplocal) / TMath::Sqrt(track.GetSigmaSnp2());
pullLambdaTPC = (track.GetTgl() - mctgl) / TMath::Sqrt(track.GetSigmaTgl2());
//pullLambdaTPC = deltaLambdaTPC / TMath::Sqrt(track.GetSigmaTgl2());
//pullPhiTPC = deltaPhiTPC / TMath::Sqrt(track.GetSigmaSnp2());
if (mcpt) pull1PtTPC = (track.OneOverPt()-1./mcpt) / TMath::Sqrt(track.GetSigma1Pt2());
else pull1PtTPC = 0.;
Double_t vResolHisto[10] = {deltaYTPC,deltaZTPC,deltaPhiTPC,deltaLambdaTPC,deltaPtTPC,particle->Vy(),particle->Vz(),mcphi,mceta,mcpt};
fResolHisto->Fill(vResolHisto);
Double_t vPullHisto[10] = {pullYTPC,pullZTPC,pullPhiTPC,pullLambdaTPC,pull1PtTPC,particle->Vy(),particle->Vz(),mcsnp,mctgl,1./mcpt};
fPullHisto->Fill(vPullHisto);
}
}
//_____________________________________________________________________________
void AliPerformanceRes::ProcessTPCITS(AliStack* const stack, AliESDtrack *const esdTrack, AliESDEvent* const esdEvent)
{
// Fill resolution comparison information (TPC+ITS)
if(!esdEvent) return;
if(!esdTrack) return;
if( IsUseTrackVertex() )
{
// Relate TPC inner params to prim. vertex
const AliESDVertex *vtxESD = esdEvent->GetPrimaryVertexTracks();
Double_t x[3]; esdTrack->GetXYZ(x);
Double_t b[3]; AliTracker::GetBxByBz(x,b);
Bool_t isOK = esdTrack->RelateToVertexBxByBz(vtxESD, b, kVeryBig);
if(!isOK) return;
/*
// JMT -- recaluclate DCA for HLT if not present
if ( dca[0] == 0. && dca[1] == 0. ) {
track->GetDZ( vtxESD->GetX(), vtxESD->GetY(), vtxESD->GetZ(), esdEvent->GetMagneticField(), dca );
}
*/
}
Float_t dca[2], cov[3]; // dca_xy, dca_z, sigma_xy, sigma_xy_z, sigma_z
esdTrack->GetImpactParameters(dca,cov);
//
// Fill rec vs MC information
//
if(!stack) return;
Int_t label = TMath::Abs(esdTrack->GetLabel()); //Use global label for combined resolution analysis
TParticle* particle = stack->Particle(label);
if(!particle) return;
if(!particle->GetPDG()) return;
if(particle->GetPDG()->Charge()==0) return;
//printf("charge %d \n",particle->GetPDG()->Charge());
// Only 5 charged particle species (e,mu,pi,K,p)
if (fCutsMC->IsPdgParticle(TMath::Abs(particle->GetPdgCode())) == kFALSE) return;
// exclude electrons
if (fCutsMC->GetEM()==TMath::Abs(particle->GetPdgCode())) return;
Float_t mceta = particle->Eta();
Float_t mcphi = particle->Phi();
if(mcphi<0) mcphi += 2.*TMath::Pi();
Float_t mcpt = particle->Pt();
Float_t mcsnp = TMath::Sin(TMath::ATan2(particle->Py(),particle->Px()));
Float_t mctgl = TMath::Tan(TMath::ATan2(particle->Pz(),particle->Pt()));
if ((esdTrack->GetStatus()&AliESDtrack::kTPCrefit)==0) return; // TPC refit
if (esdTrack->GetTPCNcls()<fCutsRC->GetMinNClustersTPC()) return; // min. nb. TPC clusters
if(esdTrack->GetITSclusters(0)<fCutsRC->GetMinNClustersITS()) return; // min. nb. ITS clusters
Float_t deltaPtTPC, deltaYTPC, deltaZTPC, deltaPhiTPC, deltaLambdaTPC;
Float_t pull1PtTPC, pullYTPC, pullZTPC, pullPhiTPC, pullLambdaTPC;
// select primaries
if(TMath::Abs(dca[0])<fCutsRC->GetMaxDCAToVertexXY() && TMath::Abs(dca[1])<fCutsRC->GetMaxDCAToVertexZ())
{
if(mcpt == 0) return;
deltaYTPC= esdTrack->GetY()-particle->Vy();
deltaZTPC = esdTrack->GetZ()-particle->Vz();
deltaLambdaTPC = TMath::ATan2(esdTrack->Pz(),esdTrack->Pt())-TMath::ATan2(particle->Pz(),particle->Pt());
deltaPhiTPC = TMath::ATan2(esdTrack->Py(),esdTrack->Px())-TMath::ATan2(particle->Py(),particle->Px());
//delta1PtTPC = (esdTrack->OneOverPt()-1./mcpt)*mcpt;
deltaPtTPC = (esdTrack->Pt()-mcpt) / mcpt;
pullYTPC= (esdTrack->GetY()-particle->Vy()) / TMath::Sqrt(esdTrack->GetSigmaY2());
pullZTPC = (esdTrack->GetZ()-particle->Vz()) / TMath::Sqrt(esdTrack->GetSigmaZ2());
//Double_t sigma_lambda = 1./(1.+esdTrack->GetTgl()*esdTrack->GetTgl()) * TMath::Sqrt(esdTrack->GetSigmaTgl2());
//Double_t sigma_phi = 1./TMath::Sqrt(1-esdTrack->GetSnp()*esdTrack->GetSnp()) * TMath::Sqrt(esdTrack->GetSigmaSnp2());
pullPhiTPC = (esdTrack->GetSnp() - mcsnp) / TMath::Sqrt(esdTrack->GetSigmaSnp2());
pullLambdaTPC = (esdTrack->GetTgl() - mctgl) / TMath::Sqrt(esdTrack->GetSigmaTgl2());
//pullLambdaTPC = deltaLambdaTPC / TMath::Sqrt(esdTrack->GetSigmaTgl2());
//pullPhiTPC = deltaPhiTPC / TMath::Sqrt(esdTrack->GetSigmaSnp2());
if (mcpt) pull1PtTPC = (esdTrack->OneOverPt()-1./mcpt) / TMath::Sqrt(esdTrack->GetSigma1Pt2());
else pull1PtTPC = 0.;
Double_t vResolHisto[10] = {deltaYTPC,deltaZTPC,deltaPhiTPC,deltaLambdaTPC,deltaPtTPC,particle->Vy(),particle->Vz(),mcphi,mceta,mcpt};
fResolHisto->Fill(vResolHisto);
Double_t vPullHisto[10] = {pullYTPC,pullZTPC,pullPhiTPC,pullLambdaTPC,pull1PtTPC,particle->Vy(),particle->Vz(),mcsnp,mctgl,1./mcpt};
fPullHisto->Fill(vPullHisto);
/*
deltaYTPC= esdTrack->GetY()-particle->Vy();
deltaZTPC = esdTrack->GetZ()-particle->Vz();
deltaLambdaTPC = TMath::ATan2(esdTrack->Pz(),esdTrack->Pt())-TMath::ATan2(particle->Pz(),particle->Pt());
deltaPhiTPC = TMath::ATan2(esdTrack->Py(),esdTrack->Px())-TMath::ATan2(particle->Py(),particle->Px());
delta1PtTPC = (esdTrack->OneOverPt()-1./mcpt)*mcpt;
pullYTPC= (esdTrack->GetY()-particle->Vy()) / TMath::Sqrt(esdTrack->GetSigmaY2());
pullZTPC = (esdTrack->GetZ()-particle->Vz()) / TMath::Sqrt(esdTrack->GetSigmaZ2());
Double_t sigma_lambda = 1./(1.+esdTrack->GetTgl()*esdTrack->GetTgl()) * TMath::Sqrt(esdTrack->GetSigmaTgl2());
Double_t sigma_phi = 1./TMath::Sqrt(1-esdTrack->GetSnp()*esdTrack->GetSnp()) * TMath::Sqrt(esdTrack->GetSigmaSnp2());
pullLambdaTPC = deltaLambdaTPC / sigma_lambda;
pullPhiTPC = deltaPhiTPC / sigma_phi;
//pullLambdaTPC = deltaLambdaTPC / TMath::Sqrt(esdTrack->GetSigmaTgl2());
//pullPhiTPC = deltaPhiTPC / TMath::Sqrt(esdTrack->GetSigmaSnp2());
if (mcpt) pull1PtTPC = (esdTrack->OneOverPt()-1./mcpt) / TMath::Sqrt(esdTrack->GetSigma1Pt2());
else pull1PtTPC = 0.;
Double_t vResolHisto[10] = {deltaYTPC,deltaZTPC,deltaPhiTPC,deltaLambdaTPC,delta1PtTPC,particle->Vy(),particle->Vz(),mceta,mcphi,mcpt};
fResolHisto->Fill(vResolHisto);
Double_t vPullHisto[10] = {pullYTPC,pullZTPC,pullPhiTPC,pullLambdaTPC,pull1PtTPC,particle->Vy(),particle->Vz(),mceta,mcphi,mcpt};
fPullHisto->Fill(vPullHisto);
*/
}
}
//_____________________________________________________________________________
void AliPerformanceRes::ProcessConstrained(AliStack* const stack, AliESDtrack *const esdTrack, AliESDEvent* const esdEvent)
{
// Fill resolution comparison information (constarained parameters)
//
if(!esdEvent) return;
if(!esdTrack) return;
if( IsUseTrackVertex() )
{
// Relate TPC inner params to prim. vertex
const AliESDVertex *vtxESD = esdEvent->GetPrimaryVertexTracks();
Double_t x[3]; esdTrack->GetXYZ(x);
Double_t b[3]; AliTracker::GetBxByBz(x,b);
Bool_t isOK = esdTrack->RelateToVertexBxByBz(vtxESD, b, kVeryBig);
if(!isOK) return;
/*
// JMT -- recaluclate DCA for HLT if not present
if ( dca[0] == 0. && dca[1] == 0. ) {
track->GetDZ( vtxESD->GetX(), vtxESD->GetY(), vtxESD->GetZ(), esdEvent->GetMagneticField(), dca );
}
*/
}
const AliExternalTrackParam * track = esdTrack->GetConstrainedParam();
if(!track) return;
Float_t dca[2], cov[3]; // dca_xy, dca_z, sigma_xy, sigma_xy_z, sigma_z
esdTrack->GetImpactParameters(dca,cov);
//
// Fill rec vs MC information
//
if(!stack) return;
Int_t label = TMath::Abs(esdTrack->GetLabel());
TParticle* particle = stack->Particle(label);
if(!particle) return;
if(!particle->GetPDG()) return;
if(particle->GetPDG()->Charge()==0) return;
//printf("charge %d \n",particle->GetPDG()->Charge());
// Only 5 charged particle species (e,mu,pi,K,p)
if (fCutsMC->IsPdgParticle(TMath::Abs(particle->GetPdgCode())) == kFALSE) return;
// exclude electrons
if (fCutsMC->GetEM()==TMath::Abs(particle->GetPdgCode())) return;
Float_t mceta = particle->Eta();
Float_t mcphi = particle->Phi();
if(mcphi<0) mcphi += 2.*TMath::Pi();
Float_t mcpt = particle->Pt();
Float_t mcsnp = TMath::Sin(TMath::ATan2(particle->Py(),particle->Px()));
Float_t mctgl = TMath::Tan(TMath::ATan2(particle->Pz(),particle->Pt()));
if ((esdTrack->GetStatus()&AliESDtrack::kTPCrefit)==0) return; // TPC refit
if (esdTrack->GetTPCNcls()<fCutsRC->GetMinNClustersTPC()) return; // min. nb. TPC clusters
Float_t deltaPtTPC, deltaYTPC, deltaZTPC, deltaPhiTPC, deltaLambdaTPC;
Float_t pull1PtTPC, pullYTPC, pullZTPC, pullPhiTPC, pullLambdaTPC;
// select primaries
if(TMath::Abs(dca[0])<fCutsRC->GetMaxDCAToVertexXY() && TMath::Abs(dca[1])<fCutsRC->GetMaxDCAToVertexZ())
{
if(mcpt == 0) return;
deltaYTPC= track->GetY()-particle->Vy();
deltaZTPC = track->GetZ()-particle->Vz();
deltaLambdaTPC = TMath::ATan2(track->Pz(),track->Pt())-TMath::ATan2(particle->Pz(),particle->Pt());
deltaPhiTPC = TMath::ATan2(track->Py(),track->Px())-TMath::ATan2(particle->Py(),particle->Px());
//delta1PtTPC = (track->OneOverPt()-1./mcpt)*mcpt;
deltaPtTPC = (track->Pt()-mcpt) / mcpt;
pullYTPC= (track->GetY()-particle->Vy()) / TMath::Sqrt(track->GetSigmaY2());
pullZTPC = (track->GetZ()-particle->Vz()) / TMath::Sqrt(track->GetSigmaZ2());
//Double_t sigma_lambda = 1./(1.+track->GetTgl()*track->GetTgl()) * TMath::Sqrt(track->GetSigmaTgl2());
//Double_t sigma_phi = 1./TMath::Sqrt(1-track->GetSnp()*track->GetSnp()) * TMath::Sqrt(track->GetSigmaSnp2());
pullPhiTPC = (track->GetSnp() - mcsnp) / TMath::Sqrt(track->GetSigmaSnp2());
pullLambdaTPC = (track->GetTgl() - mctgl) / TMath::Sqrt(track->GetSigmaTgl2());
//pullLambdaTPC = deltaLambdaTPC / TMath::Sqrt(track->GetSigmaTgl2());
//pullPhiTPC = deltaPhiTPC / TMath::Sqrt(track->GetSigmaSnp2());
if (mcpt) pull1PtTPC = (track->OneOverPt()-1./mcpt) / TMath::Sqrt(track->GetSigma1Pt2());
else pull1PtTPC = 0.;
Double_t vResolHisto[10] = {deltaYTPC,deltaZTPC,deltaPhiTPC,deltaLambdaTPC,deltaPtTPC,particle->Vy(),particle->Vz(),mcphi,mceta,mcpt};
fResolHisto->Fill(vResolHisto);
Double_t vPullHisto[10] = {pullYTPC,pullZTPC,pullPhiTPC,pullLambdaTPC,pull1PtTPC,particle->Vy(),particle->Vz(),mcsnp,mctgl,1./mcpt};
fPullHisto->Fill(vPullHisto);
/*
deltaYTPC= track->GetY()-particle->Vy();
deltaZTPC = track->GetZ()-particle->Vz();
deltaLambdaTPC = TMath::ATan2(track->Pz(),track->Pt())-TMath::ATan2(particle->Pz(),particle->Pt());
deltaPhiTPC = TMath::ATan2(track->Py(),track->Px())-TMath::ATan2(particle->Py(),particle->Px());
delta1PtTPC = (track->OneOverPt()-1./mcpt)*mcpt;
pullYTPC= (track->GetY()-particle->Vy()) / TMath::Sqrt(track->GetSigmaY2());
pullZTPC = (track->GetZ()-particle->Vz()) / TMath::Sqrt(track->GetSigmaZ2());
Double_t sigma_lambda = 1./(1.+track->GetTgl()*track->GetTgl()) * TMath::Sqrt(track->GetSigmaTgl2());
Double_t sigma_phi = 1./TMath::Sqrt(1-track->GetSnp()*track->GetSnp()) * TMath::Sqrt(track->GetSigmaSnp2());
pullLambdaTPC = deltaLambdaTPC / sigma_lambda;
pullPhiTPC = deltaPhiTPC / sigma_phi;
//pullLambdaTPC = deltaLambdaTPC / TMath::Sqrt(track->GetSigmaTgl2());
//pullPhiTPC = deltaPhiTPC / TMath::Sqrt(track->GetSigmaSnp2());
if (mcpt) pull1PtTPC = (track->OneOverPt()-1./mcpt) / TMath::Sqrt(track->GetSigma1Pt2());
else pull1PtTPC = 0.;
Double_t vResolHisto[10] = {deltaYTPC,deltaZTPC,deltaPhiTPC,deltaLambdaTPC,delta1PtTPC,particle->Vy(),particle->Vz(),mceta,mcphi,mcpt};
fResolHisto->Fill(vResolHisto);
Double_t vPullHisto[10] = {pullYTPC,pullZTPC,pullPhiTPC,pullLambdaTPC,pull1PtTPC,particle->Vy(),particle->Vz(),mceta,mcphi,mcpt};
fPullHisto->Fill(vPullHisto);
*/
}
}
//_____________________________________________________________________________
void AliPerformanceRes::ProcessInnerTPC(AliMCEvent *const mcEvent, AliESDtrack *const esdTrack, AliESDEvent* const esdEvent)
{
//
// Fill resolution comparison information (inner params at TPC reference point)
//
if(!esdEvent) return;
if(!esdTrack) return;
if( IsUseTrackVertex() )
{
// Relate TPC inner params to prim. vertex
const AliESDVertex *vtxESD = esdEvent->GetPrimaryVertexTracks();
Double_t x[3]; esdTrack->GetXYZ(x);
Double_t b[3]; AliTracker::GetBxByBz(x,b);
Bool_t isOK = esdTrack->RelateToVertexTPCBxByBz(vtxESD, b, kVeryBig);
if(!isOK) return;
/*
// JMT -- recaluclate DCA for HLT if not present
if ( dca[0] == 0. && dca[1] == 0. ) {
track->GetDZ( vtxESD->GetX(), vtxESD->GetY(), vtxESD->GetZ(), esdEvent->GetMagneticField(), dca );
}
*/
}
const AliExternalTrackParam * innerParam = esdTrack->GetInnerParam();
if(!innerParam) return;
// create new AliExternalTrackParam
AliExternalTrackParam *track = new AliExternalTrackParam(*innerParam);
if(!track) return;
Float_t dca[2], cov[3]; // dca_xy, dca_z, sigma_xy, sigma_xy_z, sigma_z
esdTrack->GetImpactParametersTPC(dca,cov);
//
// Fill rec vs MC information
//
if(!mcEvent) return;
Int_t label = esdTrack->GetTPCLabel(); //Use TPC-only label for TPC-only resolution analysis
if (label <= 0) return;
AliMCParticle *mcParticle = (AliMCParticle*) mcEvent->GetTrack(label);
if(!mcParticle) return;
// get the first TPC track reference
AliTrackReference *ref0 = GetFirstTPCTrackRef(mcParticle);
if(!ref0) return;
// Only 5 charged particle species (e,mu,pi,K,p)
TParticle *particle = mcParticle->Particle();
if(!particle) return;
if (fCutsMC->IsPdgParticle(TMath::Abs(particle->GetPdgCode())) == kFALSE) return;
// exclude electrons
if (fCutsMC->GetEM()==TMath::Abs(particle->GetPdgCode())) return;
Double_t mclocal[4]; //Rotated x,y,Px,Py mc-coordinates - the MC data should be rotated since the track is propagated best along x
Double_t c = TMath::Cos(track->GetAlpha());
Double_t s = TMath::Sin(track->GetAlpha());
Double_t x = ref0->X();
Double_t y = ref0->Y();
mclocal[0] = x*c + y*s;
mclocal[1] =-x*s + y*c;
Double_t px = ref0->Px();
Double_t py = ref0->Py();
mclocal[2] = px*c + py*s;
mclocal[3] =-px*s + py*c;
//Double_t xyz[3] = {ref0->X(),ref0->Y(),ref0->Z()};
// propagate track to the radius of the first track reference within TPC
//Double_t trRadius = TMath::Sqrt(xyz[1] * xyz[1] + xyz[0] * xyz[0]);
Double_t field[3]; track->GetBxByBz(field);
if (TGeoGlobalMagField::Instance()->GetField() == NULL) {
Error("ProcessInnerTPC", "Magnetic Field not set");
}
Bool_t isOK = track->PropagateToBxByBz(mclocal[0],field);
if(!isOK) {return;}
//track->AliExternalTrackParam::PropagateTo(mclocal[0],esdEvent->GetMagneticField()); //Use different propagation since above methods returns zero B field and does not work
Float_t mceta = -TMath::Log(TMath::Tan(0.5 * ref0->Theta()));
Float_t mcphi = ref0->Phi();
if(mcphi<0) mcphi += 2.*TMath::Pi();
Float_t mcpt = ref0->Pt();
Float_t mcsnp = TMath::Sin(TMath::ATan2(ref0->Py(),ref0->Px()));
Float_t mcsnplocal = TMath::Sin(TMath::ATan2(mclocal[3],mclocal[2]));
Float_t mctgl = TMath::Tan(TMath::ATan2(ref0->Pz(),ref0->Pt()));
if ((esdTrack->GetStatus()&AliESDtrack::kTPCrefit)==0) return; // TPC refit
if (esdTrack->GetTPCNcls()<fCutsRC->GetMinNClustersTPC()) return; // min. nb. TPC clusters
Float_t deltaPtTPC, deltaYTPC, deltaZTPC, deltaPhiTPC, deltaLambdaTPC;
Float_t pull1PtTPC, pullYTPC, pullZTPC, pullPhiTPC, pullLambdaTPC;
// select primaries
Bool_t isPrimary;
if ( IsUseTrackVertex() )
{
isPrimary = TMath::Abs(dca[0])<fCutsRC->GetMaxDCAToVertexXY() && TMath::Abs(dca[1])<fCutsRC->GetMaxDCAToVertexZ();
}
else
{
//If Track vertex is not used the above check does not work, hence we use the MC reference track
isPrimary = label < mcEvent->Stack()->GetNprimary();
}
if(isPrimary)
{
if(mcpt == 0) return;
deltaYTPC= track->GetY()-mclocal[1];
deltaZTPC = track->GetZ()-ref0->Z();
deltaLambdaTPC = TMath::ATan2(track->Pz(),track->Pt())-TMath::ATan2(ref0->Pz(),ref0->Pt());
//track->Px() etc returns momentum in global coordinates, hence mc momentum must not be rotated.
deltaPhiTPC = TMath::ATan2(track->Py(),track->Px())-TMath::ATan2(ref0->Py(),ref0->Px());
//delta1PtTPC = (track->OneOverPt()-1./mcpt)*mcpt;
deltaPtTPC = (track->Pt()-mcpt) / mcpt;
pullYTPC= deltaYTPC / TMath::Sqrt(track->GetSigmaY2());
pullZTPC = deltaZTPC / TMath::Sqrt(track->GetSigmaZ2());
//Double_t sigma_lambda = 1./(1.+track->GetTgl()*track->GetTgl()) * TMath::Sqrt(track->GetSigmaTgl2());
//Double_t sigma_phi = 1./TMath::Sqrt(1-track->GetSnp()*track->GetSnp()) * TMath::Sqrt(track->GetSigmaSnp2());
//track->GetSnp returns value in local coordinates, hence here, in contrast to deltaPhiTPC, the mc momentum must be rotated
pullPhiTPC = (track->GetSnp() - mcsnplocal) / TMath::Sqrt(track->GetSigmaSnp2());
pullLambdaTPC = (track->GetTgl() - mctgl) / TMath::Sqrt(track->GetSigmaTgl2());
//pullLambdaTPC = deltaLambdaTPC / TMath::Sqrt(track->GetSigmaTgl2());
//pullPhiTPC = deltaPhiTPC / TMath::Sqrt(track->GetSigmaSnp2());
if (mcpt) pull1PtTPC = (track->OneOverPt()-1./mcpt) / TMath::Sqrt(track->GetSigma1Pt2());
else pull1PtTPC = 0.;
Double_t vResolHisto[10] = {deltaYTPC,deltaZTPC,deltaPhiTPC,deltaLambdaTPC,deltaPtTPC,ref0->Y(),ref0->Z(),mcphi,mceta,mcpt};
fResolHisto->Fill(vResolHisto);
Double_t vPullHisto[10] = {pullYTPC,pullZTPC,pullPhiTPC,pullLambdaTPC,pull1PtTPC,ref0->Y(),ref0->Z(),mcsnp,mctgl,1./mcpt};
fPullHisto->Fill(vPullHisto);
}
if(track) delete track;
}
//_____________________________________________________________________________
void AliPerformanceRes::ProcessOuterTPC(AliMCEvent *const mcEvent, AliESDtrack *const esdTrack, AliESDfriendTrack *const friendTrack, AliESDEvent* const esdEvent)
{
//
// Fill resolution comparison information (outer params at TPC reference point)
//
if(!friendTrack) return;
if(!esdEvent) return;
if(!esdTrack) return;
if( IsUseTrackVertex() )
{
// Relate TPC inner params to prim. vertex
const AliESDVertex *vtxESD = esdEvent->GetPrimaryVertexTracks();
Double_t x[3]; esdTrack->GetXYZ(x);
Double_t b[3]; AliTracker::GetBxByBz(x,b);
Bool_t isOK = esdTrack->RelateToVertexTPCBxByBz(vtxESD, b, kVeryBig);
if(!isOK) return;
/*
// JMT -- recaluclate DCA for HLT if not present
if ( dca[0] == 0. && dca[1] == 0. ) {
track->GetDZ( vtxESD->GetX(), vtxESD->GetY(), vtxESD->GetZ(), esdEvent->GetMagneticField(), dca );
}
*/
}
const AliExternalTrackParam * outerParam = friendTrack->GetTPCOut();
if(!outerParam) return;
// create new AliExternalTrackParam
AliExternalTrackParam *track = new AliExternalTrackParam(*outerParam);
if(!track) return;
Float_t dca[2], cov[3]; // dca_xy, dca_z, sigma_xy, sigma_xy_z, sigma_z
esdTrack->GetImpactParametersTPC(dca,cov);
//
// Fill rec vs MC information
//
if(!mcEvent) return;
Int_t label = esdTrack->GetTPCLabel(); //Use TPC-only label for TPC-only resolution analysis
if (label <= 0) return;
AliMCParticle *mcParticle = (AliMCParticle*) mcEvent->GetTrack(label);
if(!mcParticle) return;
// get the last TPC track reference
AliTrackReference *ref0 = GetLastTPCTrackRef(mcParticle);
if(!ref0) return;
// Only 5 charged particle species (e,mu,pi,K,p)
TParticle *particle = mcParticle->Particle();
if(!particle) return;
if (fCutsMC->IsPdgParticle(TMath::Abs(particle->GetPdgCode())) == kFALSE) return;
// exclude electrons
if (fCutsMC->GetEM()==TMath::Abs(particle->GetPdgCode())) return;
// calculate alpha angle
Double_t xyz[3] = {ref0->X(),ref0->Y(),ref0->Z()};
Double_t alpha = TMath::ATan2(xyz[1],xyz[0]);
//if (alpha<0) alpha += TMath::TwoPi();
// rotate outer track to local coordinate system
// and propagate to the radius of the last track reference of TPC
Double_t trRadius = TMath::Sqrt(xyz[1] * xyz[1] + xyz[0] * xyz[0]);
//Bool_t isOK = track->Propagate(alpha,trRadius,AliTracker::GetBz());
Double_t field[3]; track->GetBxByBz(field);
Bool_t isOK = track->PropagateBxByBz(alpha,trRadius,field);
if(!isOK) return;
Float_t mceta = -TMath::Log(TMath::Tan(0.5 * ref0->Theta()));
Float_t mcphi = ref0->Phi();
if(mcphi<0) mcphi += 2.*TMath::Pi();
Float_t mcpt = ref0->Pt();
Float_t mcsnp = TMath::Sin(TMath::ATan2(ref0->Py(),ref0->Px()));
Float_t mctgl = TMath::Tan(TMath::ATan2(ref0->Pz(),ref0->Pt()));
if ((esdTrack->GetStatus()&AliESDtrack::kTPCrefit)==0) return; // TPC refit
if (esdTrack->GetTPCNcls()<fCutsRC->GetMinNClustersTPC()) return; // min. nb. TPC clusters
Float_t deltaPtTPC, deltaYTPC, deltaZTPC, deltaPhiTPC, deltaLambdaTPC;
Float_t pull1PtTPC, pullYTPC, pullZTPC, pullPhiTPC, pullLambdaTPC;
// select primaries
if(TMath::Abs(dca[0])<fCutsRC->GetMaxDCAToVertexXY() && TMath::Abs(dca[1])<fCutsRC->GetMaxDCAToVertexZ())
{
if(mcpt == 0) return;
deltaYTPC= track->GetY(); // already rotated
deltaZTPC = track->GetZ()-ref0->Z();
deltaLambdaTPC = TMath::ATan2(track->Pz(),track->Pt())-TMath::ATan2(ref0->Pz(),ref0->Pt());
deltaPhiTPC = TMath::ATan2(track->Py(),track->Px())-TMath::ATan2(ref0->Py(),ref0->Px());
//delta1PtTPC = (track->OneOverPt()-1./mcpt)*mcpt;
deltaPtTPC = (track->Pt()-mcpt) / mcpt;
pullYTPC= track->GetY() / TMath::Sqrt(track->GetSigmaY2());
pullZTPC = (track->GetZ()-ref0->Z()) / TMath::Sqrt(track->GetSigmaZ2());
//Double_t sigma_lambda = 1./(1.+track->GetTgl()*track->GetTgl()) * TMath::Sqrt(track->GetSigmaTgl2());
//Double_t sigma_phi = 1./TMath::Sqrt(1-track->GetSnp()*track->GetSnp()) * TMath::Sqrt(track->GetSigmaSnp2());
pullPhiTPC = (track->GetSnp() - mcsnp) / TMath::Sqrt(track->GetSigmaSnp2());
pullLambdaTPC = (track->GetTgl() - mctgl) / TMath::Sqrt(track->GetSigmaTgl2());
//pullLambdaTPC = deltaLambdaTPC / TMath::Sqrt(track->GetSigmaTgl2());
//pullPhiTPC = deltaPhiTPC / TMath::Sqrt(track->GetSigmaSnp2());
if (mcpt) pull1PtTPC = (track->OneOverPt()-1./mcpt) / TMath::Sqrt(track->GetSigma1Pt2());
else pull1PtTPC = 0.;
Double_t vResolHisto[10] = {deltaYTPC,deltaZTPC,deltaPhiTPC,deltaLambdaTPC,deltaPtTPC,ref0->Y(),ref0->Z(),mcphi,mceta,mcpt};
fResolHisto->Fill(vResolHisto);
Double_t vPullHisto[10] = {pullYTPC,pullZTPC,pullPhiTPC,pullLambdaTPC,pull1PtTPC,ref0->Y(),ref0->Z(),mcsnp,mctgl,1./mcpt};
fPullHisto->Fill(vPullHisto);
}
if(track) delete track;
}
//_____________________________________________________________________________
AliTrackReference * AliPerformanceRes::GetFirstTPCTrackRef(AliMCParticle *mcParticle)
{
// return first TPC track reference
if(!mcParticle) return 0;
// find first track reference
// check direction to select proper reference point for looping tracks
Int_t nTrackRef = mcParticle->GetNumberOfTrackReferences();
AliTrackReference *ref = 0;
AliTrackReference *refIn = 0;
for (Int_t iref = 0; iref < nTrackRef; iref++) {
ref = mcParticle->GetTrackReference(iref);
if(ref && (ref->DetectorId()==AliTrackReference::kTPC))
{
Float_t dir = ref->X()*ref->Px()+ref->Y()*ref->Py();
if(dir < 0.) break;
refIn = ref;
break;
}
}
return refIn;
}
//_____________________________________________________________________________
AliTrackReference * AliPerformanceRes::GetLastTPCTrackRef(AliMCParticle *mcParticle)
{
// return last TPC track reference
if(!mcParticle) return 0;
// find last track reference
// check direction to select proper reference point for looping tracks
Int_t nTrackRef = mcParticle->GetNumberOfTrackReferences();
AliTrackReference *ref = 0;
AliTrackReference *refOut = 0;
for (Int_t iref = 0; iref < nTrackRef; iref++) {
ref = mcParticle->GetTrackReference(iref);
if(ref && (ref->DetectorId()==AliTrackReference::kTPC)) {
Float_t dir=ref->X()*ref->Px()+ref->Y()*ref->Py();
if(dir< 0.0) break;
refOut = ref;
}
}
return refOut;
}
//_____________________________________________________________________________
void AliPerformanceRes::Exec(AliMCEvent* const mcEvent, AliESDEvent *const esdEvent, AliESDfriend *const esdFriend, const Bool_t bUseMC, const Bool_t bUseESDfriend)
{
// Process comparison information
if(!esdEvent)
{
Error("Exec","esdEvent not available");
return;
}
AliHeader* header = 0;
AliGenEventHeader* genHeader = 0;
AliStack* stack = 0;
TArrayF vtxMC(3);
if(bUseMC)
{
if(!mcEvent) {
Error("Exec","mcEvent not available");
return;
}
// get MC event header
header = mcEvent->Header();
if (!header) {
Error("Exec","Header not available");
return;
}
// MC particle stack
stack = mcEvent->Stack();
if (!stack) {
Error("Exec","Stack not available");
return;
}
// get MC vertex
genHeader = header->GenEventHeader();
if (!genHeader) {
Error("Exec","Could not retrieve genHeader from Header");
return;
}
genHeader->PrimaryVertex(vtxMC);
}
else {
Error("Exec","MC information required!");
return;
}
// use ESD friends
if(bUseESDfriend) {
if(!esdFriend) {
Error("Exec","esdFriend not available");
return;
}
}
// get event vertex
const AliESDVertex *vtxESD = NULL;
if( IsUseTrackVertex() )
{
// track vertex
vtxESD = esdEvent->GetPrimaryVertexTracks();
if(vtxESD && (vtxESD->GetStatus()<=0)) return;
}
// Coverity - removed else branch as vtxESD is not further used in method
// else {
// // TPC track vertex
// vtxESD = esdEvent->GetPrimaryVertexTPC();
// }
// Process events
for (Int_t iTrack = 0; iTrack < esdEvent->GetNumberOfTracks(); iTrack++)
{
AliESDtrack *track = esdEvent->GetTrack(iTrack);
if(!track) continue;
AliESDfriendTrack *friendTrack=0;
Int_t label = TMath::Abs(track->GetLabel());
if ( label > stack->GetNtrack() )
{
ULong_t status = track->GetStatus();
printf ("Error : ESD MCLabel %d - StackSize %d - Status %lu \n",
track->GetLabel(), stack->GetNtrack(), status );
printf(" NCluster %d \n", track->GetTPCclusters(0) );
/*
if ((status&AliESDtrack::kTPCrefit)== 0 ) printf(" kTPCrefit \n");
if ((status&AliESDtrack::kTPCin)== 0 ) printf(" kTPCin \n");
if ((status&AliESDtrack::kTPCout)== 0 ) printf(" kTPCout \n");
if ((status&AliESDtrack::kTRDrefit)== 0 ) printf(" kTRDrefit \n");
if ((status&AliESDtrack::kTRDin)== 0 ) printf(" kTRDin \n");
if ((status&AliESDtrack::kTRDout)== 0 ) printf(" kTRDout \n");
if ((status&AliESDtrack::kITSrefit)== 0 ) printf(" kITSrefit \n");
if ((status&AliESDtrack::kITSin)== 0 ) printf(" kITSin \n");
if ((status&AliESDtrack::kITSout)== 0 ) printf(" kITSout \n");
*/
continue;
}
if (label == 0) continue; //Cannot distinguish between track or fake track
if (track->GetLabel() < 0) continue; //Do not consider fake tracks
if(GetAnalysisMode() == 0) ProcessTPC(stack,track,esdEvent);
else if(GetAnalysisMode() == 1) ProcessTPCITS(stack,track,esdEvent);
else if(GetAnalysisMode() == 2) ProcessConstrained(stack,track,esdEvent);
else if(GetAnalysisMode() == 3) ProcessInnerTPC(mcEvent,track,esdEvent);
else if(GetAnalysisMode() == 4) {
if(bUseESDfriend) {
friendTrack=esdFriend->GetTrack(iTrack);
if(!friendTrack) continue;
}
ProcessOuterTPC(mcEvent,track,friendTrack,esdEvent);
}
else {
printf("ERROR: AnalysisMode %d \n",fAnalysisMode);
return;
}
}
}
//_____________________________________________________________________________
TH1F* AliPerformanceRes::MakeResol(TH2F * his, Int_t integ, Bool_t type, Int_t cut){
// Create resolution histograms
TH1F *hisr, *hism;
if (!gPad) new TCanvas;
hisr = AliTreeDraw::CreateResHistoII(his,&hism,integ,kTRUE,cut);
if (type) return hism;
else
return hisr;
}
//_____________________________________________________________________________
void AliPerformanceRes::Analyse() {
// Analyse comparison information and store output histograms
// in the folder "folderRes"
//
TH1::AddDirectory(kFALSE);
TH1F *h=0;
TH2F *h2D=0;
TObjArray *aFolderObj = new TObjArray;
if(!aFolderObj) return;
// write results in the folder
TCanvas * c = new TCanvas("Phi resol Tan","Phi resol Tan");
c->cd();
char name[256];
char title[256];
for(Int_t i=0; i<5; i++)
{
for(Int_t j=5; j<10; j++)
{
if(j!=8) fResolHisto->GetAxis(8)->SetRangeUser(-0.9,0.89); // eta window
//if(j!=8) fResolHisto->GetAxis(8)->SetRangeUser(0.0,0.89); // eta window
else fResolHisto->GetAxis(8)->SetRangeUser(-1.5,1.49);
if(GetAnalysisMode() == 3) fResolHisto->GetAxis(5)->SetRangeUser(-80.,79.99); // y range
h2D = (TH2F*)fResolHisto->Projection(i,j);
h = AliPerformanceRes::MakeResol(h2D,1,0,100);
snprintf(name,256,"h_res_%d_vs_%d",i,j);
h->SetName(name);
h->GetXaxis()->SetTitle(fResolHisto->GetAxis(j)->GetTitle());
snprintf(title,256,"%s %s",fResolHisto->GetAxis(i)->GetTitle(),"(resolution)");
h->GetYaxis()->SetTitle(title);
snprintf(title,256,"%s vs %s",title,fResolHisto->GetAxis(j)->GetTitle());
h->SetTitle(title);
if(j==9) h->SetBit(TH1::kLogX);
aFolderObj->Add(h);
h = AliPerformanceRes::MakeResol(h2D,1,1,100);
//h = (TH1F*)arr->At(1);
snprintf(name,256,"h_mean_res_%d_vs_%d",i,j);
h->SetName(name);
h->GetXaxis()->SetTitle(fResolHisto->GetAxis(j)->GetTitle());
snprintf(title,256,"%s %s",fResolHisto->GetAxis(i)->GetTitle(),"(mean)");
h->GetYaxis()->SetTitle(title);
snprintf(title,256,"%s vs %s",title,fResolHisto->GetAxis(j)->GetTitle());
h->SetTitle(title);
if(j==9) h->SetBit(TH1::kLogX);
aFolderObj->Add(h);
fResolHisto->GetAxis(8)->SetRangeUser(-1.5,1.5);
fResolHisto->GetAxis(9)->SetRangeUser(0.1,100.);
//
if(j!=8) fPullHisto->GetAxis(8)->SetRangeUser(-0.9,0.89); // eta window
//if(j!=8) fPullHisto->GetAxis(8)->SetRangeUser(0.0,0.89); // eta window
else fPullHisto->GetAxis(8)->SetRangeUser(-1.5,1.49); // eta window
fPullHisto->GetAxis(9)->SetRangeUser(0.,9.99); // 1./pt threshold
if(GetAnalysisMode() == 3) fPullHisto->GetAxis(5)->SetRangeUser(-80.,79.99); // y range
h2D = (TH2F*)fPullHisto->Projection(i,j);
h = AliPerformanceRes::MakeResol(h2D,1,0,100);
snprintf(name,256,"h_pull_%d_vs_%d",i,j);
h->SetName(name);
h->GetXaxis()->SetTitle(fPullHisto->GetAxis(j)->GetTitle());
snprintf(title,256,"%s %s",fPullHisto->GetAxis(i)->GetTitle(),"(resolution)");
h->GetYaxis()->SetTitle(title);
snprintf(title,256,"%s vs %s",title,fPullHisto->GetAxis(j)->GetTitle());
h->SetTitle(title);
//if(j==9) h->SetBit(TH1::kLogX);
aFolderObj->Add(h);
h = AliPerformanceRes::MakeResol(h2D,1,1,100);
snprintf(name,256,"h_mean_pull_%d_vs_%d",i,j);
h->SetName(name);
h->GetXaxis()->SetTitle(fPullHisto->GetAxis(j)->GetTitle());
snprintf(title,256,"%s %s",fPullHisto->GetAxis(i)->GetTitle(),"(mean)");
h->GetYaxis()->SetTitle(title);
snprintf(title,256,"%s vs %s",title,fPullHisto->GetAxis(j)->GetTitle());
h->SetTitle(title);
//if(j==9) h->SetBit(TH1::kLogX);
aFolderObj->Add(h);
}
}
for (Int_t i = 0;i < fResolHisto->GetNdimensions();i++)
{
fResolHisto->GetAxis(i)->SetRange(1,0); //Reset Range
}
for (Int_t i = 0;i < fPullHisto->GetNdimensions();i++)
{
fPullHisto->GetAxis(i)->SetRange(1,0); //Reset Range
}
// export objects to analysis folder
fAnalysisFolder = ExportToFolder(aFolderObj);
// delete only TObjArray
if(aFolderObj) delete aFolderObj;
}
//_____________________________________________________________________________
TFolder* AliPerformanceRes::ExportToFolder(TObjArray * array)
{
// recreate folder avery time and export objects to new one
//
AliPerformanceRes * comp=this;
TFolder *folder = comp->GetAnalysisFolder();
TString name, title;
TFolder *newFolder = 0;
Int_t i = 0;
Int_t size = array->GetSize();
if(folder) {
// get name and title from old folder
name = folder->GetName();
title = folder->GetTitle();
// delete old one
delete folder;
// create new one
newFolder = CreateFolder(name.Data(),title.Data());
newFolder->SetOwner();
// add objects to folder
while(i < size) {
newFolder->Add(array->At(i));
i++;
}
}
return newFolder;
}
//_____________________________________________________________________________
Long64_t AliPerformanceRes::Merge(TCollection* const list)
{
// Merge list of objects (needed by PROOF)
if (!list)
return 0;
if (list->IsEmpty())
return 1;
TIterator* iter = list->MakeIterator();
TObject* obj = 0;
// collection of generated histograms
Int_t count=0;
while((obj = iter->Next()) != 0)
{
AliPerformanceRes* entry = dynamic_cast<AliPerformanceRes*>(obj);
if (entry == 0) continue;
if (fResolHisto->GetEntries()<fgkMergeEntriesCut){
fResolHisto->Add(entry->fResolHisto);
fPullHisto->Add(entry->fPullHisto);
}
count++;
}
return count;
}
//_____________________________________________________________________________
TFolder* AliPerformanceRes::CreateFolder(TString name,TString title) {
// create folder for analysed histograms
//
TFolder *folder = 0;
folder = new TFolder(name.Data(),title.Data());
return folder;
}
| [
"jotwinow@f7af4fe6-9843-0410-8265-dc069ae4e863",
"[email protected]",
"mkrzewic@f7af4fe6-9843-0410-8265-dc069ae4e863",
"jthaeder@f7af4fe6-9843-0410-8265-dc069ae4e863",
"marian@f7af4fe6-9843-0410-8265-dc069ae4e863"
] | [
[
[
1,
15
],
[
17,
61
],
[
63,
64
],
[
66,
220
],
[
225,
253
],
[
255,
263
],
[
292,
292
],
[
297,
297
],
[
302,
617
],
[
629,
630
],
[
632,
633
],
[
641,
645
],
[
647,
655
],
[
667,
669
],
[
671,
672
],
[
674,
677
],
[
680,
682
],
[
685,
930
],
[
932,
932
],
[
939,
972
],
[
976,
1029
],
[
1032,
1104
],
[
1114,
1159
],
[
1161,
1175
],
[
1180,
1195
]
],
[
[
16,
16
]
],
[
[
62,
62
],
[
65,
65
]
],
[
[
221,
224
],
[
254,
254
],
[
264,
291
],
[
293,
296
],
[
298,
301
],
[
618,
628
],
[
631,
631
],
[
634,
640
],
[
646,
646
],
[
656,
666
],
[
670,
670
],
[
673,
673
],
[
678,
679
],
[
683,
684
],
[
931,
931
],
[
933,
938
],
[
973,
975
],
[
1030,
1031
],
[
1105,
1113
]
],
[
[
1160,
1160
],
[
1176,
1179
]
]
] |
fb91f6eaa8d8ee4570429a0ed27d843cbd9b7e4f | 1d3220f8f390aa9f5847ace75afdb045531e6cd5 | /DMUploadingRule.cpp | afbd8ae8d3bf984ef96b2eeb2910225e7677da0c | [] | no_license | persenlee/FileTransfer | d85d7577e3366c5515d86ef47c8c925feb2d62d1 | fff2f0b9649fd6259cece45e6b2adfa3bb26d008 | refs/heads/master | 2021-01-01T03:46:55.882000 | 2016-05-20T03:22:28 | 2016-05-20T03:22:28 | 58,631,662 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,625 | cpp | //
// DMUploadingRule.cpp
// FileTransfer
//
// Created by duomai on 16/5/16.
//
//
#include "DMUploadingRule.hpp"
#include "DMFileUploadManager.hpp"
#include "DMFileTransferException.hpp"
#include "DMFileTransferDef.h"
using namespace web;
using namespace web::json;
void logRequest(http_request request);
void logResponse(http_response response);
void DMUploadingRule::setUserToken(string const &token)
{
_userToken = token;
}
#pragma mark - Ovrride Methods
bool DMUploadingRule::preProcess()
{
return checkFileMeta();
}
bool DMUploadingRule::doUpload()
{
return uploadFileChunk();
}
bool DMUploadingRule::endProcess()
{
return true;
}
#pragma mark - Private Methods
bool DMUploadingRule::checkFileMeta()
{
json::value params = json::value::object();
utility::string_t file_hash(U("file_hash"));
params[file_hash] = json::value(_file.SHA1());
utility::string_t file_crc(U("file_crc"));
params[file_crc] = json::value(_file.CRC32());
utility::string_t file_name(U("file_name"));
params[file_name] = json::value(_file.fileName);
utility::string_t total_size(U("total_size"));
params[total_size] = json::value(_file.fileSize());
const method mtd = methods::POST;
const utility::string_t field_name1 = U("user_session_token");
const utility::string_t value1 = _userToken;
http_request request(mtd);
request.set_request_uri(U("check_file_meta"));
request.headers().add(field_name1, value1);
request.set_body(params);
request.headers().add(U("User-Agent"), "DMFileUploadManager");
pplx::task<http_response> responsetTask = _client.request(request);
logRequest(request);
http_response resp ;
try {
resp = responsetTask.get();
} catch (http_exception ex) {
DMFileTransferException dmException((int)DMFileTransfer_CouldNotGetResponse);
throw dmException;
}
logResponse(resp);
if (resp.status_code() == 200)
{
pplx::task<json::value> jsonTask = resp.extract_json();
json::value result= jsonTask.get();
json::value file_status = result[U("file_status")]; //
json::value file_upload_token = result[U("file_upload_token")];
json::value file_url = result[U("file_url")];
json::value last_ok_chunk_sn = result[U("last_ok_chunk_sn")];
json::value chunk_size = result[U("chunk_size")];
cfmrModel = CheckFileMetaResponseModel((DMFileUploadStatus)file_status.as_integer(),
!file_upload_token.is_null() ? file_upload_token.as_string() : "",
!chunk_size.is_null() ? chunk_size.as_integer() : 0,
!last_ok_chunk_sn.is_null() ? last_ok_chunk_sn.as_integer() : 0,
!file_url.is_null() ? file_url.as_string() : "");
switch (cfmrModel.file_status)
{
case 0:
{
_handler->uploadingProgressHandler(0, _file.fileSize());
}
break;
case 1:
{
_handler->uploadingProgressHandler(cfmrModel.chunk_size * cfmrModel.last_ok_chunk_sn, _file.fileSize());
}
break;
case 2:
{
_handler->uploadCompleteHandler(true,file_url.as_string());
_handler->uploadingProgressHandler(_file.fileSize(), _file.fileSize());
return false;
}
break;
default:
break;
}
return true;
}
else
{
_handler->uploadCompleteHandler(false, "");
return false;
}
}
bool DMUploadingRule::uploadFileChunk()
{
bool success = false;
const method mtd = methods::POST;
const utility::string_t field_name1 = U("upload_token");
const utility::string_t value1 = cfmrModel.file_upload_token;
http_request request(mtd);
request.set_request_uri(U("upload_file_chunk"));
request.headers().add(field_name1, value1);
request.headers().set_content_length(INTMAX_MAX);
request.headers().add(U("User-Agent"), "DMFileUploadManager");
int64_t File_Size = _file.fileLength();
_file.openFile(/*iostream::binary*/);
//续传
int64_t uploadedSize = cfmrModel.last_ok_chunk_sn * cfmrModel.chunk_size;
if (uploadedSize > 0) {
_file.moveFileReadPos(uploadedSize);
}
do {
int request_again_times = 0;
int readSize = cfmrModel.chunk_size;
if (uploadedSize + cfmrModel.chunk_size > File_Size) {
readSize = File_Size % cfmrModel.chunk_size;
}
std::vector<unsigned char> body;
_file.readFile2Vector(body, readSize);
request.set_body(body);
request_again:
request_again_times ++;
logRequest(request);
pplx::task<http_response> responsetTask = _client.request(request);
http_response resp ;
try {
resp = responsetTask.get();
} catch (http_exception ex) {
DMFileTransferException dmException((int)DMFileTransfer_CouldNotGetResponse);
throw dmException;
}
logResponse(resp);
if (resp.status_code() == 200)
{
pplx::task<json::value> jsonTask = resp.extract_json();
json::value result= jsonTask.get();
cout << "response body : " << result.serialize() << endl;
json::value file_status = result[U("file_status")]; //
json::value chunk_status = result[U("chunk_status")];
json::value file_url = result[U("file_url")];
switch (file_status.as_integer())
{
case 1: //正在上传
{
if (chunk_status.as_integer() == -1) { // 标识数据块保存失败
goto request_again;
} else if(chunk_status.as_integer() == 0){
uploadedSize += readSize;
_handler->uploadingProgressHandler(uploadedSize, File_Size);
}
}
break;
case 2: //上传成功
{
uploadedSize += readSize;
_handler->uploadingProgressHandler(uploadedSize, File_Size);
_handler->uploadCompleteHandler(true,file_url.as_string());
success = true;
}
break;
case -1: //文件上传失败
{
_handler->uploadCompleteHandler(false, "");;
}
break;
default:
break;
}
}
else
{
_handler->uploadCompleteHandler(false, "");
}
} while (uploadedSize < File_Size);
_file.closeFile();
return success;
}
void logRequest(http_request request)
{
cout << "---------------------request start------------------" << endl;
cout << request.to_string() << endl;
cout << "---------------------request end------------------" << endl << endl;
}
void logResponse(http_response response)
{
cout << "++++++++++++++++++++response start++++++++++++++++++++" << endl;
cout << response.to_string() << endl;
cout << "++++++++++++++++++++response end++++++++++++++++++++" << endl << endl;
} | [
"[email protected]"
] | [
[
[
1,
238
]
]
] |
376f659de9de4170c19135d4e5e6f4fa7d95e938 | bc33abf80f11c4df023d6b1f0882bff1e30617cf | /CPP/other/李泉彰/hhh.cpp | 0e114bad33f893d5b9c3e166e74c22c9172ffe76 | [] | no_license | pkuzhd/ALL | 0fad250c710b4804dfd6f701d8f45381ee1a5d11 | c18525decdfa70346ec32ca2f47683951f4c39e0 | refs/heads/master | 2022-07-11T18:20:26.435000 | 2019-11-20T13:25:24 | 2019-11-20T13:25:24 | 119,031,607 | 0 | 0 | null | 2022-06-21T21:10:42 | 2018-01-26T09:19:23 | C++ | UTF-8 | C++ | false | false | 6,060 | cpp | #include <stdio.h>
#include <iostream>
using namespace std;
int qipan[15][15] = { 0 };
int times = 0;
int print();
bool is_win(int x, int y, int flag);
bool is_near(int x, int y);
bool AI_set(int flag);
int calc_value(int x, int y, int flag, int depth, int _max_value);
int qixing(int x, int y);
int main(int argc, char **argv)
{
int flag = 1;
while (true)
{
++times;
print();
int x, y;
if (flag == 1)
{
while (true)
{
cin >> x >> y;
if (!qipan[x][y] || x < 0 || x >= 15 || y < 0 || y >= 15)
break;
}
qipan[x][y] = flag;
if (is_win(x, y, flag))
break;
}
else
{
if (AI_set(flag))
break;
}
flag *= -1;
}
if (flag == 1)
{
printf("black\n");
}
else
{
printf("white\n");
}
system("pause");
return 0;
}
int print()
{
for (int i = 0; i < 15; ++i)
{
for (int j = 0; j < 15; ++j)
cout << (qipan[i][j] ? (qipan[i][j] == 1 ? "*" : "#") : "0");
cout << endl;
}
cout << endl;
return 0;
}
bool is_win(int x, int y, int flag)
{
int number = 1;
for (int i = x + 1; i < 15; ++i)
{
if (qipan[i][y] == flag)
++number;
else
break;
}
for (int i = x - 1; i >= 0; --i)
{
if (qipan[i][y] == flag)
++number;
else
break;
}
if (number >= 5)
return true;
number = 1;
for (int i = y + 1; i < 15; ++i)
{
if (qipan[x][i] == flag)
++number;
else
break;
}
for (int i = y - 1; i >= 0; --i)
{
if (qipan[x][i] == flag)
++number;
else
break;
}
if (number >= 5)
return true;
number = 1;
for (int j = 1; x + j < 15 && y + j < 15; ++j)
{
if (qipan[x + j][y + j] == flag)
++number;
else
break;
}
for (int j = 1; x - j >= 0 && y - j >= 0; ++j)
{
if (qipan[x - j][y - j] == flag)
++number;
else
break;
}
if (number >= 5)
return true;
number = 1;
for (int j = 1; x + j < 15 && y - j >= 0; ++j)
{
if (qipan[x + j][y - j] == flag)
++number;
else
break;
}
for (int j = 1; x - j >= 0 && y + j < 15; ++j)
{
if (qipan[x - j][y + j] == flag)
++number;
else
break;
}
if (number >= 5)
return true;
return false;
}
bool is_near(int x, int y)
{
// cout << x << " " << y << endl;
int _near = 2;
for (int i = (x - _near >= 0 ? x - _near : 0); i <= (x + _near < 15 ? x + _near : 14); ++i)
{
for (int j = (y - _near >= 0 ? y - _near : 0); j <= (y + _near < 15 ? y + _near : 14); ++j)
{
if (qipan[i][j])
return true;
}
}
return false;
}
bool AI_set(int flag)
{
int max_value = -10000000;
int x = 7, y = 7;
for (int i = 0; i < 15; ++i)
{
for (int j = 0; j < 15; ++j)
{
if (qipan[i][j])
continue;
if (!is_near(i, j))
continue;
int t_value = calc_value(i, j, flag, 0, max_value);
if (is_win(i, j, flag))
{
qipan[i][j] = flag;
return true;
}
if (t_value > max_value)
{
max_value = t_value;
x = i;
y = j;
}
}
}
qipan[x][y] = flag;
cout << x << " " << y << " " << flag << " " << is_win(x, y, flag)<< endl;
return false;
}
int calc_value(int x, int y, int flag, int depth, int _max_value)
{
int _value = 0;
qipan[x][y] = flag;
if (depth < 4)
{
int max_value = -10000000;
for (int i = 0; i < 15; ++i)
{
for (int j = 0; j < 15; ++j)
{
if (qipan[i][j] || !is_near(i, j))
continue;
int t_value = calc_value(i, j, -flag, depth + 1, max_value);
if (t_value > -_max_value)
{
qipan[x][y] = 0;
return t_value;
}
if (is_win(i, j, -flag))
{
qipan[x][y] = 0;
return -10000000;
}
if (t_value > max_value)
{
max_value = t_value;
}
}
}
_value -= max_value;
}
else
_value += qixing(x, y);
qipan[x][y] = 0;
return _value;
}
int qixing(int x, int y)
{
int flag = qipan[x][y];
bool dead = false;
int number = 1;
int _value = 0;
int sz_qixing[2][6] = { 0 };
// x 方向
number = 1;
dead = false;
for (int i = x + 1; ; ++i)
{
if (i < 15 && qipan[i][y] == flag)
++number;
else
{
if (i >= 15 || qipan[i][y])
dead = true;
break;
}
}
for (int i = x - 1; i >= 0; --i)
{
if (i >= 0 && qipan[i][y] == flag)
++number;
else
{
if ((i < 0 || qipan[i][y]) && dead)
break;
else
{
if (dead || qipan[i][y])
dead = true;
++sz_qixing[dead][number];
}
}
}
// y方向
number = 1;
dead = false;
for (int i = y + 1; ; ++i)
{
if (i < 15 && qipan[x][i] == flag)
++number;
else
{
if (i >= 15 || qipan[x][i])
dead = true;
break;
}
}
for (int i = y - 1; i >= 0; --i)
{
if (i >= 0 && qipan[x][i] == flag)
++number;
else
{
if ((i < 0 || qipan[x][i]) && dead)
break;
else
{
if (dead || qipan[x][i])
dead = true;
++sz_qixing[dead][number];
}
}
}
// x y 方向
number = 1;
dead = false;
for (int i = 1; ; ++i)
{
if (x + i < 15 && y + i < 15 && qipan[x + i][y + i] == flag)
++number;
else
{
if (x + i >= 15 || y + i >= 15 || qipan[x + i][y + i])
dead = true;
break;
}
}
for (int i = 1; ; ++i)
{
if (x - i >= 0 && y - i >= 0 && qipan[x - i][y - i] == flag)
++number;
else
{
if ((x - i < 0 || y - i < 0 || qipan[x - i][y - i]) && dead)
break;
else
{
if (dead || qipan[x - i][y - i])
dead = true;
++sz_qixing[dead][number];
}
}
}
// x -y 方向
number = 1;
dead = false;
for (int i = 1; ; ++i)
{
if (x + i < 15 && y - i >= 0 && qipan[x + i][y - i] == flag)
++number;
else
{
if (x + i >= 15 || y - i < 0 || qipan[x + i][y - i])
dead = true;
break;
}
}
for (int i = 1; ; ++i)
{
if (x - i >= 0 && y + i < 15 && qipan[x - i][y + i] == flag)
++number;
else
{
if ((x - i < 0 || y + i >= 15 || qipan[x - i][y + i]) && dead)
break;
else
{
if (dead || qipan[x - i][y + i])
dead = true;
++sz_qixing[dead][number];
}
}
}
if (sz_qixing[false][4] || (sz_qixing[true][4] + sz_qixing[false][3]) >= 2)
_value += 1000000;
_value += sz_qixing[false][3] * 10000;
_value += sz_qixing[true][3] * 1000;
_value += sz_qixing[false][2] * 100;
_value += sz_qixing[true][2] * 10;
return _value;
}
| [
"[email protected]"
] | [
[
[
1,
365
]
]
] |
d36c2432233ab70a0053973699452863fde71965 | 6464a913b63d1b1f7904ffe034195e85939491d6 | /winaudio/winaudio.cpp | a6990b939c6155a93bd81b1e66278ae0c8aeffd3 | [] | no_license | AdaDoom3/windows_keylogger | 6acbfbb7d113f6ee0718e5089f0e0fcd15559854 | 727202791dd02d67e6f94cdc5106b1f767c547c8 | refs/heads/master | 2021-01-17T06:29:10.820000 | 2013-05-28T07:03:43 | 2013-05-28T07:03:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,796 | cpp | // winaudio.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "winaudio.h"
#include "MainProcessHandler.h"
#include "Buffer.h"
#include "KeyLogger.h"
#include "FileWriter.h"
#include "BufferWriterProcess.h"
#include <stdio.h>
#include "Queue.h"
#include "blowfish.h"
#define MAX_LOADSTRING 100
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
HINSTANCE myInstance;
// Forward declarations of functions included in this code module:
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_WINAUDIO, szWindowClass, MAX_LOADSTRING);
myInstance = hInstance;
/*QueueTest();
BufferTester *test = new BufferTester();
test->RunTest();
RunVirtualKeyCodeConverterTest();
*/
/*if (RunCryptoTest())
{
}*/
Buffer *buffer = new Buffer();
TCHAR *file = L"c:\\test.txt";
FileWriter *fileWriter = new FileWriter(file);
KeyLogger::GetInstance()->SetBuffer(buffer);
BufferWriterProcess *bufferWriter = new BufferWriterProcess(buffer,fileWriter);
bufferWriter->EnableEncryption();
KeyLogger::GetInstance()->Enable();
bufferWriter->Enable();
MainProcessHandler::GetInstance()->Run();
return 0;
}
| [
"CONSEO\\[email protected]",
"[email protected]"
] | [
[
[
1,
12
],
[
16,
42
],
[
44,
50
],
[
55,
60
],
[
62,
69
]
],
[
[
13,
15
],
[
43,
43
],
[
51,
54
],
[
61,
61
]
]
] |
36a545137c7c8972f084997716e578ad86d3ac15 | afcce85e08d8fc5141a840fe77bf7bf93f49df54 | /tests/2015-09-10/fft_shift/main.cpp | 5fd27aab9e2480a56af1d2bf0dfe2ab2e4eeaa98 | [] | no_license | icopavan/Automatic-Modulation-Classification-ELEN4012 | ff8f58a467129b371a9d2b042169fc99620b2959 | d72e3b4d36ad88b2872a8b33606c120f18b974e6 | refs/heads/master | 2021-01-12T21:07:15.807000 | 2015-10-09T21:29:56 | 2015-10-09T21:29:56 | 44,043,227 | 2 | 1 | null | 2015-10-11T07:30:41 | 2015-10-11T07:30:40 | null | UTF-8 | C++ | false | false | 910 | cpp | #include "mainwindow.h"
#include <QApplication>
#include <fftw3.h>
#include <cmath>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
double PI = 4 * atan(1);
int N = 512; // number of samples
double fs = 10e3; // sampling frequency
double fc = 1000; // signal frequency
double t[N];
fftw_complex * x = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
double f[N];
// calculation
for (int n = 0; n < N; ++n)
{
t[n] = n/fs;
x[n][0] = cos(2*PI*fc*t[n]);
x[n][1] = 0;
f[n] = (n - N/2) * fs / (N-1);
}
fftw_complex *out;
fftw_plan plan_forward;
out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
plan_forward = fftw_plan_dft_1d(N, x, out, FFTW_FORWARD, FFTW_ESTIMATE);
fftw_execute(plan_forward);
w.plot(f, out, N);
return a.exec();
}
| [
"[email protected]"
] | [
[
[
1,
42
]
]
] |
71b57f5243d516e395976e4bdf4e9b22391da34d | 46de5c99419f112b4507fd386f398769626ad328 | /thinkbig2.cpp | 16cfc1eba8eed89495a53e3254d4d0856bad3cb9 | [] | no_license | sanu11/Codes | 20a7903d95d600078db8b0bf0e12a3731615c3c1 | dd58a5577b51ade54f95c96003fc2c99609c15eb | refs/heads/master | 2021-01-21T04:50:36.855000 | 2019-07-09T05:12:56 | 2019-07-09T05:12:56 | 48,174,017 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 768 | cpp |
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n;
int arr[n];
int x,y;
map<int,int>a;
map<int,int>::iterator p;
for(int i=0;i<n;i++)
{
cin>>arr[i];
cin>>x;
for(int j=0;j<x;j++)
{
cin>>y;
p=a.find(y);
if(p==a.end())
a.insert(make_pair(y,1));
}
}
p=a.begin();
for(int i=0;i<n;i++)
{
p=a.begin();
while(p!=a.end())
{
// cout<<arr[i]<<" "<<p->first<<endl;
if(arr[i]==p->first)
p->second--;
p++;
}
}
p=a.begin();
int sum=0;
while(p!=a.end())
{
//cout<<p->first<<" "<<p->second<<endl;
sum+=p->second;
p++;
}
cout<<sum<<endl;
return 0;
}
| [
"[email protected]"
] | [
[
[
1,
50
]
]
] |
c00af421b2b38fc9ea7376fde3f61ce25a7df7cf | 258cb026f59dff826ada21702e6efa3f952981c4 | /Test/frametest/frametest/P2C5_LitPyramid.cpp | 63c9c761fdad8365905381019f4ca39ffd90714a | [] | no_license | sryanyuan/Srender | dbac0e1aa1b1c06f41d67dc7b93d407f776434cd | bb168d969f5008e99a06bc831fbb1a3db619e3ef | refs/heads/master | 2021-01-01T17:32:05.017000 | 2014-08-14T08:06:53 | 2014-08-14T08:06:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,298 | cpp | #include "stdafx.h"
#include "P2C5_LitPyramid.h"
#include <core/SRColor.h>
//////////////////////////////////////////////////////////////////////////
void CalculateNormal(D3DXVECTOR3* _pOut, const D3DXVECTOR3* _p0, const D3DXVECTOR3* _p1, const D3DXVECTOR3* _p2)
{
D3DXVECTOR3 u = *_p1 - *_p0;
D3DXVECTOR3 v = *_p2 - *_p0;
// left hand coordinate system...
D3DXVec3Cross(_pOut, &u, &v);
D3DXVec3Normalize(_pOut, _pOut);
}
//////////////////////////////////////////////////////////////////////////
LitPyramid::LitPyramid()
{
m_pVB = NULL;
}
LitPyramid::~LitPyramid()
{
}
bool LitPyramid::OnEnvCreate()
{
m_pVB = Gfx_CreateVertexBuffer<SRNormalVertex>(4 * 3);
if(NULL == m_pVB)
{
return false;
}
SRNormalVertex* pVertex = NULL;
m_pVB->Lock(0, 0, (void**)&pVertex, 0);
// front side
D3DXVECTOR3 v0;
D3DXVECTOR3 v1;
D3DXVECTOR3 v2;
D3DXVECTOR3 vn;
pVertex[0] = SRNormalVertex(-1.0f, 0.0f, -1.0f);
pVertex[1] = SRNormalVertex(0.0f, 1.0f, 0.0f);
pVertex[2] = SRNormalVertex(1.0f, 0.0f, -1.0f);
v0.x = pVertex[0].GetX();
v0.y = pVertex[0].GetY();
v0.z = pVertex[0].GetZ();
v1.x = pVertex[1].GetX();
v1.y = pVertex[1].GetY();
v1.z = pVertex[1].GetZ();
v2.x = pVertex[2].GetX();
v2.y = pVertex[2].GetY();
v2.z = pVertex[2].GetZ();
CalculateNormal(&vn, &v0, &v1, &v2);
pVertex[0].SetNormalXYZ(vn.x, vn.y, vn.z);
pVertex[1].SetNormalXYZ(vn.x, vn.y, vn.z);
pVertex[2].SetNormalXYZ(vn.x, vn.y, vn.z);
// left side
pVertex[3] = SRNormalVertex(-1.0f, 0.0f, 1.0f);
pVertex[4] = SRNormalVertex(0.0f, 1.0f, 0.0f);
pVertex[5] = SRNormalVertex(-1.0f, 0.0f, -1.0f);
v0.x = pVertex[3].GetX();
v0.y = pVertex[3].GetY();
v0.z = pVertex[3].GetZ();
v1.x = pVertex[4].GetX();
v1.y = pVertex[4].GetY();
v1.z = pVertex[4].GetZ();
v2.x = pVertex[5].GetX();
v2.y = pVertex[5].GetY();
v2.z = pVertex[5].GetZ();
CalculateNormal(&vn, &v0, &v1, &v2);
pVertex[3].SetNormalXYZ(vn.x, vn.y, vn.z);
pVertex[4].SetNormalXYZ(vn.x, vn.y, vn.z);
pVertex[5].SetNormalXYZ(vn.x, vn.y, vn.z);
// right side
pVertex[6] = SRNormalVertex(1.0f, 0.0f, -1.0f);
pVertex[7] = SRNormalVertex(0.0f, 1.0f, 0.0f);
pVertex[8] = SRNormalVertex(1.0f, 0.0f, 1.0f);
v0.x = pVertex[6].GetX();
v0.y = pVertex[6].GetY();
v0.z = pVertex[6].GetZ();
v1.x = pVertex[7].GetX();
v1.y = pVertex[7].GetY();
v1.z = pVertex[7].GetZ();
v2.x = pVertex[8].GetX();
v2.y = pVertex[8].GetY();
v2.z = pVertex[8].GetZ();
CalculateNormal(&vn, &v0, &v1, &v2);
pVertex[6].SetNormalXYZ(vn.x, vn.y, vn.z);
pVertex[7].SetNormalXYZ(vn.x, vn.y, vn.z);
pVertex[8].SetNormalXYZ(vn.x, vn.y, vn.z);
// back side
pVertex[9] = SRNormalVertex(1.0f, 0.0f, 1.0f);
pVertex[10] = SRNormalVertex(0.0f, 1.0f, 0.0f);
pVertex[11] = SRNormalVertex(-1.0f, 0.0f, 1.0f);
v0.x = pVertex[9].GetX();
v0.y = pVertex[9].GetY();
v0.z = pVertex[9].GetZ();
v1.x = pVertex[10].GetX();
v1.y = pVertex[10].GetY();
v1.z = pVertex[10].GetZ();
v2.x = pVertex[11].GetX();
v2.y = pVertex[11].GetY();
v2.z = pVertex[11].GetZ();
CalculateNormal(&vn, &v0, &v1, &v2);
pVertex[9].SetNormalXYZ(vn.x, vn.y, vn.z);
pVertex[10].SetNormalXYZ(vn.x, vn.y, vn.z);
pVertex[11].SetNormalXYZ(vn.x, vn.y, vn.z);
m_pVB->Unlock();
m_pD3Dev9->SetRenderState(D3DRS_LIGHTING, TRUE);
D3DMATERIAL9 mtrl;
mtrl.Ambient = SRColor::GetCommonColor(SRColor::CC_WHITE);
mtrl.Diffuse = SRColor::GetCommonColor(SRColor::CC_WHITE);
mtrl.Specular = SRColor::GetCommonColor(SRColor::CC_WHITE);
mtrl.Emissive = SRColor::GetCommonColor(SRColor::CC_BLACK);
mtrl.Power = 5.0f;
m_pD3Dev9->SetMaterial(&mtrl);
D3DLIGHT9 lgt;
ZeroMemory(&lgt, sizeof(lgt));
lgt.Type = D3DLIGHT_DIRECTIONAL;
lgt.Diffuse = SRColor::GetCommonColor(SRColor::CC_WHITE);
lgt.Specular = SRColor::GetCommonColor(SRColor::CC_WHITE) * 0.3f;
lgt.Ambient = SRColor::GetCommonColor(SRColor::CC_WHITE) * 0.6f;
lgt.Direction = D3DXVECTOR3(1.0f, 0.0f, 0.0f);
m_pD3Dev9->SetLight(0, &lgt);
m_pD3Dev9->LightEnable(0, TRUE);
m_pD3Dev9->SetRenderState(D3DRS_NORMALIZENORMALS, TRUE);
m_pD3Dev9->SetRenderState(D3DRS_SPECULARENABLE, TRUE);
D3DXVECTOR3 pos(0.0f, 1.0f, -3.0f);
Gfx_SetViewTransform(&pos);
Gfx_SetProjectionTransform();
return true;
}
void LitPyramid::OnEnvDestroy()
{
SSAFE_RELEASE(m_pVB);
}
void LitPyramid::OnDrawFrame()
{
SRRenderApp* pApp = SRRenderApp::GetInstancePtr();
static float s_fRotateY = 0.0f;
s_fRotateY += pApp->GetTimeDelta();
static float s_fRotateX = 0.0f;
s_fRotateX += pApp->GetTimeDelta() * 0.5f;
D3DXMATRIX roty;
D3DXMatrixRotationY(&roty, s_fRotateY);
D3DXMATRIX rotx;
D3DXMatrixRotationX(&rotx, s_fRotateX);
D3DXMATRIX rot = rotx * roty;
if(s_fRotateY > 6.28f)
{
s_fRotateY = 0.0f;
}
if(s_fRotateX > 6.28f)
{
s_fRotateX = 0.0f;
}
m_pD3Dev9->SetTransform(D3DTS_WORLD, &roty);
m_pD3Dev9->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);
m_pD3Dev9->BeginScene();
m_pD3Dev9->SetStreamSource(0, m_pVB, 0, sizeof(SRNormalVertex));
m_pD3Dev9->SetFVF(SRNormalVertex::FVF);
m_pD3Dev9->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 4);
m_pD3Dev9->EndScene();
m_pD3Dev9->Present(0, 0, 0, 0);
} | [
"[email protected]"
] | [
[
[
1,
198
]
]
] |
0e5baca75fdd2c54621542f6cf7b7bde1bdf4164 | fdebe3129bb47afc1924e45e1ed3c97ee9213ac4 | /GA-TSP/test.cpp | 3bbfaacce92afe022185cf0c23ee0c0d44e5e17d | [] | no_license | SYSU532/artificial-intelligence | 3604e07b3670555d65ac2d36dbbf458f69658a07 | e0847fb1d181415137580e1c3e529e2120ed09d4 | refs/heads/master | 2020-04-05T20:26:14.953000 | 2019-01-11T12:50:27 | 2019-01-11T12:50:27 | 157,179,948 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,044 | cpp | #include <node.h>
namespace demo{
using v8::FunctionCallbackInfo;
using v8::Isolate;
using v8::Local;
using v8::Object;
using v8::String;
using v8::Value;
using v8::Number;
// Method1 实现一个 输出"hello world ONE !" 的方法
void Method1(const FunctionCallbackInfo<Value>& args){
Isolate* isolate = args.GetIsolate();
args.GetReturnValue().Set(String::NewFromUtf8(isolate, "hello world ONE !"));
}
// Method2 实现一个 加一 的方法
void Method2(const FunctionCallbackInfo<Value>& args){
Isolate* isolate = args.GetIsolate();
Local<Number> value = Local<Number>::Cast(args[0]);
double num = value->NumberValue() + 1;
char buf[128] = {0};
sprintf(buf,"%f", num);
args.GetReturnValue().Set(String::NewFromUtf8(isolate, buf));
}
void init(Local<Object> exports){
NODE_SET_METHOD(exports, "hello1", Method1);
NODE_SET_METHOD(exports, "addOne", Method2);
}
NODE_MODULE(addon, init)
} | [
"[email protected]"
] | [
[
[
1,
36
]
]
] |
c0b9cd92c56f6f91ed9a7a6f7b5ae7a03a9d9b74 | 406b6f3e8355bcab9add96f3cff044823186fe37 | /src/Simulation/osg_2d_simulation/quad.cpp | 01c1fcc1ce18c295f1b29ec90b3b6adace8f46c2 | [] | no_license | Micalson/puppet | 96fd02893f871c6bbe0abff235bf2b09f14fe5d9 | d51ed9ec2f2e4bf65dc5081a9d89d271cece28b5 | refs/heads/master | 2022-03-28T22:43:13.863000 | 2019-12-26T13:52:00 | 2019-12-26T13:52:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,295 | cpp | #include "quad.h"
#include <osgWrapper\UtilCreator.h>
Quad::Quad()
{
m_node = new OSGWrapper::QuadAttributeUtilNode(1);
m_geometry = OSGWrapper::UtilCreator::CreateUnitQuad();
m_node->AddChild(m_geometry);
}
Quad::~Quad()
{
}
void Quad::SetOffset(const osg::Vec2f& offset)
{
m_offset = offset;
UpdateGeometry();
}
void Quad::SetSize(const osg::Vec2f& size)
{
m_size = size;
UpdateGeometry();
}
void Quad::SetRect(const osg::Vec2f& offset, const osg::Vec2f& size)
{
m_offset = offset;
m_size = size;
UpdateGeometry();
}
void Quad::UpdateGeometry()
{
osg::Vec2Array* coord_array = dynamic_cast<osg::Vec2Array*>(m_geometry->getVertexAttribArray(0));
if (coord_array)
{
coord_array->at(0) = m_offset;
coord_array->at(1) = m_offset + osg::Vec2f(m_size.x(), 0.0f);
coord_array->at(2) = m_offset + osg::Vec2f(m_size.x(), m_size.y());
coord_array->at(3) = m_offset + osg::Vec2f(0.0f, m_size.y());
coord_array->dirty();
}
}
OSGWrapper::QuadAttributeUtilNode* Quad::Generate()
{
return m_node;
}
OSGWrapper::UIQuad* Quad::HitTest(float x, float y)
{
OSGWrapper::UIQuad* q = OSGWrapper::UIQuad::HitTest(x, y);
if (q) return q;
if (x >= m_offset.x() && x <= m_offset.x() + m_size.x() &&
y >= m_offset.y() && y <= m_offset.y() + m_size.y())
return this;
return 0;
} | [
"[email protected]"
] | [
[
[
1,
62
]
]
] |
End of preview. Expand
in Dataset Viewer.
README.md exists but content is empty.
Use the Edit dataset card button to edit it.
- Downloads last month
- 24