blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 3 264 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 5 140 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 905
values | visit_date timestamp[us]date 2015-08-09 11:21:18 2023-09-06 10:45:07 | revision_date timestamp[us]date 1997-09-14 05:04:47 2023-09-17 19:19:19 | committer_date timestamp[us]date 1997-09-14 05:04:47 2023-09-06 06:22:19 | github_id int64 3.89k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 22
values | gha_event_created_at timestamp[us]date 2012-06-07 00:51:45 2023-09-14 21:58:39 ⌀ | gha_created_at timestamp[us]date 2008-03-27 23:40:48 2023-08-21 23:17:38 ⌀ | gha_language stringclasses 141
values | src_encoding stringclasses 34
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 3 10.4M | extension stringclasses 115
values | content stringlengths 3 10.4M | authors listlengths 1 1 | author_id stringlengths 0 158 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
284b54cbe4ba2d8d6ac669e2bb0513d300c91f30 | ed8e03335b5615059daed13aa93281a54445dbf7 | /src/DataStructure/BinarySearchTree/TreeNode.h | 25685410348166fa35bb02cafc3d20db3a891b8f | [] | no_license | option0417/learning-cpp | 87e6183f29de3562f6a22ff304cdd656ca7b4178 | aa17019a72c4192ad75de9fd8eab770f7480a4b3 | refs/heads/master | 2023-03-05T10:02:39.865169 | 2012-02-25T16:54:27 | 2012-02-25T16:54:27 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,284 | h | /*
* TreeNode.h
*
* Created on: Feb 8, 2012
* Author: option0417
*/
#ifndef TREENODE_H_
#define TREENODE_H_
#include <iostream>
namespace op {
template <typename T>
class TreeNode {
public:
TreeNode(const T&);
~TreeNode();
const T& getValue();
void setNext(TreeNode*);
void show();
private:
const T *val;
TreeNode *more;
TreeNode *less;
};
template <typename T>
TreeNode<T>::TreeNode(const T& val) {
this->val = &val;
more = 0;
less = 0;
}
template <typename T>
const T& TreeNode<T>::getValue() {
return *val;
}
template <typename T>
void TreeNode<T>::setNext(TreeNode* node) {
if (*val < node->getValue()) {
if (more) {
more->setNext(node);
} else {
more = node;
}
} else {
if (less) {
less->setNext(node);
} else {
less = node;
}
}
}
template <typename T>
void TreeNode<T>::show() {
try {
std::cout<<"Root :"<<*val<<std::endl;
if (less) {
std::cout<<"l :"<<less->getValue()<<std::endl;
less->show();
} else {
std::cout<<"l : Null"<<std::endl;
}
if (more) {
std::cout<<"m :"<<more->getValue()<<std::endl;
more->show();
} else {
std::cout<<"m : Null"<<std::endl;
}
} catch (int errCode) {
std::cout<<"ErrCode : "<<errCode<<std::endl;
}
}
} /* namespace op */
#endif /* TREENODE_H_ */
| [
"option0417@gmail.com"
] | option0417@gmail.com |
7d4ec5b5f1cb41fa1296d249dd52e6294481e23e | 1b8ae277ef7f39af15b6e0bff057c433dc44a109 | /src/mame/includes/decocass.h | e033b9a3ee19a766de5ea7e5a97f9ad728c62d39 | [] | no_license | ilitirit-za/ShmupMame-unofficial | 2ea58e7674df935c98e73d34ca888152b82c570d | 2ddd533fbaceac256cf0fbc2f918de1966280a22 | refs/heads/master | 2021-01-11T02:07:06.094952 | 2016-10-24T11:17:30 | 2016-10-24T11:17:30 | 70,804,668 | 3 | 0 | null | 2016-10-21T13:17:50 | 2016-10-13T12:35:08 | C | UTF-8 | C++ | false | false | 8,754 | h | #ifdef MAME_DEBUG
#define LOGLEVEL 5
#else
#define LOGLEVEL 0
#endif
#define LOG(n,x) do { if (LOGLEVEL >= n) logerror x; } while (0)
#include "machine/decocass_tape.h"
#define T1PROM 1
#define T1DIRECT 2
#define T1LATCH 4
#define T1LATCHINV 8
class decocass_state : public driver_device
{
public:
decocass_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_audiocpu(*this, "audiocpu"),
m_mcu(*this, "mcu"),
m_cassette(*this, "cassette"),
m_rambase(*this, "rambase"),
m_charram(*this, "charram"),
m_fgvideoram(*this, "fgvideoram"),
m_colorram(*this, "colorram"),
m_tileram(*this, "tileram"),
m_objectram(*this, "objectram"),
m_paletteram(*this, "paletteram")
{
m_type1_map = 0;
}
/* devices */
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_audiocpu;
required_device<cpu_device> m_mcu;
required_device<decocass_tape_device> m_cassette;
/* memory pointers */
required_shared_ptr<UINT8> m_rambase;
required_shared_ptr<UINT8> m_charram;
required_shared_ptr<UINT8> m_fgvideoram;
required_shared_ptr<UINT8> m_colorram;
UINT8 * m_bgvideoram; /* shares bits D0-3 with tileram! */
required_shared_ptr<UINT8> m_tileram;
required_shared_ptr<UINT8> m_objectram;
required_shared_ptr<UINT8> m_paletteram;
size_t m_bgvideoram_size;
/* video-related */
tilemap_t *m_fg_tilemap;
tilemap_t *m_bg_tilemap_l;
tilemap_t *m_bg_tilemap_r;
INT32 m_watchdog_count;
INT32 m_watchdog_flip;
INT32 m_color_missiles;
INT32 m_color_center_bot;
INT32 m_mode_set;
INT32 m_back_h_shift;
INT32 m_back_vl_shift;
INT32 m_back_vr_shift;
INT32 m_part_h_shift;
INT32 m_part_v_shift;
INT32 m_center_h_shift_space;
INT32 m_center_v_shift;
rectangle m_bg_tilemap_l_clip;
rectangle m_bg_tilemap_r_clip;
/* sound-related */
UINT8 m_sound_ack; /* sound latches, ACK status bits and NMI timer */
UINT8 m_audio_nmi_enabled;
UINT8 m_audio_nmi_state;
/* misc */
INT32 m_firsttime;
UINT8 m_latch1;
UINT8 m_decocass_reset;
INT32 m_de0091_enable; /* DE-0091xx daughter board enable */
UINT8 m_quadrature_decoder[4]; /* four inputs from the quadrature decoder (H1, V1, H2, V2) */
int m_showmsg; // for debugging purposes
/* i8041 */
UINT8 m_i8041_p1;
UINT8 m_i8041_p2;
int m_i8041_p1_write_latch;
int m_i8041_p1_read_latch;
int m_i8041_p2_write_latch;
int m_i8041_p2_read_latch;
/* dongles-related */
read8_delegate m_dongle_r;
write8_delegate m_dongle_w;
/* dongle type #1 */
UINT32 m_type1_inmap;
UINT32 m_type1_outmap;
/* dongle type #2: status of the latches */
INT32 m_type2_d2_latch; /* latched 8041-STATUS D2 value */
INT32 m_type2_xx_latch; /* latched value (D7-4 == 0xc0) ? 1 : 0 */
INT32 m_type2_promaddr; /* latched PROM address A0-A7 */
/* dongle type #3: status and patches */
INT32 m_type3_ctrs; /* 12 bit counter stage */
INT32 m_type3_d0_latch; /* latched 8041-D0 value */
INT32 m_type3_pal_19; /* latched 1 for PAL input pin-19 */
INT32 m_type3_swap;
/* dongle type #4: status */
INT32 m_type4_ctrs; /* latched PROM address (E5x0 LSB, E5x1 MSB) */
INT32 m_type4_latch; /* latched enable PROM (1100xxxx written to E5x1) */
/* dongle type #5: status */
INT32 m_type5_latch; /* latched enable PROM (1100xxxx written to E5x1) */
/* DS Telejan */
UINT8 m_mux_data;
DECLARE_DRIVER_INIT(decocass);
DECLARE_DRIVER_INIT(decocrom);
DECLARE_DRIVER_INIT(cdsteljn);
TILEMAP_MAPPER_MEMBER(fgvideoram_scan_cols);
TILEMAP_MAPPER_MEMBER(bgvideoram_scan_cols);
TILE_GET_INFO_MEMBER(get_bg_l_tile_info);
TILE_GET_INFO_MEMBER(get_bg_r_tile_info);
TILE_GET_INFO_MEMBER(get_fg_tile_info);
virtual void machine_start();
virtual void machine_reset();
virtual void video_start();
virtual void palette_init();
DECLARE_MACHINE_RESET(ctsttape);
DECLARE_MACHINE_RESET(cprogolfj);
DECLARE_MACHINE_RESET(cdsteljn);
DECLARE_MACHINE_RESET(cfishing);
DECLARE_MACHINE_RESET(chwy);
DECLARE_MACHINE_RESET(cterrani);
DECLARE_MACHINE_RESET(castfant);
DECLARE_MACHINE_RESET(csuperas);
DECLARE_MACHINE_RESET(clocknch);
DECLARE_MACHINE_RESET(cprogolf);
DECLARE_MACHINE_RESET(cluckypo);
DECLARE_MACHINE_RESET(ctisland);
DECLARE_MACHINE_RESET(cexplore);
DECLARE_MACHINE_RESET(cdiscon1);
DECLARE_MACHINE_RESET(ctornado);
DECLARE_MACHINE_RESET(cmissnx);
DECLARE_MACHINE_RESET(cptennis);
DECLARE_MACHINE_RESET(cbtime);
DECLARE_MACHINE_RESET(cburnrub);
DECLARE_MACHINE_RESET(cgraplop);
DECLARE_MACHINE_RESET(cgraplop2);
DECLARE_MACHINE_RESET(clapapa);
DECLARE_MACHINE_RESET(cskater);
DECLARE_MACHINE_RESET(cprobowl);
DECLARE_MACHINE_RESET(cnightst);
DECLARE_MACHINE_RESET(cpsoccer);
DECLARE_MACHINE_RESET(csdtenis);
DECLARE_MACHINE_RESET(czeroize);
DECLARE_MACHINE_RESET(cppicf);
DECLARE_MACHINE_RESET(cfghtice);
DECLARE_MACHINE_RESET(type4);
DECLARE_MACHINE_RESET(cbdash);
DECLARE_MACHINE_RESET(cflyball);
DECLARE_MACHINE_RESET(cmanhat);
UINT32 screen_update_decocass(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
DECLARE_WRITE8_MEMBER(decocass_coin_counter_w);
DECLARE_WRITE8_MEMBER(decocass_sound_command_w);
DECLARE_READ8_MEMBER( decocass_sound_command_main_r );
DECLARE_READ8_MEMBER(decocass_sound_data_r);
DECLARE_READ8_MEMBER(decocass_sound_ack_r);
DECLARE_WRITE8_MEMBER(decocass_sound_data_w);
DECLARE_READ8_MEMBER(decocass_sound_command_r);
DECLARE_WRITE8_MEMBER(decocass_sound_nmi_enable_w);
DECLARE_READ8_MEMBER(decocass_sound_nmi_enable_r);
DECLARE_READ8_MEMBER(decocass_sound_data_ack_reset_r);
DECLARE_WRITE8_MEMBER(decocass_sound_data_ack_reset_w);
DECLARE_WRITE8_MEMBER(decocass_nmi_reset_w);
DECLARE_WRITE8_MEMBER(decocass_quadrature_decoder_reset_w);
DECLARE_WRITE8_MEMBER(decocass_adc_w);
DECLARE_READ8_MEMBER(decocass_input_r);
DECLARE_WRITE8_MEMBER(decocass_reset_w);
DECLARE_READ8_MEMBER(decocass_e5xx_r);
DECLARE_WRITE8_MEMBER(decocass_e5xx_w);
DECLARE_WRITE8_MEMBER(decocass_de0091_w);
DECLARE_WRITE8_MEMBER(decocass_e900_w);
DECLARE_WRITE8_MEMBER(i8041_p1_w);
DECLARE_READ8_MEMBER(i8041_p1_r);
DECLARE_WRITE8_MEMBER(i8041_p2_w);
DECLARE_READ8_MEMBER(i8041_p2_r);
void decocass_machine_state_save_init();
DECLARE_WRITE8_MEMBER(decocass_paletteram_w);
DECLARE_WRITE8_MEMBER(decocass_charram_w);
DECLARE_WRITE8_MEMBER(decocass_fgvideoram_w);
DECLARE_WRITE8_MEMBER(decocass_colorram_w);
DECLARE_WRITE8_MEMBER(decocass_bgvideoram_w);
DECLARE_WRITE8_MEMBER(decocass_tileram_w);
DECLARE_WRITE8_MEMBER(decocass_objectram_w);
DECLARE_WRITE8_MEMBER(decocass_watchdog_count_w);
DECLARE_WRITE8_MEMBER(decocass_watchdog_flip_w);
DECLARE_WRITE8_MEMBER(decocass_color_missiles_w);
DECLARE_WRITE8_MEMBER(decocass_mode_set_w);
DECLARE_WRITE8_MEMBER(decocass_color_center_bot_w);
DECLARE_WRITE8_MEMBER(decocass_back_h_shift_w);
DECLARE_WRITE8_MEMBER(decocass_back_vl_shift_w);
DECLARE_WRITE8_MEMBER(decocass_back_vr_shift_w);
DECLARE_WRITE8_MEMBER(decocass_part_h_shift_w);
DECLARE_WRITE8_MEMBER(decocass_part_v_shift_w);
DECLARE_WRITE8_MEMBER(decocass_center_h_shift_space_w);
DECLARE_WRITE8_MEMBER(decocass_center_v_shift_w);
void decocass_video_state_save_init();
DECLARE_WRITE8_MEMBER(mirrorvideoram_w);
DECLARE_WRITE8_MEMBER(mirrorcolorram_w);
DECLARE_READ8_MEMBER(mirrorvideoram_r);
DECLARE_READ8_MEMBER(mirrorcolorram_r);
DECLARE_READ8_MEMBER(cdsteljn_input_r);
DECLARE_WRITE8_MEMBER(cdsteljn_mux_w);
TIMER_DEVICE_CALLBACK_MEMBER(decocass_audio_nmi_gen);
private:
DECLARE_READ8_MEMBER(decocass_type1_r);
DECLARE_READ8_MEMBER(decocass_type2_r);
DECLARE_WRITE8_MEMBER(decocass_type2_w);
DECLARE_READ8_MEMBER(decocass_type3_r);
DECLARE_WRITE8_MEMBER(decocass_type3_w);
DECLARE_READ8_MEMBER(decocass_type4_r);
DECLARE_WRITE8_MEMBER(decocass_type4_w);
DECLARE_READ8_MEMBER(decocass_type5_r);
DECLARE_WRITE8_MEMBER(decocass_type5_w);
DECLARE_READ8_MEMBER(decocass_nodong_r);
UINT8* m_type1_map;
void draw_edge(bitmap_ind16 &bitmap, const rectangle &cliprect, int which, bool opaque);
void draw_object(bitmap_ind16 &bitmap, const rectangle &cliprect);
void draw_center(bitmap_ind16 &bitmap, const rectangle &cliprect);
void mark_bg_tile_dirty(offs_t offset);
void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int color,
int sprite_y_adjust, int sprite_y_adjust_flip_screen,
UINT8 *sprite_ram, int interleave);
void draw_missiles(bitmap_ind16 &bitmap, const rectangle &cliprect,
int missile_y_adjust, int missile_y_adjust_flip_screen,
UINT8 *missile_ram, int interleave);
};
| [
"ilitirit@gmail.com"
] | ilitirit@gmail.com |
ff84cee47cc7fd663ef1762f05482b32ef304915 | 0161c2f3a3f591f713618fa7c6c7dac3d69bb29b | /control/controller_factory.h | 278328dddb8bdfc6700fa94bde6ed882dbde79f9 | [] | no_license | liudong206/Apollo_control_algorithm | 7ddcc98ca9dc5aa0bef1619c3cb8e1d41356d68f | 038746942fc07ce679ce844cebe95514ac745c80 | refs/heads/main | 2023-08-27T10:38:48.216266 | 2021-10-30T07:20:36 | 2021-10-30T07:20:36 | 422,808,145 | 5 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 842 | h | #ifndef CONTROLLER_FACTORY_H
#define CONTROLLER_FACTORY_H
#include <memory>
#include "control/controller.h"
/**
* @class LatControllerType
* @brief LatControllerType is a enum class used to specify a Controller instance.
*/
enum class ControllerType{ MPCController,
LQRController,
PPController,
PIDController,
OTHER };
class ControllerFactory{
public:
ControllerFactory() = delete;
/**
* @brief Generate a controller instance.
* @param LatControllerType The specific type of controller
* @return A unique pointer pointing to the controller instance.
*/
static std::unique_ptr<control::Controller> CreateInstance(
const ControllerType& controller_type);
};
#endif // CONTROLLER_FACTORY_H
| [
"1072169613@qq.com"
] | 1072169613@qq.com |
6fa9dffe61ea13ea29f56810351adaba2cd235c3 | 8c3d93108c02b513624d1088c4b3774d1989ccf7 | /src/sqlRequire/sqlRequire.cpp | 6c9d7db85d5f4aae62f00e12976d24b99be38232 | [] | no_license | haost74/skaner | 9619f77dc05808ac2ff30997d7d28d1e763283be | 71edd90906f24b10a1757918072ccdc6305d1f7b | refs/heads/master | 2023-01-24T00:49:41.261828 | 2020-12-09T10:16:30 | 2020-12-09T10:16:30 | 319,917,029 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,101 | cpp | #include "sqlRequire.h"
#include <sys/stat.h>
#include <unistd.h>
#include <string>
#include <fstream>
#include <iostream>
sql::sql(string name)
{
nameDb = name;
}
sql::~sql()
{
std::cout << "end" << '\n';
}
bool sql::CreateDb()
{
rc = sqlite3_open(nameDb.c_str(), &db);
return rc;
}
bool sql::CreateTable(string strSql)
{
if(strSql.length() ==0) return 0;
int res{0};
if(rc == SQLITE_OK)
{
return sqlite3_exec(db, strSql.c_str(), NULL, 0, &messageError);
}
return 0;
}
bool sql::Require(std::string strSql)
{
if(rc != SQLITE_OK) return 0;
try
{
return sqlite3_exec(db, strSql.c_str(), callback, 0, &messageError);
}
catch(const std::exception& e)
{
std::cerr << e.what() << '\n';
}
return 0;
}
void sql::CloseDb()
{
try
{
if(db != nullptr)
{
sqlite3_close(db);
}
if(messageError != nullptr)
{
delete[] messageError;
}
}
catch(const std::exception& e)
{
std::cerr << e.what() << '\n';
}
}
| [
"Aleksey.V.Gribkov@rt.ru"
] | Aleksey.V.Gribkov@rt.ru |
54325275d6c27bd61a4d008c173cc1adc9b07288 | 4b6fe0d8a552fe76a8f42ad25960a6cea9a41406 | /VSOptics/VSOMirror.hpp | 4bbae4d4dce2684e61432164c46d32ae5da57b44 | [
"BSD-3-Clause"
] | permissive | sfegan/ChiLA | 769aef0486b94b5c3281273946c74b471a6a7ef2 | 916bdd95348c2df2ecc736511d5f5b2bfb4a831e | refs/heads/main | 2021-07-30T16:24:06.076214 | 2016-02-10T08:10:02 | 2016-02-10T08:10:02 | 51,363,796 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,085 | hpp | //-*-mode:c++; mode:font-lock;-*-
/*! \file VSOMirror.hpp
Mirror class header file
\author Stephen Fegan \n
UCLA \n
sfegan@astro.ucla.edu \n
\author Maciej Nicewicz \n
UCLA \n
nicewicz@physics.ucla.edu \n
\date 11/30/2004
\version 0.2
\note
*/
#ifndef VSOMIRROR_HPP
#define VSOMIRROR_HPP
#include <iostream>
#include <Vec3D.hpp>
#include <Particle.hpp>
#include <VSDatabase.hpp>
namespace VERITAS
{
class VSOTelescope;
//! VSOMirror class for telescope, stores information about individual mirror
class VSOMirror
{
public:
// ************************************************************************
// Constructor and Destructor
// ************************************************************************
VSOMirror();
VSOMirror(const VSOTelescope* T, unsigned ID, unsigned MHID, bool REM,
const Physics::Vec3D& P, const Physics::Vec3D& A,
double FL, double SS, double DF);
virtual ~VSOMirror();
// ************************************************************************
// Write to and Read from the database
// ************************************************************************
static VSDBStatement* createInsertQuery(VSDatabase* db);
static VSDBStatement* createSelectQuery(VSDatabase* db);
void writeToDatabase(VSDBStatement* stmt, uint32_t optics_id) const;
static VSOMirror* createFromDatabaseRow(VSDBStatement* stmt,
const VSOTelescope* T);
static void createMirrorTable(VSDatabase* db);
// ************************************************************************
// Coordinate transformations
// ************************************************************************
void reflectorToMirror(Physics::Vec3D& v) const; //!< Transform vector from reflector to mirror
void mirrorToReflector(Physics::Vec3D& v) const ; //!< Transform vector from mirror to reflector
void reflectorToMirror(Physics::Particle& p) const; //!< Transform particle reflector to mirror
void mirrorToReflector(Physics::Particle& p) const; //!< Transform particle mirror to reflector
// ************************************************************************
// Dump
// ************************************************************************
void dumpShort(std::ostream& stream) const;
void dump(std::ostream& stream, unsigned l=0) const;
static VSOMirror* createFromShortDump(std::istream& stream,
const VSOTelescope* T);
// ************************************************************************
// Accessors
// ************************************************************************
const VSOTelescope* telescope() const { return fTelescope; }
unsigned id() const { return fID; }
unsigned hexID() const { return fHexID; }
bool removed() const { return fRemoved; }
const Physics::Vec3D& pos() const { return fPos; }
const Physics::Vec3D& align() const { return fAlign; }
double focalLength() const { return fFocalLength; }
double spotSize() const { return fSpotSize; }
double degradingFactor() const { return fDegradingFactor; }
private:
const VSOTelescope* fTelescope; //!< Telescope
unsigned fID; //!< Sequential ID (starting at 0)
unsigned fHexID; //!< Hex index on reflector
bool fRemoved; //!< Mirror is removed from scope
Physics::Vec3D fPos; //!< Position
Physics::Vec3D fAlign; //!< Alignment angles
double fFocalLength; //!< Focal length
double fSpotSize; //!< Spot size
double fDegradingFactor; //!< Degrading factor of mirror
Physics::Vec3D fRotationVector;
void calculateRotationVector();
};
}
#endif // VSOMIRROR_H
| [
"sfegan@gmail.com"
] | sfegan@gmail.com |
f29d44cd01d4c1df4117557a684b1eb725109348 | 9746f26da7796ceb6d09634a890586b89ed4bc30 | /OpenGL_Demo/OpenGL_Demo/Classes/GameObject.h | 7e3f613a21ea6cb365890b4617c629a4cdad8ed1 | [] | no_license | xiaokimi/OpenGL_Learn | 4e3dadb8ca54d3a95ac320e74c00306bf3d926fd | 768e458020c607f018c7fb4cf0445fb4c7453ec8 | refs/heads/master | 2020-12-02T22:42:32.925646 | 2017-09-14T07:56:07 | 2017-09-14T07:56:07 | 96,168,534 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 559 | h | #ifndef __GAME_OBJECT_H__
#define __GAME_OBJECT_H__
#include <gl/glew.h>
#include <glm/glm.hpp>
#include "Texture.h"
#include "SpriteRenderer.h"
class GameObject
{
public:
GameObject();
GameObject(glm::vec2 pos, glm::vec2 size, Texture2D sprite, glm::vec3 color = glm::vec3(1.0f), glm::vec2 velocity = glm::vec2(0.0f));
virtual void draw(SpriteRenderer &renderer);
public:
glm::vec2 _position;
glm::vec2 _size;
glm::vec2 _velocity;
glm::vec3 _color;
GLfloat _rotation;
GLboolean _isSolid;
GLboolean _destroyed;
Texture2D _sprite;
};
#endif | [
"515360208@qq.com"
] | 515360208@qq.com |
285ae8059f2d9b50a8e1508b736b7d92b8fdc612 | 508ca425a965615f67af8fc4f731fb3a29f4665a | /OldStuff/TIMUS/AC/1261.cpp | 7636d014cfde52525efc4942a3465909335a070a | [] | no_license | knakul853/ProgrammingContests | 2a1b216dfc20ef81fb666267d78be355400549e9 | 3366b6a4447dd4df117217734880199e006db5b4 | refs/heads/master | 2020-04-14T23:37:02.641774 | 2015-09-06T09:49:12 | 2015-09-06T09:49:12 | 164,209,133 | 1 | 0 | null | 2019-01-05T11:34:11 | 2019-01-05T11:34:10 | null | UTF-8 | C++ | false | false | 640 | cpp | /*
Alfonso2 Peterssen(mukel)
Team: UH++
Timus Online Judge
1261. Tips
*/
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long int64;
const int MAXP = 16;
int64 N, A, B;
int64 pow3[MAXP];
int main()
{
pow3[0] = 1;
for (int i = 1; i < MAXP; i++)
pow3[i] = pow3[i - 1] * 3;
cin >> N;
int pos = 0;
while (N > 0)
{
if (N % 3 == 1)
A += pow3[pos];
else
if (N % 3 == 2)
{
N += 3;
B += pow3[pos];
}
pos++;
N /= 3;
}
if (B == 0)
{
A += pow3[MAXP - 1];
B += pow3[MAXP - 1];
}
cout << A << " " << B << endl;
return 0;
}
| [
"a2peterssen@gmail.com"
] | a2peterssen@gmail.com |
9c3f44febe29693d2eef7b0f5c31fbd412d7b5aa | 7a41a89ba43de9de8f70aea6933d095bb40e47fe | /modio/modio/detail/entities/ModioImage.h | d6aaec88fa3c2528e58ce243547c512a6b6415c2 | [
"BSL-1.0",
"MIT"
] | permissive | nyzeairs/modio-sdk | cf2a711f887643430db7dbd5c89ebdea69f1fee3 | 6ab4e0e6e0407812889186e181496294cd0295f9 | refs/heads/main | 2023-08-14T20:15:22.216462 | 2021-10-01T02:20:30 | 2021-10-01T02:20:30 | 417,957,561 | 1 | 0 | NOASSERTION | 2021-10-16T21:54:55 | 2021-10-16T21:54:55 | null | UTF-8 | C++ | false | false | 1,630 | h | /*
* Copyright (C) 2021 mod.io Pty Ltd. <https://mod.io>
*
* This file is part of the mod.io SDK.
*
* Distributed under the MIT License. (See accompanying file LICENSE or
* view online at <https://github.com/modio/modio-sdk/blob/main/LICENSE>)
*
*/
#pragma once
#include "modio/core/ModioCoreTypes.h"
#include "modio/detail/ModioJsonHelpers.h"
#include <string>
namespace Modio
{
namespace Detail
{
struct Image
{
/** Image filename including extension. */
std::string Filename;
/** URL to the full-sized image. */
std::string Original;
/** URL to the image thumbnail (320x180) */
std::string Thumb320x180;
};
static void from_json(const nlohmann::json& Json, Image& Image)
{
Detail::ParseSafe(Json, Image.Filename, "filename");
Detail::ParseSafe(Json, Image.Original, "original");
Detail::ParseSafe(Json, Image.Thumb320x180, "thumb_320x180");
}
static const std::string& GetImmageURL(const Image& Image, Modio::GallerySize Size)
{
switch (Size)
{
case Modio::GallerySize::Original:
return Image.Original;
case Modio::GallerySize::Thumb320:
return Image.Thumb320x180;
}
// Should never reach this
assert(false);
static std::string NoResult("");
return NoResult;
}
inline std::string ToString(Modio::GallerySize Size)
{
switch (Size)
{
case Modio::GallerySize::Original:
return "Original";
case Modio::GallerySize::Thumb320:
return "Thumb320";
}
assert(false && "Invalid value to ToString(Modio::AvatarSize)");
return "Unknown";
}
} // namespace Detail
} // namespace Modio
| [
"swhittle@crypticwarrior.net"
] | swhittle@crypticwarrior.net |
d55c3e3d2bf2536033f795e5162cf78b2c8b6dc2 | 52768e01951726ebcac03022929d244d9b68a945 | /ME20150525/SVGlib/curve.cpp | 114b626a85bbf9d8f62bff4934e35f84c55739c8 | [] | no_license | Tjuly/ME | 2cb24d7070aca2c4a82cbed9b0148da1e7019e0d | 8eadb7e85f3177be872af6172be9fac2cb1efac3 | refs/heads/master | 2021-01-10T15:17:14.573588 | 2015-06-01T08:33:55 | 2015-06-01T08:33:55 | 36,609,184 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,550 | cpp | /* private part of the path and curve data structures */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "potracelib.h"
#include "lists.h"
#include "curve.h"
#define SAFE_MALLOC(var, n, typ) \
if ((var = (typ *)malloc((n)*sizeof(typ))) == NULL) goto malloc_error
/* ---------------------------------------------------------------------- */
/* allocate and free path objects */
path_t *path_new(void) {
path_t *p = NULL;
privpath_t *priv = NULL;
SAFE_MALLOC(p, 1, path_t);
memset(p, 0, sizeof(path_t));
SAFE_MALLOC(priv, 1, privpath_t);
memset(priv, 0, sizeof(privpath_t));
p->priv = priv;
return p;
malloc_error:
free(p);
free(priv);
return NULL;
}
/* free the members of the given curve structure. Leave errno unchanged. */
static void privcurve_free_members(privcurve_t *curve) {
free(curve->tag);
free(curve->c);
free(curve->vertex);
free(curve->alpha);
free(curve->alpha0);
free(curve->beta);
}
/* free a path. Leave errno untouched. */
void path_free(path_t *p) {
if (p) {
if (p->priv) {
free(p->priv->pt);
free(p->priv->lon);
free(p->priv->sums);
free(p->priv->po);
privcurve_free_members(&p->priv->curve);
privcurve_free_members(&p->priv->ocurve);
}
free(p->priv);
/* do not free p->fcurve ! */
}
free(p);
}
/* free a pathlist, leaving errno untouched. */
void pathlist_free(path_t *plist) {
path_t *p;
list_forall_unlink(p, plist) {
path_free(p);
}
}
/* ---------------------------------------------------------------------- */
/* initialize and finalize curve structures */
typedef dpoint_t dpoint3_t[3];
/* initialize the members of the given curve structure to size m.
Return 0 on success, 1 on error with errno set. */
int privcurve_init(privcurve_t *curve, int n) {
memset(curve, 0, sizeof(privcurve_t));
curve->n = n;
SAFE_MALLOC(curve->tag, n, int);
SAFE_MALLOC(curve->c, n, dpoint3_t);
SAFE_MALLOC(curve->vertex, n, dpoint_t);
SAFE_MALLOC(curve->alpha, n, double);
SAFE_MALLOC(curve->alpha0, n, double);
SAFE_MALLOC(curve->beta, n, double);
return 0;
malloc_error:
free(curve->tag);
free(curve->c);
free(curve->vertex);
free(curve->alpha);
free(curve->alpha0);
free(curve->beta);
return 1;
}
/* copy private to public curve structure */
void privcurve_to_curve(privcurve_t *pc, potrace_curve_t *c) {
c->n = pc->n;
c->tag = pc->tag;
c->c = pc->c;
}
| [
"348854308@qq.com"
] | 348854308@qq.com |
235f2dbb38929271e3fd5944c2b3f9dd79d7e26c | 7434253608fb27a5840efc74306264e7081dc4bc | /TD2/Sebastien_Yanis/Exercice4.cpp | bd21df3a0a6038faca24926891a9d23257243b5c | [] | no_license | seb9465/inf1005C | ed29f13d8889cdd7b8f41e507ba28a6642301f59 | 7bf8bfb735b61fb44cbdb2240f903fefe86be96d | refs/heads/master | 2021-01-20T14:53:35.371752 | 2017-11-08T16:48:53 | 2017-11-08T16:48:53 | 90,684,823 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 1,321 | cpp | /**
* Valeur approchée de sin(x).
* \fichier Exercice4.cpp
* \auteur Sebastien Cadorette & Yanis Bouhraoua
* \date 25 septembre 2014
* Créé le 24 septembre 2014
*/
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
//Initialisation des variables
double valeur = 0.0;
double sinusValeur = 0.0;
double premierTerme = 0.0;
double deuxiemeTerme = 0.0;
double troisiemeTerme = 0.0;
double sommeTroisTermes = 0.0;
//Génération d'un nombre aléatoire entre 0 et 1
srand(time(nullptr));
valeur = (double)rand() / RAND_MAX;
cout << "Valeur du nombre aleatoire : " << valeur << endl;
//Calcul de valeur sinus avec le sinus
sinusValeur = sin(valeur);
cout << "Valeur du sinus du nombre aleatoire : " << sinusValeur << endl;
//Calcul de la valeur sinus avec la série
premierTerme = valeur;
deuxiemeTerme = pow(valeur, 3) / (3 * 2 * 1); //Structure de répétition pour calculer factorielle
troisiemeTerme = pow(valeur, 5) / (5 * 4 * 3 * 2 * 1); //Structure de répétition pour calculer factorielle
sommeTroisTermes = premierTerme - deuxiemeTerme + troisiemeTerme;
cout << "Somme des trois premiers termes de la serie : " << sommeTroisTermes << endl;
cout << "Difference entre les deux valeurs : " << sommeTroisTermes - sinusValeur << endl;
return 0;
} | [
"Sébastien Cadorette"
] | Sébastien Cadorette |
236146731ba575e52d4166bf8bf3aa3071a52165 | c76adc973e5251452e1beb3de7776d0a2b709fce | /submissions/c3.s838.ncu100502203.Group1C.cpp.0.proC.cpp | b6bf5370beab1fa2b3f4fdd7a3244edaef59380e | [] | no_license | ncuoolab/domjudge | 779a167f695f45a6a33437996ec5ad0f9d01c563 | bda18c69d418c829ff653f9183b3244520139f8a | refs/heads/master | 2020-05-19T08:10:39.974107 | 2015-03-10T19:35:03 | 2015-03-10T19:43:26 | 31,972,137 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,714 | cpp | #include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;
bool checkID(char c)
{
if(c>='a' && c<='z')
return true;
if(c>='A' && c<='Z')
return true;
if(c=='_')
return true;
return false;
}
bool checkNUM(char c)
{
if(!(c>='0' && c<='9'))
return false;
return true;
}
bool checkNull(char c)
{
if(c==')')
return true;
return false;
}
int main()
{
bool fail = false;
char input[200],inputS[200], id[200], para[200];
cin.getline(input,200);
int count=0, length=0;
while(input[count++] != '\0')
length++;
count=0;
for(int i=0; i<length; i++)
{
if(input[i] != ' ')
inputS[count++] = input[i];
}
count=0;
int icount=0;
while(inputS[count] != '(')
{
if(inputS[count] == '\0')
{
fail = true;
break;
}
if(checkID(inputS[count]))
id[icount] = inputS[count];
else
fail = true;
icount++;
count++;
}
id[icount] = '\0';
count++;
int pcount=0;
int optID = 0;
if(checkID(inputS[count]))
{
optID = 0;
while(inputS[count] != ')')
{
if(inputS[count] == '\0')
{
fail = true;
break;
}
if(checkID(inputS[count]))
para[pcount] = inputS[count];
else
fail = true;
pcount++;
count++;
}
}
else if(checkNUM(inputS[count]))
{
optID = 1;
while(inputS[count] != ')')
{
if(inputS[count] == ' ')
{
count++;
continue;
}
if(inputS[count] == '\0')
{
fail = true;
break;
}
if(checkNUM(inputS[count]))
para[pcount] = inputS[count];
else
fail = true;
pcount++;
count++;
}
}
else if(checkNull(inputS[count]))
{
optID = 2;
count++;
}
else
fail = true;
para[pcount] = '\0';
if(fail)
cout << "invalid input" << endl;
else
{
cout << "id " << id << endl;
cout << "lparenthesis (" << endl;
if(optID==0)
cout << "id " << para << endl;
else if(optID==1)
cout << "inum " << para << endl;
cout << "rparenthesis )" << endl;
}
return 0;
}
| [
"fntsrlike@gmail.com"
] | fntsrlike@gmail.com |
de015fdd17a09a2669ec094e91df41f757fa59e4 | 7285b873c7db671dd02e9a9172b8e8595b328b36 | /edgedetection.cpp | 48b059d8b2522d0d63bc6ca5e1cf4ee35405251b | [] | no_license | RamMahindra/OpenCV | 0d7f880d18503de845fe40fa75df8b6768794759 | f38bc1cb40cdd2f5ff9df6135b30fb2df9687390 | refs/heads/master | 2021-01-20T06:19:39.369979 | 2015-09-16T12:50:07 | 2015-09-16T12:50:07 | 41,297,774 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 686 | cpp | #include "opencv2/opencv.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/core/core.hpp"
#include <iostream>
#include <stdlib.h>
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/videostab/videostab.hpp"
using namespace cv;
using namespace std;
int main( )
{
Mat src1;
src1 = imread("lena.jpg", CV_LOAD_IMAGE_COLOR);
namedWindow( "Original image", CV_WINDOW_AUTOSIZE );
imshow( "Original image", src1 );
Mat gray, edge, draw;
cvtColor(src1, gray, CV_BGR2GRAY);
Canny( gray, edge, 50, 150, 3);
edge.convertTo(draw, CV_8U);
namedWindow("image", CV_WINDOW_AUTOSIZE);
imshow("image", draw);
waitKey(0);
return 0;
}
| [
"rammahindra90@gmail.com"
] | rammahindra90@gmail.com |
a1099aa1f0fcf86c9598f11a8172a811e992f5aa | 06d1347c088951549328d0aa6a4cf5a3d32e58fd | /crash的数字表格.cpp | 6a78bd67853ff5e8f0af019b0554f460c309e5a9 | [] | no_license | jesseliu612/oi-code | 885991a926d3f261f8ad4cfabc51e34a51dc2f6e | 617209f1dd50d3742074c643b0a2d1b774eba0dc | refs/heads/master | 2021-05-07T23:56:52.246851 | 2017-10-20T12:20:26 | 2017-10-20T12:20:26 | 107,673,474 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,584 | cpp | #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <ctime>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
const int inf = 2147483640;
typedef long long ll;
ll geti(){
char ch=getchar();while((ch<'0' || ch>'9')&&ch!='-')ch=getchar();
ll ret=0,k=1;
if(ch=='-')k=-1,ch=getchar();
while(ch>='0' && ch<='9')ret=ret*10+ch-'0',ch=getchar();
return ret*k;
}
const int maxn = 1e7+100;
const int mo = 20101009;
int n,m;
int prime[maxn],vis[maxn],fx[maxn],pre[maxn],s[maxn],sum[maxn],pnt=0;
void sieve(){
fx[1]=1;
for(int i=2;i<=n;i++){
if(!vis[i]){
prime[++pnt]=i;fx[i]=1-i;
}
for(int j=1;j<=pnt && i*prime[j]<=n;j++){
vis[i*prime[j]]=true;
if(i%prime[j]==0){
fx[i*prime[j]]=fx[i];
break;
}
else{
ll cur=(ll)fx[i]*fx[prime[j]];cur%=mo;
fx[i*prime[j]]=cur;
}
}
}
for(int i=1;i<=n;i++)pre[i]=(pre[i-1]+fx[i])%mo;
}
int main(){
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
n=geti();m=geti();
sieve();
if(n>m)swap(n,m);
ll ans=0;
for(int i=1;i<=m;i++)sum[i]=sum[i-1]+i,sum[i]%=mo;
for(int Q=1;Q<=n;Q++){
ll cur=Q;
cur*=sum[n/Q];cur%=mo;
cur*=sum[m/Q];cur%=mo;
cur*=fx[Q];cur%=mo;
ans+=cur;ans%=mo;
}
cout << (ans%mo+mo)%mo;
fclose(stdin);
fclose(stdout);
return 0;
}
| [
"jesseliu612@126.com"
] | jesseliu612@126.com |
24ca6cf5927f81a735bed4a0ac94fb3c30e53f42 | 82dc3cc4c97c05e384812cc9aa07938e2dbfe24b | /toolbox/src-mirror/bessel/bessel.cpp | 8327fe0689b5d40a303dd4fbbdb709939e11b599 | [
"BSD-3-Clause"
] | permissive | samanseifi/Tahoe | ab40da0f8d952491943924034fa73ee5ecb2fecd | 542de50ba43645f19ce4b106ac8118c4333a3f25 | refs/heads/master | 2020-04-05T20:24:36.487197 | 2017-12-02T17:09:11 | 2017-12-02T17:24:23 | 38,074,546 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 47 | cpp | /home/saman/Tahoe/toolbox/src/bessel/bessel.cpp | [
"saman@bu.(none)"
] | saman@bu.(none) |
315c3e5a6cd839bd704188fe4dd7873e3e5d6672 | 2305da7d3158d4e23a401e2e505157746b94ea46 | /XcodeCPPTest/STL/Container/STLContainer.cpp | eacc60b469c534d3f5397f43b4e4951e5d6e23f8 | [] | no_license | JackeryShh/CPPlayGround | 8b26884456bc9269a7b9f7c378b96893fe41daff | 53dc7580c8070019d2bb4a8de283cbd09b5a61a1 | refs/heads/master | 2020-03-12T08:50:23.810861 | 2018-08-06T02:42:49 | 2018-08-06T02:42:49 | 130,537,303 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 164 | cpp | //
// STLContainer.cpp
// XcodeCPPTest
//
// Created by MOMO on 2018/8/6.
// Copyright © 2018年 jackery. All rights reserved.
//
#include "STLContainer.hpp"
| [
"shi.haihua@immomo.com"
] | shi.haihua@immomo.com |
117c0ef50e3e34fb927bb9a60c330a86a94ee580 | 4326b99b7d0431929bca59f5381a592a33a4ae2f | /PSX/Core/mednafen/settings.cpp | dde415f239cc978cdbe5d32b4097c650de865798 | [] | no_license | chipsoftwaretester/OpenEmu | 9a1e44f7f61147b363cff0975a8bd0cd7059a19c | 8cb81b545b40565478caf8927798a179e6042adc | refs/heads/master | 2021-01-14T08:26:28.780327 | 2013-04-25T04:53:05 | 2013-04-25T04:53:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 19,059 | cpp | /* Mednafen - Multi-system Emulator
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mednafen.h"
#include <errno.h>
#include <string.h>
#include <vector>
#include <string>
#include <trio/trio.h>
#include <map>
#include <list>
#include "settings.h"
#include "md5.h"
#include "string/world_strtod.h"
#include "string/escape.h"
#include "FileStream.h"
#include "MemoryStream.h"
typedef struct
{
char *name;
char *value;
} UnknownSetting_t;
std::multimap <uint32, MDFNCS> CurrentSettings;
std::vector<UnknownSetting_t> UnknownSettings;
static std::string fname; // TODO: remove
static MDFNCS *FindSetting(const char *name, bool deref_alias = true, bool dont_freak_out_on_fail = false);
static bool TranslateSettingValueUI(const char *value, unsigned long long &tlated_value)
{
char *endptr = NULL;
if(value[0] == '0' && (value[1] == 'x' || value[1] == 'X'))
tlated_value = strtoull(value + 2, &endptr, 16);
else
tlated_value = strtoull(value, &endptr, 10);
if(!endptr || *endptr != 0)
{
return(false);
}
return(true);
}
static bool TranslateSettingValueI(const char *value, long long &tlated_value)
{
char *endptr = NULL;
if(value[0] == '0' && (value[1] == 'x' || value[1] == 'X'))
tlated_value = strtoll(value + 2, &endptr, 16);
else
tlated_value = strtoll(value, &endptr, 10);
if(!endptr || *endptr != 0)
{
return(false);
}
return(true);
}
static void ValidateSetting(const char *value, const MDFNSetting *setting)
{
MDFNSettingType base_type = setting->type;
if(base_type == MDFNST_UINT)
{
unsigned long long ullvalue;
if(!TranslateSettingValueUI(value, ullvalue))
{
throw MDFN_Error(0, _("Setting \"%s\", value \"%s\", is not set to a valid unsigned integer."), setting->name, value);
}
if(setting->minimum)
{
unsigned long long minimum;
TranslateSettingValueUI(setting->minimum, minimum);
if(ullvalue < minimum)
{
throw MDFN_Error(0, _("Setting \"%s\" is set too small(\"%s\"); the minimum acceptable value is \"%s\"."), setting->name, value, setting->minimum);
}
}
if(setting->maximum)
{
unsigned long long maximum;
TranslateSettingValueUI(setting->maximum, maximum);
if(ullvalue > maximum)
{
throw MDFN_Error(0, _("Setting \"%s\" is set too large(\"%s\"); the maximum acceptable value is \"%s\"."), setting->name, value, setting->maximum);
}
}
}
else if(base_type == MDFNST_INT)
{
long long llvalue;
if(!TranslateSettingValueI(value, llvalue))
{
throw MDFN_Error(0, _("Setting \"%s\", value \"%s\", is not set to a valid signed integer."), setting->name, value);
}
if(setting->minimum)
{
long long minimum;
TranslateSettingValueI(setting->minimum, minimum);
if(llvalue < minimum)
{
throw MDFN_Error(0, _("Setting \"%s\" is set too small(\"%s\"); the minimum acceptable value is \"%s\"."), setting->name, value, setting->minimum);
}
}
if(setting->maximum)
{
long long maximum;
TranslateSettingValueI(setting->maximum, maximum);
if(llvalue > maximum)
{
throw MDFN_Error(0, _("Setting \"%s\" is set too large(\"%s\"); the maximum acceptable value is \"%s\"."), setting->name, value, setting->maximum);
}
}
}
else if(base_type == MDFNST_FLOAT)
{
double dvalue;
char *endptr = NULL;
dvalue = world_strtod(value, &endptr);
if(!endptr || *endptr != 0)
{
throw MDFN_Error(0, _("Setting \"%s\", value \"%s\", is not set to a floating-point(real) number."), setting->name, value);
}
if(setting->minimum)
{
double minimum;
minimum = world_strtod(setting->minimum, NULL);
if(dvalue < minimum)
{
throw MDFN_Error(0, _("Setting \"%s\" is set too small(\"%s\"); the minimum acceptable value is \"%s\"."), setting->name, value, setting->minimum);
}
}
if(setting->maximum)
{
double maximum;
maximum = world_strtod(setting->maximum, NULL);
if(dvalue > maximum)
{
throw MDFN_Error(0, _("Setting \"%s\" is set too large(\"%s\"); the maximum acceptable value is \"%s\"."), setting->name, value, setting->maximum);
}
}
}
else if(base_type == MDFNST_BOOL)
{
if(strlen(value) != 1 || (value[0] != '0' && value[0] != '1'))
{
throw MDFN_Error(0, _("Setting \"%s\", value \"%s\", is not a valid boolean value."), setting->name, value);
}
}
else if(base_type == MDFNST_ENUM)
{
const MDFNSetting_EnumList *enum_list = setting->enum_list;
bool found = false;
std::string valid_string_list;
assert(enum_list);
while(enum_list->string)
{
if(!strcasecmp(value, enum_list->string))
{
found = true;
break;
}
if(enum_list->description) // Don't list out undocumented and deprecated values.
valid_string_list = valid_string_list + (enum_list == setting->enum_list ? "" : " ") + std::string(enum_list->string);
enum_list++;
}
if(!found)
{
throw MDFN_Error(0, _("Setting \"%s\", value \"%s\", is not a recognized string. Recognized strings: %s"), setting->name, value, valid_string_list.c_str());
}
}
if(setting->validate_func && !setting->validate_func(setting->name, value))
{
if(base_type == MDFNST_STRING)
throw MDFN_Error(0, _("Setting \"%s\" is not set to a valid string: \"%s\""), setting->name, value);
else
throw MDFN_Error(0, _("Setting \"%s\" is not set to a valid unsigned integer: \"%s\""), setting->name, value);
}
}
static uint32 MakeNameHash(const char *name)
{
uint32 name_hash;
name_hash = crc32(0, (const Bytef *)name, strlen(name));
return(name_hash);
}
static void ParseSettingLine(std::string &linebuf, bool IsOverrideSetting = false)
{
MDFNCS *zesetting;
size_t spacepos = linebuf.find(' ');
// EOF or bad line
if(spacepos == std::string::npos)
return;
// No name(key)
if(spacepos == 0)
return;
// No value
if((spacepos + 1) == linebuf.size())
return;
// Comment
if(linebuf[0] == ';')
return;
linebuf[spacepos] = 0;
zesetting = FindSetting(linebuf.c_str(), true, true);
if(zesetting)
{
char *nv = strdup(linebuf.c_str() + spacepos + 1);
if(IsOverrideSetting)
{
if(zesetting->game_override)
free(zesetting->game_override);
zesetting->game_override = nv;
}
else
{
if(zesetting->value)
free(zesetting->value);
zesetting->value = nv;
}
ValidateSetting(nv, zesetting->desc); // TODO: Validate later(so command line options can override invalid setting file data correctly)
}
else if(!IsOverrideSetting)
{
UnknownSetting_t unks;
unks.name = strdup(linebuf.c_str());
unks.value = strdup(linebuf.c_str() + spacepos + 1);
UnknownSettings.push_back(unks);
}
}
static void LoadSettings(Stream *fp, const char *section, bool override)
{
bool InCorrectSection = true; // To also allow for all-game overrides at the start of the override file, might be useful in certain scenarios.
std::string linebuf;
linebuf.reserve(1024);
while(fp->get_line(linebuf) != -1)
{
if(linebuf[0] == '[')
{
if(section)
{
if(!strcasecmp(linebuf.c_str() + 1, section) && linebuf[1 + strlen(section)] == ']')
InCorrectSection = true;
else
InCorrectSection = false;
}
}
else if(InCorrectSection)
{
ParseSettingLine(linebuf, override);
}
}
}
bool MDFN_LoadSettings(const char *path, const char *section, bool override)
{
MDFN_printf(_("Loading settings from \"%s\"..."), path);
try
{
MemoryStream mp(new FileStream(path, FileStream::MODE_READ));
LoadSettings(&mp, section, override);
}
catch(MDFN_Error &e)
{
if(e.GetErrno() == ENOENT)
{
MDFN_indent(1);
MDFN_printf(_("Failed: %s\n"), e.what());
MDFN_indent(-1);
return(true);
}
else
{
MDFN_printf("\n");
MDFN_PrintError(_("Failed to load settings from \"%s\": %s"), fname.c_str(), e.what());
return(false);
}
}
catch(std::exception &e)
{
MDFN_printf("\n");
MDFN_PrintError(_("Failed to load settings from \"%s\": %s"), fname.c_str(), e.what());
return(false);
}
MDFN_printf("\n");
return(true);
}
static bool compare_sname(MDFNCS *first, MDFNCS *second)
{
return(strcmp(first->name, second->name) < 0);
}
static void SaveSettings(Stream *fp)
{
std::multimap <uint32, MDFNCS>::iterator sit;
std::list<MDFNCS *> SortedList;
std::list<MDFNCS *>::iterator lit;
fp->printf(";VERSION %s\n", MEDNAFEN_VERSION);
fp->printf(_(";Edit this file at your own risk!\n"));
fp->printf(_(";File format: <key><single space><value><LF or CR+LF>\n\n"));
for(sit = CurrentSettings.begin(); sit != CurrentSettings.end(); sit++)
SortedList.push_back(&sit->second);
SortedList.sort(compare_sname);
for(lit = SortedList.begin(); lit != SortedList.end(); lit++)
{
if((*lit)->desc->type == MDFNST_ALIAS)
continue;
fp->printf(";%s\n%s %s\n\n", _((*lit)->desc->description), (*lit)->name, (*lit)->value);
}
if(UnknownSettings.size())
{
fp->printf("\n;\n;Unrecognized settings follow:\n;\n\n");
for(unsigned int i = 0; i < UnknownSettings.size(); i++)
{
fp->printf("%s %s\n\n", UnknownSettings[i].name, UnknownSettings[i].value);
}
}
fp->close();
}
bool MDFN_SaveSettings(const char *path)
{
try
{
FileStream fp(path, FileStream::MODE_WRITE);
SaveSettings(&fp);
}
catch(std::exception &e)
{
MDFND_PrintError(e.what());
return(0);
}
return(1);
}
static INLINE void MergeSettingSub(const MDFNSetting *setting)
{
MDFNCS TempSetting;
uint32 name_hash;
assert(setting->name);
assert(setting->default_value);
if(FindSetting(setting->name, false, true) != NULL)
{
printf("Duplicate setting name %s\n", setting->name);
//abort();
return;
}
name_hash = MakeNameHash(setting->name);
TempSetting.name = strdup(setting->name);
TempSetting.value = strdup(setting->default_value);
TempSetting.name_hash = name_hash;
TempSetting.desc = setting;
TempSetting.ChangeNotification = setting->ChangeNotification;
TempSetting.game_override = NULL;
TempSetting.netplay_override = NULL;
CurrentSettings.insert(std::pair<uint32, MDFNCS>(name_hash, TempSetting)); //[name_hash] = TempSetting;
}
bool MDFN_MergeSettings(const MDFNSetting *setting)
{
while(setting->name != NULL)
{
MergeSettingSub(setting);
setting++;
}
return(1);
}
bool MDFN_MergeSettings(const std::vector<MDFNSetting> &setting)
{
for(unsigned int x = 0; x < setting.size(); x++)
MergeSettingSub(&setting[x]);
return(1);
}
void MDFN_KillSettings(void)
{
std::multimap <uint32, MDFNCS>::iterator sit;
for(sit = CurrentSettings.begin(); sit != CurrentSettings.end(); sit++)
{
if(sit->second.desc->type == MDFNST_ALIAS)
continue;
free(sit->second.name);
free(sit->second.value);
}
if(UnknownSettings.size())
{
for(unsigned int i = 0; i < UnknownSettings.size(); i++)
{
free(UnknownSettings[i].name);
free(UnknownSettings[i].value);
}
}
CurrentSettings.clear(); // Call after the list is all handled
UnknownSettings.clear();
}
static MDFNCS *FindSetting(const char *name, bool dref_alias, bool dont_freak_out_on_fail)
{
MDFNCS *ret = NULL;
uint32 name_hash;
//printf("Find: %s\n", name);
name_hash = MakeNameHash(name);
std::pair<std::multimap <uint32, MDFNCS>::iterator, std::multimap <uint32, MDFNCS>::iterator> sit_pair;
std::multimap <uint32, MDFNCS>::iterator sit;
sit_pair = CurrentSettings.equal_range(name_hash);
for(sit = sit_pair.first; sit != sit_pair.second; sit++)
{
//printf("Found: %s\n", sit->second.name);
if(!strcmp(sit->second.name, name))
{
if(dref_alias && sit->second.desc->type == MDFNST_ALIAS)
return(FindSetting(sit->second.value, dref_alias, dont_freak_out_on_fail));
ret = &sit->second;
}
}
if(!ret && !dont_freak_out_on_fail)
{
printf("\n\nINCONCEIVABLE! Setting not found: %s\n\n", name);
exit(1);
}
return(ret);
}
static const char *GetSetting(const MDFNCS *setting)
{
const char *value;
if(setting->netplay_override)
value = setting->netplay_override;
else if(setting->game_override)
value = setting->game_override;
else
value = setting->value;
return(value);
}
static int GetEnum(const MDFNCS *setting, const char *value)
{
const MDFNSetting_EnumList *enum_list = setting->desc->enum_list;
int ret = 0;
bool found = false;
assert(enum_list);
while(enum_list->string)
{
if(!strcasecmp(value, enum_list->string))
{
found = true;
ret = enum_list->number;
break;
}
enum_list++;
}
assert(found);
return(ret);
}
uint64 MDFN_GetSettingUI(const char *name)
{
const MDFNCS *setting = FindSetting(name);
const char *value = GetSetting(setting);
if(setting->desc->type == MDFNST_ENUM)
return(GetEnum(setting, value));
else
{
unsigned long long ret;
TranslateSettingValueUI(value, ret);
return(ret);
}
}
int64 MDFN_GetSettingI(const char *name)
{
const MDFNCS *setting = FindSetting(name);
const char *value = GetSetting(FindSetting(name));
if(setting->desc->type == MDFNST_ENUM)
return(GetEnum(setting, value));
else
{
long long ret;
TranslateSettingValueI(value, ret);
return(ret);
}
}
double MDFN_GetSettingF(const char *name)
{
return(world_strtod(GetSetting(FindSetting(name)), (char **)NULL));
}
bool MDFN_GetSettingB(const char *name)
{
return((bool)MDFN_GetSettingUI(name));
}
std::string MDFN_GetSettingS(const char *name)
{
const MDFNCS *setting = FindSetting(name);
const char *value = GetSetting(setting);
// Even if we're getting the string value of an enum instead of the associated numeric value, we still need
// to make sure it's a valid enum
// (actually, not really, since it's handled in other places where the setting is actually set)
//if(setting->desc->type == MDFNST_ENUM)
// GetEnum(setting, value);
return(std::string(value));
}
const std::multimap <uint32, MDFNCS> *MDFNI_GetSettings(void)
{
return(&CurrentSettings);
}
bool MDFNI_SetSetting(const char *name, const char *value, bool NetplayOverride)
{
MDFNCS *zesetting = FindSetting(name, true, true);
if(zesetting)
{
try
{
ValidateSetting(value, zesetting->desc);
}
catch(std::exception &e)
{
MDFND_PrintError(e.what());
return(0);
}
// TODO: When NetplayOverride is set, make sure the setting is an emulation-related setting,
// and that it is safe to change it(changing paths to BIOSes and such is not safe :b).
if(NetplayOverride)
{
if(zesetting->netplay_override)
free(zesetting->netplay_override);
zesetting->netplay_override = strdup(value);
}
else
{
// Overriding the per-game override. Poetic. Though not really.
if(zesetting->game_override)
{
free(zesetting->game_override);
zesetting->game_override = NULL;
}
if(zesetting->value)
free(zesetting->value);
zesetting->value = strdup(value);
}
// TODO, always call driver notification function, regardless of whether a game is loaded.
if(zesetting->ChangeNotification)
{
if(MDFNGameInfo)
zesetting->ChangeNotification(name);
}
return(true);
}
else
{
MDFN_PrintError(_("Unknown setting \"%s\""), name);
return(false);
}
}
#if 0
// TODO after a game is loaded, but should we?
void MDFN_CallSettingsNotification(void)
{
for(unsigned int x = 0; x < CurrentSettings.size(); x++)
{
if(CurrentSettings[x].ChangeNotification)
{
// TODO, always call driver notification function, regardless of whether a game is loaded.
if(MDFNGameInfo)
CurrentSettings[x].ChangeNotification(CurrentSettings[x].name);
}
}
}
#endif
bool MDFNI_SetSettingB(const char *name, bool value)
{
char tmpstr[2];
tmpstr[0] = value ? '1' : '0';
tmpstr[1] = 0;
return(MDFNI_SetSetting(name, tmpstr, FALSE));
}
bool MDFNI_SetSettingUI(const char *name, uint64 value)
{
char tmpstr[32];
trio_snprintf(tmpstr, 32, "%llu", value);
return(MDFNI_SetSetting(name, tmpstr, FALSE));
}
void MDFNI_DumpSettingsDef(const char *path)
{
FileStream fp(path, FileStream::MODE_WRITE);
std::multimap <uint32, MDFNCS>::iterator sit;
std::list<MDFNCS *> SortedList;
std::list<MDFNCS *>::iterator lit;
std::map<int, const char *> tts;
std::map<uint32, const char *>fts;
tts[MDFNST_INT] = "MDFNST_INT";
tts[MDFNST_UINT] = "MDFNST_UINT";
tts[MDFNST_BOOL] = "MDFNST_BOOL";
tts[MDFNST_FLOAT] = "MDFNST_FLOAT";
tts[MDFNST_STRING] = "MDFNST_STRING";
tts[MDFNST_ENUM] = "MDFNST_ENUM";
fts[MDFNSF_CAT_INPUT] = "MDFNSF_CAT_INPUT";
fts[MDFNSF_CAT_SOUND] = "MDFNSF_CAT_SOUND";
fts[MDFNSF_CAT_VIDEO] = "MDFNSF_CAT_VIDEO";
fts[MDFNSF_EMU_STATE] = "MDFNSF_EMU_STATE";
fts[MDFNSF_UNTRUSTED_SAFE] = "MDFNSF_UNTRUSTED_SAFE";
fts[MDFNSF_SUPPRESS_DOC] = "MDFNSF_SUPPRESS_DOC";
fts[MDFNSF_COMMON_TEMPLATE] = "MDFNSF_COMMON_TEMPLATE";
fts[MDFNSF_REQUIRES_RELOAD] = "MDFNSF_REQUIRES_RELOAD";
fts[MDFNSF_REQUIRES_RESTART] = "MDFNSF_REQUIRES_RESTART";
for(sit = CurrentSettings.begin(); sit != CurrentSettings.end(); sit++)
SortedList.push_back(&sit->second);
SortedList.sort(compare_sname);
for(lit = SortedList.begin(); lit != SortedList.end(); lit++)
{
const MDFNSetting *setting = (*lit)->desc;
char *desc_escaped;
char *desc_extra_escaped;
if(setting->type == MDFNST_ALIAS)
continue;
fp.printf("%s\n", setting->name);
for(unsigned int i = 0; i < 32; i++)
{
if(setting->flags & (1 << i))
fp.printf("%s ", fts[1 << i]);
}
fp.printf("\n");
desc_escaped = escape_string(setting->description ? setting->description : "");
desc_extra_escaped = escape_string(setting->description_extra ? setting->description_extra : "");
fp.printf("%s\n", desc_escaped);
fp.printf("%s\n", desc_extra_escaped);
free(desc_escaped);
free(desc_extra_escaped);
fp.printf("%s\n", tts[setting->type]);
fp.printf("%s\n", setting->default_value ? setting->default_value : "");
fp.printf("%s\n", setting->minimum ? setting->minimum : "");
fp.printf("%s\n", setting->maximum ? setting->maximum : "");
if(!setting->enum_list)
fp.printf("0\n");
else
{
const MDFNSetting_EnumList *el = setting->enum_list;
int count = 0;
while(el->string)
{
count++;
el++;
}
fp.printf("%d\n", count);
el = setting->enum_list;
while(el->string)
{
desc_escaped = escape_string(el->description ? el->description : "");
desc_extra_escaped = escape_string(el->description_extra ? el->description_extra : "");
fp.printf("%s\n", el->string);
fp.printf("%s\n", desc_escaped);
fp.printf("%s\n", desc_extra_escaped);
free(desc_escaped);
free(desc_extra_escaped);
el++;
}
}
}
fp.close();
}
| [
"brymaster@gmail.com"
] | brymaster@gmail.com |
9dabd93c3c56357b37d58969566ad3454a2dd712 | a182d9251cc643c74c4e2431048c4c2e09a244a6 | /rostms_tutorial_basic/src/ros_tutorial_srv_client.cpp | c7103ca8a72e31ee27223487ec72b397b2eae7eb | [] | no_license | irvs/rostms_tutorials | 369fef78de324d0558177ac7a68e99a887a33f3b | f20ebd44fc6cf22725a9737ffc7f4e757d7c60f2 | refs/heads/master | 2021-01-23T21:38:48.524854 | 2014-11-09T12:02:13 | 2014-11-09T12:02:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,966 | cpp | #include "ros/ros.h" // ROSメインヘッダーファイル
#include "rostms_tutorial_basic/srvTutorial.h" // srvTutorial サービスファイルのヘッダー(ビルド後に自動的に生成される)
#include <cstdlib>
int main(int argc, char **argv) // ノードのメイン関数
{
ros::init(argc, argv, "ros_tutorial_srv_client"); // ノード名の初期化
if (argc != 3) // 入力値のエラー処理
{
ROS_ERROR("cmd : rosrun ros_tutorial ros_tutorial_service_client arg0 arg1");
ROS_ERROR("arg0: double number, arg1: double number");
return 1;
}
ros::NodeHandle nh; // ROSシステムとの通信のためのノードのハンドルを宣言
// サービスクライアントを宣言し、 rostms_tutorial_basicパッケージのsrvTutorialサービスファイルを利用した
// サービスクライアントros_tutorial_service_clientを作成する。サービス名は「 ros_tutorial_srv 」である
ros::ServiceClient ros_tutorial_service_client = nh.serviceClient<rostms_tutorial_basic::srvTutorial>("ros_tutorial_srv");
// srvという名前でsrvTutorialサービス·ファイルを使用するサービス·ファイルを宣言する
rostms_tutorial_basic::srvTutorial srv;
// サービスの要求値にノードが実行されるときに、入力として使用されたパラメータを、それぞれのa 、bに格納する
srv.request.a = atof(argv[1]);
srv.request.b = atof(argv[2]);
// サービスを要求し、要求が受け入れられた場合、応答値を表示する
if (ros_tutorial_service_client.call(srv))
{
ROS_INFO("send srv, srv.Request.a and b: %f, %f", srv.request.a, srv.request.b);
ROS_INFO("recieve srv, srv.Response.result: %f", srv.response.result);
}
else
{
ROS_ERROR("Failed to call service ros_tutorial_srv");
return 1;
}
return 0;
}
| [
"passionvirus@gmail.com"
] | passionvirus@gmail.com |
f9abe64c8f832ef7bcabe136f6a9623073adf06d | 720092a9b6b9bfd00d08fa28f22676ff435b2052 | /Praktikum1/MyXmlOutputterHook.h | 8bbd472ebb122d14ed9c0ec87ba5e6ac5dbc1bd9 | [] | no_license | lukas15442/PAD2RepUnitTests | ec84e1031851bad37c4e86a53f6b4aa4b94fd706 | ddef049093509c045c28d74bda71f692d97e7d7e | refs/heads/master | 2020-03-27T01:40:46.271880 | 2018-08-22T18:16:24 | 2018-08-22T18:16:24 | 145,732,574 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,328 | h | //
// Created by lukas koehler on 21.08.18.
//
// Created by lukas koehler on 21.08.18.
//
#ifndef CODELUKAS_MYXMLOUTPUTTERHOOK_H
#define CODELUKAS_MYXMLOUTPUTTERHOOK_H
#include <cppunit/XmlOutputterHook.h>
#include <cppunit/tools/StringTools.h>
#include <cppunit/tools/XmlDocument.h>
#include <cppunit/tools/XmlElement.h>
class MyXmlOutputterHook : public CppUnit::XmlOutputterHook {
public:
MyXmlOutputterHook(const std::string projectName,
const std::string author) {
m_projectName = projectName;
m_author = author;
};
virtual ~MyXmlOutputterHook() {
};
void beginDocument(CppUnit::XmlDocument *document) {
if (!document)
return;
std::string szDate = CppUnit::StringTools::toString((int) time(0));
CppUnit::XmlElement *metaEl = new CppUnit::XmlElement("SuiteInfo",
"");
metaEl->addElement(new CppUnit::XmlElement("Author", m_author));
metaEl->addElement(new CppUnit::XmlElement("Project", m_projectName));
metaEl->addElement(new CppUnit::XmlElement("Date", szDate));
document->rootElement().addElement(metaEl);
};
private:
std::string m_projectName;
std::string m_author;
};
#endif //CODELUKAS_MYXMLOUTPUTTERHOOK_H
| [
"lukas.koehler@h-da.de"
] | lukas.koehler@h-da.de |
756956527433a105e3575f90c9ab1dfb1bf42731 | 9da88ab805303c25bd9654ad45287a62a6c4710f | /Cpp/LeetCode/wc254_1.cpp | 8a4fbd9b2cc4c6aa0adde39406b371475b7f95a3 | [] | no_license | ms303956362/myexercise | 7bb7be1ac0b8f40aeee8ca2df19255024c6d9bdc | 4730c438354f0c7fc3bce54f8c1ade6e627586c9 | refs/heads/master | 2023-04-13T01:15:01.882780 | 2023-04-03T15:03:22 | 2023-04-03T15:03:22 | 232,984,051 | 2 | 0 | null | 2022-12-02T06:55:19 | 2020-01-10T06:47:00 | C | UTF-8 | C++ | false | false | 546 | cpp | #include "usual.h"
class Solution {
public:
int numOfStrings(vector<string>& patterns, string word) {
int ans = 0, n = word.size();
for (const auto& p : patterns) {
int m = p.size();
if (m > n)
continue;
for (int i = 0; i <= n - m; ++i) {
if (word.substr(i, m) == p) {
++ans;
break;
}
}
}
return ans;
}
};
int main(int argc, char const *argv[])
{
return 0;
}
| [
"ms303956362@163.com"
] | ms303956362@163.com |
026a054d84ec933adf0fa135de72fb4081088ce5 | d121b9f699c92812fca4a00d65f6a6950b3e98ac | /Plugins/CustomRichText/Source/CustomRichText/Public/CustomRichTextBlock.h | 1158e7e70e23eaf3d001f99b5805f24b6cc4314f | [] | no_license | Naotsun19B/CustomRichText | 218452610df74ba0a7286c8b13a76cf1115819d7 | 46d18c5d0de942b66db04150a12d9b30d8a41878 | refs/heads/master | 2022-11-06T20:36:48.919283 | 2020-06-28T06:03:12 | 2020-06-28T06:03:12 | 275,518,463 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,977 | h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/RichTextBlock.h"
#include "CustomRichTextBlock.generated.h"
/**
*
*/
UCLASS()
class CUSTOMRICHTEXT_API UCustomRichTextBlock : public URichTextBlock
{
GENERATED_BODY()
protected:
// デフォルトで使用するスタイルセットのデータテーブルID.
UPROPERTY(EditAnywhere, Category = "Appearance")
FName DefaultStyleSetID;
// 挿入される画像サイズ.
UPROPERTY(EditAnywhere, Category = "Appearance")
int32 InlineImageSize;
public:
UCustomRichTextBlock(const FObjectInitializer& ObjectInitializer);
// デフォルトのTextStyleを取得.
UFUNCTION(BlueprintPure, Category = "Widget", meta = (DisplayName = "Get Default Text Style"))
FTextBlockStyle GetDefaultTextStyleBP() const;
// デフォルトで使用するスタイルセットのデータテーブルIDを設定.
UFUNCTION(BlueprintCallable, Category = "Widget")
void SetDefaultStyleSetID(const FName& StyleSetID);
// 挿入される画像サイズを取得.
UFUNCTION(BlueprintPure, Category = "Widget")
int32 GetInlineImageSize() const { return InlineImageSize; }
// 挿入される画像サイズを設定.
UFUNCTION(BlueprintCallable, Category = "Widget")
void SetInlineImageSize(int32 Size);
protected:
// UObject Interface.
virtual void PostLoad() override;
#if WITH_EDITOR
virtual void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) override;
virtual bool CanEditChange(const FProperty* InProperty) const override;
#endif
// End of UObject Interface.
// UWidget interface.
#if WITH_EDITOR
virtual void ValidateCompiledDefaults(IWidgetCompilerLog& CompileLog) const override;
#endif
// End of UWidget interface.
// プロパティの変更イベント.
virtual void OnChageDecoratorClasses();
virtual void OnChageDefaultStyleSetID();
virtual void OnChageInlineImageSize();
};
| [
"51815450+Naotsun19B@users.noreply.github.com"
] | 51815450+Naotsun19B@users.noreply.github.com |
f098ee80e7afa9ab12201b369e421644b35575d5 | c326f8662bb220e8c15fc6fd23b60ab98d219a38 | /Parser/Parser.cpp | 0e0306be93a2ef38c2450ed5833caba99202659f | [] | no_license | Karton4a/signal-compiler | ce6dbc89176333b9106451c46eb15216d9b0563d | 48570d0f8973b2a1274684a1c33ae5588583eb51 | refs/heads/master | 2023-07-27T04:41:49.758420 | 2021-09-13T21:05:52 | 2021-09-13T21:05:52 | 406,128,780 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,704 | cpp | #include "Parser.h"
#include "ParserExceptions.h"
void Parser::Parse(const Lexer& lexer)
{
m_Error.clear();
auto& table = lexer.GetTokenTable();
if (table.empty()) return;
m_CurrentToken = table.cbegin();
m_End = table.cend();
m_Root = ParserNode(NodeType::SignalProgram);
try
{
Program(&m_Root);
}
catch (ParserException& err)
{
m_Error = err.Message(lexer);
}
}
void Parser::Program(ParserNode* _root)
{
ParserNode* root = PushType(_root, NodeType::Program);
if (m_CurrentToken->Type != Lexer::Keywords::PROGRAM)
{
throw ValueException("PROGRAM",*m_CurrentToken); // TODO maybe shoud use lexer keyword search
}
PushCurrentToken(root);
ProcedureIdentifier(root);
if (m_CurrentToken->Type != ';')
{
throw ValueException(';', *m_CurrentToken);
}
PushCurrentToken(root);
Block(root);
if (m_CurrentToken->Type != '.')
{
throw ValueException('.', *m_CurrentToken);
}
root->Childs.emplace_back(*m_CurrentToken);
}
void Parser::ProcedureIdentifier(ParserNode* _root)
{
ParserNode* root = PushType(_root, NodeType::ProcedureIdentifier);
Identifier(root);
}
void Parser::Identifier(ParserNode* _root)
{
ParserNode* root = PushType(_root, NodeType::Identifier);
if (Lexer::Token::IsIdentifier(m_CurrentToken->Type))
{
PushCurrentToken(root);
}
else throw TypeException(NodeTypeToString(NodeType::Identifier),*m_CurrentToken);
}
void Parser::Block(ParserNode* _root)
{
ParserNode* root = PushType(_root, NodeType::Block);
//Declarations(root);
if (m_CurrentToken->Type != Lexer::Keywords::BEGIN)
{
throw ValueException("BEGIN", *m_CurrentToken);
}
PushCurrentToken(root);
bool is_empty = StatementsList(root);
if (m_CurrentToken->Type != Lexer::Keywords::END)
{
if (is_empty)
{
throw ValueException("END", *m_CurrentToken);
}
throw UnexpectedGrammarException(NodeTypeToString(NodeType::Block), m_CurrentToken->Row, m_CurrentToken->Column);
}
PushCurrentToken(root);
}
void Parser::Declarations(ParserNode* _root)
{
ParserNode* root = PushType(_root, NodeType::Declarations);
LabelDecl(root);
}
void Parser::LabelDecl(ParserNode* _root)
{
ParserNode* root = PushType(_root, NodeType::LabelDeclarations);
if (m_CurrentToken->Type != Lexer::Keywords::LABEL)
{
PushType(root, NodeType::Empty);
return;
}
PushCurrentToken(root);
if (!Lexer::Token::IsConstant(m_CurrentToken->Type))
{
throw TypeException(NodeTypeToString(NodeType::LabelDeclarations), *m_CurrentToken);
}
PushCurrentToken(root);
LabelsList(root);
if (m_CurrentToken->Type != ';')
{
throw ValueException(";", *m_CurrentToken);
}
PushCurrentToken(root);
}
void Parser::LabelsList(ParserNode* _root)
{
ParserNode* root = PushType(_root, NodeType::LabelsList);
if (m_CurrentToken->Type != ',')
{
root = PushType(root, NodeType::Empty);
return;
}
PushCurrentToken(root);
if (!Lexer::Token::IsConstant(m_CurrentToken->Type))
{
throw TypeException(NodeTypeToString(NodeType::LabelsList), *m_CurrentToken);
}
PushCurrentToken(root);
LabelsList(root);
}
bool Parser::StatementsList(ParserNode* _root)
{
ParserNode* root = PushType(_root, NodeType::StatementsList);
while (Statement(root))
{
root = PushType(root, NodeType::StatementsList);
};
if (root->Childs.empty())
{
PushType(root, NodeType::Empty);
return true;
}
return false;
}
bool Parser::Statement(ParserNode* _root)
{
if (m_CurrentToken->Type == Lexer::Keywords::LOOP)
{
ParserNode* root = PushType(_root, NodeType::Statement);
PushCurrentToken(root);
bool is_empty = StatementsList(root);
if (m_CurrentToken->Type != Lexer::Keywords::ENDLOOP)
{
throw ValueException("ENDLOOP", *m_CurrentToken);
}
PushCurrentToken(root);
if (m_CurrentToken->Type != ';')
{
throw ValueException(';', *m_CurrentToken);
//throw "expected one get another";
}
PushCurrentToken(root);
}
else if (m_CurrentToken->Type == Lexer::Keywords::CASE)
{
ParserNode* root = PushType(_root, NodeType::Statement);
PushCurrentToken(root);
Expresion(root);
if (m_CurrentToken->Type != Lexer::Keywords::OF)
{
throw UnexpectedGrammarException(NodeTypeToString(NodeType::Expresion), m_CurrentToken->Row, m_CurrentToken->Column);
}
PushCurrentToken(root);
bool is_empty = AlternativesList(root);
if (m_CurrentToken->Type != Lexer::Keywords::ENDCASE)
{
if (is_empty)
{
throw ValueException("ENDCASE",*m_CurrentToken);
}
throw UnexpectedGrammarException(NodeTypeToString(NodeType::AlternativesList), m_CurrentToken->Row, m_CurrentToken->Column);
}
PushCurrentToken(root);
if (m_CurrentToken->Type != ';')
{
throw ValueException(';', *m_CurrentToken);
}
PushCurrentToken(root);
}
else
{
return false;
}
return true;
}
bool Parser::Expresion(ParserNode* _root)
{
ParserNode* root = PushType(_root, NodeType::Expresion);
if (!Multiplier(root))
{
throw TypeException(NodeTypeToString(NodeType::Multiplier), *m_CurrentToken);
}
MultipliersList(root);
return true;
}
void Parser::MultipliersList(ParserNode* _root)
{
ParserNode* root = PushType(_root, NodeType::MultipliersList);
while (MultiplicationInstruction(root))
{
if (!Multiplier(root))
{
throw TypeException(NodeTypeToString(NodeType::Multiplier), *m_CurrentToken);
}
root = PushType(root, NodeType::MultipliersList);
}
if (root->Childs.empty())
{
PushType(root, NodeType::Empty);
}
}
bool Parser::MultiplicationInstruction(ParserNode* _root)
{
if (m_CurrentToken->Type == '*' || m_CurrentToken->Type == '/' || m_CurrentToken->Type == Lexer::Keywords::MOD)
{
ParserNode* root = PushType(_root, NodeType::MultiplicationInstruction);
PushCurrentToken(root);
return true;
}
return false;
}
bool Parser::Multiplier(ParserNode* _root)
{
if (Lexer::Token::IsConstant(m_CurrentToken->Type) || Lexer::Token::IsIdentifier(m_CurrentToken->Type))
{
ParserNode* root = PushType(_root, NodeType::Multiplier);
PushCurrentToken(root);
return true;
}
return false;
}
bool Parser::AlternativesList(ParserNode* _root)
{
ParserNode* root = PushType(_root, NodeType::AlternativesList);
while (Alternative(root))
{
root = PushType(root, NodeType::AlternativesList);
}
if (root->Childs.empty())
{
PushType(root, NodeType::Empty);
return true;
}
return false;
}
bool Parser::Alternative(ParserNode* _root)
{
ParserNode* root = PushType(_root, NodeType::Alternative);
try
{
Expresion(root);
}
catch (ParserException&)
{
if (root->Childs.back().Childs.empty())
{
_root->Childs.pop_back();
return false;
}
throw;
}
if (m_CurrentToken->Type != ':')
{
throw ValueException(':',*m_CurrentToken);
}
PushCurrentToken(root);
if (m_CurrentToken->Type != '/')
{
throw ValueException('/', *m_CurrentToken);
}
PushCurrentToken(root);
bool is_empty = StatementsList(root);
if (m_CurrentToken->Type != '\\')
{
if (is_empty)
{
throw ValueException('\\', *m_CurrentToken);
}
throw UnexpectedGrammarException(NodeTypeToString(NodeType::StatementsList),m_CurrentToken->Row,m_CurrentToken->Column);
}
PushCurrentToken(root);
return true;
}
Parser::ParserNode* Parser::PushType(ParserNode* _node, NodeType type)
{
_node->Childs.emplace_back(type);
return &_node->Childs.back();
}
void Parser::NextToken()
{
m_PreviousToken = m_CurrentToken;
m_CurrentToken++;
if (m_CurrentToken == m_End)
throw UnexpectedEndException(m_PreviousToken->Row, m_PreviousToken->Column);
}
void Parser::PushCurrentToken(ParserNode* _root)
{
_root->Childs.emplace_back(*m_CurrentToken);
NextToken();
}
const char* NodeTypeToString(NodeType type)
{
switch (type)
{
case NodeType::SignalProgram: return "<signal-program>";
case NodeType::Program: return "<program>";
case NodeType::Block: return "<block>";
case NodeType::StatementsList: return "<statements-list>";
case NodeType::Statement: return "<statement>";
case NodeType::AlternativesList: return "<alternatives-list>";
case NodeType::Alternative: return "<alternative>";
case NodeType::Expression: return "<expression>";
case NodeType::MultipliersList: return "<multipliers-list>";
case NodeType::MultiplicationInstruction: return "<multiplication-instruction>";
case NodeType::Multiplier: return "<multiplier>";
case NodeType::Identifier: return "<identifier>";
case NodeType::ProcedureIdentifier: return "<procedure-identifier>";
case NodeType::Expresion: return "<expresion>";
case NodeType::Declarations: return "<declarations>";
case NodeType::LabelDeclarations: return "<label-declarations>";
case NodeType::LabelsList: return "<labels-list>";
case NodeType::Empty: return "<empty>";
case NodeType::Token: return "<token>";
default: return "<unknown>";
}
/*Declarations,
LabelDeclarations,
LabelsList*/
}
| [
"anpaschenko@gmail.com"
] | anpaschenko@gmail.com |
5ddc9f24880158a1198a89369d0ad83a7ec56d99 | 7cce0635a50e8d2db92b7b1bf4ad49fc218fb0b8 | /Operation添加脉冲设置界面/ShotPoints.cpp | f388ed8516f72d3f5f966f74a95b982eb7c113a7 | [] | no_license | liquanhai/cxm-hitech-matrix428 | dcebcacea58123aabcd9541704b42b3491444220 | d06042a3de79379a77b0e4e276de42de3c1c6d23 | refs/heads/master | 2021-01-20T12:06:23.622153 | 2013-01-24T01:05:10 | 2013-01-24T01:05:10 | 54,619,320 | 2 | 2 | null | null | null | null | GB18030 | C++ | false | false | 2,310 | cpp | #include "StdAfx.h"
#include "ShotPoints.h"
/**
* @brief CShotPoints构造函数
*/
CShotPoints::CShotPoints(void)
{
}
/**
* @brief CShotPoints析构函数
*
* 先释放每个炮号对象,再清空放炮表。
*/
CShotPoints::~CShotPoints(void)
{
RemoveAll();
}
/**
* @brief 删除所有放炮对象
* @note 删除所有放炮对象
* @param void
* @return void
*/
void CShotPoints::RemoveAll(void)
{
int i,nCount = m_AllVP.GetCount();
for (i=0;i<nCount;i++)
{
if(m_AllVP[i])
{
delete m_AllVP[i];
m_AllVP[i] = NULL;
}
}
m_AllVP.RemoveAll();
}
/**
* @brief 拷贝放炮表
* @note 从一个对象中拷贝全部放炮表,仅仅是拷贝内存中放炮表指针数组,
并不是将放炮表数据拷贝到该对象中。调用该函数后,本地对象和pPoints对象指向内存
中同一块的放炮表区域。
* @param CShotPoints* pPoints-放炮表
* @return void
*/
void CShotPoints::Copy(CShotPoints* pPoints)
{
m_AllVP.Copy(pPoints->m_AllVP);
}
/**
* @brief 增加一个炮号
* @note 向放炮表的尾端增加一个炮号对象
* @param CShotPoint* pVP,炮号对象
* @return 返回在数组中的位置
*/
int CShotPoints::Add(CShotPoint* pVP)
{
return m_AllVP.Add(pVP);
}
/**
* @brief 计算总数
* @note 计算放炮表中总的炮号数
* @param void
* @return 返回总的炮号数
*/
int CShotPoints::GetCount(void)
{
return m_AllVP.GetCount();
}
/**
* @brief 获得指定位置的炮号对象
* @note 返回放炮表中指定位置的炮号对象
* @param int iIndex,索引值,索引从0开始
* @return 成功返回炮号指针,失败则返回NULL
*/
CShotPoint* CShotPoints::GetShotPoint(int iIndex)
{
int nCount = GetCount();
if(iIndex>=nCount)
return NULL;
return m_AllVP[iIndex];
}
/**
* @brief 通过炮点编号查找对象
* @note 通过炮点编号查找对象,返回炮号对象
* @param DWORD dwNb,炮点编号
* @return 成功则返回炮号指针,失败则返回NULL
*/
CShotPoint* CShotPoints::GetShotPointByNb(DWORD dwNb)
{
int i,nCount = m_AllVP.GetCount();
for (i=0;i<nCount;i++)
{
if(m_AllVP[i]->m_dwShotNb == dwNb)
{
return m_AllVP[i];
}
}
return NULL;
} | [
"chengxianming1981@gmail.com"
] | chengxianming1981@gmail.com |
3a1398790e172074c67436d660c65d021f796d0e | ece46d54db148fcd1717ae33e9c277e156067155 | /SDK/arxsdk2011/samples/database/ARXDBG/Inc/ArxDbgDwgFiler.h | 748e5f1b523a01445abfa1a6592e7ae0c688946d | [] | no_license | 15831944/ObjectArx | ffb3675875681b1478930aeac596cff6f4187ffd | 8c15611148264593730ff5b6213214cebd647d23 | refs/heads/main | 2023-06-16T07:36:01.588122 | 2021-07-09T10:17:27 | 2021-07-09T10:17:27 | 384,473,453 | 0 | 1 | null | 2021-07-09T15:08:56 | 2021-07-09T15:08:56 | null | UTF-8 | C++ | false | false | 5,364 | h | //
//
// (C) Copyright 1998-2006,2008 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//
//
#ifndef ARXDBGDWGFILER_H
#define ARXDBGDWGFILER_H
/****************************************************************************
**
** CLASS ArxDbgDwgFiler:
**
** **jma
**
*************************************/
#include "dbfiler.h"
class ArxDbgDwgFiler: public AcDbDwgFiler {
public:
ACRX_DECLARE_MEMBERS(ArxDbgDwgFiler);
ArxDbgDwgFiler();
virtual ~ArxDbgDwgFiler();
virtual Acad::ErrorStatus filerStatus() const;
virtual AcDb::FilerType filerType() const;
virtual void setFilerStatus(Acad::ErrorStatus);
virtual void resetFilerStatus();
virtual Acad::ErrorStatus readHardOwnershipId(AcDbHardOwnershipId*);
virtual Acad::ErrorStatus writeHardOwnershipId(const AcDbHardOwnershipId&);
virtual Acad::ErrorStatus readSoftOwnershipId(AcDbSoftOwnershipId*);
virtual Acad::ErrorStatus writeSoftOwnershipId(const AcDbSoftOwnershipId&);
virtual Acad::ErrorStatus readHardPointerId(AcDbHardPointerId*) ;
virtual Acad::ErrorStatus writeHardPointerId(const AcDbHardPointerId&);
virtual Acad::ErrorStatus readSoftPointerId(AcDbSoftPointerId*) ;
virtual Acad::ErrorStatus writeSoftPointerId(const AcDbSoftPointerId&);
virtual Acad::ErrorStatus readString(ACHAR **);
virtual Acad::ErrorStatus writeString(const ACHAR *);
virtual Acad::ErrorStatus readString(AcString &);
virtual Acad::ErrorStatus writeString(const AcString &);
virtual Acad::ErrorStatus readBChunk(ads_binary*);
virtual Acad::ErrorStatus writeBChunk(const ads_binary&);
virtual Acad::ErrorStatus readAcDbHandle(AcDbHandle*);
virtual Acad::ErrorStatus writeAcDbHandle(const AcDbHandle&);
virtual Acad::ErrorStatus readInt64(Adesk::Int64*);
virtual Acad::ErrorStatus writeInt64(Adesk::Int64);
virtual Acad::ErrorStatus readInt32(Adesk::Int32*);
virtual Acad::ErrorStatus writeInt32(Adesk::Int32);
virtual Acad::ErrorStatus readInt16(Adesk::Int16*);
virtual Acad::ErrorStatus writeInt16(Adesk::Int16);
virtual Acad::ErrorStatus readInt8(Adesk::Int8 *);
virtual Acad::ErrorStatus writeInt8(Adesk::Int8);
virtual Acad::ErrorStatus readUInt64(Adesk::UInt64*);
virtual Acad::ErrorStatus writeUInt64(Adesk::UInt64);
virtual Acad::ErrorStatus readUInt32(Adesk::UInt32*);
virtual Acad::ErrorStatus writeUInt32(Adesk::UInt32);
virtual Acad::ErrorStatus readUInt16(Adesk::UInt16*);
virtual Acad::ErrorStatus writeUInt16(Adesk::UInt16);
virtual Acad::ErrorStatus readUInt8(Adesk::UInt8*);
virtual Acad::ErrorStatus writeUInt8(Adesk::UInt8);
virtual Acad::ErrorStatus readBoolean(Adesk::Boolean*);
virtual Acad::ErrorStatus writeBoolean(Adesk::Boolean);
virtual Acad::ErrorStatus readBool(bool*);
virtual Acad::ErrorStatus writeBool(bool);
virtual Acad::ErrorStatus readDouble(double*);
virtual Acad::ErrorStatus writeDouble(double);
virtual Acad::ErrorStatus readPoint2d(AcGePoint2d*);
virtual Acad::ErrorStatus writePoint2d(const AcGePoint2d&);
virtual Acad::ErrorStatus readPoint3d(AcGePoint3d*);
virtual Acad::ErrorStatus writePoint3d(const AcGePoint3d&);
virtual Acad::ErrorStatus readVector2d(AcGeVector2d*);
virtual Acad::ErrorStatus writeVector2d(const AcGeVector2d&);
virtual Acad::ErrorStatus readVector3d(AcGeVector3d*);
virtual Acad::ErrorStatus writeVector3d(const AcGeVector3d&);
virtual Acad::ErrorStatus readScale3d(AcGeScale3d*);
virtual Acad::ErrorStatus writeScale3d(const AcGeScale3d&);
virtual Acad::ErrorStatus readBytes(void*, Adesk::UIntPtr);
virtual Acad::ErrorStatus writeBytes(const void*, Adesk::UIntPtr);
virtual Acad::ErrorStatus readAddress(void**);
virtual Acad::ErrorStatus writeAddress(const void*);
virtual Acad::ErrorStatus seek(Adesk::Int64 nOffset, int nMethod);
virtual Adesk::Int64 tell() const;
void setFilerType(AcDb::FilerType newType) { m_filerType = newType; }
private:
Acad::ErrorStatus m_stat;
CString m_str;
AcDb::FilerType m_filerType;
// helper functions
void printIt(LPCTSTR labelStr);
void objIdToStr(const AcDbObjectId& objId, CString& str);
};
#endif // ARXDBGDWGFILER_H
| [
"zhangsensen@zwcad.com"
] | zhangsensen@zwcad.com |
c9d6ef19f6c93d4ca3d7085c361f96d2732a54ef | 63326562e87bae81661ace58b0bc9b702503d535 | /isengard/cpp_training/mit_courseware/intro2cs/assignment_1/Mit_exercises/Part_B.cpp | 5470377fc8785c37b1c63250bacc1ae4e9baf387 | [] | no_license | mithrandirgreyhame/arda | afdc2d8b55e0dd1a2120af25dc8084f16d76b2a5 | 4535c68b4c4641ae94e3444200ecdb76d012f4fc | refs/heads/master | 2020-05-31T03:59:46.424241 | 2019-08-30T07:24:24 | 2019-08-30T07:24:24 | 190,092,217 | 0 | 1 | null | 2019-08-30T07:24:26 | 2019-06-03T22:42:07 | C++ | UTF-8 | C++ | false | false | 1,140 | cpp | #include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
long total_cost = 0;
const float portion_down_payment = 0.25;
long double current_savings = 0;
const float r = 0.04;
long double annual_salary = 0;
float portion_saved = 0;
long double monthly_salary = 0;
int month = 0;
long double semi_annual_raise = 0;
cout << "Enter your annual salary";
cin >> annual_salary;
cout << "Enter the percent of your salary to save, as a decimal";
cin >> portion_saved;
cout << "Enter the cost of your dream house";
cin >> total_cost;
cout << "Enter the percent of your semi-annual salary raise as the as a decimal percentage ";
cin >> semi_annual_raise;
monthly_salary = annual_salary / 12;
while (current_savings < total_cost *portion_down_payment) {
current_savings += monthly_salary*portion_saved + current_savings * r /12;
month++;
if (month%6==0){
monthly_salary += monthly_salary*semi_annual_raise;
}
}
cout << "You need " << month << " month to save up enough money for a down payment";
return 0;
}
| [
"phamtrinhan69@gmail.com"
] | phamtrinhan69@gmail.com |
f6f975387e2d0b1875816019269ddc0fc7a687ab | f427c8f5447d5ce51a3a416a1a59cb053b9efd5d | /STL-hashset/main.cpp | f8a7e554f70b0fc18824424be608e10ceae8181e | [] | no_license | laomd-2/Data-Structure | 9ac48d245a9fed6bac5ca70623a659eaaad68b10 | 7c99e6117781151da775afd09c337b6dee49e754 | refs/heads/master | 2020-03-27T19:06:49.769355 | 2018-09-01T04:29:31 | 2018-09-01T04:29:31 | 146,966,372 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 191 | cpp | #include "test.h"
using namespace std;
int main() {
try {
testConstructors();
testInsert();
testErase();
}
catch (std::exception& e) {
cout << e.what() << endl;
}
return 0;
}
| [
"laomd@mail2.sysu.edu.cn"
] | laomd@mail2.sysu.edu.cn |
fda7f9ed220b6f282606a5f4f40f292f1854526f | b2b298f4f3205e16e0491b26f81df7e352dddc7a | /src/GEOS/src/geomgraph/Node.cpp | 779d3874afee7088329d7ecad1555a0c8d73a4fd | [] | no_license | mustafaemre06/tools | 9e20ded4fb34a5494e15a9f630952133e4c15ec0 | 7135c1376b643d7d3730fb180dafa53dfb2cefe5 | refs/heads/master | 2020-12-12T06:23:53.718215 | 2017-07-05T14:55:58 | 2017-07-05T14:55:58 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,499 | cpp | /**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2011 Sandro Santilli <strk@keybit.net>
* Copyright (C) 2005-2006 Refractions Research Inc.
* Copyright (C) 2001-2002 Vivid Solutions Inc.
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************
*
* Last port: geomgraph/Node.java r411 (JTS-1.12+)
*
**********************************************************************/
#include <geos/platform.h>
#include <geos/geom/Coordinate.h>
#include <geos/geomgraph/Node.h>
#include <geos/geomgraph/Edge.h>
#include <geos/geomgraph/EdgeEndStar.h>
#include <geos/geomgraph/Label.h>
#include <geos/geomgraph/DirectedEdge.h>
#include <geos/geom/Location.h>
#include <geos/util/IllegalArgumentException.h>
#include <cmath>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#ifndef GEOS_DEBUG
#define GEOS_DEBUG 0
#endif
#ifndef COMPUTE_Z
#define COMPUTE_Z 1
#endif
using namespace std;
using namespace geos::geom;
namespace geos {
namespace geomgraph { // geos.geomgraph
/*public*/
Node::Node(const Coordinate& newCoord, EdgeEndStar* newEdges)
:
GraphComponent(Label(0,Location::UNDEF)),
coord(newCoord),
edges(newEdges)
{
#if GEOS_DEBUG
cerr<<"["<<this<<"] Node::Node("<<newCoord.toString()<<")"<<endl;
#endif
#if COMPUTE_Z
ztot = 0;
addZ(newCoord.z);
if ( edges )
{
EdgeEndStar::iterator endIt = edges->end();
for (EdgeEndStar::iterator it=edges->begin(); it!=endIt; ++it)
{
EdgeEnd *ee = *it;
addZ(ee->getCoordinate().z);
}
}
#endif // COMPUTE_Z
testInvariant();
}
/*public*/
Node::~Node()
{
testInvariant();
#if GEOS_DEBUG
cerr<<"["<<this<<"] Node::~Node()"<<endl;
#endif
delete edges;
}
/*public*/
const Coordinate&
Node::getCoordinate() const
{
testInvariant();
return coord;
}
/*public*/
EdgeEndStar *
Node::getEdges()
{
testInvariant();
return edges;
}
/*public*/
bool
Node::isIsolated() const
{
testInvariant();
return (label.getGeometryCount()==1);
}
/*public*/
bool
Node::isIncidentEdgeInResult() const
{
testInvariant();
if (!edges) return false;
EdgeEndStar::iterator it=edges->begin();
EdgeEndStar::iterator endIt=edges->end();
for ( ; it!=endIt; ++it)
{
assert(*it);
assert(dynamic_cast<DirectedEdge *>(*it));
DirectedEdge *de = static_cast<DirectedEdge *>(*it);
if ( de->getEdge()->isInResult() ) return true;
}
return false;
}
void
Node::add(EdgeEnd *e)
{
assert(e);
#if GEOS_DEBUG
cerr<<"["<<this<<"] Node::add("<<e->print()<<")"<<endl;
#endif
// Assert: start pt of e is equal to node point
if ( ! e->getCoordinate().equals2D(coord) ) {
std::stringstream ss;
ss << "EdgeEnd with coordinate " << e->getCoordinate()
<< " invalid for node " << coord;
throw util::IllegalArgumentException(ss.str());
}
// It seems it's legal for edges to be NULL
// we'd not be honouring the promise of adding
// an EdgeEnd in this case, though ...
assert(edges);
//if (edges==NULL) return;
edges->insert(e);
e->setNode(this);
#if COMPUTE_Z
addZ(e->getCoordinate().z);
#endif
testInvariant();
}
/*public*/
void
Node::mergeLabel(const Node& n)
{
assert(!n.label.isNull());
mergeLabel(n.label);
testInvariant();
}
/*public*/
void
Node::mergeLabel(const Label& label2)
{
for (int i=0; i<2; i++) {
int loc=computeMergedLocation(label2, i);
int thisLoc=label.getLocation(i);
if (thisLoc==Location::UNDEF) label.setLocation(i,loc);
}
testInvariant();
}
/*public*/
void
Node::setLabel(int argIndex, int onLocation)
{
if ( label.isNull() ) {
label = Label(argIndex, onLocation);
} else
label.setLocation(argIndex, onLocation);
testInvariant();
}
/*public*/
void
Node::setLabelBoundary(int argIndex)
{
int loc = label.getLocation(argIndex);
// flip the loc
int newLoc;
switch (loc){
case Location::BOUNDARY: newLoc=Location::INTERIOR; break;
case Location::INTERIOR: newLoc=Location::BOUNDARY; break;
default: newLoc=Location::BOUNDARY; break;
}
label.setLocation(argIndex, newLoc);
testInvariant();
}
/*public*/
int
Node::computeMergedLocation(const Label& label2, int eltIndex)
{
int loc=Location::UNDEF;
loc=label.getLocation(eltIndex);
if (!label2.isNull(eltIndex)) {
int nLoc=label2.getLocation(eltIndex);
if (loc!=Location::BOUNDARY) loc=nLoc;
}
testInvariant();
return loc;
}
/*public*/
string
Node::print()
{
testInvariant();
ostringstream ss;
ss<<*this;
return ss.str();
}
/*public*/
void
Node::addZ(double z)
{
#if GEOS_DEBUG
cerr<<"["<<this<<"] Node::addZ("<<z<<")";
#endif
if ( ISNAN(z) )
{
#if GEOS_DEBUG
cerr<<" skipped"<<endl;
#endif
return;
}
if ( find(zvals.begin(), zvals.end(), z) != zvals.end() )
{
#if GEOS_DEBUG
cerr<<" already stored"<<endl;
#endif
return;
}
zvals.push_back(z);
ztot+=z;
coord.z=ztot/zvals.size();
#if GEOS_DEBUG
cerr<<" added "<<z<<": ["<<ztot<<"/"<<zvals.size()<<"="<<coord.z<<"]"<<endl;
#endif
}
/*public*/
const vector<double>&
Node::getZ() const
{
return zvals;
}
std::ostream& operator<< (std::ostream& os, const Node& node)
{
os << "Node["<<&node<<"]" << std::endl
<< " POINT(" << node.coord << ")" << std::endl
<< " lbl: " << node.label;
return os;
}
} // namespace geos.geomgraph
} // namespace geos
| [
"tim.tisler@digitalglobe.com"
] | tim.tisler@digitalglobe.com |
6523fdc17b17d74a91e08392f60386328a2de876 | 602ea0c05970cbd766df068b003671c561f59661 | /chrome/browser/profiles/profile_statistics_unittest.cc | f75a535e8084d01ef6ed75df334760265c696d4b | [
"BSD-3-Clause"
] | permissive | VitalyKononenko/chromium | 088de78a639375b073cabb7665afc638334e8672 | b8ad2cadb6a163269cd7851bc7962744743785bd | refs/heads/master | 2023-03-01T10:15:00.815394 | 2019-08-15T19:51:40 | 2019-08-15T19:51:40 | 202,603,102 | 1 | 0 | BSD-3-Clause | 2019-08-15T19:54:34 | 2019-08-15T19:54:33 | null | UTF-8 | C++ | false | false | 5,447 | cc | // Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/profiles/profile_statistics.h"
#include <map>
#include <memory>
#include <set>
#include <utility>
#include <vector>
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/run_loop.h"
#include "base/task/post_task.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/bookmarks/chrome_bookmark_client.h"
#include "chrome/browser/bookmarks/managed_bookmark_service_factory.h"
#include "chrome/browser/password_manager/password_store_factory.h"
#include "chrome/browser/profiles/profile_statistics_aggregator.h"
#include "chrome/browser/profiles/profile_statistics_common.h"
#include "chrome/browser/profiles/profile_statistics_factory.h"
#include "chrome/browser/sync/bookmark_sync_service_factory.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/password_manager/core/browser/password_manager_test_utils.h"
#include "components/password_manager/core/browser/test_password_store.h"
#include "components/prefs/pref_service.h"
#include "components/sync_bookmarks/bookmark_sync_service.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
std::unique_ptr<KeyedService> BuildBookmarkModelWithoutLoad(
content::BrowserContext* context) {
Profile* profile = Profile::FromBrowserContext(context);
std::unique_ptr<bookmarks::BookmarkModel> bookmark_model(
new bookmarks::BookmarkModel(std::make_unique<ChromeBookmarkClient>(
profile, ManagedBookmarkServiceFactory::GetForProfile(profile),
BookmarkSyncServiceFactory::GetForProfile(profile))));
return std::move(bookmark_model);
}
void LoadBookmarkModel(Profile* profile,
bookmarks::BookmarkModel* bookmark_model) {
bookmark_model->Load(
profile->GetPrefs(), profile->GetPath(), profile->GetIOTaskRunner(),
base::CreateSingleThreadTaskRunner({content::BrowserThread::UI}));
}
bookmarks::BookmarkModel* CreateBookmarkModelWithoutLoad(Profile* profile) {
return static_cast<bookmarks::BookmarkModel*>(
BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse(
profile, base::BindRepeating(&BuildBookmarkModelWithoutLoad)));
}
class BookmarkStatHelper {
public:
BookmarkStatHelper() : num_of_times_called_(0) {}
void StatsCallback(profiles::ProfileCategoryStats stats) {
if (stats.back().category == profiles::kProfileStatisticsBookmarks)
++num_of_times_called_;
}
int GetNumOfTimesCalled() { return num_of_times_called_; }
private:
base::Closure quit_closure_;
int num_of_times_called_;
};
} // namespace
class ProfileStatisticsTest : public testing::Test {
public:
ProfileStatisticsTest() : manager_(TestingBrowserProcess::GetGlobal()) {}
~ProfileStatisticsTest() override {}
protected:
void SetUp() override {
ASSERT_TRUE(manager_.SetUp());
}
void TearDown() override {
}
TestingProfileManager* manager() { return &manager_; }
private:
content::TestBrowserThreadBundle thread_bundle_;
TestingProfileManager manager_;
};
TEST_F(ProfileStatisticsTest, WaitOrCountBookmarks) {
TestingProfile* profile = manager()->CreateTestingProfile("Test 1");
ASSERT_TRUE(profile);
// We need history, autofill and password services for the test to succeed.
ASSERT_TRUE(profile->CreateHistoryService(true, false));
profile->CreateWebDataService();
PasswordStoreFactory::GetInstance()->SetTestingFactory(
profile,
base::BindRepeating(
&password_manager::BuildPasswordStore<
content::BrowserContext, password_manager::TestPasswordStore>));
bookmarks::BookmarkModel* bookmark_model =
CreateBookmarkModelWithoutLoad(profile);
ASSERT_TRUE(bookmark_model);
// Run ProfileStatisticsAggregator::WaitOrCountBookmarks.
BookmarkStatHelper bookmark_stat_helper;
base::RunLoop run_loop_aggregator_done;
ProfileStatisticsAggregator aggregator(
profile, run_loop_aggregator_done.QuitClosure());
aggregator.AddCallbackAndStartAggregator(
base::Bind(&BookmarkStatHelper::StatsCallback,
base::Unretained(&bookmark_stat_helper)));
// Wait until ProfileStatisticsAggregator::WaitOrCountBookmarks is run.
base::RunLoop run_loop1;
run_loop1.RunUntilIdle();
EXPECT_EQ(0, bookmark_stat_helper.GetNumOfTimesCalled());
// Run ProfileStatisticsAggregator::WaitOrCountBookmarks again.
aggregator.AddCallbackAndStartAggregator(
profiles::ProfileStatisticsCallback());
// Wait until ProfileStatisticsAggregator::WaitOrCountBookmarks is run.
base::RunLoop run_loop2;
run_loop2.RunUntilIdle();
EXPECT_EQ(0, bookmark_stat_helper.GetNumOfTimesCalled());
// Load the bookmark model. When the model is loaded (asynchronously), the
// observer added by WaitOrCountBookmarks is run.
LoadBookmarkModel(profile, bookmark_model);
run_loop_aggregator_done.Run();
EXPECT_EQ(1, bookmark_stat_helper.GetNumOfTimesCalled());
}
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
cb804ecaaf18c29c82b050239cd9ed906581536f | 7a6270961bd863da3c888d289034f89cf0c8a9e6 | /tests/progs/test-range.cpp | 7fd09579ade171725bd0673553d12071865ca6cb | [] | no_license | wujingyue/slicer | b63924905f4726db892a47d9499a4758d851ea01 | 05682258bb4993f03fa5e08da82807ea93ad1c54 | refs/heads/master | 2021-01-10T19:32:54.422448 | 2014-10-07T14:58:17 | 2014-10-07T14:58:17 | 24,665,996 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,433 | cpp | #include <pthread.h>
#include <cstdio>
#include <cstdlib>
using namespace std;
pthread_barrier_t barrier;
pthread_mutex_t mutex;
int size = -1;
int nThreads = -1;
int N = -1;
int rootN = -1;
double *XXX;
void run(double *x, int xSize, int my, int start) {
long q;
long L;
long Lstar;
long j;
for (q = 1; q <= size / 2; q++) {
L = (1 << q);
Lstar = L;
for (j = 0; j < Lstar; j++) {
x[2 * j] += (my + 0.1);
}
}
}
void *subRoutine(void *arg) {
pthread_barrier_wait(&barrier);
long my = (long)arg;
int start = my * rootN / nThreads;
int end = start + rootN / nThreads;
for (int i = start; i < end; i++)
run(&XXX[2 * i * rootN], rootN, my, 2 * i * rootN);
pthread_barrier_wait(&barrier);
return NULL;
}
int main(int argc, char *argv[]) {
nThreads = atoi(argv[1]);
size = atoi(argv[2]);
if (size < nThreads)
exit(1);
if (size > 16)
exit(1);
pthread_t *threadIds = (pthread_t *)malloc(sizeof(pthread_t) * nThreads);
N = (1 << size);
rootN = (1 << (size / 2));
XXX = (double *)malloc(sizeof(double) * 2 * (N + rootN));
for (int i = 0; i < 2 * (N + rootN); i++)
XXX[i] = 0;
pthread_barrier_init(&barrier, NULL, nThreads);
for (int i = 0; i < nThreads - 1; i++)
pthread_create(&threadIds[0], NULL, subRoutine, (void *)i);
subRoutine((void *)(nThreads - 1));
for (int i = 0; i < nThreads - 1; i++)
pthread_join(threadIds[i], NULL);
free(threadIds);
free(XXX);
return 0;
}
| [
"jingyue@cs.columbia.edu"
] | jingyue@cs.columbia.edu |
56187d05769b1f598a5c82a1ae46f9356ff84ca6 | b779cd0820c62e50a0b5158b2bf9a78943eb18c6 | /helloWorldStyle.cpp | 48947562c84c2642e21716e49e66540c6c04b69a | [] | no_license | ICS3U-Programming-LiamC/Unit1-03-CPP | 0601bbbf2e22fca544957133c04af53c488a6f33 | 0d1128be1f6183203c9c6c72524957a544dba26a | refs/heads/main | 2023-04-09T14:00:22.783001 | 2021-04-27T17:39:23 | 2021-04-27T17:39:23 | 362,193,773 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 251 | cpp | // Copyright (c) Year Your Name All rights reserved.
//
// Created by: Liam Csiffary
// Date: April 27, 2021
// This program displays hello world but in the proper format
#include <iostream>
int main() {
std::cout << "Hello world!" << std::endl;
}
| [
"ubuntu@ip-172-31-93-33.ec2.internal"
] | ubuntu@ip-172-31-93-33.ec2.internal |
706c7b18306c73653d513c24e8d30340b20022bf | 303a1d56299c647ba2c556371ae76dc16ef54584 | /SearchWidget.h | 20f53907f7e44f7b8e35beab695c66f0b26959eb | [] | no_license | SkyTreeDelivery/GISDevelopmentKMJ | 61e1d62d49b8f23aa8cb0def1576b3b129a942b2 | 59cc7c0e8e378d40a10507565d050bf92796a65f | refs/heads/master | 2020-09-23T22:23:44.497760 | 2019-12-23T06:04:51 | 2019-12-23T06:04:51 | 225,602,021 | 0 | 0 | null | 2019-12-16T15:29:54 | 2019-12-03T11:20:05 | C++ | UTF-8 | C++ | false | false | 971 | h | #pragma once
#include <QWidget>
#include "ui_SearchWidget.h"
#include "GeoLayer.h"
namespace Ui {
class SearchWidget;
}
class SearchWidget : public QWidget
{
Q_OBJECT
public:
SearchWidget(GeoLayer* layer, QWidget *parent = nullptr);
~SearchWidget();
protected:
void closeEvent(QCloseEvent *event);
private:
Ui::SearchWidget* ui;
GeoLayer* layer;
QMap<int, GeoFeature*> rowFeatureMap;
QMenu* itemMenu;
void initRightedMenu();
signals:
void closeSignal();
void renderSelectedFeatures(QList<GeoFeature*> features);
void zoomToFeatureSignal(GeoFeature* feature);
void transToFeatureSignal(GeoFeature* feature);
void selectFeatureSignal(GeoFeature* feature);
public slots:
void on_search_button_clicked();
void on_zoomToFeature_action_triggered();
void on_transToFeature_action_triggered();
void on_fileTree_contextMenu_request(const QPoint &pos);
void on_item_doubleClicked(QListWidgetItem* item);
};
| [
"zhang113751@sina.com"
] | zhang113751@sina.com |
ae3e604487c1d85c570f77cbe6d815843e1a5d7a | b9a56df43414a1a762f9086a714f61516a7dd4df | /app/src/main/cpp/native-lib.cpp | bbc53edbbf9122f80beb298f88c050ed58bee91d | [] | no_license | FrizzleLiu/FrizzleMusic | 4e98410292f37c70a2bcb8ec2f18ea42afffde8c | 498c93e75d04f312ba4ee42f342a00dfa0906021 | refs/heads/master | 2022-11-13T04:12:26.015331 | 2020-07-01T02:01:02 | 2020-07-01T02:01:02 | 276,251,517 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,800 | cpp | #include <jni.h>
#include <string>
#include <android/log.h>
extern "C" {
//解码
#include "libavcodec/avcodec.h"
//缩放
#include <libswscale/swscale.h>
//封装格式
#include <libavformat/avformat.h>
//重采样
#include <libswresample/swresample.h>
}
#define LOGE(FORMAT, ...) __android_log_print(ANDROID_LOG_ERROR,"LC",FORMAT,##__VA_ARGS__);
//window上有48000Hz 和41000Hz
#define MAX_AUDIO_FRME_SIZE 48000*4
extern "C" JNIEXPORT jstring JNICALL
Java_com_frizzle_frizzlemusic_MainActivity_stringFromJNI(
JNIEnv *env,
jobject /* this */) {
std::string hello = "Hello from C++";
return env->NewStringUTF(av_version_info());
}extern "C"
JNIEXPORT void JNICALL
Java_com_frizzle_frizzlemusic_FrizzlePlayer_openAudio(JNIEnv *env, jobject thiz, jstring input_,
jstring output_) {
const char *input = env->GetStringUTFChars(input_, 0);
const char *output = env->GetStringUTFChars(output_, 0);
//初始化FFmpeg,可以不初始化
avformat_network_init();
//总上下文
AVFormatContext *avFormatContext = avformat_alloc_context();
//打开音频文件
if(avformat_open_input(&avFormatContext,input,NULL,NULL) != 0){
LOGE("打开文件失败");
return;
}
//查找音频流
if (avformat_find_stream_info(avFormatContext,NULL) != 0) {
return;
}
int audio_stream_index;
for (int i = 0; i < avFormatContext->nb_streams; ++i) {
if (avFormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
audio_stream_index = i;
break;
}
}
//获取解码器参数
AVCodecParameters *avCodecParameters = avFormatContext->streams[audio_stream_index]->codecpar;
//获取解码器
AVCodec *avCodec = avcodec_find_decoder(avCodecParameters->codec_id);
//解码器上下文
AVCodecContext *avCodecContext = avcodec_alloc_context3(avCodec);
//将解码器参数给解码器上下文
avcodec_parameters_to_context(avCodecContext, avCodecParameters);
//读取数据的包
AVPacket *avPacket = av_packet_alloc();
//转换器上下文
SwrContext *swrContext = swr_alloc();
//获取输入采样位数
AVSampleFormat in_sample_fmt = avCodecContext->sample_fmt;
//获取输入采样率
int in_sample_rate = avCodecContext->sample_rate;
//获取输入通道数
uint64_t in_channel_layout = avCodecContext->channel_layout;
//输出参数
//定义输出采样位数
AVSampleFormat out_sample_fmt = AV_SAMPLE_FMT_S16;
//定义输出采样率
int out_sample_rate = 44100;
//定义输出通道
uint64_t out_channel_layout = AV_CH_LAYOUT_STEREO;
//设置采样频率,采样位数,通道数
swr_alloc_set_opts(swrContext, out_channel_layout, out_sample_fmt, out_sample_rate,
in_channel_layout, in_sample_fmt, in_sample_rate, 0, NULL);
//初始化转换器
swr_init(swrContext);
//输出缓冲区,大小一般为输出采样率*通道数,上面用的是双通道
uint8_t *out_buffer = (uint8_t *) (av_malloc(2 * 44100));
//打开音频文件解压为wb格式
FILE *fc_pcm = fopen(output, "wb");
int count;
//读取音频流
while (av_read_frame(avFormatContext, avPacket) >= 0) {
avcodec_send_packet(avCodecContext, avPacket);
//拿到解码后的数据(未压缩数据)
AVFrame *avFrame = av_frame_alloc();
int result = avcodec_receive_frame(avCodecContext, avFrame);
if (result == AVERROR(EAGAIN)) {//有错误
LOGE("有错误");
continue;
} else if (result < 0) {//解码完成
break;
}
if (avPacket->stream_index != audio_stream_index) {//判断是否是音频流
continue;
}
LOGE("解码%d", count++);
//将解压后的frame转换成统一格式
swr_convert(swrContext, &out_buffer, 2 * 44100, (const uint8_t **) (avFrame->data),
avFrame->nb_samples);
//out_buffer输出到文件
//获取输出的布局通道数
int out_nb_channel = av_get_channel_layout_nb_channels(out_channel_layout);
//获取每一帧的实际大小
int out_buffer_size = av_samples_get_buffer_size(NULL, out_nb_channel, avFrame->nb_samples,
out_sample_fmt, 1);
//写入文件
fwrite(out_buffer,1,out_buffer_size,fc_pcm);
}
//释放资源
fclose(fc_pcm);
av_free(out_buffer);
swr_free(&swrContext);
avcodec_close(avCodecContext);
avformat_close_input(&avFormatContext);
env->ReleaseStringUTFChars(input_, input);
env->ReleaseStringUTFChars(output_, output);
} | [
"15888897624@163.com"
] | 15888897624@163.com |
a40a81e3c84dddf5e38c336c113e02ce8b007f52 | 830f3e46c89891dc988dda8e96b864d6e5f30805 | /leetcode/600-699/695_max_area_of_island.cpp | 86cde6166633aa42ea548ed09f6c9191dcdc093e | [] | no_license | boddicheg/competitive | 80cbf989520ef0b21d777a614963629c8bb5845f | 950465a95992115839b0c7752e0a7a2b02ee09a4 | refs/heads/master | 2023-08-16T20:27:01.601048 | 2023-08-16T15:07:30 | 2023-08-16T15:07:30 | 191,551,702 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,676 | cpp | #include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
#define watch(x) std::cout << (#x) << " is " << (x) << std::endl
static int x = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
class Solution
{
public:
int island(vector<vector<int>>& grid, int x, int y)
{
int result = 0;
// std::cout << x << " " << y << " " << grid.size() << std::endl;
if(x < 0 || x >= grid.size() || y < 0 || y >= grid.at(0).size())
return result;
if(grid.at(x).at(y) == 0 || grid.at(x).at(y) == 2)
return result;
else
{
result++;
grid.at(x).at(y) = 2;
// Check all directions
result += island(grid, x + 1, y);
result += island(grid, x - 1, y);
result += island(grid, x, y + 1);
result += island(grid, x, y - 1);
}
return result;
}
int maxAreaOfIsland(vector<vector<int>>& grid)
{
int result = 0;
for(size_t x = 0; x < grid.size(); x++)
for(size_t y = 0; y < grid.at(x).size(); y++)
{
int element = grid.at(x).at(y);
if(element == 0 || element == 2) continue;
result = std::max(island(grid, x, y), result);
}
return result;
}
};
int main(int argc, char const *argv[])
{
vector<vector<int>> grid = {
{0, 0, 0, 0, 0},
{0, 0, 1, 0, 0},
{0, 1, 0, 1, 0},
{0, 0, 1, 0, 0},
{0, 0, 1, 1, 0},
};
Solution s;
std::cout << s.maxAreaOfIsland(grid) << std::endl;
return 0;
}
| [
"boddicheg@gmail.com"
] | boddicheg@gmail.com |
2a0f4a3485201b03a7ff0e77bf90821447536292 | b0dd7779c225971e71ae12c1093dc75ed9889921 | /boost/math/special_functions/expint.hpp | 9242804a36b3e025d090827f9ad8ad58b00e3446 | [
"LicenseRef-scancode-warranty-disclaimer",
"BSL-1.0"
] | permissive | blackberry/Boost | 6e653cd91a7806855a162347a5aeebd2a8c055a2 | fc90c3fde129c62565c023f091eddc4a7ed9902b | refs/heads/1_48_0-gnu | 2021-01-15T14:31:33.706351 | 2013-06-25T16:02:41 | 2013-06-25T16:02:41 | 2,599,411 | 244 | 154 | BSL-1.0 | 2018-10-13T18:35:09 | 2011-10-18T14:25:18 | C++ | UTF-8 | C++ | false | false | 76,671 | hpp | // Copyright John Maddock 2007.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_MATH_EXPINT_HPP
#define BOOST_MATH_EXPINT_HPP
#ifdef _MSC_VER
#pragma once
#endif
#include <boost/math/tools/precision.hpp>
#include <boost/math/tools/promotion.hpp>
#include <boost/math/tools/fraction.hpp>
#include <boost/math/tools/series.hpp>
#include <boost/math/policies/error_handling.hpp>
#include <boost/math/special_functions/digamma.hpp>
#include <boost/math/special_functions/log1p.hpp>
#include <boost/math/special_functions/pow.hpp>
namespace boost{ namespace math{
template <class T, class Policy>
inline typename tools::promote_args<T>::type
expint(unsigned n, T z, const Policy& /*pol*/);
namespace detail{
template <class T>
inline T expint_1_rational(const T& z, const mpl::int_<0>&)
{
// this function is never actually called
BOOST_ASSERT(0);
return z;
}
template <class T>
T expint_1_rational(const T& z, const mpl::int_<53>&)
{
BOOST_MATH_STD_USING
T result;
if(z <= 1)
{
// Maximum Deviation Found: 2.006e-18
// Expected Error Term: 2.006e-18
// Max error found at double precision: 2.760e-17
static const T Y = 0.66373538970947265625F;
static const T P[6] = {
BOOST_MATH_BIG_CONSTANT(T, 53, 0.0865197248079397976498),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.0320913665303559189999),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.245088216639761496153),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.0368031736257943745142),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.00399167106081113256961),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.000111507792921197858394)
};
static const T Q[6] = {
BOOST_MATH_BIG_CONSTANT(T, 53, 1),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.37091387659397013215),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.056770677104207528384),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.00427347600017103698101),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.000131049900798434683324),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.528611029520217142048e-6)
};
result = tools::evaluate_polynomial(P, z)
/ tools::evaluate_polynomial(Q, z);
result += z - log(z) - Y;
}
else if(z < -boost::math::tools::log_min_value<T>())
{
// Maximum Deviation Found (interpolated): 1.444e-17
// Max error found at double precision: 3.119e-17
static const T P[11] = {
BOOST_MATH_BIG_CONSTANT(T, 53, -0.121013190657725568138e-18),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.999999999999998811143),
BOOST_MATH_BIG_CONSTANT(T, 53, -43.3058660811817946037),
BOOST_MATH_BIG_CONSTANT(T, 53, -724.581482791462469795),
BOOST_MATH_BIG_CONSTANT(T, 53, -6046.8250112711035463),
BOOST_MATH_BIG_CONSTANT(T, 53, -27182.6254466733970467),
BOOST_MATH_BIG_CONSTANT(T, 53, -66598.2652345418633509),
BOOST_MATH_BIG_CONSTANT(T, 53, -86273.1567711649528784),
BOOST_MATH_BIG_CONSTANT(T, 53, -54844.4587226402067411),
BOOST_MATH_BIG_CONSTANT(T, 53, -14751.4895786128450662),
BOOST_MATH_BIG_CONSTANT(T, 53, -1185.45720315201027667)
};
static const T Q[12] = {
BOOST_MATH_BIG_CONSTANT(T, 53, 1),
BOOST_MATH_BIG_CONSTANT(T, 53, 45.3058660811801465927),
BOOST_MATH_BIG_CONSTANT(T, 53, 809.193214954550328455),
BOOST_MATH_BIG_CONSTANT(T, 53, 7417.37624454689546708),
BOOST_MATH_BIG_CONSTANT(T, 53, 38129.5594484818471461),
BOOST_MATH_BIG_CONSTANT(T, 53, 113057.05869159631492),
BOOST_MATH_BIG_CONSTANT(T, 53, 192104.047790227984431),
BOOST_MATH_BIG_CONSTANT(T, 53, 180329.498380501819718),
BOOST_MATH_BIG_CONSTANT(T, 53, 86722.3403467334749201),
BOOST_MATH_BIG_CONSTANT(T, 53, 18455.4124737722049515),
BOOST_MATH_BIG_CONSTANT(T, 53, 1229.20784182403048905),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.776491285282330997549)
};
T recip = 1 / z;
result = 1 + tools::evaluate_polynomial(P, recip)
/ tools::evaluate_polynomial(Q, recip);
result *= exp(-z) * recip;
}
else
{
result = 0;
}
return result;
}
template <class T>
T expint_1_rational(const T& z, const mpl::int_<64>&)
{
BOOST_MATH_STD_USING
T result;
if(z <= 1)
{
// Maximum Deviation Found: 3.807e-20
// Expected Error Term: 3.807e-20
// Max error found at long double precision: 6.249e-20
static const T Y = 0.66373538970947265625F;
static const T P[6] = {
BOOST_MATH_BIG_CONSTANT(T, 64, 0.0865197248079397956816),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.0275114007037026844633),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.246594388074877139824),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.0237624819878732642231),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.00259113319641673986276),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.30853660894346057053e-4)
};
static const T Q[7] = {
BOOST_MATH_BIG_CONSTANT(T, 64, 1),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.317978365797784100273),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.0393622602554758722511),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.00204062029115966323229),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.732512107100088047854e-5),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.202872781770207871975e-5),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.52779248094603709945e-7)
};
result = tools::evaluate_polynomial(P, z)
/ tools::evaluate_polynomial(Q, z);
result += z - log(z) - Y;
}
else if(z < -boost::math::tools::log_min_value<T>())
{
// Maximum Deviation Found (interpolated): 2.220e-20
// Max error found at long double precision: 1.346e-19
static const T P[14] = {
BOOST_MATH_BIG_CONSTANT(T, 64, -0.534401189080684443046e-23),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.999999999999999999905),
BOOST_MATH_BIG_CONSTANT(T, 64, -62.1517806091379402505),
BOOST_MATH_BIG_CONSTANT(T, 64, -1568.45688271895145277),
BOOST_MATH_BIG_CONSTANT(T, 64, -21015.3431990874009619),
BOOST_MATH_BIG_CONSTANT(T, 64, -164333.011755931661949),
BOOST_MATH_BIG_CONSTANT(T, 64, -777917.270775426696103),
BOOST_MATH_BIG_CONSTANT(T, 64, -2244188.56195255112937),
BOOST_MATH_BIG_CONSTANT(T, 64, -3888702.98145335643429),
BOOST_MATH_BIG_CONSTANT(T, 64, -3909822.65621952648353),
BOOST_MATH_BIG_CONSTANT(T, 64, -2149033.9538897398457),
BOOST_MATH_BIG_CONSTANT(T, 64, -584705.537139793925189),
BOOST_MATH_BIG_CONSTANT(T, 64, -65815.2605361889477244),
BOOST_MATH_BIG_CONSTANT(T, 64, -2038.82870680427258038)
};
static const T Q[14] = {
BOOST_MATH_BIG_CONSTANT(T, 64, 1),
BOOST_MATH_BIG_CONSTANT(T, 64, 64.1517806091379399478),
BOOST_MATH_BIG_CONSTANT(T, 64, 1690.76044393722763785),
BOOST_MATH_BIG_CONSTANT(T, 64, 24035.9534033068949426),
BOOST_MATH_BIG_CONSTANT(T, 64, 203679.998633572361706),
BOOST_MATH_BIG_CONSTANT(T, 64, 1074661.58459976978285),
BOOST_MATH_BIG_CONSTANT(T, 64, 3586552.65020899358773),
BOOST_MATH_BIG_CONSTANT(T, 64, 7552186.84989547621411),
BOOST_MATH_BIG_CONSTANT(T, 64, 9853333.79353054111434),
BOOST_MATH_BIG_CONSTANT(T, 64, 7689642.74550683631258),
BOOST_MATH_BIG_CONSTANT(T, 64, 3385553.35146759180739),
BOOST_MATH_BIG_CONSTANT(T, 64, 763218.072732396428725),
BOOST_MATH_BIG_CONSTANT(T, 64, 73930.2995984054930821),
BOOST_MATH_BIG_CONSTANT(T, 64, 2063.86994219629165937)
};
T recip = 1 / z;
result = 1 + tools::evaluate_polynomial(P, recip)
/ tools::evaluate_polynomial(Q, recip);
result *= exp(-z) * recip;
}
else
{
result = 0;
}
return result;
}
template <class T>
T expint_1_rational(const T& z, const mpl::int_<113>&)
{
BOOST_MATH_STD_USING
T result;
if(z <= 1)
{
// Maximum Deviation Found: 2.477e-35
// Expected Error Term: 2.477e-35
// Max error found at long double precision: 6.810e-35
static const T Y = 0.66373538970947265625F;
static const T P[10] = {
BOOST_MATH_BIG_CONSTANT(T, 113, 0.0865197248079397956434879099175975937),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.0369066175910795772830865304506087759),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.24272036838415474665971599314725545),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.0502166331248948515282379137550178307),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.00768384138547489410285101483730424919),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.000612574337702109683505224915484717162),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.380207107950635046971492617061708534e-4),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.136528159460768830763009294683628406e-5),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.346839106212658259681029388908658618e-7),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.340500302777838063940402160594523429e-9)
};
static const T Q[10] = {
BOOST_MATH_BIG_CONSTANT(T, 113, 1),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.426568827778942588160423015589537302),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.0841384046470893490592450881447510148),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.0100557215850668029618957359471132995),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.000799334870474627021737357294799839363),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.434452090903862735242423068552687688e-4),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.15829674748799079874182885081231252e-5),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.354406206738023762100882270033082198e-7),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.369373328141051577845488477377890236e-9),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.274149801370933606409282434677600112e-12)
};
result = tools::evaluate_polynomial(P, z)
/ tools::evaluate_polynomial(Q, z);
result += z - log(z) - Y;
}
else if(z <= 4)
{
// Max error in interpolated form: 5.614e-35
// Max error found at long double precision: 7.979e-35
static const T Y = 0.70190334320068359375F;
static const T P[16] = {
BOOST_MATH_BIG_CONSTANT(T, 113, 0.298096656795020369955077350585959794),
BOOST_MATH_BIG_CONSTANT(T, 113, 12.9314045995266142913135497455971247),
BOOST_MATH_BIG_CONSTANT(T, 113, 226.144334921582637462526628217345501),
BOOST_MATH_BIG_CONSTANT(T, 113, 2070.83670924261732722117682067381405),
BOOST_MATH_BIG_CONSTANT(T, 113, 10715.1115684330959908244769731347186),
BOOST_MATH_BIG_CONSTANT(T, 113, 30728.7876355542048019664777316053311),
BOOST_MATH_BIG_CONSTANT(T, 113, 38520.6078609349855436936232610875297),
BOOST_MATH_BIG_CONSTANT(T, 113, -27606.0780981527583168728339620565165),
BOOST_MATH_BIG_CONSTANT(T, 113, -169026.485055785605958655247592604835),
BOOST_MATH_BIG_CONSTANT(T, 113, -254361.919204983608659069868035092282),
BOOST_MATH_BIG_CONSTANT(T, 113, -195765.706874132267953259272028679935),
BOOST_MATH_BIG_CONSTANT(T, 113, -83352.6826013533205474990119962408675),
BOOST_MATH_BIG_CONSTANT(T, 113, -19251.6828496869586415162597993050194),
BOOST_MATH_BIG_CONSTANT(T, 113, -2226.64251774578542836725386936102339),
BOOST_MATH_BIG_CONSTANT(T, 113, -109.009437301400845902228611986479816),
BOOST_MATH_BIG_CONSTANT(T, 113, -1.51492042209561411434644938098833499)
};
static const T Q[16] = {
BOOST_MATH_BIG_CONSTANT(T, 113, 1),
BOOST_MATH_BIG_CONSTANT(T, 113, 46.734521442032505570517810766704587),
BOOST_MATH_BIG_CONSTANT(T, 113, 908.694714348462269000247450058595655),
BOOST_MATH_BIG_CONSTANT(T, 113, 9701.76053033673927362784882748513195),
BOOST_MATH_BIG_CONSTANT(T, 113, 63254.2815292641314236625196594947774),
BOOST_MATH_BIG_CONSTANT(T, 113, 265115.641285880437335106541757711092),
BOOST_MATH_BIG_CONSTANT(T, 113, 732707.841188071900498536533086567735),
BOOST_MATH_BIG_CONSTANT(T, 113, 1348514.02492635723327306628712057794),
BOOST_MATH_BIG_CONSTANT(T, 113, 1649986.81455283047769673308781585991),
BOOST_MATH_BIG_CONSTANT(T, 113, 1326000.828522976970116271208812099),
BOOST_MATH_BIG_CONSTANT(T, 113, 683643.09490612171772350481773951341),
BOOST_MATH_BIG_CONSTANT(T, 113, 217640.505137263607952365685653352229),
BOOST_MATH_BIG_CONSTANT(T, 113, 40288.3467237411710881822569476155485),
BOOST_MATH_BIG_CONSTANT(T, 113, 3932.89353979531632559232883283175754),
BOOST_MATH_BIG_CONSTANT(T, 113, 169.845369689596739824177412096477219),
BOOST_MATH_BIG_CONSTANT(T, 113, 2.17607292280092201170768401876895354)
};
T recip = 1 / z;
result = Y + tools::evaluate_polynomial(P, recip)
/ tools::evaluate_polynomial(Q, recip);
result *= exp(-z) * recip;
}
else if(z < -boost::math::tools::log_min_value<T>())
{
// Max error in interpolated form: 4.413e-35
// Max error found at long double precision: 8.928e-35
static const T P[19] = {
BOOST_MATH_BIG_CONSTANT(T, 113, -0.559148411832951463689610809550083986e-40),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.999999999999999999999999999999999997),
BOOST_MATH_BIG_CONSTANT(T, 113, -166.542326331163836642960118190147367),
BOOST_MATH_BIG_CONSTANT(T, 113, -12204.639128796330005065904675153652),
BOOST_MATH_BIG_CONSTANT(T, 113, -520807.069767086071806275022036146855),
BOOST_MATH_BIG_CONSTANT(T, 113, -14435981.5242137970691490903863125326),
BOOST_MATH_BIG_CONSTANT(T, 113, -274574945.737064301247496460758654196),
BOOST_MATH_BIG_CONSTANT(T, 113, -3691611582.99810039356254671781473079),
BOOST_MATH_BIG_CONSTANT(T, 113, -35622515944.8255047299363690814678763),
BOOST_MATH_BIG_CONSTANT(T, 113, -248040014774.502043161750715548451142),
BOOST_MATH_BIG_CONSTANT(T, 113, -1243190389769.53458416330946622607913),
BOOST_MATH_BIG_CONSTANT(T, 113, -4441730126135.54739052731990368425339),
BOOST_MATH_BIG_CONSTANT(T, 113, -11117043181899.7388524310281751971366),
BOOST_MATH_BIG_CONSTANT(T, 113, -18976497615396.9717776601813519498961),
BOOST_MATH_BIG_CONSTANT(T, 113, -21237496819711.1011661104761906067131),
BOOST_MATH_BIG_CONSTANT(T, 113, -14695899122092.5161620333466757812848),
BOOST_MATH_BIG_CONSTANT(T, 113, -5737221535080.30569711574295785864903),
BOOST_MATH_BIG_CONSTANT(T, 113, -1077042281708.42654526404581272546244),
BOOST_MATH_BIG_CONSTANT(T, 113, -68028222642.1941480871395695677675137)
};
static const T Q[20] = {
BOOST_MATH_BIG_CONSTANT(T, 113, 1),
BOOST_MATH_BIG_CONSTANT(T, 113, 168.542326331163836642960118190147311),
BOOST_MATH_BIG_CONSTANT(T, 113, 12535.7237814586576783518249115343619),
BOOST_MATH_BIG_CONSTANT(T, 113, 544891.263372016404143120911148640627),
BOOST_MATH_BIG_CONSTANT(T, 113, 15454474.7241010258634446523045237762),
BOOST_MATH_BIG_CONSTANT(T, 113, 302495899.896629522673410325891717381),
BOOST_MATH_BIG_CONSTANT(T, 113, 4215565948.38886507646911672693270307),
BOOST_MATH_BIG_CONSTANT(T, 113, 42552409471.7951815668506556705733344),
BOOST_MATH_BIG_CONSTANT(T, 113, 313592377066.753173979584098301610186),
BOOST_MATH_BIG_CONSTANT(T, 113, 1688763640223.4541980740597514904542),
BOOST_MATH_BIG_CONSTANT(T, 113, 6610992294901.59589748057620192145704),
BOOST_MATH_BIG_CONSTANT(T, 113, 18601637235659.6059890851321772682606),
BOOST_MATH_BIG_CONSTANT(T, 113, 36944278231087.2571020964163402941583),
BOOST_MATH_BIG_CONSTANT(T, 113, 50425858518481.7497071917028793820058),
BOOST_MATH_BIG_CONSTANT(T, 113, 45508060902865.0899967797848815980644),
BOOST_MATH_BIG_CONSTANT(T, 113, 25649955002765.3817331501988304758142),
BOOST_MATH_BIG_CONSTANT(T, 113, 8259575619094.6518520988612711292331),
BOOST_MATH_BIG_CONSTANT(T, 113, 1299981487496.12607474362723586264515),
BOOST_MATH_BIG_CONSTANT(T, 113, 70242279152.8241187845178443118302693),
BOOST_MATH_BIG_CONSTANT(T, 113, -37633302.9409263839042721539363416685)
};
T recip = 1 / z;
result = 1 + tools::evaluate_polynomial(P, recip)
/ tools::evaluate_polynomial(Q, recip);
result *= exp(-z) * recip;
}
else
{
result = 0;
}
return result;
}
template <class T>
struct expint_fraction
{
typedef std::pair<T,T> result_type;
expint_fraction(unsigned n_, T z_) : b(n_ + z_), i(-1), n(n_){}
std::pair<T,T> operator()()
{
std::pair<T,T> result = std::make_pair(-static_cast<T>((i+1) * (n+i)), b);
b += 2;
++i;
return result;
}
private:
T b;
int i;
unsigned n;
};
template <class T, class Policy>
inline T expint_as_fraction(unsigned n, T z, const Policy& pol)
{
BOOST_MATH_STD_USING
BOOST_MATH_INSTRUMENT_VARIABLE(z)
boost::uintmax_t max_iter = policies::get_max_series_iterations<Policy>();
expint_fraction<T> f(n, z);
T result = tools::continued_fraction_b(
f,
boost::math::policies::get_epsilon<T, Policy>(),
max_iter);
policies::check_series_iterations<T>("boost::math::expint_continued_fraction<%1%>(unsigned,%1%)", max_iter, pol);
BOOST_MATH_INSTRUMENT_VARIABLE(result)
BOOST_MATH_INSTRUMENT_VARIABLE(max_iter)
result = exp(-z) / result;
BOOST_MATH_INSTRUMENT_VARIABLE(result)
return result;
}
template <class T>
struct expint_series
{
typedef T result_type;
expint_series(unsigned k_, T z_, T x_k_, T denom_, T fact_)
: k(k_), z(z_), x_k(x_k_), denom(denom_), fact(fact_){}
T operator()()
{
x_k *= -z;
denom += 1;
fact *= ++k;
return x_k / (denom * fact);
}
private:
unsigned k;
T z;
T x_k;
T denom;
T fact;
};
template <class T, class Policy>
inline T expint_as_series(unsigned n, T z, const Policy& pol)
{
BOOST_MATH_STD_USING
boost::uintmax_t max_iter = policies::get_max_series_iterations<Policy>();
BOOST_MATH_INSTRUMENT_VARIABLE(z)
T result = 0;
T x_k = -1;
T denom = T(1) - n;
T fact = 1;
unsigned k = 0;
for(; k < n - 1;)
{
result += x_k / (denom * fact);
denom += 1;
x_k *= -z;
fact *= ++k;
}
BOOST_MATH_INSTRUMENT_VARIABLE(result)
result += pow(-z, static_cast<T>(n - 1))
* (boost::math::digamma(static_cast<T>(n)) - log(z)) / fact;
BOOST_MATH_INSTRUMENT_VARIABLE(result)
expint_series<T> s(k, z, x_k, denom, fact);
result = tools::sum_series(s, policies::get_epsilon<T, Policy>(), max_iter, result);
policies::check_series_iterations<T>("boost::math::expint_series<%1%>(unsigned,%1%)", max_iter, pol);
BOOST_MATH_INSTRUMENT_VARIABLE(result)
BOOST_MATH_INSTRUMENT_VARIABLE(max_iter)
return result;
}
template <class T, class Policy, class Tag>
T expint_imp(unsigned n, T z, const Policy& pol, const Tag& tag)
{
BOOST_MATH_STD_USING
static const char* function = "boost::math::expint<%1%>(unsigned, %1%)";
if(z < 0)
return policies::raise_domain_error<T>(function, "Function requires z >= 0 but got %1%.", z, pol);
if(z == 0)
return n == 1 ? policies::raise_overflow_error<T>(function, 0, pol) : T(1 / (static_cast<T>(n - 1)));
T result;
bool f;
if(n < 3)
{
f = z < 0.5;
}
else
{
f = z < (static_cast<T>(n - 2) / static_cast<T>(n - 1));
}
#ifdef BOOST_MSVC
# pragma warning(push)
# pragma warning(disable:4127) // conditional expression is constant
#endif
if(n == 0)
result = exp(-z) / z;
else if((n == 1) && (Tag::value))
{
result = expint_1_rational(z, tag);
}
else if(f)
result = expint_as_series(n, z, pol);
else
result = expint_as_fraction(n, z, pol);
#ifdef BOOST_MSVC
# pragma warning(pop)
#endif
return result;
}
template <class T>
struct expint_i_series
{
typedef T result_type;
expint_i_series(T z_) : k(0), z_k(1), z(z_){}
T operator()()
{
z_k *= z / ++k;
return z_k / k;
}
private:
unsigned k;
T z_k;
T z;
};
template <class T, class Policy>
T expint_i_as_series(T z, const Policy& pol)
{
BOOST_MATH_STD_USING
T result = log(z); // (log(z) - log(1 / z)) / 2;
result += constants::euler<T>();
expint_i_series<T> s(z);
boost::uintmax_t max_iter = policies::get_max_series_iterations<Policy>();
result = tools::sum_series(s, policies::get_epsilon<T, Policy>(), max_iter, result);
policies::check_series_iterations<T>("boost::math::expint_i_series<%1%>(%1%)", max_iter, pol);
return result;
}
template <class T, class Policy, class Tag>
T expint_i_imp(T z, const Policy& pol, const Tag& tag)
{
static const char* function = "boost::math::expint<%1%>(%1%)";
if(z < 0)
return -expint_imp(1, T(-z), pol, tag);
if(z == 0)
return -policies::raise_overflow_error<T>(function, 0, pol);
return expint_i_as_series(z, pol);
}
template <class T, class Policy>
T expint_i_imp(T z, const Policy& pol, const mpl::int_<53>& tag)
{
BOOST_MATH_STD_USING
static const char* function = "boost::math::expint<%1%>(%1%)";
if(z < 0)
return -expint_imp(1, T(-z), pol, tag);
if(z == 0)
return -policies::raise_overflow_error<T>(function, 0, pol);
T result;
if(z <= 6)
{
// Maximum Deviation Found: 2.852e-18
// Expected Error Term: 2.852e-18
// Max Error found at double precision = Poly: 2.636335e-16 Cheb: 4.187027e-16
static const T P[10] = {
BOOST_MATH_BIG_CONSTANT(T, 53, 2.98677224343598593013),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.356343618769377415068),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.780836076283730801839),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.114670926327032002811),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.0499434773576515260534),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.00726224593341228159561),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.00115478237227804306827),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.000116419523609765200999),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.798296365679269702435e-5),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.2777056254402008721e-6)
};
static const T Q[8] = {
BOOST_MATH_BIG_CONSTANT(T, 53, 1),
BOOST_MATH_BIG_CONSTANT(T, 53, -1.17090412365413911947),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.62215109846016746276),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.195114782069495403315),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.0391523431392967238166),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.00504800158663705747345),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.000389034007436065401822),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.138972589601781706598e-4)
};
static const T c1 = BOOST_MATH_BIG_CONSTANT(T, 53, 1677624236387711.0);
static const T c2 = BOOST_MATH_BIG_CONSTANT(T, 53, 4503599627370496.0);
static const T r1 = static_cast<T>(c1 / c2);
static const T r2 = BOOST_MATH_BIG_CONSTANT(T, 53, 0.131401834143860282009280387409357165515556574352422001206362e-16);
static const T r = static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 53, 0.372507410781366634461991866580119133535689497771654051555657435242200120636201854384926049951548942392));
T t = (z / 3) - 1;
result = tools::evaluate_polynomial(P, t)
/ tools::evaluate_polynomial(Q, t);
t = (z - r1) - r2;
result *= t;
if(fabs(t) < 0.1)
{
result += boost::math::log1p(t / r);
}
else
{
result += log(z / r);
}
}
else if (z <= 10)
{
// Maximum Deviation Found: 6.546e-17
// Expected Error Term: 6.546e-17
// Max Error found at double precision = Poly: 6.890169e-17 Cheb: 6.772128e-17
static const T Y = 1.158985137939453125F;
static const T P[8] = {
BOOST_MATH_BIG_CONSTANT(T, 53, 0.00139324086199402804173),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.0349921221823888744966),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.0264095520754134848538),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.00761224003005476438412),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.00247496209592143627977),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.000374885917942100256775),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.554086272024881826253e-4),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.396487648924804510056e-5)
};
static const T Q[8] = {
BOOST_MATH_BIG_CONSTANT(T, 53, 1),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.744625566823272107711),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.329061095011767059236),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.100128624977313872323),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.0223851099128506347278),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.00365334190742316650106),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.000402453408512476836472),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.263649630720255691787e-4)
};
T t = z / 2 - 4;
result = Y + tools::evaluate_polynomial(P, t)
/ tools::evaluate_polynomial(Q, t);
result *= exp(z) / z;
result += z;
}
else if(z <= 20)
{
// Maximum Deviation Found: 1.843e-17
// Expected Error Term: -1.842e-17
// Max Error found at double precision = Poly: 4.375868e-17 Cheb: 5.860967e-17
static const T Y = 1.0869731903076171875F;
static const T P[9] = {
BOOST_MATH_BIG_CONSTANT(T, 53, -0.00893891094356945667451),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.0484607730127134045806),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.0652810444222236895772),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.0478447572647309671455),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.0226059218923777094596),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.00720603636917482065907),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.00155941947035972031334),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.000209750022660200888349),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.138652200349182596186e-4)
};
static const T Q[9] = {
BOOST_MATH_BIG_CONSTANT(T, 53, 1),
BOOST_MATH_BIG_CONSTANT(T, 53, 1.97017214039061194971),
BOOST_MATH_BIG_CONSTANT(T, 53, 1.86232465043073157508),
BOOST_MATH_BIG_CONSTANT(T, 53, 1.09601437090337519977),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.438873285773088870812),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.122537731979686102756),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.0233458478275769288159),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.00278170769163303669021),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.000159150281166108755531)
};
T t = z / 5 - 3;
result = Y + tools::evaluate_polynomial(P, t)
/ tools::evaluate_polynomial(Q, t);
result *= exp(z) / z;
result += z;
}
else if(z <= 40)
{
// Maximum Deviation Found: 5.102e-18
// Expected Error Term: 5.101e-18
// Max Error found at double precision = Poly: 1.441088e-16 Cheb: 1.864792e-16
static const T Y = 1.03937530517578125F;
static const T P[9] = {
BOOST_MATH_BIG_CONSTANT(T, 53, -0.00356165148914447597995),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.0229930320357982333406),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.0449814350482277917716),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.0453759383048193402336),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.0272050837209380717069),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.00994403059883350813295),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.00207592267812291726961),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.000192178045857733706044),
BOOST_MATH_BIG_CONSTANT(T, 53, -0.113161784705911400295e-9)
};
static const T Q[9] = {
BOOST_MATH_BIG_CONSTANT(T, 53, 1),
BOOST_MATH_BIG_CONSTANT(T, 53, 2.84354408840148561131),
BOOST_MATH_BIG_CONSTANT(T, 53, 3.6599610090072393012),
BOOST_MATH_BIG_CONSTANT(T, 53, 2.75088464344293083595),
BOOST_MATH_BIG_CONSTANT(T, 53, 1.2985244073998398643),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.383213198510794507409),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.0651165455496281337831),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.00488071077519227853585)
};
T t = z / 10 - 3;
result = Y + tools::evaluate_polynomial(P, t)
/ tools::evaluate_polynomial(Q, t);
result *= exp(z) / z;
result += z;
}
else
{
// Max Error found at double precision = 3.381886e-17
static const T exp40 = static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 53, 2.35385266837019985407899910749034804508871617254555467236651e17));
static const T Y= 1.013065338134765625F;
static const T P[6] = {
BOOST_MATH_BIG_CONSTANT(T, 53, -0.0130653381347656243849),
BOOST_MATH_BIG_CONSTANT(T, 53, 0.19029710559486576682),
BOOST_MATH_BIG_CONSTANT(T, 53, 94.7365094537197236011),
BOOST_MATH_BIG_CONSTANT(T, 53, -2516.35323679844256203),
BOOST_MATH_BIG_CONSTANT(T, 53, 18932.0850014925993025),
BOOST_MATH_BIG_CONSTANT(T, 53, -38703.1431362056714134)
};
static const T Q[7] = {
BOOST_MATH_BIG_CONSTANT(T, 53, 1),
BOOST_MATH_BIG_CONSTANT(T, 53, 61.9733592849439884145),
BOOST_MATH_BIG_CONSTANT(T, 53, -2354.56211323420194283),
BOOST_MATH_BIG_CONSTANT(T, 53, 22329.1459489893079041),
BOOST_MATH_BIG_CONSTANT(T, 53, -70126.245140396567133),
BOOST_MATH_BIG_CONSTANT(T, 53, 54738.2833147775537106),
BOOST_MATH_BIG_CONSTANT(T, 53, 8297.16296356518409347)
};
T t = 1 / z;
result = Y + tools::evaluate_polynomial(P, t)
/ tools::evaluate_polynomial(Q, t);
if(z < 41)
result *= exp(z) / z;
else
{
// Avoid premature overflow if we can:
t = z - 40;
if(t > tools::log_max_value<T>())
{
result = policies::raise_overflow_error<T>(function, 0, pol);
}
else
{
result *= exp(z - 40) / z;
if(result > tools::max_value<T>() / exp40)
{
result = policies::raise_overflow_error<T>(function, 0, pol);
}
else
{
result *= exp40;
}
}
}
result += z;
}
return result;
}
template <class T, class Policy>
T expint_i_imp(T z, const Policy& pol, const mpl::int_<64>& tag)
{
BOOST_MATH_STD_USING
static const char* function = "boost::math::expint<%1%>(%1%)";
if(z < 0)
return -expint_imp(1, T(-z), pol, tag);
if(z == 0)
return -policies::raise_overflow_error<T>(function, 0, pol);
T result;
if(z <= 6)
{
// Maximum Deviation Found: 3.883e-21
// Expected Error Term: 3.883e-21
// Max Error found at long double precision = Poly: 3.344801e-19 Cheb: 4.989937e-19
static const T P[11] = {
BOOST_MATH_BIG_CONSTANT(T, 64, 2.98677224343598593764),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.25891613550886736592),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.789323584998672832285),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.092432587824602399339),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.0514236978728625906656),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.00658477469745132977921),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.00124914538197086254233),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.000131429679565472408551),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.11293331317982763165e-4),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.629499283139417444244e-6),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.177833045143692498221e-7)
};
static const T Q[9] = {
BOOST_MATH_BIG_CONSTANT(T, 64, 1),
BOOST_MATH_BIG_CONSTANT(T, 64, -1.20352377969742325748),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.66707904942606479811),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.223014531629140771914),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.0493340022262908008636),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.00741934273050807310677),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.00074353567782087939294),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.455861727069603367656e-4),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.131515429329812837701e-5)
};
static const T c1 = BOOST_MATH_BIG_CONSTANT(T, 64, 1677624236387711.0);
static const T c2 = BOOST_MATH_BIG_CONSTANT(T, 64, 4503599627370496.0);
static const T r1 = c1 / c2;
static const T r2 = BOOST_MATH_BIG_CONSTANT(T, 64, 0.131401834143860282009280387409357165515556574352422001206362e-16);
static const T r = static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 0.372507410781366634461991866580119133535689497771654051555657435242200120636201854384926049951548942392));
T t = (z / 3) - 1;
result = tools::evaluate_polynomial(P, t)
/ tools::evaluate_polynomial(Q, t);
t = (z - r1) - r2;
result *= t;
if(fabs(t) < 0.1)
{
result += boost::math::log1p(t / r);
}
else
{
result += log(z / r);
}
}
else if (z <= 10)
{
// Maximum Deviation Found: 2.622e-21
// Expected Error Term: -2.622e-21
// Max Error found at long double precision = Poly: 1.208328e-20 Cheb: 1.073723e-20
static const T Y = 1.158985137939453125F;
static const T P[9] = {
BOOST_MATH_BIG_CONSTANT(T, 64, 0.00139324086199409049399),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.0345238388952337563247),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.0382065278072592940767),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.0156117003070560727392),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.00383276012430495387102),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.000697070540945496497992),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.877310384591205930343e-4),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.623067256376494930067e-5),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.377246883283337141444e-6)
};
static const T Q[10] = {
BOOST_MATH_BIG_CONSTANT(T, 64, 1),
BOOST_MATH_BIG_CONSTANT(T, 64, 1.08073635708902053767),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.553681133533942532909),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.176763647137553797451),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.0387891748253869928121),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.0060603004848394727017),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.000670519492939992806051),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.4947357050100855646e-4),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.204339282037446434827e-5),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.146951181174930425744e-7)
};
T t = z / 2 - 4;
result = Y + tools::evaluate_polynomial(P, t)
/ tools::evaluate_polynomial(Q, t);
result *= exp(z) / z;
result += z;
}
else if(z <= 20)
{
// Maximum Deviation Found: 3.220e-20
// Expected Error Term: 3.220e-20
// Max Error found at long double precision = Poly: 7.696841e-20 Cheb: 6.205163e-20
static const T Y = 1.0869731903076171875F;
static const T P[10] = {
BOOST_MATH_BIG_CONSTANT(T, 64, -0.00893891094356946995368),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.0487562980088748775943),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.0670568657950041926085),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.0509577352851442932713),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.02551800927409034206),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.00892913759760086687083),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.00224469630207344379888),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.000392477245911296982776),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.44424044184395578775e-4),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.252788029251437017959e-5)
};
static const T Q[10] = {
BOOST_MATH_BIG_CONSTANT(T, 64, 1),
BOOST_MATH_BIG_CONSTANT(T, 64, 2.00323265503572414261),
BOOST_MATH_BIG_CONSTANT(T, 64, 1.94688958187256383178),
BOOST_MATH_BIG_CONSTANT(T, 64, 1.19733638134417472296),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.513137726038353385661),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.159135395578007264547),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.0358233587351620919881),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.0056716655597009417875),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.000577048986213535829925),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.290976943033493216793e-4)
};
T t = z / 5 - 3;
result = Y + tools::evaluate_polynomial(P, t)
/ tools::evaluate_polynomial(Q, t);
result *= exp(z) / z;
result += z;
}
else if(z <= 40)
{
// Maximum Deviation Found: 2.940e-21
// Expected Error Term: -2.938e-21
// Max Error found at long double precision = Poly: 3.419893e-19 Cheb: 3.359874e-19
static const T Y = 1.03937530517578125F;
static const T P[12] = {
BOOST_MATH_BIG_CONSTANT(T, 64, -0.00356165148914447278177),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.0240235006148610849678),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.0516699967278057976119),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.0586603078706856245674),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.0409960120868776180825),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.0185485073689590665153),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.00537842101034123222417),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.000920988084778273760609),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.716742618812210980263e-4),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.504623302166487346677e-9),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.712662196671896837736e-10),
BOOST_MATH_BIG_CONSTANT(T, 64, -0.533769629702262072175e-11)
};
static const T Q[9] = {
BOOST_MATH_BIG_CONSTANT(T, 64, 1),
BOOST_MATH_BIG_CONSTANT(T, 64, 3.13286733695729715455),
BOOST_MATH_BIG_CONSTANT(T, 64, 4.49281223045653491929),
BOOST_MATH_BIG_CONSTANT(T, 64, 3.84900294427622911374),
BOOST_MATH_BIG_CONSTANT(T, 64, 2.15205199043580378211),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.802912186540269232424),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.194793170017818925388),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.0280128013584653182994),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.00182034930799902922549)
};
T t = z / 10 - 3;
result = Y + tools::evaluate_polynomial(P, t)
/ tools::evaluate_polynomial(Q, t);
BOOST_MATH_INSTRUMENT_VARIABLE(result)
result *= exp(z) / z;
BOOST_MATH_INSTRUMENT_VARIABLE(result)
result += z;
BOOST_MATH_INSTRUMENT_VARIABLE(result)
}
else
{
// Maximum Deviation Found: 3.536e-20
// Max Error found at long double precision = Poly: 1.310671e-19 Cheb: 8.630943e-11
static const T exp40 = static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 2.35385266837019985407899910749034804508871617254555467236651e17));
static const T Y= 1.013065338134765625F;
static const T P[9] = {
BOOST_MATH_BIG_CONSTANT(T, 64, -0.0130653381347656250004),
BOOST_MATH_BIG_CONSTANT(T, 64, 0.644487780349757303739),
BOOST_MATH_BIG_CONSTANT(T, 64, 143.995670348227433964),
BOOST_MATH_BIG_CONSTANT(T, 64, -13918.9322758014173709),
BOOST_MATH_BIG_CONSTANT(T, 64, 476260.975133624194484),
BOOST_MATH_BIG_CONSTANT(T, 64, -7437102.15135982802122),
BOOST_MATH_BIG_CONSTANT(T, 64, 53732298.8764767916542),
BOOST_MATH_BIG_CONSTANT(T, 64, -160695051.957997452509),
BOOST_MATH_BIG_CONSTANT(T, 64, 137839271.592778020028)
};
static const T Q[9] = {
BOOST_MATH_BIG_CONSTANT(T, 64, 1),
BOOST_MATH_BIG_CONSTANT(T, 64, 27.2103343964943718802),
BOOST_MATH_BIG_CONSTANT(T, 64, -8785.48528692879413676),
BOOST_MATH_BIG_CONSTANT(T, 64, 397530.290000322626766),
BOOST_MATH_BIG_CONSTANT(T, 64, -7356441.34957799368252),
BOOST_MATH_BIG_CONSTANT(T, 64, 63050914.5343400957524),
BOOST_MATH_BIG_CONSTANT(T, 64, -246143779.638307701369),
BOOST_MATH_BIG_CONSTANT(T, 64, 384647824.678554961174),
BOOST_MATH_BIG_CONSTANT(T, 64, -166288297.874583961493)
};
T t = 1 / z;
result = Y + tools::evaluate_polynomial(P, t)
/ tools::evaluate_polynomial(Q, t);
if(z < 41)
result *= exp(z) / z;
else
{
// Avoid premature overflow if we can:
t = z - 40;
if(t > tools::log_max_value<T>())
{
result = policies::raise_overflow_error<T>(function, 0, pol);
}
else
{
result *= exp(z - 40) / z;
if(result > tools::max_value<T>() / exp40)
{
result = policies::raise_overflow_error<T>(function, 0, pol);
}
else
{
result *= exp40;
}
}
}
result += z;
}
return result;
}
template <class T>
void expint_i_imp_113a(T& result, const T& z)
{
BOOST_MATH_STD_USING
// Maximum Deviation Found: 1.230e-36
// Expected Error Term: -1.230e-36
// Max Error found at long double precision = Poly: 4.355299e-34 Cheb: 7.512581e-34
static const T P[15] = {
BOOST_MATH_BIG_CONSTANT(T, 113, 2.98677224343598593765287235997328555),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.333256034674702967028780537349334037),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.851831522798101228384971644036708463),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.0657854833494646206186773614110374948),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.0630065662557284456000060708977935073),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.00311759191425309373327784154659649232),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.00176213568201493949664478471656026771),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.491548660404172089488535218163952295e-4),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.207764227621061706075562107748176592e-4),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.225445398156913584846374273379402765e-6),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.996939977231410319761273881672601592e-7),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.212546902052178643330520878928100847e-9),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.154646053060262871360159325115980023e-9),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.143971277122049197323415503594302307e-11),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.306243138978114692252817805327426657e-13)
};
static const T Q[15] = {
BOOST_MATH_BIG_CONSTANT(T, 113, 1),
BOOST_MATH_BIG_CONSTANT(T, 113, -1.40178870313943798705491944989231793),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.943810968269701047641218856758605284),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.405026631534345064600850391026113165),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.123924153524614086482627660399122762),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.0286364505373369439591132549624317707),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.00516148845910606985396596845494015963),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.000738330799456364820380739850924783649),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.843737760991856114061953265870882637e-4),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.767957673431982543213661388914587589e-5),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.549136847313854595809952100614840031e-6),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.299801381513743676764008325949325404e-7),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.118419479055346106118129130945423483e-8),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.30372295663095470359211949045344607e-10),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.382742953753485333207877784720070523e-12)
};
static const T c1 = BOOST_MATH_BIG_CONSTANT(T, 113, 1677624236387711.0);
static const T c2 = BOOST_MATH_BIG_CONSTANT(T, 113, 4503599627370496.0);
static const T c3 = BOOST_MATH_BIG_CONSTANT(T, 113, 266514582277687.0);
static const T c4 = BOOST_MATH_BIG_CONSTANT(T, 113, 4503599627370496.0);
static const T c5 = BOOST_MATH_BIG_CONSTANT(T, 113, 4503599627370496.0);
static const T r1 = c1 / c2;
static const T r2 = c3 / c4 / c5;
static const T r3 = static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 113, 0.283806480836357377069325311780969887585024578164571984232357e-31));
static const T r = static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 113, 0.372507410781366634461991866580119133535689497771654051555657435242200120636201854384926049951548942392));
T t = (z / 3) - 1;
result = tools::evaluate_polynomial(P, t)
/ tools::evaluate_polynomial(Q, t);
t = ((z - r1) - r2) - r3;
result *= t;
if(fabs(t) < 0.1)
{
result += boost::math::log1p(t / r);
}
else
{
result += log(z / r);
}
}
template <class T>
void expint_i_113b(T& result, const T& z)
{
BOOST_MATH_STD_USING
// Maximum Deviation Found: 7.779e-36
// Expected Error Term: -7.779e-36
// Max Error found at long double precision = Poly: 2.576723e-35 Cheb: 1.236001e-34
static const T Y = 1.158985137939453125F;
static const T P[15] = {
BOOST_MATH_BIG_CONSTANT(T, 113, 0.00139324086199409049282472239613554817),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.0338173111691991289178779840307998955),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.0555972290794371306259684845277620556),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.0378677976003456171563136909186202177),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.0152221583517528358782902783914356667),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.00428283334203873035104248217403126905),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.000922782631491644846511553601323435286),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.000155513428088853161562660696055496696),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.205756580255359882813545261519317096e-4),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.220327406578552089820753181821115181e-5),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.189483157545587592043421445645377439e-6),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.122426571518570587750898968123803867e-7),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.635187358949437991465353268374523944e-9),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.203015132965870311935118337194860863e-10),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.384276705503357655108096065452950822e-12)
};
static const T Q[15] = {
BOOST_MATH_BIG_CONSTANT(T, 113, 1),
BOOST_MATH_BIG_CONSTANT(T, 113, 1.58784732785354597996617046880946257),
BOOST_MATH_BIG_CONSTANT(T, 113, 1.18550755302279446339364262338114098),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.55598993549661368604527040349702836),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.184290888380564236919107835030984453),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.0459658051803613282360464632326866113),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.0089505064268613225167835599456014705),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.00139042673882987693424772855926289077),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.000174210708041584097450805790176479012),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.176324034009707558089086875136647376e-4),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.142935845999505649273084545313710581e-5),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.907502324487057260675816233312747784e-7),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.431044337808893270797934621235918418e-8),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.139007266881450521776529705677086902e-9),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.234715286125516430792452741830364672e-11)
};
T t = z / 2 - 4;
result = Y + tools::evaluate_polynomial(P, t)
/ tools::evaluate_polynomial(Q, t);
result *= exp(z) / z;
result += z;
}
template <class T>
void expint_i_113c(T& result, const T& z)
{
BOOST_MATH_STD_USING
// Maximum Deviation Found: 1.082e-34
// Expected Error Term: 1.080e-34
// Max Error found at long double precision = Poly: 1.958294e-34 Cheb: 2.472261e-34
static const T Y = 1.091579437255859375F;
static const T P[17] = {
BOOST_MATH_BIG_CONSTANT(T, 113, -0.00685089599550151282724924894258520532),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.0443313550253580053324487059748497467),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.071538561252424027443296958795814874),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.0622923153354102682285444067843300583),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.0361631270264607478205393775461208794),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.0153192826839624850298106509601033261),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.00496967904961260031539602977748408242),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.00126989079663425780800919171538920589),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.000258933143097125199914724875206326698),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.422110326689204794443002330541441956e-4),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.546004547590412661451073996127115221e-5),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.546775260262202177131068692199272241e-6),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.404157632825805803833379568956559215e-7),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.200612596196561323832327013027419284e-8),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.502538501472133913417609379765434153e-10),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.326283053716799774936661568391296584e-13),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.869226483473172853557775877908693647e-15)
};
static const T Q[15] = {
BOOST_MATH_BIG_CONSTANT(T, 113, 1),
BOOST_MATH_BIG_CONSTANT(T, 113, 2.23227220874479061894038229141871087),
BOOST_MATH_BIG_CONSTANT(T, 113, 2.40221000361027971895657505660959863),
BOOST_MATH_BIG_CONSTANT(T, 113, 1.65476320985936174728238416007084214),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.816828602963895720369875535001248227),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.306337922909446903672123418670921066),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.0902400121654409267774593230720600752),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.0212708882169429206498765100993228086),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.00404442626252467471957713495828165491),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.0006195601618842253612635241404054589),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.755930932686543009521454653994321843e-4),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.716004532773778954193609582677482803e-5),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.500881663076471627699290821742924233e-6),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.233593219218823384508105943657387644e-7),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.554900353169148897444104962034267682e-9)
};
T t = z / 4 - 3.5;
result = Y + tools::evaluate_polynomial(P, t)
/ tools::evaluate_polynomial(Q, t);
result *= exp(z) / z;
result += z;
}
template <class T>
void expint_i_113d(T& result, const T& z)
{
BOOST_MATH_STD_USING
// Maximum Deviation Found: 3.163e-35
// Expected Error Term: 3.163e-35
// Max Error found at long double precision = Poly: 4.158110e-35 Cheb: 5.385532e-35
static const T Y = 1.051731109619140625F;
static const T P[14] = {
BOOST_MATH_BIG_CONSTANT(T, 113, -0.00144552494420652573815404828020593565),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.0126747451594545338365684731262912741),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.01757394877502366717526779263438073),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.0126838952395506921945756139424722588),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.0060045057928894974954756789352443522),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.00205349237147226126653803455793107903),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.000532606040579654887676082220195624207),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.000107344687098019891474772069139014662),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.169536802705805811859089949943435152e-4),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.20863311729206543881826553010120078e-5),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.195670358542116256713560296776654385e-6),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.133291168587253145439184028259772437e-7),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.595500337089495614285777067722823397e-9),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.133141358866324100955927979606981328e-10)
};
static const T Q[14] = {
BOOST_MATH_BIG_CONSTANT(T, 113, 1),
BOOST_MATH_BIG_CONSTANT(T, 113, 1.72490783907582654629537013560044682),
BOOST_MATH_BIG_CONSTANT(T, 113, 1.44524329516800613088375685659759765),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.778241785539308257585068744978050181),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.300520486589206605184097270225725584),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.0879346899691339661394537806057953957),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.0200802415843802892793583043470125006),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.00362842049172586254520256100538273214),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.000519731362862955132062751246769469957),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.584092147914050999895178697392282665e-4),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.501851497707855358002773398333542337e-5),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.313085677467921096644895738538865537e-6),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.127552010539733113371132321521204458e-7),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.25737310826983451144405899970774587e-9)
};
T t = z / 4 - 5.5;
result = Y + tools::evaluate_polynomial(P, t)
/ tools::evaluate_polynomial(Q, t);
BOOST_MATH_INSTRUMENT_VARIABLE(result)
result *= exp(z) / z;
BOOST_MATH_INSTRUMENT_VARIABLE(result)
result += z;
BOOST_MATH_INSTRUMENT_VARIABLE(result)
}
template <class T>
void expint_i_113e(T& result, const T& z)
{
BOOST_MATH_STD_USING
// Maximum Deviation Found: 7.972e-36
// Expected Error Term: 7.962e-36
// Max Error found at long double precision = Poly: 1.711721e-34 Cheb: 3.100018e-34
static const T Y = 1.032726287841796875F;
static const T P[15] = {
BOOST_MATH_BIG_CONSTANT(T, 113, -0.00141056919297307534690895009969373233),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.0123384175302540291339020257071411437),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.0298127270706864057791526083667396115),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.0390686759471630584626293670260768098),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.0338226792912607409822059922949035589),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.0211659736179834946452561197559654582),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.0100428887460879377373158821400070313),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.00370717396015165148484022792801682932),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.0010768667551001624764329000496561659),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.000246127328761027039347584096573123531),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.437318110527818613580613051861991198e-4),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.587532682329299591501065482317771497e-5),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.565697065670893984610852937110819467e-6),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.350233957364028523971768887437839573e-7),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.105428907085424234504608142258423505e-8)
};
static const T Q[16] = {
BOOST_MATH_BIG_CONSTANT(T, 113, 1),
BOOST_MATH_BIG_CONSTANT(T, 113, 3.17261315255467581204685605414005525),
BOOST_MATH_BIG_CONSTANT(T, 113, 4.85267952971640525245338392887217426),
BOOST_MATH_BIG_CONSTANT(T, 113, 4.74341914912439861451492872946725151),
BOOST_MATH_BIG_CONSTANT(T, 113, 3.31108463283559911602405970817931801),
BOOST_MATH_BIG_CONSTANT(T, 113, 1.74657006336994649386607925179848899),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.718255607416072737965933040353653244),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.234037553177354542791975767960643864),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.0607470145906491602476833515412605389),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.0125048143774226921434854172947548724),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.00201034366420433762935768458656609163),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.000244823338417452367656368849303165721),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.213511655166983177960471085462540807e-4),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.119323998465870686327170541547982932e-5),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.322153582559488797803027773591727565e-7),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.161635525318683508633792845159942312e-16)
};
T t = z / 8 - 4.25;
result = Y + tools::evaluate_polynomial(P, t)
/ tools::evaluate_polynomial(Q, t);
BOOST_MATH_INSTRUMENT_VARIABLE(result)
result *= exp(z) / z;
BOOST_MATH_INSTRUMENT_VARIABLE(result)
result += z;
BOOST_MATH_INSTRUMENT_VARIABLE(result)
}
template <class T>
void expint_i_113f(T& result, const T& z)
{
BOOST_MATH_STD_USING
// Maximum Deviation Found: 4.469e-36
// Expected Error Term: 4.468e-36
// Max Error found at long double precision = Poly: 1.288958e-35 Cheb: 2.304586e-35
static const T Y = 1.0216197967529296875F;
static const T P[12] = {
BOOST_MATH_BIG_CONSTANT(T, 113, -0.000322999116096627043476023926572650045),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.00385606067447365187909164609294113346),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.00686514524727568176735949971985244415),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.00606260649593050194602676772589601799),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.00334382362017147544335054575436194357),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.00126108534260253075708625583630318043),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.000337881489347846058951220431209276776),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.648480902304640018785370650254018022e-4),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.87652644082970492211455290209092766e-5),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.794712243338068631557849449519994144e-6),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.434084023639508143975983454830954835e-7),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.107839681938752337160494412638656696e-8)
};
static const T Q[12] = {
BOOST_MATH_BIG_CONSTANT(T, 113, 1),
BOOST_MATH_BIG_CONSTANT(T, 113, 2.09913805456661084097134805151524958),
BOOST_MATH_BIG_CONSTANT(T, 113, 2.07041755535439919593503171320431849),
BOOST_MATH_BIG_CONSTANT(T, 113, 1.26406517226052371320416108604874734),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.529689923703770353961553223973435569),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.159578150879536711042269658656115746),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.0351720877642000691155202082629857131),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.00565313621289648752407123620997063122),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.000646920278540515480093843570291218295),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.499904084850091676776993523323213591e-4),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.233740058688179614344680531486267142e-5),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.498800627828842754845418576305379469e-7)
};
T t = z / 7 - 7;
result = Y + tools::evaluate_polynomial(P, t)
/ tools::evaluate_polynomial(Q, t);
BOOST_MATH_INSTRUMENT_VARIABLE(result)
result *= exp(z) / z;
BOOST_MATH_INSTRUMENT_VARIABLE(result)
result += z;
BOOST_MATH_INSTRUMENT_VARIABLE(result)
}
template <class T>
void expint_i_113g(T& result, const T& z)
{
BOOST_MATH_STD_USING
// Maximum Deviation Found: 5.588e-35
// Expected Error Term: -5.566e-35
// Max Error found at long double precision = Poly: 9.976345e-35 Cheb: 8.358865e-35
static const T Y = 1.015148162841796875F;
static const T P[11] = {
BOOST_MATH_BIG_CONSTANT(T, 113, -0.000435714784725086961464589957142615216),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.00432114324353830636009453048419094314),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.0100740363285526177522819204820582424),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.0116744115827059174392383504427640362),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.00816145387784261141360062395898644652),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.00371380272673500791322744465394211508),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.00112958263488611536502153195005736563),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.000228316462389404645183269923754256664),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.29462181955852860250359064291292577e-4),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.21972450610957417963227028788460299e-5),
BOOST_MATH_BIG_CONSTANT(T, 113, -0.720558173805289167524715527536874694e-7)
};
static const T Q[11] = {
BOOST_MATH_BIG_CONSTANT(T, 113, 1),
BOOST_MATH_BIG_CONSTANT(T, 113, 2.95918362458402597039366979529287095),
BOOST_MATH_BIG_CONSTANT(T, 113, 3.96472247520659077944638411856748924),
BOOST_MATH_BIG_CONSTANT(T, 113, 3.15563251550528513747923714884142131),
BOOST_MATH_BIG_CONSTANT(T, 113, 1.64674612007093983894215359287448334),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.58695020129846594405856226787156424),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.144358385319329396231755457772362793),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.024146911506411684815134916238348063),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.0026257132337460784266874572001650153),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.000167479843750859222348869769094711093),
BOOST_MATH_BIG_CONSTANT(T, 113, 0.475673638665358075556452220192497036e-5)
};
T t = z / 14 - 5;
result = Y + tools::evaluate_polynomial(P, t)
/ tools::evaluate_polynomial(Q, t);
BOOST_MATH_INSTRUMENT_VARIABLE(result)
result *= exp(z) / z;
BOOST_MATH_INSTRUMENT_VARIABLE(result)
result += z;
BOOST_MATH_INSTRUMENT_VARIABLE(result)
}
template <class T>
void expint_i_113h(T& result, const T& z)
{
BOOST_MATH_STD_USING
// Maximum Deviation Found: 4.448e-36
// Expected Error Term: 4.445e-36
// Max Error found at long double precision = Poly: 2.058532e-35 Cheb: 2.165465e-27
static const T Y= 1.00849151611328125F;
static const T P[9] = {
BOOST_MATH_BIG_CONSTANT(T, 113, -0.0084915161132812500000001440233607358),
BOOST_MATH_BIG_CONSTANT(T, 113, 1.84479378737716028341394223076147872),
BOOST_MATH_BIG_CONSTANT(T, 113, -130.431146923726715674081563022115568),
BOOST_MATH_BIG_CONSTANT(T, 113, 4336.26945491571504885214176203512015),
BOOST_MATH_BIG_CONSTANT(T, 113, -76279.0031974974730095170437591004177),
BOOST_MATH_BIG_CONSTANT(T, 113, 729577.956271997673695191455111727774),
BOOST_MATH_BIG_CONSTANT(T, 113, -3661928.69330208734947103004900349266),
BOOST_MATH_BIG_CONSTANT(T, 113, 8570600.041606912735872059184527855),
BOOST_MATH_BIG_CONSTANT(T, 113, -6758379.93672362080947905580906028645)
};
static const T Q[10] = {
BOOST_MATH_BIG_CONSTANT(T, 113, 1),
BOOST_MATH_BIG_CONSTANT(T, 113, -99.4868026047611434569541483506091713),
BOOST_MATH_BIG_CONSTANT(T, 113, 3879.67753690517114249705089803055473),
BOOST_MATH_BIG_CONSTANT(T, 113, -76495.82413252517165830203774900806),
BOOST_MATH_BIG_CONSTANT(T, 113, 820773.726408311894342553758526282667),
BOOST_MATH_BIG_CONSTANT(T, 113, -4803087.64956923577571031564909646579),
BOOST_MATH_BIG_CONSTANT(T, 113, 14521246.227703545012713173740895477),
BOOST_MATH_BIG_CONSTANT(T, 113, -19762752.0196769712258527849159393044),
BOOST_MATH_BIG_CONSTANT(T, 113, 8354144.67882768405803322344185185517),
BOOST_MATH_BIG_CONSTANT(T, 113, 355076.853106511136734454134915432571)
};
T t = 1 / z;
result = Y + tools::evaluate_polynomial(P, t)
/ tools::evaluate_polynomial(Q, t);
result *= exp(z) / z;
result += z;
}
template <class T, class Policy>
T expint_i_imp(T z, const Policy& pol, const mpl::int_<113>& tag)
{
BOOST_MATH_STD_USING
static const char* function = "boost::math::expint<%1%>(%1%)";
if(z < 0)
return -expint_imp(1, T(-z), pol, tag);
if(z == 0)
return -policies::raise_overflow_error<T>(function, 0, pol);
T result;
if(z <= 6)
{
expint_i_imp_113a(result, z);
}
else if (z <= 10)
{
expint_i_113b(result, z);
}
else if(z <= 18)
{
expint_i_113c(result, z);
}
else if(z <= 26)
{
expint_i_113d(result, z);
}
else if(z <= 42)
{
expint_i_113e(result, z);
}
else if(z <= 56)
{
expint_i_113f(result, z);
}
else if(z <= 84)
{
expint_i_113g(result, z);
}
else if(z <= 210)
{
expint_i_113h(result, z);
}
else // z > 210
{
// Maximum Deviation Found: 3.963e-37
// Expected Error Term: 3.963e-37
// Max Error found at long double precision = Poly: 1.248049e-36 Cheb: 2.843486e-29
static const T exp40 = static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 113, 2.35385266837019985407899910749034804508871617254555467236651e17));
static const T Y= 1.00252532958984375F;
static const T P[8] = {
BOOST_MATH_BIG_CONSTANT(T, 113, -0.00252532958984375000000000000000000085),
BOOST_MATH_BIG_CONSTANT(T, 113, 1.16591386866059087390621952073890359),
BOOST_MATH_BIG_CONSTANT(T, 113, -67.8483431314018462417456828499277579),
BOOST_MATH_BIG_CONSTANT(T, 113, 1567.68688154683822956359536287575892),
BOOST_MATH_BIG_CONSTANT(T, 113, -17335.4683325819116482498725687644986),
BOOST_MATH_BIG_CONSTANT(T, 113, 93632.6567462673524739954389166550069),
BOOST_MATH_BIG_CONSTANT(T, 113, -225025.189335919133214440347510936787),
BOOST_MATH_BIG_CONSTANT(T, 113, 175864.614717440010942804684741336853)
};
static const T Q[9] = {
BOOST_MATH_BIG_CONSTANT(T, 113, 1),
BOOST_MATH_BIG_CONSTANT(T, 113, -65.6998869881600212224652719706425129),
BOOST_MATH_BIG_CONSTANT(T, 113, 1642.73850032324014781607859416890077),
BOOST_MATH_BIG_CONSTANT(T, 113, -19937.2610222467322481947237312818575),
BOOST_MATH_BIG_CONSTANT(T, 113, 124136.267326632742667972126625064538),
BOOST_MATH_BIG_CONSTANT(T, 113, -384614.251466704550678760562965502293),
BOOST_MATH_BIG_CONSTANT(T, 113, 523355.035910385688578278384032026998),
BOOST_MATH_BIG_CONSTANT(T, 113, -217809.552260834025885677791936351294),
BOOST_MATH_BIG_CONSTANT(T, 113, -8555.81719551123640677261226549550872)
};
T t = 1 / z;
result = Y + tools::evaluate_polynomial(P, t)
/ tools::evaluate_polynomial(Q, t);
if(z < 41)
result *= exp(z) / z;
else
{
// Avoid premature overflow if we can:
t = z - 40;
if(t > tools::log_max_value<T>())
{
result = policies::raise_overflow_error<T>(function, 0, pol);
}
else
{
result *= exp(z - 40) / z;
if(result > tools::max_value<T>() / exp40)
{
result = policies::raise_overflow_error<T>(function, 0, pol);
}
else
{
result *= exp40;
}
}
}
result += z;
}
return result;
}
template <class T, class Policy, class tag>
struct expint_i_initializer
{
struct init
{
init()
{
do_init(tag());
}
static void do_init(const mpl::int_<0>&){}
static void do_init(const mpl::int_<53>&)
{
boost::math::expint(T(5));
boost::math::expint(T(7));
boost::math::expint(T(18));
boost::math::expint(T(38));
boost::math::expint(T(45));
}
static void do_init(const mpl::int_<64>&)
{
boost::math::expint(T(5));
boost::math::expint(T(7));
boost::math::expint(T(18));
boost::math::expint(T(38));
boost::math::expint(T(45));
}
static void do_init(const mpl::int_<113>&)
{
boost::math::expint(T(5));
boost::math::expint(T(7));
boost::math::expint(T(17));
boost::math::expint(T(25));
boost::math::expint(T(40));
boost::math::expint(T(50));
boost::math::expint(T(80));
boost::math::expint(T(200));
boost::math::expint(T(220));
}
void force_instantiate()const{}
};
static const init initializer;
static void force_instantiate()
{
initializer.force_instantiate();
}
};
template <class T, class Policy, class tag>
const typename expint_i_initializer<T, Policy, tag>::init expint_i_initializer<T, Policy, tag>::initializer;
template <class T, class Policy, class tag>
struct expint_1_initializer
{
struct init
{
init()
{
do_init(tag());
}
static void do_init(const mpl::int_<0>&){}
static void do_init(const mpl::int_<53>&)
{
boost::math::expint(1, T(0.5));
boost::math::expint(1, T(2));
}
static void do_init(const mpl::int_<64>&)
{
boost::math::expint(1, T(0.5));
boost::math::expint(1, T(2));
}
static void do_init(const mpl::int_<113>&)
{
boost::math::expint(1, T(0.5));
boost::math::expint(1, T(2));
boost::math::expint(1, T(6));
}
void force_instantiate()const{}
};
static const init initializer;
static void force_instantiate()
{
initializer.force_instantiate();
}
};
template <class T, class Policy, class tag>
const typename expint_1_initializer<T, Policy, tag>::init expint_1_initializer<T, Policy, tag>::initializer;
template <class T, class Policy>
inline typename tools::promote_args<T>::type
expint_forwarder(T z, const Policy& /*pol*/, mpl::true_ const&)
{
typedef typename tools::promote_args<T>::type result_type;
typedef typename policies::evaluation<result_type, Policy>::type value_type;
typedef typename policies::precision<result_type, Policy>::type precision_type;
typedef typename policies::normalise<
Policy,
policies::promote_float<false>,
policies::promote_double<false>,
policies::discrete_quantile<>,
policies::assert_undefined<> >::type forwarding_policy;
typedef typename mpl::if_<
mpl::less_equal<precision_type, mpl::int_<0> >,
mpl::int_<0>,
typename mpl::if_<
mpl::less_equal<precision_type, mpl::int_<53> >,
mpl::int_<53>, // double
typename mpl::if_<
mpl::less_equal<precision_type, mpl::int_<64> >,
mpl::int_<64>, // 80-bit long double
typename mpl::if_<
mpl::less_equal<precision_type, mpl::int_<113> >,
mpl::int_<113>, // 128-bit long double
mpl::int_<0> // too many bits, use generic version.
>::type
>::type
>::type
>::type tag_type;
expint_i_initializer<value_type, forwarding_policy, tag_type>::force_instantiate();
return policies::checked_narrowing_cast<result_type, forwarding_policy>(detail::expint_i_imp(
static_cast<value_type>(z),
forwarding_policy(),
tag_type()), "boost::math::expint<%1%>(%1%)");
}
template <class T>
inline typename tools::promote_args<T>::type
expint_forwarder(unsigned n, T z, const mpl::false_&)
{
return boost::math::expint(n, z, policies::policy<>());
}
} // namespace detail
template <class T, class Policy>
inline typename tools::promote_args<T>::type
expint(unsigned n, T z, const Policy& /*pol*/)
{
typedef typename tools::promote_args<T>::type result_type;
typedef typename policies::evaluation<result_type, Policy>::type value_type;
typedef typename policies::precision<result_type, Policy>::type precision_type;
typedef typename policies::normalise<
Policy,
policies::promote_float<false>,
policies::promote_double<false>,
policies::discrete_quantile<>,
policies::assert_undefined<> >::type forwarding_policy;
typedef typename mpl::if_<
mpl::less_equal<precision_type, mpl::int_<0> >,
mpl::int_<0>,
typename mpl::if_<
mpl::less_equal<precision_type, mpl::int_<53> >,
mpl::int_<53>, // double
typename mpl::if_<
mpl::less_equal<precision_type, mpl::int_<64> >,
mpl::int_<64>, // 80-bit long double
typename mpl::if_<
mpl::less_equal<precision_type, mpl::int_<113> >,
mpl::int_<113>, // 128-bit long double
mpl::int_<0> // too many bits, use generic version.
>::type
>::type
>::type
>::type tag_type;
detail::expint_1_initializer<value_type, forwarding_policy, tag_type>::force_instantiate();
return policies::checked_narrowing_cast<result_type, forwarding_policy>(detail::expint_imp(
n,
static_cast<value_type>(z),
forwarding_policy(),
tag_type()), "boost::math::expint<%1%>(unsigned, %1%)");
}
template <class T, class U>
inline typename detail::expint_result<T, U>::type
expint(T const z, U const u)
{
typedef typename policies::is_policy<U>::type tag_type;
return detail::expint_forwarder(z, u, tag_type());
}
template <class T>
inline typename tools::promote_args<T>::type
expint(T z)
{
return expint(z, policies::policy<>());
}
}} // namespaces
#endif // BOOST_MATH_EXPINT_HPP
| [
"tvaneerd@rim.com"
] | tvaneerd@rim.com |
61381e05454ea94182aef784df7255cf52db0371 | 541c4f648cee67b937b3a5087d69a467826aff52 | /Tests/bubble-column-mini/main-aw.cpp | fe13b0daa60614c484c19c7f568e6bcf51222977 | [] | no_license | Wentao2017/PSI-Boil-liquid-film | 9831382e5d3303a7be54f2216225f113c804c630 | 8c59435c4bc6c75bb06b17f6d4c899aee0099aa0 | refs/heads/master | 2023-05-07T05:38:07.261651 | 2021-05-31T06:28:25 | 2021-05-31T06:28:25 | 328,350,633 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 8,139 | cpp | /*-------------------------------------------------------------+
| Simulation of mini - bubble column |
| In order to retrieve Deen bubble column: |
| LX should be 0.15 instead of 0.05 |
+-------------------------------------------------------------*/
#include "Include/psi-boil.h"
#define resume false /* this is for resuming the simulation */
/* boundary conditions */
const int NX = 48; //152;
const int NZ = NX * 3;
const real RB = 0.5 * 0.004;
const real DB = 2.0 * RB;
const real LX = 0.05; //0.15;
const real LZ = LX*NZ/NX;
const int nholes = 2; // 7; /* this will give 7 x 7 = 49 spargers */
const real pitch = 0.00625; /* distance between two spargers */
/******************************************************************************/
main(int argc, char * argv[]) {
boil::timer.start();
/*--------------------------------+
| choose the output file format |
+--------------------------------*/
boil::plot = new PlotTEC();
/*----------+
| grid(s) |
+----------*/
Grid1D gx( Range<real>(-LX/2.0, LX/2.0),
Range<real>( LX/NX, LX/NX ),
NX, Periodic::no());
Grid1D gz( Range<real>(0.0, LZ),
Range<real>( LZ/NZ, LZ/NZ ),
NZ, Periodic::no());
/*---------+
| domain |
+---------*/
Domain d(gx, gx, gz);
/*----------------------+
| physical properties |
+----------------------*/
Matter air(d), water(d);
air.rho (1.205);
water.rho (998.2);
air.mu (1.82e-5);
water.mu (1.0e-3);
/*----------------+
| linear solver |
+----------------*/
Krylov * solver = new CG(d, Prec::di());
/*------------------+
| define unknowns |
+------------------*/
Vector uvw(d), xyz(d), de(d), uli(d);
Scalar p (d), f (d);
Scalar press(d);
Scalar c_dro(d); /* color function for the droplets */
Scalar c (d); /* color function for the bubbles */
Scalar c_sep(d, "separated"); /* separated phase */
/*-----------------------------+
| insert boundary conditions |
+-----------------------------*/
for_m(m) {
uvw.bc(m).add( BndCnd( Dir::imin(), BndType::wall() ) );
uvw.bc(m).add( BndCnd( Dir::imax(), BndType::wall() ) );
uvw.bc(m).add( BndCnd( Dir::jmin(), BndType::wall() ) );
uvw.bc(m).add( BndCnd( Dir::jmax(), BndType::wall() ) );
uvw.bc(m).add( BndCnd( Dir::kmin(), BndType::wall() ) );
uvw.bc(m).add( BndCnd( Dir::kmax(), BndType::outlet() ));
}
for_m(m) {
uli.bc(m).add( BndCnd( Dir::imin(), BndType::wall() ) );
uli.bc(m).add( BndCnd( Dir::imax(), BndType::wall() ) );
uli.bc(m).add( BndCnd( Dir::jmin(), BndType::wall() ) );
uli.bc(m).add( BndCnd( Dir::jmax(), BndType::wall() ) );
uli.bc(m).add( BndCnd( Dir::kmin(), BndType::wall() ) );
uli.bc(m).add( BndCnd( Dir::kmax(), BndType::outlet() ));
}
p.bc().add( BndCnd( Dir::imin(), BndType::neumann() ) );
p.bc().add( BndCnd( Dir::imax(), BndType::neumann() ) );
p.bc().add( BndCnd( Dir::jmin(), BndType::neumann() ) );
p.bc().add( BndCnd( Dir::jmax(), BndType::neumann() ) );
p.bc().add( BndCnd( Dir::kmin(), BndType::neumann() ) );
p.bc().add( BndCnd( Dir::kmax(), BndType::neumann() ) );
press = p.shape();
c.bc().add( BndCnd( Dir::imin(), BndType::neumann() ) );
c.bc().add( BndCnd( Dir::imax(), BndType::neumann() ) );
c.bc().add( BndCnd( Dir::jmin(), BndType::neumann() ) );
c.bc().add( BndCnd( Dir::jmax(), BndType::neumann() ) );
c.bc().add( BndCnd( Dir::kmin(), BndType::neumann() ) );
c.bc().add( BndCnd( Dir::kmax(), BndType::neumann() ) );
c_sep = p.shape();
c_dro = p.shape();
real dt = 1.0e-4;
//int n = int(120.0/dt);
int n = int(6.0/dt);
Times time(n, dt); /* ndt, dt */
/* this is for plotting the data */
//const int nsint = 120; /* 120: plot every 1 sec; 480 --> 0.25 seconds */
const int nsint = 12; /* 120: plot every 1 sec; 480 --> 0.25 seconds */
int csint = 0;
std::vector<real> save_instants;
save_instants.resize(nsint+1); /* to store last too */
for(int i=0; i<=nsint; i++) {
save_instants[i] = (real)i * time.total_time() / (real)nsint;
}
/* this is for saving the data */
const int nb_bck = 240;
int bck_ind = 0;
std::vector<real> bck_instants;
bck_instants.resize(nb_bck + 1);
for(int i = 0; i <= nb_bck; i++) {
bck_instants[i] = (real)i * time.total_time() / (real)nb_bck;
}
Matter mixed(air,water, &c_sep, &c, & c_dro);
mixed.sigma(0.072);
c_sep = 0.0;
c_sep.exchange_all();
c = 0.0;
c.exchange_all();
c_dro = 1.0;
c_dro.exchange_all();
Dispersed disp (c, & c_sep, 1, uvw, time, &mixed);
const real bubble_period = 0.01489; /* period for bubbles release */
std::vector<real> bubble_instants;
const int nbint = time.total_time()/bubble_period;
int cbint = 0;
bubble_instants.resize(nbint+1); /* to store last too */
for(int i=0; i<=nbint; i++) {
bubble_instants[i] = (real)i * bubble_period;
}
/*-----------------+
| define solvers |
+-----------------*/
Momentum ns(uvw, xyz, time, solver, &mixed);
ns.diffusion_set (TimeScheme::backward_euler());
ns.convection_set(ConvScheme::superbee());
Pressure pr(p, f, uvw, time, solver, &mixed);
AC multigrid( &pr );
multigrid.stop_if_diverging(false);
multigrid.max_cycles(30);
/*Locate a point: (0.0 ; 0.0; 0.56 * LZ); */
real xl = 0.0; real yl = 0.0; real zl = 0.56 * LZ;
int ixl = d.local_i( d.I(xl) );
int jyl = d.local_j( d.J(yl) );
int kzl = d.local_k( d.K(zl) );
#if resume
/* set resume to true when you want to resume the simulation */
/* the numbers for csint, cbint, bck_ind: you find them in the file output
Search for the word: SAVING */
time.first_step(20525); // the step from the ouput file where you have SAVING
csint= 7;
cbint= 403;
bck_ind= 13;
time.current_time(6.00041); /* select the time of the next
time step after SAVING */
uvw.load("uvw",12); /* usually this is equal to bck_ind - 1 */
press.load("press",12);
disp.load("particles",12);
time.set_dt(0.00021);/* this can be the difference between current time of
time step after Saving and the one at the SAVING */
#endif
///////////////////////////////////////////////////////////////////
// Start Time Loop //
///////////////////////////////////////////////////////////////////
for(time.start(); time.end(); time.increase()) {
for_m(m) for_vmijk(xyz,m,i,j,k) xyz[m][i][j][k] = 0.0;
/*----------+
| bubbles |
+----------*/
if(cbint <= nbint) {
if(time.current_time() > bubble_instants[cbint]) {
real xb0 = -0.5 * (nholes - 1) * pitch;
real yb0 = -0.5 * (nholes - 1)* pitch;
real zb0 = 0.0025;
for (int i = 0; i < nholes; i++) {
for (int j = 0; j < nholes; j++) {
real xb = xb0 + real(i) * pitch;
real yb = yb0 + real(j) * pitch;
disp.add(Particle( Position(xb, yb, zb0),
Diameter(0.004),
Position(0.0,0.0,0.4)));
}
}
cbint++;
boil::oout<<"ADD BUBBLES.. " << boil::endl;
disp.check_add_particles();
}
}
disp.advance(& xyz);
Comp m = Comp::w();
for_vmijk(xyz,m,i,j,k) {
xyz[m][i][j][k] -= 9.81 * xyz.dV(m,i,j,k) * mixed.rho(m,i,j,k);
}
ns.discretize();
pr.discretize();
ns.new_time_step();
ns.grad(press);
ns.solve(ResRat(1e-4));
p = 0.0;
p.exchange();
multigrid.vcycle(ResRat(1e-3));
p.exchange();
ns.project(p);
press +=p;
press.exchange();
pr.update_rhs();
time.control_dt(ns.cfl_max(), 0.5, 1.0);
if(csint <= nsint) {
if(time.current_time() > save_instants[csint]) {
boil::plot->plot(uvw, c, "uvw-c-press", csint);
csint++;
}
}
}
boil::oout << "finished" << boil::endl;
boil::timer.stop();
boil::timer.report();
}
| [
"guow@eu-login-06.euler.ethz.ch"
] | guow@eu-login-06.euler.ethz.ch |
cf3aad347a678c3f16c424df60f7f829cab0d801 | b68712cb69730cfffddb4472fd2807168988cc56 | /MFC贪吃蛇小游戏/Snake/Snake.h | 0c7395ea96689ea2f241f467970e4610a56dd541 | [] | no_license | 1duyan/Game | 73c342854a46260e01bc1413cb028552e29e3f0f | 5fcdb7c9706de3f169302f83bdec3fb5e5c19482 | refs/heads/master | 2021-04-09T10:58:59.359353 | 2018-03-16T06:02:08 | 2018-03-16T06:02:08 | 125,464,626 | 2 | 0 | null | null | null | null | GB18030 | C++ | false | false | 647 | h |
// Snake.h : Snake 应用程序的主头文件
//
#pragma once
#ifndef __AFXWIN_H__
#error "在包含此文件之前包含“stdafx.h”以生成 PCH 文件"
#endif
#include "resource.h" // 主符号
// CSnakeApp:
// 有关此类的实现,请参阅 Snake.cpp
//
class CSnakeApp : public CWinAppEx
{
public:
CSnakeApp();
// 重写
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
// 实现
UINT m_nAppLook;
BOOL m_bHiColorIcons;
virtual void PreLoadState();
virtual void LoadCustomState();
virtual void SaveCustomState();
afx_msg void OnAppAbout();
DECLARE_MESSAGE_MAP()
};
extern CSnakeApp theApp;
| [
"3477323124@qq.com"
] | 3477323124@qq.com |
6df9d22871979f2a5118a568d22da3bf757163db | 856ffbdde78c4c84303eb8b3229f7afdd10dac9a | /src/moc/moc_evaluationwindow.cpp | 7606a0786f8ab79a976fb84a07d2665b136fb55e | [] | no_license | landracer/multidisplay-ARMv7--Asus-Tinkerboard | 14aa1e4d309c981c6ea0ea0a86454b86d3832309 | 0c4a1e5475a66b92bb1242d627cdf0a10195be87 | refs/heads/master | 2020-04-05T06:18:01.419882 | 2018-11-08T05:27:19 | 2018-11-08T05:27:19 | 156,632,620 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,975 | cpp | /****************************************************************************
** Meta object code from reading C++ file 'evaluationwindow.h'
**
** Created by: The Qt Meta Object Compiler version 67 (Qt 5.9.5)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../../../multidisplay-app/src/evaluation/evaluationwindow.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'evaluationwindow.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 67
#error "This file was generated using the moc from 5.9.5. 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
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
struct qt_meta_stringdata_EvaluationWindow_t {
QByteArrayData data[3];
char stringdata0[32];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
qptrdiff(offsetof(qt_meta_stringdata_EvaluationWindow_t, stringdata0) + ofs \
- idx * sizeof(QByteArrayData)) \
)
static const qt_meta_stringdata_EvaluationWindow_t qt_meta_stringdata_EvaluationWindow = {
{
QT_MOC_LITERAL(0, 0, 16), // "EvaluationWindow"
QT_MOC_LITERAL(1, 17, 13), // "writeSettings"
QT_MOC_LITERAL(2, 31, 0) // ""
},
"EvaluationWindow\0writeSettings\0"
};
#undef QT_MOC_LITERAL
static const uint qt_meta_data_EvaluationWindow[] = {
// content:
7, // revision
0, // classname
0, 0, // classinfo
1, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
1, // signalCount
// signals: name, argc, parameters, tag, flags
1, 0, 19, 2, 0x06 /* Public */,
// signals: parameters
QMetaType::Void,
0 // eod
};
void EvaluationWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
EvaluationWindow *_t = static_cast<EvaluationWindow *>(_o);
Q_UNUSED(_t)
switch (_id) {
case 0: _t->writeSettings(); break;
default: ;
}
} else if (_c == QMetaObject::IndexOfMethod) {
int *result = reinterpret_cast<int *>(_a[0]);
{
typedef void (EvaluationWindow::*_t)();
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&EvaluationWindow::writeSettings)) {
*result = 0;
return;
}
}
}
Q_UNUSED(_a);
}
const QMetaObject EvaluationWindow::staticMetaObject = {
{ &QDialog::staticMetaObject, qt_meta_stringdata_EvaluationWindow.data,
qt_meta_data_EvaluationWindow, qt_static_metacall, nullptr, nullptr}
};
const QMetaObject *EvaluationWindow::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
void *EvaluationWindow::qt_metacast(const char *_clname)
{
if (!_clname) return nullptr;
if (!strcmp(_clname, qt_meta_stringdata_EvaluationWindow.stringdata0))
return static_cast<void*>(this);
return QDialog::qt_metacast(_clname);
}
int EvaluationWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QDialog::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 1)
qt_static_metacall(this, _c, _id, _a);
_id -= 1;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 1)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 1;
}
return _id;
}
// SIGNAL 0
void EvaluationWindow::writeSettings()
{
QMetaObject::activate(this, &staticMetaObject, 0, nullptr);
}
QT_WARNING_POP
QT_END_MOC_NAMESPACE
| [
"nick.sutton@patriotlsr.com"
] | nick.sutton@patriotlsr.com |
f92e0e89f9036138f180965fec26776556992474 | 23ea7fc0dde3c46a4599241116dbb24efb763fe5 | /host/tools/configtool/standalone/wxwin/propertywin.cpp | 795716bb5ec99ed0038b2c3f489f6bdc784d08c7 | [] | no_license | metadevfoundation/ecos-ax-som-bf609 | 5a1fa24c344533f308e2cf3a40843eb2dd1ca644 | 4d587d59f5daf3e76ae44323e0bcb5463f1ce54a | refs/heads/master | 2020-12-28T21:28:53.139917 | 2014-03-12T16:53:37 | 2014-03-12T16:53:37 | 33,082,245 | 0 | 1 | null | 2020-08-30T00:56:00 | 2015-03-29T17:36:55 | C | UTF-8 | C++ | false | false | 16,564 | cpp | // ####ECOSHOSTGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of the eCos host tools.
// Copyright (C) 1998, 1999, 2000, 2008, 2009 Free Software Foundation, Inc.
//
// 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 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.
// -------------------------------------------
// ####ECOSHOSTGPLCOPYRIGHTEND####
// propertywin.cpp :
//
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): julians, jld
// Contact(s): julians
// Date: 2000/09/04
// Version: $Id: propertywin.cpp,v 1.7 2001/04/24 14:39:13 julians Exp $
// Purpose:
// Description: Implementation file for ecPropertyListCtrl
// Requires:
// Provides:
// See also:
// Known bugs:
// Usage:
//
//####DESCRIPTIONEND####
//
//===========================================================================
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#ifdef __GNUG__
#pragma implementation "propertywin.h"
#endif
// Includes other headers for precompiled compilation
#include "ecpch.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "propertywin.h"
#include "configtool.h"
#include "configitem.h"
#include "configtooldoc.h"
#include "ecutils.h"
// specify the CDL properties which are to be visible in the properties view
const std::string ecPropertyListCtrl::visible_properties [] =
{
CdlPropertyId_ActiveIf,
CdlPropertyId_BuildProc,
CdlPropertyId_Calculated,
CdlPropertyId_CancelProc,
CdlPropertyId_CheckProc,
CdlPropertyId_Compile,
CdlPropertyId_ConfirmProc,
CdlPropertyId_DecorationProc,
CdlPropertyId_DefaultValue,
CdlPropertyId_Define,
CdlPropertyId_DefineHeader,
CdlPropertyId_DefineProc,
// CdlPropertyId_Description,
CdlPropertyId_Dialog,
// CdlPropertyId_Display,
CdlPropertyId_DisplayProc,
CdlPropertyId_Doc,
CdlPropertyId_EntryProc,
CdlPropertyId_Flavor,
CdlPropertyId_DefineFormat,
CdlPropertyId_Group,
CdlPropertyId_Hardware,
CdlPropertyId_IfDefine,
CdlPropertyId_Implements,
CdlPropertyId_IncludeDir,
CdlPropertyId_IncludeFiles,
CdlPropertyId_InitProc,
CdlPropertyId_InstallProc,
CdlPropertyId_LegalValues,
CdlPropertyId_Library,
CdlPropertyId_LicenseProc,
CdlPropertyId_Make,
CdlPropertyId_Makefile,
CdlPropertyId_MakeObject,
CdlPropertyId_NoDefine,
CdlPropertyId_Object,
CdlPropertyId_Parent,
CdlPropertyId_Requires,
CdlPropertyId_Screen,
CdlPropertyId_Script,
CdlPropertyId_UpdateProc,
CdlPropertyId_Wizard
};
const wxChar* ecPropertyListCtrl::sm_fieldTypeImage[ecMAXFIELDTYPE]=
{wxT("Type"), wxT("Value"), wxT("Default"), wxT("Macro"), wxT("File"), wxT("URL"), wxT("Enabled")};
/*
* ecPropertyListCtrl
*/
IMPLEMENT_CLASS(ecPropertyListCtrl, wxListCtrl)
BEGIN_EVENT_TABLE(ecPropertyListCtrl, wxListCtrl)
EVT_RIGHT_DOWN(ecPropertyListCtrl::OnRightClick)
EVT_LEFT_DCLICK(ecPropertyListCtrl::OnDoubleClick)
END_EVENT_TABLE()
ecPropertyListCtrl::ecPropertyListCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pt,
const wxSize& sz, long style):
wxListCtrl(parent, id, pt, sz, style)
{
if (!wxGetApp().GetSettings().GetWindowSettings().GetUseDefaults() &&
wxGetApp().GetSettings().GetWindowSettings().GetFont(wxT("Properties")).Ok())
{
SetFont(wxGetApp().GetSettings().GetWindowSettings().GetFont(wxT("Properties")));
}
m_f[0]=0.25;
m_f[1]=0.75;
m_pti = NULL;
m_nFirstProperty = 0;
m_nOnSizeRecursionCount = 0;
AddColumns();
#if 0
int j;
int i = 0;
for (j = 0; j < 4; j++)
{
// Insert some dummy items
wxListItem info;
info.m_text = _("URL");
info.m_mask = wxLIST_MASK_TEXT ; // | wxLIST_MASK_IMAGE | wxLIST_MASK_DATA;
info.m_itemId = i;
info.m_image = -1;
//info.m_data = (long) doc;
long item = InsertItem(info);
SetItem(i, 1, _("redirects/interrupts.html"));
i ++;
info.m_text = _("Enabled");
info.m_mask = wxLIST_MASK_TEXT ; // | wxLIST_MASK_IMAGE | wxLIST_MASK_DATA;
info.m_itemId = i;
info.m_image = -1;
//info.m_data = (long) doc;
item = InsertItem(info);
SetItem(i, 1, _("True"));
i ++;
}
#endif
}
void ecPropertyListCtrl::OnRightClick(wxMouseEvent& event)
{
PopupMenu(wxGetApp().GetWhatsThisMenu(), event.GetX(), event.GetY());
}
void ecPropertyListCtrl::AddColumns()
{
InsertColumn(0, "Property", wxLIST_FORMAT_LEFT, 100);
InsertColumn(1, "Value", wxLIST_FORMAT_LEFT, 100);
}
void ecPropertyListCtrl::Fill(ecConfigItem *pti)
{
if(NULL==pti){
ClearAll();
AddColumns();
m_nFirstProperty=0;
m_pti=NULL;
} else /* if(pti!=m_pti) */ {
m_pti=pti;
m_nMaxValueWidth=0;
ecOptionType type=m_pti->GetOptionType();
int i;
// Initially flag all items as unnecessary - calls of SetItem or SetProperty will change this
for(i=GetItemCount()-1;i>=0;--i){
SetItemData(i,0);
}
if (m_pti->HasBool () || (ecOptionTypeNone!=type)){
SetItem(ecMacro, m_pti->GetMacro ());
}
if (m_pti->HasBool ()){
SetItem(ecEnabled, m_pti->IsEnabled() ? wxT("True") : wxT("False"));
}
if(!m_pti->GetFilename().IsEmpty()){
SetItem(ecFile, m_pti->GetFilename());
}
SetItem(ecURL, m_pti->GetURL());
if (ecOptionTypeNone!=type){
switch(type){
case ecString:
SetItem(ecValue, m_pti->StringValue());
SetItem(ecDefaultValue, m_pti->StringDefaultValue());
break;
case ecLong:
SetItem(ecValue, ecUtils::IntToStr(m_pti->Value(), wxGetApp().GetSettings().m_bHex));
SetItem(ecDefaultValue, ecUtils::IntToStr(m_pti->DefaultValue(), wxGetApp().GetSettings().m_bHex));
break;
case ecDouble:
SetItem(ecValue, ecUtils::DoubleToStr(m_pti->DoubleValue()));
SetItem(ecDefaultValue, ecUtils::DoubleToStr(m_pti->DoubleDefaultValue()));
break;
case ecEnumerated:
SetItem(ecValue,m_pti->StringValue());
SetItem(ecDefaultValue,m_pti->StringDefaultValue());
break;
default:
wxASSERT( FALSE );
break;
}
// TODO: set image
// SetItem(ecType, ecConfigItem::TreeItemTypeImage[type]);
}
// List all the properties applicable to me
const std::string name = ecUtils::UnicodeToStdStr (m_pti->GetMacro ());
if (name.size () > 0)
{
const CdlConfiguration config = wxGetApp().GetConfigToolDoc ()->GetCdlConfig ();
const CdlNode node = config->find_node (name, true);
wxASSERT (node);
const std::vector<CdlProperty> & properties = node->get_properties ();
std::vector<CdlProperty>::const_iterator property_i;
// CMapStringToPtr map; // count of each property name
wxHashTable map(wxKEY_STRING); // count of each property name
for (property_i = properties.begin (); property_i != properties.end (); property_i++) {// for each property
// get the property name
const CdlProperty &prop=*property_i;
const wxString strName(prop->get_property_name ().c_str());
enum {VISIBLE_PROPERTIES_COUNT=sizeof visible_properties/sizeof visible_properties[0]};
if (std::find (visible_properties, visible_properties + VISIBLE_PROPERTIES_COUNT, ecUtils::UnicodeToStdStr(strName)) != visible_properties + VISIBLE_PROPERTIES_COUNT) {// if the property should be displayed
// set the property arguments
wxString strPropertyArgs;
const std::vector<std::string> & argv = prop->get_argv ();
void *p;
p = (void*) map.Delete(strName);
p=(void *)((int)p+1);
map.Put(strName, (wxObject*) p);
std::vector<std::string>::const_iterator argv_i;
for (argv_i = argv.begin (); argv_i != argv.end (); argv_i++){ // for each property argument...
if (argv_i != argv.begin ()){ // ...except the first (the property name)
wxString strArg(ecUtils::StripExtraWhitespace (wxString(argv_i->c_str())));
if (strPropertyArgs.Len() + strArg.Len() + 1 > 256) {// if the string is too long for the list control
break; // no need to add any further arguments
}
strPropertyArgs += strArg; // add the argument to the string
strPropertyArgs += wxT (" "); // separate arguments by a space character
}
}
// the list control appears to display a maximum of 256 characters
int nIndex=SetItem(strName, strPropertyArgs, GetItemCount(), (int)p);
SetItemData(nIndex, (long) prop);
// display the exclamation icon if the property is in a conflicts list
bool bConflictItem =
// PropertyInConflictsList (* property_i, config->get_structural_conflicts ()) || ignore for now
PropertyInConflictsList (prop, config->get_all_conflicts ());
// TODO: set the image for a conflict item
// CListCtrl::SetItem (nIndex, 0, LVIF_IMAGE, NULL, bConflictItem ? 1 : 0, 0, 0, 0 );
}
}
}
for(i=GetItemCount()-1;i>=0;--i){
if(0==GetItemData(i)){
DeleteItem(i);
if(i<m_nFirstProperty){
m_nFirstProperty--;
}
}
}
// TODO
#if 0
CRect rect;
GetClientRect(rect);
int nAvailWidth=rect.Width()-GetColumnWidth(0);
int w=max(m_nMaxValueWidth,nAvailWidth);
m_f[1]=double(w)/double(rect.Width());
SetColumnWidth(1,w);
#endif
}
SetColumnWidth(1, wxLIST_AUTOSIZE); // resize the value column for the longest item
if (GetColumnWidth(1) < 100) // but at least wide enough for the column heading
SetColumnWidth(1, 100);
Refresh();
}
bool ecPropertyListCtrl::PropertyInConflictsList (CdlProperty property, const std::list<CdlConflict> & conflicts)
{
std::list<CdlConflict>::const_iterator conf_i;
for (conf_i = conflicts.begin (); conf_i != conflicts.end (); conf_i++) // for each conflict
if (property == (* conf_i)->get_property ())
return true;
return false;
}
void ecPropertyListCtrl::RefreshValue()
{
if (!m_pti)
return;
if (m_pti->HasBool ()){
SetItem(ecEnabled, m_pti->IsEnabled () ? wxT("True") : wxT("False"));
}
if (m_pti->GetOptionType () != ecOptionTypeNone){
SetItem(ecValue, m_pti->StringValue());
}
for (int nItem = m_nFirstProperty; nItem < GetItemCount (); nItem++)
{
CdlProperty property = (CdlProperty) GetItemData (nItem);
wxASSERT (property);
// display the exclamation icon if the property is in a conflicts list
const CdlConfiguration config = wxGetApp().GetConfigToolDoc ()->GetCdlConfig ();
bool bConflictItem =
// PropertyInConflictsList (property, config->get_structural_conflicts ()) || ignore for now
PropertyInConflictsList (property, config->get_all_conflicts ());
// TODO
// CListCtrl::SetItem (nItem, 0, LVIF_IMAGE, NULL, bConflictItem ? 1 : 0, 0, 0, 0 );
}
}
int ecPropertyListCtrl::SetItem(ecFieldType f, const wxString& value)
{
int nIndex=SetItem(sm_fieldTypeImage[f], value, m_nFirstProperty);
if(nIndex==m_nFirstProperty){
m_nFirstProperty++;
}
SetItemData(nIndex,1);
return nIndex;
}
int ecPropertyListCtrl::SetItem(const wxString& item, const wxString& value, int nInsertAs, int nRepeat)
{
wxASSERT( nInsertAs <= GetItemCount() );
int nIndex = -2;
do {
nIndex = FindItem(nIndex+1, item);
} while (--nRepeat > 0 && nIndex != -1);
if(-1==nIndex){
nIndex = InsertItem(nInsertAs, item);
}
wxListCtrl::SetItem(nIndex, 1, value);
// TODO
#if 0
CDC *pDC=GetDC();
CFont *pOldFont=pDC->SelectObject(GetFont());
m_nMaxValueWidth=max(m_nMaxValueWidth,pDC->GetTextExtent(pszValue).cx);
pDC->SelectObject(pOldFont);
ReleaseDC(pDC);
#endif
return nIndex;
}
void ecPropertyListCtrl::OnDoubleClick(wxMouseEvent& event)
{
// Double-clicked the item
int flags;
long item = HitTest(event.GetPosition(), flags);
if (item > -1)
{
const wxString strText = wxListCtrlGetItemTextColumn(*this, item,0);
if(strText == wxT("File")){
m_pti->ViewHeader();
} else if (strText == wxT("URL")) {
m_pti->ViewURL();
}
}
// TODO
#if 0
int pos=GetMessagePos();
CPoint pt(GET_X_LPARAM(pos),GET_Y_LPARAM(pos));
ScreenToClient(&pt);
int nItem=HitTest(pt,NULL);
if(GetItemData(nItem)>1){
// This is a property row
const CdlGoalExpression goal = dynamic_cast<CdlGoalExpression> ((CdlProperty) GetItemData (nItem));
if (goal){
// This is a rule row
const CdlExpression expression = goal->get_expression ();
if (1 == expression->references.size ()) // if the property contains a single reference
{
// assume that the reference is to another user visible node and try to find it
std::string macro_name = expression->references [0].get_destination_name ();
CConfigItem * pItem = CConfigTool::GetConfigToolDoc ()->Find (CString (macro_name.c_str ()));
if (pItem) // the referenced node was found so select it
{
CConfigTool::GetControlView()->GetTreeCtrl().SelectItem(pItem->HItem());
}
}
}
} else {
const CString strText(GetItemText(nItem,0));
if(strText==FieldTypeImage[File]){
m_pti->ViewHeader();
} else if (strText==FieldTypeImage[URL]) {
m_pti->ViewURL();
}
}
#endif
event.Skip();
}
| [
"aleksandr.loiko@axonim.by"
] | aleksandr.loiko@axonim.by |
ccd475ba4f6bc16b0ef772457e58f4d8181c26c4 | 92c78eb9af70455ab664702b396a1bfcc96c92f8 | /automated-driving/automated-driving/cpp/collision/boundingvolume.h | 83a9f4e3245d500be4e2ed168f9d092bab4dfd90 | [] | no_license | mr-d-self-driving/AutonomousDriving | 83c42793d3acaf99a6c89f06f31086483219f316 | 94f9ee3d2af27f5849187699f3a66e30ebc24fc2 | refs/heads/master | 2022-01-03T03:50:37.299594 | 2018-03-15T17:53:21 | 2018-03-15T17:53:21 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,816 | h | #ifndef BOUNDINGVOLUME_H_
#define BOUNDINGVOLUME_H_
#include <iostream>
#include <vector>
#include <array>
#include "collision_object.h"
namespace collision {
//class BoundingVolume : public CollisionObject {
class BoundingVolume{
public:
BoundingVolume(std::array<double,2> x, std::array<double,2> y, std::array<int,2> t, CollisionObjectConstPtr = NULL);
BoundingVolume(std::vector<BoundingVolumeConstPtr>);
virtual ~BoundingVolume() {};
//! Dispatcher functions
// bool collide(const CollisionObject& c) const;
// bool collide(const Shape& shape) const;
// bool collide(const Point& point) const;
// bool collide(const RectangleAABB& aabb) const;
// bool collide(const RectangleOBB& obb) const;
// bool collide(const Sphere& sphere) const;
// bool collide(const Triangle& triangle) const;
// bool collide(const TimeVariantCollisionObject& tvco) const;
// bool collide(const ShapeGroup& sg) const;
// bool collide(const BoundingVolume& bv) const;
// //! Print all parameters of the bounding volume
// void print(std::ostringstream &stream) const;
// virtual CollisionObjectConstPtr timeSlice(int time_idx, CollisionObjectConstPtr shared_ptr_this) const;
BoundingVolumeConstPtr getBoundingVolume() const;
bool isLeaf() const;
//! Get member variables
std::vector<BoundingVolumeConstPtr> getChildrenBoundingVolumes() const;
std::vector<CollisionObjectConstPtr> getChildrenCollisionObjects() const;
std::array<double,2> x() const;
std::array<double,2> y() const;
std::array<int,2> t() const;
private:
std::array<double,2> x_;
std::array<double,2> y_;
std::array<int,2> t_;
std::vector<BoundingVolumeConstPtr> children_BV_;
std::vector<CollisionObjectConstPtr> children_CO_;
};
}
#endif
| [
"ga38vud@mytum.de"
] | ga38vud@mytum.de |
f354d55009a52bfd07036ba7f03ceb9e4148505d | 9a359d367bcc90c338ae0d39fbbe8959eb6cddc5 | /gsi/src/PeriodicThread.cpp | f151902e241359336169c7c7ee8f6a06b265901c | [] | no_license | JosephFoster118/ApartmentElectricManager | 3b4cb656ff0d0ea997b8e466296e5b7f1f5f6730 | bb8885641bd286f06b0dda0cce8b4aadd4059d54 | refs/heads/master | 2020-07-05T16:45:30.482581 | 2016-11-17T04:33:44 | 2016-11-17T04:33:44 | 73,990,069 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,036 | cpp | /*******************************************************************************
*
* File: PeriodicThread.cpp
* Generic System Interface class for periodic threads
*
* Written by:
* The Robonauts
* FRC Team 118
* NASA, Johnson Space Center
* Clear Creek Independent School District
*
******************************************************************************/
#include "gsi/PeriodicThread.h"
#include "gsi/Time.h"
static const double MIN_SLEEP_TIME = 0.001;
namespace gsi
{
/*******************************************************************************
*
* Constructor for PeriodicTThread
*
* The constructor initializes the instance variables for the task.
*
******************************************************************************/
PeriodicThread::PeriodicThread(std::string name, double period, ThreadPriority priority,
uint32_t options, uint32_t stack_size) : Thread(name, priority, options, stack_size)
{
thread_period = period;
thread_next_time = 0.0;
}
/*******************************************************************************
*
* Free the resources for this class.
*
******************************************************************************/
PeriodicThread::~PeriodicThread()
{
}
/*******************************************************************************
*
* @return the period in seconds
*
******************************************************************************/
double PeriodicThread::getPeriod()
{
return thread_period;
}
/*******************************************************************************
*
* Set the period of this thread. If the thread is already running, the new
* period will not have an impact until the current cycle completes.
*
* @param period the new period in seconds
*
******************************************************************************/
void PeriodicThread::setPeriod(double period)
{
thread_period = period;
}
/*******************************************************************************
*
* This method implements the base classes run method to periodically call
* the update() method that must be implemented by subclasses.
*
******************************************************************************/
void PeriodicThread::run(void)
{
//printf("PeriodicThread:%s, %s:%d\n", getName().c_str(), __FUNCTION__, __LINE__);
thread_next_time = Time::getTime();
while( ! isStopRequested() )
{
//printf("PeriodicThread:%s, %s:%d\n", getName().c_str(), __FUNCTION__, __LINE__);
doPeriodic();
//printf("PeriodicThread:%s, %s:%d\n", getName().c_str(), __FUNCTION__, __LINE__);
thread_next_time += thread_period;
double wait_time = thread_next_time - Time::getTime();
if (wait_time >= MIN_SLEEP_TIME)
{
//printf("PeriodicThread:%s, %s:%d\n", getName().c_str(), __FUNCTION__, __LINE__);
sleep(wait_time);
}
else
{
//printf("PeriodicThread:%s, %s:%d\n", getName().c_str(), __FUNCTION__, __LINE__);
sleep(MIN_SLEEP_TIME);
}
}
}
} // namespace gsi
| [
"root@beaglebone.localdomain"
] | root@beaglebone.localdomain |
7be6c52db47f54b8771d3b3680ae78f23a6539c8 | 8fbacd0ec4cf4b5afd725461e19ffb7ed08739cd | /447A. DZY Loves Hash.cpp | 165d7cdc29d83a97c59f473ad7f16f736248c766 | [] | no_license | khairulTonu/Codeforces_Solutions | 693f2c8694cf24366849d5a65c994c1c2a776b41 | 2e3d1597b223613f0109a76c0cece4d3c20721e4 | refs/heads/master | 2021-06-22T07:46:45.518561 | 2017-08-15T05:22:59 | 2017-08-15T05:22:59 | 100,341,078 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 724 | cpp | #include<bits/stdc++.h>
using namespace std;
int main()
{
int a[10001],i,j=0,k,l,p,n,rem,cnt=0;
int b[10001];
list<int>lst;
cin>>p>>n;
for(i=0;i<n;i++)
{
cin>>a[i];
}
for(i=0;i<n;i++)
{
rem=a[i]%p;
b[j]=rem;
j++;
}
/*for(k=1;k<j;k++)
{
cout<<b[k]<<" ";
}
cout<<endl<<endl;*/
for(k=0;k<j-1;k++)
{
for(l=k+1;l<j;l++)
{
if(b[k]==b[l])
{
lst.push_back(l+1);
cnt++;
}
}
}
if(cnt==0)
{
cout<<"-1";
}
else
{
lst.sort();
list<int>::iterator it=lst.begin();
cout<<*it;
}
}
| [
"khairulislamtonu0509@gmail.com"
] | khairulislamtonu0509@gmail.com |
23af04a0c38ab7dd42fd931f6a4eeb2dad70e876 | f3a65d8ef604547edc3c7f915619a476de6426d6 | /ExampleViewAllySkillPanel_src_backup/DotAAllstarsHelper/DotaClickHelper.cpp | d4d3c70e37a0601492ef68abe53b714c42a301f1 | [
"Unlicense"
] | permissive | jerryyang0304/DotaAllstarsHelper_DLL_FOR_DOTA | 325074af34b7e7e9c44cde13043a91928b04a3c4 | ed621a70540cdab03db8acc7cc6b80794363abcd | refs/heads/main | 2023-08-12T08:49:57.455032 | 2021-09-19T05:34:53 | 2021-09-19T05:34:53 | null | 0 | 0 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 120,697 | cpp | #include "DotaClickHelper.h"
#include <War3Window.h>
#include "Main.h"
#include <Input.h>
#include <codecvt>
#include <Timer.h>
#include "RawImageApi.h"
HWND Warcraft3Window = 0;
WarcraftRealWNDProc WarcraftRealWNDProc_org = NULL;
WarcraftRealWNDProc WarcraftRealWNDProc_ptr;
LPARAM lpF1ScanKeyUP = ( LPARAM )( 0xC0000001 | ( LPARAM )( MapVirtualKey( VK_F1, 0 ) << 16 ) );
LPARAM lpF1ScanKeyDOWN = ( LPARAM )( 0x00000001 | ( LPARAM )( MapVirtualKey( VK_F1, 0 ) << 16 ) );
LPARAM lpAltScanKeyUP = ( LPARAM )( 0xC0000001 | ( LPARAM )( MapVirtualKey( VK_MENU, 0 ) << 16 ) );
LPARAM lpAltScanKeyDOWN = ( LPARAM )( 0x00000001 | ( LPARAM )( MapVirtualKey( VK_MENU, 0 ) << 16 ) );
LPARAM lpCtrlScanKeyUP = ( LPARAM )( 0xC0000001 | ( LPARAM )( MapVirtualKey( VK_CONTROL, 0 ) << 16 ) );
LPARAM lpCtrlScanKeyDOWN = ( LPARAM )( 0x00000001 | ( LPARAM )( MapVirtualKey( VK_CONTROL, 0 ) << 16 ) );
BOOL EmulateKeyInputForHWND = FALSE;
int ShiftPressed = 0;
DWORD SkipSingleShift = 0;
DWORD SingleShift = 0;
BOOL SkipAllMessages = FALSE;
void PressKeyboard( int VK )
{
BOOL PressedKey = FALSE;
INPUT Input = { 0 };
Input.type = INPUT_KEYBOARD;
Input.ki.wScan = ( WORD )MapVirtualKey( ( unsigned int )VK, 0 );
Input.ki.wVk = ( WORD )VK;
if ( IsKeyPressed( VK ) )
{
PressedKey = TRUE;
Input.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput( 1, &Input, sizeof( INPUT ) );
}
Input.ki.dwFlags = 0;
SendInput( 1, &Input, sizeof( INPUT ) );
if ( !PressedKey )
{
Input.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput( 1, &Input, sizeof( INPUT ) );
}
}
DWORD LastKeyPressedTime = 0;
DWORD LastKeyPressedKey = 0;
void __fastcall PressCancel( int data )
{
__asm
{
push data;
mov ecx, GameDll;
add ecx, 0xACE9EC;
mov edi, GameDll;
add edi, 0x3747E0;
call edi;
}
}
BOOL IsCursorSelectTarget( )
{
int pOffset1 = GetGlobalClassAddr( );
if ( pOffset1 > 0 && *( int* )( pOffset1 + 0x1BC ) == 1 )
{
/*char tmp[ 100 ];
sprintf_s( tmp, 100, "%X", pOffset1 );
MessageBoxA( 0, tmp, tmp, 0 );*/
return TRUE;
}
return FALSE;
}
int GetCursorSkillID( )
{
int pOffset1 = GetGlobalClassAddr( );
if ( pOffset1 > 0 && ( pOffset1 = *( int* )( pOffset1 + 0x1B4 ) ) > 0 )
{
return *( int* )( pOffset1 + 0xC );
}
return 0;
}
int GetCursorOrder( )
{
int pOffset1 = GetGlobalClassAddr( );
if ( pOffset1 > 0 && ( pOffset1 = *( int* )( pOffset1 + 0x1B4 ) ) > 0 )
{
return *( int* )( pOffset1 + 0x10 );
}
return 0;
}
vector<int> doubleclickSkillIDs;
int __stdcall AddDoubleClickSkillID( int skillID )
{
/*char addedid[ 100 ];
sprintf_s( addedid, "Added new id:%i", skillID );
MessageBoxA( 0, addedid, "", 0 );*/
if ( skillID == 0 && !doubleclickSkillIDs.empty( ) )
{
//MessageBoxA( 0, "ERROR! IDS CLEARED", "", 0 );
doubleclickSkillIDs.clear( );
}
else
doubleclickSkillIDs.push_back( skillID );
return skillID;
}
float HeroPortX = 0.318f;
float HeroPortY = 0.888f;
BOOL ScreenToClientReplace = FALSE;
POINT ScreenToClientReplacedPoint;
BOOL ClientToScreenReplace = FALSE;
POINT ClientToScreenReplacedPoint;
LPARAM oldlParam = 0;
BOOL BLOCKMOUSEMOVING = FALSE;
float HeroFrameX = 0.256f;
float HeroFrameY = 0.0666f;
float HeroFrameX_old = 0.256f;
float HeroFrameY_old = 0.0666f;
void SetHeroFrameXY( )
{
HeroFrameX_old = *( float* )( GameFrameAtMouseStructOffset + 0x14 );
*( float* )( GameFrameAtMouseStructOffset + 0x14 ) = HeroFrameX;
HeroFrameY_old = *( float* )( GameFrameAtMouseStructOffset + 0x18 );
*( float* )( GameFrameAtMouseStructOffset + 0x18 ) = HeroFrameY;
}
void SetHeroFrameXY_old( )
{
if ( *( float* )( GameFrameAtMouseStructOffset + 0x14 ) == HeroFrameX )
{
*( float* )( GameFrameAtMouseStructOffset + 0x14 ) = HeroFrameX_old;
*( float* )( GameFrameAtMouseStructOffset + 0x18 ) = HeroFrameY_old;
}
}
void MouseClickX( int toX, int toY )
{
Sleep( 5 );
POINT point;
GetCursorPos( &point );
PostMessage( Warcraft3Window, WM_LBUTTONDOWN, MK_LBUTTON, MAKELONG( point.x, point.y ) );
PostMessage( Warcraft3Window, WM_LBUTTONUP, MK_LBUTTON, MAKELONG( point.x, point.y ) );
/*
POINT cursorPos;
GetCursorPos( &cursorPos );
double dx = toX * ( 65535.0f / DesktopScreen_Width );
double dy = toY * ( 65535.0f / DesktopScreen_Height );
INPUT Input = { 0 };
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
Input.mi.dx = LONG( dx );
Input.mi.dy = LONG( dy );
SendInput( 1, &Input, sizeof( INPUT ) );
SetHeroFrameXY( );
SendInput( 1, &Input, sizeof( INPUT ) );
SetHeroFrameXY( );
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
SendInput( 1, &Input, sizeof( INPUT ) );
SetHeroFrameXY( );
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
SendInput( 1, &Input, sizeof( INPUT ) );
SetHeroFrameXY( );
dx = cursorPos.x*( 65535.0f / DesktopScreen_Width );
dy = cursorPos.y*( 65535.0f / DesktopScreen_Height );
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
Input.mi.dx = LONG( dx );
Input.mi.dy = LONG( dy );
SendInput( 1, &Input, sizeof( INPUT ) );
SetHeroFrameXY( );*/
}
unsigned long __stdcall ThreadTest( void * lpp )
{
POINT * p = ( POINT * )lpp;
SkipAllMessages = TRUE;
MouseClickX( p->x, p->y );
SkipAllMessages = FALSE;
delete p;
return 0;
}
void MouseClick( int toX, int toY )
{
POINT * ClickPoint = new POINT( );
ClickPoint->x = toX;
ClickPoint->y = toY;
HANDLE thr = CreateThread( 0, 0, ThreadTest, ClickPoint, 0, 0 );
if ( thr != NULL )
CloseHandle( thr );
}
void JustClickMouse( )
{
BOOL ButtonDown = FALSE;
if ( IsKeyPressed( VK_LBUTTON ) )
{
ButtonDown = TRUE;
SendMessage( Warcraft3Window, WM_LBUTTONUP, 0, oldlParam );
}
INPUT Input = { 0 };
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
SendInput( 1, &Input, sizeof( INPUT ) );
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
SendInput( 1, &Input, sizeof( INPUT ) );
}
int PressMouseAtSelectedHero( BOOL IsItem )
{
int errorvalue = 0;
if ( !IsCursorSelectTarget( ) )
{
errorvalue = 1;
//PrintText( "ERROR 1" );
}
if ( GetCursorOrder( ) == 0xD000F ||
GetCursorOrder( ) == 0xD0012 ||
GetCursorOrder( ) == 0xD0016 )
{
errorvalue = 2;
// PrintText( "ERROR 2" );
}
if ( IsCursorSelectTarget( ) &&
GetCursorOrder( ) != 0xD000F &&
GetCursorOrder( ) != 0xD0012 &&
GetCursorOrder( ) != 0xD0016 )
{
if ( /*!IsItem || */doubleclickSkillIDs.empty( ) ||
std::find( doubleclickSkillIDs.begin( ), doubleclickSkillIDs.end( ), GetCursorSkillID( ) ) != doubleclickSkillIDs.end( )
)
{
int PortraitButtonAddr = GetGlobalClassAddr( );
if ( PortraitButtonAddr > 0 )
{
PortraitButtonAddr = *( int* )( PortraitButtonAddr + 0x3F4 );
}
if ( PortraitButtonAddr > 0 && !IsItem )
{
//PrintText( "NEED CLICK PORTRAIT" );
Wc3ControlClickButton_org( PortraitButtonAddr, 1 );
}
else
{
errorvalue = 4;
//PrintText( "ERROR 4" );
}
/*BOOL ButtonDown = FALSE;
if ( IsKeyPressed( VK_LBUTTON ) )
{
ButtonDown = TRUE;
SendMessage( Warcraft3Window, WM_LBUTTONUP, 0, oldlParam );
}
int x = ( int )( *GetWindowXoffset * HeroPortX );
int y = ( int )( *GetWindowYoffset * HeroPortY );
POINT cursorhwnd;
GetCursorPos( &cursorhwnd );
ScreenToClient( Warcraft3Window, &cursorhwnd );
POINT cursor;
GetCursorPos( &cursor );
x = x - cursorhwnd.x;
y = y - cursorhwnd.y;
cursor.x = cursor.x + x;
cursor.y = cursor.y + y;
//( toXX, toYY );
MouseClick( cursor.x, cursor.y );*/
}
else
{
errorvalue = 3;
//PrintText( ( "ERROR 3:" + to_string( GetCursorSkillID( ) ) ).c_str( ) );
}
}
return errorvalue;
}
DWORD LastPressedKeysTime[ 1024 ];
vector<int> RegisteredKeyCodes;
vector<int> BlockedKeyCodes;
vector<KeyActionStruct> KeyActionList;
struct mMessage
{
unsigned int Msg;
unsigned int wParam;
};
vector<mMessage> SkipMessagesList;
WPARAM LastShift = 0;
LPARAM MakeLParamVK( unsigned int VK, BOOL up, BOOL Extended = FALSE )
{
if ( up ) return ( LPARAM )( 0xC0000001 | ( ( unsigned int )Extended << 24 ) | ( LPARAM )( MapVirtualKey( VK, 0 ) << 16 ) );
else return ( LPARAM )( 0x00000001 | ( ( unsigned int )Extended << 24 ) | ( LPARAM )( MapVirtualKey( VK, 0 ) << 16 ) );
}
int __stdcall TriggerRegisterPlayerKeyboardEvent( int KeyCode )
{
if ( !KeyCode )
{
if ( !RegisteredKeyCodes.empty( ) )
RegisteredKeyCodes.clear( );
return 0;
}
RegisteredKeyCodes.push_back( KeyCode );
return 0;
}
BOOL bTriggerRegisterPlayerKeyboardBlock = TRUE;
void __stdcall TriggerRegisterPlayerKeyboardBlock( BOOL enabled )
{
bTriggerRegisterPlayerKeyboardBlock = enabled;
}
int __stdcall BlockKeyAction( int KeyCode )
{
if ( !KeyCode )
{
if ( !BlockedKeyCodes.empty( ) )
BlockedKeyCodes.clear( );
return 0;
}
BlockedKeyCodes.push_back( KeyCode );
return 0;
}
int GetAltBtnID( int btnID )
{
switch ( btnID )
{
case 2:
return 0;
case 5:
return 3;
case 8:
return 6;
case 11:
return 9;
case 4:
return 1;
case 7:
return 4;
}
return -1;
}
BOOL EnabledReplaceHotkeyFlag = TRUE;
void __stdcall EnableReplaceHotkeyFlag( BOOL enabled )
{
EnabledReplaceHotkeyFlag = enabled;
}
std::vector<KeySelectActionStruct> KeySelectActionList;
int __stdcall AddKeySelectAction( int KeyCode, int GroupHandle )
{
if ( !KeyCode )
{
if ( !KeySelectActionList.empty( ) )
KeySelectActionList.clear( );
return 0;
}
KeySelectActionStruct tmpstr;
tmpstr.VK = KeyCode & 0xFF;
tmpstr.IsAlt = KeyCode & 0x10000;
tmpstr.IsCtrl = KeyCode & 0x20000;
tmpstr.IsShift = KeyCode & 0x40000;
tmpstr.GroupHandle = GroupHandle;
tmpstr.units = GetUnitsFromGroup( GroupHandle );
//reverse( tmpstr.units.begin( ), tmpstr.units.end( ) );
if ( !EnabledReplaceHotkeyFlag || KeyCode & 0x100000 )
{
for ( KeySelectActionStruct & curstr : KeySelectActionList )
{
if ( curstr.VK == tmpstr.VK )
{
if ( curstr.GroupHandle == tmpstr.GroupHandle ||
( ( ( !curstr.IsAlt && !curstr.IsCtrl && !curstr.IsShift )
&&
( !tmpstr.IsAlt && !tmpstr.IsCtrl && !tmpstr.IsShift ) )
|| ( curstr.IsAlt && tmpstr.IsAlt )
|| ( curstr.IsCtrl && tmpstr.IsCtrl )
|| ( curstr.IsShift && tmpstr.IsShift ) ) )
{
if ( SetInfoObjDebugVal )
{
PrintText( "Replace old selection hotkey." );
}
curstr = tmpstr;
return 0;
}
}
}
}
if ( SetInfoObjDebugVal )
{
PrintText( "Add new selection hotkey." );
}
KeySelectActionList.push_back( tmpstr );
return 0;
}
std::vector<KeyChatActionStruct> KeyChatActionList;
int __stdcall AddKeyChatAction( int KeyCode, const char * str, BOOL SendToAll )
{
if ( !KeyCode )
{
if ( !KeyChatActionList.empty( ) )
KeyChatActionList.clear( );
return 0;
}
KeyChatActionStruct tmpstr;
tmpstr.VK = KeyCode & 0xFF;
tmpstr.IsAlt = KeyCode & 0x10000;
tmpstr.IsCtrl = KeyCode & 0x20000;
tmpstr.IsShift = KeyCode & 0x40000;
tmpstr.SendToAll = SendToAll;
tmpstr.Message = str && strlen( str ) < 127 ? str : "Bad message length";
if ( !EnabledReplaceHotkeyFlag || KeyCode & 0x100000 )
{
for ( KeyChatActionStruct & curstr : KeyChatActionList )
{
if ( curstr.VK == tmpstr.VK )
{
if ( ( ( !curstr.IsAlt && !curstr.IsCtrl && !curstr.IsShift ) &&
( !tmpstr.IsAlt && !tmpstr.IsCtrl && !tmpstr.IsShift ) )
|| ( curstr.IsAlt && tmpstr.IsAlt )
|| ( curstr.IsCtrl && tmpstr.IsCtrl )
|| ( curstr.IsShift && tmpstr.IsShift )
)
{
if ( SetInfoObjDebugVal )
{
PrintText( "Replace old chat hotkey." );
}
curstr = tmpstr;
return 0;
}
}
}
}
if ( SetInfoObjDebugVal )
{
PrintText( "Add new chat hotkey." );
}
KeyChatActionList.push_back( tmpstr );
return 0;
}
std::vector<KeyCalbackActionStruct> KeyCalbackActionList;
int __stdcall AddKeyCalbackAction( int KeyCode, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8 )
{
if ( !KeyCode )
{
if ( !KeyCalbackActionList.empty( ) )
KeyCalbackActionList.clear( );
return 0;
}
KeyCalbackActionStruct tmpstr;
tmpstr.VK = KeyCode & 0xFF;
tmpstr.IsAlt = KeyCode & 0x10000;
tmpstr.IsCtrl = KeyCode & 0x20000;
tmpstr.IsShift = KeyCode & 0x40000;
// save args safe
tmpstr.args[ 0 ] = arg2;
tmpstr.args[ 1 ] = arg3;
tmpstr.args[ 2 ] = arg4;
tmpstr.args[ 3 ] = arg5;
tmpstr.args[ 4 ] = arg6;
tmpstr.args[ 5 ] = arg7;
tmpstr.args[ 6 ] = arg8;
if ( !EnabledReplaceHotkeyFlag || KeyCode & 0x100000 )
{
for ( KeyCalbackActionStruct & curstr : KeyCalbackActionList )
{
if ( curstr.VK == tmpstr.VK )
{
if (
( ( !curstr.IsAlt && !curstr.IsCtrl && !curstr.IsShift ) &&
( !tmpstr.IsAlt && !tmpstr.IsCtrl && !tmpstr.IsShift ) )
|| ( curstr.IsAlt && tmpstr.IsAlt )
|| ( curstr.IsCtrl && tmpstr.IsCtrl )
|| ( curstr.IsShift && tmpstr.IsShift )
)
{
if ( SetInfoObjDebugVal )
{
PrintText( "Replace old callback hotkey." );
}
curstr = tmpstr;
return 0;
}
}
}
}
if ( SetInfoObjDebugVal )
{
char bufka[ 200 ];
sprintf_s( bufka, "Add new callback hotkey. VK %X/ALT %X/CTRL %X/SHIFT %X", tmpstr.VK, tmpstr.IsAlt, tmpstr.IsCtrl, tmpstr.IsShift );
PrintText( bufka );
}
KeyCalbackActionList.push_back( tmpstr );
return 0;
}
int __stdcall AddKeyButtonAction( int KeyCode, int btnID, BOOL IsSkill )
{
if ( !KeyCode )
{
if ( !KeyActionList.empty( ) )
KeyActionList.clear( );
return 0;
}
KeyActionStruct tmpstr;
tmpstr.VK = KeyCode & 0xFF;
tmpstr.btnID = btnID;
tmpstr.IsSkill = IsSkill;
if ( IsSkill )
tmpstr.altbtnID = ( GetAltBtnID( btnID ) );
else
tmpstr.altbtnID = 0;
tmpstr.IsAlt = KeyCode & 0x10000;
tmpstr.IsCtrl = KeyCode & 0x20000;
tmpstr.IsShift = KeyCode & 0x40000;
tmpstr.IsRightClick = KeyCode & 0x80000;
tmpstr.IsQuickCast = KeyCode & 0x200000;
if ( !EnabledReplaceHotkeyFlag || KeyCode & 0x100000 )
{
for ( KeyActionStruct & curstr : KeyActionList )
{
if ( curstr.btnID == tmpstr.btnID )
{
if ( ( ( !curstr.IsAlt && !curstr.IsCtrl && !curstr.IsShift ) &&
( !tmpstr.IsAlt && !tmpstr.IsCtrl && !tmpstr.IsShift ) )
|| ( curstr.IsAlt && tmpstr.IsAlt )
|| ( curstr.IsCtrl && tmpstr.IsCtrl )
|| ( curstr.IsShift && tmpstr.IsShift )
)
{
if ( SetInfoObjDebugVal )
{
PrintText( "Replace hotkey" );
}
curstr = tmpstr;
return 0;
}
}
}
}
if ( SetInfoObjDebugVal )
{
char debugtext[ 512 ];
sprintf_s( debugtext, "%s:%X %s:%s %s:%s %s:%s %s:%s %s:%s",
"added new hotkey", KeyCode,
"IsAlt", GetBoolStr( tmpstr.IsAlt ),
"IsCtrl", GetBoolStr( tmpstr.IsCtrl ),
"IsShift", GetBoolStr( tmpstr.IsShift ),
"IsRightClick", GetBoolStr( tmpstr.IsRightClick ),
"IsQuickCast", GetBoolStr( tmpstr.IsQuickCast ) );
PrintText( debugtext );
}
KeyActionList.push_back( tmpstr );
return 0;
}
BOOL IsNULLButtonFound( int pButton )
{
if ( pButton > 0 && *( int* )( pButton ) > 0 )
{
if ( *( int* )( pButton + 0x190 ) != 0 && *( int* )( *( int* )( pButton + 0x190 ) + 4 ) == 0 )
return TRUE;
}
return FALSE;
}
// | 0 | 3 | 6 | 9 |
// | 1 | 4 | 7 | 10 |
// | 2 | 5 | 8 | 11 |
#define flagsOffset 0x138
#define sizeOfCommandButtonObj 0x1c0
int __stdcall GetSkillPanelButton( int idx )
{
if ( GetSelectedUnit( GetLocalPlayerId( ) ) )
{
int pclass = GetGlobalClassAddr( );
if ( pclass > 0 )
{
int pGamePlayerPanelSkills = *( int* )( pclass + 0x3c8 );
if ( pGamePlayerPanelSkills > 0 )
{
int topLeftCommandButton = *( int* )( pGamePlayerPanelSkills + 0x154 );
if ( topLeftCommandButton > 0 )
{
topLeftCommandButton = **( int** )( topLeftCommandButton + 0x8 );
if ( topLeftCommandButton > 0 )
return topLeftCommandButton + sizeOfCommandButtonObj * idx;
}
}
}
}
return 0;
}
// | 0 | 1
// | 2 | 3
// | 4 | 5
int __stdcall GetItemPanelButton( int idx )
{
if ( GetSelectedUnit( GetLocalPlayerId( ) ) )
{
int pclass = GetGlobalClassAddr( );
if ( pclass > 0 )
{
int pGamePlayerPanelItems = *( int* )( pclass + 0x3c4 );
if ( pGamePlayerPanelItems > 0 )
{
int topLeftCommandButton = *( int* )( pGamePlayerPanelItems + 0x148 );
if ( topLeftCommandButton > 0 )
{
topLeftCommandButton = *( int* )( topLeftCommandButton + 0x130 );
if ( topLeftCommandButton > 0 )
{
topLeftCommandButton = *( int* )( topLeftCommandButton + 0x4 );
if ( topLeftCommandButton > 0 )
{
return topLeftCommandButton + sizeOfCommandButtonObj * idx;
}
}
}
}
}
}
return 0;
}
int GetHeroButton( int idx )
{
int pclass = GetGlobalClassAddr( );
if ( pclass > 0 )
{
int pGamePlayerHeroBtn = *( int* )( pclass + 0x3c8 );
if ( pGamePlayerHeroBtn > 0 )
{
pGamePlayerHeroBtn = *( int* )( pGamePlayerHeroBtn + 0x40 );
if ( pGamePlayerHeroBtn > 0 )
{
pGamePlayerHeroBtn = *( int* )( pGamePlayerHeroBtn + 0x20 );
return pGamePlayerHeroBtn;
}
}
}
return 0;
}
c_SimpleButtonClickEvent SimpleButtonClickEvent_org;
c_SimpleButtonClickEvent SimpleButtonClickEvent_ptr;
int CommandButtonVtable = 0;
BOOL IsCommandButton( int addr )
{
if ( addr > 0 )
{
if ( CommandButtonVtable )
{
return *( int* )addr == CommandButtonVtable;
}
}
return FALSE;
}
std::vector<ClickPortrainForId> ClickPortrainForIdList;
BOOL __stdcall AddClickPortrainForId( int abilid, int keycode )
{
if ( abilid == 0 || keycode == 0 )
{
ClickPortrainForIdList.clear( );
return FALSE;
}
ClickPortrainForId tmpClickPortrainForId = ClickPortrainForId( );
tmpClickPortrainForId.abilid = abilid;
tmpClickPortrainForId.keycode = keycode;
tmpClickPortrainForId.checkforcd = FALSE;
ClickPortrainForIdList.push_back( tmpClickPortrainForId );
return TRUE;
}
BOOL __stdcall AddClickPortrainForIdEx( int abilid, int keycode, BOOL checkforcd )
{
if ( abilid == 0 || keycode == 0 )
{
ClickPortrainForIdList.clear( );
return FALSE;
}
ClickPortrainForId tmpClickPortrainForId = ClickPortrainForId( );
tmpClickPortrainForId.abilid = abilid;
tmpClickPortrainForId.keycode = keycode;
tmpClickPortrainForId.checkforcd = checkforcd;
ClickPortrainForIdList.push_back( tmpClickPortrainForId );
return TRUE;
}
int CheckBtnForClickPortrain( int pButton )
{
if ( pButton && IsCommandButton( pButton ) )
{
//PrintText( "SimpleButton IsCommandButton" );
int CommandButtonData = *( int* )( pButton + 0x190 );
if ( CommandButtonData )
{
// PrintText( "Click command button." );
int pAbil = *( int* )( CommandButtonData + 0x6D4 );
if ( pAbil )
{
// PrintText( "Abil found." );
int pAbilId = *( int* )( pAbil + 0x34 );
if ( pAbilId )
{
// PrintText( "Abil id found." );
for ( auto tmpClick : ClickPortrainForIdList )
{
if ( pAbilId == tmpClick.abilid && !IsKeyPressed( tmpClick.keycode ) )
{
if ( tmpClick.checkforcd )
{
if ( *( unsigned int * )( pAbil + 0x20 ) & 0x200 )
return 2;
}
// PrintText( "OK! Need click!" );
return 1;
}
else
{
// PrintText( "NO Need click!" );
}
}
}
}
}
}
return 0;
}
DWORD LatestButtonClickTime = 0;
int __fastcall SimpleButtonClickEvent_my( int pButton, int unused, int ClickEventType )
{
if ( ClickEventType == 1 && CheckBtnForClickPortrain( pButton ) )
{
//PrintText( "Abil id found in list." );
int retval = SimpleButtonClickEvent_ptr( pButton, unused, ClickEventType );
int PortraitButtonAddr = GetGlobalClassAddr( );
if ( PortraitButtonAddr > 0 )
{
PortraitButtonAddr = *( int* )( PortraitButtonAddr + 0x3F4 );
}
if ( PortraitButtonAddr > 0 )
{
//PrintText( "Click to portrain." );
if ( Wc3ControlClickButton_org( PortraitButtonAddr, 1 ) )
{
LatestButtonClickTime = GetTickCount( );
}
}
return retval;
}
bool CheckDoubleOk = false;
if ( SetInfoObjDebugVal )
{
PrintText( "Click SimpleButton." );
}
//
if ( IsCommandButton( pButton ) )
{
if ( SetInfoObjDebugVal )
{
PrintText( "SimpleButton IsCommandButton" );
}
//
int CommandButtonData = *( int* )( pButton + 0x190 );
if ( CommandButtonData )
{
if ( SetInfoObjDebugVal )
{
PrintText( "Click command button." );
}
//
int pAbil = *( int* )( CommandButtonData + 0x6D4 );
if ( pAbil )
{
if ( SetInfoObjDebugVal )
{
PrintText( "Abil found." );
}
//
int pAbilId = *( int* )( pAbil + 0x34 );
if ( pAbilId )
{
if ( doubleclickSkillIDs.empty( ) ||
std::find( doubleclickSkillIDs.begin( ), doubleclickSkillIDs.end( ), pAbilId ) != doubleclickSkillIDs.end( ) )
{
if ( SetInfoObjDebugVal )
{
PrintText( "Abilid found!!!!" );
}
CheckDoubleOk = true;
}
}
}
}
}
int retval = SimpleButtonClickEvent_ptr( pButton, unused, ClickEventType );
if ( retval && CheckDoubleOk )
{
if ( SetInfoObjDebugVal )
{
PrintText( "Button click success" );
}
LatestButtonClickTime = GetTickCount( );
}
return retval;
}
BOOL __stdcall SimpleButtonClick( int simplebtnaddr, BOOL LeftMouse )
{
return SimpleButtonClickEvent_org( simplebtnaddr, simplebtnaddr, LeftMouse ? 1 : 4 );
}
BOOL PressSkillPanelButton( int idx, BOOL RightClick )
{
int button = GetSkillPanelButton( idx );
if ( button > 0 && IsCommandButton( button ) )
{
UINT oldflag = *( UINT * )( button + flagsOffset );
if ( !( oldflag & 2 ) )
*( UINT * )( button + flagsOffset ) = oldflag | 2;
int retval = SimpleButtonClickEvent_org( button, 0, RightClick ? 4 : 1 );
*( UINT * )( button + flagsOffset ) = oldflag;
return retval;
}
return 0;
}
BOOL PressItemPanelButton( int idx, BOOL RightClick )
{
int button = GetItemPanelButton( idx );
if ( button > 0 && IsCommandButton( button ) )
{
UINT oldflag = *( UINT * )( button + flagsOffset );
if ( !( oldflag & 2 ) )
*( UINT * )( button + flagsOffset ) = oldflag | 2;
int retval = SimpleButtonClickEvent_org( button, 0, RightClick ? 4 : 1 );
*( UINT * )( button + flagsOffset ) = oldflag;
return retval;
}
return 0;
}
BOOL PressHeroPanelButton( int idx, BOOL RightClick )
{
int button = GetHeroButton( idx );
if ( button > 0 && IsCommandButton( button ) )
{
UINT oldflag = *( UINT * )( button + flagsOffset );
if ( !( oldflag & 2 ) )
*( UINT * )( button + flagsOffset ) = oldflag | 2;
int retval = SimpleButtonClickEvent_org( button, 0, RightClick ? 4 : 1 );
*( UINT * )( button + flagsOffset ) = oldflag;
return retval;
}
return 0;
}
BOOL IsMouseOverWindow( RECT pwi, POINT cursorPos )
{
return PtInRect( &pwi, cursorPos );
}
vector<unsigned char> SendKeyEvent;
auto t_start = std::chrono::high_resolution_clock::now( );
BOOL LOCK_MOUSE_IN_WINDOW = FALSE;
int __stdcall LockMouseInWindow( BOOL enable )
{
LOCK_MOUSE_IN_WINDOW = enable;
if ( !LOCK_MOUSE_IN_WINDOW )
ClipCursor( 0 );
return enable;
}
BOOL BlockKeyboardAndMouseWhenTeleport = FALSE;
int __stdcall TeleportHelper( BOOL enabled )
{
BlockKeyboardAndMouseWhenTeleport = enabled;
return enabled;
}
vector<int> WhiteListForTeleport;
BOOL TeleportShiftPress = FALSE;
int __stdcall TeleportShiftKey( BOOL enabled )
{
TeleportShiftPress = enabled;
return enabled;
}
int __stdcall TeleportWhiteListKey( int VK )
{
if ( VK == 0 && !WhiteListForTeleport.empty( ) )
WhiteListForTeleport.clear( );
WhiteListForTeleport.push_back( VK );
return VK;
}
BOOL ShopHelperEnabled = FALSE;
int __stdcall ShopHelper( BOOL enable )
{
ShopHelperEnabled = enable;
return enable;
}
BOOL rawimage_skipmouseevent = TRUE;
int __stdcall RawImage_SkipMouseClick( BOOL enabled )
{
rawimage_skipmouseevent = enabled;
return rawimage_skipmouseevent;
}
BOOL AutoSelectHero = FALSE;
int __stdcall SetAutoSelectHero( BOOL enabled )
{
AutoSelectHero = TRUE;
return AutoSelectHero;
}
safevector<DelayedPress> DelayedPressList;
void DelayedPressList_pushback( DelayedPress & d )
{
for ( unsigned int i = 0; i < DelayedPressList.size( ); i++ )
{
if ( DelayedPressList[ i ].IsNull( ) )
{
DelayedPressList[ i ] = d;
DelayedPressList[ i ].ISNULL = FALSE;
return;
}
}
DelayedPressList.push_back( d );
}
int DisableTargetCurcorWORK = 0;
DWORD latDisableTargetCurcor = 0;
void DisableTargetCurcor( )
{
if ( DisableTargetCurcorWORK <= 0 )
return;
if ( GetTickCount( ) - latDisableTargetCurcor > 25 )
{
latDisableTargetCurcor = GetTickCount( );
DisableTargetCurcorWORK--;
if ( SetInfoObjDebugVal )
{
PrintText( "w1" );
}
if ( IsCursorSelectTarget( ) )
{
if ( SetInfoObjDebugVal )
{
PrintText( "w2" );
}
POINT cursorhwnd;
GetCursorPos( &cursorhwnd );
ScreenToClient( Warcraft3Window, &cursorhwnd );
WarcraftRealWNDProc_ptr( Warcraft3Window, WM_RBUTTONDOWN, MK_RBUTTON, MAKELPARAM( cursorhwnd.x, cursorhwnd.y ) );
WarcraftRealWNDProc_ptr( Warcraft3Window, WM_RBUTTONUP, 0, MAKELPARAM( cursorhwnd.x, cursorhwnd.y ) );
DisableTargetCurcorWORK = 0;
//__asm
//{
// mov ecx, GameDll;
// add ecx, 0xAB4F80;
// mov ecx, [ ecx ];
// mov edi, GameDll;
// add edi, 0x2FB920; // clear cursor
// call edi;
//}
}
}
}
void PressKeyWithDelay_timed( Timer *tm )
{
if ( IsGame( ) && *IsWindowActive )
{
for ( unsigned int i = 0; i < DelayedPressList.size( ); i++ )
{
if ( DelayedPressList[ i ].IsNull( ) )
continue;
if ( DelayedPressList[ i ].TimeOut >= 20 )
{
DelayedPressList[ i ].TimeOut -= 20;
}
else if ( DelayedPressList[ i ].TimeOut > 0 )
{
DelayedPressList[ i ].TimeOut = 0;
}
else
{
if ( !DelayedPressList[ i ].IsCustom )
{
if ( DelayedPressList[ i ].NeedPressMsg == 0 )
{
WarcraftRealWNDProc_ptr( Warcraft3Window, WM_KEYDOWN, DelayedPressList[ i ].NeedPresswParam, DelayedPressList[ i ].NeedPresslParam );
WarcraftRealWNDProc_ptr( Warcraft3Window, WM_KEYUP, DelayedPressList[ i ].NeedPresswParam, ( LPARAM )( 0xC0000000 | DelayedPressList[ i ].NeedPresslParam ) );
}
else
{
WarcraftRealWNDProc_ptr( Warcraft3Window, DelayedPressList[ i ].NeedPressMsg, DelayedPressList[ i ].NeedPresswParam, DelayedPressList[ i ].NeedPresslParam );
}
}
else
{
for ( KeyActionStruct & keyAction : KeyActionList )
{
if ( keyAction.VK == ( int )DelayedPressList[ i ].NeedPresswParam && IsGameFrameActive( ) )
{
if ( ( !keyAction.IsAlt && !keyAction.IsCtrl && !keyAction.IsShift )
|| ( keyAction.IsAlt && DelayedPressList[ i ].IsAlt )
|| ( keyAction.IsCtrl && DelayedPressList[ i ].IsCtrl )
|| ( keyAction.IsShift && DelayedPressList[ i ].IsCustom )
)
{
int selectedunits = GetSelectedUnitCountBigger( GetLocalPlayerId( ) );
BOOL itempressed = !keyAction.IsSkill;
if ( itempressed || ( keyAction.IsSkill && !IsCursorSelectTarget( ) ) )
{
int selectedunit = GetSelectedUnit( GetLocalPlayerId( ) );
if ( selectedunit > 0 && selectedunits > 0 )
{
int unitowner = GetUnitOwnerSlot( selectedunit );
if ( unitowner != 15 )
{
BOOL PressedButton = FALSE;
if ( IsNULLButtonFound( GetSkillPanelButton( 11 ) ) )
{
if ( keyAction.altbtnID >= 0 )
{
if ( !( DelayedPressList[ i ].NeedPresslParam & 0x40000000 ) )
{
if ( keyAction.IsSkill )
PressedButton = PressSkillPanelButton( keyAction.altbtnID, keyAction.IsRightClick );
else
PressedButton = PressItemPanelButton( keyAction.btnID, keyAction.IsRightClick );
}
}
}
else
{
if ( !( DelayedPressList[ i ].NeedPresslParam & 0x40000000 ) )
{
if ( keyAction.IsSkill )
PressedButton = PressSkillPanelButton( keyAction.btnID, keyAction.IsRightClick );
else
PressedButton = PressItemPanelButton( keyAction.btnID, keyAction.IsRightClick );
//PressedButton = TRUE;
}
}
/* if ( !PressedButton )
{
if ( SetInfoObjDebugVal )
{
PrintText( "NO ButtonPressed!" );
}
}
*/
if ( keyAction.IsQuickCast && PressedButton && IsCursorSelectTarget( ) )
{
if ( SetInfoObjDebugVal )
{
int button = GetSkillPanelButton( 11 );
PrintText( "QuickCast called: ButtonAddr:" + to_string( button ) + ". IsCursorSelectTarget: " + to_string( IsCursorSelectTarget( ) ) );
}
/*int x = ( int )( *GetWindowXoffset );
int y = ( int )( *GetWindowYoffset );
*/
POINT cursorhwnd;
GetCursorPos( &cursorhwnd );
ScreenToClient( Warcraft3Window, &cursorhwnd );
WarcraftRealWNDProc_ptr( Warcraft3Window, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM( cursorhwnd.x, cursorhwnd.y ) );
WarcraftRealWNDProc_ptr( Warcraft3Window, WM_LBUTTONUP, 0, MAKELPARAM( cursorhwnd.x, cursorhwnd.y ) );
DisableTargetCurcorWORK = 3;
/* if ( IsCursorSelectTarget( ) )
{
PressSkillPanelButton( 11, FALSE );
}*/
//POINT cursor;
//GetCursorPos( &cursor );
//x = x - cursorhwnd.x;
//y = y - cursorhwnd.y;
//cursor.x = cursor.x + x;
//cursor.y = cursor.y + y;
////( toXX, toYY );
//MouseClick( cursor.x, cursor.y );
}
else if ( !keyAction.IsQuickCast )
{
if ( SetInfoObjDebugVal )
{
PrintText( "Skip quick cast: no flag!" );
}
}
else if ( !PressedButton )
{
if ( SetInfoObjDebugVal )
{
PrintText( "Skip quick cast: Button not pressed!" );
}
}
if ( PressedButton )
break;
}
}
}
break;
}
}
}
}
DelayedPressList[ i ].ISNULL = TRUE;
}
}
}
}
BOOL IsNumpadPressed( int VK )
{
return VK == VK_NUMPAD1 ||
VK == VK_NUMPAD2 ||
VK == VK_NUMPAD4 ||
VK == VK_NUMPAD5 ||
VK == VK_NUMPAD7 ||
VK == VK_NUMPAD8;
}
// | 0 | 1
// | 2 | 3
// | 4 | 5
//int __stdcall GetItemPanelButton( int idx )
int GetBtnIdByNumpad( int VK )
{
switch ( VK )
{
case VK_NUMPAD1:
return 4;
case VK_NUMPAD2:
return 5;
case VK_NUMPAD4:
return 2;
case VK_NUMPAD5:
return 3;
case VK_NUMPAD7:
return 0;
case VK_NUMPAD8:
return 1;
default:
break;
}
return -1;
}
int GetBtnAddrByNumpad( int VK )
{
int btnid = GetBtnIdByNumpad( VK );
if ( btnid == -1 )
return 0;
return GetItemPanelButton( GetBtnIdByNumpad( VK ) );
}
WPARAM LatestPressedKey = NULL;
POINTS GlobalMousePos = { 0,0 };
//BOOL DebugMsgShow = FALSE;
bool InitTestValues = false;
unsigned int TestValues[ 10 ];
void GetMousePosition( float * x, float * y, float * z )
{
#ifdef BOTDEBUG
PrintDebugInfo( "Mouse info" );
#endif
int globalclass = GetGlobalClassAddr( );
int offset1 = globalclass + 0x3BC;
if ( globalclass > 0 )
{
if ( IsOkayPtr( ( void* )offset1 ) )
{
offset1 = *( int * )offset1;
if ( IsOkayPtr( ( void* )offset1 ) )
{
*x = *( float* )( offset1 + 0x310 );
*y = *( float* )( offset1 + 0x310 + 4 );
*z = *( float* )( offset1 + 0x310 + 4 + 4 );
}
else
{
*x = 0.0f;
*y = 0.0f;
*z = 0.0f;
}
}
else
{
*x = 0.0f;
*y = 0.0f;
*z = 0.0f;
}
}
}
int _stdcall GetMouseX( int )
{
return GlobalMousePos.x;
}
int _stdcall GetMouseY( int )
{
return GlobalMousePos.y;
}
float _stdcall GetMouseFrameX( int )
{
return GetMousePosition( )->x;
}
float _stdcall GetMouseFrameY( int )
{
return GetMousePosition( )->y;
}
float __stdcall GetMouseIngameX( int )
{
float x, y, z;
GetMousePosition( &x, &y, &z );
return x;
}
float __stdcall GetMouseIngameY( int )
{
float x, y, z;
GetMousePosition( &x, &y, &z );
return y;
}
float __stdcall GetMouseIngameZ( int )
{
float x, y, z;
GetMousePosition( &x, &y, &z );
return z;
}
unsigned int __stdcall GetTestValue( int id )
{
if ( id >= 0 && id <= 7 )
{
return TestValues[ id ];
}
return 0;
}
BOOL ForceLvl1 = FALSE;
BOOL ForceLvl2 = FALSE;
BOOL ForceLvl3 = FALSE;
void __stdcall SetForceHotkeyProcess( BOOL lvl1, BOOL lvl2, BOOL lvl3 )
{
ForceLvl1 = lvl1;
ForceLvl2 = lvl2;
ForceLvl3 = lvl3;
}
// Заменяет текст в строке
bool replaceAll( std::string& str, const std::string& from, const std::string& to, int addtofrom = 0 )
{
if ( from.empty( ) )
return false;
bool replaced = false;
size_t start_pos = 0;
while ( ( start_pos = str.find( from, start_pos ) ) != std::string::npos ) {
replaced = true;
str.replace( start_pos, from.length( ) + addtofrom, to );
start_pos += to.length( ); // In case 'to' contains 'from', like replacing 'x' with 'yx'
}
return replaced;
}
std::string ReturnStringWithoutWarcraftTags( std::string str )
{
if ( str.length( ) <= 1 )
return str;
replaceAll( str, "|c", "", 8 );
replaceAll( str, "|n", "" );
replaceAll( str, "|r", "" );
replaceAll( str, "|", "" );
replaceAll( str, "- [Level ", "[" );
return str;
}
std::string ReturnStringBeforeFirstChar( std::string str, char crepl )
{
if ( str.length( ) <= 1 )
return str;
for ( auto & c : str )
{
if ( c == crepl )
{
c = '\0';
break;
}
}
return str;
}
std::string ReturnStringBeforeFirstString( std::string str, char crepl )
{
if ( str.length( ) <= 1 )
return str;
for ( auto & c : str )
{
if ( c == crepl )
{
c = '\0';
break;
}
}
return str;
}
std::string GetObjectNameByID( int clid )
{
if ( clid > 0 )
{
int tInfo = GetTypeInfo( clid, 0 );
int tInfo_1d, tInfo_2id;
if ( tInfo && ( tInfo_1d = *( int * )( tInfo + 40 ) ) != 0 )
{
tInfo_2id = tInfo_1d - 1;
if ( tInfo_2id >= ( unsigned int )0 )
tInfo_2id = 0;
return ( const char * )*( int * )( *( int * )( tInfo + 44 ) + 4 * tInfo_2id );
}
else
{
return "Default String";
}
}
return "Default String";
}
std::string IsCooldownMessage = "%s > On cooldown ( %02i:%02i ).";
std::string IsCooldownAndNoMana = "%s > On cooldown and no mana.";
std::string IsReadyMessage = "%s > is ready.";
std::string WantToLearnMessage = "I want to %s";
std::string WantToPickMessage = "I want to pick > %s";
std::string NeedToChooseMessage = "We need > %s";
std::string WantToBuyMessage = "I want to buy > %s";
std::string NeedToBuyMessage = "We need to buy > %s";
std::string ItemAbiltPlayerHasItem = "%s has > %s";
std::string NeedMoreMana = "Need %i mana for > %s";
std::string IgotSilence = "Can't use %s while silenced";
int ignorelist[ ] = { 1,2,3 };
std::vector<ObjInfoAction> IgnoreObjInfo;
void __stdcall SetCustomDefaultMessage( int id, const char * message )
{
if ( id < 1 || id > 10 || message == NULL )
return;
switch ( id )
{
case 1:
IsCooldownMessage = message;
break;
case 2:
IsReadyMessage = message;
break;
case 3:
WantToLearnMessage = message;
break;
case 4:
WantToPickMessage = message;
break;
case 5:
NeedToChooseMessage = message;
break;
case 6:
WantToBuyMessage = message;
break;
case 7:
NeedToBuyMessage = message;
break;
case 8:
ItemAbiltPlayerHasItem = message;
break;
case 9:
NeedMoreMana = message;
break;
case 10:
IgotSilence = message;
break;
default:
break;
}
}
/*
action
-1 ignore click
0 skip message
1 IsCooldownMessage
2 IsReadyMessage
3 WantToLearnMessage
4 WantToPickMessage
5 WantToBuyMessage
6 ItemAbiltPlayerHasItem
7 CustomMessage ( custommessage )
8 CustomPrintTextMessage ( custommessage )
*/
/*
ObjId
ObjId = CommandData + 4 offset
ObjId2 = CommandData + 8 offset
OrderId
AbilId
ItemId
*/
void __stdcall AddInfoObjCodeCustomAction( int ObjId, int ObjId2, int action, const char * custommessage )
{
if ( ObjId == 0 && ObjId2 == 0 && action == 0 )
{
IgnoreObjInfo.clear( );
}
for ( auto & s : IgnoreObjInfo )
{
if ( s.ObjId == ObjId && s.ObjId2 == ObjId2 )
{
s.Action = action;
s.CustomMessage = custommessage ? custommessage : "";
return;
}
}
IgnoreObjInfo.push_back( ObjInfoAction( ObjId, ObjId2, action, custommessage ? custommessage : "" ) );
}
std::vector< int > InfoWhitelistedObj;
void __stdcall AddInfoWhiteListedObj( int ObjId )
{
if ( ObjId == 0 )
{
InfoWhitelistedObj.clear( );
}
InfoWhitelistedObj.push_back( ObjId );
}
void __stdcall SetInfoObjDebug( BOOL debug )
{
SetInfoObjDebugVal = debug;
}
int GetAbilityManacost( int pAbil )
{
if ( pAbil )
{
int vtable = *( int * )pAbil;
if ( vtable )
{
int GetAbilMPcostAddr = *( int* )( vtable + 0x3d4 );
if ( GetAbilMPcostAddr )
{
auto GetAbilMPcost = ( int( __thiscall * )( int ) )( GetAbilMPcostAddr );
return GetAbilMPcost( pAbil );
}
}
}
return 0;
}
pSimpleButtonPreClickEvent SimpleButtonPreClickEvent_org;
pSimpleButtonPreClickEvent SimpleButtonPreClickEvent_ptr;
int __fastcall SimpleButtonPreClickEvent_my( int pButton, int unused, int a2 )
{
/*__try
{*/
bool incooldown = false;
std::string incooldownmessage = "";
int selectedunit = 0;
char PrintAbilState[ 2048 ];
PrintAbilState[ 0 ] = '\0';
if ( pButton && ( IsKeyPressed( VK_LMENU ) || ( IsKeyPressed( VK_LMENU ) && IsKeyPressed( VK_LCONTROL ) ) ) && IsCommandButton( pButton ) && ( selectedunit = GetSelectedUnit( GetLocalPlayerId( ) ) ) )
{
int CommandButtonData = *( int* )( pButton + 0x190 );
if ( CommandButtonData )
{
//CONSOLE_Print( "Command button" );
int pObjId = *( int* )( CommandButtonData + 4 );
int pItemUnitID = *( int* )( CommandButtonData + 8 );
const char * pAbilTitle = ( const char * )( CommandButtonData + 0x2C );
std::string AbilName = /*ReturnStringBeforeFirstChar(*/ ReturnStringWithoutWarcraftTags( pAbilTitle ? pAbilTitle : "" )/*, '(' )*/;
// AbilName = ReturnStringBeforeFirstChar( AbilName, '[' );
if ( !pObjId )
{
AbilName = ReturnStringBeforeFirstChar( AbilName, '(' );
}
int pAbil = *( int* )( CommandButtonData + 0x6D4 );
//bool AbilFound = pAbil > 0 ;
int pObjId_1 = *( int* )( CommandButtonData + 0x6F8 );
int pObjId_2 = *( int* )( CommandButtonData + 0x6FC );
int pBtnFlag = *( int* )( CommandButtonData + 0x5BC );
int unitownerslot = GetUnitOwnerSlot( ( int )selectedunit );
int localplayeridslot = GetLocalPlayerId( );
int UnitMana = 0;
int AbilManacost = 0;
if ( SetInfoObjDebugVal )
{
char buttoninfo[ 256 ];
sprintf_s( buttoninfo, " Command button %X data -> %X\n Object id: %X \nObject id2: %X \nObject id2: %X \n Abil addr: %X \n Title :%s \n Manacost: %i \n Unit Mana: %i", pButton, CommandButtonData, pObjId, pItemUnitID, pObjId_1, pAbil, ( pAbilTitle ? pAbilTitle : " no " ), AbilManacost, UnitMana );
PrintText( buttoninfo );
}
if ( pObjId && !pAbil )
{
unsigned int abilscount = 0;
int * abils = FindUnitAbils( selectedunit, &abilscount, pObjId );
if ( abilscount > 0 )
{
pAbil = abils[ 0 ];
}
}
if ( pAbil )
{
int pAbilId = *( int* )( pAbil + 0x34 );
if ( pAbilId )
{
if ( AbilName.length( ) <= 2 )
{
AbilName = ReturnStringWithoutWarcraftTags( GetObjectNameByID( pAbilId ) );
}
}
}
if ( *( unsigned int * )( pButton + 0x140 ) & 16 || ( std::find( InfoWhitelistedObj.begin( ), InfoWhitelistedObj.end( ), pObjId ) != InfoWhitelistedObj.end( ) ) )
{
if ( pObjId != 'AHer' && pObjId != 'Asel'&& pObjId != 'Asud'&& pObjId != 'Asid' && pObjId != 'Aneu'
&& pObjId != 0x77123477 && pObjId != 0x07123407 && pObjId != 0x77000077 )
{
if ( pAbil || pObjId )
{
if ( localplayeridslot == unitownerslot )
{
if ( pAbil && *( int* )( pAbil + 0x54 ) )
{
pObjId = *( int* )( pAbil + 0x54 );
pObjId = *( int* )( pObjId + 0x34 );
}
if ( ( std::find( InfoWhitelistedObj.begin( ), InfoWhitelistedObj.end( ), pObjId ) != InfoWhitelistedObj.end( ) )
|| ( pObjId != 'AHer' && pObjId != 'Asel'&& pObjId != 'Asud'&& pObjId != 'Asid'&& pObjId != 'Aneu' ) )
{
unsigned int abilscount = 0;
int * abils = FindUnitAbils( selectedunit, &abilscount, pObjId );
if ( abilscount > 0 )
{
AbilManacost = GetAbilityManacost( abils[ 0 ] );
}
}
}
}
}
}
if ( AbilManacost )
{
float fUnitMana = 0.0f;
GetUnitFloatState( selectedunit, &fUnitMana, 2 );
UnitMana = ( int )fUnitMana;
}
if ( SetInfoObjDebugVal && AbilManacost == 0 )
{
PrintText( "Ignore mana request for button" );
}
for ( auto & s : IgnoreObjInfo )
{
int tmpObj1 = 0;
if ( pAbil && *( int* )( pAbil + 0x54 ) )
{
tmpObj1 = *( int* )( pAbil + 0x54 );
tmpObj1 = *( int* )( tmpObj1 + 0x30 );
}
if ( ( s.ObjId == pObjId || s.ObjId == tmpObj1 || s.ObjId == 0 ) && ( s.ObjId2 == pObjId || s.ObjId2 == pObjId_1 || s.ObjId2 == pItemUnitID || s.ObjId2 == 0 ) )
{
switch ( s.Action )
{
case -1:
return 0;
case 1:
sprintf_s( PrintAbilState, IsCooldownMessage.c_str( ), AbilName.c_str( ) );
SendMessageToChat( PrintAbilState, 0 );
return 0;
case 2:
sprintf_s( PrintAbilState, IsReadyMessage.c_str( ), AbilName.c_str( ) );
SendMessageToChat( PrintAbilState, 0 );
return 0;
case 3:
sprintf_s( PrintAbilState, WantToLearnMessage.c_str( ), AbilName.c_str( ) );
SendMessageToChat( PrintAbilState, 0 );
return 0;
case 4:
if ( !IsKeyPressed( VK_LCONTROL ) )
sprintf_s( PrintAbilState, WantToPickMessage.c_str( ), AbilName.c_str( ) );
else
sprintf_s( PrintAbilState, NeedToChooseMessage.c_str( ), AbilName.c_str( ) );
SendMessageToChat( PrintAbilState, 0 );
return 0;
case 5:
if ( !IsKeyPressed( VK_LCONTROL ) )
sprintf_s( PrintAbilState, WantToBuyMessage.c_str( ), AbilName.c_str( ) );
else
sprintf_s( PrintAbilState, NeedToBuyMessage.c_str( ), AbilName.c_str( ) );
SendMessageToChat( PrintAbilState, 0 );
return 0;
case 6:
sprintf_s( PrintAbilState, ItemAbiltPlayerHasItem.c_str( ), GetPlayerName( unitownerslot, 1 ), AbilName.c_str( ) );
SendMessageToChat( PrintAbilState, 0 );
return 0;
case 7:
sprintf_s( PrintAbilState, ( s.CustomMessage.length( ) > 0 ? s.CustomMessage.c_str( ) : AbilName.c_str( ) ), AbilName.c_str( ) );
SendMessageToChat( PrintAbilState, 0 );
return 0;
case 8:
PrintText( ( s.CustomMessage.length( ) > 0 ? s.CustomMessage.c_str( ) : AbilName.c_str( ) ) );
return 0;
default:
return SimpleButtonPreClickEvent_ptr( pButton, unused, a2 );
}
}
}
if ( AbilName.length( ) > 1 &&
( pItemUnitID == 0xD0142
||
( ( pBtnFlag != 2 && ( pObjId != 'AHer' || pObjId_1 != 0 ) ) && ( pAbil || pObjId || ( pAbilTitle[ 0 ] != '\0' && localplayeridslot != unitownerslot ) ) )
||
( std::find( InfoWhitelistedObj.begin( ), InfoWhitelistedObj.end( ), pObjId ) != InfoWhitelistedObj.end( ) ) ) )
{
if ( SetInfoObjDebugVal )
{
PrintText( "Click Button 1" );
}
if ( unitownerslot != localplayeridslot && unitownerslot != 15 )
{
sprintf_s( PrintAbilState, ItemAbiltPlayerHasItem.c_str( ), GetPlayerName( unitownerslot, 1 ), AbilName.c_str( ) );
}
else
{
sprintf_s( PrintAbilState, IsReadyMessage.c_str( ), AbilName.c_str( ) );
}
if ( unitownerslot == localplayeridslot )
{
if ( pBtnFlag != 2 && pObjId == 'AHer' )
{
sprintf_s( PrintAbilState, WantToLearnMessage.c_str( ), AbilName.c_str( ) );
SendMessageToChat( PrintAbilState, 0 );
return 0;
}
}
if ( pObjId == 'Asel' )
{
//PrintText( "Sell Button" );
char * pObjectIdToStr = ( char * )&pItemUnitID;
if ( isupper( pObjectIdToStr[ 3 ] ) )
{
// PrintText( "Sell hero" );
if ( !IsKeyPressed( VK_LCONTROL ) )
sprintf_s( PrintAbilState, WantToPickMessage.c_str( ), AbilName.c_str( ) );
else
sprintf_s( PrintAbilState, NeedToChooseMessage.c_str( ), AbilName.c_str( ) );
}
else
{
//PrintText( "Sell item" );
if ( !IsKeyPressed( VK_LCONTROL ) )
sprintf_s( PrintAbilState, WantToBuyMessage.c_str( ), AbilName.c_str( ) );
else
sprintf_s( PrintAbilState, NeedToBuyMessage.c_str( ), AbilName.c_str( ) );
}
if ( AbilManacost > UnitMana )
{
sprintf_s( PrintAbilState, NeedMoreMana.c_str( ), ( AbilManacost - UnitMana ), AbilName.c_str( ) );
/*SendMessageToChat( PrintAbilState, 0 );
return 0;*/
}
SendMessageToChat( PrintAbilState, 0 );
return 0;
}
if ( pAbil && unitownerslot == localplayeridslot )
{
//CONSOLE_Print(
if ( SetInfoObjDebugVal )
{
PrintText( "Click Button owner ability!" );
}
int pAbilId = *( int* )( pAbil + 0x34 );
if ( pAbilId && ( *( unsigned int * )( pButton + 0x140 ) & 16 || ( std::find( InfoWhitelistedObj.begin( ), InfoWhitelistedObj.end( ), pObjId ) != InfoWhitelistedObj.end( ) ) ) )
{
if ( pObjId != 'AHer' && pObjId != 'Asel'&& pObjId != 'Asud'&& pObjId != 'Asid' && pObjId != 'Aneu' )
{
//if ( !pObjId )
// AbilName = ReturnStringBeforeFirstChar( ReturnStringWithoutWarcraftTags( pAbilTitle ), '(' );
//else
if ( SetInfoObjDebugVal )
{
PrintText( "Search cooldown " );
}
int pAbilData = *( int* )( pAbil + 0xDC );
if ( pAbilData )
{
if ( SetInfoObjDebugVal )
{
PrintText( "Found 1" );
}
float pAbilDataVal1 = *( float* )( pAbilData + 0x4 );
int pAbilDataVal2tmp = *( int* )( pAbilData + 0xC );
if ( pAbilDataVal1 > 0.0f && pAbilDataVal2tmp )
{
if ( SetInfoObjDebugVal )
{
PrintText( "Found 2" );
}
float pAbilDataVal2 = *( float* )( pAbilDataVal2tmp + 0x40 );
float AbilCooldown = pAbilDataVal1 - pAbilDataVal2;
int AbilCooldownMinutes = ( int )( AbilCooldown / 60.0f );
int AbilCooldownSeconds = ( int )( ( int )AbilCooldown % 60 );
incooldown = true;
sprintf_s( PrintAbilState, IsCooldownMessage.c_str( ), AbilName.c_str( ), AbilCooldownMinutes, AbilCooldownSeconds );
incooldownmessage = PrintAbilState;
}
else
{
if ( SetInfoObjDebugVal )
{
PrintText( "No cooldown Button 1.1" );
}
sprintf_s( PrintAbilState, IsReadyMessage.c_str( ), AbilName.c_str( ) );
}
}
else
{
if ( SetInfoObjDebugVal )
{
PrintText( "No cooldown Button 1.2" );
}
sprintf_s( PrintAbilState, IsReadyMessage.c_str( ), AbilName.c_str( ) );
}
}
}
if ( *( int* )( pAbil + 0x3C ) > 0 )
{
sprintf_s( PrintAbilState, IgotSilence.c_str( ), AbilName.c_str( ) );
SendMessageToChat( PrintAbilState, 0 );
return 0;
}
}
if ( AbilManacost > UnitMana )
{
if ( incooldown )
sprintf_s( PrintAbilState, IsCooldownAndNoMana.c_str( ), AbilName.c_str( ) );
else
sprintf_s( PrintAbilState, NeedMoreMana.c_str( ), ( AbilManacost - UnitMana ), AbilName.c_str( ) );
}
else if ( incooldown )
{
sprintf_s( PrintAbilState, "%s", incooldownmessage.c_str( ) );
}
SendMessageToChat( PrintAbilState, 0 );
return 0;
}
else if ( pAbil )
{
if ( SetInfoObjDebugVal )
{
PrintText( "Click Button 2" );
}
if ( *( int* )( pAbil + 0x3C ) > 0 )
{
sprintf_s( PrintAbilState, IgotSilence.c_str( ), AbilName.c_str( ) );
}
SendMessageToChat( PrintAbilState, 0 );
return 0;
}
}
}
//}
//__except ( g_crashRpt.SendReport( GetExceptionInformation( ) ) )
//{
// ::ExitProcess( 0 ); // It is better to stop the process here or else corrupted data may incomprehensibly crash it later.
// return 0;
//}
return SimpleButtonPreClickEvent_ptr( pButton, unused, a2 );
}
typedef float( __fastcall * pGetCameraHeight/*sub_6F3019A0*/ )( unsigned int a1 );
pGetCameraHeight GetCameraHeight_org;
pGetCameraHeight GetCameraHeight_ptr;
float cameraoffset = 0;
void IncreaseCameraOffset( float offset = 50 )
{
if ( cameraoffset > 3000 )
return;
cameraoffset += offset;
}
void DecreaseCameraOffset( float offset = 50 )
{
if ( cameraoffset < -1000 )
return;
cameraoffset -= offset;
}
void ResetCameraOffset( )
{
cameraoffset = 0;
}
float __fastcall GetCameraHeight_my( unsigned int a1 )
{
return GetCameraHeight_ptr( a1 ) + cameraoffset;
}
DWORD GroupSelectLastTime = GetTickCount( );
int LastSelectedGroupHandle = 0;
BOOL ProcessHotkeys( HWND & hWnd, unsigned int & Msg, WPARAM & wParam, LPARAM & lParam, BOOL & _IsAltPressed,
BOOL & _IsCtrlPressed, BOOL & _IsShiftPressed, BOOL & itempressed, BOOL & ClickHelperWork, BOOL WithModifiers )
{
for ( KeyActionStruct & keyAction : KeyActionList )
{
if ( keyAction.VK == ( int )wParam )
{
if ( SetInfoObjDebugVal )
{
PrintText( "Hotkey vk code found." );
}
TestValues[ 6 ]++;
if ( Msg == WM_SYSKEYDOWN )
Msg = WM_KEYDOWN;
if ( ( !keyAction.IsAlt && !keyAction.IsCtrl && !keyAction.IsShift && !WithModifiers )
||
( WithModifiers && ( ( keyAction.IsAlt && _IsAltPressed )
|| ( keyAction.IsCtrl && _IsCtrlPressed )
|| ( keyAction.IsShift && _IsShiftPressed ) ) )
)
{
BOOL DoubleClicked = FALSE;
if ( !keyAction.IsQuickCast )
{
if ( GetTickCount( ) - keyAction.LastPressTime < 200 )
{
itempressed = !keyAction.IsSkill;
if ( SetInfoObjDebugVal )
{
PrintText( "need doubleclick!" );
}
int selectedunits = GetSelectedUnitCountBigger( GetLocalPlayerId( ) );
int selectedunit = GetSelectedUnit( GetLocalPlayerId( ) );
if ( selectedunit > 0 && selectedunits > 0 )
{
int unitowner = GetUnitOwnerSlot( selectedunit );
if ( SetInfoObjDebugVal )
{
if ( !DoubleClickHelper )
{
PrintText( "doubleclick disabled (!" );
}
}
if ( DoubleClickHelper && unitowner != 15 )
{
if ( IsCursorSelectTarget( ) )
{
if ( SetInfoObjDebugVal )
{
PrintText( "Select hero!" );
}
if ( keyAction.IsShift )
{
SkipSingleShift = GetTickCount( );
}
if ( PressMouseAtSelectedHero( itempressed ) == 0 )
{
ClickHelperWork = TRUE;
if ( SetInfoObjDebugVal )
{
PrintText( "Success double click." );
}
DisableTargetCurcorWORK = 3;
DoubleClicked = TRUE;
}
}
}
}
else
{
if ( SetInfoObjDebugVal )
{
PrintText( "no doubleclick! no units" );
}
}
}
}
if ( DoubleClicked )
{
keyAction.LastPressTime = 0;
return TRUE;
}
if ( SetInfoObjDebugVal )
{
PrintText( "Hotkey availabled!" );
}
//if (itempressed || (keyAction.IsSkill && !IsCursorSelectTarget()))
{
int selectedunits = GetSelectedUnitCountBigger( GetLocalPlayerId( ) );
int selectedunit = GetSelectedUnit( GetLocalPlayerId( ) );
if ( selectedunit > 0 && selectedunits > 0 )
{
int unitowner = GetUnitOwnerSlot( selectedunit );
if ( unitowner != 15 && !ClickHelperWork )
{
if ( EnableSelectHelper )
{
if ( unitowner != GetLocalPlayerId( ) && !GetPlayerAlliance( Player( unitowner ), Player( GetLocalPlayerId( ) ), 6 ) )
{
// sprintf_s( keystateprint, 200, "Start emulate #2..." );
// PrintText( keystateprint );
//PressHeroPanelButton( 0, FALSE );
WarcraftRealWNDProc_ptr( hWnd, WM_KEYDOWN, VK_F1, lpF1ScanKeyDOWN );
WarcraftRealWNDProc_ptr( hWnd, WM_KEYUP, VK_F1, lpF1ScanKeyUP );
if ( SetInfoObjDebugVal )
{
PrintText( "Hotkey delay press start!!" );
}
DelayedPress tmpDelayPress = DelayedPress( );
tmpDelayPress.IsCustom = TRUE;
tmpDelayPress.IsAlt = _IsAltPressed;
tmpDelayPress.IsCtrl = _IsCtrlPressed;
tmpDelayPress.IsShift = _IsShiftPressed;
tmpDelayPress.NeedPresslParam = lParam;
tmpDelayPress.NeedPresswParam = wParam;
tmpDelayPress.NeedPressMsg = Msg;
tmpDelayPress.TimeOut = 140;
DelayedPressList_pushback( tmpDelayPress );
return TRUE;
}
}
BOOL PressedButton = FALSE;
if ( IsNULLButtonFound( GetSkillPanelButton( 11 ) ) )
{
if ( keyAction.altbtnID >= 0 )
{
if ( keyAction.IsSkill )
PressedButton = PressSkillPanelButton( keyAction.altbtnID, keyAction.IsRightClick );
else
PressedButton = PressItemPanelButton( keyAction.btnID, keyAction.IsRightClick );
//PressedButton = TRUE;
}
}
else
{
if ( keyAction.IsSkill )
PressedButton = PressSkillPanelButton( keyAction.btnID, keyAction.IsRightClick );
else
PressedButton = PressItemPanelButton( keyAction.btnID, keyAction.IsRightClick );
//PressedButton = TRUE;
}
/* if ( !PressedButton )
{
if ( SetInfoObjDebugVal )
{
PrintText( "NO ButtonPressed!" );
}
}*/
if ( keyAction.IsQuickCast && PressedButton && IsCursorSelectTarget( ) )
{
if ( SetInfoObjDebugVal )
{
int button = GetSkillPanelButton( 11 );
PrintText( "QuickCast called: ButtonAddr:" + to_string( button ) + ". IsCursorSelectTarget: " + to_string( IsCursorSelectTarget( ) ) );
}
if ( keyAction.IsShift )
{
SkipSingleShift = GetTickCount( );
}
/*int x = ( int )( *GetWindowXoffset );
int y = ( int )( *GetWindowYoffset );
*/
POINT cursorhwnd;
GetCursorPos( &cursorhwnd );
ScreenToClient( Warcraft3Window, &cursorhwnd );
WarcraftRealWNDProc_ptr( Warcraft3Window, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM( cursorhwnd.x, cursorhwnd.y ) );
WarcraftRealWNDProc_ptr( Warcraft3Window, WM_LBUTTONUP, 0, MAKELPARAM( cursorhwnd.x, cursorhwnd.y ) );
DisableTargetCurcorWORK = 3;
/* if ( IsCursorSelectTarget( ) )
{
PressSkillPanelButton( 11, FALSE );
}*/
//POINT cursor;
//GetCursorPos( &cursor );
//x = x - cursorhwnd.x;
//y = y - cursorhwnd.y;
//cursor.x = cursor.x + x;
//cursor.y = cursor.y + y;
////( toXX, toYY );
//MouseClick( cursor.x, cursor.y );
}
else if ( !keyAction.IsQuickCast )
{
if ( SetInfoObjDebugVal )
{
PrintText( "Skip quick cast: no flag!" );
}
}
else if ( !PressedButton )
{
if ( SetInfoObjDebugVal )
{
PrintText( "Skip quick cast: Button not pressed!" );
}
}
//if ( IsNULLButtonFound( GetSkillPanelButton( 11 ) ) )
//{
// if ( keyAction.altbtnID >= 0 )
// {
// if ( SetInfoObjDebugVal )
// {
// PrintText( "OK. Now press panel button." );
// }
// //if ( !( lParam & 0x40000000 ) )
// // {
// if ( keyAction.IsSkill )
// PressSkillPanelButton( keyAction.altbtnID, keyAction.IsRightClick );
// else
// PressItemPanelButton( keyAction.btnID, keyAction.IsRightClick );
// // }
// }
// else
// {
// if ( SetInfoObjDebugVal )
// {
// PrintText( "ERROR. NO ACTION FOUND!" );
// }
// }
//}
//else
//{
// if ( SetInfoObjDebugVal )
// {
// PrintText( "OK. Now press panel button." );
// }
// //if ( !( lParam & 0x40000000 ) )
//// {
// if ( keyAction.IsSkill )
// PressSkillPanelButton( keyAction.btnID, keyAction.IsRightClick );
// else
// PressItemPanelButton( keyAction.btnID, keyAction.IsRightClick );
// // }
//}
}
else
{
if ( SetInfoObjDebugVal )
{
PrintText( "Bad selected unit( player 15 ) or hotkey disabled." );
}
}
}
}
/*else
{
if (SetInfoObjDebugVal)
{
PrintText("No selected unit!");
}
}*/
keyAction.LastPressTime = GetTickCount( );
return TRUE;
}
else
{
if ( SetInfoObjDebugVal )
{
PrintText( "Hotkey not equal skip..." );
}
}
}
}
return FALSE;
}
BOOL ProcessSelectActionHotkeys( HWND & hWnd, unsigned int & Msg, WPARAM & wParam, LPARAM & lParam, BOOL & _IsAltPressed,
BOOL & _IsCtrlPressed, BOOL & _IsShiftPressed, BOOL WithModifiers )
{
for ( auto keyAction : KeySelectActionList )
{
if ( keyAction.VK == ( int )wParam )
{
if ( ( !keyAction.IsAlt && !keyAction.IsCtrl && !keyAction.IsShift && !WithModifiers )
||
( WithModifiers && ( ( keyAction.IsAlt && _IsAltPressed )
|| ( keyAction.IsCtrl && _IsCtrlPressed )
|| ( keyAction.IsShift && _IsShiftPressed ) ) )
)
{
if ( ( keyAction.IsAlt && _IsAltPressed )
|| ( keyAction.IsCtrl && _IsCtrlPressed )
|| ( keyAction.IsShift && _IsShiftPressed )
)
{
if ( Msg == WM_SYSKEYDOWN )
Msg = WM_KEYDOWN;
}
else
{
if ( _IsAltPressed
|| _IsCtrlPressed )
{
}
}
if ( SetInfoObjDebugVal )
{
PrintText( "Clear selection" );
}
vector<int> units = GetUnitsFromGroup( keyAction.GroupHandle );
//reverse( units.begin( ), units.end( ) );
if ( SetInfoObjDebugVal )
{
PrintText( ( "Select units:" + uint_to_hex( units.size( ) ) ).c_str( ) );
}
if ( units.size( ) > 0 )
{
ClearSelection( );
for ( int unit : units )
{
if ( SetInfoObjDebugVal )
{
PrintText( ( "Select unit:" + uint_to_hex( unit ) ).c_str( ) );
}
SelectUnit( unit );
}
if ( GetTickCount( ) - GroupSelectLastTime < 450 &&
LastSelectedGroupHandle == keyAction.GroupHandle )
{
int PortraitButtonAddr = GetGlobalClassAddr( );
if ( PortraitButtonAddr > 0 )
{
PortraitButtonAddr = *( int* )( PortraitButtonAddr + 0x3F4 );
}
if ( PortraitButtonAddr > 0 )
{
if ( SetInfoObjDebugVal )
{
PrintText( "double click to portrain." );
}
Wc3ControlClickButton_org( PortraitButtonAddr, 1 );
Wc3ControlClickButton_org( PortraitButtonAddr, 1 );
}
}
}
LastSelectedGroupHandle = keyAction.GroupHandle;
GroupSelectLastTime = GetTickCount( );
return TRUE;
}
}
}
return FALSE;
}
BOOL ProcessCallbackHotkeys( HWND & hWnd, unsigned int & Msg, WPARAM & wParam, LPARAM & lParam, BOOL & _IsAltPressed,
BOOL & _IsCtrlPressed, BOOL & _IsShiftPressed, BOOL WithModifiers )
{
int selectedunits = GetSelectedUnitCountBigger( GetLocalPlayerId( ) );
int selectedunit = GetSelectedUnit( GetLocalPlayerId( ) );
if ( selectedunit > 0 && selectedunits > 0 )
{
int unitowner = GetUnitOwnerSlot( selectedunit );
if ( unitowner != 15 )
{
for ( auto keyAction : KeyCalbackActionList )
{
if ( keyAction.VK == ( int )wParam )
{
if ( ( !keyAction.IsAlt && !keyAction.IsCtrl && !keyAction.IsShift && !WithModifiers )
||
( WithModifiers && ( ( keyAction.IsAlt && _IsAltPressed )
|| ( keyAction.IsCtrl && _IsCtrlPressed )
|| ( keyAction.IsShift && _IsShiftPressed ) ) )
)
{
if ( SetInfoObjDebugVal )
{
PrintText( "Need keyAction!" );
}
if ( ( keyAction.IsAlt && _IsAltPressed )
|| ( keyAction.IsCtrl && _IsCtrlPressed )
|| ( keyAction.IsShift && _IsShiftPressed )
)
{
if ( Msg == WM_SYSKEYDOWN )
Msg = WM_KEYDOWN;
}
else
{
if ( _IsAltPressed
|| _IsCtrlPressed )
{
}
}
__asm
{
push eax;
mov eax, GameDll;
add eax, 0x3309F0;
call eax;
pop eax;
}
( ( int( __thiscall * )( int, int, int, int, int, int, int ) )( GameDll + 0x37C420 ) )
( keyAction.args[ 0 ], keyAction.args[ 1 ], keyAction.args[ 2 ],
keyAction.args[ 3 ], keyAction.args[ 4 ], keyAction.args[ 5 ], keyAction.args[ 6 ] );
return TRUE;
}
}
}
}
}
return FALSE;
}
BOOL ProcessChatHotkeys( HWND & hWnd, unsigned int & Msg, WPARAM & wParam, LPARAM & lParam, BOOL & _IsAltPressed,
BOOL & _IsCtrlPressed, BOOL & _IsShiftPressed, BOOL WithModifiers )
{
for ( auto keyAction : KeyChatActionList )
{
if ( keyAction.VK == ( int )wParam )
{
if ( ( !keyAction.IsAlt && !keyAction.IsCtrl && !keyAction.IsShift && !WithModifiers ) ||
( WithModifiers && ( ( keyAction.IsAlt && _IsAltPressed )
|| ( keyAction.IsCtrl && _IsCtrlPressed )
|| ( keyAction.IsShift && _IsShiftPressed ) ) )
)
{
if ( ( keyAction.IsAlt && _IsAltPressed )
|| ( keyAction.IsCtrl && _IsCtrlPressed )
|| ( keyAction.IsShift && _IsShiftPressed )
)
{
if ( Msg == WM_SYSKEYDOWN )
Msg = WM_KEYDOWN;
}
else
{
if ( _IsAltPressed
|| _IsCtrlPressed )
{
}
}
SendMessageToChat( keyAction.Message.c_str( ), keyAction.SendToAll );
return TRUE;
}
}
}
return FALSE;
}
BOOL ProcessShopHelper( HWND & hWnd, unsigned int & Msg, WPARAM & wParam, LPARAM & lParam )
{
if ( ShopHelperEnabled && IsGameFrameActive( ) && /*(*/ Msg == WM_KEYDOWN /*|| Msg == WM_KEYUP ) */ )
{
if (
wParam == 'Q' ||
wParam == 'W' ||
wParam == 'E' ||
wParam == 'R' ||
wParam == 'A' ||
wParam == 'S' ||
wParam == 'D' ||
wParam == 'F' ||
wParam == 'Z' ||
wParam == 'X' ||
wParam == 'C' ||
wParam == 'V'
)
{
int selectedunit = GetSelectedUnit( GetLocalPlayerId( ) );
if ( selectedunit > 0 && GetSelectedUnitCountBigger( GetLocalPlayerId( ) ) > 0 )
{
if ( GetUnitOwnerSlot( selectedunit ) == 15 )
{
// | 0 | 3 | 6 | 9 |
// | 1 | 4 | 7 | 10 |
// | 2 | 5 | 8 | 11 |
/* if ( Msg == WM_KEYDOWN && !( lParam & 0x40000000 ) )
{*/
if ( wParam == 'Q' )
PressSkillPanelButton( 0, FALSE );
else if ( wParam == 'W' )
PressSkillPanelButton( 3, FALSE );
else if ( wParam == 'E' )
PressSkillPanelButton( 6, FALSE );
else if ( wParam == 'R' )
PressSkillPanelButton( 9, FALSE );
else if ( wParam == 'A' )
PressSkillPanelButton( 1, FALSE );
else if ( wParam == 'S' )
PressSkillPanelButton( 4, FALSE );
else if ( wParam == 'D' )
PressSkillPanelButton( 7, FALSE );
else if ( wParam == 'F' )
PressSkillPanelButton( 10, FALSE );
else if ( wParam == 'Z' )
PressSkillPanelButton( 2, FALSE );
else if ( wParam == 'X' )
PressSkillPanelButton( 5, FALSE );
else if ( wParam == 'C' )
PressSkillPanelButton( 8, FALSE );
else if ( wParam == 'V' )
PressSkillPanelButton( 11, FALSE );
else
return FALSE;
//}
return TRUE;
}
}
}
}
return FALSE;
}
BOOL SkipKeyboardAndMouseWhenTeleport( HWND & hWnd, unsigned int & Msg, WPARAM & wParam, LPARAM & lParam )
{
if ( BlockKeyboardAndMouseWhenTeleport )
{
if ( Msg == WM_KEYDOWN ||/* Msg == WM_KEYUP || */Msg == WM_RBUTTONDOWN )
{
if ( Msg == WM_RBUTTONDOWN )
{
int selectedunit = GetSelectedUnit( GetLocalPlayerId( ) );
if ( selectedunit > 0 )
{
unsigned int abilscount = 0;
FindUnitAbils( selectedunit, &abilscount, 'A3VO' );
if ( abilscount > 0 )
{
if ( TeleportShiftPress )
{
if ( ShiftPressed == 0 && !ShiftPressed )
{
SingleShift = GetTickCount( );
ShiftPressed = 1;
}
}
else
return TRUE;
}
}
}
if ( ( wParam >= 0x41 && wParam <= 0x5A ) || ( wParam >= VK_NUMPAD1 && wParam <= VK_NUMPAD8 ) )
{
BOOL NeedSkipForTP = TRUE;
for ( int & VK : WhiteListForTeleport )
{
if ( wParam == VK )
{
NeedSkipForTP = FALSE;
break;
}
}
if ( NeedSkipForTP )
{
int selectedunit = GetSelectedUnit( GetLocalPlayerId( ) );
if ( selectedunit > 0 )
{
unsigned int abilscount = 0;
FindUnitAbils( selectedunit, &abilscount, 'A3VO' );
if ( abilscount > 0 )
{
if ( TeleportShiftPress )
{
if ( !ShiftPressed )
{
SingleShift = GetTickCount( );
ShiftPressed = 1;
}
}
else
return TRUE;
}
}
}
}
}
}
return FALSE;
}
jRCString GlobalCallbackForRegisteredHotkeys = jRCString( );
void __stdcall SetGlobalCallbackForRegisteredHotkeys( const char * func )
{
str2jstr( &GlobalCallbackForRegisteredHotkeys, func );
}
WPARAM LatestRegisteredHotkeyWPARAM = 0;
int __stdcall GetLatestRegisteredHotkeyWPARAM( int )
{
return ( int )LatestRegisteredHotkeyWPARAM;
}
int LatestRegisteredHotkeyMsg = 0;
int __stdcall GetLatestRegisteredHotkeyMsg( int )
{
return LatestRegisteredHotkeyMsg;
}
BOOL ProcessRegisteredHotkeys( HWND & hWnd, unsigned int & Msg, WPARAM & wParam, LPARAM & lParam )
{
LatestRegisteredHotkeyWPARAM = wParam;
LatestRegisteredHotkeyMsg = Msg;
if ( Msg == WM_KEYDOWN || Msg == WM_KEYUP ||
Msg == WM_LBUTTONDOWN || Msg == WM_MBUTTONDOWN || Msg == WM_RBUTTONDOWN ||
Msg == WM_LBUTTONUP || Msg == WM_MBUTTONUP || Msg == WM_RBUTTONUP )
{
for ( int keyCode : RegisteredKeyCodes )
{
bool keycodefound = true;
if ( keyCode != ( int )wParam )
{
keycodefound = false;
keyCode = keyCode - 0x1000;
}
if ( keycodefound || keyCode == WM_KEYDOWN || keyCode == WM_KEYUP ||
keyCode == WM_LBUTTONDOWN || keyCode == WM_MBUTTONDOWN || keyCode == WM_RBUTTONDOWN ||
keyCode == WM_LBUTTONUP || keyCode == WM_MBUTTONUP || keyCode == WM_RBUTTONUP )
{
if ( Msg == WM_KEYDOWN || Msg == WM_LBUTTONDOWN || Msg == WM_MBUTTONDOWN || Msg == WM_RBUTTONDOWN )
{
if ( SetInfoObjDebugVal )
{
PrintText( "KEY_DOWN" );
}
if ( GlobalCallbackForRegisteredHotkeys.stringRep == NULL )
{
//BytesToSend.push_back( 0x50 );
//// packet header
//BytesToSend.push_back( 0xFF );
//// packet size
//BytesToSend.push_back( 0 );
//BytesToSend.push_back( 0 );
//BytesToSend.push_back( 0 );
//BytesToSend.push_back( 0 );
SendKeyEvent.push_back( 0x50 );
// header custom packets
SendKeyEvent.push_back( 0xFF );
// size custom packets
SendKeyEvent.push_back( 0 );
SendKeyEvent.push_back( 0 );
SendKeyEvent.push_back( 0 );
SendKeyEvent.push_back( 0 );
// packet type
int packettype = 'IKEY';
SendKeyEvent.insert( SendKeyEvent.end( ), ( unsigned char * )&packettype, ( ( unsigned char * )&packettype ) + 4 );
*( int* )&SendKeyEvent[ 2 ] += 4;
// data
int locpid = GetLocalPlayerId( );
SendKeyEvent.insert( SendKeyEvent.end( ), ( unsigned char * )&locpid, ( ( unsigned char * )&locpid ) + 4 );
*( int* )&SendKeyEvent[ 2 ] += 4;
SendKeyEvent.insert( SendKeyEvent.end( ), ( unsigned char * )&Msg, ( ( unsigned char * )&Msg ) + 4 );
*( int* )&SendKeyEvent[ 2 ] += 4;
SendKeyEvent.insert( SendKeyEvent.end( ), ( unsigned char * )&wParam, ( ( unsigned char * )&wParam ) + 4 );
*( int* )&SendKeyEvent[ 2 ] += 4;
SendPacket( ( unsigned char* )&SendKeyEvent[ 0 ], SendKeyEvent.size( ) );
SendKeyEvent.clear( );
}
else
{
//*KeyboardAddrForKey = ( int ) wParam;
//*KeyboardAddrForKeyEvent = ( int ) Msg;
// TriggerExecute( KeyboardTriggerHandle );
ExecuteFunc( &GlobalCallbackForRegisteredHotkeys );
}
return bTriggerRegisterPlayerKeyboardBlock;
}
else if ( Msg == WM_KEYUP || Msg == WM_LBUTTONUP || Msg == WM_MBUTTONUP || Msg == WM_RBUTTONUP )
{
if ( SetInfoObjDebugVal )
{
PrintText( "KEY_UP" );
}
if ( GlobalCallbackForRegisteredHotkeys.stringRep == NULL )
{
SendKeyEvent.push_back( 0x50 );
// header custom packets
SendKeyEvent.push_back( 0xFF );
// size custom packets
SendKeyEvent.push_back( 0 );
SendKeyEvent.push_back( 0 );
SendKeyEvent.push_back( 0 );
SendKeyEvent.push_back( 0 );
// packet type
int packettype = 'IKEY';
SendKeyEvent.insert( SendKeyEvent.end( ), ( unsigned char * )&packettype, ( ( unsigned char * )&packettype ) + 4 );
*( int* )&SendKeyEvent[ 2 ] += 4;
// data
int locpid = GetLocalPlayerId( );
SendKeyEvent.insert( SendKeyEvent.end( ), ( unsigned char * )&locpid, ( ( unsigned char * )&locpid ) + 4 );
*( int* )&SendKeyEvent[ 2 ] += 4;
SendKeyEvent.insert( SendKeyEvent.end( ), ( unsigned char * )&Msg, ( ( unsigned char * )&Msg ) + 4 );
*( int* )&SendKeyEvent[ 2 ] += 4;
SendKeyEvent.insert( SendKeyEvent.end( ), ( unsigned char * )&wParam, ( ( unsigned char * )&wParam ) + 4 );
*( int* )&SendKeyEvent[ 2 ] += 4;
SendPacket( ( unsigned char* )&SendKeyEvent[ 0 ], SendKeyEvent.size( ) );
SendKeyEvent.clear( );
}
else
{
//*KeyboardAddrForKey = ( int ) wParam;
//*KeyboardAddrForKeyEvent = ( int ) Msg;
// TriggerExecute( KeyboardTriggerHandle );
ExecuteFunc( &GlobalCallbackForRegisteredHotkeys );
}
return bTriggerRegisterPlayerKeyboardBlock;
}
else
{
if ( SetInfoObjDebugVal )
{
PrintText( "UNKNOWN_KEY_EVENT" );
}
}
}
}
}
return FALSE;
}
BOOL FixNumpad( HWND & hWnd, unsigned int & Msg, WPARAM & wParam, WPARAM & _wParam, LPARAM & lParam, BOOL & _IsShiftPressed )
{
// SHIFT+NUMPAD TRICK
if ( IsGameFrameActive( ) && ( Msg == WM_KEYDOWN || Msg == WM_KEYUP ) && (
wParam == 0xC ||
wParam == 0x23 ||
wParam == 0x24 ||
wParam == 0x25 ||
wParam == 0x26 ||
wParam == 0x28
) )
{
int scanCode = ( int )( ( lParam >> 24 ) & 0x1 );
if ( scanCode != 1 )
{
switch ( wParam )
{
case 0x23:
wParam = VK_NUMPAD1;
break;
case 0x28:
wParam = VK_NUMPAD2;
break;
case 0x25:
wParam = VK_NUMPAD4;
break;
case 0xC:
wParam = VK_NUMPAD5;
break;
case 0x24:
wParam = VK_NUMPAD7;
break;
case 0x26:
wParam = VK_NUMPAD8;
break;
default:
break;
}
if ( wParam != _wParam )
{
if ( !_IsShiftPressed )
{
BOOL NumLock = ( ( ( unsigned short )GetKeyState( VK_NUMLOCK ) ) & 0xffff ) != 0;
if ( NumLock )
ShiftPressed = 0x1;
else
ShiftPressed = 0x0;
}
//if (Msg == WM_KEYDOWN && IsNumpadPressed(wParam))
//{
// bool NotFoundInHotKeys = true;
// for (KeyActionStruct & keyAction : KeyActionList)
// {
// if (keyAction.VK == wParam)
// {
// NotFoundInHotKeys = false;
// }
// }
// if (NotFoundInHotKeys)
// {
// int btnaddr = GetBtnAddrByNumpad(wParam);
// if (btnaddr)
// {
// SimpleButtonClickEvent_my(btnaddr, 0, 1);
// /*if ( CheckBtnForClickPortrain( btnaddr ) )
// {
// SimpleButtonClickEvent_my( btnaddr, 0, 1 );*/
// return TRUE;
// //int PortraitButtonAddr = GetGlobalClassAddr( );
// //if ( PortraitButtonAddr > 0 )
// //{
// // PortraitButtonAddr = *( int* )( PortraitButtonAddr + 0x3F4 );
// //}
// //if ( PortraitButtonAddr > 0 )
// //{
// // //PrintText( "Click to portrain." );
// // Wc3ControlClickButton_org( PortraitButtonAddr, 1 );
// //}
// //}
// }
// }
//}
//LRESULT retval1 = WarcraftRealWNDProc_ptr(hWnd, Msg, wParam, lParam);
//return FALSE;
}
}
else
{
if ( !_IsShiftPressed )
{
ShiftPressed = 0;
}
}
}
return FALSE;
}
LRESULT __fastcall WarcraftWindowProcHooked( HWND hWnd, unsigned int _Msg, WPARAM _wParam, LPARAM lParam )
{
if ( Warcraft3Window != hWnd && hWnd != NULL )
{
Warcraft3Window = hWnd;
SetWar3Window( hWnd );
}
DreamUI_WarWindow3Proc( hWnd, _Msg, _wParam, lParam );
if ( !InitTestValues )
{
InitTestValues = true;
memset( TestValues, 0, sizeof( TestValues ) );
}
TestValues[ 0 ]++;
unsigned int Msg = _Msg;
BOOL ClickHelperWork = FALSE;
WPARAM wParam = _wParam;
BOOL _IsCtrlPressed = IsKeyPressed( VK_CONTROL );
BOOL _IsShiftPressed = IsKeyPressed( VK_SHIFT );
BOOL _IsAltPressed = IsKeyPressed( VK_MENU );
if ( _Msg == WM_KEYDOWN )
{
LatestPressedKey = 0;
}
if ( _Msg == WM_SIZE )
{
for ( auto & v : ListOfRawImages )
v.needResetTexture = TRUE;
}
// NEXT BLOCK ONLY FOR TEST!!!!
//if ( Msg == WM_KEYDOWN && TestModeActivated )
//{
// ShowConfigWindow( ".\\config.dota" );
//}
if ( SkipAllMessages || TerminateStarted )
{
if ( SetInfoObjDebugVal )
{
PrintText( "SkipAllMessages" );
}
return DefWindowProc( hWnd, Msg, wParam, lParam );
}
if ( SetInfoObjDebugVal && _Msg == WM_KEYDOWN )
{
PrintText( "!" );
}
//if ( Msg == WM_KEYDOWN && wParam == VK_ESCAPE )
//{
// MessageBoxA( 0, "WMKEYDOWNESCAPE", "", 0 );
// if ( IsKeyPressed( '1' ) )
// return DefWindowProc( hWnd, Msg, wParam, lParam );
//}
//if ( Msg == WM_KEYUP && wParam == VK_ESCAPE )
//{
// MessageBoxA( 0, "WMKEYUPESCAPE", "", 0 );
// if ( IsKeyPressed( '1' ) )
// return DefWindowProc( hWnd, Msg, wParam, lParam );
//}
//if ( !DebugMsgShow )
//{
// DebugMsgShow = TRUE;
// if ( IsKeyPressed( VK_F1 ) )
// {
// char debugmsg[ 200 ];
// sprintf_s( debugmsg, "Current file cache size:%i", ICONMDLCACHELIST.size( ) );
// MessageBoxA( 0, debugmsg, debugmsg, 0 );
// }
// DebugMsgShow = FALSE;
//}
if ( !IsGame( ) )
{
return WarcraftRealWNDProc_ptr( hWnd, Msg, wParam, lParam );
}
if ( SetInfoObjDebugVal && _Msg == WM_KEYDOWN )
{
PrintText( "@" );
}
else
{
if ( SetInfoObjDebugVal && Msg == WM_KEYDOWN )
{
PrintText( "@2" );
}
}
if ( usedcustomframes && *( int* )ChatFound == 0 && IsGameFrameActive( ) )
{
*( int* )pCurrentFrameFocusedAddr = 0;
}
if ( !IsGameFrameActive( ) )
{
if ( SetInfoObjDebugVal && Msg == WM_KEYDOWN )
{
PrintText( "!IsGameFrameActive" );
}
return WarcraftRealWNDProc_ptr( hWnd, Msg, wParam, lParam );
}
DisableTargetCurcor( );
//if ( _Msg == WM_LBUTTONDOWN )
//{
// if ( IsKeyPressed( VK_F1 ) )
// {
// char debugmsg[ 200 ];
// sprintf_s( debugmsg, "_Msg:%X WPARAM:%X LPARAM:%X", Msg, _wParam, lParam );
// MessageBoxA( 0, debugmsg, debugmsg, 0 );
// }
//}
TestValues[ 1 ]++;
if ( _Msg == WM_MOUSEWHEEL && IsKeyPressed( VK_LCONTROL ) )
{
short wheeltarg = HIWORD( _wParam );
if ( wheeltarg > 0 )
{
DecreaseCameraOffset( );
}
else
{
IncreaseCameraOffset( );
}
WarcraftRealWNDProc_ptr( hWnd, WM_SYSKEYDOWN, VK_PRIOR, NULL );
WarcraftRealWNDProc_ptr( hWnd, WM_SYSKEYDOWN, VK_NEXT, NULL );
return DefWindowProc( hWnd, Msg, wParam, lParam );
}
if ( _Msg == WM_MBUTTONDOWN && IsKeyPressed( VK_LCONTROL ) )
{
ResetCameraOffset( );
WarcraftRealWNDProc_ptr( hWnd, WM_SYSKEYDOWN, VK_PRIOR, NULL );
WarcraftRealWNDProc_ptr( hWnd, WM_SYSKEYDOWN, VK_NEXT, NULL );
return DefWindowProc( hWnd, Msg, wParam, lParam );
}
if ( Msg == WM_LBUTTONDOWN || Msg == WM_RBUTTONDOWN || Msg == WM_MBUTTONDOWN || Msg == WM_LBUTTONUP || Msg == WM_RBUTTONUP || Msg == WM_MBUTTONUP )
{
DisableInputForAnyHotkeyAndEditBox( );
}
if ( IsAnyEditBoxIsActive( ) )
{
if ( _Msg == WM_KEYDOWN || _Msg == WM_SYSKEYDOWN )
{
if ( wParam == VK_BACK )
{
CurrentEditBoxRemoveCharacter( false );
}
else if ( wParam == VK_DELETE )
{
CurrentEditBoxRemoveCharacter( true );
}
else if ( wParam == VK_LEFT )
{
CurrentEditBoxMoveCursorLeft( );
}
else if ( wParam == VK_RIGHT )
{
CurrentEditBoxMoveCursorRight( );
}
else
{
unsigned char _keystate[ 256 ];
WCHAR _inputbuf[ 32 ]{ 0 };
GetKeyboardState( _keystate );
if ( !( MapVirtualKey( wParam, MAPVK_VK_TO_CHAR ) >> ( sizeof( UINT ) * 8 - 1 ) & 1 ) )
{
if ( ToUnicode( wParam, MapVirtualKey( wParam, 0 ),
_keystate, _inputbuf, 32, 0 ) >= 1 )
{
CurrentEditBoxEnterText( _inputbuf );
}
}
}
return DefWindowProc( hWnd, Msg, wParam, lParam );
}
}
if ( ( lParam & 0x40000000 ) && Msg == WM_KEYDOWN && !*( int* )ChatFound )
{
if ( SetInfoObjDebugVal )
{
PrintText( "Skip1" );
}
return DefWindowProc( hWnd, Msg, wParam, lParam );
}
if ( IsAnyHotkeyIsActive( ) )
{
if ( _Msg == WM_KEYDOWN || _Msg == WM_KEYUP || _Msg == WM_SYSKEYDOWN || _Msg == WM_SYSKEYUP ||
/*_Msg == WM_LBUTTONUP || _Msg == WM_LBUTTONDOWN ||*/ _Msg == WM_RBUTTONUP || _Msg == WM_RBUTTONDOWN ||
_Msg == WM_MBUTTONDOWN || _Msg == WM_MBUTTONUP )
{
return DefWindowProc( hWnd, Msg, wParam, lParam );
}
}
TestValues[ 2 ]++;
if ( Msg == WM_MOUSEMOVE )
{
GlobalMousePos = MAKEPOINTS( lParam );
}
if ( *IsWindowActive || ForceLvl2 )
{
TestValues[ 3 ]++;
if ( Msg == WM_LBUTTONUP )
{
ProcessClickAtCustomFrames( );
}
if ( GlobalRawImageCallbackData )
{
if ( Msg == WM_LBUTTONUP )
{
GlobalRawImageCallbackData->IsLeftButton = TRUE;
RawImageGlobalCallbackFunc( RawImageEventType::MouseUp, ( float )GlobalMousePos.x, ( float )GlobalMousePos.y );
}
if ( Msg == WM_LBUTTONDOWN )
{
GlobalRawImageCallbackData->IsLeftButton = TRUE;
if ( RawImageGlobalCallbackFunc( RawImageEventType::MouseDown, ( float )GlobalMousePos.x, ( float )GlobalMousePos.y ) )
{
if ( SetInfoObjDebugVal )
{
PrintText( "Skip WM_LBUTTONDOWN" );
}
return DefWindowProc( hWnd, Msg, wParam, lParam );
}
else
{
if ( SetInfoObjDebugVal )
{
PrintText( "No Skip WM_LBUTTONDOWN" );
}
}
}
if ( Msg == WM_RBUTTONUP )
{
GlobalRawImageCallbackData->IsLeftButton = FALSE;
RawImageGlobalCallbackFunc( RawImageEventType::MouseUp, ( float )GlobalMousePos.x, ( float )GlobalMousePos.y );
}
if ( Msg == WM_RBUTTONDOWN )
{
GlobalRawImageCallbackData->IsLeftButton = FALSE;
if ( RawImageGlobalCallbackFunc( RawImageEventType::MouseDown, ( float )GlobalMousePos.x, ( float )GlobalMousePos.y ) )
return DefWindowProc( hWnd, Msg, wParam, lParam );
}
if ( Msg == WM_MOUSEMOVE )
{
RawImageGlobalCallbackFunc( RawImageEventType::MouseMove, ( float )GlobalMousePos.x, ( float )GlobalMousePos.y );
}
}
if ( LOCK_MOUSE_IN_WINDOW )
{
POINT p;
tagWINDOWINFO pwi;
if ( Warcraft3Window && GetCursorPos( &p ) && GetWindowInfo( Warcraft3Window, &pwi ) && IsMouseOverWindow( pwi.rcClient, p ) )
{
ClipCursor( &pwi.rcClient );
}
else
{
ClipCursor( 0 );
}
}
if ( FPS_LIMIT_ENABLED )
{
auto t_end = std::chrono::high_resolution_clock::now( );
if ( std::chrono::duration<float, std::milli>( t_end - t_start ).count( ) > 250.0 )
{
t_start = t_end;
UpdateFPS( );
}
}
if ( AutoSelectHero )
{
if ( Msg == WM_KEYDOWN && wParam >= VK_F1 && wParam <= VK_F5 )
{
LPARAM lpFKEYScanKeyUP = ( LPARAM )( 0xC0000001 | ( LPARAM )( MapVirtualKey( wParam, 0 ) << 16 ) );
LPARAM lpFKEYScanKeyDOWN = ( LPARAM )( 0x00000001 | ( LPARAM )( MapVirtualKey( wParam, 0 ) << 16 ) );
WarcraftRealWNDProc_ptr( hWnd, WM_KEYDOWN, wParam, lpFKEYScanKeyDOWN );
WarcraftRealWNDProc_ptr( hWnd, WM_KEYUP, wParam, lpFKEYScanKeyUP );
}
}
if ( ( Msg == WM_KEYDOWN || Msg == WM_KEYUP ) && ( _wParam == VK_SHIFT || _wParam == VK_LSHIFT || _wParam == VK_RSHIFT ) )
{
ShiftPressed = ( unsigned char )( Msg == WM_KEYDOWN ? 0x1u : 0x0u );
}
if ( Msg == WM_RBUTTONDOWN )
{
ShiftPressed = ( unsigned char )( _IsShiftPressed ? 0x1u : 0x0u );
}
for ( unsigned int i = 0; i < SkipMessagesList.size( ); i++ )
{
if ( SkipMessagesList[ i ].Msg == Msg && SkipMessagesList[ i ].wParam == wParam )
{
SkipMessagesList.erase( SkipMessagesList.begin( ) + ( int )i );
if ( SetInfoObjDebugVal )
{
PrintText( "SKIP SINGLE MSG" );
}
return DefWindowProc( hWnd, Msg, wParam, lParam );
}
}
if ( Msg == WM_MOUSEMOVE && BLOCKMOUSEMOVING )
{
if ( SetInfoObjDebugVal )
{
PrintText( "MOUSE MOVING BLOCKED" );
}
return DefWindowProc( hWnd, Msg, wParam, lParam );
}
TestValues[ 4 ]++;
if ( ( *( int* )ChatFound == 0 || ForceLvl3 ) && ( IsGameFrameActive( ) || ForceLvl1 ) )
{
TestValues[ 5 ]++;
//char keystateprint[ 200 ];
if ( SetInfoObjDebugVal && ( Msg == WM_KEYUP || Msg == WM_KEYDOWN ) )
{
PrintText( "Fix numpad..." );
}
if ( FixNumpad( hWnd, Msg, wParam, _wParam, lParam, _IsShiftPressed ) )
{
return DefWindowProc( hWnd, Msg, wParam, lParam );
}
if ( SetInfoObjDebugVal && ( Msg == WM_KEYUP || Msg == WM_KEYDOWN ) )
{
PrintText( "Fix numpad OK" );
}
if ( Msg == WM_KEYDOWN && IsNumpadPressed( wParam ) && IsGameFrameActive( ) )
{
bool NotFoundInHotKeys = true;
for ( KeyActionStruct & keyAction : KeyActionList )
{
if ( keyAction.VK == wParam )
{
NotFoundInHotKeys = false;
}
}
if ( NotFoundInHotKeys )
{
int btnaddr = GetBtnAddrByNumpad( wParam );
if ( btnaddr )
{
SimpleButtonClickEvent_my( btnaddr, 0, 1 );
return DefWindowProc( hWnd, Msg, wParam, lParam );
}
}
}
if ( SetInfoObjDebugVal )
{
if ( Msg == WM_KEYDOWN || Msg == WM_KEYUP ||
Msg == WM_LBUTTONDOWN || Msg == WM_MBUTTONDOWN || Msg == WM_RBUTTONDOWN ||
Msg == WM_LBUTTONUP || Msg == WM_MBUTTONUP || Msg == WM_RBUTTONUP )
{
char tempDebugMsg[ 256 ];
sprintf_s( tempDebugMsg, "DEBUG MSG:%X WPARAM:%X LPARAM:%X", _Msg, _wParam, lParam );
PrintText( tempDebugMsg );
}
}
if ( ProcessRegisteredHotkeys( hWnd, Msg, wParam, lParam ) )
{
return DefWindowProc( hWnd, Msg, wParam, lParam );
}
if ( SetInfoObjDebugVal && ( Msg == WM_KEYUP || Msg == WM_KEYDOWN ) )
{
PrintText( "SkipKeyboardAndMouseWhenTeleport..." );
}
if ( SkipKeyboardAndMouseWhenTeleport( hWnd, Msg, wParam, lParam ) )
{
return DefWindowProc( hWnd, Msg, wParam, lParam );
}
if ( Msg == WM_KEYDOWN || Msg == WM_XBUTTONDOWN || Msg == WM_MBUTTONDOWN ||
Msg == WM_SYSKEYDOWN )
{
BOOL itempressed = FALSE;
if ( _Msg == WM_XBUTTONDOWN )
{
Msg = WM_KEYDOWN;
wParam = _wParam & MK_XBUTTON1 ? VK_XBUTTON1 : VK_XBUTTON2;
}
if ( _Msg == WM_MBUTTONDOWN )
{
Msg = WM_KEYDOWN;
wParam = VK_MBUTTON;
}
if ( SetInfoObjDebugVal && ( Msg == WM_KEYUP || Msg == WM_KEYDOWN ) )
{
PrintText( "ProcessShopHelper..." );
}
if ( ProcessShopHelper( hWnd, Msg, wParam, lParam ) )
{
return DefWindowProc( hWnd, Msg, wParam, lParam );
}
if ( SetInfoObjDebugVal && ( Msg == WM_KEYUP || Msg == WM_KEYDOWN ) )
{
PrintText( "ProcessChatHotkeys..." );
}
if ( ProcessChatHotkeys( hWnd, Msg, wParam, lParam, _IsAltPressed, _IsCtrlPressed, _IsShiftPressed, TRUE ) ||
ProcessChatHotkeys( hWnd, Msg, wParam, lParam, _IsAltPressed, _IsCtrlPressed, _IsShiftPressed, FALSE ) )
{
return DefWindowProc( hWnd, Msg, wParam, lParam );
}
if ( SetInfoObjDebugVal && ( Msg == WM_KEYUP || Msg == WM_KEYDOWN ) )
{
PrintText( "ProcessHotkeys..." );
}
if ( ProcessHotkeys( hWnd, Msg, wParam, lParam, _IsAltPressed, _IsCtrlPressed, _IsShiftPressed, itempressed, ClickHelperWork, TRUE ) ||
ProcessHotkeys( hWnd, Msg, wParam, lParam, _IsAltPressed, _IsCtrlPressed, _IsShiftPressed, itempressed, ClickHelperWork, FALSE ) )
{
return DefWindowProc( hWnd, Msg, wParam, lParam );
}
if ( SetInfoObjDebugVal && ( Msg == WM_KEYUP || Msg == WM_KEYDOWN ) )
{
PrintText( "ProcessCallbackHotkeys..." );
}
if ( ProcessCallbackHotkeys( hWnd, Msg, wParam, lParam, _IsAltPressed, _IsCtrlPressed, _IsShiftPressed, TRUE ) ||
ProcessCallbackHotkeys( hWnd, Msg, wParam, lParam, _IsAltPressed, _IsCtrlPressed, _IsShiftPressed, FALSE ) )
{
return DefWindowProc( hWnd, Msg, wParam, lParam );
}
if ( SetInfoObjDebugVal && ( Msg == WM_KEYUP || Msg == WM_KEYDOWN ) )
{
PrintText( "ProcessSelectActionHotkeys..." );
}
if ( ProcessSelectActionHotkeys( hWnd, Msg, wParam, lParam, _IsAltPressed, _IsCtrlPressed, _IsShiftPressed, TRUE ) ||
ProcessSelectActionHotkeys( hWnd, Msg, wParam, lParam, _IsAltPressed, _IsCtrlPressed, _IsShiftPressed, FALSE ) )
{
return DefWindowProc( hWnd, Msg, wParam, lParam );
}
if ( SetInfoObjDebugVal && ( Msg == WM_KEYUP || Msg == WM_KEYDOWN ) )
{
PrintText( "ProcessSelectActionHotkeys ok" );
}
for ( int & keyCode : BlockedKeyCodes )
{
if ( keyCode == ( int )wParam )
{
return DefWindowProc( hWnd, Msg, wParam, lParam );
}
}
Msg = _Msg;
wParam = _wParam;
if ( ( wParam >= 0x41 && wParam <= 0x5A ) ||
( wParam >= VK_NUMPAD1 && wParam <= VK_NUMPAD8 ) )
{
int selectedunits = GetSelectedUnitCountBigger( GetLocalPlayerId( ) );
int unitowner = selectedunits > 0 ? GetUnitOwnerSlot( GetSelectedUnit( GetLocalPlayerId( ) ) ) : 0;
if ( selectedunits == 1 )
{
if ( EnableSelectHelper )
{
if ( selectedunits == 0 ||
( unitowner != GetLocalPlayerId( ) && !GetPlayerAlliance( Player( unitowner ), Player( GetLocalPlayerId( ) ), 6 ) ) )
{
WarcraftRealWNDProc_ptr( hWnd, WM_KEYDOWN, VK_F1, lpF1ScanKeyDOWN );
WarcraftRealWNDProc_ptr( hWnd, WM_KEYUP, VK_F1, lpF1ScanKeyUP );
DelayedPress tmpDelayPress;
tmpDelayPress.NeedPresslParam = lParam;
tmpDelayPress.NeedPresswParam = wParam;
tmpDelayPress.NeedPressMsg = 0;
tmpDelayPress.TimeOut = 60;
DelayedPressList_pushback( tmpDelayPress );
return WarcraftRealWNDProc_ptr( hWnd, Msg, wParam, lParam );
}
}
}
if ( !ClickHelperWork && DoubleClickHelper )
{
if ( GetTickCount( ) - LastPressedKeysTime[ wParam ] < 450 && ( ( wParam == LatestPressedKey && LatestButtonClickTime + 500 > GetTickCount( ) ) || wParam != LatestPressedKey ) )
{
itempressed = itempressed || ( wParam >= VK_NUMPAD1 && wParam <= VK_NUMPAD8 );
if ( IsCursorSelectTarget( ) )
{
if ( PressMouseAtSelectedHero( itempressed ) == 0 )
{
LastPressedKeysTime[ wParam ] = 0;
if ( wParam >= VK_NUMPAD1 && wParam <= VK_NUMPAD8 )
{
LastPressedKeysTime[ wParam ] = 0;
return DefWindowProc( hWnd, Msg, wParam, lParam );
}
}
}
}
else
{
LastPressedKeysTime[ wParam ] = GetTickCount( );
}
}
}
}
if ( Msg == WM_LBUTTONDOWN )
{
oldlParam = lParam;
}
if ( Msg == WM_RBUTTONDOWN )
{
if ( EnableSelectHelper )
{
int selectedunits = GetSelectedUnitCountBigger( GetLocalPlayerId( ) );
int unitowner = selectedunits > 0 ? GetUnitOwnerSlot( GetSelectedUnit( GetLocalPlayerId( ) ) ) : 0;
if ( selectedunits == 0 ||
( unitowner != GetLocalPlayerId( ) && ( unitowner == 15 || !GetPlayerAlliance( Player( unitowner ), Player( GetLocalPlayerId( ) ), 6 ) ) )
)
{
//PressHeroPanelButton( 0, FALSE );
WarcraftRealWNDProc_ptr( hWnd, WM_KEYDOWN, VK_F1, lpF1ScanKeyDOWN );
WarcraftRealWNDProc_ptr( hWnd, WM_KEYUP, VK_F1, lpF1ScanKeyUP );
}
}
}
}
if ( Msg == WM_KEYDOWN )
{
if ( SetInfoObjDebugVal )
{
PrintText( "end 1 " );
}
}
}
else
{
// Process RawImages. Mouse up and leave;
if ( GlobalRawImageCallbackData )
RawImageGlobalCallbackFunc( RawImageEventType::ALL, 0.0f, 0.0f );
if ( LOCK_MOUSE_IN_WINDOW )
ClipCursor( 0 );
if ( BlockKeyAndMouseEmulation )
{
if ( Msg == WM_RBUTTONDOWN || Msg == WM_KEYDOWN || Msg == WM_KEYUP )
{
return DefWindowProc( hWnd, Msg, wParam, lParam );
}
}
}
return WarcraftRealWNDProc_ptr( hWnd, Msg, wParam, lParam );
}
int __stdcall ToggleBlockKeyAndMouseEmulation( BOOL enable )
{
BlockKeyAndMouseEmulation = enable;
return 0;
}
int __stdcall ToggleForcedSubSelection( BOOL enable )
{
EnableSelectHelper = enable;
return 0;
}
int __stdcall ToggleClickHelper( BOOL enable )
{
DoubleClickHelper = enable;
return 0;
}
#pragma region Фикс шифта для приказов
typedef int( __stdcall * IssueWithoutTargetOrder )( int a1, int a2, unsigned int a3, unsigned int a4 );
typedef int( __stdcall * IssueTargetOrPointOrder2 )( int a1, int a2, float a3, float a4, int a5, int a6 );
typedef int( __stdcall * sub_6F339D50 )( int a1, int a2, int a3, unsigned int a4, unsigned int a5 );
typedef int( __stdcall * IssueTargetOrPointOrder )( int a1, int a2, float a3, float a4, int a5, int a6, int a7 );
typedef int( __stdcall * sub_6F339E60 )( int a1, int a2, float a3, float a4, int a5, int a6, int a7, int a8 );
typedef int( __stdcall * sub_6F339F00 )( int a1, int a2, int a3, unsigned int a4, unsigned int a5 );
typedef int( __stdcall * sub_6F339F80 )( int a1, int a2, float a3, float a4, int a5, int a6, int a7 );
typedef int( __stdcall * sub_6F33A010 )( int a1, int a2, float a3, float a4, int a5, int a6, int a7, int a8 );
IssueWithoutTargetOrder IssueWithoutTargetOrderorg;
IssueWithoutTargetOrder IssueWithoutTargetOrderptr;
IssueTargetOrPointOrder2 IssueTargetOrPointOrder2org;
IssueTargetOrPointOrder2 IssueTargetOrPointOrder2ptr;
sub_6F339D50 sub_6F339D50org;
sub_6F339D50 sub_6F339D50ptr;
IssueTargetOrPointOrder IssueTargetOrPointOrderorg;
IssueTargetOrPointOrder IssueTargetOrPointOrderptr;
sub_6F339E60 sub_6F339E60org;
sub_6F339E60 sub_6F339E60ptr;
sub_6F339F00 sub_6F339F00org;
sub_6F339F00 sub_6F339F00ptr;
sub_6F339F80 sub_6F339F80org;
sub_6F339F80 sub_6F339F80ptr;
sub_6F33A010 sub_6F33A010org;
sub_6F33A010 sub_6F33A010ptr;
int __stdcall IssueWithoutTargetOrdermy( int a1, int a2, unsigned int a3, unsigned int a4 )
{
if ( a4 & ShiftPressed )
{
if ( GetTickCount( ) - SkipSingleShift < 100 )
{
SkipSingleShift = 0;
a4 -= ShiftPressed;
}
}
else
{
if ( ShiftPressed )
{
a4 += ShiftPressed;
}
}
int retvalue = IssueWithoutTargetOrderptr( a1, a2, a3, a4 );
if ( GetTickCount( ) - SingleShift < 100 )
{
SingleShift = 0;
ShiftPressed = 0;
}
return retvalue;
}
int __stdcall IssueTargetOrPointOrder2my( int a1, int a2, float a3, float a4, int a5, int a6 )
{
if ( a6 & ShiftPressed )
{
if ( GetTickCount( ) - SkipSingleShift < 100 )
{
SkipSingleShift = 0;
a6 -= ShiftPressed;
}
}
else
{
if ( ShiftPressed )
{
a6 += ShiftPressed;
}
}
int retvalue = IssueTargetOrPointOrder2ptr( a1, a2, a3, a4, a5, a6 );
if ( GetTickCount( ) - SingleShift < 100 )
{
SingleShift = 0;
ShiftPressed = 0;
}
return retvalue;
}
int __stdcall sub_6F339D50my( int a1, int a2, int a3, unsigned int a4, unsigned int a5 )
{
if ( a5 & ShiftPressed )
{
if ( GetTickCount( ) - SkipSingleShift < 100 )
{
SkipSingleShift = 0;
a5 -= ShiftPressed;
}
}
else
{
if ( ShiftPressed )
{
a5 += ShiftPressed;
}
}
int retvalue = sub_6F339D50ptr( a1, a2, a3, a4, a5 );
if ( GetTickCount( ) - SingleShift < 100 )
{
SingleShift = 0;
ShiftPressed = 0;
}
return retvalue;
}
int __stdcall IssueTargetOrPointOrdermy( int a1, int a2, float a3, float a4, int a5, int a6, int a7 )
{
if ( a7 & ShiftPressed )
{
if ( GetTickCount( ) - SkipSingleShift < 100 )
{
SkipSingleShift = 0;
a7 -= ShiftPressed;
}
}
else
{
if ( ShiftPressed )
{
a7 += ShiftPressed;
}
}
int retvalue = IssueTargetOrPointOrderptr( a1, a2, a3, a4, a5, a6, a7 );
if ( GetTickCount( ) - SingleShift < 100 )
{
SingleShift = 0;
ShiftPressed = 0;
}
return retvalue;
}
int __stdcall sub_6F339E60my( int a1, int a2, float a3, float a4, int a5, int a6, int a7, int a8 )
{
if ( a8 & ShiftPressed )
{
if ( GetTickCount( ) - SkipSingleShift < 100 )
{
SkipSingleShift = 0;
a8 -= ShiftPressed;
}
}
else
{
if ( ShiftPressed )
{
a8 += ShiftPressed;
}
}
int retvalue = sub_6F339E60ptr( a1, a2, a3, a4, a5, a6, a7, a8 );
if ( GetTickCount( ) - SingleShift < 100 )
{
SingleShift = 0;
ShiftPressed = 0;
}
return retvalue;
}
int __stdcall sub_6F339F00my( int a1, int a2, int a3, unsigned int a4, unsigned int a5 )
{
if ( a5 & ShiftPressed )
{
if ( GetTickCount( ) - SkipSingleShift < 100 )
{
SkipSingleShift = 0;
a5 -= ShiftPressed;
}
}
else
{
if ( ShiftPressed )
{
a5 += ShiftPressed;
}
}
int retvalue = sub_6F339F00ptr( a1, a2, a3, a4, a5 );
if ( GetTickCount( ) - SingleShift < 100 )
{
SingleShift = 0;
ShiftPressed = 0;
}
return retvalue;
}
int __stdcall sub_6F339F80my( int a1, int a2, float a3, float a4, int a5, int a6, int a7 )
{
if ( a7 & ShiftPressed )
{
if ( GetTickCount( ) - SkipSingleShift < 100 )
{
SkipSingleShift = 0;
a7 -= ShiftPressed;
}
}
else
{
if ( ShiftPressed )
{
a7 += ShiftPressed;
}
}
int retvalue = sub_6F339F80ptr( a1, a2, a3, a4, a5, a6, a7 );
if ( GetTickCount( ) - SingleShift < 100 )
{
SingleShift = 0;
ShiftPressed = 0;
}
return retvalue;
}
int __stdcall sub_6F33A010my( int a1, int a2, float a3, float a4, int a5, int a6, int a7, int a8 )
{
if ( a8 & ShiftPressed )
{
if ( GetTickCount( ) - SkipSingleShift < 100 )
{
SkipSingleShift = 0;
a8 -= ShiftPressed;
}
}
else
{
if ( ShiftPressed )
{
a8 += ShiftPressed;
}
}
int retvalue = sub_6F33A010ptr( a1, a2, a3, a4, a5, a6, a7, a8 );
if ( GetTickCount( ) - SingleShift < 100 )
{
SingleShift = 0;
ShiftPressed = 0;
}
return retvalue;
}
int IssueWithoutTargetOrderOffset = 0;
int IssueTargetOrPointOrder2Offset = 0;
int sub_6F339D50Offset = 0;
int IssueTargetOrPointOrderOffset = 0;
int sub_6F339E60Offset = 0;
int sub_6F339F00Offset = 0;
int sub_6F339F80Offset = 0;
int sub_6F33A010Offset = 0;
#pragma endregion
// Включить фикс шифта для приказов
void IssueFixerInit( )
{
IssueWithoutTargetOrderorg = ( IssueWithoutTargetOrder )( GameDll + IssueWithoutTargetOrderOffset );
MH_CreateHook( IssueWithoutTargetOrderorg, &IssueWithoutTargetOrdermy, reinterpret_cast< void** >( &IssueWithoutTargetOrderptr ) );
IssueTargetOrPointOrder2org = ( IssueTargetOrPointOrder2 )( GameDll + IssueTargetOrPointOrder2Offset );
MH_CreateHook( IssueTargetOrPointOrder2org, &IssueTargetOrPointOrder2my, reinterpret_cast< void** >( &IssueTargetOrPointOrder2ptr ) );
sub_6F339D50org = ( sub_6F339D50 )( GameDll + sub_6F339D50Offset );
MH_CreateHook( sub_6F339D50org, &sub_6F339D50my, reinterpret_cast< void** >( &sub_6F339D50ptr ) );
IssueTargetOrPointOrderorg = ( IssueTargetOrPointOrder )( GameDll + IssueTargetOrPointOrderOffset );
MH_CreateHook( IssueTargetOrPointOrderorg, &IssueTargetOrPointOrdermy, reinterpret_cast< void** >( &IssueTargetOrPointOrderptr ) );
sub_6F339E60org = ( sub_6F339E60 )( GameDll + sub_6F339E60Offset );
MH_CreateHook( sub_6F339E60org, &sub_6F339E60my, reinterpret_cast< void** >( &sub_6F339E60ptr ) );
sub_6F339F00org = ( sub_6F339F00 )( GameDll + sub_6F339F00Offset );
MH_CreateHook( sub_6F339F00org, &sub_6F339F00my, reinterpret_cast< void** >( &sub_6F339F00ptr ) );
sub_6F339F80org = ( sub_6F339F80 )( GameDll + sub_6F339F80Offset );
MH_CreateHook( sub_6F339F80org, &sub_6F339F80my, reinterpret_cast< void** >( &sub_6F339F80ptr ) );
sub_6F33A010org = ( sub_6F33A010 )( GameDll + sub_6F33A010Offset );
MH_CreateHook( sub_6F33A010org, &sub_6F33A010my, reinterpret_cast< void** >( &sub_6F33A010ptr ) );
MH_EnableHook( IssueWithoutTargetOrderorg );
MH_EnableHook( IssueTargetOrPointOrder2org );
MH_EnableHook( sub_6F339D50org );
MH_EnableHook( IssueTargetOrPointOrderorg );
MH_EnableHook( sub_6F339E60org );
MH_EnableHook( sub_6F339F00org );
MH_EnableHook( sub_6F339F80org );
MH_EnableHook( sub_6F33A010org );
GetCameraHeight_org = pGetCameraHeight( GameDll + 0x3019A0 );
MH_CreateHook( GetCameraHeight_org, &GetCameraHeight_my, reinterpret_cast< void** >( &GetCameraHeight_ptr ) );
MH_EnableHook( GetCameraHeight_org );
}
// Отключить фикс шифта для приказов
void IssueFixerDisable( )
{
memset( LastPressedKeysTime, 0, sizeof( LastPressedKeysTime ) );
if ( IssueWithoutTargetOrderorg )
{
MH_DisableHook( IssueWithoutTargetOrderorg );
IssueWithoutTargetOrderorg = NULL;
}
if ( IssueTargetOrPointOrder2org )
{
MH_DisableHook( IssueTargetOrPointOrder2org );
IssueTargetOrPointOrder2org = NULL;
}
if ( sub_6F339D50org )
{
MH_DisableHook( sub_6F339D50org );
sub_6F339D50org = NULL;
}
if ( IssueTargetOrPointOrderorg )
{
MH_DisableHook( IssueTargetOrPointOrderorg );
IssueTargetOrPointOrderorg = NULL;
}
if ( sub_6F339E60org )
{
MH_DisableHook( sub_6F339E60org );
sub_6F339E60org = NULL;
}
if ( sub_6F339F00org )
{
MH_DisableHook( sub_6F339F00org );
sub_6F339F00org = NULL;
}
if ( sub_6F339F80org )
{
MH_DisableHook( sub_6F339F80org );
sub_6F339F80org = NULL;
}
if ( sub_6F33A010org )
{
MH_DisableHook( sub_6F33A010org );
sub_6F33A010org = NULL;
}
if ( GetCameraHeight_org )
{
MH_DisableHook( GetCameraHeight_org );
GetCameraHeight_org = NULL;
}
if ( !RegisteredKeyCodes.empty( ) )
RegisteredKeyCodes.clear( );
if ( !BlockedKeyCodes.empty( ) )
BlockedKeyCodes.clear( );
if ( !KeyActionList.empty( ) )
KeyActionList.clear( );
if ( !KeyChatActionList.empty( ) )
KeyChatActionList.clear( );
if ( !KeySelectActionList.empty( ) )
KeySelectActionList.clear( );
if ( !KeyCalbackActionList.empty( ) )
KeyCalbackActionList.clear( );
GlobalCallbackForRegisteredHotkeys = jRCString( );
SkipAllMessages = FALSE;
}
// построение текущих нажатых кнопок в код клавиш
unsigned int BuildKeyCode( )
{
unsigned int code = 0;
if ( IsKeyPressed( VK_LSHIFT ) ||
IsKeyPressed( VK_RSHIFT ) ||
IsKeyPressed( VK_SHIFT ) )
{
code += 0x40000;
}
else if ( IsKeyPressed( VK_MENU ) ||
IsKeyPressed( VK_RMENU ) ||
IsKeyPressed( VK_LMENU ) )
{
code += 0x10000;
}
else if ( IsKeyPressed( VK_LCONTROL ) ||
IsKeyPressed( VK_RCONTROL ) ||
IsKeyPressed( VK_CONTROL ) )
{
code += 0x20000;
}
for ( int i = 0; i < 255; i++ )
{
if ( i == ( int )VK_LSHIFT ||
i == ( int )VK_RSHIFT ||
i == ( int )VK_SHIFT ||
i == ( int )VK_MENU ||
i == ( int )VK_RMENU ||
i == ( int )VK_LMENU ||
i == ( int )VK_LCONTROL ||
i == ( int )VK_RCONTROL ||
i == ( int )VK_CONTROL )
continue;
if ( i == ( int )VK_MENU )
continue;
if ( i == ( int )VK_CONTROL )
continue;
short x = GetAsyncKeyState( i );
if ( ( x & 0x8000 ) > 0 )
{
code += i;
break;
}
}
return code;
}
// конвертировать строку в код клавиши
int _StrToVKey( const std::string & skey ) {
if ( skey == "LBTN" ) return VK_LBUTTON; // Left mouse button
if ( skey == "RBTN" ) return VK_RBUTTON; // Right mouse button
if ( skey == "CANCEL" ) return VK_CANCEL; // Control-break processing
if ( skey == "MBTN" ) return VK_MBUTTON; // Middle mouse button (three-button mouse)
if ( skey == "XBTN1" ) return VK_XBUTTON1; // X1 mouse button
if ( skey == "XBTN2" ) return VK_XBUTTON2; // X2 mouse button
if ( skey == "BACK" ) return VK_BACK; // BACKSPACE key
if ( skey == "TAB" ) return VK_TAB; // TAB key
if ( skey == "CLEAR" ) return VK_CLEAR; // CLEAR key
if ( skey == "RETURN" ) return VK_RETURN; // ENTER key
if ( skey == "SHIFT" ) return VK_SHIFT; // SHIFT key
if ( skey == "CTRL" ) return VK_CONTROL; // CTRL key
if ( skey == "ALT" ) return VK_MENU; // ALT key
if ( skey == "PAUSE" ) return VK_PAUSE; // PAUSE key
if ( skey == "CAPS" ) return VK_CAPITAL; // CAPS LOCK key
if ( skey == "KANA" ) return VK_KANA; // IME Kana mode
//if (skey == "VK_HANGUEL") return VK_HANGUL; // IME Hangul mode
if ( skey == "JUNJA" ) return VK_JUNJA; // IME Junja mode
if ( skey == "FINAL" ) return VK_FINAL; // IME final mode
if ( skey == "HANJA" ) return VK_HANJA; // IME Hanja mode
//if (skey == "VK_KANJI") return VK_KANJI; // IME Kanji mode
if ( skey == "ESC" ) return VK_ESCAPE; // ESC key
if ( skey == "CONV" ) return VK_CONVERT; // IME convert
if ( skey == "NCONV" ) return VK_NONCONVERT; // IME nonconvert
if ( skey == "ACCEPT" ) return VK_ACCEPT; // IME accept
if ( skey == "MCHANGE" ) return VK_MODECHANGE; // IME mode change request
if ( skey == "SPACE" ) return VK_SPACE; // SPACEBAR
if ( skey == "PAGEUP" ) return VK_PRIOR; // PAGE UP key
if ( skey == "PAGEDN" ) return VK_NEXT; // PAGE DOWN key
if ( skey == "END" ) return VK_END; // END key
if ( skey == "HOME" ) return VK_HOME; // HOME key
if ( skey == "LEFT" ) return VK_LEFT; // LEFT ARROW key
if ( skey == "UP" ) return VK_UP; // UP ARROW key
if ( skey == "RIGHT" ) return VK_RIGHT; // RIGHT ARROW key
if ( skey == "DOWN" ) return VK_DOWN; // DOWN ARROW key
if ( skey == "SELECT" ) return VK_SELECT; // SELECT key
if ( skey == "PRINT" ) return VK_PRINT; // PRINT key
if ( skey == "EXEC" ) return VK_EXECUTE; // EXECUTE key
if ( skey == "SSHOT" ) return VK_SNAPSHOT; // PRINT SCREEN key
if ( skey == "INSERT" ) return VK_INSERT; // INS key
if ( skey == "DELETE" ) return VK_DELETE; // DEL key
if ( skey == "HELP" ) return VK_HELP; // HELP key
if ( skey == "0" ) return '0';
if ( skey == "1" ) return '1';
if ( skey == "2" ) return '2';
if ( skey == "3" ) return '3';
if ( skey == "4" ) return '4';
if ( skey == "5" ) return '5';
if ( skey == "6" ) return '6';
if ( skey == "7" ) return '7';
if ( skey == "8" ) return '8';
if ( skey == "9" ) return '9';
if ( skey == "A" ) return 'A';
if ( skey == "B" ) return 'B';
if ( skey == "C" ) return 'C';
if ( skey == "D" ) return 'D';
if ( skey == "E" ) return 'E';
if ( skey == "F" ) return 'F';
if ( skey == "G" ) return 'G';
if ( skey == "H" ) return 'H';
if ( skey == "I" ) return 'I';
if ( skey == "J" ) return 'J';
if ( skey == "K" ) return 'K';
if ( skey == "L" ) return 'L';
if ( skey == "M" ) return 'M';
if ( skey == "N" ) return 'N';
if ( skey == "O" ) return 'O';
if ( skey == "P" ) return 'P';
if ( skey == "Q" ) return 'Q';
if ( skey == "R" ) return 'R';
if ( skey == "S" ) return 'S';
if ( skey == "T" ) return 'T';
if ( skey == "U" ) return 'U';
if ( skey == "V" ) return 'V';
if ( skey == "W" ) return 'W';
if ( skey == "X" ) return 'X';
if ( skey == "Y" ) return 'Y';
if ( skey == "Z" ) return 'Z';
if ( skey == "LWIN" ) return VK_LWIN; // Left Windows key (Natural keyboard)
if ( skey == "RWIN" ) return VK_RWIN; // Right Windows key (Natural keyboard)
if ( skey == "APPS" ) return VK_APPS; // Applications key (Natural keyboard)
if ( skey == "SLEEP" ) return VK_SLEEP; // Computer Sleep key
if ( skey == "NPAD0" ) return VK_NUMPAD0; // Numeric keypad 0 key
if ( skey == "NPAD1" ) return VK_NUMPAD1; // Numeric keypad 1 key
if ( skey == "NPAD2" ) return VK_NUMPAD2; // Numeric keypad 2 key
if ( skey == "NPAD3" ) return VK_NUMPAD3; // Numeric keypad 3 key
if ( skey == "NPAD4" ) return VK_NUMPAD4; // Numeric keypad 4 key
if ( skey == "NPAD5" ) return VK_NUMPAD5; // Numeric keypad 5 key
if ( skey == "NPAD6" ) return VK_NUMPAD6; // Numeric keypad 6 key
if ( skey == "NPAD7" ) return VK_NUMPAD7; // Numeric keypad 7 key
if ( skey == "NPAD8" ) return VK_NUMPAD8; // Numeric keypad 8 key
if ( skey == "NPAD9" ) return VK_NUMPAD9; // Numeric keypad 9 key
if ( skey == "MULT" ) return VK_MULTIPLY; // Multiply key
if ( skey == "ADD" ) return VK_ADD; // Add key
if ( skey == "SEP" ) return VK_SEPARATOR; // Separator key
if ( skey == "SUB" ) return VK_SUBTRACT; // Subtract key
if ( skey == "DEC" ) return VK_DECIMAL; // Decimal key
if ( skey == "DIV" ) return VK_DIVIDE; // Divide key
if ( skey == "F1" ) return VK_F1; // F1 key
if ( skey == "F2" ) return VK_F2; // F2 key
if ( skey == "F3" ) return VK_F3; // F3 key
if ( skey == "F4" ) return VK_F4; // F4 key
if ( skey == "F5" ) return VK_F5; // F5 key
if ( skey == "F6" ) return VK_F6; // F6 key
if ( skey == "F7" ) return VK_F7; // F7 key
if ( skey == "F8" ) return VK_F8; // F8 key
if ( skey == "F9" ) return VK_F9; // F9 key
if ( skey == "F10" ) return VK_F10; // F10 key
if ( skey == "F11" ) return VK_F11; // F11 key
if ( skey == "F12" ) return VK_F12; // F12 key
if ( skey == "F13" ) return VK_F13; // F13 key
if ( skey == "F14" ) return VK_F14; // F14 key
if ( skey == "F15" ) return VK_F15; // F15 key
if ( skey == "F16" ) return VK_F16; // F16 key
if ( skey == "F17" ) return VK_F17; // F17 key
if ( skey == "F18" ) return VK_F18; // F18 key
if ( skey == "F19" ) return VK_F19; // F19 key
if ( skey == "F20" ) return VK_F20; // F20 key
if ( skey == "F21" ) return VK_F21; // F21 key
if ( skey == "F22" ) return VK_F22; // F22 key
if ( skey == "F23" ) return VK_F23; // F23 key
if ( skey == "F24" ) return VK_F24; // F24 key
if ( skey == "NLOCK" ) return VK_NUMLOCK; // NUM LOCK key
if ( skey == "SCRL" ) return VK_SCROLL; // SCROLL LOCK key
if ( skey == "LSHFT" ) return VK_LSHIFT; // Left SHIFT key
if ( skey == "RSHFT" ) return VK_RSHIFT; // Right SHIFT key
if ( skey == "LCTRL" ) return VK_LCONTROL; // Left CONTROL key
if ( skey == "RCTRL" ) return VK_RCONTROL; // Right CONTROL key
if ( skey == "LALT" ) return VK_LMENU; // Left MENU key
if ( skey == "RALT" ) return VK_RMENU; // Right MENU key
if ( skey == "BBACK" ) return VK_BROWSER_BACK; // Browser Back key
if ( skey == "BFORW" ) return VK_BROWSER_FORWARD; // Browser Forward key
if ( skey == "BREFR" ) return VK_BROWSER_REFRESH; // Browser Refresh key
if ( skey == "BSTOP" ) return VK_BROWSER_STOP; // Browser Stop key
if ( skey == "BSEARCH" ) return VK_BROWSER_SEARCH; // Browser Search key
if ( skey == "BFAV" ) return VK_BROWSER_FAVORITES; // Browser Favorites key
if ( skey == "BHOME" ) return VK_BROWSER_HOME; // Browser Start and Home key
if ( skey == "MUTE" ) return VK_VOLUME_MUTE; // Volume Mute key
if ( skey == "V_DOWN" ) return VK_VOLUME_DOWN; // Volume Down key
if ( skey == "V_UP" ) return VK_VOLUME_UP; // Volume Up key
if ( skey == "NEXT" ) return VK_MEDIA_NEXT_TRACK; // Next Track key
if ( skey == "PREV" ) return VK_MEDIA_PREV_TRACK; // Previous Track key
if ( skey == "STOP" ) return VK_MEDIA_STOP; // Stop Media key
if ( skey == "MPLAY" ) return VK_MEDIA_PLAY_PAUSE; // Play/Pause Media key
if ( skey == "MAIL" ) return VK_LAUNCH_MAIL; // Start Mail key
if ( skey == "MSEL" ) return VK_LAUNCH_MEDIA_SELECT; // Select Media key
if ( skey == "APP1" ) return VK_LAUNCH_APP1; // Start Application 1 key
if ( skey == "APP2" ) return VK_LAUNCH_APP2; // Start Application 2 key
if ( skey == "OEM_1" ) return VK_OEM_1; // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the ';:' key
if ( skey == "OEM_P" ) return VK_OEM_PLUS; // For any country/region, the '+' key
if ( skey == "COMMA" ) return VK_OEM_COMMA; // For any country/region, the ',' key
if ( skey == "MINUS" ) return VK_OEM_MINUS; // For any country/region, the '-' key
if ( skey == "PERIOD" ) return VK_OEM_PERIOD; // For any country/region, the '.' key
if ( skey == "OEM_2" ) return VK_OEM_2; // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '/?' key
if ( skey == "OEM_3" ) return VK_OEM_3; // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '`~' key
if ( skey == "ABNT_C1" ) return 0xC1; // Brazilian (ABNT) Keyboard
if ( skey == "ABNT_C2" ) return 0xC2; // Brazilian (ABNT) Keyboard
if ( skey == "OEM_4" ) return VK_OEM_4; // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '[{' key
if ( skey == "OEM_5" ) return VK_OEM_5; // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '\|' key
if ( skey == "OEM_6" ) return VK_OEM_6; // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the ']}' key
if ( skey == "OEM_7" ) return VK_OEM_7; // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the 'single-quote/double-quote' key
if ( skey == "OEM_8" ) return VK_OEM_8; // Used for miscellaneous characters; it can vary by keyboard.
if ( skey == "OEM102" ) return VK_OEM_102; // Either the angle bracket key or the backslash key on the RT 102-key keyboard
if ( skey == "PROCKEY" ) return VK_PROCESSKEY; // IME PROCESS key
if ( skey == "PACKET" ) return VK_PACKET; // Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT, SendInput, WM_KEYDOWN, and WM_KEYUP // 0xE8
if ( skey == "ATTN" ) return VK_ATTN; // Attn key
if ( skey == "CRSEL" ) return VK_CRSEL; // CrSel key
if ( skey == "EXSEL" ) return VK_EXSEL; // ExSel key
if ( skey == "EREOF" ) return VK_EREOF; // Erase EOF key
if ( skey == "PLAY" ) return VK_PLAY; // Play key
if ( skey == "ZOOM" ) return VK_ZOOM; // Zoom key
if ( skey == "NONAME" ) return VK_NONAME; // Reserved
if ( skey == "PA1" ) return VK_PA1; // PA1 key
if ( skey == "OCLEAR" ) return VK_OEM_CLEAR; // Clear key
return 0;
}
// конвертировать код клавиши в строку
std::string _VKeyToStr( int vkey ) {
switch ( vkey ) {
case VK_LBUTTON: return "LBTN"; // Left mouse button
case VK_RBUTTON: return "RBTN"; // Right mouse button
case VK_CANCEL: return "CANCEL"; // Control-break processing
case VK_MBUTTON: return "MBTN"; // Middle mouse button (three-button mouse)
case VK_XBUTTON1: return "XBTN1"; // X1 mouse button
case VK_XBUTTON2: return "XBTN2"; // X2 mouse button
case VK_BACK: return "BACK"; // BACKSPACE key
case VK_TAB: return "TAB"; // TAB key
case VK_CLEAR: return "CLEAR"; // CLEAR key
case VK_RETURN: return "RETURN"; // ENTER key
case VK_SHIFT: return "SHIFT"; // SHIFT key
case VK_CONTROL: return "CTRL"; // CTRL key
case VK_MENU: return "ALT"; // ALT key
case VK_PAUSE: return "PAUSE"; // PAUSE key
case VK_CAPITAL: return "CAPS"; // CAPS LOCK key
case VK_KANA: return "KANA"; // IME Kana mode
//case VK_HANGUL: return "VK_HANGUEL"; // IME Hangul mode
case VK_JUNJA: return "JUNJA"; // IME Junja mode
case VK_FINAL: return "FINAL"; // IME final mode
case VK_HANJA: return "HANJA"; // IME Hanja mode
//case VK_KANJI: return "VK_KANJI"; // IME Kanji mode
case VK_ESCAPE: return "ESC"; // ESC key
case VK_CONVERT: return "CONV"; // IME convert
case VK_NONCONVERT: return "NCONV"; // IME nonconvert
case VK_ACCEPT: return "ACCEPT"; // IME accept
case VK_MODECHANGE: return "MCHANGE"; // IME mode change request
case VK_SPACE: return "SPACE"; // SPACEBAR
case VK_PRIOR: return "PAGEUP"; // PAGE UP key
case VK_NEXT: return "PAGEDN"; // PAGE DOWN key
case VK_END: return "END"; // END key
case VK_HOME: return "HOME"; // HOME key
case VK_LEFT: return "LEFT"; // LEFT ARROW key
case VK_UP: return "UP"; // UP ARROW key
case VK_RIGHT: return "RIGHT"; // RIGHT ARROW key
case VK_DOWN: return "DOWN"; // DOWN ARROW key
case VK_SELECT: return "SELECT"; // SELECT key
case VK_PRINT: return "PRINT"; // PRINT key
case VK_EXECUTE: return "EXEC"; // EXECUTE key
case VK_SNAPSHOT: return "SSHOT"; // PRINT SCREEN key
case VK_INSERT: return "INSERT"; // INS key
case VK_DELETE: return "DELETE"; // DEL key
case VK_HELP: return "HELP"; // HELP key
case '0': return "0";
case '1': return "1";
case '2': return "2";
case '3': return "3";
case '4': return "4";
case '5': return "5";
case '6': return "6";
case '7': return "7";
case '8': return "8";
case '9': return "9";
case 'A': return "A";
case 'B': return "B";
case 'C': return "C";
case 'D': return "D";
case 'E': return "E";
case 'F': return "F";
case 'G': return "G";
case 'H': return "H";
case 'I': return "I";
case 'J': return "J";
case 'K': return "K";
case 'L': return "L";
case 'M': return "M";
case 'N': return "N";
case 'O': return "O";
case 'P': return "P";
case 'Q': return "Q";
case 'R': return "R";
case 'S': return "S";
case 'T': return "T";
case 'U': return "U";
case 'V': return "V";
case 'W': return "W";
case 'X': return "X";
case 'Y': return "Y";
case 'Z': return "Z";
case VK_LWIN: return "LWIN"; // Left Windows key (Natural keyboard)
case VK_RWIN: return "RWIN"; // Right Windows key (Natural keyboard)
case VK_APPS: return "APPS"; // Applications key (Natural keyboard)
case VK_SLEEP: return "SLEEP"; // Computer Sleep key
case VK_NUMPAD0: return "NPAD0"; // Numeric keypad 0 key
case VK_NUMPAD1: return "NPAD1"; // Numeric keypad 1 key
case VK_NUMPAD2: return "NPAD2"; // Numeric keypad 2 key
case VK_NUMPAD3: return "NPAD3"; // Numeric keypad 3 key
case VK_NUMPAD4: return "NPAD4"; // Numeric keypad 4 key
case VK_NUMPAD5: return "NPAD5"; // Numeric keypad 5 key
case VK_NUMPAD6: return "NPAD6"; // Numeric keypad 6 key
case VK_NUMPAD7: return "NPAD7"; // Numeric keypad 7 key
case VK_NUMPAD8: return "NPAD8"; // Numeric keypad 8 key
case VK_NUMPAD9: return "NPAD9"; // Numeric keypad 9 key
case VK_MULTIPLY: return "MULT"; // Multiply key
case VK_ADD: return "ADD"; // Add key
case VK_SEPARATOR: return "SEP"; // Separator key
case VK_SUBTRACT: return "SUB"; // Subtract key
case VK_DECIMAL: return "DEC"; // Decimal key
case VK_DIVIDE: return "DIV"; // Divide key
case VK_F1: return "F1"; // F1 key
case VK_F2: return "F2"; // F2 key
case VK_F3: return "F3"; // F3 key
case VK_F4: return "F4"; // F4 key
case VK_F5: return "F5"; // F5 key
case VK_F6: return "F6"; // F6 key
case VK_F7: return "F7"; // F7 key
case VK_F8: return "F8"; // F8 key
case VK_F9: return "F9"; // F9 key
case VK_F10: return "F10"; // F10 key
case VK_F11: return "F11"; // F11 key
case VK_F12: return "F12"; // F12 key
case VK_F13: return "F13"; // F13 key
case VK_F14: return "F14"; // F14 key
case VK_F15: return "F15"; // F15 key
case VK_F16: return "F16"; // F16 key
case VK_F17: return "F17"; // F17 key
case VK_F18: return "F18"; // F18 key
case VK_F19: return "F19"; // F19 key
case VK_F20: return "F20"; // F20 key
case VK_F21: return "F21"; // F21 key
case VK_F22: return "F22"; // F22 key
case VK_F23: return "F23"; // F23 key
case VK_F24: return "F24"; // F24 key
case VK_NUMLOCK: return "NLOCK"; // NUM LOCK key
case VK_SCROLL: return "SCRL"; // SCROLL LOCK key
case VK_LSHIFT: return "LSHFT"; // Left SHIFT key
case VK_RSHIFT: return "RSHFT"; // Right SHIFT key
case VK_LCONTROL: return "LCTRL"; // Left CONTROL key
case VK_RCONTROL: return "RCTRL"; // Right CONTROL key
case VK_LMENU: return "LALT"; // Left MENU key
case VK_RMENU: return "RALT"; // Right MENU key
case VK_BROWSER_BACK: return "BBACK"; // Browser Back key
case VK_BROWSER_FORWARD: return "BFORW"; // Browser Forward key
case VK_BROWSER_REFRESH: return "BREFR"; // Browser Refresh key
case VK_BROWSER_STOP: return "BSTOP"; // Browser Stop key
case VK_BROWSER_SEARCH: return "BSEARCH"; // Browser Search key
case VK_BROWSER_FAVORITES: return "BFAV"; // Browser Favorites key
case VK_BROWSER_HOME: return "BHOME"; // Browser Start and Home key
case VK_VOLUME_MUTE: return "MUTE"; // Volume Mute key
case VK_VOLUME_DOWN: return "V_DOWN"; // Volume Down key
case VK_VOLUME_UP: return "V_UP"; // Volume Up key
case VK_MEDIA_NEXT_TRACK: return "NEXT"; // Next Track key
case VK_MEDIA_PREV_TRACK: return "PREV"; // Previous Track key
case VK_MEDIA_STOP: return "STOP"; // Stop Media key
case VK_MEDIA_PLAY_PAUSE: return "MPLAY"; // Play/Pause Media key
case VK_LAUNCH_MAIL: return "MAIL"; // Start Mail key
case VK_LAUNCH_MEDIA_SELECT: return "MSEL"; // Select Media key
case VK_LAUNCH_APP1: return "APP1"; // Start Application 1 key
case VK_LAUNCH_APP2: return "APP2"; // Start Application 2 key
case VK_OEM_1: return "OEM_1"; // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the ';:' key
case VK_OEM_PLUS: return "OEM_P"; // For any country/region, the '+' key
case VK_OEM_COMMA: return "COMMA"; // For any country/region, the ',' key
case VK_OEM_MINUS: return "MINUS"; // For any country/region, the '-' key
case VK_OEM_PERIOD: return "PERIOD"; // For any country/region, the '.' key
case VK_OEM_2: return "OEM_2"; // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '/?' key
case VK_OEM_3: return "OEM_3"; // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '`~' key
case 0xC1: return "ABNT_C1"; // Brazilian (ABNT) Keyboard
case 0xC2: return "ABNT_C2"; // Brazilian (ABNT) Keyboard
case VK_OEM_4: return "OEM_4"; // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '[{' key
case VK_OEM_5: return "OEM_5"; // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '\|' key
case VK_OEM_6: return "OEM_6"; // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the ']}' key
case VK_OEM_7: return "OEM_7"; // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the 'single-quote/double-quote' key
case VK_OEM_8: return "OEM_8"; // Used for miscellaneous characters; it can vary by keyboard.
case VK_OEM_102: return "OEM102"; // Either the angle bracket key or the backslash key on the RT 102-key keyboard
case VK_PROCESSKEY: return "PROCKEY"; // IME PROCESS key
case VK_PACKET: return "PACKET"; // Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT, SendInput, WM_KEYDOWN, and WM_KEYUP // 0xE8
case VK_ATTN: return "ATTN"; // Attn key
case VK_CRSEL: return "CRSEL"; // CrSel key
case VK_EXSEL: return "EXSEL"; // ExSel key
case VK_EREOF: return "EREOF"; // Erase EOF key
case VK_PLAY: return "PLAY"; // Play key
case VK_ZOOM: return "ZOOM"; // Zoom key
case VK_NONAME: return "NONAME"; // Reserved
case VK_PA1: return "PA1"; // PA1 key
case VK_OEM_CLEAR: return "OCLEAR"; // Clear key
}
return "NOTHING";
}
// конвертировать код клавиши в строку
std::string CovertKeyCodeToString( unsigned int val )
{
std::string outstr;
if ( val == 0 )
{
return "";
}
int KeyVal = ( int )( val & 0xFF );
outstr = _VKeyToStr( KeyVal );
if ( ( val & 0x40000 ) > 0 )
{
outstr = "SHIFT+" + outstr;
}
if ( ( val & 0x10000 ) > 0 )
{
outstr = "ALT+" + outstr;
}
if ( ( val & 0x20000 ) > 0 )
{
outstr = "CTRL+" + outstr;
}
if ( !KeyVal )
return "";
return outstr;
}
// конвертировать строку в код клавиши (комбинации клавиш)
unsigned int CovertStringToKeyCode( std::string code )
{
if ( code.length( ) == 0 )
return 0;
unsigned int outcode = 0;
char * arg2;
if ( ( arg2 = strstr( &code[ 0 ], "+" ) ) != NULL )
{
arg2[ 0 ] = '\0';
arg2++;
std::string arg1 = &code[ 0 ];
if ( arg1 == "CTRL" )
{
outcode = 0x20000;
}
else if ( arg1 == "ALT" )
{
outcode = 0x10000;
}
else if ( arg1 == "SHIFT" )
{
outcode = 0x40000;
}
}
else arg2 = &code[ 0 ];
int vkeyout = _StrToVKey( ToUpper( arg2 ) );
outcode += vkeyout;
if ( vkeyout == 0 )
return 0;
return outcode;
}
std::string tmpkeycode;
// конвертировать строку в код клавиши (комбинации клавиш)
int __stdcall ConvertKeyStringToKeyCode( const char * str )
{
if ( str == NULL )
return 0;
return CovertStringToKeyCode( str );
}
// конвертировать код клавиши в строку
const char * __stdcall ConvertKeyCodeToKeyString( unsigned int code )
{
tmpkeycode = CovertKeyCodeToString( code );
return tmpkeycode.c_str( );
} | [
"88730285+UnrealKaraulov@users.noreply.github.com"
] | 88730285+UnrealKaraulov@users.noreply.github.com |
5dcab6daf83fc92456fecde9d4d43abb052a3c98 | ec1cbf4c889170c49ac967a22caffad174600d4c | /code/machine/interrupt.h | 4982cb697a255804cc911dc6e66f0e20c585a5f9 | [
"MIT-Modern-Variant"
] | permissive | chenwei850825/Nachos-Filesystem | 777efebe7d1ab1cb6cf51be6cea8897e364dce8e | cffc038882b44ec96371267b151674ed9f6febbb | refs/heads/master | 2021-01-11T20:36:17.199981 | 2017-01-16T19:42:29 | 2017-01-16T19:42:29 | 79,151,224 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,477 | h | // interrupt.h
// Data structures to emulate low-level interrupt hardware.
//
// The hardware provides a routine (SetLevel) to enable or disable
// interrupts.
//
// In order to emulate the hardware, we need to keep track of all
// interrupts the hardware devices would cause, and when they
// are supposed to occur.
//
// This module also keeps track of simulated time. Time advances
// only when the following occur:
// interrupts are re-enabled
// a user instruction is executed
// there is nothing in the ready queue
//
// As a result, unlike real hardware, interrupts (and thus time-slice
// context switches) cannot occur anywhere in the code where interrupts
// are enabled, but rather only at those places in the code where
// simulated time advances (so that it becomes time to invoke an
// interrupt in the hardware simulation).
//
// NOTE: this means that incorrectly synchronized code may work
// fine on this hardware simulation (even with randomized time slices),
// but it wouldn't work on real hardware.
//
// DO NOT CHANGE -- part of the machine emulation
//
// Copyright (c) 1992-1996 The Regents of the University of California.
// All rights reserved. See copyright.h for copyright notice and limitation
// of liability and disclaimer of warranty provisions.
#ifndef INTERRUPT_H
#define INTERRUPT_H
#include "copyright.h"
#include "list.h"
#include "callback.h"
// Interrupts can be disabled (IntOff) or enabled (IntOn)
enum IntStatus { IntOff, IntOn };
// Nachos can be running kernel code (SystemMode), user code (UserMode),
// or there can be no runnable thread, because the ready list
// is empty (IdleMode).
enum MachineStatus {IdleMode, SystemMode, UserMode};
// IntType records which hardware device generated an interrupt.
// In Nachos, we support a hardware timer device, a disk, a console
// display and keyboard, and a network.
enum IntType { TimerInt, DiskInt, ConsoleWriteInt, ConsoleReadInt,
NetworkSendInt, NetworkRecvInt};
// The following class defines an interrupt that is scheduled
// to occur in the future. The internal data structures are
// left public to make it simpler to manipulate.
class PendingInterrupt {
public:
PendingInterrupt(CallBackObj *callOnInt, int time, IntType kind);
// initialize an interrupt that will
// occur in the future
CallBackObj *callOnInterrupt;// The object (in the hardware device
// emulator) to call when the interrupt occurs
int when; // When the interrupt is supposed to fire
IntType type; // for debugging
};
// The following class defines the data structures for the simulation
// of hardware interrupts. We record whether interrupts are enabled
// or disabled, and any hardware interrupts that are scheduled to occur
// in the future.
class Interrupt {
public:
Interrupt(); // initialize the interrupt simulation
~Interrupt(); // de-allocate data structures
IntStatus SetLevel(IntStatus level);
// Disable or enable interrupts
// and return previous setting.
void Enable() { (void) SetLevel(IntOn); }
// Enable interrupts.
IntStatus getLevel() {return level;}
// Return whether interrupts
// are enabled or disabled
void Idle(); // The ready queue is empty, roll
// simulated time forward until the
// next interrupt
void Halt(); // quit and print out stats
void PrintInt(int number);
#ifdef FILESYS_STUB
int CreateFile(char *filename);
#endif
void YieldOnReturn(); // cause a context switch on return
// from an interrupt handler
MachineStatus getStatus() { return status; }
void setStatus(MachineStatus st) { status = st; }
// idle, kernel, user
void DumpState(); // Print interrupt state
// NOTE: the following are internal to the hardware simulation code.
// DO NOT call these directly. I should make them "private",
// but they need to be public since they are called by the
// hardware device simulators.
void Schedule(CallBackObj *callTo, int when, IntType type);
// Schedule an interrupt to occur
// at time "when". This is called
// by the hardware device simulators.
void OneTick(); // Advance simulated time
/** @@MP4 **/
int CreateFile(char *filename, int size);
int OpenFile( char *name );
int WriteFile( char *buffer, int size, int id );
int ReadFile( char *buffer, int size, int id );
int CloseFile( int id );
private:
IntStatus level; // are interrupts enabled or disabled?
SortedList<PendingInterrupt *> *pending;
// the list of interrupts scheduled
// to occur in the future
//int writeFileNo; //UNIX file emulating the display
bool inHandler; // TRUE if we are running an interrupt handler
//bool putBusy; // Is a PrintInt operation in progress
//If so, you cannoot do another one
bool yieldOnReturn; // TRUE if we are to context switch
// on return from the interrupt handler
MachineStatus status; // idle, kernel mode, user mode
// these functions are internal to the interrupt simulation code
bool CheckIfDue(bool advanceClock);
// Check if any interrupts are supposed
// to occur now, and if so, do them
void ChangeLevel(IntStatus old, // SetLevel, without advancing the
IntStatus now); // simulated time
};
#endif // INTERRRUPT_H
| [
"chenwei850825@gmail.com"
] | chenwei850825@gmail.com |
27555604d50951cb42f550169b9f2058f2ef2ed6 | 396355feb70db5df83a9d0da7c699ae6e87f3396 | /755.cpp | 69cc22f4441670474ad5ceda1768ee3eeebd358d | [] | no_license | liuhb86/uva | 1621a9c8657bb9b5e78a06c3e351d7f8ef0121d6 | 6a642b59e6f56a2cac88ec6d06583713b124837c | refs/heads/master | 2020-04-10T06:48:15.061103 | 2014-12-04T04:59:00 | 2014-12-04T04:59:00 | 6,099,954 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,144 | cpp | #include <iostream>
#include <map>
#include <cstring>
using namespace std;
typedef map<string,int> Map;
char remap[]="11112ABC3DEF4GHI5JKL6MNO7PRS8TUV9WXY0000";
char table[200];
char buf[10];
int main(){
for(int i=0;i<40;i++){
table[remap[i]]=remap[i/4*4];
}
string s;
Map numbers;
int cases;
cin>>cases;
bool first=true;
for(int i=0;i<cases;i++){
if(first) first=false; else cout<<endl;
numbers.clear();
int n;
cin>>n;
getline(cin,s);
for(int j=0;j<n;j++){
int k=0;
while(k<7){
char c;
cin>>c;
if(c=='-') continue;
buf[k++]=table[c];
}
getline(cin,s);
buf[k]=0;
s.assign(buf);
Map::iterator it=numbers.find(s);
if(it==numbers.end()) it=numbers.insert(make_pair(s,0)).first;
it->second++;
}
bool empty=true;
for(Map::iterator it=numbers.begin();it!=numbers.end();++it){
if(it->second>1){
for(int i=0;i<3;i++) cout<<it->first[i];
cout<<'-';
for(int i=3;i<7;i++)cout<<it->first[i];
cout<<' '<<it->second<<endl;
empty=false;
}
}
if(empty) cout<<"No duplicates."<<endl;
}
return 0;
}
| [
"hongbo@liuhb.(none)"
] | hongbo@liuhb.(none) |
07a379a30846f421ca591613333504cc93020f6c | 57e1a4a0b238283abd62a0fac59695f64d01d13f | /bakjoon/좋은날싫은날.cpp | ca4cf9ecc9c1e705ef711d9747ea38d922cf8e5c | [] | no_license | junhobit/Algorithm | 4fc57486cd08debd9dc5cb961d3e3c107fe7963f | 1eed20a0ca144c1f442233633aa8027c01df35ca | refs/heads/master | 2021-02-07T21:53:13.694140 | 2020-07-10T14:55:15 | 2020-07-10T14:55:15 | 244,080,732 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 688 | cpp | #include <iostream>
#include <cmath>
using namespace std;
float per[4];
float sum, good, bad;
void feeling(int feel,float sum,int n)
{
n--;
sum = roundf(sum * 100) / 100;
if (n)
{
if (feel)
{
feeling(feel, sum * per[0], n);
feeling(!feel, sum * per[1], n);
}
else
{
feeling(!feel, sum * per[2], n);
feeling(feel, sum * per[3], n);
}
}
else
{
if (feel)
good += sum;
else
bad += sum;
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int n, feel;
cin >> n >> feel;
for (int i = 0; i < 1; i++)
{
cin >> per[i];
per[i] = round(per[i] * 100)/100;
}
feeling(feel, 1, n+1);
cout << good << endl << bad;
}
| [
"krs199228@gmail.com"
] | krs199228@gmail.com |
9d5d147f07bd16781061d7486f8d487e6a3c7761 | 88ae8695987ada722184307301e221e1ba3cc2fa | /chrome/browser/chromeos/policy/dlp/dlp_scoped_file_access_delegate.cc | 8b2175132b41ce09cd9573c08562449ce3b339f5 | [
"BSD-3-Clause"
] | permissive | iridium-browser/iridium-browser | 71d9c5ff76e014e6900b825f67389ab0ccd01329 | 5ee297f53dc7f8e70183031cff62f37b0f19d25f | refs/heads/master | 2023-08-03T16:44:16.844552 | 2023-07-20T15:17:00 | 2023-07-23T16:09:30 | 220,016,632 | 341 | 40 | BSD-3-Clause | 2021-08-13T13:54:45 | 2019-11-06T14:32:31 | null | UTF-8 | C++ | false | false | 6,446 | cc | // Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/policy/dlp/dlp_scoped_file_access_delegate.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/process/process_handle.h"
#include "base/task/bind_post_task.h"
#include "chrome/browser/chromeos/policy/dlp/dlp_file_access_copy_or_move_delegate_factory.h"
#include "chromeos/dbus/dlp/dlp_client.h"
#include "components/file_access/scoped_file_access.h"
#include "components/file_access/scoped_file_access_copy.h"
#include "components/file_access/scoped_file_access_delegate.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
namespace policy {
namespace {
dlp::RequestFileAccessRequest PrepareBaseRequestFileAccessRequest(
const std::vector<base::FilePath>& files) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
dlp::RequestFileAccessRequest request;
for (const auto& file : files)
request.add_files_paths(file.value());
request.set_process_id(base::GetCurrentProcId());
return request;
}
void RequestFileAccessForSystem(
const std::vector<base::FilePath>& files,
base::OnceCallback<void(file_access::ScopedFileAccess)> callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (file_access::ScopedFileAccessDelegate::HasInstance()) {
file_access::ScopedFileAccessDelegate::Get()->RequestFilesAccessForSystem(
files, base::BindPostTask(content::GetIOThreadTaskRunner({}),
std::move(callback)));
} else {
content::GetIOThreadTaskRunner({})->PostTask(
FROM_HERE, base::BindOnce(std::move(callback),
file_access::ScopedFileAccess::Allowed()));
}
}
} // namespace
// static
void DlpScopedFileAccessDelegate::Initialize(chromeos::DlpClient* client) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (!HasInstance()) {
new DlpScopedFileAccessDelegate(client);
}
content::GetIOThreadTaskRunner({})->PostTask(
FROM_HERE, base::BindOnce([]() {
if (!request_files_access_for_system_io_callback_) {
request_files_access_for_system_io_callback_ =
new file_access::ScopedFileAccessDelegate::
RequestFilesAccessIOCallback(base::BindPostTask(
content::GetUIThreadTaskRunner({}),
base::BindRepeating(&RequestFileAccessForSystem)));
}
}));
}
DlpScopedFileAccessDelegate::DlpScopedFileAccessDelegate(
chromeos::DlpClient* client)
: client_(client), weak_ptr_factory_(this) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DlpFileAccessCopyOrMoveDelegateFactory::Initialize();
}
DlpScopedFileAccessDelegate::~DlpScopedFileAccessDelegate() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DlpFileAccessCopyOrMoveDelegateFactory::DeleteInstance();
content::GetIOThreadTaskRunner({})->PostTask(
FROM_HERE, base::BindOnce([]() {
if (request_files_access_for_system_io_callback_) {
delete request_files_access_for_system_io_callback_;
request_files_access_for_system_io_callback_ = nullptr;
}
}));
}
void DlpScopedFileAccessDelegate::RequestFilesAccess(
const std::vector<base::FilePath>& files,
const GURL& destination_url,
base::OnceCallback<void(file_access::ScopedFileAccess)> callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (!client_->IsAlive()) {
std::move(callback).Run(file_access::ScopedFileAccess::Allowed());
return;
}
dlp::RequestFileAccessRequest request =
PrepareBaseRequestFileAccessRequest(files);
request.set_destination_url(destination_url.spec());
PostRequestFileAccessToDaemon(request, std::move(callback));
}
void DlpScopedFileAccessDelegate::RequestFilesAccessForSystem(
const std::vector<base::FilePath>& files,
base::OnceCallback<void(file_access::ScopedFileAccess)> callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (!client_->IsAlive()) {
std::move(callback).Run(file_access::ScopedFileAccess::Allowed());
return;
}
dlp::RequestFileAccessRequest request =
PrepareBaseRequestFileAccessRequest(files);
request.set_destination_component(dlp::DlpComponent::SYSTEM);
PostRequestFileAccessToDaemon(request, std::move(callback));
}
DlpScopedFileAccessDelegate::RequestFilesAccessIOCallback
DlpScopedFileAccessDelegate::CreateFileAccessCallback(
const GURL& destination) const {
return base::BindPostTask(
content::GetUIThreadTaskRunner({}),
base::BindRepeating(
[](const GURL& destination, const std::vector<base::FilePath>& files,
base::OnceCallback<void(file_access::ScopedFileAccess)> callback) {
if (file_access::ScopedFileAccessDelegate::HasInstance()) {
file_access::ScopedFileAccessDelegate::Get()->RequestFilesAccess(
files, destination,
base::BindPostTask(content::GetIOThreadTaskRunner({}),
std::move(callback)));
} else {
content::GetIOThreadTaskRunner({})->PostTask(
FROM_HERE,
base::BindOnce(std::move(callback),
file_access::ScopedFileAccess::Allowed()));
}
},
destination));
}
void DlpScopedFileAccessDelegate::PostRequestFileAccessToDaemon(
const ::dlp::RequestFileAccessRequest request,
base::OnceCallback<void(file_access::ScopedFileAccess)> callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
client_->RequestFileAccess(
request,
base::BindOnce(&DlpScopedFileAccessDelegate::OnResponse,
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
}
void DlpScopedFileAccessDelegate::OnResponse(
base::OnceCallback<void(file_access::ScopedFileAccess)> callback,
const dlp::RequestFileAccessResponse response,
base::ScopedFD fd) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (response.has_error_message()) {
std::move(callback).Run(file_access::ScopedFileAccess::Allowed());
return;
}
std::move(callback).Run(
file_access::ScopedFileAccess(response.allowed(), std::move(fd)));
}
} // namespace policy
| [
"jengelh@inai.de"
] | jengelh@inai.de |
778c7d42e7c2a121269a1893620adda3fbb5fdaf | a2b20babc0082981039342935aca203618e7757a | /app/src/main/cpp/egl/egl_surface.cpp | 27dcde8694dcfdea57287f880051e2a967723027 | [] | no_license | zone-a/BlogDemo | 91f6f74a45b64af2912927b9c0b4d18791c005ef | 1b24b6d1f054276f4e2d876af8d2c38ef35dd2a8 | refs/heads/master | 2023-01-28T12:46:05.918562 | 2020-12-10T02:39:46 | 2020-12-10T02:39:46 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,269 | cpp | //
// Created by feibiao.ma on 2020/9/16.
//
#include "egl_surface.h"
#include "../utils/logger.h"
EglSurface::EglSurface() {
m_core = new EglCore();
}
EglSurface::~EglSurface() {
delete m_core;
}
bool EglSurface::Init() {
return m_core->Init(NULL);
}
/**
*
* @param native_window 传入上一步创建的ANativeWindow
* @param width
* @param height
*/
void EglSurface::CreateEglSurface(ANativeWindow *native_window, int width, int height) {
if (native_window != NULL) {
this->m_native_window = native_window;
m_surface = m_core->CreateWindSurface(m_native_window);
} else {
m_surface = m_core->CreateOffScreenSurface(width, height);
}
if (m_surface == NULL) {
LOGE(TAG, "EGL create window surface fail")
Release();
}
MakeCurrent();
}
void EglSurface::MakeCurrent() {
m_core->MakeCurrent(m_surface);
}
void EglSurface::SwapBuffers() {
m_core->SwapBuffer(m_surface);
}
void EglSurface::DestroyEglSurface() {
if (m_surface != NULL) {
if (m_core != NULL) {
m_core->DestroySurface(m_surface);
}
m_surface = NULL;
}
}
void EglSurface::Release() {
DestroyEglSurface();
if (m_core != NULL) {
m_core->Release();
}
}
| [
"lovewfan@qq.com"
] | lovewfan@qq.com |
2c80fb2e7d5db97b59ca3a54d37e51b326b205fb | f66ecbea154414611ea07bb9277183b37275a07c | /math/primeFactors.cpp | aa841d426b822f86583d8e47084198e031d30706 | [] | no_license | shnjm/Templates | a77b08de7a68bbcd8c847d16bc5b2b679c06d452 | 460fe94e75042db920d2d608a05642e1a7665512 | refs/heads/master | 2022-04-09T18:51:58.138096 | 2020-01-06T15:39:33 | 2020-01-06T15:39:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 391 | cpp | #include<bits/stdc++.h>
using namespace std;
#define LLD long long int //note ur code
vector<int> primeFactors(LLD n)
{
vector<int> factors;
LLD pf_idx=0;pf=primes[pf_idx]; //primes has been populated by sieve
while(pf*pf<=n)
{
while(n%pf==0){n/=pf;factors.push_back(pf);}
pf=primes[++pf_idx];
}
if(n!=1) factors.push_back(n);
return factors;
}
| [
"skhwthssn@gmail.com"
] | skhwthssn@gmail.com |
785460bcc831b37d46dd9a89777a51c3570f59ef | 057f2783821562579dea238c1073d0ba0839b402 | /OCR/RecognitionNumber/.localhistory/RecognitionNumber/1480076492$main.cpp | 47e2b2a80ba2bd0407ec13a32e52ebdde4f0afb1 | [] | no_license | KrzysztofKozubek/Projects | 6cafb2585796c907e8a818da4b51c97197ccbd11 | 66ef23fbc8a6e6cf3b6ef837b390d7f2113a9847 | refs/heads/master | 2023-02-07T12:24:49.155221 | 2022-10-08T18:39:58 | 2022-10-08T18:39:58 | 163,520,516 | 0 | 0 | null | 2023-02-04T17:46:12 | 2018-12-29T15:18:18 | null | UTF-8 | C++ | false | false | 598 | cpp | /* library OpenCV */
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
/* library VS */
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <stdio.h>
/* My Class */
#include "Recognition.h"
#include "PreProcessing.h"
using namespace cv;
using namespace std;
int main() {
Mat image = imread("1.png", 0);
imshow("Z", image);
waitKey();
string pathToImage = "";
//cin >> pathToImage;
CPreProcessing* pp = new CPreProcessing(image);
pp->preProcessing(image);
vector<Mat> ims = pp->findSign(pp->getImage());
} | [
"krzysztof.kozubek135@gmail.com"
] | krzysztof.kozubek135@gmail.com |
24b55eb871ece292a91081721896bbc8e725e70f | eec6fc365c7415835b4a69eaceb23a224f2abc47 | /BaekJoon/2020/헤일스톤 수열.cpp | 776bd6304443352dbdb5890ba8973e4e05f6b004 | [] | no_license | chosh95/STUDY | 3e2381c632cebecc9a91e791a4a27a89ea6491ea | 0c88a1dd55d1826e72ebebd5626d6d83665c8431 | refs/heads/master | 2022-04-30T23:58:56.228240 | 2022-04-18T13:08:01 | 2022-04-18T13:08:01 | 166,837,216 | 3 | 1 | null | 2019-06-20T10:51:49 | 2019-01-21T15:32:03 | C++ | UTF-8 | C++ | false | false | 369 | cpp | #include <iostream>
#include <algorithm>
using namespace std;
int T, N;
int dp[100001];
int hale(int n) {
int ans = 1;
while (n != 1) {
ans = max(ans, n);
if (n % 2 == 0)
n /= 2;
else {
n *= 3;
n += 1;
}
}
return ans;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> T;
while (T--) {
cin >> N;
printf("%d\n", hale(N));
}
} | [
"chosh-95@hanmail.net"
] | chosh-95@hanmail.net |
0ee7c45deb5eccf9f8b4d81c110517f91e7b87d5 | 31b60bd2580a2e69309879bc324bd1a790205a94 | /third_party/gpus/cuda/include/thrust/detail/scan.inl | 5047b12f2fb2e4b79b684dab528ff7bc9f6aaa88 | [
"Apache-2.0"
] | permissive | synthesisai/tensorflow | 44881a6a7af7988178f32e12ef8261ea527fc576 | 8587db23b694093db16864c5ceda025cdc35027f | refs/heads/master | 2021-01-12T22:53:48.556872 | 2017-02-10T19:37:50 | 2017-02-10T19:37:50 | 81,367,986 | 0 | 0 | null | 2017-02-08T19:33:37 | 2017-02-08T19:33:37 | null | UTF-8 | C++ | false | false | 46 | inl | /usr/local/cuda/include/thrust/detail/scan.inl | [
"ubuntu@ip-172-31-31-214.ec2.internal"
] | ubuntu@ip-172-31-31-214.ec2.internal |
cb52d58075ff4da5b4b6200e3cf4ec916a5a95d4 | 3804ed89712eb236d131cb8c6fbc2da4c19b8ac3 | /repos/plywood/src/math/math/ply-math/Box.h | d06403f6a93d8e876c5a10e8520469d094674c68 | [
"MIT"
] | permissive | mingodad/plywood | 1c4eb60ff0309a970bf3415aa9f2479cb599311e | bbe69f5b23522e138f66a20c285ac68661b50c9c | refs/heads/main | 2023-02-09T16:12:57.455617 | 2021-01-02T01:29:28 | 2021-01-02T01:29:28 | 326,051,972 | 0 | 0 | MIT | 2021-01-01T20:36:11 | 2021-01-01T20:36:10 | null | UTF-8 | C++ | false | false | 4,730 | h | /*------------------------------------
///\ Plywood C++ Framework
\\\/ https://plywood.arc80.com/
------------------------------------*/
#pragma once
#include <ply-math/Core.h>
namespace ply {
template <class V>
struct Box {
using T = decltype(V::x);
V mins;
V maxs;
// Constructors
Box() = default; // uninitialized
Box(const V& arg) : mins{arg}, maxs{arg} {
}
Box(const V& mins, const V& maxs) : mins{mins}, maxs{maxs} {
}
T length2() const {
return mins.length2() + maxs.length2();
}
static Box<V> fromSize(T minx, T miny, T width, T height) {
return {{minx, miny}, {T(minx + width), T(miny + height)}};
}
static Box<V> fromSize(const V& mins, const V& size) {
return {mins, mins + size};
}
template <typename OtherBox>
OtherBox to() const {
using V2 = decltype(OtherBox::mins);
return OtherBox{mins.template to<V2>(), maxs.template to<V2>()};
}
// +
Box operator+(const Box& arg) const {
return Box(mins + arg.mins, maxs + arg.maxs);
}
void operator+=(const Box& arg) {
mins += arg.mins;
maxs += arg.maxs;
}
// -
Box operator-(const Box& arg) const {
return Box(mins - arg.mins, maxs - arg.maxs);
}
void operator-=(const Box& arg) {
mins -= arg.mins;
maxs -= arg.maxs;
}
// *
Box operator*(const V& arg) const {
return Box(mins * arg, maxs * arg);
}
void operator*=(const V& arg) {
mins *= arg;
maxs *= arg;
}
// /
Box operator/(const V& arg) const {
return *this * (T(1) / arg);
}
Box& operator/=(const V& arg) {
return *this *= (T(1) / arg);
}
// ==
bool operator==(const Box& arg) const {
return (mins == arg.mins) && (maxs == arg.maxs);
}
// Size
V size() const {
return maxs - mins;
}
bool isEmpty() const {
return !allLess(mins, maxs); // Note: This is different from (maxs > mins)
}
T width() const {
return maxs.x - mins.x;
}
T height() const {
return maxs.y - mins.y;
}
T depth() const {
return maxs.z - mins.z;
}
// Adjustments
friend Box expand(const Box& box, const V& arg) {
return Box(box.mins - arg, box.maxs + arg);
}
friend Box shrink(const Box& box, const V& arg) {
return Box(box.mins + arg, box.maxs - arg);
}
// Math
V mix(const V& arg) const {
return ply::mix(mins, maxs, arg);
}
V unmix(const V& arg) const {
return ply::unmix(mins, maxs, arg);
}
V mid() const {
return (mins + maxs) * 0.5f;
}
Box mix(const Box& arg) const {
return {mix(arg.mins), mix(arg.maxs)};
}
Box unmix(const Box& arg) const {
return {unmix(arg.mins), unmix(arg.maxs)};
}
V clamp(const V& arg) const {
return clamp(arg, mins, maxs);
}
V topLeft() const {
return V{mins.x, maxs.y};
}
V bottomRight() const {
return V{maxs.x, mins.y};
}
// Boolean operations
bool contains(const V& arg) const {
return allLessOrEqual(mins, arg) && allLess(arg, maxs);
}
bool contains(const Box& arg) const {
return allLessOrEqual(mins, arg.mins) && allLessOrEqual(arg.maxs, maxs);
}
bool intersects(const Box& arg) const {
return !intersect(*this, arg).isEmpty();
}
static Box zero() {
return {V{0}, V{0}};
}
static Box empty() {
return {V{Limits<T>::Max}, V{Limits<T>::Min}};
}
static Box full() {
return {V{Limits<T>::Min}, V{Limits<T>::Min}};
}
};
template <typename V>
Box<V> makeUnion(const V& p0, const V& p1) {
return Box<V>(min(p0, p1), max(p0, p1));
}
template <typename V>
Box<V> makeUnion(const Box<V>& box, const V& arg) {
return Box<V>(min(box.mins, arg), max(box.maxs, arg));
}
template <typename V>
Box<V> makeUnion(const Box<V>& a, const Box<V>& b) {
return Box<V>(min(a.mins, b.mins), max(a.maxs, b.maxs));
}
template <typename V>
Box<V> intersect(const Box<V>& a, const Box<V>& b) {
return Box<V>(max(a.mins, b.mins), min(a.maxs, b.maxs));
}
template <typename V>
Box<V> makeSolid(const Box<V>& a) {
return Box<V>(min(a.mins, a.maxs), max(a.mins, a.maxs));
}
template <typename V>
Box<V> quantizeNearest(const Box<V>& a, float spacing) {
return {quantizeNearest(a.mins, spacing), quantizeNearest(a.maxs, spacing)};
}
template <typename V>
PLY_INLINE Box<V> quantizeExpand(const Box<V>& a, float spacing) {
return {quantizeDown(a.mins, spacing), quantizeUp(a.maxs, spacing)};
}
} // namespace ply
| [
"filter-github@preshing.com"
] | filter-github@preshing.com |
d9357e9866258ac947096f97684ca37f2e0575d0 | 8122d1d3b5adbb80d34ce0e922657cae3ee8970a | /src/drivers/uniqueID.cpp | 2b8f7eb3577802ea082a1f2a50115771b429a4f1 | [] | no_license | bootchk/nRF5x | 151eea478e8c93929f4bca4deb4429e5589d6bfc | 2e7cdb8421d508318a0df1e702691294a07b32d4 | refs/heads/master | 2021-01-12T10:31:28.736063 | 2018-05-03T20:22:16 | 2018-05-03T20:22:16 | 76,469,379 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 503 | cpp |
#include "uniqueID.h"
#include <nrf.h>
// FUTURE use a 48-bit bit field
uint64_t SystemProperties::deviceID() {
/*
* NRF_FICR->DEVICEADDR[] is array of 32-bit words.
* NRF_FICR->DEVICEADDR yields type (unit32_t*)
* Cast: (uint64_t*) NRF_FICR->DEVICEADDR yields type (unit64_t*)
* Dereferencing: *(uint64_t*) NRF_FICR->DEVICEADDR yields type uint64_t
*
* Nordic doc asserts upper two bytes read all ones.
*/
uint64_t result = *((uint64_t*) NRF_FICR->DEVICEADDR);
return result;
}
| [
"bootch@nc.rr.com"
] | bootch@nc.rr.com |
d55e0f6b8b7fd1df263f93a35ac8b558d20ddbc2 | 7dcc00aeab6ce52256eb37e7a6da6c986e7015c3 | /yl_algorithm_code/C,C++/2020 暑假 蓝桥杯训练/二刷PTA/PTA_L1-040.cpp | 8265050bad09bdc3a7100f2d1f21e3af31b7b13a | [] | no_license | ztony123/codeHouse | ea2e6efb4460d1296e24dbf670e0a783ec99655a | f767149cbc558fae14f8cfde5778f57a122984e2 | refs/heads/master | 2023-01-22T14:12:52.483079 | 2020-12-01T11:09:37 | 2020-12-01T11:09:37 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 313 | cpp | #include<iostream>
using namespace std;
int main() {
int n;
char c;
double h[15][2];
cin >> n;
for(int i=0; i<n; i++) {
cin >> c >> h[i][0];
if(c == 'M') {
h[i][1] = h[i][0] / 1.09;
} else {
h[i][1] = h[i][0] * 1.09;
}
}
for(int i=0; i<n; i++) {
printf("%.2lf\n",h[i][1]);
}
return 0;
}
| [
"2336739721@qq.com"
] | 2336739721@qq.com |
0ea161f86a265308e72ea81a572bbb3784cffdc7 | 1f5079b24785a0e6a8bef1f15e1bca939e94ba56 | /Dev/C++/Mascaret/src/VEHA/Behavior/Common/pluginManager.cpp | bb5c0079d9251ac4da5dfa0f55bf5bb094354dae | [] | no_license | querrec/Mascaret | 7d5d0628dfb93226a602f79a7a974c14a60a88e8 | c71eba3667b3e3fa8a0b18a1f40219aee358c968 | refs/heads/master | 2021-01-17T08:12:10.024097 | 2016-04-14T13:27:52 | 2016-04-14T13:27:52 | 25,727,699 | 0 | 5 | null | null | null | null | UTF-8 | C++ | false | false | 7,114 | cpp | #include "Tools/filesystem.h"
#include "VEHA/Behavior/Common/pluginManager.h"
#ifdef _WIN32
#include <windows.h>
#else
#include <dlfcn.h>
#endif
#include <iostream>
#include <fstream>
#include <sstream>
#include <sys/stat.h>
DECLARE_NAMESPACE_FILESYSTEM;
#define MAGIC_CHAR_4_RAW_DATA '$'
namespace VEHA
{
using std::ifstream;
using std::stringbuf;
using std::ofstream;
typedef void (*MessageFct)();
typedef void (*initPluginFct)(shared_ptr<XmlNode> pluginNode);
PluginManager * PluginManager::_instance=NULL;
PluginManager * PluginManager::getInstance()
{
if (!_instance)
_instance=new PluginManager();
return _instance;
}
typedef void (*fct) (void);
//TODO ->add
bool PluginManager::openPlugin(const string & name, shared_ptr<XmlNode> pluginNode)
{
#ifdef _WIN32
string libName=name+".dll";
#else
string libName="lib"+name+".so";
#endif
# if BOOST_FILESYSTEM_VERSION == 2
string filefullpath = fs::complete(libName,_pluginDir).file_string();
# else
string filefullpath = fs::complete(libName,_pluginDir).string();
# endif
cerr << "[PluginManager Info] Loading: " << filefullpath << endl;
#ifdef _WIN32
void * lib=(void*)LoadLibrary(filefullpath.c_str());
#else
void * lib=dlopen(filefullpath.c_str(), RTLD_LAZY);
#endif
if (lib)
{
_libs.push_back(lib);
void* initFct;
#ifdef _WIN32
if ((initFct=(void*)GetProcAddress((HINSTANCE)lib,"MASCARET_INIT")))
#else
if ((initFct=dlsym(lib,"MASCARET_INIT")))
#endif
{
(*(initPluginFct)(intptr_t)initFct)(pluginNode);
}
else
{
cerr<<"[PluginManager Error] NO MASCARET_INIT found in " << name <<" !"<<endl;
}
}
else
{
cerr << "[PluginManager Error] Opening plugin \""<< name <<"\": " << getPluginError() << endl;
}
return (lib!=NULL);
}
void * PluginManager::getSymbol(const string& symbolName)
{
// cerr<<"Want symbol:"<<symbolName<<"|"<<endl;
void * result=NULL;
for (size_t i=_libs.size();i--;)
{
#ifdef _WIN32
if ((result=(void*)GetProcAddress((HINSTANCE)_libs[i],symbolName.c_str())))
#else
if ((result=dlsym(_libs[i],symbolName.c_str())))
#endif
break;
}
#ifdef _WIN32
if (!result) result=(void*)GetProcAddress((HINSTANCE)NULL,symbolName.c_str());
#else
if (!result) result=dlsym(NULL,symbolName.c_str());
#endif
return result;
}
string PluginManager::getPluginError()
{
#ifdef _WIN32
static char error_buffer[65535];
DWORD errCode=GetLastError();
FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, NULL, errCode,
MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ),
error_buffer, sizeof(error_buffer), NULL );
return string(error_buffer);
#else
char * err=dlerror();
if (err)return err;
else return "";
#endif
}
PluginManager::PluginManager()
:_pluginDir("/tmp/"), _init(false)
{
}
PluginManager::~PluginManager()
{
for (size_t i=_libs.size();i--;)
{
#ifdef _WIN32
FreeLibrary((HINSTANCE)_libs[i]);
#else
dlclose(_libs[i]);
#endif
}
}
void PluginManager::test()
{
vector<pair<string,string> > v;
v.push_back(make_pair(string("Deflecteur_Ouvrir"),string("cerr<<\"Lancement set Pos\"<<endl;Vector3 b;dynamic_cast<Entity*>(_host.get())->setPosition(b);")));
updatePlugin("MonPlug",v);
if(!openPlugin("./MonPlug.so"))
cerr<<"Cant open MonPlug.so"<<endl;
// _generateCppFile("monTest__","he he ho ho \n toto tutu");
//cerr<<"et hop"<<endl;
}
void PluginManager::fireMascaretWindowsCreated()
{
fire("MASCARET_WINDOWS_CREATED");
}
void PluginManager::fireMascaretModelLoaded()
{
fire("MASCARET_MODEL_LOADED");
}
void PluginManager::fireMascaretStep()
{
fire("MASCARET_STEP");
}
void PluginManager::fireMascaretDestroying()
{
fire("MASCARET_DESTROYING");
}
void PluginManager::fire(const string& message)
{
//cerr << " WANT : " << message << endl;
for (size_t i=_libs.size();i--;)
{
void * result=NULL;
#ifdef _WIN32
if ((result=(void*)GetProcAddress((HINSTANCE)_libs[i],message.c_str())))
#else
if ((result=dlsym(_libs[i],message.c_str())))
#endif
{
//cerr << " PLUGIN : " << message << " FOUND" << endl;
(*(MessageFct)(intptr_t)result)();
}
}
}
void PluginManager::updatePlugin(const string& pluginName,const vector<pair<string,string> >& behaviors)
{
#if BOOST_FILESYSTEM_VERSION == 2
string name=fs::complete(pluginName,_pluginDir).file_string();
#else
string name=fs::complete(pluginName,_pluginDir).string();
#endif
string cppFileData=_generateCppCodePlugin(behaviors);
_generateCppFile(name,cppFileData);
_generatePlugin(name);
}
string PluginManager::_generateCppCodePlugin(const vector<pair<string,string> >& behaviors)
{
string result("\
#include \"VEHA/Kernel/InstanceSpecification.h\"\
\n#include \"VEHA/Kernel/Slot.h\"\
\n#include \"VEHA/Kernel/Property.h\"\
\n#include \"VEHA/Kernel/LiteralReal.h\"\
\n#include \"VEHA/Behavior/Common/BehaviorExecution.h\"\
\n#include \"VEHA/Behavior/Common/Behavior.h\"\
\n#include \"VEHA/Entity/Vector3.h\"\
\n#include \"VEHA/Entity/RotationVector.h\"\
\n#include \"VEHA/Entity/Entity.h\"\
\n#include <iostream>\
\n#include <vector>\
\nusing namespace std;\
\nusing namespace VEHA;\n");
for(size_t i=behaviors.size();i--;)
{
const string& b=behaviors[i].second;
const string& behaviorName=behaviors[i].first;
if (b.size()&& b[0]==MAGIC_CHAR_4_RAW_DATA)
{
result+=b.substr(1);
}
else
{
string className=behaviorName;
result+="\nclass "+className+": public BehaviorExecution \n{\n"
+"public:\n"
//constructor
+className+"(shared_ptr<Behavior> specif, shared_ptr<InstanceSpecification> host,const Parameters& p):BehaviorExecution(specif,host,p) \n{}\ndouble execute()\n{\n";
//executeFonction
// for (size_t i=
result+=b
+"return -1;\n}\n"
//+"\nconst Parameters& parameters;\n};\n"
+"\n};\n"
//init
+"extern \"C\"{\nshared_ptr<BehaviorExecution> "+behaviorName+"_init(shared_ptr<Behavior> specif, shared_ptr<InstanceSpecification> host,const Parameters& p)\n{\n"
+" return shared_ptr<BehaviorExecution>(new "+className+"(specif,host,p));\n}\n}\n";
}
}
return result;
}
void PluginManager::_generateCppFile(const string& pluginName,const string& data)
{
ifstream f((pluginName+".cpp").c_str());
if (!f.fail())
{
stringbuf fileStr;
f.get(fileStr,0);
if (fileStr.str()==data)
return; //nothin to do: same data
else f.close();
}
ofstream of((pluginName+".cpp").c_str());
of<<data;
of.close();
}
void PluginManager::_generatePlugin(const string& pluginName)
{
struct stat infosPlugin, infosCpp;
if (!stat((pluginName+".so").c_str(),&infosPlugin))
{
//FILE EXIST
if (!stat((pluginName+".cpp").c_str(),&infosCpp))
{
if (infosPlugin.st_mtime>infosCpp.st_mtime)
return ; //nothing to do;
}
else
{
cerr<<"can't create Plugin :"<<pluginName<<".cpp don't exist"<<endl;
return ;
}
}
string compileLine("g++ -rdynamic -fPIC --shared -I ../VEHA/include -I ../Tools/include -o ");
compileLine+=pluginName+".so "+pluginName+".cpp";
compileLine+=" -g"; //debug
if (system(compileLine.c_str()))
cerr<<"Error in creating : "<<pluginName<<".so"<<endl;
}
}
| [
"querrec@querrecPortable.(none)"
] | querrec@querrecPortable.(none) |
81301bd507ad87faa168289d588d152c023b1102 | 52ca17dca8c628bbabb0f04504332c8fdac8e7ea | /boost/python/object/function_handle.hpp | 92db26b8a2b5b628750644f019695097a8f1a25c | [] | no_license | qinzuoyan/thirdparty | f610d43fe57133c832579e65ca46e71f1454f5c4 | bba9e68347ad0dbffb6fa350948672babc0fcb50 | refs/heads/master | 2021-01-16T17:47:57.121882 | 2015-04-21T06:59:19 | 2015-04-21T06:59:19 | 33,612,579 | 0 | 0 | null | 2015-04-08T14:39:51 | 2015-04-08T14:39:51 | null | UTF-8 | C++ | false | false | 75 | hpp | #include "thirdparty/boost_1_58_0/boost/python/object/function_handle.hpp"
| [
"qinzuoyan@xiaomi.com"
] | qinzuoyan@xiaomi.com |
0127282142818f8fb9cf102b909a92cb81350281 | 1f04b7ea0c94568ac7ca6637ae1b0018b6a3fbe6 | /snackdown/roundb/e.cpp | 79067db3f2ca03ef249b6b5744adae9c8eeca3d8 | [] | no_license | shubhsingh594/codepractice | 14858853277d618245d39b5ff4074d4142d4025a | 73916e32949b1d74e2e2d62e2019df99628b773a | refs/heads/master | 2021-01-19T21:02:02.401593 | 2018-09-19T06:50:58 | 2018-09-19T06:50:58 | 88,597,028 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,742 | cpp | // template
#include <string.h>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <list>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz size()
#define rep(i,m) for(int i=0; i<(int)(m); i++)
#define rep2(i,n,m) for(int i=n; i<(int)(m); i++)
#define For(it,c) for(__typeof(c.begin()) it=c.begin(); it!=c.end(); ++it)
#define mem(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define ff first
#define ss second
#define dot(a,b) ((conj(a)*(b)).X)
#define X real()
#define Y imag()
#define length(V) (hypot((V).X,(V).Y))
#define vect(a,b) ((b)-(a))
#define cross(a,b) ((conj(a)*(b)).imag())
#define normalize(v) ((v)/length(v))
#define rotate(p,about,theta) ((p-about)*exp(point(0,theta))+about)
#define pointEqu(a,b) (comp(a.X,b.X)==0 && comp(a.Y,b.Y)==0)
#define mod 1000000007
typedef stringstream ss;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vector<int> > vii;
typedef long long ll;
typedef long double ld;
typedef complex<double> point;
typedef pair<point, point> segment;
typedef pair<double, point> circle;
typedef vector<point> polygon;
const int oo = (int) 1e9;
const double PI = 2 * acos(0);
const double eps = 1e-9;
int arr[60][60];
int dist[60][60];
int main()
{
int test; cin>>test; int t; int n;
int xs,ys,xe,ye;
int x1,y1,x2,y2; int i;
char type; int x,y;
for(t=0; t<test; t++)
{
cin>>n;
memset(arr,0,sizeof(arr));
memset(dist,0,sizeof(dist));
for(i=0; i<n; i++)
{
cin>>x1>>y1>>x2>>y2;
xs=min(x1,x2);
xe=max(x1,x2);
ys=min(y1,y2);
ye=max(y1,y2);
if (xs==xe)
{
type='c';
}
else
type ='r';
for(x=0; x<=50; x++)
{
for(y=0; y<=50; y++)
{
if (type=='r')
{
if (x<xs)
{
dist[x][y]=max(dist[x][y],abs(xs-x)+abs(y-ys));
}
else if (x>xe)
{
dist[x][y]=max(dist[x][y],abs(x-xe)+abs(y-ys));
}
else
{
dist[x][y]=max(dist[x][y],abs(y-ys));
}
}
else
{
if (y<ys)
{
dist[x][y]=max(dist[x][y],abs(ys-y)+abs(xs-x));
}
else if (y>ye)
{
dist[x][y]=max(dist[x][y],abs(y-ye)+abs(xs-x));
}
else
{
dist[x][y]=max(dist[x][y],abs(xs-x));
}
}
}
}
}
int result=dist[0][0];
for(x=0; x<=50; x++)
{
for(y=0; y<=50; y++)
{
result=min(result,dist[x][y]);
}
}
cout<<result<<"\n";
}//test
return 0;
}//main
| [
"shubh.112358@gmail.com"
] | shubh.112358@gmail.com |
cec39a5ccd82bd0924986ae69a6c7ace00d69af9 | e6944aad58294192eb0e27776d13ed84378f5468 | /src/MutateSeq.cpp | a2be1cd3d766b30b40ca68b9a0880dc98665ba56 | [
"MIT"
] | permissive | kant/RJModules | fd20690cc3632b13328e483d69d2e27b8b2c4402 | ab1b7c3dc7a855f096513783d88bed29c3538437 | refs/heads/master | 2020-09-04T20:14:28.943156 | 2019-11-05T21:58:35 | 2019-11-05T21:58:35 | 219,879,746 | 0 | 0 | MIT | 2019-11-06T00:48:13 | 2019-11-06T00:48:12 | null | UTF-8 | C++ | false | false | 13,173 | cpp | #include "RJModules.hpp"
#define NUM_CHANNELS 8
struct MutateSnapKnob : RoundSmallBlackKnob
{
MutateSnapKnob()
{
minAngle = -0.83 * M_PI;
maxAngle = 0.83 * M_PI;
snap = true;
}
};
struct MutateSnapKnobLg : RoundBlackKnob
{
MutateSnapKnobLg()
{
minAngle = -0.83 * M_PI;
maxAngle = 0.83 * M_PI;
snap = true;
}
};
struct MutateSeq : Module {
enum ParamIds {
ENUMS(LOCK_PARAM, 8),
ENUMS(OCT_PARAM, 8),
ENUMS(SEMI_PARAM, 8),
STEPS_PARAM,
OCT_DEPTH,
NOTE_DEPTH,
MUTATE_EVERY,
NUM_PARAMS
};
enum InputIds {
IN_INPUT,
NUM_INPUTS = IN_INPUT + NUM_CHANNELS
};
enum OutputIds {
OUT_OUTPUT,
NUM_OUTPUTS = OUT_OUTPUT + NUM_CHANNELS
};
enum LightIds {
ENUMS(LOCK_LIGHT, 8),
NUM_LIGHTS
};
// Lock
bool lock_state[8];
dsp::BooleanTrigger lockTrigger[8];
// Seq
int index = 0;
float phase = 0.f;
int currentPosition;
SchmittTrigger clockTrigger;
bool init = false;
float seq_notes[8] = {-99,-99,-99,-99,-99,-99,-99,-99};
float seq_octaves[8] = {-99,-99,-99,-99,-99,-99,-99,-99};
float last_notes[8] = {-99,-99,-99,-99,-99,-99,-99,-99};
float last_octaves[8] = {-99,-99,-99,-99,-99,-99,-99,-99};
int mut_counter = 0;
// Static
float notes[12] = {0, 0.08, 0.17, 0.25, 0.33, 0.42,
0.5, 0.58, 0.67, 0.75, 0.83, 0.92};
int octaves[7] = {-2, -1, 0, 1, 2, 3, 4};
MutateSeq() {
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
configParam(MutateSeq::LOCK_PARAM + 0, 0.0, 1.0, 0.0, string::f("Ch %d lock", 0));
configParam(MutateSeq::LOCK_PARAM + 1, 0.0, 1.0, 0.0, string::f("Ch %d lock", 1));
configParam(MutateSeq::LOCK_PARAM + 2, 0.0, 1.0, 0.0, string::f("Ch %d lock", 2));
configParam(MutateSeq::LOCK_PARAM + 3, 0.0, 1.0, 0.0, string::f("Ch %d lock", 3));
configParam(MutateSeq::LOCK_PARAM + 4, 0.0, 1.0, 0.0, string::f("Ch %d lock", 4));
configParam(MutateSeq::LOCK_PARAM + 5, 0.0, 1.0, 0.0, string::f("Ch %d lock", 5));
configParam(MutateSeq::LOCK_PARAM + 6, 0.0, 1.0, 0.0, string::f("Ch %d lock", 6));
configParam(MutateSeq::LOCK_PARAM + 7, 0.0, 1.0, 0.0, string::f("Ch %d lock", 7));
configParam(MutateSeq::OCT_PARAM + 0, 0.0, 6.0, 1.0, string::f("Ch %d octave", 0));
configParam(MutateSeq::OCT_PARAM + 1, 0.0, 6.0, 1.0, string::f("Ch %d octave", 1));
configParam(MutateSeq::OCT_PARAM + 2, 0.0, 6.0, 1.0, string::f("Ch %d octave", 2));
configParam(MutateSeq::OCT_PARAM + 3, 0.0, 6.0, 1.0, string::f("Ch %d octave", 3));
configParam(MutateSeq::OCT_PARAM + 4, 0.0, 6.0, 1.0, string::f("Ch %d octave", 4));
configParam(MutateSeq::OCT_PARAM + 5, 0.0, 6.0, 1.0, string::f("Ch %d octave", 5));
configParam(MutateSeq::OCT_PARAM + 6, 0.0, 6.0, 1.0, string::f("Ch %d octave", 6));
configParam(MutateSeq::OCT_PARAM + 7, 0.0, 6.0, 1.0, string::f("Ch %d octave", 7));
configParam(MutateSeq::SEMI_PARAM + 0, 0.0, 11.0, 0.0, string::f("Ch %d semi", 0));
configParam(MutateSeq::SEMI_PARAM + 1, 0.0, 11.0, 0.0, string::f("Ch %d semi", 1));
configParam(MutateSeq::SEMI_PARAM + 2, 0.0, 11.0, 0.0, string::f("Ch %d semi", 2));
configParam(MutateSeq::SEMI_PARAM + 3, 0.0, 11.0, 0.0, string::f("Ch %d semi", 3));
configParam(MutateSeq::SEMI_PARAM + 4, 0.0, 11.0, 0.0, string::f("Ch %d semi", 4));
configParam(MutateSeq::SEMI_PARAM + 5, 0.0, 11.0, 0.0, string::f("Ch %d semi", 5));
configParam(MutateSeq::SEMI_PARAM + 6, 0.0, 11.0, 0.0, string::f("Ch %d semi", 6));
configParam(MutateSeq::SEMI_PARAM + 7, 0.0, 11.0, 0.0, string::f("Ch %d semi", 7));
configParam(MutateSeq::MUTATE_EVERY, 1.0, 128.0, 16.0, "Mutate Every");
configParam(MutateSeq::OCT_DEPTH, 0.0, 6.0, 1.0, "Oct depth");
configParam(MutateSeq::NOTE_DEPTH, 0.0, 11.0, 11.0, "Note depth");
configParam(MutateSeq::STEPS_PARAM, 1.0f, 8.0f, 8.0f, "Length");
}
void setIndex(int index) {
int numSteps = (int) clamp(roundf(params[STEPS_PARAM].value), 1.0f, 8.0f);
phase = 0.f;
this->index = index;
if (this->index >= numSteps)
this->index = 0;
}
// void step() override;
// json_t *dataToJson() override {};
// void dataFromJson(json_t *rootJ) override {};
void process(const ProcessArgs &args) override {
// Reset on first process
if(!init){
for (int i = 0; i < 8; i++) {
seq_octaves[i] = params[OCT_PARAM + i].value;
seq_notes[i] = params[SEMI_PARAM + i].value;
last_octaves[i] = params[OCT_PARAM + i].value;
last_notes[i] = params[SEMI_PARAM + i].value;
lock_state[i] = false;
}
init = true;
}
bool gateIn = false;
if (inputs[IN_INPUT].active) {
if (clockTrigger.process(inputs[IN_INPUT].value)) {
setIndex(index + 1);
// MUTATION
mut_counter++;
if (mut_counter >= params[MUTATE_EVERY].value){
mut_counter = 0;
int choice = rand() % (int) params[STEPS_PARAM].value;
if(!lock_state[choice]){
bool mutate_oct = rand() & 1;
if(mutate_oct){
if(rand() & 1){
int plus_distance = (int) rand() & (int) params[OCT_DEPTH].value + 1;
seq_octaves[choice] = seq_octaves[choice] + plus_distance;
}else{
int minus_distance = (int) rand() & (int) params[OCT_DEPTH].value + 1;
seq_octaves[choice] = seq_octaves[choice] - minus_distance;
}
if(seq_octaves[choice] < 0)
seq_octaves[choice] = 0;
if(seq_octaves[choice] > 6)
seq_octaves[choice] = 6;
}
bool mutate_semi = rand() & 1;
if(mutate_semi){
if(rand() & 1){
int plus_distance = (int) rand() & (int) params[NOTE_DEPTH].value + 1;
seq_notes[choice] = seq_notes[choice] + plus_distance;
}else{
int minus_distance = (int) rand() & (int) params[NOTE_DEPTH].value + 1;
seq_notes[choice] = seq_notes[choice] - minus_distance;
}
if(seq_notes[choice] < 0)
seq_notes[choice] = 0;
if(seq_notes[choice] > 11)
seq_notes[choice] = 11;
}
}
}
}
}
// Iterate rows
for (int i = 0; i < 8; i++) {
// Process trigger
if (lockTrigger[i].process(params[LOCK_PARAM + i].getValue() > 0.f))
lock_state[i] ^= true;
// Set light
lights[LOCK_LIGHT + i].setBrightness(lock_state[i] ? 0.6f : 0.f);
lights[LOCK_LIGHT + i].setBrightness((index == i) ? 1.0f :lights[LOCK_LIGHT + i].getBrightness());
}
// If knobs have been nudged since last seen, use those.
if(params[OCT_PARAM + index].value != last_octaves[index]){
seq_octaves[index] = params[OCT_PARAM + index].value;
}
last_octaves[index] = params[OCT_PARAM + index].value;
if(params[SEMI_PARAM + index].value != last_notes[index]){
seq_notes[index] = params[SEMI_PARAM + index].value;
}
last_notes[index] = params[SEMI_PARAM + index].value;
float oct_param = seq_octaves[index];
float note_param = seq_notes[index];
outputs[OUT_OUTPUT].value = octaves[(int)oct_param] + notes[(int)note_param];
}
};
template <typename BASE>
struct MuteLight : BASE {
MuteLight() {
this->box.size = mm2px(Vec(6.0, 6.0));
}
};
struct MutateSeqWidget: ModuleWidget {
MutateSeqWidget(MutateSeq *module);
};
MutateSeqWidget::MutateSeqWidget(MutateSeq *module) {
setModule(module);
setPanel(SVG::load(assetPlugin(pluginInstance, "res/MutateSeq.svg")));
// MAGNETS
// addChild(createWidget<ScrewSilver>(Vec(15, 0)));
// addChild(createWidget<ScrewSilver>(Vec(box.size.x - 30, 0)));
// addChild(createWidget<ScrewSilver>(Vec(15, 365)));
// addChild(createWidget<ScrewSilver>(Vec(box.size.x - 30, 365)));
addParam(createParam<LEDBezel>(mm2px(Vec(4.214, 17.81)), module, MutateSeq::LOCK_PARAM + 0));
addParam(createParam<LEDBezel>(mm2px(Vec(4.214, 27.809)), module, MutateSeq::LOCK_PARAM + 1));
addParam(createParam<LEDBezel>(mm2px(Vec(4.214, 37.809)), module, MutateSeq::LOCK_PARAM + 2));
addParam(createParam<LEDBezel>(mm2px(Vec(4.214, 47.81)), module, MutateSeq::LOCK_PARAM + 3));
addParam(createParam<LEDBezel>(mm2px(Vec(4.214, 57.81)), module, MutateSeq::LOCK_PARAM + 4));
addParam(createParam<LEDBezel>(mm2px(Vec(4.214, 67.809)), module, MutateSeq::LOCK_PARAM + 5));
addParam(createParam<LEDBezel>(mm2px(Vec(4.214, 77.81)), module, MutateSeq::LOCK_PARAM + 6));
addParam(createParam<LEDBezel>(mm2px(Vec(4.214, 87.81)), module, MutateSeq::LOCK_PARAM + 7));
addChild(createLight<MuteLight<GreenLight>>(mm2px(Vec(4.214 + 0.75, 17.81 + 0.75)), module, MutateSeq::LOCK_LIGHT + 0));
addChild(createLight<MuteLight<GreenLight>>(mm2px(Vec(4.214 + 0.75, 27.809 + 0.75)), module, MutateSeq::LOCK_LIGHT + 1));
addChild(createLight<MuteLight<GreenLight>>(mm2px(Vec(4.214 + 0.75, 37.809 + 0.75)), module, MutateSeq::LOCK_LIGHT + 2));
addChild(createLight<MuteLight<GreenLight>>(mm2px(Vec(4.214 + 0.75, 47.81 + 0.75)), module, MutateSeq::LOCK_LIGHT + 3));
addChild(createLight<MuteLight<GreenLight>>(mm2px(Vec(4.214 + 0.75, 57.81 + 0.75)), module, MutateSeq::LOCK_LIGHT + 4));
addChild(createLight<MuteLight<GreenLight>>(mm2px(Vec(4.214 + 0.75, 67.809 + 0.75)), module, MutateSeq::LOCK_LIGHT + 5));
addChild(createLight<MuteLight<GreenLight>>(mm2px(Vec(4.214 + 0.75, 77.81 + 0.75)), module, MutateSeq::LOCK_LIGHT + 6));
addChild(createLight<MuteLight<GreenLight>>(mm2px(Vec(4.214 + 0.75, 87.81 + 0.75)), module, MutateSeq::LOCK_LIGHT + 7));
addParam(createParam<MutateSnapKnob>(mm2px(Vec(16.57, 17.165)), module, MutateSeq::OCT_PARAM + 0));
addParam(createParam<MutateSnapKnob>(mm2px(Vec(16.57, 27.164)), module, MutateSeq::OCT_PARAM + 1));
addParam(createParam<MutateSnapKnob>(mm2px(Vec(16.57, 37.164)), module, MutateSeq::OCT_PARAM + 2));
addParam(createParam<MutateSnapKnob>(mm2px(Vec(16.57, 47.165)), module, MutateSeq::OCT_PARAM + 3));
addParam(createParam<MutateSnapKnob>(mm2px(Vec(16.57, 57.164)), module, MutateSeq::OCT_PARAM + 4));
addParam(createParam<MutateSnapKnob>(mm2px(Vec(16.57, 67.165)), module, MutateSeq::OCT_PARAM + 5));
addParam(createParam<MutateSnapKnob>(mm2px(Vec(16.57, 77.164)), module, MutateSeq::OCT_PARAM + 6));
addParam(createParam<MutateSnapKnob>(mm2px(Vec(16.57, 87.164)), module, MutateSeq::OCT_PARAM + 7));
addParam(createParam<MutateSnapKnob>(mm2px(Vec(28.214, 17.165)), module, MutateSeq::SEMI_PARAM + 0));
addParam(createParam<MutateSnapKnob>(mm2px(Vec(28.214, 27.164)), module, MutateSeq::SEMI_PARAM + 1));
addParam(createParam<MutateSnapKnob>(mm2px(Vec(28.214, 37.164)), module, MutateSeq::SEMI_PARAM + 2));
addParam(createParam<MutateSnapKnob>(mm2px(Vec(28.214, 47.165)), module, MutateSeq::SEMI_PARAM + 3));
addParam(createParam<MutateSnapKnob>(mm2px(Vec(28.214, 57.164)), module, MutateSeq::SEMI_PARAM + 4));
addParam(createParam<MutateSnapKnob>(mm2px(Vec(28.214, 67.165)), module, MutateSeq::SEMI_PARAM + 5));
addParam(createParam<MutateSnapKnob>(mm2px(Vec(28.214, 77.164)), module, MutateSeq::SEMI_PARAM + 6));
addParam(createParam<MutateSnapKnob>(mm2px(Vec(28.214, 87.164)), module, MutateSeq::SEMI_PARAM + 7));
// Mutate Params
addParam(createParam<MutateSnapKnobLg>(mm2px(Vec(4.0, 102.0)), module, MutateSeq::MUTATE_EVERY));
addParam(createParam<MutateSnapKnobLg>(mm2px(Vec(16.0, 102.0)), module, MutateSeq::OCT_DEPTH));
addParam(createParam<MutateSnapKnobLg>(mm2px(Vec(28.0, 102.0)), module, MutateSeq::NOTE_DEPTH));
// Ins/Outs
addInput(createPort<PJ301MPort>(mm2px(Vec(4.214, 117.809)), PortWidget::INPUT, module, MutateSeq::IN_INPUT));
addParam(createParam<MutateSnapKnob>(mm2px(Vec(16.57, 117.809)), module, MutateSeq::STEPS_PARAM));
addOutput(createPort<PJ301MPort>(mm2px(Vec(28.214, 117.809)), PortWidget::OUTPUT, module, MutateSeq::OUT_OUTPUT));
}
Model *modelMutateSeq = createModel<MutateSeq, MutateSeqWidget>("MutateSeq");
| [
"rich@anomos.info"
] | rich@anomos.info |
a854faf6fc64680f8c88a58e5f9fffbee9bf7818 | 9dc9a2495de7e0be5929517628a787cd04917797 | /benchmark/tests/luabind_common.h | 1709b94e81332132a8893858ed2f496f0888ecfa | [
"Apache-2.0"
] | permissive | cpgf/cpgf | e707c96b439cdcbbb8959abf26b4a4e257362b73 | 2590f6bfe85de4cba9645acac64460031739767f | refs/heads/master | 2023-03-09T00:56:02.276678 | 2022-05-22T06:47:24 | 2022-05-22T06:47:24 | 16,725,840 | 201 | 52 | null | 2018-08-15T01:04:29 | 2014-02-11T09:28:40 | C++ | UTF-8 | C++ | false | false | 1,098 | h | #ifndef LUABIND_COMMON_H
#define LUABIND_COMMON_H
#include "cpgf/metatraits/gmetaconverter_string.h"
#include "cpgf/gmetaapi.h"
#include "cpgf/scriptbind/gluabind.h"
#include "cpgf/gscopedinterface.h"
#include <memory>
class TestLuaContext
{
public:
TestLuaContext() {
this->luaState = luaL_newstate();
luaL_openlibs(this->luaState);
this->service.reset(cpgf::createDefaultMetaService());
this->binding.reset(createLuaScriptObject(this->service.get(), this->luaState));
}
~TestLuaContext() {
lua_close(this->luaState);
}
cpgf::IMetaService * getService() const {
return this->service.get();
}
lua_State * getLua() const {
return this->luaState;
}
cpgf::GScriptObject * getBinding() const {
return this->binding.get();
}
bool doString(const char * code) const {
luaL_loadstring(this->luaState, code);
lua_call(this->luaState, 0, LUA_MULTRET);
return true;
}
private:
lua_State * luaState;
cpgf::GScopedInterface<cpgf::IMetaService> service;
std::unique_ptr<cpgf::GScriptObject> binding;
};
#endif
| [
"wqking@outlook.com"
] | wqking@outlook.com |
11327d10fc6d46f4f105b0fcc7cde37fdcb4a7dc | 90699fa45fdb43cd78668d0a99d70af1dafa79c3 | /ccc/rtti/main.cpp | 1cbcf0cb915eb327532e5b243967606d6c09b5dc | [] | no_license | wallEVA96/ccc-c-trial | e75d62bdef0c5e6d95738095644eb8a8e3be9ac0 | 36287399e2cd817c33cbfbaf0ae2ee52b419a779 | refs/heads/master | 2021-07-13T13:05:40.932384 | 2020-07-06T11:41:12 | 2020-07-06T11:41:12 | 154,621,759 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 784 | cpp | /*
* main.cpp
* _ _
* __ ____ _| | | _____ ____ _
* \ \ /\ / / _` | | |/ _ \ \ / / _` |
* \ V V / (_| | | | __/\ V / (_| |
* \_/\_/ \__,_|_|_|\___| \_/ \__,_|
* Copyright (C) 2019 walleva <walleva@ubuntu>
*
* Distributed under terms of the MIT license.
*/
#include <iostream>
using namespace std;
#include <typeinfo>
#include <cxxabi.h>
class temp
{
public:
temp()
{
cout << "temp" << endl;
}
};
int main(int argc, char **argv)
{
double t;
int num;
temp *tp;
cout << "data type:" << typeid(t).name() << endl;
cout << "data type:" << typeid(*tp).name() << endl;
char *chrp = abi::__cxa_demangle(typeid(t).name(), 0, 0, &num);
cout << chrp << " " << t << endl;
return 0;
}
| [
"walleva@email.com"
] | walleva@email.com |
59ec42db5fa30ada85a29563cf1c4c9a77745b9f | 7bb793c39d512bc3490608ec028c06677fdd7b05 | /hrserver/src/base/HttpParserWrapper.cpp | c20f2496c2dfe6472708a6cb4e4fd8323496b6f0 | [] | no_license | rineishou/highwayns_rin | 11564fc667633720db50f31ff9baf7654ceaac3f | dfade9705a95a41f44a7c921c94bd3b9e7a1e360 | refs/heads/master | 2021-06-17T23:06:29.082403 | 2018-12-17T12:13:09 | 2018-12-17T12:13:09 | 88,716,361 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,663 | cpp | //
// HttpPdu.cpp
// http_msg_server
//
// Created by jianqing.du on 13-9-29.
// Copyright (c) 2013年 ziteng. All rights reserved.
//
#include "HttpParserWrapper.h"
#include "http_parser.h"
#define MAX_REFERER_LEN 32
CHttpParserWrapper::CHttpParserWrapper()
{
}
void CHttpParserWrapper::ParseHttpContent(const char* buf, uint32_t len)
{
http_parser_init(&m_http_parser, HTTP_REQUEST);
memset(&m_settings, 0, sizeof(m_settings));
m_settings.on_url = OnUrl;
m_settings.on_header_field = OnHeaderField;
m_settings.on_header_value = OnHeaderValue;
m_settings.on_headers_complete = OnHeadersComplete;
m_settings.on_body = OnBody;
m_settings.on_message_complete = OnMessageComplete;
m_settings.object = this;
m_read_all = false;
m_read_referer = false;
m_read_forward_ip = false;
m_read_user_agent = false;
m_read_content_type = false;
m_read_content_len = false;
m_read_host = false;
m_total_length = 0;
m_url.clear();
m_body_content.clear();
m_referer.clear();
m_forward_ip.clear();
m_user_agent.clear();
m_content_type.clear();
m_content_len = 0;
m_host.clear();
http_parser_execute(&m_http_parser, &m_settings, buf, len);
}
int CHttpParserWrapper::OnUrl(http_parser* parser, const char *at,
size_t length, void* obj)
{
((CHttpParserWrapper*)obj)->SetUrl(at, length);
return 0;
}
int CHttpParserWrapper::OnHeaderField(http_parser* parser, const char *at,
size_t length, void* obj)
{
if (!((CHttpParserWrapper*)obj)->HasReadReferer())
{
if (strncasecmp(at, "Referer", 7) == 0)
{
((CHttpParserWrapper*)obj)->SetReadReferer(true);
}
}
if (!((CHttpParserWrapper*)obj)->HasReadForwardIP())
{
if (strncasecmp(at, "X-Forwarded-For", 15) == 0)
{
((CHttpParserWrapper*)obj)->SetReadForwardIP(true);
}
}
if (!((CHttpParserWrapper*)obj)->HasReadUserAgent())
{
if (strncasecmp(at, "User-Agent", 10) == 0)
{
((CHttpParserWrapper*)obj)->SetReadUserAgent(true);
}
}
if (!((CHttpParserWrapper*)obj)->HasReadContentType())
{
if (strncasecmp(at, "Content-Type", 12) == 0)
{
((CHttpParserWrapper*)obj)->SetReadContentType(true);
}
}
if(!((CHttpParserWrapper*)obj)->HasReadContentLen())
{
if(strncasecmp(at, "Content-Length", 14) == 0)
{
((CHttpParserWrapper*)obj)->SetReadContentLen(true);
}
}
if(!((CHttpParserWrapper*)obj)->HasReadHost())
{
if(strncasecmp(at, "Host", 4) == 0)
{
((CHttpParserWrapper*)obj)->SetReadHost(true);
}
}
return 0;
}
int CHttpParserWrapper::OnHeaderValue(http_parser* parser, const char *at, size_t length, void* obj)
{
if (((CHttpParserWrapper*)obj)->IsReadReferer())
{
size_t referer_len =
(length > MAX_REFERER_LEN) ? MAX_REFERER_LEN : length;
((CHttpParserWrapper*)obj)->SetReferer(at, referer_len);
((CHttpParserWrapper*)obj)->SetReadReferer(false);
}
if (((CHttpParserWrapper*)obj)->IsReadForwardIP())
{
((CHttpParserWrapper*)obj)->SetForwardIP(at, length);
((CHttpParserWrapper*)obj)->SetReadForwardIP(false);
}
if (((CHttpParserWrapper*)obj)->IsReadUserAgent())
{
((CHttpParserWrapper*)obj)->SetUserAgent(at, length);
((CHttpParserWrapper*)obj)->SetReadUserAgent(false);
}
if (((CHttpParserWrapper*)obj)->IsReadContentType())
{
((CHttpParserWrapper*)obj)->SetContentType(at, length);
((CHttpParserWrapper*)obj)->SetReadContentType(false);
}
if(((CHttpParserWrapper*)obj)->IsReadContentLen())
{
string strContentLen(at, length);
((CHttpParserWrapper*)obj)->SetContentLen(atoi(strContentLen.c_str()));
((CHttpParserWrapper*)obj)->SetReadContentLen(false);
}
if(((CHttpParserWrapper*)obj)->IsReadHost())
{
((CHttpParserWrapper*)obj)->SetHost(at, length);
((CHttpParserWrapper*)obj)->SetReadHost(false);
}
return 0;
}
int CHttpParserWrapper::OnHeadersComplete(http_parser* parser, void* obj)
{
((CHttpParserWrapper*)obj)->SetTotalLength(parser->nread + (uint32_t) parser->content_length);
return 0;
}
int CHttpParserWrapper::OnBody(http_parser* parser, const char *at, size_t length, void* obj)
{
((CHttpParserWrapper*)obj)->SetBodyContent(at, length);
return 0;
}
int CHttpParserWrapper::OnMessageComplete(http_parser* parser, void* obj)
{
((CHttpParserWrapper*)obj)->SetReadAll();
return 0;
}
| [
"tei952@hotmail.com"
] | tei952@hotmail.com |
f5d53b9c6b8de205b6f8f1167fcfb81ebe586e48 | aca4f00c884e1d0e6b2978512e4e08e52eebd6e9 | /2011/contest/zjpcpc/L.cpp | 3f7acb151f894aa22692aedffd52912442c57794 | [] | no_license | jki14/competitive-programming | 2d28f1ac8c7de62e5e82105ae1eac2b62434e2a4 | ba80bee7827521520eb16a2d151fc0c3ca1f7454 | refs/heads/master | 2023-08-07T19:07:22.894480 | 2023-07-30T12:18:36 | 2023-07-30T12:18:36 | 166,743,930 | 2 | 0 | null | 2021-09-04T09:25:40 | 2019-01-21T03:40:47 | C++ | UTF-8 | C++ | false | false | 502 | cpp | #include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<climits>
#include<algorithm>
using namespace std;
typedef long long lld;
int main(){
int t,k,N;scanf("%d",&t);
lld n,p;
//double d;
while(t--){
scanf("%d",&N);n=(lld)N;
/*//debug
d=log((double)n)/log(2);
//cout<<"log2="<<d<<endl;
k=(int)d;
//cout<<"k="<<k<<endl;
k++;
printf("%d\n",k);*/
for(p=1L,k=1;!(n>=p && n<p*2);p*=2,k++);
printf("%d\n",k);
}
return 0;
}
| [
"jki14wz@gmail.com"
] | jki14wz@gmail.com |
6a9a5c209d2f6e97d5d6d62174a86048a4857d19 | 3c1009f45ca0108eac0e97b87aab5453daf3846d | /CircularList/node.cpp | 88d00cebf7afea395c1a340fc919e4c154367858 | [] | no_license | pedroeagle/notes-ed1 | f60a1d00000305fd86797640bd341e9d9d7294f5 | 7e384e20aba524b94413cb32bc89d8c2e4a6bd0c | refs/heads/master | 2020-04-26T19:29:05.060657 | 2018-11-26T12:40:18 | 2018-11-26T12:40:18 | 173,776,545 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 179 | cpp | #include "node.hpp"
Node::Node(){
next = previous = 0;
}
Node::Node(int info, Node *previous, Node *next){
this->info = info;
this->previous = previous;
this->next = next;
} | [
"pedroigor@aluno.unb.br"
] | pedroigor@aluno.unb.br |
c8d6ad4b342a141d8e1ae7de27518f11a676d539 | 367a80c031716a9d600a30eb72d7eac15698c7f2 | /src/util/bind_sdl.h | 45562ce779938979ae9ab4ec282090aec3517b0e | [] | no_license | mnvl/scratch | 9588ed1410655961d15d376d4bb2aad4981db859 | 7717772e0b9a85c8feb73fdc3562425f48b4a727 | refs/heads/master | 2020-04-10T08:39:52.750838 | 2012-08-19T08:24:32 | 2012-08-19T08:24:32 | 5,469,431 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 101 | h | #pragma once
#include <luabind/lua_include.hpp>
namespace util
{
void bind_SDL(lua_State *L);
}
| [
"manvel.avetisian@gmail.com"
] | manvel.avetisian@gmail.com |
c2f3f58e56efb91cf3281fcf18cf35176df863b1 | c1f89beed3118eed786415e2a6d378c28ecbf6bb | /src/debug/ildbsymlib/symwrite.cpp | 16ae07c566df25443b40a90df73e8bfc1650984f | [
"MIT"
] | permissive | mono/coreclr | 0d85c616ffc8db17f9a588e0448f6b8547324015 | 90f7060935732bb624e1f325d23f63072433725f | refs/heads/mono | 2023-08-23T10:17:23.811021 | 2019-03-05T18:50:49 | 2019-03-05T18:50:49 | 45,067,402 | 10 | 4 | NOASSERTION | 2019-03-05T18:50:51 | 2015-10-27T20:15:09 | C# | UTF-8 | C++ | false | false | 50,121 | cpp | //
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
// ===========================================================================
// File: symwrite.cpp
//
//
// Note: The various SymWriter_* and SymDocumentWriter_* are entry points
// called via PInvoke from the managed symbol wrapper used by managed languages
// to emit debug information (such as jscript)
// ===========================================================================
#include "pch.h"
#include "symwrite.h"
// -------------------------------------------------------------------------
// SymWriter class
// -------------------------------------------------------------------------
// This is a COM object which is called both directly from the runtime, and from managed code
// via PInvoke (CoreSymWrapper) and IJW (ISymWrapper). This is an unusual pattern, and it's not
// clear exactly how best to address it. Eg., should we be using BEGIN_EXTERNAL_ENTRYPOINT
// macros? Conceptually this is just a drop-in replacement for diasymreader.dll, and could
// live in a different DLL instead of being statically linked into the runtime. But since it
// relies on utilcode (and actually gets the runtime utilcode, not the nohost utilcode like
// other external tools), it does have some properties of runtime code.
//
//-----------------------------------------------------------
// NewSymWriter
// Static function used to create a new instance of SymWriter
//-----------------------------------------------------------
HRESULT SymWriter::NewSymWriter(const GUID& id, void **object)
{
if (id != IID_ISymUnmanagedWriter)
return (E_UNEXPECTED);
SymWriter *writer = NEW(SymWriter());
if (writer == NULL)
return (E_OUTOFMEMORY);
*object = (ISymUnmanagedWriter*)writer;
writer->AddRef();
return (S_OK);
}
//-----------------------------------------------------------
// SymWriter Constuctor
//-----------------------------------------------------------
SymWriter::SymWriter() :
m_refCount(0),
m_openMethodToken(mdMethodDefNil),
m_LargestMethodToken(mdMethodDefNil),
m_pmethod(NULL),
m_currentScope(k_noScope),
m_hFile(NULL),
m_pIStream(NULL),
m_pStringPool(NULL),
m_closed( false ),
m_sortLines (false),
m_sortMethodEntries(false)
{
memset(m_szPath, 0, sizeof(m_szPath));
memset(&ModuleLevelInfo, 0, sizeof(PDBInfo));
}
//-----------------------------------------------------------
// SymWriter QI
//-----------------------------------------------------------
COM_METHOD SymWriter::QueryInterface(REFIID riid, void **ppInterface)
{
if (ppInterface == NULL)
return E_INVALIDARG;
if (riid == IID_ISymUnmanagedWriter )
*ppInterface = (ISymUnmanagedWriter*)this;
/* ROTORTODO: Pretend that we do not implement ISymUnmanagedWriter2 to prevent C# compiler from using it.
This is against COM rules since ISymUnmanagedWriter3 inherits from ISymUnmanagedWriter2.
else if (riid == IID_ISymUnmanagedWriter2 )
*ppInterface = (ISymUnmanagedWriter2*)this;
*/
else if (riid == IID_ISymUnmanagedWriter3 )
*ppInterface = (ISymUnmanagedWriter3*)this;
else if (riid == IID_IUnknown)
*ppInterface = (IUnknown*)(ISymUnmanagedWriter*)this;
else
{
*ppInterface = NULL;
return E_NOINTERFACE;
}
AddRef();
return S_OK;
}
//-----------------------------------------------------------
// SymWriter Destructor
//-----------------------------------------------------------
SymWriter::~SymWriter()
{
// Note that this must be thread-safe - it may be invoked on the finalizer thread
// But since this dtor can only be invoked when all references have been released,
// no other threads can be manipulating the writer.
// Ideally we'd probably just add locking to all methods, but this is low-priority
// because diasymreader.dll isn't thread-safe and so we need to ensure the CLR's use
// of these interfaces are properly syncrhonized.
if ( !m_closed )
Close();
RELEASE(m_pIStream);
DELETE(m_pStringPool);
}
//-----------------------------------------------------------
// SymWriter Initialize the SymWriter
//-----------------------------------------------------------
COM_METHOD SymWriter::Initialize
(
IUnknown *emitter, // Emitter (IMetaData Emit/Import) - unused by ILDB
const WCHAR *szFilename, // FileName of the exe we're creating
IStream *pIStream, // Stream to store into
BOOL fFullBuild // Is this a full build or an incremental build
)
{
HRESULT hr = S_OK;
// Incremental compile not implemented in Rotor
_ASSERTE(fFullBuild);
if (emitter == NULL)
return E_INVALIDARG;
if (pIStream != NULL)
{
m_pIStream = pIStream;
pIStream->AddRef();
}
else
{
if (szFilename == NULL)
{
IfFailRet(E_INVALIDARG);
}
}
m_pStringPool = NEW(StgStringPool());
IfFailRet(m_pStringPool->InitNew());
if (szFilename != NULL)
{
wchar_t fullpath[_MAX_PATH];
wchar_t drive[_MAX_DRIVE];
wchar_t dir[_MAX_DIR];
wchar_t fname[_MAX_FNAME];
_wsplitpath_s( szFilename, drive, COUNTOF(drive), dir, COUNTOF(dir), fname, COUNTOF(fname), NULL, 0 );
_wmakepath_s( fullpath, COUNTOF(fullpath), drive, dir, fname, W("ildb") );
if (wcsncpy_s( m_szPath, COUNTOF(m_szPath), fullpath, _TRUNCATE) == STRUNCATE)
return HrFromWin32(ERROR_INSUFFICIENT_BUFFER);
}
// Note that we don't need the emitter - ILDB is agnostic to the module metadata.
return hr;
}
//-----------------------------------------------------------
// SymWriter Initialize2 the SymWriter
// Delegate to Initialize then use the szFullPathName param
//-----------------------------------------------------------
COM_METHOD SymWriter::Initialize2
(
IUnknown *emitter, // Emitter (IMetaData Emit/Import)
const WCHAR *szTempPath, // Location of the file
IStream *pIStream, // Stream to store into
BOOL fFullBuild, // Full build or not
const WCHAR *szFullPathName // Final destination of the ildb
)
{
HRESULT hr = S_OK;
IfFailGo( Initialize( emitter, szTempPath, pIStream, fFullBuild ) );
// We don't need the final location of the ildb
ErrExit:
return hr;
}
//-----------------------------------------------------------
// SymWriter GetorCreateDocument
// creates a new symbol document writer for a specified source
// Arguments:
// input: wcsUrl - The source file name
// output: ppRetVal - The new document writer
// Return Value: hr - S_OK if success, OOM otherwise
//-----------------------------------------------------------
HRESULT SymWriter::GetOrCreateDocument(
const WCHAR *wcsUrl, // Document name
const GUID *pLanguage, // What Language we're compiling
const GUID *pLanguageVendor, // What vendor
const GUID *pDocumentType, // Type
ISymUnmanagedDocumentWriter **ppRetVal // [out] Created DocumentWriter
)
{
ULONG UrlEntry;
DWORD strLength = WszWideCharToMultiByte(CP_UTF8, 0, wcsUrl, -1, 0, 0, 0, 0);
LPSTR multiByteURL = (LPSTR) new char [strLength+1];
HRESULT hr = S_OK;
if (multiByteURL == NULL)
{
return E_OUTOFMEMORY;
}
WszWideCharToMultiByte(CP_UTF8, 0, wcsUrl, -1, multiByteURL, strLength+1, 0, 0);
if (m_pStringPool->FindString(multiByteURL, &UrlEntry) == S_FALSE) // no file of that name has been seen before
{
hr = CreateDocument(wcsUrl, pLanguage, pLanguageVendor, pDocumentType, ppRetVal);
}
else // we already have a writer for this file
{
UINT32 docInfo = 0;
CRITSEC_COOKIE cs = ClrCreateCriticalSection(CrstLeafLock, CRST_DEFAULT);
ClrEnterCriticalSection(cs);
while ((docInfo < m_MethodInfo.m_documents.count()) && (m_MethodInfo.m_documents[docInfo].UrlEntry() != UrlEntry))
{
docInfo++;
}
if (docInfo == m_MethodInfo.m_documents.count()) // something went wrong and we didn't find the writer
{
hr = CreateDocument(wcsUrl, pLanguage, pLanguageVendor, pDocumentType, ppRetVal);
}
else
{
*ppRetVal = m_MethodInfo.m_documents[docInfo].DocumentWriter();
(*ppRetVal)->AddRef();
}
ClrLeaveCriticalSection(cs);
}
delete [] multiByteURL;
return hr;
} // SymWriter::GetOrCreateDocument
//-----------------------------------------------------------
// SymWriter CreateDocument
// creates a new symbol document writer for a specified source
// Arguments:
// input: wcsUrl - The source file name
// output: ppRetVal - The new document writer
// Return Value: hr - S_OK if success, OOM otherwise
//-----------------------------------------------------------
HRESULT SymWriter::CreateDocument(const WCHAR *wcsUrl, // Document name
const GUID *pLanguage, // What Language we're compiling
const GUID *pLanguageVendor, // What vendor
const GUID *pDocumentType, // Type
ISymUnmanagedDocumentWriter **ppRetVal // [out] Created DocumentWriter
)
{
DocumentInfo* pDocument = NULL;
SymDocumentWriter *sdw = NULL;
UINT32 DocumentEntry;
ULONG UrlEntry;
HRESULT hr = NOERROR;
DocumentEntry = m_MethodInfo.m_documents.count();
IfNullGo(pDocument = m_MethodInfo.m_documents.next());
memset(pDocument, 0, sizeof(DocumentInfo));
// Create the new document writer.
sdw = NEW(SymDocumentWriter(DocumentEntry, this));
IfNullGo(sdw);
pDocument->SetLanguage(*pLanguage);
pDocument->SetLanguageVendor(*pLanguageVendor);
pDocument->SetDocumentType(*pDocumentType);
pDocument->SetDocumentWriter(sdw);
// stack check needed to call back into utilcode
BEGIN_SO_INTOLERANT_CODE_NO_THROW_CHECK_THREAD_FORCE_SO();
hr = m_pStringPool->AddStringW(wcsUrl, (UINT32 *)&UrlEntry);
END_SO_INTOLERANT_CODE;
IfFailGo(hr);
pDocument->SetUrlEntry(UrlEntry);
// Pass out the new ISymUnmanagedDocumentWriter.
sdw->AddRef();
*ppRetVal = (ISymUnmanagedDocumentWriter*)sdw;
sdw = NULL;
ErrExit:
DELETE(sdw);
return hr;
}
//-----------------------------------------------------------
// SymWriter DefineDocument
//-----------------------------------------------------------
COM_METHOD SymWriter::DefineDocument(
const WCHAR *wcsUrl, // Document name
const GUID *pLanguage, // What Language we're compiling
const GUID *pLanguageVendor, // What vendor
const GUID *pDocumentType, // Type
ISymUnmanagedDocumentWriter **ppRetVal // [out] Created DocumentWriter
)
{
HRESULT hr = NOERROR;
IfFalseGo(wcsUrl, E_INVALIDARG);
IfFalseGo(pLanguage, E_INVALIDARG);
IfFalseGo(pLanguageVendor, E_INVALIDARG);
IfFalseGo(pDocumentType, E_INVALIDARG);
IfFalseGo(ppRetVal, E_INVALIDARG);
// Init out parameter
*ppRetVal = NULL;
hr = GetOrCreateDocument(wcsUrl, pLanguage, pLanguageVendor, pDocumentType, ppRetVal);
ErrExit:
return hr;
}
//-----------------------------------------------------------
// SymWriter SetDocumentSrc
//-----------------------------------------------------------
HRESULT SymWriter::SetDocumentSrc(
UINT32 DocumentEntry,
DWORD SourceSize,
BYTE* pSource
)
{
DocumentInfo* pDocument = NULL;
HRESULT hr = S_OK;
IfFalseGo( SourceSize == 0 || pSource, E_INVALIDARG);
IfFalseGo( DocumentEntry < m_MethodInfo.m_documents.count(), E_INVALIDARG);
pDocument = &m_MethodInfo.m_documents[DocumentEntry];
if (pSource)
{
UINT32 i;
IfFalseGo( m_MethodInfo.m_bytes.grab(SourceSize, &i), E_OUTOFMEMORY);
memcpy(&m_MethodInfo.m_bytes[i], pSource, SourceSize);
pDocument->SetSourceEntry(i);
pDocument->SetSourceSize(SourceSize);
}
ErrExit:
return hr;
}
//-----------------------------------------------------------
// SymWriter SetDocumentCheckSum
//-----------------------------------------------------------
HRESULT SymWriter::SetDocumentCheckSum(
UINT32 DocumentEntry,
GUID AlgorithmId,
DWORD CheckSumSize,
BYTE* pCheckSum
)
{
DocumentInfo* pDocument = NULL;
HRESULT hr = S_OK;
IfFalseGo( CheckSumSize == 0 || pCheckSum, E_INVALIDARG);
IfFalseGo( DocumentEntry < m_MethodInfo.m_documents.count(), E_INVALIDARG);
pDocument = &m_MethodInfo.m_documents[DocumentEntry];
if (pCheckSum)
{
UINT32 i;
IfFalseGo( m_MethodInfo.m_bytes.grab(CheckSumSize, &i), E_OUTOFMEMORY);
memcpy(&m_MethodInfo.m_bytes[i], pCheckSum, CheckSumSize);
pDocument->SetCheckSumEntry(i);
pDocument->SetCheckSymSize(CheckSumSize);
}
pDocument->SetAlgorithmId(AlgorithmId);
ErrExit:
return hr;
}
//-----------------------------------------------------------
// SymWriter SetUserEntryPoint
//-----------------------------------------------------------
COM_METHOD SymWriter::SetUserEntryPoint(mdMethodDef entryMethod)
{
HRESULT hr = S_OK;
// Make sure that an entry point hasn't already been set.
if (ModuleLevelInfo.m_userEntryPoint == 0)
ModuleLevelInfo.m_userEntryPoint = entryMethod;
return hr;
}
//-----------------------------------------------------------
// SymWriter OpenMethod
// Get ready to get information about a new method
//-----------------------------------------------------------
COM_METHOD SymWriter::OpenMethod(mdMethodDef method)
{
HRESULT hr = S_OK;
// We can only have one open method at a time.
if (m_openMethodToken != mdMethodDefNil)
return E_INVALIDARG;
m_LargestMethodToken = max(method, m_LargestMethodToken);
if (m_LargestMethodToken != method)
{
m_sortMethodEntries = true;
// Check to see if we're trying to open a method we've already done
unsigned i;
for (i = 0; i < m_MethodInfo.m_methods.count(); i++)
{
if (m_MethodInfo.m_methods[i].MethodToken() == method)
{
return E_INVALIDARG;
}
}
}
// Remember the token for this method.
m_openMethodToken = method;
IfNullGo( m_pmethod = m_MethodInfo.m_methods.next() );
m_pmethod->SetMethodToken(m_openMethodToken);
m_pmethod->SetStartScopes(m_MethodInfo.m_scopes.count());
m_pmethod->SetStartVars(m_MethodInfo.m_vars.count());
m_pmethod->SetStartUsing(m_MethodInfo.m_usings.count());
m_pmethod->SetStartConstant(m_MethodInfo.m_constants.count());
m_pmethod->SetStartDocuments(m_MethodInfo.m_documents.count());
m_pmethod->SetStartSequencePoints(m_MethodInfo.m_auxSequencePoints.count());
// By default assume the lines are inserted in the correct order
m_sortLines = false;
// Initialize the maximum scope end offset for this method
m_maxScopeEnd = 1;
// Open the implicit root scope for the method
_ASSERTE(m_currentScope == k_noScope);
IfFailRet(OpenScope(0, NULL));
_ASSERTE(m_currentScope != k_noScope);
ErrExit:
return hr;
}
COM_METHOD SymWriter::OpenMethod2(
mdMethodDef method,
ULONG32 isect,
ULONG32 offset)
{
// This symbol writer doesn't support section offsets
_ASSERTE(FALSE);
return E_NOTIMPL;
}
//-----------------------------------------------------------
// compareAuxLines
// Used to sort SequencePoint
//-----------------------------------------------------------
int __cdecl SequencePoint::compareAuxLines(const void *elem1, const void *elem2 )
{
SequencePoint* p1 = (SequencePoint*)elem1;
SequencePoint* p2 = (SequencePoint*)elem2;
return p1->Offset() - p2->Offset();
}
//-----------------------------------------------------------
// SymWriter CloseMethod
// We're done with this function, write it out.
//-----------------------------------------------------------
COM_METHOD SymWriter::CloseMethod()
{
HRESULT hr = S_OK;
UINT32 CountOfSequencePoints;
// Must have an open method.
if (m_openMethodToken == mdMethodDefNil)
return E_UNEXPECTED;
// All scopes up to the root must have been closed (and the root must not have been closed).
_ASSERTE(m_currentScope != k_noScope);
if (m_MethodInfo.m_scopes[m_currentScope].ParentScope() != k_noScope)
return E_FAIL;
// Close the implicit root scope using the largest end offset we've seen in this method, or 1 if none.
IfFailRet(CloseScopeInternal(m_maxScopeEnd));
m_pmethod->SetEndScopes(m_MethodInfo.m_scopes.count());
m_pmethod->SetEndVars(m_MethodInfo.m_vars.count());
m_pmethod->SetEndUsing(m_MethodInfo.m_usings.count());
m_pmethod->SetEndConstant(m_MethodInfo.m_constants.count());
m_pmethod->SetEndDocuments(m_MethodInfo.m_documents.count());
m_pmethod->SetEndSequencePoints(m_MethodInfo.m_auxSequencePoints.count());
CountOfSequencePoints = m_pmethod->EndSequencePoints() - m_pmethod->StartSequencePoints();
// Write any sequence points.
if (CountOfSequencePoints > 0 ) {
// sort the sequence points
if ( m_sortLines )
{
qsort(&m_MethodInfo.m_auxSequencePoints[m_pmethod->StartSequencePoints()],
CountOfSequencePoints,
sizeof( SequencePoint ),
SequencePoint::compareAuxLines );
}
}
// All done with this method.
m_openMethodToken = mdMethodDefNil;
return hr;
}
//-----------------------------------------------------------
// SymWriter DefineSequencePoints
// Define the sequence points for this function
//-----------------------------------------------------------
COM_METHOD SymWriter::DefineSequencePoints(
ISymUnmanagedDocumentWriter *document, //
ULONG32 spCount, // Count of sequence points
ULONG32 offsets[], // Offsets
ULONG32 lines[], // Beginning Lines
ULONG32 columns[], // [optional] Columns
ULONG32 endLines[], // [optional] End Lines
ULONG32 endColumns[] // [optional] End Columns
)
{
HRESULT hr = S_OK;
DWORD docnum;
// We must have a document, offsets, and lines.
IfFalseGo(document && offsets && lines, E_INVALIDARG);
// Must have some sequence points
IfFalseGo(spCount != 0, E_INVALIDARG);
// Must have an open method.
IfFalseGo(m_openMethodToken != mdMethodDefNil, E_INVALIDARG);
// Remember that we've loaded the sequence points and
// which document they were for.
docnum = (DWORD)((SymDocumentWriter *)document)->GetDocumentEntry();;
// if sets of lines have been inserted out-of-order, remember to sort when emitting
if ( m_MethodInfo.m_auxSequencePoints.count() > 0 && m_MethodInfo.m_auxSequencePoints[ m_MethodInfo.m_auxSequencePoints.count()-1 ].Offset() > offsets[0] )
m_sortLines = true;
// Copy the incomming arrays into the internal format.
for ( UINT32 i = 0; i < spCount; i++)
{
SequencePoint * paux;
IfNullGo(paux = m_MethodInfo.m_auxSequencePoints.next());
paux->SetOffset(offsets[i]);
paux->SetStartLine(lines[i]);
paux->SetStartColumn(columns ? columns[i] : 0);
// If no endLines specified, assume same as start
paux->SetEndLine(endLines ? endLines[i] : lines[i]);
paux->SetEndColumn(endColumns ? endColumns[i]: 0);
paux->SetDocument(docnum);
}
ErrExit:
return hr;
}
//-----------------------------------------------------------
// SymWriter OpenScope
// Open a new scope for this function
//-----------------------------------------------------------
COM_METHOD SymWriter::OpenScope(ULONG32 startOffset, ULONG32 *scopeID)
{
HRESULT hr = S_OK;
// Make sure the startOffset is within the current scope.
if ((m_currentScope != k_noScope) &&
(unsigned int)startOffset < m_MethodInfo.m_scopes[m_currentScope].StartOffset())
return E_INVALIDARG;
// Fill in the new scope.
UINT32 newScope = m_MethodInfo.m_scopes.count();
// Make sure that adding 1 below won't overflow (although "next" should fail much
// sooner if we were anywhere near close enough).
if (newScope >= UINT_MAX)
return E_UNEXPECTED;
SymLexicalScope *sc;
IfNullGo( sc = m_MethodInfo.m_scopes.next());
sc->SetParentScope(m_currentScope); // parent is the current scope.
sc->SetStartOffset(startOffset);
sc->SetHasChildren(FALSE);
sc->SetHasVars(FALSE);
sc->SetEndOffset(0);
// The current scope has a child now.
if (m_currentScope != k_noScope)
m_MethodInfo.m_scopes[m_currentScope].SetHasChildren(TRUE);
// The new scope is now the current scope.
m_currentScope = newScope;
_ASSERTE(m_currentScope != k_noScope);
// Pass out the "scope id", which is a _1_ based id for the scope.
if (scopeID)
*scopeID = m_currentScope + 1;
ErrExit:
return hr;
}
//-----------------------------------------------------------
// SymWriter CloseScope
//-----------------------------------------------------------
COM_METHOD SymWriter::CloseScope(
ULONG32 endOffset // Closing offset of scope
)
{
// This API can only be used to close explicit user scopes.
// The implicit root scope is only closed internally by CloseMethod.
if ((m_currentScope == k_noScope) || (m_MethodInfo.m_scopes[m_currentScope].ParentScope() == k_noScope))
return E_FAIL;
HRESULT hr = CloseScopeInternal(endOffset);
_ASSERTE(m_currentScope != k_noScope);
return hr;
}
//-----------------------------------------------------------
// CloseScopeInternal
// Implementation for ISymUnmanagedWriter::CloseScope but can be called even to
// close the implicit root scope.
//-----------------------------------------------------------
COM_METHOD SymWriter::CloseScopeInternal(
ULONG32 endOffset // Closing offset of scope
)
{
_ASSERTE(m_currentScope != k_noScope);
// Capture the end offset
m_MethodInfo.m_scopes[m_currentScope].SetEndOffset(endOffset);
// The current scope is now the parent scope.
m_currentScope = m_MethodInfo.m_scopes[m_currentScope].ParentScope();
// Update the maximum scope end offset for this method
if (endOffset > m_maxScopeEnd)
m_maxScopeEnd = endOffset;
return S_OK;
}
//-----------------------------------------------------------
// SymWriter SetScopeRange
// Set the Start/End Offset for this scope
//-----------------------------------------------------------
COM_METHOD SymWriter::SetScopeRange(
ULONG32 scopeID, // ID for the scope
ULONG32 startOffset, // Start Offset
ULONG32 endOffset // End Offset
)
{
if (scopeID <= 0)
return E_INVALIDARG;
if (scopeID > m_MethodInfo.m_scopes.count() )
return E_INVALIDARG;
// Remember the new start and end offsets. Also remember that the
// scopeID is _1_ based!!!
SymLexicalScope *sc = &(m_MethodInfo.m_scopes[scopeID - 1]);
sc->SetStartOffset(startOffset);
sc->SetEndOffset(endOffset);
// Update the maximum scope end offset for this method
if (endOffset > m_maxScopeEnd)
m_maxScopeEnd = endOffset;
return S_OK;
}
//-----------------------------------------------------------
// SymWriter DefineLocalVariable
//-----------------------------------------------------------
COM_METHOD SymWriter::DefineLocalVariable(
const WCHAR *name, // Name of the variable
ULONG32 attributes, // Attributes for the var
ULONG32 cSig, // Signature for the variable
BYTE signature[],
ULONG32 addrKind,
ULONG32 addr1, ULONG32 addr2, ULONG32 addr3,
ULONG32 startOffset, ULONG32 endOffset)
{
HRESULT hr = S_OK;
ULONG NameEntry;
// We must have a current scope.
if (m_currentScope == k_noScope)
return E_FAIL;
// We must have a name and a signature.
if (!name || !signature)
return E_INVALIDARG;
if (cSig == 0)
return E_INVALIDARG;
// Make a new local variable and copy the data.
SymVariable *var;
IfNullGo( var = m_MethodInfo.m_vars.next());
var->SetIsParam(FALSE);
var->SetAttributes(attributes);
var->SetAddrKind(addrKind);
var->SetIsHidden(attributes & VAR_IS_COMP_GEN);
var->SetAddr1(addr1);
var->SetAddr2(addr2);
var->SetAddr3(addr3);
// Length of the sig?
ULONG32 sigLen;
sigLen = cSig;
// stack check needed to call back into utilcode
BEGIN_SO_INTOLERANT_CODE_NO_THROW_CHECK_THREAD_FORCE_SO();
// Copy the name.
hr = m_pStringPool->AddStringW(name, (UINT32 *)&NameEntry);
END_SO_INTOLERANT_CODE;
IfFailGo(hr);
var->SetName(NameEntry);
// Copy the signature
// Note that we give this back exactly as-is, but callers typically remove any calling
// convention prefix.
UINT32 i;
IfFalseGo(m_MethodInfo.m_bytes.grab(sigLen, &i), E_OUTOFMEMORY);
memcpy(&m_MethodInfo.m_bytes[i], signature, sigLen);
var->SetSignature(i);
var->SetSignatureSize(sigLen);
// This var is in the current scope
var->SetScope(m_currentScope);
m_MethodInfo.m_scopes[m_currentScope].SetHasVars(TRUE);
var->SetStartOffset(startOffset);
var->SetEndOffset(endOffset);
ErrExit:
return hr;
}
COM_METHOD SymWriter::DefineLocalVariable2(
const WCHAR *name,
ULONG32 attributes,
mdSignature sigToken,
ULONG32 addrKind,
ULONG32 addr1, ULONG32 addr2, ULONG32 addr3,
ULONG32 startOffset, ULONG32 endOffset)
{
// This symbol writer doesn't support definiting signatures via tokens
_ASSERTE(FALSE);
return E_NOTIMPL;
}
//-----------------------------------------------------------
// SymWriter DefineParameter
//-----------------------------------------------------------
COM_METHOD SymWriter::DefineParameter(
const WCHAR *name, // Param name
ULONG32 attributes, // Attribute for the parameter
ULONG32 sequence,
ULONG32 addrKind,
ULONG32 addr1, ULONG32 addr2, ULONG32 addr3)
{
HRESULT hr = S_OK;
ULONG NameEntry;
// We must have a method.
if (m_openMethodToken == mdMethodDefNil)
return E_INVALIDARG;
// We must have a name.
if (!name)
return E_INVALIDARG;
SymVariable *var;
IfNullGo( var = m_MethodInfo.m_vars.next());
var->SetIsParam(TRUE);
var->SetAttributes(attributes);
var->SetAddrKind(addrKind);
var->SetIsHidden(attributes & VAR_IS_COMP_GEN);
var->SetAddr1(addr1);
var->SetAddr2(addr2);
var->SetAddr3(addr3);
var->SetSequence(sequence);
// stack check needed to call back into utilcode
BEGIN_SO_INTOLERANT_CODE_NO_THROW_CHECK_THREAD_FORCE_SO();
// Copy the name.
hr = m_pStringPool->AddStringW(name, (UINT32 *)&NameEntry);
END_SO_INTOLERANT_CODE;
IfFailGo(hr);
var->SetName(NameEntry);
// This var is in the current scope
if (m_currentScope != k_noScope)
m_MethodInfo.m_scopes[m_currentScope].SetHasVars(TRUE);
var->SetStartOffset(0);
var->SetEndOffset(0);
ErrExit:
return hr;
}
//-----------------------------------------------------------
// verifyConstTypes
// Verify that the type is a type we support
//-----------------------------------------------------------
static bool verifyConstTypes( DWORD vt )
{
switch ( vt ) {
case VT_UI8:
case VT_I8:
case VT_I4:
case VT_UI1: // value < LF_NUMERIC
case VT_I2:
case VT_R4:
case VT_R8:
case VT_BOOL: // value < LF_NUMERIC
case VT_DATE:
case VT_BSTR:
case VT_I1:
case VT_UI2:
case VT_UI4:
case VT_INT:
case VT_UINT:
case VT_DECIMAL:
return true;
}
return false;
}
//-----------------------------------------------------------
// SymWriter DefineConstant
//-----------------------------------------------------------
COM_METHOD SymWriter::DefineConstant(
const WCHAR __RPC_FAR *name,
VARIANT value,
ULONG32 cSig,
unsigned char __RPC_FAR signature[])
{
HRESULT hr = S_OK;
ULONG ValueBstr = 0;
ULONG Name;
// currently we only support local constants
// We must have a method.
if (m_openMethodToken == mdMethodDefNil)
return E_INVALIDARG;
// We must have a name and signature.
IfFalseGo(name, E_INVALIDARG);
IfFalseGo(signature, E_INVALIDARG);
IfFalseGo(cSig > 0, E_INVALIDARG);
//
// Support byref decimal values
//
if ( (V_VT(&value)) == ( VT_BYREF | VT_DECIMAL ) ) {
if ( V_DECIMALREF(&value) == NULL )
return E_INVALIDARG;
V_DECIMAL(&value) = *V_DECIMALREF(&value);
V_VT(&value) = VT_DECIMAL;
}
// we only support non-ref constants
if ( ( V_VT(&value) & VT_BYREF ) != 0 )
return E_INVALIDARG;
if ( !verifyConstTypes( V_VT(&value) ) )
return E_INVALIDARG;
// If it's a BSTR, we need to persist the Bstr as an entry into
// the stringpool
if (V_VT(&value) == VT_BSTR)
{
// stack check needed to call back into utilcode
BEGIN_SO_INTOLERANT_CODE_NO_THROW_CHECK_THREAD_FORCE_SO();
// Copy the bstrValue.
hr = m_pStringPool->AddStringW(V_BSTR(&value), (UINT32 *)&ValueBstr);
END_SO_INTOLERANT_CODE;
IfFailGo(hr);
V_BSTR(&value) = NULL;
}
SymConstant *con;
IfNullGo( con = m_MethodInfo.m_constants.next());
con->SetValue(value, ValueBstr);
// stack check needed to call back into utilcode
BEGIN_SO_INTOLERANT_CODE_NO_THROW_CHECK_THREAD_FORCE_SO();
// Copy the name.
hr = m_pStringPool->AddStringW(name, (UINT32 *)&Name);
END_SO_INTOLERANT_CODE;
IfFailGo(hr);
con->SetName(Name);
// Copy the signature
UINT32 i;
IfFalseGo(m_MethodInfo.m_bytes.grab(cSig, &i), E_OUTOFMEMORY);
memcpy(&m_MethodInfo.m_bytes[i], signature, cSig);
con->SetSignature(i);
con->SetSignatureSize(cSig);
// This const is in the current scope
con->SetParentScope(m_currentScope);
m_MethodInfo.m_scopes[m_currentScope].SetHasVars(TRUE);
ErrExit:
return hr;
}
COM_METHOD SymWriter::DefineConstant2(
const WCHAR *name,
VARIANT value,
mdSignature sigToken)
{
// This symbol writer doesn't support definiting signatures via tokens
_ASSERTE(FALSE);
return E_NOTIMPL;
}
//-----------------------------------------------------------
// SymWriter Abort
//-----------------------------------------------------------
COM_METHOD SymWriter::Abort(void)
{
m_closed = true;
return S_OK;
}
//-----------------------------------------------------------
// SymWriter DefineField
//-----------------------------------------------------------
COM_METHOD SymWriter::DefineField(
mdTypeDef parent,
const WCHAR *name,
ULONG32 attributes,
ULONG32 csig,
BYTE signature[],
ULONG32 addrKind,
ULONG32 addr1, ULONG32 addr2, ULONG32 addr3)
{
// This symbol store doesn't support extra random variable
// definitions.
return S_OK;
}
//-----------------------------------------------------------
// SymWriter DefineGlobalVariable
//-----------------------------------------------------------
COM_METHOD SymWriter::DefineGlobalVariable(
const WCHAR *name,
ULONG32 attributes,
ULONG32 csig,
BYTE signature[],
ULONG32 addrKind,
ULONG32 addr1, ULONG32 addr2, ULONG32 addr3)
{
// This symbol writer doesn't support global variables
_ASSERTE(FALSE);
return E_NOTIMPL;
}
COM_METHOD SymWriter::DefineGlobalVariable2(
const WCHAR *name,
ULONG32 attributes,
mdSignature sigToken,
ULONG32 addrKind,
ULONG32 addr1, ULONG32 addr2, ULONG32 addr3)
{
// This symbol writer doesn't support global variables
_ASSERTE(FALSE);
return E_NOTIMPL;
}
//-----------------------------------------------------------
// compareMethods
// Used to sort method entries
//-----------------------------------------------------------
int __cdecl SymMethodInfo::compareMethods(const void *elem1, const void *elem2 )
{
SymMethodInfo* p1 = (SymMethodInfo*)elem1;
SymMethodInfo* p2 = (SymMethodInfo*)elem2;
return p1->MethodToken() - p2->MethodToken();
}
//-----------------------------------------------------------
// SymWriter Close
//-----------------------------------------------------------
COM_METHOD SymWriter::Close()
{
HRESULT hr = Commit();
m_closed = true;
for (UINT32 docInfo = 0; docInfo < m_MethodInfo.m_documents.count(); docInfo++)
{
m_MethodInfo.m_documents[docInfo].SetDocumentWriter(NULL);
}
return hr;
}
//-----------------------------------------------------------
// SymWriter Commit
//-----------------------------------------------------------
COM_METHOD SymWriter::Commit(void)
{
// Sort the entries if need be
if (m_sortMethodEntries)
{
// First remap any tokens we need to
if (m_MethodMap.count())
{
unsigned i;
for (i = 0; i< m_MethodMap.count(); i++)
{
m_MethodInfo.m_methods[m_MethodMap[i].MethodEntry].SetMethodToken(m_MethodMap[i].m_MethodToken);
}
}
// Now sort the array
qsort(&m_MethodInfo.m_methods[0],
m_MethodInfo.m_methods.count(),
sizeof( SymMethodInfo ),
SymMethodInfo::compareMethods );
m_sortMethodEntries = false;
}
return WritePDB();
}
//-----------------------------------------------------------
// SymWriter SetSymAttribute
//-----------------------------------------------------------
COM_METHOD SymWriter::SetSymAttribute(
mdToken parent,
const WCHAR *name,
ULONG32 cData,
BYTE data[])
{
// Setting attributes on the symbol isn't supported
// ROTORTODO: #156785 in PS
return S_OK;
}
//-----------------------------------------------------------
// SymWriter OpenNamespace
//-----------------------------------------------------------
COM_METHOD SymWriter::OpenNamespace(const WCHAR *name)
{
// This symbol store doesn't support namespaces.
return E_NOTIMPL;
}
//-----------------------------------------------------------
// SymWriter OpenNamespace
//-----------------------------------------------------------
COM_METHOD SymWriter::CloseNamespace()
{
// This symbol store doesn't support namespaces.
return S_OK;
}
//-----------------------------------------------------------
// SymWriter UsingNamespace
// Add a Namespace to the list of namespace for this method
//-----------------------------------------------------------
COM_METHOD SymWriter::UsingNamespace(const WCHAR *fullName)
{
HRESULT hr = S_OK;
ULONG Name;
// We must have a current scope.
if (m_currentScope == k_noScope)
return E_FAIL;
// We must have a name.
if (!fullName)
return E_INVALIDARG;
SymUsingNamespace *use;
IfNullGo( use = m_MethodInfo.m_usings.next());
// stack check needed to call back into utilcode
BEGIN_SO_INTOLERANT_CODE_NO_THROW_CHECK_THREAD_FORCE_SO();
// Copy the name.
hr = m_pStringPool->AddStringW(fullName, (UINT32 *)&Name);
END_SO_INTOLERANT_CODE;
IfFailGo(hr);
use->SetName(Name);
use->SetParentScope(m_currentScope);
ErrExit:
return hr;
}
//-----------------------------------------------------------
// SymWriter SetMethodSourceRange
//-----------------------------------------------------------
COM_METHOD SymWriter::SetMethodSourceRange(
ISymUnmanagedDocumentWriter *startDoc,
ULONG32 startLine,
ULONG32 startColumn,
ISymUnmanagedDocumentWriter *endDoc,
ULONG32 endLine,
ULONG32 endColumn)
{
// This symbol store doesn't support source ranges.
return E_NOTIMPL;
}
//-----------------------------------------------------------
// UnicodeToUTF8
// Translate the Unicode string to a UTF8 string
// Return the length in UTF8 of the Unicode string
// Including NULL terminator
//-----------------------------------------------------------
inline int WINAPI UnicodeToUTF8(
LPCWSTR pUni, // Unicode string
__out_bcount_opt(cbUTF) PSTR pUTF8, // [optional, out] Buffer for UTF8 string
int cbUTF // length of UTF8 buffer
)
{
// Pass in the length including the NULL terminator
int cchSrc = (int)wcslen(pUni)+1;
return WideCharToMultiByte(CP_UTF8, 0, pUni, cchSrc, pUTF8, cbUTF, NULL, NULL);
}
//-----------------------------------------------------------
// SymWriter GetDebugCVInfo
// Get the size and potentially the debug info
//-----------------------------------------------------------
COM_METHOD SymWriter::GetDebugCVInfo(
DWORD cbBuf, // [optional] Size of buf
DWORD *pcbBuf, // [out] Size needed for the DebugInfo
BYTE buf[]) // [optional, out] Buffer for DebugInfo
{
if ( m_szPath == NULL || *m_szPath == 0 )
return E_UNEXPECTED;
// We need to change the .ildb extension to .pdb to be
// compatible with VS7
wchar_t fullpath[_MAX_PATH];
wchar_t drive[_MAX_DRIVE];
wchar_t dir[_MAX_DIR];
wchar_t fname[_MAX_FNAME];
if (_wsplitpath_s( m_szPath, drive, COUNTOF(drive), dir, COUNTOF(dir), fname, COUNTOF(fname), NULL, 0 ))
return E_FAIL;
if (_wmakepath_s( fullpath, COUNTOF(fullpath), drive, dir, fname, W("pdb") ))
return E_FAIL;
// Get UTF-8 string size, including the Null Terminator
int Utf8Length = UnicodeToUTF8( fullpath, NULL, 0 );
if (Utf8Length < 0 )
return HRESULT_FROM_GetLastError();
DWORD dwSize = sizeof(RSDSI) + DWORD(Utf8Length);
// If the caller is just checking for the size
if ( cbBuf == 0 && pcbBuf != NULL )
{
*pcbBuf = dwSize;
return S_OK;
}
if (cbBuf < dwSize)
{
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
}
if ( buf == NULL )
{
return E_INVALIDARG;
}
RSDSI* pRsdsi = (RSDSI*)buf;
pRsdsi->dwSig = VAL32(0x53445352); // "SDSR";
pRsdsi->guidSig = ILDB_VERSION_GUID;
SwapGuid(&(pRsdsi->guidSig));
// Age of 0 represent VC6.0 format so make sure it's 1
pRsdsi->age = VAL32(1);
UnicodeToUTF8( fullpath, pRsdsi->szPDB, Utf8Length );
if ( pcbBuf )
*pcbBuf = dwSize;
return S_OK;
}
//-----------------------------------------------------------
// SymWriter GetDebugInfo
// Get the size and potentially the debug info
//-----------------------------------------------------------
COM_METHOD SymWriter::GetDebugInfo(
IMAGE_DEBUG_DIRECTORY *pIDD, // [out] IDD to fill in
DWORD cData, // [optional] size of data
DWORD *pcData, // [optional, out] return needed size for DebugInfo
BYTE data[]) // [optional] Buffer to store into
{
HRESULT hr = S_OK;
if ( cData == 0 && pcData != NULL )
{
// just checking for the size
return GetDebugCVInfo( 0, pcData, NULL );
}
if ( pIDD == NULL )
return E_INVALIDARG;
DWORD cTheData = 0;
IfFailGo( GetDebugCVInfo( cData, &cTheData, data ) );
memset( pIDD, 0, sizeof( *pIDD ) );
pIDD->Type = VAL32(IMAGE_DEBUG_TYPE_CODEVIEW);
pIDD->SizeOfData = VAL32(cTheData);
if ( pcData ) {
*pcData = cTheData;
}
ErrExit:
return hr;
}
COM_METHOD SymWriter::RemapToken(mdToken oldToken, mdToken newToken)
{
HRESULT hr = NOERROR;
if (oldToken != newToken)
{
// We only care about methods
if ((TypeFromToken(oldToken) == mdtMethodDef) ||
(TypeFromToken(newToken) == mdtMethodDef))
{
// Make sure they are both methods
_ASSERTE(TypeFromToken(newToken) == mdtMethodDef);
_ASSERTE(TypeFromToken(oldToken) == mdtMethodDef);
// Make sure we sort before saving
m_sortMethodEntries = true;
// Check to see if we're trying to map a token we know about
unsigned i;
for (i = 0; i < m_MethodInfo.m_methods.count(); i++)
{
if (m_MethodInfo.m_methods[i].MethodToken() == oldToken)
{
// Remember the map, we need to actually do the actual
// mapping later because we might already have a function
// with a token 'newToken'
SymMap *pMethodMap;
IfNullGo( pMethodMap = m_MethodMap.next() );
pMethodMap->m_MethodToken = newToken;
pMethodMap->MethodEntry = i;
break;
}
}
}
}
ErrExit:
return hr;
}
//-----------------------------------------------------------
// SymWriter Write
// Write the information to a file or to a stream
//-----------------------------------------------------------
COM_METHOD SymWriter::Write(void *pData, DWORD SizeOfData)
{
HRESULT hr = NOERROR;
DWORD NumberOfBytesWritten = 0;
if (m_pIStream)
{
IfFailGo(m_pIStream->Write(pData,
SizeOfData,
&NumberOfBytesWritten));
}
else
{
// Write out a signature to recognize that we're an ildb
if (!WriteFile(m_hFile, pData, SizeOfData, &NumberOfBytesWritten, NULL))
return HrFromWin32(GetLastError());
}
_ASSERTE(NumberOfBytesWritten == SizeOfData);
ErrExit:
return hr;
}
//-----------------------------------------------------------
// SymWriter WriteStringPool
// Write the information to a file or to a stream
//-----------------------------------------------------------
COM_METHOD SymWriter::WriteStringPool()
{
IStream *pIStream = NULL;
BYTE *pStreamMem = NULL;
HRESULT hr = NOERROR;
if (m_pIStream)
{
IfFailGo(m_pStringPool->PersistToStream(m_pIStream));
}
else
{
LARGE_INTEGER disp = { {0, 0} };
DWORD NumberOfBytes;
DWORD SizeOfData;
STATSTG statStg;
IfFailGo(CreateStreamOnHGlobal(NULL,
TRUE,
&pIStream));
IfFailGo(m_pStringPool->PersistToStream(pIStream));
IfFailGo(pIStream->Stat(&statStg, STATFLAG_NONAME));
SizeOfData = statStg.cbSize.u.LowPart;
IfFailGo(pIStream->Seek(disp, STREAM_SEEK_SET, NULL));
pStreamMem = NEW(BYTE[SizeOfData]);
IfFailGo(pIStream->Read(pStreamMem, SizeOfData, &NumberOfBytes));
if (!WriteFile(m_hFile, pStreamMem, SizeOfData, &NumberOfBytes, NULL))
return HrFromWin32(GetLastError());
_ASSERTE(NumberOfBytes == SizeOfData);
}
ErrExit:
RELEASE(pIStream);
DELETEARRAY(pStreamMem);
return hr;
}
//-----------------------------------------------------------
// SymWriter WritePDB
// Write the PDB information to a file or to a stream
//-----------------------------------------------------------
COM_METHOD SymWriter::WritePDB()
{
HRESULT hr = NOERROR;
GUID ildb_guid = ILDB_VERSION_GUID;
// Make sure the ModuleLevelInfo is set
ModuleLevelInfo.m_CountOfVars = VAL32(m_MethodInfo.m_vars.count());
ModuleLevelInfo.m_CountOfBytes = VAL32(m_MethodInfo.m_bytes.count());
ModuleLevelInfo.m_CountOfUsing = VAL32(m_MethodInfo.m_usings.count());
ModuleLevelInfo.m_CountOfScopes = VAL32(m_MethodInfo.m_scopes.count());
ModuleLevelInfo.m_CountOfMethods = VAL32(m_MethodInfo.m_methods.count());
if (m_pStringPool)
{
DWORD dwSaveSize;
IfFailGo(m_pStringPool->GetSaveSize((UINT32 *)&dwSaveSize));
ModuleLevelInfo.m_CountOfStringBytes = VAL32(dwSaveSize);
}
else
{
ModuleLevelInfo.m_CountOfStringBytes = 0;
}
ModuleLevelInfo.m_CountOfConstants = VAL32(m_MethodInfo.m_constants.count());
ModuleLevelInfo.m_CountOfDocuments = VAL32(m_MethodInfo.m_documents.count());
ModuleLevelInfo.m_CountOfSequencePoints = VAL32(m_MethodInfo.m_auxSequencePoints.count());
// Open the file
if (m_pIStream == NULL)
{
// We need to open the output file.
m_hFile = WszCreateFile(m_szPath,
GENERIC_WRITE,
0,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (m_hFile == INVALID_HANDLE_VALUE)
{
IfFailGo(HrFromWin32(GetLastError()));
}
}
else
{
// We're writing to a stream. Make sure we're at the beginning
// (eg. if this is being called more than once).
// Note that technically we should probably call SetSize to truncate the
// stream to ensure we don't leave reminants of the previous contents
// at the end of the new stream. But with our current CGrowableStream
// implementation, this would have a big performance impact (causing us to
// do linear growth and lots of reallocations at every write). We only
// ever add data to a symbol writer (don't remove anything), and so subsequent
// streams should always get larger. Regardless, ILDB supports trailing garbage
// without a problem (we used to always have the remainder of a page at the end
// of the stream), and so this is not an issue of correctness.
LARGE_INTEGER pos0;
pos0.QuadPart = 0;
IfFailGo(m_pIStream->Seek(pos0, STREAM_SEEK_SET, NULL));
}
#if _DEBUG
// We need to make sure the Variant entry in the constants is 8 byte
// aligned so make sure everything up to the there is aligned correctly
if ((ILDB_SIGNATURE_SIZE % 8) ||
(sizeof(PDBInfo) % 8) ||
(sizeof(GUID) % 8))
{
_ASSERTE(!"We need to safe the data in an aligned format");
}
#endif
// Write out a signature to recognize that we're an ildb
IfFailGo(Write((void *)ILDB_SIGNATURE, ILDB_SIGNATURE_SIZE));
// Write out a guid representing the version
SwapGuid(&ildb_guid);
IfFailGo(Write((void *)&ildb_guid, sizeof(GUID)));
// Now we need to write the Project level
IfFailGo(Write(&ModuleLevelInfo, sizeof(PDBInfo)));
// Now we have to write out each array as appropriate
IfFailGo(Write(m_MethodInfo.m_constants.m_array, sizeof(SymConstant) * m_MethodInfo.m_constants.count()));
// These members are all 4 byte aligned
IfFailGo(Write(m_MethodInfo.m_methods.m_array, sizeof(SymMethodInfo) * m_MethodInfo.m_methods.count()));
IfFailGo(Write(m_MethodInfo.m_scopes.m_array, sizeof(SymLexicalScope) * m_MethodInfo.m_scopes.count()));
IfFailGo(Write(m_MethodInfo.m_vars.m_array, sizeof(SymVariable) * m_MethodInfo.m_vars.count()));
IfFailGo(Write(m_MethodInfo.m_usings.m_array, sizeof(SymUsingNamespace) * m_MethodInfo.m_usings.count()));
IfFailGo(Write(m_MethodInfo.m_auxSequencePoints.m_array, sizeof(SequencePoint) * m_MethodInfo.m_auxSequencePoints.count()));
IfFailGo(Write(m_MethodInfo.m_documents.m_array, sizeof(DocumentInfo) * m_MethodInfo.m_documents.count()));
IfFailGo(Write(m_MethodInfo.m_bytes.m_array, sizeof(BYTE) * m_MethodInfo.m_bytes.count()));
IfFailGo(WriteStringPool());
ErrExit:
if (m_hFile)
CloseHandle(m_hFile);
return hr;
}
/* ------------------------------------------------------------------------- *
* SymDocumentWriter class
* ------------------------------------------------------------------------- */
SymDocumentWriter::SymDocumentWriter(
UINT32 DocumentEntry,
SymWriter *pEmitter
) :
m_refCount ( 0 ),
m_DocumentEntry ( DocumentEntry ),
m_pEmitter( pEmitter )
{
_ASSERTE(pEmitter);
m_pEmitter->AddRef();
}
SymDocumentWriter::~SymDocumentWriter()
{
// Note that this must be thread-safe - it may be invoked on the finalizer thread
RELEASE(m_pEmitter);
}
COM_METHOD SymDocumentWriter::QueryInterface(REFIID riid, void **ppInterface)
{
if (ppInterface == NULL)
return E_INVALIDARG;
if (riid == IID_ISymUnmanagedDocumentWriter)
*ppInterface = (ISymUnmanagedDocumentWriter*)this;
else if (riid == IID_IUnknown)
*ppInterface = (IUnknown*)(ISymUnmanagedDocumentWriter*)this;
else
{
*ppInterface = NULL;
return E_NOINTERFACE;
}
AddRef();
return S_OK;
}
//-----------------------------------------------------------
// SymDocumentWriter SetSource
//-----------------------------------------------------------
COM_METHOD SymDocumentWriter::SetSource(ULONG32 sourceSize,
BYTE source[])
{
return m_pEmitter->SetDocumentSrc(m_DocumentEntry, sourceSize, source);
}
//-----------------------------------------------------------
// SymDocumentWriter SetCheckSum
//-----------------------------------------------------------
COM_METHOD SymDocumentWriter::SetCheckSum(GUID algorithmId,
ULONG32 checkSumSize,
BYTE checkSum[])
{
return m_pEmitter->SetDocumentCheckSum(m_DocumentEntry, algorithmId, checkSumSize, checkSum);
}
//-----------------------------------------------------------
// DocumentInfo SetDocumentWriter
//-----------------------------------------------------------
// Set the pointer to the SymDocumentWriter instance corresponding to this instance of DocumentInfo
// An argument of NULL will call Release
// Arguments
// input: pDoc - pointer to the associated SymDocumentWriter or NULL
void DocumentInfo::SetDocumentWriter(SymDocumentWriter * pDoc)
{
if (m_pDocumentWriter != NULL)
{
m_pDocumentWriter->Release();
}
m_pDocumentWriter = pDoc;
if (m_pDocumentWriter != NULL)
{
pDoc->AddRef();
}
}
| [
"dotnet-bot@microsoft.com"
] | dotnet-bot@microsoft.com |
5183826ea2de6b5bf11f07c995ff8eb80a730690 | 6ce5ecfc0933a296e329097e84fc1c2aeefaa317 | /AVLNode.h | 02f5ad8cded62e13f5981d1853d7ccd7d0a6ed76 | [] | no_license | magicmitra/AVLTree | fc1ba6edc3c6aa988b0771c54cdc4e73b0f9fcb4 | feb9cd5e37bb1a1713dfb1585adfed62a0d97472 | refs/heads/master | 2020-03-14T13:41:51.480200 | 2018-05-07T19:59:57 | 2018-05-07T19:59:57 | 131,637,971 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 309 | h | /* AVL Node
* user as nodes for the AVLTreeClass
*/
#pragma once
class AVLNode
{
public:
AVLNode(int obj);
AVLNode(int obj, AVLNode *leftChild, AVLNode *rightChild);
AVLNode();
~AVLNode();
// data item, left child, right child, height
int theItem;
AVLNode* left;
AVLNode* right;
int height;
};
| [
"ervinmitra@gmail.com"
] | ervinmitra@gmail.com |
12fae88f2a9dc82f4498b84acda8aaf1e61a0423 | a61a21484fa9d29152793b0010334bfe2fed71eb | /Skyrim/src/Forms/BGSOutfit.cpp | f4a83ac601f72fba0d2912bd6f1549ee5a9a52a6 | [] | no_license | kassent/IndividualizedShoutCooldowns | 784e3c62895869c7826dcdbdeea6e8e177e8451c | f708063fbc8ae21ef7602e03b4804ae85518f551 | refs/heads/master | 2021-01-19T05:22:24.794134 | 2017-04-06T13:00:19 | 2017-04-06T13:00:19 | 87,429,558 | 3 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 723 | cpp | #include "Skyrim/Forms/BGSOutfit.h"
#include "Skyrim/Forms/TESLevItem.h"
void BGSOutfit::Calcurate(UInt16 level, BSTArray<TESForm*> &result, bool ignoreChanceValue, bool unk) const
{
result.clear();
result.reserve(5);
BSScrapArray<TESLeveledList::CalcuratedResult> calcurated(10);
for (TESForm *item : armorOrLeveledItemArray)
{
if (item->Is(FormType::LeveledItem))
{
TESLevItem *levItem = (TESLevItem*)item;
levItem->Calcurate(level, 1, calcurated, ignoreChanceValue, unk);
}
else if (item->Is(FormType::Armor))
{
if (result.Find(item) < 0)
result.Add(item);
}
}
for (auto &node : calcurated)
{
if (node.form->IsArmor() && result.Find(node.form) < 0)
result.Add(node.form);
}
}
| [
"wangzhengzewzz@gmail.com"
] | wangzhengzewzz@gmail.com |
9e96e4d61d4a31a1a9e2815643478990e76a87e0 | 4628d601b5c56679bd48aa50a0bfe3874c365f37 | /engine/gui/widgets/textarea.h | 75aff2a69c6e4195f4faac2af9406c1570d5b737 | [] | no_license | di15/mathd | 09f8695cc95933ed18d69f1ca5cf43d75099ed78 | 5b92aeb399855dbee07b1ccd6f91e1d1cb533297 | refs/heads/master | 2021-01-17T06:28:32.740625 | 2015-02-03T01:33:38 | 2015-02-03T01:33:38 | 28,899,581 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 899 | h | #ifndef TEXTAREA_H
#define TEXTAREA_H
#include "../widget.h"
class TextArea : public Widget
{
public:
int m_highl[2]; // highlighted (selected) text
UStr m_compos; //composition for unicode text
TextArea(Widget* parent, const char* n, const RichText t, int f, void (*reframef)(Widget* thisw), float r=1, float g=1, float b=1, float a=1, void (*change)()=NULL);
void draw();
int rowsshown();
int square();
float topratio()
{
return m_scroll[1] / (float)m_lines;
}
float bottomratio()
{
return (m_scroll[1]+rowsshown()) / (float)m_lines;
}
float scrollspace();
void changevalue(const char* newv);
bool delnext();
bool delprev();
void copyval();
void pasteval();
void selectall();
//void placestr(const char* str);
void placestr(const RichText* str);
void placechar(unsigned int k);
void inev(InEv* ie);
void close();
void gainfocus();
void losefocus();
};
#endif
| [
"polyfrag@hotmail.com"
] | polyfrag@hotmail.com |
09dcd6cb526756e2a1bcdc8f8500661ec8deaeca | 41a76318e5b9eef2c69bbf922724f8b191d7d124 | /kokkos/core/src/eti/HPX/Kokkos_HPX_ViewCopyETIInst_int_int_LayoutStride_Rank2.cpp | 06513c4fe6394e3b7fb2e6e2fb5bbdf27ac5f6f7 | [
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | zishengye/compadre | d0ff10deca224284e7e153371a738e053e66012a | 75b738a6a613c89e3c3232cbf7b2589a6b28d0a3 | refs/heads/master | 2021-06-25T06:16:38.327543 | 2021-04-02T02:08:48 | 2021-04-02T02:08:48 | 223,650,267 | 0 | 0 | NOASSERTION | 2019-11-23T20:41:03 | 2019-11-23T20:41:02 | null | UTF-8 | C++ | false | false | 2,638 | cpp | //@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Kokkos is licensed under 3-clause BSD terms of use:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. 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.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "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 SANDIA CORPORATION OR THE
// 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.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
#define KOKKOS_IMPL_COMPILING_LIBRARY true
#include <Kokkos_Core.hpp>
namespace Kokkos {
namespace Impl {
KOKKOS_IMPL_VIEWCOPY_ETI_INST(int**, LayoutStride, LayoutRight,
Experimental::HPX, int)
KOKKOS_IMPL_VIEWCOPY_ETI_INST(int**, LayoutStride, LayoutLeft,
Experimental::HPX, int)
KOKKOS_IMPL_VIEWCOPY_ETI_INST(int**, LayoutStride, LayoutStride,
Experimental::HPX, int)
KOKKOS_IMPL_VIEWFILL_ETI_INST(int**, LayoutStride, Experimental::HPX, int)
} // namespace Impl
} // namespace Kokkos
| [
"pakuber@sandia.gov"
] | pakuber@sandia.gov |
4618b56795c343a9a1cc006e2d42182426c32315 | 38b057c7dea2e7b9015e3fce67726cb1678a90b1 | /libs/z3/src/util/lp/lar_core_solver_def.h | 476e1169859917b183ee40f5871afd27541fa4e0 | [
"MIT"
] | permissive | anhvvcs/corana | 3ef150667e8124c19238a3f75a875096bbf698c5 | dc40868ee4ba1c6148547fb125fddccfb0d446c3 | refs/heads/master | 2023-08-10T07:04:37.740227 | 2023-07-24T20:41:30 | 2023-07-24T20:41:30 | 181,912,504 | 34 | 4 | MIT | 2023-06-29T03:32:18 | 2019-04-17T14:49:09 | C | UTF-8 | C++ | false | false | 10,918 | h | /*++
Copyright (c) 2017 Microsoft Corporation
Module Name:
<name>
Abstract:
<abstract>
Author:
Lev Nachmanson (levnach)
Revision History:
--*/
/*++
Copyright (c) 2017 Microsoft Corporation
Module Name:
<name>
Abstract:
<abstract>
Author:
Lev Nachmanson (levnach)
Revision History:
--*/
#include <string>
#include "util/vector.h"
#include "util/lp/lar_core_solver.h"
#include "util/lp/lar_solution_signature.h"
namespace lp {
lar_core_solver::lar_core_solver(
lp_settings & settings,
const column_namer & column_names
):
m_infeasible_sum_sign(0),
m_r_solver(m_r_A,
m_right_sides_dummy,
m_r_x,
m_r_basis,
m_r_nbasis,
m_r_heading,
m_costs_dummy,
m_column_types(),
m_r_lower_bounds(),
m_r_upper_bounds(),
settings,
column_names),
m_d_solver(m_d_A,
m_d_right_sides_dummy,
m_d_x,
m_d_basis,
m_d_nbasis,
m_d_heading,
m_d_costs_dummy,
m_column_types(),
m_d_lower_bounds,
m_d_upper_bounds,
settings,
column_names){}
void lar_core_solver::init_costs(bool first_time) {
lp_assert(false); // should not be called
// lp_assert(this->m_x.size() >= this->m_n());
// lp_assert(this->m_column_types.size() >= this->m_n());
// if (first_time)
// this->m_costs.resize(this->m_n());
// X inf = this->m_infeasibility;
// this->m_infeasibility = zero_of_type<X>();
// for (unsigned j = this->m_n(); j--;)
// init_cost_for_column(j);
// if (!(first_time || inf >= this->m_infeasibility)) {
// LP_OUT(this->m_settings, "iter = " << this->total_iterations() << std::endl);
// LP_OUT(this->m_settings, "inf was " << T_to_string(inf) << " and now " << T_to_string(this->m_infeasibility) << std::endl);
// lp_assert(false);
// }
// if (inf == this->m_infeasibility)
// this->m_iters_with_no_cost_growing++;
}
void lar_core_solver::init_cost_for_column(unsigned j) {
/*
// If j is a breakpoint column, then we set the cost zero.
// When anylyzing an entering column candidate we update the cost of the breakpoints columns to get the left or the right derivative if the infeasibility function
const numeric_pair<mpq> & x = this->m_x[j];
// set zero cost for each non-basis column
if (this->m_basis_heading[j] < 0) {
this->m_costs[j] = numeric_traits<T>::zero();
return;
}
// j is a basis column
switch (this->m_column_types[j]) {
case fixed:
case column_type::boxed:
if (x > this->m_upper_bounds[j]) {
this->m_costs[j] = 1;
this->m_infeasibility += x - this->m_upper_bounds[j];
} else if (x < this->m_lower_bounds[j]) {
this->m_infeasibility += this->m_lower_bounds[j] - x;
this->m_costs[j] = -1;
} else {
this->m_costs[j] = numeric_traits<T>::zero();
}
break;
case lower_bound:
if (x < this->m_lower_bounds[j]) {
this->m_costs[j] = -1;
this->m_infeasibility += this->m_lower_bounds[j] - x;
} else {
this->m_costs[j] = numeric_traits<T>::zero();
}
break;
case upper_bound:
if (x > this->m_upper_bounds[j]) {
this->m_costs[j] = 1;
this->m_infeasibility += x - this->m_upper_bounds[j];
} else {
this->m_costs[j] = numeric_traits<T>::zero();
}
break;
case free_column:
this->m_costs[j] = numeric_traits<T>::zero();
break;
default:
lp_assert(false);
break;
}*/
}
// returns m_sign_of_alpha_r
int lar_core_solver::column_is_out_of_bounds(unsigned j) {
/*
switch (this->m_column_type[j]) {
case fixed:
case column_type::boxed:
if (this->x_below_low_bound(j)) {
return -1;
}
if (this->x_above_upper_bound(j)) {
return 1;
}
return 0;
case lower_bound:
if (this->x_below_low_bound(j)) {
return -1;
}
return 0;
case upper_bound:
if (this->x_above_upper_bound(j)) {
return 1;
}
return 0;
default:
return 0;
break;
}*/
lp_assert(false);
return true;
}
void lar_core_solver::calculate_pivot_row(unsigned i) {
m_r_solver.calculate_pivot_row(i);
}
void lar_core_solver::prefix_r() {
if (!m_r_solver.m_settings.use_tableau()) {
m_r_solver.m_copy_of_xB.resize(m_r_solver.m_n());
m_r_solver.m_ed.resize(m_r_solver.m_m());
m_r_solver.m_pivot_row.resize(m_r_solver.m_n());
m_r_solver.m_pivot_row_of_B_1.resize(m_r_solver.m_m());
m_r_solver.m_w.resize(m_r_solver.m_m());
m_r_solver.m_y.resize(m_r_solver.m_m());
m_r_solver.m_rows_nz.resize(m_r_solver.m_m(), 0);
m_r_solver.m_columns_nz.resize(m_r_solver.m_n(), 0);
init_column_row_nz_for_r_solver();
}
m_r_solver.m_b.resize(m_r_solver.m_m());
if (m_r_solver.m_settings.simplex_strategy() != simplex_strategy_enum::tableau_rows) {
if(m_r_solver.m_settings.use_breakpoints_in_feasibility_search)
m_r_solver.m_breakpoint_indices_queue.resize(m_r_solver.m_n());
m_r_solver.m_costs.resize(m_r_solver.m_n());
m_r_solver.m_d.resize(m_r_solver.m_n());
m_r_solver.m_using_infeas_costs = true;
}
}
void lar_core_solver::prefix_d() {
m_d_solver.m_b.resize(m_d_solver.m_m());
m_d_solver.m_breakpoint_indices_queue.resize(m_d_solver.m_n());
m_d_solver.m_copy_of_xB.resize(m_d_solver.m_n());
m_d_solver.m_costs.resize(m_d_solver.m_n());
m_d_solver.m_d.resize(m_d_solver.m_n());
m_d_solver.m_ed.resize(m_d_solver.m_m());
m_d_solver.m_pivot_row.resize(m_d_solver.m_n());
m_d_solver.m_pivot_row_of_B_1.resize(m_d_solver.m_m());
m_d_solver.m_w.resize(m_d_solver.m_m());
m_d_solver.m_y.resize(m_d_solver.m_m());
m_d_solver.m_steepest_edge_coefficients.resize(m_d_solver.m_n());
m_d_solver.m_column_norms.clear();
m_d_solver.m_column_norms.resize(m_d_solver.m_n(), 2);
m_d_solver.m_inf_set.clear();
m_d_solver.m_inf_set.resize(m_d_solver.m_n());
}
void lar_core_solver::fill_not_improvable_zero_sum_from_inf_row() {
CASSERT("A_off", m_r_solver.A_mult_x_is_off() == false);
unsigned bj = m_r_basis[m_r_solver.m_inf_row_index_for_tableau];
m_infeasible_sum_sign = m_r_solver.inf_sign_of_column(bj);
m_infeasible_linear_combination.clear();
for (auto & rc : m_r_solver.m_A.m_rows[m_r_solver.m_inf_row_index_for_tableau]) {
m_infeasible_linear_combination.push_back(std::make_pair( rc.get_val(), rc.var()));
}
}
void lar_core_solver::fill_not_improvable_zero_sum() {
if (m_r_solver.m_settings.simplex_strategy() == simplex_strategy_enum::tableau_rows) {
fill_not_improvable_zero_sum_from_inf_row();
return;
}
// reusing the existing mechanism for row_feasibility_loop
m_infeasible_sum_sign = m_r_solver.m_settings.use_breakpoints_in_feasibility_search? -1 : 1;
m_infeasible_linear_combination.clear();
for (auto j : m_r_solver.m_basis) {
const mpq & cost_j = m_r_solver.m_costs[j];
if (!numeric_traits<mpq>::is_zero(cost_j)) {
m_infeasible_linear_combination.push_back(std::make_pair(cost_j, j));
}
}
// m_costs are expressed by m_d ( additional costs), substructing the latter gives 0
for (unsigned j = 0; j < m_r_solver.m_n(); j++) {
if (m_r_solver.m_basis_heading[j] >= 0) continue;
const mpq & d_j = m_r_solver.m_d[j];
if (!numeric_traits<mpq>::is_zero(d_j)) {
m_infeasible_linear_combination.push_back(std::make_pair(-d_j, j));
}
}
}
unsigned lar_core_solver::get_number_of_non_ints() const {
unsigned n = 0;
for (auto & x : m_r_solver.m_x) {
if (x.is_int() == false)
n++;
}
return n;
}
void lar_core_solver::solve() {
TRACE("lar_solver", tout << m_r_solver.get_status() << "\n";);
lp_assert(m_r_solver.non_basic_columns_are_set_correctly());
lp_assert(m_r_solver.inf_set_is_correct());
TRACE("find_feas_stats", tout << "infeasibles = " << m_r_solver.m_inf_set.size() << ", int_infs = " << get_number_of_non_ints() << std::endl;);
if (m_r_solver.current_x_is_feasible() && m_r_solver.m_look_for_feasible_solution_only) {
m_r_solver.set_status(lp_status::OPTIMAL);
TRACE("lar_solver", tout << m_r_solver.get_status() << "\n";);
return;
}
++settings().st().m_need_to_solve_inf;
CASSERT("A_off", !m_r_solver.A_mult_x_is_off());
lp_assert((!settings().use_tableau()) || r_basis_is_OK());
if (need_to_presolve_with_double_solver()) {
TRACE("lar_solver", tout << "presolving\n";);
prefix_d();
lar_solution_signature solution_signature;
vector<unsigned> changes_of_basis = find_solution_signature_with_doubles(solution_signature);
if (m_d_solver.get_status() == lp_status::TIME_EXHAUSTED) {
m_r_solver.set_status(lp_status::TIME_EXHAUSTED);
return;
}
if (settings().use_tableau())
solve_on_signature_tableau(solution_signature, changes_of_basis);
else
solve_on_signature(solution_signature, changes_of_basis);
lp_assert(!settings().use_tableau() || r_basis_is_OK());
} else {
if (!settings().use_tableau()) {
TRACE("lar_solver", tout << "no tablau\n";);
bool snapped = m_r_solver.snap_non_basic_x_to_bound();
lp_assert(m_r_solver.non_basic_columns_are_set_correctly());
if (snapped)
m_r_solver.solve_Ax_eq_b();
}
if (m_r_solver.m_look_for_feasible_solution_only)
m_r_solver.find_feasible_solution();
else {
TRACE("lar_solver", tout << "solve\n";);
m_r_solver.solve();
}
lp_assert(!settings().use_tableau() || r_basis_is_OK());
}
if (m_r_solver.get_status() == lp_status::INFEASIBLE) {
fill_not_improvable_zero_sum();
} else if (m_r_solver.get_status() != lp_status::UNBOUNDED) {
m_r_solver.set_status(lp_status::OPTIMAL);
}
lp_assert(r_basis_is_OK());
lp_assert(m_r_solver.non_basic_columns_are_set_correctly());
lp_assert(m_r_solver.inf_set_is_correct());
TRACE("lar_solver", tout << m_r_solver.get_status() << "\n";);
}
}
| [
"anhvvcs@gmail.com"
] | anhvvcs@gmail.com |
ae11a52454459aac6721e61f202a932f08e36fbc | 5a0595f75402ecd15d8aeb701f3496e3e4ea096e | /DiRa_Software/Jetson_TK1/Software/DiRA_Firmware_Modules/DiRa_PCA9685_Controller/dira_pca9685_tk1_controller/include/JHPWMPCA9685.h | 79b2429c687f26d6e04667a5e23eb05eca92468f | [
"MIT"
] | permissive | thodoxuan99/DiRa | 852358af033c481ed6619a1b20b0c125cb88e76e | b6beda59a64487b6242940156c8e2fa0a5ae2866 | refs/heads/master | 2020-09-03T11:57:31.437422 | 2019-11-04T07:00:36 | 2019-11-04T07:00:36 | 219,457,078 | 0 | 1 | MIT | 2019-11-04T08:54:04 | 2019-11-04T08:54:04 | null | UTF-8 | C++ | false | false | 5,444 | h | /*
* The MIT License (MIT)
Copyright (c) 2015 Jetsonhacks
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef _JHPWMPCA9685_H
#define _JHPWMPCA9685_H
#include <cstddef>
extern "C" {
//#include <i2c/smbus.h>
#include <linux/i2c-dev.h>
}
#include <sys/ioctl.h>
#include <cstdlib>
#include <cstdio>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
class PCA9685
{
public:
unsigned char kI2CBus ; // I2C bus of the PCA9685
int kI2CFileDescriptor ; // File Descriptor to the PCA9685
int kI2CAddress ; // Address of PCA9685; defaults to 0x40
int error ;
PCA9685(int address=0x40);
~PCA9685() ;
bool openPCA9685() ;
void closePCA9685();
void reset() ;
// Sets the frequency of the PWM signal
// Frequency is ranged between 40 and 1000 Hertz
void setPWMFrequency ( float frequency );
// Channels 0-15
// Channels are in sets of 4 bytes
void setPWM ( int channel, int onValue, int offValue);
void setAllPWM (int onValue, int offValue);
// Read the given register
int readByte(int readRegister);
// Write the the given value to the given register
int writeByte(int writeRegister, int writeValue);
int getError() ;
};
// Register definitions from Table 7.3 NXP Semiconductors
// Product Data Sheet, Rev. 4 - 16 April 2015
#define PCA9685_MODE1 0x00
#define PCA9685_MODE2 0x01
#define PCA9685_SUBADR1 0x02
#define PCA9685_SUBADR2 0x03
#define PCA9685_SUBADR3 0x04
#define PCA9685_ALLCALLADR 0x05
// LED outbut and brightness
#define PCA9685_LED0_ON_L 0x06
#define PCA9685_LED0_ON_H 0x07
#define PCA9685_LED0_OFF_L 0x08
#define PCA9685_LED0_OFF_H 0x09
#define PCA9685_LED1_ON_L 0x0A
#define PCA9685_LED1_ON_H 0x0B
#define PCA9685_LED1_OFF_L 0x0C
#define PCA9685_LED1_OFF_H 0x0D
#define PCA9685_LED2_ON_L 0x0E
#define PCA9685_LED2_ON_H 0x0F
#define PCA9685_LED2_OFF_L 0x10
#define PCA9685_LED2_OFF_H 0x11
#define PCA9685_LED3_ON_L 0x12
#define PCA9685_LED3_ON_H 0x13
#define PCA9685_LED3_OFF_L 0x14
#define PCA9685_LED3_OFF_H 0x15
#define PCA9685_LED4_ON_L 0x16
#define PCA9685_LED4_ON_H 0x17
#define PCA9685_LED4_OFF_L 0x18
#define PCA9685_LED4_OFF_H 0x19
#define PCA9685_LED5_ON_L 0x1A
#define PCA9685_LED5_ON_H 0x1B
#define PCA9685_LED5_OFF_L 0x1C
#define PCA9685_LED5_OFF_H 0x1D
#define PCA9685_LED6_ON_L 0x1E
#define PCA9685_LED6_ON_H 0x1F
#define PCA9685_LED6_OFF_L 0x20
#define PCA9685_LED6_OFF_H 0x21
#define PCA9685_LED7_ON_L 0x22
#define PCA9685_LED7_ON_H 0x23
#define PCA9685_LED7_OFF_L 0x24
#define PCA9685_LED7_OFF_H 0x25
#define PCA9685_LED8_ON_L 0x26
#define PCA9685_LED8_ON_H 0x27
#define PCA9685_LED8_OFF_L 0x28
#define PCA9685_LED8_OFF_H 0x29
#define PCA9685_LED9_ON_L 0x2A
#define PCA9685_LED9_ON_H 0x2B
#define PCA9685_LED9_OFF_L 0x2C
#define PCA9685_LED9_OFF_H 0x2D
#define PCA9685_LED10_ON_L 0x2E
#define PCA9685_LED10_ON_H 0x2F
#define PCA9685_LED10_OFF_L 0x30
#define PCA9685_LED10_OFF_H 0x31
#define PCA9685_LED11_ON_L 0x32
#define PCA9685_LED11_ON_H 0x33
#define PCA9685_LED11_OFF_L 0x34
#define PCA9685_LED11_OFF_H 0x35
#define PCA9685_LED12_ON_L 0x36
#define PCA9685_LED12_ON_H 0x37
#define PCA9685_LED12_OFF_L 0x38
#define PCA9685_LED12_OFF_H 0x39
#define PCA9685_LED13_ON_L 0x3A
#define PCA9685_LED13_ON_H 0x3B
#define PCA9685_LED13_OFF_L 0x3C
#define PCA9685_LED13_OFF_H 0x3D
#define PCA9685_LED14_ON_L 0x3E
#define PCA9685_LED14_ON_H 0x3F
#define PCA9685_LED14_OFF_L 0x40
#define PCA9685_LED14_OFF_H 0x41
#define PCA9685_LED15_ON_L 0x42
#define PCA9685_LED15_ON_H 0x43
#define PCA9685_LED15_OFF_L 0x44
#define PCA9685_LED15_OFF_H 0x45
#define PCA9685_ALL_LED_ON_L 0xFA
#define PCA9685_ALL_LED_ON_H 0xFB
#define PCA9685_ALL_LED_OFF_L 0xFC
#define PCA9685_ALL_LED_OFF_H 0xFD
#define PCA9685_PRE_SCALE 0xFE
// Register Bits
#define PCA9685_ALLCALL 0x01
#define PCA9685_OUTDRV 0x04
#define PCA9685_RESTART 0x80
#define PCA9685_SLEEP 0x10
#define PCA9685_INVERT 0x10
#endif
| [
"hieump5@fpt.com.vn"
] | hieump5@fpt.com.vn |
78ef450c41dffab1417b295cc22135d43e6a946c | b7182aabd325137aa7e1df85cc65875a526c5e43 | /eos/inline/types/vrf.h | b17c631319ad9186229cb1d4e5e08b6a3c98a7c8 | [
"BSD-3-Clause"
] | permissive | dubnetwork/EosSdk | 793d357292b1147704872a240c467480be227a82 | 90a7a18bddb75eaf83ec74a68d5f011fe85ed89c | refs/heads/master | 2020-12-25T22:57:20.007351 | 2014-12-11T23:30:32 | 2014-12-13T22:12:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,403 | h | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved.
// Arista Networks, Inc. Confidential and Proprietary.
#ifndef EOS_INLINE_TYPES_VRF_H
#define EOS_INLINE_TYPES_VRF_H
namespace eos {
// Default constructor.
inline vrf_t::vrf_t() :
name_(""), rd_(0), af_ipv4_(false), af_ipv6_(false) {
}
inline vrf_t::vrf_t(std::string name, uint64_t rd, bool af_ipv4, bool af_ipv6) :
name_(name), rd_(rd), af_ipv4_(af_ipv4), af_ipv6_(af_ipv6) {
}
inline std::string
vrf_t::name() const {
return name_;
}
inline uint64_t
vrf_t::rd() const {
return rd_;
}
inline bool
vrf_t::af_ipv4() const {
return af_ipv4_;
}
inline bool
vrf_t::af_ipv6() const {
return af_ipv6_;
}
inline bool
vrf_t::operator==(vrf_t const & other) const {
return name_ == other.name_ &&
rd_ == other.rd_ &&
af_ipv4_ == other.af_ipv4_ &&
af_ipv6_ == other.af_ipv6_;
}
inline bool
vrf_t::operator!=(vrf_t const & other) const {
return !operator==(other);
}
inline std::string
vrf_t::to_string() const {
std::ostringstream ss;
ss << "vrf_t(";
ss << "name='" << name_ << "'";
ss << ", rd=" << rd_;
ss << ", af_ipv4=" << af_ipv4_;
ss << ", af_ipv6=" << af_ipv6_;
ss << ")";
return ss.str();
}
inline std::ostream&
operator<<(std::ostream& os, const vrf_t& obj) {
os << obj.to_string();
return os;
}
}
#endif // EOS_INLINE_TYPES_VRF_H
| [
"tsuna@arista.com"
] | tsuna@arista.com |
2be7b36cfe9531ac2a4e1b752221a3e53a89adbc | adb16eaccac05b07dbc44bb7fe87a17bf59889f0 | /worktree/funk/imgui/Imgui.cpp | ba2014df1d71ae92ce50b8daf30af1e26ee9b25f | [] | no_license | tech-ui/nao-gm | e29f6cc899e744b1faf596d770b440eb81039a53 | bd0f201640701a0a3eaddc12a1fa12c0c7c48891 | refs/heads/master | 2021-05-27T12:07:25.586855 | 2012-12-20T05:05:15 | 2012-12-20T05:05:15 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 43,105 | cpp | #include "Imgui.h"
#include <cstring>
#include <assert.h>
#include <gl/glew.h>
#include "ImguiManager.h"
#include "ImguiWindow.h"
#include <gfx/Renderer.h>
#include <gfx/DrawPrimitives.h>
#include <gfx/LineGraph.h>
#include <math/CubicSpline2d.h>
#include <math/ColorUtil.h>
#include <common/Input.h>
#include <common/Timer.h>
#include <common/Window.h>
#include <common/Debug.h>
namespace funk
{
int Imgui::FONT_WIDTH = 6;
int Imgui::FONT_HEIGHT = 12;
const int BUTTON_INSIDE_PADDING = 3;
const int TAB_WIDTH = Imgui::FONT_WIDTH*2;
const int WIDGET_PADDING = 4;
const int WINDOW_INSIDE_PADDING = 6;
const int TITLE_BAR_PADDING = 6;
const int TITLE_BAR_HEIGHT = Imgui::FONT_HEIGHT+TITLE_BAR_PADDING*2;
const int SCROLL_BAR_SIZE = 12;
const int FILLBAR_WIDTH = 150;
const int FILLBAR_TEXT_BUFFER = 2;
const int FILLBAR_HEIGHT = Imgui::FONT_HEIGHT+FILLBAR_TEXT_BUFFER*2;
const v3 COLOR_WINDOW_BG = v3(0.15f);
const v3 COLOR_SLIDER_BTN_BORDER = v3(0.0f);
const v3 COLOR_SLIDER_BG_BORDER = v3(0.08f);
const v3 COLOR_SLIDER = v3(0.25f);
const v3 COLOR_SLIDER_ACTIVE = v3(0.40f);
const v3 COLOR_BUTTON = v3( 0.35f );
const v3 COLOR_BUTTON_HOVER = v3( 0.45f );
const v3 COLOR_BUTTON_PRESS = v3( 0.25f );
const v3 COLOR_BAR = v3(0.15f);
const v3 COLOR_BAR_HOVER = v3(0.30f);
const v3 COLOR_FILLBAR = v3(0.6f, 0.6f, 0.0f);
const v3 COLOR_SEPARATOR = v3(0.35f);
const v3 COLOR_WHITE = v3(1.0f);
const v3 COLOR_BLACK = v3(0.0f);
const float MOUSEWHEEL_SCROLL_DELTA = 100.0f;
enum ButtonState
{
BUTTON_NONE,
BUTTON_HOVER,
BUTTON_PRESS,
BUTTON_DOWN
};
enum SpecialWidgetId
{
ID_SCROLL_X = (1<<16)+0,
ID_SCROLL_Y = (1<<16)+1,
ID_RESIZE_BUTTON = (1<<16)+2,
};
inline v2 toV2( v2i v ) { return v2((float)v.x, (float)v.y); }
inline v2i toV2i( v2 v ) { return v2i((int)v.x, (int)v.y); }
inline StrongHandle<ImguiWindow> &ImguiWorkingWindow() { return ImguiManager::Get()->state.workingWindow; }
inline int ImguiTextWidth(const char* c) { return Imgui::FONT_WIDTH*strlen(c); }
inline bool ImguiIsMinized() { assert(ImguiWorkingWindow()); return ImguiWorkingWindow()->minimized || ImguiWorkingWindow()->locked; }
inline void ImguiPrint( const char* text, v2i pos ) { ImguiManager::Get()->GetFont().Print(text,toV2(pos)); }
inline ImguiManager::State &ImguiState() { return ImguiManager::Get()->state; }
inline bool ImguiMouseDown()
{
return Input::Get()->IsMouseDown(1);
}
inline bool ImguiDidMouseJustGoDown()
{
return Input::Get()->DidMouseJustGoDown(1);
}
inline bool ImguiDidMouseJustGoUp()
{
return Input::Get()->DidMouseJustGoUp(1);
}
inline v2i ImguiGetMousePos()
{
return Input::Get()->GetMousePos() + ImguiState().scrollOffset;
}
bool ImguiMouseOver( v2i pos, v2i dimen )
{
if ( ImguiWorkingWindow()->locked ) return false;
const v2i mousePos = ImguiGetMousePos();
int mX = (int)mousePos.x;
int mY = (int)mousePos.y;
// mouse regions
v2i regionPos = ImguiState().mouseRegionStart + ImguiState().scrollOffset;
v2i regionDimen = ImguiState().mouseRegionDimen;
return (mX >= pos.x) && (mX <= pos.x+dimen.x) && (mY <= pos.y) && (mY >= pos.y-dimen.y)
&& (mX >= regionPos.x) && (mX <= regionPos.x+regionDimen.x) && (mY <= regionPos.y) && (mY >= regionPos.y-regionDimen.y);
}
inline bool ImguiMouseDoubleClick()
{
return Input::Get()->DidMouseDoubleClick();
}
inline bool ImguiIsWindowActive()
{
return ImguiWorkingWindow() == ImguiState().activeWindow;
}
inline bool ImguiIsWidgetActive(int id)
{
return ImguiIsWindowActive() && (ImguiManager::Get()->state.activeWidgetId == id );
}
inline int ImguiGenWidgetId()
{
return ++ImguiState().widgetCount;
}
inline void ImguiSetActiveWidgetId(int id)
{
if( id == ImguiManager::State::WIDGET_NULL )
{
// nothing
}
ImguiState().activeWidgetId = id;
}
inline void ImguiSetActiveWindow(StrongHandle<ImguiWindow> &window)
{
if ( window == NULL )
{
ImguiManager::Get()->ClearActiveWindow();
}
if ( ImguiState().activeWindow != window )
{
ImguiSetActiveWidgetId( ImguiManager::State::WIDGET_NULL );
}
ImguiState().activeWindow = window;
}
void MoveDrawPosBy( v2i dimen )
{
StrongHandle<ImguiWindow> &window = ImguiWorkingWindow();
ImguiState().drawPosPrev = ImguiState().drawPos;
ImguiState().drawPosPrev.x += dimen.x + WIDGET_PADDING;
ImguiState().drawPos += v2i(dimen.x, -dimen.y);
window->dimenAutosize.x = max( window->dimenAutosize.x, ImguiState().drawPos.x - window->pos.x );
window->dimenAutosize.y = max( window->dimenAutosize.y, window->pos.y - ImguiState().drawPos.y );
}
inline void MoveDrawPosNextLine( v2i dimen )
{
StrongHandle<ImguiWindow> &window = ImguiWorkingWindow();
MoveDrawPosBy( dimen + v2i(0,WIDGET_PADDING) );
ImguiState().drawPos.x = window->pos.x + WINDOW_INSIDE_PADDING + TAB_WIDTH*ImguiState().numTabs;
}
inline void ImguiDrawRect( v2i pos, v2i dimen )
{
DrawRect( toV2(pos-v2i(0,dimen.y)), toV2(dimen) );
}
inline void ImguiDrawRectWire( v2i pos, v2i dimen )
{
DrawRectWire( toV2(pos-v2i(0,dimen.y)), toV2(dimen) );
}
inline void ImguiDrawLine( v2i start, v2i end )
{
DrawLine( toV2(start), toV2(end) );
}
inline void ImguiDrawPoint( v2i pt, float radius )
{
DrawCircle(toV2(pt), radius);
}
inline void ImguiColor( v3 color, float alpha = 1.0f )
{
glColor4f( color.x, color.y, color.z, alpha );
}
ButtonState ImguiButton( const char* name, int padding = BUTTON_INSIDE_PADDING )
{
if( ImguiIsMinized() ) return BUTTON_NONE;
const v3 COLOR_BORDER = v3( 0.15f );
const v3 COLOR_TEXT = COLOR_WHITE;
ButtonState result = BUTTON_NONE;
const int id = ImguiGenWidgetId();
const int buttonHeight = Imgui::FONT_HEIGHT+padding*2;
const int fontWidth = ImguiTextWidth(name);
const v2i pos = ImguiState().drawPos;
const v2i dimen = v2i(fontWidth+padding*2, buttonHeight);
v3 buttonColor = COLOR_BUTTON;
// mouse go down
if ( ImguiMouseOver(pos,dimen) )
{
buttonColor = COLOR_BUTTON_HOVER;
result = BUTTON_HOVER;
// mouse goes down on button
if ( ImguiDidMouseJustGoDown() && ImguiIsWindowActive() )
{
ImguiSetActiveWidgetId(id);
}
// fully clicked on button!
else if ( ImguiDidMouseJustGoUp() && ImguiIsWidgetActive(id) )
{
result = BUTTON_PRESS;
ImguiSetActiveWidgetId(ImguiManager::State::WIDGET_NULL);
}
}
// released mouse
else if ( ImguiDidMouseJustGoUp() )
{
if ( ImguiIsWidgetActive(id) )
{
ImguiSetActiveWidgetId(ImguiManager::State::WIDGET_NULL);
}
}
// held down
if ( ImguiIsWidgetActive(id) )
{
result = BUTTON_DOWN;
buttonColor = COLOR_BUTTON_PRESS;
}
// draw button
ImguiColor(buttonColor);
ImguiDrawRect( pos, dimen );
ImguiColor(COLOR_BORDER);
ImguiDrawRectWire( pos, dimen );
ImguiColor(COLOR_TEXT);
ImguiPrint(name, pos+v2i(padding,-padding) );
MoveDrawPosNextLine(dimen);
return result;
}
void ImguiTitleBar(StrongHandle<ImguiWindow> &window, const char* name, int id)
{
const int MINIZE_BUTTON_PADDING = WIDGET_PADDING;
const v3 COLOR_WINDOW_TITLE = v3(0.1f, 0.6f, 0.3f);
const v3 COLOR_WINDOW_TITLE_INACTIVE = v3(0.1f, 0.6f, 0.3f)*0.5f;
const int BUTTON_HEIGHT = Imgui::FONT_HEIGHT+BUTTON_INSIDE_PADDING*2;
bool isWindowActive = ImguiIsWindowActive();
const v2i mousePos = ImguiGetMousePos();
// draw title bar background
v2i titleBarDimen = v2i( window->dimen.x, TITLE_BAR_HEIGHT );
float titleBarAlpha = isWindowActive ? 1.0f : 0.7f;
v3 titleBarColor = isWindowActive ? COLOR_WINDOW_TITLE : COLOR_WINDOW_TITLE_INACTIVE;
ImguiColor( titleBarColor, titleBarAlpha );
ImguiDrawRect( window->pos, titleBarDimen );
// draw title font
int fontWidth = ImguiTextWidth(name);
float fontAlpha = isWindowActive ? 1.0f: 0.6f;
ImguiColor(COLOR_WHITE, fontAlpha);
ImguiPrint(name, window->pos + v2i(TITLE_BAR_PADDING, -TITLE_BAR_PADDING) );
// find position for button
int buttonWidth = Imgui::FONT_WIDTH + BUTTON_INSIDE_PADDING*2;
ImguiState().drawPos = window->pos+v2i(window->dimen.x - buttonWidth-WIDGET_PADDING/2, -(TITLE_BAR_HEIGHT-BUTTON_HEIGHT)/2);
// calculate how big min title bar
window->titleBarMinWidth = fontWidth + TITLE_BAR_PADDING + buttonWidth + MINIZE_BUTTON_PADDING;
// handle minimized (need to unmiminimize to draw the button)
bool minimized = window->minimized;
window->minimized = false;
ButtonState minBtn = ImguiButton(minimized ? "+" : "-");
minimized = minimized^(minBtn == BUTTON_PRESS);
window->minimized = minimized;
// Handle title bar drag
if ( minBtn == BUTTON_NONE )
{
if ( ImguiMouseOver(window->pos, titleBarDimen) )
{
if( ImguiDidMouseJustGoDown() && ImguiIsWindowActive() )
{
// double click
if ( ImguiMouseDoubleClick() )
{
window->minimized = !window->minimized;
}
ImguiSetActiveWidgetId(id);
ImguiState().data.ivec[0] = mousePos.x - window->pos.x;
ImguiState().data.ivec[1] = mousePos.y - window->pos.y;
}
}
}
}
void ImguiWindowBG(StrongHandle<ImguiWindow> &window)
{
const float ALPHA_INACTIVE = 0.6f;
const float ALPHA_HOVER = 0.7f;
const float ALPHA_ACTIVE = 0.97f;
float bgAlpha = ALPHA_INACTIVE;
ImguiManager * imgui = ImguiManager::Get();
// handle case where the bar is minimized
v2i dimen = window->dimen;
if ( window->minimized ) dimen.y = TITLE_BAR_HEIGHT;
// hovering over
if ( ImguiMouseOver(window->pos, dimen) )
{
bgAlpha = ALPHA_HOVER;
// current active
StrongHandle<ImguiWindow> & prevActiveWindow = ImguiState().activeWindow;
// make sure the mouse is not active window
if ( ImguiDidMouseJustGoDown() &&
( !prevActiveWindow
|| prevActiveWindow->framesSinceUpdate > 1
|| (!ImguiMouseOver(prevActiveWindow->pos, prevActiveWindow->dimen))) )
{
ImguiSetActiveWindow(window);
}
// mouse scroll
else if ( ImguiIsWindowActive() && !window->autosize )
{
const float scrollDelta = MOUSEWHEEL_SCROLL_DELTA / max(1,window->dimenAutosize.y);
if ( Input::Get()->DidMouseWheelHit(Input::MOUSEWHEEL_DOWN) )
{
window->scrollPos.y = min( window->scrollPos.y+scrollDelta, 1.0f );
}
else if ( Input::Get()->DidMouseWheelHit(Input::MOUSEWHEEL_UP) )
{
window->scrollPos.y = max( window->scrollPos.y-scrollDelta, 0.0f );
}
}
}
if ( ImguiIsWindowActive() )
{
bgAlpha = ALPHA_ACTIVE;
}
if ( !ImguiIsMinized() )
{
ImguiColor(COLOR_WINDOW_BG, bgAlpha );
ImguiDrawRect( window->pos, window->dimen );
}
}
bool ImguiHorizScrollBar(StrongHandle<ImguiWindow> &window)
{
if( ImguiIsMinized() ) return false;
const int id = ID_SCROLL_X;
// calculate how much bar is shown
int totalWidthAllWidgets = window->dimenAutosize.x;
if ( totalWidthAllWidgets <= 0) totalWidthAllWidgets = 1;
const int barWidth = window->dimen.x-1;
const float percentShown = (float)barWidth/totalWidthAllWidgets;
// don't show bar if not needed
if ( percentShown >= 1.0f )
{
window->scrollPos.x = 0.0f;
return false;
}
if ( !ImguiIsWindowActive() ) return false;
// bar
v3 barColor = COLOR_BAR;
v2i barPos = v2i( window->pos.x+1, window->pos.y-window->dimen.y );
v2i barDimen = v2i( barWidth, SCROLL_BAR_SIZE );
// slider
v3 sliderColor = COLOR_SLIDER;
v2i sliderDimen = v2i( (int)(barDimen.x*percentShown), SCROLL_BAR_SIZE );
int sliderPosMinX = barPos.x;
int sliderPosMaxX = barPos.x + barDimen.x - sliderDimen.x;
v2i sliderPos = v2i( (int)lerp((float)sliderPosMinX, (float)sliderPosMaxX, window->scrollPos.x), barPos.y );
const int mouseX = ImguiGetMousePos().x;
// mouse over
if ( ImguiMouseOver(barPos, barDimen) )
{
barColor = COLOR_BAR_HOVER;
if ( ImguiDidMouseJustGoDown() )
{
ImguiSetActiveWidgetId(id);
if ( ImguiMouseOver(sliderPos, sliderDimen) ) // over slider
{
ImguiState().data.i = mouseX - sliderPos.x;
}
else // not over slider, chose half the position
{
ImguiState().data.i = sliderDimen.x >> 1;
}
}
}
if ( ImguiIsWidgetActive(id) )
{
// release mouse
if ( ImguiDidMouseJustGoUp() )
{
ImguiSetActiveWidgetId(ImguiManager::State::WIDGET_NULL);
}
// bar position based on mouse pos
else
{
int xMin = barPos.x + ImguiState().data.i;
int xMax = barPos.x + barDimen.x - sliderDimen.x + ImguiState().data.i;
window->scrollPos.x = saturate(((float)mouseX - xMin)/(xMax-xMin));
}
}
if ( ImguiIsWidgetActive(id) ) sliderColor = COLOR_SLIDER_ACTIVE;
// draw background
ImguiColor( barColor );
ImguiDrawRect( barPos, barDimen );
ImguiColor( COLOR_SLIDER_BG_BORDER );
ImguiDrawRectWire( barPos, barDimen );
// draw slider
ImguiColor( sliderColor );
ImguiDrawRect( sliderPos, sliderDimen );
ImguiColor( COLOR_SLIDER_BTN_BORDER );
ImguiDrawRectWire( sliderPos, sliderDimen );
return true;
}
bool ImguiVertScrollBar(StrongHandle<ImguiWindow> &window)
{
if( ImguiIsMinized() ) return false;
const int id = ID_SCROLL_Y;
// calculate how much bar is shown
int totalHeightAllWidgets = window->dimenAutosize.y-TITLE_BAR_HEIGHT;
if ( totalHeightAllWidgets <= 0) totalHeightAllWidgets = 1;
const int barHeight = window->dimen.y-TITLE_BAR_HEIGHT;
const float percentShown = (float)barHeight/totalHeightAllWidgets;
// don't show bar if not needed
if ( percentShown >= 1.0f )
{
window->scrollPos.y = 0.0f;
return false;
}
if ( !ImguiIsWindowActive() ) return false;
// bar
v3 barColor = COLOR_BAR;
v2i barPos = v2i( window->pos.x+window->dimen.x, window->pos.y-TITLE_BAR_HEIGHT );
v2i barDimen = v2i( SCROLL_BAR_SIZE, barHeight );
// slider
v3 sliderColor = COLOR_SLIDER;
v2i sliderDimen = v2i( SCROLL_BAR_SIZE, (int)(barDimen.y*percentShown) );
int sliderPosMinY = barPos.y;
int sliderPosMaxY = barPos.y - barDimen.y + sliderDimen.y;
v2i sliderPos = v2i( barPos.x, (int)lerp((float)sliderPosMinY, (float)sliderPosMaxY, window->scrollPos.y) );
const int mouseY = ImguiGetMousePos().y;
// mouse over
if ( ImguiMouseOver(barPos, barDimen) )
{
barColor = COLOR_BAR_HOVER;
if ( ImguiDidMouseJustGoDown() )
{
ImguiSetActiveWidgetId(id);
if ( ImguiMouseOver(sliderPos, sliderDimen ) ) // over slider
{
ImguiState().data.i = sliderPos.y - mouseY;
}
else // not over slider, chose half the position
{
ImguiState().data.i = sliderDimen.y >> 1;
}
}
}
if ( ImguiIsWidgetActive(id) )
{
// release mouse
if ( ImguiDidMouseJustGoUp() )
{
ImguiSetActiveWidgetId(ImguiManager::State::WIDGET_NULL);
}
// bar position based on mouse pos
else
{
int yMin = barPos.y - ImguiState().data.i;
int yMax = barPos.y - barDimen.y + sliderDimen.y - ImguiState().data.i;
window->scrollPos.y = saturate(((float)mouseY - yMin)/(yMax-yMin));
}
}
if ( ImguiIsWidgetActive(id) ) sliderColor = COLOR_SLIDER_ACTIVE;
// draw background
ImguiColor( barColor );
ImguiDrawRect( barPos, barDimen );
ImguiColor( COLOR_SLIDER_BG_BORDER );
ImguiDrawRectWire( barPos, barDimen );
// draw slider
ImguiColor( sliderColor );
ImguiDrawRect( sliderPos, sliderDimen );
ImguiColor( COLOR_SLIDER_BTN_BORDER );
ImguiDrawRectWire( sliderPos, sliderDimen );
return true;
}
void ImguiResizeButton(StrongHandle<ImguiWindow> &window)
{
if( ImguiIsMinized() || !ImguiIsWindowActive() ) return;
const int id = ID_RESIZE_BUTTON;
const v2i pos = window->pos + v2i(window->dimen.x, -window->dimen.y);
const v2i dimen = v2i(SCROLL_BAR_SIZE);
const v2i mousePos = ImguiGetMousePos();
v3 color = COLOR_SLIDER;
// mouse over
if ( ImguiMouseOver(pos,dimen) )
{
color = COLOR_BUTTON_HOVER;
// clicked on button
if ( ImguiDidMouseJustGoDown() )
{
ImguiSetActiveWidgetId(id);
// cache mouse pos and offset
ImguiState().data.ivec[0] = mousePos.x;
ImguiState().data.ivec[1] = mousePos.y;
ImguiState().data.ivec[2] = mousePos.x - pos.x;
ImguiState().data.ivec[3] = mousePos.y - pos.y;
}
}
if ( ImguiIsWidgetActive(id) )
{
color = COLOR_BUTTON_PRESS;
// release
if ( ImguiDidMouseJustGoUp() )
{
ImguiSetActiveWidgetId(ImguiManager::State::WIDGET_NULL);
}
else
{
// resize window
window->dimen.x = max( window->titleBarMinWidth+SCROLL_BAR_SIZE, mousePos.x - window->pos.x - ImguiState().data.ivec[2] );
window->dimen.y = max( TITLE_BAR_HEIGHT+SCROLL_BAR_SIZE, window->pos.y - mousePos.y + ImguiState().data.ivec[3] );
}
}
// background
ImguiColor(color);
ImguiDrawRect( pos, dimen );
ImguiColor(COLOR_BLACK);
ImguiDrawRectWire( pos, dimen );
// line
const int LINE_PADDING = 2;
v2i linePosStart = pos + v2i(LINE_PADDING, -SCROLL_BAR_SIZE+LINE_PADDING);
v2i linePosEnd = pos + v2i(SCROLL_BAR_SIZE-LINE_PADDING,-LINE_PADDING);
ImguiColor(COLOR_WHITE, ImguiIsWidgetActive(id) ? 0.85f : 0.5f );
ImguiDrawLine(linePosStart, linePosEnd);
}
void Imgui::Begin( const char* name, v2i pos, v2i dimen )
{
assert( name );
CHECK( ImguiWorkingWindow() == NULL, "Imgui::Begin('%s') Error - Forgot to call Imgui::End() on window '%s'", name, ImguiState().workingWindowTitle.c_str() );
const int id = ImguiGenWidgetId();
const v2i mousePos = ImguiGetMousePos();
const v2i windowSize = Window::Get()->Sizei();
// setup render
ImguiManager::Get()->GetCam().Begin();
Renderer::Get()->BeginDefaultShader();
glEnable(GL_BLEND);
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_DEPTH_TEST);
glDisable(GL_LINE_SMOOTH);
glDisable(GL_CULL_FACE);
glDisable(GL_LINE_SMOOTH);
glLineWidth(1.0f);
glViewport(0,0, windowSize.x, windowSize.y);
// get window
ImguiManager * mngr = ImguiManager::Get();
StrongHandle<ImguiWindow> window = mngr->GetWindow(name);
window->framesSinceUpdate = 0;
ImguiState().workingWindow = window;
ImguiState().workingWindowTitle = name;
// remove any tabbing
ImguiState().numTabs = 0;
// on first creation of window
if ( window->isNewWindow )
{
// dimensions
window->dimen = dimen;
window->autosize = ( dimen == v2i(Imgui::AUTOSIZE) );
// autosize
if ( window->autosize ) window->dimen = v2i(0);
window->pos = pos;
}
// handle dragging window
if ( ImguiIsWidgetActive(id) )
{
if ( ImguiDidMouseJustGoUp() )
{
ImguiSetActiveWidgetId(ImguiManager::State::WIDGET_NULL);
}
else
{
v2i delta = v2i( ImguiState().data.ivec[0], ImguiState().data.ivec[1] );
window->pos = mousePos-delta;
}
}
ImguiWindowBG(window);
ImguiTitleBar(window, name, id );
// show scroll bars
if( !window->autosize )
{
bool showHorizScroll = ImguiHorizScrollBar(window);
bool showVertScroll = ImguiVertScrollBar(window);
// only show resize button if any scrollbars are visible
//if ( showHorizScroll || showVertScroll )
{
ImguiResizeButton(window);
}
}
// scissor around box (not the title bar or scrollers)
glEnable(GL_SCISSOR_TEST);
glScissor(window->pos.x, window->pos.y-window->dimen.y, max(0,window->dimen.x-1), max(0,window->dimen.y-TITLE_BAR_HEIGHT-1) );
glMatrixMode( GL_MODELVIEW );
glPushMatrix();
// figure out translation offset
int translateX = int(-(window->dimenAutosize.x-window->dimen.x) * window->scrollPos.x);
int translateY = int((window->dimenAutosize.y-window->dimen.y) * window->scrollPos.y);
ImguiState().scrollOffset = -v2i(translateX, translateY);
glTranslatef( (float)translateX, (float)translateY, 0.0f );
// where the mouse can interact
ImguiState().mouseRegionStart = window->pos - v2i(0, TITLE_BAR_HEIGHT);
ImguiState().mouseRegionDimen = window->dimen - v2i(0, TITLE_BAR_HEIGHT);
// determine size through imgui calls
window->dimenAutosize = v2i(0);
MoveDrawPosNextLine( v2i(0,WINDOW_INSIDE_PADDING-WIDGET_PADDING) );
}
void Imgui::End()
{
CHECK( ImguiWorkingWindow() != NULL, "Imgui::End() called without existing working window" );
// editable region
const v2i windowSize = Window::Get()->Sizei();
ImguiState().mouseRegionStart = v2i(0, windowSize.y);
ImguiState().mouseRegionDimen = windowSize;
ImguiState().scrollOffset = v2i(0);
glMatrixMode( GL_MODELVIEW );
glPopMatrix();
// end render state
glDisable(GL_SCISSOR_TEST);
ImguiManager * mngr = ImguiManager::Get();
Renderer::Get()->EndDefaultShader();
ImguiManager::Get()->GetCam().End();
// disable working window
StrongHandle<ImguiWindow> window = ImguiWorkingWindow();
window->isNewWindow = false;
// will use title bar width if that is bigger
window->dimenAutosize.x = max( window->dimenAutosize.x, window->titleBarMinWidth );
// add window padding
window->dimenAutosize += v2i(WINDOW_INSIDE_PADDING, WINDOW_INSIDE_PADDING-WIDGET_PADDING);
// if autosized
if ( window->autosize ) window->dimen = window->dimenAutosize;
ImguiState().workingWindow = NULL;
ImguiState().widgetCount = 0;
ImguiState().workingWindowTitle = "";
}
bool Imgui::Button( const char* name )
{
return ImguiButton(name) == BUTTON_PRESS;
}
bool Imgui::ButtonDown( const char* name )
{
return ImguiButton(name) == BUTTON_DOWN;
}
bool Imgui::ButtonHover( const char* name )
{
return ImguiButton(name) == BUTTON_HOVER;
}
bool Imgui::ButtonNoPadding( const char* name )
{
return ImguiButton(name, 0) == BUTTON_PRESS;
}
bool Imgui::ButtonDownNoPadding( const char* name )
{
return ImguiButton(name, 0) == BUTTON_DOWN;
}
bool Imgui::ButtonHoverNoPadding( const char* name )
{
return ImguiButton(name, 0) == BUTTON_HOVER;
}
void Imgui::Separator()
{
if( ImguiIsMinized() ) return;
const int PADDING = WIDGET_PADDING;
StrongHandle<ImguiWindow> window = ImguiWorkingWindow();
v2i pos = ImguiState().drawPos - v2i(0, PADDING);
v2i dimen = v2i(window->dimen.x, 0 );
ImguiColor(COLOR_BLACK, 0.6f);
ImguiDrawLine( pos, pos + v2i(window->dimen.x-WINDOW_INSIDE_PADDING*2, 0) );
ImguiColor(COLOR_SEPARATOR);
ImguiDrawLine( pos-v2i(0,1), pos -v2i(0,1) + v2i(window->dimen.x-WINDOW_INSIDE_PADDING*2, 0) );
MoveDrawPosNextLine( v2i(1,dimen.y+PADDING*2+1) );
}
float ImguiSlider( int id, float percent )
{
const int SLIDER_WIDTH = 150;
const int SLIDER_HEIGHT = Imgui::FONT_HEIGHT;
const int BUTTON_WIDTH = 10;
v2i pos = ImguiState().drawPos;
v2i dimen = v2i( SLIDER_WIDTH, SLIDER_HEIGHT );
// extend size if not autosized
if( !ImguiWorkingWindow()->autosize )
{
dimen.x = max( dimen.x, ImguiWorkingWindow()->dimen.x - WIDGET_PADDING*2 - WINDOW_INSIDE_PADDING*2 - Imgui::FONT_WIDTH*15 );
}
v3 colorBar = COLOR_BAR;
v3 colorButton = COLOR_SLIDER;
// button position
int xMin = pos.x+BUTTON_WIDTH/2;
int xMax = pos.x+dimen.x-BUTTON_WIDTH/2;
if ( ImguiMouseOver(pos,dimen) )
{
colorBar = COLOR_BAR_HOVER;
// clicked down
if ( ImguiDidMouseJustGoDown() && ImguiIsWindowActive() )
{
ImguiSetActiveWidgetId(id);
ImguiState().data.f = 0.0f;
}
}
if ( ImguiIsWidgetActive(id) )
{
// released
if ( ImguiDidMouseJustGoUp() )
{
ImguiSetActiveWidgetId(ImguiManager::State::WIDGET_NULL);
}
colorButton = COLOR_SLIDER_ACTIVE;
}
// background
ImguiColor( colorBar );
ImguiDrawRect( pos, dimen );
ImguiColor( COLOR_SLIDER_BG_BORDER );
ImguiDrawRectWire( pos, dimen );
// draw button
int xPos = (int)lerp((float)xMin, (float)xMax, saturate(percent) );
v2i buttonDimen = v2i(BUTTON_WIDTH, SLIDER_HEIGHT-1 );
v2i buttonPos = v2i( xPos-BUTTON_WIDTH/2, pos.y );
ImguiColor( colorButton );
ImguiDrawRect( buttonPos, buttonDimen );
ImguiColor( COLOR_SLIDER_BTN_BORDER );
ImguiDrawRectWire( buttonPos, buttonDimen );
// move draw cursor
MoveDrawPosNextLine( dimen );
// do this after draw call because some buttons need to snap
if ( ImguiIsWidgetActive(id) )
{
int mouseX = ImguiGetMousePos().x;
percent = saturate( float(mouseX - xMin)/(xMax-xMin) );
}
return percent;
}
float Imgui::SliderFloat( const char* name, float & val, float min, float max )
{
if( ImguiIsMinized() ) return val;
const int id = ImguiGenWidgetId();
Print(name);
// calc value
float sliderVal = min + ImguiSlider(id, (val-min)/(max-min) )*(max-min);
if ( ImguiIsWidgetActive(id) ) val = sliderVal;
// print text
SameLine();
char buffer[32];
sprintf_s(buffer, "%0.4f", val);
Print(buffer);
return val;
}
int Imgui::SliderInt( const char* name, int & val, int min, int max )
{
if( ImguiIsMinized() ) return val;
const int id = ImguiGenWidgetId();
Print(name);
// calc value
int sliderVal = min + (int)(ImguiSlider(id, float(val-min)/(max-min) )*max);
sliderVal = std::min<int>(sliderVal, max);
if ( ImguiIsWidgetActive(id) ) val = sliderVal;
// print text
SameLine();
char buffer[32];
sprintf_s(buffer, "%d", val);
Print(buffer);
return val;
}
funk::v2 Imgui::SliderV2( const char* name, v2 & val, v2 min, v2 max )
{
if( ImguiIsMinized() ) return val;
const int id = ImguiGenWidgetId();
Print(name);
SliderFloat( NULL, val.x, min.x, max.x );
SliderFloat( NULL, val.y, min.y, max.y );
return val;
}
funk::v3 Imgui::SliderV3( const char* name, v3 & val, v3 min, v3 max )
{
if( ImguiIsMinized() ) return val;
const int id = ImguiGenWidgetId();
Print(name);
SliderFloat( NULL, val.x, min.x, max.x );
SliderFloat( NULL, val.y, min.y, max.y );
SliderFloat( NULL, val.z, min.z, max.z );
return val;
}
funk::v3 Imgui::SliderRGB( const char* name, v3 & val )
{
if( ImguiIsMinized() ) return val;
const int id = ImguiGenWidgetId();
Print(name);
// draw color block
SameLine();
v2i pos = ImguiState().drawPos;
v2i dimen = v2i(Imgui::FONT_HEIGHT*2, Imgui::FONT_HEIGHT);
ImguiColor( val );
ImguiDrawRect( pos, dimen );
ImguiColor( COLOR_BLACK );
ImguiDrawRectWire( pos, dimen );
MoveDrawPosNextLine(dimen);
const v3 min(0.0f);
const v3 max(1.0f);
SliderFloat( NULL, val.x, min.x, max.x );
SliderFloat( NULL, val.y, min.y, max.y );
SliderFloat( NULL, val.z, min.z, max.z );
return val;
}
funk::v3 Imgui::SliderHSV( const char* name, v3 & rgb )
{
if( ImguiIsMinized() ) return rgb;
const int id = ImguiGenWidgetId();
Print(name);
// draw color block
SameLine();
v2i pos = ImguiState().drawPos;
v2i dimen = v2i(Imgui::FONT_HEIGHT*2, Imgui::FONT_HEIGHT);
ImguiColor( rgb );
ImguiDrawRect( pos, dimen );
ImguiColor( COLOR_BLACK );
ImguiDrawRectWire( pos, dimen );
MoveDrawPosNextLine(dimen);
const v3 min(0.0f);
const v3 max(1.0f);
v3 hsv = RGBtoHSV(rgb);
SliderFloat( NULL, hsv.x, 0.0f, 2.0f*PI-0.01f );
SliderFloat( NULL, hsv.y, min.y, max.y );
SliderFloat( NULL, hsv.z, min.z, max.z );
rgb = HSVtoRGB(hsv);
return rgb;
}
void Imgui::Print( const char * text )
{
if( ImguiIsMinized() || !text ) return;
int textWidth = ImguiTextWidth(text);
ImguiColor(COLOR_WHITE);
ImguiPrint(text, ImguiState().drawPos );
MoveDrawPosNextLine( v2i(textWidth, Imgui::FONT_HEIGHT) );
}
void Imgui::PrintParagraph( const char * text )
{
if( ImguiIsMinized() || !text ) return;
int srcLen = strlen(text);
int offset = 0;
int lineNumber = 1;
const char * textPos = text;
while( textPos-text < srcLen )
{
const char * endPos = strchr( textPos, '\n' );
if ( endPos == NULL ) endPos = text+srcLen;
// copy line
char buffer[256];
int len = min( (int)(endPos-textPos), (int)sizeof(buffer)-1);
memcpy(buffer, textPos, len);
buffer[len] = 0;
textPos = endPos+1;
Imgui::Print(buffer);
}
}
void Imgui::SameLine()
{
if( ImguiIsMinized() ) return;
ImguiState().drawPos = ImguiState().drawPosPrev;
}
bool Imgui::CheckBox( const char* name, bool &val )
{
if( ImguiIsMinized() ) return val;
if ( ImguiButton(val ? " X " : " ", 0) == BUTTON_PRESS )
{
val = !val;
}
SameLine();
Print(name);
return val;
}
int Imgui::Select( const char* names[], int &val, int numChoices )
{
if( ImguiIsMinized() ) return val;
for( int i = 0; i < numChoices; ++i )
{
if ( ImguiButton( i==val ? " * " : " ", 0) == BUTTON_PRESS )
{
val = i;
}
SameLine();
Print(names[i]);
}
return val;
}
int Imgui::SelectCustom( const char* names[], int* values, int &val, int numChoices )
{
if( ImguiIsMinized() ) return val;
for( int i = 0; i < numChoices; ++i )
{
if ( ImguiButton( i==val ? " * " : " ", 0) == BUTTON_PRESS )
{
val = values[i];
}
SameLine();
Print(names[i]);
}
return val;
}
int Imgui::DropDown( const char* name, bool &val )
{
if( ImguiIsMinized() ) return val;
if ( ImguiButton(val ? " V " : " > ", 0) == BUTTON_PRESS )
{
val = !val;
}
SameLine();
Print(name);
return val;
}
void ImguiFillBar(float percent)
{
v2i pos = ImguiState().drawPos;
v2i dimen = v2i( FILLBAR_WIDTH, FILLBAR_HEIGHT );
ImguiColor( COLOR_BAR );
ImguiDrawRect( pos, dimen );
ImguiColor( COLOR_BLACK, 0.5f );
ImguiDrawRectWire( pos, dimen );
ImguiColor( COLOR_FILLBAR );
ImguiDrawRect( pos, v2i((int)(dimen.x*saturate(percent)), dimen.y) );
}
void Imgui::FillBarFloat( const char* name, float val, float min, float max )
{
if( ImguiIsMinized() ) return;
// title
Imgui::Print( name );
// bar
float percent = (float)(val-min)/(max-min);
ImguiFillBar(percent);
v2i pos = ImguiState().drawPos;
v2i dimen = v2i( FILLBAR_WIDTH, FILLBAR_HEIGHT );
// text on top
char buffer[32];
sprintf_s(buffer, "%f", val);
ImguiColor(COLOR_WHITE);
ImguiPrint(buffer, pos+v2i(FILLBAR_TEXT_BUFFER,-FILLBAR_TEXT_BUFFER));
MoveDrawPosNextLine( dimen );
}
void Imgui::FillBarV2( const char* name, v2 val, v2 min, v2 max )
{
if( ImguiIsMinized() ) return;
Imgui::Print( name );
Imgui::FillBarFloat(NULL, val.x, min.x, max.x);
Imgui::FillBarFloat(NULL, val.y, min.y, max.y);
}
void Imgui::FillBarV3( const char* name, v3 val, v3 min, v3 max )
{
if( ImguiIsMinized() ) return;
Imgui::Print( name );
Imgui::FillBarFloat(NULL, val.x, min.x, max.x);
Imgui::FillBarFloat(NULL, val.y, min.y, max.y);
Imgui::FillBarFloat(NULL, val.z, min.z, max.z);
}
void Imgui::FillBarInt( const char* name, int val, int min, int max )
{
if( ImguiIsMinized() ) return;
// title
Imgui::Print( name );
// bar
float percent = (float)(val-min)/(max-min);
ImguiFillBar(percent);
v2i pos = ImguiState().drawPos;
v2i dimen = v2i( FILLBAR_WIDTH, FILLBAR_HEIGHT );
// text on top
char buffer[32];
sprintf_s(buffer, "%d", val);
ImguiColor(COLOR_WHITE);
ImguiPrint(buffer, pos+v2i(FILLBAR_TEXT_BUFFER,-FILLBAR_TEXT_BUFFER));
MoveDrawPosNextLine( dimen );
}
int Imgui::TextInput( const char* name, std::string& val, int width )
{
const float KEYPRESS_COOLDOWN = 0.4f;
const float KEYHOLD_COOLDOWN = 0.04f;
// time
static Timer timer;
static float prevFrameTime = 0.0f;
float currTime = timer.GetTimeSecs();
float dt = currTime - prevFrameTime;
prevFrameTime = currTime;
if( ImguiIsMinized() ) return 0;
const int id = ImguiGenWidgetId();
// title
Imgui::Print( name );
v2i pos = ImguiState().drawPos;
v2i dimen = v2i( width, FILLBAR_HEIGHT );
v3 colorBar = COLOR_BAR;
v3 colorBorder = COLOR_BLACK;
int numCharSlots = (dimen.x - FILLBAR_TEXT_BUFFER*2) / Imgui::FONT_WIDTH;
// get carret pos
int & caretStart = ImguiState().data.ivec[0];
int & caretPos = ImguiState().data.ivec[1];
if ( ImguiIsWidgetActive(id) )
{
caretStart = clamp( caretStart, 0, max(0, (int)val.size()-1) );
if( (int)val.size() <= numCharSlots ) caretStart = 0;
caretPos = clamp( caretPos, caretStart, caretStart + min(numCharSlots-1, (int)val.size()) );
}
float & heldKeyCooldown = ImguiState().data.fvec[2];
if ( ImguiMouseOver(pos,dimen) )
{
colorBar = COLOR_BAR_HOVER;
// clicked down
if ( ImguiDidMouseJustGoDown() && !ImguiIsWidgetActive(id) && ImguiIsWindowActive() )
{
ImguiSetActiveWidgetId(id);
caretStart = max( (int)val.size() - numCharSlots + 1, 0 ); // start
caretPos = caretStart + min(numCharSlots-1, (int)val.size()); // position
heldKeyCooldown = 0.0f;
}
}
// highlight if active
if ( ImguiIsWidgetActive(id) )
{
colorBorder = COLOR_WHITE;
int caretDelta = 0;
// did press a key
char c = Input::Get()->GetKeyDown();
if ( c != 0 && c != Input::KEY_BACKSPACE )
{
if ( c == Input::KEY_RETURN )
{
//ImguiSetActiveWidgetId(ImguiManager::State::WIDGET_NULL);
return 1;
}
else // append character
{
val.insert( caretPos, 1, c );
++caretDelta;
}
}
// handle special cases
else
{
// keys that can be held down
const char * heldKey = NULL;
const char* holdableKeys[] = {"LEFT", "RIGHT", "DELETE", "BACKSPACE"};
for( int i = 0; i < sizeof(holdableKeys)/sizeof(holdableKeys[0]); ++i )
{
// just pressed down
if( Input::Get()->DidKeyJustGoDown(holdableKeys[i]) ) // firstime press
{
heldKeyCooldown = KEYPRESS_COOLDOWN;
heldKey = holdableKeys[i];
break;
}
else if ( Input::Get()->IsKeyDown(holdableKeys[i]) ) // held down
{
heldKeyCooldown -= dt;
if ( heldKeyCooldown <= 0.0f )
{
heldKeyCooldown = KEYHOLD_COOLDOWN;
heldKey = holdableKeys[i];
break;
}
}
}
if ( heldKey )
{
if( strcmp(heldKey, "LEFT") == 0 )
{
--caretDelta;
}
else if( strcmp(heldKey, "RIGHT") == 0 )
{
++caretDelta;
}
else if( strcmp(heldKey, "DELETE") == 0 )
{
if ( caretPos < (int)val.size() ) val.erase(caretPos, 1);
}
else if( strcmp(heldKey, "BACKSPACE") == 0 )
{
if ( !val.empty() && caretPos-1 >= 0 )
{
val.erase( caretPos-1, 1 );
--caretDelta;
}
}
}
else if ( Input::Get()->DidKeyJustGoDown("HOME"))
{
caretPos = caretStart = 0;
}
else if ( Input::Get()->DidKeyJustGoDown("END"))
{
caretStart = max( (int)val.size() - numCharSlots + 1, 0 ); // start
caretPos = caretStart + min(numCharSlots-1, (int)val.size()); // position
}
}
// move caret left
if ( caretDelta == -1 )
{
caretPos = max(caretPos-1, 0);
if ( caretPos < caretStart ) caretStart -= 1;
// handle case where deleting
if ( caretStart > 0 && caretPos >= (int)val.size() && (caretStart-caretPos)<numCharSlots )
{
--caretStart;
}
}
// move caret right
else if ( caretDelta == 1 )
{
if ( (int)val.size() > numCharSlots )
{
if( caretPos < (int)val.size() ) ++caretPos;
}
else if ( caretPos < (int)val.size() ) ++caretPos;
if ( caretPos-caretStart >= numCharSlots )
{
++caretStart;
}
}
}
// draw rect
ImguiColor( colorBar );
ImguiDrawRect(pos, dimen);
ImguiColor( colorBorder, 0.5f );
ImguiDrawRectWire(pos, dimen);
// tex position
v2i textPos = pos + v2i(FILLBAR_TEXT_BUFFER, -FILLBAR_TEXT_BUFFER);
int characterStart = 0;
int characterEnd = min( (int)val.size(), numCharSlots );
// substr with caret positions
if ( ImguiIsWidgetActive(id) )
{
characterStart = caretStart;
characterEnd = caretStart + numCharSlots;
}
// draw text
int numCharsPrint = min(characterEnd-characterStart, numCharSlots );
ImguiColor( COLOR_WHITE );
ImguiPrint( val.substr(characterStart,numCharsPrint).c_str(), textPos );
// do "text_" blinking
if ( ImguiIsWidgetActive(id) && fmod( timer.GetTimeSecs(), 1.0f ) < 0.5f )
{
v2i underlinePos = textPos + Imgui::FONT_WIDTH*v2i(caretPos-caretStart, 0);
ImguiPrint( "_", underlinePos-v2i(0,1) );
}
MoveDrawPosNextLine( dimen );
return 0;
}
void Imgui::Tab()
{
if( ImguiIsMinized() ) return;
ImguiState().drawPos.x += TAB_WIDTH;
++ImguiState().numTabs;
}
void Imgui::Untab()
{
if( ImguiIsMinized() ) return;
if ( ImguiState().numTabs > 0 )
{
ImguiState().drawPos.x -= TAB_WIDTH;
--ImguiState().numTabs;
}
}
void Imgui::Minimize()
{
StrongHandle<ImguiWindow> window = ImguiWorkingWindow();
if ( window->isNewWindow ) { window->minimized = true; }
}
void Imgui::Header( const char* name )
{
if( ImguiIsMinized() ) return;
const int HEADER_PADDING = 3;
const int HEADER_HEIGHT = Imgui::FONT_HEIGHT + HEADER_PADDING*3;
const int HEADER_WIDTH = FILLBAR_WIDTH;
const int HEADER_TOP_PADDING = 7;
ImguiState().drawPos.x = ImguiWorkingWindow()->pos.x;
ImguiState().drawPos.y -= HEADER_TOP_PADDING;
v2i pos = ImguiState().drawPos;
v2i dimen = v2i( ImguiWorkingWindow()->dimen.x, HEADER_HEIGHT );
const v3 HEADER_COLOR = v3(0.1f, 0.25f, 0.29f );
ImguiColor( COLOR_BAR_HOVER, ImguiIsWindowActive() ? 1.0f : 0.7f );
ImguiDrawRect( pos, dimen );
ImguiColor( COLOR_WHITE );
ImguiPrint(name, pos+v2i(HEADER_PADDING*2, -HEADER_PADDING));
// border around
ImguiColor( COLOR_WHITE,0.2f );
ImguiDrawRectWire( pos, dimen-v2i(0,1) );
MoveDrawPosNextLine(dimen+v2i(-WINDOW_INSIDE_PADDING-WIDGET_PADDING,HEADER_PADDING));
}
void Imgui::Lock( const char * gui )
{
StrongHandle<ImguiWindow> window = ImguiManager::Get()->GetWindow(gui);
assert(window);
window->locked = true;
if ( window == ImguiState().activeWindow )
{
ImguiManager::Get()->ClearActiveWindow();
}
}
void Imgui::Unlock( const char * gui )
{
StrongHandle<ImguiWindow> window = ImguiManager::Get()->GetWindow(gui);
assert(window);
window->locked = false;
}
void Imgui::SetScrollX( float x )
{
if( ImguiIsMinized() ) return;
ImguiWorkingWindow()->scrollPos.x = saturate(x);
}
void Imgui::SetScrollY( float y )
{
if( ImguiIsMinized() ) return;
ImguiWorkingWindow()->scrollPos.y = saturate(y);
}
bool Imgui::IsWindowActive()
{
return ImguiWorkingWindow() && (ImguiWorkingWindow() == ImguiState().activeWindow );
}
int Imgui::GetPrevWidgetId()
{
assert( ImguiState().workingWindow != NULL );
return ImguiState().widgetCount;
}
bool Imgui::IsWidgetActive(int id)
{
assert( id > 0 );
return IsWindowActive() && (ImguiState().activeWidgetId == id);
}
bool Imgui::IsWorkingWindowNew()
{
assert( ImguiState().workingWindow != NULL );
return ImguiState().workingWindow->isNewWindow;
}
void Imgui::SetActiveWidgetId(int id)
{
assert( ImguiState().workingWindow != NULL );
assert( id > 0 );
ImguiState().activeWidgetId = id;
ImguiState().activeWindow = ImguiState().workingWindow;
}
void Imgui::LineGraph( StrongHandle<funk::LineGraph> lineGraph )
{
assert(lineGraph);
if( ImguiIsMinized() ) return;
const v2i pos = ImguiState().drawPos;
const v2i dimen = lineGraph->Dimen();
lineGraph->DrawBG( toV2(pos) );
lineGraph->Draw( toV2(pos) );
MoveDrawPosNextLine( dimen );
}
void Imgui::CubicSpline2d( StrongHandle<funk::CubicSpline2d> spline, v2 minPos, v2 maxPos, v2i dimen )
{
assert(spline);
if( ImguiIsMinized() ) return;
const int id = ImguiGenWidgetId();
const v2i pos = ImguiState().drawPos;
const v2 posf = toV2(pos);
const v2 dimenf = toV2(dimen);
const bool isMouseOverWidget = ImguiMouseOver(pos, dimen);
// drop box
ImguiColor( v3(0.2f, 0.2f, 0.2f), 0.8f );
ImguiDrawRect( pos, dimen );
ImguiColor( v3(1.0f,1.0f,1.0f), isMouseOverWidget ? 1.0f : 0.6f );
ImguiDrawRectWire( pos, dimen );
// calc relative mouse pos, in spline space
const v2 mousePos = toV2(ImguiGetMousePos());
v2 mouseAlpha = (mousePos-posf+v2(0.0f,dimenf.y))/(dimenf);
mouseAlpha = saturate(mouseAlpha);
float newX = lerp(minPos.x, maxPos.x, mouseAlpha.x);
float newY = lerp(minPos.y, maxPos.y, mouseAlpha.y);
const v2 mousePosSpline = v2(newX, newY);
// draw grid
int numLines = 9;
ImguiColor( COLOR_WHITE, 0.1f );
const v2i boxMinPos = pos + v2i(0, -dimen.y);
const v2i boxMaxPos = boxMinPos + dimen;
for ( int i = 0; i <= numLines+1; ++i )
{
float alpha = (float)i/(numLines+1);
int x = lerp( boxMinPos.x, boxMaxPos.x, alpha );
int y = lerp( boxMinPos.y, boxMaxPos.y, alpha );
ImguiDrawLine( v2i(x, boxMinPos.y), v2i(x, boxMaxPos.y));
ImguiDrawLine( v2i(boxMinPos.x, y), v2i(boxMaxPos.x, y));
}
// draw curve
ImguiColor( COLOR_WHITE, 0.3f );
const int numCurvePts = 128;
const float deltaT = 1.0f / numCurvePts;
for( int i = 0; i < numCurvePts; ++i )
{
float t0 = deltaT*i;
float t1 = deltaT*(i+1);
const v2 pt0 = spline->CalcPosAt(t0);
const v2 pt1 = spline->CalcPosAt(t1);
// position in the widget
const v2 alpha0 = (pt0 - minPos)/(maxPos-minPos);
const v2 alpha1 = (pt1 - minPos)/(maxPos-minPos);
const v2 relPos0 = posf + dimenf*alpha0 - v2(0, dimenf.y);
const v2 relPos1 = posf + dimenf*alpha1 - v2(0, dimenf.y);
ImguiDrawLine( toV2i(relPos0), toV2i(relPos1) );
}
// draw control points
const int numControlPts = spline->NumControlPts();
const int ptSize = 14;
int & selectedPtIndex = ImguiState().data.i;
int mouseOverPtIndex = -1;
for( int i = 0; i < numControlPts; ++i )
{
const v2 pt = spline->GetControlPt(i);
const v2 alpha = (pt - minPos)/(maxPos-minPos);
const v2 relPos = posf + dimenf*alpha - v2(0, dimenf.y);
const v2i ptPos = toV2i(relPos)+v2i(-ptSize>>1, +ptSize>>1);
const v2i ptDimen = v2i(ptSize);
bool isMouseOverPt = ImguiMouseOver(ptPos,ptDimen);
mouseOverPtIndex = ImguiIsWidgetActive(id) ? selectedPtIndex : mouseOverPtIndex != -1 ?mouseOverPtIndex: isMouseOverPt?i:-1;
// draw box border around control pt
if ( isMouseOverWidget )
{
// select color
if ( ImguiIsWidgetActive(id) && selectedPtIndex == i )
{
ImguiColor(v3(1.0f,1.0f,1.0f) );
}
else if ( isMouseOverPt )
{
ImguiColor(v3(1.0f,0.7f,0.0f) );
}
else
{
ImguiColor(v3(1.0f,0.0f,0.0f) );
}
ImguiDrawRectWire(ptPos, ptDimen);
}
ImguiColor(v3(1.0f,1.0f,1.0f) );
ImguiDrawPoint(toV2i(relPos), 2.0f);
// handle mouse active
if ( ImguiIsWidgetActive(id) )
{
// released
if ( ImguiDidMouseJustGoUp() )
{
ImguiSetActiveWidgetId( ImguiManager::State::WIDGET_NULL );
}
else if ( i == selectedPtIndex )
{
spline->SetControlPt( i, mousePosSpline );
}
}
else if ( isMouseOverPt && ImguiDidMouseJustGoDown() ) // click down
{
ImguiSetActiveWidgetId(id);
ImguiState().data.i = i;
}
}
MoveDrawPosNextLine( dimen );
char buffer[64];
ImguiColor(COLOR_WHITE);
if ( mouseOverPtIndex != -1 )
{
const v2 ptPos = spline->GetControlPt(mouseOverPtIndex);
sprintf_s( buffer, "(%.3f, %.3f)", ptPos.x, ptPos.y );
ImguiPrint(buffer, ImguiGetMousePos()+v2i(-Imgui::FONT_WIDTH*5, Imgui::FONT_HEIGHT*2) );
}
else if ( isMouseOverWidget )
{
sprintf_s( buffer, "(%.3f, %.3f)", mousePosSpline.x, mousePosSpline.y );
ImguiPrint(buffer, ImguiGetMousePos()+v2i(-Imgui::FONT_WIDTH*5, Imgui::FONT_HEIGHT*2) );
ImguiDrawPoint(ImguiGetMousePos(), 4.0f);
}
}
} | [
"kalin.eh@gmail.com"
] | kalin.eh@gmail.com |
8d6c4a529e27af94fc07a3e0f615eb49a28a90d4 | 92e67b30497ffd29d3400e88aa553bbd12518fe9 | /assignment2/part6/Re=110/29.7/U | 693fa91ab369671dc5346fc9cb18b0d4b65bb324 | [] | no_license | henryrossiter/OpenFOAM | 8b89de8feb4d4c7f9ad4894b2ef550508792ce5c | c54b80dbf0548b34760b4fdc0dc4fb2facfdf657 | refs/heads/master | 2022-11-18T10:05:15.963117 | 2020-06-28T15:24:54 | 2020-06-28T15:24:54 | 241,991,470 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 63,096 | /*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "29.7";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField nonuniform List<vector>
2000
(
(0.000917271 -0.0067504 1.19653e-22)
(0.00357013 0.00879742 0)
(0.0079994 0.0389377 0)
(0.0120816 0.075191 2.77821e-22)
(0.0150637 0.112814 -5.51396e-23)
(0.0167162 0.149592 6.42361e-23)
(0.0172881 0.184793 8.34226e-23)
(0.0172026 0.218112 0)
(0.0167211 0.248963 0)
(0.0159324 0.276359 0)
(0.0015989 -0.00770673 0)
(0.00381377 0.00609647 2.37851e-22)
(0.00747947 0.0350795 -2.19336e-22)
(0.0109498 0.0709632 -3.97922e-22)
(0.0136067 0.108892 0)
(0.0151268 0.14629 7.02682e-23)
(0.0156201 0.182089 -6.53443e-23)
(0.0154281 0.215855 0)
(0.0148091 0.247086 9.41682e-22)
(0.0138387 0.274975 -2.12055e-21)
(0.00239029 -0.00870574 0)
(0.00434532 0.00295252 -5.12354e-22)
(0.00731346 0.0301708 0)
(0.0102097 0.0650483 4.67047e-22)
(0.0126096 0.102786 0)
(0.0141265 0.14052 -1.37397e-21)
(0.0147169 0.176823 0)
(0.0146043 0.211063 2.1502e-21)
(0.014022 0.242769 -2.0138e-21)
(0.0130167 0.271285 -3.01631e-21)
(0.00327334 -0.00966074 8.40835e-23)
(0.00516455 -0.000466543 4.97131e-22)
(0.0075146 0.0243928 -5.96389e-23)
(0.00985387 0.0575576 1.46009e-22)
(0.012008 0.0944757 -5.66256e-22)
(0.013588 0.132138 3.28768e-22)
(0.014413 0.168785 9.71833e-22)
(0.01456 0.203515 5.67606e-23)
(0.0141969 0.235797 2.67797e-21)
(0.0133119 0.26505 3.00883e-21)
(0.00421437 -0.0104823 -8.54558e-23)
(0.00625724 -0.00395691 -6.27188e-22)
(0.00810294 0.0180189 -2.15403e-21)
(0.00990493 0.048742 7.93824e-22)
(0.0117775 0.0840826 0)
(0.013407 0.121078 0)
(0.0145306 0.157743 -3.20657e-21)
(0.0150809 0.192891 -3.45662e-21)
(0.0151189 0.225826 3.75275e-21)
(0.0145075 0.255905 1.19439e-20)
(0.0051702 -0.0110845 4.05961e-22)
(0.00760523 -0.00729455 7.06488e-22)
(0.00911647 0.0114037 -4.56543e-21)
(0.0104335 0.0390113 7.70095e-21)
(0.0119679 0.0719376 -1.38783e-21)
(0.0135543 0.107462 0)
(0.0149336 0.143558 0)
(0.0159465 0.178828 1.97748e-20)
(0.0165386 0.212371 -1.97013e-20)
(0.0163262 0.243286 4.06697e-21)
(0.00610018 -0.011405 5.16123e-21)
(0.00920267 -0.0102623 0)
(0.0106254 0.00496013 5.4298e-21)
(0.0115735 0.0289376 -6.19873e-21)
(0.0127331 0.0586472 0)
(0.0141346 0.0917525 4.26354e-21)
(0.0156137 0.126385 -1.28856e-20)
(0.0170174 0.161112 -1.71972e-20)
(0.0182389 0.194911 8.46815e-21)
(0.018429 0.226423 8.59858e-21)
(0.00698333 -0.0114152 -1.18487e-20)
(0.011076 -0.0126671 -1.91349e-21)
(0.0127466 -0.000867624 -4.51115e-21)
(0.0135315 0.0192328 -1.0947e-20)
(0.0143457 0.0451169 -4.70923e-21)
(0.0154284 0.0748738 -5.39896e-21)
(0.0167793 0.106938 -9.81928e-22)
(0.0183695 0.140044 0)
(0.0201863 0.173252 0)
(0.020629 0.204572 -1.5563e-22)
(0.00783658 -0.0111258 6.68769e-21)
(0.0133006 -0.0143579 -8.96544e-21)
(0.015649 -0.0056462 5.94033e-21)
(0.0165804 0.0106854 1.63869e-20)
(0.0171826 0.0324957 -4.73768e-21)
(0.017887 0.058234 4.37119e-21)
(0.0188896 0.0866657 4.92446e-21)
(0.0203931 0.116807 0)
(0.0227102 0.147979 0)
(0.0233148 0.177332 4.14312e-22)
(0.00872515 -0.0105811 -1.07941e-21)
(0.0160075 -0.0152415 1.15416e-20)
(0.0195406 -0.00900703 -2.37409e-21)
(0.0210269 0.00405329 0)
(0.0216702 0.022022 0)
(0.0220535 0.0435744 1.07495e-20)
(0.0225479 0.0677116 0)
(0.0236021 0.0936565 -1.11839e-20)
(0.0261373 0.120822 -9.59278e-23)
(0.0281841 0.145448 1.00197e-20)
(0.015056 0.3277 1.70136e-22)
(-0.00092206 0.386729 -1.72135e-22)
(-0.00151162 0.42177 -3.29925e-22)
(-0.00472593 0.43979 -4.31823e-22)
(-0.0064987 0.451465 -5.60277e-22)
(-0.00546056 0.466881 -2.6695e-23)
(-0.00962392 0.503251 2.99826e-22)
(-0.00143989 0.587489 1.04798e-21)
(-0.013208 0.744067 0)
(0.00514068 0.923052 -7.64315e-22)
(0.0122483 0.328009 3.60272e-22)
(-0.00207672 0.387169 -1.13188e-21)
(-0.00262641 0.421482 2.12946e-21)
(-0.00544498 0.439587 4.32607e-22)
(-0.00719288 0.45124 9.95599e-22)
(-0.00627476 0.466577 1.73275e-21)
(-0.0104471 0.50227 -6.41034e-22)
(-0.00250242 0.586719 -7.02882e-22)
(-0.0134451 0.742672 1.37443e-21)
(0.00443527 0.921142 7.62495e-22)
(0.0108182 0.326633 0)
(-0.00220514 0.386586 -9.88977e-22)
(-0.00304915 0.42089 -6.60644e-22)
(-0.00565218 0.439251 0)
(-0.00753167 0.450945 -3.09083e-21)
(-0.00682263 0.466032 9.66535e-22)
(-0.0110686 0.500928 1.11766e-21)
(-0.00346437 0.585165 3.85129e-21)
(-0.013654 0.740822 -1.36998e-21)
(0.00380095 0.919216 2.78455e-21)
(0.0106144 0.323408 0)
(-0.00143033 0.384991 9.97606e-22)
(-0.00284592 0.419862 0)
(-0.00540067 0.438694 3.52392e-21)
(-0.00752745 0.45055 -3.54148e-21)
(-0.00708296 0.465282 -2.23945e-21)
(-0.0114802 0.499189 -1.24017e-22)
(-0.00428732 0.58264 -3.78131e-21)
(-0.0137867 0.73802 -6.201e-22)
(0.00323025 0.916444 -3.42823e-21)
(0.0114458 0.318206 1.04477e-21)
(0.000119517 0.382647 -2.22497e-21)
(-0.00207762 0.41869 5.65604e-22)
(-0.00475685 0.438147 -2.89467e-21)
(-0.00723827 0.450179 0)
(-0.00710886 0.464466 -2.16064e-21)
(-0.0117442 0.497182 -1.62701e-22)
(-0.00502339 0.579625 4.80343e-21)
(-0.0139231 0.735212 6.29896e-22)
(0.00268797 0.914059 -6.3214e-22)
(0.0131389 0.310651 -6.3313e-21)
(0.00232417 0.378843 4.67853e-21)
(-0.000798346 0.416682 2.84538e-21)
(-0.00370825 0.437202 -2.84281e-21)
(-0.00660807 0.449641 -1.75788e-21)
(-0.00683132 0.463496 0)
(-0.0117813 0.494743 -4.35869e-21)
(-0.00556808 0.575561 2.18081e-21)
(-0.0139613 0.730889 2.34006e-21)
(0.00217703 0.910308 2.41882e-21)
(0.0153633 0.300715 -8.32665e-22)
(0.00504644 0.374716 0)
(0.000922277 0.415079 0)
(-0.00239894 0.436632 0)
(-0.00580728 0.449348 -1.92394e-21)
(-0.00641846 0.462675 3.675e-21)
(-0.01174 0.492403 4.27151e-21)
(-0.00608995 0.571772 -6.60732e-21)
(-0.0140898 0.727524 1.15233e-21)
(0.00167476 0.907866 -3.53677e-21)
(0.0180063 0.286718 4.87656e-21)
(0.00818215 0.367139 4.65214e-21)
(0.00311219 0.41123 -4.6072e-21)
(-0.000598042 0.434931 6.39298e-21)
(-0.00455102 0.448546 -7.99018e-21)
(-0.0055846 0.461509 0)
(-0.0113454 0.489338 -1.96175e-21)
(-0.00630514 0.566103 7.62967e-23)
(-0.0140322 0.721217 -2.11835e-21)
(0.00118935 0.902891 -2.20145e-21)
(0.0203714 0.271803 -4.2341e-21)
(0.0114836 0.362348 0)
(0.00541825 0.41006 -6.09815e-21)
(0.00107056 0.43489 1.16629e-20)
(-0.00346966 0.448726 -4.4984e-21)
(-0.00490829 0.461136 -8.9317e-22)
(-0.011081 0.487505 1.95759e-21)
(-0.00670467 0.562833 1.70434e-23)
(-0.0142425 0.718447 3.08091e-21)
(0.000723764 0.901127 3.20861e-21)
(0.0239887 0.243042 -3.87659e-21)
(0.0152058 0.345398 3.7629e-21)
(0.00862114 0.401698 6.02259e-22)
(0.00388329 0.431307 0)
(-0.00139424 0.447123 0)
(-0.00333979 0.459393 8.59323e-22)
(-0.0100758 0.483116 3.67475e-21)
(-0.00644012 0.55427 -3.58066e-21)
(-0.0140052 0.708858 -9.39879e-22)
(0.000237132 0.894254 9.06071e-22)
(0.025781 0.232945 0)
(0.0246477 0.348248 0)
(0.0139127 0.407015 0)
(0.00703732 0.436104 0)
(0.000587933 0.450999 0)
(-0.00224528 0.462533 0)
(-0.00960987 0.484984 0)
(-0.00784643 0.555481 0)
(-0.0151324 0.709413 0)
(-0.000701598 0.894585 0)
(0.0292761 0.237797 0)
(0.0378242 0.353344 0)
(0.0279366 0.414579 0)
(0.0181324 0.443463 0)
(0.00827173 0.457548 0)
(0.00298534 0.468764 0)
(-0.00535541 0.489282 0)
(-0.00533722 0.555769 0)
(-0.0127838 0.700678 0)
(-0.00130151 0.875253 0)
(0.0327766 0.246065 0)
(0.0421507 0.36094 0)
(0.032979 0.426035 0)
(0.0233532 0.454605 0)
(0.0126789 0.466232 0)
(0.00537117 0.47488 0)
(-0.00422256 0.494049 0)
(-0.00585627 0.561373 0)
(-0.0127744 0.707213 0)
(-0.0013924 0.880134 0)
(0.0341042 0.246709 0)
(0.0465052 0.360052 0)
(0.0397723 0.431452 0)
(0.0295015 0.46343 0)
(0.018324 0.476261 0)
(0.010489 0.484455 0)
(0.000804145 0.501531 0)
(-0.00200684 0.563563 0)
(-0.0105149 0.699232 0)
(-0.00246311 0.861977 0)
(0.0329145 0.250084 0)
(0.0409946 0.360904 0)
(0.0387661 0.439681 0)
(0.0304435 0.473168 0)
(0.0197966 0.484125 0)
(0.0118703 0.490133 0)
(0.00274899 0.506751 0)
(-0.000178059 0.5702 0)
(-0.00668589 0.706657 0)
(-0.00090947 0.865533 0)
(0.0318868 0.247046 0)
(0.0393918 0.357594 0)
(0.0376764 0.442915 0)
(0.0307232 0.482531 0)
(0.0210261 0.495545 0)
(0.0132996 0.501211 0)
(0.00442278 0.516201 0)
(-0.000152441 0.575332 0)
(-0.00882913 0.703956 0)
(-0.00259737 0.855229 0)
(0.0232794 0.244718 0)
(0.0294523 0.356155 0)
(0.0307341 0.446458 0)
(0.0271729 0.488697 0)
(0.0209018 0.501776 0)
(0.0159645 0.505736 0)
(0.009712 0.519894 0)
(0.00692632 0.579656 0)
(-0.000885387 0.708139 0)
(-0.000928311 0.854584 0)
(0.0196004 0.245607 0)
(0.0203147 0.354691 0)
(0.021499 0.447671 0)
(0.018383 0.492433 0)
(0.0137042 0.50734 0)
(0.00994218 0.512496 0)
(0.00441299 0.52769 0)
(0.0005953 0.586633 0)
(-0.00502285 0.711627 0)
(-0.00131663 0.851609 0)
(0.00800933 0.240134 0)
(0.0101365 0.352402 0)
(0.0136574 0.44849 0)
(0.0142985 0.495979 0)
(0.0135002 0.510505 0)
(0.0137987 0.514449 0)
(0.0120254 0.529704 0)
(0.0091604 0.589218 0)
(-0.000325245 0.71263 0)
(-0.000446097 0.850329 0)
(-0.000606913 0.246745 0)
(-0.00336355 0.35107 0)
(-0.00053954 0.442873 0)
(0.00223845 0.491197 0)
(0.00376387 0.507263 0)
(0.00528934 0.513074 0)
(0.00490579 0.531927 0)
(0.00427993 0.595805 0)
(-0.000303041 0.718808 0)
(-0.000618317 0.849268 0)
(0.0355274 0.141935 3.54219e-21)
(0.0432077 0.168106 -3.48624e-21)
(0.0473252 0.192482 2.1504e-22)
(0.0451705 0.205614 0)
(0.0395602 0.214047 0)
(0.0332269 0.211243 -9.24491e-23)
(0.0238385 0.207671 4.71887e-22)
(0.0181321 0.203882 -4.63648e-22)
(0.00793968 0.197333 -6.5396e-23)
(0.00284423 0.203922 6.37098e-23)
(0.0462239 0.118716 -4.4969e-21)
(0.0510585 0.149913 0)
(0.051655 0.177138 7.35732e-22)
(0.0464471 0.191734 -9.57658e-22)
(0.0387379 0.199854 -8.92688e-23)
(0.0310642 0.196223 9.03586e-23)
(0.0219706 0.192102 -2.57194e-22)
(0.0162815 0.186477 -4.51449e-22)
(0.00760191 0.180198 -3.35342e-23)
(0.00379082 0.185651 -2.54746e-24)
(0.0576148 0.109455 4.97575e-21)
(0.0592162 0.14206 -1.66752e-21)
(0.0561465 0.167343 1.65153e-21)
(0.0478148 0.179897 2.72424e-22)
(0.0378048 0.185688 -1.53129e-22)
(0.0287334 0.180552 0)
(0.0197731 0.175697 2.57788e-22)
(0.0142757 0.168407 -4.46057e-24)
(0.00726832 0.162898 1.82004e-22)
(0.004621 0.166319 6.46714e-23)
(0.0689578 0.107252 -7.5161e-22)
(0.0665367 0.137385 0)
(0.0597997 0.157713 0)
(0.0485778 0.166608 0)
(0.0365615 0.169418 -7.275e-22)
(0.0263643 0.162908 4.89746e-22)
(0.0175623 0.157447 -2.54708e-23)
(0.0123562 0.148942 2.31066e-22)
(0.00689345 0.144321 5.94709e-23)
(0.00524301 0.145121 2.02822e-24)
(0.0792454 0.105885 -8.72202e-22)
(0.0721025 0.130175 -1.64742e-21)
(0.0619717 0.144191 6.19328e-23)
(0.0483227 0.149236 -6.18862e-23)
(0.0347826 0.149371 2.34327e-22)
(0.0238509 0.142123 0)
(0.0152967 0.136414 2.94768e-22)
(0.010496 0.127327 -4.64281e-22)
(0.006361 0.12343 2.12061e-22)
(0.00550655 0.121496 -6.18092e-23)
(0.0871618 0.100408 -4.03437e-21)
(0.0754853 0.11706 1.00446e-21)
(0.0627056 0.124766 4.56561e-22)
(0.0472782 0.126645 -2.13927e-22)
(0.0327274 0.124859 0)
(0.0213724 0.117639 0)
(0.0130806 0.112083 0)
(0.00871779 0.10305 -2.55092e-22)
(0.00561978 0.0996159 0)
(0.00538054 0.0953625 0)
(0.0920118 0.0880295 0)
(0.0767586 0.0970865 2.04689e-22)
(0.0622984 0.0993535 -8.16825e-23)
(0.0457701 0.099095 6.11444e-22)
(0.0306866 0.0961654 -6.14571e-22)
(0.0191239 0.0895948 -3.45768e-22)
(0.0110456 0.0845137 3.8564e-22)
(0.00705477 0.0760655 9.06218e-22)
(0.00468715 0.0729395 -7.70316e-23)
(0.00492059 0.0671883 3.14922e-23)
(0.0938301 0.0684029 0)
(0.0763236 0.0712404 -1.22385e-22)
(0.0611297 0.0692404 7.60179e-23)
(0.044075 0.0677996 0)
(0.0288518 0.0642841 -1.86545e-22)
(0.0172125 0.058728 5.77165e-22)
(0.00926859 0.0543313 -4.73983e-22)
(0.00553883 0.0468891 -1.08674e-22)
(0.00364776 0.0441391 7.69118e-23)
(0.0042479 0.0378909 -5.96953e-23)
(0.0931034 0.043084 4.30952e-22)
(0.0746622 0.041628 -6.66051e-23)
(0.0595177 0.0363892 -5.32984e-23)
(0.0423903 0.034426 -8.54211e-23)
(0.0272969 0.0306027 -1.92884e-22)
(0.0156739 0.0261999 -2.93222e-22)
(0.00778746 0.0226308 8.28762e-23)
(0.00422856 0.0165411 6.23171e-23)
(0.00263388 0.0144275 -7.71634e-23)
(0.00350069 0.00861236 -1.43911e-23)
(0.0904581 0.0145069 -3.32194e-23)
(0.072195 0.0106284 3.36055e-23)
(0.0576476 0.00283285 4.46582e-23)
(0.0408663 0.000694254 8.52905e-23)
(0.025985 -0.00334688 -9.90176e-23)
(0.0145095 -0.00659408 1.98507e-22)
(0.00663797 -0.00920604 -1.18848e-22)
(0.00320744 -0.0136657 -2.61101e-23)
(0.00178018 -0.0148474 0)
(0.00263086 -0.0195537 1.43613e-23)
(0.0865437 -0.0149347 3.20414e-23)
(0.0692953 -0.0196976 -3.23742e-23)
(0.0556715 -0.0296993 4.52781e-23)
(0.0394708 -0.031845 8.43921e-23)
(0.0249283 -0.0360789 9.76264e-23)
(0.0137052 -0.0382373 -2.91121e-24)
(0.00587455 -0.039768 -4.46305e-23)
(0.00254626 -0.0424396 -9.46282e-23)
(0.00119305 -0.0425148 0)
(0.00201838 -0.0458155 1.24999e-23)
(0.081945 -0.043373 0)
(0.066248 -0.0478774 8.10017e-23)
(0.0536826 -0.0598614 -2.07367e-22)
(0.0381614 -0.0619678 -8.45151e-23)
(0.0241533 -0.0663561 -1.85034e-22)
(0.0132573 -0.0674952 -2.79049e-22)
(0.00553191 -0.0678895 7.97444e-23)
(0.00227273 -0.068808 5.91013e-23)
(0.000895466 -0.0678096 -6.756e-23)
(0.0015424 -0.0697873 -1.24651e-23)
(0.0770805 -0.0695445 0)
(0.063213 -0.0730682 -5.40746e-23)
(0.0516887 -0.0867765 8.06651e-23)
(0.0370191 -0.0888699 0)
(0.0236098 -0.0932936 5.42785e-22)
(0.0131662 -0.0935582 -1.7646e-22)
(0.00558894 -0.0928627 -1.62824e-22)
(0.00236361 -0.0922986 -3.49789e-22)
(0.000849283 -0.0904613 6.73393e-23)
(0.00118895 -0.0914221 -4.27985e-23)
(0.0722542 -0.0927974 0)
(0.0602949 -0.0950112 5.45207e-23)
(0.0497009 -0.11002 0)
(0.0360766 -0.112218 -6.0346e-22)
(0.02328 -0.116484 6.06607e-22)
(0.0134006 -0.116141 3.09946e-22)
(0.00598202 -0.114516 -1.85089e-23)
(0.00273706 -0.11293 3.40424e-22)
(0.000977098 -0.110595 6.4229e-23)
(0.000935266 -0.110902 6.35281e-23)
(0.0676835 -0.112983 3.24917e-21)
(0.057577 -0.113917 -1.17447e-21)
(0.047757 -0.129574 -3.5189e-22)
(0.0353378 -0.132132 3.05245e-22)
(0.0231413 -0.136 0)
(0.0138834 -0.135441 2.89585e-22)
(0.00660765 -0.133125 -5.54887e-23)
(0.00327034 -0.131063 -4.42346e-22)
(0.00118878 -0.128563 -1.99322e-23)
(0.000746768 -0.12853 1.99175e-23)
(0.0634991 -0.130299 1.10856e-21)
(0.0551414 -0.130337 1.46239e-21)
(0.0459175 -0.145747 -2.17123e-22)
(0.0347837 -0.149083 2.17002e-22)
(0.0231595 -0.152293 2.50854e-22)
(0.0145065 -0.151986 0)
(0.0073487 -0.14923 4.62663e-22)
(0.00384487 -0.147207 -2.52155e-22)
(0.00141597 -0.144784 -1.52634e-22)
(0.000596088 -0.144637 -3.41614e-23)
(0.0597936 -0.145094 -5.99246e-22)
(0.0531078 -0.145017 0)
(0.0442732 -0.159059 0)
(0.0343851 -0.163718 0)
(0.0232992 -0.166014 2.41393e-22)
(0.0151631 -0.16643 -4.91575e-22)
(0.00810505 -0.163443 -4.47334e-22)
(0.00437357 -0.161869 5.60282e-22)
(0.00162164 -0.159653 -3.5466e-23)
(0.000468541 -0.159535 6.89154e-23)
(0.0564811 -0.157665 -1.7086e-21)
(0.0514874 -0.158745 7.3917e-22)
(0.0428558 -0.170133 -7.32265e-22)
(0.0340699 -0.176694 -6.10057e-22)
(0.0235277 -0.177859 7.86132e-22)
(0.0157809 -0.179386 0)
(0.00882493 -0.17632 2.05386e-22)
(0.00481709 -0.175467 -1.12495e-23)
(0.00179893 -0.173494 9.91909e-23)
(0.000360002 -0.173495 2.89852e-23)
(0.0527863 -0.168022 -7.06074e-22)
(0.0497133 -0.172217 0)
(0.0414253 -0.179629 -2.40352e-22)
(0.0336184 -0.188576 -2.84194e-22)
(0.023767 -0.188466 2.52275e-22)
(0.0163062 -0.191351 9.44566e-23)
(0.00951035 -0.188293 -2.04918e-22)
(0.00519389 -0.188305 -3.39106e-23)
(0.00196989 -0.186558 -1.90487e-22)
(0.000272485 -0.18674 -5.88233e-23)
(0.0492531 -0.175618 -2.67547e-21)
(0.0477041 -0.185968 2.60761e-21)
(0.0401242 -0.188293 8.51641e-23)
(0.0329605 -0.19984 0)
(0.0238912 -0.198393 0)
(0.0165966 -0.2027 -9.73689e-23)
(0.010043 -0.199681 -3.2682e-22)
(0.00546448 -0.200587 3.20629e-22)
(0.00212339 -0.199028 2.88735e-23)
(0.000202695 -0.199459 -2.82256e-23)
(0.0537525 -0.184969 0)
(0.0493799 -0.218036 0)
(0.0413964 -0.208003 0)
(0.0329777 -0.225654 0)
(0.0241891 -0.221415 0)
(0.016455 -0.229163 0)
(0.0102599 -0.226371 0)
(0.00527457 -0.229332 0)
(0.00212109 -0.227921 0)
(7.5038e-05 -0.22883 0)
(0.0446762 -0.235193 0)
(0.037453 -0.267353 0)
(0.0332662 -0.255137 0)
(0.0259013 -0.272553 0)
(0.020345 -0.267023 0)
(0.0139407 -0.276156 0)
(0.00915493 -0.273093 0)
(0.00472029 -0.2771 0)
(0.00221989 -0.275006 0)
(3.60384e-05 -0.276371 0)
(0.0415823 -0.286119 0)
(0.0328431 -0.318512 0)
(0.0286629 -0.304371 0)
(0.0215454 -0.322839 0)
(0.0170393 -0.315667 0)
(0.0114913 -0.3261 0)
(0.00791101 -0.321621 0)
(0.00426615 -0.326406 0)
(0.00218257 -0.323131 0)
(9.18059e-05 -0.325113 0)
(0.0366059 -0.341696 0)
(0.0278657 -0.374306 0)
(0.0243626 -0.357986 0)
(0.0177023 -0.377694 0)
(0.0142739 -0.368447 0)
(0.00958377 -0.380115 0)
(0.00698706 -0.373817 0)
(0.00395027 -0.379631 0)
(0.00219672 -0.374736 0)
(0.000162169 -0.377814 0)
(0.0313903 -0.40544 0)
(0.0234877 -0.438429 0)
(0.020352 -0.42009 0)
(0.0145292 -0.441115 0)
(0.0119945 -0.429734 0)
(0.0080521 -0.442858 0)
(0.00622419 -0.4347 0)
(0.00363203 -0.441785 0)
(0.00216749 -0.435223 0)
(0.000193046 -0.439703 0)
(0.0263673 -0.482794 0)
(0.019305 -0.515841 0)
(0.0167118 -0.496353 0)
(0.0117545 -0.518595 0)
(0.0100059 -0.505587 0)
(0.00664867 -0.520168 0)
(0.00544969 -0.510437 0)
(0.00313597 -0.518889 0)
(0.0019942 -0.510898 0)
(0.000125506 -0.517046 0)
(0.0205905 -0.578643 0)
(0.0152236 -0.609442 0)
(0.0131371 -0.591679 0)
(0.00919743 -0.613477 0)
(0.00789081 -0.600635 0)
(0.00509915 -0.615687 0)
(0.00425952 -0.605562 0)
(0.00216 -0.614913 0)
(0.0013836 -0.606433 0)
(-7.94513e-05 -0.613944 0)
(0.0161698 -0.688191 0)
(0.0114676 -0.712379 0)
(0.00953623 -0.700312 0)
(0.00624406 -0.717955 0)
(0.00530907 -0.708517 0)
(0.00304132 -0.72127 0)
(0.00242052 -0.713041 0)
(0.000634404 -0.721319 0)
(0.000362346 -0.71415 0)
(-0.000338062 -0.721484 0)
(0.00886635 -0.786029 0)
(0.00582336 -0.798943 0)
(0.00482113 -0.795886 0)
(0.00314582 -0.806481 0)
(0.00263469 -0.802974 0)
(0.0012416 -0.810237 0)
(0.000707836 -0.80576 0)
(-0.000424961 -0.810295 0)
(-0.000375727 -0.805965 0)
(-0.000372555 -0.810529 0)
(0.00161031 -0.839041 0)
(0.00107022 -0.848547 0)
(0.00100214 -0.850461 0)
(0.000868024 -0.855857 0)
(0.000680832 -0.855404 0)
(0.000310789 -0.858441 0)
(1.79412e-05 -0.856373 0)
(-0.000308431 -0.857852 0)
(-0.000286334 -0.855563 0)
(-0.000143742 -0.857514 0)
(0.0513743 -0.204511 4.23749e-21)
(0.0458166 -0.254546 -4.15977e-21)
(0.0436949 -0.305317 6.10195e-22)
(0.0386891 -0.361179 0)
(0.0337321 -0.425115 0)
(0.028597 -0.502176 8.72061e-22)
(0.0229754 -0.595553 -4.03858e-21)
(0.0174467 -0.697565 4.02143e-21)
(0.0109372 -0.789319 1.20475e-21)
(0.0034368 -0.835087 -1.19233e-21)
(0.050894 -0.212311 -5.04246e-21)
(0.0466906 -0.261377 0)
(0.0446944 -0.311386 4.35925e-21)
(0.0396776 -0.366968 -1.03529e-20)
(0.0348142 -0.430808 6.95003e-21)
(0.0296261 -0.507707 -7.8559e-22)
(0.0240415 -0.600106 1.903e-21)
(0.0180412 -0.700217 4.19283e-21)
(0.0118656 -0.789001 1.27095e-21)
(0.00426475 -0.834719 1.2808e-21)
(0.0509994 -0.220095 6.017e-21)
(0.0481409 -0.268361 -4.6248e-21)
(0.0460644 -0.3172 4.58091e-21)
(0.0410034 -0.372046 -5.92804e-21)
(0.0361619 -0.435503 4.37054e-21)
(0.0308618 -0.512009 0)
(0.0251677 -0.60335 -1.90776e-21)
(0.018764 -0.701844 1.62746e-22)
(0.0124655 -0.787605 -2.2293e-21)
(0.00466613 -0.834694 -2.43183e-21)
(0.0516499 -0.226997 -9.81039e-22)
(0.0500325 -0.274899 0)
(0.0478102 -0.322819 0)
(0.0427096 -0.376993 0)
(0.0378171 -0.440056 5.33767e-21)
(0.0323384 -0.516083 -3.58783e-21)
(0.0264234 -0.606351 -5.02456e-23)
(0.0196304 -0.703079 -2.50167e-21)
(0.0128422 -0.786279 -1.28784e-21)
(0.0047425 -0.833526 -1.39599e-21)
(0.0529087 -0.23305 2.91549e-22)
(0.0522805 -0.280401 -3.13966e-21)
(0.0498677 -0.327584 -2.8651e-21)
(0.0447441 -0.381317 2.86335e-21)
(0.0397425 -0.444137 -1.72619e-21)
(0.0340338 -0.519769 0)
(0.0278404 -0.609068 -2.22987e-21)
(0.0206409 -0.704052 5.12716e-21)
(0.0132201 -0.785095 -2.65062e-21)
(0.00473259 -0.831279 2.7158e-21)
(0.0548516 -0.238399 -8.52236e-21)
(0.0549179 -0.284803 7.09387e-22)
(0.0522411 -0.331185 -4.20473e-22)
(0.0470728 -0.384565 3.02103e-21)
(0.0418976 -0.447247 0)
(0.0359151 -0.522588 0)
(0.0294105 -0.611078 0)
(0.0217915 -0.704538 2.79921e-21)
(0.0137439 -0.783762 0)
(0.0047922 -0.828467 0)
(0.0575107 -0.242958 0)
(0.0579997 -0.288152 3.99108e-21)
(0.054986 -0.333633 -2.72305e-21)
(0.0497124 -0.38663 -3.71795e-21)
(0.0442839 -0.449175 3.73735e-21)
(0.0379771 -0.524267 2.4414e-21)
(0.0311234 -0.612087 -2.39783e-21)
(0.0230713 -0.704308 -1.00428e-20)
(0.0144388 -0.782053 7.13573e-22)
(0.00495669 -0.825467 -2.56494e-21)
(0.0608992 -0.24655 0)
(0.0615553 -0.290395 -1.27155e-21)
(0.0581511 -0.334956 -7.99316e-22)
(0.0526956 -0.387537 0)
(0.0469305 -0.449908 1.17984e-21)
(0.040244 -0.524749 -3.56027e-21)
(0.0329932 -0.611995 4.13848e-21)
(0.0244851 -0.703233 1.52237e-21)
(0.0152843 -0.779845 -1.71844e-21)
(0.00521137 -0.822368 3.38929e-21)
(0.0650343 -0.249031 1.03095e-21)
(0.0656 -0.291444 1.49724e-21)
(0.0617614 -0.335115 -2.90698e-22)
(0.0560443 -0.38729 5.017e-22)
(0.0498675 -0.449471 1.09969e-21)
(0.0427462 -0.524076 1.93411e-21)
(0.035041 -0.610859 -7.59037e-22)
(0.0260331 -0.701357 -8.43182e-22)
(0.0162382 -0.77716 1.72413e-21)
(0.00551914 -0.819146 9.5947e-22)
(0.0699375 -0.25029 -3.22199e-22)
(0.0701484 -0.291238 3.24703e-22)
(0.0658293 -0.334057 -4.21867e-22)
(0.059768 -0.38585 -5.01094e-22)
(0.0531137 -0.447847 6.44791e-22)
(0.0455084 -0.52225 -1.32231e-21)
(0.0372979 -0.608681 1.1705e-21)
(0.0277433 -0.698667 4.29351e-22)
(0.0173057 -0.77397 0)
(0.00587963 -0.815698 -9.61576e-22)
(0.0756313 -0.250251 3.36965e-22)
(0.0752125 -0.28977 -3.39751e-22)
(0.0703628 -0.33176 -4.74124e-22)
(0.0638725 -0.383194 -5.65271e-22)
(0.0566832 -0.445024 -6.84975e-22)
(0.0485427 -0.519304 -6.64163e-23)
(0.0397684 -0.605553 4.19486e-22)
(0.0296062 -0.695295 1.3894e-21)
(0.0184622 -0.770371 0)
(0.00627003 -0.812025 -1.07842e-21)
(0.0821322 -0.248887 0)
(0.080796 -0.2871 -1.76582e-21)
(0.0753691 -0.328239 3.26039e-21)
(0.0683627 -0.379337 5.66272e-22)
(0.0605836 -0.440985 1.40045e-21)
(0.0518645 -0.515171 2.36363e-21)
(0.0424862 -0.601353 -8.55464e-22)
(0.0316716 -0.691097 -9.48457e-22)
(0.0197598 -0.76625 2.17335e-21)
(0.00672675 -0.808044 1.07586e-21)
(0.0894377 -0.246266 0)
(0.0868959 -0.283335 -1.71427e-21)
(0.0808506 -0.32359 -1.00939e-21)
(0.0732419 -0.374333 0)
(0.0648328 -0.435792 -4.48717e-21)
(0.0554736 -0.509985 1.49878e-21)
(0.045422 -0.596292 1.87715e-21)
(0.0338874 -0.686301 6.20986e-21)
(0.0211391 -0.761784 -2.16633e-21)
(0.00720066 -0.803856 4.79046e-21)
(0.0975285 -0.242517 0)
(0.0935052 -0.27855 1.72902e-21)
(0.0868173 -0.317857 0)
(0.0785188 -0.368262 5.65874e-21)
(0.0694326 -0.429447 -5.68774e-21)
(0.0594036 -0.503576 -3.70503e-21)
(0.0486563 -0.59004 -1.04404e-22)
(0.0363563 -0.680505 -6.44637e-21)
(0.022703 -0.756692 -1.07077e-21)
(0.00777158 -0.799297 -5.95852e-21)
(0.106378 -0.237832 1.10676e-20)
(0.100627 -0.272818 -4.29339e-21)
(0.0932321 -0.311352 9.0081e-22)
(0.084191 -0.36116 -5.09837e-21)
(0.0744215 -0.422055 0)
(0.0636359 -0.496216 -3.91602e-21)
(0.0520997 -0.583117 -4.30181e-22)
(0.038932 -0.674348 8.82037e-21)
(0.0242898 -0.751398 1.25208e-21)
(0.00831528 -0.794606 -1.25661e-21)
(0.115946 -0.232364 -2.3009e-21)
(0.108236 -0.266178 8.7926e-21)
(0.100146 -0.30384 5.37955e-21)
(0.0903461 -0.352761 -5.37586e-21)
(0.07981 -0.413381 -3.49426e-21)
(0.0682526 -0.487469 0)
(0.0559143 -0.574734 -9.06545e-21)
(0.0418626 -0.666909 4.53619e-21)
(0.0261604 -0.745262 4.97369e-21)
(0.00902137 -0.789418 5.48393e-21)
(0.126169 -0.226595 -1.53673e-21)
(0.116393 -0.258658 0)
(0.107514 -0.2956 0)
(0.0968709 -0.343896 0)
(0.085488 -0.404333 -4.19581e-21)
(0.0730765 -0.478585 7.67643e-21)
(0.0598137 -0.566509 9.29012e-21)
(0.0447503 -0.659797 -1.4859e-20)
(0.027917 -0.739301 2.73794e-21)
(0.00959025 -0.784266 -8.14379e-21)
(0.136933 -0.219988 -1.44362e-21)
(0.125245 -0.249684 9.78062e-21)
(0.115328 -0.286173 -9.6871e-21)
(0.103908 -0.333602 1.41155e-20)
(0.091713 -0.393422 -1.78397e-20)
(0.078496 -0.467413 0)
(0.0643554 -0.555732 -4.91268e-21)
(0.0482849 -0.650429 -2.57748e-22)
(0.0302007 -0.731955 -5.74527e-21)
(0.0104853 -0.778322 -5.92145e-21)
(0.147796 -0.214347 -1.61456e-21)
(0.134323 -0.241919 0)
(0.123113 -0.278177 -1.40419e-20)
(0.110924 -0.324974 2.727e-20)
(0.09783 -0.384544 -1.07513e-20)
(0.08368 -0.458717 -2.28797e-21)
(0.0685159 -0.547645 4.90232e-21)
(0.0513251 -0.643277 -3.39489e-22)
(0.032014 -0.725727 8.32544e-21)
(0.0109793 -0.772809 8.76037e-21)
(0.160297 -0.203904 -7.83806e-21)
(0.145397 -0.229542 7.67293e-21)
(0.132475 -0.265349 1.43565e-21)
(0.119465 -0.311084 0)
(0.105474 -0.369807 0)
(0.0904241 -0.443639 2.20605e-21)
(0.0742503 -0.533297 1.04511e-20)
(0.0558423 -0.631256 -1.01512e-20)
(0.0349759 -0.716843 -2.87331e-21)
(0.012219 -0.765848 2.81539e-21)
(0.174159 -0.210033 0)
(0.169819 -0.22752 0)
(0.150295 -0.262958 0)
(0.135106 -0.306852 0)
(0.118969 -0.363618 0)
(0.101822 -0.43559 0)
(0.0834261 -0.523069 0)
(0.0625181 -0.618778 0)
(0.0388636 -0.702907 0)
(0.0126981 -0.752109 0)
(0.204683 -0.190084 0)
(0.212075 -0.212085 0)
(0.180369 -0.25102 0)
(0.165611 -0.29381 0)
(0.146001 -0.350481 0)
(0.125735 -0.421376 0)
(0.103764 -0.506375 0)
(0.0784327 -0.597778 0)
(0.0494862 -0.6764 0)
(0.0180387 -0.720193 0)
(0.242308 -0.165899 0)
(0.252313 -0.186382 0)
(0.210449 -0.226183 0)
(0.200125 -0.268769 0)
(0.176192 -0.325375 0)
(0.152634 -0.394579 0)
(0.125974 -0.476596 0)
(0.0948563 -0.564264 0)
(0.0590615 -0.64039 0)
(0.0189736 -0.685484 0)
(0.286033 -0.145972 0)
(0.296533 -0.164896 0)
(0.25067 -0.208318 0)
(0.245291 -0.250877 0)
(0.214413 -0.306133 0)
(0.187835 -0.372656 0)
(0.155966 -0.450415 0)
(0.118305 -0.531746 0)
(0.0747067 -0.600158 0)
(0.0273636 -0.636896 0)
(0.338997 -0.121685 0)
(0.349891 -0.141999 0)
(0.301045 -0.184599 0)
(0.296268 -0.221126 0)
(0.255966 -0.272089 0)
(0.226714 -0.334514 0)
(0.187385 -0.406694 0)
(0.141121 -0.482214 0)
(0.0875662 -0.546799 0)
(0.0273142 -0.586019 0)
(0.408456 -0.108467 0)
(0.416772 -0.129299 0)
(0.364091 -0.166785 0)
(0.359903 -0.1986 0)
(0.3108 -0.248902 0)
(0.280336 -0.306249 0)
(0.230736 -0.370983 0)
(0.174035 -0.436057 0)
(0.109452 -0.489149 0)
(0.0412594 -0.515073 0)
(0.489102 -0.0834785 0)
(0.490423 -0.100972 0)
(0.437524 -0.13141 0)
(0.430777 -0.159594 0)
(0.3697 -0.205052 0)
(0.336402 -0.251375 0)
(0.268406 -0.304454 0)
(0.200152 -0.358532 0)
(0.122168 -0.408933 0)
(0.0344626 -0.442754 0)
(0.590162 -0.0714867 0)
(0.583467 -0.0863965 0)
(0.535289 -0.112151 0)
(0.517193 -0.136195 0)
(0.449043 -0.173287 0)
(0.408479 -0.20702 0)
(0.321585 -0.24932 0)
(0.246518 -0.292651 0)
(0.152467 -0.332447 0)
(0.0646615 -0.342538 0)
(0.683256 -0.0372599 0)
(0.666283 -0.0456807 0)
(0.614027 -0.0615084 0)
(0.578559 -0.0755605 0)
(0.503393 -0.0979929 0)
(0.44697 -0.115299 0)
(0.342079 -0.142382 0)
(0.254501 -0.16854 0)
(0.132483 -0.200992 0)
(0.0120372 -0.246173 0)
(0.866523 -0.0193514 0)
(0.843254 -0.023388 0)
(0.798623 -0.0295541 0)
(0.75506 -0.0361398 0)
(0.688488 -0.04539 0)
(0.620516 -0.0542269 0)
(0.520128 -0.0684064 0)
(0.415236 -0.0848407 0)
(0.274826 -0.113489 0)
(0.174004 -0.166892 0)
(0.210418 -0.188235 6.58417e-21)
(0.247067 -0.167141 -6.49641e-21)
(0.285734 -0.14252 1.35111e-21)
(0.326474 -0.123419 0)
(0.376928 -0.101782 0)
(0.443197 -0.0904127 2.50941e-21)
(0.522471 -0.0689215 -1.25193e-20)
(0.618223 -0.0591045 1.2446e-20)
(0.710806 -0.0289108 3.74671e-21)
(0.885833 -0.0160987 -3.75906e-21)
(0.221432 -0.179258 -4.30695e-21)
(0.25762 -0.157774 0)
(0.296115 -0.133238 9.96056e-21)
(0.336491 -0.114473 -2.50154e-20)
(0.386757 -0.0938801 1.75785e-20)
(0.452703 -0.083292 -2.28494e-21)
(0.53205 -0.0631469 5.08602e-21)
(0.626618 -0.0541271 1.17937e-20)
(0.719639 -0.0255406 3.43939e-21)
(0.892241 -0.0147263 3.3272e-21)
(0.230835 -0.168933 4.62691e-21)
(0.265908 -0.147775 -8.11932e-21)
(0.303269 -0.123849 8.04283e-21)
(0.343093 -0.105565 -1.37434e-20)
(0.393175 -0.0860586 9.85979e-21)
(0.459089 -0.0762943 0)
(0.538558 -0.0575362 -5.0986e-21)
(0.632515 -0.0494198 -9.84069e-23)
(0.726377 -0.0224836 -6.2587e-21)
(0.897247 -0.0134557 -6.62372e-21)
(0.240559 -0.157711 -8.7705e-22)
(0.276108 -0.137282 0)
(0.312074 -0.114226 0)
(0.351014 -0.0965789 0)
(0.400499 -0.0782335 1.16576e-20)
(0.4661 -0.0693472 -8.01079e-21)
(0.545462 -0.0520308 -4.12124e-22)
(0.638741 -0.0449312 -5.98728e-21)
(0.733122 -0.019702 -3.15079e-21)
(0.902139 -0.0122821 -3.21997e-21)
(0.249594 -0.145945 2.61532e-21)
(0.28654 -0.126524 -2.90338e-21)
(0.321284 -0.104441 -5.03845e-21)
(0.359531 -0.0875659 5.03563e-21)
(0.408382 -0.0704158 -3.59513e-21)
(0.473645 -0.0624615 0)
(0.55292 -0.0466223 -4.93653e-21)
(0.645579 -0.0406046 1.13842e-20)
(0.74021 -0.0171071 -5.76748e-21)
(0.907142 -0.0111722 6.43285e-21)
(0.257444 -0.133618 -4.90471e-21)
(0.295833 -0.115519 -9.25859e-22)
(0.329699 -0.0945505 -1.43049e-21)
(0.367228 -0.0786055 4.80161e-21)
(0.415535 -0.0626704 0)
(0.480583 -0.0557013 0)
(0.559948 -0.0413599 0)
(0.652237 -0.0364465 5.3168e-21)
(0.747126 -0.0146551 0)
(0.911959 -0.0101055 0)
(0.263989 -0.12062 0)
(0.303767 -0.104209 4.25596e-21)
(0.337116 -0.0845292 -3.1301e-21)
(0.373735 -0.069662 -5.93708e-21)
(0.421393 -0.055016 5.96817e-21)
(0.48627 -0.0490867 4.28348e-21)
(0.56585 -0.0362662 -3.93956e-21)
(0.658027 -0.0324799 -1.82114e-20)
(0.753334 -0.0123491 1.28087e-21)
(0.916238 -0.0090838 -4.50056e-21)
(0.26905 -0.106872 0)
(0.310399 -0.0925246 -1.13264e-21)
(0.343454 -0.0743388 -8.89177e-22)
(0.379206 -0.0606695 0)
(0.425989 -0.0473989 1.94871e-21)
(0.490621 -0.0425861 -5.48452e-21)
(0.570428 -0.0313065 6.95965e-21)
(0.662642 -0.0286907 2.79022e-21)
(0.758507 -0.0101855 -2.7629e-21)
(0.919778 -0.00810621 6.01164e-21)
(0.272395 -0.0922932 -9.68002e-23)
(0.315618 -0.0803926 1.34072e-21)
(0.348602 -0.0639463 -4.50454e-23)
(0.383618 -0.0516031 6.05501e-22)
(0.429451 -0.0397643 1.58546e-21)
(0.493732 -0.0361404 2.86407e-21)
(0.573695 -0.0264188 -1.09577e-21)
(0.666183 -0.0250376 -1.25272e-21)
(0.762636 -0.0081533 2.77204e-21)
(0.922557 -0.00717851 1.44438e-21)
(0.273772 -0.0767749 -1.19567e-22)
(0.319226 -0.0677403 1.21142e-22)
(0.352421 -0.0533027 -4.20228e-22)
(0.386828 -0.0424537 -6.04766e-22)
(0.431784 -0.0320948 8.45519e-22)
(0.495611 -0.0296882 -1.79514e-21)
(0.575716 -0.0215607 1.67647e-21)
(0.668687 -0.0214633 6.68746e-22)
(0.765682 -0.00619908 0)
(0.924635 -0.00629291 -1.4475e-21)
(0.27297 -0.0601815 9.44207e-23)
(0.32109 -0.0544986 -9.56697e-23)
(0.354798 -0.0423494 -3.82033e-22)
(0.388774 -0.0332173 -5.7286e-22)
(0.432946 -0.024387 -8.31783e-22)
(0.496244 -0.0232045 -7.54287e-23)
(0.576598 -0.0167022 4.96941e-22)
(0.67021 -0.0179288 1.8011e-21)
(0.76789 -0.00430893 0)
(0.926091 -0.00546363 -1.41118e-21)
(0.269877 -0.0423979 0)
(0.32119 -0.0406057 -1.07951e-21)
(0.35569 -0.0310175 2.20425e-21)
(0.389467 -0.023875 5.73879e-22)
(0.432889 -0.0166283 1.47471e-21)
(0.495572 -0.0166697 2.72948e-21)
(0.576226 -0.0117983 -1.06968e-21)
(0.670577 -0.0143802 -1.22185e-21)
(0.769158 -0.00243543 2.65078e-21)
(0.926934 -0.00465447 1.40784e-21)
(0.264431 -0.0233896 0)
(0.319517 -0.0260063 -5.38863e-22)
(0.355085 -0.0192247 -7.36305e-22)
(0.38899 -0.0143935 0)
(0.43169 -0.00880551 -4.74471e-21)
(0.493695 -0.0100795 1.47436e-21)
(0.574723 -0.00684002 1.97631e-21)
(0.670018 -0.0108278 7.11749e-21)
(0.769711 -0.00059083 -2.64221e-21)
(0.92718 -0.00388059 5.56736e-21)
(0.256585 -0.00319064 0)
(0.315937 -0.0106567 5.43521e-22)
(0.35282 -0.0068834 0)
(0.38727 -0.00471226 5.11517e-21)
(0.429275 -0.000870168 -5.14111e-21)
(0.490497 -0.00339019 -3.91295e-21)
(0.57182 -0.00175826 -3.00331e-22)
(0.668129 -0.00718752 -7.15188e-21)
(0.769159 0.00129666 -1.1804e-21)
(0.926844 -0.00308727 -6.88024e-21)
(0.246434 0.0181181 -2.7481e-21)
(0.310313 0.00548945 1.23952e-21)
(0.348868 0.00606553 1.75914e-21)
(0.384453 0.00518085 -3.5461e-21)
(0.425878 0.00716237 0)
(0.486337 0.00335768 -3.92934e-21)
(0.568022 0.00339856 -5.93926e-22)
(0.665565 -0.00352511 9.36765e-21)
(0.768071 0.00317524 1.34758e-21)
(0.925946 -0.00232742 -1.34657e-21)
(0.234283 0.0404121 -3.08897e-21)
(0.302323 0.0224859 2.53764e-22)
(0.342877 0.019719 3.50704e-21)
(0.380122 0.0154392 -3.50433e-21)
(0.42108 0.0154287 -2.94982e-21)
(0.480715 0.0102812 0)
(0.56251 0.00878868 -8.86093e-21)
(0.661273 0.000333813 4.38726e-21)
(0.765579 0.00516169 5.06385e-21)
(0.924511 -0.00151093 5.55347e-21)
(0.22071 0.0635645 5.24566e-22)
(0.292233 0.040357 0)
(0.335598 0.0339532 0)
(0.375085 0.0258954 0)
(0.415861 0.0237322 -3.71258e-21)
(0.474867 0.0171686 6.64976e-21)
(0.556889 0.0141882 8.90368e-21)
(0.657061 0.00417126 -1.43991e-20)
(0.763074 0.00713333 2.71605e-21)
(0.92254 -0.000750793 -8.17984e-21)
(0.206138 0.0873102 2.62943e-21)
(0.278802 0.0593248 3.08019e-21)
(0.32535 0.0492392 -3.05086e-21)
(0.367353 0.0372485 1.04467e-20)
(0.408336 0.0326212 -1.33732e-20)
(0.466661 0.0244662 0)
(0.54845 0.0200438 -4.40626e-21)
(0.650073 0.00838142 -9.047e-23)
(0.758488 0.00929549 -5.39732e-21)
(0.920098 0.000121405 -5.60674e-21)
(0.192687 0.111228 6.29259e-22)
(0.265793 0.0785783 0)
(0.316978 0.0641571 -7.64361e-21)
(0.361417 0.0480742 1.75455e-20)
(0.402886 0.0410125 -7.42084e-21)
(0.460796 0.0313329 -1.9076e-21)
(0.542514 0.0255903 4.39695e-21)
(0.645281 0.0123801 -2.73744e-22)
(0.755107 0.0114118 7.74086e-21)
(0.917096 0.000881004 8.24027e-21)
(0.17489 0.13632 1.27287e-21)
(0.243044 0.101923 -1.23681e-21)
(0.299493 0.0829563 6.13674e-22)
(0.347823 0.0622472 0)
(0.391106 0.0514181 0)
(0.448712 0.0394838 1.83759e-21)
(0.530058 0.0322133 9.18986e-21)
(0.634872 0.0171388 -8.9183e-21)
(0.748073 0.0138452 -2.60076e-21)
(0.913765 0.00185405 2.50531e-21)
(0.170895 0.164523 0)
(0.232864 0.153233 0)
(0.296645 0.117552 0)
(0.345001 0.0871092 0)
(0.389244 0.0715462 0)
(0.445517 0.0559544 0)
(0.524004 0.0457047 0)
(0.627192 0.0272708 0)
(0.739788 0.0196204 0)
(0.903794 0.00365281 0)
(0.134897 0.234718 0)
(0.198754 0.242259 0)
(0.26297 0.172429 0)
(0.318931 0.140867 0)
(0.373465 0.110417 0)
(0.434068 0.0850841 0)
(0.512747 0.0692771 0)
(0.615827 0.0450115 0)
(0.732039 0.029186 0)
(0.895978 0.00702702 0)
(0.0990115 0.317436 0)
(0.149689 0.316784 0)
(0.212486 0.239158 0)
(0.275155 0.209037 0)
(0.339545 0.158836 0)
(0.407812 0.124258 0)
(0.487809 0.0984061 0)
(0.586413 0.0663065 0)
(0.699741 0.0412696 0)
(0.863438 0.010236 0)
(0.0691708 0.381561 0)
(0.107476 0.371751 0)
(0.16495 0.310424 0)
(0.225661 0.277849 0)
(0.297759 0.217901 0)
(0.374003 0.175244 0)
(0.46081 0.133088 0)
(0.561325 0.0900634 0)
(0.678351 0.0546766 0)
(0.844753 0.0148043 0)
(0.0462554 0.419432 0)
(0.0750212 0.409126 0)
(0.12161 0.368023 0)
(0.172712 0.336717 0)
(0.242415 0.280645 0)
(0.315262 0.232392 0)
(0.403851 0.175426 0)
(0.502622 0.119621 0)
(0.617829 0.0706516 0)
(0.789434 0.0187839 0)
(0.0373278 0.442245 0)
(0.0590047 0.437193 0)
(0.0962291 0.408385 0)
(0.136921 0.382942 0)
(0.198193 0.335714 0)
(0.262716 0.286917 0)
(0.353177 0.222942 0)
(0.451291 0.155464 0)
(0.571286 0.0889608 0)
(0.753149 0.0247892 0)
(0.0208757 0.47229 0)
(0.0377517 0.474635 0)
(0.0647722 0.448546 0)
(0.0955338 0.431562 0)
(0.142837 0.390979 0)
(0.195352 0.346767 0)
(0.274607 0.279796 0)
(0.358202 0.202038 0)
(0.472545 0.115969 0)
(0.662741 0.0318746 0)
(0.0285815 0.537354 0)
(0.0418939 0.54592 0)
(0.0628607 0.51403 0)
(0.0865368 0.504931 0)
(0.122003 0.461806 0)
(0.163476 0.423128 0)
(0.225108 0.347898 0)
(0.294832 0.266299 0)
(0.409194 0.161625 0)
(0.603371 0.0488856 0)
(-0.0015676 0.697375 0)
(0.00505154 0.702851 0)
(0.0161249 0.669484 0)
(0.029065 0.659123 0)
(0.0485901 0.610346 0)
(0.073606 0.570526 0)
(0.11077 0.486797 0)
(0.158786 0.401979 0)
(0.249752 0.265543 0)
(0.429017 0.0818798 0)
(0.0160766 0.914581 0)
(0.0224838 0.910632 0)
(0.0294117 0.888932 0)
(0.0389585 0.871576 0)
(0.0506755 0.829828 0)
(0.0669573 0.784317 0)
(0.0888848 0.704007 0)
(0.120967 0.60513 0)
(0.178162 0.4343 0)
(0.303278 0.151636 0)
(0.128141 0.220124 -1.22581e-21)
(0.0922912 0.29892 1.21575e-21)
(0.0648858 0.371333 5.63936e-22)
(0.0436487 0.418293 0)
(0.0283075 0.442862 0)
(0.0233927 0.458117 1.80183e-21)
(0.0113943 0.487264 -8.83235e-21)
(0.0201346 0.55595 8.7447e-21)
(-0.00481215 0.714317 2.49765e-21)
(0.0141045 0.922619 -2.527e-21)
(0.111986 0.23946 3.73498e-21)
(0.0765221 0.315754 0)
(0.0528165 0.383461 5.32235e-21)
(0.0345585 0.424986 -1.46643e-20)
(0.0217398 0.446235 1.13978e-20)
(0.0181556 0.460616 -1.63588e-21)
(0.0077657 0.490823 3.57973e-21)
(0.0167789 0.562019 8.08175e-21)
(-0.00601854 0.719998 2.15895e-21)
(0.0133396 0.92382 2.16938e-21)
(0.0957391 0.256724 -3.83429e-21)
(0.0614561 0.329066 -3.21578e-21)
(0.0419787 0.390397 3.1852e-21)
(0.0266556 0.426664 -9.20239e-21)
(0.0161581 0.445557 6.541e-21)
(0.013699 0.460381 0)
(0.00466003 0.492392 -3.58857e-21)
(0.0137103 0.566684 -1.38689e-22)
(-0.00729465 0.724566 -4.14382e-21)
(0.0124403 0.923593 -4.35522e-21)
(0.080262 0.272726 4.42967e-22)
(0.0475837 0.342846 0)
(0.0322651 0.398255 0)
(0.0197305 0.429487 0)
(0.0113757 0.44601 8.33776e-21)
(0.00990132 0.460966 -5.73237e-21)
(0.00201696 0.494317 -2.42009e-22)
(0.0109543 0.571253 -3.97223e-21)
(-0.00858645 0.729086 -2.04246e-21)
(0.0114213 0.923895 -2.08394e-21)
(0.0661486 0.286659 2.55236e-21)
(0.0354646 0.355171 -2.91617e-23)
(0.0238306 0.406039 -3.25104e-21)
(0.0136873 0.433273 3.2496e-21)
(0.0071907 0.447828 -2.56976e-21)
(0.0065532 0.462648 0)
(-0.000315307 0.49682 -3.40136e-21)
(0.00848691 0.575783 7.46848e-21)
(-0.00976477 0.733533 -3.72618e-21)
(0.0103699 0.924866 4.17552e-21)
(0.0535397 0.29843 3.38018e-22)
(0.0252658 0.364947 -1.47468e-21)
(0.0168039 0.412054 -1.26843e-21)
(0.00857675 0.436407 3.20598e-21)
(0.00356904 0.449675 0)
(0.00358128 0.464491 0)
(-0.0024133 0.499302 0)
(0.00628889 0.579855 3.43823e-21)
(-0.0107395 0.737473 0)
(0.0093655 0.925896 0)
(0.0424927 0.308197 0)
(0.0168868 0.37245 2.7605e-21)
(0.0111006 0.416129 -2.01612e-21)
(0.00440006 0.438294 -4.23688e-21)
(0.000530783 0.450824 4.25953e-21)
(0.0010022 0.465843 2.92434e-21)
(-0.00428592 0.501292 -2.73512e-21)
(0.00434272 0.583141 -1.16889e-20)
(-0.0115024 0.740601 8.19365e-22)
(0.00843105 0.926493 -2.72397e-21)
(0.0330913 0.316006 0)
(0.0101908 0.378149 -7.48661e-22)
(0.00654576 0.41881 -6.57271e-22)
(0.00106917 0.439237 0)
(-0.0019423 0.451336 1.35152e-21)
(-0.00116919 0.46661 -3.82135e-21)
(-0.00592939 0.502659 4.55306e-21)
(0.00262722 0.585483 1.75943e-21)
(-0.0120865 0.742778 -1.61799e-21)
(0.00756183 0.92639 3.64873e-21)
(0.0253912 0.321871 3.11843e-23)
(0.00506785 0.382288 1.07246e-21)
(0.00298992 0.420539 -9.65316e-23)
(-0.00151696 0.43967 4.51031e-22)
(-0.00390462 0.451517 1.12908e-21)
(-0.00294736 0.466954 1.95774e-21)
(-0.00735889 0.50343 -6.93601e-22)
(0.00110809 0.586943 -7.63172e-22)
(-0.0125466 0.744082 1.62334e-21)
(0.00672544 0.925729 8.3295e-22)
(0.0194005 0.325713 -1.53499e-22)
(0.00140808 0.385075 1.55189e-22)
(0.000340008 0.421497 -3.29426e-22)
(-0.0034328 0.439815 -4.50503e-22)
(-0.00540713 0.451553 5.79775e-22)
(-0.0043667 0.467 -1.22202e-21)
(-0.00858456 0.503661 1.04938e-21)
(-0.000233862 0.587531 4.05368e-22)
(-0.0129075 0.74447 0)
(0.00592327 0.924502 -8.34769e-22)
(0.0097591 -0.00984527 0)
(0.0193728 -0.0152923 0)
(0.024636 -0.0107056 -1.16101e-20)
(0.0271518 -7.99309e-05 0)
(0.0281968 0.0147706 6.20477e-21)
(0.0284535 0.0326204 -5.74977e-21)
(0.0283702 0.0525799 0)
(0.0283424 0.0738833 0)
(0.0292172 0.0957771 -1.14871e-20)
(0.0315381 0.115561 2.19638e-20)
(0.0110766 -0.00898691 0)
(0.0235746 -0.0145408 -8.83087e-21)
(0.0310955 -0.0106639 -3.5948e-21)
(0.0351172 -0.00144543 -1.27421e-20)
(0.03699 0.0113508 -6.31558e-21)
(0.0374888 0.0265431 -1.87213e-20)
(0.037138 0.04334 0)
(0.0363363 0.0611607 0)
(0.0357414 0.0795758 0)
(0.0365108 0.0968498 -1.89991e-22)
(0.0128209 -0.00806111 0)
(0.0287318 -0.0130605 -3.9786e-21)
(0.0389407 -0.00899751 5.72072e-21)
(0.0448501 -0.000189971 9.65043e-21)
(0.0479281 0.0116466 -3.76276e-22)
(0.0490815 0.0253644 -2.26074e-22)
(0.0489581 0.0402445 1.2394e-20)
(0.0480686 0.0558488 -1.17441e-20)
(0.0470552 0.0718881 2.21416e-20)
(0.0470504 0.0869425 -2.09547e-20)
(0.0151188 -0.0070909 -1.46153e-21)
(0.034875 -0.0109485 9.20179e-21)
(0.0480145 -0.00599242 1.61767e-20)
(0.055988 0.00314474 -2.06244e-20)
(0.0604484 0.0148202 1.28314e-20)
(0.062488 0.0279394 1.26741e-20)
(0.0629168 0.0418373 -6.28865e-21)
(0.062387 0.0561375 2.33444e-20)
(0.0615991 0.0705997 -6.48287e-22)
(0.0615274 0.0841903 -1.01345e-20)
(0.0180351 -0.00605095 -1.65366e-21)
(0.0419052 -0.00830066 1.57109e-21)
(0.0579613 -0.00204471 0)
(0.0678917 0.00775208 1.71909e-20)
(0.0736098 0.0195566 -3.27718e-21)
(0.0764424 0.0323703 8.92611e-23)
(0.0773805 0.0456031 -6.02549e-21)
(0.0771988 0.0589251 -1.65685e-20)
(0.0766317 0.0721537 -1.52302e-22)
(0.0765183 0.0847568 1.35277e-20)
(0.0215423 -0.00487438 0)
(0.049571 -0.00520295 -1.0989e-20)
(0.0682462 0.00240325 3.42022e-21)
(0.0797305 0.0127266 -1.06533e-20)
(0.086278 0.0243929 3.30578e-21)
(0.0894933 0.0365577 7.74476e-23)
(0.0905571 0.0487532 1.45133e-22)
(0.0903469 0.0607267 1.06892e-20)
(0.089598 0.0723955 -1.42197e-20)
(0.0890193 0.083718 1.25517e-20)
(0.0255069 -0.00347585 8.43641e-22)
(0.0574748 -0.00174256 7.27941e-21)
(0.0782128 0.00690862 0)
(0.0906121 0.0172104 1.06725e-20)
(0.097352 0.0280188 -1.00316e-20)
(0.100354 0.0387155 -3.05321e-21)
(0.100994 0.0490129 8.56418e-21)
(0.100242 0.0587884 0)
(0.0988183 0.0681082 0)
(0.0972907 0.0772349 0)
(0.0296905 -0.00178244 -9.64623e-22)
(0.0651063 0.00196832 -3.11827e-21)
(0.0871666 0.0110559 3.90024e-21)
(0.0997246 0.0204992 5.48005e-21)
(0.105967 0.0294858 5.03216e-21)
(0.108162 0.0377068 3.00489e-21)
(0.107882 0.0451141 0)
(0.10618 0.0517661 4.51215e-21)
(0.10376 0.0578998 -2.26797e-21)
(0.101098 0.0638458 0)
(0.0337697 0.000234597 0)
(0.0719023 0.00576959 6.17741e-21)
(0.0944728 0.0144773 -3.89948e-21)
(0.106462 0.022109 -3.66682e-21)
(0.111626 0.0283086 4.99685e-23)
(0.112594 0.0331587 -1.47816e-21)
(0.111119 0.0368973 1.29049e-21)
(0.108319 0.0397902 0)
(0.104885 0.0422138 -1.95803e-21)
(0.101282 0.0444453 -1.46026e-21)
(0.037397 0.00253449 1.33815e-22)
(0.077337 0.00944413 -2.42257e-21)
(0.0996522 0.0168737 -2.62956e-22)
(0.110501 0.0218045 9.13151e-24)
(0.114235 0.0244592 -1.26137e-21)
(0.113818 0.0253714 0)
(0.111153 0.0250797 -1.29028e-21)
(0.107385 0.0240403 0)
(0.103181 0.0226961 0)
(0.0990122 0.0212685 0)
(0.0403118 0.00500717 -2.95433e-22)
(0.0810198 0.0127403 0)
(0.102444 0.0180393 0)
(0.111811 0.019587 -1.56638e-21)
(0.114026 0.0182674 4.01132e-22)
(0.112328 0.0150784 -6.06677e-23)
(0.108703 0.0108292 -6.78651e-22)
(0.104278 0.0061041 0)
(0.099661 0.00133557 0)
(0.0952653 -0.00329635 0)
(0.0422491 0.00750701 0)
(0.0826933 0.0154361 -1.27979e-21)
(0.102792 0.0178873 1.18023e-21)
(0.110581 0.0156396 2.05552e-21)
(0.11142 0.0102531 0)
(0.108724 0.00314644 1.51098e-21)
(0.104489 -0.00467575 -1.40518e-21)
(0.0997673 -0.0125849 0)
(0.0950747 -0.0202149 1.70628e-21)
(0.0907077 -0.0274479 -1.64869e-21)
(0.0429207 0.00982051 0)
(0.0821776 0.0172737 1.15664e-20)
(0.100771 0.0163702 0)
(0.10713 0.0102041 9.25732e-21)
(0.106909 0.000949563 0)
(0.103594 -0.00964866 -6.84896e-21)
(0.0991186 -0.0204911 0)
(0.094423 -0.0309894 4.40971e-21)
(0.0899092 -0.040884 -4.13013e-21)
(0.0857332 -0.0501109 -3.37597e-21)
(0.0421998 0.0116967 -3.21153e-21)
(0.0794974 0.0180068 -5.53943e-21)
(0.0966283 0.013485 -2.74455e-21)
(0.101866 0.00353507 -4.63281e-21)
(0.100984 -0.00918312 -4.27282e-21)
(0.0974366 -0.022722 3.48517e-21)
(0.0930468 -0.0359836 3.12886e-21)
(0.0886285 -0.0484807 4.52009e-22)
(0.084464 -0.0600666 4.40743e-21)
(0.0805732 -0.0707274 3.38658e-21)
(0.0400876 0.012885 -3.59363e-21)
(0.0748303 0.0174247 -6.40618e-21)
(0.0907065 0.00925313 -1.17793e-20)
(0.0952216 -0.00414728 5.22721e-21)
(0.0940939 -0.0198057 0)
(0.0906596 -0.0356951 0)
(0.0866125 -0.0507968 -6.02571e-21)
(0.0826496 -0.0647566 -5.04336e-21)
(0.0789486 -0.0775272 4.63299e-21)
(0.0754201 -0.0891405 -3.20773e-21)
(0.0366921 0.013157 3.80659e-21)
(0.0684722 0.0153619 3.24101e-21)
(0.0834029 0.00370376 -1.98364e-20)
(0.087627 -0.0126805 2.73626e-20)
(0.08664 -0.030703 -4.81308e-21)
(0.0836013 -0.0483642 0)
(0.0800786 -0.0647785 0)
(0.0766822 -0.0797374 2.8063e-20)
(0.0735154 -0.0932731 -2.39087e-20)
(0.0704141 -0.10545 -1.19143e-20)
(0.0322142 0.0123271 3.51127e-20)
(0.0608015 0.0117025 0)
(0.0751432 -0.00313257 2.55327e-20)
(0.0794959 -0.0219599 -2.21551e-20)
(0.078988 -0.0417642 0)
(0.0765608 -0.0606569 7.98039e-21)
(0.0736719 -0.0779147 -2.19427e-20)
(0.0708854 -0.0934774 -2.32689e-20)
(0.0682757 -0.107444 1.08093e-20)
(0.0656504 -0.119884 8.81812e-21)
(0.0269268 0.0102674 -7.22716e-20)
(0.0522487 0.00638514 -7.65361e-21)
(0.0663589 -0.0112228 -1.42891e-20)
(0.0712216 -0.031928 -3.02597e-20)
(0.071482 -0.052961 -9.77337e-21)
(0.0698317 -0.0725997 -8.61261e-21)
(0.0676282 -0.0902887 -6.1663e-22)
(0.065424 -0.106115 0)
(0.0633281 -0.120247 0)
(0.0611901 -0.132723 1.95965e-20)
(0.0211495 0.00691746 3.71597e-20)
(0.0432658 -0.000591672 -3.30752e-20)
(0.0574663 -0.0205245 2.11201e-20)
(0.0631674 -0.0425614 4.22915e-20)
(0.0644526 -0.0643304 -1.09153e-20)
(0.0637413 -0.084303 8.12234e-21)
(0.0622855 -0.102069 7.10278e-21)
(0.0606373 -0.117849 0)
(0.0589814 -0.131905 0)
(0.0571977 -0.144207 -1.01545e-20)
(0.0152226 0.00228904 -4.9218e-21)
(0.0342991 -0.00916545 4.12307e-20)
(0.0488452 -0.0309754 -7.51633e-21)
(0.0556451 -0.0538567 0)
(0.0581894 -0.0759734 0)
(0.0586405 -0.0960039 1.81954e-20)
(0.0581732 -0.11363 0)
(0.0573614 -0.129133 -1.31956e-20)
(0.0564039 -0.142813 8.46588e-22)
(0.0548782 -0.154468 1.12654e-20)
(0.00947912 -0.00353738 0)
(0.0257612 -0.01921 0)
(0.0408166 -0.0424787 -2.93856e-20)
(0.0488738 -0.0657985 0)
(0.0528354 -0.0880284 1.04906e-20)
(0.0546485 -0.108149 -9.72249e-21)
(0.0554725 -0.126057 0)
(0.0559373 -0.14231 0)
(0.056203 -0.157641 -1.232e-20)
(0.0555925 -0.172424 2.42051e-20)
(0.00423519 -0.0104124 0)
(0.0180286 -0.0305263 -2.51483e-20)
(0.0336475 -0.0548691 -7.20246e-21)
(0.0429793 -0.0782588 -2.50378e-20)
(0.0483316 -0.10036 -1.11068e-20)
(0.0514121 -0.120461 -2.86339e-20)
(0.0533004 -0.138568 0)
(0.054557 -0.155202 0)
(0.0552291 -0.170846 0)
(0.054703 -0.185269 2.00563e-22)
(-0.000217649 -0.0181027 0)
(0.0114432 -0.0428241 -6.98556e-21)
(0.0275724 -0.0679015 1.51716e-20)
(0.0380725 -0.0910087 1.86187e-20)
(0.0446653 -0.112677 3.53418e-22)
(0.0488066 -0.132458 1.58386e-22)
(0.0514826 -0.150347 1.66063e-20)
(0.0532069 -0.166691 -1.48842e-20)
(0.0540661 -0.181738 2.66915e-20)
(0.0537539 -0.1952 -2.56502e-20)
(-0.00364282 -0.0263187 -4.69601e-21)
(0.00628167 -0.0557616 2.4596e-20)
(0.0227882 -0.0812963 3.53643e-20)
(0.0342708 -0.103799 -3.52968e-20)
(0.0419045 -0.124711 2.1858e-20)
(0.0469061 -0.143817 1.91364e-20)
(0.0501908 -0.161066 -8.14197e-21)
(0.0522778 -0.176657 2.96139e-20)
(0.0533609 -0.190752 -1.28149e-22)
(0.0533831 -0.203241 -1.3199e-20)
(-0.00587314 -0.0347358 -4.16681e-21)
(0.00275209 -0.06896 3.9598e-21)
(0.0194561 -0.0947549 0)
(0.0316909 -0.116391 2.91976e-20)
(0.0401502 -0.136257 -5.20187e-21)
(0.0458351 -0.15439 2.69231e-23)
(0.0496094 -0.170706 -8.30248e-21)
(0.0520223 -0.185327 -2.22117e-20)
(0.0533716 -0.198425 1.85724e-22)
(0.0537558 -0.210087 2.00561e-20)
(-0.00681827 -0.0430148 0)
(0.000987033 -0.0820225 -1.96829e-20)
(0.0176945 -0.107973 6.20566e-21)
(0.0304324 -0.128564 -1.57372e-20)
(0.0395006 -0.147168 4.91966e-21)
(0.0457097 -0.164115 2.32206e-22)
(0.0498783 -0.179331 1.90445e-22)
(0.0525842 -0.192911 1.47974e-20)
(0.0541998 -0.205073 -2.07241e-20)
(0.0549189 -0.216047 2.03824e-20)
(-0.00646677 -0.0508229 1.79145e-21)
(0.00103911 -0.094553 1.29538e-20)
(0.0175716 -0.12065 0)
(0.0305654 -0.140111 1.53682e-20)
(0.0400329 -0.157322 -1.33201e-20)
(0.0466196 -0.172957 -4.16744e-21)
(0.0510956 -0.186995 1.17453e-20)
(0.0540519 -0.19953 0)
(0.0559032 -0.210821 0)
(0.0569028 -0.221186 0)
(-0.00488286 -0.0578494 -1.46902e-21)
(0.00288016 -0.106172 -3.47066e-21)
(0.0191013 -0.132497 4.57328e-21)
(0.0321236 -0.150841 6.53999e-21)
(0.0417939 -0.166611 6.6425e-21)
(0.048622 -0.18088 3.80502e-21)
(0.0533217 -0.193717 0)
(0.0564787 -0.205229 7.22015e-21)
(0.0585219 -0.215693 -3.3477e-21)
(0.0597396 -0.225468 0)
(-0.00219939 -0.0638167 0)
(0.00640293 -0.116527 6.84522e-21)
(0.0222413 -0.143237 -4.57208e-21)
(0.0351002 -0.160567 -4.27026e-21)
(0.0447967 -0.174928 -1.34746e-22)
(0.0517411 -0.187836 -2e-21)
(0.056585 -0.199486 1.73301e-21)
(0.0598912 -0.210003 0)
(0.0620819 -0.219664 -3.41384e-21)
(0.0634595 -0.228831 -3.54334e-21)
(0.00138947 -0.0685239 1.21716e-22)
(0.0114218 -0.125321 -2.2066e-21)
(0.0268918 -0.152618 -2.4325e-22)
(0.0394468 -0.169111 -2.98593e-23)
(0.0490206 -0.18216 -1.39763e-21)
(0.055971 -0.193759 0)
(0.0608867 -0.204261 -1.73241e-21)
(0.0642953 -0.213815 0)
(0.0665974 -0.222683 0)
(0.0680894 -0.231205 0)
(0.00565716 -0.0719969 -1.71551e-22)
(0.017697 -0.132421 0)
(0.0329068 -0.16048 0)
(0.0450813 -0.17635 -9.16612e-22)
(0.0544184 -0.188232 4.37592e-22)
(0.0612821 -0.198609 7.91994e-23)
(0.0662074 -0.208017 -7.56029e-22)
(0.0696803 -0.216637 0)
(0.0720727 -0.224707 0)
(0.0736556 -0.232532 0)
(0.0104036 -0.0742011 0)
(0.0249989 -0.137656 -4.65213e-22)
(0.040101 -0.166629 4.29054e-22)
(0.0518718 -0.182126 1.29988e-21)
(0.0608987 -0.193029 0)
(0.0676101 -0.202304 1.49183e-21)
(0.0725021 -0.210691 -1.38732e-21)
(0.076018 -0.218414 0)
(0.0785027 -0.225688 3.43962e-21)
(0.0801843 -0.232762 -3.32822e-21)
(0.0154088 -0.0750277 0)
(0.0330567 -0.140877 3.30955e-22)
(0.0482642 -0.170908 0)
(0.0596678 -0.186304 2.83985e-21)
(0.0683534 -0.196452 0)
(0.0748738 -0.204775 -4.59482e-21)
(0.0797081 -0.212235 0)
(0.0832618 -0.219113 6.41282e-21)
(0.0858631 -0.225599 -6.00601e-21)
(0.087686 -0.231881 -6.97966e-21)
(0.0204435 -0.0744989 2.56016e-22)
(0.0415602 -0.142016 -5.29049e-22)
(0.0571442 -0.173203 -4.16156e-23)
(0.0682815 -0.188772 -1.37684e-21)
(0.0766433 -0.198413 -1.35128e-21)
(0.0829652 -0.205961 2.17877e-21)
(0.0877388 -0.212608 2.24641e-21)
(0.0913399 -0.21871 -6.51026e-22)
(0.0941002 -0.224436 5.79202e-21)
(0.0961428 -0.229908 6.96988e-21)
(0.0252987 -0.0727127 8.78748e-22)
(0.0501887 -0.141078 7.55956e-22)
(0.0664684 -0.17347 4.21189e-22)
(0.0774983 -0.189451 1.34613e-22)
(0.0856021 -0.19884 0)
(0.091752 -0.205807 0)
(0.096485 -0.211777 -5.14447e-21)
(0.100155 -0.217191 -5.92322e-21)
(0.103122 -0.222209 5.9573e-21)
(0.1055 -0.226886 -8.10642e-21)
(0.0297966 -0.0698117 -1.22564e-21)
(0.0586339 -0.138168 -3.98953e-22)
(0.0759359 -0.171696 5.4914e-21)
(0.0870874 -0.188285 -8.67586e-22)
(0.0950403 -0.197674 -3.62983e-22)
(0.101077 -0.204269 0)
(0.105814 -0.209711 0)
(0.109586 -0.214545 2.60429e-20)
(0.112784 -0.218927 -2.93033e-20)
(0.115645 -0.222861 -2.25458e-20)
(0.0337858 -0.06597 -1.63008e-20)
(0.0666234 -0.133439 0)
(0.0852499 -0.167903 -5.31396e-21)
(0.09678 -0.185257 1.2605e-21)
(0.104743 -0.19488 0)
(0.110762 -0.201311 2.95406e-21)
(0.115572 -0.206387 -9.13533e-21)
(0.1195 -0.210777 -2.01465e-20)
(0.122913 -0.214666 9.85951e-21)
(0.126336 -0.21787 1.32577e-20)
(0.0371537 -0.0613729 3.57562e-20)
(0.0739004 -0.12707 3.03682e-21)
(0.094129 -0.162203 5.85559e-21)
(0.106305 -0.180394 7.25415e-21)
(0.114476 -0.190448 -6.36804e-22)
(0.120606 -0.196912 -1.5502e-21)
(0.125571 -0.201781 1.21201e-21)
(0.129706 -0.205849 0)
(0.133385 -0.209306 0)
(0.137334 -0.211686 2.63365e-20)
(0.0398285 -0.0562127 -1.94559e-20)
(0.0802456 -0.119289 1.80384e-20)
(0.1023 -0.154751 -8.0704e-21)
(0.115391 -0.17377 -1.01057e-20)
(0.123995 -0.184398 2.13473e-21)
(0.130403 -0.191071 3.09153e-21)
(0.135653 -0.195881 3.72941e-21)
(0.140101 -0.199745 0)
(0.144165 -0.202879 0)
(0.148742 -0.204712 -1.21554e-20)
(0.0417798 -0.0506834 2.94991e-21)
(0.0854888 -0.110362 -2.23404e-20)
(0.109514 -0.145746 3.96496e-21)
(0.12377 -0.165503 0)
(0.133045 -0.176794 0)
(0.139919 -0.183819 6.04891e-22)
(0.145604 -0.188695 0)
(0.15044 -0.192387 -7.71329e-21)
(0.154643 -0.195004 -2.85343e-21)
(0.159399 -0.195712 9.67717e-21)
(0.0430171 -0.044966 0)
(0.0895156 -0.100565 0)
(0.115558 -0.13542 1.68952e-20)
(0.131187 -0.155749 0)
(0.141369 -0.167728 -1.9653e-21)
(0.148924 -0.175213 1.82134e-21)
(0.155287 -0.180257 0)
(0.160997 -0.183806 0)
(0.16621 -0.186295 -9.23112e-21)
(0.172592 -0.188185 1.85382e-20)
(0.043538 -0.0391898 0)
(0.0922317 -0.0901474 1.88095e-20)
(0.120243 -0.124022 6.74545e-21)
(0.137402 -0.144704 1.33419e-20)
(0.148708 -0.157346 5.64824e-21)
(0.157153 -0.165393 6.91301e-21)
(0.16437 -0.170808 0)
(0.171139 -0.174604 0)
(0.177726 -0.177609 0)
(0.18528 -0.180755 2.46285e-22)
(0.0433436 -0.0334802 0)
(0.0935803 -0.0793963 7.36713e-21)
(0.123426 -0.111849 -8.08161e-21)
(0.142204 -0.132614 -9.29987e-21)
(0.15481 -0.145828 1.7051e-21)
(0.164323 -0.154469 1.68391e-21)
(0.172517 -0.160375 -2.24411e-21)
(0.180352 -0.164582 -1.01772e-21)
(0.18823 -0.168059 1.02213e-20)
(0.196945 -0.171645 -1.4499e-20)
(0.0424883 -0.0279745 3.90611e-21)
(0.093567 -0.0685998 -1.95523e-20)
(0.125023 -0.0992166 -2.60728e-20)
(0.145434 -0.11975 2.3602e-20)
(0.159464 -0.133367 -1.20369e-20)
(0.17019 -0.142548 -7.69e-21)
(0.179478 -0.14894 -1.18101e-22)
(0.1884 -0.153548 2.78988e-21)
(0.197455 -0.157366 1.37308e-21)
(0.207275 -0.161083 -4.44791e-21)
(0.0410456 -0.0227905 3.86102e-21)
(0.0922474 -0.0580278 -3.66817e-21)
(0.125013 -0.0864425 0)
(0.146994 -0.106403 -2.05264e-20)
(0.162514 -0.120193 3.60021e-21)
(0.174569 -0.129778 1.23454e-21)
(0.185066 -0.13658 3.16943e-21)
(0.195145 -0.14153 1.08194e-21)
(0.205373 -0.145599 -2.28661e-21)
(0.216266 -0.149364 7.11441e-21)
(0.0390926 -0.0180186 0)
(0.0897156 -0.0479195 2.14566e-20)
(0.123434 -0.0738324 -6.3015e-21)
(0.146853 -0.0928749 1.40162e-20)
(0.163873 -0.106557 -3.95711e-21)
(0.177333 -0.116353 -3.75493e-22)
(0.18913 -0.123431 -3.36744e-22)
(0.200443 -0.128625 -1.98624e-21)
(0.211882 -0.132832 -4.94073e-22)
(0.223864 -0.136556 3.24506e-21)
(0.0367063 -0.013726 -2.14608e-21)
(0.0860979 -0.0384783 -1.46221e-20)
(0.120383 -0.0616667 0)
(0.145049 -0.0794592 -1.43769e-20)
(0.163517 -0.0927218 1.24846e-20)
(0.178411 -0.102478 2.55471e-21)
(0.191563 -0.109643 -6.00699e-21)
(0.204159 -0.114924 0)
(0.216836 -0.119119 0)
(0.229934 -0.122685 0)
(0.0339615 -0.00995976 2.09666e-21)
(0.0815453 -0.0298674 5.6934e-21)
(0.116008 -0.0501863 -6.56704e-21)
(0.141687 -0.066421 -7.95492e-21)
(0.161497 -0.0789305 -5.8913e-21)
(0.177796 -0.0883505 -3.48893e-21)
(0.192312 -0.0953546 0)
(0.206202 -0.100518 -2.5856e-21)
(0.220114 -0.104513 1.32428e-21)
(0.23432 -0.107779 0)
(0.0309268 -0.0067502 0)
(0.0762246 -0.0222065 -1.15938e-20)
(0.110498 -0.0395798 6.56563e-21)
(0.136931 -0.0539787 5.46298e-21)
(0.157925 -0.0653923 -2.31591e-22)
(0.175546 -0.0741437 1.50322e-21)
(0.191383 -0.0806922 -1.50569e-21)
(0.206532 -0.085485 0)
(0.221632 -0.089057 1.09724e-21)
(0.236885 -0.0918424 3.28004e-22)
(0.0276835 -0.00411394 -2.79324e-22)
(0.0703251 -0.015573 4.38745e-21)
(0.104078 -0.0299783 3.83663e-22)
(0.130994 -0.042293 -6.33689e-23)
(0.152971 -0.0522675 1.7287e-21)
(0.171773 -0.0599925 0)
(0.188825 -0.0657528 1.50526e-21)
(0.205143 -0.0698819 0)
(0.221329 -0.0727726 0)
(0.237505 -0.0748618 0)
(0.0243882 -0.00204925 5.60994e-22)
(0.0641203 -0.00999439 0)
(0.0970611 -0.0214508 0)
(0.124185 -0.0314639 2.35015e-21)
(0.146906 -0.0396664 -5.59289e-22)
(0.166688 -0.0459981 1.21622e-22)
(0.184784 -0.050616 9.49636e-22)
(0.20211 -0.0537636 0)
(0.219208 -0.0556923 0)
(0.236103 -0.0568276 0)
(0.0211098 -0.000517017 0)
(0.0577787 -0.00540355 1.96966e-21)
(0.0896709 -0.0139474 -1.81628e-21)
(0.116738 -0.021471 -3.07953e-21)
(0.13994 -0.0275953 0)
(0.160456 -0.0321839 -2.20382e-21)
(0.179368 -0.0353129 2.0494e-21)
(0.197481 -0.0371653 0)
(0.215253 -0.0378593 -2.19148e-21)
(0.232591 -0.0377738 2.08964e-21)
(0.017861 0.000519881 0)
(0.0514338 -0.00172048 -1.60993e-20)
(0.0821114 -0.00738572 0)
(0.108885 -0.0122537 -1.2953e-20)
(0.132298 -0.0160261 0)
(0.153271 -0.0185561 1.00126e-20)
(0.17272 -0.0198814 0)
(0.191345 -0.0201541 -6.47874e-21)
(0.209494 -0.0193765 6.06782e-21)
(0.226933 -0.017844 4.63982e-21)
(0.0147043 0.00110373 4.34246e-21)
(0.0452376 0.00115635 7.98717e-21)
(0.0745815 -0.00164985 3.67601e-21)
(0.100842 -0.00371722 6.53172e-21)
(0.124189 -0.00490721 5.93137e-21)
(0.145315 -0.00511696 -5.07005e-21)
(0.164988 -0.00438178 -4.59619e-21)
(0.18381 -0.00284782 -6.66435e-22)
(0.202002 -0.000419742 -6.6192e-21)
(0.219158 0.00272498 -4.64291e-21)
(0.0117147 0.00128978 4.39026e-21)
(0.0393321 0.00335265 7.96314e-21)
(0.0672536 0.0034023 1.44828e-20)
(0.0927936 0.00425461 -6.67743e-21)
(0.115795 0.00582193 0)
(0.136754 0.00812098 0)
(0.156318 0.0110927 8.904e-21)
(0.175001 0.0145787 7.55662e-21)
(0.192894 0.0187582 -6.88646e-21)
(0.209396 0.023615 3.79392e-21)
(0.00896102 0.00114453 -4.24441e-21)
(0.0338327 0.00500816 -3.87731e-21)
(0.06026 0.00792167 2.16936e-20)
(0.0848798 0.0117795 -3.31932e-20)
(0.107255 0.0162141 6.09422e-21)
(0.127727 0.0211261 0)
(0.146845 0.0264164 0)
(0.165058 0.0319017 -4.08355e-20)
(0.182341 0.0378364 3.50776e-20)
(0.197894 0.0444359 1.56637e-20)
(0.0065008 0.000743357 -3.32291e-20)
(0.0288232 0.00626628 0)
(0.0536924 0.0120529 -2.8984e-20)
(0.0771981 0.0189624 2.65976e-20)
(0.0986747 0.026307 0)
(0.118343 0.0338515 -1.07147e-20)
(0.136688 0.0414503 2.94877e-20)
(0.154126 0.0488853 3.32093e-20)
(0.170553 0.0564699 -1.53415e-20)
(0.185005 0.0647675 -1.22859e-20)
(0.00437758 0.000167061 6.53721e-20)
(0.0243555 0.00726422 7.65215e-21)
(0.0476044 0.0159229 1.38359e-20)
(0.069809 0.0258881 3.25472e-20)
(0.0901252 0.0361247 1.19318e-20)
(0.108689 0.04625 1.06714e-20)
(0.125944 0.0560705 -6.37005e-23)
(0.142307 0.0653169 0)
(0.157669 0.0742932 0)
(0.170988 0.0840723 -2.48192e-20)
(0.00261747 -0.000503328 -3.21436e-20)
(0.0204499 0.00812365 2.90005e-20)
(0.042018 0.0196331 -2.10576e-20)
(0.0627463 0.0326188 -4.52502e-20)
(0.0816582 0.0456863 1.18701e-20)
(0.0988333 0.0583037 -1.10356e-20)
(0.114699 0.0702412 -9.60355e-21)
(0.129718 0.0811886 0)
(0.143894 0.0912651 0)
(0.1563 0.102026 1.31802e-20)
(0.0012274 -0.00119263 3.77144e-21)
(0.0170988 0.00894223 -3.61789e-20)
(0.0369322 0.0232543 6.61498e-21)
(0.0560281 0.0391948 0)
(0.0733105 0.0550105 0)
(0.0888039 0.0700082 -2.13017e-20)
(0.102882 0.0838706 0)
(0.115937 0.0961451 1.60518e-20)
(0.128108 0.106338 -1.12965e-21)
(0.139164 0.115849 -1.33606e-20)
(0.000194338 -0.00183883 0)
(0.0142695 0.00978568 0)
(0.0323298 0.0268226 2.48168e-20)
(0.0496709 0.0456417 0)
(0.0651357 0.0641783 -1.09667e-20)
(0.0786586 0.0816837 1.01634e-20)
(0.0904313 0.0980114 0)
(0.100524 0.1133 0)
(0.109103 0.128085 1.22115e-20)
(0.116989 0.145489 -2.22092e-20)
(-0.000513521 -0.00240213 0)
(0.0119093 0.0106753 1.82468e-20)
(0.0281871 0.0303249 4.45726e-21)
(0.043717 0.0519332 2.18599e-20)
(0.0573064 0.0731837 9.84438e-21)
(0.0688555 0.0933788 2.80173e-20)
(0.0785395 0.112666 0)
(0.086556 0.131774 0)
(0.0936603 0.151784 0)
(0.101174 0.174331 9.11205e-22)
(-0.000941714 -0.00286618 0)
(0.00995611 0.0115877 4.22973e-21)
(0.0244812 0.0336927 -1.29442e-20)
(0.0382127 0.0579666 -1.66315e-20)
(0.0499792 0.081884 -1.52987e-21)
(0.0597007 0.10482 -1.43774e-21)
(0.0676385 0.12716 -1.51001e-20)
(0.074174 0.149859 1.31228e-20)
(0.080168 0.173836 -2.17432e-20)
(0.0864353 0.199094 1.91681e-20)
(-0.00113991 -0.00323666 2.8738e-21)
(0.00834851 0.0124657 -1.73624e-20)
(0.0211826 0.0368154 -2.67457e-20)
(0.0331865 0.063592 2.81236e-20)
(0.0432361 0.0900614 -1.88066e-20)
(0.0512817 0.115639 -1.72462e-20)
(0.0576739 0.14081 7.74046e-21)
(0.0628942 0.16645 -2.49131e-20)
(0.0676793 0.192981 2.77334e-21)
(0.0724674 0.219345 9.2907e-21)
(-0.0011579 -0.00354296 2.61793e-21)
(0.00702614 0.0132195 -2.48738e-21)
(0.0182642 0.039547 0)
(0.028658 0.0686247 -2.27961e-20)
(0.0371275 0.0974698 4.02532e-21)
(0.0436577 0.125476 -2.89263e-22)
(0.0486662 0.153113 6.53521e-21)
(0.0526801 0.181022 1.51987e-20)
(0.0562853 0.209122 1.05863e-22)
(0.0597517 0.235806 -9.39254e-21)
(-0.00103955 -0.00383368 0)
(0.00593761 0.0137284 1.28276e-20)
(0.0157057 0.0417287 -4.13434e-21)
(0.0246392 0.072857 1.10072e-20)
(0.0316982 0.103856 -3.53911e-21)
(0.0368978 0.134016 -6.88929e-22)
(0.0406979 0.163703 -6.91041e-22)
(0.0436391 0.193298 -9.21328e-21)
(0.0461712 0.222352 1.04573e-20)
(0.0485011 0.249064 -7.75965e-21)
(-0.000818477 -0.00416623 -1.03315e-21)
(0.00505239 0.0138611 -8.34406e-21)
(0.0134936 0.0431914 0)
(0.0211348 0.0760785 -1.04501e-20)
(0.0269788 0.108977 8.44596e-21)
(0.0310508 0.14099 2.50361e-21)
(0.0338275 0.172324 -7.26217e-21)
(0.0358441 0.203139 0)
(0.0374468 0.23277 0)
(0.0388137 0.259464 0)
(-0.000512831 -0.00459519 8.84529e-22)
(0.0043616 0.0135007 2.19567e-21)
(0.0116171 0.0437638 -2.76258e-21)
(0.0181402 0.0780869 -3.82416e-21)
(0.0229789 0.112612 -4.17326e-21)
(0.0261347 0.146183 -1.81761e-21)
(0.0280755 0.17882 0)
(0.0293242 0.210511 -2.314e-21)
(0.0301621 0.240511 1.4693e-21)
(0.0307412 0.267237 0)
(-0.000126445 -0.00516507 0)
(0.00387109 0.0125516 -4.26563e-21)
(0.0100727 0.043294 2.76193e-21)
(0.0156448 0.078695 2.47411e-21)
(0.0196836 0.114564 8.61314e-23)
(0.0221364 0.149431 9.92972e-22)
(0.0234314 0.1831 -4.72479e-22)
(0.0240739 0.215443 0)
(0.0243207 0.245721 6.97898e-22)
(0.0242863 0.272564 -1.06378e-22)
(0.00034696 -0.00588878 -7.69608e-23)
(0.00359954 0.0109705 1.36224e-21)
(0.0088647 0.0416816 1.07099e-22)
(0.0136326 0.0777445 -1.95712e-23)
(0.017061 0.114657 6.25751e-22)
(0.019017 0.150586 0)
(0.0198561 0.185091 4.72314e-22)
(0.0200534 0.217955 0)
(0.0198663 0.248502 0)
(0.0193899 0.275559 0)
)
;
boundaryField
{
inlet
{
type uniformFixedValue;
uniformValue constant (1 0 0);
value uniform (1 0 0);
}
outlet
{
type pressureInletOutletVelocity;
value nonuniform List<vector>
40
(
(-0.000606913 0.246745 0)
(-0.00336355 0.35107 0)
(-0.00053954 0.442873 0)
(0.00223845 0.491197 0)
(0.00376387 0.507263 0)
(0.00528934 0.513074 0)
(0.00490579 0.531927 0)
(0.00427993 0.595805 0)
(-0.000303041 0.718808 0)
(-0.000618317 0.849268 0)
(0.00284423 0.203922 6.37098e-23)
(0.00379082 0.185651 -2.54746e-24)
(0.004621 0.166319 6.46714e-23)
(0.00524301 0.145121 2.02822e-24)
(0.00550655 0.121496 -6.18092e-23)
(0.00538054 0.0953625 0)
(0.00492059 0.0671883 3.14922e-23)
(0.0042479 0.0378909 -5.96953e-23)
(0.00350069 0.00861236 -1.43911e-23)
(0 -0.0195537 0)
(0 -0.0458155 0)
(0 -0.0697873 0)
(0 -0.0914221 0)
(0 -0.110902 0)
(0 -0.12853 0)
(0 -0.144637 0)
(0 -0.159535 0)
(0 -0.173495 0)
(0 -0.18674 0)
(0 -0.199459 0)
(0 -0.22883 0)
(0 -0.276371 0)
(0 -0.325113 0)
(0 -0.377814 0)
(0 -0.439703 0)
(0 -0.517046 0)
(0 -0.613944 0)
(0 -0.721484 0)
(0 -0.810529 0)
(0 -0.857514 0)
)
;
}
cylinder
{
type fixedValue;
value uniform (0 0 0);
}
top
{
type symmetryPlane;
}
bottom
{
type symmetryPlane;
}
defaultFaces
{
type empty;
}
}
// ************************************************************************* //
| [
"henry.rossiter@utexas.edu"
] | henry.rossiter@utexas.edu | |
b9dded1cdfad27c4454000bb82c2415511336864 | 7558545b658fd7c150e3b6aa36853352ebca8188 | /lib/include/py2cpp/fractions.hpp | c3686e50afe6dca6bc732418fb3f0eb697a13662 | [
"MIT"
] | permissive | luk036/ellcpp | ae947d3dc54f1d9fd875bafc410e848382dc9568 | 5ec9a0f3b78969305d3100c767a6d67f37e7fd26 | refs/heads/master | 2022-12-05T03:03:28.667027 | 2022-12-01T12:28:46 | 2022-12-01T12:28:46 | 104,174,540 | 4 | 2 | MIT | 2020-01-20T10:42:00 | 2017-09-20T06:23:27 | C++ | UTF-8 | C++ | false | false | 11,461 | hpp | // -*- coding: utf-16 -*-
#pragma once
/*! @file include/fractions.hpp
* This is a C++ Library header.
*/
#include <boost/operators.hpp>
#include <cmath>
#include <numeric>
#include <type_traits>
namespace fun
{
/*!
* @brief Greatest common divider
*
* @tparam _Mn
* @param[in] __m
* @param[in] __n
* @return _Mn
*/
template <typename Mn>
constexpr auto gcd(Mn _m, Mn _n) -> Mn
{
return _m == 0 ? abs(_n) : _n == 0 ? abs(_m) : gcd(_n, _m % _n);
}
/*!
* @brief Least common multiple
*
* @tparam _Mn
* @param[in] __m
* @param[in] __n
* @return _Mn
*/
template <typename Mn>
constexpr auto lcm(Mn _m, Mn _n) -> Mn
{
return (_m != 0 && _n != 0) ? (abs(_m) / gcd(_m, _n)) * abs(_n) : 0;
}
template <typename Z>
struct Fraction : boost::totally_ordered<Fraction<Z>,
boost::totally_ordered2<Fraction<Z>, Z,
boost::multipliable2<Fraction<Z>, Z,
boost::dividable2<Fraction<Z>, Z>>>>
{
Z _numerator;
Z _denominator;
/*!
* @brief Construct a new Fraction object
*
* @param[in] numerator
* @param[in] denominator
*/
constexpr Fraction(Z&& numerator, Z&& denominator) noexcept
: _numerator {std::move(numerator)}
, _denominator {std::move(denominator)}
{
this->normalize();
}
/*!
* @brief Construct a new Fraction object
*
* @param[in] numerator
* @param[in] denominator
*/
constexpr Fraction(const Z& numerator, const Z& denominator)
: _numerator {numerator}
, _denominator {denominator}
{
this->normalize();
}
constexpr void normalize()
{
auto common = gcd(this->_numerator, this->_denominator);
if (common == Z(1))
{
return;
}
// if (common == Z(0)) [[unlikely]] return; // both num and den are zero
if (this->_denominator < Z(0))
{
common = -common;
}
this->_numerator /= common;
this->_denominator /= common;
}
/*!
* @brief Construct a new Fraction object
*
* @param[in] numerator
*/
constexpr explicit Fraction(Z&& numerator) noexcept
: _numerator {std::move(numerator)}
, _denominator(Z(1))
{
}
/*!
* @brief Construct a new Fraction object
*
* @param[in] numerator
*/
constexpr explicit Fraction(const Z& numerator)
: _numerator {numerator}
, _denominator(Z(1))
{
}
/*!
* @brief
*
* @return const Z&
*/
[[nodiscard]] constexpr auto numerator() const -> const Z&
{
return _numerator;
}
/*!
* @brief
*
* @return const Z&
*/
[[nodiscard]] constexpr auto denominator() const -> const Z&
{
return _denominator;
}
/*!
* @brief
*
* @return Fraction
*/
[[nodiscard]] constexpr auto abs() const -> Fraction
{
return Fraction(std::abs(_numerator), std::abs(_denominator));
}
/*!
* @brief
*
*/
constexpr void reciprocal()
{
std::swap(_numerator, _denominator);
}
/*!
* @brief
*
* @return Fraction
*/
constexpr auto operator-() const -> Fraction
{
auto res = Fraction(*this);
res._numerator = -res._numerator;
return res;
}
/*!
* @brief
*
* @param[in] frac
* @return Fraction
*/
constexpr auto operator+(const Fraction& frac) const -> Fraction
{
if (_denominator == frac._denominator)
{
return Fraction(_numerator + frac._numerator, _denominator);
}
auto d = _denominator * frac._denominator;
auto n =
frac._denominator * _numerator + _denominator * frac._numerator;
return Fraction(n, d);
}
/*!
* @brief
*
* @param[in] frac
* @return Fraction
*/
constexpr auto operator-(const Fraction& frac) const -> Fraction
{
return *this + (-frac);
}
/*!
* @brief
*
* @param[in] frac
* @return Fraction
*/
constexpr auto operator*(const Fraction& frac) const -> Fraction
{
auto n = _numerator * frac._numerator;
auto d = _denominator * frac._denominator;
return Fraction(std::move(n), std::move(d));
}
/*!
* @brief
*
* @param[in] frac
* @return Fraction
*/
constexpr auto operator/(Fraction frac) const -> Fraction
{
frac.reciprocal();
return *this * frac;
}
/*!
* @brief
*
* @param[in] i
* @return Fraction
*/
constexpr auto operator+(const Z& i) const -> Fraction
{
auto n = _numerator + _denominator * i;
return Fraction(std::move(n), _denominator);
}
/*!
* @brief
*
* @param[in] i
* @return Fraction
*/
constexpr auto operator-(const Z& i) const -> Fraction
{
return *this + (-i);
}
// /*!
// * @brief
// *
// * @param[in] i
// * @return Fraction
// */
// constexpr Fraction operator*(const Z& i) const
// {
// auto n = _numerator * i;
// return Fraction(n, _denominator);
// }
// /*!
// * @brief
// *
// * @param[in] i
// * @return Fraction
// */
// constexpr Fraction operator/(const Z& i) const
// {
// auto d = _denominator * i;
// return Fraction(_numerator, d);
// }
/*!
* @brief
*
* @param[in] frac
* @return Fraction
*/
constexpr auto operator+=(const Fraction& frac) -> Fraction&
{
return *this = *this + frac;
}
/*!
* @brief
*
* @param[in] frac
* @return Fraction
*/
constexpr auto operator-=(const Fraction& frac) -> Fraction&
{
return *this = *this - frac;
}
/*!
* @brief
*
* @param[in] frac
* @return Fraction
*/
constexpr auto operator*=(const Fraction& frac) -> Fraction&
{
return *this = *this * frac;
}
/*!
* @brief
*
* @param[in] frac
* @return Fraction
*/
constexpr auto operator/=(const Fraction& frac) -> Fraction&
{
return *this = *this / frac;
}
/*!
* @brief
*
* @param[in] i
* @return Fraction
*/
constexpr auto operator+=(const Z& i) -> Fraction&
{
return *this = *this + i;
}
/*!
* @brief
*
* @param[in] i
* @return Fraction
*/
constexpr auto operator-=(const Z& i) -> Fraction&
{
return *this = *this - i;
}
/*!
* @brief
*
* @param[in] i
* @return Fraction
*/
constexpr auto operator*=(const Z& i) -> Fraction&
{
const auto common = gcd(i, this->_denominator);
if (common == Z(1))
{
this->_numerator *= i;
}
// else if (common == Z(0)) [[unlikely]] // both i and den are zero
// {
// this->_numerator = Z(0);
// }
else
{
this->_numerator *= (i / common);
this->_denominator /= common;
}
return *this;
}
/*!
* @brief
*
* @param[in] i
* @return Fraction
*/
constexpr auto operator/=(const Z& i) -> Fraction&
{
const auto common = gcd(this->_numerator, i);
if (common == Z(1))
{
this->_denominator *= i;
}
// else if (common == Z(0)) [[unlikely]] // both i and num are zero
// {
// this->_denominator = Z(0);
// }
else
{
this->_denominator *= (i / common);
this->_numerator /= common;
}
return *this;
}
/*!
* @brief Three way comparison
*
* @param[in] frac
* @return auto
*/
template <typename U>
constexpr auto cmp(const Fraction<U>& frac) const
{
// if (_denominator == frac._denominator) {
// return _numerator - frac._numerator;
// }
return _numerator * frac._denominator - _denominator * frac._numerator;
}
constexpr auto operator==(const Fraction<Z>& rhs) const -> bool
{
if (this->_denominator == rhs._denominator)
{
return this->_numerator == rhs._numerator;
}
return (this->_numerator * rhs._denominator) ==
(this->_denominator * rhs._numerator);
}
constexpr auto operator<(const Fraction<Z>& rhs) const -> bool
{
if (this->_denominator == rhs._denominator)
{
return this->_numerator < rhs._numerator;
}
return (this->_numerator * rhs._denominator) <
(this->_denominator * rhs._numerator);
}
/**
* @brief
*
*/
constexpr auto operator==(const Z& rhs) const -> bool
{
return this->_denominator == Z(1) && this->_numerator == rhs;
}
/**
* @brief
*
*/
constexpr auto operator<(const Z& rhs) const -> bool
{
return this->_numerator < (this->_denominator * rhs);
}
/**
* @brief
*
*/
constexpr auto operator>(const Z& rhs) const -> bool
{
return this->_numerator > (this->_denominator * rhs);
}
// /*!
// * @brief
// *
// * @return double
// */
// constexpr explicit operator double()
// {
// return double(_numerator) / _denominator;
// }
// /**
// * @brief
// *
// */
// friend constexpr bool operator<(const Z& lhs, const Fraction<Z>& rhs)
// {
// return lhs * rhs.denominator() < rhs.numerator();
// }
};
/*!
* @brief
*
* @param[in] c
* @param[in] frac
* @return Fraction<Z>
*/
template <typename Z>
constexpr auto operator+(const Z& c, const Fraction<Z>& frac) -> Fraction<Z>
{
return frac + c;
}
/*!
* @brief
*
* @param[in] c
* @param[in] frac
* @return Fraction<Z>
*/
template <typename Z>
constexpr auto operator-(const Z& c, const Fraction<Z>& frac) -> Fraction<Z>
{
return c + (-frac);
}
// /*!
// * @brief
// *
// * @param[in] c
// * @param[in] frac
// * @return Fraction<Z>
// */
// template <typename Z>
// constexpr Fraction<Z> operator*(const Z& c, const Fraction<Z>& frac)
// {
// return frac * c;
// }
/*!
* @brief
*
* @param[in] c
* @param[in] frac
* @return Fraction<Z>
*/
template <typename Z>
constexpr auto operator+(int&& c, const Fraction<Z>& frac) -> Fraction<Z>
{
return frac + c;
}
/*!
* @brief
*
* @param[in] c
* @param[in] frac
* @return Fraction<Z>
*/
template <typename Z>
constexpr auto operator-(int&& c, const Fraction<Z>& frac) -> Fraction<Z>
{
return (-frac) + c;
}
/*!
* @brief
*
* @param[in] c
* @param[in] frac
* @return Fraction<Z>
*/
template <typename Z>
constexpr auto operator*(int&& c, const Fraction<Z>& frac) -> Fraction<Z>
{
return frac * c;
}
/*!
* @brief
*
* @tparam _Stream
* @tparam Z
* @param[in] os
* @param[in] frac
* @return _Stream&
*/
template <typename Stream, typename Z>
auto operator<<(Stream& os, const Fraction<Z>& frac) -> Stream&
{
os << frac.numerator() << "/" << frac.denominator();
return os;
}
// For template deduction
// Integral{Z} Fraction(const Z &, const Z &) -> Fraction<Z>;
} // namespace fun
| [
"luk036@gmail.com"
] | luk036@gmail.com |
24b3b79887cca20366056d5abb321438206376a7 | d1e4718197ba3bddd13d6f6958e1d5a492b51af5 | /Object/Line_Type.h | 8d20c3e638d5b732a1c329d4af1750f7599bbc65 | [] | no_license | reisoftware/ap2d | 1f398664fdc4f8cab9479df18cd2a745f904cdff | e09732655ef66e13e98b8f3b008c91dac541e1f5 | refs/heads/master | 2022-01-22T05:36:56.295845 | 2022-01-04T05:31:57 | 2022-01-04T05:31:57 | 162,372,004 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,653 | h |
#ifndef _TIAN_OBJECT_LINE_TYPE_H_
#define _TIAN_OBJECT_LINE_TYPE_H_
#include "export.h"
#include <vector>
#include "iolua.h"
#include "../afc/counter.h"
#pragma warning (disable:4786)
// class iLua_File;
// class oLua_File;
namespace dlhml{
OBJECT_API LPCTSTR lt_continue();
OBJECT_API LPCTSTR lt_dot();
OBJECT_API LPCTSTR lt_center();
class OBJECT_API Line_Type
{
public:
Line_Type();
Line_Type(const Line_Type& rhs);
Line_Type& operator =(const Line_Type& rhs);
virtual ~Line_Type();
static Line_Type* create_me();
bool close();
void save_lua(std::ofstream &out,char *name,int tab_num);
void open_lua(lua_State *l,char *name) ;
void name(LPCTSTR n) {string_copy(name_,n);}
LPCTSTR name() const {return name_;}
void set_style(DWORD* style,int num);
HPEN get_pen(COLORREF col, bool sel) const;
HPEN get_pen(DWORD* style,int num,COLORREF col)const;
char Name[MAX_DXF_LEN]; // Line Type Name
char StandardFlags; // Standard flags
char DescriptiveText[MAX_DXF_LEN]; // Descriptive Text
short ElementsNumber; // Line Elements Number
double Elements[LINE_ELEM_MAX_NUM]; // Line Elements (Max=30)
double PatternLength; // Length of linetype pattern
private:
LPTSTR name_;
#pragma warning(push)
#pragma warning(disable:4251)
std::vector<DWORD> style_;
#pragma warning(pop)
static void* operator new(size_t size){
return ::operator new(size);
}
static void operator delete(void* ptr){
::operator delete(ptr);
}
//zhong 10-9-6
private:
MCT_DEF
};
}//namespace
#endif//FILE
| [
"tian_bj@126.com"
] | tian_bj@126.com |
ba721d5dfef3978b3165e70735fa4d3988b17587 | 814d2840dcf9aaa27a9eba83d1548253fc633d7c | /Sliding Brick Puzzle/Node.cpp | 93d734001f984fd695604436c6e454e96b8f7984 | [] | no_license | jinu2ID/AI | f351b245b907a486f4d1851649b3b4a3341dd00c | 3ddbaca740886ed7bde2895ef9a2fb9dfc88e75e | refs/heads/master | 2016-12-13T14:19:26.992217 | 2016-05-25T01:04:22 | 2016-05-25T01:04:22 | 47,855,957 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,588 | cpp | /*
Created: 10/18/15
Author: Jinu Jacob
jj559@drexel.edi
node class implementation for Sliding Brick Puzzle
*/
#include <vector>
#include <string>
#include <iostream>
#include "Node.h"
#include "GameState.h"
using namespace std;
// Constructors
Node::Node(){
state = GameState();
parent = NULL;
parentMove = Move();
g = 0;
}
Node::Node(GameState _state){
state = _state;
parent = NULL;
parentMove = Move();
g = 0;
}
Node::Node(GameState _state, Node *_parent){
state = _state;
parent = _parent;
parentMove = Move();
g = 0;
}
Node::Node(GameState _state, Node *_parent, Move _parentMove){
state = _state;
parent = _parent;
parentMove = _parentMove;
g = 0;
}
Node::Node(GameState _state, Node *_parent, Move _parentMove, int _g){
state = _state;
parent = _parent;
parentMove = _parentMove;
g = _g;
}
// Copy Constructor
Node::Node(const Node &nSource){
state = nSource.state;
parent = nSource.parent;
parentMove = nSource.parentMove;
f = nSource.f;
g = nSource.g;
h = nSource.h;
}
// Inspectors
bool Node::checkSolved(){
return state.checkSolved();
}
bool Node::compareNode(const Node otherNode){
if (state == otherNode.state)
return true;
else
return false;
}
void Node::printNode(){
parentMove.printMove();
state.printState();
cout << "F:" << f << " G:" << g << " H:" << h << endl;
}
int Node::getFScore(){
return f;
}
int Node::getGScore(){
return g;
}
// Accessors
GameState Node::getState(){
return state;
}
Node* Node::getParent(){
return parent;
}
// Creates a hash from a gameState by converting the 2D vector to a single
// string
string Node::hashNode(){
string hash; // Stores hash
vector< vector<int> > state = this->getState().getBoard();
int i,j;
for ( i = 0; i < state.size(); i++){ // [#1]
for (j = 0; j < state[i].size(); j++){
// Convert number to string and append to hash string
int number = state[i][j];
string numberStr = static_cast<ostringstream*>( &(ostringstream()
<< number) )->str();
hash.append(numberStr);
}
}
return hash;
}
// [#1] To create a unique hash this function takes the values in a matrix
// and turns them into a one line string. So for the following matrix:
//
// 1 2 3
// 4 5 6 ----[ nodeHash()]------> "123456789012"
// 7 8 9
// 0 1 2
//
// Of course a 3 X 4 matrix with the same values in the same order would
// return the same hash, but for our sliding brick puzzles the dimensions
// of the board stay the same (even if we did have have to deal with changing
// dimensions we could tag the height and width to the hash to ensure
// that it was unique). Therefore any two game states will return the same
// hash.
// Sets g(n) for node by adding +1 to the parent nodes g score
void Node::setGScore(){
if (parent == NULL)
g = 0;
else
g = parent->g + 1;
}
// Sets h(n) for node using heuristic 1 which is Manhattan distance
void Node::setH1Score(){
// Get average of distance between goals and pieces
int distance = state.getDistance(2,-1);
// Set h = avg distance
h = distance;
}
// Adds number of blocker to Manhattan distance
void Node::setH2Score(){
// Get distance between goals and pieces and number of blockers
int distance = state.getDistance(2,-1);
int blockers = state.getBlocked(2,-1);
h = distance + blockers;
}
// f(n) = g(n) + h(n)
void Node::setFScore(){
f = g + h;
}
// Set f(n) and h(n)
void Node::setScores(){
this->setH1Score();
this->setFScore();
}
// Set scores using H2 heuristic
void Node::setScoresH2(){
this->setH2Score();
this->setFScore();
}
| [
"jj559@drexel.edu"
] | jj559@drexel.edu |
b128d77279abaab7d44e0dc4062988168012bfe5 | 6911d361705934417fe1aa525cc27325e8a67213 | /9_the_viewport_renderer_at_postition/09_the_viewport.cpp | f6245286823a376cd1e3b0581628f8a28d1b253a | [] | no_license | sws-54/SDL | 5deef826903e1db0e1aeb4078e9018b4d086caca | 20f2006b7c15bc32ed6e6ef545e9069cdee943be | refs/heads/master | 2020-03-17T07:15:02.011783 | 2018-06-02T01:56:21 | 2018-06-02T01:56:21 | 133,390,194 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,155 | cpp | #include <cstdio>
#include <SDL.h>
#include <SDL_image.h>
#include <string>
// screen sizes
const int Width = 640;
const int Height = 480;
// start SDL
void Start();
// load images
void LoadImage(std::string);
// end SDL
void End();
// window
SDL_Window *Window = nullptr;
// renderer
SDL_Renderer *Renderer = nullptr;
// texutre
SDL_Texture *Texture = nullptr;
void Start()
{
if (SDL_Init(SDL_INIT_VIDEO) < 0)
printf("Error at [SDL_INIT_VIDEO] \n%s\n", SDL_GetError());
Window = SDL_CreateWindow("title", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_WINDOW_SHOWN);
if(Window == nullptr)
printf("Error at [SDL_CreateWindow] \n%s\n", SDL_GetError());
Renderer = SDL_CreateRenderer(Window, -1, 0);
if(Renderer == nullptr)
printf("Error at [SDL_CreateRenderer] \n%s\n", SDL_GetError());
if(!IMG_Init(IMG_INIT_PNG))
printf("Error at [IMG_Init] \n%s\n", IMG_GetError());
}
void End()
{
SDL_DestroyRenderer(Renderer);
SDL_DestroyWindow(Window);
SDL_DestroyTexture(Texture);
Renderer = nullptr;
Window = nullptr;
Texture = nullptr;
SDL_Quit();
}
void LoadImage(std::string Path)
{
// create tmp surface to load img to
SDL_Surface *TmpSurface = IMG_Load(Path.c_str());
if(TmpSurface == nullptr)
printf("Error at [IMG_Load] \n%s\n", IMG_GetError());
Texture = SDL_CreateTextureFromSurface(Renderer, TmpSurface);
if(Texture == nullptr)
printf("Error at [SDL_CreateTextureFromSurface] \n%s\n", SDL_GetError());
}
int main(int argc,char* args[])
{
Start();
SDL_Event Events;
LoadImage("files/viewport.png");
bool Quit = false;
while (Quit == false)
{
while (SDL_PollEvent(&Events))
{
if (Events.type == SDL_QUIT)
Quit = true;
}
SDL_SetRenderDrawColor(Renderer, 255, 255, 255, 255);
SDL_RenderClear(Renderer);
// create rect
SDL_Rect TopLeft;
TopLeft.x = 0;
TopLeft.y = Height/2;
TopLeft.w = Width/2;
TopLeft.h = Height / 2;
// set to rendere at a given Rect
SDL_RenderSetViewport(Renderer, &TopLeft);
// send texture to renderer
SDL_RenderCopy(Renderer, Texture, nullptr, nullptr);
SDL_RenderPresent(Renderer);
}
End();
return 0;
} | [
"38383942+sws-54@users.noreply.github.com"
] | 38383942+sws-54@users.noreply.github.com |
8087dda9a212b5a01733409ba7925705316c6531 | b2f2c4942f535285a28cfaa2127abc4a33a54c4a | /syzygy/kasko/waitable_timer.h | abed0119f620f98e37963dfabfae55744c38eca3 | [
"Apache-2.0"
] | permissive | pombreda/syzygy | 4f71e27e54182e26ee3f6605be62d60210bb5820 | 7bac6936c0c28872bfabc10a1108e0157ff65d4a | refs/heads/master | 2021-01-25T07:08:04.019036 | 2015-03-12T18:29:28 | 2015-03-12T18:29:28 | 32,210,396 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,317 | h | // Copyright 2014 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SYZYGY_KASKO_WAITABLE_TIMER_H_
#define SYZYGY_KASKO_WAITABLE_TIMER_H_
#include <windows.h>
namespace kasko {
// Defines an interface for a timer that can be used with the Windows wait
// functions (WaitForSingleObject, WaitForMultipleObjects, etc.). The wait
// interval is determined by the implementation.
class WaitableTimer {
public:
virtual ~WaitableTimer() {}
// Starts the timer.
virtual void Start() = 0;
// Returns a HANDLE that will be signaled when the timer completes.
// @returns an automatically resetting HANDLE compatible with the Windows wait
// functions.
virtual HANDLE GetHANDLE() = 0;
};
} // namespace kasko
#endif // SYZYGY_KASKO_WAITABLE_TIMER_H_
| [
"erikwright@chromium.org"
] | erikwright@chromium.org |
4489e8542cb81a93aba226342a008044e87ce21c | c5e26167d000f9d52db0a1491c7995d0714f8714 | /洛谷/P4503 [CTSC2014]企鹅QQ.cpp | b0cadff0b3463056ef16b393703e804686a9e4c3 | [] | no_license | memset0/OI-Code | 48d0970685a62912409d75e1183080ec0c243e21 | 237e66d21520651a87764c385345e250f73b245c | refs/heads/master | 2020-03-24T21:23:04.692539 | 2019-01-05T12:38:28 | 2019-01-05T12:38:28 | 143,029,281 | 18 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,175 | cpp | // luogu-judger-enable-o2
// ==============================
// author: memset0
// website: https://memset0.cn
// ==============================
#include <bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for (int i = l; i <= r; i++)
#define getc(x) getchar(x)
#define putc(x) putchar(x)
template <typename T> inline void read(T &x) {
x = 0; register char ch; register bool fl = 0;
while (ch = getc(), ch < 48 || 57 < ch) fl ^= ch == '-'; x = (ch & 15);
while (ch = getc(), 47 < ch && ch < 58) x = (x << 1) + (x << 3) + (ch & 15);
if (fl) x = -x;
}
template <typename T> inline void readc(T &x) {
while (x = getc(), !islower(x) && !isupper(x));
}
template <typename T> inline void print(T x, char c = ' ') {
static int buf[40];
if (x == 0) { putc('0'); putc(c); return; }
if (x < 0) putc('-'), x = -x;
for (buf[0] = 0; x; x /= 10) buf[++buf[0]] = x % 10 + 48;
while (buf[0]) putc((char) buf[buf[0]--]);
putc(c);
}
const int maxn = 30010, maxm = 210;
const int M = 13131;
int n, m, t, val, ans, tmp;
int a[maxm]; char s[maxm];
unsigned long long now, mul[maxm], l[maxm], r[maxm];
unsigned long long f[maxm][maxn];
typedef std::map < int, int > mapType;
typedef mapType::iterator mapIterator;
mapType map[maxm];
int change(char c) {
if ('a' <= c && c <= 'z') return c - 'a' + 1;
if ('A' <= c && c <= 'Z') return c - 'A' + 27;
if ('0' <= c && c <= '9') return c - '0' + 53;
if (c == '_') return 63;
if (c == '@') return 64;
}
int inv(int x, int p) {
if (x == 0 || x == 1) return 1;
return 1ll * (p - p / x) * inv(p % x, p) % p;
}
int main() {
// freopen("1.in", "r", stdin);
read(n), read(m), read(t);
for (int k = 1; k <= n; k++) {
scanf("%s", s + 1);
for (int i = 1; i <= m; i++)
a[i] = change(s[i]);
for (int i = 1; i <= m; i++)
l[i] = l[i - 1] * M + a[i];
for (int i = m; i >= 1; i--)
r[i] = r[i + 1] * M + a[i];
for (int i = 1; i <= m; i++)
f[i][k] = l[i - 1] * 137 + r[i + 1] * 129;
}
for (int i = 1; i <= m; i++) {
std::sort(f[i] + 1, f[i] + n + 1);
tmp = 0;
for (int j = 2; j <= n; j++)
if (f[i][j] == f[i][j - 1]) {
ans += ++tmp;
} else {
tmp = 0;
}
}
print(ans, '\n');
return 0;
} | [
"memset0@outlook.com"
] | memset0@outlook.com |
9c51da20874c4660a938cf00028742b3c094aba6 | d7021f77ae62fa2ea4dfeb609ac5d03fcefe915a | /StateMechanic/State/State.cpp | b1d20584808efeb210ab194e0e3eb313fa9400de | [
"MIT"
] | permissive | RadekVana/EmbeddedStateMechanic | 98684f28c9117a77d912809414050e9ab85786bd | 4ec58442bb5394709fa23693c2f0e102f45d13e3 | refs/heads/master | 2020-06-12T22:42:20.580017 | 2019-07-06T20:23:46 | 2019-07-06T20:23:46 | 194,450,749 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,207 | cpp | #include "State.hpp"
/******************************************************************************/
//State
State::State(IStateMachineWithEventFireRequest& sm, auto_ptr<EvHandler> entry, auto_ptr<EvHandler> exit):
IStateWithMachineRef(sm),
entryHandler(entry),
exitHandler(exit){}
void State::SinkEntryHandler(auto_ptr<EvHandler> eh){
entryHandler = eh;
}
void State::SinkExitHandler(auto_ptr<EvHandler> eh){
exitHandler = eh;
}
void State::FireEntry(auto_ptr<Iinfo> info) const{
(*entryHandler)(info);
}
void State::FireExit(auto_ptr<Iinfo> info) const{
(*exitHandler)(info);
}
bool State::IsCurrent() const{
return (&(GetParentStateMachine().GetCurrentState())) == this;
}
/******************************************************************************/
//TransitionOn
bool State::TransitionOn(Event& ev)const{
return TransitionOnTo(ev, *this);
}
bool State::TransitionOnWith(Event& ev, auto_ptr<EvHandler> evh)const{
return TransitionOnToWith(ev, *this, evh);
}
bool State::TransitionOnWithGuard(Event& ev, auto_ptr<TransitionGuard> grd) const{
return TransitionOnToWithGuard(ev, *this, grd);
}
bool State::TransitionOnWithGuardAndHandler(Event& ev, auto_ptr<TransitionGuard> grd,
auto_ptr<EvHandler> evh) const{
return TransitionOnToWithGuardAndHandler(ev, *this, grd, evh);
}
/******************************************************************************/
//TransitionOnTo
bool State::TransitionOnTo(Event& ev, const State& to)const{
auto_ptr<EvHandler> evh(new DummyEvHandler());
return TransitionOnToWith(ev, to, evh);
}
bool State::TransitionOnToWith(Event& ev, const State& to, auto_ptr<EvHandler> evh)const{
auto_ptr<TransitionGuard> grd(new DummyTransitionGuard);
return TransitionOnToWithGuardAndHandler(ev, to, grd, evh);
}
bool State::TransitionOnToWithGuard(Event& ev, const State& to, auto_ptr<TransitionGuard> grd) const{
auto_ptr<EvHandler> evh(new DummyEvHandler());
return TransitionOnToWithGuardAndHandler(ev, to, grd, evh);
}
bool State::TransitionOnToWithGuardAndHandler(Event& ev, const State& to,
auto_ptr<TransitionGuard> grd, auto_ptr<EvHandler> evh) const{
return ev.AddTransition(*this, to, evh, grd);
}
/******************************************************************************/
//InnerSelfTransitionOn
bool State::InnerSelfTransitionOn(Event& ev) const{
auto_ptr<EvHandler> evh(new DummyEvHandler());
return InnerSelfTransitionOnWith(ev, evh);
}
bool State::InnerSelfTransitionOnWith(Event& ev, auto_ptr<EvHandler> evh) const{
auto_ptr<TransitionGuard> grd(new DummyTransitionGuard);
return InnerSelfTransitionOnWithGuardAndHandler(ev, grd, evh);
}
bool State::InnerSelfTransitionOnWithGuard(Event& ev, auto_ptr<TransitionGuard> grd) const{
auto_ptr<EvHandler> evh(new DummyEvHandler());
return InnerSelfTransitionOnWithGuardAndHandler(ev, grd, evh);
}
bool State::InnerSelfTransitionOnWithGuardAndHandler(Event& ev, auto_ptr<TransitionGuard> grd,
auto_ptr<EvHandler> evh) const{
return ev.AddInnerTransition(*this, evh, grd);
} | [
"r.v.mail@centrum.cz"
] | r.v.mail@centrum.cz |
c4703e163cc7a573de308d8fdbde695003b2ef5c | 94903d3084f03c1255701126edb23095522b3583 | /0205 Isomorphic Strings.cpp | 6f8ac8db3ee3f49d64926dd4d46facf254f33e11 | [] | no_license | xieh1987/MyLeetCodeCpp | dcf786f4c5504e063ab30adcbb87436fc6067fb0 | 9fff547aa12cf64b801092d175b34caf8e56336f | refs/heads/master | 2021-08-08T03:07:54.297810 | 2021-07-16T23:21:53 | 2021-07-16T23:21:53 | 23,158,836 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 502 | cpp | class Solution {
public:
bool isIsomorphic(string s, string t) {
unordered_map<char, char> dicts, dictt;
for (int i=0;i<s.size();++i) {
if (dicts.find(s[i])!=dicts.end()) {
if (t[i]!=dicts[s[i]]) return false;
}
else dicts[s[i]] = t[i];
if (dictt.find(t[i])!=dictt.end()) {
if (s[i]!=dictt[t[i]]) return false;
}
else dictt[t[i]] = s[i];
}
return true;
}
};
| [
"xieh1987@users.noreply.github.com"
] | xieh1987@users.noreply.github.com |
9bfa6cf56773058f6efdf522edc59cc4ffff44ac | 21d6917fee2008882234866e0fea7e711438e03f | /Aurora/src/Platform/Windows/WindowsInput.cpp | daf792853537bc33970f4de5786f3673232ba56d | [
"Apache-2.0"
] | permissive | JoshuaColell/Aurora | 35cb20c13884366590b3315460665a5dd6fc840c | 2c081e085cc1e7420d6d4dac4a3927507d5ac594 | refs/heads/main | 2023-06-30T06:43:15.949419 | 2021-08-04T20:38:11 | 2021-08-04T20:38:11 | 391,793,905 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,113 | cpp | #include "aupch.h"
#include "WindowsInput.h"
#include "Aurora/Application.h"
#include <GLFW/glfw3.h>
namespace Aurora {
Input* Input::s_Instance = new WindowsInput();
bool WindowsInput::IsKeyPressedImpl(int keycode)
{
auto window = static_cast<GLFWwindow*>(Application::Get().GetWindow().GetNativeWindow());
auto state = glfwGetKey(window, keycode);
return state == GLFW_PRESS || state == GLFW_REPEAT;
}
bool WindowsInput::IsMouseButtonPressedImpl(int button)
{
auto window = static_cast<GLFWwindow*>(Application::Get().GetWindow().GetNativeWindow());
auto state = glfwGetMouseButton(window, button);
return state == GLFW_PRESS;
}
std::pair<float, float> WindowsInput::GetMousePositionImpl()
{
auto window = static_cast<GLFWwindow*>(Application::Get().GetWindow().GetNativeWindow());
double xpos, ypos;
glfwGetCursorPos(window, &xpos, &ypos);
return { (float)xpos, (float)ypos };
}
float WindowsInput::GetMouseXImpl()
{
auto [x, y] = GetMousePositionImpl();
return x;
}
float WindowsInput::GetMouseYImpl()
{
auto [x, y] = GetMousePositionImpl();
return y;
}
} | [
"luaadev@gmail.com"
] | luaadev@gmail.com |
ed44fa004942f8d870a20ffca3ac6b5c619dc6e1 | 8f5c6088261a55e3ffc0e28675b504ff545771ef | /GTEngine/Include/Mathematics/GteContEllipse2.h | 749dbca9d676f37d4eb39b828abe931f3a41994e | [
"BSL-1.0"
] | permissive | dfqytcom/GeometricTools-2 | 56283300e6b6a97e9441475e69fb283c70f17d44 | ae6e933f9ab3a5474d830700ea8d9445cc78ef4b | refs/heads/master | 2022-01-31T06:34:38.991605 | 2018-12-10T12:51:15 | 2018-12-10T12:51:15 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,613 | h | // David Eberly, Geometric Tools, Redmond WA 98052
// Copyright (c) 1998-2018
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
// http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
// File Version: 3.0.1 (2018/10/05)
#pragma once
#include <Mathematics/GteApprGaussian2.h>
#include <Mathematics/GteHyperellipsoid.h>
#include <Mathematics/GteProjection.h>
namespace gte
{
// The input points are fit with a Gaussian distribution. The center C of the
// ellipsoid is chosen to be the mean of the distribution. The axes of the
// ellipsoid are chosen to be the eigenvectors of the covariance matrix M.
// The shape of the ellipsoid is determined by the absolute values of the
// eigenvalues. NOTE: The construction is ill-conditioned if the points are
// (nearly) collinear. In this case M has a (nearly) zero eigenvalue, so
// inverting M can be a problem numerically.
template <typename Real>
bool GetContainer(int numPoints, Vector2<Real> const* points,
Ellipse2<Real>& ellipse);
// Test for containment of a point inside an ellipse.
template <typename Real>
bool InContainer(Vector2<Real> const& point, Ellipse2<Real> const& ellipse);
// Construct a bounding ellipse for the two input ellipses. The result is
// not necessarily the minimum-area ellipse containing the two ellipses.
template <typename Real>
bool MergeContainers(Ellipse2<Real> const& ellipse0,
Ellipse2<Real> const& ellipse1, Ellipse2<Real>& merge);
template <typename Real>
bool GetContainer(int numPoints, Vector2<Real> const* points,
Ellipse2<Real>& ellipse)
{
// Fit the points with a Gaussian distribution. The covariance matrix
// is M = sum_j D[j]*U[j]*U[j]^T, where D[j] are the eigenvalues and U[j]
// are corresponding unit-length eigenvectors.
ApprGaussian2<Real> fitter;
if (fitter.Fit(numPoints, points))
{
OrientedBox2<Real> box = fitter.GetParameters();
// If either eigenvalue is nonpositive, adjust the D[] values so that
// we actually build an ellipse.
for (int j = 0; j < 2; ++j)
{
if (box.extent[j] < (Real)0)
{
box.extent[j] = -box.extent[j];
}
}
// Grow the ellipse, while retaining its shape determined by the
// covariance matrix, to enclose all the input points. The quadratic
// form that is used for the ellipse construction is
// Q(X) = (X-C)^T*M*(X-C)
// = (X-C)^T*(sum_j D[j]*U[j]*U[j]^T)*(X-C)
// = sum_j D[j]*Dot(U[j],X-C)^2
// If the maximum value of Q(X[i]) for all input points is V^2, then a
// bounding ellipse is Q(X) = V^2, because Q(X[i]) <= V^2 for all i.
Real maxValue = (Real)0;
for (int i = 0; i < numPoints; ++i)
{
Vector2<Real> diff = points[i] - box.center;
Real dot[2] =
{
Dot(box.axis[0], diff),
Dot(box.axis[1], diff)
};
Real value =
box.extent[0] * dot[0] * dot[0] +
box.extent[1] * dot[1] * dot[1];
if (value > maxValue)
{
maxValue = value;
}
}
// Arrange for the quadratic to satisfy Q(X) <= 1.
ellipse.center = box.center;
for (int j = 0; j < 2; ++j)
{
ellipse.axis[j] = box.axis[j];
ellipse.extent[j] = std::sqrt(maxValue / box.extent[j]);
}
return true;
}
return false;
}
template <typename Real>
bool InContainer(Vector2<Real> const& point, Ellipse2<Real> const& ellipse)
{
Vector2<Real> diff = point - ellipse.center;
Vector2<Real> standardized{
Dot(diff, ellipse.axis[0]) / ellipse.extent[0],
Dot(diff, ellipse.axis[1]) / ellipse.extent[1] };
return Length(standardized) <= (Real)1;
}
template <typename Real>
bool MergeContainers(Ellipse2<Real> const& ellipse0,
Ellipse2<Real> const& ellipse1, Ellipse2<Real>& merge)
{
// Compute the average of the input centers.
merge.center = ((Real)0.5)*(ellipse0.center + ellipse1.center);
// The bounding ellipse orientation is the average of the input
// orientations.
if (Dot(ellipse0.axis[0], ellipse1.axis[0]) >= (Real)0)
{
merge.axis[0] = ((Real)0.5)*(ellipse0.axis[0] + ellipse1.axis[0]);
}
else
{
merge.axis[0] = ((Real)0.5)*(ellipse0.axis[0] - ellipse1.axis[0]);
}
Normalize(merge.axis[0]);
merge.axis[1] = -Perp(merge.axis[0]);
// Project the input ellipses onto the axes obtained by the average of the
// orientations and that go through the center obtained by the average of
// the centers.
for (int j = 0; j < 2; ++j)
{
// Projection axis.
Line2<Real> line(merge.center, merge.axis[j]);
// Project ellipsoids onto the axis.
Real min0, max0, min1, max1;
Project(ellipse0, line, min0, max0);
Project(ellipse1, line, min1, max1);
// Determine the smallest interval containing the projected
// intervals.
Real maxIntr = (max0 >= max1 ? max0 : max1);
Real minIntr = (min0 <= min1 ? min0 : min1);
// Update the average center to be the center of the bounding box
// defined by the projected intervals.
merge.center += line.direction*(((Real)0.5)*(minIntr + maxIntr));
// Compute the extents of the box based on the new center.
merge.extent[j] = ((Real)0.5)*(maxIntr - minIntr);
}
return true;
}
}
| [
"p.m.joniak@gmail.com"
] | p.m.joniak@gmail.com |
cbdd83dcc754f5a6702162c853dff6d0a34d3a49 | cfeac52f970e8901871bd02d9acb7de66b9fb6b4 | /generated/src/aws-cpp-sdk-apigateway/include/aws/apigateway/APIGatewayErrorMarshaller.h | d01ae04f037cf7fe8f5db14ab1789b4d5335c575 | [
"Apache-2.0",
"MIT",
"JSON"
] | permissive | aws/aws-sdk-cpp | aff116ddf9ca2b41e45c47dba1c2b7754935c585 | 9a7606a6c98e13c759032c2e920c7c64a6a35264 | refs/heads/main | 2023-08-25T11:16:55.982089 | 2023-08-24T18:14:53 | 2023-08-24T18:14:53 | 35,440,404 | 1,681 | 1,133 | Apache-2.0 | 2023-09-12T15:59:33 | 2015-05-11T17:57:32 | null | UTF-8 | C++ | false | false | 524 | h | /**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/apigateway/APIGateway_EXPORTS.h>
#include <aws/core/client/AWSErrorMarshaller.h>
namespace Aws
{
namespace Client
{
class AWS_APIGATEWAY_API APIGatewayErrorMarshaller : public Aws::Client::JsonErrorMarshaller
{
public:
Aws::Client::AWSError<Aws::Client::CoreErrors> FindErrorByName(const char* exceptionName) const override;
};
} // namespace Client
} // namespace Aws
| [
"sdavtaker@users.noreply.github.com"
] | sdavtaker@users.noreply.github.com |
0b66b8d200af82d234d9f14461c2e06f57e8a48a | 37b53d11b252b5b1b827a2f4d50e154ed56b6a50 | /samples/Atlantis/Atlantis/AscentAP.h | d4b0840f51005d48546736da975e0021f34c8296 | [] | no_license | johndpope/orbiter-sdk | 070232d667bf1eb7aceae2e14df068f424e86090 | 8f0f45583ed43d7f0df2ef6ddd837fe7c2ef17f8 | refs/heads/master | 2020-05-16T22:50:51.303970 | 2019-03-25T16:43:55 | 2019-03-25T16:43:55 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,610 | h | // ==============================================================
// ORBITER MODULE: Atlantis
// Part of the ORBITER SDK
// Copyright (C) 2001-2012 Martin Schweiger
// All rights reserved
//
// AscentAP.h
// Class interface for Atlantis ascent autopilot
// Automatic control of ascent profile from liftoff to
// ET separation using engine gimballing of SSME and SRB engines
// ==============================================================
#ifndef __ATLANTIS_ASCENTAP
#define __ATLANTIS_ASCENTAP
#include "Common\Dialog\TabDlg.h"
class Atlantis;
class Graph;
struct ProfSample {
double t;
double v;
};
// ==============================================================
// class AscentAP: ascent autopilot
// ==============================================================
class AscentAP {
friend class AscentApMfd;
friend class AscentAPDlg;
public:
AscentAP (Atlantis *atlantis);
~AscentAP ();
Atlantis *GetVessel () { return vessel; }
void Launch ();
double StartMissionTime (double simt); // start MET counter without engaging AP
void Update (double simt);
bool Active() const { return active; }
void Engage () { active = true; }
void Disengage () { active = false; }
double GetMET (double simt) const;
double GetMT0 () const { return t_launch; }
double GetInclination (double lat, double az) const;
// orbit inclination (0..pi) from current latitude and azimuth
void SetLaunchAzimuth (double azimuth);
void SetOrbitAltitude (double alt) { tgt_alt = alt; }
double GetLaunchAzimuth () const { return launch_azimuth; }
double GetTargetAzimuth () const { return tgt.az; }
double GetTargetPitch () const { return tgt.pitch; }
double GetOrbitAltitude () const { return tgt_alt; }
double GetTargetInclination ();
void GetTargetDirection (double met, VECTOR3 &dir, double &tgt_hdg) const;
void GetTargetRate (double met, VECTOR3 &rate) const;
void ToggleOMS2();
bool GetOMS2Schedule() const { return do_oms2; }
void SaveState (FILEHANDLE scn);
bool ParseScenarioLine (const char *line);
protected:
void SetDefaultProfiles ();
private:
double CalcTargetAzimuth () const;
double CalcTargetPitch () const;
double GetTargetPitchRate (double dpitch, double vpitch) const;
double GetTargetYawRate (double dyaw, double vyaw) const;
double GetTargetRollRate (double tgt, bool tgt_is_heading) const;
Atlantis *vessel;
ProfSample *pitch_profile;
int n_pitch_profile;
double launch_azimuth;
double tgt_alt;
double ecc_min;
double t_roll_upright;
double launch_lng, launch_lat;
double t_launch;
double met;
double met_meco, met_oms_start, met_oms_end;
double met_oms1_start, schedule_oms1;
bool active;
bool met_active;
bool do_oms2;
struct TGTPRM {
double inc; // target orbit inclination
double lan; // target orbit longitude of ascending node
double az; // current target azimuth
double pitch; // current target pitch
MATRIX3 R; // rotation from equator plane to target plane
} tgt;
};
// ==============================================================
// class AscentApMfd: MFD interface for ascent autopilot
// ==============================================================
class AscentApMfd: public MFD2 {
public:
AscentApMfd (DWORD w, DWORD h, VESSEL *v);
~AscentApMfd();
bool Update (oapi::Sketchpad *skp);
char *ButtonLabel (int bt);
int ButtonMenu (const MFDBUTTONMENU **menu) const;
bool ConsumeKeyBuffered (DWORD key);
bool ConsumeButton (int bt, int event);
static int MsgProc (UINT msg, UINT mfd, WPARAM wparam, LPARAM lparam);
private:
void UpdatePg_Prm (oapi::Sketchpad *skp);
void UpdatePg_Gbl (oapi::Sketchpad *skp);
void DrawGimbal (oapi::Sketchpad *skp, int cx, int cy, double pitch, double yaw);
void DecPage();
void IncPage();
bool OnLaunch();
bool OnEngage();
bool OnDisengage();
void InitDecAzimuth();
void InitIncAzimuth();
void DecAzimuth();
void IncAzimuth();
void InitDecAltitude();
void InitIncAltitude();
void DecAltitude();
void IncAltitude();
void ToggleOMS2Schedule();
enum SET_MODE { MODE_NONE, MODE_AZIMUTH_DEC, MODE_AZIMUTH_INC } set_mode;
double ref_t;
double ref_val;
AscentAP *ap;
DWORD cpg; // current page
oapi::Pen *pen[2];
};
// ==============================================================
// class AscentAPDlg: dialog interface for ascent autopilot
// ==============================================================
class AscentAPDlgTab;
class AscentAPDlg: public TabbedDialog {
public:
AscentAPDlg (AscentAP *_ap);
virtual ~AscentAPDlg ();
void Update (double simt);
AscentAP *AP() { return ap; }
int OnInitDialog (WPARAM wParam);
int Closed ();
private:
AscentAP *ap;
};
// ==============================================================
// class AscentAPDlgTab: base class for dialog tabs
// ==============================================================
class AscentAPDlgTab: public TabPage {
public:
AscentAPDlgTab (AscentAPDlg *frame, int dlgId);
protected:
AscentAP *ap;
};
// ==============================================================
// class AscentAPDlgTabControl: AP control tab
// ==============================================================
class AscentAPDlgTabControl: public AscentAPDlgTab {
public:
AscentAPDlgTabControl (AscentAPDlg *frame);
protected:
int OnInitTab (WPARAM wParam);
int OnLaunch ();
int OnCommand (WPARAM wParam, LPARAM lParam);
};
// ==============================================================
// class AscentAPDlgTabGimbal: AP gimbal tab
// ==============================================================
class AscentAPDlgTabGimbal: public AscentAPDlgTab {
public:
AscentAPDlgTabGimbal (AscentAPDlg *frame);
~AscentAPDlgTabGimbal();
void Update (double simt);
protected:
void RepaintAll (HWND hWnd);
void PaintGimbalCross (HDC hDC, const RECT &rect, int x, int y);
void UpdateGimbalCross (HWND hCtrl, int idx, double pitch, double yaw);
void PaintGimbalBox (HWND hWnd);
BOOL DlgProc (HWND, UINT, WPARAM, LPARAM);
private:
int gimbalx[5], gimbaly[5];
double rad;
HPEN pen1, pen2;
};
// ==============================================================
// class AscentAPDlgTabThrust: AP thrust tab
// ==============================================================
class AscentAPDlgTabThrust: public AscentAPDlgTab {
public:
AscentAPDlgTabThrust (AscentAPDlg *frame);
~AscentAPDlgTabThrust ();
void Update (double simt);
protected:
int OnPaint ();
void RefreshGraph (Graph *graph, int GraphId);
BOOL DlgProc (HWND, UINT, WPARAM, LPARAM);
private:
Graph *ssmegraph, *srbgraph;
double updt;
double dupdt;
};
// ==============================================================
// class AscentAPDlgTabAltitude: AP altitude tab
// ==============================================================
class AscentAPDlgTabAltitude: public AscentAPDlgTab {
public:
AscentAPDlgTabAltitude (AscentAPDlg *frame);
~AscentAPDlgTabAltitude ();
void Update (double simt);
protected:
int OnPaint ();
void RefreshGraph (Graph *graph, int GraphId);
BOOL DlgProc (HWND, UINT, WPARAM, LPARAM);
private:
Graph *altgraph;
double updt;
double dupdt;
};
// ==============================================================
// auxiliary functions
// ==============================================================
const char *MetStr (double met);
#endif // !__ATLANTIS_ASCENTAP | [
"amicard@eurodns.com"
] | amicard@eurodns.com |
0a4251ea3efa690585ce22cec85a01f0d0f8e675 | e9172462c822ad88c7d32d46c0d7d9ec90fe15c1 | /day03/ex04/FragTrap.hpp | b4cb1583536971f34a33e2e66df47dfa2f38557a | [] | no_license | AnaChepurna/CPP_Piscine | c0628e8ba04adc22427f59e9095af3ce360ff20d | 092e98fab6501cb7c3991c3777bda2130ba0f720 | refs/heads/master | 2020-03-20T22:12:15.908691 | 2018-06-29T14:46:09 | 2018-06-29T14:46:09 | 137,785,229 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 709 | hpp | #ifndef FRAGTRAP_HPP
# define FRAGTRAP_HPP
#include "ClapTrap.hpp"
class FragTrap : public virtual ClapTrap
{
protected:
static const int _max_hit_points = 100;
static const int _max_energy_points = 100;
static const int _level = 1;
static const int _melee_attack_damage = 30;
static const int _ranged_attack_damage = 20;
static const int _armor_damage_reduction = 5;
public:
FragTrap(void);
FragTrap(std::string const name);
FragTrap(FragTrap const & src);
~FragTrap(void);
FragTrap & operator=(FragTrap const & src);
int rangedAttack(std::string const & target);
int meleeAttack(std::string const & target);
int vaulthunter_dot_exe(std::string const & target);
};
#endif | [
"ch.nastasie@gmail.com"
] | ch.nastasie@gmail.com |
709527133aa1d5dc803b41e9e65462fec1687c23 | 88ee2fb90bbb66499dcf3b67b93286e686a22bcb | /src/core/index/ImpactsSource.hpp | e4ec62cdf0db041ca276092dbc1c73f6022da6dc | [] | no_license | finddit/lucene_cpp_20 | 83b4bb779557985dc1e04f49dbb72cb93ac6c649 | 98611d3ef0aa01a345cf8640fdc460c837d15182 | refs/heads/main | 2023-06-03T02:07:23.564842 | 2021-06-17T19:47:08 | 2021-06-17T19:47:08 | 377,941,462 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 199 | hpp | //
// Created by Ervin Bosenbacher on 17/06/2021.
//
#ifndef LUCENECPP20_IMPACTSSOURCE_HPP
#define LUCENECPP20_IMPACTSSOURCE_HPP
class ImpactsSource {
};
#endif //LUCENECPP20_IMPACTSSOURCE_HPP
| [
"ervin@blueparrot.co"
] | ervin@blueparrot.co |
386bd9d51f164d5a11ca2091ed7e52e55b04550b | e8db32198b27dbc386df93473b8ce9a8cf0cb6f0 | /minidriver/tags/initial_import/cardlib/SIMCard.h | 1a7a7a8e1d484eecb728f21721bebfafff972c38 | [] | no_license | tixsys/esteid | 03e84f219f94e55a468484752e08deec7dbe7428 | a0be3c31a0390f68f042127f0498e0900d0304a5 | refs/heads/master | 2016-09-16T06:51:05.086837 | 2013-03-29T10:34:10 | 2013-03-29T10:34:10 | 33,731,241 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 144 | h | #pragma once
#include "CardBase.h"
class SIMCard :
public CardBase
{
public:
SIMCard(void);
~SIMCard(void);
void test(void);
};
| [
"kalev@0d7e1ef0-d974-fc83-f0b3-ccc071561e0e"
] | kalev@0d7e1ef0-d974-fc83-f0b3-ccc071561e0e |
e76c8321816535472adeb4e898b55685d489307b | 3a01d6f6e9f7db7428ae5dc286d6bc267c4ca13e | /unittests/libtests/faults/TestFaultCohesiveKinSrcsCases.hh | 4ee65d888b2959fd53a5f953963750ca70c4de23 | [
"MIT"
] | permissive | youngsolar/pylith | 1ee9f03c2b01560706b44b4ccae99c3fb6b9fdf4 | 62c07b91fa7581641c7b2a0f658bde288fa003de | refs/heads/master | 2020-12-26T04:04:21.884785 | 2014-10-06T21:42:42 | 2014-10-06T21:42:42 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,478 | hh | // -*- C++ -*-
//
// ----------------------------------------------------------------------
//
// Brad T. Aagaard, U.S. Geological Survey
// Charles A. Williams, GNS Science
// Matthew G. Knepley, University of Chicago
//
// This code was developed as part of the Computational Infrastructure
// for Geodynamics (http://geodynamics.org).
//
// Copyright (c) 2010-2014 University of California, Davis
//
// See COPYING for license information.
//
// ----------------------------------------------------------------------
//
/**
* @file unittests/libtests/faults/TestFaultCohesiveKinSrcsCases.hh
*
* @brief C++ unit testing for FaultCohesiveKin with multiple earthquake ruptures.
*/
#if !defined(pylith_faults_testfaultcohesivekinsrcscases_hh)
#define pylith_faults_testfaultcohesivekinsrcscases_hh
#include "TestFaultCohesiveKinSrcs.hh" // ISA TestFaultCohesiveKinSrcs
/// Namespace for pylith package
namespace pylith {
namespace faults {
class TestFaultCohesiveKinSrcsTri3;
class TestFaultCohesiveKinSrcsQuad4;
class TestFaultCohesiveKinSrcsTet4;
class TestFaultCohesiveKinSrcsHex8;
} // bc
} // pylith
// ----------------------------------------------------------------------
/// C++ unit testing for FaultCohesiveKinSrcs for mesh with 2-D triangular cells.
class pylith::faults::TestFaultCohesiveKinSrcsTri3 : public TestFaultCohesiveKinSrcs
{ // class TestFaultCohesiveKinSrcsTri3
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestFaultCohesiveKinSrcsTri3 );
CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
CPPUNIT_TEST( testIntegrateJacobianLumped );
CPPUNIT_TEST( testCalcTractionsChange );
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
public :
/// Setup testing data.
void setUp(void);
}; // class TestFaultCohesiveKinSrcsTri3
// ----------------------------------------------------------------------
/// C++ unit testing for FaultCohesiveKin for mesh with 2-D quadrilateral cells.
class pylith::faults::TestFaultCohesiveKinSrcsQuad4 : public TestFaultCohesiveKinSrcs
{ // class TestFaultCohesiveKinSrcsQuad4
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestFaultCohesiveKinSrcsQuad4 );
CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
CPPUNIT_TEST( testIntegrateJacobianLumped );
CPPUNIT_TEST( testCalcTractionsChange );
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
public :
/// Setup testing data.
void setUp(void);
}; // class TestFaultCohesiveKinSrcsQuad4
// ----------------------------------------------------------------------
/// C++ unit testing for FaultCohesiveKin for mesh with 3-D tetrahedral cells.
class pylith::faults::TestFaultCohesiveKinSrcsTet4 : public TestFaultCohesiveKinSrcs
{ // class TestFaultCohesiveKinSrcsTet4
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestFaultCohesiveKinSrcsTet4 );
CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
CPPUNIT_TEST( testIntegrateJacobianLumped );
CPPUNIT_TEST( testCalcTractionsChange );
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
public :
/// Setup testing data.
void setUp(void);
}; // class TestFaultCohesiveKinSrcsTet4
// ----------------------------------------------------------------------
/// C++ unit testing for FaultCohesiveKin for mesh with 3-D hex cells.
class pylith::faults::TestFaultCohesiveKinSrcsHex8 : public TestFaultCohesiveKinSrcs
{ // class TestFaultCohesiveKinSrcsHex8
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestFaultCohesiveKinSrcsHex8 );
CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
CPPUNIT_TEST( testIntegrateJacobianLumped );
CPPUNIT_TEST( testCalcTractionsChange );
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
public :
/// Setup testing data.
void setUp(void);
}; // class TestFaultCohesiveKinSrcsHex8
#endif // pylith_faults_testfaultcohesivesrcscases_hh
// End of file
| [
"baagaard@usgs.gov"
] | baagaard@usgs.gov |
83c647c85b173c7c65d03cc8099839bb4b29ae67 | 8ef6b0a9c9c65cf8abecf5cf82d5af485f87f47d | /dp/mcm.h | de66876e74c219e03e90e26fe6950b1612a3a323 | [
"MIT"
] | permissive | RahulSisondia/random_experiments | 50820d729e0e82f76bc65207fd192f722fb6de87 | 2a4f64983718166973d0ada77beb9746abf83ac0 | refs/heads/master | 2023-03-04T11:37:19.832463 | 2023-02-28T12:49:09 | 2023-02-28T12:49:09 | 196,296,969 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,578 | h | /*
* Matrix Chain Multiplication (mcm)
*/
#include "../my_util.h"
/*
complexity is exponential i.e. Ω(4^n/n^3/2)
*/
int mcm_rec(vector<int> dims, int i, int j) {
// i cannot be greater than j of course.
// if i == j means only 1 dimension which invalid case as well.
if (i >= j) return 0;
int res = numeric_limits<int>::max();
for (int k = i; k < j; k++) {
// Enable to debug
// cout << "i: " << i << " j: " << j << " k: " << k << endl;
int temp_res =
mcm_rec(dims, i, k) /* cost of multiplying matrices from i to k */
+
mcm_rec(dims, k + 1, j) /* cost of multiplying matrices from k+1 to j */
+ (dims[i - 1] * dims[k] *
dims[j]) /* cost of multiplying the previous two matrices */;
/* Keep track of the minimal cost so far */
res = min(res, temp_res);
}
return res;
}
/**
dp: to keep track of cost
pmat : to keep track of position of k so that we can pring where to put
brackets.
*/
int mcm_top_down_util(vector<int> dims, int i, int j, vector<vector<int>>& dp,
vector<vector<int>>& pmat) {
if (i >= j) return 0;
int res = numeric_limits<int>::max();
if (dp[i][j] != -1) return dp[i][j];
for (int k = i; k < j; k++) {
int temp_res =
mcm_top_down_util(dims, i, k, dp,
pmat) /* cost of multiplying matrices from i to k */
+
mcm_top_down_util(dims, k + 1, j, dp,
pmat) /* cost of multiplying matrices from k+1 to j */
+ (dims[i - 1] * dims[k] *
dims[j]) /* cost of multiplying the previous two matrices */;
/* Keep track of the minimal cost so far */
res = min(res, temp_res);
dp[i][j] = res;
pmat[i][j] = k;
// Uncomment to see matrices
/* if (i == 1 && j == 4) {
PRINT(pmat);
PRINT(dp);
} */
}
return res;
}
/*
*/
void print_parathesis(vector<int>& dims, vector<vector<int>>& pmat, int i,
int j) {
if (i > j)
return;
else if (i == j)
cout << "M" << i;
else {
cout << "(";
print_parathesis(dims, pmat, i, pmat[i][j]);
cout << " ";
print_parathesis(dims, pmat, pmat[i][j] + 1, j);
cout << ")";
}
}
int mcm_top_down(vector<int> dims, int i, int j) {
// It's fine to keep the length as dims.size() since we passed the j as
// dims.size()-1.
vector<vector<int>> dp(dims.size(), vector<int>(dims.size(), -1));
vector<vector<int>> pmat(dims.size(), vector<int>(dims.size(), 0));
int res = mcm_top_down_util(dims, i, j, dp, pmat);
print_parathesis(dims, pmat, 0, dims.size() - 1);
cout << endl;
return res;
}
/*
TODO
https://youtu.be/_WncuhSJZyA
https://www.techiedelight.com/matrix-chain-multiplication/
*/
int mcm_bottom_up(vector<int> dims) {
vector<vector<int>> dp(dims.size(), vector<int>(dims.size(), 0));
for (int i = 1; i < dims.size(); i++) {
for (int j = 1; j < dims.size(); j++) {
}
}
return dp.back().back();
}
void mcm() {
vector<int> dims{40, 20, 30, 10, 30};
/*
* dims = {d0, d1, d2, d3, d4,...}
* Matrices :
* { (do x d1) = M1, (d1 x d2) = M2, ( d2 x d3) = M3, (d3 x d4) = M4, ...}.
* If I have been given 5 dims then I can form only 4 matrices out it.
* Starting from 1st matrix i.e (do x d1). Therefore, pass 1 and 4
*/
CHECK(mcm_rec(dims, 1, dims.size() - 1), 26000);
CHECK(mcm_top_down(dims, 1, dims.size() - 1), 26000);
cout << "Matrix Chain Multiplication tests passed.\n";
}
/*--------------- Palindromic Partitioning -----------------------*/
bool is_palindrome(string X, int i, int j) {
// count_ops++;
while (i <= j) {
if (X[i++] != X[j--]) return false;
}
return true;
}
bool is_palindrome(string X) {
// count_ops++;
int i = 0;
int j = X.length() - 1;
while (i <= j) {
if (X[i++] != X[j--]) return false;
}
return true;
}
int min_palindromic_partitioning_rec(string str, int i, int j) {
// Passing both index to check palindrome is much easier than calculting the
// inclusive length
// if (i == j || is_palindrome(str.substr(i, j - i + 1)) == true) return 0;
if (i == j || is_palindrome(str, i, j) == true) return 0;
int res = numeric_limits<int>::max();
for (int k = i; k <= j - 1; k++) {
int temp_res =
min_palindromic_partitioning_rec(str, i, k) /* left partition */
+ 1 /* cost of cutting left and right partitions */
+ min_palindromic_partitioning_rec(str, k + 1, j) /* right partition */;
res = min(res, temp_res);
count_ops++;
// Uncomment to debug
// cout << " i : " << i << " j: " << j << " k: " << k
// << " temp_res: " << temp_res << " res: " << res << endl;
}
return res;
}
int min_palindromic_partitioning_mem_util(string str, int i, int j,
vector<vector<int>>& dp) {
if (i == j || is_palindrome(str, i, j) == true) return 0;
if (dp[i][j] != -1) return dp[i][j];
int res = numeric_limits<int>::max();
for (int k = i; k <= j - 1; k++) {
int temp_res = min_palindromic_partitioning_mem_util(
str, i, k, dp) /* left partition */
+ 1 /* cost of cutting left and right partitions */
+ min_palindromic_partitioning_mem_util(
str, k + 1, j, dp) /* right partition */;
res = min(res, temp_res);
count_ops++;
}
dp[i][j] = res;
return res;
}
int min_palindromic_partitioning_memo(string str, int i, int j) {
vector<vector<int>> dp(str.length(), vector<int>(str.length(), -1));
count_ops = 0;
return min_palindromic_partitioning_mem_util(str, i, j, dp);
}
int min_palindromic_partitioning_mem_util_opt(string str, int i, int j,
vector<vector<int>>& dp) {
if (i == j) return 0;
if (dp[i][j] != -1) return dp[i][j];
/* We check for this base only if this subprpoblem was not evaluated before */
if (is_palindrome(str, i, j) == true) return 0;
int res = numeric_limits<int>::max();
for (int k = i; k <= j - 1; k++) {
int temp;
// We now look the values for left & right partitions in the cache before
// evaluating them.
{
/* left partition. */
if (dp[i][k] != -1)
temp = dp[i][k];
else
temp = min_palindromic_partitioning_mem_util_opt(str, i, k, dp);
}
temp += 1; /* cost of cutting left and right partitions */
{
/* right partition */;
if (dp[k + 1][j] != -1)
temp += dp[k + 1][j];
else
temp += min_palindromic_partitioning_mem_util_opt(str, k + 1, j, dp);
}
count_ops++;
res = min(res, temp);
}
dp[i][j] = res;
return res;
}
int min_palindromic_partitioning_memo_opt(string str, int i, int j) {
vector<vector<int>> dp(str.length(), vector<int>(str.length(), -1));
count_ops = 0;
return min_palindromic_partitioning_mem_util_opt(str, i, j, dp);
}
void test_palindromic_partitioning() {
string str("ababbbabbababa"); // abab| bb | abba | baba
CHECK(min_palindromic_partitioning_rec(str, 0, str.size() - 1), 3);
CHECK(min_palindromic_partitioning_memo(str, 0, str.size() - 1), 3);
CHECK(min_palindromic_partitioning_memo_opt(str, 0, str.size() - 1), 3);
// clang-format off
/*
Number of operations stats:
Without counting palindrome operations:
Number of operations in recursive soln : 255224
Number of operations in memo soln : 362
Number of operations in optimized mem soln : 362
Counting palindrome operations:
Number of operations in recursive soln : 432371 - 255224 = 177147 (is_palindromeis called)
Number of operations in memo soln : 935 - 362 = 573 (ispalindrome is called)
Number of operations in optimized mem soln : 460 - 362 = 98 (is palindrome is called)
*/
// clang-format on
str = "geeksforgeeks"; // g | ee | k | s | f | o | r | g | ee | k | s
// count_ops = 0;
CHECK(min_palindromic_partitioning_rec(str, 0, str.size() - 1), 10);
// cout << "Number of operations in recursive soln : " << count_ops << endl;
// count_ops = 0;
CHECK(min_palindromic_partitioning_memo(str, 0, str.size() - 1), 10);
// cout << "Number of operations in memo soln : " << count_ops << endl;
// count_ops = 0;
CHECK(min_palindromic_partitioning_memo_opt(str, 0, str.size() - 1), 10);
// cout << "Number of operations in optimized mem soln : " << count_ops <<
// endl;
str = "nitin";
CHECK(min_palindromic_partitioning_rec(str, 0, str.size() - 1), 0);
CHECK(min_palindromic_partitioning_memo(str, 0, str.size() - 1), 0);
CHECK(min_palindromic_partitioning_memo_opt(str, 0, str.size() - 1), 0);
PRINT_MSG;
}
/*
https://leetcode.com/problems/burst-balloons/
You are given n balloons, indexed from 0 to n - 1. Each balloon is painted with
a number on it represented by an array nums. You are asked to burst all the
balloons.
If you burst the ith balloon, you will get nums[i - 1] * nums[i] * nums[i + 1]
coins. If i - 1 or i + 1 goes out of bounds of the array, then treat it as if
there is a balloon with a 1 painted on it.
Return the maximum coins you can collect by bursting the balloons wisely.
Example 1:
Input: nums = [3,1,5,8]
Output: 167
Explanation:
nums = [3,1,5,8] --> [3,5,8] --> [3,8] --> [8] --> []
coins = 3*1*5 + 3*5*8 + 1*3*8 + 1*8*1 = 167
This is similar to mcm. Only hard part part is to get the calculations of
bursting balloons right
// 1,3,2,3,4,5,6,7,1
// ^ ^ ^
// i k j
*/
int burst_balloon(vector<int> v, int i, int j, vector<vector<int>>& dp) {
if (i > j) return 0;
if (i == j) {
dp[i][j] = v[i - 1] * v[i] * v[i + 1];
return dp[i][j];
}
if (dp[i][j] != -1) {
return dp[i][j];
}
int res = numeric_limits<int>::min();
for (int k = i; k <= j; k++) {
int left_cost = burst_balloon(v, i, k - 1, dp);
int right_cost = burst_balloon(v, k + 1, j, dp);
/*
Cost of bursting remaining balloons +
Cost bursting the left side i to k- 1 balloons +
Cost bursting the right side k+1 to j balloons
*/
int cost = v[k] * v[i - 1] * v[j + 1] + left_cost + right_cost;
res = max(res, cost);
}
dp[i][j] = res;
return res;
}
int burst_balloon(vector<int> v) {
int size = v.size();
v.insert(v.begin(), 1);
v.push_back(1);
vector<vector<int>> dp(v.size(), vector<int>(v.size(), -1));
// Original array will be at these positions
return burst_balloon(v, 1, size, dp);
}
void test_burst_balloon() {
vector<int> v = {3, 1, 5, 8};
CHECK(burst_balloon(v), 167);
PRINT_MSG;
}
/*
Given a non-empty string s and a dictionary wordDict containing a list of
non-empty words, determine if s can be segmented into a space-separated sequence
of one or more dictionary words.
Note:
The same word in the dictionary may be reused multiple times in the
segmentation. You may assume the dictionary does not contain duplicate words.
Example 1:
Input: s = "leetcode", wordDict = ["leet", "code"]
Output: true
Explanation: Return true because "leetcode" can be segmented as "leet code".
Example 2:
Input: s = "applepenapple", wordDict = ["apple", "pen"]
Output: true
Explanation: Return true because "applepenapple" can be segmented as "apple pen
apple". Note that you are allowed to reuse a dictionary word.
Also have a look next problem - https://leetcode.com/problems/word-break-ii/
*/
class Solution_139 {
public:
bool wordBreak(const string s, const vector<string>& wordDict) {
for (auto word : wordDict) {
dict.emplace(word);
}
int n = s.size();
vector<int> dp(n + 1, -1);
return word_break(s, dp);
}
private:
unordered_set<string> dict;
bool word_break(string s, vector<int>& dp) {
if (s.empty()) return true;
int n = s.size();
if (dp[n] != -1) return dp[n];
bool ret = false;
for (int i = 0; i < s.size(); i++) {
if (dict.count(s.substr(0, i + 1)) && word_break(s.substr(i + 1), dp)) {
ret = true;
break;
}
}
dp[n] = ret ? 1 : 0;
return ret;
}
};
void test_word_break() {
Solution_139 s;
CHECK(s.wordBreak("applepenapple", {"apple", "pen"}), true);
PRINT_MSG;
}
/*
Given a non-empty string s and a dictionary wordDict containing a list of
non-empty words, add spaces in s to construct a sentence where each word is a
valid dictionary word. Return all such possible sentences.
Note:
The same word in the dictionary may be reused multiple times in the
segmentation. You may assume the dictionary does not contain duplicate words.
Example 1:
Input:
s = "catsanddog"
wordDict = ["cat", "cats", "and", "sand", "dog"]
Output:
[
"cats and dog",
"cat sand dog"
]
Example 2:
Input:
s = "pineapplepenapple"
wordDict = ["apple", "pen", "applepen", "pine", "pineapple"]
Output:
[
"pine apple pen apple",
"pineapple pen apple",
"pine applepen apple"
]
Explanation: Note that you are allowed to reuse a dictionary word.
Example 3:
Input:
s = "catsandog"
wordDict = ["cats", "dog", "sand", "and", "cat"]
Output:
[]
*/
/*
class Solution_brute_force {
public:
vector<string> wordBreak(const string s, const vector<string>& wordDict) {
if(s.empty()) return result;
for (auto word : wordDict) {
dict.emplace(word);
}
vector<string> current;
word_break(s, 0, current);
return result;
}
private:
unordered_set<string> dict;
vector<string> result;
void word_break(const string& s, int pos, vector<string>& current) {
if (pos == s.size()) {
string res;
for(int i=0; i< current.size()-1; i++) {
res += current[i] + " ";
}
res += current.back();
result.push_back(res);
return;
}
for (int i = pos; i < s.size(); i++) {
string lstr = s.substr(pos, i-pos+1);
//cout << "substr " << lstr << endl;
if (dict.count(lstr)){
// cout << " found " << lstr << endl;
current.push_back(lstr);
word_break(s, i+1, current);
current.pop_back();
}
}
}
};
We were solving the subproblems repeatedly in the above bruteforce solution.
for instance :
"catsanddog" --> (1) cat|s|anddog (2) cats|anddog
here we solve anddog two times.
how about we cache the subproblem results.
dog -> dog
anddog -> and, dog
Learnings:
Recursive Solution gives TLE. But realize that we are solving the
subproblems repeatedly in the above bruteforce solution.
for instance :
"catsanddog" --> (1) cat|s|anddog (2) cats|anddog
here we solve anddog two times.
how about we cache the subproblem results.
dog -> dog
anddog -> and, dog
*/
class Solution_140 {
public:
vector<string> wordBreak(const string s, const vector<string>& wordDict) {
if (s.empty()) return vector<string>{};
for (auto word : wordDict) {
dict.emplace(word);
}
return word_break(s);
}
private:
unordered_set<string> dict;
unordered_map<string, vector<string>> dp;
vector<string> word_break(string s) {
if (dp.count(s)) return dp[s];
vector<string> result;
if (dict.count(s)) result.push_back(s);
for (int len = 1; len < s.size(); len++) {
string lstr = s.substr(0, len);
if (dict.count(lstr)) {
auto words = word_break(s.substr(len));
for (auto word : words) {
result.push_back(lstr + " " + word);
}
}
}
dp[s] = result;
return result;
}
};
void test_word_break_II() {
Solution_140 s;
CHECK(s.wordBreak("catsanddog", {"cat", "cats", "and", "sand", "dog"}),
{{"cat sand dog"}, {"cats and dog"}});
PRINT_MSG;
} | [
"rahul.sisondia@oracle.com"
] | rahul.sisondia@oracle.com |
272e59bea1183c1c40d407501bcc748f66448d3a | 75da0db5bfde99720ddb22692594241308be967e | /DuiDesigner/DialogCustomFonts.h | 64dca0ff5d45de227c04edd3fcf50f033bec8e1b | [] | no_license | 021xcy/BrowserDll | f6bd549e26828f5950b769e4232511e101696263 | a071a3c364d18b704ccaec5b74467237cd157900 | refs/heads/master | 2023-06-25T18:51:02.224423 | 2017-03-20T03:06:15 | 2017-03-20T03:06:15 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 699 | h | #pragma once
#include "afxwin.h"
// CDialogCustomFonts dialog
class CDialogCustomFonts : public CDialog
{
DECLARE_DYNAMIC(CDialogCustomFonts)
public:
CDialogCustomFonts(CWnd* pParent = NULL); // standard constructor
virtual ~CDialogCustomFonts();
// Dialog Data
enum { IDD = IDD_DIALOG_CUSTOM_FONTS };
private:
CPaintManagerUI* m_pManager;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
virtual BOOL OnInitDialog();
CListCtrl m_lstCustomFonts;
afx_msg void OnBnClickedButtonFontAdd();
afx_msg void OnBnClickedButtonFontDelete();
afx_msg void OnBnClickedButtonFontModify();
};
| [
"x583194811l@gmail.com"
] | x583194811l@gmail.com |
18200b934d8cc876eaf28e52d220c7ad10fc4449 | c27e4bae6ff1d0c2e9d4c5b4e89a720c06063aa5 | /src/crypto/sha256_sse4.cpp | 02d5c7adc90d0a97fd86e0d14ffeb7967cd97916 | [
"MIT"
] | permissive | cryptomiles/cryptomiles | b747c8ebdd0aa11169a9e7b6e6f56f70525cc75f | d3815eaf7716fbca9459f4162ae7ba4714298d27 | refs/heads/master | 2020-04-21T16:53:19.359673 | 2019-02-08T14:48:47 | 2019-02-08T14:48:47 | 169,717,359 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 42,953 | cpp | // Copyright (c) 2017 The Bitcoin Core developers
// Copyright (c) 2017 The Cryptomiles Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
//
// This is a translation to GCC extended asm syntax from YASM code by Intel
// (available at the bottom of this file).
#include <stdint.h>
#include <stdlib.h>
#if defined(__x86_64__) || defined(__amd64__)
namespace sha256_sse4
{
void Transform(uint32_t* s, const unsigned char* chunk, size_t blocks)
{
static const uint32_t K256 alignas(16) [] = {
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
};
static const uint32_t FLIP_MASK alignas(16) [] = {0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f};
static const uint32_t SHUF_00BA alignas(16) [] = {0x03020100, 0x0b0a0908, 0xffffffff, 0xffffffff};
static const uint32_t SHUF_DC00 alignas(16) [] = {0xffffffff, 0xffffffff, 0x03020100, 0x0b0a0908};
uint32_t a, b, c, d, f, g, h, y0, y1, y2;
uint64_t tbl;
uint64_t inp_end, inp;
uint32_t xfer alignas(16) [4];
__asm__ __volatile__(
"shl $0x6,%2;"
"je Ldone_hash_%=;"
"add %1,%2;"
"mov %2,%14;"
"mov (%0),%3;"
"mov 0x4(%0),%4;"
"mov 0x8(%0),%5;"
"mov 0xc(%0),%6;"
"mov 0x10(%0),%k2;"
"mov 0x14(%0),%7;"
"mov 0x18(%0),%8;"
"mov 0x1c(%0),%9;"
"movdqa %18,%%xmm12;"
"movdqa %19,%%xmm10;"
"movdqa %20,%%xmm11;"
"Lloop0_%=:"
"lea %17,%13;"
"movdqu (%1),%%xmm4;"
"pshufb %%xmm12,%%xmm4;"
"movdqu 0x10(%1),%%xmm5;"
"pshufb %%xmm12,%%xmm5;"
"movdqu 0x20(%1),%%xmm6;"
"pshufb %%xmm12,%%xmm6;"
"movdqu 0x30(%1),%%xmm7;"
"pshufb %%xmm12,%%xmm7;"
"mov %1,%15;"
"mov $3,%1;"
"Lloop1_%=:"
"movdqa 0x0(%13),%%xmm9;"
"paddd %%xmm4,%%xmm9;"
"movdqa %%xmm9,%16;"
"movdqa %%xmm7,%%xmm0;"
"mov %k2,%10;"
"ror $0xe,%10;"
"mov %3,%11;"
"palignr $0x4,%%xmm6,%%xmm0;"
"ror $0x9,%11;"
"xor %k2,%10;"
"mov %7,%12;"
"ror $0x5,%10;"
"movdqa %%xmm5,%%xmm1;"
"xor %3,%11;"
"xor %8,%12;"
"paddd %%xmm4,%%xmm0;"
"xor %k2,%10;"
"and %k2,%12;"
"ror $0xb,%11;"
"palignr $0x4,%%xmm4,%%xmm1;"
"xor %3,%11;"
"ror $0x6,%10;"
"xor %8,%12;"
"movdqa %%xmm1,%%xmm2;"
"ror $0x2,%11;"
"add %10,%12;"
"add %16,%12;"
"movdqa %%xmm1,%%xmm3;"
"mov %3,%10;"
"add %12,%9;"
"mov %3,%12;"
"pslld $0x19,%%xmm1;"
"or %5,%10;"
"add %9,%6;"
"and %5,%12;"
"psrld $0x7,%%xmm2;"
"and %4,%10;"
"add %11,%9;"
"por %%xmm2,%%xmm1;"
"or %12,%10;"
"add %10,%9;"
"movdqa %%xmm3,%%xmm2;"
"mov %6,%10;"
"mov %9,%11;"
"movdqa %%xmm3,%%xmm8;"
"ror $0xe,%10;"
"xor %6,%10;"
"mov %k2,%12;"
"ror $0x9,%11;"
"pslld $0xe,%%xmm3;"
"xor %9,%11;"
"ror $0x5,%10;"
"xor %7,%12;"
"psrld $0x12,%%xmm2;"
"ror $0xb,%11;"
"xor %6,%10;"
"and %6,%12;"
"ror $0x6,%10;"
"pxor %%xmm3,%%xmm1;"
"xor %9,%11;"
"xor %7,%12;"
"psrld $0x3,%%xmm8;"
"add %10,%12;"
"add 4+%16,%12;"
"ror $0x2,%11;"
"pxor %%xmm2,%%xmm1;"
"mov %9,%10;"
"add %12,%8;"
"mov %9,%12;"
"pxor %%xmm8,%%xmm1;"
"or %4,%10;"
"add %8,%5;"
"and %4,%12;"
"pshufd $0xfa,%%xmm7,%%xmm2;"
"and %3,%10;"
"add %11,%8;"
"paddd %%xmm1,%%xmm0;"
"or %12,%10;"
"add %10,%8;"
"movdqa %%xmm2,%%xmm3;"
"mov %5,%10;"
"mov %8,%11;"
"ror $0xe,%10;"
"movdqa %%xmm2,%%xmm8;"
"xor %5,%10;"
"ror $0x9,%11;"
"mov %6,%12;"
"xor %8,%11;"
"ror $0x5,%10;"
"psrlq $0x11,%%xmm2;"
"xor %k2,%12;"
"psrlq $0x13,%%xmm3;"
"xor %5,%10;"
"and %5,%12;"
"psrld $0xa,%%xmm8;"
"ror $0xb,%11;"
"xor %8,%11;"
"xor %k2,%12;"
"ror $0x6,%10;"
"pxor %%xmm3,%%xmm2;"
"add %10,%12;"
"ror $0x2,%11;"
"add 8+%16,%12;"
"pxor %%xmm2,%%xmm8;"
"mov %8,%10;"
"add %12,%7;"
"mov %8,%12;"
"pshufb %%xmm10,%%xmm8;"
"or %3,%10;"
"add %7,%4;"
"and %3,%12;"
"paddd %%xmm8,%%xmm0;"
"and %9,%10;"
"add %11,%7;"
"pshufd $0x50,%%xmm0,%%xmm2;"
"or %12,%10;"
"add %10,%7;"
"movdqa %%xmm2,%%xmm3;"
"mov %4,%10;"
"ror $0xe,%10;"
"mov %7,%11;"
"movdqa %%xmm2,%%xmm4;"
"ror $0x9,%11;"
"xor %4,%10;"
"mov %5,%12;"
"ror $0x5,%10;"
"psrlq $0x11,%%xmm2;"
"xor %7,%11;"
"xor %6,%12;"
"psrlq $0x13,%%xmm3;"
"xor %4,%10;"
"and %4,%12;"
"ror $0xb,%11;"
"psrld $0xa,%%xmm4;"
"xor %7,%11;"
"ror $0x6,%10;"
"xor %6,%12;"
"pxor %%xmm3,%%xmm2;"
"ror $0x2,%11;"
"add %10,%12;"
"add 12+%16,%12;"
"pxor %%xmm2,%%xmm4;"
"mov %7,%10;"
"add %12,%k2;"
"mov %7,%12;"
"pshufb %%xmm11,%%xmm4;"
"or %9,%10;"
"add %k2,%3;"
"and %9,%12;"
"paddd %%xmm0,%%xmm4;"
"and %8,%10;"
"add %11,%k2;"
"or %12,%10;"
"add %10,%k2;"
"movdqa 0x10(%13),%%xmm9;"
"paddd %%xmm5,%%xmm9;"
"movdqa %%xmm9,%16;"
"movdqa %%xmm4,%%xmm0;"
"mov %3,%10;"
"ror $0xe,%10;"
"mov %k2,%11;"
"palignr $0x4,%%xmm7,%%xmm0;"
"ror $0x9,%11;"
"xor %3,%10;"
"mov %4,%12;"
"ror $0x5,%10;"
"movdqa %%xmm6,%%xmm1;"
"xor %k2,%11;"
"xor %5,%12;"
"paddd %%xmm5,%%xmm0;"
"xor %3,%10;"
"and %3,%12;"
"ror $0xb,%11;"
"palignr $0x4,%%xmm5,%%xmm1;"
"xor %k2,%11;"
"ror $0x6,%10;"
"xor %5,%12;"
"movdqa %%xmm1,%%xmm2;"
"ror $0x2,%11;"
"add %10,%12;"
"add %16,%12;"
"movdqa %%xmm1,%%xmm3;"
"mov %k2,%10;"
"add %12,%6;"
"mov %k2,%12;"
"pslld $0x19,%%xmm1;"
"or %8,%10;"
"add %6,%9;"
"and %8,%12;"
"psrld $0x7,%%xmm2;"
"and %7,%10;"
"add %11,%6;"
"por %%xmm2,%%xmm1;"
"or %12,%10;"
"add %10,%6;"
"movdqa %%xmm3,%%xmm2;"
"mov %9,%10;"
"mov %6,%11;"
"movdqa %%xmm3,%%xmm8;"
"ror $0xe,%10;"
"xor %9,%10;"
"mov %3,%12;"
"ror $0x9,%11;"
"pslld $0xe,%%xmm3;"
"xor %6,%11;"
"ror $0x5,%10;"
"xor %4,%12;"
"psrld $0x12,%%xmm2;"
"ror $0xb,%11;"
"xor %9,%10;"
"and %9,%12;"
"ror $0x6,%10;"
"pxor %%xmm3,%%xmm1;"
"xor %6,%11;"
"xor %4,%12;"
"psrld $0x3,%%xmm8;"
"add %10,%12;"
"add 4+%16,%12;"
"ror $0x2,%11;"
"pxor %%xmm2,%%xmm1;"
"mov %6,%10;"
"add %12,%5;"
"mov %6,%12;"
"pxor %%xmm8,%%xmm1;"
"or %7,%10;"
"add %5,%8;"
"and %7,%12;"
"pshufd $0xfa,%%xmm4,%%xmm2;"
"and %k2,%10;"
"add %11,%5;"
"paddd %%xmm1,%%xmm0;"
"or %12,%10;"
"add %10,%5;"
"movdqa %%xmm2,%%xmm3;"
"mov %8,%10;"
"mov %5,%11;"
"ror $0xe,%10;"
"movdqa %%xmm2,%%xmm8;"
"xor %8,%10;"
"ror $0x9,%11;"
"mov %9,%12;"
"xor %5,%11;"
"ror $0x5,%10;"
"psrlq $0x11,%%xmm2;"
"xor %3,%12;"
"psrlq $0x13,%%xmm3;"
"xor %8,%10;"
"and %8,%12;"
"psrld $0xa,%%xmm8;"
"ror $0xb,%11;"
"xor %5,%11;"
"xor %3,%12;"
"ror $0x6,%10;"
"pxor %%xmm3,%%xmm2;"
"add %10,%12;"
"ror $0x2,%11;"
"add 8+%16,%12;"
"pxor %%xmm2,%%xmm8;"
"mov %5,%10;"
"add %12,%4;"
"mov %5,%12;"
"pshufb %%xmm10,%%xmm8;"
"or %k2,%10;"
"add %4,%7;"
"and %k2,%12;"
"paddd %%xmm8,%%xmm0;"
"and %6,%10;"
"add %11,%4;"
"pshufd $0x50,%%xmm0,%%xmm2;"
"or %12,%10;"
"add %10,%4;"
"movdqa %%xmm2,%%xmm3;"
"mov %7,%10;"
"ror $0xe,%10;"
"mov %4,%11;"
"movdqa %%xmm2,%%xmm5;"
"ror $0x9,%11;"
"xor %7,%10;"
"mov %8,%12;"
"ror $0x5,%10;"
"psrlq $0x11,%%xmm2;"
"xor %4,%11;"
"xor %9,%12;"
"psrlq $0x13,%%xmm3;"
"xor %7,%10;"
"and %7,%12;"
"ror $0xb,%11;"
"psrld $0xa,%%xmm5;"
"xor %4,%11;"
"ror $0x6,%10;"
"xor %9,%12;"
"pxor %%xmm3,%%xmm2;"
"ror $0x2,%11;"
"add %10,%12;"
"add 12+%16,%12;"
"pxor %%xmm2,%%xmm5;"
"mov %4,%10;"
"add %12,%3;"
"mov %4,%12;"
"pshufb %%xmm11,%%xmm5;"
"or %6,%10;"
"add %3,%k2;"
"and %6,%12;"
"paddd %%xmm0,%%xmm5;"
"and %5,%10;"
"add %11,%3;"
"or %12,%10;"
"add %10,%3;"
"movdqa 0x20(%13),%%xmm9;"
"paddd %%xmm6,%%xmm9;"
"movdqa %%xmm9,%16;"
"movdqa %%xmm5,%%xmm0;"
"mov %k2,%10;"
"ror $0xe,%10;"
"mov %3,%11;"
"palignr $0x4,%%xmm4,%%xmm0;"
"ror $0x9,%11;"
"xor %k2,%10;"
"mov %7,%12;"
"ror $0x5,%10;"
"movdqa %%xmm7,%%xmm1;"
"xor %3,%11;"
"xor %8,%12;"
"paddd %%xmm6,%%xmm0;"
"xor %k2,%10;"
"and %k2,%12;"
"ror $0xb,%11;"
"palignr $0x4,%%xmm6,%%xmm1;"
"xor %3,%11;"
"ror $0x6,%10;"
"xor %8,%12;"
"movdqa %%xmm1,%%xmm2;"
"ror $0x2,%11;"
"add %10,%12;"
"add %16,%12;"
"movdqa %%xmm1,%%xmm3;"
"mov %3,%10;"
"add %12,%9;"
"mov %3,%12;"
"pslld $0x19,%%xmm1;"
"or %5,%10;"
"add %9,%6;"
"and %5,%12;"
"psrld $0x7,%%xmm2;"
"and %4,%10;"
"add %11,%9;"
"por %%xmm2,%%xmm1;"
"or %12,%10;"
"add %10,%9;"
"movdqa %%xmm3,%%xmm2;"
"mov %6,%10;"
"mov %9,%11;"
"movdqa %%xmm3,%%xmm8;"
"ror $0xe,%10;"
"xor %6,%10;"
"mov %k2,%12;"
"ror $0x9,%11;"
"pslld $0xe,%%xmm3;"
"xor %9,%11;"
"ror $0x5,%10;"
"xor %7,%12;"
"psrld $0x12,%%xmm2;"
"ror $0xb,%11;"
"xor %6,%10;"
"and %6,%12;"
"ror $0x6,%10;"
"pxor %%xmm3,%%xmm1;"
"xor %9,%11;"
"xor %7,%12;"
"psrld $0x3,%%xmm8;"
"add %10,%12;"
"add 4+%16,%12;"
"ror $0x2,%11;"
"pxor %%xmm2,%%xmm1;"
"mov %9,%10;"
"add %12,%8;"
"mov %9,%12;"
"pxor %%xmm8,%%xmm1;"
"or %4,%10;"
"add %8,%5;"
"and %4,%12;"
"pshufd $0xfa,%%xmm5,%%xmm2;"
"and %3,%10;"
"add %11,%8;"
"paddd %%xmm1,%%xmm0;"
"or %12,%10;"
"add %10,%8;"
"movdqa %%xmm2,%%xmm3;"
"mov %5,%10;"
"mov %8,%11;"
"ror $0xe,%10;"
"movdqa %%xmm2,%%xmm8;"
"xor %5,%10;"
"ror $0x9,%11;"
"mov %6,%12;"
"xor %8,%11;"
"ror $0x5,%10;"
"psrlq $0x11,%%xmm2;"
"xor %k2,%12;"
"psrlq $0x13,%%xmm3;"
"xor %5,%10;"
"and %5,%12;"
"psrld $0xa,%%xmm8;"
"ror $0xb,%11;"
"xor %8,%11;"
"xor %k2,%12;"
"ror $0x6,%10;"
"pxor %%xmm3,%%xmm2;"
"add %10,%12;"
"ror $0x2,%11;"
"add 8+%16,%12;"
"pxor %%xmm2,%%xmm8;"
"mov %8,%10;"
"add %12,%7;"
"mov %8,%12;"
"pshufb %%xmm10,%%xmm8;"
"or %3,%10;"
"add %7,%4;"
"and %3,%12;"
"paddd %%xmm8,%%xmm0;"
"and %9,%10;"
"add %11,%7;"
"pshufd $0x50,%%xmm0,%%xmm2;"
"or %12,%10;"
"add %10,%7;"
"movdqa %%xmm2,%%xmm3;"
"mov %4,%10;"
"ror $0xe,%10;"
"mov %7,%11;"
"movdqa %%xmm2,%%xmm6;"
"ror $0x9,%11;"
"xor %4,%10;"
"mov %5,%12;"
"ror $0x5,%10;"
"psrlq $0x11,%%xmm2;"
"xor %7,%11;"
"xor %6,%12;"
"psrlq $0x13,%%xmm3;"
"xor %4,%10;"
"and %4,%12;"
"ror $0xb,%11;"
"psrld $0xa,%%xmm6;"
"xor %7,%11;"
"ror $0x6,%10;"
"xor %6,%12;"
"pxor %%xmm3,%%xmm2;"
"ror $0x2,%11;"
"add %10,%12;"
"add 12+%16,%12;"
"pxor %%xmm2,%%xmm6;"
"mov %7,%10;"
"add %12,%k2;"
"mov %7,%12;"
"pshufb %%xmm11,%%xmm6;"
"or %9,%10;"
"add %k2,%3;"
"and %9,%12;"
"paddd %%xmm0,%%xmm6;"
"and %8,%10;"
"add %11,%k2;"
"or %12,%10;"
"add %10,%k2;"
"movdqa 0x30(%13),%%xmm9;"
"paddd %%xmm7,%%xmm9;"
"movdqa %%xmm9,%16;"
"add $0x40,%13;"
"movdqa %%xmm6,%%xmm0;"
"mov %3,%10;"
"ror $0xe,%10;"
"mov %k2,%11;"
"palignr $0x4,%%xmm5,%%xmm0;"
"ror $0x9,%11;"
"xor %3,%10;"
"mov %4,%12;"
"ror $0x5,%10;"
"movdqa %%xmm4,%%xmm1;"
"xor %k2,%11;"
"xor %5,%12;"
"paddd %%xmm7,%%xmm0;"
"xor %3,%10;"
"and %3,%12;"
"ror $0xb,%11;"
"palignr $0x4,%%xmm7,%%xmm1;"
"xor %k2,%11;"
"ror $0x6,%10;"
"xor %5,%12;"
"movdqa %%xmm1,%%xmm2;"
"ror $0x2,%11;"
"add %10,%12;"
"add %16,%12;"
"movdqa %%xmm1,%%xmm3;"
"mov %k2,%10;"
"add %12,%6;"
"mov %k2,%12;"
"pslld $0x19,%%xmm1;"
"or %8,%10;"
"add %6,%9;"
"and %8,%12;"
"psrld $0x7,%%xmm2;"
"and %7,%10;"
"add %11,%6;"
"por %%xmm2,%%xmm1;"
"or %12,%10;"
"add %10,%6;"
"movdqa %%xmm3,%%xmm2;"
"mov %9,%10;"
"mov %6,%11;"
"movdqa %%xmm3,%%xmm8;"
"ror $0xe,%10;"
"xor %9,%10;"
"mov %3,%12;"
"ror $0x9,%11;"
"pslld $0xe,%%xmm3;"
"xor %6,%11;"
"ror $0x5,%10;"
"xor %4,%12;"
"psrld $0x12,%%xmm2;"
"ror $0xb,%11;"
"xor %9,%10;"
"and %9,%12;"
"ror $0x6,%10;"
"pxor %%xmm3,%%xmm1;"
"xor %6,%11;"
"xor %4,%12;"
"psrld $0x3,%%xmm8;"
"add %10,%12;"
"add 4+%16,%12;"
"ror $0x2,%11;"
"pxor %%xmm2,%%xmm1;"
"mov %6,%10;"
"add %12,%5;"
"mov %6,%12;"
"pxor %%xmm8,%%xmm1;"
"or %7,%10;"
"add %5,%8;"
"and %7,%12;"
"pshufd $0xfa,%%xmm6,%%xmm2;"
"and %k2,%10;"
"add %11,%5;"
"paddd %%xmm1,%%xmm0;"
"or %12,%10;"
"add %10,%5;"
"movdqa %%xmm2,%%xmm3;"
"mov %8,%10;"
"mov %5,%11;"
"ror $0xe,%10;"
"movdqa %%xmm2,%%xmm8;"
"xor %8,%10;"
"ror $0x9,%11;"
"mov %9,%12;"
"xor %5,%11;"
"ror $0x5,%10;"
"psrlq $0x11,%%xmm2;"
"xor %3,%12;"
"psrlq $0x13,%%xmm3;"
"xor %8,%10;"
"and %8,%12;"
"psrld $0xa,%%xmm8;"
"ror $0xb,%11;"
"xor %5,%11;"
"xor %3,%12;"
"ror $0x6,%10;"
"pxor %%xmm3,%%xmm2;"
"add %10,%12;"
"ror $0x2,%11;"
"add 8+%16,%12;"
"pxor %%xmm2,%%xmm8;"
"mov %5,%10;"
"add %12,%4;"
"mov %5,%12;"
"pshufb %%xmm10,%%xmm8;"
"or %k2,%10;"
"add %4,%7;"
"and %k2,%12;"
"paddd %%xmm8,%%xmm0;"
"and %6,%10;"
"add %11,%4;"
"pshufd $0x50,%%xmm0,%%xmm2;"
"or %12,%10;"
"add %10,%4;"
"movdqa %%xmm2,%%xmm3;"
"mov %7,%10;"
"ror $0xe,%10;"
"mov %4,%11;"
"movdqa %%xmm2,%%xmm7;"
"ror $0x9,%11;"
"xor %7,%10;"
"mov %8,%12;"
"ror $0x5,%10;"
"psrlq $0x11,%%xmm2;"
"xor %4,%11;"
"xor %9,%12;"
"psrlq $0x13,%%xmm3;"
"xor %7,%10;"
"and %7,%12;"
"ror $0xb,%11;"
"psrld $0xa,%%xmm7;"
"xor %4,%11;"
"ror $0x6,%10;"
"xor %9,%12;"
"pxor %%xmm3,%%xmm2;"
"ror $0x2,%11;"
"add %10,%12;"
"add 12+%16,%12;"
"pxor %%xmm2,%%xmm7;"
"mov %4,%10;"
"add %12,%3;"
"mov %4,%12;"
"pshufb %%xmm11,%%xmm7;"
"or %6,%10;"
"add %3,%k2;"
"and %6,%12;"
"paddd %%xmm0,%%xmm7;"
"and %5,%10;"
"add %11,%3;"
"or %12,%10;"
"add %10,%3;"
"sub $0x1,%1;"
"jne Lloop1_%=;"
"mov $0x2,%1;"
"Lloop2_%=:"
"paddd 0x0(%13),%%xmm4;"
"movdqa %%xmm4,%16;"
"mov %k2,%10;"
"ror $0xe,%10;"
"mov %3,%11;"
"xor %k2,%10;"
"ror $0x9,%11;"
"mov %7,%12;"
"xor %3,%11;"
"ror $0x5,%10;"
"xor %8,%12;"
"xor %k2,%10;"
"ror $0xb,%11;"
"and %k2,%12;"
"xor %3,%11;"
"ror $0x6,%10;"
"xor %8,%12;"
"add %10,%12;"
"ror $0x2,%11;"
"add %16,%12;"
"mov %3,%10;"
"add %12,%9;"
"mov %3,%12;"
"or %5,%10;"
"add %9,%6;"
"and %5,%12;"
"and %4,%10;"
"add %11,%9;"
"or %12,%10;"
"add %10,%9;"
"mov %6,%10;"
"ror $0xe,%10;"
"mov %9,%11;"
"xor %6,%10;"
"ror $0x9,%11;"
"mov %k2,%12;"
"xor %9,%11;"
"ror $0x5,%10;"
"xor %7,%12;"
"xor %6,%10;"
"ror $0xb,%11;"
"and %6,%12;"
"xor %9,%11;"
"ror $0x6,%10;"
"xor %7,%12;"
"add %10,%12;"
"ror $0x2,%11;"
"add 4+%16,%12;"
"mov %9,%10;"
"add %12,%8;"
"mov %9,%12;"
"or %4,%10;"
"add %8,%5;"
"and %4,%12;"
"and %3,%10;"
"add %11,%8;"
"or %12,%10;"
"add %10,%8;"
"mov %5,%10;"
"ror $0xe,%10;"
"mov %8,%11;"
"xor %5,%10;"
"ror $0x9,%11;"
"mov %6,%12;"
"xor %8,%11;"
"ror $0x5,%10;"
"xor %k2,%12;"
"xor %5,%10;"
"ror $0xb,%11;"
"and %5,%12;"
"xor %8,%11;"
"ror $0x6,%10;"
"xor %k2,%12;"
"add %10,%12;"
"ror $0x2,%11;"
"add 8+%16,%12;"
"mov %8,%10;"
"add %12,%7;"
"mov %8,%12;"
"or %3,%10;"
"add %7,%4;"
"and %3,%12;"
"and %9,%10;"
"add %11,%7;"
"or %12,%10;"
"add %10,%7;"
"mov %4,%10;"
"ror $0xe,%10;"
"mov %7,%11;"
"xor %4,%10;"
"ror $0x9,%11;"
"mov %5,%12;"
"xor %7,%11;"
"ror $0x5,%10;"
"xor %6,%12;"
"xor %4,%10;"
"ror $0xb,%11;"
"and %4,%12;"
"xor %7,%11;"
"ror $0x6,%10;"
"xor %6,%12;"
"add %10,%12;"
"ror $0x2,%11;"
"add 12+%16,%12;"
"mov %7,%10;"
"add %12,%k2;"
"mov %7,%12;"
"or %9,%10;"
"add %k2,%3;"
"and %9,%12;"
"and %8,%10;"
"add %11,%k2;"
"or %12,%10;"
"add %10,%k2;"
"paddd 0x10(%13),%%xmm5;"
"movdqa %%xmm5,%16;"
"add $0x20,%13;"
"mov %3,%10;"
"ror $0xe,%10;"
"mov %k2,%11;"
"xor %3,%10;"
"ror $0x9,%11;"
"mov %4,%12;"
"xor %k2,%11;"
"ror $0x5,%10;"
"xor %5,%12;"
"xor %3,%10;"
"ror $0xb,%11;"
"and %3,%12;"
"xor %k2,%11;"
"ror $0x6,%10;"
"xor %5,%12;"
"add %10,%12;"
"ror $0x2,%11;"
"add %16,%12;"
"mov %k2,%10;"
"add %12,%6;"
"mov %k2,%12;"
"or %8,%10;"
"add %6,%9;"
"and %8,%12;"
"and %7,%10;"
"add %11,%6;"
"or %12,%10;"
"add %10,%6;"
"mov %9,%10;"
"ror $0xe,%10;"
"mov %6,%11;"
"xor %9,%10;"
"ror $0x9,%11;"
"mov %3,%12;"
"xor %6,%11;"
"ror $0x5,%10;"
"xor %4,%12;"
"xor %9,%10;"
"ror $0xb,%11;"
"and %9,%12;"
"xor %6,%11;"
"ror $0x6,%10;"
"xor %4,%12;"
"add %10,%12;"
"ror $0x2,%11;"
"add 4+%16,%12;"
"mov %6,%10;"
"add %12,%5;"
"mov %6,%12;"
"or %7,%10;"
"add %5,%8;"
"and %7,%12;"
"and %k2,%10;"
"add %11,%5;"
"or %12,%10;"
"add %10,%5;"
"mov %8,%10;"
"ror $0xe,%10;"
"mov %5,%11;"
"xor %8,%10;"
"ror $0x9,%11;"
"mov %9,%12;"
"xor %5,%11;"
"ror $0x5,%10;"
"xor %3,%12;"
"xor %8,%10;"
"ror $0xb,%11;"
"and %8,%12;"
"xor %5,%11;"
"ror $0x6,%10;"
"xor %3,%12;"
"add %10,%12;"
"ror $0x2,%11;"
"add 8+%16,%12;"
"mov %5,%10;"
"add %12,%4;"
"mov %5,%12;"
"or %k2,%10;"
"add %4,%7;"
"and %k2,%12;"
"and %6,%10;"
"add %11,%4;"
"or %12,%10;"
"add %10,%4;"
"mov %7,%10;"
"ror $0xe,%10;"
"mov %4,%11;"
"xor %7,%10;"
"ror $0x9,%11;"
"mov %8,%12;"
"xor %4,%11;"
"ror $0x5,%10;"
"xor %9,%12;"
"xor %7,%10;"
"ror $0xb,%11;"
"and %7,%12;"
"xor %4,%11;"
"ror $0x6,%10;"
"xor %9,%12;"
"add %10,%12;"
"ror $0x2,%11;"
"add 12+%16,%12;"
"mov %4,%10;"
"add %12,%3;"
"mov %4,%12;"
"or %6,%10;"
"add %3,%k2;"
"and %6,%12;"
"and %5,%10;"
"add %11,%3;"
"or %12,%10;"
"add %10,%3;"
"movdqa %%xmm6,%%xmm4;"
"movdqa %%xmm7,%%xmm5;"
"sub $0x1,%1;"
"jne Lloop2_%=;"
"add (%0),%3;"
"mov %3,(%0);"
"add 0x4(%0),%4;"
"mov %4,0x4(%0);"
"add 0x8(%0),%5;"
"mov %5,0x8(%0);"
"add 0xc(%0),%6;"
"mov %6,0xc(%0);"
"add 0x10(%0),%k2;"
"mov %k2,0x10(%0);"
"add 0x14(%0),%7;"
"mov %7,0x14(%0);"
"add 0x18(%0),%8;"
"mov %8,0x18(%0);"
"add 0x1c(%0),%9;"
"mov %9,0x1c(%0);"
"mov %15,%1;"
"add $0x40,%1;"
"cmp %14,%1;"
"jne Lloop0_%=;"
"Ldone_hash_%=:"
: "+r"(s), "+r"(chunk), "+r"(blocks), "=r"(a), "=r"(b), "=r"(c), "=r"(d), /* e = chunk */ "=r"(f), "=r"(g), "=r"(h), "=r"(y0), "=r"(y1), "=r"(y2), "=r"(tbl), "+m"(inp_end), "+m"(inp), "+m"(xfer)
: "m"(K256), "m"(FLIP_MASK), "m"(SHUF_00BA), "m"(SHUF_DC00)
: "cc", "memory", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", "xmm8", "xmm9", "xmm10", "xmm11", "xmm12"
);
}
}
/*
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright (c) 2012, Intel 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 Intel 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 INTEL CORPORATION "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 INTEL CORPORATION 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.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Example YASM command lines:
; Windows: yasm -Xvc -f x64 -rnasm -pnasm -o sha256_sse4.obj -g cv8 sha256_sse4.asm
; Linux: yasm -f x64 -f elf64 -X gnu -g dwarf2 -D LINUX -o sha256_sse4.o sha256_sse4.asm
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; This code is described in an Intel White-Paper:
; "Fast SHA-256 Implementations on Intel Architecture Processors"
;
; To find it, surf to http://www.intel.com/p/en_US/embedded
; and search for that title.
; The paper is expected to be released roughly at the end of April, 2012
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; This code schedules 1 blocks at a time, with 4 lanes per block
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
%define MOVDQ movdqu ;; assume buffers not aligned
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Define Macros
; addm [mem], reg
; Add reg to mem using reg-mem add and store
%macro addm 2
add %2, %1
mov %1, %2
%endm
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; COPY_XMM_AND_BSWAP xmm, [mem], byte_flip_mask
; Load xmm with mem and byte swap each dword
%macro COPY_XMM_AND_BSWAP 3
MOVDQ %1, %2
pshufb %1, %3
%endmacro
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
%define X0 xmm4
%define X1 xmm5
%define X2 xmm6
%define X3 xmm7
%define XTMP0 xmm0
%define XTMP1 xmm1
%define XTMP2 xmm2
%define XTMP3 xmm3
%define XTMP4 xmm8
%define XFER xmm9
%define SHUF_00BA xmm10 ; shuffle xBxA -> 00BA
%define SHUF_DC00 xmm11 ; shuffle xDxC -> DC00
%define BYTE_FLIP_MASK xmm12
%ifdef LINUX
%define NUM_BLKS rdx ; 3rd arg
%define CTX rsi ; 2nd arg
%define INP rdi ; 1st arg
%define SRND rdi ; clobbers INP
%define c ecx
%define d r8d
%define e edx
%else
%define NUM_BLKS r8 ; 3rd arg
%define CTX rdx ; 2nd arg
%define INP rcx ; 1st arg
%define SRND rcx ; clobbers INP
%define c edi
%define d esi
%define e r8d
%endif
%define TBL rbp
%define a eax
%define b ebx
%define f r9d
%define g r10d
%define h r11d
%define y0 r13d
%define y1 r14d
%define y2 r15d
_INP_END_SIZE equ 8
_INP_SIZE equ 8
_XFER_SIZE equ 8
%ifdef LINUX
_XMM_SAVE_SIZE equ 0
%else
_XMM_SAVE_SIZE equ 7*16
%endif
; STACK_SIZE plus pushes must be an odd multiple of 8
_ALIGN_SIZE equ 8
_INP_END equ 0
_INP equ _INP_END + _INP_END_SIZE
_XFER equ _INP + _INP_SIZE
_XMM_SAVE equ _XFER + _XFER_SIZE + _ALIGN_SIZE
STACK_SIZE equ _XMM_SAVE + _XMM_SAVE_SIZE
; rotate_Xs
; Rotate values of symbols X0...X3
%macro rotate_Xs 0
%xdefine X_ X0
%xdefine X0 X1
%xdefine X1 X2
%xdefine X2 X3
%xdefine X3 X_
%endm
; ROTATE_ARGS
; Rotate values of symbols a...h
%macro ROTATE_ARGS 0
%xdefine TMP_ h
%xdefine h g
%xdefine g f
%xdefine f e
%xdefine e d
%xdefine d c
%xdefine c b
%xdefine b a
%xdefine a TMP_
%endm
%macro FOUR_ROUNDS_AND_SCHED 0
;; compute s0 four at a time and s1 two at a time
;; compute W[-16] + W[-7] 4 at a time
movdqa XTMP0, X3
mov y0, e ; y0 = e
ror y0, (25-11) ; y0 = e >> (25-11)
mov y1, a ; y1 = a
palignr XTMP0, X2, 4 ; XTMP0 = W[-7]
ror y1, (22-13) ; y1 = a >> (22-13)
xor y0, e ; y0 = e ^ (e >> (25-11))
mov y2, f ; y2 = f
ror y0, (11-6) ; y0 = (e >> (11-6)) ^ (e >> (25-6))
movdqa XTMP1, X1
xor y1, a ; y1 = a ^ (a >> (22-13)
xor y2, g ; y2 = f^g
paddd XTMP0, X0 ; XTMP0 = W[-7] + W[-16]
xor y0, e ; y0 = e ^ (e >> (11-6)) ^ (e >> (25-6))
and y2, e ; y2 = (f^g)&e
ror y1, (13-2) ; y1 = (a >> (13-2)) ^ (a >> (22-2))
;; compute s0
palignr XTMP1, X0, 4 ; XTMP1 = W[-15]
xor y1, a ; y1 = a ^ (a >> (13-2)) ^ (a >> (22-2))
ror y0, 6 ; y0 = S1 = (e>>6) & (e>>11) ^ (e>>25)
xor y2, g ; y2 = CH = ((f^g)&e)^g
movdqa XTMP2, XTMP1 ; XTMP2 = W[-15]
ror y1, 2 ; y1 = S0 = (a>>2) ^ (a>>13) ^ (a>>22)
add y2, y0 ; y2 = S1 + CH
add y2, [rsp + _XFER + 0*4] ; y2 = k + w + S1 + CH
movdqa XTMP3, XTMP1 ; XTMP3 = W[-15]
mov y0, a ; y0 = a
add h, y2 ; h = h + S1 + CH + k + w
mov y2, a ; y2 = a
pslld XTMP1, (32-7)
or y0, c ; y0 = a|c
add d, h ; d = d + h + S1 + CH + k + w
and y2, c ; y2 = a&c
psrld XTMP2, 7
and y0, b ; y0 = (a|c)&b
add h, y1 ; h = h + S1 + CH + k + w + S0
por XTMP1, XTMP2 ; XTMP1 = W[-15] ror 7
or y0, y2 ; y0 = MAJ = (a|c)&b)|(a&c)
add h, y0 ; h = h + S1 + CH + k + w + S0 + MAJ
ROTATE_ARGS
movdqa XTMP2, XTMP3 ; XTMP2 = W[-15]
mov y0, e ; y0 = e
mov y1, a ; y1 = a
movdqa XTMP4, XTMP3 ; XTMP4 = W[-15]
ror y0, (25-11) ; y0 = e >> (25-11)
xor y0, e ; y0 = e ^ (e >> (25-11))
mov y2, f ; y2 = f
ror y1, (22-13) ; y1 = a >> (22-13)
pslld XTMP3, (32-18)
xor y1, a ; y1 = a ^ (a >> (22-13)
ror y0, (11-6) ; y0 = (e >> (11-6)) ^ (e >> (25-6))
xor y2, g ; y2 = f^g
psrld XTMP2, 18
ror y1, (13-2) ; y1 = (a >> (13-2)) ^ (a >> (22-2))
xor y0, e ; y0 = e ^ (e >> (11-6)) ^ (e >> (25-6))
and y2, e ; y2 = (f^g)&e
ror y0, 6 ; y0 = S1 = (e>>6) & (e>>11) ^ (e>>25)
pxor XTMP1, XTMP3
xor y1, a ; y1 = a ^ (a >> (13-2)) ^ (a >> (22-2))
xor y2, g ; y2 = CH = ((f^g)&e)^g
psrld XTMP4, 3 ; XTMP4 = W[-15] >> 3
add y2, y0 ; y2 = S1 + CH
add y2, [rsp + _XFER + 1*4] ; y2 = k + w + S1 + CH
ror y1, 2 ; y1 = S0 = (a>>2) ^ (a>>13) ^ (a>>22)
pxor XTMP1, XTMP2 ; XTMP1 = W[-15] ror 7 ^ W[-15] ror 18
mov y0, a ; y0 = a
add h, y2 ; h = h + S1 + CH + k + w
mov y2, a ; y2 = a
pxor XTMP1, XTMP4 ; XTMP1 = s0
or y0, c ; y0 = a|c
add d, h ; d = d + h + S1 + CH + k + w
and y2, c ; y2 = a&c
;; compute low s1
pshufd XTMP2, X3, 11111010b ; XTMP2 = W[-2] {BBAA}
and y0, b ; y0 = (a|c)&b
add h, y1 ; h = h + S1 + CH + k + w + S0
paddd XTMP0, XTMP1 ; XTMP0 = W[-16] + W[-7] + s0
or y0, y2 ; y0 = MAJ = (a|c)&b)|(a&c)
add h, y0 ; h = h + S1 + CH + k + w + S0 + MAJ
ROTATE_ARGS
movdqa XTMP3, XTMP2 ; XTMP3 = W[-2] {BBAA}
mov y0, e ; y0 = e
mov y1, a ; y1 = a
ror y0, (25-11) ; y0 = e >> (25-11)
movdqa XTMP4, XTMP2 ; XTMP4 = W[-2] {BBAA}
xor y0, e ; y0 = e ^ (e >> (25-11))
ror y1, (22-13) ; y1 = a >> (22-13)
mov y2, f ; y2 = f
xor y1, a ; y1 = a ^ (a >> (22-13)
ror y0, (11-6) ; y0 = (e >> (11-6)) ^ (e >> (25-6))
psrlq XTMP2, 17 ; XTMP2 = W[-2] ror 17 {xBxA}
xor y2, g ; y2 = f^g
psrlq XTMP3, 19 ; XTMP3 = W[-2] ror 19 {xBxA}
xor y0, e ; y0 = e ^ (e >> (11-6)) ^ (e >> (25-6))
and y2, e ; y2 = (f^g)&e
psrld XTMP4, 10 ; XTMP4 = W[-2] >> 10 {BBAA}
ror y1, (13-2) ; y1 = (a >> (13-2)) ^ (a >> (22-2))
xor y1, a ; y1 = a ^ (a >> (13-2)) ^ (a >> (22-2))
xor y2, g ; y2 = CH = ((f^g)&e)^g
ror y0, 6 ; y0 = S1 = (e>>6) & (e>>11) ^ (e>>25)
pxor XTMP2, XTMP3
add y2, y0 ; y2 = S1 + CH
ror y1, 2 ; y1 = S0 = (a>>2) ^ (a>>13) ^ (a>>22)
add y2, [rsp + _XFER + 2*4] ; y2 = k + w + S1 + CH
pxor XTMP4, XTMP2 ; XTMP4 = s1 {xBxA}
mov y0, a ; y0 = a
add h, y2 ; h = h + S1 + CH + k + w
mov y2, a ; y2 = a
pshufb XTMP4, SHUF_00BA ; XTMP4 = s1 {00BA}
or y0, c ; y0 = a|c
add d, h ; d = d + h + S1 + CH + k + w
and y2, c ; y2 = a&c
paddd XTMP0, XTMP4 ; XTMP0 = {..., ..., W[1], W[0]}
and y0, b ; y0 = (a|c)&b
add h, y1 ; h = h + S1 + CH + k + w + S0
;; compute high s1
pshufd XTMP2, XTMP0, 01010000b ; XTMP2 = W[-2] {DDCC}
or y0, y2 ; y0 = MAJ = (a|c)&b)|(a&c)
add h, y0 ; h = h + S1 + CH + k + w + S0 + MAJ
ROTATE_ARGS
movdqa XTMP3, XTMP2 ; XTMP3 = W[-2] {DDCC}
mov y0, e ; y0 = e
ror y0, (25-11) ; y0 = e >> (25-11)
mov y1, a ; y1 = a
movdqa X0, XTMP2 ; X0 = W[-2] {DDCC}
ror y1, (22-13) ; y1 = a >> (22-13)
xor y0, e ; y0 = e ^ (e >> (25-11))
mov y2, f ; y2 = f
ror y0, (11-6) ; y0 = (e >> (11-6)) ^ (e >> (25-6))
psrlq XTMP2, 17 ; XTMP2 = W[-2] ror 17 {xDxC}
xor y1, a ; y1 = a ^ (a >> (22-13)
xor y2, g ; y2 = f^g
psrlq XTMP3, 19 ; XTMP3 = W[-2] ror 19 {xDxC}
xor y0, e ; y0 = e ^ (e >> (11-6)) ^ (e >> (25-6))
and y2, e ; y2 = (f^g)&e
ror y1, (13-2) ; y1 = (a >> (13-2)) ^ (a >> (22-2))
psrld X0, 10 ; X0 = W[-2] >> 10 {DDCC}
xor y1, a ; y1 = a ^ (a >> (13-2)) ^ (a >> (22-2))
ror y0, 6 ; y0 = S1 = (e>>6) & (e>>11) ^ (e>>25)
xor y2, g ; y2 = CH = ((f^g)&e)^g
pxor XTMP2, XTMP3
ror y1, 2 ; y1 = S0 = (a>>2) ^ (a>>13) ^ (a>>22)
add y2, y0 ; y2 = S1 + CH
add y2, [rsp + _XFER + 3*4] ; y2 = k + w + S1 + CH
pxor X0, XTMP2 ; X0 = s1 {xDxC}
mov y0, a ; y0 = a
add h, y2 ; h = h + S1 + CH + k + w
mov y2, a ; y2 = a
pshufb X0, SHUF_DC00 ; X0 = s1 {DC00}
or y0, c ; y0 = a|c
add d, h ; d = d + h + S1 + CH + k + w
and y2, c ; y2 = a&c
paddd X0, XTMP0 ; X0 = {W[3], W[2], W[1], W[0]}
and y0, b ; y0 = (a|c)&b
add h, y1 ; h = h + S1 + CH + k + w + S0
or y0, y2 ; y0 = MAJ = (a|c)&b)|(a&c)
add h, y0 ; h = h + S1 + CH + k + w + S0 + MAJ
ROTATE_ARGS
rotate_Xs
%endm
;; input is [rsp + _XFER + %1 * 4]
%macro DO_ROUND 1
mov y0, e ; y0 = e
ror y0, (25-11) ; y0 = e >> (25-11)
mov y1, a ; y1 = a
xor y0, e ; y0 = e ^ (e >> (25-11))
ror y1, (22-13) ; y1 = a >> (22-13)
mov y2, f ; y2 = f
xor y1, a ; y1 = a ^ (a >> (22-13)
ror y0, (11-6) ; y0 = (e >> (11-6)) ^ (e >> (25-6))
xor y2, g ; y2 = f^g
xor y0, e ; y0 = e ^ (e >> (11-6)) ^ (e >> (25-6))
ror y1, (13-2) ; y1 = (a >> (13-2)) ^ (a >> (22-2))
and y2, e ; y2 = (f^g)&e
xor y1, a ; y1 = a ^ (a >> (13-2)) ^ (a >> (22-2))
ror y0, 6 ; y0 = S1 = (e>>6) & (e>>11) ^ (e>>25)
xor y2, g ; y2 = CH = ((f^g)&e)^g
add y2, y0 ; y2 = S1 + CH
ror y1, 2 ; y1 = S0 = (a>>2) ^ (a>>13) ^ (a>>22)
add y2, [rsp + _XFER + %1 * 4] ; y2 = k + w + S1 + CH
mov y0, a ; y0 = a
add h, y2 ; h = h + S1 + CH + k + w
mov y2, a ; y2 = a
or y0, c ; y0 = a|c
add d, h ; d = d + h + S1 + CH + k + w
and y2, c ; y2 = a&c
and y0, b ; y0 = (a|c)&b
add h, y1 ; h = h + S1 + CH + k + w + S0
or y0, y2 ; y0 = MAJ = (a|c)&b)|(a&c)
add h, y0 ; h = h + S1 + CH + k + w + S0 + MAJ
ROTATE_ARGS
%endm
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; void sha256_sse4(void *input_data, UINT32 digest[8], UINT64 num_blks)
;; arg 1 : pointer to input data
;; arg 2 : pointer to digest
;; arg 3 : Num blocks
section .text
global sha256_sse4
align 32
sha256_sse4:
push rbx
%ifndef LINUX
push rsi
push rdi
%endif
push rbp
push r13
push r14
push r15
sub rsp,STACK_SIZE
%ifndef LINUX
movdqa [rsp + _XMM_SAVE + 0*16],xmm6
movdqa [rsp + _XMM_SAVE + 1*16],xmm7
movdqa [rsp + _XMM_SAVE + 2*16],xmm8
movdqa [rsp + _XMM_SAVE + 3*16],xmm9
movdqa [rsp + _XMM_SAVE + 4*16],xmm10
movdqa [rsp + _XMM_SAVE + 5*16],xmm11
movdqa [rsp + _XMM_SAVE + 6*16],xmm12
%endif
shl NUM_BLKS, 6 ; convert to bytes
jz done_hash
add NUM_BLKS, INP ; pointer to end of data
mov [rsp + _INP_END], NUM_BLKS
;; load initial digest
mov a,[4*0 + CTX]
mov b,[4*1 + CTX]
mov c,[4*2 + CTX]
mov d,[4*3 + CTX]
mov e,[4*4 + CTX]
mov f,[4*5 + CTX]
mov g,[4*6 + CTX]
mov h,[4*7 + CTX]
movdqa BYTE_FLIP_MASK, [PSHUFFLE_BYTE_FLIP_MASK wrt rip]
movdqa SHUF_00BA, [_SHUF_00BA wrt rip]
movdqa SHUF_DC00, [_SHUF_DC00 wrt rip]
loop0:
lea TBL,[K256 wrt rip]
;; byte swap first 16 dwords
COPY_XMM_AND_BSWAP X0, [INP + 0*16], BYTE_FLIP_MASK
COPY_XMM_AND_BSWAP X1, [INP + 1*16], BYTE_FLIP_MASK
COPY_XMM_AND_BSWAP X2, [INP + 2*16], BYTE_FLIP_MASK
COPY_XMM_AND_BSWAP X3, [INP + 3*16], BYTE_FLIP_MASK
mov [rsp + _INP], INP
;; schedule 48 input dwords, by doing 3 rounds of 16 each
mov SRND, 3
align 16
loop1:
movdqa XFER, [TBL + 0*16]
paddd XFER, X0
movdqa [rsp + _XFER], XFER
FOUR_ROUNDS_AND_SCHED
movdqa XFER, [TBL + 1*16]
paddd XFER, X0
movdqa [rsp + _XFER], XFER
FOUR_ROUNDS_AND_SCHED
movdqa XFER, [TBL + 2*16]
paddd XFER, X0
movdqa [rsp + _XFER], XFER
FOUR_ROUNDS_AND_SCHED
movdqa XFER, [TBL + 3*16]
paddd XFER, X0
movdqa [rsp + _XFER], XFER
add TBL, 4*16
FOUR_ROUNDS_AND_SCHED
sub SRND, 1
jne loop1
mov SRND, 2
loop2:
paddd X0, [TBL + 0*16]
movdqa [rsp + _XFER], X0
DO_ROUND 0
DO_ROUND 1
DO_ROUND 2
DO_ROUND 3
paddd X1, [TBL + 1*16]
movdqa [rsp + _XFER], X1
add TBL, 2*16
DO_ROUND 0
DO_ROUND 1
DO_ROUND 2
DO_ROUND 3
movdqa X0, X2
movdqa X1, X3
sub SRND, 1
jne loop2
addm [4*0 + CTX],a
addm [4*1 + CTX],b
addm [4*2 + CTX],c
addm [4*3 + CTX],d
addm [4*4 + CTX],e
addm [4*5 + CTX],f
addm [4*6 + CTX],g
addm [4*7 + CTX],h
mov INP, [rsp + _INP]
add INP, 64
cmp INP, [rsp + _INP_END]
jne loop0
done_hash:
%ifndef LINUX
movdqa xmm6,[rsp + _XMM_SAVE + 0*16]
movdqa xmm7,[rsp + _XMM_SAVE + 1*16]
movdqa xmm8,[rsp + _XMM_SAVE + 2*16]
movdqa xmm9,[rsp + _XMM_SAVE + 3*16]
movdqa xmm10,[rsp + _XMM_SAVE + 4*16]
movdqa xmm11,[rsp + _XMM_SAVE + 5*16]
movdqa xmm12,[rsp + _XMM_SAVE + 6*16]
%endif
add rsp, STACK_SIZE
pop r15
pop r14
pop r13
pop rbp
%ifndef LINUX
pop rdi
pop rsi
%endif
pop rbx
ret
section .data
align 64
K256:
dd 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5
dd 0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5
dd 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3
dd 0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174
dd 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc
dd 0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da
dd 0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7
dd 0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967
dd 0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13
dd 0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85
dd 0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3
dd 0xd192e819,0xd6990624,0xf40e3585,0x106aa070
dd 0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5
dd 0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3
dd 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208
dd 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2
PSHUFFLE_BYTE_FLIP_MASK: ddq 0x0c0d0e0f08090a0b0405060700010203
; shuffle xBxA -> 00BA
_SHUF_00BA: ddq 0xFFFFFFFFFFFFFFFF0b0a090803020100
; shuffle xDxC -> DC00
_SHUF_DC00: ddq 0x0b0a090803020100FFFFFFFFFFFFFFFF
*/
#endif
| [
"admin@cryptomiles.club"
] | admin@cryptomiles.club |
8c7c62725280963a45ef34bdcaa74e6d911e4f8a | c6176861e394bad79922ffececfe7d89f95a94e5 | /Floyd.cc | 39159d3bc88b36c016bed924d50b944adef2fba7 | [] | no_license | adamzyc/algorithm | 553d0f93ff959d3731335d17eb21dd2347598dd1 | 0394d7338f14feac8a0dbd14b360fd3a27c06a62 | refs/heads/master | 2021-01-25T05:34:18.461808 | 2015-05-11T09:14:21 | 2015-05-11T09:14:21 | 34,985,288 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 997 | cc | /*************************************************************************
> File Name: Floyd.cc
> Author: 周雨晨
> Mail: 15917836@qq.com
> Created Time: Sat 09 May 2015 15:39:35 CST
************************************************************************/
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
int main()
{
int e[10][10],k,i,j,m,n,t1,t2,t3;
int inf = 999999;
scanf("%d %d",&n,&m); //读入n顶点个数,m边数
for(i=1;i<n;i++)
for(j=1;j<n;j++)
if(i==j) e[i][j] = 0;
else e[i][j] = inf;
for(i=1;i<=m;++i)
{
scanf("%d %d %d",&t1,&t2,&t3);
e[t1][t2] = t3;
}
for(k=1;k<=n;k++)
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
if(e[i][j] > e[i][k] + e[k][j])
e[i][j] = e[i][k] + e[k][j];
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
printf("%10d",e[i][j]);
printf("\n");
}
return 0;
}
| [
"m18166546481@163.com"
] | m18166546481@163.com |
98fd4b18aaf5125a6419e8fbee84fae2e60909ca | 0edbcda83b7a9542f15f706573a8e21da51f6020 | /private/windows/shell/dskquota/watchdog/stats.h | ddfc3608f5da9f2a96fade476fea6c9b14317178 | [] | no_license | yair-k/Win2000SRC | fe9f6f62e60e9bece135af15359bb80d3b65dc6a | fd809a81098565b33f52d0f65925159de8f4c337 | refs/heads/main | 2023-04-12T08:28:31.485426 | 2021-05-08T22:47:00 | 2021-05-08T22:47:00 | 365,623,923 | 1 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 4,269 | h | #ifndef __STATS_H
#define __STATS_H
///////////////////////////////////////////////////////////////////////////////
/* File: stats.h
Description: These classes provide temporary storage of quota
information for a given volume/user pair. Creation of the object
automatically gathers the necessary quota and user information.
Clients then query the objects to retrieve quota statistics when
desired.
CStatistics
CStatisticsList
+----------+
+--->| CVolume |
| +----------+
+-----------------+ +-------------+<---+
| CStatisticsList |<-->>| CStatistics | contains
+-----------------+ +-------------+<---+
| +-------------+
+--->| CVolumeUser |
+-------------+
Revision History:
Date Description Programmer
-------- --------------------------------------------------- ----------
07/01/97 Initial creation. BrianAu
*/
///////////////////////////////////////////////////////////////////////////////
#ifndef _WINDOWS_
# include <windows.h>
#endif
#ifndef __VOLUSER_H
# include "voluser.h"
#endif
#ifndef __VOLUME_H
# include "volume.h"
#endif
class CStatistics
{
public:
CStatistics(TCHAR chVolLetter,
LPCTSTR pszVolDisplayName,
LPBYTE pUserSid);
~CStatistics(VOID) { };
BOOL SameVolume(const CStatistics& rhs) const
{ return m_vol == rhs.m_vol; }
TCHAR GetVolumeLetter(VOID) const
{ return m_vol.GetLetter(); }
VOID GetVolumeDisplayName(CString& strOut) const
{ m_vol.GetDisplayName(strOut); }
LPCTSTR GetVolumeDisplayName(VOID) const
{ return m_vol.GetDisplayName(); }
BOOL QuotasEnabled(VOID) const
{ return m_bQuotaEnabled; }
BOOL WarnAtThreshold(VOID) const
{ return m_bWarnAtThreshold; }
BOOL DenyAtLimit(VOID) const
{ return m_bDenyAtLimit; }
VOID GetUserDisplayName(CString& strOut) const
{ m_volUser.GetDisplayName(strOut); }
LPCTSTR GetUserDisplayName(VOID) const
{ return m_volUser.GetDisplayName(); }
VOID GetUserEmailName(CString& strOut) const
{ m_volUser.GetEmailName(strOut); }
LPCTSTR GetUserEmailName(VOID) const
{ return m_volUser.GetEmailName(); }
LARGE_INTEGER GetUserQuotaThreshold(VOID) const
{ return m_volUser.GetQuotaThreshold(); }
LARGE_INTEGER GetUserQuotaLimit(VOID) const
{ return m_volUser.GetQuotaLimit(); }
LARGE_INTEGER GetUserQuotaUsed(VOID) const
{ return m_volUser.GetQuotaUsed(); }
BOOL IsValid(VOID) const
{ return m_bValid; }
BOOL IncludeInReport(VOID) const;
private:
CVolume m_vol; // Volume-specific info.
CVolumeUser m_volUser; // User-specific info.
BOOL m_bQuotaEnabled; // Are quotas enabled?
BOOL m_bWarnAtThreshold; // Warn user at threshold?
BOOL m_bDenyAtLimit; // Deny disk space at limit?
BOOL m_bValid; // Is this object valid?
//
// Prevent copy.
//
CStatistics(const CStatistics& rhs);
CStatistics& operator = (const CStatistics& rhs);
};
class CStatisticsList
{
public:
CStatisticsList(VOID);
~CStatisticsList(VOID);
INT Count(VOID)
{ return m_List.Count(); }
const CStatistics *GetEntry(INT iEntry);
HRESULT AddEntry(TCHAR chVolLetter,
LPCTSTR pszVolDisplayName,
LPBYTE pUserSid);
private:
CArray<CStatistics *> m_List;
};
#endif //__STATS_H
| [
"ykorokhov@pace.ca"
] | ykorokhov@pace.ca |
3bdaf49251de7fd00e5a4ef8d25df22300329ee3 | dc2e0d49f99951bc40e323fb92ea4ddd5d9644a0 | /Activemq-cpp_3.7.1/activemq-cpp/src/test-integration/activemq/test/stomp/StompBulkMessageTest.h | 941030f74d57afa2247f72f54b56064bf99330ef | [
"Apache-2.0"
] | permissive | wenyu826/CecilySolution | 8696290d1723fdfe6e41ce63e07c7c25a9295ded | 14c4ba9adbb937d0ae236040b2752e2c7337b048 | refs/heads/master | 2020-07-03T06:26:07.875201 | 2016-11-19T07:04:29 | 2016-11-19T07:04:29 | 74,192,785 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,559 | h | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 _ACTIVEMQ_TEST_STOMP_STOMPBULKMESSAGETESTER_H_
#define _ACTIVEMQ_TEST_STOMP_STOMPBULKMESSAGETESTER_H_
#include <activemq/test/BulkMessageTest.h>
namespace activemq{
namespace test{
namespace stomp{
class StompBulkMessageTest : public BulkMessageTest {
CPPUNIT_TEST_SUITE( StompBulkMessageTest );
CPPUNIT_TEST( testBulkMessageSendReceive );
CPPUNIT_TEST_SUITE_END();
public:
StompBulkMessageTest();
virtual ~StompBulkMessageTest();
virtual std::string getBrokerURL() const {
return activemq::util::IntegrationCommon::getInstance().getStompURL();
}
};
}}}
#endif /*_ACTIVEMQ_TEST_STOMP_STOMPBULKMESSAGETESTER_H_*/
| [
"626955115@qq.com"
] | 626955115@qq.com |
84afe27e1236819714d3181c39c5af60a84f6a98 | ac37d8d8b8506ed87d589f4fbbddba445793340e | /NMF/NMF.cpp | be48709191d742310b77730381e9b023aeb1db55 | [] | no_license | yingqichao/Robust-Perceptual-Image-Hashing-Based-on-Ring-Partition-and-NMF | 7af7cde23bb82757aeb539f47eb412dc414a3919 | 2a6200846a81900eecdb30a1037871582b0732f4 | refs/heads/master | 2022-11-13T01:02:09.148128 | 2020-06-30T08:35:41 | 2020-06-30T08:35:41 | 189,379,049 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 18,644 | cpp | #include "NMF.h"
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/xfeatures2d.hpp>
using namespace std;
using namespace cv;
//clock_t start, endq;
int main()
{
char* path1 = "E:/HashTest/HashTest/pic/330.jpg";
char* path2 = "E:/HashTest/HashTest/pic/331.jpg";
char* out1 = SingleHashCode(path1);
cout << "out1 = " << out1 << endl;
char* out2 = SingleHashCode(path2);
cout << "out2 = " << out2 << endl;
float sim = HashCodeCompare_string(out1, out2); //第一次比对,比较两串哈希码字符串的SSIM
cout << "sim = " << sim << endl;
//start = clock();
int a = HashCodeCompare_second(path1, path2); //第二次比对,仅对第一次结果大于0.9的每对图片进行SURF特征点匹配
cout << a << endl;
//endq = clock();
//double endtime = (double)(endq - start) / CLOCKS_PER_SEC;
//cout << "Total time:" << endtime * 1000 << "ms" << endl; //计时
system("pause");
return 0;
}
int HashCodeCompare_second(char* in1, char* in2) //第二次比对,仅对第一次结果大于0.9的每对图片进行SURF特征点匹配
{
Mat img_1 = imread(in1);
Mat img_2 = imread(in2);
if (img_1.empty() || img_2.empty()) //保证路径错误时不报错
{
int p = 0;
return p;
}
Ptr<Feature2D> Detector = xfeatures2d::SURF::create();
vector<KeyPoint> keypoints1, keypoints2; //得到特征点
Detector->detect(img_1, keypoints1);
Detector->detect(img_2, keypoints2);
Mat descriptors1, descriptors2; //特征点描述子
Detector->compute(img_1, keypoints1, descriptors1);
Detector->compute(img_2, keypoints2, descriptors2);
FlannBasedMatcher matcher; //特征点匹配
vector<vector<DMatch>> matchpoints;
vector<DMatch> Usefulmatchpoints;
vector<Mat> traindescriptors(1, descriptors1);
matcher.add(traindescriptors);
matcher.train();
matcher.knnMatch(descriptors2, matchpoints, 2);
//matcher.match(descriptors1, descriptors2, matchpoints);
for (int i = 0; i < matchpoints.size(); i++) //选其中较好的特征点
{
if (matchpoints[i][0].distance < 0.5 * matchpoints[i][1].distance)
{
Usefulmatchpoints.push_back(matchpoints[i][0]);
}
}
int size1 = min(img_1.rows, img_1.cols);
int size2 = min(img_2.rows, img_2.cols);
int i = 0;
if (size1 >= 300 && size2 >= 300 ) //以下均为根据不同图片尺寸选取阈值,阈值用于判别匹配点数量是否足够
{
if (Usefulmatchpoints.size() > 100)
{
i = 1;
}
else
{
i = 0;
}
}
else if (size1 < 150 || size2 < 150)
{
if (Usefulmatchpoints.size() > 10)
{
i = 1;
}
else
{
i = 0;
}
}
else
{
if (Usefulmatchpoints.size() > 30)
{
i = 1;
}
else
{
i = 0;
}
}
cout << Usefulmatchpoints.size() << endl;
return i;
}
float HashCodeCompare_string(char* hash1, char* hash2) //比较两个字符串输入的相关性
{
string line = hash1;
float* tmp = new float[64];
string key = line;
int p = 0;
for (int i = 0; i < 64; i++) {
int t = 0;
for (int j = 0; j < 3; j++) {
t += line[3 * i + j] - '!';
p++;
}
tmp[i] = (float)t;
}
string line2 = hash2;
float* tmp2 = new float[64];
string key2 = line2;
int p2 = 0;
for (int i = 0; i < 64; i++) {
int t = 0;
for (int j = 0; j < 3; j++) {
t += line2[3 * i + j] - '!';
p++;
}
tmp2[i] = (float)t;
}
for (int i = 0; i < 64; i++)
{
cout << tmp[i] ;
cout << ";";
}
cout << endl;
for (int i = 0; i < 64; i++)
{
cout << tmp2[i];
cout << ";";
}
cout << endl;
//float sim = corr(tmp, tmp2, 64);
float sim = ssim(tmp, tmp2, 64);
delete []tmp;
delete []tmp2;
return sim;
}
char* SingleHashCode(char* in) //单张图像生成Hash码返回string
{
Mat oriImg = imread(in);
char* p;
if (oriImg.empty())
{
p = "\0";
return p;
}
int imgsize = 512;
int ring = 32;
int rank = 2;
Mat H1 = RingNMF(oriImg, imgsize, ring, rank, in);
int len = H1.rows*H1.cols; //len1==len2
uchar* f1 = new uchar[len];
int k = 0;
for (int j = 0; j < H1.cols; j++)
{
for (int i = 0; i < H1.rows; i++)
{
f1[k] = round(H1.at<float>(i, j));
k++;
}
}
map<string, uchar*> m1;
m1.insert(make_pair(in, f1));
delete []f1;
map<string, uchar*>::iterator iter;
iter = m1.begin();
string out;
while (iter != m1.end()) {
string name = iter->first;
uchar* h = iter->second;
for (int i = 0; i < len; i++) {
int t = (int)h[i];
for (int j = 0; j < 3; j++) {
int cur = min(93, t);
char tmp = '!' + cur;
t -= cur;
out.push_back(tmp);
}
}
iter++;
}
int hashlen = out.length();
p = (char *)malloc((hashlen + 1) * sizeof(char));
//char* p = nullptr;
out.copy(p, hashlen, 0);
//static char q[193];
//int i;
//for (i = 0; i < out.length(); i++)
// q[i] = out[i];
//q[i] = '\0';
//char* p = q;
//memcpy(p, (char*)out.data(), (out.length() + 1) * sizeof(char));
//p = (char*)out.data();
//p = (char*)out.data();
//cout << p << endl;
return p;
}
void GenerateHashCode(char* in, int mode) {
//mode:1-hashcode.txt(源文件),2-hashtest.txt(待检测文件)
int len = 64;
map<string, uchar*> Map = calculation(in);
string pname = (string)in + "\\" + ((mode == 0) ? "hashcode.txt" : "hashtest.txt");
saveFile(Map, pname, len);
}
void observeHashCode(char* in) {
try {
map<string, uchar*> m1;
int len0 = 64; int imgsize = 512; // Image size
int ring = 32; // Ring Number
int rank = 2; // Rank
Mat oriIm = imread(in);
Mat H1 = RingNMF(oriIm, imgsize, ring, rank, in);
int len = H1.rows*H1.cols; //len1==len2
uchar* f1 = new uchar[len];
int k = 0;
for (int j = 0; j < H1.cols; j++)
{
for (int i = 0; i < H1.rows; i++)
{
//float转uchar
f1[k] = round(H1.at<float>(i, j));
k++;
}
}
m1.insert(make_pair(in, f1));
string pname = "observe.txt";
saveFile(m1, pname, len0);
}
catch (cv::Exception& e) {
cout << "Error loading Image: " << in << endl;
}
}
void HashTest(char* in, char* fold2, int tolerance) {
int len0 = 64;
ofstream ofresult("result.txt");
if (!ofresult.is_open()) {
cout << "File is open fail!" << endl;
return;
}
map<string, float*> Map1;
int imgsize = 512; // Image size
int ring = 32; // Ring Number
int rank = 2; // Rank
Mat oriIm = imread(in);
Mat H1 = RingNMF(oriIm, imgsize, ring, rank, in);
int len = H1.rows*H1.cols; //len1==len2
float* f1 = new float[len];
int k = 0;
for (int j = 0; j < H1.cols; j++)
{
for (int i = 0; i < H1.rows; i++)
{
//float转uchar
f1[k] = round(H1.at<float>(i, j));
k++;
}
}
Map1.insert(make_pair(in, f1));
map<string, float*> Map2 = read("hashtest.txt", len0);
map<string, float*>::iterator iter1;
iter1 = Map1.begin();
while (iter1 != Map1.end()) {
string targetname = iter1->first;
cout << "Comparing Result For :" << targetname << endl;
ofresult << "Compare Result For :" << targetname << endl;
float* F1 = iter1->second;
map<string, float*>::iterator iter2;
iter2 = Map2.begin();
while (iter2 != Map2.end()) {
string comparename = iter2->first;
float* F2 = iter2->second;
float sim = corr(F1, F2, len);
if (sim >= tolerance / 10.0) {
ofresult << sim << " " << targetname << endl;
cout << sim << " " << targetname << endl;
}
iter2++;
}
iter1++;
}
ofresult.close();
}
void HashTest_folder(char* fold1, char* fold2, int tolerance) {
int len = 64;
ofstream ofresult("result.txt");
if (!ofresult.is_open()) {
cout << "File is open fail!" << endl;
return;
}
map<string, float*> Map1 = read("hashcode.txt", len);
map<string, float*> Map2 = read("hashtest.txt", len);
map<string, float*>::iterator iter1;
iter1 = Map1.begin();
while (iter1 != Map1.end()) {
string targetname = iter1->first;
cout << "Comparing Result For :" << targetname << endl;
ofresult << "Compare Result For :" << targetname << endl;
float* F1 = iter1->second;
map<string, float*>::iterator iter2;
iter2 = Map2.begin();
while (iter2 != Map2.end()) {
string comparename = iter2->first;
float* F2 = iter2->second;
float sim = corr(F1, F2, len);
if (sim >= tolerance / 10.0) {
ofresult << sim << " " << targetname << endl;
cout << sim << " " << targetname << endl;
}
iter2++;
}
iter1++;
}
ofresult.close();
}
/**
vector<string> findTxt(char* in_path) {
string str = in_path;
struct _finddata_t fileinfo;
vector<string> res;
string in_name;
string curr = str + "\\*.txt";
long handle;
if ((handle = _findfirst(curr.c_str(), &fileinfo)) == -1L)
{
cout << "没有找到匹配文件!" << endl;
}
else
{
in_name = str + "\\" + fileinfo.name;
res.push_back(in_name);
while (!(_findnext(handle, &fileinfo)))
{
in_name = str + "\\" + fileinfo.name;
res.push_back(in_name);
}
_findclose(handle);
}
return res;
}
**/
map<string, uchar*> calculation(char* fold) {
//Settings
int imgsize = 512; // Image size
int ring = 32; // Ring Number
int rank = 2; // Rank
map<string, uchar*> m1;
string format[6] = { "/*.jpg","/*.png","/*.tif","/*.bmp","/*.jpeg","/*.tiff" };
for (int ind = 0; ind < 6; ind++) {
cv::String pattern1 = fold + format[ind];
vector<cv::String> fn1;
glob(pattern1, fn1, false);
for (int im = 0; im < fn1.size(); im++) {
try {
Mat oriIm = imread(fn1[im]);
Mat H1 = RingNMF(oriIm, imgsize, ring, rank, fn1[im]);
int len = H1.rows*H1.cols; //len1==len2
uchar* f1 = new uchar[len];
int k = 0;
for (int j = 0; j < H1.cols; j++)
{
for (int i = 0; i < H1.rows; i++)
{
//float转uchar
f1[k] = round(H1.at<float>(i, j));
k++;
}
}
m1.insert(make_pair(fn1[im], f1));
}
catch (cv::Exception& e) {
cout << "Error loading Image: " << fn1[im] << endl;
}
}
}
return m1;
}
Mat RingNMF(Mat Im, int imgsize, int ring, int rank, string name) {
//对图像I进行环形分割,
//规格化图像为imgsize*imgsize, n个环形等面积,
//图像内切圆的半径为R,如果按半径等分,则第i个圆环的半径 ri ^ 2 = i * R ^ 2 / n;
resize(Im, Im, Size(imgsize, imgsize));
cout << "Generating hashcode for: " << name << endl;
GaussianBlur(Im, Im, Size(3, 3), 1); //低通滤波
cvtColor(Im, Im, 37);//转YCbCr
Mat ImChannel[3];
//src为要分离的Mat对象
split(Im, ImChannel); //利用数组分离
Mat I1 = ImChannel[0];
//imshow("portion",I1);
//waitKey();
double cc = 0;
if (imgsize % 2 == 0)
cc = imgsize / 2.0 + 0.5; //圆心坐标(cc, cc)
else
cc = (imgsize + 1) / 2.0;
Mat H = cv::Mat::zeros(ring, 1, CV_32FC1);
Mat rpt = cv::Mat::zeros(1, imgsize, CV_32FC1);
for (int i = 0; i < imgsize; i++)
rpt.at<float>(0, i) = i + 1;
Mat XA = repeat(rpt, imgsize, 1);
Mat YA; transpose(XA, YA);
for (int j = 0; j < imgsize; j++)
{
for (int i = 0; i < imgsize; i++)
{
XA.at<float>(j, i) = pow((XA.at<float>(j, i) - cc), 2) + pow((YA.at<float>(j, i) - cc), 2);
}
}
Mat RN = cv::Mat::zeros(1, ring, CV_32FC1);
for (int i = 0; i < ring; i++)
RN.at<float>(0, i) = i + 1;
RN.at<float>(0, ring - 1) = imgsize - cc;
float s = floor(CV_PI*RN.at<float>(0, ring - 1) * RN.at<float>(0, ring - 1) / ring);
RN.at<float>(0, 0) = sqrt(s / CV_PI);
for (int i = 1; i < ring - 1; i++)
RN.at<float>(0, i) = sqrt((s + CV_PI * RN.at<float>(0, i - 1) * RN.at<float>(0, i - 1)) / CV_PI); //radius of each circle
for (int i = 0; i < ring; i++)
RN.at<float>(0, i) = pow(RN.at<float>(0, i), 2);
Mat V = cv::Mat::zeros(s, ring, CV_32FC1);
vector<vector<float>> vectorHolder;
vector<float> v;
for (int j = 0; j < imgsize; j++)
{
for (int i = 0; i < imgsize; i++)
{
if (XA.at<float>(j, i) <= RN.at<float>(0, 0)) {
v.push_back((float)I1.at<uchar>(j, i));
}
}
}
vectorHolder.push_back(v);
int len = v.size(); int row = 0;
/*float* mapped = new float[s];
funcResampling(mapped, s, &v[0], v.size());
sort(mapped, mapped+(int)s);
for (int i = 0; i < (int)s;i++) {
V.at<float>(row,0) = mapped[i];
row++;
}*/
//Starting from 2nd ring
for (int r = 0; r < ring - 1; r++) {
//cout << "Ring" << endl;
vector<float> v1;
for (int j = 0; j < imgsize; j++)
{
for (int i = 0; i < imgsize; i++)
{
if (XA.at<float>(j, i) <= RN.at<float>(0, r + 1) && XA.at<float>(j, i) > RN.at<float>(0, r))
v1.push_back((float)I1.at<uchar>(j, i));
}
}
len = min(len, (int)v1.size());
vectorHolder.push_back(v1);
}
for (int r = 0; r < ring; r++) {
/*funcResampling(mapped, s, &v[0], v.size());*/
//cout << "Sort" << endl;
vector<float> tmp = vectorHolder[r];
sort(tmp.begin(), tmp.begin() + len);
row = 0;
for (int i = 0; i < len; i++) {
V.at<float>(row, r + 1) = vectorHolder[r][i];
row++;
}
}
//for (int r = 0; r < ring - 1; r++)
// delete vectorHolder[r];
//delete vectorHolder;
int maxiter = 60;
H = NMFLee2000(V, rank, maxiter);
return H;
}
//
Mat NMFLee2000(Mat V, int rank, int maxiter) {
int n = V.rows; int m = V.cols;
cv::RNG rnger;
cv::Mat W;
// CV_32FC1 uniform distribution
W.create(n, rank, CV_32FC1);
rnger.fill(W, cv::RNG::UNIFORM, cv::Scalar::all(0.), cv::Scalar::all(1.));
////Reset
//rnger(cv::getTickCount());
cv::Mat H;
// CV_32FC1 uniform distribution
H.create(rank, m, CV_32FC1);
rnger.fill(H, cv::RNG::UNIFORM, cv::Scalar::all(0.), cv::Scalar::all(1.));
for (int iter = 0; iter < maxiter; iter++) {
//Stage 1
// %H = (H.*(W'*(V./(W*H))))./((sum(W)')*ones(1, m))
// %1.e1 = (W*H) s1 = (sum(W)')
Mat e1 = W * H;
Mat s1 = cv::Mat::zeros(rank, 1, CV_32FC1);
for (int j = 0; j < rank; j++)
{
for (int i = 0; i < n; i++)
{
s1.at<float>(j, 0) = s1.at<float>(j, 0) + W.at<float>(i, j);
}
}
// %2.e2 = V. / e1 s2 = s1 * ones(1,m)
Mat Ones = Mat::ones(1, m, CV_32FC1);
Mat s2 = s1 * Ones;
Mat e2 = Mat::zeros(V.rows, V.cols, CV_32FC1);
for (int j = 0; j < V.rows; j++)
{
for (int i = 0; i < V.cols; i++)
{
e2.at<float>(j, i) = V.at<float>(j, i) / (e1.at<float>(j, i) + 0.0001);
}
}
// %3.e3 = W'*e2 e4 = H.*e3
Mat W1; transpose(W, W1);
Mat e3 = W1 * e2;
Mat e4 = Mat::zeros(H.rows, H.cols, CV_32FC1);
for (int j = 0; j < H.rows; j++)
{
for (int i = 0; i < H.cols; i++)
{
e4.at<float>(j, i) = H.at<float>(j, i) * e3.at<float>(j, i);
}
}
// %4.H = e4. / s2
for (int j = 0; j < H.rows; j++)
{
for (int i = 0; i < H.cols; i++)
{
H.at<float>(j, i) = e4.at<float>(j, i) / (s2.at<float>(j, i) + 0.0001);
}
}
//Stage 2
//%1.e1 = W * H s1 = (sum(H, 2)')
e1 = W * H;
s1 = cv::Mat::zeros(1, rank, CV_32FC1);
for (int j = 0; j < rank; j++)
{
for (int i = 0; i < m; i++)
{
s1.at<float>(0, j) += H.at<float>(j, i);
}
}
//%2.e2 = V. / e1 s2 = ones(n, 1)*s1
for (int j = 0; j < V.rows; j++)
{
for (int i = 0; i < V.cols; i++)
{
e2.at<float>(j, i) = V.at<float>(j, i) / (e1.at<float>(j, i) + 0.0001);
}
}
Ones = Mat::ones(n, 1, CV_32FC1);
s2 = Ones * s1;
//%3.e3 = e2 * H' e4 = W.*e3
Mat H1; transpose(H, H1);
e3 = e2 * H1;
e4 = Mat::zeros(W.rows, W.cols, CV_32FC1);
for (int j = 0; j < W.rows; j++)
{
for (int i = 0; i < W.cols; i++)
{
e4.at<float>(j, i) = W.at<float>(j, i) * e3.at<float>(j, i);
}
}
//%4.W = e4. / s2
for (int j = 0; j < W.rows; j++)
{
for (int i = 0; i < W.cols; i++)
{
W.at<float>(j, i) = e4.at<float>(j, i) / (s2.at<float>(j, i) + 0.0001);
}
}
}
return H;
}
void funcResampling(float *pDst, unsigned destLen, float *pSrc, unsigned srcLen) {
for (unsigned indexD = 0; indexD < destLen; indexD++)
{
unsigned nCount = 0;
for (unsigned j = 0; j < srcLen; j++)
{
unsigned indexM = indexD * srcLen + j;
unsigned indexS = indexM / destLen;
nCount += pSrc[indexS];
}
pDst[indexD] = nCount / (float)srcLen;
}
}
float corr(float* x, float* y, int N) {
float sum_sq_x = 0;
float sum_sq_y = 0;
float sum_coproduct = 0;
float mean_x = x[0];
float mean_y = y[0];
float sweep;
float delta_x;
float delta_y;
for (int i = 1; i < N; i++) {
sweep = (i - 1.0) / i;
delta_x = x[i] - mean_x;
delta_y = y[i] - mean_y;
sum_sq_x += delta_x * delta_x * sweep;
sum_sq_y += delta_y * delta_y * sweep;
sum_coproduct += delta_x * delta_y * sweep;
mean_x += delta_x / i;
mean_y += delta_y / i;
}
float pop_sd_x = sqrt(sum_sq_x / N);
float pop_sd_y = sqrt(sum_sq_y / N);
float cov_x_y = sum_coproduct / N;
float correlation = cov_x_y / (pop_sd_x * pop_sd_y);
return correlation;
}
float ssim(float* x, float* y, int N) {
float mean_x = 0;
float mean_y = 0;
float sigma_x = 0;
float sigma_y = 0;
float sigma_xy = 0;
float C1 = 6.5025, C2 = 58.5225;
for (int i = 0; i < N; i++) {
mean_x += x[i];
mean_y += y[i];
}
mean_x = mean_x / N;
mean_y = mean_y / N;
for (int i = 0; i < N; i++) {
sigma_x += (x[i] - mean_x)*(x[i] - mean_x);
sigma_y += (y[i] - mean_y)*(y[i] - mean_y);
sigma_xy += abs((x[i] - mean_x)*(y[i] - mean_y));
}
sigma_x = sigma_x / N;
sigma_y = sigma_y / N;
sigma_xy = sigma_xy / N;
float x1 = (2 * mean_x*mean_y + C1) * (2 * sigma_xy + C2);
float x2 = (mean_x*mean_x + mean_y * mean_y + C1) * (sigma_x + sigma_y + C2);
float ssim = x1 / x2;
return ssim;
}
void saveFile(map<string, uchar*> hashcode, string foldpath, int len) {
ofstream ofresult(foldpath);
if (!ofresult.is_open()) {
cout << "File is open fail!" << endl;
return;
}
map<string, uchar*>::iterator iter;
iter = hashcode.begin();
while (iter != hashcode.end()) {
string name = iter->first;
uchar* h = iter->second;
ofresult << name << endl;
for (int i = 0; i < len; i++) {
int t = (int)h[i];
for (int j = 0; j < 3; j++) {
int cur = min(93, t);
char tmp = '!' + cur;
t -= cur;
ofresult << tmp;
}
}
ofresult << endl;
iter++;
}
/*while (iter != obm.end()) {
ofresult << iter->first << endl;
ofresult << iter->second << endl;
iter++;
}*/
ofresult.close();
}
map<string, float*> read(string name, int len) {
//说明:hashcode用来读取原图,hashtest用来读取测试图
map<string, float*> dict;
fstream f(name);
f.open(name);
if (f.is_open())
{
string line;
while (getline(f, line))
{
float* tmp = new float[len];
string key = line;
getline(f, line);
int p = 0;
for (int i = 0; i < len; i++) {
int t = 0;
for (int j = 0; j < 3; j++) {
t += line[3 * i + j] - '!';
p++;
}
tmp[i] = (float)t;
}
dict.insert(make_pair(key, tmp));
}
f.close();
}
//char* ShowArr = new char[len];
//fstream f(name);
//string line;
//getline(f, line);
//int i = 0;
//while (!f.eof())
//{
// f >> ShowArr[i];
// i++;
//}
//f.close();
return dict;
} | [
"shinydotcom@163.com"
] | shinydotcom@163.com |
b6f6d68491be4edea3ef0e6a7c05e70e3bbf431f | 018d53451db1e2f75b46935cdecbd041af63cb97 | /SmithWaterman.cpp | ac879219a2edd19c4ff53a002fe659b3377ec729 | [] | no_license | allengmcd/adna | 49929a03676f31a30b74430ded603fac5e4b55df | 73d2e4c662cfa4d30e3352f4f0421c07e2055ce6 | refs/heads/master | 2021-06-06T12:41:20.046484 | 2016-10-30T21:45:50 | 2016-10-30T21:45:50 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,510 | cpp | #include "SmithWaterman.hpp"
using namespace std;
typedef vector<vector<int> >Grid;
//similarity function
#define MATCH 7
#define MISMATCH -4
// const int MATCH = 2;
// const int MISMATCH = -3;
//gap-scoring scheme
#define GAP_EXTENSION 8
#define GAP_PENALTY 10
// const int GAP = -4;
class functions {
public:
/**
** this function calculates the individual scores
** for each cell in the table
**/
Grid build_grid (string str1, string str2) {
int m = str1.length();
int n = str2.length();
Grid grid(m+1, vector<int>(n+1, 0));
// cout << str1 << " " << str2 << " " << n << endl;
for (int i = 1; i < grid.size(); i++) {
char a = str1[i-1];
for (int j = 1; j < grid[i].size(); j++) {
char b = str2[j-1];
int score = 0;
int match = 0;
int deletion = 0;
int insertion = 0;
//match/mismatch
int s = (a == b) ? MATCH : MISMATCH;
match = grid[i-1][j-1] + s;
//deletion
for (int k = i-1; k > 0; k--) {
int temp = grid[i-k][j] - gap(k);
if (deletion < temp) deletion = temp;
}
// deletion = grid[i-1][j] + GAP;
//insertion
for (int l = j-1; l > 0; l--) {
int temp = grid[i][j-l] - gap(l);
if (deletion < temp) insertion = temp;
}
// insertion = grid[i][j-1] + GAP;
//find maximum between the three
score = (score < match) ? match : score;
score = (score < deletion) ? deletion : score;
score = (score < insertion) ? insertion : score;
grid[i][j] = score;
}
}
return grid;
}
void print_grid (string str1, string str2, Grid grid) {
int m = str1.length();
int n = str2.length();
cout << setw(5) << "- ";
for (int i = 0; i < str2.length(); i++) {
cout << setw(2) << str2[i] << " ";
}
cout << endl;
for (int i = 0; i < m+1; i++) {
if (i != 0) {
cout << str1[i-1] << " ";
} else {
cout << "- ";
}
for (int j = 0; j < n+1; j++) {
cout << setw(2) << grid[i][j] << " ";
}
cout << endl;
}
cout << endl;
}
private:
int gap (int i) {
return GAP_PENALTY + (GAP_EXTENSION * i);
}
// int similarity_function() {
// }
};
SmithWaterman::SmithWaterman (string str1, string str2, int match_score) : str1(str1), str2(str2), match_score(match_score) {
functions f;
int m = str1.length();
int n = str2.length();
// grid.resize(m+1,vector<int>(n+1,0));
if (m == 0 || n == 0) {
cout << "Error: string(s) length is zero" << endl;
exit(EXIT_FAILURE);
}
grid = f.build_grid(str1, str2);
f.print_grid(str1,str2,grid);
}
string SmithWaterman::trim_both_sides () {
string trimmed = trim_from_beginning();
str1 = trimmed;
functions f;
grid = f.build_grid(str1, str2);
int m = str1.length();
int n = str2.length();
cout << setw(5) << "- ";
for (int i = 0; i < str2.length(); i++) {
cout << setw(2) << str2[i] << " ";
}
cout << endl;
for (int i = 0; i < m+1; i++) {
if (i != 0) {
cout << str1[i-1] << " ";
} else {
cout << "- ";
}
for (int j = 0; j < n+1; j++) {
cout << setw(2) << grid[i][j] << " ";
}
cout << endl;
}
cout << endl;
return trim_from_ending();
}
/**
** This function trims beginning adapter from
** sequence read
**/
string SmithWaterman::trim_from_beginning () {
int highest = 0;
int highest_i = 0;
int highest_j = 0;
for (int i = 0; i < grid.size(); i++) {
for (int j = 0; j <grid[i].size(); j++) {
if (grid[i][j] > highest) {
highest = grid[i][j];
highest_i = i;
highest_j = j;
}
}
}
string trimmed = str1.substr(highest_i, str1.length()-highest_i);
return trimmed;
}
/**
** This function trims ending adapter from
** sequence read
**/
string SmithWaterman::trim_from_ending () {
int highest = 0;
int highest_i = 0;
int highest_j = 0;
for (int i = 0; i < grid.size(); i++) {
for (int j = 0; j <grid[i].size(); j++) {
if (grid[i][j] >= highest) {
highest = grid[i][j];
highest_i = i;
highest_j = j;
}
}
}
// cout << highest_i << "," << highest_j << endl;
//get trimmed sequence
int curr_score = highest;
int i = highest_i;
int j = highest_j;
while (curr_score != 0 && i > 0 && j > 0) {
int current = grid[i][j];
int left = grid[i][j-1];
int upper_left = grid[i-1][j-1];
int upper = grid[i-1][j];
int next_i = i-1;
int next_j = j-1;
int next_highest = 0;
if (left > next_highest) {
// if (left != current) {
//left is biggest
next_highest = left;
next_j = j-1;
// }
}
if (upper_left > next_highest) {
// if (upper_left != current) {
//upper_left is biggest
next_highest = upper_left;
next_i = i-1;
next_j = j-1;
// }
}
if (upper > next_highest) {
// if (upper != current) {
//upper is bigest
next_highest = upper;
next_i = i-1;
// }
}
i = next_i;
j = next_j;
// cout << i << "," << j << endl;
}
string r = str1.substr(0,i);
// cout << i << "," << j << endl;
// cout << i << " " << r << endl;
return r;
}
/**
**
**
**/
// string SmithWaterman::concatString () {
// }
// SmithWaterman::~SmithWaterman() {
// }
// extern "C" SmithWaterman* create(string str1, string str2, int match_score) {
// return new SmithWaterman(str1, str2, match_score);
// }
// extern "C" void erase(SmithWaterman* sw) {
// delete sw;
// } | [
"hyilai@outlook.com"
] | hyilai@outlook.com |
58c5a52a71f42ec5b89bc06b80b20c0e93b79f10 | 9c74703c56d3447de1dff009eb570cd494befe81 | /StatsDisplay/src/StatsDisplay.cpp | 52819106f383926759122f30a77de2e05964ab67 | [] | no_license | derlistigelurch/RobotCommander | a915db6129116ad42769da6e2de37b75ff39ec49 | 7bd1fc5d5647f46d166783cbdda6d000d7924c83 | refs/heads/master | 2022-11-21T22:02:54.284072 | 2020-07-29T06:58:34 | 2020-07-29T06:58:34 | 276,303,950 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,353 | cpp | #include <iostream>
#include <fstream>
#include <algorithm>
#include "../../MapDisplay/include/Colors.h"
#include "../../MessageManager/include/ConfigManager.h"
#define ENEMY 'E'
#define DELIMITER ':'
std::string GetValue(std::string &line)
{
int pos = line.find(DELIMITER);
std::string value = line.substr(0, pos);
line.erase(0, pos + 1);
return value;
}
int main()
{
while(true)
{
std::string line;
int pos = 0;
std::ifstream pipe(ConfigManager().statsPipe);
if(!pipe.is_open())
{
std::cerr << "ERROR: Unable to read from pipe" << std::endl << std::flush;
std::exit(EXIT_FAILURE);
}
while(getline(pipe, line))
{
std::cout << CLEAR;
// SYMBOL|E:ID:SYMBOL:NAME:CURRENT_HEALTH:HEALTH:CURRENT_ACTION_POINTS:ACTION_POINTS:DAMAGE:ATTACK_RADIUS:POSITION:DESCRIPTION
line = ConfigManager::RemoveNewLine(line);
if(line == "shutdown")
{
pipe.close();
return EXIT_SUCCESS;
}
char color = line.substr(0, pos = line.find(DELIMITER))[0];
std::string bgColor = BG_BLUE;
line.erase(0, pos + 1);
if(color == ENEMY)
{
bgColor = BG_RED;
}
std::string picture = GetValue(line);
std::replace(picture.begin(), picture.end(), '\t', '\n');
std::cout << ESCAPE << bgColor << SEPARATOR << FG_BLACK << END_ESCAPE << picture << RESET
<< std::flush << std::endl;
std::cout << ESCAPE << bgColor << SEPARATOR << FG_BLACK << END_ESCAPE << "ID:" << RESET << " "
<< GetValue(line) << std::flush << std::endl;
std::cout << ESCAPE << bgColor << SEPARATOR << FG_BLACK << END_ESCAPE << "SYMBOL:" << RESET << " "
<< GetValue(line) << std::flush << std::endl;
std::cout << ESCAPE << bgColor << SEPARATOR << FG_BLACK << END_ESCAPE << "NAME:" << RESET << " "
<< GetValue(line) << std::flush << std::endl;
std::cout << ESCAPE << bgColor << SEPARATOR << FG_BLACK << END_ESCAPE << "HEALTH:" << RESET << " "
<< GetValue(line) << "/" << GetValue(line) << std::flush << std::endl;
std::cout << ESCAPE << bgColor << SEPARATOR << FG_BLACK << END_ESCAPE << "ACTION_POINTS:" << RESET << " "
<< GetValue(line) << "/" << GetValue(line) << std::flush << std::endl;
std::cout << ESCAPE << bgColor << SEPARATOR << FG_BLACK << END_ESCAPE << "DAMAGE:" << RESET << " "
<< GetValue(line) << std::flush << std::endl;
std::cout << ESCAPE << bgColor << SEPARATOR << FG_BLACK << END_ESCAPE << "ATTACK_RADIUS:" << RESET << " "
<< GetValue(line) << std::flush << std::endl;
std::cout << ESCAPE << bgColor << SEPARATOR << FG_BLACK << END_ESCAPE << "POSITION:" << RESET << " "
<< GetValue(line) << std::flush << std::endl;
std::cout << ESCAPE << bgColor << SEPARATOR << FG_BLACK << END_ESCAPE << "DESCRIPTION:" << RESET << " "
<< GetValue(line) << std::flush << std::endl;
}
pipe.close();
}
return EXIT_SUCCESS;
}
| [
"dalistige@gmail.com"
] | dalistige@gmail.com |
4ee07ccf995637f9ef7156699aac8ae28b03bb01 | 6972211c57e6713cabc1871dc2fe9aa36f0f653c | /142-lab7/Main.cpp | d4cde1886d221553311ce2a75141aedf8d39a08e | [] | no_license | jmbarzee/byu-142 | 0dd809632587a408ef543dcc52b52f3d55d866ed | f4c3b9a983d30f4a62d477637262b94360571382 | refs/heads/master | 2021-01-21T06:25:07.012639 | 2017-02-26T18:22:47 | 2017-02-26T18:22:47 | 83,230,646 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,470 | cpp | /*
* Main.cpp
*
* Created on: Mar 9, 2015
* Author: jacobmb
*
* TEST CASE : 1
* commands: 1,6
* TEST CASE : 2
* commands: 1,4,4,4,4,4,4,4,4,4,4,5
* During tournament: 1,1,2,1 3,2,1 2
* TEST CASE : 2
* commands: 1,2
* Adding: "Denny's"
* commands: 3
* Adding: "Wendey's"
* Commands: 5
* During tournament: 1,3,3,1,2,1 3,2,A,1 5,2
*
*/
#include <vector>
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
using namespace std;
int find(vector<string>& list, string name) {
//FIND HERE
for (int i = 0; i < list.size(); i++) {
if (list[i] == name)
return i;
}
return -1;
}
void display(vector<string> list) {
//DISPLAY VECTOR HERE
for (int i = 0; i < list.size(); i++) {
cout << list[i];
if (i < list.size()-1)
cout << ',';
}
cout << endl;
}
void add(vector<string>& list) {
//ADD VECTOR HERE
cout << "Please enter the restaurant you would like to add the list"
<< endl;
string name;
cin.ignore();
getline(cin, name);
int pos = find(list, name);
if (pos == -1) {
list.push_back(name);
cout << name << " has been added to the list" << endl;
} else {
cout << name << " is already in the list" << endl;
}
}
void remove(vector<string>& list) {
//ADD VECTOR HERE
cout << "Please enter the restaurant you would like to add the list"
<< endl;
string name;
cin.ignore();
getline(cin, name);
int pos = find(list, name);
if (pos == -1) {
cout << name << " is not in the list" << endl;\
} else {
list.erase(list.begin() + pos);
cout << name << " has been removed to the list" << endl;
}
}
void shuffle(vector<string>& list) {
//ADD SHUFFLE LIST HERE
string tempName;
for (int i = 0; i < list.size() * 2; i++) {
int pos1 = rand() % list.size();
int pos2 = rand() % list.size();
tempName = list[pos1];
list[pos1] = list[pos2];
list[pos2] = tempName;
}
}
bool tournament(vector<string>& list) {
//ADD TOURNY HERE
int roundT = 1; // starts at 1 to account for the final match
int round = 0;
double i;
for (i = list.size(); i > 2; i/=2) { // this loop both finds the number of rounds and finds if it is a valid tournament
roundT++;
}
if (i != 2) {
return false;
}
//RUN TOURNAMENT
while (list.size() > 1) { // this loop runs every time we need to do a round
round++;
int matchT = list.size() / 2;
for (int match = 0; match < matchT; match++) { // this loop runs every time we need to do a match
cout << "Match " << match + 1 << '/' << matchT << ", Round "
<< round << '/' << roundT;
cout << " --- 1: " << list[match] << " or 2: " << list[match + 1]
<< '?';
char winner;
do {
cin >> winner;
if (winner != '1' && winner != '2')
cout << "Invalid response (" << winner << ")" << endl;
} while (winner != '1' && winner != '2');
if (winner == '1') {
list.erase(list.begin() + match + 1);
} else if (winner == '2') {
list.erase(list.begin() + match);
}
}
}
cout << list[0] << " is the winner!" << endl;
return true;
}
int main() {
srand(time(0));
vector<string> list;
list.push_back("McDondald's");
list.push_back("Little Ceaser's");
list.push_back("Black Sheep Cafe");
list.push_back("Wendey's");
list.push_back("Gloria's Little Italy");
list.push_back("Taco Time");
list.push_back("Big Jud's");
list.push_back("Gringo's");
char command = '_';
do {
if (command == '1') {
cout << " 1 - Display the restaurants" << endl;
display(list);
} else if (command == '2') {
cout << " 2 - Add a restaurants" << endl;
add(list);
} else if (command == '3') {
cout << " 3 - remove a restaurant" << endl;
remove(list);
} else if (command == '4') {
cout << " 4 - shuffle the restaurants" << endl;
shuffle(list);
} else if (command == '5') {
cout << " 5 - begin the tournament" << endl;
if (tournament(list))
break;
cout << "Tournament can't run" << endl;
} else if (command == '6') {
break;
} else {
cout << "Possible commands are:" << endl;
cout << " 1 - Display the restaurants" << endl;
cout << " 2 - Add a restaurants" << endl;
cout << " 3 - remove a restaurant" << endl;
cout << " 4 - shuffle the restaurants" << endl;
cout << " 5 - begin the tournament" << endl;
cout << " 6 - quit" << endl;
}
cout << "please enter a command" << endl;
cin >> command;
} while (command != '6');
cout << " 6 - quit" << endl;
return 0;
}
| [
"jbarzee@qualtrics.com"
] | jbarzee@qualtrics.com |
24680482f0d22295a8d3de9d33a788bd9c59018c | c119fcb4a881ea6aa555faf92b5b33ce42748238 | /corpc/src/proto/corpc_option.pb.cc | a9dba92dc06e078539d4efb6d7c6cd7148a4f31d | [
"Apache-2.0"
] | permissive | ChenwxJay/libcorpc | 7e2aa4a1774542cf683480924f2412d3e98ba83e | a72d8823332545222867647386e560b4342cff97 | refs/heads/master | 2020-06-19T20:32:13.435435 | 2019-02-21T03:28:36 | 2019-02-21T03:28:36 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | true | 9,307 | cc | // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: corpc_option.proto
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
#include "corpc_option.pb.h"
#include <algorithm>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/once.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/wire_format_lite_inl.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
// @@protoc_insertion_point(includes)
namespace corpc {
namespace {
const ::google::protobuf::Descriptor* Void_descriptor_ = NULL;
const ::google::protobuf::internal::GeneratedMessageReflection*
Void_reflection_ = NULL;
} // namespace
void protobuf_AssignDesc_corpc_5foption_2eproto() {
protobuf_AddDesc_corpc_5foption_2eproto();
const ::google::protobuf::FileDescriptor* file =
::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
"corpc_option.proto");
GOOGLE_CHECK(file != NULL);
Void_descriptor_ = file->message_type(0);
static const int Void_offsets_[1] = {
};
Void_reflection_ =
new ::google::protobuf::internal::GeneratedMessageReflection(
Void_descriptor_,
Void::default_instance_,
Void_offsets_,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Void, _has_bits_[0]),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Void, _unknown_fields_),
-1,
::google::protobuf::DescriptorPool::generated_pool(),
::google::protobuf::MessageFactory::generated_factory(),
sizeof(Void));
}
namespace {
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
inline void protobuf_AssignDescriptorsOnce() {
::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
&protobuf_AssignDesc_corpc_5foption_2eproto);
}
void protobuf_RegisterTypes(const ::std::string&) {
protobuf_AssignDescriptorsOnce();
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
Void_descriptor_, &Void::default_instance());
}
} // namespace
void protobuf_ShutdownFile_corpc_5foption_2eproto() {
delete Void::default_instance_;
delete Void_reflection_;
}
void protobuf_AddDesc_corpc_5foption_2eproto() {
static bool already_here = false;
if (already_here) return;
already_here = true;
GOOGLE_PROTOBUF_VERIFY_VERSION;
::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
"\n\022corpc_option.proto\022\005corpc\032 google/prot"
"obuf/descriptor.proto\"\006\n\004Void:;\n\021global_"
"service_id\022\037.google.protobuf.ServiceOpti"
"ons\030\220N \001(\r:7\n\016need_coroutine\022\036.google.pr"
"otobuf.MethodOptions\030\222N \001(\010::\n\021not_care_"
"response\022\036.google.protobuf.MethodOptions"
"\030\223N \001(\010", 247);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"corpc_option.proto", &protobuf_RegisterTypes);
Void::default_instance_ = new Void();
::google::protobuf::internal::ExtensionSet::RegisterExtension(
&::google::protobuf::ServiceOptions::default_instance(),
10000, 13, false, false);
::google::protobuf::internal::ExtensionSet::RegisterExtension(
&::google::protobuf::MethodOptions::default_instance(),
10002, 8, false, false);
::google::protobuf::internal::ExtensionSet::RegisterExtension(
&::google::protobuf::MethodOptions::default_instance(),
10003, 8, false, false);
Void::default_instance_->InitAsDefaultInstance();
::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_corpc_5foption_2eproto);
}
// Force AddDescriptors() to be called at static initialization time.
struct StaticDescriptorInitializer_corpc_5foption_2eproto {
StaticDescriptorInitializer_corpc_5foption_2eproto() {
protobuf_AddDesc_corpc_5foption_2eproto();
}
} static_descriptor_initializer_corpc_5foption_2eproto_;
// ===================================================================
#ifndef _MSC_VER
#endif // !_MSC_VER
Void::Void()
: ::google::protobuf::Message() {
SharedCtor();
// @@protoc_insertion_point(constructor:corpc.Void)
}
void Void::InitAsDefaultInstance() {
}
Void::Void(const Void& from)
: ::google::protobuf::Message() {
SharedCtor();
MergeFrom(from);
// @@protoc_insertion_point(copy_constructor:corpc.Void)
}
void Void::SharedCtor() {
_cached_size_ = 0;
::memset(_has_bits_, 0, sizeof(_has_bits_));
}
Void::~Void() {
// @@protoc_insertion_point(destructor:corpc.Void)
SharedDtor();
}
void Void::SharedDtor() {
if (this != default_instance_) {
}
}
void Void::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* Void::descriptor() {
protobuf_AssignDescriptorsOnce();
return Void_descriptor_;
}
const Void& Void::default_instance() {
if (default_instance_ == NULL) protobuf_AddDesc_corpc_5foption_2eproto();
return *default_instance_;
}
Void* Void::default_instance_ = NULL;
Void* Void::New() const {
return new Void;
}
void Void::Clear() {
::memset(_has_bits_, 0, sizeof(_has_bits_));
mutable_unknown_fields()->Clear();
}
bool Void::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:corpc.Void)
for (;;) {
::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
tag = p.first;
if (!p.second) goto handle_unusual;
handle_unusual:
if (tag == 0 ||
::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
}
success:
// @@protoc_insertion_point(parse_success:corpc.Void)
return true;
failure:
// @@protoc_insertion_point(parse_failure:corpc.Void)
return false;
#undef DO_
}
void Void::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:corpc.Void)
if (!unknown_fields().empty()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:corpc.Void)
}
::google::protobuf::uint8* Void::SerializeWithCachedSizesToArray(
::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:corpc.Void)
if (!unknown_fields().empty()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:corpc.Void)
return target;
}
int Void::ByteSize() const {
int total_size = 0;
if (!unknown_fields().empty()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = total_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void Void::MergeFrom(const ::google::protobuf::Message& from) {
GOOGLE_CHECK_NE(&from, this);
const Void* source =
::google::protobuf::internal::dynamic_cast_if_available<const Void*>(
&from);
if (source == NULL) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
MergeFrom(*source);
}
}
void Void::MergeFrom(const Void& from) {
GOOGLE_CHECK_NE(&from, this);
mutable_unknown_fields()->MergeFrom(from.unknown_fields());
}
void Void::CopyFrom(const ::google::protobuf::Message& from) {
if (&from == this) return;
Clear();
MergeFrom(from);
}
void Void::CopyFrom(const Void& from) {
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool Void::IsInitialized() const {
return true;
}
void Void::Swap(Void* other) {
if (other != this) {
_unknown_fields_.Swap(&other->_unknown_fields_);
std::swap(_cached_size_, other->_cached_size_);
}
}
::google::protobuf::Metadata Void::GetMetadata() const {
protobuf_AssignDescriptorsOnce();
::google::protobuf::Metadata metadata;
metadata.descriptor = Void_descriptor_;
metadata.reflection = Void_reflection_;
return metadata;
}
::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::ServiceOptions,
::google::protobuf::internal::PrimitiveTypeTraits< ::google::protobuf::uint32 >, 13, false >
global_service_id(kGlobalServiceIdFieldNumber, 0u);
::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::MethodOptions,
::google::protobuf::internal::PrimitiveTypeTraits< bool >, 8, false >
need_coroutine(kNeedCoroutineFieldNumber, false);
::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::MethodOptions,
::google::protobuf::internal::PrimitiveTypeTraits< bool >, 8, false >
not_care_response(kNotCareResponseFieldNumber, false);
// @@protoc_insertion_point(namespace_scope)
} // namespace corpc
// @@protoc_insertion_point(global_scope)
| [
"xianke.liu@dena.com"
] | xianke.liu@dena.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.