blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 4 201 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 7 100 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 260
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 11.4k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 17
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 80
values | src_encoding stringclasses 28
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 8 9.86M | extension stringclasses 52
values | content stringlengths 8 9.86M | authors listlengths 1 1 | author stringlengths 0 119 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
d40612bf1016a466601746b07797151a6be1ff6a | 6c73b1090cc2a1cd980a14dfa8a3b15902b65830 | /MainWindow.cpp | 3130f3ef1eceec40651df2892378f4e1b3d7eef2 | [
"MIT"
] | permissive | sfrank90/PADI | 4b27e7f4c696d8ee9b8a5b62940f628922082d18 | 1c3a013f8134a29195a19cba259651ab76f0012f | refs/heads/master | 2016-09-05T20:28:46.710539 | 2015-02-16T14:01:32 | 2015-02-16T14:01:32 | 30,639,039 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 21,001 | cpp | #include "MainWindow.h"
#include "ui_MainWindow.h"
// Qt
#include <QLabel>
#include <QMessageBox>
#include <QFileDialog>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
//setup UI
ui->setupUi(this);
// Create image processing settings dialog
imageProcessingSettingsDialog = new ImageProcessingSettingsDialog(this);
//connect other signals/slots
connect(ui->actionMode, SIGNAL(triggered()),this , SLOT(selectMode()));
connect(ui->actionAddOveralys, SIGNAL(triggered()),this , SLOT(setImageProcessingSettings()));
connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(showAboutDialog()));
connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(close()));
connect(ui->actionDetection, SIGNAL(toggled(bool)), this, SLOT(setDetection(bool)));
//connect recording buttons
connect(ui->recDirButton, SIGNAL(released()), SLOT(setRecDir()));
connect(ui->recVideoButton, SIGNAL(released()), SLOT(recordVideo()));
connect(ui->snapshotButton, SIGNAL(released()), SLOT(takeSnapshot()));
//connect button
connect(ui->modebutton, SIGNAL(released()), SLOT(selectMode()));
connect(ui->overlaybutton, SIGNAL(released()), SLOT(setImageProcessingSettings()));
//disable overlay functions
ui->overlaybutton->setDisabled(true);
ui->actionAddOveralys->setDisabled(true);
//disable snapshot and rec button
ui->snapshotButton->setDisabled(true);
ui->recVideoButton->setDisabled(true);
//init user information
ui->imagelabel->setText("Please select initial mode for the software...");
//initialization of variables
recording = false;
liveViewActive = false;
playbackActive = false;
detection = ui->actionDetection->isChecked();
saveDirectory = "";
this->deviceNumber = 0;
// Initialize ImageProcessingFlags structure
imageProcessingFlags.showDetectionOn=false;
imageProcessingFlags.showOverlaysOn=true;
// label adjustement for images
ui->imagelabel->setAlignment(Qt::AlignCenter);
////////////////////////////////////////////
// Check for necessary cascade files
QFile cascade_face( "./cascade/haarcascade_frontalface_alt.xml" );
QFile cascade_eyes( "./cascade/haarcascade_eye_tree_eyeglasses.xml" );
QFile cascade_nose( "./cascade/haarcascade_mcs_nose.xml" );
QFile cascade_mouth( "./cascade/haarcascade_mcs_mouth.xml" );
if( !cascade_face.exists() || !cascade_eyes.exists() || !cascade_nose.exists() || !cascade_mouth.exists() )
{
// disable all detections due to missing xml files
imageDetection = false;
QMessageBox::warning(this,"WARNING:","Detection was disabled because Haarcascade XML files are missing!");
close();
} else
imageDetection = true;
}
MainWindow::~MainWindow()
{
// destruct all
if(liveViewActive)
disconnectCamera();
if(playbackActive)
stopPlayback();
if(recording)
recordVideo();
if(imageProcessingSettingsDialog != NULL)
delete imageProcessingSettingsDialog;
if(imageHandler != NULL)
delete imageHandler;
delete ui;
}
void MainWindow::selectMode()
{
// Show dialog for mode
CameraConnectDialog *cameraConnectDialog = new CameraConnectDialog(this);
if(cameraConnectDialog->exec()==QDialog::Accepted)
{
// File Dialog
QFileDialog* fd = new QFileDialog;
fd->setDirectory(".");
// store mode (integer) to private variable
mode = cameraConnectDialog->getMode();
if(mode != 1)
{
// first of all stop liveview thread if camera is active
if(liveViewActive)
{
std::cout << "Disconnect camera!" << std::endl;
disconnectCamera();
}
}
if(mode != 1 || mode != 2)
ui->recVideoButton->setDisabled(true);
if(mode != 2)
{
if(playbackActive)
stopPlayback();
}
if(mode != 3)
{
ui->actionDetection->setDisabled(false);
}
switch(mode)
{
case 0:
QMessageBox::warning(this,"ERROR:","No valid mode selected!");
break;
case 1:
ui->imagelabel->setText("Connecting...");
connectToCamera();
break;
case 2:
fd->setNameFilter("Videos (*.avi *.mp4)");
if(fd->exec() == QFileDialog::Accepted)
file = fd->selectedFiles()[0];
//standard file dialog
//file = QFileDialog::getOpenFileName(this, tr("Open File..."),
//QString(), tr("Video files (*.mp4);;All Files (*)"));
if(file.isEmpty())
{
mode = 0;
ui->statusBar->showMessage("Video selection canceled.", 4000);
delete cameraConnectDialog;
return;
}
if(playbackActive)
stopPlayback();
startPlayback(file);
break;
case 3:
fd->setNameFilter("Images (*.jpg)");
if(fd->exec() == QFileDialog::Accepted)
file = fd->selectedFiles()[0];
//standard file dialoag
//file = QFileDialog::getOpenFileName(this, tr("Open File..."),
//QString(), tr("Image files (*.jpg *.jpeg *.png);;All Files (*)"));
if(file.isEmpty())
{
mode = 0;
ui->statusBar->showMessage("Image selection canceled.", 4000);
delete cameraConnectDialog;
return;
}
// call show image
showImage(file);
break;
}
delete fd;
} else
{
mode = 0;
ui->statusBar->showMessage("Mode selection canceled.", 4000);
delete cameraConnectDialog;
return;
}
// Delete dialog
delete cameraConnectDialog;
}
//------------------------------------------------
//------------- liveview functions ---------------
void MainWindow::connectToCamera()
{
// start video thread for live view
if(mode == 1 && !liveViewActive)
{
videoImageBuffer = new VideoImageBuffer();
Buffer<Mat> *imageBuffer = new Buffer<Mat>(1000);
// Add created ImageBuffer to SharedImageBuffer object
videoImageBuffer->add(deviceNumber, imageBuffer);
// Create VideoThread
videoThread = new VideoThread(videoImageBuffer, deviceNumber, true);
if(videoThread->connectToCamera())
{
rec_height = videoThread->getInputSourceHeight();
rec_width = videoThread->getInputSourceWidth();
ui->statusBar->showMessage("Connecting...", 5000);
// Create processing thread
//videoImageBuffer = new VideoImageBuffer();
processingThread = new ProcessingThread(videoImageBuffer, deviceNumber);
// Setup signal/slot connections
connect(processingThread, SIGNAL(newFrame(QPixmap)), this, SLOT(updateFrame(QPixmap)));
connect(imageProcessingSettingsDialog, SIGNAL(newImageProcessingSettings(struct ImageProcessingSettings)), processingThread, SLOT(updateImageProcessingSettings(struct ImageProcessingSettings)));
connect(this, SIGNAL(newImageProcessingFlags(struct ImageProcessingFlags)), processingThread, SLOT(updateImageProcessingFlags(struct ImageProcessingFlags)));
connect(this, SIGNAL(changeDetectionState(bool)), processingThread, SLOT(setFrameProcessing(bool)));
connect(this, SIGNAL(setROI(QRect)), processingThread, SLOT(setROI(QRect)));
connect(this, SIGNAL(setSaveParams(QString, QString)), processingThread, SLOT(setSaveParams(QString, QString)));
connect(this, SIGNAL(setLiveViewSaveImgFlag(bool)), processingThread, SLOT(setSaveImgFlag(bool)));
connect(this, SIGNAL(setRecordFlag(bool)), processingThread, SLOT(setRecFlag(bool)));
// Set initial data in processing thread
emit changeDetectionState(detection);
emit setROI(QRect(0, 0, videoThread->getInputSourceWidth(), videoThread->getInputSourceHeight()));
emit newImageProcessingFlags(imageProcessingFlags);
emit setRecordFlag(false);
imageProcessingSettingsDialog->updateStoredSettingsFromDialog();
// Start capturing frames from camera
videoThread->start();
// Start processing captured frames
processingThread->start();
// Set internal flag
liveViewActive=true;
//enable snapshot button
ui->snapshotButton->setDisabled(false);
//enable overlays
ui->overlaybutton->setDisabled(false);
ui->actionAddOveralys->setDisabled(false);
//enable record video button
ui->recVideoButton->setDisabled(false);
ui->statusBar->showMessage("Connected to Webcam. Mode: LiveView", 4000);
}
else
{
ui->imagelabel->setText("Camera seems to be not available! Check if plugged in...");
ui->statusBar->showMessage("Connecting to camera failed!", 5000);
}
}
}
void MainWindow::disconnectCamera()
{
if(liveViewActive)
{
// Stop processing thread
if(processingThread->isRunning())
stopProcessingThread();
// Stop capture thread
if(videoThread->isRunning())
stopVideoThread();
// Remove from shared buffer
videoImageBuffer->removeByDeviceNumber(deviceNumber);
// Disconnect camera
if(videoThread->disconnectCamera())
ui->statusBar->showMessage("LiveView Camera successfully disconnected.", 4000);
else
ui->statusBar->showMessage("LiveView Camera already disconnected.", 4000);
}
// delete created pointer
if(videoImageBuffer != NULL)
delete videoImageBuffer;
if(processingThread != NULL)
delete processingThread;
if(videoThread != NULL)
delete videoThread;
// set liveView not active
liveViewActive = false;
}
void MainWindow::updateFrame(const QPixmap &frame)
{
//get display label size
int width = ui->imagelabel->width();
int height = ui->imagelabel->height();
// Display frame
ui->imagelabel->setPixmap(frame.scaled(width,height,Qt::KeepAspectRatio));
}
void MainWindow::stopVideoThread()
{
ui->statusBar->showMessage("About to stop capture thread...", 3000);
videoThread->stop();
videoImageBuffer->wakeAll();
// Take one frame off a FULL queue to allow the capture thread to finish
if(videoImageBuffer->getByDeviceNumber(deviceNumber)->isFull())
videoImageBuffer->getByDeviceNumber(deviceNumber)->get();
videoThread->wait();
ui->statusBar->showMessage("Video thread successfully stopped.", 3000);
}
void MainWindow::stopProcessingThread()
{
ui->statusBar->showMessage("About to stop processing thread...", 3000);
processingThread->stop();
videoImageBuffer->wakeAll();
processingThread->wait();
ui->statusBar->showMessage("Processing thread successfully stopped.", 3000);
}
//------------------------------------------------
//------------------------------------------------
//----------- Show Playback Functions ------------
void MainWindow::startPlayback(QString filename)
{
if(mode == 2)
{
ui->statusBar->showMessage("Loading file...", 5000);
// Create playback thread
playbackThread = new PlaybackThread(filename);
// Setup signal/slot connections
connect(playbackThread, SIGNAL(nextFrame(QPixmap)), this, SLOT(updateFrame(QPixmap)));
connect(imageProcessingSettingsDialog, SIGNAL(newImageProcessingSettings(struct ImageProcessingSettings)), playbackThread, SLOT(updateImageProcessingSettings(struct ImageProcessingSettings)));
connect(this, SIGNAL(newImageProcessingFlags(struct ImageProcessingFlags)), playbackThread, SLOT(updateImageProcessingFlags(struct ImageProcessingFlags)));
connect(this, SIGNAL(changeDetectionState(bool)), playbackThread, SLOT(updateDetState(bool)));
emit changeDetectionState(detection);
emit newImageProcessingFlags(imageProcessingFlags);
//load videofile
if(!playbackThread->loadPlayback())
{
ui->statusBar->showMessage("Error loading Videofile!", 4000);
return;
}
// Start playback
playbackThread->start();
// Set internal flag
playbackActive=true;
//enable snapshot button
ui->snapshotButton->setDisabled(false);
//enable overlays
ui->overlaybutton->setDisabled(false);
ui->actionAddOveralys->setDisabled(false);
//enable record video button
//ui->recVideoButton->setDisabled(false);
ui->statusBar->showMessage("Mode: Playback", 4000);
}
}
void MainWindow::stopPlayback()
{
if(playbackActive)
{
if(playbackThread->isRunning())
stopPlaybackThread();
}
// delete created pointer
if(playbackThread != NULL)
delete playbackThread;
std::cout << "Playback thread stopped!" << std::endl;
playbackActive = false;
}
void MainWindow::stopPlaybackThread()
{
ui->statusBar->showMessage("About to stop playback thread...", 3000);
playbackThread->stop();
playbackThread->wait();
ui->statusBar->showMessage("Playback thread successfully stopped.", 3000);
}
//------------------------------------------------
//------------------------------------------------
//----------- Show Image Functions ---------------
void MainWindow::showImage(QString fn)
{
imageHandler = new ImageHandler();
// status information
ui->imagelabel->setText("Loading image from file...");
ui->statusBar->showMessage("Loading image from file...", 4000);
imageProcessingSettings = imageProcessingSettingsDialog->getImgProcSettingsForImg();
imageProcessingFlags = imageProcessingSettingsDialog->ImgProcFlagsForImg();
QPixmap temp_pix = imageHandler->loadImageFromFile(fn, imageProcessingSettings, imageProcessingFlags, imageDetection);
ui->statusBar->showMessage("Image loaded", 4000);
//get display label size
int width = ui->imagelabel->width();
int height = ui->imagelabel->height();
ui->imagelabel->setPixmap(temp_pix.scaled(width,height,Qt::KeepAspectRatio));
//enable snapshot button
ui->snapshotButton->setDisabled(false);
//disable action detection
ui->actionDetection->setDisabled(true);
//enable overlays
ui->overlaybutton->setDisabled(false);
ui->actionAddOveralys->setDisabled(false);
}
void MainWindow::applyChangesOnSingleImage()
{
ui->statusBar->showMessage("Apply changes to image", 4000);
imageProcessingSettings = imageProcessingSettingsDialog->getImgProcSettingsForImg();
imageProcessingFlags = imageProcessingSettingsDialog->ImgProcFlagsForImg();
if(imageDetection)
{
QPixmap img_new = imageHandler->applyChangesToImageProc(imageProcessingSettings, imageProcessingFlags);
//get display label size
int width = ui->imagelabel->width();
int height = ui->imagelabel->height();
ui->imagelabel->setPixmap(img_new.scaled(width,height,Qt::KeepAspectRatio));
}
}
//------------------------------------------------
// Option functions
void MainWindow::showAboutDialog()
{
QMessageBox::about(this, "About", QString("MisterSpex Demo 2014 \nProgrammed for PADI, WS 13/14 @ TU Braunschweig"));
}
void MainWindow::setDetection(bool input)
{
if(input)
this->detection = true;
else
this->detection = false;
emit changeDetectionState(this->detection);
}
//------------------------------------------------
//------ Recording options and functions ---------
void MainWindow::takeSnapshot()
{
bool succ = false;
QInputDialog* inputDialog = new QInputDialog();
inputDialog->setOptions(QInputDialog::NoButtons);
bool ok = false;
QString filename = inputDialog->getText(NULL ,"Snapshot Filename",
"Filename: (without *.jpg ...)", QLineEdit::Normal,
"", &ok);
delete inputDialog;
// return if cancel inputdialog
if(!ok)
{
ui->statusBar->showMessage("Save Snapshot: Canceled!", 5000);
return;
}
if(saveDirectory.isEmpty())
{
saveDirectory = "./output";
QMessageBox::warning(this,"WARNING:",QString("No user directory selected. Default dir (%1/) will be used!").arg(saveDirectory));
if (!QDir(saveDirectory).exists()) {
QDir().mkdir(saveDirectory);
}
}
//static image
if(mode == 3)
{
if(filename.isEmpty())
filename = "Test";
succ = imageHandler->saveImageToFile(filename, saveDirectory);
}
//current image from LiveView
if(mode == 1)
{
if(filename.isEmpty())
filename = "Test";
emit setSaveParams(saveDirectory, filename);
emit setLiveViewSaveImgFlag(true);
succ = true;
}
if(succ)
ui->statusBar->showMessage(QString("Snapshot saved to dir (%1/%2.jpg)").arg(saveDirectory,filename), 5000);
else
ui->statusBar->showMessage("Error while saving snapshot", 5000);
}
void MainWindow::recordVideo()//start at actual frame till hit button again
{
if(!recording)
{
QInputDialog* inputDialog = new QInputDialog();
inputDialog->setOptions(QInputDialog::NoButtons);
bool ok = false;
QString filename = inputDialog->getText(NULL ,"Video Filename",
"Filename: (without *.avi ...)", QLineEdit::Normal,
"", &ok);
delete inputDialog;
// return if cancel inputdialog
if(!ok)
{
ui->statusBar->showMessage("Record Video: Canceled!", 5000);
return;
}
if(filename.isEmpty())
filename = "TestVideo";
if(saveDirectory.isEmpty())
{
saveDirectory = "./output";
QMessageBox::warning(this,"WARNING:",QString("No user directory selected. Default dir (%1/) will be used!").arg(saveDirectory));
if (!QDir(saveDirectory).exists()) {
QDir().mkdir(saveDirectory);
}
}
QString dir = saveDirectory;
// build path and file name to save
if(filename.contains("."))
filename.replace(".","-");
dir.append("/");
dir.append(filename);
dir.append(".avi");
recording = true;
// change button text to "stop recording"
ui->recVideoButton->setText("Stop Rec.");
//disable snapshot button
ui->snapshotButton->setDisabled(true);
//create record thread
recordThread = new RecordVideoThread(dir, rec_height, rec_width);
if(!recordThread->createVideoWriter())
{
recording = false;
ui->recVideoButton->setText("Rec. Video");
//disable snapshot button
ui->snapshotButton->setDisabled(false);
delete recordThread;
ui->statusBar->showMessage("Recording video failed...");
return;
}
qRegisterMetaType< Mat >("Mat");
connect(processingThread, SIGNAL(recFrame(Mat)), recordThread, SLOT(addRecFrame(Mat)));
// send stop rec signal
emit setRecordFlag(true);
ui->statusBar->showMessage(QString("Recording video to dir (%1)").arg(saveDirectory));
} else
{
std::cout << "Stopping record thread" << std::endl;
recording = false;
// send stop rec signal
emit setRecordFlag(false);
// change button text to "Rec. Video"
ui->recVideoButton->setText("Rec. Video");
// enable snapshot button
ui->snapshotButton->setDisabled(false);
//finalize and stop thread
recordThread->stop();
//delete thread
delete recordThread;
ui->statusBar->showMessage("Recording stopped! File saved.", 5000);
}
}
void MainWindow::setRecDir()
{
QFileDialog* dir_select = new QFileDialog;
dir_select->setDirectory(".");
dir_select->setFileMode(QFileDialog::DirectoryOnly);
if(dir_select->exec() == QFileDialog::Accepted)
{
saveDirectory = dir_select->selectedFiles()[0];
ui->statusBar->showMessage(QString("Directory: %1").arg(dir_select->selectedFiles()[0]));
}
delete dir_select;
//standard choose directory
//saveDirectory = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
//"/home",
//QFileDialog::ShowDirsOnly
//| QFileDialog::DontResolveSymlinks);
}
//------------------------------------------------
// Image Processing Settings
void MainWindow::setImageProcessingSettings()
{
// Prompt user:
// If user presses OK button on dialog, update image processing settings
if(imageProcessingSettingsDialog->exec()==QDialog::Accepted)
{
imageProcessingSettingsDialog->updateStoredSettingsFromDialog();
if(mode == 1 || mode == 2)
{
imageProcessingFlags = imageProcessingSettingsDialog->ImgProcFlagsForImg();
emit newImageProcessingFlags(imageProcessingFlags);
}
if(mode == 3)
applyChangesOnSingleImage();
}
// Else, restore dialog state
else
imageProcessingSettingsDialog->updateDialogSettingsFromStored();
}
| [
"sven.frank90@gmail.com"
] | sven.frank90@gmail.com |
d889b989092e2081ad1e189abd17414a3e2992e0 | 6af49b61d29ab34ec0b5bd567a7df0124d0e2971 | /app/src/main/cpp/http/MediaType.cpp | 428fd659c52a110e26d1aa7fefad1af4fdd724a6 | [] | no_license | wengz/OkHttpNative | e9ade604c779144624d8757b91f3a85ce3cdc037 | 708548abe560a142ee7cfd29689f443950c55113 | refs/heads/master | 2020-05-16T04:03:10.116747 | 2019-09-23T10:26:58 | 2019-09-23T10:26:58 | 182,760,220 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,796 | cpp | //
// Created by wengzc on 2019/4/24.
//
#include "MediaType.h"
const string MediaType::TOKEN = "([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)";
const string MediaType::QUOTED = "\"([^\"]*)\"";
const regex MediaType::TYPE_SUBTYPE = regex(string(TOKEN).append("/").append(TOKEN));
const regex MediaType::PARAMETER = regex(
string(";\\s*(?:").append(TOKEN).append("=(?:").append(TOKEN).append("|").append(QUOTED).append("))?")
);
/**
* 返回str表示的MediaType
*/
MediaType MediaType::get(string str) throw (runtime_error){
smatch typeSubtype;
string type;
string subtype;
if (regex_search(str, typeSubtype, TYPE_SUBTYPE)){
type = typeSubtype[1];
subtype = typeSubtype[2];
}else{
throw runtime_error("MediaType 格式不正确");
}
string charset;
smatch parameter;
string::const_iterator iterator_start = str.begin();
string::const_iterator iterator_end = str.end();
while (regex_search(iterator_start, iterator_end, parameter, PARAMETER)){
string name = parameter[1];
string charsetParameter;
if (name.empty() || (name.compare("charset") != 0)){
continue;
}
string token = parameter[2];
if (!token.empty()){
//token为单引号包裹的字符串是非法的,去除单引号
if(token[0] == '\'' && token[token.length()-1] == '\'' && token.length() > 2){
charsetParameter = token.substr(1, token.length()-2);
}else{
charsetParameter = token;
}
}else{
charsetParameter = parameter[3];
}
charset = charsetParameter;
iterator_start = parameter[0].second;
}
return MediaType(str, type, subtype, charset);
}
/**
* 返回str表示的MediaType
*/
MediaType MediaType::parse(string str) {
try{
return get(str);
}catch (...){}
return MediaType();
}
/**
* 返回主要的媒体类型,如 "text", "image", "audio", "video", "application" 等
*/
string MediaType::getType() const {
return type;
}
/**
* 返回特定的子媒体类型,如 "plain" or "png", "mpeg", "mp4" or "xml"
*/
string MediaType::getSubtype() const {
return subtype;
}
/**
* 返回与此媒体类型关联的字符集
*/
string MediaType::getCharset() const {
return charset;
}
/**
* 返回与此媒体类型关联的字符集,若原字符集未指定时返回defaultValue
*/
string MediaType::getCharset(string &defaultValue) const {
if (charset.empty()){
return charset;
}
return defaultValue;
}
MediaType::MediaType(string &mediaType, string &type, string &subtype, string &charset)
:mediaType(mediaType), type(type), subtype(subtype), charset(charset){
}
MediaType::MediaType() {
}
| [
"wengzc@yeah.net"
] | wengzc@yeah.net |
a9f1c8c9e9c06769da05343efa193b1de9532bd9 | a326e253fc86e6aa9fdd4b5657cc0735ee394c8a | /ManagerM/object_e_orden_compra.cpp | 4a8cefc29b5b7f02c0dfc83502be062dc2151e9c | [] | no_license | janfranco27/TheProyect | 9b63df6fa8ca4017e604c8e30b678808fa4014fd | bc8725e15a17228649bbcda047c061ec52129bed | refs/heads/master | 2016-09-06T19:37:42.913805 | 2013-07-05T03:28:00 | 2013-07-05T03:28:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,281 | cpp | #include "object_e_orden_compra.h"
object_e_orden_compra::object_e_orden_compra()
{
//file e_orden_compra
//function construct_0
//w!
}
object_e_orden_compra::object_e_orden_compra(_QSTR pk_orden_compra, _QSTR fk_comprobante, _QSTR fk_transportista, _QSTR fk_proveedor, _QSTR fk_tipo_pago, _QSTR fk_tipo_moneda, _QSTR total, _QSTR igv)
{
//file e_orden_compra
//function construct_1
//w!
md_o_pk_orden_compra = pk_orden_compra;
md_o_fk_comprobante = fk_comprobante;
md_o_fk_transportista = fk_transportista;
md_o_fk_proveedor = fk_proveedor;
md_o_fk_tipo_pago = fk_tipo_pago;
md_o_fk_tipo_moneda = fk_tipo_moneda;
md_o_total = total;
md_o_igv = igv;
}
object_e_orden_compra::object_e_orden_compra(_QSTR fk_comprobante, _QSTR fk_transportista, _QSTR fk_proveedor, _QSTR fk_tipo_pago, _QSTR fk_tipo_moneda, _QSTR total, _QSTR igv)
{
//file e_orden_compra
//function construct_2
//w!
md_o_fk_comprobante = fk_comprobante;
md_o_fk_transportista = fk_transportista;
md_o_fk_proveedor = fk_proveedor;
md_o_fk_tipo_pago = fk_tipo_pago;
md_o_fk_tipo_moneda = fk_tipo_moneda;
md_o_total = total;
md_o_igv = igv;
}
object_e_orden_compra::~object_e_orden_compra()
{
}
void object_e_orden_compra::mf_set_pk_orden_compra(_QSTR pk_orden_compra)
{
//function mf_set_pk_orden_compra
//w!
md_o_pk_orden_compra = pk_orden_compra;
}
void object_e_orden_compra::mf_set_fk_comprobante(_QSTR fk_comprobante)
{
//function mf_set_fk_comprobante
//w!
md_o_fk_comprobante = fk_comprobante;
}
void object_e_orden_compra::mf_set_fk_transportista(_QSTR fk_transportista)
{
//function mf_set_fk_transportista
//w!
md_o_fk_transportista = fk_transportista;
}
void object_e_orden_compra::mf_set_fk_proveedor(_QSTR fk_proveedor)
{
//function mf_set_fk_proveedor
//w!
md_o_fk_proveedor = fk_proveedor;
}
void object_e_orden_compra::mf_set_fk_tipo_pago(_QSTR fk_tipo_pago)
{
//function mf_set_fk_tipo_pago
//w!
md_o_fk_tipo_pago = fk_tipo_pago;
}
void object_e_orden_compra::mf_set_fk_tipo_moneda(_QSTR fk_tipo_moneda)
{
//function mf_set_fk_tipo_moneda
//w!
md_o_fk_tipo_moneda = fk_tipo_moneda;
}
void object_e_orden_compra::mf_set_total(_QSTR total)
{
//function mf_set_total
//w!
md_o_total = total;
}
void object_e_orden_compra::mf_set_igv(_QSTR igv)
{
//function mf_set_igv
//w!
md_o_igv = igv;
}
_QSTR object_e_orden_compra::mf_get_pk_orden_compra()
{
//function mf_get_pk_orden_compra
//w!
return md_o_pk_orden_compra;
}
_QSTR object_e_orden_compra::mf_get_fk_comprobante()
{
//function mf_get_fk_comprobante
//w!
return md_o_fk_comprobante;
}
_QSTR object_e_orden_compra::mf_get_fk_transportista()
{
//function mf_get_fk_transportista
//w!
return md_o_fk_transportista;
}
_QSTR object_e_orden_compra::mf_get_fk_proveedor()
{
//function mf_get_fk_proveedor
//w!
return md_o_fk_proveedor;
}
_QSTR object_e_orden_compra::mf_get_fk_tipo_pago()
{
//function mf_get_fk_tipo_pago
//w!
return md_o_fk_tipo_pago;
}
_QSTR object_e_orden_compra::mf_get_fk_tipo_moneda()
{
//function mf_get_fk_tipo_moneda
//w!
return md_o_fk_tipo_moneda;
}
_QSTR object_e_orden_compra::mf_get_total()
{
//function mf_get_total
//w!
return md_o_total;
}
_QSTR object_e_orden_compra::mf_get_igv()
{
//function mf_get_igv
//w!
return md_o_igv;
}
bool object_e_orden_compra::mf_load(_QSTR pk)
{
//function mf_load
//w!
QSqlQuery query;
query.prepare("SELECT * FROM e_orden_compra WHERE pk_orden_compra = ?");
query.bindValue(0,pk);
query.exec();
if(query.next())
{
md_o_pk_orden_compra = query.value(0).toString();
md_o_fk_comprobante = query.value(1).toString();
md_o_fk_transportista = query.value(2).toString();
md_o_fk_proveedor = query.value(3).toString();
md_o_fk_tipo_pago = query.value(4).toString();
md_o_fk_tipo_moneda = query.value(5).toString();
md_o_total = query.value(6).toString();
md_o_igv = query.value(7).toString();
//state OK
//w!
return true;
}else{
//state FAILED
//w!
return false;
}
}
bool object_e_orden_compra::mf_add()
{
//function mf_add
//w!
QSqlQuery query;
string str_query = "INSERT INTO e_orden_compra(";
if (md_o_pk_orden_compra != "")
str_query += "pk_orden_compra, ";
str_query += "fk_comprobante, ";
str_query += "fk_transportista, ";
str_query += "fk_proveedor, ";
str_query += "fk_tipo_pago, ";
str_query += "fk_tipo_moneda, ";
str_query += "total, ";
str_query += "igv";
str_query += ") VALUES(";
if (md_o_pk_orden_compra!= "")
{
str_query += "?, ";
}
str_query += "?, ";
str_query += "?, ";
str_query += "?, ";
str_query += "?, ";
str_query += "?, ";
str_query += "?, ";
str_query += "?";
str_query += ")";
query.prepare(QString(str_query.c_str()));
int integer = 0;
if (md_o_pk_orden_compra != "")
{
query.bindValue(0, md_o_pk_orden_compra);
integer++;
}
query.bindValue(integer++, md_o_fk_comprobante);
query.bindValue(integer++, md_o_fk_transportista);
query.bindValue(integer++, md_o_fk_proveedor);
query.bindValue(integer++, md_o_fk_tipo_pago);
query.bindValue(integer++, md_o_fk_tipo_moneda);
query.bindValue(integer++, md_o_total);
query.bindValue(integer++, md_o_igv);
if(query.exec())
{
//state OK
//w!
return true;
}else{
//state FAILED
//w!
return false;
}
}
bool object_e_orden_compra::mf_update()
{
//function mf_update
//w!
QSqlQuery query;
query.prepare("UPDATE e_orden_compra SET fk_comprobante = ?, fk_transportista = ?, fk_proveedor = ?, fk_tipo_pago = ?, fk_tipo_moneda = ?, total = ?, igv = ? WHERE pk_orden_compra = ?");
query.bindValue(0, md_o_fk_comprobante);
query.bindValue(1, md_o_fk_transportista);
query.bindValue(2, md_o_fk_proveedor);
query.bindValue(3, md_o_fk_tipo_pago);
query.bindValue(4, md_o_fk_tipo_moneda);
query.bindValue(5, md_o_total);
query.bindValue(6, md_o_igv);
query.bindValue(7, md_o_pk_orden_compra);
if(query.exec())
{
//state OK
//w!
return true;
}else{
//state FAILED
//w!
return false;
}
}
bool object_e_orden_compra::mf_remove()
{
//function mf_remove
//w!
QSqlQuery query;
query.prepare("DELETE e_orden_compra FROM pk_orden_compra = ?");
query.bindValue(0, md_o_pk_orden_compra);
if(query.exec())
{
//state OK
//w!
return true;
}else{
//state FAILED
//w!
return false;
}
}
| [
"Lordalex27@gmail.com"
] | Lordalex27@gmail.com |
819977732d4d248a2b8b88f665b9fde837ec3d43 | e537ccf5cec931491ab74bec6eda6603cd3db173 | /easyOffice/logindialog.h | e56644d76d3e56d7537bb04e86cde4a8211bd2c1 | [] | no_license | H-K-ai/Qt-4.7.4 | 47b8f5e84a96a1448c78f690b63453f296d67561 | b5f857e75799e711e48bda1e29e023c17557cfe6 | refs/heads/master | 2021-05-28T07:22:34.300373 | 2015-03-02T19:10:15 | 2015-03-02T19:10:15 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 527 | h | #ifndef LOGINDIALOG_H
#define LOGINDIALOG_H
#include <QDialog>
#include "myFunc.h"
#include "wardrobewindow.h"
#include "staffdialog.h"
namespace Ui {
class loginDialog;
}
class loginDialog : public QDialog
{
Q_OBJECT
public:
explicit loginDialog(QWidget *parent = 0);
~loginDialog();
private slots:
void loginShow();
void on_loginBut_clicked();
void on_cancelBut_clicked();
private:
Ui::loginDialog *ui;
wardrobeWindow wardrobew;
staffDialog staffw;
};
#endif // LOGINDIALOG_H
| [
"llwslc@gmail.com"
] | llwslc@gmail.com |
21842da776f8a8ae57f8ef09fdb3902e97cd0862 | 2c43423a1d2fd27a882f4daa372b11c705308f57 | /Chapter5/Source/Recipe1/Recipe9/Game.cpp | aabb9c5322260f7bc558fdd952dd6a5565c7a793 | [
"MIT"
] | permissive | PacktPublishing/CPP-Game-Development-Cookbook | 3cb93dc88643efea3dc9488b68545e51e7b0237e | 207d3fe4d12d5fccc560be12744d451db44bf52e | refs/heads/master | 2022-11-05T15:55:53.911384 | 2022-10-28T09:22:50 | 2022-10-28T09:22:50 | 60,015,783 | 42 | 22 | null | null | null | null | UTF-8 | C++ | false | false | 1,904 | cpp | // Library Includes
// Local Includes
#include "Clock.h"
#include "Level.h"
#include "BackBuffer.h"
#include "Utilities.h"
// This Include
#include "Game.h"
// Static Variables
CGame* CGame::s_pGame = 0;
// Static Function Prototypes
// Implementation
CGame::CGame()
: m_pLevel(0)
, m_pClock(0)
, m_hApplicationInstance(0)
, m_hMainWindow(0)
, m_pBackBuffer(0)
{
}
CGame::~CGame()
{
delete m_pLevel;
m_pLevel = 0;
delete m_pBackBuffer;
m_pBackBuffer = 0;
delete m_pClock;
m_pClock = 0;
}
bool
CGame::Initialise(HINSTANCE _hInstance, HWND _hWnd, int _iWidth, int _iHeight)
{
m_hApplicationInstance = _hInstance;
m_hMainWindow = _hWnd;
m_pClock = new CClock();
VALIDATE(m_pClock->Initialise());
m_pClock->Process();
m_pBackBuffer = new CBackBuffer();
VALIDATE(m_pBackBuffer->Initialise(_hWnd, _iWidth, _iHeight));
m_pLevel = new CLevel();
VALIDATE(m_pLevel->Initialise(_iWidth, _iHeight));
ShowCursor(false);
return (true);
}
void
CGame::Draw()
{
m_pBackBuffer->Clear();
m_pLevel->Draw();
m_pBackBuffer->Present();
}
void
CGame::Process(float _fDeltaTick)
{
m_pLevel->Process(_fDeltaTick);
}
void
CGame::ExecuteOneFrame()
{
float fDT = m_pClock->GetDeltaTick();
Process(fDT);
Draw();
m_pClock->Process();
Sleep(1);
}
CGame&
CGame::GetInstance()
{
if (s_pGame == 0)
{
s_pGame = new CGame();
}
return (*s_pGame);
}
void
CGame::GameOverWon()
{
MessageBox(m_hMainWindow, L"Winner!", L"Game Over", MB_OK);
PostQuitMessage(0);
}
void
CGame::GameOverLost()
{
MessageBox(m_hMainWindow, "Loser!", "Game Over", MB_OK);
PostQuitMessage(0);
}
void
CGame::DestroyInstance()
{
delete s_pGame;
s_pGame = 0;
}
CBackBuffer*
CGame::GetBackBuffer()
{
return (m_pBackBuffer);
}
CLevel*
CGame::GetLevel()
{
return (m_pLevel);
}
HINSTANCE
CGame::GetAppInstance()
{
return (m_hApplicationInstance);
}
HWND
CGame::GetWindow()
{
return (m_hMainWindow);
}
| [
"anushreet@packtpub.net"
] | anushreet@packtpub.net |
fa1a7f2956d57d343979a4d0fdf56ed9120122b5 | 3be9511fe82d24bb9368b5456ce5a8d0f46c47b7 | /engine/scene/Layer.hpp | 03b18bc84f134b8c65f228063df86cb043b1eb08 | [
"LicenseRef-scancode-public-domain",
"Unlicense"
] | permissive | Guangehhhh/ouzel | d49b633a801b0b7fab92ffa1fb2c82062b65eb91 | 0cc159a812d1690a1e6457876bf70cd23a4b609f | refs/heads/master | 2023-09-02T16:54:11.905359 | 2021-11-09T06:33:18 | 2021-11-09T06:33:18 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,667 | hpp | // Ouzel by Elviss Strazdins
#ifndef OUZEL_SCENE_LAYER_HPP
#define OUZEL_SCENE_LAYER_HPP
#include <cstdint>
#include <vector>
#include "../scene/Actor.hpp"
#include "../math/Vector.hpp"
namespace ouzel::scene
{
class Scene;
class Camera;
class Light;
class Layer: public ActorContainer
{
friend Scene;
friend Camera;
friend Light;
public:
using Order = std::int32_t;
Layer();
~Layer() override;
virtual void draw();
void addChild(Actor& actor) override;
auto& getCameras() const noexcept { return cameras; }
std::pair<Actor*, math::Vector<float, 3>> pickActor(const math::Vector<float, 2>& position, bool renderTargets = false) const;
std::vector<std::pair<Actor*, math::Vector<float, 3>>> pickActors(const math::Vector<float, 2>& position, bool renderTargets = false) const;
std::vector<Actor*> pickActors(const std::vector<math::Vector<float, 2>>& edges, bool renderTargets = false) const;
[[nodiscard]] auto getOrder() const noexcept { return order; }
void setOrder(Order newOrder);
[[nodiscard]] auto getScene() const noexcept { return scene; }
void removeFromScene();
protected:
void addCamera(Camera& camera);
void removeCamera(Camera& camera);
void addLight(Light& light);
void removeLight(Light& light);
virtual void recalculateProjection();
void enter() override;
Scene* scene = nullptr;
std::vector<Camera*> cameras;
std::vector<Light*> lights;
Order order = 0;
};
}
#endif // OUZEL_SCENE_LAYER_HPP
| [
"elviss@elviss.lv"
] | elviss@elviss.lv |
fc6656f29a5bd02a6920b826e9b2b00c8244c304 | 37c243e2f0aab70cbf38013d1d91bfc3a83f7972 | /pp7TeV/RecoHI/HiTracking/src/HICaloCompatibleTrackSelector.cc | da84cf944d76f601a507a311677a04eacd11bb9d | [] | no_license | maoyx/CMSWork | 82f37256833cbe4c60cb8df0b4eb68ceb12b65e7 | 501456f3f3e0f11e2f628b40e4d91e29668766d5 | refs/heads/master | 2021-01-01T18:47:55.157534 | 2015-03-12T03:47:15 | 2015-03-12T03:47:15 | 10,951,799 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,055 | cc | /*
Based on analytical track selector
- This track selector assigns a quality bit to tracks deemed compatible with matching calo info
- The default mode is to use the matching provided by particle flow,
but a delta R matching to calorimeter towers is also supported
- No selection is done other then selecting calo-compatible tracks.
- The code always keeps all tracks in the input collection (should make configurable)
- Note that matching by PF candidate only works on the same track collection used as input to PF
- Tower code not up to data
Authors: Matthew Nguyen, Andre Yoon, Frank Ma (November 4th, 2011)
*/
// Basic inclusion
#include "RecoHI/HiTracking/interface/HICaloCompatibleTrackSelector.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "DataFormats/ParticleFlowReco/interface/PFBlock.h"
#include "DataFormats/ParticleFlowReco/interface/PFCluster.h"
#include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h"
#include "DataFormats/RecoCandidate/interface/TrackAssociation.h"
#include "SimTracker/Records/interface/TrackAssociatorRecord.h"
#include "SimTracker/TrackAssociation/interface/TrackAssociatorByHits.h"
#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticleFwd.h"
#include "DataFormats/CaloTowers/interface/CaloTower.h"
#include "DataFormats/CaloTowers/interface/CaloTowerFwd.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "DataFormats/Math/interface/deltaR.h"
#include <Math/DistFunc.h>
#include "TMath.h"
using reco::modules::HICaloCompatibleTrackSelector;
HICaloCompatibleTrackSelector::HICaloCompatibleTrackSelector( const edm::ParameterSet & cfg ) :
srcTracks_(cfg.getParameter<edm::InputTag>("srcTracks")),
srcPFCands_(cfg.getParameter<edm::InputTag>("srcPFCands")),
srcTower_(cfg.getParameter<edm::InputTag>("srcTower")),
usePFCandMatching_(cfg.getUntrackedParameter<bool>("usePFCandMatching", true)),
trkMatchPtMin_(cfg.getUntrackedParameter<double>("trkMatchPtMin",10.0)),
trkCompPtMin_(cfg.getUntrackedParameter<double>("trkCompPtMin",35.0)),
trkEtaMax_(cfg.getUntrackedParameter<double>("trkEtaMax",2.4)),
towerPtMin_(cfg.getUntrackedParameter<double>("towerPtMin",5.0)),
matchConeRadius_(cfg.getUntrackedParameter<double>("matchConeRadius",0.087)),
keepAllTracks_(cfg.getUntrackedParameter<bool>("keepAllTracks", true)),
copyExtras_(cfg.getUntrackedParameter<bool>("copyExtras", true)),
copyTrajectories_(cfg.getUntrackedParameter<bool>("copyTrajectories", true)),
qualityToSet_(cfg.getParameter<std::string>("qualityToSet")),
qualityToSkip_(cfg.getParameter<std::string>("qualityToSkip")),
qualityToMatch_(cfg.getParameter<std::string>("qualityToMatch")),
minimumQuality_(cfg.getParameter<std::string>("minimumQuality")),
resetQuality_(cfg.getUntrackedParameter<bool>("resetQuality", true)),
passMuons_(cfg.getUntrackedParameter<bool>("passMuons", true)),
passElectrons_(cfg.getUntrackedParameter<bool>("passElectrons", false)),
funcDeltaRTowerMatch_(cfg.getParameter<std::string>("funcDeltaRTowerMatch")),
funcCaloComp_(cfg.getParameter<std::string>("funcCaloComp"))
{
copyExtras_= false;
std::string alias( cfg.getParameter<std::string>( "@module_label" ) );
produces<reco::TrackCollection>().setBranchAlias( alias + "Tracks");
if (copyExtras_) {
produces<reco::TrackExtraCollection>().setBranchAlias( alias + "TrackExtras");
produces<TrackingRecHitCollection>().setBranchAlias( alias + "RecHits");
}
if (copyTrajectories_) {
produces< std::vector<Trajectory> >().setBranchAlias( alias + "Trajectories");
produces< TrajTrackAssociationCollection >().setBranchAlias( alias + "TrajectoryTrackAssociations");
}
// pt dependence of delta R matching requirement
fDeltaRTowerMatch = new TF1("fDeltaRTowerMatch",funcDeltaRTowerMatch_.c_str(),0,200);
// pt dependance of calo compatibility, i.e., minimum sum Calo Et vs. track pT
fCaloComp = new TF1("fCaloComp",funcCaloComp_.c_str(),0,200); // a parameterization of pt dependent cut
}
HICaloCompatibleTrackSelector::~HICaloCompatibleTrackSelector() {
}
void HICaloCompatibleTrackSelector::produce( edm::Event& evt, const edm::EventSetup& es )
{
using namespace std;
using namespace edm;
using namespace reco;
LogDebug("HICaloCompatibleTrackSelector")<<"min pt for selection = "<< trkMatchPtMin_<<endl;
Handle<TrackCollection> hSrcTrack;
Handle< vector<Trajectory> > hTraj;
Handle< vector<Trajectory> > hTrajP;
Handle< TrajTrackAssociationCollection > hTTAss;
evt.getByLabel(srcTracks_,hSrcTrack);
selTracks_ = auto_ptr<TrackCollection>(new TrackCollection());
rTracks_ = evt.getRefBeforePut<TrackCollection>();
if (copyExtras_) {
selTrackExtras_ = auto_ptr<TrackExtraCollection>(new TrackExtraCollection());
selHits_ = auto_ptr<TrackingRecHitCollection>(new TrackingRecHitCollection());
rHits_ = evt.getRefBeforePut<TrackingRecHitCollection>();
rTrackExtras_ = evt.getRefBeforePut<TrackExtraCollection>();
}
if (copyTrajectories_) trackRefs_.resize(hSrcTrack->size());
Handle<PFCandidateCollection> pfCandidates;
Handle<CaloTowerCollection> towers;
bool isPFThere = false;
bool isTowerThere = false;
if(usePFCandMatching_) isPFThere = evt.getByLabel(srcPFCands_, pfCandidates);
else isTowerThere = evt.getByLabel(srcTower_, towers);
size_t current = 0;
for (TI ti = hSrcTrack->begin(), ed = hSrcTrack->end(); ti != ed; ++ti, ++current) {
const reco::Track& trk = *ti;
bool isSelected;
if(usePFCandMatching_) isSelected = selectByPFCands(ti, hSrcTrack, pfCandidates, isPFThere);
else isSelected = selectByTowers(ti, hSrcTrack, towers, isTowerThere);
if(!keepAllTracks_ && !isSelected) continue;
// Add all tracks to output collection, the rest of the code only sets the quality bit
selTracks_->push_back( reco::Track( trk ) ); // clone and store
if(isSelected) selTracks_->back().setQuality(reco::TrackBase::qualityByName(qualityToSet_.c_str()));
if (copyExtras_) {
// TrackExtras
selTrackExtras_->push_back( TrackExtra( trk.outerPosition(), trk.outerMomentum(), trk.outerOk(),
trk.innerPosition(), trk.innerMomentum(), trk.innerOk(),
trk.outerStateCovariance(), trk.outerDetId(),
trk.innerStateCovariance(), trk.innerDetId(),
trk.seedDirection(), trk.seedRef() ) );
selTracks_->back().setExtra( TrackExtraRef( rTrackExtras_, selTrackExtras_->size() - 1) );
TrackExtra & tx = selTrackExtras_->back();
tx.setResiduals(trk.residuals());
// TrackingRecHits
for( trackingRecHit_iterator hit = trk.recHitsBegin(); hit != trk.recHitsEnd(); ++ hit ) {
selHits_->push_back( (*hit)->clone() );
tx.add( TrackingRecHitRef( rHits_, selHits_->size() - 1) );
}
}
if (copyTrajectories_) {
trackRefs_[current] = TrackRef(rTracks_, selTracks_->size() - 1);
}
} // close track loop
if ( copyTrajectories_ ) {
Handle< vector<Trajectory> > hTraj;
Handle< TrajTrackAssociationCollection > hTTAss;
evt.getByLabel(srcTracks_, hTTAss);
evt.getByLabel(srcTracks_, hTraj);
selTrajs_ = auto_ptr< vector<Trajectory> >(new vector<Trajectory>());
rTrajectories_ = evt.getRefBeforePut< vector<Trajectory> >();
selTTAss_ = auto_ptr< TrajTrackAssociationCollection >(new TrajTrackAssociationCollection());
for (size_t i = 0, n = hTraj->size(); i < n; ++i) {
Ref< vector<Trajectory> > trajRef(hTraj, i);
TrajTrackAssociationCollection::const_iterator match = hTTAss->find(trajRef);
if (match != hTTAss->end()) {
const Ref<TrackCollection> &trkRef = match->val;
short oldKey = static_cast<short>(trkRef.key());
if (trackRefs_[oldKey].isNonnull()) {
selTrajs_->push_back( Trajectory(*trajRef) );
selTTAss_->insert ( Ref< vector<Trajectory> >(rTrajectories_, selTrajs_->size() - 1), trackRefs_[oldKey] );
}
}
}
}
static const string emptyString;
evt.put(selTracks_);
if (copyExtras_ ) {
evt.put(selTrackExtras_);
evt.put(selHits_);
}
if ( copyTrajectories_ ) {
evt.put(selTrajs_);
evt.put(selTTAss_);
}
}
bool
HICaloCompatibleTrackSelector::selectByPFCands(TI ti, edm::Handle<TrackCollection> hSrcTrack, edm::Handle<PFCandidateCollection> pfCandidates, bool isPFThere)
{
const reco::Track& trk = *ti;
// If it passes this quality threshold or is under the minimum match pT, automatically save it
if(trk.quality(reco::TrackBase::qualityByName(qualityToSkip_))){
return true;
}
else if(!trk.quality(reco::TrackBase::qualityByName(minimumQuality_))){
return false;
}
else
{
double trkPt = trk.pt();
//if(trkPt < trkMatchPtMin_ ) return false;
double caloEt = 0.0;
if(usePFCandMatching_){
if(isPFThere){
unsigned int trackKey = ti - hSrcTrack->begin();
caloEt = matchPFCandToTrack(pfCandidates, trackKey, trkPt);
}
}
// Set quality bit based on calo matching
if(!(caloEt>0.)) return false;
if(trkPt<=trkCompPtMin_){
if(trk.quality(reco::TrackBase::qualityByName(qualityToMatch_))) return true;
else return false;
}
else{
// loose cuts are implied in selectors, make configurable?
float compPt = (fCaloComp->Eval(trkPt)!=fCaloComp->Eval(trkPt)) ? 0 : fCaloComp->Eval(trkPt); // protect agains NaN
if(caloEt>compPt) return true;
else return false;
}
} // else above trkMatchPtMin_
throw cms::Exception("Undefined case in HICaloCompatibleTrackSelector") << "Undefined case in HICaloCompatibleTrackSelector";
}
bool
HICaloCompatibleTrackSelector::selectByTowers(TI ti, edm::Handle<TrackCollection> hSrcTrack, edm::Handle<CaloTowerCollection> towers, bool isTowerThere)
{
// Not up to date! use PF towers instead
const reco::Track& trk = *ti;
// If it passes the high purity cuts, then consider it confirmed
if(trk.quality(reco::TrackBase::qualityByName(qualityToSkip_))){
return true;
}
else{
if(trk.pt() < trkMatchPtMin_ || !trk.quality(reco::TrackBase::qualityByName(qualityToMatch_))) return false;
double caloEt = 0.0;
if(isTowerThere){
double matchDr;
matchByDrAllowReuse(trk,towers,matchDr,caloEt);
float matchConeRadius_pt = (fDeltaRTowerMatch->Eval(trk.pt())!=fDeltaRTowerMatch->Eval(trk.pt())) ? 0 : fDeltaRTowerMatch->Eval(trk.pt()); // protect agains NaN
if (caloEt>0 && matchDr>matchConeRadius_pt) caloEt=0.;
}
if(trk.pt()<trkCompPtMin_||caloEt>0.75*(trk.pt()-trkCompPtMin_)) return true;
else return false;
}
}
double
HICaloCompatibleTrackSelector::matchPFCandToTrack( const edm::Handle<reco::PFCandidateCollection> & pfCandidates, unsigned it, double trkPt)
{
// This function returns the sum of the calo energy in the block containing the track
// There is another piece of information which could be useful which is the pT assigned to the charged hadron by PF
double sum_ecal=0.0, sum_hcal=0.0;
int candType = 0;
reco::PFCandidate matchedCand;
// loop over the PFCandidates until you find the one whose trackRef points to the track
for( CI ci = pfCandidates->begin(); ci!=pfCandidates->end(); ++ci) {
const reco::PFCandidate& cand = *ci;
int type = cand.particleId();
// only charged hadrons and leptons can be asscociated with a track
if(!(type == PFCandidate::h || //type1
type == PFCandidate::e || //type2
type == PFCandidate::mu //type3
)
) continue;
unsigned candTrackRefKey = cand.trackRef().key();
if(it==candTrackRefKey) {
matchedCand = cand;
candType = type;
break;
}
}
// take all muons as compatible, extend to electrons when validataed
if(passMuons_ && candType==3) return 9999.;
if(passElectrons_ && candType==2) return 9999.;
if(trkPt < trkMatchPtMin_ ) return 0.;
if(candType>0){
// Now that we found the matched PF candidate, loop over the elements in the block summing the calo Et
for(unsigned ib=0; ib<matchedCand.elementsInBlocks().size(); ib++) {
PFBlockRef blockRef = matchedCand.elementsInBlocks()[ib].first;
unsigned indexInBlock = matchedCand.elementsInBlocks()[ib].second;
const edm::OwnVector< reco::PFBlockElement>& elements = (*blockRef).elements();
//This tells you what type of element it is:
//cout<<" block type"<<elements[indexInBlock].type()<<endl;
switch (elements[indexInBlock].type()) {
case PFBlockElement::ECAL: {
reco::PFClusterRef clusterRef = elements[indexInBlock].clusterRef();
sum_ecal += clusterRef->energy()/cosh(clusterRef->eta());
break;
}
case PFBlockElement::HCAL: {
reco::PFClusterRef clusterRef = elements[indexInBlock].clusterRef();
sum_hcal += clusterRef->energy()/cosh(clusterRef->eta());
break;
}
case PFBlockElement::TRACK: {
//Do nothing since track are not normally linked to other tracks
break;
}
default:
break;
}
// We could also add in the PS, HO, ..
} // end of elementsInBlocks()
} // end of isCandFound
return sum_ecal+sum_hcal;
}
void HICaloCompatibleTrackSelector::matchByDrAllowReuse(const reco::Track & trk, const edm::Handle<CaloTowerCollection> & towers, double & bestdr, double & bestpt)
{
// loop over towers
bestdr=1e10;
bestpt=0.;
for(unsigned int i = 0; i < towers->size(); ++i){
const CaloTower & tower= (*towers)[i];
double pt = tower.pt();
if (pt<towerPtMin_) continue;
if (fabs(tower.eta())>trkEtaMax_) continue;
double dr = reco::deltaR(tower,trk);
if (dr<bestdr) {
bestdr = dr;
bestpt = pt;
}
}
}
| [
"yaxian.mao@cern.ch"
] | yaxian.mao@cern.ch |
93a68383b134931be17fa509b75d5f84a9778325 | 38c10c01007624cd2056884f25e0d6ab85442194 | /mandoline/app/desktop/main.cc | a1e26aa7eb8ad538dbe82106134648eb33b8096d | [
"BSD-3-Clause"
] | permissive | zenoalbisser/chromium | 6ecf37b6c030c84f1b26282bc4ef95769c62a9b2 | e71f21b9b4b9b839f5093301974a45545dad2691 | refs/heads/master | 2022-12-25T14:23:18.568575 | 2016-07-14T21:49:52 | 2016-07-23T08:02:51 | 63,980,627 | 0 | 2 | BSD-3-Clause | 2022-12-12T12:43:41 | 2016-07-22T20:14:04 | null | UTF-8 | C++ | false | false | 813 | cc | // Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/at_exit.h"
#include "base/command_line.h"
#include "mandoline/app/desktop/launcher_process.h"
#include "mojo/runner/child_process.h"
#include "mojo/runner/init.h"
#include "mojo/runner/switches.h"
int main(int argc, char** argv) {
base::CommandLine::Init(argc, argv);
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
base::AtExitManager at_exit;
mojo::runner::InitializeLogging();
mojo::runner::WaitForDebuggerIfNecessary();
if (command_line.HasSwitch(switches::kChildProcess))
return mojo::runner::ChildProcessMain();
return mandoline::LauncherProcessMain(argc, argv);
}
| [
"zeno.albisser@hemispherian.com"
] | zeno.albisser@hemispherian.com |
b521987112b5859bdee8e1b9bc55767da866f68d | 3741cd26aed3f3de018c18d094ef5aafaac732a9 | /Task2/tsk2_real.h | 8390479dc912721dbf28fbf5dbe0152c751130aa | [] | no_license | cheremnov/Parallel_Computing_CMC_2020 | b12a3810c7ac014356f8f5892aeeeae08bd91e0b | 3003f71863032ffd4100e88e0ab4ad3c37f191cc | refs/heads/master | 2023-01-22T06:13:16.677830 | 2020-11-23T13:20:47 | 2020-11-23T13:20:47 | 297,119,552 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,992 | h | #ifndef REAL_H
#define REAL_H
#include <map>
#include <vector>
/**
* A class that stores information about the program environment
*/
class ProgramEnv{
private:
// Is a debug print enabled
bool debug_print_;
// A number of processes
int process_num_;
// A current process
int process_rank_;
// Convertation of node array from local to global and vice versa
std::map<int,int> local_to_global_;
std::map<int,int> global_to_local_;
// Which processor holds the vertex
std::vector<int> parts_;
// The block parameters
size_t start_row_idx_;
size_t end_row_idx_;
size_t start_column_idx_;
size_t end_column_idx_;
public:
void setDebugPrint( bool debug_print){
debug_print_ = debug_print;
}
bool isDebugPrint(){
return debug_print_;
}
void setProcessNum( int process_num){
process_num_ = process_num;
}
int getProcessNum(){
return process_num_;
}
void setProcessRank( int process_rank){
process_rank_ = process_rank;
}
int getProcessRank(){
return process_rank_;
}
void setBlockParams( size_t start_row_idx, size_t end_row_idx,
size_t start_column_idx, size_t end_column_idx){
start_row_idx_ = start_row_idx;
start_column_idx_ = start_column_idx;
end_row_idx_ = end_row_idx;
end_column_idx_ = end_column_idx;
}
size_t getStartRow(){
return start_row_idx_;
}
size_t getEndRow(){
return end_row_idx_;
}
size_t getStartColumn(){
return start_column_idx_;
}
size_t getEndColumn(){
return end_column_idx_;
}
std::map<int, int>& getGlobalToLocal(){
return global_to_local_;
}
std::map<int, int>& getLocalToGlobal(){
return local_to_global_;
}
std::vector<int>& getParts(){
return parts_;
}
ProgramEnv(): debug_print_( false), process_num_(1), process_rank_(0) {}
};
#endif
| [
"32135863+cheremnov@users.noreply.github.com"
] | 32135863+cheremnov@users.noreply.github.com |
1934b86ff28432027c9f35d9e47927289f56ef2b | dd7151503d5d6d3a965b231789e887dfeefc9762 | /sifsim/cmdarg.cpp | cb112dc93194920430e7f25d6b0ee6c78cf0e8b4 | [
"MIT"
] | permissive | statementreply/SIFSimulator | a85ffbdd52f87cb82237b873b95fd8defd6fcf05 | de9efc0c07d1532156a20f66eb47a4ff1f6c7b28 | refs/heads/master | 2021-05-06T16:28:18.076423 | 2018-01-07T09:15:55 | 2018-01-07T09:15:55 | 113,740,195 | 7 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,715 | cpp | #include "cmdarg.h"
#include "util.h"
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <limits>
#include <cassert>
using namespace std;
CmdArg g_cmdArg;
void printUsage() {
cout << R"(Usage: sifsim [OPTION]... [FILE]
Run LLSIF live score simulation.
With no FILE, or when FILE is -, read standard input.
-n, --iters=NUM run NUM simulations [default: )" MACRO_STRING(SIFSIM_DEFAULT_ITERS) R"(]
-s, --seed=NUM set random seed to NUM
--skip-iters=NUM skip NUM iterations before simulation
--threads=NUM run in NUM theards [default: 0 (auto)]
-h, --help display this help and exit
)";
}
class ErrNoGuard {
public:
ErrNoGuard() { old = errno; }
ErrNoGuard(const ErrNoGuard &) = delete;
ErrNoGuard & operator=(const ErrNoGuard &) = delete;
~ErrNoGuard() { errno = old; }
private:
int old;
};
optional<int> strtoi(const char * str, int radix = 10) {
ErrNoGuard _e;
char * pend;
auto i = strtol(str, &pend, radix);
if (pend == str) return nullopt;
if (errno == ERANGE) return nullopt;
if (*pend) return nullopt;
if (i < numeric_limits<int>::min()) return nullopt;
if (i > numeric_limits<int>::max()) return nullopt;
return static_cast<int>(i);
}
optional<uint64_t> strtou64(const char * str, int radix = 10) {
ErrNoGuard _e;
char * pend;
auto u = strtoull(str, &pend, radix);
static_assert(numeric_limits<decltype(u)>::max() >= numeric_limits<uint64_t>::max(),
"u should be larger than uint64_t");
if (pend == str) return nullopt;
if (errno == ERANGE) return nullopt;
if (*pend) return nullopt;
if (u > numeric_limits<uint64_t>::max()) return nullopt;
return static_cast<uint64_t>(u);
}
bool parseCmdArg(CmdArg & cmdArg, int argc, char * argv[]) {
const auto locateArg = [argv](bool isLongOpt, char * parg, int &i) {
if (isLongOpt) {
char * pos = strchr(parg, '=');
if (pos) {
*pos++ = '\0';
} else {
pos = argv[++i];
}
return pos;
} else {
return parg[1] ? parg + 1 : argv[++i];
}
};
bool acceptOpt = true;
for (int i = 1; i < argc; i++) {
char * parg = argv[i];
if (!(acceptOpt && parg[0] == '-' && parg[1] != '\0')) {
cmdArg.argumunts.emplace_back(parg);
continue;
}
++parg;
const char * pval;
bool isLongOpt = false;
bool haveArg = false;
_shortOpt:
switch (*parg) {
case '\0':
continue;
case '-':
isLongOpt = true;
++parg;
goto _longOpt;
case 'h':
case '?':
goto _help;
case 'n':
goto _iters;
case 's':
goto _seed;
default:
goto _badOpt;
}
assert(false);
throw logic_error("Bug detected. Please contact software developer.\n (" FILE_LOC ")");
_longOpt:
if (*parg == '\0') {
acceptOpt = false;
continue;
} else if (strcmp(parg, "help") == 0) {
_help:
cmdArg.help = true;
} else if (strcmp(parg, "iters") == 0) {
_iters:
haveArg = true;
pval = locateArg(isLongOpt, parg, i);
if (!pval) goto _noArg;
auto n = strtoi(pval);
if (!n || *n <= 0) goto _badArg;
cmdArg.iters = *n;
} else if (strcmp(parg, "seed") == 0) {
_seed:
haveArg = true;
pval = locateArg(isLongOpt, parg, i);
if (!pval) goto _noArg;
auto u = strtou64(pval, 0);
if (!u) goto _badArg;
cmdArg.seed = *u;
} else if (strcmp(parg, "skip-iters") == 0) {
haveArg = true;
pval = locateArg(isLongOpt, parg, i);
if (!pval) goto _noArg;
auto u = strtou64(pval);
if (!u) goto _badArg;
cmdArg.skipIters = *u;
} else if (strcmp(parg, "threads") == 0) {
haveArg = true;
pval = locateArg(isLongOpt, parg, i);
if (!pval) goto _noArg;
auto n = strtoi(pval);
if (!n || *n < 0) goto _badArg;
if (*n == 0) {
cmdArg.threads = nullopt;
} else {
cmdArg.threads = *n;
}
} else {
goto _badOpt;
}
if (isLongOpt || haveArg) {
continue;
} else {
++parg;
goto _shortOpt;
}
assert(false);
throw logic_error("Bug detected. Please contact software developer.\n (" FILE_LOC ")");
_badOpt:
if (isLongOpt) {
cerr << "sifsim: unknown option --" << parg << "\n";
} else {
cerr << "sifsim: unknown option --" << parg << "\n";
}
cerr << "Try 'sifsim --help' for more information.\n";
return false;
_noArg:
if (isLongOpt) {
cerr << "sifsim: option --" << parg << " requires an argument\n";
} else {
cerr << "sifsim: option -" << *parg << " requires an argument\n";
}
cerr << "Try 'sifsim --help' for more information.\n";
return false;
_badArg:
if (isLongOpt) {
cerr << "sifsim: invalid argument for option --" << parg << ": '" << pval << "'\n";
} else {
cerr << "sifsim: invalid argument for option -" << *parg << ": '" << pval << "'\n";
}
return false;
}
return true;
}
| [
"statementreply@gmail.com"
] | statementreply@gmail.com |
cd7490c8798fa82102c03be1be8f1aa61f04a7c6 | 554e357c340a20f179686742d14d4702cfc41322 | /RenderSystem/autogen/tables/FontRenderingConstants.h | 8872ec1bd8becb51e677ba626b4788f175a15d10 | [] | no_license | brucelevis/Spectrum | 749bdace73c96156a95526c934dd3b0674cf88ff | d8e80e59ebb89daecc9c43d3dab9673899d5e9bf | refs/heads/master | 2023-04-06T12:32:30.426660 | 2020-08-04T20:31:05 | 2020-08-04T20:31:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 405 | h | #pragma once
namespace Table
{
#pragma pack(push, 1)
struct FontRenderingConstants
{
struct CB
{
float4x4 TransformMatrix;
float4 ClipRect;
} &cb;
using SRV = Empty;
using UAV = Empty;
using SMP = Empty;
float4x4& GetTransformMatrix() { return cb.TransformMatrix; }
float4& GetClipRect() { return cb.ClipRect; }
FontRenderingConstants(CB&cb) :cb(cb){}
};
#pragma pack(pop)
}
| [
"Cheater.dev@hotmail.com"
] | Cheater.dev@hotmail.com |
d6c6b92fc864043eb270ca5b5abe24c2869dae5c | 89610d7018677e1677e683b3ba2029cd8722c357 | /http_cli.cpp | f70eccfb66bc0ac6e8caf83e62438f39ff367bed | [] | no_license | dingx170/HTTPClientC | 08b27d77acec7d7a7e34c2ede9065a7febcf4f0d | 6147fe41d3525ec11f93cb2490ed3ed6506353f5 | refs/heads/master | 2022-09-03T07:45:10.189127 | 2020-05-27T20:01:03 | 2020-05-27T20:01:03 | 260,085,260 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,374 | cpp | /**
* A simple HTTP client sends a request to a server then prints
* out the request hearder and response hearder, and either
* prints out the response body or saves it in a given file
* @author Tong (Debby) Ding
* @version 1.0
* @see CPSC 5510 Spring 2020, Seattle University
*/
#include <netdb.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <string.h>
#include <sys/errno.h>
#define PORT_DEF 80
#define BUF_SIZE 0xfff
#define ARR_SIZE 100
/**
* Print an error message and exit the program
* @param msg customized error message
*/
void checkErr(const char *msg) {
fprintf(stderr, "Error: %s\n", msg);
exit(1);
}
/**
* Send a request to a server and print out both request and response
* @param argc number of arguments entered by user
* @param argv[] the content of arguments
*/
int main(int argc, char *argv[]) {
// server URI, HTTP port
char *port_num, *path_adr;
char host[ARR_SIZE], path[ARR_SIZE];
int port = PORT_DEF;
// flags
bool url_parsed = false, addr_connected = false, is_text = false;
// header info
const char *requestLineFmt = "GET /%s HTTP/1.1\r\n";
const char *headerFmt = "Host: %s\r\n";
const char *connFmt = "Connection: %s\r\n";
const char *CRLF = "\r\n";
// socket & msg related
int sockfd, err, bytes;
struct addrinfo hints, *svr_addr, *addr; // getaddrinfo() result
// request & response holder
char request[BUF_SIZE], response[BUF_SIZE];
char header_buf[BUF_SIZE];
char *buffer1, *buffer2, *buffer3;
size_t bufLen;
char *header_end, *ctnt_type_start, *ctnt_type_end;
char header[BUF_SIZE], body[BUF_SIZE], ctnt_type[ARR_SIZE];
int len, tmplen;
// check user input
if (argc < 2)
checkErr("user input");
// parse URL
if (sscanf(argv[1], "http://%99[^:]:%99d/%99[^\n]", host, &port, path) == 3)
url_parsed = true;
else if (sscanf(argv[1], "http://%99[^/]/%99[^\n]", host, path) == 2)
url_parsed = true;
else if (sscanf(argv[1], "http://%99[^:]:%99d[^\n]", host, &port) == 2)
url_parsed = true;
else if (sscanf(argv[1], "http://%99[^\n]", host) == 1)
url_parsed = true;
if (url_parsed == false)
checkErr("parse URL");
// get port num and path
asprintf(&port_num, "%d", port);
asprintf(&path_adr, "%s", path);
// get IP
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC; // use IPv4 or IPv6
hints.ai_flags = AI_NUMERICSERV; // treat port as number
hints.ai_protocol = 0;
err = getaddrinfo(host, port_num, &hints, &svr_addr);
if (err != 0)
checkErr((char *)gai_strerror(err));
// construct request
strcpy(request, "");
// request line
bufLen = strlen(requestLineFmt) + strlen(path_adr) + 1; // plus 1 for '\0'
buffer1 = (char *)malloc(bufLen);
snprintf(buffer1, bufLen, requestLineFmt, path_adr);
// host
bufLen = strlen(headerFmt) + strlen(host) + 1;
buffer2 = (char *)malloc(bufLen);
snprintf(buffer2, bufLen, headerFmt, host);
// connection
bufLen = strlen(connFmt) + strlen("close") + 1;
buffer3 = (char *)malloc(bufLen);
snprintf(buffer3, bufLen, connFmt, "close");
strcat(request, buffer1);
strcat(request, buffer2);
strcat(request, buffer3);
strcat(request, CRLF);
// send request, loop breaks if 1 addr works
for (addr = svr_addr; addr != NULL; addr = addr->ai_next) {
// construct socket
sockfd = socket(addr->ai_family, addr->ai_socktype, 0);
// connect server
err = connect(sockfd, svr_addr->ai_addr, svr_addr->ai_addrlen);
if (err < 0)
checkErr("connect server");
else
addr_connected = true;
fprintf(stderr, "--------------\nRequest:\n--------------\n%s\n", request);
// send request
err = send(sockfd, request, strlen(request), 0);
if (err < 0)
checkErr("send request");
// recv the first response to get header
err = recv(sockfd, header_buf, BUF_SIZE, 0);
if (err < 0)
checkErr("receive response");
// get header
header_end = strstr(header_buf, "\r\n\r\n");
len = header_end - header_buf;
strncpy(header, header_buf, len); // memcpy(tmp, header_buf, len);
// get initial part of body
len = BUF_SIZE - len - 4;
tmplen = len;
strncpy(body, header_end + sizeof("\r\n\r\n") - 1, len);
// check content length, may be useful later
// char ctnt_len[ARR_SIZE];
// if (strstr(header_buf, "Content-Length:") != nullptr) {
// char *ctnt_len_start = strstr(header_buf, "Content-Length:") + sizeof("Content-Length:");
// char *ctnt_len_end = strstr(ctnt_len_start, "\n");
// len = ctnt_len_end - ctnt_len_start;
// strncpy(ctnt_len, ctnt_len_start, len);
// }
// get content type
ctnt_type_start = strstr(header_buf, "Content-Type:") + sizeof("Content-Type:");
ctnt_type_end = strstr(ctnt_type_start, "\n");
len = ctnt_type_end - ctnt_type_start;
strncpy(ctnt_type, ctnt_type_start, len);
fprintf(stderr, "--------------\nResponse:\n--------------\n%s\n", header);
// adjust print aproach based on content type
if (strstr(ctnt_type, "text")) {
printf(body);
is_text = true;
} else {
write(fileno(stdout), header_end + sizeof("\r\n\r\n") - 1, tmplen);
}
// continue content receiving
do {
bytes = recv(sockfd, response, BUF_SIZE, 0);
if (bytes < 0)
checkErr("ERROR reading response from socket");
if (is_text == true)
printf(response);
else
write(fileno(stdout), response, bytes);
memset(response, 0, BUF_SIZE);
} while (bytes != 0);
if (addr_connected)
break;
}
// free ptr memory
free(buffer1);
buffer1 = NULL;
free(buffer2);
buffer2 = NULL;
free(buffer3);
buffer3 = NULL;
freeaddrinfo(svr_addr);
svr_addr = NULL;
close(sockfd);
return 0;
} | [
"dingtong@seattleu.edu"
] | dingtong@seattleu.edu |
1abf4ee8914690240782a9a11a3c7120091df488 | 78cb99556fbe30f6d6c81dfb45562e06d203a54f | /tests/Litecoin/TWCoinTypeTests.cpp | 985f871cb01121d13d2a8b27f2597ef2f157a8cc | [
"MIT"
] | permissive | Khaos-Labs/khaos-wallet-core | 2b00f37a7f6546f38f4421671f08954745de9a3d | 2c06d49fddf978e0815b208dddef50ee2011c551 | refs/heads/main | 2023-01-09T10:43:59.424174 | 2020-11-15T06:55:13 | 2020-11-15T06:55:13 | 311,566,879 | 2 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,613 | cpp | // Copyright © 2017-2020 Khaos Wallet.
//
// This file is part of Trust. The full Trust copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.
//
// This is a GENERATED FILE, changes made here MAY BE LOST.
// Generated one-time (codegen/bin/cointests)
//
#include "../interface/TWTestUtilities.h"
#include <KhaosWalletCore/TWCoinTypeConfiguration.h>
#include <gtest/gtest.h>
TEST(TWLitecoinCoinType, TWCoinType) {
auto symbol = WRAPS(TWCoinTypeConfigurationGetSymbol(TWCoinTypeLitecoin));
auto txId = TWStringCreateWithUTF8Bytes("t123");
auto txUrl = WRAPS(TWCoinTypeConfigurationGetTransactionURL(TWCoinTypeLitecoin, txId));
auto accId = TWStringCreateWithUTF8Bytes("a12");
auto accUrl = WRAPS(TWCoinTypeConfigurationGetAccountURL(TWCoinTypeLitecoin, accId));
auto id = WRAPS(TWCoinTypeConfigurationGetID(TWCoinTypeLitecoin));
auto name = WRAPS(TWCoinTypeConfigurationGetName(TWCoinTypeLitecoin));
ASSERT_EQ(TWCoinTypeConfigurationGetDecimals(TWCoinTypeLitecoin), 8);
ASSERT_EQ(TWBlockchainBitcoin, TWCoinTypeBlockchain(TWCoinTypeLitecoin));
ASSERT_EQ(0x32, TWCoinTypeP2shPrefix(TWCoinTypeLitecoin));
ASSERT_EQ(0x0, TWCoinTypeStaticPrefix(TWCoinTypeLitecoin));
assertStringsEqual(symbol, "LTC");
assertStringsEqual(txUrl, "https://blockchair.com/litecoin/transaction/t123");
assertStringsEqual(accUrl, "https://blockchair.com/litecoin/address/a12");
assertStringsEqual(id, "litecoin");
assertStringsEqual(name, "Litecoin");
}
| [
"admin@example.com"
] | admin@example.com |
230add9a6deb53337462822a6df7f7068fc03d45 | 9586c70bf182ece97b7186cf370dfaec2173071c | /src/ufo/filters/obsfunctions/HydrometeorCheckAMSUA.cc | 87e648ef71cff5f44ad364cf0190560f0623f4c3 | [
"Apache-2.0"
] | permissive | scogre/ufo | 81cd44a762b146c6c9eaf49d78a271c596106c1f | 2af9b91433553ca473c72fcd131400a01c3aabdb | refs/heads/master | 2023-08-11T02:21:26.356648 | 2021-06-11T22:28:50 | 2021-06-11T22:28:50 | 415,057,301 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,166 | cc | /*
* (C) Copyright 2019 UCAR
*
* This software is licensed under the terms of the Apache Licence Version 2.0
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
*/
#include "ufo/filters/obsfunctions/HydrometeorCheckAMSUA.h"
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#include "ioda/ObsDataVector.h"
#include "oops/util/IntSetParser.h"
#include "ufo/filters/obsfunctions/CLWRetMW.h"
#include "ufo/filters/obsfunctions/ObsErrorModelRamp.h"
#include "ufo/filters/Variable.h"
#include "ufo/utils/Constants.h"
namespace ufo {
static ObsFunctionMaker<HydrometeorCheckAMSUA> makerHydrometeorCheckAMSUA_("HydrometeorCheckAMSUA");
// -----------------------------------------------------------------------------
HydrometeorCheckAMSUA::HydrometeorCheckAMSUA(const eckit::LocalConfiguration & conf)
: invars_() {
// Initialize options
options_.deserialize(conf);
// Get channels from options
std::set<int> channelset = oops::parseIntSet(options_.channelList);
std::copy(channelset.begin(), channelset.end(), std::back_inserter(channels_));
ASSERT(channels_.size() > 0);
// Get test groups from options
const std::string &biastermgrp = options_.testBiasTerm.value();
const std::string &biasgrp = options_.testBias.value();
const std::string &hofxgrp = options_.testHofX.value();
// Include required variables from ObsDiag
invars_ += Variable("brightness_temperature_jacobian_surface_emissivity@ObsDiag", channels_);
invars_ += Variable("brightness_temperature_assuming_clear_sky@ObsDiag", channels_);
// Include list of required data from ObsSpace
invars_ += Variable("brightness_temperature@ObsValue", channels_);
invars_ += Variable("brightness_temperature@"+biasgrp, channels_);
invars_ += Variable("brightness_temperature@"+hofxgrp, channels_);
invars_ += Variable("constant@"+biastermgrp, channels_);
invars_ += Variable("scan_angle_order_4@"+biastermgrp, channels_);
invars_ += Variable("scan_angle_order_3@"+biastermgrp, channels_);
invars_ += Variable("scan_angle_order_2@"+biastermgrp, channels_);
invars_ += Variable("scan_angle@"+biastermgrp, channels_);
// Include list of required data from GeoVaLs
invars_ += Variable("water_area_fraction@GeoVaLs");
// Include list of required data from ObsFunction
const Variable &obserrfunc = options_.obserrFunction.value();
invars_ += obserrfunc;
const Variable &clwretfunc = options_.clwretFunction.value();
invars_ += clwretfunc;
}
// -----------------------------------------------------------------------------
HydrometeorCheckAMSUA::~HydrometeorCheckAMSUA() {}
// -----------------------------------------------------------------------------
void HydrometeorCheckAMSUA::compute(const ObsFilterData & in,
ioda::ObsDataVector<float> & out) const {
// Get dimensions
size_t nlocs = in.nlocs();
size_t nchans = channels_.size();
// Set channel index
int ich238 = 0, ich314 = 1, ich503 = 2, ich528 = 3, ich536 = 4;
int ich544 = 5, ich549 = 6, ich890 = 14;
// Get test groups from options
const std::string &biastermgrp = options_.testBiasTerm.value();
const std::string &biasgrp = options_.testBias.value();
const std::string &hofxgrp = options_.testHofX.value();
// Get clear-sky observation error from options
const std::vector<float> &obserr0 = options_.obserrClearSky.value();
// Get area fraction of each surface type
std::vector<float> water_frac(nlocs);
in.get(Variable("water_area_fraction@GeoVaLs"), water_frac);
// Get surface temperature jacobian
std::vector<std::vector<float>> dbtde(nchans, std::vector<float>(nlocs));
for (size_t ichan = 0; ichan < nchans; ++ichan) {
in.get(Variable("brightness_temperature_jacobian_surface_emissivity@ObsDiag", channels_)[ichan],
dbtde[ichan]);
}
// Get HofX for clear-sky simulation
std::vector<float> hofxclr536(nlocs);
in.get(Variable("brightness_temperature_assuming_clear_sky@ObsDiag", channels_)[ich536],
hofxclr536);
// Get ObsBiasTerm: constant term for 23.8GHz channel
std::vector<float> bias_const238(nlocs);
in.get(Variable("constant@"+biastermgrp, channels_)[ich238], bias_const238);
// Get ObsBiasTerm: scan angle terms for 23.8GHz channel
size_t nangs = 4;
std::vector<float> values(nlocs);
std::vector<std::string> scanterms(nangs);
std::vector<float> bias_scanang238(nlocs);
scanterms[0] = "scan_angle_order_4@"+biastermgrp;
scanterms[1] = "scan_angle_order_3@"+biastermgrp;
scanterms[2] = "scan_angle_order_2@"+biastermgrp;
scanterms[3] = "scan_angle@"+biastermgrp;
for (size_t iang = 0; iang < nangs; ++iang) {
in.get(Variable(scanterms[iang], channels_)[ich238], values);
for (size_t iloc = 0; iloc < nlocs; ++iloc) {
bias_scanang238[iloc] = bias_scanang238[iloc] + values[iloc];
}
}
// Calculate bias-corrected innovation: Observation - HofX (HofX includes bias correction)
std::vector<std::vector<float>> btobs(nchans, std::vector<float>(nlocs));
// Read bias since it's used for correcting clear-sky simulated values below
std::vector<std::vector<float>> bias(nchans, std::vector<float>(nlocs));
std::vector<std::vector<float>> innov(nchans, std::vector<float>(nlocs));
std::vector<float> hofx(nlocs);
for (size_t ichan = 0; ichan < nchans; ++ichan) {
in.get(Variable("brightness_temperature@ObsValue", channels_)[ichan], btobs[ichan]);
in.get(Variable("brightness_temperature@"+biasgrp, channels_)[ichan], bias[ichan]);
in.get(Variable("brightness_temperature@"+hofxgrp, channels_)[ichan], hofx);
for (size_t iloc = 0; iloc < nlocs; ++iloc) {
innov[ichan][iloc] = btobs[ichan][iloc] - hofx[iloc];
}
}
// Get all-sky observation error from ObsFunction
const Variable &obserrvar = options_.obserrFunction.value();
ioda::ObsDataVector<float> obserr(in.obsspace(), obserrvar.toOopsVariables());
in.get(obserrvar, obserr);
// Get CLW retrieval based on observation from ObsFunction
const Variable &clwretvar = options_.clwretFunction.value();
ioda::ObsDataVector<float> clwobs(in.obsspace(), clwretvar.toOopsVariables());
in.get(clwretvar, clwobs);
// Set parameters
float w1f6 = 1.0/10.0, w2f6 = 1.0/0.80;
float w1f4 = 1.0/0.30, w2f4 = 1.0/1.80;
std::vector<std::vector<int>> affected_channels(nchans, std::vector<int>(nlocs));
// Loop over locations
// Combined cloud-precipitation-surface checks
for (size_t iloc = 0; iloc < nlocs; ++iloc) {
// Initialization
for (size_t ich = 0; ich < nchans; ++ich) {
affected_channels[ich][iloc] = 0;
}
// Calculate cloud effect
float cldeff_obs536 = 0.0;
if (water_frac[iloc] > 0.99) {
cldeff_obs536 = btobs[ich536][iloc] - hofxclr536[iloc] - bias[ich536][iloc];
}
// Calculate scattering effect
std::vector<float> factch4(nlocs);
std::vector<float> factch6(nlocs);
float btobsbc238 = btobs[ich238][iloc] - bias_const238[iloc]
- bias_scanang238[iloc];
float clwx = 0.6;
float dsval = 0.8;
if (water_frac[iloc] > 0.99) {
clwx = 0.0;
dsval = ((2.410 - 0.0098 * btobsbc238) * innov[ich238][iloc] +
0.454 * innov[ich314][iloc] - innov[ich890][iloc]) * w1f6;
dsval = std::max(static_cast<float>(0.0), dsval);
}
factch4[iloc] = pow(clwx, 2) + pow(innov[ich528][iloc] * w2f4, 2);
factch6[iloc] = pow(dsval, 2) + pow(innov[ich544][iloc] * w2f6, 2);
// Window channel sanity check
// If any of the window channels is bad, skip all window channels
// List of surface sensitivity channels
std::vector<float> OmFs{std::abs(innov[ich238][iloc]), std::abs(innov[ich314][iloc]),
std::abs(innov[ich503][iloc]), std::abs(innov[ich528][iloc]),
std::abs(innov[ich536][iloc]), std::abs(innov[ich544][iloc]),
std::abs(innov[ich890][iloc])};
bool result = false;
result = any_of(OmFs.begin(), OmFs.end(), [](float x){return x > 200.0;});
if (result) {
for (size_t ich = ich238; ich <= ich544; ++ich) {
affected_channels[ich][iloc] = 1;
}
affected_channels[ich890][iloc] = 1;
} else {
// Hydrometeor check over water surface
if (water_frac[iloc] > 0.99) {
// Cloud water retrieval sanity check
if (clwobs[0][iloc] > 999.0) {
for (size_t ich = ich238; ich <= ich544; ++ich) {
affected_channels[ich][iloc] = 1;
}
affected_channels[ich890][iloc] = 1;
}
// Precipitation check (factch6)
if (factch6[iloc] >= 1.0) {
for (size_t ich = ich238; ich <= ich544; ++ich) {
affected_channels[ich][iloc] = 1;
}
affected_channels[ich890][iloc] = 1;
// Scattering check (ch5 cloud effect)
} else if (cldeff_obs536 < -0.5) {
for (size_t ich = ich238; ich <= ich544; ++ich) {
affected_channels[ich][iloc] = 1;
}
affected_channels[ich890][iloc] = 1;
// Sensitivity of BT to the surface emissivity check
} else {
float thrd238 = 0.025, thrd314 = 0.015, thrd503 = 0.030, thrd890 = 0.030;
float de238 = 0.0, de314 = 0.0, de503 = 0.0, de890 = 0.0;
float dbtde238 = dbtde[ich238][iloc];
float dbtde314 = dbtde[ich314][iloc];
float dbtde503 = dbtde[ich503][iloc];
float dbtde890 = dbtde[ich890][iloc];
if (dbtde238 != 0.0) de238 = std::abs(innov[ich238][iloc]) / dbtde238 *
(obserr0[ich238] / obserr[ich238][iloc]) *
(1.0 - std::max(1.0, 10.0*clwobs[0][iloc]));
if (dbtde314 != 0.0) de314 = std::abs(innov[ich314][iloc]) / dbtde314 *
(obserr0[ich314] / obserr[ich314][iloc]) *
(1.0 - std::max(1.0, 10.0*clwobs[0][iloc]));
if (dbtde503 != 0.0) de503 = std::abs(innov[ich503][iloc]) / dbtde503 *
(obserr0[ich503] / obserr[ich503][iloc]) *
(1.0 - std::max(1.0, 10.0*clwobs[0][iloc]));
if (dbtde890 != 0.0) de890 = std::abs(innov[ich890][iloc]) / dbtde890 *
(obserr0[ich890] / obserr[ich890][iloc]) *
(1.0 - std::max(1.0, 10.0*clwobs[0][iloc]));
bool qcemiss = false;
qcemiss = de238 > thrd238 || de314 > thrd314 || de503 > thrd503 || de890 > thrd890;
if (qcemiss) {
for (size_t ich = ich238; ich <= ich536; ++ich) {
affected_channels[ich][iloc] = 1;
}
affected_channels[ich890][iloc] = 1;
}
}
} else {
// Hydrometeor check over non-water (land/sea ice/snow) surface
// Precipitation check (factch6)
if (factch6[iloc] >= 1.0) {
for (size_t ich = ich238; ich <= ich544; ++ich) {
affected_channels[ich][iloc] = 1;
}
affected_channels[ich890][iloc] = 1;
// Thick cloud check (factch4)
} else if (factch4[iloc] > 0.5) {
for (size_t ich = ich238; ich <= ich536; ++ich) {
affected_channels[ich][iloc] = 1;
}
affected_channels[ich890][iloc] = 1;
// Sensitivity of BT to the surface emissivity check
} else {
float thrd238 = 0.020, thrd314 = 0.015, thrd503 = 0.035, thrd890 = 0.015;
float de238 = 0.0, de314 = 0.0, de503 = 0.0, de890 = 0.0;
float dbtde238 = dbtde[ich238][iloc];
float dbtde314 = dbtde[ich314][iloc];
float dbtde503 = dbtde[ich503][iloc];
float dbtde890 = dbtde[ich890][iloc];
if (dbtde238 != 0.0) de238 = std::abs(innov[ich238][iloc]) / dbtde238;
if (dbtde314 != 0.0) de314 = std::abs(innov[ich314][iloc]) / dbtde314;
if (dbtde503 != 0.0) de503 = std::abs(innov[ich503][iloc]) / dbtde503;
if (dbtde890 != 0.0) de890 = std::abs(innov[ich890][iloc]) / dbtde890;
bool qcemiss = false;
qcemiss = de238 > thrd238 || de314 > thrd314 || de503 > thrd503 || de890 > thrd890;
if (qcemiss) {
for (size_t ich = ich238; ich <= ich536; ++ich) {
affected_channels[ich][iloc] = 1;
}
affected_channels[ich890][iloc] = 1;
}
}
// surface type
}
// window channel sanity check
}
// loop over locations
}
// Output
for (size_t ichan = 0; ichan < nchans; ++ichan) {
for (size_t iloc = 0; iloc < nlocs; ++iloc) {
out[ichan][iloc] = affected_channels[ichan][iloc];
}
}
}
// -----------------------------------------------------------------------------
const ufo::Variables & HydrometeorCheckAMSUA::requiredVariables() const {
return invars_;
}
// -----------------------------------------------------------------------------
} // namespace ufo
| [
"noreply@github.com"
] | noreply@github.com |
62ecbe4853b771096bb811fb1c07051276372da3 | 6d115d4eec6a31b688fdf86b0738f7659738415f | /common/controls/input.cpp | 22b10fb4329c564450e64c067f14a05c8a9bec35 | [] | no_license | kambielawski/OpenGL-programming | 1a04a5ae7f7ce7a78887ded99b3fa4006334978a | 115773317b3b77e966d856f92ec0fc6990957ad5 | refs/heads/master | 2022-04-15T02:59:30.754589 | 2020-04-11T02:43:03 | 2020-04-11T02:43:03 | 254,741,551 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 324 | cpp | #include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <math.h>
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) {
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) {
glfwSetWindowShouldClose(window, GLFW_TRUE);
}
} | [
"kamtb28@gmail.com"
] | kamtb28@gmail.com |
83e103e09b4c1260bccbbb1d1436c20e8423b877 | 56ac931b9124f65e1fdee6199b986b0ae60471a4 | /C2_Ejemplo_examen6.cpp | eb1612323c3606c1f96c90a19e1d9b315f099c29 | [] | no_license | saraparva/FonamentsD-infromatica | 6b94ee47695a9348684a3fd74e843715efa37ff8 | 6912b544bc72a012ecf1c5ae4843d04183595ccf | refs/heads/master | 2022-11-07T04:17:42.719548 | 2020-06-20T12:15:49 | 2020-06-20T12:15:49 | 239,741,872 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,439 | cpp | #include <iostream>
#include <fstream>
using namespace std;
bool es_lletra(char caracter){
if ((caracter>='A' && caracter<='Z')||(caracter>='a' && caracter<='z')){
return true;}
else{
return false;}
}
bool es_vocal(char caracter){
bool vocal;
switch (caracter){
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
vocal=true;
break;
}
return vocal;
}
void comptadors(char caracter, int &comptv, int &comptc, int &comptn, int &comptl){
if (es_lletra(caracter)){
comptl++;
if (es_vocal(caracter)){
comptv++;
}
else{
comptc++;
}
}
else{
comptn++;
}
}
int main(){
char caracter;
int comptv=0, comptc=0, comptn=0, comptl=0, comptch=0;
ifstream texto("ElQuijote.txt");
while(texto>>caracter){
comptch++;
comptadors(caracter,comptv,comptc,comptn,comptl);
}
cout<<"La quantitat de vocals es: "<<comptv<<endl;
cout<<"La cuantitat de consonants es: "<<comptc<<endl;
cout<<"El percentatge de caracters que no son lletres es: "<<(float(comptn)/comptch)*100<<'%'<<endl;
cout<<"El percentatge de lletres que son vocals es: "<<(float(comptv)/comptl)*100<<'%'<<endl;
}
| [
"noreply@github.com"
] | noreply@github.com |
1933015698a204fdab1faeab702982cbe3c44065 | d378859ed71f630cdab4712931e64149db76546d | /app/libdashframework/Buffer/AudioChunk.h | 6bcda28874f63748d4a55574fed9fac5a2c18f47 | [] | no_license | humwerthuz/libdash-android | ee2f4f1212a35ab797a08dd6a2281383f8720065 | f3fa651337c9f40b2947e317ea9f6c535b85ff07 | refs/heads/master | 2021-01-17T12:00:12.639639 | 2014-03-12T01:37:45 | 2014-03-12T01:37:45 | 17,651,001 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,212 | h | /*
* AudioChunk.h
*****************************************************************************
* Copyright (C) 2013, bitmovin Softwareentwicklung OG, All Rights Reserved
*
* Email: libdash-dev@vicky.bitmovin.net
*
* This source code and its use and distribution, is subject to the terms
* and conditions of the applicable license agreement.
*****************************************************************************/
#ifndef QTSAMPLEPLAYER_BUFFER_AUDIOCHUNK_H_
#define QTSAMPLEPLAYER_BUFFER_AUDIOCHUNK_H_
#include "config.h"
namespace libdash
{
namespace framework
{
namespace buffer
{
class AudioChunk
{
public:
AudioChunk (void *format, char * data, uint64_t dataLength);
virtual ~AudioChunk ();
char* Data ();
uint64_t Length ();
void* Format ();
private:
uint64_t chunkLength;
char *data;
void *format;
};
}
}
}
#endif /* QTSAMPLEPLAYER_BUFFER_AUDIOCHUNK_H_ */
| [
"heineken69addict@gmail.com"
] | heineken69addict@gmail.com |
db7cce266ec5515e18cd16c94205eea22f584f49 | 78e93cd3a4cffbe81ebed05cfda410caa8701621 | /Dovelet/3F/13_3np1.cpp | 0cf5fb13f00ab2d60cbb2cf872d54e8d82d0efb2 | [] | no_license | WonDoY/PSNote | 4cfbbda8b77f0bd2a7ea9457d59b0fe5d7223201 | 30b751d5a9ac7f6c652f37af8627c6223858580b | refs/heads/master | 2021-06-12T18:19:36.441041 | 2017-04-04T19:10:30 | 2017-04-04T19:10:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 160 | cpp | #include<cstdio>
int main(){
int n;scanf("%d",&n);
while(n!=1){
printf("%d ",n);
if(n&1){
n=3*n+1;
}else{
n/=2;
}
}
printf("1");
return 0;
} | [
"wondy1128@naver.com"
] | wondy1128@naver.com |
c3c1dce7de7b2fa5911d3e3227d4280e6e7bf4ce | 3ff0cd67a34eff9e816f13d1b0ec26dc0dd02131 | /cliente.cpp | a8291e27e1c57b6f139be611e899aa24717b0be9 | [] | no_license | EnriquelTM/Proyecto-Final- | 3b7bc9e2726a4fdddda7e0317a1526ddeb66d89f | 7d68237f5298982841b9f503cbee6f6332d8ede6 | refs/heads/master | 2023-03-02T22:30:21.749363 | 2021-02-09T15:11:09 | 2021-02-09T15:11:09 | 335,115,730 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,086 | cpp | #include <iostream>
#include "cliente.h"
using namespace std;
void cliente::habitacion(){
int habitacion;
cout << " Habitación asignada: ";
cin >> habitacion;
}
void cliente::pago(){
cout << "¿Cuantas noches se hospedara? ";
cin >> noches;
for (int noche=20; noche>=20; noche = noche*noches){
cout << "El monto a pagar será de: " << noche;
}
}
void cliente::check_in(){
cout << "Nombre del cliente: ";
cin >> nombre;
cout << "Apellido del cliente: ";
cin >> apellido;
cout << "Número de D.N.I. : ";
cin >> dni;
cout << "Día de registro : ";
cin >> fecha;
cout << "Se debe retirar el día" << fecha + noches << endl;
}
void cliente::check_out(){
int fecha1;
cout << "Día de registro : ";
cin >> fecha1;
cout << "Nombre del cliente: ";
cin >> nombre;
cout << "Apellido del cliente: ";
cin >> apellido;
cout << "Número de D.N.I. : ";
cin >> dni;
if (fecha + noches == fecha1){
cout << "se puede ir";
}
}
| [
"noreply@github.com"
] | noreply@github.com |
6b6d29144a0a6cab8430cdf625555cc4282ad558 | 64841e0503d06b3b59d433991c22d1faf30b1237 | /zeromq_agent.cpp | 3a87f21e502e8be1b8ee3ce2892b4b510eb98d03 | [] | no_license | thereisnosun/zeromq_agent | 9257dd70ebfd03898d067d1b67aa9606d41a6cd8 | dee295e57b15200a8631a3bbacf1c92de11445eb | refs/heads/master | 2020-06-13T12:59:40.271580 | 2019-07-09T12:42:21 | 2019-07-09T12:42:21 | 194,662,997 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 10,024 | cpp | #include "broker_api.h"
#include "server_api.h"
#include "client_api.h"
#include <iostream>
#include <random>
//TODO: test with raw void* ptr
const std::string UPDATE_TOKEN = "{'msg_type' : 'ipc', 'name': 'update_token', 'data': {'token': '<token>'}}";
const std::string CLIP_REQUEST = "{'msg_type' : 'ipc', 'name': 'clip_request', 'data': {'time': '<timestamp>'}}";
const std::string ADD_CAMERA = "{'msg_type' : 'ipc', 'name': 'add_camera|edit_camera|delete_camera', "
"'data': <camera_json_info>}";
//const std::string REPLY = "1234567{'status' : 'ok'}";
const std::string REPLY = "{'status' : 'ok'}";
const std::string FRONTEND_ENDPOINT = "tcp://*:5559";
const std::string BACKEND_ENDPOINT = "tcp://*:5560";
const char* end_point = "tcp://localhost:5559";
const char* end_point_front_end = "tcp://localhost:5560";
const char* end_point_server = "tcp://*:5559";
const int ITERATIONS_NUM = 100;
const int SLEEP_MS = 100;
const std::vector<std::string> messages{UPDATE_TOKEN, CLIP_REQUEST, ADD_CAMERA};
int req_rep_client(const std::string& end_point)
{
zmq::Client client{zmq::SocketType::REQUEST};
if (client.connect(end_point) != zmq::ErrorType::OK)
{
std::cout << "Coud not connect from client\n";
return -1;
}
std::random_device dev;
std::mt19937 rng(dev());
std::uniform_int_distribution<std::mt19937::result_type> dist(0, 2);
for(int i = 0; i < ITERATIONS_NUM; ++i)
{
const int index = dist(rng);
const std::string& message_to_send = messages[index];
std::cout << "Sending message: \n" << message_to_send << "\n";
zmq::SendMessage zmq_message{message_to_send};
client.send(zmq_message);
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_MS));
const zmq::IMessage * message = client.receive();
if (!message)
continue;
const std::string str_message{static_cast<char*>(message->get_data()), message->get_size()};
std::cout << "Received a response from server: \n" << str_message << std::endl;
}
return 0;
}
int req_rep_server(const std::string& end_point_server)
{
zmq::Server server{zmq::SocketType::REPLY};
if (server.bind(end_point_server) != zmq::ErrorType::OK)
{
std::cout << "Could not bind a server\n";
return -1;
}
for (int i = 0; i < ITERATIONS_NUM; ++i)
{
const zmq::IMessage* message = server.receive();
if (!message)
continue;
const std::string str_message{static_cast<char*>(message->get_data()), message->get_size()};
std::cout << "Received a message from client: \n" << str_message << std::endl;
zmq::SendMessage send_message{REPLY};
server.publish(send_message);
}
return 0;
}
int pub_sub_client(const std::string& end_point)
{
zmq::Client client{zmq::SocketType::SUBSCRIBE};
if (client.connect(end_point) != zmq::ErrorType::OK)
{
std::cout << "Coud not connect from client\n";
return -1;
}
for(int i = 0; i < ITERATIONS_NUM; ++i)
{
const zmq::IMessage* message = client.receive();
if (!message)
continue;
const std::string str_message{static_cast<char*>(message->get_data()), message->get_size()};
std::cout << "Received a message from client: \n" << str_message << std::endl;
}
return 0;
}
int pub_sub_server(const std::string& end_point)
{
zmq::Server server{zmq::SocketType::PUBLISH};
if (server.bind(end_point) != zmq::ErrorType::OK)
{
std::cout << "Could not bind to server\n";
return -1;
}
std::random_device dev;
std::mt19937 rng(dev());
std::uniform_int_distribution<std::mt19937::result_type> dist(0, 2);
for(int i = 0; i < ITERATIONS_NUM; ++i)
{
const int index = dist(rng);
const std::string& message_to_send = messages[index];
std::cout << "Sending message: \n" << message_to_send << "\n";
zmq::SendMessage zmq_message{message_to_send};
server.publish(zmq_message);
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_MS));
}
return 0;
}
int req_rep_worker(const std::string& end_point)
{
zmq::Client client{zmq::SocketType::REPLY};
if (client.connect(end_point) != zmq::ErrorType::OK)
{
std::cout << "Coud not connect from client\n";
return -1;
}
for(int i = 0; i < ITERATIONS_NUM; ++i)
{
const zmq::IMessage * message = client.receive();
if (!message)
continue;
const std::string str_message{static_cast<char*>(message->get_data()), message->get_size()};
std::cout << "Received a response from server: \n" << str_message << std::endl;
std::cout << "Sending message: \n" << REPLY << "\n";
zmq::SendMessage send_message{REPLY};
client.send(send_message);
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_MS));
}
return 0;
}
int pub_sub_client_async(const std::string& end_point)
{
zmq::Client client{zmq::SocketType::SUBSCRIBE};
if (client.connect(end_point) != zmq::ErrorType::OK)
{
std::cout << "Coud not connect from client\n";
return -1;
}
for(int i = 0; i < ITERATIONS_NUM; ++i)
{
client.async_receive([](zmq::IMessage& message) -> void
{
const std::string str_message{static_cast<char*>(message.get_data()), message.get_size()};
std::cout << "Received a message from client: \n" << str_message << std::endl;
});
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_MS));
std::cout << "Waiting for the previous message\n";
}
std::cout << "Press a key\n";
//getchar();
std::cout << "End of function\n";
return 0;
}
int req_rep_client_async(const std::string& end_point)
{
zmq::Client client{zmq::SocketType::REQUEST};
if (client.connect(end_point) != zmq::ErrorType::OK)
{
std::cout << "Coud not connect from client\n";
return -1;
}
std::random_device dev;
std::mt19937 rng(dev());
std::uniform_int_distribution<std::mt19937::result_type> dist(0, 2);
for(int i = 0; i < ITERATIONS_NUM; ++i)
{
const int index = dist(rng);
const std::string& message_to_send = messages[index];
std::cout << "Sending message: \n" << message_to_send << "\n";
zmq::SendMessage zmq_message{message_to_send};
client.async_send(zmq_message, [&client] (zmq::Status status) -> void {
const zmq::IMessage * message = client.receive();
if (!message)
{
std::cout << "Failed to receive stuff\n";
return;
}
const std::string str_message{static_cast<char*>(message->get_data()), message->get_size()};
std::cout << "Received a response from server: \n" << str_message << std::endl;
});
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_MS));
std::cout << "Iteration " << i << " is finished\n";
}
return 0;
}
int req_rep_server_async(const std::string& end_point_server)
{
zmq::Server server{zmq::SocketType::REPLY};
if (server.bind(end_point_server) != zmq::ErrorType::OK)
{
std::cout << "Could not bind a server\n";
return -1;
}
for (int i = 0; i < ITERATIONS_NUM; ++i)
{
server.async_receive([&server, &REPLY](zmq::IMessage& message)
{
const std::string str_message{static_cast<char*>(message.get_data()), message.get_size()};
std::cout << "Received a message from client: \n" << str_message << std::endl;
zmq::SendMessage send_message{REPLY};
server.publish(send_message);
});
std::cout << "Iteration " << i << " is finished\n";
}
std::cout << "Enter a character...\n";
getchar();
return 0;
}
int main(int argc, char* argv[])
{
if (argc < 2)
{
std::cout << "Specify mode, bitch! \n";
return -1;
}
if (std::string{argv[1]} == "client")
{
std::cout << "Starting socket client... \n";
req_rep_client(end_point);
}
else if (std::string{argv[1]} == "server")
{
std::cout << "Starting socket server... \n";
req_rep_server(end_point_server);
}
else if (std::string{argv[1]} == "client_pub")
{
std::cout << "Starting socket subscribe client... \n";
pub_sub_client(end_point);
}
else if (std::string{argv[1]} == "server_pub")
{
std::cout << "Starting socket publish server... \n";
pub_sub_server(end_point_server);
}
else if (std::string{argv[1]} == "broker")
{
std::cout << "Starting broker REQ - REP...\n";
zmq::Broker broker;
broker.bind(BACKEND_ENDPOINT, FRONTEND_ENDPOINT);
broker.start_loop();
}
else if (std::string{argv[1]} == "worker")
{
std::cout << "Starting worker...\n";
req_rep_worker(end_point_front_end);
}
else if (std::string{argv[1]} == "broker_publish")
{
std::cout << "Starting broker PUB - SUB...\n";
zmq::BrokerPublisher broker;
broker.bind(BACKEND_ENDPOINT, FRONTEND_ENDPOINT);
}
else if (std::string{argv[1]} == "client_pub_async")
{
std::cout << "Starting async subscribe client...\n";
pub_sub_client_async(end_point);
}
else if (std::string{argv[1]} == "client_req_async")
{
std::cout << "Starting async REQ_REP client...\n";
req_rep_client_async(end_point);
}
else if (std::string{argv[1]} == "server_req_async")
{
std::cout << "Starting async REQ_REP server\n";
req_rep_server_async(end_point_server);
}
else
{
std::cout << "You've specified wrong mode, bitch.\n";
return -1;
}
std::cout << "Normal program exit\n";
return 0;
}
| [
"teodor.moroz@ezlo.com"
] | teodor.moroz@ezlo.com |
d6ada2b195ebbad614b3eb79c47f449e890e42ef | ece46d54db148fcd1717ae33e9c277e156067155 | /SDK/zrxsdk2021/inc/zaduiDialog.h | 8187c35bb00163e1b24b54bf4d1b8ac451c841b4 | [] | 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 | 3,474 | h |
#ifndef _zduiDialog_h
#define _zduiDialog_h
#pragma pack (push, 8)
#if _MSC_VER >= 1000
#pragma once
#endif
#ifndef _ZSOFT_MAC_
class ZDUI_PORT CZdUiDialog : public CZdUiBaseDialog {
DECLARE_DYNAMIC(CZdUiDialog);
public:
CZdUiDialog (
UINT idd,
CWnd *pParent=NULL,
HINSTANCE hDialogResource=NULL
);
virtual ~CZdUiDialog ();
protected:
virtual void OnInitDialogBegin ();
virtual void OnInitDialogFinish ();
private:
LPVOID m_pElastic;
CString m_dlgHelpTag;
protected:
BOOL m_bEnableElasticMessageMap;
UINT m_templateid;
public:
BOOL AddControl (CWnd *pControl);
BOOL AutoLoadControl (CWnd *pControl);
BOOL DelDialogData(LPCTSTR valueName);
BOOL ForceControlRepaint (CWnd *pControl, BOOL bForce);
BOOL ForceControlResize (CWnd *pControl, LPRECT prect);
BOOL GetColumnSizes (CListCtrl *pList);
CSize *GetCurrentDelta ();
BOOL GetDialogData (LPCTSTR valueName, CString& data);
BOOL GetDialogData (LPCTSTR valueName, DWORD& data);
BOOL GetDialogKey (CString& key);
BOOL GetDialogName (CString& name);
void GetDialogHelpTag (CString& tag);
void GetElasticMinMaxInfo (MINMAXINFO& mmi);
LPVOID GetElasticPointer ();
BOOL GetPixelData (CRect& r);
void LockDialogHeight ();
void LockDialogWidth ();
BOOL MoveControlX (UINT id, LONG lMovePct);
BOOL MoveControlXY (UINT id, LONG lMoveXPct, LONG lMoveYPct);
BOOL MoveControlY (UINT id, LONG lMovePct);
BOOL ReloadControl (CWnd *pControl, LPCTSTR lpResString);
BOOL RemoveControl (CWnd *pControl);
BOOL SaveColumnSizes (CListCtrl *pList);
BOOL SetControlProperty (PDLGCTLINFO lp, DWORD numElements);
BOOL SetDialogData (LPCTSTR valueName, LPCTSTR data);
BOOL SetDialogData (LPCTSTR valueName, DWORD data);
void SetDialogMaxExtents (int width, int height);
void SetDialogMinExtents (int width, int height);
void SetDialogName (LPCTSTR name);
void SetDialogHelpTag (LPCTSTR tag);
void SetElasticSize (CSize& size, BOOL bRefreshDialog);
void SetPersistency (BOOL bFlag);
void SetRootKey (LPCTSTR key);
void SetTabSize (LPARAM lParam, BOOL bRefreshDialog);
BOOL StorePixelData ();
BOOL StretchControlX (UINT id, LONG lStretchPct);
BOOL StretchControlXY (UINT id, LONG lStretchXPct, LONG lStretchYPct);
BOOL StretchControlY (UINT id, LONG lStretchPct);
public:
enum { IDD = 0 };
protected:
virtual void DoDataExchange(CDataExchange* pDX);
public:
virtual void OnDialogHelp();
virtual BOOL DoDialogHelp();
protected:
afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);
virtual void OnOK();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
DECLARE_MESSAGE_MAP()
private:
void* mHighlightWnd;
bool m_bNewItemsHighlighted;
public:
bool BeginHighlight(CString dialogName);
void EndHighlight();
};
#endif
#pragma pack (pop)
#endif
| [
"3494543191@qq.com"
] | 3494543191@qq.com |
6a34142d0f21f08366126938c8c1fafbfe055829 | 5607abcd70ad2365e05f03b302738b654083adec | /reflection/variant.cpp | 4b9a1f55f87cca5801fbe261649680853bd72041 | [] | no_license | caster99yzw/Y3DGameEngine | 650dffc95b501eb1d499877e142b1cfe3bea4a7d | c932fd91261fbaf8a7a38d24d86258692fb29441 | refs/heads/master | 2021-11-11T17:01:55.033172 | 2021-10-30T12:56:51 | 2021-10-30T12:56:51 | 99,477,051 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 49 | cpp | #include "variant.h"
namespace reflection
{
}
| [
"caster99@163.com"
] | caster99@163.com |
a8aa9c178fe7e9dd34c4aeceb780c2e57f35d7eb | 85455876309135778cba6bbf16933ca514f457f8 | /2900/2924.cpp | f5274ee559ecf60b4b1075cd2b5700b67b1cd7a1 | [] | no_license | kks227/BOJ | 679598042f5d5b9c3cb5285f593231a4cd508196 | 727a5d5def7dbbc937bd39713f9c6c96b083ab59 | refs/heads/master | 2020-04-12T06:42:59.890166 | 2020-03-09T14:30:54 | 2020-03-09T14:30:54 | 64,221,108 | 83 | 19 | null | null | null | null | UTF-8 | C++ | false | false | 768 | cpp | #include <cstdio>
using namespace std;
int ccnt, next[500000], cn[500000], cs[500000];
bool visited[500000];
void dfs(int curr){
visited[curr] = true;
cn[curr] = ccnt;
cs[cn[curr]]++;
if(!visited[next[curr]]) dfs(next[curr]);
}
long long gcd(long long p, long long q){
while(q){
long long r = p%q;
p = q;
q = r;
}
return p;
}
long long lcm(long long p, long long q){
return p/gcd(p, q)*q;
}
int main(){
int N, C, D;
long long A, B;
scanf("%d %lld %lld %d %d", &N, &A, &B, &C, &D);
for(int i=0; i<N; i++){
scanf("%d", next+i);
next[i]--;
}
for(int i=0; i<N; i++){
if(!visited[i]){
dfs(i);
ccnt++;
}
}
long long g = 1;
for(int i=C; i<N-D; i++)
g = lcm(g, cs[cn[i]]);
printf("%lld\n", (B-1)/g+1 - (A==1 ? 0 : (A-2)/g+1));
} | [
"wongrikera@nate.com"
] | wongrikera@nate.com |
f6336cc6e85006eede748a7aefac54ce5d27e01d | 143cb64bdc09e69a0cb15cc42d84d805a8119932 | /third_party/double-conversion/test/cctest/test-conversions.cc | 42bca876ca3891a16949b60cdf1fe6c4c6d63ebd | [
"BSD-3-Clause",
"Apache-2.0",
"BSL-1.0"
] | permissive | ulfjack/ryu | 49944fbc1259041c9cd10f07a53e5ac72d552e1c | cc41df9626ba8d7aa69b9de611e3f775d80452b0 | refs/heads/master | 2023-08-08T04:33:15.366964 | 2023-05-26T18:17:36 | 2023-05-26T18:17:36 | 121,561,462 | 1,067 | 115 | Apache-2.0 | 2023-07-21T21:54:52 | 2018-02-14T21:07:38 | C++ | UTF-8 | C++ | false | false | 148,912 | cc | // Copyright 2012 the V8 project authors. All rights reserved.
#include <string.h>
#include "cctest.h"
#include "double-conversion/double-conversion.h"
#include "double-conversion/ieee.h"
#include "double-conversion/utils.h"
// DoubleToString is already tested in test-dtoa.cc.
using namespace double_conversion;
TEST(DoubleToShortest) {
const int kBufferSize = 128;
char buffer[kBufferSize];
StringBuilder builder(buffer, kBufferSize);
int flags = DoubleToStringConverter::UNIQUE_ZERO |
DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN;
DoubleToStringConverter dc(flags, NULL, NULL, 'e', -6, 21, 0, 0);
CHECK(dc.ToShortest(0.0, &builder));
CHECK_EQ("0", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(12345.0, &builder));
CHECK_EQ("12345", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(12345e23, &builder));
CHECK_EQ("1.2345e+27", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(1e21, &builder));
CHECK_EQ("1e+21", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(1e20, &builder));
CHECK_EQ("100000000000000000000", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(111111111111111111111.0, &builder));
CHECK_EQ("111111111111111110000", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(1111111111111111111111.0, &builder));
CHECK_EQ("1.1111111111111111e+21", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(11111111111111111111111.0, &builder));
CHECK_EQ("1.1111111111111111e+22", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(-0.00001, &builder));
CHECK_EQ("-0.00001", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(-0.000001, &builder));
CHECK_EQ("-0.000001", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(-0.0000001, &builder));
CHECK_EQ("-1e-7", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(-0.0, &builder));
CHECK_EQ("0", builder.Finalize());
flags = DoubleToStringConverter::NO_FLAGS;
DoubleToStringConverter dc2(flags, NULL, NULL, 'e', -1, 1, 0, 0);
builder.Reset();
CHECK(dc2.ToShortest(0.1, &builder));
CHECK_EQ("0.1", builder.Finalize());
builder.Reset();
CHECK(dc2.ToShortest(0.01, &builder));
CHECK_EQ("1e-2", builder.Finalize());
builder.Reset();
CHECK(dc2.ToShortest(1.0, &builder));
CHECK_EQ("1", builder.Finalize());
builder.Reset();
CHECK(dc2.ToShortest(10.0, &builder));
CHECK_EQ("1e1", builder.Finalize());
builder.Reset();
CHECK(dc2.ToShortest(-0.0, &builder));
CHECK_EQ("-0", builder.Finalize());
flags = DoubleToStringConverter::EMIT_TRAILING_DECIMAL_POINT |
DoubleToStringConverter::EMIT_TRAILING_ZERO_AFTER_POINT;
DoubleToStringConverter dc3(flags, NULL, NULL, 'E', -5, 5, 0, 0);
builder.Reset();
CHECK(dc3.ToShortest(0.1, &builder));
CHECK_EQ("0.1", builder.Finalize());
builder.Reset();
CHECK(dc3.ToShortest(1.0, &builder));
CHECK_EQ("1.0", builder.Finalize());
builder.Reset();
CHECK(dc3.ToShortest(10000.0, &builder));
CHECK_EQ("10000.0", builder.Finalize());
builder.Reset();
CHECK(dc3.ToShortest(100000.0, &builder));
CHECK_EQ("1E5", builder.Finalize());
// Test the examples in the comments of ToShortest.
flags = DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN;
DoubleToStringConverter dc4(flags, NULL, NULL, 'e', -6, 21, 0, 0);
builder.Reset();
CHECK(dc4.ToShortest(0.000001, &builder));
CHECK_EQ("0.000001", builder.Finalize());
builder.Reset();
CHECK(dc4.ToShortest(0.0000001, &builder));
CHECK_EQ("1e-7", builder.Finalize());
builder.Reset();
CHECK(dc4.ToShortest(111111111111111111111.0, &builder));
CHECK_EQ("111111111111111110000", builder.Finalize());
builder.Reset();
CHECK(dc4.ToShortest(100000000000000000000.0, &builder));
CHECK_EQ("100000000000000000000", builder.Finalize());
builder.Reset();
CHECK(dc4.ToShortest(1111111111111111111111.0, &builder));
CHECK_EQ("1.1111111111111111e+21", builder.Finalize());
// Test special value handling.
DoubleToStringConverter dc5(flags, NULL, NULL, 'e', 0, 0, 0, 0);
builder.Reset();
CHECK(!dc5.ToShortest(Double::Infinity(), &builder));
builder.Reset();
CHECK(!dc5.ToShortest(-Double::Infinity(), &builder));
builder.Reset();
CHECK(!dc5.ToShortest(Double::NaN(), &builder));
builder.Reset();
CHECK(!dc5.ToShortest(-Double::NaN(), &builder));
DoubleToStringConverter dc6(flags, "Infinity", "NaN", 'e', 0, 0, 0, 0);
builder.Reset();
CHECK(dc6.ToShortest(Double::Infinity(), &builder));
CHECK_EQ("Infinity", builder.Finalize());
builder.Reset();
CHECK(dc6.ToShortest(-Double::Infinity(), &builder));
CHECK_EQ("-Infinity", builder.Finalize());
builder.Reset();
CHECK(dc6.ToShortest(Double::NaN(), &builder));
CHECK_EQ("NaN", builder.Finalize());
builder.Reset();
CHECK(dc6.ToShortest(-Double::NaN(), &builder));
CHECK_EQ("NaN", builder.Finalize());
}
TEST(DoubleToShortestSingle) {
const int kBufferSize = 128;
char buffer[kBufferSize];
StringBuilder builder(buffer, kBufferSize);
int flags = DoubleToStringConverter::UNIQUE_ZERO |
DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN;
DoubleToStringConverter dc(flags, NULL, NULL, 'e', -6, 21, 0, 0);
CHECK(dc.ToShortestSingle(0.0f, &builder));
CHECK_EQ("0", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortestSingle(12345.0f, &builder));
CHECK_EQ("12345", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortestSingle(12345e23f, &builder));
CHECK_EQ("1.2345e+27", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortestSingle(1e21f, &builder));
CHECK_EQ("1e+21", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortestSingle(1e20f, &builder));
CHECK_EQ("100000000000000000000", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortestSingle(111111111111111111111.0f, &builder));
CHECK_EQ("111111110000000000000", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortestSingle(1111111111111111111111.0f, &builder));
CHECK_EQ("1.11111114e+21", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortestSingle(11111111111111111111111.0f, &builder));
CHECK_EQ("1.1111111e+22", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortestSingle(-0.00001f, &builder));
CHECK_EQ("-0.00001", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortestSingle(-0.000001f, &builder));
CHECK_EQ("-0.000001", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortestSingle(-0.0000001f, &builder));
CHECK_EQ("-1e-7", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortestSingle(-0.0f, &builder));
CHECK_EQ("0", builder.Finalize());
flags = DoubleToStringConverter::NO_FLAGS;
DoubleToStringConverter dc2(flags, NULL, NULL, 'e', -1, 1, 0, 0);
builder.Reset();
CHECK(dc2.ToShortestSingle(0.1f, &builder));
CHECK_EQ("0.1", builder.Finalize());
builder.Reset();
CHECK(dc2.ToShortestSingle(0.01f, &builder));
CHECK_EQ("1e-2", builder.Finalize());
builder.Reset();
CHECK(dc2.ToShortestSingle(1.0f, &builder));
CHECK_EQ("1", builder.Finalize());
builder.Reset();
CHECK(dc2.ToShortestSingle(10.0f, &builder));
CHECK_EQ("1e1", builder.Finalize());
builder.Reset();
CHECK(dc2.ToShortestSingle(-0.0f, &builder));
CHECK_EQ("-0", builder.Finalize());
flags = DoubleToStringConverter::EMIT_TRAILING_DECIMAL_POINT |
DoubleToStringConverter::EMIT_TRAILING_ZERO_AFTER_POINT;
DoubleToStringConverter dc3(flags, NULL, NULL, 'E', -5, 5, 0, 0);
builder.Reset();
CHECK(dc3.ToShortestSingle(0.1f, &builder));
CHECK_EQ("0.1", builder.Finalize());
builder.Reset();
CHECK(dc3.ToShortestSingle(1.0f, &builder));
CHECK_EQ("1.0", builder.Finalize());
builder.Reset();
CHECK(dc3.ToShortestSingle(10000.0f, &builder));
CHECK_EQ("10000.0", builder.Finalize());
builder.Reset();
CHECK(dc3.ToShortestSingle(100000.0f, &builder));
CHECK_EQ("1E5", builder.Finalize());
// Test the examples in the comments of ToShortestSingle.
flags = DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN;
DoubleToStringConverter dc4(flags, NULL, NULL, 'e', -6, 21, 0, 0);
builder.Reset();
CHECK(dc4.ToShortestSingle(0.000001f, &builder));
CHECK_EQ("0.000001", builder.Finalize());
builder.Reset();
CHECK(dc4.ToShortestSingle(0.0000001f, &builder));
CHECK_EQ("1e-7", builder.Finalize());
builder.Reset();
CHECK(dc4.ToShortestSingle(111111111111111111111.0f, &builder));
CHECK_EQ("111111110000000000000", builder.Finalize());
builder.Reset();
CHECK(dc4.ToShortestSingle(100000000000000000000.0f, &builder));
CHECK_EQ("100000000000000000000", builder.Finalize());
builder.Reset();
CHECK(dc4.ToShortestSingle(1111111111111111111111.0f, &builder));
CHECK_EQ("1.11111114e+21", builder.Finalize());
// Test special value handling.
DoubleToStringConverter dc5(flags, NULL, NULL, 'e', 0, 0, 0, 0);
builder.Reset();
CHECK(!dc5.ToShortestSingle(Single::Infinity(), &builder));
builder.Reset();
CHECK(!dc5.ToShortestSingle(-Single::Infinity(), &builder));
builder.Reset();
CHECK(!dc5.ToShortestSingle(Single::NaN(), &builder));
builder.Reset();
CHECK(!dc5.ToShortestSingle(-Single::NaN(), &builder));
DoubleToStringConverter dc6(flags, "Infinity", "NaN", 'e', 0, 0, 0, 0);
builder.Reset();
CHECK(dc6.ToShortestSingle(Single::Infinity(), &builder));
CHECK_EQ("Infinity", builder.Finalize());
builder.Reset();
CHECK(dc6.ToShortestSingle(-Single::Infinity(), &builder));
CHECK_EQ("-Infinity", builder.Finalize());
builder.Reset();
CHECK(dc6.ToShortestSingle(Single::NaN(), &builder));
CHECK_EQ("NaN", builder.Finalize());
builder.Reset();
CHECK(dc6.ToShortestSingle(-Single::NaN(), &builder));
CHECK_EQ("NaN", builder.Finalize());
}
TEST(DoubleToFixed) {
const int kBufferSize = 128;
char buffer[kBufferSize];
StringBuilder builder(buffer, kBufferSize);
int flags = DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN |
DoubleToStringConverter::UNIQUE_ZERO;
DoubleToStringConverter dc(flags, "Infinity", "NaN", 'e',
0, 0, 0, 0); // Padding zeroes.
CHECK(dc.ToFixed(0.0, 0, &builder));
CHECK_EQ("0", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-0.0, 0, &builder));
CHECK_EQ("0", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-0.0, 1, &builder));
CHECK_EQ("0.0", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-0.0, 1, &builder));
CHECK_EQ("0.0", builder.Finalize());
ASSERT(DoubleToStringConverter::kMaxFixedDigitsBeforePoint == 60);
ASSERT(DoubleToStringConverter::kMaxFixedDigitsAfterPoint == 60);
builder.Reset();
CHECK(dc.ToFixed(
0.0, DoubleToStringConverter::kMaxFixedDigitsAfterPoint, &builder));
CHECK_EQ("0.000000000000000000000000000000000000000000000000000000000000",
builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(
9e59, DoubleToStringConverter::kMaxFixedDigitsAfterPoint, &builder));
CHECK_EQ("899999999999999918767229449717619953810131273674690656206848."
"000000000000000000000000000000000000000000000000000000000000",
builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(
-9e59, DoubleToStringConverter::kMaxFixedDigitsAfterPoint, &builder));
CHECK_EQ("-899999999999999918767229449717619953810131273674690656206848."
"000000000000000000000000000000000000000000000000000000000000",
builder.Finalize());
builder.Reset();
CHECK(!dc.ToFixed(
1e60, DoubleToStringConverter::kMaxFixedDigitsAfterPoint, &builder));
CHECK_EQ(0, builder.position());
builder.Reset();
CHECK(!dc.ToFixed(
9e59, DoubleToStringConverter::kMaxFixedDigitsAfterPoint + 1, &builder));
CHECK_EQ(0, builder.position());
builder.Reset();
CHECK(dc.ToFixed(3.0, 0, &builder));
CHECK_EQ("3", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(3.23, 1, &builder));
CHECK_EQ("3.2", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(3.23, 3, &builder));
CHECK_EQ("3.230", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(0.0323, 2, &builder));
CHECK_EQ("0.03", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(0.0373, 2, &builder));
CHECK_EQ("0.04", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(0.0000373, 2, &builder));
CHECK_EQ("0.00", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(1.5, 0, &builder));
CHECK_EQ("2", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(2.5, 0, &builder));
CHECK_EQ("3", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(3.5, 0, &builder));
CHECK_EQ("4", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(0.15, 1, &builder));
CHECK_EQ("0.1", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(0.25, 1, &builder));
CHECK_EQ("0.3", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(0.35, 1, &builder));
CHECK_EQ("0.3", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(0.45, 1, &builder));
CHECK_EQ("0.5", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(0.55, 1, &builder));
CHECK_EQ("0.6", builder.Finalize());
// Test positive/negative zeroes.
int flags2 = DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN;
DoubleToStringConverter dc2(flags2, "Infinity", "NaN", 'e',
0, 0, 0, 0); // Padding zeroes.
builder.Reset();
CHECK(dc2.ToFixed(0.0, 1, &builder));
CHECK_EQ("0.0", builder.Finalize());
builder.Reset();
CHECK(dc2.ToFixed(-0.0, 1, &builder));
CHECK_EQ("-0.0", builder.Finalize());
// Verify the trailing dot is emitted.
int flags3 = DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN |
DoubleToStringConverter::EMIT_TRAILING_DECIMAL_POINT;
DoubleToStringConverter dc3(flags3, "Infinity", "NaN", 'e',
0, 0, 0, 0); // Padding zeroes.
builder.Reset();
CHECK(dc3.ToFixed(0.0, 0, &builder));
CHECK_EQ("0.", builder.Finalize());
builder.Reset();
CHECK(dc3.ToFixed(-0.0, 0, &builder));
CHECK_EQ("-0.", builder.Finalize());
builder.Reset();
CHECK(dc3.ToFixed(1.0, 0, &builder));
CHECK_EQ("1.", builder.Finalize());
builder.Reset();
CHECK(dc3.ToFixed(-1.0, 0, &builder));
CHECK_EQ("-1.", builder.Finalize());
// Verify no trailing zero is emitted, even if the configuration is set.
// The given parameter takes precedence.
int flags4 = DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN |
DoubleToStringConverter::EMIT_TRAILING_DECIMAL_POINT |
DoubleToStringConverter::EMIT_TRAILING_ZERO_AFTER_POINT;
DoubleToStringConverter dc4(flags4, "Infinity", "NaN", 'e',
0, 0, 0, 0); // Padding zeroes.
builder.Reset();
CHECK(dc4.ToFixed(0.0, 0, &builder));
CHECK_EQ("0.0", builder.Finalize());
builder.Reset();
CHECK(dc4.ToFixed(-0.0, 0, &builder));
CHECK_EQ("-0.0", builder.Finalize());
builder.Reset();
CHECK(dc4.ToFixed(1.0, 0, &builder));
CHECK_EQ("1.0", builder.Finalize());
builder.Reset();
CHECK(dc4.ToFixed(-1.0, 0, &builder));
CHECK_EQ("-1.0", builder.Finalize());
// Test the examples in the comments of ToFixed.
flags = DoubleToStringConverter::NO_FLAGS;
DoubleToStringConverter dc5(flags, NULL, NULL, 'e', 0, 0, 0, 0);
builder.Reset();
CHECK(dc5.ToFixed(3.12, 1, &builder));
CHECK_EQ("3.1", builder.Finalize());
builder.Reset();
CHECK(dc5.ToFixed(3.1415, 3, &builder));
CHECK_EQ("3.142", builder.Finalize());
builder.Reset();
CHECK(dc5.ToFixed(1234.56789, 4, &builder));
CHECK_EQ("1234.5679", builder.Finalize());
builder.Reset();
CHECK(dc5.ToFixed(1.23, 5, &builder));
CHECK_EQ("1.23000", builder.Finalize());
builder.Reset();
CHECK(dc5.ToFixed(0.1, 4, &builder));
CHECK_EQ("0.1000", builder.Finalize());
builder.Reset();
CHECK(dc5.ToFixed(1e30, 2, &builder));
CHECK_EQ("1000000000000000019884624838656.00", builder.Finalize());
builder.Reset();
CHECK(dc5.ToFixed(0.1, 30, &builder));
CHECK_EQ("0.100000000000000005551115123126", builder.Finalize());
builder.Reset();
CHECK(dc5.ToFixed(0.1, 17, &builder));
CHECK_EQ("0.10000000000000001", builder.Finalize());
builder.Reset();
CHECK(dc5.ToFixed(123.45, 0, &builder));
CHECK_EQ("123", builder.Finalize());
builder.Reset();
CHECK(dc5.ToFixed(0.678, 0, &builder));
CHECK_EQ("1", builder.Finalize());
flags = DoubleToStringConverter::EMIT_TRAILING_DECIMAL_POINT;
DoubleToStringConverter dc6(flags, NULL, NULL, 'e', 0, 0, 0, 0);
builder.Reset();
CHECK(dc6.ToFixed(123.45, 0, &builder));
CHECK_EQ("123.", builder.Finalize());
builder.Reset();
CHECK(dc6.ToFixed(0.678, 0, &builder));
CHECK_EQ("1.", builder.Finalize());
flags = DoubleToStringConverter::EMIT_TRAILING_DECIMAL_POINT |
DoubleToStringConverter::EMIT_TRAILING_ZERO_AFTER_POINT;
DoubleToStringConverter dc7(flags, NULL, NULL, 'e', 0, 0, 0, 0);
builder.Reset();
CHECK(dc7.ToFixed(123.45, 0, &builder));
CHECK_EQ("123.0", builder.Finalize());
builder.Reset();
CHECK(dc7.ToFixed(0.678, 0, &builder));
CHECK_EQ("1.0", builder.Finalize());
// Test special value handling.
DoubleToStringConverter dc8(flags, NULL, NULL, 'e', 0, 0, 0, 0);
builder.Reset();
CHECK(!dc8.ToFixed(Double::Infinity(), 1, &builder));
builder.Reset();
CHECK(!dc8.ToFixed(-Double::Infinity(), 1, &builder));
builder.Reset();
CHECK(!dc8.ToFixed(Double::NaN(), 1, &builder));
builder.Reset();
CHECK(!dc8.ToFixed(-Double::NaN(), 1, &builder));
DoubleToStringConverter dc9(flags, "Infinity", "NaN", 'e', 0, 0, 0, 0);
builder.Reset();
CHECK(dc9.ToFixed(Double::Infinity(), 1, &builder));
CHECK_EQ("Infinity", builder.Finalize());
builder.Reset();
CHECK(dc9.ToFixed(-Double::Infinity(), 1, &builder));
CHECK_EQ("-Infinity", builder.Finalize());
builder.Reset();
CHECK(dc9.ToFixed(Double::NaN(), 1, &builder));
CHECK_EQ("NaN", builder.Finalize());
builder.Reset();
CHECK(dc9.ToFixed(-Double::NaN(), 1, &builder));
CHECK_EQ("NaN", builder.Finalize());
}
TEST(DoubleToExponential) {
const int kBufferSize = 256;
char buffer[kBufferSize];
int flags = DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN |
DoubleToStringConverter::UNIQUE_ZERO;
StringBuilder builder(buffer, kBufferSize);
DoubleToStringConverter dc(flags, "Infinity", "NaN", 'e', 0, 0, 0, 0);
builder.Reset();
CHECK(dc.ToExponential(0.0, 5, &builder));
CHECK_EQ("0.00000e+0", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(0.0, 0, &builder));
CHECK_EQ("0e+0", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(0.0, 1, &builder));
CHECK_EQ("0.0e+0", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(0.123456, 5, &builder));
CHECK_EQ("1.23456e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(1.2, 1, &builder));
CHECK_EQ("1.2e+0", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-0.0, 1, &builder));
CHECK_EQ("0.0e+0", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(0.0, 2, &builder));
CHECK_EQ("0.00e+0", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-0.0, 2, &builder));
CHECK_EQ("0.00e+0", builder.Finalize());
ASSERT(DoubleToStringConverter::kMaxExponentialDigits == 120);
builder.Reset();
CHECK(dc.ToExponential(
0.0, DoubleToStringConverter::kMaxExponentialDigits, &builder));
CHECK_EQ("0.00000000000000000000000000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000000000000000000000e+0",
builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(
9e59, DoubleToStringConverter::kMaxExponentialDigits, &builder));
CHECK_EQ("8.99999999999999918767229449717619953810131273674690656206848"
"0000000000000000000000000000000000000000000000000000000000000e+59",
builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(
-9e59, DoubleToStringConverter::kMaxExponentialDigits, &builder));
CHECK_EQ("-8.99999999999999918767229449717619953810131273674690656206848"
"0000000000000000000000000000000000000000000000000000000000000e+59",
builder.Finalize());
const double max_double = 1.7976931348623157e308;
builder.Reset();
CHECK(dc.ToExponential(
max_double, DoubleToStringConverter::kMaxExponentialDigits, &builder));
CHECK_EQ("1.79769313486231570814527423731704356798070567525844996598917"
"4768031572607800285387605895586327668781715404589535143824642e+308",
builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(0.000001, 2, &builder));
CHECK_EQ("1.00e-6", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(0.0000001, 2, &builder));
CHECK_EQ("1.00e-7", builder.Finalize());
// Test the examples in the comments of ToExponential.
flags = DoubleToStringConverter::NO_FLAGS;
DoubleToStringConverter dc2(flags, "Infinity", "NaN", 'e', 0, 0, 0, 0);
builder.Reset();
CHECK(dc2.ToExponential(3.12, 1, &builder));
CHECK_EQ("3.1e0", builder.Finalize());
builder.Reset();
CHECK(dc2.ToExponential(5.0, 3, &builder));
CHECK_EQ("5.000e0", builder.Finalize());
builder.Reset();
CHECK(dc2.ToExponential(0.001, 2, &builder));
CHECK_EQ("1.00e-3", builder.Finalize());
builder.Reset();
CHECK(dc2.ToExponential(3.1415, -1, &builder));
CHECK_EQ("3.1415e0", builder.Finalize());
builder.Reset();
CHECK(dc2.ToExponential(3.1415, 4, &builder));
CHECK_EQ("3.1415e0", builder.Finalize());
builder.Reset();
CHECK(dc2.ToExponential(3.1415, 3, &builder));
CHECK_EQ("3.142e0", builder.Finalize());
builder.Reset();
CHECK(dc2.ToExponential(123456789000000, 3, &builder));
CHECK_EQ("1.235e14", builder.Finalize());
builder.Reset();
CHECK(dc2.ToExponential(1000000000000000019884624838656.0, -1, &builder));
CHECK_EQ("1e30", builder.Finalize());
builder.Reset();
CHECK(dc2.ToExponential(1000000000000000019884624838656.0, 32, &builder));
CHECK_EQ("1.00000000000000001988462483865600e30", builder.Finalize());
builder.Reset();
CHECK(dc2.ToExponential(1234, 0, &builder));
CHECK_EQ("1e3", builder.Finalize());
// Test special value handling.
DoubleToStringConverter dc3(flags, NULL, NULL, 'e', 0, 0, 0, 0);
builder.Reset();
CHECK(!dc3.ToExponential(Double::Infinity(), 1, &builder));
builder.Reset();
CHECK(!dc3.ToExponential(-Double::Infinity(), 1, &builder));
builder.Reset();
CHECK(!dc3.ToExponential(Double::NaN(), 1, &builder));
builder.Reset();
CHECK(!dc3.ToExponential(-Double::NaN(), 1, &builder));
DoubleToStringConverter dc4(flags, "Infinity", "NaN", 'e', 0, 0, 0, 0);
builder.Reset();
CHECK(dc4.ToExponential(Double::Infinity(), 1, &builder));
CHECK_EQ("Infinity", builder.Finalize());
builder.Reset();
CHECK(dc4.ToExponential(-Double::Infinity(), 1, &builder));
CHECK_EQ("-Infinity", builder.Finalize());
builder.Reset();
CHECK(dc4.ToExponential(Double::NaN(), 1, &builder));
CHECK_EQ("NaN", builder.Finalize());
builder.Reset();
CHECK(dc4.ToExponential(-Double::NaN(), 1, &builder));
CHECK_EQ("NaN", builder.Finalize());
}
TEST(DoubleToPrecision) {
const int kBufferSize = 256;
char buffer[kBufferSize];
int flags = DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN |
DoubleToStringConverter::UNIQUE_ZERO;
StringBuilder builder(buffer, kBufferSize);
DoubleToStringConverter dc(flags, "Infinity", "NaN", 'e',
0, 0, // Padding zeroes for shortest mode.
6, 0); // Padding zeroes for precision mode.
ASSERT(DoubleToStringConverter::kMinPrecisionDigits == 1);
CHECK(dc.ToPrecision(0.0, 1, &builder));
CHECK_EQ("0", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(-0.0, 1, &builder));
CHECK_EQ("0", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(0.0, 2, &builder));
CHECK_EQ("0.0", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(-0.0, 2, &builder));
CHECK_EQ("0.0", builder.Finalize());
ASSERT(DoubleToStringConverter::kMaxPrecisionDigits == 120);
builder.Reset();
CHECK(dc.ToPrecision(
0.0, DoubleToStringConverter::kMaxPrecisionDigits, &builder));
CHECK_EQ("0.00000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000",
builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(
9e59, DoubleToStringConverter::kMaxPrecisionDigits, &builder));
CHECK_EQ("899999999999999918767229449717619953810131273674690656206848."
"000000000000000000000000000000000000000000000000000000000000",
builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(
-9e59, DoubleToStringConverter::kMaxPrecisionDigits, &builder));
CHECK_EQ("-899999999999999918767229449717619953810131273674690656206848."
"000000000000000000000000000000000000000000000000000000000000",
builder.Finalize());
const double max_double = 1.7976931348623157e308;
builder.Reset();
CHECK(dc.ToPrecision(
max_double, DoubleToStringConverter::kMaxPrecisionDigits, &builder));
CHECK_EQ("1.79769313486231570814527423731704356798070567525844996598917"
"476803157260780028538760589558632766878171540458953514382464e+308",
builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(0.000001, 2, &builder));
CHECK_EQ("0.0000010", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(0.0000001, 2, &builder));
CHECK_EQ("1.0e-7", builder.Finalize());
flags = DoubleToStringConverter::NO_FLAGS;
DoubleToStringConverter dc2(flags, NULL, NULL, 'e', 0, 0, 0, 1);
builder.Reset();
CHECK(dc2.ToPrecision(230.0, 2, &builder));
CHECK_EQ("230", builder.Finalize());
builder.Reset();
CHECK(dc2.ToPrecision(23.0, 2, &builder));
CHECK_EQ("23", builder.Finalize());
builder.Reset();
CHECK(dc2.ToPrecision(2.30, 2, &builder));
CHECK_EQ("2.3", builder.Finalize());
builder.Reset();
CHECK(dc2.ToPrecision(2300.0, 2, &builder));
CHECK_EQ("2.3e3", builder.Finalize());
flags = DoubleToStringConverter::EMIT_TRAILING_DECIMAL_POINT;
DoubleToStringConverter dc3(flags, NULL, NULL, 'e', 0, 0, 0, 1);
builder.Reset();
CHECK(dc3.ToPrecision(230.0, 2, &builder));
CHECK_EQ("230.", builder.Finalize());
builder.Reset();
CHECK(dc3.ToPrecision(23.0, 2, &builder));
CHECK_EQ("23.", builder.Finalize());
builder.Reset();
CHECK(dc3.ToPrecision(2.30, 2, &builder));
CHECK_EQ("2.3", builder.Finalize());
builder.Reset();
CHECK(dc3.ToPrecision(2300.0, 2, &builder));
CHECK_EQ("2.3e3", builder.Finalize());
flags = DoubleToStringConverter::EMIT_TRAILING_DECIMAL_POINT |
DoubleToStringConverter::EMIT_TRAILING_ZERO_AFTER_POINT;
DoubleToStringConverter dc4(flags, NULL, NULL, 'e', 0, 0, 0, 1);
builder.Reset();
CHECK(dc4.ToPrecision(230.0, 2, &builder));
CHECK_EQ("2.3e2", builder.Finalize());
builder.Reset();
CHECK(dc4.ToPrecision(23.0, 2, &builder));
CHECK_EQ("23.0", builder.Finalize());
builder.Reset();
CHECK(dc4.ToPrecision(2.30, 2, &builder));
CHECK_EQ("2.3", builder.Finalize());
builder.Reset();
CHECK(dc4.ToPrecision(2300.0, 2, &builder));
CHECK_EQ("2.3e3", builder.Finalize());
// Test the examples in the comments of ToPrecision.
flags = DoubleToStringConverter::NO_FLAGS;
DoubleToStringConverter dc5(flags, "Infinity", "NaN", 'e', 0, 0, 6, 1);
flags = DoubleToStringConverter::EMIT_TRAILING_DECIMAL_POINT;
DoubleToStringConverter dc6(flags, "Infinity", "NaN", 'e', 0, 0, 6, 1);
flags = DoubleToStringConverter::EMIT_TRAILING_DECIMAL_POINT |
DoubleToStringConverter::EMIT_TRAILING_ZERO_AFTER_POINT;
DoubleToStringConverter dc7(flags, "Infinity", "NaN", 'e', 0, 0, 6, 1);
builder.Reset();
CHECK(dc5.ToPrecision(0.0000012345, 2, &builder));
CHECK_EQ("0.0000012", builder.Finalize());
builder.Reset();
CHECK(dc5.ToPrecision(0.00000012345, 2, &builder));
CHECK_EQ("1.2e-7", builder.Finalize());
builder.Reset();
CHECK(dc5.ToPrecision(230.0, 2, &builder));
CHECK_EQ("230", builder.Finalize());
builder.Reset();
CHECK(dc6.ToPrecision(230.0, 2, &builder));
CHECK_EQ("230.", builder.Finalize());
builder.Reset();
CHECK(dc7.ToPrecision(230.0, 2, &builder));
CHECK_EQ("2.3e2", builder.Finalize());
flags = DoubleToStringConverter::NO_FLAGS;
DoubleToStringConverter dc8(flags, NULL, NULL, 'e', 0, 0, 6, 3);
builder.Reset();
CHECK(dc8.ToPrecision(123450.0, 6, &builder));
CHECK_EQ("123450", builder.Finalize());
builder.Reset();
CHECK(dc8.ToPrecision(123450.0, 5, &builder));
CHECK_EQ("123450", builder.Finalize());
builder.Reset();
CHECK(dc8.ToPrecision(123450.0, 4, &builder));
CHECK_EQ("123500", builder.Finalize());
builder.Reset();
CHECK(dc8.ToPrecision(123450.0, 3, &builder));
CHECK_EQ("123000", builder.Finalize());
builder.Reset();
CHECK(dc8.ToPrecision(123450.0, 2, &builder));
CHECK_EQ("1.2e5", builder.Finalize());
// Test special value handling.
builder.Reset();
CHECK(!dc8.ToPrecision(Double::Infinity(), 1, &builder));
builder.Reset();
CHECK(!dc8.ToPrecision(-Double::Infinity(), 1, &builder));
builder.Reset();
CHECK(!dc8.ToPrecision(Double::NaN(), 1, &builder));
builder.Reset();
CHECK(!dc8.ToPrecision(-Double::NaN(), 1, &builder));
builder.Reset();
CHECK(dc7.ToPrecision(Double::Infinity(), 1, &builder));
CHECK_EQ("Infinity", builder.Finalize());
builder.Reset();
CHECK(dc7.ToPrecision(-Double::Infinity(), 1, &builder));
CHECK_EQ("-Infinity", builder.Finalize());
builder.Reset();
CHECK(dc7.ToPrecision(Double::NaN(), 1, &builder));
CHECK_EQ("NaN", builder.Finalize());
builder.Reset();
CHECK(dc7.ToPrecision(-Double::NaN(), 1, &builder));
CHECK_EQ("NaN", builder.Finalize());
}
TEST(DoubleToStringJavaScript) {
const int kBufferSize = 128;
char buffer[kBufferSize];
StringBuilder builder(buffer, kBufferSize);
const DoubleToStringConverter& dc =
DoubleToStringConverter::EcmaScriptConverter();
builder.Reset();
CHECK(dc.ToShortest(Double::NaN(), &builder));
CHECK_EQ("NaN", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(Double::Infinity(), &builder));
CHECK_EQ("Infinity", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(-Double::Infinity(), &builder));
CHECK_EQ("-Infinity", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(0.0, &builder));
CHECK_EQ("0", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(9.0, &builder));
CHECK_EQ("9", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(90.0, &builder));
CHECK_EQ("90", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(90.12, &builder));
CHECK_EQ("90.12", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(0.1, &builder));
CHECK_EQ("0.1", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(0.01, &builder));
CHECK_EQ("0.01", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(0.0123, &builder));
CHECK_EQ("0.0123", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(111111111111111111111.0, &builder));
CHECK_EQ("111111111111111110000", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(100000000000000000000.0, &builder));
CHECK_EQ("100000000000000000000", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(1111111111111111111111.0, &builder));
CHECK_EQ("1.1111111111111111e+21", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(11111111111111111111111.0, &builder));
CHECK_EQ("1.1111111111111111e+22", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(0.00001, &builder));
CHECK_EQ("0.00001", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(0.000001, &builder));
CHECK_EQ("0.000001", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(0.0000001, &builder));
CHECK_EQ("1e-7", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(0.00000012, &builder));
CHECK_EQ("1.2e-7", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(0.000000123, &builder));
CHECK_EQ("1.23e-7", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(0.00000001, &builder));
CHECK_EQ("1e-8", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(0.000000012, &builder));
CHECK_EQ("1.2e-8", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(0.000000012, &builder));
CHECK_EQ("1.2e-8", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(0.0000000123, &builder));
CHECK_EQ("1.23e-8", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(-0.0, &builder));
CHECK_EQ("0", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(-9.0, &builder));
CHECK_EQ("-9", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(-90.0, &builder));
CHECK_EQ("-90", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(-90.12, &builder));
CHECK_EQ("-90.12", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(-0.1, &builder));
CHECK_EQ("-0.1", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(-0.01, &builder));
CHECK_EQ("-0.01", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(-0.0123, &builder));
CHECK_EQ("-0.0123", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(-111111111111111111111.0, &builder));
CHECK_EQ("-111111111111111110000", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(-1111111111111111111111.0, &builder));
CHECK_EQ("-1.1111111111111111e+21", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(-11111111111111111111111.0, &builder));
CHECK_EQ("-1.1111111111111111e+22", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(-0.00001, &builder));
CHECK_EQ("-0.00001", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(-0.000001, &builder));
CHECK_EQ("-0.000001", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(-0.0000001, &builder));
CHECK_EQ("-1e-7", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(-0.00000012, &builder));
CHECK_EQ("-1.2e-7", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(-0.000000123, &builder));
CHECK_EQ("-1.23e-7", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(-0.00000001, &builder));
CHECK_EQ("-1e-8", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(-0.000000012, &builder));
CHECK_EQ("-1.2e-8", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(-0.000000012, &builder));
CHECK_EQ("-1.2e-8", builder.Finalize());
builder.Reset();
CHECK(dc.ToShortest(-0.0000000123, &builder));
CHECK_EQ("-1.23e-8", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(Double::NaN(), 2, &builder));
CHECK_EQ("NaN", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(Double::Infinity(), 2, &builder));
CHECK_EQ("Infinity", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-Double::Infinity(), 2, &builder));
CHECK_EQ("-Infinity", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-0.1, 1, &builder));
CHECK_EQ("-0.1", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-0.1, 2, &builder));
CHECK_EQ("-0.10", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-0.1, 3, &builder));
CHECK_EQ("-0.100", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-0.01, 2, &builder));
CHECK_EQ("-0.01", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-0.01, 3, &builder));
CHECK_EQ("-0.010", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-0.01, 4, &builder));
CHECK_EQ("-0.0100", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-0.001, 2, &builder));
CHECK_EQ("-0.00", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-0.001, 3, &builder));
CHECK_EQ("-0.001", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-0.001, 4, &builder));
CHECK_EQ("-0.0010", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-1.0, 4, &builder));
CHECK_EQ("-1.0000", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-1.0, 1, &builder));
CHECK_EQ("-1.0", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-1.0, 0, &builder));
CHECK_EQ("-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-12.0, 0, &builder));
CHECK_EQ("-12", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-1.1, 0, &builder));
CHECK_EQ("-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-12.1, 0, &builder));
CHECK_EQ("-12", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-1.12, 0, &builder));
CHECK_EQ("-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-12.12, 0, &builder));
CHECK_EQ("-12", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-0.0000006, 7, &builder));
CHECK_EQ("-0.0000006", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-0.00000006, 8, &builder));
CHECK_EQ("-0.00000006", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-0.00000006, 9, &builder));
CHECK_EQ("-0.000000060", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-0.00000006, 10, &builder));
CHECK_EQ("-0.0000000600", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-0, 0, &builder));
CHECK_EQ("0", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-0, 1, &builder));
CHECK_EQ("0.0", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-0, 2, &builder));
CHECK_EQ("0.00", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(1000, 0, &builder));
CHECK_EQ("1000", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(0.00001, 0, &builder));
CHECK_EQ("0", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(0.00001, 5, &builder));
CHECK_EQ("0.00001", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(0.0000000000000000001, 20, &builder));
CHECK_EQ("0.00000000000000000010", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(0.00001, 17, &builder));
CHECK_EQ("0.00001000000000000", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(1000000000000000128.0, 0, &builder));
CHECK_EQ("1000000000000000128", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(1000000000000000128.0, 1, &builder));
CHECK_EQ("1000000000000000128.0", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(1000000000000000128.0, 2, &builder));
CHECK_EQ("1000000000000000128.00", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(1000000000000000128.0, 20, &builder));
CHECK_EQ("1000000000000000128.00000000000000000000", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(0.0, 0, &builder));
CHECK_EQ("0", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-42.0, 3, &builder));
CHECK_EQ("-42.000", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-1000000000000000128.0, 0, &builder));
CHECK_EQ("-1000000000000000128", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-0.0000000000000000001, 20, &builder));
CHECK_EQ("-0.00000000000000000010", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(0.123123123123123, 20, &builder));
CHECK_EQ("0.12312312312312299889", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(0.5, 0, &builder));
CHECK_EQ("1", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(-0.5, 0, &builder));
CHECK_EQ("-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(1.25, 1, &builder));
CHECK_EQ("1.3", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(234.20405, 4, &builder));
CHECK_EQ("234.2040", builder.Finalize());
builder.Reset();
CHECK(dc.ToFixed(234.2040506, 4, &builder));
CHECK_EQ("234.2041", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(1.0, -1, &builder));
CHECK_EQ("1e+0", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(11.0, -1, &builder));
CHECK_EQ("1.1e+1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(112.0, -1, &builder));
CHECK_EQ("1.12e+2", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(1.0, 0, &builder));
CHECK_EQ("1e+0", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(11.0, 0, &builder));
CHECK_EQ("1e+1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(112.0, 0, &builder));
CHECK_EQ("1e+2", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(1.0, 1, &builder));
CHECK_EQ("1.0e+0", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(11.0, 1, &builder));
CHECK_EQ("1.1e+1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(112.0, 1, &builder));
CHECK_EQ("1.1e+2", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(1.0, 2, &builder));
CHECK_EQ("1.00e+0", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(11.0, 2, &builder));
CHECK_EQ("1.10e+1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(112.0, 2, &builder));
CHECK_EQ("1.12e+2", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(1.0, 3, &builder));
CHECK_EQ("1.000e+0", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(11.0, 3, &builder));
CHECK_EQ("1.100e+1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(112.0, 3, &builder));
CHECK_EQ("1.120e+2", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(0.1, -1, &builder));
CHECK_EQ("1e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(0.11, -1, &builder));
CHECK_EQ("1.1e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(0.112, -1, &builder));
CHECK_EQ("1.12e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(0.1, 0, &builder));
CHECK_EQ("1e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(0.11, 0, &builder));
CHECK_EQ("1e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(0.112, 0, &builder));
CHECK_EQ("1e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(0.1, 1, &builder));
CHECK_EQ("1.0e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(0.11, 1, &builder));
CHECK_EQ("1.1e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(0.112, 1, &builder));
CHECK_EQ("1.1e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(0.1, 2, &builder));
CHECK_EQ("1.00e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(0.11, 2, &builder));
CHECK_EQ("1.10e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(0.112, 2, &builder));
CHECK_EQ("1.12e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(0.1, 3, &builder));
CHECK_EQ("1.000e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(0.11, 3, &builder));
CHECK_EQ("1.100e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(0.112, 3, &builder));
CHECK_EQ("1.120e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-1.0, -1, &builder));
CHECK_EQ("-1e+0", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-11.0, -1, &builder));
CHECK_EQ("-1.1e+1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-112.0, -1, &builder));
CHECK_EQ("-1.12e+2", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-1.0, 0, &builder));
CHECK_EQ("-1e+0", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-11.0, 0, &builder));
CHECK_EQ("-1e+1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-112.0, 0, &builder));
CHECK_EQ("-1e+2", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-1.0, 1, &builder));
CHECK_EQ("-1.0e+0", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-11.0, 1, &builder));
CHECK_EQ("-1.1e+1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-112.0, 1, &builder));
CHECK_EQ("-1.1e+2", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-1.0, 2, &builder));
CHECK_EQ("-1.00e+0", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-11.0, 2, &builder));
CHECK_EQ("-1.10e+1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-112.0, 2, &builder));
CHECK_EQ("-1.12e+2", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-1.0, 3, &builder));
CHECK_EQ("-1.000e+0", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-11.0, 3, &builder));
CHECK_EQ("-1.100e+1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-112.0, 3, &builder));
CHECK_EQ("-1.120e+2", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-0.1, -1, &builder));
CHECK_EQ("-1e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-0.11, -1, &builder));
CHECK_EQ("-1.1e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-0.112, -1, &builder));
CHECK_EQ("-1.12e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-0.1, 0, &builder));
CHECK_EQ("-1e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-0.11, 0, &builder));
CHECK_EQ("-1e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-0.112, 0, &builder));
CHECK_EQ("-1e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-0.1, 1, &builder));
CHECK_EQ("-1.0e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-0.11, 1, &builder));
CHECK_EQ("-1.1e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-0.112, 1, &builder));
CHECK_EQ("-1.1e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-0.1, 2, &builder));
CHECK_EQ("-1.00e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-0.11, 2, &builder));
CHECK_EQ("-1.10e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-0.112, 2, &builder));
CHECK_EQ("-1.12e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-0.1, 3, &builder));
CHECK_EQ("-1.000e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-0.11, 3, &builder));
CHECK_EQ("-1.100e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-0.112, 3, &builder));
CHECK_EQ("-1.120e-1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(Double::NaN(), 2, &builder));
CHECK_EQ("NaN", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(Double::Infinity(), 2, &builder));
CHECK_EQ("Infinity", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-Double::Infinity(), 2, &builder));
CHECK_EQ("-Infinity", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(1.0, 0, &builder));
CHECK_EQ("1e+0", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(0.0, -1, &builder));
CHECK_EQ("0e+0", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(0.0, 2, &builder));
CHECK_EQ("0.00e+0", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(11.2356, 0, &builder));
CHECK_EQ("1e+1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(11.2356, 4, &builder));
CHECK_EQ("1.1236e+1", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(0.000112356, 4, &builder));
CHECK_EQ("1.1236e-4", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-0.000112356, 4, &builder));
CHECK_EQ("-1.1236e-4", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(0.000112356, -1, &builder));
CHECK_EQ("1.12356e-4", builder.Finalize());
builder.Reset();
CHECK(dc.ToExponential(-0.000112356, -1, &builder));
CHECK_EQ("-1.12356e-4", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(Double::NaN(), 1, &builder));
CHECK_EQ("NaN", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(Double::Infinity(), 2, &builder));
CHECK_EQ("Infinity", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(-Double::Infinity(), 2, &builder));
CHECK_EQ("-Infinity", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(0.000555, 15, &builder));
CHECK_EQ("0.000555000000000000", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(0.000000555, 15, &builder));
CHECK_EQ("5.55000000000000e-7", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(-0.000000555, 15, &builder));
CHECK_EQ("-5.55000000000000e-7", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(123456789.0, 1, &builder));
CHECK_EQ("1e+8", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(123456789.0, 9, &builder));
CHECK_EQ("123456789", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(123456789.0, 8, &builder));
CHECK_EQ("1.2345679e+8", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(123456789.0, 7, &builder));
CHECK_EQ("1.234568e+8", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(-123456789.0, 7, &builder));
CHECK_EQ("-1.234568e+8", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(-.0000000012345, 2, &builder));
CHECK_EQ("-1.2e-9", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(-.000000012345, 2, &builder));
CHECK_EQ("-1.2e-8", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(-.00000012345, 2, &builder));
CHECK_EQ("-1.2e-7", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(-.0000012345, 2, &builder));
CHECK_EQ("-0.0000012", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(-.000012345, 2, &builder));
CHECK_EQ("-0.000012", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(-.00012345, 2, &builder));
CHECK_EQ("-0.00012", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(-.0012345, 2, &builder));
CHECK_EQ("-0.0012", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(-.012345, 2, &builder));
CHECK_EQ("-0.012", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(-.12345, 2, &builder));
CHECK_EQ("-0.12", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(-1.2345, 2, &builder));
CHECK_EQ("-1.2", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(-12.345, 2, &builder));
CHECK_EQ("-12", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(-123.45, 2, &builder));
CHECK_EQ("-1.2e+2", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(-1234.5, 2, &builder));
CHECK_EQ("-1.2e+3", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(-12345.0, 2, &builder));
CHECK_EQ("-1.2e+4", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(-12345.67, 4, &builder));
CHECK_EQ("-1.235e+4", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(-12344.67, 4, &builder));
CHECK_EQ("-1.234e+4", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(1.25, 2, &builder));
CHECK_EQ("1.3", builder.Finalize());
builder.Reset();
CHECK(dc.ToPrecision(1.35, 2, &builder));
CHECK_EQ("1.4", builder.Finalize());
}
static double StrToD16(const uc16* str16, int length, int flags,
double empty_string_value,
int* processed_characters_count, bool* processed_all) {
StringToDoubleConverter converter(flags, empty_string_value, Double::NaN(),
NULL, NULL);
double result =
converter.StringToDouble(str16, length, processed_characters_count);
*processed_all = (length == *processed_characters_count);
return result;
}
static double StrToD(const char* str, int flags, double empty_string_value,
int* processed_characters_count, bool* processed_all) {
StringToDoubleConverter converter(flags, empty_string_value, Double::NaN(),
NULL, NULL);
double result = converter.StringToDouble(str, strlen(str),
processed_characters_count);
*processed_all =
((strlen(str) == static_cast<unsigned>(*processed_characters_count)));
uc16 buffer16[256];
ASSERT(strlen(str) < ARRAY_SIZE(buffer16));
int len = strlen(str);
for (int i = 0; i < len; i++) {
buffer16[i] = str[i];
}
int processed_characters_count16;
bool processed_all16;
double result16 = StrToD16(buffer16, len, flags, empty_string_value,
&processed_characters_count16, &processed_all16);
CHECK_EQ(result, result16);
CHECK_EQ(*processed_characters_count, processed_characters_count16);
return result;
}
TEST(StringToDoubleVarious) {
int flags;
int processed;
bool all_used;
flags = StringToDoubleConverter::ALLOW_LEADING_SPACES |
StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN |
StringToDoubleConverter::ALLOW_TRAILING_SPACES;
CHECK_EQ(0.0, StrToD("", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0, StrToD("", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0, StrToD(" ", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0, StrToD(" ", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(42.0, StrToD("42", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(42.0, StrToD(" + 42 ", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-42.0, StrToD(" - 42 ", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD("x", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" x", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("42x", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("42 x", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" + 42 x", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" - 42 x", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
flags = StringToDoubleConverter::ALLOW_LEADING_SPACES |
StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN |
StringToDoubleConverter::ALLOW_TRAILING_SPACES |
StringToDoubleConverter::ALLOW_TRAILING_JUNK;
CHECK_EQ(0.0, StrToD("", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0, StrToD("", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0, StrToD(" ", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0, StrToD(" ", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(42.0, StrToD("42", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(42.0, StrToD(" + 42 ", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-42.0, StrToD(" - 42 ", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD("x", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" x", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(42.0, StrToD("42x", flags, 0.0, &processed, &all_used));
CHECK_EQ(2, processed);
CHECK_EQ(42.0, StrToD("42 x", flags, 0.0, &processed, &all_used));
CHECK_EQ(3, processed);
CHECK_EQ(42.0, StrToD(" + 42 x", flags, 0.0, &processed, &all_used));
CHECK_EQ(6, processed);
CHECK_EQ(-42.0, StrToD(" - 42 x", flags, 0.0, &processed, &all_used));
CHECK_EQ(6, processed);
flags = StringToDoubleConverter::ALLOW_LEADING_SPACES |
StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN |
StringToDoubleConverter::ALLOW_TRAILING_JUNK;
CHECK_EQ(0.0, StrToD("", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0, StrToD("", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0, StrToD(" ", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0, StrToD(" ", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(42.0, StrToD("42", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(42.0, StrToD(" + 42 ", flags, 0.0, &processed, &all_used));
CHECK_EQ(5, processed);
CHECK_EQ(-42.0, StrToD(" - 42 ", flags, 0.0, &processed, &all_used));
CHECK_EQ(5, processed);
CHECK_EQ(Double::NaN(), StrToD("x", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" x", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(42.0, StrToD("42x", flags, 0.0, &processed, &all_used));
CHECK_EQ(2, processed);
CHECK_EQ(42.0, StrToD("42 x", flags, 0.0, &processed, &all_used));
CHECK_EQ(2, processed);
CHECK_EQ(42.0, StrToD(" + 42 x", flags, 0.0, &processed, &all_used));
CHECK_EQ(5, processed);
CHECK_EQ(-42.0, StrToD(" - 42 x", flags, 0.0, &processed, &all_used));
CHECK_EQ(5, processed);
flags = StringToDoubleConverter::ALLOW_LEADING_SPACES |
StringToDoubleConverter::ALLOW_TRAILING_JUNK;
CHECK_EQ(42.0, StrToD(" +42 ", flags, 0.0, &processed, &all_used));
CHECK_EQ(4, processed);
CHECK_EQ(-42.0, StrToD(" -42 ", flags, 0.0, &processed, &all_used));
CHECK_EQ(4, processed);
CHECK_EQ(Double::NaN(), StrToD(" + 42 ", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" - 42 ", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
flags = StringToDoubleConverter::NO_FLAGS;
CHECK_EQ(0.0, StrToD("", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0, StrToD("", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD(" ", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" ", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(42.0, StrToD("42", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD(" + 42 ", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" - 42 ", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("x", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" x", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("42x", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("42 x", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" + 42 x", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" - 42 x", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
flags = StringToDoubleConverter::ALLOW_LEADING_SPACES;
CHECK_EQ(0.0, StrToD(" ", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0, StrToD(" ", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(42.0, StrToD(" 42", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD("42 ", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
flags = StringToDoubleConverter::ALLOW_TRAILING_SPACES;
CHECK_EQ(0.0, StrToD(" ", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0, StrToD(" ", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(42.0, StrToD("42 ", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD(" 42", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
}
TEST(StringToDoubleEmptyString) {
int flags;
int processed;
bool all_used;
flags = StringToDoubleConverter::NO_FLAGS;
CHECK_EQ(0.0, StrToD("", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0, StrToD("", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD("", flags, Double::NaN(),
&processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD(" ", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" ", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" ", flags, Double::NaN(),
&processed, &all_used));
CHECK_EQ(0, processed);
flags = StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN;
CHECK_EQ(0.0, StrToD("", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0, StrToD("", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD("", flags, Double::NaN(),
&processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD(" ", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" ", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" ", flags, Double::NaN(),
&processed, &all_used));
CHECK_EQ(0, processed);
flags = StringToDoubleConverter::ALLOW_LEADING_SPACES;
CHECK_EQ(0.0, StrToD("", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0, StrToD("", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD("", flags, Double::NaN(),
&processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0, StrToD(" ", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0, StrToD(" ", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD(" ", flags, Double::NaN(),
&processed, &all_used));
CHECK(all_used);
flags = StringToDoubleConverter::ALLOW_TRAILING_SPACES;
CHECK_EQ(0.0, StrToD("", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0, StrToD("", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD("", flags, Double::NaN(),
&processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0, StrToD(" ", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0, StrToD(" ", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD(" ", flags, Double::NaN(),
&processed, &all_used));
CHECK(all_used);
flags = StringToDoubleConverter::ALLOW_TRAILING_JUNK;
CHECK_EQ(0.0, StrToD("", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0, StrToD("", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD("", flags, Double::NaN(),
&processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD(" ", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" ", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" ", flags, Double::NaN(),
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("x", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" x", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
}
TEST(StringToDoubleHexString) {
int flags;
int processed;
bool all_used;
flags = StringToDoubleConverter::ALLOW_HEX |
StringToDoubleConverter::ALLOW_LEADING_SPACES |
StringToDoubleConverter::ALLOW_TRAILING_SPACES |
StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN;
CHECK_EQ(18.0, StrToD("0x12", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0, StrToD("0x0", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<double>(0x123456789),
StrToD("0x123456789", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(18.0, StrToD(" 0x12 ", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0, StrToD(" 0x0 ", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<double>(0x123456789),
StrToD(" 0x123456789 ", flags, Double::NaN(),
&processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<double>(0xabcdef),
StrToD("0xabcdef", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<double>(0xabcdef),
StrToD("0xABCDEF", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<double>(0xabcdef),
StrToD(" 0xabcdef ", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<double>(0xabcdef),
StrToD(" 0xABCDEF ", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD(" ", flags, Double::NaN(),
&processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD("0x", flags, 0.0,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 0x ", flags, 0.0,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 0x 3", flags, 0.0,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("0x3g", flags, 0.0,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("0x3.23", flags, 0.0,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("x3", flags, 0.0,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("0x3 foo", flags, 0.0,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 0x3 foo", flags, 0.0,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("+ 0x3 foo", flags, 0.0,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("+", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("-", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(-5.0, StrToD("-0x5", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-5.0, StrToD(" - 0x5 ", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(5.0, StrToD(" + 0x5 ", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD("- -0x5", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("- +0x5", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("+ +0x5", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
flags = StringToDoubleConverter::ALLOW_HEX;
CHECK_EQ(18.0, StrToD("0x12", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0, StrToD("0x0", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<double>(0x123456789),
StrToD("0x123456789", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD(" 0x12 ", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 0x0 ", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 0x123456789 ", flags, Double::NaN(),
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(static_cast<double>(0xabcdef),
StrToD("0xabcdef", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<double>(0xabcdef),
StrToD("0xABCDEF", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(),
StrToD(" 0xabcdef ", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" 0xABCDEF ", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" ", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("0x", flags, 0.0,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 0x ", flags, 0.0,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 0x 3", flags, 0.0,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("0x3g", flags, 0.0,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("0x3.23", flags, 0.0,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("x3", flags, 0.0,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("+ 0x3 foo", flags, 0.0,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("+", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("-", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(-5.0, StrToD("-0x5", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD(" - 0x5 ", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" + 0x5 ", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("- -0x5", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("- +0x5", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("+ +0x5", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
flags = StringToDoubleConverter::ALLOW_TRAILING_JUNK |
StringToDoubleConverter::ALLOW_HEX;
CHECK_EQ(18.0, StrToD("0x12", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0, StrToD("0x0", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<double>(0x123456789),
StrToD("0x123456789", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD(" 0x12 ", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 0x0 ", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(18.0, StrToD("0x12 ", flags, 0.0, &processed, &all_used));
CHECK_EQ(4, processed);
CHECK_EQ(0.0, StrToD("0x0 ", flags, 1.0, &processed, &all_used));
CHECK_EQ(3, processed);
CHECK_EQ(Double::NaN(),
StrToD(" 0x123456789 ", flags, Double::NaN(),
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(static_cast<double>(0xabcdef),
StrToD("0xabcdef", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<double>(0xabcdef),
StrToD("0xABCDEF", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(),
StrToD(" 0xabcdef ", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" 0xABCDEF ", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(static_cast<double>(0xabcdef),
StrToD("0xabcdef ", flags, 0.0, &processed, &all_used));
CHECK_EQ(8, processed);
CHECK_EQ(static_cast<double>(0xabcdef),
StrToD("0xABCDEF ", flags, 0.0, &processed, &all_used));
CHECK_EQ(8, processed);
CHECK_EQ(Double::NaN(),
StrToD(" 0xabcdef", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" 0xABCDEF", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" ", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("0x", flags, 0.0,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 0x ", flags, 0.0,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 0x 3", flags, 0.0,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(3.0, StrToD("0x3g", flags, 0.0, &processed, &all_used));
CHECK_EQ(3, processed);
CHECK_EQ(3.0, StrToD("0x3.234", flags, 0.0, &processed, &all_used));
CHECK_EQ(3, processed);
CHECK_EQ(Double::NaN(), StrToD(" 0x3g", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" 0x3.234", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("x3", flags, 0.0,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("+ 0x3 foo", flags, 0.0,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("+", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("-", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(-5.0, StrToD("-0x5", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD(" - 0x5 ", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" + 0x5 ", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("- -0x5", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("- +0x5", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("+ +0x5", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
flags = StringToDoubleConverter::ALLOW_TRAILING_JUNK |
StringToDoubleConverter::ALLOW_LEADING_SPACES |
StringToDoubleConverter::ALLOW_TRAILING_SPACES |
StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN |
StringToDoubleConverter::ALLOW_HEX;
CHECK_EQ(18.0, StrToD("0x12", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0, StrToD("0x0", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<double>(0x123456789),
StrToD("0x123456789", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(18.0, StrToD(" 0x12 ", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0, StrToD(" 0x0 ", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<double>(0x123456789),
StrToD(" 0x123456789 ", flags, Double::NaN(),
&processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<double>(0xabcdef),
StrToD("0xabcdef", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<double>(0xabcdef),
StrToD("0xABCDEF", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<double>(0xabcdef),
StrToD(" 0xabcdef ", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<double>(0xabcdef),
StrToD(" 0xABCDEF ", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<double>(0xabc),
StrToD(" 0xabc def ", flags, 0.0, &processed, &all_used));
CHECK_EQ(7, processed);
CHECK_EQ(static_cast<double>(0xabc),
StrToD(" 0xABC DEF ", flags, 0.0, &processed, &all_used));
CHECK_EQ(7, processed);
CHECK_EQ(static_cast<double>(0x12),
StrToD(" 0x12 ", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0, StrToD(" 0x0 ", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<double>(0x123456789),
StrToD(" 0x123456789 ", flags, Double::NaN(),
&processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD(" ", flags, Double::NaN(),
&processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD("0x", flags, 0.0,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 0x ", flags, 0.0,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 0x 3", flags, 0.0,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ((double)0x3, StrToD("0x3g", flags, 0.0, &processed, &all_used));
CHECK_EQ(3, processed);
CHECK_EQ((double)0x3, StrToD("0x3.234", flags, 0.0, &processed, &all_used));
CHECK_EQ(3, processed);
CHECK_EQ(Double::NaN(), StrToD("x3", flags, 0.0,
&processed, &all_used));
CHECK_EQ(0, processed);
}
TEST(StringToDoubleOctalString) {
int flags;
int processed;
bool all_used;
flags = StringToDoubleConverter::ALLOW_OCTALS |
StringToDoubleConverter::ALLOW_LEADING_SPACES |
StringToDoubleConverter::ALLOW_TRAILING_SPACES |
StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN;
CHECK_EQ(10.0, StrToD("012", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0, StrToD("00", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0, StrToD("012", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(123456789.0,
StrToD("0123456789", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0,
StrToD("01234567", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0,
StrToD("+01234567", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-342391.0,
StrToD("-01234567", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0, StrToD(" 012", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0, StrToD("\n012", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0, StrToD(" 00", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0, StrToD("\t00", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0, StrToD(" 012", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0, StrToD("\n012", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(123456789.0,
StrToD(" 0123456789", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0,
StrToD(" 01234567", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0,
StrToD("\n01234567", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0,
StrToD(" + 01234567", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-342391.0,
StrToD(" - 01234567", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-342391.0,
StrToD("\n-\t01234567", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0, StrToD(" 012 ", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0, StrToD(" 00 ", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0, StrToD(" 012 ", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(123456789.0,
StrToD(" 0123456789 ", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0,
StrToD(" 01234567 ", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0,
StrToD(" + 01234567 ", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-342391.0,
StrToD(" - 01234567 ", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0, StrToD("012 ", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0, StrToD("00 ", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0, StrToD("012 ", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(123456789.0,
StrToD("0123456789 ", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0,
StrToD("01234567 ", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0,
StrToD("+01234567", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-342391.0,
StrToD("-01234567", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(),
StrToD("01234567e0", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
flags = StringToDoubleConverter::ALLOW_OCTALS;
CHECK_EQ(10.0, StrToD("012", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0, StrToD("00", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0, StrToD("012", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(123456789.0,
StrToD("0123456789", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0,
StrToD("01234567", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0,
StrToD("+01234567", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-342391.0,
StrToD("-01234567", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD(" 012", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 00", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 012", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" 0123456789", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" 01234567", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" + 01234567", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" - 01234567", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 012 ", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 00 ", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 012 ", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" 0123456789 ", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" 01234567 ", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" + 01234567 ", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" - 01234567 ", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("012 ", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("00 ", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("012 ", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD("0123456789 ", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD("01234567 ", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(342391.0,
StrToD("+01234567", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-342391.0,
StrToD("-01234567", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(),
StrToD("01234567e0", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
flags = StringToDoubleConverter::ALLOW_OCTALS |
StringToDoubleConverter::ALLOW_TRAILING_JUNK;
CHECK_EQ(10.0, StrToD("012", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0, StrToD("00", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0, StrToD("012", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(123456789.0,
StrToD("0123456789", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0,
StrToD("01234567", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0,
StrToD("+01234567", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-342391.0,
StrToD("-01234567", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD(" 012", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 00", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 012", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" 0123456789", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" 01234567", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" + 01234567", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" - 01234567", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 012 ", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 00 ", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 012 ", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" 0123456789 ", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" 01234567 ", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" + 01234567 ", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" - 01234567 ", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(10.0, StrToD("012 ", flags, 0.0, &processed, &all_used));
CHECK_EQ(3, processed);
CHECK_EQ(0.0, StrToD("00 ", flags, 1.0, &processed, &all_used));
CHECK_EQ(2, processed);
CHECK_EQ(123456789.0,
StrToD("0123456789 ", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(10, processed);
CHECK_EQ(342391.0,
StrToD("01234567 ", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(8, processed);
CHECK_EQ(342391.0,
StrToD("+01234567", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-342391.0,
StrToD("-01234567", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0, StrToD("012foo ", flags, 0.0, &processed, &all_used));
CHECK_EQ(3, processed);
CHECK_EQ(0.0, StrToD("00foo ", flags, 1.0, &processed, &all_used));
CHECK_EQ(2, processed);
CHECK_EQ(123456789.0,
StrToD("0123456789foo ", flags, Double::NaN(),
&processed, &all_used));
CHECK_EQ(10, processed);
CHECK_EQ(342391.0,
StrToD("01234567foo ", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(8, processed);
CHECK_EQ(342391.0,
StrToD("+01234567foo", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(9, processed);
CHECK_EQ(-342391.0,
StrToD("-01234567foo", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(9, processed);
CHECK_EQ(10.0, StrToD("012 foo ", flags, 0.0, &processed, &all_used));
CHECK_EQ(3, processed);
CHECK_EQ(0.0, StrToD("00 foo ", flags, 1.0, &processed, &all_used));
CHECK_EQ(2, processed);
CHECK_EQ(123456789.0,
StrToD("0123456789 foo ", flags, Double::NaN(),
&processed, &all_used));
CHECK_EQ(10, processed);
CHECK_EQ(342391.0,
StrToD("01234567 foo ", flags, Double::NaN(),
&processed, &all_used));
CHECK_EQ(8, processed);
CHECK_EQ(342391.0,
StrToD("+01234567 foo", flags, Double::NaN(),
&processed, &all_used));
CHECK_EQ(9, processed);
CHECK_EQ(-342391.0,
StrToD("-01234567 foo", flags, Double::NaN(), &processed,
&all_used));
CHECK_EQ(9, processed);
CHECK_EQ(342391.0,
StrToD("01234567e0", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(8, processed);
CHECK_EQ(342391.0,
StrToD("01234567e", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(8, processed);
flags = StringToDoubleConverter::ALLOW_OCTALS |
StringToDoubleConverter::ALLOW_TRAILING_SPACES |
StringToDoubleConverter::ALLOW_TRAILING_JUNK;
CHECK_EQ(10.0, StrToD("012", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0, StrToD("00", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0, StrToD("012", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(123456789.0,
StrToD("0123456789", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0,
StrToD("01234567", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0,
StrToD("+01234567", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-342391.0,
StrToD("-01234567", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD(" 012", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 00", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 012", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" 0123456789", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" 01234567", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" + 01234567", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" - 01234567", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 012 ", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 00 ", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD(" 012 ", flags, 1.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" 0123456789 ", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" 01234567 ", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" + 01234567 ", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(),
StrToD(" - 01234567 ", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(10.0, StrToD("012 ", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0, StrToD("00 ", flags, 1.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(123456789.0,
StrToD("0123456789 ", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0,
StrToD("01234567 ", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0,
StrToD("+01234567", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-342391.0,
StrToD("-01234567", flags, Double::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0, StrToD("012foo ", flags, 0.0, &processed, &all_used));
CHECK_EQ(3, processed);
CHECK_EQ(0.0, StrToD("00foo ", flags, 1.0, &processed, &all_used));
CHECK_EQ(2, processed);
CHECK_EQ(123456789.0,
StrToD("0123456789foo ", flags, Double::NaN(),
&processed, &all_used));
CHECK_EQ(10, processed);
CHECK_EQ(342391.0,
StrToD("01234567foo ", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(8, processed);
CHECK_EQ(342391.0,
StrToD("+01234567foo", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(9, processed);
CHECK_EQ(-342391.0,
StrToD("-01234567foo", flags, Double::NaN(), &processed, &all_used));
CHECK_EQ(9, processed);
CHECK_EQ(10.0, StrToD("012 foo ", flags, 0.0, &processed, &all_used));
CHECK_EQ(4, processed);
CHECK_EQ(0.0, StrToD("00 foo ", flags, 1.0, &processed, &all_used));
CHECK_EQ(3, processed);
CHECK_EQ(123456789.0,
StrToD("0123456789 foo ", flags, Double::NaN(),
&processed, &all_used));
CHECK_EQ(11, processed);
CHECK_EQ(342391.0,
StrToD("01234567 foo ", flags, Double::NaN(),
&processed, &all_used));
CHECK_EQ(9, processed);
CHECK_EQ(342391.0,
StrToD("+01234567 foo", flags, Double::NaN(),
&processed, &all_used));
CHECK_EQ(10, processed);
CHECK_EQ(-342391.0,
StrToD("-01234567 foo", flags, Double::NaN(),
&processed, &all_used));
CHECK_EQ(10, processed);
}
TEST(StringToDoubleSpecialValues) {
int processed;
int flags = StringToDoubleConverter::NO_FLAGS;
{
// Use 1.0 as junk_string_value.
StringToDoubleConverter converter(flags, 0.0, 1.0, "infinity", "NaN");
CHECK_EQ(Double::NaN(), converter.StringToDouble("+NaN", 4, &processed));
CHECK_EQ(4, processed);
CHECK_EQ(-Double::Infinity(),
converter.StringToDouble("-infinity", 9, &processed));
CHECK_EQ(9, processed);
CHECK_EQ(1.0, converter.StringToDouble("Infinity", 8, &processed));
CHECK_EQ(0, processed);
CHECK_EQ(1.0, converter.StringToDouble("++NaN", 5, &processed));
CHECK_EQ(0, processed);
}
{
// Use 1.0 as junk_string_value.
StringToDoubleConverter converter(flags, 0.0, 1.0, "+infinity", "1NaN");
// The '+' is consumed before trying to match the infinity string.
CHECK_EQ(1.0, converter.StringToDouble("+infinity", 9, &processed));
CHECK_EQ(0, processed);
// The match for "1NaN" triggers, and doesn't let the 1234.0 complete.
CHECK_EQ(1.0, converter.StringToDouble("1234.0", 6, &processed));
CHECK_EQ(0, processed);
}
}
TEST(StringToDoubleCommentExamples) {
// Make sure the examples in the comments are correct.
int flags;
int processed;
bool all_used;
flags = StringToDoubleConverter::ALLOW_HEX;
CHECK_EQ(4660.0, StrToD("0x1234", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(),
StrToD("0x1234.56", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
flags |= StringToDoubleConverter::ALLOW_TRAILING_JUNK;
CHECK_EQ(4660.0,
StrToD("0x1234.56", flags, 0.0, &processed, &all_used));
CHECK_EQ(6, processed);
flags = StringToDoubleConverter::ALLOW_OCTALS;
CHECK_EQ(668.0, StrToD("01234", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(12349.0, StrToD("012349", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(),
StrToD("01234.56", flags, 0.0, &processed, &all_used));
CHECK_EQ(processed, 0);
flags |= StringToDoubleConverter::ALLOW_TRAILING_JUNK;
CHECK_EQ(668.0,
StrToD("01234.56", flags, 0.0, &processed, &all_used));
CHECK_EQ(processed, 5);
flags = StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN;
CHECK_EQ(-123.2, StrToD("- 123.2", flags, 0.0, &processed, &all_used));
CHECK(all_used);
flags = StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN;
CHECK_EQ(123.2, StrToD("+ 123.2", flags, 0.0, &processed, &all_used));
CHECK(all_used);
flags = StringToDoubleConverter::ALLOW_HEX |
StringToDoubleConverter::ALLOW_TRAILING_JUNK;
CHECK_EQ(4660.0, StrToD("0x1234", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(4660.0, StrToD("0x1234K", flags, 0.0, &processed, &all_used));
CHECK_EQ(processed, 6);
CHECK_EQ(0.0, StrToD("", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD(" ", flags, 0.0, &processed, &all_used));
CHECK_EQ(processed, 0);
CHECK_EQ(Double::NaN(), StrToD(" 1", flags, 0.0, &processed, &all_used));
CHECK_EQ(processed, 0);
CHECK_EQ(Double::NaN(), StrToD("0x", flags, 0.0, &processed, &all_used));
CHECK_EQ(processed, 0);
CHECK_EQ(-123.45, StrToD("-123.45", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(),
StrToD("--123.45", flags, 0.0, &processed, &all_used));
CHECK_EQ(processed, 0);
CHECK_EQ(123e45, StrToD("123e45", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(123e45, StrToD("123E45", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(123e45, StrToD("123e+45", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(123e-45, StrToD("123e-45", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(123.0, StrToD("123e", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(123.0, StrToD("123e-", flags, 0.0, &processed, &all_used));
CHECK(all_used);
{
StringToDoubleConverter converter(flags, 0.0, 1.0, "infinity", "NaN");
CHECK_EQ(Double::NaN(), converter.StringToDouble("+NaN", 4, &processed));
CHECK_EQ(4, processed);
CHECK_EQ(-Double::Infinity(),
converter.StringToDouble("-infinity", 9, &processed));
CHECK_EQ(9, processed);
CHECK_EQ(1.0, converter.StringToDouble("Infinity", 9, &processed));
CHECK_EQ(0, processed);
}
flags = StringToDoubleConverter::ALLOW_OCTALS |
StringToDoubleConverter::ALLOW_LEADING_SPACES;
CHECK_EQ(Double::NaN(), StrToD("0x1234", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(668.0, StrToD("01234", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0, StrToD("", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0, StrToD(" ", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0, StrToD(" 1", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToD("0x", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("0123e45", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(1239e45, StrToD("01239e45", flags, 0.0, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(),
StrToD("-infinity", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToD("NaN", flags, 0.0, &processed, &all_used));
CHECK_EQ(0, processed);
}
static float StrToF16(const uc16* str16, int length, int flags,
double empty_string_value,
int* processed_characters_count,
bool* processed_all) {
StringToDoubleConverter converter(flags, empty_string_value, Double::NaN(),
NULL, NULL);
double result =
converter.StringToFloat(str16, length, processed_characters_count);
*processed_all = (length == *processed_characters_count);
return result;
}
static double StrToF(const char* str, int flags, double empty_string_value,
int* processed_characters_count, bool* processed_all) {
StringToDoubleConverter converter(flags, empty_string_value, Single::NaN(),
NULL, NULL);
float result = converter.StringToFloat(str, strlen(str),
processed_characters_count);
*processed_all =
((strlen(str) == static_cast<unsigned>(*processed_characters_count)));
uc16 buffer16[256];
ASSERT(strlen(str) < ARRAY_SIZE(buffer16));
int len = strlen(str);
for (int i = 0; i < len; i++) {
buffer16[i] = str[i];
}
int processed_characters_count16;
bool processed_all16;
float result16 = StrToF16(buffer16, len, flags, empty_string_value,
&processed_characters_count16,
&processed_all16);
CHECK_EQ(result, result16);
CHECK_EQ(*processed_characters_count, processed_characters_count16);
return result;
}
TEST(StringToFloatVarious) {
int flags;
int processed;
bool all_used;
flags = StringToDoubleConverter::ALLOW_LEADING_SPACES |
StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN |
StringToDoubleConverter::ALLOW_TRAILING_SPACES;
CHECK_EQ(0.0f, StrToF("", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0f, StrToF("", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0f, StrToF(" ", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0f, StrToF(" ", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(42.0f, StrToF("42", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(42.0f, StrToF(" + 42 ", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-42.0f, StrToF(" - 42 ", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToF("x", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToF(" x", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToF("42x", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToF("42 x", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToF(" + 42 x", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToF(" - 42 x", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
flags = StringToDoubleConverter::ALLOW_LEADING_SPACES |
StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN |
StringToDoubleConverter::ALLOW_TRAILING_SPACES |
StringToDoubleConverter::ALLOW_TRAILING_JUNK;
CHECK_EQ(0.0f, StrToF("", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0f, StrToF("", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0f, StrToF(" ", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0f, StrToF(" ", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(42.0f, StrToF("42", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(42.0f, StrToF(" + 42 ", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-42.0f, StrToF(" - 42 ", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToF("x", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToF(" x", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(42.0f, StrToF("42x", flags, 0.0f, &processed, &all_used));
CHECK_EQ(2, processed);
CHECK_EQ(42.0f, StrToF("42 x", flags, 0.0f, &processed, &all_used));
CHECK_EQ(3, processed);
CHECK_EQ(42.0f, StrToF(" + 42 x", flags, 0.0f, &processed, &all_used));
CHECK_EQ(6, processed);
CHECK_EQ(-42.0f, StrToF(" - 42 x", flags, 0.0f, &processed, &all_used));
CHECK_EQ(6, processed);
flags = StringToDoubleConverter::ALLOW_LEADING_SPACES |
StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN |
StringToDoubleConverter::ALLOW_TRAILING_JUNK;
CHECK_EQ(0.0f, StrToF("", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0f, StrToF("", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0f, StrToF(" ", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0f, StrToF(" ", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(42.0f, StrToF("42", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(42.0f, StrToF(" + 42 ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(5, processed);
CHECK_EQ(-42.0f, StrToF(" - 42 ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(5, processed);
CHECK_EQ(Double::NaN(), StrToF("x", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToF(" x", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(42.0f, StrToF("42x", flags, 0.0f, &processed, &all_used));
CHECK_EQ(2, processed);
CHECK_EQ(42.0f, StrToF("42 x", flags, 0.0f, &processed, &all_used));
CHECK_EQ(2, processed);
CHECK_EQ(42.0f, StrToF(" + 42 x", flags, 0.0f, &processed, &all_used));
CHECK_EQ(5, processed);
CHECK_EQ(-42.0f, StrToF(" - 42 x", flags, 0.0f, &processed, &all_used));
CHECK_EQ(5, processed);
flags = StringToDoubleConverter::ALLOW_LEADING_SPACES |
StringToDoubleConverter::ALLOW_TRAILING_JUNK;
CHECK_EQ(42.0f, StrToF(" +42 ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(4, processed);
CHECK_EQ(-42.0f, StrToF(" -42 ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(4, processed);
CHECK_EQ(Double::NaN(), StrToF(" + 42 ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToF(" - 42 ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
flags = StringToDoubleConverter::NO_FLAGS;
CHECK_EQ(0.0f, StrToF("", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0f, StrToF("", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToF(" ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToF(" ", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(42.0f, StrToF("42", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToF(" + 42 ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToF(" - 42 ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToF("x", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToF(" x", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToF("42x", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToF("42 x", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToF(" + 42 x", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Double::NaN(), StrToF(" - 42 x", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
flags = StringToDoubleConverter::ALLOW_LEADING_SPACES;
CHECK_EQ(0.0f, StrToF(" ", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0f, StrToF(" ", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(42.0f, StrToF(" 42", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToF("42 ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
flags = StringToDoubleConverter::ALLOW_TRAILING_SPACES;
CHECK_EQ(0.0f, StrToF(" ", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0f, StrToF(" ", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(42.0f, StrToF("42 ", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Double::NaN(), StrToF(" 42", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
}
TEST(StringToFloatEmptyString) {
int flags;
int processed;
bool all_used;
flags = StringToDoubleConverter::NO_FLAGS;
CHECK_EQ(0.0f, StrToF("", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0f, StrToF("", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Single::NaN(), StrToF("", flags, Single::NaN(),
&processed, &all_used));
CHECK(all_used);
CHECK_EQ(Single::NaN(), StrToF(" ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" ", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" ", flags, Single::NaN(),
&processed, &all_used));
CHECK_EQ(0, processed);
flags = StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN;
CHECK_EQ(0.0f, StrToF("", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0f, StrToF("", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Single::NaN(), StrToF("", flags, Single::NaN(),
&processed, &all_used));
CHECK(all_used);
CHECK_EQ(Single::NaN(), StrToF(" ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" ", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" ", flags, Single::NaN(),
&processed, &all_used));
CHECK_EQ(0, processed);
flags = StringToDoubleConverter::ALLOW_LEADING_SPACES;
CHECK_EQ(0.0f, StrToF("", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0f, StrToF("", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Single::NaN(), StrToF("", flags, Single::NaN(),
&processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0f, StrToF(" ", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0f, StrToF(" ", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Single::NaN(), StrToF(" ", flags, Single::NaN(),
&processed, &all_used));
CHECK(all_used);
flags = StringToDoubleConverter::ALLOW_TRAILING_SPACES;
CHECK_EQ(0.0f, StrToF("", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0f, StrToF("", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Single::NaN(), StrToF("", flags, Single::NaN(),
&processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0f, StrToF(" ", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0f, StrToF(" ", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Single::NaN(), StrToF(" ", flags, Single::NaN(),
&processed, &all_used));
CHECK(all_used);
flags = StringToDoubleConverter::ALLOW_TRAILING_JUNK;
CHECK_EQ(0.0f, StrToF("", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(1.0f, StrToF("", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Single::NaN(), StrToF("", flags, Single::NaN(),
&processed, &all_used));
CHECK(all_used);
CHECK_EQ(Single::NaN(), StrToF(" ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" ", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" ", flags, Single::NaN(),
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("x", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" x", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
}
TEST(StringToFloatHexString) {
int flags;
int processed;
bool all_used;
double d;
float f;
flags = StringToDoubleConverter::ALLOW_HEX |
StringToDoubleConverter::ALLOW_LEADING_SPACES |
StringToDoubleConverter::ALLOW_TRAILING_SPACES |
StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN;
// Check that no double rounding occurs:
const char* double_rounding_example1 = "0x100000100000008";
d = StrToD(double_rounding_example1, flags, 0.0, &processed, &all_used);
f = StrToF(double_rounding_example1, flags, 0.0f, &processed, &all_used);
CHECK(f != static_cast<float>(d));
CHECK_EQ(72057602627862528.0f, StrToF(double_rounding_example1,
flags, 0.0f, &processed, &all_used));
CHECK(all_used);
const char* double_rounding_example2 = "0x1000002FFFFFFF8";
d = StrToD(double_rounding_example2, flags, 0.0, &processed, &all_used);
f = StrToF(double_rounding_example2, flags, 0.0f, &processed, &all_used);
CHECK(f != static_cast<float>(d));
CHECK_EQ(72057602627862528.0f, StrToF(double_rounding_example2,
flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(18.0f, StrToF("0x12", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0f, StrToF("0x0", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<float>(0x123456789),
StrToF("0x123456789", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(18.0f, StrToF(" 0x12 ", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0f, StrToF(" 0x0 ", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<float>(0x123456789),
StrToF(" 0x123456789 ", flags, Single::NaN(),
&processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<float>(0xabcdef),
StrToF("0xabcdef", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<float>(0xabcdef),
StrToF("0xABCDEF", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<float>(0xabcdef),
StrToF(" 0xabcdef ", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<float>(0xabcdef),
StrToF(" 0xABCDEF ", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Single::NaN(), StrToF(" ", flags, Single::NaN(),
&processed, &all_used));
CHECK(all_used);
CHECK_EQ(Single::NaN(), StrToF("0x", flags, 0.0f,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 0x ", flags, 0.0f,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 0x 3", flags, 0.0f,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("0x3g", flags, 0.0f,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("0x3.23", flags, 0.0f,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("x3", flags, 0.0f,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("0x3 foo", flags, 0.0f,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 0x3 foo", flags, 0.0f,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("+ 0x3 foo", flags, 0.0f,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("+", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("-", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(-5.0f, StrToF("-0x5", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-5.0f, StrToF(" - 0x5 ", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(5.0f, StrToF(" + 0x5 ", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Single::NaN(), StrToF("- -0x5", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("- +0x5", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("+ +0x5", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
flags = StringToDoubleConverter::ALLOW_HEX;
CHECK_EQ(18.0f, StrToF("0x12", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0f, StrToF("0x0", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<float>(0x123456789),
StrToF("0x123456789", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Single::NaN(), StrToF(" 0x12 ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 0x0 ", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 0x123456789 ", flags, Single::NaN(),
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(static_cast<float>(0xabcdef),
StrToF("0xabcdef", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<float>(0xabcdef),
StrToF("0xABCDEF", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Single::NaN(),
StrToF(" 0xabcdef ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" 0xABCDEF ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("0x", flags, 0.0f,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 0x ", flags, 0.0f,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 0x 3", flags, 0.0f,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("0x3g", flags, 0.0f,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("0x3.23", flags, 0.0f,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("x3", flags, 0.0f,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("+ 0x3 foo", flags, 0.0f,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("+", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("-", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(-5.0f, StrToF("-0x5", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Single::NaN(), StrToF(" - 0x5 ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" + 0x5 ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("- -0x5", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("- +0x5", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("+ +0x5", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
flags = StringToDoubleConverter::ALLOW_TRAILING_JUNK |
StringToDoubleConverter::ALLOW_HEX;
CHECK_EQ(18.0f, StrToF("0x12", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0f, StrToF("0x0", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<float>(0x123456789),
StrToF("0x123456789", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Single::NaN(), StrToF(" 0x12 ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 0x0 ", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(18.0f, StrToF("0x12 ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(4, processed);
CHECK_EQ(0.0f, StrToF("0x0 ", flags, 1.0f, &processed, &all_used));
CHECK_EQ(3, processed);
CHECK_EQ(Single::NaN(),
StrToF(" 0x123456789 ", flags, Single::NaN(),
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(static_cast<float>(0xabcdef),
StrToF("0xabcdef", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<float>(0xabcdef),
StrToF("0xABCDEF", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Single::NaN(),
StrToF(" 0xabcdef ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" 0xABCDEF ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(static_cast<float>(0xabcdef),
StrToF("0xabcdef ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(8, processed);
CHECK_EQ(static_cast<float>(0xabcdef),
StrToF("0xABCDEF ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(8, processed);
CHECK_EQ(Single::NaN(),
StrToF(" 0xabcdef", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" 0xABCDEF", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("0x", flags, 0.0f,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 0x ", flags, 0.0f,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 0x 3", flags, 0.0f,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(3.0f, StrToF("0x3g", flags, 0.0f, &processed, &all_used));
CHECK_EQ(3, processed);
CHECK_EQ(3.0f, StrToF("0x3.234", flags, 0.0f, &processed, &all_used));
CHECK_EQ(3, processed);
CHECK_EQ(Single::NaN(), StrToF(" 0x3g", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" 0x3.234", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("x3", flags, 0.0f,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("+ 0x3 foo", flags, 0.0f,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("+", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("-", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(-5.0f, StrToF("-0x5", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Single::NaN(), StrToF(" - 0x5 ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" + 0x5 ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("- -0x5", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("- +0x5", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("+ +0x5", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
flags = StringToDoubleConverter::ALLOW_TRAILING_JUNK |
StringToDoubleConverter::ALLOW_LEADING_SPACES |
StringToDoubleConverter::ALLOW_TRAILING_SPACES |
StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN |
StringToDoubleConverter::ALLOW_HEX;
CHECK_EQ(18.0f, StrToF("0x12", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0f, StrToF("0x0", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<float>(0x123456789),
StrToF("0x123456789", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(18.0f, StrToF(" 0x12 ", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0f, StrToF(" 0x0 ", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<float>(0x123456789),
StrToF(" 0x123456789 ", flags, Single::NaN(),
&processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<float>(0xabcdef),
StrToF("0xabcdef", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<float>(0xabcdef),
StrToF("0xABCDEF", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<float>(0xabcdef),
StrToF(" 0xabcdef ", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<float>(0xabcdef),
StrToF(" 0xABCDEF ", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<float>(0xabc),
StrToF(" 0xabc def ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(7, processed);
CHECK_EQ(static_cast<float>(0xabc),
StrToF(" 0xABC DEF ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(7, processed);
CHECK_EQ(static_cast<float>(0x12),
StrToF(" 0x12 ", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0f, StrToF(" 0x0 ", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(static_cast<float>(0x123456789),
StrToF(" 0x123456789 ", flags, Single::NaN(),
&processed, &all_used));
CHECK(all_used);
CHECK_EQ(Single::NaN(), StrToF(" ", flags, Single::NaN(),
&processed, &all_used));
CHECK(all_used);
CHECK_EQ(Single::NaN(), StrToF("0x", flags, 0.0f,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 0x ", flags, 0.0f,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 0x 3", flags, 0.0f,
&processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ((float)0x3, StrToF("0x3g", flags, 0.0f, &processed, &all_used));
CHECK_EQ(3, processed);
CHECK_EQ((float)0x3, StrToF("0x3.234", flags, 0.0f, &processed, &all_used));
CHECK_EQ(3, processed);
CHECK_EQ(Single::NaN(), StrToF("x3", flags, 0.0f,
&processed, &all_used));
CHECK_EQ(0, processed);
}
TEST(StringToFloatOctalString) {
int flags;
int processed;
bool all_used;
double d;
float f;
flags = StringToDoubleConverter::ALLOW_OCTALS |
StringToDoubleConverter::ALLOW_LEADING_SPACES |
StringToDoubleConverter::ALLOW_TRAILING_SPACES |
StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN;
// Check that no double rounding occurs:
const char* double_rounding_example1 = "04000000040000000010";
d = StrToD(double_rounding_example1, flags, 0.0, &processed, &all_used);
f = StrToF(double_rounding_example1, flags, 0.0f, &processed, &all_used);
CHECK(f != static_cast<float>(d));
CHECK_EQ(72057602627862528.0f, StrToF(double_rounding_example1,
flags, 0.0f, &processed, &all_used));
CHECK(all_used);
const char* double_rounding_example2 = "04000000137777777770";
d = StrToD(double_rounding_example2, flags, 0.0, &processed, &all_used);
f = StrToF(double_rounding_example2, flags, 0.0f, &processed, &all_used);
CHECK(f != static_cast<float>(d));
CHECK_EQ(72057602627862528.0f, StrToF(double_rounding_example2,
flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0f, StrToF("012", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0f, StrToF("00", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0f, StrToF("012", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(123456789.0f,
StrToF("0123456789", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0f,
StrToF("01234567", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0f,
StrToF("+01234567", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-342391.0f,
StrToF("-01234567", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0f, StrToF(" 012", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0f, StrToF(" 00", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0f, StrToF(" 012", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(123456789.0f,
StrToF(" 0123456789", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0f,
StrToF(" 01234567", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0f,
StrToF(" + 01234567", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-342391.0f,
StrToF(" - 01234567", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0f, StrToF(" 012 ", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0f, StrToF(" 00 ", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0f, StrToF(" 012 ", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(123456789.0f,
StrToF(" 0123456789 ", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0f,
StrToF(" 01234567 ", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0f,
StrToF(" + 01234567 ", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-342391.0f,
StrToF(" - 01234567 ", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0f, StrToF("012 ", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0f, StrToF("00 ", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0f, StrToF("012 ", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(123456789.0f,
StrToF("0123456789 ", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0f,
StrToF("01234567 ", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0f,
StrToF("+01234567", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-342391.0f,
StrToF("-01234567", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Single::NaN(),
StrToF("01234567e0", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
flags = StringToDoubleConverter::ALLOW_OCTALS;
CHECK_EQ(10.0f, StrToF("012", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0f, StrToF("00", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0f, StrToF("012", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(123456789.0f,
StrToF("0123456789", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0f,
StrToF("01234567", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0f,
StrToF("+01234567", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-342391.0f,
StrToF("-01234567", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Single::NaN(), StrToF(" 012", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 00", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 012", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" 0123456789", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" 01234567", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" + 01234567", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" - 01234567", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 012 ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 00 ", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 012 ", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" 0123456789 ", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" 01234567 ", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" + 01234567 ", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" - 01234567 ", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("012 ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("00 ", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF("012 ", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF("0123456789 ", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF("01234567 ", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(342391.0f,
StrToF("+01234567", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-342391.0f,
StrToF("-01234567", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Single::NaN(),
StrToF("01234567e0", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
flags = StringToDoubleConverter::ALLOW_OCTALS |
StringToDoubleConverter::ALLOW_TRAILING_JUNK;
CHECK_EQ(10.0f, StrToF("012", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0f, StrToF("00", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0f, StrToF("012", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(123456789.0f,
StrToF("0123456789", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0f,
StrToF("01234567", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0f,
StrToF("+01234567", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-342391.0f,
StrToF("-01234567", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Single::NaN(), StrToF(" 012", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 00", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 012", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" 0123456789", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" 01234567", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" + 01234567", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" - 01234567", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 012 ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 00 ", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 012 ", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" 0123456789 ", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" 01234567 ", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" + 01234567 ", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" - 01234567 ", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(10.0f, StrToF("012 ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(3, processed);
CHECK_EQ(0.0f, StrToF("00 ", flags, 1.0f, &processed, &all_used));
CHECK_EQ(2, processed);
CHECK_EQ(123456789.0f,
StrToF("0123456789 ", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(10, processed);
CHECK_EQ(342391.0f,
StrToF("01234567 ", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(8, processed);
CHECK_EQ(342391.0f,
StrToF("+01234567", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-342391.0f,
StrToF("-01234567", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0f, StrToF("012foo ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(3, processed);
CHECK_EQ(0.0f, StrToF("00foo ", flags, 1.0f, &processed, &all_used));
CHECK_EQ(2, processed);
CHECK_EQ(123456789.0f,
StrToF("0123456789foo ", flags, Single::NaN(),
&processed, &all_used));
CHECK_EQ(10, processed);
CHECK_EQ(342391.0f,
StrToF("01234567foo ", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(8, processed);
CHECK_EQ(342391.0f,
StrToF("+01234567foo", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(9, processed);
CHECK_EQ(-342391.0f,
StrToF("-01234567foo", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(9, processed);
CHECK_EQ(10.0f, StrToF("012 foo ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(3, processed);
CHECK_EQ(0.0f, StrToF("00 foo ", flags, 1.0f, &processed, &all_used));
CHECK_EQ(2, processed);
CHECK_EQ(123456789.0f,
StrToF("0123456789 foo ", flags, Single::NaN(),
&processed, &all_used));
CHECK_EQ(10, processed);
CHECK_EQ(342391.0f,
StrToF("01234567 foo ", flags, Single::NaN(),
&processed, &all_used));
CHECK_EQ(8, processed);
CHECK_EQ(342391.0f,
StrToF("+01234567 foo", flags, Single::NaN(),
&processed, &all_used));
CHECK_EQ(9, processed);
CHECK_EQ(-342391.0f,
StrToF("-01234567 foo", flags, Single::NaN(), &processed,
&all_used));
CHECK_EQ(9, processed);
CHECK_EQ(342391.0f,
StrToF("01234567e0", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(8, processed);
CHECK_EQ(342391.0f,
StrToF("01234567e", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(8, processed);
flags = StringToDoubleConverter::ALLOW_OCTALS |
StringToDoubleConverter::ALLOW_TRAILING_SPACES |
StringToDoubleConverter::ALLOW_TRAILING_JUNK;
CHECK_EQ(10.0f, StrToF("012", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0f, StrToF("00", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0f, StrToF("012", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(123456789.0f,
StrToF("0123456789", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0f,
StrToF("01234567", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0f,
StrToF("+01234567", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-342391.0f,
StrToF("-01234567", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(Single::NaN(), StrToF(" 012", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 00", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 012", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" 0123456789", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" 01234567", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" + 01234567", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" - 01234567", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 012 ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 00 ", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(), StrToF(" 012 ", flags, 1.0f, &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" 0123456789 ", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" 01234567 ", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" + 01234567 ", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(Single::NaN(),
StrToF(" - 01234567 ", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(0, processed);
CHECK_EQ(10.0f, StrToF("012 ", flags, 0.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(0.0f, StrToF("00 ", flags, 1.0f, &processed, &all_used));
CHECK(all_used);
CHECK_EQ(123456789.0f,
StrToF("0123456789 ", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0f,
StrToF("01234567 ", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(342391.0f,
StrToF("+01234567", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(-342391.0f,
StrToF("-01234567", flags, Single::NaN(), &processed, &all_used));
CHECK(all_used);
CHECK_EQ(10.0f, StrToF("012foo ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(3, processed);
CHECK_EQ(0.0f, StrToF("00foo ", flags, 1.0f, &processed, &all_used));
CHECK_EQ(2, processed);
CHECK_EQ(123456789.0f,
StrToF("0123456789foo ", flags, Single::NaN(),
&processed, &all_used));
CHECK_EQ(10, processed);
CHECK_EQ(342391.0f,
StrToF("01234567foo ", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(8, processed);
CHECK_EQ(342391.0f,
StrToF("+01234567foo", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(9, processed);
CHECK_EQ(-342391.0f,
StrToF("-01234567foo", flags, Single::NaN(), &processed, &all_used));
CHECK_EQ(9, processed);
CHECK_EQ(10.0f, StrToF("012 foo ", flags, 0.0f, &processed, &all_used));
CHECK_EQ(4, processed);
CHECK_EQ(0.0f, StrToF("00 foo ", flags, 1.0f, &processed, &all_used));
CHECK_EQ(3, processed);
CHECK_EQ(123456789.0f,
StrToF("0123456789 foo ", flags, Single::NaN(),
&processed, &all_used));
CHECK_EQ(11, processed);
CHECK_EQ(342391.0f,
StrToF("01234567 foo ", flags, Single::NaN(),
&processed, &all_used));
CHECK_EQ(9, processed);
CHECK_EQ(342391.0f,
StrToF("+01234567 foo", flags, Single::NaN(),
&processed, &all_used));
CHECK_EQ(10, processed);
CHECK_EQ(-342391.0f,
StrToF("-01234567 foo", flags, Single::NaN(),
&processed, &all_used));
CHECK_EQ(10, processed);
}
TEST(StringToFloatSpecialValues) {
int processed;
int flags = StringToDoubleConverter::NO_FLAGS;
{
// Use 1.0 as junk_string_value.
StringToDoubleConverter converter(flags, 0.0f, 1.0f, "infinity", "NaN");
CHECK_EQ(Single::NaN(), converter.StringToDouble("+NaN", 4, &processed));
CHECK_EQ(4, processed);
CHECK_EQ(-Single::Infinity(),
converter.StringToDouble("-infinity", 9, &processed));
CHECK_EQ(9, processed);
CHECK_EQ(1.0f, converter.StringToDouble("Infinity", 8, &processed));
CHECK_EQ(0, processed);
CHECK_EQ(1.0f, converter.StringToDouble("++NaN", 5, &processed));
CHECK_EQ(0, processed);
}
{
// Use 1.0 as junk_string_value.
StringToDoubleConverter converter(flags, 0.0f, 1.0f, "+infinity", "1NaN");
// The '+' is consumed before trying to match the infinity string.
CHECK_EQ(1.0f, converter.StringToDouble("+infinity", 9, &processed));
CHECK_EQ(0, processed);
// The match for "1NaN" triggers, and doesn't let the 1234.0 complete.
CHECK_EQ(1.0f, converter.StringToDouble("1234.0", 6, &processed));
CHECK_EQ(0, processed);
}
}
TEST(StringToDoubleFloatWhitespace) {
int flags;
int processed;
bool all_used;
flags = StringToDoubleConverter::ALLOW_LEADING_SPACES |
StringToDoubleConverter::ALLOW_TRAILING_SPACES |
StringToDoubleConverter::ALLOW_SPACES_AFTER_SIGN;
const char kWhitespaceAscii[] = {
0x0A, 0x0D, 0x09, 0x0B, 0x0C, 0x20,
'-',
0x0A, 0x0D, 0x09, 0x0B, 0x0C, 0x20,
'1', '.', '2',
0x0A, 0x0D, 0x09, 0x0B, 0x0C, 0x20,
0x00
};
CHECK_EQ(-1.2, StrToD(kWhitespaceAscii, flags, Double::NaN(),
&processed, &all_used));
CHECK(all_used);
CHECK_EQ(-1.2f, StrToF(kWhitespaceAscii, flags, Double::NaN(),
&processed, &all_used));
CHECK(all_used);
const uc16 kOghamSpaceMark = 0x1680;
const uc16 kMongolianVowelSeparator = 0x180E;
const uc16 kEnQuad = 0x2000;
const uc16 kEmQuad = 0x2001;
const uc16 kEnSpace = 0x2002;
const uc16 kEmSpace = 0x2003;
const uc16 kThreePerEmSpace = 0x2004;
const uc16 kFourPerEmSpace = 0x2005;
const uc16 kSixPerEmSpace = 0x2006;
const uc16 kFigureSpace = 0x2007;
const uc16 kPunctuationSpace = 0x2008;
const uc16 kThinSpace = 0x2009;
const uc16 kHairSpace = 0x200A;
const uc16 kNarrowNoBreakSpace = 0x202F;
const uc16 kMediumMathematicalSpace = 0x205F;
const uc16 kIdeographicSpace = 0x3000;
const uc16 kWhitespace16[] = {
0x0A, 0x0D, 0x09, 0x0B, 0x0C, 0x20, 0xA0, 0xFEFF,
kOghamSpaceMark, kMongolianVowelSeparator, kEnQuad, kEmQuad,
kEnSpace, kEmSpace, kThreePerEmSpace, kFourPerEmSpace, kSixPerEmSpace,
kFigureSpace, kPunctuationSpace, kThinSpace, kHairSpace,
kNarrowNoBreakSpace, kMediumMathematicalSpace, kIdeographicSpace,
'-',
0x0A, 0x0D, 0x09, 0x0B, 0x0C, 0x20, 0xA0, 0xFEFF,
kOghamSpaceMark, kMongolianVowelSeparator, kEnQuad, kEmQuad,
kEnSpace, kEmSpace, kThreePerEmSpace, kFourPerEmSpace, kSixPerEmSpace,
kFigureSpace, kPunctuationSpace, kThinSpace, kHairSpace,
kNarrowNoBreakSpace, kMediumMathematicalSpace, kIdeographicSpace,
'1', '.', '2',
0x0A, 0x0D, 0x09, 0x0B, 0x0C, 0x20, 0xA0, 0xFEFF,
kOghamSpaceMark, kMongolianVowelSeparator, kEnQuad, kEmQuad,
kEnSpace, kEmSpace, kThreePerEmSpace, kFourPerEmSpace, kSixPerEmSpace,
kFigureSpace, kPunctuationSpace, kThinSpace, kHairSpace,
kNarrowNoBreakSpace, kMediumMathematicalSpace, kIdeographicSpace,
};
const int kWhitespace16Length = ARRAY_SIZE(kWhitespace16);
CHECK_EQ(-1.2, StrToD16(kWhitespace16, kWhitespace16Length, flags,
Double::NaN(),
&processed, &all_used));
CHECK(all_used);
CHECK_EQ(-1.2f, StrToF16(kWhitespace16, kWhitespace16Length, flags,
Single::NaN(),
&processed, &all_used));
CHECK(all_used);
}
| [
"ulfjack@gmail.com"
] | ulfjack@gmail.com |
e599f9e3babd9141e4bfc8e5950eda801bb3d171 | 745b21e40fecda1397bf5adfffce2b4dbbb6b638 | /save_image_to_file/src/main.cpp | fbba9be6354fcce4fa59fcf552643ff79a328055 | [] | no_license | NiltonGMJunior/opencv-cpp | b6ffc636e24ab5d247b5f5a71cfe61bad0be3866 | 3d2873ad0f2cd0ee59f8733fa8f6bcbd5ddf9986 | refs/heads/master | 2020-06-04T23:30:49.198492 | 2019-06-17T12:33:12 | 2019-06-17T12:33:12 | 192,233,509 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 977 | cpp | #include <opencv2/opencv.hpp>
#include <iostream>
int main(int argc, char const *argv[])
{
cv::Mat image = cv::imread("../img/lena.png");
if(image.empty())
{
std::cout << "Could not open or find the image" << std::endl;
std::cin.get();
return -1;
}
// Make changes to the image before outputting it.
// In this example, the image is converted to greyscale.
cv::Mat image_greyscale;
cv::cvtColor(image, image_greyscale, cv::COLOR_BGR2GRAY);
bool isSuccess = cv::imwrite("../img/modified_lena.png", image_greyscale);
if(!isSuccess)
{
std::cout << "Failed to save the image" << std::endl;
std::cin.get();
return -1;
}
std::cout << "Image was successfully saved" << std::endl;
cv::String windowName = "The Saved Image";
cv::namedWindow(windowName);
cv::imshow(windowName, image_greyscale);
cv::waitKey(0);
cv::destroyWindow(windowName);
return 0;
}
| [
"nilton.junior51@hotmail.com"
] | nilton.junior51@hotmail.com |
d5e8d4edf1a49f4677a67ce4922459895813d58d | 3911760a8b34f5c095bb4e9d98c151b44eca1dec | /dcgmi/tests/TestCommandOutputController.h | 229135201362c3ecd29e71978154d97b105bc1d9 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | APX103/DCGM | 0e02caf874d090c75768b4a4fb07e4a5c7c5dedc | 7196e004c2bb7b30e07e3437da900b4cb42ba123 | refs/heads/master | 2023-07-22T20:39:24.621421 | 2021-09-01T23:43:05 | 2021-09-01T23:43:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,430 | h | /*
* Copyright (c) 2021, NVIDIA CORPORATION. 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 TESTCOMMANDOUTPUTCONTROLLER_H
#define TESTCOMMANDOUTPUTCONTROLLER_H
#include <string>
#include "TestDcgmiModule.h"
class TestCommandOutputController : public TestDcgmiModule
{
public:
TestCommandOutputController();
virtual ~TestCommandOutputController();
/*************************************************************************/
/* Inherited methods from TestNvcmModule */
int Run();
std::string GetTag();
private:
/*************************************************************************/
/*
* Actual test cases. These should return a status like below
*
* Returns 0 on success
* <0 on fatal error. Will abort entire framework
* >0 on non-fatal error
*
**/
int TestHelperDisplayValue();
};
#endif
| [
"dbeer@nvidia.com"
] | dbeer@nvidia.com |
2a5c60a87f5e113619c7b6cb602cad97027f3b64 | 12233a7b4af54ba605d5fe2b3f89c0ec8e1d39ca | /hello.cpp | 53cad246aaff9c2356cf993fd3e48dcb706ede36 | [] | no_license | icingjingjing/helloworld | d63f27017f81867baf5cf3785523e97664f0a804 | b715fd71f809b3484696594360a4f778cf1b1ee1 | refs/heads/master | 2022-11-11T23:51:02.336146 | 2020-07-13T07:31:21 | 2020-07-13T07:31:21 | 277,843,512 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,352 | cpp | #include <stdio.h>
#include "hello.h"
#include "algorithms.h"
//#define TEST_SORTING
//#define TEST_ADD
#define TEST_RBT
void testSorting()
{
printf("test Soring\n");
Sorting sort;
int A[] = {9, 8, 1, 3, 5, 7, 6, 2, 4, 0};
const int nSize = sizeof(A)/sizeof(int);
sort.InsertionSort(A, nSize);
for(int i = 0; i < nSize; i++)
{
printf("%d ", A[i]);
}
printf("\n");
}
void testAdd()
{
int a, b;
printf("test add intput a");
scanf("%d", &a);
printf("intput b");
scanf("%d", &b);
add(a, b);
}
void testRBT()
{
int A[] = {9, 8, 1, 3, 5, 7, 6, 2, 4, 0};
RBT tree(A, sizeof(A)/sizeof(int));
char cmd[16]={0};
int value = -1;
while(cmd[0] != 'q')
{
scanf("%s %d", cmd, &value);
if(cmd[0] == 'i')
{
tree.Insert(value);
printf("inserted %d\n", value);
}
else if(cmd[0] == 'f')
{
const RBTNode<int>*node = tree.Find(value);
if(node == nullptr)
printf("can't find %d\n", value);
while(node != nullptr)
{
printf("%d %s %s\n", node->value, node->color == BLACK ? "BLACK":"RED"
, node->parent == nullptr ? "root" : node == node->parent->right ? "right" : "left");
node = node->parent;
}
}
}
}
int main()
{
#ifdef TEST_SORTING
testSorting();
#endif
#ifdef TEST_ADD
testAdd();
#endif
#ifdef TEST_RBT
testRBT();
#endif
printf("press any key to exit");
getchar();
return 0;
}
| [
"158163215@qq.com"
] | 158163215@qq.com |
7b62dd4abd5f670ce8472da4a429e5875d371430 | 41575c498b7197e97b12a8ce2a880047df363cc3 | /src/local/vid/opengl/ViewContext.cpp | d8ac8bc607083baeeb57dd36cbebff8300797ca3 | [] | no_license | gongfuPanada/page | f00a6f9015b4aad79398f0df041613ab28be405b | fa2ccdef4b33480c2ac5f872d717323f45618a34 | refs/heads/master | 2021-01-15T22:09:34.836791 | 2013-03-23T18:54:13 | 2013-03-23T18:54:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 40,566 | cpp | /**
* @section license
*
* Copyright (c) 2006-2013 David Osborn
*
* Permission is granted to use and redistribute this software in source and
* binary form, with or without modification, subject to the following
* conditions:
*
* 1. Redistributions in source form 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, and in the same
* place and form as other copyright, license, and disclaimer information.
*
* As a special exception, distributions of derivative works in binary form may
* include an acknowledgement in place of the above copyright notice, this list
* of conditions, and the following disclaimer in the documentation and/or other
* materials provided with the distribution, and in the same place and form as
* other acknowledgements, similar in substance to the following:
*
* Portions of this software are based on the work of David Osborn.
*
* This software is provided "as is", without any express or implied warranty.
* In no event will the authors be liable for any damages arising out of the use
* of this software.
*/
#include <algorithm> // min
#include <cassert>
#include <cmath> // cos, sin
#include <GL/gl.h>
#include "../../cache/proxy/Aabb.hpp"
#include "../../cache/proxy/opengl/Drawable.hpp"
#include "../../cache/proxy/opengl/Texture.hpp"
#include "../../cfg/vars.hpp"
#include "../../cfg/vars.hpp"
#include "../../math/Color.hpp" // Rgb{,a}Color
#include "../../math/float.hpp" // DegToRad
#include "../../math/interp.hpp" // HermiteConvolutionKernel
#include "../../math/OrthoFrustum.hpp"
#include "../../math/Vector.hpp"
#include "../../math/ViewFrustum.hpp"
#include "../../phys/Form.hpp" // Form::{Get{Matrix,Parts},IsPosed,Part::{Get{Form,Material,Matrix},IsDeformed}}
#include "../../phys/Light.hpp" // Light::Get{Ambient,Cutoff,Diffuse,{Max,Min}Range,Normal,Position,Specular}
#include "../../phys/mixin/Collidable.hpp" // Collidable::Get{Position,Radius}
#include "../../res/type/Track.hpp"
#include "../Driver.hpp" // Driver::GetViewport
#include "activeTexture.hpp" // {,Can}AllocActiveTexture, GetActiveTextureIndex
#include "ActiveTextureSaver.hpp"
#include "blend.hpp" // ColorBlendFunc
#include "Drawable.hpp" // Drawable::Draw
#include "DrawContext.hpp" // DrawContext->vid::DrawContext, DrawContext::{{Begin,End}VolatileMatrix,Fill,Get{Frame,Resources}}
#include "Driver.hpp" // Driver->vid::Driver
#include "ext.hpp" // ARB_{multitexture,shader_objects,vertex_buffer_object}, EXT_blend_func_separate
#include "Framebuffer.hpp" // Framebuffer::GetPow2Size
#include "MatrixGuard.hpp"
#include "Program.hpp" // Bind, Program::GetUniform
#include "ProgramSaver.hpp"
#include "RenderTarget.hpp" // RenderTarget::framebuffer
#include "RenderTargetPool.hpp" // Bind, RenderTargetPool::{Get{,Size},Pooled}
#include "RenderTargetSaver.hpp"
#include "Resources.hpp" // Resources::{{Get,Has}{Program,RenderTargetPool,Shader{Outline,Render},Shadow,Texture},convolutionFilter[35][hv]Program,{rgbaComposite,rgbBlur}RenderTargetPool,whiteTexture}
#include "resources/ShaderMaterialResources.hpp" // ShaderMaterialResources::{GetProgram,MaterialMask}
#include "resources/ShaderOutlineResources.hpp" // ShaderOutlineResources::Get{Program,RenderTargetPool}
#include "resources/ShadowResources.hpp" // ShadowResources::{Get{Program,RenderTargetPool,Type},Type}
#include "Texture.hpp" // Bind
#include "ViewContext.hpp"
namespace page
{
namespace vid
{
namespace opengl
{
const float
shadowNear = -40,
shadowFar = 40,
shadowSize = 40;
namespace
{
// texture binding
void Bind(const res::Material::Pass::Texture &texture,
MatrixGuard &matrixGuard, TextureFormat format = defaultTextureFormat)
{
Bind(*cache::opengl::Texture(texture.image, format));
if (Any(texture.offset) || Any(texture.scale != 1))
{
glMatrixMode(GL_TEXTURE);
matrixGuard.Push();
glTranslatef(texture.offset.x, texture.offset.y, 0);
glScalef(texture.scale.x, texture.scale.y, 0);
}
}
}
// construct/destroy
ViewContext::ViewContext(Base &base, const math::ViewFrustum<> &frustum) :
vid::ViewContext(base, frustum)
{
// setup frame
// NOTE: moving frame into projection matrix to leave modelview
// matrix free for 3D positioning
glMatrixMode(GL_PROJECTION);
matrixGuard.Push();
math::Aabb<2> frame(base.GetFrame());
glTranslatef(frame.min.x, frame.min.y, 0);
math::Vector<2> frameSize(Size(frame));
glScalef(frameSize.x, frameSize.y, 1);
glOrtho(-3, 1, 3, -1, -1, 1);
// setup view frustum
glMultMatrixf(&*math::Matrix<4, 4, GLfloat>(GetProjMatrix(frustum)).begin());
glMatrixMode(GL_MODELVIEW);
matrixGuard.Push();
glLoadMatrixf(&*math::Matrix<4, 4, GLfloat>(GetViewMatrix(frustum)).begin());
// set default state
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glAlphaFunc(GL_GEQUAL, .5);
glEnable(GL_ALPHA_TEST);
glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
glClear(GL_DEPTH_BUFFER_BIT);
// mark matrix volatility
base.BeginVolatileMatrix();
}
ViewContext::~ViewContext()
{
GetBase().EndVolatileMatrix();
}
// base context access
ViewContext::Base &ViewContext::GetBase()
{
return static_cast<Base &>(vid::ViewContext::GetBase());
}
const ViewContext::Base &ViewContext::GetBase() const
{
return static_cast<const Base &>(vid::ViewContext::GetBase());
}
// scene rendering
void ViewContext::Draw(const phys::Scene &scene)
{
const Resources &res(GetBase().GetResources());
// retrieve visible forms
typedef phys::Scene::View<phys::Form>::Type Forms;
Forms forms(scene.GetVisibleForms(GetFrustum()));
// write early depth pass
// FIXME: this has a detrimental effect right now
/*{
AttribGuard attribGuard;
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
glDisable(GL_BLEND);
Draw(forms, zcullFixedType);
}
glDepthFunc(GL_EQUAL);
glDepthMask(GL_FALSE);*/
// retrieve scene lights
typedef phys::Scene::View<phys::Light>::Type Lights;
Lights lights(scene.GetInfluentialLights(GetFrustum()));
// select rendering path
if (*CVAR(opengl)::renderShader && res.HasShaderMaterial())
{
// perform shadow mapping
boost::optional<ShadowAttachment> shadowAttachment;
if (*CVAR(opengl)::renderShadow && res.HasShadow())
{
math::Vector<2, unsigned> shadowRenderTargetSize(
res.GetShadow().GetRenderTargetPool().GetSize());
math::Vector<3> shadowTexelSize(
shadowSize / shadowRenderTargetSize,
// FIXME: it shouldn't be necessary to round in the
// direction of the shadow
(shadowFar - shadowNear) / Max(shadowRenderTargetSize));
math::Matrix<3> sunMatrix(LookMatrix(scene.GetSunDirection(), math::NormVector<3>()));
math::OrthoFrustum<> shadowFrustum(
shadowNear, shadowFar, shadowSize, shadowSize,
sunMatrix * Round(Tpos(sunMatrix) * scene.GetFocus(), shadowTexelSize),
math::Quat<>(sunMatrix));
shadowAttachment = DrawShadow(shadowFrustum, forms);
}
// initialize lighting
AttribGuard attribGuard;
glPushAttrib(GL_LIGHTING_BIT);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, &*math::RgbaColor<GLfloat>(scene.GetAmbient()).begin());
glLightfv(GL_LIGHT0, GL_POSITION, &*math::Vector<4, GLfloat>(-scene.GetSunDirection(), 0).begin());
// draw opaque forms
Draw(forms, basicShaderType, shadowAttachment);
// draw transparent forms
// FIXME: implement
// draw emissive and specular glow
// TEST: disabled until we actually need emissive/specular
/*if (*CVAR(opengl)::renderGlow &&
res.HasProgram(Resources::convolutionFilter5hProgram) &&
res.HasProgram(Resources::convolutionFilter5vProgram) &&
res.HasRenderTargetPool(Resources::rgbBlurRenderTargetPool))
{
// draw emissive and specular to first glow buffer
AttribGuard attribGuard;
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
RenderTargetSaver renderTargetSaver;
Bind(glowRes.GetBuffer());
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
Draw(forms, emissiveSpecularShaderType, shadowAttachment);
// copy to second glow buffer with horizontal blur
Bind(glowRes.GetBuffer(), 1);
ProgramSaver programSaver;
Bind(blurRes.Get5hProgram());
glUniform1iARB(
blurRes.Get5hProgram().GetUniform("texSize").location,
glowRes.GetBuffer().GetPow2Size().x);
glDisable(GL_ALPHA_TEST);
glDisable(GL_DEPTH_TEST);
GetBase().Fill(glowRes.GetBuffer());
// add to parent buffer buffer with vertical blur
bufferSaver.Reset();
Bind(blurRes.Get5vProgram());
glUniform1iARB(
blurRes.Get5vProgram().GetUniform("texSize").location,
glowRes.GetBuffer().GetPow2Size().y);
glBlendFunc(GL_ONE, GL_ONE);
glEnable(GL_BLEND);
GetBase().Fill(glowRes.GetBuffer(), 1);
}*/
// draw outlines
if (*CVAR(opengl)::renderOutline &&
res.HasShaderOutline() &&
res.HasProgram(Resources::normalProgram))
{
const Resources::ShaderOutline &outlineRes(res.GetShaderOutline());
const Program &outlineProgram(outlineRes.GetProgram());
RenderTargetPool::Pooled outlineRenderTarget(outlineRes.GetRenderTargetPool().Get());
// render normals to first outline buffer
AttribGuard attribGuard;
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
RenderTargetSaver renderTargetSaver;
Bind(outlineRenderTarget);
glClearColor(0, 0, 1, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
Draw(forms, normalShaderType);
// copy to parent buffer with edge detection
renderTargetSaver.Reset();
ProgramSaver programSaver;
Bind(outlineProgram);
glUniform2ivARB(
outlineProgram.GetUniform("texSize").location, 1,
&*math::Vector<2, GLint>(outlineRenderTarget->framebuffer.GetPow2Size()).begin());
glDisable(GL_ALPHA_TEST);
glDisable(GL_DEPTH_TEST);
glBlendFunc(GL_DST_COLOR, GL_ZERO);
glEnable(GL_BLEND);
GetBase().Fill(*outlineRenderTarget);
}
}
else // fixed-function path
{
AttribGuard attribGuard;
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_LIGHTING_BIT);
// initialize lighting
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, &*math::RgbaColor<GLfloat>(scene.GetAmbient()).begin());
glLightfv(GL_LIGHT0, GL_POSITION, &*math::Vector<4, GLfloat>(-scene.GetSunDirection(), 0).begin());
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
// draw opaque forms
Draw(forms, basicFixedType);
// draw transparent forms
glDepthMask(GL_FALSE);
if (res.HasRenderTargetPool(Resources::rgbaCompositeRenderTargetPool))
{
glDisable(GL_ALPHA_TEST);
glBlendFunc(GL_ONE, GL_ONE);
glEnable(GL_BLEND);
// FIXME: implement; composite using alpha buffer
}
else
{
// FIXME: implement; render opaque if opacity >= 50%
}
// draw outlines
if (*CVAR(opengl)::renderOutline)
{
glDisable(GL_LIGHTING);
glDisable(GL_ALPHA_TEST);
glBlendFunc(GL_ONE, GL_ONE);
glEnable(GL_BLEND);
// FIXME: implement; use backface line primitives
}
}
// draw debug overlays
if (*CVAR(debugDrawTrack) && scene.HasTrack()) Draw(scene.GetTrack());
if (*CVAR(debugDrawCollision)) Draw(scene.GetVisibleCollidables(GetFrustum()));
if (*CVAR(debugDrawBounds)) DrawBounds(forms);
if (*CVAR(debugDrawSkeleton)) DrawSkeleton(forms);
}
// mesh rendering
void ViewContext::Draw(const phys::Form &form, ShaderType type, const boost::optional<ShadowAttachment> &shadow)
{
using std::bind;
using namespace std::placeholders;
Draw(form, bind(&ViewContext::PrepShaderMaterial, this, _1, _2, type, shadow),
*CVAR(opengl)::renderMultipass && type != shadowShaderType);
}
void ViewContext::Draw(const phys::Form &form, FixedType type)
{
using std::bind;
using namespace std::placeholders;
Draw(form, bind(&ViewContext::PrepFixedMaterial, this, _1, _2, type),
*CVAR(opengl)::renderMultipass && type != zcullFixedType);
}
void ViewContext::Draw(const phys::Scene::View<phys::Form>::Type &forms, ShaderType type, const boost::optional<ShadowAttachment> &shadow)
{
typedef phys::Scene::View<phys::Form>::Type Forms;
for (Forms::const_iterator iter(forms.begin()); iter != forms.end(); ++iter)
{
const phys::Form &form(**iter);
Draw(form, type, shadow);
}
}
void ViewContext::Draw(const phys::Scene::View<phys::Form>::Type &forms, FixedType type)
{
typedef phys::Scene::View<phys::Form>::Type Forms;
for (Forms::const_iterator iter(forms.begin()); iter != forms.end(); ++iter)
{
const phys::Form &form(**iter);
Draw(form, type);
}
}
// mesh rendering implementation
void ViewContext::Draw(const phys::Form &form, const PrepMaterialCallback &prepMaterialCallback, bool multipass)
{
// set matrix
glMatrixMode(GL_MODELVIEW);
MatrixGuard matrixGuard;
matrixGuard.Push();
glMultMatrixf(&*math::Matrix<4, 4, GLfloat>(form.GetMatrix()).begin());
// draw parts
for (phys::Form::Parts::const_iterator part(form.GetParts().begin()); part != form.GetParts().end(); ++part)
Draw(*part, prepMaterialCallback, multipass);
}
void ViewContext::Draw(const phys::Form::Part &part, const PrepMaterialCallback &prepMaterialCallback, bool multipass)
{
// set matrix
glMatrixMode(GL_MODELVIEW);
MatrixGuard matrixGuard;
matrixGuard.Push();
glMultMatrixf(&*math::Matrix<4, 4, GLfloat>(part.GetMatrix()).begin());
// draw part with material
ProgramSaver programSaver;
if (part.GetMaterial())
{
const res::Material &mat(*part.GetMaterial());
if (multipass && mat.passes.size() > 1)
{
// draw first pass to establish base
{
ActiveTextureSaver activeTextureSaver;
AttribGuard attribGuard;
MatrixGuard matrixGuard;
Draw(part, prepMaterialCallback(mat.passes.front(), matrixGuard));
}
// blend in remaining passes
AttribGuard attribGuard;
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDisable(GL_ALPHA_TEST);
if (haveExtBlendFuncSeparate)
ColorBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
else glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glDepthFunc(GL_EQUAL);
glDepthMask(GL_FALSE);
for (res::Material::Passes::const_iterator pass(mat.passes.begin() + 1); pass != mat.passes.end(); ++pass)
{
ActiveTextureSaver activeTextureSaver;
AttribGuard attribGuard;
glPushAttrib(GL_COLOR_BUFFER_BIT);
MatrixGuard matrixGuard;
Draw(part, prepMaterialCallback(*pass, matrixGuard));
}
}
else
{
// use single material pass
ActiveTextureSaver activeTextureSaver;
AttribGuard attribGuard;
MatrixGuard matrixGuard;
Draw(part, prepMaterialCallback(mat.passes.front(), matrixGuard));
}
}
else
{
// use default material
ActiveTextureSaver activeTextureSaver;
AttribGuard attribGuard;
MatrixGuard matrixGuard;
Draw(part, prepMaterialCallback(res::Material::Pass(), matrixGuard));
}
}
void ViewContext::Draw(const phys::Form::Part &part, const VertexFormat &vertexFormat)
{
cache::opengl::Drawable(part)->Draw(vertexFormat);
}
// shader material setup
VertexFormat ViewContext::PrepShaderMaterial(const res::Material::Pass &pass, MatrixGuard &matrixGuard, ShaderType type, const boost::optional<ShadowAttachment> &shadow)
{
assert(haveArbMultitexture);
assert(!GetActiveTextureIndex());
switch (type)
{
case basicShaderType: return PrepBasicShaderMaterial(pass, matrixGuard, shadow);
case emissiveSpecularShaderType: return PrepEmissiveSpecularShaderMaterial(pass, matrixGuard, shadow);
case normalShaderType: return PrepNormalShaderMaterial(pass, matrixGuard);
case shadowShaderType: return PrepShadowShaderMaterial(pass, matrixGuard);
default: assert(!"invalid shader type");
}
}
VertexFormat ViewContext::PrepBasicShaderMaterial(const res::Material::Pass &pass, MatrixGuard &matrixGuard, const boost::optional<ShadowAttachment> &shadow)
{
VertexFormat vertexFormat;
vertexFormat.normal = true;
glPushAttrib(GL_CURRENT_BIT);
// initialize shader
const Resources &res(GetBase().GetResources());
const Resources::ShaderMaterial &shaderMaterialResources(res.GetShaderMaterial());
Resources::ShaderMaterial::MaterialMask mask = Resources::ShaderMaterial::allMaterialMask;
if (!UseEmissiveSpecularGlow())
mask = static_cast<Resources::ShaderMaterial::MaterialMask>(
mask ^ (
Resources::ShaderMaterial::emissiveMaterialMask |
Resources::ShaderMaterial::specularMaterialMask));
if (!shadow)
mask = static_cast<Resources::ShaderMaterial::MaterialMask>(
mask ^ Resources::ShaderMaterial::shadowMaterialMask);
const Program &program(*shaderMaterialResources.GetProgram(pass, mask));
Bind(program);
// initialize diffuse texture
if (const Program::Uniform *uniform = program.FindUniform("diffuseSampler"))
{
assert(CanAllocActiveTexture());
AllocActiveTexture();
if (pass.diffuse.texture.image)
Bind(pass.diffuse.texture, matrixGuard);
else Bind(res.GetTexture(Resources::whiteTexture));
vertexFormat.uvIndices.push_back(pass.diffuse.texture.uvIndex);
glUniform1iARB(uniform->location, GetActiveTextureIndex());
}
// initialize diffuse color and mask value
math::RgbaColor<GLfloat> color(pass.diffuse.color);
color.a *= pass.mask.value;
glColor4fv(&*color.begin());
// initialize emissive texture
// FIXME: implement
// initialize emissive color
// FIXME: implement
// initialize fresnel texture
// FIXME: implement
// initialize fresnel color
// FIXME: implement
// initialize gloss texture
// FIXME: implement
// initialize gloss value
// FIXME: implement
// initialize mask texture
if (const Program::Uniform *uniform = program.FindUniform("maskSampler"))
{
assert(CanAllocActiveTexture());
AllocActiveTexture();
if (pass.mask.texture.image)
Bind(pass.mask.texture, matrixGuard, alphaTextureFormat);
else Bind(res.GetTexture(Resources::whiteTexture));
vertexFormat.uvIndices.push_back(pass.mask.texture.uvIndex);
glUniform1iARB(uniform->location, GetActiveTextureIndex());
}
// initialize normal texture
if (const Program::Uniform *uniform = program.FindUniform("normalSampler"))
{
// FIXME: implement
vertexFormat.tangent = true;
}
// initialize specular texture
// FIXME: implement
// initialize specular color
// FIXME: implement
// initialize shadow texture
if (const Program::Uniform *uniform = program.FindUniform("shadowSampler"))
{
assert(CanAllocActiveTexture());
AllocActiveTexture();
if (shadow)
{
glBindTexture(GL_TEXTURE_2D, GetTexture(shadow->renderTarget));
if (const Program::Uniform *uniform = program.FindUniform("shadowMatrix"))
glUniformMatrix4fvARB(uniform->location, 1, GL_FALSE,
&*math::Matrix<4, 4, GLfloat>(shadow->matrix).begin());
}
else Bind(res.GetTexture(Resources::whiteTexture));
glUniform1iARB(uniform->location, GetActiveTextureIndex());
}
return vertexFormat;
}
VertexFormat ViewContext::PrepEmissiveSpecularShaderMaterial(const res::Material::Pass &pass, MatrixGuard &matrixGuard, const boost::optional<ShadowAttachment> &shadow)
{
VertexFormat vertexFormat;
vertexFormat.normal = true;
glPushAttrib(GL_CURRENT_BIT);
// initialize shader
const Resources &res(GetBase().GetResources());
const Resources::ShaderMaterial &shaderMaterialResources(res.GetShaderMaterial());
Resources::ShaderMaterial::MaterialMask mask =
static_cast<Resources::ShaderMaterial::MaterialMask>(
Resources::ShaderMaterial::emissiveMaterialMask |
Resources::ShaderMaterial::specularMaterialMask);
if (shadow)
mask = static_cast<Resources::ShaderMaterial::MaterialMask>(
mask | Resources::ShaderMaterial::shadowMaterialMask);
const Program &program(*shaderMaterialResources.GetProgram(pass, mask));
Bind(program);
// initialize ambient color
if (const Program::Uniform *uniform = program.FindUniform("ambientColor"))
glUniform3fvARB(uniform->location, 1, &*math::RgbColor<GLfloat>().begin());
// initialize diffuse texture
if (const Program::Uniform *uniform = program.FindUniform("diffuseSampler"))
{
assert(CanAllocActiveTexture());
AllocActiveTexture();
if (pass.diffuse.texture.image)
Bind(pass.diffuse.texture, matrixGuard);
else Bind(res.GetTexture(Resources::whiteTexture));
vertexFormat.uvIndices.push_back(pass.diffuse.texture.uvIndex);
glUniform1iARB(uniform->location, GetActiveTextureIndex());
}
// initialize diffuse color and mask value
glColor4f(0, 0, 0, pass.diffuse.color.a * pass.mask.value);
// initialize emissive texture
// FIXME: implement
// initialize emissive color
// FIXME: implement
// initialize mask texture
if (const Program::Uniform *uniform = program.FindUniform("maskSampler"))
{
assert(CanAllocActiveTexture());
AllocActiveTexture();
if (pass.mask.texture.image)
Bind(pass.mask.texture, matrixGuard, alphaTextureFormat);
else Bind(res.GetTexture(Resources::whiteTexture));
vertexFormat.uvIndices.push_back(pass.mask.texture.uvIndex);
glUniform1iARB(uniform->location, GetActiveTextureIndex());
}
// initialize specular texture
// FIXME: implement
// initialize specular color
// FIXME: implement
// initialize shadow texture
if (const Program::Uniform *uniform = program.FindUniform("shadowSampler"))
{
assert(CanAllocActiveTexture());
AllocActiveTexture();
if (shadow)
{
glBindTexture(GL_TEXTURE_2D, GetTexture(shadow->renderTarget));
if (const Program::Uniform *uniform = program.FindUniform("shadowMatrix"))
glUniformMatrix4fvARB(uniform->location, 1, GL_FALSE,
&*math::Matrix<4, 4, GLfloat>(shadow->matrix).begin());
}
else Bind(res.GetTexture(Resources::whiteTexture));
glUniform1iARB(uniform->location, GetActiveTextureIndex());
}
return vertexFormat;
}
VertexFormat ViewContext::PrepNormalShaderMaterial(const res::Material::Pass &pass, MatrixGuard &matrixGuard)
{
VertexFormat vertexFormat;
vertexFormat.normal = true;
glPushAttrib(GL_CURRENT_BIT);
// initialize shader
const Resources &res(GetBase().GetResources());
const Program &program(res.GetProgram(Resources::normalProgram));
Bind(program);
// initialize diffuse color and mask value
glColor4f(1, 1, 1, pass.diffuse.color.a * pass.mask.value);
// initialize diffuse texture
if (const Program::Uniform *uniform = program.FindUniform("diffuseSampler"))
{
assert(CanAllocActiveTexture());
AllocActiveTexture();
if (pass.diffuse.texture.image)
Bind(pass.diffuse.texture, matrixGuard);
else Bind(res.GetTexture(Resources::whiteTexture));
vertexFormat.uvIndices.push_back(pass.diffuse.texture.uvIndex);
glUniform1iARB(uniform->location, GetActiveTextureIndex());
}
// initialize mask texture
if (const Program::Uniform *uniform = program.FindUniform("maskSampler"))
{
assert(CanAllocActiveTexture());
AllocActiveTexture();
if (pass.mask.texture.image)
Bind(pass.mask.texture, matrixGuard, alphaTextureFormat);
else Bind(res.GetTexture(Resources::whiteTexture));
vertexFormat.uvIndices.push_back(pass.mask.texture.uvIndex);
glUniform1iARB(uniform->location, GetActiveTextureIndex());
}
return vertexFormat;
}
VertexFormat ViewContext::PrepShadowShaderMaterial(const res::Material::Pass &pass, MatrixGuard &matrixGuard)
{
VertexFormat vertexFormat;
glPushAttrib(GL_CURRENT_BIT);
// initialize shader
const Resources &res(GetBase().GetResources());
const Resources::Shadow &shadowRes(res.GetShadow());
const Program &program(shadowRes.GetProgram());
Bind(program);
// initialize diffuse color and mask value
glColor4f(1, 1, 1, pass.diffuse.color.a * pass.mask.value);
// initialize diffuse texture
if (const Program::Uniform *uniform = program.FindUniform("diffuseSampler"))
{
assert(CanAllocActiveTexture());
AllocActiveTexture();
if (pass.diffuse.texture.image)
Bind(pass.diffuse.texture, matrixGuard);
else Bind(res.GetTexture(Resources::whiteTexture));
vertexFormat.uvIndices.push_back(pass.diffuse.texture.uvIndex);
glUniform1iARB(uniform->location, GetActiveTextureIndex());
}
// initialize mask texture
if (const Program::Uniform *uniform = program.FindUniform("maskSampler"))
{
assert(CanAllocActiveTexture());
AllocActiveTexture();
if (pass.mask.texture.image)
Bind(pass.mask.texture, matrixGuard, alphaTextureFormat);
else Bind(res.GetTexture(Resources::whiteTexture));
vertexFormat.uvIndices.push_back(pass.mask.texture.uvIndex);
glUniform1iARB(uniform->location, GetActiveTextureIndex());
}
return vertexFormat;
}
// fixed-function material setup
VertexFormat ViewContext::PrepFixedMaterial(const res::Material::Pass &pass, MatrixGuard &matrixGuard, FixedType type)
{
switch (type)
{
case basicFixedType: return PrepBasicFixedMaterial(pass, matrixGuard);
case zcullFixedType: return PrepZcullFixedMaterial(pass, matrixGuard);
default: assert(!"invalid fixed-function type");
}
}
VertexFormat ViewContext::PrepBasicFixedMaterial(const res::Material::Pass &pass, MatrixGuard &matrixGuard)
{
VertexFormat vertexFormat;
vertexFormat.normal = true;
glPushAttrib(GL_CURRENT_BIT);
// initialize diffuse color and mask value
math::RgbaColor<GLfloat> color(pass.diffuse.color);
color.a *= pass.mask.value;
glColor4fv(&*color.begin());
// initialize textures
if (haveArbMultitexture)
{
assert(!GetActiveTextureIndex());
glPushAttrib(GL_TEXTURE_BIT);
// initialize diffuse texture
if (pass.diffuse.texture.image && CanAllocActiveTexture())
{
AllocActiveTexture();
Bind(pass.diffuse.texture, matrixGuard);
glEnable(GL_TEXTURE_2D);
vertexFormat.uvIndices.push_back(pass.diffuse.texture.uvIndex);
}
// initialize emissive texture
// FIXME: implement
// initialize emissive color
// FIXME: implement
// initialize mask texture
if (pass.mask.texture.image && CanAllocActiveTexture())
{
AllocActiveTexture();
Bind(pass.mask.texture, matrixGuard, alphaTextureFormat);
glEnable(GL_TEXTURE_2D);
vertexFormat.uvIndices.push_back(pass.mask.texture.uvIndex);
}
// initialize specular texture
// FIXME: implement
// initialize specular color
// FIXME: implement
}
else
{
glPushAttrib(GL_ENABLE_BIT);
// initialize diffuse texture
if (pass.diffuse.texture.image)
{
Bind(pass.diffuse.texture, matrixGuard);
glEnable(GL_TEXTURE_2D);
vertexFormat.uvIndices.push_back(pass.diffuse.texture.uvIndex);
}
}
return vertexFormat;
}
VertexFormat ViewContext::PrepZcullFixedMaterial(const res::Material::Pass &pass, MatrixGuard &matrixGuard)
{
VertexFormat vertexFormat;
// initialize diffuse color and mask value
math::RgbaColor<GLfloat> color(pass.diffuse.color);
color.a *= pass.mask.value;
glColor4fv(&*color.begin());
// initialize textures
if (haveArbMultitexture)
{
assert(!GetActiveTextureIndex());
glPushAttrib(GL_ENABLE_BIT);
// initialize diffuse texture
if (pass.diffuse.texture.image && CanAllocActiveTexture())
{
AllocActiveTexture();
Bind(pass.diffuse.texture, matrixGuard);
glEnable(GL_TEXTURE_2D);
vertexFormat.uvIndices.push_back(pass.diffuse.texture.uvIndex);
}
// initialize mask texture
if (pass.mask.texture.image && CanAllocActiveTexture())
{
AllocActiveTexture();
Bind(pass.mask.texture, matrixGuard, alphaTextureFormat);
glEnable(GL_TEXTURE_2D);
vertexFormat.uvIndices.push_back(pass.mask.texture.uvIndex);
}
}
else
{
glPushAttrib(GL_ENABLE_BIT);
// initialize diffuse texture
if (pass.diffuse.texture.image)
{
Bind(pass.diffuse.texture, matrixGuard);
glEnable(GL_TEXTURE_2D);
vertexFormat.uvIndices.push_back(pass.diffuse.texture.uvIndex);
}
}
return vertexFormat;
}
// shadow rendering
ViewContext::ShadowAttachment ViewContext::DrawShadow(const math::OrthoFrustum<> &frustum, const phys::Scene::View<phys::Form>::Type &forms)
{
const Resources &res(GetBase().GetResources());
const Resources::Shadow &shadowRes(res.GetShadow());
// set shadow matrix
glMatrixMode(GL_PROJECTION);
MatrixGuard matrixGuard;
matrixGuard.Push();
glLoadMatrixf(&*math::Matrix<4, 4, GLfloat>(GetProjMatrix(frustum)).begin());
glMatrixMode(GL_MODELVIEW);
matrixGuard.Push();
glLoadMatrixf(&*math::Matrix<4, 4, GLfloat>(GetViewMatrix(frustum)).begin());
// render shadow map
const RenderTargetPool &shadowRenderTargetPool(shadowRes.GetRenderTargetPool());
RenderTargetPool::Pooled shadowRenderTarget(shadowRenderTargetPool.Get());
switch (shadowRes.GetType())
{
case Resources::Shadow::exponentialType:
case Resources::Shadow::varianceType:
{
AttribGuard attribGuard;
glPushAttrib(GL_COLOR_BUFFER_BIT);
RenderTargetSaver renderTargetSaver;
Bind(shadowRenderTarget);
glDisable(GL_ALPHA_TEST);
glDisable(GL_BLEND);
glClearColor(1, 1, 1, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
Draw(forms, shadowShaderType);
}
break;
case Resources::Shadow::packedType:
{
AttribGuard attribGuard;
glPushAttrib(GL_COLOR_BUFFER_BIT);
RenderTargetSaver renderTargetSaver;
Bind(shadowRenderTarget);
glDisable(GL_ALPHA_TEST);
glDisable(GL_BLEND);
glClearColor(1, 1, 1, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
Draw(forms, shadowShaderType);
}
break;
default: assert(!"invalid shadow type");
}
// blur shadow map
if (*CVAR(opengl)::renderShadowBlur)
{
const Program
*blurhProgram = 0,
*blurvProgram = 0;
switch (shadowRes.GetType())
{
case Resources::Shadow::exponentialType:
if (!res.HasProgram(Resources::expMeanFilter3hProgram) ||
!res.HasProgram(Resources::expMeanFilter3vProgram))
goto NoShadow;
blurhProgram = &res.GetProgram(Resources::expMeanFilter3hProgram);
blurvProgram = &res.GetProgram(Resources::expMeanFilter3vProgram);
break;
case Resources::Shadow::varianceType:
if (!res.HasProgram(Resources::meanFilter3hProgram) ||
!res.HasProgram(Resources::meanFilter3vProgram))
goto NoShadow;
blurhProgram = &res.GetProgram(Resources::meanFilter3hProgram);
blurvProgram = &res.GetProgram(Resources::meanFilter3vProgram);
break;
default: goto NoShadow;
}
assert(blurhProgram && blurvProgram);
RenderTargetPool::Pooled blurRenderTarget(shadowRenderTargetPool.Get());
// perform horizontal blur
AttribGuard attribGuard;
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
RenderTargetSaver renderTargetSaver;
Bind(blurRenderTarget);
ProgramSaver programSaver;
Bind(*blurhProgram);
glUniform1iARB(
blurhProgram->GetUniform("texSize").location,
shadowRenderTargetPool.GetPow2Size().x);
glDisable(GL_ALPHA_TEST);
glDisable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
GetBase().Fill(*shadowRenderTarget);
// perform vertical blur
Bind(shadowRenderTarget);
Bind(*blurvProgram);
glUniform1iARB(
blurvProgram->GetUniform("texSize").location,
shadowRenderTargetPool.GetPow2Size().y);
GetBase().Fill(*blurRenderTarget);
}
NoShadow:;
// return shadow attachment
ShadowAttachment shadowAttachment =
{
shadowRenderTarget,
GetMatrix(frustum) * GetInvViewMatrix(GetFrustum())
};
return shadowAttachment;
}
// debug rendering
void ViewContext::Draw(const res::Track &track)
{
// bias height to avoid Z fighting
glMatrixMode(GL_MODELVIEW);
MatrixGuard matrixGuard;
matrixGuard.Push();
glTranslatef(0, .001, 0);
// draw overlay
AttribGuard attribGuard;
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT | GL_DEPTH_BUFFER_BIT | GL_POLYGON_BIT);
glDisable(GL_ALPHA_TEST);
glDepthMask(GL_FALSE);
if (haveExtBlendFuncSeparate)
ColorBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
else glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glColor4f(1, 0, 0, .25);
glBegin(GL_TRIANGLES);
for (res::Track::Faces::const_iterator face(track.faces.begin()); face != track.faces.end(); ++face)
for (res::Track::Face::Vertices::const_iterator vertex(face->vertices.begin()); vertex != face->vertices.end(); ++vertex)
glVertex3fv(&*math::Vector<3, GLfloat>(*vertex).begin());
glEnd();
// draw wireframe
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glColor4f(0, 0, 0, .25);
glBegin(GL_TRIANGLES);
for (res::Track::Faces::const_iterator face(track.faces.begin()); face != track.faces.end(); ++face)
for (res::Track::Face::Vertices::const_iterator vertex(face->vertices.begin()); vertex != face->vertices.end(); ++vertex)
glVertex3fv(&*math::Vector<3, GLfloat>(*vertex).begin());
glEnd();
// draw boundaries
glColor3f(1, 1, 1);
glBegin(GL_LINES);
for (res::Track::Faces::const_iterator face(track.faces.begin()); face != track.faces.end(); ++face)
for (unsigned i = 0; i < 3; ++i)
if (!face->neighbours[i])
{
glVertex3fv(&*math::Vector<3, GLfloat>(face->vertices[i]).begin());
glVertex3fv(&*math::Vector<3, GLfloat>(face->vertices[(i + 1) % 3]).begin());
}
glEnd();
}
void ViewContext::Draw(const phys::Scene::View<phys::Collidable>::Type &collidables)
{
// bias height to avoid Z fighting
glMatrixMode(GL_MODELVIEW);
MatrixGuard matrixGuard;
matrixGuard.Push();
glTranslatef(0, .001, 0);
// draw collidable disks
AttribGuard attribGuard;
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDisable(GL_ALPHA_TEST);
glDepthMask(GL_FALSE);
if (haveExtBlendFuncSeparate)
ColorBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
else glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
typedef phys::Scene::View<phys::Collidable>::Type Collidables;
for (Collidables::const_iterator iter(collidables.begin()); iter != collidables.end(); ++iter)
{
const phys::Collidable &collidable(**iter);
math::Vector<3> center(collidable.GetPosition());
float radius = collidable.GetRadius();
glBegin(GL_LINE_LOOP);
for (float i = 0; i < 360; i += 20)
glVertex3f(
center.x + std::cos(math::DegToRad(i)) * radius,
center.y,
center.z + std::sin(math::DegToRad(i)) * radius);
glEnd();
}
}
void ViewContext::DrawBounds(const phys::Scene::View<phys::Form>::Type &forms)
{
typedef const phys::Scene::View<phys::Form>::Type Forms;
for (Forms::const_iterator iter(forms.begin()); iter != forms.end(); ++iter)
{
const phys::Form &form(**iter);
DrawBounds(form);
}
}
void ViewContext::DrawBounds(const phys::Form &form)
{
if (!form.GetModel()) return;
math::Aabb<3> aabb(*cache::Aabb(form));
AttribGuard attribGuard;
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDisable(GL_ALPHA_TEST);
glDisable(GL_DEPTH_TEST);
if (haveExtBlendFuncSeparate)
ColorBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
else glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glBegin(GL_LINE_LOOP);
glVertex3f(aabb.min.x, aabb.min.y, aabb.min.z);
glVertex3f(aabb.min.x, aabb.min.y, aabb.max.z);
glVertex3f(aabb.max.x, aabb.min.y, aabb.max.z);
glVertex3f(aabb.max.x, aabb.min.y, aabb.min.z);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex3f(aabb.min.x, aabb.max.y, aabb.min.z);
glVertex3f(aabb.min.x, aabb.max.y, aabb.max.z);
glVertex3f(aabb.max.x, aabb.max.y, aabb.max.z);
glVertex3f(aabb.max.x, aabb.max.y, aabb.min.z);
glEnd();
glBegin(GL_LINES);
glVertex3f(aabb.min.x, aabb.min.y, aabb.min.z);
glVertex3f(aabb.min.x, aabb.max.y, aabb.min.z);
glVertex3f(aabb.min.x, aabb.min.y, aabb.max.z);
glVertex3f(aabb.min.x, aabb.max.y, aabb.max.z);
glVertex3f(aabb.max.x, aabb.min.y, aabb.max.z);
glVertex3f(aabb.max.x, aabb.max.y, aabb.max.z);
glVertex3f(aabb.max.x, aabb.min.y, aabb.min.z);
glVertex3f(aabb.max.x, aabb.max.y, aabb.min.z);
glEnd();
}
void ViewContext::DrawSkeleton(const phys::Scene::View<phys::Form>::Type &forms)
{
typedef phys::Scene::View<phys::Form>::Type Forms;
for (Forms::const_iterator iter(forms.begin()); iter != forms.end(); ++iter)
{
const phys::Form &form(**iter);
DrawSkeleton(form);
}
}
void ViewContext::DrawSkeleton(const phys::attrib::Pose &pose)
{
glMatrixMode(GL_MODELVIEW);
MatrixGuard matrixGuard;
matrixGuard.Push();
glMultMatrixf(&*math::Matrix<4, 4, GLfloat>(pose.GetMatrix()).begin());
// draw posed skeleton
AttribGuard attribGuard;
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT | GL_DEPTH_BUFFER_BIT);
glDisable(GL_ALPHA_TEST);
glDisable(GL_DEPTH_TEST);
if (haveExtBlendFuncSeparate)
ColorBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
else glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glBegin(GL_LINES);
for (phys::Form::ConstBoneIterator bone(pose.BeginBones()); bone != pose.EndBones(); ++bone)
{
math::Vector<3, GLfloat> pos(GetTranslation(bone->GetPoseMatrix()));
// draw basis
math::Vector<3, GLfloat> axes[3] =
{
bone->GetPoseMatrix() * math::Vector<3>(.1, 0, 0),
bone->GetPoseMatrix() * math::Vector<3>(0, .1, 0),
bone->GetPoseMatrix() * math::Vector<3>(0, 0, .1)
};
glColor4f(1.f, 0.f, 0.f, .5);
glVertex3fv(&*pos.begin());
glVertex3fv(&*axes[0].begin());
glColor4f(0.f, 1.f, 0.f, .5);
glVertex3fv(&*pos.begin());
glVertex3fv(&*axes[1].begin());
glColor4f(0.f, 0.f, 1.f, .5);
glVertex3fv(&*pos.begin());
glVertex3fv(&*axes[2].begin());
// draw connections
if (const phys::Form::Bone *parent = bone->GetParent())
{
math::Vector<3, GLfloat> end(GetTranslation(parent->GetPoseMatrix()));
glColor4f(0.f, 0.f, 0.f, .5f);
glVertex3fv(&*pos.begin());
glVertex3fv(&*end.begin());
}
}
glEnd();
}
// decisions
bool ViewContext::UseEmissiveSpecularGlow() const
{
// FIXME: methinks this function is not good because it is so
// distant from the actual implementation such that if the
// implementation changes, this function may be forgotten
const Resources &res(GetBase().GetResources());
return
*CVAR(opengl)::renderGlow &&
res.HasProgram(Resources::convolutionFilter5hProgram) &&
res.HasProgram(Resources::convolutionFilter5vProgram) &&
res.HasRenderTargetPool(Resources::rgbBlurRenderTargetPool);
}
}
}
}
| [
"davidcosborn@gmail.com"
] | davidcosborn@gmail.com |
c4d162399aa0c995aac52e87bae89562aa477c27 | b591fbbd37b9b5e81d8f308f61d607fe7b145ed7 | /include/RE/B/BSLightingShaderMaterialEye.h | 09d664dc261a9029fc83e38170b5d012b567f282 | [
"MIT"
] | permissive | aquilae/CommonLibSSE | f6a1d321b16f2eb1e296f1154d697bd4bed549b6 | b8e6a72875b22c91dd125202dfc6a54f91cda597 | refs/heads/master | 2023-02-02T16:45:00.368879 | 2020-12-15T03:58:22 | 2020-12-15T03:58:22 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,363 | h | #pragma once
#include "RE/B/BSLightingShaderMaterialBase.h"
#include "RE/N/NiPoint3.h"
#include "RE/N/NiSmartPointer.h"
namespace RE
{
class NiSourceTexture;
class BSLightingShaderMaterialEye : public BSLightingShaderMaterialBase
{
public:
inline static constexpr auto RTTI = RTTI_BSLightingShaderMaterialEye;
virtual ~BSLightingShaderMaterialEye(); // 00
// override (BSLightingShaderMaterialBase)
virtual BSShaderMaterial* Create() override; // 01
virtual void CopyMembers(BSShaderMaterial* a_other) override; // 02
virtual std::uint32_t ComputeCRC32(void) override; // 04
virtual Feature GetFeature() const override; // 06 - { return Feature::kEye; }
virtual void OnLoadTextureSet(void) override; // 08
virtual void ClearTextures(void) override; // 09
virtual void ReceiveValuesFromRootMaterial(void) override; // 0A
virtual void GetTextures(void) override; // 0B
virtual void SaveBinary(void) override; // 0C
virtual void LoadBinary(void) override; // 0D
// members
NiPointer<NiSourceTexture> envTexture; // A0
NiPointer<NiSourceTexture> envMaskTexture; // A8
float envMapScale; // B0
NiPoint3 eyeCenter[2]; // B4
std::uint32_t padC8; // CC
};
static_assert(sizeof(BSLightingShaderMaterialEye) == 0xD0);
}
| [
"ryan__mckenzie@hotmail.com"
] | ryan__mckenzie@hotmail.com |
29086aed4713e300dc0a7e086c0b80b7af9ff5ca | c563f27c3bab7883d7a3e67ff1d8dbaf6f93224f | /0012 - Highly divisible triangular number.cpp | 5a4c5b307f2ac05e6b81135e90d2bf883a24b701 | [] | no_license | MusfiqDehan/Project-Euler | 58ef650b526c1b01a8dacca53ba0501c5cf5db19 | 8a4fcd5e01b34fdd26ec5448a2fe0f5d43c4e638 | refs/heads/master | 2022-12-07T10:46:11.771750 | 2020-08-30T13:57:11 | 2020-08-30T13:57:11 | 272,605,540 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,043 | cpp | #include <bits/stdc++.h>
using namespace std;
typedef unsigned int ui;
const ui maxDivisors = 1000;
int main ()
{
vector<ui> smallest;
smallest.push_back(0);
ui index = 0;
ui triangle = 0;
while (smallest.size() < maxDivisors)
{
index++;
triangle += index;
if (smallest.size() > 300 && triangle % 10 != 0)
{
continue;
}
ui divisors = 0;
ui i = 1;
while (i * i < triangle)
{
if (triangle % i == 0) {
divisors += 2;
}
i++;
}
if (i * i == triangle) {
divisors++;
}
while (smallest.size() <= divisors)
{
smallest.push_back(triangle);
}
}
ui test;
cin >> test;
while (test--) {
ui minDivisors;
cin >> minDivisors;
cout << smallest[minDivisors + 1] << endl;
}
return 0;
} | [
"noreply@github.com"
] | noreply@github.com |
8d541e5cae645044f69aa85b183c6cb7cf233e9c | 634120df190b6262fccf699ac02538360fd9012d | /Develop/Server/AppServer/main/Log/PLog_ItemLost.h | d0a69a00a6caa11803a645840e635adcc1a8d61d | [] | no_license | ktj007/Raiderz_Public | c906830cca5c644be384e68da205ee8abeb31369 | a71421614ef5711740d154c961cbb3ba2a03f266 | refs/heads/master | 2021-06-08T03:37:10.065320 | 2016-11-28T07:50:57 | 2016-11-28T07:50:57 | 74,959,309 | 6 | 4 | null | 2016-11-28T09:53:49 | 2016-11-28T09:53:49 | null | UTF-8 | C++ | false | false | 621 | h | #ifndef _G_LOG_ITEM_LOST_H_
#define _G_LOG_ITEM_LOST_H_
#include "PLog.h"
#include "MTypes.h"
enum LOG_ITEM_LOST_TYPE
{
LILT_NONE = 0,
LILT_BUY,
LILT_SELL,
LILT_CRAFT,
LILT_QUEST,
LILT_MAIL,
LILT_DESTROY,
LILT_MAX
};
class PLog_ItemLost : public PLog
{
private:
int m_nCID;
LOG_ITEM_LOST_TYPE m_nType;
int64 m_nIUID;
int m_nQuantity;
int m_nGold;
static wstring m_strQueryForm;
public:
PLog_ItemLost(const wstring& strDate, int nCID, LOG_ITEM_LOST_TYPE nType, const int64& nIUID, int nQuantity, int nGold);
virtual ~PLog_ItemLost();
virtual wstring MakeQuery();
};
#endif
| [
"espause0703@gmail.com"
] | espause0703@gmail.com |
7936cd72fe9cde85a1c38116da36eaad65241cb0 | cb99847747fc614d5244728fae0729599de9c425 | /recSys/cpp/src/main/gradient_computers/GradientComputer.cpp | 809f6c13578e83d0a98e5b9bc223b519ab607d44 | [
"Apache-2.0"
] | permissive | mindis/Alpenglow | dec665def8a9aeab9ecb1ce6553cd64de4c3fcc3 | f4bcc5a4daa7382b0c44fdbf3f49b78ea7ca485b | refs/heads/master | 2021-06-18T17:31:20.521837 | 2017-07-07T13:40:30 | 2017-07-07T13:51:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,215 | cpp | #include "GradientComputer.h"
vector<pair<RecDat*,double> >* GradientComputerPointWise::get_next_gradient(){
//get next sample
RecDat* rec_dat = &(*train_data_it);
train_data_it++;
double gradient = get_gradient(rec_dat);
//gradient_vector
gradient_vector.clear();
gradient_vector.push_back(make_pair(rec_dat,gradient));
return &gradient_vector;
}
double GradientComputerPointWise::get_gradient(RecDat* rec_dat){
//compute prediction
RecPred rec_pred;
rec_pred.prediction = model->prediction(rec_dat);
rec_pred.score = rec_dat->score;
//compute gradient
double gradient = objective->get_gradient(&rec_pred);
return gradient;
}
vector<pair<RecDat*,double> >* GradientComputerImplicitPairWise::get_next_gradient(){
//get next negative sample
RecDat* negative_data = &(*train_data_it);
train_data_it++;
//compute predictions
RecPred positive_pred;
positive_pred.prediction = model->prediction(positive_data);
positive_pred.score = positive_data->score;
RecPred negative_pred;
negative_pred.prediction = model->prediction(negative_data);
negative_pred.score = negative_data->score;
//compute gradient
pair<double,double> gradient_pair = objective->get_gradient(&positive_pred, &negative_pred);
//gradient_vector
gradient_vector.clear();
gradient_vector.push_back(make_pair(positive_data,gradient_pair.first));
gradient_vector.push_back(make_pair(negative_data,gradient_pair.second));
return &gradient_vector;
}
vector<pair<RecDat*,double> >* GradientComputerListWise::get_next_gradient(){
has_next_=false;
//compute predictions
vector<RecPred> predictions;
predictions.resize(train_data->size());
for(uint i=0; i<train_data->size(); i++){
predictions[i].prediction = model->prediction(&(train_data->at(i)));
predictions[i].score = train_data->at(i).score;
}
//compute gradients
vector<double> gradients;
gradients = objective->get_gradient(&predictions);
//gradient_vector
gradient_vector.clear();
gradient_vector.resize(train_data->size());
for(uint i=0; i<train_data->size(); i++){
gradient_vector[i].first = &(train_data->at(i));
gradient_vector[i].second = gradients[i];
}
return &gradient_vector;
}
| [
"fbobee@info.ilab.sztaki.hu"
] | fbobee@info.ilab.sztaki.hu |
f986b0f4647c8d9bec5ccb9b4cef8071906eea07 | f003672225bbdea69daa32af2b5bfdc279c6056c | /src/xml/hardware_xml_handler.cc | 2cf1389120b191dab401c783db09ee6d36e6358b | [
"Unlicense"
] | permissive | OverheadTransmissionLineSoftware/AppCommon | 90e17846d7770a970a0e18e4bb8ae578fa7068e5 | 213b9df221be6059292b8a230d3425a1fecb1b37 | refs/heads/master | 2021-01-19T01:21:43.912006 | 2019-03-24T22:12:45 | 2019-03-24T22:12:45 | 84,390,787 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 6,216 | cc | // This is free and unencumbered software released into the public domain.
// For more information, please refer to <http://unlicense.org/>
#include "appcommon/xml/hardware_xml_handler.h"
#include "appcommon/units/hardware_unit_converter.h"
#include "models/base/helper.h"
wxXmlNode* HardwareXmlHandler::CreateNode(
const Hardware& hardware,
const std::string& name,
const units::UnitSystem& system_units,
const units::UnitStyle& /**style_units**/) {
// variables used to create XML node
wxXmlNode* node_root = nullptr;
wxXmlNode* node_element = nullptr;
std::string title;
std::string content;
wxXmlAttribute attribute;
double value = -999999;
// creates a node for the root
node_root = new wxXmlNode(wxXML_ELEMENT_NODE, "hardware");
node_root->AddAttribute("version", "1");
if (name != "") {
node_root->AddAttribute("name", name);
}
// creates name node and adds to root node
title = "name";
content = hardware.name;
node_element = CreateElementNodeWithContent(title, content);
node_root->AddChild(node_element);
// creates type node and adds to root node
title = "type";
if (hardware.type == Hardware::HardwareType::kDeadEnd) {
content = "DeadEnd";
} else if (hardware.type == Hardware::HardwareType::kSuspension) {
content = "Suspension";
}
node_element = CreateElementNodeWithContent(title, content);
node_root->AddChild(node_element);
// creates area-cross-section node and adds to root node
title = "area_cross_section";
value = hardware.area_cross_section;
content = helper::DoubleToString(value, 6);
if (system_units == units::UnitSystem::kImperial) {
attribute = wxXmlAttribute("units", "ft^2");
} else if (system_units == units::UnitSystem::kMetric) {
attribute = wxXmlAttribute("units", "m^2");
}
node_element = CreateElementNodeWithContent(title, content, &attribute);
node_root->AddChild(node_element);
// creates length node and adds to root node
title = "length";
value = hardware.length;
content = helper::DoubleToString(value, 3, true);
if (system_units == units::UnitSystem::kImperial) {
attribute = wxXmlAttribute("units", "ft");
} else if (system_units == units::UnitSystem::kMetric) {
attribute = wxXmlAttribute("units", "m");
}
node_element = CreateElementNodeWithContent(title, content, &attribute);
node_root->AddChild(node_element);
// creates weight node and adds to root node
title = "weight";
value = hardware.weight;
content = helper::DoubleToString(value, 3, true);
if (system_units == units::UnitSystem::kImperial) {
attribute = wxXmlAttribute("units", "lbs");
} else if (system_units == units::UnitSystem::kMetric) {
attribute = wxXmlAttribute("units", "N");
}
node_element = CreateElementNodeWithContent(title, content, &attribute);
node_root->AddChild(node_element);
// returns root node
return node_root;
}
bool HardwareXmlHandler::ParseNode(
const wxXmlNode* root,
const std::string& filepath,
const units::UnitSystem& units,
const bool& convert,
Hardware& hardware) {
wxString message;
// checks for valid root node
if (root->GetName() != "hardware") {
message = FileAndLineNumber(filepath, root) +
" Invalid root node. Aborting node parse.";
wxLogError(message);
return false;
}
// gets version attribute
const int kVersion = Version(root);
if (kVersion == -1) {
message = FileAndLineNumber(filepath, root) +
" Version attribute is missing or invalid. Aborting node parse.";
wxLogError(message);
return false;
}
// sends to proper parsing function
if (kVersion == 1) {
return ParseNodeV1(root, filepath, units, convert, hardware);
} else {
message = FileAndLineNumber(filepath, root) +
" Invalid version number. Aborting node parse.";
wxLogError(message);
return false;
}
}
bool HardwareXmlHandler::ParseNodeV1(
const wxXmlNode* root,
const std::string& filepath,
const units::UnitSystem& units,
const bool& convert,
Hardware& hardware) {
bool status = true;
wxString message;
// evaluates each child node
const wxXmlNode* node = root->GetChildren();
while (node != nullptr) {
const wxString title = node->GetName();
const wxString content = ParseElementNodeWithContent(node);
double value = -999999;
if (title == "name") {
hardware.name = content;
} else if (title == "type") {
if (content == "DeadEnd") {
hardware.type = Hardware::HardwareType::kDeadEnd;
} else if (content == "Suspension") {
hardware.type = Hardware::HardwareType::kSuspension;
} else {
message = FileAndLineNumber(filepath, node)
+ "Invalid type.";
wxLogError(message);
status = false;
}
} else if (title == "area_cross_section") {
if (content.ToDouble(&value) == true) {
hardware.area_cross_section = value;
} else {
message = FileAndLineNumber(filepath, node)
+ "Invalid cross sectional area.";
wxLogError(message);
hardware.area_cross_section = -999999;
status = false;
}
} else if (title == "length") {
if (content.ToDouble(&value) == true) {
hardware.length = value;
} else {
message = FileAndLineNumber(filepath, node)
+ "Invalid length.";
wxLogError(message);
hardware.length = -999999;
status = false;
}
} else if (title == "weight") {
if (content.ToDouble(&value) == true) {
hardware.weight = value;
} else {
message = FileAndLineNumber(filepath, node)
+ "Invalid weight.";
wxLogError(message);
hardware.weight = -999999;
status = false;
}
} else {
message = FileAndLineNumber(filepath, node)
+ "XML node isn't recognized.";
wxLogError(message);
status = false;
}
node = node->GetNext();
}
// converts unit style to 'consistent' if needed
if (convert == true) {
HardwareUnitConverter::ConvertUnitStyleToConsistent(1, units, hardware);
}
return status;
}
| [
"bretzel12@users.noreply.github.com"
] | bretzel12@users.noreply.github.com |
adecd3a91fa569e631679d7cfa8a04eeec7d1f1f | 477c8309420eb102b8073ce067d8df0afc5a79b1 | /VTK/Rendering/vtkMesaRenderer.h | e280233a6c7f1b2bf7612d1f9cd39d23d1cdda89 | [
"LicenseRef-scancode-paraview-1.2",
"BSD-3-Clause"
] | permissive | aashish24/paraview-climate-3.11.1 | e0058124e9492b7adfcb70fa2a8c96419297fbe6 | c8ea429f56c10059dfa4450238b8f5bac3208d3a | refs/heads/uvcdat-master | 2021-07-03T11:16:20.129505 | 2013-05-10T13:14:30 | 2013-05-10T13:14:30 | 4,238,077 | 1 | 0 | NOASSERTION | 2020-10-12T21:28:23 | 2012-05-06T02:32:44 | C++ | UTF-8 | C++ | false | false | 2,500 | h | /*=========================================================================
Program: Visualization Toolkit
Module: vtkMesaRenderer.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkMesaRenderer - OpenGL renderer
// .SECTION Description
// vtkMesaRenderer is a concrete implementation of the abstract class
// vtkRenderer. vtkMesaRenderer interfaces to the mesa graphics library.
// This file is created, by a copy of vtkOpenGLRenderer
#ifndef __vtkMesaRenderer_h
#define __vtkMesaRenderer_h
#include "vtkRenderer.h"
class VTK_RENDERING_EXPORT vtkMesaRenderer : public vtkRenderer
{
protected:
int NumberOfLightsBound;
public:
static vtkMesaRenderer *New();
vtkTypeMacro(vtkMesaRenderer,vtkRenderer);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Concrete open gl render method.
void DeviceRender(void);
// Description:
// Internal method temporarily removes lights before reloading them
// into graphics pipeline.
void ClearLights(void);
void Clear(void);
// Description:
// Ask lights to load themselves into graphics pipeline.
int UpdateLights(void);
// Create a vtkMesaCamera, will be used by the super class
// to create the correct camera object.
virtual vtkCamera* MakeCamera();
// Create a vtkMesaLight, will be used by the super class
// to create the correct light object.
virtual vtkLight* MakeLight();
protected:
vtkMesaRenderer();
~vtkMesaRenderer();
//BTX
// Picking functions to be implemented by sub-classes
virtual void DevicePickRender();
virtual void StartPick(unsigned int pickFromSize);
virtual void UpdatePickId();
virtual void DonePick();
virtual unsigned int GetPickedId();
virtual unsigned int GetNumPickedIds();
virtual int GetPickedIds(unsigned int atMost, unsigned int *callerBuffer);
virtual double GetPickedZ();
// Ivars used in picking
class vtkGLPickInfo* PickInfo;
//ETX
double PickedZ;
private:
vtkMesaRenderer(const vtkMesaRenderer&); // Not implemented.
void operator=(const vtkMesaRenderer&); // Not implemented.
};
#endif
| [
"aashish.chaudhary@kitware.com"
] | aashish.chaudhary@kitware.com |
775989a92e6156e04fd9e5194879dea27238cf44 | e1634ce6f17ddad0ddbad9915767874a5a2a70ba | /101-150/Problem 116/main.cpp | 9a7284e5bce49758d4b0524432727dd5cc426232 | [] | no_license | IamLupo/Project-Euler | f5b02a576ab67f4abf8070211756dee9e55ffe81 | 33e8931b658543dfd249e9442556632765a1d918 | refs/heads/master | 2020-12-22T14:38:39.333626 | 2018-10-03T23:47:09 | 2018-10-03T23:47:09 | 55,143,257 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,414 | cpp | #include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <fstream>
#include <string.h>
#include <stdlib.h>
#include "IamLupo/math.h"
using namespace std;
/*
How many different ways can the black tiles in a row measuring
fifty units in length be replaced if colours cannot be mixed
and at least one coloured tile must be used?
*/
/* Slow Recursive */
long long count(int v, int len) {
int i;
long long r;
//Init
r = 0;
r += len - v + 1;
for(i = 0; i <= len - (2 * v); i++)
r += count(v, len - v - i);
return r;
}
long long f2(int n) {
int i;
long long r;
//Init
r = 0;
for(i = 2; i <= 4; i++)
r += count(i, n);
return r; // Unknown
}
/* Fast */
/*
Red:
Sum C(n-k,k+1), k=0..floor(n)
Green:
Sum C(n-2k,k+1), k=0..floor(n/2)
Blue:
Sum C(n-3k,k+1), k=0..floor(n/4)
Reference:
http://oeis.org/A098578
http://oeis.org/A077868
http://oeis.org/A000071
*/
long long f(int n) {
int k;
long long r;
//Init
r = 0;
n--;
for(k = 0; k <= n; k++) {
//Red
r += IamLupo::Math::binomial_coefficient(n - k, k + 1);
//Green
if(k <= (n - 1) / 2)
r += IamLupo::Math::binomial_coefficient(n - 1 - (2 * k), k + 1);
//Blue
if(k <= (n - 2) / 4)
r += IamLupo::Math::binomial_coefficient(n - 2 - (3 * k), k + 1);
}
return r;
}
int main() {
cout << "Result = " << f(50) << endl;
return 0;
}
| [
"admin@ludoruisch.nl"
] | admin@ludoruisch.nl |
ac98c620e90e3fc161194d3df391a993ac62e56c | ab20941e86f4cfb11bbf3fdc8db8cac406de989a | /src/rpc/core_rpc_server.cpp | f6431a018a9905ee731f95a359e15a3e4a91f249 | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] | permissive | Comodore125/noodledoodle_xmr_trezor | 9caced6927e84fdc1e988ab07def0ac2d8f5f5ee | a0cc0e7c6dc721b64d07f17a4f59f28655b20385 | refs/heads/master | 2020-07-05T01:30:37.871688 | 2016-11-13T05:36:15 | 2016-11-13T05:36:15 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 51,991 | cpp | // Copyright (c) 2014-2016, The Monero Project
//
// All rights reserved.
//
// 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 copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER 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.
//
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
#include <boost/foreach.hpp>
#include "include_base_utils.h"
using namespace epee;
#include "core_rpc_server.h"
#include "common/command_line.h"
#include "cryptonote_core/cryptonote_format_utils.h"
#include "cryptonote_core/account.h"
#include "cryptonote_core/cryptonote_basic_impl.h"
#include "misc_language.h"
#include "crypto/hash.h"
#include "core_rpc_server_error_codes.h"
#define MAX_RESTRICTED_FAKE_OUTS_COUNT 40
#define MAX_RESTRICTED_GLOBAL_FAKE_OUTS_COUNT 500
namespace cryptonote
{
//-----------------------------------------------------------------------------------
void core_rpc_server::init_options(boost::program_options::options_description& desc)
{
command_line::add_arg(desc, arg_rpc_bind_ip);
command_line::add_arg(desc, arg_rpc_bind_port);
command_line::add_arg(desc, arg_testnet_rpc_bind_port);
command_line::add_arg(desc, arg_restricted_rpc);
command_line::add_arg(desc, arg_user_agent);
}
//------------------------------------------------------------------------------------------------------------------------------
core_rpc_server::core_rpc_server(
core& cr
, nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<cryptonote::core> >& p2p
)
: m_core(cr)
, m_p2p(p2p)
{}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::handle_command_line(
const boost::program_options::variables_map& vm
)
{
auto p2p_bind_arg = m_testnet ? arg_testnet_rpc_bind_port : arg_rpc_bind_port;
m_bind_ip = command_line::get_arg(vm, arg_rpc_bind_ip);
m_port = command_line::get_arg(vm, p2p_bind_arg);
m_restricted = command_line::get_arg(vm, arg_restricted_rpc);
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::init(
const boost::program_options::variables_map& vm
)
{
m_testnet = command_line::get_arg(vm, command_line::arg_testnet_on);
std::string m_user_agent = command_line::get_arg(vm, command_line::arg_user_agent);
m_net_server.set_threads_prefix("RPC");
bool r = handle_command_line(vm);
CHECK_AND_ASSERT_MES(r, false, "Failed to process command line in core_rpc_server");
return epee::http_server_impl_base<core_rpc_server, connection_context>::init(m_port, m_bind_ip, m_user_agent);
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::check_core_busy()
{
if(m_p2p.get_payload_object().get_core().get_blockchain_storage().is_storing_blockchain())
{
return false;
}
return true;
}
#define CHECK_CORE_BUSY() do { if(!check_core_busy()){res.status = CORE_RPC_STATUS_BUSY;return true;} } while(0)
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::check_core_ready()
{
if(!m_p2p.get_payload_object().is_synchronized())
{
return false;
}
return check_core_busy();
}
#define CHECK_CORE_READY() do { if(!check_core_ready()){res.status = CORE_RPC_STATUS_BUSY;return true;} } while(0)
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_get_height(const COMMAND_RPC_GET_HEIGHT::request& req, COMMAND_RPC_GET_HEIGHT::response& res)
{
CHECK_CORE_BUSY();
res.height = m_core.get_current_blockchain_height();
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_get_info(const COMMAND_RPC_GET_INFO::request& req, COMMAND_RPC_GET_INFO::response& res)
{
CHECK_CORE_BUSY();
crypto::hash top_hash;
if (!m_core.get_blockchain_top(res.height, top_hash))
{
res.status = "Failed";
return false;
}
++res.height; // turn top block height into blockchain height
res.top_block_hash = string_tools::pod_to_hex(top_hash);
res.target_height = m_core.get_target_blockchain_height();
res.difficulty = m_core.get_blockchain_storage().get_difficulty_for_next_block();
res.target = m_core.get_blockchain_storage().get_current_hard_fork_version() < 2 ? DIFFICULTY_TARGET_V1 : DIFFICULTY_TARGET_V2;
res.tx_count = m_core.get_blockchain_storage().get_total_transactions() - res.height; //without coinbase
res.tx_pool_size = m_core.get_pool_transactions_count();
res.alt_blocks_count = m_core.get_blockchain_storage().get_alternative_blocks_count();
uint64_t total_conn = m_p2p.get_connections_count();
res.outgoing_connections_count = m_p2p.get_outgoing_connections_count();
res.incoming_connections_count = total_conn - res.outgoing_connections_count;
res.white_peerlist_size = m_p2p.get_peerlist_manager().get_white_peers_count();
res.grey_peerlist_size = m_p2p.get_peerlist_manager().get_gray_peers_count();
res.testnet = m_testnet;
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_get_blocks(const COMMAND_RPC_GET_BLOCKS_FAST::request& req, COMMAND_RPC_GET_BLOCKS_FAST::response& res)
{
CHECK_CORE_BUSY();
std::list<std::pair<block, std::list<transaction> > > bs;
if(!m_core.find_blockchain_supplement(req.start_height, req.block_ids, bs, res.current_height, res.start_height, COMMAND_RPC_GET_BLOCKS_FAST_MAX_COUNT))
{
res.status = "Failed";
return false;
}
BOOST_FOREACH(auto& b, bs)
{
res.blocks.resize(res.blocks.size()+1);
res.blocks.back().block = block_to_blob(b.first);
res.output_indices.push_back(COMMAND_RPC_GET_BLOCKS_FAST::block_output_indices());
res.output_indices.back().indices.push_back(COMMAND_RPC_GET_BLOCKS_FAST::tx_output_indices());
bool r = m_core.get_tx_outputs_gindexs(get_transaction_hash(b.first.miner_tx), res.output_indices.back().indices.back().indices);
if (!r)
{
res.status = "Failed";
return false;
}
size_t txidx = 0;
BOOST_FOREACH(auto& t, b.second)
{
res.blocks.back().txs.push_back(tx_to_blob(t));
res.output_indices.back().indices.push_back(COMMAND_RPC_GET_BLOCKS_FAST::tx_output_indices());
bool r = m_core.get_tx_outputs_gindexs(b.first.tx_hashes[txidx++], res.output_indices.back().indices.back().indices);
if (!r)
{
res.status = "Failed";
return false;
}
}
}
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_get_hashes(const COMMAND_RPC_GET_HASHES_FAST::request& req, COMMAND_RPC_GET_HASHES_FAST::response& res)
{
CHECK_CORE_BUSY();
NOTIFY_RESPONSE_CHAIN_ENTRY::request resp;
resp.start_height = req.start_height;
if(!m_core.find_blockchain_supplement(req.block_ids, resp))
{
res.status = "Failed";
return false;
}
res.current_height = resp.total_height;
res.start_height = resp.start_height;
res.m_block_ids = std::move(resp.m_block_ids);
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_get_random_outs(const COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::request& req, COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::response& res)
{
CHECK_CORE_BUSY();
res.status = "Failed";
if (m_restricted)
{
if (req.amounts.size() > 100 || req.outs_count > MAX_RESTRICTED_FAKE_OUTS_COUNT)
{
res.status = "Too many outs requested";
return true;
}
}
if(!m_core.get_random_outs_for_amounts(req, res))
{
return true;
}
res.status = CORE_RPC_STATUS_OK;
std::stringstream ss;
typedef COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::outs_for_amount outs_for_amount;
typedef COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::out_entry out_entry;
std::for_each(res.outs.begin(), res.outs.end(), [&](outs_for_amount& ofa)
{
ss << "[" << ofa.amount << "]:";
CHECK_AND_ASSERT_MES(ofa.outs.size(), ;, "internal error: ofa.outs.size() is empty for amount " << ofa.amount);
std::for_each(ofa.outs.begin(), ofa.outs.end(), [&](out_entry& oe)
{
ss << oe.global_amount_index << " ";
});
ss << ENDL;
});
std::string s = ss.str();
LOG_PRINT_L2("COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS: " << ENDL << s);
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_get_outs(const COMMAND_RPC_GET_OUTPUTS::request& req, COMMAND_RPC_GET_OUTPUTS::response& res)
{
CHECK_CORE_BUSY();
res.status = "Failed";
if (m_restricted)
{
if (req.outputs.size() > MAX_RESTRICTED_GLOBAL_FAKE_OUTS_COUNT)
{
res.status = "Too many outs requested";
return true;
}
}
if(!m_core.get_outs(req, res))
{
return true;
}
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_get_random_rct_outs(const COMMAND_RPC_GET_RANDOM_RCT_OUTPUTS::request& req, COMMAND_RPC_GET_RANDOM_RCT_OUTPUTS::response& res)
{
CHECK_CORE_BUSY();
res.status = "Failed";
if(!m_core.get_random_rct_outs(req, res))
{
return true;
}
res.status = CORE_RPC_STATUS_OK;
std::stringstream ss;
typedef COMMAND_RPC_GET_RANDOM_RCT_OUTPUTS::out_entry out_entry;
CHECK_AND_ASSERT_MES(res.outs.size(), true, "internal error: res.outs.size() is empty");
std::for_each(res.outs.begin(), res.outs.end(), [&](out_entry& oe)
{
ss << oe.global_amount_index << " ";
});
ss << ENDL;
std::string s = ss.str();
LOG_PRINT_L2("COMMAND_RPC_GET_RANDOM_RCT_OUTPUTS: " << ENDL << s);
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_get_indexes(const COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES::request& req, COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES::response& res)
{
CHECK_CORE_BUSY();
bool r = m_core.get_tx_outputs_gindexs(req.txid, res.o_indexes);
if(!r)
{
res.status = "Failed";
return true;
}
res.status = CORE_RPC_STATUS_OK;
LOG_PRINT_L2("COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES: [" << res.o_indexes.size() << "]");
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_get_transactions(const COMMAND_RPC_GET_TRANSACTIONS::request& req, COMMAND_RPC_GET_TRANSACTIONS::response& res)
{
CHECK_CORE_BUSY();
std::vector<crypto::hash> vh;
BOOST_FOREACH(const auto& tx_hex_str, req.txs_hashes)
{
blobdata b;
if(!string_tools::parse_hexstr_to_binbuff(tx_hex_str, b))
{
res.status = "Failed to parse hex representation of transaction hash";
return true;
}
if(b.size() != sizeof(crypto::hash))
{
res.status = "Failed, size of data mismatch";
return true;
}
vh.push_back(*reinterpret_cast<const crypto::hash*>(b.data()));
}
std::list<crypto::hash> missed_txs;
std::list<transaction> txs;
bool r = m_core.get_transactions(vh, txs, missed_txs);
if(!r)
{
res.status = "Failed";
return true;
}
LOG_PRINT_L2("Found " << txs.size() << "/" << vh.size() << " transactions on the blockchain");
// try the pool for any missing txes
size_t found_in_pool = 0;
std::unordered_set<crypto::hash> pool_tx_hashes;
if (!missed_txs.empty())
{
std::list<transaction> pool_txs;
bool r = m_core.get_pool_transactions(pool_txs);
if(r)
{
for (std::list<transaction>::const_iterator i = pool_txs.begin(); i != pool_txs.end(); ++i)
{
crypto::hash tx_hash = get_transaction_hash(*i);
std::list<crypto::hash>::iterator mi = std::find(missed_txs.begin(), missed_txs.end(), tx_hash);
if (mi != missed_txs.end())
{
pool_tx_hashes.insert(tx_hash);
missed_txs.erase(mi);
txs.push_back(*i);
++found_in_pool;
}
}
}
LOG_PRINT_L2("Found " << found_in_pool << "/" << vh.size() << " transactions in the pool");
}
std::list<std::string>::const_iterator txhi = req.txs_hashes.begin();
std::vector<crypto::hash>::const_iterator vhi = vh.begin();
BOOST_FOREACH(auto& tx, txs)
{
res.txs.push_back(COMMAND_RPC_GET_TRANSACTIONS::entry());
COMMAND_RPC_GET_TRANSACTIONS::entry &e = res.txs.back();
crypto::hash tx_hash = *vhi++;
e.tx_hash = *txhi++;
blobdata blob = t_serializable_object_to_blob(tx);
e.as_hex = string_tools::buff_to_hex_nodelimer(blob);
if (req.decode_as_json)
e.as_json = obj_to_json_str(tx);
e.in_pool = pool_tx_hashes.find(tx_hash) != pool_tx_hashes.end();
if (e.in_pool)
{
e.block_height = std::numeric_limits<uint64_t>::max();
}
else
{
e.block_height = m_core.get_blockchain_storage().get_db().get_tx_block_height(tx_hash);
}
// fill up old style responses too, in case an old wallet asks
res.txs_as_hex.push_back(e.as_hex);
if (req.decode_as_json)
res.txs_as_json.push_back(e.as_json);
}
BOOST_FOREACH(const auto& miss_tx, missed_txs)
{
res.missed_tx.push_back(string_tools::pod_to_hex(miss_tx));
}
LOG_PRINT_L2(res.txs.size() << " transactions found, " << res.missed_tx.size() << " not found");
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_is_key_image_spent(const COMMAND_RPC_IS_KEY_IMAGE_SPENT::request& req, COMMAND_RPC_IS_KEY_IMAGE_SPENT::response& res)
{
CHECK_CORE_BUSY();
std::vector<crypto::key_image> key_images;
BOOST_FOREACH(const auto& ki_hex_str, req.key_images)
{
blobdata b;
if(!string_tools::parse_hexstr_to_binbuff(ki_hex_str, b))
{
res.status = "Failed to parse hex representation of key image";
return true;
}
if(b.size() != sizeof(crypto::key_image))
{
res.status = "Failed, size of data mismatch";
}
key_images.push_back(*reinterpret_cast<const crypto::key_image*>(b.data()));
}
std::vector<bool> spent_status;
bool r = m_core.are_key_images_spent(key_images, spent_status);
if(!r)
{
res.status = "Failed";
return true;
}
res.spent_status.clear();
for (size_t n = 0; n < spent_status.size(); ++n)
res.spent_status.push_back(spent_status[n] ? COMMAND_RPC_IS_KEY_IMAGE_SPENT::SPENT_IN_BLOCKCHAIN : COMMAND_RPC_IS_KEY_IMAGE_SPENT::UNSPENT);
// check the pool too
std::vector<cryptonote::tx_info> txs;
std::vector<cryptonote::spent_key_image_info> ki;
r = m_core.get_pool_transactions_and_spent_keys_info(txs, ki);
if(!r)
{
res.status = "Failed";
return true;
}
for (std::vector<cryptonote::spent_key_image_info>::const_iterator i = ki.begin(); i != ki.end(); ++i)
{
crypto::hash hash;
crypto::key_image spent_key_image;
if (parse_hash256(i->id_hash, hash))
{
memcpy(&spent_key_image, &hash, sizeof(hash)); // a bit dodgy, should be other parse functions somewhere
for (size_t n = 0; n < res.spent_status.size(); ++n)
{
if (res.spent_status[n] == COMMAND_RPC_IS_KEY_IMAGE_SPENT::UNSPENT)
{
if (key_images[n] == spent_key_image)
{
res.spent_status[n] = COMMAND_RPC_IS_KEY_IMAGE_SPENT::SPENT_IN_POOL;
break;
}
}
}
}
}
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_send_raw_tx(const COMMAND_RPC_SEND_RAW_TX::request& req, COMMAND_RPC_SEND_RAW_TX::response& res)
{
CHECK_CORE_READY();
std::string tx_blob;
if(!string_tools::parse_hexstr_to_binbuff(req.tx_as_hex, tx_blob))
{
LOG_PRINT_L0("[on_send_raw_tx]: Failed to parse tx from hexbuff: " << req.tx_as_hex);
res.status = "Failed";
return true;
}
cryptonote_connection_context fake_context = AUTO_VAL_INIT(fake_context);
tx_verification_context tvc = AUTO_VAL_INIT(tvc);
if(!m_core.handle_incoming_tx(tx_blob, tvc, false, false) || tvc.m_verifivation_failed)
{
if (tvc.m_verifivation_failed)
{
LOG_PRINT_L0("[on_send_raw_tx]: tx verification failed");
}
else
{
LOG_PRINT_L0("[on_send_raw_tx]: Failed to process tx");
}
res.status = "Failed";
if ((res.low_mixin = tvc.m_low_mixin))
res.reason = "mixin too low";
if ((res.double_spend = tvc.m_double_spend))
res.reason = "double spend";
if ((res.invalid_input = tvc.m_invalid_input))
res.reason = "invalid input";
if ((res.invalid_output = tvc.m_invalid_output))
res.reason = "invalid output";
if ((res.too_big = tvc.m_too_big))
res.reason = "too big";
if ((res.overspend = tvc.m_overspend))
res.reason = "overspend";
if ((res.fee_too_low = tvc.m_fee_too_low))
res.reason = "fee too low";
if ((res.not_rct = tvc.m_not_rct))
res.reason = "tx is not ringct";
return true;
}
if(!tvc.m_should_be_relayed || req.do_not_relay)
{
LOG_PRINT_L0("[on_send_raw_tx]: tx accepted, but not relayed");
res.reason = "Not relayed";
res.not_relayed = true;
res.status = CORE_RPC_STATUS_OK;
return true;
}
NOTIFY_NEW_TRANSACTIONS::request r;
r.txs.push_back(tx_blob);
m_core.get_protocol()->relay_transactions(r, fake_context);
//TODO: make sure that tx has reached other nodes here, probably wait to receive reflections from other nodes
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_start_mining(const COMMAND_RPC_START_MINING::request& req, COMMAND_RPC_START_MINING::response& res)
{
CHECK_CORE_READY();
account_public_address adr;
if(!get_account_address_from_str(adr, m_testnet, req.miner_address))
{
res.status = "Failed, wrong address";
LOG_PRINT_L0(res.status);
return true;
}
boost::thread::attributes attrs;
attrs.set_stack_size(THREAD_STACK_SIZE);
if(!m_core.get_miner().start(adr, static_cast<size_t>(req.threads_count), attrs))
{
res.status = "Failed, mining not started";
LOG_PRINT_L0(res.status);
return true;
}
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_stop_mining(const COMMAND_RPC_STOP_MINING::request& req, COMMAND_RPC_STOP_MINING::response& res)
{
if(!m_core.get_miner().stop())
{
res.status = "Failed, mining not stopped";
LOG_PRINT_L0(res.status);
return true;
}
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_mining_status(const COMMAND_RPC_MINING_STATUS::request& req, COMMAND_RPC_MINING_STATUS::response& res)
{
CHECK_CORE_READY();
const miner& lMiner = m_core.get_miner();
res.active = lMiner.is_mining();
if ( lMiner.is_mining() ) {
res.speed = lMiner.get_speed();
res.threads_count = lMiner.get_threads_count();
const account_public_address& lMiningAdr = lMiner.get_mining_address();
res.address = get_account_address_as_str(m_testnet, lMiningAdr);
}
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_save_bc(const COMMAND_RPC_SAVE_BC::request& req, COMMAND_RPC_SAVE_BC::response& res)
{
CHECK_CORE_BUSY();
if( !m_core.get_blockchain_storage().store_blockchain() )
{
res.status = "Error while storing blockhain";
return true;
}
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_get_peer_list(const COMMAND_RPC_GET_PEER_LIST::request& req, COMMAND_RPC_GET_PEER_LIST::response& res)
{
std::list<nodetool::peerlist_entry> white_list;
std::list<nodetool::peerlist_entry> gray_list;
m_p2p.get_peerlist_manager().get_peerlist_full(gray_list, white_list);
for (auto & entry : white_list)
{
res.white_list.emplace_back(entry.id, entry.adr.ip, entry.adr.port, entry.last_seen);
}
for (auto & entry : gray_list)
{
res.gray_list.emplace_back(entry.id, entry.adr.ip, entry.adr.port, entry.last_seen);
}
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_set_log_hash_rate(const COMMAND_RPC_SET_LOG_HASH_RATE::request& req, COMMAND_RPC_SET_LOG_HASH_RATE::response& res)
{
if(m_core.get_miner().is_mining())
{
m_core.get_miner().do_print_hashrate(req.visible);
res.status = CORE_RPC_STATUS_OK;
}
else
{
res.status = CORE_RPC_STATUS_NOT_MINING;
}
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_set_log_level(const COMMAND_RPC_SET_LOG_LEVEL::request& req, COMMAND_RPC_SET_LOG_LEVEL::response& res)
{
if (req.level < LOG_LEVEL_MIN || req.level > LOG_LEVEL_MAX)
{
res.status = "Error: log level not valid";
}
else
{
epee::log_space::log_singletone::get_set_log_detalisation_level(true, req.level);
int otshell_utils_log_level = 100 - (req.level * 20);
gCurrentLogger.setDebugLevel(otshell_utils_log_level);
res.status = CORE_RPC_STATUS_OK;
}
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_get_transaction_pool(const COMMAND_RPC_GET_TRANSACTION_POOL::request& req, COMMAND_RPC_GET_TRANSACTION_POOL::response& res)
{
CHECK_CORE_BUSY();
m_core.get_pool_transactions_and_spent_keys_info(res.transactions, res.spent_key_images);
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_stop_daemon(const COMMAND_RPC_STOP_DAEMON::request& req, COMMAND_RPC_STOP_DAEMON::response& res)
{
// FIXME: replace back to original m_p2p.send_stop_signal() after
// investigating why that isn't working quite right.
m_p2p.send_stop_signal();
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_getblockcount(const COMMAND_RPC_GETBLOCKCOUNT::request& req, COMMAND_RPC_GETBLOCKCOUNT::response& res)
{
CHECK_CORE_BUSY();
res.count = m_core.get_current_blockchain_height();
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_getblockhash(const COMMAND_RPC_GETBLOCKHASH::request& req, COMMAND_RPC_GETBLOCKHASH::response& res, epee::json_rpc::error& error_resp)
{
if(!check_core_busy())
{
error_resp.code = CORE_RPC_ERROR_CODE_CORE_BUSY;
error_resp.message = "Core is busy";
return false;
}
if(req.size() != 1)
{
error_resp.code = CORE_RPC_ERROR_CODE_WRONG_PARAM;
error_resp.message = "Wrong parameters, expected height";
return false;
}
uint64_t h = req[0];
if(m_core.get_current_blockchain_height() <= h)
{
error_resp.code = CORE_RPC_ERROR_CODE_TOO_BIG_HEIGHT;
error_resp.message = std::string("Too big height: ") + std::to_string(h) + ", current blockchain height = " + std::to_string(m_core.get_current_blockchain_height());
}
res = string_tools::pod_to_hex(m_core.get_block_id_by_height(h));
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
// equivalent of strstr, but with arbitrary bytes (ie, NULs)
// This does not differentiate between "not found" and "found at offset 0"
uint64_t slow_memmem(const void* start_buff, size_t buflen,const void* pat,size_t patlen)
{
const void* buf = start_buff;
const void* end=(const char*)buf+buflen;
if (patlen > buflen || patlen == 0) return 0;
while(buflen>0 && (buf=memchr(buf,((const char*)pat)[0],buflen-patlen+1)))
{
if(memcmp(buf,pat,patlen)==0)
return (const char*)buf - (const char*)start_buff;
buf=(const char*)buf+1;
buflen = (const char*)end - (const char*)buf;
}
return 0;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_getblocktemplate(const COMMAND_RPC_GETBLOCKTEMPLATE::request& req, COMMAND_RPC_GETBLOCKTEMPLATE::response& res, epee::json_rpc::error& error_resp)
{
if(!check_core_ready())
{
error_resp.code = CORE_RPC_ERROR_CODE_CORE_BUSY;
error_resp.message = "Core is busy";
return false;
}
if(req.reserve_size > 255)
{
error_resp.code = CORE_RPC_ERROR_CODE_TOO_BIG_RESERVE_SIZE;
error_resp.message = "To big reserved size, maximum 255";
return false;
}
cryptonote::account_public_address acc = AUTO_VAL_INIT(acc);
if(!req.wallet_address.size() || !cryptonote::get_account_address_from_str(acc, m_testnet, req.wallet_address))
{
error_resp.code = CORE_RPC_ERROR_CODE_WRONG_WALLET_ADDRESS;
error_resp.message = "Failed to parse wallet address";
return false;
}
block b = AUTO_VAL_INIT(b);
cryptonote::blobdata blob_reserve;
blob_reserve.resize(req.reserve_size, 0);
if(!m_core.get_block_template(b, acc, res.difficulty, res.height, blob_reserve))
{
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
error_resp.message = "Internal error: failed to create block template";
LOG_ERROR("Failed to create block template");
return false;
}
blobdata block_blob = t_serializable_object_to_blob(b);
crypto::public_key tx_pub_key = cryptonote::get_tx_pub_key_from_extra(b.miner_tx);
if(tx_pub_key == null_pkey)
{
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
error_resp.message = "Internal error: failed to create block template";
LOG_ERROR("Failed to tx pub key in coinbase extra");
return false;
}
res.reserved_offset = slow_memmem((void*)block_blob.data(), block_blob.size(), &tx_pub_key, sizeof(tx_pub_key));
if(!res.reserved_offset)
{
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
error_resp.message = "Internal error: failed to create block template";
LOG_ERROR("Failed to find tx pub key in blockblob");
return false;
}
res.reserved_offset += sizeof(tx_pub_key) + 3; //3 bytes: tag for TX_EXTRA_TAG_PUBKEY(1 byte), tag for TX_EXTRA_NONCE(1 byte), counter in TX_EXTRA_NONCE(1 byte)
if(res.reserved_offset + req.reserve_size > block_blob.size())
{
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
error_resp.message = "Internal error: failed to create block template";
LOG_ERROR("Failed to calculate offset for ");
return false;
}
blobdata hashing_blob = get_block_hashing_blob(b);
res.prev_hash = string_tools::pod_to_hex(b.prev_id);
res.blocktemplate_blob = string_tools::buff_to_hex_nodelimer(block_blob);
res.blockhashing_blob = string_tools::buff_to_hex_nodelimer(hashing_blob);
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_submitblock(const COMMAND_RPC_SUBMITBLOCK::request& req, COMMAND_RPC_SUBMITBLOCK::response& res, epee::json_rpc::error& error_resp)
{
CHECK_CORE_READY();
if(req.size()!=1)
{
error_resp.code = CORE_RPC_ERROR_CODE_WRONG_PARAM;
error_resp.message = "Wrong param";
return false;
}
blobdata blockblob;
if(!string_tools::parse_hexstr_to_binbuff(req[0], blockblob))
{
error_resp.code = CORE_RPC_ERROR_CODE_WRONG_BLOCKBLOB;
error_resp.message = "Wrong block blob";
return false;
}
// Fixing of high orphan issue for most pools
// Thanks Boolberry!
block b = AUTO_VAL_INIT(b);
if(!parse_and_validate_block_from_blob(blockblob, b))
{
error_resp.code = CORE_RPC_ERROR_CODE_WRONG_BLOCKBLOB;
error_resp.message = "Wrong block blob";
return false;
}
// Fix from Boolberry neglects to check block
// size, do that with the function below
if(!m_core.check_incoming_block_size(blockblob))
{
error_resp.code = CORE_RPC_ERROR_CODE_WRONG_BLOCKBLOB_SIZE;
error_resp.message = "Block bloc size is too big, rejecting block";
return false;
}
if(!m_core.handle_block_found(b))
{
error_resp.code = CORE_RPC_ERROR_CODE_BLOCK_NOT_ACCEPTED;
error_resp.message = "Block not accepted";
return false;
}
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
uint64_t core_rpc_server::get_block_reward(const block& blk)
{
uint64_t reward = 0;
BOOST_FOREACH(const tx_out& out, blk.miner_tx.vout)
{
reward += out.amount;
}
return reward;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::fill_block_header_responce(const block& blk, bool orphan_status, uint64_t height, const crypto::hash& hash, block_header_responce& responce)
{
responce.major_version = blk.major_version;
responce.minor_version = blk.minor_version;
responce.timestamp = blk.timestamp;
responce.prev_hash = string_tools::pod_to_hex(blk.prev_id);
responce.nonce = blk.nonce;
responce.orphan_status = orphan_status;
responce.height = height;
responce.depth = m_core.get_current_blockchain_height() - height - 1;
responce.hash = string_tools::pod_to_hex(hash);
responce.difficulty = m_core.get_blockchain_storage().block_difficulty(height);
responce.reward = get_block_reward(blk);
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_get_last_block_header(const COMMAND_RPC_GET_LAST_BLOCK_HEADER::request& req, COMMAND_RPC_GET_LAST_BLOCK_HEADER::response& res, epee::json_rpc::error& error_resp)
{
if(!check_core_busy())
{
error_resp.code = CORE_RPC_ERROR_CODE_CORE_BUSY;
error_resp.message = "Core is busy.";
return false;
}
uint64_t last_block_height;
crypto::hash last_block_hash;
bool have_last_block_hash = m_core.get_blockchain_top(last_block_height, last_block_hash);
if (!have_last_block_hash)
{
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
error_resp.message = "Internal error: can't get last block hash.";
return false;
}
block last_block;
bool have_last_block = m_core.get_block_by_hash(last_block_hash, last_block);
if (!have_last_block)
{
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
error_resp.message = "Internal error: can't get last block.";
return false;
}
bool responce_filled = fill_block_header_responce(last_block, false, last_block_height, last_block_hash, res.block_header);
if (!responce_filled)
{
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
error_resp.message = "Internal error: can't produce valid response.";
return false;
}
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_get_block_header_by_hash(const COMMAND_RPC_GET_BLOCK_HEADER_BY_HASH::request& req, COMMAND_RPC_GET_BLOCK_HEADER_BY_HASH::response& res, epee::json_rpc::error& error_resp){
if(!check_core_busy())
{
error_resp.code = CORE_RPC_ERROR_CODE_CORE_BUSY;
error_resp.message = "Core is busy.";
return false;
}
crypto::hash block_hash;
bool hash_parsed = parse_hash256(req.hash, block_hash);
if(!hash_parsed)
{
error_resp.code = CORE_RPC_ERROR_CODE_WRONG_PARAM;
error_resp.message = "Failed to parse hex representation of block hash. Hex = " + req.hash + '.';
return false;
}
block blk;
bool have_block = m_core.get_block_by_hash(block_hash, blk);
if (!have_block)
{
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
error_resp.message = "Internal error: can't get block by hash. Hash = " + req.hash + '.';
return false;
}
if (blk.miner_tx.vin.front().type() != typeid(txin_gen))
{
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
error_resp.message = "Internal error: coinbase transaction in the block has the wrong type";
return false;
}
uint64_t block_height = boost::get<txin_gen>(blk.miner_tx.vin.front()).height;
bool responce_filled = fill_block_header_responce(blk, false, block_height, block_hash, res.block_header);
if (!responce_filled)
{
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
error_resp.message = "Internal error: can't produce valid response.";
return false;
}
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_get_block_header_by_height(const COMMAND_RPC_GET_BLOCK_HEADER_BY_HEIGHT::request& req, COMMAND_RPC_GET_BLOCK_HEADER_BY_HEIGHT::response& res, epee::json_rpc::error& error_resp){
if(!check_core_busy())
{
error_resp.code = CORE_RPC_ERROR_CODE_CORE_BUSY;
error_resp.message = "Core is busy.";
return false;
}
if(m_core.get_current_blockchain_height() <= req.height)
{
error_resp.code = CORE_RPC_ERROR_CODE_TOO_BIG_HEIGHT;
error_resp.message = std::string("Too big height: ") + std::to_string(req.height) + ", current blockchain height = " + std::to_string(m_core.get_current_blockchain_height());
return false;
}
crypto::hash block_hash = m_core.get_block_id_by_height(req.height);
block blk;
bool have_block = m_core.get_block_by_hash(block_hash, blk);
if (!have_block)
{
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
error_resp.message = "Internal error: can't get block by height. Height = " + std::to_string(req.height) + '.';
return false;
}
bool responce_filled = fill_block_header_responce(blk, false, req.height, block_hash, res.block_header);
if (!responce_filled)
{
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
error_resp.message = "Internal error: can't produce valid response.";
return false;
}
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_get_block(const COMMAND_RPC_GET_BLOCK::request& req, COMMAND_RPC_GET_BLOCK::response& res, epee::json_rpc::error& error_resp){
if(!check_core_busy())
{
error_resp.code = CORE_RPC_ERROR_CODE_CORE_BUSY;
error_resp.message = "Core is busy.";
return false;
}
crypto::hash block_hash;
if (!req.hash.empty())
{
bool hash_parsed = parse_hash256(req.hash, block_hash);
if(!hash_parsed)
{
error_resp.code = CORE_RPC_ERROR_CODE_WRONG_PARAM;
error_resp.message = "Failed to parse hex representation of block hash. Hex = " + req.hash + '.';
return false;
}
}
else
{
if(m_core.get_current_blockchain_height() <= req.height)
{
error_resp.code = CORE_RPC_ERROR_CODE_TOO_BIG_HEIGHT;
error_resp.message = std::string("Too big height: ") + std::to_string(req.height) + ", current blockchain height = " + std::to_string(m_core.get_current_blockchain_height());
return false;
}
block_hash = m_core.get_block_id_by_height(req.height);
}
block blk;
bool have_block = m_core.get_block_by_hash(block_hash, blk);
if (!have_block)
{
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
error_resp.message = "Internal error: can't get block by hash. Hash = " + req.hash + '.';
return false;
}
if (blk.miner_tx.vin.front().type() != typeid(txin_gen))
{
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
error_resp.message = "Internal error: coinbase transaction in the block has the wrong type";
return false;
}
uint64_t block_height = boost::get<txin_gen>(blk.miner_tx.vin.front()).height;
bool responce_filled = fill_block_header_responce(blk, false, block_height, block_hash, res.block_header);
if (!responce_filled)
{
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
error_resp.message = "Internal error: can't produce valid response.";
return false;
}
for (size_t n = 0; n < blk.tx_hashes.size(); ++n)
{
res.tx_hashes.push_back(epee::string_tools::pod_to_hex(blk.tx_hashes[n]));
}
res.blob = string_tools::buff_to_hex_nodelimer(t_serializable_object_to_blob(blk));
res.json = obj_to_json_str(blk);
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_get_connections(const COMMAND_RPC_GET_CONNECTIONS::request& req, COMMAND_RPC_GET_CONNECTIONS::response& res, epee::json_rpc::error& error_resp)
{
if(!check_core_busy())
{
error_resp.code = CORE_RPC_ERROR_CODE_CORE_BUSY;
error_resp.message = "Core is busy.";
return false;
}
res.connections = m_p2p.get_payload_object().get_connections();
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_get_info_json(const COMMAND_RPC_GET_INFO::request& req, COMMAND_RPC_GET_INFO::response& res, epee::json_rpc::error& error_resp)
{
if(!check_core_busy())
{
error_resp.code = CORE_RPC_ERROR_CODE_CORE_BUSY;
error_resp.message = "Core is busy.";
return false;
}
res.height = m_core.get_current_blockchain_height();
res.target_height = m_core.get_target_blockchain_height();
res.difficulty = m_core.get_blockchain_storage().get_difficulty_for_next_block();
res.target = m_core.get_blockchain_storage().get_current_hard_fork_version() < 2 ? DIFFICULTY_TARGET_V1 : DIFFICULTY_TARGET_V2;
res.tx_count = m_core.get_blockchain_storage().get_total_transactions() - res.height; //without coinbase
res.tx_pool_size = m_core.get_pool_transactions_count();
res.alt_blocks_count = m_core.get_blockchain_storage().get_alternative_blocks_count();
uint64_t total_conn = m_p2p.get_connections_count();
res.outgoing_connections_count = m_p2p.get_outgoing_connections_count();
res.incoming_connections_count = total_conn - res.outgoing_connections_count;
res.white_peerlist_size = m_p2p.get_peerlist_manager().get_white_peers_count();
res.grey_peerlist_size = m_p2p.get_peerlist_manager().get_gray_peers_count();
res.testnet = m_testnet;
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_hard_fork_info(const COMMAND_RPC_HARD_FORK_INFO::request& req, COMMAND_RPC_HARD_FORK_INFO::response& res, epee::json_rpc::error& error_resp)
{
if(!check_core_busy())
{
error_resp.code = CORE_RPC_ERROR_CODE_CORE_BUSY;
error_resp.message = "Core is busy.";
return false;
}
const Blockchain &blockchain = m_core.get_blockchain_storage();
uint8_t version = req.version > 0 ? req.version : blockchain.get_next_hard_fork_version();
res.version = blockchain.get_current_hard_fork_version();
res.enabled = blockchain.get_hard_fork_voting_info(version, res.window, res.votes, res.threshold, res.earliest_height, res.voting);
res.state = blockchain.get_hard_fork_state();
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_get_bans(const COMMAND_RPC_GETBANS::request& req, COMMAND_RPC_GETBANS::response& res, epee::json_rpc::error& error_resp)
{
if(!check_core_busy())
{
error_resp.code = CORE_RPC_ERROR_CODE_CORE_BUSY;
error_resp.message = "Core is busy.";
return false;
}
auto now = time(nullptr);
std::map<uint32_t, time_t> blocked_ips = m_p2p.get_blocked_ips();
for (std::map<uint32_t, time_t>::const_iterator i = blocked_ips.begin(); i != blocked_ips.end(); ++i)
{
if (i->second > now) {
COMMAND_RPC_GETBANS::ban b;
b.ip = i->first;
b.seconds = i->second - now;
res.bans.push_back(b);
}
}
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_set_bans(const COMMAND_RPC_SETBANS::request& req, COMMAND_RPC_SETBANS::response& res, epee::json_rpc::error& error_resp)
{
if(!check_core_busy())
{
error_resp.code = CORE_RPC_ERROR_CODE_CORE_BUSY;
error_resp.message = "Core is busy.";
return false;
}
for (auto i = req.bans.begin(); i != req.bans.end(); ++i)
{
if (i->ban)
m_p2p.block_ip(i->ip, i->seconds);
else
m_p2p.unblock_ip(i->ip);
}
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_flush_txpool(const COMMAND_RPC_FLUSH_TRANSACTION_POOL::request& req, COMMAND_RPC_FLUSH_TRANSACTION_POOL::response& res, epee::json_rpc::error& error_resp)
{
if(!check_core_busy())
{
error_resp.code = CORE_RPC_ERROR_CODE_CORE_BUSY;
error_resp.message = "Core is busy.";
return false;
}
bool failed = false;
std::list<crypto::hash> txids;
if (req.txids.empty())
{
std::list<transaction> pool_txs;
bool r = m_core.get_pool_transactions(pool_txs);
if (!r)
{
res.status = "Failed to get txpool contents";
return true;
}
for (const auto &tx: pool_txs)
{
txids.push_back(cryptonote::get_transaction_hash(tx));
}
}
else
{
for (const auto &str: req.txids)
{
cryptonote::blobdata txid_data;
if(!epee::string_tools::parse_hexstr_to_binbuff(str, txid_data))
{
failed = true;
}
crypto::hash txid = *reinterpret_cast<const crypto::hash*>(txid_data.data());
txids.push_back(txid);
}
}
if (!m_core.get_blockchain_storage().flush_txes_from_pool(txids))
{
res.status = "Failed to remove one more tx";
return false;
}
if (failed)
{
res.status = "Failed to parse txid";
return false;
}
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_get_output_histogram(const COMMAND_RPC_GET_OUTPUT_HISTOGRAM::request& req, COMMAND_RPC_GET_OUTPUT_HISTOGRAM::response& res, epee::json_rpc::error& error_resp)
{
if(!check_core_busy())
{
error_resp.code = CORE_RPC_ERROR_CODE_CORE_BUSY;
error_resp.message = "Core is busy.";
return false;
}
std::map<uint64_t, uint64_t> histogram;
try
{
histogram = m_core.get_blockchain_storage().get_output_histogram(req.amounts, req.unlocked);
}
catch (const std::exception &e)
{
res.status = "Failed to get output histogram";
return true;
}
res.histogram.clear();
res.histogram.reserve(histogram.size());
for (const auto &i: histogram)
{
if (i.second >= req.min_count && (i.second <= req.max_count || req.max_count == 0))
res.histogram.push_back(COMMAND_RPC_GET_OUTPUT_HISTOGRAM::entry(i.first, i.second));
}
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_get_version(const COMMAND_RPC_GET_VERSION::request& req, COMMAND_RPC_GET_VERSION::response& res, epee::json_rpc::error& error_resp)
{
res.version = CORE_RPC_VERSION;
res.status = CORE_RPC_STATUS_OK;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_fast_exit(const COMMAND_RPC_FAST_EXIT::request& req, COMMAND_RPC_FAST_EXIT::response& res)
{
cryptonote::core::set_fast_exit();
m_p2p.deinit();
m_core.deinit();
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_out_peers(const COMMAND_RPC_OUT_PEERS::request& req, COMMAND_RPC_OUT_PEERS::response& res)
{
// TODO
/*if (m_p2p.get_outgoing_connections_count() > req.out_peers)
{
m_p2p.m_config.m_net_config.connections_count = req.out_peers;
if (m_p2p.get_outgoing_connections_count() > req.out_peers)
{
int count = m_p2p.get_outgoing_connections_count() - req.out_peers;
m_p2p.delete_connections(count);
}
}
else
m_p2p.m_config.m_net_config.connections_count = req.out_peers;
*/
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_start_save_graph(const COMMAND_RPC_START_SAVE_GRAPH::request& req, COMMAND_RPC_START_SAVE_GRAPH::response& res)
{
m_p2p.set_save_graph(true);
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_stop_save_graph(const COMMAND_RPC_STOP_SAVE_GRAPH::request& req, COMMAND_RPC_STOP_SAVE_GRAPH::response& res)
{
m_p2p.set_save_graph(false);
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
const command_line::arg_descriptor<std::string> core_rpc_server::arg_rpc_bind_ip = {
"rpc-bind-ip"
, "IP for RPC server"
, "127.0.0.1"
};
const command_line::arg_descriptor<std::string> core_rpc_server::arg_rpc_bind_port = {
"rpc-bind-port"
, "Port for RPC server"
, std::to_string(config::RPC_DEFAULT_PORT)
};
const command_line::arg_descriptor<std::string> core_rpc_server::arg_testnet_rpc_bind_port = {
"testnet-rpc-bind-port"
, "Port for testnet RPC server"
, std::to_string(config::testnet::RPC_DEFAULT_PORT)
};
const command_line::arg_descriptor<bool> core_rpc_server::arg_restricted_rpc = {
"restricted-rpc"
, "Restrict RPC to view only commands"
, false
};
const command_line::arg_descriptor<std::string> core_rpc_server::arg_user_agent = {
"user-agent"
, "Restrict RPC to clients using this user agent"
, ""
};
} // namespace cryptonote
| [
"brad@butterkiss.com"
] | brad@butterkiss.com |
30971c06676ef0257abb96602daee210d0fa937d | 91a882547e393d4c4946a6c2c99186b5f72122dd | /Source/XPSP1/NT/com/ole32/stg/props/utils.cxx | c963aee3377b0db8ede8a92066865013ce1f1464 | [] | no_license | IAmAnubhavSaini/cryptoAlgorithm-nt5src | 94f9b46f101b983954ac6e453d0cf8d02aa76fc7 | d9e1cdeec650b9d6d3ce63f9f0abe50dabfaf9e2 | refs/heads/master | 2023-09-02T10:14:14.795579 | 2021-11-20T13:47:06 | 2021-11-20T13:47:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 45,946 | cxx | //+-------------------------------------------------------------------------
//
// Microsoft Windows
// Copyright (C) Microsoft Corporation, 1992 - 1993.
//
// File: utils.cxx
//
// Contents: Utility classes/functions for property implementation.
//
// Classes: CPropSetName -- wraps buffer and conversion of fmtids
// CStackBuffer -- utility class that allows a small number
// of items be on stack, but more be on heap.
//
// Functions: PropVariantClear
// FreePropVariantArray
// AllocAndCopy
// PropVariantCopy
//
// History: 1-Mar-95 BillMo Created.
// 22-Feb-96 MikeHill Removed an over-active assert.
// 22-May-96 MikeHill Handle "unmappable character" in
// NtStatusToScode.
// 12-Jun-96 MikeHill - Added PropSysAllocString and PropSysFreeString.
// - Added VT_I1 support (under ifdef)
// - Fix PropVarCopy where the input VT_CF
// has a zero size but a non-NULL pClipData.
// 29-Jul-96 MikeHill - PropSet names: WCHAR => OLECHAR
// - Bug in PropVarCopy of 0-length VT_BLOB
// - Support VT_BSTR_BLOB types (used in IProp.dll)
// 10-Mar-98 MikeHIll Support Variant types in PropVariantCopy/Clear
// 06-May-98 MikeHill - Use CoTaskMem rather than new/delete.
// - Removed unused PropSysAlloc/FreeString.
// - Support VT_VECTOR|VT_I1.
// - Removed UnicodeCallouts support.
// - Use oleaut32.dll wrappers, don't call directly.
// 5/18/98 MikeHill
// - Moved IsOriginalPropVariantType from utils.hxx.
// - Added IsVariantType.
//
// Notes:
//
// Codework:
//
//--------------------------------------------------------------------------
#include <pch.cxx>
#include <privoa.h> // Private OleAut32 wrappers
#ifdef _MAC_NODOC
ASSERTDATA // File-specific data for FnAssert
#endif
//+-------------------------------------------------------------------
//
// Member: CPropSetName::CPropSetName
//
// Synopsis: Initialize internal buffer with converted FMTID
//
// Arguments: [rfmtid] -- FMTID to convert
//
//--------------------------------------------------------------------
CPropSetName::CPropSetName(REFFMTID rfmtid)
{
PrGuidToPropertySetName(&rfmtid, _oszName);
}
//+-------------------------------------------------------------------
//
// Member: CStackBuffer::Init
//
// Synopsis: Determine whether the class derived from this one
// needs to have additional buffer allocated on the
// heap and allocate it if neccessary. Otherwise, if
// there is space, use the internal buffer in the
// derived class.
//
// Arguments: [cElements] -- the number of elements required.
//
// Returns: S_OK if buffer available
// STG_E_INSUFFICIENTMEMORY if stack buffer was not
// big enough AND heap allocation failed.
//
// Notes: To be called directly by client after the derived
// classes constructor initialized CStackBuffer.
//
//--------------------------------------------------------------------
HRESULT CStackBuffer::Init(ULONG cElements)
{
if (cElements > _cElements)
{
_pbHeapBuf = reinterpret_cast<BYTE*>( CoTaskMemAlloc( cElements * _cbElement ));
if (_pbHeapBuf == NULL)
{
return(STG_E_INSUFFICIENTMEMORY);
}
_cElements = cElements;
}
memset( _pbHeapBuf, 0, _cElements * _cbElement );
return(S_OK);
}
//+-------------------------------------------------------------------------
//
// Function: PropVariantClear
//
// Synopsis: Deallocates the members of the PROPVARIANT that require
// deallocation.
//
// Arguments: [pvarg] - variant to clear
//
// Returns: S_OK if successful,
// STG_E_INVALIDPARAMETER if any part of the variant has
// an unknown vt type. (In this case, ALL the elements
// that can be freed, will be freed.)
//
// Modifies: [pvarg] - the variant is left with vt = VT_EMPTY
//
//--------------------------------------------------------------------------
STDAPI PropVariantClear(PROPVARIANT *pvarg)
{
ULONG l;
HRESULT hr = S_OK;
// Is there really anything to clear?
if (pvarg == NULL)
return(hr);
// Validate the input
VDATEPTROUT( pvarg, PROPVARIANT );
switch (pvarg->vt)
{
case VT_EMPTY:
case VT_NULL:
case VT_ILLEGAL:
case VT_I1:
case VT_UI1:
case VT_I2:
case VT_UI2:
case VT_I4:
case VT_UI4:
case VT_I8:
case VT_UI8:
case VT_R4:
case VT_R8:
case VT_CY:
case VT_DATE:
break;
case VT_BSTR:
if (pvarg->bstrVal != NULL)
PrivSysFreeString( pvarg->bstrVal );
break;
case VT_BSTR_BLOB:
if (pvarg->bstrblobVal.pData != NULL)
CoTaskMemFree( pvarg->bstrblobVal.pData );
break;
case VT_BOOL:
case VT_ERROR:
case VT_FILETIME:
break;
case VT_LPSTR:
case VT_LPWSTR:
case VT_CLSID:
DfpAssert((void**)&pvarg->pszVal == (void**)&pvarg->pwszVal);
DfpAssert((void**)&pvarg->pszVal == (void**)&pvarg->puuid);
CoTaskMemFree( pvarg->pszVal ); // ptr at 0
break;
case VT_CF:
if (pvarg->pclipdata != NULL)
{
CoTaskMemFree( pvarg->pclipdata->pClipData ); // ptr at 8
CoTaskMemFree( pvarg->pclipdata );
}
break;
case VT_BLOB:
case VT_BLOB_OBJECT:
CoTaskMemFree( pvarg->blob.pBlobData ); //ptr at 4
break;
case VT_STREAM:
case VT_STREAMED_OBJECT:
if (pvarg->pStream != NULL)
pvarg->pStream->Release();
break;
case VT_VERSIONED_STREAM:
if( NULL != pvarg->pVersionedStream )
{
if( NULL != pvarg->pVersionedStream->pStream )
pvarg->pVersionedStream->pStream->Release();
CoTaskMemFree( pvarg->pVersionedStream );
}
break;
case VT_STORAGE:
case VT_STORED_OBJECT:
if (pvarg->pStorage != NULL)
pvarg->pStorage->Release();
break;
case (VT_VECTOR | VT_I1):
case (VT_VECTOR | VT_UI1):
case (VT_VECTOR | VT_I2):
case (VT_VECTOR | VT_UI2):
case (VT_VECTOR | VT_I4):
case (VT_VECTOR | VT_UI4):
case (VT_VECTOR | VT_I8):
case (VT_VECTOR | VT_UI8):
case (VT_VECTOR | VT_R4):
case (VT_VECTOR | VT_R8):
case (VT_VECTOR | VT_CY):
case (VT_VECTOR | VT_DATE):
FreeArray:
DfpAssert((void**)&pvarg->caub.pElems == (void**)&pvarg->cai.pElems);
CoTaskMemFree( pvarg->caub.pElems );
break;
case (VT_VECTOR | VT_BSTR):
if (pvarg->cabstr.pElems != NULL)
{
for (l=0; l< pvarg->cabstr.cElems; l++)
{
if (pvarg->cabstr.pElems[l] != NULL)
{
PrivSysFreeString( pvarg->cabstr.pElems[l] );
}
}
}
goto FreeArray;
case (VT_VECTOR | VT_BSTR_BLOB):
if (pvarg->cabstrblob.pElems != NULL)
{
for (l=0; l< pvarg->cabstrblob.cElems; l++)
{
if (pvarg->cabstrblob.pElems[l].pData != NULL)
{
CoTaskMemFree( pvarg->cabstrblob.pElems[l].pData );
}
}
}
goto FreeArray;
case (VT_VECTOR | VT_BOOL):
case (VT_VECTOR | VT_ERROR):
goto FreeArray;
case (VT_VECTOR | VT_LPSTR):
case (VT_VECTOR | VT_LPWSTR):
if (pvarg->calpstr.pElems != NULL)
for (l=0; l< pvarg->calpstr.cElems; l++)
{
CoTaskMemFree( pvarg->calpstr.pElems[l] );
}
goto FreeArray;
case (VT_VECTOR | VT_FILETIME):
case (VT_VECTOR | VT_CLSID):
goto FreeArray;
case (VT_VECTOR | VT_CF):
if (pvarg->caclipdata.pElems != NULL)
for (l=0; l< pvarg->caclipdata.cElems; l++)
{
CoTaskMemFree( pvarg->caclipdata.pElems[l].pClipData );
}
goto FreeArray;
case (VT_VECTOR | VT_VARIANT):
if (pvarg->capropvar.pElems != NULL)
hr = FreePropVariantArray(pvarg->capropvar.cElems, pvarg->capropvar.pElems);
goto FreeArray;
default:
hr = PrivVariantClear( reinterpret_cast<VARIANT*>(pvarg) );
if( DISP_E_BADVARTYPE == hr )
hr = STG_E_INVALIDPARAMETER;
break;
}
// We have all of the important information about the variant, so
// let's clear it out.
//
PropVariantInit(pvarg);
return (hr);
}
//+---------------------------------------------------------------------------
//
// Function: FreePropVariantArray, public
//
// Synopsis: Frees a value array returned from ReadMultiple
//
// Arguments: [cval] - Number of elements
// [rgvar] - Array
//
// Returns: S_OK if all types recognised and all freeable items were freed.
// STG_E_INVALID_PARAMETER if one or more types were not
// recognised but all items are freed too.
//
// Notes: Even if a vt-type is not understood, all the ones that are
// understood are freed. The error code will indicate
// if *any* of the members were illegal types.
//
//----------------------------------------------------------------------------
STDAPI FreePropVariantArray (
ULONG cVariants,
PROPVARIANT *rgvars)
{
HRESULT hr = S_OK;
VDATESIZEPTROUT_LABEL(rgvars, cVariants * sizeof(PROPVARIANT),
Exit, hr );
if (rgvars != NULL)
for ( ULONG I=0; I < cVariants; I++ )
if (STG_E_INVALIDPARAMETER == PropVariantClear ( rgvars + I ))
hr = STG_E_INVALIDPARAMETER;
Exit:
return hr;
}
//+-------------------------------------------------------------------
//
// Function: AllocAndCopy
//
// Synopsis: Allocates enough memory to copy the passed data into and
// then copies the data into the new buffer.
//
// Arguments: [cb] -- number of bytes of data to allocate and copy
// [pvData] -- the source of the data to copy
// [phr] -- optional pointer to an HRESULT set to
// STG_E_INSUFFICIENTMEMORY if memory could
// not be allocated.
//
//
// Returns: NULL if no memory could be allocated,
// Otherwise, pointer to allocated and copied data.
//
//--------------------------------------------------------------------
void * AllocAndCopy(ULONG cb, void * pvData, HRESULT *phr /* = NULL */)
{
void * pvNew = CoTaskMemAlloc( cb );
if (pvNew != NULL)
{
memcpy(pvNew, pvData, cb);
}
else
{
if (phr != NULL)
{
*phr = STG_E_INSUFFICIENTMEMORY;
}
}
return(pvNew);
}
//+-------------------------------------------------------------------
//
// Function: PropSysAllocString
// PropSysFreeString
//
// Synopsis: Wrappers for OleAut32 routines.
//
// Notes: These PropSys* functions simply forward the call to
// the PrivSys* routines in OLE32. Those functions
// will load OleAut32 if necessary, and forward the call.
//
// The PrivSys* wrapper functions are provided in order to
// delay the OleAut32 load. The PropSys* functions below
// are provided as a mechanism to allow the NTDLL PropSet
// functions to call the PrivSys* function pointers.
//
// The PropSys* functions below are part of the
// UNICODECALLOUTS structure used by NTDLL.
// These functions should go away when the property set
// code is moved from NTDLL to OLE32.
//
//--------------------------------------------------------------------
STDAPI_(BSTR)
PropSysAllocString(OLECHAR FAR* pwsz)
{
return( PrivSysAllocString( pwsz ));
}
STDAPI_(VOID)
PropSysFreeString(BSTR bstr)
{
PrivSysFreeString( bstr );
return;
}
//+---------------------------------------------------------------------------
//
// Class: CRGTypeSizes (instantiated in g_TypeSizes)
//
// Synopsis: This class maintains a table with an entry for
// each of the VT types. Each entry contains
// flags and a byte-size for the type (each entry is
// only a byte).
//
// This was implemented as a class so that we could use
// it like an array (using an overloaded subscript operator),
// indexed by the VT. An actual array would require
// 4K entries
//
// Internally, this class keeps two tables, each containing
// a range of VTs (the VTs range from 0 to 31, and 64 to 72).
// Other values are treated as a special-case.
//
//----------------------------------------------------------------------------
// -----------------------
// Flags for table entries
// -----------------------
#define BIT_VECTNOALLOC 0x80 // the VT_VECTOR with this type does not
// use heap allocation
#define BIT_SIMPNOALLOC 0x40 // the non VT_VECTOR with this type does not
// use heap allocation
#define BIT_INVALID 0x20 // marks an invalid type
#define BIT_SIZEMASK 0x1F // mask for size of underlying type
// Dimensions of the internal tables
#define MIN_TYPE_SIZES_A VT_EMPTY // First contiguous range of VTs
#define MAX_TYPE_SIZES_A VT_LPWSTR
#define MIN_TYPE_SIZES_B VT_FILETIME // Second continuous range of VTs
#define MAX_TYPE_SIZES_B VT_VERSIONED_STREAM
// ----------------
// class CRTTypeSizes
// ----------------
class CRGTypeSizes
{
public:
// Subscript Operator
//
// This is the only method on this class. It is used to
// read an entry in the table.
unsigned char operator[]( int nSubscript )
{
// Is this in the first table?
if( MIN_TYPE_SIZES_A <= nSubscript && nSubscript <= MAX_TYPE_SIZES_A )
{
return( m_ucTypeSizesA[ nSubscript ] );
}
// Or, is it in the second table?
else if( MIN_TYPE_SIZES_B<= nSubscript && nSubscript <= MAX_TYPE_SIZES_B )
{
return( m_ucTypeSizesB[ nSubscript - MIN_TYPE_SIZES_B ] );
}
// Or, is it a special-case value (not in either table)?
else
if( VT_BSTR_BLOB == nSubscript )
{
return( sizeof(BSTRBLOB) );
}
// Otherwise, the VT is invalid.
return( BIT_INVALID );
}
private:
// There are two ranges of supported VTs, so we have
// one table for each.
static const unsigned char m_ucTypeSizesA[];
static const unsigned char m_ucTypeSizesB[];
};
// --------------------------
// Instantiate the CRGTypeSizes
// --------------------------
CRGTypeSizes g_TypeSizes;
// ----------------------------
// Define the CTypeSizes tables
// ----------------------------
const unsigned char CRGTypeSizes::m_ucTypeSizesA[] =
{ BIT_SIMPNOALLOC | BIT_VECTNOALLOC | 0, //VT_EMPTY= 0,
BIT_SIMPNOALLOC | BIT_VECTNOALLOC | 0, //VT_NULL = 1,
BIT_SIMPNOALLOC | BIT_VECTNOALLOC | 2, //VT_I2 = 2,
BIT_SIMPNOALLOC | BIT_VECTNOALLOC | 4, //VT_I4 = 3,
BIT_SIMPNOALLOC | BIT_VECTNOALLOC | 4, //VT_R4 = 4,
BIT_SIMPNOALLOC | BIT_VECTNOALLOC | 8, //VT_R8 = 5,
BIT_SIMPNOALLOC | BIT_VECTNOALLOC | sizeof(CY), //VT_CY = 6,
BIT_SIMPNOALLOC | BIT_VECTNOALLOC | sizeof(DATE), //VT_DATE = 7,
sizeof(BSTR), //VT_BSTR = 8,
BIT_INVALID | 0, //VT_DISPATCH = 9,
BIT_SIMPNOALLOC | BIT_VECTNOALLOC | sizeof(SCODE), //VT_ERROR = 10,
BIT_SIMPNOALLOC | BIT_VECTNOALLOC | sizeof(VARIANT_BOOL), //VT_BOOL = 11,
sizeof(PROPVARIANT), //VT_VARIANT = 12,
BIT_INVALID | BIT_SIMPNOALLOC | BIT_VECTNOALLOC | 0, //VT_UNKNOWN = 13,
BIT_INVALID | BIT_SIMPNOALLOC | BIT_VECTNOALLOC | 0, // 14
BIT_INVALID | BIT_SIMPNOALLOC | BIT_VECTNOALLOC | 0, // 15
BIT_SIMPNOALLOC | BIT_VECTNOALLOC | 1, //VT_I1 = 16,
BIT_SIMPNOALLOC | BIT_VECTNOALLOC | 1, //VT_UI1 = 17,
BIT_SIMPNOALLOC | BIT_VECTNOALLOC | 2, //VT_UI2 = 18,
BIT_SIMPNOALLOC | BIT_VECTNOALLOC | 4, //VT_UI4 = 19,
BIT_SIMPNOALLOC | BIT_VECTNOALLOC | 8, //VT_I8 = 20,
BIT_SIMPNOALLOC | BIT_VECTNOALLOC | 8, //VT_UI8 = 21,
BIT_INVALID | BIT_SIMPNOALLOC | BIT_VECTNOALLOC | 0, //VT_INT = 22,
BIT_INVALID | BIT_SIMPNOALLOC | BIT_VECTNOALLOC | 0, //VT_UINT = 23,
BIT_INVALID | BIT_SIMPNOALLOC | BIT_VECTNOALLOC | 0, //VT_VOID = 24,
BIT_INVALID | BIT_SIMPNOALLOC | BIT_VECTNOALLOC | 0, //VT_HRESULT = 25,
BIT_INVALID | 0, //VT_PTR = 26,
BIT_INVALID | 0, //VT_SAFEARRAY = 27,
BIT_INVALID | 0, //VT_CARRAY = 28,
BIT_INVALID | 0, //VT_USERDEFINED = 29,
sizeof(LPSTR), //VT_LPSTR = 30,
sizeof(LPWSTR) //VT_LPWSTR = 31,
};
const unsigned char CRGTypeSizes::m_ucTypeSizesB[] =
{
// sizes for vectors of types marked ** are determined dynamically
BIT_SIMPNOALLOC | BIT_VECTNOALLOC | sizeof(FILETIME), //VT_FILETIME = 64,
0, //**VT_BLOB = 65,
0, //**VT_STREAM = 66,
0, //**VT_STORAGE = 67,
0, //**VT_STREAMED_OBJECT = 68,
0, //**VT_STORED_OBJECT = 69,
0, //**VT_BLOB_OBJECT = 70,
sizeof(CLIPDATA), //VT_CF = 71,
BIT_VECTNOALLOC | sizeof(CLSID), //VT_CLSID = 72,
0 //**VT_VERSIONED_STREAM = 73
};
//+---------------------------------------------------------------------------
//
// Function: PropVariantCopy, public
//
// Synopsis: Copies a PROPVARIANT
//
// Arguments: [pDest] -- the destination PROPVARIANT
// [pvarg] - the source PROPVARIANT
//
// Returns: Appropriate status code
//
//----------------------------------------------------------------------------
STDAPI PropVariantCopy ( PROPVARIANT * pvOut, const PROPVARIANT * pvarg )
{
HRESULT hr = S_OK;
register unsigned char TypeInfo;
register int iBaseType;
BOOL fInputValidated = FALSE;
PROPVARIANT Temp, *pDest = &Temp;
// ----------
// Initialize
// ----------
// Validate the inputs
VDATEREADPTRIN_LABEL( pvarg, PROPVARIANT, Exit, hr );
VDATEPTROUT_LABEL( pvOut, PROPVARIANT, Exit, hr );
fInputValidated = TRUE;
// Duplicate the source propvar to the temp destination. For types with
// no external buffer (e.g. an I4), this will be sufficient. For
// types with an external buffer, we'll now have both propvars
// pointing to the same buffer. So we'll have to re-allocate
// for the destination propvar and copy the data into it.
//
*pDest = *pvarg;
// Handle the simple types quickly.
iBaseType = pvarg->vt & ~VT_VECTOR;
TypeInfo = g_TypeSizes[ iBaseType ]; // Not to be confused with an ITypeInfo
if( (TypeInfo & BIT_INVALID) != 0 )
{
// Try copying it as a regular Variant
PropVariantInit( pDest );
hr = PrivVariantCopy( reinterpret_cast<VARIANT*>(pDest),
reinterpret_cast<VARIANT*>(const_cast<PROPVARIANT*>( pvarg )) );
goto Exit;
}
// -----------------------
// Handle non-vector types
// -----------------------
if ((pvarg->vt & VT_VECTOR) == 0)
{
// Is this a type which requires an allocation (otherwise there's
// nothing to do)?
if ((TypeInfo & BIT_SIMPNOALLOC) == 0)
{
// Yes - an allocation is required.
// Keep a copy of the allocated buffer, so that at the end of
// this switch, we can distiguish the out-of-memory condition from
// the no-alloc-required condition.
void * pvAllocated = (void*)-1;
switch (pvarg->vt)
{
case VT_BSTR:
if( NULL != pvarg->bstrVal )
pvAllocated = pDest->bstrVal = PrivSysAllocString( pvarg->bstrVal );
break;
case VT_BSTR_BLOB:
if( NULL != pvarg->bstrblobVal.pData )
pvAllocated = pDest->bstrblobVal.pData = (BYTE*)
AllocAndCopy(pDest->bstrblobVal.cbSize, pvarg->bstrblobVal.pData);
break;
case VT_LPSTR:
if (pvarg->pszVal != NULL)
pvAllocated = pDest->pszVal = (CHAR *)
AllocAndCopy(strlen(pvarg->pszVal)+1, pvarg->pszVal);
break;
case VT_LPWSTR:
if (pvarg->pwszVal != NULL)
{
ULONG cbString = (Prop_wcslen(pvarg->pwszVal)+1) * sizeof(WCHAR);
pvAllocated = pDest->pwszVal = (WCHAR *)
AllocAndCopy(cbString, pvarg->pwszVal);
}
break;
case VT_CLSID:
if (pvarg->puuid != NULL)
pvAllocated = pDest->puuid = (GUID *)
AllocAndCopy(sizeof(*(pvarg->puuid)), pvarg->puuid);
break;
case VT_CF:
// first check if CLIPDATA is present
if (pvarg->pclipdata != NULL)
{
// yes ... copy the clip data structure
pvAllocated = pDest->pclipdata = (CLIPDATA*)AllocAndCopy(
sizeof(*(pvarg->pclipdata)), pvarg->pclipdata);
// did we allocate the CLIPDATA ?
if (pvAllocated != NULL)
{
// yes ... initialize the destination.
pDest->pclipdata->pClipData = NULL;
// Is the input valid?
if (NULL == pvarg->pclipdata->pClipData
&&
0 != CBPCLIPDATA(*pvarg->pclipdata))
{
// no ... the input is not valid
hr = STG_E_INVALIDPARAMETER;
CoTaskMemFree( pDest->pclipdata );
pvAllocated = pDest->pclipdata = NULL;
break;
}
// Copy the actual clip data. Note that if the source
// is non-NULL, we copy it, even if the length is 0.
if( NULL != pvarg->pclipdata->pClipData )
{
pvAllocated = pDest->pclipdata->pClipData =
(BYTE*)AllocAndCopy(CBPCLIPDATA(*pvarg->pclipdata),
pvarg->pclipdata->pClipData);
}
} // if (pvAllocated != NULL)
} // if (pvarg->pclipdata != NULL)
break;
case VT_BLOB:
case VT_BLOB_OBJECT:
// Is the input valid?
if (NULL == pvarg->blob.pBlobData
&&
0 != pvarg->blob.cbSize)
{
// no ... the input is not valid
hr = STG_E_INVALIDPARAMETER;
goto Exit;
}
// Copy the actual blob. Note that if the source
// is non-NULL, we copy it, even if the length is 0.
if( NULL != pvarg->blob.pBlobData )
{
pvAllocated = pDest->blob.pBlobData =
(BYTE*)AllocAndCopy(pvarg->blob.cbSize,
pvarg->blob.pBlobData);
}
break;
case VT_STREAM:
case VT_STREAMED_OBJECT:
if (pDest->pStream != NULL)
pDest->pStream->AddRef();
break;
case VT_VERSIONED_STREAM:
if( NULL != pvarg->pVersionedStream )
{
LPVERSIONEDSTREAM pVersionedStream
= reinterpret_cast<LPVERSIONEDSTREAM>(CoTaskMemAlloc( sizeof(VERSIONEDSTREAM) ));
if( NULL == pVersionedStream )
{
hr = E_OUTOFMEMORY;
goto Exit;
}
*pVersionedStream = *pvarg->pVersionedStream;
if( NULL != pVersionedStream->pStream )
pVersionedStream->pStream->AddRef();
pDest->pVersionedStream = pVersionedStream;
}
break;
case VT_STORAGE:
case VT_STORED_OBJECT:
if (pDest->pStorage != NULL)
pDest->pStorage->AddRef();
break;
case VT_VARIANT:
// drop through - this merely documents that VT_VARIANT has been thought of.
// VT_VARIANT is only supported as part of a vector.
default:
hr = STG_E_INVALIDPARAMETER;
goto Exit;
} // switch (pvarg->vt)
// If there was an error, we're done.
if( FAILED(hr) )
goto Exit;
// pvAllocated was initialized to -1, so if it's NULL now,
// there was an alloc failure.
if (pvAllocated == NULL)
{
hr = STG_E_INSUFFICIENTMEMORY;
goto Exit;
}
} // if ((TypeInfo & BIT_SIMPNOALLOC) == 0)
} // if ((pvarg->vt & VT_VECTOR) == 0)
// -------------------
// Handle vector types
// -------------------
else
{
// What's the byte-size of this type.
ULONG cbType = TypeInfo & BIT_SIZEMASK;
if (cbType == 0)
{
hr = STG_E_INVALIDPARAMETER;
goto Exit;
}
// handle the vector types
// this depends on the pointer and count being in the same place in
// each of CAUI1 CAI2 etc
// allocate the array for pElems
if (pvarg->caub.pElems == NULL || pvarg->caub.cElems == 0)
{
DfpAssert( hr == S_OK );
goto Exit; // not really an error
}
// Allocate the pElems array (the size of which is
// type-dependent), and copy the source into it.
void *pvAllocated = pDest->caub.pElems = (BYTE *)
AllocAndCopy(cbType * pvarg->caub.cElems, pvarg->caub.pElems);
if (pvAllocated == NULL)
{
hr = STG_E_INSUFFICIENTMEMORY;
goto Exit;
}
// If this type doesn't require secondary allocation (e.g.
// a VT_VECTOR | VT_I4), then we're done.
if ((TypeInfo & BIT_VECTNOALLOC) != 0)
{
// the vector needs no further allocation
DfpAssert( hr == S_OK );
goto Exit;
}
ULONG l;
// vector types that require allocation ...
// we first zero out the pointers so that we can use PropVariantClear
// to clean up in the error case
switch (pvarg->vt)
{
case (VT_VECTOR | VT_BSTR):
// initialize for error case
for (l=0; l< pvarg->cabstr.cElems; l++)
{
pDest->cabstr.pElems[l] = NULL;
}
break;
case (VT_VECTOR | VT_BSTR_BLOB):
// initialize for error case
for (l=0; l< pvarg->cabstrblob.cElems; l++)
{
memset( &pDest->cabstrblob.pElems[l], 0, sizeof(BSTRBLOB) );
}
break;
case (VT_VECTOR | VT_LPSTR):
case (VT_VECTOR | VT_LPWSTR):
// initialize for error case
for (l=0; l< pvarg->calpstr.cElems; l++)
{
pDest->calpstr.pElems[l] = NULL;
}
break;
case (VT_VECTOR | VT_CF):
// initialize for error case
for (l=0; l< pvarg->caclipdata.cElems; l++)
{
pDest->caclipdata.pElems[l].pClipData = NULL;
}
break;
case (VT_VECTOR | VT_VARIANT):
// initialize for error case
for (l=0; l< pvarg->capropvar.cElems; l++)
{
pDest->capropvar.pElems[l].vt = VT_ILLEGAL;
}
break;
default:
DfpAssert(!"Internal error: Unexpected type in PropVariantCopy");
CoTaskMemFree( pvAllocated );
hr = STG_E_INVALIDPARAMETER;
goto Exit;
}
// This is a vector type which requires a secondary alloc.
switch (pvarg->vt)
{
case (VT_VECTOR | VT_BSTR):
for (l=0; l< pvarg->cabstr.cElems; l++)
{
if (pvarg->cabstr.pElems[l] != NULL)
{
pDest->cabstr.pElems[l] = PrivSysAllocString( pvarg->cabstr.pElems[l]);
if (pDest->cabstr.pElems[l] == NULL)
{
hr = STG_E_INSUFFICIENTMEMORY;
break;
}
}
}
break;
case (VT_VECTOR | VT_BSTR_BLOB):
for (l=0; l< pvarg->cabstrblob.cElems; l++)
{
if (pvarg->cabstrblob.pElems[l].pData != NULL)
{
pDest->cabstrblob.pElems[l].cbSize
= pvarg->cabstrblob.pElems[l].cbSize;
pDest->cabstrblob.pElems[l].pData = (BYTE*)AllocAndCopy(
pvarg->cabstrblob.pElems[l].cbSize,
pvarg->cabstrblob.pElems[l].pData,
&hr );
if (hr != S_OK)
break;
}
}
break;
case (VT_VECTOR | VT_LPWSTR):
for (l=0; l< pvarg->calpwstr.cElems; l++)
{
if (pvarg->calpwstr.pElems[l] != NULL)
{
pDest->calpwstr.pElems[l] = (LPWSTR)AllocAndCopy(
sizeof(WCHAR)*(Prop_wcslen(pvarg->calpwstr.pElems[l])+1),
pvarg->calpwstr.pElems[l],
&hr);
if (hr != S_OK)
break;
}
}
break;
case (VT_VECTOR | VT_LPSTR):
for (l=0; l< pvarg->calpstr.cElems; l++)
{
if (pvarg->calpstr.pElems[l] != NULL)
{
pDest->calpstr.pElems[l] = (LPSTR)AllocAndCopy(
strlen(pvarg->calpstr.pElems[l])+1,
pvarg->calpstr.pElems[l],
&hr);
if (hr != S_OK)
break;
}
}
break;
case (VT_VECTOR | VT_CF):
for (l=0; l< pvarg->caclipdata.cElems; l++)
{
// Is the input valid?
if (NULL == pvarg->caclipdata.pElems[l].pClipData
&&
0 != CBPCLIPDATA(pvarg->caclipdata.pElems[l] ))
{
hr = STG_E_INVALIDPARAMETER;
break;
}
// Is there data to copy?
if (NULL != pvarg->caclipdata.pElems[l].pClipData)
{
pDest->caclipdata.pElems[l].pClipData = (BYTE*)AllocAndCopy(
CBPCLIPDATA(pvarg->caclipdata.pElems[l]),
pvarg->caclipdata.pElems[l].pClipData,
&hr);
if (hr != S_OK)
break;
}
}
break;
case (VT_VECTOR | VT_VARIANT):
for (l=0; l< pvarg->capropvar.cElems; l++)
{
hr = PropVariantCopy(pDest->capropvar.pElems + l,
pvarg->capropvar.pElems + l);
if (hr != S_OK)
{
break;
}
}
break;
default:
DfpAssert(!"Internal error: Unexpected type in PropVariantCopy");
CoTaskMemFree( pvAllocated );
hr = STG_E_INVALIDPARAMETER;
goto Exit;
} // switch (pvarg->vt)
} // if ((pvarg->vt & VT_VECTOR) == 0) ... else
// ----
// Exit
// ----
Exit:
// If there was an error, and it wasn't a caller error
// (in which case *pDest may not be writable), clear the
// destination propvar.
if (fInputValidated && hr != S_OK && E_INVALIDARG != hr)
{
// if *pDest == *pvarg, then we didn't alloc anything, and
// nothing need be cleared, so we'll just init *pDest.
// We can't free it because it may point to pvarg's buffers.
if( !memcmp( pDest, pvarg, sizeof(PROPVARIANT) ))
PropVariantInit( pDest );
// Otherwise, we must have done some allocations for *pDest,
// and must free them.
else
PropVariantClear( pDest );
}
if (SUCCEEDED(hr))
*pvOut = Temp;
return(hr);
}
//+---------------------------------------------------------------------------
//
// Function: NtStatusToScode, public
//
// Synopsis: Attempts to map an NTSTATUS code to an SCODE
//
// Arguments: [nts] - NTSTATUS
//
// Returns: Appropriate status code
//
// History: 29-Jun-93 DrewB Created
//
// Notes: Assumes [nts] is an error code
// This function is by no means exhaustively complete
//
//----------------------------------------------------------------------------
SCODE NtStatusToScode(NTSTATUS nts)
{
SCODE sc;
propDbg((DEB_ITRACE, "In NtStatusToScode(%lX)\n", nts));
switch(nts)
{
case STATUS_INVALID_PARAMETER:
case STATUS_INVALID_PARAMETER_MIX:
case STATUS_INVALID_PARAMETER_1:
case STATUS_INVALID_PARAMETER_2:
case STATUS_INVALID_PARAMETER_3:
case STATUS_INVALID_PARAMETER_4:
case STATUS_INVALID_PARAMETER_5:
case STATUS_INVALID_PARAMETER_6:
case STATUS_INVALID_PARAMETER_7:
case STATUS_INVALID_PARAMETER_8:
case STATUS_INVALID_PARAMETER_9:
case STATUS_INVALID_PARAMETER_10:
case STATUS_INVALID_PARAMETER_11:
case STATUS_INVALID_PARAMETER_12:
sc = STG_E_INVALIDPARAMETER;
break;
case STATUS_DUPLICATE_NAME:
case STATUS_DUPLICATE_OBJECTID:
case STATUS_OBJECTID_EXISTS:
case STATUS_OBJECT_NAME_COLLISION:
sc = STG_E_FILEALREADYEXISTS;
break;
case STATUS_NO_SUCH_DEVICE:
case STATUS_NO_SUCH_FILE:
case STATUS_OBJECT_NAME_NOT_FOUND:
case STATUS_NOT_A_DIRECTORY:
case STATUS_FILE_IS_A_DIRECTORY:
case STATUS_PROPSET_NOT_FOUND:
case STATUS_NOT_FOUND:
case STATUS_OBJECT_TYPE_MISMATCH:
sc = STG_E_FILENOTFOUND;
break;
case STATUS_OBJECT_NAME_INVALID:
case STATUS_OBJECT_PATH_SYNTAX_BAD:
case STATUS_OBJECT_PATH_INVALID:
case STATUS_NAME_TOO_LONG:
sc = STG_E_INVALIDNAME;
break;
case STATUS_ACCESS_DENIED:
sc = STG_E_ACCESSDENIED;
break;
case STATUS_NO_MEMORY:
case STATUS_INSUFFICIENT_RESOURCES:
sc = STG_E_INSUFFICIENTMEMORY;
break;
case STATUS_INVALID_HANDLE:
case STATUS_FILE_INVALID:
case STATUS_FILE_FORCED_CLOSED:
sc = STG_E_INVALIDHANDLE;
break;
case STATUS_INVALID_DEVICE_REQUEST:
case STATUS_INVALID_SYSTEM_SERVICE:
case STATUS_NOT_IMPLEMENTED:
sc = STG_E_INVALIDFUNCTION;
break;
case STATUS_NO_MEDIA_IN_DEVICE:
case STATUS_UNRECOGNIZED_MEDIA:
case STATUS_DISK_CORRUPT_ERROR:
case STATUS_DATA_ERROR:
sc = STG_E_WRITEFAULT;
break;
case STATUS_OBJECT_PATH_NOT_FOUND:
sc = STG_E_PATHNOTFOUND;
break;
case STATUS_SHARING_VIOLATION:
sc = STG_E_SHAREVIOLATION;
break;
case STATUS_FILE_LOCK_CONFLICT:
case STATUS_LOCK_NOT_GRANTED:
sc = STG_E_LOCKVIOLATION;
break;
case STATUS_DISK_FULL:
sc = STG_E_MEDIUMFULL;
break;
case STATUS_ACCESS_VIOLATION:
case STATUS_INVALID_USER_BUFFER:
sc = STG_E_INVALIDPOINTER;
break;
case STATUS_TOO_MANY_OPENED_FILES:
sc = STG_E_TOOMANYOPENFILES;
break;
case STATUS_DIRECTORY_NOT_EMPTY:
sc = HRESULT_FROM_WIN32(ERROR_DIR_NOT_EMPTY);
break;
case STATUS_DELETE_PENDING:
sc = STG_E_REVERTED;
break;
case STATUS_INTERNAL_DB_CORRUPTION:
sc = STG_E_INVALIDHEADER;
break;
case STATUS_UNSUCCESSFUL:
sc = E_FAIL;
break;
case STATUS_UNMAPPABLE_CHARACTER:
sc = HRESULT_FROM_WIN32( ERROR_NO_UNICODE_TRANSLATION );
break;
default:
propDbg((DEB_TRACE, "NtStatusToScode: Unknown status %lX\n", nts));
sc = HRESULT_FROM_WIN32(RtlNtStatusToDosError(nts));
break;
}
propDbg((DEB_ITRACE, "Out NtStatusToScode => %lX\n", sc));
return sc;
}
#if DBG!=0 && !defined(WINNT)
ULONG
DbgPrint(
PCHAR Format,
...
)
{
va_list arglist;
CHAR Buffer[512];
int cb;
//
// Format the output into a buffer and then print it.
//
va_start(arglist, Format);
cb = PropVsprintfA(Buffer, Format, arglist);
if (cb == -1) { // detect buffer overflow
cb = sizeof(Buffer);
Buffer[sizeof(Buffer) - 2] = '\n';
Buffer[sizeof(Buffer) - 1] = '\0';
}
OutputDebugString(Buffer);
return 0;
}
#endif
//+-------------------------------------------------------------------
//
// Member: ValidateInRGPROPVARIANT
//
// Synopsis: S_OK if PROPVARIANT[] is valid for Read.
// E_INVALIDARG otherwise.
//
//--------------------------------------------------------------------
HRESULT
ValidateInRGPROPVARIANT( ULONG cpspec, const PROPVARIANT rgpropvar[] )
{
// We verify that we can read the whole PropVariant[], but
// we don't validate the content of those elements.
HRESULT hr;
VDATESIZEREADPTRIN_LABEL(rgpropvar, cpspec * sizeof(PROPVARIANT), Exit, hr);
hr = S_OK;
Exit:
return( hr );
}
//+-------------------------------------------------------------------
//
// Member: ValidateOutRGPROPVARIANT
//
// Synopsis: S_OK if PROPVARIANT[] is valid for Write.
// E_INVALIDARG otherwise.
//
//--------------------------------------------------------------------
HRESULT
ValidateOutRGPROPVARIANT( ULONG cpspec, PROPVARIANT rgpropvar[] )
{
// We verify that we can write the whole PropVariant[], but
// we don't validate the content of those elements.
HRESULT hr;
VDATESIZEPTROUT_LABEL(rgpropvar, cpspec * sizeof(PROPVARIANT), Exit, hr);
hr = S_OK;
Exit:
return( hr );
}
//+-------------------------------------------------------------------
//
// Member: ValidateOutRGLPOLESTR.
//
// Synopsis: S_OK if LPOLESTR[] is valid for Write.
// E_INVALIDARG otherwise.
//
//--------------------------------------------------------------------
HRESULT
ValidateOutRGLPOLESTR( ULONG cpropid, LPOLESTR rglpwstrName[] )
{
HRESULT hr;
VDATESIZEPTROUT_LABEL( rglpwstrName, cpropid * sizeof(LPOLESTR), Exit, hr );
hr = S_OK;
Exit:
return( hr );
}
//+-------------------------------------------------------------------
//
// Member: ValidateInRGLPOLESTR
//
// Synopsis: S_OK if LPOLESTR[] is valid for Read.
// E_INVALIDARG otherwise.
//
//--------------------------------------------------------------------
HRESULT
ValidateInRGLPOLESTR( ULONG cpropid, const OLECHAR* const rglpwstrName[] )
{
// Validate that we can read the entire vector.
HRESULT hr;
VDATESIZEREADPTRIN_LABEL( rglpwstrName, cpropid * sizeof(LPOLESTR), Exit, hr );
// Validate that we can at least read the first character of
// each of the strings.
for( ; cpropid > 0; cpropid-- )
{
VDATEREADPTRIN_LABEL( rglpwstrName[cpropid-1], WCHAR, Exit, hr );
}
hr = S_OK;
Exit:
return( hr );
}
//+----------------------------------------------------------------------------
//
// Function: IsOriginalPropVariantType
//
// Determines if a VARTYPE was one of the ones in the original PropVariant
// definition (as defined in the OLE2 spec and shipped with NT4/DCOM95).
//
//+----------------------------------------------------------------------------
BOOL
IsOriginalPropVariantType( VARTYPE vt )
{
if( vt & ~VT_TYPEMASK & ~VT_VECTOR )
return( FALSE );
switch( vt )
{
case VT_EMPTY:
case VT_NULL:
case VT_UI1:
case VT_I2:
case VT_UI2:
case VT_BOOL:
case VT_I4:
case VT_UI4:
case VT_R4:
case VT_ERROR:
case VT_I8:
case VT_UI8:
case VT_R8:
case VT_CY:
case VT_DATE:
case VT_FILETIME:
case VT_CLSID:
case VT_BLOB:
case VT_BLOB_OBJECT:
case VT_CF:
case VT_STREAM:
case VT_STREAMED_OBJECT:
case VT_STORAGE:
case VT_STORED_OBJECT:
case VT_BSTR:
case VT_LPSTR:
case VT_LPWSTR:
case VT_UI1|VT_VECTOR:
case VT_I2|VT_VECTOR:
case VT_UI2|VT_VECTOR:
case VT_BOOL|VT_VECTOR:
case VT_I4|VT_VECTOR:
case VT_UI4|VT_VECTOR:
case VT_R4|VT_VECTOR:
case VT_ERROR|VT_VECTOR:
case VT_I8|VT_VECTOR:
case VT_UI8|VT_VECTOR:
case VT_R8|VT_VECTOR:
case VT_CY|VT_VECTOR:
case VT_DATE|VT_VECTOR:
case VT_FILETIME|VT_VECTOR:
case VT_CLSID|VT_VECTOR:
case VT_CF|VT_VECTOR:
case VT_BSTR|VT_VECTOR:
case VT_BSTR_BLOB|VT_VECTOR:
case VT_LPSTR|VT_VECTOR:
case VT_LPWSTR|VT_VECTOR:
case VT_VARIANT|VT_VECTOR:
return( TRUE );
}
return( FALSE );
}
//+----------------------------------------------------------------------------
//
// Function: IsVariantType
//
// Determines if a VARTYPE is one in the set of Variant types which are
// supported in the property set implementation.
//
//+----------------------------------------------------------------------------
BOOL
IsVariantType( VARTYPE vt )
{
// Vectors are unsupported
if( (VT_VECTOR | VT_RESERVED) & vt )
return( FALSE );
switch( VT_TYPEMASK & vt )
{
case VT_EMPTY:
case VT_NULL:
case VT_I1:
case VT_UI1:
case VT_I2:
case VT_UI2:
case VT_I4:
case VT_UI4:
case VT_INT:
case VT_UINT:
case VT_R4:
case VT_R8:
case VT_CY:
case VT_DATE:
case VT_BSTR:
case VT_UNKNOWN:
case VT_DISPATCH:
case VT_BOOL:
case VT_ERROR:
case VT_DECIMAL:
case VT_VARIANT:
return( TRUE );
default:
return( FALSE );
}
}
| [
"support@cryptoalgo.cf"
] | support@cryptoalgo.cf |
bcd819ea7d7c09648460b8b401a189ee1d1710bb | 6dbe783d17fbd11ae19938c94cd798691d77c35e | /LinkedList.cpp | 85284597a2a068fb0e52bf5e3508aaff40b2482a | [] | no_license | faisalAkhtar/Data-Structures | 5af6fcf780c6c538d0dea7bcb4529b803747a101 | 7738ef3078ed4bc933a8c542fd1c65be416e7e12 | refs/heads/master | 2020-03-26T04:10:14.838783 | 2018-11-25T11:54:42 | 2018-11-25T11:54:42 | 144,490,368 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,530 | cpp | /*
This program creates a linked list.
Through a menu, then nodes can be added at the beginning or end or after a specific node.
Also, any specific node in between or in the beginning or at the end can be deleted.
*/
#include<iostream>
#include<stdlib.h>
using namespace std;
struct node
{
int data;
struct node* next;
}*s;
void createList(int n)
{
struct node *Node1, *p;
int data, i;
s = (struct node *)malloc(sizeof(struct node));
if(s == NULL)
{
cout << "Memory not located";
}
else
{
cout << "Enter the data at node 1: ";
cin >> data;
s->data = data; // Link data field with data
s->next = NULL; // Link address field to NULL
p = s;
for(i=2; i<=n; i++)
{
Node1 = (struct node*)malloc(sizeof(struct node));
if(Node1 == NULL)
{
cout << "Memory not located";
break;
}
else
{
cout << "Enter the data at node " << i << ": ";
cin >> data;
Node1->data = data;
Node1->next = NULL;
p->next = Node1;
p = p->next;
}
}
cout << "LINKED-LIST CREATED SUCCESSFULLY\n";
}
}
void insertAtBeginning(int data)
{
struct node *p;
p = (struct node*)malloc(sizeof(struct node));
if(p == NULL)
{
cout << "Memory not located";
}
else
{
p->data = data;
p->next = s;
s = p;
cout << "DATA INSERTED SUCCESSFULLY\n";
}
}
void insertAtEnding(int data)
{
struct node*p=s,*Node2;
Node2 = (struct node*)malloc(sizeof(struct node));
if(p==NULL)
{
cout << "Memory not located";
}
else
{
Node2->data=data;
Node2->next=NULL;
while(p->next!=NULL)
{
p=p->next;
}
p->next=Node2;
}
}
bool insertInMid(int x, int data)
{
struct node*p=s, *q;
bool found = false;
q=(struct node*)malloc(sizeof(struct node));
for (; p->next!=NULL; p=p->next)
{
if(p->data==x)
{
q->next=p->next;
p->next=q;
q->data=data;
found=true;
}
}
return found;
}
bool deletex(int data)
{
struct node*p=s;
bool found = false;
while(p->next!=NULL)
{
if(p->next->data==data)
{
found = true;
p->next=p->next->next;
break;
}
p=p->next;
}
return found;
}
void displayFull()
{
struct node*p;
if(s==NULL)
{
cout << "EMPTY LIST";
}
else
{
p = s;
int i=1;
while(p!=NULL)
{
cout << "\t" << i << ". " << p->data << endl;
p=p->next;
i++;
}
}
}
void deleteFirstNode()
{
if(s!=NULL)
{
s = s->next;
cout << "\nDeleted the first node...\n";
}
else
{
cout << "\nEmpty List!!!\n";
}
}
void deleteLastNode()
{
struct node *p=s;
if(s!=NULL)
{
if(p->next!=NULL)
{
while(p->next->next!=NULL)
{
p = p->next;
}
p->next = NULL;
}
else
s = NULL;
cout << "\nDeleted the last node...\n";
}
else
{
cout << "\nEmpty List!!!\n";
}
}
int main()
{
int n, data, x, choice;
cout << "Enter size of linked-list : ";
cin >> n;
createList(n);
while(1)
{
cout << "\n\n\tM E N U\n1. Insert x at beginning\n2. Insert x at end\n3. Insert x in middle\n4. Delete a specific value\n5. Delete the first node\n6. Delete the last node : ";
cin >> choice;
switch(choice)
{
case 1 :
cout << "Enter data to be put in the beginning : ";
cin >> data;
insertAtBeginning(data);
cout << "Inserted!!\n";
displayFull();
break;
case 2 :
cout << "Enter data to be put in the beginning : ";
cin >> data;
insertAtEnding(data);
cout << "Inserted!!\n";
displayFull();
break;
case 3 :
cout << "Enter a number of the list : ";
cin >> x;
cout << "Enter data to be put after the first occurence of " << x << " : ";
cin >> data;
if(insertInMid(x,data))
cout << "Inserted!!\n";
else
cout << x << " not found\n";
displayFull();
break;
case 4 :
printf("Enter a number of the list : ");
cin >> x;
if(deletex(x))
cout << "Deleted " << x << "!!\n";
else
cout << x << " not found\n";
displayFull();
break;
case 5 :
deleteFirstNode();
displayFull();
break;
case 6 :
deleteLastNode();
displayFull();
break;
default :
break;
}
}
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
76d8abdfcbbfb8b9e0ba1123c54e06aada4dba5b | 27159526061707442aaaef9d10c343b77290a419 | /A11s_SAT/AppClass.cpp | 78d04307dc772bb0916460a39f8161817fd67961 | [
"MIT"
] | permissive | jl4312/DSA2-EnityManagerICE | b4e1e8a68394c40d1064fa4b5c97e9e9caabee76 | 7b8e3884a09ba80d219b76b6b142211e1e09b71d | refs/heads/master | 2021-01-10T09:50:04.751268 | 2015-11-18T00:45:37 | 2015-11-18T00:45:37 | 46,280,381 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,405 | cpp | #include "AppClass.h"
void AppClass::InitWindow(String a_sWindowName)
{
super::InitWindow("Separation Axis Test"); // Window Name
// Set the clear color based on Microsoft's CornflowerBlue (default in XNA)
//if this line is in Init Application it will depend on the .cfg file, if it
//is on the InitVariables it will always force it regardless of the .cfg
m_v4ClearColor = vector4(0.4f, 0.6f, 0.9f, 0.0f);
}
void AppClass::InitVariables(void)
{
//Initialize positions
m_v3O1 = vector3(-2.5f, 0.0f, 0.0f);
m_v3O2 = vector3(2.5f, 0.0f, 0.0f);
//Load Models
m_pMeshMngr->LoadModel("Minecraft\\Steve.obj", "Steve");
m_pMeshMngr->LoadModel("Minecraft\\Creeper.obj", "Creeper");
m_pBOMngr = MyBOManager::GetInstance();
m_pBOMngr->AddObject(m_pMeshMngr->GetVertexList("Steve"), "Steve");
m_pBOMngr->AddObject(m_pMeshMngr->GetVertexList("Creeper"), "Creeper");
}
void AppClass::Update(void)
{
//Update the system's time
m_pSystem->UpdateTime();
//Update the mesh manager's time without updating for collision detection
m_pMeshMngr->Update(false);
//First person camera movement
if (m_bFPC == true)
CameraRotation();
ArcBall();
//Set the model matrices for both objects and Bounding Spheres
m_pMeshMngr->SetModelMatrix(glm::translate(m_v3O1) * ToMatrix4(m_qArcBall), "Steve");
m_pMeshMngr->SetModelMatrix(glm::translate(m_v3O2), "Creeper");
//Set the model matrix to the Bounding Object
m_pBOMngr->SetModelMatrix(m_pMeshMngr->GetModelMatrix("Steve"), "Steve");
m_pBOMngr->SetModelMatrix(m_pMeshMngr->GetModelMatrix("Creeper"), "Creeper");
m_pBOMngr->Update();//Update collision detection
m_pBOMngr->DisplaySphere(-1, REWHITE);
m_pBOMngr->DisplayReAlligned();
m_pBOMngr->DisplayOriented(-1, REWHITE);
//Adds all loaded instance to the render list
m_pMeshMngr->AddInstanceToRenderList("ALL");
//Indicate the FPS
int nFPS = m_pSystem->GetFPS();
//print info into the console
printf("FPS: %d \r", nFPS);//print the Frames per Second
//Print info on the screen
std::vector<int> list = m_pBOMngr->GetCollidingVector(0);
m_pMeshMngr->Print("Object 0 colliding with: ", REBLUE);
for (uint n = 0; n < list.size(); n++)
{
m_pMeshMngr->Print(std::to_string(list[n]) + " ", REYELLOW);
}
m_pMeshMngr->PrintLine(" ");
m_pMeshMngr->PrintLine(m_pSystem->GetAppName(), REYELLOW);
m_pMeshMngr->Print("FPS:");
m_pMeshMngr->Print(std::to_string(nFPS), RERED);
}
void AppClass::Display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear the window
//Render the grid based on the camera's mode:
switch (m_pCameraMngr->GetCameraMode())
{
default: //Perspective
m_pMeshMngr->AddGridToQueue(1.0f, REAXIS::XY); //renders the XY grid with a 100% scale
break;
case CAMERAMODE::CAMROTHOX:
m_pMeshMngr->AddGridToQueue(1.0f, REAXIS::YZ, RERED * 0.75f); //renders the YZ grid with a 100% scale
break;
case CAMERAMODE::CAMROTHOY:
m_pMeshMngr->AddGridToQueue(1.0f, REAXIS::XZ, REGREEN * 0.75f); //renders the XZ grid with a 100% scale
break;
case CAMERAMODE::CAMROTHOZ:
m_pMeshMngr->AddGridToQueue(1.0f, REAXIS::XY, REBLUE * 0.75f); //renders the XY grid with a 100% scale
break;
}
m_pMeshMngr->Render(); //renders the render list
m_pGLSystem->GLSwapBuffers(); //Swaps the OpenGL buffers
}
void AppClass::Release(void)
{
super::Release(); //release the memory of the inherited fields
MyBOManager::ReleaseInstance();
} | [
"BSAlberto@gmail.com"
] | BSAlberto@gmail.com |
7debc7b7c38b36e26778aa80e83f3f485dc9af3e | 2adcfe8eac8fd40c859e23791f402913a425e26c | /messaging/numrabw/LimitedSizeBuffer.h | 83bfc9d4564ac9db9e2c6564efae0524ae7b04dd | [
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | reunanen/Numcore_messaging_library | bbcd19c5c9dd0c5798b4db4654be8ba079470dfc | 8c0fb010e42b60d25e0997faaaf6ae57a86ccdba | refs/heads/master | 2022-12-17T21:23:45.930127 | 2022-12-05T13:01:14 | 2022-12-05T13:03:58 | 6,916,231 | 0 | 0 | BSL-1.0 | 2018-09-01T06:33:16 | 2012-11-29T06:17:06 | C++ | UTF-8 | C++ | false | false | 3,792 | h | // Copyright 2007-2008 Juha Reunanen
// 2008-2011 Numcore Ltd
// 2016,2018 Juha Reunanen
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#pragma once
#include <numcfc/Time.h>
#include <mutex>
#include <condition_variable>
#include <deque>
#include <assert.h>
template <typename T>
class LimitedSizeBuffer {
public:
LimitedSizeBuffer() : m_maxItemCount(1024), m_maxByteCount(1024 * 1024), m_currentByteCount(0) {}
void SetMaxItemCount(size_t maxItemCount) {
std::unique_lock<std::mutex> lock(m_mutex);
m_maxItemCount = maxItemCount;
}
void SetMaxByteCount(size_t maxByteCount) {
std::unique_lock<std::mutex> lock(m_mutex);
m_maxByteCount = maxByteCount;
}
bool push_back(const T& item) {
std::unique_lock<std::mutex> lock(m_mutex);
if (m_items.size() >= m_maxItemCount) {
return false;
}
else if (m_currentByteCount + item.GetSize() >= m_maxByteCount && m_items.size() > 0) { // exception: allow large messages if the buffer is otherwise empty
return false;
}
m_items.push_back(item);
m_currentByteCount += item.GetSize();
{ // signaling
{
std::lock_guard<std::mutex> lock(m_mutexSignaling);
m_notified = true;
}
m_condSignaling.notify_one();
}
return true;
}
bool pop_front(T& item, double maxSecondsToWait = 0) {
if (m_items.empty()) {
if (maxSecondsToWait <= 0) {
return false;
}
{ // signaling
numcfc::TimeElapsed te;
te.ResetToCurrent();
std::unique_lock<std::mutex> lock(m_mutexSignaling);
double secondsLeft = maxSecondsToWait;
while (!m_notified && secondsLeft > 0) {
m_condSignaling.wait_for(lock, std::chrono::milliseconds(static_cast<int>(secondsLeft * 1000)));
if (!m_notified) {
secondsLeft = maxSecondsToWait - te.GetElapsedSeconds();
if (secondsLeft > 0.0 && secondsLeft <= 1.0) {
numcfc::SleepMinimal(); // this is to prevent another loop in the normal case of returning false
secondsLeft = maxSecondsToWait - te.GetElapsedSeconds();
}
}
}
if (m_notified) {
m_notified = false;
}
else {
return false;
}
}
}
std::unique_lock<std::mutex> lock(m_mutex);
if (m_items.empty()) {
return false; // somebody else got it
}
item = m_items.front();
size_t newByteCount = m_currentByteCount - item.GetSize();
assert(newByteCount <= m_currentByteCount);
m_currentByteCount = newByteCount;
m_items.pop_front();
assert((m_currentByteCount == 0) == m_items.empty());
return true;
}
std::pair<size_t, size_t> GetItemAndByteCount() const {
std::unique_lock<std::mutex> lock(m_mutex);
std::pair<size_t, size_t> p(std::make_pair(m_items.size(), m_currentByteCount));
return p;
}
private:
mutable std::mutex m_mutex;
// for signaling
mutable bool m_notified;
mutable std::mutex m_mutexSignaling;
mutable std::condition_variable m_condSignaling;
std::deque<T> m_items;
size_t m_maxItemCount;
size_t m_maxByteCount;
size_t m_currentByteCount;
};
| [
"juha.reunanen@tomaattinen.com"
] | juha.reunanen@tomaattinen.com |
d24ca007c52cd3f1a33bc23be71a45e8d38510c9 | 461e4738fcde8a1896b5207a65974b8c78cf9290 | /Game.cpp | 6e99e33a3525462b45d8ba57522a6bb7d9935e82 | [] | no_license | codelink7/Chilli-tut | 736b084bac5599abb18f2e0bc65570ee97303eee | 482579c791d3b56ec82d6833ac831fa70ab2a1dd | refs/heads/main | 2023-08-05T10:58:50.885556 | 2021-09-12T13:01:58 | 2021-09-12T13:01:58 | 404,429,339 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,757 | cpp | /******************************************************************************************
* Chili DirectX Framework Version 16.07.20 *
* Game.cpp *
* Copyright 2016 PlanetChili.net <http://www.planetchili.net> *
* *
* This file is part of The Chili DirectX Framework. *
* *
* The Chili DirectX Framework is free software: you can redistribute it and/or modify *
* it u\nder the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* The Chili DirectX Framework 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 The Chili DirectX Framework. If not, see <http://www.gnu.org/licenses/>. *
******************************************************************************************/
#include "MainWindow.h"
#include "Game.h"
Game::Game( MainWindow& wnd )
:
wnd( wnd ),
gfx( wnd )
{
}
void Game::Go()
{
gfx.BeginFrame();
UpdateModel();
ComposeFrame();
gfx.EndFrame();
}
void Game::UpdateModel()
{
upKey = wnd.kbd.KeyIsPressed(VK_UP);
leftKey = wnd.kbd.KeyIsPressed(VK_LEFT);
downKey = wnd.kbd.KeyIsPressed(VK_DOWN);
rightKey = wnd.kbd.KeyIsPressed(VK_RIGHT);
Ctrl = wnd.kbd.KeyIsPressed(VK_CONTROL);
shapeIsChanged = wnd.kbd.KeyIsPressed(VK_SHIFT);
// Update cursor position with the velocity.
if (Ctrl)
{
vx = 0;
vy = 0;
}
// Cursor Logic,
// Inhibition system to prevent Cursor from moving when Key is held.
if (upKey)
{
y = y - 1;
}
if (downKey)
{
y = y + 1;
}
if (rightKey)
{
x = x + 1;
}
if (leftKey)
{
x = x - 1;
}
/*
if ((x > 200 && x < 400) && (y > 100 && y < 350))
{
shapeIsChanged = true;
c = 0;
}
*/
if (isOverlaped(x, y, x_2, y_2))
{
g = 0;
b = 0;
}
}
void Game::drawBox(int x, int y, int r, int g, int b)
{
gfx.PutPixel(-5 + x, -5 + y, r, g, b);
gfx.PutPixel(-5 + x, -4 + y, r, g, b);
gfx.PutPixel(-5 + x, -3 + y, r, g, b);
gfx.PutPixel(-4 + x, -5 + y, r, g, b);
gfx.PutPixel(-3 + x, -5 + y, r, g, b);
gfx.PutPixel(-5 + x, 5 + y, r, g, b);
gfx.PutPixel(-5 + x, 4 + y, r, g, b);
gfx.PutPixel(-5 + x, 3 + y, r, g, b);
gfx.PutPixel(-4 + x, 5 + y, r, g, b);
gfx.PutPixel(-3 + x, 5 + y, r, g, b);
gfx.PutPixel(5 + x, -5 + y, r, g, b);
gfx.PutPixel(5 + x, -4 + y, r, g, b);
gfx.PutPixel(5 + x, -3 + y, r, g, b);
gfx.PutPixel(4 + x, -5 + y, r, g, b);
gfx.PutPixel(3 + x, -5 + y, r, g, b);
gfx.PutPixel(5 + x, 5 + y, r, g, b);
gfx.PutPixel(5 + x, 4 + y, r, g, b);
gfx.PutPixel(5 + x, 3 + y, r, g, b);
gfx.PutPixel(4 + x, 5 + y, r, g, b);
gfx.PutPixel(3 + x, 5 + y, r, g, b);
}
void Game::KeepAtBoundaries(int* ptrx, int* ptry)
{
int right = *ptrx + 5;
int left = *ptrx + -5;
int up = *ptry + -5;
int down = *ptry + 5;
// Setting X-boundaries for the Cursor.
if ( right >= gfx.ScreenWidth - 5)
{
*ptrx = gfx.ScreenWidth - 10;
}
else if (left <= 0)
{
*ptrx = 10;
}
// Setting Y-boundaries for the Cursor.
if (down > gfx.ScreenHeight - 5)
{
*ptry = gfx.ScreenHeight - 10;
}
else if (up < 0)
{
*ptry = 6;
}
}
void Game::drawReticle(int x, int y, int r, int g, int b)
{
gfx.PutPixel(x + -5, y, r, g, b);
gfx.PutPixel(x + -4, y, r, g, b);
gfx.PutPixel(x + -3, y, r, g, b);
gfx.PutPixel(x + 3, y, r, g, b);
gfx.PutPixel(x + 4, y, r, g, b);
gfx.PutPixel(x + 5, y, r, g, b);
gfx.PutPixel(x, y + -5, r, g, b);
gfx.PutPixel(x, y + -4, r, g, b);
gfx.PutPixel(x, y + -3, r, g, b);
gfx.PutPixel(x, y + 3, r, g, b);
gfx.PutPixel(x, y + 4, r, g, b);
gfx.PutPixel(x, y + 5, r, g, b);
}
bool Game::isOverlaped(int x, int y, int x_1, int y_2)
{
return (x + 5 >= x_2 - 5 && x -5 <= x_2 + 5 && y + 5 >= y_2 - 5 && y - 5 <= y_2 + 5);
}
void Game::ComposeFrame()
{
if (shapeIsChanged) {
drawBox(x, y, c, 255, b);
}
else
{
drawBox(x, y, c, g, b);
}
KeepAtBoundaries(ptrx, ptry);
drawBox(x_2, y_2, 255, 255, 255);
} | [
"noreply@github.com"
] | noreply@github.com |
87e369244c05971c57f6894582969714070df795 | bdb9cbcbfd89577a35cb34ad6df76c949b8aee05 | /apigateway/include/tencentcloud/apigateway/v20180808/model/CreateServiceRequest.h | 9bd0c90495a50648d4db3ef956cd3ea15726dc92 | [
"Apache-2.0"
] | permissive | xqmaster/tencentcloud-sdk-cpp | 90c1f4fa21beaa66930432611c830676db4f67ac | 5bd0b9c19f389ce84c1b841b0d27c3cca4d1f68f | refs/heads/master | 2023-01-08T07:10:38.178584 | 2020-11-09T01:22:13 | 2020-11-09T01:22:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,234 | h | /*
* Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. 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 TENCENTCLOUD_APIGATEWAY_V20180808_MODEL_CREATESERVICEREQUEST_H_
#define TENCENTCLOUD_APIGATEWAY_V20180808_MODEL_CREATESERVICEREQUEST_H_
#include <string>
#include <vector>
#include <map>
#include <tencentcloud/core/AbstractModel.h>
#include <tencentcloud/apigateway/v20180808/model/Tag.h>
namespace TencentCloud
{
namespace Apigateway
{
namespace V20180808
{
namespace Model
{
/**
* CreateService请求参数结构体
*/
class CreateServiceRequest : public AbstractModel
{
public:
CreateServiceRequest();
~CreateServiceRequest() = default;
std::string ToJsonString() const;
/**
* 获取用户自定义的服务名称。如果没传,则系统自动生成一个唯一名称。
* @return ServiceName 用户自定义的服务名称。如果没传,则系统自动生成一个唯一名称。
*/
std::string GetServiceName() const;
/**
* 设置用户自定义的服务名称。如果没传,则系统自动生成一个唯一名称。
* @param ServiceName 用户自定义的服务名称。如果没传,则系统自动生成一个唯一名称。
*/
void SetServiceName(const std::string& _serviceName);
/**
* 判断参数 ServiceName 是否已赋值
* @return ServiceName 是否已赋值
*/
bool ServiceNameHasBeenSet() const;
/**
* 获取服务的前端请求类型。如 http、https、http&https。
* @return Protocol 服务的前端请求类型。如 http、https、http&https。
*/
std::string GetProtocol() const;
/**
* 设置服务的前端请求类型。如 http、https、http&https。
* @param Protocol 服务的前端请求类型。如 http、https、http&https。
*/
void SetProtocol(const std::string& _protocol);
/**
* 判断参数 Protocol 是否已赋值
* @return Protocol 是否已赋值
*/
bool ProtocolHasBeenSet() const;
/**
* 获取用户自定义的服务描述。
* @return ServiceDesc 用户自定义的服务描述。
*/
std::string GetServiceDesc() const;
/**
* 设置用户自定义的服务描述。
* @param ServiceDesc 用户自定义的服务描述。
*/
void SetServiceDesc(const std::string& _serviceDesc);
/**
* 判断参数 ServiceDesc 是否已赋值
* @return ServiceDesc 是否已赋值
*/
bool ServiceDescHasBeenSet() const;
/**
* 获取独立集群名称,用于指定创建服务所在的独立集群。
* @return ExclusiveSetName 独立集群名称,用于指定创建服务所在的独立集群。
*/
std::string GetExclusiveSetName() const;
/**
* 设置独立集群名称,用于指定创建服务所在的独立集群。
* @param ExclusiveSetName 独立集群名称,用于指定创建服务所在的独立集群。
*/
void SetExclusiveSetName(const std::string& _exclusiveSetName);
/**
* 判断参数 ExclusiveSetName 是否已赋值
* @return ExclusiveSetName 是否已赋值
*/
bool ExclusiveSetNameHasBeenSet() const;
/**
* 获取网络类型列表,用于指定支持的访问类型,INNER为内网访问,OUTER为外网访问。默认为OUTER。
* @return NetTypes 网络类型列表,用于指定支持的访问类型,INNER为内网访问,OUTER为外网访问。默认为OUTER。
*/
std::vector<std::string> GetNetTypes() const;
/**
* 设置网络类型列表,用于指定支持的访问类型,INNER为内网访问,OUTER为外网访问。默认为OUTER。
* @param NetTypes 网络类型列表,用于指定支持的访问类型,INNER为内网访问,OUTER为外网访问。默认为OUTER。
*/
void SetNetTypes(const std::vector<std::string>& _netTypes);
/**
* 判断参数 NetTypes 是否已赋值
* @return NetTypes 是否已赋值
*/
bool NetTypesHasBeenSet() const;
/**
* 获取IP版本号,支持IPv4和IPv6,默认为IPv4。
* @return IpVersion IP版本号,支持IPv4和IPv6,默认为IPv4。
*/
std::string GetIpVersion() const;
/**
* 设置IP版本号,支持IPv4和IPv6,默认为IPv4。
* @param IpVersion IP版本号,支持IPv4和IPv6,默认为IPv4。
*/
void SetIpVersion(const std::string& _ipVersion);
/**
* 判断参数 IpVersion 是否已赋值
* @return IpVersion 是否已赋值
*/
bool IpVersionHasBeenSet() const;
/**
* 获取集群名称。保留字段,tsf serverlss类型使用。
* @return SetServerName 集群名称。保留字段,tsf serverlss类型使用。
*/
std::string GetSetServerName() const;
/**
* 设置集群名称。保留字段,tsf serverlss类型使用。
* @param SetServerName 集群名称。保留字段,tsf serverlss类型使用。
*/
void SetSetServerName(const std::string& _setServerName);
/**
* 判断参数 SetServerName 是否已赋值
* @return SetServerName 是否已赋值
*/
bool SetServerNameHasBeenSet() const;
/**
* 获取用户类型。保留类型,serverless用户使用。
* @return AppIdType 用户类型。保留类型,serverless用户使用。
*/
std::string GetAppIdType() const;
/**
* 设置用户类型。保留类型,serverless用户使用。
* @param AppIdType 用户类型。保留类型,serverless用户使用。
*/
void SetAppIdType(const std::string& _appIdType);
/**
* 判断参数 AppIdType 是否已赋值
* @return AppIdType 是否已赋值
*/
bool AppIdTypeHasBeenSet() const;
/**
* 获取标签。
* @return Tags 标签。
*/
std::vector<Tag> GetTags() const;
/**
* 设置标签。
* @param Tags 标签。
*/
void SetTags(const std::vector<Tag>& _tags);
/**
* 判断参数 Tags 是否已赋值
* @return Tags 是否已赋值
*/
bool TagsHasBeenSet() const;
private:
/**
* 用户自定义的服务名称。如果没传,则系统自动生成一个唯一名称。
*/
std::string m_serviceName;
bool m_serviceNameHasBeenSet;
/**
* 服务的前端请求类型。如 http、https、http&https。
*/
std::string m_protocol;
bool m_protocolHasBeenSet;
/**
* 用户自定义的服务描述。
*/
std::string m_serviceDesc;
bool m_serviceDescHasBeenSet;
/**
* 独立集群名称,用于指定创建服务所在的独立集群。
*/
std::string m_exclusiveSetName;
bool m_exclusiveSetNameHasBeenSet;
/**
* 网络类型列表,用于指定支持的访问类型,INNER为内网访问,OUTER为外网访问。默认为OUTER。
*/
std::vector<std::string> m_netTypes;
bool m_netTypesHasBeenSet;
/**
* IP版本号,支持IPv4和IPv6,默认为IPv4。
*/
std::string m_ipVersion;
bool m_ipVersionHasBeenSet;
/**
* 集群名称。保留字段,tsf serverlss类型使用。
*/
std::string m_setServerName;
bool m_setServerNameHasBeenSet;
/**
* 用户类型。保留类型,serverless用户使用。
*/
std::string m_appIdType;
bool m_appIdTypeHasBeenSet;
/**
* 标签。
*/
std::vector<Tag> m_tags;
bool m_tagsHasBeenSet;
};
}
}
}
}
#endif // !TENCENTCLOUD_APIGATEWAY_V20180808_MODEL_CREATESERVICEREQUEST_H_
| [
"tencentcloudapi@tenent.com"
] | tencentcloudapi@tenent.com |
24de2382620d89fd0733fb2a8a211f4c8435d4bf | 6cfc281f699a6af355bda88f7b9c667491cbfbdc | /Apps/IOS/Classes/Native/UnityClassRegistration.cpp | 42351d2d376456e6598522368841f5c0869b3647 | [] | no_license | slifcoa/FordHackathon | 93868b834eeeae2fa727e8fd1d83bbab8b291433 | c466b9c8b32154d08bd1106a28d0bec3726b8d96 | refs/heads/main | 2023-06-25T22:41:09.018873 | 2021-07-16T20:49:47 | 2021-07-16T20:49:47 | 377,796,506 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 19,008 | cpp | extern "C" void RegisterStaticallyLinkedModulesGranular()
{
void RegisterModule_SharedInternals();
RegisterModule_SharedInternals();
void RegisterModule_Core();
RegisterModule_Core();
void RegisterModule_AndroidJNI();
RegisterModule_AndroidJNI();
void RegisterModule_Animation();
RegisterModule_Animation();
void RegisterModule_Audio();
RegisterModule_Audio();
void RegisterModule_ImageConversion();
RegisterModule_ImageConversion();
void RegisterModule_GameCenter();
RegisterModule_GameCenter();
void RegisterModule_IMGUI();
RegisterModule_IMGUI();
void RegisterModule_Input();
RegisterModule_Input();
void RegisterModule_InputLegacy();
RegisterModule_InputLegacy();
void RegisterModule_JSONSerialize();
RegisterModule_JSONSerialize();
void RegisterModule_ParticleSystem();
RegisterModule_ParticleSystem();
void RegisterModule_Physics();
RegisterModule_Physics();
void RegisterModule_Physics2D();
RegisterModule_Physics2D();
void RegisterModule_RuntimeInitializeOnLoadManagerInitializer();
RegisterModule_RuntimeInitializeOnLoadManagerInitializer();
void RegisterModule_Subsystems();
RegisterModule_Subsystems();
void RegisterModule_TextRendering();
RegisterModule_TextRendering();
void RegisterModule_TextCore();
RegisterModule_TextCore();
void RegisterModule_TLS();
RegisterModule_TLS();
void RegisterModule_UI();
RegisterModule_UI();
void RegisterModule_UnityWebRequest();
RegisterModule_UnityWebRequest();
void RegisterModule_XR();
RegisterModule_XR();
void RegisterModule_VR();
RegisterModule_VR();
}
template <typename T> void RegisterUnityClass(const char*);
template <typename T> void RegisterStrippedType(int, const char*, const char*);
void InvokeRegisterStaticallyLinkedModuleClasses()
{
// Do nothing (we're in stripping mode)
}
namespace ObjectProduceTestTypes { class Derived; }
namespace ObjectProduceTestTypes { class SubDerived; }
class EditorExtension; template <> void RegisterUnityClass<EditorExtension>(const char*);
namespace Unity { class Component; } template <> void RegisterUnityClass<Unity::Component>(const char*);
class Behaviour; template <> void RegisterUnityClass<Behaviour>(const char*);
class Animation;
class Animator; template <> void RegisterUnityClass<Animator>(const char*);
namespace Unity { class ArticulationBody; }
class AudioBehaviour; template <> void RegisterUnityClass<AudioBehaviour>(const char*);
class AudioListener; template <> void RegisterUnityClass<AudioListener>(const char*);
class AudioSource; template <> void RegisterUnityClass<AudioSource>(const char*);
class AudioFilter;
class AudioChorusFilter;
class AudioDistortionFilter;
class AudioEchoFilter;
class AudioHighPassFilter;
class AudioLowPassFilter;
class AudioReverbFilter;
class AudioReverbZone;
class Camera; template <> void RegisterUnityClass<Camera>(const char*);
namespace UI { class Canvas; } template <> void RegisterUnityClass<UI::Canvas>(const char*);
namespace UI { class CanvasGroup; } template <> void RegisterUnityClass<UI::CanvasGroup>(const char*);
namespace Unity { class Cloth; }
class Collider2D; template <> void RegisterUnityClass<Collider2D>(const char*);
class BoxCollider2D;
class CapsuleCollider2D;
class CircleCollider2D;
class CompositeCollider2D;
class EdgeCollider2D;
class PolygonCollider2D;
class TilemapCollider2D;
class ConstantForce;
class Effector2D;
class AreaEffector2D;
class BuoyancyEffector2D;
class PlatformEffector2D;
class PointEffector2D;
class SurfaceEffector2D;
class FlareLayer; template <> void RegisterUnityClass<FlareLayer>(const char*);
class GridLayout;
class Grid;
class Tilemap;
class Halo;
class HaloLayer;
class IConstraint;
class AimConstraint;
class LookAtConstraint;
class ParentConstraint;
class PositionConstraint;
class RotationConstraint;
class ScaleConstraint;
class Joint2D;
class AnchoredJoint2D;
class DistanceJoint2D;
class FixedJoint2D;
class FrictionJoint2D;
class HingeJoint2D;
class SliderJoint2D;
class SpringJoint2D;
class WheelJoint2D;
class RelativeJoint2D;
class TargetJoint2D;
class LensFlare;
class Light; template <> void RegisterUnityClass<Light>(const char*);
class LightProbeGroup;
class LightProbeProxyVolume;
class MonoBehaviour; template <> void RegisterUnityClass<MonoBehaviour>(const char*);
class NavMeshAgent;
class NavMeshObstacle;
class OffMeshLink;
class ParticleSystemForceField;
class PhysicsUpdateBehaviour2D;
class ConstantForce2D;
class PlayableDirector;
class Projector;
class ReflectionProbe; template <> void RegisterUnityClass<ReflectionProbe>(const char*);
class Skybox; template <> void RegisterUnityClass<Skybox>(const char*);
class SortingGroup;
class StreamingController;
class Terrain;
class VideoPlayer;
class VisualEffect;
class WindZone;
namespace UI { class CanvasRenderer; } template <> void RegisterUnityClass<UI::CanvasRenderer>(const char*);
class Collider; template <> void RegisterUnityClass<Collider>(const char*);
class BoxCollider; template <> void RegisterUnityClass<BoxCollider>(const char*);
class CapsuleCollider; template <> void RegisterUnityClass<CapsuleCollider>(const char*);
class CharacterController;
class MeshCollider; template <> void RegisterUnityClass<MeshCollider>(const char*);
class SphereCollider; template <> void RegisterUnityClass<SphereCollider>(const char*);
class TerrainCollider;
class WheelCollider;
class FakeComponent;
namespace Unity { class Joint; }
namespace Unity { class CharacterJoint; }
namespace Unity { class ConfigurableJoint; }
namespace Unity { class FixedJoint; }
namespace Unity { class HingeJoint; }
namespace Unity { class SpringJoint; }
class LODGroup;
class MeshFilter; template <> void RegisterUnityClass<MeshFilter>(const char*);
class OcclusionArea;
class OcclusionPortal;
class ParticleSystem; template <> void RegisterUnityClass<ParticleSystem>(const char*);
class Renderer; template <> void RegisterUnityClass<Renderer>(const char*);
class BillboardRenderer;
class LineRenderer; template <> void RegisterUnityClass<LineRenderer>(const char*);
class RendererFake;
class MeshRenderer; template <> void RegisterUnityClass<MeshRenderer>(const char*);
class ParticleSystemRenderer; template <> void RegisterUnityClass<ParticleSystemRenderer>(const char*);
class SkinnedMeshRenderer;
class SpriteMask;
class SpriteRenderer; template <> void RegisterUnityClass<SpriteRenderer>(const char*);
class SpriteShapeRenderer;
class TilemapRenderer;
class TrailRenderer; template <> void RegisterUnityClass<TrailRenderer>(const char*);
class VFXRenderer;
class Rigidbody; template <> void RegisterUnityClass<Rigidbody>(const char*);
class Rigidbody2D; template <> void RegisterUnityClass<Rigidbody2D>(const char*);
namespace TextRenderingPrivate { class TextMesh; } template <> void RegisterUnityClass<TextRenderingPrivate::TextMesh>(const char*);
class Transform; template <> void RegisterUnityClass<Transform>(const char*);
namespace UI { class RectTransform; } template <> void RegisterUnityClass<UI::RectTransform>(const char*);
class Tree;
class GameObject; template <> void RegisterUnityClass<GameObject>(const char*);
class NamedObject; template <> void RegisterUnityClass<NamedObject>(const char*);
class AssetBundle;
class AssetBundleManifest;
class AudioMixer; template <> void RegisterUnityClass<AudioMixer>(const char*);
class AudioMixerController;
class AudioMixerGroup; template <> void RegisterUnityClass<AudioMixerGroup>(const char*);
class AudioMixerGroupController;
class AudioMixerSnapshot; template <> void RegisterUnityClass<AudioMixerSnapshot>(const char*);
class AudioMixerSnapshotController;
class Avatar; template <> void RegisterUnityClass<Avatar>(const char*);
class AvatarMask;
class BillboardAsset;
class ComputeShader; template <> void RegisterUnityClass<ComputeShader>(const char*);
class Flare;
namespace TextRendering { class Font; } template <> void RegisterUnityClass<TextRendering::Font>(const char*);
class LightProbes; template <> void RegisterUnityClass<LightProbes>(const char*);
class LightingSettings; template <> void RegisterUnityClass<LightingSettings>(const char*);
class LocalizationAsset;
class Material; template <> void RegisterUnityClass<Material>(const char*);
class ProceduralMaterial;
class Mesh; template <> void RegisterUnityClass<Mesh>(const char*);
class Motion; template <> void RegisterUnityClass<Motion>(const char*);
class AnimationClip; template <> void RegisterUnityClass<AnimationClip>(const char*);
class NavMeshData;
class OcclusionCullingData;
class PhysicMaterial;
class PhysicsMaterial2D;
class PreloadData; template <> void RegisterUnityClass<PreloadData>(const char*);
class RayTracingShader;
class RuntimeAnimatorController; template <> void RegisterUnityClass<RuntimeAnimatorController>(const char*);
class AnimatorController; template <> void RegisterUnityClass<AnimatorController>(const char*);
class AnimatorOverrideController; template <> void RegisterUnityClass<AnimatorOverrideController>(const char*);
class SampleClip; template <> void RegisterUnityClass<SampleClip>(const char*);
class AudioClip; template <> void RegisterUnityClass<AudioClip>(const char*);
class Shader; template <> void RegisterUnityClass<Shader>(const char*);
class ShaderVariantCollection;
class SpeedTreeWindAsset;
class Sprite; template <> void RegisterUnityClass<Sprite>(const char*);
class SpriteAtlas; template <> void RegisterUnityClass<SpriteAtlas>(const char*);
class SubstanceArchive;
class TerrainData;
class TerrainLayer;
class TextAsset; template <> void RegisterUnityClass<TextAsset>(const char*);
class MonoScript; template <> void RegisterUnityClass<MonoScript>(const char*);
class Texture; template <> void RegisterUnityClass<Texture>(const char*);
class BaseVideoTexture;
class WebCamTexture;
class CubemapArray; template <> void RegisterUnityClass<CubemapArray>(const char*);
class LowerResBlitTexture; template <> void RegisterUnityClass<LowerResBlitTexture>(const char*);
class MovieTexture;
class ProceduralTexture;
class RenderTexture; template <> void RegisterUnityClass<RenderTexture>(const char*);
class CustomRenderTexture;
class SparseTexture;
class Texture2D; template <> void RegisterUnityClass<Texture2D>(const char*);
class Cubemap; template <> void RegisterUnityClass<Cubemap>(const char*);
class Texture2DArray; template <> void RegisterUnityClass<Texture2DArray>(const char*);
class Texture3D; template <> void RegisterUnityClass<Texture3D>(const char*);
class VideoClip;
class VisualEffectObject;
class VisualEffectAsset;
class VisualEffectSubgraph;
class EmptyObject;
class GameManager; template <> void RegisterUnityClass<GameManager>(const char*);
class GlobalGameManager; template <> void RegisterUnityClass<GlobalGameManager>(const char*);
class AudioManager; template <> void RegisterUnityClass<AudioManager>(const char*);
class BuildSettings; template <> void RegisterUnityClass<BuildSettings>(const char*);
class DelayedCallManager; template <> void RegisterUnityClass<DelayedCallManager>(const char*);
class GraphicsSettings; template <> void RegisterUnityClass<GraphicsSettings>(const char*);
class InputManager; template <> void RegisterUnityClass<InputManager>(const char*);
class MonoManager; template <> void RegisterUnityClass<MonoManager>(const char*);
class NavMeshProjectSettings;
class Physics2DSettings; template <> void RegisterUnityClass<Physics2DSettings>(const char*);
class PhysicsManager; template <> void RegisterUnityClass<PhysicsManager>(const char*);
class PlayerSettings; template <> void RegisterUnityClass<PlayerSettings>(const char*);
class QualitySettings; template <> void RegisterUnityClass<QualitySettings>(const char*);
class ResourceManager; template <> void RegisterUnityClass<ResourceManager>(const char*);
class RuntimeInitializeOnLoadManager; template <> void RegisterUnityClass<RuntimeInitializeOnLoadManager>(const char*);
class ScriptMapper; template <> void RegisterUnityClass<ScriptMapper>(const char*);
class StreamingManager;
class TagManager; template <> void RegisterUnityClass<TagManager>(const char*);
class TimeManager; template <> void RegisterUnityClass<TimeManager>(const char*);
class UnityConnectSettings;
class VFXManager;
class LevelGameManager; template <> void RegisterUnityClass<LevelGameManager>(const char*);
class LightmapSettings; template <> void RegisterUnityClass<LightmapSettings>(const char*);
class NavMeshSettings;
class OcclusionCullingSettings;
class RenderSettings; template <> void RegisterUnityClass<RenderSettings>(const char*);
class NativeObjectType;
class PropertyModificationsTargetTestObject;
class SerializableManagedHost;
class SerializableManagedRefTestClass;
namespace ObjectProduceTestTypes { class SiblingDerived; }
class TestObjectVectorPairStringBool;
class TestObjectWithSerializedAnimationCurve;
class TestObjectWithSerializedArray;
class TestObjectWithSerializedMapStringBool;
class TestObjectWithSerializedMapStringNonAlignedStruct;
class TestObjectWithSpecialLayoutOne;
class TestObjectWithSpecialLayoutTwo;
void RegisterAllClasses()
{
void RegisterBuiltinTypes();
RegisterBuiltinTypes();
//Total: 89 non stripped classes
//0. AnimationClip
RegisterUnityClass<AnimationClip>("Animation");
//1. Animator
RegisterUnityClass<Animator>("Animation");
//2. AnimatorController
RegisterUnityClass<AnimatorController>("Animation");
//3. AnimatorOverrideController
RegisterUnityClass<AnimatorOverrideController>("Animation");
//4. Avatar
RegisterUnityClass<Avatar>("Animation");
//5. Motion
RegisterUnityClass<Motion>("Animation");
//6. RuntimeAnimatorController
RegisterUnityClass<RuntimeAnimatorController>("Animation");
//7. AudioBehaviour
RegisterUnityClass<AudioBehaviour>("Audio");
//8. AudioClip
RegisterUnityClass<AudioClip>("Audio");
//9. AudioListener
RegisterUnityClass<AudioListener>("Audio");
//10. AudioManager
RegisterUnityClass<AudioManager>("Audio");
//11. AudioMixer
RegisterUnityClass<AudioMixer>("Audio");
//12. AudioMixerGroup
RegisterUnityClass<AudioMixerGroup>("Audio");
//13. AudioMixerSnapshot
RegisterUnityClass<AudioMixerSnapshot>("Audio");
//14. AudioSource
RegisterUnityClass<AudioSource>("Audio");
//15. SampleClip
RegisterUnityClass<SampleClip>("Audio");
//16. Behaviour
RegisterUnityClass<Behaviour>("Core");
//17. BuildSettings
RegisterUnityClass<BuildSettings>("Core");
//18. Camera
RegisterUnityClass<Camera>("Core");
//19. Unity::Component
RegisterUnityClass<Unity::Component>("Core");
//20. ComputeShader
RegisterUnityClass<ComputeShader>("Core");
//21. Cubemap
RegisterUnityClass<Cubemap>("Core");
//22. CubemapArray
RegisterUnityClass<CubemapArray>("Core");
//23. DelayedCallManager
RegisterUnityClass<DelayedCallManager>("Core");
//24. EditorExtension
RegisterUnityClass<EditorExtension>("Core");
//25. FlareLayer
RegisterUnityClass<FlareLayer>("Core");
//26. GameManager
RegisterUnityClass<GameManager>("Core");
//27. GameObject
RegisterUnityClass<GameObject>("Core");
//28. GlobalGameManager
RegisterUnityClass<GlobalGameManager>("Core");
//29. GraphicsSettings
RegisterUnityClass<GraphicsSettings>("Core");
//30. InputManager
RegisterUnityClass<InputManager>("Core");
//31. LevelGameManager
RegisterUnityClass<LevelGameManager>("Core");
//32. Light
RegisterUnityClass<Light>("Core");
//33. LightingSettings
RegisterUnityClass<LightingSettings>("Core");
//34. LightmapSettings
RegisterUnityClass<LightmapSettings>("Core");
//35. LightProbes
RegisterUnityClass<LightProbes>("Core");
//36. LineRenderer
RegisterUnityClass<LineRenderer>("Core");
//37. LowerResBlitTexture
RegisterUnityClass<LowerResBlitTexture>("Core");
//38. Material
RegisterUnityClass<Material>("Core");
//39. Mesh
RegisterUnityClass<Mesh>("Core");
//40. MeshFilter
RegisterUnityClass<MeshFilter>("Core");
//41. MeshRenderer
RegisterUnityClass<MeshRenderer>("Core");
//42. MonoBehaviour
RegisterUnityClass<MonoBehaviour>("Core");
//43. MonoManager
RegisterUnityClass<MonoManager>("Core");
//44. MonoScript
RegisterUnityClass<MonoScript>("Core");
//45. NamedObject
RegisterUnityClass<NamedObject>("Core");
//46. Object
//Skipping Object
//47. PlayerSettings
RegisterUnityClass<PlayerSettings>("Core");
//48. PreloadData
RegisterUnityClass<PreloadData>("Core");
//49. QualitySettings
RegisterUnityClass<QualitySettings>("Core");
//50. UI::RectTransform
RegisterUnityClass<UI::RectTransform>("Core");
//51. ReflectionProbe
RegisterUnityClass<ReflectionProbe>("Core");
//52. Renderer
RegisterUnityClass<Renderer>("Core");
//53. RenderSettings
RegisterUnityClass<RenderSettings>("Core");
//54. RenderTexture
RegisterUnityClass<RenderTexture>("Core");
//55. ResourceManager
RegisterUnityClass<ResourceManager>("Core");
//56. RuntimeInitializeOnLoadManager
RegisterUnityClass<RuntimeInitializeOnLoadManager>("Core");
//57. ScriptMapper
RegisterUnityClass<ScriptMapper>("Core");
//58. Shader
RegisterUnityClass<Shader>("Core");
//59. Skybox
RegisterUnityClass<Skybox>("Core");
//60. Sprite
RegisterUnityClass<Sprite>("Core");
//61. SpriteAtlas
RegisterUnityClass<SpriteAtlas>("Core");
//62. SpriteRenderer
RegisterUnityClass<SpriteRenderer>("Core");
//63. TagManager
RegisterUnityClass<TagManager>("Core");
//64. TextAsset
RegisterUnityClass<TextAsset>("Core");
//65. Texture
RegisterUnityClass<Texture>("Core");
//66. Texture2D
RegisterUnityClass<Texture2D>("Core");
//67. Texture2DArray
RegisterUnityClass<Texture2DArray>("Core");
//68. Texture3D
RegisterUnityClass<Texture3D>("Core");
//69. TimeManager
RegisterUnityClass<TimeManager>("Core");
//70. TrailRenderer
RegisterUnityClass<TrailRenderer>("Core");
//71. Transform
RegisterUnityClass<Transform>("Core");
//72. ParticleSystem
RegisterUnityClass<ParticleSystem>("ParticleSystem");
//73. ParticleSystemRenderer
RegisterUnityClass<ParticleSystemRenderer>("ParticleSystem");
//74. BoxCollider
RegisterUnityClass<BoxCollider>("Physics");
//75. CapsuleCollider
RegisterUnityClass<CapsuleCollider>("Physics");
//76. Collider
RegisterUnityClass<Collider>("Physics");
//77. MeshCollider
RegisterUnityClass<MeshCollider>("Physics");
//78. PhysicsManager
RegisterUnityClass<PhysicsManager>("Physics");
//79. Rigidbody
RegisterUnityClass<Rigidbody>("Physics");
//80. SphereCollider
RegisterUnityClass<SphereCollider>("Physics");
//81. Collider2D
RegisterUnityClass<Collider2D>("Physics2D");
//82. Physics2DSettings
RegisterUnityClass<Physics2DSettings>("Physics2D");
//83. Rigidbody2D
RegisterUnityClass<Rigidbody2D>("Physics2D");
//84. TextRendering::Font
RegisterUnityClass<TextRendering::Font>("TextRendering");
//85. TextRenderingPrivate::TextMesh
RegisterUnityClass<TextRenderingPrivate::TextMesh>("TextRendering");
//86. UI::Canvas
RegisterUnityClass<UI::Canvas>("UI");
//87. UI::CanvasGroup
RegisterUnityClass<UI::CanvasGroup>("UI");
//88. UI::CanvasRenderer
RegisterUnityClass<UI::CanvasRenderer>("UI");
}
| [
"slifcoa@mail.gvsu.edu"
] | slifcoa@mail.gvsu.edu |
b84fdbf918abbf97b1d0014481dea93f3c3a2d75 | a764c9dc879cf07ab2eb0056635f4d84f5dc65a2 | /16235(나무재테크).cpp | e53c136b647cb2a0b6d2adfffcc9d63d130505e2 | [] | no_license | chaedyl/CodingTest | c90d95d23e379945f3605ecab897fb77f0629e81 | b740a77b58dbee8f7f4d0b0f89d3bd5227fbf9d0 | refs/heads/master | 2020-09-09T08:15:46.731518 | 2019-11-13T07:38:04 | 2019-11-13T07:38:04 | 221,396,861 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 3,439 | cpp | ////yabmoons.tistory.com/161
//
//#include <iostream>
//#include <algorithm>
//#include <vector>
//using namespace std;
//
//int N, M, K;
//vector<int> map[11][11]; // 나무 심은곳, 나이 저장
//// => 하나의 칸에 여러 개의 나무가 동시에 존재하기 때문에
//// 맵을 일반적인 int 형으로 받지 않고, 벡터형으로 받음!!!!!!
//
//int A[11][11]; // 겨울에 추가되는 양분의 양
//int nut[11][11];// 기본 양분
//// int nut[11][11]= { 5, }; 이렇게 초기화하면 틀림! 아래에서 입력 받을 때 for문 이용!
//int dx[8] = { 0, 0, -1, 1, 1, 1, -1, -1 };
//int dy[8] = { -1, 1, 0, 0, -1, 1, -1, 1 };
//int years; // 몇년이 지났는지
//int ans; // 살아있는 나무의 수
//
////void plant(int tree_y, int tree_x, int tree_old, int ind) {
////
//// ind = 0;
//// if (map[tree_y][tree_x][ind] == 0) {
//// map[tree_y][tree_x][ind] = tree_old;
//// }
//// else {
//// map[tree_y][tree_x][ind++] = tree_old;
//// }
////}
//
//
//int main() {
//
// cin >> N >> M >> K;
// for (int i = 1; i <= N; i++) {
// for (int j = 1; j <= N; j++) {
// cin >> A[i][j];
// nut[i][j] = 5; // 기본 양분 초기화 해줌
// }
// }
//
// for (int i = 0; i < M; i++) {
// int tree_x, tree_y, tree_old;
// cin >> tree_y >> tree_x >> tree_old;
//
// map[tree_y][tree_x].push_back(tree_old);
// }
//
//
// while (1) {
//
// years++;
// if (years > K) break;
//
// // 봄, 여름
// for (int i = 1; i <= N; i++) {
// for (int j = 1; j <= N; j++) {
//
// if (map[i][j].size() == 0) continue;
//
// vector<int> temp;
// int die_nut = 0;
//
// sort(map[i][j].begin(), map[i][j].end());
//
// for (int k = 0; k < map[i][j].size(); k++) {
// int age = map[i][j][k];
//
// if (nut[i][j] >= age) { // 나무가 양분 섭취 가능
// nut[i][j] -= age;
// temp.push_back(age + 1);
// }
// else { // 나무 죽음
// die_nut += age / 2; // 여름 단계로 넘어감
//
// //nut[i][j] += age / 2; 이렇게 해버리면, 봄 단계에 영향 미쳐서 안됨
// }
// }
//
// map[i][j].clear();
// for (int k = 0; k < temp.size(); k++) {
// map[i][j].push_back(temp[k]);
// }
// nut[i][j] += die_nut;
// }
// }
//
// // 가을
// for (int i = 1; i <= N; i++) {
// for (int j = 1; j <= N; j++) {
// if (map[i][j].size() == 0) continue;
//
// for (int k = 0; k < map[i][j].size(); k++) {
//
// if (map[i][j][k] % 5 == 0) {
// for (int l = 0; l < 8; l++) {
// int nextx = j + dx[l];
// int nexty = i + dy[l];
//
// if (nextx <= 0 || nexty <= 0 || nextx > N || nexty > N) continue;
//
// //map[nexty][nextx][k] = 1; 이거 아님!
// map[nexty][nextx].push_back(1); // 이게 맞음!
// }
// }
// }
// }
// }
//
// // 겨울
// for (int i = 1; i <= N; i++) {
// for (int j = 1; j <= N; j++) {
// nut[i][j] += A[i][j];
// }
// }
//
// }
//
// //for (int i = 1; i <= N; i++) {
// // for (int j = 1; j <= N; j++) {
// // cout << nut[i][j] << ' ';
// // }
// // cout << endl;
// //}
//
// //for (int i = 1; i <= N; i++) {
// // for (int j = 1; j <= N; j++) {
// // cout << map[i][j] << ' ';
// // }
// // cout << endl;
// //}
//
// for (int i = 1; i <= N; i++) {
// for (int j = 1; j <= N; j++) {
// if (map[i][j].size()!=0) {
// ans += map[i][j].size();
// }
// }
// }
//
// cout << ans << endl;
// return 0;
//} | [
"eunny1690@nvaer.com"
] | eunny1690@nvaer.com |
4e6daa161b6e2e1895c7ed001206728226ddb6a9 | 373973a49d5a44317f4ae270d0528e69086f6fa4 | /UVa/10071 - Back to High School Physics/smsesteves.cpp | 30e9971b549ea419fb7ce7fb9275fcea1eb85b31 | [] | no_license | ferrolho/feup-contests | c72cfaa44eae4a4d897b38bd9e8b7a27b753c6bb | d515e85421bed05af343fda528a076ce62283268 | refs/heads/master | 2021-01-10T21:03:53.996687 | 2017-03-29T17:34:35 | 2017-03-29T17:34:35 | 13,063,931 | 9 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 184 | cpp | #include <iostream>
#include "stdio.h"
using namespace std;
int main()
{
int n1,n2;
while(scanf("%d %d",&n1,&n2)==2)
{
cout<<n1*n2*2<<endl;
}
return 0;
}
| [
"sergiomanuelesteves@gmail.com"
] | sergiomanuelesteves@gmail.com |
14c381c07226764d87c68ee830a3bc953cddbd13 | 8a98078487b88e45a07cfe837b653c6de570bfb3 | /source/Producer/src/HEPDSWProducerManager.cc | cea32f9869931d27f8185766d880336b9013d455 | [] | no_license | wjburger/HEPDSW_V4 | 7b3f8e4672ebfd4a2962c83d0ee230051f92ca36 | bed3f2ffa5b39af8782d497ccbc2ab279ff189c6 | refs/heads/master | 2020-03-25T18:27:51.874925 | 2018-08-27T14:42:01 | 2018-08-27T14:42:01 | 144,031,982 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 16,237 | cc | //
// wjb modifed for optical photon simulation
//
#include "HEPDSWProducerManager.hh"
#include "HEPDSWProducerMessenger.hh"
//Analyser
#include "G4RunManager.hh"
#include "G4ParticleTable.hh"
#include "G4SDManager.hh"
#include "G4EventManager.hh"
#include "G4RunManager.hh"
#include "G4PrimaryParticle.hh"
#include "G4Step.hh"
#include "G4Timer.hh"
#include "Randomize.hh"
#include "RootCaloHit.hh"
#include "CalorimeterSD.hh"
#include "VetoSD.hh"
#include "PmtSD.hh"
#include <map>
#include "G4PhysicalVolumeStore.hh"
#include "G4VPhysicalVolume.hh"
#include "G4LogicalVolume.hh"
#include "G4VTrajectory.hh"
#include "G4VTrajectoryPoint.hh"
#include "G4TrajectoryContainer.hh"
#include <iterator>
#include "G4SIunits.hh"
HEPDSWProducerManager* HEPDSWProducerManager::instance = 0;
////////////////////////////////////////////////////////////////////////////////
//
HEPDSWProducerManager::HEPDSWProducerManager():theEvent(0),theRootFile(0),theEventTree(0),thePathDir(0)
{
theMessenger = new HEPDSWProducerMessenger(this);
caloHitCollID=-1;
pmtHitsCollID=-1;
vetoHitCollID=-1;
trackerHitCollID=-1;
degraderHitCollID=-1;
trackCollID=-1;
vertexCollID=-1;
theAutoSaveLimit = 1000;
eventID=0;
verboseLevel = 0;
saveTracker=true;
saveMCTruth=true;
saveCalo=true;
saveDegrader=true;
theEvent = new RootEvent();
}
////////////////////////////////////////////////////////////////////////////////
//
HEPDSWProducerManager::~HEPDSWProducerManager()
{
delete theMessenger;
delete theEventTree;
delete theEvent;
delete theRootFile;
}
////////////////////////////////////////////////////////////////////////////////
//
void HEPDSWProducerManager::SetRootFile(G4String aFileName,G4String aDirName)
{
theRootFile = new TFile(aFileName,"RECREATE","Storing of HEPD info");
G4String aNameDir = aDirName;
thePathDir = theRootFile->mkdir(aNameDir);
thePathDir->cd();
theEventTree = new TTree("EventTree","The Tree with the variable used to performe the calculation of energy deposition on the HEPD detector");
theEventTree->Branch("Event","RootEvent",&theEvent);
theEventTree->SetAutoSave(theAutoSaveLimit);
}
HEPDSWProducerManager* HEPDSWProducerManager::GetInstance()
{
if (instance == 0) instance = new HEPDSWProducerManager;
return instance;
}
////////////////////////////////////////////////////////////////////////////////
//
void HEPDSWProducerManager::BeginOfEventAction(const G4Event*)
{
G4SDManager * SDman = G4SDManager::GetSDMpointer();
if(caloHitCollID<0||vetoHitCollID<0||trackerHitCollID<0||trackCollID<0){
if(saveCalo){
caloHitCollID = SDman->GetCollectionID("caloCollection");
vetoHitCollID = SDman->GetCollectionID("vetoCollection");
pmtHitsCollID = SDman->GetCollectionID("pmtCollection");
}
if(saveTracker)
trackerHitCollID = SDman->GetCollectionID("trackerHitCollection");
if(saveDegrader)
degraderHitCollID = SDman->GetCollectionID("degraderHitCollection");
if(saveMCTruth){
trackCollID = SDman->GetCollectionID("trackCollection");
vertexCollID = SDman->GetCollectionID("vertexCollection");
}
}
}
void HEPDSWProducerManager::StoreRootFile()
{
theRootFile->Write(0,TObject::kOverwrite);
theRootFile->Close();
}
void HEPDSWProducerManager::BeginOfRunAction(const G4Run*)
{
eventID=0;
}
///////////////////////////////////////////////////////////////////////////////
//
void HEPDSWProducerManager::EndOfEventAction(const G4Event* evt)
{
if(verboseLevel>0)
G4cout << "entering in EndOfEventAction..." << G4endl;
eventID = evt->GetEventID();
G4HCofThisEvent * HCE = evt->GetHCofThisEvent();
if(verboseLevel>0) {
G4cout << " prod fin eventID " << eventID << " HCE " << HCE << G4endl;
G4cout << " degraderHitCollID " << degraderHitCollID << G4endl;
G4cout << " trackerHitCollID " << trackerHitCollID << G4endl;
G4cout << " pmtHitsCollID " << pmtHitsCollID << G4endl;
G4cout << " caloHitCollID " << caloHitCollID << G4endl;
G4cout << " vetoHitCollID " << vetoHitCollID << G4endl;
G4cout << " trackCollID " << trackCollID << G4endl;
G4cout << " vertexCollID " << vertexCollID << G4endl;
}
PmtHitsCollection * pmtHC = 0;
CaloHitsCollection * caloHC = 0;
CaloHitsCollection * vetoHC = 0;
TrackerHitsCollection * trackerHC = 0;
DegraderHitsCollection * degraderHC = 0;
TracksCollection * trackHC = 0;
VertexsCollection * vertexHC = 0;
if(theCaloHitContainer.size())
theCaloHitContainer.clear();
if(thePmtHitsContainer.size())
thePmtHitsContainer.clear();
if(theVetoHitContainer.size())
theVetoHitContainer.clear();
if(theTrackerHitContainer.size())
theTrackerHitContainer.clear();
if(theDegraderHitContainer.size())
theDegraderHitContainer.clear();
if(theTrackContainer.size())
theTrackContainer.clear();
if(theVertexContainer.size())
theVertexContainer.clear();
if(HCE){
if(verboseLevel>0)
std::cout<<"Evento # "<<eventID<<std::endl;
if(!(degraderHitCollID<0)){
degraderHC = (DegraderHitsCollection*)(HCE->GetHC(degraderHitCollID));
for(int i=0;i<degraderHC->entries();i++){
TVector3 SPosHit((*degraderHC)[i]->GetStartPosition().getX(),(*degraderHC)[i]->GetStartPosition().getY(),(*degraderHC)[i]->GetStartPosition().getZ());
TVector3 EPosHit((*degraderHC)[i]->GetEndPosition().getX(),(*degraderHC)[i]->GetEndPosition().getY(),(*degraderHC)[i]->GetEndPosition().getZ());
TVector3 MomDirStartHit((*degraderHC)[i]->GetMomDirStart().getX(),(*degraderHC)[i]->GetMomDirStart().getY(),(*degraderHC)[i]->GetMomDirStart().getZ());
TVector3 MomDirEndHit((*degraderHC)[i]->GetMomDirEnd().getX(),(*degraderHC)[i]->GetMomDirEnd().getY(),(*degraderHC)[i]->GetMomDirEnd().getZ());
theDegraderHitContainer.push_back(RootDegraderHit((*degraderHC)[i]->GetKineticEnergy(),MomDirStartHit,MomDirEndHit,(*degraderHC)[i]->GetELoss(),SPosHit,EPosHit,(*degraderHC)[i]->GetStepLength(),(*degraderHC)[i]->GetdEdx(),(*degraderHC)[i]->GetTrackId(),(*degraderHC)[i]->GetParticleType()));
if(verboseLevel>0) std::cout<<"DegraderHit # "<<i<<" ; Edep = "<<(*degraderHC)[i]->GetELoss()<<" MeV"<<std::endl;
}
}
if(!(trackerHitCollID<0)){
trackerHC = (TrackerHitsCollection*)(HCE->GetHC(trackerHitCollID));
for(int i=0;i<trackerHC->entries();i++){
TVector3 Entry((*trackerHC)[i]->GetEntryPoint().getX(),(*trackerHC)[i]->GetEntryPoint().getY(),(*trackerHC)[i]->GetEntryPoint().getZ());
TVector3 Exit((*trackerHC)[i]->GetExitPoint().getX(),(*trackerHC)[i]->GetExitPoint().getY(),(*trackerHC)[i]->GetExitPoint().getZ());
TVector3 MomDir((*trackerHC)[i]->GetMomentumDirection().getX(),(*trackerHC)[i]->GetMomentumDirection().getY(),(*trackerHC)[i]->GetMomentumDirection().getZ());
theTrackerHitContainer.push_back(RootTrackerHit(Entry,Exit,(*trackerHC)[i]->GetKinEnergy(),(*trackerHC)[i]->GetToF(),(*trackerHC)[i]->GetELoss(),(*trackerHC)[i]->GetParticleType(),(*trackerHC)[i]->GetDetectorId(),(*trackerHC)[i]->GetTrackId(),(*trackerHC)[i]->GetThetaAtEntry(),(*trackerHC)[i]->GetPhiAtEntry(),MomDir));
//if(verboseLevel>0)
//std::cout<<"TrackerHit # "<<i<<" ; Edep = "<<(*trackerHC)[i]->GetELoss()<<" MeV"<<std::endl;
}
}
if(!(caloHitCollID<0)){
caloHC = (CaloHitsCollection*)(HCE->GetHC(caloHitCollID));
//G4cout << " caloHC entries " << caloHC->entries() << G4endl;
std::map<int,TVector3> aStepPosMap;
for(int i=0;i<caloHC->entries();i++){
aStepPosMap.clear();
TVector3 Entry((*caloHC)[i]->GetEntryPoint().getX(),(*caloHC)[i]->GetEntryPoint().getY(),(*caloHC)[i]->GetEntryPoint().getZ());
TVector3 Exit((*caloHC)[i]->GetExitPoint().getX(),(*caloHC)[i]->GetExitPoint().getY(),(*caloHC)[i]->GetExitPoint().getZ());
aStepPosMap.empty();
unsigned int mapsize = 0;
bool arret = false;
for(std::map<int,G4ThreeVector>::iterator j=(*caloHC)[i]->GetStepPosMap().begin();j!=(*caloHC)[i]->GetStepPosMap().end();j++){
mapsize++;
if ((*caloHC)[i]->GetStepPosMap().size()<mapsize) break;
int itkid = j->first;
G4ThreeVector g4tv = j->second;
TVector3 tv(g4tv.getX(),g4tv.getY(),g4tv.getZ());
aStepPosMap[itkid]=tv;
}
if (arret) break;
theCaloHitContainer.push_back( RootCaloHit((*caloHC)[i]->GetVolume(),Entry,Exit,(*caloHC)[i]->GetKinEnergy(),(*caloHC)[i]->GetTotalEdep()/CLHEP::MeV,(*caloHC)[i]->GetEdepMap(),aStepPosMap,(*caloHC)[i]->GetNPhot((*caloHC)[i]->GetVolume())) ); // OP
if(verboseLevel>0) std::cout <<"CaloHit # "<<i<<" ; Volume = "<<(*caloHC)[i]->GetVolume()<<" ; Edep = "<<(*caloHC)[i]->GetTotalEdep()/CLHEP::MeV<<" MeV"<< std::endl;
}
}
if(!(vetoHitCollID<0)){
vetoHC = (CaloHitsCollection*)(HCE->GetHC(vetoHitCollID));
//G4cout << " vetoHC entries " << vetoHC->entries() << G4endl;
std::map<int,TVector3> aStepPosMap;
for(int i=0;i<vetoHC->entries();i++){
aStepPosMap.clear();
TVector3 Entry((*vetoHC)[i]->GetEntryPoint().getX(),(*vetoHC)[i]->GetEntryPoint().getY(),(*vetoHC)[i]->GetEntryPoint().getZ());
TVector3 Exit((*vetoHC)[i]->GetExitPoint().getX(),(*vetoHC)[i]->GetExitPoint().getY(),(*vetoHC)[i]->GetExitPoint().getZ());
unsigned int mapsize = 0;
//bool arret = false;
for(std::map<int,G4ThreeVector>::iterator j=(*vetoHC)[i]->GetStepPosMap().begin();j!=(*vetoHC)[i]->GetStepPosMap().end();j++){
mapsize++;
if ((*vetoHC)[i]->GetStepPosMap().size()<mapsize) break;
int itkid = j->first;
G4ThreeVector g4tv = j->second;
TVector3 tv(g4tv.getX(),g4tv.getY(),g4tv.getZ());
aStepPosMap[itkid]=tv;
}
theVetoHitContainer.push_back(RootCaloHit((*vetoHC)[i]->GetVolume(),Entry,Exit,(*vetoHC)[i]->GetKinEnergy(),(*vetoHC)[i]->GetTotalEdep()/CLHEP::MeV,(*vetoHC)[i]->GetEdepMap(),aStepPosMap,(*vetoHC)[i]->GetNPhot((*vetoHC)[i]->GetVolume())) ); // OP
if(verboseLevel>0) std::cout<<"VetoHit # "<<i<<" ; Volume = "<<(*vetoHC)[i]->GetVolume()<<" ; Edep = "<<(*vetoHC)[i]->GetTotalEdep()/CLHEP::MeV<<" MeV"<<std::endl;
}
}
if(!(trackCollID<0)){
trackHC = (TracksCollection*)(HCE->GetHC(trackCollID));
for(int i=0;i<trackHC->entries();i++){
TVector3 Pos((*trackHC)[i]->GetPosition().getX(),(*trackHC)[i]->GetPosition().getY(),(*trackHC)[i]->GetPosition().getZ());
TVector3 Dir((*trackHC)[i]->GetMomentumDirection().getX(),(*trackHC)[i]->GetMomentumDirection().getY(),(*trackHC)[i]->GetMomentumDirection().getZ());
theTrackContainer.push_back(RootTrack((*trackHC)[i]->GetTrackId(),(*trackHC)[i]->GetPDGCode(),(*trackHC)[i]->GetName(),Pos,Dir,(*trackHC)[i]->GetKinEnergy(),(*trackHC)[i]->GetMotherTrackId(),(*trackHC)[i]->GetVertexVolumeName(),(*trackHC)[i]->GetCreatorProcessName()));
}
}
if(!(vertexCollID<0)){
vertexHC = (VertexsCollection*)(HCE->GetHC(vertexCollID));
if(vertexHC->entries()){
for(int i=0;i<vertexHC->entries();i++){
TString volumeName((std::string)(*vertexHC)[i]->GetVolumeName());
TVector3 Pos((*vertexHC)[i]->GetPosition().getX(),(*vertexHC)[i]->GetPosition().getY(),(*vertexHC)[i]->GetPosition().getZ());
theVertexContainer.push_back(RootVertex((*vertexHC)[i]->IsQuasielastic(),(*vertexHC)[i]->IsInelastic(),volumeName,Pos));
}
} else theVertexContainer.push_back(RootVertex(false,false,"NA",TVector3(0,0,0)));
}
if(!(pmtHitsCollID<0)){
pmtHC = (PmtHitsCollection*)(HCE->GetHC(pmtHitsCollID));
for(int i=0;i<pmtHC->entries();i++){
int TotalNPhot[53];
char PmtName[53][6];
// G4cout << " entree " << i << " NPmt " << (*pmtHC)[i]->GetNPmt() << G4endl;
for (int j=0; j<53; j++) {
TotalNPhot[j] = (*pmtHC)[i]->GetNPhot(j);
// G4cout << " pmt " << j << " TotalNPhot " << TotalNPhot[j] << G4endl;
switch (j) {
case 0: sprintf(PmtName[j],"%s","T1w"); break;
case 1: sprintf(PmtName[j],"%s","T1e"); break;
case 2: sprintf(PmtName[j],"%s","T2w"); break;
case 3: sprintf(PmtName[j],"%s","T2e"); break;
case 4: sprintf(PmtName[j],"%s","T3w"); break;
case 5: sprintf(PmtName[j],"%s","T3e"); break;
case 6: sprintf(PmtName[j],"%s","T4w"); break;
case 7: sprintf(PmtName[j],"%s","T4e"); break;
case 8: sprintf(PmtName[j],"%s","T5w"); break;
case 9: sprintf(PmtName[j],"%s","T5e"); break;
case 10: sprintf(PmtName[j],"%s","T6w"); break;
case 11: sprintf(PmtName[j],"%s","T6e"); break;
case 12: sprintf(PmtName[j],"%s","P1nw"); break;
case 13: sprintf(PmtName[j],"%s","P1se"); break;
case 14: sprintf(PmtName[j],"%s","P2sw"); break;
case 15: sprintf(PmtName[j],"%s","P2ne"); break;
case 16: sprintf(PmtName[j],"%s","P3nw"); break;
case 17: sprintf(PmtName[j],"%s","P3se"); break;
case 18: sprintf(PmtName[j],"%s","P4sw"); break;
case 19: sprintf(PmtName[j],"%s","P4ne"); break;
case 20: sprintf(PmtName[j],"%s","P5nw"); break;
case 21: sprintf(PmtName[j],"%s","P5se"); break;
case 22: sprintf(PmtName[j],"%s","P6sw"); break;
case 23: sprintf(PmtName[j],"%s","P6ne"); break;
case 24: sprintf(PmtName[j],"%s","P7nw"); break;
case 25: sprintf(PmtName[j],"%s","P7se"); break;
case 26: sprintf(PmtName[j],"%s","P8sw"); break;
case 27: sprintf(PmtName[j],"%s","P8ne"); break;
case 28: sprintf(PmtName[j],"%s","P9nw"); break;
case 29: sprintf(PmtName[j],"%s","P9se"); break;
case 30: sprintf(PmtName[j],"%s","P10sw"); break;
case 31: sprintf(PmtName[j],"%s","P10ne"); break;
case 32: sprintf(PmtName[j],"%s","P11nw"); break;
case 33: sprintf(PmtName[j],"%s","P11se"); break;
case 34: sprintf(PmtName[j],"%s","P12sw"); break;
case 35: sprintf(PmtName[j],"%s","P12ne"); break;
case 36: sprintf(PmtName[j],"%s","P13nw"); break;
case 37: sprintf(PmtName[j],"%s","P13se"); break;
case 38: sprintf(PmtName[j],"%s","P14sw"); break;
case 39: sprintf(PmtName[j],"%s","P14ne"); break;
case 40: sprintf(PmtName[j],"%s","P15nw"); break;
case 41: sprintf(PmtName[j],"%s","P15se"); break;
case 42: sprintf(PmtName[j],"%s","P16sw"); break;
case 43: sprintf(PmtName[j],"%s","P16ne"); break;
case 44: sprintf(PmtName[j],"%s","L1ne"); break;
case 45: sprintf(PmtName[j],"%s","L4n"); break;
case 46: sprintf(PmtName[j],"%s","L7nw"); break;
case 47: sprintf(PmtName[j],"%s","L2e"); break;
case 48: sprintf(PmtName[j],"%s","L5c"); break;
case 49: sprintf(PmtName[j],"%s","L8w"); break;
case 50: sprintf(PmtName[j],"%s","L3se"); break;
case 51: sprintf(PmtName[j],"%s","L6s"); break;
case 52: sprintf(PmtName[j],"%s","L9sw"); break;
default: break;
}
}
thePmtHitsContainer.push_back(RootPmtHits(TotalNPhot,&PmtName[0],
(*pmtHC)[i]->GetNPmt()));
}
}
if(verboseLevel>0)
std::cout<<"=============================================================================================="<<std::endl;
}
if(verboseLevel>0)
G4cout << "theEvent: " << theEvent << G4endl;
theEvent->SetEventID(eventID);
if(verboseLevel>0)
G4cout << "saveCalo: " << saveCalo << "\tsaveTracker: " << saveTracker << "\tsaveDegrader: " << saveDegrader <<"\tsaveMCTruth: " << saveMCTruth << G4endl;
if(saveCalo){
theEvent->SetCaloHit(theCaloHitContainer);
theEvent->SetVetoHit(theVetoHitContainer);
theEvent->SetPmtHits(thePmtHitsContainer);
}
if(saveTracker)
theEvent->SetTrackerHit(theTrackerHitContainer);
if(saveDegrader)
theEvent->SetDegraderHit(theDegraderHitContainer);
if(saveMCTruth){
theEvent->SetTracks(theTrackContainer);
theEvent->SetVertex(theVertexContainer);
}
//if(verboseLevel>0)
//G4cout << "theEventTree: 0x" << theEventTree << G4endl;
theEventTree->Fill();
if(verboseLevel>0)
G4cout << "leaving in EndOfEventAction..." << G4endl;
}
| [
"william.burger@tifpa.infn.it"
] | william.burger@tifpa.infn.it |
323af634443654c1ff92766dabf5882e39795df8 | 54485318384fccc4031e9ce640cd0ec3b176e52f | /baekjoon/tetromino/main.cpp | 5d5d1c059bf39cfccbd0e0634ca5a876f6281c81 | [] | no_license | lazymonday/PS | f67afc2be9b40af861dcd9824c644595f8325a07 | 79750b485727ef46dc6017b582b058c27b4e8fb1 | refs/heads/main | 2023-01-20T08:46:02.561418 | 2020-12-01T14:01:37 | 2020-12-01T14:01:37 | 303,917,059 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,823 | cpp | #include <iostream>
#include <algorithm>
struct Tetromino {
int x[4];
int y[4];
Tetromino(int x[4], int y[4]) {
for (int i = 0; i < 4; ++i) {
this->x[i] = x[i];
this->y[i] = y[i];
}
}
};
int n, m;
int findMaxSum();
// ㅡ
Tetromino tet_1[2] = {
Tetromino(new int[4]{0, 1, 2, 3}, new int[4]{0, 0, 0, 0}),
Tetromino(new int[4]{0, 0, 0, 0}, new int[4]{0, 1, 2, 3}),
};
// ㅁ
Tetromino tet_2[1] = {
Tetromino(new int[4]{0, 1, 0, 1}, new int[4]{0, 0, 1, 1}),
};
// ㄴ
Tetromino tet_3[8] = {
Tetromino(new int[4]{0, 0, 0, 1}, new int[4]{0, 1, 2, 2}),
Tetromino(new int[4]{0, 1, 2, 0}, new int[4]{0, 0, 0, 1}),
Tetromino(new int[4]{0, 1, 1, 1}, new int[4]{0, 0, 1, 2}),
Tetromino(new int[4]{0, 1, 2, 2}, new int[4]{0, 0, 0, -1}),
Tetromino(new int[4]{0, 0, 0, -1}, new int[4]{0, 1, 2, 2}),
Tetromino(new int[4]{0, 0, 1, 2}, new int[4]{0, 1, 1, 1}),
Tetromino(new int[4]{0, 0, 0, 1}, new int[4]{0, 1, 2, 0}),
Tetromino(new int[4]{0, 1, 2, 2}, new int[4]{0, 0, 0, 1}),
};
// ㄱㄴ
Tetromino tet_4[4] = {
Tetromino(new int[4]{0, 0, 1, 1}, new int[4]{0, 1, 1, 2}),
Tetromino(new int[4]{0, 0, -1, -1}, new int[4]{0, 1, 1, 2}),
Tetromino(new int[4]{0, 1, 1, 2}, new int[4]{0, 0, -1, -1}),
Tetromino(new int[4]{0, 1, 1, 2}, new int[4]{0, 0, 1, 1}),
};
// ㅜ
Tetromino tet_5[4] = {
Tetromino(new int[4]{0, 1, 2, 1}, new int[4]{0, 0, 0, -1}), // ㅗ
Tetromino(new int[4]{0, 1, 2, 1}, new int[4]{0, 0, 0, 1}), // ㅜ
Tetromino(new int[4]{0, 0, 0, 1}, new int[4]{0, 1, 2, 1}), // ㅏ
Tetromino(new int[4]{0, 0, 0, -1}, new int[4]{0, 1, 2, 1}), // ㅓ
};
int board[502][502] = {0};
void printTetromino() {
Tetromino *tets[] = {tet_1, tet_2, tet_3, tet_4, tet_5};
int sizes[5] = {2, 1, 8, 4, 4};
for (int k = 0; k < 5; ++k) {
Tetromino *tet = tets[k];
for (int i = 0; i < sizes[k]; ++i) {
for (int j = 0; j < 4; ++j) {
board[tet[i].y[j] + 1][tet[i].x[j] + 1] = 1;
}
for (int i = 0; i < 5; ++i) { // row
for (int j = 0; j < 5; ++j) { // col
std::cout << board[i][j];
board[i][j] = 0;
}
std::cout << std::endl;
}
std::cout << std::endl;
}
}
}
int findMaxSum() {
Tetromino *tets[] = {tet_1, tet_2, tet_3, tet_4, tet_5};
int sizes[5] = {2, 1, 8, 4, 4};
int max = 0;
for (int k = 0; k < 5; ++k) {
Tetromino *tet = tets[k];
for (int i = 0; i < sizes[k]; ++i) {
for (int r = 0; r < n + 2; ++r) {
for (int c = 0; c < m + 2; ++c) {
int sum = 0;
for (int j = 0; j < 4; ++j) {
int x = tet[i].x[j] + c;
int y = tet[i].y[j] + r;
if (x < 0 || x > m + 1) {
break;
}
if (y < 0 || y > n + 1) {
break;
}
sum += board[y][x];
}
max = std::max(max, sum);
}
}
}
}
return max;
}
int main() {
//printTetromino();
std::cin >> n;
std::cin >> m;
for (int i = 0; i <= n + 1; ++i) {
for (int j = 0; j <= m + 1; ++j) {
if (i == 0 || j == 0 || i == n + 1 || j == m + 1) {
board[i][j] = 0;
} else {
std::cin >> board[i][j];
}
}
}
int ret = findMaxSum();
std::cout << ret << std::endl;
return 0;
} | [
"lazymonday@gmail.com"
] | lazymonday@gmail.com |
0b1d050ab7575f48feca97c2476098c32848240b | 339f706c892eb4ef53a2471f518005a797eb86d5 | /ming/linux/linux_mutex.h | e24feaf840b048e0635b18bed9576d40c345d92f | [
"MIT"
] | permissive | gmd20/ming | 032b62d65ba7657500b9feffbd7f3e35d1ae2169 | 05b9c44789edc1a77e00996d301c6fda649433da | refs/heads/master | 2022-09-29T10:48:05.201304 | 2022-09-14T03:06:50 | 2022-09-14T03:06:50 | 20,284,391 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 633 | h | #ifndef MING_LINUX_MUTEX_H_
#define MING_LINUX_MUTEX_H_
#include <pthread.h>
#include "ming/noncopyable.h"
#include "ming/scoped_lock.h"
namespace ming {
class Mutex : private noncopyable {
public:
typedef ming::ScopedLock<Mutex> ScopedLock;
Mutex() { ::pthread_mutex_init(&mutex_, 0); }
~Mutex() {
::pthread_mutex_destroy(&mutex_); // Ignore EBUSY.
}
void Lock() {
(void)::pthread_mutex_lock(&mutex_); // Ignore EINVAL.
}
void Unlock() {
(void)::pthread_mutex_unlock(&mutex_); // Ignore EINVAL.
}
private:
::pthread_mutex_t mutex_;
};
} // namespace ming
#endif // MING_LINUX_MUTEX_H_
| [
"gmd20@163.com"
] | gmd20@163.com |
a2c37d0df972be89428bea90b5ba22cff4cb2655 | 6f57bf8a8135b94dad2b3fce61627262c6f923c3 | /scientific_repo-headers/async_task_library/source/task_system.cxx | 739d2990cd6f0f3872303cf6e831b9fa57458d16 | [
"CC0-1.0"
] | permissive | mtezych/towards-better-cxx-compilation-model | 65ddb08b5e1719a355c63664bc944df477f1ff3f | 876d8f281c592bea786f0f34d122f954a36199ab | refs/heads/master | 2022-11-17T21:46:45.790242 | 2020-07-10T22:48:40 | 2020-07-10T22:56:28 | 278,736,312 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 841 | cxx |
#include <atl/task_system.hxx>
namespace atl
{
namespace
{
auto run_thread (task_queue& queue) -> void
{
while (true)
{
auto task = queue.pop();
if (task)
{
std::invoke(*task);
}
else
{
break;
}
}
}
}
task_system::task_system ()
{
const auto thread_count = std::thread::hardware_concurrency();
for (auto i = 0uL; i != thread_count; ++i)
{
threads.emplace_back([this] () { run_thread(queue); });
}
}
task_system::~task_system ()
{
queue.finish();
for (auto& thread : threads)
{
thread.join();
}
}
}
| [
"mte.zych@gmail.com"
] | mte.zych@gmail.com |
eb335f831a34110abef2b4cae55c60d0aa77c3dc | aa0ef419f30a14799d943f896b1d978cbd265b2d | /HOAOIs/AOIModels/TowerAOI/TowerAOI.cpp | e2aa621776991f9a2006c4cfacd00e4290e1b354 | [] | no_license | zklgame/HOAOIs | 4c7b799af2ffb2c17b45aa1d81a8a03fa8a0c14f | 22e1560bc178cbf47e0bf56a5b138ce715e78c2c | refs/heads/master | 2016-09-12T19:52:55.025686 | 2016-05-21T06:35:37 | 2016-05-21T06:35:37 | 58,842,596 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 25,322 | cpp | //
// TowerAOI.cpp
// AOIs
//
// Created by zklgame on 4/13/16.
// Copyright © 2016 Zhejiang University. All rights reserved.
//
#include "TowerAOI.hpp"
#include <cmath>
TowerAOI::TowerAOI(position_t worldWidth, position_t worldHeight, position_t towerWidth, position_t towerHeight): worldWidth(worldWidth), worldHeight(worldHeight), towerWidth(towerWidth), towerHeight(towerHeight) {
// tower range: [ ... )
this -> towerX = worldWidth / towerWidth + 1;
this -> towerY = worldHeight / towerHeight + 1;
for (position_t i = 0; i < this -> towerX; i ++) {
for (position_t j = 0; j < this -> towerY; j ++) {
this -> towers[i][j] = new Tower();
}
}
}
TowerAOI::~TowerAOI() {
for (position_t i = 0; i < this -> towerX; i ++) {
for (position_t j = 0; j < this -> towerY; j ++) {
delete this -> towers[i][j];
}
}
}
bool TowerAOI::addPublisher(GameObject *obj) {
position_t towerPosX = obj -> posX / this -> towerWidth;
position_t towerPosY = obj -> posY / this -> towerHeight;
this -> towers[towerPosX][towerPosY] -> addPublisher(obj);
this -> findSubscribersInTheirRange(obj, ADD_MESSAGE);
return true;
}
bool TowerAOI::addSubscriber(GameObject *obj) {
this -> subscribers[obj -> id] = obj;
this -> findPublishersInRange(obj, ADD_MESSAGE);
return true;
}
bool TowerAOI::removePublisher(GameObject *obj) {
this -> findSubscribersInTheirRange(obj, REMOVE_MESSAGE);
position_t towerPosX = obj -> posX / this -> towerWidth;
position_t towerPosY = obj -> posY / this -> towerHeight;
this -> towers[towerPosX][towerPosY] -> removePublisher(obj);
return true;
}
bool TowerAOI::removeSubscriber(GameObject *obj) {
this -> findPublishersInRange(obj, REMOVE_MESSAGE);
this -> subscribers . erase(obj -> id);
return true;
}
bool TowerAOI::addHugePublisher(HOGameObject *obj) {
position_t towerMinPosX = obj -> minPosX / this -> towerWidth;
position_t towerMinPosY = obj -> minPosY / this -> towerHeight;
position_t towerMaxPosX = obj -> maxPosX / this -> towerWidth;
position_t towerMaxPosY = obj -> maxPosY / this -> towerHeight;
for (position_t i = towerMinPosX; i <= towerMaxPosX; i ++) {
for (position_t j = towerMinPosY; j <= towerMaxPosY; j ++) {
this -> towers[i][j] -> addPublisher(obj);
}
}
this -> findSubscribersInTheirRangeForHO(obj, ADD_MESSAGE);
return true;
}
bool TowerAOI::addHugeSubscriber(HOGameObject *obj) {
this -> hugeSubscribers[obj -> id] = obj;
this -> findPublishersInRangeForHO(obj, ADD_MESSAGE);
return true;
}
bool TowerAOI::removeHugePublisher(HOGameObject *obj) {
this -> findSubscribersInTheirRangeForHO(obj, REMOVE_MESSAGE);
position_t towerMinPosX = obj -> minPosX / this -> towerWidth;
position_t towerMinPosY = obj -> minPosY / this -> towerHeight;
position_t towerMaxPosX = obj -> maxPosX / this -> towerWidth;
position_t towerMaxPosY = obj -> maxPosY / this -> towerHeight;
for (position_t i = towerMinPosX; i <= towerMaxPosX; i ++) {
for (position_t j = towerMinPosY; j <= towerMaxPosY; j ++) {
this -> towers[i][j] -> removePublisher(obj);
}
}
return true;
}
bool TowerAOI::removeHugeSubscriber(HOGameObject *obj) {
this -> findPublishersInRangeForHO(obj, REMOVE_MESSAGE);
this -> hugeSubscribers . erase(obj -> id);
return true;
}
bool TowerAOI::onPublisherMove(GameObject *obj, position_t oldPosX, position_t oldPosY) {
if (oldPosX != obj -> posX || oldPosY != obj -> posY) {
this -> towers[oldPosX / towerWidth][oldPosY / towerHeight] -> removePublisher(obj);
this -> towers[obj -> posX / towerWidth][obj -> posY / towerHeight] -> addPublisher(obj);
}
map<entity_t, GameObject *> oldSubMaps, newSubMaps;
oldSubMaps = this -> BaseAOI::findSubscribersInTheirRange(obj -> id, oldPosX, oldPosY);
newSubMaps = this -> BaseAOI::findSubscribersInTheirRange(obj -> id, obj -> posX, obj -> posY);
list<GameObject *> addSet, moveSet, removeSet;
map<entity_t, GameObject *> :: iterator iter;
for (iter = oldSubMaps . begin(); iter != oldSubMaps . end(); iter ++) {
if (newSubMaps.find(iter -> first) != newSubMaps.end()) {
moveSet.push_back(iter -> second);
newSubMaps.erase(iter -> first);
} else {
removeSet.push_back(iter -> second);
}
}
if (newSubMaps.size() > 0) {
for (iter = newSubMaps . begin(); iter != newSubMaps . end(); iter ++) {
addSet.push_back(iter -> second);
}
}
this -> aoiEventManager -> onAddPublisher(obj, addSet);
this -> aoiEventManager -> onRemovePublisher(obj, removeSet);
this -> aoiEventManager -> onMovePublisher(obj, moveSet);
return true;
}
bool TowerAOI::onSubscriberMove(GameObject *obj, position_t oldPosX, position_t oldPosY) {
map<entity_t, GameObject *> oldPubMaps, newPubMaps;
oldPubMaps = this -> findPublishersInRange(obj -> id, oldPosX, oldPosY, obj -> range);
newPubMaps = this -> findPublishersInRange(obj -> id, obj -> posX, obj -> posY, obj -> range);
list<GameObject *> addSet, moveSet, removeSet;
map<entity_t, GameObject *> :: iterator iter;
for (iter = oldPubMaps . begin(); iter != oldPubMaps . end(); iter ++) {
if (newPubMaps.find(iter -> first) != newPubMaps.end()) {
moveSet.push_back(iter -> second);
newPubMaps.erase(iter -> first);
} else {
removeSet.push_back(iter -> second);
}
}
if (newPubMaps.size() > 0) {
for (iter = newPubMaps . begin(); iter != newPubMaps . end(); iter ++) {
addSet.push_back(iter -> second);
}
}
// do no change to moveSet
this -> aoiEventManager -> onAddSubscriber(obj, addSet);
this -> aoiEventManager -> onRemoveSubscriber(obj, removeSet);
return true;
}
bool TowerAOI::onHugePublisherMove(HOGameObject *obj, position_t oldMinPosX, position_t oldMinPosY, position_t oldMaxPosX, position_t oldMaxPosY) {
position_t oldTowerMinPosX = oldMinPosX / this -> towerWidth;
position_t oldTowerMinPosY = oldMinPosY / this -> towerHeight;
position_t oldTowerMaxPosX = oldMaxPosX / this -> towerWidth;
position_t oldTowerMaxPosY = oldMaxPosY / this -> towerHeight;
position_t towerMinPosX = obj -> minPosX / this -> towerWidth;
position_t towerMinPosY = obj -> minPosY / this -> towerHeight;
position_t towerMaxPosX = obj -> maxPosX / this -> towerWidth;
position_t towerMaxPosY = obj -> maxPosY / this -> towerHeight;
if (oldTowerMinPosX != towerMinPosX || oldTowerMinPosY != towerMinPosY || oldTowerMaxPosX != towerMaxPosX || oldTowerMaxPosY != towerMaxPosY) {
for (position_t i = oldTowerMinPosX; i <= oldTowerMaxPosX; i ++) {
for (position_t j = oldTowerMinPosY; j <= oldTowerMaxPosY; j ++) {
this -> towers[i][j] -> removePublisher(obj);
}
}
for (position_t i = towerMinPosX; i <= towerMaxPosX; i ++) {
for (position_t j = towerMinPosY; j <= towerMaxPosY; j ++) {
this -> towers[i][j] -> addPublisher(obj);
}
}
}
map<entity_t, GameObject *> oldSubMaps, newSubMaps;
oldSubMaps = this -> BaseAOI::findSubscribersInTheirRangeForHO(obj -> id, oldMinPosX, oldMinPosY, oldMaxPosX, oldMaxPosY);
newSubMaps = this -> BaseAOI::findSubscribersInTheirRangeForHO(obj -> id, obj -> minPosX, obj -> minPosY, obj -> maxPosX, obj -> maxPosY);
list<GameObject *> addSet, moveSet, removeSet;
map<entity_t, GameObject *> :: iterator iter;
for (iter = oldSubMaps . begin(); iter != oldSubMaps . end(); iter ++) {
if (newSubMaps.find(iter -> first) != newSubMaps.end()) {
moveSet.push_back(iter -> second);
newSubMaps.erase(iter -> first);
} else {
removeSet.push_back(iter -> second);
}
}
if (newSubMaps.size() > 0) {
for (iter = newSubMaps . begin(); iter != newSubMaps . end(); iter ++) {
addSet.push_back(iter -> second);
}
}
this -> aoiEventManager -> onAddPublisher(obj, addSet);
this -> aoiEventManager -> onRemovePublisher(obj, removeSet);
this -> aoiEventManager -> onMovePublisher(obj, moveSet);
return true;
}
bool TowerAOI::onHugeSubscriberMove(HOGameObject *obj, position_t oldMinPosX, position_t oldMinPosY, position_t oldMaxPosX, position_t oldMaxPosY) {
map<entity_t, GameObject *> oldPubMaps, newPubMaps;
oldPubMaps = this -> findPublishersInRangeForHO(obj -> id, oldMinPosX, oldMinPosY, oldMaxPosX, oldMaxPosY, obj -> range);
newPubMaps = this -> findPublishersInRangeForHO(obj -> id, obj -> minPosX, obj -> minPosY, obj -> maxPosX, obj -> maxPosY, obj -> range);
list<GameObject *> addSet, moveSet, removeSet;
map<entity_t, GameObject *> :: iterator iter;
for (iter = oldPubMaps . begin(); iter != oldPubMaps . end(); iter ++) {
if (newPubMaps.find(iter -> first) != newPubMaps.end()) {
moveSet.push_back(iter -> second);
newPubMaps.erase(iter -> first);
} else {
removeSet.push_back(iter -> second);
}
}
if (newPubMaps.size() > 0) {
for (iter = newPubMaps . begin(); iter != newPubMaps . end(); iter ++) {
addSet.push_back(iter -> second);
}
}
// do no change to moveSet
this -> aoiEventManager -> onAddSubscriber(obj, addSet);
this -> aoiEventManager -> onRemoveSubscriber(obj, removeSet);
return true;
}
void TowerAOI::findSubscribersInTheirRange(GameObject *obj, state_t state) {
map<entity_t, GameObject *> subMaps = this -> BaseAOI::findSubscribersInTheirRange(obj -> id, obj -> posX, obj -> posY);
list<GameObject *> subs = transMapsToLists(subMaps);
if (ADD_MESSAGE == state) {
this -> aoiEventManager -> onAddPublisher(obj, subs);
} else if (REMOVE_MESSAGE == state) {
this -> aoiEventManager -> onRemovePublisher(obj, subs);
}
}
void TowerAOI::findPublishersInRange(GameObject *obj, state_t state) {
map<entity_t, GameObject *> pubMaps = this -> findPublishersInRange(obj -> id, obj -> posX, obj -> posY, obj -> range);
list<GameObject *> pubs = transMapsToLists(pubMaps);
if (ADD_MESSAGE == state) {
this -> aoiEventManager -> onAddSubscriber(obj, pubs);
} else if (REMOVE_MESSAGE == state) {
this -> aoiEventManager -> onRemoveSubscriber(obj, pubs);
}
}
void TowerAOI::findSubscribersInTheirRangeForHO(HOGameObject *obj, state_t state) {
map<entity_t, GameObject *> subMaps = this -> BaseAOI::findSubscribersInTheirRangeForHO(obj -> id, obj -> minPosX, obj -> minPosY, obj -> maxPosX, obj -> maxPosY);
list<GameObject *> subs = transMapsToLists(subMaps);
if (ADD_MESSAGE == state) {
this -> aoiEventManager -> onAddPublisher(obj, subs);
} else if (REMOVE_MESSAGE == state) {
this -> aoiEventManager -> onRemovePublisher(obj, subs);
}
}
void TowerAOI::findPublishersInRangeForHO(HOGameObject *obj, state_t state) {
map<entity_t, GameObject *> pubMaps = this -> findPublishersInRangeForHO(obj -> id, obj -> minPosX, obj -> minPosY, obj -> maxPosX, obj -> maxPosY, obj -> range);
list<GameObject *> pubs = transMapsToLists(pubMaps);
// receive messages from above publishers
if (ADD_MESSAGE == state) {
this -> aoiEventManager -> onAddSubscriber(obj, pubs);
} else if (REMOVE_MESSAGE == state) {
this -> aoiEventManager -> onRemoveSubscriber(obj, pubs);
}
}
map<entity_t, GameObject *> TowerAOI::findPublishersInRange(entity_t objId, position_t posX, position_t posY, position_t range) {
map<entity_t, GameObject *> pubs, partialPubs;
list<Tower*> fullCoveredTowers, partialCoveredTowers;
list<Tower*>::iterator iter;
map<entity_t, GameObject *>::iterator pubMapIter;
position_t towerPosX = posX / this -> towerWidth;
position_t towerPosY = posY / this -> towerHeight;
position_t i, j;
for (i = towerPosX; i < this -> towerX; i ++) {
for (j = towerPosY; j < this -> towerY; j ++) {
if (!classifyTower(posX, posY, range, i, j, fullCoveredTowers, partialCoveredTowers)) {
break;
}
}
if (towerPosY != 0) {
for (j = towerPosY - 1; j != 0; j --) {
if (!classifyTower(posX, posY, range, i, j, fullCoveredTowers, partialCoveredTowers)) {
break;
}
}
if (0 == j) {
classifyTower(posX, posY, range, i, j, fullCoveredTowers, partialCoveredTowers);
}
}
}
if (towerPosX != 0) {
for (i = towerPosX - 1; i != 0; i --) {
for (j = towerPosY; j < this -> towerY; j ++) {
if (!classifyTower(posX, posY, range, i, j, fullCoveredTowers, partialCoveredTowers)) {
break;
}
}
if (towerPosY != 0) {
for (j = towerPosY - 1; j != 0; j --) {
if (!classifyTower(posX, posY, range, i, j, fullCoveredTowers, partialCoveredTowers)) {
break;
}
}
if (0 == j) {
classifyTower(posX, posY, range, i, j, fullCoveredTowers, partialCoveredTowers);
}
}
}
if (0 == i) {
for (j = towerPosY; j < this -> towerY; j ++) {
if (!classifyTower(posX, posY, range, i, j, fullCoveredTowers, partialCoveredTowers)) {
break;
}
}
if (towerPosY != 0) {
for (j = towerPosY - 1; j != 0; j --) {
if (!classifyTower(posX, posY, range, i, j, fullCoveredTowers, partialCoveredTowers)) {
break;
}
}
if (0 == j) {
classifyTower(posX, posY, range, i, j, fullCoveredTowers, partialCoveredTowers);
}
}
}
}
for (iter = fullCoveredTowers . begin(); iter != fullCoveredTowers . end(); iter ++) {
pubs = addTwoMaps(pubs, (*iter) -> getPublishers());
}
int32_t minPosX, minPosY, maxPosX, maxPosY;
// traversal all the partialCoveredTowers to find all the object in range
for (iter = partialCoveredTowers . begin(); iter != partialCoveredTowers . end(); iter ++) {
partialPubs = (*iter) -> getPublishers();
for (pubMapIter = partialPubs.begin(); pubMapIter != partialPubs.end(); pubMapIter ++) {
if (!pubMapIter -> second -> isHugeObject) {
if (isInRange2(posX, posY, pubMapIter -> second -> posX, pubMapIter -> second -> posY, range)) {
pubs[pubMapIter -> first] = pubMapIter -> second;
}
} else {
HOGameObject *obj = (HOGameObject *)(pubMapIter -> second);
minPosX = obj -> minPosX;
minPosY = obj -> minPosY;
maxPosX = obj -> maxPosX;
maxPosY = obj -> maxPosY;
if (isPointInRect(posX, posY, minPosX - range, minPosY - range, maxPosX + range, maxPosY + range)) {
if (posX <= minPosX && posY <= minPosY) {
if (!isInRange2(posX, posY, minPosX, minPosY, range)) {
continue;
}
} else if (posX <= minPosX && posY >= maxPosY) {
if (!isInRange2(posX, posY, minPosX, maxPosY, range)) {
continue;
}
} else if(posX >= maxPosX && posY <= minPosY) {
if (!isInRange2(posX, posY, maxPosX, minPosY, range)) {
continue;
}
} else if(posX >= maxPosX && posY >= maxPosY) {
if (!isInRange2(posX, posY, maxPosX, maxPosY, range)) {
continue;
}
}
pubs[pubMapIter -> first] = pubMapIter -> second;
}
}
}
}
pubs.erase(objId);
return pubs;
}
map<entity_t, GameObject *> TowerAOI::findPublishersInRangeForHO(entity_t objId, position_t minPosX, position_t minPosY, position_t maxPosX, position_t maxPosY, position_t range) {
map<entity_t, GameObject *> pubs, partialPubs;
list<Tower*> fullCoveredTowers, partialCoveredTowers;
list<Tower*>::iterator iter;
map<entity_t, GameObject *>::iterator pubMapIter;
position_t newMinPosX, newMinPosY, newMaxPosX, newMaxPosY;
newMinPosX = minPosX < range ? 0 : minPosX - range;
newMinPosY = minPosY < range ? 0 : minPosY - range;
newMaxPosX = maxPosX + range >= this -> worldWidth ? this -> worldWidth - 1 : maxPosX + range;
newMaxPosY = maxPosY + range >= this -> worldHeight ? this -> worldHeight - 1 : maxPosY + range;
position_t newTowerMinPosX = newMinPosX / this -> towerWidth;
position_t newTowerMinPosY = newMinPosY / this -> towerHeight;
position_t newTowerMaxPosX = newMaxPosX / this -> towerWidth;
position_t newTowerMaxPosY = newMaxPosY / this -> towerHeight;
position_t towerMinPosX = minPosX / this -> towerWidth;
position_t towerMinPosY = minPosY / this -> towerHeight;
position_t towerMaxPosX = maxPosX / this -> towerWidth;
position_t towerMaxPosY = maxPosY / this -> towerHeight;
for (position_t i = newTowerMinPosX; i <= towerMinPosX; i ++) {
for (position_t j = newTowerMinPosY; j <= towerMinPosY; j ++) {
partialCoveredTowers.push_back(this -> towers[i][j]);
}
for (position_t j = towerMaxPosY; j <= newTowerMaxPosY; j ++) {
partialCoveredTowers.push_back(this -> towers[i][j]);
}
}
for (position_t i = towerMaxPosX; i <= newTowerMaxPosX; i ++) {
for (position_t j = newTowerMinPosY; j <= towerMinPosY; j ++) {
partialCoveredTowers.push_back(this -> towers[i][j]);
}
for (position_t j = towerMaxPosY; j <= newTowerMaxPosY; j ++) {
partialCoveredTowers.push_back(this -> towers[i][j]);
}
}
for (position_t j = towerMinPosY + 1; j < towerMaxPosY; j ++) {
partialCoveredTowers.push_back(this -> towers[newTowerMinPosX][j]);
partialCoveredTowers.push_back(this -> towers[newTowerMaxPosX][j]);
}
for (position_t i = towerMinPosX + 1; i < towerMaxPosX; i ++) {
partialCoveredTowers.push_back(this -> towers[i][newTowerMinPosY]);
partialCoveredTowers.push_back(this -> towers[i][newTowerMaxPosY]);
}
for (position_t i = newTowerMinPosX + 1; i < newTowerMaxPosX; i ++) {
for (position_t j = towerMinPosY + 1; j < towerMaxPosY; j ++) {
fullCoveredTowers.push_back(this -> towers[i][j]);
}
}
for (position_t i = towerMinPosX + 1; i < towerMaxPosX; i ++) {
for (position_t j = newTowerMinPosY + 1; j <= towerMinPosY; j ++) {
fullCoveredTowers.push_back(this -> towers[i][j]);
}
for (position_t j = towerMaxPosY; j < newTowerMaxPosY; j ++) {
fullCoveredTowers.push_back(this -> towers[i][j]);
}
}
// for (position_t i = newTowerMinPosX; i <= newTowerMaxPosX; i ++) {
// for (position_t j = newTowerMinPosY; j <= towerMinPosY; j ++) {
// partialCoveredTowers.push_back(this -> towers[i][j]);
// }
// for (position_t j = towerMaxPosY; j <= newTowerMaxPosY; j ++) {
// partialCoveredTowers.push_back(this -> towers[i][j]);
// }
// }
//
// for (position_t j = towerMinPosY + 1; j < towerMaxPosY; j ++) {
// partialCoveredTowers.push_back(this -> towers[newTowerMinPosX][j]);
// partialCoveredTowers.push_back(this -> towers[newTowerMaxPosX][j]);
// }
//
// for (position_t i = newTowerMinPosX + 1; i < newTowerMaxPosX; i ++) {
// for (position_t j = towerMinPosY + 1; j < towerMaxPosY; j ++) {
// fullCoveredTowers.push_back(this -> towers[i][j]);
// }
// }
for (iter = fullCoveredTowers . begin(); iter != fullCoveredTowers . end(); iter ++) {
pubs = addTwoMaps(pubs, (*iter) -> getPublishers());
}
position_t posX, posY;
// traversal all the partialCoveredTowers to find all the object in range
for (iter = partialCoveredTowers . begin(); iter != partialCoveredTowers . end(); iter ++) {
partialPubs = (*iter) -> getPublishers();
for (pubMapIter = partialPubs.begin(); pubMapIter != partialPubs.end(); pubMapIter ++) {
if (!pubMapIter -> second -> isHugeObject) {
posX = pubMapIter -> second -> posX;
posY = pubMapIter -> second -> posY;
if (isPointInRect(posX, posY, newMinPosX, newMinPosY, newMaxPosX, newMaxPosY)) {
if (posX <= minPosX && posY <= minPosY) {
if (!isInRange2(posX, posY, minPosX, minPosY, range)) {
continue;
}
} else if (posX <= minPosX && posY >= maxPosY) {
if (!isInRange2(posX, posY, minPosX, maxPosY, range)) {
continue;
}
} else if(posX >= maxPosX && posY <= minPosY) {
if (!isInRange2(posX, posY, maxPosX, minPosY, range)) {
continue;
}
} else if(posX >= maxPosX && posY >= maxPosY) {
if (!isInRange2(posX, posY, maxPosX, maxPosY, range)) {
continue;
}
}
pubs[pubMapIter -> first] = pubMapIter -> second;
}
}
// else {
// HOGameObject *obj = (HOGameObject *)(pubMapIter -> second);
//
// if (obj -> minPosX > maxPosX || obj -> maxPosX < minPosX || obj -> minPosY > maxPosY || obj -> maxPosY < minPosY) {
// // blank
// } else {
// pubs[pubMapIter -> first] = pubMapIter -> second;
// }
// }
}
}
pubs.erase(objId);
return pubs;
}
bool TowerAOI::isFullCoveredTower(position_t posX, position_t posY, position_t range, position_t pos1X, position_t pos1Y, position_t pos2X, position_t pos2Y) {
if ((isInRange2(posX, posY, pos1X, pos1Y, range)) &&
(isInRange2(posX, posY, pos2X, pos2Y, range)) &&
(isInRange2(posX, posY, pos1X, pos2Y, range)) &&
(isInRange2(posX, posY, pos2X, pos1Y, range))) {
return true;
}
return false;
}
bool TowerAOI::isPartialCoveredTower(position_t posX, position_t posY, position_t range, position_t pos1X, position_t pos1Y, position_t pos2X, position_t pos2Y) {
// angel in circle
if ((isInRange2(posX, posY, pos1X, pos1Y, range)) ||
(isInRange2(posX, posY, pos2X, pos2Y, range)) ||
(isInRange2(posX, posY, pos1X, pos2Y, range)) ||
(isInRange2(posX, posY, pos2X, pos1Y, range))) {
return true;
}
// side in circle
if ((isCoveredBySide(posX, posY, range, pos1X, pos1Y, pos2X, pos2Y)) ||
(isCoveredBySide(posX, posY, range, pos2X, pos1Y, pos1X, pos2Y)) ||
(isCoveredBySide(posY, posX, range, pos1Y, pos1X, pos2Y, pos2X)) ||
(isCoveredBySide(posY, posX, range, pos2Y, pos1X, pos1Y, pos2X))) {
return true;
}
return false;
}
bool TowerAOI::isCoveredBySide(position_t posX, position_t posY, position_t range, position_t pos1X, position_t pos1Y, position_t pos2X, position_t pos2Y) {
if (isInRange(posX, pos1X, range)) {
position_t dis2 = range * range - (posX - pos1X) * (posX - pos1X);
position_t testposY = sqrt(dis2) + posY;
return (testposY * testposY) >= pos1Y * pos1Y && (testposY * testposY) <= pos2Y * pos2Y;
}
return false;
}
bool TowerAOI::classifyTower(position_t posX, position_t posY, position_t range, int i, int j, list<Tower*> &fullCoveredTowers, list<Tower*> &partialCoveredTowers) {
if (isFullCoveredTower(posX, posY, range, i * towerWidth, j * towerHeight, (i + 1) * towerWidth, (j + 1) * towerHeight)) {
fullCoveredTowers.push_back(towers[i][j]);
} else if (isPartialCoveredTower(posX, posY, range, i * towerWidth, j * towerHeight, (i + 1) * towerWidth, (j + 1) * towerHeight)) {
partialCoveredTowers.push_back(towers[i][j]);
} else if (i == posX / towerWidth && j == posY / towerHeight) {
partialCoveredTowers.push_back(towers[i][j]);
} else {
return false;
}
return true;
}
| [
"chikanebest@163.com"
] | chikanebest@163.com |
410af24f031b5c0d69a95d1ee242b14773e0e70b | 9ff35738af78a2a93741f33eeb639d22db461c5f | /.build/Android-Debug/jni/app/Uno.Action__Experimental_Net_Http_Implementation_HttpRequestEventArgs.cpp | 770a8402cd242dc13cd52753cd3b604f39310d2d | [] | no_license | shingyho4/FuseProject-Minerals | aca37fbeb733974c1f97b1b0c954f4f660399154 | 643b15996e0fa540efca271b1d56cfd8736e7456 | refs/heads/master | 2016-09-06T11:19:06.904784 | 2015-06-15T09:28:09 | 2015-06-15T09:28:09 | 37,452,199 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 734 | cpp | // This file was generated based on 'C:\ProgramData\Uno\Packages\UnoCore\0.1.0\Source\Uno\$.uno'.
// WARNING: Changes might be lost if you edit this file directly.
#include <app/Experimental.Net.Http.Implementation.HttpRequestEventArgs.h>
#include <app/Uno.Action__Experimental_Net_Http_Implementation_HttpRequestEventArgs.h>
namespace app {
namespace Uno {
::uDelegateType* Action__Experimental_Net_Http_Implementation_HttpRequestEventArgs__typeof()
{
static ::uDelegateType* type;
if (::uEnterCriticalIfNull(&type))
{
type = ::uAllocDelegateType("Uno.Action<Experimental.Net.Http.Implementation.HttpRequestEventArgs>");
::uRetainObject(type);
::uExitCritical();
}
return type;
}
}}
| [
"hyl.hsy@gmail.com"
] | hyl.hsy@gmail.com |
b66e81b3e2cc1cb0b25c0a5c7fe567c25ff96dca | bb68632c4cd50982ebd9bc07c5dd533d98217c08 | /Solution/Day-559.cpp | 9b1ec0c0ba9c3bfc63c9b8859654f3e37adc1a93 | [] | no_license | offamitkumar/Daily-Coding-Problem | 83a4ba127d2118d20fbbe99aa832400c71ce8bfa | e831e360bb1170162473a5e4ddf9b07d134826c1 | refs/heads/master | 2023-07-21T01:24:37.558689 | 2023-07-13T03:24:30 | 2023-07-13T03:24:30 | 234,764,757 | 32 | 12 | null | 2023-07-13T03:24:31 | 2020-01-18T16:41:42 | C++ | UTF-8 | C++ | false | false | 1,140 | cpp | /**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode() : val(0), next(nullptr) {}
* ListNode(int x) : val(x), next(nullptr) {}
* ListNode(int x, ListNode *next) : val(x), next(next) {}
* };
*/
class Solution {
public:
ListNode* mergeKLists(vector<ListNode*>& lists) {
ListNode *res_head , *res_end;
res_head = res_end = nullptr;
set<pair<int, ListNode*>> h;
for (int i=0; i<lists.size(); ++i) {
if (lists[i] != nullptr) {
h.insert(make_pair(lists[i]->val , lists[i]));
}
}
while (!h.empty()) {
ListNode *temp = h.begin()->second;
if ( res_head == nullptr) {
res_head = temp;
res_end = temp;
} else {
res_end->next = temp;
res_end = res_end->next;
}
if (temp->next != nullptr) {
h.insert(make_pair(temp->next->val , temp->next));
}
h.erase(h.begin());
}
return res_head;
}
};
| [
"offamitkumar@gmail.com"
] | offamitkumar@gmail.com |
f367c0441766f7323eec15a301f19ea37c353ab1 | 873f12b41713c0e01c3e2ffdf44dcb211545d0ad | /test/ridge-regression/runner.cpp | 4a7d1503107188bb7fd7e960a42d2659ea2c92f1 | [
"MIT"
] | permissive | jman-9/linear-regression-practice | 2b9c63b76b8da30af0b857b33e7a73ef9382c037 | 7fe48387ebb8c494ce279bf9bbc50262da7a75d2 | refs/heads/main | 2023-03-18T14:10:05.513751 | 2021-03-07T12:43:07 | 2021-03-07T12:43:07 | 332,285,045 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,197 | cpp | #include "pch.h"
#include "../../libsrc/linear_least_squares.h"
#include "../../libsrc/ridge_regression.h"
#include <stdio.h>
using namespace csv;
using namespace std;
int main()
{
ridge_regression rr;
linear_least_squares::residual_list bhd;
linear_least_squares::parameter_vector pv;
CSVReader reader("data/BostonHousing.csv");
for (CSVRow& row: reader)
{
bhd.push_back({});
bhd.back().y = row["medv"].get<double>();
for(size_t i=0; i<row.size()-1; i++)
{
bhd.back().x.push_back(row[i].get<double>());
}
}
auto colnames = reader.get_col_names();
colnames.back() = "bias";
printf("=========\n");
printf("solving Boston Housing Dataset\n");
pv = rr.solve(bhd, 0.0);
printf("---------\n");
printf("parameters (not regularized) :\n");
printf("%s:%lf", colnames[0].c_str(), pv[0]);
for(size_t i=1; i<pv.size(); i++)
printf(", %s:%lf", colnames[i].c_str(), pv[i]);
printf("\n");
pv = rr.solve(bhd, 1.0);
printf("---------\n");
printf("parameters (regularized) :\n");
printf("%s:%lf", colnames[0].c_str(), pv[0]);
for(size_t i=1; i<pv.size(); i++)
printf(", %s:%lf", colnames[i].c_str(), pv[i]);
printf("\n");
printf("=========\n");
return 0;
}
| [
"flute999@daum.net"
] | flute999@daum.net |
8cae70d31ce7b35c0470c1e62da07d9d0a9303bd | 285987b6d2fdb4c9d22bbd4cc463fd7db82eef2b | /发布版unit05区间模型1/看最多电影.cpp | e032a91d5f5a4186e628ab993f03f462ecf69217 | [] | no_license | fdfzjxxxStudent/CS153 | 629b8a2300d5a8d36368a527707f266420ab6d6c | 8e62852b9d4e9dc57581093fa46e29924fdc936a | refs/heads/master | 2021-04-30T10:46:42.629600 | 2018-02-13T05:12:24 | 2018-02-13T05:12:24 | 121,119,529 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 438 | cpp | #include<iostream>
#include<algorithm>
#define N 105
using namespace std;
struct movie{int s,t;};
bool cmp(const movie& a,const movie& b){
return a.t<b.t||a.t==b.t&&a.s<b.s;
}
movie d[N];
int n,i,x,ans;
int main(){
cin>>n;
for(i=0;i<n;i++) cin>>d[i].s;
for(i=0;i<n;i++) cin>>d[i].t;
sort(d,d+n,cmp);
x=-1; ans=0;
for(i=0;i<n;i++)
if(d[i].s>x) {
ans++;
x=d[i].t;
}
cout<<ans<<endl;
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
f92ee8749903431ffbeb0088076e8195191320ff | 06341c1c451fdd7a7cf38b1f7d5f858dc91f24ac | /External/SFBAudioEngine/Metadata/OggFLACMetadata.cpp | 2f04e21466ca694c57e570d01a4fbaa77ad32bb2 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | Rm1210/Sonora | 57f70a4753790ec13f90b13f89d267e2bbe4fd83 | 8e78d101e3e8209a5b7bce183e20f03653d95025 | refs/heads/master | 2020-04-06T03:47:54.926832 | 2014-03-23T14:58:12 | 2014-03-23T14:58:12 | 17,465,058 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,751 | cpp | /*
* Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Stephen F. Booth <me@sbooth.org>
* 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 Stephen F. Booth nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER 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.
*/
#include <taglib/tfilestream.h>
#include <taglib/oggflacfile.h>
#include <taglib/flacproperties.h>
#include "OggFLACMetadata.h"
#include "CFErrorUtilities.h"
#include "AddXiphCommentToDictionary.h"
#include "SetXiphCommentFromMetadata.h"
#include "AddAudioPropertiesToDictionary.h"
#include "CFDictionaryUtilities.h"
#pragma mark Static Methods
CFArrayRef OggFLACMetadata::CreateSupportedFileExtensions()
{
CFStringRef supportedExtensions [] = { CFSTR("ogg"), CFSTR("oga") };
return CFArrayCreate(kCFAllocatorDefault, reinterpret_cast<const void **>(supportedExtensions), 2, &kCFTypeArrayCallBacks);
}
CFArrayRef OggFLACMetadata::CreateSupportedMIMETypes()
{
CFStringRef supportedMIMETypes [] = { CFSTR("audio/ogg") };
return CFArrayCreate(kCFAllocatorDefault, reinterpret_cast<const void **>(supportedMIMETypes), 1, &kCFTypeArrayCallBacks);
}
bool OggFLACMetadata::HandlesFilesWithExtension(CFStringRef extension)
{
if(nullptr == extension)
return false;
if(kCFCompareEqualTo == CFStringCompare(extension, CFSTR("ogg"), kCFCompareCaseInsensitive))
return true;
else if(kCFCompareEqualTo == CFStringCompare(extension, CFSTR("oga"), kCFCompareCaseInsensitive))
return true;
return false;
}
bool OggFLACMetadata::HandlesMIMEType(CFStringRef mimeType)
{
if(nullptr == mimeType)
return false;
if(kCFCompareEqualTo == CFStringCompare(mimeType, CFSTR("audio/ogg"), kCFCompareCaseInsensitive))
return true;
return false;
}
#pragma mark Creation and Destruction
OggFLACMetadata::OggFLACMetadata(CFURLRef url)
: AudioMetadata(url)
{}
OggFLACMetadata::~OggFLACMetadata()
{}
#pragma mark Functionality
bool OggFLACMetadata::ReadMetadata(CFErrorRef *error)
{
// Start from scratch
CFDictionaryRemoveAllValues(mMetadata);
CFDictionaryRemoveAllValues(mChangedMetadata);
UInt8 buf [PATH_MAX];
if(!CFURLGetFileSystemRepresentation(mURL, false, buf, PATH_MAX))
return false;
auto stream = new TagLib::FileStream(reinterpret_cast<const char *>(buf), true);
TagLib::Ogg::FLAC::File file(stream);
if(!file.isValid()) {
if(nullptr != error) {
CFStringRef description = CFCopyLocalizedString(CFSTR("The file “%@” is not a valid Ogg file."), "");
CFStringRef failureReason = CFCopyLocalizedString(CFSTR("Not an Ogg file"), "");
CFStringRef recoverySuggestion = CFCopyLocalizedString(CFSTR("The file's extension may not match the file's type."), "");
*error = CreateErrorForURL(AudioMetadataErrorDomain, AudioMetadataInputOutputError, description, mURL, failureReason, recoverySuggestion);
CFRelease(description), description = nullptr;
CFRelease(failureReason), failureReason = nullptr;
CFRelease(recoverySuggestion), recoverySuggestion = nullptr;
}
return false;
}
CFDictionarySetValue(mMetadata, kPropertiesFormatNameKey, CFSTR("Ogg FLAC"));
if(file.audioProperties()) {
auto properties = file.audioProperties();
AddAudioPropertiesToDictionary(mMetadata, properties);
if(properties->sampleWidth())
AddIntToDictionary(mMetadata, kPropertiesBitsPerChannelKey, properties->sampleWidth());
}
if(file.tag()) {
std::vector<AttachedPicture *> pictures;
AddXiphCommentToDictionary(mMetadata, pictures, file.tag());
for(auto picture : pictures)
AddSavedPicture(picture);
}
return true;
}
bool OggFLACMetadata::WriteMetadata(CFErrorRef *error)
{
UInt8 buf [PATH_MAX];
if(!CFURLGetFileSystemRepresentation(mURL, false, buf, PATH_MAX))
return false;
auto stream = new TagLib::FileStream(reinterpret_cast<const char *>(buf));
TagLib::Ogg::FLAC::File file(stream, false);
if(!file.isValid()) {
if(error) {
CFStringRef description = CFCopyLocalizedString(CFSTR("The file “%@” is not a valid Ogg file."), "");
CFStringRef failureReason = CFCopyLocalizedString(CFSTR("Not an Ogg file"), "");
CFStringRef recoverySuggestion = CFCopyLocalizedString(CFSTR("The file's extension may not match the file's type."), "");
*error = CreateErrorForURL(AudioMetadataErrorDomain, AudioMetadataInputOutputError, description, mURL, failureReason, recoverySuggestion);
CFRelease(description), description = nullptr;
CFRelease(failureReason), failureReason = nullptr;
CFRelease(recoverySuggestion), recoverySuggestion = nullptr;
}
return false;
}
SetXiphCommentFromMetadata(*this, file.tag());
if(!file.save()) {
if(error) {
CFStringRef description = CFCopyLocalizedString(CFSTR("The file “%@” is not a valid Ogg file."), "");
CFStringRef failureReason = CFCopyLocalizedString(CFSTR("Unable to write metadata"), "");
CFStringRef recoverySuggestion = CFCopyLocalizedString(CFSTR("The file's extension may not match the file's type."), "");
*error = CreateErrorForURL(AudioMetadataErrorDomain, AudioMetadataInputOutputError, description, mURL, failureReason, recoverySuggestion);
CFRelease(description), description = nullptr;
CFRelease(failureReason), failureReason = nullptr;
CFRelease(recoverySuggestion), recoverySuggestion = nullptr;
}
return false;
}
MergeChangedMetadataIntoMetadata();
return true;
}
| [
"zhanxcyy@gmail.com"
] | zhanxcyy@gmail.com |
122b2c5cb5a8a3c161910a3683fdea9ea851683f | f92fd9574dd2b9dfcaf624f68c994e1e062a4f5e | /BRUTE_FORCE_N-M_10.cpp | 85df85c48a5150284c1fbd28f1a0aab4eb330ccf | [] | no_license | hyunsooryu/Algorithm | db848e839ab9d67a3571c0a4b73ed4d0295896a0 | 91fbc974f42012e1acc5ec77f828353c930b11fb | refs/heads/master | 2020-04-25T14:30:04.943659 | 2019-04-11T01:20:25 | 2019-04-11T01:20:25 | 172,843,521 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 970 | cpp | #include <iostream>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;
int N, M;
vector<int> path;
bool impossible[10001];
map<vector<int>, bool> V;
vector<int> A;
void go(int i, int cnt){
if(cnt == M){
if(!V[path]){
V[path] = true;
for(auto j : path){
cout << j << " ";
}
cout << endl;
}
return;
}
for(int k = i; k < N; k++){
if(impossible[k]){
continue;
}
impossible[k] = true;
path.push_back(A[k]);
go(k, cnt + 1);
path.pop_back();
impossible[k] = false;
}
}
int main(){
cin >> N >> M;
A.resize(N);
for(int i = 0; i < N; i++){
cin >> A[i];
}
sort(A.begin(), A.end());
for(int i = 0; i < N; i++){
impossible[i] = true;
path.push_back(A[i]);
go(i, 1);
path.pop_back();
impossible[i] = false;
}
return 0;
} | [
"41038031+hyunsooryu@users.noreply.github.com"
] | 41038031+hyunsooryu@users.noreply.github.com |
805849bcf6a435236e089da3b53aff501fcd7d8a | 8ae9bdbb56622e7eb2fe7cf700b8fe4b7bd6e7ae | /llvm-3.8.0-r267675/lib/CodeGen/SplitKit.cpp | 8bf139156eeed991f348a4f4c66b365613dd4a8b | [
"NCSA"
] | permissive | mapu/toolchains | f61aa8b64d1dce5e618f0ff919d91dd5b664e901 | 3a6fea03c6a7738091e980b9cdee0447eb08bb1d | refs/heads/master | 2021-09-16T00:07:16.731713 | 2017-12-29T04:09:01 | 2017-12-29T04:09:01 | 104,563,481 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 54,585 | cpp | //===---------- SplitKit.cpp - Toolkit for splitting live ranges ----------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains the SplitAnalysis class as well as mutator functions for
// live range splitting.
//
//===----------------------------------------------------------------------===//
#include "SplitKit.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/LiveIntervalAnalysis.h"
#include "llvm/CodeGen/LiveRangeEdit.h"
#include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineLoopInfo.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/VirtRegMap.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/Target/TargetMachine.h"
using namespace llvm;
#define DEBUG_TYPE "regalloc"
STATISTIC(NumFinished, "Number of splits finished");
STATISTIC(NumSimple, "Number of splits that were simple");
STATISTIC(NumCopies, "Number of copies inserted for splitting");
STATISTIC(NumRemats, "Number of rematerialized defs for splitting");
STATISTIC(NumRepairs, "Number of invalid live ranges repaired");
//===----------------------------------------------------------------------===//
// Split Analysis
//===----------------------------------------------------------------------===//
SplitAnalysis::SplitAnalysis(const VirtRegMap &vrm, const LiveIntervals &lis,
const MachineLoopInfo &mli)
: MF(vrm.getMachineFunction()), VRM(vrm), LIS(lis), Loops(mli),
TII(*MF.getSubtarget().getInstrInfo()), CurLI(nullptr),
LastSplitPoint(MF.getNumBlockIDs()) {}
void SplitAnalysis::clear() {
UseSlots.clear();
UseBlocks.clear();
ThroughBlocks.clear();
CurLI = nullptr;
DidRepairRange = false;
}
SlotIndex SplitAnalysis::computeLastSplitPoint(unsigned Num) {
const MachineBasicBlock *MBB = MF.getBlockNumbered(Num);
std::pair<SlotIndex, SlotIndex> &LSP = LastSplitPoint[Num];
SlotIndex MBBEnd = LIS.getMBBEndIdx(MBB);
SmallVector<const MachineBasicBlock *, 1> EHPadSucessors;
for (const MachineBasicBlock *SMBB : MBB->successors())
if (SMBB->isEHPad())
EHPadSucessors.push_back(SMBB);
// Compute split points on the first call. The pair is independent of the
// current live interval.
if (!LSP.first.isValid()) {
MachineBasicBlock::const_iterator FirstTerm = MBB->getFirstTerminator();
if (FirstTerm == MBB->end())
LSP.first = MBBEnd;
else
LSP.first = LIS.getInstructionIndex(*FirstTerm);
// If there is a landing pad successor, also find the call instruction.
if (EHPadSucessors.empty())
return LSP.first;
// There may not be a call instruction (?) in which case we ignore LPad.
LSP.second = LSP.first;
for (MachineBasicBlock::const_iterator I = MBB->end(), E = MBB->begin();
I != E;) {
--I;
if (I->isCall()) {
LSP.second = LIS.getInstructionIndex(*I);
break;
}
}
}
// If CurLI is live into a landing pad successor, move the last split point
// back to the call that may throw.
if (!LSP.second)
return LSP.first;
if (none_of(EHPadSucessors, [&](const MachineBasicBlock *EHPad) {
return LIS.isLiveInToMBB(*CurLI, EHPad);
}))
return LSP.first;
// Find the value leaving MBB.
const VNInfo *VNI = CurLI->getVNInfoBefore(MBBEnd);
if (!VNI)
return LSP.first;
// If the value leaving MBB was defined after the call in MBB, it can't
// really be live-in to the landing pad. This can happen if the landing pad
// has a PHI, and this register is undef on the exceptional edge.
// <rdar://problem/10664933>
if (!SlotIndex::isEarlierInstr(VNI->def, LSP.second) && VNI->def < MBBEnd)
return LSP.first;
// Value is properly live-in to the landing pad.
// Only allow splits before the call.
return LSP.second;
}
MachineBasicBlock::iterator
SplitAnalysis::getLastSplitPointIter(MachineBasicBlock *MBB) {
SlotIndex LSP = getLastSplitPoint(MBB->getNumber());
if (LSP == LIS.getMBBEndIdx(MBB))
return MBB->end();
return LIS.getInstructionFromIndex(LSP);
}
/// analyzeUses - Count instructions, basic blocks, and loops using CurLI.
void SplitAnalysis::analyzeUses() {
assert(UseSlots.empty() && "Call clear first");
// First get all the defs from the interval values. This provides the correct
// slots for early clobbers.
for (const VNInfo *VNI : CurLI->valnos)
if (!VNI->isPHIDef() && !VNI->isUnused())
UseSlots.push_back(VNI->def);
// Get use slots form the use-def chain.
const MachineRegisterInfo &MRI = MF.getRegInfo();
for (MachineOperand &MO : MRI.use_nodbg_operands(CurLI->reg))
if (!MO.isUndef())
UseSlots.push_back(LIS.getInstructionIndex(*MO.getParent()).getRegSlot());
array_pod_sort(UseSlots.begin(), UseSlots.end());
// Remove duplicates, keeping the smaller slot for each instruction.
// That is what we want for early clobbers.
UseSlots.erase(std::unique(UseSlots.begin(), UseSlots.end(),
SlotIndex::isSameInstr),
UseSlots.end());
// Compute per-live block info.
if (!calcLiveBlockInfo()) {
// FIXME: calcLiveBlockInfo found inconsistencies in the live range.
// I am looking at you, RegisterCoalescer!
DidRepairRange = true;
++NumRepairs;
DEBUG(dbgs() << "*** Fixing inconsistent live interval! ***\n");
const_cast<LiveIntervals&>(LIS)
.shrinkToUses(const_cast<LiveInterval*>(CurLI));
UseBlocks.clear();
ThroughBlocks.clear();
bool fixed = calcLiveBlockInfo();
(void)fixed;
assert(fixed && "Couldn't fix broken live interval");
}
DEBUG(dbgs() << "Analyze counted "
<< UseSlots.size() << " instrs in "
<< UseBlocks.size() << " blocks, through "
<< NumThroughBlocks << " blocks.\n");
}
/// calcLiveBlockInfo - Fill the LiveBlocks array with information about blocks
/// where CurLI is live.
bool SplitAnalysis::calcLiveBlockInfo() {
ThroughBlocks.resize(MF.getNumBlockIDs());
NumThroughBlocks = NumGapBlocks = 0;
if (CurLI->empty())
return true;
LiveInterval::const_iterator LVI = CurLI->begin();
LiveInterval::const_iterator LVE = CurLI->end();
SmallVectorImpl<SlotIndex>::const_iterator UseI, UseE;
UseI = UseSlots.begin();
UseE = UseSlots.end();
// Loop over basic blocks where CurLI is live.
MachineFunction::iterator MFI =
LIS.getMBBFromIndex(LVI->start)->getIterator();
for (;;) {
BlockInfo BI;
BI.MBB = &*MFI;
SlotIndex Start, Stop;
std::tie(Start, Stop) = LIS.getSlotIndexes()->getMBBRange(BI.MBB);
// If the block contains no uses, the range must be live through. At one
// point, RegisterCoalescer could create dangling ranges that ended
// mid-block.
if (UseI == UseE || *UseI >= Stop) {
++NumThroughBlocks;
ThroughBlocks.set(BI.MBB->getNumber());
// The range shouldn't end mid-block if there are no uses. This shouldn't
// happen.
if (LVI->end < Stop)
return false;
} else {
// This block has uses. Find the first and last uses in the block.
BI.FirstInstr = *UseI;
assert(BI.FirstInstr >= Start);
do ++UseI;
while (UseI != UseE && *UseI < Stop);
BI.LastInstr = UseI[-1];
assert(BI.LastInstr < Stop);
// LVI is the first live segment overlapping MBB.
BI.LiveIn = LVI->start <= Start;
// When not live in, the first use should be a def.
if (!BI.LiveIn) {
assert(LVI->start == LVI->valno->def && "Dangling Segment start");
assert(LVI->start == BI.FirstInstr && "First instr should be a def");
BI.FirstDef = BI.FirstInstr;
}
// Look for gaps in the live range.
BI.LiveOut = true;
while (LVI->end < Stop) {
SlotIndex LastStop = LVI->end;
if (++LVI == LVE || LVI->start >= Stop) {
BI.LiveOut = false;
BI.LastInstr = LastStop;
break;
}
if (LastStop < LVI->start) {
// There is a gap in the live range. Create duplicate entries for the
// live-in snippet and the live-out snippet.
++NumGapBlocks;
// Push the Live-in part.
BI.LiveOut = false;
UseBlocks.push_back(BI);
UseBlocks.back().LastInstr = LastStop;
// Set up BI for the live-out part.
BI.LiveIn = false;
BI.LiveOut = true;
BI.FirstInstr = BI.FirstDef = LVI->start;
}
// A Segment that starts in the middle of the block must be a def.
assert(LVI->start == LVI->valno->def && "Dangling Segment start");
if (!BI.FirstDef)
BI.FirstDef = LVI->start;
}
UseBlocks.push_back(BI);
// LVI is now at LVE or LVI->end >= Stop.
if (LVI == LVE)
break;
}
// Live segment ends exactly at Stop. Move to the next segment.
if (LVI->end == Stop && ++LVI == LVE)
break;
// Pick the next basic block.
if (LVI->start < Stop)
++MFI;
else
MFI = LIS.getMBBFromIndex(LVI->start)->getIterator();
}
assert(getNumLiveBlocks() == countLiveBlocks(CurLI) && "Bad block count");
return true;
}
unsigned SplitAnalysis::countLiveBlocks(const LiveInterval *cli) const {
if (cli->empty())
return 0;
LiveInterval *li = const_cast<LiveInterval*>(cli);
LiveInterval::iterator LVI = li->begin();
LiveInterval::iterator LVE = li->end();
unsigned Count = 0;
// Loop over basic blocks where li is live.
MachineFunction::const_iterator MFI =
LIS.getMBBFromIndex(LVI->start)->getIterator();
SlotIndex Stop = LIS.getMBBEndIdx(&*MFI);
for (;;) {
++Count;
LVI = li->advanceTo(LVI, Stop);
if (LVI == LVE)
return Count;
do {
++MFI;
Stop = LIS.getMBBEndIdx(&*MFI);
} while (Stop <= LVI->start);
}
}
bool SplitAnalysis::isOriginalEndpoint(SlotIndex Idx) const {
unsigned OrigReg = VRM.getOriginal(CurLI->reg);
const LiveInterval &Orig = LIS.getInterval(OrigReg);
assert(!Orig.empty() && "Splitting empty interval?");
LiveInterval::const_iterator I = Orig.find(Idx);
// Range containing Idx should begin at Idx.
if (I != Orig.end() && I->start <= Idx)
return I->start == Idx;
// Range does not contain Idx, previous must end at Idx.
return I != Orig.begin() && (--I)->end == Idx;
}
void SplitAnalysis::analyze(const LiveInterval *li) {
clear();
CurLI = li;
analyzeUses();
}
//===----------------------------------------------------------------------===//
// Split Editor
//===----------------------------------------------------------------------===//
/// Create a new SplitEditor for editing the LiveInterval analyzed by SA.
SplitEditor::SplitEditor(SplitAnalysis &sa, LiveIntervals &lis, VirtRegMap &vrm,
MachineDominatorTree &mdt,
MachineBlockFrequencyInfo &mbfi)
: SA(sa), LIS(lis), VRM(vrm), MRI(vrm.getMachineFunction().getRegInfo()),
MDT(mdt), TII(*vrm.getMachineFunction().getSubtarget().getInstrInfo()),
TRI(*vrm.getMachineFunction().getSubtarget().getRegisterInfo()),
MBFI(mbfi), Edit(nullptr), OpenIdx(0), SpillMode(SM_Partition),
RegAssign(Allocator) {}
void SplitEditor::reset(LiveRangeEdit &LRE, ComplementSpillMode SM) {
Edit = &LRE;
SpillMode = SM;
OpenIdx = 0;
RegAssign.clear();
Values.clear();
// Reset the LiveRangeCalc instances needed for this spill mode.
LRCalc[0].reset(&VRM.getMachineFunction(), LIS.getSlotIndexes(), &MDT,
&LIS.getVNInfoAllocator());
if (SpillMode)
LRCalc[1].reset(&VRM.getMachineFunction(), LIS.getSlotIndexes(), &MDT,
&LIS.getVNInfoAllocator());
// We don't need an AliasAnalysis since we will only be performing
// cheap-as-a-copy remats anyway.
Edit->anyRematerializable(nullptr);
}
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void SplitEditor::dump() const {
if (RegAssign.empty()) {
dbgs() << " empty\n";
return;
}
for (RegAssignMap::const_iterator I = RegAssign.begin(); I.valid(); ++I)
dbgs() << " [" << I.start() << ';' << I.stop() << "):" << I.value();
dbgs() << '\n';
}
#endif
VNInfo *SplitEditor::defValue(unsigned RegIdx,
const VNInfo *ParentVNI,
SlotIndex Idx) {
assert(ParentVNI && "Mapping NULL value");
assert(Idx.isValid() && "Invalid SlotIndex");
assert(Edit->getParent().getVNInfoAt(Idx) == ParentVNI && "Bad Parent VNI");
LiveInterval *LI = &LIS.getInterval(Edit->get(RegIdx));
// Create a new value.
VNInfo *VNI = LI->getNextValue(Idx, LIS.getVNInfoAllocator());
// Use insert for lookup, so we can add missing values with a second lookup.
std::pair<ValueMap::iterator, bool> InsP =
Values.insert(std::make_pair(std::make_pair(RegIdx, ParentVNI->id),
ValueForcePair(VNI, false)));
// This was the first time (RegIdx, ParentVNI) was mapped.
// Keep it as a simple def without any liveness.
if (InsP.second)
return VNI;
// If the previous value was a simple mapping, add liveness for it now.
if (VNInfo *OldVNI = InsP.first->second.getPointer()) {
SlotIndex Def = OldVNI->def;
LI->addSegment(LiveInterval::Segment(Def, Def.getDeadSlot(), OldVNI));
// No longer a simple mapping. Switch to a complex, non-forced mapping.
InsP.first->second = ValueForcePair();
}
// This is a complex mapping, add liveness for VNI
SlotIndex Def = VNI->def;
LI->addSegment(LiveInterval::Segment(Def, Def.getDeadSlot(), VNI));
return VNI;
}
void SplitEditor::forceRecompute(unsigned RegIdx, const VNInfo *ParentVNI) {
assert(ParentVNI && "Mapping NULL value");
ValueForcePair &VFP = Values[std::make_pair(RegIdx, ParentVNI->id)];
VNInfo *VNI = VFP.getPointer();
// ParentVNI was either unmapped or already complex mapped. Either way, just
// set the force bit.
if (!VNI) {
VFP.setInt(true);
return;
}
// This was previously a single mapping. Make sure the old def is represented
// by a trivial live range.
SlotIndex Def = VNI->def;
LiveInterval *LI = &LIS.getInterval(Edit->get(RegIdx));
LI->addSegment(LiveInterval::Segment(Def, Def.getDeadSlot(), VNI));
// Mark as complex mapped, forced.
VFP = ValueForcePair(nullptr, true);
}
VNInfo *SplitEditor::defFromParent(unsigned RegIdx,
VNInfo *ParentVNI,
SlotIndex UseIdx,
MachineBasicBlock &MBB,
MachineBasicBlock::iterator I) {
MachineInstr *CopyMI = nullptr;
SlotIndex Def;
LiveInterval *LI = &LIS.getInterval(Edit->get(RegIdx));
// We may be trying to avoid interference that ends at a deleted instruction,
// so always begin RegIdx 0 early and all others late.
bool Late = RegIdx != 0;
// Attempt cheap-as-a-copy rematerialization.
unsigned Original = VRM.getOriginal(Edit->get(RegIdx));
LiveInterval &OrigLI = LIS.getInterval(Original);
VNInfo *OrigVNI = OrigLI.getVNInfoAt(UseIdx);
LiveRangeEdit::Remat RM(ParentVNI);
RM.OrigMI = LIS.getInstructionFromIndex(OrigVNI->def);
if (Edit->canRematerializeAt(RM, OrigVNI, UseIdx, true)) {
Def = Edit->rematerializeAt(MBB, I, LI->reg, RM, TRI, Late);
++NumRemats;
} else {
// Can't remat, just insert a copy from parent.
CopyMI = BuildMI(MBB, I, DebugLoc(), TII.get(TargetOpcode::COPY), LI->reg)
.addReg(Edit->getReg());
Def = LIS.getSlotIndexes()
->insertMachineInstrInMaps(*CopyMI, Late)
.getRegSlot();
++NumCopies;
}
// Define the value in Reg.
return defValue(RegIdx, ParentVNI, Def);
}
/// Create a new virtual register and live interval.
unsigned SplitEditor::openIntv() {
// Create the complement as index 0.
if (Edit->empty())
Edit->createEmptyInterval();
// Create the open interval.
OpenIdx = Edit->size();
Edit->createEmptyInterval();
return OpenIdx;
}
void SplitEditor::selectIntv(unsigned Idx) {
assert(Idx != 0 && "Cannot select the complement interval");
assert(Idx < Edit->size() && "Can only select previously opened interval");
DEBUG(dbgs() << " selectIntv " << OpenIdx << " -> " << Idx << '\n');
OpenIdx = Idx;
}
SlotIndex SplitEditor::enterIntvBefore(SlotIndex Idx) {
assert(OpenIdx && "openIntv not called before enterIntvBefore");
DEBUG(dbgs() << " enterIntvBefore " << Idx);
Idx = Idx.getBaseIndex();
VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Idx);
if (!ParentVNI) {
DEBUG(dbgs() << ": not live\n");
return Idx;
}
DEBUG(dbgs() << ": valno " << ParentVNI->id << '\n');
MachineInstr *MI = LIS.getInstructionFromIndex(Idx);
assert(MI && "enterIntvBefore called with invalid index");
VNInfo *VNI = defFromParent(OpenIdx, ParentVNI, Idx, *MI->getParent(), MI);
return VNI->def;
}
SlotIndex SplitEditor::enterIntvAfter(SlotIndex Idx) {
assert(OpenIdx && "openIntv not called before enterIntvAfter");
DEBUG(dbgs() << " enterIntvAfter " << Idx);
Idx = Idx.getBoundaryIndex();
VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Idx);
if (!ParentVNI) {
DEBUG(dbgs() << ": not live\n");
return Idx;
}
DEBUG(dbgs() << ": valno " << ParentVNI->id << '\n');
MachineInstr *MI = LIS.getInstructionFromIndex(Idx);
assert(MI && "enterIntvAfter called with invalid index");
VNInfo *VNI = defFromParent(OpenIdx, ParentVNI, Idx, *MI->getParent(),
std::next(MachineBasicBlock::iterator(MI)));
return VNI->def;
}
SlotIndex SplitEditor::enterIntvAtEnd(MachineBasicBlock &MBB) {
assert(OpenIdx && "openIntv not called before enterIntvAtEnd");
SlotIndex End = LIS.getMBBEndIdx(&MBB);
SlotIndex Last = End.getPrevSlot();
DEBUG(dbgs() << " enterIntvAtEnd BB#" << MBB.getNumber() << ", " << Last);
VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Last);
if (!ParentVNI) {
DEBUG(dbgs() << ": not live\n");
return End;
}
DEBUG(dbgs() << ": valno " << ParentVNI->id);
VNInfo *VNI = defFromParent(OpenIdx, ParentVNI, Last, MBB,
SA.getLastSplitPointIter(&MBB));
RegAssign.insert(VNI->def, End, OpenIdx);
DEBUG(dump());
return VNI->def;
}
/// useIntv - indicate that all instructions in MBB should use OpenLI.
void SplitEditor::useIntv(const MachineBasicBlock &MBB) {
useIntv(LIS.getMBBStartIdx(&MBB), LIS.getMBBEndIdx(&MBB));
}
void SplitEditor::useIntv(SlotIndex Start, SlotIndex End) {
assert(OpenIdx && "openIntv not called before useIntv");
DEBUG(dbgs() << " useIntv [" << Start << ';' << End << "):");
RegAssign.insert(Start, End, OpenIdx);
DEBUG(dump());
}
SlotIndex SplitEditor::leaveIntvAfter(SlotIndex Idx) {
assert(OpenIdx && "openIntv not called before leaveIntvAfter");
DEBUG(dbgs() << " leaveIntvAfter " << Idx);
// The interval must be live beyond the instruction at Idx.
SlotIndex Boundary = Idx.getBoundaryIndex();
VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Boundary);
if (!ParentVNI) {
DEBUG(dbgs() << ": not live\n");
return Boundary.getNextSlot();
}
DEBUG(dbgs() << ": valno " << ParentVNI->id << '\n');
MachineInstr *MI = LIS.getInstructionFromIndex(Boundary);
assert(MI && "No instruction at index");
// In spill mode, make live ranges as short as possible by inserting the copy
// before MI. This is only possible if that instruction doesn't redefine the
// value. The inserted COPY is not a kill, and we don't need to recompute
// the source live range. The spiller also won't try to hoist this copy.
if (SpillMode && !SlotIndex::isSameInstr(ParentVNI->def, Idx) &&
MI->readsVirtualRegister(Edit->getReg())) {
forceRecompute(0, ParentVNI);
defFromParent(0, ParentVNI, Idx, *MI->getParent(), MI);
return Idx;
}
VNInfo *VNI = defFromParent(0, ParentVNI, Boundary, *MI->getParent(),
std::next(MachineBasicBlock::iterator(MI)));
return VNI->def;
}
SlotIndex SplitEditor::leaveIntvBefore(SlotIndex Idx) {
assert(OpenIdx && "openIntv not called before leaveIntvBefore");
DEBUG(dbgs() << " leaveIntvBefore " << Idx);
// The interval must be live into the instruction at Idx.
Idx = Idx.getBaseIndex();
VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Idx);
if (!ParentVNI) {
DEBUG(dbgs() << ": not live\n");
return Idx.getNextSlot();
}
DEBUG(dbgs() << ": valno " << ParentVNI->id << '\n');
MachineInstr *MI = LIS.getInstructionFromIndex(Idx);
assert(MI && "No instruction at index");
VNInfo *VNI = defFromParent(0, ParentVNI, Idx, *MI->getParent(), MI);
return VNI->def;
}
SlotIndex SplitEditor::leaveIntvAtTop(MachineBasicBlock &MBB) {
assert(OpenIdx && "openIntv not called before leaveIntvAtTop");
SlotIndex Start = LIS.getMBBStartIdx(&MBB);
DEBUG(dbgs() << " leaveIntvAtTop BB#" << MBB.getNumber() << ", " << Start);
VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Start);
if (!ParentVNI) {
DEBUG(dbgs() << ": not live\n");
return Start;
}
VNInfo *VNI = defFromParent(0, ParentVNI, Start, MBB,
MBB.SkipPHIsAndLabels(MBB.begin()));
RegAssign.insert(Start, VNI->def, OpenIdx);
DEBUG(dump());
return VNI->def;
}
void SplitEditor::overlapIntv(SlotIndex Start, SlotIndex End) {
assert(OpenIdx && "openIntv not called before overlapIntv");
const VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Start);
assert(ParentVNI == Edit->getParent().getVNInfoBefore(End) &&
"Parent changes value in extended range");
assert(LIS.getMBBFromIndex(Start) == LIS.getMBBFromIndex(End) &&
"Range cannot span basic blocks");
// The complement interval will be extended as needed by LRCalc.extend().
if (ParentVNI)
forceRecompute(0, ParentVNI);
DEBUG(dbgs() << " overlapIntv [" << Start << ';' << End << "):");
RegAssign.insert(Start, End, OpenIdx);
DEBUG(dump());
}
//===----------------------------------------------------------------------===//
// Spill modes
//===----------------------------------------------------------------------===//
void SplitEditor::removeBackCopies(SmallVectorImpl<VNInfo*> &Copies) {
LiveInterval *LI = &LIS.getInterval(Edit->get(0));
DEBUG(dbgs() << "Removing " << Copies.size() << " back-copies.\n");
RegAssignMap::iterator AssignI;
AssignI.setMap(RegAssign);
for (unsigned i = 0, e = Copies.size(); i != e; ++i) {
SlotIndex Def = Copies[i]->def;
MachineInstr *MI = LIS.getInstructionFromIndex(Def);
assert(MI && "No instruction for back-copy");
MachineBasicBlock *MBB = MI->getParent();
MachineBasicBlock::iterator MBBI(MI);
bool AtBegin;
do AtBegin = MBBI == MBB->begin();
while (!AtBegin && (--MBBI)->isDebugValue());
DEBUG(dbgs() << "Removing " << Def << '\t' << *MI);
LIS.removeVRegDefAt(*LI, Def);
LIS.RemoveMachineInstrFromMaps(*MI);
MI->eraseFromParent();
// Adjust RegAssign if a register assignment is killed at Def. We want to
// avoid calculating the live range of the source register if possible.
AssignI.find(Def.getPrevSlot());
if (!AssignI.valid() || AssignI.start() >= Def)
continue;
// If MI doesn't kill the assigned register, just leave it.
if (AssignI.stop() != Def)
continue;
unsigned RegIdx = AssignI.value();
if (AtBegin || !MBBI->readsVirtualRegister(Edit->getReg())) {
DEBUG(dbgs() << " cannot find simple kill of RegIdx " << RegIdx << '\n');
forceRecompute(RegIdx, Edit->getParent().getVNInfoAt(Def));
} else {
SlotIndex Kill = LIS.getInstructionIndex(*MBBI).getRegSlot();
DEBUG(dbgs() << " move kill to " << Kill << '\t' << *MBBI);
AssignI.setStop(Kill);
}
}
}
MachineBasicBlock*
SplitEditor::findShallowDominator(MachineBasicBlock *MBB,
MachineBasicBlock *DefMBB) {
if (MBB == DefMBB)
return MBB;
assert(MDT.dominates(DefMBB, MBB) && "MBB must be dominated by the def.");
const MachineLoopInfo &Loops = SA.Loops;
const MachineLoop *DefLoop = Loops.getLoopFor(DefMBB);
MachineDomTreeNode *DefDomNode = MDT[DefMBB];
// Best candidate so far.
MachineBasicBlock *BestMBB = MBB;
unsigned BestDepth = UINT_MAX;
for (;;) {
const MachineLoop *Loop = Loops.getLoopFor(MBB);
// MBB isn't in a loop, it doesn't get any better. All dominators have a
// higher frequency by definition.
if (!Loop) {
DEBUG(dbgs() << "Def in BB#" << DefMBB->getNumber() << " dominates BB#"
<< MBB->getNumber() << " at depth 0\n");
return MBB;
}
// We'll never be able to exit the DefLoop.
if (Loop == DefLoop) {
DEBUG(dbgs() << "Def in BB#" << DefMBB->getNumber() << " dominates BB#"
<< MBB->getNumber() << " in the same loop\n");
return MBB;
}
// Least busy dominator seen so far.
unsigned Depth = Loop->getLoopDepth();
if (Depth < BestDepth) {
BestMBB = MBB;
BestDepth = Depth;
DEBUG(dbgs() << "Def in BB#" << DefMBB->getNumber() << " dominates BB#"
<< MBB->getNumber() << " at depth " << Depth << '\n');
}
// Leave loop by going to the immediate dominator of the loop header.
// This is a bigger stride than simply walking up the dominator tree.
MachineDomTreeNode *IDom = MDT[Loop->getHeader()]->getIDom();
// Too far up the dominator tree?
if (!IDom || !MDT.dominates(DefDomNode, IDom))
return BestMBB;
MBB = IDom->getBlock();
}
}
void SplitEditor::computeRedundantBackCopies(
DenseSet<unsigned> &NotToHoistSet, SmallVectorImpl<VNInfo *> &BackCopies) {
LiveInterval *LI = &LIS.getInterval(Edit->get(0));
LiveInterval *Parent = &Edit->getParent();
SmallVector<SmallPtrSet<VNInfo *, 8>, 8> EqualVNs(Parent->getNumValNums());
SmallPtrSet<VNInfo *, 8> DominatedVNIs;
// Aggregate VNIs having the same value as ParentVNI.
for (VNInfo *VNI : LI->valnos) {
if (VNI->isUnused())
continue;
VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(VNI->def);
EqualVNs[ParentVNI->id].insert(VNI);
}
// For VNI aggregation of each ParentVNI, collect dominated, i.e.,
// redundant VNIs to BackCopies.
for (unsigned i = 0, e = Parent->getNumValNums(); i != e; ++i) {
VNInfo *ParentVNI = Parent->getValNumInfo(i);
if (!NotToHoistSet.count(ParentVNI->id))
continue;
SmallPtrSetIterator<VNInfo *> It1 = EqualVNs[ParentVNI->id].begin();
SmallPtrSetIterator<VNInfo *> It2 = It1;
for (; It1 != EqualVNs[ParentVNI->id].end(); ++It1) {
It2 = It1;
for (++It2; It2 != EqualVNs[ParentVNI->id].end(); ++It2) {
if (DominatedVNIs.count(*It1) || DominatedVNIs.count(*It2))
continue;
MachineBasicBlock *MBB1 = LIS.getMBBFromIndex((*It1)->def);
MachineBasicBlock *MBB2 = LIS.getMBBFromIndex((*It2)->def);
if (MBB1 == MBB2) {
DominatedVNIs.insert((*It1)->def < (*It2)->def ? (*It2) : (*It1));
} else if (MDT.dominates(MBB1, MBB2)) {
DominatedVNIs.insert(*It2);
} else if (MDT.dominates(MBB2, MBB1)) {
DominatedVNIs.insert(*It1);
}
}
}
if (!DominatedVNIs.empty()) {
forceRecompute(0, ParentVNI);
for (auto VNI : DominatedVNIs) {
BackCopies.push_back(VNI);
}
DominatedVNIs.clear();
}
}
}
/// For SM_Size mode, find a common dominator for all the back-copies for
/// the same ParentVNI and hoist the backcopies to the dominator BB.
/// For SM_Speed mode, if the common dominator is hot and it is not beneficial
/// to do the hoisting, simply remove the dominated backcopies for the same
/// ParentVNI.
void SplitEditor::hoistCopies() {
// Get the complement interval, always RegIdx 0.
LiveInterval *LI = &LIS.getInterval(Edit->get(0));
LiveInterval *Parent = &Edit->getParent();
// Track the nearest common dominator for all back-copies for each ParentVNI,
// indexed by ParentVNI->id.
typedef std::pair<MachineBasicBlock*, SlotIndex> DomPair;
SmallVector<DomPair, 8> NearestDom(Parent->getNumValNums());
// The total cost of all the back-copies for each ParentVNI.
SmallVector<BlockFrequency, 8> Costs(Parent->getNumValNums());
// The ParentVNI->id set for which hoisting back-copies are not beneficial
// for Speed.
DenseSet<unsigned> NotToHoistSet;
// Find the nearest common dominator for parent values with multiple
// back-copies. If a single back-copy dominates, put it in DomPair.second.
for (VNInfo *VNI : LI->valnos) {
if (VNI->isUnused())
continue;
VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(VNI->def);
assert(ParentVNI && "Parent not live at complement def");
// Don't hoist remats. The complement is probably going to disappear
// completely anyway.
if (Edit->didRematerialize(ParentVNI))
continue;
MachineBasicBlock *ValMBB = LIS.getMBBFromIndex(VNI->def);
DomPair &Dom = NearestDom[ParentVNI->id];
// Keep directly defined parent values. This is either a PHI or an
// instruction in the complement range. All other copies of ParentVNI
// should be eliminated.
if (VNI->def == ParentVNI->def) {
DEBUG(dbgs() << "Direct complement def at " << VNI->def << '\n');
Dom = DomPair(ValMBB, VNI->def);
continue;
}
// Skip the singly mapped values. There is nothing to gain from hoisting a
// single back-copy.
if (Values.lookup(std::make_pair(0, ParentVNI->id)).getPointer()) {
DEBUG(dbgs() << "Single complement def at " << VNI->def << '\n');
continue;
}
if (!Dom.first) {
// First time we see ParentVNI. VNI dominates itself.
Dom = DomPair(ValMBB, VNI->def);
} else if (Dom.first == ValMBB) {
// Two defs in the same block. Pick the earlier def.
if (!Dom.second.isValid() || VNI->def < Dom.second)
Dom.second = VNI->def;
} else {
// Different basic blocks. Check if one dominates.
MachineBasicBlock *Near =
MDT.findNearestCommonDominator(Dom.first, ValMBB);
if (Near == ValMBB)
// Def ValMBB dominates.
Dom = DomPair(ValMBB, VNI->def);
else if (Near != Dom.first)
// None dominate. Hoist to common dominator, need new def.
Dom = DomPair(Near, SlotIndex());
Costs[ParentVNI->id] += MBFI.getBlockFreq(ValMBB);
}
DEBUG(dbgs() << "Multi-mapped complement " << VNI->id << '@' << VNI->def
<< " for parent " << ParentVNI->id << '@' << ParentVNI->def
<< " hoist to BB#" << Dom.first->getNumber() << ' '
<< Dom.second << '\n');
}
// Insert the hoisted copies.
for (unsigned i = 0, e = Parent->getNumValNums(); i != e; ++i) {
DomPair &Dom = NearestDom[i];
if (!Dom.first || Dom.second.isValid())
continue;
// This value needs a hoisted copy inserted at the end of Dom.first.
VNInfo *ParentVNI = Parent->getValNumInfo(i);
MachineBasicBlock *DefMBB = LIS.getMBBFromIndex(ParentVNI->def);
// Get a less loopy dominator than Dom.first.
Dom.first = findShallowDominator(Dom.first, DefMBB);
if (SpillMode == SM_Speed &&
MBFI.getBlockFreq(Dom.first) > Costs[ParentVNI->id]) {
NotToHoistSet.insert(ParentVNI->id);
continue;
}
SlotIndex Last = LIS.getMBBEndIdx(Dom.first).getPrevSlot();
Dom.second =
defFromParent(0, ParentVNI, Last, *Dom.first,
SA.getLastSplitPointIter(Dom.first))->def;
}
// Remove redundant back-copies that are now known to be dominated by another
// def with the same value.
SmallVector<VNInfo*, 8> BackCopies;
for (VNInfo *VNI : LI->valnos) {
if (VNI->isUnused())
continue;
VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(VNI->def);
const DomPair &Dom = NearestDom[ParentVNI->id];
if (!Dom.first || Dom.second == VNI->def ||
NotToHoistSet.count(ParentVNI->id))
continue;
BackCopies.push_back(VNI);
forceRecompute(0, ParentVNI);
}
// If it is not beneficial to hoist all the BackCopies, simply remove
// redundant BackCopies in speed mode.
if (SpillMode == SM_Speed && !NotToHoistSet.empty())
computeRedundantBackCopies(NotToHoistSet, BackCopies);
removeBackCopies(BackCopies);
}
/// transferValues - Transfer all possible values to the new live ranges.
/// Values that were rematerialized are left alone, they need LRCalc.extend().
bool SplitEditor::transferValues() {
bool Skipped = false;
RegAssignMap::const_iterator AssignI = RegAssign.begin();
for (const LiveRange::Segment &S : Edit->getParent()) {
DEBUG(dbgs() << " blit " << S << ':');
VNInfo *ParentVNI = S.valno;
// RegAssign has holes where RegIdx 0 should be used.
SlotIndex Start = S.start;
AssignI.advanceTo(Start);
do {
unsigned RegIdx;
SlotIndex End = S.end;
if (!AssignI.valid()) {
RegIdx = 0;
} else if (AssignI.start() <= Start) {
RegIdx = AssignI.value();
if (AssignI.stop() < End) {
End = AssignI.stop();
++AssignI;
}
} else {
RegIdx = 0;
End = std::min(End, AssignI.start());
}
// The interval [Start;End) is continuously mapped to RegIdx, ParentVNI.
DEBUG(dbgs() << " [" << Start << ';' << End << ")=" << RegIdx);
LiveRange &LR = LIS.getInterval(Edit->get(RegIdx));
// Check for a simply defined value that can be blitted directly.
ValueForcePair VFP = Values.lookup(std::make_pair(RegIdx, ParentVNI->id));
if (VNInfo *VNI = VFP.getPointer()) {
DEBUG(dbgs() << ':' << VNI->id);
LR.addSegment(LiveInterval::Segment(Start, End, VNI));
Start = End;
continue;
}
// Skip values with forced recomputation.
if (VFP.getInt()) {
DEBUG(dbgs() << "(recalc)");
Skipped = true;
Start = End;
continue;
}
LiveRangeCalc &LRC = getLRCalc(RegIdx);
// This value has multiple defs in RegIdx, but it wasn't rematerialized,
// so the live range is accurate. Add live-in blocks in [Start;End) to the
// LiveInBlocks.
MachineFunction::iterator MBB = LIS.getMBBFromIndex(Start)->getIterator();
SlotIndex BlockStart, BlockEnd;
std::tie(BlockStart, BlockEnd) = LIS.getSlotIndexes()->getMBBRange(&*MBB);
// The first block may be live-in, or it may have its own def.
if (Start != BlockStart) {
VNInfo *VNI = LR.extendInBlock(BlockStart, std::min(BlockEnd, End));
assert(VNI && "Missing def for complex mapped value");
DEBUG(dbgs() << ':' << VNI->id << "*BB#" << MBB->getNumber());
// MBB has its own def. Is it also live-out?
if (BlockEnd <= End)
LRC.setLiveOutValue(&*MBB, VNI);
// Skip to the next block for live-in.
++MBB;
BlockStart = BlockEnd;
}
// Handle the live-in blocks covered by [Start;End).
assert(Start <= BlockStart && "Expected live-in block");
while (BlockStart < End) {
DEBUG(dbgs() << ">BB#" << MBB->getNumber());
BlockEnd = LIS.getMBBEndIdx(&*MBB);
if (BlockStart == ParentVNI->def) {
// This block has the def of a parent PHI, so it isn't live-in.
assert(ParentVNI->isPHIDef() && "Non-phi defined at block start?");
VNInfo *VNI = LR.extendInBlock(BlockStart, std::min(BlockEnd, End));
assert(VNI && "Missing def for complex mapped parent PHI");
if (End >= BlockEnd)
LRC.setLiveOutValue(&*MBB, VNI); // Live-out as well.
} else {
// This block needs a live-in value. The last block covered may not
// be live-out.
if (End < BlockEnd)
LRC.addLiveInBlock(LR, MDT[&*MBB], End);
else {
// Live-through, and we don't know the value.
LRC.addLiveInBlock(LR, MDT[&*MBB]);
LRC.setLiveOutValue(&*MBB, nullptr);
}
}
BlockStart = BlockEnd;
++MBB;
}
Start = End;
} while (Start != S.end);
DEBUG(dbgs() << '\n');
}
LRCalc[0].calculateValues();
if (SpillMode)
LRCalc[1].calculateValues();
return Skipped;
}
void SplitEditor::extendPHIKillRanges() {
// Extend live ranges to be live-out for successor PHI values.
for (const VNInfo *PHIVNI : Edit->getParent().valnos) {
if (PHIVNI->isUnused() || !PHIVNI->isPHIDef())
continue;
unsigned RegIdx = RegAssign.lookup(PHIVNI->def);
LiveRange &LR = LIS.getInterval(Edit->get(RegIdx));
// Check whether PHI is dead.
const LiveRange::Segment *Segment = LR.getSegmentContaining(PHIVNI->def);
assert(Segment != nullptr && "Missing segment for VNI");
if (Segment->end == PHIVNI->def.getDeadSlot()) {
// This is a dead PHI. Remove it.
LR.removeSegment(*Segment, true);
continue;
}
LiveRangeCalc &LRC = getLRCalc(RegIdx);
MachineBasicBlock *MBB = LIS.getMBBFromIndex(PHIVNI->def);
for (MachineBasicBlock::pred_iterator PI = MBB->pred_begin(),
PE = MBB->pred_end(); PI != PE; ++PI) {
SlotIndex End = LIS.getMBBEndIdx(*PI);
SlotIndex LastUse = End.getPrevSlot();
// The predecessor may not have a live-out value. That is OK, like an
// undef PHI operand.
if (Edit->getParent().liveAt(LastUse)) {
assert(RegAssign.lookup(LastUse) == RegIdx &&
"Different register assignment in phi predecessor");
LRC.extend(LR, End);
}
}
}
}
/// rewriteAssigned - Rewrite all uses of Edit->getReg().
void SplitEditor::rewriteAssigned(bool ExtendRanges) {
for (MachineRegisterInfo::reg_iterator RI = MRI.reg_begin(Edit->getReg()),
RE = MRI.reg_end(); RI != RE;) {
MachineOperand &MO = *RI;
MachineInstr *MI = MO.getParent();
++RI;
// LiveDebugVariables should have handled all DBG_VALUE instructions.
if (MI->isDebugValue()) {
DEBUG(dbgs() << "Zapping " << *MI);
MO.setReg(0);
continue;
}
// <undef> operands don't really read the register, so it doesn't matter
// which register we choose. When the use operand is tied to a def, we must
// use the same register as the def, so just do that always.
SlotIndex Idx = LIS.getInstructionIndex(*MI);
if (MO.isDef() || MO.isUndef())
Idx = Idx.getRegSlot(MO.isEarlyClobber());
// Rewrite to the mapped register at Idx.
unsigned RegIdx = RegAssign.lookup(Idx);
LiveInterval *LI = &LIS.getInterval(Edit->get(RegIdx));
MO.setReg(LI->reg);
DEBUG(dbgs() << " rewr BB#" << MI->getParent()->getNumber() << '\t'
<< Idx << ':' << RegIdx << '\t' << *MI);
// Extend liveness to Idx if the instruction reads reg.
if (!ExtendRanges || MO.isUndef())
continue;
// Skip instructions that don't read Reg.
if (MO.isDef()) {
if (!MO.getSubReg() && !MO.isEarlyClobber())
continue;
// We may wan't to extend a live range for a partial redef, or for a use
// tied to an early clobber.
Idx = Idx.getPrevSlot();
if (!Edit->getParent().liveAt(Idx))
continue;
} else
Idx = Idx.getRegSlot(true);
getLRCalc(RegIdx).extend(*LI, Idx.getNextSlot());
}
}
void SplitEditor::deleteRematVictims() {
SmallVector<MachineInstr*, 8> Dead;
for (LiveRangeEdit::iterator I = Edit->begin(), E = Edit->end(); I != E; ++I){
LiveInterval *LI = &LIS.getInterval(*I);
for (const LiveRange::Segment &S : LI->segments) {
// Dead defs end at the dead slot.
if (S.end != S.valno->def.getDeadSlot())
continue;
if (S.valno->isPHIDef())
continue;
MachineInstr *MI = LIS.getInstructionFromIndex(S.valno->def);
assert(MI && "Missing instruction for dead def");
MI->addRegisterDead(LI->reg, &TRI);
if (!MI->allDefsAreDead())
continue;
DEBUG(dbgs() << "All defs dead: " << *MI);
Dead.push_back(MI);
}
}
if (Dead.empty())
return;
Edit->eliminateDeadDefs(Dead);
}
void SplitEditor::finish(SmallVectorImpl<unsigned> *LRMap) {
++NumFinished;
// At this point, the live intervals in Edit contain VNInfos corresponding to
// the inserted copies.
// Add the original defs from the parent interval.
for (const VNInfo *ParentVNI : Edit->getParent().valnos) {
if (ParentVNI->isUnused())
continue;
unsigned RegIdx = RegAssign.lookup(ParentVNI->def);
defValue(RegIdx, ParentVNI, ParentVNI->def);
// Force rematted values to be recomputed everywhere.
// The new live ranges may be truncated.
if (Edit->didRematerialize(ParentVNI))
for (unsigned i = 0, e = Edit->size(); i != e; ++i)
forceRecompute(i, ParentVNI);
}
// Hoist back-copies to the complement interval when in spill mode.
switch (SpillMode) {
case SM_Partition:
// Leave all back-copies as is.
break;
case SM_Size:
case SM_Speed:
// hoistCopies will behave differently between size and speed.
hoistCopies();
}
// Transfer the simply mapped values, check if any are skipped.
bool Skipped = transferValues();
// Rewrite virtual registers, possibly extending ranges.
rewriteAssigned(Skipped);
if (Skipped)
extendPHIKillRanges();
else
++NumSimple;
// Delete defs that were rematted everywhere.
if (Skipped)
deleteRematVictims();
// Get rid of unused values and set phi-kill flags.
for (LiveRangeEdit::iterator I = Edit->begin(), E = Edit->end(); I != E; ++I) {
LiveInterval &LI = LIS.getInterval(*I);
LI.RenumberValues();
}
// Provide a reverse mapping from original indices to Edit ranges.
if (LRMap) {
LRMap->clear();
for (unsigned i = 0, e = Edit->size(); i != e; ++i)
LRMap->push_back(i);
}
// Now check if any registers were separated into multiple components.
ConnectedVNInfoEqClasses ConEQ(LIS);
for (unsigned i = 0, e = Edit->size(); i != e; ++i) {
// Don't use iterators, they are invalidated by create() below.
unsigned VReg = Edit->get(i);
LiveInterval &LI = LIS.getInterval(VReg);
SmallVector<LiveInterval*, 8> SplitLIs;
LIS.splitSeparateComponents(LI, SplitLIs);
unsigned Original = VRM.getOriginal(VReg);
for (LiveInterval *SplitLI : SplitLIs)
VRM.setIsSplitFromReg(SplitLI->reg, Original);
// The new intervals all map back to i.
if (LRMap)
LRMap->resize(Edit->size(), i);
}
// Calculate spill weight and allocation hints for new intervals.
Edit->calculateRegClassAndHint(VRM.getMachineFunction(), SA.Loops, MBFI);
assert(!LRMap || LRMap->size() == Edit->size());
}
//===----------------------------------------------------------------------===//
// Single Block Splitting
//===----------------------------------------------------------------------===//
bool SplitAnalysis::shouldSplitSingleBlock(const BlockInfo &BI,
bool SingleInstrs) const {
// Always split for multiple instructions.
if (!BI.isOneInstr())
return true;
// Don't split for single instructions unless explicitly requested.
if (!SingleInstrs)
return false;
// Splitting a live-through range always makes progress.
if (BI.LiveIn && BI.LiveOut)
return true;
// No point in isolating a copy. It has no register class constraints.
if (LIS.getInstructionFromIndex(BI.FirstInstr)->isCopyLike())
return false;
// Finally, don't isolate an end point that was created by earlier splits.
return isOriginalEndpoint(BI.FirstInstr);
}
void SplitEditor::splitSingleBlock(const SplitAnalysis::BlockInfo &BI) {
openIntv();
SlotIndex LastSplitPoint = SA.getLastSplitPoint(BI.MBB->getNumber());
SlotIndex SegStart = enterIntvBefore(std::min(BI.FirstInstr,
LastSplitPoint));
if (!BI.LiveOut || BI.LastInstr < LastSplitPoint) {
useIntv(SegStart, leaveIntvAfter(BI.LastInstr));
} else {
// The last use is after the last valid split point.
SlotIndex SegStop = leaveIntvBefore(LastSplitPoint);
useIntv(SegStart, SegStop);
overlapIntv(SegStop, BI.LastInstr);
}
}
//===----------------------------------------------------------------------===//
// Global Live Range Splitting Support
//===----------------------------------------------------------------------===//
// These methods support a method of global live range splitting that uses a
// global algorithm to decide intervals for CFG edges. They will insert split
// points and color intervals in basic blocks while avoiding interference.
//
// Note that splitSingleBlock is also useful for blocks where both CFG edges
// are on the stack.
void SplitEditor::splitLiveThroughBlock(unsigned MBBNum,
unsigned IntvIn, SlotIndex LeaveBefore,
unsigned IntvOut, SlotIndex EnterAfter){
SlotIndex Start, Stop;
std::tie(Start, Stop) = LIS.getSlotIndexes()->getMBBRange(MBBNum);
DEBUG(dbgs() << "BB#" << MBBNum << " [" << Start << ';' << Stop
<< ") intf " << LeaveBefore << '-' << EnterAfter
<< ", live-through " << IntvIn << " -> " << IntvOut);
assert((IntvIn || IntvOut) && "Use splitSingleBlock for isolated blocks");
assert((!LeaveBefore || LeaveBefore < Stop) && "Interference after block");
assert((!IntvIn || !LeaveBefore || LeaveBefore > Start) && "Impossible intf");
assert((!EnterAfter || EnterAfter >= Start) && "Interference before block");
MachineBasicBlock *MBB = VRM.getMachineFunction().getBlockNumbered(MBBNum);
if (!IntvOut) {
DEBUG(dbgs() << ", spill on entry.\n");
//
// <<<<<<<<< Possible LeaveBefore interference.
// |-----------| Live through.
// -____________ Spill on entry.
//
selectIntv(IntvIn);
SlotIndex Idx = leaveIntvAtTop(*MBB);
assert((!LeaveBefore || Idx <= LeaveBefore) && "Interference");
(void)Idx;
return;
}
if (!IntvIn) {
DEBUG(dbgs() << ", reload on exit.\n");
//
// >>>>>>> Possible EnterAfter interference.
// |-----------| Live through.
// ___________-- Reload on exit.
//
selectIntv(IntvOut);
SlotIndex Idx = enterIntvAtEnd(*MBB);
assert((!EnterAfter || Idx >= EnterAfter) && "Interference");
(void)Idx;
return;
}
if (IntvIn == IntvOut && !LeaveBefore && !EnterAfter) {
DEBUG(dbgs() << ", straight through.\n");
//
// |-----------| Live through.
// ------------- Straight through, same intv, no interference.
//
selectIntv(IntvOut);
useIntv(Start, Stop);
return;
}
// We cannot legally insert splits after LSP.
SlotIndex LSP = SA.getLastSplitPoint(MBBNum);
assert((!IntvOut || !EnterAfter || EnterAfter < LSP) && "Impossible intf");
if (IntvIn != IntvOut && (!LeaveBefore || !EnterAfter ||
LeaveBefore.getBaseIndex() > EnterAfter.getBoundaryIndex())) {
DEBUG(dbgs() << ", switch avoiding interference.\n");
//
// >>>> <<<< Non-overlapping EnterAfter/LeaveBefore interference.
// |-----------| Live through.
// ------======= Switch intervals between interference.
//
selectIntv(IntvOut);
SlotIndex Idx;
if (LeaveBefore && LeaveBefore < LSP) {
Idx = enterIntvBefore(LeaveBefore);
useIntv(Idx, Stop);
} else {
Idx = enterIntvAtEnd(*MBB);
}
selectIntv(IntvIn);
useIntv(Start, Idx);
assert((!LeaveBefore || Idx <= LeaveBefore) && "Interference");
assert((!EnterAfter || Idx >= EnterAfter) && "Interference");
return;
}
DEBUG(dbgs() << ", create local intv for interference.\n");
//
// >>><><><><<<< Overlapping EnterAfter/LeaveBefore interference.
// |-----------| Live through.
// ==---------== Switch intervals before/after interference.
//
assert(LeaveBefore <= EnterAfter && "Missed case");
selectIntv(IntvOut);
SlotIndex Idx = enterIntvAfter(EnterAfter);
useIntv(Idx, Stop);
assert((!EnterAfter || Idx >= EnterAfter) && "Interference");
selectIntv(IntvIn);
Idx = leaveIntvBefore(LeaveBefore);
useIntv(Start, Idx);
assert((!LeaveBefore || Idx <= LeaveBefore) && "Interference");
}
void SplitEditor::splitRegInBlock(const SplitAnalysis::BlockInfo &BI,
unsigned IntvIn, SlotIndex LeaveBefore) {
SlotIndex Start, Stop;
std::tie(Start, Stop) = LIS.getSlotIndexes()->getMBBRange(BI.MBB);
DEBUG(dbgs() << "BB#" << BI.MBB->getNumber() << " [" << Start << ';' << Stop
<< "), uses " << BI.FirstInstr << '-' << BI.LastInstr
<< ", reg-in " << IntvIn << ", leave before " << LeaveBefore
<< (BI.LiveOut ? ", stack-out" : ", killed in block"));
assert(IntvIn && "Must have register in");
assert(BI.LiveIn && "Must be live-in");
assert((!LeaveBefore || LeaveBefore > Start) && "Bad interference");
if (!BI.LiveOut && (!LeaveBefore || LeaveBefore >= BI.LastInstr)) {
DEBUG(dbgs() << " before interference.\n");
//
// <<< Interference after kill.
// |---o---x | Killed in block.
// ========= Use IntvIn everywhere.
//
selectIntv(IntvIn);
useIntv(Start, BI.LastInstr);
return;
}
SlotIndex LSP = SA.getLastSplitPoint(BI.MBB->getNumber());
if (!LeaveBefore || LeaveBefore > BI.LastInstr.getBoundaryIndex()) {
//
// <<< Possible interference after last use.
// |---o---o---| Live-out on stack.
// =========____ Leave IntvIn after last use.
//
// < Interference after last use.
// |---o---o--o| Live-out on stack, late last use.
// ============ Copy to stack after LSP, overlap IntvIn.
// \_____ Stack interval is live-out.
//
if (BI.LastInstr < LSP) {
DEBUG(dbgs() << ", spill after last use before interference.\n");
selectIntv(IntvIn);
SlotIndex Idx = leaveIntvAfter(BI.LastInstr);
useIntv(Start, Idx);
assert((!LeaveBefore || Idx <= LeaveBefore) && "Interference");
} else {
DEBUG(dbgs() << ", spill before last split point.\n");
selectIntv(IntvIn);
SlotIndex Idx = leaveIntvBefore(LSP);
overlapIntv(Idx, BI.LastInstr);
useIntv(Start, Idx);
assert((!LeaveBefore || Idx <= LeaveBefore) && "Interference");
}
return;
}
// The interference is overlapping somewhere we wanted to use IntvIn. That
// means we need to create a local interval that can be allocated a
// different register.
unsigned LocalIntv = openIntv();
(void)LocalIntv;
DEBUG(dbgs() << ", creating local interval " << LocalIntv << ".\n");
if (!BI.LiveOut || BI.LastInstr < LSP) {
//
// <<<<<<< Interference overlapping uses.
// |---o---o---| Live-out on stack.
// =====----____ Leave IntvIn before interference, then spill.
//
SlotIndex To = leaveIntvAfter(BI.LastInstr);
SlotIndex From = enterIntvBefore(LeaveBefore);
useIntv(From, To);
selectIntv(IntvIn);
useIntv(Start, From);
assert((!LeaveBefore || From <= LeaveBefore) && "Interference");
return;
}
// <<<<<<< Interference overlapping uses.
// |---o---o--o| Live-out on stack, late last use.
// =====------- Copy to stack before LSP, overlap LocalIntv.
// \_____ Stack interval is live-out.
//
SlotIndex To = leaveIntvBefore(LSP);
overlapIntv(To, BI.LastInstr);
SlotIndex From = enterIntvBefore(std::min(To, LeaveBefore));
useIntv(From, To);
selectIntv(IntvIn);
useIntv(Start, From);
assert((!LeaveBefore || From <= LeaveBefore) && "Interference");
}
void SplitEditor::splitRegOutBlock(const SplitAnalysis::BlockInfo &BI,
unsigned IntvOut, SlotIndex EnterAfter) {
SlotIndex Start, Stop;
std::tie(Start, Stop) = LIS.getSlotIndexes()->getMBBRange(BI.MBB);
DEBUG(dbgs() << "BB#" << BI.MBB->getNumber() << " [" << Start << ';' << Stop
<< "), uses " << BI.FirstInstr << '-' << BI.LastInstr
<< ", reg-out " << IntvOut << ", enter after " << EnterAfter
<< (BI.LiveIn ? ", stack-in" : ", defined in block"));
SlotIndex LSP = SA.getLastSplitPoint(BI.MBB->getNumber());
assert(IntvOut && "Must have register out");
assert(BI.LiveOut && "Must be live-out");
assert((!EnterAfter || EnterAfter < LSP) && "Bad interference");
if (!BI.LiveIn && (!EnterAfter || EnterAfter <= BI.FirstInstr)) {
DEBUG(dbgs() << " after interference.\n");
//
// >>>> Interference before def.
// | o---o---| Defined in block.
// ========= Use IntvOut everywhere.
//
selectIntv(IntvOut);
useIntv(BI.FirstInstr, Stop);
return;
}
if (!EnterAfter || EnterAfter < BI.FirstInstr.getBaseIndex()) {
DEBUG(dbgs() << ", reload after interference.\n");
//
// >>>> Interference before def.
// |---o---o---| Live-through, stack-in.
// ____========= Enter IntvOut before first use.
//
selectIntv(IntvOut);
SlotIndex Idx = enterIntvBefore(std::min(LSP, BI.FirstInstr));
useIntv(Idx, Stop);
assert((!EnterAfter || Idx >= EnterAfter) && "Interference");
return;
}
// The interference is overlapping somewhere we wanted to use IntvOut. That
// means we need to create a local interval that can be allocated a
// different register.
DEBUG(dbgs() << ", interference overlaps uses.\n");
//
// >>>>>>> Interference overlapping uses.
// |---o---o---| Live-through, stack-in.
// ____---====== Create local interval for interference range.
//
selectIntv(IntvOut);
SlotIndex Idx = enterIntvAfter(EnterAfter);
useIntv(Idx, Stop);
assert((!EnterAfter || Idx >= EnterAfter) && "Interference");
openIntv();
SlotIndex From = enterIntvBefore(std::min(Idx, BI.FirstInstr));
useIntv(From, Idx);
}
| [
"wangl@cb94f8c2-beb9-42d2-aaaf-6dc30ea5c36a"
] | wangl@cb94f8c2-beb9-42d2-aaaf-6dc30ea5c36a |
b02807b70cd5e038ca2cada844ef84990b855cd8 | c4d51d07bfa867a2c5f1c0ffb93a375ee9bf3409 | /ncnn/src/layer/arm/eltwise_arm.cpp | 3bc6b1d02d62071d38e8bab8c891ffa7b82500cc | [] | no_license | ganyuhuoguang/ncnn-tool | c7a56307ac8f662b08744527bca61b1ff813a664 | 5be6968a68437cc624b07e7a7784ceef519975cd | refs/heads/master | 2023-01-04T06:29:38.488822 | 2020-10-15T07:03:38 | 2020-10-15T07:03:38 | 261,683,959 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 31,064 | cpp | // Tencent is pleased to support the open source community by making ncnn available.
//
// Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
// in compliance with the License. You may obtain a copy of the License at
//
// https://opensource.org/licenses/BSD-3-Clause
//
// Unless required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
#include "eltwise_arm.h"
#if __ARM_NEON
#include <arm_neon.h>
#endif // __ARM_NEON
namespace tmtool {
DEFINE_LAYER_CREATOR(Eltwise_arm)
int Eltwise_arm::forward(const std::vector<Mat>& bottom_blobs, std::vector<Mat>& top_blobs, const Option& opt) const
{
const Mat& bottom_blob = bottom_blobs[0];
int w = bottom_blob.w;
int h = bottom_blob.h;
int channels = bottom_blob.c;
size_t elemsize = bottom_blob.elemsize;
int elempack = bottom_blob.elempack;
int size = w * h;
Mat& top_blob = top_blobs[0];
top_blob.create(w, h, channels, elemsize, elempack, opt.blob_allocator);
if (top_blob.empty())
return -100;
if (opt.use_packing_layout)
{
if (elempack == 4)
{
if (op_type == Operation_PROD)
{
// first blob
const Mat& bottom_blob1 = bottom_blobs[1];
#pragma omp parallel for num_threads(opt.num_threads)
for (int q=0; q<channels; q++)
{
const float* ptr = bottom_blob.channel(q);
const float* ptr1 = bottom_blob1.channel(q);
float* outptr = top_blob.channel(q);
for (int i=0; i<size; i++)
{
float32x4_t _p = vld1q_f32(ptr);
float32x4_t _p1 = vld1q_f32(ptr1);
_p = vmulq_f32(_p, _p1);
vst1q_f32(outptr, _p);
ptr += 4;
ptr1 += 4;
outptr += 4;
}
}
for (size_t b=2; b<bottom_blobs.size(); b++)
{
const Mat& bottom_blob1 = bottom_blobs[b];
#pragma omp parallel for num_threads(opt.num_threads)
for (int q=0; q<channels; q++)
{
const float* ptr = bottom_blob1.channel(q);
float* outptr = top_blob.channel(q);
for (int i=0; i<size; i++)
{
float32x4_t _p = vld1q_f32(outptr);
float32x4_t _p1 = vld1q_f32(ptr);
_p = vmulq_f32(_p, _p1);
vst1q_f32(outptr, _p);
ptr += 4;
outptr += 4;
}
}
}
}
else if (op_type == Operation_SUM)
{
if (coeffs.w == 0)
{
// first blob
const Mat& bottom_blob1 = bottom_blobs[1];
#pragma omp parallel for num_threads(opt.num_threads)
for (int q=0; q<channels; q++)
{
const float* ptr = bottom_blob.channel(q);
const float* ptr1 = bottom_blob1.channel(q);
float* outptr = top_blob.channel(q);
for (int i=0; i<size; i++)
{
float32x4_t _p = vld1q_f32(ptr);
float32x4_t _p1 = vld1q_f32(ptr1);
_p = vaddq_f32(_p, _p1);
vst1q_f32(outptr, _p);
ptr += 4;
ptr1 += 4;
outptr += 4;
}
}
for (size_t b=2; b<bottom_blobs.size(); b++)
{
const Mat& bottom_blob1 = bottom_blobs[b];
#pragma omp parallel for num_threads(opt.num_threads)
for (int q=0; q<channels; q++)
{
const float* ptr = bottom_blob1.channel(q);
float* outptr = top_blob.channel(q);
for (int i=0; i<size; i++)
{
float32x4_t _p = vld1q_f32(outptr);
float32x4_t _p1 = vld1q_f32(ptr);
_p = vaddq_f32(_p, _p1);
vst1q_f32(outptr, _p);
ptr += 4;
outptr += 4;
}
}
}
}
else
{
// first blob
const Mat& bottom_blob1 = bottom_blobs[1];
float32x4_t _coeff0 = vdupq_n_f32(coeffs[0]);
float32x4_t _coeff1 = vdupq_n_f32(coeffs[1]);
#pragma omp parallel for num_threads(opt.num_threads)
for (int q=0; q<channels; q++)
{
const float* ptr = bottom_blob.channel(q);
const float* ptr1 = bottom_blob1.channel(q);
float* outptr = top_blob.channel(q);
for (int i=0; i<size; i++)
{
float32x4_t _p = vld1q_f32(ptr);
float32x4_t _p1 = vld1q_f32(ptr1);
_p = vmulq_f32(_p, _coeff0);
_p = vmlaq_f32(_p, _p1, _coeff1);
vst1q_f32(outptr, _p);
ptr += 4;
ptr1 += 4;
outptr += 4;
}
}
for (size_t b=2; b<bottom_blobs.size(); b++)
{
const Mat& bottom_blob1 = bottom_blobs[b];
float32x4_t _coeff = vdupq_n_f32(coeffs[b]);
#pragma omp parallel for num_threads(opt.num_threads)
for (int q=0; q<channels; q++)
{
const float* ptr = bottom_blob1.channel(q);
float* outptr = top_blob.channel(q);
for (int i=0; i<size; i++)
{
float32x4_t _p = vld1q_f32(outptr);
float32x4_t _p1 = vld1q_f32(ptr);
_p = vmlaq_f32(_p, _p1, _coeff);
vst1q_f32(outptr, _p);
ptr += 4;
outptr += 4;
}
}
}
}
}
else if (op_type == Operation_MAX)
{
// first blob
const Mat& bottom_blob1 = bottom_blobs[1];
#pragma omp parallel for num_threads(opt.num_threads)
for (int q=0; q<channels; q++)
{
const float* ptr = bottom_blob.channel(q);
const float* ptr1 = bottom_blob1.channel(q);
float* outptr = top_blob.channel(q);
for (int i=0; i<size; i++)
{
float32x4_t _p = vld1q_f32(ptr);
float32x4_t _p1 = vld1q_f32(ptr1);
_p = vmaxq_f32(_p, _p1);
vst1q_f32(outptr, _p);
ptr += 4;
ptr1 += 4;
outptr += 4;
}
}
for (size_t b=2; b<bottom_blobs.size(); b++)
{
const Mat& bottom_blob1 = bottom_blobs[b];
#pragma omp parallel for num_threads(opt.num_threads)
for (int q=0; q<channels; q++)
{
const float* ptr = bottom_blob1.channel(q);
float* outptr = top_blob.channel(q);
for (int i=0; i<size; i++)
{
float32x4_t _p = vld1q_f32(outptr);
float32x4_t _p1 = vld1q_f32(ptr);
_p = vmaxq_f32(_p, _p1);
vst1q_f32(outptr, _p);
ptr += 4;
outptr += 4;
}
}
}
}
return 0;
}
} // opt.use_packing_layout
if (op_type == Operation_PROD)
{
// first blob
const Mat& bottom_blob1 = bottom_blobs[1];
#pragma omp parallel for num_threads(opt.num_threads)
for (int q=0; q<channels; q++)
{
const float* ptr = bottom_blob.channel(q);
const float* ptr1 = bottom_blob1.channel(q);
float* outptr = top_blob.channel(q);
#if __ARM_NEON
int nn = size >> 2;
int remain = size - (nn << 2);
#else
int remain = size;
#endif // __ARM_NEON
#if __ARM_NEON
#if __aarch64__
if (nn > 0)
{
asm volatile(
"0: \n"
"prfm pldl1keep, [%1, #128] \n"
"prfm pldl1keep, [%2, #128] \n"
"ld1 {v0.4s}, [%1], #16 \n"
"ld1 {v1.4s}, [%2], #16 \n"
"fmul v0.4s, v0.4s, v1.4s \n"
"subs %w0, %w0, #1 \n"
"st1 {v0.4s}, [%3], #16 \n"
"bne 0b \n"
: "=r"(nn), // %0
"=r"(ptr), // %1
"=r"(ptr1), // %2
"=r"(outptr) // %3
: "0"(nn),
"1"(ptr),
"2"(ptr1),
"3"(outptr)
: "cc", "memory", "v0", "v1"
);
}
#else
if (nn > 0)
{
asm volatile(
"0: \n"
"pld [%1, #128] \n"
"pld [%2, #128] \n"
"vld1.f32 {d0-d1}, [%1 :128]! \n"
"vld1.f32 {d2-d3}, [%2 :128]! \n"
"vmul.f32 q0, q0, q1 \n"
"subs %0, #1 \n"
"vst1.f32 {d0-d1}, [%3 :128]! \n"
"bne 0b \n"
: "=r"(nn), // %0
"=r"(ptr), // %1
"=r"(ptr1), // %2
"=r"(outptr) // %3
: "0"(nn),
"1"(ptr),
"2"(ptr1),
"3"(outptr)
: "cc", "memory", "q0", "q1"
);
}
#endif // __aarch64__
#endif // __ARM_NEON
for (; remain>0; remain--)
{
*outptr = *ptr * *ptr1;
ptr++;
ptr1++;
outptr++;
}
}
for (size_t b=2; b<bottom_blobs.size(); b++)
{
const Mat& bottom_blob1 = bottom_blobs[b];
#pragma omp parallel for num_threads(opt.num_threads)
for (int q=0; q<channels; q++)
{
const float* ptr = bottom_blob1.channel(q);
float* outptr = top_blob.channel(q);
#if __ARM_NEON
int nn = size >> 2;
int remain = size - (nn << 2);
#else
int remain = size;
#endif // __ARM_NEON
#if __ARM_NEON
#if __aarch64__
if (nn > 0)
{
asm volatile(
"0: \n"
"prfm pldl1keep, [%1, #128] \n"
"prfm pldl1keep, [%2, #128] \n"
"ld1 {v0.4s}, [%1], #16 \n"
"ld1 {v1.4s}, [%2] \n"
"fmul v0.4s, v0.4s, v1.4s \n"
"subs %w0, %w0, #1 \n"
"st1 {v0.4s}, [%2], #16 \n"
"bne 0b \n"
: "=r"(nn), // %0
"=r"(ptr), // %1
"=r"(outptr) // %2
: "0"(nn),
"1"(ptr),
"2"(outptr)
: "cc", "memory", "v0", "v1"
);
}
#else
if (nn > 0)
{
asm volatile(
"0: \n"
"pld [%1, #128] \n"
"pld [%2, #128] \n"
"vld1.f32 {d0-d1}, [%1 :128]! \n"
"vld1.f32 {d2-d3}, [%2 :128] \n"
"vmul.f32 q0, q0, q1 \n"
"subs %0, #1 \n"
"vst1.f32 {d0-d1}, [%2 :128]! \n"
"bne 0b \n"
: "=r"(nn), // %0
"=r"(ptr), // %1
"=r"(outptr) // %2
: "0"(nn),
"1"(ptr),
"2"(outptr)
: "cc", "memory", "q0", "q1"
);
}
#endif // __aarch64__
#endif // __ARM_NEON
for (; remain>0; remain--)
{
*outptr *= *ptr;
ptr++;
outptr++;
}
}
}
}
else if (op_type == Operation_SUM)
{
if (coeffs.w == 0)
{
// first blob
const Mat& bottom_blob1 = bottom_blobs[1];
#pragma omp parallel for num_threads(opt.num_threads)
for (int q=0; q<channels; q++)
{
const float* ptr = bottom_blob.channel(q);
const float* ptr1 = bottom_blob1.channel(q);
float* outptr = top_blob.channel(q);
#if __ARM_NEON
int nn = size >> 2;
int remain = size - (nn << 2);
#else
int remain = size;
#endif // __ARM_NEON
#if __ARM_NEON
#if __aarch64__
if (nn > 0)
{
asm volatile(
"0: \n"
"prfm pldl1keep, [%1, #128] \n"
"prfm pldl1keep, [%2, #128] \n"
"ld1 {v0.4s}, [%1], #16 \n"
"ld1 {v1.4s}, [%2], #16 \n"
"fadd v0.4s, v0.4s, v1.4s \n"
"subs %w0, %w0, #1 \n"
"st1 {v0.4s}, [%3], #16 \n"
"bne 0b \n"
: "=r"(nn), // %0
"=r"(ptr), // %1
"=r"(ptr1), // %2
"=r"(outptr) // %3
: "0"(nn),
"1"(ptr),
"2"(ptr1),
"3"(outptr)
: "cc", "memory", "v0", "v1"
);
}
#else
if (nn > 0)
{
asm volatile(
"0: \n"
"pld [%1, #128] \n"
"pld [%2, #128] \n"
"vld1.f32 {d0-d1}, [%1 :128]! \n"
"vld1.f32 {d2-d3}, [%2 :128]! \n"
"vadd.f32 q0, q0, q1 \n"
"subs %0, #1 \n"
"vst1.f32 {d0-d1}, [%3 :128]! \n"
"bne 0b \n"
: "=r"(nn), // %0
"=r"(ptr), // %1
"=r"(ptr1), // %2
"=r"(outptr) // %3
: "0"(nn),
"1"(ptr),
"2"(ptr1),
"3"(outptr)
: "cc", "memory", "q0", "q1"
);
}
#endif // __aarch64__
#endif // __ARM_NEON
for (; remain>0; remain--)
{
*outptr = *ptr + *ptr1;
ptr++;
ptr1++;
outptr++;
}
}
for (size_t b=2; b<bottom_blobs.size(); b++)
{
const Mat& bottom_blob1 = bottom_blobs[b];
#pragma omp parallel for num_threads(opt.num_threads)
for (int q=0; q<channels; q++)
{
const float* ptr = bottom_blob1.channel(q);
float* outptr = top_blob.channel(q);
#if __ARM_NEON
int nn = size >> 2;
int remain = size - (nn << 2);
#else
int remain = size;
#endif // __ARM_NEON
#if __ARM_NEON
#if __aarch64__
if (nn > 0)
{
asm volatile(
"0: \n"
"prfm pldl1keep, [%1, #128] \n"
"prfm pldl1keep, [%2, #128] \n"
"ld1 {v0.4s}, [%1], #16 \n"
"ld1 {v1.4s}, [%2] \n"
"fadd v0.4s, v0.4s, v1.4s \n"
"subs %w0, %w0, #1 \n"
"st1 {v0.4s}, [%2], #16 \n"
"bne 0b \n"
: "=r"(nn), // %0
"=r"(ptr), // %1
"=r"(outptr) // %2
: "0"(nn),
"1"(ptr),
"2"(outptr)
: "cc", "memory", "v0", "v1"
);
}
#else
if (nn > 0)
{
asm volatile(
"0: \n"
"pld [%1, #128] \n"
"pld [%2, #128] \n"
"vld1.f32 {d0-d1}, [%1 :128]! \n"
"vld1.f32 {d2-d3}, [%2 :128] \n"
"vadd.f32 q0, q0, q1 \n"
"subs %0, #1 \n"
"vst1.f32 {d0-d1}, [%2 :128]! \n"
"bne 0b \n"
: "=r"(nn), // %0
"=r"(ptr), // %1
"=r"(outptr) // %2
: "0"(nn),
"1"(ptr),
"2"(outptr)
: "cc", "memory", "q0", "q1"
);
}
#endif // __aarch64__
#endif // __ARM_NEON
for (; remain>0; remain--)
{
*outptr += *ptr;
ptr++;
outptr++;
}
}
}
}
else
{
// first blob
const Mat& bottom_blob1 = bottom_blobs[1];
float coeff0 = coeffs[0];
float coeff1 = coeffs[1];
#pragma omp parallel for num_threads(opt.num_threads)
for (int q=0; q<channels; q++)
{
const float* ptr = bottom_blob.channel(q);
const float* ptr1 = bottom_blob1.channel(q);
float* outptr = top_blob.channel(q);
#if __ARM_NEON
int nn = size >> 2;
int remain = size - (nn << 2);
#else
int remain = size;
#endif // __ARM_NEON
#if __ARM_NEON
float32x4_t _coeff0 = vdupq_n_f32(coeff0);
float32x4_t _coeff1 = vdupq_n_f32(coeff1);
#if __aarch64__
if (nn > 0)
{
asm volatile(
"0: \n"
"prfm pldl1keep, [%1, #128] \n"
"prfm pldl1keep, [%2, #128] \n"
"ld1 {v0.4s}, [%1], #16 \n"
"ld1 {v1.4s}, [%2], #16 \n"
"fmul v0.4s, v0.4s, %8.4s \n"
"fmla v0.4s, v1.4s, %9.4s \n"
"subs %w0, %w0, #1 \n"
"st1 {v0.4s}, [%3], #16 \n"
"bne 0b \n"
: "=r"(nn), // %0
"=r"(ptr), // %1
"=r"(ptr1), // %2
"=r"(outptr) // %3
: "0"(nn),
"1"(ptr),
"2"(ptr1),
"3"(outptr),
"w"(_coeff0), // %8
"w"(_coeff1) // %9
: "cc", "memory", "v0", "v1"
);
}
#else
if (nn > 0)
{
asm volatile(
"0: \n"
"pld [%1, #128] \n"
"pld [%2, #128] \n"
"vld1.f32 {d0-d1}, [%1 :128]! \n"
"vld1.f32 {d2-d3}, [%2 :128]! \n"
"vmul.f32 q0, q0, %q8 \n"
"vmla.f32 q0, q1, %q9 \n"
"subs %0, #1 \n"
"vst1.f32 {d0-d1}, [%3 :128]! \n"
"bne 0b \n"
: "=r"(nn), // %0
"=r"(ptr), // %1
"=r"(ptr1), // %2
"=r"(outptr) // %3
: "0"(nn),
"1"(ptr),
"2"(ptr1),
"3"(outptr),
"w"(_coeff0), // %8
"w"(_coeff1) // %9
: "cc", "memory", "q0", "q1"
);
}
#endif // __aarch64__
#endif // __ARM_NEON
for (; remain>0; remain--)
{
*outptr = *ptr * coeff0 + *ptr1 * coeff1;
ptr++;
ptr1++;
outptr++;
}
}
for (size_t b=2; b<bottom_blobs.size(); b++)
{
const Mat& bottom_blob1 = bottom_blobs[b];
float coeff = coeffs[b];
#pragma omp parallel for num_threads(opt.num_threads)
for (int q=0; q<channels; q++)
{
const float* ptr = bottom_blob1.channel(q);
float* outptr = top_blob.channel(q);
#if __ARM_NEON
int nn = size >> 2;
int remain = size - (nn << 2);
#else
int remain = size;
#endif // __ARM_NEON
#if __ARM_NEON
float32x4_t _coeff = vdupq_n_f32(coeff);
#if __aarch64__
if (nn > 0)
{
asm volatile(
"0: \n"
"prfm pldl1keep, [%1, #128] \n"
"prfm pldl1keep, [%2, #128] \n"
"ld1 {v0.4s}, [%1], #16 \n"
"ld1 {v1.4s}, [%2] \n"
"fmla v1.4s, v0.4s, %6.4s \n"
"subs %w0, %w0, #1 \n"
"st1 {v1.4s}, [%2], #16 \n"
"bne 0b \n"
: "=r"(nn), // %0
"=r"(ptr), // %1
"=r"(outptr) // %2
: "0"(nn),
"1"(ptr),
"2"(outptr),
"w"(_coeff) // %6
: "cc", "memory", "v0", "v1"
);
}
#else
if (nn > 0)
{
asm volatile(
"0: \n"
"pld [%1, #128] \n"
"pld [%2, #128] \n"
"vld1.f32 {d0-d1}, [%1 :128]! \n"
"vld1.f32 {d2-d3}, [%2 :128] \n"
"vmla.f32 q1, q0, %q6 \n"
"subs %0, #1 \n"
"vst1.f32 {d2-d3}, [%2 :128]! \n"
"bne 0b \n"
: "=r"(nn), // %0
"=r"(ptr), // %1
"=r"(outptr) // %2
: "0"(nn),
"1"(ptr),
"2"(outptr),
"w"(_coeff) // %6
: "cc", "memory", "q0", "q1"
);
}
#endif // __aarch64__
#endif // __ARM_NEON
for (; remain>0; remain--)
{
*outptr += *ptr * coeff;
ptr++;
outptr++;
}
}
}
}
}
else if (op_type == Operation_MAX)
{
// first blob
const Mat& bottom_blob1 = bottom_blobs[1];
#pragma omp parallel for num_threads(opt.num_threads)
for (int q=0; q<channels; q++)
{
const float* ptr = bottom_blob.channel(q);
const float* ptr1 = bottom_blob1.channel(q);
float* outptr = top_blob.channel(q);
#if __ARM_NEON
int nn = size >> 2;
int remain = size - (nn << 2);
#else
int remain = size;
#endif // __ARM_NEON
#if __ARM_NEON
#if __aarch64__
if (nn > 0)
{
asm volatile(
"0: \n"
"prfm pldl1keep, [%1, #128] \n"
"prfm pldl1keep, [%2, #128] \n"
"ld1 {v0.4s}, [%1], #16 \n"
"ld1 {v1.4s}, [%2], #16 \n"
"fmax v0.4s, v0.4s, v1.4s \n"
"subs %w0, %w0, #1 \n"
"st1 {v0.4s}, [%3], #16 \n"
"bne 0b \n"
: "=r"(nn), // %0
"=r"(ptr), // %1
"=r"(ptr1), // %2
"=r"(outptr) // %3
: "0"(nn),
"1"(ptr),
"2"(ptr1),
"3"(outptr)
: "cc", "memory", "v0", "v1"
);
}
#else
if (nn > 0)
{
asm volatile(
"0: \n"
"pld [%1, #128] \n"
"pld [%2, #128] \n"
"vld1.f32 {d0-d1}, [%1 :128]! \n"
"vld1.f32 {d2-d3}, [%2 :128]! \n"
"vmax.f32 q0, q0, q1 \n"
"subs %0, #1 \n"
"vst1.f32 {d0-d1}, [%3 :128]! \n"
"bne 0b \n"
: "=r"(nn), // %0
"=r"(ptr), // %1
"=r"(ptr1), // %2
"=r"(outptr) // %3
: "0"(nn),
"1"(ptr),
"2"(ptr1),
"3"(outptr)
: "cc", "memory", "q0", "q1"
);
}
#endif // __aarch64__
#endif // __ARM_NEON
for (; remain>0; remain--)
{
*outptr = std::max(*ptr, *ptr1);
ptr++;
ptr1++;
outptr++;
}
}
for (size_t b=2; b<bottom_blobs.size(); b++)
{
const Mat& bottom_blob1 = bottom_blobs[b];
#pragma omp parallel for num_threads(opt.num_threads)
for (int q=0; q<channels; q++)
{
const float* ptr = bottom_blob1.channel(q);
float* outptr = top_blob.channel(q);
#if __ARM_NEON
int nn = size >> 2;
int remain = size - (nn << 2);
#else
int remain = size;
#endif // __ARM_NEON
#if __ARM_NEON
#if __aarch64__
if (nn > 0)
{
asm volatile(
"0: \n"
"prfm pldl1keep, [%1, #128] \n"
"prfm pldl1keep, [%2, #128] \n"
"ld1 {v0.4s}, [%1], #16 \n"
"ld1 {v1.4s}, [%2] \n"
"fmax v0.4s, v0.4s, v1.4s \n"
"subs %w0, %w0, #1 \n"
"st1 {v0.4s}, [%2], #16 \n"
"bne 0b \n"
: "=r"(nn), // %0
"=r"(ptr), // %1
"=r"(outptr) // %2
: "0"(nn),
"1"(ptr),
"2"(outptr)
: "cc", "memory", "v0", "v1"
);
}
#else
if (nn > 0)
{
asm volatile(
"0: \n"
"pld [%1, #128] \n"
"pld [%2, #128] \n"
"vld1.f32 {d0-d1}, [%1 :128]! \n"
"vld1.f32 {d2-d3}, [%2 :128] \n"
"vmax.f32 q0, q0, q1 \n"
"subs %0, #1 \n"
"vst1.f32 {d0-d1}, [%2 :128]! \n"
"bne 0b \n"
: "=r"(nn), // %0
"=r"(ptr), // %1
"=r"(outptr) // %2
: "0"(nn),
"1"(ptr),
"2"(outptr)
: "cc", "memory", "q0", "q1"
);
}
#endif // __aarch64__
#endif // __ARM_NEON
for (; remain>0; remain--)
{
*outptr = std::max(*ptr, *outptr);
ptr++;
outptr++;
}
}
}
}
return 0;
}
} // namespace tmtool
| [
"1151812935@qq.com"
] | 1151812935@qq.com |
71be0adc6a35b2d39dc1716c1477f7b8ea1a6e09 | a8a79f15ea0689e0eec19e3e5d3cf18ad3cfd0ff | /ZeroEngine/NthEngine/Sprite.cpp | 5203900cdccff24c863a6234fbf6c4a61f2978ad | [] | no_license | sidzero/MyProject | 8c0982617ca4ac2fd44b4fc0105f0858e30ff54e | 244bd79813059aa4658932c8088a3138a6f3028d | refs/heads/master | 2021-01-02T08:32:53.270289 | 2015-11-16T07:34:02 | 2015-11-16T07:34:02 | 40,749,270 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,770 | cpp | #include "Sprite.h"
#include "Vertex.h"
#include "ResourceManager.h"
#include<cstddef>
namespace nEngine
{
Sprite::Sprite()
{
_vboID = 0;
}
Sprite::~Sprite()
{
if (_vboID != 0)
{
glDeleteBuffers(1, &_vboID);
}
}
void Sprite::init(float x, float y, float width, float height, std::string texturePath)
{
_x = x;
_y = y;
_width = width;
_height = height;
_texture = ResourceManager::getTexture(texturePath);
if (_vboID == 0)
{
glGenBuffers(1, &_vboID);
}
//screen codrinates bottom left start at 0,0
//GLfloat vertexData[12];
Vertex vertexData[6];
//firt traingle
/*vertexData[0].position.x = x + width;
vertexData[0].position.y = y + height;*/
vertexData[0].setPosition(x + width, y + height);
vertexData[0].setUV(1.0f, 1.0f);
/*vertexData[1].position.x = x;
vertexData[1].position.y = y + height;*/
vertexData[1].setPosition(x, y + height);
vertexData[1].setUV(0.0f, 1.0f);
/*vertexData[2].position.x = x;
vertexData[2].position.y = y;*/
vertexData[2].setPosition(x, y);
vertexData[2].setUV(0.0f, 0.0f);
//secind
//vertexData[3].position.x = x ;
//vertexData[3].position.y = y ;
vertexData[3].setPosition(x, y);
vertexData[3].setUV(0.0f, 0.0f);
/*
vertexData[4].position.x = x+width;
vertexData[4].position.y = y;*/
vertexData[4].setPosition(x + width, y);
vertexData[4].setUV(1.0f, 0.0f);
/*vertexData[5].position.x = x+width;
vertexData[5].position.y = y+height;*/
vertexData[5].setPosition(x + width, y + height);
vertexData[5].setUV(1.0f, 1.0f);
for (int i = 0; i < 6; i++)
{
vertexData[i].color.r = 255;
vertexData[i].color.g = 0;
vertexData[i].color.b = 255;
vertexData[i].color.a = 255;
}
vertexData[1].setColor(255, 0, 0, 255);
vertexData[4].setColor(0, 255, 0, 255);
glBindBuffer(GL_ARRAY_BUFFER, _vboID);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertexData), vertexData, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
};
void Sprite::draw()
{
glBindTexture(GL_TEXTURE_2D, _texture.id);
glBindBuffer(GL_ARRAY_BUFFER, _vboID);
glEnableVertexAttribArray(0);
//this postion attrinb pointer
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, position));
glEnableVertexAttribArray(1);
//this color attrinb pointer
glVertexAttribPointer(1, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(Vertex), (void*)offsetof(Vertex, color));
glEnableVertexAttribArray(2);
//this uv attrinb pointer
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, uv));
glDrawArrays(GL_TRIANGLES, 0, 6);
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
glDisableVertexAttribArray(2);
glBindBuffer(GL_ARRAY_BUFFER, 0);
};
}; | [
"srikanth.siddhu@gmail.com"
] | srikanth.siddhu@gmail.com |
60c8086ab218cf30de02cc777c394177aad7975c | c846f199a160a5c8e96a5497c1a6725cface69f7 | /include/flash_driver_file.h | f8ab606707044e8c70e14d16ccf4ee3691e3535f | [] | no_license | ErnestSzczepaniak/rfs | 0a7adb2ddb25b66e5a680acae065999645535a23 | 4ae463709ba77b1ef27973ff4d274b4617d93d42 | refs/heads/master | 2022-10-12T02:59:08.911371 | 2020-06-14T20:57:25 | 2020-06-14T20:57:25 | 255,918,338 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 655 | h | #ifndef _flash_driver_file_h
#define _flash_driver_file_h
/**
* @file flash_driver_file.h
* @author en2
* @date 28-04-2020
* @brief
* @details
**/
#ifdef build_platform_host
#include "flash_driver_generic.h"
#include <fstream>
class Flash_driver_file : public Flash_driver_generic
{
/**
* @class Flash_driver_file
* @brief
* @details
**/
public:
bool init();
bool deinit();
bool read(int, int, unsigned char *);
bool write(int, int, unsigned char *);
bool erase(int, int);
private:
std::fstream _stream;
}; /* class: Flash_driver_file */
#endif
#endif /* define: flash_driver_file_h */ | [
"ernest.szczepaniak.en2@gmail.com"
] | ernest.szczepaniak.en2@gmail.com |
7edda5b1cb7640c2d6f3ab7fcff481dbb071ce03 | fe5078b6932ff199c1cb8c18d7a4b63564daef9e | /JUtility.h | 71a5c159445b1b1f5150f3a2ec59e50f86e9bd72 | [] | no_license | Kajune/Javelin | ee55b500a8d1d65c9739048fafcf2612119de206 | f454ee580fb0187e723d0ee4d383a97d142c6575 | refs/heads/master | 2021-01-17T16:15:47.160594 | 2016-06-13T08:22:26 | 2016-06-13T08:22:26 | 56,835,108 | 0 | 0 | null | 2016-04-26T07:42:41 | 2016-04-22T07:23:13 | C++ | UTF-8 | C++ | false | false | 843 | h | #pragma once
#include "JGlobal.h"
#include <vector>
namespace Javelin {
template<typename T, UINT N>
constexpr UINT array_length(const T(&)[N]) {
return N;
}
template<typename T>
void SAFE_RELEASE(T*& x) {
if (x) {
x->Release();
x = nullptr;
}
}
extern std::string wstr_to_str(const std::wstring& wstr);
extern std::wstring str_to_wstr(const std::string& str);
extern void Split(const std::string& str,
std::vector<std::string>& splitedStr,
const std::string& delim = ",",
bool allowEmptyElement = false);
extern void Split(const std::string& str,
std::vector<std::string>& splitedStr,
char delim = ',', bool allowEmptyElement = false);
template<typename T, typename U>
T ceil_to_multiple(const T& value, const U& multiple) {
return (value + multiple - static_cast<T>(1)) / multiple * multiple;
}
}
| [
"ryuzoji21@gmail.com"
] | ryuzoji21@gmail.com |
2fadd4ec90880c81320ebbf485ff33279f228328 | 6cd93777b68dcd8735a58d93748e6837392bb3f6 | /libsdd/sdd/hom/traits.hh | 10df2dfa91937d3dc9400043ff791320ad069137 | [
"MIT",
"BSD-2-Clause"
] | permissive | kyouko-taiga/SwiftSDD | 8df77a80b9da6ff5cde99fb2eda7449c03c569bf | 9312160e0fac5fef6e605c9e74c543ded9708e54 | refs/heads/master | 2021-01-09T06:11:46.303362 | 2017-02-08T18:18:31 | 2017-02-08T18:18:31 | 80,961,255 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 650 | hh | /// @file
/// @copyright The code is licensed under the BSD License
/// <http://opensource.org/licenses/BSD-2-Clause>,
/// Copyright (c) 2012-2015 Alexandre Hamez.
/// @author Alexandre Hamez
#pragma once
namespace sdd { namespace hom {
/*------------------------------------------------------------------------------------------------*/
/// @internal
/// @brief Default traits for homomorphisms.
template <typename T>
struct homomorphism_traits
{
static constexpr bool should_cache = true;
};
/*------------------------------------------------------------------------------------------------*/
}} // namespace sdd::hom
| [
"dimitri.racordon@gmail.com"
] | dimitri.racordon@gmail.com |
2cf22ee8c03e1ab5e7a7d7aed6eae1f9df50f81c | 2e44884082d0e23c09d431c4fa008b844003fe3a | /sources/src/protocolgame.cpp | 2efe03e517f873531ba56a57c0d0ddcd73934d93 | [] | no_license | otmanager/baiaklking1090 | 4ef28bd87667b28ba264b46868e94322bfc6d8ba | 2b09361cae41569e9149b6e9997775fa39c32079 | refs/heads/master | 2021-01-19T04:48:07.947063 | 2016-09-24T13:26:34 | 2016-09-24T13:26:34 | 69,103,838 | 0 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 67,865 | cpp | /**
* The Forgotten Server - a free and open-source MMORPG server emulator
* Copyright (C) 2015 Mark Samman <mark.samman@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "otpch.h"
#include <boost/range/adaptor/reversed.hpp>
#include "protocolgame.h"
#include "outputmessage.h"
#include "player.h"
#include "configmanager.h"
#include "actions.h"
#include "game.h"
#include "iologindata.h"
#include "iomarket.h"
#include "waitlist.h"
#include "ban.h"
#include "scheduler.h"
#include "databasetasks.h"
extern Game g_game;
extern ConfigManager g_config;
extern Actions actions;
extern CreatureEvents* g_creatureEvents;
extern Chat* g_chat;
ProtocolGame::LiveCastsMap ProtocolGame::liveCasts;
void ProtocolGame::release()
{
//dispatcher thread
stopLiveCast();
if (player && player->client == shared_from_this()) {
player->client.reset();
player->decrementReferenceCounter();
player = nullptr;
}
OutputMessagePool::getInstance().removeProtocolFromAutosend(shared_from_this());
Protocol::release();
}
void ProtocolGame::login(const std::string& name, uint32_t accountId, OperatingSystem_t operatingSystem)
{
//dispatcher thread
Player* _player = g_game.getPlayerByName(name);
if (!_player || g_config.getBoolean(ConfigManager::ALLOW_CLONES)) {
player = new Player(getThis());
player->setName(name);
player->incrementReferenceCounter();
player->setID();
if (!IOLoginData::preloadPlayer(player, name)) {
disconnectClient("Your character could not be loaded.");
return;
}
if (IOBan::isPlayerNamelocked(player->getGUID())) {
disconnectClient("Your character has been namelocked.");
return;
}
if (g_game.getGameState() == GAME_STATE_CLOSING && !player->hasFlag(PlayerFlag_CanAlwaysLogin)) {
disconnectClient("The game is just going down.\nPlease try again later.");
return;
}
if (g_game.getGameState() == GAME_STATE_CLOSED && !player->hasFlag(PlayerFlag_CanAlwaysLogin)) {
disconnectClient("Server is currently closed.\nPlease try again later.");
return;
}
if (g_config.getBoolean(ConfigManager::ONE_PLAYER_ON_ACCOUNT) && player->getAccountType() < ACCOUNT_TYPE_GAMEMASTER && g_game.getPlayerByAccount(player->getAccount())) {
disconnectClient("You may only login with one character\nof your account at the same time.");
return;
}
if (!player->hasFlag(PlayerFlag_CannotBeBanned)) {
BanInfo banInfo;
if (IOBan::isAccountBanned(accountId, banInfo)) {
if (banInfo.reason.empty()) {
banInfo.reason = "(none)";
}
std::ostringstream ss;
if (banInfo.expiresAt > 0) {
ss << "Your account has been banned until " << formatDateShort(banInfo.expiresAt) << " by " << banInfo.bannedBy << ".\n\nReason specified:\n" << banInfo.reason;
}
else {
ss << "Your account has been permanently banned by " << banInfo.bannedBy << ".\n\nReason specified:\n" << banInfo.reason;
}
disconnectClient(ss.str());
return;
}
}
if (!WaitingList::getInstance()->clientLogin(player)) {
uint32_t currentSlot = WaitingList::getInstance()->getClientSlot(player);
uint32_t retryTime = WaitingList::getTime(currentSlot);
std::ostringstream ss;
ss << "Too many players online.\nYou are at place "
<< currentSlot << " on the waiting list.";
auto output = OutputMessagePool::getOutputMessage();
output->addByte(0x16);
output->addString(ss.str());
output->addByte(retryTime);
send(output);
disconnect();
return;
}
if (!IOLoginData::loadPlayerByName(player, name)) {
disconnectClient("Your character could not be loaded.");
return;
}
player->setOperatingSystem(operatingSystem);
if (!g_game.placeCreature(player, player->getLoginPosition())) {
if (!g_game.placeCreature(player, player->getTemplePosition(), false, true)) {
disconnectClient("Temple position is wrong. Contact the administrator.");
return;
}
}
if (operatingSystem >= CLIENTOS_OTCLIENT_LINUX) {
player->registerCreatureEvent("ExtendedOpcode");
}
player->lastIP = player->getIP();
player->lastLoginSaved = std::max<time_t>(time(nullptr), player->lastLoginSaved + 1);
m_acceptPackets = true;
}
else {
if (eventConnect != 0 || !g_config.getBoolean(ConfigManager::REPLACE_KICK_ON_LOGIN)) {
//Already trying to connect
disconnectClient("You are already logged in.");
return;
}
if (_player->client) {
_player->disconnect();
_player->isConnecting = true;
eventConnect = g_scheduler.addEvent(createSchedulerTask(1000, std::bind(&ProtocolGame::connect, getThis(), _player->getID(), operatingSystem)));
}
else {
connect(_player->getID(), operatingSystem);
}
}
OutputMessagePool::getInstance().addProtocolToAutosend(shared_from_this());
}
void ProtocolGame::connect(uint32_t playerId, OperatingSystem_t operatingSystem)
{
eventConnect = 0;
Player* _player = g_game.getPlayerByID(playerId);
if (!_player || _player->client) {
disconnectClient("You are already logged in.");
return;
}
if (isConnectionExpired()) {
//ProtocolGame::release() has been called at this point and the Connection object
//no longer exists, so we return to prevent leakage of the Player.
return;
}
player = _player;
player->incrementReferenceCounter();
g_chat->removeUserFromAllChannels(*player);
player->clearModalWindows();
player->setOperatingSystem(operatingSystem);
player->isConnecting = false;
player->client = getThis();
sendAddCreature(player, player->getPosition(), 0, false);
player->lastIP = player->getIP();
player->lastLoginSaved = std::max<time_t>(time(nullptr), player->lastLoginSaved + 1);
m_acceptPackets = true;
}
void ProtocolGame::logout(bool displayEffect, bool forced)
{
//dispatcher thread
if (!player) {
return;
}
if (!player->isRemoved()) {
if (!forced) {
if (!player->isAccessPlayer()) {
if (player->getTile()->hasFlag(TILESTATE_NOLOGOUT)) {
player->sendCancelMessage(RETURNVALUE_YOUCANNOTLOGOUTHERE);
return;
}
if (!player->getTile()->hasFlag(TILESTATE_PROTECTIONZONE) && player->hasCondition(CONDITION_INFIGHT)) {
player->sendCancelMessage(RETURNVALUE_YOUMAYNOTLOGOUTDURINGAFIGHT);
return;
}
}
//scripting event - onLogout
if (!g_creatureEvents->playerLogout(player)) {
//Let the script handle the error message
return;
}
}
if (displayEffect && player->getHealth() > 0) {
g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
}
}
stopLiveCast();
disconnect();
g_game.removeCreature(player);
}
bool ProtocolGame::startLiveCast(const std::string& password /*= ""*/)
{
auto connection = getConnection();
if (!g_config.getBoolean(ConfigManager::ENABLE_LIVE_CASTING) || isLiveCaster() || !player || player->isRemoved() || !connection || liveCasts.size() >= getMaxLiveCastCount()) {
return false;
}
{
std::lock_guard<decltype(liveCastLock)> lock{ liveCastLock };
//DO NOT do any send operations here
liveCastName = player->getName();
liveCastPassword = password;
isCaster.store(true, std::memory_order_relaxed);
}
liveCasts.insert(std::make_pair(player, getThis()));
registerLiveCast();
//Send a "dummy" channel
sendChannel(CHANNEL_CAST, LIVE_CAST_CHAT_NAME, nullptr, nullptr);
return true;
}
bool ProtocolGame::stopLiveCast()
{
//dispatcher
if (!isLiveCaster()) {
return false;
}
CastSpectatorVec spectators;
{
std::lock_guard<decltype(liveCastLock)> lock{ liveCastLock };
//DO NOT do any send operations here
std::swap(this->spectators, spectators);
isCaster.store(false, std::memory_order_relaxed);
}
liveCasts.erase(player);
for (auto& spectator : spectators) {
spectator->onLiveCastStop();
}
unregisterLiveCast();
return true;
}
void ProtocolGame::clearLiveCastInfo()
{
static std::once_flag flag;
std::call_once(flag, []() {
assert(g_game.getGameState() == GAME_STATE_INIT);
std::ostringstream query;
query << "TRUNCATE TABLE `live_casts`;";
g_databaseTasks.addTask(query.str());
});
}
void ProtocolGame::registerLiveCast()
{
std::ostringstream query;
query << "INSERT into `live_casts` (`player_id`, `cast_name`, `password`) VALUES (" << player->getGUID() << ", '"
<< getLiveCastName() << "', " << isPasswordProtected() << ");";
g_databaseTasks.addTask(query.str());
}
void ProtocolGame::unregisterLiveCast()
{
std::ostringstream query;
query << "DELETE FROM `live_casts` WHERE `player_id`=" << player->getGUID() << ";";
g_databaseTasks.addTask(query.str());
}
void ProtocolGame::updateLiveCastInfo()
{
std::ostringstream query;
query << "UPDATE `live_casts` SET `cast_name`='" << getLiveCastName() << "', `password`="
<< isPasswordProtected() << ", `spectators`=" << getSpectatorCount()
<< " WHERE `player_id`=" << player->getGUID() << ";";
g_databaseTasks.addTask(query.str());
}
void ProtocolGame::addSpectator(ProtocolSpectator_ptr spectatorClient)
{
std::lock_guard<decltype(liveCastLock)> lock(liveCastLock);
//DO NOT do any send operations here
spectators.emplace_back(spectatorClient);
updateLiveCastInfo();
}
void ProtocolGame::removeSpectator(ProtocolSpectator_ptr spectatorClient)
{
std::lock_guard<decltype(liveCastLock)> lock(liveCastLock);
//DO NOT do any send operations here
auto it = std::find(spectators.begin(), spectators.end(), spectatorClient);
if (it != spectators.end()) {
spectators.erase(it);
updateLiveCastInfo();
}
}
void ProtocolGame::onRecvFirstMessage(NetworkMessage& msg)
{
if (g_game.getGameState() == GAME_STATE_SHUTDOWN) {
disconnect();
return;
}
OperatingSystem_t operatingSystem = static_cast<OperatingSystem_t>(msg.get<uint16_t>());
version = msg.get<uint16_t>();
msg.skipBytes(7); // U32 client version, U8 client type, U16 dat revision
if (!Protocol::RSA_decrypt(msg)) {
disconnect();
return;
}
uint32_t key[4];
key[0] = msg.get<uint32_t>();
key[1] = msg.get<uint32_t>();
key[2] = msg.get<uint32_t>();
key[3] = msg.get<uint32_t>();
enableXTEAEncryption();
setXTEAKey(key);
if (operatingSystem >= CLIENTOS_OTCLIENT_LINUX) {
NetworkMessage opcodeMessage;
opcodeMessage.addByte(0x32);
opcodeMessage.addByte(0x00);
opcodeMessage.add<uint16_t>(0x00);
writeToOutputBuffer(opcodeMessage);
}
msg.skipBytes(1); // gamemaster flag
std::string sessionKey = msg.getString();
size_t pos = sessionKey.find('\n');
if (pos == std::string::npos) {
disconnectClient("You must enter your account name.");
return;
}
std::string accountName = sessionKey.substr(0, pos);
if (accountName.empty()) {
disconnectClient("You must enter your account name.");
return;
}
std::string password = sessionKey.substr(pos + 1);
std::string characterName = msg.getString();
uint32_t timeStamp = msg.get<uint32_t>();
uint8_t randNumber = msg.getByte();
if (m_challengeTimestamp != timeStamp || m_challengeRandom != randNumber) {
disconnect();
return;
}
if (version < CLIENT_VERSION_MIN || version > CLIENT_VERSION_MAX) {
disconnectClient("Only clients with protocol " CLIENT_VERSION_STR " allowed!");
return;
}
if (g_game.getGameState() == GAME_STATE_STARTUP) {
disconnectClient("Gameworld is starting up. Please wait.");
return;
}
if (g_game.getGameState() == GAME_STATE_MAINTAIN) {
disconnectClient("Gameworld is under maintenance. Please re-connect in a while.");
return;
}
BanInfo banInfo;
if (IOBan::isIpBanned(getIP(), banInfo)) {
if (banInfo.reason.empty()) {
banInfo.reason = "(none)";
}
std::ostringstream ss;
ss << "Your IP has been banned until " << formatDateShort(banInfo.expiresAt) << " by " << banInfo.bannedBy << ".\n\nReason specified:\n" << banInfo.reason;
disconnectClient(ss.str());
return;
}
uint32_t accountId = IOLoginData::gameworldAuthentication(accountName, password, characterName);
if (accountId == 0) {
disconnectClient("Account name or password is not correct.");
return;
}
g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::login, getThis(), characterName, accountId, operatingSystem)));
}
void ProtocolGame::disconnectClient(const std::string& message) const
{
auto output = OutputMessagePool::getOutputMessage();
output->addByte(0x14);
output->addString(message);
send(output);
disconnect();
}
void ProtocolGame::writeToOutputBuffer(const NetworkMessage& msg, bool broadcast /*= true*/)
{
if (!broadcast && isLiveCaster()) {
//We're casting and we need to send a packet that's not supposed to be broadcast so we need a new messasge.
//This shouldn't impact performance by a huge amount as most packets can be broadcast.
auto out = OutputMessagePool::getOutputMessage();
out->append(msg);
send(std::move(out));
}
else {
auto out = getOutputBuffer(msg.getLength());
if (isLiveCaster()) {
out->setBroadcastMsg(true);
}
out->append(msg);
}
}
void ProtocolGame::parsePacket(NetworkMessage& msg)
{
if (!m_acceptPackets || g_game.getGameState() == GAME_STATE_SHUTDOWN || msg.getLength() <= 0) {
return;
}
uint8_t recvbyte = msg.getByte();
//a dead player can not perform actions
if (!player || player->isRemoved() || player->getHealth() <= 0) {
auto this_ptr = getThis();
g_dispatcher.addTask(createTask([this_ptr]() {
this_ptr->stopLiveCast();
}));
if (recvbyte == 0x0F) {
disconnect();
return;
}
if (recvbyte != 0x14) {
return;
}
}
switch (recvbyte) {
case 0x14: g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::logout, getThis(), true, false))); break;
case 0x1D: addGameTask(&Game::playerReceivePingBack, player->getID()); break;
case 0x1E: addGameTask(&Game::playerReceivePing, player->getID()); break;
case 0x32: parseExtendedOpcode(msg); break; //otclient extended opcode
case 0x64: parseAutoWalk(msg); break;
case 0x65: addGameTask(&Game::playerMove, player->getID(), DIRECTION_NORTH); break;
case 0x66: addGameTask(&Game::playerMove, player->getID(), DIRECTION_EAST); break;
case 0x67: addGameTask(&Game::playerMove, player->getID(), DIRECTION_SOUTH); break;
case 0x68: addGameTask(&Game::playerMove, player->getID(), DIRECTION_WEST); break;
case 0x69: addGameTask(&Game::playerStopAutoWalk, player->getID()); break;
case 0x6A: addGameTask(&Game::playerMove, player->getID(), DIRECTION_NORTHEAST); break;
case 0x6B: addGameTask(&Game::playerMove, player->getID(), DIRECTION_SOUTHEAST); break;
case 0x6C: addGameTask(&Game::playerMove, player->getID(), DIRECTION_SOUTHWEST); break;
case 0x6D: addGameTask(&Game::playerMove, player->getID(), DIRECTION_NORTHWEST); break;
case 0x6F: addGameTaskTimed(DISPATCHER_TASK_EXPIRATION, &Game::playerTurn, player->getID(), DIRECTION_NORTH); break;
case 0x70: addGameTaskTimed(DISPATCHER_TASK_EXPIRATION, &Game::playerTurn, player->getID(), DIRECTION_EAST); break;
case 0x71: addGameTaskTimed(DISPATCHER_TASK_EXPIRATION, &Game::playerTurn, player->getID(), DIRECTION_SOUTH); break;
case 0x72: addGameTaskTimed(DISPATCHER_TASK_EXPIRATION, &Game::playerTurn, player->getID(), DIRECTION_WEST); break;
case 0x78: parseThrow(msg); break;
case 0x79: parseLookInShop(msg); break;
case 0x7A: parsePlayerPurchase(msg); break;
case 0x7B: parsePlayerSale(msg); break;
case 0x7C: addGameTask(&Game::playerCloseShop, player->getID()); break;
case 0x7D: parseRequestTrade(msg); break;
case 0x7E: parseLookInTrade(msg); break;
case 0x7F: addGameTask(&Game::playerAcceptTrade, player->getID()); break;
case 0x80: addGameTask(&Game::playerCloseTrade, player->getID()); break;
case 0x82: parseUseItem(msg); break;
case 0x83: parseUseItemEx(msg); break;
case 0x84: parseUseWithCreature(msg); break;
case 0x85: parseRotateItem(msg); break;
case 0x87: parseCloseContainer(msg); break;
case 0x88: parseUpArrowContainer(msg); break;
case 0x89: parseTextWindow(msg); break;
case 0x8A: parseHouseWindow(msg); break;
case 0x8C: parseLookAt(msg); break;
case 0x8D: parseLookInBattleList(msg); break;
case 0x8E: /* join aggression */ break;
case 0x96: parseSay(msg); break;
case 0x97: addGameTask(&Game::playerRequestChannels, player->getID()); break;
case 0x98: parseOpenChannel(msg); break;
case 0x99: parseCloseChannel(msg); break;
case 0x9A: parseOpenPrivateChannel(msg); break;
case 0x9E: addGameTask(&Game::playerCloseNpcChannel, player->getID()); break;
case 0xA0: parseFightModes(msg); break;
case 0xA1: parseAttack(msg); break;
case 0xA2: parseFollow(msg); break;
case 0xA3: parseInviteToParty(msg); break;
case 0xA4: parseJoinParty(msg); break;
case 0xA5: parseRevokePartyInvite(msg); break;
case 0xA6: parsePassPartyLeadership(msg); break;
case 0xA7: addGameTask(&Game::playerLeaveParty, player->getID()); break;
case 0xA8: parseEnableSharedPartyExperience(msg); break;
case 0xAA: addGameTask(&Game::playerCreatePrivateChannel, player->getID()); break;
case 0xAB: parseChannelInvite(msg); break;
case 0xAC: parseChannelExclude(msg); break;
case 0xBE: addGameTask(&Game::playerCancelAttackAndFollow, player->getID()); break;
case 0xC9: /* update tile */ break;
case 0xCA: parseUpdateContainer(msg); break;
case 0xCB: parseBrowseField(msg); break;
case 0xCC: parseSeekInContainer(msg); break;
case 0xD2: addGameTask(&Game::playerRequestOutfit, player->getID()); break;
case 0xD3: parseSetOutfit(msg); break;
case 0xD4: parseToggleMount(msg); break;
case 0xDC: parseAddVip(msg); break;
case 0xDD: parseRemoveVip(msg); break;
case 0xDE: parseEditVip(msg); break;
case 0xE6: parseBugReport(msg); break;
case 0xE7: /* thank you */ break;
case 0xE8: parseDebugAssert(msg); break;
case 0xF0: addGameTaskTimed(DISPATCHER_TASK_EXPIRATION, &Game::playerShowQuestLog, player->getID()); break;
case 0xF1: parseQuestLine(msg); break;
case 0xF2: /* rule violation report */ break;
case 0xF3: /* get object info */ break;
case 0xF4: parseMarketLeave(); break;
case 0xF5: parseMarketBrowse(msg); break;
case 0xF6: parseMarketCreateOffer(msg); break;
case 0xF7: parseMarketCancelOffer(msg); break;
case 0xF8: parseMarketAcceptOffer(msg); break;
case 0xF9: parseModalWindowAnswer(msg); break;
default:
// std::cout << "Player: " << player->getName() << " sent an unknown packet header: 0x" << std::hex << static_cast<uint16_t>(recvbyte) << std::dec << "!" << std::endl;
break;
}
if (msg.isOverrun()) {
disconnect();
}
}
// Parse methods
void ProtocolGame::parseChannelInvite(NetworkMessage& msg)
{
const std::string name = msg.getString();
addGameTask(&Game::playerChannelInvite, player->getID(), name);
}
void ProtocolGame::parseChannelExclude(NetworkMessage& msg)
{
const std::string name = msg.getString();
addGameTask(&Game::playerChannelExclude, player->getID(), name);
}
void ProtocolGame::parseOpenChannel(NetworkMessage& msg)
{
uint16_t channelId = msg.get<uint16_t>();
addGameTask(&Game::playerOpenChannel, player->getID(), channelId);
}
void ProtocolGame::parseCloseChannel(NetworkMessage& msg)
{
uint16_t channelId = msg.get<uint16_t>();
addGameTask(&Game::playerCloseChannel, player->getID(), channelId);
}
void ProtocolGame::parseOpenPrivateChannel(NetworkMessage& msg)
{
const std::string receiver = msg.getString();
addGameTask(&Game::playerOpenPrivateChannel, player->getID(), receiver);
}
void ProtocolGame::parseAutoWalk(NetworkMessage& msg)
{
uint8_t numdirs = msg.getByte();
if (numdirs == 0 || (msg.getBufferPosition() + numdirs) != (msg.getLength() + 8)) {
return;
}
msg.skipBytes(numdirs);
std::forward_list<Direction> path;
for (uint8_t i = 0; i < numdirs; ++i) {
uint8_t rawdir = msg.getPreviousByte();
switch (rawdir) {
case 1: path.push_front(DIRECTION_EAST); break;
case 2: path.push_front(DIRECTION_NORTHEAST); break;
case 3: path.push_front(DIRECTION_NORTH); break;
case 4: path.push_front(DIRECTION_NORTHWEST); break;
case 5: path.push_front(DIRECTION_WEST); break;
case 6: path.push_front(DIRECTION_SOUTHWEST); break;
case 7: path.push_front(DIRECTION_SOUTH); break;
case 8: path.push_front(DIRECTION_SOUTHEAST); break;
default: break;
}
}
if (path.empty()) {
return;
}
addGameTask(&Game::playerAutoWalk, player->getID(), path);
}
void ProtocolGame::parseSetOutfit(NetworkMessage& msg)
{
Outfit_t newOutfit;
newOutfit.lookType = msg.get<uint16_t>();
newOutfit.lookHead = msg.getByte();
newOutfit.lookBody = msg.getByte();
newOutfit.lookLegs = msg.getByte();
newOutfit.lookFeet = msg.getByte();
newOutfit.lookAddons = msg.getByte();
newOutfit.lookMount = msg.get<uint16_t>();
addGameTask(&Game::playerChangeOutfit, player->getID(), newOutfit);
}
void ProtocolGame::parseToggleMount(NetworkMessage& msg)
{
bool mount = msg.getByte() != 0;
addGameTask(&Game::playerToggleMount, player->getID(), mount);
}
void ProtocolGame::parseUseItem(NetworkMessage& msg)
{
Position pos = msg.getPosition();
uint16_t spriteId = msg.get<uint16_t>();
uint8_t stackpos = msg.getByte();
uint8_t index = msg.getByte();
addGameTaskTimed(DISPATCHER_TASK_EXPIRATION, &Game::playerUseItem, player->getID(), pos, stackpos, index, spriteId);
}
void ProtocolGame::parseUseItemEx(NetworkMessage& msg)
{
Position fromPos = msg.getPosition();
uint16_t fromSpriteId = msg.get<uint16_t>();
uint8_t fromStackPos = msg.getByte();
Position toPos = msg.getPosition();
uint16_t toSpriteId = msg.get<uint16_t>();
uint8_t toStackPos = msg.getByte();
addGameTaskTimed(DISPATCHER_TASK_EXPIRATION, &Game::playerUseItemEx, player->getID(), fromPos, fromStackPos, fromSpriteId, toPos, toStackPos, toSpriteId);
}
void ProtocolGame::parseUseWithCreature(NetworkMessage& msg)
{
Position fromPos = msg.getPosition();
uint16_t spriteId = msg.get<uint16_t>();
uint8_t fromStackPos = msg.getByte();
uint32_t creatureId = msg.get<uint32_t>();
addGameTaskTimed(DISPATCHER_TASK_EXPIRATION, &Game::playerUseWithCreature, player->getID(), fromPos, fromStackPos, creatureId, spriteId);
}
void ProtocolGame::parseCloseContainer(NetworkMessage& msg)
{
uint8_t cid = msg.getByte();
addGameTask(&Game::playerCloseContainer, player->getID(), cid);
}
void ProtocolGame::parseUpArrowContainer(NetworkMessage& msg)
{
uint8_t cid = msg.getByte();
addGameTask(&Game::playerMoveUpContainer, player->getID(), cid);
}
void ProtocolGame::parseUpdateContainer(NetworkMessage& msg)
{
uint8_t cid = msg.getByte();
addGameTask(&Game::playerUpdateContainer, player->getID(), cid);
}
void ProtocolGame::parseThrow(NetworkMessage& msg)
{
Position fromPos = msg.getPosition();
uint16_t spriteId = msg.get<uint16_t>();
uint8_t fromStackpos = msg.getByte();
Position toPos = msg.getPosition();
uint8_t count = msg.getByte();
if (toPos != fromPos) {
addGameTaskTimed(DISPATCHER_TASK_EXPIRATION, &Game::playerMoveThing, player->getID(), fromPos, spriteId, fromStackpos, toPos, count);
}
}
void ProtocolGame::parseLookAt(NetworkMessage& msg)
{
Position pos = msg.getPosition();
msg.skipBytes(2); // spriteId
uint8_t stackpos = msg.getByte();
addGameTaskTimed(DISPATCHER_TASK_EXPIRATION, &Game::playerLookAt, player->getID(), pos, stackpos);
}
void ProtocolGame::parseLookInBattleList(NetworkMessage& msg)
{
uint32_t creatureId = msg.get<uint32_t>();
addGameTaskTimed(DISPATCHER_TASK_EXPIRATION, &Game::playerLookInBattleList, player->getID(), creatureId);
}
void ProtocolGame::parseSay(NetworkMessage& msg)
{
std::string receiver;
uint16_t channelId;
SpeakClasses type = static_cast<SpeakClasses>(msg.getByte());
switch (type) {
case TALKTYPE_PRIVATE_TO:
case TALKTYPE_PRIVATE_RED_TO:
receiver = msg.getString();
channelId = 0;
break;
case TALKTYPE_CHANNEL_Y:
case TALKTYPE_CHANNEL_R1:
channelId = msg.get<uint16_t>();
break;
default:
channelId = 0;
break;
}
const std::string text = msg.getString();
if (text.length() > 255) {
return;
}
addGameTask(&Game::playerSay, player->getID(), channelId, type, receiver, text);
}
void ProtocolGame::parseFightModes(NetworkMessage& msg)
{
uint8_t rawFightMode = msg.getByte(); // 1 - offensive, 2 - balanced, 3 - defensive
uint8_t rawChaseMode = msg.getByte(); // 0 - stand while fightning, 1 - chase opponent
uint8_t rawSecureMode = msg.getByte(); // 0 - can't attack unmarked, 1 - can attack unmarked
// uint8_t rawPvpMode = msg.getByte(); // pvp mode introduced in 10.0
chaseMode_t chaseMode;
if (rawChaseMode == 1) {
chaseMode = CHASEMODE_FOLLOW;
}
else {
chaseMode = CHASEMODE_STANDSTILL;
}
fightMode_t fightMode;
if (rawFightMode == 1) {
fightMode = FIGHTMODE_ATTACK;
}
else if (rawFightMode == 2) {
fightMode = FIGHTMODE_BALANCED;
}
else {
fightMode = FIGHTMODE_DEFENSE;
}
addGameTask(&Game::playerSetFightModes, player->getID(), fightMode, chaseMode, rawSecureMode != 0);
}
void ProtocolGame::parseAttack(NetworkMessage& msg)
{
uint32_t creatureId = msg.get<uint32_t>();
// msg.get<uint32_t>(); creatureId (same as above)
addGameTask(&Game::playerSetAttackedCreature, player->getID(), creatureId);
}
void ProtocolGame::parseFollow(NetworkMessage& msg)
{
uint32_t creatureId = msg.get<uint32_t>();
// msg.get<uint32_t>(); creatureId (same as above)
addGameTask(&Game::playerFollowCreature, player->getID(), creatureId);
}
void ProtocolGame::parseTextWindow(NetworkMessage& msg)
{
uint32_t windowTextId = msg.get<uint32_t>();
const std::string newText = msg.getString();
addGameTask(&Game::playerWriteItem, player->getID(), windowTextId, newText);
}
void ProtocolGame::parseHouseWindow(NetworkMessage& msg)
{
uint8_t doorId = msg.getByte();
uint32_t id = msg.get<uint32_t>();
const std::string text = msg.getString();
addGameTask(&Game::playerUpdateHouseWindow, player->getID(), doorId, id, text);
}
void ProtocolGame::parseLookInShop(NetworkMessage& msg)
{
uint16_t id = msg.get<uint16_t>();
uint8_t count = msg.getByte();
addGameTaskTimed(DISPATCHER_TASK_EXPIRATION, &Game::playerLookInShop, player->getID(), id, count);
}
void ProtocolGame::parsePlayerPurchase(NetworkMessage& msg)
{
uint16_t id = msg.get<uint16_t>();
uint8_t count = msg.getByte();
uint8_t amount = msg.getByte();
bool ignoreCap = msg.getByte() != 0;
bool inBackpacks = msg.getByte() != 0;
addGameTaskTimed(DISPATCHER_TASK_EXPIRATION, &Game::playerPurchaseItem, player->getID(), id, count, amount, ignoreCap, inBackpacks);
}
void ProtocolGame::parsePlayerSale(NetworkMessage& msg)
{
uint16_t id = msg.get<uint16_t>();
uint8_t count = msg.getByte();
uint8_t amount = msg.getByte();
bool ignoreEquipped = msg.getByte() != 0;
addGameTaskTimed(DISPATCHER_TASK_EXPIRATION, &Game::playerSellItem, player->getID(), id, count, amount, ignoreEquipped);
}
void ProtocolGame::parseRequestTrade(NetworkMessage& msg)
{
Position pos = msg.getPosition();
uint16_t spriteId = msg.get<uint16_t>();
uint8_t stackpos = msg.getByte();
uint32_t playerId = msg.get<uint32_t>();
addGameTask(&Game::playerRequestTrade, player->getID(), pos, stackpos, playerId, spriteId);
}
void ProtocolGame::parseLookInTrade(NetworkMessage& msg)
{
bool counterOffer = (msg.getByte() == 0x01);
uint8_t index = msg.getByte();
addGameTaskTimed(DISPATCHER_TASK_EXPIRATION, &Game::playerLookInTrade, player->getID(), counterOffer, index);
}
void ProtocolGame::parseAddVip(NetworkMessage& msg)
{
const std::string name = msg.getString();
addGameTask(&Game::playerRequestAddVip, player->getID(), name);
}
void ProtocolGame::parseRemoveVip(NetworkMessage& msg)
{
uint32_t guid = msg.get<uint32_t>();
addGameTask(&Game::playerRequestRemoveVip, player->getID(), guid);
}
void ProtocolGame::parseEditVip(NetworkMessage& msg)
{
uint32_t guid = msg.get<uint32_t>();
const std::string description = msg.getString();
uint32_t icon = std::min<uint32_t>(10, msg.get<uint32_t>()); // 10 is max icon in 9.63
bool notify = msg.getByte() != 0;
addGameTask(&Game::playerRequestEditVip, player->getID(), guid, description, icon, notify);
}
void ProtocolGame::parseRotateItem(NetworkMessage& msg)
{
Position pos = msg.getPosition();
uint16_t spriteId = msg.get<uint16_t>();
uint8_t stackpos = msg.getByte();
addGameTaskTimed(DISPATCHER_TASK_EXPIRATION, &Game::playerRotateItem, player->getID(), pos, stackpos, spriteId);
}
void ProtocolGame::parseBugReport(NetworkMessage& msg)
{
uint8_t category = msg.getByte();
std::string message = msg.getString();
Position position;
if (category == BUG_CATEGORY_MAP) {
position = msg.getPosition();
}
addGameTask(&Game::playerReportBug, player->getID(), message, position, category);
}
void ProtocolGame::parseDebugAssert(NetworkMessage& msg)
{
if (m_debugAssertSent) {
return;
}
m_debugAssertSent = true;
std::string assertLine = msg.getString();
std::string date = msg.getString();
std::string description = msg.getString();
std::string comment = msg.getString();
addGameTask(&Game::playerDebugAssert, player->getID(), assertLine, date, description, comment);
}
void ProtocolGame::parseInviteToParty(NetworkMessage& msg)
{
uint32_t targetId = msg.get<uint32_t>();
addGameTask(&Game::playerInviteToParty, player->getID(), targetId);
}
void ProtocolGame::parseJoinParty(NetworkMessage& msg)
{
uint32_t targetId = msg.get<uint32_t>();
addGameTask(&Game::playerJoinParty, player->getID(), targetId);
}
void ProtocolGame::parseRevokePartyInvite(NetworkMessage& msg)
{
uint32_t targetId = msg.get<uint32_t>();
addGameTask(&Game::playerRevokePartyInvitation, player->getID(), targetId);
}
void ProtocolGame::parsePassPartyLeadership(NetworkMessage& msg)
{
uint32_t targetId = msg.get<uint32_t>();
addGameTask(&Game::playerPassPartyLeadership, player->getID(), targetId);
}
void ProtocolGame::parseEnableSharedPartyExperience(NetworkMessage& msg)
{
bool sharedExpActive = msg.getByte() == 1;
addGameTask(&Game::playerEnableSharedPartyExperience, player->getID(), sharedExpActive);
}
void ProtocolGame::parseQuestLine(NetworkMessage& msg)
{
uint16_t questId = msg.get<uint16_t>();
addGameTask(&Game::playerShowQuestLine, player->getID(), questId);
}
void ProtocolGame::parseMarketLeave()
{
addGameTask(&Game::playerLeaveMarket, player->getID());
}
void ProtocolGame::parseMarketBrowse(NetworkMessage& msg)
{
uint16_t browseId = msg.get<uint16_t>();
if (browseId == MARKETREQUEST_OWN_OFFERS) {
addGameTask(&Game::playerBrowseMarketOwnOffers, player->getID());
}
else if (browseId == MARKETREQUEST_OWN_HISTORY) {
addGameTask(&Game::playerBrowseMarketOwnHistory, player->getID());
}
else {
addGameTask(&Game::playerBrowseMarket, player->getID(), browseId);
}
}
void ProtocolGame::parseMarketCreateOffer(NetworkMessage& msg)
{
uint8_t type = msg.getByte();
uint16_t spriteId = msg.get<uint16_t>();
uint16_t amount = msg.get<uint16_t>();
uint32_t price = msg.get<uint32_t>();
bool anonymous = (msg.getByte() != 0);
addGameTask(&Game::playerCreateMarketOffer, player->getID(), type, spriteId, amount, price, anonymous);
}
void ProtocolGame::parseMarketCancelOffer(NetworkMessage& msg)
{
uint32_t timestamp = msg.get<uint32_t>();
uint16_t counter = msg.get<uint16_t>();
addGameTask(&Game::playerCancelMarketOffer, player->getID(), timestamp, counter);
}
void ProtocolGame::parseMarketAcceptOffer(NetworkMessage& msg)
{
uint32_t timestamp = msg.get<uint32_t>();
uint16_t counter = msg.get<uint16_t>();
uint16_t amount = msg.get<uint16_t>();
addGameTask(&Game::playerAcceptMarketOffer, player->getID(), timestamp, counter, amount);
}
void ProtocolGame::parseModalWindowAnswer(NetworkMessage& msg)
{
uint32_t id = msg.get<uint32_t>();
uint8_t button = msg.getByte();
uint8_t choice = msg.getByte();
addGameTask(&Game::playerAnswerModalWindow, player->getID(), id, button, choice);
}
void ProtocolGame::parseBrowseField(NetworkMessage& msg)
{
const Position& pos = msg.getPosition();
addGameTask(&Game::playerBrowseField, player->getID(), pos);
}
void ProtocolGame::parseSeekInContainer(NetworkMessage& msg)
{
uint8_t containerId = msg.getByte();
uint16_t index = msg.get<uint16_t>();
addGameTask(&Game::playerSeekInContainer, player->getID(), containerId, index);
}
// Send methods
void ProtocolGame::sendOpenPrivateChannel(const std::string& receiver)
{
NetworkMessage msg;
msg.addByte(0xAD);
msg.addString(receiver);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendChannelEvent(uint16_t channelId, const std::string& playerName, ChannelEvent_t channelEvent)
{
NetworkMessage msg;
msg.addByte(0xF3);
msg.add<uint16_t>(channelId);
msg.addString(playerName);
msg.addByte(channelEvent);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendCreatureOutfit(const Creature* creature, const Outfit_t& outfit)
{
if (!canSee(creature)) {
return;
}
NetworkMessage msg;
msg.addByte(0x8E);
msg.add<uint32_t>(creature->getID());
AddOutfit(msg, outfit);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendCreatureWalkthrough(const Creature* creature, bool walkthrough)
{
if (!canSee(creature)) {
return;
}
NetworkMessage msg;
msg.addByte(0x92);
msg.add<uint32_t>(creature->getID());
msg.addByte(walkthrough ? 0x00 : 0x01);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendCreatureShield(const Creature* creature)
{
if (!canSee(creature)) {
return;
}
NetworkMessage msg;
msg.addByte(0x91);
msg.add<uint32_t>(creature->getID());
msg.addByte(player->getPartyShield(creature->getPlayer()));
writeToOutputBuffer(msg);
}
void ProtocolGame::sendCreatureSkull(const Creature* creature)
{
if (g_game.getWorldType() != WORLD_TYPE_PVP) {
return;
}
if (!canSee(creature)) {
return;
}
NetworkMessage msg;
msg.addByte(0x90);
msg.add<uint32_t>(creature->getID());
msg.addByte(player->getSkullClient(creature));
writeToOutputBuffer(msg);
}
void ProtocolGame::sendCreatureType(uint32_t creatureId, uint8_t creatureType)
{
NetworkMessage msg;
msg.addByte(0x95);
msg.add<uint32_t>(creatureId);
msg.addByte(creatureType);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendCreatureHelpers(uint32_t creatureId, uint16_t helpers)
{
NetworkMessage msg;
msg.addByte(0x94);
msg.add<uint32_t>(creatureId);
msg.add<uint16_t>(helpers);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendCreatureSquare(const Creature* creature, SquareColor_t color)
{
if (!canSee(creature)) {
return;
}
NetworkMessage msg;
msg.addByte(0x93);
msg.add<uint32_t>(creature->getID());
msg.addByte(0x01);
msg.addByte(color);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendTutorial(uint8_t tutorialId)
{
NetworkMessage msg;
msg.addByte(0xDC);
msg.addByte(tutorialId);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendAddMarker(const Position& pos, uint8_t markType, const std::string& desc)
{
NetworkMessage msg;
msg.addByte(0xDD);
msg.addPosition(pos);
msg.addByte(markType);
msg.addString(desc);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendReLoginWindow(uint8_t unfairFightReduction)
{
NetworkMessage msg;
msg.addByte(0x28);
msg.addByte(0x00);
msg.addByte(unfairFightReduction);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendTextMessage(const TextMessage& message)
{
NetworkMessage msg;
msg.addByte(0xB4);
msg.addByte(message.type);
switch (message.type) {
case MESSAGE_DAMAGE_DEALT:
case MESSAGE_DAMAGE_RECEIVED:
case MESSAGE_DAMAGE_OTHERS: {
msg.addPosition(message.position);
msg.add<uint32_t>(message.primary.value);
msg.addByte(message.primary.color);
msg.add<uint32_t>(message.secondary.value);
msg.addByte(message.secondary.color);
break;
}
case MESSAGE_HEALED:
case MESSAGE_HEALED_OTHERS:
case MESSAGE_EXPERIENCE:
case MESSAGE_EXPERIENCE_OTHERS: {
msg.addPosition(message.position);
msg.add<uint32_t>(message.primary.value);
msg.addByte(message.primary.color);
break;
}
default: {
break;
}
}
msg.addString(message.text);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendClosePrivate(uint16_t channelId)
{
NetworkMessage msg;
msg.addByte(0xB3);
msg.add<uint16_t>(channelId);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendCreatePrivateChannel(uint16_t channelId, const std::string& channelName)
{
NetworkMessage msg;
msg.addByte(0xB2);
msg.add<uint16_t>(channelId);
msg.addString(channelName);
msg.add<uint16_t>(0x01);
msg.addString(player->getName());
msg.add<uint16_t>(0x00);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendChannelsDialog()
{
NetworkMessage msg;
msg.addByte(0xAB);
const ChannelList& list = g_chat->getChannelList(*player);
msg.addByte(list.size());
for (ChatChannel* channel : list) {
msg.add<uint16_t>(channel->getId());
msg.addString(channel->getName());
}
writeToOutputBuffer(msg);
}
void ProtocolGame::sendChannelMessage(const std::string& author, const std::string& text, SpeakClasses type, uint16_t channel)
{
NetworkMessage msg;
msg.addByte(0xAA);
msg.add<uint32_t>(0x00);
msg.addString(author);
msg.add<uint16_t>(0x00);
msg.addByte(type);
msg.add<uint16_t>(channel);
msg.addString(text);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendIcons(uint16_t icons)
{
NetworkMessage msg;
msg.addByte(0xA2);
msg.add<uint16_t>(icons);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendShop(Npc* npc, const ShopInfoList& itemList)
{
NetworkMessage msg;
msg.addByte(0x7A);
msg.addString(npc->getName());
uint16_t itemsToSend = std::min<size_t>(itemList.size(), std::numeric_limits<uint16_t>::max());
msg.add<uint16_t>(itemsToSend);
uint16_t i = 0;
for (ShopInfoList::const_iterator it = itemList.begin(); i < itemsToSend; ++it, ++i) {
AddShopItem(msg, *it);
}
writeToOutputBuffer(msg);
}
void ProtocolGame::sendCloseShop()
{
NetworkMessage msg;
msg.addByte(0x7C);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendSaleItemList(const std::list<ShopInfo>& shop)
{
NetworkMessage msg;
msg.addByte(0x7B);
msg.add<uint64_t>(player->getMoney());
std::map<uint16_t, uint32_t> saleMap;
if (shop.size() <= 5) {
// For very small shops it's not worth it to create the complete map
for (const ShopInfo& shopInfo : shop) {
if (shopInfo.sellPrice == 0) {
continue;
}
int8_t subtype = -1;
const ItemType& itemType = Item::items[shopInfo.itemId];
if (itemType.hasSubType() && !itemType.stackable) {
subtype = (shopInfo.subType == 0 ? -1 : shopInfo.subType);
}
uint32_t count = player->getItemTypeCount(shopInfo.itemId, subtype);
if (count > 0) {
saleMap[shopInfo.itemId] = count;
}
}
}
else {
// Large shop, it's better to get a cached map of all item counts and use it
// We need a temporary map since the finished map should only contain items
// available in the shop
std::map<uint32_t, uint32_t> tempSaleMap;
player->getAllItemTypeCount(tempSaleMap);
// We must still check manually for the special items that require subtype matches
// (That is, fluids such as potions etc., actually these items are very few since
// health potions now use their own ID)
for (const ShopInfo& shopInfo : shop) {
if (shopInfo.sellPrice == 0) {
continue;
}
int8_t subtype = -1;
const ItemType& itemType = Item::items[shopInfo.itemId];
if (itemType.hasSubType() && !itemType.stackable) {
subtype = (shopInfo.subType == 0 ? -1 : shopInfo.subType);
}
if (subtype != -1) {
uint32_t count;
if (!itemType.isFluidContainer() && !itemType.isSplash()) {
count = player->getItemTypeCount(shopInfo.itemId, subtype); // This shop item requires extra checks
}
else {
count = subtype;
}
if (count > 0) {
saleMap[shopInfo.itemId] = count;
}
}
else {
std::map<uint32_t, uint32_t>::const_iterator findIt = tempSaleMap.find(shopInfo.itemId);
if (findIt != tempSaleMap.end() && findIt->second > 0) {
saleMap[shopInfo.itemId] = findIt->second;
}
}
}
}
uint8_t itemsToSend = std::min<size_t>(saleMap.size(), std::numeric_limits<uint8_t>::max());
msg.addByte(itemsToSend);
uint8_t i = 0;
for (std::map<uint16_t, uint32_t>::const_iterator it = saleMap.begin(); i < itemsToSend; ++it, ++i) {
msg.addItemId(it->first);
msg.addByte(std::min<uint32_t>(it->second, std::numeric_limits<uint8_t>::max()));
}
writeToOutputBuffer(msg);
}
void ProtocolGame::sendMarketEnter(uint32_t depotId)
{
NetworkMessage msg;
msg.addByte(0xF6);
msg.add<uint64_t>(player->getBankBalance());
msg.addByte(std::min<uint32_t>(IOMarket::getPlayerOfferCount(player->getGUID()), std::numeric_limits<uint8_t>::max()));
DepotChest* depotChest = player->getDepotChest(depotId, false);
if (!depotChest) {
msg.add<uint16_t>(0x00);
writeToOutputBuffer(msg);
return;
}
player->setInMarket(true);
std::map<uint16_t, uint32_t> depotItems;
std::forward_list<Container*> containerList{ depotChest, player->getInbox() };
do {
Container* container = containerList.front();
containerList.pop_front();
for (Item* item : container->getItemList()) {
Container* c = item->getContainer();
if (c && !c->empty()) {
containerList.push_front(c);
continue;
}
const ItemType& itemType = Item::items[item->getID()];
if (itemType.wareId == 0) {
continue;
}
if (c && (!itemType.isContainer() || c->capacity() != itemType.maxItems)) {
continue;
}
if (!item->hasMarketAttributes()) {
continue;
}
depotItems[itemType.wareId] += Item::countByType(item, -1);
}
} while (!containerList.empty());
uint16_t itemsToSend = std::min<size_t>(depotItems.size(), std::numeric_limits<uint16_t>::max());
msg.add<uint16_t>(itemsToSend);
uint16_t i = 0;
for (std::map<uint16_t, uint32_t>::const_iterator it = depotItems.begin(); i < itemsToSend; ++it, ++i) {
msg.add<uint16_t>(it->first);
msg.add<uint16_t>(std::min<uint32_t>(0xFFFF, it->second));
}
writeToOutputBuffer(msg);
}
void ProtocolGame::sendMarketLeave()
{
NetworkMessage msg;
msg.addByte(0xF7);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendMarketBrowseItem(uint16_t itemId, const MarketOfferList& buyOffers, const MarketOfferList& sellOffers)
{
NetworkMessage msg;
msg.addByte(0xF9);
msg.addItemId(itemId);
msg.add<uint32_t>(buyOffers.size());
for (const MarketOffer& offer : buyOffers) {
msg.add<uint32_t>(offer.timestamp);
msg.add<uint16_t>(offer.counter);
msg.add<uint16_t>(offer.amount);
msg.add<uint32_t>(offer.price);
msg.addString(offer.playerName);
}
msg.add<uint32_t>(sellOffers.size());
for (const MarketOffer& offer : sellOffers) {
msg.add<uint32_t>(offer.timestamp);
msg.add<uint16_t>(offer.counter);
msg.add<uint16_t>(offer.amount);
msg.add<uint32_t>(offer.price);
msg.addString(offer.playerName);
}
writeToOutputBuffer(msg);
}
void ProtocolGame::sendMarketAcceptOffer(const MarketOfferEx& offer)
{
NetworkMessage msg;
msg.addByte(0xF9);
msg.addItemId(offer.itemId);
if (offer.type == MARKETACTION_BUY) {
msg.add<uint32_t>(0x01);
msg.add<uint32_t>(offer.timestamp);
msg.add<uint16_t>(offer.counter);
msg.add<uint16_t>(offer.amount);
msg.add<uint32_t>(offer.price);
msg.addString(offer.playerName);
msg.add<uint32_t>(0x00);
}
else {
msg.add<uint32_t>(0x00);
msg.add<uint32_t>(0x01);
msg.add<uint32_t>(offer.timestamp);
msg.add<uint16_t>(offer.counter);
msg.add<uint16_t>(offer.amount);
msg.add<uint32_t>(offer.price);
msg.addString(offer.playerName);
}
writeToOutputBuffer(msg);
}
void ProtocolGame::sendMarketBrowseOwnOffers(const MarketOfferList& buyOffers, const MarketOfferList& sellOffers)
{
NetworkMessage msg;
msg.addByte(0xF9);
msg.add<uint16_t>(MARKETREQUEST_OWN_OFFERS);
msg.add<uint32_t>(buyOffers.size());
for (const MarketOffer& offer : buyOffers) {
msg.add<uint32_t>(offer.timestamp);
msg.add<uint16_t>(offer.counter);
msg.addItemId(offer.itemId);
msg.add<uint16_t>(offer.amount);
msg.add<uint32_t>(offer.price);
}
msg.add<uint32_t>(sellOffers.size());
for (const MarketOffer& offer : sellOffers) {
msg.add<uint32_t>(offer.timestamp);
msg.add<uint16_t>(offer.counter);
msg.addItemId(offer.itemId);
msg.add<uint16_t>(offer.amount);
msg.add<uint32_t>(offer.price);
}
writeToOutputBuffer(msg);
}
void ProtocolGame::sendMarketCancelOffer(const MarketOfferEx& offer)
{
NetworkMessage msg;
msg.addByte(0xF9);
msg.add<uint16_t>(MARKETREQUEST_OWN_OFFERS);
if (offer.type == MARKETACTION_BUY) {
msg.add<uint32_t>(0x01);
msg.add<uint32_t>(offer.timestamp);
msg.add<uint16_t>(offer.counter);
msg.addItemId(offer.itemId);
msg.add<uint16_t>(offer.amount);
msg.add<uint32_t>(offer.price);
msg.add<uint32_t>(0x00);
}
else {
msg.add<uint32_t>(0x00);
msg.add<uint32_t>(0x01);
msg.add<uint32_t>(offer.timestamp);
msg.add<uint16_t>(offer.counter);
msg.addItemId(offer.itemId);
msg.add<uint16_t>(offer.amount);
msg.add<uint32_t>(offer.price);
}
writeToOutputBuffer(msg);
}
void ProtocolGame::sendMarketBrowseOwnHistory(const HistoryMarketOfferList& buyOffers, const HistoryMarketOfferList& sellOffers)
{
uint32_t i = 0;
std::map<uint32_t, uint16_t> counterMap;
uint32_t buyOffersToSend = std::min<uint32_t>(buyOffers.size(), 810 + std::max<int32_t>(0, 810 - sellOffers.size()));
uint32_t sellOffersToSend = std::min<uint32_t>(sellOffers.size(), 810 + std::max<int32_t>(0, 810 - buyOffers.size()));
NetworkMessage msg;
msg.addByte(0xF9);
msg.add<uint16_t>(MARKETREQUEST_OWN_HISTORY);
msg.add<uint32_t>(buyOffersToSend);
for (HistoryMarketOfferList::const_iterator it = buyOffers.begin(); i < buyOffersToSend; ++it, ++i) {
msg.add<uint32_t>(it->timestamp);
msg.add<uint16_t>(counterMap[it->timestamp]++);
msg.addItemId(it->itemId);
msg.add<uint16_t>(it->amount);
msg.add<uint32_t>(it->price);
msg.addByte(it->state);
}
counterMap.clear();
i = 0;
msg.add<uint32_t>(sellOffersToSend);
for (HistoryMarketOfferList::const_iterator it = sellOffers.begin(); i < sellOffersToSend; ++it, ++i) {
msg.add<uint32_t>(it->timestamp);
msg.add<uint16_t>(counterMap[it->timestamp]++);
msg.addItemId(it->itemId);
msg.add<uint16_t>(it->amount);
msg.add<uint32_t>(it->price);
msg.addByte(it->state);
}
writeToOutputBuffer(msg);
}
void ProtocolGame::sendMarketDetail(uint16_t itemId)
{
NetworkMessage msg;
msg.addByte(0xF8);
msg.addItemId(itemId);
const ItemType& it = Item::items[itemId];
if (it.armor != 0) {
msg.addString(std::to_string(it.armor));
}
else {
msg.add<uint16_t>(0x00);
}
if (it.attack != 0) {
// TODO: chance to hit, range
// example:
// "attack +x, chance to hit +y%, z fields"
if (it.abilities && it.abilities->elementType != COMBAT_NONE && it.abilities->elementDamage != 0) {
std::ostringstream ss;
ss << it.attack << " physical +" << it.abilities->elementDamage << ' ' << getCombatName(it.abilities->elementType);
msg.addString(ss.str());
}
else {
msg.addString(std::to_string(it.attack));
}
}
else {
msg.add<uint16_t>(0x00);
}
if (it.isContainer()) {
msg.addString(std::to_string(it.maxItems));
}
else {
msg.add<uint16_t>(0x00);
}
if (it.defense != 0) {
if (it.extraDefense != 0) {
std::ostringstream ss;
ss << it.defense << ' ' << std::showpos << it.extraDefense << std::noshowpos;
msg.addString(ss.str());
}
else {
msg.addString(std::to_string(it.defense));
}
}
else {
msg.add<uint16_t>(0x00);
}
if (!it.description.empty()) {
const std::string& descr = it.description;
if (descr.back() == '.') {
msg.addString(std::string(descr, 0, descr.length() - 1));
}
else {
msg.addString(descr);
}
}
else {
msg.add<uint16_t>(0x00);
}
if (it.decayTime != 0) {
std::ostringstream ss;
ss << it.decayTime << " seconds";
msg.addString(ss.str());
}
else {
msg.add<uint16_t>(0x00);
}
if (it.abilities) {
std::ostringstream ss;
bool separator = false;
for (size_t i = 0; i < COMBAT_COUNT; ++i) {
if (it.abilities->absorbPercent[i] == 0) {
continue;
}
if (separator) {
ss << ", ";
}
else {
separator = true;
}
ss << getCombatName(indexToCombatType(i)) << ' ' << std::showpos << it.abilities->absorbPercent[i] << std::noshowpos << '%';
}
msg.addString(ss.str());
}
else {
msg.add<uint16_t>(0x00);
}
if (it.minReqLevel != 0) {
msg.addString(std::to_string(it.minReqLevel));
}
else {
msg.add<uint16_t>(0x00);
}
if (it.minReqMagicLevel != 0) {
msg.addString(std::to_string(it.minReqMagicLevel));
}
else {
msg.add<uint16_t>(0x00);
}
msg.addString(it.vocationString);
msg.addString(it.runeSpellName);
if (it.abilities) {
std::ostringstream ss;
bool separator = false;
for (uint8_t i = SKILL_FIRST; i <= SKILL_LAST; i++) {
if (!it.abilities->skills[i]) {
continue;
}
if (separator) {
ss << ", ";
}
else {
separator = true;
}
ss << getSkillName(i) << ' ' << std::showpos << it.abilities->skills[i] << std::noshowpos;
}
if (it.abilities->stats[STAT_MAGICPOINTS] != 0) {
if (separator) {
ss << ", ";
}
else {
separator = true;
}
ss << "magic level " << std::showpos << it.abilities->stats[STAT_MAGICPOINTS] << std::noshowpos;
}
if (it.abilities->speed != 0) {
if (separator) {
ss << ", ";
}
ss << "speed " << std::showpos << (it.abilities->speed >> 1) << std::noshowpos;
}
msg.addString(ss.str());
}
else {
msg.add<uint16_t>(0x00);
}
if (it.charges != 0) {
msg.addString(std::to_string(it.charges));
}
else {
msg.add<uint16_t>(0x00);
}
std::string weaponName = getWeaponName(it.weaponType);
if (it.slotPosition & SLOTP_TWO_HAND) {
if (!weaponName.empty()) {
weaponName += ", two-handed";
}
else {
weaponName = "two-handed";
}
}
msg.addString(weaponName);
if (it.weight != 0) {
std::ostringstream ss;
if (it.weight < 10) {
ss << "0.0" << it.weight;
}
else if (it.weight < 100) {
ss << "0." << it.weight;
}
else {
std::string weightString = std::to_string(it.weight);
weightString.insert(weightString.end() - 2, '.');
ss << weightString;
}
ss << " oz";
msg.addString(ss.str());
}
else {
msg.add<uint16_t>(0x00);
}
MarketStatistics* statistics = IOMarket::getInstance()->getPurchaseStatistics(itemId);
if (statistics) {
msg.addByte(0x01);
msg.add<uint32_t>(statistics->numTransactions);
msg.add<uint32_t>(std::min<uint64_t>(std::numeric_limits<uint32_t>::max(), statistics->totalPrice));
msg.add<uint32_t>(statistics->highestPrice);
msg.add<uint32_t>(statistics->lowestPrice);
}
else {
msg.addByte(0x00);
}
statistics = IOMarket::getInstance()->getSaleStatistics(itemId);
if (statistics) {
msg.addByte(0x01);
msg.add<uint32_t>(statistics->numTransactions);
msg.add<uint32_t>(std::min<uint64_t>(std::numeric_limits<uint32_t>::max(), statistics->totalPrice));
msg.add<uint32_t>(statistics->highestPrice);
msg.add<uint32_t>(statistics->lowestPrice);
}
else {
msg.addByte(0x00);
}
writeToOutputBuffer(msg);
}
void ProtocolGame::sendQuestLog()
{
NetworkMessage msg;
msg.addByte(0xF0);
msg.add<uint16_t>(g_game.quests.getQuestsCount(player));
for (const Quest& quest : g_game.quests.getQuests()) {
if (quest.isStarted(player)) {
msg.add<uint16_t>(quest.getID());
msg.addString(quest.getName());
msg.addByte(quest.isCompleted(player));
}
}
writeToOutputBuffer(msg);
}
void ProtocolGame::sendQuestLine(const Quest* quest)
{
NetworkMessage msg;
msg.addByte(0xF1);
msg.add<uint16_t>(quest->getID());
msg.addByte(quest->getMissionsCount(player));
for (const Mission& mission : quest->getMissions()) {
if (mission.isStarted(player)) {
msg.addString(mission.getName(player));
msg.addString(mission.getDescription(player));
}
}
writeToOutputBuffer(msg);
}
void ProtocolGame::sendTradeItemRequest(const std::string& traderName, const Item* item, bool ack)
{
NetworkMessage msg;
if (ack) {
msg.addByte(0x7D);
}
else {
msg.addByte(0x7E);
}
msg.addString(traderName);
if (const Container* tradeContainer = item->getContainer()) {
std::list<const Container*> listContainer{ tradeContainer };
std::list<const Item*> itemList{ tradeContainer };
while (!listContainer.empty()) {
const Container* container = listContainer.front();
listContainer.pop_front();
for (Item* containerItem : container->getItemList()) {
Container* tmpContainer = containerItem->getContainer();
if (tmpContainer) {
listContainer.push_back(tmpContainer);
}
itemList.push_back(containerItem);
}
}
msg.addByte(itemList.size());
for (const Item* listItem : itemList) {
msg.addItem(listItem);
}
}
else {
msg.addByte(0x01);
msg.addItem(item);
}
writeToOutputBuffer(msg);
}
void ProtocolGame::sendCloseTrade()
{
NetworkMessage msg;
msg.addByte(0x7F);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendCloseContainer(uint8_t cid)
{
NetworkMessage msg;
msg.addByte(0x6F);
msg.addByte(cid);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendCreatureTurn(const Creature* creature, uint32_t stackPos)
{
if (!canSee(creature)) {
return;
}
NetworkMessage msg;
msg.addByte(0x6B);
msg.addPosition(creature->getPosition());
msg.addByte(stackPos);
msg.add<uint16_t>(0x63);
msg.add<uint32_t>(creature->getID());
msg.addByte(creature->getDirection());
msg.addByte(player->canWalkthroughEx(creature) ? 0x00 : 0x01);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendCreatureSay(const Creature* creature, SpeakClasses type, const std::string& text, const Position* pos/* = nullptr*/)
{
NetworkMessage msg;
msg.addByte(0xAA);
static uint32_t statementId = 0;
msg.add<uint32_t>(++statementId);
msg.addString(creature->getName());
//Add level only for players
if (const Player* speaker = creature->getPlayer()) {
msg.add<uint16_t>(speaker->getLevel());
}
else {
msg.add<uint16_t>(0x00);
}
msg.addByte(type);
if (pos) {
msg.addPosition(*pos);
}
else {
msg.addPosition(creature->getPosition());
}
msg.addString(text);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendToChannel(const Creature* creature, SpeakClasses type, const std::string& text, uint16_t channelId)
{
NetworkMessage msg;
msg.addByte(0xAA);
static uint32_t statementId = 0;
msg.add<uint32_t>(++statementId);
if (!creature) {
msg.add<uint32_t>(0x00);
}
else if (type == TALKTYPE_CHANNEL_R2) {
msg.add<uint32_t>(0x00);
type = TALKTYPE_CHANNEL_R1;
}
else {
msg.addString(creature->getName());
//Add level only for players
if (const Player* speaker = creature->getPlayer()) {
msg.add<uint16_t>(speaker->getLevel());
}
else {
msg.add<uint16_t>(0x00);
}
}
msg.addByte(type);
msg.add<uint16_t>(channelId);
msg.addString(text);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendPrivateMessage(const Player* speaker, SpeakClasses type, const std::string& text)
{
NetworkMessage msg;
msg.addByte(0xAA);
static uint32_t statementId = 0;
msg.add<uint32_t>(++statementId);
if (speaker) {
msg.addString(speaker->getName());
msg.add<uint16_t>(speaker->getLevel());
}
else {
msg.add<uint32_t>(0x00);
}
msg.addByte(type);
msg.addString(text);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendCancelTarget()
{
NetworkMessage msg;
msg.addByte(0xA3);
msg.add<uint32_t>(0x00);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendChangeSpeed(const Creature* creature, uint32_t speed)
{
NetworkMessage msg;
msg.addByte(0x8F);
msg.add<uint32_t>(creature->getID());
msg.add<uint16_t>(creature->getBaseSpeed() / 2);
msg.add<uint16_t>(speed / 2);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendDistanceShoot(const Position& from, const Position& to, uint8_t type)
{
NetworkMessage msg;
msg.addByte(0x85);
msg.addPosition(from);
msg.addPosition(to);
msg.addByte(type);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendCreatureHealth(const Creature* creature)
{
NetworkMessage msg;
msg.addByte(0x8C);
msg.add<uint32_t>(creature->getID());
if (creature->isHealthHidden()) {
msg.addByte(0x00);
}
else {
msg.addByte(std::ceil((static_cast<double>(creature->getHealth()) / std::max<int32_t>(creature->getMaxHealth(), 1)) * 100));
}
writeToOutputBuffer(msg);
}
void ProtocolGame::sendFYIBox(const std::string& message)
{
NetworkMessage msg;
msg.addByte(0x15);
msg.addString(message);
writeToOutputBuffer(msg);
}
//tile
void ProtocolGame::sendAddTileItem(const Position& pos, uint32_t stackpos, const Item* item)
{
if (!canSee(pos)) {
return;
}
NetworkMessage msg;
msg.addByte(0x6A);
msg.addPosition(pos);
msg.addByte(stackpos);
msg.addItem(item);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendUpdateTileItem(const Position& pos, uint32_t stackpos, const Item* item)
{
if (!canSee(pos)) {
return;
}
NetworkMessage msg;
msg.addByte(0x6B);
msg.addPosition(pos);
msg.addByte(stackpos);
msg.addItem(item);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendRemoveTileThing(const Position& pos, uint32_t stackpos)
{
if (!canSee(pos)) {
return;
}
NetworkMessage msg;
RemoveTileThing(msg, pos, stackpos);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendFightModes()
{
NetworkMessage msg;
msg.addByte(0xA7);
msg.addByte(player->fightMode);
msg.addByte(player->chaseMode);
msg.addByte(player->secureMode);
msg.addByte(PVP_MODE_DOVE);
writeToOutputBuffer(msg);
msg.addString("http://static.tibia.com/images/store");
msg.addByte(0x19);
msg.addByte(0x00);
}
void ProtocolGame::sendMoveCreature(const Creature* creature, const Position& newPos, int32_t newStackPos, const Position& oldPos, int32_t oldStackPos, bool teleport)
{
if (creature == player) {
if (oldStackPos >= 10) {
sendMapDescription(newPos);
}
else if (teleport) {
NetworkMessage msg;
RemoveTileThing(msg, oldPos, oldStackPos);
writeToOutputBuffer(msg);
sendMapDescription(newPos);
}
else {
NetworkMessage msg;
if (oldPos.z == 7 && newPos.z >= 8) {
RemoveTileThing(msg, oldPos, oldStackPos);
}
else {
msg.addByte(0x6D);
msg.addPosition(oldPos);
msg.addByte(oldStackPos);
msg.addPosition(newPos);
}
if (newPos.z > oldPos.z) {
MoveDownCreature(msg, creature, newPos, oldPos);
}
else if (newPos.z < oldPos.z) {
MoveUpCreature(msg, creature, newPos, oldPos);
}
if (oldPos.y > newPos.y) { // north, for old x
msg.addByte(0x65);
GetMapDescription(oldPos.x - 8, newPos.y - 6, newPos.z, 18, 1, msg);
}
else if (oldPos.y < newPos.y) { // south, for old x
msg.addByte(0x67);
GetMapDescription(oldPos.x - 8, newPos.y + 7, newPos.z, 18, 1, msg);
}
if (oldPos.x < newPos.x) { // east, [with new y]
msg.addByte(0x66);
GetMapDescription(newPos.x + 9, newPos.y - 6, newPos.z, 1, 14, msg);
}
else if (oldPos.x > newPos.x) { // west, [with new y]
msg.addByte(0x68);
GetMapDescription(newPos.x - 8, newPos.y - 6, newPos.z, 1, 14, msg);
}
writeToOutputBuffer(msg);
}
}
else if (canSee(oldPos) && canSee(creature->getPosition())) {
if (teleport || (oldPos.z == 7 && newPos.z >= 8) || oldStackPos >= 10) {
sendRemoveTileThing(oldPos, oldStackPos);
sendAddCreature(creature, newPos, newStackPos, false);
}
else {
NetworkMessage msg;
msg.addByte(0x6D);
msg.addPosition(oldPos);
msg.addByte(oldStackPos);
msg.addPosition(creature->getPosition());
writeToOutputBuffer(msg);
}
}
else if (canSee(oldPos)) {
sendRemoveTileThing(oldPos, oldStackPos);
}
else if (canSee(creature->getPosition())) {
sendAddCreature(creature, newPos, newStackPos, false);
}
}
void ProtocolGame::sendAddContainerItem(uint8_t cid, uint16_t slot, const Item* item)
{
NetworkMessage msg;
msg.addByte(0x70);
msg.addByte(cid);
msg.add<uint16_t>(slot);
msg.addItem(item);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendUpdateContainerItem(uint8_t cid, uint16_t slot, const Item* item)
{
NetworkMessage msg;
msg.addByte(0x71);
msg.addByte(cid);
msg.add<uint16_t>(slot);
msg.addItem(item);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendRemoveContainerItem(uint8_t cid, uint16_t slot, const Item* lastItem)
{
NetworkMessage msg;
msg.addByte(0x72);
msg.addByte(cid);
msg.add<uint16_t>(slot);
if (lastItem) {
msg.addItem(lastItem);
}
else {
msg.add<uint16_t>(0x00);
}
writeToOutputBuffer(msg);
}
void ProtocolGame::sendTextWindow(uint32_t windowTextId, Item* item, uint16_t maxlen, bool canWrite)
{
NetworkMessage msg;
msg.addByte(0x96);
msg.add<uint32_t>(windowTextId);
msg.addItem(item);
if (canWrite) {
msg.add<uint16_t>(maxlen);
msg.addString(item->getText());
}
else {
const std::string& text = item->getText();
msg.add<uint16_t>(text.size());
msg.addString(text);
}
const std::string& writer = item->getWriter();
if (!writer.empty()) {
msg.addString(writer);
}
else {
msg.add<uint16_t>(0x00);
}
time_t writtenDate = item->getDate();
if (writtenDate != 0) {
msg.addString(formatDateShort(writtenDate));
}
else {
msg.add<uint16_t>(0x00);
}
writeToOutputBuffer(msg);
}
void ProtocolGame::sendTextWindow(uint32_t windowTextId, uint32_t itemId, const std::string& text)
{
NetworkMessage msg;
msg.addByte(0x96);
msg.add<uint32_t>(windowTextId);
msg.addItem(itemId, 1);
msg.add<uint16_t>(text.size());
msg.addString(text);
msg.add<uint16_t>(0x00);
msg.add<uint16_t>(0x00);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendHouseWindow(uint32_t windowTextId, const std::string& text)
{
NetworkMessage msg;
msg.addByte(0x97);
msg.addByte(0x00);
msg.add<uint32_t>(windowTextId);
msg.addString(text);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendOutfitWindow()
{
NetworkMessage msg;
msg.addByte(0xC8);
Outfit_t currentOutfit = player->getDefaultOutfit();
Mount* currentMount = g_game.mounts.getMountByID(player->getCurrentMount());
if (currentMount) {
currentOutfit.lookMount = currentMount->clientId;
}
AddOutfit(msg, currentOutfit);
std::vector<ProtocolOutfit> protocolOutfits;
if (player->isAccessPlayer()) {
static const std::string gamemasterOutfitName = "Gamemaster";
protocolOutfits.emplace_back(
&gamemasterOutfitName,
75,
0
);
}
const auto& outfits = Outfits::getInstance()->getOutfits(player->getSex());
protocolOutfits.reserve(outfits.size());
for (const Outfit& outfit : outfits) {
uint8_t addons;
if (!player->getOutfitAddons(outfit, addons)) {
continue;
}
protocolOutfits.emplace_back(
&outfit.name,
outfit.lookType,
addons
);
if (protocolOutfits.size() == 100) { // Game client doesn't allow more than 50 outfits
break;
}
}
msg.addByte(protocolOutfits.size());
for (const ProtocolOutfit& outfit : protocolOutfits) {
msg.add<uint16_t>(outfit.lookType);
msg.addString(*outfit.name);
msg.addByte(outfit.addons);
}
std::vector<const Mount*> mounts;
for (const Mount& mount : g_game.mounts.getMounts()) {
if (player->hasMount(&mount)) {
mounts.push_back(&mount);
}
}
msg.addByte(mounts.size());
for (const Mount* mount : mounts) {
msg.add<uint16_t>(mount->clientId);
msg.addString(mount->name);
}
writeToOutputBuffer(msg);
}
void ProtocolGame::sendUpdatedVIPStatus(uint32_t guid, VipStatus_t newStatus)
{
NetworkMessage msg;
msg.addByte(0xD3);
msg.add<uint32_t>(guid);
msg.addByte(newStatus);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendSpellCooldown(uint8_t spellId, uint32_t time)
{
NetworkMessage msg;
msg.addByte(0xA4);
msg.addByte(spellId);
msg.add<uint32_t>(time);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendSpellGroupCooldown(SpellGroup_t groupId, uint32_t time)
{
NetworkMessage msg;
msg.addByte(0xA5);
msg.addByte(groupId);
msg.add<uint32_t>(time);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendModalWindow(const ModalWindow& modalWindow)
{
NetworkMessage msg;
msg.addByte(0xFA);
msg.add<uint32_t>(modalWindow.id);
msg.addString(modalWindow.title);
msg.addString(modalWindow.message);
msg.addByte(modalWindow.buttons.size());
for (const auto& it : modalWindow.buttons) {
msg.addString(it.first);
msg.addByte(it.second);
}
msg.addByte(modalWindow.choices.size());
for (const auto& it : modalWindow.choices) {
msg.addString(it.first);
msg.addByte(it.second);
}
msg.addByte(modalWindow.defaultEscapeButton);
msg.addByte(modalWindow.defaultEnterButton);
msg.addByte(modalWindow.priority ? 0x01 : 0x00);
writeToOutputBuffer(msg);
}
////////////// Add common messages
void ProtocolGame::MoveUpCreature(NetworkMessage& msg, const Creature* creature, const Position& newPos, const Position& oldPos)
{
if (creature != player) {
return;
}
//floor change up
msg.addByte(0xBE);
//going to surface
if (newPos.z == 7) {
int32_t skip = -1;
GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, 5, 18, 14, 3, skip); //(floor 7 and 6 already set)
GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, 4, 18, 14, 4, skip);
GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, 3, 18, 14, 5, skip);
GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, 2, 18, 14, 6, skip);
GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, 1, 18, 14, 7, skip);
GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, 0, 18, 14, 8, skip);
if (skip >= 0) {
msg.addByte(skip);
msg.addByte(0xFF);
}
}
//underground, going one floor up (still underground)
else if (newPos.z > 7) {
int32_t skip = -1;
GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, oldPos.getZ() - 3, 18, 14, 3, skip);
if (skip >= 0) {
msg.addByte(skip);
msg.addByte(0xFF);
}
}
//moving up a floor up makes us out of sync
//west
msg.addByte(0x68);
GetMapDescription(oldPos.x - 8, oldPos.y - 5, newPos.z, 1, 14, msg);
//north
msg.addByte(0x65);
GetMapDescription(oldPos.x - 8, oldPos.y - 6, newPos.z, 18, 1, msg);
}
void ProtocolGame::MoveDownCreature(NetworkMessage& msg, const Creature* creature, const Position& newPos, const Position& oldPos)
{
if (creature != player) {
return;
}
//floor change down
msg.addByte(0xBF);
//going from surface to underground
if (newPos.z == 8) {
int32_t skip = -1;
GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, newPos.z, 18, 14, -1, skip);
GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, newPos.z + 1, 18, 14, -2, skip);
GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, newPos.z + 2, 18, 14, -3, skip);
if (skip >= 0) {
msg.addByte(skip);
msg.addByte(0xFF);
}
}
//going further down
else if (newPos.z > oldPos.z && newPos.z > 8 && newPos.z < 14) {
int32_t skip = -1;
GetFloorDescription(msg, oldPos.x - 8, oldPos.y - 6, newPos.z + 2, 18, 14, -3, skip);
if (skip >= 0) {
msg.addByte(skip);
msg.addByte(0xFF);
}
}
//moving down a floor makes us out of sync
//east
msg.addByte(0x66);
GetMapDescription(oldPos.x + 9, oldPos.y - 7, newPos.z, 1, 14, msg);
//south
msg.addByte(0x67);
GetMapDescription(oldPos.x - 8, oldPos.y + 7, newPos.z, 18, 1, msg);
}
void ProtocolGame::AddShopItem(NetworkMessage& msg, const ShopInfo& item)
{
const ItemType& it = Item::items[item.itemId];
msg.add<uint16_t>(it.clientId);
if (it.isSplash() || it.isFluidContainer()) {
msg.addByte(serverFluidToClient(item.subType));
}
else {
msg.addByte(0x00);
}
msg.addString(item.realName);
msg.add<uint32_t>(it.weight);
msg.add<uint32_t>(item.buyPrice);
msg.add<uint32_t>(item.sellPrice);
}
void ProtocolGame::parseExtendedOpcode(NetworkMessage& msg)
{
uint8_t opcode = msg.getByte();
const std::string& buffer = msg.getString();
// process additional opcodes via lua script event
addGameTask(&Game::parsePlayerExtendedOpcode, player->getID(), opcode, buffer);
}
| [
"contato@otmanager.com.br"
] | contato@otmanager.com.br |
ec2995dd5a17b344b4f892becf0086ee754d137b | b3241cb2d2761a084c219b6e854f8a65d0a6a59d | /estun/src/core/log.cpp | 8269a9f6c9a5a2f1abaf21cfefdc3cc80270c20a | [
"MIT"
] | permissive | ibvfteh/watersim | b88bae9d3aa078d923db9d8e16ba8103c90917ea | 8a524f9290c49b84889785160ce875d524ed190b | refs/heads/master | 2020-12-04T05:35:04.492335 | 2020-05-12T16:48:12 | 2020-05-12T16:48:12 | 231,634,106 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 485 | cpp | #include "core/log.h"
#include <spdlog/sinks/stdout_color_sinks.h>
namespace estun
{
std::shared_ptr<spdlog::logger> Log::coreLogger;
std::shared_ptr<spdlog::logger> Log::clientLogger;
void Log::Init()
{
spdlog::set_pattern("%^[%T] %n: %v%$");
coreLogger = spdlog::stdout_color_mt("ESTUN");
coreLogger->set_level(spdlog::level::trace);
clientLogger = spdlog::stdout_color_mt("APP");
clientLogger->set_level(spdlog::level::trace);
}
} // namespace estun
| [
"ibvfteh@gmail.com"
] | ibvfteh@gmail.com |
d130860ac30f02127e068f93165df04fd94a6bcd | 1f7bec17e16aab926807108e619c37bddefe1cd2 | /uva.12541 - Birthdates.cpp | b3d7e6ff12f97aa83da8cd467476ea6d61a8fd01 | [] | no_license | shuvra-mbstu/Uva-problems | 2dd1399aabce0028cc46e2fdaef5e68f7c4d4f61 | 90295bd37e24dfd72721e32edecdb7f87c84422b | refs/heads/master | 2021-02-10T16:42:53.367805 | 2020-03-05T09:22:38 | 2020-03-05T09:22:38 | 244,399,935 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,211 | cpp | #include<bits/stdc++.h>
using namespace std;
int main()
{
int day[1009],mon[1009],yr[1009],i,j,k,num,l;
char name[1001][1001],fr[2000];
while(scanf("%d",&num)!= EOF)
{
for(i=0; i<num; i++)
{
scanf("%s",name[i]);
scanf("%d%d%d",&day[i],&mon[i],&yr[i]);
}
for(i=0; i<num-1; i++)
{
for(j=i+1; j<num; j++)
{
if(yr[i]>yr[j])
{
strcpy(fr,name[i]);
strcpy(name[i],name[j]);
strcpy(name[j],fr);
l = yr[i];
yr[i]=yr[j];
yr[j]= l;
l=mon[i];
mon[i]= mon[j];
mon[j]=l;
l=day[i];
day[i]=day[j];
day[j]=l;
}
else if(yr[i]==yr[j])
{
if(mon[i]>mon[j])
{
strcpy(fr,name[i]);
strcpy(name[i],name[j]);
strcpy(name[j],fr);
l = yr[i];
yr[i]=yr[j];
yr[j]= l;
l=mon[i];
mon[i]= mon[j];
mon[j]=l;
l=day[i];
day[i]=day[j];
day[j]=l;
}
else if(mon[i]==mon[j])
{
if(day[i]>day[j])
{
strcpy(fr,name[i]);
strcpy(name[i],name[j]);
strcpy(name[j],fr);
l = yr[i];
yr[i]=yr[j];
yr[j]= l;
l=mon[i];
mon[i]= mon[j];
mon[j]=l;
l=day[i];
day[i]=day[j];
day[j]=l;
}
}
}
}
}
printf("%s\n%s\n",name[num-1],name[0]);
}
}
| [
"noreply@github.com"
] | noreply@github.com |
9387e95ac326a6e33cf6372c8b12b78aa3fe28f0 | a4e3f58154c349f951066c61db4c2e23ddb095ce | /OpenFoam_Cases/Channel_14124_M2/processor4/2000/U | e0015aa6882a2fe31b710b705072cbf71f0cf86f | [] | no_license | dikshant96/Thesis_OF1 | a53d1b01b19e9bf95f4b03fc3787298b8244c1c5 | 2c6ed256347a2e32611a93e117022d9aa1ff3317 | refs/heads/master | 2020-09-11T01:59:25.606585 | 2019-11-15T11:04:11 | 2019-11-15T11:04:11 | 221,902,054 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 149,978 | /*--------------------------------*- 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 "2000";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField nonuniform List<vector>
3974
(
(0.124562 -2.98532e-07 2.9832e-16)
(0.124562 -2.99e-07 3.23049e-16)
(0.124562 -2.77439e-07 2.61484e-16)
(0.124562 -2.59911e-07 2.93604e-16)
(0.124562 -2.45297e-07 2.36309e-16)
(0.124562 -2.32227e-07 2.30412e-16)
(0.124562 -2.20332e-07 1.88602e-16)
(0.124562 -2.09545e-07 6.98195e-17)
(0.124562 -1.99806e-07 1.73735e-16)
(0.124563 -1.90998e-07 1.72724e-16)
(0.124563 -1.82952e-07 1.80893e-16)
(0.124563 -1.75473e-07 1.47722e-16)
(0.124563 -1.68362e-07 7.08428e-17)
(0.124563 -1.61438e-07 1.1133e-16)
(0.124563 -1.54551e-07 2.34262e-17)
(0.124563 -1.47589e-07 7.79915e-17)
(0.124563 -1.40476e-07 9.90746e-17)
(0.124563 -1.33164e-07 2.11914e-17)
(0.124563 -1.25631e-07 1.27219e-16)
(0.124563 -1.17865e-07 9.95119e-17)
(0.124563 -1.09869e-07 1.05144e-16)
(0.124563 -1.0165e-07 9.32583e-17)
(0.124563 -9.3224e-08 3.44651e-17)
(0.124563 -8.46087e-08 7.84114e-17)
(0.124563 -7.58265e-08 -6.63929e-18)
(0.124563 -6.69035e-08 6.88157e-17)
(0.124563 -5.78645e-08 4.35012e-17)
(0.124563 -4.87384e-08 -1.11683e-17)
(0.124562 -3.95468e-08 3.71741e-17)
(0.124562 -3.03157e-08 1.28767e-17)
(0.124562 -2.10587e-08 4.92178e-17)
(0.124562 -1.17591e-08 1.20928e-16)
(0.124562 -2.45642e-09 3.1658e-17)
(0.124562 7.21967e-09 1.08874e-16)
(0.124562 1.66125e-08 1.55204e-16)
(0.124562 2.98443e-08 6.41825e-17)
(0.124562 3.68427e-08 1.19583e-16)
(0.124562 1.08176e-07 2.50778e-17)
(0.125681 -1.08235e-07 5.67532e-16)
(0.125681 -2.25327e-07 5.05231e-16)
(0.125681 -3.04224e-07 5.16775e-16)
(0.125681 -2.94616e-07 5.47025e-16)
(0.125681 -2.75574e-07 4.71134e-16)
(0.125681 -2.60386e-07 5.01176e-16)
(0.125681 -2.46581e-07 4.33573e-16)
(0.125681 -2.33745e-07 4.4374e-16)
(0.125681 -2.21863e-07 4.40247e-16)
(0.125681 -2.10986e-07 3.36864e-16)
(0.125681 -2.01099e-07 3.7375e-16)
(0.125681 -1.92111e-07 3.63969e-16)
(0.125681 -1.8387e-07 3.82167e-16)
(0.125681 -1.76191e-07 3.85531e-16)
(0.125681 -1.68884e-07 2.67046e-16)
(0.125681 -1.61772e-07 3.09498e-16)
(0.125681 -1.54708e-07 2.48004e-16)
(0.125681 -1.47581e-07 2.82691e-16)
(0.125681 -1.40313e-07 3.33922e-16)
(0.125681 -1.32857e-07 2.73603e-16)
(0.125681 -1.25187e-07 3.12742e-16)
(0.125681 -1.17293e-07 2.76343e-16)
(0.125681 -1.09173e-07 2.98643e-16)
(0.125681 -1.00836e-07 3.18451e-16)
(0.125681 -9.22942e-08 2.31529e-16)
(0.125681 -8.35657e-08 2.62045e-16)
(0.125681 -7.46718e-08 2.12174e-16)
(0.125681 -6.56378e-08 2.57614e-16)
(0.125681 -5.64877e-08 2.72244e-16)
(0.125681 -4.72504e-08 1.84124e-16)
(0.125681 -3.79473e-08 2.18233e-16)
(0.125681 -2.86052e-08 1.73717e-16)
(0.125681 -1.92366e-08 2.29895e-16)
(0.125681 -9.83141e-09 3.07077e-16)
(0.125681 -4.1999e-10 2.76023e-16)
(0.125681 9.32418e-09 2.99975e-16)
(0.12568 1.88315e-08 3.32762e-16)
(0.12568 3.17861e-08 2.90577e-16)
(0.12568 3.92743e-08 3.15936e-16)
(0.12568 1.01572e-07 2.68667e-16)
(0.125681 1.69379e-07 2.96517e-16)
(0.125681 2.31453e-07 3.38614e-16)
(0.126764 3.93891e-07 8.35998e-16)
(0.126764 8.55929e-08 7.2484e-16)
(0.126764 -1.10833e-07 7.59206e-16)
(0.126764 -2.06264e-07 7.42897e-16)
(0.126763 -2.72337e-07 7.45036e-16)
(0.126763 -2.71146e-07 7.75199e-16)
(0.126763 -2.64879e-07 6.82513e-16)
(0.126763 -2.5531e-07 7.21565e-16)
(0.126763 -2.43873e-07 6.40808e-16)
(0.126763 -2.32215e-07 6.71545e-16)
(0.126763 -2.20965e-07 6.87273e-16)
(0.126763 -2.10423e-07 5.69033e-16)
(0.126763 -2.00695e-07 5.91715e-16)
(0.126763 -1.91756e-07 5.56375e-16)
(0.126763 -1.83494e-07 5.99523e-16)
(0.126763 -1.75751e-07 6.23562e-16)
(0.126763 -1.68355e-07 4.78333e-16)
(0.126763 -1.61141e-07 5.19017e-16)
(0.126763 -1.5397e-07 4.2538e-16)
(0.126763 -1.46734e-07 4.91781e-16)
(0.126762 -1.3936e-07 5.63331e-16)
(0.126762 -1.31799e-07 4.67596e-16)
(0.126762 -1.24028e-07 5.13786e-16)
(0.126762 -1.16034e-07 4.47897e-16)
(0.126762 -1.07818e-07 5.02348e-16)
(0.126762 -9.93864e-08 5.42858e-16)
(0.126762 -9.07513e-08 4.40496e-16)
(0.126762 -8.19307e-08 4.61093e-16)
(0.126762 -7.29449e-08 4.12152e-16)
(0.126762 -6.38189e-08 4.66272e-16)
(0.126762 -5.45765e-08 4.96817e-16)
(0.126762 -4.52468e-08 3.87783e-16)
(0.126762 -3.58506e-08 4.16943e-16)
(0.126762 -2.64162e-08 3.55447e-16)
(0.126762 -1.69548e-08 4.29779e-16)
(0.126762 -7.46407e-09 5.07085e-16)
(0.126762 2.03626e-09 5.05491e-16)
(0.126762 1.1819e-08 5.02814e-16)
(0.126762 2.14387e-08 5.18691e-16)
(0.126762 3.38447e-08 5.0367e-16)
(0.126762 4.27514e-08 5.16605e-16)
(0.126762 8.00021e-08 4.95868e-16)
(0.126763 1.31989e-07 5.00884e-16)
(0.126763 2.04811e-07 5.26767e-16)
(0.126763 2.65189e-07 5.14549e-16)
(0.126763 2.5412e-07 5.31707e-16)
(0.126763 2.26603e-07 5.1731e-16)
(0.126763 2.04236e-07 5.23121e-16)
(0.126763 1.88004e-07 5.47323e-16)
(0.126763 1.75507e-07 5.37331e-16)
(0.126763 1.65248e-07 5.52069e-16)
(0.126763 1.56593e-07 5.34946e-16)
(0.126763 1.50726e-07 5.41872e-16)
(0.126763 1.46582e-07 5.59569e-16)
(0.126763 1.52961e-07 5.5239e-16)
(0.126763 1.58018e-07 5.73558e-16)
(0.126763 2.11429e-07 5.5384e-16)
(0.126763 2.29064e-07 5.63333e-16)
(0.126763 4.96622e-07 5.82221e-16)
(0.127812 3.81293e-07 1.04708e-15)
(0.127812 9.76576e-08 8.70977e-16)
(0.127812 -8.19061e-08 9.65596e-16)
(0.127812 -1.62998e-07 9.73001e-16)
(0.127811 -2.26005e-07 9.74021e-16)
(0.127811 -2.42816e-07 1.00614e-15)
(0.127811 -2.48267e-07 8.88238e-16)
(0.127811 -2.45062e-07 9.5663e-16)
(0.127811 -2.37173e-07 7.56679e-16)
(0.12781 -2.27555e-07 9.19364e-16)
(0.12781 -2.17527e-07 9.30611e-16)
(0.12781 -2.07741e-07 7.33504e-16)
(0.12781 -1.98483e-07 8.25336e-16)
(0.12781 -1.89827e-07 7.46364e-16)
(0.12781 -1.81725e-07 8.35958e-16)
(0.12781 -1.7406e-07 8.60402e-16)
(0.12781 -1.66689e-07 6.4743e-16)
(0.12781 -1.59464e-07 7.41354e-16)
(0.12781 -1.5226e-07 6.20514e-16)
(0.12781 -1.44978e-07 7.26804e-16)
(0.12781 -1.37548e-07 7.93556e-16)
(0.12781 -1.29926e-07 6.6603e-16)
(0.12781 -1.2209e-07 7.31572e-16)
(0.12781 -1.14029e-07 6.38358e-16)
(0.12781 -1.05744e-07 7.31397e-16)
(0.12781 -9.72417e-08 7.68938e-16)
(0.12781 -8.85356e-08 5.84299e-16)
(0.12781 -7.96432e-08 6.79362e-16)
(0.12781 -7.05846e-08 6.01295e-16)
(0.12781 -6.1385e-08 6.98034e-16)
(0.12781 -5.20682e-08 7.20665e-16)
(0.12781 -4.26633e-08 5.30535e-16)
(0.12781 -3.31915e-08 6.38579e-16)
(0.12781 -2.36825e-08 4.57799e-16)
(0.12781 -1.41464e-08 6.51302e-16)
(0.12781 -4.58921e-09 7.22386e-16)
(0.12781 4.98061e-09 7.28542e-16)
(0.12781 1.47742e-08 7.05421e-16)
(0.12781 2.44964e-08 7.0873e-16)
(0.12781 3.6187e-08 7.10496e-16)
(0.12781 4.69381e-08 7.20134e-16)
(0.12781 5.92168e-08 7.16063e-16)
(0.12781 9.25765e-08 7.10266e-16)
(0.12781 1.56524e-07 7.2208e-16)
(0.127811 2.14228e-07 7.24584e-16)
(0.127811 2.30273e-07 7.36062e-16)
(0.127811 2.1951e-07 7.3845e-16)
(0.127811 2.03676e-07 7.36055e-16)
(0.127811 1.897e-07 7.44533e-16)
(0.127811 1.78083e-07 7.48609e-16)
(0.127811 1.68192e-07 7.61428e-16)
(0.127811 1.59655e-07 7.63921e-16)
(0.127811 1.53639e-07 7.55297e-16)
(0.127811 1.49274e-07 7.59691e-16)
(0.127811 1.5496e-07 7.66004e-16)
(0.127811 1.59614e-07 7.82056e-16)
(0.127811 2.11092e-07 7.77613e-16)
(0.127811 2.28558e-07 7.80576e-16)
(0.127811 4.87666e-07 7.89532e-16)
(0.128827 3.57822e-07 1.25705e-15)
(0.128827 1.17909e-07 1.16651e-15)
(0.128827 -4.34483e-08 1.216e-15)
(0.128827 -1.28088e-07 1.19656e-15)
(0.128827 -1.89636e-07 1.20028e-15)
(0.128826 -2.1391e-07 1.23466e-15)
(0.128826 -2.27492e-07 1.16063e-15)
(0.128826 -2.30556e-07 1.22424e-15)
(0.128826 -2.26826e-07 1.13706e-15)
(0.128826 -2.19856e-07 1.20678e-15)
(0.128826 -2.11536e-07 1.16313e-15)
(0.128826 -2.02878e-07 1.05662e-15)
(0.128826 -1.94375e-07 1.08878e-15)
(0.128825 -1.86227e-07 1.02763e-15)
(0.128825 -1.78462e-07 1.1043e-15)
(0.128825 -1.71018e-07 1.08492e-15)
(0.128825 -1.63786e-07 9.57589e-16)
(0.128825 -1.56645e-07 1.00508e-15)
(0.128825 -1.49486e-07 8.98351e-16)
(0.128825 -1.42222e-07 1.01509e-15)
(0.128825 -1.34791e-07 1.01807e-15)
(0.128825 -1.27154e-07 9.29923e-16)
(0.128825 -1.19293e-07 9.79282e-16)
(0.128825 -1.112e-07 9.07993e-16)
(0.128825 -1.02876e-07 1.01411e-15)
(0.128825 -9.43319e-08 9.89344e-16)
(0.128825 -8.55802e-08 8.97269e-16)
(0.128825 -7.66393e-08 9.34243e-16)
(0.128825 -6.75302e-08 8.77933e-16)
(0.128825 -5.82783e-08 9.72498e-16)
(0.128825 -4.89076e-08 9.37754e-16)
(0.128825 -3.9448e-08 8.38322e-16)
(0.128825 -2.99209e-08 9.01187e-16)
(0.128825 -2.03577e-08 8.18546e-16)
(0.128825 -1.07678e-08 9.18048e-16)
(0.128825 -1.16609e-09 9.46041e-16)
(0.128825 8.45077e-09 9.4689e-16)
(0.128825 1.82268e-08 8.99182e-16)
(0.128825 2.8027e-08 8.9998e-16)
(0.128825 3.89724e-08 9.16889e-16)
(0.128825 5.09932e-08 9.25657e-16)
(0.128825 5.20035e-08 9.34036e-16)
(0.128825 7.15127e-08 9.2113e-16)
(0.128825 1.11996e-07 9.22096e-16)
(0.128825 1.57817e-07 9.35476e-16)
(0.128826 1.96768e-07 9.43366e-16)
(0.128826 2.04083e-07 9.58103e-16)
(0.128826 1.97473e-07 9.53716e-16)
(0.128826 1.87725e-07 9.49246e-16)
(0.128826 1.78131e-07 9.63495e-16)
(0.128826 1.69282e-07 9.75089e-16)
(0.128826 1.61295e-07 9.90919e-16)
(0.128826 1.55416e-07 9.71274e-16)
(0.128826 1.51024e-07 9.6348e-16)
(0.128826 1.56081e-07 9.81128e-16)
(0.128826 1.6041e-07 9.95178e-16)
(0.128826 2.09413e-07 1.00223e-15)
(0.128826 2.27069e-07 1.00397e-15)
(0.128826 4.6831e-07 1.00334e-15)
(0.129811 3.26892e-07 1.45899e-15)
(0.129811 1.24738e-07 1.4286e-15)
(0.129811 -1.9093e-08 1.49259e-15)
(0.129811 -1.00117e-07 1.41507e-15)
(0.12981 -1.58826e-07 1.40487e-15)
(0.12981 -1.86103e-07 1.45021e-15)
(0.12981 -2.04906e-07 1.43053e-15)
(0.12981 -2.13171e-07 1.55539e-15)
(0.12981 -2.13527e-07 1.41961e-15)
(0.12981 -2.09467e-07 1.49513e-15)
(0.12981 -2.03164e-07 1.37317e-15)
(0.129809 -1.95912e-07 1.32093e-15)
(0.129809 -1.88397e-07 1.33197e-15)
(0.129809 -1.80947e-07 1.30127e-15)
(0.129809 -1.73678e-07 1.39199e-15)
(0.129809 -1.66584e-07 1.28798e-15)
(0.129809 -1.59599e-07 1.23841e-15)
(0.129809 -1.52632e-07 1.33899e-15)
(0.129809 -1.45593e-07 1.18864e-15)
(0.129809 -1.38411e-07 1.30322e-15)
(0.129809 -1.31033e-07 1.22434e-15)
(0.129809 -1.23429e-07 1.19808e-15)
(0.129809 -1.15583e-07 1.27158e-15)
(0.129809 -1.07492e-07 1.18927e-15)
(0.129809 -9.9162e-08 1.2955e-15)
(0.129809 -9.06033e-08 1.19254e-15)
(0.129809 -8.18314e-08 1.15175e-15)
(0.129809 -7.28659e-08 1.25752e-15)
(0.129809 -6.37286e-08 1.14957e-15)
(0.129809 -5.44457e-08 1.24754e-15)
(0.129809 -4.50419e-08 1.13763e-15)
(0.129809 -3.5548e-08 1.09273e-15)
(0.129809 -2.5986e-08 1.13145e-15)
(0.129809 -1.63893e-08 1.10265e-15)
(0.129809 -6.76679e-09 1.24338e-15)
(0.129809 2.85734e-09 1.16677e-15)
(0.129808 1.24981e-08 1.16071e-15)
(0.129808 2.22303e-08 1.11972e-15)
(0.129808 3.20733e-08 1.09296e-15)
(0.129808 4.23193e-08 1.12738e-15)
(0.129808 5.49699e-08 1.13272e-15)
(0.129808 5.10465e-08 1.15332e-15)
(0.129808 6.07747e-08 1.14383e-15)
(0.129808 8.60285e-08 1.12637e-15)
(0.129809 1.19665e-07 1.15052e-15)
(0.129809 1.64559e-07 1.15279e-15)
(0.129809 1.83967e-07 1.17985e-15)
(0.129809 1.86645e-07 1.17954e-15)
(0.129809 1.82308e-07 1.15953e-15)
(0.129809 1.75679e-07 1.18458e-15)
(0.129809 1.68489e-07 1.19211e-15)
(0.129809 1.61464e-07 1.21937e-15)
(0.129809 1.55995e-07 1.20154e-15)
(0.129809 1.51768e-07 1.17252e-15)
(0.129809 1.56256e-07 1.20218e-15)
(0.129809 1.60327e-07 1.21255e-15)
(0.129809 2.06356e-07 1.23057e-15)
(0.12981 2.24458e-07 1.23547e-15)
(0.129809 4.43123e-07 1.2199e-15)
(0.130764 2.91212e-07 1.66284e-15)
(0.130764 1.22795e-07 1.67306e-15)
(0.130764 -3.87698e-09 1.69247e-15)
(0.130764 -7.80987e-08 1.614e-15)
(0.130764 -1.33004e-07 1.61279e-15)
(0.130764 -1.60915e-07 1.66279e-15)
(0.130764 -1.8241e-07 1.68393e-15)
(0.130764 -1.9434e-07 1.71718e-15)
(0.130763 -1.98184e-07 1.68183e-15)
(0.130763 -1.96931e-07 1.70639e-15)
(0.130763 -1.92739e-07 1.62976e-15)
(0.130763 -1.87039e-07 1.58745e-15)
(0.130763 -1.80663e-07 1.58629e-15)
(0.130763 -1.74052e-07 1.56102e-15)
(0.130763 -1.67401e-07 1.59587e-15)
(0.130763 -1.60764e-07 1.54618e-15)
(0.130763 -1.54118e-07 1.51034e-15)
(0.130763 -1.47403e-07 1.50817e-15)
(0.130763 -1.40553e-07 1.46214e-15)
(0.130763 -1.33511e-07 1.52225e-15)
(0.130763 -1.26238e-07 1.4778e-15)
(0.130763 -1.18709e-07 1.46499e-15)
(0.130763 -1.10918e-07 1.47631e-15)
(0.130763 -1.02864e-07 1.45923e-15)
(0.130762 -9.45572e-08 1.5093e-15)
(0.130762 -8.60117e-08 1.44445e-15)
(0.130762 -7.72448e-08 1.41537e-15)
(0.130762 -6.82781e-08 1.42773e-15)
(0.130762 -5.91346e-08 1.40731e-15)
(0.130762 -4.98419e-08 1.45667e-15)
(0.130762 -4.04256e-08 1.38809e-15)
(0.130762 -3.09178e-08 1.35548e-15)
(0.130762 -2.13412e-08 1.3894e-15)
(0.130762 -1.17316e-08 1.35807e-15)
(0.130762 -2.0978e-09 1.40468e-15)
(0.130762 7.52654e-09 1.36082e-15)
(0.130762 1.71675e-08 1.37019e-15)
(0.130762 2.68313e-08 1.3262e-15)
(0.130762 3.66757e-08 1.29538e-15)
(0.130762 4.62988e-08 1.34562e-15)
(0.130762 5.90396e-08 1.33993e-15)
(0.130762 5.32338e-08 1.37812e-15)
(0.130762 5.66266e-08 1.36732e-15)
(0.130762 7.15122e-08 1.33393e-15)
(0.130762 9.42165e-08 1.37332e-15)
(0.130762 1.3711e-07 1.36246e-15)
(0.130762 1.62876e-07 1.40818e-15)
(0.130762 1.73018e-07 1.40959e-15)
(0.130763 1.74154e-07 1.37193e-15)
(0.130763 1.70985e-07 1.41493e-15)
(0.130763 1.65902e-07 1.41063e-15)
(0.130763 1.6017e-07 1.45327e-15)
(0.130763 1.55343e-07 1.43423e-15)
(0.130763 1.51443e-07 1.38665e-15)
(0.130763 1.5541e-07 1.43406e-15)
(0.130763 1.59271e-07 1.43287e-15)
(0.130763 2.01886e-07 1.46655e-15)
(0.130763 2.20435e-07 1.47076e-15)
(0.130763 4.14922e-07 1.43584e-15)
(0.131689 2.52906e-07 1.86951e-15)
(0.131689 1.14768e-07 1.91763e-15)
(0.131689 4.26768e-09 1.90356e-15)
(0.131689 -6.20158e-08 1.79771e-15)
(0.131689 -1.12294e-07 1.80964e-15)
(0.131688 -1.3921e-07 1.87416e-15)
(0.131688 -1.6136e-07 1.93653e-15)
(0.131688 -1.75361e-07 1.93121e-15)
(0.131688 -1.81778e-07 1.93555e-15)
(0.131688 -1.82925e-07 1.89789e-15)
(0.131688 -1.8071e-07 1.86006e-15)
(0.131688 -1.76561e-07 1.84941e-15)
(0.131688 -1.71378e-07 1.80715e-15)
(0.131688 -1.65677e-07 1.81897e-15)
(0.131687 -1.59721e-07 1.80109e-15)
(0.131687 -1.53615e-07 1.77928e-15)
(0.131687 -1.47376e-07 1.7764e-15)
(0.131687 -1.40976e-07 1.73734e-15)
(0.131687 -1.34369e-07 1.72974e-15)
(0.131687 -1.27517e-07 1.71772e-15)
(0.131687 -1.20391e-07 1.70843e-15)
(0.131687 -1.12978e-07 1.72829e-15)
(0.131687 -1.05275e-07 1.71269e-15)
(0.131687 -9.7289e-08 1.72482e-15)
(0.131687 -8.90339e-08 1.70163e-15)
(0.131687 -8.0527e-08 1.67502e-15)
(0.131687 -7.17887e-08 1.67758e-15)
(0.131687 -6.28427e-08 1.65363e-15)
(0.131687 -5.37141e-08 1.66646e-15)
(0.131687 -4.44317e-08 1.64873e-15)
(0.131687 -3.50227e-08 1.61856e-15)
(0.131687 -2.55206e-08 1.61704e-15)
(0.131687 -1.59492e-08 1.60433e-15)
(0.131687 -6.34687e-09 1.61292e-15)
(0.131686 3.27741e-09 1.60693e-15)
(0.131686 1.28802e-08 1.53429e-15)
(0.131686 2.24979e-08 1.58239e-15)
(0.131686 3.20707e-08 1.55578e-15)
(0.131686 4.18724e-08 1.48872e-15)
(0.131686 5.09535e-08 1.57876e-15)
(0.131686 6.3397e-08 1.54396e-15)
(0.131686 5.72797e-08 1.61528e-15)
(0.131686 5.69235e-08 1.60012e-15)
(0.131686 6.4727e-08 1.53581e-15)
(0.131686 7.85712e-08 1.61e-15)
(0.131686 1.16098e-07 1.56841e-15)
(0.131686 1.43655e-07 1.65104e-15)
(0.131687 1.58627e-07 1.64473e-15)
(0.131687 1.64382e-07 1.57858e-15)
(0.131687 1.64626e-07 1.65897e-15)
(0.131687 1.61827e-07 1.62597e-15)
(0.131687 1.57583e-07 1.69935e-15)
(0.131687 1.5355e-07 1.67766e-15)
(0.131687 1.50091e-07 1.59681e-15)
(0.131687 1.53556e-07 1.68251e-15)
(0.131687 1.57215e-07 1.65207e-15)
(0.131687 1.96043e-07 1.71636e-15)
(0.131687 2.14792e-07 1.71092e-15)
(0.131687 3.85054e-07 1.64387e-15)
(0.132585 2.13468e-07 2.1025e-15)
(0.132585 1.02327e-07 2.07558e-15)
(0.132585 6.61703e-09 2.10753e-15)
(0.132585 -5.14564e-08 1.96236e-15)
(0.132585 -9.65182e-08 2.03093e-15)
(0.132585 -1.21326e-07 2.10634e-15)
(0.132585 -1.42631e-07 2.09976e-15)
(0.132584 -1.57279e-07 2.14008e-15)
(0.132584 -1.6524e-07 2.09139e-15)
(0.132584 -1.68169e-07 2.07472e-15)
(0.132584 -1.67613e-07 2.08161e-15)
(0.132584 -1.64868e-07 2.01322e-15)
(0.132584 -1.60824e-07 2.01781e-15)
(0.132584 -1.5603e-07 1.98292e-15)
(0.132584 -1.5079e-07 1.99568e-15)
(0.132584 -1.45248e-07 2.00557e-15)
(0.132584 -1.39454e-07 1.94476e-15)
(0.132584 -1.33406e-07 1.95948e-15)
(0.132583 -1.27081e-07 1.90159e-15)
(0.132583 -1.20453e-07 1.91152e-15)
(0.132583 -1.13509e-07 1.93513e-15)
(0.132583 -1.06241e-07 1.89425e-15)
(0.132583 -9.86543e-08 1.93667e-15)
(0.132583 -9.07624e-08 1.8977e-15)
(0.132583 -8.25826e-08 1.88711e-15)
(0.132583 -7.41363e-08 1.90159e-15)
(0.132583 -6.54472e-08 1.8438e-15)
(0.132583 -5.65416e-08 1.88392e-15)
(0.132583 -4.74465e-08 1.83377e-15)
(0.132583 -3.81928e-08 1.83877e-15)
(0.132583 -2.88091e-08 1.8456e-15)
(0.132583 -1.93307e-08 1.78269e-15)
(0.132583 -9.78283e-09 1.8338e-15)
(0.132583 -2.06717e-10 1.77901e-15)
(0.132583 9.3883e-09 1.79687e-15)
(0.132583 1.89491e-08 1.78577e-15)
(0.132583 2.85204e-08 1.81163e-15)
(0.132582 3.79817e-08 1.76484e-15)
(0.132582 4.7698e-08 1.75832e-15)
(0.132582 5.63089e-08 1.83851e-15)
(0.132582 6.82127e-08 1.83376e-15)
(0.132582 6.25361e-08 1.87406e-15)
(0.132582 6.0181e-08 1.82302e-15)
(0.132582 6.33912e-08 1.82275e-15)
(0.132582 7.06277e-08 1.87897e-15)
(0.132582 1.01749e-07 1.86016e-15)
(0.132582 1.28027e-07 1.92477e-15)
(0.132583 1.45237e-07 1.87169e-15)
(0.132583 1.54234e-07 1.86954e-15)
(0.132583 1.5737e-07 1.92853e-15)
(0.132583 1.5673e-07 1.92607e-15)
(0.132583 1.53992e-07 1.96856e-15)
(0.132583 1.508e-07 1.91066e-15)
(0.132583 1.47822e-07 1.89355e-15)
(0.132583 1.5076e-07 1.95878e-15)
(0.132583 1.54179e-07 1.95726e-15)
(0.132583 1.88902e-07 1.98987e-15)
(0.132583 2.07421e-07 1.94465e-15)
(0.132583 3.54207e-07 1.93223e-15)
(0.133454 1.73862e-07 2.33188e-15)
(0.133454 8.67756e-08 2.22751e-15)
(0.133454 4.42142e-09 2.29224e-15)
(0.133454 -4.56506e-08 2.19128e-15)
(0.133454 -8.52354e-08 2.3024e-15)
(0.133454 -1.07254e-07 2.35521e-15)
(0.133453 -1.26691e-07 2.25151e-15)
(0.133453 -1.40838e-07 2.41934e-15)
(0.133453 -1.49351e-07 2.22899e-15)
(0.133453 -1.53353e-07 2.32529e-15)
(0.133453 -1.54003e-07 2.3024e-15)
(0.133453 -1.52395e-07 2.16018e-15)
(0.133453 -1.49341e-07 2.30625e-15)
(0.133453 -1.45374e-07 2.13152e-15)
(0.133453 -1.40812e-07 2.16506e-15)
(0.133453 -1.35822e-07 2.23393e-15)
(0.133452 -1.30476e-07 2.09663e-15)
(0.133452 -1.24791e-07 2.16966e-15)
(0.133452 -1.18763e-07 2.05697e-15)
(0.133452 -1.12379e-07 2.1244e-15)
(0.133452 -1.05634e-07 2.16513e-15)
(0.133452 -9.85313e-08 2.04504e-15)
(0.133452 -9.1081e-08 2.14202e-15)
(0.133452 -8.33015e-08 2.0563e-15)
(0.133452 -7.52147e-08 2.11034e-15)
(0.133452 -6.68461e-08 2.12969e-15)
(0.133452 -5.82224e-08 1.99381e-15)
(0.133452 -4.93728e-08 2.08704e-15)
(0.133452 -4.03268e-08 1.98899e-15)
(0.133452 -3.11171e-08 2.0902e-15)
(0.133452 -2.17742e-08 2.07476e-15)
(0.133452 -1.23354e-08 1.93154e-15)
(0.133452 -2.82728e-09 2.02832e-15)
(0.133451 6.70575e-09 1.93561e-15)
(0.133451 1.62536e-08 2.05083e-15)
(0.133451 2.57535e-08 2.03082e-15)
(0.133451 3.52572e-08 2.0859e-15)
(0.133451 4.45886e-08 1.95191e-15)
(0.133451 5.41804e-08 2.01821e-15)
(0.133451 6.23795e-08 2.12172e-15)
(0.133451 7.36133e-08 2.11842e-15)
(0.133451 6.86693e-08 2.12714e-15)
(0.133451 6.54086e-08 2.02663e-15)
(0.133451 6.58417e-08 2.08665e-15)
(0.133451 6.84865e-08 2.20925e-15)
(0.133451 9.34254e-08 2.15049e-15)
(0.133451 1.16737e-07 2.17426e-15)
(0.133451 1.3411e-07 2.0772e-15)
(0.133451 1.44849e-07 2.17734e-15)
(0.133451 1.5005e-07 2.18643e-15)
(0.133451 1.51181e-07 2.2208e-15)
(0.133451 1.49783e-07 2.27212e-15)
(0.133451 1.47355e-07 2.12147e-15)
(0.133451 1.44816e-07 2.20453e-15)
(0.133451 1.47147e-07 2.219e-15)
(0.133451 1.50233e-07 2.25503e-15)
(0.133451 1.80576e-07 2.25528e-15)
(0.133452 1.98319e-07 2.16365e-15)
(0.133452 3.2275e-07 2.21321e-15)
(0.134296 1.34679e-07 2.4904e-15)
(0.134296 6.91272e-08 2.34036e-15)
(0.134296 -1.17882e-09 2.41359e-15)
(0.134296 -4.37361e-08 2.38813e-15)
(0.134296 -7.78674e-08 2.4425e-15)
(0.134296 -9.67527e-08 2.50875e-15)
(0.134296 -1.13688e-07 2.35922e-15)
(0.134295 -1.26486e-07 2.46858e-15)
(0.134295 -1.347e-07 2.30958e-15)
(0.134295 -1.39069e-07 2.32429e-15)
(0.134295 -1.40411e-07 2.43528e-15)
(0.134295 -1.3959e-07 2.26788e-15)
(0.134295 -1.37294e-07 2.35281e-15)
(0.134295 -1.34006e-07 2.2447e-15)
(0.134295 -1.3003e-07 2.26427e-15)
(0.134295 -1.25534e-07 2.36781e-15)
(0.134295 -1.20602e-07 2.20254e-15)
(0.134295 -1.15263e-07 2.30705e-15)
(0.134295 -1.09524e-07 2.17405e-15)
(0.134294 -1.03383e-07 2.18583e-15)
(0.134294 -9.6842e-08 2.30112e-15)
(0.134294 -8.99105e-08 2.1612e-15)
(0.134294 -8.26047e-08 2.27857e-15)
(0.134294 -7.4947e-08 2.17177e-15)
(0.134294 -6.69635e-08 2.16812e-15)
(0.134294 -5.8683e-08 2.27096e-15)
(0.134294 -5.01355e-08 2.09839e-15)
(0.134294 -4.1353e-08 2.22854e-15)
(0.134294 -3.23673e-08 2.10169e-15)
(0.134294 -2.32132e-08 2.1069e-15)
(0.134294 -1.39232e-08 2.21014e-15)
(0.134294 -4.53642e-09 2.0363e-15)
(0.134294 4.91848e-09 2.17297e-15)
(0.134294 1.43942e-08 2.03893e-15)
(0.134293 2.38796e-08 2.0664e-15)
(0.134293 3.33023e-08 2.18669e-15)
(0.134293 4.27191e-08 2.17375e-15)
(0.134293 5.1905e-08 2.10583e-15)
(0.134293 6.13382e-08 2.20172e-15)
(0.134293 6.91704e-08 2.23024e-15)
(0.134293 7.96807e-08 2.30109e-15)
(0.134293 7.55327e-08 2.27244e-15)
(0.134293 7.20034e-08 2.2027e-15)
(0.134293 7.08896e-08 2.28636e-15)
(0.134293 7.05558e-08 2.28613e-15)
(0.134293 9.01385e-08 2.34035e-15)
(0.134293 1.09834e-07 2.33377e-15)
(0.134293 1.25962e-07 2.22926e-15)
(0.134293 1.37105e-07 2.33332e-15)
(0.134293 1.43438e-07 2.34364e-15)
(0.134293 1.45779e-07 2.41601e-15)
(0.134293 1.45398e-07 2.38855e-15)
(0.134293 1.43542e-07 2.29034e-15)
(0.134293 1.4131e-07 2.36922e-15)
(0.134293 1.42897e-07 2.37727e-15)
(0.134293 1.45498e-07 2.44948e-15)
(0.134293 1.71214e-07 2.41517e-15)
(0.134294 1.87569e-07 2.35472e-15)
(0.134293 2.90901e-07 2.42098e-15)
(0.135112 9.62561e-08 2.6387e-15)
(0.135112 5.01065e-08 2.51121e-15)
(0.135112 -9.26013e-09 2.55265e-15)
(0.135112 -4.48913e-08 2.58461e-15)
(0.135112 -7.37799e-08 2.61551e-15)
(0.135112 -8.94302e-08 2.67099e-15)
(0.135112 -1.03534e-07 2.4657e-15)
(0.135112 -1.1442e-07 2.61324e-15)
(0.135112 -1.21667e-07 2.49178e-15)
(0.135111 -1.25776e-07 2.51041e-15)
(0.135111 -1.27294e-07 2.59454e-15)
(0.135111 -1.26869e-07 2.44725e-15)
(0.135111 -1.2505e-07 2.50866e-15)
(0.135111 -1.22241e-07 2.37954e-15)
(0.135111 -1.1871e-07 2.45527e-15)
(0.135111 -1.14611e-07 2.53154e-15)
(0.135111 -1.10024e-07 2.39552e-15)
(0.135111 -1.04984e-07 2.45885e-15)
(0.135111 -9.95023e-08 2.31392e-15)
(0.135111 -9.35826e-08 2.38148e-15)
(0.135111 -8.72323e-08 2.46648e-15)
(0.13511 -8.04646e-08 2.34549e-15)
(0.13511 -7.32997e-08 2.42999e-15)
(0.13511 -6.57632e-08 2.26838e-15)
(0.13511 -5.78844e-08 2.37328e-15)
(0.13511 -4.9695e-08 2.43951e-15)
(0.13511 -4.1228e-08 2.29375e-15)
(0.13511 -3.25178e-08 2.37166e-15)
(0.13511 -2.35984e-08 2.2372e-15)
(0.13511 -1.45069e-08 2.30083e-15)
(0.13511 -5.27759e-09 2.37521e-15)
(0.13511 4.04825e-09 2.23184e-15)
(0.13511 1.34402e-08 2.30946e-15)
(0.13511 2.28479e-08 2.1809e-15)
(0.13511 3.22586e-08 2.26116e-15)
(0.13511 4.15907e-08 2.37964e-15)
(0.135109 5.09044e-08 2.37968e-15)
(0.135109 5.99321e-08 2.24259e-15)
(0.135109 6.91786e-08 2.40732e-15)
(0.135109 7.66783e-08 2.43952e-15)
(0.135109 8.64602e-08 2.50574e-15)
(0.135109 8.30707e-08 2.47887e-15)
(0.135109 7.96157e-08 2.29529e-15)
(0.135109 7.77406e-08 2.49479e-15)
(0.135109 7.5624e-08 2.49979e-15)
(0.135109 9.08514e-08 2.55455e-15)
(0.135109 1.06938e-07 2.53674e-15)
(0.135109 1.21036e-07 2.41488e-15)
(0.135109 1.31566e-07 2.53397e-15)
(0.135109 1.38152e-07 2.56503e-15)
(0.135109 1.41069e-07 2.63175e-15)
(0.135109 1.41283e-07 2.60602e-15)
(0.135109 1.39711e-07 2.48245e-15)
(0.135109 1.37576e-07 2.57676e-15)
(0.135109 1.38226e-07 2.59633e-15)
(0.135109 1.40133e-07 2.66296e-15)
(0.135109 1.60994e-07 2.63382e-15)
(0.135109 1.75318e-07 2.53893e-15)
(0.135109 2.58821e-07 2.64854e-15)
(0.135902 5.87779e-08 2.79996e-15)
(0.135902 3.02083e-08 2.74143e-15)
(0.135902 -1.91161e-08 2.73013e-15)
(0.135902 -4.83964e-08 2.77431e-15)
(0.135902 -7.2346e-08 2.80755e-15)
(0.135902 -8.48203e-08 2.83884e-15)
(0.135902 -9.59838e-08 2.76928e-15)
(0.135902 -1.04635e-07 2.79827e-15)
(0.135902 -1.10443e-07 2.70897e-15)
(0.135902 -1.13781e-07 2.73813e-15)
(0.135902 -1.15009e-07 2.76576e-15)
(0.135902 -1.14592e-07 2.67924e-15)
(0.135902 -1.12945e-07 2.70086e-15)
(0.135902 -1.10384e-07 2.65951e-15)
(0.135902 -1.07123e-07 2.68043e-15)
(0.135902 -1.0329e-07 2.7099e-15)
(0.135902 -9.89515e-08 2.62547e-15)
(0.135901 -9.41374e-08 2.65612e-15)
(0.135901 -8.8858e-08 2.59914e-15)
(0.135901 -8.3119e-08 2.61302e-15)
(0.135901 -7.69289e-08 2.64957e-15)
(0.135901 -7.03029e-08 2.58676e-15)
(0.135901 -6.32627e-08 2.6214e-15)
(0.135901 -5.5836e-08 2.5889e-15)
(0.135901 -4.8054e-08 2.6029e-15)
(0.135901 -3.99507e-08 2.62104e-15)
(0.135901 -3.15612e-08 2.52755e-15)
(0.135901 -2.2922e-08 2.56981e-15)
(0.135901 -1.40694e-08 2.52193e-15)
(0.135901 -5.04217e-09 2.52905e-15)
(0.135901 4.1234e-09 2.55637e-15)
(0.1359 1.33841e-08 2.46551e-15)
(0.1359 2.27075e-08 2.50668e-15)
(0.1359 3.20403e-08 2.46133e-15)
(0.1359 4.13678e-08 2.49527e-15)
(0.1359 5.05997e-08 2.51433e-15)
(0.1359 5.97974e-08 2.56701e-15)
(0.1359 6.86579e-08 2.52396e-15)
(0.1359 7.7696e-08 2.57882e-15)
(0.1359 8.48901e-08 2.6455e-15)
(0.1359 9.3967e-08 2.63629e-15)
(0.1359 9.12618e-08 2.66241e-15)
(0.1359 8.80469e-08 2.62893e-15)
(0.1359 8.58835e-08 2.66482e-15)
(0.1359 8.28151e-08 2.71401e-15)
(0.1359 9.46337e-08 2.69278e-15)
(0.1359 1.07471e-07 2.72271e-15)
(0.1359 1.19235e-07 2.65391e-15)
(0.1359 1.28487e-07 2.71009e-15)
(0.1359 1.34609e-07 2.77837e-15)
(0.1359 1.37495e-07 2.76994e-15)
(0.1359 1.37839e-07 2.79833e-15)
(0.1359 1.36205e-07 2.73314e-15)
(0.1359 1.33895e-07 2.75921e-15)
(0.1359 1.33369e-07 2.81109e-15)
(0.1359 1.34323e-07 2.8014e-15)
(0.1359 1.50114e-07 2.83085e-15)
(0.1359 1.61764e-07 2.80143e-15)
(0.1359 2.26661e-07 2.82779e-15)
(0.136668 2.23397e-08 2.9682e-15)
(0.136668 9.76479e-09 2.95764e-15)
(0.136668 -3.0225e-08 2.92153e-15)
(0.136668 -5.36583e-08 2.988e-15)
(0.136668 -7.29938e-08 3.00303e-15)
(0.136668 -8.24402e-08 3.01421e-15)
(0.136668 -9.0705e-08 3.00148e-15)
(0.136668 -9.69826e-08 2.98967e-15)
(0.136668 -1.01059e-07 2.9576e-15)
(0.136668 -1.0325e-07 2.97558e-15)
(0.136668 -1.038e-07 2.94159e-15)
(0.136668 -1.03041e-07 2.91298e-15)
(0.136668 -1.01268e-07 2.90681e-15)
(0.136668 -9.87117e-08 2.89703e-15)
(0.136668 -9.55279e-08 2.92222e-15)
(0.136667 -9.18084e-08 2.8945e-15)
(0.136667 -8.75988e-08 2.87282e-15)
(0.136667 -8.29166e-08 2.8648e-15)
(0.136667 -7.77662e-08 2.84385e-15)
(0.136667 -7.21497e-08 2.86312e-15)
(0.136667 -6.60742e-08 2.83966e-15)
(0.136667 -5.95538e-08 2.82697e-15)
(0.136667 -5.26101e-08 2.83042e-15)
(0.136667 -4.5271e-08 2.82725e-15)
(0.136667 -3.75684e-08 2.84568e-15)
(0.136667 -2.95376e-08 2.80906e-15)
(0.136667 -2.12151e-08 2.7821e-15)
(0.136667 -1.2639e-08 2.78228e-15)
(0.136666 -3.84736e-09 2.76387e-15)
(0.136666 5.11942e-09 2.77644e-15)
(0.136666 1.42234e-08 2.74587e-15)
(0.136666 2.34195e-08 2.72056e-15)
(0.136666 3.26734e-08 2.72034e-15)
(0.136666 4.19288e-08 2.71251e-15)
(0.136666 5.11687e-08 2.74556e-15)
(0.136666 6.02948e-08 2.65828e-15)
(0.136666 6.93679e-08 2.77031e-15)
(0.136666 7.80556e-08 2.78516e-15)
(0.136666 8.68703e-08 2.76876e-15)
(0.136666 9.37813e-08 2.86753e-15)
(0.136666 1.02192e-07 2.76221e-15)
(0.136666 1.0009e-07 2.85669e-15)
(0.136666 9.7181e-08 2.88174e-15)
(0.136665 9.49947e-08 2.85536e-15)
(0.136665 9.15167e-08 2.93941e-15)
(0.136665 1.0072e-07 2.82279e-15)
(0.136665 1.10803e-07 2.92098e-15)
(0.136665 1.20251e-07 2.92873e-15)
(0.136665 1.27873e-07 2.90292e-15)
(0.136665 1.33019e-07 3.0034e-15)
(0.136665 1.35358e-07 2.9001e-15)
(0.136665 1.35387e-07 2.99971e-15)
(0.136665 1.33324e-07 3.01698e-15)
(0.136665 1.30532e-07 2.96027e-15)
(0.136665 1.28562e-07 3.04201e-15)
(0.136665 1.28267e-07 2.93548e-15)
(0.136665 1.38786e-07 3.03841e-15)
(0.136666 1.47132e-07 3.05753e-15)
(0.136666 1.9458e-07 3.02434e-15)
(0.137409 -1.30106e-08 3.13855e-15)
(0.137409 -1.10001e-08 3.17196e-15)
(0.137409 -4.22115e-08 3.11055e-15)
(0.137409 -6.02117e-08 3.20655e-15)
(0.137409 -7.52337e-08 3.20123e-15)
(0.137409 -8.18338e-08 3.19165e-15)
(0.137409 -8.73295e-08 3.21966e-15)
(0.137409 -9.12286e-08 3.17719e-15)
(0.137409 -9.34269e-08 3.18886e-15)
(0.137409 -9.4225e-08 3.21635e-15)
(0.137409 -9.38069e-08 3.10557e-15)
(0.137409 -9.24111e-08 3.14367e-15)
(0.137409 -9.0244e-08 3.11251e-15)
(0.137409 -8.74594e-08 3.13694e-15)
(0.137409 -8.4157e-08 3.17293e-15)
(0.137409 -8.03893e-08 3.06802e-15)
(0.137409 -7.6176e-08 3.11012e-15)
(0.137409 -7.15176e-08 3.07502e-15)
(0.137409 -6.64079e-08 3.09197e-15)
(0.137409 -6.08421e-08 3.12324e-15)
(0.137409 -5.48224e-08 3.02026e-15)
(0.137408 -4.83597e-08 3.06809e-15)
(0.137408 -4.14734e-08 3.04183e-15)
(0.137408 -3.41898e-08 3.0677e-15)
(0.137408 -2.65404e-08 3.09767e-15)
(0.137408 -1.85605e-08 2.987e-15)
(0.137408 -1.02871e-08 3.02607e-15)
(0.137408 -1.75956e-09 2.99594e-15)
(0.137408 6.98317e-09 3.01037e-15)
(0.137408 1.58992e-08 3.03443e-15)
(0.137408 2.49491e-08 2.92541e-15)
(0.137408 3.40863e-08 2.96476e-15)
(0.137408 4.32745e-08 2.93528e-15)
(0.137408 5.24545e-08 2.96147e-15)
(0.137408 6.1607e-08 3.00273e-15)
(0.137407 7.0626e-08 2.86942e-15)
(0.137407 7.95702e-08 2.93309e-15)
(0.137407 8.80841e-08 3.0685e-15)
(0.137407 9.66667e-08 2.9503e-15)
(0.137407 1.03315e-07 3.02628e-15)
(0.137407 1.11108e-07 2.94279e-15)
(0.137407 1.09531e-07 3.00809e-15)
(0.137407 1.06942e-07 3.19292e-15)
(0.137407 1.04867e-07 3.03495e-15)
(0.137407 1.01311e-07 3.09649e-15)
(0.137407 1.08518e-07 3.00428e-15)
(0.137407 1.1635e-07 3.07534e-15)
(0.137407 1.23678e-07 3.24698e-15)
(0.137407 1.29558e-07 3.08529e-15)
(0.137407 1.33416e-07 3.16172e-15)
(0.137407 1.34819e-07 3.08177e-15)
(0.137407 1.34145e-07 3.1545e-15)
(0.137407 1.31305e-07 3.254e-15)
(0.137407 1.27716e-07 3.15465e-15)
(0.137407 1.24022e-07 3.20847e-15)
(0.137407 1.22158e-07 3.12462e-15)
(0.137407 1.2722e-07 3.20155e-15)
(0.137407 1.31663e-07 3.3017e-15)
(0.137407 1.62748e-07 3.21365e-15)
(0.138127 -4.72476e-08 3.31025e-15)
(0.138127 -3.19302e-08 3.30608e-15)
(0.138127 -5.4808e-08 3.28451e-15)
(0.138127 -6.77036e-08 3.44197e-15)
(0.138127 -7.86655e-08 3.38518e-15)
(0.138127 -8.25969e-08 3.3697e-15)
(0.138127 -8.54942e-08 3.35529e-15)
(0.138127 -8.70942e-08 3.34931e-15)
(0.138127 -8.73794e-08 3.33633e-15)
(0.138127 -8.66512e-08 3.36752e-15)
(0.138127 -8.50686e-08 3.32374e-15)
(0.138127 -8.28139e-08 3.30644e-15)
(0.138127 -8.00294e-08 3.30539e-15)
(0.138127 -7.68096e-08 3.30104e-15)
(0.138127 -7.32046e-08 3.3375e-15)
(0.138127 -6.92296e-08 3.2967e-15)
(0.138126 -6.48768e-08 3.28221e-15)
(0.138126 -6.01276e-08 3.27536e-15)
(0.138126 -5.4962e-08 3.26475e-15)
(0.138126 -4.93657e-08 3.29785e-15)
(0.138126 -4.33337e-08 3.25731e-15)
(0.138126 -3.68716e-08 3.24489e-15)
(0.138126 -2.99945e-08 3.24274e-15)
(0.138126 -2.27261e-08 3.23359e-15)
(0.138126 -1.50958e-08 3.26477e-15)
(0.138126 -7.13786e-09 3.22113e-15)
(0.138126 1.11083e-09 3.20256e-15)
(0.138126 9.61083e-09 3.19829e-15)
(0.138126 1.83224e-08 3.18144e-15)
(0.138125 2.72029e-08 3.2058e-15)
(0.138125 3.62116e-08 3.16016e-15)
(0.138125 4.53005e-08 3.14148e-15)
(0.138125 5.44317e-08 3.1383e-15)
(0.138125 6.3543e-08 3.13279e-15)
(0.138125 7.26126e-08 3.17272e-15)
(0.138125 8.15278e-08 3.12529e-15)
(0.138125 9.03435e-08 3.14121e-15)
(0.138125 9.86868e-08 3.20231e-15)
(0.138125 1.07035e-07 3.18323e-15)
(0.138125 1.13441e-07 3.21388e-15)
(0.138125 1.20666e-07 3.18391e-15)
(0.138125 1.19548e-07 3.20362e-15)
(0.138125 1.17269e-07 3.28151e-15)
(0.138124 1.15363e-07 3.25776e-15)
(0.138124 1.11912e-07 3.27805e-15)
(0.138124 1.17582e-07 3.24422e-15)
(0.138124 1.23605e-07 3.27284e-15)
(0.138124 1.29086e-07 3.3421e-15)
(0.138124 1.3327e-07 3.31337e-15)
(0.138124 1.35697e-07 3.34631e-15)
(0.138124 1.35906e-07 3.32132e-15)
(0.138124 1.34225e-07 3.35221e-15)
(0.138124 1.30303e-07 3.43401e-15)
(0.138124 1.25619e-07 3.38681e-15)
(0.138124 1.19928e-07 3.40463e-15)
(0.138124 1.16173e-07 3.37442e-15)
(0.138124 1.15614e-07 3.4073e-15)
(0.138124 1.15595e-07 3.47777e-15)
(0.138124 1.31342e-07 3.45283e-15)
(0.138821 -8.03546e-08 3.47807e-15)
(0.138821 -5.29092e-08 3.43786e-15)
(0.138821 -6.78221e-08 3.45804e-15)
(0.138821 -7.58714e-08 3.54857e-15)
(0.138821 -8.29743e-08 3.56186e-15)
(0.138821 -8.43885e-08 3.54238e-15)
(0.138821 -8.48656e-08 3.48847e-15)
(0.138821 -8.42917e-08 3.52042e-15)
(0.138821 -8.27047e-08 3.48212e-15)
(0.138821 -8.04065e-08 3.52977e-15)
(0.138821 -7.75494e-08 3.52435e-15)
(0.138821 -7.42847e-08 3.46962e-15)
(0.138821 -7.0714e-08 3.49903e-15)
(0.138821 -6.6889e-08 3.46831e-15)
(0.138821 -6.28211e-08 3.51595e-15)
(0.138821 -5.84929e-08 3.50905e-15)
(0.138821 -5.3871e-08 3.45915e-15)
(0.138821 -4.89174e-08 3.47968e-15)
(0.13882 -4.35974e-08 3.44062e-15)
(0.13882 -3.78854e-08 3.48656e-15)
(0.13882 -3.17677e-08 3.47883e-15)
(0.13882 -2.52429e-08 3.42528e-15)
(0.13882 -1.83209e-08 3.44718e-15)
(0.13882 -1.1021e-08 3.40354e-15)
(0.13882 -3.36961e-09 3.44656e-15)
(0.13882 4.60106e-09 3.43967e-15)
(0.13882 1.28553e-08 3.3802e-15)
(0.13882 2.13541e-08 3.40251e-15)
(0.13882 3.00576e-08 3.35432e-15)
(0.13882 3.89227e-08 3.38933e-15)
(0.13882 4.79079e-08 3.37782e-15)
(0.138819 5.69639e-08 3.32063e-15)
(0.138819 6.6051e-08 3.34307e-15)
(0.138819 7.51048e-08 3.30246e-15)
(0.138819 8.41006e-08 3.35438e-15)
(0.138819 9.29198e-08 3.36304e-15)
(0.138819 1.01612e-07 3.36767e-15)
(0.138819 1.09792e-07 3.38858e-15)
(0.138819 1.1791e-07 3.40064e-15)
(0.138819 1.24094e-07 3.41272e-15)
(0.138819 1.30805e-07 3.41443e-15)
(0.138819 1.30089e-07 3.41907e-15)
(0.138819 1.281e-07 3.45065e-15)
(0.138819 1.26376e-07 3.46194e-15)
(0.138819 1.23121e-07 3.4685e-15)
(0.138818 1.27584e-07 3.47236e-15)
(0.138818 1.32159e-07 3.48986e-15)
(0.138818 1.36073e-07 3.51914e-15)
(0.138818 1.38694e-07 3.52522e-15)
(0.138818 1.39669e-07 3.53969e-15)
(0.138818 1.38545e-07 3.54766e-15)
(0.138818 1.35643e-07 3.56718e-15)
(0.138818 1.30396e-07 3.60285e-15)
(0.138818 1.24353e-07 3.60455e-15)
(0.138818 1.16418e-07 3.61004e-15)
(0.138818 1.10456e-07 3.61284e-15)
(0.138818 1.04145e-07 3.63183e-15)
(0.138818 9.91593e-08 3.66506e-15)
(0.138818 1.00533e-07 3.67613e-15)
(0.139492 -1.12315e-07 3.64038e-15)
(0.139492 -7.38421e-08 3.63938e-15)
(0.139492 -8.11104e-08 3.64768e-15)
(0.139492 -8.45199e-08 3.72959e-15)
(0.139492 -8.79179e-08 3.7274e-15)
(0.139492 -8.69319e-08 3.70825e-15)
(0.139492 -8.51535e-08 3.69303e-15)
(0.139492 -8.25477e-08 3.70487e-15)
(0.139492 -7.91755e-08 3.70812e-15)
(0.139492 -7.53282e-08 3.71451e-15)
(0.139492 -7.11573e-08 3.71713e-15)
(0.139492 -6.67977e-08 3.71173e-15)
(0.139492 -6.23274e-08 3.70627e-15)
(0.139492 -5.77706e-08 3.71933e-15)
(0.139492 -5.31108e-08 3.71967e-15)
(0.139492 -4.83051e-08 3.71473e-15)
(0.139492 -4.32987e-08 3.71929e-15)
(0.139492 -3.80355e-08 3.70089e-15)
(0.139492 -3.24667e-08 3.69879e-15)
(0.139491 -2.6555e-08 3.69988e-15)
(0.139491 -2.02773e-08 3.6943e-15)
(0.139491 -1.36245e-08 3.68095e-15)
(0.139491 -6.60019e-09 3.66816e-15)
(0.139491 7.81558e-10 3.65785e-15)
(0.139491 8.4982e-09 3.65396e-15)
(0.139491 1.65205e-08 3.65224e-15)
(0.139491 2.48147e-08 3.6342e-15)
(0.139491 3.33428e-08 3.62091e-15)
(0.139491 4.20656e-08 3.60649e-15)
(0.139491 5.09397e-08 3.59632e-15)
(0.139491 5.9923e-08 3.5878e-15)
(0.139491 6.89654e-08 3.58237e-15)
(0.139491 7.80258e-08 3.56346e-15)
(0.13949 8.70374e-08 3.54147e-15)
(0.13949 9.59726e-08 3.55701e-15)
(0.13949 1.04708e-07 3.60194e-15)
(0.13949 1.13286e-07 3.60051e-15)
(0.13949 1.21315e-07 3.58212e-15)
(0.13949 1.29212e-07 3.61888e-15)
(0.13949 1.35197e-07 3.6154e-15)
(0.13949 1.41447e-07 3.64634e-15)
(0.13949 1.41086e-07 3.64225e-15)
(0.13949 1.39367e-07 3.63021e-15)
(0.13949 1.37819e-07 3.66889e-15)
(0.13949 1.34791e-07 3.66276e-15)
(0.13949 1.3828e-07 3.70286e-15)
(0.139489 1.41682e-07 3.71611e-15)
(0.139489 1.44281e-07 3.70874e-15)
(0.139489 1.4551e-07 3.73889e-15)
(0.139489 1.45089e-07 3.73523e-15)
(0.139489 1.42584e-07 3.77423e-15)
(0.139489 1.38333e-07 3.78982e-15)
(0.139489 1.31584e-07 3.79094e-15)
(0.139489 1.23964e-07 3.82175e-15)
(0.139489 1.13575e-07 3.81757e-15)
(0.139489 1.05116e-07 3.85133e-15)
(0.139489 9.29593e-08 3.86381e-15)
(0.139489 8.25619e-08 3.86273e-15)
(0.139489 7.04865e-08 3.89927e-15)
(0.14014 -1.43112e-07 3.80219e-15)
(0.14014 -9.4644e-08 3.85993e-15)
(0.14014 -9.45596e-08 3.83962e-15)
(0.14014 -9.35013e-08 3.83986e-15)
(0.14014 -9.33119e-08 3.87285e-15)
(0.14014 -9.00082e-08 3.87277e-15)
(0.140141 -8.61153e-08 3.87874e-15)
(0.140141 -8.16172e-08 3.88963e-15)
(0.14014 -7.65691e-08 3.96987e-15)
(0.14014 -7.1236e-08 3.90699e-15)
(0.14014 -6.57652e-08 3.90927e-15)
(0.14014 -6.02816e-08 3.91573e-15)
(0.14014 -5.48502e-08 3.9159e-15)
(0.14014 -4.9479e-08 3.99523e-15)
(0.14014 -4.41338e-08 3.93189e-15)
(0.14014 -3.87537e-08 3.92166e-15)
(0.14014 -3.32671e-08 3.96978e-15)
(0.14014 -2.76036e-08 3.92477e-15)
(0.14014 -2.17012e-08 3.98646e-15)
(0.14014 -1.5512e-08 3.92067e-15)
(0.14014 -9.00375e-09 3.91204e-15)
(0.14014 -2.15931e-09 3.90983e-15)
(0.14014 5.02452e-09 3.8893e-15)
(0.14014 1.25393e-08 3.87149e-15)
(0.14014 2.0367e-08 3.87114e-15)
(0.14014 2.84819e-08 3.86658e-15)
(0.140139 3.68529e-08 3.93175e-15)
(0.140139 4.54438e-08 3.841e-15)
(0.140139 5.42159e-08 3.89296e-15)
(0.140139 6.31263e-08 3.80968e-15)
(0.140139 7.21327e-08 3.79851e-15)
(0.140139 8.11842e-08 3.7984e-15)
(0.140139 9.02383e-08 3.78804e-15)
(0.140139 9.92265e-08 3.83641e-15)
(0.140139 1.08118e-07 3.7641e-15)
(0.140139 1.16785e-07 3.85623e-15)
(0.140139 1.25262e-07 3.83154e-15)
(0.140139 1.33157e-07 3.77334e-15)
(0.140139 1.40848e-07 3.84825e-15)
(0.140139 1.46658e-07 3.81539e-15)
(0.140138 1.52501e-07 3.88776e-15)
(0.140138 1.52456e-07 3.86353e-15)
(0.140138 1.50988e-07 3.80982e-15)
(0.140138 1.49602e-07 3.89074e-15)
(0.140138 1.46803e-07 3.85678e-15)
(0.140138 1.49481e-07 3.9474e-15)
(0.140138 1.51916e-07 3.94436e-15)
(0.140138 1.53408e-07 3.89868e-15)
(0.140138 1.53415e-07 3.96963e-15)
(0.140138 1.51699e-07 3.92925e-15)
(0.140138 1.4783e-07 4.01282e-15)
(0.140138 1.42168e-07 4.01342e-15)
(0.140138 1.33805e-07 3.98046e-15)
(0.140138 1.24441e-07 4.04681e-15)
(0.140138 1.11432e-07 4.02068e-15)
(0.140138 1.0022e-07 4.09916e-15)
(0.140138 8.21689e-08 4.09449e-15)
(0.140138 6.59844e-08 4.06026e-15)
(0.140138 4.13461e-08 4.13318e-15)
(0.140766 -1.7272e-07 3.96628e-15)
(0.140766 -1.15233e-07 4.00379e-15)
(0.140767 -1.08074e-07 4.02548e-15)
(0.140767 -1.02699e-07 4.01545e-15)
(0.140767 -9.90148e-08 4.03123e-15)
(0.140767 -9.3447e-08 4.04141e-15)
(0.140767 -8.75535e-08 4.06204e-15)
(0.140767 -8.12899e-08 4.07064e-15)
(0.140767 -7.46806e-08 4.09651e-15)
(0.140767 -6.79486e-08 4.08438e-15)
(0.140767 -6.12289e-08 4.10918e-15)
(0.140767 -5.46358e-08 4.13097e-15)
(0.140767 -4.82261e-08 4.10929e-15)
(0.140767 -4.19994e-08 4.1382e-15)
(0.140767 -3.59112e-08 4.12818e-15)
(0.140766 -2.98895e-08 4.13821e-15)
(0.140766 -2.38513e-08 4.16225e-15)
(0.140766 -1.77151e-08 4.12793e-15)
(0.140766 -1.14087e-08 4.1374e-15)
(0.140766 -4.87499e-09 4.12558e-15)
(0.140766 1.92693e-09 4.13773e-15)
(0.140766 9.02153e-09 4.13935e-15)
(0.140766 1.64187e-08 4.10017e-15)
(0.140766 2.41156e-08 4.09491e-15)
(0.140766 3.20993e-08 4.07278e-15)
(0.140766 4.03479e-08 4.09076e-15)
(0.140766 4.88331e-08 4.09003e-15)
(0.140766 5.75209e-08 4.04877e-15)
(0.140766 6.63738e-08 4.03962e-15)
(0.140766 7.53496e-08 4.00851e-15)
(0.140765 8.4406e-08 4.01965e-15)
(0.140765 9.34916e-08 4.03057e-15)
(0.140765 1.02563e-07 3.99138e-15)
(0.140765 1.11549e-07 3.97637e-15)
(0.140765 1.20416e-07 3.97115e-15)
(0.140765 1.29034e-07 4.03959e-15)
(0.140765 1.37428e-07 4.04327e-15)
(0.140765 1.45207e-07 3.95499e-15)
(0.140765 1.52711e-07 4.06835e-15)
(0.140765 1.58374e-07 3.99847e-15)
(0.140765 1.63863e-07 4.12862e-15)
(0.140765 1.64104e-07 4.06493e-15)
(0.140765 1.62873e-07 3.97884e-15)
(0.140765 1.61632e-07 4.06618e-15)
(0.140764 1.59046e-07 4.03657e-15)
(0.140764 1.61033e-07 4.18686e-15)
(0.140764 1.6265e-07 4.15703e-15)
(0.140764 1.63201e-07 4.07698e-15)
(0.140764 1.6214e-07 4.11229e-15)
(0.140764 1.59241e-07 4.11233e-15)
(0.140764 1.54064e-07 4.18067e-15)
(0.140764 1.46984e-07 4.22298e-15)
(0.140764 1.36947e-07 4.15982e-15)
(0.140764 1.25721e-07 4.27439e-15)
(0.140764 1.09977e-07 4.20671e-15)
(0.140764 9.57974e-08 4.28238e-15)
(0.140764 7.18502e-08 4.30806e-15)
(0.140764 4.95773e-08 4.24883e-15)
(0.140764 1.32351e-08 4.29746e-15)
(0.141371 -2.01113e-07 4.13346e-15)
(0.141371 -1.35526e-07 4.18162e-15)
(0.141371 -1.21564e-07 4.21397e-15)
(0.141371 -1.12015e-07 4.18664e-15)
(0.141371 -1.04915e-07 4.20425e-15)
(0.141371 -9.71153e-08 4.21489e-15)
(0.141371 -8.93105e-08 4.2381e-15)
(0.141371 -8.13901e-08 4.25173e-15)
(0.141371 -7.33297e-08 4.26751e-15)
(0.141371 -6.52955e-08 4.25821e-15)
(0.141371 -5.74003e-08 4.31496e-15)
(0.141371 -4.97435e-08 4.31655e-15)
(0.141371 -4.23741e-08 4.29561e-15)
(0.141371 -3.52867e-08 4.31122e-15)
(0.141371 -2.84317e-08 4.33268e-15)
(0.141371 -2.17311e-08 4.36267e-15)
(0.141371 -1.50955e-08 4.35001e-15)
(0.141371 -8.43563e-09 4.32176e-15)
(0.141371 -1.67225e-09 4.32204e-15)
(0.141371 5.25937e-09 4.3328e-15)
(0.141371 1.2407e-08 4.36985e-15)
(0.141371 1.98018e-08 4.34566e-15)
(0.141371 2.74596e-08 4.29945e-15)
(0.14137 3.53833e-08 4.28249e-15)
(0.14137 4.35644e-08 4.26999e-15)
(0.14137 5.19852e-08 4.3296e-15)
(0.14137 6.06205e-08 4.2976e-15)
(0.14137 6.94387e-08 4.25329e-15)
(0.14137 7.84038e-08 4.22734e-15)
(0.14137 8.74744e-08 4.20109e-15)
(0.14137 9.66083e-08 4.25857e-15)
(0.14137 1.05754e-07 4.22458e-15)
(0.14137 1.14866e-07 4.19396e-15)
(0.14137 1.23874e-07 4.17726e-15)
(0.14137 1.32739e-07 4.17434e-15)
(0.14137 1.41329e-07 4.16066e-15)
(0.14137 1.4966e-07 4.24513e-15)
(0.141369 1.57346e-07 4.11516e-15)
(0.141369 1.64688e-07 4.07883e-15)
(0.141369 1.70231e-07 4.17416e-15)
(0.141369 1.7542e-07 4.16117e-15)
(0.141369 1.75923e-07 4.25827e-15)
(0.141369 1.74918e-07 4.11529e-15)
(0.141369 1.7381e-07 4.10733e-15)
(0.141369 1.71415e-07 4.21243e-15)
(0.141369 1.72801e-07 4.22527e-15)
(0.141369 1.73709e-07 4.35475e-15)
(0.141369 1.73444e-07 4.22277e-15)
(0.141369 1.71444e-07 4.19629e-15)
(0.141369 1.67474e-07 4.28418e-15)
(0.141369 1.61066e-07 4.292e-15)
(0.141369 1.52593e-07 4.4232e-15)
(0.141369 1.40868e-07 4.30802e-15)
(0.141369 1.27706e-07 4.28713e-15)
(0.141369 1.09156e-07 4.38411e-15)
(0.141369 9.18382e-08 4.40048e-15)
(0.141369 6.20445e-08 4.51179e-15)
(0.141369 3.34595e-08 4.41362e-15)
(0.141369 -1.37486e-08 4.39693e-15)
(0.141954 -2.28257e-07 4.32337e-15)
(0.141954 -1.5544e-07 4.37138e-15)
(0.141954 -1.34947e-07 4.39903e-15)
(0.141954 -1.21361e-07 4.35523e-15)
(0.141954 -1.10919e-07 4.4131e-15)
(0.141954 -1.00907e-07 4.36522e-15)
(0.141954 -9.12605e-08 4.41684e-15)
(0.141954 -8.17743e-08 4.39144e-15)
(0.141954 -7.23625e-08 4.44947e-15)
(0.141954 -6.31235e-08 4.49344e-15)
(0.141954 -5.41378e-08 4.51213e-15)
(0.141954 -4.54836e-08 4.5037e-15)
(0.141954 -3.71995e-08 4.48857e-15)
(0.141954 -2.92755e-08 4.49085e-15)
(0.141954 -2.16594e-08 4.56219e-15)
(0.141954 -1.42708e-08 4.57978e-15)
(0.141954 -7.01699e-09 4.53617e-15)
(0.141954 1.95019e-10 4.48145e-15)
(0.141954 7.4494e-09 4.50944e-15)
(0.141954 1.4816e-08 4.56867e-15)
(0.141954 2.23482e-08 4.58622e-15)
(0.141954 3.00822e-08 4.53829e-15)
(0.141954 3.80392e-08 4.46469e-15)
(0.141953 4.62268e-08 4.47635e-15)
(0.141953 5.46411e-08 4.51811e-15)
(0.141953 6.32682e-08 4.46414e-15)
(0.141953 7.20861e-08 4.4995e-15)
(0.141953 8.10655e-08 4.48136e-15)
(0.141953 9.01722e-08 4.42592e-15)
(0.141953 9.93657e-08 4.37858e-15)
(0.141953 1.08604e-07 4.38754e-15)
(0.141953 1.17836e-07 4.4197e-15)
(0.141953 1.27014e-07 4.34944e-15)
(0.141953 1.36067e-07 4.37377e-15)
(0.141953 1.44954e-07 4.35113e-15)
(0.141953 1.53538e-07 4.26246e-15)
(0.141953 1.61829e-07 4.34366e-15)
(0.141953 1.69446e-07 4.19386e-15)
(0.141952 1.76651e-07 4.14111e-15)
(0.141952 1.82105e-07 4.26171e-15)
(0.141952 1.87046e-07 4.24985e-15)
(0.141952 1.87794e-07 4.43009e-15)
(0.141952 1.87011e-07 4.17071e-15)
(0.141952 1.86025e-07 4.16555e-15)
(0.141952 1.83799e-07 4.37328e-15)
(0.141952 1.84656e-07 4.31669e-15)
(0.141952 1.84939e-07 4.4703e-15)
(0.141952 1.83954e-07 4.31475e-15)
(0.141952 1.8112e-07 4.25552e-15)
(0.141952 1.76179e-07 4.39084e-15)
(0.141952 1.6862e-07 4.38946e-15)
(0.141952 1.58801e-07 4.54691e-15)
(0.141952 1.45402e-07 4.37562e-15)
(0.141952 1.30269e-07 4.36754e-15)
(0.141952 1.08884e-07 4.50296e-15)
(0.141952 8.83037e-08 4.5101e-15)
(0.141952 5.27616e-08 4.68146e-15)
(0.141952 1.77196e-08 4.55033e-15)
(0.141952 -3.95325e-08 4.49489e-15)
(0.142516 -2.54114e-07 4.35643e-15)
(0.142516 -1.74886e-07 4.42304e-15)
(0.142516 -1.48138e-07 4.42801e-15)
(0.142516 -1.30654e-07 4.42742e-15)
(0.142516 -1.16946e-07 4.41201e-15)
(0.142516 -1.04736e-07 4.41097e-15)
(0.142516 -9.33021e-08 4.43742e-15)
(0.142516 -8.23254e-08 4.437e-15)
(0.142516 -7.16504e-08 4.46039e-15)
(0.142516 -6.12995e-08 4.49008e-15)
(0.142516 -5.13118e-08 4.48989e-15)
(0.142516 -4.17383e-08 4.54714e-15)
(0.142516 -3.26027e-08 4.50494e-15)
(0.142516 -2.38885e-08 4.50656e-15)
(0.142516 -1.55413e-08 4.57162e-15)
(0.142516 -7.48009e-09 4.55266e-15)
(0.142516 3.88821e-10 4.57591e-15)
(0.142516 8.15986e-09 4.5299e-15)
(0.142516 1.59196e-08 4.53007e-15)
(0.142516 2.37412e-08 4.57639e-15)
(0.142516 3.16815e-08 4.55888e-15)
(0.142516 3.9781e-08 4.573e-15)
(0.142515 4.80647e-08 4.51735e-15)
(0.142515 5.65444e-08 4.50351e-15)
(0.142515 6.522e-08 4.52274e-15)
(0.142515 7.40812e-08 4.52148e-15)
(0.142515 8.31088e-08 4.53781e-15)
(0.142515 9.2276e-08 4.47098e-15)
(0.142515 1.0155e-07 4.46318e-15)
(0.142515 1.10892e-07 4.45713e-15)
(0.142515 1.2026e-07 4.44724e-15)
(0.142515 1.29602e-07 4.44816e-15)
(0.142515 1.3887e-07 4.40427e-15)
(0.142515 1.47992e-07 4.39287e-15)
(0.142515 1.56923e-07 4.42275e-15)
(0.142515 1.65525e-07 4.32615e-15)
(0.142515 1.73799e-07 4.40943e-15)
(0.142515 1.81374e-07 4.2614e-15)
(0.142514 1.88472e-07 4.19287e-15)
(0.142514 1.93866e-07 4.3251e-15)
(0.142514 1.98611e-07 4.31954e-15)
(0.142514 1.99593e-07 4.43426e-15)
(0.142514 1.99027e-07 4.26756e-15)
(0.142514 1.98161e-07 4.24739e-15)
(0.142514 1.96086e-07 4.37811e-15)
(0.142514 1.96475e-07 4.39048e-15)
(0.142514 1.96196e-07 4.54478e-15)
(0.142514 1.94565e-07 4.38205e-15)
(0.142514 1.9098e-07 4.3276e-15)
(0.142514 1.85153e-07 4.46891e-15)
(0.142514 1.76523e-07 4.47143e-15)
(0.142514 1.65414e-07 4.63158e-15)
(0.142514 1.5038e-07 4.49459e-15)
(0.142514 1.33266e-07 4.45532e-15)
(0.142514 1.09057e-07 4.58251e-15)
(0.142514 8.51312e-08 4.61243e-15)
(0.142514 4.39852e-08 4.73927e-15)
(0.142514 2.4192e-09 4.62676e-15)
(0.142514 -6.40684e-08 4.60445e-15)
(0.143057 -2.78641e-07 4.41344e-15)
(0.143057 -1.93774e-07 4.53018e-15)
(0.143057 -1.6105e-07 4.45119e-15)
(0.143057 -1.3981e-07 4.51766e-15)
(0.143057 -1.22918e-07 4.43501e-15)
(0.143057 -1.08525e-07 4.43347e-15)
(0.143057 -9.5351e-08 4.45752e-15)
(0.143057 -8.29477e-08 4.43846e-15)
(0.143057 -7.10869e-08 4.46557e-15)
(0.143057 -5.97097e-08 4.55545e-15)
(0.143057 -4.88078e-08 4.52312e-15)
(0.143057 -3.83984e-08 4.56078e-15)
(0.143057 -2.84856e-08 4.52553e-15)
(0.143057 -1.90436e-08 4.51293e-15)
(0.143057 -1.00144e-08 4.61288e-15)
(0.143057 -1.31632e-09 4.58089e-15)
(0.143057 7.14388e-09 4.58535e-15)
(0.143057 1.54607e-08 4.54123e-15)
(0.143057 2.37213e-08 4.6003e-15)
(0.143057 3.20004e-08 4.62116e-15)
(0.143057 4.0357e-08 4.57944e-15)
(0.143057 4.88341e-08 4.58375e-15)
(0.143057 5.746e-08 4.53036e-15)
(0.143057 6.62492e-08 4.50312e-15)
(0.143057 7.52051e-08 4.58205e-15)
(0.143057 8.432e-08 4.53597e-15)
(0.143057 9.35778e-08 4.54436e-15)
(0.143057 1.02954e-07 4.47995e-15)
(0.143056 1.12416e-07 4.46116e-15)
(0.143056 1.21928e-07 4.52678e-15)
(0.143056 1.31446e-07 4.45844e-15)
(0.143056 1.4092e-07 4.52652e-15)
(0.143056 1.503e-07 4.40904e-15)
(0.143056 1.59513e-07 4.39602e-15)
(0.143056 1.6851e-07 4.47709e-15)
(0.143056 1.77155e-07 4.33384e-15)
(0.143056 1.85435e-07 4.47212e-15)
(0.143056 1.92994e-07 4.35254e-15)
(0.143056 2.00014e-07 4.29214e-15)
(0.143056 2.05379e-07 4.40619e-15)
(0.143056 2.09978e-07 4.34539e-15)
(0.143056 2.11188e-07 4.52609e-15)
(0.143056 2.1084e-07 4.39635e-15)
(0.143056 2.10092e-07 4.28854e-15)
(0.143056 2.08155e-07 4.47392e-15)
(0.143055 2.0813e-07 4.48754e-15)
(0.143055 2.07345e-07 4.6424e-15)
(0.143055 2.05127e-07 4.44567e-15)
(0.143055 2.00857e-07 4.38475e-15)
(0.143055 1.94217e-07 4.58371e-15)
(0.143055 1.84587e-07 4.59761e-15)
(0.143055 1.72248e-07 4.74122e-15)
(0.143055 1.55628e-07 4.63997e-15)
(0.143055 1.36548e-07 4.59349e-15)
(0.143055 1.09555e-07 4.70688e-15)
(0.143055 8.22417e-08 4.73338e-15)
(0.143055 3.56784e-08 4.86405e-15)
(0.143055 -1.24034e-08 4.75792e-15)
(0.143055 -8.73298e-08 4.73798e-15)
(0.143578 -3.01792e-07 4.56521e-15)
(0.143578 -2.1201e-07 4.53051e-15)
(0.143578 -1.73594e-07 4.54013e-15)
(0.143578 -1.48747e-07 4.48362e-15)
(0.143578 -1.28762e-07 4.51119e-15)
(0.143578 -1.12206e-07 4.54973e-15)
(0.143578 -9.73343e-08 4.49108e-15)
(0.143578 -8.3561e-08 4.51336e-15)
(0.143578 -7.05828e-08 4.48352e-15)
(0.143578 -5.82584e-08 4.55807e-15)
(0.143578 -4.65263e-08 4.62074e-15)
(0.143578 -3.53655e-08 4.60809e-15)
(0.143578 -2.47559e-08 4.59211e-15)
(0.143578 -1.46589e-08 4.51461e-15)
(0.143578 -5.01061e-09 4.6047e-15)
(0.143578 4.27214e-09 4.67324e-15)
(0.143578 1.32824e-08 4.61941e-15)
(0.143578 2.21139e-08 4.59902e-15)
(0.143578 3.08535e-08 4.53935e-15)
(0.143578 3.9576e-08 4.60913e-15)
(0.143578 4.83415e-08 4.66093e-15)
(0.143578 5.71944e-08 4.60395e-15)
(0.143578 6.61648e-08 4.59363e-15)
(0.143578 7.52695e-08 4.50095e-15)
(0.143578 8.45141e-08 4.56603e-15)
(0.143578 9.38936e-08 4.61896e-15)
(0.143578 1.03394e-07 4.57484e-15)
(0.143578 1.12992e-07 4.5391e-15)
(0.143578 1.22658e-07 4.48181e-15)
(0.143578 1.32355e-07 4.5123e-15)
(0.143578 1.42041e-07 4.54247e-15)
(0.143577 1.51664e-07 4.49422e-15)
(0.143577 1.61175e-07 4.47031e-15)
(0.143577 1.70498e-07 4.40516e-15)
(0.143577 1.79582e-07 4.46267e-15)
(0.143577 1.8829e-07 4.44833e-15)
(0.143577 1.966e-07 4.52434e-15)
(0.143577 2.04168e-07 4.45869e-15)
(0.143577 2.11141e-07 4.40283e-15)
(0.143577 2.16508e-07 4.48595e-15)
(0.143577 2.21007e-07 4.52012e-15)
(0.143577 2.22442e-07 4.60073e-15)
(0.143577 2.22316e-07 4.52696e-15)
(0.143577 2.21689e-07 4.49979e-15)
(0.143577 2.1988e-07 4.55604e-15)
(0.143577 2.19493e-07 4.59766e-15)
(0.143577 2.18251e-07 4.71519e-15)
(0.143577 2.15496e-07 4.64474e-15)
(0.143576 2.10597e-07 4.59744e-15)
(0.143576 2.03204e-07 4.69449e-15)
(0.143576 1.92639e-07 4.72146e-15)
(0.143576 1.79128e-07 4.83897e-15)
(0.143576 1.60981e-07 4.78993e-15)
(0.143576 1.39964e-07 4.74582e-15)
(0.143576 1.10252e-07 4.82163e-15)
(0.143576 7.95462e-08 4.86299e-15)
(0.143576 2.77898e-08 4.95984e-15)
(0.143576 -2.67285e-08 4.9165e-15)
(0.143576 -1.09308e-07 4.8903e-15)
(0.144079 -3.23516e-07 4.72865e-15)
(0.144079 -2.295e-07 4.50851e-15)
(0.144079 -1.8568e-07 4.64576e-15)
(0.144079 -1.57377e-07 4.49258e-15)
(0.144079 -1.34402e-07 4.61236e-15)
(0.144079 -1.15712e-07 4.68079e-15)
(0.14408 -9.9186e-08 4.45514e-15)
(0.14408 -8.40956e-08 4.60501e-15)
(0.14408 -7.00631e-08 4.42639e-15)
(0.14408 -5.68644e-08 4.59967e-15)
(0.144079 -4.43819e-08 4.73533e-15)
(0.144079 -3.25531e-08 4.54085e-15)
(0.144079 -2.13297e-08 4.67129e-15)
(0.144079 -1.06567e-08 4.45971e-15)
(0.144079 -4.61775e-10 4.63246e-15)
(0.144079 9.34146e-09 4.78618e-15)
(0.144079 1.88466e-08 4.61715e-15)
(0.144079 2.81469e-08 4.67095e-15)
(0.144079 3.73282e-08 4.47226e-15)
(0.144079 4.64649e-08 4.63223e-15)
(0.144079 5.56171e-08 4.75666e-15)
(0.144079 6.48299e-08 4.54035e-15)
(0.144079 7.41343e-08 4.66078e-15)
(0.144079 8.35484e-08 4.43253e-15)
(0.144079 9.30795e-08 4.58389e-15)
(0.144079 1.02724e-07 4.71596e-15)
(0.144079 1.1247e-07 4.56222e-15)
(0.144079 1.22296e-07 4.60522e-15)
(0.144079 1.32173e-07 4.45473e-15)
(0.144079 1.42065e-07 4.53307e-15)
(0.144079 1.51929e-07 4.64839e-15)
(0.144079 1.61715e-07 4.42187e-15)
(0.144079 1.71371e-07 4.53928e-15)
(0.144079 1.8082e-07 4.32387e-15)
(0.144079 1.90009e-07 4.48052e-15)
(0.144079 1.98798e-07 4.53934e-15)
(0.144079 2.0716e-07 4.61438e-15)
(0.144078 2.14761e-07 4.56612e-15)
(0.144078 2.21717e-07 4.55203e-15)
(0.144078 2.27113e-07 4.60022e-15)
(0.144078 2.31558e-07 4.66845e-15)
(0.144078 2.33219e-07 4.72147e-15)
(0.144078 2.33318e-07 4.66343e-15)
(0.144078 2.3282e-07 4.66821e-15)
(0.144078 2.31135e-07 4.67793e-15)
(0.144078 2.30435e-07 4.74549e-15)
(0.144078 2.28782e-07 4.83924e-15)
(0.144078 2.25535e-07 4.78556e-15)
(0.144078 2.20054e-07 4.7884e-15)
(0.144078 2.1196e-07 4.85096e-15)
(0.144078 2.00519e-07 4.90192e-15)
(0.144078 1.85892e-07 4.97708e-15)
(0.144078 1.66279e-07 4.93928e-15)
(0.144078 1.43368e-07 4.93254e-15)
(0.144078 1.11023e-07 4.97196e-15)
(0.144078 7.69519e-08 5.02086e-15)
(0.144078 2.02588e-08 5.0913e-15)
(0.144078 -4.05499e-08 5.05351e-15)
(0.144078 -1.30011e-07 5.05273e-15)
(0.144561 -3.4376e-07 4.82123e-15)
(0.144561 -2.46147e-07 4.72305e-15)
(0.144561 -1.97215e-07 4.73178e-15)
(0.144561 -1.65613e-07 4.67383e-15)
(0.144561 -1.39761e-07 4.69543e-15)
(0.144561 -1.18976e-07 4.74316e-15)
(0.144561 -1.00843e-07 4.64972e-15)
(0.144561 -8.44888e-08 4.67673e-15)
(0.144561 -6.94621e-08 4.60863e-15)
(0.144561 -5.5458e-08 4.72468e-15)
(0.144561 -4.23013e-08 4.78358e-15)
(0.144561 -2.98856e-08 4.71715e-15)
(0.144561 -1.81317e-08 4.72021e-15)
(0.144561 -6.9648e-09 4.6214e-15)
(0.144561 3.69813e-09 4.75025e-15)
(0.144561 1.3949e-08 4.8792e-15)
(0.144561 2.38833e-08 4.72258e-15)
(0.144561 3.35942e-08 4.71687e-15)
(0.144561 4.31669e-08 4.63039e-15)
(0.144561 5.26752e-08 4.74167e-15)
(0.144561 6.21788e-08 4.85123e-15)
(0.144561 7.17225e-08 4.69462e-15)
(0.144561 8.13378e-08 4.70297e-15)
(0.144561 9.10435e-08 4.58102e-15)
(0.144561 1.00848e-07 4.69644e-15)
(0.144561 1.10748e-07 4.8102e-15)
(0.144561 1.20734e-07 4.6537e-15)
(0.144561 1.30784e-07 4.64188e-15)
(0.144561 1.40872e-07 4.53999e-15)
(0.144561 1.50961e-07 4.63214e-15)
(0.144561 1.61009e-07 4.66795e-15)
(0.144561 1.70964e-07 4.58742e-15)
(0.144561 1.80774e-07 4.57028e-15)
(0.144561 1.9036e-07 4.4734e-15)
(0.144561 1.99666e-07 4.57365e-15)
(0.144561 2.08554e-07 4.56152e-15)
(0.14456 2.16985e-07 4.76585e-15)
(0.14456 2.24642e-07 4.64395e-15)
(0.14456 2.31607e-07 4.60215e-15)
(0.14456 2.3706e-07 4.7226e-15)
(0.14456 2.41493e-07 4.71988e-15)
(0.14456 2.43382e-07 4.8442e-15)
(0.14456 2.43712e-07 4.7644e-15)
(0.14456 2.43351e-07 4.72853e-15)
(0.14456 2.4179e-07 4.88453e-15)
(0.14456 2.40823e-07 4.80493e-15)
(0.14456 2.38804e-07 5.02394e-15)
(0.14456 2.35107e-07 4.89583e-15)
(0.14456 2.29089e-07 4.92649e-15)
(0.14456 2.20341e-07 4.99712e-15)
(0.14456 2.08077e-07 4.98546e-15)
(0.14456 1.92388e-07 5.17922e-15)
(0.14456 1.71374e-07 5.05469e-15)
(0.14456 1.46621e-07 5.02015e-15)
(0.14456 1.11747e-07 5.1234e-15)
(0.14456 7.43669e-08 5.17214e-15)
(0.14456 1.30209e-08 5.22932e-15)
(0.14456 -5.38711e-08 5.16773e-15)
(0.14456 -1.49454e-07 5.13328e-15)
(0.145024 -3.62467e-07 4.92761e-15)
(0.145024 -2.61854e-07 4.85702e-15)
(0.145024 -2.08106e-07 4.83732e-15)
(0.145024 -1.73365e-07 4.80514e-15)
(0.145024 -1.4476e-07 4.79829e-15)
(0.145024 -1.2193e-07 4.82462e-15)
(0.145024 -1.02245e-07 4.76491e-15)
(0.145024 -8.46819e-08 4.76801e-15)
(0.145024 -6.87206e-08 4.7189e-15)
(0.145024 -5.3978e-08 4.76083e-15)
(0.145024 -4.02207e-08 4.8369e-15)
(0.145024 -2.72971e-08 4.79542e-15)
(0.145024 -1.5095e-08 4.78735e-15)
(0.145024 -3.51772e-09 4.72644e-15)
(0.145024 7.53119e-09 4.77205e-15)
(0.145024 1.81511e-08 4.85661e-15)
(0.145024 2.8441e-08 4.79381e-15)
(0.145024 3.84951e-08 4.78157e-15)
(0.145024 4.83985e-08 4.72314e-15)
(0.145024 5.82244e-08 4.755e-15)
(0.145024 6.8032e-08 4.81702e-15)
(0.145024 7.7866e-08 4.76852e-15)
(0.145024 8.77575e-08 4.75502e-15)
(0.145024 9.77256e-08 4.67778e-15)
(0.145024 1.07779e-07 4.7136e-15)
(0.145024 1.17915e-07 4.7773e-15)
(0.145024 1.28125e-07 4.71839e-15)
(0.145024 1.38388e-07 4.69316e-15)
(0.145024 1.48678e-07 4.61652e-15)
(0.145024 1.58958e-07 4.63878e-15)
(0.145024 1.69187e-07 4.70217e-15)
(0.145024 1.79311e-07 4.63706e-15)
(0.145024 1.89278e-07 4.61599e-15)
(0.145024 1.99008e-07 4.54412e-15)
(0.145024 2.0844e-07 4.57117e-15)
(0.145023 2.17438e-07 4.58058e-15)
(0.145023 2.25954e-07 4.67863e-15)
(0.145023 2.33686e-07 4.67177e-15)
(0.145023 2.40685e-07 4.65089e-15)
(0.145023 2.46218e-07 4.72272e-15)
(0.145023 2.50677e-07 4.76686e-15)
(0.145023 2.52796e-07 4.83472e-15)
(0.145023 2.53364e-07 4.81486e-15)
(0.145023 2.5315e-07 4.80349e-15)
(0.145023 2.51715e-07 4.83273e-15)
(0.145023 2.50529e-07 4.8663e-15)
(0.145023 2.48186e-07 4.96377e-15)
(0.145023 2.44083e-07 4.95021e-15)
(0.145023 2.37569e-07 4.94485e-15)
(0.145023 2.28211e-07 5.02197e-15)
(0.145023 2.15174e-07 5.04359e-15)
(0.145023 1.98476e-07 5.12377e-15)
(0.145023 1.76129e-07 5.11596e-15)
(0.145023 1.49595e-07 5.09633e-15)
(0.145023 1.12307e-07 5.15456e-15)
(0.145023 7.17031e-08 5.16865e-15)
(0.145023 6.01137e-09 5.24401e-15)
(0.145023 -6.67012e-08 5.23475e-15)
(0.145023 -1.67664e-07 5.20963e-15)
(0.145468 -3.79583e-07 5.04315e-15)
(0.145468 -2.76525e-07 4.96182e-15)
(0.145469 -2.18258e-07 4.94344e-15)
(0.145469 -1.80542e-07 4.92521e-15)
(0.145469 -1.49318e-07 4.90831e-15)
(0.145469 -1.24508e-07 4.9211e-15)
(0.145469 -1.03331e-07 4.85498e-15)
(0.145469 -8.46182e-08 4.86236e-15)
(0.145469 -6.77838e-08 4.80965e-15)
(0.145469 -5.23693e-08 4.8307e-15)
(0.145469 -3.80834e-08 4.89534e-15)
(0.145469 -2.47291e-08 4.85324e-15)
(0.145469 -1.21602e-08 4.85961e-15)
(0.145469 -2.56114e-10 4.8e-15)
(0.145469 1.1095e-08 4.82237e-15)
(0.145469 2.20018e-08 4.88974e-15)
(0.145469 3.25685e-08 4.84204e-15)
(0.145469 4.28913e-08 4.84742e-15)
(0.145468 5.30564e-08 4.78834e-15)
(0.145468 6.31367e-08 4.80071e-15)
(0.145468 7.31912e-08 4.85743e-15)
(0.145468 8.32643e-08 4.80929e-15)
(0.145468 9.33868e-08 4.80804e-15)
(0.145468 1.03578e-07 4.73999e-15)
(0.145468 1.13845e-07 4.75782e-15)
(0.145468 1.24188e-07 4.81462e-15)
(0.145468 1.34597e-07 4.75805e-15)
(0.145468 1.45051e-07 4.74669e-15)
(0.145468 1.55526e-07 4.67151e-15)
(0.145468 1.65984e-07 4.67506e-15)
(0.145468 1.76384e-07 4.72255e-15)
(0.145468 1.86671e-07 4.66734e-15)
(0.145468 1.96791e-07 4.66503e-15)
(0.145468 2.06665e-07 4.59379e-15)
(0.145468 2.16226e-07 4.60129e-15)
(0.145468 2.25341e-07 4.6043e-15)
(0.145468 2.33952e-07 4.67407e-15)
(0.145468 2.41773e-07 4.69485e-15)
(0.145468 2.48828e-07 4.68452e-15)
(0.145468 2.54463e-07 4.74523e-15)
(0.145468 2.58979e-07 4.78059e-15)
(0.145468 2.61332e-07 4.83892e-15)
(0.145468 2.62145e-07 4.85315e-15)
(0.145468 2.62089e-07 4.84394e-15)
(0.145468 2.60785e-07 4.87537e-15)
(0.145468 2.59423e-07 4.90187e-15)
(0.145468 2.56801e-07 4.97652e-15)
(0.145468 2.52332e-07 4.99681e-15)
(0.145467 2.45365e-07 4.99115e-15)
(0.145467 2.3544e-07 5.04694e-15)
(0.145467 2.21681e-07 5.07405e-15)
(0.145467 2.04026e-07 5.14401e-15)
(0.145467 1.80417e-07 5.16246e-15)
(0.145467 1.52169e-07 5.15277e-15)
(0.145467 1.12598e-07 5.19816e-15)
(0.145467 6.88795e-08 5.21973e-15)
(0.145467 -8.3169e-10 5.27604e-15)
(0.145467 -7.90522e-08 5.28879e-15)
(0.145467 -1.84669e-07 5.27101e-15)
(0.145895 -3.95049e-07 5.1607e-15)
(0.145895 -2.90066e-07 5.03087e-15)
(0.145895 -2.27578e-07 5.05219e-15)
(0.145895 -1.87052e-07 5.04384e-15)
(0.145895 -1.53354e-07 5.02067e-15)
(0.145895 -1.26639e-07 5.02783e-15)
(0.145895 -1.04038e-07 4.91571e-15)
(0.145895 -8.42419e-08 4.96242e-15)
(0.145895 -6.65989e-08 4.87439e-15)
(0.145895 -5.05803e-08 4.92231e-15)
(0.145895 -3.58377e-08 4.98101e-15)
(0.145895 -2.21293e-08 4.89117e-15)
(0.145895 -9.27383e-09 4.93964e-15)
(0.145895 2.87389e-09 4.84454e-15)
(0.145895 1.44428e-08 4.89276e-15)
(0.145895 2.55524e-08 4.95539e-15)
(0.145895 3.63135e-08 4.86801e-15)
(0.145895 4.68258e-08 4.91895e-15)
(0.145895 5.71772e-08 4.82678e-15)
(0.145895 6.74414e-08 4.86917e-15)
(0.145895 7.76775e-08 4.92297e-15)
(0.145895 8.79298e-08 4.82757e-15)
(0.145895 9.82289e-08 4.86694e-15)
(0.145895 1.08593e-07 4.76946e-15)
(0.145895 1.19032e-07 4.82024e-15)
(0.145895 1.29542e-07 4.87605e-15)
(0.145895 1.40115e-07 4.77495e-15)
(0.145895 1.50732e-07 4.80662e-15)
(0.145895 1.61365e-07 4.70009e-15)
(0.145895 1.71979e-07 4.73203e-15)
(0.145895 1.82532e-07 4.77496e-15)
(0.145895 1.92969e-07 4.6765e-15)
(0.145895 2.03232e-07 4.72182e-15)
(0.145895 2.13243e-07 4.61901e-15)
(0.145894 2.22931e-07 4.65543e-15)
(0.145894 2.32165e-07 4.6424e-15)
(0.145894 2.40877e-07 4.71246e-15)
(0.145894 2.48797e-07 4.73662e-15)
(0.145894 2.55925e-07 4.72373e-15)
(0.145894 2.61677e-07 4.79539e-15)
(0.145894 2.66279e-07 4.81516e-15)
(0.145894 2.6887e-07 4.87635e-15)
(0.145894 2.69931e-07 4.90016e-15)
(0.145894 2.70045e-07 4.89831e-15)
(0.145894 2.68879e-07 4.94444e-15)
(0.145894 2.67383e-07 4.95568e-15)
(0.145894 2.64525e-07 5.03083e-15)
(0.145894 2.59732e-07 5.0534e-15)
(0.145894 2.52354e-07 5.04382e-15)
(0.145894 2.41906e-07 5.10278e-15)
(0.145894 2.27474e-07 5.1159e-15)
(0.145894 2.08919e-07 5.19586e-15)
(0.145894 1.84121e-07 5.21596e-15)
(0.145894 1.54237e-07 5.20509e-15)
(0.145894 1.12523e-07 5.26721e-15)
(0.145894 6.58229e-08 5.27671e-15)
(0.145894 -7.56505e-09 5.33316e-15)
(0.145894 -9.09361e-08 5.34652e-15)
(0.145894 -2.00502e-07 5.32574e-15)
(0.146304 -4.08811e-07 5.27268e-15)
(0.146304 -3.02386e-07 5.19884e-15)
(0.146304 -2.35974e-07 5.18802e-15)
(0.146304 -1.92807e-07 5.16325e-15)
(0.146304 -1.56786e-07 5.13445e-15)
(0.146304 -1.28253e-07 5.14176e-15)
(0.146304 -1.04306e-07 5.08371e-15)
(0.146304 -8.34976e-08 5.09004e-15)
(0.146304 -6.51148e-08 5.04663e-15)
(0.146304 -4.85622e-08 5.05176e-15)
(0.146304 -3.34357e-08 5.08879e-15)
(0.146304 -1.94493e-08 5.04294e-15)
(0.146304 -6.38707e-09 5.04905e-15)
(0.146304 5.92172e-09 4.99619e-15)
(0.146304 1.76239e-08 4.99931e-15)
(0.146304 2.88514e-08 5.04189e-15)
(0.146304 3.97225e-08 5.0072e-15)
(0.146304 5.03419e-08 5.01901e-15)
(0.146304 6.08e-08 4.97443e-15)
(0.146304 7.11721e-08 4.9774e-15)
(0.146304 8.1518e-08 5.01251e-15)
(0.146304 9.18824e-08 4.96174e-15)
(0.146304 1.02296e-07 4.95347e-15)
(0.146304 1.12777e-07 4.90426e-15)
(0.146304 1.23333e-07 4.92062e-15)
(0.146304 1.33964e-07 4.95585e-15)
(0.146304 1.44659e-07 4.90472e-15)
(0.146304 1.55399e-07 4.89473e-15)
(0.146304 1.66157e-07 4.83801e-15)
(0.146303 1.76898e-07 4.82702e-15)
(0.146303 1.87579e-07 4.84585e-15)
(0.146303 1.98143e-07 4.79622e-15)
(0.146303 2.08533e-07 4.80664e-15)
(0.146303 2.18667e-07 4.75446e-15)
(0.146303 2.28475e-07 4.75064e-15)
(0.146303 2.37822e-07 4.68822e-15)
(0.146303 2.46636e-07 4.79953e-15)
(0.146303 2.54661e-07 4.80095e-15)
(0.146303 2.61874e-07 4.77417e-15)
(0.146303 2.67755e-07 4.88334e-15)
(0.146303 2.72466e-07 4.85938e-15)
(0.146303 2.75294e-07 4.94883e-15)
(0.146303 2.76608e-07 4.958e-15)
(0.146303 2.76901e-07 4.96816e-15)
(0.146303 2.7588e-07 5.04744e-15)
(0.146303 2.74291e-07 5.01744e-15)
(0.146303 2.71238e-07 5.12382e-15)
(0.146303 2.66165e-07 5.1217e-15)
(0.146303 2.58419e-07 5.1038e-15)
(0.146303 2.47494e-07 5.1922e-15)
(0.146303 2.32441e-07 5.15746e-15)
(0.146303 2.13044e-07 5.28859e-15)
(0.146303 1.87134e-07 5.2818e-15)
(0.146303 1.55702e-07 5.25908e-15)
(0.146303 1.11996e-07 5.37171e-15)
(0.146303 6.24699e-08 5.33369e-15)
(0.146303 -1.42389e-08 5.42549e-15)
(0.146303 -1.02364e-07 5.41137e-15)
(0.146303 -2.15196e-07 5.37944e-15)
(0.146696 -4.20812e-07 5.38019e-15)
(0.146695 -3.13398e-07 5.33452e-15)
(0.146696 -2.43357e-07 5.32939e-15)
(0.146696 -1.97718e-07 5.28177e-15)
(0.146696 -1.59534e-07 5.25648e-15)
(0.146696 -1.29282e-07 5.27117e-15)
(0.146696 -1.04073e-07 5.22666e-15)
(0.146696 -8.23305e-08 5.22093e-15)
(0.146696 -6.32812e-08 5.19146e-15)
(0.146696 -4.62676e-08 5.1952e-15)
(0.146696 -3.08316e-08 5.22097e-15)
(0.146696 -1.66438e-08 5.17345e-15)
(0.146696 -3.45433e-09 5.16308e-15)
(0.146696 8.93345e-09 5.12027e-15)
(0.146696 2.06849e-08 5.10874e-15)
(0.146695 3.1945e-08 5.14524e-15)
(0.146695 4.28408e-08 5.12471e-15)
(0.146695 5.34829e-08 5.12333e-15)
(0.146695 6.39651e-08 5.09915e-15)
(0.146695 7.43651e-08 5.0955e-15)
(0.146695 8.47443e-08 5.12844e-15)
(0.146695 9.51479e-08 5.07877e-15)
(0.146695 1.05607e-07 5.04207e-15)
(0.146695 1.16141e-07 5.01305e-15)
(0.146695 1.26756e-07 5.0377e-15)
(0.146695 1.37452e-07 5.04771e-15)
(0.146695 1.48218e-07 5.01287e-15)
(0.146695 1.59036e-07 4.98492e-15)
(0.146695 1.69878e-07 4.9526e-15)
(0.146695 1.80708e-07 4.93111e-15)
(0.146695 1.91483e-07 4.93372e-15)
(0.146695 2.02147e-07 4.88978e-15)
(0.146695 2.12639e-07 4.89158e-15)
(0.146695 2.22878e-07 4.86407e-15)
(0.146695 2.32789e-07 4.85661e-15)
(0.146695 2.4224e-07 4.72271e-15)
(0.146695 2.51151e-07 4.93363e-15)
(0.146695 2.5928e-07 4.86708e-15)
(0.146695 2.66584e-07 4.80369e-15)
(0.146695 2.72602e-07 5.03125e-15)
(0.146695 2.77437e-07 4.88249e-15)
(0.146695 2.80503e-07 5.13534e-15)
(0.146695 2.8207e-07 5.01417e-15)
(0.146695 2.82552e-07 5.00318e-15)
(0.146695 2.81685e-07 5.21912e-15)
(0.146695 2.80039e-07 5.06611e-15)
(0.146695 2.76832e-07 5.25002e-15)
(0.146695 2.7152e-07 5.18235e-15)
(0.146695 2.63452e-07 5.1392e-15)
(0.146695 2.52096e-07 5.29031e-15)
(0.146695 2.36477e-07 5.17186e-15)
(0.146695 2.16299e-07 5.37806e-15)
(0.146695 1.89363e-07 5.34336e-15)
(0.146695 1.56477e-07 5.29638e-15)
(0.146695 1.10941e-07 5.55283e-15)
(0.146695 5.87665e-08 5.3633e-15)
(0.146695 -2.08958e-08 5.58107e-15)
(0.146695 -1.13343e-07 5.46914e-15)
(0.146695 -2.28782e-07 5.39716e-15)
(0.147071 -4.31003e-07 5.54268e-15)
(0.147071 -3.23019e-07 5.45329e-15)
(0.147071 -2.49643e-07 5.44024e-15)
(0.147071 -2.01702e-07 5.38822e-15)
(0.147071 -1.61519e-07 5.34526e-15)
(0.147071 -1.29656e-07 5.42635e-15)
(0.147071 -1.03278e-07 5.34734e-15)
(0.147071 -8.06867e-08 5.38928e-15)
(0.147071 -6.10491e-08 5.31684e-15)
(0.147071 -4.36508e-08 5.37827e-15)
(0.147071 -2.79813e-08 5.32706e-15)
(0.147071 -1.36697e-08 5.28473e-15)
(0.147071 -4.32404e-10 5.31536e-15)
(0.147071 1.19527e-08 5.22004e-15)
(0.147071 2.36699e-08 5.25909e-15)
(0.147071 3.48777e-08 5.33683e-15)
(0.147071 4.57127e-08 5.22307e-15)
(0.147071 5.62921e-08 5.26505e-15)
(0.147071 6.67142e-08 5.21179e-15)
(0.147071 7.70597e-08 5.2093e-15)
(0.147071 8.73919e-08 5.20438e-15)
(0.147071 9.77578e-08 5.17997e-15)
(0.147071 1.08189e-07 5.11895e-15)
(0.147071 1.18705e-07 5.10392e-15)
(0.147071 1.29314e-07 5.13654e-15)
(0.147071 1.40014e-07 5.13211e-15)
(0.147071 1.50794e-07 5.10573e-15)
(0.147071 1.61637e-07 5.1801e-15)
(0.147071 1.72514e-07 5.05492e-15)
(0.147071 1.8339e-07 5.0228e-15)
(0.147071 1.94219e-07 5.05751e-15)
(0.147071 2.04947e-07 4.96371e-15)
(0.147071 2.1551e-07 5.01945e-15)
(0.147071 2.25827e-07 4.95059e-15)
(0.14707 2.35819e-07 4.95156e-15)
(0.14707 2.45358e-07 4.90391e-15)
(0.14707 2.54355e-07 5.08054e-15)
(0.14707 2.62582e-07 4.87361e-15)
(0.14707 2.69979e-07 4.86965e-15)
(0.14707 2.76134e-07 4.95947e-15)
(0.14707 2.81106e-07 4.99967e-15)
(0.14707 2.84406e-07 5.09239e-15)
(0.14707 2.86225e-07 5.03143e-15)
(0.14707 2.86901e-07 5.13604e-15)
(0.14707 2.86195e-07 5.22427e-15)
(0.14707 2.84526e-07 5.19136e-15)
(0.14707 2.81204e-07 5.33794e-15)
(0.14707 2.75697e-07 5.18997e-15)
(0.14707 2.67351e-07 5.26308e-15)
(0.14707 2.55613e-07 5.33678e-15)
(0.14707 2.39486e-07 5.35662e-15)
(0.14707 2.18595e-07 5.51141e-15)
(0.14707 1.9072e-07 5.33284e-15)
(0.14707 1.56487e-07 5.35934e-15)
(0.14707 1.09294e-07 5.53987e-15)
(0.14707 5.46689e-08 5.44016e-15)
(0.14707 -2.75702e-08 5.53071e-15)
(0.14707 -1.2388e-07 5.45256e-15)
(0.14707 -2.4129e-07 5.40408e-15)
(0.14743 -4.39335e-07 5.57239e-15)
(0.14743 -3.31173e-07 5.53372e-15)
(0.14743 -2.54752e-07 5.55299e-15)
(0.14743 -2.04679e-07 5.41582e-15)
(0.14743 -1.62669e-07 5.44279e-15)
(0.14743 -1.29312e-07 5.45498e-15)
(0.14743 -1.01864e-07 5.47897e-15)
(0.14743 -7.85138e-08 5.42024e-15)
(0.14743 -5.83706e-08 5.44924e-15)
(0.14743 -4.0667e-08 5.44456e-15)
(0.14743 -2.48423e-08 5.43334e-15)
(0.14743 -1.04852e-08 5.40928e-15)
(0.14743 2.72021e-09 5.33334e-15)
(0.14743 1.50214e-08 5.34671e-15)
(0.14743 2.66216e-08 5.31405e-15)
(0.14743 3.76928e-08 5.29252e-15)
(0.14743 4.8382e-08 5.3227e-15)
(0.14743 5.88132e-08 5.2678e-15)
(0.14743 6.90901e-08 5.31362e-15)
(0.14743 7.92971e-08 5.26328e-15)
(0.14743 8.95001e-08 5.2744e-15)
(0.14743 9.97482e-08 5.21485e-15)
(0.14743 1.10075e-07 5.1739e-15)
(0.14743 1.20499e-07 5.15254e-15)
(0.14743 1.3103e-07 5.18499e-15)
(0.14743 1.41667e-07 5.19092e-15)
(0.14743 1.52399e-07 5.14043e-15)
(0.14743 1.63207e-07 5.11804e-15)
(0.14743 1.74065e-07 5.10008e-15)
(0.14743 1.84935e-07 5.13542e-15)
(0.14743 1.95773e-07 5.06069e-15)
(0.14743 2.06522e-07 4.99985e-15)
(0.14743 2.1712e-07 5.0195e-15)
(0.14743 2.27482e-07 5.05625e-15)
(0.14743 2.37528e-07 4.97541e-15)
(0.14743 2.47131e-07 4.94064e-15)
(0.14743 2.56197e-07 5.06099e-15)
(0.14743 2.64511e-07 4.78302e-15)
(0.14743 2.71995e-07 4.7954e-15)
(0.14743 2.78285e-07 5.04166e-15)
(0.14743 2.83397e-07 4.96385e-15)
(0.14743 2.86924e-07 5.11195e-15)
(0.14743 2.88991e-07 5.00582e-15)
(0.14743 2.89865e-07 5.00628e-15)
(0.14743 2.89326e-07 5.12347e-15)
(0.14743 2.87666e-07 5.18035e-15)
(0.14743 2.84266e-07 5.33238e-15)
(0.14743 2.78604e-07 5.02535e-15)
(0.14743 2.70026e-07 5.13604e-15)
(0.14743 2.57959e-07 5.25142e-15)
(0.14743 2.41384e-07 5.26336e-15)
(0.14743 2.1985e-07 5.38087e-15)
(0.14743 1.91134e-07 5.27379e-15)
(0.14743 1.5567e-07 5.30614e-15)
(0.14743 1.07001e-07 5.5105e-15)
(0.14743 5.01436e-08 5.43958e-15)
(0.14743 -3.42883e-08 5.52105e-15)
(0.14743 -1.33976e-07 5.40001e-15)
(0.14743 -2.52747e-07 5.36845e-15)
(0.147774 -4.45766e-07 5.54374e-15)
(0.147774 -3.37791e-07 5.45458e-15)
(0.147774 -2.58611e-07 5.42415e-15)
(0.147774 -2.06576e-07 5.38377e-15)
(0.147774 -1.62913e-07 5.34001e-15)
(0.147774 -1.28187e-07 5.45905e-15)
(0.147774 -9.97751e-08 5.31987e-15)
(0.147774 -7.57623e-08 5.42937e-15)
(0.147774 -5.52003e-08 5.29403e-15)
(0.147774 -3.72737e-08 5.26685e-15)
(0.147774 -2.13737e-08 5.27067e-15)
(0.147774 -7.05043e-09 5.23892e-15)
(0.147773 6.04357e-09 5.21238e-15)
(0.147773 1.81803e-08 5.17447e-15)
(0.147773 2.95814e-08 5.12948e-15)
(0.147773 4.04329e-08 5.19308e-15)
(0.147773 5.08919e-08 5.13749e-15)
(0.147773 6.10903e-08 5.18051e-15)
(0.147773 7.11371e-08 5.13848e-15)
(0.147773 8.1121e-08 5.12335e-15)
(0.147773 9.11114e-08 5.15996e-15)
(0.147773 1.0116e-07 5.07741e-15)
(0.147773 1.11301e-07 5.04354e-15)
(0.147773 1.21557e-07 5.03549e-15)
(0.147773 1.31936e-07 5.04061e-15)
(0.147773 1.42439e-07 5.02963e-15)
(0.147773 1.53054e-07 5.01765e-15)
(0.147773 1.63764e-07 5.03471e-15)
(0.147773 1.74542e-07 4.98382e-15)
(0.147773 1.8535e-07 4.93257e-15)
(0.147773 1.96144e-07 5.0153e-15)
(0.147773 2.06867e-07 4.86664e-15)
(0.147773 2.17455e-07 4.87493e-15)
(0.147773 2.27823e-07 4.87605e-15)
(0.147773 2.3789e-07 4.82201e-15)
(0.147773 2.47528e-07 4.93961e-15)
(0.147773 2.56641e-07 4.87592e-15)
(0.147773 2.65022e-07 4.72156e-15)
(0.147773 2.72584e-07 4.79922e-15)
(0.147773 2.78998e-07 4.80207e-15)
(0.147773 2.84249e-07 4.93427e-15)
(0.147773 2.87993e-07 4.977e-15)
(0.147773 2.90299e-07 4.88597e-15)
(0.147773 2.91374e-07 4.9929e-15)
(0.147773 2.91006e-07 5.00841e-15)
(0.147773 2.89381e-07 5.1146e-15)
(0.147773 2.85938e-07 5.12131e-15)
(0.147773 2.80162e-07 5.01319e-15)
(0.147773 2.71399e-07 5.11418e-15)
(0.147773 2.59054e-07 5.11992e-15)
(0.147773 2.42095e-07 5.22571e-15)
(0.147773 2.19996e-07 5.23594e-15)
(0.147773 1.9054e-07 5.1424e-15)
(0.147773 1.53973e-07 5.2551e-15)
(0.147773 1.04021e-07 5.29582e-15)
(0.147773 4.51668e-08 5.43777e-15)
(0.147773 -4.10677e-08 5.36408e-15)
(0.147773 -1.43629e-07 5.26268e-15)
(0.147773 -2.63181e-07 5.40897e-15)
(0.148102 -4.50257e-07 5.38327e-15)
(0.148102 -3.42812e-07 5.32271e-15)
(0.148102 -2.61153e-07 5.30092e-15)
(0.148102 -2.07328e-07 5.24068e-15)
(0.148102 -1.62188e-07 5.23182e-15)
(0.148102 -1.26225e-07 5.228e-15)
(0.148102 -9.69612e-08 5.19911e-15)
(0.148102 -7.23859e-08 5.1911e-15)
(0.148102 -5.14956e-08 5.14395e-15)
(0.148102 -3.34307e-08 5.08212e-15)
(0.148102 -1.75368e-08 5.12966e-15)
(0.148102 -3.32691e-09 5.07249e-15)
(0.148102 9.57629e-09 5.07257e-15)
(0.148102 2.14687e-08 5.02504e-15)
(0.148102 3.259e-08 4.96399e-15)
(0.148102 4.314e-08 4.99547e-15)
(0.148102 5.32861e-08 4.96585e-15)
(0.148102 6.31679e-08 4.96706e-15)
(0.148102 7.29006e-08 4.95051e-15)
(0.148102 8.25773e-08 4.92409e-15)
(0.148102 9.22713e-08 4.93314e-15)
(0.148102 1.02037e-07 4.90812e-15)
(0.148102 1.11912e-07 4.89545e-15)
(0.148102 1.21919e-07 4.8771e-15)
(0.148102 1.3207e-07 4.83669e-15)
(0.148102 1.42364e-07 4.87457e-15)
(0.148102 1.52791e-07 4.84079e-15)
(0.148102 1.63334e-07 4.824e-15)
(0.148102 1.73967e-07 4.80058e-15)
(0.148102 1.84652e-07 4.74525e-15)
(0.148102 1.95344e-07 4.75125e-15)
(0.148102 2.05987e-07 4.69497e-15)
(0.148102 2.16516e-07 4.73297e-15)
(0.148102 2.26846e-07 4.70217e-15)
(0.148102 2.36893e-07 4.6016e-15)
(0.148102 2.46533e-07 4.75259e-15)
(0.148102 2.55663e-07 4.67648e-15)
(0.148102 2.64088e-07 4.6054e-15)
(0.148102 2.71711e-07 4.72135e-15)
(0.148102 2.78234e-07 4.64633e-15)
(0.148102 2.83616e-07 4.81013e-15)
(0.148102 2.87563e-07 4.77918e-15)
(0.148102 2.90098e-07 4.76425e-15)
(0.148102 2.91371e-07 4.91156e-15)
(0.148102 2.91175e-07 4.82475e-15)
(0.148102 2.89609e-07 4.97431e-15)
(0.148102 2.86156e-07 4.9129e-15)
(0.148102 2.80305e-07 4.86502e-15)
(0.148102 2.71403e-07 5.01686e-15)
(0.148102 2.58835e-07 4.9591e-15)
(0.148102 2.41558e-07 5.09225e-15)
(0.148102 2.18976e-07 5.03922e-15)
(0.148102 1.88889e-07 4.98841e-15)
(0.148102 1.51356e-07 5.15048e-15)
(0.148102 1.00322e-07 5.06953e-15)
(0.148102 3.97253e-08 5.21189e-15)
(0.148102 -4.79176e-08 5.16781e-15)
(0.148102 -1.52833e-07 5.11252e-15)
(0.148102 -2.72611e-07 5.23586e-15)
(0.148416 -4.52778e-07 5.25022e-15)
(0.148416 -3.46183e-07 5.1752e-15)
(0.148416 -2.62322e-07 5.13587e-15)
(0.148416 -2.06875e-07 5.06613e-15)
(0.148416 -1.60438e-07 5.09906e-15)
(0.148416 -1.23377e-07 5.10128e-15)
(0.148416 -9.33769e-08 5.06972e-15)
(0.148416 -6.83435e-08 5.04938e-15)
(0.148416 -4.72181e-08 4.99258e-15)
(0.148416 -2.91012e-08 4.89868e-15)
(0.148416 -1.32954e-08 4.96649e-15)
(0.148416 7.21352e-10 4.87032e-15)
(0.148416 1.33552e-08 4.91271e-15)
(0.148416 2.49247e-08 4.81418e-15)
(0.148416 3.56872e-08 4.77909e-15)
(0.148416 4.58557e-08 4.8404e-15)
(0.148416 5.56079e-08 4.81614e-15)
(0.148416 6.50913e-08 4.80586e-15)
(0.148416 7.44273e-08 4.73812e-15)
(0.148416 8.37139e-08 4.67199e-15)
(0.148416 9.30284e-08 4.78264e-15)
(0.148416 1.02429e-07 4.69143e-15)
(0.148416 1.11956e-07 4.74128e-15)
(0.148416 1.21634e-07 4.71574e-15)
(0.148416 1.31476e-07 4.59888e-15)
(0.148416 1.41484e-07 4.71754e-15)
(0.148416 1.51649e-07 4.68751e-15)
(0.148416 1.61954e-07 4.67052e-15)
(0.148416 1.72372e-07 4.6528e-15)
(0.148416 1.82868e-07 4.55402e-15)
(0.148416 1.93397e-07 4.60163e-15)
(0.148416 2.03902e-07 4.57047e-15)
(0.148416 2.14317e-07 4.56222e-15)
(0.148416 2.2456e-07 4.4301e-15)
(0.148416 2.34542e-07 4.35474e-15)
(0.148416 2.44143e-07 4.50262e-15)
(0.148416 2.53256e-07 4.46853e-15)
(0.148416 2.61696e-07 4.486e-15)
(0.148416 2.69357e-07 4.56821e-15)
(0.148416 2.75969e-07 4.44068e-15)
(0.148416 2.81468e-07 4.61193e-15)
(0.148416 2.85599e-07 4.59966e-15)
(0.148416 2.88349e-07 4.64053e-15)
(0.148416 2.89813e-07 4.74449e-15)
(0.148416 2.8979e-07 4.66954e-15)
(0.148416 2.88303e-07 4.75985e-15)
(0.148416 2.84868e-07 4.70533e-15)
(0.148416 2.78979e-07 4.72771e-15)
(0.148416 2.69984e-07 4.8355e-15)
(0.148416 2.5725e-07 4.78034e-15)
(0.148416 2.39724e-07 4.87003e-15)
(0.148416 2.16746e-07 4.76693e-15)
(0.148416 1.86143e-07 4.83913e-15)
(0.148416 1.47793e-07 4.93197e-15)
(0.148416 9.58856e-08 4.80899e-15)
(0.148417 3.38158e-08 4.96348e-15)
(0.148417 -5.48387e-08 4.88438e-15)
(0.148417 -1.6158e-07 4.95751e-15)
(0.148417 -2.8106e-07 5.03705e-15)
(0.148717 -4.53303e-07 5.10852e-15)
(0.148717 -3.47859e-07 4.98803e-15)
(0.148717 -2.62069e-07 4.97448e-15)
(0.148717 -2.0517e-07 4.99181e-15)
(0.148717 -1.57617e-07 4.98666e-15)
(0.148717 -1.19601e-07 4.96667e-15)
(0.148717 -8.89836e-08 4.88264e-15)
(0.148717 -6.35995e-08 4.90977e-15)
(0.148716 -4.23343e-08 4.74758e-15)
(0.148716 -2.42528e-08 4.85388e-15)
(0.148716 -8.6174e-09 4.85755e-15)
(0.148716 5.12742e-09 4.74266e-15)
(0.148716 1.74146e-08 4.78265e-15)
(0.148716 2.85845e-08 4.68973e-15)
(0.148716 3.89113e-08 4.72066e-15)
(0.148716 4.86208e-08 4.74029e-15)
(0.148716 5.79006e-08 4.64319e-15)
(0.148716 6.69061e-08 4.67227e-15)
(0.148716 7.57649e-08 4.65708e-15)
(0.148716 8.45803e-08 4.68783e-15)
(0.148716 9.34337e-08 4.68654e-15)
(0.148716 1.02387e-07 4.63374e-15)
(0.148716 1.11484e-07 4.60271e-15)
(0.148716 1.20752e-07 4.59111e-15)
(0.148716 1.30207e-07 4.59901e-15)
(0.148716 1.39851e-07 4.63012e-15)
(0.148716 1.49677e-07 4.52292e-15)
(0.148716 1.59669e-07 4.53443e-15)
(0.148716 1.69801e-07 4.51214e-15)
(0.148716 1.80039e-07 4.51944e-15)
(0.148716 1.90339e-07 4.50694e-15)
(0.148716 2.00643e-07 4.39337e-15)
(0.148716 2.10886e-07 4.44608e-15)
(0.148716 2.20986e-07 4.29889e-15)
(0.148716 2.30854e-07 4.35172e-15)
(0.148717 2.4037e-07 4.37521e-15)
(0.148717 2.49427e-07 4.41011e-15)
(0.148717 2.57848e-07 4.42225e-15)
(0.148717 2.65518e-07 4.45845e-15)
(0.148717 2.72192e-07 4.45146e-15)
(0.148717 2.77789e-07 4.50301e-15)
(0.148717 2.82082e-07 4.53174e-15)
(0.148717 2.85027e-07 4.58326e-15)
(0.148717 2.86674e-07 4.62721e-15)
(0.148717 2.86821e-07 4.64106e-15)
(0.148717 2.85428e-07 4.65497e-15)
(0.148717 2.82038e-07 4.6262e-15)
(0.148717 2.76147e-07 4.6471e-15)
(0.148717 2.67104e-07 4.70132e-15)
(0.148717 2.54259e-07 4.72631e-15)
(0.148717 2.36557e-07 4.73485e-15)
(0.148717 2.13275e-07 4.73814e-15)
(0.148717 1.82277e-07 4.73873e-15)
(0.148717 1.43266e-07 4.77327e-15)
(0.148717 9.07043e-08 4.76987e-15)
(0.148717 2.74447e-08 4.81238e-15)
(0.148717 -6.18236e-08 4.84229e-15)
(0.148717 -1.69856e-07 4.84336e-15)
(0.148717 -2.88542e-07 4.8765e-15)
(0.149003 -4.51815e-07 4.94528e-15)
(0.149003 -3.47806e-07 4.89253e-15)
(0.149003 -2.60353e-07 4.83528e-15)
(0.149003 -2.02172e-07 5.01863e-15)
(0.149003 -1.53685e-07 4.86021e-15)
(0.149003 -1.14861e-07 4.81855e-15)
(0.149003 -8.37504e-08 4.81031e-15)
(0.149003 -5.81252e-08 4.7742e-15)
(0.149003 -3.68169e-08 4.73697e-15)
(0.149003 -1.88584e-08 4.79866e-15)
(0.149003 -3.47489e-09 4.75994e-15)
(0.149003 9.92045e-09 4.70127e-15)
(0.149003 2.17858e-08 4.67167e-15)
(0.149003 3.2482e-08 4.63459e-15)
(0.149003 4.2299e-08 4.68953e-15)
(0.149003 5.14749e-08 4.64402e-15)
(0.149003 6.02069e-08 4.60382e-15)
(0.149003 6.8658e-08 4.56442e-15)
(0.149003 7.69621e-08 4.55982e-15)
(0.149003 8.52275e-08 4.64597e-15)
(0.149003 9.35404e-08 4.59939e-15)
(0.149003 1.01967e-07 4.5296e-15)
(0.149003 1.10553e-07 4.49633e-15)
(0.149003 1.19331e-07 4.47658e-15)
(0.149003 1.28318e-07 4.56781e-15)
(0.149003 1.37519e-07 4.54527e-15)
(0.149003 1.46929e-07 4.47946e-15)
(0.149003 1.56532e-07 4.43362e-15)
(0.149003 1.66305e-07 4.4146e-15)
(0.149003 1.76214e-07 4.47692e-15)
(0.149003 1.86215e-07 4.42909e-15)
(0.149003 1.96252e-07 4.37875e-15)
(0.149003 2.06261e-07 4.3461e-15)
(0.149003 2.1616e-07 4.30757e-15)
(0.149003 2.25859e-07 4.38725e-15)
(0.149003 2.35242e-07 4.28861e-15)
(0.149003 2.44197e-07 4.35843e-15)
(0.149003 2.52558e-07 4.39101e-15)
(0.149003 2.60204e-07 4.37916e-15)
(0.149003 2.6691e-07 4.44691e-15)
(0.149003 2.7258e-07 4.41578e-15)
(0.149003 2.77008e-07 4.48984e-15)
(0.149003 2.80126e-07 4.53899e-15)
(0.149003 2.81942e-07 4.53557e-15)
(0.149003 2.82253e-07 4.61153e-15)
(0.149004 2.80966e-07 4.58003e-15)
(0.149004 2.77643e-07 4.63325e-15)
(0.149004 2.71784e-07 4.58912e-15)
(0.149004 2.62738e-07 4.59261e-15)
(0.149004 2.49839e-07 4.67006e-15)
(0.149004 2.32035e-07 4.62233e-15)
(0.149004 2.08544e-07 4.64619e-15)
(0.149004 1.77278e-07 4.65891e-15)
(0.149004 1.37774e-07 4.64358e-15)
(0.149004 8.47819e-08 4.70566e-15)
(0.149004 2.06286e-08 4.67773e-15)
(0.149004 -6.88565e-08 4.8425e-15)
(0.149004 -1.77645e-07 4.75072e-15)
(0.149004 -2.95071e-07 4.73662e-15)
(0.149277 -4.48304e-07 4.75774e-15)
(0.149277 -3.45997e-07 4.7751e-15)
(0.149277 -2.57144e-07 4.68821e-15)
(0.149277 -1.97852e-07 4.7323e-15)
(0.149277 -1.48613e-07 4.67782e-15)
(0.149277 -1.09133e-07 4.64935e-15)
(0.149277 -7.76549e-08 4.69957e-15)
(0.149277 -5.19e-08 4.63445e-15)
(0.149277 -3.06459e-08 4.65145e-15)
(0.149277 -1.28974e-08 4.64907e-15)
(0.149277 2.15416e-09 4.60268e-15)
(0.149277 1.51247e-08 4.627e-15)
(0.149277 2.64958e-08 4.56043e-15)
(0.149277 3.66473e-08 4.57164e-15)
(0.149277 4.5884e-08 4.54026e-15)
(0.149277 5.44554e-08 4.50581e-15)
(0.149277 6.2568e-08 4.53122e-15)
(0.149277 7.03919e-08 4.45991e-15)
(0.149277 7.80672e-08 4.49593e-15)
(0.149277 8.57075e-08 4.50416e-15)
(0.149277 9.34034e-08 4.45586e-15)
(0.149277 1.01225e-07 4.46701e-15)
(0.149277 1.09223e-07 4.38885e-15)
(0.149277 1.17432e-07 4.41569e-15)
(0.149277 1.25873e-07 4.43298e-15)
(0.149277 1.34552e-07 4.40442e-15)
(0.149277 1.43467e-07 4.41902e-15)
(0.149277 1.52605e-07 4.33063e-15)
(0.149277 1.61944e-07 4.34756e-15)
(0.149277 1.7145e-07 4.34089e-15)
(0.149277 1.81081e-07 4.28846e-15)
(0.149277 1.90784e-07 4.31698e-15)
(0.149277 2.00493e-07 4.24584e-15)
(0.149277 2.10128e-07 4.2486e-15)
(0.149277 2.19601e-07 4.20628e-15)
(0.149277 2.28795e-07 4.18639e-15)
(0.149277 2.37602e-07 4.234e-15)
(0.149277 2.45858e-07 4.35078e-15)
(0.149277 2.53441e-07 4.31489e-15)
(0.149277 2.60143e-07 4.33985e-15)
(0.149277 2.65855e-07 4.3018e-15)
(0.149277 2.70388e-07 4.32899e-15)
(0.149277 2.73653e-07 4.47742e-15)
(0.149277 2.75621e-07 4.45038e-15)
(0.149277 2.76087e-07 4.48904e-15)
(0.149277 2.74914e-07 4.44734e-15)
(0.149277 2.71677e-07 4.42044e-15)
(0.149277 2.6588e-07 4.52822e-15)
(0.149277 2.56875e-07 4.49128e-15)
(0.149278 2.43981e-07 4.52816e-15)
(0.149278 2.26151e-07 4.46811e-15)
(0.149278 2.02552e-07 4.45172e-15)
(0.149278 1.71149e-07 4.56031e-15)
(0.149278 1.31326e-07 4.52377e-15)
(0.149278 7.81345e-08 4.52666e-15)
(0.149278 1.33938e-08 4.49927e-15)
(0.149278 -7.59135e-08 4.54139e-15)
(0.149278 -1.84927e-07 4.64243e-15)
(0.149278 -3.00656e-07 4.60404e-15)
(0.149539 -4.42764e-07 4.70269e-15)
(0.149539 -3.42413e-07 4.68302e-15)
(0.149539 -2.52422e-07 4.64669e-15)
(0.149539 -1.9219e-07 4.55807e-15)
(0.149539 -1.42384e-07 4.59702e-15)
(0.149539 -1.02403e-07 4.61339e-15)
(0.149539 -7.06841e-08 4.62956e-15)
(0.149538 -4.49119e-08 4.60764e-15)
(0.149538 -2.38092e-08 4.59445e-15)
(0.149538 -6.35654e-09 4.59351e-15)
(0.149538 8.28518e-09 4.5813e-15)
(0.149538 2.07587e-08 4.58227e-15)
(0.149538 3.15667e-08 4.55695e-15)
(0.149538 4.11065e-08 4.52725e-15)
(0.149538 4.96966e-08 4.50538e-15)
(0.149538 5.75972e-08 4.49525e-15)
(0.149538 6.5023e-08 4.48942e-15)
(0.149538 7.21513e-08 4.46145e-15)
(0.149538 7.9128e-08 4.45743e-15)
(0.149538 8.60718e-08 4.46096e-15)
(0.149538 9.30778e-08 4.44472e-15)
(0.149538 1.0022e-07 4.42942e-15)
(0.149538 1.07554e-07 4.39068e-15)
(0.149538 1.15118e-07 4.38278e-15)
(0.149538 1.22935e-07 4.3985e-15)
(0.149538 1.31016e-07 4.39685e-15)
(0.149538 1.3936e-07 4.38369e-15)
(0.149538 1.47957e-07 4.33509e-15)
(0.149538 1.56785e-07 4.30408e-15)
(0.149538 1.65814e-07 4.29672e-15)
(0.149538 1.75004e-07 4.28482e-15)
(0.149538 1.84301e-07 4.28457e-15)
(0.149538 1.93643e-07 4.25558e-15)
(0.149539 2.0295e-07 4.21986e-15)
(0.149539 2.12134e-07 4.19406e-15)
(0.149539 2.21084e-07 4.04889e-15)
(0.149539 2.29687e-07 4.23015e-15)
(0.149539 2.37791e-07 4.25224e-15)
(0.149539 2.45268e-07 4.2261e-15)
(0.149539 2.51925e-07 4.38267e-15)
(0.149539 2.57644e-07 4.22276e-15)
(0.149539 2.62248e-07 4.29308e-15)
(0.149539 2.6563e-07 4.34023e-15)
(0.149539 2.67729e-07 4.33182e-15)
(0.149539 2.68338e-07 4.43394e-15)
(0.149539 2.67282e-07 4.32143e-15)
(0.149539 2.64149e-07 4.48629e-15)
(0.149539 2.58443e-07 4.3887e-15)
(0.149539 2.4952e-07 4.35478e-15)
(0.149539 2.3669e-07 4.45043e-15)
(0.149539 2.18911e-07 4.27246e-15)
(0.149539 1.95307e-07 4.37094e-15)
(0.149539 1.63903e-07 4.38797e-15)
(0.149539 1.23945e-07 4.37287e-15)
(0.149539 7.07896e-08 4.45562e-15)
(0.149539 5.77617e-09 4.23101e-15)
(0.149539 -8.29628e-08 4.48834e-15)
(0.149539 -1.91677e-07 4.46719e-15)
(0.149539 -3.05302e-07 4.43511e-15)
(0.149788 -4.35198e-07 4.65384e-15)
(0.149788 -3.37045e-07 4.59937e-15)
(0.149788 -2.46175e-07 4.59445e-15)
(0.149788 -1.85176e-07 4.49241e-15)
(0.149788 -1.34988e-07 4.53458e-15)
(0.149788 -9.4664e-08 4.58466e-15)
(0.149788 -6.28349e-08 4.57372e-15)
(0.149788 -3.71583e-08 4.57669e-15)
(0.149788 -1.63037e-08 4.54521e-15)
(0.149788 7.69079e-10 4.55346e-15)
(0.149788 1.4926e-08 4.56402e-15)
(0.149788 2.68338e-08 4.54565e-15)
(0.149788 3.70141e-08 4.54385e-15)
(0.149788 4.588e-08 4.48071e-15)
(0.149788 5.37622e-08 4.46864e-15)
(0.149788 6.09307e-08 4.48182e-15)
(0.149788 6.76078e-08 4.44695e-15)
(0.149788 7.39773e-08 4.44805e-15)
(0.149788 8.01905e-08 4.4246e-15)
(0.149788 8.63711e-08 4.43054e-15)
(0.149788 9.26189e-08 4.4356e-15)
(0.149788 9.90122e-08 4.40058e-15)
(0.149788 1.0561e-07 4.38437e-15)
(0.149788 1.12456e-07 4.3547e-15)
(0.149788 1.19575e-07 4.37509e-15)
(0.149788 1.26982e-07 4.39251e-15)
(0.149788 1.34679e-07 4.35671e-15)
(0.149788 1.42659e-07 4.33003e-15)
(0.149788 1.50902e-07 4.25102e-15)
(0.149788 1.5938e-07 4.26559e-15)
(0.149788 1.68055e-07 4.28271e-15)
(0.149788 1.76875e-07 4.2546e-15)
(0.149788 1.8578e-07 4.2559e-15)
(0.149788 1.94692e-07 4.18767e-15)
(0.149788 2.03525e-07 4.18063e-15)
(0.149788 2.1217e-07 4.14099e-15)
(0.149788 2.20515e-07 4.19817e-15)
(0.149788 2.28413e-07 4.15165e-15)
(0.149788 2.35737e-07 4.14236e-15)
(0.149788 2.42305e-07 4.2376e-15)
(0.149788 2.47992e-07 4.17582e-15)
(0.149788 2.52628e-07 4.21453e-15)
(0.149788 2.56094e-07 4.20758e-15)
(0.149788 2.58301e-07 4.21158e-15)
(0.149788 2.59037e-07 4.29379e-15)
(0.149788 2.58099e-07 4.2521e-15)
(0.149788 2.55082e-07 4.27689e-15)
(0.149789 2.49494e-07 4.22694e-15)
(0.149789 2.40694e-07 4.21596e-15)
(0.149789 2.27984e-07 4.29922e-15)
(0.149789 2.10336e-07 4.22634e-15)
(0.149789 1.86835e-07 4.23934e-15)
(0.149789 1.55571e-07 4.20248e-15)
(0.149789 1.15665e-07 4.21853e-15)
(0.149789 6.27861e-08 4.2837e-15)
(0.149789 -2.1788e-09 4.23899e-15)
(0.149789 -8.99645e-08 4.30452e-15)
(0.149789 -1.97866e-07 4.25628e-15)
(0.149789 -3.09009e-07 4.26486e-15)
(0.150026 -4.25615e-07 4.62361e-15)
(0.150026 -3.2989e-07 4.43865e-15)
(0.150026 -2.384e-07 4.56012e-15)
(0.150026 -1.76812e-07 4.47539e-15)
(0.150026 -1.26429e-07 4.52876e-15)
(0.150026 -8.59226e-08 4.5725e-15)
(0.150026 -5.41145e-08 4.42597e-15)
(0.150026 -2.86467e-08 4.56329e-15)
(0.150026 -8.13605e-09 4.40719e-15)
(0.150026 8.47521e-09 4.54163e-15)
(0.150026 2.20757e-08 4.55971e-15)
(0.150026 3.33534e-08 4.50299e-15)
(0.150026 4.28465e-08 4.53823e-15)
(0.150026 5.09817e-08 4.40124e-15)
(0.150026 5.81005e-08 4.45117e-15)
(0.150026 6.44814e-08 4.47914e-15)
(0.150026 7.03536e-08 4.31132e-15)
(0.150026 7.59067e-08 4.43857e-15)
(0.150026 8.12973e-08 4.39341e-15)
(0.150026 8.66535e-08 4.42436e-15)
(0.150026 9.20797e-08 4.43758e-15)
(0.150026 9.76585e-08 4.3722e-15)
(0.150026 1.03453e-07 4.3907e-15)
(0.150026 1.09511e-07 4.33107e-15)
(0.150026 1.15861e-07 4.3721e-15)
(0.150026 1.22523e-07 4.39897e-15)
(0.150026 1.295e-07 4.21998e-15)
(0.150026 1.36789e-07 4.33539e-15)
(0.150026 1.44373e-07 4.24092e-15)
(0.150026 1.52227e-07 4.24927e-15)
(0.150026 1.60314e-07 4.29306e-15)
(0.150026 1.68587e-07 4.23515e-15)
(0.150026 1.76985e-07 4.26257e-15)
(0.150026 1.85434e-07 4.18689e-15)
(0.150026 1.9385e-07 4.1856e-15)
(0.150026 2.02127e-07 4.18476e-15)
(0.150026 2.10156e-07 4.19815e-15)
(0.150026 2.17794e-07 4.08333e-15)
(0.150026 2.24914e-07 4.08016e-15)
(0.150026 2.31344e-07 4.1444e-15)
(0.150026 2.36955e-07 4.1452e-15)
(0.150026 2.41583e-07 4.16106e-15)
(0.150026 2.45096e-07 4.08183e-15)
(0.150026 2.47384e-07 4.10877e-15)
(0.150027 2.48229e-07 4.16749e-15)
(0.150027 2.47406e-07 4.17248e-15)
(0.150027 2.44516e-07 4.17885e-15)
(0.150027 2.39068e-07 4.02676e-15)
(0.150027 2.30431e-07 4.09031e-15)
(0.150027 2.179e-07 4.1415e-15)
(0.150027 2.00462e-07 4.12838e-15)
(0.150027 1.77173e-07 4.13376e-15)
(0.150027 1.46193e-07 3.99606e-15)
(0.150027 1.06533e-07 4.07395e-15)
(0.150027 5.41745e-08 4.13976e-15)
(0.150027 -1.04163e-08 4.14176e-15)
(0.150027 -9.68707e-08 4.17033e-15)
(0.150027 -2.0346e-07 4.08239e-15)
(0.150027 -3.11769e-07 4.10669e-15)
(0.150253 -4.14028e-07 4.6136e-15)
(0.150253 -3.2095e-07 4.60022e-15)
(0.150253 -2.29102e-07 4.59625e-15)
(0.150253 -1.67107e-07 4.56223e-15)
(0.150253 -1.16718e-07 4.55698e-15)
(0.150253 -7.61944e-08 4.57893e-15)
(0.150253 -4.45407e-08 4.6126e-15)
(0.150253 -1.93953e-08 4.60364e-15)
(0.150253 6.76988e-10 4.60546e-15)
(0.150253 1.67477e-08 4.58866e-15)
(0.150253 2.9724e-08 4.56832e-15)
(0.150253 4.03121e-08 4.57248e-15)
(0.150253 4.9064e-08 4.56472e-15)
(0.150253 5.64176e-08 4.544e-15)
(0.150253 6.27238e-08 4.50025e-15)
(0.150253 6.82681e-08 4.4869e-15)
(0.150253 7.32857e-08 4.49009e-15)
(0.150253 7.79715e-08 4.48077e-15)
(0.150253 8.24864e-08 4.47909e-15)
(0.150253 8.69632e-08 4.46702e-15)
(0.150253 9.15103e-08 4.4501e-15)
(0.150253 9.62147e-08 4.45645e-15)
(0.150253 1.01144e-07 4.43937e-15)
(0.150253 1.06349e-07 4.42145e-15)
(0.150253 1.11864e-07 4.41822e-15)
(0.150253 1.17711e-07 4.41467e-15)
(0.150253 1.23899e-07 4.39895e-15)
(0.150253 1.30427e-07 4.37453e-15)
(0.150253 1.37281e-07 4.32394e-15)
(0.150253 1.44439e-07 4.31642e-15)
(0.150253 1.51867e-07 4.31166e-15)
(0.150253 1.59521e-07 4.3161e-15)
(0.150253 1.67342e-07 4.31673e-15)
(0.150253 1.75261e-07 4.29412e-15)
(0.150253 1.83194e-07 4.26427e-15)
(0.150253 1.9104e-07 4.24078e-15)
(0.150253 1.98691e-07 4.21465e-15)
(0.150253 2.06011e-07 4.11335e-15)
(0.150253 2.12874e-07 4.09013e-15)
(0.150253 2.19116e-07 4.09966e-15)
(0.150253 2.24605e-07 4.11429e-15)
(0.150253 2.29181e-07 4.11367e-15)
(0.150254 2.32702e-07 4.0602e-15)
(0.150254 2.3504e-07 4.05879e-15)
(0.150254 2.35974e-07 4.07837e-15)
(0.150254 2.35258e-07 4.09891e-15)
(0.150254 2.32502e-07 4.09603e-15)
(0.150254 2.27217e-07 4.02998e-15)
(0.150254 2.1878e-07 4.02598e-15)
(0.150254 2.06486e-07 4.03473e-15)
(0.150254 1.89338e-07 4.04337e-15)
(0.150254 1.66373e-07 4.04111e-15)
(0.150254 1.35825e-07 3.98141e-15)
(0.150254 9.66095e-08 4.00497e-15)
(0.150254 4.50161e-08 4.02556e-15)
(0.150254 -1.88723e-08 4.04873e-15)
(0.150254 -1.03625e-07 4.06302e-15)
(0.150254 -2.0842e-07 4.00428e-15)
(0.150254 -3.13568e-07 4.02561e-15)
(0.15047 -4.00453e-07 4.62163e-15)
(0.15047 -3.10234e-07 4.68152e-15)
(0.15047 -2.18292e-07 4.644e-15)
(0.15047 -1.56077e-07 4.61956e-15)
(0.15047 -1.05876e-07 4.59838e-15)
(0.15047 -6.55053e-08 4.5983e-15)
(0.15047 -3.41416e-08 4.68106e-15)
(0.15047 -9.4325e-09 4.6583e-15)
(0.15047 1.01081e-08 4.79059e-15)
(0.15047 2.55621e-08 4.64149e-15)
(0.15047 3.78507e-08 4.57663e-15)
(0.15047 4.76948e-08 4.6211e-15)
(0.15047 5.56572e-08 4.59105e-15)
(0.150469 6.21849e-08 4.67051e-15)
(0.150469 6.7636e-08 4.55799e-15)
(0.150469 7.23017e-08 4.49589e-15)
(0.150469 7.64222e-08 4.55322e-15)
(0.150469 8.01965e-08 4.52583e-15)
(0.150469 8.37898e-08 4.55992e-15)
(0.150469 8.73387e-08 4.51126e-15)
(0.150469 9.09557e-08 4.46403e-15)
(0.150469 9.47319e-08 4.52211e-15)
(0.150469 9.87392e-08 4.48798e-15)
(0.150469 1.03033e-07 4.51354e-15)
(0.150469 1.07651e-07 4.46465e-15)
(0.150469 1.1262e-07 4.43275e-15)
(0.150469 1.17953e-07 4.57386e-15)
(0.15047 1.23652e-07 4.41694e-15)
(0.15047 1.29708e-07 4.48978e-15)
(0.15047 1.36101e-07 4.38026e-15)
(0.15047 1.42801e-07 4.33505e-15)
(0.15047 1.49766e-07 4.4987e-15)
(0.15047 1.56943e-07 4.36815e-15)
(0.15047 1.64263e-07 4.40325e-15)
(0.15047 1.71647e-07 4.34359e-15)
(0.15047 1.78998e-07 4.30336e-15)
(0.15047 1.8621e-07 4.22887e-15)
(0.15047 1.93154e-07 4.14992e-15)
(0.15047 1.99704e-07 4.11629e-15)
(0.15047 2.05706e-07 4.07226e-15)
(0.15047 2.11023e-07 4.09923e-15)
(0.15047 2.15501e-07 4.06649e-15)
(0.15047 2.1899e-07 4.02991e-15)
(0.15047 2.21345e-07 4.02912e-15)
(0.15047 2.22343e-07 4.00636e-15)
(0.15047 2.21727e-07 4.04761e-15)
(0.15047 2.19108e-07 4.02059e-15)
(0.15047 2.14005e-07 3.98549e-15)
(0.15047 2.05805e-07 3.98346e-15)
(0.15047 1.93804e-07 3.9513e-15)
(0.15047 1.77028e-07 3.984e-15)
(0.150471 1.54501e-07 3.959e-15)
(0.150471 1.24532e-07 3.93728e-15)
(0.150471 8.59639e-08 3.95241e-15)
(0.150471 3.5383e-08 3.93273e-15)
(0.150471 -2.74737e-08 3.98085e-15)
(0.150471 -1.10164e-07 3.96955e-15)
(0.150471 -2.127e-07 3.94937e-15)
(0.150471 -3.14385e-07 3.96728e-15)
(0.150676 -3.84908e-07 4.64688e-15)
(0.150676 -2.97751e-07 4.66541e-15)
(0.150676 -2.05987e-07 4.64557e-15)
(0.150676 -1.43748e-07 4.68425e-15)
(0.150676 -9.39339e-08 4.63864e-15)
(0.150676 -5.38907e-08 4.63254e-15)
(0.150676 -2.29559e-08 4.66967e-15)
(0.150676 1.20243e-09 4.65484e-15)
(0.150676 2.0119e-08 4.67264e-15)
(0.150676 3.48832e-08 4.62596e-15)
(0.150676 4.64247e-08 4.57383e-15)
(0.150676 5.54757e-08 4.57025e-15)
(0.150676 6.26066e-08 4.57432e-15)
(0.150676 6.82707e-08 4.6006e-15)
(0.150676 7.28313e-08 4.54075e-15)
(0.150676 7.65838e-08 4.49647e-15)
(0.150676 7.97719e-08 4.51819e-15)
(0.150676 8.25981e-08 4.51409e-15)
(0.150676 8.5231e-08 4.53272e-15)
(0.150676 8.78109e-08 4.50489e-15)
(0.150676 9.04539e-08 4.4686e-15)
(0.150676 9.3255e-08 4.48888e-15)
(0.150676 9.62904e-08 4.4851e-15)
(0.150676 9.96194e-08 4.49062e-15)
(0.150676 1.03286e-07 4.46555e-15)
(0.150676 1.07319e-07 4.44562e-15)
(0.150676 1.11736e-07 4.4414e-15)
(0.150676 1.16544e-07 4.42631e-15)
(0.150676 1.21737e-07 4.43084e-15)
(0.150676 1.273e-07 4.38651e-15)
(0.150676 1.33206e-07 4.35018e-15)
(0.150676 1.39417e-07 4.36935e-15)
(0.150676 1.45882e-07 4.37712e-15)
(0.150676 1.52538e-07 4.40561e-15)
(0.150676 1.59308e-07 4.34923e-15)
(0.150676 1.661e-07 4.37068e-15)
(0.150676 1.72811e-07 4.21196e-15)
(0.150676 1.7932e-07 4.16291e-15)
(0.150676 1.85501e-07 4.14078e-15)
(0.150676 1.91207e-07 4.02964e-15)
(0.150676 1.96303e-07 4.11753e-15)
(0.150676 2.00634e-07 4.00129e-15)
(0.150677 2.04047e-07 3.99256e-15)
(0.150677 2.06386e-07 4.00935e-15)
(0.150677 2.07424e-07 3.92608e-15)
(0.150677 2.06894e-07 4.03734e-15)
(0.150677 2.04414e-07 3.93255e-15)
(0.150677 1.99511e-07 3.93434e-15)
(0.150677 1.91582e-07 3.95387e-15)
(0.150677 1.7993e-07 3.8649e-15)
(0.150677 1.63608e-07 3.96942e-15)
(0.150677 1.41633e-07 3.86776e-15)
(0.150677 1.12396e-07 3.88217e-15)
(0.150677 7.46785e-08 3.91617e-15)
(0.150677 2.53578e-08 3.83566e-15)
(0.150677 -3.61384e-08 3.95797e-15)
(0.150677 -1.16413e-07 3.86904e-15)
(0.150677 -2.16246e-07 3.88653e-15)
(0.150677 -3.14187e-07 3.92538e-15)
(0.150873 -3.67414e-07 4.68262e-15)
(0.150873 -2.83513e-07 4.64242e-15)
(0.150873 -1.92206e-07 4.63804e-15)
(0.150873 -1.30151e-07 4.65488e-15)
(0.150873 -8.09293e-08 4.65274e-15)
(0.150873 -4.13951e-08 4.68478e-15)
(0.150873 -1.10317e-08 4.63527e-15)
(0.150873 1.24599e-08 4.64962e-15)
(0.150873 3.06611e-08 4.6294e-15)
(0.150873 4.46646e-08 4.58431e-15)
(0.150873 5.54038e-08 4.55943e-15)
(0.150873 6.36179e-08 4.50379e-15)
(0.150873 6.98814e-08 4.57398e-15)
(0.150873 7.46509e-08 4.5559e-15)
(0.150873 7.82928e-08 4.5053e-15)
(0.150873 8.11048e-08 4.47708e-15)
(0.150873 8.3333e-08 4.45483e-15)
(0.150873 8.51822e-08 4.51477e-15)
(0.150873 8.68238e-08 4.50184e-15)
(0.150873 8.84012e-08 4.47804e-15)
(0.150873 9.00337e-08 4.46218e-15)
(0.150873 9.18204e-08 4.43897e-15)
(0.150873 9.38413e-08 4.48907e-15)
(0.150873 9.61601e-08 4.46823e-15)
(0.150873 9.88249e-08 4.44641e-15)
(0.150873 1.0187e-07 4.45952e-15)
(0.150873 1.05318e-07 4.41611e-15)
(0.150873 1.09178e-07 4.43445e-15)
(0.150873 1.1345e-07 4.4113e-15)
(0.150873 1.18122e-07 4.36827e-15)
(0.150873 1.23171e-07 4.35194e-15)
(0.150873 1.28564e-07 4.32892e-15)
(0.150873 1.34255e-07 4.39654e-15)
(0.150873 1.40183e-07 4.3853e-15)
(0.150873 1.46276e-07 4.334e-15)
(0.150873 1.52447e-07 4.32867e-15)
(0.150873 1.58598e-07 4.24022e-15)
(0.150873 1.64611e-07 4.18432e-15)
(0.150873 1.70366e-07 4.16269e-15)
(0.150873 1.75723e-07 4.0743e-15)
(0.150873 1.80545e-07 4.08165e-15)
(0.150873 1.84681e-07 4.00107e-15)
(0.150873 1.87975e-07 3.97811e-15)
(0.150873 1.90261e-07 4.00273e-15)
(0.150873 1.91311e-07 3.93662e-15)
(0.150873 1.90854e-07 3.97708e-15)
(0.150873 1.88513e-07 3.90263e-15)
(0.150874 1.83825e-07 3.90908e-15)
(0.150874 1.76201e-07 3.94294e-15)
(0.150874 1.64953e-07 3.87371e-15)
(0.150874 1.49166e-07 3.9125e-15)
(0.150874 1.27859e-07 3.8406e-15)
(0.150874 9.95058e-08 3.85862e-15)
(0.150874 6.28455e-08 3.90434e-15)
(0.150874 1.50327e-08 3.82897e-15)
(0.150874 -4.47757e-08 3.89112e-15)
(0.150874 -1.22293e-07 3.83661e-15)
(0.150874 -2.18997e-07 3.85595e-15)
(0.150874 -3.12929e-07 3.90864e-15)
(0.15106 -3.47986e-07 4.70117e-15)
(0.15106 -2.6753e-07 4.582e-15)
(0.15106 -1.76972e-07 4.63126e-15)
(0.15106 -1.1532e-07 4.60929e-15)
(0.15106 -6.69059e-08 4.66198e-15)
(0.15106 -2.80705e-08 4.70457e-15)
(0.15106 1.57346e-09 4.58871e-15)
(0.15106 2.42806e-08 4.65025e-15)
(0.15106 4.16749e-08 4.56688e-15)
(0.15106 5.48491e-08 4.5201e-15)
(0.15106 6.47346e-08 4.55581e-15)
(0.15106 7.20729e-08 4.42575e-15)
(0.15106 7.74389e-08 4.65468e-15)
(0.15106 8.12895e-08 4.5161e-15)
(0.15106 8.39915e-08 4.44919e-15)
(0.15106 8.58432e-08 4.5022e-15)
(0.15106 8.70915e-08 4.37948e-15)
(0.15106 8.79426e-08 4.51591e-15)
(0.15106 8.85699e-08 4.46555e-15)
(0.15106 8.91192e-08 4.44744e-15)
(0.15106 8.97131e-08 4.49271e-15)
(0.15106 9.04537e-08 4.37502e-15)
(0.15106 9.14253e-08 4.54672e-15)
(0.15106 9.26958e-08 4.44087e-15)
(0.15106 9.43179e-08 4.41912e-15)
(0.15106 9.63307e-08 4.50454e-15)
(0.15106 9.87606e-08 4.37966e-15)
(0.15106 1.01623e-07 4.56093e-15)
(0.15106 1.0492e-07 4.38049e-15)
(0.15106 1.08647e-07 4.3272e-15)
(0.15106 1.12783e-07 4.38172e-15)
(0.15106 1.17301e-07 4.27311e-15)
(0.15106 1.22157e-07 4.41345e-15)
(0.15106 1.27298e-07 4.36902e-15)
(0.15106 1.32654e-07 4.29895e-15)
(0.15106 1.38145e-07 4.30773e-15)
(0.15106 1.43676e-07 4.12789e-15)
(0.15106 1.49137e-07 4.20063e-15)
(0.15106 1.54411e-07 4.1862e-15)
(0.15106 1.59363e-07 3.99008e-15)
(0.15106 1.6386e-07 4.08799e-15)
(0.151061 1.67752e-07 4.00605e-15)
(0.151061 1.70882e-07 3.98033e-15)
(0.151061 1.73079e-07 4.01733e-15)
(0.151061 1.74114e-07 3.84182e-15)
(0.151061 1.73713e-07 3.94767e-15)
(0.151061 1.7151e-07 3.84616e-15)
(0.151061 1.67051e-07 3.89954e-15)
(0.151061 1.59763e-07 3.96294e-15)
(0.151061 1.48975e-07 3.90462e-15)
(0.151061 1.33804e-07 3.90617e-15)
(0.151061 1.1328e-07 3.84551e-15)
(0.151061 8.59637e-08 3.85555e-15)
(0.151061 5.05675e-08 3.9281e-15)
(0.151061 4.50974e-09 3.8014e-15)
(0.151061 -5.3286e-08 3.87649e-15)
(0.151061 -1.27711e-07 3.74861e-15)
(0.151061 -2.2088e-07 3.85212e-15)
(0.151061 -3.10555e-07 3.93269e-15)
(0.151239 -3.26637e-07 4.57759e-15)
(0.151239 -2.49806e-07 4.54315e-15)
(0.151239 -1.60305e-07 4.5521e-15)
(0.151239 -9.92931e-08 4.54467e-15)
(0.151239 -5.19126e-08 4.55048e-15)
(0.151239 -1.3976e-08 4.60218e-15)
(0.151238 1.4794e-08 4.55429e-15)
(0.151238 3.65956e-08 4.58035e-15)
(0.151238 5.3091e-08 4.55955e-15)
(0.151238 6.53688e-08 4.54764e-15)
(0.151238 7.43522e-08 4.51979e-15)
(0.151238 8.07801e-08 4.42556e-15)
(0.151238 8.52239e-08 4.51745e-15)
(0.151238 8.81371e-08 4.50587e-15)
(0.151238 8.98846e-08 4.49295e-15)
(0.151238 9.07632e-08 4.412e-15)
(0.151238 9.10191e-08 4.41052e-15)
(0.151238 9.08589e-08 4.48458e-15)
(0.151238 9.0457e-08 4.47458e-15)
(0.151238 8.99609e-08 4.5904e-15)
(0.151238 8.9496e-08 4.43619e-15)
(0.151238 8.91675e-08 4.40179e-15)
(0.151238 8.90635e-08 4.475e-15)
(0.151238 8.9256e-08 4.45855e-15)
(0.151238 8.98022e-08 4.47055e-15)
(0.151238 9.0746e-08 4.49381e-15)
(0.151238 9.21186e-08 4.41752e-15)
(0.151238 9.39397e-08 4.43774e-15)
(0.151238 9.62177e-08 4.41639e-15)
(0.151238 9.89503e-08 4.44874e-15)
(0.151238 1.02124e-07 4.26734e-15)
(0.151238 1.05714e-07 4.31412e-15)
(0.151238 1.09682e-07 4.40492e-15)
(0.151238 1.1398e-07 4.39771e-15)
(0.151239 1.18545e-07 4.4764e-15)
(0.151239 1.233e-07 4.35627e-15)
(0.151239 1.28156e-07 4.27938e-15)
(0.151239 1.33009e-07 4.23091e-15)
(0.151239 1.37748e-07 4.21115e-15)
(0.151239 1.42243e-07 4.15385e-15)
(0.151239 1.46363e-07 4.15546e-15)
(0.151239 1.49964e-07 4.08103e-15)
(0.151239 1.52887e-07 4.04434e-15)
(0.151239 1.54957e-07 4.05741e-15)
(0.151239 1.55949e-07 4.02803e-15)
(0.151239 1.55589e-07 3.9448e-15)
(0.151239 1.5352e-07 4.01987e-15)
(0.151239 1.49301e-07 3.97866e-15)
(0.151239 1.42381e-07 4.01573e-15)
(0.151239 1.32107e-07 3.98611e-15)
(0.151239 1.17632e-07 4.01687e-15)
(0.151239 9.80079e-08 4.03209e-15)
(0.151239 7.18811e-08 3.93011e-15)
(0.151239 3.79558e-08 3.98641e-15)
(0.15124 -6.10043e-09 3.99024e-15)
(0.15124 -6.15616e-08 3.88518e-15)
(0.15124 -1.32569e-07 4.03558e-15)
(0.15124 -2.21813e-07 3.94056e-15)
(0.15124 -3.06991e-07 3.99659e-15)
(0.151408 -3.03373e-07 4.45448e-15)
(0.151408 -2.30342e-07 4.47162e-15)
(0.151408 -1.42222e-07 4.48341e-15)
(0.151408 -8.21073e-08 4.44911e-15)
(0.151408 -3.60015e-08 4.44842e-15)
(0.151408 8.2374e-10 4.4836e-15)
(0.151408 2.85571e-08 4.49917e-15)
(0.151408 4.93275e-08 4.52297e-15)
(0.151408 6.483e-08 4.53095e-15)
(0.151408 7.61447e-08 4.55995e-15)
(0.151408 8.41797e-08 4.45374e-15)
(0.151408 8.96661e-08 4.44991e-15)
(0.151408 9.31672e-08 4.48138e-15)
(0.151408 9.51301e-08 4.49498e-15)
(0.151408 9.59144e-08 4.52181e-15)
(0.151408 9.58137e-08 4.43495e-15)
(0.151408 9.50719e-08 4.43756e-15)
(0.151408 9.38946e-08 4.47112e-15)
(0.151408 9.24564e-08 4.48693e-15)
(0.151408 9.09061e-08 4.54933e-15)
(0.151408 8.93709e-08 4.43981e-15)
(0.151408 8.79591e-08 4.44049e-15)
(0.151408 8.67622e-08 4.46887e-15)
(0.151408 8.5856e-08 4.47608e-15)
(0.151408 8.53022e-08 4.52923e-15)
(0.151408 8.51495e-08 4.45124e-15)
(0.151408 8.54338e-08 4.44562e-15)
(0.151408 8.61798e-08 4.44729e-15)
(0.151408 8.74009e-08 4.44501e-15)
(0.151408 8.90996e-08 4.45448e-15)
(0.151408 9.12673e-08 4.35788e-15)
(0.151408 9.38841e-08 4.37422e-15)
(0.151408 9.69183e-08 4.41338e-15)
(0.151408 1.00325e-07 4.42597e-15)
(0.151408 1.04048e-07 4.44561e-15)
(0.151408 1.08016e-07 4.41323e-15)
(0.151408 1.12146e-07 4.33009e-15)
(0.151408 1.16341e-07 4.19105e-15)
(0.151408 1.20492e-07 4.25017e-15)
(0.151408 1.2448e-07 4.20642e-15)
(0.151408 1.28177e-07 4.22452e-15)
(0.151408 1.3144e-07 4.18325e-15)
(0.151409 1.34113e-07 4.10425e-15)
(0.151409 1.36021e-07 4.13948e-15)
(0.151409 1.36941e-07 4.12175e-15)
(0.151409 1.36605e-07 4.15032e-15)
(0.151409 1.34667e-07 4.13162e-15)
(0.151409 1.30701e-07 4.08368e-15)
(0.151409 1.24178e-07 4.12112e-15)
(0.151409 1.1447e-07 4.10887e-15)
(0.151409 1.00771e-07 4.1259e-15)
(0.151409 8.21625e-08 4.07947e-15)
(0.151409 5.73782e-08 4.03681e-15)
(0.151409 2.51304e-08 4.08351e-15)
(0.151409 -1.66789e-08 4.07264e-15)
(0.151409 -6.94864e-08 4.12327e-15)
(0.151409 -1.36756e-07 4.10218e-15)
(0.151409 -2.21701e-07 4.0525e-15)
(0.151409 -3.02148e-07 4.1127e-15)
(0.151569 -2.78185e-07 4.37205e-15)
(0.151569 -2.09124e-07 4.41933e-15)
(0.151569 -1.22734e-07 4.43412e-15)
(0.151569 -6.37989e-08 4.35989e-15)
(0.151569 -1.92264e-08 4.37787e-15)
(0.151569 1.62601e-08 4.41106e-15)
(0.151569 4.27833e-08 4.46057e-15)
(0.151569 6.23909e-08 4.48271e-15)
(0.151569 7.68035e-08 4.51614e-15)
(0.151569 8.70873e-08 4.55855e-15)
(0.151569 9.41285e-08 4.51336e-15)
(0.151569 9.86443e-08 4.50817e-15)
(0.151569 1.01186e-07 4.49358e-15)
(0.151569 1.02189e-07 4.49975e-15)
(0.151569 1.02007e-07 4.53134e-15)
(0.151569 1.00926e-07 4.50255e-15)
(0.151569 9.91879e-08 4.49049e-15)
(0.151569 9.69951e-08 4.49243e-15)
(0.151569 9.45214e-08 4.51459e-15)
(0.151569 9.19163e-08 4.57256e-15)
(0.151569 8.93085e-08 4.51963e-15)
(0.151569 8.68084e-08 4.50061e-15)
(0.151569 8.45107e-08 4.49805e-15)
(0.151569 8.24948e-08 4.49676e-15)
(0.151569 8.08269e-08 4.55373e-15)
(0.151569 7.956e-08 4.51401e-15)
(0.151569 7.87349e-08 4.51458e-15)
(0.151569 7.83813e-08 4.48409e-15)
(0.151569 7.85175e-08 4.48413e-15)
(0.151569 7.91512e-08 4.50273e-15)
(0.151569 8.0279e-08 4.46185e-15)
(0.151569 8.18862e-08 4.4634e-15)
(0.151569 8.39466e-08 4.46378e-15)
(0.151569 8.64212e-08 4.46402e-15)
(0.151569 8.92592e-08 4.5185e-15)
(0.151569 9.23957e-08 4.49964e-15)
(0.151569 9.5754e-08 4.446e-15)
(0.151569 9.92431e-08 4.35563e-15)
(0.151569 1.02762e-07 4.35275e-15)
(0.151569 1.06197e-07 4.33918e-15)
(0.15157 1.09423e-07 4.35896e-15)
(0.15157 1.12305e-07 4.36686e-15)
(0.15157 1.14689e-07 4.29653e-15)
(0.15157 1.164e-07 4.29698e-15)
(0.15157 1.17223e-07 4.34012e-15)
(0.15157 1.16895e-07 4.36433e-15)
(0.15157 1.15083e-07 4.39043e-15)
(0.15157 1.11382e-07 4.31768e-15)
(0.15157 1.05286e-07 4.32581e-15)
(0.15157 9.61959e-08 4.3263e-15)
(0.15157 8.33524e-08 4.3119e-15)
(0.15157 6.5873e-08 4.31392e-15)
(0.15157 4.25833e-08 4.25299e-15)
(0.15157 1.22185e-08 4.28385e-15)
(0.15157 -2.70997e-08 4.30885e-15)
(0.15157 -7.6937e-08 4.33197e-15)
(0.15157 -1.40153e-07 4.34704e-15)
(0.15157 -2.20435e-07 4.29342e-15)
(0.15157 -2.95914e-07 4.33834e-15)
(0.151722 -2.51053e-07 4.33462e-15)
(0.151722 -1.86125e-07 4.37121e-15)
(0.151722 -1.01845e-07 4.40449e-15)
(0.151722 -4.44002e-08 4.41225e-15)
(0.151722 -1.64114e-09 4.36547e-15)
(0.151722 3.2261e-08 4.37722e-15)
(0.151722 5.73877e-08 4.42057e-15)
(0.151722 7.56928e-08 4.46008e-15)
(0.151722 8.89133e-08 4.47905e-15)
(0.151722 9.80959e-08 4.6274e-15)
(0.151722 1.04097e-07 4.53742e-15)
(0.151722 1.07614e-07 4.61597e-15)
(0.151722 1.0918e-07 4.52092e-15)
(0.151722 1.09218e-07 4.59698e-15)
(0.151722 1.08069e-07 4.52464e-15)
(0.151722 1.06013e-07 4.53303e-15)
(0.151722 1.03286e-07 4.62146e-15)
(0.151722 1.00086e-07 4.51933e-15)
(0.151722 9.65853e-08 4.62131e-15)
(0.151722 9.29335e-08 4.66522e-15)
(0.151722 8.92596e-08 4.57042e-15)
(0.151722 8.5676e-08 4.62826e-15)
(0.151722 8.22797e-08 4.53074e-15)
(0.151722 7.91538e-08 4.60775e-15)
(0.151722 7.63681e-08 4.63573e-15)
(0.151722 7.39799e-08 4.55996e-15)
(0.151722 7.2035e-08 4.63157e-15)
(0.151722 7.05677e-08 4.53407e-15)
(0.151722 6.96016e-08 4.59844e-15)
(0.151722 6.91494e-08 4.52335e-15)
(0.151722 6.92131e-08 4.5197e-15)
(0.151722 6.97835e-08 4.52078e-15)
(0.151722 7.08399e-08 4.51989e-15)
(0.151722 7.23495e-08 4.59445e-15)
(0.151722 7.42674e-08 4.53023e-15)
(0.151722 7.65353e-08 4.65826e-15)
(0.151722 7.90832e-08 4.51514e-15)
(0.151722 8.18271e-08 4.46102e-15)
(0.151722 8.46729e-08 4.54295e-15)
(0.151722 8.75127e-08 4.4596e-15)
(0.151722 9.02289e-08 4.47744e-15)
(0.151722 9.26902e-08 4.51671e-15)
(0.151723 9.47478e-08 4.49017e-15)
(0.151723 9.62315e-08 4.51287e-15)
(0.151723 9.69323e-08 4.55261e-15)
(0.151723 9.65969e-08 4.55357e-15)
(0.151723 9.49091e-08 4.57551e-15)
(0.151723 9.14828e-08 4.54816e-15)
(0.151723 8.58433e-08 4.50823e-15)
(0.151723 7.74228e-08 4.62988e-15)
(0.151723 6.55125e-08 4.61534e-15)
(0.151723 4.92754e-08 4.50344e-15)
(0.151723 2.76311e-08 4.4901e-15)
(0.151723 -6.47102e-10 4.47813e-15)
(0.151723 -3.72304e-08 4.60577e-15)
(0.151723 -8.37825e-08 4.64128e-15)
(0.151723 -1.4263e-07 4.56602e-15)
(0.151723 -2.17889e-07 4.54686e-15)
(0.151723 -2.88158e-07 4.54457e-15)
(0.151867 -2.21933e-07 4.18195e-15)
(0.151867 -1.613e-07 4.21537e-15)
(0.151867 -7.95425e-08 4.22493e-15)
(0.151867 -2.39377e-08 4.21485e-15)
(0.151867 1.67015e-08 4.21879e-15)
(0.151867 4.87522e-08 4.22254e-15)
(0.151867 7.22801e-08 4.27545e-15)
(0.151867 8.91325e-08 4.28779e-15)
(0.151867 1.01052e-07 4.32035e-15)
(0.151867 1.09058e-07 4.34094e-15)
(0.151867 1.13969e-07 4.36824e-15)
(0.151867 1.16457e-07 4.38458e-15)
(0.151867 1.17032e-07 4.3607e-15)
(0.151867 1.161e-07 4.34349e-15)
(0.151867 1.13988e-07 4.35129e-15)
(0.151867 1.10966e-07 4.39168e-15)
(0.151867 1.07262e-07 4.39262e-15)
(0.151867 1.0307e-07 4.38753e-15)
(0.151867 9.85597e-08 4.3935e-15)
(0.151867 9.3878e-08 4.40927e-15)
(0.151867 8.91543e-08 4.41719e-15)
(0.151867 8.45021e-08 4.41389e-15)
(0.151867 8.00204e-08 4.38948e-15)
(0.151867 7.5795e-08 4.36249e-15)
(0.151867 7.18992e-08 4.38732e-15)
(0.151867 6.83944e-08 4.40382e-15)
(0.151867 6.53308e-08 4.42216e-15)
(0.151867 6.27475e-08 4.38825e-15)
(0.151867 6.0673e-08 4.36566e-15)
(0.151867 5.91252e-08 4.36116e-15)
(0.151867 5.81116e-08 4.39176e-15)
(0.151867 5.76284e-08 4.42362e-15)
(0.151867 5.76609e-08 4.40395e-15)
(0.151867 5.81824e-08 4.36695e-15)
(0.151867 5.91543e-08 4.39507e-15)
(0.151867 6.05253e-08 4.41057e-15)
(0.151867 6.22321e-08 4.41507e-15)
(0.151867 6.41983e-08 4.38548e-15)
(0.151867 6.63367e-08 4.40511e-15)
(0.151867 6.85469e-08 4.42658e-15)
(0.151867 7.07179e-08 4.46189e-15)
(0.151867 7.27244e-08 4.50396e-15)
(0.151867 7.4424e-08 4.48066e-15)
(0.151867 7.56524e-08 4.48798e-15)
(0.151868 7.62097e-08 4.5415e-15)
(0.151868 7.58546e-08 4.56278e-15)
(0.151868 7.42889e-08 4.59534e-15)
(0.151868 7.115e-08 4.55324e-15)
(0.151868 6.59956e-08 4.56365e-15)
(0.151868 5.82952e-08 4.57469e-15)
(0.151868 4.73946e-08 4.55474e-15)
(0.151868 3.2511e-08 4.55944e-15)
(0.151868 1.2661e-08 4.52406e-15)
(0.151868 -1.33288e-08 4.53766e-15)
(0.151868 -4.69342e-08 4.56547e-15)
(0.151868 -8.98867e-08 4.58505e-15)
(0.151868 -1.44047e-07 4.61995e-15)
(0.151868 -2.13924e-07 4.60145e-15)
(0.151868 -2.78722e-07 4.62215e-15)
(0.152004 -1.90756e-07 4.04492e-15)
(0.152004 -1.34577e-07 4.09868e-15)
(0.152004 -5.58015e-08 4.0593e-15)
(0.152004 -2.43047e-09 4.04312e-15)
(0.152004 3.57507e-08 4.07948e-15)
(0.152004 6.56568e-08 4.08188e-15)
(0.152004 8.7364e-08 4.10438e-15)
(0.152004 1.026e-07 4.1325e-15)
(0.152004 1.13098e-07 4.0939e-15)
(0.152004 1.19845e-07 4.10406e-15)
(0.152004 1.23612e-07 4.22971e-15)
(0.152004 1.25037e-07 4.17679e-15)
(0.152004 1.24605e-07 4.19612e-15)
(0.152004 1.22698e-07 4.24055e-15)
(0.152004 1.19629e-07 4.13643e-15)
(0.152004 1.15654e-07 4.27005e-15)
(0.152004 1.10991e-07 4.21647e-15)
(0.152004 1.0583e-07 4.23724e-15)
(0.152004 1.00334e-07 4.28826e-15)
(0.152004 9.46484e-08 4.18359e-15)
(0.152004 8.89014e-08 4.28904e-15)
(0.152004 8.32064e-08 4.31923e-15)
(0.152004 7.76637e-08 4.24262e-15)
(0.152004 7.23613e-08 4.26696e-15)
(0.152004 6.73753e-08 4.15809e-15)
(0.152004 6.27708e-08 4.27643e-15)
(0.152004 5.86021e-08 4.22003e-15)
(0.152004 5.49127e-08 4.24053e-15)
(0.152004 5.1736e-08 4.1733e-15)
(0.152004 4.90952e-08 4.15041e-15)
(0.152004 4.70029e-08 4.27903e-15)
(0.152004 4.54611e-08 4.33913e-15)
(0.152004 4.44609e-08 4.27096e-15)
(0.152004 4.39821e-08 4.18754e-15)
(0.152004 4.39926e-08 4.17003e-15)
(0.152004 4.4448e-08 4.26031e-15)
(0.152004 4.52925e-08 4.32268e-15)
(0.152004 4.64572e-08 4.31422e-15)
(0.152004 4.78624e-08 4.3546e-15)
(0.152004 4.94156e-08 4.39862e-15)
(0.152004 5.10131e-08 4.43005e-15)
(0.152004 5.2537e-08 4.47526e-15)
(0.152004 5.38522e-08 4.46427e-15)
(0.152004 5.48026e-08 4.5144e-15)
(0.152004 5.5199e-08 4.54126e-15)
(0.152005 5.48145e-08 4.56001e-15)
(0.152005 5.33711e-08 4.56278e-15)
(0.152005 5.05328e-08 4.53857e-15)
(0.152005 4.58925e-08 4.58303e-15)
(0.152005 3.8962e-08 4.61623e-15)
(0.152005 2.91464e-08 4.60833e-15)
(0.152005 1.5725e-08 4.59419e-15)
(0.152005 -2.18452e-09 4.54793e-15)
(0.152005 -2.56868e-08 4.58965e-15)
(0.152005 -5.60717e-08 4.59547e-15)
(0.152005 -9.51084e-08 4.62053e-15)
(0.152005 -1.44255e-07 4.64738e-15)
(0.152005 -2.08381e-07 4.63694e-15)
(0.152005 -2.6742e-07 4.68107e-15)
(0.152133 -1.57419e-07 4.05547e-15)
(0.152133 -1.05854e-07 4.04848e-15)
(0.152133 -3.05769e-08 4.04513e-15)
(0.152133 2.01104e-08 4.16869e-15)
(0.152133 5.54565e-08 4.12229e-15)
(0.152133 8.28935e-08 4.095e-15)
(0.152133 1.02534e-07 4.10855e-15)
(0.152133 1.15972e-07 4.11254e-15)
(0.152133 1.24916e-07 4.12609e-15)
(0.152133 1.3031e-07 3.99565e-15)
(0.152133 1.32871e-07 4.20762e-15)
(0.152133 1.33195e-07 4.1998e-15)
(0.152133 1.31737e-07 4.18609e-15)
(0.152133 1.28851e-07 4.17708e-15)
(0.152133 1.24832e-07 4.04702e-15)
(0.152133 1.1992e-07 4.26001e-15)
(0.152133 1.14324e-07 4.24836e-15)
(0.152133 1.08223e-07 4.23684e-15)
(0.152133 1.01775e-07 4.22918e-15)
(0.152133 9.51222e-08 4.08058e-15)
(0.152133 8.83891e-08 4.27669e-15)
(0.152133 8.16887e-08 4.25938e-15)
(0.152133 7.51217e-08 4.22725e-15)
(0.152133 6.87772e-08 4.20688e-15)
(0.152133 6.27338e-08 4.06539e-15)
(0.152133 5.70596e-08 4.26592e-15)
(0.152133 5.18123e-08 4.25402e-15)
(0.152133 4.704e-08 4.23426e-15)
(0.152133 4.27805e-08 4.21217e-15)
(0.152133 3.90619e-08 4.06851e-15)
(0.152133 3.59022e-08 4.27874e-15)
(0.152133 3.33092e-08 4.28549e-15)
(0.152133 3.12798e-08 4.25846e-15)
(0.152133 2.98001e-08 4.22471e-15)
(0.152133 2.88449e-08 4.07711e-15)
(0.152133 2.83771e-08 4.21205e-15)
(0.152133 2.83482e-08 4.24185e-15)
(0.152133 2.86974e-08 4.26208e-15)
(0.152133 2.93527e-08 4.43074e-15)
(0.152133 3.02302e-08 4.35436e-15)
(0.152133 3.12341e-08 4.44548e-15)
(0.152133 3.22548e-08 4.53027e-15)
(0.152133 3.31661e-08 4.44341e-15)
(0.152134 3.38213e-08 4.61415e-15)
(0.152134 3.40444e-08 4.53971e-15)
(0.152134 3.36246e-08 4.5839e-15)
(0.152134 3.23067e-08 4.54117e-15)
(0.152134 2.97836e-08 4.51409e-15)
(0.152134 2.56868e-08 4.5996e-15)
(0.152134 1.95752e-08 4.62845e-15)
(0.152134 1.09176e-08 4.68216e-15)
(0.152134 -9.35987e-10 4.60346e-15)
(0.152134 -1.67621e-08 4.56412e-15)
(0.152134 -3.75813e-08 4.62189e-15)
(0.152134 -6.4503e-08 4.73383e-15)
(0.152134 -9.93045e-08 4.68002e-15)
(0.152134 -1.43097e-07 4.76312e-15)
(0.152134 -2.01083e-07 4.65663e-15)
(0.152134 -2.54035e-07 4.82197e-15)
(0.152255 -1.21772e-07 4.0579e-15)
(0.152255 -7.49921e-08 4.04766e-15)
(0.152255 -3.80225e-09 4.0422e-15)
(0.152255 4.36814e-08 4.11453e-15)
(0.152254 7.57671e-08 4.11971e-15)
(0.152254 1.00372e-07 4.10391e-15)
(0.152254 1.17669e-07 4.10276e-15)
(0.152254 1.29107e-07 4.1087e-15)
(0.152254 1.36347e-07 4.12308e-15)
(0.152254 1.40281e-07 4.06882e-15)
(0.152254 1.41564e-07 4.11851e-15)
(0.152254 1.40744e-07 4.15411e-15)
(0.152254 1.38237e-07 4.17082e-15)
(0.152254 1.3437e-07 4.18364e-15)
(0.152254 1.29411e-07 4.13143e-15)
(0.152254 1.23587e-07 4.17751e-15)
(0.152254 1.17089e-07 4.20622e-15)
(0.152254 1.10087e-07 4.21863e-15)
(0.152254 1.02732e-07 4.22304e-15)
(0.152254 9.51579e-08 4.15563e-15)
(0.152254 8.74879e-08 4.18801e-15)
(0.152254 7.98321e-08 4.20636e-15)
(0.152254 7.22901e-08 4.20892e-15)
(0.152254 6.49518e-08 4.20971e-15)
(0.152254 5.78971e-08 4.14456e-15)
(0.152254 5.11965e-08 4.18096e-15)
(0.152254 4.4911e-08 4.20658e-15)
(0.152254 3.90923e-08 4.21878e-15)
(0.152254 3.37828e-08 4.22196e-15)
(0.152254 2.90152e-08 4.15844e-15)
(0.152254 2.48127e-08 4.20385e-15)
(0.152254 2.11886e-08 4.23329e-15)
(0.152254 1.8146e-08 4.23411e-15)
(0.152254 1.56774e-08 4.225e-15)
(0.152254 1.37644e-08 4.15228e-15)
(0.152255 1.23772e-08 4.20342e-15)
(0.152255 1.1475e-08 4.19191e-15)
(0.152255 1.10052e-08 4.18813e-15)
(0.152255 1.09043e-08 4.25338e-15)
(0.152255 1.10969e-08 4.29992e-15)
(0.152255 1.1496e-08 4.35292e-15)
(0.152255 1.20013e-08 4.38798e-15)
(0.152255 1.24965e-08 4.38815e-15)
(0.152255 1.28463e-08 4.45757e-15)
(0.152255 1.28893e-08 4.45682e-15)
(0.152255 1.2433e-08 4.4866e-15)
(0.152255 1.12468e-08 4.47876e-15)
(0.152255 9.05572e-09 4.48402e-15)
(0.152255 5.53254e-09 4.55416e-15)
(0.152255 2.8773e-10 4.57629e-15)
(0.152255 -7.14144e-09 4.59073e-15)
(0.152255 -1.73257e-08 4.58116e-15)
(0.152255 -3.09302e-08 4.54099e-15)
(0.152255 -4.88752e-08 4.5937e-15)
(0.152255 -7.20914e-08 4.60886e-15)
(0.152255 -1.02333e-07 4.64295e-15)
(0.152255 -1.40411e-07 4.64429e-15)
(0.152255 -1.91834e-07 4.65443e-15)
(0.152255 -2.38313e-07 4.704e-15)
(0.152368 -8.36095e-08 4.05263e-15)
(0.152368 -4.18018e-08 4.05067e-15)
(0.152368 2.46115e-08 4.05031e-15)
(0.152368 6.82817e-08 4.15581e-15)
(0.152368 9.66213e-08 4.12216e-15)
(0.152368 1.17982e-07 4.10877e-15)
(0.152368 1.32623e-07 4.11164e-15)
(0.152368 1.41828e-07 4.12007e-15)
(0.152368 1.47194e-07 4.13254e-15)
(0.152368 1.49548e-07 4.09753e-15)
(0.152368 1.49473e-07 4.08996e-15)
(0.152368 1.47461e-07 4.134e-15)
(0.152368 1.43885e-07 4.17e-15)
(0.152368 1.39036e-07 4.19221e-15)
(0.152368 1.33157e-07 4.16175e-15)
(0.152368 1.26451e-07 4.15996e-15)
(0.152368 1.19094e-07 4.18264e-15)
(0.152368 1.11242e-07 4.2101e-15)
(0.152368 1.03035e-07 4.22343e-15)
(0.152368 9.46004e-08 4.17737e-15)
(0.152368 8.60558e-08 4.1528e-15)
(0.152368 7.75075e-08 4.17981e-15)
(0.152368 6.90536e-08 4.20128e-15)
(0.152368 6.0783e-08 4.2107e-15)
(0.152368 5.27767e-08 4.1664e-15)
(0.152368 4.51067e-08 4.15198e-15)
(0.152368 3.78368e-08 4.18337e-15)
(0.152368 3.10221e-08 4.21272e-15)
(0.152368 2.47088e-08 4.22922e-15)
(0.152368 1.89343e-08 4.18905e-15)
(0.152368 1.37269e-08 4.19463e-15)
(0.152368 9.10522e-09 4.21299e-15)
(0.152368 5.07844e-09 4.22315e-15)
(0.152368 1.64545e-09 4.22305e-15)
(0.152368 -1.20519e-09 4.16898e-15)
(0.152368 -3.4958e-09 4.14856e-15)
(0.152368 -5.25937e-09 4.11162e-15)
(0.152368 -6.54012e-09 4.1537e-15)
(0.152368 -7.39294e-09 4.227e-15)
(0.152368 -7.88408e-09 4.27681e-15)
(0.152368 -8.09113e-09 4.26353e-15)
(0.152368 -8.10432e-09 4.25397e-15)
(0.152368 -8.0288e-09 4.35807e-15)
(0.152368 -7.98716e-09 4.40156e-15)
(0.152369 -8.12477e-09 4.42643e-15)
(0.152369 -8.61361e-09 4.46243e-15)
(0.152369 -9.65772e-09 4.44032e-15)
(0.152369 -1.1498e-08 4.4612e-15)
(0.152369 -1.4417e-08 4.51182e-15)
(0.152369 -1.87485e-08 4.44568e-15)
(0.152369 -2.48821e-08 4.47555e-15)
(0.152369 -3.3301e-08 4.44106e-15)
(0.152369 -4.45521e-08 4.53545e-15)
(0.152369 -5.94381e-08 4.5627e-15)
(0.152369 -7.87073e-08 4.50738e-15)
(0.152369 -1.04057e-07 4.59345e-15)
(0.152369 -1.36031e-07 4.64636e-15)
(0.152369 -1.80423e-07 4.64168e-15)
(0.152369 -2.19961e-07 4.67461e-15)
(0.152474 -4.26522e-08 4.05315e-15)
(0.152474 -6.03802e-09 4.06747e-15)
(0.152474 5.47735e-08 4.07672e-15)
(0.152474 9.39031e-08 4.00971e-15)
(0.152474 1.17932e-07 4.07994e-15)
(0.152474 1.35577e-07 4.11886e-15)
(0.152474 1.47199e-07 4.13666e-15)
(0.152474 1.5391e-07 4.14849e-15)
(0.152474 1.5721e-07 4.15879e-15)
(0.152474 1.57853e-07 4.09726e-15)
(0.152474 1.56336e-07 4.05239e-15)
(0.152474 1.53086e-07 4.15021e-15)
(0.152474 1.48427e-07 4.19832e-15)
(0.152474 1.42608e-07 4.21414e-15)
(0.152474 1.35838e-07 4.15406e-15)
(0.152474 1.28296e-07 4.20437e-15)
(0.152474 1.20136e-07 4.20651e-15)
(0.152474 1.11498e-07 4.23078e-15)
(0.152474 1.02509e-07 4.23903e-15)
(0.152474 9.32889e-08 4.16293e-15)
(0.152474 8.39458e-08 4.19608e-15)
(0.152474 7.4582e-08 4.1846e-15)
(0.152474 6.52924e-08 4.2206e-15)
(0.152474 5.61647e-08 4.22405e-15)
(0.152474 4.72797e-08 4.15024e-15)
(0.152474 3.87107e-08 4.09726e-15)
(0.152474 3.05234e-08 4.19301e-15)
(0.152474 2.2776e-08 4.23196e-15)
(0.152474 1.55184e-08 4.24669e-15)
(0.152474 8.79228e-09 4.17879e-15)
(0.152474 2.63068e-09 4.13611e-15)
(0.152474 -2.9422e-09 4.23904e-15)
(0.152474 -7.91141e-09 4.23909e-15)
(0.152474 -1.22716e-08 4.23382e-15)
(0.152474 -1.60272e-08 4.15314e-15)
(0.152474 -1.9193e-08 4.12622e-15)
(0.152474 -2.17942e-08 4.18842e-15)
(0.152474 -2.38664e-08 4.24253e-15)
(0.152474 -2.54555e-08 4.27192e-15)
(0.152474 -2.66184e-08 4.32832e-15)
(0.152474 -2.74226e-08 4.24859e-15)
(0.152474 -2.79476e-08 4.34104e-15)
(0.152474 -2.82864e-08 4.39255e-15)
(0.152474 -2.85477e-08 4.40949e-15)
(0.152474 -2.88592e-08 4.43945e-15)
(0.152474 -2.9371e-08 4.33757e-15)
(0.152474 -3.02587e-08 4.42012e-15)
(0.152474 -3.17267e-08 4.49231e-15)
(0.152474 -3.40105e-08 4.517e-15)
(0.152475 -3.73843e-08 4.55423e-15)
(0.152475 -4.21597e-08 4.4475e-15)
(0.152475 -4.87245e-08 4.51594e-15)
(0.152475 -5.74988e-08 4.57402e-15)
(0.152475 -6.91497e-08 4.58693e-15)
(0.152475 -8.42336e-08 4.65144e-15)
(0.152475 -1.04351e-07 4.46493e-15)
(0.152475 -1.29797e-07 4.64242e-15)
(0.152475 -1.6662e-07 4.69338e-15)
(0.152475 -1.98635e-07 4.69129e-15)
(0.152572 1.47854e-09 4.09268e-15)
(0.152572 3.26129e-08 4.10541e-15)
(0.152572 8.68028e-08 4.11774e-15)
(0.152572 1.20507e-07 4.11374e-15)
(0.152571 1.39559e-07 4.13871e-15)
(0.152571 1.52936e-07 4.16509e-15)
(0.152571 1.61126e-07 4.18163e-15)
(0.152571 1.65047e-07 4.19525e-15)
(0.152571 1.66077e-07 4.19809e-15)
(0.152571 1.64873e-07 4.34503e-15)
(0.152571 1.61838e-07 4.28923e-15)
(0.152571 1.5732e-07 4.2586e-15)
(0.152571 1.51582e-07 4.25122e-15)
(0.152571 1.44823e-07 4.23921e-15)
(0.152571 1.37213e-07 4.38607e-15)
(0.152571 1.28899e-07 4.34074e-15)
(0.152571 1.20011e-07 4.30069e-15)
(0.152571 1.10669e-07 4.28695e-15)
(0.152571 1.00987e-07 4.25991e-15)
(0.152571 9.10691e-08 4.38561e-15)
(0.152571 8.1018e-08 4.31341e-15)
(0.152571 7.09291e-08 4.27829e-15)
(0.152571 6.08933e-08 4.26619e-15)
(0.152571 5.09962e-08 4.24096e-15)
(0.152571 4.13178e-08 4.3719e-15)
(0.152571 3.19321e-08 4.3123e-15)
(0.152571 2.29065e-08 4.27785e-15)
(0.152571 1.43017e-08 4.27234e-15)
(0.152571 6.17121e-09 4.26935e-15)
(0.152571 -1.43939e-09 4.40919e-15)
(0.152572 -8.49231e-09 4.36317e-15)
(0.152572 -1.49581e-08 4.31299e-15)
(0.152572 -2.08159e-08 4.28021e-15)
(0.152572 -2.6054e-08 4.2526e-15)
(0.152572 -3.067e-08 4.37633e-15)
(0.152572 -3.4671e-08 4.3089e-15)
(0.152572 -3.80743e-08 4.44223e-15)
(0.152572 -4.09067e-08 4.39783e-15)
(0.152572 -4.32052e-08 4.35495e-15)
(0.152572 -4.50169e-08 4.49621e-15)
(0.152572 -4.63987e-08 4.41274e-15)
(0.152572 -4.74189e-08 4.54187e-15)
(0.152572 -4.81575e-08 4.49466e-15)
(0.152572 -4.87078e-08 4.4462e-15)
(0.152572 -4.91793e-08 4.57706e-15)
(0.152572 -4.96984e-08 4.47657e-15)
(0.152572 -5.0411e-08 4.60827e-15)
(0.152572 -5.14831e-08 4.58118e-15)
(0.152572 -5.31009e-08 4.54398e-15)
(0.152572 -5.54754e-08 4.68481e-15)
(0.152572 -5.88359e-08 4.57755e-15)
(0.152572 -6.34671e-08 4.70624e-15)
(0.152572 -6.96533e-08 4.66457e-15)
(0.152572 -7.79057e-08 4.62968e-15)
(0.152572 -8.85723e-08 4.78226e-15)
(0.152572 -1.0311e-07 4.70236e-15)
(0.152572 -1.21558e-07 4.82778e-15)
(0.152572 -1.50188e-07 4.77787e-15)
(0.152572 -1.73934e-07 4.72535e-15)
(0.152661 4.92905e-08 4.16608e-15)
(0.152661 7.45402e-08 4.16841e-15)
(0.152661 1.20802e-07 4.1812e-15)
(0.152661 1.47977e-07 4.22385e-15)
(0.152661 1.61249e-07 4.23782e-15)
(0.152661 1.69716e-07 4.24416e-15)
(0.152661 1.74003e-07 4.24772e-15)
(0.152661 1.74823e-07 4.26169e-15)
(0.152661 1.7338e-07 4.25162e-15)
(0.152661 1.70217e-07 4.44581e-15)
(0.152661 1.65618e-07 4.42221e-15)
(0.152661 1.59836e-07 4.33314e-15)
(0.152661 1.53057e-07 4.30036e-15)
(0.152661 1.45421e-07 4.25708e-15)
(0.152661 1.37051e-07 4.45764e-15)
(0.152661 1.28056e-07 4.44426e-15)
(0.152661 1.18537e-07 4.38959e-15)
(0.152661 1.08594e-07 4.34621e-15)
(0.152661 9.83201e-08 4.27391e-15)
(0.152661 8.781e-08 4.4456e-15)
(0.152661 7.71547e-08 4.41089e-15)
(0.152661 6.64432e-08 4.33965e-15)
(0.152661 5.57619e-08 4.31494e-15)
(0.152661 4.51937e-08 4.24187e-15)
(0.152661 3.48174e-08 4.42749e-15)
(0.152661 2.47074e-08 4.40173e-15)
(0.152661 1.49324e-08 4.32773e-15)
(0.152661 5.55569e-09 4.31021e-15)
(0.152661 -3.36634e-09 4.29926e-15)
(0.152661 -1.17841e-08 4.48131e-15)
(0.152661 -1.96551e-08 4.44566e-15)
(0.152661 -2.6945e-08 4.37932e-15)
(0.152661 -3.36269e-08 4.32248e-15)
(0.152661 -3.96829e-08 4.27225e-15)
(0.152661 -4.51036e-08 4.44633e-15)
(0.152661 -4.98888e-08 4.47361e-15)
(0.152661 -5.40474e-08 4.58176e-15)
(0.152661 -5.7598e-08 4.49936e-15)
(0.152661 -6.05681e-08 4.43566e-15)
(0.152661 -6.29948e-08 4.54181e-15)
(0.152661 -6.49245e-08 4.51138e-15)
(0.152662 -6.64132e-08 4.61465e-15)
(0.152662 -6.75274e-08 4.53644e-15)
(0.152662 -6.83447e-08 4.47747e-15)
(0.152662 -6.89547e-08 4.57013e-15)
(0.152662 -6.94597e-08 4.54255e-15)
(0.152662 -6.99742e-08 4.6617e-15)
(0.152662 -7.06248e-08 4.60985e-15)
(0.152662 -7.15463e-08 4.56754e-15)
(0.152662 -7.2884e-08 4.67378e-15)
(0.152662 -7.47811e-08 4.65081e-15)
(0.152662 -7.74114e-08 4.7498e-15)
(0.152662 -8.09143e-08 4.69037e-15)
(0.152662 -8.56231e-08 4.65786e-15)
(0.152662 -9.16532e-08 4.78553e-15)
(0.152662 -1.0026e-07 4.76207e-15)
(0.152662 -1.1119e-07 4.86179e-15)
(0.152662 -1.30885e-07 4.78924e-15)
(0.152662 -1.45387e-07 4.74208e-15)
(0.152742 1.01463e-07 4.24351e-15)
(0.152742 1.20204e-07 4.25267e-15)
(0.152742 1.56794e-07 4.2675e-15)
(0.152742 1.76035e-07 4.38934e-15)
(0.152742 1.82554e-07 4.35713e-15)
(0.152742 1.85369e-07 4.33654e-15)
(0.152742 1.85253e-07 4.25144e-15)
(0.152742 1.82677e-07 4.35389e-15)
(0.152742 1.78612e-07 4.36081e-15)
(0.152742 1.73437e-07 4.44186e-15)
(0.152742 1.67293e-07 4.483e-15)
(0.152742 1.6031e-07 4.3301e-15)
(0.152742 1.52581e-07 4.33408e-15)
(0.152742 1.44176e-07 4.3272e-15)
(0.152742 1.35162e-07 4.42983e-15)
(0.152742 1.25606e-07 4.47235e-15)
(0.152742 1.15579e-07 4.36505e-15)
(0.152742 1.05155e-07 4.38549e-15)
(0.152742 9.44098e-08 4.24546e-15)
(0.152742 8.3424e-08 4.39981e-15)
(0.152742 7.22789e-08 4.42974e-15)
(0.152742 6.10565e-08 4.2929e-15)
(0.152742 4.98382e-08 4.35031e-15)
(0.152742 3.87043e-08 4.32508e-15)
(0.152742 2.77325e-08 4.35669e-15)
(0.152742 1.69972e-08 4.39514e-15)
(0.152742 6.5686e-09 4.37758e-15)
(0.152742 -3.48792e-09 4.3349e-15)
(0.152742 -1.31129e-08 4.26436e-15)
(0.152742 -2.22528e-08 4.44547e-15)
(0.152742 -3.0861e-08 4.45501e-15)
(0.152742 -3.88977e-08 4.41768e-15)
(0.152742 -4.63306e-08 4.35529e-15)
(0.152742 -5.31353e-08 4.2272e-15)
(0.152742 -5.92957e-08 4.41865e-15)
(0.152743 -6.48043e-08 4.58733e-15)
(0.152743 -6.96619e-08 4.54692e-15)
(0.152743 -7.38784e-08 4.51332e-15)
(0.152743 -7.74722e-08 4.56067e-15)
(0.152743 -8.04703e-08 4.43441e-15)
(0.152743 -8.29079e-08 4.64781e-15)
(0.152743 -8.48291e-08 4.48793e-15)
(0.152743 -8.62861e-08 4.48401e-15)
(0.152743 -8.73399e-08 4.52979e-15)
(0.152743 -8.806e-08 4.39212e-15)
(0.152743 -8.85236e-08 4.5545e-15)
(0.152743 -8.88134e-08 4.51818e-15)
(0.152743 -8.90154e-08 4.55167e-15)
(0.152743 -8.92121e-08 4.53933e-15)
(0.152743 -8.94809e-08 4.50887e-15)
(0.152743 -8.98762e-08 4.74598e-15)
(0.152743 -9.04548e-08 4.62275e-15)
(0.152743 -9.12008e-08 4.63195e-15)
(0.152743 -9.22471e-08 4.7327e-15)
(0.152743 -9.34444e-08 4.626e-15)
(0.152743 -9.5775e-08 4.77756e-15)
(0.152743 -9.8613e-08 4.69315e-15)
(0.152743 -1.08484e-07 4.7062e-15)
(0.152743 -1.12433e-07 4.79857e-15)
(0.152815 1.58894e-07 4.28e-15)
(0.152815 1.70095e-07 4.37329e-15)
(0.152815 1.94592e-07 4.42829e-15)
(0.152815 2.04082e-07 4.36014e-15)
(0.152815 2.02688e-07 4.34491e-15)
(0.152815 1.99052e-07 4.4546e-15)
(0.152815 1.94075e-07 4.4701e-15)
(0.152815 1.87912e-07 4.5011e-15)
(0.152815 1.81193e-07 4.50022e-15)
(0.152815 1.74076e-07 4.68878e-15)
(0.152815 1.66511e-07 4.55421e-15)
(0.152815 1.58477e-07 4.48136e-15)
(0.152815 1.4996e-07 4.36555e-15)
(0.152815 1.40946e-07 4.42328e-15)
(0.152815 1.31445e-07 4.63363e-15)
(0.152815 1.21478e-07 4.57023e-15)
(0.152815 1.11085e-07 4.49537e-15)
(0.152815 1.00315e-07 4.49039e-15)
(0.152815 8.92285e-08 4.40885e-15)
(0.152815 7.78912e-08 4.63387e-15)
(0.152815 6.63754e-08 4.50483e-15)
(0.152815 5.47567e-08 4.41514e-15)
(0.152815 4.31123e-08 4.43106e-15)
(0.152815 3.15201e-08 4.40237e-15)
(0.152815 2.00568e-08 4.62002e-15)
(0.152815 8.79734e-09 4.37966e-15)
(0.152815 -2.18678e-09 4.3792e-15)
(0.152815 -1.28281e-08 4.43907e-15)
(0.152815 -2.30639e-08 4.45877e-15)
(0.152815 -3.28372e-08 4.53915e-15)
(0.152815 -4.20968e-08 4.48874e-15)
(0.152815 -5.07977e-08 4.44476e-15)
(0.152815 -5.89023e-08 4.42244e-15)
(0.152815 -6.63799e-08 4.38918e-15)
(0.152815 -7.32078e-08 4.61967e-15)
(0.152815 -7.93712e-08 4.50516e-15)
(0.152815 -8.48632e-08 4.60107e-15)
(0.152815 -8.9685e-08 4.563e-15)
(0.152815 -9.38459e-08 4.41209e-15)
(0.152815 -9.73627e-08 4.50467e-15)
(0.152815 -1.0026e-07 4.43619e-15)
(0.152815 -1.02568e-07 4.49163e-15)
(0.152815 -1.04327e-07 4.47195e-15)
(0.152815 -1.05579e-07 4.34746e-15)
(0.152815 -1.06375e-07 4.41172e-15)
(0.152815 -1.06765e-07 4.27481e-15)
(0.152815 -1.068e-07 4.6342e-15)
(0.152815 -1.06526e-07 4.52936e-15)
(0.152815 -1.05972e-07 4.53418e-15)
(0.152815 -1.05147e-07 4.64712e-15)
(0.152816 -1.04016e-07 4.48371e-15)
(0.152816 -1.02512e-07 4.6986e-15)
(0.152816 -1.00457e-07 4.63174e-15)
(0.152816 -9.7759e-08 4.62819e-15)
(0.152816 -9.39653e-08 4.75473e-15)
(0.152816 -8.96955e-08 4.6055e-15)
(0.152816 -8.38227e-08 4.67813e-15)
(0.152816 -8.27962e-08 4.65868e-15)
(0.152815 -7.4393e-08 4.49295e-15)
(0.152878 2.22742e-07 4.59241e-15)
(0.152878 2.24601e-07 4.62651e-15)
(0.152878 2.33531e-07 4.63406e-15)
(0.152878 2.30943e-07 4.62928e-15)
(0.152878 2.20362e-07 4.63132e-15)
(0.152878 2.09561e-07 4.62526e-15)
(0.152878 1.99466e-07 4.67444e-15)
(0.152878 1.89764e-07 4.68636e-15)
(0.152878 1.80587e-07 4.71907e-15)
(0.152878 1.71779e-07 4.4631e-15)
(0.152878 1.63058e-07 4.54423e-15)
(0.152878 1.54228e-07 4.59929e-15)
(0.152878 1.45154e-07 4.60592e-15)
(0.152878 1.35741e-07 4.63144e-15)
(0.152878 1.25939e-07 4.42829e-15)
(0.152878 1.1573e-07 4.50068e-15)
(0.152878 1.05124e-07 4.61665e-15)
(0.152878 9.41486e-08 4.60728e-15)
(0.152878 8.28491e-08 4.63587e-15)
(0.152878 7.12813e-08 4.44019e-15)
(0.152878 5.95096e-08 4.49343e-15)
(0.152878 4.76042e-08 4.52683e-15)
(0.152878 3.56392e-08 4.55798e-15)
(0.152878 2.36909e-08 4.59907e-15)
(0.152878 1.18356e-08 4.49441e-15)
(0.152878 1.49005e-10 4.47457e-15)
(0.152878 -1.12958e-08 4.54177e-15)
(0.152878 -2.24291e-08 4.57631e-15)
(0.152878 -3.31852e-08 4.62605e-15)
(0.152878 -4.35031e-08 4.45837e-15)
(0.152878 -5.33272e-08 4.44161e-15)
(0.152878 -6.26079e-08 4.52179e-15)
(0.152878 -7.1302e-08 4.53048e-15)
(0.152878 -7.9373e-08 4.56712e-15)
(0.152878 -8.67916e-08 4.4636e-15)
(0.152878 -9.3536e-08 4.51526e-15)
(0.152878 -9.95916e-08 4.43294e-15)
(0.152878 -1.04951e-07 4.4931e-15)
(0.152878 -1.09616e-07 4.53297e-15)
(0.152878 -1.13591e-07 4.41923e-15)
(0.152878 -1.16892e-07 4.40005e-15)
(0.152878 -1.19536e-07 4.14576e-15)
(0.152878 -1.21547e-07 4.371e-15)
(0.152878 -1.22954e-07 4.43237e-15)
(0.152879 -1.23784e-07 4.22272e-15)
(0.152879 -1.24064e-07 4.3597e-15)
(0.152879 -1.23813e-07 4.23266e-15)
(0.152879 -1.23035e-07 4.42579e-15)
(0.152879 -1.2171e-07 4.51961e-15)
(0.152879 -1.19777e-07 4.43994e-15)
(0.152879 -1.1711e-07 4.46587e-15)
(0.152879 -1.13519e-07 4.42609e-15)
(0.152879 -1.08656e-07 4.49895e-15)
(0.152879 -1.02184e-07 4.61682e-15)
(0.152879 -9.33019e-08 4.4466e-15)
(0.152879 -8.21595e-08 4.56128e-15)
(0.152879 -6.69344e-08 4.50102e-15)
(0.152879 -5.37213e-08 4.53562e-15)
(0.152879 -3.04491e-08 4.67518e-15)
(0.152932 2.94365e-07 4.86489e-15)
(0.152931 2.83686e-07 4.95021e-15)
(0.152931 2.7201e-07 4.88859e-15)
(0.152931 2.54529e-07 4.8781e-15)
(0.152931 2.33658e-07 4.86056e-15)
(0.152931 2.15395e-07 4.83567e-15)
(0.152931 2.004e-07 4.9467e-15)
(0.152931 1.8763e-07 4.89469e-15)
(0.152931 1.76507e-07 4.98169e-15)
(0.152931 1.66481e-07 4.56508e-15)
(0.152931 1.57013e-07 4.63687e-15)
(0.152931 1.47726e-07 4.80056e-15)
(0.152931 1.38375e-07 4.78307e-15)
(0.152931 1.28795e-07 4.88917e-15)
(0.152931 1.18885e-07 4.68953e-15)
(0.152931 1.08598e-07 4.63683e-15)
(0.152931 9.79198e-08 4.81433e-15)
(0.152931 8.68645e-08 4.79218e-15)
(0.152931 7.54657e-08 4.89607e-15)
(0.152931 6.37718e-08 4.71356e-15)
(0.152931 5.18419e-08 4.63718e-15)
(0.152931 3.97433e-08 4.74892e-15)
(0.152931 2.75481e-08 4.72905e-15)
(0.152931 1.53319e-08 4.84097e-15)
(0.152932 3.17172e-09 4.67797e-15)
(0.152932 -8.85595e-09 4.6273e-15)
(0.152932 -2.06761e-08 4.76245e-15)
(0.152932 -3.22165e-08 4.74609e-15)
(0.152932 -4.34083e-08 4.86135e-15)
(0.152932 -5.41869e-08 4.54521e-15)
(0.152932 -6.44923e-08 4.52601e-15)
(0.152932 -7.42703e-08 4.72309e-15)
(0.152932 -8.34724e-08 4.70276e-15)
(0.152932 -9.20566e-08 4.8096e-15)
(0.152932 -9.99874e-08 4.62655e-15)
(0.152932 -1.07236e-07 4.60388e-15)
(0.152932 -1.13781e-07 4.51151e-15)
(0.152932 -1.19607e-07 4.55003e-15)
(0.152932 -1.24706e-07 4.65066e-15)
(0.152932 -1.29075e-07 4.41033e-15)
(0.152932 -1.32716e-07 4.54489e-15)
(0.152932 -1.35638e-07 4.33868e-15)
(0.152932 -1.37848e-07 4.49444e-15)
(0.152932 -1.39359e-07 4.59134e-15)
(0.152932 -1.40179e-07 4.4518e-15)
(0.152932 -1.4031e-07 4.50143e-15)
(0.152932 -1.39739e-07 4.42265e-15)
(0.152932 -1.38434e-07 4.49403e-15)
(0.152932 -1.36321e-07 4.63952e-15)
(0.152932 -1.33276e-07 4.43966e-15)
(0.152932 -1.29085e-07 4.59975e-15)
(0.152932 -1.23436e-07 4.5059e-15)
(0.152932 -1.15805e-07 4.5987e-15)
(0.152932 -1.05598e-07 4.72892e-15)
(0.152932 -9.16235e-08 4.52135e-15)
(0.152932 -7.34366e-08 4.69484e-15)
(0.152932 -4.8255e-08 4.49009e-15)
(0.152932 -2.13301e-08 4.68347e-15)
(0.152932 2.03509e-08 4.80144e-15)
(0.152975 3.74894e-07 5.09818e-15)
(0.152975 3.46027e-07 5.07713e-15)
(0.152975 3.06851e-07 5.04077e-15)
(0.152974 2.71656e-07 5.13824e-15)
(0.152974 2.4022e-07 5.08428e-15)
(0.152974 2.15169e-07 5.03599e-15)
(0.152974 1.96304e-07 5.03738e-15)
(0.152974 1.81481e-07 5.02106e-15)
(0.152974 1.6925e-07 5.02868e-15)
(0.152975 1.5865e-07 5.03927e-15)
(0.152975 1.48914e-07 4.84371e-15)
(0.152975 1.39528e-07 4.88472e-15)
(0.152975 1.30167e-07 4.91205e-15)
(0.152975 1.2062e-07 4.95209e-15)
(0.152975 1.10759e-07 5.00626e-15)
(0.152975 1.00518e-07 4.8368e-15)
(0.152975 8.987e-08 4.89117e-15)
(0.152975 7.88215e-08 4.92038e-15)
(0.152975 6.74e-08 4.95564e-15)
(0.152975 5.56503e-08 5.02337e-15)
(0.152975 4.36291e-08 4.82454e-15)
(0.152975 3.14021e-08 4.84891e-15)
(0.152975 1.90413e-08 4.87125e-15)
(0.152975 6.6225e-09 4.90461e-15)
(0.152975 -5.77632e-09 4.97798e-15)
(0.152975 -1.80772e-08 4.80089e-15)
(0.152975 -3.02031e-08 4.84249e-15)
(0.152975 -4.20793e-08 4.871e-15)
(0.152975 -5.36338e-08 4.91101e-15)
(0.152975 -6.47984e-08 4.93289e-15)
(0.152975 -7.55092e-08 4.76092e-15)
(0.152975 -8.57077e-08 4.81235e-15)
(0.152975 -9.53404e-08 4.83637e-15)
(0.152975 -1.0436e-07 4.86846e-15)
(0.152975 -1.12726e-07 4.90992e-15)
(0.152975 -1.20402e-07 4.87019e-15)
(0.152975 -1.27361e-07 4.80859e-15)
(0.152975 -1.33579e-07 4.81917e-15)
(0.152975 -1.3904e-07 4.87255e-15)
(0.152975 -1.43733e-07 4.8554e-15)
(0.152975 -1.4765e-07 4.87613e-15)
(0.152975 -1.50785e-07 4.84486e-15)
(0.152975 -1.53137e-07 4.83638e-15)
(0.152975 -1.54698e-07 4.87298e-15)
(0.152975 -1.5546e-07 4.84076e-15)
(0.152975 -1.554e-07 4.85052e-15)
(0.152975 -1.54478e-07 4.8102e-15)
(0.152975 -1.52622e-07 4.8322e-15)
(0.152975 -1.49715e-07 4.89664e-15)
(0.152975 -1.45569e-07 4.90212e-15)
(0.152975 -1.39888e-07 4.92867e-15)
(0.152975 -1.32244e-07 4.90913e-15)
(0.152975 -1.21946e-07 4.9249e-15)
(0.152976 -1.08133e-07 4.9895e-15)
(0.152976 -8.91984e-08 4.98507e-15)
(0.152975 -6.39717e-08 5.0138e-15)
(0.152975 -2.83867e-08 5.00038e-15)
(0.152975 1.39931e-08 5.01309e-15)
(0.152975 7.90082e-08 5.068e-15)
(0.153007 4.64312e-07 5.27269e-15)
(0.153007 4.06936e-07 5.20823e-15)
(0.153007 3.32217e-07 5.16841e-15)
(0.153007 2.78559e-07 5.20619e-15)
(0.153007 2.38371e-07 5.21532e-15)
(0.153007 2.08693e-07 5.19695e-15)
(0.153007 1.87885e-07 5.15101e-15)
(0.153007 1.72444e-07 5.13507e-15)
(0.153007 1.60062e-07 5.10442e-15)
(0.153007 1.49501e-07 5.10534e-15)
(0.153007 1.3989e-07 5.13419e-15)
(0.153007 1.30655e-07 5.09723e-15)
(0.153007 1.21442e-07 5.07814e-15)
(0.153007 1.12031e-07 5.06789e-15)
(0.153007 1.02286e-07 5.0967e-15)
(0.153007 9.21336e-08 5.1143e-15)
(0.153007 8.15468e-08 5.10391e-15)
(0.153007 7.05285e-08 5.0954e-15)
(0.153007 5.9105e-08 5.07379e-15)
(0.153007 4.732e-08 5.0953e-15)
(0.153007 3.52298e-08 5.11695e-15)
(0.153007 2.29001e-08 5.08463e-15)
(0.153007 1.04033e-08 5.06752e-15)
(0.153007 -2.18385e-09 5.03355e-15)
(0.153007 -1.47824e-08 5.04922e-15)
(0.153007 -2.73128e-08 5.09127e-15)
(0.153007 -3.96962e-08 5.05676e-15)
(0.153007 -5.18552e-08 5.04344e-15)
(0.153007 -6.37153e-08 5.03148e-15)
(0.153007 -7.52049e-08 5.04557e-15)
(0.153007 -8.62569e-08 5.06639e-15)
(0.153007 -9.68085e-08 5.03701e-15)
(0.153007 -1.06802e-07 5.0217e-15)
(0.153007 -1.16186e-07 4.99789e-15)
(0.153007 -1.24913e-07 5.01375e-15)
(0.153007 -1.32943e-07 5.06989e-15)
(0.153007 -1.40242e-07 5.11102e-15)
(0.153007 -1.4678e-07 5.11487e-15)
(0.153007 -1.52532e-07 5.17399e-15)
(0.153007 -1.57479e-07 5.22317e-15)
(0.153007 -1.61603e-07 5.29699e-15)
(0.153007 -1.64889e-07 5.29162e-15)
(0.153007 -1.67321e-07 5.23506e-15)
(0.153007 -1.68878e-07 5.22493e-15)
(0.153008 -1.69534e-07 5.25169e-15)
(0.153008 -1.69243e-07 5.26507e-15)
(0.153008 -1.67939e-07 5.27134e-15)
(0.153008 -1.65519e-07 5.22422e-15)
(0.153008 -1.6182e-07 5.2461e-15)
(0.153008 -1.56601e-07 5.30369e-15)
(0.153008 -1.49492e-07 5.34558e-15)
(0.153008 -1.3996e-07 5.34686e-15)
(0.153008 -1.27164e-07 5.31045e-15)
(0.153008 -1.09991e-07 5.3594e-15)
(0.153008 -8.64168e-08 5.37859e-15)
(0.153008 -5.44487e-08 5.39887e-15)
(0.153008 -8.40027e-09 5.41549e-15)
(0.153008 5.12932e-08 5.38933e-15)
(0.153008 1.46526e-07 5.42938e-15)
(0.153027 5.60315e-07 5.41462e-15)
(0.153027 4.58716e-07 5.2667e-15)
(0.153027 3.39174e-07 5.27528e-15)
(0.153027 2.72121e-07 5.31325e-15)
(0.153027 2.29275e-07 5.35332e-15)
(0.153027 1.987e-07 5.34456e-15)
(0.153027 1.78092e-07 5.21066e-15)
(0.153027 1.63204e-07 5.24392e-15)
(0.153027 1.51246e-07 5.1488e-15)
(0.153027 1.4097e-07 5.18946e-15)
(0.153027 1.31564e-07 5.36718e-15)
(0.153027 1.22473e-07 5.27817e-15)
(0.153027 1.13361e-07 5.24234e-15)
(0.153027 1.04017e-07 5.16183e-15)
(0.153027 9.43124e-08 5.22894e-15)
(0.153027 8.41765e-08 5.47887e-15)
(0.153027 7.35824e-08 5.29441e-15)
(0.153027 6.25335e-08 5.28831e-15)
(0.153027 5.10563e-08 5.19611e-15)
(0.153027 3.9194e-08 5.22738e-15)
(0.153027 2.70031e-08 5.57661e-15)
(0.153027 1.45491e-08 5.31769e-15)
(0.153027 1.90496e-09 5.28373e-15)
(0.153027 -1.08522e-08 5.14609e-15)
(0.153027 -2.36427e-08 5.17206e-15)
(0.153027 -3.63861e-08 5.34611e-15)
(0.153027 -4.9002e-08 5.28067e-15)
(0.153027 -6.14111e-08 5.23352e-15)
(0.153027 -7.35366e-08 5.16659e-15)
(0.153027 -8.53046e-08 5.19678e-15)
(0.153028 -9.66449e-08 5.34311e-15)
(0.153028 -1.07492e-07 5.23646e-15)
(0.153028 -1.17784e-07 5.22051e-15)
(0.153028 -1.27465e-07 5.12427e-15)
(0.153028 -1.36485e-07 5.16836e-15)
(0.153028 -1.44798e-07 5.32366e-15)
(0.153028 -1.52364e-07 5.45761e-15)
(0.153028 -1.59147e-07 5.39926e-15)
(0.153028 -1.65117e-07 5.68419e-15)
(0.153028 -1.70245e-07 5.71027e-15)
(0.153028 -1.74507e-07 5.79267e-15)
(0.153028 -1.77877e-07 5.77167e-15)
(0.153028 -1.80326e-07 5.58798e-15)
(0.153028 -1.81823e-07 5.59742e-15)
(0.153028 -1.82321e-07 5.6444e-15)
(0.153028 -1.8176e-07 5.89563e-15)
(0.153028 -1.80047e-07 5.70711e-15)
(0.153028 -1.7705e-07 5.58907e-15)
(0.153028 -1.72572e-07 5.69485e-15)
(0.153028 -1.66323e-07 5.69598e-15)
(0.153028 -1.57874e-07 5.96919e-15)
(0.153028 -1.46606e-07 5.888e-15)
(0.153028 -1.31557e-07 5.64779e-15)
(0.153028 -1.114e-07 5.70257e-15)
(0.153028 -8.3756e-08 5.8113e-15)
(0.153028 -4.58088e-08 5.80843e-15)
(0.153028 9.91211e-09 5.82912e-15)
(0.153028 8.80543e-08 5.71702e-15)
(0.153028 2.21072e-07 5.86354e-15)
(0.153035 6.40344e-07 5.52126e-15)
(0.153035 5.09602e-07 5.57289e-15)
(0.153035 3.35856e-07 5.45806e-15)
(0.153035 2.58706e-07 5.47196e-15)
(0.153035 2.19758e-07 5.48156e-15)
(0.153035 1.91668e-07 5.48008e-15)
(0.153035 1.72107e-07 5.5368e-15)
(0.153035 1.57652e-07 5.43636e-15)
(0.153035 1.45742e-07 5.40366e-15)
(0.153035 1.35336e-07 5.39055e-15)
(0.153035 1.25742e-07 5.4694e-15)
(0.153035 1.16448e-07 5.45194e-15)
(0.153035 1.07131e-07 5.43318e-15)
(0.153035 9.75887e-08 5.52224e-15)
(0.153035 8.76926e-08 5.47191e-15)
(0.153035 7.73717e-08 5.50411e-15)
(0.153035 6.65968e-08 5.50014e-15)
(0.153035 5.53689e-08 5.53288e-15)
(0.153035 4.3712e-08 5.46345e-15)
(0.153035 3.16674e-08 5.50358e-15)
(0.153035 1.92895e-08 5.51568e-15)
(0.153035 6.64286e-09 5.61248e-15)
(0.153035 -6.20086e-09 5.55817e-15)
(0.153035 -1.91652e-08 5.6368e-15)
(0.153035 -3.21711e-08 5.41216e-15)
(0.153035 -4.51376e-08 5.48085e-15)
(0.153035 -5.79839e-08 5.46742e-15)
(0.153035 -7.063e-08 5.48314e-15)
(0.153035 -8.29977e-08 5.63856e-15)
(0.153035 -9.50116e-08 5.49904e-15)
(0.153035 -1.06599e-07 5.48564e-15)
(0.153035 -1.17693e-07 5.5519e-15)
(0.153035 -1.28229e-07 5.45584e-15)
(0.153035 -1.38147e-07 5.61542e-15)
(0.153035 -1.47395e-07 5.44731e-15)
(0.153035 -1.55921e-07 5.47068e-15)
(0.153035 -1.63683e-07 5.51986e-15)
(0.153035 -1.70639e-07 5.54269e-15)
(0.153035 -1.76752e-07 5.60102e-15)
(0.153036 -1.81989e-07 5.66453e-15)
(0.153036 -1.86316e-07 5.74665e-15)
(0.153036 -1.89699e-07 5.76684e-15)
(0.153036 -1.92102e-07 5.72739e-15)
(0.153036 -1.93478e-07 5.70442e-15)
(0.153036 -1.9377e-07 5.73115e-15)
(0.153036 -1.92897e-07 5.74284e-15)
(0.153036 -1.9075e-07 5.75714e-15)
(0.153036 -1.87171e-07 5.7035e-15)
(0.153036 -1.81934e-07 5.6969e-15)
(0.153036 -1.74716e-07 5.74428e-15)
(0.153036 -1.6504e-07 5.7807e-15)
(0.153036 -1.5223e-07 5.79661e-15)
(0.153036 -1.35245e-07 5.76801e-15)
(0.153036 -1.12618e-07 5.80018e-15)
(0.153036 -8.17625e-08 5.81798e-15)
(0.153036 -3.92673e-08 5.83092e-15)
(0.153036 2.35525e-08 5.85167e-15)
(0.153036 1.16777e-07 5.82625e-15)
(0.153036 2.71612e-07 5.84833e-15)
)
;
boundaryField
{
bottomWall
{
type noSlip;
}
topWall
{
type noSlip;
}
sides1_half0
{
type cyclic;
}
sides1_half1
{
type cyclic;
}
sides2_half0
{
type cyclic;
}
sides2_half1
{
type cyclic;
}
inout1_half0
{
type cyclic;
}
inout1_half1
{
type cyclic;
}
inout2_half0
{
type cyclic;
}
inout2_half1
{
type cyclic;
}
procBoundary4to2
{
type processor;
value nonuniform List<vector>
59
(
(0.15303 6.56049e-07 5.63282e-15)
(0.15303 5.28849e-07 5.62989e-15)
(0.15303 3.51796e-07 5.62308e-15)
(0.15303 2.69334e-07 5.62359e-15)
(0.15303 2.27309e-07 5.62611e-15)
(0.15303 1.96836e-07 5.62786e-15)
(0.15303 1.7524e-07 5.62181e-15)
(0.15303 1.59172e-07 5.61855e-15)
(0.15303 1.45935e-07 5.60523e-15)
(0.15303 1.34403e-07 5.58894e-15)
(0.15303 1.23858e-07 5.60065e-15)
(0.15303 1.13753e-07 5.60548e-15)
(0.15303 1.03739e-07 5.60945e-15)
(0.15303 9.3591e-08 5.63809e-15)
(0.15303 8.31636e-08 5.64993e-15)
(0.15303 7.23714e-08 5.64851e-15)
(0.15303 6.11737e-08 5.67447e-15)
(0.15303 4.95622e-08 5.65961e-15)
(0.15303 3.75533e-08 5.67327e-15)
(0.15303 2.51821e-08 5.65683e-15)
(0.15303 1.24981e-08 5.66132e-15)
(0.15303 -4.37945e-10 5.70411e-15)
(0.15303 -1.35577e-08 5.69426e-15)
(0.15303 -2.67872e-08 5.65877e-15)
(0.15303 -4.00493e-08 5.63118e-15)
(0.15303 -5.32645e-08 5.63667e-15)
(0.15303 -6.63526e-08 5.66021e-15)
(0.15303 -7.92339e-08 5.65862e-15)
(0.15303 -9.18302e-08 5.69192e-15)
(0.15303 -1.04066e-07 5.66868e-15)
(0.15303 -1.15867e-07 5.65302e-15)
(0.15303 -1.27165e-07 5.65413e-15)
(0.15303 -1.37894e-07 5.65652e-15)
(0.15303 -1.47994e-07 5.66691e-15)
(0.15303 -1.57407e-07 5.66094e-15)
(0.15303 -1.66082e-07 5.6416e-15)
(0.15303 -1.7397e-07 5.6617e-15)
(0.15303 -1.81028e-07 5.69184e-15)
(0.15303 -1.87213e-07 5.71629e-15)
(0.15303 -1.92488e-07 5.74991e-15)
(0.15303 -1.96812e-07 5.77266e-15)
(0.15303 -2.00145e-07 5.80425e-15)
(0.15303 -2.02441e-07 5.81895e-15)
(0.15303 -2.03645e-07 5.80734e-15)
(0.15303 -2.03687e-07 5.80613e-15)
(0.153031 -2.02475e-07 5.79192e-15)
(0.153031 -1.99883e-07 5.79683e-15)
(0.153031 -1.95736e-07 5.7843e-15)
(0.153031 -1.89786e-07 5.76733e-15)
(0.153031 -1.81688e-07 5.77506e-15)
(0.153031 -1.70942e-07 5.78041e-15)
(0.153031 -1.56841e-07 5.81321e-15)
(0.153031 -1.38321e-07 5.83076e-15)
(0.153031 -1.13881e-07 5.84042e-15)
(0.153031 -8.09445e-08 5.86148e-15)
(0.153031 -3.60371e-08 5.86461e-15)
(0.153031 2.91872e-08 5.87445e-15)
(0.153031 1.25141e-07 5.8738e-15)
(0.153031 2.80592e-07 5.87302e-15)
)
;
}
procBoundary4to3
{
type processor;
value nonuniform List<vector>
63
(
(0.123405 -2.60271e-07 1.07551e-16)
(0.123405 -2.78562e-07 9.7883e-17)
(0.123406 -2.68291e-07 1.47255e-16)
(0.123406 -2.53847e-07 1.08674e-16)
(0.123406 -2.40339e-07 1.42672e-16)
(0.123406 -2.27968e-07 4.54307e-19)
(0.123406 -2.16637e-07 -7.5684e-17)
(0.123406 -2.06335e-07 -1.27607e-18)
(0.123406 -1.97024e-07 1.11132e-17)
(0.123406 -1.88601e-07 9.10263e-17)
(0.123406 -1.80905e-07 1.59414e-17)
(0.123406 -1.73745e-07 -9.65784e-17)
(0.123406 -1.66924e-07 -3.67733e-17)
(0.123406 -1.60261e-07 -5.71646e-17)
(0.123406 -1.53611e-07 1.40761e-19)
(0.123406 -1.46864e-07 -8.82357e-17)
(0.123406 -1.39945e-07 -1.50392e-16)
(0.123406 -1.32813e-07 -1.98386e-17)
(0.123406 -1.25444e-07 -3.9676e-17)
(0.123406 -1.17833e-07 3.1694e-17)
(0.123406 -1.09982e-07 -5.65346e-17)
(0.123406 -1.01902e-07 -1.42171e-16)
(0.123406 -9.36093e-08 -5.66363e-17)
(0.123406 -8.51243e-08 -8.20597e-17)
(0.123406 -7.64704e-08 -3.39594e-17)
(0.123406 -6.76744e-08 -1.31427e-16)
(0.123406 -5.8762e-08 -2.03049e-16)
(0.123406 -4.97625e-08 -1.02685e-16)
(0.123406 -4.06981e-08 -1.18319e-16)
(0.123406 -3.15937e-08 -5.55346e-17)
(0.123406 -2.24644e-08 -1.42064e-16)
(0.123406 -1.32874e-08 -5.82526e-17)
(0.123406 -4.11029e-09 -1.311e-16)
(0.123406 5.47083e-09 -5.06347e-17)
(0.123406 1.47498e-08 9.89151e-17)
(0.123406 2.79805e-08 -7.372e-17)
(0.123406 3.51318e-08 -6.57763e-17)
(0.123406 1.04722e-07 -1.38629e-16)
(0.124562 -7.80009e-08 3.85088e-16)
(0.124562 -2.05136e-07 2.60343e-16)
(0.124562 -2.05136e-07 2.60343e-16)
(0.124562 1.82364e-07 1.06448e-16)
(0.124562 1.82364e-07 1.06448e-16)
(0.124562 2.33297e-07 1.59306e-16)
(0.125681 3.94129e-07 6.2855e-16)
(0.125681 9.11591e-08 5.35459e-16)
(0.125681 9.11591e-08 5.35459e-16)
(0.125681 2.85094e-07 3.00013e-16)
(0.125681 2.85094e-07 3.00013e-16)
(0.125681 2.59115e-07 3.31529e-16)
(0.125681 2.22708e-07 2.89457e-16)
(0.125681 1.99076e-07 3.17108e-16)
(0.125681 1.82955e-07 3.60051e-16)
(0.125681 1.70672e-07 3.24937e-16)
(0.125681 1.60669e-07 3.47728e-16)
(0.12568 1.52303e-07 2.98589e-16)
(0.12568 1.4685e-07 3.33391e-16)
(0.12568 1.43108e-07 3.63012e-16)
(0.12568 1.50232e-07 3.34917e-16)
(0.12568 1.55764e-07 3.70508e-16)
(0.12568 2.10562e-07 3.26258e-16)
(0.12568 2.2876e-07 3.55396e-16)
(0.12568 4.95037e-07 3.85233e-16)
)
;
}
procBoundary4to5
{
type processor;
value nonuniform List<vector>
132
(
(0.126764 2.30792e-07 7.99202e-16)
(0.126763 6.51337e-07 5.65028e-16)
(0.127812 2.20105e-07 1.01306e-15)
(0.127812 6.4112e-07 7.84617e-16)
(0.128827 1.99975e-07 1.22559e-15)
(0.128826 6.1971e-07 1.00596e-15)
(0.12981 1.74894e-07 1.42434e-15)
(0.12981 5.89791e-07 1.23083e-15)
(0.130764 1.47686e-07 1.6223e-15)
(0.130763 5.53962e-07 1.46263e-15)
(0.131688 1.19674e-07 1.80901e-15)
(0.131688 5.1438e-07 1.70742e-15)
(0.132584 9.15209e-08 2.00501e-15)
(0.132584 4.72623e-07 1.97896e-15)
(0.133453 6.35479e-08 2.23917e-15)
(0.133452 4.29773e-07 2.28055e-15)
(0.134295 3.58979e-08 2.40707e-15)
(0.134294 3.86541e-07 2.40829e-15)
(0.135111 8.62749e-09 2.58817e-15)
(0.13511 3.43399e-07 2.64104e-15)
(0.135902 -1.82413e-08 2.77714e-15)
(0.1359 3.00667e-07 2.8685e-15)
(0.136667 -4.46965e-08 2.96382e-15)
(0.136666 2.58589e-07 3.10768e-15)
(0.137409 -7.07252e-08 3.1516e-15)
(0.137407 2.17363e-07 3.28027e-15)
(0.138126 -9.63097e-08 3.32591e-15)
(0.138125 1.77164e-07 3.47967e-15)
(0.13882 -1.21426e-07 3.495e-15)
(0.138819 1.38152e-07 3.68847e-15)
(0.139491 -1.46043e-07 3.65798e-15)
(0.13949 1.00474e-07 3.89973e-15)
(0.14014 -1.70123e-07 3.80663e-15)
(0.140138 6.4259e-08 4.10843e-15)
(0.140766 -1.93625e-07 3.96906e-15)
(0.140765 2.96172e-08 4.30498e-15)
(0.14137 -2.16498e-07 4.13691e-15)
(0.141369 -3.36319e-09 4.50195e-15)
(0.141953 -2.38687e-07 4.29567e-15)
(0.141952 -3.46171e-08 4.62745e-15)
(0.142515 -2.60132e-07 4.36586e-15)
(0.142514 -6.4103e-08 4.72703e-15)
(0.143057 -2.80766e-07 4.41899e-15)
(0.143055 -9.18016e-08 4.85344e-15)
(0.143578 -3.00517e-07 4.5338e-15)
(0.143577 -1.17714e-07 4.9552e-15)
(0.144079 -3.19309e-07 4.67512e-15)
(0.144078 -1.41857e-07 5.09086e-15)
(0.144561 -3.3706e-07 4.78446e-15)
(0.14456 -1.64264e-07 5.23655e-15)
(0.145024 -3.53687e-07 4.91232e-15)
(0.145023 -1.84979e-07 5.26249e-15)
(0.145468 -3.69101e-07 5.04434e-15)
(0.145468 -2.04052e-07 5.306e-15)
(0.145895 -3.83216e-07 5.17359e-15)
(0.145894 -2.21543e-07 5.3667e-15)
(0.146304 -3.9594e-07 5.29568e-15)
(0.146303 -2.37512e-07 5.45173e-15)
(0.146695 -4.07188e-07 5.41521e-15)
(0.146695 -2.52023e-07 5.65639e-15)
(0.147071 -4.16872e-07 5.50711e-15)
(0.14707 -2.6514e-07 5.57132e-15)
(0.14743 -4.24912e-07 5.60665e-15)
(0.14743 -2.76926e-07 5.47942e-15)
(0.147773 -4.31228e-07 5.50677e-15)
(0.147774 -2.87443e-07 5.34032e-15)
(0.148102 -4.3575e-07 5.41865e-15)
(0.148102 -2.9675e-07 5.16575e-15)
(0.148416 -4.38415e-07 5.28238e-15)
(0.148417 -3.04903e-07 4.9097e-15)
(0.148717 -4.39166e-07 5.16272e-15)
(0.148717 -3.11953e-07 4.88517e-15)
(0.149003 -4.37957e-07 5.02385e-15)
(0.149004 -3.17946e-07 4.85738e-15)
(0.149277 -4.34751e-07 4.82686e-15)
(0.149278 -3.22923e-07 4.62924e-15)
(0.149539 -4.29521e-07 4.72847e-15)
(0.149539 -3.26916e-07 4.58705e-15)
(0.149788 -4.22252e-07 4.63818e-15)
(0.149789 -3.29949e-07 4.35896e-15)
(0.150026 -4.12936e-07 4.60254e-15)
(0.150027 -3.32036e-07 4.18478e-15)
(0.150253 -4.01577e-07 4.60177e-15)
(0.150254 -3.33178e-07 4.05919e-15)
(0.15047 -3.88185e-07 4.61848e-15)
(0.150471 -3.33365e-07 3.95981e-15)
(0.150676 -3.72778e-07 4.63946e-15)
(0.150677 -3.32572e-07 3.86148e-15)
(0.150873 -3.55381e-07 4.63685e-15)
(0.150874 -3.30754e-07 3.86306e-15)
(0.151061 -3.36018e-07 4.63096e-15)
(0.151061 -3.27851e-07 3.7923e-15)
(0.151239 -3.14718e-07 4.51263e-15)
(0.15124 -3.2378e-07 4.03399e-15)
(0.151409 -2.91504e-07 4.40435e-15)
(0.151409 -3.18436e-07 4.12326e-15)
(0.15157 -2.66396e-07 4.32814e-15)
(0.15157 -3.11686e-07 4.34659e-15)
(0.151723 -2.39402e-07 4.32164e-15)
(0.151723 -3.03371e-07 4.57737e-15)
(0.151867 -2.10517e-07 4.18089e-15)
(0.151868 -2.93299e-07 4.63053e-15)
(0.152004 -1.79717e-07 4.04168e-15)
(0.152005 -2.81242e-07 4.69819e-15)
(0.152134 -1.4695e-07 4.09167e-15)
(0.152134 -2.66928e-07 4.73906e-15)
(0.152255 -1.12135e-07 4.07455e-15)
(0.152255 -2.50038e-07 4.71885e-15)
(0.152368 -7.51478e-08 4.06465e-15)
(0.152369 -2.30196e-07 4.69478e-15)
(0.152474 -3.58132e-08 4.01445e-15)
(0.152474 -2.06951e-07 4.73601e-15)
(0.152572 6.10823e-09 4.07291e-15)
(0.152572 -1.7976e-07 4.86374e-15)
(0.152662 5.09377e-08 4.17977e-15)
(0.152662 -1.47961e-07 4.86388e-15)
(0.152743 9.91008e-08 4.3075e-15)
(0.152743 -1.10732e-07 4.69256e-15)
(0.152815 1.51157e-07 4.42903e-15)
(0.152815 -6.70519e-08 4.83238e-15)
(0.152878 2.07829e-07 4.65168e-15)
(0.152878 -1.56591e-08 4.50109e-15)
(0.152932 2.69998e-07 4.92454e-15)
(0.152932 4.48813e-08 4.59979e-15)
(0.152975 3.38624e-07 5.16385e-15)
(0.152975 1.1575e-07 5.04988e-15)
(0.153007 4.14702e-07 5.29528e-15)
(0.153007 1.96943e-07 5.44537e-15)
(0.153027 4.96412e-07 5.42269e-15)
(0.153028 2.8616e-07 5.86322e-15)
(0.153035 5.52752e-07 5.51509e-15)
(0.153036 3.60784e-07 5.86671e-15)
)
;
}
}
// ************************************************************************* //
| [
"dikshant.sud@gmail.com"
] | dikshant.sud@gmail.com | |
1f7f331a1223fc5cdcfdcd36c8590d4000adf8ea | f4aa6bfdf2bf1caacf9e9a8cefd09d00382e9e8c | /My_Study/CBY_Projects/C_Client_window/C_Clientsrc.h | 45a000e2bdcb575fd9ec9ca51cff94425b4fb4f3 | [] | no_license | Byeng-Yong-Choi/C_Yong | e39a015b64facd473c5193d21a157b552813e9b7 | 9c2a1856b7c59156c2364ea2bf0a21e3d02eab1d | refs/heads/master | 2020-09-28T14:26:17.358211 | 2019-12-18T04:51:44 | 2019-12-18T04:51:44 | 226,795,230 | 1 | 0 | null | 2019-12-09T05:57:44 | 2019-12-09T05:53:34 | null | UTF-8 | C++ | false | false | 314 | h | #pragma once
#include "C_Client.h"
class C_Clientsrc: public C_Client
{
public:
FD_SET rSet;
FD_SET wSet;
public:
bool Init();
void SetFunction();
bool RunThread() override;
bool Run() override;
bool SelectRun();
public:
static void RecvMsg(USERPAKET& pk);
public:
C_Clientsrc();
~C_Clientsrc();
};
| [
"58583903+Byeng-Yong-Choi@users.noreply.github.com"
] | 58583903+Byeng-Yong-Choi@users.noreply.github.com |
e176c3d6fd34d45fa51cd766f448568e14aef489 | 0e5ea03c2455b34a2f416c6c94c1669d7fe26e37 | /_2017_08_18 Armata Tank 1/CameraManager.h | 59f183bcb8f78fbc04e1c95232f5591a6c16e18f | [] | no_license | Arroria/__old_project | 8682652fac9a95898b41eff5b4fdfab023cda699 | efb655b2356bd95744ba19093f25ab266a625722 | refs/heads/master | 2020-09-05T08:02:44.806509 | 2019-11-06T18:01:23 | 2019-11-06T18:01:23 | 220,033,980 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 457 | h | #pragma once
namespace AF
{
class CameraManager
{
private:
D3DXVECTOR3 m_cameraEye;
D3DXVECTOR3 m_cameraAt;
D3DXVECTOR3 m_cameraUp;
float m_viewAngle;
float m_sightAngle;
public:
void SetViewTransform (const D3DXVECTOR3& eye, const D3DXVECTOR3& at, const D3DXVECTOR3& up = D3DXVECTOR3(0, 1, 0));
void SetProjectionTransform (const float& viewingAngle, const float& sightRange);
public:
CameraManager();
~CameraManager();
};
}
| [
"mermerkwon@naver.com"
] | mermerkwon@naver.com |
139551b0df5725bbf8fa01debf80a0c87fa93924 | 91a882547e393d4c4946a6c2c99186b5f72122dd | /Source/XPSP1/NT/admin/wmi/wbem/winmgmt/wmitest/methodspg.cpp | 4ee3685ebb779717a8a0ea8b15a37aa8c1f69582 | [] | no_license | IAmAnubhavSaini/cryptoAlgorithm-nt5src | 94f9b46f101b983954ac6e453d0cf8d02aa76fc7 | d9e1cdeec650b9d6d3ce63f9f0abe50dabfaf9e2 | refs/heads/master | 2023-09-02T10:14:14.795579 | 2021-11-20T13:47:06 | 2021-11-20T13:47:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,470 | cpp | /*++
Copyright (C) 1997-2001 Microsoft Corporation
Module Name:
Abstract:
History:
--*/
// MethodsPg.cpp : implementation file
//
#include "stdafx.h"
#include "wmitest.h"
#include "MethodsPg.h"
#include "WMITestDoc.h"
#include "MainFrm.h"
#include "OpWrap.h"
#include "ParamsPg.h"
#include "PropQualsPg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMethodsPg property page
IMPLEMENT_DYNCREATE(CMethodsPg, CPropertyPage)
CMethodsPg::CMethodsPg() : CPropertyPage(CMethodsPg::IDD)
{
//{{AFX_DATA_INIT(CMethodsPg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
CMethodsPg::~CMethodsPg()
{
}
void CMethodsPg::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMethodsPg)
DDX_Control(pDX, IDC_METHODS, m_ctlMethods);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMethodsPg, CPropertyPage)
//{{AFX_MSG_MAP(CMethodsPg)
ON_BN_CLICKED(IDC_ADD, OnAdd)
ON_BN_CLICKED(IDC_EDIT, OnEdit)
ON_BN_CLICKED(IDC_DELETE, OnDelete)
ON_NOTIFY(NM_DBLCLK, IDC_METHODS, OnDblclkMethods)
ON_NOTIFY(LVN_ITEMCHANGED, IDC_METHODS, OnItemchangedMethods)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMethodsPg message handlers
void CMethodsPg::OnAdd()
{
CPropertySheet sheet(IDS_EDIT_NEW_METHOD);
CParamsPg pgParams;
pgParams.m_bNewMethod = TRUE;
pgParams.m_pClass = m_pObj;
sheet.AddPage(&pgParams);
if (sheet.DoModal() == IDOK)
{
HRESULT hr;
hr =
m_pObj->PutMethod(
_bstr_t(pgParams.m_strName),
0,
pgParams.m_pObjIn,
pgParams.m_pObjOut);
if (SUCCEEDED(hr))
AddMethod(pgParams.m_strName);
else
CWMITestDoc::DisplayWMIErrorBox(hr);
}
}
void CMethodsPg::OnEdit()
{
int iItem = GetSelectedItem();
if (iItem != -1)
{
CPropertySheet sheet(IDS_EDIT_METHOD);
CParamsPg pgParams;
CPropQualsPg pgQuals;
pgParams.m_strName = m_ctlMethods.GetItemText(iItem, 0);
pgParams.m_bNewMethod = FALSE;
pgParams.m_pClass = m_pObj;
sheet.AddPage(&pgParams);
pgQuals.m_pObj = m_pObj;
pgQuals.m_bIsInstance = FALSE;
pgQuals.m_mode = CPropQualsPg::QMODE_METHOD;
pgQuals.m_strMethodName = pgParams.m_strName;
sheet.AddPage(&pgQuals);
if (sheet.DoModal() == IDOK)
{
HRESULT hr;
hr =
m_pObj->PutMethod(
_bstr_t(pgParams.m_strName),
0,
pgParams.m_pObjIn,
pgParams.m_pObjOut);
if (SUCCEEDED(hr))
{
LV_ITEM item;
item.mask = LVIF_IMAGE;
item.iItem = iItem;
item.iImage = GetMethodImage(pgParams.m_strName);
m_ctlMethods.SetItem(&item);
}
else
CWMITestDoc::DisplayWMIErrorBox(hr);
}
}
}
void CMethodsPg::OnDelete()
{
int iItem = GetSelectedItem();
if (iItem != -1)
{
HRESULT hr;
CString strName = m_ctlMethods.GetItemText(iItem, 0);
if (SUCCEEDED(hr =
m_pObj->DeleteMethod(_bstr_t(strName))))
{
m_ctlMethods.DeleteItem(iItem);
int nItems = m_ctlMethods.GetItemCount();
if (iItem >= nItems)
iItem--;
if (iItem >= 0)
m_ctlMethods.SetItemState(iItem, LVIS_SELECTED, LVIS_SELECTED);
}
else
CWMITestDoc::DisplayWMIErrorBox(hr);
}
}
void CMethodsPg::OnDblclkMethods(NMHDR* pNMHDR, LRESULT* pResult)
{
OnEdit();
*pResult = 0;
}
void CMethodsPg::OnItemchangedMethods(NMHDR* pNMHDR, LRESULT* pResult)
{
UpdateButtons();
*pResult = 0;
}
BOOL CMethodsPg::OnInitDialog()
{
CPropertyPage::OnInitDialog();
InitListCtrl();
LoadMethods();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CMethodsPg::UpdateButtons()
{
int iIndex = GetSelectedItem();
GetDlgItem(IDC_DELETE)->EnableWindow(iIndex != -1);
GetDlgItem(IDC_EDIT)->EnableWindow(iIndex != -1);
}
int CMethodsPg::GetSelectedItem()
{
POSITION pos = m_ctlMethods.GetFirstSelectedItemPosition();
if (pos)
return m_ctlMethods.GetNextSelectedItem(pos);
else
return -1;
}
void CMethodsPg::InitListCtrl()
{
RECT rect;
CString strTemp;
m_ctlMethods.SetExtendedStyle(LVS_EX_FULLROWSELECT);
m_ctlMethods.SetImageList(&((CMainFrame *) AfxGetMainWnd())->m_imageList,
LVSIL_SMALL);
m_ctlMethods.GetClientRect(&rect);
strTemp.LoadString(IDS_NAME);
m_ctlMethods.InsertColumn(0, strTemp, LVCFMT_LEFT, rect.right);
}
void CMethodsPg::LoadMethods()
{
HRESULT hr;
m_ctlMethods.DeleteAllItems();
int iItem = 0;
if (SUCCEEDED(hr = m_pObj->BeginMethodEnumeration(0)))
{
BSTR pName = NULL;
while(1)
{
hr =
m_pObj->NextMethod(
0,
&pName,
NULL,
NULL);
if (FAILED(hr) || hr == WBEM_S_NO_MORE_DATA)
break;
AddMethod(_bstr_t(pName));
SysFreeString(pName);
}
}
UpdateButtons();
if (FAILED(hr))
CWMITestDoc::DisplayWMIErrorBox(hr);
}
int CMethodsPg::GetMethodImage(LPCTSTR szName)
{
IWbemQualifierSetPtr pQuals;
HRESULT hr;
int iImage = IMAGE_OBJECT;
if (SUCCEEDED(hr = m_pObj->GetMethodQualifierSet(
_bstr_t(szName),
&pQuals)))
{
_variant_t vStatic;
if (SUCCEEDED(hr = pQuals->Get(
L"static",
0,
&vStatic,
NULL)) && vStatic.vt == VT_BOOL && (bool) vStatic == true)
{
iImage = IMAGE_CLASS;
}
}
return iImage;
}
void CMethodsPg::AddMethod(LPCTSTR szName)
{
int iImage = GetMethodImage(szName),
iItem = m_ctlMethods.GetItemCount();
m_ctlMethods.InsertItem(iItem, szName, iImage);
}
| [
"support@cryptoalgo.cf"
] | support@cryptoalgo.cf |
a09eb1d2741f7e6a3b45ae7feead48d2ea5dcd0b | 8403304f3a79159e0a5e4cb03200d950f5359dc7 | /Day-36/203_RemoveLinkedListElements.cpp | c8a803156798f1bd2595158d43f23c8725a3bbda | [] | no_license | pratham-0094/100DaysOfCode | c38be5bbf9332b91667e1730d87389de9f4f1879 | 19d35726e5418d77a0af410594c986c7abd2eea2 | refs/heads/main | 2023-09-05T15:55:07.564770 | 2021-11-19T17:57:36 | 2021-11-19T17:57:36 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,728 | cpp | #include <iostream>
using namespace std;
class ListNode
{
public:
int val;
ListNode *next;
ListNode(int data)
{
val = data;
next = NULL;
}
};
void InsertAtHead(ListNode *&head, int val)
{
ListNode *n = new ListNode(val);
if (head == NULL)
{
n->next = n;
head = n;
return;
}
ListNode *temp = head;
while (temp->next != head)
{
temp = temp->next;
}
temp->next = n;
n->next = head;
head = n;
}
void Insert(ListNode *&head, int val)
{
ListNode *n = new ListNode(val);
if (head == NULL)
{
InsertAtHead(head, val);
return;
}
ListNode *temp = head;
while (temp->next != head)
{
temp = temp->next;
}
temp->next = n;
n->next = head;
}
class Solution
{
public:
ListNode *removeElements(ListNode *head, int val)
{
if (head == NULL)
{
return head;
}
while (head->val == val)
{
if (head->next == NULL)
{
return NULL;
}
else
head = head->next;
}
ListNode *temp1 = head;
ListNode *temp2 = head->next;
while (temp2 != NULL)
{
if (temp2->val == val)
{
ListNode *todelete = temp2;
if (temp2->next == NULL)
{
temp1->next = NULL;
delete todelete;
return head;
}
temp1->next = temp2->next;
temp2 = temp2->next;
delete todelete;
}
else
{
temp2 = temp2->next;
temp1 = temp1->next;
}
}
return head;
}
void DeleteAtHead(ListNode *&head)
{
ListNode *temp = head;
if (temp->next != NULL)
{
temp = temp->next;
}
ListNode *todelete = head;
head = head->next;
delete todelete;
}
};
void display(ListNode *head)
{
ListNode *temp = head;
do
{
cout << temp->val << "->";
temp = temp->next;
} while (temp != head);
cout <<"NULL"<< endl;
}
int main()
{
ListNode *head = NULL;
Insert(head, 1);
Insert(head, 2);
Insert(head, 3);
Insert(head, 4);
Insert(head, 5);
Insert(head, 6);
Insert(head, 7);
display(head);
Solution dt;
ListNode* ans=dt.removeElements(head, 5);
display(ans);
return 0;
} | [
"noreply@github.com"
] | noreply@github.com |
adaa314c1319788f2ccfe127e789aea8eb34b08a | 6eeabf248d1a7550e20e334e5aa2afd6c693c444 | /peano/datatraversal/dForLoop.h | 0a220432bba29789127239b5b182e0d256bc5e52 | [] | no_license | yungcheeze/peano-code | b70edbe2e5422620b7c6b95980a30abc5535ecc6 | e8b688ed7a96d47a331d7bcaf3e57e5c0735137d | refs/heads/master | 2021-09-12T22:11:04.138074 | 2017-12-08T07:24:53 | 2017-12-08T07:24:53 | 100,594,193 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,062 | h | // This file is part of the Peano project. For conditions of distribution and
// use, please see the copyright notice at www.peano-framework.org
#ifndef _PEANO_DATA_TRAVERSAL_DFOR_LOOP_H_
#define _PEANO_DATA_TRAVERSAL_DFOR_LOOP_H_
#include "tarch/la/Vector.h"
#include "tarch/logging/Log.h"
#include "peano/datatraversal/dForRange.h"
#include "peano/datatraversal/tests/dForLoopTest.h"
#include "tarch/multicore/BooleanSemaphore.h"
#include <vector>
namespace peano {
namespace datatraversal {
template <class LoopBody>
class dForLoop;
}
}
/**
* Simple d-dimensional For-Loop
*
* This class is a simple wrapper for for-loops that has one significant
* advantage: It is parallelised if TBBs or OpenMP are included. The class
* needs, besides the range (iteration space), an event handle (loop body). It
* has to implement an operator() (const tarch::la::Vector<DIMENSIONS,int>& i)
* at least (see remarks below).
*
* This means you write a simple class with a constructor and this single
* operation. Then, you move the body of your original for-loop to the
* implementation of the operator() and replace the original for loop by
* something similar to
* \code
typedef loops::GridStoreVertexLoopBody LoopBody;
LoopBody loopBody(*this,other arguments you need within the loop body);
peano::datatraversal::dForLoop<LoopBody>(int-vector with loop range,loopBody);
\endcode
*
* The range implementation will copy the loop body for each thread, i.e. you
* have to ensure that there is an appropriate copy constructor for your loop
* body. The loop body class itself may have a state and also may modify this
* state from call to call. However, this state ain't persistent, i.e. after
* the very last iteration (and you actually don't know how many iterations
* there will be due to load stealing), the complete object is thrown away.
*
* If you want to merge a thread's local copies into a global variable, you
* do this in the operation mergeWithWorkerThread(). The grid's loops for
* example all have a merge operation (TBB calls this merge join) that first
* locks a global semaphore, and then it calls a merge
* operation on the mappings.
*
* Merging the whole loop body back however is not a cheap process. If it is
* not required (this holds notably if your loop already does restrict
* on-the-fly, i.e. it sets some global values protected by a semaphore), then
* you can run the parallel loop without a reduction. mergeWithMaster then is
* omitted.
*
* We finally emphasise that thread merges in this code are done in two steps.
* The loop class creates copies of the loop body and merges those guys back
* via mergeWithWorkerThread(). At the very end, i.e. after the very last
* thread has terminated, it then merges back this thread into the prototype
* (original loop body handed over) via mergeIntoMasterThread(). This allows
* you to do different things, notably if several loop types run in parallel
* in your code.
*
*
* <h2> Parallel Implementation (TBB) </h2>
*
* The TBB implementation is straightforward. While I could deploy the range
* management to the loop bodys, i.e. the loop bodys' operator() runs over a
* whole range, this would make the implementation more difficult. Instead, I
* decided to require the loop body only to provide an operator() operating on
* one single element.
*
* However, forcing TBB to create a task per loop element in turn induces a big
* overhead. Thus, I introduced an intermediate layer: The embedded class
* dForLoopInstance implements the loop over a (sub)-range, i.e. the dForLoop
* itself just creates an instance of dForLoopInstance and invokes a parallel
* for for this object. The object accepts a Peano range, traverses this range,
* and invokes the loop body's operator() for each range element. It is
* important that dForLoopInstance creates a thread-local copy of the loop body
* - Peano allows loop bodys to have a (thread-wise) state. Thus, we have to
* ensure that we are working on a copy and that not all threads are working on
* the same loop body instance.
*
* One may not use TBB's parallel_for as parallel for requires the loop bodies
* to be const. Instead, we have to use the parallel_reduce even though we
* merge the copies ourself in the destructors.
*
*
* <h2> Serial runs </h2>
*
* If the code is running serial, the loop body is not copied at all. If the
* code runs in parallel, each thread creates a copy of the loop body. In
* particular, also the master thread first creates a copy and then loops,
* i.e. we also create a copy even if we work only with one thread.
*
* <h2> Runs without reduction </h2>
*
* You can run the whole code without a reduction. For this, you may omit the
* merge operations, but the important thing is that you make operator() const.
*
* @author Tobias Weinzierl
*/
template <class LoopBody>
class peano::datatraversal::dForLoop {
private:
friend class peano::datatraversal::tests::dForLoopTest;
static tarch::logging::Log _log;
/**
* Required only for OpenMP (not used currently)
*/
static std::vector<dForRange> createRangesVector(
const tarch::la::Vector<DIMENSIONS,int>& range,
int grainSize
);
class dForLoopInstance {
private:
LoopBody _loopBody;
tarch::la::Vector<DIMENSIONS,int> _offset;
const int _padding;
public:
dForLoopInstance(
const LoopBody& loopBody,
tarch::la::Vector<DIMENSIONS,int> offset,
const int padding
);
void setOffset(const tarch::la::Vector<DIMENSIONS,int>& offset);
/**
* See documentation of TBB. This flag is just used to
* distinguish the split constructor from a standard
* copy constructor.
*/
#if defined(SharedTBB) || defined(SharedTBBInvade)
typedef tbb::split SplitFlag;
#else
typedef int SplitFlag;
#endif
/**
* Copy Constructor
*
* TBB requires the copy constructor for loops to accept an additional
* argument to be able to distinguish it from the standard copy
* constructor. As a consequence, the code does not compile anymore
* without tbb. I thus wrap the TBB type with a typedef of my own.
*/
dForLoopInstance( const dForLoopInstance& loopBody, SplitFlag );
/**
* Process range
*
* Could, at first glance, be const as the method copies the loop body anyway. The
* operation first copies the loop body. This process can run
* in parallel, as the copy process may not modify the original
* loop body instance. When the operation has terminated, it calls the
* loop body copy's updateGlobalValues(). Usually, the copy holds a
* reference to the original data. A reference not used until this
* final operation is called. The final operation then commits changes
* to the original data set. This operation hence is not const.
* Consequently, the whole operator may not be const.
*/
void operator() (const dForRange& range);
/**
* A loopInstance wrapper for the LoopBody operator()
* Allows for convenient use of the padding and offset functionality of a
* LoopInstance
*/
void operator() (const tarch::la::Vector<DIMENSIONS,int>& range);
/**
* Maps TBB's join onto mergeWithWorkerThread
*/
void join(const dForLoopInstance& with);
void mergeIntoMasterThread( LoopBody& originalLoopBody ) const;
};
class dForLoopInstanceWithoutReduction {
private:
//const LoopBody& _loopBody;
LoopBody _loopBody;
tarch::la::Vector<DIMENSIONS,int> _offset;
const int _padding;
public:
dForLoopInstanceWithoutReduction(
const LoopBody& loopBody,
tarch::la::Vector<DIMENSIONS,int> offset,
const int padding
);
void setOffset(const tarch::la::Vector<DIMENSIONS,int>& offset);
/**
* See documentation of TBB. This flag is just used to
* distinguish the split constructor from a standard
* copy constructor.
*/
#if defined(SharedTBB) || defined(SharedTBBInvade)
typedef tbb::split SplitFlag;
#else
typedef int SplitFlag;
#endif
/**
* Copy Constructor
*
* TBB requires the copy constructor for loops to accept an additional
* argument to be able to distinguish it from the standard copy
* constructor. As a consequence, the code does not compile anymore
* without tbb. I thus wrap the TBB type with a typedef of my own.
*/
dForLoopInstanceWithoutReduction( const dForLoopInstanceWithoutReduction& loopBody, SplitFlag );
void operator() (const dForRange& range) const;
void operator() (const tarch::la::Vector<DIMENSIONS,int>& range) const;
};
void runSequentially(
const tarch::la::Vector<DIMENSIONS,int>& range,
LoopBody& loopBody
);
void runParallelWithoutColouring(
const tarch::la::Vector<DIMENSIONS,int>& range,
LoopBody& loopBody,
int grainSize,
bool altersState
);
void runParallelWithColouring(
const tarch::la::Vector<DIMENSIONS,int>& range,
LoopBody& loopBody,
int grainSize,
int colouring,
bool altersState
);
public:
enum ParallelisationStrategy {
Serial = 0,
NoColouring = 1,
TwoPowerDColouring = 2,
SixPowerDColouring = 6,
SevenPowerDColouring = 7
};
/**
* Constructor
*
* @param grainSize Grain size of problem. See dForLoop for a
* documentation. If the grain size equals zero, the
* multithreading is switched off. Another term for grain
* size is chunk size (OpenMP prefers this term).
*/
inline dForLoop(
const tarch::la::Vector<DIMENSIONS,int>& range,
LoopBody& body,
int grainSize,
int colouring,
bool altersState
);
};
#include "peano/datatraversal/dForLoop.cpph"
#endif
| [
"tobiasweinzierl@aa977e5b-e928-4c84-aa66-c90e40304b12"
] | tobiasweinzierl@aa977e5b-e928-4c84-aa66-c90e40304b12 |
b403e7edfd6d64cb9f5d8676adac42a4d8418840 | fef58dcd0c1434724a0a0a82e4c84ae906200289 | /usages/0x633F6F44A537EBB6.cpp | 588f1457045a8cd06ce59e2eeea3d5c53af608b4 | [] | no_license | DottieDot/gta5-additional-nativedb-data | a8945d29a60c04dc202f180e947cbdb3e0842ace | aea92b8b66833f063f391cb86cbcf4d58e1d7da3 | refs/heads/main | 2023-06-14T08:09:24.230253 | 2021-07-11T20:43:48 | 2021-07-11T20:43:48 | 380,364,689 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 426 | cpp | // fm_bj_race_controler.ysc @ L275888
bool func_3663(int iParam0, int iParam1)
{
return (((((((VEHICLE::IS_THIS_MODEL_A_BOAT(iParam0) || VEHICLE::IS_THIS_MODEL_A_JETSKI(iParam0)) || VEHICLE::_IS_THIS_MODEL_AN_AMPHIBIOUS_CAR(iParam0)) || VEHICLE::_IS_THIS_MODEL_AN_AMPHIBIOUS_QUADBIKE(iParam0)) || iParam0 == joaat("TULA")) || iParam0 == joaat("DODO")) || iParam0 == joaat("SEABREEZE")) || (iParam1 && func_3664(iParam0)));
} | [
"tvangroenigen@outlook.com"
] | tvangroenigen@outlook.com |
52132525dabd9ec9ef4d5c772434be2bb0477ada | cbd5f21dd2924140d717d4263c493a9b015af898 | /src/o3s/plugins/fbxi/proxy/globalsettingsproxy.cpp | 48cc73873f5624ac1cf85ab2031674a5dc6e4174 | [] | no_license | dream-overflow/o3sfbxi | 9a13e0f8d0fc6f667301de4cc92f38ff946f91aa | b7eee7744c989fdbf42df665df4d297dd3d52b95 | refs/heads/master | 2020-04-27T08:03:20.300228 | 2018-04-19T11:28:36 | 2018-04-19T11:28:36 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,870 | cpp | /**
* @brief FBX global settings data proxy
* @copyright Copyright (C) 2018 Dream Overflow. All rights reserved.
* @author Frederic SCHERMA (frederic.scherma@dreamoverflow.org)
* @date 2018-01-20
* @details
*/
#include "globalsettingsproxy.h"
#include <o3d/core/debug.h>
#include "../property/propertystring.h"
#include "../property/propertyint32.h"
#include "../property/propertyfloat32.h"
#include "../property/propertyfloat64.h"
using namespace o3d::studio::fbxi;
GlobalSettingsProxy::GlobalSettingsProxy(FBXNode *node) :
Proxy(node)
{
if (!m_node || m_node->name() != "GlobalSettings") {
O3D_ERROR(E_InvalidParameter("Must be an GlobalSettings node"));
}
// @todo check Version == 1000
}
o3d::Vector3 GlobalSettingsProxy::upAxis()
{
Vector3 axis;
Int32 a = 0;
Int32 sign = 0;
FBXNode *p70 = m_node->child("Properties70");
if (p70) {
FBXNode *P = p70->searchPropertyNode("UpAxis");
if (P) {
a = P->interpretAsInt32();
}
P = p70->searchPropertyNode("UpAxisSign");
if (P) {
sign = P->interpretAsInt32();
}
if (a == 0) {
axis.set(sign ? 1 : -1, 0, 0);
} else if (a == 1) {
axis.set(0, sign ? 1 : -1, 0);
} else if (a == 2) {
axis.set(0, 0, sign ? 1 : -1);
}
}
return axis;
}
o3d::Vector3 GlobalSettingsProxy::frontAxis()
{
Vector3 axis;
Int32 a = 0;
Int32 sign = 0;
FBXNode *p70 = m_node->child("Properties70");
if (p70) {
FBXNode *P = p70->searchPropertyNode("FrontAxis");
if (P) {
a = P->interpretAsInt32();
}
P = p70->searchPropertyNode("FrontAxisSign");
if (P) {
sign = P->interpretAsInt32();
}
if (a == 0) {
axis.set(sign ? 1 : -1, 0, 0);
} else if (a == 1) {
axis.set(0, sign ? 1 : -1, 0);
} else if (a == 2) {
axis.set(0, 0, sign ? 1 : -1);
}
}
return axis;
}
o3d::Vector3 GlobalSettingsProxy::coordAxis()
{
Vector3 axis;
Int32 a = 0;
Int32 sign = 0;
FBXNode *p70 = m_node->child("Properties70");
if (p70) {
FBXNode *P = p70->searchPropertyNode("CoordAxis");
if (P) {
a = P->interpretAsInt32();
}
P = p70->searchPropertyNode("CoordAxisSign");
if (P) {
sign = P->interpretAsInt32();
}
if (a == 0) {
axis.set(sign ? 1 : -1, 0, 0);
} else if (a == 1) {
axis.set(0, sign ? 1 : -1, 0);
} else if (a == 2) {
axis.set(0, 0, sign ? 1 : -1);
}
}
return axis;
}
o3d::Double GlobalSettingsProxy::unitScale()
{
Double scale = 1.0;
FBXNode *p70 = m_node->child("Properties70");
if (p70) {
FBXNode *P = p70->searchPropertyNode("UnitScaleFactor");
if (P) {
scale = P->interpretAsDouble();
}
}
return scale;
}
o3d::Color GlobalSettingsProxy::ambientColor()
{
Color color;
FBXNode *p70 = m_node->child("Properties70");
if (p70) {
FBXNode *P = p70->searchPropertyNode("AmbientColor");
if (P) {
color = P->interpretAsColor();
}
}
return color;
}
o3d::Int64 GlobalSettingsProxy::timeSpanStart()
{
Int64 t = 0;
FBXNode *p70 = m_node->child("Properties70");
if (p70) {
FBXNode *P = p70->searchPropertyNode("TimeSpanStart");
if (P) {
t = P->interpretAsTime();
}
}
return t;
}
o3d::Int64 GlobalSettingsProxy::timeSpanEnd()
{
Int64 t = 0;
FBXNode *p70 = m_node->child("Properties70");
if (p70) {
FBXNode *P = p70->searchPropertyNode("TimeSpanStop");
if (P) {
t = P->interpretAsTime();
}
}
return t;
}
| [
"frederic.scherma@mailz.org"
] | frederic.scherma@mailz.org |
b5169d5d82c1f987491275a01db9ec4fb17d8310 | c82054a337e3df952e5d6702f9946234d42b071f | /missio/json/json.hpp | 16f41fe066d520fb0825a172f766b8d89e86adb5 | [
"LicenseRef-scancode-unknown-license-reference",
"BSL-1.0"
] | permissive | missio-cpp/missio | b89d28db380539cd240b5e532e20d04979e0494d | 74b7e2d5a0f6bbab0958a562ba286b3a50319eed | refs/heads/develop | 2020-12-03T10:42:17.748936 | 2018-07-19T20:08:07 | 2018-07-19T20:08:07 | 34,669,832 | 5 | 1 | null | 2016-03-26T21:32:13 | 2015-04-27T13:57:29 | C++ | UTF-8 | C++ | false | false | 591 | hpp | //---------------------------------------------------------------------------
//
// This file is part of Missio.JSON library
// Copyright (C) 2011, 2012, 2014 Ilya Golovenko
//
//---------------------------------------------------------------------------
#ifndef _missio_json_json_hpp
#define _missio_json_json_hpp
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
// Application headers
#include <missio/json/value.hpp>
#include <missio/json/binary.hpp>
#include <missio/json/json_io.hpp>
#endif // _missio_json_json_hpp
| [
"ilya@golovenko.com"
] | ilya@golovenko.com |
0454652edd40544885c89f784e635aeb96edbf3c | 560090526e32e009e2e9331e8a2b4f1e7861a5e8 | /Compiled/blaze-3.2/blazetest/src/mathtest/dmatdmatadd/LDbDDa.cpp | 9a5f2c45fdb5ddae1ca13f524a7fbd95d1445333 | [
"BSD-3-Clause"
] | permissive | jcd1994/MatlabTools | 9a4c1f8190b5ceda102201799cc6c483c0a7b6f7 | 2cc7eac920b8c066338b1a0ac495f0dbdb4c75c1 | refs/heads/master | 2021-01-18T03:05:19.351404 | 2018-02-14T02:17:07 | 2018-02-14T02:17:07 | 84,264,330 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,034 | cpp | //=================================================================================================
/*!
// \file src/mathtest/dmatdmatadd/LDbDDa.cpp
// \brief Source file for the LDbDDa dense matrix/dense matrix addition math test
//
// Copyright (C) 2012-2017 Klaus Iglberger - All Rights Reserved
//
// This file is part of the Blaze library. You can redistribute it and/or modify it under
// the terms of the New (Revised) BSD License. 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 names of the Blaze development group nor the names of its contributors
// may be used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
// SHALL THE COPYRIGHT HOLDER 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.
*/
//=================================================================================================
//*************************************************************************************************
// Includes
//*************************************************************************************************
#include <cstdlib>
#include <iostream>
#include <blaze/math/DiagonalMatrix.h>
#include <blaze/math/DynamicMatrix.h>
#include <blaze/math/LowerMatrix.h>
#include <blazetest/mathtest/Creator.h>
#include <blazetest/mathtest/dmatdmatadd/OperationTest.h>
#include <blazetest/system/MathTest.h>
//=================================================================================================
//
// MAIN FUNCTION
//
//=================================================================================================
//*************************************************************************************************
int main()
{
std::cout << " Running 'LDbDDa'..." << std::endl;
using blazetest::mathtest::TypeA;
using blazetest::mathtest::TypeB;
try
{
// Matrix type definitions
typedef blaze::LowerMatrix< blaze::DynamicMatrix<TypeB> > LDb;
typedef blaze::DiagonalMatrix< blaze::DynamicMatrix<TypeA> > DDa;
// Creator type definitions
typedef blazetest::Creator<LDb> CLDb;
typedef blazetest::Creator<DDa> CDDa;
// Running tests with small matrices
for( size_t i=0UL; i<=9UL; ++i ) {
RUN_DMATDMATADD_OPERATION_TEST( CLDb( i ), CDDa( i ) );
}
// Running tests with large matrices
RUN_DMATDMATADD_OPERATION_TEST( CLDb( 67UL ), CDDa( 67UL ) );
RUN_DMATDMATADD_OPERATION_TEST( CLDb( 128UL ), CDDa( 128UL ) );
}
catch( std::exception& ex ) {
std::cerr << "\n\n ERROR DETECTED during dense matrix/dense matrix addition:\n"
<< ex.what() << "\n";
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
//*************************************************************************************************
| [
"jonathan.doucette@alumni.ubc.ca"
] | jonathan.doucette@alumni.ubc.ca |
da9d6565dc009f6d47e56779704c747f532fd5f7 | 10571cc8e30797b2bdad94817580e420b4a89742 | /f9twf/ExgMkt_UT.cpp | 4853322806ab1326213b583e644ec6ba331fa33b | [
"Apache-2.0"
] | permissive | fonwin/libfon9 | 3651cab44470ca353dd779280f0a1e550001af9b | ff682e272798a9a65d4b18852eb6522a715f48f2 | refs/heads/master | 2023-08-28T06:54:05.250118 | 2023-07-25T02:36:46 | 2023-07-25T02:36:46 | 115,598,127 | 30 | 12 | Apache-2.0 | 2023-02-24T07:08:05 | 2017-12-28T07:36:02 | C++ | UTF-8 | C++ | false | false | 22,333 | cpp | // \file f9twf/ExgMkt_UT.cpp
//
// 測試 台灣期交所 行情格式解析.
//
// \author fonwinz@gmail.com
#define _CRT_SECURE_NO_WARNINGS
#include "f9twf/ExgMdPkReceiver.hpp"
#include "f9twf/ExgMdFmtMatch.hpp"
#include "f9twf/ExgMdFmtBS.hpp"
#include "f9twf/ExgMdFmtHL.hpp"
#include "f9twf/ExgMcFmtSS.hpp"
#include "f9twf/ExgMdSymbs.hpp"
#include "f9extests/ExgMktTester.hpp"
//--------------------------------------------------------------------------//
/// = sizeof(f9twf::ExgMiHead); or sizeof(f9twf::ExgMcHead);
unsigned gPkHeadSize = 0;
struct TwfPkReceiver : public fon9::PkReceiver {
fon9_NON_COPY_NON_MOVE(TwfPkReceiver);
using base = fon9::PkReceiver;
using base::ReceivedCount_;
using base::ChkSumErrCount_;
using base::DroppedBytes_;
uint32_t FmtCount_[0x100][0x100];
uint32_t LastSeq_[0x100][0x100];
uint32_t SeqMisCount_[0x100][0x100];
TwfPkReceiver() : base{gPkHeadSize} {
this->ClearStatus();
}
unsigned GetPkSize(const void* pkptr) override {
return this->PkHeadSize_ == sizeof(f9twf::ExgMiHead)
? f9twf::GetPkSize_ExgMi(*reinterpret_cast<const f9twf::ExgMiHead*>(pkptr))
: f9twf::GetPkSize_ExgMc(*reinterpret_cast<const f9twf::ExgMcHead*>(pkptr));
}
void ClearStatus() {
base::ClearStatus();
memset(this->FmtCount_, 0, sizeof(this->FmtCount_));
memset(this->LastSeq_, 0, sizeof(this->LastSeq_));
memset(this->SeqMisCount_, 0, sizeof(this->SeqMisCount_));
}
bool OnPkReceived(const void* pkptr, unsigned pksz) override {
(void)pksz;
const f9twf::ExgMdHead0& pk = *reinterpret_cast<const f9twf::ExgMdHead0*>(pkptr);
unsigned char txCode = fon9::unsigned_cast(pk.TransmissionCode_);
unsigned char mgKind = fon9::unsigned_cast(pk.MessageKind_);
++this->FmtCount_[txCode][mgKind];
uint32_t seqNo;
if (this->PkHeadSize_ == sizeof(f9twf::ExgMiHead))
seqNo = fon9::PackBcdTo<uint32_t>(reinterpret_cast<const f9twf::ExgMiHead*>(pkptr)->InformationSeq_);
else {
bool isHb = (txCode == '0' && mgKind == '1'); // Hb: CHANNEL-SEQ 欄位會為該傳輸群組之末筆序號訊息。
uint32_t chid = fon9::PackBcdTo<uint32_t>(reinterpret_cast<const f9twf::ExgMcHead*>(pkptr)->ChannelId_);
txCode = static_cast<unsigned char>(chid >> 8);
mgKind = static_cast<unsigned char>(chid & 0xff);
seqNo = static_cast<uint32_t>(
fon9::PackBcdTo<uint64_t>(reinterpret_cast<const f9twf::ExgMcHead*>(pkptr)->ChannelSeq_));
if (isHb)
--this->LastSeq_[txCode][mgKind];
}
if (seqNo != this->LastSeq_[txCode][mgKind] + 1)
++this->SeqMisCount_[txCode][mgKind];
this->LastSeq_[txCode][mgKind] = seqNo;
return true;
}
};
//--------------------------------------------------------------------------//
/// 買賣報價 & 成交明細.
struct RtParser : public TwfPkReceiver, public fon9::fmkt::MdSymbTree {
fon9_NON_COPY_NON_MOVE(RtParser);
using basePkReceiver = TwfPkReceiver;
using baseTree = fon9::fmkt::MdSymbTree;
using MiParserMap = f9twf::ExgMdParserMap<f9twf::ExgMiHead, RtParser>;
using McParserMap = f9twf::ExgMdParserMap<f9twf::ExgMcHead, RtParser>;
MiParserMap MiParserMap_;
McParserMap McParserMap_;
size_t ParsedCount_{};
size_t TotalQtyLostCount_{};
size_t UnknownValue_{};
RtParser() : baseTree{fon9::seed::LayoutSP{}} {
// 逐筆: 成交價量:I024;
this->McParserMap_.Reg<'2', 'D', 1>(&McI024MatchParser);
this->McParserMap_.Reg<'5', 'D', 1>(&McI024MatchParser);
// 一般: 成交價量:I020; 試撮成交價量:I022;
this->MiParserMap_.Reg<'2', '1', 4>(&MiI020MatchParser);
this->MiParserMap_.Reg<'5', '1', 4>(&MiI020MatchParser);
this->MiParserMap_.Reg<'2', '7', 2>(&MiI022MatchParser);
this->MiParserMap_.Reg<'5', '7', 2>(&MiI022MatchParser);
// 逐筆: 委託簿揭示訊息:I081; 委託簿快照訊息:I083;
this->McParserMap_.Reg<'2', 'A', 1>(&McI081BSParser);
this->McParserMap_.Reg<'5', 'A', 1>(&McI081BSParser);
this->McParserMap_.Reg<'2', 'B', 1>(&McI083BSParser);
this->McParserMap_.Reg<'5', 'B', 1>(&McI083BSParser);
// 一般: 委託簿揭示訊息:I080; 試撮後剩餘委託簿揭示訊息:I082;
this->MiParserMap_.Reg<'2', '2', 2>(&MiI080BSParser);
this->MiParserMap_.Reg<'5', '2', 2>(&MiI080BSParser);
this->MiParserMap_.Reg<'2', '8', 1>(&MiI082BSParser);
this->MiParserMap_.Reg<'5', '8', 1>(&MiI082BSParser);
// 最高價、最低價.
this->McParserMap_.Reg<'2', 'E', 1>(&McI025HLParser);
this->McParserMap_.Reg<'5', 'E', 1>(&McI025HLParser);
this->MiParserMap_.Reg<'2', '5', 3>(&MiI021HLParser);
this->MiParserMap_.Reg<'5', '5', 3>(&MiI021HLParser);
// 快照.
this->McParserMap_.Reg<'2', 'C', 1>(&McI084SSParser);
this->McParserMap_.Reg<'5', 'C', 1>(&McI084SSParser);
}
fon9::fmkt::SymbSP MakeSymb(const fon9::StrView& symbid) override {
return new f9extests::SymbIn{symbid};
}
size_t GetParsedCount() const {
return this->ParsedCount_;
}
void PrintInfo() {
if (this->TotalQtyLostCount_ > 0)
std::cout << "TotalQty lost count=" << this->TotalQtyLostCount_ << std::endl;
if (this->UnknownValue_ > 0)
std::cout << "Unknown value count=" << this->UnknownValue_ << std::endl;
}
bool OnPkReceived(const void* pkptr, unsigned pksz) override {
basePkReceiver::OnPkReceived(pkptr, pksz);
if (this->PkHeadSize_ == sizeof(f9twf::ExgMiHead))
this->ParsedCount_ += this->MiParserMap_.Call(*reinterpret_cast<const f9twf::ExgMiHead*>(pkptr), pksz, *this);
else
this->ParsedCount_ += this->McParserMap_.Call(*reinterpret_cast<const f9twf::ExgMcHead*>(pkptr), pksz, *this);
return true;
}
//-----------------------------------------------------------------------//
static void McI024MatchParser(const f9twf::ExgMcHead& pk, unsigned pksz, RtParser& dst) {
if (AssignMatch(dst, *static_cast<const f9twf::ExgMcI024*>(&pk),
static_cast<const f9twf::ExgMcI024*>(&pk)->CalculatedFlag_ == '1')
!= pksz - sizeof(f9twf::ExgMdTail))
fon9_CheckTestResult("McI024MatchParser.pksz", false);
}
static void MiI020MatchParser(const f9twf::ExgMiHead& pk, unsigned pksz, RtParser& dst) {
if (AssignMatch(dst, *static_cast<const f9twf::ExgMiI020*>(&pk), false)
!= pksz - sizeof(f9twf::ExgMdMatchStatusCode) - sizeof(f9twf::ExgMdTail))
fon9_CheckTestResult("MiI020MatchParser.pksz", false);
}
static void MiI022MatchParser(const f9twf::ExgMiHead& pk, unsigned pksz, RtParser& dst) {
if(AssignMatch(dst, *static_cast<const f9twf::ExgMiI022*>(&pk), true)
!= pksz - sizeof(f9twf::ExgMdMatchStatusCode) - sizeof(f9twf::ExgMdTail))
fon9_CheckTestResult("MiI022MatchParser.pksz", false);
}
// isCalc = true = 試撮價格訊息.
template <class Pk>
static uintptr_t AssignMatch(RtParser& dst, const Pk& pk, bool isCalc) {
return AssignMatch(dst, fon9::StrView_eos_or_all(pk.ProdId_.Chars_, ' '), pk, pk, isCalc)
- reinterpret_cast<uintptr_t>(&pk);
}
static uintptr_t AssignMatch(RtParser& dst, const fon9::StrView& symbid,
const f9twf::ExgMdMatchHead& mat, const f9twf::ExgMdHead0& hdr,
bool isCalc) {
SymbMap::Locker symbs{dst.SymbMap_};
f9extests::SymbIn& symb = *static_cast<f9extests::SymbIn*>(dst.FetchSymb(symbs, symbid).get());
symb.Deal_.Data_.InfoTime_ = hdr.InformationTime_.ToDayTime();
symb.Deal_.Data_.DealTime_ = mat.MatchTime_.ToDayTime();
mat.FirstMatchPrice_.AssignTo(symb.Deal_.Data_.Deal_.Pri_, symb.PriceOrigDiv_);
symb.Deal_.Data_.Deal_.Qty_ = fon9::PackBcdTo<uint32_t>(mat.FirstMatchQty_);
const f9twf::ExgMdMatchData* pdat = mat.MatchData_;
auto checkTotalQty = symb.Deal_.Data_.TotalQty_ + symb.Deal_.Data_.Deal_.Qty_;
if (auto count = (mat.MatchDisplayItem_ & 0x7f)) {
do {
pdat->MatchPrice_.AssignTo(symb.Deal_.Data_.Deal_.Pri_, symb.PriceOrigDiv_);
symb.Deal_.Data_.Deal_.Qty_ = fon9::PackBcdTo<uint32_t>(pdat->MatchQty_);
checkTotalQty += symb.Deal_.Data_.Deal_.Qty_;
++pdat;
} while (--count > 0);
}
const f9twf::ExgMdMatchCnt* pcnt = reinterpret_cast<const f9twf::ExgMdMatchCnt*>(pdat);
symb.Deal_.Data_.TotalQty_ = fon9::PackBcdTo<uint32_t>(pcnt->MatchTotalQty_);
if (!isCalc && symb.Deal_.Data_.TotalQty_ != checkTotalQty)
++dst.TotalQtyLostCount_;
return reinterpret_cast<uintptr_t>(pcnt + 1);
}
//-----------------------------------------------------------------------//
static void MiI080BSParser(const f9twf::ExgMiHead& pk, unsigned pksz, RtParser& dst) {
MiBSParser(*static_cast<const f9twf::ExgMiI080*>(&pk), pksz, dst);
}
static void MiI082BSParser(const f9twf::ExgMiHead& pk, unsigned pksz, RtParser& dst) {
MiBSParser(*static_cast<const f9twf::ExgMiI082*>(&pk), pksz, dst);
}
static void MiBSParser(const f9twf::ExgMiI080& pk, unsigned pksz, RtParser& dst) {
fon9::StrView symbid = fon9::StrView_eos_or_all(pk.ProdId_.Chars_, ' ');
SymbMap::Locker symbs{dst.SymbMap_};
f9extests::SymbIn& symb = *static_cast<f9extests::SymbIn*>(dst.FetchSymb(symbs, symbid).get());
static_assert(fon9::fmkt::SymbBSData::kBSCount == sizeof(pk.BuyOrderBook_)/sizeof(pk.BuyOrderBook_[0]),
"fon9::fmkt::SymbBS::kBSCount must equal to numofele(pk.BuyOrderBook_)");
AssignBS(symb.BS_.Data_.Buys_, pk.BuyOrderBook_, symb.PriceOrigDiv_);
AssignBS(symb.BS_.Data_.Sells_, pk.SellOrderBook_, symb.PriceOrigDiv_);
// pk.DerivedFlag_: 有無衍生委託單之旗標: 01:解析 FirstDerived_; 00:不帶 FirstDerived_.
if (fon9::PackBcdTo<uint8_t>(pk.DerivedFlag_) == 0) {
if (pksz != sizeof(pk) + sizeof(f9twf::ExgMdTail) - sizeof(pk.FirstDerived_))
fon9_CheckTestResult("MiBSParser.pksz", false);
}
else {
if (pksz != sizeof(pk) + sizeof(f9twf::ExgMdTail))
fon9_CheckTestResult("MiBSParser+Derived.pksz", false);
f9twf::ExgMdPriceTo(symb.BS_.Data_.DerivedBuy_.Pri_, pk.FirstDerived_.BuyPrice_, symb.PriceOrigDiv_);
f9twf::ExgMdPriceTo(symb.BS_.Data_.DerivedSell_.Pri_, pk.FirstDerived_.SellPrice_, symb.PriceOrigDiv_);
symb.BS_.Data_.DerivedBuy_.Qty_ = fon9::PackBcdTo<uint32_t>(pk.FirstDerived_.BuyQty_);
symb.BS_.Data_.DerivedSell_.Qty_ = fon9::PackBcdTo<uint32_t>(pk.FirstDerived_.SellQty_);
}
}
static void AssignBS(fon9::fmkt::PriQty* dst, const f9twf::ExgMdOrderPQ* pqs, uint32_t origDiv) {
for (unsigned L = 0; L < fon9::fmkt::SymbBSData::kBSCount; ++L) {
pqs->Price_.AssignTo(dst->Pri_, origDiv);
dst->Qty_ = fon9::PackBcdTo<uint32_t>(pqs->Qty_);
++pqs;
++dst;
}
}
//-----------------------------------------------------------------------//
static void McI081BSParser(const f9twf::ExgMcHead& pk, unsigned pksz, RtParser& rthis) {
fon9::StrView symbid = fon9::StrView_eos_or_all(static_cast<const f9twf::ExgMcI081*>(&pk)->ProdId_.Chars_, ' ');
SymbMap::Locker symbs{rthis.SymbMap_};
f9extests::SymbIn& symb = *static_cast<f9extests::SymbIn*>(rthis.FetchSymb(symbs, symbid).get());
unsigned mdCount = fon9::PackBcdTo<unsigned>(static_cast<const f9twf::ExgMcI081*>(&pk)->NoMdEntries_);
auto* mdEntry = static_cast<const f9twf::ExgMcI081*>(&pk)->MdEntry_;
f9twf::ExgMdToUpdateBS(pk.InformationTime_.ToDayTime(), mdCount, mdEntry, symb,
fon9::fmkt::PackBcdToMarketSeq(static_cast<const f9twf::ExgMcI081*>(&pk)->ProdMsgSeq_));
if (reinterpret_cast<uintptr_t>(mdEntry + mdCount) - reinterpret_cast<uintptr_t>(&pk)
!= pksz - sizeof(f9twf::ExgMdTail))
fon9_CheckTestResult("McI081BSParser.pksz", false);
}
static void McI083BSParser(const f9twf::ExgMcHead& pk, unsigned pksz, RtParser& rthis) {
fon9::StrView symbid = fon9::StrView_eos_or_all(static_cast<const f9twf::ExgMcI083*>(&pk)->ProdId_.Chars_, ' ');
SymbMap::Locker symbs{rthis.SymbMap_};
f9extests::SymbIn& symb = *static_cast<f9extests::SymbIn*>(rthis.FetchSymb(symbs, symbid).get());
symb.BS_.Data_.Clear();
const void* entryEnd = f9twf::ExgMdToSnapshotBS(pk.InformationTime_.ToDayTime(),
fon9::PackBcdTo<unsigned>(static_cast<const f9twf::ExgMcI083*>(&pk)->NoMdEntries_),
static_cast<const f9twf::ExgMcI083*>(&pk)->MdEntry_,
symb,
fon9::fmkt::PackBcdToMarketSeq(static_cast<const f9twf::ExgMcI083*>(&pk)->ProdMsgSeq_));
if (reinterpret_cast<uintptr_t>(entryEnd) - reinterpret_cast<uintptr_t>(&pk)
!= pksz - sizeof(f9twf::ExgMdTail))
fon9_CheckTestResult("McI083BSParser.pksz", false);
}
//-----------------------------------------------------------------------//
static void McI025HLParser(const f9twf::ExgMcHead& pk, unsigned pksz, RtParser& rthis) {
AssignHL(rthis, *static_cast<const f9twf::ExgMcI025*>(&pk), pksz);
}
static void MiI021HLParser(const f9twf::ExgMiHead& pk, unsigned pksz, RtParser& rthis) {
AssignHL(rthis, *static_cast<const f9twf::ExgMiI021*>(&pk), pksz);
}
template <class Pk>
static void AssignHL(RtParser& rthis, const Pk& pk, unsigned pksz) {
if (pksz != sizeof(pk))
fon9_CheckTestResult("AssignHL.pksz", false);
AssignHL(rthis, pk);
}
static void AssignHL(RtParser& rthis, const f9twf::ExgMdDayHighLow& pk) {
(void)rthis; (void)pk;
}
//-----------------------------------------------------------------------//
static void McI084SSParser(const f9twf::ExgMcHead& pk, unsigned pksz, RtParser& rthis) {
switch (static_cast<const f9twf::ExgMcI084*>(&pk)->MessageType_) {
case 'A':
McI084SSParserA(static_cast<const f9twf::ExgMcI084*>(&pk)->_A_RefreshBegin_, pksz, rthis);
break;
case 'O':
McI084SSParserO(static_cast<const f9twf::ExgMcI084*>(&pk)->_O_OrderData_, pksz, rthis);
break;
case 'S':
McI084SSParserS(static_cast<const f9twf::ExgMcI084*>(&pk)->_S_ProductStatistics_, pksz, rthis);
break;
case 'P':
McI084SSParserP(static_cast<const f9twf::ExgMcI084*>(&pk)->_P_ProductStatus_, pksz, rthis);
break;
case 'Z':
McI084SSParserZ(static_cast<const f9twf::ExgMcI084*>(&pk)->_Z_RefreshComplete_, pksz, rthis);
break;
default:
++rthis.UnknownValue_;
break;
}
}
static void McI084SSParserA(const f9twf::ExgMcI084::RefreshBegin& pk, unsigned pksz, RtParser& rthis) {
(void)pk; (void)rthis;
if (pksz != sizeof(pk) + sizeof(const f9twf::ExgMcNoBody) + 1/*MessageType*/)
fon9_CheckTestResult("McI084SSParserA.pksz", false);
}
static void McI084SSParserO(const f9twf::ExgMcI084::OrderData& pk, unsigned pksz, RtParser& rthis) {
(void)rthis;
unsigned prodCount = fon9::PackBcdTo<unsigned>(pk.NoEntries_);
const f9twf::ExgMcI084::OrderDataEntry* prod = pk.Entry_;
for (unsigned L = 0; L < prodCount; ++L) {
unsigned mdCount = fon9::PackBcdTo<unsigned>(prod->NoMdEntries_);
// 處理 prod & md
prod = reinterpret_cast<const f9twf::ExgMcI084::OrderDataEntry*>(prod->MdEntry_ + mdCount);
}
if (pksz != (sizeof(const f9twf::ExgMcNoBody) + 1/*MessageType*/
+ (reinterpret_cast<uintptr_t>(prod) - reinterpret_cast<uintptr_t>(&pk))))
fon9_CheckTestResult("McI084SSParserO.pksz", false);
}
static void McI084SSParserS(const f9twf::ExgMcI084::ProductStatistics& pk, unsigned pksz, RtParser& rthis) {
(void)pk; (void)rthis;
if (pksz != (sizeof(pk) + sizeof(const f9twf::ExgMcNoBody) + 1/*MessageType*/
+ sizeof(*pk.Entry_) * (fon9::PackBcdTo<unsigned>(pk.NoEntries_) - 1)))
fon9_CheckTestResult("McI084SSParserS.pksz", false);
}
static void McI084SSParserP(const f9twf::ExgMcI084::ProductStatus& pk, unsigned pksz, RtParser& rthis) {
(void)pk; (void)rthis;
if (pksz != (sizeof(pk) + sizeof(const f9twf::ExgMcNoBody) + 1/*MessageType*/
+ sizeof(*pk.Entry_) * (fon9::PackBcdTo<unsigned>(pk.NoEntries_) - 1)))
fon9_CheckTestResult("McI084SSParserP.pksz", false);
}
static void McI084SSParserZ(const f9twf::ExgMcI084::RefreshComplete& pk, unsigned pksz, RtParser& rthis) {
(void)pk; (void)rthis;
if (pksz != sizeof(pk) + sizeof(const f9twf::ExgMcNoBody) + 1/*MessageType*/)
fon9_CheckTestResult("McI084SSParserZ.pksz", false);
}
};
int main(int argc, char* argv[]) {
fon9::AutoPrintTestInfo utinfo{"f9twf ExgMkt"};
if (argc < 4) {
std::cout << "Usage: MarketDataFile ReadFrom ReadSize [Steps or ?SymbId]\n"
"ReadSize=0 for read to EOF.\n"
"Steps=0 for test Rt(Match & BS) parsing.\n"
<< std::endl;
return 3;
}
f9extests::MktDataFile mdf{argv};
if (!mdf.Buffer_)
return 3;
// 檢查格式.
if (const char* pEsc = reinterpret_cast<const char*>(memchr(mdf.Buffer_, 27, mdf.Size_))) {
const char* pEnd = mdf.Buffer_ + mdf.Size_;
unsigned pksz = f9twf::GetPkSize_ExgMi(*reinterpret_cast<const f9twf::ExgMiHead*>(pEsc));
if (pEsc + pksz <= pEnd && pEsc[pksz - 2] == '\x0d' && pEsc[pksz - 1] == '\x0a') {
gPkHeadSize = sizeof(f9twf::ExgMiHead);
std::cout << "fmt=Information" << std::endl;
}
else {
pksz = f9twf::GetPkSize_ExgMc(*reinterpret_cast<const f9twf::ExgMcHead*>(pEsc));
if (pEsc + pksz <= pEnd && pEsc[pksz - 2] == '\x0d' && pEsc[pksz - 1] == '\x0a') {
gPkHeadSize = sizeof(f9twf::ExgMcHead);
std::cout << "fmt=Channel:"
<< fon9::PackBcdTo<unsigned>(reinterpret_cast<const f9twf::ExgMcHead*>(pEsc)->ChannelId_)
<< std::endl;
}
}
}
if (gPkHeadSize == 0) {
std::cout << "err=Unknown format." << mdf.Size_ << std::endl;
return 3;
}
// [TRANSMISSION-CODE][MESSAGE-KIND]
static const char* fmtName[0x100][0x100];
fmtName['0']['0'] = "I000(Hb)";
fmtName['0']['1'] = "I001(Hb)";
fmtName['0']['2'] = "I002(Rst)";
// --- Fut
fmtName['1']['1'] = "Fut.I010"; fmtName['2']['1'] = "Fut.I020"; fmtName['3']['1'] = "Fut.I070"; fmtName['7']['1'] = "Fut.B020";
fmtName['1']['2'] = "Fut.I030"; fmtName['2']['2'] = "Fut.I080"; fmtName['3']['2'] = "Fut.I071"; fmtName['7']['2'] = "Fut.B080";
fmtName['1']['3'] = "Fut.I011"; fmtName['2']['3'] = "Fut.I140"; fmtName['3']['3'] = "Fut.I072"; fmtName['7']['3'] = "Fut.B021";
fmtName['1']['4'] = "Fut.I050"; fmtName['2']['4'] = "Fut.I100"; fmtName['3']['4'] = "Fut.I073";
fmtName['1']['5'] = "Fut.I060"; fmtName['2']['5'] = "Fut.I021";
fmtName['1']['6'] = "Fut.I120"; fmtName['2']['6'] = "Fut.I023";
fmtName['1']['7'] = "Fut.I130"; fmtName['2']['7'] = "Fut.I022";
fmtName['1']['8'] = "Fut.I064"; fmtName['2']['8'] = "Fut.I082";
fmtName['1']['9'] = "Fut.I065"; fmtName['2']['9'] = "Fut.I090";
fmtName['2']['A'] = "Fut.I081";
fmtName['2']['B'] = "Fut.I083";
fmtName['2']['C'] = "Fut.I084";
fmtName['2']['D'] = "Fut.I024";
fmtName['2']['E'] = "Fut.I025";
// --- Opt
fmtName['4']['1'] = "Opt.I010"; fmtName['5']['1'] = "Opt.I020"; fmtName['6']['1'] = "Opt.I070";
fmtName['4']['2'] = "Opt.I030"; fmtName['5']['2'] = "Opt.I080"; fmtName['6']['2'] = "Opt.I071";
fmtName['4']['3'] = "Opt.I011"; fmtName['5']['3'] = "Opt.I140"; fmtName['6']['3'] = "Opt.I072";
fmtName['4']['4'] = "Opt.I050"; fmtName['5']['4'] = "Opt.I100";
fmtName['4']['5'] = "Opt.I060"; fmtName['5']['5'] = "Fut.I021";
fmtName['4']['6'] = "Opt.I120"; fmtName['5']['6'] = "Fut.I023";
fmtName['4']['7'] = "Opt.I130"; fmtName['5']['7'] = "Fut.I022";
fmtName['4']['8'] = "Opt.I064"; fmtName['5']['8'] = "Fut.I082";
fmtName['5']['9'] = "Fut.I090";
fmtName['5']['A'] = "Opt.I081";
fmtName['5']['B'] = "Opt.I083";
fmtName['5']['C'] = "Opt.I084";
fmtName['5']['D'] = "Opt.I024";
fmtName['5']['E'] = "Opt.I025";
// ---
TwfPkReceiver pkReceiver;
double tmFull = f9extests::ExgMktFeedAll(mdf, pkReceiver);
for (unsigned txL = 0; txL < 0x100; ++txL) {
for (unsigned mgL = 0; mgL < 0x100; ++mgL) {
if (pkReceiver.FmtCount_[txL][mgL]) {
std::cout << "Fmt=" << static_cast<char>(txL) << static_cast<char>(mgL)
<< ":" << (fmtName[txL][mgL] ? fmtName[txL][mgL] : "?")
<< "|Count=" << pkReceiver.FmtCount_[txL][mgL];
if (gPkHeadSize == sizeof(f9twf::ExgMiHead)) {
std::cout << "|LastSeq=" << pkReceiver.LastSeq_[txL][mgL]
<< "|MisCount=" << pkReceiver.SeqMisCount_[txL][mgL];
}
std::cout << std::endl;
}
}
}
if (gPkHeadSize == sizeof(f9twf::ExgMcHead)) {
for (unsigned txL = 0; txL < 0x100; ++txL) {
for (unsigned mgL = 0; mgL < 0x100; ++mgL) {
if (pkReceiver.LastSeq_[txL][mgL] || pkReceiver.SeqMisCount_[txL][mgL]) {
std::cout << "Channel=" << ((txL << 8) + mgL)
<< "|LastSeq=" << pkReceiver.LastSeq_[txL][mgL]
<< "|MisCount=" << pkReceiver.SeqMisCount_[txL][mgL]
<< std::endl;
}
}
}
}
if (argc >= 5) {
if (f9extests::CheckExgMktFeederStep(pkReceiver, mdf, argv[4]) == 0)
f9extests::ExgMktTestParser<RtParser>("Parse Match+BS", mdf, argc - 4, argv + 4, tmFull,
fon9::FmtDef{7,8});
}
}
| [
"fonwinz@gmail.com"
] | fonwinz@gmail.com |
309c2054662a5491d817838f4419d522b76173d3 | 08cd9b06ec88022c5058067c17659960e80a553d | /洛谷/P3355(网络流加速二分图匹配)骑士共存问题.cpp | 0e25761c24a89478f88ae2ebba4c226bf9e6a8d5 | [] | no_license | tmzengbi/save-code | fe6641b18f488b01241b6112d56249ca00b541b6 | fe50f15beca52f3cb47398ac6f116fefbf31fc85 | refs/heads/master | 2023-08-25T15:17:57.278833 | 2021-09-18T09:50:39 | 2021-09-18T09:50:39 | 298,801,679 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,244 | cpp | #include <bits/stdc++.h>
using namespace std;
const int maxn=2e2+10;
typedef long long ll;
int n,m;
int mp[maxn][maxn],r[maxn][maxn];
int cnt;
const int fx[8]={-2,-2,-1,-1,1,1,2,2},fy[8]={1,-1,2,-2,2,-2,1,-1};
bool check(int x,int y){
return x<=n&&y<=n&&x>=1&&y>=1;
}
class Max_flow{
typedef long long ll;
const static int maxn=4e4+10;
private:
struct Flow{
int u,v,cap,now;
Flow(int u,int v,int cap,int now):
u(u),v(v),cap(cap),now(now){}
};
const int inf=0x7fffffff;
vector<Flow>G;
vector<int>edges[maxn];
int from,to,dep[maxn],cur[maxn];
queue<int>q;
bool bfs(){
memset(dep,0,sizeof dep);
q.push(from);
dep[from]=1;
while(!q.empty()){
auto u=q.front();q.pop();
for(int v:edges[u]){
auto &e=G[v];
if(!dep[e.v]&&e.cap-e.now>0){
dep[e.v]=dep[u]+1;
q.push(e.v);
}
}
}
return dep[to];
}
int dfs(int u,int a){
ll sum=0;
if(u==to||a==0) return a;
for(int &i=cur[u];i<edges[u].size();++i){
auto &e=G[edges[u][i]];
int f;
if(dep[e.v]==dep[u]+1&&(f=dfs(e.v,min(a,e.cap-e.now)))>0){
auto &re=G[edges[u][i]^1];
e.now+=f;re.now-=f;
a-=f;sum+=f;
if(a==0) break;
}
}
return sum;
}
public:
void set(int from,int to){
this->from=from;
this->to=to;
}
void addedge(int u,int v,int f){
G.push_back(Flow(u,v,f,0));
edges[u].push_back(G.size()-1);
G.push_back(Flow(v,u,f,f));
edges[v].push_back(G.size()-1);
}
ll dinic(){
ll sum=0;
while(bfs()){
memset(cur,0,sizeof cur);
sum+=dfs(from,inf);
}
return sum;
}
}flow;
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=m;++i){
int a,b;
scanf("%d%d",&a,&b);
mp[a][b]=1;
}
for(int i=1;i<=n;++i)
for(int j=1;j<=n;++j){
if(mp[i][j]) continue;
r[i][j]=++cnt;
}
flow.set(0,cnt+1);
const int inf=0x3f3f3f3f;
for(int i=1;i<=n;++i)
for(int j=1;j<=n;++j) {
if(!r[i][j]) continue;
if((i+j)&1) {
flow.addedge(0,r[i][j],1);
for(int k=0;k<8;++k){
int x=i+fx[k],y=j+fy[k];
if(!check(x,y)||!r[x][y]) continue;
flow.addedge(r[i][j],r[x][y],1);
}
} else {
flow.addedge(r[i][j],cnt+1,1);
}
}
ll res=flow.dinic();
printf("%lld\n",cnt-res);
} | [
"2818097988@qq.com"
] | 2818097988@qq.com |
e51a68c7161104390f31da98ba9bf10a00a14f0c | d36e60bb9f0f2ac759756369b31e44bb1be2e039 | /abc/145/b.cpp | 02c39a787c08a43f4ef70ee616a7af0931907f22 | [] | no_license | Kaniikura/atcoder-cpp | e578c264ef7ac9a2cf30ee58f45d280e47db33e1 | e34035c4241e449e6b3bcd28a5601408ac783936 | refs/heads/master | 2021-08-08T15:32:38.657776 | 2020-07-12T03:29:17 | 2020-07-12T03:29:17 | 200,956,321 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 323 | cpp | #include <iostream>
#include <string>
using namespace std;
int n;
string s;
void solve()
{
string ans = "No";
if (n % 2 == 0)
{
if (s.substr(0, n / 2) == s.substr(n / 2, n / 2))
ans = "Yes";
}
cout << ans;
}
int main()
{
cin >> n >> s;
solve();
} | [
"constantl492@gmail.com"
] | constantl492@gmail.com |
db0fc817a302e8f5d37451bb40d62d2a2280343a | b315cf03955013b0fd6514d61218d466f40f7a8c | /W6/yp2201_hw6_q1.cpp | 8537e468e9aeb09b1b0b3e1fc892a8a256c1fd28 | [] | no_license | yoontaepark/C-plus-plus | 072257bd152f96c84e888e73d9318b7e4644a5d1 | 770b926ae57e00a3a9ff2a69792703c44341d837 | refs/heads/main | 2023-04-07T07:23:38.683884 | 2021-04-11T13:03:18 | 2021-04-11T13:03:18 | 331,621,377 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 922 | cpp | #include <iostream>
using namespace std;
const int MAX_SIZE = 20;
int minInArray(int arr[], int arrSize);
void locInArray(int arr[]);
int main()
{
int arr[MAX_SIZE];
int input_num;
cout << "Please enter 20 integers separated by a space:" << endl;
for (int i = 0; i <= 19; i++)
{
cin >> input_num;
arr[i] = input_num;
}
cout << "The minimum value is " << minInArray(arr, 20) << ", and it is located in the following indices: ";
locInArray(arr);
cout <<endl;
return 0;
}
int minInArray(int arr[], int arrSize)
{
int min;
min = arr[0];
for (int i = 0; i <= 19; i++)
{
if (arr[i] < min)
min = arr[i];
}
return min;
}
void locInArray(int arr[])
{
int min;
min = arr[0];
for (int i = 0; i <= 19; i++)
{
if (arr[i] < min)
min = arr[i];
}
for (int i = 0; i <= 19; i++)
{
if (arr[i] == min)
cout << i << " ";
}
}
| [
"noreply@github.com"
] | noreply@github.com |
89a231a3db5ebb8fd6f0664a59589a1d6200f93a | 7c5450c2aad0166797582f8ae8528a8a3e1ad057 | /nicecock-master/base/features/Resolver.hpp | 89967f6a0bd69f7f7f9ca17374222087848cb5fe | [] | no_license | NOEASYv2/rejecta | 9a6fb2cfb9a6a24f79b97a88243ab34e36fdbd78 | f4f9cb7e9645db8fa38689d89d41277493d4a00c | refs/heads/master | 2020-03-12T15:12:33.403778 | 2018-04-23T11:16:29 | 2018-04-23T11:16:29 | 130,685,106 | 4 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 613 | hpp | #pragma once
#include "../Singleton.hpp"
#include "../Structs.hpp"
#include "../helpers/Math.hpp"
#include <deque>
class QAngle;
class C_BasePlayer;
class Resolver;
struct STickRecord;
struct CValidTick {
//antipaste
};
struct STickRecord
{
//antipaste
};
inline CValidTick::operator STickRecord() const {
//antipaste
}
struct Values
{
//antipaste
};
struct SResolveInfo
{
//antipaste
};
enum BruteforceStep : unsigned int {
//antipaste
};
struct Bruteforce
{
//antipaste
};
class Resolver : public Singleton<Resolver>
{
//antipaste
};
//antipaste
//antipaste
//antipaste
//antipaste
| [
"kontonowe20@onet.pl"
] | kontonowe20@onet.pl |
73f4774a124ae051984d28345fb865744ff0df40 | b20353e26e471ed53a391ee02ea616305a63bbb0 | /trunk/engine/sdk/inc/CEffect.h | a5b868a0fc1d688eb60c64fb850f215dcef4a4dd | [] | no_license | trancx/ybtx | 61de88ef4b2f577e486aba09c9b5b014a8399732 | 608db61c1b5e110785639d560351269c1444e4c4 | refs/heads/master | 2022-12-17T05:53:50.650153 | 2020-09-19T12:10:09 | 2020-09-19T12:10:09 | 291,492,104 | 0 | 0 | null | 2020-08-30T15:00:16 | 2020-08-30T15:00:15 | null | GB18030 | C++ | false | false | 3,883 | h | #pragma once
#include "IEffect.h"
#include "IEffectUnit.h"
class CEffectManager;
class CEffectProp;
//////////////////////////////////////////////////////////////////////////
class CEffect : public IEffect
{
public:
struct EFFECTKEY
{
EFFECTKEY();
IEffectUnit* pParentEffectUnit;
IEffectUnit* pEffectUnit;
};
protected:
uint32 m_CurTime;
float m_fCurTime;
CSkeletalFrame* m_PreSkeFrame;
CBaseModel* m_pModel;
bool m_IsAniEnd;
//bool m_bFollowBone;
const IDNAME* m_FrameString;
//CVector3f m_vecScale;
//CVector3f m_vecOff;
//CAxisAlignedBox m_AABB;
AniResult m_Result;
bool m_bVisible;
//EMap<EString,CRenderable*> m_CenterLink; //和物体中心挂钩的模型
void ResetUnitStartTime(uint32 uCurTime);
//void ResetVelocityUnit(uint32 uCurTime);
//void ResetNormalUnit(uint32 uCurTime);
//EString m_EffectName;
//float m_fVelocity;
protected:
static float st_EffectLod;
static bool st_CameraShake;
CEffectManager* m_pEffectMgr;
CEffectProp* m_pEffectProp;
EVector< EMap< int, EFFECTKEY > > m_Tracks;
public:
static void SetEffectRenderLod(float rLod);
static float GetEffectRenderLod(void);
static void SetCameraShake(bool b);
static bool GetCameraShake(void);
public:
CEffect( CEffectManager* pEffectMgr, CEffectProp* pEffectProp );
CEffect( CEffectManager* pEffectMgr);
virtual ~CEffect(void);
void InitEffect(CEffectProp* pEffectProp );
virtual ERenderObjType GetType();
virtual bool IsValid();;
virtual bool IsFollowBone(CRenderable* pParentObj);
virtual const char* GetEffectName();
virtual const char* GetFullEffectName();
virtual int GetAttachAniNum();
virtual const char* GetAttachAniName( int Num );
virtual const char* GetUserDesc();
virtual int GetTimeRange();
virtual void SetRenderCallback( IEffectUnitHandler* pUnitHandler, const char* szUnitName );
virtual void SetRenderCallback( IEffectUnitHandler* pUnitHandler, EBaseEffectUnit EUnit );
//virtual const CVector3f& GetBoxScale();
//virtual const CVector3f& GetBoxOff();
virtual const float GetAABBHeight();
virtual IntersectFlag IntersectRay( const CMatrix& transform, const CVector3f& rayPos, const CVector3f& rayDir ){return IF_IMPOSSIBLE;}
virtual void OnLinked( CRenderable* pParentObj );
virtual void OnUnlinked( void );
//virtual void OnPreRender( const AniResult& ParentAniRes, float FrameRatio );
virtual void GetCurAnimationInfo( float& CurFrame, uint32& CurTime );
//virtual bool SetNextAnimation( IDNAME AniName, FramePair FmPair, bool bLoop = true, int32 DelayTime = 200 /*毫秒*/, float AniSpeed = -1.0f );
virtual const AniResult Render( const CMatrix& matWorld, RenderObjStyle* pRORS = NULL ); //渲染模型
virtual bool UpdateTime(uint32 uCurTime);
virtual bool UpdateEfx(uint32 uCurTime, bool bReset = true);
virtual void SetVisible( bool isVisible );
virtual bool IsFrameSynch(void);
virtual void SetUnitVisibleOnRender(int track,int key);
};
//------------------------------------------------------------------------------
inline void
CEffect::SetEffectRenderLod( float rLod )
{
st_EffectLod = rLod;
}
//------------------------------------------------------------------------------
inline float
CEffect::GetEffectRenderLod( void )
{
return st_EffectLod;
}
//------------------------------------------------------------------------------
inline void
CEffect::SetCameraShake( bool b )
{
st_CameraShake = b;
}
//------------------------------------------------------------------------------
inline bool
CEffect::GetCameraShake( void )
{
return st_CameraShake;
}
| [
"CoolManBob@a2c23ad7-41ce-4a1d-83b7-33535e6483ee"
] | CoolManBob@a2c23ad7-41ce-4a1d-83b7-33535e6483ee |
01068da9396e3652ea392852812466e8d4bac663 | 40c24dfc0525ee80069de697bb8b65bc1b6a894b | /Documentation/Marshall/Proto-8-master/Platform/extras/MultiOscExample/MultiOscExample/P8PanelComponents.cpp | 23a955212cb07b2a39dcde0d4525b8c5eb286df5 | [
"MIT"
] | permissive | JoelEB/Touch_Drum | 67d0caef5b66fa7160b03936be2239dfca4f8bdf | 6f46e605f56fe4f9c12c962dabd682d0af87ff29 | refs/heads/master | 2020-03-29T08:18:19.609514 | 2019-09-12T17:27:04 | 2019-09-12T17:27:04 | 149,703,672 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,407 | cpp | //**********************************************************************//
//
// MIT License: http://opensource.org/licenses/MIT
//
// Written by: Marshall Taylor
// Changelog (YYYY/MM/DD):
// 2015/10/08: Beta Release
// 2016/2/24: Forked to 'P8' set
// 2016/2/29: LEDs wrapped by VoltageMonitor + hysteresis fix
//
//**********************************************************************//
#include "P8PanelComponents.h"
//#include "timeKeeper.h"
#include "Arduino.h"
#include "proto-8Hardware.h"
#include "VoltageMonitor.h"
extern VoltageMonitor LEDs;
extern AnalogMuxTree knobs;
extern SwitchMatrix switches;
//---Switch------------------------------------------------------
P8PanelSwitch::P8PanelSwitch( void )
{
}
void P8PanelSwitch::init( uint8_t posColInput, uint8_t posRowInput )
{
posColNumber = posColInput;
posRowNumber = posRowInput - 1; // range: 0-3
}
void P8PanelSwitch::update( void )
{
uint16_t numTemp = 0;
numTemp = (posRowNumber * 16) + posColNumber;
uint8_t tempState = switches.fetch( numTemp );
tempState ^= invert;
if(( state.getFlag() != tempState ) && ( SwitchDebounceTimeKeeper.mGet() > 200 ))
{
if( tempState == 1 )
{
state.setFlag();
}
else
{
state.clearFlag();
}
SwitchDebounceTimeKeeper.mClear();
}
}
//---Knob--------------------------------------------------------
P8PanelKnob8Bit::P8PanelKnob8Bit( void )
{
lastState = 0;
}
void P8PanelKnob8Bit::init( uint8_t posInput )
{
posNumber = posInput;
update();
//force newData high in case knob starts on last value
newData = 1;
}
void P8PanelKnob8Bit::update( void )
{
uint16_t tempState = knobs.fetch( posNumber ) >> 2;
int8_t tempSlope = 0;
state = tempState;
int8_t histDirTemp = 0;
if( state > lastState )
{
tempSlope = 1;
if( lastSlope == 1 ) histDirTemp = 1;
}
else if( state < lastState )
{
tempSlope = -1;
if( lastSlope == -1 ) histDirTemp = -1;
}
if( tempSlope != 0 )
{
if( state > lastState + hysteresis || histDirTemp == 1)
{
newData = 1;
lastState = state;
lastSlope = tempSlope;
}
if( state < lastState - hysteresis || histDirTemp == -1 )
{
newData = 1;
lastState = state;
lastSlope = tempSlope;
}
}
}
uint8_t P8PanelKnob8Bit::getState( void )
{
newData = 0;
return state;
}
uint8_t P8PanelKnob8Bit::serviceChanged( void )
{
return newData;
}
//---Button------------------------------------------------------
P8PanelButton::P8PanelButton( void )
{
beingHeld = 0;
risingEdgeFlag = 0;
fallingEdgeFlag = 0;
holdRisingEdgeFlag = 0;
holdFallingEdgeFlag = 0;
}
void P8PanelButton::init( uint8_t posColInput, uint8_t posRowInput )
{
posColNumber = posColInput;
posRowNumber = posRowInput - 1; // range: 0-3
}
//This is the intended operation:
// Button is pressed. If it has been long enough since last movement:
// update newData
// clear timer
// If This has already been done, check for button held. If so,
// update newData
// clear timer
void P8PanelButton::update( void )
{
uint8_t freshData;
uint16_t numTemp = 0;
numTemp = (posRowNumber << 4) + posColNumber;
freshData = switches.fetch( numTemp );
buttonState_t nextState = state;
switch( state )
{
case BUTTONOFF: //Last state was BUTTONOFF
if(( freshData == 1 ) && ( buttonDebounceTimeKeeper.mGet() > 150 ))
{
//Start the timer
buttonDebounceTimeKeeper.mClear();
nextState = BUTTONON;
risingEdgeFlag = 1;
}
else
{
nextState = BUTTONOFF;
}
break;
case BUTTONON: //Last state was BUTTONON
if( freshData == 1 )
{
if( buttonDebounceTimeKeeper.mGet() > 1000 )
{
nextState = BUTTONHOLD;
holdRisingEdgeFlag = 1;
}
}
//No break;, do buttonhold's state too
case BUTTONHOLD: //In the process of holding
if( freshData == 0 )
{
buttonDebounceTimeKeeper.mClear();
nextState = BUTTONOFF;
}
break;
default:
break;
}
state = nextState;
}
buttonState_t P8PanelButton::getState( void )
{
return state;
}
uint8_t P8PanelButton::serviceRisingEdge( void )
{
uint8_t returnVar = 0;
if( risingEdgeFlag == 1 )
{
risingEdgeFlag = 0;
returnVar = 1;
}
return returnVar;
}
uint8_t P8PanelButton::serviceFallingEdge( void )
{
uint8_t returnVar = 0;
if( fallingEdgeFlag == 1 )
{
fallingEdgeFlag = 0;
returnVar = 1;
}
return returnVar;
}
uint8_t P8PanelButton::serviceHoldRisingEdge( void )
{
uint8_t returnVar = 0;
if( holdRisingEdgeFlag == 1 )
{
holdRisingEdgeFlag = 0;
returnVar = 1;
}
return returnVar;
}
uint8_t P8PanelButton::serviceHoldFallingEdge( void )
{
uint8_t returnVar = 0;
if( holdFallingEdgeFlag == 1 )
{
holdFallingEdgeFlag = 0;
returnVar = 1;
}
return returnVar;
}
//---Led---------------------------------------------------------
P8PanelLed::P8PanelLed( void )
{
state = LEDOFF;
}
void P8PanelLed::init( uint8_t posInput )
{
posNumber = posInput;
update();
}
void P8PanelLed::init( uint8_t posInput, volatile uint8_t * volatile flasherAddress, volatile uint8_t * volatile fastFlasherAddress )
{
flasherState = flasherAddress;
fastFlasherState = fastFlasherAddress;
init( posInput ); //Do regular init, plus:
}
void P8PanelLed::update( void )
{
uint8_t outputValue = 0;
switch(state)
{
case LEDON:
outputValue = 1;
break;
case LEDFLASHING:
outputValue = *flasherState;
break;
case LEDFLASHINGFAST:
outputValue = *fastFlasherState;
break;
default:
case LEDOFF:
outputValue = 0;
break;
}
LEDs.store(posNumber, outputValue);
}
ledState_t P8PanelLed::getState( void )
{
return state;
}
void P8PanelLed::setState( ledState_t inputValue )
{
state = inputValue;
}
void P8PanelLed::toggle( void )
{
switch(state)
{
case LEDON:
state = LEDOFF;
break;
case LEDOFF:
state = LEDON;
break;
default:
break;
}
}
//---Selector----------------------------------------------------
P8PanelSelector::P8PanelSelector( void )
{
changedFlag = 0;
points = 10;
}
P8PanelSelector::~P8PanelSelector( void )
{
delete[] thresholds;
}
// 8 bit resolution on the ADC should be fine. Right shift on analogRead
void P8PanelSelector::init( uint8_t posInput, uint8_t maxInput, uint8_t minInput, uint8_t pointsInput )
{
if( pointsInput < 2 )
{
points = 2;
}
else
{
points = pointsInput - 1; //( by (n-1) not n )
}
thresholds = new uint8_t[points];
posNumber = posInput;
pinMode( posNumber, INPUT );
//Set up the ranges
uint8_t stepHeight = ( maxInput - minInput ) / points;
thresholds[0] = minInput + ( stepHeight / 2 );
int i;
for( i = 1; i < points; i++ )
{
thresholds[i] = thresholds[i - 1] + stepHeight;
}
update();
//force changedFlag high in case knob starts on last value
//changedFlag = 1;
}
void P8PanelSelector::init( uint8_t posInput, uint8_t maxInput, uint8_t minInput )
{
init( posInput, maxInput, minInput, 10 );
}
void P8PanelSelector::update( void )
{
uint8_t freshData = (analogRead( posNumber )) >> 2; //Now 8 bits
uint8_t tempState = 0;
//Seek the position
int i;
for( i = 0; i < points; i++ )
{
if( freshData > thresholds[i] )
{
tempState = i + 1; //It's this or higher
}
}
//Check if new
if( state != tempState )
{
state = tempState;
changedFlag = 1;
}
}
uint8_t P8PanelSelector::getState( void )
{
return state;
}
uint8_t P8PanelSelector::serviceChanged( void )
{
uint8_t returnVar = 0;
if( changedFlag == 1 )
{
changedFlag = 0;
returnVar = 1;
}
return returnVar;
}
| [
"jbartlett@meowwolf.com"
] | jbartlett@meowwolf.com |
f7c9bb66de149ddb12001005752151e39b72dc9f | 489623b7a30fa6494b258de063aabeecc95b0f66 | /DynamicProgramming/LongestPalindromicSubsequence.cpp | aed4cedc2d8077c452a4be5ce980c515c44074a8 | [] | no_license | giriteja94495/leetcodesolutions | 9ce3e2190dcd0c0dc3d6069794f1e277a9d1cb7b | e0460e9ff03a3272f167098c1a207a721e4dc030 | refs/heads/master | 2022-12-11T08:22:25.853675 | 2022-12-01T04:36:15 | 2022-12-01T04:36:15 | 239,805,769 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,899 | cpp | // https://leetcode.com/problems/longest-palindromic-subsequence/
// Naive recursive approach with memoization
class Solution {
public:
// extra space to store the calculations
vector<vector<int>> dp;
int longestPalindromeSubseq(string s) {
// resizing takes good amount of time complexity but still... i had to go for it
dp.resize(s.size(),vector<int> (s.size()));
return helper(s,0,s.size()-1);
}
private:
int helper(string s, int l, int r){
// this is a tricky base case,consider an example of "gg" after s[0]==s[1] then l and r becomes 1 and 0 ,so we have to return 0
if(l>r) return 0;
// this is for odd length palindrome
if(l==r) return 1;
// if we found the calculation ...just return it
if(dp[l][r]) return dp[l][r];
// if the strings are equal ..then we found 2 similar chars in our required palindrome so ,it is 2+helper(increment left ,decrement right)
// if they are not equal ,either increase left or decrease right and find the max subsequence
return dp[l][r]=(s[l]==s[r]?2+helper(s,l+1,r-1):max(helper(s,l+1,r),helper(s,l,r-1)));
}
};
// i cracked my head while understanding this ...it was worth it
// DP Solution
class Solution {
public:
int longestPalindromeSubseq(string s) {
int n=s.size();
vector<vector<int>> dp(n,vector<int>(n));
for(int i=n-1;i>=0; i--){
dp[i][i]=1;
for(int j=i+1;j<n;j++){
if(s[i]==s[j]){
dp[i][j]=2+dp[i+1][j-1];
}
else{
dp[i][j]=max(dp[i+1][j],dp[i][j-1]);
}
}
}
return dp[0][n-1];
}
};
| [
"noreply@github.com"
] | noreply@github.com |
711ee96410278bb9e2bd69b526541c2a82889cb2 | 5d7807e52888b9505c4b5a0e24f5f87e4f6c343f | /cryengine/CryAction/IVehicleSystem.h | c9a14aed00456602c44104bda26fa0e7a934199f | [] | no_license | CapsAdmin/oohh | 01533c72450c5ac036a245ffbaba09b6fda00e69 | b63abeb717e1cd1ee2d3483bd5f0954c81bfc6e9 | refs/heads/master | 2021-01-25T10:44:22.976777 | 2016-10-11T19:05:47 | 2016-10-11T19:05:47 | 32,117,923 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 66,513 | h | /*************************************************************************
Crytek Source File.
Copyright (C), Crytek Studios, 2001-2004.
-------------------------------------------------------------------------
$Id$
$DateTime$
Description: Vehicle System interface
-------------------------------------------------------------------------
History:
- 26:8:2004 11:40 : Created by Mathieu Pinard
*************************************************************************/
#include DEVIRTUALIZE_HEADER_FIX(IVehicleSystem.h)
#ifndef __IVEHICLESYSTEM_H__
#define __IVEHICLESYSTEM_H__
#if _MSC_VER > 1000
# pragma once
#endif
#include <IEntity.h>
#include <IEntitySystem.h>
#include <ISound.h>
#include <ISerialize.h>
#include "IGameObjectSystem.h"
#include "IGameObject.h"
#include "IMovementController.h"
#include "VehicleSystem/VehicleParams.h"
struct IGameFramework;
struct SViewParams;
struct SOBJECTSTATE;
struct IVehiclePart;
struct IVehicleWheel;
class CVehicleSeat;
struct IVehicleMovement;
class CMovementRequest;
struct SMovementState;
struct IVehicleEventListener;
struct SVehicleEventParams;
struct IFireController;
struct IVehicleSystem;
struct IVehicleSeat;
struct IVehicleAnimation;
struct IVehicleHelper;
struct IVehicleComponent;
struct IVehicleClient;
// compile out debug draw code in release builds
#ifdef _RELEASE
#define ENABLE_VEHICLE_DEBUG 0
#else
#define ENABLE_VEHICLE_DEBUG 1
#endif
// Summary
// Type used to hold vehicle's ActionIds
// See Also
// EVehicleActionIds
typedef int TVehicleActionId;
// Summary
// ActionId constants
// Description
// ActionId constants which represent the multiple ways that an actor can
// interact while being on a vehicle seat.
// See Also
// TVehicleActionId
enum EVehicleActionIds
{
eVAI_Exit = 1,
eVAI_ChangeSeat,
eVAI_ChangeSeat1,
eVAI_ChangeSeat2,
eVAI_ChangeSeat3,
eVAI_ChangeSeat4,
eVAI_ChangeSeat5,
eVAI_RotatePitch,
eVAI_RotateYaw,
eVAI_RotateRoll,
eVAI_XIRotatePitch,
eVAI_XIRotateYaw,
eVAI_XIRotateRoll,
eVAI_MoveForward,
eVAI_MoveBack,
eVAI_XIMoveY,
eVAI_TurnLeft,
eVAI_TurnRight,
eVAI_XIMoveX,
eVAI_StrafeLeft,
eVAI_StrafeRight,
eVAI_RollLeft,
eVAI_RollRight,
eVAI_AfterBurner,
eVAI_Brake,
eVAI_MoveUp,
eVAI_MoveDown,
eVAI_ChangeView,
eVAI_RearView,
eVAI_ViewOption,
eVAI_FireMode,
eVAI_Attack1,
eVAI_Attack2,
eVAI_ToggleLights,
eVAI_Horn,
eVAI_ZoomIn,
eVAI_ZoomOut,
eVAI_DesirePitch,
eVAI_Boost,
eVAI_PitchUp,
eVAI_PitchDown,
eVAI_Debug_1,
eVAI_Debug_2,
eVAI_PhysicsStep,
eVAI_XIAccelerate,
eVAI_XIDeccelerate,
eVAI_Others,
};
// Summary
// Vehicle event types
// See Also
// IVehicle::BroadcastVehicleEvent, IVehicle::RegisterVehicleEventListener, IVehicleEventListener
enum EVehicleEvent
{
eVE_Collision = 0,
eVE_Hit,
eVE_Damaged,
eVE_Destroyed,
eVE_Repair,
eVE_PassengerEnter,
eVE_PassengerExit,
eVE_PassengerChangeSeat,
eVE_SeatFreed,
eVE_PreVehicleDeletion,
eVE_VehicleDeleted,
eVE_ToggleDebugView,
eVE_ToggleDriverControlledGuns,
eVE_Brake,
eVE_Timer,
eVE_EngineStopped,
eVE_OpenDoors,
eVE_CloseDoors,
eVE_BlockDoors,
eVE_ExtractGears,
eVE_RetractGears,
eVE_Indestructible,
eVE_BeingFlipped,
eVE_Reversing,
eVE_WeaponRemoved,
eVE_TryDetachPartEntity,
eVE_OnDetachPartEntity,
eVE_StartParticleEffect,
eVE_StopParticleEffect,
eVE_Hide,
eVE_Last,
};
// Summary
// Value type used to define the seat id in the vehicle system
// See Also
// IVehicleSeat
typedef int TVehicleSeatId;
const TVehicleSeatId InvalidVehicleSeatId = 0;
// Summary
// Value type used to define the view id in the vehicle system
// See Also
// IVehicleView
typedef int TVehicleViewId;
const TVehicleSeatId InvalidVehicleViewId = 0;
// Summary
// Value type used to define the state id of a vehicle animation
// See Also
// IVehicleAnimation
typedef int TVehicleAnimStateId;
const TVehicleAnimStateId InvalidVehicleAnimStateId = -1;
struct SVehicleStatus
{
SVehicleStatus()
{
Reset();
}
void Reset()
{
vel.Set(0,0,0);
speed = 0.f;
health = 1.f;
passengerCount = 0;
altitude = 0.f;
flipped = 0.f;
contacts = 0;
submergedRatio = 0.f;
frameId = 0;
frozenAmount = 0.f;
beingFlipped = false;
}
void Serialize(TSerialize ser, EEntityAspects aspects)
{
ser.Value("health", health);
ser.Value("speed", speed);
ser.Value("altitude", altitude);
ser.Value("flipped", flipped);
ser.Value("frozenAmount", frozenAmount);
}
Vec3 vel;
float speed;
float health;
float altitude;
float flipped;
int passengerCount;
int contacts;
float submergedRatio;
float frozenAmount;
bool beingFlipped;
int frameId;
};
struct SVehicleDamageParams
{
float collisionDamageThreshold;
float groundCollisionMinSpeed;
float groundCollisionMaxSpeed;
float groundCollisionMinMult;
float groundCollisionMaxMult;
float vehicleCollisionDestructionSpeed;
float submergedRatioMax;
float submergedDamageMult;
float aiKillPlayerSpeed;
float playerKillAISpeed;
float aiKillAISpeed; // only applies to AI of other faction
SVehicleDamageParams()
{
collisionDamageThreshold = 50.f;
groundCollisionMinMult = 1.f; // increases "falling" damage when > 1
groundCollisionMaxMult = 1.f;
groundCollisionMinSpeed = 15.f;
groundCollisionMaxSpeed = 50.f;
vehicleCollisionDestructionSpeed = -1; // eg disabled.
submergedRatioMax = 1.f;
submergedDamageMult = 1.f;
aiKillPlayerSpeed = 0.0f;
playerKillAISpeed = 0.0f;
aiKillAISpeed = 0.0f;
}
};
struct SVehicleImpls
{
void Add(const string& impl){ vImpls.push_back(impl); }
int Count() const { return vImpls.size(); }
string GetAt(int idx) const
{
if (idx >= 0 && idx < (int)vImpls.size())
return vImpls[idx];
return "";
}
private:
std::vector<string> vImpls;
};
/** Exhaust particles parameter structure
* Movement classes can use this to control exhausts.
* Currently we support a start/stop effect and a running effect
* with various parameters. It's up to the movement if/how
* it makes use of it.
*/
UNIQUE_IFACE struct SExhaustParams
{
SExhaustParams()
{
runBaseSizeScale = 1.f;
runMinSpeed = runMaxSpeed = 0;
runMinPower = runMaxPower = 0;
runMinSpeedSizeScale = runMaxSpeedSizeScale = 1.f;
runMinSpeedCountScale = runMaxSpeedCountScale = 1.f;
runMinSpeedSpeedScale = runMaxSpeedSpeedScale = 1.f;
runMinPowerSizeScale = runMaxPowerSizeScale = 1.f;
runMinPowerSpeedScale = runMaxPowerSpeedScale = 1.f;
insideWater = false;
outsideWater = true;
disableWithNegativePower = false;
hasExhaust = false;
}
virtual ~SExhaustParams(){}
virtual size_t GetExhaustCount() const = 0;
virtual IVehicleHelper* GetHelper(int idx) const = 0;
virtual const char* GetStartEffect() const = 0;
virtual const char* GetStopEffect() const = 0;
virtual const char* GetRunEffect() const = 0;
virtual const char* GetBoostEffect() const = 0;
float runBaseSizeScale;
float runMinSpeed;
float runMinSpeedSizeScale;
float runMinSpeedCountScale;
float runMinSpeedSpeedScale;
float runMaxSpeed;
float runMaxSpeedSizeScale;
float runMaxSpeedCountScale;
float runMaxSpeedSpeedScale;
float runMinPower;
float runMinPowerSizeScale;
float runMinPowerCountScale;
float runMinPowerSpeedScale;
float runMaxPower;
float runMaxPowerSizeScale;
float runMaxPowerCountScale;
float runMaxPowerSpeedScale;
bool insideWater;
bool outsideWater;
bool disableWithNegativePower;
bool hasExhaust;
};
struct SDamageEffect
{
string effectName;
IVehicleHelper* pHelper;
bool isGravityDirUsed;
Vec3 gravityDir;
float pulsePeriod;
void GetMemoryUsage(ICrySizer * s) const
{
s->AddObject(effectName);
}
SDamageEffect()
: pHelper(NULL),
isGravityDirUsed(false),
gravityDir(ZERO),
pulsePeriod(0.f)
{
}
};
/** SEnvironmentParticles
* Holds params for environment particles like dust, dirt..
* A vehicle can use several layers to control different effects
* with distinct parameters.
*/
UNIQUE_IFACE struct SEnvironmentLayer
{
SEnvironmentLayer()
{
minSpeed = 0;
maxSpeed = 10;
minSpeedSizeScale = maxSpeedSizeScale = 1.f;
minSpeedCountScale = maxSpeedCountScale = 1.f;
minSpeedSpeedScale = maxSpeedSpeedScale = 1.f;
minPowerSizeScale = maxPowerSizeScale = 1.f;
minPowerCountScale = maxPowerCountScale = 1.f;
minPowerSpeedScale = maxPowerSpeedScale = 1.f;
maxHeightSizeScale = maxHeightCountScale = 1.f;
alignGroundHeight = 0;
alignToWater = false;
active = true;
}
virtual ~SEnvironmentLayer(){}
virtual const char* GetName() const = 0;
virtual size_t GetHelperCount() const = 0;
virtual IVehicleHelper* GetHelper(int idx) const = 0;
virtual size_t GetGroupCount() const = 0;
virtual size_t GetWheelCount(int group) const = 0;
virtual int GetWheelAt(int group, int wheel) const = 0;
virtual bool IsGroupActive(int group) const = 0;
virtual void SetGroupActive(int group, bool active) = 0;
float minSpeed;
float minSpeedSizeScale;
float minSpeedCountScale;
float minSpeedSpeedScale;
float maxSpeed;
float maxSpeedSizeScale;
float maxSpeedCountScale;
float maxSpeedSpeedScale;
float minPowerSizeScale;
float minPowerCountScale;
float minPowerSpeedScale;
float maxPowerSizeScale;
float maxPowerCountScale;
float maxPowerSpeedScale;
float alignGroundHeight;
float maxHeightSizeScale;
float maxHeightCountScale;
bool alignToWater;
bool active;
};
/** SEnvironmentParticles
* Holds EnvironmentLayers
*/
UNIQUE_IFACE struct SEnvironmentParticles
{
virtual ~SEnvironmentParticles(){}
virtual size_t GetLayerCount() const = 0;
virtual const SEnvironmentLayer& GetLayer(int idx) const = 0;
virtual const char* GetMFXRowName() const = 0;
};
typedef std::map <string, SDamageEffect> TDamageEffectMap;
/** SParticleParams is the container for all particle structures
*/
UNIQUE_IFACE struct SParticleParams
{
virtual ~SParticleParams(){}
virtual SExhaustParams* GetExhaustParams() = 0;
virtual const SDamageEffect *GetDamageEffect(const char *pName) const = 0;
virtual SEnvironmentParticles* GetEnvironmentParticles() = 0;
};
struct SVehicleEventParams
{
EntityId entityId;
bool bParam;
int iParam;
float fParam,fParam2;
Vec3 vParam;
SVehicleEventParams()
: entityId(0)
, bParam(false)
, iParam(0)
, fParam(0.f)
, fParam2(0.0f)
{
vParam.zero();
}
};
struct SVehicleMovementEventParams
{
Vec3 vParam; // param for hit pos or others
float fValue; // param for e.g. damage value
int iValue;
bool bValue;
const char* sParam;
IVehicleComponent* pComponent; // optionally, vehicle component involved
SVehicleMovementEventParams()
: fValue(0.f)
, iValue(0)
, bValue(false)
, pComponent(NULL)
, sParam(NULL)
{
vParam.zero();
}
};
// Sound event info
struct SVehicleSoundInfo
{
string name; // event name
IVehicleHelper* pHelper;
tSoundID soundId;
bool isEngineSound;
SVehicleSoundInfo() : isEngineSound(false)
{
soundId = INVALID_SOUNDID;
}
};
typedef int TVehicleSoundEventId;
const TVehicleSoundEventId InvalidSoundEventId = -1;
// Vehicle weapon info
struct SVehicleWeaponInfo
{
EntityId entityId;
bool bCanFire;
SVehicleWeaponInfo() : entityId(0), bCanFire(false) {}
};
struct IVehicleEventListener
{
virtual ~IVehicleEventListener(){}
virtual void OnVehicleEvent(EVehicleEvent event, const SVehicleEventParams& params) = 0;
};
struct IVehicleUsageEventListener
{
virtual ~IVehicleUsageEventListener(){}
virtual void OnStartUse( const EntityId playerId, IVehicle* pVehicle ) = 0;
virtual void OnEndUse( const EntityId playerId, IVehicle* pVehicle ) = 0;
};
// Summary
// Type for the id used to define the class of a vehicle object
// See Also
// IVehicleObject
typedef unsigned int TVehicleObjectId;
const TVehicleObjectId InvalidVehicleObjectId = 0;
// Summary
// Base interface used by many vehicle objects
struct IVehicleObject
: public IVehicleEventListener
{
// Summary
// Returns the id of the vehicle object
virtual TVehicleObjectId GetId() = 0;
// Summary
// Serialize the vehicle object
virtual void Serialize(TSerialize ser, EEntityAspects aspects) = 0;
// Summary
// Update the vehicle object
// Description
// Used to handle any time sensitive updates. In example, rotation for
// turret parts is implemented in this function.
// Parameters
// deltaTime - total time for the update, in seconds
virtual void Update(const float deltaTime) = 0;
virtual void UpdateFromPassenger(const float deltaTime, EntityId playerId) {}
};
// Summary
// Enumeration of different event which can trigger a vehicle action to
// perform some tasks.
// See Also
// IVehicleAction
enum EVehicleActionEvent
{
eVAE_IsUsable = 1, // When the vehicle is being tested to be usuable by a player (by aiming the crossair).
eVAE_OnUsed, // When the vehicle is being used by a player (with the USE key).
eVAE_OnGroundCollision, // When the vehicle collide with the ground.
eVAE_OnEntityCollision, // When the vehicle collide with another entity.
eVAE_Others, // ot be used as starting index for game specific action events.
};
// Summary
// Interface used to implement a special behavior that affect the vehicle
// Description
// In example, landing gears on flying vehicles or the entering procedure
// for the player are implemented as vehicle action.
struct IVehicleAction
: public IVehicleObject
{
virtual bool Init(IVehicle* pVehicle, const CVehicleParams& table) = 0;
virtual void Reset() = 0;
virtual void Release() = 0;
virtual int OnEvent(int eventType, SVehicleEventParams& eventParams) = 0;
// IVehicleObject
virtual TVehicleObjectId GetId() = 0;
virtual void Serialize(TSerialize ser, EEntityAspects aspects) = 0;
virtual void Update(const float deltaTime) = 0;
// ~IVehicleObject
};
#define IMPLEMENT_VEHICLEOBJECT \
public: \
static TVehicleObjectId m_objectId; \
friend struct IVehicleSystem; \
virtual TVehicleObjectId GetId() { return m_objectId; }
#define DEFINE_VEHICLEOBJECT(obj) \
TVehicleObjectId obj::m_objectId = InvalidVehicleObjectId;
#define CAST_VEHICLEOBJECT(type, objptr) \
(objptr->GetId() == type::m_objectId) ? (type*)objptr : NULL
// Summary:
// Vehicle implementation interface
// Description:
// Interface used to implement a vehicle.
struct IVehicle : public IGameObjectExtension
{
// Summary:
// Reset vehicle
// Description:
// Will reset properly all components of the vehicle including the seats,
// components, parts and the movement.
virtual void Reset(bool enterGame) = 0;
// Summary:
// Gets the physics params
// Description:
// It will return the physics params which have been sent to the entity
// system when the vehicle entity was spawned
// Return value:
// a SEntityPhysicalizeParams structure
virtual SEntityPhysicalizeParams& GetPhysicsParams() =0;
// Summary:
// Gets the status
// Description:
// Will return a structure which hold several status information on the vehicle, including destroyed state and passenger count.
// Return value:
// a SVehicleStatus structure
virtual const SVehicleStatus& GetStatus() const = 0;
// Summary:
// Updates view of a passenger
// Description:
// Will update the SViewParams structure will the correct camera info for a specified passenger of the vehicle.
// Parameters:
// viewParams - structure which is used to return the camera info
// playerId - entity id of the passenger
virtual void UpdateView(SViewParams &viewParams, EntityId playerId = 0) = 0;
virtual void UpdatePassenger(float frameTime, EntityId playerId) = 0;
//FIXME:move this to the gameside, its not really needed here, plus add callerId to the IActionListener interface
virtual void OnAction(const TVehicleActionId actionId, int activationMode, float value, EntityId callerId) = 0;
virtual void OnHit(EntityId targetId, EntityId shooterId, float damage, Vec3 position, float radius, int hitTypeId, bool explosion, IVehicleComponent *pHitComponent = NULL) = 0;
// set & get cameraAdjustment Value
virtual void SetCameraAdjustment(float adjustmentValue=0.f) = 0;
virtual float GetCameraAdjustment() = 0;
virtual float GetDamageRatio(bool onlyMajorComponents = false) const = 0;
virtual void SetAmmoCount(IEntityClass* pAmmoType, int amount) = 0;
virtual int GetAmmoCount(IEntityClass* pAmmoType) const = 0;
virtual void SetOwnerId(EntityId ownerId) = 0;
virtual EntityId GetOwnerId() const = 0;
virtual int IsUsable(EntityId userId) = 0;
virtual bool OnUsed(EntityId userId, int index) = 0;
virtual bool AddSeat(const SmartScriptTable& seatParams) = 0;
virtual bool AddHelper(const char* name, Vec3 position, Vec3 direction, IVehiclePart* pPart) = 0;
virtual int GetPartCount() = 0;
virtual IVehiclePart* GetPart(unsigned int index) = 0;
virtual void GetParts(IVehiclePart** parts, int nMax) = 0;
virtual int GetComponentCount() const = 0;
virtual IVehicleComponent* GetComponent(int index) = 0;
virtual IVehicleComponent* GetComponent(const char* name) = 0;
virtual IVehicleAnimation* GetAnimation(const char* name) = 0;
virtual int GetActionCount() = 0;
virtual IVehicleAction* GetAction(int index) = 0;
// get the current movement controller
virtual IMovementController * GetMovementController() = 0;
virtual IFireController* GetFireController(uint32 controllerNum = 0) = 0;
// Get TVehicleSeatId of last seat
virtual TVehicleSeatId GetLastSeatId() = 0;
// Get Seat by SeatId, or NULL
virtual IVehicleSeat* GetSeatById(const TVehicleSeatId seatId) const = 0;
// Get amount of Seats
virtual unsigned int GetSeatCount() = 0;
// get seat interface for passengerId, or NULL
virtual IVehicleSeat* GetSeatForPassenger(EntityId passengerId) const = 0;
// Get SeatId by name
virtual TVehicleSeatId GetSeatId(const char* pSeatName) = 0;
// check if player/client is driving this vehicle
virtual bool IsPlayerDriving(bool clientOnly = true) = 0;
// check if there is friendlyPassenger
virtual bool HasFriendlyPassenger(IEntity *pPlayer) = 0;
// check if client is inside this vehicle
virtual bool IsPlayerPassenger() = 0;
// get total number of weapon entities on vehicle
virtual int GetWeaponCount() const = 0;
// Get EntityId by weapon index
virtual EntityId GetWeaponId(int index) const = 0;
// get EntityId for currently used weapon for passengerId, or 0
virtual EntityId GetCurrentWeaponId(EntityId passengerId, bool secondary=false) const = 0;
// get currently used weapon info for passengerId. Returns true if info was found.
virtual bool GetCurrentWeaponInfo(SVehicleWeaponInfo &outInfo, EntityId passengerId, bool secondary=false) const = 0;
// Summary:
// Indicates if an helper position is available
// Description:
// Will find if a specified helper position exist on the vehicle.
// Parameters:
// name - name of the helper position
virtual bool HasHelper(const char* pName) = 0;
virtual IVehiclePart* GetPart(const char* name) = 0;
virtual IVehiclePart* GetWeaponParentPart(EntityId weaponId) = 0;
virtual IVehicleSeat* GetWeaponParentSeat(EntityId weaponId) = 0;
virtual IVehicleMovement* GetMovement() const = 0;
// Summary:
// Returns the wheel count
// Description:
// Will return the wheel count of the vehicle, if any are preset.
// Return value:
// The wheel count, or 0 if none are available
virtual int GetWheelCount() = 0;
virtual IVehiclePart* GetWheelPart(int idx) = 0;
// Summary:
// Returns the mass
// Description:
// Will return the mass of the vehicle.
// Return value:
// The mass value, it should never be a negative value
virtual float GetMass() const = 0;
// Summary:
// Returns the altitude
// Description:
// Will return the altitude of the vehicle.
// Return value:
// The altitude value, it should be a positive value
virtual float GetAltitude() = 0;
virtual IMovementController * GetPassengerMovementController( EntityId passenger ) = 0;
// Summary
// Sends a vehicle event to all the listeners
// Parameters
// event - One of the event declared in EVehicleEvent
// params - optional parameter, see EVehicleEvent to know which member of this structure needs to be filled for the specific event
// See Also
// UnregisterVehicleEventListener
virtual void BroadcastVehicleEvent(EVehicleEvent event, const SVehicleEventParams& params) = 0;
// Summary
// Registers an event listener
// Parameters
// pEvenListener - a pointer to class which implements the IVehicleEventListener interface
// See Also
// UnregisterVehicleEventListener
virtual void RegisterVehicleEventListener(IVehicleEventListener* pEvenListener, const char* name) = 0;
// Summary
// Unregisters an event listener
// Parameters
// pEvenListener - a pointer to class which implements the IVehicleEventListener interface
// See Also
// RegisterVehicleEventListener
virtual void UnregisterVehicleEventListener(IVehicleEventListener* pEvenListener) = 0;
virtual SParticleParams* GetParticleParams() = 0;
virtual const SVehicleDamageParams& GetDamageParams() const = 0;
uint16 GetChannelId()
{
return GetGameObject()->GetChannelId();
}
void SetChannelId( uint16 id )
{
GetGameObject()->SetChannelId( id );
}
enum EVehicleUpdateSlot
{
eVUS_Always = 0, // used for vehicle elements which always need to be updated
eVUS_EnginePowered, // used for vehicle elements which should only be updated when the engine is powered
eVUS_PassengerIn, // used for vehicle elements which should only when a passenger has entered the vehicle
eVUS_Visible, // currently unused
eVUS_AIControlled, // used for vehicle using new flight nav
eVUS_Last = eVUS_AIControlled
};
enum EVehicleObjectUpdate
{
eVOU_NoUpdate = 0,
eVOU_AlwaysUpdate,
eVOU_PassengerUpdate,
eVOU_Visible,
};
virtual void SetObjectUpdate(IVehicleObject* pObject, EVehicleObjectUpdate updatePolicy) = 0;
virtual IVehicleHelper* GetHelper(const char* pName) = 0;
virtual void Destroy() = 0;
virtual bool IsDestroyed() const = 0;
virtual bool IsFlipped(float maxSpeed=0.f) = 0;
// Summary:
// Enables/disables engine slot triggering by vehicle speed
virtual void TriggerEngineSlotBySpeed(bool trigger) = 0;
enum EVehicleNeedsUpdateFlags
{
eVUF_AwakePhysics = 1 << 0,
};
// Summary:
// Notify vehicle to that update is required
virtual void NeedsUpdate(int flags=0, bool bThreadSafe=false) = 0;
// Summary:
// Register Entity Timer. If timerId == -1, timerId will be assigned
virtual int SetTimer(int timerId, int ms, IVehicleObject* pObject) = 0;
// Summary:
// Kill Entity Timer
virtual int KillTimer(int timerId) = 0;
// Summary:
// Get Actor on driver seat, or NULL
virtual IActor* GetDriver() const = 0;
// Summary:
// Finds a valid world position the actor could be placed at when they exit the vehicle.
// Based on seat helpers, but does additional checks if these are all blocked.
// NB: actor may not necessarily be a passenger (used for MP spawn trucks)
// Returns true if a valid position was found, false otherwise.
// extended==true -> allows two actors to exit from one seat (lining up away from the vehicle).
virtual bool GetExitPositionForActor(IActor* pActor, Vec3& pos, bool extended = false) = 0;
// Summary:
// Returns the physical entities attached to this vehicle, for use with physics RWI and PWI tests
virtual int GetSkipEntities(IPhysicalEntity** pSkipEnts, int nMaxSkip) = 0;
// Summary:
// Returns vehicle modification name
virtual const char* GetModification()const = 0;
// Request a passenger to leave the vehicle and spawn at pos
virtual void ExitVehicleAtPosition(EntityId passengerId, const Vec3 &pos) = 0;
// Evacuate all passengers
virtual void EvictAllPassengers() = 0;
// Check that an enemy is not already using this vehicle, before entering
virtual bool IsCrewHostile(EntityId actorId) = 0;
// Returns the name of the action map specified for this vehicle type in
// the xml file
virtual const char* GetActionMap() const = 0;
// Returns collision damage multiplayer
virtual float GetSelfCollisionMult(const Vec3& velocity, const Vec3& normal, int partId, EntityId colliderId) const = 0;
// Is vehicle probably distant from the player?
virtual bool IsProbablyDistant() const = 0;
virtual bool IsIndestructable() const = 0;
// Summary:
//Used in MP for logically linking associated vehicles together when spawning
virtual EntityId GetParentEntityId() const = 0;
virtual void SetParentEntityId(EntityId parentEntityId) = 0;
// Evacuate all passengers immediately on a client without having to ask the server for permission
virtual void ClientEvictAllPassengers() = 0;
virtual void OffsetPosition(const Vec3 &delta) = 0;
// Sound parameters structure.
struct SSoundParams
{
string engineProjectName;
string functionalityProjectName;
};
// Get sound parameters.
inline const SSoundParams &GetSoundParams() const
{
return m_soundParams;
}
protected:
// Sound parameters.
SSoundParams m_soundParams;
};
struct SVehicleMovementAction
{
SVehicleMovementAction()
{
Clear();
};
float power;
float rotateYaw;
float rotatePitch;
float rotateRoll;
bool brake;
bool isAI;
void Clear(bool keepPressHoldControlledVars = false)
{
if (!keepPressHoldControlledVars)
{
power = 0.0f;
brake = false;
isAI = false;
rotateYaw = 0.0f;
}
else
{
// only keep slight pedal (to allow rolling)
power *= 0.1f;
}
rotateRoll = 0.0f;
rotatePitch = 0.0f;
}
};
UNIQUE_IFACE struct IVehicleMovementActionFilter
{
virtual ~IVehicleMovementActionFilter(){}
virtual void OnProcessActions(SVehicleMovementAction& movementAction) = 0;
virtual void GetMemoryUsage(ICrySizer * pSizer) const =0;
};
// Summary:
// Interface for vehicle movement class
// Description:
// Interface used to implement a movement class for vehicles.
struct IVehicleMovement
: public IMovementController
{
enum EVehicleMovementType
{
eVMT_Sea = 0,
eVMT_Air,
eVMT_Land,
eVMT_Amphibious,
eVMT_Other
};
// Summary:
// Event values for the movement
// Description:
// All event type possible to be sent to a movement.
enum EVehicleMovementEvent
{
// the vehicle got hit and the movement should be damaged according to the
// value which got passed
eVME_Damage = 0,
// the vehicle got hit and the movement steering should fail according to
// the value which got passed
eVME_DamageSteering,
eVME_VehicleDestroyed,
// Repair event. New damage ratio is passed.
eVME_Repair,
// the vehicle is being frozen, a value of 1.0 indicate that it's
// completely frozen and shouldn't move anymore
eVME_Freeze,
// tire destroyed
eVME_TireBlown,
// tires restored
eVME_TireRestored,
// sent when player enters/leaves seat
eVME_PlayerEnterLeaveSeat,
// sent when player enters/leaves the vehicle
eVME_PlayerEnterLeaveVehicle,
// sent when player switches view
eVME_PlayerSwitchView,
// sent on collision
eVME_Collision,
// sent on ground collision
eVME_GroundCollision,
// ?
eVME_WarmUpEngine,
// sent when vehicle toggles engine update slot
eVME_ToggleEngineUpdate,
// becoming visible
eVME_BecomeVisible,
eVME_SetMode,
eVME_Turbulence,
eVME_NW_Discharge,
eVME_EnableHandbrake,
eVME_PartDetached,
eVME_SetFactorMaxSpeed,
eVME_SetFactorAccel,
eVME_Others,
};
// Summary:
// Initializes the movement
// Description:
// Used to initialize a movement from a script table.
// Parameters:
// pVehicle - pointer to the vehicle which will uses this movement instance
// table - table which hold all the movement parameters
virtual bool Init(IVehicle* pVehicle, const CVehicleParams& table) = 0;
// Summary:
// PostInit, e.g. for things that need full physicalization
virtual void PostInit() = 0;
// Summary:
// Change physicalization of the vehicle.
virtual void Physicalize() = 0;
// Summary:
// Post - physicalize.
virtual void PostPhysicalize() = 0;
// Summary:
// Resets the movement
virtual void Reset() = 0;
// Summary:
// Releases the movement
virtual void Release() = 0;
// Summary:
// Get movement type
virtual EVehicleMovementType GetMovementType() = 0;
// Summary:
// Resets any input previously active in the movement
virtual void ResetInput() = 0;
// Summary:
// Turn On the movement
// Description:
// It will soon be replaced by an event passed with the OnEvent function.
virtual bool StartEngine(EntityId driverId) = 0;
// Summary:
// Turn Off the movement
// Description:
// It will soon be replaced by an event passed with the OnEvent function.
virtual void StopEngine() = 0;
virtual bool IsPowered() = 0;
// Summary
// Returns the damage ratio of the engine
// Description
// Used to receive the damage ratio of the movement. The damage ratio of
// the movement may not reflect the damage ratio of the vehicle. The value
// is between 0 and 1.
// Returns
// The damage ratio
virtual float GetDamageRatio() = 0;
// Summary
// Gets number of wheel contacts, 0 if n/a
virtual int GetWheelContacts() const = 0;
// Summary:
// Sends an event message to the vehicle movement
// Description:
// Used by various code module of the vehicle system to notify the
// movement code of any appropriate change. A list of all the supported
// event can be found in the EVehicleMovementEvent enum.
// Parameters:
// event - event to be passed to the movement
// params - event parameters, e.g. damage value
virtual void OnEvent(EVehicleMovementEvent event, const SVehicleMovementEventParams& params) = 0;
virtual void OnAction(const TVehicleActionId actionId, int activationMode, float value) = 0;
// Summary:
// Updates all physics related to the movement
// Description:
// Will update the vehicle movement for a specified frame time. Unlike the
// Update function also present on the movement interface, this function is
// called from a callback function in CryPhysics rather than from
// IVehicle::Update. It's usually called at fixed interval and much more
// often than the Update function. This should only be used to update
// physics related attributes of the vehicle.
// Parameters:
// deltaTime - time in seconds of the update
virtual void ProcessMovement(const float deltaTime) = 0;
// Summary:
// Enables/disables movement processing
// Description:
// This allows disabling of the actual movement processing, while still
// have the engine running and process driver input, effects, etc.
// Useful for trackview sequences
virtual void EnableMovementProcessing(bool enable) = 0;
virtual bool IsMovementProcessingEnabled() = 0;
// Summary:
// Enables/disables engine's ability to start
virtual void DisableEngine(bool disable) = 0;
// Summary:
// Updates the movement
// Description:
// Will update the vehicle movement for a specified frame time. Unlike the
// ProcessMovement function, this function is called from the Update
// function of IVehicle.
// Parameters:
// deltaTime - time in seconds of the update
virtual void Update(const float deltaTime) = 0;
virtual void Serialize(TSerialize ser, EEntityAspects aspects) = 0;
virtual void SetAuthority(bool auth) = 0;
virtual void PostSerialize() = 0;
virtual void RequestActions(const SVehicleMovementAction& movementAction) = 0;
virtual bool RequestMovement(CMovementRequest& movementRequest) = 0;
virtual void GetMovementState(SMovementState& movementState) = 0;
virtual pe_type GetPhysicalizationType() const = 0;
virtual bool UseDrivingProxy() const = 0;
virtual void RegisterActionFilter(IVehicleMovementActionFilter* pActionFilter) = 0;
virtual void UnregisterActionFilter(IVehicleMovementActionFilter* pActionFilter) = 0;
virtual void ProcessEvent(SEntityEvent& event) = 0;
virtual void SetSoundMasterVolume(float vol) = 0;
virtual void GetMemoryUsage(ICrySizer * s) const = 0;
virtual void AllowBoosting(const bool allowBoosting) = 0;
virtual void SetMaxSpeed(const float maxSpeed) = 0;
};
// Summary
// Interface used to implement vehicle views
// Description
// A vehicle view is a camera implementation. Default implementations of a
// first person and third person camera are already available in the
// CryAction Dll.
struct IVehicleView
: public IVehicleObject
{
virtual bool Init(CVehicleSeat* pSeat, const CVehicleParams& table) = 0;
virtual void Reset() = 0;
virtual void Release() = 0;
virtual void ResetPosition() = 0;
// Summary
// Returns the name of the camera view
virtual const string& GetName() const = 0;
// Summary
// Indicates if the view implements a third person camera
virtual bool IsThirdPerson() = 0;
// Summary
// Indicates if the player body has been hidden
virtual bool IsPassengerHidden() = 0;
// Summary
// Performs tasks needed when the client start using this view
// Parameters
// playerId - EntityId of the player who will use the view
virtual void OnStartUsing(EntityId playerId) = 0;
// Summary
// Performs tasks needed when the client stop using this view
virtual void OnStopUsing() = 0;
virtual void OnAction(const TVehicleActionId actionId, int activationMode, float value) = 0;
virtual void UpdateView(SViewParams &viewParams, EntityId playerId = 0) = 0;
virtual void SetDebugView(bool debug) = 0;
virtual bool IsDebugView() = 0;
virtual bool ShootToCrosshair() = 0;
virtual bool IsAvailableRemotely() const = 0;
virtual void GetMemoryUsage(ICrySizer *pSizer) const =0;
virtual void OffsetPosition(const Vec3 &delta) = 0;
};
// Summary:
// Seat-dependent sound parameters
struct SSeatSoundParams
{
float inout; // [0..1], 0 means fully inside
float mood; // [0..1], 1 means fully active (inside!)
float moodCurr; // current value
SSeatSoundParams()
{
inout = 0.f;
mood = 0.f;
moodCurr = 0.f;
}
};
// Summary:
// Seat locking
enum EVehicleSeatLockStatus
{
eVSLS_Unlocked,
eVSLS_LockedForPlayers,
eVSLS_LockedForAI,
eVSLS_Locked,
};
// Summary:
// Vehicle Seat interface
UNIQUE_IFACE struct IVehicleSeat
{
enum EVehicleTransition
{
eVT_None = 0, // Assigned passenger is inside [9/21/2011 evgeny]
eVT_Entering,
eVT_Exiting,
eVT_ExitingWarped,
eVT_Dying,
eVT_SeatIsBorrowed,
eVT_RemoteUsage,
};
virtual ~IVehicleSeat(){}
virtual bool Init(IVehicle* pVehicle, TVehicleSeatId seatId, const CVehicleParams& paramsTable) = 0;
virtual void PostInit(IVehicle* pVehicle) = 0;
virtual void Reset() = 0;
virtual void Release() = 0;
// Summary
// Returns the seat name
// Returns
// a string with the name
virtual const char* GetSeatName() const = 0;
// Summary
// Returns the id of the seat
// Returns
// A seat id
virtual TVehicleSeatId GetSeatId() const = 0;
virtual EntityId GetPassenger(bool remoteUser=false) const = 0;
virtual int GetCurrentTransition() const = 0;
virtual TVehicleViewId GetCurrentView() const = 0;
virtual IVehicleView* GetView(TVehicleViewId viewId) const = 0;
virtual bool SetView(TVehicleViewId viewId) = 0;
virtual TVehicleViewId GetNextView(TVehicleViewId viewId) const = 0;
virtual bool IsDriver() const = 0;
virtual bool IsGunner() const = 0;
virtual bool IsLocked(IActor* pActor) const = 0;
virtual bool Enter(EntityId actorId, bool isTransitionEnabled = true) = 0;
virtual bool Exit(bool isTransitionEnabled, bool force=false, Vec3 exitPos=ZERO) = 0;
virtual void SetLocked(EVehicleSeatLockStatus status) = 0;
virtual void OnPassengerDeath() = 0;
virtual void ForceAnimGraphInputs() = 0;
virtual void UnlinkPassenger(bool ragdoll) = 0;
virtual bool IsPassengerHidden() const = 0;
virtual bool IsPassengerExposed() const = 0;
virtual bool ProcessPassengerMovementRequest(const CMovementRequest& movementRequest) = 0;
virtual IVehicle* GetVehicle() const = 0;
virtual IVehicleHelper* GetSitHelper() const = 0;
virtual IVehicleHelper* GetAIVisionHelper() const = 0;
virtual const SSeatSoundParams& GetSoundParams() const = 0;
virtual bool IsAnimGraphStateExisting(EntityId actorId) const = 0;
virtual void OnCameraShake(float& angleAmount, float& shiftAmount, const Vec3& pos, const char* source) const = 0;
virtual void ForceFinishExiting() = 0;
// Returns the name of the action map specified for this vehicle seat in
// the xml file (can be null if no specific seat actionmap)
virtual const char* GetActionMap() const = 0;
virtual void OffsetPosition(const Vec3 &delta) = 0;
};
// Summary:
// Vehicle Wheel interface
// Description:
// Interface providing wheel-specific access
UNIQUE_IFACE struct IVehicleWheel
{
virtual ~IVehicleWheel (){}
virtual int GetSlot() const = 0;
virtual int GetWheelIndex() const = 0;
virtual float GetTorqueScale() const = 0;
virtual float GetSlipFrictionMod(float slip) const = 0;
virtual const pe_cargeomparams* GetCarGeomParams() const = 0;
};
// Summary:
// Vehicle Part interface
// Description:
// Interface used to implement parts of a vehicle.
struct IVehiclePart
: public IVehicleObject
{
// Summary:
// Part event values
// Description:
// Values used by the type variable in SVehiclePartEvent.
enum EVehiclePartEvent
{
// the part got damaged, fparam will hold the damage ratio
eVPE_Damaged = 0,
// part gets repaired, fparam also holds damage ratio
eVPE_Repair,
// currently unused
eVPE_Physicalize,
// currently unused
eVPE_PlayAnimation,
// used to notify that the part geometry got modified and would need to be
// reloaded next time the part is reset
eVPE_GotDirty,
// toggle hide the part, fparam specify the amount of time until the requested effect is fully completed
eVPE_Hide,
// sent when driver entered the vehicle
eVPE_DriverEntered,
// sent when driver left
eVPE_DriverLeft,
// sent when part starts being used in turret (or similar) rotation
eVPE_StartUsing,
// sent when part starts being used in turret (or similar) rotation
eVPE_StopUsing,
// sent when rotations need to be blocked
eVPE_BlockRotation,
// sent when vehicle flips over. bParam is true when flipping, false when returning to normal orientation
eVPE_FlippedOver,
// used as a starting index for project specific part events
eVPE_OtherEvents,
};
enum EVehiclePartType
{
eVPT_Base = 0,
eVPT_Animated,
eVPT_AnimatedJoint,
eVPT_Static,
eVPT_SubPart,
eVPT_Wheel,
eVPT_Tread,
eVPT_Massbox,
eVPT_Light,
eVPT_Attachment,
eVPT_Entity,
eVPT_Last,
};
enum EVehiclePartState
{
eVGS_Default = 0,
eVGS_Damaged1,
eVGS_Destroyed,
eVGS_Last,
};
enum EVehiclePartStateFlags
{
eVPSF_Physicalize = 1<<0,
eVPSF_Force = 1<<1,
};
// Summary:
// Part event structure
// Description:
// This structure is used by the OnEvent function to pass message to
// vehicle parts.
struct SVehiclePartEvent
{
// message type value, usually defined in EVehiclePartEvent
EVehiclePartEvent type;
// c string parameter (optional)
const char* sparam;
// float parameter (optional)
float fparam;
bool bparam;
void* pData;
SVehiclePartEvent()
{
sparam = 0;
fparam = 0.f;
bparam = false;
pData = NULL;
}
};
// Summary:
// Initializes the vehicle part
// Description:
// Will initialize a newly allocated instance of the vehicle part class
// according to the parameter table which is passed. This function should only be called once.
// Parameters:
// pVehicle - pointer to the vehicle instance which will own this part
// table - script table which hold all the part parameters
// pParent - pointer to a parent part, or NULL if there isn't any parent
// part specified
// Return value:
// A boolean which indicate if the function succeeded
//virtual bool Init(IVehicle* pVehicle, const SmartScriptTable &table, IVehiclePart* pParent = NULL) = 0;
virtual void PostInit() = 0;
virtual void PostSerialize() = 0;
// Summary:
// Resets the vehicle part
// Description:
// Used to reset a vehicle part to its initial state. Is usually being
// called when the Editor enter and exit the game mode.
virtual void Reset() = 0;
// Summary:
// Releases the vehicle part
// Description:
// Used to release a vehicle part. A vehicle part implementation should
// then deallocate any memory or object that it dynamically allocated.
// In addition, the part implementation or its base class should include
// "delete this;".
virtual void Release() = 0;
virtual void GetMemoryUsage(ICrySizer *pSizer) const =0;
// Summary
// Retrieves a pointer of the parent part
// Return Value
// A pointer to the parent part, or NULL if there isn't any.
virtual IVehiclePart* GetParent(bool root=false) = 0;
// Summary
// Retrieves the name of the part
virtual const char* GetName() = 0;
// Summary
// Retrieves the entity which hold the vehicle part
// Description
// In most of the cases, the entity holding the vehicle part will be the vehicle entity itself.
virtual IEntity* GetEntity() = 0;
// Summary:
// Sends an event message to the vehicle part
// Description:
// Used to send different events to the vehicle part implementation. The
// EVehiclePartEvent enum lists several usual vehicle part events.
// Parameters:
// event - event to be passed to the part
virtual void OnEvent(const SVehiclePartEvent& event) = 0;
// Summary:
// Loads the geometry/character needed by the vehicle part
virtual bool ChangeState(EVehiclePartState state, int flags=0) = 0;
// Summary:
// Query the current state of the vehicle part
virtual EVehiclePartState GetState() const = 0;
// Summary:
// Sets material on the part
virtual void SetMaterial(IMaterial* pMaterial) = 0;
// Summary:
// Query the current state of the vehicle part
// Description:
// Obsolete. Will be changed soon in favor of an event passed by OnEvent.
virtual void Physicalize() = 0;
// Summary:
// Gets final local transform matrix
// Description:
// Will return the FINAL local transform matrix (with recoil etc) relative to parent part or vehicle space
// Return value:
// a 3x4 matrix
virtual const Matrix34& GetLocalTM(bool relativeToParentPart, bool forced = false) = 0;
// Summary:
// Gets the local base transform matrix
// Description:
// Will return the local BASE transform matrix (without recoil etc) relative to parent part
virtual const Matrix34& GetLocalBaseTM() = 0;
// Summary:
// Gets the initial base transform matrix
// Description:
// Will return the local transform matrix from the initial state of the model as relative to parent part
virtual const Matrix34& GetLocalInitialTM() = 0;
// Summary:
// Gets a world transform matrix
// Description:
// Will return a transform matrix world space.
// Return value:
// a 3x4 matrix
virtual const Matrix34& GetWorldTM() = 0;
// Summary:
// Sets local transformation matrix relative to parent part
// Description:
// This sets the FINAL local tm only. Usually you'll want to use SetLocalBaseTM
virtual void SetLocalTM(const Matrix34& localTM) = 0;
// Summary:
// Sets local base transformation matrix relative to parent part
// Description:
// This sets the local base tm.
virtual void SetLocalBaseTM(const Matrix34& localTM) = 0;
// Summary:
// Gets a local bounding box
// Description:
// Will return a local transform matrix relative to the vehicle space.
// Return value:
// a 3x4 matrix
virtual const AABB& GetLocalBounds() = 0;
// Summary:
// Obsolete function
// Description:
// Obsolete. Will be changed soon.
virtual void RegisterSerializer(IGameObjectExtension* gameObjectExt) = 0;
// Summary:
// Retrieve type id
virtual int GetType() = 0;
// Summary:
// Retrieve IVehicleWheel interface, or NULL
virtual IVehicleWheel* GetIWheel() = 0;
// Summary:
// Add part to child list
// Description:
// Used for part implementations that needs to keep track of their children
virtual void AddChildPart(IVehiclePart* pPart) = 0;
// Summary:
// Invalidate local transformation matrix
virtual void InvalidateTM(bool invalidate) = 0;
// Summary:
// Sets part as being moveable and/or rotateable
virtual void SetMoveable() = 0;
virtual const Vec3& GetDetachBaseForce() = 0;
virtual float GetMass() = 0;
virtual int GetPhysId() = 0;
virtual int GetSlot() = 0;
virtual int GetIndex() const = 0;
virtual TVehicleObjectId GetId() = 0;
virtual void Update(const float deltaTime) = 0;
virtual void Serialize(TSerialize ser, EEntityAspects aspects) = 0;
};
// Summary:
// Damage behavior events
// Description:
// Values used by the OnDamageEvent function
enum EVehicleDamageBehaviorEvent
{
// Used to transmit the hit values that the vehicle component took
eVDBE_Hit = 0,
// repair event
eVDBE_Repair,
// Sent once when max damage ratio is exceeded
eVDBE_MaxRatioExceeded,
// Obsolete, eVDBE_Hit should be used instead
eVDBE_ComponentDestroyed,
// Obsolete, eVDBE_Hit should be used instead
eVDBE_VehicleDestroyed,
};
// Summary
// Interface used to define different areas
// Description
// The most important use for the vehicle components is to define different
// region on the vehicle which have specific uses. A good example would be
// to have components on the vehicles which react to hit damage in different
// ways.
UNIQUE_IFACE struct IVehicleComponent
{
virtual ~IVehicleComponent(){}
// Summary
// Gets the name of the component
// Returns
// A c style string with the name of the component.
virtual const char* GetComponentName() const = 0;
// Summary
// Gets the number of vehicle parts which are linked to the vehicle
// Returns
// The number of parts
// See Also
// GetPart
virtual unsigned int GetPartCount() const = 0;
virtual IVehiclePart* GetPart(unsigned int index) const = 0;
// Summary:
// Get bounding box in vehicle space
virtual const AABB& GetBounds() = 0;
// Summary:
// Get current damage ratio
virtual float GetDamageRatio() const = 0;
// Summary:
// Set current damage ratio
virtual void SetDamageRatio(float ratio) = 0;
// Summary:
// Get max damage
virtual float GetMaxDamage() const = 0;
virtual void GetMemoryUsage(ICrySizer * s) const =0;
};
struct SVehicleDamageBehaviorEventParams
{
EntityId shooterId;
Vec3 localPos;
float radius;
float hitValue;
int hitType;
float componentDamageRatio;
float randomness;
IVehicleComponent* pVehicleComponent;
SVehicleDamageBehaviorEventParams()
{
shooterId = 0;
localPos.zero();
radius = 0.f;
hitValue = 0.f;
hitType = 0;
componentDamageRatio = 0.f;
randomness = 0.f;
pVehicleComponent = 0;
}
void Serialize(TSerialize ser, IVehicle* pVehicle)
{
ser.Value("shooterId", shooterId);
ser.Value("localPos", localPos);
ser.Value("radius", radius);
ser.Value("hitValue", hitValue);
ser.Value("componentDamageRatio", componentDamageRatio);
ser.Value("randomness", randomness);
string name;
if(ser.IsWriting())
name = pVehicleComponent->GetComponentName();
ser.Value("componentName", name);
if(ser.IsReading())
pVehicleComponent = pVehicle->GetComponent(name.c_str());
}
};
// Summary:
// Vehicle Damage Behavior interface
// Description:
// Interface used to implement a damage behavior for vehicles.
struct IVehicleDamageBehavior
: public IVehicleObject
{
// Summary:
// Initializes the damage behavior
// Description:
// Will initialize a newly allocated instance of the damage behavior class
// according to the parameter table which is passed. This function should
// only be called once.
// Parameters:
// pVehicle - pointer to the vehicle instance for which will own this
// damage behavior
// table - script table which hold all the parameters
// Return value:
// A boolean which indicate if the function succeeded
virtual bool Init(IVehicle* pVehicle, const CVehicleParams& table) = 0;
// Summary:
// Resets the damage behavior
// Description:
// Used to reset a damage behavior to its initial state. Is usually being
// called when the Editor enter and exit the game mode.
virtual void Reset() = 0;
// Summary:
// Releases the damage behavior
// Description:
// Used to release a damage behavior, usually at the same time than the
// vehicle is being released. A damage behavior implementation should
// then deallocate any memory or object that it dynamically allocated.
// In addition, the part implementation or its base class should include
// "delete this;".
virtual void Release() = 0;
virtual void GetMemoryUsage(ICrySizer *pSizer) const =0;
virtual TVehicleObjectId GetId() = 0;
virtual void Serialize(TSerialize ser, EEntityAspects aspects) = 0;
virtual void Update(const float deltaTime) = 0;
// Summary:
// Sends an event message to the damage behavior
// Description:
// Used to send different events to the damage behavior implementation.
// The EVehicleDamageBehaviorEvent enum lists all the event which a damage
// behavior can receive.
// Parameters:
// event - event type
// value - a float value used for the event
virtual void OnDamageEvent(EVehicleDamageBehaviorEvent event, const SVehicleDamageBehaviorEventParams& params) = 0;
};
// Summary
// Interface used to implement interactive elements for the player passenger
// Description
// The tank turret, headlights, vehicle weapons and steering wheels are all
// examples of vehicle seat actions.
struct IVehicleSeatAction
: public IVehicleObject
{
virtual bool Init(IVehicle* pVehicle, IVehicleSeat* pSeat, const CVehicleParams& table) = 0;
virtual void Reset() = 0;
virtual void Release() = 0;
virtual void StartUsing(EntityId passengerId) = 0;
virtual void ForceUsage() = 0;
virtual void StopUsing() = 0;
virtual void OnAction(const TVehicleActionId actionId, int activationMode, float value) = 0;
virtual void GetMemoryUsage(ICrySizer *pSizer) const =0;
// IVehicleObject
virtual TVehicleObjectId GetId() = 0;
virtual void Serialize(TSerialize ser, EEntityAspects aspects) = 0;
virtual void PostSerialize() = 0;
virtual void Update(const float deltaTime) = 0;
// ~IVehicleObject
virtual const char* GetName() const { return m_name.c_str(); }
string m_name;
};
// Summary
// Handles animations on the vehicle model
UNIQUE_IFACE struct IVehicleAnimation
{
virtual ~IVehicleAnimation(){}
virtual bool Init(IVehicle* pVehicle, const CVehicleParams& table) = 0;
virtual void Reset() = 0;
virtual void Release() = 0;
// Summary
// Triggers the animation to start
// Returns
// A bool which indicates the success
virtual bool StartAnimation() = 0;
// Summary
// Triggers the animation to stop
virtual void StopAnimation() = 0;
// Summary
// Performs a change of state
// Parameters
// stateId - An id of the state
// Remarks
// The function GetStateId can return an appropriate stateId which can be
// used as parameter for this function.
// Returns
// A bool which indicates if the state could be used
// See Also
// GetState
virtual bool ChangeState(TVehicleAnimStateId stateId) = 0;
// Summary
// Returns the current animation state
// Returns
// A stateId of the current animation state in use
// See Also
// ChangeState
virtual TVehicleAnimStateId GetState() = 0;
virtual string GetStateName(TVehicleAnimStateId stateId) = 0;
virtual TVehicleAnimStateId GetStateId(const string& name) = 0;
// Summary
// Changes the speed of the animation
// Parameters
// speed - a value between 0 to 1
virtual void SetSpeed(float speed) = 0;
// Summary
// Returns the current time in the animation
// Returns
// a value usually between 0 to 1
virtual float GetAnimTime(bool raw=false) = 0;
virtual void ToggleManualUpdate(bool isEnabled) = 0;
virtual bool IsUsingManualUpdates() = 0;
virtual void SetTime(float time, bool force=false) = 0;
virtual void GetMemoryUsage( ICrySizer *pSizer ) const=0;
};
UNIQUE_IFACE struct IVehicleDamagesGroup
{
virtual ~IVehicleDamagesGroup(){}
virtual bool ParseDamagesGroup(const CVehicleParams& table) = 0;
};
UNIQUE_IFACE struct IVehicleDamagesTemplateRegistry
{
virtual ~IVehicleDamagesTemplateRegistry(){}
virtual bool Init(const string& defaultDefFilename, const string& damagesTemplatesPath) = 0;
virtual void Release() = 0;
virtual bool RegisterTemplates(const string& filename, const string& defFilename) = 0;
virtual bool UseTemplate(const string& templateName, IVehicleDamagesGroup* pDamagesGroup) = 0;
};
struct IVehicleIterator
{
virtual ~IVehicleIterator(){}
virtual size_t Count() = 0;
virtual IVehicle* Next() = 0;
virtual void AddRef() = 0;
virtual void Release() = 0;
};
typedef _smart_ptr<IVehicleIterator> IVehicleIteratorPtr;
// Summary:
// Vehicle System interface
// Description:
// Interface used to implement the vehicle system.
UNIQUE_IFACE struct IVehicleSystem
{
DECLARE_GAMEOBJECT_FACTORY(IVehicleMovement);
DECLARE_GAMEOBJECT_FACTORY(IVehicleView);
DECLARE_GAMEOBJECT_FACTORY(IVehiclePart);
DECLARE_GAMEOBJECT_FACTORY(IVehicleDamageBehavior);
DECLARE_GAMEOBJECT_FACTORY(IVehicleSeatAction);
DECLARE_GAMEOBJECT_FACTORY(IVehicleAction);
virtual ~IVehicleSystem(){}
virtual bool Init() = 0;
virtual void Release() = 0;
virtual void Reset() = 0;
// Summary
// Performs the registration of all the different vehicle classes
// Description
// The vehicle system will read all the xml files which are inside the
// directory "Scripts/Entities/Vehicles/Implementations/Xml/". All the
// valid vehicle classes will be registered as game object extension with
// IGameObjectSystem.
//
// Several default vehicle parts, views, actions and
// damage behaviors classes are registered in this function as well.
// Parameters
// pGameFramework - A pointer to the game framework
virtual void RegisterVehicles(IGameFramework* pGameFramework) = 0;
// Summary:
// Spawns a new vehicle instance
// Description:
// Will spawn an entity based on the vehicle class requested. Usually
// called by the entity system when a vehicle entity is spawned.
// Arguments:
// channelId - Id of the intented channel
// name - Name of the new vehicle instance to be spawned
// vehicleClass - Name of the vehicle class requested
// pos - Position of the new vehicle instance
// rot - Rotation of the new vehicle instance
// scale - Scale factor of the new vehicle instance
// id - Unused
// Returns:
// A pointer to the correct vehicle proxy. The value 0 is returned in case
// that the specified vehicle couldn't be created.
virtual IVehicle* CreateVehicle(uint16 channelId, const char *name, const char *vehicleClass, const Vec3 &pos, const Quat &rot, const Vec3 &scale, EntityId id = 0) = 0;
// Summary:
// Gets the Vehicle proxy of an entity
// Description:
// Will return the correct vehicle proxy of a vehicle entity.
// Returns:
// A pointer to the correct vehicle proxy. The value 0 is returned in case
// that the proxy wasn't found.
virtual IVehicle* GetVehicle(EntityId entityId) = 0;
virtual IVehicle* GetVehicleByChannelId(uint16 channelId) = 0;
virtual const char* GetVehicleLightType(IVehiclePart* pVehiclePart) = 0;
virtual bool IsVehicleClass(const char *name) const = 0;
virtual IVehicleMovement* CreateVehicleMovement(const string& name) = 0;
virtual IVehicleView* CreateVehicleView(const string& name) = 0;
virtual IVehiclePart* CreateVehiclePart(const string& name) = 0;
virtual IVehicleDamageBehavior* CreateVehicleDamageBehavior(const string& name) = 0;
virtual IVehicleSeatAction* CreateVehicleSeatAction(const string& name) = 0;
virtual IVehicleAction* CreateVehicleAction(const string& name) = 0;
virtual IVehicleDamagesTemplateRegistry* GetDamagesTemplateRegistry() = 0;
virtual void GetVehicleImplementations(SVehicleImpls& impls) = 0;
virtual bool GetOptionalScript(const char* vehicleName, char* buf, size_t len) = 0;
// Summary
// Registers a newly spawned vehicle in the vehicle system
virtual void AddVehicle(EntityId entityId, IVehicle* pProxy) = 0;
// Summary
// Registers a newly removed vehicle in the vehicle system
virtual void RemoveVehicle(EntityId entityId) = 0;
virtual TVehicleObjectId AssignVehicleObjectId() = 0;
virtual TVehicleObjectId AssignVehicleObjectId(const string& className) = 0;
virtual TVehicleObjectId GetVehicleObjectId(const string& className) const = 0;
// Summary
// Used to get the count of all vehicle instance
// Returns
// The count of all the vehicle instance created by the vehicle system
virtual uint32 GetVehicleCount() = 0;
virtual IVehicleIteratorPtr CreateVehicleIterator() = 0;
// Summary
// Returns the vehicle client class implementation
// Returns
// A pointer to the current vehicle client implementation, or null
// if none as been registrated
// See Also
// RegisterVehicleClient
virtual IVehicleClient* GetVehicleClient() = 0;
// Summary
// Performs the registration of vehicle client implementation
// Parameters
// pVehicleClient - a pointer to the vehicle client implementation
// Notes
// Only one vehicle client implementation can be registrated
// See Also
// GetVehicleClient
virtual void RegisterVehicleClient(IVehicleClient* pVehicleClient) = 0;
// Summary
// Performs the registration of a class which wants to know when a specific player starts to use a vehicle
// Parameters
// playerId - the entity id of the player to listen for.
// pListener - a pointer to a listener object.
// See Also
// IVehicle::RegisterVehicleEventListener()
virtual void RegisterVehicleUsageEventListener(const EntityId playerId, IVehicleUsageEventListener* pEventListener ) = 0;
// Summary
// Unregisters class listening to the current player's vehicle.
// Parameters
// playerId - the entity id of the player that the listener is registered for.
// pListener - the pointer to be removed from the list of callbacks.
// See Also
// IVehicle::RegisterVehicleEventListener()
virtual void UnregisterVehicleUsageEventListener(const EntityId playerId, IVehicleUsageEventListener* pEventListener) = 0;
// Summary
// Announces OnUse events for vehicles.
// Parameters
// eventID - One of the events declared in EVehicleEvent, currently only eVE_PassengerEnter and eVE_PassengerExit
// playerId - the entity id of the player that the listener is registered for.
// pVehicle - the vehicle which the player is interacting.
// See Also
// RegisterVehicleUsageEventListener
// UnregisterVehicleEventListener
virtual void BroadcastVehicleUsageEvent(const EVehicleEvent eventId, const EntityId playerId, IVehicle* pVehicle) = 0;
virtual void Update(float deltaTime) = 0;
};
enum EVehicleDebugDraw
{
eVDB_General = 1,
eVDB_Particles = 2,
eVDB_Parts = 3,
eVDB_View = 4,
eVDB_Sounds = 5,
eVDB_PhysParts = 6,
eVDB_PhysPartsExt = 7,
eVDB_Damage = 8,
eVDB_Veed = 10,
};
// Summary
// Defines a position on a vehicle
// Description
// The vehicle helper object is used to define a position on a vehicle.
// Several components of the vehicle system use this object type to define
// position on the vehicle (ie: seat position, firing position on vehicle
// weapons). The Matrices are updated to reflect any changes in the position
// or orientation parent part.
UNIQUE_IFACE struct IVehicleHelper
{
virtual ~IVehicleHelper(){}
// Summary
// Releases the VehicleHelper instance
// Notes
// Should usually be only used by the implementation of IVehicle
virtual void Release() = 0;
// Summary
// Returns the helper matrix in local space
// Returns
// The Matrix34 holding the local space matrix
// Notes
// The matrix is relative to the parent part
// See Also
// GetParentPart, GetVehicleTM, GetWorldTM
virtual const Matrix34& GetLocalTM() const = 0;
// Summary
// Returns the helper matrix in vehicle space
// Returns
// The Matrix34 holding the vehicle space matrix
// See Also
// GetLocalTM, GetWorldTM
virtual void GetVehicleTM(Matrix34 &vehicleTM, bool forced = false) const = 0;
// Summary
// Returns the helper matrix in world space
// Returns
// The Matrix34 holding the world space matrix
// See Also
// GetLocalTM, GetVehicleTM, GetReflectedWorldTM
virtual void GetWorldTM(Matrix34 &worldTM) const = 0;
// Summary
// Returns the helper matrix in world space after reflecting the
// local translation across the yz plane (for left/right side of vehicle)
// Returns
// The Matrix34 holding the world space matrix
// See Also
// GetLocalTM, GetVehicleTM, GetWorldTM
virtual void GetReflectedWorldTM(Matrix34 &reflectedWorldTM) const = 0;
// Summary
// Returns the helper translation in local space
// Notes
// The matrix is relative to the parent part
virtual Vec3 GetLocalSpaceTranslation() const = 0;
// Summary
// Returns the helper translation in vehicle space
virtual Vec3 GetVehicleSpaceTranslation() const = 0;
// Summary
// Returns the helper translation in world space
virtual Vec3 GetWorldSpaceTranslation() const = 0;
// Summary
// Returns the parent part of the helper
// Returns
// A pointer to the parent part, which is never null
virtual IVehiclePart* GetParentPart() const = 0;
// tmp(will be pure virtual soon)
virtual void GetMemoryUsage( ICrySizer *pSizer ) const =0;
};
// Summary
// Handles game specific client/player tasks
// Description
// The implementation of the vehicle client class is used to perform
// game specific tasks related to the client player. For example,
// it can be used to store the last view used by the player on specific
// vehicle class or to filter game specific action types into vehicle
// ActionIds.
// Remarks
// Should be implemented inside the Game DLL. The game should call the
// function IVehicleSystem::RegisterVehicleClient during intialization.
UNIQUE_IFACE struct IVehicleClient
{
virtual ~IVehicleClient(){}
// Summary
// Initializes the vehicle client implementation
// Returns
// A bool representing the success of the initialization
virtual bool Init() = 0;
virtual void Reset() = 0;
// Summary
// Releases the vehicle client implementation
// Note
// Should only be called when the game is shutdown
virtual void Release() = 0;
// Summary
// Filters client actions
// Parameter
// pVehicle - vehicle instance used by the client
// actionId - ActionId sent
// activationMode - One of the different activation mode defined in EActionActivationMode
// value - value of the action
virtual void OnAction(IVehicle* pVehicle, EntityId actorId, const ActionId& actionId, int activationMode, float value) = 0;
// Summary
// Perform game specific tasks when the client enter a vehicle seat
// Parameters
// pSeat - instance of the new vehicle seat assigned to the client
// Note
// Is also called when the client switch to a different seats inside the
// same vehicle
virtual void OnEnterVehicleSeat(IVehicleSeat* pSeat) = 0;
// Summary
// Perform game specific tasks when the client exit a vehicle seat
// Parameters
// pSeat - instance of the new vehicle seat exited by the client
// Note
// Is also called when the client switch to a different seats inside the
// same vehicle
virtual void OnExitVehicleSeat(IVehicleSeat* pSeat) = 0;
};
#endif //__IVEHICLESYSTEM_H__
| [
"eliashogstvedt@gmail.com"
] | eliashogstvedt@gmail.com |
00c67b710c0b4687d9a28879caf2d77bafdd54d9 | 158e9058dcd3f4dc74beede425296b98daf46c1b | /Factory/Interface/Interface.cpp | 27e767abfb64040c27981aa919a1c75db80115f1 | [] | no_license | garlyon/MeetUp | 3e3fd7cf1d41b664ebc30416e7e2506a12a7e15c | f3d8e24d94ccf5812b7388b19f4ece86d55581d4 | refs/heads/master | 2020-12-05T06:59:05.773404 | 2016-09-13T13:29:10 | 2016-09-13T13:29:10 | 67,745,215 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 74 | cpp | #include "Interface.h"
Interface_NS::Interface::~Interface() = default;
| [
"aterekhov@aligntech.com"
] | aterekhov@aligntech.com |
9639348840e2b08f4fd542bce997440f4a73e3fa | a8f694bbffd5ef34d8b94a8dc31aa2d5ccea365b | /vigir_move_group/include/vigir_move_group/octomap_access_capability.h | 4db7152baeac2557444e9190fa65cc033995c7e4 | [] | no_license | kyawawa/vigir_manipulation_planning | bc326cbbe9554008d94e086b644fa8c40d63e611 | 537ffb38525f89073d64a457dfe78f9c6cc861ea | refs/heads/master | 2021-07-24T21:01:29.377864 | 2015-06-04T06:05:18 | 2015-06-04T06:05:18 | 109,773,079 | 0 | 0 | null | 2017-11-07T01:54:08 | 2017-11-07T01:54:08 | null | UTF-8 | C++ | false | false | 2,495 | h | /*********************************************************************
* Software License Agreement (BSD License)
*
* Copyright (c) 2014, SRI, Inc.
* 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 Willow Garage nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/
/* Author: David Hershberger */
#ifndef MOVEIT_MOVE_GROUP_CLEAR_OCTOMAP_SERVICE_CAPABILITY_
#define MOVEIT_MOVE_GROUP_CLEAR_OCTOMAP_SERVICE_CAPABILITY_
#include <moveit/move_group/move_group_capability.h>
#include <std_srvs/Empty.h>
namespace move_group
{
class OctomapAccessCapability : public MoveGroupCapability
{
public:
OctomapAccessCapability();
virtual void initialize();
private:
void visTimerCallback(const ros::TimerEvent& event);
ros::Timer vis_timer_;
ros::Publisher octomap_full_pub_;
// bool clearOctomap(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res);
// ros::ServiceServer service_;
};
}
#endif // MOVEIT_MOVE_GROUP_CLEAR_OCTOMAP_SERVICE_CAPABILITY_
| [
"kohlbrecher@sim.tu-darmstadt.de"
] | kohlbrecher@sim.tu-darmstadt.de |
7dad3cdcaff790fa2eb618b2e2b427df8bb60e35 | a5ecaf861aa1c1647a623dbf50fc04bd942d704d | /socket/tcp/tcp_cli.cpp | 49367b13b36c02768c1570d3560ee55ff2e51a83 | [] | no_license | yang1127/Linux | 80e55b48cd135dc432e68fe4b5c1736f096bccf3 | 9178ee62875a9972d938d125ad63766fb296be16 | refs/heads/master | 2021-01-01T13:59:08.245571 | 2020-05-19T19:53:25 | 2020-05-19T19:53:25 | 239,310,184 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 950 | cpp | #include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include "tcpsocket.hpp"
void sigcb(int signum)
{
printf("recv a signum:%d\n", signum);
}
int main(int argc, char *argv[])
{
if (argc != 3) {
std::cerr << "./tcp_cli ip port\n";
return -1;
}
signal(SIGPIPE, sigcb);
std::string ip = argv[1];
uint16_t port = atoi(argv[2]);
TcpSocket cli_sock;//客服端套接字
CHECK_RET(cli_sock.Socket());//创建套接字
CHECK_RET(cli_sock.Connect(ip, port));//连接服务器,不建议主动绑定地址信息
while(1) {
std::cout << "client say:";
fflush(stdout);
std::string buf;
std::cin >> buf;
CHECK_RET(cli_sock.Send(buf));//客户端发送数据
buf.clear();
CHECK_RET(cli_sock.Recv(buf));//客户端接收数据
std::cout << "server say:" << buf << "\n";
}
//关闭套接字
cli_sock.Close();
return 0;
}
| [
"1536520643@qq.com"
] | 1536520643@qq.com |
cba4678bb7afea2a7cf04e7a69888eedb3f7830f | 8f02939917edda1e714ffc26f305ac6778986e2d | /BOJ/21042/main.cc | 920986c164a49ef6b2a3309e5ea00e2cddd1672c | [] | no_license | queuedq/ps | fd6ee880d67484d666970e7ef85459683fa5b106 | d45bd3037a389495d9937afa47cf0f74cd3f09cf | refs/heads/master | 2023-08-18T16:45:18.970261 | 2023-08-17T17:04:19 | 2023-08-17T17:04:19 | 134,966,734 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 494 | cc | #include <bits/stdc++.h>
using namespace std;
// triangle edges (a, b, a+b)
// 1, 11, 12
// 3, 7, 10
// 4, 5, 9
// 2, 6, 8
vector<array<int, 3>> ans;
int main() {
int N = 25;
for (int i=0; i<N; i++) {
ans.push_back({i, i+1, i+12});
ans.push_back({i, i+3, i+10});
ans.push_back({i, i+4, i+9});
ans.push_back({i, i+2, i+8});
}
for (auto [a, b, c]: ans) {
a %= N, b %= N, c %= N;
cout << (char)('A'+a) << (char)('A'+b) << (char)('A'+c) << "\n";
}
return 0;
}
| [
"queuedq@gmail.com"
] | queuedq@gmail.com |
a391a6c3ec191fd564ccb51c477cd4b269f375b3 | bb7645bab64acc5bc93429a6cdf43e1638237980 | /Official Windows Platform Sample/Windows 8.1 Store app samples/[C++]-Windows 8.1 Store app samples/Search contract sample/C++/MainPage.xaml.cpp | 0be3a85bba33485986f280bf2b2310154fbd462b | [
"MIT"
] | permissive | Violet26/msdn-code-gallery-microsoft | 3b1d9cfb494dc06b0bd3d509b6b4762eae2e2312 | df0f5129fa839a6de8f0f7f7397a8b290c60ffbb | refs/heads/master | 2020-12-02T02:00:48.716941 | 2020-01-05T22:39:02 | 2020-01-05T22:39:02 | 230,851,047 | 1 | 0 | MIT | 2019-12-30T05:06:00 | 2019-12-30T05:05:59 | null | UTF-8 | C++ | false | false | 10,859 | cpp | //*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
//
// MainPage.xaml.cpp
// Implementation of the MainPage.xaml class.
//
#include "pch.h"
#include "MainPage.xaml.h"
#include "App.xaml.h"
#include <collection.h>
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Platform;
using namespace SDKSample;
using namespace Windows::UI::Xaml::Navigation;
using namespace Windows::UI::Xaml::Interop;
using namespace Windows::Graphics::Display;
using namespace Windows::UI::ViewManagement;
MainPage^ MainPage::Current = nullptr;
MainPage::MainPage()
{
InitializeComponent();
// This frame is hidden, meaning it is never shown. It is simply used to load
// each scenario page and then pluck out the input and output sections and
// place them into the UserControls on the main page.
HiddenFrame = ref new Windows::UI::Xaml::Controls::Frame();
HiddenFrame->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
LayoutRoot->Children->Append(HiddenFrame);
FeatureName->Text = FEATURE_NAME;
this->SizeChanged += ref new SizeChangedEventHandler(this, &MainPage::MainPage_SizeChanged);
Scenarios->SelectionChanged += ref new SelectionChangedEventHandler(this, &MainPage::Scenarios_SelectionChanged);
MainPage::Current = this;
}
/// <summary>
/// We need to handle SizeChanged so that we can make the sample layout property
/// in the various layouts.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void MainPage::MainPage_SizeChanged(Object^ sender, SizeChangedEventArgs^ e)
{
InvalidateSize();
MainPageSizeChangedEventArgs^ args = ref new MainPageSizeChangedEventArgs();
args->Width = this->ActualWidth;
MainPageResized(this, args);
}
void MainPage::InvalidateSize()
{
// Get the window width
double windowWidth = this->ActualWidth;
if (windowWidth != 0.0)
{
// Get the width of the ListBox.
double listBoxWidth = Scenarios->ActualWidth;
// Is the ListBox using any margins that we need to consider?
double listBoxMarginLeft = Scenarios->Margin.Left;
double listBoxMarginRight = Scenarios->Margin.Right;
// Figure out how much room is left after considering the list box width
double availableWidth = windowWidth - listBoxWidth;
// Is the top most child using margins?
double layoutRootMarginLeft = ContentRoot->Margin.Left;
double layoutRootMarginRight = ContentRoot->Margin.Right;
// We have different widths to use depending on the layout
if (windowWidth >= 768)
{
// Make us as big as the the left over space, factoring in the ListBox width, the ListBox margins.
// and the LayoutRoot's margins
InputSection->Width = ((availableWidth) -
(layoutRootMarginLeft + layoutRootMarginRight + listBoxMarginLeft + listBoxMarginRight));
}
else
{
// Make us as big as the left over space, factoring in just the LayoutRoot's margins.
InputSection->Width = (windowWidth - (layoutRootMarginLeft + layoutRootMarginRight));
}
}
InvalidateLayout();
}
void MainPage::InvalidateLayout()
{
if (this->ActualWidth < 768)
{
Grid::SetRow(DescriptionText, 3);
Grid::SetColumn(DescriptionText, 0);
Grid::SetRow(InputSection, 4);
Grid::SetColumn(InputSection, 0);
Grid::SetRow(FooterPanel, 2);
Grid::SetColumn(FooterPanel, 0);
}
else
{
Grid::SetRow(DescriptionText, 1);
Grid::SetColumn(DescriptionText, 1);
Grid::SetRow(InputSection, 2);
Grid::SetColumn(InputSection, 1);
Grid::SetRow(FooterPanel, 1);
Grid::SetColumn(FooterPanel, 1);
}
// Since we don't load the scenario page in the traditional manner (we just pluck out the
// input and output sections from the page) we need to ensure that any VSM code used
// by the scenario's input and output sections is fired.
VisualStateManager::GoToState(InputSection, "Input" + LayoutAwarePage::DetermineVisualState(this->ActualWidth), false);
VisualStateManager::GoToState(OutputSection, "Output" + LayoutAwarePage::DetermineVisualState(this->ActualWidth), false);
}
void MainPage::PopulateScenarios()
{
ScenarioList = ref new Platform::Collections::Vector<Object^>();
// Populate the ListBox with the list of scenarios as defined in Constants.cpp.
for (unsigned int i = 0; i < scenarios->Length; ++i)
{
Scenario s = scenarios[i];
ListBoxItem^ item = ref new ListBoxItem();
item->Name = s.ClassName;
item->Content = (i + 1).ToString() + ") " + s.Title;
ScenarioList->Append(item);
}
// Bind the ListBox to the scenario list.
Scenarios->ItemsSource = ScenarioList;
}
/// <summary>
/// This method is responsible for loading the individual input and output sections for each scenario. This
/// is based on navigating a hidden Frame to the ScenarioX.xaml page and then extracting out the input
/// and output sections into the respective UserControl on the main page.
/// </summary>
/// <param name="scenarioName"></param>
void MainPage::LoadScenario(String^ scenarioName)
{
// Load the ScenarioX.xaml file into the Frame.
TypeName scenarioType = {scenarioName, TypeKind::Custom};
HiddenFrame->Navigate(scenarioType, this);
// Get the top element, the Page, so we can look up the elements
// that represent the input and output sections of the ScenarioX file.
Page^ hiddenPage = safe_cast<Page^>(HiddenFrame->Content);
// Get each element.
UIElement^ input = safe_cast<UIElement^>(hiddenPage->FindName("Input"));
UIElement^ output = safe_cast<UIElement^>(hiddenPage->FindName("Output"));
if (input == nullptr)
{
// Malformed input section.
NotifyUser("Cannot load scenario input section for " + scenarioName +
" Make sure root of input section markup has x:Name of 'Input'", NotifyType::ErrorMessage);
return;
}
if (output == nullptr)
{
// Malformed output section.
NotifyUser("Cannot load scenario output section for " + scenarioName +
" Make sure root of output section markup has x:Name of 'Output'", NotifyType::ErrorMessage);
return;
}
// Find the LayoutRoot which parents the input and output sections in the main page.
Panel^ panel = safe_cast<Panel^>(hiddenPage->FindName("LayoutRoot"));
if (panel != nullptr)
{
unsigned int index = 0;
UIElementCollection^ collection = panel->Children;
// Get rid of the content that is currently in the intput and output sections.
collection->IndexOf(input, &index);
collection->RemoveAt(index);
collection->IndexOf(output, &index);
collection->RemoveAt(index);
// Populate the input and output sections with the newly loaded content.
InputSection->Content = input;
OutputSection->Content = output;
ScenarioLoaded(this, nullptr);
}
else
{
// Malformed Scenario file.
NotifyUser("Cannot load scenario: " + scenarioName + ". Make sure root tag in the '" +
scenarioName + "' file has an x:Name of 'LayoutRoot'", NotifyType::ErrorMessage);
}
}
void MainPage::Scenarios_SelectionChanged(Object^ sender, SelectionChangedEventArgs^ e)
{
if (Scenarios->SelectedItem != nullptr)
{
NotifyUser("", NotifyType::StatusMessage);
LoadScenario((safe_cast<ListBoxItem^>(Scenarios->SelectedItem))->Name);
InvalidateSize();
}
}
void MainPage::NotifyUser(String^ strMessage, NotifyType type)
{
switch (type)
{
case NotifyType::StatusMessage:
// Use the status message style.
StatusBlock->Style = safe_cast<Windows::UI::Xaml::Style^>(this->Resources->Lookup("StatusStyle"));
break;
case NotifyType::ErrorMessage:
// Use the error message style.
StatusBlock->Style = safe_cast<Windows::UI::Xaml::Style^>(this->Resources->Lookup("ErrorStyle"));
break;
default:
break;
}
StatusBlock->Text = strMessage;
// Collapsed the StatusBlock if it has no text to conserve real estate.
if (StatusBlock->Text != "")
{
StatusBlock->Visibility = Windows::UI::Xaml::Visibility::Visible;
}
else
{
StatusBlock->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
}
}
void MainPage::Footer_Click(Object^ sender, RoutedEventArgs^ e)
{
auto uri = ref new Uri((String^)((HyperlinkButton^)sender)->Tag);
Windows::System::Launcher::LaunchUriAsync(uri);
}
/// <summary>
/// Populates the page with content passed during navigation. Any saved state is also
/// provided when recreating a page from a prior session.
/// </summary>
/// <param name="navigationParameter">The parameter value passed to
/// <see cref="Frame::Navigate(Type, Object)"/> when this page was initially requested.
/// </param>
/// <param name="pageState">A map of state preserved by this page during an earlier
/// session. This will be null the first time a page is visited.</param>
void MainPage::LoadState(Object^ navigationParameter, IMap<String^, Object^>^ pageState)
{
(void) navigationParameter; // Unused parameter
PopulateScenarios();
// Starting scenario is the first or based upon a previous state.
ListBoxItem^ startingScenario = nullptr;
int startingScenarioIndex = -1;
if (pageState != nullptr && pageState->HasKey("SelectedScenarioIndex"))
{
startingScenarioIndex = safe_cast<int>(pageState->Lookup("SelectedScenarioIndex"));
}
Scenarios->SelectedIndex = startingScenarioIndex != -1 ? startingScenarioIndex : 0;
InvalidateLayout();
}
/// <summary>
/// Preserves state associated with this page in case the application is suspended or the
/// page is discarded from the navigation cache. Values must conform to the serialization
/// requirements of <see cref="SuspensionManager::SessionState"/>.
/// </summary>
/// <param name="pageState">An empty map to be populated with serializable state.</param>
void MainPage::SaveState(IMap<String^, Object^>^ pageState)
{
int selectedListBoxItemIndex = Scenarios->SelectedIndex;
pageState->Insert("SelectedScenarioIndex", selectedListBoxItemIndex);
}
| [
"v-tiafe@microsoft.com"
] | v-tiafe@microsoft.com |
500187127acea8095feb5e9e2d33d6855fbca810 | 955136ab4f9aaa8636ea968728800695a52267e2 | /Classes/TopMenu.cpp | 67131c45f932a12f6bd0d5e568e6282b6352c835 | [] | no_license | mengtest/clearstar | dfe9d0b06c3e1fb2eb796c0148fad6e32b7a072b | ac4b877c8b1acab377b87fb659cff77ea1b5cb27 | refs/heads/master | 2021-01-22T08:18:53.228663 | 2014-11-12T02:18:31 | 2014-11-12T02:18:31 | 27,822,840 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,960 | cpp | #include "TopMenu.h"
#include "Chinese.h"
#include "GameData.h"
bool TopMenu::init(){
if(!Node::init()){
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
highestScore = Label::create(
ChineseWord("highestScore") + cocos2d::String::createWithFormat("%d",GAMEDATA::getInstance()->getHistoryScore())->_string,
"Verdana-Bold",30
);
highestScore->setPosition(visibleSize.width/2,visibleSize.height - 50);
this->addChild(highestScore);
level = Label::create(
ChineseWord("guanqia") + cocos2d::String::createWithFormat("%d",GAMEDATA::getInstance()->getNextLevel())->_string,
"Verdana-Bold",30
);
level->setPosition(200,visibleSize.height - 100);
this->addChild(level);
targetScore = Label::create(
ChineseWord("mubiao") + cocos2d::String::createWithFormat("%d",GAMEDATA::getInstance()->getNextScore())->_string + ChineseWord("fen"),
"Verdana-Bold",30
);
targetScore->setPosition(400,visibleSize.height - 100);
this->addChild(targetScore);
curScore = Label::create(
cocos2d::String::createWithFormat("%d",GAMEDATA::getInstance()->getCurScore())->_string,
"Verdana-Bold",50
);
curScore->setPosition(visibleSize.width/2,visibleSize.height - 150);
this->addChild(curScore);
return true;
}
void TopMenu::refresh(){
char buf[64];
sprintf(buf,"%d",GAMEDATA::getInstance()->getCurScore());
curScore->setString(buf);
string history = ChineseWord("highestScore") + cocos2d::String::createWithFormat("%d",GAMEDATA::getInstance()->getHistoryScore())->_string;
highestScore->setString(history);
string guanqia = ChineseWord("guanqia") + cocos2d::String::createWithFormat("%d",GAMEDATA::getInstance()->getNextLevel())->_string;
level->setString(guanqia);
string target = ChineseWord("mubiao") + cocos2d::String::createWithFormat("%d",GAMEDATA::getInstance()->getNextScore())->_string + ChineseWord("fen");
targetScore->setString(target);
}
| [
"1213250243@qq.com"
] | 1213250243@qq.com |
f525f8f34c1e2c239c0a82b65de85663bf2a77a0 | 5286798f369775a6607636a7c97c87d2a4380967 | /thirdparty/cgal/CGAL-5.1/include/CGAL/Polynomial/polynomial_gcd.h | 3c7ac13206b1aecd1641dfc19682812489978449 | [
"GPL-3.0-only",
"LGPL-2.1-or-later",
"LicenseRef-scancode-proprietary-license",
"GPL-1.0-or-later",
"LGPL-2.0-or-later",
"MIT",
"LicenseRef-scancode-free-unknown",
"LicenseRef-scancode-unknown-license-reference",
"MIT-0",
"LGPL-3.0-only",
"LGPL-3.0-or-later"
] | permissive | MelvinG24/dust3d | d03e9091c1368985302bd69e00f59fa031297037 | c4936fd900a9a48220ebb811dfeaea0effbae3ee | refs/heads/master | 2023-08-24T20:33:06.967388 | 2021-08-10T10:44:24 | 2021-08-10T10:44:24 | 293,045,595 | 0 | 0 | MIT | 2020-09-05T09:38:30 | 2020-09-05T09:38:29 | null | UTF-8 | C++ | false | false | 16,900 | h | // Copyright (c) 2008 Max-Planck-Institute Saarbruecken (Germany).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL: https://github.com/CGAL/cgal/blob/v5.1/Polynomial/include/CGAL/Polynomial/polynomial_gcd.h $
// $Id: polynomial_gcd.h 0779373 2020-03-26T13:31:46+01:00 Sébastien Loriot
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
//
// Author(s) : Arno Eigenwillig <arno@mpi-inf.mpg.de>
// Tobias Reithmann <treith@mpi-inf.mpg.de>
// Michael Hemmer <hemmer@informatik.uni-mainz.de>
// Michael Kerber <mkerber@mpi-inf.mpg.de>
// Dominik Huelse <dominik.huelse@gmx.de>
// ============================================================================
/*! \file CGAL/Polynomial/polynomial_gcd.h
* \brief Greatest common divisors and related operations on polynomials.
*/
#ifndef CGAL_POLYNOMIAL_GCD_H
#define CGAL_POLYNOMIAL_GCD_H
#include <CGAL/config.h>
#ifndef CGAL_USE_INTERNAL_MODULAR_GCD
#define CGAL_USE_INTERNAL_MODULAR_GCD 1
#endif
#include <CGAL/basic.h>
#include <CGAL/Residue.h>
#include <CGAL/Polynomial.h>
#include <CGAL/Scalar_factor_traits.h>
#include <CGAL/Real_timer.h>
#include <CGAL/Polynomial/Polynomial_type.h>
#include <CGAL/Polynomial/misc.h>
#include <CGAL/Polynomial/polynomial_gcd_implementations.h>
#include <CGAL/polynomial_utils.h>
#ifdef CGAL_USE_NTL
#include <CGAL/Polynomial/polynomial_gcd_ntl.h>
#endif
#if CGAL_USE_INTERNAL_MODULAR_GCD
#include <CGAL/Polynomial/modular_gcd.h>
#endif
// 1) gcd (basic form without cofactors)
// uses three level of dispatch on tag types:
// a) if the algebra type of the innermost coefficient is a field,
// ask for decomposability. for UFDs compute the gcd directly
// b) if NT supports integralization, the gcd is computed on
// integralized polynomials
// c) over a field (unless integralized), use the Euclidean algorithm;
// over a UFD, use the subresultant algorithm
//
// NOTICE: For better performance, especially in AlciX, there exist special
// modular implementations for the polynmials with coefficient type
// leda::integer and the CORE::BigInt type which use, when the
// NTL library is available.
// see CGAL/Polynomial/polynomial_gcd_ntl.h
namespace CGAL {
namespace internal {
template <class NT>
inline
Polynomial<NT> gcd_(
const Polynomial<NT>& p1,
const Polynomial<NT>& p2,
Field_tag)
{
return CGAL::internal::gcd_utcf_(p1,p2);
}
template <class NT>
inline
Polynomial<NT> gcd_(
const Polynomial<NT>& p1,
const Polynomial<NT>& p2,
Unique_factorization_domain_tag)
{
typedef Polynomial<NT> POLY;
typedef Polynomial_traits_d<POLY> PT;
typedef typename PT::Innermost_coefficient_type IC;
typename PT::Multivariate_content mcont;
IC mcont_p1 = mcont(p1);
IC mcont_p2 = mcont(p2);
typename CGAL::Coercion_traits<POLY,IC>::Cast ictp;
POLY p1_ = CGAL::integral_division(p1,ictp(mcont_p1));
POLY p2_ = CGAL::integral_division(p2,ictp(mcont_p2));
return CGAL::internal::gcd_utcf_(p1_, p2_) * ictp(CGAL::gcd(mcont_p1, mcont_p2));
}
// name gcd() forwarded to the internal::gcd_() dispatch function
/*! \ingroup CGAL_Polynomial
* \relates CGAL::Polynomial
* \brief return the greatest common divisor of \c p1 and \c p2
*
* \pre Requires \c Innermost_coefficient_type to be a \c Field or a \c UFDomain.
*/
template <class NT>
inline
Polynomial<NT> gcd_(const Polynomial<NT>& p1, const Polynomial<NT>& p2)
{
typedef typename internal::Innermost_coefficient_type<Polynomial<NT> >::Type IC;
typedef typename Algebraic_structure_traits<IC>::Algebraic_category Algebraic_category;
// Filter for zero-polynomials
if( p1 == Polynomial<NT>(0) )
return p2;
if( p2 == Polynomial<NT>(0) )
return p1;
return internal::gcd_(p1,p2,Algebraic_category());
}
} // namespace internal
// 2) gcd_utcf computation
// (gcd up to scalar factors, for non-UFD non-field coefficients)
// a) first try to decompose the coefficients
// b) second dispatch depends on the algebra type of NT
namespace internal {
template <class NT> Polynomial<NT> inline
gcd_utcf_(const Polynomial<NT>& p1, const Polynomial<NT>& p2){
typedef CGAL::Fraction_traits< Polynomial<NT> > FT;
typedef typename FT::Is_fraction Is_fraction;
return gcd_utcf_is_fraction_(p1, p2, Is_fraction());
}
// is fraction ?
template <class NT> Polynomial<NT> inline
gcd_utcf_is_fraction_(
const Polynomial<NT>& p1,
const Polynomial<NT>& p2,
::CGAL::Tag_true)
{
typedef Polynomial<NT> POLY;
typedef Polynomial_traits_d<POLY> PT;
typedef Fraction_traits<POLY> FT;
typename FT::Denominator_type dummy;
typename FT::Numerator_type p1i, p2i;
typename FT::Decompose()(p1,p1i, dummy);
typename FT::Decompose()(p2,p2i, dummy);
typename Coercion_traits<POLY,typename FT::Numerator_type>::Cast cast;
return typename PT::Canonicalize()(cast(internal::gcd_utcf_(p1i, p2i)));
}
template <class NT> Polynomial<NT> inline
gcd_utcf_is_fraction_(
const Polynomial<NT>& p1,
const Polynomial<NT>& p2,
::CGAL::Tag_false)
{
typedef Algebraic_structure_traits< Polynomial<NT> > NTT;
typedef CGAL::Modular_traits<Polynomial<NT> > MT;
return gcd_utcf_modularizable_algebra_(
p1,p2,typename MT::Is_modularizable(),typename NTT::Algebraic_category());
}
// is type modularizable
template <class NT> Polynomial<NT> inline
gcd_utcf_modularizable_algebra_(
const Polynomial<NT>& p1,
const Polynomial<NT>& p2,
::CGAL::Tag_false,
Integral_domain_tag){
return internal::gcd_utcf_Integral_domain(p1, p2);
}
template <class NT> Polynomial<NT> inline
gcd_utcf_modularizable_algebra_(
const Polynomial<NT>& p1,
const Polynomial<NT>& p2,
::CGAL::Tag_false,
Unique_factorization_domain_tag){
return internal::gcd_utcf_UFD(p1, p2);
}
template <class NT> Polynomial<NT> inline
gcd_utcf_modularizable_algebra_(
const Polynomial<NT>& p1,
const Polynomial<NT>& p2,
::CGAL::Tag_false,
Euclidean_ring_tag){
return internal::gcd_Euclidean_ring(p1, p2);
}
#if CGAL_USE_INTERNAL_MODULAR_GCD
template <class NT> Polynomial<NT> inline
gcd_utcf_modularizable_algebra_(
const Polynomial<NT>& p1,
const Polynomial<NT>& p2,
::CGAL::Tag_true,
Integral_domain_tag tag){
return modular_gcd_utcf(p1, p2, tag);
}
template <class NT> Polynomial<NT> inline
gcd_utcf_modularizable_algebra_(
const Polynomial<NT>& p1,
const Polynomial<NT>& p2,
::CGAL::Tag_true,
Unique_factorization_domain_tag tag){
return modular_gcd_utcf(p1, p2, tag);
// return modular_gcd_utcf_algorithm_M(p1, p2);
}
#else
template <class NT> Polynomial<NT> inline
gcd_utcf_modularizable_algebra_(
const Polynomial<NT>& p1,
const Polynomial<NT>& p2,
::CGAL::Tag_true,
Integral_domain_tag){
return internal::gcd_utcf_Integral_domain(p1, p2);
}
template <class NT> Polynomial<NT> inline
gcd_utcf_modularizable_algebra_(
const Polynomial<NT>& p1,
const Polynomial<NT>& p2,
::CGAL::Tag_true,
Unique_factorization_domain_tag){
return internal::gcd_utcf_UFD(p1, p2);
}
#endif
template <class NT> Polynomial<NT> inline
gcd_utcf_modularizable_algebra_(
const Polynomial<NT>& p1,
const Polynomial<NT>& p2,
::CGAL::Tag_true,
Euclidean_ring_tag){
// No modular algorithm available
return internal::gcd_Euclidean_ring(p1, p2);
}
template <class NT> Polynomial<NT> inline
gcd_utcf(const Polynomial<NT>& p1, const Polynomial<NT>& p2){
return internal::gcd_utcf_(p1,p2);
}
} // namespace internal
// 3) extended gcd computation (with cofactors)
// with dispatch similar to gcd
namespace internal {
template <class NT>
inline
Polynomial<NT> gcdex_(
Polynomial<NT> x, Polynomial<NT> y,
Polynomial<NT>& xf, Polynomial<NT>& yf,
::CGAL::Tag_false
) {
typedef typename Algebraic_structure_traits<NT>::Algebraic_category Algebraic_category;
return gcdex_(x, y, xf, yf, Algebraic_category());
}
template <class NT>
inline
Polynomial<NT> gcdex_(
Polynomial<NT> x, Polynomial<NT> y,
Polynomial<NT>& xf, Polynomial<NT>& yf,
Field_tag
) {
/* The extended Euclidean algorithm for univariate polynomials.
* See [Cohen, 1993], algorithm 3.2.2
*/
typedef Polynomial<NT> POLY;
typename Algebraic_structure_traits<NT>::Integral_div idiv;
// handle trivial cases
if (x.is_zero()) {
if (y.is_zero()) CGAL_error_msg("gcdex(0,0) is undefined");
xf = NT(0); yf = idiv(NT(1), y.unit_part());
return yf * y;
}
if (y.is_zero()) {
yf = NT(0); xf = idiv(NT(1), x.unit_part());
return xf * x;
}
bool swapped = x.degree() < y.degree();
if (swapped) { POLY t = x; x = y; y = t; }
// main loop
POLY u = x, v = y, q, r, m11(1), m21(0), m21old;
for (;;) {
/* invariant: (i) There exist m12 and m22 such that
* u = m11*x + m12*y
* v = m21*x + m22*y
* (ii) and we have
* gcd(u,v) == gcd(x,y)
*/
// compute next element of remainder sequence
POLY::euclidean_division(u, v, q, r); // u == qv + r
if (r.is_zero()) break;
// update u and v while preserving invariant
u = v; v = r;
/* Since r = u - qv, this preserves invariant (part ii)
* and corresponds to the matrix assignment
* (u) = (0 1) (u)
* (v) (1 -q) (v)
*/
m21old = m21; m21 = m11 - q*m21; m11 = m21old;
/* This simulates the matching matrix assignment
* (m11 m12) = (0 1) (m11 m12)
* (m21 m22) (1 -q) (m21 m22)
* which preserves the invariant (part i)
*/
if (r.degree() == 0) break;
}
/* postcondition: invariant holds and v divides u */
// make gcd unit-normal
m21 /= v.unit_part(); v /= v.unit_part();
// obtain m22 such that v == m21*x + m22*y
POLY m22;
POLY::euclidean_division(v - m21*x, y, m22, r);
CGAL_assertion(r.is_zero());
// check computation
CGAL_assertion(v == m21*x + m22*y);
// return results
if (swapped) {
xf = m22; yf = m21;
} else {
xf = m21; yf = m22;
}
return v;
}
template <class NT>
inline
Polynomial<NT> gcdex_(
Polynomial<NT> x, Polynomial<NT> y,
Polynomial<NT>& xf, Polynomial<NT>& yf,
::CGAL::Tag_true
) {
typedef Polynomial<NT> POLY;
typedef typename CGAL::Fraction_traits<POLY>::Numerator_type INTPOLY;
typedef typename CGAL::Fraction_traits<POLY>::Denominator_type DENOM;
typedef typename INTPOLY::NT INTNT;
typename CGAL::Fraction_traits<POLY>::Decompose decompose;
typename CGAL::Fraction_traits<POLY>::Compose compose;
// rewrite x as xi/xd and y as yi/yd with integral polynomials xi, yi
DENOM xd, yd;
x.simplify_coefficients();
y.simplify_coefficients();
INTPOLY xi ,yi;
decompose(x,xi,xd);
decompose(y,yi,yd);
// compute the integral gcd with cofactors:
// vi = gcd(xi, yi); vfi*vi == xfi*xi + yfi*yi
INTPOLY xfi, yfi; INTNT vfi;
INTPOLY vi = pseudo_gcdex(xi, yi, xfi, yfi, vfi);
// proceed to vfi*v == xfi*x + yfi*y with v = gcd(x,y) (unit-normal)
POLY v = compose(vi, vi.lcoeff());
v.simplify_coefficients();
CGAL_assertion(v.unit_part() == NT(1));
vfi *= vi.lcoeff(); xfi *= xd; yfi *= yd;
// compute xf, yf such that gcd(x,y) == v == xf*x + yf*y
xf = compose(xfi, vfi);
yf = compose(yfi, vfi);
xf.simplify_coefficients();
yf.simplify_coefficients();
return v;
}
} // namespace internal
/*! \ingroup CGAL_Polynomial
* \relates CGAL::Polynomial
* \brief compute gcd with cofactors
*
* This function computes the gcd of polynomials \c p1 and \c p2
* along with two other polynomials \c f1 and \c f2 such that
* gcd(\e p1, \e p2) = <I>f1*p1 + f2*p2</I>. This is called
* <I>extended</I> gcd computation, and <I>f1, f2</I> are called
* <I>Bézout factors</I> or <I>cofactors</I>.
*
* CGALially, computation is performed ``denominator-free'' if
* supported by the coefficient type via \c CGAL::Fraction_traits
* (using \c pseudo_gcdex() ), otherwise the euclidean remainder
* sequence is used.
*
* \pre \c NT must be a \c Field.
*
* The result <I>d</I> is unit-normal,
* i.e. <I>d</I><TT>.lcoeff() == NT(1)</TT>.
*
*/
template <class NT>
inline
Polynomial<NT> gcdex(
Polynomial<NT> p1, Polynomial<NT> p2,
Polynomial<NT>& f1, Polynomial<NT>& f2
) {
typedef typename CGAL::Fraction_traits< Polynomial<NT> >
::Is_fraction Is_fraction;
return internal::gcdex_(p1, p2, f1, f2, Is_fraction());
}
/*! \ingroup CGAL_Polynomial
* \relates CGAL::Polynomial
* \brief compute gcd with ``almost'' cofactors
*
* This is a variant of \c exgcd() for use over non-field \c NT.
* It computes the gcd of polynomials \c p1 and \c p2
* along with two other polynomials \c f1 and \c f2 and a scalar \c v
* such that \e v * gcd(\e p1, \e p2) = <I>f1*p1 + f2*p2</I>,
* using the subresultant remainder sequence. That \c NT is not a field
* implies that one cannot achieve \e v = 1 for all inputs.
*
* \pre \c NT must be a \c UFDomain of scalars (not polynomials).
*
* The result is unit-normal.
*
*/
template <class NT>
inline
Polynomial<NT> pseudo_gcdex(
#ifdef DOXYGEN_RUNNING
Polynomial<NT> p1, Polynomial<NT> p2,
Polynomial<NT>& f2, Polynomial<NT>& f2, NT& v
#else
Polynomial<NT> x, Polynomial<NT> y,
Polynomial<NT>& xf, Polynomial<NT>& yf, NT& vf
#endif // DOXYGEN_RUNNING
) {
/* implemented using the extended subresultant algorithm
* for gcd computation with Bezout factors
*
* To understand this, you need to understand the computation of
* cofactors as in the basic extended Euclidean algorithm (see
* the code above of gcdex_(..., Field_tag)), and the subresultant
* gcd algorithm, see gcd_(..., Unique_factorization_domain_tag).
*
* The crucial point of the combination of both is the observation
* that the subresultant factor (called rho here) divided out of the
* new remainder in each step can also be divided out of the
* cofactors.
*/
typedef Polynomial<NT> POLY;
typename Algebraic_structure_traits<NT>::Integral_division idiv;
typename Algebraic_structure_traits<NT>::Gcd gcd;
// handle trivial cases
if (x.is_zero()) {
if (y.is_zero()) CGAL_error_msg("gcdex(0,0) is undefined");
xf = POLY(0); yf = POLY(1); vf = y.unit_part();
return y / vf;
}
if (y.is_zero()) {
xf = POLY(1); yf = POLY(0); vf = x.unit_part();
return x / vf;
}
bool swapped = x.degree() < y.degree();
if (swapped) { POLY t = x; x = y; y = t; }
// compute gcd of content
NT xcont = x.content(); NT ycont = y.content();
NT gcdcont = gcd(xcont, ycont);
// compute gcd of primitive parts
POLY xprim = x / xcont; POLY yprim = y / ycont;
POLY u = xprim, v = yprim, q, r;
POLY m11(1), m21(0), m21old;
NT g(1), h(1), d, rho;
for (;;) {
int delta = u.degree() - v.degree();
POLY::pseudo_division(u, v, q, r, d);
CGAL_assertion(d == ipower(v.lcoeff(), delta+1));
if (r.is_zero()) break;
rho = g * ipower(h, delta);
u = v; v = r / rho;
m21old = m21; m21 = (d*m11 - q*m21) / rho; m11 = m21old;
/* The transition from (u, v) to (v, r/rho) corresponds
* to multiplication with the matrix
* __1__ (0 rho)
* rho (d -q)
* The comments and correctness arguments from
* gcdex(..., Field_tag) apply analogously.
*/
g = u.lcoeff();
CGAL::internal::hgdelta_update(h, g, delta);
if (r.degree() == 0) break;
}
// obtain v == m21*xprim + m22*yprim
// the correct m21 was already computed above
POLY m22;
POLY::euclidean_division(v - m21*xprim, yprim, m22, r);
CGAL_assertion(r.is_zero());
// now obtain gcd(x,y) == gcdcont * v/v.content() == (m21*x + m22*y)/denom
NT vcont = v.content(), vup = v.unit_part();
v /= vup * vcont; v *= gcdcont;
m21 *= ycont; m22 *= xcont;
vf = idiv(xcont, gcdcont) * ycont * (vup * vcont);
CGAL_assertion(vf * v == m21*x + m22*y);
// return results
if (swapped) {
xf = m22; yf = m21;
} else {
xf = m21; yf = m22;
}
return v;
}
} // namespace CGAL
#endif // CGAL_POLYNOMIAL_GCD_H
// EOF
| [
"huxingyi@msn.com"
] | huxingyi@msn.com |
63e8c6c0c837171b6b9b9168718d8cfa406212ef | 7c9c12ecf62fdcfb19709240241e04041a871e01 | /Platform/Platform/map.h | 4e3002940e6b4e1c1d05a9c46d667f8788b9a99e | [] | no_license | sb5829/CS3113 | 63750907a5eb6c33cc4dbd2f0704ee4d11a6d398 | de27f1841d8c5fcb7ca10f53a7a8c21476647d81 | refs/heads/master | 2021-01-05T08:29:52.808852 | 2020-04-21T12:04:48 | 2020-04-21T12:04:48 | 240,954,200 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 954 | h | //
// map.h
// Platform
//
// Created by Angie Beck on 4/20/20.
// Copyright © 2020 sabrena beck. All rights reserved.
//
#pragma once
#define GL_SILENCE_DEPRECATION
#ifdef _WINDOWS
#include <GL/glew.h>
#endif
#define GL_GLTEXT_PROTYOTYPES 1
#include <vector>
#include <math.h>
#include <SDL.h>
#include <SDL_opengl.h>
#include <SDL_image.h>
#include "glm/mat4x4.hpp"
#include "glm/gtc/matrix_transform.hpp"
#include "ShaderProgram.h"
class Map {
int width;
int height;
unsigned int *levelData;
GLuint textureID;
float tile_size;
int tile_count_x;
int tile_count_y;
std::vector<float> vertices;
std::vector<float> textCoords;
float left_bound, right_bound, top_bound, bottom_bound;
public:
Map(int width, int height, unsigned int *levelData, GLuint textureID, float tile_size, int tile_count_x, int tile_count_y);
void Build();
void Render(ShaderProgram *program);
};
| [
"sb5829@nyu.edu"
] | sb5829@nyu.edu |
24702dce74fa420b41361090b54c68e05296f0a9 | c695ed452c9cc7bf6a8393a172dbc4391caae0bf | /spiral-matrix-ii/spiral-matrix-ii.cpp | d66a0c8d464cb931f2aeacebd54abd2ebfd6f084 | [] | no_license | prashanth-io/LeetCode | ccce6dbce01cbce34e7e9f774bafc05beabce4b1 | 4dab776c7fe3755ec43855671942b4badcadfd19 | refs/heads/main | 2023-08-13T02:18:33.952884 | 2021-09-30T21:02:47 | 2021-09-30T21:02:47 | 399,352,697 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 923 | cpp | class Solution {
public:
vector<vector<int>> generateMatrix(int n) {
int left=0;
int right=n-1;
int top=0;
int bottom=n-1;
int val=1;
vector<vector<int>>a(n,vector<int>(n));
while(val<=n*n)
{
for(int i=left;i<=right;i++)
{
a[top][i]=val++;
}
top++;
for(int i=top;i<=bottom;i++)
{
a[i][right]=val++;
}
right--;
if(top<=bottom)
{
for(int i=right;i>=left;i--)
{
a[bottom][i]=val++;
}
bottom--;
}
if(left<=right)
{
for(int i=bottom;i>=top;i--)
{
a[i][left]=val++;
}
left++;
}
}
return a;
}
}; | [
"86674577+prashanth-io@users.noreply.github.com"
] | 86674577+prashanth-io@users.noreply.github.com |
7973710e92ec1786dc7a9123ce656df5bb06f227 | ed71c7bc5e116282084713b0ec36b1370780f99e | /icu/source/i18n/format.cpp | 1e888657dbd8144e114245d0817e78281ea801a7 | [
"ICU",
"LicenseRef-scancode-unicode"
] | permissive | alexswider/dropup.brigade | 12e6a12f82a44e568f39b98bb0dbafee78c0c3f7 | 13fa5308c30786b5bba98564a0959b3c05343502 | refs/heads/master | 2021-01-18T22:20:51.901107 | 2016-04-25T18:46:27 | 2016-04-25T18:46:27 | 47,217,645 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,246 | cpp | /*
*******************************************************************************
* Copyright (C) 1997-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*
* File FORMAT.CPP
*
* Modification History:
*
* Date Name Description
* 02/19/97 aliu Converted from java.
* 03/17/97 clhuang Implemented with new APIs.
* 03/27/97 helena Updated to pass the simple test after code review.
* 07/20/98 stephen Added explicit init values for Field/ParsePosition
********************************************************************************
*/
// *****************************************************************************
// This file was generated from the java source file Format.java
// *****************************************************************************
#include <typeinfo> // for 'typeid' to work
#include "unicode/utypes.h"
/*
* Dummy code:
* If all modules in the I18N library are switched off, then there are no
* library exports and MSVC 6 writes a .dll but not a .lib file.
* Unless we export _something_ in that case...
*/
#if UCONFIG_NO_COLLATION && UCONFIG_NO_FORMATTING && UCONFIG_NO_TRANSLITERATION
U_CAPI int32_t U_EXPORT2
uprv_icuin_lib_dummy(int32_t i) {
return -i;
}
#endif
/* Format class implementation ---------------------------------------------- */
#if !UCONFIG_NO_FORMATTING
#include "unicode/format.h"
#include "unicode/ures.h"
#include "cstring.h"
#include "locbased.h"
// *****************************************************************************
// class Format
// *****************************************************************************
U_NAMESPACE_BEGIN
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(FieldPosition)
FieldPosition::~FieldPosition() {}
FieldPosition *
FieldPosition::clone() const {
return new FieldPosition(*this);
}
// -------------------------------------
// default constructor
Format::Format()
: UObject()
{
*validLocale = *actualLocale = 0;
}
// -------------------------------------
Format::~Format()
{
}
// -------------------------------------
// copy constructor
Format::Format(const Format &that)
: UObject(that)
{
*this = that;
}
// -------------------------------------
// assignment operator
Format&
Format::operator=(const Format& that)
{
if (this != &that) {
uprv_strcpy(validLocale, that.validLocale);
uprv_strcpy(actualLocale, that.actualLocale);
}
return *this;
}
// -------------------------------------
// Formats the obj and append the result in the buffer, toAppendTo.
// This calls the actual implementation in the concrete subclasses.
UnicodeString&
Format::format(const Formattable& obj,
UnicodeString& toAppendTo,
UErrorCode& status) const
{
if (U_FAILURE(status)) return toAppendTo;
FieldPosition pos(FieldPosition::DONT_CARE);
return format(obj, toAppendTo, pos, status);
}
// -------------------------------------
// Default implementation sets unsupported error; subclasses should
// override.
UnicodeString&
Format::format(const Formattable& /* unused obj */,
UnicodeString& toAppendTo,
FieldPositionIterator* /* unused posIter */,
UErrorCode& status) const
{
if (!U_FAILURE(status)) {
status = U_UNSUPPORTED_ERROR;
}
return toAppendTo;
}
// -------------------------------------
// Parses the source string and create the corresponding
// result object. Checks the parse position for errors.
void
Format::parseObject(const UnicodeString& source,
Formattable& result,
UErrorCode& status) const
{
if (U_FAILURE(status)) return;
ParsePosition parsePosition(0);
parseObject(source, result, parsePosition);
if (parsePosition.getIndex() == 0) {
status = U_INVALID_FORMAT_ERROR;
}
}
// -------------------------------------
UBool
Format::operator==(const Format& that) const
{
// Subclasses: Call this method and then add more specific checks.
return typeid(*this) == typeid(that);
}
//---------------------------------------
/**
* Simple function for initializing a UParseError from a UnicodeString.
*
* @param pattern The pattern to copy into the parseError
* @param pos The position in pattern where the error occured
* @param parseError The UParseError object to fill in
* @draft ICU 2.4
*/
void Format::syntaxError(const UnicodeString& pattern,
int32_t pos,
UParseError& parseError) {
parseError.offset = pos;
parseError.line=0; // we are not using line number
// for pre-context
int32_t start = (pos < U_PARSE_CONTEXT_LEN)? 0 : (pos - (U_PARSE_CONTEXT_LEN-1
/* subtract 1 so that we have room for null*/));
int32_t stop = pos;
pattern.extract(start,stop-start,parseError.preContext,0);
//null terminate the buffer
parseError.preContext[stop-start] = 0;
//for post-context
start = pos+1;
stop = ((pos+U_PARSE_CONTEXT_LEN)<=pattern.length()) ? (pos+(U_PARSE_CONTEXT_LEN-1)) :
pattern.length();
pattern.extract(start,stop-start,parseError.postContext,0);
//null terminate the buffer
parseError.postContext[stop-start]= 0;
}
Locale
Format::getLocale(ULocDataLocaleType type, UErrorCode& status) const {
U_LOCALE_BASED(locBased, *this);
return locBased.getLocale(type, status);
}
const char *
Format::getLocaleID(ULocDataLocaleType type, UErrorCode& status) const {
U_LOCALE_BASED(locBased, *this);
return locBased.getLocaleID(type, status);
}
void
Format::setLocaleIDs(const char* valid, const char* actual) {
U_LOCALE_BASED(locBased, *this);
locBased.setLocaleIDs(valid, actual);
}
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_FORMATTING */
//eof
| [
"marcinkozakk@gmail.com"
] | marcinkozakk@gmail.com |
981b5fc4771fc30d9418d700f8b580c14d883af2 | 55f96fe96191b78a766fd3adf45967183ea81578 | /bea/tuxedo8.1/include/xercesc/validators/datatype/YearMonthDatatypeValidator.hpp | 9e4f66ef12c5a4b52f37f6d041de9bbfe77a051b | [] | no_license | Billpro-Software/ninja-bea-tuxedo-8-1 | 79dd195acac94632beb948955a85480ce1bc0d63 | f6e85879a5053bfd4d1ad8e2f7d3c78aec21e802 | refs/heads/master | 2021-05-20T09:14:32.836968 | 2020-04-02T10:28:19 | 2020-04-02T10:28:19 | 252,208,511 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,644 | hpp | /*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* 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. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS 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.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: YearMonthDatatypeValidator.hpp,v 1.1 2002/05/11 21:32:57 bhavani Exp $
* $Log: YearMonthDatatypeValidator.hpp,v $
* Revision 1.1 2002/05/11 21:32:57 bhavani
* CR#CR062582# adding xercesc 1.7 file
*
* Revision 1.1.1.1 2002/02/01 22:22:43 peiyongz
* sane_include
*
* Revision 1.1 2001/11/07 19:18:52 peiyongz
* DateTime Port
*
*/
#if !defined(YEARMONTH_DATATYPE_VALIDATOR_HPP)
#define YEARMONTH_DATATYPE_VALIDATOR_HPP
#include <xercesc/validators/datatype/DateTimeValidator.hpp>
class VALIDATORS_EXPORT YearMonthDatatypeValidator : public DateTimeValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructor. */
//@{
YearMonthDatatypeValidator();
YearMonthDatatypeValidator(DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefVectorOf<XMLCh>* const enums
, const int finalSet);
~YearMonthDatatypeValidator();
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets
, RefVectorOf<XMLCh>* const enums
, const int finalSet);
protected:
// -----------------------------------------------------------------------
// implementation of (DateTimeValidator's) virtual interface
// -----------------------------------------------------------------------
virtual XMLDateTime* parse(const XMLCh* const);
};
/**
* End of file YearMonthDatatypeValidator.hpp
*/
#endif
| [
"raviv.shweid@telia.no"
] | raviv.shweid@telia.no |
d8f9446077ad65d62ef7e1af3c4cb4c332f11aab | 19b6b3ba07a68e9660d20e78f4fe1b2fda8aee12 | /Engine/engine/utils/math/Vector2.h | 48e2191dbc5570127f19e59ef2014f42c84ce037 | [] | no_license | Jmack66/protegon | 1621d7f97730ece22eb98e7af4866468e991217e | b4c7bbc138d662d27111179c75df0168b2dbd456 | refs/heads/master | 2023-07-18T15:24:56.160891 | 2021-01-28T02:54:03 | 2021-01-28T02:54:03 | 263,612,955 | 0 | 0 | null | 2020-05-13T11:42:04 | 2020-05-13T11:42:04 | null | UTF-8 | C++ | false | false | 20,678 | h | #pragma once
#include <algorithm> // std::swap
#include <iostream> // std::ostream, std::istream
#include <type_traits> // std::is_arithmetic_v, std::is_convertible_v, std::enable_if_t, std::common_type
#include <random> // std::minstd_rand, std::uniform_real_distribution, std::uniform_int_distribution
#include <string> // std::string
#include <limits> // std::numeric_limits
#include <cmath> // std::round
#include <cstdint> // std::int32_t, etc
#include <cstdlib> // std::size_t
#include <cassert> // assert
#include "utils/math/MathFunctions.h"
// TODO: Write tests for clamp.
// TODO: Write tests for lerp.
// Hidden vector related implementations.
namespace internal {
// Vector stream output / input delimeters, allow for consistent serialization / deserialization.
static constexpr const char VECTOR_LEFT_DELIMETER = '(';
static constexpr const char VECTOR_CENTER_DELIMETER = ',';
static constexpr const char VECTOR_RIGHT_DELIMETER = ')';
} // namespace internal
template <class T, engine::type_traits::is_number<T> = true>
struct Vector2 {
// Zero construction by default.
T x{ 0 };
T y{ 0 };
Vector2() = default;
~Vector2() = default;
// Allow construction from two different types, cast to the vector type.
template <typename U, typename V, engine::type_traits::is_number<U> = true, engine::type_traits::is_number<V> = true>
Vector2(U x, V y) : x{ static_cast<T>(x) }, y{ static_cast<T>(y) } {}
// Constructing vector from string used for deserializing vectors.
// Important: we assume that the string has already been filtered down to just the vector characters (no whitespace around).
Vector2(const std::string& s) {
assert(s.at(0) == internal::VECTOR_LEFT_DELIMETER && "Vector2 construction string must start with VECTOR_LEFT_DELIMETER, check for possible whitespace");
assert(s.at(s.size() - 1) == internal::VECTOR_RIGHT_DELIMETER && "Vector2 construction string must end with VECTOR_RIGHT_DELIMETER, check for possible whitespace");
// Find the index of the center delimeter from the string.
auto center_delimeter = s.find(internal::VECTOR_CENTER_DELIMETER);
assert(center_delimeter != std::string::npos && "Vector2 construction string must contain VECTOR_CENTER_DELIMETER");
assert(s.find('\n') == std::string::npos && "Vector2 construction string cannot contain any newlines");
assert(s.find(' ') == std::string::npos && "Vector2 construction string cannot contain any whitespace");
// Find the substring from after the left delimeter to right before the center delimeter.
// Then turn into double and cast to the appropriate type.
x = static_cast<T>(std::stod(std::move(s.substr(1, center_delimeter - 1))));
// Find the substring from after the center delimeter until the end of the string, excluding the right delimeter.
// Then turn into double and cast to the appropriate type.
y = static_cast<T>(std::stod(std::move(s.substr(center_delimeter + 1, s.size() - 2))));
}
// Copy / assignment construction.
Vector2(const Vector2& vector) = default;
Vector2(Vector2&& vector) = default;
Vector2& operator=(const Vector2& rhs) = default;
Vector2& operator=(Vector2&& rhs) = default;
// Unary increment / decrement / minus operators.
Vector2& operator++() {
++x; ++y;
return *this;
}
Vector2 operator++(int) {
Vector2 tmp(*this);
operator++();
return tmp;
}
Vector2& operator--() {
--x; --y;
return *this;
}
Vector2 operator--(int) {
Vector2 tmp(*this);
operator--();
return tmp;
}
/*Vector2& operator-() {
x *= -1; y *= -1;
return *this;
}*/
Vector2 operator-() const {
return { -x, -y };
}
// Arithmetic operators between vectors.
template <typename U, engine::type_traits::convertible<U, T> = true>
Vector2& operator+=(const Vector2<U>& rhs) {
x += static_cast<T>(rhs.x);
y += static_cast<T>(rhs.y);
return *this;
}
template <typename U, engine::type_traits::convertible<U, T> = true>
Vector2& operator-=(const Vector2<U>& rhs) {
x -= static_cast<T>(rhs.x);
y -= static_cast<T>(rhs.y);
return *this;
}
template <typename U, engine::type_traits::convertible<U, T> = true>
Vector2& operator*=(const Vector2<U>& rhs) {
x *= static_cast<T>(rhs.x);
y *= static_cast<T>(rhs.y);
return *this;
}
template <typename U, engine::type_traits::convertible<U, T> = true>
Vector2& operator/=(const Vector2<U>& rhs) {
if (rhs.x) {
x /= static_cast<T>(rhs.x);
} else {
x = std::numeric_limits<T>::infinity();
}
if (rhs.y) {
y /= static_cast<T>(rhs.y);
} else {
y = std::numeric_limits<T>::infinity();
}
return *this;
}
// Arithmetic operators with basic types.
template <typename U, engine::type_traits::is_number<U> = true, engine::type_traits::convertible<U, T> = true>
Vector2& operator+=(U rhs) {
x += static_cast<T>(rhs);
y += static_cast<T>(rhs);
return *this;
}
template <typename U, engine::type_traits::is_number<U> = true, engine::type_traits::convertible<U, T> = true>
Vector2& operator-=(U rhs) {
x -= static_cast<T>(rhs);
y -= static_cast<T>(rhs);
return *this;
}
template <typename U, engine::type_traits::is_number<U> = true, engine::type_traits::convertible<U, T> = true>
Vector2& operator*=(U rhs) {
x *= static_cast<T>(rhs);
y *= static_cast<T>(rhs);
return *this;
}
template <typename U, engine::type_traits::is_number<U> = true, engine::type_traits::convertible<U, T> = true>
Vector2& operator/=(U rhs) {
if (rhs) {
x /= static_cast<T>(rhs);
y /= static_cast<T>(rhs);
} else {
x = std::numeric_limits<T>::infinity();
y = std::numeric_limits<T>::infinity();
}
return *this;
}
// Accessor operators.
// Access vector elements by index, 0 for x, 1 for y. (reference)
T& operator[](std::size_t idx) {
assert(idx < 2 && "Vector2 subscript out of range");
if (idx == 0) {
return x;
}
return y; // idx == 1
}
// Access vector elements by index, 0 for x, 1 for y. (constant)
T operator[](std::size_t idx) const {
assert(idx < 2 && "Vector2 subscript out of range");
if (idx == 0) {
return x;
}
return y; // idx == 1
}
// Explicit conversion from this vector to other arithmetic type vectors.
/*template <typename U, engine::type_traits::is_number<U> = true, engine::type_traits::convertible<T, U> = true>
explicit operator Vector2<U>() const { return Vector2<U>{ static_cast<U>(x), static_cast<U>(y) }; }*/
// Implicit conversion from this vector to other arithmetic types which are less wide.
operator Vector2<int>() const { return Vector2<int>{ static_cast<int>(x), static_cast<int>(y) };
}
operator Vector2<double>() const { return Vector2<double>{ static_cast<double>(x), static_cast<double>(y) }; }
operator Vector2<float>() const { return Vector2<float>{ static_cast<float>(x), static_cast<float>(y) }; }
operator Vector2<unsigned int>() const { return Vector2<unsigned int>{ static_cast<unsigned int>(x), static_cast<unsigned int>(y) }; }
// Vector specific utility functions start here.
// Return true if both vector components equal 0.
inline bool IsZero() const {
return !x && !y;
}
// Return true if either vector component equals 0.
inline bool HasZero() const {
return !x || !y;
}
friend inline void Swap(Vector2& lhs, Vector2& rhs) {
std::swap(lhs.x, rhs.x);
std::swap(lhs.y, rhs.y);
}
// Return true if both vector components equal numeric limits infinity.
inline bool IsInfinite() const {
if constexpr (std::is_floating_point_v<T>) {
return x == std::numeric_limits<T>::infinity() && y == std::numeric_limits<T>::infinity();
}
return false;
}
// Return true if either vector component equals numeric limits infinity.
inline bool HasInfinity() const {
if constexpr (std::is_floating_point_v<T>) {
return x == std::numeric_limits<T>::infinity() || y == std::numeric_limits<T>::infinity();
}
return false;
}
// Return a vector with numeric_limit::infinity() set for both components
static Vector2 Infinite() {
static_assert(std::is_floating_point_v<T>, "Cannot create infinite vector for integer type. Must use floating points.");
return Vector2{ std::numeric_limits<T>::infinity(), std::numeric_limits<T>::infinity() };
}
// Return a vector with both components randomized in the given ranges.
static Vector2 Random(T min_x = 0.0, T max_x = 1.0, T min_y = 0.0, T max_y = 1.0) {
assert(min_x < max_x && "Minimum random value must be less than maximum random value");
assert(min_y < max_y && "Minimum random value must be less than maximum random value");
std::minstd_rand gen(std::random_device{}());
// Vary distribution type based on template parameter type.
if constexpr (std::is_floating_point_v<T>) {
// TODO: Possible to combine these using different seed?
std::uniform_real_distribution<T> dist_x(min_x, max_x);
std::uniform_real_distribution<T> dist_y(min_y, max_y);
return { dist_x(gen), dist_y(gen) };
} else if constexpr (std::is_integral_v<T>) {
std::uniform_int_distribution<T> dist_x(min_x, max_x);
std::uniform_int_distribution<T> dist_y(min_y, max_y);
return { dist_x(gen), dist_y(gen) };
}
assert(!"Incorrect type to random vector function");
return {};
}
// Return 2D vector projection (dot product).
template <typename U, typename S = typename std::common_type<T, U>::type>
inline S DotProduct(const Vector2<U>& other) const {
return static_cast<S>(x) * static_cast<S>(other.x) + static_cast<S>(y) * static_cast<S>(other.y);
}
// Return area of cross product between x and y components.
template <typename U, typename S = typename std::common_type<T, U>::type>
inline S CrossProduct(const Vector2<U>& other) const {
return static_cast<S>(x) * static_cast<S>(other.y) - static_cast<S>(y) * static_cast<S>(other.x);
}
template <typename U, typename S = typename std::common_type<T, U>::type>
inline Vector2<S> CrossProduct(U value) {
return { static_cast<S>(value) * static_cast<S>(y), -static_cast<S>(value) * static_cast<S>(x) };
}
// Return a unit vector (normalized).
inline auto Unit() const {
// Cache magnitude calculation.
auto m = Magnitude();
// Avoid division by zero error for zero magnitude vectors.
if (m > DBL_EPSILON) {
return *this / m;
}
using U = decltype(*this / m);
return static_cast<U>(*this);
}
// Return normalized (unit) vector.
inline auto Normalized() const {
return Unit();
}
// Return identity vector, both components must be 0, 1 or -1.
inline Vector2 Identity() const {
return { engine::math::Sign(x), engine::math::Sign(y) };
}
// Return tangent vector, (x, y) -> (y, -x).
inline Vector2 Tangent() const {
return { y, -x };
}
// Flip signs of both vector components, (x, y) -> (-x, -y).
inline Vector2 Opposite() const {
return -(*this);
}
// Return magnitude squared, x * x + y * y.
inline T MagnitudeSquared() const {
return x * x + y * y;
}
// Return magnitude, sqrt(x * x + y * y).
inline double Magnitude() const {
return std::sqrt(MagnitudeSquared());
}
};
// Common vector aliases.
using V2_int = Vector2<int>;
using V2_uint = Vector2<unsigned int>;
using V2_double = Vector2<double>;
using V2_float = Vector2<float>;
// Bitshift / stream operators.
template <typename T>
std::ostream& operator<<(std::ostream& os, const Vector2<T>& obj) {
os << internal::VECTOR_LEFT_DELIMETER << obj.x << internal::VECTOR_CENTER_DELIMETER << obj.y << internal::VECTOR_RIGHT_DELIMETER;
return os;
}
template <typename T>
std::istream& operator>>(std::istream& is, Vector2<T>& obj) {
std::string tmp;
// Pass istream into string.
is >> tmp;
// Construct object from string.
obj = std::move(Vector2<T>{ tmp });
return is;
}
// Comparison operators.
template <typename T, typename U, typename S = typename std::common_type<T, U>::type>
inline bool operator==(const Vector2<T>& lhs, const Vector2<U>& rhs) {
return static_cast<S>(lhs.x) == static_cast<S>(rhs.x) && static_cast<S>(lhs.y) == static_cast<S>(rhs.y);
}
template <typename T, typename U>
inline bool operator!=(const Vector2<T>& lhs, const Vector2<U>& rhs) {
return !operator==(lhs, rhs);
}
template <typename T, typename U, engine::type_traits::is_number<U> = true, typename S = typename std::common_type<T, U>::type>
inline bool operator==(const Vector2<T>& lhs, U rhs) {
return static_cast<S>(lhs.x) == static_cast<S>(rhs) && static_cast<S>(lhs.y) == static_cast<S>(rhs);
}
template <typename T, typename U, engine::type_traits::is_number<U> = true>
inline bool operator!=(const Vector2<T>& lhs, U rhs) {
return !operator==(lhs, rhs);
}
template <typename T, typename U, engine::type_traits::is_number<U> = true>
inline bool operator==(U lhs, const Vector2<T>& rhs) {
return operator==(rhs, lhs);
}
template <typename T, typename U, engine::type_traits::is_number<U> = true>
inline bool operator!=(U lhs, const Vector2<T>& rhs) {
return !operator==(rhs, lhs);
}
/*
// Possibly include these comparisons in the future.
template <typename T>
inline bool operator< (const Vector2<T>& lhs, const Vector2<T>& rhs) { return lhs.x < rhs.x && lhs.y < rhs.y; }
template <typename T>
inline bool operator> (const Vector2<T>& lhs, const Vector2<T>& rhs) { return operator< (rhs, lhs); }
template <typename T>
inline bool operator<=(const Vector2<T>& lhs, const Vector2<T>& rhs) { return !operator> (lhs, rhs); }
template <typename T>
inline bool operator>=(const Vector2<T>& lhs, const Vector2<T>& rhs) { return !operator< (lhs, rhs); }
*/
// Binary arithmetic operators between two vectors.
template <typename T, typename U>
Vector2<typename std::common_type<T, U>::type> operator+(const Vector2<T>& lhs, const Vector2<U>& rhs) {
return { lhs.x + rhs.x, lhs.y + rhs.y };
}
template <typename T, typename U>
Vector2<typename std::common_type<T, U>::type> operator-(const Vector2<T>& lhs, const Vector2<U>& rhs) {
return { lhs.x - rhs.x, lhs.y - rhs.y };
}
template <typename T, typename U>
Vector2<typename std::common_type<T, U>::type> operator*(const Vector2<T>& lhs, const Vector2<U>& rhs) {
return { lhs.x * rhs.x, lhs.y * rhs.y };
}
template <typename T, typename U, typename S = typename std::common_type<T, U>::type>
Vector2<S> operator/(const Vector2<T>& lhs, const Vector2<U>& rhs) {
Vector2<S> vector;
if (rhs.x) {
vector.x = lhs.x / rhs.x;
} else {
vector.x = std::numeric_limits<S>::infinity();
}
if (rhs.y) {
vector.y = lhs.y / rhs.y;
} else {
vector.y = std::numeric_limits<S>::infinity();
}
return vector;
}
// Binary arithmetic operators with a basic type.
template <typename T, typename U, engine::type_traits::is_number<T> = true>
Vector2<typename std::common_type<T, U>::type> operator+(T lhs, const Vector2<U>& rhs) {
return { lhs + rhs.x, lhs + rhs.y };
}
template <typename T, typename U, engine::type_traits::is_number<T> = true>
Vector2<typename std::common_type<T, U>::type> operator-(T lhs, const Vector2<U>& rhs) {
return { lhs - rhs.x, lhs - rhs.y };
}
template <typename T, typename U, engine::type_traits::is_number<T> = true>
Vector2<typename std::common_type<T, U>::type> operator*(T lhs, const Vector2<U>& rhs) {
return { lhs * rhs.x, lhs * rhs.y };
}
template <typename T, typename U, engine::type_traits::is_number<T> = true, typename S = typename std::common_type<T, U>::type>
Vector2<S> operator/(T lhs, const Vector2<U>& rhs) {
Vector2<S> vector;
if (rhs.x) {
vector.x = lhs / rhs.x;
} else {
vector.x = std::numeric_limits<S>::infinity();
}
if (rhs.y) {
vector.y = lhs / rhs.y;
} else {
vector.y = std::numeric_limits<S>::infinity();
}
return vector;
}
template <typename T, typename U, engine::type_traits::is_number<U> = true>
Vector2<typename std::common_type<T, U>::type> operator+(const Vector2<T>& lhs, U rhs) {
return { lhs.x + rhs, lhs.y + rhs };
}
template <typename T, typename U, engine::type_traits::is_number<U> = true>
Vector2<typename std::common_type<T, U>::type> operator-(const Vector2<T>& lhs, U rhs) {
return { lhs.x - rhs, lhs.y - rhs };
}
template <typename T, typename U, engine::type_traits::is_number<U> = true>
Vector2<typename std::common_type<T, U>::type> operator*(const Vector2<T>& lhs, U rhs) {
return { lhs.x * rhs, lhs.y * rhs };
}
template <typename T, typename U, engine::type_traits::is_number<U> = true, typename S = typename std::common_type<T, U>::type>
Vector2<S> operator/(const Vector2<T>& lhs, U rhs) {
Vector2<S> vector;
if (rhs) {
vector.x = lhs.x / rhs;
vector.y = lhs.y / rhs;
} else {
vector.x = std::numeric_limits<S>::infinity();
vector.y = std::numeric_limits<S>::infinity();
}
return vector;
}
// Special functions.
// Return the absolute value of both vectors components.
template <typename T>
inline Vector2<T> Abs(const Vector2<T>& vector) {
return { engine::math::Abs(vector.x), engine::math::Abs(vector.y) };
}
// Return the distance squared between two vectors.
template <typename T, typename U, typename S = typename std::common_type<T, U>::type>
inline S DistanceSquared(const Vector2<T>& lhs, const Vector2<U>& rhs) {
S x = lhs.x - rhs.x;
S y = lhs.y - rhs.y;
return x * x + y * y;
}
// Return the distance between two vectors.
template <typename T, typename U, typename S = typename std::common_type<T, U>::type>
inline S Distance(const Vector2<T>& lhs, const Vector2<U>& rhs) {
return engine::math::Sqrt<S>(DistanceSquared(lhs, rhs));
}
// Return minimum component of vector. (reference)
template <typename T>
inline T& Min(Vector2<T>& vector) {
return (vector.y < vector.x) ? vector.y : vector.x;
}
// Return maximum component of vector. (reference)
template <typename T>
inline T& Max(Vector2<T>& vector) {
return (vector.x < vector.y) ? vector.y : vector.x;
}
// Return both vector components rounded to the closest integer.
template <typename T>
inline Vector2<T> Round(const Vector2<T>& vector) {
if constexpr (std::is_floating_point_v<T>) {
return { engine::math::Round(vector.x), engine::math::Round(vector.y) };
}
return vector;
}
// Return both vector components ceiled to the closest integer.
template <typename T>
inline Vector2<T> Ceil(const Vector2<T>& vector) {
if constexpr (std::is_floating_point_v<T>) {
return { engine::math::Ceil(vector.x), engine::math::Ceil(vector.y) };
}
return vector;
}
// Return both vector components floored to the closest integer.
template <typename T>
inline Vector2<T> Floor(const Vector2<T>& vector) {
if constexpr (std::is_floating_point_v<T>) {
return { engine::math::Floor(vector.x), engine::math::Floor(vector.y) };
}
return vector;
}
// Clamp both vectors value within a vector range.
template <typename T>
inline Vector2<T> Clamp(const Vector2<T>& value, const Vector2<T>& low, const Vector2<T>& high) {
return { engine::math::Clamp(value.x, low.x, high.x), engine::math::Clamp(value.y, low.y, high.y) };
}
template <typename T, typename U, typename S = typename std::common_type<T, U>::type>
inline Vector2<S> CrossProduct(U value, const Vector2<T>& vector) {
return { -static_cast<S>(value) * static_cast<S>(vector.y), static_cast<S>(value) * static_cast<S>(vector.x) };
}
// Linearly interpolates both vector components by the given value.
template <typename T, typename U>
inline Vector2<U> Lerp(const Vector2<T>& a, const Vector2<T>& b, U amount) {
return { engine::math::Lerp(a.x, b.x, amount), engine::math::Lerp(a.y, b.y, amount) };
}
| [
"emailregisterlogin@gmail.com"
] | emailregisterlogin@gmail.com |
9a91f19648e95ad0f6da30e0c1e051454b12ac0c | 877fff5bb313ccd23d1d01bf23b1e1f2b13bb85a | /app/src/main/cpp/dir7941/dir7942/dir8062/dir8063/dir12766/dir12767/dir13029/dir13714/dir14099/dir14100/file14168.cpp | ae7a613e85e406657c96429ff2f50fc21bfa53cf | [] | no_license | tgeng/HugeProject | 829c3bdfb7cbaf57727c41263212d4a67e3eb93d | 4488d3b765e8827636ce5e878baacdf388710ef2 | refs/heads/master | 2022-08-21T16:58:54.161627 | 2020-05-28T01:54:03 | 2020-05-28T01:54:03 | 267,468,475 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 115 | cpp | #ifndef file14168
#error "macro file14168 must be defined"
#endif
static const char* file14168String = "file14168"; | [
"tgeng@google.com"
] | tgeng@google.com |
ab3d5654561894cd50cf114f4683825f57ab2fd1 | e763b855be527d69fb2e824dfb693d09e59cdacb | /aws-cpp-sdk-opsworkscm/source/model/Server.cpp | 1a217326a1ad9cbfc2befc77a4852e6898db7f35 | [
"MIT",
"Apache-2.0",
"JSON"
] | permissive | 34234344543255455465/aws-sdk-cpp | 47de2d7bde504273a43c99188b544e497f743850 | 1d04ff6389a0ca24361523c58671ad0b2cde56f5 | refs/heads/master | 2023-06-10T16:15:54.618966 | 2018-05-07T23:32:08 | 2018-05-07T23:32:08 | 132,632,360 | 1 | 0 | Apache-2.0 | 2023-06-01T23:20:47 | 2018-05-08T15:56:35 | C++ | UTF-8 | C++ | false | false | 11,210 | cpp | /*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. 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.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#include <aws/opsworkscm/model/Server.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <utility>
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
namespace Aws
{
namespace OpsWorksCM
{
namespace Model
{
Server::Server() :
m_associatePublicIpAddress(false),
m_associatePublicIpAddressHasBeenSet(false),
m_backupRetentionCount(0),
m_backupRetentionCountHasBeenSet(false),
m_serverNameHasBeenSet(false),
m_createdAtHasBeenSet(false),
m_cloudFormationStackArnHasBeenSet(false),
m_disableAutomatedBackup(false),
m_disableAutomatedBackupHasBeenSet(false),
m_endpointHasBeenSet(false),
m_engineHasBeenSet(false),
m_engineModelHasBeenSet(false),
m_engineAttributesHasBeenSet(false),
m_engineVersionHasBeenSet(false),
m_instanceProfileArnHasBeenSet(false),
m_instanceTypeHasBeenSet(false),
m_keyPairHasBeenSet(false),
m_maintenanceStatus(MaintenanceStatus::NOT_SET),
m_maintenanceStatusHasBeenSet(false),
m_preferredMaintenanceWindowHasBeenSet(false),
m_preferredBackupWindowHasBeenSet(false),
m_securityGroupIdsHasBeenSet(false),
m_serviceRoleArnHasBeenSet(false),
m_status(ServerStatus::NOT_SET),
m_statusHasBeenSet(false),
m_statusReasonHasBeenSet(false),
m_subnetIdsHasBeenSet(false),
m_serverArnHasBeenSet(false)
{
}
Server::Server(const JsonValue& jsonValue) :
m_associatePublicIpAddress(false),
m_associatePublicIpAddressHasBeenSet(false),
m_backupRetentionCount(0),
m_backupRetentionCountHasBeenSet(false),
m_serverNameHasBeenSet(false),
m_createdAtHasBeenSet(false),
m_cloudFormationStackArnHasBeenSet(false),
m_disableAutomatedBackup(false),
m_disableAutomatedBackupHasBeenSet(false),
m_endpointHasBeenSet(false),
m_engineHasBeenSet(false),
m_engineModelHasBeenSet(false),
m_engineAttributesHasBeenSet(false),
m_engineVersionHasBeenSet(false),
m_instanceProfileArnHasBeenSet(false),
m_instanceTypeHasBeenSet(false),
m_keyPairHasBeenSet(false),
m_maintenanceStatus(MaintenanceStatus::NOT_SET),
m_maintenanceStatusHasBeenSet(false),
m_preferredMaintenanceWindowHasBeenSet(false),
m_preferredBackupWindowHasBeenSet(false),
m_securityGroupIdsHasBeenSet(false),
m_serviceRoleArnHasBeenSet(false),
m_status(ServerStatus::NOT_SET),
m_statusHasBeenSet(false),
m_statusReasonHasBeenSet(false),
m_subnetIdsHasBeenSet(false),
m_serverArnHasBeenSet(false)
{
*this = jsonValue;
}
Server& Server::operator =(const JsonValue& jsonValue)
{
if(jsonValue.ValueExists("AssociatePublicIpAddress"))
{
m_associatePublicIpAddress = jsonValue.GetBool("AssociatePublicIpAddress");
m_associatePublicIpAddressHasBeenSet = true;
}
if(jsonValue.ValueExists("BackupRetentionCount"))
{
m_backupRetentionCount = jsonValue.GetInteger("BackupRetentionCount");
m_backupRetentionCountHasBeenSet = true;
}
if(jsonValue.ValueExists("ServerName"))
{
m_serverName = jsonValue.GetString("ServerName");
m_serverNameHasBeenSet = true;
}
if(jsonValue.ValueExists("CreatedAt"))
{
m_createdAt = jsonValue.GetDouble("CreatedAt");
m_createdAtHasBeenSet = true;
}
if(jsonValue.ValueExists("CloudFormationStackArn"))
{
m_cloudFormationStackArn = jsonValue.GetString("CloudFormationStackArn");
m_cloudFormationStackArnHasBeenSet = true;
}
if(jsonValue.ValueExists("DisableAutomatedBackup"))
{
m_disableAutomatedBackup = jsonValue.GetBool("DisableAutomatedBackup");
m_disableAutomatedBackupHasBeenSet = true;
}
if(jsonValue.ValueExists("Endpoint"))
{
m_endpoint = jsonValue.GetString("Endpoint");
m_endpointHasBeenSet = true;
}
if(jsonValue.ValueExists("Engine"))
{
m_engine = jsonValue.GetString("Engine");
m_engineHasBeenSet = true;
}
if(jsonValue.ValueExists("EngineModel"))
{
m_engineModel = jsonValue.GetString("EngineModel");
m_engineModelHasBeenSet = true;
}
if(jsonValue.ValueExists("EngineAttributes"))
{
Array<JsonValue> engineAttributesJsonList = jsonValue.GetArray("EngineAttributes");
for(unsigned engineAttributesIndex = 0; engineAttributesIndex < engineAttributesJsonList.GetLength(); ++engineAttributesIndex)
{
m_engineAttributes.push_back(engineAttributesJsonList[engineAttributesIndex].AsObject());
}
m_engineAttributesHasBeenSet = true;
}
if(jsonValue.ValueExists("EngineVersion"))
{
m_engineVersion = jsonValue.GetString("EngineVersion");
m_engineVersionHasBeenSet = true;
}
if(jsonValue.ValueExists("InstanceProfileArn"))
{
m_instanceProfileArn = jsonValue.GetString("InstanceProfileArn");
m_instanceProfileArnHasBeenSet = true;
}
if(jsonValue.ValueExists("InstanceType"))
{
m_instanceType = jsonValue.GetString("InstanceType");
m_instanceTypeHasBeenSet = true;
}
if(jsonValue.ValueExists("KeyPair"))
{
m_keyPair = jsonValue.GetString("KeyPair");
m_keyPairHasBeenSet = true;
}
if(jsonValue.ValueExists("MaintenanceStatus"))
{
m_maintenanceStatus = MaintenanceStatusMapper::GetMaintenanceStatusForName(jsonValue.GetString("MaintenanceStatus"));
m_maintenanceStatusHasBeenSet = true;
}
if(jsonValue.ValueExists("PreferredMaintenanceWindow"))
{
m_preferredMaintenanceWindow = jsonValue.GetString("PreferredMaintenanceWindow");
m_preferredMaintenanceWindowHasBeenSet = true;
}
if(jsonValue.ValueExists("PreferredBackupWindow"))
{
m_preferredBackupWindow = jsonValue.GetString("PreferredBackupWindow");
m_preferredBackupWindowHasBeenSet = true;
}
if(jsonValue.ValueExists("SecurityGroupIds"))
{
Array<JsonValue> securityGroupIdsJsonList = jsonValue.GetArray("SecurityGroupIds");
for(unsigned securityGroupIdsIndex = 0; securityGroupIdsIndex < securityGroupIdsJsonList.GetLength(); ++securityGroupIdsIndex)
{
m_securityGroupIds.push_back(securityGroupIdsJsonList[securityGroupIdsIndex].AsString());
}
m_securityGroupIdsHasBeenSet = true;
}
if(jsonValue.ValueExists("ServiceRoleArn"))
{
m_serviceRoleArn = jsonValue.GetString("ServiceRoleArn");
m_serviceRoleArnHasBeenSet = true;
}
if(jsonValue.ValueExists("Status"))
{
m_status = ServerStatusMapper::GetServerStatusForName(jsonValue.GetString("Status"));
m_statusHasBeenSet = true;
}
if(jsonValue.ValueExists("StatusReason"))
{
m_statusReason = jsonValue.GetString("StatusReason");
m_statusReasonHasBeenSet = true;
}
if(jsonValue.ValueExists("SubnetIds"))
{
Array<JsonValue> subnetIdsJsonList = jsonValue.GetArray("SubnetIds");
for(unsigned subnetIdsIndex = 0; subnetIdsIndex < subnetIdsJsonList.GetLength(); ++subnetIdsIndex)
{
m_subnetIds.push_back(subnetIdsJsonList[subnetIdsIndex].AsString());
}
m_subnetIdsHasBeenSet = true;
}
if(jsonValue.ValueExists("ServerArn"))
{
m_serverArn = jsonValue.GetString("ServerArn");
m_serverArnHasBeenSet = true;
}
return *this;
}
JsonValue Server::Jsonize() const
{
JsonValue payload;
if(m_associatePublicIpAddressHasBeenSet)
{
payload.WithBool("AssociatePublicIpAddress", m_associatePublicIpAddress);
}
if(m_backupRetentionCountHasBeenSet)
{
payload.WithInteger("BackupRetentionCount", m_backupRetentionCount);
}
if(m_serverNameHasBeenSet)
{
payload.WithString("ServerName", m_serverName);
}
if(m_createdAtHasBeenSet)
{
payload.WithDouble("CreatedAt", m_createdAt.SecondsWithMSPrecision());
}
if(m_cloudFormationStackArnHasBeenSet)
{
payload.WithString("CloudFormationStackArn", m_cloudFormationStackArn);
}
if(m_disableAutomatedBackupHasBeenSet)
{
payload.WithBool("DisableAutomatedBackup", m_disableAutomatedBackup);
}
if(m_endpointHasBeenSet)
{
payload.WithString("Endpoint", m_endpoint);
}
if(m_engineHasBeenSet)
{
payload.WithString("Engine", m_engine);
}
if(m_engineModelHasBeenSet)
{
payload.WithString("EngineModel", m_engineModel);
}
if(m_engineAttributesHasBeenSet)
{
Array<JsonValue> engineAttributesJsonList(m_engineAttributes.size());
for(unsigned engineAttributesIndex = 0; engineAttributesIndex < engineAttributesJsonList.GetLength(); ++engineAttributesIndex)
{
engineAttributesJsonList[engineAttributesIndex].AsObject(m_engineAttributes[engineAttributesIndex].Jsonize());
}
payload.WithArray("EngineAttributes", std::move(engineAttributesJsonList));
}
if(m_engineVersionHasBeenSet)
{
payload.WithString("EngineVersion", m_engineVersion);
}
if(m_instanceProfileArnHasBeenSet)
{
payload.WithString("InstanceProfileArn", m_instanceProfileArn);
}
if(m_instanceTypeHasBeenSet)
{
payload.WithString("InstanceType", m_instanceType);
}
if(m_keyPairHasBeenSet)
{
payload.WithString("KeyPair", m_keyPair);
}
if(m_maintenanceStatusHasBeenSet)
{
payload.WithString("MaintenanceStatus", MaintenanceStatusMapper::GetNameForMaintenanceStatus(m_maintenanceStatus));
}
if(m_preferredMaintenanceWindowHasBeenSet)
{
payload.WithString("PreferredMaintenanceWindow", m_preferredMaintenanceWindow);
}
if(m_preferredBackupWindowHasBeenSet)
{
payload.WithString("PreferredBackupWindow", m_preferredBackupWindow);
}
if(m_securityGroupIdsHasBeenSet)
{
Array<JsonValue> securityGroupIdsJsonList(m_securityGroupIds.size());
for(unsigned securityGroupIdsIndex = 0; securityGroupIdsIndex < securityGroupIdsJsonList.GetLength(); ++securityGroupIdsIndex)
{
securityGroupIdsJsonList[securityGroupIdsIndex].AsString(m_securityGroupIds[securityGroupIdsIndex]);
}
payload.WithArray("SecurityGroupIds", std::move(securityGroupIdsJsonList));
}
if(m_serviceRoleArnHasBeenSet)
{
payload.WithString("ServiceRoleArn", m_serviceRoleArn);
}
if(m_statusHasBeenSet)
{
payload.WithString("Status", ServerStatusMapper::GetNameForServerStatus(m_status));
}
if(m_statusReasonHasBeenSet)
{
payload.WithString("StatusReason", m_statusReason);
}
if(m_subnetIdsHasBeenSet)
{
Array<JsonValue> subnetIdsJsonList(m_subnetIds.size());
for(unsigned subnetIdsIndex = 0; subnetIdsIndex < subnetIdsJsonList.GetLength(); ++subnetIdsIndex)
{
subnetIdsJsonList[subnetIdsIndex].AsString(m_subnetIds[subnetIdsIndex]);
}
payload.WithArray("SubnetIds", std::move(subnetIdsJsonList));
}
if(m_serverArnHasBeenSet)
{
payload.WithString("ServerArn", m_serverArn);
}
return payload;
}
} // namespace Model
} // namespace OpsWorksCM
} // namespace Aws
| [
"henso@amazon.com"
] | henso@amazon.com |
58ba00f59a8807db02392731a7604a99da521768 | 6f2b6e9d77fc4dd5e1dae8ba6e5a66eb7c7ae849 | /sstd_boost/sstd/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp | ecc97a8ae412dcb42c53267f89ea196e1d99649c | [
"BSL-1.0"
] | permissive | KqSMea8/sstd_library | 9e4e622e1b01bed5de7322c2682539400d13dd58 | 0fcb815f50d538517e70a788914da7fbbe786ce1 | refs/heads/master | 2020-05-03T21:07:01.650034 | 2019-04-01T00:10:47 | 2019-04-01T00:10:47 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 27,811 | hpp | // Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2012-2014 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2016.
// Modifications copyright (c) 2016 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is 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_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_TURN_IN_PIECE_VISITOR
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_TURN_IN_PIECE_VISITOR
#include <sstd/boost/core/ignore_unused.hpp>
#include <sstd/boost/range.hpp>
#include <sstd/boost/geometry/core/assert.hpp>
#include <sstd/boost/geometry/arithmetic/dot_product.hpp>
#include <sstd/boost/geometry/algorithms/assign.hpp>
#include <sstd/boost/geometry/algorithms/comparable_distance.hpp>
#include <sstd/boost/geometry/algorithms/equals.hpp>
#include <sstd/boost/geometry/algorithms/expand.hpp>
#include <sstd/boost/geometry/algorithms/detail/disjoint/point_box.hpp>
#include <sstd/boost/geometry/algorithms/detail/disjoint/box_box.hpp>
#include <sstd/boost/geometry/algorithms/detail/overlay/segment_identifier.hpp>
#include <sstd/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp>
#include <sstd/boost/geometry/policies/compare.hpp>
#include <sstd/boost/geometry/strategies/buffer.hpp>
#include <sstd/boost/geometry/algorithms/detail/buffer/buffer_policies.hpp>
#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION)
#include <sstd/boost/geometry/strategies/cartesian/side_of_intersection.hpp>
#else
#include <sstd/boost/geometry/strategies/agnostic/point_in_poly_winding.hpp>
#endif
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace buffer
{
struct piece_get_box
{
template <typename Box, typename Piece>
static inline void apply(Box& total, Piece const& piece)
{
geometry::expand(total, piece.robust_envelope);
}
};
struct piece_ovelaps_box
{
template <typename Box, typename Piece>
static inline bool apply(Box const& box, Piece const& piece)
{
if (piece.type == strategy::buffer::buffered_flat_end
|| piece.type == strategy::buffer::buffered_concave)
{
// Turns cannot be inside a flat end (though they can be on border)
// Neither we need to check if they are inside concave helper pieces
// Skip all pieces not used as soon as possible
return false;
}
return ! geometry::detail::disjoint::disjoint_box_box(box, piece.robust_envelope);
}
};
struct turn_get_box
{
template <typename Box, typename Turn>
static inline void apply(Box& total, Turn const& turn)
{
geometry::expand(total, turn.robust_point);
}
};
struct turn_ovelaps_box
{
template <typename Box, typename Turn>
static inline bool apply(Box const& box, Turn const& turn)
{
return ! geometry::detail::disjoint::disjoint_point_box(turn.robust_point, box);
}
};
enum analyse_result
{
analyse_unknown,
analyse_continue,
analyse_disjoint,
analyse_within,
analyse_on_original_boundary,
analyse_on_offsetted
#if ! defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION)
, analyse_near_offsetted
#endif
};
template <typename Point>
inline bool in_box(Point const& previous,
Point const& current, Point const& point)
{
// Get its box (TODO: this can be prepared-on-demand later)
typedef geometry::model::box<Point> box_type;
box_type box;
geometry::assign_inverse(box);
geometry::expand(box, previous);
geometry::expand(box, current);
return geometry::covered_by(point, box);
}
template <typename Point, typename Turn>
inline analyse_result check_segment(Point const& previous,
Point const& current, Turn const& turn,
bool from_monotonic)
{
#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION)
typedef geometry::model::referring_segment<Point const> segment_type;
segment_type const p(turn.rob_pi, turn.rob_pj);
segment_type const q(turn.rob_qi, turn.rob_qj);
segment_type const r(previous, current);
int const side = strategy::side::side_of_intersection::apply(p, q, r,
turn.robust_point);
if (side == 0)
{
return analyse_on_offsetted;
}
if (side == -1 && from_monotonic)
{
return analyse_within;
}
if (side == 1 && from_monotonic)
{
return analyse_disjoint;
}
return analyse_continue;
#else
typedef typename strategy::side::services::default_strategy
<
typename cs_tag<Point>::type
>::type side_strategy;
typedef typename geometry::coordinate_type<Point>::type coordinate_type;
coordinate_type const twice_area
= side_strategy::template side_value
<
coordinate_type,
coordinate_type
>(previous, current, turn.robust_point);
if (twice_area == 0)
{
// Collinear, only on segment if it is covered by its bbox
if (in_box(previous, current, turn.robust_point))
{
return analyse_on_offsetted;
}
}
else if (twice_area < 0)
{
// It is in the triangle right-of the segment where the
// segment is the hypothenusa. Check if it is close
// (within rounding-area)
if (twice_area * twice_area < geometry::comparable_distance(previous, current)
&& in_box(previous, current, turn.robust_point))
{
return analyse_near_offsetted;
}
else if (from_monotonic)
{
return analyse_within;
}
}
else if (twice_area > 0 && from_monotonic)
{
// Left of segment
return analyse_disjoint;
}
// Not monotonic, on left or right side: continue analysing
return analyse_continue;
#endif
}
class analyse_turn_wrt_point_piece
{
public :
template <typename Turn, typename Piece>
static inline analyse_result apply(Turn const& turn, Piece const& piece)
{
typedef typename Piece::section_type section_type;
typedef typename Turn::robust_point_type point_type;
typedef typename geometry::coordinate_type<point_type>::type coordinate_type;
#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION)
typedef geometry::model::referring_segment<point_type const> segment_type;
segment_type const p(turn.rob_pi, turn.rob_pj);
segment_type const q(turn.rob_qi, turn.rob_qj);
#else
typedef strategy::within::winding<point_type> strategy_type;
typename strategy_type::state_type state;
strategy_type strategy;
boost::ignore_unused(strategy);
#endif
BOOST_GEOMETRY_ASSERT(! piece.sections.empty());
coordinate_type const point_x = geometry::get<0>(turn.robust_point);
for (std::size_t s = 0; s < piece.sections.size(); s++)
{
section_type const& section = piece.sections[s];
// If point within horizontal range of monotonic section:
if (! section.duplicate
&& section.begin_index < section.end_index
&& point_x >= geometry::get<min_corner, 0>(section.bounding_box) - 1
&& point_x <= geometry::get<max_corner, 0>(section.bounding_box) + 1)
{
for (signed_size_type i = section.begin_index + 1; i <= section.end_index; i++)
{
point_type const& previous = piece.robust_ring[i - 1];
point_type const& current = piece.robust_ring[i];
#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION)
// First check if it is in range - if it is not, the
// expensive side_of_intersection does not need to be
// applied
coordinate_type x1 = geometry::get<0>(previous);
coordinate_type x2 = geometry::get<0>(current);
if (x1 > x2)
{
std::swap(x1, x2);
}
if (point_x >= x1 - 1 && point_x <= x2 + 1)
{
segment_type const r(previous, current);
int const side = strategy::side::side_of_intersection::apply(p, q, r,
turn.robust_point);
// Sections are monotonic in x-dimension
if (side == 1)
{
// Left on segment
return analyse_disjoint;
}
else if (side == 0)
{
// Collinear - TODO: check if really on segment
return analyse_on_offsetted;
}
}
#else
analyse_result code = check_segment(previous, current, turn, false);
if (code != analyse_continue)
{
return code;
}
// Get the state (to determine it is within), we don't have
// to cover the on-segment case (covered above)
strategy.apply(turn.robust_point, previous, current, state);
#endif
}
}
}
#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION)
// It is nowhere outside, and not on segment, so it is within
return analyse_within;
#else
int const code = strategy.result(state);
if (code == 1)
{
return analyse_within;
}
else if (code == -1)
{
return analyse_disjoint;
}
// Should normally not occur - on-segment is covered
return analyse_unknown;
#endif
}
};
class analyse_turn_wrt_piece
{
template <typename Point, typename Turn>
static inline analyse_result check_helper_segment(Point const& s1,
Point const& s2, Turn const& turn,
#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION)
bool , // is on original, to be reused
#else
bool is_original,
#endif
Point const& offsetted)
{
boost::ignore_unused(offsetted);
#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION)
typedef geometry::model::referring_segment<Point const> segment_type;
segment_type const p(turn.rob_pi, turn.rob_pj);
segment_type const q(turn.rob_qi, turn.rob_qj);
segment_type const r(s1, s2);
int const side = strategy::side::side_of_intersection::apply(p, q, r,
turn.robust_point);
if (side == 1)
{
// left of segment
return analyse_disjoint;
}
else if (side == 0)
{
// If is collinear, either on segment or before/after
typedef geometry::model::box<Point> box_type;
box_type box;
geometry::assign_inverse(box);
geometry::expand(box, s1);
geometry::expand(box, s2);
if (geometry::covered_by(turn.robust_point, box))
{
// Points on helper-segments (and not on its corners)
// are considered as within
return analyse_within;
}
// It is collinear but not on the segment. Because these
// segments are convex, it is outside
// Unless the offsetted ring is collinear or concave w.r.t.
// helper-segment but that scenario is not yet supported
return analyse_disjoint;
}
// right of segment
return analyse_continue;
#else
typedef typename strategy::side::services::default_strategy
<
typename cs_tag<Point>::type
>::type side_strategy;
switch(side_strategy::apply(s1, s2, turn.robust_point))
{
case 1 :
return analyse_disjoint; // left of segment
case 0 :
{
// If is collinear, either on segment or before/after
typedef geometry::model::box<Point> box_type;
box_type box;
geometry::assign_inverse(box);
geometry::expand(box, s1);
geometry::expand(box, s2);
if (geometry::covered_by(turn.robust_point, box))
{
// It is on the segment
if (! is_original
&& geometry::comparable_distance(turn.robust_point, offsetted) <= 1)
{
// It is close to the offsetted-boundary, take
// any rounding-issues into account
return analyse_near_offsetted;
}
// Points on helper-segments are considered as within
// Points on original boundary are processed differently
return is_original
? analyse_on_original_boundary
: analyse_within;
}
// It is collinear but not on the segment. Because these
// segments are convex, it is outside
// Unless the offsetted ring is collinear or concave w.r.t.
// helper-segment but that scenario is not yet supported
return analyse_disjoint;
}
break;
}
// right of segment
return analyse_continue;
#endif
}
template <typename Turn, typename Piece>
static inline analyse_result check_helper_segments(Turn const& turn, Piece const& piece)
{
typedef typename Turn::robust_point_type point_type;
geometry::equal_to<point_type> comparator;
point_type points[4];
signed_size_type helper_count = static_cast<signed_size_type>(piece.robust_ring.size())
- piece.offsetted_count;
if (helper_count == 4)
{
for (int i = 0; i < 4; i++)
{
points[i] = piece.robust_ring[piece.offsetted_count + i];
}
// 3--offsetted outline--0
// | |
// left | | right
// | |
// 2===>==original===>===1
}
else if (helper_count == 3)
{
// Triangular piece, assign points but assign second twice
for (int i = 0; i < 4; i++)
{
int index = i < 2 ? i : i - 1;
points[i] = piece.robust_ring[piece.offsetted_count + index];
}
}
else
{
// Some pieces (e.g. around points) do not have helper segments.
// Others should have 3 (join) or 4 (side)
return analyse_continue;
}
// First check point-equality
point_type const& point = turn.robust_point;
if (comparator(point, points[0]) || comparator(point, points[3]))
{
return analyse_on_offsetted;
}
if (comparator(point, points[1]))
{
// On original, right corner
return piece.is_flat_end ? analyse_continue : analyse_on_original_boundary;
}
if (comparator(point, points[2]))
{
// On original, left corner
return piece.is_flat_start ? analyse_continue : analyse_on_original_boundary;
}
// Right side of the piece
analyse_result result
= check_helper_segment(points[0], points[1], turn,
false, points[0]);
if (result != analyse_continue)
{
return result;
}
// Left side of the piece
result = check_helper_segment(points[2], points[3], turn,
false, points[3]);
if (result != analyse_continue)
{
return result;
}
if (! comparator(points[1], points[2]))
{
// Side of the piece at side of original geometry
result = check_helper_segment(points[1], points[2], turn,
true, point);
if (result != analyse_continue)
{
return result;
}
}
// We are within the \/ or |_| shaped piece, where the top is the
// offsetted ring.
if (! geometry::covered_by(point, piece.robust_offsetted_envelope))
{
// Not in offsetted-area. This makes a cheap check possible
typedef typename strategy::side::services::default_strategy
<
typename cs_tag<point_type>::type
>::type side_strategy;
switch(side_strategy::apply(points[3], points[0], point))
{
case 1 : return analyse_disjoint;
case -1 : return analyse_within;
case 0 : return analyse_disjoint;
}
}
return analyse_continue;
}
template <typename Turn, typename Piece, typename Compare>
static inline analyse_result check_monotonic(Turn const& turn, Piece const& piece, Compare const& compare)
{
typedef typename Piece::piece_robust_ring_type ring_type;
typedef typename ring_type::const_iterator it_type;
it_type end = piece.robust_ring.begin() + piece.offsetted_count;
it_type it = std::lower_bound(piece.robust_ring.begin(),
end,
turn.robust_point,
compare);
if (it != end
&& it != piece.robust_ring.begin())
{
// iterator points to point larger than point
// w.r.t. specified direction, and prev points to a point smaller
// We now know if it is inside/outside
it_type prev = it - 1;
return check_segment(*prev, *it, turn, true);
}
return analyse_continue;
}
public :
template <typename Turn, typename Piece>
static inline analyse_result apply(Turn const& turn, Piece const& piece)
{
typedef typename Turn::robust_point_type point_type;
analyse_result code = check_helper_segments(turn, piece);
if (code != analyse_continue)
{
return code;
}
geometry::equal_to<point_type> comparator;
if (piece.offsetted_count > 8)
{
// If the offset contains some points and is monotonic, we try
// to avoid walking all points linearly.
// We try it only once.
if (piece.is_monotonic_increasing[0])
{
code = check_monotonic(turn, piece, geometry::less<point_type, 0>());
if (code != analyse_continue) return code;
}
else if (piece.is_monotonic_increasing[1])
{
code = check_monotonic(turn, piece, geometry::less<point_type, 1>());
if (code != analyse_continue) return code;
}
else if (piece.is_monotonic_decreasing[0])
{
code = check_monotonic(turn, piece, geometry::greater<point_type, 0>());
if (code != analyse_continue) return code;
}
else if (piece.is_monotonic_decreasing[1])
{
code = check_monotonic(turn, piece, geometry::greater<point_type, 1>());
if (code != analyse_continue) return code;
}
}
// It is small or not monotonic, walk linearly through offset
// TODO: this will be combined with winding strategy
for (signed_size_type i = 1; i < piece.offsetted_count; i++)
{
point_type const& previous = piece.robust_ring[i - 1];
point_type const& current = piece.robust_ring[i];
// The robust ring can contain duplicates
// (on which any side or side-value would return 0)
if (! comparator(previous, current))
{
code = check_segment(previous, current, turn, false);
if (code != analyse_continue)
{
return code;
}
}
}
return analyse_unknown;
}
};
template <typename Turns, typename Pieces>
class turn_in_piece_visitor
{
Turns& m_turns; // because partition is currently operating on const input only
Pieces const& m_pieces; // to check for piece-type
template <typename Operation, typename Piece>
inline bool skip(Operation const& op, Piece const& piece) const
{
if (op.piece_index == piece.index)
{
return true;
}
Piece const& pc = m_pieces[op.piece_index];
if (pc.left_index == piece.index || pc.right_index == piece.index)
{
if (pc.type == strategy::buffer::buffered_flat_end)
{
// If it is a flat end, don't compare against its neighbor:
// it will always be located on one of the helper segments
return true;
}
if (pc.type == strategy::buffer::buffered_concave)
{
// If it is concave, the same applies: the IP will be
// located on one of the helper segments
return true;
}
}
return false;
}
#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION)
// NOTE: this function returns a side value in {-1, 0, 1}
template <typename Turn, typename Piece>
static inline int turn_in_convex_piece(Turn const& turn,
Piece const& piece)
{
typedef typename Turn::robust_point_type point_type;
typedef typename Piece::piece_robust_ring_type ring_type;
typedef geometry::model::referring_segment<point_type const> segment;
segment const p(turn.rob_pi, turn.rob_pj);
segment const q(turn.rob_qi, turn.rob_qj);
typedef typename boost::range_iterator<ring_type const>::type iterator_type;
iterator_type it = boost::begin(piece.robust_ring);
iterator_type end = boost::end(piece.robust_ring);
// A robust ring is always closed, and always clockwise
for (iterator_type previous = it++; it != end; ++previous, ++it)
{
geometry::equal_to<point_type> comparator;
if (comparator(*previous, *it))
{
// Points are the same
continue;
}
segment r(*previous, *it);
int const side = strategy::side::side_of_intersection::apply(p, q, r,
turn.robust_point);
if (side == 1)
{
// IP is left of segment, so it is outside
return -1; // outside
}
else if (side == 0)
{
// IP is collinear with segment. TODO: we should analyze this further
// For now we use the fallback point
if (in_box(*previous, *it, turn.robust_point))
{
return 0;
}
else
{
return -1; // outside
}
}
}
return 1; // inside
}
#endif
public:
inline turn_in_piece_visitor(Turns& turns, Pieces const& pieces)
: m_turns(turns)
, m_pieces(pieces)
{}
template <typename Turn, typename Piece>
inline bool apply(Turn const& turn, Piece const& piece, bool first = true)
{
boost::ignore_unused(first);
if (turn.count_within > 0)
{
// Already inside - no need to check again
return true;
}
if (piece.type == strategy::buffer::buffered_flat_end
|| piece.type == strategy::buffer::buffered_concave)
{
// Turns cannot be located within flat-end or concave pieces
return true;
}
if (! geometry::covered_by(turn.robust_point, piece.robust_envelope))
{
// Easy check: if the turn is not in the envelope, we can safely return
return true;
}
if (skip(turn.operations[0], piece) || skip(turn.operations[1], piece))
{
return true;
}
// TODO: mutable_piece to make some on-demand preparations in analyse
Turn& mutable_turn = m_turns[turn.turn_index];
if (piece.type == geometry::strategy::buffer::buffered_point)
{
// Optimization for buffer around points: if distance from center
// is not between min/max radius, the result is clear
typedef typename default_comparable_distance_result
<
typename Turn::robust_point_type
>::type distance_type;
distance_type const cd
= geometry::comparable_distance(piece.robust_center,
turn.robust_point);
if (cd < piece.robust_min_comparable_radius)
{
mutable_turn.count_within++;
return true;
}
if (cd > piece.robust_max_comparable_radius)
{
return true;
}
}
analyse_result analyse_code =
piece.type == geometry::strategy::buffer::buffered_point
? analyse_turn_wrt_point_piece::apply(turn, piece)
: analyse_turn_wrt_piece::apply(turn, piece);
switch(analyse_code)
{
case analyse_disjoint :
return true;
case analyse_on_offsetted :
mutable_turn.count_on_offsetted++; // value is not used anymore
return true;
case analyse_on_original_boundary :
mutable_turn.count_on_original_boundary++;
return true;
case analyse_within :
mutable_turn.count_within++;
return true;
#if ! defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION)
case analyse_near_offsetted :
mutable_turn.count_within_near_offsetted++;
return true;
#endif
default :
break;
}
#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION)
// We don't know (yet)
int geometry_code = 0;
if (piece.is_convex)
{
geometry_code = turn_in_convex_piece(turn, piece);
}
else
{
// TODO: this point_in_geometry is a performance-bottleneck here and
// will be replaced completely by extending analyse_piece functionality
geometry_code = detail::within::point_in_geometry(turn.robust_point, piece.robust_ring);
}
#else
int geometry_code = detail::within::point_in_geometry(turn.robust_point, piece.robust_ring);
#endif
if (geometry_code == 1)
{
mutable_turn.count_within++;
}
return true;
}
};
}} // namespace detail::buffer
#endif // DOXYGEN_NO_DETAIL
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_TURN_IN_PIECE_VISITOR
| [
"zhaixueqiang@hotmail.com"
] | zhaixueqiang@hotmail.com |
5dba7781522df2209e8d61375c42dae5dc1337b1 | 34b22618cc53750a239ee7d3c98314d8e9b19093 | /framework/core/cfoundation/src/Utils/Color.cpp | 72f6ee36a1c618a75fdb04a71406f75788f455c7 | [] | no_license | ivan-kits/cframework | 7beef16da89fb4f9559c0611863d05ac3de25abd | 30015ddf1e5adccd138a2988455fe8010d1d9f50 | refs/heads/master | 2023-06-12T05:09:30.355989 | 2021-07-04T09:00:00 | 2021-07-04T09:00:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,154 | cpp | #include "cfoundation/Utils/Color.h"
#include <algorithm>
#include "cfoundation/Base/Defines.h"
#include "cfoundation/Serialization/Serializer.h"
using namespace CFoundation;
Color::Color()
: m_u32Color( 0 )
{
}
Color::Color( Unsigned32 u32HexColor )
: m_u32Color( u32HexColor )
{
}
Color::Color( Float16 f16R, Float16 f16G, Float16 f16B, Float16 f16A )
: m_u32Color( 0 )
{
SetHex( RGBAToHex( static_cast<Unsigned8>( f16R * MAX_U8 ),
static_cast<Unsigned8>( f16G * MAX_U8 ),
static_cast<Unsigned8>( f16B * MAX_U8 ),
static_cast<Unsigned8>( f16A * MAX_U8 ) ) );
}
Color::Color( Unsigned8 u8R, Unsigned8 u8G, Unsigned8 u8B, Unsigned8 u8A )
: m_u32Color( 0 )
{
SetHex( RGBAToHex( u8R, u8G, u8B, u8A ) );
}
Color::Color( const Vector3Df &clColor )
: m_u32Color( 0 )
{
SetHex( RGBAToHex( static_cast<Unsigned8>( clColor.GetX() * MAX_U8 ),
static_cast<Unsigned8>( clColor.GetY() * MAX_U8 ),
static_cast<Unsigned8>( clColor.GetZ() * MAX_U8 ),
MAX_U8 ) );
}
Color::Color( const String& _sHexString )
: m_u32Color( 0 )
{
Unsigned32 u32Digits = 0;
m_u32Color = _sHexString.HexToInteger( u32Digits );
// Check if alpha channel is set (last two digits)
if ( u32Digits <= 6 )
{
m_u32Color = ( m_u32Color << ( 8 - u32Digits ) * 4 ) + 0xff;
}
else if ( u32Digits == 7 )
{
m_u32Color = ( m_u32Color << 4 );
}
}
void Color::Serialize( CFoundation::Serializer& _Serializer )
{
_Serializer.Serialize( m_u32Color );
}
void Color::SetU8R( Unsigned8 _u8R )
{
Unsigned8 u8R, u8G, u8B, u8A;
ToRGBA( u8R, u8G, u8B, u8A );
SetRGBA( _u8R, u8G, u8B, u8A );
}
void Color::SetU8G( Unsigned8 _u8G )
{
Unsigned8 u8R, u8G, u8B, u8A;
ToRGBA( u8R, u8G, u8B, u8A );
SetRGBA( u8R, _u8G, u8B, u8A );
}
void Color::SetU8B( Unsigned8 _u8B )
{
Unsigned8 u8R, u8G, u8B, u8A;
ToRGBA( u8R, u8G, u8B, u8A );
SetRGBA( u8R, u8G, _u8B, u8A );
}
void Color::SetU8A( Unsigned8 _u8A )
{
Unsigned8 u8R, u8G, u8B, u8A;
ToRGBA( u8R, u8G, u8B, u8A );
SetRGBA( u8R, u8G, u8B, _u8A );
}
void Color::SetF16R( Float16 _f16R )
{
Float16 f16R, f16G, f16B, f16A;
ToRGBA( f16R, f16G, f16B, f16A );
SetRGBA( _f16R, f16G, f16B, f16A );
}
void Color::SetF16G( Float16 _f16G )
{
Float16 f16R, f16G, f16B, f16A;
ToRGBA( f16R, f16G, f16B, f16A );
SetRGBA( f16R, _f16G, f16B, f16A );
}
void Color::SetF16B( Float16 _f16B )
{
Float16 f16R, f16G, f16B, f16A;
ToRGBA( f16R, f16G, f16B, f16A );
SetRGBA( f16R, f16G, _f16B, f16A );
}
void Color::SetF16A( Float16 _f16A )
{
Float16 f16R, f16G, f16B, f16A;
ToRGBA( f16R, f16G, f16B, f16A );
SetRGBA( f16R, f16G, f16B, _f16A );
}
void Color::SetHex( Unsigned32 u32Color )
{
m_u32Color = u32Color;
}
void Color::SetRGB( Float16 f16R, Float16 f16G, Float16 f16B )
{
SetRGBA( f16R, f16G, f16B, GetF16A() );
}
void Color::SetRGB( Unsigned8 u8R, Unsigned8 u8G, Unsigned8 u8B )
{
SetRGBA( u8R, u8G, u8B, GetU8A() );
}
void Color::SetRGBA( Float16 f16R, Float16 f16G, Float16 f16B, Float16 f16A )
{
SetHex( RGBAToHex( static_cast<Unsigned8>( f16R * MAX_U8 ),
static_cast<Unsigned8>( f16G * MAX_U8 ),
static_cast<Unsigned8>( f16B * MAX_U8 ),
static_cast<Unsigned8>( f16A * MAX_U8 ) ) );
}
void Color::SetRGBA( Unsigned8 u8R, Unsigned8 u8G, Unsigned8 u8B, Unsigned8 u8A )
{
SetHex( RGBAToHex( u8R, u8G, u8B, u8A ) );
}
void Color::SetHSV( Unsigned8 _u8H, Unsigned8 _u8S, Unsigned8 _u8V )
{
// Make h in (0,6)
Float16 f16Hi = _u8H / 60.0f;
Unsigned8 u8Hi = static_cast< Unsigned8 >( f16Hi );
// Get fractional
Float16 f = f16Hi - u8Hi;
// Compute helper variables
Float16 v = _u8V / 100.0f;
Float16 s = _u8S / 100.0f;
Float16 p = v * (1 - s);
Float16 q = v * (1 - (s * f));
Float16 t = v * (1 - (s * (1 - f)));
Float16 f16R = 0.0f, f16G = 0.0f, f16B = 0.0f;
switch ( u8Hi )
{
case 0:
f16R = v;
f16G = t;
f16B = p;
break;
case 1:
f16R = q;
f16G = v;
f16B = p;
break;
case 2:
f16R = p;
f16G = v;
f16B = t;
break;
case 3:
f16R = p;
f16G = q;
f16B = v;
break;
case 4:
f16R = t;
f16G = p;
f16B = v;
break;
case 5:
f16R = v;
f16G = p;
f16B = q;
break;
}
SetRGB( f16R, f16G, f16B );
}
void Color::ToRGB( Unsigned8 &u8R, Unsigned8 &u8G, Unsigned8 &u8B ) const
{
Unsigned8 u8A = 0;
ToRGBA( u8R, u8G, u8B, u8A );
}
void Color::ToRGB( Float16 &f16R, Float16 &f16G, Float16 &f16B ) const
{
Float16 f16A = 0.0f;
ToRGBA( f16R, f16G, f16B, f16A );
}
void Color::ToRGBA( Unsigned8 &u8R, Unsigned8 &u8G, Unsigned8 &u8B, Unsigned8& u8A ) const
{
u8R = static_cast<Unsigned8>( ( m_u32Color & 0xff000000 ) >> 24 );
u8G = static_cast<Unsigned8>( ( m_u32Color & 0x00ff0000 ) >> 16 );
u8B = static_cast<Unsigned8>( ( m_u32Color & 0x0000ff00 ) >> 8 );
u8A = static_cast<Unsigned8>( ( m_u32Color & 0x000000ff ) );
}
void Color::ToRGBA( Float16 &f16R, Float16 &f16G, Float16 &f16B, Float16& f16A ) const
{
Unsigned8 u8R, u8G, u8B, u8A;
ToRGBA( u8R, u8G, u8B, u8A );
f16R = u8R * 1.0f / MAX_U8;
f16G = u8G * 1.0f / MAX_U8;
f16B = u8B * 1.0f / MAX_U8;
f16A = u8A * 1.0f / MAX_U8;
}
Unsigned32 Color::ToHex() const
{
return m_u32Color;
}
void Color::ToHSV( Unsigned8& _u8H, Unsigned8& _u8S, Unsigned8& _u8V ) const
{
Unsigned8 u8R, u8G, u8B, u8A;
ToRGBA( u8R, u8G, u8B, u8A );
Unsigned8 u8Max = std::max( u8R, std::max( u8G, u8B ) );
Unsigned8 u8Min = std::min( u8R, std::min( u8G, u8B ) );
Unsigned8 u8Diff = u8Max - u8Min;
// Compute H
Float16 f16H = 0.0f;
if ( u8Min == u8Max )
{
f16H = 0;
}
else if ( u8R == u8Max )
{
f16H = 60 * ( 0 + ( u8G - u8B ) * 1.0f / u8Diff );
}
else if ( u8G == u8Max )
{
f16H = 60 * ( 2 + ( u8B - u8R ) * 1.0f / u8Diff );
}
else if ( u8B == u8Max )
{
f16H = 60 * ( 4 + ( u8R - u8G ) * 1.0f / u8Diff );
}
if ( f16H < 0.0f )
{
f16H += 360.0f;
}
_u8H = static_cast< Unsigned8 >( f16H );
// Compute S
if ( u8Max == 0 )
{
_u8S = 0;
}
else
{
_u8S = u8Diff * 100.0f / u8Max;
}
// Compute V
_u8V = u8Max * 100 / 255;
}
Unsigned32 Color::GetHex() const
{
return m_u32Color;
}
const CFoundation::String Color::GetHexString() const
{
CFoundation::String sTmp = CFoundation::String::ToHexString( m_u32Color );
// add leading nils
while( sTmp.GetLength() < 8 )
{
sTmp = "0" + sTmp;
}
return sTmp;
}
Unsigned8 Color::GetU8R() const
{
Unsigned8 u8R, u8G, u8B;
ToRGB( u8R, u8G, u8B );
return u8R;
}
Unsigned8 Color::GetU8G() const
{
Unsigned8 u8R, u8G, u8B;
ToRGB( u8R, u8G, u8B );
return u8G;
}
Unsigned8 Color::GetU8B() const
{
Unsigned8 u8R, u8G, u8B;
ToRGB( u8R, u8G, u8B );
return u8B;
}
Unsigned8 Color::GetU8A() const
{
Unsigned8 u8R, u8G, u8B, u8A;
ToRGBA( u8R, u8G, u8B, u8A );
return u8A;
}
Float16 Color::GetF16R() const
{
Float16 f16R, f16G, f16B;
ToRGB( f16R, f16G, f16B );
return f16R;
}
Float16 Color::GetF16G() const
{
Float16 f16R, f16G, f16B;
ToRGB( f16R, f16G, f16B );
return f16G;
}
Float16 Color::GetF16B() const
{
Float16 f16R, f16G, f16B;
ToRGB( f16R, f16G, f16B );
return f16B;
}
Float16 Color::GetF16A() const
{
Float16 f16R, f16G, f16B, f16A;
ToRGBA( f16R, f16G, f16B, f16A );
return f16A;
}
bool Color::operator==( const Color &rhs ) const
{
return m_u32Color == rhs.m_u32Color;
}
bool Color::operator!=( const Color &rhs ) const
{
return !( *this == rhs );
}
Color& Color::operator+=( const Color &rhs )
{
Float16 f16R1, f16G1, f16B1;
ToRGB( f16R1, f16G1, f16B1 );
Float16 f16R2, f16G2, f16B2;
rhs.ToRGB( f16R2, f16G2, f16B2 );
SetRGB( std::min<Float16>( f16R1 + f16R2, 1.0f ),
std::min<Float16>( f16G1 + f16G2, 1.0f ),
std::min<Float16>( f16B1 + f16B2, 1.0f ) );
return *this;
}
Color& Color::operator-=( const Color &rhs )
{
Float16 f16R1, f16G1, f16B1;
ToRGB( f16R1, f16G1, f16B1 );
Float16 f16R2, f16G2, f16B2;
rhs.ToRGB( f16R2, f16G2, f16B2 );
SetRGB( std::max<Float16>( f16R1 - f16R2, 0.0f ),
std::max<Float16>( f16G1 - f16G2, 0.0f ),
std::max<Float16>( f16B1 - f16B2, 0.0f ) );
return *this;
}
Color& Color::operator*=( Float16 d )
{
Float16 f16R1, f16G1, f16B1;
ToRGB( f16R1, f16G1, f16B1 );
SetRGB( std::min<Float16>( f16R1 * d, 1.0f ),
std::min<Float16>( f16G1 * d, 1.0f ),
std::min<Float16>( f16B1 * d, 1.0f ) );
return *this;
}
Color& Color::operator*=( const Color &rhs )
{
Float16 f16R1, f16G1, f16B1;
ToRGB( f16R1, f16G1, f16B1 );
Float16 f16R2, f16G2, f16B2;
rhs.ToRGB( f16R2, f16G2, f16B2 );
SetRGB( std::min<Float16>( f16R1 * f16R2, 1.0f ),
std::min<Float16>( f16G1 * f16G2, 1.0f ),
std::min<Float16>( f16B1 * f16B2, 1.0f ) );
return *this;
}
Color& Color::operator*=( const Vector3Df &rhs )
{
Float16 f16R1, f16G1, f16B1;
ToRGB( f16R1, f16G1, f16B1 );
SetRGB( std::min<Float16>( f16R1 * static_cast<Float16>( rhs.GetX() ), 1.0f ),
std::min<Float16>( f16G1 * static_cast<Float16>( rhs.GetY() ), 1.0f ),
std::min<Float16>( f16B1 * static_cast<Float16>( rhs.GetZ() ), 1.0f ) );
return *this;
}
Unsigned32 Color::RGBAToHex( Unsigned8 u8R, Unsigned8 u8G, Unsigned8 u8B, Unsigned8 u8A )
{
return ( u8R << 24 ) + ( u8G << 16 ) + ( u8B << 8 ) + ( u8A );
}
void Color::Mix( const Color &clColor )
{
Float16 f16R1, f16G1, f16B1;
ToRGB( f16R1, f16G1, f16B1 );
Float16 f16R2, f16G2, f16B2;
clColor.ToRGB( f16R2, f16G2, f16B2 );
SetRGB( f16R1 * 0.5f + f16R2 * 0.5f,
f16G1 * 0.5f + f16G2 * 0.5f,
f16B1 * 0.5f + f16B2 * 0.5f );
}
namespace CFoundation
{
Color operator+( const Color &lhs, const Color &rhs )
{
return Color( lhs ) += rhs;
}
Color operator-( const Color &lhs, const Color &rhs )
{
return Color( lhs ) -= rhs;
}
Color operator*( const Color &lhs, Float16 d )
{
return Color( lhs ) *= d;
}
Color operator*( Float16 d, const Color &rhs )
{
return Color( rhs ) *= d;
}
Color operator*( const Color &lhs, const Color &rhs )
{
return Color( lhs ) *= rhs;
}
}
| [
"dev@oeing.eu"
] | dev@oeing.eu |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.