hexsha stringlengths 40 40 | size int64 19 11.4M | ext stringclasses 13
values | lang stringclasses 1
value | max_stars_repo_path stringlengths 3 270 | max_stars_repo_name stringlengths 5 110 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 9 | max_stars_count float64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringlengths 24 24 ⌀ | max_stars_repo_stars_event_max_datetime stringlengths 24 24 ⌀ | max_issues_repo_path stringlengths 3 270 | max_issues_repo_name stringlengths 5 116 | max_issues_repo_head_hexsha stringlengths 40 78 | max_issues_repo_licenses listlengths 1 9 | max_issues_count float64 1 67k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 3 270 | max_forks_repo_name stringlengths 5 116 | max_forks_repo_head_hexsha stringlengths 40 78 | max_forks_repo_licenses listlengths 1 9 | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringlengths 24 24 ⌀ | max_forks_repo_forks_event_max_datetime stringlengths 24 24 ⌀ | content stringlengths 19 11.4M | avg_line_length float64 1.93 229k | max_line_length int64 12 688k | alphanum_fraction float64 0.07 0.99 | matches listlengths 1 10 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
754474adc92bcd99ac544dca5ba006b7e873d2b8 | 5,744 | cc | C++ | src/util.cc | NoelM/darc2json | 02822273f5b3c8baa49f10b6ee399b2a0b26de16 | [
"MIT"
] | 13 | 2018-12-18T00:35:23.000Z | 2021-07-15T13:11:31.000Z | src/util.cc | NoelM/darc2json | 02822273f5b3c8baa49f10b6ee399b2a0b26de16 | [
"MIT"
] | 1 | 2018-03-30T21:23:44.000Z | 2018-03-31T06:10:58.000Z | src/util.cc | NoelM/darc2json | 02822273f5b3c8baa49f10b6ee399b2a0b26de16 | [
"MIT"
] | 4 | 2019-03-10T23:43:07.000Z | 2021-08-02T15:20:10.000Z | /*
* Copyright (c) Oona Räisänen
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
#include "src/util.h"
#include <cassert>
#include <iomanip>
#include <map>
#include <sstream>
#include <vector>
namespace darc2json {
// Convert generator polynomial (x^6 + x^4 + x^3 + 1) coefficients
// ({6, 4, 3, 0}) to bitstring ({1, 0, 1, 1, 0, 0, 1})
Bits poly_coeffs_to_bits(const std::vector<int>& coeffs) {
Bits bits(coeffs.at(0) + 1);
for (int c : coeffs)
bits.at(bits.size() - c - 1) = 1;
return bits;
}
Bits bitvector_lsb(std::vector<uint8_t> input) {
Bits result;
for (uint8_t c : input) {
for (int i = 7; i >= 0; i--) {
result.push_back((c >> i) & 1);
}
}
return result;
}
Bits bitvector_msb(std::vector<uint8_t> input) {
Bits result;
for (uint8_t c : input) {
for (int i = 0; i < 8; i++) {
result.push_back((c >> i) & 1);
}
}
return result;
}
uint32_t field(const Bits& bits,
int start_at, int length) {
assert (length <= 32);
uint32_t result = 0;
for (int i = 0; i < length; i++) {
result += (bits.at(start_at + i) << i);
}
return result;
}
uint32_t field_rev(const Bits& bits,
int start_at, int length) {
assert (length <= 32);
uint32_t result = 0;
for (int i = 0; i < length; i++) {
result += (bits.at(start_at + i) << (length - 1 - i));
}
return result;
}
void lshift(Bits& bits) {
for (size_t i = 0; i < bits.size() - 1; i++)
bits[i] = bits[i + 1];
bits[bits.size() - 1] = 0;
}
Bits crc(const Bits& bits, const Bits& generator, size_t message_length) {
assert(message_length <= bits.size());
Bits result(generator.size() - 1);
for (size_t n_bit = 0; n_bit < message_length; n_bit++) {
int popped_bit = result[0];
lshift(result);
result[result.size() - 1] = bits[n_bit];
// XOR if shifted-out bit was 1
if (popped_bit) {
for (size_t j = 0; j < result.size(); j++)
result[j] ^= generator[j + 1];
}
}
return result;
}
// Zero-pad data-only message and return calculated CRC
/*Bits crc(Bits bits, const Bits& generator) {
for (size_t i = 0; i < generator.size() - 1; i++)
bits.push_back(0);
return _crc(bits, generator, bits.size());
}*/
bool check_crc(const Bits& bits, const Bits& generator, size_t message_length) {
return AllBitsZero(crc(bits, generator, message_length));
}
bool BitsEqual(const Bits& bits1, const Bits& bits2) {
bool match = true;
if (bits1.size() == bits2.size()) {
for (size_t i = 0; i < bits1.size(); i++) {
if (bits1[i] != bits2[i]) {
match = false;
break;
}
}
} else {
match = false;
}
return match;
}
std::string BitString(const Bits& bits) {
std::string result;
for (int b : bits)
result += std::to_string(b);
return result;
}
const std::map<Bits, Bits> create_bitflip_syndrome_map(size_t len,
const Bits& generator) {
std::map<Bits, Bits> result;
for (size_t i = 0; i < len; i++) {
Bits error_vector(len);
error_vector.at(i) = 1;
result[crc(error_vector, generator, error_vector.size())] = error_vector;
}
return result;
}
std::string BytesToHexString(const std::vector<uint8_t>& data) {
std::stringstream ss;
for (size_t n_byte = 0; n_byte < data.size(); n_byte++) {
ss << std::setfill('0') << std::setw(2) << std::hex <<
static_cast<int>(data[n_byte]);
if (n_byte < data.size() - 1)
ss << " ";
}
return ss.str();
}
std::string BitsToHexString(const Bits& data) {
std::stringstream ss;
for (size_t nbyte = 0; nbyte < data.size() / 8; nbyte++) {
ss << std::setfill('0') << std::setw(2) << std::hex <<
field(data, nbyte * 8, 8);
if (nbyte < data.size() / 8 - 1)
ss << " ";
}
return ss.str();
}
bool AllBitsZero(const Bits& bits) {
bool result = true;
for (auto bit : bits) {
if (bit) {
result = false;
break;
}
}
return result;
}
Bits reversed_bytes_to_bit_vector(const std::vector<uint8_t>& bytes) {
Bits bits;
for (uint8_t byte : bytes)
for (int n_bit = 0; n_bit < 8; n_bit++)
bits.push_back((byte >> (7-n_bit)) & 1);
return bits;
}
std::vector<uint8_t> bit_vector_to_reversed_bytes(const Bits& bits) {
std::vector<uint8_t> bytes;
for (size_t n_byte = 0; n_byte < bits.size() / 8; n_byte++) {
bytes.push_back(field(bits, n_byte * 8, 8));
}
return bytes;
}
// Extract a field from a vector of bytes.
// The bit numbering in a byte corresponds to that used in the DARC
// specification.
uint32_t bfield(const std::vector<uint8_t>& bytes, size_t start_byte,
size_t start_bit, size_t length) {
uint32_t result = 0;
int n_byte = start_byte;
int n_bit = start_bit;
for (size_t n_bit_result = 0; n_bit_result < length; n_bit_result++) {
result += ((bytes[n_byte] >> n_bit) & 1) << (length - n_bit_result - 1);
n_bit--;
if (n_bit < 0) {
n_byte++;
n_bit = 7;
}
}
return result;
}
} // namespace darc2json
| 24.758621 | 80 | 0.611595 | [
"vector"
] |
754b71695d1209eef8436d0b60567c59b119b9ab | 19,601 | cc | C++ | xic/src/main/errorlog.cc | wrcad/xictools | f46ba6d42801426739cc8b2940a809b74f1641e2 | [
"Apache-2.0"
] | 73 | 2017-10-26T12:40:24.000Z | 2022-03-02T16:59:43.000Z | xic/src/main/errorlog.cc | chris-ayala/xictools | 4ea72c118679caed700dab3d49a8d36445acaec3 | [
"Apache-2.0"
] | 12 | 2017-11-01T10:18:22.000Z | 2022-03-20T19:35:36.000Z | xic/src/main/errorlog.cc | chris-ayala/xictools | 4ea72c118679caed700dab3d49a8d36445acaec3 | [
"Apache-2.0"
] | 34 | 2017-10-06T17:04:21.000Z | 2022-02-18T16:22:03.000Z |
/*========================================================================*
* *
* Distributed by Whiteley Research Inc., Sunnyvale, California, USA *
* http://wrcad.com *
* Copyright (C) 2017 Whiteley Research Inc., all rights reserved. *
* Author: Stephen R. Whiteley, except as indicated. *
* *
* As fully as possible recognizing licensing terms and conditions *
* imposed by earlier work from which this work was derived, if any, *
* this work is released under the Apache License, Version 2.0 (the *
* "License"). You may not use this file except in compliance with *
* the License, and compliance with inherited licenses which are *
* specified in a sub-header below this one if applicable. A copy *
* of the License is provided with this distribution, or you may *
* obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* See the License for the specific language governing permissions *
* and limitations under the License. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON- *
* INFRINGEMENT. IN NO EVENT SHALL WHITELEY RESEARCH INCORPORATED *
* OR STEPHEN R. WHITELEY BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
*========================================================================*
* XicTools Integrated Circuit Design System *
* *
* Xic Integrated Circuit Layout and Schematic Editor *
* *
*========================================================================*
$Id:$
*========================================================================*/
#include "main.h"
#include "errorlog.h"
#include "dsp_tkif.h"
#include "dsp_inlines.h"
#include "miscutil/filestat.h"
#include "miscutil/pathlist.h"
#include "miscutil/miscutil.h"
#include <dirent.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
//
// Error Logging
//
// Message header exports.
namespace mh {
const char *DRC = "DRC";
const char *DRCViolation = "DRC violation";
const char *ObjectCreation = "object creation";
const char *EditOperation = "edit operation";
const char *Flatten = "flatten";
const char *CellPlacement = "cell placement";
const char *Techfile = "techfile";
const char *Initialization = "initialization";
const char *Internal = "internal";
const char *NetlistCreation = "netlist creation";
const char *Variables = "variables";
const char *PCells = "pcells";
const char *Properties = "properties";
const char *JobControl = "job control";
const char *Processing = "processing";
const char *OpenAccess = "OpenAccess";
const char *InputOutput = "Input/Output";
}
// We keep a list of the last KEEPMSGS-1 error messages in memory, all are
// written to an errors file. Each error is given an error count.
#define KEEPMSGS 21
cErrLog *cErrLog::instancePtr = 0;
cErrLog::cErrLog()
{
if (instancePtr) {
fprintf(stderr, "Singleton class cErrLog already instantiated.\n");
exit(1);
}
instancePtr = this;
el_log_directory = 0;
el_mem_err_log_name = 0;
el_mail_address = 0;
setupInterface();
}
// Private static error exit.
//
void
cErrLog::on_null_ptr()
{
fprintf(stderr, "Singleton class cErrLog used before instantiated.\n");
exit(1);
}
//-----------------------------------------------------------------------
// The error/warning display functions follow. Each will pop up a
// window, or use an existing error window if already present, and
// display a message. The ErrorLog and similar functions assign an
// error number and record the message in a list, which is saved in
// the error log file. The function will display the current error,
// along with the last few errors. The PopUpErr and similar functions
// do not record the message, but simply display the text.
//
// Most errors and warnings should use the ErrorLog group of
// functions, as this avoids a problem with PopUpErr: The messages
// will be overwritten by subsequent errors/warnings of any type, and
// may therefor be unseen. The logging functions will always record
// the error in the log, so it won't be lost.
//
// We use the PopUpErrs functions only for very simple messages in
// commands, which are probably instructional, and occur just before a
// natural pause so that the message will be displayed immediately and
// not overwritten.
//-----------------------------------------------------------------------
// Pop up the top of the error list with the new errstr added.
//
void
cErrLog::ErrorLog(const char *header, const char *errstr)
{
el_list.add_msg(false, header, errstr, LW_CENTER);
}
// Formatting version of above, note that literal '%' characters cause
// trouble so this function is not a potential replacement for the
// string version above.
//
void
cErrLog::ErrorLogV(const char *header, const char *fmt, ...)
{
if (!fmt || !*fmt)
return;
int len = strlen(fmt) + 1024;
char *bf = new char[len];
va_list args;
va_start(args, fmt);
vsnprintf(bf, len, fmt, args);
va_end(args);
el_list.add_msg(false, header, bf, LW_CENTER);
delete [] bf;
}
void
cErrLog::WarningLog(const char *header, const char *errstr)
{
el_list.add_msg(true, header, errstr, LW_CENTER);
}
void
cErrLog::WarningLogV(const char *header, const char *fmt, ...)
{
if (!fmt || !*fmt)
return;
int len = strlen(fmt) + 1024;
char *bf = new char[len];
va_list args;
va_start(args, fmt);
vsnprintf(bf, len, fmt, args);
va_end(args);
el_list.add_msg(true, header, bf, LW_LR);
delete [] bf;
}
// Print the string in an error pop-up.
//
void
cErrLog::PopUpErr(const char *string)
{
if (!string || !*string)
return;
if (XM()->RunMode() == ModeNormal)
DSPmainWbag(PopUpErr(MODE_ON, string, STY_NORM))
else
fputs(string, stderr);
}
// Print the string in an error pop-up, with some extra options.
//
void
cErrLog::PopUpErrEx(const char *string, bool sty, int lw_code)
{
if (!string || !*string)
return;
if (XM()->RunMode() == ModeNormal) {
if (lw_code < 0)
// use default placement
DSPmainWbag(PopUpErr(MODE_ON, string,
sty ? STY_FIXED : STY_NORM))
else {
// assigned placement
GRloc loc((LWenum)lw_code);
DSPmainWbag(PopUpErr(MODE_ON, string,
sty ? STY_FIXED : STY_NORM, loc))
}
}
else
fputs(string, stderr);
}
// Format and print a message in an error pop-up. This is a separate
// function from above, since literal '%' characters are a problem.
//
void
cErrLog::PopUpErrV(const char *fmt, ...)
{
if (!fmt || !*fmt)
return;
int len = strlen(fmt) + 1024;
char *bf = new char[len];
va_list args;
va_start(args, fmt);
vsnprintf(bf, len, fmt, args);
va_end(args);
if (XM()->RunMode() == ModeNormal)
DSPmainWbag(PopUpErr(MODE_ON, bf))
else
fputs(bf, stderr);
delete [] bf;
}
void
cErrLog::PopUpWarn(const char *string)
{
if (!string || !*string)
return;
if (XM()->RunMode() == ModeNormal)
DSPmainWbag(PopUpWarn(MODE_ON, string))
else
fputs(string, stderr);
}
// Print the string in a warning pop-up.
//
void
cErrLog::PopUpWarnEx(const char *string, bool sty, int lw_code)
{
if (!string || !*string)
return;
if (XM()->RunMode() == ModeNormal) {
if (lw_code < 0)
// use default placement
DSPmainWbag(PopUpWarn(MODE_ON, string,
sty ? STY_FIXED : STY_NORM))
else {
// assigned placement
GRloc loc((LWenum)lw_code);
DSPmainWbag(PopUpWarn(MODE_ON, string,
sty ? STY_FIXED : STY_NORM, loc))
}
}
else
fputs(string, stderr);
}
// Format and print a message in an error pop-up. This is a separate
// function from above, since literal '%' characters are a problem
//
void
cErrLog::PopUpWarnV(const char *fmt, ...)
{
if (!fmt || !*fmt)
return;
int len = strlen(fmt) + 1024;
char *bf = new char[len];
va_list args;
va_start(args, fmt);
vsnprintf(bf, len, fmt, args);
va_end(args);
if (XM()->RunMode() == ModeNormal)
DSPmainWbag(PopUpWarn(MODE_ON, bf))
else
fputs(bf, stderr);
delete [] bf;
}
// Open a directory for the log files, create if necessary.
//
bool
cErrLog::OpenLogDir(const char *app_root)
{
const char *path = getenv("XIC_LOG_DIR");
if (!path || !*path)
path = getenv("XIC_TMP_DIR");
if (!path || !*path)
path = getenv("TMPDIR");
if (!path || !*path)
path = "/tmp";
path = pathlist::expand_path(path, true, true);
#ifdef WIN32
if (lstring::is_dirsep(path[0]) && !lstring::is_dirsep(path[1])) {
// Add a drive specifier. If the CWD is a share, use "C:".
char *cwd = getcwd(0, 0);
if (!isalpha(cwd[0]) || cwd[1] != ':') {
cwd[0] = 'c';
cwd[1] = ':';
}
cwd[2] = 0;
char *t = new char[strlen(path) + 4];
strcpy(t, cwd);
free(cwd);
strcpy(t+2, path);
delete [] path;
path = t;
}
// In Windows, create the directory.
mkdir(path);
#endif
char buf[64];
if (!app_root)
app_root = "errlog";
strcpy(buf, app_root);
char *e = strrchr(buf, '.');
// Strip exec suffix, if any.
if (e && lstring::cieq(e, ".exe"))
*e = 0;
e = buf + strlen(buf);
sprintf(e, ".%d", (int)getpid());
char *logdir = pathlist::mk_path(path, buf);
#ifdef WIN32
if (mkdir(logdir) && errno != EEXIST) {
#else
if (mkdir(logdir, 0755) && errno != EEXIST) {
#endif
delete [] logdir;
fprintf(stderr,
"Error: Could not create directory in %s.\n"
"I need to create a directory in /tmp, or in a directory given by\n"
"any of the environment variables XIC_LOG_DIR, XIC_TMP_DIR, TMPDIR.\n"
"This directory must exist and have write permission for the user.\n",
path);
delete [] path;
return (false);
}
delete [] path;
el_log_directory = logdir;
if (el_list.log_filename()) {
// Export the log file path to the graphics system. A button
// will appear in error windows which will pop up the file
// viewer loaded with this file.
path = pathlist::mk_path(el_log_directory, el_list.log_filename());
DSPmainWbag(SetErrorLogName(path));
delete [] path;
}
return (true);
}
// Return a list of the files in the log directory.
//
stringlist *
cErrLog::ListLogDir()
{
if (!el_log_directory)
return (0);
stringlist *s0 = 0;
DIR *wdir = opendir(el_log_directory);
if (wdir) {
struct dirent *de;
while ((de = readdir(wdir)) != 0) {
if (!strcmp(de->d_name, "."))
continue;
if (!strcmp(de->d_name, ".."))
continue;
s0 = new stringlist(lstring::copy(de->d_name), s0);
}
closedir(wdir);
stringlist::sort(s0);
}
return (s0);
}
// Remove the log directory, done on normal exit.
//
void
cErrLog::CloseLogDir()
{
if (!el_log_directory)
return;
// Mail the memory errors file, if it exists.
if (el_mail_address && el_mem_err_log_name) {
char *path = pathlist::mk_path(el_log_directory, el_mem_err_log_name);
FILE *fp = fopen(path, "r");
if (fp) {
sLstr lstr;
char buf[256];
while (fgets(buf, 256, fp) != 0)
lstr.add(buf);
fclose(fp);
if (!getenv("XICNOMAIL") && !getenv("XTNOMAIL")) {
miscutil::send_mail(el_mail_address, "XicMemoryErrors",
lstr.string_trim());
}
else {
fp = fopen(el_mem_err_log_name, "w");
if (fp)
fputs(lstr.string_trim(), fp);
fclose(fp);
fprintf(stderr,
"Memory errors were detected. Please email %s to\n%s.\n",
el_mem_err_log_name, el_mail_address);
}
}
delete [] path;
}
if (XM()->RunMode() == ModeServer) {
// All descriptors to the stdout log must be closed, or the
// log file won't be unlinked before the rmdir call in some
// cases, e.g., when the directory is on an NFS share under
// Linux. This causes rmdir to fail and the empty directory
// will remain.
//
close(1);
close(2);
}
DIR *wdir = opendir(el_log_directory);
if (wdir) {
char *path = new char[strlen(el_log_directory) + 256];
strcpy(path, el_log_directory);
char *t = path + strlen(path) - 1;
if (!lstring::is_dirsep(*t)) {
t++;
*t++ = '/';
*t = 0;
}
else
t++;
struct dirent *de;
while ((de = readdir(wdir)) != 0) {
if (!strcmp(de->d_name, "."))
continue;
if (!strcmp(de->d_name, ".."))
continue;
strcpy(t, de->d_name);
unlink(path);
}
closedir(wdir);
delete [] path;
}
rmdir(el_log_directory);
}
// Special fopen() to open a log file in the log directory.
//
FILE *
cErrLog::OpenLog(const char *name, const char *mode, bool sizetest)
{
if (!name || !mode)
return (0);
char *path;
if (el_log_directory && *el_log_directory)
path = pathlist::mk_path(el_log_directory, name);
else
path = lstring::copy(name);
if (*mode == 'a' && sizetest) {
// make sure file doesn't grow too large
struct stat st;
if (stat(path, &st) == 0 && st.st_size > 100000) {
char *bak = new char[strlen(path) + 3];
strcpy(bak, path);
strcat(bak, ".0");
if (!filestat::move_file_local(bak, path))
GRpkgIf()->ErrPrintf(ET_ERROR, "%s", filestat::error_msg());
delete [] bak;
FILE *fp = fopen(path, "w");
if (fp)
fputs("# size limit exceeded, file rollover\n", fp);
delete [] path;
return (fp);
}
}
if (*mode == 'w') {
if (!filestat::create_bak(path)) {
GRpkgIf()->ErrPrintf(ET_ERROR, "%s", filestat::error_msg());
return (0);
}
char *bak = new char[strlen(path) + 3];
strcpy(bak, path);
strcat(bak, ".0");
if (!access(bak, F_OK)) {
if (!filestat::create_bak(bak))
GRpkgIf()->ErrPrintf(ET_ERROR, "%s", filestat::error_msg());
unlink(bak);
}
delete [] bak;
}
FILE *fp = fopen(path, mode);
delete [] path;
return (fp);
}
// End of cErrLog functions.
void
sMsgList::set_filename(const char *fname)
{
delete [] ml_log_filename;
ml_log_filename = lstring::copy(fname);
}
// Return a *copy* of the message corresponding to num, or 0 if out of
// range. The range is the current error number and the positive
// KEEPMSGS below that.
//
char *
sMsgList::get_msg(int num)
{
if (!ml_msg_list)
return (0);
char *s = ml_msg_list->string;
int curnum;
if (sscanf(s, "(%d)", &curnum) != 1)
// List corrupted!
return (0);
if (num > curnum || num <= 0 || num <= curnum - KEEPMSGS + 1)
return (0);
for (stringlist *sl = ml_msg_list; sl; sl = sl->next) {
if (num == curnum)
return (lstring::copy(sl->string));
curnum--;
}
return (0);
}
// Add msgstr to a running list of error messages, and pop up the
// message list (scroll bars come automatically if needed).
//
// The posn is an LWenum value (graphics.h).
//
void
sMsgList::add_msg(bool warn, const char *header, const char *msgstr,
int posn)
{
if (!msgstr || !*msgstr)
return;
if (!ml_log_filename) {
fprintf(stderr, "%s: %s\n", warn ? "Warning" : "Error", msgstr);
return;
}
ml_msg_count++;
char buf[256];
FILE *fp = Log()->OpenLog(ml_log_filename, ml_msg_count == 1 ? "w" : "a",
true);
if (!fp && ml_msg_count == 1) {
sprintf(buf,
"(%d) Warning [initialization]\n"
"Can't open %s file, errors and warningss won't be logged.",
ml_msg_count, ml_log_filename);
ml_msg_list = new stringlist(lstring::copy(buf), ml_msg_list);
ml_msg_count++;
}
int hlen = 24 + (header ? strlen(header) : 0);
char *mbuf = new char[strlen(msgstr) + hlen];
if (header)
sprintf(mbuf, "(%d) %s [%s]\n%s", ml_msg_count,
warn ? "Warning" : "Error", header, msgstr);
else
sprintf(mbuf, "(%d) %s\n%s", ml_msg_count,
warn ? "Warning" : "Error", msgstr);
char *t = mbuf + strlen(mbuf) - 1;
if (*t == '\n')
*t = 0;
ml_msg_list = new stringlist(mbuf, ml_msg_list);
const char *sepstring = "----------------------------\n";
if (fp) {
if (ml_msg_count == 1)
fprintf(fp, "# %s\n", XM()->IdString());
else
fputs(sepstring, fp);
fprintf(fp, "%s\n", mbuf);
}
int cnt = 0;
for (stringlist *sl = ml_msg_list; sl; sl = sl->next) {
cnt++;
if (cnt == KEEPMSGS) {
delete [] sl->string;
if (fp)
sprintf(buf, "See %s file.", ml_log_filename);
else
strcpy(buf, "No logfile, message list truncated.");
sl->string = lstring::copy(buf);
stringlist::destroy(sl->next);
sl->next = 0;
break;
}
}
if (fp)
fclose(fp);
sLstr lstr;
for (stringlist *sl = ml_msg_list; sl; sl = sl->next) {
lstr.add(sl->string);
lstr.add_c('\n');
if (sl->next)
lstr.add(sepstring);
}
if (DSP()->MainWdesc() && DSP()->MainWdesc()->Wbag())
Log()->PopUpErrEx(lstr.string(), false, posn);
else
fprintf(stderr, "%s: %s\n", warn ? "Warning" : "Error", msgstr);
}
| 30.295209 | 78 | 0.534973 | [
"object"
] |
754bf06bc90e8288b05308d5fa4d1ae8c4f6acdf | 1,596 | cpp | C++ | Src/142_LinkedListCycleII/LinkedListCycleII.cpp | HATTER-LONG/https---github.com-HATTER-LONG-AlgorithmTraining | bd2773c066352bab46ac019cef9fbbff8761c147 | [
"Apache-2.0"
] | 2 | 2021-02-07T07:03:43.000Z | 2021-02-08T16:04:42.000Z | Src/142_LinkedListCycleII/LinkedListCycleII.cpp | HATTER-LONG/https---github.com-HATTER-LONG-AlgorithmTraining | bd2773c066352bab46ac019cef9fbbff8761c147 | [
"Apache-2.0"
] | null | null | null | Src/142_LinkedListCycleII/LinkedListCycleII.cpp | HATTER-LONG/https---github.com-HATTER-LONG-AlgorithmTraining | bd2773c066352bab46ac019cef9fbbff8761c147 | [
"Apache-2.0"
] | 1 | 2021-02-24T09:48:26.000Z | 2021-02-24T09:48:26.000Z | #include "Tools/ListNodeTools.h"
#include <algorithm>
#include <catch2/catch.hpp>
#include <climits>
#include <cstddef>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace Catch;
using namespace std;
// 快慢指针
/**
* fast 指针走过的距离都为 slow 指针的 2 倍,这时从相遇点到入环点的距离加上 n−1
* 圈的环长,恰好等于从链表头部到入环点的距离。
*
*/
class Solution
{
public:
ListNode* detectCycle(ListNode* head)
{
ListNode *fast = head, *slow = head;
while (fast != nullptr)
{
slow = slow->next;
if (fast->next == nullptr)
{
return nullptr;
}
fast = fast->next->next;
if (fast == slow)
{
ListNode* ptr = head;
while (ptr != slow)
{
ptr = ptr->next;
slow = slow->next;
}
return ptr;
}
}
return nullptr;
}
};
TEST_CASE("Check Solution detectCycle method work successfully")
{
Solution solution;
vector<int> inputParm;
int inputParm2;
tie(inputParm, inputParm2) = GENERATE(table<vector<int>, int>({
make_tuple(vector<int> { 3, 2, 0, -4 }, 1),
make_tuple(vector<int> { 1, 2 }, 0),
make_tuple(vector<int> { 1 }, -1),
}));
auto listNodeHead = initListNode(inputParm, inputParm2);
auto* resultParm = findListNode(listNodeHead.get(), inputParm2);
CAPTURE(resultParm);
REQUIRE(solution.detectCycle(listNodeHead.get()) == (resultParm));
}
| 22.478873 | 70 | 0.550752 | [
"vector"
] |
754e694132002afba9923fd447532ec655957064 | 693 | hpp | C++ | src/msTreeType-cpp/msTreeType.hpp | galudino/My-CLI-Playground | 6c34f4718444aa2fc592de7b224746df1aaa2828 | [
"MIT"
] | null | null | null | src/msTreeType-cpp/msTreeType.hpp | galudino/My-CLI-Playground | 6c34f4718444aa2fc592de7b224746df1aaa2828 | [
"MIT"
] | null | null | null | src/msTreeType-cpp/msTreeType.hpp | galudino/My-CLI-Playground | 6c34f4718444aa2fc592de7b224746df1aaa2828 | [
"MIT"
] | null | null | null | /*!
\file msTreeType.hpp
\brief Header file
\author
\date
*/
#ifndef MSTREETYPE_HPP
#define MSTREETYPE_HPP
#include "graphType.hpp"
#include <vector>
#include <fstream>
class msTreeType : public graphType {
public:
void createSpanningGraph();
void createSpanningGraph(const std::string &filename);
void createSpanningGraph(std::ifstream &infile);
void printWeightMatrix();
void minimalSpanning(int sVertex);
void printTreeAndWeight();
msTreeType(int size = 0);
protected:
int source;
std::vector<std::vector<double>> weights;
std::vector<int> edges;
std::vector<double> edgeWeights;
};
#endif /* MSTREETYPE_HPP */
| 19.8 | 58 | 0.68254 | [
"vector"
] |
754e72b2c8d6ba762fef9df0d21c04520240386a | 8,779 | cpp | C++ | OperationalStatus.cpp | kovdan01/OMS-Auditd-Plugin | 529db434129f43f5763a405eb3357bedad757968 | [
"MIT"
] | 13 | 2019-07-01T04:58:51.000Z | 2022-01-28T13:38:02.000Z | OperationalStatus.cpp | kovdan01/OMS-Auditd-Plugin | 529db434129f43f5763a405eb3357bedad757968 | [
"MIT"
] | 16 | 2019-05-08T00:40:43.000Z | 2021-07-27T23:11:26.000Z | OperationalStatus.cpp | kovdan01/OMS-Auditd-Plugin | 529db434129f43f5763a405eb3357bedad757968 | [
"MIT"
] | 9 | 2019-12-19T00:06:53.000Z | 2021-12-03T09:45:20.000Z | /*
microsoft-oms-auditd-plugin
Copyright (c) Microsoft Corporation
All rights reserved.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "OperationalStatus.h"
#include "Logger.h"
#include "RecordType.h"
#include "Translate.h"
#include "auoms_version.h"
#include "StringUtils.h"
#include <sstream>
#include <sys/time.h>
#include <rapidjson/stringbuffer.h>
#include <rapidjson/writer.h>
bool OperationalStatusListener::Initialize() {
return _listener.Open();
}
void OperationalStatusListener::on_stopping() {
std::unique_lock<std::mutex> lock(_run_mutex);
_listener.Close();
}
void OperationalStatusListener::run() {
Logger::Info("OperationalStatusListener starting");
while(!IsStopping()) {
int newfd = _listener.Accept();
if (newfd > 0) {
Logger::Info("OperationalStatusListener: new connection: fd == %d", newfd);
if (!IsStopping()) {
handle_connection(newfd);
} else {
close(newfd);
}
} else {
return;
}
}
}
void OperationalStatusListener::handle_connection(int fd) {
IOBase io(fd);
auto rep = _status_fn();
io.SetNonBlock(true);
// Only give status requester 100 milliseconds to read the status.
// We don't care if the write fails
io.WriteAll(rep.data(), rep.size(), 100, [this]() { return !IsStopping(); });
io.Close();
}
bool OperationalStatus::Initialize() {
Logger::Info("OperationalStatus initializing");
return _listener.Initialize();
}
std::vector<std::pair<ErrorCategory, std::string>> OperationalStatus::GetErrors() {
std::unique_lock<std::mutex> lock(_run_mutex);
std::vector<std::pair<ErrorCategory, std::string>> errors;
for (auto& e : _error_conditions) {
errors.emplace_back(e);
}
std::sort(errors.begin(), errors.end(), [](std::pair<ErrorCategory, std::string>& a, std::pair<ErrorCategory, std::string>& b) -> bool { return a.first < b.first; });
return errors;
}
void OperationalStatus::SetErrorCondition(ErrorCategory category, const std::string& error_msg) {
std::unique_lock<std::mutex> lock(_run_mutex);
_error_conditions[category] = error_msg;
}
void OperationalStatus::ClearErrorCondition(ErrorCategory category) {
std::unique_lock<std::mutex> lock(_run_mutex);
_error_conditions.erase(category);
}
void OperationalStatus::SetDesiredAuditRules(const std::vector<AuditRule>& rules) {
std::unique_lock<std::mutex> lock(_run_mutex);
std::vector<std::string> lines;
for (auto& rule :rules ) {
lines.emplace_back(rule.CanonicalText());
}
_desired_audit_rules = join(lines, "\n");
}
void OperationalStatus::SetLoadedAuditRules(const std::vector<AuditRule>& rules) {
std::unique_lock<std::mutex> lock(_run_mutex);
std::vector<std::string> lines;
for (auto& rule :rules ) {
lines.emplace_back(rule.CanonicalText());
}
_loaded_audit_rules = join(lines, "\n");
}
void OperationalStatus::SetRedactionRules(const std::vector<std::shared_ptr<const CmdlineRedactionRule>>& rules) {
if (rules.empty()) {
_redaction_rules = "";
}
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer;
buffer.Clear();
writer.Reset(buffer);
writer.StartArray();
for (auto& rule : rules) {
writer.StartObject();
writer.Key("file_name");
writer.String(rule->FileName().data(), rule->FileName().size(), true);
writer.Key("name");
writer.String(rule->Name().data(), rule->Name().size(), true);
writer.Key("regex");
writer.String(rule->Regex().data(), rule->Regex().size(), true);
std::string rchar;
rchar.push_back(rule->ReplacementChar());
writer.Key("replacement_char");
writer.String(rchar.data(), rchar.size(), true);
writer.EndObject();
}
writer.EndArray();
_redaction_rules = std::string(buffer.GetString(), buffer.GetSize());
}
void OperationalStatus::on_stopping() {
std::unique_lock<std::mutex> lock(_run_mutex);
_listener.Stop();
}
void OperationalStatus::run() {
Logger::Info("OperationalStatus starting");
_listener.Start();
// Send first status 15 seconds after startup
if(!_sleep(15000)) {
if (!send_status()) {
return;
}
}
// Generate a status message once an hour
while(!_sleep(3600000)) {
if (!send_status()) {
return;
}
}
}
std::string OperationalStatus::get_status_str() {
std::stringstream str;
str << "Version: " << AUOMS_VERSION << std::endl;
auto errors = GetErrors();
if (errors.empty()) {
str << "Status: Healthy" << std::endl;
} else {
str << "Status: " << errors.size() << " errors" << std::endl;
str << "Errors:" << std::endl;
for (auto& error: errors) {
str << " " << error.second << std::endl;
}
}
return str.str();
}
std::string OperationalStatus::get_json_status() {
auto errors = GetErrors();
if (errors.empty()) {
return std::string();
}
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer;
buffer.Clear();
writer.Reset(buffer);
writer.StartObject();
for (auto& error: errors) {
std::string key;
switch (error.first) {
case ErrorCategory::DATA_COLLECTION:
key = "DATA_COLLECTION";
break;
case ErrorCategory::DESIRED_RULES:
key = "DESIRED_RULES";
break;
case ErrorCategory::AUDIT_RULES_KERNEL:
key = "AUDIT_RULES_KERNEL";
break;
case ErrorCategory::AUDIT_RULES_FILE:
key = "AUDIT_RULES_FILE";
break;
case ErrorCategory ::MISSING_REDACTION_RULES:
key = "MISSING_REDACTION_RULES";
break;
default:
key = "UNKNOWN[" + std::to_string(static_cast<int>(error.first)) + "]";
break;
}
writer.Key(key.data(), key.length(), true);
writer.String(error.second.data(), error.second.size(), true);
}
writer.EndObject();
return std::string(buffer.GetString(), buffer.GetSize());
}
bool OperationalStatus::send_status() {
struct timeval tv;
gettimeofday(&tv, nullptr);
uint64_t sec = static_cast<uint64_t>(tv.tv_sec);
uint32_t msec = static_cast<uint32_t>(tv.tv_usec)/1000;
int num_fields = 4;
auto errors = get_json_status();
if (!errors.empty()) {
num_fields += 1;
}
if (!_builder.BeginEvent(sec, msec, 0, 1)) {
return false;
}
if (!_builder.BeginRecord(static_cast<uint32_t>(RecordType::AUOMS_STATUS), RecordTypeToName(RecordType::AUOMS_STATUS), "", num_fields)) {
return false;
}
if (!_builder.AddField("version", AUOMS_VERSION, nullptr, field_type_t::UNCLASSIFIED)) {
return false;
}
if (!_builder.AddField("desired_audit_rules", _desired_audit_rules, nullptr, field_type_t::UNCLASSIFIED)) {
return false;
}
if (!_builder.AddField("loaded_audit_rules", _loaded_audit_rules, nullptr, field_type_t::UNCLASSIFIED)) {
return false;
}
if (!_builder.AddField("redaction_rules", _redaction_rules, nullptr, field_type_t::UNCLASSIFIED)) {
return false;
}
if (!errors.empty()) {
if (!_builder.AddField("errors", errors, nullptr, field_type_t::UNCLASSIFIED)) {
return false;
}
}
if(!_builder.EndRecord()) {
return false;
}
return _builder.EndEvent() != 0;
} | 29.459732 | 464 | 0.636861 | [
"vector"
] |
754ffc175e35a0b6859ee2dc779ac9694cbdc157 | 1,617 | hpp | C++ | Modules/OpenGL/Public/Toon/OpenGL/OpenGLGraphicsDriver.hpp | benjinx/Toon | f21032b2f9ad5fbc9a3618a7719c33159257d954 | [
"MIT"
] | 2 | 2021-01-28T03:08:08.000Z | 2021-01-28T03:08:21.000Z | Modules/OpenGL/Public/Toon/OpenGL/OpenGLGraphicsDriver.hpp | benjinx/Toon | f21032b2f9ad5fbc9a3618a7719c33159257d954 | [
"MIT"
] | null | null | null | Modules/OpenGL/Public/Toon/OpenGL/OpenGLGraphicsDriver.hpp | benjinx/Toon | f21032b2f9ad5fbc9a3618a7719c33159257d954 | [
"MIT"
] | null | null | null | #ifndef TOON_OPENGL_GRAPHICS_DRIVER_HPP
#define TOON_OPENGL_GRAPHICS_DRIVER_HPP
#include <Toon/OpenGL/OpenGLConfig.hpp>
#include <Toon/SDL2/SDL2GraphicsDriver.hpp>
#include <Toon/OpenGL/OpenGLPipeline.hpp>
#include <Toon/OpenGL/OpenGLTexture.hpp>
#include <Toon/OpenGL/OpenGLShader.hpp>
#include <Toon/OpenGL/OpenGLMesh.hpp>
#include <Toon/OpenGL/OpenGLMaterial.hpp>
#include <Toon/OpenGL/OpenGLPrimitive.hpp>
#include <Toon/OpenGL/OpenGLBuffer.hpp>
#include <SDL.h>
namespace Toon::OpenGL {
#define TOON_OPENGL_GRAPHICS_DRIVER(x) (dynamic_cast<Toon::OpenGL::OpenGLGraphicsDriver *>(x))
class TOON_OPENGL_API OpenGLGraphicsDriver : public SDL2::SDL2GraphicsDriver
{
public:
DISALLOW_COPY_AND_ASSIGN(OpenGLGraphicsDriver)
OpenGLGraphicsDriver() = default;
virtual ~OpenGLGraphicsDriver() = default;
bool Initialize() override;
void Terminate() override;
void Render() override;
std::shared_ptr<Buffer> CreateBuffer() override;
std::shared_ptr<Pipeline> CreatePipeline(std::shared_ptr<Shader> shader) override;
std::shared_ptr<Texture> CreateTexture() override;
std::shared_ptr<Shader> CreateShader() override;
std::shared_ptr<Mesh> CreateMesh() override;
std::shared_ptr<Material> CreateMaterial() override;
std::shared_ptr<Primitive> CreatePrimitive() override;
private:
void BindUniformBufferObjects();
void InitDebugMessageCallback();
SDL_GLContext _glContext = nullptr;
std::vector<std::weak_ptr<Shader>> _shaderList;
}; // class OpenGLGraphicsDriver
} // namespace Toon::OpenGL
#endif // TOON_OPENGL_GRAPHICS_DRIVER_HPP | 25.265625 | 94 | 0.766234 | [
"mesh",
"render",
"vector"
] |
7553b2e956db71f18aeefa6c2fad532038eae8e4 | 45,578 | hpp | C++ | include/ProMPs_emission.hpp | DiegoAE/BOSD | a7ce88462c64c540ba2922d16eb6f7eba8055b47 | [
"MIT"
] | 19 | 2019-05-03T05:31:43.000Z | 2022-01-08T18:14:31.000Z | include/ProMPs_emission.hpp | DiegoAE/BOSD | a7ce88462c64c540ba2922d16eb6f7eba8055b47 | [
"MIT"
] | 2 | 2019-02-14T15:29:34.000Z | 2020-06-04T10:14:54.000Z | include/ProMPs_emission.hpp | DiegoAE/BOSD | a7ce88462c64c540ba2922d16eb6f7eba8055b47 | [
"MIT"
] | 1 | 2019-07-01T07:44:09.000Z | 2019-07-01T07:44:09.000Z | #ifndef PROMP_EMISSION_H
#define PROMP_EMISSION_H
#include <armadillo>
#include <emissions.hpp>
#include <iostream>
#include <json.hpp>
#include <ForwardBackward.hpp>
#include <map>
#include <memory>
#include <robotics.hpp>
using namespace arma;
using namespace hsmm;
using namespace robotics;
using namespace std;
namespace hsmm {
class NormalInverseWishart {
public:
NormalInverseWishart(vec mu_0, double lambda, mat Phi, int dof) :
Phi_(Phi), dof_(dof), mu_0_(mu_0), lambda_(lambda) {
assert(dof > Phi.n_rows + 1);
vec eigenvalues = eig_sym(Phi);
assert(eigenvalues(0) > 0);
assert(!(lambda < 0));
assert(mu_0.n_rows == Phi.n_rows);
}
// This constructor assumes there is no prior for the mean.
// (i.e. only the inverse-Wishart part).
NormalInverseWishart(mat Phi, int dof) : NormalInverseWishart(
zeros<vec>(Phi.n_rows), 0.0, Phi, dof) {}
vec getMu0() {
return mu_0_;
}
double getLambda() {
return lambda_;
}
mat getPhi() {
return Phi_;
}
int getDof() {
return dof_;
}
private:
vec mu_0_;
double lambda_;
mat Phi_;
int dof_;
};
double zeroMeanGaussianLogLikelihood(const vec& x, const mat &precision) {
return -0.5 * as_scalar(x.t()*precision*x - log(det(precision)) +
x.n_elem * log(2*datum::pi));
}
class ProMPsEmission : public AbstractEmissionOnlineSetting {
public:
ProMPsEmission(vector<FullProMP> promps) :
AbstractEmissionOnlineSetting(promps.size(),
promps.at(0).get_num_joints()), promps_(promps),
diagonal_sigma_y_(true) {
for(int i = 0; i < getNumberStates(); i++)
assert(promps_.at(i).get_num_joints() == getDimension());
}
ProMPsEmission* clone() const {
return new ProMPsEmission(*this);
}
void resetMemCaches() {
cachePhis_.clear();
cacheInvS_.clear();
cacheK_.clear();
cachePosteriorSigma_.clear();
}
// TODO: remove this once this behavior is moved to a subclass.
void setDelta(double delta) {
//assert(delta > 0);
sample_locations_delta_ = delta;
}
// Derived classes could implement a different kinf of dependence
// on the segment duration. Default implementation normalizes
// the input to be between 0 and 1.
// TODO: Implement the segment independent in a subclass.
virtual vec getSampleLocations(int length) const {
if (sample_locations_delta_ < 0)
return linspace<vec>(0, 1.0, length);
else
return linspace<vec>(0, (length-1)*sample_locations_delta_,
length);
}
// This initialization mechanism assumes all the hidden states
// share the same basis functions and their hyperparameters.
void init_params_from_data(int min_duration, int ndurations,
const arma::field<arma::field<arma::mat>>& mobs) {
vector<pair<double, vec>> pairs;
vector<double> noise_vars;
for(auto &obs : mobs) {
for(int t = 0; t < obs.n_elem; t++) {
for(int d = 0; d < ndurations; d++) {
if (t + min_duration + d > obs.n_elem)
break;
int end_idx = t + min_duration + d - 1;
auto &segment = obs.rows(t, end_idx);
vec lsq_omega = least_squares_omega(0, segment);
double var = var_isotropic_gaussian_given_omega(0,
lsq_omega, segment);
pairs.push_back(make_pair(var, lsq_omega));
noise_vars.push_back(var);
}
}
}
sort(pairs.begin(), pairs.end(), [](const pair<double, vec>& a,
const pair<double, vec>& b)
{return a.first < b.first;});
int cutoff_index = (int)((pairs.size() - 1) *
init_fraction_);
double threshold = pairs.at(cutoff_index).first;
cout << "Cuttoff index for init: " << cutoff_index <<
" var: " << threshold << endl;
// Showing a histogram of the distribution of noise vars.
vec vars(noise_vars);
vec histogram_cutoffs = linspace<vec>(0, max(vars), 20);
uvec histogram = histc(vars, histogram_cutoffs);
cout << "Hist. of noise vars:" << endl << histogram << endl;
mat remaining_w(promps_.at(0).get_model().get_mu_w().n_rows,
cutoff_index + 1);
for(int i = 0; i <= cutoff_index; i++)
remaining_w.col(i) = pairs.at(i).second;
mat means;
kmeans(means, remaining_w, getNumberStates(), static_subset,
10, false);
// Updating the means of the ProMPs based on the k-means.
for(int i = 0; i < getNumberStates(); i++) {
ProMP promp = promps_.at(i).get_model();
promp.set_mu_w(means.col(i));
promps_.at(i).set_model(promp);
}
}
// Note that the method is returning the posterior covariance for
// the given state and duration which is independent of obs.
mat generateCachedMatrices(const pair<int, int> &p) const {
if (cacheInvS_.find(p) == cacheInvS_.end() ||
cacheK_.find(p) == cacheK_.end()) {
int state = p.first;
int dur = p.second;
const FullProMP& promp = promps_.at(state);
const cube& Phis = getPhiCube(state, dur);
mat Sigma(promp.get_model().get_Sigma_w());
mat Sigma_y(promp.get_model().get_Sigma_y());
field<mat> invS(dur);
field<mat> K(dur);
for(int i = 0; i < dur; i++) {
const mat& Phi = Phis.slice(i);
mat S = Phi * Sigma * Phi.t() + Sigma_y;
invS(i) = inv_sympd(S);
// Kalman updating (correcting) step.
K(i) = Sigma * Phi.t() * inv(S);
Sigma = Sigma - K(i) * S * K(i).t();
}
// Caching the matrices for faster likelihood evaluation.
cacheInvS_[p] = invS;
cacheK_[p] = K;
cachePosteriorSigma_[p] = Sigma;
}
return cachePosteriorSigma_.at(p);
}
double loglikelihood(int state, const field<mat>& obs) const {
// Making sure all the required matrices are already
// precomputed.
pair<int, int> p = make_pair(state, obs.n_elem);
generateCachedMatrices(p);
const FullProMP& promp = promps_.at(state);
const cube& Phis = getPhiCube(state, obs.n_elem);
vec mu(promp.get_model().get_mu_w());
const field<mat>& invS = cacheInvS_[p];
const field<mat>& K = cacheK_[p];
double ret = 0;
for(int i = 0; i < obs.n_elem; i++) {
const mat& Phi = Phis.slice(i);
if (obs(i).is_empty()) {
// Making sure all the missing obs are at the end.
// Other missing obs patterns are not supported yet.
for(int j = i; j < obs.n_elem; j++)
assert(obs(j).is_empty());
break;
}
vec diff = obs(i) - Phi * mu;
// p(y_t | y_1, ..., y_{t-1}).
ret += zeroMeanGaussianLogLikelihood(diff, invS(i));
mu = mu + K(i) * diff;
}
return ret;
}
double informationFilterLoglikelihood(int state,
const field<mat>& obs) const {
const FullProMP& promp = promps_.at(state);
// The samples are assumed to be equally spaced.
vec sample_locations = getSampleLocations(obs.n_elem);
// Moment based parameterization.
vec mu(promp.get_model().get_mu_w());
mat Sigma(promp.get_model().get_Sigma_w());
mat Sigma_y(promp.get_model().get_Sigma_y());
// Canonical parameterization.
mat information_matrix = inv_sympd(Sigma);
vec information_state = information_matrix * mu;
mat inv_obs_noise = inv_sympd(Sigma_y);
double ret = 0;
for(int i = 0; i < obs.n_elem; i++) {
mat Phi = promp.get_phi_t(sample_locations(i));
// Computing the likelihood under the current filtering
// distribution.
mat filtered_Sigma = inv_sympd(information_matrix);
vec filtered_mu = filtered_Sigma * information_state;
// p(y_t | y_{1:t-1}).
random::NormalDist dist = random::NormalDist(
Phi * filtered_mu,
Phi * filtered_Sigma * Phi.t() + Sigma_y);
ret = ret + log_normal_density(dist, obs(i));
mat aux = Phi.t() * inv_obs_noise;
mat I_k = aux * Phi;
mat i_k = aux * obs(i);
information_matrix = information_matrix + I_k;
information_state = information_state + i_k;
}
return ret;
}
double loglikelihoodBatchVersion(int state, const arma::mat& obs) {
int dimension = obs.n_rows;
assert(dimension == getDimension());
random::NormalDist dist = getNormalDistForMultipleTimeSteps(state,
obs.n_cols);
vec stacked_obs = vectorise(obs);
return random::log_normal_density(dist, stacked_obs);
}
void reestimate(int min_duration,
const arma::field<arma::cube>& meta,
const arma::field<arma::field<arma::mat>>& mobs) {
int nseq = mobs.n_elem;
for(int i = 0; i < getNumberStates(); i++) {
ProMP promp = promps_.at(i).get_model();
const mat inv_Sigma_w = inv_sympd(promp.get_Sigma_w());
const mat inv_Sigma_y = inv_sympd(promp.get_Sigma_y());
const vec mu_w = promp.get_mu_w();
vector<double> mult_c;
vector<double> denominator_Sigma_y;
for(int s = 0; s < nseq; s++) {
const cube& eta = meta(s);
int nobs = mobs(s).n_elem;
int ndurations = eta.n_cols;
for(int t = min_duration - 1; t < nobs; t++) {
for(int d = 0; d < ndurations; d++) {
int first_idx_seg = t - min_duration - d + 1;
if (first_idx_seg < 0)
break;
mult_c.push_back(eta(i, d, t));
denominator_Sigma_y.push_back(eta(i, d, t) +
log(min_duration + d));
}
}
}
// Computing the multiplicative constants for mu_w and
// Sigma_w.
vec mult_c_normalized(mult_c);
mult_c_normalized -= logsumexp(mult_c_normalized);
mult_c_normalized = exp(mult_c_normalized);
// Computing the multiplicative constants for Sigma_y since
// they have a different denominator.
vec mult_c_Sigma_y_normalized(mult_c);
vec den_Sigma_y(denominator_Sigma_y);
mult_c_Sigma_y_normalized -= logsumexp(den_Sigma_y);
mult_c_Sigma_y_normalized = exp(mult_c_Sigma_y_normalized);
mat new_Sigma_y(size(promp.get_Sigma_y()), fill::zeros);
// EM for ProMPs.
vec weighted_sum_post_mean(size(mu_w), fill::zeros);
mat weighted_sum_post_cov(size(inv_Sigma_w), fill::zeros);
mat weighted_sum_post_mean_mean_T(size(inv_Sigma_w),
fill::zeros);
int idx_mult_c = 0;
for(int s = 0; s < nseq; s++) {
auto& obs = mobs(s);
int nobs = obs.n_elem;
int ndurations = meta(s).n_cols;
for(int t = min_duration - 1; t < nobs; t++) {
for(int d = 0; d < ndurations; d++) {
int first_idx_seg = t - min_duration - d + 1;
if (first_idx_seg < 0)
break;
const int current_duration = min_duration + d;
const cube& Phis = getPhiCube(i, current_duration);
// E step for the emission hidden variables (Ws).
// Computing the posterior of W given Y and Theta.
// Computing the posterior covariance of the hidden
// variable w for this segment.
mat posterior_cov(size(inv_Sigma_w), fill::zeros);
for(int step = 0; step < current_duration; step++) {
posterior_cov += Phis.slice(step).t() *
inv_Sigma_y * Phis.slice(step);
}
posterior_cov = (posterior_cov+posterior_cov.t())/2.0;
posterior_cov = posterior_cov + inv_Sigma_w;
posterior_cov = (posterior_cov+posterior_cov.t())/2.0;
posterior_cov = inv_sympd(posterior_cov);
posterior_cov = (posterior_cov+posterior_cov.t())/2.0;
// Computing the posterior mean of the hidden
// variable w for this segment.
vec posterior_mean(size(mu_w), fill::zeros);
for(int step = 0; step < current_duration; step++) {
const vec& ob = obs(first_idx_seg + step);
posterior_mean += Phis.slice(step).t() *
inv_Sigma_y * ob;
}
posterior_mean = inv_Sigma_w * mu_w + posterior_mean;
posterior_mean = posterior_cov * posterior_mean;
// Getting the multiplicative constants.
double mult_constant = mult_c_normalized(idx_mult_c);
double mult_constant_Sigma_y =
mult_c_Sigma_y_normalized(idx_mult_c);
idx_mult_c++;
// Statistics required for updating mu_w & Sigma_w.
weighted_sum_post_mean += mult_constant *
posterior_mean;
weighted_sum_post_cov += mult_constant *
posterior_cov;
weighted_sum_post_mean_mean_T += mult_constant *
posterior_mean * posterior_mean.t();
// Computing the new output noise covariance: Sigma_y.
mat Sigma_y_term(size(new_Sigma_y), fill::zeros);
for(int step = 0; step < current_duration; step++) {
const mat& phi = Phis.slice(step);
const vec& diff_y = obs(first_idx_seg + step) -
phi * posterior_mean;
Sigma_y_term += diff_y * diff_y.t() +
phi * posterior_cov * phi.t();
}
new_Sigma_y += mult_constant_Sigma_y * Sigma_y_term;
}
}
}
// Expected number of segments generated by the i-th state.
double mle_den = exp(logsumexp(mult_c));
// M step for the emission variables.
vec new_mu_w_MLE(weighted_sum_post_mean);
mat new_Sigma_w_MLE = weighted_sum_post_cov +
weighted_sum_post_mean_mean_T - new_mu_w_MLE *
new_mu_w_MLE.t();
// If there is a prior then we do MAP instead.
mat new_Sigma_w;
mat new_mu_w;
if (normal_inverse_prior_) {
double v_0 = normal_inverse_prior_->getDof();
double D = mu_w.n_rows;
mat S_0 = normal_inverse_prior_->getPhi();
new_Sigma_w = (S_0 + mle_den * new_Sigma_w_MLE) /
(v_0 + mle_den + D + 2);
double k_0 = normal_inverse_prior_->getLambda();
vec m_0 = normal_inverse_prior_->getMu0();
new_mu_w = (k_0 * m_0 + mle_den * new_mu_w_MLE) /
(mle_den + k_0);
}
else {
new_Sigma_w = new_Sigma_w_MLE;
new_mu_w = new_mu_w_MLE;
}
cout << "State " << i << " MLE Den: " << mle_den << " ";
if (mle_den > epsilon_) {
// Making sure the noise covariance is diagonal.
if (diagonal_sigma_y_)
new_Sigma_y = diagmat(new_Sigma_y.diag());
// Checking that the new Sigma_w is a covariance matrix.
vec eigenvalues_map = eig_sym(new_Sigma_w);
assert(eigenvalues_map(0) > 0);
// Setting the new parameters.
promp.set_mu_w(new_mu_w);
promp.set_Sigma_w(new_Sigma_w);
promp.set_Sigma_y(new_Sigma_y);
promps_.at(i).set_model(promp);
resetMemCaches();
cout << ". Updated." << endl;
}
else
cout << ". Not updated." << endl;
}
}
// Unshadowing this method from the AbstractEmission class.
using AbstractEmission::sampleFromState;
field<mat> sampleFromState(int state, int size,
mt19937 &rand_generator) const {
return sampleFromProMP(promps_.at(state), size, rand_generator);
}
field<mat> sampleFromProMP(const FullProMP& fpromp, int size,
mt19937 &rand_generator) const {
const ProMP& model = fpromp.get_model();
assert(model.get_mu_w().n_rows == model.get_Sigma_w().n_rows);
vector<vec> w_samples = random::sample_multivariate_normal(
rand_generator,
{model.get_mu_w(), model.get_Sigma_w()}, 1);
vec w = w_samples.back();
vec noise_mean = zeros<vec>(getDimension());
vector<vec> output_noise = random::sample_multivariate_normal(
rand_generator, {noise_mean, model.get_Sigma_y()}, size);
field<mat> ret(size);
// The samples are assumed to be equally spaced.
vec sample_locations = getSampleLocations(size);
for(int i = 0; i < size; i++) {
double z = sample_locations(i);
mat phi_z =fpromp.get_phi_t(z);
ret(i) = phi_z * w + output_noise.at(i);
}
return ret;
}
// Equivalent to sampleFromState but uses conditioning.
field<mat> sampleFromState2(int state, int size,
mt19937 &rand_generator) const {
field<mat> no_obs;
return sampleNextObsGivenPastObs(state, size, no_obs,
rand_generator);
}
field<mat> sampleNextObsGivenPastObs(int state, int seg_dur,
const field<mat>& past_obs, std::mt19937 &rng) const {
assert(past_obs.n_elem < seg_dur);
// Making sure all the required matrices are already computed.
pair<int, int> p = make_pair(state, seg_dur);
generateCachedMatrices(p);
field<mat> ret(seg_dur);
for(int i = 0; i < past_obs.n_elem; i++)
ret(i) = past_obs(i);
const FullProMP& promp = promps_.at(state);
const cube& Phis = getPhiCube(state, seg_dur);
vec mu(promp.get_model().get_mu_w());
const field<mat>& invS = cacheInvS_.at(p);
const field<mat>& K = cacheK_.at(p);
int i;
for(i = 0; i < past_obs.n_elem; i++)
mu = mu + K(i) * (past_obs(i) - Phis.slice(i) * mu);
// Now i indexes the offset we want to sample from.
for(; i < seg_dur; i++) {
vector<vec> sample = random::sample_multivariate_normal(
rng, {Phis.slice(i) * mu, inv(invS(i))}, 1);
ret(i) = sample.at(0);
mu = mu + K(i) * (ret(i) - Phis.slice(i) * mu);
}
return ret;
}
field<mat> sampleFirstSegmentObsGivenLastSegment(int curr_state,
int curr_seg_dur, const field<mat> &last_segment,
int last_state, std::mt19937 &rng) const {
mat last_obs = last_segment(last_segment.n_elem - 1);
// Making sure all the required matrices are already computed.
pair<int, int> p = make_pair(curr_state, curr_seg_dur);
pair<int, int> last_p = make_pair(last_state,
last_segment.n_elem);
generateCachedMatrices(p);
mat last_p_Sigma = generateCachedMatrices(last_p);
// Finding the posterior omega mean for the last segment.
const cube& LPhis = getPhiCube(last_state, last_segment.n_elem);
vec last_p_mu(promps_.at(last_state).get_model().get_mu_w());
const field<mat>& last_K = cacheK_[last_p];
for(int i = 0; i < last_segment.n_elem; i++) {
const mat& Phi = LPhis.slice(i);
vec diff = last_segment(i) - Phi * last_p_mu;
last_p_mu = last_p_mu + last_K(i) * diff;
}
FullProMP last_full_promp(promps_.at(last_state));
mat zeros_Sigma_y = zeros<mat>(getDimension(), getDimension());
ProMP last_p_promp(last_p_mu, last_p_Sigma, zeros_Sigma_y);
last_full_promp.set_model(last_p_promp);
// This gives the posterior distribution over q = (y, v) at the
// last time step of the last segment.
random::NormalDist last_pos_vel = last_full_promp.joint_dist(
1.0, true, true, false);
vec last_p_pos = last_pos_vel.mean().head(getDimension());
vec last_p_vel = last_pos_vel.mean().tail(getDimension());
FullProMP promp = promps_.at(curr_state);
promp = promp.condition_current_position(0, 1.0, last_p_pos);
//promp = promp.condition_current_state(0, 1.0, last_p_pos,
// last_p_vel);
return sampleFromProMP(promp, curr_seg_dur, rng);
}
nlohmann::json to_stream() const {
vector<nlohmann::json> array_emission_params;
for(int i = 0; i < getNumberStates(); i++) {
const ProMP& promp = promps_.at(i).get_model();
nlohmann::json whole_thing;
nlohmann::json promp_params;
promp_params["mu_w"] = vec2json(promp.get_mu_w());
promp_params["Sigma_w"] = mat2json(promp.get_Sigma_w());
promp_params["Sigma_y"] = mat2json(promp.get_Sigma_y());
whole_thing["model"] = promp_params;
whole_thing["num_joints"] = getDimension();
// Note that the information about the basis functions is not
// serialized.
array_emission_params.push_back(whole_thing);
}
nlohmann::json ret = array_emission_params;
return ret;
}
void from_stream(const nlohmann::json& emission_params) {
// Note that the given parameters need to be consistent with some
// of the preexisting settings. Moreover, part of the structure of
// this emission process is not read from the input json.
// (e.g. the used basis functions).
assert(emission_params.size() == getNumberStates());
for(int i = 0; i < getNumberStates(); i++) {
const nlohmann::json& params = emission_params.at(i);
promps_.at(i).set_model(json2basic_promp(params.at("model")));
assert(params.at("num_joints") == getDimension());
}
resetMemCaches();
return;
}
// TODO: change the name of this method.
void set_Sigma_w_Prior(NormalInverseWishart prior) {
normal_inverse_prior_ = std::make_shared<NormalInverseWishart>(
std::move(prior));
int size_cov = promps_.at(0).get_model().get_Sigma_w().n_rows;
assert(size_cov == normal_inverse_prior_->getPhi().n_rows);
}
void setParamsForInitialization(double fraction) {
assert(fraction > 0 && fraction < 1.0);
init_fraction_ = fraction;
}
protected:
// Returns the marginal distribution of a particular state (ProMP) and
// duration. Keep in mind that the covariance matrix grows quadratically
// with respect to the duration. This could be cached for efficiency
// but is mostly intended for debugging.
random::NormalDist getNormalDistForMultipleTimeSteps(int state, int duration) {
int nrows = getDimension();
const FullProMP& promp = promps_.at(state);
const mat stacked_Phi = getPhiStacked(state, duration);
vec mean = stacked_Phi * promp.get_model().get_mu_w();
mat cov = stacked_Phi * promp.get_model().get_Sigma_w() *
stacked_Phi.t();
// Adding the noise variance.
mat noise_cov(size(cov), fill::zeros);
for(int i = 0; i < duration; i++)
noise_cov.submat(i * nrows, i * nrows, (i + 1) * nrows - 1,
(i + 1) * nrows - 1) = promp.get_model().get_Sigma_y();
cov = cov + noise_cov;
return random::NormalDist(mean, cov);
}
// Takes the covariance matrix for omega and returns it as if the
// joints were independent (blockdiag operator in Sebastian's paper).
mat getCovarianceIndependentJoints(const mat& cov) const {
mat ret(size(cov), fill::zeros);
assert(cov.n_rows == cov.n_cols);
int dim = cov.n_rows;
assert(dim % getDimension() == 0);
int blocklen = dim / getDimension();
for(int i = 0; i < dim; i++)
for(int j = 0; j < dim; j++)
if ((i/blocklen) == (j/blocklen))
ret(i, j) = cov(i, j);
mat extra_term = eye<mat>(size(ret)) * 1e-4;
return ret + extra_term;
}
mat getPhiStacked(int state, int duration) {
cube Phis = getPhiCube(state, duration);
mat PhiStacked(Phis.n_rows * Phis.n_slices, Phis.n_cols);
for(int d = 0; d < duration; d++)
PhiStacked.rows(d * Phis.n_rows, (d + 1) * Phis.n_rows - 1) =
Phis.slice(d);
return PhiStacked;
}
cube getPhiCube(int state, int duration) const {
pair<int, int> p = make_pair(state, duration);
if (cachePhis_.find(p) != cachePhis_.end())
return cachePhis_[p];
const FullProMP& promp = promps_.at(state);
// The samples are assumed to be equally spaced.
vec sample_locations = getSampleLocations(duration);
mat tmp = promp.get_phi_t(0);
int ncols = tmp.n_cols;
int nrows = tmp.n_rows;
cube stacked_Phi(nrows, ncols, duration, fill::zeros);
for(int i = 0; i < duration; i++)
stacked_Phi.slice(i) = promp.get_phi_t(sample_locations(i));
cachePhis_[p] = stacked_Phi;
return stacked_Phi;
}
// Returns the least squares solution to the problem:
// y(t) = Phi(t) * w for a bunch of i.i.d. y's. Note that omega is
// not assumed to be a random variable.
vec least_squares_omega(int state,
const field<mat>& segment) const {
int nobs = segment.n_elem;
const cube& Phis = getPhiCube(state, nobs);
mat A(size(Phis.slice(0).t() * Phis.slice(0)),
fill::zeros);
vec b(A.n_rows, fill::zeros);
for(int t = 0; t < nobs; t++) {
const mat& Phi = Phis.slice(t);
A = A + Phi.t() * Phi;
b = b + Phi.t() * segment(t);
}
// Solving A * w = b
vec lsq_omega = solve(A, b);
return lsq_omega;
}
// Compute the variance of an isotropic Gaussian noise model
// given omega.
double var_isotropic_gaussian_given_omega(int state, vec w,
const field<mat>& segment) const {
int nobs = segment.n_elem;
const cube& Phis = getPhiCube(state, nobs);
double var = 0;
for(int t = 0; t < nobs; t++) {
const mat& Phi = Phis.slice(t);
vec diff = segment(t) - Phi * w;
var += dot(diff, diff);
}
return var / (nobs * segment(0).n_rows);
}
vector<FullProMP> promps_;
std::shared_ptr<NormalInverseWishart> normal_inverse_prior_;
double epsilon_ = 1e-15;
bool diagonal_sigma_y_;
// Delta for emissions which are not dependent on the total
// duration.
double sample_locations_delta_ = -1;
// Fraction of the total least squares omega estimates that will be
// used for initialization.
double init_fraction_ = 0.1;
// Members for caching.
mutable map<pair<int, int>, cube> cachePhis_;
mutable map<pair<int, int>, field<mat>> cacheInvS_;
mutable map<pair<int, int>, field<mat>> cacheK_;
mutable map<pair<int, int>, mat> cachePosteriorSigma_;
};
// This version of the ProMP is specifically designed for HMMs where a
// single observation is a time series itself
class ProMPsEmissionHMM : public ProMPsEmission {
public:
ProMPsEmissionHMM(vector<FullProMP> promps) :
ProMPsEmission(promps) {}
ProMPsEmission* clone() const {
return new ProMPsEmission(*this);
}
double loglikelihood(int state, const field<mat>& obs) const {
// Making sure that the duration is one.
assert(obs.n_elem == 1);
auto& sequence = obs(0);
const FullProMP& promp = promps_.at(state);
// The samples are assumed to be equally spaced.
vec sample_locations = getSampleLocations(sequence.n_cols);
vec mu(promp.get_model().get_mu_w());
mat Sigma(promp.get_model().get_Sigma_w());
mat Sigma_y(promp.get_model().get_Sigma_y());
double ret = 0;
for(int i = 0; i < sequence.n_cols; i++) {
mat Phi = promp.get_phi_t(sample_locations(i));
mat S = Phi * Sigma * Phi.t() + Sigma_y;
// Required for the marginal likelihood p(y_t | y_{1:t-1}).
random::NormalDist dist = random::NormalDist(Phi * mu, S);
ret = ret + log_normal_density(dist, sequence.col(i));
// Using the kalman updating step to compute this efficiently.
mat K = Sigma * Phi.t() * inv(S);
mu = mu + K * (sequence.col(i) - Phi * mu);
Sigma = Sigma - K * S * K.t();
}
return ret;
}
void reestimate(int min_duration,
const arma::field<arma::cube>& meta,
const arma::field<arma::field<arma::mat>>& mobs) {
int nseq = mobs.n_elem;
for(int i = 0; i < getNumberStates(); i++) {
ProMP promp = promps_.at(i).get_model();
const mat inv_Sigma_w = inv_sympd(promp.get_Sigma_w());
const mat inv_Sigma_y = inv_sympd(promp.get_Sigma_y());
const vec mu_w = promp.get_mu_w();
vector<double> mult_c;
vector<double> denominator_Sigma_y;
for(int s = 0; s < nseq; s++) {
const cube& eta = meta(s);
int nobs = mobs(s).n_elem;
int ndurations = eta.n_cols;
assert(ndurations == 1 && min_duration == 1);
for(int t = 0; t < nobs; t++) {
mult_c.push_back(eta(i, 0, t));
int current_duration = mobs(s)(t).n_cols;
denominator_Sigma_y.push_back(eta(i, 0, t) +
log(current_duration));
}
}
// Computing the multiplicative constants for mu_w and
// Sigma_w.
vec mult_c_normalized(mult_c);
mult_c_normalized -= logsumexp(mult_c_normalized);
mult_c_normalized = exp(mult_c_normalized);
// Computing the multiplicative constants for Sigma_y since
// they have a different denominator.
vec mult_c_Sigma_y_normalized(mult_c);
vec den_Sigma_y(denominator_Sigma_y);
mult_c_Sigma_y_normalized -= logsumexp(den_Sigma_y);
mult_c_Sigma_y_normalized = exp(mult_c_Sigma_y_normalized);
mat new_Sigma_y(size(promp.get_Sigma_y()), fill::zeros);
// EM for ProMPs.
vec weighted_sum_post_mean(size(mu_w), fill::zeros);
mat weighted_sum_post_cov(size(inv_Sigma_w), fill::zeros);
mat weighted_sum_post_mean_mean_T(size(inv_Sigma_w),
fill::zeros);
int idx_mult_c = 0;
for(int s = 0; s < nseq; s++) {
auto& obs = mobs(s);
int nobs = obs.n_elem;
int ndurations = meta(s).n_cols;
for(int t = 0; t < nobs; t++) {
// Length of the current observation
const int current_duration = obs(t).n_cols;
const cube& Phis = getPhiCube(i, current_duration);
// E step for the emission hidden variables (Ws).
// Computing the posterior of W given Y and Theta.
// Computing the posterior covariance of the hidden
// variable w for this segment.
mat posterior_cov(size(inv_Sigma_w), fill::zeros);
for(int step = 0; step < current_duration; step++) {
posterior_cov += Phis.slice(step).t() *
inv_Sigma_y * Phis.slice(step);
}
posterior_cov = (posterior_cov+posterior_cov.t())/2.0;
posterior_cov = posterior_cov + inv_Sigma_w;
posterior_cov = (posterior_cov+posterior_cov.t())/2.0;
posterior_cov = inv_sympd(posterior_cov);
posterior_cov = (posterior_cov+posterior_cov.t())/2.0;
// Computing the posterior mean of the hidden
// variable w for this segment.
vec posterior_mean(size(mu_w), fill::zeros);
for(int step = 0; step < current_duration; step++) {
const vec& ob = obs(t).col(step);
posterior_mean += Phis.slice(step).t() *
inv_Sigma_y * ob;
}
posterior_mean = inv_Sigma_w * mu_w + posterior_mean;
posterior_mean = posterior_cov * posterior_mean;
// Getting the multiplicative constants.
double mult_constant = mult_c_normalized(idx_mult_c);
double mult_constant_Sigma_y =
mult_c_Sigma_y_normalized(idx_mult_c);
idx_mult_c++;
// Statistics required for updating mu_w & Sigma_w.
weighted_sum_post_mean += mult_constant *
posterior_mean;
weighted_sum_post_cov += mult_constant *
posterior_cov;
weighted_sum_post_mean_mean_T += mult_constant *
posterior_mean * posterior_mean.t();
// Computing the new output noise covariance: Sigma_y.
mat Sigma_y_term(size(new_Sigma_y), fill::zeros);
for(int step = 0; step < current_duration; step++) {
const mat& phi = Phis.slice(step);
const vec& diff_y = obs(t).col(step) -
phi * posterior_mean;
Sigma_y_term += diff_y * diff_y.t() +
phi * posterior_cov * phi.t();
}
new_Sigma_y += mult_constant_Sigma_y * Sigma_y_term;
}
}
// Expected number of segments generated by the i-th state.
double mle_den = exp(logsumexp(mult_c));
// M step for the emission variables.
vec new_mu_w_MLE(weighted_sum_post_mean);
mat new_Sigma_w_MLE = weighted_sum_post_cov +
weighted_sum_post_mean_mean_T - new_mu_w_MLE *
new_mu_w_MLE.t();
// If there is a prior then we do MAP instead.
mat new_Sigma_w;
mat new_mu_w;
if (normal_inverse_prior_) {
double v_0 = normal_inverse_prior_->getDof();
double D = mu_w.n_rows;
mat S_0 = normal_inverse_prior_->getPhi();
new_Sigma_w = (S_0 + mle_den * new_Sigma_w_MLE) /
(v_0 + mle_den + D + 2);
double k_0 = normal_inverse_prior_->getLambda();
vec m_0 = normal_inverse_prior_->getMu0();
new_mu_w = (k_0 * m_0 + mle_den * new_mu_w_MLE) /
(mle_den + k_0);
}
else {
new_Sigma_w = new_Sigma_w_MLE;
new_mu_w = new_mu_w_MLE;
}
cout << "State " << i << " MLE Den: " << mle_den << " ";
if (mle_den > epsilon_) {
// Making sure the noise covariance is diagonal.
if (diagonal_sigma_y_)
new_Sigma_y = diagmat(new_Sigma_y.diag());
// Checking that the new Sigma_w is a covariance matrix.
vec eigenvalues_map = eig_sym(new_Sigma_w);
assert(eigenvalues_map(0) > 0);
// Setting the new parameters.
promp.set_mu_w(new_mu_w);
promp.set_Sigma_w(new_Sigma_w);
promp.set_Sigma_y(new_Sigma_y);
promps_.at(i).set_model(promp);
cout << ". Updated." << endl;
}
else
cout << ". Not updated." << endl;
}
}
field<mat> sampleFromState(int state, int size,
mt19937 &rand_generator) const {
// Since the segments are modeled as single observations.
assert(size == 1);
const ProMP& model = promps_.at(state).get_model();
vector<vec> w_samples = random::sample_multivariate_normal(
rand_generator, {model.get_mu_w(), model.get_Sigma_w()}, 1);
vec w = w_samples.back();
// Getting the actual size of the segment.
size = getDurationForEachSegment(rand_generator);
vec noise_mean = zeros<vec>(getDimension());
vector<vec> output_noise = random::sample_multivariate_normal(
rand_generator, {noise_mean, model.get_Sigma_y()}, size);
mat joint_sample(getDimension(), size);
// The samples are assumed to be equally spaced.
vec sample_locations = getSampleLocations(size);
for(int i = 0; i < size; i++) {
double z = sample_locations(i);
mat phi_z = promps_.at(state).get_phi_t(z);
joint_sample.col(i) = phi_z * w + output_noise.at(i);
}
field<mat> ret = {joint_sample};
return ret;
}
private:
int getDurationForEachSegment(mt19937 &rand_generator) const {
return 20;
}
};
};
#endif
| 47.03612 | 91 | 0.470512 | [
"vector",
"model"
] |
7556dabed8e98e76328ea8bf9d0f3bf2179ef28d | 59,441 | cpp | C++ | src/PlaneSlam.cpp | richard5635/PlaneLoc | aab6637124b1b99ad726a94e9f6762dddf3716b5 | [
"MIT"
] | null | null | null | src/PlaneSlam.cpp | richard5635/PlaneLoc | aab6637124b1b99ad726a94e9f6762dddf3716b5 | [
"MIT"
] | null | null | null | src/PlaneSlam.cpp | richard5635/PlaneLoc | aab6637124b1b99ad726a94e9f6762dddf3716b5 | [
"MIT"
] | null | null | null | /*
Copyright (c) 2017 Mobile Robots Laboratory at Poznan University of Technology:
-Jan Wietrzykowski name.surname [at] put.poznan.pl
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <iostream>
#include <memory>
#include <chrono>
#include <thread>
#include <map>
#include <boost/filesystem.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <opencv2/opencv.hpp>
#include <pcl/common/common_headers.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/impl/point_types.hpp>
#include <pcl/features/normal_3d.h>
#include <pcl/features/integral_image_normal.h>
#include <pcl/visualization/point_cloud_color_handlers.h>
#include <g2o/types/slam3d/se3quat.h>
#include <LineSeg.hpp>
#include <LineDet.hpp>
#include <pcl/common/transforms.h>
#include "PlaneSlam.hpp"
#include "Misc.hpp"
#include "Matching.hpp"
#include "PlaneSegmentation.hpp"
#include "Serialization.hpp"
#include "ConcaveHull.hpp"
using namespace std;
using namespace cv;
PlaneSlam::PlaneSlam(const cv::FileStorage& isettings) :
settings(isettings),
fileGrabber(isettings["fileGrabber"]),
map(isettings)
// viewer("3D Viewer")
{
}
void PlaneSlam::run(){
Mat cameraParams;
settings["planeSlam"]["cameraMatrix"] >> cameraParams;
cout << "cameraParams = " << cameraParams << endl;
vector<double> gtOffsetVals;
settings["planeSlam"]["gtOffset"] >> gtOffsetVals;
Vector7d gtOffset;
for(int v = 0; v < gtOffsetVals.size(); ++v){
gtOffset(v) = gtOffsetVals[v];
}
g2o::SE3Quat gtOffsetSE3Quat(gtOffset);
cout << "gtOffsetSE3Quat = " << gtOffsetSE3Quat.toVector().transpose() << endl;
int frameCnt = 0;
pcl::visualization::PCLVisualizer::Ptr viewer(new pcl::visualization::PCLVisualizer("3D Viewer"));
int v1 = 0;
int v2 = 0;
viewer->createViewPort(0.0, 0.0, 1.0, 1.0, v1);
// viewer->createViewPort(0.0, 0.0, 0.5, 1.0, v1);
// viewer->createViewPort(0.5, 0.0, 1.0, 1.0, v2);
// viewer->addCoordinateSystem();
// Map
cout << "Getting object instances from map" << endl;
vectorObjInstance mapObjInstances;
for(auto it = map.begin(); it != map.end(); ++it){
mapObjInstances.push_back(*it);
}
vectorObjInstance prevObjInstances;
Vector7d prevPose;
Mat rgb, depth;
std::vector<FileGrabber::FrameObjInstance> objInstances;
std::vector<double> accelData;
Vector7d pose;
Vector7d voPose;
bool voCorr = false;
pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr pointCloudRead(new pcl::PointCloud<pcl::PointXYZRGBNormal>());
int framesToSkip = (int)settings["planeSlam"]["framesToSkip"];
cout << "skipping " << framesToSkip << " frames" << endl;
static constexpr int frameRate = 30;
int framesSkipped = 0;
int curFrameIdx = -1;
while((framesSkipped < framesToSkip) && ((curFrameIdx = fileGrabber.getFrame(rgb, depth, objInstances, accelData, pose, voPose, voCorr)) >= 0))
{
++framesSkipped;
}
cout << "reading global settings" << endl;
bool drawVis = bool((int)settings["planeSlam"]["drawVis"]);
bool visualizeSegmentation = bool((int)settings["planeSlam"]["visualizeSegmentation"]);
bool visualizeMatching = bool((int)settings["planeSlam"]["visualizeMatching"]);
bool stopEveryFrame = bool((int)settings["planeSlam"]["stopEveryFrame"]);
bool stopWrongFrame = bool((int)settings["planeSlam"]["stopWrongFrame"]);
bool saveRes = bool((int)settings["planeSlam"]["saveRes"]);
bool loadRes = bool((int)settings["planeSlam"]["loadRes"]);
bool saveVis = bool((int)settings["planeSlam"]["saveVis"]);
bool framesFromPly = bool((int)settings["planeSlam"]["framesFromPly"]);
bool incrementalMatching = bool((int)settings["planeSlam"]["incrementalMatching"]);
bool globalMatching = bool((int)settings["planeSlam"]["globalMatching"]);
bool useLines = bool((int)settings["planeSlam"]["useLines"]);
bool processFrames = bool((int)settings["planeSlam"]["processFrames"]);
// bool localize = bool((int)settings["planeSlam"]["localize"]);
bool compRes = true;
double poseDiffThresh = (double)settings["planeSlam"]["poseDiffThresh"];
double scoreThresh = (double)settings["planeSlam"]["scoreThresh"];
double scoreDiffThresh = (double)settings["planeSlam"]["scoreDiffThresh"];
double fitThresh = (double)settings["planeSlam"]["fitThresh"];
double distinctThresh = (double)settings["planeSlam"]["distinctThresh"];
vectorVector7d visGtPoses;
vectorVector7d visRecPoses;
vector<RecCode> visRecCodes;
vector<int> visRecFrameIdxs;
vectorVector7d visGtCompPoses;
vectorVector7d visRecCompPoses;
vector<RecCode> visRecCompCodes;
ofstream outputResGlobFile;
ofstream outputResIncrFile;
if(saveRes){
if(globalMatching) {
outputResGlobFile.open("../output/res_glob.out");
}
if(incrementalMatching){
outputResIncrFile.open("../output/res_incr.out");
}
}
// ofstream visFile;
// if(saveVis){
// visFile.open("../output/vis");
// }
cv::VideoWriter visVideo;
if(saveVis){
visVideo.open("../output/rec/vis.avi", VideoWriter::fourcc('X','2','6','4'), 2, Size(1280, 720));
}
ifstream inputResGlobFile;
ifstream inputResIncrFile;
if(loadRes){
if(globalMatching) {
inputResGlobFile.open("../output/res_glob.in");
}
if(incrementalMatching){
inputResIncrFile.open("../output/res_incr.in");
}
}
ifstream inputResGlobCompFile;
if(compRes){
inputResGlobCompFile.open("../output/res_comp.in");
}
// variables used for accumulation
// vector<ObjInstance> accObjInstances;
Map accMap;
Vector7d accStartFramePose;
int accFrames = 50;
int processNewFrameSkip = 1;
int corrCnt = 0;
int incorrCnt = 0;
int unkCnt = 0;
double meanDist = 0.0;
double meanAngDist = 0.0;
int meanCnt = 0;
int prevCorrFrameIdx = curFrameIdx;
int longestUnk = 0;
int corrCntComp = 0;
int incorrCntComp = 0;
int unkCntComp = 0;
int meanCntComp = 0;
double meanDistComp = 0;
double meanAngDistComp = 0;
int prevCorrFrameIdxComp = curFrameIdx;
int longestUnkComp = 0;
// ofstream logFile("../output/log.out");
cout << "Starting the loop" << endl;
while((curFrameIdx = fileGrabber.getFrame(rgb, depth, objInstances, accelData, pose, voPose, voCorr, accMap)) >= 0) {
cout << "curFrameIdx = " << curFrameIdx << endl;
int64_t timestamp = (int64_t) curFrameIdx * 1e6 / frameRate;
cout << "timestamp = " << timestamp << endl;
bool stopFlag = stopEveryFrame;
vectorObjInstance curObjInstances;
std::map<int, int> idToCnt;
bool localize = true;
if(inputResGlobCompFile.is_open()){
int codeVal;
inputResGlobCompFile >> codeVal;
// cout << "code = " << code << endl;
// visGtCompPoses.push_back(pose);
RecCode code = RecCode::Unk;
Vector7d compTrans = Vector7d::Zero();
if(codeVal != -1) {
// Vector7d compTrans;
for (int i = 0; i < 7; ++i) {
inputResGlobCompFile >> compTrans(i);
}
}
if(curFrameIdx % 10 == 0) {
visGtCompPoses.push_back(pose);
if(codeVal == -1) {
visRecCompCodes.push_back(RecCode::Unk);
visRecCompPoses.push_back(Vector7d::Zero());
++unkCntComp;
}
else {
g2o::SE3Quat compTransSE3Quat(compTrans);
g2o::SE3Quat gtTransformSE3Quat(pose);
// cout << "compTrans = " << compTrans.transpose() << endl;
// cout << "pose = " << pose.transpose() << endl;
g2o::SE3Quat diffSE3Quat = compTransSE3Quat.inverse() * gtTransformSE3Quat;
// g2o::SE3Quat diffInvSE3Quat = poseSE3Quat * planesTransSE3Quat.inverse();
Vector6d diffLog = diffSE3Quat.log();
// cout << "diffLog = " << diffSE3Quat.log().transpose() << endl;
// cout << "diffInvLog = " << diffInvSE3Quat.log().transpose() << endl;
double diff = diffLog.transpose() * diffLog;
double diffEucl = diffSE3Quat.toVector().head<3>().norm();
Eigen::Vector3d diffLogAng = Misc::logMap(diffSE3Quat.rotation());
double diffAng = diffLogAng.norm();
meanDistComp += diffEucl;
meanAngDistComp += diffAng;
++meanCntComp;
if (diff > poseDiffThresh) {
code = RecCode::Incorr;
++incorrCntComp;
} else {
code = RecCode::Corr;
int unkLenComp = curFrameIdx - prevCorrFrameIdxComp;
if(unkLenComp > longestUnkComp){
longestUnkComp = unkLenComp;
}
prevCorrFrameIdxComp = curFrameIdx;
++corrCntComp;
}
visRecCompCodes.push_back(code);
visRecCompPoses.push_back(compTrans);
}
}
}
if (processFrames) {
if ((curFrameIdx - framesSkipped) % processNewFrameSkip == 0) {
g2o::SE3Quat poseSE3Quat(pose);
poseSE3Quat = gtOffsetSE3Quat.inverse() * poseSE3Quat;
pose = poseSE3Quat.toVector();
viewer->removeAllPointClouds();
viewer->removeAllShapes();
pcl::PointCloud<pcl::PointXYZRGB>::Ptr pointCloud;
pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr pointCloudNormals;
if (framesFromPly) {
pointCloudNormals.reset(new pcl::PointCloud<pcl::PointXYZRGBNormal>(*pointCloudRead));
pointCloud.reset(new pcl::PointCloud<pcl::PointXYZRGB>());
for (int p = 0; p < pointCloudNormals->size(); ++p) {
pcl::PointXYZRGB pt;
pt.x = pointCloudNormals->at(p).x;
pt.y = pointCloudNormals->at(p).y;
pt.z = pointCloudNormals->at(p).z;
pt.r = pointCloudNormals->at(p).r;
pt.g = pointCloudNormals->at(p).g;
pt.b = pointCloudNormals->at(p).b;
pointCloud->push_back(pt);
}
} else {
pointCloudNormals.reset(new pcl::PointCloud<pcl::PointXYZRGBNormal>(rgb.cols,
rgb.rows));
pointCloud.reset(new pcl::PointCloud<pcl::PointXYZRGB>(rgb.cols, rgb.rows));
Mat xyz = Misc::projectTo3D(depth, cameraParams);
for (int row = 0; row < rgb.rows; ++row) {
for (int col = 0; col < rgb.cols; ++col) {
pcl::PointXYZRGB p;
// ((uint8_t)rgb.at<Vec3b>(row, col)[0],
// (uint8_t)rgb.at<Vec3b>(row, col)[1],
// (uint8_t)rgb.at<Vec3b>(row, col)[2]);
p.x = xyz.at<Vec3f>(row, col)[0];
p.y = xyz.at<Vec3f>(row, col)[1];
p.z = xyz.at<Vec3f>(row, col)[2];
p.r = (uint8_t) rgb.at<Vec3b>(row, col)[0];
p.g = (uint8_t) rgb.at<Vec3b>(row, col)[1];
p.b = (uint8_t) rgb.at<Vec3b>(row, col)[2];
// cout << "Point at (" << xyz.at<Vec3f>(row, col)[0] << ", " <<
// xyz.at<Vec3f>(row, col)[1] << ", " <<
// xyz.at<Vec3f>(row, col)[2] << "), rgb = (" <<
// (int)rgb.at<Vec3b>(row, col)[0] << ", " <<
// (int)rgb.at<Vec3b>(row, col)[1] << ", " <<
// (int)rgb.at<Vec3b>(row, col)[2] << ") " << endl;
pointCloud->at(col, row) = p;
pointCloudNormals->at(col, row).x = p.x;
pointCloudNormals->at(col, row).y = p.y;
pointCloudNormals->at(col, row).z = p.z;
pointCloudNormals->at(col, row).r = p.r;
pointCloudNormals->at(col, row).g = p.g;
pointCloudNormals->at(col, row).b = p.b;
}
}
// Create the normal estimation class, and pass the input dataset to it
pcl::IntegralImageNormalEstimation<pcl::PointXYZRGB, pcl::PointXYZRGBNormal> ne;
ne.setNormalEstimationMethod(ne.COVARIANCE_MATRIX);
ne.setMaxDepthChangeFactor(0.02f);
ne.setNormalSmoothingSize(20.0f);
ne.setInputCloud(pointCloud);
ne.setViewPoint(0.0, 0.0, 0.0);
ne.compute(*pointCloudNormals);
cout << "pointCloudNormals->size() = " << pointCloudNormals->size() << endl;
}
if (drawVis) {
// viewer->addPointCloud(pointCloud, "cloud", v1);
// cout << endl << "whole cloud" << endl << endl;
// viewer->resetStoppedFlag();
// viewer->initCameraParameters();
// viewer->setCameraPosition(0.0, 0.0, -6.0, 0.0, -1.0, 0.0);
// viewer->spinOnce(100);
// while (!viewer->wasStopped()) {
// viewer->spinOnce(100);
// std::this_thread::sleep_for(std::chrono::milliseconds(50));
// }
// viewer->close();
}
if (!pointCloud->empty()) {
pcl::PointCloud<pcl::PointXYZRGBL>::Ptr pointCloudLab(new pcl::PointCloud<pcl::PointXYZRGBL>());
if (!visualizeSegmentation) {
// PlaneSegmentation::segment(settings,
// pointCloudNormals,
// pointCloudLab,
// curObjInstances,
// false);
PlaneSegmentation::segment(settings,
rgb,
depth,
pointCloudLab,
curObjInstances);
}
else {
// PlaneSegmentation::segment(settings,
// pointCloudNormals,
// pointCloudLab,
// curObjInstances,
// false,
// viewer,
// v1,
// v2);
PlaneSegmentation::segment(settings,
rgb,
depth,
pointCloudLab,
curObjInstances,
viewer,
v1,
v2);
}
vectorLineSeg lineSegs;
if (useLines) {
viewer->addPointCloud(pointCloud, "cloud_raw", v2);
LineDet::detectLineSegments(settings,
rgb,
depth,
curObjInstances,
cameraParams,
lineSegs,
viewer,
v1,
v2);
}
// if not the last frame for accumulation
if ((curFrameIdx - framesSkipped) % accFrames != accFrames - 1) {
localize = false;
}
// if (curFrameIdx % accFrames == accFrames - 1) {
// stopFlag = true;
// }
// if current frame starts accumulation
if (((curFrameIdx - framesSkipped)/processNewFrameSkip) % accFrames == 0) {
cout << endl << "starting new accumulation" << endl << endl;
accMap = Map();
accStartFramePose = voPose;
// accStartFramePose = pose;
}
if (voCorr) {
cout << endl << "merging curObjInstances" << endl << endl;
// g2o::SE3Quat accPoseIncrSE3Quat = g2o::SE3Quat(accStartFramePose).inverse() * g2o::SE3Quat(pose);
g2o::SE3Quat accPoseIncrSE3Quat =
g2o::SE3Quat(accStartFramePose).inverse() * g2o::SE3Quat(voPose);
// g2o::SE3Quat accPoseIncrSE3Quat = g2o::SE3Quat(pose);
Vector7d accPoseIncr = accPoseIncrSE3Quat.toVector();
cout << "accPoseIncr = " << accPoseIncr.transpose() << endl;
vectorObjInstance curObjInstancesTrans = curObjInstances;
for (ObjInstance &curObj : curObjInstancesTrans) {
curObj.transform(accPoseIncr);
}
cout << "Getting visible" << endl;
idToCnt = accMap.getVisibleObjs(accPoseIncr,
cameraParams,
rgb.rows,
rgb.cols/*,
viewer,
v1,
v2*/);
cout << "Merging new" << endl;
if (curFrameIdx >= 2500) {
accMap.mergeNewObjInstances(curObjInstancesTrans,
idToCnt,
viewer,
v1,
v2);
} else {
accMap.mergeNewObjInstances(curObjInstancesTrans,
idToCnt);
}
// every 50th frame
int mergeMapFrameSkip = 50;
if (((curFrameIdx - framesSkipped)/processNewFrameSkip)
% mergeMapFrameSkip == mergeMapFrameSkip - 1)
{
cout << "Merging map" << endl;
accMap.mergeMapObjInstances(/*viewer,
v1,
v2*/);
}
}
// if last frame in accumulation
if (((curFrameIdx - framesSkipped)/processNewFrameSkip)
% accFrames == accFrames - 1)
{
accMap.removeObjsEolThresh(6);
// saving
{
cout << "saving map to file" << endl;
char buf[100];
sprintf(buf,
"../output/acc/acc%05d",
curFrameIdx - accFrames*processNewFrameSkip + 1);
std::ofstream ofs(buf);
boost::archive::text_oarchive oa(ofs);
oa << accMap;
}
}
prevObjInstances.swap(curObjInstances);
}
}
}
if(accMap.size() == 0){
localize = false;
}
if (globalMatching && localize) {
cout << "global matching" << endl;
RecCode curRecCode;
// g2o::SE3Quat gtTransSE3Quat =
// g2o::SE3Quat(prevPose).inverse() * g2o::SE3Quat(pose);
Vector7d predTrans;
double linDist, angDist;
pcl::visualization::PCLVisualizer::Ptr curViewer = nullptr;
int curViewPort1 = -1;
int curViewPort2 = -1;
if (visualizeMatching) {
curViewer = viewer;
curViewPort1 = v1;
curViewPort2 = v2;
}
vectorObjInstance accObjInstances;
for(const ObjInstance &curObj : accMap){
accObjInstances.push_back(curObj);
}
evaluateMatching(settings,
accObjInstances,
mapObjInstances,
inputResGlobFile,
outputResGlobFile,
pose,
scoreThresh,
scoreDiffThresh,
fitThresh,
distinctThresh,
poseDiffThresh,
predTrans,
curRecCode,
linDist,
angDist,
curViewer,
curViewPort1,
curViewPort2);
visRecCodes.push_back(curRecCode);
visGtPoses.push_back(pose);
visRecPoses.push_back(predTrans);
visRecFrameIdxs.push_back(curFrameIdx);
// cout << "pose = " << pose.transpose() << endl;
// cout << "predTrans = " << predTrans.transpose() << endl;
if (curRecCode == RecCode::Corr) {
++corrCnt;
int unkLen = curFrameIdx - prevCorrFrameIdx;
if(unkLen > longestUnk){
longestUnk = unkLen;
}
prevCorrFrameIdx = curFrameIdx;
} else if (curRecCode == RecCode::Incorr) {
++incorrCnt;
stopFlag |= stopWrongFrame;
} else {
++unkCnt;
}
if (curRecCode != RecCode::Unk) {
meanDist += linDist;
meanAngDist += angDist;
++meanCnt;
}
if(visRecCodes.back() == RecCode::Corr && visRecCompCodes.back() == RecCode::Unk){
cout << "Recognized where ORB-SLAM2 not recognized" << endl;
g2o::SE3Quat planesTransSE3Quat;
planesTransSE3Quat.fromVector(predTrans);
g2o::SE3Quat gtTransformSE3Quat;
gtTransformSE3Quat.fromVector(pose);
g2o::SE3Quat diffSE3Quat = planesTransSE3Quat.inverse() * gtTransformSE3Quat;
// g2o::SE3Quat diffInvSE3Quat = poseSE3Quat * planesTransSE3Quat.inverse();
Vector6d diffLog = diffSE3Quat.log();
// cout << "diffLog = " << diffSE3Quat.log().transpose() << endl;
// cout << "diffInvLog = " << diffInvSE3Quat.log().transpose() << endl;
double diff = diffLog.transpose() * diffLog;
// double diffEucl = diffSE3Quat.toVector().head<3>().norm();
// Eigen::Vector3d diffLogAng = Misc::logMap(diffSE3Quat.rotation());
// double diffAng = diffLogAng.norm();
cout << "diff = " << diff << endl;
}
}
if (incrementalMatching && !prevObjInstances.empty() && localize) {
RecCode curRecCode;
g2o::SE3Quat gtTransSE3Quat =
g2o::SE3Quat(prevPose).inverse() * g2o::SE3Quat(pose);
Vector7d predTrans;
double linDist, angDist;
pcl::visualization::PCLVisualizer::Ptr curViewer = nullptr;
int curViewPort1 = -1;
int curViewPort2 = -1;
if (visualizeMatching) {
curViewer = viewer;
curViewPort1 = v1;
curViewPort2 = v2;
}
evaluateMatching(settings,
curObjInstances,
prevObjInstances,
inputResIncrFile,
outputResIncrFile,
gtTransSE3Quat.toVector(),
scoreThresh,
scoreDiffThresh,
fitThresh,
distinctThresh,
poseDiffThresh,
predTrans,
curRecCode,
linDist,
angDist,
curViewer,
curViewPort1,
curViewPort2);
visRecCodes.push_back(curRecCode);
visGtPoses.push_back(pose);
visRecPoses.push_back(predTrans);
if (curRecCode == RecCode::Corr) {
++corrCnt;
} else if (curRecCode == RecCode::Incorr) {
++incorrCnt;
stopFlag |= stopWrongFrame;
} else {
++unkCnt;
}
if (curRecCode != RecCode::Unk) {
meanDist += linDist;
meanAngDist += angDist;
++meanCnt;
}
}
// if(curFrameIdx == 850 || curFrameIdx == 890){
// stopFlag = true;
// }
if (drawVis && accMap.size() > 0) {
cout << "visualization" << endl;
// // saving
// {
// cout << "saving map to file" << endl;
// std::ofstream ofs("filename");
// boost::archive::text_oarchive oa(ofs);
// oa << accMap;
// }
// // loading
// {
// accMap = Map();
//
// cout << "loading map from file" << endl;
// std::ifstream ifs("filename");
// boost::archive::text_iarchive ia(ifs);
// ia >> accMap;
// }
viewer->removeAllPointClouds();
viewer->removeAllShapes();
viewer->removeAllCoordinateSystems();
// viewer->addCoordinateSystem();
pcl::PointCloud<pcl::PointXYZRGB>::Ptr mapPc(new pcl::PointCloud<pcl::PointXYZRGB>());
for(const ObjInstance &mObj : map){
mapPc->insert(mapPc->end(), mObj.getPoints()->begin(), mObj.getPoints()->end());
}
pcl::PointCloud<pcl::PointXYZRGB>::Ptr mapPcGray(new pcl::PointCloud<pcl::PointXYZRGB>());
pcl::copyPointCloud(*mapPc, *mapPcGray);
for(int p = 0; p < mapPcGray->size(); ++p){
int gray = mapPcGray->at(p).r * 0.21 +
mapPcGray->at(p).g * 0.72 +
mapPcGray->at(p).b * 0.07;
gray = min(gray, 255);
mapPcGray->at(p).r = gray;
mapPcGray->at(p).g = gray;
mapPcGray->at(p).b = gray;
}
viewer->addPointCloud(mapPcGray, "map_cloud", v1);
viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_OPACITY,
0.5,
"map_cloud",
v1);
pcl::PointCloud<pcl::PointXYZ>::Ptr trajLine(new pcl::PointCloud<pcl::PointXYZ>());
for(int f = 1; f < visGtPoses.size(); ++f){
pcl::PointXYZ prevPose(visGtPoses[f-1][0],
visGtPoses[f-1][1],
visGtPoses[f-1][2]);
pcl::PointXYZ curPose(visGtPoses[f][0],
visGtPoses[f][1],
visGtPoses[f][2]);
// trajLine->push_back(curPose);
viewer->addLine(prevPose, curPose, 1.0, 0.0, 0.0, string("line_traj_") + to_string(f), v1);
viewer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_LINE_WIDTH,
4,
string("line_traj_") + to_string(f),
v1);
viewer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_SHADING,
pcl::visualization::PCL_VISUALIZER_SHADING_FLAT,
string("line_traj_") + to_string(f),
v1);
}
viewer->addPolygon<pcl::PointXYZ>(trajLine, 0.0, 1.0, 0.0, "traj_poly", v1);
pcl::PointCloud<pcl::PointXYZ>::Ptr corrPoses(new pcl::PointCloud<pcl::PointXYZ>());
pcl::PointCloud<pcl::PointXYZ>::Ptr incorrPoses(new pcl::PointCloud<pcl::PointXYZ>());
for(int f = 0; f < visRecCodes.size(); ++f){
if(visRecCodes[f] == RecCode::Corr || visRecCodes[f] == RecCode::Incorr){
pcl::PointXYZ curPose(visGtPoses[f][0],
visGtPoses[f][1],
visGtPoses[f][2]);
pcl::PointXYZ curRecPose(visRecPoses[f][0],
visRecPoses[f][1],
visRecPoses[f][2]);
if(visRecCodes[f] == RecCode::Corr) {
corrPoses->push_back(curRecPose);
// cout << "correct for " << visRecFrameIdxs[f] << endl;
}
else/* if(visRecCodes[f] == RecCode::Incorr) */ {
incorrPoses->push_back(curRecPose);
// cout << "incorrect for " << visRecFrameIdxs[f] << endl;
}
viewer->addLine(curPose, curRecPose, 0.0, 1.0, 0.0, string("line_pose_") + to_string(f), v1);
viewer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_LINE_WIDTH,
4,
string("line_pose_") + to_string(f),
v1);
viewer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_SHADING,
pcl::visualization::PCL_VISUALIZER_SHADING_FLAT,
string("line_pose_") + to_string(f),
v1);
}
}
viewer->addPointCloud(corrPoses, "corr_poses_cloud", v1);
viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE,
5,
"corr_poses_cloud",
v1);
viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR,
0.0, 0.0, 1.0,
"corr_poses_cloud",
v1);
viewer->addPointCloud(incorrPoses, "incorr_poses_cloud", v1);
viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE,
5,
"incorr_poses_cloud",
v1);
viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR,
1.0, 0.0, 1.0,
"incorr_poses_cloud",
v1);
{
g2o::SE3Quat accPoseIncrSE3Quat =
g2o::SE3Quat(accStartFramePose).inverse() *
g2o::SE3Quat(voPose);
Eigen::Affine3f trans = Eigen::Affine3f::Identity();
// trans.matrix() = poseSE3Quat.to_homogeneous_matrix().cast<float>();
trans.matrix() = accPoseIncrSE3Quat.to_homogeneous_matrix().cast<float>();
// viewer->addCoordinateSystem(0.5, trans, "camera_coord");
}
int o = 0;
for (auto it = accMap.begin(); it != accMap.end(); ++it, ++o) {
const pcl::PointCloud<pcl::PointXYZRGB>::Ptr curPc = it->getPoints();
const pcl::PointCloud<pcl::PointXYZRGB>::Ptr curPcTrans(new pcl::PointCloud<pcl::PointXYZRGB>());
g2o::SE3Quat poseSE3Quat;
poseSE3Quat.fromVector(pose);
pcl::transformPointCloud(*curPc, *curPcTrans, poseSE3Quat.to_homogeneous_matrix());
const pcl::PointCloud<pcl::PointXYZRGBL>::Ptr curPcTransLab(new pcl::PointCloud<pcl::PointXYZRGBL>());
pcl::copyPointCloud(*curPcTrans, *curPcTransLab);
for(auto itPts = curPcTransLab->begin(); itPts != curPcTransLab->end(); ++itPts){
itPts->label = it->getId();
}
// pcl::visualization::PointCloudColorHandlerLabelField<pcl::PointXYZRGBL>::Ptr
// colorHandler(new pcl::visualization::PointCloudColorHandlerLabelField<pcl::PointXYZRGBL>(curPcTransLab));
pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGBL>::Ptr
colorHandler(new pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGBL>(curPcTransLab));
viewer->addPointCloud<pcl::PointXYZRGBL>(curPcTransLab, *colorHandler, "cloud_lab_" + to_string(o), v1);
}
viewer->resetStoppedFlag();
static bool cameraInit = false;
if (!cameraInit) {
viewer->initCameraParameters();
viewer->setSize(1280, 720);
// viewer->setSize(640, 480);
// viewer->setCameraPosition(0.0, 0.0, -4.0, 0.0, -1.0, 0.0);
cameraInit = true;
}
{
g2o::SE3Quat poseSE3Quat;
// if(curFrameIdx == 850){
// Vector7d endPose;
// endPose << -1.4574, 0.618103, -2.37465, 0.851687, 0.0842968, -0.497145, 0.142725;
// poseSE3Quat.fromVector(endPose);
// }
// else if(curFrameIdx == 890){
// Vector7d endPose;
// endPose << -1.59232, 0.632686, -2.83519, 0.794182, 0.0810181, -0.592532, 0.107778;
// poseSE3Quat.fromVector(endPose);
// }
// else {
// poseSE3Quat.fromVector(pose);
// }
poseSE3Quat.fromVector(pose);
Eigen::Vector3d dtFocal;
dtFocal << 0.0, 0.0, 0.0;
// dtFocal << 0.0, 0.0, 1.0;
Eigen::Vector3d t = poseSE3Quat.translation() + poseSE3Quat.rotation().toRotationMatrix() * dtFocal;
Eigen::Vector3d dtPose;
dtPose << 0.0, -2.0, -4.0;
// dtPose << 0.0, 0.0, 0.0;
Eigen::Vector3d tc = poseSE3Quat.translation() + poseSE3Quat.rotation().toRotationMatrix() * dtPose;
viewer->setCameraPosition(tc(0), tc(1), tc(2), t(0), t(1), t(2), 0.0, 1.0, 0.0);
viewer->setCameraClipDistances(0.2, 20.0);
}
viewer->spinOnce(100);
while (stopFlag && !viewer->wasStopped()) {
viewer->spinOnce(100);
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
if(saveVis){
char buf[100];
sprintf(buf, "../output/rec/vis%04d.png", curFrameIdx);
viewer->saveScreenshot(buf);
cv::Mat image = cv::imread(buf);
visVideo << image;
}
viewer->close();
}
++frameCnt;
prevPose = pose;
cout << "end frame" << endl;
}
cout << "corrCnt = " << corrCnt << endl;
cout << "incorrCnt = " << incorrCnt << endl;
cout << "unkCnt = " << unkCnt << endl;
if(meanCnt > 0){
cout << "meanDist = " << meanDist / meanCnt << " m " << endl;
cout << "meanAngDist = " << meanAngDist * 180.0 / pi / meanCnt << " deg" << endl;
}
{
int unkLen = fileGrabber.getNumFrames() - prevCorrFrameIdx;
if(unkLen > longestUnk){
longestUnk = unkLen;
}
}
cout << "longestUnk = " << longestUnk << endl;
cout << "corrCntComp = " << corrCntComp << endl;
cout << "incorrCnt = " << incorrCntComp << endl;
cout << "unkCntComp = " << unkCntComp << endl;
if(meanCnt > 0){
cout << "meanDistComp = " << meanDistComp / meanCntComp << " m " << endl;
cout << "meanAngDistComp = " << meanAngDistComp * 180.0 / pi / meanCntComp << " deg" << endl;
}
{
int unkLenComp = fileGrabber.getNumFrames() - prevCorrFrameIdxComp;
if(unkLenComp > longestUnkComp){
longestUnkComp = unkLenComp;
}
}
cout << "longestUnkComp = " << longestUnkComp << endl;
if(drawVis){
viewer->removeAllPointClouds();
viewer->removeAllShapes();
viewer->removeAllCoordinateSystems();
pcl::PointCloud<pcl::PointXYZRGB>::Ptr mapPc(new pcl::PointCloud<pcl::PointXYZRGB>());
for(const ObjInstance &mObj : map){
mapPc->insert(mapPc->end(), mObj.getPoints()->begin(), mObj.getPoints()->end());
}
pcl::PointCloud<pcl::PointXYZRGB>::Ptr mapPcGray(new pcl::PointCloud<pcl::PointXYZRGB>());
pcl::copyPointCloud(*mapPc, *mapPcGray);
for(int p = 0; p < mapPcGray->size(); ++p){
int gray = mapPcGray->at(p).r * 0.21 +
mapPcGray->at(p).g * 0.72 +
mapPcGray->at(p).b * 0.07;
gray = min(gray, 255);
mapPcGray->at(p).r = gray;
mapPcGray->at(p).g = gray;
mapPcGray->at(p).b = gray;
}
viewer->addPointCloud(mapPcGray, "map_cloud", v1);
// pcl::PointCloud<pcl::PointXYZ>::Ptr trajLine(new pcl::PointCloud<pcl::PointXYZ>());
for(int f = 1; f < visGtPoses.size(); ++f){
pcl::PointXYZ prevPose(visGtPoses[f-1][0],
visGtPoses[f-1][1],
visGtPoses[f-1][2]);
pcl::PointXYZ curPose(visGtPoses[f][0],
visGtPoses[f][1],
visGtPoses[f][2]);
// trajLine->push_back(curPose);
viewer->addLine(prevPose, curPose, 1.0, 0.0, 0.0, string("line_traj_") + to_string(f), v1);
viewer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_LINE_WIDTH,
4,
string("line_traj_") + to_string(f),
v1);
viewer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_SHADING,
pcl::visualization::PCL_VISUALIZER_SHADING_FLAT,
string("line_traj_") + to_string(f),
v1);
}
// viewer->addPolygon<pcl::PointXYZ>(trajLine, 0.0, 1.0, 0.0, "traj_poly", v1);
pcl::PointCloud<pcl::PointXYZ>::Ptr corrPoses(new pcl::PointCloud<pcl::PointXYZ>());
pcl::PointCloud<pcl::PointXYZ>::Ptr incorrPoses(new pcl::PointCloud<pcl::PointXYZ>());
for(int f = 0; f < visRecCodes.size(); ++f){
if(visRecCodes[f] == RecCode::Corr || visRecCodes[f] == RecCode::Incorr){
pcl::PointXYZ curPose(visGtPoses[f][0],
visGtPoses[f][1],
visGtPoses[f][2]);
pcl::PointXYZ curRecPose(visRecPoses[f][0],
visRecPoses[f][1],
visRecPoses[f][2]);
if(visRecCodes[f] == RecCode::Corr) {
corrPoses->push_back(curRecPose);
// cout << "correct for " << visRecFrameIdxs[f] << endl;
}
else/* if(visRecCodes[f] == RecCode::Incorr) */ {
incorrPoses->push_back(curRecPose);
// cout << "incorrect for " << visRecFrameIdxs[f] << endl;
}
viewer->addLine(curPose, curRecPose, 0.0, 1.0, 0.0, string("line_pose_") + to_string(f), v1);
viewer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_LINE_WIDTH,
4,
string("line_pose_") + to_string(f),
v1);
viewer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_SHADING,
pcl::visualization::PCL_VISUALIZER_SHADING_FLAT,
string("line_pose_") + to_string(f),
v1);
}
}
viewer->addPointCloud(corrPoses, "corr_poses_cloud", v1);
viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE,
5,
"corr_poses_cloud",
v1);
viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR,
0.0, 0.0, 1.0,
"corr_poses_cloud",
v1);
viewer->addPointCloud(incorrPoses, "incorr_poses_cloud", v1);
viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE,
5,
"incorr_poses_cloud",
v1);
viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR,
1.0, 0.0, 1.0,
"incorr_poses_cloud",
v1);
pcl::PointCloud<pcl::PointXYZ>::Ptr corrCompPoses(new pcl::PointCloud<pcl::PointXYZ>());
pcl::PointCloud<pcl::PointXYZ>::Ptr incorrCompPoses(new pcl::PointCloud<pcl::PointXYZ>());
for(int f = 0; f < visRecCompCodes.size(); ++f){
/*if(f % 10 == 0)*/ {
if (visRecCompCodes[f] == RecCode::Corr || visRecCompCodes[f] == RecCode::Incorr) {
pcl::PointXYZ curPose(visGtCompPoses[f][0],
visGtCompPoses[f][1],
visGtCompPoses[f][2]);
pcl::PointXYZ curRecPose(visRecCompPoses[f][0],
visRecCompPoses[f][1],
visRecCompPoses[f][2]);
if (visRecCompCodes[f] == RecCode::Corr) {
corrCompPoses->push_back(curRecPose);
} else/* if(visRecCodes[f] == RecCode::Incorr) */ {
incorrCompPoses->push_back(curRecPose);
}
viewer->addLine(curPose,
curRecPose,
0.0,
1.0,
1.0,
string("line_comp_pose_") + to_string(f),
v1);
viewer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_LINE_WIDTH,
4,
string("line_comp_pose_") + to_string(f),
v1);
viewer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_SHADING,
pcl::visualization::PCL_VISUALIZER_SHADING_FLAT,
string("line_comp_pose_") + to_string(f),
v1);
}
}
}
viewer->addPointCloud(corrCompPoses, "corr_comp_poses_cloud", v1);
viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE,
5,
"corr_comp_poses_cloud",
v1);
viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR,
1.0, 1.0, 0.0,
"corr_comp_poses_cloud",
v1);
viewer->addPointCloud(incorrCompPoses, "incorr_comp_poses_cloud", v1);
viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE,
5,
"incorr_comp_poses_cloud",
v1);
viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR,
1.0, 0.0, 1.0,
"incorr_comp_poses_cloud",
v1);
viewer->resetStoppedFlag();
viewer->initCameraParameters();
viewer->setCameraPosition(0.0, 0.0, -6.0, 0.0, 1.0, 0.0);
viewer->spinOnce(100);
while (!viewer->wasStopped()) {
viewer->spinOnce(100);
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
viewer->close();
}
viewer->close();
}
void PlaneSlam::evaluateMatching(const cv::FileStorage &fs,
const vectorObjInstance &objInstances1,
const vectorObjInstance &objInstances2,
std::ifstream &inputResFile,
std::ofstream &outputResFile,
const Vector7d >Transform,
double scoreThresh,
double scoreDiffThresh,
double fitThresh,
double distinctThresh,
double poseDiffThresh,
Vector7d &predTransform,
RecCode &recCode,
double &linDist,
double &angDist,
pcl::visualization::PCLVisualizer::Ptr viewer,
int viewPort1,
int viewPort2)
{
vectorVector7d planesTrans;
vector<double> planesTransScores;
vector<double> planesTransFits;
vector<int> planesTransDistinct;
vector<Matching::ValidTransform> transforms;
Matching::MatchType matchType = Matching::MatchType::Unknown;
if(inputResFile.is_open()){
Vector7d curPose;
for(int c = 0; c < 7; ++c){
inputResFile >> curPose(c);
}
int matchTypeId;
inputResFile >> matchTypeId;
if(matchTypeId == 0){
matchType = Matching::MatchType::Ok;
cout << "matchType = Matching::MatchType::Ok;" << endl;
int numTrans;
inputResFile >> numTrans;
for(int t = 0; t < numTrans; ++t){
Vector7d curTrans;
double curScore;
double curFit;
int curDistinct;
double curDiff;
for(int c = 0; c < 7; ++c){
inputResFile >> curTrans(c);
}
inputResFile >> curScore >> curFit >> curDistinct >> curDiff;
planesTrans.push_back(curTrans);
planesTransScores.push_back(curScore);
planesTransFits.push_back(curFit);
planesTransDistinct.push_back(curDistinct);
// diff is recalculated later
}
}
else if(matchTypeId == -1){
matchType = Matching::MatchType::Unknown;
cout << "matchType = Matching::MatchType::Unknown;" << endl;
}
cout << "results read" << endl;
}
else {
matchType = Matching::matchFrameToMap(settings,
objInstances1,
objInstances2,
planesTrans,
planesTransScores,
planesTransFits,
planesTransDistinct,
transforms,
viewer,
viewPort1,
viewPort2);
}
g2o::SE3Quat gtTransformSE3Quat(gtTransform);
bool isUnamb = true;
if( matchType == Matching::MatchType::Ok){
if(planesTransScores.front() < scoreThresh){
isUnamb = false;
}
if(planesTransScores.size() > 1){
if(fabs(planesTransScores[0] - planesTransScores[1]) < scoreDiffThresh){
isUnamb = false;
}
}
if(planesTransFits.front() > fitThresh){
isUnamb = false;
}
if(planesTransDistinct.front() < distinctThresh){
isUnamb = false;
}
}
if(planesTrans.size() > 0){
// stopFlag = true;
}
cout << "planesTrans.size() = " << planesTrans.size() << endl;
vector<double> planesTransDiff;
vector<double> planesTransDiffEucl;
vector<double> planesTransDiffAng;
for(int t = 0; t < planesTrans.size(); ++t){
g2o::SE3Quat planesTransSE3Quat(planesTrans[t]);
// cout << "frame diff SE3Quat = " << (planesTransSE3Quat.inverse() * poseSE3Quat).toVector().transpose() << endl;
cout << "planesTrans[" << t << "] = " << planesTrans[t].transpose() << endl;
cout << "planesTransScores[" << t << "] = " << planesTransScores[t] << endl;
cout << "planesTransFits[" << t << "] = " << planesTransFits[t] << endl;
cout << "planesTransDistinct[" << t << "] = " << planesTransDistinct[t] << endl;
if(std::isnan(planesTransScores[t])){
planesTransScores[t] = 0.0;
}
// cout << "pose = " << pose.transpose() << endl;
// cout << "planesTrans = " << planesTrans.transpose() << endl;
// {
// viewer->removeCoordinateSystem("trans coord", v2);
// Eigen::Affine3f trans = Eigen::Affine3f::Identity();
// trans.matrix() = planesTransSE3Quat.inverse().to_homogeneous_matrix().cast<float>();
// // trans.fromPositionOrientationScale(, rot, 1.0);
// viewer->addCoordinateSystem(1.0, trans, "trans coord", v2);
// }
g2o::SE3Quat diffSE3Quat = planesTransSE3Quat.inverse() * gtTransformSE3Quat;
// g2o::SE3Quat diffInvSE3Quat = poseSE3Quat * planesTransSE3Quat.inverse();
Vector6d diffLog = diffSE3Quat.log();
// cout << "diffLog = " << diffSE3Quat.log().transpose() << endl;
// cout << "diffInvLog = " << diffInvSE3Quat.log().transpose() << endl;
double diff = diffLog.transpose() * diffLog;
double diffEucl = diffSE3Quat.toVector().head<3>().norm();
Eigen::Vector3d diffLogAng = Misc::logMap(diffSE3Quat.rotation());
double diffAng = diffLogAng.norm();
// Eigen::Vector3d diffAngEuler = diffInvSE3Quat.rotation().toRotationMatrix().eulerAngles(1, 0, 2);
// cout << "diffAngEuler = " << diffAngEuler.transpose() << endl;
// double diffAng = std::min(diffAngEuler[0], pi - diffAngEuler[0]);
planesTransDiff.push_back(diff);
planesTransDiffEucl.push_back(diffEucl);
cout << "planesTransDiffEucl[" << t << "] = " << planesTransDiffEucl[t] << endl;
planesTransDiffAng.push_back(diffAng);
cout << "planesTransDiffAng[" << t << "] = " << planesTransDiffAng[t] << endl;
cout << "planesTransDiff[" << t << "] = " << planesTransDiff[t] << endl;
}
if( matchType == Matching::MatchType::Ok && isUnamb){
if(planesTransDiff.front() > poseDiffThresh){
recCode = RecCode::Incorr;
}
else{
recCode = RecCode::Corr;
// computing mean and standard deviation
static float refNumTransforms = 0;
static float expNumTransforms = 0;
static float expNumTransformsSq = 0;
static int numTransformsCnt = 0;
if(numTransformsCnt == 0){
refNumTransforms = transforms.size();
}
expNumTransforms += transforms.size() - refNumTransforms;
expNumTransformsSq += (transforms.size() - refNumTransforms) * (transforms.size() - refNumTransforms);
++numTransformsCnt;
cout << "refNumTransforms = " << refNumTransforms << endl;
cout << "expNumTransforms = " << expNumTransforms << endl;
cout << "expNumTransformsSq = " << expNumTransformsSq << endl;
cout << "numTransformsCnt = " << numTransformsCnt << endl;
cout << "mean number of transforms: " << refNumTransforms +
expNumTransforms/numTransformsCnt << endl;
if(numTransformsCnt > 1) {
cout << "std dev = " << sqrt((expNumTransformsSq -
expNumTransforms * expNumTransforms /
numTransformsCnt) /
(numTransformsCnt - 1)) << endl;
}
}
predTransform = planesTrans.front();
linDist = planesTransDiffEucl.front();
angDist = planesTransDiffAng.front();
}
else{
recCode = RecCode::Unk;
}
if(outputResFile.is_open()){
// saving results file
outputResFile << gtTransform.transpose() << endl;
if( matchType == Matching::MatchType::Ok){
outputResFile << 0 << endl;
outputResFile << planesTrans.size() << endl;
for(int t = 0; t < planesTrans.size(); ++t){
outputResFile << planesTrans[t].transpose() <<
" " << planesTransScores[t] <<
" " << planesTransFits[t] <<
" " << planesTransDistinct[t] <<
" " << planesTransDiff[t] << endl;
}
}
else if(matchType == Matching::MatchType::Unknown){
outputResFile << -1 << endl;
}
outputResFile << endl << endl;
}
}
| 45.340198 | 144 | 0.459885 | [
"object",
"vector",
"transform",
"3d"
] |
755931c2c29e58d8942563ed1dba8c1794fe7fc2 | 2,362 | cpp | C++ | src/gct/semaphore_create_info.cpp | Fadis/gct | bde211f9336e945e4db21f5abb4ce01dcad78049 | [
"MIT"
] | 1 | 2022-03-03T09:27:09.000Z | 2022-03-03T09:27:09.000Z | src/gct/semaphore_create_info.cpp | Fadis/gct | bde211f9336e945e4db21f5abb4ce01dcad78049 | [
"MIT"
] | 1 | 2021-12-02T03:45:45.000Z | 2021-12-03T23:44:37.000Z | src/gct/semaphore_create_info.cpp | Fadis/gct | bde211f9336e945e4db21f5abb4ce01dcad78049 | [
"MIT"
] | null | null | null | #include <gct/semaphore_create_info.hpp>
#include <vulkan2json/SemaphoreCreateInfo.hpp>
#ifdef VK_VERSION_1_1
#include <vulkan2json/ExportSemaphoreCreateInfo.hpp>
#elif defined(VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME)
#include <vulkan2json/ExportSemaphoreCreateInfoKHR.hpp>
#endif
#ifdef VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME
#include <vulkan2json/ExportSemaphoreWin32HandleInfoKHR.hpp>
#endif
#ifdef VK_VERSION_1_2
#include <vulkan2json/SemaphoreTypeCreateInfo.hpp>
#elif defined(VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME)
#include <vulkan2json/SemaphoreTypeCreateInfoKHR.hpp>
#endif
namespace gct {
void to_json( nlohmann::json &root, const semaphore_create_info_t &v ) {
root = nlohmann::json::object();
root[ "basic" ] = v.get_basic();
#if defined(VK_VERSION_1_1) || defined(VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME)
LIBGCT_EXTENSION_TO_JSON( export_semaphore )
#endif
#ifdef VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME
LIBGCT_EXTENSION_TO_JSON( export_semaphore_win32_handle )
#endif
#if defined(VK_VERSION_1_2) || defined(VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME)
LIBGCT_EXTENSION_TO_JSON( type )
#endif
}
void from_json( const nlohmann::json &root, semaphore_create_info_t &v ) {
if( !root.is_object() ) throw incompatible_json( "The JSON is incompatible to semaphore_create_info_t", __FILE__, __LINE__ );
LIBGCT_EXTENSION_FROM_JSON( basic )
#if defined(VK_VERSION_1_1) || defined(VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME)
LIBGCT_EXTENSION_FROM_JSON( export_semaphore )
#endif
#ifdef VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME
LIBGCT_EXTENSION_FROM_JSON( export_semaphore_win32_handle )
#endif
#if defined(VK_VERSION_1_2) || defined(VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME)
LIBGCT_EXTENSION_FROM_JSON( type )
#endif
}
semaphore_create_info_t &semaphore_create_info_t::rebuild_chain() {
LIBGCT_EXTENSION_BEGIN_REBUILD_CHAIN
#if defined(VK_VERSION_1_1) || defined(VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME)
LIBGCT_EXTENSION_REBUILD_CHAIN( export_semaphore )
#endif
#ifdef VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME
LIBGCT_EXTENSION_REBUILD_CHAIN( export_semaphore_win32_handle )
#endif
#if defined(VK_VERSION_1_2) || defined(VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME)
LIBGCT_EXTENSION_REBUILD_CHAIN( type )
#endif
LIBGCT_EXTENSION_END_REBUILD_CHAIN
}
}
| 40.033898 | 129 | 0.825995 | [
"object"
] |
755cb923a683974c775a59e935fcb67203e96cfb | 63,366 | cxx | C++ | test/multiarray/test_chunked.cxx | BSeppke/vigra | 490213d8954a03bdb985b52cfaafd6389431efd8 | [
"MIT"
] | 316 | 2015-01-01T02:06:53.000Z | 2022-03-28T08:37:28.000Z | test/multiarray/test_chunked.cxx | BSeppke/vigra | 490213d8954a03bdb985b52cfaafd6389431efd8 | [
"MIT"
] | 232 | 2015-01-06T23:51:07.000Z | 2022-03-18T13:14:02.000Z | test/multiarray/test_chunked.cxx | BSeppke/vigra | 490213d8954a03bdb985b52cfaafd6389431efd8 | [
"MIT"
] | 150 | 2015-01-05T02:11:18.000Z | 2022-03-16T09:44:14.000Z | /************************************************************************/
/* */
/* Copyright 2013-2014 by Ullrich Koethe */
/* */
/* This file is part of the VIGRA computer vision library. */
/* The VIGRA Website is */
/* http://hci.iwr.uni-heidelberg.de/vigra/ */
/* Please direct questions, bug reports, and contributions to */
/* ullrich.koethe@iwr.uni-heidelberg.de or */
/* vigra@informatik.uni-hamburg.de */
/* */
/* Permission is hereby granted, free of charge, to any person */
/* obtaining a copy of this software and associated documentation */
/* files (the "Software"), to deal in the Software without */
/* restriction, including without limitation the rights to use, */
/* copy, modify, merge, publish, distribute, sublicense, and/or */
/* sell copies of the Software, and to permit persons to whom the */
/* Software is furnished to do so, subject to the following */
/* conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the */
/* Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
#include <functional>
#include <stdio.h>
#include "vigra/unittest.hxx"
#include "vigra/multi_array.hxx"
#include "vigra/multi_array_chunked.hxx"
#ifdef HasHDF5
#include "vigra/multi_array_chunked_hdf5.hxx"
#endif
#include "vigra/functorexpression.hxx"
#include "vigra/multi_math.hxx"
#include "vigra/algorithm.hxx"
#include "vigra/random.hxx"
#include "vigra/timing.hxx"
//#include "marray.hxx"
using namespace vigra;
using namespace vigra::functor;
#define shouldEqualIndexing(N, a, b) \
{ \
MultiCoordinateIterator<N> cccccccc(a.shape()), ccccccccend(cccccccc.getEndIterator()); \
for(; cccccccc != ccccccccend; ++cccccccc) \
if(a[*cccccccc] != b[*cccccccc]) \
shouldEqual(a[*cccccccc], b[*cccccccc]); \
}
template <class Array>
class ChunkedMultiArrayTest
{
public:
// typedef typename vigra::detail::ResolveMultiband<T>::type scalar_type;
typedef typename Array::value_type T;
typedef MultiArray <3, T> PlainArray;
typedef ChunkedArray<3, T> BaseArray;
typedef VIGRA_UNIQUE_PTR<BaseArray> ArrayPtr;
typedef typename BaseArray::iterator Iterator;
static const int channelCount = NumericTraits<T>::isScalar::value
? 1
: 3;
Shape3 shape, chunk_shape;
ArrayPtr empty_array, array;
PlainArray ref;
static const int fill_value = 42;
ChunkedMultiArrayTest ()
: shape(20,21,22),
chunk_shape(8),
ref(shape)
{
linearSequence(ref.begin(), ref.end());
empty_array = createArray(shape, chunk_shape, (Array *)0, "empty.h5");
empty_array->setCacheMaxSize(27);
array = createArray(shape, chunk_shape, (Array *)0);
linearSequence(array->begin(), array->end());
}
static ArrayPtr createArray(Shape3 const & shape,
Shape3 const & /*chunk_shape*/,
ChunkedArrayFull<3, T> *,
std::string const & = "chunked_test.h5")
{
return ArrayPtr(new ChunkedArrayFull<3, T>(shape, ChunkedArrayOptions().fillValue(fill_value)));
}
static ArrayPtr createArray(Shape3 const & shape,
Shape3 const & chunk_shape,
ChunkedArrayLazy<3, T> *,
std::string const & = "chunked_test.h5")
{
return ArrayPtr(new ChunkedArrayLazy<3, T>(shape, chunk_shape,
ChunkedArrayOptions().fillValue(fill_value)));
}
static ArrayPtr createArray(Shape3 const & shape,
Shape3 const & chunk_shape,
ChunkedArrayCompressed<3, T> *,
std::string const & = "chunked_test.h5")
{
return ArrayPtr(new ChunkedArrayCompressed<3, T>(shape, chunk_shape,
ChunkedArrayOptions().fillValue(fill_value)
.compression(LZ4)));
}
#ifdef HasHDF5
static ArrayPtr createArray(Shape3 const & shape,
Shape3 const & chunk_shape,
ChunkedArrayHDF5<3, T> *,
std::string const & name = "chunked_test.h5")
{
HDF5File hdf5_file(name, HDF5File::New);
return ArrayPtr(new ChunkedArrayHDF5<3, T>(hdf5_file, "test", HDF5File::New,
shape, chunk_shape,
ChunkedArrayOptions().fillValue(fill_value)));
}
#endif
static ArrayPtr createArray(Shape3 const & shape,
Shape3 const & chunk_shape,
ChunkedArrayTmpFile<3, T> *,
std::string const & = "chunked_test.h5")
{
return ArrayPtr(new ChunkedArrayTmpFile<3, T>(shape, chunk_shape,
ChunkedArrayOptions().fillValue(fill_value), ""));
}
void test_construction ()
{
bool isFullArray = IsSameType<Array, ChunkedArrayFull<3, T> >::value;
should(array->isInside(Shape3(1,2,3)));
should(!array->isInside(Shape3(1,23,3)));
should(!array->isInside(Shape3(1,2,-3)));
shouldEqual(array->shape(), ref.shape());
shouldEqual(array->shape(0), ref.shape(0));
shouldEqual(array->shape(1), ref.shape(1));
shouldEqual(array->shape(2), ref.shape(2));
if(isFullArray)
shouldEqual(array->chunkArrayShape(), Shape3(1));
else
shouldEqual(array->chunkArrayShape(), Shape3(3));
shouldEqualSequence(array->begin(), array->end(), ref.begin());
shouldEqualSequence(array->cbegin(), array->cend(), ref.begin());
should(*array == ref);
should(*array != ref.subarray(Shape3(1),ref.shape()));
shouldEqual(array->getItem(Shape3(1,8,17)), ref[Shape3(1,8,17)]);
ref[ref.size()-1] = ref[ref.size()-1] + T(1);
should(*array != ref);
array->setItem(ref.shape()-Shape3(1), ref[ref.size()-1]);
should(*array == ref);
if(isFullArray)
shouldEqual(empty_array->dataBytes(), ref.size()*sizeof(T));
else
shouldEqual(empty_array->dataBytes(), 0);
PlainArray empty(shape, T(fill_value));
// const_iterator should simply use the fill_value_chunk_
shouldEqualSequence(empty_array->cbegin(), empty_array->cend(), empty.begin());
if(isFullArray)
shouldEqual(empty_array->dataBytes(), ref.size()*sizeof(T));
else
shouldEqual(empty_array->dataBytes(), 0);
// non-const iterator should allocate the array and initialize with fill_value_
shouldEqualSequence(empty_array->begin(), empty_array->end(), empty.begin());
if(IsSameType<Array, ChunkedArrayTmpFile<3, T> >::value)
should(empty_array->dataBytes() >= ref.size()*sizeof(T)); // must pad to a full memory page
else
shouldEqual(empty_array->dataBytes(), ref.size()*sizeof(T));
// make sure the central chunk is loaded, so that releaseChunks() will have an effect
array->getItem(Shape3(10,10,10));
int dataBytesBefore = array->dataBytes();
array->releaseChunks(Shape3(5, 0, 3), Shape3(shape[0], shape[1], shape[2]-3), true);
if(!isFullArray)
should(array->dataBytes() < (unsigned)dataBytesBefore);
if(IsSameType<Array, ChunkedArrayLazy<3, T> >::value ||
IsSameType<Array, ChunkedArrayCompressed<3, T> >::value)
{
ref.subarray(Shape3(8, 0, 8), Shape3(shape[0], shape[1], 16)) = T(fill_value);
}
shouldEqualSequence(array->cbegin(), array->cend(), ref.begin());
// FIXME: test copy construction?
// should(array3 != array3.subarray(Shape(1,1,1), Shape(2,2,2)));
// should(array3.subarray(Shape(0,0,0), Shape(10,1,1)) != array3.subarray(Shape(0,1,0), Shape(10,2,1)));
// array3_type a(array3.shape());
// linearSequence(a.begin(), a.end());
// should(a == array3);
// for(unsigned int k=0; k<10; ++k)
// array3(k,0,0) += 10;
// should(array3.subarray(Shape(0,0,0), Shape(10,1,1)) == array3.subarray(Shape(0,1,0), Shape(10,2,1)));
// MultibandView3 channel_view(a.multiband());
// shouldEqual(a.shape(), channel_view.shape());
// shouldEqual(a.data(), channel_view.data());
}
void test_assignment()
{
MultiArrayView <3, T, ChunkedArrayTag> v;
should(!v.hasData());
v = array->subarray(Shape3(), ref.shape());
should(v.hasData());
MultiArrayView <3, T, ChunkedArrayTag> vc;
should(!vc.hasData());
vc = v;
should(vc.hasData());
shouldEqual(vc.shape(), ref.shape());
shouldEqualSequence(vc.begin(), vc.end(), ref.begin());
vc = T(7);
std::vector<T> v7ref(vc.size(), T(7));
should(vc.hasData());
shouldEqual(vc.shape(), ref.shape());
shouldEqualSequence(vc.begin(), vc.end(), v7ref.begin());
shouldEqualSequence(v.begin(), v.end(), v7ref.begin());
vc = ref;
should(vc.hasData());
shouldEqual(vc.shape(), ref.shape());
shouldEqualSequence(vc.begin(), vc.end(), ref.begin());
MultiArrayView <3, T, ChunkedArrayTag> vs(array->subarray(Shape3(), Shape3(4)));
should(vs.hasData());
try
{
vc = vs;
failTest("shape mismatch in assignment failed to throw exception");
}
catch(PreconditionViolation & e)
{
std::string expected("\nPrecondition violation!\nMultiArrayView::operator=(): shape mismatch.\n"),
actual(e.what());
shouldEqual(actual.substr(0, expected.size()), expected);
}
vc += T(1);
ref += T(1);
shouldEqual(vc.shape(), ref.shape());
shouldEqualSequence(vc.begin(), vc.end(), ref.begin());
vc += v;
ref *= T(2);
shouldEqual(vc.shape(), ref.shape());
shouldEqualSequence(vc.begin(), vc.end(), ref.begin());
vc += T(42);
ref += T(42);
shouldEqual(vc.shape(), ref.shape());
shouldEqualSequence(vc.begin(), vc.end(), ref.begin());
vc -= T(42);
ref -= T(42);
shouldEqual(vc.shape(), ref.shape());
shouldEqualSequence(vc.begin(), vc.end(), ref.begin());
ref /= T(2);
vc -= ref;
shouldEqual(vc.shape(), ref.shape());
shouldEqualSequence(vc.begin(), vc.end(), ref.begin());
vc *= v;
ref *= ref;
shouldEqual(vc.shape(), ref.shape());
shouldEqualSequence(vc.begin(), vc.end(), ref.begin());
vc *= T(4);
ref *= T(4);
shouldEqual(vc.shape(), ref.shape());
shouldEqualSequence(vc.begin(), vc.end(), ref.begin());
vc /= T(4);
ref /= T(4);
shouldEqual(vc.shape(), ref.shape());
shouldEqualSequence(vc.begin(), vc.end(), ref.begin());
vc /= PlainArray(ref.shape(), T(1));
shouldEqual(vc.shape(), ref.shape());
shouldEqualSequence(vc.begin(), vc.end(), ref.begin());
}
void test_bindAt ()
{
MultiArrayView <2, T, ChunkedArrayTag> v = array->bindAt (1, 4);
MultiArrayView <2, T, ChunkedArrayTag> vv = array->template bind<1>(4);
MultiArrayView <2, T, StridedArrayTag> vr = ref.bindAt (1, 4);
shouldEqual(v.shape(), vr.shape());
shouldEqual(vv.shape(), vr.shape());
should(v == vr);
should(vv == vr);
shouldEqualSequence(v.begin(), v.end(), vr.begin());
shouldEqualIndexing(2, v, vr);
MultiArrayView <2, T, ChunkedArrayTag> vt = v.transpose();
MultiArrayView <2, T, StridedArrayTag> vtr = vr.transpose();
shouldEqual(vt.shape(), vtr.shape());
should(vt == vtr);
shouldEqualSequence(vt.begin(), vt.end(), vtr.begin());
shouldEqualIndexing(2, vt, vtr);
MultiArrayView <1, T, ChunkedArrayTag> v1 = v.bindAt (0, 11);
MultiArrayView <1, T, StridedArrayTag> v1r = vr.bindAt (0, 11);
shouldEqual(v1.shape(), v1r.shape());
should(v1 == v1r);
shouldEqualSequence(v1.begin(), v1.end(), v1r.begin());
shouldEqualIndexing(1, v1, v1r);
MultiArrayView <1, T, ChunkedArrayTag> v1t = v1.transpose();
shouldEqual(v1t.shape(), v1r.shape());
should(v1t == v1r);
shouldEqualSequence(v1t.begin(), v1t.end(), v1r.begin());
shouldEqualIndexing(1, v1t, v1r);
}
void test_bindInner ()
{
MultiArrayView <2, T, ChunkedArrayTag> v = array->bindInner(2);
MultiArrayView <2, T, StridedArrayTag> vr = ref.bindInner(2);
shouldEqual(v.shape(), vr.shape());
should(v == vr);
TinyVector <int, 2> inner_indices (2, 5);
MultiArrayView <1, T, ChunkedArrayTag> v1 = array->bindInner(inner_indices);
MultiArrayView <1, T, StridedArrayTag> v1r = ref.bindInner(inner_indices);
shouldEqual(v1.shape(), v1r.shape());
should(v1 == v1r);
MultiArrayView <1, T, ChunkedArrayTag> v21 = v.bindInner(5);
shouldEqual(v21.shape(), v1r.shape());
should(v21 == v1r);
}
void test_bindOuter ()
{
MultiArrayView <2, T, ChunkedArrayTag> v = array->bindOuter(2);
MultiArrayView <2, T, StridedArrayTag> vr = ref.bindOuter(2);
shouldEqual(v.shape(), vr.shape());
should(v == vr);
TinyVector <int, 2> inner_indices (5, 2);
MultiArrayView <1, T, ChunkedArrayTag> v1 = array->bindOuter(inner_indices);
MultiArrayView <1, T, StridedArrayTag> v1r = ref.bindOuter(inner_indices);
shouldEqual(v1.shape(), v1r.shape());
should(v1 == v1r);
MultiArrayView <1, T, ChunkedArrayTag> v21 = v.bindOuter(5);
shouldEqual(v21.shape(), v1r.shape());
should(v21 == v1r);
}
void test_subarray ()
{
{
Shape3 start, stop(ref.shape()); // empty array
bool isFullArray = IsSameType<Array, ChunkedArrayFull<3, T> >::value;
MultiArrayView <3, T const, ChunkedArrayTag> vc(empty_array->const_subarray(start, stop));
MultiArray <3, T> c(stop-start);
empty_array->checkoutSubarray(start, c);
if(isFullArray)
shouldEqual(empty_array->dataBytes(), ref.size()*sizeof(T));
else
shouldEqual(empty_array->dataBytes(), 0);
PlainArray empty(shape, T(fill_value));
shouldEqualSequence(vc.begin(), vc.end(), empty.begin());
shouldEqualSequence(c.begin(), c.end(), empty.begin());
MultiArrayView <3, T, ChunkedArrayTag> v(empty_array->subarray(start, stop));
if(IsSameType<Array, ChunkedArrayTmpFile<3, T> >::value)
should(empty_array->dataBytes() >= ref.size()*sizeof(T)); // must pad to a full memory page
else
shouldEqual(empty_array->dataBytes(), ref.size()*sizeof(T));
shouldEqualSequence(v.begin(), v.end(), empty.begin());
}
{
Shape3 start, stop(ref.shape()); // whole array
MultiArrayView <3, T, ChunkedArrayTag> v(array->subarray(start, stop));
MultiArrayView <3, T, ChunkedArrayTag> vt(v.transpose());
MultiArray <3, T> c(stop-start);
array->checkoutSubarray(start, c);
MultiArrayView <3, T, StridedArrayTag> vr = ref.subarray(start, stop);
MultiArrayView <3, T, StridedArrayTag> vtr = vr.transpose();
shouldEqual(v.shape(), vr.shape());
should(v == vr);
shouldEqualSequence(v.begin(), v.end(), vr.begin());
shouldEqualIndexing(3, v, vr);
shouldEqual(vt.shape(), vtr.shape());
should(vt == vtr);
shouldEqualSequence(vt.begin(), vt.end(), vtr.begin());
shouldEqualIndexing(3, vt, vtr);
shouldEqual(c.shape(), vr.shape());
should(c == vr);
shouldEqualSequence(c.begin(), c.end(), vr.begin());
shouldEqualIndexing(3, c, vr);
}
{
Shape3 start(3,2,1), stop(4,5,6); // single chunk
MultiArrayView <3, T, ChunkedArrayTag> v(array->subarray(start, stop));
MultiArrayView <3, T, ChunkedArrayTag> vt(v.transpose());
MultiArray <3, T> c(stop-start);
array->checkoutSubarray(start, c);
MultiArrayView <3, T, StridedArrayTag> vr = ref.subarray(start, stop);
MultiArrayView <3, T, StridedArrayTag> vtr = vr.transpose();
shouldEqual(v.shape(), vr.shape());
should(v == vr);
shouldEqualSequence(v.begin(), v.end(), vr.begin());
shouldEqualIndexing(3, v, vr);
shouldEqual(vt.shape(), vtr.shape());
should(vt == vtr);
shouldEqualSequence(vt.begin(), vt.end(), vtr.begin());
shouldEqualIndexing(3, vt, vtr);
shouldEqual(c.shape(), vr.shape());
should(c == vr);
shouldEqualSequence(c.begin(), c.end(), vr.begin());
shouldEqualIndexing(3, c, vr);
}
{
Shape3 start(7,6,5), stop(9,10,11); // across chunk borders
MultiArrayView <3, T, ChunkedArrayTag> v(array->subarray(start, stop));
MultiArrayView <3, T, ChunkedArrayTag> vt(v.transpose());
MultiArray <3, T> c(stop-start);
array->checkoutSubarray(start, c);
MultiArrayView <3, T, StridedArrayTag> vr = ref.subarray(start, stop);
shouldEqual(v.shape(), vr.shape());
should(v == vr);
shouldEqualSequence(v.begin(), v.end(), vr.begin());
shouldEqualIndexing(3, v, vr);
shouldEqual(c.shape(), vr.shape());
should(c == vr);
shouldEqualSequence(c.begin(), c.end(), vr.begin());
shouldEqualIndexing(3, c, vr);
}
}
void test_iterator ()
{
Shape3 s(ref.shape());
typedef typename ChunkedArray<3, T>::iterator Iterator;
MultiArrayView <3, T, ChunkedArrayTag> v(array->subarray(Shape3(), s));
Iterator i1 = array->begin();
Iterator iend = array->end();
MultiCoordinateIterator<3> c(s),
cend = c.getEndIterator();
should(i1.isValid() && !i1.atEnd());
should(!iend.isValid() && iend.atEnd());
should(iend.getEndIterator() == iend);
shouldEqual(i1.point(), *c);
shouldEqual((i1+0).point(), c[0]);
shouldEqual((i1+1).point(), c[1]);
shouldEqual((i1+2).point(), c[2]);
shouldEqual((i1+3).point(), c[3]);
shouldEqual((i1+6).point(), c[6]);
shouldEqual((i1+7).point(), c[7]);
shouldEqual((i1+9).point(), c[9]);
shouldEqual((iend-1).point(), *(cend-1));
shouldEqual((iend-2).point(), *(cend-2));
shouldEqual((iend-3).point(), *(cend-3));
shouldEqual((iend-7).point(), *(cend-7));
shouldEqual((iend-8).point(), *(cend-8));
shouldEqual((iend-10).point(), *(cend-10));
shouldEqual(&i1[0], &v[Shape3(0,0,0)]);
shouldEqual(&i1[1], &v[Shape3(1,0,0)]);
shouldEqual(&i1[s[0]], &v[Shape3(0,1,0)]);
shouldEqual(&i1[s[0]*9+1], &v[Shape3(1,9,0)]);
shouldEqual(&i1[s[0]*s[1]], &v[Shape3(0,0,1)]);
shouldEqual(&i1[s[0]*s[1]*9+1], &v[Shape3(1,0,9)]);
shouldEqual(&i1[(s[0]+1)*s[1]], &v[Shape3(1,1,1)]);
shouldEqual(&*(i1+0), &v[Shape3(0,0,0)]);
shouldEqual(&*(i1+1), &v[Shape3(1,0,0)]);
shouldEqual(&*(i1+s[0]), &v[Shape3(0,1,0)]);
shouldEqual(&*(i1+s[0]*9+1), &v[Shape3(1,9,0)]);
shouldEqual(&*(i1+s[0]*s[1]), &v[Shape3(0,0,1)]);
shouldEqual(&*(i1+s[0]*s[1]*9+1), &v[Shape3(1,0,9)]);
shouldEqual(&*(i1+(s[0]+1)*s[1]), &v[Shape3(1,1,1)]);
shouldEqual(&*(i1+Shape3(0,0,0)), &v[Shape3(0,0,0)]);
shouldEqual(&*(i1+Shape3(1,0,0)), &v[Shape3(1,0,0)]);
shouldEqual(&*(i1+Shape3(0,1,0)), &v[Shape3(0,1,0)]);
shouldEqual(&*(i1+Shape3(1,11,0)), &v[Shape3(1,11,0)]);
shouldEqual(&*(i1+Shape3(0,0,1)), &v[Shape3(0,0,1)]);
shouldEqual(&*(i1+Shape3(1,0,11)), &v[Shape3(1,0,11)]);
shouldEqual(&*(i1+Shape3(1,1,1)), &v[Shape3(1,1,1)]);
shouldEqual(&*(iend-1), &v[Shape3(19,20,21)]);
shouldEqual(&*(iend-2), &v[Shape3(18,20,21)]);
shouldEqual(&*(iend-10), &v[Shape3(10,20,21)]);
shouldEqual(&*(iend-s[0]-1), &v[Shape3(19,19,21)]);
shouldEqual(&iend[-1], &v[Shape3(19,20,21)]);
shouldEqual(&iend[-2], &v[Shape3(18,20,21)]);
shouldEqual(&iend[-10], &v[Shape3(10,20,21)]);
shouldEqual(&iend[-s[0]-1], &v[Shape3(19,19,21)]);
Iterator i2;
i2 = iend;
should(i2 == iend);
should(!i2.isValid() && i2.atEnd());
--i2;
should(i2.isValid() && !i2.atEnd());
should(i2.getEndIterator() == iend);
shouldEqual(i2.point(), Shape3(19,20,21));
shouldEqual(&*i2, &v[Shape3(19,20,21)]);
for(int k=0; k<20; ++k)
--i2;
should(i2.isValid() && !i2.atEnd());
should(i2.getEndIterator() == iend);
shouldEqual(i2.point(), Shape3(19,19,21));
shouldEqual(&*i2, &v[Shape3(19,19,21)]);
for(int k=0; k<420; ++k)
--i2;
should(i2.isValid() && !i2.atEnd());
should(i2.getEndIterator() == iend);
shouldEqual(i2.point(), Shape3(19,19,20));
shouldEqual(&*i2, &v[Shape3(19,19,20)]);
i2 = iend-1;
shouldEqual(&*(i2-Shape3(0,0,0)), &v[Shape3(19,20,21)]);
shouldEqual(&*(i2-Shape3(1,0,0)), &v[Shape3(18,20,21)]);
shouldEqual(&*(i2-Shape3(0,1,0)), &v[Shape3(19,19,21)]);
shouldEqual(&*(i2-Shape3(9,1,0)), &v[Shape3(10,19,21)]);
shouldEqual(&*(i2-Shape3(0,0,1)), &v[Shape3(19,20,20)]);
shouldEqual(&*(i2-Shape3(9,0,1)), &v[Shape3(10,20,20)]);
shouldEqual(&*(i2-Shape3(9,9,1)), &v[Shape3(10,11,20)]);
shouldEqual(&*(i2-Shape3(9,9,9)), &v[Shape3(10,11,12)]);
unsigned int count = 0;
Shape3 p;
i2 = array->begin();
Iterator i3 = array->begin();
Iterator i4 = array->begin();
Iterator i5 = array->begin();
Iterator i6 = array->begin();
for (p[2]=0, i3.resetDim(2), i4.setDim(2, 0), i5.template dim<2>() = 0, i6.resetDim(2);
i3.point(2) != s[2];
i3.incDim(2), i4.addDim(2, 1), ++i5.template dim<2>(), i6.template dim<2>() += 1, ++p[2])
{
for (p[1]=0, i3.resetDim(1), i4.setDim(1, 0), i5.template dim<1>() = 0, i6.resetDim(1);
i3.point(1) != s[1];
i3.incDim(1), i4.addDim(1, 1), ++i5.template dim<1>(), i6.template dim<1>() += 1, ++p[1])
{
for (p[0]=0, i3.resetDim(0), i4.setDim(0, 0), i5.template dim<0>() = 0, i6.resetDim(0);
i3.point(0) != s[0];
i3.incDim(0), i4.addDim(0, 1), ++i5.template dim<0>(), i6.template dim<0>() += 1, ++p[0], ++i1, ++c, i2 += 1, ++count)
{
shouldEqual(&*i1, &v[p]);
shouldEqual(&*i2, &v[p]);
shouldEqual(&*i3, &v[p]);
shouldEqual(&*i4, &v[p]);
shouldEqual(&*i5, &v[p]);
shouldEqual(&*i6, &v[p]);
shouldEqual(i1.operator->(), &v[p]);
shouldEqual(i2.operator->(), &v[p]);
shouldEqual(*c, p);
shouldEqual(i1.point(), p);
shouldEqual(i2.point(), p);
shouldEqual(i3.point(), p);
shouldEqual(i4.point(), p);
shouldEqual(i5.point(), p);
shouldEqual(i6.point(), p);
shouldEqual(i1.index(), count);
shouldEqual(i2.index(), count);
shouldEqual(i3.index(), count);
shouldEqual(i4.index(), count);
shouldEqual(i5.index(), count);
shouldEqual(i6.index(), count);
should(i1 != iend);
should(!(i1 == iend));
should(i1 < iend);
should(i1 <= iend);
should(!(i1 > iend));
should(!(i1 >= iend));
should(i5.template dim<2>() == p[2]);
should(i5.template dim<1>() == p[1]);
should(i5.template dim<0>() == p[0]);
should(i5.template dim<2>() != s[2]);
should(i5.template dim<1>() != s[1]);
should(i5.template dim<0>() != s[0]);
should(i5.template dim<2>() <= p[2]);
should(i5.template dim<1>() <= p[1]);
should(i5.template dim<0>() <= p[0]);
should(i5.template dim<2>() < s[2]);
should(i5.template dim<1>() < s[1]);
should(i5.template dim<0>() < s[0]);
should(i5.template dim<2>() >= 0);
should(i5.template dim<1>() >= 0);
should(i5.template dim<0>() >= 0);
shouldNot(i5.template dim<2>() > s[2]);
shouldNot(i5.template dim<1>() > s[1]);
shouldNot(i5.template dim<0>() > s[0]);
shouldEqual(iend - i1, v.size() - count);
bool atBorder = p[0] == 0 || p[0] == s[0]-1 || p[1] == 0 || p[1] == s[1]-1 ||
p[2] == 0 || p[2] == s[2]-1;
if(!atBorder)
{
should(!i1.atBorder());
should(!i2.atBorder());
}
else
{
should(i1.atBorder());
should(i2.atBorder());
}
}
}
}
should(c == cend);
should(i1 == iend);
should(!(i1 != iend));
should(!(i1 < iend));
should(i1 <= iend);
should(!(i1 > iend));
should(i1 >= iend);
should(i2 == iend);
should(!(i2 != iend));
should(!(i2 < iend));
should(i2 <= iend);
should(!(i2 > iend));
should(i2 >= iend);
shouldEqual(iend - i1, 0);
shouldEqual(iend - i2, 0);
shouldEqual (count, v.size());
--i1;
i2 -= 1;
shouldEqual(&*i1, &v[Shape3(19,20,21)]);
shouldEqual(&*i2, &v[Shape3(19,20,21)]);
}
void testChunkIterator()
{
Shape3 start(5,0,3), stop(shape[0], shape[1], shape[2]-3);
MultiArrayView <3, T, ChunkedArrayTag> v(array->subarray(Shape3(), shape));
typename Array::chunk_iterator i = array->chunk_begin(start, stop),
end = array->chunk_end(start, stop);
typename MultiArrayView <3, T, ChunkedArrayTag>::chunk_const_iterator
vi = v.chunk_cbegin(start, stop),
vend = v.chunk_cend(start, stop);
int count = -1;
for(; i != end; ++i, ++vi, --count)
{
shouldEqual(i->data(), i[0].data());
shouldEqual(i->data(), vi->data());
*i = T(count);
ref.subarray(i.chunkStart(), i.chunkStop()) = T(count);
should(*vi == ref.subarray(i.chunkStart(), i.chunkStop()));
}
should(vi == vend);
shouldEqualSequence(array->cbegin(), array->cend(), ref.begin());
for(;;)
{
--i;
--vi;
++count;
shouldEqual(i->data(), i[0].data());
shouldEqual(i->data(), vi->data());
shouldEqual((*i)[Shape3()], T(count));
*i = T(fill_value);
if(i.scanOrderIndex() == 0)
break;
}
ref.subarray(start, stop) = T(fill_value);
shouldEqualSequence(array->cbegin(), array->cend(), ref.begin());
}
static void testMultiThreadedRun(BaseArray * v, int startIndex, int d,
threading::atomic_long * go)
{
while(go->load() == 0)
threading::this_thread::yield();
Shape3 s = v->shape();
int sliceSize = s[0]*s[1];
Iterator bi(v->begin());
T count(startIndex*sliceSize), start((d-1)*sliceSize), inc(1);
for(bi.setDim(2,startIndex); bi.coord(2) < s[2]; bi.addDim(2, d), count += start)
for(bi.setDim(1,0); bi.coord(1) < s[1]; bi.incDim(1))
for(bi.setDim(0,0); bi.coord(0) < s[0]; bi.incDim(0), count += inc)
{
*bi = count;
}
}
void testMultiThreaded()
{
array.reset(0); // close the file if backend is HDF5
ArrayPtr a = createArray(Shape3(200, 201, 202), Shape3(), (Array *)0);
threading::atomic_long go;
go.store(0);
threading::thread t1(std::bind(testMultiThreadedRun,a.get(),0,4,&go));
threading::thread t2(std::bind(testMultiThreadedRun,a.get(),1,4,&go));
threading::thread t3(std::bind(testMultiThreadedRun,a.get(),2,4,&go));
threading::thread t4(std::bind(testMultiThreadedRun,a.get(),3,4,&go));
go.store(1);
t4.join();
t3.join();
t2.join();
t1.join();
PlainArray ref(a->shape());
linearSequence(ref.begin(), ref.end());
shouldEqualSequence(a->begin(), a->end(), ref.begin());
}
// void testIsUnstrided()
// {
// typedef difference3_type Shape;
// should(array3.isUnstrided());
// should(array3.isUnstrided(0));
// should(array3.isUnstrided(1));
// should(array3.isUnstrided(2));
// should(array3.bindOuter(0).isUnstrided());
// should(!array3.bindInner(0).isUnstrided());
// should(!array3.bindAt(1, 0).isUnstrided());
// should(array3.bindAt(1, 0).isUnstrided(0));
// should(!array3.subarray(Shape(), array3.shape()-Shape(1)).isUnstrided());
// should(!array3.subarray(Shape(), array3.shape()-Shape(1)).isUnstrided(1));
// should(array3.subarray(Shape(), array3.shape()-Shape(1)).isUnstrided(0));
// should(!array3.subarray(Shape(), array3.shape()-Shape(0,2,2)).isUnstrided());
// should(array3.subarray(Shape(), array3.shape()-Shape(0,2,2)).isUnstrided(1));
// should(array3.subarray(Shape(), array3.shape()-Shape(0,2,2)).isUnstrided(0));
// }
// void testMethods ()
// {
// shouldEqual(array3.squaredNorm(), 332833500);
// shouldEqual(array3.norm(), std::sqrt(332833500.0));
// shouldEqual(array3.norm(0), 999.0);
// shouldEqual(array3.norm(1), 499500.0);
// shouldEqualTolerance(array3.norm(2, false), std::sqrt(332833500.0), 1e-14);
// difference3_type first(0,0,0), last(1,1,1);
// shouldEqual(array3.subarray(first, last).norm(), 0.0);
// shouldEqual(array3.subarray(first, last).norm(0), 0.0);
// shouldEqual(array3.subarray(first, last).norm(1), 0.0);
// shouldEqual(array3.subarray(first, last).norm(2, false), 0.0);
// shouldEqual(array3.squaredNorm(), squaredNorm(array3));
// shouldEqual(array3.norm(), vigra::norm(array3));
// should(array3.any());
// should(!array3.subarray(first, last).any());
// should(!array3.all());
// should(array3.subarray(last, array3.shape()).all());
// shouldEqual(array3.template sum<int>(), 499500);
// shouldEqual(array3.subarray(Shape3(1,1,1),Shape3(3,3,2)).template product<int>(), 183521184);
// Shape3 reducedShape(1, 1, array3.shape(2));
// array3_type reducedSums(reducedShape);
// array3.sum(reducedSums);
// int res = 4950;
// for(int k=0; k<reducedShape[2]; ++k, res += 10000)
// shouldEqual(reducedSums(0,0,k), res);
// scalar_type minimum, maximum;
// array3.minmax(&minimum, &maximum);
// shouldEqual(minimum, 0);
// shouldEqual(maximum, array3.size()-1);
// double mean, variance;
// array3.meanVariance(&mean, &variance);
// shouldEqual(mean, 499.5);
// shouldEqual(variance, 83333.25);
// }
// void test_expandElements()
// {
// using namespace multi_math;
// MultiArray<3, TinyVector<int, 3> > a(Shape3(4,3,2));
// a.init(TinyVector<int, 3>(1,2,3));
// MultiArrayView<4, int, StridedArrayTag> ex = a.expandElements(0);
// MultiArrayView<4, int, StridedArrayTag>::iterator i = ex.begin();
// while(i != ex.end())
// {
// shouldEqual(*i, 1); ++i;
// shouldEqual(*i, 2); ++i;
// shouldEqual(*i, 3); ++i;
// }
// MultiArrayView<4, int, StridedArrayTag> ex2 = a.expandElements(3);
// i = ex2.begin();
// for(int k=0; k < a.size(); ++i, ++k)
// shouldEqual(*i, 1);
// for(int k=0; k < a.size(); ++i, ++k)
// shouldEqual(*i, 2);
// for(int k=0; k < a.size(); ++i, ++k)
// shouldEqual(*i, 3);
// MultiArray<3, bool> b = (a.bindElementChannel(0) == 1);
// should(b.all());
// b = (a.bindElementChannel(1) == 2);
// should(b.all());
// b = (a.bindElementChannel(2) == 3);
// should(b.all());
// }
};
// struct MultiArrayPointoperatorsTest
// {
// typedef float PixelType;
// typedef MultiArray<3,PixelType> Image3D;
// typedef MultiArrayView<3,PixelType> View3D;
// typedef Image3D::difference_type Size3;
// typedef MultiArray<1,PixelType> Image1D;
// typedef Image1D::difference_type Size1;
// Image3D img;
// MultiArrayPointoperatorsTest()
// : img(Size3(5,4,3))
// {
// int i;
// PixelType c = 0.1f;
// for(i=0; i<img.elementCount(); ++i, ++c)
// img.data()[i] = c;
// }
// void testInit()
// {
// Image3D res(img.shape());
// const Image3D::value_type ini = 1.1f;
// should(res.shape() == Size3(5,4,3));
// initMultiArray(destMultiArrayRange(res), ini);
// int x,y,z;
// for(z=0; z<img.shape(2); ++z)
// for(y=0; y<img.shape(1); ++y)
// for(x=0; x<img.shape(0); ++x)
// shouldEqual(res(x,y,z), ini);
// using namespace multi_math;
// should(all(res == ini));
// initMultiArray(res, 2.2f);
// should(all(res == 2.2f));
// res = 3.3f;
// should(all(res == 3.3f));
// res.init(4.4f);
// should(all(res == 4.4f));
// }
// void testCopy()
// {
// Image3D res(img.shape(), 1.0), res1(img.shape(), 1.0);
// copyMultiArray(srcMultiArrayRange(img), destMultiArray(res));
// copyMultiArray(img, res1);
// should(img == res);
// should(img == res1);
// }
// void testCopyOuterExpansion()
// {
// Image3D res(img.shape());
// copyMultiArray(img.subarray(Size3(0,0,0), Size3(5,1,1)), res);
// int x,y,z;
// for(z=0; z<img.shape(2); ++z)
// for(y=0; y<img.shape(1); ++y)
// for(x=0; x<img.shape(0); ++x)
// shouldEqual(res(x,y,z), img(x,0,0));
// }
// void testCopyInnerExpansion()
// {
// Image3D res(img.shape());
// copyMultiArray(img.subarray(Size3(0,0,0), Size3(1,1,3)), res);
// int x,y,z;
// for(z=0; z<img.shape(2); ++z)
// for(y=0; y<img.shape(1); ++y)
// for(x=0; x<img.shape(0); ++x)
// shouldEqual(res(x,y,z), img(0,0,z));
// }
// void testTransform()
// {
// Image3D res(img.shape()), res1(img.shape());
// transformMultiArray(srcMultiArrayRange(img), destMultiArray(res),
// Arg1() + Arg1());
// transformMultiArray(img, res1, Arg1() + Arg1());
// using namespace multi_math;
// should(all(2.0*img == res));
// should(all(2.0*img == res1));
// }
// void testTransformOuterExpand()
// {
// Image3D res(img.shape());
// transformMultiArray(img.subarray(Size3(0,0,0), Size3(5,1,1)), res,
// Arg1() + Arg1());
// int x,y,z;
// for(z=0; z<img.shape(2); ++z)
// for(y=0; y<img.shape(1); ++y)
// for(x=0; x<img.shape(0); ++x)
// shouldEqual(res(x,y,z), 2.0*img(x,0,0));
// }
// void testTransformInnerExpand()
// {
// Image3D res(img.shape());
// transformMultiArray(img.subarray(Size3(0,0,0), Size3(1,1,3)), res,
// Arg1() + Arg1());
// int x,y,z;
// for(z=0; z<img.shape(2); ++z)
// for(y=0; y<img.shape(1); ++y)
// for(x=0; x<img.shape(0); ++x)
// shouldEqual(res(x,y,z), 2.0*img(0,0,z));
// }
// void testTransformOuterReduce()
// {
// Image3D res(Size3(5,1,1));
// transformMultiArray(img, res, reduceFunctor(Arg1() + Arg2(), 0.0));
// int x,y,z;
// for(x=0; x<img.shape(0); ++x)
// {
// double sum = 0.0;
// for(y=0; y<img.shape(1); ++y)
// for(z=0; z<img.shape(2); ++z)
// sum += img(x,y,z);
// shouldEqual(res(x,0,0), sum);
// }
// Image1D res1(Size1(5));
// MultiArrayView<3,PixelType> res3 = res1.insertSingletonDimension(1).insertSingletonDimension(2);
// transformMultiArray(img, res3, FindSum<PixelType>());
// shouldEqualSequenceTolerance(res1.data(), res1.data()+5, res.data(), 1e-7);
// }
// void testTransformInnerReduce()
// {
// Image3D res(Size3(1,1,3));
// transformMultiArray(img, res, reduceFunctor(Arg1() + Arg2(), 0.0));
// int x,y,z;
// for(z=0; z<img.shape(2); ++z)
// {
// double sum = 0.0;
// for(y=0; y<img.shape(1); ++y)
// for(x=0; x<img.shape(0); ++x)
// sum += img(x,y,z);
// shouldEqual(res(0,0,z), sum);
// }
// Image1D res1(Size1(3));
// MultiArrayView<3,PixelType> res3 = res1.insertSingletonDimension(0).insertSingletonDimension(0);
// transformMultiArray(img, res3, FindSum<PixelType>());
// shouldEqualSequenceTolerance(res1.data(), res1.data()+3, res.data(), 1e-6);
// }
// void testCombine2()
// {
// Image3D res(img.shape()), res1(img.shape());
// combineTwoMultiArrays(srcMultiArrayRange(img), srcMultiArray(img),
// destMultiArray(res),
// Arg1() + Arg2());
// combineTwoMultiArrays(img, img, res1, Arg1() + Arg2());
// using namespace multi_math;
// should(all(2.0*img == res));
// should(all(2.0*img == res1));
// }
// void testCombine2OuterExpand()
// {
// Image3D res(img.shape());
// combineTwoMultiArrays(img.subarray(Size3(0,0,0), Size3(5,1,1)), img, res,
// Arg1() + Param(2.0)*Arg2());
// int x,y,z;
// for(z=0; z<img.shape(2); ++z)
// for(y=0; y<img.shape(1); ++y)
// for(x=0; x<img.shape(0); ++x)
// shouldEqual(res(x,y,z), 2.0*img(x,y,z) + img(x,0,0));
// combineTwoMultiArrays(img, img.subarray(Size3(0,0,0), Size3(5,1,1)), res,
// Arg1() + Param(2.0)*Arg2());
// for(z=0; z<img.shape(2); ++z)
// for(y=0; y<img.shape(1); ++y)
// for(x=0; x<img.shape(0); ++x)
// shouldEqual(res(x,y,z), img(x,y,z) + 2.0*img(x,0,0));
// View3D view = img.subarray(Size3(0,0,0), Size3(5,1,1));
// combineTwoMultiArrays(srcMultiArrayRange(view), srcMultiArrayRange(view),
// destMultiArrayRange(res),
// Arg1() + Param(2.0)*Arg2());
// for(z=0; z<img.shape(2); ++z)
// for(y=0; y<img.shape(1); ++y)
// for(x=0; x<img.shape(0); ++x)
// shouldEqual(res(x,y,z), 3.0*img(x,0,0));
// }
// void testCombine2InnerExpand()
// {
// Image3D res(img.shape());
// View3D view = img.subarray(Size3(0,0,0), Size3(1,1,3));
// combineTwoMultiArrays(view, img, res,
// Arg1() + Param(2.0)*Arg2());
// int x,y,z;
// for(z=0; z<img.shape(2); ++z)
// for(y=0; y<img.shape(1); ++y)
// for(x=0; x<img.shape(0); ++x)
// shouldEqual(res(x,y,z), 2.0*img(x,y,z) + img(0,0,z));
// combineTwoMultiArrays(img, view, res,
// Arg1() + Param(2.0)*Arg2());
// for(z=0; z<img.shape(2); ++z)
// for(y=0; y<img.shape(1); ++y)
// for(x=0; x<img.shape(0); ++x)
// shouldEqual(res(x,y,z), img(x,y,z) + 2.0*img(0,0,z));
// combineTwoMultiArrays(srcMultiArrayRange(view), srcMultiArrayRange(view),
// destMultiArrayRange(res),
// Arg1() + Param(2.0)*Arg2());
// for(z=0; z<img.shape(2); ++z)
// for(y=0; y<img.shape(1); ++y)
// for(x=0; x<img.shape(0); ++x)
// shouldEqual(res(x,y,z), 3.0*img(0,0,z));
// }
// void testCombine2OuterReduce()
// {
// Image3D res(Size3(5,1,1));
// combineTwoMultiArrays(img, img, res,
// reduceFunctor(Arg1() + Arg2() + Arg3(), 0.0));
// int x,y,z;
// for(x=0; x<img.shape(0); ++x)
// {
// double sum = 0.0;
// for(y=0; y<img.shape(1); ++y)
// for(z=0; z<img.shape(2); ++z)
// sum += img(x,y,z);
// shouldEqual(res(x,0,0), 2.0*sum);
// }
// }
// void testCombine2InnerReduce()
// {
// Image3D res(Size3(1,1,3));
// combineTwoMultiArrays(img, img, res,
// reduceFunctor(Arg1() + Arg2() + Arg3(), 0.0));
// int x,y,z;
// for(z=0; z<img.shape(2); ++z)
// {
// double sum = 0.0;
// for(y=0; y<img.shape(1); ++y)
// for(x=0; x<img.shape(0); ++x)
// sum += img(x,y,z);
// shouldEqual(res(0,0,z), 2.0*sum);
// }
// }
// void testCombine3()
// {
// Image3D res(img.shape()), res1(img.shape());
// combineThreeMultiArrays(srcMultiArrayRange(img),
// srcMultiArray(img), srcMultiArray(img),
// destMultiArray(res),
// Arg1() + Arg2() + Arg3());
// combineThreeMultiArrays(img, img, img, res1,
// Arg1() + Arg2() + Arg3());
// int x,y,z;
// for(z=0; z<img.shape(2); ++z)
// for(y=0; y<img.shape(1); ++y)
// for(x=0; x<img.shape(0); ++x)
// {
// shouldEqual(res(x,y,z), 3.0*img(x,y,z));
// shouldEqual(res1(x,y,z), 3.0*img(x,y,z));
// }
// }
// void testInitMultiArrayBorder(){
// typedef vigra::MultiArray<1,int> IntLine;
// typedef vigra::MultiArray<2,int> IntImage;
// typedef vigra::MultiArray<3,int> IntVolume;
// const int desired_vol[] ={ 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 5, 5, 0, 0,
// 0, 0, 5, 5, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 5, 5, 0, 0,
// 0, 0, 5, 5, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0};
// const int desired_img[] ={ 0, 0, 0, 0, 0, 0,
// 0, 5, 5, 5, 5, 0,
// 0, 5, 5, 5, 5, 0,
// 0, 5, 5, 5, 5, 0,
// 0, 5, 5, 5, 5, 0,
// 0, 0, 0, 0, 0, 0};
// const int desired_lin[] ={ 0, 0, 0, 5, 0, 0, 0 };
// const int desired_vol2[] ={ 0, 0,
// 0, 0,
// 0, 0,
// 0, 0};
// IntVolume vol(IntVolume::difference_type(6,6,6));
// for(IntVolume::iterator iter=vol.begin(); iter!=vol.end(); ++iter)
// *iter=5;
// initMultiArrayBorder(destMultiArrayRange(vol),2,0);
// shouldEqualSequence(vol.begin(), vol.end(), desired_vol);
// IntImage img(IntImage::difference_type(6,6));
// for(IntImage::iterator iter=img.begin(); iter!=img.end(); ++iter)
// *iter=5;
// initMultiArrayBorder(destMultiArrayRange(img),1,0);
// shouldEqualSequence(img.begin(), img.end(), desired_img);
// IntLine lin(IntLine::difference_type(7));
// for(IntLine::iterator iter=lin.begin(); iter!=lin.end(); ++iter)
// *iter=5;
// initMultiArrayBorder(destMultiArrayRange(lin),3,0);
// shouldEqualSequence(lin.begin(), lin.end(), desired_lin);
// IntVolume vol2(IntVolume::difference_type(2,2,2));
// for(IntVolume::iterator iter=vol2.begin(); iter!=vol2.end(); ++iter)
// *iter=5;
// initMultiArrayBorder(vol2, 9, 0);
// shouldEqualSequence(vol2.begin(), vol2.end(), desired_vol2);
// }
// void testInspect()
// {
// vigra::FindMinMax<PixelType> minmax;
// inspectMultiArray(img, minmax);
// shouldEqual(minmax.count, img.size());
// shouldEqual(minmax.min, 0.1f);
// shouldEqual(minmax.max, 59.1f);
// vigra::MultiArray<3, unsigned char> labels(img.shape());
// labels.subarray(Shape3(1,0,0), img.shape()-Shape3(1,0,0)) = 1;
// vigra::ArrayOfRegionStatistics<vigra::FindMinMax<PixelType> > stats(1);
// inspectTwoMultiArrays(img, labels, stats);
// shouldEqual(stats[0].count, 24);
// shouldEqual(stats[0].min, 0.1f);
// shouldEqual(stats[0].max, 59.1f);
// shouldEqual(stats[1].count, 36);
// shouldEqual(stats[1].min, 1.1f);
// shouldEqual(stats[1].max, 58.1f);
// }
// void testTensorUtilities()
// {
// MultiArrayShape<2>::type shape(3,4);
// int size = shape[0]*shape[1];
// MultiArray<2, TinyVector<double, 2> > vector(shape), rvector(shape);
// MultiArray<2, TinyVector<double, 3> > tensor1(shape), tensor2(shape), rtensor(shape);
// MultiArray<2, double > trace(shape), rtrace(shape);
// MultiArray<2, double > determinant(shape), rdet(shape);
// for(int k=0; k<size; ++k)
// {
// for(int l=0; l<2; ++l)
// vector[k][l] = randomMT19937().uniform();
// for(int l=0; l<3; ++l)
// tensor1[k][l] = randomMT19937().uniform();
// rdet[k] = tensor1[k][0]*tensor1[k][2] - sq(tensor1[k][1]);
// }
// vectorToTensor(srcImageRange(vector), destImage(rtensor));
// vectorToTensorMultiArray(srcMultiArrayRange(vector), destMultiArray(tensor2));
// shouldEqualSequence(tensor2.data(), tensor2.data()+size, rtensor.data());
// tensor2.init(TinyVector<double, 3>());
// vectorToTensorMultiArray(vector, tensor2);
// shouldEqualSequence(tensor2.data(), tensor2.data()+size, rtensor.data());
// tensorTrace(srcImageRange(tensor1), destImage(rtrace));
// tensorTraceMultiArray(srcMultiArrayRange(tensor1), destMultiArray(trace));
// shouldEqualSequence(trace.data(), trace.data()+size, rtrace.data());
// trace = 0;
// tensorTraceMultiArray(tensor1, trace);
// shouldEqualSequence(trace.data(), trace.data()+size, rtrace.data());
// tensorDeterminantMultiArray(srcMultiArrayRange(tensor1), destMultiArray(determinant));
// shouldEqualSequence(determinant.data(), determinant.data()+size, rdet.data());
// determinant = 0;
// tensorDeterminantMultiArray(tensor1, determinant);
// shouldEqualSequence(determinant.data(), determinant.data()+size, rdet.data());
// determinant = 1000.0;
// tensorDeterminantMultiArray(srcMultiArrayRange(tensor2), destMultiArray(determinant));
// shouldEqualTolerance(norm(determinant), 0.0, 1e-14);
// tensorEigenRepresentation(srcImageRange(tensor1), destImage(rtensor));
// tensorEigenvaluesMultiArray(srcMultiArrayRange(tensor1), destMultiArray(vector));
// shouldEqualSequenceTolerance(vector.begin(), vector.end(), rtensor.begin(), (TinyVector<double, 2>(1e-14)));
// vector = TinyVector<double, 2>();
// tensorEigenvaluesMultiArray(tensor1, vector);
// shouldEqualSequenceTolerance(vector.begin(), vector.end(), rtensor.begin(), (TinyVector<double, 2>(1e-14)));
// }
// };
template <class Array>
class ChunkedMultiArraySpeedTest
{
public:
typedef typename Array::value_type T;
typedef ChunkedArray<3, T> BaseArray;
typedef VIGRA_UNIQUE_PTR<BaseArray> ArrayPtr;
typedef typename BaseArray::iterator Iterator;
Shape3 shape;
ArrayPtr array;
ChunkedMultiArraySpeedTest ()
: shape(200, 201, 202)
{
array = createArray(shape, (Array *)0);
linearSequence(array->begin(), array->end());
std::cerr << "chunked multi array test for type " << typeid(Array).name() << ": \n";
}
static ArrayPtr createArray(Shape3 const & shape,
ChunkedArrayFull<3, T> *)
{
return ArrayPtr(new ChunkedArrayFull<3, T>(shape));
}
static ArrayPtr createArray(Shape3 const & shape,
ChunkedArrayLazy<3, T> *)
{
return ArrayPtr(new ChunkedArrayLazy<3, T>(shape));
}
static ArrayPtr createArray(Shape3 const & shape,
ChunkedArrayCompressed<3, T> *)
{
return ArrayPtr(new ChunkedArrayCompressed<3, T>(shape));
}
#ifdef HasHDF5
static ArrayPtr createArray(Shape3 const & shape,
ChunkedArrayHDF5<3, T> *)
{
HDF5File hdf5_file("chunked_test.h5", HDF5File::New);
return ArrayPtr(new ChunkedArrayHDF5<3, T>(hdf5_file, "test", HDF5File::New,
shape, Shape3(),
ChunkedArrayOptions().compression(NO_COMPRESSION)));
}
#endif
static ArrayPtr createArray(Shape3 const & shape,
ChunkedArrayTmpFile<3, T> *)
{
return ArrayPtr(new ChunkedArrayTmpFile<3, T>(shape));
}
void testBaselineSpeed()
{
std::cerr << "############ chunked iterator speed #############\n";
ChunkedArrayFull<3, T> a(shape);
linearSequence(a.begin(), a.end());
typename ChunkedArrayFull<3, T>::iterator i = a.begin(),
end = a.end();
USETICTOC;
T count = 0;
TIC;
for(; i != end; ++i, ++count)
if(count != *i)
{
shouldEqual(*i, count);
}
std::string t = TOCS;
std::cerr << " baseline: " << t << "\n";
}
void testIteratorSpeed()
{
Iterator i = array->begin(),
end = array->end();
USETICTOC;
T count = 0;
TIC;
for(; i != end; ++i, ++count)
{
if(count != *i)
{
shouldEqual(*i, count);
}
}
std::string t = TOCS;
std::cerr << " read time: " << t << " (cache: " << array->cacheSize() << ")\n";
}
void testNestedLoopSpeed()
{
Iterator i = array->begin(),
end = array->end();
USETICTOC;
T count = 0;
TIC;
for(i.setDim(2,0); i.coord(2) < shape[2]; i.incDim(2))
for(i.setDim(1,0); i.coord(1) < shape[1]; i.incDim(1))
for(i.setDim(0,0); i.coord(0) < shape[0]; i.incDim(0), ++count)
{
if(count != *i)
{
shouldEqual(*i, count);
}
}
std::string t = TOCS;
std::cerr << " loop time: " << t << " (cache: " << array->cacheSize() << ")\n";
}
void testIteratorSpeed_LargeCache()
{
array.reset(0);
array = createArray(shape, (Array *)0);
array->setCacheMaxSize(prod(array->chunkArrayShape()));
linearSequence(array->begin(), array->end());
testIteratorSpeed();
}
void testIndexingBaselineSpeed()
{
std::cerr << "################## indexing speed ####################\n";
ChunkedArrayFull<3, T> a(shape);
linearSequence(a.begin(), a.end());
MultiCoordinateIterator<3> i(shape),
end = i.getEndIterator();
USETICTOC;
T count = 0;
TIC;
for(; i != end; ++i, ++count)
if(count != a[*i])
{
shouldEqual(a[*i], count);
}
std::string t = TOCS;
std::cerr << " baseline: " << t << "\n";
}
void testIndexingSpeed()
{
MultiArrayView<3, T, ChunkedArrayTag> sub(array->subarray(Shape3(), shape));
MultiCoordinateIterator<3> i(shape),
end = i.getEndIterator();
USETICTOC;
T count = 0;
TIC;
for(; i != end; ++i, ++count)
{
if(count != sub[*i])
{
shouldEqual(sub[*i], count);
}
}
std::string t = TOCS;
std::cerr << " indexing: " << t << " (cache: " << array->cacheSize() << ")\n";
}
};
struct ChunkedMultiArrayTestSuite
: public vigra::test_suite
{
template <class Array>
void testImpl()
{
add( testCase( &ChunkedMultiArrayTest<Array>::test_construction ) );
add( testCase( &ChunkedMultiArrayTest<Array>::test_assignment ) );
add( testCase( &ChunkedMultiArrayTest<Array>::test_bindAt ) );
add( testCase( &ChunkedMultiArrayTest<Array>::test_bindInner ) );
add( testCase( &ChunkedMultiArrayTest<Array>::test_bindOuter ) );
add( testCase( &ChunkedMultiArrayTest<Array>::test_subarray ) );
add( testCase( &ChunkedMultiArrayTest<Array>::test_iterator ) );
add( testCase( &ChunkedMultiArrayTest<Array>::testChunkIterator ) );
add( testCase( &ChunkedMultiArrayTest<Array>::testMultiThreaded ) );
}
template <class T>
void testSpeedImpl()
{
add( testCase( (&ChunkedMultiArraySpeedTest<ChunkedArrayFull<3, T> >::testBaselineSpeed )));
add( testCase( (&ChunkedMultiArraySpeedTest<ChunkedArrayFull<3, T> >::testIteratorSpeed )));
add( testCase( (&ChunkedMultiArraySpeedTest<ChunkedArrayLazy<3, T> >::testNestedLoopSpeed )));
add( testCase( (&ChunkedMultiArraySpeedTest<ChunkedArrayLazy<3, T> >::testIteratorSpeed )));
add( testCase( (&ChunkedMultiArraySpeedTest<ChunkedArrayCompressed<3, T> >::testIteratorSpeed )));
add( testCase( (&ChunkedMultiArraySpeedTest<ChunkedArrayTmpFile<3, T> >::testIteratorSpeed )));
add( testCase( (&ChunkedMultiArraySpeedTest<ChunkedArrayTmpFile<3, T> >::testIteratorSpeed_LargeCache )));
#ifdef HasHDF5
add( testCase( (&ChunkedMultiArraySpeedTest<ChunkedArrayHDF5<3, T> >::testIteratorSpeed )));
add( testCase( (&ChunkedMultiArraySpeedTest<ChunkedArrayHDF5<3, T> >::testIteratorSpeed_LargeCache )));
#endif
}
template <class T>
void testIndexingSpeedImpl()
{
add( testCase( (&ChunkedMultiArraySpeedTest<ChunkedArrayFull<3, T> >::testIndexingBaselineSpeed )));
add( testCase( (&ChunkedMultiArraySpeedTest<ChunkedArrayFull<3, T> >::testIndexingSpeed )));
add( testCase( (&ChunkedMultiArraySpeedTest<ChunkedArrayLazy<3, T> >::testIndexingSpeed )));
add( testCase( (&ChunkedMultiArraySpeedTest<ChunkedArrayCompressed<3, T> >::testIndexingSpeed )));
add( testCase( (&ChunkedMultiArraySpeedTest<ChunkedArrayTmpFile<3, T> >::testIndexingSpeed )));
#ifdef HasHDF5
add( testCase( (&ChunkedMultiArraySpeedTest<ChunkedArrayHDF5<3, T> >::testIndexingSpeed )));
#endif
}
ChunkedMultiArrayTestSuite()
: vigra::test_suite("ChunkedMultiArrayTestSuite")
{
testImpl<ChunkedArrayFull<3, float> >();
testImpl<ChunkedArrayLazy<3, float> >();
testImpl<ChunkedArrayCompressed<3, float> >();
testImpl<ChunkedArrayTmpFile<3, float> >();
#ifdef HasHDF5
testImpl<ChunkedArrayHDF5<3, float> >();
#endif
testImpl<ChunkedArrayFull<3, TinyVector<float, 3> > >();
testImpl<ChunkedArrayLazy<3, TinyVector<float, 3> > >();
testImpl<ChunkedArrayCompressed<3, TinyVector<float, 3> > >();
testImpl<ChunkedArrayTmpFile<3, TinyVector<float, 3> > >();
#ifdef HasHDF5
testImpl<ChunkedArrayHDF5<3, TinyVector<float, 3> > >();
#endif
testSpeedImpl<unsigned char>();
testSpeedImpl<float>();
testSpeedImpl<double>();
testIndexingSpeedImpl<unsigned char>();
testIndexingSpeedImpl<float>();
testIndexingSpeedImpl<double>();
//add( testCase( &MultiArrayPointoperatorsTest::testInit ) );
//add( testCase( &MultiArrayPointoperatorsTest::testCopy ) );
//add( testCase( &MultiArrayPointoperatorsTest::testCopyOuterExpansion ) );
//add( testCase( &MultiArrayPointoperatorsTest::testCopyInnerExpansion ) );
//add( testCase( &MultiArrayPointoperatorsTest::testTransform ) );
//add( testCase( &MultiArrayPointoperatorsTest::testTransformOuterExpand ) );
//add( testCase( &MultiArrayPointoperatorsTest::testTransformInnerExpand ) );
//add( testCase( &MultiArrayPointoperatorsTest::testTransformOuterReduce ) );
//add( testCase( &MultiArrayPointoperatorsTest::testTransformInnerReduce ) );
//add( testCase( &MultiArrayPointoperatorsTest::testCombine2 ) );
//add( testCase( &MultiArrayPointoperatorsTest::testCombine2OuterExpand ) );
//add( testCase( &MultiArrayPointoperatorsTest::testCombine2InnerExpand ) );
//add( testCase( &MultiArrayPointoperatorsTest::testCombine2OuterReduce ) );
//add( testCase( &MultiArrayPointoperatorsTest::testCombine2InnerReduce ) );
//add( testCase( &MultiArrayPointoperatorsTest::testCombine3 ) );
//add( testCase( &MultiArrayPointoperatorsTest::testInitMultiArrayBorder ) );
//add( testCase( &MultiArrayPointoperatorsTest::testInspect ) );
//add( testCase( &MultiArrayPointoperatorsTest::testTensorUtilities ) );
}
};
int main(int argc, char ** argv)
{
int failed = 0;
ChunkedMultiArrayTestSuite test0;
failed += test0.run(vigra::testsToBeExecuted(argc, argv));
std::cout << test0.report() << std::endl;
return (failed != 0);
}
| 39.066584 | 142 | 0.503503 | [
"shape",
"vector"
] |
755dc6d6bafc8c8dc06795706dc0a0c3e6e65693 | 639 | hpp | C++ | WorkerProcess.hpp | arylee/psmon | ef10dee8e498f7d072c1975ad67228dc952c26d6 | [
"BSD-3-Clause"
] | 2 | 2020-11-06T08:44:20.000Z | 2021-02-06T14:03:18.000Z | WorkerProcess.hpp | arylee/psmon | ef10dee8e498f7d072c1975ad67228dc952c26d6 | [
"BSD-3-Clause"
] | null | null | null | WorkerProcess.hpp | arylee/psmon | ef10dee8e498f7d072c1975ad67228dc952c26d6 | [
"BSD-3-Clause"
] | null | null | null | /*
NAME
WorkerProcess.hpp - Header file of the Worker Process class.
DESCRIPTION
Worker Process.
*/
#ifndef __WORKER_PROCESS_HPP__
#define __WORKER_PROCESS_HPP__
#include <string>
#include <vector>
class WorkerProcess {
public:
WorkerProcess();
WorkerProcess(std::string name, std::string command, std::string work_dir);
~WorkerProcess();
bool launch();
void relaunch(int old_pid);
pid_t get_pid();
void set_pid(pid_t pid);
private:
int _length;
pid_t _pid;
std::string _name;
std::string _command;
std::string _work_dir;
std::vector<std::string> _tokens;
};
#endif
| 18.794118 | 79 | 0.682316 | [
"vector"
] |
7563a685b0e040cf9baa4641456d09b9416ec095 | 115,412 | cc | C++ | Utilities/src/imgUtils.cc | abhineet123/MTF | 6cb45c88d924fb2659696c3375bd25c683802621 | [
"BSD-3-Clause"
] | 100 | 2016-12-11T00:34:06.000Z | 2022-01-27T23:03:40.000Z | Utilities/src/imgUtils.cc | siqiyan/MTF | 9a76388c907755448bb7223420fe74349130f636 | [
"BSD-3-Clause"
] | 21 | 2017-09-04T06:27:13.000Z | 2021-07-14T19:07:23.000Z | Utilities/src/imgUtils.cc | siqiyan/MTF | 9a76388c907755448bb7223420fe74349130f636 | [
"BSD-3-Clause"
] | 21 | 2017-02-19T02:12:11.000Z | 2020-09-23T03:47:55.000Z | #include "mtf/Utilities/imgUtils.h"
#include "mtf/Utilities/miscUtils.h"
#include "mtf/Utilities/warpUtils.h"
#include "opencv2/highgui/highgui.hpp"
#include<opencv2/imgproc/imgproc.hpp>
#ifdef USE_TBB
#include "tbb/tbb.h"
#endif
_MTF_BEGIN_NAMESPACE
namespace utils{
const char* toString(InterpType interp_type){
switch(interp_type){
case InterpType::Nearest:
return "Nearest";
case InterpType::Linear:
return "Linear";
case InterpType::Cubic:
return "Cubic";
case InterpType::Cubic2:
return "Cubic2";
case InterpType::CubicBSpl:
return "CubicBSpl";
default:
throw InvalidArgument("Invalid interpolation type provided");
}
}
const char* toString(BorderType border_type){
switch(border_type){
case BorderType::Constant:
return "Constant";
case BorderType::Replicate:
return "Replicate";
default:
throw InvalidArgument("Invalid border type provided");
}
}
const char* typeToString(int img_type){
switch(img_type){
case CV_8UC1: return "CV_8UC1";
case CV_8UC2: return "CV_8UC2";
case CV_8UC3: return "CV_8UC3";
case CV_8UC4: return "CV_8UC4";
case CV_8SC1: return "CV_8SC1";
case CV_8SC2: return "CV_8SC2";
case CV_8SC3: return "CV_8SC3";
case CV_8SC4: return "CV_8SC4";
case CV_16UC1: return "CV_16UC1";
case CV_16UC2: return "CV_16UC2";
case CV_16UC3: return "CV_16UC3";
case CV_16UC4: return "CV_16UC4";
case CV_16SC1: return "CV_16SC1";
case CV_16SC2: return "CV_16SC2";
case CV_16SC3: return "CV_16SC3";
case CV_16SC4: return "CV_16SC4";
case CV_32SC1: return "CV_32SC1";
case CV_32SC2: return "CV_32SC2";
case CV_32SC3: return "CV_32SC3";
case CV_32SC4: return "CV_32SC4";
case CV_32FC1: return "CV_32FC1";
case CV_32FC2: return "CV_32FC2";
case CV_32FC3: return "CV_32FC3";
case CV_32FC4: return "CV_32FC4";
case CV_64FC1: return "CV_64FC1";
case CV_64FC2: return "CV_64FC2";
case CV_64FC3: return "CV_64FC3";
case CV_64FC4: return "CV_64FC4";
default:
throw InvalidArgument(
cv_format("typeToString::Invalid image type provided: %d", img_type)
);
}
}
// using cubic BSpline interpolation
inline double cubicBSplInterpolate(double p0, double p1, double p2, double p3, double dx) {
double dx2 = dx*dx;
double dx3 = dx2*dx;
double dxi = 1 - dx;
double dxi2 = dxi*dxi;
double dxi3 = dxi2*dxi;
return (p0*dxi3 + p1*(4 - 6 * dx2 + 3 * dx3) + p2*(4 - 6 * dxi2 + 3 * dxi3) + p3*dx3) / 6;
}
template<>
inline double getPixVal<InterpType::CubicBSpl, BorderType::Constant>(
const EigImgT &img, double x, double y,
unsigned int h, unsigned int w, double overflow_val){
assert(img.rows() == h && img.cols() == w);
//printf("----------Cubic BSpline Interpolation------------\n\n");
if(checkOverflow(x, y, h, w)){
return overflow_val;
}
int x1 = static_cast<int>(x);
int y1 = static_cast<int>(y);
Matrix4d neigh_pix_grid;
if(!getNeighboringPixGrid(neigh_pix_grid, img, x1, y1, h, w))
return overflow_val;
double dx = x - x1;
double dy = y - y1;
Vector4d col_interp_pix;
col_interp_pix(0) = cubicBSplInterpolate(neigh_pix_grid.row(0), dy);
col_interp_pix(1) = cubicBSplInterpolate(neigh_pix_grid.row(1), dy);
col_interp_pix(2) = cubicBSplInterpolate(neigh_pix_grid.row(2), dy);
col_interp_pix(3) = cubicBSplInterpolate(neigh_pix_grid.row(3), dy);
return cubicBSplInterpolate(col_interp_pix, dx);
}
// using bicubic interpolation
inline double cubicInterpolate(double p0, double p1, double p2, double p3, double x) {
return p1 + 0.5 * x*(p2 - p0 + x*(2.0*p0 - 5.0*p1 + 4.0*p2 - p3 + x*(3.0*(p1 - p2) + p3 - p0)));
}
template<>
inline double getPixVal<InterpType::Cubic, BorderType::Constant>(
const EigImgT &img, double x, double y,
unsigned int h, unsigned int w, double overflow_val){
assert(img.rows() == h && img.cols() == w);
//printf("----------Bicubic Interpolation------------\n\n");
if(checkOverflow(x, y, h, w)){
return overflow_val;
}
Matrix4d neigh_pix_grid;
if(!getNeighboringPixGrid(neigh_pix_grid, img, x, y, h, w))
return overflow_val;
double dx = x - static_cast<int>(x);
double dy = y - static_cast<int>(y);
Vector4d col_interp_pix;
col_interp_pix(0) = cubicInterpolate(neigh_pix_grid.row(0), dy);
col_interp_pix(1) = cubicInterpolate(neigh_pix_grid.row(1), dy);
col_interp_pix(2) = cubicInterpolate(neigh_pix_grid.row(2), dy);
col_interp_pix(3) = cubicInterpolate(neigh_pix_grid.row(3), dy);
return cubicInterpolate(col_interp_pix, dx);
}
template<>
inline double getPixVal<InterpType::Cubic2, BorderType::Constant>(
const EigImgT &img, double x, double y,
unsigned int h, unsigned int w, double overflow_val){
assert(img.rows() == h && img.cols() == w);
//printf("----------Bi cubic Interpolation using coefficients------------\n\n");
Matrix4d neigh_pix_grid, bicubic_coeff;
if(!getNeighboringPixGrid(neigh_pix_grid, img, x, y, h, w))
return overflow_val;
getBiCubicCoefficients(bicubic_coeff, neigh_pix_grid);
double dx = x - static_cast<int>(x);
double dy = y - static_cast<int>(y);
return biCubic(bicubic_coeff, dx, dy);
}
#ifdef USE_TBB
#include "imgUtils_tbb.cc"
#else
template<typename PtsT>
void getPixVals(VectorXd &pix_vals,
const EigImgT &img, const PtsT &pts, unsigned int n_pix, unsigned int h, unsigned int w,
double norm_mult, double norm_add){
//printf("n_pix: %d\t pix_vals.size(): %l\t pts.cols(): %l", n_pix, pix_vals.size(), pts.cols());
assert(pix_vals.size() == n_pix && pts.cols() == n_pix);
for(unsigned int i = 0; i < n_pix; i++){
pix_vals(i) = norm_mult * getPixVal<PIX_INTERP_TYPE, PIX_BORDER_TYPE>(img, pts(0, i), pts(1, i), h, w) + norm_add;
}
}
/****************************************************************/
/******************** Gradient of Warped Image********************/
/****************************************************************/
void getWarpedImgGrad(PixGradT &warped_img_grad,
const EigImgT &img, const Matrix8Xd &warped_offset_pts,
double grad_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor){
assert(warped_img_grad.rows() == n_pix);
double grad_mult_factor = pix_mult_factor / (2 * grad_eps);
double pix_val_inc, pix_val_dec;
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
pix_val_inc = getPixVal<GRAD_INTERP_TYPE, PIX_BORDER_TYPE>(img, warped_offset_pts(0, pix_id),
warped_offset_pts(1, pix_id), h, w);
pix_val_dec = getPixVal<GRAD_INTERP_TYPE, PIX_BORDER_TYPE>(img, warped_offset_pts(2, pix_id),
warped_offset_pts(3, pix_id), h, w);
warped_img_grad(pix_id, 0) = (pix_val_inc - pix_val_dec)*grad_mult_factor;
pix_val_inc = getPixVal<GRAD_INTERP_TYPE, PIX_BORDER_TYPE>(img, warped_offset_pts(4, pix_id),
warped_offset_pts(5, pix_id), h, w);
pix_val_dec = getPixVal<GRAD_INTERP_TYPE, PIX_BORDER_TYPE>(img, warped_offset_pts(6, pix_id),
warped_offset_pts(7, pix_id), h, w);
warped_img_grad(pix_id, 1) = (pix_val_inc - pix_val_dec)*grad_mult_factor;
}
//utils::printMatrixToFile(warped_img_grad, "warped_img_grad", "log/mtf_log.txt", "%15.9f", "a");
}
// mapped version
template<InterpType mapping_type>
void getWarpedImgGrad(PixGradT &warped_img_grad,
const EigImgT &img, const VectorXd &intensity_map,
const Matrix8Xd &warped_offset_pts, double grad_eps,
unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor){
assert(warped_img_grad.rows() == n_pix);
double grad_mult_factor = pix_mult_factor / (2 * grad_eps);
double pix_val_inc, pix_val_dec;
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
pix_val_inc = mapPixVal<mapping_type>(getPixVal<GRAD_INTERP_TYPE, PIX_BORDER_TYPE>(img,
warped_offset_pts(0, pix_id), warped_offset_pts(1, pix_id), h, w), intensity_map);
pix_val_dec = mapPixVal<mapping_type>(getPixVal<GRAD_INTERP_TYPE, PIX_BORDER_TYPE>(img,
warped_offset_pts(2, pix_id), warped_offset_pts(3, pix_id), h, w), intensity_map);
warped_img_grad(pix_id, 0) = (pix_val_inc - pix_val_dec)*grad_mult_factor;
pix_val_inc = mapPixVal<mapping_type>(getPixVal<GRAD_INTERP_TYPE, PIX_BORDER_TYPE>(img,
warped_offset_pts(4, pix_id), warped_offset_pts(5, pix_id), h, w), intensity_map);
pix_val_dec = mapPixVal<mapping_type>(getPixVal<GRAD_INTERP_TYPE, PIX_BORDER_TYPE>(img,
warped_offset_pts(6, pix_id), warped_offset_pts(7, pix_id), h, w), intensity_map);
warped_img_grad(pix_id, 1) = (pix_val_inc - pix_val_dec)*grad_mult_factor;
}
}
/***************************************************************/
/******************** Warp of Image Gradient********************/
/***************************************************************/
void getImgGrad(PixGradT &img_grad,
const EigImgT &img, const PtsT &pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w,
double pix_mult_factor){
assert(img_grad.rows() == n_pix && pts.cols() == n_pix);
double grad_mult_factor = pix_mult_factor / (2 * grad_eps);
double pix_val_inc, pix_val_dec;
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double curr_x = pts(0, pix_id), curr_y = pts(1, pix_id);
pix_val_inc = getPixVal<GRAD_INTERP_TYPE, PIX_BORDER_TYPE>(img, curr_x + grad_eps, curr_y, h, w);
pix_val_dec = getPixVal<GRAD_INTERP_TYPE, PIX_BORDER_TYPE>(img, curr_x - grad_eps, curr_y, h, w);
img_grad(pix_id, 0) = (pix_val_inc - pix_val_dec)*grad_mult_factor;
pix_val_inc = getPixVal<GRAD_INTERP_TYPE, PIX_BORDER_TYPE>(img, curr_x, curr_y + grad_eps, h, w);
pix_val_dec = getPixVal<GRAD_INTERP_TYPE, PIX_BORDER_TYPE>(img, curr_x, curr_y - grad_eps, h, w);
img_grad(pix_id, 1) = (pix_val_inc - pix_val_dec)*grad_mult_factor;
}
}
/***************************************************************/
/******************** Hessian of Warped Image ******************/
/***************************************************************/
void getWarpedImgHess(PixHessT &warped_img_hess,
const EigImgT &img, const PtsT &warped_pts,
const HessPtsT &warped_offset_pts, double hess_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor){
assert(warped_img_hess.cols() == n_pix && warped_pts.cols() == n_pix);
double hess_eps2 = 2 * hess_eps;
double hess_mult_factor = pix_mult_factor / (hess_eps2 * hess_eps2);
double pix_val_inc, pix_val_dec, pix_val_inc2, pix_val_dec2;
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double pix_val = getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, warped_pts(0, pix_id), warped_pts(1, pix_id), h, w);
pix_val_inc = getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, warped_offset_pts(0, pix_id), warped_offset_pts(1, pix_id), h, w);
pix_val_dec = getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, warped_offset_pts(2, pix_id), warped_offset_pts(3, pix_id), h, w);
warped_img_hess(0, pix_id) = (pix_val_inc + pix_val_dec - 2 * pix_val)*hess_mult_factor;
pix_val_inc = getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, warped_offset_pts(4, pix_id), warped_offset_pts(5, pix_id), h, w);
pix_val_dec = getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, warped_offset_pts(6, pix_id), warped_offset_pts(7, pix_id), h, w);
warped_img_hess(3, pix_id) = (pix_val_inc + pix_val_dec - 2 * pix_val)*hess_mult_factor;
pix_val_inc = getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, warped_offset_pts(8, pix_id), warped_offset_pts(9, pix_id), h, w);
pix_val_dec = getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, warped_offset_pts(10, pix_id), warped_offset_pts(11, pix_id), h, w);
pix_val_inc2 = getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, warped_offset_pts(12, pix_id), warped_offset_pts(13, pix_id), h, w);
pix_val_dec2 = getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, warped_offset_pts(14, pix_id), warped_offset_pts(15, pix_id), h, w);
warped_img_hess(1, pix_id) = warped_img_hess(2, pix_id) = ((pix_val_inc + pix_val_dec) - (pix_val_inc2 + pix_val_dec2)) * hess_mult_factor;
}
}
// mapped version
template<InterpType mapping_type>
void getWarpedImgHess(PixHessT &warped_img_hess,
const EigImgT &img, const VectorXd &intensity_map,
const PtsT &warped_pts, const HessPtsT &warped_offset_pts,
double hess_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor){
assert(warped_img_hess.cols() == n_pix && warped_pts.cols() == n_pix);
double hess_eps2 = 2 * hess_eps;
double hess_mult_factor = pix_mult_factor / (hess_eps2 * hess_eps2);
double pix_val_inc, pix_val_dec, pix_val_inc2, pix_val_dec2;
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double pix_val = mapPixVal<mapping_type>(getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, warped_pts(0, pix_id),
warped_pts(1, pix_id), h, w), intensity_map);
pix_val_inc = mapPixVal<mapping_type>(getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, warped_offset_pts(0, pix_id),
warped_offset_pts(1, pix_id), h, w), intensity_map);
pix_val_dec = mapPixVal<mapping_type>(getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, warped_offset_pts(2, pix_id),
warped_offset_pts(3, pix_id), h, w), intensity_map);
warped_img_hess(0, pix_id) = (pix_val_inc + pix_val_dec - 2 * pix_val)*hess_mult_factor;
pix_val_inc = mapPixVal<mapping_type>(getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, warped_offset_pts(4, pix_id),
warped_offset_pts(5, pix_id), h, w), intensity_map);
pix_val_dec = mapPixVal<mapping_type>(getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, warped_offset_pts(6, pix_id),
warped_offset_pts(7, pix_id), h, w), intensity_map);
warped_img_hess(3, pix_id) = (pix_val_inc + pix_val_dec - 2 * pix_val)*hess_mult_factor;
pix_val_inc = mapPixVal<mapping_type>(getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, warped_offset_pts(8, pix_id),
warped_offset_pts(9, pix_id), h, w), intensity_map);
pix_val_dec = mapPixVal<mapping_type>(getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, warped_offset_pts(10, pix_id),
warped_offset_pts(11, pix_id), h, w), intensity_map);
pix_val_inc2 = mapPixVal<mapping_type>(getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, warped_offset_pts(12, pix_id),
warped_offset_pts(13, pix_id), h, w), intensity_map);
pix_val_dec2 = mapPixVal<mapping_type>(getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, warped_offset_pts(14, pix_id),
warped_offset_pts(15, pix_id), h, w), intensity_map);
warped_img_hess(1, pix_id) = warped_img_hess(2, pix_id) = ((pix_val_inc + pix_val_dec) - (pix_val_inc2 + pix_val_dec2)) * hess_mult_factor;
}
}
/***************************************************************/
/******************** Warp of Image Hessian********************/
/***************************************************************/
void getImgHess(PixHessT &img_hess, const EigImgT &img,
const PtsT &pts, double hess_eps,
unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor){
assert(img_hess.cols() == n_pix && pts.cols() == n_pix);
double hess_eps2 = 2 * hess_eps;
double hess_mult_factor = pix_mult_factor / (hess_eps2 * hess_eps2);
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double curr_x = pts(0, pix_id), curr_y = pts(1, pix_id);
double curr_pix_val = getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, curr_x, curr_y, h, w);
double ix_pix_val = getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, curr_x + hess_eps2, curr_y, h, w);
double dx_pix_val = getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, curr_x - hess_eps2, curr_y, h, w);
img_hess(0, pix_id) = (ix_pix_val + dx_pix_val - 2 * curr_pix_val) * hess_mult_factor;
double iy_pix_val = getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, curr_x, curr_y + hess_eps2, h, w);
double dy_pix_val = getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, curr_x, curr_y - hess_eps2, h, w);
img_hess(3, pix_id) = (iy_pix_val + dy_pix_val - 2 * curr_pix_val) * hess_mult_factor;
double inc_x = curr_x + hess_eps, dec_x = curr_x - hess_eps;
double inc_y = curr_y + hess_eps, dec_y = curr_y - hess_eps;
double ixiy_pix_val = getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, inc_x, inc_y, h, w);
double dxdy_pix_val = getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, dec_x, dec_y, h, w);
double ixdy_pix_val = getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, inc_x, dec_y, h, w);
double iydx_pix_val = getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, dec_x, inc_y, h, w);
img_hess(1, pix_id) = img_hess(2, pix_id) = ((ixiy_pix_val + dxdy_pix_val) - (ixdy_pix_val + iydx_pix_val)) * hess_mult_factor;
}
}
#endif
// mapped version
template<InterpType mapping_type>
void getImgGrad(PixGradT &img_grad, const EigImgT &img,
const VectorXd &intensity_map, const PtsT &pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w,
double pix_mult_factor){
assert(img_grad.rows() == n_pix && pts.cols() == n_pix);
double grad_mult_factor = pix_mult_factor / (2 * grad_eps);
double pix_val_inc, pix_val_dec;
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double curr_x = pts(0, pix_id), curr_y = pts(1, pix_id);
pix_val_inc = mapPixVal<mapping_type>(getPixVal<GRAD_INTERP_TYPE, PIX_BORDER_TYPE>(img, curr_x + grad_eps, curr_y, h, w), intensity_map);
pix_val_dec = mapPixVal<mapping_type>(getPixVal<GRAD_INTERP_TYPE, PIX_BORDER_TYPE>(img, curr_x - grad_eps, curr_y, h, w), intensity_map);
img_grad(pix_id, 0) = (pix_val_inc - pix_val_dec)*grad_mult_factor;
pix_val_inc = mapPixVal<mapping_type>(getPixVal<GRAD_INTERP_TYPE, PIX_BORDER_TYPE>(img, curr_x, curr_y + grad_eps, h, w), intensity_map);
pix_val_dec = mapPixVal<mapping_type>(getPixVal<GRAD_INTERP_TYPE, PIX_BORDER_TYPE>(img, curr_x, curr_y - grad_eps, h, w), intensity_map);
img_grad(pix_id, 1) = (pix_val_inc - pix_val_dec)*grad_mult_factor;
}
}
// mapped version
template<InterpType mapping_type>
void getImgHess(PixHessT &img_hess, const EigImgT &img,
const VectorXd &intensity_map, const PtsT &pts, double hess_eps,
unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor){
assert(img_hess.cols() == n_pix && pts.cols() == n_pix);
double hess_eps2 = 2 * hess_eps;
double hess_mult_factor = pix_mult_factor / (hess_eps2 * hess_eps2);
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double curr_x = pts(0, pix_id), curr_y = pts(1, pix_id);
double curr_pix_val = mapPixVal<mapping_type>(getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, curr_x, curr_y, h, w), intensity_map);
double ix_pix_val = mapPixVal<mapping_type>(getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, curr_x + hess_eps2, curr_y, h, w), intensity_map);
double dx_pix_val = mapPixVal<mapping_type>(getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, curr_x - hess_eps2, curr_y, h, w), intensity_map);
img_hess(0, pix_id) = (ix_pix_val + dx_pix_val - 2 * curr_pix_val) * hess_mult_factor;
double iy_pix_val = mapPixVal<mapping_type>(getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, curr_x, curr_y + hess_eps2, h, w), intensity_map);
double dy_pix_val = mapPixVal<mapping_type>(getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, curr_x, curr_y - hess_eps2, h, w), intensity_map);
img_hess(3, pix_id) = (iy_pix_val + dy_pix_val - 2 * curr_pix_val) * hess_mult_factor;
double inc_x = curr_x + hess_eps, dec_x = curr_x - hess_eps;
double inc_y = curr_y + hess_eps, dec_y = curr_y - hess_eps;
double ixiy_pix_val = mapPixVal<mapping_type>(getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, inc_x, inc_y, h, w), intensity_map);
double dxdy_pix_val = mapPixVal<mapping_type>(getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, dec_x, dec_y, h, w), intensity_map);
double ixdy_pix_val = mapPixVal<mapping_type>(getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, inc_x, dec_y, h, w), intensity_map);
double iydx_pix_val = mapPixVal<mapping_type>(getPixVal<HESS_INTERP_TYPE, PIX_BORDER_TYPE>(img, dec_x, inc_y, h, w), intensity_map);
img_hess(1, pix_id) = img_hess(2, pix_id) = ((ixiy_pix_val + dxdy_pix_val) - (ixdy_pix_val + iydx_pix_val)) * hess_mult_factor;
}
}
// computes image hessian analytically by fitting a cubic polynomial surface to a 4x4 grid of pixels around each location
void getImgHess(PixHessT &img_hess,
const EigImgT &img, const PtsT &pts,
unsigned int n_pix, unsigned int h, unsigned int w){
assert(img_hess.cols() == n_pix && pts.cols() == n_pix);
Matrix4d neigh_pix_grid, bicubic_coeff;
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double x = pts(0, pix_id), y = pts(1, pix_id);
if(!getNeighboringPixGrid(neigh_pix_grid, img, x, y, h, w)){
img_hess(0, pix_id) = img_hess(1, pix_id) = img_hess(2, pix_id) = img_hess(3, pix_id) = 0;
continue;
}
getBiCubicCoefficients(bicubic_coeff, neigh_pix_grid);
double dx = x - static_cast<int>(x);
double dy = y - static_cast<int>(y);
img_hess(0, pix_id) = biCubicHessXX(bicubic_coeff, dx, dy);
img_hess(3, pix_id) = biCubicHessYY(bicubic_coeff, dx, dy);
img_hess(1, pix_id) = img_hess(2, pix_id) = biCubicHessYX(bicubic_coeff, dx, dy);
//img_hess(2, pix_id) = biCubicHessXY(bicubic_coeff, dx, dy);
//printMatrix(neigh_pix_grid, "neigh_pix_grid");
//printMatrix(bicubic_coeff, "bicubic_coeff");
//printMatrix(Map<Matrix2d>((double*)img_hess.col(pix_id).data()), "img_hess");
}
//printScalarToFile(hess_eps, "hess_eps", "./log/mtf_log.txt", "%e", "a");
//printMatrixToFile(img_hess, "img_hess", "./log/mtf_log.txt", "%e", "a");
}
// convenience functions for mapping
void getWarpedImgGrad(PixGradT &warped_img_grad, const EigImgT &img,
bool weighted_mapping, const VectorXd &intensity_map, const Matrix8Xd &warped_offset_pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor){
if(weighted_mapping){
getWarpedImgGrad<InterpType::Linear>(warped_img_grad,
img, intensity_map, warped_offset_pts, grad_eps, n_pix, h, w,
pix_mult_factor);
} else{
getWarpedImgGrad<InterpType::Nearest>(warped_img_grad,
img, intensity_map, warped_offset_pts, grad_eps, n_pix, h, w,
pix_mult_factor);
}
}
void getWarpedImgHess(PixHessT &warped_img_hess, const EigImgT &img,
bool weighted_mapping, const VectorXd &intensity_map,
const PtsT &warped_pts, const Matrix16Xd &warped_offset_pts,
double hess_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor){
if(weighted_mapping){
getWarpedImgHess<InterpType::Linear>(warped_img_hess,
img, intensity_map, warped_pts, warped_offset_pts,
hess_eps, n_pix, h, w, pix_mult_factor);
} else{
getWarpedImgHess<InterpType::Nearest>(warped_img_hess,
img, intensity_map, warped_pts, warped_offset_pts,
hess_eps, n_pix, h, w, pix_mult_factor);
}
}
void getImgGrad(PixGradT &img_grad, const EigImgT &img,
bool weighted_mapping, const VectorXd &intensity_map,
const PtsT &pts, double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w,
double pix_mult_factor){
if(weighted_mapping){
getImgGrad<InterpType::Linear>(img_grad,
img, intensity_map, pts, grad_eps,
n_pix, h, w, pix_mult_factor);
} else{
getImgGrad<InterpType::Nearest>(img_grad,
img, intensity_map, pts, grad_eps,
n_pix, h, w, pix_mult_factor);
}
}
void getImgHess(PixHessT &img_hess, const EigImgT &img, bool weighted_mapping,
const VectorXd &intensity_map, const PtsT &pts, double hess_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor){
if(weighted_mapping){
getImgHess<InterpType::Linear>(img_hess,
img, intensity_map, pts, hess_eps, n_pix, h, w, pix_mult_factor);
} else{
getImgHess<InterpType::Nearest>(img_hess,
img, intensity_map, pts, hess_eps, n_pix, h, w, pix_mult_factor);
}
}
void getWeightedPixVals(VectorXd &pix_vals, const EigImgT &img, const PtsT &pts,
unsigned int frame_count, double alpha, bool use_running_avg, unsigned int n_pix,
unsigned int h, unsigned int w, double norm_mult, double norm_add){
if(use_running_avg){
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double pix_val = norm_mult * getPixVal<PIX_INTERP_TYPE, PIX_BORDER_TYPE>(
img, pts(0, pix_id), pts(1, pix_id),
h, w) + norm_add;
pix_vals(pix_id) += (pix_val - pix_vals(pix_id)) / frame_count;
}
} else{
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double pix_val = getPixVal<PIX_INTERP_TYPE, PIX_BORDER_TYPE>(
img, pts(0, pix_id), pts(1, pix_id), h, w);
pix_vals(pix_id) = alpha*pix_val + (1 - alpha)*pix_vals(pix_id);
}
}
}
namespace sc{
//! ----------------------------------------------- !//
//! OpenCV single channel images
//! ----------------------------------------------- !//
template<typename ScalarType, typename PtsT>
void getPixVals(VectorXd &pix_vals,
const cv::Mat &img, const PtsT &pts, unsigned int n_pix, unsigned int h, unsigned int w,
double norm_mult, double norm_add){
//printf("n_pix: %d\t pix_vals.size(): %l\t pts.cols(): %l", n_pix, pix_vals.size(), pts.cols());
assert(pix_vals.size() == n_pix && pts.cols() == n_pix);
for(unsigned int i = 0; i < n_pix; i++){
pix_vals(i) = norm_mult * PixVal<ScalarType, PIX_INTERP_TYPE, PIX_BORDER_TYPE>::
get(img, pts(0, i), pts(1, i), h, w) + norm_add;
//pix_vals(i) = 0;
}
}
template<typename ScalarType>
void getWeightedPixVals(VectorXd &pix_vals, const cv::Mat &img, const PtsT &pts,
unsigned int frame_count, double alpha, bool use_running_avg, unsigned int n_pix,
unsigned int h, unsigned int w, double norm_mult, double norm_add){
if(use_running_avg){
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double pix_val = PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(img,
pts(0, pix_id), pts(1, pix_id), h, w);
pix_vals[pix_id] += (norm_mult*pix_vals[pix_id] + norm_add - pix_vals[pix_id]) / frame_count;
}
} else{
double alpha_mult = norm_mult*alpha, alpha_add = norm_add*alpha;
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double pix_val = PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(img,
pts(0, pix_id), pts(1, pix_id), h, w);
pix_vals[pix_id] = alpha_mult*pix_val + alpha_add + (1 - alpha)*pix_vals[pix_id];
}
}
}
template<typename ScalarType>
void getWarpedImgGrad(PixGradT &warped_img_grad,
const cv::Mat &img, const Matrix8Xd &warped_offset_pts,
double grad_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor){
assert(warped_img_grad.rows() == n_pix && warped_offset_pts.cols() == n_pix);
double grad_mult_factor = pix_mult_factor / (2 * grad_eps);
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double pix_val_inc_x, pix_val_dec_x;
double pix_val_inc_y, pix_val_dec_y;
pix_val_inc_x = PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, warped_offset_pts(0, pix_id),
warped_offset_pts(1, pix_id), h, w);
pix_val_dec_x = PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, warped_offset_pts(2, pix_id),
warped_offset_pts(3, pix_id), h, w);
pix_val_inc_y = PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, warped_offset_pts(4, pix_id),
warped_offset_pts(5, pix_id), h, w);
pix_val_dec_y = PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, warped_offset_pts(6, pix_id),
warped_offset_pts(7, pix_id), h, w);
warped_img_grad(pix_id, 0) = (pix_val_inc_x - pix_val_dec_x)*grad_mult_factor;
warped_img_grad(pix_id, 1) = (pix_val_inc_y - pix_val_dec_y)*grad_mult_factor;
}
//utils::printMatrixToFile(warped_img_grad, "warped_img_grad", "log/mtf_log.txt", "%15.9f", "a");
}
// mapped version
template<typename ScalarType, InterpType mapping_type>
void getWarpedImgGrad(PixGradT &warped_img_grad,
const cv::Mat &img, const VectorXd &intensity_map,
const Matrix8Xd &warped_offset_pts, double grad_eps,
unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor){
assert(warped_img_grad.rows() == n_pix);
double grad_mult_factor = pix_mult_factor / (2 * grad_eps);
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double pix_val_inc_x = PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(img,
warped_offset_pts(0, pix_id), warped_offset_pts(1, pix_id), h, w);
double pix_val_dec_x = PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(img,
warped_offset_pts(2, pix_id), warped_offset_pts(3, pix_id), h, w);
double pix_val_inc_y = PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(img,
warped_offset_pts(4, pix_id), warped_offset_pts(5, pix_id), h, w);
double pix_val_dec_y = PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(img,
warped_offset_pts(6, pix_id), warped_offset_pts(7, pix_id), h, w);
warped_img_grad(pix_id, 0) = (mapPixVal<mapping_type>(pix_val_inc_x, intensity_map)
- mapPixVal<mapping_type>(pix_val_dec_x, intensity_map))*grad_mult_factor;
warped_img_grad(pix_id, 1) = (mapPixVal<mapping_type>(pix_val_inc_y, intensity_map)
- mapPixVal<mapping_type>(pix_val_dec_y, intensity_map))*grad_mult_factor;
}
}
template<typename ScalarType>
void getImgGrad(PixGradT &img_grad,
const cv::Mat &img, const PtsT &pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w,
double pix_mult_factor){
assert(img_grad.rows() == n_pix && pts.cols() == n_pix);
double grad_mult_factor = pix_mult_factor / (2 * grad_eps);
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double curr_x = pts(0, pix_id), curr_y = pts(1, pix_id);
double pix_val_inc_x = PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, curr_x + grad_eps, curr_y, h, w);
double pix_val_dec_x = PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, curr_x - grad_eps, curr_y, h, w);
double pix_val_inc_y = PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, curr_x, curr_y + grad_eps, h, w);
double pix_val_dec_y = PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, curr_x, curr_y - grad_eps, h, w);
img_grad(pix_id, 0) = (pix_val_inc_x - pix_val_dec_x)*grad_mult_factor;
img_grad(pix_id, 1) = (pix_val_inc_y - pix_val_dec_y)*grad_mult_factor;
}
}
// mapped version
template<typename ScalarType, InterpType mapping_type>
void getImgGrad(PixGradT &img_grad, const cv::Mat &img,
const VectorXd &intensity_map, const PtsT &pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w,
double pix_mult_factor){
assert(img_grad.rows() == n_pix && pts.cols() == n_pix);
double grad_mult_factor = pix_mult_factor / (2 * grad_eps);
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double curr_x = pts(0, pix_id), curr_y = pts(1, pix_id);
double pix_val_inc_x = PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, curr_x + grad_eps, curr_y, h, w);
double pix_val_dec_x = PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, curr_x - grad_eps, curr_y, h, w);
double pix_val_inc_y = PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, curr_x, curr_y + grad_eps, h, w);
double pix_val_dec_y = PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, curr_x, curr_y - grad_eps, h, w);
img_grad(pix_id, 0) = (mapPixVal<mapping_type>(pix_val_inc_x, intensity_map) -
mapPixVal<mapping_type>(pix_val_dec_x, intensity_map))*grad_mult_factor;
img_grad(pix_id, 1) = (mapPixVal<mapping_type>(pix_val_inc_y, intensity_map) -
mapPixVal<mapping_type>(pix_val_dec_y, intensity_map))*grad_mult_factor;
}
}
template<typename ScalarType>
void getWarpedImgHess(PixHessT &warped_img_hess,
const cv::Mat &img, const PtsT &warped_pts,
const HessPtsT &warped_offset_pts, double hess_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor){
assert(warped_img_hess.cols() == n_pix && warped_pts.cols() == n_pix);
double hess_eps2 = 2 * hess_eps;
double hess_mult_factor = pix_mult_factor / (hess_eps2 * hess_eps2);
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double pix_val = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, warped_pts(0, pix_id), warped_pts(1, pix_id), h, w);
double pix_val_inc_x = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, warped_offset_pts(0, pix_id), warped_offset_pts(1, pix_id), h, w);
double pix_val_dec_x = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, warped_offset_pts(2, pix_id), warped_offset_pts(3, pix_id), h, w);
double pix_val_inc_y = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, warped_offset_pts(4, pix_id), warped_offset_pts(5, pix_id), h, w);
double pix_val_dec_y = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, warped_offset_pts(6, pix_id), warped_offset_pts(7, pix_id), h, w);
double pix_val_inc_xy = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, warped_offset_pts(8, pix_id), warped_offset_pts(9, pix_id), h, w);
double pix_val_dec_xy = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, warped_offset_pts(10, pix_id), warped_offset_pts(11, pix_id), h, w);
double pix_val_inc_yx = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, warped_offset_pts(12, pix_id), warped_offset_pts(13, pix_id), h, w);
double pix_val_dec_yx = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, warped_offset_pts(14, pix_id), warped_offset_pts(15, pix_id), h, w);
warped_img_hess(0, pix_id) = (pix_val_inc_x + pix_val_dec_x - 2 * pix_val)*hess_mult_factor;
warped_img_hess(3, pix_id) = (pix_val_inc_y + pix_val_dec_y - 2 * pix_val)*hess_mult_factor;
warped_img_hess(1, pix_id) = warped_img_hess(2, pix_id) = ((pix_val_inc_xy + pix_val_dec_xy) -
(pix_val_inc_yx + pix_val_dec_yx)) * hess_mult_factor;
}
}
// mapped version
template<typename ScalarType, InterpType mapping_type>
void getWarpedImgHess(PixHessT &warped_img_hess,
const cv::Mat &img, const VectorXd &intensity_map,
const PtsT &warped_pts, const HessPtsT &warped_offset_pts,
double hess_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor){
assert(warped_img_hess.cols() == n_pix && warped_pts.cols() == n_pix);
double hess_eps2 = 2 * hess_eps;
double hess_mult_factor = pix_mult_factor / (hess_eps2 * hess_eps2);
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double pix_val = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, warped_pts(0, pix_id), warped_pts(1, pix_id), h, w);
double pix_val_inc_x = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, warped_offset_pts(0, pix_id), warped_offset_pts(1, pix_id), h, w);
double pix_val_dec_x = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, warped_offset_pts(2, pix_id), warped_offset_pts(3, pix_id), h, w);
double pix_val_inc_y = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, warped_offset_pts(4, pix_id), warped_offset_pts(5, pix_id), h, w);
double pix_val_dec_y = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, warped_offset_pts(6, pix_id), warped_offset_pts(7, pix_id), h, w);
double pix_val_inc_xy = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, warped_offset_pts(8, pix_id), warped_offset_pts(9, pix_id), h, w);
double pix_val_dec_xy = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, warped_offset_pts(10, pix_id), warped_offset_pts(11, pix_id), h, w);
double pix_val_inc_yx = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, warped_offset_pts(12, pix_id), warped_offset_pts(13, pix_id), h, w);
double pix_val_dec_yx = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, warped_offset_pts(14, pix_id), warped_offset_pts(15, pix_id), h, w);
warped_img_hess(0, pix_id) = (mapPixVal<mapping_type>(pix_val_inc_x, intensity_map) +
mapPixVal<mapping_type>(pix_val_dec_x, intensity_map) -
2 * mapPixVal<mapping_type>(pix_val, intensity_map))*hess_mult_factor;
warped_img_hess(3, pix_id) = (mapPixVal<mapping_type>(pix_val_inc_y, intensity_map) +
mapPixVal<mapping_type>(pix_val_dec_y, intensity_map) -
2 * mapPixVal<mapping_type>(pix_val, intensity_map))*hess_mult_factor;
warped_img_hess(1, pix_id) = warped_img_hess(2, pix_id) = (
(mapPixVal<mapping_type>(pix_val_inc_xy, intensity_map) +
mapPixVal<mapping_type>(pix_val_dec_xy, intensity_map))
-
(mapPixVal<mapping_type>(pix_val_inc_yx, intensity_map) +
mapPixVal<mapping_type>(pix_val_dec_yx, intensity_map))) * hess_mult_factor;
}
}
template<typename ScalarType>
void getImgHess(PixHessT &img_hess, const cv::Mat &img,
const PtsT &pts, double hess_eps,
unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor){
assert(img_hess.cols() == n_pix && pts.cols() == n_pix);
double hess_eps2 = 2 * hess_eps;
double hess_mult_factor = pix_mult_factor / (hess_eps2 * hess_eps2);
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double curr_x = pts(0, pix_id), curr_y = pts(1, pix_id);
double pix_val = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, curr_x, curr_y, h, w);
double pix_val_inc_x = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, curr_x + hess_eps2, curr_y, h, w);
double pix_val_dec_x = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, curr_x - hess_eps2, curr_y, h, w);
double pix_val_inc_y = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, curr_x, curr_y + hess_eps2, h, w);
double pix_val_dec_y = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, curr_x, curr_y - hess_eps2, h, w);
double inc_x = curr_x + hess_eps, dec_x = curr_x - hess_eps;
double inc_y = curr_y + hess_eps, dec_y = curr_y - hess_eps;
double pix_val_inc_xy = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, inc_x, inc_y, h, w);
double pix_val_dec_xy = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, dec_x, dec_y, h, w);
double pix_val_inc_yx = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, inc_x, dec_y, h, w);
double pix_val_dec_yx = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, dec_x, inc_y, h, w);
img_hess(0, pix_id) = (pix_val_inc_x + pix_val_dec_x - 2 * pix_val) * hess_mult_factor;
img_hess(3, pix_id) = (pix_val_inc_y + pix_val_dec_y - 2 * pix_val) * hess_mult_factor;
img_hess(1, pix_id) = img_hess(2, pix_id) = ((pix_val_inc_xy + pix_val_dec_xy) -
(pix_val_inc_yx + pix_val_dec_yx)) * hess_mult_factor;
}
}
// mapped version
template<typename ScalarType, InterpType mapping_type>
void getImgHess(PixHessT &img_hess, const cv::Mat &img,
const VectorXd &intensity_map, const PtsT &pts, double hess_eps,
unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor){
assert(img_hess.cols() == n_pix && pts.cols() == n_pix);
double hess_eps2 = 2 * hess_eps;
double hess_mult_factor = pix_mult_factor / (hess_eps2 * hess_eps2);
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double curr_x = pts(0, pix_id), curr_y = pts(1, pix_id);
double inc_x = curr_x + hess_eps, dec_x = curr_x - hess_eps;
double inc_y = curr_y + hess_eps, dec_y = curr_y - hess_eps;
double pix_val = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, curr_x, curr_y, h, w);
double pix_val_inc_x = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, curr_x + hess_eps2, curr_y, h, w);
double pix_val_dec_x = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, curr_x - hess_eps2, curr_y, h, w);
double pix_val_inc_y = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, curr_x, curr_y + hess_eps2, h, w);
double pix_val_dec_y = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, curr_x, curr_y - hess_eps2, h, w);
double pix_val_ixiy = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, inc_x, inc_y, h, w);
double pix_val_dxdy = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, dec_x, dec_y, h, w);
double pix_val_ixdy = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, inc_x, dec_y, h, w);
double pix_val_dxiy = PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(img, dec_x, inc_y, h, w);
img_hess(0, pix_id) = (mapPixVal<mapping_type>(pix_val_inc_x, intensity_map) +
mapPixVal<mapping_type>(pix_val_dec_x, intensity_map) - 2 * mapPixVal<mapping_type>(pix_val, intensity_map)) * hess_mult_factor;
img_hess(3, pix_id) = (mapPixVal<mapping_type>(pix_val_inc_y, intensity_map) +
mapPixVal<mapping_type>(pix_val_dec_y, intensity_map) -
2 * mapPixVal<mapping_type>(pix_val, intensity_map)) * hess_mult_factor;
img_hess(1, pix_id) = img_hess(2, pix_id) = (
(mapPixVal<mapping_type>(pix_val_ixiy, intensity_map) +
mapPixVal<mapping_type>(pix_val_dxdy, intensity_map))
-
(mapPixVal<mapping_type>(pix_val_ixdy, intensity_map) +
mapPixVal<mapping_type>(pix_val_dxiy, intensity_map))
) * hess_mult_factor;
}
}
template<typename ScalarType>
void getWarpedImgGrad(PixGradT &warped_img_grad, const cv::Mat &img,
bool weighted_mapping, const VectorXd &intensity_map,
const Matrix8Xd &warped_offset_pts, double grad_eps,
unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor){
if(weighted_mapping){
getWarpedImgGrad<ScalarType, InterpType::Linear>(warped_img_grad,
img, intensity_map, warped_offset_pts, grad_eps,
n_pix, h, w, pix_mult_factor);
} else{
getWarpedImgGrad<ScalarType, InterpType::Nearest>(warped_img_grad,
img, intensity_map, warped_offset_pts, grad_eps,
n_pix, h, w, pix_mult_factor);
}
}
template<typename ScalarType>
void getImgGrad(PixGradT &img_grad, const cv::Mat &img,
bool weighted_mapping, const VectorXd &intensity_map,
const PtsT &pts, double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w,
double pix_mult_factor){
if(weighted_mapping){
getImgGrad<ScalarType, InterpType::Linear>(img_grad,
img, intensity_map, pts, grad_eps,
n_pix, h, w, pix_mult_factor);
} else{
getImgGrad<ScalarType, InterpType::Nearest>(img_grad,
img, intensity_map, pts, grad_eps,
n_pix, h, w, pix_mult_factor);
}
}
template<typename ScalarType>
void getWarpedImgHess(PixHessT &warped_img_hess,
const cv::Mat &img, bool weighted_mapping, const VectorXd &intensity_map,
const PtsT &warped_pts, const HessPtsT &warped_offset_pts,
double hess_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor){
if(weighted_mapping){
getWarpedImgHess<ScalarType, InterpType::Linear>(warped_img_hess,
img, intensity_map,
warped_pts, warped_offset_pts,
hess_eps, n_pix, h, w, pix_mult_factor);
} else{
getWarpedImgHess<ScalarType, InterpType::Nearest>(warped_img_hess,
img, intensity_map,
warped_pts, warped_offset_pts,
hess_eps, n_pix, h, w, pix_mult_factor);
}
}
template<typename ScalarType>
void getImgHess(PixHessT &img_hess, const cv::Mat &img, bool weighted_mapping,
const VectorXd &intensity_map, const PtsT &pts, double hess_eps,
unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor){
if(weighted_mapping){
getImgHess<ScalarType, InterpType::Linear>(img_hess, img, intensity_map, pts,
hess_eps, n_pix, h, w, pix_mult_factor);
} else{
getImgHess<ScalarType, InterpType::Nearest>(img_hess, img, intensity_map, pts,
hess_eps, n_pix, h, w, pix_mult_factor);
}
}
}
namespace mc{
//--------------------------------------------------------- //
// ---------------- multi channel versions ---------------- //
//--------------------------------------------------------- //
template<typename ScalarType, typename PtsT>
void getPixVals(VectorXd &pix_vals,
const cv::Mat &img, const PtsT &pts, unsigned int n_pix, unsigned int h, unsigned int w,
double norm_mult, double norm_add){
//printf("n_pix: %d\t pix_vals.size(): %l\t pts.cols(): %l", n_pix, pix_vals.size(), pts.cols());
assert(pix_vals.size() == 3 * n_pix && pts.cols() == n_pix);
double *pix_data = pix_vals.data();
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_data, img,
pts(0, pix_id), pts(1, pix_id), h, w);
pix_data[0] = norm_mult*pix_data[0] + norm_add;
pix_data[1] = norm_mult*pix_data[1] + norm_add;
pix_data[2] = norm_mult*pix_data[2] + norm_add;
pix_data += 3;
}
}
template<typename ScalarType>
void getWeightedPixVals(VectorXd &pix_vals, const cv::Mat &img, const PtsT &pts,
unsigned int frame_count, double alpha, bool use_running_avg, unsigned int n_pix,
unsigned int h, unsigned int w, double norm_mult, double norm_add){
double *pix_data = pix_vals.data();
if(use_running_avg){
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double pix_val[3];
PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val, img,
pts(0, pix_id), pts(1, pix_id), h, w);
pix_data[0] += (norm_mult*pix_val[0] + norm_add - pix_data[0]) / frame_count;
pix_data[1] += (norm_mult*pix_val[1] + norm_add - pix_data[1]) / frame_count;
pix_data[2] += (norm_mult*pix_val[2] + norm_add - pix_data[2]) / frame_count;
pix_data += 3;
}
} else{
double alpha_mult = norm_mult*alpha, alpha_add = norm_add*alpha;
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double pix_val[3];
PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val, img,
pts(0, pix_id), pts(1, pix_id), h, w);
pix_data[0] = alpha_mult*pix_val[0] + alpha_add + (1 - alpha)*pix_data[0];
pix_data[1] = alpha_mult*pix_val[1] + alpha_add + (1 - alpha)*pix_data[1];
pix_data[2] = alpha_mult*pix_val[2] + alpha_add + (1 - alpha)*pix_data[2];
pix_data += 3;
}
}
}
template<typename ScalarType>
void getWarpedImgGrad(PixGradT &warped_img_grad,
const cv::Mat &img, const Matrix8Xd &warped_offset_pts,
double grad_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor){
assert(warped_img_grad.rows() == n_pix * 3 && warped_offset_pts.cols() == n_pix);
double grad_mult_factor = pix_mult_factor / (2 * grad_eps);
int ch_pix_id = 0;
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double pix_val_inc_x[3], pix_val_dec_x[3];
double pix_val_inc_y[3], pix_val_dec_y[3];
PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_inc_x, img, warped_offset_pts(0, pix_id),
warped_offset_pts(1, pix_id), h, w);
PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_dec_x, img, warped_offset_pts(2, pix_id),
warped_offset_pts(3, pix_id), h, w);
PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_inc_y, img, warped_offset_pts(4, pix_id),
warped_offset_pts(5, pix_id), h, w);
PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_dec_y, img, warped_offset_pts(6, pix_id),
warped_offset_pts(7, pix_id), h, w);
for(unsigned int channel_id = 0; channel_id < 3; ++channel_id){
warped_img_grad(ch_pix_id, 0) = (pix_val_inc_x[channel_id] - pix_val_dec_x[channel_id])*grad_mult_factor;
warped_img_grad(ch_pix_id, 1) = (pix_val_inc_y[channel_id] - pix_val_dec_y[channel_id])*grad_mult_factor;
++ch_pix_id;
}
}
//utils::printMatrixToFile(warped_img_grad, "warped_img_grad", "log/mtf_log.txt", "%15.9f", "a");
}
// mapped version
template<typename ScalarType, InterpType mapping_type>
void getWarpedImgGrad(PixGradT &warped_img_grad,
const cv::Mat &img, const VectorXd &intensity_map,
const Matrix8Xd &warped_offset_pts, double grad_eps,
unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor){
assert(warped_img_grad.rows() == n_pix * 3);
double grad_mult_factor = pix_mult_factor / (2 * grad_eps);
int ch_pix_id = 0;
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double pix_val_inc_x[3], pix_val_dec_x[3];
double pix_val_inc_y[3], pix_val_dec_y[3];
PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_inc_x, img,
warped_offset_pts(0, pix_id), warped_offset_pts(1, pix_id), h, w);
PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_dec_x, img,
warped_offset_pts(2, pix_id), warped_offset_pts(3, pix_id), h, w);
PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_inc_y, img,
warped_offset_pts(4, pix_id), warped_offset_pts(5, pix_id), h, w);
PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_dec_y, img,
warped_offset_pts(6, pix_id), warped_offset_pts(7, pix_id), h, w);
for(unsigned int channel_id = 0; channel_id < 3; ++channel_id){
warped_img_grad(ch_pix_id, 0) = (mapPixVal<mapping_type>(pix_val_inc_x[channel_id], intensity_map)
- mapPixVal<mapping_type>(pix_val_dec_x[channel_id], intensity_map))*grad_mult_factor;
warped_img_grad(ch_pix_id, 1) = (mapPixVal<mapping_type>(pix_val_inc_y[channel_id], intensity_map)
- mapPixVal<mapping_type>(pix_val_dec_y[channel_id], intensity_map))*grad_mult_factor;
++ch_pix_id;
}
}
}
template<typename ScalarType>
void getImgGrad(PixGradT &img_grad,
const cv::Mat &img, const PtsT &pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w,
double pix_mult_factor){
assert(img_grad.rows() == n_pix * 3 && pts.cols() == n_pix);
double grad_mult_factor = pix_mult_factor / (2 * grad_eps);
int ch_pix_id = 0;
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double curr_x = pts(0, pix_id), curr_y = pts(1, pix_id);
double pix_val_inc_x[3], pix_val_dec_x[3];
double pix_val_inc_y[3], pix_val_dec_y[3];
PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_inc_x, img, curr_x + grad_eps, curr_y, h, w);
PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_dec_x, img, curr_x - grad_eps, curr_y, h, w);
PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_inc_y, img, curr_x, curr_y + grad_eps, h, w);
PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_dec_y, img, curr_x, curr_y - grad_eps, h, w);
for(unsigned int channel_id = 0; channel_id < 3; ++channel_id){
img_grad(ch_pix_id, 0) = (pix_val_inc_x[channel_id] - pix_val_dec_x[channel_id])*grad_mult_factor;
img_grad(ch_pix_id, 1) = (pix_val_inc_y[channel_id] - pix_val_dec_y[channel_id])*grad_mult_factor;
++ch_pix_id;
}
}
}
// mapped version
template<typename ScalarType, InterpType mapping_type>
void getImgGrad(PixGradT &img_grad, const cv::Mat &img,
const VectorXd &intensity_map, const PtsT &pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w,
double pix_mult_factor){
assert(img_grad.rows() == n_pix * 3 && pts.cols() == n_pix);
double grad_mult_factor = pix_mult_factor / (2 * grad_eps);
int ch_pix_id = 0;
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double curr_x = pts(0, pix_id), curr_y = pts(1, pix_id);
double pix_val_inc_x[3], pix_val_dec_x[3];
double pix_val_inc_y[3], pix_val_dec_y[3];
PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_inc_x, img, curr_x + grad_eps, curr_y, h, w);
PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_dec_x, img, curr_x - grad_eps, curr_y, h, w);
PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_inc_y, img, curr_x, curr_y + grad_eps, h, w);
PixVal<ScalarType, GRAD_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_dec_y, img, curr_x, curr_y - grad_eps, h, w);
for(unsigned int channel_id = 0; channel_id < 3; ++channel_id){
img_grad(ch_pix_id, 0) = (mapPixVal<mapping_type>(pix_val_inc_x[channel_id], intensity_map) -
mapPixVal<mapping_type>(pix_val_dec_x[channel_id], intensity_map))*grad_mult_factor;
img_grad(ch_pix_id, 1) = (mapPixVal<mapping_type>(pix_val_inc_y[channel_id], intensity_map) -
mapPixVal<mapping_type>(pix_val_dec_y[channel_id], intensity_map))*grad_mult_factor;
++ch_pix_id;
}
}
}
template<typename ScalarType>
void getWarpedImgHess(PixHessT &warped_img_hess,
const cv::Mat &img, const PtsT &warped_pts,
const HessPtsT &warped_offset_pts, double hess_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor){
assert(warped_img_hess.cols() == n_pix * 3 && warped_pts.cols() == n_pix);
double hess_eps2 = 2 * hess_eps;
double hess_mult_factor = pix_mult_factor / (hess_eps2 * hess_eps2);
int ch_pix_id = 0;
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double pix_val[3];
double pix_val_inc_x[3], pix_val_dec_x[3];
double pix_val_inc_y[3], pix_val_dec_y[3];
double pix_val_inc_xy[3], pix_val_dec_xy[3];
double pix_val_inc_yx[3], pix_val_dec_yx[3];
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val, img, warped_pts(0, pix_id), warped_pts(1, pix_id), h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_inc_x, img, warped_offset_pts(0, pix_id), warped_offset_pts(1, pix_id), h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_dec_x, img, warped_offset_pts(2, pix_id), warped_offset_pts(3, pix_id), h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_inc_y, img, warped_offset_pts(4, pix_id), warped_offset_pts(5, pix_id), h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_dec_y, img, warped_offset_pts(6, pix_id), warped_offset_pts(7, pix_id), h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_inc_xy, img, warped_offset_pts(8, pix_id), warped_offset_pts(9, pix_id), h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_dec_xy, img, warped_offset_pts(10, pix_id), warped_offset_pts(11, pix_id), h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_inc_yx, img, warped_offset_pts(12, pix_id), warped_offset_pts(13, pix_id), h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_dec_yx, img, warped_offset_pts(14, pix_id), warped_offset_pts(15, pix_id), h, w);
for(unsigned int channel_id = 0; channel_id < 3; ++channel_id){
warped_img_hess(0, ch_pix_id) = (pix_val_inc_x[channel_id] + pix_val_dec_x[channel_id] - 2 * pix_val[channel_id])*hess_mult_factor;
warped_img_hess(3, ch_pix_id) = (pix_val_inc_y[channel_id] + pix_val_dec_y[channel_id] - 2 * pix_val[channel_id])*hess_mult_factor;
warped_img_hess(1, ch_pix_id) = warped_img_hess(2, ch_pix_id) = ((pix_val_inc_xy[channel_id] + pix_val_dec_xy[channel_id]) -
(pix_val_inc_yx[channel_id] + pix_val_dec_yx[channel_id])) * hess_mult_factor;
++ch_pix_id;
}
}
}
// mapped version
template<typename ScalarType, InterpType mapping_type>
void getWarpedImgHess(PixHessT &warped_img_hess,
const cv::Mat &img, const VectorXd &intensity_map,
const PtsT &warped_pts, const HessPtsT &warped_offset_pts,
double hess_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor){
assert(warped_img_hess.cols() == n_pix && warped_pts.cols() == n_pix);
double hess_eps2 = 2 * hess_eps;
double hess_mult_factor = pix_mult_factor / (hess_eps2 * hess_eps2);
int ch_pix_id = 0;
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double pix_val[3];
double pix_val_inc_x[3], pix_val_dec_x[3];
double pix_val_inc_y[3], pix_val_dec_y[3];
double pix_val_inc_xy[3], pix_val_dec_xy[3];
double pix_val_inc_yx[3], pix_val_dec_yx[3];
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val, img, warped_pts(0, pix_id), warped_pts(1, pix_id), h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_inc_x, img, warped_offset_pts(0, pix_id), warped_offset_pts(1, pix_id), h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_dec_x, img, warped_offset_pts(2, pix_id), warped_offset_pts(3, pix_id), h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_inc_y, img, warped_offset_pts(4, pix_id), warped_offset_pts(5, pix_id), h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_dec_y, img, warped_offset_pts(6, pix_id), warped_offset_pts(7, pix_id), h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_inc_xy, img, warped_offset_pts(8, pix_id), warped_offset_pts(9, pix_id), h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_dec_xy, img, warped_offset_pts(10, pix_id), warped_offset_pts(11, pix_id), h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_inc_yx, img, warped_offset_pts(12, pix_id), warped_offset_pts(13, pix_id), h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_dec_yx, img, warped_offset_pts(14, pix_id), warped_offset_pts(15, pix_id), h, w);
for(unsigned int channel_id = 0; channel_id < 3; ++channel_id){
warped_img_hess(0, ch_pix_id) = (mapPixVal<mapping_type>(pix_val_inc_x[channel_id], intensity_map) +
mapPixVal<mapping_type>(pix_val_dec_x[channel_id], intensity_map) -
2 * mapPixVal<mapping_type>(pix_val[channel_id], intensity_map))*hess_mult_factor;
warped_img_hess(3, ch_pix_id) = (mapPixVal<mapping_type>(pix_val_inc_y[channel_id], intensity_map) +
mapPixVal<mapping_type>(pix_val_dec_y[channel_id], intensity_map) -
2 * mapPixVal<mapping_type>(pix_val[channel_id], intensity_map))*hess_mult_factor;
warped_img_hess(1, ch_pix_id) = warped_img_hess(2, ch_pix_id) = (
(mapPixVal<mapping_type>(pix_val_inc_xy[channel_id], intensity_map) +
mapPixVal<mapping_type>(pix_val_dec_xy[channel_id], intensity_map))
-
(mapPixVal<mapping_type>(pix_val_inc_yx[channel_id], intensity_map) +
mapPixVal<mapping_type>(pix_val_dec_yx[channel_id], intensity_map))) * hess_mult_factor;
++ch_pix_id;
}
}
}
template<typename ScalarType>
void getImgHess(PixHessT &img_hess, const cv::Mat &img,
const PtsT &pts, double hess_eps,
unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor){
assert(img_hess.cols() == n_pix * 3 && pts.cols() == n_pix);
double hess_eps2 = 2 * hess_eps;
double hess_mult_factor = pix_mult_factor / (hess_eps2 * hess_eps2);
int ch_pix_id = 0;
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double pix_val[3];
double pix_val_inc_x[3], pix_val_dec_x[3];
double pix_val_inc_y[3], pix_val_dec_y[3];
double pix_val_inc_xy[3], pix_val_dec_xy[3];
double pix_val_inc_yx[3], pix_val_dec_yx[3];
double curr_x = pts(0, pix_id), curr_y = pts(1, pix_id);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val, img, curr_x, curr_y, h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_inc_x, img, curr_x + hess_eps2, curr_y, h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_dec_x, img, curr_x - hess_eps2, curr_y, h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_inc_y, img, curr_x, curr_y + hess_eps2, h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_dec_y, img, curr_x, curr_y - hess_eps2, h, w);
double inc_x = curr_x + hess_eps, dec_x = curr_x - hess_eps;
double inc_y = curr_y + hess_eps, dec_y = curr_y - hess_eps;
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_inc_xy, img, inc_x, inc_y, h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_dec_xy, img, dec_x, dec_y, h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_inc_yx, img, inc_x, dec_y, h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_dec_yx, img, dec_x, inc_y, h, w);
for(unsigned int channel_id = 0; channel_id < 3; ++channel_id){
img_hess(0, ch_pix_id) = (pix_val_inc_x[channel_id] + pix_val_dec_x[channel_id] - 2 * pix_val[channel_id]) * hess_mult_factor;
img_hess(3, ch_pix_id) = (pix_val_inc_y[channel_id] + pix_val_dec_y[channel_id] - 2 * pix_val[channel_id]) * hess_mult_factor;
img_hess(1, ch_pix_id) = img_hess(2, ch_pix_id) = ((pix_val_inc_xy[channel_id] + pix_val_dec_xy[channel_id]) -
(pix_val_inc_yx[channel_id] + pix_val_dec_yx[channel_id])) * hess_mult_factor;
++ch_pix_id;
}
}
}
// mapped version
template<typename ScalarType, InterpType mapping_type>
void getImgHess(PixHessT &img_hess, const cv::Mat &img,
const VectorXd &intensity_map, const PtsT &pts, double hess_eps,
unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor){
assert(img_hess.cols() == n_pix * 3 && pts.cols() == n_pix);
double hess_eps2 = 2 * hess_eps;
double hess_mult_factor = pix_mult_factor / (hess_eps2 * hess_eps2);
int ch_pix_id = 0;
for(unsigned int pix_id = 0; pix_id < n_pix; ++pix_id){
double curr_x = pts(0, pix_id), curr_y = pts(1, pix_id);
double inc_x = curr_x + hess_eps, dec_x = curr_x - hess_eps;
double inc_y = curr_y + hess_eps, dec_y = curr_y - hess_eps;
double pix_val[3];
double pix_val_inc_x[3], pix_val_dec_x[3];
double pix_val_inc_y[3], pix_val_dec_y[3];
double pix_val_ixiy[3], pix_val_dxdy[3];
double pix_val_ixdy[3], pix_val_dxiy[3];
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val, img, curr_x, curr_y, h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_inc_x, img, curr_x + hess_eps2, curr_y, h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_dec_x, img, curr_x - hess_eps2, curr_y, h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_inc_y, img, curr_x, curr_y + hess_eps2, h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_dec_y, img, curr_x, curr_y - hess_eps2, h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_ixiy, img, inc_x, inc_y, h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_dxdy, img, dec_x, dec_y, h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_ixdy, img, inc_x, dec_y, h, w);
PixVal<ScalarType, HESS_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_val_dxiy, img, dec_x, inc_y, h, w);
for(unsigned int channel_id = 0; channel_id < 3; ++channel_id){
img_hess(0, ch_pix_id) = (mapPixVal<mapping_type>(pix_val_inc_x[channel_id], intensity_map) +
mapPixVal<mapping_type>(pix_val_dec_x[channel_id], intensity_map) - 2 * mapPixVal<mapping_type>(pix_val[channel_id], intensity_map)) * hess_mult_factor;
img_hess(3, ch_pix_id) = (mapPixVal<mapping_type>(pix_val_inc_y[channel_id], intensity_map) +
mapPixVal<mapping_type>(pix_val_dec_y[channel_id], intensity_map) -
2 * mapPixVal<mapping_type>(pix_val[channel_id], intensity_map)) * hess_mult_factor;
img_hess(1, ch_pix_id) = img_hess(2, ch_pix_id) = (
(mapPixVal<mapping_type>(pix_val_ixiy[channel_id], intensity_map) +
mapPixVal<mapping_type>(pix_val_dxdy[channel_id], intensity_map))
-
(mapPixVal<mapping_type>(pix_val_ixdy[channel_id], intensity_map) +
mapPixVal<mapping_type>(pix_val_dxiy[channel_id], intensity_map))
) * hess_mult_factor;
++ch_pix_id;
}
}
}
template<typename ScalarType>
void getWarpedImgGrad(PixGradT &warped_img_grad, const cv::Mat &img,
bool weighted_mapping, const VectorXd &intensity_map,
const Matrix8Xd &warped_offset_pts, double grad_eps,
unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor){
if(weighted_mapping){
getWarpedImgGrad<ScalarType, InterpType::Linear>(warped_img_grad,
img, intensity_map, warped_offset_pts, grad_eps,
n_pix, h, w, pix_mult_factor);
} else{
getWarpedImgGrad<ScalarType, InterpType::Nearest>(warped_img_grad,
img, intensity_map, warped_offset_pts, grad_eps,
n_pix, h, w, pix_mult_factor);
}
}
template<typename ScalarType>
void getImgGrad(PixGradT &img_grad, const cv::Mat &img,
bool weighted_mapping, const VectorXd &intensity_map,
const PtsT &pts, double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w,
double pix_mult_factor){
if(weighted_mapping){
getImgGrad<ScalarType, InterpType::Linear>(img_grad,
img, intensity_map, pts, grad_eps,
n_pix, h, w, pix_mult_factor);
} else{
getImgGrad<ScalarType, InterpType::Nearest>(img_grad,
img, intensity_map, pts, grad_eps,
n_pix, h, w, pix_mult_factor);
}
}
template<typename ScalarType>
void getWarpedImgHess(PixHessT &warped_img_hess,
const cv::Mat &img, bool weighted_mapping, const VectorXd &intensity_map,
const PtsT &warped_pts, const HessPtsT &warped_offset_pts,
double hess_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor){
if(weighted_mapping){
getWarpedImgHess<ScalarType, InterpType::Linear>(warped_img_hess,
img, intensity_map,
warped_pts, warped_offset_pts,
hess_eps, n_pix, h, w, pix_mult_factor);
} else{
getWarpedImgHess<ScalarType, InterpType::Nearest>(warped_img_hess,
img, intensity_map,
warped_pts, warped_offset_pts,
hess_eps, n_pix, h, w, pix_mult_factor);
}
}
template<typename ScalarType>
void getImgHess(PixHessT &img_hess, const cv::Mat &img, bool weighted_mapping,
const VectorXd &intensity_map, const PtsT &pts, double hess_eps,
unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor){
if(weighted_mapping){
getImgHess<ScalarType, InterpType::Linear>(img_hess, img, intensity_map, pts,
hess_eps, n_pix, h, w, pix_mult_factor);
} else{
getImgHess<ScalarType, InterpType::Nearest>(img_hess, img, intensity_map, pts,
hess_eps, n_pix, h, w, pix_mult_factor);
}
}
}
// ******************************************************************************* //
// ************ functions for cubic BSpline and bicubic interpolation ************ //
// ******************************************************************************* //
bool getNeighboringPixGrid(Matrix4d &pix_grid, const EigImgT &img, double x, double y,
unsigned int h, unsigned int w){
assert(img.rows() == h && img.cols() == w);
if(checkOverflow(x, y, h, w)){
return false;
}
unsigned int x1 = static_cast<int>(x);
unsigned int y1 = static_cast<int>(y);
unsigned int x2 = x1 + 1;
unsigned int y2 = y1 + 1;
if(checkOverflow(x1, y1, h, w) || checkOverflow(x2, y2, h, w)){
return false;
}
pix_grid(1, 1) = img(y1, x1), pix_grid(1, 2) = img(y1, x2);
pix_grid(2, 1) = img(y2, x1), pix_grid(2, 2) = img(y2, x2);
unsigned int x0 = x1 - 1, x3 = x2 + 1;
unsigned int y0 = y1 - 1, y3 = y2 + 1;
bool ul = true, ur = true, lr = true, ll = true;
if(y0 < 0){
ul = ur = false;
pix_grid(0, 1) = pix_grid(1, 1);
pix_grid(0, 2) = pix_grid(1, 2);
} else{
pix_grid(0, 1) = img(y0, x1);
pix_grid(0, 2) = img(y0, x2);
}
if(y3 >= h){
ll = lr = false;
pix_grid(3, 1) = pix_grid(2, 1);
pix_grid(3, 2) = pix_grid(2, 2);
} else{
pix_grid(3, 1) = img(y3, x1);
pix_grid(3, 2) = img(y3, x2);
}
if(x0 < 0){
ul = ll = false;
pix_grid(1, 0) = pix_grid(1, 1);
pix_grid(2, 0) = pix_grid(2, 1);
} else{
pix_grid(1, 0) = img(y1, x0);
pix_grid(2, 0) = img(y2, x0);
}
if(x3 >= w){
ur = lr = false;
pix_grid(1, 3) = pix_grid(1, 2);
pix_grid(2, 3) = pix_grid(2, 2);
} else{
pix_grid(1, 3) = img(y1, x3);
pix_grid(2, 3) = img(y2, x3);
}
pix_grid(0, 0) = ul ? img(y0, x0) : pix_grid(1, 1);
pix_grid(0, 3) = ur ? img(y0, x3) : pix_grid(1, 2);
pix_grid(3, 3) = lr ? img(y3, x3) : pix_grid(2, 2);
pix_grid(3, 0) = ll ? img(y3, x0) : pix_grid(2, 1);
return true;
}
void getBiCubicCoefficients(Matrix4d &bicubic_coeff, const Matrix4d &pix_grid){
bicubic_coeff(0, 0) = pix_grid(1, 1);
bicubic_coeff(0, 1) = -.5*pix_grid(1, 0) + .5*pix_grid(1, 2);
bicubic_coeff(0, 2) = pix_grid(1, 0) - 2.5*pix_grid(1, 1) + 2 * pix_grid(1, 2) - .5*pix_grid(1, 3);
bicubic_coeff(0, 3) = -.5*pix_grid(1, 0) + 1.5*pix_grid(1, 1) - 1.5*pix_grid(1, 2) + .5*pix_grid(1, 3);
bicubic_coeff(1, 0) = -.5*pix_grid(0, 1) + .5*pix_grid(2, 1);
bicubic_coeff(1, 1) = .25*pix_grid(0, 0) - .25*pix_grid(0, 2) - .25*pix_grid(2, 0) + .25*pix_grid(2, 2);
bicubic_coeff(1, 2) = -.5*pix_grid(0, 0) + 1.25*pix_grid(0, 1) - pix_grid(0, 2) + .25*pix_grid(0, 3) + .5*pix_grid(2, 0) - 1.25*pix_grid(2, 1) + pix_grid(2, 2) - .25*pix_grid(2, 3);
bicubic_coeff(1, 3) = .25*pix_grid(0, 0) - .75*pix_grid(0, 1) + .75*pix_grid(0, 2) - .25*pix_grid(0, 3) - .25*pix_grid(2, 0) + .75*pix_grid(2, 1) - .75*pix_grid(2, 2) + .25*pix_grid(2, 3);
bicubic_coeff(2, 0) = pix_grid(0, 1) - 2.5*pix_grid(1, 1) + 2 * pix_grid(2, 1) - .5*pix_grid(3, 1);
bicubic_coeff(2, 1) = -.5*pix_grid(0, 0) + .5*pix_grid(0, 2) + 1.25*pix_grid(1, 0) - 1.25*pix_grid(1, 2) - pix_grid(2, 0) + pix_grid(2, 2) + .25*pix_grid(3, 0) - .25*pix_grid(3, 2);
bicubic_coeff(2, 2) = pix_grid(0, 0) - 2.5*pix_grid(0, 1) + 2 * pix_grid(0, 2) - .5*pix_grid(0, 3) - 2.5*pix_grid(1, 0) + 6.25*pix_grid(1, 1) - 5 * pix_grid(1, 2) + 1.25*pix_grid(1, 3) + 2 * pix_grid(2, 0) - 5 * pix_grid(2, 1) + 4 * pix_grid(2, 2) - pix_grid(2, 3) - .5*pix_grid(3, 0) + 1.25*pix_grid(3, 1) - pix_grid(3, 2) + .25*pix_grid(3, 3);
bicubic_coeff(2, 3) = -.5*pix_grid(0, 0) + 1.5*pix_grid(0, 1) - 1.5*pix_grid(0, 2) + .5*pix_grid(0, 3) + 1.25*pix_grid(1, 0) - 3.75*pix_grid(1, 1) + 3.75*pix_grid(1, 2) - 1.25*pix_grid(1, 3) - pix_grid(2, 0) + 3 * pix_grid(2, 1) - 3 * pix_grid(2, 2) + pix_grid(2, 3) + .25*pix_grid(3, 0) - .75*pix_grid(3, 1) + .75*pix_grid(3, 2) - .25*pix_grid(3, 3);
bicubic_coeff(3, 0) = -.5*pix_grid(0, 1) + 1.5*pix_grid(1, 1) - 1.5*pix_grid(2, 1) + .5*pix_grid(3, 1);
bicubic_coeff(3, 1) = .25*pix_grid(0, 0) - .25*pix_grid(0, 2) - .75*pix_grid(1, 0) + .75*pix_grid(1, 2) + .75*pix_grid(2, 0) - .75*pix_grid(2, 2) - .25*pix_grid(3, 0) + .25*pix_grid(3, 2);
bicubic_coeff(3, 2) = -.5*pix_grid(0, 0) + 1.25*pix_grid(0, 1) - pix_grid(0, 2) + .25*pix_grid(0, 3) + 1.5*pix_grid(1, 0) - 3.75*pix_grid(1, 1) + 3 * pix_grid(1, 2) - .75*pix_grid(1, 3) - 1.5*pix_grid(2, 0) + 3.75*pix_grid(2, 1) - 3 * pix_grid(2, 2) + .75*pix_grid(2, 3) + .5*pix_grid(3, 0) - 1.25*pix_grid(3, 1) + pix_grid(3, 2) - .25*pix_grid(3, 3);
bicubic_coeff(3, 3) = .25*pix_grid(0, 0) - .75*pix_grid(0, 1) + .75*pix_grid(0, 2) - .25*pix_grid(0, 3) - .75*pix_grid(1, 0) + 2.25*pix_grid(1, 1) - 2.25*pix_grid(1, 2) + .75*pix_grid(1, 3) + .75*pix_grid(2, 0) - 2.25*pix_grid(2, 1) + 2.25*pix_grid(2, 2) - .75*pix_grid(2, 3) - .25*pix_grid(3, 0) + .75*pix_grid(3, 1) - .75*pix_grid(3, 2) + .25*pix_grid(3, 3);
}
//evaluates the cubic polynomial surface defines by the given parameters at the given location
double biCubic(const Matrix4d &bicubic_coeff, double x, double y) {
double x2 = x * x;
double x3 = x2 * x;
double y2 = y * y;
double y3 = y2 * y;
return (bicubic_coeff(0, 0) + bicubic_coeff(0, 1) * y + bicubic_coeff(0, 2) * y2 + bicubic_coeff(0, 3) * y3) +
(bicubic_coeff(1, 0) + bicubic_coeff(1, 1) * y + bicubic_coeff(1, 2) * y2 + bicubic_coeff(1, 3) * y3) * x +
(bicubic_coeff(2, 0) + bicubic_coeff(2, 1) * y + bicubic_coeff(2, 2)* y2 + bicubic_coeff(2, 3) * y3) * x2 +
(bicubic_coeff(3, 0) + bicubic_coeff(3, 1) * y + bicubic_coeff(3, 2) * y2 + bicubic_coeff(3, 3) * y3) * x3;
}
//evaluates the gradient of cubic polynomial surface defines by the given parameters at the given location
double biCubicGradX(Vector2d &grad, const Matrix4d &bicubic_coeff, double x, double y) {
double x2 = x * x;
double y2 = y * y;
double y3 = y2 * y;
return (bicubic_coeff(1, 0) + bicubic_coeff(1, 1) * y + bicubic_coeff(1, 2) * y2 + bicubic_coeff(1, 3) * y3) +
(bicubic_coeff(2, 0) + bicubic_coeff(2, 1) * y + bicubic_coeff(2, 2)* y2 + bicubic_coeff(2, 3) * y3) * 2 * x +
(bicubic_coeff(3, 0) + bicubic_coeff(3, 1) * y + bicubic_coeff(3, 2) * y2 + bicubic_coeff(3, 3) * y3) * 3 * x2;
}
double biCubicGradY(Vector2d &grad, const Matrix4d &bicubic_coeff, double x, double y) {
double x2 = x * x;
double x3 = x2 * x;
double y2 = y * y;
return (bicubic_coeff(0, 1) + bicubic_coeff(1, 1) * x + bicubic_coeff(2, 1) * x2 + bicubic_coeff(3, 1) * x3) +
(bicubic_coeff(0, 2) + bicubic_coeff(1, 2) * x + bicubic_coeff(2, 2)* x2 + bicubic_coeff(3, 2) * x3) * 2 * y +
(bicubic_coeff(0, 3) + bicubic_coeff(1, 3) * x + bicubic_coeff(2, 3) * x2 + bicubic_coeff(3, 3) * x3) * 3 * y2;
}
//evaluates the hessian of the cubic polynomial surface defines by the given parameters at the given location
double biCubicHessXX(const Matrix4d &bicubic_coeff, double x, double y) {
double y2 = y * y;
double y3 = y2 * y;
return 2 * (bicubic_coeff(2, 0) + bicubic_coeff(2, 1) * y + bicubic_coeff(2, 2)* y2 + bicubic_coeff(2, 3) * y3) +
6 * x*(bicubic_coeff(3, 0) + bicubic_coeff(3, 1) * y + bicubic_coeff(3, 2) * y2 + bicubic_coeff(3, 3) * y3);
}
double biCubicHessYY(const Matrix4d &bicubic_coeff, double x, double y) {
double x2 = x * x;
double x3 = x2 * x;
return 2 * (bicubic_coeff(0, 2) + bicubic_coeff(1, 2) * x + bicubic_coeff(2, 2)* x2 + bicubic_coeff(3, 2) * x3) +
6 * y*(bicubic_coeff(0, 3) + bicubic_coeff(1, 3) * x + bicubic_coeff(2, 3) * x2 + bicubic_coeff(3, 3) * x3);
}
double biCubicHessYX(const Matrix4d &bicubic_coeff, double x, double y) {
double x2 = x * x;
double y2 = y * y;
double y2d = 2 * y, y3d = 3 * y2;
return (bicubic_coeff(1, 1) + bicubic_coeff(1, 2) * y2d + bicubic_coeff(1, 3) * y3d) +
(bicubic_coeff(2, 1) + bicubic_coeff(2, 2)* y2d + bicubic_coeff(2, 3) * y3d) * 2 * x +
(bicubic_coeff(3, 1) + bicubic_coeff(3, 2) * y2d + bicubic_coeff(3, 3) * y3d) * 3 * x2;
}
double biCubicHessXY(const Matrix4d &bicubic_coeff, double x, double y) {
double y2 = y * y;
double y3 = y * y2;
double x2 = x * x;
double x2d = 2 * x, x3d = 3 * x2;
return (bicubic_coeff(1, 1) + bicubic_coeff(2, 1) * x2d + bicubic_coeff(3, 1) * x3d) +
(bicubic_coeff(1, 2) + bicubic_coeff(2, 2)* x2d + bicubic_coeff(3, 2) * x3d) * 2 * y +
(bicubic_coeff(1, 3) + bicubic_coeff(2, 3) * x2d + bicubic_coeff(3, 3) * x3d) * 3 * y2;
}
cv::Mat convertFloatImgToUchar(cv::Mat &img, int nchannels){
cv::Mat imgU;
double minVal;
double maxVal;
cv::Point minLoc;
cv::Point maxLoc;
if(nchannels == 1){
cv::minMaxLoc(img, &minVal, &maxVal, &minLoc, &maxLoc);
img -= minVal;
img.convertTo(imgU, CV_8UC1, 255.0 / (maxVal - minVal));
} else {
cv::Mat planes[3];
cv::split(img, planes);
cv::minMaxLoc(planes[0], &minVal, &maxVal, &minLoc, &maxLoc);
img.convertTo(imgU, CV_8UC3, 255.0 / (maxVal - minVal));
}
return imgU;
}
void generateWarpedImg(cv::Mat &warped_img, const cv::Mat &warped_corners,
const mtf::PtsT &warped_pts, const mtf::PixValT orig_patch,
const cv::Mat &orig_img, unsigned int img_width, unsigned int img_height,
unsigned int n_pts, int background_type, bool show_warped_img, const char* win_name){
double inf = std::numeric_limits<double>::infinity();
double max_x = -inf, min_x = inf, max_y = -inf, min_y = inf;
for(unsigned int pt_id = 0; pt_id < n_pts; ++pt_id){
if(warped_pts(0, pt_id) > max_x){
max_x = warped_pts(0, pt_id);
}
if(warped_pts(0, pt_id) < min_x){
min_x = warped_pts(0, pt_id);
}
if(warped_pts(1, pt_id) > max_y){
max_y = warped_pts(1, pt_id);
}
if(warped_pts(1, pt_id) < min_y){
min_y = warped_pts(1, pt_id);
}
}
//printf("min_x: %f max_x: %f min_y: %f max_y: %f\n", min_x, max_x, min_y, max_y);
for(unsigned int row_id = 0; row_id < img_height; ++row_id){
for(unsigned int col_id = 0; col_id < img_width; ++col_id){
if(row_id < min_y || row_id > max_y ||
col_id < min_x || col_id > max_x ||
!mtf::utils::isInsideRegion(warped_corners, col_id, row_id)){
if(background_type){
if(warped_img.type() == CV_8UC3){
warped_img.at<cv::Vec3b>(row_id, col_id) =
orig_img.at<cv::Vec3f>(row_id, col_id);
} else{
warped_img.at<uchar>(row_id, col_id) =
static_cast<uchar>(orig_img.at<float>(row_id, col_id));
}
}
} else{
cv::Vec4i neigh_pts_id;
std::vector<cv::Vec2d> neigh_pts_dist(4);
mtf::utils::getBilinearPts(neigh_pts_id, neigh_pts_dist, col_id, row_id, warped_pts, n_pts);
if(neigh_pts_id[0] < 0 || neigh_pts_id[1] < 0 || neigh_pts_id[2] < 0 || neigh_pts_id[3] < 0){
//printf("neigh_pts_id: %d %d %d %d\n", neigh_pts_id[0], neigh_pts_id[1],
// neigh_pts_id[2], neigh_pts_id[3]);
if(warped_img.type() == CV_8UC3){
warped_img.at<cv::Vec3b>(row_id, col_id) =
orig_img.at<cv::Vec3f>(row_id, col_id);
} else{
warped_img.at<uchar>(row_id, col_id) =
static_cast<uchar>(orig_img.at<float>(row_id, col_id));
}
//throw LogicError("Neighboring points ID are invalid");
} else{
//int ulx = original_pts(0, neigh_pts_id[0]), uly = original_pts(1, neigh_pts_id[0]);
//int urx = original_pts(0, neigh_pts_id[1]), ury = original_pts(1, neigh_pts_id[1]);
//int lrx = original_pts(0, neigh_pts_id[2]), lry = original_pts(1, neigh_pts_id[2]);
//int llx = original_pts(0, neigh_pts_id[3]), lly = original_pts(1, neigh_pts_id[3]);
//const cv::Vec3b& pix_ul = orig_img.at<cv::Vec3b>(uly, ulx);
//const cv::Vec3b& pix_ur = orig_img.at<cv::Vec3b>(ury, urx);
//const cv::Vec3b& pix_lr = orig_img.at<cv::Vec3b>(lry, lrx);
//const cv::Vec3b& pix_ll = orig_img.at<cv::Vec3b>(lly, llx);
double dist_sum_x = neigh_pts_dist[0][0] + neigh_pts_dist[1][0] + neigh_pts_dist[2][0] + neigh_pts_dist[3][0];
double dist_sum_y = neigh_pts_dist[0][1] + neigh_pts_dist[1][1] + neigh_pts_dist[2][1] + neigh_pts_dist[3][1];
double wt_ul = (dist_sum_x - neigh_pts_dist[0][0]) * (dist_sum_y - neigh_pts_dist[0][1]);
double wt_ur = (dist_sum_x - neigh_pts_dist[1][0]) * (dist_sum_y - neigh_pts_dist[1][1]);
double wt_lr = (dist_sum_x - neigh_pts_dist[2][0]) * (dist_sum_y - neigh_pts_dist[2][1]);
double wt_ll = (dist_sum_x - neigh_pts_dist[3][0]) * (dist_sum_y - neigh_pts_dist[3][1]);
double wt_sum = wt_ul + wt_ur + wt_lr + wt_ll;
//printf("neigh_pts_id:\n");
//for(int pt_id = 0; pt_id < 4; ++pt_id){
// printf("%d ", neigh_pts_id[pt_id]);
//}
//printf("\n");
//printf("neigh_pts_dist:\n");
//for(int pt_id = 0; pt_id < 4; ++pt_id){
// printf("%f %f\n", neigh_pts_dist[pt_id][0], neigh_pts_dist[pt_id][1]);
//}
if(warped_img.type() == CV_8UC3){
cv::Vec3d orig_pix_vals[4];
//printf("orig_pix_vals:\n");
for(unsigned int pt_id = 0; pt_id < 4; ++pt_id){
for(unsigned int channel_id = 0; channel_id < 3; ++channel_id){
orig_pix_vals[pt_id][channel_id] = orig_patch[neigh_pts_id[pt_id] * 3 + channel_id];
//printf("%f\t", orig_pix_vals[pt_id][channel_id]);
}
//printf("\n");
}
cv::Vec3b pix_val;
pix_val[0] = static_cast<uchar>((
orig_pix_vals[0][0] * wt_ul +
orig_pix_vals[1][0] * wt_ur +
orig_pix_vals[2][0] * wt_lr +
orig_pix_vals[3][0] * wt_ll
) / wt_sum);
pix_val[1] = static_cast<uchar>((
orig_pix_vals[0][1] * wt_ul +
orig_pix_vals[1][1] * wt_ur +
orig_pix_vals[2][1] * wt_lr +
orig_pix_vals[3][1] * wt_ll
) / wt_sum);
pix_val[2] = static_cast<uchar>((
orig_pix_vals[0][2] * wt_ul +
orig_pix_vals[1][2] * wt_ur +
orig_pix_vals[2][2] * wt_lr +
orig_pix_vals[3][2] * wt_ll
) / wt_sum);
warped_img.at<cv::Vec3b>(row_id, col_id) = pix_val;
} else{
double orig_pix_vals[4];
//printf("orig_pix_vals:\n");
for(unsigned int pt_id = 0; pt_id < 4; ++pt_id){
orig_pix_vals[pt_id] = orig_patch[neigh_pts_id[pt_id]];
}
double pix_val = (
orig_pix_vals[0] * wt_ul +
orig_pix_vals[1] * wt_ur +
orig_pix_vals[2] * wt_lr +
orig_pix_vals[3] * wt_ll
) / wt_sum;
warped_img.at<uchar>(row_id, col_id) = static_cast<uchar>(pix_val);
}
}
}
}
if(show_warped_img){
cv::imshow("warped_img", warped_img);
if(cv::waitKey(1) == 27){ break; }
}
}
}
template<typename ScalarType>
void generateInverseWarpedImg(cv::Mat &warped_img, const mtf::PtsT &warped_pts,
const cv::Mat &orig_img, const mtf::PtsT &orig_pts, int img_width, int img_height,
int n_pts, bool show_warped_img, const char* win_name){
assert(n_pts == img_width*img_height);
for(unsigned int pt_id = 0; pt_id < n_pts; ++pt_id){
int col_id = pt_id % img_width;
int row_id = pt_id / img_width;
//printf("col_id: %5d row_id: %5d\n", col_id, row_id);
//printf("orig_x: %5.1f orig_y: %5.1f\n", orig_pts(0, pt_id),
// orig_pts(1, pt_id));
if(warped_img.type() == CV_8UC3){
double pix_vals[3];
mc::PixVal<ScalarType, PIX_INTERP_TYPE, PIX_BORDER_TYPE>::get(pix_vals, orig_img,
warped_pts(0, pt_id), warped_pts(1, pt_id), img_height, img_width);
for(unsigned int channel_id = 0; channel_id < 3; ++channel_id){
pix_vals[channel_id] = min(255.0, pix_vals[channel_id]);
pix_vals[channel_id] = max(0.0, pix_vals[channel_id]);
}
warped_img.at<cv::Vec3b>(row_id, col_id) = cv::Vec3b(pix_vals[0], pix_vals[1], pix_vals[2]);
} else{
double pix_val = sc::PixVal<ScalarType, PIX_INTERP_TYPE, PIX_BORDER_TYPE>::get(orig_img,
warped_pts(0, pt_id), warped_pts(1, pt_id), img_height, img_width);
pix_val = min(255.0, pix_val);
pix_val = max(0.0, pix_val);
warped_img.at<uchar>(row_id, col_id) = static_cast<uchar>(pix_val);
}
//const cv::Vec3b &dst_pix_vals = warped_img.at<cv::Vec3b>(orig_pts(1, pt_id), orig_pts(0, pt_id));
//printf("pix_vals %d: %f, %f, %f\n", pt_id, pix_vals[0], pix_vals[1], pix_vals[2]);
//printf("warped_img %d: %d, %d, %d\n", pt_id,
// dst_pix_vals(0), dst_pix_vals(1), dst_pix_vals(2));
if(show_warped_img && pt_id % img_width == 0){
cv::imshow(win_name, warped_img);
if(cv::waitKey(1) == 27){ break; }
}
}
}
void generateInverseWarpedImg(cv::Mat &warped_img,
const PixValT &pix_vals, unsigned int img_width, unsigned int img_height,
unsigned int n_pts, bool show_warped_img, const char* win_name){
assert(n_pts == img_width*img_height);
assert((warped_img.type() == CV_8UC3 && pix_vals.size() == n_pts * 3) ||
(warped_img.type() == CV_8UC1 && pix_vals.size() == n_pts));
for(unsigned int pt_id = 0; pt_id < n_pts; ++pt_id){
unsigned int col_id = pt_id % img_width;
unsigned int row_id = pt_id / img_width;
if(warped_img.type() == CV_8UC3){
double pix_val[3];
for(unsigned int channel_id = 0; channel_id < 3; ++channel_id){
pix_val[channel_id] = pix_vals[pt_id * 3 + channel_id];
pix_val[channel_id] = min(255.0, pix_val[channel_id]);
pix_val[channel_id] = max(0.0, pix_val[channel_id]);
}
warped_img.at<cv::Vec3b>(row_id, col_id) =
cv::Vec3b(static_cast<uchar>(pix_val[0]),
static_cast<uchar>(pix_val[1]),
static_cast<uchar>(pix_val[2]));
} else{
double pix_val = pix_vals[pt_id];
pix_val = min(255.0, pix_val);
pix_val = max(0.0, pix_val);
warped_img.at<uchar>(row_id, col_id) = static_cast<uchar>(pix_val);
}
//const cv::Vec3b &dst_pix_vals = warped_img.at<cv::Vec3b>(orig_pts(1, pt_id), orig_pts(0, pt_id));
//printf("pix_vals %d: %f, %f, %f\n", pt_id, pix_vals[0], pix_vals[1], pix_vals[2]);
//printf("warped_img %d: %d, %d, %d\n", pt_id,
// dst_pix_vals(0), dst_pix_vals(1), dst_pix_vals(2));
if(show_warped_img && pt_id % img_width == 0){
cv::imshow(win_name, warped_img);
if(cv::waitKey(1) == 27){ break; }
}
}
}
template<class ScalarT>
inline uchar clamp(ScalarT pix){
return pix < 0 ? 0 : pix > 255 ? 255 : static_cast<uchar>(pix);
}
inline void writePixelToImage(cv::Mat &img, MatrixXd &min_dist,
int x, int y, const PixValT &pix_vals, int pt_id, double dist,
cv::Mat &mask, bool use_mask, int n_channels){
if(checkOverflow(x, y, img.rows, img.cols)){ return; }
if(min_dist(y, x) >= 0 && min_dist(y, x) < dist){ return; }
if(use_mask && mask.at<uchar>(y, x) && min_dist(y, x) < 0){ return; }
//printf("here we are\n");
min_dist(y, x) = dist;
switch(n_channels){
case 1:
img.at<uchar>(y, x) = clamp(pix_vals(pt_id));
break;
case 3:
img.at<cv::Vec3b>(y, x) = cv::Vec3b(
static_cast<uchar>(pix_vals(pt_id*n_channels)),
static_cast<uchar>(pix_vals(pt_id*n_channels + 1)),
static_cast<uchar>(pix_vals(pt_id*n_channels + 2)));
break;
default:
throw InvalidArgument(
cv::format("Invalid channel count provided: %d", n_channels));
}
if(use_mask){ mask.at<uchar>(y, x) = 255; }
}
void writePixelsToImage(cv::Mat &img,
const PixValT &pix_vals, const mtf::PtsT &pts,
unsigned int n_channels, cv::Mat &mask){
unsigned int n_pts = pts.cols();
assert(pix_vals.size() == n_pts*n_channels);
bool use_mask = !mask.empty();
MatrixXd min_dist(img.rows, img.cols);
min_dist.fill(-1);
for(unsigned int pt_id = 0; pt_id < n_pts; ++pt_id){
int min_x = static_cast<int>(pts(0, pt_id));
int min_y = static_cast<int>(pts(1, pt_id));
int max_x = min_x + 1;
int max_y = min_y + 1;
double dx = pts(0, pt_id) - min_x, dy = pts(1, pt_id) - min_y;
double dist_x_min = dx*dx, dist_x_max = (1 - dx)*(1 - dx);
double dist_y_min = dy*dy, dist_y_max = (1 - dy)*(1 - dy);
writePixelToImage(img, min_dist, min_x, min_y, pix_vals, pt_id,
dist_x_min + dist_y_min, mask, use_mask, n_channels);
writePixelToImage(img, min_dist, max_x, min_y, pix_vals, pt_id,
dist_x_max + dist_y_min, mask, use_mask, n_channels);
writePixelToImage(img, min_dist, max_x, max_y, pix_vals, pt_id,
dist_x_max + dist_y_max, mask, use_mask, n_channels);
writePixelToImage(img, min_dist, min_x, max_y, pix_vals, pt_id,
dist_x_min + dist_y_max, mask, use_mask, n_channels);
}
}
void writePixelsToImage(cv::Mat &img, const cv::Mat &pix_vals,
const mtf::PtsT &pts, int n_channels, cv::Mat &mask){
int img_size = pix_vals.rows*pix_vals.cols*n_channels;
writePixelsToImage(img, PixValT(Map<VectorXc>(pix_vals.data, img_size).cast<double>()),
pts, n_channels, mask);
}
void writePixelsToImage(cv::Mat &img, const cv::Mat &pix_vals,
const mtf::CornersT &corners, int n_channels, cv::Mat &mask){
int img_size = pix_vals.rows*pix_vals.cols*n_channels;
writePixelsToImage(img, PixValT(Map<VectorXc>(pix_vals.data, img_size).cast<double>()),
getPtsFromCorners(corners, pix_vals.cols, pix_vals.rows), n_channels, mask);
}
void writePixelsToImage(cv::Mat &img, const cv::Mat &pix_vals,
const cv::Mat &corners, int n_channels, cv::Mat &mask){
int img_size = pix_vals.rows*pix_vals.cols*n_channels;
writePixelsToImage(img, PixValT(Map<VectorXc>(pix_vals.data, img_size).cast<double>()),
getPtsFromCorners(corners, pix_vals.cols, pix_vals.rows), n_channels, mask);
}
//! adapted from http://answers.opencv.org/question/68589/adding-noise-to-image-opencv/
bool addGaussianNoise(const cv::Mat mSrc, cv::Mat &mDst,
int n_channels, double Mean, double StdDev){
if(mSrc.empty()){
printf("addGaussianNoise:: Error: Input Image is empty!");
return false;
}
cv::Mat mSrc_16SC;
cv::Mat mGaussian_noise(mSrc.size(), n_channels == 1 ? CV_16SC1 : CV_16SC3);
cv::randn(mGaussian_noise, cv::Scalar::all(Mean), cv::Scalar::all(StdDev));
mSrc.convertTo(mSrc_16SC, n_channels == 1 ? CV_16SC1 : CV_16SC3);
addWeighted(mSrc_16SC, 1.0, mGaussian_noise, 1.0, 0.0, mSrc_16SC);
mSrc_16SC.convertTo(mDst, mSrc.type());
return true;
}
cv::Mat reshapePatch(const VectorXd &curr_patch, int img_height, int img_width, int n_channels){
cv::Mat out_img_uchar(img_height, img_width, n_channels == 1 ? CV_8UC1 : CV_8UC3);
cv::Mat(img_height, img_width, n_channels == 1 ? CV_64FC1 : CV_64FC3,
const_cast<double*>(curr_patch.data())).convertTo(out_img_uchar, out_img_uchar.type());
return out_img_uchar;
}
VectorXd reshapePatch(const cv::Mat &cv_patch, int start_x, int start_y,
int end_x, int end_y){
int n_channels = cv_patch.type() == CV_8UC1 || cv_patch.type() == CV_32FC1 ? 1 : 3;
if(end_x < 0){ end_x = cv_patch.cols - 1; }
if(end_y < 0){ end_y = cv_patch.rows - 1; }
unsigned int n_pix = (end_x - start_x + 1)* (end_y - start_y + 1);
VectorXd eig_patch(n_pix);
int pix_id = -1;
if(n_channels == 1){
for(int y = start_y; y <= end_y; ++y){
for(int x = start_x; x <= end_x; ++x){
eig_patch(++pix_id) = cv_patch.at<uchar>(y, x);
}
}
} else{
for(int y = start_y; y <= end_y; ++y){
for(int x = start_x; x <= end_x; ++x){
cv::Vec3b pix = cv_patch.at<cv::Vec3b>(y, x);
eig_patch(++pix_id) = pix[0];
eig_patch(++pix_id) = pix[1];
eig_patch(++pix_id) = pix[2];
}
}
}
return eig_patch;
}
//! adapted from http://ishankgulati.github.io/posts/Anisotropic-(Perona-Malik)-Diffusion/
void anisotropicDiffusion(cv::Mat &output, double lambda, double k, unsigned int n_iters) {
float ahN[3][3] = { { 0, 1, 0 }, { 0, -1, 0 }, { 0, 0, 0 } };
float ahS[3][3] = { { 0, 0, 0 }, { 0, -1, 0 }, { 0, 1, 0 } };
float ahE[3][3] = { { 0, 0, 0 }, { 0, -1, 1 }, { 0, 0, 0 } };
float ahW[3][3] = { { 0, 0, 0 }, { 1, -1, 0 }, { 0, 0, 0 } };
float ahNE[3][3] = { { 0, 0, 1 }, { 0, -1, 0 }, { 0, 0, 0 } };
float ahSE[3][3] = { { 0, 0, 0 }, { 0, -1, 0 }, { 0, 0, 1 } };
float ahSW[3][3] = { { 0, 0, 0 }, { 0, -1, 0 }, { 1, 0, 0 } };
float ahNW[3][3] = { { 1, 0, 0 }, { 0, -1, 0 }, { 0, 0, 0 } };
cv::Mat hN(3, 3, CV_32FC1, &ahN);
cv::Mat hS(3, 3, CV_32FC1, &ahS);
cv::Mat hE(3, 3, CV_32FC1, &ahE);
cv::Mat hW(3, 3, CV_32FC1, &ahW);
cv::Mat hNE(3, 3, CV_32FC1, &ahNE);
cv::Mat hSE(3, 3, CV_32FC1, &ahSE);
cv::Mat hSW(3, 3, CV_32FC1, &ahSW);
cv::Mat hNW(3, 3, CV_32FC1, &ahNW);
//mat initialisation
cv::Mat nablaN, nablaS, nablaW, nablaE, nablaNE, nablaSE, nablaSW, nablaNW;
cv::Mat cN, cS, cW, cE, cNE, cSE, cSW, cNW;
//center pixel distance
const double dx = 1, dy = 1, dd = sqrt(2);
const double idxSqr = 1.0 / (dx * dx), idySqr = 1.0 / (dy * dy), iddSqr = 1 / (dd * dd);
for(unsigned int i = 0; i < n_iters; ++i) {
//filters
cv::filter2D(output, nablaN, -1, hN);
cv::filter2D(output, nablaS, -1, hS);
cv::filter2D(output, nablaW, -1, hW);
cv::filter2D(output, nablaE, -1, hE);
cv::filter2D(output, nablaNE, -1, hNE);
cv::filter2D(output, nablaSE, -1, hSE);
cv::filter2D(output, nablaSW, -1, hSW);
cv::filter2D(output, nablaNW, -1, hNW);
//exponential flux
cN = nablaN / k;
cN = cN.mul(cN);
cN = 1.0 / (1.0 + cN);
//exp(-cN, cN);
cS = nablaS / k;
cS = cS.mul(cS);
cS = 1.0 / (1.0 + cS);
//exp(-cS, cS);
cW = nablaW / k;
cW = cW.mul(cW);
cW = 1.0 / (1.0 + cW);
//exp(-cW, cW);
cE = nablaE / k;
cE = cE.mul(cE);
cE = 1.0 / (1.0 + cE);
//exp(-cE, cE);
cNE = nablaNE / k;
cNE = cNE.mul(cNE);
cNE = 1.0 / (1.0 + cNE);
//exp(-cNE, cNE);
cSE = nablaSE / k;
cSE = cSE.mul(cSE);
cSE = 1.0 / (1.0 + cSE);
//exp(-cSE, cSE);
cSW = nablaSW / k;
cSW = cSW.mul(cSW);
cSW = 1.0 / (1.0 + cSW);
//exp(-cSW, cSW);
cNW = nablaNW / k;
cNW = cNW.mul(cNW);
cNW = 1.0 / (1.0 + cNW);
//exp(-cNW, cNW);
output = output + lambda * (idySqr * cN.mul(nablaN) + idySqr * cS.mul(nablaS) +
idxSqr * cW.mul(nablaW) + idxSqr * cE.mul(nablaE) +
iddSqr * cNE.mul(nablaNE) + iddSqr * cSE.mul(nablaSE) +
iddSqr * cNW.mul(nablaNW) + iddSqr * cSW.mul(nablaSW));
}
}
/******************** Explicit Template Specializations ******************/
template
void getPixVals<PtsT>(VectorXd &pix_vals,
const EigImgT &img, const PtsT &pts, unsigned int n_pix, unsigned int h, unsigned int w,
double norm_mult, double norm_add);
template
void getWarpedImgGrad<InterpType::Nearest>(PixGradT &warped_img_grad,
const EigImgT &img, const VectorXd &intensity_map,
const Matrix8Xd &warped_offset_pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getWarpedImgGrad<InterpType::Linear>(PixGradT &warped_img_grad,
const EigImgT &img, const VectorXd &intensity_map,
const Matrix8Xd &warped_offset_pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgGrad<InterpType::Nearest>(PixGradT &img_grad, const EigImgT &img,
const VectorXd &intensity_map, const PtsT &pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w,
double pix_mult_factor);
template
void getImgGrad<InterpType::Linear>(PixGradT &img_grad, const EigImgT &img,
const VectorXd &intensity_map, const PtsT &pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getWarpedImgHess<InterpType::Nearest>(PixHessT &warped_img_hess,
const EigImgT &img, const VectorXd &intensity_map, const PtsT &warped_pts,
const HessPtsT &warped_offset_pts, double hess_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor);
template
void getWarpedImgHess<InterpType::Linear>(PixHessT &warped_img_hess,
const EigImgT &img, const VectorXd &intensity_map, const PtsT &warped_pts,
const HessPtsT &warped_offset_pts, double hess_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgHess<InterpType::Nearest>(PixHessT &img_hess, const EigImgT &img,
const VectorXd &intensity_map, const PtsT &pts, double hess_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgHess<InterpType::Linear>(PixHessT &img_hess, const EigImgT &img,
const VectorXd &intensity_map, const PtsT &pts, double hess_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor);
namespace sc{
//! OpenCV single channel floating point images
template
void getPixVals<float, PtsT>(VectorXd &pix_vals,
const cv::Mat &img, const PtsT &pts, unsigned int n_pix, unsigned int h, unsigned int w,
double norm_mult, double norm_add);
template
void getWeightedPixVals<float>(VectorXd &pix_vals, const cv::Mat &img, const PtsT &pts,
unsigned int frame_count, double alpha, bool use_running_avg, unsigned int n_pix,
unsigned int h, unsigned int w, double norm_mult, double norm_add);
template
void getWarpedImgHess<float>(PixHessT &warped_img_hess,
const cv::Mat &img, const PtsT &warped_pts,
const Matrix16Xd &warped_offset_pts, double hess_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor);
template
void getWarpedImgGrad<float>(PixGradT &warped_img_grad,
const cv::Mat &img, const Matrix8Xd &warped_offset_pts,
double grad_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgGrad<float>(PixGradT &img_grad,
const cv::Mat &img, const PtsT &pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w,
double pix_mult_factor);
template
void getImgHess<float>(PixHessT &img_hess, const cv::Mat &img,
const PtsT &pts, double hess_eps,
unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getWarpedImgGrad<float, InterpType::Nearest>(PixGradT &warped_img_grad,
const cv::Mat &img, const VectorXd &intensity_map,
const Matrix8Xd &warped_offset_pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getWarpedImgGrad<float, InterpType::Linear>(PixGradT &warped_img_grad,
const cv::Mat &img, const VectorXd &intensity_map,
const Matrix8Xd &warped_offset_pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgGrad<float, InterpType::Nearest>(PixGradT &img_grad, const cv::Mat &img,
const VectorXd &intensity_map, const PtsT &pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w,
double pix_mult_factor);
template
void getImgGrad<float, InterpType::Linear>(PixGradT &img_grad, const cv::Mat &img,
const VectorXd &intensity_map, const PtsT &pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getWarpedImgHess<float, InterpType::Nearest>(PixHessT &warped_img_hess,
const cv::Mat &img, const VectorXd &intensity_map, const PtsT &warped_pts,
const HessPtsT &warped_offset_pts, double hess_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor);
template
void getWarpedImgHess<float, InterpType::Linear>(PixHessT &warped_img_hess,
const cv::Mat &img, const VectorXd &intensity_map, const PtsT &warped_pts,
const HessPtsT &warped_offset_pts, double hess_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgHess<float, InterpType::Nearest>(PixHessT &img_hess, const cv::Mat &img, const VectorXd &intensity_map,
const PtsT &pts, double hess_eps, unsigned int n_pix, unsigned int h, unsigned int w,
double pix_mult_factor);
template
void getImgHess<float, InterpType::Linear>(PixHessT &img_hess, const cv::Mat &img, const VectorXd &intensity_map,
const PtsT &pts, double hess_eps, unsigned int n_pix, unsigned int h, unsigned int w,
double pix_mult_factor);
//! convenience functions to choose the mapping type
template
void getWarpedImgGrad<float>(PixGradT &warped_img_grad, const cv::Mat &img,
bool weighted_mapping, const VectorXd &intensity_map,
const Matrix8Xd &warped_offset_pts, double grad_eps,
unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgGrad<float>(PixGradT &img_grad, const cv::Mat &img,
bool weighted_mapping, const VectorXd &intensity_map,
const PtsT &pts, double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w,
double pix_mult_factor);
template
void getWarpedImgHess<float>(PixHessT &warped_img_hess,
const cv::Mat &img, bool weighted_mapping, const VectorXd &intensity_map,
const PtsT &warped_pts, const HessPtsT &warped_offset_pts,
double hess_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgHess<float>(PixHessT &img_hess, const cv::Mat &img, bool weighted_mapping,
const VectorXd &intensity_map, const PtsT &pts, double hess_eps,
unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
//! OpenCV single channel unsigned integral images
template
void getPixVals<uchar, PtsT>(VectorXd &pix_vals,
const cv::Mat &img, const PtsT &pts, unsigned int n_pix, unsigned int h, unsigned int w,
double norm_mult, double norm_add);
template
void getWeightedPixVals<uchar>(VectorXd &pix_vals, const cv::Mat &img, const PtsT &pts,
unsigned int frame_count, double alpha, bool use_running_avg, unsigned int n_pix,
unsigned int h, unsigned int w, double norm_mult, double norm_add);
template
void getWarpedImgGrad<uchar>(PixGradT &warped_img_grad,
const cv::Mat &img, const Matrix8Xd &warped_offset_pts,
double grad_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgGrad<uchar>(PixGradT &img_grad,
const cv::Mat &img, const PtsT &pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w,
double pix_mult_factor);
template
void getWarpedImgHess<uchar>(PixHessT &warped_img_hess,
const cv::Mat &img, const PtsT &warped_pts,
const Matrix16Xd &warped_offset_pts, double hess_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgHess<uchar>(PixHessT &img_hess, const cv::Mat &img,
const PtsT &pts, double hess_eps,
unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getWarpedImgGrad<uchar, InterpType::Nearest>(PixGradT &warped_img_grad,
const cv::Mat &img, const VectorXd &intensity_map,
const Matrix8Xd &warped_offset_pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getWarpedImgGrad<uchar, InterpType::Linear>(PixGradT &warped_img_grad,
const cv::Mat &img, const VectorXd &intensity_map,
const Matrix8Xd &warped_offset_pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgGrad<uchar, InterpType::Nearest>(PixGradT &img_grad, const cv::Mat &img,
const VectorXd &intensity_map, const PtsT &pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w,
double pix_mult_factor);
template
void getImgGrad<uchar, InterpType::Linear>(PixGradT &img_grad, const cv::Mat &img,
const VectorXd &intensity_map, const PtsT &pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getWarpedImgHess<uchar, InterpType::Nearest>(PixHessT &warped_img_hess,
const cv::Mat &img, const VectorXd &intensity_map, const PtsT &warped_pts,
const HessPtsT &warped_offset_pts, double hess_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor);
template
void getWarpedImgHess<uchar, InterpType::Linear>(PixHessT &warped_img_hess,
const cv::Mat &img, const VectorXd &intensity_map, const PtsT &warped_pts,
const HessPtsT &warped_offset_pts, double hess_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgHess<uchar, InterpType::Nearest>(PixHessT &img_hess, const cv::Mat &img, const VectorXd &intensity_map,
const PtsT &pts, double hess_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgHess<uchar, InterpType::Linear>(PixHessT &img_hess, const cv::Mat &img, const VectorXd &intensity_map,
const PtsT &pts, double hess_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
//! convenience functions to choose the mapping type
template
void getWarpedImgGrad<uchar>(PixGradT &warped_img_grad, const cv::Mat &img,
bool weighted_mapping, const VectorXd &intensity_map,
const Matrix8Xd &warped_offset_pts, double grad_eps,
unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgGrad<uchar>(PixGradT &img_grad, const cv::Mat &img,
bool weighted_mapping, const VectorXd &intensity_map,
const PtsT &pts, double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w,
double pix_mult_factor);
template
void getWarpedImgHess<uchar>(PixHessT &warped_img_hess,
const cv::Mat &img, bool weighted_mapping, const VectorXd &intensity_map,
const PtsT &warped_pts, const HessPtsT &warped_offset_pts,
double hess_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgHess<uchar>(PixHessT &img_hess, const cv::Mat &img, bool weighted_mapping,
const VectorXd &intensity_map, const PtsT &pts, double hess_eps,
unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
}
namespace mc{
//! OpenCV multi channel floating point images
template
void getPixVals<float, PtsT>(VectorXd &pix_vals,
const cv::Mat &img, const PtsT &pts, unsigned int n_pix, unsigned int h, unsigned int w,
double norm_mult, double norm_add);
template
void getWeightedPixVals<float>(VectorXd &pix_vals, const cv::Mat &img, const PtsT &pts,
unsigned int frame_count, double alpha, bool use_running_avg, unsigned int n_pix,
unsigned int h, unsigned int w, double norm_mult, double norm_add);
template
void getWarpedImgHess<float>(PixHessT &warped_img_hess,
const cv::Mat &img, const PtsT &warped_pts,
const Matrix16Xd &warped_offset_pts, double hess_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor);
template
void getWarpedImgGrad<float>(PixGradT &warped_img_grad,
const cv::Mat &img, const Matrix8Xd &warped_offset_pts,
double grad_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgGrad<float>(PixGradT &img_grad,
const cv::Mat &img, const PtsT &pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w,
double pix_mult_factor);
template
void getImgHess<float>(PixHessT &img_hess, const cv::Mat &img,
const PtsT &pts, double hess_eps,
unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getWarpedImgGrad<float, InterpType::Nearest>(PixGradT &warped_img_grad,
const cv::Mat &img, const VectorXd &intensity_map,
const Matrix8Xd &warped_offset_pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getWarpedImgGrad<float, InterpType::Linear>(PixGradT &warped_img_grad,
const cv::Mat &img, const VectorXd &intensity_map,
const Matrix8Xd &warped_offset_pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgGrad<float, InterpType::Nearest>(PixGradT &img_grad, const cv::Mat &img,
const VectorXd &intensity_map, const PtsT &pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w,
double pix_mult_factor);
template
void getImgGrad<float, InterpType::Linear>(PixGradT &img_grad, const cv::Mat &img,
const VectorXd &intensity_map, const PtsT &pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getWarpedImgHess<float, InterpType::Nearest>(PixHessT &warped_img_hess,
const cv::Mat &img, const VectorXd &intensity_map, const PtsT &warped_pts,
const HessPtsT &warped_offset_pts, double hess_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor);
template
void getWarpedImgHess<float, InterpType::Linear>(PixHessT &warped_img_hess,
const cv::Mat &img, const VectorXd &intensity_map, const PtsT &warped_pts,
const HessPtsT &warped_offset_pts, double hess_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgHess<float, InterpType::Nearest>(PixHessT &img_hess, const cv::Mat &img, const VectorXd &intensity_map,
const PtsT &pts, double hess_eps, unsigned int n_pix, unsigned int h, unsigned int w,
double pix_mult_factor);
template
void getImgHess<float, InterpType::Linear>(PixHessT &img_hess, const cv::Mat &img, const VectorXd &intensity_map,
const PtsT &pts, double hess_eps, unsigned int n_pix, unsigned int h, unsigned int w,
double pix_mult_factor);
//! convenience functions to choose the mapping type
template
void getWarpedImgGrad<float>(PixGradT &warped_img_grad, const cv::Mat &img,
bool weighted_mapping, const VectorXd &intensity_map,
const Matrix8Xd &warped_offset_pts, double grad_eps,
unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgGrad<float>(PixGradT &img_grad, const cv::Mat &img,
bool weighted_mapping, const VectorXd &intensity_map,
const PtsT &pts, double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w,
double pix_mult_factor);
template
void getWarpedImgHess<float>(PixHessT &warped_img_hess,
const cv::Mat &img, bool weighted_mapping, const VectorXd &intensity_map,
const PtsT &warped_pts, const HessPtsT &warped_offset_pts,
double hess_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgHess<float>(PixHessT &img_hess, const cv::Mat &img, bool weighted_mapping,
const VectorXd &intensity_map, const PtsT &pts, double hess_eps,
unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
//! OpenCV multi channel unsigned integral images
template
void getPixVals<uchar, PtsT>(VectorXd &pix_vals,
const cv::Mat &img, const PtsT &pts, unsigned int n_pix, unsigned int h, unsigned int w,
double norm_mult, double norm_add);
template
void getWeightedPixVals<uchar>(VectorXd &pix_vals, const cv::Mat &img, const PtsT &pts,
unsigned int frame_count, double alpha, bool use_running_avg, unsigned int n_pix,
unsigned int h, unsigned int w, double norm_mult, double norm_add);
template
void getWarpedImgGrad<uchar>(PixGradT &warped_img_grad,
const cv::Mat &img, const Matrix8Xd &warped_offset_pts,
double grad_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgGrad<uchar>(PixGradT &img_grad,
const cv::Mat &img, const PtsT &pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w,
double pix_mult_factor);
template
void getWarpedImgHess<uchar>(PixHessT &warped_img_hess,
const cv::Mat &img, const PtsT &warped_pts,
const Matrix16Xd &warped_offset_pts, double hess_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgHess<uchar>(PixHessT &img_hess, const cv::Mat &img,
const PtsT &pts, double hess_eps,
unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getWarpedImgGrad<uchar, InterpType::Nearest>(PixGradT &warped_img_grad,
const cv::Mat &img, const VectorXd &intensity_map,
const Matrix8Xd &warped_offset_pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getWarpedImgGrad<uchar, InterpType::Linear>(PixGradT &warped_img_grad,
const cv::Mat &img, const VectorXd &intensity_map,
const Matrix8Xd &warped_offset_pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgGrad<uchar, InterpType::Nearest>(PixGradT &img_grad, const cv::Mat &img,
const VectorXd &intensity_map, const PtsT &pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w,
double pix_mult_factor);
template
void getImgGrad<uchar, InterpType::Linear>(PixGradT &img_grad, const cv::Mat &img,
const VectorXd &intensity_map, const PtsT &pts,
double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getWarpedImgHess<uchar, InterpType::Nearest>(PixHessT &warped_img_hess,
const cv::Mat &img, const VectorXd &intensity_map, const PtsT &warped_pts,
const HessPtsT &warped_offset_pts, double hess_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor);
template
void getWarpedImgHess<uchar, InterpType::Linear>(PixHessT &warped_img_hess,
const cv::Mat &img, const VectorXd &intensity_map, const PtsT &warped_pts,
const HessPtsT &warped_offset_pts, double hess_eps, unsigned int n_pix,
unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgHess<uchar, InterpType::Nearest>(PixHessT &img_hess, const cv::Mat &img, const VectorXd &intensity_map,
const PtsT &pts, double hess_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgHess<uchar, InterpType::Linear>(PixHessT &img_hess, const cv::Mat &img, const VectorXd &intensity_map,
const PtsT &pts, double hess_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
//! convenience functions to choose the mapping type
template
void getWarpedImgGrad<uchar>(PixGradT &warped_img_grad, const cv::Mat &img,
bool weighted_mapping, const VectorXd &intensity_map,
const Matrix8Xd &warped_offset_pts, double grad_eps,
unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgGrad<uchar>(PixGradT &img_grad, const cv::Mat &img,
bool weighted_mapping, const VectorXd &intensity_map,
const PtsT &pts, double grad_eps, unsigned int n_pix, unsigned int h, unsigned int w,
double pix_mult_factor);
template
void getWarpedImgHess<uchar>(PixHessT &warped_img_hess,
const cv::Mat &img, bool weighted_mapping, const VectorXd &intensity_map,
const PtsT &warped_pts, const HessPtsT &warped_offset_pts,
double hess_eps, unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
template
void getImgHess<uchar>(PixHessT &img_hess, const cv::Mat &img, bool weighted_mapping,
const VectorXd &intensity_map, const PtsT &pts, double hess_eps,
unsigned int n_pix, unsigned int h, unsigned int w, double pix_mult_factor);
}
}
_MTF_END_NAMESPACE
| 50.026875 | 363 | 0.688455 | [
"vector"
] |
756a555f2432a74302f57e1bbb502431641d8200 | 8,923 | cpp | C++ | Source/AllProjects/Drivers/ZWave/ZWaveUSB3/Shared/ZWaveUSB3Sh_DrvXData.cpp | MarkStega/CQC | c1d0e01ec2abcaa5b8eb1899b9f0522fecee4b07 | [
"MIT"
] | 51 | 2020-12-26T18:17:16.000Z | 2022-03-15T04:29:35.000Z | Source/AllProjects/Drivers/ZWave/ZWaveUSB3/Shared/ZWaveUSB3Sh_DrvXData.cpp | MarkStega/CQC | c1d0e01ec2abcaa5b8eb1899b9f0522fecee4b07 | [
"MIT"
] | null | null | null | Source/AllProjects/Drivers/ZWave/ZWaveUSB3/Shared/ZWaveUSB3Sh_DrvXData.cpp | MarkStega/CQC | c1d0e01ec2abcaa5b8eb1899b9f0522fecee4b07 | [
"MIT"
] | 4 | 2020-12-28T07:24:39.000Z | 2021-12-29T12:09:37.000Z | //
// FILE NAME: ZWaveUSB3Sh_DriverXData.cpp
//
// AUTHOR: Dean Roddey
//
// CREATED: 08/17/2017
//
// COPYRIGHT: Charmed Quark Systems, Ltd @ 2020
//
// This software is copyrighted by 'Charmed Quark Systems, Ltd' and
// the author (Dean Roddey.) It is licensed under the MIT Open Source
// license:
//
// https://opensource.org/licenses/MIT
//
// DESCRIPTION:
//
// The implementation for our small Z-Wave class information class.
//
// CAVEATS/GOTCHAS:
//
// LOG:
//
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include "ZWaveUSB3Sh_.hpp"
// ---------------------------------------------------------------------------
// Magic macros
// ---------------------------------------------------------------------------
RTTIDecls(TZWDriverXData, TObject)
// ---------------------------------------------------------------------------
// Local types and constants
// ---------------------------------------------------------------------------
namespace ZWaveUSB3Sh_ZWDriverXData
{
const tCIDLib::TCard2 c2FmtVersion = 1;
}
// ---------------------------------------------------------------------------
// CLASS: TZWDriverXData
// PREFIX: zwdxd
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// TZWDriverXData: Constructors and Destructor
// ---------------------------------------------------------------------------
TZWDriverXData::TZWDriverXData()
{
Reset();
}
//
// When we first find out about a class being supported via discovery, this is
// all we know.
//
TZWDriverXData::TZWDriverXData(const TZWDriverXData& zwdxdSrc) :
m_bAwake(zwdxdSrc.m_bAwake)
, m_bFlag1(zwdxdSrc.m_bFlag1)
, m_bStatus(zwdxdSrc.m_bStatus)
, m_c1EPId(zwdxdSrc.m_c1EPId)
, m_c1UnitId(zwdxdSrc.m_c1UnitId)
, m_c1Val1(zwdxdSrc.m_c1Val1)
, m_c1Val2(zwdxdSrc.m_c1Val2)
, m_c4Val1(zwdxdSrc.m_c4Val1)
, m_c4BufSz(zwdxdSrc.m_c4BufSz)
, m_i4Val1(zwdxdSrc.m_i4Val1)
, m_mbufData(zwdxdSrc.m_mbufData)
, m_strCmd(zwdxdSrc.m_strCmd)
, m_strMsg(zwdxdSrc.m_strMsg)
{
}
TZWDriverXData::~TZWDriverXData()
{
}
// ---------------------------------------------------------------------------
// TZWDriverXData: Public operators
// ---------------------------------------------------------------------------
TZWDriverXData& TZWDriverXData::operator=(const TZWDriverXData& zwdxdSrc)
{
if (&zwdxdSrc != this)
{
m_bAwake = zwdxdSrc.m_bAwake;
m_bFlag1 = zwdxdSrc.m_bFlag1;
m_bStatus = zwdxdSrc.m_bStatus;
m_c1EPId = zwdxdSrc.m_c1EPId;
m_c1UnitId = zwdxdSrc.m_c1UnitId;
m_c1Val1 = zwdxdSrc.m_c1Val1;
m_c1Val2 = zwdxdSrc.m_c1Val2;
m_c4Val1 = zwdxdSrc.m_c4Val1;
m_c4BufSz = zwdxdSrc.m_c4BufSz;
m_i4Val1 = zwdxdSrc.m_i4Val1;
m_mbufData = zwdxdSrc.m_mbufData;
m_strCmd = zwdxdSrc.m_strCmd;
m_strMsg = zwdxdSrc.m_strMsg;
}
return *this;
}
// ---------------------------------------------------------------------------
// TZWDriverXData: Public, non-virtual methods
// ---------------------------------------------------------------------------
// Full resets this object
tCIDLib::TVoid TZWDriverXData::Reset()
{
m_bAwake = kCIDLib::False;
m_bFlag1 = kCIDLib::False;
m_c1EPId = 0xFF;
m_c1UnitId = 0;
m_c1Val1 = 0;
m_c1Val2 = 0;
m_c4Val1 = 0;
m_c4BufSz = 0;
m_i4Val1 = 0;
m_strCmd.Clear();
m_strMsg.Clear();
//
// This is typically used to send from the client, so we need to set the status
// to true so that all the members get sent.
//
m_bStatus = kCIDLib::True;
}
//
// Mostly for the server side to let it just reset the object it streamed in and
// then set it up for the return. We don't reset the command, assuming that it is
// already set to what it should be and it is always returned in replies as a
// sanity check.
//
// We have a couple convenience ones that will format info into the msg. And one
// that just returns a result
//
tCIDLib::TVoid TZWDriverXData::StatusReset(const tCIDLib::TBoolean bStatus)
{
// Save the command, reset and then put it back
TString strSaveCmd = m_strCmd;
Reset();
m_strCmd = strSaveCmd;
m_bStatus = bStatus;
}
tCIDLib::TVoid
TZWDriverXData::StatusReset(const tCIDLib::TBoolean bStatus, const TString& strMsg)
{
// Save the command, reset and then put it back
TString strSaveCmd = m_strCmd;
Reset();
m_strCmd = strSaveCmd;
m_bStatus = bStatus;
m_strMsg = strMsg;
}
tCIDLib::TVoid
TZWDriverXData::StatusReset(const tCIDLib::TBoolean bStatus
, const TString& strMsg1
, const MFormattable& mfmtblToken1
, const MFormattable& mfmtblToken2
, const MFormattable& mfmtblToken3)
{
// Save the command, reset and then put it back
TString strSaveCmd = m_strCmd;
Reset();
m_strCmd = strSaveCmd;
m_bStatus = bStatus;
m_strMsg = strMsg1;
if (!MFormattable::bIsNullObject(mfmtblToken1))
m_strMsg.eReplaceToken(mfmtblToken1, kCIDLib::chDigit1);
if (!MFormattable::bIsNullObject(mfmtblToken2))
m_strMsg.eReplaceToken(mfmtblToken1, kCIDLib::chDigit2);
if (!MFormattable::bIsNullObject(mfmtblToken3))
m_strMsg.eReplaceToken(mfmtblToken1, kCIDLib::chDigit3);
}
// ---------------------------------------------------------------------------
// TZWDriverXData: Protected, inherited methods
// ---------------------------------------------------------------------------
tCIDLib::TVoid TZWDriverXData::StreamFrom(TBinInStream& strmToReadFrom)
{
// Make sure we get the start marker
strmToReadFrom.CheckForStartMarker(CID_FILE, CID_LINE);
// Check the format version
tCIDLib::TCard2 c2FmtVersion;
strmToReadFrom >> c2FmtVersion;
if (!c2FmtVersion || (c2FmtVersion != ZWaveUSB3Sh_ZWDriverXData::c2FmtVersion))
{
facCIDLib().ThrowErr
(
CID_FILE
, CID_LINE
, kCIDErrs::errcGen_UnknownFmtVersion
, tCIDLib::ESeverities::Failed
, tCIDLib::EErrClasses::Format
, TCardinal(c2FmtVersion)
, clsThis()
);
}
//
// Reset us and then read in the command, status flag, and msg. The command is
// always read, since it's returned as a sanity check in replies.
//
Reset();
strmToReadFrom >> m_strCmd
>> m_bStatus
>> m_strMsg;
// If successful we have to read in the other stuff
if (m_bStatus)
{
strmToReadFrom >> m_bAwake
>> m_bFlag1
>> m_c1EPId
>> m_c1UnitId
>> m_c1Val1
>> m_c1Val2
>> m_c4Val1
>> m_c4BufSz
>> m_i4Val1;
// If any buffer bytes, read those
tCIDLib::TCard4 c4XorCnt;
strmToReadFrom >> m_c4BufSz >> c4XorCnt;
if ((c4XorCnt ^ kCIDLib::c4MaxCard) != m_c4BufSz)
{
// <TBD> Something is awry
m_c4BufSz = 0;
}
// Read in that many bytes
if (m_c4BufSz)
{
if (m_mbufData.c4Size() < m_c4BufSz)
m_mbufData.Reallocate(m_c4BufSz, kCIDLib::False);
strmToReadFrom.c4ReadBuffer(m_mbufData, m_c4BufSz);
}
}
// Make sure we get the end marker
strmToReadFrom.CheckForEndMarker(CID_FILE, CID_LINE);
}
tCIDLib::TVoid TZWDriverXData::StreamTo(TBinOutStream& strmToWriteTo) const
{
strmToWriteTo << tCIDLib::EStreamMarkers::StartObject
<< ZWaveUSB3Sh_ZWDriverXData::c2FmtVersion;
strmToWriteTo << m_strCmd << m_bStatus << m_strMsg;
// If successful we have to stream the other stuff
if (m_bStatus)
{
strmToWriteTo << m_bAwake
<< m_bFlag1
<< m_c1EPId
<< m_c1UnitId
<< m_c1Val1
<< m_c1Val2
<< m_c4Val1
<< m_c4BufSz
<< m_i4Val1;
// Write out the data buffer stuff if any
strmToWriteTo << m_c4BufSz
<< tCIDLib::TCard4(m_c4BufSz ^ kCIDLib::c4MaxCard);
if (m_c4BufSz)
strmToWriteTo.c4WriteBuffer(m_mbufData, m_c4BufSz);
}
strmToWriteTo << tCIDLib::EStreamMarkers::EndObject;
}
| 29.743333 | 84 | 0.518323 | [
"object"
] |
75777a1218ffd30dd37a4a436fb6c587a8f80290 | 864 | hh | C++ | src/RK/computeOccupancyVolume.hh | jmikeowen/Spheral | 3e1082a7aefd6b328bd3ae24ca1a477108cfc3c4 | [
"BSD-Source-Code",
"BSD-3-Clause-LBNL",
"FSFAP"
] | 22 | 2018-07-31T21:38:22.000Z | 2020-06-29T08:58:33.000Z | src/CRKSPH/computeOccupancyVolume.hh | markguozhiming/spheral | bbb982102e61edb8a1d00cf780bfa571835e1b61 | [
"BSD-Source-Code",
"BSD-3-Clause-LBNL",
"FSFAP"
] | 41 | 2020-09-28T23:14:27.000Z | 2022-03-28T17:01:33.000Z | src/CRKSPH/computeOccupancyVolume.hh | markguozhiming/spheral | bbb982102e61edb8a1d00cf780bfa571835e1b61 | [
"BSD-Source-Code",
"BSD-3-Clause-LBNL",
"FSFAP"
] | 7 | 2019-12-01T07:00:06.000Z | 2020-09-15T21:12:39.000Z | //---------------------------------Spheral++------------------------------------
// Compute the occupancy volume per point
//------------------------------------------------------------------------------
#ifndef __Spheral__computeOccupancyVolume__
#define __Spheral__computeOccupancyVolume__
#include "Field/FieldList.hh"
#include "Neighbor/ConnectivityMap.hh"
#include "Kernel/TableKernel.hh"
#include <vector>
namespace Spheral {
template<typename Dimension>
void
computeOccupancyVolume(const ConnectivityMap<Dimension>& connectivityMap,
const TableKernel<Dimension>& W,
const FieldList<Dimension, typename Dimension::Vector>& position,
const FieldList<Dimension, typename Dimension::SymTensor>& H,
FieldList<Dimension, typename Dimension::Scalar>& vol);
}
#endif
| 33.230769 | 88 | 0.585648 | [
"vector"
] |
7577fd45b1e9530d83ce5a327e09cc309e2aebdb | 2,080 | cpp | C++ | geos-3.7.0beta1/src/algorithm/CentroidLine.cpp | litbangbungamayang/SIMTR | 23435e829f6c766ec8483c88005daac654de4057 | [
"MIT"
] | null | null | null | geos-3.7.0beta1/src/algorithm/CentroidLine.cpp | litbangbungamayang/SIMTR | 23435e829f6c766ec8483c88005daac654de4057 | [
"MIT"
] | null | null | null | geos-3.7.0beta1/src/algorithm/CentroidLine.cpp | litbangbungamayang/SIMTR | 23435e829f6c766ec8483c88005daac654de4057 | [
"MIT"
] | null | null | null | /**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2001-2002 Vivid Solutions Inc.
* Copyright (C) 2005 Refractions Research Inc.
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************
*
**********************************************************************/
#include <geos/algorithm/CentroidLine.h>
#include <geos/geom/Coordinate.h>
#include <geos/geom/CoordinateSequence.h>
#include <geos/geom/Geometry.h>
#include <geos/geom/GeometryCollection.h>
#include <geos/geom/LineString.h>
#include <typeinfo>
using namespace geos::geom;
namespace geos {
namespace algorithm { // geos.algorithm
/*public*/
void
CentroidLine::add(const Geometry *geom)
{
const LineString* ls = dynamic_cast<const LineString*>(geom);
if ( ls )
{
add(ls->getCoordinatesRO());
return;
}
const GeometryCollection* gc = dynamic_cast<const GeometryCollection*>(geom);
if (gc)
{
for(std::size_t i=0, n=gc->getNumGeometries(); i<n; i++) {
add(gc->getGeometryN(i));
}
}
}
/*public*/
void
CentroidLine::add(const CoordinateSequence *pts)
{
std::size_t const npts=pts->getSize();
for(std::size_t i=1; i<npts; ++i)
{
const Coordinate &p1=pts->getAt(i-1);
const Coordinate &p2=pts->getAt(i);
double segmentLen=p1.distance(p2);
totalLength+=segmentLen;
double midx=(p1.x+p2.x)/2;
centSum.x+=segmentLen*midx;
double midy=(p1.y+p2.y)/2;
centSum.y+=segmentLen*midy;
}
}
Coordinate *
CentroidLine::getCentroid() const
{
return new Coordinate(centSum.x/totalLength, centSum.y/totalLength);
}
bool
CentroidLine::getCentroid(Coordinate& c) const
{
if ( totalLength == 0.0 ) return false;
c=Coordinate(centSum.x/totalLength, centSum.y/totalLength);
return true;
}
} // namespace geos.algorithm
} // namespace geos
| 23.636364 | 78 | 0.635577 | [
"geometry"
] |
7579b95b2e11b2813e0dbfcefa8256917c741fac | 12,597 | cpp | C++ | Attic/AtomicEditorReference/Source/Resources/AEResourceOps.cpp | honigbeutler123/AtomicGameEngine | c53425f19b216eb21ecd3bda85052aaa1a6f2aaa | [
"Apache-2.0",
"MIT"
] | null | null | null | Attic/AtomicEditorReference/Source/Resources/AEResourceOps.cpp | honigbeutler123/AtomicGameEngine | c53425f19b216eb21ecd3bda85052aaa1a6f2aaa | [
"Apache-2.0",
"MIT"
] | null | null | null | Attic/AtomicEditorReference/Source/Resources/AEResourceOps.cpp | honigbeutler123/AtomicGameEngine | c53425f19b216eb21ecd3bda85052aaa1a6f2aaa | [
"Apache-2.0",
"MIT"
] | null | null | null | // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
// Please see LICENSE.md in repository root for license information
// https://github.com/AtomicGameEngine/AtomicGameEngine
#include "AtomicEditor.h"
#include <Atomic/Core/Context.h>
#include <Atomic/IO/File.h>
#include <Atomic/IO/FileSystem.h>
#include <Atomic/Resource/ResourceCache.h>
#include "../AEEvents.h"
#include "../AEEditor.h"
#include "../UI/UIMainFrame.h"
#include "../UI/UIResourceFrame.h"
#include "../UI/UIProjectFrame.h"
#include "../Project/AEProject.h"
#include "AEResourceOps.h"
namespace AtomicEditor
{
/// Construct.
ResourceOps::ResourceOps(Context* context) :
Object(context)
{
context->RegisterSubsystem(this);
SubscribeToEvent(E_EDITORSHUTDOWN, HANDLER(ResourceOps, HandleEditorShutdown));
}
/// Destruct.
ResourceOps::~ResourceOps()
{
}
bool ResourceOps::CheckCreateComponent(const String& resourcePath, const String& resourceName, bool reportError)
{
Editor* editor = GetSubsystem<Editor>();
Project* project = editor->GetProject();
String fullpath = resourcePath + resourceName;
if (!resourceName.EndsWith(".js"))
fullpath += ".js";
FileSystem* fs = GetSubsystem<FileSystem>();
if (fs->FileExists(fullpath))
{
if (reportError)
{
String errorMsg;
errorMsg.AppendWithFormat("The component:\n\n%s\n\nalready exists", fullpath.CString());
editor->PostModalError("Create Component Error", errorMsg);
}
return false;
}
if (!project->IsComponentsDirOrFile(resourcePath))
{
if (reportError)
{
String errorMsg;
errorMsg.AppendWithFormat("Components must reside in or in a subfolder of the Components folder");
editor->PostModalError("Create Component Error", errorMsg);
}
return false;
}
return true;
}
bool ResourceOps::CheckCreateScript(const String& resourcePath, const String& resourceName, bool reportError)
{
Editor* editor = GetSubsystem<Editor>();
Project* project = editor->GetProject();
String fullpath = resourcePath + resourceName;
if (!resourceName.EndsWith(".js"))
fullpath += ".js";
FileSystem* fs = GetSubsystem<FileSystem>();
if (fs->FileExists(fullpath))
{
if (reportError)
{
String errorMsg;
errorMsg.AppendWithFormat("The script:\n\n%s\n\nalready exists", fullpath.CString());
editor->PostModalError("Create Script Error", errorMsg);
}
return false;
}
if (!project->IsScriptsDirOrFile(resourcePath))
{
if (reportError)
{
String errorMsg;
errorMsg.AppendWithFormat("Scripts must reside in or in a subfolder of the Scripts folder");
editor->PostModalError("Create Script Error", errorMsg);
}
return false;
}
return true;
}
bool ResourceOps::CheckCreateModule(const String& resourcePath, const String& resourceName, bool reportError)
{
Editor* editor = GetSubsystem<Editor>();
Project* project = editor->GetProject();
String fullpath = resourcePath + resourceName;
if (!resourceName.EndsWith(".js"))
fullpath += ".js";
FileSystem* fs = GetSubsystem<FileSystem>();
if (fs->FileExists(fullpath))
{
if (reportError)
{
String errorMsg;
errorMsg.AppendWithFormat("The module:\n\n%s\n\nalready exists", fullpath.CString());
editor->PostModalError("Create Module Error", errorMsg);
}
return false;
}
if (!project->IsModulesDirOrFile(resourcePath))
{
if (reportError)
{
String errorMsg;
errorMsg.AppendWithFormat("Modules must reside in or in a subfolder of the Modules folder");
editor->PostModalError("Create Module Error", errorMsg);
}
return false;
}
return true;
}
bool ResourceOps::CheckCreate2DLevel(const String& resourcePath, const String& resourceName, bool reportError)
{
Editor* editor = GetSubsystem<Editor>();
Project* project = editor->GetProject();
String fullpath = resourcePath + resourceName;
if (!resourceName.EndsWith(".tmx"))
fullpath += ".tmx";
FileSystem* fs = GetSubsystem<FileSystem>();
if (fs->FileExists(fullpath))
{
if (reportError)
{
String errorMsg;
errorMsg.AppendWithFormat("The level:\n\n%s\n\nalready exists", fullpath.CString());
editor->PostModalError("Create 2D Level Error", errorMsg);
}
return false;
}
return true;
}
bool ResourceOps::CopyFile(File* srcFile, const String& destFileName)
{
SharedPtr<File> destFile(new File(context_, destFileName, FILE_WRITE));
if (!destFile->IsOpen())
return false;
unsigned fileSize = srcFile->GetSize();
SharedArrayPtr<unsigned char> buffer(new unsigned char[fileSize]);
unsigned bytesRead = srcFile->Read(buffer.Get(), fileSize);
unsigned bytesWritten = destFile->Write(buffer.Get(), fileSize);
return bytesRead == fileSize && bytesWritten == fileSize;
}
void ResourceOps::HandleResourceDelete(const String& resourcePath, bool reportError)
{
Editor* editor = GetSubsystem<Editor>();
FileSystem* fs = GetSubsystem<FileSystem>();
if (fs->DirExists(resourcePath))
{
fs->RemoveDir(resourcePath, true);
GetSubsystem<MainFrame>()->GetProjectFrame()->Refresh();
return;
}
else if (fs->FileExists(resourcePath))
{
if (!fs->Delete(resourcePath))
{
if (reportError)
{
String errorMsg;
errorMsg.AppendWithFormat("Unable to delete:\n\n %s", resourcePath.CString());
editor->PostModalError("Delete Resource Error", errorMsg);
}
return;
}
GetSubsystem<MainFrame>()->GetProjectFrame()->Refresh();
return;
}
else
{
if (reportError)
{
String errorMsg;
errorMsg.AppendWithFormat("Unable to find:\n\n %s", resourcePath.CString());
editor->PostModalError("Delete Resource Error", errorMsg);
}
return;
}
}
void ResourceOps::HandleNewFolder(const String& resourcePath, bool reportError)
{
Editor* editor = GetSubsystem<Editor>();
FileSystem* fs = GetSubsystem<FileSystem>();
if (fs->DirExists(resourcePath) || fs->FileExists(resourcePath))
{
if (reportError)
{
String errorMsg;
errorMsg.AppendWithFormat("Already exists:\n\n %s", resourcePath.CString());
editor->PostModalError("New Folder Error", errorMsg);
}
return;
}
if (!fs->CreateDir(resourcePath))
{
if (reportError)
{
String errorMsg;
errorMsg.AppendWithFormat("Could not create:\n\n %s", resourcePath.CString());
editor->PostModalError("New Folder Error", errorMsg);
}
return;
}
// file watcher doesn't currently handle subdir
GetSubsystem<MainFrame>()->GetProjectFrame()->Refresh();
}
void ResourceOps::HandleCreateComponent(const String& resourcePath, const String& resourceName,
bool navigateToResource, bool reportError)
{
Editor* editor = GetSubsystem<Editor>();
if (!CheckCreateComponent(resourcePath, resourceName, reportError))
return;
ResourceCache* cache = GetSubsystem<ResourceCache>();
SharedPtr<File> srcFile = cache->GetFile("AtomicEditor/templates/template_component.js");
if (srcFile.Null() || !srcFile->IsOpen())
{
editor->PostModalError("Create Component Error", "Could not open component template");
return;
}
String fullpath = resourcePath + resourceName;
if (!resourceName.EndsWith(".js"))
fullpath += ".js";
if (!CopyFile(srcFile, fullpath))
{
String errorMsg;
errorMsg.AppendWithFormat("Error copying template:\n\n%s\n\nto:\n\n%s",
"AtomicEditor/template_component.js", fullpath.CString());
editor->PostModalError("Create Component Error", errorMsg);
return;
}
if (navigateToResource)
{
ResourceFrame* rframe = GetSubsystem<MainFrame>()->GetResourceFrame();
rframe->EditResource(fullpath);
}
GetSubsystem<MainFrame>()->GetProjectFrame()->Refresh();
}
void ResourceOps::HandleCreateScript(const String& resourcePath, const String& resourceName,
bool navigateToResource, bool reportError)
{
Editor* editor = GetSubsystem<Editor>();
if (!CheckCreateScript(resourcePath, resourceName, reportError))
return;
ResourceCache* cache = GetSubsystem<ResourceCache>();
SharedPtr<File> srcFile = cache->GetFile("AtomicEditor/templates/template_script.js");
if (srcFile.Null() || !srcFile->IsOpen())
{
editor->PostModalError("Create Script Error", "Could not open script template");
return;
}
String fullpath = resourcePath + resourceName;
if (!resourceName.EndsWith(".js"))
fullpath += ".js";
if (!CopyFile(srcFile, fullpath))
{
String errorMsg;
errorMsg.AppendWithFormat("Error copying template:\n\n%s\n\nto:\n\n%s",
"AtomicEditor/template_script.js", fullpath.CString());
editor->PostModalError("Create Script Error", errorMsg);
return;
}
if (navigateToResource)
{
ResourceFrame* rframe = GetSubsystem<MainFrame>()->GetResourceFrame();
rframe->EditResource(fullpath);
}
GetSubsystem<MainFrame>()->GetProjectFrame()->Refresh();
}
void ResourceOps::HandleCreateModule(const String& resourcePath, const String& resourceName,
bool navigateToResource, bool reportError)
{
Editor* editor = GetSubsystem<Editor>();
if (!CheckCreateModule(resourcePath, resourceName, reportError))
return;
ResourceCache* cache = GetSubsystem<ResourceCache>();
SharedPtr<File> srcFile = cache->GetFile("AtomicEditor/templates/template_module.js");
if (srcFile.Null() || !srcFile->IsOpen())
{
editor->PostModalError("Create Script Error", "Could not open module template");
return;
}
String fullpath = resourcePath + resourceName;
if (!resourceName.EndsWith(".js"))
fullpath += ".js";
if (!CopyFile(srcFile, fullpath))
{
String errorMsg;
errorMsg.AppendWithFormat("Error copying template:\n\n%s\n\nto:\n\n%s",
"AtomicEditor/template_module.js", fullpath.CString());
editor->PostModalError("Create Module Error", errorMsg);
return;
}
if (navigateToResource)
{
ResourceFrame* rframe = GetSubsystem<MainFrame>()->GetResourceFrame();
rframe->EditResource(fullpath);
}
GetSubsystem<MainFrame>()->GetProjectFrame()->Refresh();
}
void ResourceOps::HandleCreate2DLevel(const String& resourcePath, const String& resourceName,
bool navigateToResource, bool reportError)
{
Editor* editor = GetSubsystem<Editor>();
if (!CheckCreate2DLevel(resourcePath, resourceName, reportError))
return;
ResourceCache* cache = GetSubsystem<ResourceCache>();
SharedPtr<File> srcFile = cache->GetFile("AtomicEditor/templates/template_empty.tmx");
if (srcFile.Null() || !srcFile->IsOpen())
{
editor->PostModalError("Create Script Error", "Could not open module template");
return;
}
String fullpath = resourcePath + resourceName;
if (!resourceName.EndsWith(".tmx"))
fullpath += ".tmx";
if (!CopyFile(srcFile, fullpath))
{
String errorMsg;
errorMsg.AppendWithFormat("Error copying template:\n\n%s\n\nto:\n\n%s",
"AtomicEditor/template_empty.tmx", fullpath.CString());
editor->PostModalError("Create 2D Level Error", errorMsg);
return;
}
if (navigateToResource)
{
//ResourceFrame* rframe = GetSubsystem<MainFrame>()->GetResourceFrame();
//rframe->EditResource(fullpath);
}
GetSubsystem<MainFrame>()->GetProjectFrame()->Refresh();
}
void ResourceOps::HandleEditorShutdown(StringHash eventType, VariantMap& eventData)
{
context_->RemoveSubsystem(GetType());
}
}
| 27.931264 | 112 | 0.631738 | [
"object"
] |
7579f48ce953a38f9dc62db8268c7a4ce8422172 | 1,355 | cpp | C++ | src/software/ai/hl/stp/tactic/stop/stop_fsm_test.cpp | jonl112/Software | 61a028a98d5c0dd5e79bf055b231633290ddbf9f | [
"MIT"
] | null | null | null | src/software/ai/hl/stp/tactic/stop/stop_fsm_test.cpp | jonl112/Software | 61a028a98d5c0dd5e79bf055b231633290ddbf9f | [
"MIT"
] | null | null | null | src/software/ai/hl/stp/tactic/stop/stop_fsm_test.cpp | jonl112/Software | 61a028a98d5c0dd5e79bf055b231633290ddbf9f | [
"MIT"
] | null | null | null | #include "software/ai/hl/stp/tactic/stop/stop_fsm.h"
#include <gtest/gtest.h>
#include "software/test_util/test_util.h"
TEST(StopFSMTest, test_transitions)
{
World world = ::TestUtil::createBlankTestingWorld();
Robot robot(0,
RobotState(Point(1, -3), Vector(2.1, 3.1), Angle::half(),
AngularVelocity::zero()),
Timestamp::fromSeconds(123));
FSM<StopFSM> fsm(StopFSM(false));
EXPECT_TRUE(fsm.is(boost::sml::state<StopFSM::StopState>));
fsm.process_event(
StopFSM::Update({}, TacticUpdate(robot, world, [](std::unique_ptr<Intent>) {})));
// robot is still moving
EXPECT_TRUE(fsm.is(boost::sml::state<StopFSM::StopState>));
robot = Robot(0,
RobotState(Point(1, -3), Vector(1.1, 2.1), Angle::half(),
AngularVelocity::zero()),
Timestamp::fromSeconds(123));
fsm.process_event(
StopFSM::Update({}, TacticUpdate(robot, world, [](std::unique_ptr<Intent>) {})));
// robot is still moving
EXPECT_TRUE(fsm.is(boost::sml::state<StopFSM::StopState>));
robot = TestUtil::createRobotAtPos(Point(1, -3));
fsm.process_event(
StopFSM::Update({}, TacticUpdate(robot, world, [](std::unique_ptr<Intent>) {})));
// robot stopped
EXPECT_TRUE(fsm.is(boost::sml::X));
}
| 38.714286 | 89 | 0.606642 | [
"vector"
] |
758a942e5af485ebf32b18ea270479ca416c780d | 419 | cpp | C++ | LeetCode/1000/942.cpp | K-ona/C-_Training | d54970f7923607bdc54fc13677220d1b3daf09e5 | [
"Apache-2.0"
] | null | null | null | LeetCode/1000/942.cpp | K-ona/C-_Training | d54970f7923607bdc54fc13677220d1b3daf09e5 | [
"Apache-2.0"
] | null | null | null | LeetCode/1000/942.cpp | K-ona/C-_Training | d54970f7923607bdc54fc13677220d1b3daf09e5 | [
"Apache-2.0"
] | null | null | null | class Solution {
public:
vector<int> diStringMatch(string s) {
vector<int> res;
res.reserve(s.size() + 1);
int max = s.size();
int min = 0;
for (const auto c: s) {
if (c == 'I') {
res.push_back(min++);
} else {
res.push_back(max--);
}
}
res.push_back(max);
return res;
}
}; | 23.277778 | 41 | 0.405728 | [
"vector"
] |
7590769994c6ba2fc325ef6f04cfb00b1d6538dd | 7,595 | hpp | C++ | Sources/SolarTears/Rendering/Common/FrameGraph/ModernFrameGraphBuilder.hpp | Sixshaman/SolarTears | 97d07730f876508fce8bf93c9dc90f051c230580 | [
"BSD-3-Clause"
] | 4 | 2021-06-30T16:00:20.000Z | 2021-10-13T06:17:56.000Z | Sources/SolarTears/Rendering/Common/FrameGraph/ModernFrameGraphBuilder.hpp | Sixshaman/SolarTears | 97d07730f876508fce8bf93c9dc90f051c230580 | [
"BSD-3-Clause"
] | null | null | null | Sources/SolarTears/Rendering/Common/FrameGraph/ModernFrameGraphBuilder.hpp | Sixshaman/SolarTears | 97d07730f876508fce8bf93c9dc90f051c230580 | [
"BSD-3-Clause"
] | null | null | null | #pragma once
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include "ModernFrameGraph.hpp"
#include "ModernFrameGraphMisc.hpp"
#include "FrameGraphDescription.hpp"
#include "../../../Core/DataStructures/Span.hpp"
#include <span>
class FrameGraphConfig;
class ModernFrameGraphBuilder
{
private:
struct TextureRemapInfo
{
uint32_t BaseTextureIndex;
uint32_t FrameCount;
};
protected:
//Describes a single render pass
struct PassMetadata
{
RenderPassName Name; //The name of the pass
RenderPassClass Class; //The class (graphics/compute/copy) of the pass
RenderPassType Type; //The type of the pass
uint32_t DependencyLevel; //The dependendency level of the pass
Span<uint32_t> SubresourceMetadataSpan; //The indices of pass subresource metadatas
};
//Describes a single resource
struct ResourceMetadata
{
ResourceName Name; //The name of the resource
TextureSourceType SourceType; //Defines ownership of the texture (frame graph, swapchain, etc)
uint32_t HeadNodeIndex; //The index of the head SubresourceMetadataNode
};
//Describes a particular pass usage of the resource
struct SubresourceMetadataNode
{
uint32_t PrevPassNodeIndex; //The index of the same resources metadata used in the previous pass
uint32_t NextPassNodeIndex; //The index of the same resources metadata used in the next pass
uint32_t ResourceMetadataIndex; //The index of ResourceMetadata associated with the subresource
uint32_t ImageViewHandle; //The id of the subresource in the frame graph texture view list
RenderPassClass PassClass; //The pass class (Graphics/Compute/Copy) that uses the node
#if defined(DEBUG) || defined(_DEBUG)
std::string_view PassName;
std::string_view ResourceName;
#endif
};
public:
ModernFrameGraphBuilder(ModernFrameGraph* graphToBuild);
~ModernFrameGraphBuilder();
const FrameGraphConfig* GetConfig() const;
void Build(FrameGraphDescription&& frameGraphDescription);
private:
//Fills the initial pass info
void RegisterPasses(const std::unordered_map<RenderPassName, RenderPassType>& renderPassTypes, const std::vector<SubresourceNamingInfo>& subresourceNames, const ResourceName& backbufferName);
//Fills the initial pass info from the description data
void InitPassList(const std::unordered_map<RenderPassName, RenderPassType>& renderPassTypes);
//Fills the initial pass info from the description data
void InitSubresourceList(const std::vector<SubresourceNamingInfo>& subresourceNames, const ResourceName& backbufferName);
//Sorts passes by dependency level and by topological order
void SortPasses();
//Creates lists of written resource indices and read subresource indices for each pass. Used to speed up the lookup when creating the adjacency list
void BuildReadWriteSubresourceSpans(std::vector<std::span<std::uint32_t>>& outReadIndexSpans, std::vector<std::span<std::uint32_t>>& outWriteIndexSpans, std::vector<uint32_t>& outIndicesFlat);
//Builds frame graph adjacency list
void BuildAdjacencyList(const std::vector<std::span<uint32_t>>& sortedReadNameSpansPerPass, const std::vector<std::span<uint32_t>>& sortedwriteNameSpansPerPass, std::vector<std::span<uint32_t>>& outAdjacencyList, std::vector<uint32_t>& outAdjacentPassIndicesFlat);
//Test if sorted spans share any element
bool SpansIntersect(const std::span<uint32_t> leftSortedSpan, const std::span<uint32_t> rightSortedSpan);
//Assign dependency levels to the render passes
void AssignDependencyLevels(const std::vector<uint32_t>& passIndexRemap, const std::vector<std::span<uint32_t>>& oldAdjacencyList);
//Sorts frame graph passes topologically
void SortRenderPassesByTopology(const std::vector<std::span<uint32_t>>& unsortedPassAdjacencyList, std::vector<uint32_t>& outPassIndexRemap);
//Recursively sort subtree topologically
void TopologicalSortNode(uint32_t passIndex, const std::vector<std::span<uint32_t>>& unsortedPassAdjacencyList, std::vector<uint8_t>& inoutTraversalMarkFlags, std::vector<uint32_t>& inoutPassIndexRemap);
//Sorts frame graph passes (already sorted topologically) by dependency level
void SortRenderPassesByDependency();
//Fills in augmented render pass data (pass classes, spans, pass periods)
void InitAugmentedData();
//Changes pass classes according to async compute/transfer use
void AdjustPassClasses();
//Builds pass spans for each dependency level
void BuildPassSpans();
//Creates multiple copies of passes and resources, one for each separate frame
void AmplifyResourcesAndPasses();
//Helper function to add several multiple copies of a single pass to mTotalPassMetadatas
void FindFrameCountAndSwapType(const std::vector<TextureRemapInfo>& resourceRemapInfos, std::span<const SubresourceMetadataNode> oldPassSubresourceMetadataSpan, uint32_t* outFrameCount, RenderPassFrameSwapType* outSwapType);
//Calculates PrevPassNodeIndex for the subresource metadata node in amplified list
uint32_t CalcAmplifiedPrevSubresourceIndex(uint32_t currPassFrameSpanIndex, uint32_t prevPassFrameSpanIndex, uint32_t currPassFrameIndex, uint32_t prevPassSubresourceId);
//Calculates NextPassNodeIndex for the subresource metadata node in amplified list
uint32_t CalcAmplifiedNextSubresourceIndex(uint32_t currPassFrameSpanIndex, uint32_t nextPassFrameSpanIndex, uint32_t currPassFrameIndex, uint32_t nextPassSubresourceId);
//Validates PrevPassMetadata and NextPassMetadata links in each subresource info
void ValidateSubresourceLinks();
//Initializes HeadNodeIndex of resources
void InitializeHeadNodes();
//Propagates API-specific subresource data
void PropagateSubresourcePayloadData();
//Creates textures and views
void BuildResources();
//Build the between-pass barriers
void BuildBarriers();
protected:
//Registers subresource api-specific metadata
virtual void InitMetadataPayloads() = 0;
//Propagates API-specific subresource data from one subresource to another, within a single resource
virtual bool PropagateSubresourcePayloadDataVertically(const ResourceMetadata& resourceMetadata) = 0;
//Propagates API-specific subresource data from one subresource to another, within a single pass
virtual bool PropagateSubresourcePayloadDataHorizontally(const PassMetadata& passMetadata) = 0;
//Creates image objects
virtual void CreateTextures() = 0;
//Creates image view objects
virtual void CreateTextureViews() = 0;
//Creates render pass objects
virtual void BuildPassObjects() = 0;
//Add barriers to execute before a pass
virtual void AddBeforePassBarriers(const PassMetadata& passMetadata, uint32_t barrierSpanIndex) = 0;
//Add barriers to execute before a pass
virtual void AddAfterPassBarriers(const PassMetadata& passMetadata, uint32_t barrierSpanIndex) = 0;
//Initializes command buffer, job info, etc. for the frame graph
virtual void InitializeTraverseData() const = 0;
//Get the number of swapchain images
virtual uint32_t GetSwapchainImageCount() const = 0;
protected:
ModernFrameGraph* mGraphToBuild;
std::vector<SubresourceMetadataNode> mSubresourceMetadataNodesFlat;
std::vector<PassMetadata> mTotalPassMetadatas;
std::vector<ResourceMetadata> mResourceMetadatas;
Span<uint32_t> mRenderPassMetadataSpan;
Span<uint32_t> mPresentPassMetadataSpan;
//The sole purpose of helper subresource spans for each subresources is to connect PrevPassNodeIndex and NextPassNodeIndex in multi-frame scenarios
Span<uint32_t> mPrimarySubresourceNodeSpan;
std::vector<Span<uint32_t>> mHelperNodeSpansPerPassSubresource;
}; | 41.054054 | 265 | 0.80158 | [
"render",
"vector"
] |
75a1c96b11df00285ced1d83099e236c1995530e | 2,734 | cpp | C++ | firstSynthesizer/Source/PluginEditor.cpp | TroyKurniawan/VST-Synthesizer-Plugin | 7e6f4089ddcf1051fb35396e3928c07def4c0c39 | [
"MIT"
] | null | null | null | firstSynthesizer/Source/PluginEditor.cpp | TroyKurniawan/VST-Synthesizer-Plugin | 7e6f4089ddcf1051fb35396e3928c07def4c0c39 | [
"MIT"
] | null | null | null | firstSynthesizer/Source/PluginEditor.cpp | TroyKurniawan/VST-Synthesizer-Plugin | 7e6f4089ddcf1051fb35396e3928c07def4c0c39 | [
"MIT"
] | null | null | null | /*
==============================================================================
This file was auto-generated!
It contains the basic framework code for a JUCE plugin editor.
==============================================================================
*/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
SynthFrameworkAudioProcessorEditor::SynthFrameworkAudioProcessorEditor (SynthFrameworkAudioProcessor& p)
: AudioProcessorEditor (&p), processor (p)
{
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
setSize (400, 300);
// ATTACK
attackSlider.setSliderStyle(Slider::SliderStyle::LinearVertical);
attackSlider.setRange(0.1f, 5000.0f); // Arguments are in milliseconds
attackSlider.setValue(0.1f);
// This is a text box that will appear below the slider.
// 1st Number Argument = Width | 2nd Number Argument = Height
attackSlider.setTextBoxStyle(Slider::TextBoxBelow, true, 20.0, 10.0);
attackSlider.addListener(this);
addAndMakeVisible(&attackSlider);
// Links the slider between the PluginEditor.cpp and the PluginProcessor.cpp.
sliderTree = new AudioProcessorValueTreeState::SliderAttachment(processor.tree, "attack", attackSlider);
}
SynthFrameworkAudioProcessorEditor::~SynthFrameworkAudioProcessorEditor()
{
}
//==============================================================================
void SynthFrameworkAudioProcessorEditor::paint (Graphics& g)
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
g.setColour (Colours::white);
g.setFont (15.0f);
g.drawFittedText ("Troy's Simple VST Synthesizer Plugin!", getLocalBounds(), Justification::centredBottom, 1);
// Attack Slider Box
g.drawRect(5.0f, 5.0f, 50.0f, 160.0f);
// Line Above Bottom Text
g.drawLine(30, 280, 370, 280);
}
void SynthFrameworkAudioProcessorEditor::resized()
{
// This is generally where you'll want to lay out the positions of any
// subcomponents in your editor..
// 3rd Argument = Width | 4th Argument = Height
attackSlider.setBounds(10, 10, 40, 150);
}
void SynthFrameworkAudioProcessorEditor::sliderValueChanged(Slider* slider)
{
if(slider == &attackSlider)
{
// Need to set value of attack time to the slider value
processor.attackTime = attackSlider.getValue();
}
} | 34.175 | 115 | 0.60278 | [
"solid"
] |
b5a5271b1f1298ccb9e4a8319f9fb80b558e49d3 | 6,299 | cpp | C++ | src/common/pgsql_hb.cpp | paolofrb/cotson | 1289b58ecc5d8279bc1124495ca0042f9586af11 | [
"MIT"
] | null | null | null | src/common/pgsql_hb.cpp | paolofrb/cotson | 1289b58ecc5d8279bc1124495ca0042f9586af11 | [
"MIT"
] | null | null | null | src/common/pgsql_hb.cpp | paolofrb/cotson | 1289b58ecc5d8279bc1124495ca0042f9586af11 | [
"MIT"
] | null | null | null | // (C) Copyright 2006-2009 Hewlett-Packard Development Company, L.P.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
// $Id$
#include "error.h"
#include "libmetric.h"
#include "liboptions.h"
#include <boost/scoped_ptr.hpp>
#include <boost/lexical_cast.hpp>
#include <pqxx/pqxx>
using namespace pqxx;
using namespace boost;
using namespace std;
class PgsqlWriter
{
public:
static int new_experiment(const string& dbconn,const string& description);
PgsqlWriter(const string& cst,int exp_id,int mach_id);
void add(const map<string,string>& opts);
void subscribe(metric* met);
void start_heartbeat(int heartbeat_seq);
void beat(metric* met);
private:
typedef map<string,string> MetricIds;
void add_metric(const string& name);
string get_metric_id(transaction<>& t,const string& name);
pqxx::connection C;
string experiment_id;
string machine_id;
string current_heartbeat_id;
MetricIds ids;
};
PgsqlWriter::PgsqlWriter(const string& cst,int exp_id,int mach_id) :
C(cst),
experiment_id(lexical_cast<string>(exp_id)),
machine_id(lexical_cast<string>(mach_id))
{
}
void PgsqlWriter::add(const map<string,string>& opts)
{
transaction<> t(C, "adding options "+experiment_id+" "+machine_id);
for(map<string,string>::const_iterator i=opts.begin(); i!=opts.end();++i)
{
t.exec("INSERT INTO parameters(experiment_id,machine_id,name,value) VALUES("+
experiment_id+","+
machine_id+",'"+
t.esc(i->first)+"','"+
t.esc(i->second)+"');");
}
t.commit();
}
void PgsqlWriter::add_metric(const string& m)
{
try
{
transaction<> t(C,"adding new metric");
if (t.exec("SELECT metric_id FROM metric_names WHERE name='"+t.esc(m)+"'").empty())
// This insert can fail in case of a concurrent insertion
t.exec("INSERT INTO metric_names(name) VALUES('"+ t.esc(m)+"');");
t.commit();
}
catch(...)
{
WARNING("DB insertion of metric ", m, " failed: using previous");
}
}
string PgsqlWriter::get_metric_id(transaction<>& t,const string& name)
{
result r=t.exec("SELECT metric_id FROM metric_names WHERE name='"+t.esc(name)+"'");
string value;
if(!r[0][0].to(value))
throw runtime_error("metric id from "+name+" cannot be casted");
return value;
}
void PgsqlWriter::subscribe(metric* met)
{
// First, insert metrics (if needed)
for(metric::iterator i=met->names_begin();i!=met->names_end();i++)
add_metric(*i);
for(metric::iterator i=met->ratios_begin();i!=met->ratios_end();i++)
add_metric(*i);
// Then get the ids
transaction<> t(C,"getting metric ids");
for(metric::iterator i=met->names_begin();i!=met->names_end();i++)
ids[*i]=get_metric_id(t,*i);
for(metric::iterator i=met->ratios_begin();i!=met->ratios_end();i++)
ids[*i]=get_metric_id(t,*i);
t.commit();
}
void PgsqlWriter::start_heartbeat(int heartbeat_seq)
{
transaction<> t(C, "starting heartbeat");
result r=t.exec(
"INSERT INTO heartbeats(heartbeat_seq,machine_id,experiment_id) VALUES("+
lexical_cast<string>(heartbeat_seq)+","+
machine_id+","+experiment_id+"); SELECT lastval()");
t.commit();
if(!r[0][0].to(current_heartbeat_id))
throw runtime_error("could not get a heartbeat_id");
}
void PgsqlWriter::beat(metric* met)
{
transaction<> t(C, "beat");
for(metric::iterator i=met->names_begin();i!=met->names_end();i++)
{
string val = lexical_cast<string>((*met)[*i]);
if (val != "nan" && val != "0")
t.exec("INSERT INTO metrics(heartbeat_id,metric_id,value) VALUES("+
current_heartbeat_id+","+ ids[*i]+",'"+val+"');");
}
for(metric::iterator i=met->ratios_begin();i!=met->ratios_end();i++)
{
string val = lexical_cast<string>(met->ratio(*i));
if (val != "nan" && val != "0")
t.exec("INSERT INTO metrics(heartbeat_id,metric_id,value) VALUES("+
current_heartbeat_id+","+ids[*i]+",'"+val+"');");
}
// Small optimization, might go away at some point
t.exec("UPDATE heartbeats SET nanos="+
lexical_cast<string>((*met)["nanos"])+
" WHERE heartbeat_id="+current_heartbeat_id+
" AND machine_id="+machine_id+";");
t.commit();
}
int PgsqlWriter::new_experiment(const string& dbconn,const string& description)
{
connection nc(dbconn);
transaction<> t(nc, "creating a new experiment");
result r=t.exec("INSERT INTO experiments(description) VALUES('"+
t.esc(description)+"'); SELECT lastval()");
t.commit();
int value;
if(!r[0][0].to(value))
throw runtime_error("experiment id cant be casted");
return value;
}
class PostgresHB : public HeartBeat
{
public:
PostgresHB(Parameters&);
protected:
void do_beat();
void do_last_beat();
private:
string dbconn;
int experiment_id;
int machine_id;
uint64_t count;
scoped_ptr<PgsqlWriter> writer;
};
PostgresHB::PostgresHB(Parameters&p) :
dbconn(p.get<string>("dbconn")),
machine_id(0),
count(0)
{
if(Option::has("network.mediator_nodeid"))
machine_id=Option::get<int>("network.mediator_nodeid");
if(p.has("experiment_id"))
experiment_id=p.get<int>("experiment_id");
else if(p.has("experiment_description"))
experiment_id=
PgsqlWriter::new_experiment(dbconn,p.get<string>("experiment_description"));
else
throw invalid_argument("either experiment_id or experiment_description is needed for pgsql heartbeat");
writer.reset(new PgsqlWriter(dbconn,experiment_id,machine_id));
}
void PostgresHB::do_beat()
{
if(count==0)
{
writer->add(Option::requested());
for(vector<metric*>::iterator mi=mets.begin(); mi!=mets.end(); mi++)
writer->subscribe(*mi);
}
count++;
writer->start_heartbeat(count);
for(vector<metric*>::iterator mi=mets.begin(); mi!=mets.end(); mi++)
writer->beat(*mi);
}
void PostgresHB::do_last_beat()
{
do_beat();
}
////////////////////////////////////////////////////
// Register class for COTSon use
////////////////////////////////////////////////////
registerClass<HeartBeat,PostgresHB> pgsql_c("pgsql");
| 28.373874 | 105 | 0.683442 | [
"vector"
] |
b5a65b43f4e4305243657d3ec57343d0fc008933 | 846 | cpp | C++ | ObjectOrientedProgrammingCodes-CPP/CPPWorkspace/DeclareClassAndObjects/main.cpp | srinivasamaringanti/ObjectOrientedProgrammingCodes | 84a11cf63d852aa4537bdde3bd0867b9a0725d66 | [
"MIT"
] | null | null | null | ObjectOrientedProgrammingCodes-CPP/CPPWorkspace/DeclareClassAndObjects/main.cpp | srinivasamaringanti/ObjectOrientedProgrammingCodes | 84a11cf63d852aa4537bdde3bd0867b9a0725d66 | [
"MIT"
] | null | null | null | ObjectOrientedProgrammingCodes-CPP/CPPWorkspace/DeclareClassAndObjects/main.cpp | srinivasamaringanti/ObjectOrientedProgrammingCodes | 84a11cf63d852aa4537bdde3bd0867b9a0725d66 | [
"MIT"
] | null | null | null | #include <conio.h>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
class Player
{
//FR
//attributes
string name{"Player"};
int health{100};
int xp{1};
//method
void talk(string); //prototype
bool is_dead();
};//Class Player end
class Account
{
//attributes
string name {"Account"};
double balance {0.0};
//methods
bool deposit(double);
bool withdraw(double);
};// Account class end
int main()
{
cout<< "Creating the Classes and objects"<< std::endl;
//Account class objects and calls
Account sunny_account;
Account hero_account;
//Player class objects and calls
Player sunny; //stack
Player hero; // stack
Player *enemy = new Player; // creates object on heap
Player players[] {sunny,hero,*(enemy)};
delete enemy;// free the heap spavce
// getch();
return 0;
} | 15.962264 | 58 | 0.671395 | [
"object",
"vector"
] |
b5ac38e324105caa600b3e7a63f24d6ce62172fe | 1,139 | cpp | C++ | 330_Patching_Array/main.cpp | zhenkunhe/LeetCode | 17a9a4d63d21888c7e7d300d5e29201f8621fd63 | [
"MIT"
] | null | null | null | 330_Patching_Array/main.cpp | zhenkunhe/LeetCode | 17a9a4d63d21888c7e7d300d5e29201f8621fd63 | [
"MIT"
] | null | null | null | 330_Patching_Array/main.cpp | zhenkunhe/LeetCode | 17a9a4d63d21888c7e7d300d5e29201f8621fd63 | [
"MIT"
] | null | null | null | #include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
using namespace std;
class Solution
{
public:
int minPatches( vector<int>& nums , int n )
{
int OK = 0;
vector<int> resultAdd;
vector<int>::iterator find1 = find_if( nums.begin() , nums.end() , [&](int value)
{
return (value == 1);
} );
if ( find1 == nums.end() ) resultAdd.push_back( 1 );
else nums.erase( find1 );
OK = 1;
while ( OK < n )
{
vector<int>::iterator findSmall = find_if( nums.begin() , nums.end() , [&](int value)
{
return ((OK+1)>=value);
} );
if ( findSmall != nums.end() )
{
OK = OK + *findSmall;
nums.erase( findSmall );
}
else
{
resultAdd.push_back( OK + 1 );
OK = (OK + 1) * 2 - 1;
}
if ( OK < 0 ) break;
}
for (int item : resultAdd)
{
cout << item << endl;
}
return resultAdd.size();
}
};
int main()
{
vector<int> nums;
nums.push_back( 1 );
nums.push_back( 2 );
nums.push_back( 31 );
nums.push_back( 33 );
Solution* s = new Solution();
cout << s->minPatches( nums , 2147483647 ) << endl;
return 0;
}
| 18.370968 | 89 | 0.548727 | [
"vector"
] |
b5b7b1cb27899f19a7046dbf203a5ab0add9b0d3 | 11,643 | hpp | C++ | inc/Tools/LinkTool.hpp | barne856/3DSWMM | 60dd2702c82857dcf4358b8d42a1fb430a568e90 | [
"MIT"
] | null | null | null | inc/Tools/LinkTool.hpp | barne856/3DSWMM | 60dd2702c82857dcf4358b8d42a1fb430a568e90 | [
"MIT"
] | null | null | null | inc/Tools/LinkTool.hpp | barne856/3DSWMM | 60dd2702c82857dcf4358b8d42a1fb430a568e90 | [
"MIT"
] | null | null | null | #ifndef LINK_TOOL
#define LINK_TOOL
#include "Application/Tool.hpp"
#include "Meshes/Circle.hpp"
#include "Meshes/Rectangle.hpp"
#include "3DSWMM/Network.hpp"
#include "Application/Application.hpp"
#include <limits>
#include <glm/gtx/rotate_vector.hpp>
class LinkTool : public Tool
{
public:
LinkTool()
{
link = new Rectangle();
node1 = new Circle(24, 0.1f);
node2 = new Circle(24, 0.1f);
link->set_scale(glm::vec3(0.05f, 0.70710678118f, 0.0f));
link->set_rotation(glm::vec3(0.0f, 0.0f, 1.0f), M_PI_4);
node1->set_position(glm::vec3(-0.25f, 0.25f, 0.0f));
node2->set_position(glm::vec3(0.25f, -0.25f, 0.0f));
icon->push_mesh(link);
icon->push_mesh(node1);
icon->push_mesh(node2);
tool_cursor = CURSOR::CROSSHAIRS;
network = Network::get_instance();
link_mesh = network->get_links_mesh();
snapping_distance = Application::get_camera()->get_scaled_snapping_distance();
}
virtual ~LinkTool()
{
delete link;
delete node1;
delete node2;
}
virtual void on_mouse_left_click(glm::vec3 world_pos, int x, int y)
{
if (link_mesh && Application::get_camera()->type() == Camera::ProjectionType::ORTHOGRAPHIC)
{
double time = Application::get_app()->get_info()->current_time;
if (time - last_time < 0.25 && is_using())
{
// double clicked, end multiline creation and set end point to nearest node within snapping distance
link_mesh->pop_instance();
quit_using();
begin = true;
int i = snap_to_node(world_pos);
if (i != -1 && was_snapped)
{
Node node = network->nodes.at(i);
current_link.dn_ID = node.ID;
world_pos.x = node.easting;
world_pos.y = node.northing;
link_mesh->modify_instance(link_mesh->size() - 1, link_to_model(prev_start_pos, world_pos, 1.0f));
network->links.at(network->links.size() - 1).dn_ID = node.ID;
network->nodes.at(i).dn_IDs.pop_back();
}
else if (i != -1 && !was_snapped)
{
Node node = network->nodes.at(i);
network->nodes.at(i).up_IDs.push_back(current_link.ID);
current_link.dn_ID = node.ID;
world_pos.x = node.easting;
world_pos.y = node.northing;
link_mesh->modify_instance(link_mesh->size() - 1, link_to_model(world_pos, start_pos, 1.0f));
glm::vec3 temp = start_pos;
start_pos = world_pos;
world_pos = temp;
//-- interpolate z values
float L = 0.0f;
for (int j = 0; j < current_link.points.size() - 1; j++)
{
// total length
L += glm::length(glm::vec2(current_link.points.at(j)) - glm::vec2(current_link.points.at(j + 1)));
}
float l = 0.0f;
float h = current_link.points.at(current_link.points.size() - 1).z - current_link.points.at(0).z;
float s = h / L;
for (int j = 0; j < current_link.points.size() - 1; j++)
{
// partial length
l += glm::length(glm::vec2(current_link.points.at(j)) - glm::vec2(current_link.points.at(j + 1)));
// elevation at partial length
current_link.points.at(j + 1).z = current_link.points.at(0).z + s * l;
}
//--
network->links.push_back(current_link);
current_link.dn_ID = node.ID;
world_pos.x = node.easting;
world_pos.y = node.northing;
link_mesh->modify_instance(link_mesh->size() - 1, link_to_model(prev_start_pos, world_pos, 1.0f));
network->links.at(network->links.size() - 1).dn_ID = node.ID;
}
else if (i == -1 && was_snapped)
{
// remove second to last links down node
std::string ID = network->links.at(network->links.size() - 1).dn_ID;
network->links.at(network->links.size() - 1).dn_ID = "";
// remove second to last links down node's down link
int index = network->node_ID_to_index(ID);
if (index != -1)
{
network->nodes.at(index).dn_IDs.pop_back();
}
link_mesh->modify_instance(link_mesh->size() - 1, link_to_model(prev_start_pos, world_pos, 1.0f));
}
else // wasn't snapped and isn't snapped
{
link_mesh->modify_instance(link_mesh->size() - 1, link_to_model(prev_start_pos, world_pos, 1.0f));
network->links.push_back(current_link);
}
// sync the link instances with the network link elevations
int index = 0;
for (auto link : network->links)
{
for (int i = 0; i < link.points.size() - 1; i++)
{
link_mesh->modify_instance(index, link_to_model(link.points.at(i), link.points.at(i + 1), link.diameter));
index++;
}
}
was_snapped = false;
}
else if (begin)
{
current_link = {
"LINK_" + std::to_string(network->links.size()),
"",
"",
1.0f,
0.0f,
0.0f,
std::vector<glm::vec3>{}};
// set start pos to nearest node within snapping distance
start_pos = world_pos;
int i = snap_to_node(world_pos);
if (i != -1)
{
Node node = network->nodes.at(i);
start_pos.x = node.easting;
start_pos.y = node.northing;
network->nodes.at(i).dn_IDs.push_back(current_link.ID);
current_link.points.push_back({start_pos.x, start_pos.y, node.invert_elevation});
current_link.up_ID = node.ID;
}
else
{
current_link.points.push_back({start_pos.x, start_pos.y, 0.0f});
}
begin = false;
link_mesh->push_instance(glm::scale(glm::mat4(1.0f), glm::vec3(0.0f)));
use();
}
else
{
link_mesh->modify_instance(link_mesh->size() - 1, link_to_model(start_pos, world_pos, 1.0f));
link_mesh->push_instance(glm::scale(glm::mat4(1.0f), glm::vec3(0.0f)));
prev_start_pos = start_pos;
start_pos = world_pos;
int i = snap_to_node(world_pos);
if (i != -1)
{
Node node = network->nodes.at(i);
network->nodes.at(i).up_IDs.push_back(current_link.ID);
current_link.dn_ID = node.ID;
world_pos.x = node.easting;
world_pos.y = node.northing;
link_mesh->modify_instance(link_mesh->size() - 2, link_to_model(prev_start_pos, world_pos, 1.0f));
link_mesh->modify_instance(link_mesh->size() - 1, link_to_model(world_pos, start_pos, 1.0f));
current_link.points.push_back({world_pos.x, world_pos.y, node.invert_elevation});
network->links.push_back(current_link);
current_link = {
"LINK_" + std::to_string(network->links.size()),
"",
"",
1.0f,
0.0f,
0.0f,
std::vector<glm::vec3>{}};
network->nodes.at(i).dn_IDs.push_back(current_link.ID);
current_link.up_ID = node.ID;
current_link.points.push_back({world_pos.x, world_pos.y, node.invert_elevation});
glm::vec3 temp = start_pos;
start_pos = world_pos;
world_pos = temp;
was_snapped = true;
}
else
{
int index = current_link.points.size() - 1;
float z = current_link.points.at(index).z;
current_link.points.push_back({world_pos.x, world_pos.y, z});
was_snapped = false;
}
}
last_time = time;
}
}
virtual void on_mouse_hover(glm::vec3 world_pos, int x, int y)
{
link_mesh->modify_instance(link_mesh->size() - 1, link_to_model(start_pos, world_pos, 1.0f));
}
virtual void on_mouse_left_drag(glm::vec3 direction, int dx, int dy) {}
glm::mat4 link_to_model(glm::vec3 start, glm::vec3 end, float diameter)
{
end.z += diameter / 2.0f;
start.z += diameter / 2.0f;
glm::mat4 trans = glm::translate(glm::mat4(1.0f), start);
glm::vec3 direction = end - start;
float length = glm::length(direction);
glm::mat4 scale = glm::scale(glm::mat4(1.0f), glm::vec3(diameter, length, diameter));
float h_angle = 0.0f;
if (direction.x > 0.0f)
{
h_angle = atan(direction.y / direction.x) - M_PI_2;
}
else if (direction.x < 0.0f)
{
h_angle = atan(direction.y / direction.x) + M_PI_2;
}
else if (direction.y < 0.0f)
{
h_angle = -M_PI;
}
glm::mat4 h_rotation = glm::rotate(glm::mat4(1.0f), h_angle, glm::vec3(0.0f, 0.0f, 1.0f));
float h_length = glm::length(glm::vec2(direction));
float v_angle = atan(direction.z / h_length);
glm::vec2 axis = glm::normalize(glm::vec2(glm::rotateZ(direction, float(-M_PI_2))));
glm::mat4 v_rotation = glm::rotate(glm::mat4(1.0f), v_angle, glm::vec3(axis.x, axis.y, 0.0f));
return trans * v_rotation * h_rotation * scale;
}
int snap_to_node(glm::vec3 world_pos)
{
int index = -1;
int i = 0;
float min_dist = std::numeric_limits<float>::infinity();
for (auto node : network->nodes)
{
glm::vec2 node_pos = {node.easting, node.northing};
float dist = glm::length(node_pos - glm::vec2(world_pos));
if (dist < min_dist)
{
min_dist = dist;
if (min_dist <= *snapping_distance)
{
index = i;
}
}
i++;
}
return index;
}
private:
// Icon
Rectangle *link;
Circle *node1;
Circle *node2;
// application
Network* network;
InstancedMesh *link_mesh;
float* snapping_distance;
// tool
bool begin = true;
glm::vec3 start_pos{};
glm::vec3 prev_start_pos{};
double last_time = 0.0;
Link current_link;
bool was_snapped = false;
};
#endif | 41.731183 | 130 | 0.488362 | [
"vector"
] |
b5b9e2341c9350c9d6dcc77ab7347cf2dfbf34f6 | 2,948 | cpp | C++ | Source/BuildingEscape/Grabber.cpp | DMinsky/udemy_building_escape | a5cdaa0a1a17d6778c2bb600bf69f85d46f3244d | [
"MIT"
] | null | null | null | Source/BuildingEscape/Grabber.cpp | DMinsky/udemy_building_escape | a5cdaa0a1a17d6778c2bb600bf69f85d46f3244d | [
"MIT"
] | null | null | null | Source/BuildingEscape/Grabber.cpp | DMinsky/udemy_building_escape | a5cdaa0a1a17d6778c2bb600bf69f85d46f3244d | [
"MIT"
] | null | null | null | // Fill out your copyright notice in the Description page of Project Settings.
#include "GameFramework/PlayerController.h"
#include "Engine/World.h"
#include "Grabber.h"
#include "DrawDebugHelpers.h"
#define OUT
// Sets default values for this component's properties
UGrabber::UGrabber()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;
}
// Called when the game starts
void UGrabber::BeginPlay()
{
Super::BeginPlay();
FindPhysicsHandle();
SetupInput();
}
void UGrabber::FindPhysicsHandle()
{
PhysicsHandle = GetOwner()->FindComponentByClass<UPhysicsHandleComponent>();
if (!PhysicsHandle) {
UE_LOG(LogTemp, Error, TEXT("%s has no UPhysicsHandleComponent!"), *(GetOwner()->GetName()));
}
}
void UGrabber::SetupInput()
{
InputComponent = GetOwner()->FindComponentByClass<UInputComponent>();
if (InputComponent)
{
InputComponent->BindAction("Grab", IE_Pressed, this, &UGrabber::Grab);
InputComponent->BindAction("Release", IE_Released, this, &UGrabber::Release);
}
}
void UGrabber::Grab()
{
UE_LOG(LogTemp, Log, TEXT("GRAB"));
FHitResult HitResult = GetFirstPhysicalBodyInReach();
AActor* HitActor = HitResult.GetActor();
if (HitActor)
{
UE_LOG(LogTemp, Log, TEXT("GRAB %s"), *HitActor->GetName());
UPrimitiveComponent* GrabComponent = HitResult.GetComponent();
if (!PhysicsHandle) { return; }
PhysicsHandle->GrabComponentAtLocation(
GrabComponent,
NAME_None,
GetLookVector(Reach)
);
}
}
void UGrabber::Release()
{
if (!PhysicsHandle) { return; }
if (PhysicsHandle->GrabbedComponent) {
PhysicsHandle->ReleaseComponent();
}
}
void UGrabber::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
if (!PhysicsHandle) { return; }
if (PhysicsHandle->GrabbedComponent) {
PhysicsHandle->SetTargetLocation(GetLookVector(Reach));
}
}
FHitResult UGrabber::GetFirstPhysicalBodyInReach() const
{
FHitResult HitResult;
FCollisionQueryParams QueryParams(FName(TEXT("")), false, GetOwner());
bool Hit = GetWorld()->LineTraceSingleByObjectType(
OUT HitResult,
GetPlayerLocation(),
GetLookVector(Reach),
FCollisionObjectQueryParams(ECollisionChannel::ECC_PhysicsBody),
QueryParams
);
return HitResult;
}
FVector UGrabber::GetLookVector(float Distance) const
{
FVector PlayerLocation;
FRotator PlayerRotation;
GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint(OUT PlayerLocation, OUT PlayerRotation);
return PlayerLocation + PlayerRotation.Vector() * Distance;
}
FVector UGrabber::GetPlayerLocation() const
{
FVector PlayerLocation;
FRotator PlayerRotation;
GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint(OUT PlayerLocation, OUT PlayerRotation);
return PlayerLocation;
} | 27.551402 | 121 | 0.75848 | [
"vector"
] |
b5be7f05eda69e561ae9146830fb214af5adfc44 | 3,784 | cc | C++ | models/topic-models/template-modeling/src/template_sampler.cc | ypetinot/web-summarization | 2f7caf51b1e8bf5e510ce91070d622c8119e9865 | [
"Apache-2.0"
] | null | null | null | models/topic-models/template-modeling/src/template_sampler.cc | ypetinot/web-summarization | 2f7caf51b1e8bf5e510ce91070d622c8119e9865 | [
"Apache-2.0"
] | null | null | null | models/topic-models/template-modeling/src/template_sampler.cc | ypetinot/web-summarization | 2f7caf51b1e8bf5e510ce91070d622c8119e9865 | [
"Apache-2.0"
] | 1 | 2016-03-03T04:58:44.000Z | 2016-03-03T04:58:44.000Z | #include "template_alignment.h"
#include "template_sampler.h"
#include <boost/lexical_cast.hpp>
#include <iostream>
#include <fstream>
#include <glog/logging.h>
/* constructor */
TemplateSampler::TemplateSampler( Corpus& corpus , const vector< tr1::shared_ptr<Gist> >& gists )
:_corpus(corpus),data(gists),_iteration_number(0) {
for ( vector< tr1::shared_ptr<Gist> >::const_iterator iter = gists.begin(); iter != gists.end(); iter++ ) {
#if 0 /* for now we do not initialize anything */
/* collect initial gappy patterns */
set<unsigned int> active_colors = (*iter)->get_colors();
for ( set<unsigned int>::iterator color_iter = active_colors.begin(); color_iter != active_colors.end(); ++color_iter ) {
_increment_pattern_count( ( (*iter)->get_color_pattern_from_color( *color_iter ) ).get() );
}
#endif
}
}
/* run one sampler iteration */
void TemplateSampler::iterate() {
LOG(INFO) << "\t" << "Iteration # " << ++_iteration_number << " ...";
/* Iterate over each training sample */
for ( vector< tr1::shared_ptr<Gist> >::const_iterator iter = data.begin(); iter != data.end(); ++iter ) {
/* Update model for the current data sample */
(*iter)->sample_template();
}
}
/* check whether the sampler has converged */
bool TemplateSampler::has_converged() {
/* 1 - compute likelihood of current model */
/* TODO */
return false;
}
/* return iteration number */
unsigned int TemplateSampler::get_iteration_number() const {
return _iteration_number;
}
/* dump state (sampler + gists) */
void TemplateSampler::dump_state() {
dump_state_sampler();
dump_state_gists();
}
/* dump gists state */
void TemplateSampler::dump_state_gists() {
string filename = "dump_gists." + boost::lexical_cast<std::string>( get_iteration_number() ) + ".out" ;
ofstream gists_state_output( filename.c_str() );
vector< tr1::shared_ptr<Gist> >::const_iterator iter = data.begin();
while ( iter != data.end() ) {
gists_state_output << (*iter)->as_string() << "\t" << (*iter)->get_category()->get_label() << endl;
iter++;
}
gists_state_output.close();
}
/* dump sampler state */
void TemplateSampler::dump_state_sampler() {
vector< GappyPatternProcess* > slot_types = _corpus.get_slot_types();
vector< GappyPatternProcess* >::const_iterator iter = slot_types.begin();
while ( iter != slot_types.end() ) {
/* output file */
unsigned int type_id = iter - slot_types.begin();
string filename = "dump_state." + boost::lexical_cast<std::string>( get_iteration_number() ) + "." +
boost::lexical_cast<std::string>( type_id ) + ".out" ;
(*iter)->dump_state( filename );
iter++;
}
}
/* compute log likelihood */
double TemplateSampler::log_likelihood() const {
double _log_likelihood = 0.0;
for ( vector< tr1::shared_ptr<Gist> >::const_iterator iter = data.begin(); iter != data.end(); ++iter ) {
/* compute likelihood for the current gist */
_log_likelihood += log_likelihood( (*iter).get() );
}
return _log_likelihood;
}
/* compute log likelihood for a specific gist */
double TemplateSampler::log_likelihood( Gist* gist ) const {
double _log_likelihood = 0.0;
// P( w , c | params ) \prop P ( c | w , params )
// P( color combination ) * P
// --> # of colors --> #
/* likelihood of individual color assignments */
_log_likelihood = 0.0;
return _log_likelihood;
}
/* sample slot word pattern */
void TemplateSampler::_sample_slot_word_pattern( Gist* gist , unsigned int index ) {
/* 1 - get the slot object for the target location */
tr1::shared_ptr<TemplateSlot> target_slot = gist->get_template()->get_slot_at_word_location( index );
/* 2 - run the sampling procedure */
target_slot->sample_color( index );
}
| 25.226667 | 125 | 0.667548 | [
"object",
"vector",
"model"
] |
b5bf8af5f05273916d93f6d1c08ad2bd63141dd2 | 12,297 | cpp | C++ | src/Util/Util.cpp | scemino/engge | 3362ad56b67f58bdc89f7eb1a77f0f75bd350e1f | [
"MIT"
] | 127 | 2018-12-09T18:40:02.000Z | 2022-03-06T00:10:07.000Z | src/Util/Util.cpp | scemino/engge | 3362ad56b67f58bdc89f7eb1a77f0f75bd350e1f | [
"MIT"
] | 267 | 2019-02-26T22:16:48.000Z | 2022-02-09T09:49:22.000Z | src/Util/Util.cpp | scemino/engge | 3362ad56b67f58bdc89f7eb1a77f0f75bd350e1f | [
"MIT"
] | 17 | 2019-02-26T20:45:34.000Z | 2021-06-17T15:06:26.000Z | #include "../../extlibs/squirrel/squirrel/sqpcheader.h"
#include "../../extlibs/squirrel/squirrel/sqvm.h"
#include "../../extlibs/squirrel/squirrel/sqstring.h"
#include "../../extlibs/squirrel/squirrel/sqtable.h"
#include "../../extlibs/squirrel/squirrel/sqarray.h"
#include "../../extlibs/squirrel/squirrel/sqfuncproto.h"
#include "../../extlibs/squirrel/squirrel/sqclosure.h"
#include "engge/Engine/EntityManager.hpp"
#include "engge/Scripting/ScriptEngine.hpp"
#include <codecvt>
#include <ngf/IO/GGPackValue.h>
#include "Util.hpp"
#include "engge/System/Locator.hpp"
#include "engge/Engine/Preferences.hpp"
namespace ng {
namespace {
constexpr const char *objectKey = "_objectKey";
constexpr const char *roomKey = "_roomKey";
constexpr const char *actorKey = "_actorKey";
constexpr const char *idKey = "_id";
ngf::GGPackValue toGGPackValue(SQObject obj, bool checkId, const std::string &tableKey = "");
bool canSave(HSQOBJECT obj) {
switch (sq_type(obj)) {
case OT_STRING: return true;
case OT_INTEGER: return true;
case OT_BOOL:return true;
case OT_FLOAT:return true;
case OT_NULL:return true;
case OT_TABLE:return true;
case OT_ARRAY:return true;
default:return false;
}
}
ngf::GGPackValue toArray(HSQOBJECT obj) {
ngf::GGPackValue array;
SQObjectPtr refpos;
SQObjectPtr outkey, outvar;
SQInteger res;
while ((res = obj._unVal.pArray->Next(refpos, outkey, outvar)) != -1) {
if (canSave(outvar)) {
array.push_back(toGGPackValue(outvar, true));
}
refpos._type = OT_INTEGER;
refpos._unVal.nInteger = res;
}
return array;
}
ngf::GGPackValue toTable(HSQOBJECT table, bool checkId, const std::string &tableKey = "") {
ngf::GGPackValue hash;
int id;
if (checkId && ng::ScriptEngine::get(table, idKey, id)) {
if (ng::EntityManager::isActor(id)) {
auto pActor = ng::EntityManager::getActorFromId(id);
if (pActor && pActor->getKey() != tableKey) {
hash[actorKey] = pActor->getKey();
return hash;
}
return nullptr;
}
if (ng::EntityManager::isObject(id)) {
auto pObj = ng::EntityManager::getObjectFromId(id);
if (pObj && pObj->getKey() != tableKey) {
auto pRoom = pObj->getRoom();
if (pRoom && pRoom->isPseudoRoom()) {
hash[roomKey] = pRoom->getName();
}
hash[objectKey] = pObj->getKey();
return hash;
}
return nullptr;
}
if (ng::EntityManager::isRoom(id)) {
auto pRoom = ng::EntityManager::getRoomFromId(id);
if (pRoom && pRoom->getName() != tableKey) {
hash[roomKey] = pRoom->getName();
return hash;
}
return nullptr;
}
return nullptr;
}
SQObjectPtr refpos;
SQObjectPtr outkey, outvar;
SQInteger res;
while ((res = table._unVal.pTable->Next(false, refpos, outkey, outvar)) != -1) {
std::string key = _stringval(outkey);
if (!key.empty() && key[0] != '_' && canSave(outvar)) {
auto value = toGGPackValue(outvar, true, key);
if (!value.isNull()) {
hash[key] = value;
}
}
refpos._type = OT_INTEGER;
refpos._unVal.nInteger = res;
}
return hash;
}
ngf::GGPackValue toGGPackValue(SQObject obj, bool checkId, const std::string &tableKey) {
switch (sq_type(obj)) {
case OT_STRING:return _stringval(obj);
case OT_INTEGER:
case OT_BOOL:return static_cast<int>(_integer(obj));
case OT_FLOAT:return static_cast<float >(_float(obj));
case OT_NULL:return nullptr;
case OT_TABLE: return toTable(obj, checkId, tableKey);
case OT_ARRAY: {
return toArray(obj);
}
default:assert(false);
}
}
}
std::string str_toupper(std::string s) {
std::transform(s.begin(), s.end(), s.begin(),
[](unsigned char c) { return ::toupper(c); } // correct
);
return s;
}
void replaceAll(std::string &text, const std::string &search, const std::string &replace) {
auto pos = text.find(search);
while (pos != std::string::npos) {
text.replace(pos, search.size(), replace);
pos = text.find(search, pos + replace.size());
}
}
void replaceAll(std::wstring &text, const std::wstring &search, const std::wstring &replace) {
auto pos = text.find(search);
while (pos != std::wstring::npos) {
text.replace(pos, search.size(), replace);
pos = text.find(search, pos + replace.size());
}
}
void removeFirstParenthesis(std::wstring &text) {
if (text.size() < 2)
return;
if (text.find(L'(') != 0)
return;
auto pos = text.find(L')');
if (pos == std::wstring::npos)
return;
text = text.substr(pos + 1);
}
bool startsWith(const std::string &str, const std::string &prefix) {
return str.length() >= prefix.length() && 0 == str.compare(0, prefix.length(), prefix);
}
bool endsWith(const std::string &str, const std::string &suffix) {
return str.length() >= suffix.length() && 0 == str.compare(str.length() - suffix.length(), suffix.length(), suffix);
}
void checkLanguage(std::string &str) {
if (endsWith(str, "_en")) {
const auto &lang = Locator<Preferences>::get().getUserPreference<std::string>(PreferenceNames::Language,
PreferenceDefaultValues::Language);
str = str.substr(0, str.length() - 3).append("_").append(lang);
return;
}
if (str.length() > 7 && str[str.length() - 4] == '.' && str.substr(str.length() - 7, 3) == "_en") {
const auto &lang = Locator<Preferences>::get().getUserPreference<std::string>(PreferenceNames::Language,
PreferenceDefaultValues::Language);
str = str.substr(0, str.length() - 7).append("_").append(lang).append(str.substr(str.length() - 4, 4));
}
}
bool getLine(GGPackBufferStream &input, std::string &line) {
char c;
line.clear();
do {
input.read(&c, 1);
if (c == 0 || c == '\n') {
return input.tell() < input.getLength();
}
line.append(&c, 1);
} while (true);
}
std::wstring towstring(const std::string &text) {
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> converter;
return converter.from_bytes(text.data(), text.data() + text.size());
}
std::string tostring(const std::wstring &text) {
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> converter;
return converter.to_bytes(text);
}
std::string toUtf8(const std::wstring &text) {
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
return converter.to_bytes(text);
}
bool getLine(GGPackBufferStream &input, std::wstring &wline) {
std::string line;
char c;
do {
input.read(&c, 1);
if (c == 0 || c == '\n') {
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> converter;
wline = converter.from_bytes(line.data(), line.data() + line.size());
return input.tell() < input.getLength();
}
line.append(&c, 1);
} while (true);
}
float distanceSquared(const glm::vec2 &vector1, const glm::vec2 &vector2) {
float dx = vector1.x - vector2.x;
float dy = vector1.y - vector2.y;
return dx * dx + dy * dy;
}
float distance(const glm::vec2 &v1, const glm::vec2 &v2) {
return std::sqrt(distanceSquared(v1, v2));
}
float length(const glm::vec2 &v) {
return sqrtf(v.x * v.x + v.y * v.y);
}
const double EPS = 1E-9;
double det(float a, float b, float c, float d) {
return a * d - b * c;
}
inline bool betw(float l, float r, float x) {
return fmin(l, r) <= x + EPS && x <= fmax(l, r) + EPS;
}
template<typename T>
void swap(T &a, T &b) {
T c = a;
a = b;
b = c;
}
inline bool intersect_1d(float a, float b, float c, float d) {
if (a > b)
swap(a, b);
if (c > d)
swap(c, d);
return fmax(a, c) <= fmin(b, d) + EPS;
}
bool less(const glm::vec2 &p1, const glm::vec2 &p2) {
return p1.x < p2.x - EPS || (fabs(p1.x - p2.x) < EPS && p1.y < p2.y - EPS);
}
Facing toFacing(std::optional<UseDirection> direction) {
auto dir = direction.value_or(UseDirection::Front);
switch (dir) {
case UseDirection::Front:return Facing::FACE_FRONT;
case UseDirection::Back:return Facing::FACE_BACK;
case UseDirection::Left:return Facing::FACE_LEFT;
case UseDirection::Right:return Facing::FACE_RIGHT;
}
}
Facing getOppositeFacing(Facing facing) {
switch (facing) {
case Facing::FACE_FRONT:return Facing::FACE_BACK;
case Facing::FACE_BACK:return Facing::FACE_FRONT;
case Facing::FACE_LEFT:return Facing::FACE_RIGHT;
case Facing::FACE_RIGHT:return Facing::FACE_LEFT;
}
}
ngf::irect toRect(const ngf::GGPackValue &json) {
auto x = json["x"].getInt();
auto y = json["y"].getInt();
auto w = json["w"].getInt();
auto h = json["h"].getInt();
return ngf::irect::fromPositionSize({x, y}, {w, h});
}
glm::ivec2 toSize(const ngf::GGPackValue &json) {
glm::ivec2 v;
v.x = json["w"].getInt();
v.y = json["h"].getInt();
return v;
}
UseDirection toDirection(const std::string &text) {
if (strcmp(text.c_str(), "DIR_FRONT") == 0) {
return UseDirection::Front;
}
if (strcmp(text.c_str(), "DIR_LEFT") == 0) {
return UseDirection::Left;
}
if (strcmp(text.c_str(), "DIR_BACK") == 0) {
return UseDirection::Back;
}
if (strcmp(text.c_str(), "DIR_RIGHT") == 0) {
return UseDirection::Right;
}
return UseDirection::Front;
}
glm::vec2 parsePos(const std::string &text) {
auto commaPos = text.find_first_of(',');
auto x = std::strtof(text.substr(1, commaPos - 1).c_str(), nullptr);
auto y = std::strtof(text.substr(commaPos + 1, text.length() - 1).c_str(), nullptr);
return glm::vec2(x, y);
}
ngf::irect parseRect(const std::string &text) {
auto re = std::regex(R"(\{\{(\-?\d+),(\-?\d+)\},\{(\-?\d+),(\-?\d+)\}\})");
std::smatch matches;
std::regex_search(text, matches, re);
auto left = std::strtol(matches[1].str().c_str(), nullptr, 10);
auto top = std::strtol(matches[2].str().c_str(), nullptr, 10);
auto right = std::strtol(matches[3].str().c_str(), nullptr, 10);
auto bottom = std::strtol(matches[4].str().c_str(), nullptr, 10);
return ngf::irect::fromPositionSize({left, top}, {right - left, bottom - top});
}
void parsePolygon(const std::string &text, std::vector<glm::ivec2> &vertices) {
int i = 1;
int endPos;
do {
auto commaPos = text.find_first_of(',', i);
auto x = std::strtol(text.substr(i, commaPos - i).c_str(), nullptr, 10);
endPos = text.find_first_of('}', commaPos + 1);
auto y = std::strtol(text.substr(commaPos + 1, endPos - commaPos - 1).c_str(), nullptr, 10);
i = endPos + 3;
vertices.emplace_back(x, y);
} while (static_cast<int>(text.length() - 1) != endPos);
}
ngf::Color parseColor(const std::string &color) {
auto c = std::strtol(color.c_str(), nullptr, 16);
return fromRgb(c);
}
ngf::Color fromRgba(SQInteger color) {
auto col = static_cast<uint32_t>(color);
ngf::Color c(
static_cast<int>((col >> 16) & 255),
static_cast<int>((col >> 8) & 255),
static_cast<int>(col & 255),
static_cast<int>((col >> 24) & 255));
return c;
}
int toInteger(const ngf::Color &c) {
auto r = static_cast<uint32_t>(c.r * 255u);
auto g = static_cast<uint32_t>(c.g * 255u);
auto b = static_cast<uint32_t>(c.b * 255u);
auto a = static_cast<uint32_t>(c.a * 255u);
return static_cast<int>((r << 16) | (g << 8) | b | (a << 24));
}
ngf::Color fromRgb(SQInteger color) {
auto col = static_cast<int>(color);
ngf::Color c((col >> 16) & 255, (col >> 8) & 255, col & 255);
return c;
}
glm::vec2 toDefaultView(glm::ivec2 pos, glm::ivec2 fromSize) {
return glm::vec2((Screen::Width * pos.x) / fromSize.x, (Screen::Height * pos.y) / fromSize.y);
}
InterpolationMethod toInterpolationMethod(SQInteger interpolation) {
auto method = static_cast<InterpolationMethod>((interpolation & 7) + 1);
if (interpolation & 0x100) {
method |= InterpolationMethod::Looping;
}
if (interpolation & 0x200) {
method |= InterpolationMethod::Swing;
}
return method;
}
ngf::frect getGlobalBounds(const ngf::Text &text) {
return ngf::transform(text.getTransform().getTransform(), text.getLocalBounds());
}
ngf::frect getGlobalBounds(const ngf::Sprite &sprite) {
return ngf::transform(sprite.getTransform().getTransform(), sprite.getLocalBounds());
}
ngf::GGPackValue toGGPackValue(HSQOBJECT obj) {
return toGGPackValue((SQObject) obj, false);
}
} // namespace ng
| 30.513648 | 118 | 0.636741 | [
"vector",
"transform"
] |
b5c3d91cf974f8e8d6d4d117538c3793b1ed78b9 | 7,305 | cpp | C++ | examples/branin_hoo/branin_hoo.cpp | alan-turing-institute/BOAT | f8bb0313f6a3ae5bbec169431d613d7b53235694 | [
"Apache-2.0"
] | 1 | 2020-02-19T19:56:29.000Z | 2020-02-19T19:56:29.000Z | examples/branin_hoo/branin_hoo.cpp | alan-turing-institute/BOAT | f8bb0313f6a3ae5bbec169431d613d7b53235694 | [
"Apache-2.0"
] | 5 | 2019-03-22T08:44:31.000Z | 2019-03-22T16:04:18.000Z | examples/branin_hoo/branin_hoo.cpp | alan-turing-institute/BOAT | f8bb0313f6a3ae5bbec169431d613d7b53235694 | [
"Apache-2.0"
] | null | null | null | #include "boat.hpp"
using namespace std;
using boat::ProbEngine;
using boat::SemiParametricModel;
using boat::DAGModel;
using boat::GPParams;
using boat::NLOpt;
using boat::BayesOpt;
using boat::SimpleOpt;
using boat::generator;
using boat::RangeParameter;
struct BHParams{
BHParams() : x1_(-5, 10), x2_(0, 15){}
RangeParameter<double> x1_;
RangeParameter<double> x2_;
};
/// The Branin-Hoo objective function
double branin_hoo(const BHParams& p){
static constexpr double a = 1;
static constexpr double b = 5.1 / (4 * pow(M_PI, 2));
static constexpr double c = 5.0 / M_PI;
static constexpr double r = 6.0;
static constexpr double s = 10;
static constexpr double t = 1.0 / (8 * M_PI);
double x1 = p.x1_.value();
double x2 = p.x2_.value();
double fx = a * pow(x2 - b * pow(x1, 2) + c * x1 - r, 2) +
s * (1.0 - t) * std::cos(x1) + s;
return fx;
}
double branin_hoo_first_term(const BHParams& p){
static constexpr double s = 10;
static constexpr double t = 1.0 / (8 * M_PI);
double x1 = p.x1_.value();
double fx = s * (1.0 - t) * std::cos(x1) + s;
return fx;
}
/// Naive way of optimizing it, model with simple GP prior
struct Param : public SemiParametricModel<Param> {
Param() {
p_.default_noise(0.0);
p_.mean(uniform_real_distribution<>(0.0, 10.0)(generator));
p_.stdev(uniform_real_distribution<>(0.0, 200.0)(generator));
p_.linear_scales({uniform_real_distribution<>(0.0, 15.0)(generator),
uniform_real_distribution<>(0.0, 15.0)(generator)});
set_params(p_);
}
GPParams p_;
};
struct FullModel : public DAGModel<FullModel> {
FullModel(){
eng_.set_num_particles(100);
}
void model(const BHParams& p) {
output("objective", eng_, p.x1_.value(), p.x2_.value());
}
void print() {
PR(AVG_PROP(eng_, p_.mean()));
PR(AVG_PROP(eng_, p_.stdev()));
PR(AVG_PROP(eng_, p_.linear_scales()[0]));
PR(AVG_PROP(eng_, p_.linear_scales()[1]));
}
ProbEngine<Param> eng_;
};
void maximize_ei(FullModel& m, BHParams& p, double incumbent) {
NLOpt<> opt(p.x1_, p.x2_);
auto obj = [&]() {
double r = m.expected_improvement("objective", incumbent, p);
return r;
};
opt.set_objective_function(obj);
opt.set_max_num_iterations(10000);
opt.set_maximizing();
opt.run_optimization();
}
void bo_naive_optim() {
FullModel m;
m.set_num_particles(100);
BHParams p;
BayesOpt<unordered_map<string, double> > opt;
auto subopt = [&]() {
maximize_ei(m, p, opt.best_objective());
};
auto util = [&](){
unordered_map<string, double> res;
res["objective"] = branin_hoo(p);
PR(p.x1_.value(), p.x2_.value(), res["objective"]);
return res;
};
auto learn = [&](const unordered_map<string, double>& r){
m.observe(r, p);
};
opt.set_subopt_function(subopt);
opt.set_objective_function(util);
opt.set_learning_function(learn);
opt.set_minimizing();
opt.set_max_num_iterations(25);
opt.run_optimization();
}
/// Structured way of optimizing it, more accurate model
struct FirstTermModel : public SemiParametricModel<FirstTermModel> {
FirstTermModel() {
alpha_ = uniform_real_distribution<>(0.0, 20.0)(generator);
p_.default_noise(0.0);
p_.mean(uniform_real_distribution<>(0.0, 10.0)(generator));
p_.stdev(uniform_real_distribution<>(0.0, 200.0)(generator));
p_.linear_scales({uniform_real_distribution<>(0.0, 15.0)(generator)});
set_params(p_);
}
double parametric(double x1) const {
return alpha_ * cos(x1);
}
double alpha_;
GPParams p_;
};
struct SecondTermModel : public SemiParametricModel<SecondTermModel> {
SecondTermModel() {
beta_ = uniform_real_distribution<>(0.0, 20.0)(generator);
p_.default_noise(0.0);
p_.mean(uniform_real_distribution<>(0.0, 10.0)(generator));
p_.stdev(uniform_real_distribution<>(0.0, 200.0)(generator));
p_.linear_scales({uniform_real_distribution<>(0.0, 15.0)(generator),
uniform_real_distribution<>(0.0, 15.0)(generator)});
set_params(p_);
}
double parametric(double first_term, double x1, double x2) const {
return first_term + pow(x2, 2.0) + beta_ * pow(x1, 4.0);
}
vector<double> to_vec(double first_term, double x1, double x2) const {
return {x1, x2};
}
double beta_;
GPParams p_;
};
struct BHModel : public DAGModel<BHModel> {
BHModel() {
first_.set_num_particles(100000);
second_.set_num_particles(100000);
}
void model(const BHParams& p) {
double ft = output("first", first_, p.x1_.value());
output("objective", second_, ft, p.x1_.value(), p.x2_.value());
}
ProbEngine<FirstTermModel> first_;
ProbEngine<SecondTermModel> second_;
};
void maximize_ei(BHModel& m, BHParams& p, double incumbent) {
NLOpt<> opt(p.x1_, p.x2_);
auto obj = [&]() {
double r = m.expected_improvement("objective", incumbent, p);
return r;
};
opt.set_objective_function(obj);
opt.set_max_num_iterations(10000);
opt.set_maximizing();
opt.run_optimization();
}
void bo_struct_optim() {
BHModel m;
m.set_num_particles(100);
BHParams p;
BayesOpt<unordered_map<string, double> > opt;
auto subopt = [&]() {
maximize_ei(m, p, opt.best_objective());
};
auto util = [&](){
unordered_map<string, double> res;
res["first"] = branin_hoo_first_term(p);
res["objective"] = branin_hoo(p);
PR(p.x1_.value(), p.x2_.value(), res["first"], res["objective"]);
return res;
};
auto learn = [&](const unordered_map<string, double>& r){
m.observe(r, p);
};
opt.set_subopt_function(subopt);
opt.set_objective_function(util);
opt.set_learning_function(learn);
opt.set_minimizing();
opt.set_max_num_iterations(25);
opt.run_optimization();
}
/// Better optimization procedure: sample from the model and optimize its
/// prediction
void maximize_sample_prediction(BHModel& m, BHParams& p) {
NLOpt<> opt(p.x1_, p.x2_);
auto util = [&]() {
return m.sample_predict("objective", p);
};
opt.set_objective_function(util);
opt.set_minimizing();
opt.set_max_num_iterations(10000);
opt.run_optimization();
}
void maximize_with_samples(BHModel& m, BHParams& p, double incumbent) {
SimpleOpt<> opt;
auto util = [&]() {
auto s = m.sample();
maximize_sample_prediction(*s, p);
return m.expected_improvement("objective", incumbent, p);
};
opt.set_objective_function(util);
opt.set_maximizing();
opt.set_max_num_iterations(20);
opt.run_optimization();
}
void bo_struct_optim_efficient() {
BHModel m;
m.set_num_particles(100);
BHParams p;
BayesOpt<unordered_map<string, double> > opt;
auto subopt = [&]() {
maximize_with_samples(m, p, opt.best_objective());
};
auto util = [&](){
unordered_map<string, double> res;
res["first"] = branin_hoo_first_term(p);
res["objective"] = branin_hoo(p);
PR(p.x1_.value(), p.x2_.value(), res["first"], res["objective"]);
return res;
};
auto learn = [&](const unordered_map<string, double>& r){
m.observe(r, p);
};
opt.set_subopt_function(subopt);
opt.set_objective_function(util);
opt.set_learning_function(learn);
opt.set_minimizing();
opt.set_max_num_iterations(25);
opt.run_optimization();
}
int main() {
//bo_naive_optim();
//bo_struct_optim();
bo_struct_optim_efficient();
}
| 27.670455 | 74 | 0.668583 | [
"vector",
"model"
] |
b5c539421771f9ee3ad09dce4e753ac88699a9fc | 7,621 | cpp | C++ | Source/Shared/user_context_winrt.cpp | yklys/Xbox-Live-API | e409400ec38c0c131b16e09281cdc83199d1c90f | [
"MIT"
] | 1 | 2019-04-19T01:37:34.000Z | 2019-04-19T01:37:34.000Z | Source/Shared/user_context_winrt.cpp | DalavanCloud/xbox-live-api | 2166ffcb4a1ca1f5d89a43dce9ab4c5ff9b797b7 | [
"MIT"
] | null | null | null | Source/Shared/user_context_winrt.cpp | DalavanCloud/xbox-live-api | 2166ffcb4a1ca1f5d89a43dce9ab4c5ff9b797b7 | [
"MIT"
] | null | null | null | // Copyright (c) Microsoft Corporation
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#include "pch.h"
#include "xbox_system_factory.h"
#include "user_context.h"
#include "shared_macros.h"
#if defined __cplusplus_winrt
using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
#if !XSAPI_CPP
using namespace Microsoft::Xbox::Services::System;
#endif
#endif
using namespace xbox::services::system;
#if !TV_API && !XSAPI_CPP // Non-XDK WinRT
NAMESPACE_MICROSOFT_XBOX_SERVICES_CPP_BEGIN
// XDK's Windows.* user object
user_context::user_context(_In_ XboxLiveUser^ user) :
m_user(user),
m_callerContextType(xbox::services::caller_context_type::title)
{
XSAPI_ASSERT(m_user != nullptr);
m_xboxUserId = utils::internal_string_from_utf16(m_user->XboxUserId->Data());
}
user_context::user_context(_In_ std::shared_ptr<xbox_live_user> user) :
m_user(user_context::user_convert(user)),
m_callerContextType(xbox::services::caller_context_type::title)
{
XSAPI_ASSERT(m_user != nullptr);
m_xboxUserId = utils::internal_string_from_utf16(m_user->XboxUserId->Data());
}
XboxLiveUser^ user_context::user() const
{
return m_user;
}
struct auth_context
{
XboxLiveUser^ user;
String^ httpMethod;
String^ url;
String^ headers;
String^ requestBodyString;
Array<byte>^ byteArray;
xbox_live_result<user_context_auth_result> result;
xbox_live_callback<xbox_live_result<user_context_auth_result>> callback;
auth_context() : requestBodyString(nullptr), byteArray(nullptr) {}
};
void get_auth_result(
std::shared_ptr<auth_context> context,
async_queue_handle_t queue
)
{
AsyncBlock* async = new (xsapi_memory::mem_alloc(sizeof(AsyncBlock))) AsyncBlock{};
async->queue = queue;
async->context = utils::store_shared_ptr(context);
async->callback = [](AsyncBlock* async)
{
auto context = utils::get_shared_ptr<auth_context>(async->context);
context->callback(context->result);
xsapi_memory::mem_free(async);
};
auto hr = BeginAsync(async, async->context, nullptr, __FUNCTION__,
[](AsyncOp op, const AsyncProviderData* data)
{
std::shared_ptr<auth_context> context;
IAsyncOperation<GetTokenAndSignatureResult^>^ asyncOp = nullptr;
switch (op)
{
case AsyncOp_DoWork:
context = utils::get_shared_ptr<auth_context>(data->context, false);
if (context->requestBodyString != nullptr)
{
asyncOp = context->user->GetTokenAndSignatureAsync(
context->httpMethod,
context->url,
context->headers,
context->requestBodyString
);
}
else if (context->byteArray != nullptr)
{
asyncOp = context->user->GetTokenAndSignatureArrayAsync(
context->httpMethod,
context->url,
context->headers,
context->byteArray
);
}
else
{
asyncOp = context->user->GetTokenAndSignatureAsync(
context->httpMethod,
context->url,
context->headers,
""
);
}
XSAPI_ASSERT(asyncOp != nullptr);
asyncOp->Completed = ref new AsyncOperationCompletedHandler<GetTokenAndSignatureResult^>(
[data, context](IAsyncOperation<GetTokenAndSignatureResult^>^ asyncOp, AsyncStatus status)
{
UNREFERENCED_PARAMETER(status);
try
{
auto result = asyncOp->GetResults();
user_context_auth_result userContextResult(
utils::internal_string_from_utf16(result->Token->Data()),
utils::internal_string_from_utf16(result->Signature->Data())
);
context->result = xbox_live_result<user_context_auth_result>(userContextResult);
CompleteAsync(data->async, S_OK, 0);
}
catch (Exception^ ex)
{
xbox_live_error_code err = xbox::services::utils::convert_exception_to_xbox_live_error_code();
CompleteAsync(data->async, utils::convert_xbox_live_error_code_to_hresult(err), 0);
}
});
return E_PENDING;
}
return S_OK;
});
if (SUCCEEDED(hr))
{
ScheduleAsync(async, 0);
}
}
void user_context::get_auth_result(
_In_ const xsapi_internal_string& httpMethod,
_In_ const xsapi_internal_string& url,
_In_ const xsapi_internal_string& headers,
_In_ const xsapi_internal_string& requestBodyString,
_In_ bool allUsersAuthRequired,
_In_ async_queue_handle_t queue,
_In_ xbox_live_callback<xbox_live_result<user_context_auth_result>> callback
)
{
UNREFERENCED_PARAMETER(allUsersAuthRequired);
auto context = xsapi_allocate_shared<auth_context>();
context->user = m_user;
context->httpMethod = UtilsWinRT::StringFromInternalString(httpMethod);
context->url = UtilsWinRT::StringFromInternalString(url);
context->headers = UtilsWinRT::StringFromInternalString(headers);
context->requestBodyString = UtilsWinRT::StringFromInternalString(requestBodyString);
context->callback = std::move(callback);
xbox::services::get_auth_result(context, queue);
}
void user_context::get_auth_result(
_In_ const xsapi_internal_string& httpMethod,
_In_ const xsapi_internal_string& url,
_In_ const xsapi_internal_string& headers,
_In_ const xsapi_internal_vector<unsigned char>& requestBody,
_In_ bool allUsersAuthRequired,
_In_ async_queue_handle_t queue,
_In_ xbox_live_callback<xbox_live_result<user_context_auth_result>> callback
)
{
UNREFERENCED_PARAMETER(allUsersAuthRequired);
auto context = xsapi_allocate_shared<auth_context>();
context->user = m_user;
context->httpMethod = UtilsWinRT::StringFromInternalString(httpMethod);
context->url = UtilsWinRT::StringFromInternalString(url);
context->headers = UtilsWinRT::StringFromInternalString(headers);
context->byteArray = ref new Array<byte>(static_cast<uint32_t>(requestBody.size()));
memcpy(&context->byteArray->Data[0], &requestBody[0], requestBody.size());
context->callback = std::move(callback);
xbox::services::get_auth_result(context, queue);
}
void user_context::refresh_token(
_In_ async_queue_handle_t queue,
_In_ xbox_live_callback<xbox_live_result<std::shared_ptr<token_and_signature_result_internal>>> callback
)
{
auto authConfig = m_user->_User_impl()->get_auth_config();
m_user->_User_impl()->internal_get_token_and_signature(
"GET",
authConfig->xbox_live_endpoint(),
xsapi_internal_string(),
xsapi_internal_string(),
xsapi_internal_vector<unsigned char>(),
false,
true,
queue,
[callback](xbox_live_result<std::shared_ptr<token_and_signature_result_internal>> result)
{
callback(xbox_live_result<std::shared_ptr<token_and_signature_result_internal>>(result.err(), result.err_message()));
});
}
bool user_context::is_signed_in() const
{
if (!user()) return false;
return user()->IsSignedIn;
}
NAMESPACE_MICROSOFT_XBOX_SERVICES_CPP_END
#endif | 34.022321 | 125 | 0.663036 | [
"object"
] |
b5c583bb44fa6dbe6137b4f2d0cafa5d382279e4 | 11,338 | cpp | C++ | lib/elf/file-emitter.cpp | Dennisbonke/lewis | 456c4d3f02eeab38f091f5ec8c5836cee894553f | [
"MIT"
] | 10 | 2018-12-25T21:59:36.000Z | 2021-06-08T13:26:02.000Z | lib/elf/file-emitter.cpp | Dennisbonke/lewis | 456c4d3f02eeab38f091f5ec8c5836cee894553f | [
"MIT"
] | 2 | 2019-07-14T11:04:21.000Z | 2021-07-25T15:13:41.000Z | lib/elf/file-emitter.cpp | Dennisbonke/lewis | 456c4d3f02eeab38f091f5ec8c5836cee894553f | [
"MIT"
] | 4 | 2018-12-25T19:48:55.000Z | 2022-02-13T16:26:57.000Z | // Copyright the lewis authors (AUTHORS.md) 2018
// SPDX-License-Identifier: MIT
#include <cassert>
#include <iostream>
#include <elf.h>
#include <lewis/elf/file-emitter.hpp>
#include <lewis/elf/passes.hpp>
#include <lewis/elf/utils.hpp>
namespace lewis::elf {
struct FileEmitterImpl : FileEmitter {
FileEmitterImpl(Object *elf)
: _elf{elf} { }
void run() override;
private:
void _emitPhdrs(PhdrsFragment *phdrs);
void _emitShdrs(ShdrsFragment *shdrs);
void _emitDynamic(DynamicSection *dynamic);
void _emitStringTable(StringTableSection *strtab);
void _emitSymbolTable(SymbolTableSection *symtab);
void _emitRela(RelocationSection *rel);
void _emitHash(HashSection *hash);
Object *_elf;
};
void FileEmitterImpl::run() {
util::ByteEncoder ehdr{&buffer};
// Write the EHDR.e_ident field.
encode8(ehdr, 0x7F);
encodeChars(ehdr, "ELF");
encode8(ehdr, ELFCLASS64);
encode8(ehdr, ELFDATA2LSB);
encode8(ehdr, 1); // ELF version; so far, there is only one.
encode8(ehdr, ELFOSABI_SYSV);
encode8(ehdr, 0); // ABI version. For the SysV ABI, this is not defined.
for (int i = 0; i < 7; i++) // The remaining e_ident bytes are padding.
encode8(ehdr, 0);
// Write the remaining EHDR fields.
assert(_elf->phdrsFragment);
assert(_elf->shdrsFragment);
assert(_elf->stringTableFragment);
encodeHalf(ehdr, ET_DYN); // e_type
encodeHalf(ehdr, EM_X86_64); // e_machine
encodeWord(ehdr, 1); // e_version
encodeAddr(ehdr, 0); // e_entry
encodeOff(ehdr, _elf->phdrsFragment->fileOffset.value()); // e_phoff
encodeOff(ehdr, _elf->shdrsFragment->fileOffset.value()); // e_shoff
encodeWord(ehdr, 0); // e_flags
// TODO: Do not hardcode this size.
encodeHalf(ehdr, 64); // e_ehsize
encodeHalf(ehdr, sizeof(Elf64_Phdr)); // e_phentsize
// TODO: # of PHDRs should be independent of # of sections.
encodeHalf(ehdr, _elf->numberOfFragments() + 1); // e_phnum
encodeHalf(ehdr, sizeof(Elf64_Shdr)); // e_shentsize
encodeHalf(ehdr, 1 + _elf->numberOfSections()); // e_shnum
encodeHalf(ehdr, _elf->stringTableFragment->designatedIndex.value()); // e_shstrndx
for (auto fragment : _elf->fragments()) {
// Make sure that sections are at least 8-byte aligned.
// TODO: Support arbitrary alignment.
while(buffer.size() & size_t(7))
buffer.push_back(0);
// Make sure that the fragment ends up at the correct address.
assert(fragment->fileOffset.value() == buffer.size());
if (auto phdrs = hierarchy_cast<PhdrsFragment *>(fragment); phdrs) {
_emitPhdrs(phdrs);
} else if (auto shdrs = hierarchy_cast<ShdrsFragment *>(fragment); shdrs) {
_emitShdrs(shdrs);
} else if (auto dynamic = hierarchy_cast<DynamicSection *>(fragment); dynamic) {
_emitDynamic(dynamic);
} else if (auto strtab = hierarchy_cast<StringTableSection *>(fragment); strtab) {
_emitStringTable(strtab);
} else if (auto symtab = hierarchy_cast<SymbolTableSection *>(fragment); symtab) {
_emitSymbolTable(symtab);
} else if (auto rel = hierarchy_cast<RelocationSection *>(fragment); rel) {
_emitRela(rel);
} else if (auto hash = hierarchy_cast<HashSection *>(fragment); hash) {
_emitHash(hash);
} else {
auto section = hierarchy_cast<ByteSection *>(fragment);
assert(section && "Unexpected Fragment for FileEmitter");
buffer.insert(buffer.end(), section->buffer.begin(), section->buffer.end());
}
}
}
void FileEmitterImpl::_emitPhdrs(PhdrsFragment *phdrs) {
util::ByteEncoder section{&buffer};
for (auto fragment : _elf->fragments()) {
// TODO: p_type and p_flags are only fillers.
encodeWord(section, PT_LOAD); // p_type
encodeWord(section, PF_R | PF_X); // p_flags
encodeOff(section, fragment->fileOffset.value()); // p_offset
encodeAddr(section, fragment->virtualAddress.value()); // p_vaddr
encodeAddr(section, fragment->virtualAddress.value()); // p_paddr
// TODO: p_filesz and p_memsz need not match.
encodeXword(section, fragment->computedSize.value()); // p_filesz
encodeXword(section, fragment->computedSize.value()); // p_memsz
encodeXword(section, 0); // p_align
}
// Emit the PT_DYNAMIC segment.
encodeWord(section, PT_DYNAMIC); // p_type
encodeWord(section, PF_R); // p_flags
encodeOff(section, _elf->dynamicFragment->fileOffset.value()); // p_offset
encodeAddr(section, _elf->dynamicFragment->virtualAddress.value()); // p_vaddr
encodeAddr(section, _elf->dynamicFragment->virtualAddress.value()); // p_paddr
encodeXword(section, _elf->dynamicFragment->computedSize.value()); // p_filesz
encodeXword(section, _elf->dynamicFragment->computedSize.value()); // p_memsz
encodeXword(section, 0); // p_align
}
void FileEmitterImpl::_emitShdrs(ShdrsFragment *shdrs) {
util::ByteEncoder section{&buffer};
// Emit the SHN_UNDEF section. Specified in the ELF base specification.
encodeWord(section, 0); // sh_name
encodeWord(section, SHT_NULL); // sh_type
encodeXword(section, 0); // sh_flags
encodeAddr(section, 0); // sh_addr
encodeOff(section, 0); // sh_offset
encodeXword(section, 0); // sh_size
encodeWord(section, SHN_UNDEF); // sh_link
encodeWord(section, 0); // sh_info
encodeXword(section, 0); // sh_addralign
encodeXword(section, 0); // sh_entsize
// Emit all "real sections.
for (auto fragment : _elf->fragments()) {
if (!fragment->isSection())
continue;
size_t nameIndex = 0;
if (fragment->name) {
assert(fragment->name->designatedOffset.has_value()
&& "String table layout must be fixed for FileEmitter");
nameIndex = fragment->name->designatedOffset.value();
}
size_t linkIndex = 0;
if (fragment->sectionLink) {
assert(fragment->sectionLink->designatedIndex.has_value()
&& "Section layout must be fixed for FileEmitter");
linkIndex = fragment->sectionLink->designatedIndex.value();
}
encodeWord(section, nameIndex); // sh_name
encodeWord(section, fragment->type); // sh_type
encodeXword(section, fragment->flags); // sh_flags
encodeAddr(section, fragment->virtualAddress.value()); // sh_addr
encodeOff(section, fragment->fileOffset.value()); // sh_offset
encodeXword(section, fragment->computedSize.value()); // sh_size
encodeWord(section, linkIndex); // sh_link
encodeWord(section, fragment->sectionInfo.value_or(0)); // sh_info
encodeXword(section, 0); // sh_addralign
encodeXword(section, fragment->entrySize.value_or(0)); // sh_entsize
}
}
void FileEmitterImpl::_emitDynamic(DynamicSection *dynamic) {
util::ByteEncoder section{&buffer};
encodeSxword(section, DT_STRTAB);
encodeXword(section, _elf->stringTableFragment->virtualAddress.value());
encodeSxword(section, DT_SYMTAB);
encodeXword(section, _elf->symbolTableFragment->virtualAddress.value());
encodeSxword(section, DT_HASH);
encodeXword(section, _elf->hashFragment->virtualAddress.value());
encodeSxword(section, DT_JMPREL);
encodeXword(section, _elf->pltRelocationFragment->virtualAddress.value());
encodeSxword(section, DT_PLTRELSZ);
encodeXword(section, _elf->pltRelocationFragment->computedSize.value());
encodeSxword(section, DT_NULL);
encodeXword(section, 0);
}
void FileEmitterImpl::_emitStringTable(StringTableSection *strtab) {
util::ByteEncoder section{&buffer};
encode8(section, 0); // ELF uses index zero for non-existent strings.
for (auto string : _elf->strings()) {
encodeChars(section, string->buffer.c_str());
encode8(section, 0);
}
}
void FileEmitterImpl::_emitSymbolTable(SymbolTableSection *symtab) {
util::ByteEncoder section{&buffer};
// Encode the null symbol.
encodeWord(section, 0); // st_name
encode8(section, 0); // st_info
encode8(section, 0); // st_other
encodeHalf(section, 0); // st_shndx
encodeAddr(section, 0); // st_value
encodeXword(section, 0); // st_size
// Encode all "real" symbols.
for (auto symbol : _elf->symbols()) {
size_t nameIndex = 0;
if (symbol->name) {
assert(symbol->name->designatedOffset.has_value()
&& "String table layout must be fixed for FileEmitter");
nameIndex = symbol->name->designatedOffset.value();
}
size_t sectionIndex = 0;
uint64_t virtualAddress = 0;
if (symbol->section) {
assert(symbol->section->designatedIndex.has_value()
&& "Section layout must be fixed for FileEmitter");
assert(symbol->section->virtualAddress.has_value()
&& "Section layout must be fixed for FileEmitter");
sectionIndex = symbol->section->designatedIndex.value();
virtualAddress = symbol->section->virtualAddress.value() + symbol->value;
}
encodeWord(section, nameIndex); // st_name
encode8(section, ELF64_ST_INFO(STB_GLOBAL, STT_FUNC)); // st_info
encode8(section, 0); // st_other
encodeHalf(section, sectionIndex); // st_shndx
// TODO: Use symbol->value in object files.
encodeAddr(section, virtualAddress); // st_value
encodeXword(section, 0); // st_size
}
}
void FileEmitterImpl::_emitRela(RelocationSection *rel) {
util::ByteEncoder section{&buffer};
for (auto relocation : _elf->relocations()) {
assert(relocation->offset >= 0);
assert(relocation->section && "Section layout must be fixed for FileEmitter");
assert(relocation->section->virtualAddress.has_value()
&& "Section layout must be fixed for FileEmitter");
size_t sectionAddress = relocation->section->virtualAddress.value();
size_t symbolIndex = 0;
if (relocation->symbol) {
assert(relocation->symbol->designatedIndex.has_value()
&& "Symbol table layout must be fixed for FileEmitter");
symbolIndex = relocation->symbol->designatedIndex.value();
}
encodeAddr(section, sectionAddress + relocation->offset);
encodeXword(section, (symbolIndex << 32) | R_X86_64_JUMP_SLOT);
encodeSxword(section, 0);
}
}
void FileEmitterImpl::_emitHash(HashSection *hash) {
util::ByteEncoder section{&buffer};
encodeWord(section, hash->buckets.size());
encodeWord(section, hash->chains.size());
for (auto symbol : hash->buckets) {
if (symbol) {
encodeWord(section, symbol->designatedIndex.value());
}else{
encodeWord(section, 0);
}
}
for (auto symbol : hash->chains) {
if (symbol) {
encodeWord(section, symbol->designatedIndex.value());
}else{
encodeWord(section, 0);
}
}
}
std::unique_ptr<FileEmitter> FileEmitter::create(Object *elf) {
return std::make_unique<FileEmitterImpl>(elf);
}
} // namespace lewis::elf
| 39.096552 | 90 | 0.652849 | [
"object"
] |
b5c609ddbff242fa295f4cd529fd0a9dfcbf584c | 15,661 | cpp | C++ | shell/ext/docpropv3/dll.cpp | npocmaka/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 17 | 2020-11-13T13:42:52.000Z | 2021-09-16T09:13:13.000Z | shell/ext/docpropv3/dll.cpp | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 2 | 2020-10-19T08:02:06.000Z | 2020-10-19T08:23:18.000Z | shell/ext/docpropv3/dll.cpp | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 14 | 2020-11-14T09:43:20.000Z | 2021-08-28T08:59:57.000Z | //
// Copyright 2001 - Microsoft Corporation
//
// Created By:
// Geoff Pease (GPease) 23-JAN-2001
//
// Maintained By:
// Geoff Pease (GPease) 23-JAN-2001
//
// Notes:
// If ENTRY_PREFIX is defined, this indicates that your are trying to
// included proxy/stub code into the DLL that is generated by the
// MIDL compiler.
//
//////////////////////////////////////////////////////////////////////////////
#include "pch.h"
#include <InitGuid.h>
#include "Guids.h"
#include <shfusion.h>
#include "DocProp.h"
#include "DefProp.h"
#include "PropertyCacheItem.h"
#include "IEditVariantsInPlace.h"
#include "EditTypeItem.h"
#include "MLEditTypeItem.h"
#include "DropListTypeItem.h"
#include "CalendarTypeItem.h"
#pragma hdrstop
DEFINE_MODULE("DOCPROP3")
//
// Classes in this Component
//
// This table is used to create the objects supported in this DLL. It also is
// used to map a name with a particular CLSID. HrCoCreateInternalInstance() uses
// this table to shortcut COM.
//
// CreateInstance CLSID User Friendly Name Apartment Model
BEGIN_CLASSTABLE
DEFINE_CLASS( CDocPropShExt::CreateInstance , CLSID_DocPropShellExtension , "Microsoft DocProp Shell Ext" , "Apartment" )
DEFINE_CLASS( CEditTypeItem::CreateInstance , CLSID_DocPropEditBoxControl , "Microsoft DocProp Inplace Edit Box Control" , "Apartment" )
DEFINE_CLASS( CMLEditTypeItem::CreateInstance , CLSID_DocPropMLEditBoxControl , "Microsoft DocProp Inplace ML Edit Box Control" , "Apartment" )
DEFINE_CLASS( CDropListTypeItem::CreateInstance , CLSID_DocPropDropListComboControl , "Microsoft DocProp Inplace Droplist Combo Control" , "Apartment" )
DEFINE_CLASS( CCalendarTypeItem::CreateInstance , CLSID_DocPropCalendarControl , "Microsoft DocProp Inplace Calendar Control" , "Apartment" )
DEFINE_CLASS( CEditTypeItem::CreateInstance , CLSID_DocPropTimeControl , "Microsoft DocProp Inplace Time Control" , "Apartment" )
END_CLASSTABLE
//
// DLL Globals
//
HINSTANCE g_hInstance = NULL;
LONG g_cObjects = 0;
LONG g_cLock = 0;
TCHAR g_szDllFilename[ MAX_PATH ] = { 0 };
LPVOID g_GlobalMemoryList = NULL; // Global memory tracking list
#if defined( ENTRY_PREFIX )
extern "C"
{
extern HINSTANCE hProxyDll;
}
#endif
//
// Macros to generate RPC entry points
//
#define __rpc_macro_expand2(a, b) a##b
#define __rpc_macro_expand(a, b) __rpc_macro_expand2(a,b)
#if !defined(NO_DLL_MAIN) || defined(ENTRY_PREFIX) || defined(DEBUG)
//
// Description:
// Dll entry point.
//
BOOL WINAPI
DllMain(
HINSTANCE hInstIn, // DLL instance
ULONG ulReasonIn, // DLL reason code for entrance.
LPVOID // lpReservedIn
)
{
//
// KB: NO_THREAD_OPTIMIZATIONS gpease 19-OCT-1999
//
// By not defining this you can prvent the linker
// from calling you DllEntry for every new thread.
// This makes creating new thread significantly
// faster if every DLL in a process does it.
// Unfortunately, not all DLLs do this.
//
// In CHKed/DEBUG, we keep this on for memory
// tracking.
//
#if defined( DEBUG )
#define NO_THREAD_OPTIMIZATIONS
#endif // DEBUG
#if defined(NO_THREAD_OPTIMIZATIONS)
switch( ulReasonIn )
{
case DLL_PROCESS_ATTACH:
{
SHFusionInitializeFromModule( hInstIn );
#if defined(USE_WMI_TRACING)
TraceInitializeProcess( g_rgTraceControlGuidList,
ARRAYSIZE( g_rgTraceControlGuidList )
);
#else
TraceInitializeProcess();
#endif
TraceCreateMemoryList( g_GlobalMemoryList );
TraceMemoryDelete( g_GlobalMemoryList, FALSE ); // can't track this list.
#if defined( DEBUG )
TraceFunc( "" );
TraceMessage( TEXT(__FILE__),
__LINE__,
__MODULE__,
mtfDLL,
TEXT("DLL: DLL_PROCESS_ATTACH - ThreadID = %#x"),
GetCurrentThreadId( )
);
FRETURN( TRUE );
#endif // DEBUG
g_hInstance = (HINSTANCE) hInstIn;
#if defined( ENTRY_PREFIX )
hProxyDll = g_hInstance;
#endif
GetModuleFileName( g_hInstance, g_szDllFilename, MAX_PATH );
break;
}
case DLL_PROCESS_DETACH:
{
#if defined( DEBUG )
TraceFunc( "" );
TraceMessage( TEXT(__FILE__),
__LINE__,
__MODULE__,
mtfDLL,
TEXT("DLL: DLL_PROCESS_DETACH - ThreadID = %#x [ g_cLock=%u, g_cObjects=%u ]"),
GetCurrentThreadId( ),
g_cLock,
g_cObjects
);
FRETURN( TRUE );
#endif // DEBUG
TraceMemoryAddAddress( g_GlobalMemoryList );
TraceTerminateMemoryList( g_GlobalMemoryList );
#if defined(USE_WMI_TRACING)
TraceTerminateProcess( g_rgTraceControlGuidList,
ARRAYSIZE( g_rgTraceControlGuidList )
);
#else
TraceTerminateProcess();
#endif
SHFusionUninitialize();
break;
}
case DLL_THREAD_ATTACH:
{
TraceInitializeThread( NULL );
#if defined( DEBUG )
TraceMessage( TEXT(__FILE__),
__LINE__,
__MODULE__,
mtfDLL,
TEXT("The thread %#x has started."),
GetCurrentThreadId( ) );
TraceFunc( "" );
TraceMessage( TEXT(__FILE__),
__LINE__,
__MODULE__,
mtfDLL,
TEXT("DLL: DLL_THREAD_ATTACH - ThreadID = %#x [ g_cLock=%u, g_cObjects=%u ]"),
GetCurrentThreadId( ),
g_cLock,
g_cObjects
);
FRETURN( TRUE );
#endif // DEBUG
break;
}
case DLL_THREAD_DETACH:
{
#if defined( DEBUG )
TraceFunc( "" );
TraceMessage( TEXT(__FILE__),
__LINE__,
__MODULE__,
mtfDLL,
TEXT("DLL: DLL_THREAD_DETACH - ThreadID = %#x [ g_cLock=%u, g_cObjects=%u ]"),
GetCurrentThreadId( ),
g_cLock,
g_cObjects
);
FRETURN( TRUE );
#endif // DEBUG
TraceTerminateThread( );;
break;
}
default:
{
#if defined( DEBUG )
TraceFunc( "" );
TraceMessage( TEXT(__FILE__),
__LINE__,
__MODULE__,
mtfDLL,
TEXT("DLL: UNKNOWN ENTRANCE REASON - ThreadID = %#x [ g_cLock=%u, g_cObjects=%u ]"),
GetCurrentThreadId( ),
g_cLock,
g_cObjects
);
FRETURN( TRUE );
#endif // DEBUG
break;
}
}
return TRUE;
#else // !NO_THREAD_OPTIMIZATIONS
Assert( ulReasonIn == DLL_PROCESS_ATTACH || ulReasonIn == DLL_PROCESS_DETACH );
if ( DLL_PROCESS_ATTACH == ulReasonIn )
{
SHFusionInitializeFromModule( hInstIn );
g_hInstance = (HINSTANCE) hInstIn;
#ifdef ENTRY_PREFIX
hProxyDll = g_hInstance;
#endif
#ifdef DEBUG
#ifdef USE_WMI_TRACING
TraceInitializeProcess( g_rgTraceControlGuidList,
ARRAYSIZE( g_rgTraceControlGuidList )
);
#else
TraceInitializeProcess();
#endif USE_WMI_TRACING
#endif DEBUG
GetModuleFileName( g_hInstance, g_szDllFilename, MAX_PATH );
BOOL fResult = DisableThreadLibraryCalls( g_hInstance );
AssertMsg( fResult, "*ERROR* DisableThreadLibraryCalls( ) failed." );
}
else
{
#ifdef DEBUG
#ifdef USE_WMI_TRACING
TraceTerminateProcess( g_rgTraceControlGuidList,
ARRAYSIZE( g_rgTraceControlGuidList )
);
#else
TraceTerminateProcess();
#endif USE_WMI_TRACING
#endif DEBUG
SHFusionUninitialize();
}
return TRUE;
#endif // NO_THREAD_OPTIMIZATIONS
}
#endif // !defined(NO_DLL_MAIN) && !defined(ENTRY_PREFIX) && !defined(DEBUG)
//
// Description:
// OLE calls this to get the class factory from the DLL.
//
// Return Values:
// S_OK
// Success.
//
// any other HRESULT to indicate failure.
//
STDAPI
DllGetClassObject(
REFCLSID rclsidIn, // class ID of the object that the class factory should create.
REFIID riidIn, // Interface of the class factory
void** ppvOut // The interface pointer to the class factory.
)
{
TraceFunc( "rclsidIn, riidIn, ppvOut" );
if ( ppvOut == NULL )
{
HRETURN(E_POINTER);
}
LPCFACTORY lpClassFactory;
HRESULT hr;
int idx;
hr = CLASS_E_CLASSNOTAVAILABLE;
idx = 0;
while( g_DllClasses[ idx ].rclsid )
{
if ( *g_DllClasses[ idx ].rclsid == rclsidIn )
{
TraceMessage( TEXT(__FILE__), __LINE__, __MODULE__, mtfFUNC, L"rclsidIn = %s", g_DllClasses[ idx ].pszName );
hr = S_OK;
break;
}
idx++;
}
if ( hr == CLASS_E_CLASSNOTAVAILABLE )
{
TraceMsgGUID( mtfFUNC, "rclsidIn = ", rclsidIn );
#if defined( ENTRY_PREFIX )
//
// See if the MIDL generated code can create it.
//
hr = STHR( __rpc_macro_expand( ENTRY_PREFIX, DllGetClassObject )( rclsidIn, riidIn, ppvOut ) );
#endif // defined( ENTRY_PREFIX )
goto Cleanup;
}
Assert( g_DllClasses[ idx ].pfnCreateInstance != NULL );
lpClassFactory = new CFactory;
if ( lpClassFactory == NULL )
{
hr = E_OUTOFMEMORY;
goto Cleanup;
}
hr = THR( lpClassFactory->Init( g_DllClasses[ idx ].pfnCreateInstance ) );
if ( FAILED( hr ) )
{
TraceDo( lpClassFactory->Release( ) );
goto Cleanup;
}
// Can't safe type.
hr = lpClassFactory->QueryInterface( riidIn, ppvOut );
//
// Release the created instance to counter the AddRef( ) in Init( ).
//
((IUnknown *) lpClassFactory )->Release( );
Cleanup:
HRETURN(hr);
}
//
// Description:
// OLE's register entry point.
//
// Return Values:
// S_OK
// Success.
//
// any other HRESULT.
//
STDAPI
DllRegisterServer( void )
{
HRESULT hr;
TraceFunc( "" );
hr = THR( HrRegisterDll( TRUE ) );
#if defined( ENTRY_PREFIX )
if ( SUCCEEDED( hr ) )
{
hr = THR( __rpc_macro_expand( ENTRY_PREFIX, DllRegisterServer )( ) );
}
#endif // defined( ENTRY_PREFIX )
if ( SUCCEEDED( hr ) )
{
hr = CDocPropShExt::RegisterShellExtensions( TRUE );
}
HRETURN(hr);
}
//
// Description:
// OLE's unregister entry point.
//
// Return Values:
// S_OK
// Success.
//
// any other HRESULT
//
STDAPI
DllUnregisterServer( void )
{
TraceFunc( "" );
HRESULT hr;
hr = THR( HrRegisterDll( FALSE ) );
#if defined( ENTRY_PREFIX )
if ( SUCCEEDED( hr ) )
{
hr = THR( __rpc_macro_expand( ENTRY_PREFIX, DllUnregisterServer )( ) );
}
#endif // defined( ENTRY_PREFIX )
if ( SUCCEEDED( hr ) )
{
hr = CDocPropShExt::RegisterShellExtensions( TRUE );
}
HRETURN( hr );
}
//
// Description:
// OLE calls this entry point to see if it can unload the DLL.
//
// Return Values:
// S_OK
// Can unload the DLL.
//
// S_FALSE
// Can NOT unload the DLL.
//
STDAPI
DllCanUnloadNow( void )
{
TraceFunc( "" );
HRESULT hr = S_OK;
if ( g_cLock || g_cObjects )
{
TraceMsg( mtfDLL, "DLL: Can't unload - g_cLock=%u, g_cObjects=%u", g_cLock, g_cObjects );
hr = S_FALSE;
}
#if defined( ENTRY_PREFIX )
else
{
//
// Check with the MIDL generated proxy/stubs.
//
hr = STHR( __rpc_macro_expand( ENTRY_PREFIX, DllCanUnloadNow )( ) );
}
#endif
HRETURN(hr);
}
//
// Description:
// Mimic CoCreateInstance( ) except that it looks into the DLL table
// to see if we can shortcut the CoCreate with a simple CreateInstance
// call.
//
// Return Values:
// S_OK
// Success.
//
// E_OUTOFMEMORY
// Out of memory.
//
// other HRESULT values
//
HRESULT
HrCoCreateInternalInstance(
REFCLSID rclsidIn, // Class identifier (CLSID) of the object
LPUNKNOWN pUnkOuterIn, // Pointer to controlling IUnknown
DWORD dwClsContextIn, // Context for running executable code
REFIID riidIn, // Reference to the identifier of the interface
LPVOID * ppvOut // Address of output variable that receives
)
{
TraceFunc( "" );
Assert( ppvOut != NULL );
HRESULT hr = CLASS_E_CLASSNOTAVAILABLE;
//
// Limit simple CoCreate( ) only works to INPROC and non-aggregatable objects.
//
if ( ( dwClsContextIn & CLSCTX_INPROC_HANDLER ) // inproc only
&& ( NULL == pUnkOuterIn ) // no aggregation
)
{
int idx;
//
// Try to find the class in our DLL table.
//
for( idx = 0; g_DllClasses[ idx ].rclsid != NULL; idx++ )
{
if ( *g_DllClasses[ idx ].rclsid == rclsidIn )
{
LPUNKNOWN punk;
Assert( g_DllClasses[ idx ].pfnCreateInstance != NULL );
hr = THR( g_DllClasses[ idx ].pfnCreateInstance( &punk ) );
if ( SUCCEEDED( hr ) )
{
// Can't safe type.
hr = THR( punk->QueryInterface( riidIn, ppvOut ) );
punk->Release( );
}
break; // bail loop
}
}
}
//
// If not found or asking for something we do not support,
// use the COM version.
//
if ( hr == CLASS_E_CLASSNOTAVAILABLE )
{
//
// Try it the old fashion way...
//
hr = THR( CoCreateInstance( rclsidIn, pUnkOuterIn, dwClsContextIn, riidIn, ppvOut ) );
}
HRETURN( hr );
}
//
// TODO: gpease 27-NOV-1999
// Whilest parrusing the around the MIDL SDK, I foud that
// RPC creates the same type of class table we do. Maybe
// we can leverage the MIDL code to create our objects(??).
//
| 27.669611 | 159 | 0.527233 | [
"object",
"model"
] |
b5c94894b418f8b040637b5b46cae32500fd2563 | 11,126 | cpp | C++ | src/dale/Serialise/Serialise.cpp | ChengCat/dale | 4a764895611679cd1670d9a43ffdbee136661759 | [
"BSD-3-Clause"
] | 1,083 | 2015-03-18T09:42:49.000Z | 2022-03-29T03:17:47.000Z | src/dale/Serialise/Serialise.cpp | ChengCat/dale | 4a764895611679cd1670d9a43ffdbee136661759 | [
"BSD-3-Clause"
] | 195 | 2015-01-04T03:06:41.000Z | 2022-03-18T18:16:27.000Z | src/dale/Serialise/Serialise.cpp | ChengCat/dale | 4a764895611679cd1670d9a43ffdbee136661759 | [
"BSD-3-Clause"
] | 56 | 2015-03-18T20:02:13.000Z | 2022-01-22T19:35:27.000Z | #include "Serialise.h"
#include <cassert>
#include <map>
#include <string>
#include <vector>
#include "../Utils/Utils.h"
namespace dale {
void xfwrite(const void *a, size_t b, size_t c, FILE *d) {
size_t res = fwrite(a, b, c, d);
if (res != c) {
error("write failed", true);
}
}
void serialise(FILE *out, bool a) { xfwrite(&a, sizeof(bool), 1, out); }
void serialise(FILE *out, bool *a) { serialise(out, *a); }
char *deserialise(TypeRegister *tr, char *in, bool *a) {
*a = *(reinterpret_cast<bool *>(in));
return in + sizeof(bool);
}
void serialise(FILE *out, int64_t a) {
xfwrite(&a, sizeof(int64_t), 1, out);
}
void serialise(FILE *out, int64_t *a) { serialise(out, *a); }
char *deserialise(TypeRegister *tr, char *in, int64_t *a) {
*a = *(reinterpret_cast<int64_t *>(in));
return in + sizeof(int64_t);
}
void serialise(FILE *out, char a) { xfwrite(&a, sizeof(char), 1, out); }
void serialise(FILE *out, char *a) { serialise(out, *a); }
char *deserialise(TypeRegister *tr, char *in, char *a) {
*a = *in;
return in + 1;
}
void serialise(FILE *out, int a) {
assert(((a >= 0) && (a <= 255)) &&
"serialised ints must be between 0 and 255 inclusive");
uint8_t aa = (uint8_t)a;
xfwrite(&aa, sizeof(uint8_t), 1, out);
}
void serialise(FILE *out, int *a) { serialise(out, *a); }
char *deserialise(TypeRegister *tr, char *in, int *a) {
uint8_t aa;
aa = *(reinterpret_cast<uint8_t *>(in));
*a = aa;
return in + sizeof(uint8_t);
}
void serialise(FILE *out, size_t s) {
uint16_t ss = (uint16_t)s;
xfwrite(&ss, sizeof(uint16_t), 1, out);
}
void serialise(FILE *out, size_t *s) { serialise(out, *s); }
char *deserialise(TypeRegister *tr, char *in, size_t *s) {
uint16_t ss;
ss = *(reinterpret_cast<uint16_t *>(in));
*s = ss;
return in + sizeof(uint16_t);
}
void serialise(FILE *out, std::string x) {
serialise(out, x.length());
xfwrite(x.c_str(), sizeof(char), x.length(), out);
}
void serialise(FILE *out, std::string *x) {
serialise(out, x->length());
xfwrite(x->c_str(), sizeof(char), x->length(), out);
}
char *deserialise(TypeRegister *tr, char *in, std::string *x) {
size_t s;
in = deserialise(tr, in, &s);
x->reserve(s);
char buf[256];
strncpy(buf, in, s);
buf[s] = '\0';
x->clear();
x->append(buf);
return in + s;
}
void serialise(FILE *out, Type *t) {
/* Shortcut for simple types. */
char c;
if (!t->is_array && !t->array_size && !t->array_type &&
!t->is_function && !(t->struct_name.size()) &&
!(t->namespaces.size()) && !t->points_to && !t->return_type &&
!(t->parameter_types.size()) && !t->is_const &&
!t->is_reference && !t->bitfield_size && !t->is_retval) {
c = 'S';
serialise(out, &c);
serialise(out, &(t->base_type));
return;
}
c = 'N';
serialise(out, &c);
serialise(out, &(t->base_type));
serialise(out, &(t->is_array));
serialise(out, &(t->array_size));
serialise(out, &(t->bitfield_size));
serialise(out, &(t->is_const));
serialise(out, &(t->is_reference));
serialise(out, &(t->is_retval));
if (!t->array_type) {
serialise(out, 0);
} else {
serialise(out, 1);
serialise(out, t->array_type);
}
serialise(out, &(t->is_function));
if (!t->struct_name.size()) {
serialise(out, 0);
} else {
serialise(out, 1);
serialise(out, &(t->struct_name));
}
if (!t->namespaces.size()) {
serialise(out, 0);
} else {
serialise(out, 1);
serialise(out, &(t->namespaces));
}
if (!t->points_to) {
serialise(out, 0);
} else {
serialise(out, 1);
serialise(out, t->points_to);
}
if (!t->return_type) {
serialise(out, 0);
} else {
serialise(out, 1);
serialise(out, t->return_type);
}
if (!t->parameter_types.size()) {
serialise(out, 0);
} else {
serialise(out, 1);
serialise(out, &(t->parameter_types));
}
}
char *deserialise(TypeRegister *tr, char *in, Type **t) {
char c;
in = deserialise(tr, in, &c);
if (c == 'S') {
int base_type;
in = deserialise(tr, in, &base_type);
*t = tr->getBasicType(base_type);
return in;
}
assert((c == 'N') && "got invalid char on deserialising");
Type temp;
in = deserialise(tr, in, &(temp.base_type));
in = deserialise(tr, in, &(temp.is_array));
in = deserialise(tr, in, &(temp.array_size));
in = deserialise(tr, in, &(temp.bitfield_size));
in = deserialise(tr, in, &(temp.is_const));
in = deserialise(tr, in, &(temp.is_reference));
in = deserialise(tr, in, &(temp.is_retval));
int is_present;
in = deserialise(tr, in, &is_present);
if (is_present) {
Type *at;
in = deserialise(tr, in, &at);
temp.array_type = at;
}
in = deserialise(tr, in, &(temp.is_function));
in = deserialise(tr, in, &is_present);
if (is_present) {
in = deserialise(tr, in, &temp.struct_name);
}
in = deserialise(tr, in, &is_present);
if (is_present) {
in = deserialise(tr, in, &temp.namespaces);
}
in = deserialise(tr, in, &is_present);
if (is_present) {
Type *pt;
in = deserialise(tr, in, &pt);
temp.points_to = pt;
}
in = deserialise(tr, in, &is_present);
if (is_present) {
Type *rt;
in = deserialise(tr, in, &rt);
temp.return_type = rt;
}
in = deserialise(tr, in, &is_present);
if (is_present) {
in = deserialise_type_vector(tr, in, &temp.parameter_types);
}
Type *final = tr->getType(&temp);
*t = final;
return in;
}
void serialise(FILE *out, Variable *v) {
serialise(out, v->type);
serialise(out, &(v->name));
serialise(out, v->linkage);
if (!(v->symbol.compare(""))) {
serialise(out, 0);
} else {
serialise(out, 1);
serialise(out, &(v->symbol));
}
serialise(out, v->once_tag);
}
void serialise(FILE *out, Variable **v) { serialise(out, *v); }
char *deserialise(TypeRegister *tr, char *in, Variable *v) {
Type *vt;
in = deserialise(tr, in, &vt);
v->type = vt;
in = deserialise(tr, in, &(v->name));
in = deserialise(tr, in, &(v->linkage));
int is_present;
in = deserialise(tr, in, &is_present);
if (is_present) {
in = deserialise(tr, in, &(v->symbol));
}
in = deserialise(tr, in, &(v->once_tag));
v->value = NULL;
return in;
}
char *deserialise(TypeRegister *tr, char *in, Variable **v) {
Variable *vv = new Variable();
vv->serialise = false;
*v = vv;
return deserialise(tr, in, vv);
}
void serialise(FILE *out, Function *fn) {
serialise(out, fn->return_type);
serialise(out, &(fn->parameters));
serialise(out, fn->is_macro);
serialise(out, fn->symbol);
serialise(out, fn->always_inline);
serialise(out, fn->once_tag);
serialise(out, fn->cto);
serialise(out, fn->linkage);
return;
}
void serialise(FILE *out, Function **fn) { serialise(out, *fn); }
char *deserialise(TypeRegister *tr, char *in, Function *fn) {
Type *rt;
in = deserialise(tr, in, &rt);
fn->return_type = rt;
fn->llvm_function = NULL;
in = deserialise(tr, in, &(fn->parameters));
in = deserialise(tr, in, &(fn->is_macro));
in = deserialise(tr, in, &(fn->symbol));
in = deserialise(tr, in, &(fn->always_inline));
in = deserialise(tr, in, &(fn->once_tag));
in = deserialise(tr, in, &(fn->cto));
in = deserialise(tr, in, &(fn->linkage));
return in;
}
char *deserialise(TypeRegister *tr, char *in, Function **fn) {
Function *ff = new Function();
ff->serialise = false;
*fn = ff;
return deserialise(tr, in, ff);
}
void serialise(FILE *out, Struct *st) {
serialise(out, &(st->is_opaque));
serialise(out, &(st->member_types));
serialise(out, &(st->name_to_index));
serialise(out, &(st->symbol));
serialise(out, st->once_tag);
serialise(out, st->linkage);
return;
}
void serialise(FILE *out, Struct **st) { serialise(out, *st); }
char *deserialise(TypeRegister *tr, char *in, Struct *st) {
st->type = NULL;
in = deserialise(tr, in, &(st->is_opaque));
in = deserialise(tr, in, &(st->member_types));
in = deserialise(tr, in, &(st->name_to_index));
in = deserialise(tr, in, &(st->symbol));
in = deserialise(tr, in, &(st->once_tag));
in = deserialise(tr, in, &(st->linkage));
return in;
}
char *deserialise(TypeRegister *tr, char *in, Struct **st) {
Struct *st_ = new Struct();
st_->serialise = false;
*st = st_;
return deserialise(tr, in, st_);
}
void serialise(FILE *out, Namespace *ns) {
serialise(out, &(ns->functions));
serialise(out, &(ns->variables));
serialise(out, &(ns->structs));
serialise(out, &(ns->name));
serialise(out, &(ns->symbol_prefix));
return;
}
void serialise(FILE *out, Namespace **ns) { serialise(out, *ns); }
char *deserialise(TypeRegister *tr, char *in, Namespace *ns) {
in = deserialise(tr, in, &(ns->functions));
in = deserialise(tr, in, &(ns->variables));
in = deserialise(tr, in, &(ns->structs));
std::string name;
in = deserialise(tr, in, &name);
ns->name = name;
in = deserialise(tr, in, &(ns->symbol_prefix));
if (ns->symbol_prefix.size()) {
ns->has_symbol_prefix = true;
}
ns->tr = tr;
return in;
}
void serialise(FILE *out, NSNode *nsnode) {
serialise(out, nsnode->ns);
serialise(out, &(nsnode->children));
return;
}
void serialise(FILE *out, NSNode **nsnode) {
serialise(out, *nsnode);
return;
}
char *deserialise(TypeRegister *tr, char *in, NSNode *nsnode) {
Namespace *ns = new Namespace();
in = deserialise(tr, in, ns);
nsnode->ns = ns;
std::map<std::string, NSNode *> *children =
new std::map<std::string, NSNode *>;
in = deserialise(tr, in, children);
nsnode->children = *children;
return in;
}
char *deserialise(TypeRegister *tr, char *in, NSNode **nsnode) {
NSNode *nsn = new NSNode();
*nsnode = nsn;
return deserialise(tr, in, nsn);
}
void serialise(FILE *out, Context *ctx) {
serialise(out, ctx->namespaces);
return;
}
void serialise(FILE *out, Context **ctx) { serialise(out, *ctx); }
char *deserialise(TypeRegister *tr, char *in, Context *ctx) {
NSNode *nsnode = new NSNode();
in = deserialise(tr, in, nsnode);
ctx->namespaces = nsnode;
return in;
}
char *deserialise(TypeRegister *tr, char *in, Context **ctx) {
Context *mc = new Context();
*ctx = mc;
return deserialise(tr, in, mc);
}
char *deserialise_type_vector(TypeRegister *tr, char *in,
std::vector<Type *> *x) {
size_t s;
in = deserialise(tr, in, &s);
x->reserve(s);
for (size_t i = 0; i < s; i++) {
Type *t;
in = deserialise(tr, in, &t);
x->push_back(t);
}
return in;
}
}
| 25.814385 | 72 | 0.576398 | [
"vector"
] |
b5d709152abbb8c16defb884bd4e601700ab197a | 790 | cpp | C++ | src/get_image_distance.cpp | Fadis/genetic_fm | 415158b02e2c0dad8fafc81b5762b8889e493f10 | [
"MIT"
] | 34 | 2016-10-08T08:55:30.000Z | 2021-08-17T03:19:54.000Z | src/get_image_distance.cpp | Fadis/genetic_fm | 415158b02e2c0dad8fafc81b5762b8889e493f10 | [
"MIT"
] | null | null | null | src/get_image_distance.cpp | Fadis/genetic_fm | 415158b02e2c0dad8fafc81b5762b8889e493f10 | [
"MIT"
] | 1 | 2018-06-21T00:06:30.000Z | 2018-06-21T00:06:30.000Z | #include <cmath>
#include <fstream>
#include <iostream>
#include <fstream>
#include <vector>
#include <complex>
#include <tuple>
#include <algorithm>
#include "get_image_distance.hpp"
double get_image_distance( const std::vector< uint8_t > &l, const std::vector< uint8_t > &r ) {
if( l.size() > r.size() ) {
return get_image_distance( r, l );
}
double sum = 0.0;
double local = 0.0;
for( size_t i = 0; i != l.size(); ++i ) {
double d = r[ i ] - l[ i ];
local += std::abs( d );
if( !( i % 100000 ) ) {
sum += local;
local = 0.0;
}
}
for( size_t i = l.size(); i != r.size(); ++i ) {
double d = r[ i ];
local += std::abs( d );
if( !( i % 100000 ) ) {
sum += local;
local = 0.0;
}
}
sum += local;
return sum;
}
| 20.789474 | 95 | 0.527848 | [
"vector"
] |
b5d8a8af28a3f81c9ff9ede866bc441f3825fe4a | 1,499 | cpp | C++ | Game/Wave.cpp | Eremiell/Ludum-Dare-42 | 73d42afe4ae596f5469e20de70c5c18cf494b130 | [
"CC0-1.0"
] | 9 | 2018-08-14T10:58:45.000Z | 2021-02-14T12:53:31.000Z | Game/Wave.cpp | Eremiell/Ludum-Dare-42 | 73d42afe4ae596f5469e20de70c5c18cf494b130 | [
"CC0-1.0"
] | 1 | 2018-08-15T00:49:45.000Z | 2018-08-15T00:49:45.000Z | Game/Wave.cpp | UglySwedishFish/Ludum-Dare-42 | 281ca4e76afeba92e3089d68021702a0fbe214d8 | [
"CC0-1.0"
] | null | null | null | #include "Wave.h"
#include <iostream>
LDEngine::Game::WaveState GetRank(int PlayerHealthStart, int PlayerHealth, int BaseHealthStart, int BaseHealth) {
int HealthDifferencePlayer = PlayerHealthStart - PlayerHealth;
int HealthDifferenceBase = BaseHealthStart - BaseHealth;
std::cout << HealthDifferencePlayer << ' ' << HealthDifferenceBase << '\n';
for (int PossibleRank = 0; PossibleRank < 4; PossibleRank++) {
if (HealthDifferencePlayer < 100 * (PossibleRank + 1) && HealthDifferenceBase < 1000 * (PossibleRank + 1)) {
return LDEngine::Game::WaveState(PossibleRank);
}
}
return LDEngine::Game::RANKE;
}
LDEngine::Game::WaveState LDEngine::Game::Wave::HandleWave(EnemySystem & Enemies, Window & Window, Vector3f SpawnPoint, int PlayerHealth, int BaseHealth)
{
if (Enemies.Enemies.size() == 0 && EnemySpawnTimes.size() == 0) {
//get rank based on how enemies were killed every second
return GetRank(StartPlayerHealth, PlayerHealth, StartBaseHealth, BaseHealth); //test
}
TimeElapsedInWave += Window.GetFrameTime();
std::vector<int> EraseLocations{};
for (int PossibleSpawn = 0; PossibleSpawn < EnemySpawnTimes.size(); PossibleSpawn++) {
if (TimeElapsedInWave > EnemySpawnTimes[PossibleSpawn]) {
EraseLocations.push_back(PossibleSpawn);
Enemies.AddEnemy(Enemy(SpawnPoint));
}
}
for (int Erase = EraseLocations.size() - 1; Erase >= 0; Erase--) {
EnemySpawnTimes.erase(EnemySpawnTimes.begin() + EraseLocations[Erase]);
}
return ONGOING;
}
| 31.893617 | 153 | 0.725817 | [
"vector"
] |
b5daec08240c0b8d072f491ff32504d9da1bc63a | 5,216 | cpp | C++ | unittests/ut_util_gen_enumerator.cpp | nightwolf55la/utilities | 1ceacf0d998835d56cafbe16ad0614c1253024d9 | [
"MIT"
] | 2 | 2019-01-10T13:11:52.000Z | 2020-12-02T13:40:23.000Z | unittests/ut_util_gen_enumerator.cpp | nightwolf55la/utilities | 1ceacf0d998835d56cafbe16ad0614c1253024d9 | [
"MIT"
] | 1 | 2020-12-02T13:41:04.000Z | 2020-12-02T13:41:04.000Z | unittests/ut_util_gen_enumerator.cpp | nightwolf55la/utilities | 1ceacf0d998835d56cafbe16ad0614c1253024d9 | [
"MIT"
] | 1 | 2020-12-02T13:41:23.000Z | 2020-12-02T13:41:23.000Z | #include <catch2/catch.hpp>
#include <vector>
#include <array>
#include <deque>
#include <list>
#include <forward_list>
#include <util/gen/enumerate.h>
namespace {
template<class Iterable, bool CONST>
using IterableTypeWConst =
std::conditional_t<
CONST,
std::add_const_t<Iterable>,
Iterable
>;
template<class Iterable, bool RVALUE>
using IterableTypeWRValue =
std::conditional_t<
RVALUE,
Iterable,
std::add_lvalue_reference_t<Iterable>
>;
template<class Iterable, bool CONST, bool RVALUE>
using IterableType = IterableTypeWRValue<IterableTypeWConst<Iterable, CONST>, RVALUE>;
template<class Iterable, bool CONST, bool RVALUE>
IterableType<Iterable, CONST, RVALUE> get_iterable() {
if constexpr(RVALUE) {
return {{0, 1, 2, 3, 4}};
} else {
static Iterable iterable;
iterable = Iterable{{0, 1, 2, 3, 4}};
return iterable;
}
}
template<class Iterable, bool CONST, bool RVALUE>
void test() {
[[maybe_unused]] Iterable i{}; // Clang 6.0 compilation segfaults without this line
auto&& iterable = get_iterable<Iterable, CONST, RVALUE>();
for(auto&&[idx, value] : util::gen::enumerate{get_iterable<Iterable, CONST, RVALUE>()}) {
using ValueType = decltype(value);
static_assert(std::is_lvalue_reference_v<ValueType>);
static_assert(std::is_const_v<std::remove_reference_t<ValueType>> == CONST);
CHECK(idx == value);
if constexpr(!CONST && !RVALUE) {
value = 10;
}
}
if constexpr(!CONST && !RVALUE) {
for(auto&& value : iterable) {
CHECK(value == 10);
}
}
}
template<class Iterable>
void test_iterable_wo_starting_index() {
test<Iterable, false, false>();
test<Iterable, true, false>();
test<Iterable, false, true>();
test<Iterable, true, true>();
}
template<class Iterable, bool CONST, bool RVALUE>
void test_start_idx(int64_t starting_idx) {
auto&& iterable = get_iterable<Iterable, CONST, RVALUE>();
for(auto&&[idx, value] : util::gen::enumerate{get_iterable<Iterable, CONST, RVALUE>(), starting_idx}) {
using ValueType = decltype(value);
static_assert(std::is_lvalue_reference_v<ValueType>);
static_assert(std::is_const_v<std::remove_reference_t<ValueType>> == CONST);
CHECK(idx == value + starting_idx);
if constexpr(!CONST && !RVALUE) {
value = 10;
}
}
if constexpr(!CONST && !RVALUE) {
for(auto&& value : iterable) {
CHECK(value == 10);
}
}
}
template<class Iterable>
void test_iterable_w_starting_idx(int64_t starting_idx) {
test_start_idx<Iterable, false, false>(starting_idx);
test_start_idx<Iterable, true, false>(starting_idx);
test_start_idx<Iterable, false, true>(starting_idx);
test_start_idx<Iterable, true, true>(starting_idx);
}
template<class Iterable>
void test_iterable() {
test_iterable_wo_starting_index<Iterable>();
test_iterable_w_starting_idx<Iterable>(0);
test_iterable_w_starting_idx<Iterable>(7);
test_iterable_w_starting_idx<Iterable>(-8);
}
}
TEST_CASE("enumerate std::vector") {
test_iterable<std::vector<int>>();
}
TEST_CASE("enumerate std::deque") {
test_iterable<std::deque<int>>();
}
TEST_CASE("enumerate std::list") {
test_iterable<std::list<int>>();
}
TEST_CASE("enumerate std::forward_list") {
test_iterable<std::forward_list<int>>();
}
TEST_CASE("enumerate std::array") {
test_iterable<std::array<int, 5>>();
}
TEST_CASE("enumerate c-style array") {
SECTION("LValue") {
int arr[5] = {0, 1, 2, 3, 4};
for(auto&&[idx, value] : util::gen::enumerate{arr}) {
using ValueType = decltype(value);
static_assert(std::is_lvalue_reference_v<ValueType>);
static_assert(!std::is_const_v<std::remove_reference_t<ValueType>>);
CHECK(idx == value);
value = 10;
}
for(auto&& value : arr) {
CHECK(value == 10);
}
}
SECTION("Const LValue") {
const int arr[5] = {0, 1, 2, 3, 4};
for(auto&&[idx, value] : util::gen::enumerate{arr}) {
using ValueType = decltype(value);
static_assert(std::is_lvalue_reference_v<ValueType>);
static_assert(std::is_const_v<std::remove_reference_t<ValueType>>);
CHECK(idx == value);
}
}
}
#ifdef __GNUC__
#ifndef __clang__
TEST_CASE("enumerate initializer list") {
SECTION("LValue") {
for(auto&&[idx, value] : util::gen::enumerate{{0,1,2,3,4}}) {
using ValueType = decltype(value);
static_assert(std::is_lvalue_reference_v<ValueType>);
static_assert(std::is_const_v<std::remove_reference_t<ValueType>>);
CHECK(idx == value);
}
}
}
#endif
#endif
| 29.977011 | 111 | 0.591258 | [
"vector"
] |
b5e0552cc84204af7c28e0c5176df4db75631ed0 | 8,154 | hpp | C++ | src/rrgenerator.hpp | sischkg/nxnsattack | c20896e40187bbcacb5c0255ff8f3cc7d0592126 | [
"MIT"
] | 5 | 2020-05-22T10:01:51.000Z | 2022-01-01T04:45:14.000Z | src/rrgenerator.hpp | sischkg/dns-fuzz-server | 6f45079014e745537c2f564fdad069974e727da1 | [
"MIT"
] | 1 | 2020-06-07T14:09:44.000Z | 2020-06-07T14:09:44.000Z | src/rrgenerator.hpp | sischkg/dns-fuzz-server | 6f45079014e745537c2f564fdad069974e727da1 | [
"MIT"
] | 2 | 2020-03-10T03:06:20.000Z | 2021-07-25T15:07:45.000Z | #ifndef RR_GENERATOR_HPP
#define RR_GENERATOR_HPP
#include "dns.hpp"
#include "zone.hpp"
#include <boost/noncopyable.hpp>
#include <boost/random.hpp>
#include <boost/thread.hpp>
namespace dns
{
/**********************************************************
* RandomGenarator
**********************************************************/
class RandomGenerator : private boost::noncopyable
{
public:
uint32_t rand( uint32_t = 0xffffffff );
std::vector<uint8_t> randStream( unsigned int );
std::vector<uint8_t> randSizeStream( unsigned int );
static RandomGenerator *getInstance();
private:
static RandomGenerator *mInstance;
RandomGenerator();
boost::mt19937 mGenerator;
boost::mutex mMutex;
};
inline uint32_t getRandom( uint32_t base = 0xffffffff )
{
uint32_t v = RandomGenerator::getInstance()->rand( base );
return v;
}
inline std::vector<uint8_t> getRandomStream( unsigned int size )
{
return RandomGenerator::getInstance()->randStream( size );
}
inline std::vector<uint8_t> getRandomSizeStream( unsigned int max_size )
{
return RandomGenerator::getInstance()->randSizeStream( max_size );
}
inline bool withChance( float ratio )
{
if ( ratio < 0 || ratio > 1 )
throw std::logic_error( "invalid ratio of change" );
return getRandom( 0xffff ) < 0xffff * ratio;
}
class DomainnameGenerator
{
public:
Domainname generate( const Domainname &hint1, const Domainname &hint2 );
Domainname generate();
std::string generateLabel();
};
Domainname generateDomainname();
class RDATAGeneratable
{
public:
virtual ~RDATAGeneratable() {}
virtual std::shared_ptr<RDATA> generate( const MessageInfo &hint1, const Domainname &hint2 ) = 0;
virtual std::shared_ptr<RDATA> generate() = 0;
};
class ResourceRecordGenerator
{
public:
ResourceRecordGenerator();
RRSet generate( const MessageInfo &hint1, const Domainname &hint2 );
private:
std::vector<std::shared_ptr<RDATAGeneratable>> mGenerators;
};
class RawGenerator : public RDATAGeneratable
{
public:
std::shared_ptr<RDATA> generate( const MessageInfo &hint1, const Domainname &hint2 );
std::shared_ptr<RDATA> generate();
};
template <class T>
class XNameGenerator : public RDATAGeneratable
{
public:
std::shared_ptr<RDATA> generate( const MessageInfo &hint1, const Domainname &hint2 );
std::shared_ptr<RDATA> generate();
};
typedef XNameGenerator<RecordNS> NSGenerator;
typedef XNameGenerator<RecordCNAME> CNAMEGenerator;
typedef XNameGenerator<RecordDNAME> DNAMEGenerator;
class AGenerator : public RDATAGeneratable
{
public:
std::shared_ptr<RDATA> generate( const MessageInfo &hint1, const Domainname &hint2 );
std::shared_ptr<RDATA> generate();
};
class AAAAGenerator : public RDATAGeneratable
{
public:
std::shared_ptr<RDATA> generate( const MessageInfo &hint1, const Domainname &hint2 );
std::shared_ptr<RDATA> generate();
};
class WKSGenerator : public RDATAGeneratable
{
public:
std::shared_ptr<RDATA> generate( const MessageInfo &hint1, const Domainname &hint2 );
std::shared_ptr<RDATA> generate();
};
class SOAGenerator : public RDATAGeneratable
{
public:
std::shared_ptr<RDATA> generate( const MessageInfo &hint1, const Domainname &hint2 );
std::shared_ptr<RDATA> generate();
};
class SRVGenerator : public RDATAGeneratable
{
public:
std::shared_ptr<RDATA> generate( const MessageInfo &hint1, const Domainname &hint2 );
std::shared_ptr<RDATA> generate();
};
class RRSIGGenerator : public RDATAGeneratable
{
public:
std::shared_ptr<RDATA> generate( const MessageInfo &hint1, const Domainname &hint2 );
std::shared_ptr<RDATA> generate();
};
class DNSKEYGenerator : public RDATAGeneratable
{
public:
std::shared_ptr<RDATA> generate( const MessageInfo &hint1, const Domainname &hint2 );
std::shared_ptr<RDATA> generate();
};
class DSGenerator : public RDATAGeneratable
{
public:
std::shared_ptr<RDATA> generate( const MessageInfo &hint1, const Domainname &hint2 );
std::shared_ptr<RDATA> generate();
};
class NSECGenerator : public RDATAGeneratable
{
public:
std::shared_ptr<RDATA> generate( const MessageInfo &hint1, const Domainname &hint2 );
std::shared_ptr<RDATA> generate();
};
class NSEC3Generator : public RDATAGeneratable
{
public:
std::shared_ptr<RDATA> generate( const MessageInfo &hint1, const Domainname &hint2 );
std::shared_ptr<RDATA> generate();
};
class NSEC3PARAMGenerator : public RDATAGeneratable
{
public:
std::shared_ptr<RDATA> generate( const MessageInfo &hint1, const Domainname &hint2 );
std::shared_ptr<RDATA> generate();
};
class TLSAGenerator : public RDATAGeneratable
{
public:
std::shared_ptr<RDATA> generate( const MessageInfo &hint1, const Domainname &hint2 );
std::shared_ptr<RDATA> generate();
};
class TKEYGenerator : public RDATAGeneratable
{
public:
std::shared_ptr<RDATA> generate( const MessageInfo &hint1, const Domainname &hint2 );
std::shared_ptr<RDATA> generate();
};
class TSIGGenerator : public RDATAGeneratable
{
public:
std::shared_ptr<RDATA> generate( const MessageInfo &hint1, const Domainname &hint2 );
std::shared_ptr<RDATA> generate();
};
class SIGGenerator : public RDATAGeneratable
{
public:
std::shared_ptr<RDATA> generate( const MessageInfo &hint1, const Domainname &hint2 );
std::shared_ptr<RDATA> generate();
};
class KEYGenerator : public RDATAGeneratable
{
public:
std::shared_ptr<RDATA> generate( const MessageInfo &hint1, const Domainname &hint2 );
std::shared_ptr<RDATA> generate();
};
class NXTGenerator : public RDATAGeneratable
{
public:
std::shared_ptr<RDATA> generate( const MessageInfo &hint1, const Domainname &hint2 );
std::shared_ptr<RDATA> generate();
};
class OptGeneratable
{
public:
virtual std::shared_ptr<OptPseudoRROption> generate( const MessageInfo &hint ) = 0;
virtual std::shared_ptr<OptPseudoRROption> generate() = 0;
};
class RawOptionGenerator : public OptGeneratable
{
public:
virtual std::shared_ptr<OptPseudoRROption> generate( const MessageInfo &hint );
virtual std::shared_ptr<OptPseudoRROption> generate();
};
class NSIDGenerator : public OptGeneratable
{
public:
virtual std::shared_ptr<OptPseudoRROption> generate( const MessageInfo &hint );
virtual std::shared_ptr<OptPseudoRROption> generate();
};
class ClientSubnetGenerator : public OptGeneratable
{
public:
virtual std::shared_ptr<OptPseudoRROption> generate( const MessageInfo &hint );
virtual std::shared_ptr<OptPseudoRROption> generate();
};
class CookieGenerator : public OptGeneratable
{
public:
virtual std::shared_ptr<OptPseudoRROption> generate( const MessageInfo &hint );
virtual std::shared_ptr<OptPseudoRROption> generate();
};
class TCPKeepaliveGenerator : public OptGeneratable
{
public:
virtual std::shared_ptr<OptPseudoRROption> generate( const MessageInfo &hint );
virtual std::shared_ptr<OptPseudoRROption> generate();
};
class KeyTagGenerator : public OptGeneratable
{
public:
virtual std::shared_ptr<OptPseudoRROption> generate( const MessageInfo &hint );
virtual std::shared_ptr<OptPseudoRROption> generate();
};
class OptionGenerator
{
public:
OptionGenerator();
void generate( MessageInfo &packet );
private:
std::vector<std::shared_ptr<OptGeneratable>> mGenerators;
};
}
#endif
| 28.51049 | 105 | 0.65612 | [
"vector"
] |
b5e62cbc4c5372e34c649b443f325f66b3042259 | 1,524 | hpp | C++ | include/fcppt/io/write.hpp | vinzenz/fcppt | 3f8cc5babdee178a9bbd06ca3ce7ad405d19aa6a | [
"BSL-1.0"
] | null | null | null | include/fcppt/io/write.hpp | vinzenz/fcppt | 3f8cc5babdee178a9bbd06ca3ce7ad405d19aa6a | [
"BSL-1.0"
] | null | null | null | include/fcppt/io/write.hpp | vinzenz/fcppt | 3f8cc5babdee178a9bbd06ca3ce7ad405d19aa6a | [
"BSL-1.0"
] | null | null | null | // Copyright Carl Philipp Reh 2009 - 2016.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef FCPPT_IO_WRITE_HPP_INCLUDED
#define FCPPT_IO_WRITE_HPP_INCLUDED
#include <fcppt/cast/size.hpp>
#include <fcppt/cast/to_char_ptr.hpp>
#include <fcppt/cast/to_signed.hpp>
#include <fcppt/endianness/convert.hpp>
#include <fcppt/endianness/format_fwd.hpp>
#include <fcppt/config/external_begin.hpp>
#include <iosfwd>
#include <ostream>
#include <type_traits>
#include <fcppt/config/external_end.hpp>
namespace fcppt
{
namespace io
{
/**
\brief Writes an object of fundamental type to a stream
\ingroup fcpptio
Writes \a _value to \a _stream using the endianness of \a _format. The write
will be done binary.
\tparam Type Must be a fundamental type
\param _stream The stream to write to
\param _value The value to write
\param _format The endianness to use
*/
template<
typename Type
>
void
write(
std::ostream &_stream,
Type const &_value,
fcppt::endianness::format const _format
)
{
static_assert(
std::is_fundamental<
Type
>::value,
"io::write can only be used on fundamental types"
);
Type const tmp(
fcppt::endianness::convert(
_value,
_format
)
);
_stream.write(
fcppt::cast::to_char_ptr<
char const *
>(
&tmp
),
fcppt::cast::size<
std::streamsize
>(
fcppt::cast::to_signed(
sizeof(
Type
)
)
)
);
}
}
}
#endif
| 17.123596 | 76 | 0.704724 | [
"object"
] |
b5f2be7e637b3e224906b552d6d682699c239d7c | 688 | cc | C++ | problems/0XXX/00XX/008X/0088_merge_sorted_array.cc | mohankarthik/leetcode | 9a15200460425962b26867ed14416576f54e8ce5 | [
"MIT"
] | null | null | null | problems/0XXX/00XX/008X/0088_merge_sorted_array.cc | mohankarthik/leetcode | 9a15200460425962b26867ed14416576f54e8ce5 | [
"MIT"
] | null | null | null | problems/0XXX/00XX/008X/0088_merge_sorted_array.cc | mohankarthik/leetcode | 9a15200460425962b26867ed14416576f54e8ce5 | [
"MIT"
] | null | null | null | #include "../../../../common/Includes.h"
class Solution {
public:
void merge(vector<int>& nums1, int m, vector<int>& nums2, int n) {
int i = 0;
int j = 0;
int orig_m = m;
while((i < m) && (j < n)) {
if (nums1[i] < nums2[j]) {
i++;
} else {
nums1.insert(nums1.begin() + i, nums2[j]);
j++;
i++;
m++;
}
}
if (j < n) {
for (; j < n; j++) {
nums1.insert(nums1.begin() + i, nums2[j]);
i++;
}
}
nums1.resize(orig_m+n);
}
}; | 22.933333 | 70 | 0.322674 | [
"vector"
] |
b5f8460059efc0afd268fc27af9fe2be010dd6c0 | 41,693 | cpp | C++ | bench/ml2cpp-demo/DecisionTreeRegressor_Pipeline/boston/ml2cpp-demo_DecisionTreeRegressor_Pipeline_boston.cpp | antoinecarme/ml2cpp | 2b241d44de00eafda620c2b605690276faf5f8fb | [
"BSD-3-Clause"
] | null | null | null | bench/ml2cpp-demo/DecisionTreeRegressor_Pipeline/boston/ml2cpp-demo_DecisionTreeRegressor_Pipeline_boston.cpp | antoinecarme/ml2cpp | 2b241d44de00eafda620c2b605690276faf5f8fb | [
"BSD-3-Clause"
] | 33 | 2020-09-13T09:55:01.000Z | 2022-01-06T11:53:55.000Z | bench/ml2cpp-demo/DecisionTreeRegressor_Pipeline/boston/ml2cpp-demo_DecisionTreeRegressor_Pipeline_boston.cpp | antoinecarme/ml2cpp | 2b241d44de00eafda620c2b605690276faf5f8fb | [
"BSD-3-Clause"
] | 1 | 2021-01-26T14:41:58.000Z | 2021-01-26T14:41:58.000Z | // ********************************************************
// This C++ code was automatically generated by ml2cpp (development version).
// Copyright 2020
// https://github.com/antoinecarme/ml2cpp
// Model : DecisionTreeRegressor_Pipeline
// Dataset : boston
// This CPP code can be compiled using any C++-17 compiler.
// g++ -Wall -Wno-unused-function -std=c++17 -g -o ml2cpp-demo_DecisionTreeRegressor_Pipeline_boston.exe ml2cpp-demo_DecisionTreeRegressor_Pipeline_boston.cpp
// Model deployment code
// ********************************************************
#include "../../Generic.i"
namespace {
namespace imputer {
std::vector<std::string> get_input_names(){
std::vector<std::string> lFeatures = { "Feature_0", "Feature_1", "Feature_2", "Feature_3", "Feature_4", "Feature_5", "Feature_6", "Feature_7", "Feature_8", "Feature_9", "Feature_10", "Feature_11", "Feature_12" };
return lFeatures;
}
std::vector<std::string> get_output_names(){
std::vector<std::string> lOutputs = { "imputer_output_2", "imputer_output_3", "imputer_output_4", "imputer_output_5", "imputer_output_6", "imputer_output_7", "imputer_output_8", "imputer_output_9", "imputer_output_10", "imputer_output_11", "imputer_output_12", "imputer_output_13", "imputer_output_14" };
return lOutputs;
}
tTable compute_features(std::any Feature_0, std::any Feature_1, std::any Feature_2, std::any Feature_3, std::any Feature_4, std::any Feature_5, std::any Feature_6, std::any Feature_7, std::any Feature_8, std::any Feature_9, std::any Feature_10, std::any Feature_11, std::any Feature_12) {
tTable lTable;
lTable["imputer_output_2"] = { ((Feature_0 == std::any()) ? ( 3.3936090099009903 ) : ( Feature_0)) };
lTable["imputer_output_3"] = { ((Feature_1 == std::any()) ? ( 12.113861386138614 ) : ( Feature_1)) };
lTable["imputer_output_4"] = { ((Feature_2 == std::any()) ? ( 10.983613861386127 ) : ( Feature_2)) };
lTable["imputer_output_5"] = { ((Feature_3 == std::any()) ? ( 0.07178217821782178 ) : ( Feature_3)) };
lTable["imputer_output_6"] = { ((Feature_4 == std::any()) ? ( 0.5541153465346542 ) : ( Feature_4)) };
lTable["imputer_output_7"] = { ((Feature_5 == std::any()) ? ( 6.299148514851482 ) : ( Feature_5)) };
lTable["imputer_output_8"] = { ((Feature_6 == std::any()) ? ( 67.85049504950491 ) : ( Feature_6)) };
lTable["imputer_output_9"] = { ((Feature_7 == std::any()) ? ( 3.8198420792079233 ) : ( Feature_7)) };
lTable["imputer_output_10"] = { ((Feature_8 == std::any()) ? ( 9.55940594059406 ) : ( Feature_8)) };
lTable["imputer_output_11"] = { ((Feature_9 == std::any()) ? ( 405.8019801980198 ) : ( Feature_9)) };
lTable["imputer_output_12"] = { ((Feature_10 == std::any()) ? ( 18.40915841584154 ) : ( Feature_10)) };
lTable["imputer_output_13"] = { ((Feature_11 == std::any()) ? ( 358.3797277227715 ) : ( Feature_11)) };
lTable["imputer_output_14"] = { ((Feature_12 == std::any()) ? ( 12.626584158415856 ) : ( Feature_12)) };
return lTable;
}
tTable compute_model_outputs_from_table( tTable const & iTable) {
tTable lTable = compute_features(iTable.at("Feature_0")[0], iTable.at("Feature_1")[0], iTable.at("Feature_2")[0], iTable.at("Feature_3")[0], iTable.at("Feature_4")[0], iTable.at("Feature_5")[0], iTable.at("Feature_6")[0], iTable.at("Feature_7")[0], iTable.at("Feature_8")[0], iTable.at("Feature_9")[0], iTable.at("Feature_10")[0], iTable.at("Feature_11")[0], iTable.at("Feature_12")[0]);
return lTable;
}
} // eof namespace imputer
namespace scaler {
std::vector<std::string> get_input_names(){
std::vector<std::string> lFeatures = { "imputer_output_2", "imputer_output_3", "imputer_output_4", "imputer_output_5", "imputer_output_6", "imputer_output_7", "imputer_output_8", "imputer_output_9", "imputer_output_10", "imputer_output_11", "imputer_output_12", "imputer_output_13", "imputer_output_14" };
return lFeatures;
}
std::vector<std::string> get_output_names(){
std::vector<std::string> lOutputs = { "scaler_output_2", "scaler_output_3", "scaler_output_4", "scaler_output_5", "scaler_output_6", "scaler_output_7", "scaler_output_8", "scaler_output_9", "scaler_output_10", "scaler_output_11", "scaler_output_12", "scaler_output_13", "scaler_output_14" };
return lOutputs;
}
tTable compute_features(std::any imputer_output_2, std::any imputer_output_3, std::any imputer_output_4, std::any imputer_output_5, std::any imputer_output_6, std::any imputer_output_7, std::any imputer_output_8, std::any imputer_output_9, std::any imputer_output_10, std::any imputer_output_11, std::any imputer_output_12, std::any imputer_output_13, std::any imputer_output_14) {
tTable lTable;
lTable["scaler_output_2"] = { ( ( imputer_output_2 - 3.3936090099009903 ) / 8.000616555737787 ) };
lTable["scaler_output_3"] = { ( ( imputer_output_3 - 12.113861386138614 ) / 24.187656534977855 ) };
lTable["scaler_output_4"] = { ( ( imputer_output_4 - 10.983613861386127 ) / 6.8177472477399235 ) };
lTable["scaler_output_5"] = { ( ( imputer_output_5 - 0.07178217821782178 ) / 0.2581269011709685 ) };
lTable["scaler_output_6"] = { ( ( imputer_output_6 - 0.5541153465346542 ) / 0.11800809760824685 ) };
lTable["scaler_output_7"] = { ( ( imputer_output_7 - 6.299148514851482 ) / 0.7060417397996938 ) };
lTable["scaler_output_8"] = { ( ( imputer_output_8 - 67.85049504950491 ) / 28.107403181658597 ) };
lTable["scaler_output_9"] = { ( ( imputer_output_9 - 3.8198420792079233 ) / 2.0933726902675627 ) };
lTable["scaler_output_10"] = { ( ( imputer_output_10 - 9.55940594059406 ) / 8.728803783375893 ) };
lTable["scaler_output_11"] = { ( ( imputer_output_11 - 405.8019801980198 ) / 169.7858592930543 ) };
lTable["scaler_output_12"] = { ( ( imputer_output_12 - 18.40915841584154 ) / 2.166792648327246 ) };
lTable["scaler_output_13"] = { ( ( imputer_output_13 - 358.3797277227715 ) / 90.64691624336051 ) };
lTable["scaler_output_14"] = { ( ( imputer_output_14 - 12.626584158415856 ) / 7.167938324035357 ) };
return lTable;
}
tTable compute_model_outputs_from_table( tTable const & iTable) {
tTable lTable = compute_features(iTable.at("imputer_output_2")[0], iTable.at("imputer_output_3")[0], iTable.at("imputer_output_4")[0], iTable.at("imputer_output_5")[0], iTable.at("imputer_output_6")[0], iTable.at("imputer_output_7")[0], iTable.at("imputer_output_8")[0], iTable.at("imputer_output_9")[0], iTable.at("imputer_output_10")[0], iTable.at("imputer_output_11")[0], iTable.at("imputer_output_12")[0], iTable.at("imputer_output_13")[0], iTable.at("imputer_output_14")[0]);
return lTable;
}
} // eof namespace scaler
namespace model {
typedef std::vector<double> tNodeData;
std::map<int, tNodeData> Decision_Tree_Node_data = {
{ 4 , {50. }} ,
{ 8 , {29.1 }} ,
{ 12 , {27. }} ,
{ 13 , {27.5 }} ,
{ 14 , {24.3 }} ,
{ 18 , {24.6 }} ,
{ 19 , {24.4 }} ,
{ 21 , {25.2 }} ,
{ 22 , {25. }} ,
{ 23 , {22.1 }} ,
{ 28 , {25.3 }} ,
{ 30 , {25. }} ,
{ 31 , {24.7 }} ,
{ 36 , {22.9 }} ,
{ 38 , {23.5 }} ,
{ 39 , {24.1 }} ,
{ 40 , {24.8 }} ,
{ 45 , {23. }} ,
{ 46 , {22.8 }} ,
{ 48 , {23.4 }} ,
{ 49 , {23.2 }} ,
{ 51 , {23.1 }} ,
{ 53 , {22.3 }} ,
{ 55 , {22.5 }} ,
{ 56 , {22.6 }} ,
{ 57 , {21.9 }} ,
{ 60 , {23.1 }} ,
{ 63 , {23.7 }} ,
{ 64 , {23.7 }} ,
{ 65 , {24.2 }} ,
{ 67 , {23.8 }} ,
{ 70 , {24.4 }} ,
{ 71 , {24.7 }} ,
{ 72 , {25. }} ,
{ 74 , {20.7 }} ,
{ 76 , {22.2 }} ,
{ 78 , {22.9 }} ,
{ 79 , {23.1 }} ,
{ 80 , {20.4 }} ,
{ 84 , {27.9 }} ,
{ 89 , {16.1 }} ,
{ 90 , {16. }} ,
{ 92 , {19.3 }} ,
{ 95 , {17.2 }} ,
{ 96 , {17.5 }} ,
{ 97 , {18.2 }} ,
{ 101 , {15.3 }} ,
{ 102 , {15. }} ,
{ 103 , {19.6 }} ,
{ 106 , {23.8 }} ,
{ 108 , {21.9 }} ,
{ 111 , {20.3 }} ,
{ 113 , {20.6 }} ,
{ 114 , {20.8 }} ,
{ 115 , {21.7 }} ,
{ 117 , {17.4 }} ,
{ 118 , {16.8 }} ,
{ 122 , {21.7 }} ,
{ 125 , {23.3 }} ,
{ 126 , {23.2 }} ,
{ 129 , {22.8 }} ,
{ 131 , {22.6 }} ,
{ 132 , {22.7 }} ,
{ 134 , {22.9 }} ,
{ 135 , {23.1 }} ,
{ 137 , {23.4 }} ,
{ 140 , {18.9 }} ,
{ 141 , {19.4 }} ,
{ 142 , {20.9 }} ,
{ 147 , {18.2 }} ,
{ 148 , {19.3 }} ,
{ 150 , {16.2 }} ,
{ 152 , {17.4 }} ,
{ 153 , {17.1 }} ,
{ 156 , {18.5 }} ,
{ 157 , {18.7 }} ,
{ 159 , {20.1 }} ,
{ 160 , {19.3 }} ,
{ 165 , {20. }} ,
{ 166 , {18.6 }} ,
{ 168 , {22. }} ,
{ 172 , {21.1 }} ,
{ 174 , {21. }} ,
{ 175 , {20.9 }} ,
{ 176 , {20.3 }} ,
{ 177 , {21.8 }} ,
{ 180 , {22.6 }} ,
{ 181 , {22.5 }} ,
{ 183 , {24.7 }} ,
{ 184 , {24.5 }} ,
{ 188 , {22. }} ,
{ 190 , {20.7 }} ,
{ 191 , {20.6 }} ,
{ 194 , {21.2 }} ,
{ 195 , {20.1 }} ,
{ 199 , {18.5 }} ,
{ 202 , {19.6 }} ,
{ 203 , {19.5 }} ,
{ 206 , {19.2 }} ,
{ 207 , {19.4 }} ,
{ 209 , {18.7 }} ,
{ 210 , {19. }} ,
{ 211 , {18.3 }} ,
{ 214 , {19.6 }} ,
{ 215 , {19.9 }} ,
{ 217 , {20.3 }} ,
{ 218 , {20.4 }} ,
{ 219 , {16.8 }} ,
{ 220 , {11.9 }} ,
{ 228 , {22.2 }} ,
{ 229 , {21.7 }} ,
{ 233 , {21.1 }} ,
{ 234 , {21.2 }} ,
{ 235 , {20.8 }} ,
{ 237 , {20.5 }} ,
{ 238 , {20.1 }} ,
{ 242 , {22.2 }} ,
{ 243 , {22. }} ,
{ 245 , {22.6 }} ,
{ 246 , {22.9 }} ,
{ 247 , {23.9 }} ,
{ 252 , {25. }} ,
{ 254 , {24.4 }} ,
{ 255 , {24.5 }} ,
{ 257 , {24.3 }} ,
{ 258 , {24. }} ,
{ 260 , {22.2 }} ,
{ 261 , {23. }} ,
{ 264 , {21.2 }} ,
{ 265 , {21. }} ,
{ 266 , {21.4 }} ,
{ 267 , {26.4 }} ,
{ 268 , {29.6 }} ,
{ 270 , {16.1 }} ,
{ 274 , {23.6 }} ,
{ 275 , {23. }} ,
{ 276 , {21.5 }} ,
{ 281 , {22. }} ,
{ 283 , {21.6 }} ,
{ 285 , {21.2 }} ,
{ 286 , {21.4 }} ,
{ 289 , {20.6 }} ,
{ 290 , {20.5 }} ,
{ 291 , {20. }} ,
{ 294 , {18.2 }} ,
{ 297 , {20.4 }} ,
{ 298 , {21.4 }} ,
{ 299 , {23. }} ,
{ 303 , {18.5 }} ,
{ 304 , {18.4 }} ,
{ 305 , {17.7 }} ,
{ 308 , {20.1 }} ,
{ 309 , {20.2 }} ,
{ 312 , {19.2 }} ,
{ 313 , {19.3 }} ,
{ 316 , {19.8 }} ,
{ 318 , {19.6 }} ,
{ 319 , {19.5 }} ,
{ 320 , {20. }} ,
{ 323 , {22.6 }} ,
{ 324 , {22.7 }} ,
{ 325 , {21.7 }} ,
{ 327 , {50. }} ,
{ 335 , {30.8 }} ,
{ 336 , {30.1 }} ,
{ 338 , {29.8 }} ,
{ 339 , {29.1 }} ,
{ 340 , {32.4 }} ,
{ 344 , {28. }} ,
{ 345 , {27.9 }} ,
{ 346 , {26.6 }} ,
{ 347 , {29.4 }} ,
{ 349 , {24. }} ,
{ 350 , {22.8 }} ,
{ 354 , {31.6 }} ,
{ 355 , {33.4 }} ,
{ 357 , {37. }} ,
{ 360 , {34.9 }} ,
{ 361 , {35.1 }} ,
{ 362 , {35.4 }} ,
{ 365 , {33.1 }} ,
{ 367 , {32. }} ,
{ 368 , {31.2 }} ,
{ 370 , {29.6 }} ,
{ 371 , {28.5 }} ,
{ 379 , {32. }} ,
{ 380 , {32.5 }} ,
{ 383 , {29.9 }} ,
{ 385 , {30.1 }} ,
{ 386 , {30.1 }} ,
{ 387 , {29. }} ,
{ 389 , {28.4 }} ,
{ 390 , {28.2 }} ,
{ 392 , {23.6 }} ,
{ 394 , {26.7 }} ,
{ 395 , {27.5 }} ,
{ 399 , {22.8 }} ,
{ 401 , {23.7 }} ,
{ 402 , {23.8 }} ,
{ 403 , {26.5 }} ,
{ 405 , {29.8 }} ,
{ 406 , {28.7 }} ,
{ 409 , {28.6 }} ,
{ 411 , {27.1 }} ,
{ 412 , {26.6 }} ,
{ 415 , {22. }} ,
{ 417 , {23.9 }} ,
{ 418 , {25.1 }} ,
{ 422 , {24.8 }} ,
{ 423 , {24.8 }} ,
{ 424 , {25. }} ,
{ 425 , {26.2 }} ,
{ 427 , {23.9 }} ,
{ 430 , {22. }} ,
{ 431 , {22.4 }} ,
{ 432 , {21. }} ,
{ 439 , {21.7 }} ,
{ 440 , {20.4 }} ,
{ 443 , {23.1 }} ,
{ 444 , {23.7 }} ,
{ 446 , {22.5 }} ,
{ 447 , {22.4 }} ,
{ 450 , {19.4 }} ,
{ 451 , {19.8 }} ,
{ 452 , {18.9 }} ,
{ 456 , {20.5 }} ,
{ 458 , {18.8 }} ,
{ 459 , {19.5 }} ,
{ 460 , {27.1 }} ,
{ 465 , {17.5 }} ,
{ 466 , {17.8 }} ,
{ 468 , {18.3 }} ,
{ 469 , {18.7 }} ,
{ 473 , {16.6 }} ,
{ 474 , {15.7 }} ,
{ 476 , {15. }} ,
{ 477 , {14.4 }} ,
{ 479 , {16.5 }} ,
{ 480 , {17.3 }} ,
{ 483 , {19.3 }} ,
{ 484 , {20. }} ,
{ 485 , {21.7 }} ,
{ 489 , {11.7 }} ,
{ 490 , {10.2 }} ,
{ 492 , {19.1 }} ,
{ 496 , {16.3 }} ,
{ 501 , {13.9 }} ,
{ 502 , {13.8 }} ,
{ 503 , {13.6 }} ,
{ 505 , {13.1 }} ,
{ 506 , {13.5 }} ,
{ 507 , {14.5 }} ,
{ 510 , {15.6 }} ,
{ 511 , {15.2 }} ,
{ 512 , {16.6 }} ,
{ 515 , {19.1 }} ,
{ 517 , {17.2 }} ,
{ 518 , {17.9 }} ,
{ 520 , {13.3 }} ,
{ 521 , {17.2 }} ,
{ 522 , {27.5 }} ,
{ 530 , {13.1 }} ,
{ 531 , {15.6 }} ,
{ 533 , {15.6 }} ,
{ 537 , {19. }} ,
{ 538 , {19.4 }} ,
{ 540 , {17.4 }} ,
{ 543 , {18. }} ,
{ 544 , {18.1 }} ,
{ 545 , {18.4 }} ,
{ 546 , {16.1 }} ,
{ 549 , {15.2 }} ,
{ 551 , {14.1 }} ,
{ 552 , {13.6 }} ,
{ 553 , {16.7 }} ,
{ 557 , {13.4 }} ,
{ 558 , {13.5 }} ,
{ 560 , {13.1 }} ,
{ 563 , {14.2 }} ,
{ 566 , {14.9 }} ,
{ 567 , {14.9 }} ,
{ 568 , {15.1 }} ,
{ 569 , {14.1 }} ,
{ 570 , {17.8 }} ,
{ 571 , {23.2 }} ,
{ 574 , {7. }} ,
{ 577 , {13.3 }} ,
{ 579 , {14. }} ,
{ 580 , {14.4 }} ,
{ 584 , {12.7 }} ,
{ 585 , {12.5 }} ,
{ 586 , {13. }} ,
{ 589 , {11. }} ,
{ 591 , {8.5 }} ,
{ 592 , {9.5 }} ,
{ 595 , {11.3 }} ,
{ 596 , {12.1 }} ,
{ 597 , {12.3 }} ,
{ 601 , {13.8 }} ,
{ 602 , {15.4 }} ,
{ 604 , {17.8 }} ,
{ 605 , {17.1 }} ,
{ 607 , {11.8 }} ,
{ 610 , {13.4 }} ,
{ 612 , {15.6 }} ,
{ 613 , {14.6 }} ,
{ 614 , {12.8 }} ,
{ 619 , {11.7 }} ,
{ 621 , {12.6 }} ,
{ 622 , {12.7 }} ,
{ 623 , {10.4 }} ,
{ 625 , {16.7 }} ,
{ 626 , {14.6 }} ,
{ 629 , {10.2 }} ,
{ 632 , {13.9 }} ,
{ 633 , {13.8 }} ,
{ 634 , {13.1 }} ,
{ 638 , {10.4 }} ,
{ 640 , {7.5 }} ,
{ 641 , {8.3 }} ,
{ 643 , {5. }} ,
{ 645 , {7.2 }} ,
{ 648 , {6.3 }} ,
{ 649 , {5.6 }} ,
{ 650 , {7. }} ,
{ 653 , {13.4 }} ,
{ 654 , {11.8 }} ,
{ 658 , {8.4 }} ,
{ 659 , {8.8 }} ,
{ 660 , {7.4 }} ,
{ 662 , {8.7 }} ,
{ 665 , {9.7 }} ,
{ 667 , {10.8 }} ,
{ 669 , {10.5 }} ,
{ 670 , {10.2 }} ,
{ 671 , {9.6 }} ,
{ 680 , {34.7 }} ,
{ 681 , {34.9 }} ,
{ 682 , {35.4 }} ,
{ 684 , {36.2 }} ,
{ 685 , {36.1 }} ,
{ 686 , {33.4 }} ,
{ 688 , {37.9 }} ,
{ 689 , {37.3 }} ,
{ 694 , {30.3 }} ,
{ 695 , {30.7 }} ,
{ 696 , {29. }} ,
{ 697 , {32.2 }} ,
{ 699 , {36. }} ,
{ 704 , {32.7 }} ,
{ 705 , {32.9 }} ,
{ 706 , {33.3 }} ,
{ 708 , {34.6 }} ,
{ 709 , {33.8 }} ,
{ 711 , {31. }} ,
{ 713 , {31.7 }} ,
{ 714 , {31.5 }} ,
{ 716 , {25. }} ,
{ 718 , {15. }} ,
{ 719 , {17.8 }} ,
{ 724 , {50. }} ,
{ 727 , {43.1 }} ,
{ 728 , {43.5 }} ,
{ 729 , {42.3 }} ,
{ 731 , {50. }} ,
{ 733 , {48.8 }} ,
{ 734 , {50. }} ,
{ 741 , {46. }} ,
{ 742 , {46.7 }} ,
{ 745 , {44. }} ,
{ 746 , {43.8 }} ,
{ 748 , {44.8 }} ,
{ 749 , {45.4 }} ,
{ 751 , {41.7 }} ,
{ 752 , {42.8 }} ,
{ 753 , {38.7 }} ,
{ 755 , {50. }} ,
{ 756 , {50. }} ,
{ 758 , {37.6 }} ,
{ 759 , {39.8 }} ,
{ 760 , {21.9 }}
};
int get_decision_tree_node_index(std::any scaler_output_2, std::any scaler_output_3, std::any scaler_output_4, std::any scaler_output_5, std::any scaler_output_6, std::any scaler_output_7, std::any scaler_output_8, std::any scaler_output_9, std::any scaler_output_10, std::any scaler_output_11, std::any scaler_output_12, std::any scaler_output_13, std::any scaler_output_14) {
int lNodeIndex = (scaler_output_7 <= 1.0075204372406006) ? ( (scaler_output_14 <= 0.3004233241081238) ? ( (scaler_output_7 <= 0.3439619392156601) ? ( (scaler_output_9 <= -1.2385239005088806) ? ( 4 ) : ( (scaler_output_14 <= -0.6789377927780151) ? ( (scaler_output_9 <= 0.3076174259185791) ? ( (scaler_output_6 <= -0.8356659114360809) ? ( 8 ) : ( (scaler_output_13 <= 0.18147635273635387) ? ( (scaler_output_8 <= 1.0121712684631348) ? ( (scaler_output_6 <= 0.909976989030838) ? ( 12 ) : ( 13 ) ) : ( 14 ) ) : ( (scaler_output_2 <= -0.3646405339241028) ? ( (scaler_output_13 <= 0.41463376581668854) ? ( (scaler_output_9 <= -0.09665841422975063) ? ( 18 ) : ( 19 ) ) : ( (scaler_output_10 <= -0.6941851377487183) ? ( 21 ) : ( 22 ) ) ) : ( 23 ) ) ) ) : ( (scaler_output_14 <= -0.6942838728427887) ? ( (scaler_output_12 <= 0.5726628303527832) ? ( (scaler_output_11 <= -0.8469608724117279) ? ( (scaler_output_7 <= -0.15459215641021729) ? ( 28 ) : ( (scaler_output_2 <= -0.41085946559906006) ? ( 30 ) : ( 31 ) ) ) : ( (scaler_output_7 <= 0.11380557715892792) ? ( (scaler_output_2 <= -0.41946254670619965) ? ( (scaler_output_2 <= -0.41964191198349) ? ( (scaler_output_11 <= -0.5701415985822678) ? ( 36 ) : ( (scaler_output_14 <= -0.9175001084804535) ? ( 38 ) : ( 39 ) ) ) : ( 40 ) ) : ( (scaler_output_3 <= 2.5999269485473633) ? ( (scaler_output_7 <= 0.020326681435108185) ? ( (scaler_output_14 <= -0.8344915807247162) ? ( (scaler_output_4 <= -0.2770143635571003) ? ( 45 ) : ( 46 ) ) : ( (scaler_output_10 <= -0.5223402976989746) ? ( 48 ) : ( 49 ) ) ) : ( (scaler_output_11 <= -0.6820472478866577) ? ( 51 ) : ( (scaler_output_11 <= -0.47296035289764404) ? ( 53 ) : ( (scaler_output_4 <= -1.209140419960022) ? ( 55 ) : ( 56 ) ) ) ) ) : ( 57 ) ) ) : ( (scaler_output_13 <= 0.39687255024909973) ? ( (scaler_output_2 <= -0.4178476631641388) ? ( 60 ) : ( (scaler_output_4 <= -0.45669247582554817) ? ( (scaler_output_8 <= -1.9461240768432617) ? ( 63 ) : ( 64 ) ) : ( 65 ) ) ) : ( (scaler_output_9 <= 0.3873691111803055) ? ( 67 ) : ( (scaler_output_2 <= -0.3940838724374771) ? ( (scaler_output_3 <= 1.7110437899827957) ? ( 70 ) : ( 71 ) ) : ( 72 ) ) ) ) ) ) : ( (scaler_output_2 <= -0.41865573823451996) ? ( 74 ) : ( (scaler_output_11 <= -0.6496535241603851) ? ( 76 ) : ( (scaler_output_14 <= -0.8854127824306488) ? ( 78 ) : ( 79 ) ) ) ) ) : ( 80 ) ) ) : ( (scaler_output_7 <= -0.3762504309415817) ? ( (scaler_output_7 <= -0.38333216309547424) ? ( (scaler_output_9 <= -1.1802685856819153) ? ( 84 ) : ( (scaler_output_13 <= 0.3210839778184891) ? ( (scaler_output_4 <= -0.092202577739954) ? ( (scaler_output_11 <= -0.590755820274353) ? ( (scaler_output_10 <= -0.4077770560979843) ? ( 89 ) : ( 90 ) ) : ( (scaler_output_12 <= -0.2580581158399582) ? ( 92 ) : ( (scaler_output_9 <= 2.6176934242248535) ? ( (scaler_output_13 <= 0.18473074957728386) ? ( 95 ) : ( 96 ) ) : ( 97 ) ) ) ) : ( (scaler_output_9 <= -1.0216012001037598) ? ( (scaler_output_14 <= 0.010242253541946411) ? ( (scaler_output_7 <= -1.2954595386981964) ? ( 101 ) : ( 102 ) ) : ( 103 ) ) : ( (scaler_output_14 <= 0.240433968603611) ? ( (scaler_output_13 <= -1.0899403095245361) ? ( 106 ) : ( (scaler_output_9 <= -0.9401536881923676) ? ( 108 ) : ( (scaler_output_9 <= 0.3276090957224369) ? ( (scaler_output_2 <= -0.27104148268699646) ? ( 111 ) : ( (scaler_output_2 <= -0.045648232102394104) ? ( 113 ) : ( 114 ) ) ) : ( 115 ) ) ) ) : ( (scaler_output_5 <= 1.6589429825544357) ? ( 117 ) : ( 118 ) ) ) ) ) : ( (scaler_output_12 <= -0.719569742679596) ? ( (scaler_output_9 <= 0.9906300902366638) ? ( (scaler_output_6 <= -0.6831340342760086) ? ( 122 ) : ( (scaler_output_8 <= -0.3006501570343971) ? ( (scaler_output_11 <= -0.7056063413619995) ? ( 125 ) : ( 126 ) ) : ( (scaler_output_13 <= 0.40790435671806335) ? ( (scaler_output_13 <= 0.3798835575580597) ? ( 129 ) : ( (scaler_output_2 <= -0.27875275909900665) ? ( 131 ) : ( 132 ) ) ) : ( (scaler_output_8 <= 0.3450871892273426) ? ( 134 ) : ( 135 ) ) ) ) ) : ( (scaler_output_14 <= -0.5282668322324753) ? ( 137 ) : ( (scaler_output_9 <= 1.9566787481307983) ? ( (scaler_output_3 <= 1.411304123699665) ? ( 140 ) : ( 141 ) ) : ( 142 ) ) ) ) : ( (scaler_output_7 <= -0.7756602466106415) ? ( (scaler_output_10 <= -0.5796219110488892) ? ( (scaler_output_14 <= -0.17251601815223694) ? ( (scaler_output_9 <= 0.3002847502939403) ? ( 147 ) : ( 148 ) ) : ( (scaler_output_14 <= -0.09229769464582205) ? ( 150 ) : ( (scaler_output_3 <= 0.48107755929231644) ? ( 152 ) : ( 153 ) ) ) ) : ( (scaler_output_6 <= -0.2890932597219944) ? ( (scaler_output_10 <= -0.35049544274806976) ? ( 156 ) : ( 157 ) ) : ( (scaler_output_7 <= -0.8174424767494202) ? ( 159 ) : ( 160 ) ) ) ) : ( (scaler_output_8 <= -0.804076224565506) ? ( (scaler_output_7 <= -0.5823289155960083) ? ( (scaler_output_12 <= 0.01884886436164379) ? ( (scaler_output_3 <= 0.739473819732666) ? ( 165 ) : ( 166 ) ) : ( (scaler_output_8 <= -1.4462558031082153) ? ( 168 ) : ( (scaler_output_4 <= 0.657311886548996) ? ( (scaler_output_11 <= -0.2020308431237936) ? ( (scaler_output_11 <= -0.9117483496665955) ? ( 172 ) : ( (scaler_output_2 <= -0.4111506789922714) ? ( 174 ) : ( 175 ) ) ) : ( 176 ) ) : ( 177 ) ) ) ) : ( (scaler_output_2 <= -0.4047030657529831) ? ( (scaler_output_14 <= -0.10624870285391808) ? ( 180 ) : ( 181 ) ) : ( (scaler_output_8 <= -1.1189399063587189) ? ( 183 ) : ( 184 ) ) ) ) : ( (scaler_output_7 <= -0.3882893770933151) ? ( (scaler_output_13 <= 0.3701755404472351) ? ( (scaler_output_9 <= -0.532557874917984) ? ( 188 ) : ( (scaler_output_10 <= 0.45144718885421753) ? ( 190 ) : ( 191 ) ) ) : ( (scaler_output_9 <= -0.5931060910224915) ? ( (scaler_output_12 <= 0.572662815451622) ? ( 194 ) : ( 195 ) ) : ( (scaler_output_2 <= -0.38556015491485596) ? ( (scaler_output_6 <= 0.10071049258112907) ? ( (scaler_output_2 <= -0.4201262444257736) ? ( 199 ) : ( (scaler_output_7 <= -0.4980562776327133) ? ( (scaler_output_6 <= -0.5941570848226547) ? ( 202 ) : ( 203 ) ) : ( (scaler_output_9 <= 0.001556307077407837) ? ( (scaler_output_9 <= -0.49161913990974426) ? ( 206 ) : ( 207 ) ) : ( (scaler_output_14 <= -0.4340974986553192) ? ( 209 ) : ( 210 ) ) ) ) ) : ( 211 ) ) : ( (scaler_output_13 <= 0.41424764692783356) ? ( (scaler_output_9 <= 0.20808903872966766) ? ( 214 ) : ( 215 ) ) : ( (scaler_output_11 <= -0.590755820274353) ? ( 217 ) : ( 218 ) ) ) ) ) ) : ( 219 ) ) ) ) ) ) ) : ( 220 ) ) : ( (scaler_output_8 <= 0.04801243916153908) ? ( (scaler_output_8 <= -0.014248738065361977) ? ( (scaler_output_7 <= 0.2476503551006317) ? ( (scaler_output_2 <= -0.4089321196079254) ? ( (scaler_output_7 <= -0.005875736474990845) ? ( (scaler_output_9 <= 0.04739142954349518) ? ( (scaler_output_6 <= -0.5899200737476349) ? ( 228 ) : ( 229 ) ) : ( (scaler_output_3 <= -0.06672252714633942) ? ( (scaler_output_2 <= -0.41519850492477417) ? ( (scaler_output_7 <= -0.23319940268993378) ? ( 233 ) : ( 234 ) ) : ( 235 ) ) : ( (scaler_output_3 <= 0.553428515791893) ? ( 237 ) : ( 238 ) ) ) ) : ( (scaler_output_13 <= 0.4145234525203705) ? ( (scaler_output_12 <= -0.558040663599968) ? ( (scaler_output_13 <= 0.2797146663069725) ? ( 242 ) : ( 243 ) ) : ( (scaler_output_12 <= -0.1888313628733158) ? ( 245 ) : ( 246 ) ) ) : ( 247 ) ) ) : ( (scaler_output_6 <= -0.13656136393547058) ? ( (scaler_output_12 <= 0.43420933187007904) ? ( (scaler_output_2 <= -0.3891623765230179) ? ( (scaler_output_14 <= -0.4368877112865448) ? ( 252 ) : ( (scaler_output_12 <= 0.20345351099967957) ? ( 254 ) : ( 255 ) ) ) : ( (scaler_output_4 <= -0.7265763580799103) ? ( 257 ) : ( 258 ) ) ) : ( (scaler_output_7 <= -0.19354168698191643) ? ( 260 ) : ( 261 ) ) ) : ( (scaler_output_14 <= 0.048607539385557175) ? ( (scaler_output_14 <= -0.13554582744836807) ? ( 264 ) : ( 265 ) ) : ( 266 ) ) ) ) : ( 267 ) ) : ( 268 ) ) : ( (scaler_output_13 <= -1.356965385377407) ? ( 270 ) : ( (scaler_output_12 <= -0.558040663599968) ? ( (scaler_output_4 <= 0.8435904085636139) ? ( (scaler_output_8 <= 0.7257698178291321) ? ( 274 ) : ( 275 ) ) : ( 276 ) ) : ( (scaler_output_6 <= 1.5878965854644775) ? ( (scaler_output_8 <= 0.47138842940330505) ? ( (scaler_output_12 <= -0.14268020167946815) ? ( (scaler_output_14 <= -0.551983579993248) ? ( 281 ) : ( (scaler_output_14 <= -0.33295266330242157) ? ( 283 ) : ( (scaler_output_9 <= -0.3378242701292038) ? ( 285 ) : ( 286 ) ) ) ) : ( (scaler_output_11 <= -0.24620412848889828) ? ( (scaler_output_2 <= -0.40905459225177765) ? ( 289 ) : ( 290 ) ) : ( 291 ) ) ) : ( (scaler_output_13 <= 0.324724480509758) ? ( (scaler_output_4 <= -0.38628798723220825) ? ( 294 ) : ( (scaler_output_12 <= 1.2187790870666504) ? ( (scaler_output_11 <= 0.7020491883158684) ? ( 297 ) : ( 298 ) ) : ( 299 ) ) ) : ( (scaler_output_13 <= 0.37155452370643616) ? ( (scaler_output_2 <= -0.14505870081484318) ? ( (scaler_output_9 <= -0.22176752984523773) ? ( 303 ) : ( 304 ) ) : ( 305 ) ) : ( (scaler_output_13 <= 0.39455586671829224) ? ( (scaler_output_10 <= 0.5660104155540466) ? ( 308 ) : ( 309 ) ) : ( (scaler_output_13 <= 0.40553252398967743) ? ( (scaler_output_10 <= -0.5796219110488892) ? ( 312 ) : ( 313 ) ) : ( (scaler_output_2 <= 0.41677238047122955) ? ( (scaler_output_11 <= 0.027670271694660187) ? ( 316 ) : ( (scaler_output_6 <= 0.9692949652671814) ? ( 318 ) : ( 319 ) ) ) : ( 320 ) ) ) ) ) ) ) : ( (scaler_output_7 <= -0.054031528532505035) ? ( (scaler_output_7 <= -0.2544446140527725) ? ( 323 ) : ( 324 ) ) : ( 325 ) ) ) ) ) ) ) ) ) : ( (scaler_output_9 <= -1.020430862903595) ? ( 327 ) : ( (scaler_output_14 <= -1.006089061498642) ? ( (scaler_output_7 <= 0.6966322958469391) ? ( (scaler_output_6 <= -0.25519728660583496) ? ( (scaler_output_14 <= -1.1156044602394104) ? ( (scaler_output_6 <= -0.9500648677349091) ? ( (scaler_output_11 <= -0.867575079202652) ? ( (scaler_output_9 <= 2.36171892285347) ? ( 335 ) : ( 336 ) ) : ( (scaler_output_7 <= 0.3977831155061722) ? ( 338 ) : ( 339 ) ) ) : ( 340 ) ) : ( (scaler_output_14 <= -1.020737648010254) ? ( (scaler_output_4 <= -0.7412439584732056) ? ( (scaler_output_4 <= -0.8915868699550629) ? ( 344 ) : ( 345 ) ) : ( 346 ) ) : ( 347 ) ) ) : ( (scaler_output_12 <= -0.7195697580464184) ? ( 349 ) : ( 350 ) ) ) : ( (scaler_output_4 <= -1.0815322995185852) ? ( (scaler_output_14 <= -1.1679207682609558) ? ( (scaler_output_13 <= 0.39036378264427185) ? ( 354 ) : ( 355 ) ) : ( (scaler_output_13 <= 0.2931734770536423) ? ( 357 ) : ( (scaler_output_8 <= -1.1794221997261047) ? ( (scaler_output_8 <= -1.5689992308616638) ? ( 360 ) : ( 361 ) ) : ( 362 ) ) ) ) : ( (scaler_output_12 <= -0.027302294969558716) ? ( (scaler_output_8 <= -1.4231302738189697) ? ( 365 ) : ( (scaler_output_7 <= 0.80002561211586) ? ( 367 ) : ( 368 ) ) ) : ( (scaler_output_3 <= 1.6076852828264236) ? ( 370 ) : ( 371 ) ) ) ) ) : ( (scaler_output_12 <= 1.1726279258728027) ? ( (scaler_output_9 <= 0.07091805757954717) ? ( (scaler_output_4 <= -0.5285637378692627) ? ( (scaler_output_7 <= 0.8078155219554901) ? ( (scaler_output_12 <= -0.23498252034187317) ? ( (scaler_output_4 <= -1.0675981044769287) ? ( (scaler_output_6 <= -0.7763479650020599) ? ( 379 ) : ( 380 ) ) : ( (scaler_output_5 <= 1.6589429825544357) ? ( (scaler_output_8 <= 0.34686607867479324) ? ( 383 ) : ( (scaler_output_10 <= -0.35049544274806976) ? ( 385 ) : ( 386 ) ) ) : ( 387 ) ) ) : ( (scaler_output_8 <= -0.12987663224339485) ? ( 389 ) : ( 390 ) ) ) : ( (scaler_output_4 <= -0.9062544703483582) ? ( 392 ) : ( (scaler_output_2 <= -0.362820029258728) ? ( 394 ) : ( 395 ) ) ) ) : ( (scaler_output_6 <= -0.047584418207407) ? ( (scaler_output_7 <= 0.6605154573917389) ? ( (scaler_output_12 <= -0.14268019841983914) ? ( 399 ) : ( (scaler_output_6 <= -0.13656136393547058) ? ( 401 ) : ( 402 ) ) ) : ( 403 ) ) : ( (scaler_output_8 <= 0.30239380383864045) ? ( 405 ) : ( 406 ) ) ) ) : ( (scaler_output_10 <= -0.5796219110488892) ? ( (scaler_output_8 <= -1.2470200061798096) ? ( 409 ) : ( (scaler_output_7 <= 0.4112384021282196) ? ( 411 ) : ( 412 ) ) ) : ( (scaler_output_9 <= 1.4363462328910828) ? ( (scaler_output_12 <= -0.6503430008888245) ? ( 415 ) : ( (scaler_output_2 <= -0.3900454342365265) ? ( 417 ) : ( 418 ) ) ) : ( (scaler_output_4 <= -0.7911137938499451) ? ( (scaler_output_9 <= 1.9511613845825195) ? ( (scaler_output_8 <= -1.163412183523178) ? ( 422 ) : ( 423 ) ) : ( 424 ) ) : ( 425 ) ) ) ) ) : ( (scaler_output_2 <= -0.4164571613073349) ? ( 427 ) : ( (scaler_output_11 <= -0.6820472776889801) ? ( (scaler_output_14 <= -0.6349920928478241) ? ( 430 ) : ( 431 ) ) : ( 432 ) ) ) ) ) ) ) : ( (scaler_output_6 <= 0.4142483025789261) ? ( (scaler_output_2 <= -0.3549475222826004) ? ( (scaler_output_8 <= 0.19388148188591003) ? ( (scaler_output_13 <= 0.4050360918045044) ? ( (scaler_output_14 <= 0.45248936116695404) ? ( (scaler_output_10 <= -0.46505868434906006) ? ( 439 ) : ( 440 ) ) : ( (scaler_output_9 <= -0.09544028341770172) ? ( (scaler_output_2 <= -0.39488694071769714) ? ( 443 ) : ( 444 ) ) : ( (scaler_output_5 <= 1.6589429825544357) ? ( 446 ) : ( 447 ) ) ) ) : ( (scaler_output_11 <= -0.11368428170681) ? ( (scaler_output_11 <= -0.8086773455142975) ? ( 450 ) : ( 451 ) ) : ( 452 ) ) ) : ( (scaler_output_2 <= -0.4057367295026779) ? ( (scaler_output_2 <= -0.40684664249420166) ? ( (scaler_output_13 <= 0.2245555892586708) ? ( 456 ) : ( (scaler_output_12 <= 0.7341918796300888) ? ( 458 ) : ( 459 ) ) ) : ( 460 ) ) : ( (scaler_output_5 <= 1.6589429825544357) ? ( (scaler_output_14 <= 0.8284691572189331) ? ( (scaler_output_4 <= -0.15087298303842545) ? ( (scaler_output_4 <= -0.17434114962816238) ? ( 465 ) : ( 466 ) ) : ( (scaler_output_9 <= -0.6278347373008728) ? ( 468 ) : ( 469 ) ) ) : ( (scaler_output_8 <= 1.0121712684631348) ? ( (scaler_output_9 <= 0.93622025847435) ? ( (scaler_output_4 <= 0.7768527567386627) ? ( 473 ) : ( 474 ) ) : ( (scaler_output_2 <= -0.39424824714660645) ? ( 476 ) : ( 477 ) ) ) : ( (scaler_output_4 <= 0.8472572416067123) ? ( 479 ) : ( 480 ) ) ) ) : ( (scaler_output_7 <= -0.8740963339805603) ? ( (scaler_output_9 <= -0.023809462785720825) ? ( 483 ) : ( 484 ) ) : ( 485 ) ) ) ) ) : ( (scaler_output_7 <= 0.6449356377124786) ? ( (scaler_output_8 <= 0.10493694245815277) ? ( (scaler_output_7 <= -0.8471857905387878) ? ( 489 ) : ( 490 ) ) : ( (scaler_output_8 <= 0.5300918221473694) ? ( 492 ) : ( (scaler_output_14 <= 1.1849175095558167) ? ( (scaler_output_13 <= 0.2023816481232643) ? ( (scaler_output_7 <= -1.4278879761695862) ? ( 496 ) : ( (scaler_output_2 <= 0.6099968552589417) ? ( (scaler_output_7 <= -0.9194194674491882) ? ( (scaler_output_14 <= 0.970071941614151) ? ( (scaler_output_11 <= 0.47529295086860657) ? ( 501 ) : ( 502 ) ) : ( 503 ) ) : ( (scaler_output_2 <= -0.2513979971408844) ? ( 505 ) : ( 506 ) ) ) : ( 507 ) ) ) : ( (scaler_output_9 <= 0.34440018236637115) ? ( (scaler_output_7 <= -0.37695861607789993) ? ( 510 ) : ( 511 ) ) : ( 512 ) ) ) : ( (scaler_output_7 <= -0.3068494498729706) ? ( (scaler_output_14 <= 1.567175269126892) ? ( 515 ) : ( (scaler_output_2 <= 1.2141359150409698) ? ( 517 ) : ( 518 ) ) ) : ( (scaler_output_6 <= 0.30832336843013763) ? ( 520 ) : ( 521 ) ) ) ) ) ) : ( 522 ) ) ) : ( (scaler_output_2 <= 0.8094890117645264) ? ( (scaler_output_14 <= 0.8731123805046082) ? ( (scaler_output_14 <= 0.8521858751773834) ? ( (scaler_output_2 <= 0.32292649149894714) ? ( (scaler_output_14 <= 0.6798908710479736) ? ( (scaler_output_7 <= -0.8932170569896698) ? ( (scaler_output_8 <= 1.0370757281780243) ? ( 530 ) : ( 531 ) ) : ( (scaler_output_8 <= 0.562111884355545) ? ( 533 ) : ( (scaler_output_14 <= 0.6394329369068146) ? ( (scaler_output_13 <= -0.42229484021663666) ? ( (scaler_output_13 <= -2.387281656265259) ? ( 537 ) : ( 538 ) ) : ( (scaler_output_8 <= 0.9961612522602081) ? ( 540 ) : ( (scaler_output_6 <= 1.0836938619613647) ? ( (scaler_output_2 <= -0.3689720630645752) ? ( 543 ) : ( 544 ) ) : ( 545 ) ) ) ) : ( 546 ) ) ) ) : ( (scaler_output_13 <= 0.4111587405204773) ? ( (scaler_output_14 <= 0.7587140798568726) ? ( 549 ) : ( (scaler_output_8 <= 0.8823122382164001) ? ( 551 ) : ( 552 ) ) ) : ( 553 ) ) ) : ( (scaler_output_5 <= 1.6589429825544357) ? ( (scaler_output_13 <= -3.897426962852478) ? ( (scaler_output_2 <= 0.5081534683704376) ? ( 557 ) : ( 558 ) ) : ( (scaler_output_9 <= -0.9648029208183289) ? ( 560 ) : ( (scaler_output_13 <= 0.411324217915535) ? ( (scaler_output_9 <= -0.9168420433998108) ? ( 563 ) : ( (scaler_output_13 <= -0.023825719952583313) ? ( (scaler_output_7 <= 0.030949282343499362) ? ( 566 ) : ( 567 ) ) : ( 568 ) ) ) : ( 569 ) ) ) ) : ( 570 ) ) ) : ( 571 ) ) : ( (scaler_output_6 <= 1.4607866406440735) ? ( (scaler_output_12 <= 0.8034186363220215) ? ( 574 ) : ( (scaler_output_6 <= 1.0243759155273438) ? ( (scaler_output_14 <= 1.410923957824707) ? ( 577 ) : ( (scaler_output_2 <= -0.3042064309120178) ? ( 579 ) : ( 580 ) ) ) : ( (scaler_output_14 <= 0.9791401028633118) ? ( (scaler_output_2 <= 0.4131457805633545) ? ( (scaler_output_13 <= -1.7065084874629974) ? ( 584 ) : ( 585 ) ) : ( 586 ) ) : ( (scaler_output_8 <= 1.1242413520812988) ? ( (scaler_output_2 <= 0.5157047659158707) ? ( 589 ) : ( (scaler_output_7 <= -0.33376002684235573) ? ( 591 ) : ( 592 ) ) ) : ( (scaler_output_14 <= 1.597867488861084) ? ( (scaler_output_9 <= -1.0557804703712463) ? ( 595 ) : ( 596 ) ) : ( 597 ) ) ) ) ) ) : ( (scaler_output_13 <= 0.3359769284725189) ? ( (scaler_output_9 <= -1.0949755907058716) ? ( (scaler_output_9 <= -1.121368408203125) ? ( 601 ) : ( 602 ) ) : ( (scaler_output_13 <= 0.14446462178602815) ? ( 604 ) : ( 605 ) ) ) : ( (scaler_output_7 <= -1.9611425995826721) ? ( 607 ) : ( (scaler_output_10 <= 0.5660104155540466) ? ( (scaler_output_9 <= -1.1718611121177673) ? ( 610 ) : ( (scaler_output_14 <= 2.1412594318389893) ? ( 612 ) : ( 613 ) ) ) : ( 614 ) ) ) ) ) ) : ( (scaler_output_14 <= 0.755226343870163) ? ( (scaler_output_8 <= 1.024623453617096) ? ( (scaler_output_2 <= 6.005936026573181) ? ( (scaler_output_13 <= -1.255472645163536) ? ( 619 ) : ( (scaler_output_13 <= 0.37872521579265594) ? ( 621 ) : ( 622 ) ) ) : ( 623 ) ) : ( (scaler_output_9 <= -0.8623127937316895) ? ( 625 ) : ( 626 ) ) ) : ( (scaler_output_6 <= 1.0243759155273438) ? ( (scaler_output_14 <= 1.3788366317749023) ? ( 629 ) : ( (scaler_output_9 <= -1.172434389591217) ? ( (scaler_output_13 <= 0.23806956969201565) ? ( 632 ) : ( 633 ) ) : ( 634 ) ) ) : ( (scaler_output_6 <= 1.2065668106079102) ? ( (scaler_output_6 <= 1.1175898313522339) ? ( (scaler_output_8 <= 0.7862521111965179) ? ( 638 ) : ( (scaler_output_2 <= 1.2441092729568481) ? ( 640 ) : ( 641 ) ) ) : ( (scaler_output_9 <= -1.1259065866470337) ? ( 643 ) : ( (scaler_output_14 <= 1.5232295989990234) ? ( 645 ) : ( (scaler_output_9 <= -1.0491883158683777) ? ( (scaler_output_13 <= 0.10094410926103592) ? ( 648 ) : ( 649 ) ) : ( 650 ) ) ) ) ) : ( (scaler_output_2 <= 0.9968658089637756) ? ( (scaler_output_8 <= 0.9552467167377472) ? ( 653 ) : ( 654 ) ) : ( (scaler_output_8 <= 0.8680810630321503) ? ( (scaler_output_13 <= -0.18770334124565125) ? ( (scaler_output_2 <= 1.6858564019203186) ? ( 658 ) : ( 659 ) ) : ( 660 ) ) : ( (scaler_output_13 <= -3.7505383491516113) ? ( 662 ) : ( (scaler_output_7 <= -0.20062343031167984) ? ( (scaler_output_2 <= 1.0994766354560852) ? ( 665 ) : ( (scaler_output_8 <= 1.0833268761634827) ? ( 667 ) : ( (scaler_output_14 <= 2.347036838531494) ? ( 669 ) : ( 670 ) ) ) ) : ( 671 ) ) ) ) ) ) ) ) ) ) ) : ( (scaler_output_7 <= 1.611592411994934) ? ( (scaler_output_10 <= 0.7378552705049515) ? ( (scaler_output_11 <= -0.8705199658870697) ? ( (scaler_output_2 <= -0.4145510643720627) ? ( (scaler_output_2 <= -0.41516414284706116) ? ( (scaler_output_14 <= -1.0542200207710266) ? ( (scaler_output_13 <= 0.41253772377967834) ? ( (scaler_output_2 <= -0.42036372423171997) ? ( 680 ) : ( 681 ) ) : ( 682 ) ) : ( (scaler_output_7 <= 1.2638792395591736) ? ( 684 ) : ( 685 ) ) ) : ( 686 ) ) : ( (scaler_output_9 <= 0.042423367500305176) ? ( 688 ) : ( 689 ) ) ) : ( (scaler_output_7 <= 1.1640267968177795) ? ( (scaler_output_3 <= 3.0133609771728516) ? ( (scaler_output_9 <= 1.7906787395477295) ? ( (scaler_output_2 <= -0.3721499443054199) ? ( 694 ) : ( 695 ) ) : ( 696 ) ) : ( 697 ) ) : ( (scaler_output_9 <= -0.8756883442401886) ? ( 699 ) : ( (scaler_output_7 <= 1.4274672865867615) ? ( (scaler_output_14 <= -0.9168025553226471) ? ( (scaler_output_2 <= -0.4205505847930908) ? ( (scaler_output_12 <= -0.9964767396450043) ? ( 704 ) : ( 705 ) ) : ( 706 ) ) : ( (scaler_output_10 <= -0.6941851377487183) ? ( 708 ) : ( 709 ) ) ) : ( (scaler_output_7 <= 1.477747619152069) ? ( 711 ) : ( (scaler_output_2 <= -0.3632487654685974) ? ( 713 ) : ( 714 ) ) ) ) ) ) ) : ( (scaler_output_2 <= 0.44946736097335815) ? ( 716 ) : ( (scaler_output_7 <= 1.492619276046753) ? ( 718 ) : ( 719 ) ) ) ) : ( (scaler_output_12 <= 0.572662815451622) ? ( (scaler_output_12 <= -1.6656686067581177) ? ( (scaler_output_7 <= 2.04428631067276) ? ( (scaler_output_3 <= -0.08739423751831055) ? ( 724 ) : ( (scaler_output_13 <= 0.3801593482494354) ? ( (scaler_output_13 <= 0.3414928466081619) ? ( 727 ) : ( 728 ) ) : ( 729 ) ) ) : ( (scaler_output_7 <= 2.956413745880127) ? ( 731 ) : ( (scaler_output_2 <= -0.3534438908100128) ? ( 733 ) : ( 734 ) ) ) ) : ( (scaler_output_8 <= 0.5443229377269745) ? ( (scaler_output_14 <= -1.1574575304985046) ? ( (scaler_output_14 <= -1.1790816187858582) ? ( (scaler_output_2 <= -0.3814048618078232) ? ( (scaler_output_13 <= 0.2526315748691559) ? ( (scaler_output_6 <= -0.6835577189922333) ? ( 741 ) : ( 742 ) ) : ( (scaler_output_10 <= -0.6369035243988037) ? ( (scaler_output_7 <= 1.8948617577552795) ? ( 745 ) : ( 746 ) ) : ( (scaler_output_3 <= -0.08739423751831055) ? ( 748 ) : ( 749 ) ) ) ) : ( (scaler_output_13 <= 0.36432869732379913) ? ( 751 ) : ( 752 ) ) ) : ( 753 ) ) : ( (scaler_output_9 <= -0.3692806661128998) ? ( 755 ) : ( 756 ) ) ) : ( (scaler_output_13 <= 0.3650457561016083) ? ( 758 ) : ( 759 ) ) ) ) : ( 760 ) ) );
return lNodeIndex;
}
std::vector<std::string> get_input_names(){
std::vector<std::string> lFeatures = { "scaler_output_2", "scaler_output_3", "scaler_output_4", "scaler_output_5", "scaler_output_6", "scaler_output_7", "scaler_output_8", "scaler_output_9", "scaler_output_10", "scaler_output_11", "scaler_output_12", "scaler_output_13", "scaler_output_14" };
return lFeatures;
}
std::vector<std::string> get_output_names(){
std::vector<std::string> lOutputs = { "Estimator" };
return lOutputs;
}
tTable compute_regression(std::any scaler_output_2, std::any scaler_output_3, std::any scaler_output_4, std::any scaler_output_5, std::any scaler_output_6, std::any scaler_output_7, std::any scaler_output_8, std::any scaler_output_9, std::any scaler_output_10, std::any scaler_output_11, std::any scaler_output_12, std::any scaler_output_13, std::any scaler_output_14) {
int lNodeIndex = get_decision_tree_node_index(scaler_output_2, scaler_output_3, scaler_output_4, scaler_output_5, scaler_output_6, scaler_output_7, scaler_output_8, scaler_output_9, scaler_output_10, scaler_output_11, scaler_output_12, scaler_output_13, scaler_output_14);
std::vector<double> lNodeValue = Decision_Tree_Node_data[ lNodeIndex ];
tTable lTable;
std::any lEstimator = lNodeValue [ 0 ];
lTable[ "Estimator" ] = { lEstimator };
return lTable;
}
tTable compute_model_outputs_from_table( tTable const & iTable) {
tTable lTable = compute_regression(iTable.at("scaler_output_2")[0], iTable.at("scaler_output_3")[0], iTable.at("scaler_output_4")[0], iTable.at("scaler_output_5")[0], iTable.at("scaler_output_6")[0], iTable.at("scaler_output_7")[0], iTable.at("scaler_output_8")[0], iTable.at("scaler_output_9")[0], iTable.at("scaler_output_10")[0], iTable.at("scaler_output_11")[0], iTable.at("scaler_output_12")[0], iTable.at("scaler_output_13")[0], iTable.at("scaler_output_14")[0]);
return lTable;
}
} // eof namespace model
std::vector<std::string> get_input_names(){
std::vector<std::string> lFeatures = { "Feature_0", "Feature_1", "Feature_2", "Feature_3", "Feature_4", "Feature_5", "Feature_6", "Feature_7", "Feature_8", "Feature_9", "Feature_10", "Feature_11", "Feature_12" };
return lFeatures;
}
std::vector<std::string> get_output_names(){
std::vector<std::string> lOutputs = { "Estimator" };
return lOutputs;
}
tTable compute_regression(std::any Feature_0, std::any Feature_1, std::any Feature_2, std::any Feature_3, std::any Feature_4, std::any Feature_5, std::any Feature_6, std::any Feature_7, std::any Feature_8, std::any Feature_9, std::any Feature_10, std::any Feature_11, std::any Feature_12) {
tTable lTable_imputer = imputer::compute_features(Feature_0, Feature_1, Feature_2, Feature_3, Feature_4, Feature_5, Feature_6, Feature_7, Feature_8, Feature_9, Feature_10, Feature_11, Feature_12);
tTable lTable_scaler = scaler::compute_model_outputs_from_table( lTable_imputer );
tTable lTable_model = model::compute_model_outputs_from_table( lTable_scaler );
tTable lTable;
std::any lEstimator = lTable_model[ "Estimator" ][0];
lTable[ "Estimator" ] = { lEstimator };
return lTable;
}
tTable compute_model_outputs_from_table( tTable const & iTable) {
tTable lTable = compute_regression(iTable.at("Feature_0")[0], iTable.at("Feature_1")[0], iTable.at("Feature_2")[0], iTable.at("Feature_3")[0], iTable.at("Feature_4")[0], iTable.at("Feature_5")[0], iTable.at("Feature_6")[0], iTable.at("Feature_7")[0], iTable.at("Feature_8")[0], iTable.at("Feature_9")[0], iTable.at("Feature_10")[0], iTable.at("Feature_11")[0], iTable.at("Feature_12")[0]);
return lTable;
}
} // eof namespace
int main() {
score_csv_file("outputs/ml2cpp-demo/datasets/boston.csv");
return 0;
}
| 71.884483 | 21,664 | 0.560766 | [
"vector",
"model"
] |
bd081497bd7dd8e62f488f544651c16e730997a5 | 4,347 | cpp | C++ | src/mousemanager.cpp | dnnr/herbstluftwm | 3bed77ed53c11d0f07d591feb0ef29bb4e741b51 | [
"BSD-2-Clause-FreeBSD"
] | 1 | 2018-12-02T16:51:04.000Z | 2018-12-02T16:51:04.000Z | src/mousemanager.cpp | dnnr/herbstluftwm | 3bed77ed53c11d0f07d591feb0ef29bb4e741b51 | [
"BSD-2-Clause-FreeBSD"
] | 8 | 2019-03-03T21:12:40.000Z | 2019-05-05T13:30:19.000Z | src/mousemanager.cpp | dnnr/herbstluftwm | 3bed77ed53c11d0f07d591feb0ef29bb4e741b51 | [
"BSD-2-Clause-FreeBSD"
] | null | null | null | #include "mousemanager.h"
#include <X11/Xlib.h>
#include <X11/cursorfont.h>
#include <initializer_list>
#include <ostream>
#include <set>
#include <stdexcept>
#include <string>
#include <vector>
#include "client.h"
#include "completion.h"
#include "globals.h"
#include "ipc-protocol.h"
#include "keycombo.h"
#include "mouse.h"
#include "utils.h"
using std::vector;
using std::string;
using std::endl;
MouseManager::MouseManager() {
/* set cursor theme */
cursor = XCreateFontCursor(g_display, XC_left_ptr);
XDefineCursor(g_display, g_root, cursor);
}
MouseManager::~MouseManager() {
XFreeCursor(g_display, cursor);
}
int MouseManager::addMouseBindCommand(Input input, Output output) {
if (input.size() < 2) {
return HERBST_NEED_MORE_ARGS;
}
auto mouseComboStr = input.front();
auto tokens = KeyCombo::tokensFromString(mouseComboStr);
unsigned int modifiers = 0;
try {
auto modifierSlice = vector<string>({tokens.begin(), tokens.end() - 1});
modifiers = KeyCombo::modifierMaskFromTokens(modifierSlice);
} catch (std::runtime_error &error) {
output << input.command() << ": " << error.what() << endl;
return HERBST_INVALID_ARGUMENT;
}
// Last token is the mouse button
auto buttonStr = tokens.back();
unsigned int button = string2button(buttonStr.c_str());
if (button == 0) {
output << input.command() << ": Unknown mouse button \"" << buttonStr << "\"" << endl;
return HERBST_INVALID_ARGUMENT;
}
input.shift();
auto action = string2mousefunction(input.front().c_str());
if (!action) {
output << input.command() << ": Unknown mouse action \"" << input.front() << "\"" << endl;
return HERBST_INVALID_ARGUMENT;
}
input.shift();
// Use remaining input as the associated command
vector<string> cmd = {input.begin(), input.end()};
if (action == mouse_call_command && cmd.empty()) {
return HERBST_NEED_MORE_ARGS;
}
// Actually create the mouse binding
MouseBinding mb;
mb.button = button;
mb.modifiers = modifiers;
mb.action = action;
mb.cmd = cmd;
binds.push_front(mb);
Client* client = get_current_client();
if (client) {
grab_client_buttons(client, true);
}
return HERBST_EXIT_SUCCESS;
}
void MouseManager::addMouseBindCompletion(Completion &complete) {
if (complete == 0) {
auto needle = complete.needle();
// Use the first separator char that appears in the needle as default:
const string seps = KeyCombo::separators;
string sep = {seps.front()};
for (auto& needleChar : needle) {
if (seps.find(needleChar) != string::npos) {
sep = needleChar;
break;
}
}
// Normalize needle by chopping off tokens until they all are valid
// modifiers:
auto tokens = KeyCombo::tokensFromString(needle);
while (tokens.size() > 0) {
try {
KeyCombo::modifierMaskFromTokens(tokens);
break;
} catch (std::runtime_error &error) {
tokens.pop_back();
}
}
auto normNeedle = join_strings(tokens, sep);
normNeedle += tokens.empty() ? "" : sep;
auto modifiersInNeedle = std::set<string>(tokens.begin(), tokens.end());
// Offer partial completions for an additional modifier (excluding the
// ones already mentioned in the needle):
for (auto& modifier : KeyCombo::modifierMasks) {
if (modifiersInNeedle.count(modifier.name) == 0) {
complete.partial(normNeedle + modifier.name + sep);
}
}
// Offer full completions for a mouse button:
auto buttons = {
"Button1",
"Button2",
"Button3",
"Button4",
"Button5",
"B1",
"B2",
"B3",
"B4",
"B5",
};
for (auto button : buttons) {
complete.full(normNeedle + button);
}
} else if (complete == 1) {
complete.full({"move", "resize", "zoom", "call"});
} else if (complete[1] == "call") {
complete.completeCommands(2);
} else {
complete.none();
}
}
| 28.788079 | 98 | 0.584311 | [
"vector"
] |
bd0ad25c8ca4d9231beb2129c6315d6cdcc7772a | 740,527 | cpp | C++ | test/bidi_character_test_101.cpp | eightysquirrels/text | d935545648777786dc196a75346cde8906da846a | [
"BSL-1.0"
] | null | null | null | test/bidi_character_test_101.cpp | eightysquirrels/text | d935545648777786dc196a75346cde8906da846a | [
"BSL-1.0"
] | 1 | 2021-03-05T12:56:59.000Z | 2021-03-05T13:11:53.000Z | test/bidi_character_test_101.cpp | eightysquirrels/text | d935545648777786dc196a75346cde8906da846a | [
"BSL-1.0"
] | 3 | 2019-10-30T18:38:15.000Z | 2021-03-05T12:10:13.000Z | // Warning! This file is autogenerated.
#include <boost/text/bidirectional.hpp>
#include "bidi_tests.hpp"
#include <gtest/gtest.h>
#include <algorithm>
TEST(bidi_character, bidi_character_101_000)
{
{
// line 70701
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x0028, 0x0029, 0x0028, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70702
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x05D1, 0x0062, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70703
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x05D1, 0x0062, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70704
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0062, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70705
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0062, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70706
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0028, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70707
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0028, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70708
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0028, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70709
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0028, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70710
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x0029, 0x05D1, 0x0062, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_001)
{
{
// line 70711
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x0029, 0x05D1, 0x0062, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70712
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x0029, 0x05D1, 0x0028, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70713
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x0029, 0x05D1, 0x0028, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70714
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x0029, 0x05D1, 0x0028, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70715
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x0029, 0x05D1, 0x0028, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70716
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x0029, 0x0028, 0x05D1, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 0, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70717
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x0029, 0x0028, 0x05D1, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70718
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x0029, 0x0028, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 0, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70719
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x0029, 0x0028, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70720
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0061, 0x05D1, 0x0062, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_002)
{
{
// line 70721
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0061, 0x05D1, 0x0062, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70722
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0061, 0x05D1, 0x0028, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70723
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0061, 0x05D1, 0x0028, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70724
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0061, 0x05D1, 0x0028, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70725
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0061, 0x05D1, 0x0028, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70726
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0061, 0x0028, 0x05D1, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 0, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70727
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0061, 0x0028, 0x05D1, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70728
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0061, 0x0028, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 0, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70729
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0061, 0x0028, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70730
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0028, 0x0061, 0x05D1, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 0, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_003)
{
{
// line 70731
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0028, 0x0061, 0x05D1, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70732
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 0, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70733
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70734
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0062, 0x0028, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 1, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70735
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0062, 0x0028, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 2, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70736
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0028, 0x0062, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 1, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70737
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0028, 0x0062, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70738
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0028, 0x0029, 0x0062, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 1, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70739
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0028, 0x0029, 0x0062, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70740
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0028, 0x0029, 0x0028, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 1, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_004)
{
{
// line 70741
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0028, 0x0029, 0x0028, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70742
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0028, 0x0029, 0x0028, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 1, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70743
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0028, 0x0029, 0x0028, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70744
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x05D1, 0x0062, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70745
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x05D1, 0x0062, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70746
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x05D1, 0x0029, 0x0062, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70747
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x05D1, 0x0029, 0x0062, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70748
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x05D1, 0x0029, 0x0028, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70749
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x05D1, 0x0029, 0x0028, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70750
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x05D1, 0x0029, 0x0028, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_005)
{
{
// line 70751
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x05D1, 0x0029, 0x0028, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70752
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x0029, 0x05D1, 0x0062, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70753
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x0029, 0x05D1, 0x0062, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70754
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x0029, 0x05D1, 0x0028, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70755
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x0029, 0x05D1, 0x0028, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70756
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x0029, 0x05D1, 0x0028, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70757
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x0029, 0x05D1, 0x0028, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70758
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x0029, 0x0028, 0x05D1, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70759
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x0029, 0x0028, 0x05D1, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70760
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x0029, 0x0028, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_006)
{
{
// line 70761
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x0029, 0x0028, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70762
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0062, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70763
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0062, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70764
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0062, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70765
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0062, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70766
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0028, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70767
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0028, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70768
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0028, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70769
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0028, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70770
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x0029, 0x05D1, 0x0062, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_007)
{
{
// line 70771
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x0029, 0x05D1, 0x0062, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70772
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x0029, 0x05D1, 0x0028, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70773
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x0029, 0x05D1, 0x0028, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70774
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x0029, 0x05D1, 0x0028, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70775
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x0029, 0x05D1, 0x0028, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70776
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x0029, 0x0028, 0x05D1, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70777
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x0029, 0x0028, 0x05D1, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70778
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x0029, 0x0028, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70779
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x0029, 0x0028, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70780
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0061, 0x05D1, 0x0062, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_008)
{
{
// line 70781
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0061, 0x05D1, 0x0062, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70782
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0061, 0x05D1, 0x0028, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70783
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0061, 0x05D1, 0x0028, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70784
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0061, 0x05D1, 0x0028, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70785
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0061, 0x05D1, 0x0028, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70786
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0061, 0x0028, 0x05D1, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70787
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0061, 0x0028, 0x05D1, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70788
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0061, 0x0028, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70789
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0061, 0x0028, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70790
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0028, 0x0061, 0x05D1, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_009)
{
{
// line 70791
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0028, 0x0061, 0x05D1, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70792
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70793
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70794
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0062, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70795
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0062, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70796
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x0062, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70797
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x0062, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70798
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x0028, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70799
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x0028, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70800
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x0028, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_010)
{
{
// line 70801
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x0028, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70802
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x0029, 0x05D1, 0x0062, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70803
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x0029, 0x05D1, 0x0062, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70804
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x0029, 0x05D1, 0x0028, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70805
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x0029, 0x05D1, 0x0028, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70806
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x0029, 0x05D1, 0x0028, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70807
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x0029, 0x05D1, 0x0028, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70808
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x0029, 0x0028, 0x05D1, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70809
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x0029, 0x0028, 0x05D1, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70810
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x0029, 0x0028, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_011)
{
{
// line 70811
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x0029, 0x0028, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70812
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0061, 0x05D1, 0x0062, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70813
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0061, 0x05D1, 0x0062, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70814
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0061, 0x05D1, 0x0028, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70815
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0061, 0x05D1, 0x0028, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70816
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0061, 0x05D1, 0x0028, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70817
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0061, 0x05D1, 0x0028, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70818
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0061, 0x0028, 0x05D1, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70819
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0061, 0x0028, 0x05D1, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70820
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0061, 0x0028, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_012)
{
{
// line 70821
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0061, 0x0028, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70822
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0028, 0x0061, 0x05D1, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70823
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0028, 0x0061, 0x05D1, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70824
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70825
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70826
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0061, 0x05D1, 0x0062, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 0, 1, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70827
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0061, 0x05D1, 0x0062, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70828
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0061, 0x05D1, 0x0028, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 0, 1, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70829
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0061, 0x05D1, 0x0028, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70830
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0061, 0x05D1, 0x0028, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 0, 0, 0, 1, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_013)
{
{
// line 70831
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0061, 0x05D1, 0x0028, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70832
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0061, 0x0028, 0x05D1, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 0, 1, 0, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70833
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0061, 0x0028, 0x05D1, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70834
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0061, 0x0028, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 0, 0, 0, 1, 0, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70835
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0061, 0x0028, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70836
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 0, 1, 0, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70837
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70838
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 0, 0, 0, 1, 0, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70839
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70840
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 0, 0, 1, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_014)
{
{
// line 70841
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0062, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70842
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 0, 0, 0, 0, 1, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70843
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x0062 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70846
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0028, 0x05D2, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 1, 1, 1, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 6, 5, 4, 3, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70847
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0028, 0x05D2, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70848
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0028, 0x0029, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 1, 1, 1, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 6, 5, 4, 3, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70849
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0028, 0x0029, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70850
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0028, 0x0029, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 8, 7, 6, 5, 4, 3 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70851
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0028, 0x0029, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70852
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0028, 0x0029, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 8, 7, 6, 5, 4, 3 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_015)
{
{
// line 70853
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0028, 0x0029, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70854
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x0028, 0x05D1, 0x0029, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 1, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70855
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x0028, 0x05D1, 0x0029, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70856
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x0028, 0x05D1, 0x0029, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 1, 0, 0, 1, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70857
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x0028, 0x05D1, 0x0029, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70858
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x0028, 0x05D1, 0x0029, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 1, 0, 0, 0, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70859
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x0028, 0x05D1, 0x0029, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70860
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x0028, 0x0029, 0x05D1, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 0, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 8, 7, 6, 5 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70861
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x0028, 0x0029, 0x05D1, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70862
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x0028, 0x0029, 0x05D1, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 0, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 8, 7, 6, 5 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_016)
{
{
// line 70863
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x0028, 0x0029, 0x05D1, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70864
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x0028, 0x0029, 0x0028, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 0, 0, 1, 0, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70865
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x0028, 0x0029, 0x0028, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70866
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x05D1, 0x0029, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 1, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70867
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x05D1, 0x0029, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70868
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 1, 0, 0, 1, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70869
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70870
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 1, 0, 0, 0, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70871
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70872
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x0029, 0x05D1, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 0, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 8, 7, 6, 5 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_017)
{
{
// line 70873
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x0029, 0x05D1, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70874
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x0029, 0x05D1, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 0, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 8, 7, 6, 5 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70875
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x0029, 0x05D1, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70876
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x0029, 0x0028, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 0, 0, 1, 0, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70877
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0061, 0x0029, 0x0028, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70878
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0061, 0x05D1, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 0, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 8, 7, 6, 5 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70879
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0061, 0x05D1, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70880
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0061, 0x05D1, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 0, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 8, 7, 6, 5 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70881
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0061, 0x05D1, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70882
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0061, 0x0028, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 0, 0, 1, 0, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_018)
{
{
// line 70883
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0061, 0x0028, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70884
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0028, 0x0061, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 0, 0, 1, 0, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70885
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0028, 0x0061, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70886
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0028, 0x05D2, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 1, 1, 1, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 6, 5, 4, 3, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70887
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0028, 0x05D2, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70888
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0028, 0x0029, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 1, 1, 1, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 6, 5, 4, 3, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70889
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0028, 0x0029, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70890
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0028, 0x0029, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 8, 7, 6, 5, 4, 3 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70891
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0028, 0x0029, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70892
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0028, 0x0029, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 8, 7, 6, 5, 4, 3 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_019)
{
{
// line 70893
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0028, 0x0029, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70894
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x05D1, 0x0029, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 1, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70895
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x05D1, 0x0029, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70896
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x05D1, 0x0029, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 1, 0, 0, 1, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70897
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x05D1, 0x0029, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70898
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x05D1, 0x0029, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 1, 0, 0, 0, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70899
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x05D1, 0x0029, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70900
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x0029, 0x05D1, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 8, 7, 6, 5 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70901
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x0029, 0x05D1, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70902
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x0029, 0x05D1, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 8, 7, 6, 5 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_020)
{
{
// line 70903
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x0029, 0x05D1, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70904
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x0029, 0x0028, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 0, 1, 0, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70905
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0028, 0x0029, 0x0028, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 2, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70906
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0029, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 1, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70907
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0029, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70908
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 1, 0, 0, 1, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70909
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70910
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 1, 0, 0, 0, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70911
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0029, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70912
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x0029, 0x05D1, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 8, 7, 6, 5 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_021)
{
{
// line 70913
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x0029, 0x05D1, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70914
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x0029, 0x05D1, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 8, 7, 6, 5 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70915
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x0029, 0x05D1, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70916
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x0029, 0x0028, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 0, 1, 0, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70917
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0061, 0x0029, 0x0028, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70918
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0061, 0x05D1, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 8, 7, 6, 5 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70919
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0061, 0x05D1, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70920
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0061, 0x05D1, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 8, 7, 6, 5 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70921
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0061, 0x05D1, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70922
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0061, 0x0028, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 0, 1, 0, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_022)
{
{
// line 70923
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0061, 0x0028, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70924
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0028, 0x0061, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 0, 1, 0, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70925
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0028, 0x0061, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70926
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 0, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70927
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70928
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 0, 0, 1, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70929
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70930
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 0, 0, 0, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70931
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70932
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x0029, 0x05D1, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 8, 7, 6, 5 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_023)
{
{
// line 70933
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x0029, 0x05D1, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70934
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x0029, 0x05D1, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 8, 7, 6, 5 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70935
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x0029, 0x05D1, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70936
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x0029, 0x0028, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 0, 1, 0, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70937
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0061, 0x0029, 0x0028, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70938
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0061, 0x05D1, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 8, 7, 6, 5 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70939
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0061, 0x05D1, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70940
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0061, 0x05D1, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 8, 7, 6, 5 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70941
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0061, 0x05D1, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70942
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0061, 0x0028, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 0, 1, 0, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_024)
{
{
// line 70943
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0061, 0x0028, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70944
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0028, 0x0061, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 0, 1, 0, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70945
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0028, 0x0061, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70946
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0061, 0x05D1, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 0, 1, 0, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 8, 7, 6, 5 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70947
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0061, 0x05D1, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70948
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0061, 0x05D1, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 0, 0, 1, 0, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 8, 7, 6, 5 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70949
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0061, 0x05D1, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70950
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0061, 0x0028, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 0, 0, 1, 0, 0, 1, 0, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70951
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0061, 0x0028, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70952
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 0, 0, 1, 0, 0, 1, 0, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_025)
{
{
// line 70953
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70954
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 0, 0, 0, 1, 0, 1, 0, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70955
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70958
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0028, 0x2681, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70959
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0028, 0x2681, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70960
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0028, 0x0029, 0x2681, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70961
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0028, 0x0029, 0x2681, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70962
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0028, 0x0029, 0x0028, 0x2681, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70963
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0028, 0x0029, 0x0028, 0x2681, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70964
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0028, 0x0029, 0x0028, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_026)
{
{
// line 70965
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0028, 0x0029, 0x0028, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70966
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x2680, 0x0029, 0x2681, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70967
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x2680, 0x0029, 0x2681, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70968
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x2680, 0x0029, 0x0028, 0x2681, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70969
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x2680, 0x0029, 0x0028, 0x2681, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70970
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x2680, 0x0029, 0x0028, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70971
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x2680, 0x0029, 0x0028, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70972
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x2680, 0x0028, 0x2681, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70973
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x2680, 0x0028, 0x2681, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70974
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x2680, 0x0028, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_027)
{
{
// line 70975
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x2680, 0x0028, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70976
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x0028, 0x2680, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70977
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x0028, 0x2680, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70978
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x2680, 0x0029, 0x2681, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 5, 4, 3, 2, 1, 0, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70979
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x2680, 0x0029, 0x2681, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70980
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0028, 0x2681, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 5, 4, 3, 2, 1, 0, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70981
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0028, 0x2681, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70982
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0028, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 5, 4, 3, 2, 1, 0, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70983
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0028, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70984
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0028, 0x2681, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_028)
{
{
// line 70985
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0028, 0x2681, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70986
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0028, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70987
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0028, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70988
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x0028, 0x2680, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70989
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x0028, 0x2680, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70990
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0028, 0x2681, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70991
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0028, 0x2681, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70992
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0028, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70993
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0028, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70994
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x0028, 0x2680, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_029)
{
{
// line 70995
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x0028, 0x2680, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70996
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0028, 0x05D1, 0x2680, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 7, 6, 5, 4, 3, 2, 1, 0, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70997
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0028, 0x05D1, 0x2680, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70998
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0029, 0x2681, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 5, 4, 3, 2, 1, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 70999
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0029, 0x2681, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71000
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0028, 0x2681, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 5, 4, 3, 2, 1, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71001
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0028, 0x2681, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71002
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0028, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 5, 4, 3, 2, 1, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71003
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0028, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71004
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0028, 0x2681, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_030)
{
{
// line 71005
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0028, 0x2681, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71006
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0028, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71007
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0028, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71008
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x0028, 0x2680, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71009
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x0028, 0x2680, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71010
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0028, 0x2681, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71011
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0028, 0x2681, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71012
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0028, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71013
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0028, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71014
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x0028, 0x2680, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_031)
{
{
// line 71015
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x0028, 0x2680, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71016
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0028, 0x05D1, 0x2680, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 1, 1, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 7, 6, 5, 4, 3, 2, 1, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71017
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0028, 0x05D1, 0x2680, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71018
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x0028, 0x2681, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71019
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x0028, 0x2681, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71020
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x0028, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71021
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x0028, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71022
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x0028, 0x2680, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71023
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x0028, 0x2680, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71024
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0028, 0x05D1, 0x2680, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_032)
{
{
// line 71025
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0028, 0x05D1, 0x2680, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71026
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 0, 0, 0, 1, 1, 1, 1, 1, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 7, 6, 5, 4, 3, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71027
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0029, 0x2681 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71030
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0061, 0x0028, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71031
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0061, 0x0028, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71032
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0028, 0x0061, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71033
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0028, 0x0061, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71034
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0028, 0x0029, 0x0061, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71035
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0028, 0x0029, 0x0061, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71036
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0028, 0x0029, 0x0028, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_033)
{
{
// line 71037
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0028, 0x0029, 0x0028, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71038
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0028, 0x0029, 0x0028, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71039
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0028, 0x0029, 0x0028, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71040
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x2680, 0x0061, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71041
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x2680, 0x0061, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71042
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x2680, 0x0029, 0x0061, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71043
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x2680, 0x0029, 0x0061, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71044
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x2680, 0x0029, 0x0028, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71045
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x2680, 0x0029, 0x0028, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71046
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x2680, 0x0029, 0x0028, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_034)
{
{
// line 71047
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x2680, 0x0029, 0x0028, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71048
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x2680, 0x0061, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71049
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x2680, 0x0061, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71050
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x2680, 0x0028, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71051
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x2680, 0x0028, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71052
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x2680, 0x0028, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71053
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x2680, 0x0028, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71054
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x0028, 0x2680, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71055
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x0028, 0x2680, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71056
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x0028, 0x2680, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_035)
{
{
// line 71057
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x0028, 0x2680, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71058
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x0028, 0x0029, 0x2680, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71059
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x0028, 0x0029, 0x2680, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71060
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x2680, 0x0061, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 1, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71061
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x2680, 0x0061, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71062
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0061, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 5, 4, 3, 2, 1, 0, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71063
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0061, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71064
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0028, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 5, 4, 3, 2, 1, 0, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71065
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0028, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71066
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0028, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 5, 4, 3, 2, 1, 0, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_036)
{
{
// line 71067
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0028, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71068
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0061, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71069
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0061, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71070
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0028, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71071
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0028, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71072
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0028, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71073
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0028, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71074
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x0028, 0x2680, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71075
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x0028, 0x2680, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71076
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x0028, 0x2680, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_037)
{
{
// line 71077
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x0028, 0x2680, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71078
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x0028, 0x0029, 0x2680, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71079
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x0028, 0x0029, 0x2680, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71080
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0061, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71081
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0061, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71082
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0028, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71083
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0028, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71084
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0028, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71085
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0028, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71086
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x0028, 0x2680, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_038)
{
{
// line 71087
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x0028, 0x2680, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71088
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x0028, 0x2680, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71089
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x0028, 0x2680, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71090
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x0028, 0x0029, 0x2680, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71091
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x0028, 0x0029, 0x2680, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71092
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0028, 0x05D1, 0x2680, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71093
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0028, 0x05D1, 0x2680, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71094
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 7, 6, 5, 4, 3, 2, 1, 0, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71095
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71096
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 6, 5, 4, 3, 2, 1, 0, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_039)
{
{
// line 71097
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71098
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0061, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 1, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71099
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0061, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71100
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0061, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 5, 4, 3, 2, 1, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71101
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0061, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71102
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0028, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 5, 4, 3, 2, 1, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71103
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0028, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71104
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0028, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 5, 4, 3, 2, 1, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71105
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0028, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71106
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0061, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_040)
{
{
// line 71107
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0061, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71108
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0028, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71109
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0028, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71110
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0028, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71111
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0028, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71112
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x0028, 0x2680, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71113
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x0028, 0x2680, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71114
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x0028, 0x2680, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71115
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x0028, 0x2680, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71116
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x0028, 0x0029, 0x2680, 0x0061 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_041)
{
{
// line 71117
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x0028, 0x0029, 0x2680, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71118
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0061, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71119
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0061, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71120
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0028, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71121
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0028, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71122
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0028, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71123
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0028, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71124
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x0028, 0x2680, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71125
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x0028, 0x2680, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71126
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x0028, 0x2680, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_042)
{
{
// line 71127
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x0028, 0x2680, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71128
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x0028, 0x0029, 0x2680, 0x0061 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71129
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x0028, 0x0029, 0x2680, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71130
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0028, 0x05D1, 0x2680, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71131
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0028, 0x05D1, 0x2680, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71132
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 1, 1, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 7, 6, 5, 4, 3, 2, 1, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71133
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71134
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0061 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 6, 5, 4, 3, 2, 1, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71135
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71136
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x0061, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_043)
{
{
// line 71137
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x0061, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71138
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x0028, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71139
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x0028, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71140
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x0028, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71141
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x0028, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71142
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x0028, 0x2680, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71143
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x0028, 0x2680, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71144
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x0028, 0x2680, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71145
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x0028, 0x2680, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71146
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x0028, 0x0029, 0x2680, 0x0061 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_044)
{
{
// line 71147
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x0028, 0x0029, 0x2680, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71148
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0028, 0x05D1, 0x2680, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71149
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0028, 0x05D1, 0x2680, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71150
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71151
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71152
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0061 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71153
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71154
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 0, 1, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71155
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0061, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 2, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71156
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 0, 0, 0, 1, 1, 1, 1, 1, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 7, 6, 5, 4, 3, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_045)
{
{
// line 71157
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71158
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0061 };
std::vector<int> const expected_levels =
{ 0, 0, 0, 1, 1, 1, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 6, 5, 4, 3, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71159
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0061 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 2 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71162
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x05D2, 0x0028, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71163
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x05D2, 0x0028, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71164
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0028, 0x05D2, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 6, 5, 4, 3, 2, 1, 0, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71165
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0028, 0x05D2, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71166
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0028, 0x0029, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 6, 5, 4, 3, 2, 1, 0, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71167
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0028, 0x0029, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71168
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0028, 0x0029, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_046)
{
{
// line 71169
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0028, 0x0029, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71170
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0028, 0x0029, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71171
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0028, 0x0029, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71172
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x2680, 0x05D2, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 6, 5, 4, 3, 2, 1, 0, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71173
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x2680, 0x05D2, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71174
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x2680, 0x0029, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 6, 5, 4, 3, 2, 1, 0, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71175
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x2680, 0x0029, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71176
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x2680, 0x0029, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71177
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x2680, 0x0029, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71178
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x2680, 0x0029, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_047)
{
{
// line 71179
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x2680, 0x0029, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71180
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x2680, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 6, 5, 4, 3, 2, 1, 0, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71181
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x2680, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71182
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x2680, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71183
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x2680, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71184
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x2680, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71185
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x2680, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71186
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x0028, 0x2680, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71187
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x0028, 0x2680, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71188
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x0028, 0x2680, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_048)
{
{
// line 71189
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x0028, 0x2680, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71190
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x0028, 0x0029, 0x2680, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71191
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x0028, 0x0029, 0x2680, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71192
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x2680, 0x05D2, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 6, 5, 4, 3, 2, 1, 0, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71193
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x2680, 0x05D2, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71194
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x2680, 0x0029, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 6, 5, 4, 3, 2, 1, 0, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71195
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x2680, 0x0029, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71196
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71197
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71198
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_049)
{
{
// line 71199
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71200
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x2680, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 6, 5, 4, 3, 2, 1, 0, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71201
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x2680, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71202
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71203
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71204
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71205
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71206
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x0028, 0x2680, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71207
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x0028, 0x2680, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71208
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x0028, 0x2680, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_050)
{
{
// line 71209
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x0028, 0x2680, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71210
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x0028, 0x0029, 0x2680, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71211
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x0028, 0x0029, 0x2680, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71212
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x2680, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 6, 5, 4, 3, 2, 1, 0, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71213
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x2680, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71214
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71215
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71216
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71217
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71218
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x0028, 0x2680, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_051)
{
{
// line 71219
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x0028, 0x2680, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71220
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x0028, 0x2680, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71221
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x0028, 0x2680, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71222
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x0028, 0x0029, 0x2680, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71223
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x0028, 0x0029, 0x2680, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71224
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0028, 0x05D1, 0x2680, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71225
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0028, 0x05D1, 0x2680, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71226
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0028, 0x05D1, 0x2680, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71227
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0028, 0x05D1, 0x2680, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71228
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0028, 0x05D1, 0x0029, 0x2680, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_052)
{
{
// line 71229
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0028, 0x05D1, 0x0029, 0x2680, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71230
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x05D2, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 6, 5, 4, 3, 2, 1, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71231
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x05D2, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71232
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0029, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 6, 5, 4, 3, 2, 1, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71233
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0029, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71234
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 8, 7, 6, 5, 4, 3, 2, 1 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71235
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71236
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 8, 7, 6, 5, 4, 3, 2, 1 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71237
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0029, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71238
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x2680, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 6, 5, 4, 3, 2, 1, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_053)
{
{
// line 71239
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x2680, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71240
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 8, 7, 6, 5, 4, 3, 2, 1 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71241
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71242
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 8, 7, 6, 5, 4, 3, 2, 1 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71243
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x2680, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71244
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x0028, 0x2680, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 8, 7, 6, 5, 4, 3, 2, 1 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71245
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x0028, 0x2680, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71246
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x0028, 0x2680, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 8, 7, 6, 5, 4, 3, 2, 1 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71247
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x0028, 0x2680, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71248
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x0028, 0x0029, 0x2680, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 8, 7, 6, 5, 4, 3, 2, 1 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_054)
{
{
// line 71249
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x0028, 0x0029, 0x2680, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71250
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x2680, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 6, 5, 4, 3, 2, 1, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71251
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x2680, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71252
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 8, 7, 6, 5, 4, 3, 2, 1 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71253
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71254
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 8, 7, 6, 5, 4, 3, 2, 1 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71255
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x2680, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71256
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x0028, 0x2680, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 8, 7, 6, 5, 4, 3, 2, 1 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71257
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x0028, 0x2680, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71258
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x0028, 0x2680, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 8, 7, 6, 5, 4, 3, 2, 1 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_055)
{
{
// line 71259
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x0028, 0x2680, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71260
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x0028, 0x0029, 0x2680, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 8, 7, 6, 5, 4, 3, 2, 1 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71261
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x0028, 0x0029, 0x2680, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71262
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0028, 0x05D1, 0x2680, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 8, 7, 6, 5, 4, 3, 2, 1 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71263
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0028, 0x05D1, 0x2680, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71264
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0028, 0x05D1, 0x2680, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 8, 7, 6, 5, 4, 3, 2, 1 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71265
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0028, 0x05D1, 0x2680, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71266
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0028, 0x05D1, 0x0029, 0x2680, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 8, 7, 6, 5, 4, 3, 2, 1 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71267
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0028, 0x05D1, 0x0029, 0x2680, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71268
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 1, 1, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 6, 5, 4, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_056)
{
{
// line 71269
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x05D2, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71270
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 8, 7, 6, 5, 4 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71271
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x0028, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71272
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 8, 7, 6, 5, 4 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71273
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x0028, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71274
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x0028, 0x2680, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 8, 7, 6, 5, 4 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71275
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x0028, 0x2680, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71276
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x0028, 0x2680, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 8, 7, 6, 5, 4 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71277
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x0028, 0x2680, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71278
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x0028, 0x0029, 0x2680, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 8, 7, 6, 5, 4 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_057)
{
{
// line 71279
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x0028, 0x0029, 0x2680, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71280
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0028, 0x05D1, 0x2680, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 1, 1, 1, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 7, 6, 5, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71281
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0028, 0x05D1, 0x2680, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71282
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0028, 0x05D1, 0x2680, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 1, 0, 0, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71283
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0028, 0x05D1, 0x2680, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71284
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0028, 0x05D1, 0x0029, 0x2680, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 1, 0, 0, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71285
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0028, 0x05D1, 0x0029, 0x2680, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71286
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 0, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 8, 7, 6, 5, 4, 3 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71287
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x05D2, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71288
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 0, 0, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 8, 7, 6, 5, 4, 3 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_058)
{
{
// line 71289
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0029, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71290
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x2680, 0x05D2 };
std::vector<int> const expected_levels =
{ 0, 0, 0, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 8, 7, 6, 5, 4, 3 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71291
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x2680, 0x05D2 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71294
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x2680, 0x0028, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71295
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x2680, 0x0028, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71296
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x0028, 0x2680, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71297
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x0028, 0x2680, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71298
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x0028, 0x0029, 0x2680, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71299
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x0028, 0x0029, 0x2680, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71300
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x0028, 0x0029, 0x0028, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_059)
{
{
// line 71301
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x0028, 0x0029, 0x0028, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71302
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x0028, 0x0029, 0x0028, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71303
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x0028, 0x0029, 0x0028, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 2, 1, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71304
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0061, 0x2680, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71305
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0061, 0x2680, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71306
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0061, 0x0029, 0x2680, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71307
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0061, 0x0029, 0x2680, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71308
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0061, 0x0029, 0x0028, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71309
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0061, 0x0029, 0x0028, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71310
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0061, 0x0029, 0x0028, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_060)
{
{
// line 71311
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0061, 0x0029, 0x0028, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71312
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x0061, 0x2680, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71313
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x0061, 0x2680, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71314
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x0061, 0x0028, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71315
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x0061, 0x0028, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71316
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x0061, 0x0028, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71317
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x0061, 0x0028, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71318
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x0028, 0x0061, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71319
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x0028, 0x0061, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71320
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x0028, 0x0061, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 0, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 2, 1, 0, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_061)
{
{
// line 71321
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0028, 0x0029, 0x0028, 0x0061, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71322
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0061, 0x2680, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 1, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71323
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0061, 0x2680, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71324
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0061, 0x0029, 0x2680, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 1, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71325
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0061, 0x0029, 0x2680, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71326
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0061, 0x0029, 0x0028, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 1, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71327
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0061, 0x0029, 0x0028, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71328
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0061, 0x0029, 0x0028, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 1, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71329
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0061, 0x0029, 0x0028, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71330
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x0061, 0x2680, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_062)
{
{
// line 71331
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x0061, 0x2680, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71332
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x0061, 0x0028, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71333
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x0061, 0x0028, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71334
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x0061, 0x0028, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71335
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x0061, 0x0028, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71336
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x0028, 0x0061, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71337
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x0028, 0x0061, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71338
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x0028, 0x0061, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71339
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x05D1, 0x0029, 0x0028, 0x0061, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71340
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x0061, 0x2680, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_063)
{
{
// line 71341
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x0061, 0x2680, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71342
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x0061, 0x0028, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71343
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x0061, 0x0028, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71344
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x0061, 0x0028, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71345
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x0061, 0x0028, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71346
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x0028, 0x0061, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71347
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x0028, 0x0061, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71348
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x0028, 0x0061, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 4, 3, 2, 1, 0, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71349
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x05D1, 0x0028, 0x0061, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71350
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0028, 0x05D1, 0x0061, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_064)
{
{
// line 71351
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0028, 0x05D1, 0x0061, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71352
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0028, 0x05D1, 0x0061, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 0, 0, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71353
std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0028, 0x0029, 0x0028, 0x05D1, 0x0061, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71354
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0061, 0x2680, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 1, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71355
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0061, 0x2680, 0x0029, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71356
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0061, 0x0029, 0x2680, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 1, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71357
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0061, 0x0029, 0x2680, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71358
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0061, 0x0029, 0x0028, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 1, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71359
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0061, 0x0029, 0x0028, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71360
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0061, 0x0029, 0x0028, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 1, 0, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_065)
{
{
// line 71361
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0061, 0x0029, 0x0028, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 2, 1, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71362
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x0061, 0x2680, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71363
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x0061, 0x2680, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71364
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x0061, 0x0028, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71365
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x0061, 0x0028, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71366
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x0061, 0x0028, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71367
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x0061, 0x0028, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71368
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x0028, 0x0061, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71369
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x0028, 0x0061, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71370
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x0028, 0x0061, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_066)
{
{
// line 71371
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x05D1, 0x0029, 0x0028, 0x0061, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71372
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x0061, 0x2680, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71373
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x0061, 0x2680, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71374
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x0061, 0x0028, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71375
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x0061, 0x0028, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71376
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x0061, 0x0028, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71377
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x0061, 0x0028, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71378
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x0028, 0x0061, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71379
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x0028, 0x0061, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71380
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x0028, 0x0061, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 0, 1, 1, 1, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 4, 3, 2, 1, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_067)
{
{
// line 71381
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x05D1, 0x0028, 0x0061, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71382
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0028, 0x05D1, 0x0061, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71383
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0028, 0x05D1, 0x0061, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71384
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0028, 0x05D1, 0x0061, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 0, 1, 0, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71385
std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0028, 0x0029, 0x0028, 0x05D1, 0x0061, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71386
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x0061, 0x2680, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71387
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x0061, 0x2680, 0x0028, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71388
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x0061, 0x0028, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71389
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x0061, 0x0028, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71390
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x0061, 0x0028, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
TEST(bidi_character, bidi_character_101_068)
{
{
// line 71391
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x0061, 0x0028, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 2, 1, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71392
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x0028, 0x0061, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71393
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x0028, 0x0061, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71394
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x0028, 0x0061, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 1, 0, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71395
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x05D1, 0x0028, 0x0061, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71396
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0028, 0x05D1, 0x0061, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71397
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0028, 0x05D1, 0x0061, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71398
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0028, 0x05D1, 0x0061, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 0, 0, 1, 0, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71399
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x05D0, 0x0029, 0x0028, 0x05D1, 0x0061, 0x0029, 0x2680 };
std::vector<int> const expected_levels =
{ 1, 1, 1, 1, 1, 1, 2, 1, 1 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 1);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 1);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
{
// line 71400
std::vector<uint32_t> const cps = { 0x0028, 0x0028, 0x0029, 0x05D0, 0x0028, 0x05D1, 0x0061, 0x2680, 0x0029 };
std::vector<int> const expected_levels =
{ 0, 0, 0, 1, 0, 1, 0, 0, 0 };
std::vector<int> const levels =
bidi_levels(cps.begin(), cps.end(), 0);
int i = 0;
for (int l : expected_levels) {
if (0 <= l) {
EXPECT_EQ(levels[i], l) << "i=" << i;
++i;
}
}
EXPECT_EQ((int)levels.size(), i);
std::vector<uint32_t> const expected_reordered_indices =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
std::vector<int> const reordered =
bidi_reordered_indices(cps.begin(), cps.end(), 0);
i = 0;
for (int idx : expected_reordered_indices) {
EXPECT_EQ(reordered[i], cps[idx])
<< std::hex
<< " 0x" << reordered[i]
<< " 0x" << cps[idx]
<< std::dec << " i=" << i;
++i;
}
}
}
| 34.161877 | 117 | 0.440883 | [
"vector"
] |
bd0b26bc1776398d9d65fe7e99d6a0005358dc38 | 1,366 | cpp | C++ | Source/SA/Render/Vulkan/Mesh/VkStaticMesh.cpp | SapphireSuite/Engine | f29821853aec6118508f31d3e063e83e603f52dd | [
"MIT"
] | 1 | 2022-01-20T23:17:18.000Z | 2022-01-20T23:17:18.000Z | Source/SA/Render/Vulkan/Mesh/VkStaticMesh.cpp | SapphireSuite/Engine | f29821853aec6118508f31d3e063e83e603f52dd | [
"MIT"
] | null | null | null | Source/SA/Render/Vulkan/Mesh/VkStaticMesh.cpp | SapphireSuite/Engine | f29821853aec6118508f31d3e063e83e603f52dd | [
"MIT"
] | null | null | null | // Copyright (c) 2021 Sapphire's Suite. All Rights Reserved.
#include <Render/Vulkan/Mesh/VkStaticMesh.hpp>
#include <Core/Algorithms/SizeOf.hpp>
#include <Render/Vulkan/VkRenderFrame.hpp>
#if SA_VULKAN
namespace Sa::Vk
{
void StaticMesh::Create(const Device& _device, CommandBuffer& _cmd, ResourceHolder& _resHold, const RawMesh& _raw)
{
AMesh::Create(_raw);
// Create Vertex buffer.
mVertexBuffer.Create(_device, _cmd, _resHold,
SizeOf(_raw.vertices),
VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
_raw.vertices.data());
// Create Index buffer.
mIndicesSize = SizeOf<uint32>(_raw.indices);
mIndexBuffer.Create(_device, _cmd, _resHold,
sizeof(uint32) * mIndicesSize,
VK_BUFFER_USAGE_INDEX_BUFFER_BIT,
_raw.indices.data());
}
void StaticMesh::Destroy(const Device& _device)
{
mVertexBuffer.Destroy(_device);
mIndexBuffer.Destroy(_device);
mIndicesSize = ~uint32();
}
void StaticMesh::Draw(const ARenderFrame& _frame, const MeshDrawInfos& _infos) const
{
const RenderFrame& vkFrame = _frame.As<RenderFrame>();
VkDeviceSize offsets[] = { 0 };
VkBuffer vkVertBuff = mVertexBuffer;
vkCmdBindVertexBuffers(vkFrame.cmd, 0, 1, &vkVertBuff, offsets);
vkCmdBindIndexBuffer(vkFrame.cmd, mIndexBuffer, 0, VK_INDEX_TYPE_UINT32);
vkCmdDrawIndexed(vkFrame.cmd, mIndicesSize, _infos.instanceNum, 0, 0, 0);
}
}
#endif
| 23.964912 | 115 | 0.741581 | [
"mesh",
"render"
] |
bd0e817c9ed92f904a0f3abf9fbd55dab96d3497 | 11,172 | cpp | C++ | src/race/src/traffic_light_detector/main.cpp | young43/ISCC_2020 | 2a7187410bceca901bd87b753a91fd35b73ca036 | [
"MIT"
] | 8 | 2019-07-22T08:22:43.000Z | 2020-12-09T06:25:14.000Z | src/race/src/traffic_light_detector/main.cpp | yongbeomkwak/ISCC_2021 | 7e7e5a8a14b9ed88e1cfbe2ee585fe24e4701015 | [
"MIT"
] | 2 | 2019-07-13T16:30:16.000Z | 2019-08-15T10:37:33.000Z | src/race/src/traffic_light_detector/main.cpp | yongbeomkwak/ISCC_2021 | 7e7e5a8a14b9ed88e1cfbe2ee585fe24e4701015 | [
"MIT"
] | 5 | 2020-09-13T09:06:16.000Z | 2021-06-19T02:31:23.000Z | #include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <vector>
#include <iostream>
using namespace cv;
using namespace std;
const Vec3b HSV_RED_LOWER = Vec3b(0, 100, 100);
const Vec3b HSV_RED_UPPER = Vec3b(10, 255, 255);
const Vec3b HSV_RED_LOWER1 = Vec3b(160, 100, 100);
const Vec3b HSV_RED_UPPER1 = Vec3b(190, 255, 255);
const Vec3b HSV_GREEN_LOWER = Vec3b(40, 200, 30);
const Vec3b HSV_GREEN_UPPER = Vec3b(120, 255, 255);
const Vec3b HSV_YELLOW_LOWER = Vec3b(10, 70, 130);
const Vec3b HSV_YELLOW_UPPER = Vec3b(50, 255, 255);
const Vec3b HSV_BLACK_LOWER = Vec3b(0, 0, 0);
const Vec3b HSV_BLACK_UPPER = Vec3b(180, 255, 50);
const int MAX_SIZE = 230;
const int MIN_SIZE = 50;
const int MAX_HEIGHT = 50;
const int MIN_HEIGHT = 20;
bool use_roi = false;
//Contour 영역 내에 텍스트 쓰기
//https://github.com/bsdnoobz/opencv-code/blob/master/shape-detect.cpp
void setLabel(Mat& image, string str, vector<Point> contour)
{
int fontface = FONT_HERSHEY_SIMPLEX;
double scale = 0.5;
int thickness = 1;
int baseline = 0;
Size text = getTextSize(str, fontface, scale, thickness, &baseline);
Rect r = boundingRect(contour);
Point pt(r.x + ((r.width - text.width) / 2), r.y + ((r.height + text.height) / 2));
rectangle(image, pt + Point(0, baseline), pt + Point(text.width, -text.height), CV_RGB(200, 200, 200), FILLED);
putText(image, str, pt, fontface, scale, CV_RGB(0, 0, 0), thickness, 8);
}
struct TrafficLight {
int left;
int top;
int width;
int height;
bool red_on = false;
bool yellow_on = false;
bool left_on = false;
bool green_on = false;
int state = 0;
TrafficLight() {
}
TrafficLight(int l, int t, int w, int h, int s) : left(l), top(t), width(w), height(h), state(s) {
if(s == 0)
red_on = true;
if(s == 1)
yellow_on = true;
if(s == 2)
left_on = true;
if(s == 3)
green_on = true;
}
};
int main(int argc, char** argv) {
VideoCapture cap("test.mov");
if (!cap.isOpened()) return -1;
while(1) {
Mat img;
cap >> img;
vector<TrafficLight> v;
int rows = img.rows;
int cols = img.cols;
Rect rect(0, 0, cols, rows/2);
Mat org_img = img(rect);
Mat light_off;
org_img.copyTo(light_off);
Mat binary_red, binary_yellow, binary_green;
Mat hsv_img;
cvtColor(org_img, hsv_img, COLOR_BGR2HSV);
imshow("hsv", hsv_img);
// RED Detect
Mat binaryImg1;
Mat binaryImg2;
inRange(hsv_img, HSV_RED_LOWER, HSV_RED_UPPER, binaryImg1);
inRange(hsv_img, HSV_RED_LOWER1, HSV_RED_UPPER1, binaryImg2);
binary_red = binaryImg1 | binaryImg2;
// dilate(binary_red, binary_red, Mat());
imshow("red", binary_red);
Mat red_img_labels, red_stats, red_centroids;
int red_num;
red_num = connectedComponentsWithStats(binary_red, red_img_labels, red_stats, red_centroids, 8, CV_32S);
for(int i = 1; i < red_num; i++) {
int area = red_stats.at<int>(i, CC_STAT_AREA);
int left = red_stats.at<int>(i, CC_STAT_LEFT);
int top = red_stats.at<int>(i, CC_STAT_TOP);
int width = red_stats.at<int>(i, CC_STAT_WIDTH);
int height = red_stats.at<int>(i, CC_STAT_HEIGHT);
if((float)width / (float)height > 1.5)
continue;
if(width < 20)
continue;
width += 30;
left -= 10;
Rect rc(left,top,width,height);
rectangle(light_off, rc, Scalar(0, 0, 0), FILLED);
}
// YELLOW Detect
inRange(hsv_img, HSV_YELLOW_LOWER, HSV_YELLOW_UPPER, binary_yellow);
// dilate(binary_yellow, binary_yellow, Mat());
Mat yel_img_labels, yel_stats, yel_centroids;
int yel_num;
yel_num = connectedComponentsWithStats(binary_yellow, yel_img_labels, yel_stats, yel_centroids, 8, CV_32S);
for(int i = 1; i < yel_num; i++) {
int area = yel_stats.at<int>(i, CC_STAT_AREA);
int left = yel_stats.at<int>(i, CC_STAT_LEFT);
int top = yel_stats.at<int>(i, CC_STAT_TOP);
int width = yel_stats.at<int>(i, CC_STAT_WIDTH);
int height = yel_stats.at<int>(i, CC_STAT_HEIGHT);
if((float)width / (float)height > 1.5)
continue;
if(width < 20)
continue;
width += 30;
left -= 15;
Rect rc(left,top,width,height);
rectangle(light_off, rc, Scalar(0, 0, 0), FILLED);
}
imshow("yellow", binary_yellow);
// GREEN Detect
inRange(hsv_img, HSV_GREEN_LOWER, HSV_GREEN_UPPER, binary_green);
dilate(binary_green, binary_green, Mat());
Mat green_img_labels, green_stats, green_centroids;
int green_num;
green_num = connectedComponentsWithStats(binary_green, green_img_labels, green_stats, green_centroids, 8, CV_32S);
for(int i = 1; i < green_num; i++) {
int area = green_stats.at<int>(i, CC_STAT_AREA);
int left = green_stats.at<int>(i, CC_STAT_LEFT);
int top = green_stats.at<int>(i, CC_STAT_TOP);
int width = green_stats.at<int>(i, CC_STAT_WIDTH);
int height = green_stats.at<int>(i, CC_STAT_HEIGHT);
if((float)width / (float)height > 1.5)
continue;
if(width < 20)
continue;
left -= 20;
width += 20;
Rect rc(left,top,width,height);
rectangle(light_off, rc, Scalar(0, 0, 0), FILLED);
}
imshow("green", binary_green);
imshow("light_off", light_off);
Mat binary_light_off;
cvtColor(light_off, light_off, COLOR_BGR2GRAY);
threshold(light_off, binary_light_off, 100, 255, THRESH_BINARY_INV);
imshow("binary_light_off", binary_light_off);
// RED Detection
for(int j = 1; j < red_num; j++) {
int area = red_stats.at<int>(j, CC_STAT_AREA);
int left = red_stats.at<int>(j, CC_STAT_LEFT);
int top = red_stats.at<int>(j, CC_STAT_TOP);
int width = red_stats.at<int>(j, CC_STAT_WIDTH);
int height = red_stats.at<int>(j, CC_STAT_HEIGHT);
for(int start = left+width; start < left + width * 6; start ++) {
if(start == binary_light_off.cols - 1)
break;
if(binary_light_off.at<uchar>(top+height/3, start) == 0) {
// width = start - left;
break;
}
width ++;
}
if(use_roi) {
if(width > MAX_SIZE || width < MIN_SIZE || height > MAX_HEIGHT || height < MIN_HEIGHT)
continue;
}
v.push_back(TrafficLight(left, top, width, height, 0));
}
// YELLOW Detection
for(int j = 1; j < yel_num; j++) {
int area = yel_stats.at<int>(j, CC_STAT_AREA);
int left = yel_stats.at<int>(j, CC_STAT_LEFT);
int top = yel_stats.at<int>(j, CC_STAT_TOP);
int width = yel_stats.at<int>(j, CC_STAT_WIDTH);
int height = yel_stats.at<int>(j, CC_STAT_HEIGHT);
for(int start = left+width; start < left + width * 4; start ++) {
if(start == binary_light_off.cols - 1)
break;
if(binary_light_off.at<uchar>(top+height/2, start) == 0) {
break;
}
width ++;
}
for(int start = left; start > left - width * 2; start--) {
if(start == 0)
break;
if(binary_light_off.at<uchar>(top+height/3, start) == 0) {
width += left - start;
left = start;
break;
}
}
if(use_roi) {
if(width > MAX_SIZE || width < MIN_SIZE || height > MAX_HEIGHT || height < MIN_HEIGHT)
continue;
}
bool familiar = false;
for(int i = 0; i < v.size(); i++) {
TrafficLight tl = v[i];
if(abs(tl.left - left) < 30 && abs(tl.top - top) < 30) {
tl.yellow_on = true;
familiar = true;
}
}
if(!familiar) {
v.push_back(TrafficLight(left, top, width, height, 1));
}
}
// GREEN Detection
for(int j = 1; j < green_num; j++) {
int area = green_stats.at<int>(j, CC_STAT_AREA);
int left = green_stats.at<int>(j, CC_STAT_LEFT);
int top = green_stats.at<int>(j, CC_STAT_TOP);
int width = green_stats.at<int>(j, CC_STAT_WIDTH);
int height = green_stats.at<int>(j, CC_STAT_HEIGHT);
int org_width = width;
for(int start = left; start > left - width * 5; start --) {
if(start == 0)
break;
if(binary_light_off.at<uchar>(top+height/3, start) == 0) {
width += left - start;
left = start;
break;
}
}
int delta = 0;
for(int start = left+width; start < left + width * 4; start ++) {
if(start == binary_light_off.cols - 1)
break;
if(binary_light_off.at<uchar>(top+height/2, start) == 0) {
break;
}
width ++;
delta++;
}
if(use_roi) {
if(width > MAX_SIZE || width < MIN_SIZE || height > MAX_HEIGHT || height < MIN_HEIGHT)
continue;
}
bool familiar = false;
for(int i = 0; i < v.size(); i++) {
TrafficLight tl = v[i];
if(abs(tl.left - left) < 30 && abs(tl.top - top) < 30) {
if(delta > org_width/2) {
v[i].left_on = true;
}
else
v[i].green_on = true;
familiar = true;
}
}
if(!familiar) {
// 좌회전 불
if(delta > org_width/3)
v.push_back(TrafficLight(left, top, width, height, 2));
else
v.push_back(TrafficLight(left, top, width, height, 3));
}
}
for(int i = 0; i < v.size(); i++) {
rectangle(org_img, Point(v[i].left, v[i].top), Point(v[i].left+v[i].width, v[i].top+v[i].height), Scalar(0,255,0), 3);
cout << v[i].red_on << " " << v[i].yellow_on << " " << v[i].left_on << " " << v[i].green_on << endl;
}
imshow("org_img", org_img);
waitKey(0);
if (waitKey(5) >= 0)
break;
}
}
| 32.382609 | 130 | 0.516649 | [
"shape",
"vector"
] |
bd193f7fff004410fd2ec143d4bfed9bb1e613b7 | 3,292 | cpp | C++ | LolKnow.cpp | Acidity/LolKnow-D3D9-Proxy | 20387be51ac6d444fa1835fd6f1285cd5ef9a405 | [
"CC-BY-3.0"
] | 4 | 2016-04-22T08:39:20.000Z | 2019-05-31T14:37:58.000Z | LolKnow.cpp | Acidity/LolKnow-D3D9-Proxy | 20387be51ac6d444fa1835fd6f1285cd5ef9a405 | [
"CC-BY-3.0"
] | null | null | null | LolKnow.cpp | Acidity/LolKnow-D3D9-Proxy | 20387be51ac6d444fa1835fd6f1285cd5ef9a405 | [
"CC-BY-3.0"
] | null | null | null | //Copyright 2013 Tyler O'Meara
//Released under the Creative Commons Attribution 3.0 Unported License
//See LICENSE for more details
#include "LolKnow.h"
#include "Windows.h"
using namespace std;
vector<Summoner> LolKnow::teamOne;
vector<Summoner> LolKnow::teamTwo;
int LolKnow::currentTeam = 1;
int LolKnow::lineNumber = 0;
bool LolKnow::completedDataTransfer = false;
bool LolKnow::hasCreatedThread = false;
LolKnow::LolKnow(void)
{
}
LolKnow::~LolKnow(void)
{
}
void LolKnow::timerCheckForData(long millis)
{
while(!checkIfDataAvailable())
{
Sleep(millis);
}
}
bool LolKnow::checkIfDataAvailable()
{
ifstream input;
input.open("Temp.txt", ios::in);
if(input)
{
retrieveDataFromMain();
return true;
}
return false;
}
void LolKnow::retrieveDataFromMain()
{
ifstream input;
input.open("Temp.txt", ios::in);
string line;
if(input.is_open())
{
while(input.good())
{
getline(input,line);
handleInputData(line);
}
input.close();
}
completedDataTransfer = true;
}
void LolKnow::handleInputData(string line)
{
if(line == "//BEGIN LOLKNOW DATA TRANSFER" || line == "//END LOLKNOW DATA TRANSFER")
{
return;
}
if(line == "//BEGIN TEAM ONE")
{
currentTeam = 1;
lineNumber = 0;
return;
}
if(line == "//BEGIN TEAM TWO")
{
currentTeam = 2;
lineNumber = 0;
return;
}
if(line == "-----")
{
Summoner s;
if(currentTeam == 1)
{
teamOne.push_back(s);
}
if(currentTeam == 2)
{
teamTwo.push_back(s);
}
lineNumber = 1;
return;
}
Summoner* s;
if(currentTeam == 1)
{
if(teamOne.size() > 0)
s = &(teamOne.at(teamOne.size()-1));
}
if(currentTeam == 2)
{
if(teamTwo.size() > 0)
s = &(teamTwo.at(teamTwo.size()-1));
}
stringstream ss;
switch(lineNumber)
{
case 1: (*s).champion = line; break;
case 2: (*s).name = line; break;
case 3: try { ss << line; ss >> (*s).queueGroup; }catch(...){} break; //TODO Handle exceptions relating to line not holding a number
case 4: if(line != "") { (*s).tier = line; }; break;
case 5: if(line != "") { (*s).rank = line; }; break;
case 6: try { ss << line; ss >> (*s).kills; }catch(...){} break;//TODO Handle exceptions relating to line not holding a number
case 7: try { ss << line; ss >> (*s).deaths; }catch(...){} break;//TODO Handle exceptions relating to line not holding a number
case 8: try { ss << line; ss >> (*s).assists; }catch(...){} break;//TODO Handle exceptions relating to line not holding a number
case 9: try { ss << line; ss >> (*s).wins; }catch(...){} break;//TODO Handle exceptions relating to line not holding a number
case 10: try { ss << line; ss >> (*s).losses; }catch(...){} break;//TODO Handle exceptions relating to line not holding a number
case 11: try { ss << line; ss >> (*s).champKills; }catch(...){} break;//TODO Handle exceptions relating to line not holding a number
case 12: try { ss << line; ss >> (*s).champDeaths; }catch(...){} break;//TODO Handle exceptions relating to line not holding a number
case 13: try { ss << line; ss >> (*s).champAssists; }catch(...){} break;//TODO Handle exceptions relating to line not holding a number
case 14: try { ss << line; ss >> (*s).champPlayed; }catch(...){} break;//TODO Handle exceptions relating to line not holding a number
}
lineNumber++;
} | 25.71875 | 137 | 0.641555 | [
"vector"
] |
bd26cb1adac760365140f8a8c5e53ff2c2892120 | 10,444 | cxx | C++ | FIT/FITsim/AliFITv0.cxx | AllaMaevskaya/AliRoot | c53712645bf1c7d5f565b0d3228e3a6b9b09011a | [
"BSD-3-Clause"
] | 52 | 2016-12-11T13:04:01.000Z | 2022-03-11T11:49:35.000Z | FIT/FITsim/AliFITv0.cxx | AllaMaevskaya/AliRoot | c53712645bf1c7d5f565b0d3228e3a6b9b09011a | [
"BSD-3-Clause"
] | 1,388 | 2016-11-01T10:27:36.000Z | 2022-03-30T15:26:09.000Z | FIT/FITsim/AliFITv0.cxx | AllaMaevskaya/AliRoot | c53712645bf1c7d5f565b0d3228e3a6b9b09011a | [
"BSD-3-Clause"
] | 275 | 2016-06-21T20:24:05.000Z | 2022-03-31T13:06:19.000Z | /**************************************************************************
* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
* *
* Author: The ALICE Off-line Project. *
* Contributors are mentioned in the code where appropriate. *
* *
* Permission to use, copy, modify and distribute this software and its *
* documentation strictly for non-commercial purposes is hereby granted *
* without fee, provided that the above copyright notice appears in all *
* copies and that both the copyright notice and this permission notice *
* appear in the supporting documentation. The authors make no claims *
* about the suitability of this software for any purpose. It is *
* provided "as is" without express or implied warranty. *
**************************************************************************/
/* $Id: AliT0v1.cxx 50646 2011-07-18 14:40:16Z alla $ */
/////////////////////////////////////////////////////////////////////
// //
// T0 ( T-zero) detector version 1 //
//
//Begin Html
/*
<img src="gif/AliT0v1Class.gif">
*/
//End Html
// //
// //
//////////////////////////////////////////////////////////////////////
#include <Riostream.h>
#include <stdlib.h>
#include "TGeoCompositeShape.h"
#include "TGeoManager.h"
#include "TGeoMatrix.h"
#include "TGeoVolume.h"
#include "TGeoTube.h"
#include "TGeoBBox.h"
#include "TGeoNode.h"
#include <TGeoGlobalMagField.h>
#include <TGraph.h>
#include <TLorentzVector.h>
#include <TMath.h>
#include <TVirtualMC.h>
#include <TString.h>
#include "AliLog.h"
#include "AliMagF.h"
#include "AliRun.h"
#include "AliFITHits.h"
#include "AliFITv0.h"
#include "AliMC.h"
#include "AliCDBLocal.h"
#include "AliCDBStorage.h"
#include "AliCDBManager.h"
#include "AliCDBEntry.h"
#include "AliTrackReference.h"
ClassImp(AliFITv0)
//--------------------------------------------------------------------
AliFITv0::AliFITv0(): AliFIT(),
fIdSens1(0)
{
//
// Standart constructor for T0 Detector version 0
}
//--------------------------------------------------------------------
AliFITv0::AliFITv0(const char *name, const char *title):
AliFIT(name,title),
fIdSens1(0)
{
//
// Standart constructor for T0 Detector version 0
//
printf("@@@@@@@@@@@@@@@ AliFITv0::AliFITv0 \n");
fIshunt = 2;
}
//_____________________________________________________________________________
AliFITv0::~AliFITv0()
{
// desctructor
}
//-------------------------------------------------------------------------
void AliFITv0::CreateGeometry()
{
//
// Create the geometry of FIT Detector version 1 full geometry
//
// begin Html
//
printf("@@@@@@@@@@@ AliFITv0::CreateGeometry\n");
Int_t *idtmed = fIdtmed->GetArray();
/*
TGeoMedium* kMedAir = gGeoManager->GetMedium("T0_AIR");
TGeoMedium* kMedMCPGlass = gGeoManager->GetMedium("T0_glass");
TGeoMedium* kMedOptGlass = gGeoManager->GetMedium("T0_OpticalGlass");
TGeoMedium* kMedOptGlassCathode = gGeoManager->GetMedium("T0_OpticalGlassCathode");
*/
Float_t zdetC = 80;
Float_t zdetA = 373.;
Int_t idrotm[999];
Double_t x,y,z;
Float_t pstart[3] = {6, 20 ,2.6};
Float_t pinstart[3] = {3,3,2.55};
Float_t pmcp[3] = {2.95, 2.95, 1.5}; //MCP
Float_t ptop[3] = {1.324, 1.324, 1.};//cherenkov radiator
Float_t preg[3] = {1.324, 1.324, 0.05};//photcathode
AliMatrix(idrotm[901], 90., 0., 90., 90., 180., 0.);
//-------------------------------------------------------------------
// T0 volume
//-------------------------------------------------------------------
Float_t x1[20] = {9, 9, 15 ,15 , 9,
3, -3, 3, -3, -9,
-9, -9, -15, -15, -9,
-3, 3, -3, 3, 9};
Float_t y1[20] = {3.2, -3.2, 3.2, -3.2, -9.2,
-9, -9, -15, -15, -9.2,
-3.2, 3.2, -3.2, 3.2, 9.2,
9, 9, 15, 15, 9.2};
//mother tube
TVirtualMC::GetMC()->Gsvolu("0STR","TUBE",idtmed[kAir],pstart,18);
TVirtualMC::GetMC()->Gspos("0STR",1,"ALIC",0.,0.,-zdetC-pstart[2],idrotm[901],"ONLY");
TVirtualMC::GetMC()->Gspos("0STR",2,"ALIC",0.,0.,zdetA+pstart[2],0,"ONLY");
//T0 interior
TVirtualMC::GetMC()->Gsvolu("0INS","BOX",idtmed[kAir],pinstart,3);
z=-pstart[2]+pinstart[2];
for (Int_t is=0; is<20; is++) {
TVirtualMC::GetMC()->Gspos ("0INS", is + 1, "0STR", x1[is], y1[is], z, 0, "ONLY");
TVirtualMC::GetMC()->Gspos ("0INS", is + 21, "0STR", x1[is], y1[is], z, 0, "ONLY");
printf(" 0INS is %i x %f y %f z %f \n",is, x1[is],y1[is], z);
}
//
x=y=0;
// Entry window (glass)
TVirtualMC::GetMC()->Gsvolu("0TOP","BOX",idtmed[kAir],ptop,3); //glass
TVirtualMC::GetMC()->Gsvolu ("0REG", "BOX", idtmed[kSensAir], preg, 3);
TVirtualMC::GetMC()->Gsvolu("0MCP","BOX",idtmed[kGlass],pmcp,3); //glass
Int_t ntops=0;
Float_t xin=0, yin=0;
for (Int_t ix=0; ix<4; ix++) {
xin = - pinstart[0] + 0.35 + (ix+0.5)*2*ptop[0] ;
for (Int_t iy=0; iy<4; iy++) {
z = - pinstart[2]+ptop[2];
yin = - pinstart[1] + 0.35 + (iy+0.5)*2*ptop[1];
ntops++;
TVirtualMC::GetMC()->Gspos("0TOP",ntops,"0INS",xin,yin,z,0,"ONLY");
// printf(" 0TOP full x %f y %f z %f \n", xin, yin, z);
z = -pinstart[2] + 2 * ptop[2] + preg[2];
TVirtualMC::GetMC()->Gspos ("0REG",ntops, "0INS", xin, yin, z, 0, "ONLY");
printf(" GEOGEO %i %i %i %f %f %f %f %f %f", ntops, ix, iy,
xin,yin,x1[ntops],y1[ntops],x1[ntops]+xin,y1[ntops]+yin);
}
}
// MCP
// TGeoVolume* mcp = gGeoManager->MakeBox("0MCP",kMedMCPGlass, 2.95, 2.95, 1.5);
z=-pinstart[2] + 2*ptop[2] + 2*preg[2] + pmcp[2];
TVirtualMC::GetMC()->Gspos("0MCP",1,"0INS",0,0,z,0,"ONLY");
}
//------------------------------------------------------------------------
void AliFITv0::AddAlignableVolumes() const
{
//
// Create entries for alignable volumes associating the symbolic volume
// name with the corresponding volume path. Needs to be syncronized with
// eventual changes in the geometry.
//
printf("@@@@@@@@@@@@@@@AliFITv0::AddAlignableVolumes()\n");
TString volPath;
TString symName, sn;
TString vpAalign = "/ALIC_1/0STR_1";
TString vpCalign = "/ALIC_1/0STR_2";
for (Int_t imod=0; imod<2; imod++) {
if (imod==0) {volPath = vpCalign; symName="/ALIC_1/0STR_1"; }
if (imod==1) {volPath = vpAalign; symName="/ALIC_1/0STR_2"; }
AliDebug(2,"--------------------------------------------");
AliDebug(2,Form("volPath=%s\n",volPath.Data()));
AliDebug(2,Form("symName=%s\n",symName.Data()));
AliDebug(2,"--------------------------------------------");
if(!gGeoManager->SetAlignableEntry(symName.Data(),volPath.Data()))
AliFatal(Form("Alignable entry %s not created. Volume path %s not valid",
symName.Data(),volPath.Data()));
}
}
//------------------------------------------------------------------------
void AliFITv0::CreateMaterials()
{
printf("@@@@@@@@@@@@AliFITv0::CreateMaterials\n");
Int_t isxfld = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ();
Float_t sxmgmx = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max();
// Float_t a,z,d,radl,absl,buf[1];
// Int_t nbuf;
// AIR
Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
Float_t zAir[4]={6.,7.,8.,18.};
Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
Float_t dAir = 1.20479E-3;
Float_t dAir1 = 1.20479E-11;
// PMT glass SiO2
Float_t aglass[2]={28.0855,15.9994};
Float_t zglass[2]={14.,8.};
Float_t wglass[2]={1.,2.};
Float_t dglass=2.65;
//*** Definition Of avaible T0 materials ***
AliMixture(1, "Vacuum$", aAir, zAir, dAir1,4,wAir);
AliMixture(2, "Air$", aAir, zAir, dAir,4,wAir);
AliMixture( 4, "PMT glass $",aglass,zglass,dglass,-2,wglass);
AliMedium(1, "FIT_Air$", 2, 0, isxfld, sxmgmx, 10., .1, 1., .003, .003);
AliMedium(22, "FIT_AirSens$", 2, 1, isxfld, sxmgmx, 10., .1, 1., .003, .003);
AliMedium(3, "FIT_Vacuum$", 1, 0, isxfld, sxmgmx, 10., .01, .1, .003, .003);
AliMedium(6, "Glass$", 4, 1, isxfld, sxmgmx, 10., .01, .1, .003, .003);
AliDebugClass(1,": ++++++++++++++Medium set++++++++++");
}
//-------------------------------------------------------------------
void AliFITv0::Init()
{
// Initialises version 0 of the Forward Multiplicity Detector
//
AliFIT::Init();
fIdSens1=TVirtualMC::GetMC()->VolId("0REG");
AliDebug(1,Form("%s: *** FIT version 0 initialized ***\n",ClassName()));
}
//-------------------------------------------------------------------
void AliFITv0::StepManager()
{
//
// Called for every step in the T0 Detector
//
Int_t id,copy,copy1;
static Float_t hits[6];
static Int_t vol[3];
TLorentzVector pos;
TLorentzVector mom;
// TClonesArray &lhits = *fHits;
if(!fMC->IsTrackAlive()) return; // particle has disappeared
id=fMC->CurrentVolID(copy);
// Check the sensetive volume
if(id==fIdSens1 ) {
if(fMC->IsTrackEntering()) {
fMC->CurrentVolOffID(1,copy1);
vol[1] = copy1;
vol[0]=copy;
fMC->TrackPosition(pos);
hits[0] = pos[0];
hits[1] = pos[1];
hits[2] = pos[2];
if(pos[2]<0) vol[2] = 0;
else vol[2] = 1 ;
printf(" volumes pmt %i mcp %i side %i x %f y %f z %f\n", vol[0], vol[1], vol[2], hits[0], hits[1], hits[2] );
Float_t etot=fMC->Etot();
hits[3]=etot;
Int_t iPart= fMC->TrackPid();
Int_t partID=fMC->IdFromPDG(iPart);
hits[4]=partID;
Float_t ttime=fMC->TrackTime();
hits[5]=ttime*1e12;
AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits);
// Create a track reference at the exit of photocatode
}
//charge particle
if ( TVirtualMC::GetMC()->TrackCharge() )
AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kFIT);
} //sensitive
}
| 34.130719 | 118 | 0.516277 | [
"geometry"
] |
bd2e7dc03b0c576d4d41985ef3e12cc46597d64c | 1,384 | cpp | C++ | blades/xbmc/xbmc/android/jni/List.cpp | krattai/AEBL | a7b12c97479e1236d5370166b15ca9f29d7d4265 | [
"BSD-2-Clause"
] | 4 | 2016-04-26T03:43:54.000Z | 2016-11-17T08:09:04.000Z | blades/xbmc/xbmc/android/jni/List.cpp | krattai/AEBL | a7b12c97479e1236d5370166b15ca9f29d7d4265 | [
"BSD-2-Clause"
] | 17 | 2015-01-05T21:06:22.000Z | 2015-12-07T20:45:44.000Z | blades/xbmc/xbmc/android/jni/List.cpp | krattai/AEBL | a7b12c97479e1236d5370166b15ca9f29d7d4265 | [
"BSD-2-Clause"
] | 3 | 2016-04-26T03:43:55.000Z | 2020-11-06T11:02:08.000Z | /*
* Copyright (C) 2013 Team XBMC
* http://xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
#include "List.h"
#include "View.h"
#include "ScanResult.h"
#include "WifiConfiguration.h"
#include "ApplicationInfo.h"
#include "jutils/jutils-details.hpp"
using namespace jni;
template <typename T>
T CJNIList<T>::get(int index)
{
return (T)call_method<jhobject>(m_object,
"get", "(I)Ljava/lang/Object;",
index);
}
template <typename T>
int CJNIList<T>::size()
{
return m_object.get() ? call_method<jint>(m_object,
"size", "()I") : 0;
}
template class CJNIList<CJNIScanResult>;
template class CJNIList<CJNIWifiConfiguration>;
template class CJNIList<CJNIApplicationInfo>;
template class CJNIList<CJNIViewInputDeviceMotionRange>;
| 27.68 | 72 | 0.719653 | [
"object"
] |
bd2f513aa530c0e427b17474ab45697e48873900 | 4,894 | hpp | C++ | kern/libs/kbl/include/kbl/atomic/atomic_ref.hpp | SmartPolarBear/dionysus-lite | 9f02e7a4e1ed983368aa5967bd8412244fc469d9 | [
"MIT"
] | 24 | 2020-02-05T15:20:31.000Z | 2022-03-29T03:49:06.000Z | kern/libs/kbl/include/kbl/atomic/atomic_ref.hpp | SmartPolarBear/dionysus-lite | 9f02e7a4e1ed983368aa5967bd8412244fc469d9 | [
"MIT"
] | null | null | null | kern/libs/kbl/include/kbl/atomic/atomic_ref.hpp | SmartPolarBear/dionysus-lite | 9f02e7a4e1ed983368aa5967bd8412244fc469d9 | [
"MIT"
] | 1 | 2021-10-15T10:14:39.000Z | 2021-10-15T10:14:39.000Z | #pragma once
#include <ktl/concepts.hpp>
#include <ktl/type_traits.hpp>
namespace kbl
{
// integral_atomic_ref wraps an underlying object and allows atomic operations on the
// underlying object.
//
// kbl::integral_atomic_ref is a subset of std::integral_atomic_ref, until that is available.
// kbl::integral_atomic_ref is only implemented for integral types at this time and
// does not implement wait() / notify_*()
// integral_atomic_ref is useful when dealing with ABI types or when interacting with
// types that are fixed for external reasons; in all other cases, you prefer
// atomic<T>.
using memory_order_type = size_t;
constexpr memory_order_type memory_order_relaxed = __ATOMIC_RELAXED;
constexpr memory_order_type memory_order_consume = __ATOMIC_CONSUME;
constexpr memory_order_type memory_order_acquire = __ATOMIC_ACQUIRE;
constexpr memory_order_type memory_order_release = __ATOMIC_RELEASE;
constexpr memory_order_type memory_order_acq_rel = __ATOMIC_ACQ_REL;
constexpr memory_order_type memory_order_seq_cst = __ATOMIC_SEQ_CST;
template<typename T>
class integral_atomic_ref
{
public:
// integral_atomic_ref is only implemented for integral types, which is a stronger requirement than
// std's, which only requires T be trivially copyable.
static_assert(ktl::integral<T>);
using value_type = T;
using difference_type = value_type;
static constexpr bool is_always_lock_free = __atomic_always_lock_free(sizeof(T), nullptr);
integral_atomic_ref() = delete;
explicit integral_atomic_ref(T& obj) : ptr_(&obj)
{
}
integral_atomic_ref(const integral_atomic_ref&) noexcept = default;
T operator=(T desired) const noexcept
{
__atomic_store_n(ptr_, desired, __ATOMIC_SEQ_CST);
return desired;
}
integral_atomic_ref& operator=(const integral_atomic_ref&) = delete;
bool is_lock_free() const noexcept
{
return __atomic_always_lock_free(sizeof(T), nullptr);
}
void store(T desired, kbl::memory_order_type order = kbl::memory_order_seq_cst) const noexcept
{
__atomic_store_n(ptr_, desired, static_cast<int>(order));
}
T load(kbl::memory_order_type order = kbl::memory_order_seq_cst) const noexcept
{
return __atomic_load_n(ptr_, static_cast<int>(order));
}
T exchange(T desired, kbl::memory_order_type order = kbl::memory_order_seq_cst) const noexcept
{
return __atomic_exchange_n(ptr_, desired, static_cast<int>(order));
}
bool compare_exchange_weak(T& expected, T desired, kbl::memory_order_type success,
kbl::memory_order_type failure) const noexcept
{
return __atomic_compare_exchange_n(ptr_, &expected, desired, true,
static_cast<int>(success), static_cast<int>(failure));
}
bool compare_exchange_weak(T& expected, T desired,
kbl::memory_order_type order = kbl::memory_order_seq_cst) const noexcept
{
return __atomic_compare_exchange_n(ptr_, &expected, desired, true,
static_cast<int>(order), static_cast<int>(order));
}
bool compare_exchange_strong(T& expected, T desired, kbl::memory_order_type success,
kbl::memory_order_type failure) const noexcept
{
return __atomic_compare_exchange_n(ptr_, &expected, desired, false,
static_cast<int>(success), static_cast<int>(failure));
}
bool compare_exchange_strong(T& expected, T desired,
kbl::memory_order_type order = kbl::memory_order_seq_cst) const noexcept
{
return __atomic_compare_exchange_n(ptr_, &expected, desired, false,
static_cast<int>(order), static_cast<int>(order));
}
T fetch_add(T arg, kbl::memory_order_type order = kbl::memory_order_seq_cst) const noexcept
{
return __atomic_fetch_add(ptr_, arg, static_cast<int>(order));
}
T fetch_sub(T arg, kbl::memory_order_type order = kbl::memory_order_seq_cst) const noexcept
{
return __atomic_fetch_sub(ptr_, arg, static_cast<int>(order));
}
T fetch_and(T arg, kbl::memory_order_type order = kbl::memory_order_seq_cst) const noexcept
{
return __atomic_fetch_and(ptr_, arg, static_cast<int>(order));
}
T fetch_or(T arg, kbl::memory_order_type order = kbl::memory_order_seq_cst) const noexcept
{
return __atomic_fetch_or(ptr_, arg, static_cast<int>(order));
}
T fetch_xor(T arg, kbl::memory_order_type order = kbl::memory_order_seq_cst) const noexcept
{
return __atomic_fetch_xor(ptr_, arg, static_cast<int>(order));
}
T operator++() const noexcept
{
return fetch_add(1) + 1;
}
T operator++(int) const noexcept
{
return fetch_add(1);
}
T operator--() const noexcept
{
return fetch_sub(1) - 1;
}
T operator--(int) const noexcept
{
return fetch_sub(1);
}
T operator+=(T arg) const noexcept
{
return fetch_add(arg) + arg;
}
T operator-=(T arg) const noexcept
{
return fetch_sub(arg) - arg;
}
T operator&=(T arg) const noexcept
{
return fetch_and(arg) & arg;
}
T operator|=(T arg) const noexcept
{
return fetch_or(arg) | arg;
}
T operator^=(T arg) const noexcept
{
return fetch_xor(arg) ^ arg;
}
private:
T* const ptr_;
};
} | 31.779221 | 100 | 0.762975 | [
"object"
] |
bd30bf44cb045b8186de84b1ef0cbbadfa984694 | 24,699 | cpp | C++ | test/framework/net/test_map_rnn.cpp | Shixiaowei02/Anakin | f1ea086c5dfa1009ba15a64bc3e30cde07356360 | [
"Apache-2.0"
] | 1 | 2018-08-03T05:14:27.000Z | 2018-08-03T05:14:27.000Z | test/framework/net/test_map_rnn.cpp | Shixiaowei02/Anakin | f1ea086c5dfa1009ba15a64bc3e30cde07356360 | [
"Apache-2.0"
] | 3 | 2018-06-22T09:08:44.000Z | 2018-07-04T08:38:30.000Z | test/framework/net/test_map_rnn.cpp | Shixiaowei02/Anakin | f1ea086c5dfa1009ba15a64bc3e30cde07356360 | [
"Apache-2.0"
] | 1 | 2021-01-27T07:44:55.000Z | 2021-01-27T07:44:55.000Z | #include <string>
#include "net_test.h"
#include "saber/funcs/timer.h"
#include <chrono>
#include "saber/core/tensor_op.h"
#include <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <map>
#include "framework/operators/ops.h"
#include <fstream>
#include <thread>
#ifdef USE_X86_PLACE
#include <mkl_service.h>
#endif
#if defined(USE_CUDA)
using Target = NV;
using Target_H = NVHX86;
#elif defined(USE_X86_PLACE)
using Target = X86;
using Target_H = X86;
#elif defined(USE_ARM_PLACE)
using Target = ARM;
using Target_H = ARM;
#endif
#ifdef USE_GFLAGS
#include <gflags/gflags.h>
DEFINE_string(model_dir, "", "model dir");
DEFINE_string(model_file, "", "model file");
DEFINE_int32(num, 1, "batchSize");
DEFINE_int32(warmup_iter, 10, "warm up iterations");
DEFINE_int32(epoch, 1000, "time statistic epoch");
DEFINE_int32(batch_size, 1, "seq num");
DEFINE_int32(thread_num, 1, "thread_num");
#else
std::string FLAGS_model_dir;
std::string FLAGS_model_file;
int FLAGS_num = 1;
int FLAGS_warmup_iter = 10;
int FLAGS_epoch = 1000;
int FLAGS_batch_size = 1;
int FLAGS_thread_num = 1;
#endif
std::vector<std::string> string_split(std::string in_str, std::string delimiter) {
std::vector<std::string> seq;
int found = in_str.find(delimiter);
int pre_found = -1;
while (found != std::string::npos) {
if (pre_found == -1) {
seq.push_back(in_str.substr(0, found));
} else {
seq.push_back(in_str.substr(pre_found + delimiter.length(),
found - delimiter.length() - pre_found));
}
pre_found = found;
found = in_str.find(delimiter, pre_found + delimiter.length());
}
seq.push_back(in_str.substr(pre_found + 1, in_str.length() - (pre_found + 1)));
return seq;
}
std::vector<std::string> string_split(std::string in_str, std::vector<std::string>& delimiter) {
std::vector<std::string> in;
std::vector<std::string> out;
out.push_back(in_str);
for (auto del : delimiter) {
in = out;
out.clear();
for (auto s : in) {
auto out_s = string_split(s, del);
for (auto o : out_s) {
out.push_back(o);
}
}
}
return out;
}
class Data {
public:
Data(std::string file_name, int batch_size) :
_batch_size(batch_size),
_total_length(0) {
_file.open(file_name);
CHECK(_file.is_open()) << "file open failed";
_file.seekg(_file.end);
_total_length = _file.tellg();
_file.seekg(_file.beg);
}
void get_batch_data(std::vector<std::vector<float>>& fea,
std::vector<std::vector<float>>& week_fea,
std::vector<std::vector<float>>& time_fea,
std::vector<int>& seq_offset);
private:
std::fstream _file;
int _total_length;
int _batch_size;
};
void Data::get_batch_data(std::vector<std::vector<float>>& fea,
std::vector<std::vector<float>>& week_fea,
std::vector<std::vector<float>>& time_fea,
std::vector<int>& seq_offset) {
CHECK(_file.is_open()) << "file open failed";
int seq_num = 0;
int cum = 0;
char buf[10000];
seq_offset.clear();
seq_offset.push_back(0);
fea.clear();
week_fea.clear();
time_fea.clear();
while (_file.getline(buf, 10000)) {
std::string s = buf;
std::vector<std::string> deli_vec = {":"};
std::vector<std::string> data_vec = string_split(s, deli_vec);
std::vector<std::string> seq;
seq = string_split(data_vec[0], {"|"});
for (auto link : seq) {
std::vector<std::string> data = string_split(link, ",");
std::vector<float> vec;
for (int i = 0; i < data.size(); i++) {
vec.push_back(atof(data[i].c_str()));
}
fea.push_back(vec);
}
std::vector<std::string> week_data;
std::vector<std::string> time_data;
week_data = string_split(data_vec[2], ",");
std::vector<float> vec_w;
for (int i = 0; i < week_data.size(); i++) {
vec_w.push_back(atof(week_data[i].c_str()));
}
week_fea.push_back(vec_w);
time_data = string_split(data_vec[1], ",");
std::vector<float> vec_t;
for (int i = 0; i < time_data.size(); i++) {
vec_t.push_back(atof(time_data[i].c_str()));
}
time_fea.push_back(vec_t);
cum += seq.size();
seq_offset.push_back(cum);
seq_num++;
if (seq_num >= _batch_size) {
break;
}
}
}
void getModels(std::string path, std::vector<std::string>& files) {
DIR* dir;
struct dirent* ptr;
if ((dir = opendir(path.c_str())) == NULL) {
perror("Open dri error...");
exit(1);
}
while ((ptr = readdir(dir)) != NULL) {
if (strcmp(ptr->d_name, ".") == 0 || strcmp(ptr->d_name, "..") == 0) {
continue;
} else if (ptr->d_type == 8) { //file
files.push_back(path + "/" + ptr->d_name);
} else if (ptr->d_type == 4) {
getModels(path + "/" + ptr->d_name, files);
}
}
closedir(dir);
}
void one_thread_run(std::string path,int thread_id){
#ifdef USE_OPENMP
omp_set_dynamic(0);
omp_set_num_threads(1);
#endif
#ifdef USE_X86_PLACE
mkl_set_num_threads(1);
#endif
LOG(WARNING) << "load anakin model file from " << path << " ...";
Graph<Target, AK_FLOAT, Precision::FP32> graph;
auto status = graph.load(path);
if (!status) {
LOG(FATAL) << " [ERROR] " << status.info();
}
LOG(INFO) << "set biggest batchsize to " << FLAGS_num;
graph.ResetBatchSize("input_0", FLAGS_num);
graph.ResetBatchSize("input_4", FLAGS_num);
graph.ResetBatchSize("input_5", FLAGS_num);
//graph.RegistOut("patch_0_stage1_unit2_conv1", "patch_0_stage1_unit2_bn2");
LOG(INFO) << "optimize the graph";
graph.Optimize();
// constructs the executer net
LOG(INFO) << "create net to execute";
Net<Target, AK_FLOAT, Precision::FP32> net_executer(graph, true);
// get in
auto h_tensor_in_0 = net_executer.get_in("input_0");
auto h_tensor_in_1 = net_executer.get_in("input_4");
auto h_tensor_in_2 = net_executer.get_in("input_5");
bool is_rand = false;
std::string data_path = "./test_features_sys";
Data map_data(data_path, FLAGS_batch_size);
Context<Target> ctx(0, 0, 0);
saber::SaberTimer<Target> my_time;
std::vector<std::vector<float>> fea;
std::vector<std::vector<float>> week_fea;
std::vector<std::vector<float>> time_fea;
std::vector<int> seq_offset;
my_time.start(ctx);
int batch_id = 0;
while (true) {
seq_offset.clear();
map_data.get_batch_data(fea, week_fea, time_fea, seq_offset);
if (seq_offset.size() <= 1) {
break;
}
h_tensor_in_0->reshape(Shape(fea.size(), 38, 1, 1));
h_tensor_in_1->reshape(Shape(week_fea.size(), 10, 1, 1));
h_tensor_in_2->reshape(Shape(time_fea.size(), 10, 1, 1));
h_tensor_in_0->set_seq_offset(seq_offset);
#ifdef USE_CUDA
Tensor4d<Target_H, AK_FLOAT> h_tensor_0;
Tensor4d<Target_H, AK_FLOAT> h_tensor_1;
Tensor4d<Target_H, AK_FLOAT> h_tensor_2;
h_tensor_0.reshape(h_tensor_in_0->valid_shape());
h_tensor_1.reshape(h_tensor_in_1->valid_shape());
h_tensor_2.reshape(h_tensor_in_2->valid_shape());
for (int i = 0; i < fea.size(); i++) {
memcpy(h_tensor_0.mutable_data() + i * 38, &fea[i][0], sizeof(float) * 38);
}
for (int i = 0; i < week_fea.size(); i++) {
memcpy(h_tensor_1.mutable_data() + i * 10, &week_fea[i][0], sizeof(float) * 10);
}
for (int i = 0; i < time_fea.size(); i++) {
memcpy(h_tensor_2.mutable_data() + i * 10, &time_fea[i][0], sizeof(float) * 10);
}
h_tensor_in_0->copy_from(h_tensor_0);
h_tensor_in_1->copy_from(h_tensor_1);
h_tensor_in_2->copy_from(h_tensor_2);
#else
for (int i = 0; i < fea.size(); i++) {
memcpy(h_tensor_in_0->mutable_data() + i * 38, &fea[i][0], sizeof(float) * 38);
}
for (int i = 0; i < week_fea.size(); i++) {
memcpy(h_tensor_in_1->mutable_data() + i * 10, &week_fea[i][0], sizeof(float) * 10);
}
for (int i = 0; i < time_fea.size(); i++) {
memcpy(h_tensor_in_2->mutable_data() + i * 10, &time_fea[i][0], sizeof(float) * 10);
}
#endif
net_executer.prediction();
batch_id++;
#ifdef USE_CUDA
cudaDeviceSynchronize();
auto out = net_executer.get_out("final_output.tmp_1_gout");
//print_tensor_device(*out);
cudaDeviceSynchronize();
#endif
// auto out = net_executer.get_out("final_output.tmp_1_gout");
// int size=out->valid_size();
// for(int i=0;i<size-1;i++){
// printf("%f|",out->data()[i] );
// }
// printf("%f\n", out->data()[size-1]);
//break;
}
my_time.end(ctx);
size_t end = (path).find(".anakin.bin");
size_t start = FLAGS_model_dir.length();
std::string model_name = (path).substr(start, end - start);
float time_ms=my_time.get_average_ms();
LOG(INFO)<<"[result]: thread_id = "<<thread_id<<"," << model_name << " batch_size " << FLAGS_batch_size
<< " avg time " <<time_ms/ batch_id << " ms"<<", total time = "<<time_ms;
}
TEST(NetTest, net_execute_base_test) {
#ifdef USE_X86_PLACE
std::vector<std::string> models;
Env<X86>::env_init();
if (FLAGS_model_file == "") {
getModels(FLAGS_model_dir, models);
} else {
models.push_back(FLAGS_model_dir + FLAGS_model_file);
}
for (auto iter = models.begin(); iter < models.end(); iter++) {
Context<X86> ctx(0,0,1);
SaberTimer<X86> timer;
timer.start(ctx);
std::vector<std::unique_ptr<std::thread>> threads;
for(int thread_id=0;thread_id<FLAGS_thread_num;thread_id++){
threads.emplace_back(new std::thread(&one_thread_run,*iter,thread_id));
}
for (int i = 0; i < FLAGS_thread_num; ++i) {
threads[i]->join();
}
timer.end(ctx);
float time_consume=timer.get_average_ms();
LOG(INFO) <<"[result]: totol time = "<<time_consume<<" ms, QPS = "<<FLAGS_num*FLAGS_thread_num/time_consume*1000
<<" , thread num = "<<FLAGS_thread_num;
LOG(WARNING) << "load anakin model file from " << *iter << " ...";
}
#endif
}
#define RUN_IN_WORKER
#ifdef RUN_IN_WORKER
//void consumer_task(Worker<Target , AK_FLOAT, Precision::FP32> *workers){
// LOG(INFO)<<"hello_world";
// int iterator = 88656;
// int count=0;
// while(iterator) {
// if(!workers->empty()) {
// LOG(INFO)<<"hello_world2";
// auto d_tensor_p = workers->async_get_result();
// LOG(INFO)<<"consumer "<<count;
// count++;
// Tensor<Target, AK_FLOAT>* out=d_tensor_p[0];
// iterator--;
// }
// }
// LOG(INFO)<<"bye_world";
//}
//TEST(NetTest, net_execute_base_test_worker) {
// std::vector<std::string> models;
//
// if (FLAGS_model_file == "") {
// getModels(FLAGS_model_dir, models);
// } else {
// models.push_back(FLAGS_model_dir + FLAGS_model_file);
// }
//
// for (auto iter = models.begin(); iter < models.end(); iter++) {
// Worker<Target , AK_FLOAT, Precision::FP32> workers(*iter, 1);
// Graph<Target, AK_FLOAT, Precision::FP32> graph;
// auto status = graph.load(*iter);
// if (!status) {
// LOG(FATAL) << " [ERROR] " << status.info();
// }
// std::vector<std::string>& vout_name = graph.get_outs();
// std::vector<std::string> input_names={"input_0","input_4","input_5"};
// workers.register_inputs(input_names);
// workers.register_outputs(vout_name);
// /*.Reshape("input_0", {FLAGS_num, 38, 1, 1});
// workers.Reshape("input_4", {FLAGS_num, 10, 1, 1});
// workers.Reshape("input_5", {FLAGS_num, 10, 1, 1});*/
// workers.launch();
//
// auto h_tensor_in_0 = new Tensor<Target_H,AK_FLOAT>(Shape(FLAGS_num, 38, 1, 1));
// auto h_tensor_in_1 = new Tensor<Target_H,AK_FLOAT>(Shape(FLAGS_num, 10, 1, 1));
// auto h_tensor_in_2 = new Tensor<Target_H,AK_FLOAT>(Shape(FLAGS_num, 10, 1, 1));
//
// LOG(INFO)<<"init batchsize = "<<FLAGS_num;
// std::vector<Tensor<Target_H, AK_FLOAT>*> inputs={h_tensor_in_0,h_tensor_in_1,h_tensor_in_2};
//
// std::string data_path = "./test_features_sys";
// Data map_data(data_path, FLAGS_batch_size);
// Context<Target> ctx(0, 0, 0);
// saber::SaberTimer<Target> my_time;
// std::vector<std::vector<float>> fea;
// std::vector<std::vector<float>> week_fea;
// std::vector<std::vector<float>> time_fea;
// std::vector<int> seq_offset;
// my_time.start(ctx);
// int batch_id = 0;
// std::thread* consumer=new std::thread(&consumer_task,&workers);
// while (true) {
// LOG(INFO) << batch_id++;
// seq_offset.clear();
// map_data.get_batch_data(fea, week_fea, time_fea, seq_offset);
//
// if (seq_offset.size() <= 1) {
// break;
// }
//
// /*h_tensor_in_0->reshape(Shape(fea.size(), 38, 1, 1));
// h_tensor_in_1->reshape(Shape(week_fea.size(), 10, 1, 1));
// h_tensor_in_2->reshape(Shape(time_fea.size(), 10, 1, 1));
// h_tensor_in_0->set_seq_offset(seq_offset);
//
// for (int i = 0; i < fea.size(); i++) {
// memcpy(h_tensor_in_0->mutable_data() + i * 38, &fea[i][0], sizeof(float) * 38);
// }
//
// for (int i = 0; i < week_fea.size(); i++) {
// memcpy(h_tensor_in_1->mutable_data() + i * 10, &week_fea[i][0], sizeof(float) * 10);
// }
//
// for (int i = 0; i < time_fea.size(); i++) {
// memcpy(h_tensor_in_2->mutable_data() + i * 10, &time_fea[i][0], sizeof(float) * 10);
// }*/
//
//// workers.sync_prediction(inputs);
// workers.async_prediction(inputs);
//
// }
// consumer->join();
// LOG(INFO) << "batch_id = " <<batch_id;
//
//
//
// my_time.end(ctx);
//
// size_t end = (*iter).find(".anakin.bin");
// size_t start = FLAGS_model_dir.length();
// std::string model_name = (*iter).substr(start, end - start);
//
// LOG(INFO) << model_name << " batch_size " << FLAGS_num << " average time " <<
// my_time.get_average_ms() / FLAGS_epoch << " ms";
// std::string save_model_path = *iter + std::string(".saved");
// status = graph.save(save_model_path);
//
// if (!status) {
// LOG(FATAL) << " [ERROR] " << status.info();
// }
// }
//}
#else
TEST(NetTest, net_execute_base_test) {
std::vector<std::string> models;
if (FLAGS_model_file == "") {
getModels(FLAGS_model_dir, models);
} else {
models.push_back(FLAGS_model_dir + FLAGS_model_file);
}
for (auto iter = models.begin(); iter < models.end(); iter++) {
LOG(WARNING) << "load anakin model file from " << *iter << " ...";
Graph<Target, AK_FLOAT, Precision::FP32> graph;
auto status = graph.load(*iter);
if (!status) {
LOG(FATAL) << " [ERROR] " << status.info();
}
LOG(INFO) << "set batchsize to " << FLAGS_num;
graph.ResetBatchSize("input_0", FLAGS_num);
graph.ResetBatchSize("input_4", FLAGS_num);
graph.ResetBatchSize("input_5", FLAGS_num);
//graph.RegistOut("patch_0_stage1_unit2_conv1", "patch_0_stage1_unit2_bn2");
LOG(INFO) << "optimize the graph";
graph.Optimize();
// constructs the executer net
LOG(INFO) << "create net to execute";
Net<Target, AK_FLOAT, Precision::FP32> net_executer(graph, true);
// get in
LOG(INFO) << "get input";
auto h_tensor_in_0 = net_executer.get_in("input_0");
auto h_tensor_in_1 = net_executer.get_in("input_4");
auto h_tensor_in_2 = net_executer.get_in("input_5");
//fill_tensor_host_rand(*h_tensor_in_0, -1.f, 1.f);
//fill_tensor_host_rand(*h_tensor_in_1, -1.f, 1.f);
//fill_tensor_host_rand(*h_tensor_in_2, -1.f, 1.f);
bool is_rand = false;
std::string data_path = "./test_features_sys";
Data map_data(data_path, FLAGS_batch_size);
Context<Target> ctx(0, 0, 0);
saber::SaberTimer<Target> my_time;
if (is_rand) {
int cum = 0;
std::vector<int> seq_offset;
seq_offset.push_back(cum);
for (int i = 0; i < FLAGS_batch_size; i++) {
//int len = std::rand() % 60 + 1;
int len = 30;
cum += len;
seq_offset.push_back(cum);
}
h_tensor_in_0->reshape(Shape(cum, 38, 1, 1));
h_tensor_in_0->set_seq_offset(seq_offset);
Tensor4d<Target_H, AK_FLOAT> h_tensor_0;
Tensor4d<Target_H, AK_FLOAT> h_tensor_1;
Tensor4d<Target_H, AK_FLOAT> h_tensor_2;
h_tensor_0.reshape(h_tensor_in_0->valid_shape());
h_tensor_1.reshape(h_tensor_in_1->valid_shape());
h_tensor_2.reshape(h_tensor_in_2->valid_shape());
fill_tensor_host_rand(h_tensor_0);
fill_tensor_host_rand(h_tensor_1);
fill_tensor_host_rand(h_tensor_2);
h_tensor_in_0->copy_from(h_tensor_0);
h_tensor_in_1->copy_from(h_tensor_1);
h_tensor_in_2->copy_from(h_tensor_2);
LOG(WARNING) << "EXECUTER !!!!!!!! ";
#ifdef USE_CUDA
cudaDeviceSynchronize();
#endif
for (int i = 0; i < FLAGS_warmup_iter; i++) {
net_executer.prediction();
//cudaDeviceSynchronize();
//auto out = net_executer.get_out("patch_0_pre_fc1");
//print_tensor_device(*out);
}
#ifdef ENABLE_OP_TIMER
net_executer.reset_op_time();
#endif
my_time.start(ctx);
//auto start = std::chrono::system_clock::now();
for (int i = 0; i < FLAGS_epoch; i++) {
//DLOG(ERROR) << " epoch(" << i << "/" << epoch << ") ";
net_executer.prediction();
}
my_time.end(ctx);
} else {
std::vector<std::vector<float>> fea;
std::vector<std::vector<float>> week_fea;
std::vector<std::vector<float>> time_fea;
std::vector<int> seq_offset;
my_time.start(ctx);
int batch_id = 0;
while (true) {
LOG(INFO) << batch_id++;
seq_offset.clear();
map_data.get_batch_data(fea, week_fea, time_fea, seq_offset);
if (seq_offset.size() <= 1) {
break;
}
h_tensor_in_0->reshape(Shape(fea.size(), 38, 1, 1));
h_tensor_in_1->reshape(Shape(week_fea.size(), 10, 1, 1));
h_tensor_in_2->reshape(Shape(time_fea.size(), 10, 1, 1));
h_tensor_in_0->set_seq_offset(seq_offset);
#ifdef USE_CUDA
Tensor4d<Target_H, AK_FLOAT> h_tensor_0;
Tensor4d<Target_H, AK_FLOAT> h_tensor_1;
Tensor4d<Target_H, AK_FLOAT> h_tensor_2;
h_tensor_0.reshape(h_tensor_in_0->valid_shape());
h_tensor_1.reshape(h_tensor_in_1->valid_shape());
h_tensor_2.reshape(h_tensor_in_2->valid_shape());
for (int i = 0; i < fea.size(); i++) {
memcpy(h_tensor_0.mutable_data() + i * 38, &fea[i][0], sizeof(float) * 38);
}
for (int i = 0; i < week_fea.size(); i++) {
memcpy(h_tensor_1.mutable_data() + i * 10, &week_fea[i][0], sizeof(float) * 10);
}
for (int i = 0; i < time_fea.size(); i++) {
memcpy(h_tensor_2.mutable_data() + i * 10, &time_fea[i][0], sizeof(float) * 10);
}
h_tensor_in_0->copy_from(h_tensor_0);
h_tensor_in_1->copy_from(h_tensor_1);
h_tensor_in_2->copy_from(h_tensor_2);
#else
for (int i = 0; i < fea.size(); i++) {
memcpy(h_tensor_in_0->mutable_data() + i * 38, &fea[i][0], sizeof(float) * 38);
}
for (int i = 0; i < week_fea.size(); i++) {
memcpy(h_tensor_in_1->mutable_data() + i * 10, &week_fea[i][0], sizeof(float) * 10);
}
for (int i = 0; i < time_fea.size(); i++) {
memcpy(h_tensor_in_2->mutable_data() + i * 10, &time_fea[i][0], sizeof(float) * 10);
}
#endif
net_executer.prediction();
#ifdef USE_CUDA
cudaDeviceSynchronize();
auto out = net_executer.get_out("final_output.tmp_1_gout");
//print_tensor_device(*out);
cudaDeviceSynchronize();
#endif
//break;
}
my_time.end(ctx);
}
#ifdef ENABLE_OP_TIMER
std::vector<float> op_time = net_executer.get_op_time();
auto exec_funcs = net_executer.get_exec_funcs();
auto op_param = net_executer.get_op_param();
for (int i = 0; i < op_time.size(); i++) {
LOG(INFO) << "name: " << exec_funcs[i].name << " op_type: " << exec_funcs[i].op_name <<
" op_param: " << op_param[i] << " time " << op_time[i] / FLAGS_epoch;
}
std::map<std::string, float> op_map;
for (int i = 0; i < op_time.size(); i++) {
auto it = op_map.find(op_param[i]);
if (it != op_map.end()) {
op_map[op_param[i]] += op_time[i];
} else {
op_map.insert(std::pair<std::string, float>(op_param[i], op_time[i]));
}
}
for (auto it = op_map.begin(); it != op_map.end(); ++it) {
LOG(INFO) << it->first << " " << (it->second) / FLAGS_epoch << " ms";
}
#endif
size_t end = (*iter).find(".anakin.bin");
size_t start = FLAGS_model_dir.length();
std::string model_name = (*iter).substr(start, end - start);
LOG(INFO) << model_name << " batch_size " << FLAGS_num << " average time " <<
my_time.get_average_ms() / FLAGS_epoch << " ms";
std::string save_model_path = *iter + std::string(".saved");
status = graph.save(save_model_path);
if (!status) {
LOG(FATAL) << " [ERROR] " << status.info();
}
}
}
#endif
int main(int argc, const char** argv) {
Env<Target>::env_init();
// initial logger
logger::init(argv[0]);
#ifdef USE_GFLAGS
google::ParseCommandLineFlags(&argc, &argv, true);
#else
LOG(INFO) << "BenchMark usage:";
LOG(INFO) << " $benchmark <model_dir> <model_file> <num> <warmup_iter> <epoch>";
LOG(INFO) << " model_dir: model directory";
LOG(INFO) << " model_file: path to model";
LOG(INFO) << " num: batchSize default to 1";
LOG(INFO) << " warmup_iter: warm up iterations default to 10";
LOG(INFO) << " epoch: time statistic epoch default to 1000";
LOG(INFO) << " batch_size: time statistic epoch default to 1000";
if (argc < 3) {
LOG(ERROR) << "You should fill in the variable model_dir and model_file at least.";
return 0;
}
FLAGS_model_dir = argv[1];
if (argc > 2) {
FLAGS_model_file = argv[2];
}
if (argc > 3) {
FLAGS_num = atoi(argv[3]);
}
if (argc > 4) {
FLAGS_warmup_iter = atoi(argv[4]);
}
if (argc > 5) {
FLAGS_epoch = atoi(argv[5]);
}
if (argc > 6) {
FLAGS_batch_size = atoi(argv[6]);
}
if (argc > 7) {
FLAGS_thread_num = atoi(argv[7]);
}
#endif
InitTest();
RUN_ALL_TESTS(argv[0]);
return 0;
}
| 33.197581 | 128 | 0.550225 | [
"shape",
"vector",
"model"
] |
bd38fa9fa00e035ad24707ff82d13b5a785ca735 | 1,401 | hpp | C++ | lib/libAnalyzer/include/ArchHandler.hpp | cyber-itl/citl-static-analysis | 32ef8e519dac1c6a49ff41d902a62df8f5a8e948 | [
"MIT"
] | 14 | 2021-05-03T16:03:22.000Z | 2022-02-14T23:42:39.000Z | lib/libAnalyzer/include/ArchHandler.hpp | cyber-itl/citl-static-analysis | 32ef8e519dac1c6a49ff41d902a62df8f5a8e948 | [
"MIT"
] | 1 | 2021-09-27T12:01:33.000Z | 2021-09-27T12:01:33.000Z | lib/libAnalyzer/include/ArchHandler.hpp | cyber-itl/citl-static-analysis | 32ef8e519dac1c6a49ff41d902a62df8f5a8e948 | [
"MIT"
] | null | null | null | #pragma once
#include <memory>
#include <cstdint>
#include <string>
#include <vector>
#include "json.hpp"
#include "capstone/capstone.h"
#include "llvm/Object/ObjectFile.h"
class Cfg;
class MemoryMap;
class SymResolver;
struct Block;
struct Symbol;
#include "analyzers/BaseEnvAnalyzer.hpp"
#include "analyzers_code/BaseCodeAnalyzer.hpp"
using json = nlohmann::json;
using namespace llvm;
using namespace object;
class ArchHandler {
public:
json analyze();
virtual ~ArchHandler() = default;
protected:
std::vector<std::unique_ptr<BaseEnvAnalyzer>> m_env_analyzers;
std::vector<std::unique_ptr<BaseCodeAnalyzer>> m_code_analyzers;
json m_bin_results;
std::shared_ptr<SymResolver> m_resolver;
std::shared_ptr<MemoryMap> m_memmap;
explicit ArchHandler(const ObjectFile *obj);
// Analyze format specific fields that don't have universal examples
virtual int analyze_format() = 0;
virtual uint64_t get_ep() = 0;
int run_code_analyzers(const Cfg *cfg);
const Symbol *resolve_call_sym(cs_insn *insn, cs_arch arch, const Block *block);
std::vector<std::string> m_selected_funcs;
private:
std::vector<std::string> split(const std::string &str, char delimiter) const;
std::string arch_to_str(const unsigned int arch) const;
const ObjectFile *m_obj;
};
std::unique_ptr<ArchHandler> handler_factory(const ObjectFile *obj);
| 23.745763 | 84 | 0.738044 | [
"object",
"vector"
] |
bd3a364136a7adb6509b0fe7ac8aa4df889e005d | 4,803 | cpp | C++ | src/game/client/fx_staticline.cpp | cstom4994/SourceEngineRebuild | edfd7f8ce8af13e9d23586318350319a2e193c08 | [
"MIT"
] | 6 | 2022-01-23T09:40:33.000Z | 2022-03-20T20:53:25.000Z | src/game/client/fx_staticline.cpp | cstom4994/SourceEngineRebuild | edfd7f8ce8af13e9d23586318350319a2e193c08 | [
"MIT"
] | null | null | null | src/game/client/fx_staticline.cpp | cstom4994/SourceEngineRebuild | edfd7f8ce8af13e9d23586318350319a2e193c08 | [
"MIT"
] | 1 | 2022-02-06T21:05:23.000Z | 2022-02-06T21:05:23.000Z | //========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $Workfile: $
// $Date: $
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "clientsideeffects.h"
#include "fx_staticline.h"
#include "materialsystem/imaterial.h"
#include "materialsystem/imesh.h"
#include "view.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
/*
==================================================
CFXStaticLine
==================================================
*/
CFXStaticLine::CFXStaticLine(const char *name, const Vector &start, const Vector &end, float scale, float life,
const char *shader, unsigned int flags)
: CClientSideEffect(name) {
assert(materials);
if (materials == NULL)
return;
// Create a material...
m_pMaterial = materials->FindMaterial(shader, TEXTURE_GROUP_CLIENT_EFFECTS);
m_pMaterial->IncrementReferenceCount();
//Fill in the rest of the fields
m_vecStart = start;
m_vecEnd = end;
m_uiFlags = flags;
m_fLife = life;
m_fScale = scale * 0.5f;
}
CFXStaticLine::~CFXStaticLine(void) {
Destroy();
}
//==================================================
// Purpose: Draw the primitive
// Input: frametime - the time, this frame
//==================================================
void CFXStaticLine::Draw(double frametime) {
Vector lineDir, viewDir, cross;
Vector tmp;
// Update the effect
Update(frametime);
// Get the proper orientation for the line
VectorSubtract(m_vecEnd, m_vecStart, lineDir);
VectorSubtract(m_vecEnd, CurrentViewOrigin(), viewDir);
cross = lineDir.Cross(viewDir);
VectorNormalize(cross);
CMatRenderContextPtr pRenderContext(materials);
//Bind the material
IMesh *pMesh = pRenderContext->GetDynamicMesh(true, NULL, NULL, m_pMaterial);
CMeshBuilder meshBuilder;
meshBuilder.Begin(pMesh, MATERIAL_QUADS, 1);
bool flipVertical = (m_uiFlags & FXSTATICLINE_FLIP_VERTICAL) != 0;
bool flipHorizontal = (m_uiFlags & FXSTATICLINE_FLIP_HORIZONTAL) != 0;
//Setup our points
VectorMA(m_vecStart, -m_fScale, cross, tmp);
meshBuilder.Position3fv(tmp.Base());
meshBuilder.Normal3fv(cross.Base());
if (flipHorizontal)
meshBuilder.TexCoord2f(0, 0.0f, 1.0f);
else if (flipVertical)
meshBuilder.TexCoord2f(0, 0.0f, 0.0f);
else
meshBuilder.TexCoord2f(0, 1.0f, 1.0f);
meshBuilder.Color4ub(255, 255, 255, 255);
meshBuilder.AdvanceVertex();
VectorMA(m_vecStart, m_fScale, cross, tmp);
meshBuilder.Position3fv(tmp.Base());
meshBuilder.Normal3fv(cross.Base());
if (flipHorizontal)
meshBuilder.TexCoord2f(0, 1.0f, 1.0f);
else if (flipVertical)
meshBuilder.TexCoord2f(0, 1.0f, 0.0f);
else
meshBuilder.TexCoord2f(0, 0.0f, 1.0f);
meshBuilder.Color4ub(255, 255, 255, 255);
meshBuilder.AdvanceVertex();
VectorMA(m_vecEnd, m_fScale, cross, tmp);
meshBuilder.Position3fv(tmp.Base());
meshBuilder.Normal3fv(cross.Base());
if (flipHorizontal)
meshBuilder.TexCoord2f(0, 1.0f, 0.0f);
else if (flipVertical)
meshBuilder.TexCoord2f(0, 1.0f, 1.0f);
else
meshBuilder.TexCoord2f(0, 0.0f, 0.0f);
meshBuilder.Color4ub(255, 255, 255, 255);
meshBuilder.AdvanceVertex();
VectorMA(m_vecEnd, -m_fScale, cross, tmp);
meshBuilder.Position3fv(tmp.Base());
meshBuilder.Normal3fv(cross.Base());
if (flipHorizontal)
meshBuilder.TexCoord2f(0, 0.0f, 0.0f);
else if (flipVertical)
meshBuilder.TexCoord2f(0, 0.0f, 1.0f);
else
meshBuilder.TexCoord2f(0, 1.0f, 0.0f);
meshBuilder.Color4ub(255, 255, 255, 255);
meshBuilder.AdvanceVertex();
meshBuilder.End();
pMesh->Draw();
}
//==================================================
// Purpose: Returns whether or not the effect is still active
// Output: true if active
//==================================================
bool CFXStaticLine::IsActive(void) {
return (m_fLife > 0.0) ? true : false;
}
//==================================================
// Purpose: Destroy the effect and its local resources
//==================================================
void CFXStaticLine::Destroy(void) {
//Release the material
if (m_pMaterial != NULL) {
m_pMaterial->DecrementReferenceCount();
m_pMaterial = NULL;
}
}
//==================================================
// Purpose: Perform any necessary updates
// Input: frametime - the time, this frame
//==================================================
void CFXStaticLine::Update(double frametime) {
m_fLife -= frametime;
}
| 29.832298 | 111 | 0.582136 | [
"vector"
] |
bd41e3b4d4016f8428f1187302359e9164a30d2c | 2,781 | cpp | C++ | src/Hord/Cmd/Object/CmdObjectSetMetaField.cpp | komiga/hord | 32be8ffb11bd74959c5cd5254e36d87f224b6f60 | [
"MIT"
] | null | null | null | src/Hord/Cmd/Object/CmdObjectSetMetaField.cpp | komiga/hord | 32be8ffb11bd74959c5cd5254e36d87f224b6f60 | [
"MIT"
] | null | null | null | src/Hord/Cmd/Object/CmdObjectSetMetaField.cpp | komiga/hord | 32be8ffb11bd74959c5cd5254e36d87f224b6f60 | [
"MIT"
] | null | null | null | /**
@copyright MIT license; see @ref index or the accompanying LICENSE file.
*/
#include <Hord/aux.hpp>
#include <Hord/utility.hpp>
#include <Hord/Log.hpp>
#include <Hord/Data/Defs.hpp>
#include <Hord/Data/ValueRef.hpp>
#include <Hord/Data/Metadata.hpp>
#include <Hord/IO/Defs.hpp>
#include <Hord/Object/Defs.hpp>
#include <Hord/Cmd/Object.hpp>
#include <exception>
#include <Hord/detail/gr_core.hpp>
namespace Hord {
namespace Cmd {
namespace Object {
#define HORD_SCOPE_CLASS Cmd::Object::SetMetaField
#define HORD_SCOPE_FUNC set_value // pseudo
static void
set_value(
Hord::Object::Unit& object,
Hord::Data::Table::Iterator& it,
Hord::Data::ValueRef const& new_value
) {
it.set_field(Data::Metadata::COL_VALUE, new_value);
object.prop_states().assign(
IO::PropType::metadata,
IO::PropState::modified
);
}
#undef HORD_SCOPE_FUNC
#define HORD_SCOPE_FUNC exec // pseudo
HORD_SCOPE_CLASS::exec_result_type
HORD_SCOPE_CLASS::operator()(
Hord::Object::Unit& object,
unsigned const index,
Hord::Data::ValueRef const& new_value
) noexcept try {
m_object_id = object.id();
m_field_index = signed_cast(index);
m_created = false;
if (object.metadata().num_fields() <= index) {
return commit_error("field index is out-of-bounds");
}
auto it = object.metadata().table().iterator_at(index);
set_value(object, it, new_value);
return commit();
} catch (...) {
notify_exception_current();
return commit_error("unknown error");
}
#undef HORD_SCOPE_FUNC
#define HORD_SCOPE_FUNC exec // pseudo
HORD_SCOPE_CLASS::exec_result_type
HORD_SCOPE_CLASS::operator()(
Hord::Object::Unit& object,
String const& name,
Hord::Data::ValueRef const& new_value,
bool const create
) noexcept try {
m_object_id = object.id();
m_field_index = -1;
m_created = false;
if (name.empty()) {
return commit_error("empty name");
}
auto it = object.metadata().table().begin();
for (; it.can_advance(); ++it) {
auto const value_ref = it.get_field(Data::Metadata::COL_NAME);
if (string_equal(name, value_ref.size, value_ref.data.string)) {
m_field_index = signed_cast(it.index);
set_value(object, it, new_value);
return commit();
}
}
if (create) {
Data::ValueRef fields[2];
fields[Data::Metadata::COL_NAME] = {name};
fields[Data::Metadata::COL_VALUE] = {new_value};
object.metadata().table().push_back(2, fields);
object.prop_states().assign(
IO::PropType::metadata,
IO::PropState::modified
);
m_created = true;
m_field_index = signed_cast(object.metadata().num_fields()) - 1;
return commit();
}
return commit_error("field does not exist");
} catch (...) {
notify_exception_current();
return commit_error("unknown error");
}
#undef HORD_SCOPE_FUNC
#undef HORD_SCOPE_CLASS
} // namespace Object
} // namespace Cmd
} // namespace Hord
| 24.830357 | 72 | 0.720245 | [
"object"
] |
bd4780619ff0c232c23eda2dfb5712317e9f8320 | 5,808 | cpp | C++ | tml/test/test_sc.cpp | danielfrascarelli/esys-particle | e56638000fd9c4af77e21c75aa35a4f8922fd9f0 | [
"Apache-2.0"
] | null | null | null | tml/test/test_sc.cpp | danielfrascarelli/esys-particle | e56638000fd9c4af77e21c75aa35a4f8922fd9f0 | [
"Apache-2.0"
] | null | null | null | tml/test/test_sc.cpp | danielfrascarelli/esys-particle | e56638000fd9c4af77e21c75aa35a4f8922fd9f0 | [
"Apache-2.0"
] | null | null | null | /////////////////////////////////////////////////////////////
// //
// Copyright (c) 2003-2017 by The University of Queensland //
// Centre for Geoscience Computing //
// http://earth.uq.edu.au/centre-geoscience-computing //
// //
// Primary Business: Brisbane, Queensland, Australia //
// Licensed under the Open Software License version 3.0 //
// http://www.apache.org/licenses/LICENSE-2.0 //
// //
/////////////////////////////////////////////////////////////
#include "test_sc.h"
//--- I/O includes ---
#include <iostream>
using std::cout;
using std::endl;
using std::flush;
//--- STL ---
#include <vector>
#include <set>
#include <map>
using std::vector;
using std::set;
using std::multimap;
// test scatter
bool test_scatter(TML_Comm *comm, int rank)
{
bool res=true;
if(rank==0){ // rank 0 is sender
// prepare send data
multimap<int,double> sdata;
sdata.insert(pair<int,double>(1,3.5));
sdata.insert(pair<int,double>(1,4.5));
sdata.insert(pair<int,double>(2,5.5));
sdata.insert(pair<int,double>(2,6.5));
sdata.insert(pair<int,double>(2,7.5));
comm->scatter(sdata);
} else { // other ranks receive
vector<double> rdata;
comm->recv_scatter(rdata,0);
// test
if(rank==1){
res=(rdata.size()==2)&&(rdata[0]==3.5)&&(rdata[1]==4.5);
} else if(rank==2){
res=(rdata.size()==3)&&(rdata[0]==5.5)&&(rdata[1]==6.5)&&(rdata[2]==7.5);
}
}
return res;
}
// test gather
bool test_gather(TML_Comm *comm, int rank)
{
vector<double> sdata;
multimap<int,double> rdata;
bool res=true;
// setup data
if(rank==0){
sdata.push_back(2.2);
sdata.push_back(3.3);
comm->send_gather(sdata,2);
} else if(rank==1){
sdata.push_back(4.4);
sdata.push_back(5.5);
sdata.push_back(6.6);
comm->send_gather(sdata,2);
} else { // rank 2 == root -> receive
comm->gather(rdata);
// test
res=(rdata.count(0)==2) && (rdata.count(1)==3) && (rdata.count(2)==0);
if(res){
multimap<int,double>::const_iterator iter;
iter=rdata.find(0);
res=res&&(iter->second==2.2);
iter++;
res=res&&(iter->second==3.3);
iter=rdata.find(1);
res=res&&(iter->second==4.4);
iter++;
res=res&&(iter->second==5.5);
iter++;
res=res&&(iter->second==6.6);
}
}
return res;
}
// test scatter packed
bool test_scatter_packed(TML_Comm *comm, int rank)
{
bool res=true;
if(rank==0){ // rank 0 is sender
// prepare send data
multimap<int,double> sdata;
sdata.insert(pair<int,double>(1,3.5));
sdata.insert(pair<int,double>(1,4.5));
sdata.insert(pair<int,double>(2,5.5));
sdata.insert(pair<int,double>(2,6.5));
sdata.insert(pair<int,double>(2,7.5));
comm->scatter_packed(sdata);
} else { // other ranks receive
vector<double> rdata;
comm->recv_scatter_packed(rdata,0);
// test
if(rank==1){
res=(rdata.size()==2)&&(rdata[0]==3.5)&&(rdata[1]==4.5);
} else if(rank==2){
res=(rdata.size()==3)&&(rdata[0]==5.5)&&(rdata[1]==6.5)&&(rdata[2]==7.5);
}
}
return res;
}
// test broadcast
bool test_broadcast(TML_Comm *comm, int rank)
{
bool res=true;
if(rank==0){ // rank 0 is sender
comm->broadcast(42);
} else {
int data;
comm->recv_broadcast(data,0);
// test
res=(data==42);
}
return res;
}
// test broadcast_cont
bool test_broadcast_cont(TML_Comm *comm, int rank)
{
bool res=true;
vector<double> sdata;
vector<double> rdata;
if(rank==0){ // rank 0 is sender
sdata.push_back(3.14159);
sdata.push_back(1.41421);
comm->broadcast_cont(sdata);
} else {
comm->recv_broadcast_cont(rdata,0);
//test
if(rdata.size()==2){
res=(rdata[0]==3.14159) && (rdata[1]==1.41421);
}else{
res=false;
cout << "process " << rank << "received wrong size " << rdata.size() << endl;
}
}
return res;
}
// test broadcast_cont_packed
bool test_broadcast_cont_packed(TML_Comm *comm, int rank)
{
bool res=true;
vector<double> sdata;
vector<double> rdata;
if(rank==0){ // rank 0 is sender
sdata.push_back(3.14159);
sdata.push_back(1.41421);
comm->broadcast_cont_packed(sdata);
} else {
comm->recv_broadcast_cont_packed(rdata,0);
//test
if(rdata.size()==2){
res=(rdata[0]==3.14159) && (rdata[1]==1.41421);
}else{
res=false;
cout << "process " << rank << "received wrong size " << rdata.size() << endl;
}
}
return res;
}
bool test_group_sc(TML_Comm *comm, int rank)
{
bool res=true;
if(test_scatter(comm,rank)){
cout << "test_scatter sucessfull" << endl;
}else{
res=false;
cout << "test_scatter failed" << endl;
}
if(test_gather(comm,rank)){
cout << "test_gather sucessfull" << endl;
}else{
res=false;
cout << "test_gather failed" << endl;
}
if(test_scatter_packed(comm,rank)){
cout << "test_scatter_packed sucessfull" << endl;
}else{
res=false;
cout << "test_scatter_packed failed" << endl;
}
if(test_broadcast(comm,rank)){
cout << "test_broadcast sucessfull" << endl;
}else{
res=false;
cout << "test_broadcast failed" << endl;
}
if(test_broadcast_cont(comm,rank)){
cout << "test_broadcast_cont sucessfull" << endl;
} else{
res=false;
cout << "test_broadcast_cont failed" << endl;
}
if(test_broadcast_cont_packed(comm,rank)){
cout << "test_broadcast_cont_packed sucessfull" << endl;
} else{
res=false;
cout << "test_broadcast_cont_packed failed" << endl;
}
cout << "finished test_group_sc"<< endl;
return res;
}
| 24.927039 | 83 | 0.569904 | [
"vector"
] |
bd48cfe2b551aa19220d7ff6880c4e1dc77def50 | 2,731 | hpp | C++ | engine/std/mesh.hpp | jjzhang166/OpenGLEngine | e5d86f41536834499f4dd534c590fbeed045ff7c | [
"MIT"
] | 1 | 2021-08-12T07:35:49.000Z | 2021-08-12T07:35:49.000Z | engine/std/mesh.hpp | jjzhang166/OpenGLEngine | e5d86f41536834499f4dd534c590fbeed045ff7c | [
"MIT"
] | null | null | null | engine/std/mesh.hpp | jjzhang166/OpenGLEngine | e5d86f41536834499f4dd534c590fbeed045ff7c | [
"MIT"
] | null | null | null | //
// mesh.h
// OpenGLEngine
//
// Created by 彭怀亮 on 6/9/19.
// Copyright © 2019 彭怀亮. All rights reserved.
//
#ifndef mesh_h
#define mesh_h
#include "texmgr.hpp"
#include "shader.hpp"
namespace engine
{
#define Vt_Pos3 0x0001
#define Vt_Pos2 0x0002
#define Vt_UV 0x0010
#define Vt_UV2 0x0020
#define Vt_UV3 0x0040
#define Vt_UV4 0x0040
#define Vt_Normal 0x0100
#define Vt_TAN 0x0200
#define Vt_BIT 0x0400
#define Vt_Color 0x1000
#define Vt_Skin 0x2000
#define LEN_Pos3 3
#define LEN_Pos2 2
#define LEN_UV 2
#define LEN_UV2 2
#define LEN_UV3 2
#define LEN_UV4 2
#define LEN_Normal 3
#define LEN_TAN 3
#define LEN_BIT 3
#define LEN_Color 3
#define LEN_Skin 4
typedef unsigned int VertType;
#define VIRTUAL_FUNC_CNT 1
struct Vert { };
struct BaseVert2 : Vert
{
glm::vec2 Position;
glm::vec2 TexCoords;
};
struct BaseVert3 : Vert
{
glm::vec3 Position;
glm::vec2 TexCoords;
};
struct NormalVert:Vert
{
glm::vec3 Position;
glm::vec3 Normal;
};
struct Vertex : Vert
{
glm::vec3 Position;
glm::vec2 TexCoords;
glm::vec3 Normal;
};
struct SkinVertex : Vertex
{
float weight[3];
int boneindx[3];
int bonecount;
SkinVertex()
{
bonecount=0;
loop(3) weight[i] = 0;
loop(3) boneindx[i] = 0;
}
};
struct SkeletonVertex : Vertex
{
glm::vec4 Bone;
};
struct ColorVertex : Vert
{
glm::vec3 Position;
glm::vec2 TexCoords;
glm::vec3 Color;
};
struct CompxVertex : Vertex
{
glm::vec3 Color;
};
struct TangVertex : Vertex
{
glm::vec3 Tangent;
};
struct MeshData
{
uint num_indice;
unsigned short *indices= nullptr;
uint num_vert;
Vert* vertices = nullptr;
VertType type;
~MeshData();
void ConfigAttribute(const GLenum usage = GL_STATIC_DRAW);
bool hasPos() const;
bool hasPos3() const;
bool hasPos2() const;
bool hasUV() const;
bool hasNormal() const;
bool hasColor() const;
bool BindVert(Shader* shader);
/*
* you need to delete[] after the function be called
*/
TangVertex* RecalcuteTangent();
};
}
#endif /* mesh_h */
| 18.328859 | 66 | 0.512999 | [
"mesh"
] |
bd4b42bc6d54890bc589d1cb871819ccf30a8c8c | 359 | hpp | C++ | src/cpp/ee/soomla/internal/jsb_cc_store_inventory.hpp | enrevol/ee-x | 60a66ad3dc6e14802a7c5d8d585a8499be13f5b8 | [
"MIT"
] | null | null | null | src/cpp/ee/soomla/internal/jsb_cc_store_inventory.hpp | enrevol/ee-x | 60a66ad3dc6e14802a7c5d8d585a8499be13f5b8 | [
"MIT"
] | null | null | null | src/cpp/ee/soomla/internal/jsb_cc_store_inventory.hpp | enrevol/ee-x | 60a66ad3dc6e14802a7c5d8d585a8499be13f5b8 | [
"MIT"
] | null | null | null | //
// jsb_cc_store_inventory.hpp
// ee-x
//
// Created by Nguyen Van Quynh on 9/13/18.
//
#ifndef EE_X_JSB_CC_STORE_INVENTORY_HPP
#define EE_X_JSB_CC_STORE_INVENTORY_HPP
#include <ee/soomla/SoomlaFwd.hpp>
namespace soomla {
bool register_cc_store_inventory_manual(se::Object* object);
} // namespace soomla
#endif /* EE_X_JSB_CC_STORE_INVENTORY_HPP */
| 19.944444 | 60 | 0.771588 | [
"object"
] |
bd53787437c3fbcd64f2a9048c64c236d6bf4db6 | 3,276 | cpp | C++ | examples/robotics/ur5/ur5.cpp | Janus1984/Msnhnet | 4e09f2501ba8db789f0a20441a357de3ba468f10 | [
"MIT"
] | 546 | 2020-07-05T13:09:44.000Z | 2022-03-31T01:55:22.000Z | examples/robotics/ur5/ur5.cpp | wllkk/Msnhnet | 8b472a94a3be6a8ac6a79f48c393900c2a3ba447 | [
"MIT"
] | 23 | 2020-07-09T01:26:10.000Z | 2021-12-08T01:18:46.000Z | examples/robotics/ur5/ur5.cpp | wllkk/Msnhnet | 8b472a94a3be6a8ac6a79f48c393900c2a3ba447 | [
"MIT"
] | 114 | 2020-07-06T06:04:40.000Z | 2022-03-30T14:47:50.000Z | #include <iostream>
#include <Msnhnet/robot/MsnhRobot.h>
using namespace Msnhnet;
void space()
{
SE3D M;
M.setVal({1,0,0,-817.25,
0,0,-1,-191.45,
0,1,0,-5.491,
0,0,0,1
});
std::vector<ScrewD> screwList;
screwList.push_back(ScrewD(Vector3D({0, 0, 0}),Vector3D({0, 0, 1})));
screwList.push_back(ScrewD(Vector3D({89.159, 0, 0}),Vector3D({0, -1, 0})));
screwList.push_back(ScrewD(Vector3D({89.159, 0, 425}),Vector3D({0, -1, 0})));
screwList.push_back(ScrewD(Vector3D({89.159, 0, 817.25}),Vector3D({0, -1, 0})));
screwList.push_back(ScrewD(Vector3D({109.15, -817.25, 0}),Vector3D({0, 0, -1})));
screwList.push_back(ScrewD(Vector3D({-5.491, 0, 817.25}),Vector3D({0, -1, 0})));
Vector6D thetalist0 = Vector6D({MSNH_PI_2, MSNH_PI_3,MSNH_PI_3,MSNH_PI_6,MSNH_PI_6,MSNH_PI_3});
std::cout<<"Input joint angle: "<<std::endl;
(180/MSNH_PI*thetalist0).print();
ModernRobot<6> robot(screwList,M,Msnhnet::ROBOT_SPACE);
std::cout<<"FK euler: "<<std::endl;
(180/MSNH_PI*Msnhnet::Geometry::rotMat2Euler(robot.fk(thetalist0).getRotationMat(), ROT_ZYX)).print();
std::cout<<"FK HomTransMatrix: "<<std::endl;
robot.fk(thetalist0).print();
auto T = robot.fk(thetalist0);
Vector6D thetalist1 = Vector6D({0,0,0,0,0,0});
bool ik = robot.ik(T,thetalist1,0.01,0.001);
std::cout<<"IK joint angle: "<<std::endl;
(180/MSNH_PI*thetalist1).print();
std::cout<<"FK use IK joint angle: "<<std::endl;
robot.fk(thetalist1).print();
}
void body()
{
SE3D M;
M.setVal({1,0,0,-817.25,
0,0,-1,-191.45,
0,1,0,-5.491,
0,0,0,1
});
std::vector<ScrewD> screwList;
screwList.push_back(ScrewD(Vector3D({191.45, 0, 817.25}),Vector3D({0, 1, 0})));
screwList.push_back(ScrewD(Vector3D({94.65,-817.25, 0}),Vector3D({0, 0, 1})));
screwList.push_back(ScrewD(Vector3D({94.65,-392.25, 0}),Vector3D({0, 0, 1})));
screwList.push_back(ScrewD(Vector3D({94.65, 0, 0}),Vector3D({0,0,1})));
screwList.push_back(ScrewD(Vector3D({-82.3, 0, 0}),Vector3D({0, -1, 0})));
screwList.push_back(ScrewD(Vector3D({0, 0, 0}),Vector3D({0, 0, 1})));
Vector6D thetalist0 = Vector6D({MSNH_PI_2, MSNH_PI_3,MSNH_PI_3,MSNH_PI_6,MSNH_PI_6,MSNH_PI_3});
std::cout<<"Input joint angle: "<<std::endl;
(180/MSNH_PI*thetalist0).print();
ModernRobot<6> robot(screwList,M,Msnhnet::ROBOT_BODY);
std::cout<<"FK euler: "<<std::endl;
(180/MSNH_PI*Msnhnet::Geometry::rotMat2Euler(robot.fk(thetalist0).getRotationMat(), ROT_ZYX)).print();
std::cout<<"FK HomTransMatrix: "<<std::endl;
robot.fk(thetalist0).print();
auto T = robot.fk(thetalist0);
Vector6D thetalist1 = Vector6D({0,0,0,0,0,0});
bool ik = robot.ik(T,thetalist1,0.01,0.001);
std::cout<<"IK joint angle: "<<std::endl;
(180/MSNH_PI*thetalist1).print();
std::cout<<"FK use IK joint angle: "<<std::endl;
robot.fk(thetalist1).print();
}
int main()
{
std::cout << "============================== space ==============================\n";
space();
std::cout << "============================== body ==============================\n";
body();
return 1;
} | 33.428571 | 106 | 0.582723 | [
"geometry",
"vector"
] |
32ddf78f0e14f73e8b6860c570b8c27dbd5da1e7 | 4,305 | cc | C++ | node_modules/node-spotify/src/callbacks/PlaylistContainerCallbacksHolder.cc | gilfillan9/spotify-jukebox | f0e70260890af363ed3d3d1d989faa25db09c17a | [
"MIT"
] | 2 | 2015-12-11T07:45:38.000Z | 2016-08-05T11:52:46.000Z | node_modules/node-spotify/src/callbacks/PlaylistContainerCallbacksHolder.cc | gilfillan9/spotify-jukebox | f0e70260890af363ed3d3d1d989faa25db09c17a | [
"MIT"
] | null | null | null | node_modules/node-spotify/src/callbacks/PlaylistContainerCallbacksHolder.cc | gilfillan9/spotify-jukebox | f0e70260890af363ed3d3d1d989faa25db09c17a | [
"MIT"
] | null | null | null | #include "PlaylistContainerCallbacksHolder.h"
#include "../objects/node/NodePlaylist.h"
#include "../objects/node/NodePlaylistFolder.h"
#include "../objects/spotify/Playlist.h"
using namespace v8;
PlaylistContainerCallbacksHolder::PlaylistContainerCallbacksHolder(sp_playlistcontainer* pc, node::ObjectWrap* _userdata) :
playlistContainer(pc), userdata(_userdata) {
playlistContainerCallbacks = new sp_playlistcontainer_callbacks();
}
PlaylistContainerCallbacksHolder::~PlaylistContainerCallbacksHolder() {
sp_playlistcontainer_remove_callbacks(playlistContainer, playlistContainerCallbacks, this);
delete playlistContainerCallbacks;
}
void PlaylistContainerCallbacksHolder::call(std::unique_ptr<NanCallback>& callback, std::initializer_list<Handle<Value>> args) {
unsigned int argc = args.size();
Handle<Value>* argv = const_cast<Handle<Value>*>(args.begin());
callback->Call(argc, argv);
}
void PlaylistContainerCallbacksHolder::playlistAdded(sp_playlistcontainer* pc, sp_playlist* spPlaylist, int position, void* userdata) {
auto holder = static_cast<PlaylistContainerCallbacksHolder*>(userdata);
sp_playlist_type playlistType = sp_playlistcontainer_playlist_type(pc, position);
std::shared_ptr<PlaylistBase> playlistBase;
Handle<Object> playlistV8;
if(playlistType == SP_PLAYLIST_TYPE_PLAYLIST) {
playlistBase = Playlist::fromCache(spPlaylist);
NodeWrapped<NodePlaylist>* nodePlaylist = new NodePlaylist(Playlist::fromCache(spPlaylist));
playlistV8 = nodePlaylist->createInstance();
} else if(playlistType == SP_PLAYLIST_TYPE_START_FOLDER) {
char buf[256];
sp_playlistcontainer_playlist_folder_name(pc, position, buf, 256);
NodeWrapped<NodePlaylistFolder>* nodePlaylist = new NodePlaylistFolder(std::make_shared<PlaylistFolder>(buf, playlistType));
playlistV8 = nodePlaylist->createInstance();
} else if(playlistType == SP_PLAYLIST_TYPE_END_FOLDER) {
NodeWrapped<NodePlaylistFolder>* nodePlaylist = new NodePlaylistFolder(std::make_shared<PlaylistFolder>(playlistType));
playlistV8 = nodePlaylist->createInstance();
} else {
return;
}
holder->call(holder->playlistAddedCallback, {NanUndefined(), playlistV8, NanNew<Number>(position)});
}
void PlaylistContainerCallbacksHolder::playlistRemoved(sp_playlistcontainer* pc, sp_playlist* spPlaylist, int position, void *userdata) {
auto holder = static_cast<PlaylistContainerCallbacksHolder*>(userdata);
node::ObjectWrap* nodePlaylist = nullptr; //FIXME what??
if(nodePlaylist != nullptr) {
holder->call(holder->playlistRemovedCallback, {NanUndefined(), NanNew<Number>(position), NanObjectWrapHandle(nodePlaylist)});
} else {
holder->call(holder->playlistRemovedCallback, {NanUndefined(), NanNew<Number>(position)});
}
}
void PlaylistContainerCallbacksHolder::playlistMoved(sp_playlistcontainer* pc, sp_playlist* spPlaylist, int position, int new_position, void *userdata) {
auto holder = static_cast<PlaylistContainerCallbacksHolder*>(userdata);
node::ObjectWrap* nodePlaylist = nullptr; //FIXME what?
if(nodePlaylist != nullptr) {
holder->call(holder->playlistMovedCallback, {NanUndefined(), NanNew<Number>(position), NanNew<Number>(new_position), NanObjectWrapHandle(nodePlaylist)});
} else {
holder->call(holder->playlistMovedCallback, {NanUndefined(), NanNew<Number>(position), NanNew<Number>(new_position)});
}
}
void PlaylistContainerCallbacksHolder::setCallbacks() {
sp_playlistcontainer_remove_callbacks(playlistContainer, playlistContainerCallbacks, this);
if(playlistAddedCallback && !playlistAddedCallback->IsEmpty()) {
playlistContainerCallbacks->playlist_added = &PlaylistContainerCallbacksHolder::playlistAdded;
}
if(playlistRemovedCallback && !playlistRemovedCallback->IsEmpty()) {
playlistContainerCallbacks->playlist_removed = &PlaylistContainerCallbacksHolder::playlistRemoved;
}
if(playlistMovedCallback && !playlistMovedCallback->IsEmpty()) {
playlistContainerCallbacks->playlist_moved = &PlaylistContainerCallbacksHolder::playlistMoved;
}
sp_playlistcontainer_add_callbacks(playlistContainer, playlistContainerCallbacks, this);
}
void PlaylistContainerCallbacksHolder::unsetCallbacks() {
sp_playlistcontainer_remove_callbacks(playlistContainer, playlistContainerCallbacks, this);
} | 51.86747 | 157 | 0.792799 | [
"object"
] |
32f4825988fc48f81df6ad30add9ab9efc94a772 | 16,856 | cpp | C++ | src/DungeonMaster.cpp | nickfourtimes/awndo-sdl | 8dfcfc66d28987e92fef26ff99d15a43f2d31de9 | [
"MIT"
] | null | null | null | src/DungeonMaster.cpp | nickfourtimes/awndo-sdl | 8dfcfc66d28987e92fef26ff99d15a43f2d31de9 | [
"MIT"
] | null | null | null | src/DungeonMaster.cpp | nickfourtimes/awndo-sdl | 8dfcfc66d28987e92fef26ff99d15a43f2d31de9 | [
"MIT"
] | null | null | null | #include <iostream>
#include <SDL_ttf.h>
#include "common.h"
#include "DungeonMaster.h"
#include "GarbageGobbler.h"
#include "Log.h"
#include "minigames/Born.h"
#include "minigames/Dead.h"
#include "minigames/Fuck.h"
#include "minigames/Fuzz.h"
#include "minigames/Kids.h"
#include "minigames/Play.h"
#include "minigames/Pray.h"
#include "minigames/Shop.h"
#include "minigames/Text.h"
#include "minigames/Time.h"
#include "minigames/Work.h"
///////////////////////////////////////////////////////////////////////////////
// CONSTANTS
///////////////////////////////////////////////////////////////////////////////
// sizing & placement
const Uint32 DM_TIME_BAR_H = 20; // in pixels
const Uint32 DM_MINIGAME_LABEL_X = 108;
const Uint32 DM_MINIGAME_LABEL_Y = 7;
const Uint32 DM_SCORE_LABEL_START_X = 660;
const Uint32 DM_SCORE_LABEL_Y = 7;
// timing
const Uint32 DM_LIFE_LENGTH = 5 * 60 * 1000; // in milliseconds
///////////////////////////////////////////////////////////////////////////////
// HELPERS
///////////////////////////////////////////////////////////////////////////////
int DungeonMaster::InitMinigames() {
mText = (Text*)Text::Instance();
mTime = (Time*)Time::Instance();
// pre-load each minigame
// each should return RETURN_SUCCESS = 0, so this sum should == 0
if (mText->InitialPreload() +
mTime->InitialPreload() +
Born::Instance()->InitialPreload() +
Dead::Instance()->InitialPreload() +
Fuck::Instance()->InitialPreload() +
Fuzz::Instance()->InitialPreload() +
Kids::Instance()->InitialPreload() +
Play::Instance()->InitialPreload() +
Pray::Instance()->InitialPreload() +
Shop::Instance()->InitialPreload() +
Work::Instance()->InitialPreload() != 0) {
return RETURN_ERROR;
}
// place minigame title above-left of the main game frame, Samhayne
mMinigameNameRect.x = DM_MINIGAME_LABEL_X;
mMinigameNameRect.y = DM_MINIGAME_LABEL_Y;
return RETURN_SUCCESS;
}
void DungeonMaster::GenerateTutorialSurfaces() {
// render the actual text
mTutSignGood = TTF_RenderText_Shaded(SMALL_FONT, "TUTORIAL", SDL_CLR_BLACK, SDL_CLR_WHITE);
mTutSignBad = TTF_RenderText_Shaded(SMALL_FONT, "TUTORIAL", SDL_CLR_WHITE, SDL_CLR_BLACK);
if (!mTutSignGood || !mTutSignBad) {
char msg[256];
sprintf(msg, "ERROR: Could not render TUTORIAL labels (%s)!\n", TTF_GetError());
mLog->LogMsg(msg);
}
// figure out where these signs will be placed
GetMiniFramePixel(125, 0, &mTutSignRect);
mTutSignRect.x += 6 * PIXELW - mTutSignGood->w;
mTutSignRect.y = DM_MINIGAME_LABEL_Y;
}
void DungeonMaster::GenerateScoreSurfaces() {
// discard the old surfaces
GarbageGobbler::Instance()->Discard(mPlayerScoreGoodSfc);
GarbageGobbler::Instance()->Discard(mPlayerScoreBadSfc);
mPlayerScoreGoodSfc = mPlayerScoreBadSfc = NULL;
// create the new string
char scoreStr[256];
sprintf(scoreStr, "Score: %d", (int)mPlayerScore);
// render the scores
mPlayerScoreGoodSfc = TTF_RenderText_Shaded(SMALL_FONT, scoreStr, SDL_CLR_BLACK, SDL_CLR_WHITE);
mPlayerScoreBadSfc = TTF_RenderText_Shaded(SMALL_FONT, scoreStr, SDL_CLR_WHITE, SDL_CLR_BLACK);
if (!mPlayerScoreGoodSfc || !mPlayerScoreBadSfc) {
char msg[256];
sprintf(msg, "ERROR: Could not render player scores (%s)!\n", TTF_GetError());
mLog->LogMsg(msg);
}
// place the player score (above-right of minigame frame), adjusting for string length
mPlayerScoreRect.x = DM_SCORE_LABEL_START_X - mPlayerScoreGoodSfc->w;
mPlayerScoreRect.y = DM_SCORE_LABEL_Y;
}
void DungeonMaster::SelectHUDInfo() {
// render the game name, the score, and the TUTORIAL sign as necessary
switch (mCurrentMinigame->GetMinigameType()) {
case MINIGAME_GOOD:
mMinigameNameSfc = TTF_RenderText_Shaded(SMALL_FONT, mCurrentMinigame->GetTitle(), SDL_CLR_BLACK, SDL_CLR_WHITE);
mTutSignSfc = mTutSignGood;
mRenderedScoreSfc = mPlayerScoreGoodSfc;
break;
case MINIGAME_BAD:
mMinigameNameSfc = TTF_RenderText_Shaded(SMALL_FONT, mCurrentMinigame->GetTitle(), SDL_CLR_WHITE, SDL_CLR_BLACK);
mTutSignSfc = mTutSignBad;
mRenderedScoreSfc = mPlayerScoreBadSfc;
break;
case MINIGAME_NEUTRAL: // definitely do NOT show HUD for TEXT, TIME, or FUZZ
mRenderedScoreSfc = mTutSignSfc = mMinigameNameSfc = NULL;
return;
}
// check if we successfully rendered the minigame label
if (!mMinigameNameSfc && mCurrentMinigame->GetMinigameType() != MINIGAME_NEUTRAL) {
char msg[256];
sprintf(msg, "ERROR: Could not render minigame name (%s)!\n", TTF_GetError());
mLog->LogMsg(msg);
}
}
bool DungeonMaster::IsRealLife() {
return (mCurrentGameState == STATE_BIRTH ||
mCurrentGameState == STATE_LIFE ||
mCurrentGameState == STATE_DEATH);
}
void DungeonMaster::SwitchToMinigame(Minigame* mg) {
mCurrentMinigame->EndMinigame();
mCurrentMinigame = mg;
mCurrentMinigame->NewMinigame(this->IsRealLife());
}
void DungeonMaster::CheckMinigameTimeRemaining() {
// if minigame time has run out, go back to clock
if (mCurrentMinigame->IsTimed()) {
if (mCurrentMinigame->HasTimedOut()) {
// fuzz out, which will get us back to the clock
this->SwitchToMinigame(Fuzz::Instance());
}
}
}
void DungeonMaster::CheckLifeTimeRemaining() {
Uint32 elapsedGameTime = SDL_GetTicks() - mLifeStartTime;
// if too much time has passed, GAME OVER
if (mCurrentGameState != STATE_DEATH && elapsedGameTime >= DM_LIFE_LENGTH) {
mCurrentGameState = STATE_DEATH;
this->SwitchToMinigame(Fuzz::Instance());
} else { // otherwise, just render the appropriate game time bar
mLifeTimeLeftRect.w = (int)(192 * (1 - ((float)elapsedGameTime / (float)DM_LIFE_LENGTH))) * PIXELW;
}
}
void DungeonMaster::StartLife() {
mLifeStartTime = SDL_GetTicks();
mPlayerScore = 0;
this->GenerateScoreSurfaces(); // re-render player scores
this->NextLifeMinigame(); // will go to BORN
}
void DungeonMaster::NextLifeMinigame() {
switch (mCurrentGameState) {
case STATE_BIRTH:
mCurrentGameState = STATE_LIFE;
this->SwitchToMinigame(Born::Instance());
break;
case STATE_LIFE:
switch (rand() % 6) { // choose a random minigame to go to
case 0:
this->SwitchToMinigame(Work::Instance());
break;
case 1:
this->SwitchToMinigame(Play::Instance());
break;
case 2:
this->SwitchToMinigame(Shop::Instance());
break;
case 3:
this->SwitchToMinigame(Fuck::Instance());
break;
case 4:
this->SwitchToMinigame(Kids::Instance());
break;
case 5:
this->SwitchToMinigame(Pray::Instance());
break;
}
break;
case STATE_DEATH: // if we're going to death, just die
this->SwitchToMinigame(Dead::Instance());
break;
default:
char msg[256];
sprintf(msg, "ERROR: DM attempting to go to new minigame in non-LIFE state!\n");
mLog->LogMsg(msg);
break;
}
}
void DungeonMaster::PrepareTitleText() {
mCurrentMinigame = mText;
mText->NewMinigame(this->IsRealLife());
mText->GiveNormalString("THE AMERICAN DREAM");
mText->GiveSmallString("Are We Not Drawn");
mText->GiveSmallString("Onward To New Era?");
mText->GiveSmallString(" ");
// formerly...
//mText->GiveSmallString("a game for GAMM4");
//mText->GiveSmallString("by");
//mText->GiveSmallString("newton64");
// formerly...
//mText->GiveSmallString("a game for Eastern Bloc\'s");
//mText->GiveSmallString("\'Housewarming Party\'");
//mText->GiveSmallString("september 7 to 11, 2011");
//mText->GiveSmallString("by");
//mText->GiveSmallString("nick rudzicz");
mText->GiveSmallString("a game for the world");
mText->GiveSmallString("by");
mText->GiveSmallString("nick nick nick nick");
}
void DungeonMaster::PrepareLifeText() {
mCurrentMinigame = mText;
mText->NewMinigame(this->IsRealLife());
mText->GiveNormalString("LIFE");
mText->GiveNormalString(" ");
mText->GiveSmallString("engage le jeu,");
mText->GiveSmallString("que je le gagne.");
}
void DungeonMaster::PrepareGameOverText() {
mCurrentMinigame = mText;
mText->NewMinigame(this->IsRealLife());
mText->GiveNormalString("IN GIRUM IMUS NOCTE");
mText->GiveNormalString("ET CONSUMMIMUR IGNI");
mText->GiveNormalString(" ");
mText->GiveSmallString("we wander in the night");
mText->GiveSmallString("and are consumed by fire");
}
///////////////////////////////////////////////////////////////////////////////
// {CON|DE}STRUCTORS
///////////////////////////////////////////////////////////////////////////////
DungeonMaster::DungeonMaster() {
mLog = Log::Instance();
}
DungeonMaster::~DungeonMaster() {
}
///////////////////////////////////////////////////////////////////////////////
// METHODS
///////////////////////////////////////////////////////////////////////////////
DungeonMaster* DungeonMaster::Instance() {
static DungeonMaster mInstance;
return &mInstance;
}
int DungeonMaster::InitScreen(Uint32 w, Uint32 h, Uint32 b, Uint32 f) {
if ((mMainScreen = SDL_SetVideoMode(w, h, b, f)) == NULL) {
Log* log = Log::Instance();
char msg[256];
sprintf(msg, "ERROR: DM could not set video mode (%s)!\n", SDL_GetError());
log->LogMsg(msg);
return RETURN_ERROR;
}
return RETURN_SUCCESS;
}
SDL_Surface* DungeonMaster::GetScreen() {
return mMainScreen;
}
int DungeonMaster::InitGame() {
// load all game fonts
if (LoadAllFonts() != RETURN_SUCCESS) {
char msg[256];
sprintf(msg, "ERROR: Could not load system fonts!\n");
mLog->LogMsg(msg);
return RETURN_ERROR;
}
// initialise all minigames
if (this->InitMinigames() != RETURN_SUCCESS) {
char msg[256];
sprintf(msg, "ERROR: Could not initialise minigames!\n");
mLog->LogMsg(msg);
return RETURN_ERROR;
}
// render tutorial signs
this->GenerateTutorialSurfaces();
// render the player score
mPlayerScore = 0;
this->GenerateScoreSurfaces();
// defaults
mLifeTimeLeftRect.x = 0;
mLifeTimeLeftRect.y = SCREEN_H - DM_TIME_BAR_H - PIXELH;
mLifeTimeLeftRect.h = DM_TIME_BAR_H;
// display the title screen when we first start up
mCurrentGameState = STATE_TITLE;
this->PrepareTitleText();
return RETURN_SUCCESS;
}
float DungeonMaster::GetPlayerScore() {
return mPlayerScore;
}
void DungeonMaster::ModifyPlayerScore(float pts) {
// modify the score
mPlayerScore += pts;
if (mPlayerScore < 0) {
mPlayerScore = 0;
}
// redraw the score on the game background
this->GenerateScoreSurfaces();
this->SelectHUDInfo();
}
void DungeonMaster::EndMinigame(Minigame* m) {
if (m == mText) { // finished showing some kind of text
switch (mCurrentGameState) {
case STATE_TITLE: // finished showing titles, move to TIME
mCurrentGameState = STATE_CLOCK;
this->SwitchToMinigame(mTime);
break;
case STATE_TUTORIAL: // finished showing instructions, do minigame tutorial
this->SwitchToMinigame(mTime->GetMinigame());
break;
case STATE_BIRTH: // shown life text, begin LIFE itself
this->StartLife();
break;
case STATE_GAMEOVER: // shown GAME OVER, move back to credits
mCurrentMinigame->EndMinigame();
mCurrentGameState = STATE_TITLE;
this->PrepareTitleText();
break;
default:
mLog->LogMsg("WARNING: TEXT ended in strange game state!\n");
break;
}
} else if (m == mTime) { // looking at the clock; either do minigame tutorial, or begin LIFE
if (mTime->BeginLife()) {
// beginning life itself!
mCurrentGameState = STATE_BIRTH;
mLog->LogMsg("Go go gadget\n");
this->PrepareLifeText();
} else if (mTime->Quit()) { // QUIT was selected
return; // do nothing, wait for DM loop to terminate in main.cpp
} else { // start a minigame tutorial
mCurrentGameState = STATE_TUTORIAL;
this->SwitchToMinigame(mText); // show minigame instructions
// give TEXT the title and instructions for the minigame tutorial
mText->GiveNormalString(mTime->GetMinigame()->GetTitle());
mText->GiveNormalString(" ");
vector<const char*> v = mTime->GetMinigame()->GetInstructions();
for (unsigned int i = 0; i < v.size(); ++i) {
mText->GiveSmallString(v[i]);
}
}
} else if (m == Fuzz::Instance()) { // finished fuzzing something out
switch (mCurrentGameState) {
case STATE_TUTORIAL: // fuzz after a tutorial, go back to clock
mCurrentGameState = STATE_CLOCK;
this->SwitchToMinigame(mTime);
break;
case STATE_BIRTH: // FALLTHROUGH! Both BIRTH, LIFE, and DEATH move to next minigame
case STATE_LIFE:
case STATE_DEATH:
this->NextLifeMinigame();
break;
default:
mLog->LogMsg("ERROR: Fuzz ended in strange game state!\n");
SDL_Quit();
break;
}
} else { // otherwise, this is from a minigame
if (this->IsRealLife() && m == Dead::Instance()) {
// if we just "died," then we just finished LIFE
mCurrentGameState = STATE_GAMEOVER;
this->PrepareGameOverText();
} else {
// otherwise, we just fuzz out after this minigame
this->SwitchToMinigame(Fuzz::Instance());
// fuzz shouldn't show unless we finished a tutorial or a LIFE minigame
if (mCurrentGameState != STATE_TUTORIAL && !this->IsRealLife()) {
mLog->LogMsg("ERROR: Minigame ended in strange game state!\n");
SDL_Quit();
}
}
}
// figure out which scorecard to render
this->SelectHUDInfo();
}
bool DungeonMaster::Quit() {
return mTime->Quit();
}
void DungeonMaster::Process(Uint32 ticks) {
mCurrentMinigame->Process(ticks);
}
void DungeonMaster::Update(Uint32 ticks) {
// update the current minigame
mCurrentMinigame->Update(ticks);
// if we're playing LIFE, we need to check if it has time remaining
if (this->IsRealLife() && mCurrentMinigame != mText) {
this->CheckLifeTimeRemaining();
}
// if LIFE time hasn't expired, continue and check on minigame time remaining
if (mCurrentGameState != STATE_DEATH) {
this->CheckMinigameTimeRemaining();
}
}
void DungeonMaster::Render(Uint32 ticks) {
// tell the current minigame to render stuff on the main screen
mCurrentMinigame->Render(ticks);
// this is a bad way to do this, but i'm tired
bool renderMinigameName;
bool renderTutorial, renderScore;
bool renderGoodTimeBar, renderBadTimeBar;
// rendering decisions based on the current game state
switch (mCurrentGameState) {
case STATE_TUTORIAL:
renderTutorial = true;
renderScore = false;
renderGoodTimeBar = renderBadTimeBar = false;
break;
case STATE_BIRTH:
case STATE_LIFE:
case STATE_DEATH:
renderTutorial = false;
renderScore = true;
renderGoodTimeBar = renderBadTimeBar = (mCurrentGameState != STATE_DEATH);
break;
default: // CLOCK, TITLE, GAMEOVER
renderTutorial = renderScore = renderGoodTimeBar = renderBadTimeBar = false;
break;
}
// rendering decisions based on the minigame type
switch (mCurrentMinigame->GetMinigameType()) {
case MINIGAME_GOOD:
renderMinigameName = true;
renderBadTimeBar = false;
break;
case MINIGAME_BAD:
renderMinigameName = true;
renderGoodTimeBar = false;
break;
case MINIGAME_NEUTRAL:
renderMinigameName = false;
renderTutorial = renderScore = false;
renderGoodTimeBar = renderBadTimeBar = false;
break;
}
// render the name of the minigame, Chastain
if (renderMinigameName) {
SDL_BlitSurface(mMinigameNameSfc, NULL, mMainScreen, &mMinigameNameRect);
}
// render TUTORIAL sign
if (renderTutorial) {
SDL_BlitSurface(mTutSignSfc, NULL, mMainScreen, &mTutSignRect);
}
// render player score
if (renderScore) {
SDL_BlitSurface(mRenderedScoreSfc, NULL, mMainScreen, &mPlayerScoreRect);
}
// render the global time on a good screen
if (renderGoodTimeBar) {
SDL_FillRect(mMainScreen, &mLifeTimeLeftRect, SDL_MapRGB(mMainScreen->format, SDL_CLR_BLACK));
}
// render the global time on a bad screen
if (renderBadTimeBar) {
SDL_FillRect(mMainScreen, &mLifeTimeLeftRect, SDL_MapRGB(mMainScreen->format, SDL_CLR_WHITE));
}
// if the minigame is timed, draw the minigame time bar
if (mCurrentMinigame->IsTimed()) {
// calculate the height of the timer bar based on the time remaining
int numpix = (int)((1.0f - mCurrentMinigame->FractionTimeRemaining()) * 138.0f);
SDL_Rect rect;
rect.x = 166 * PIXELW;
rect.y = (149 - numpix) * PIXELH;
rect.w = 4 * PIXELW;
rect.h = numpix * PIXELH;
switch (mCurrentMinigame->GetMinigameType()) {
case MINIGAME_GOOD:
SDL_FillRect(mMainScreen, &rect, SDL_MapRGB(mMainScreen->format, SDL_CLR_BLACK));
break;
case MINIGAME_BAD:
SDL_FillRect(mMainScreen, &rect, SDL_MapRGB(mMainScreen->format, SDL_CLR_WHITE));
break;
default:
break;
}
}
// update the screen
SDL_Flip(mMainScreen);
}
int DungeonMaster::Cleanup() {
// close down each minigame
// each should return RETURN_SUCCESS = 0, so this sum should = 0
if (mText->Cleanup() +
mTime->Cleanup() +
Born::Instance()->Cleanup() +
Dead::Instance()->Cleanup() +
Fuck::Instance()->Cleanup() +
Fuzz::Instance()->Cleanup() +
Kids::Instance()->Cleanup() +
Play::Instance()->Cleanup() +
Pray::Instance()->Cleanup() +
Shop::Instance()->Cleanup() +
Work::Instance()->Cleanup() != 0) {
return RETURN_ERROR;
}
// close all the fonts
CloseAllFonts();
return RETURN_SUCCESS;
}
| 28 | 115 | 0.690259 | [
"render",
"vector"
] |
32fc3815805edb834d8192e589ce6116b1a7a54d | 19,413 | cpp | C++ | src/fvm/src/modules/exporters/NcDataWriter.cpp | drm42/fvm-drm | c9b940e593034f1aa3020d63ff1e09ebef9c182a | [
"MIT"
] | null | null | null | src/fvm/src/modules/exporters/NcDataWriter.cpp | drm42/fvm-drm | c9b940e593034f1aa3020d63ff1e09ebef9c182a | [
"MIT"
] | null | null | null | src/fvm/src/modules/exporters/NcDataWriter.cpp | drm42/fvm-drm | c9b940e593034f1aa3020d63ff1e09ebef9c182a | [
"MIT"
] | null | null | null | // This file os part of FVM
// Copyright (c) 2012 FVM Authors
// See LICENSE file for terms.
#include <iostream>
#include <cassert>
#include <numeric>
#include "NcDataWriter.h"
#include "netcdfcpp.h"
#include "StorageSite.h"
#include "Array.h"
#include "OneToOneIndexMap.h"
#include "CRConnectivity.h"
int NcDataWriter::_writeAction = 0;
NcDataWriter::NcDataWriter( const MeshList& meshes, const string& fname )
: _meshList( meshes ), _fname( fname ), _ncFile(NULL), _xVals(NULL), _yVals(NULL), _zVals(NULL),
_gatherIndicesVals(NULL), _scatterIndicesVals(NULL), MAX_CHAR(40), BOUN_TYPE_DIM(false), NEIGH_MESH( false ), INTERFACE( false )
{
init();
}
NcDataWriter::~NcDataWriter()
{
if ( _xVals ) delete [] _xVals;
if ( _yVals ) delete [] _yVals;
if ( _zVals ) delete [] _zVals;
if ( _gatherIndicesVals ) delete [] _gatherIndicesVals;
if ( _scatterIndicesVals ) delete [] _scatterIndicesVals;
if ( _ncFile ) delete _ncFile;
}
void
NcDataWriter::record()
{
setNcFile();
setDims();
setVars();
set_var_values();
_ncFile->close();
}
//PRIVATE FUNCTIONS
void
NcDataWriter::init()
{
_writeAction++;
}
//setting NcFile
void
NcDataWriter::setNcFile()
{
assert( !_ncFile );
_ncFile = new NcFile( _fname.c_str(), NcFile::Replace );
assert ( _ncFile->is_valid() );
}
//set NcDims
//set NcDims
void
NcDataWriter::setDims()
{
_nmesh = _ncFile->add_dim("nmesh", _meshList.size() );
assert( _ncFile->add_att("nmesh", "number of total meshes") );
int index_boun = 0;
int index_interface = 0;
int nnodes = 0;
int nfaces = 0;
int ncells = 0;
int nface_row = 0;
int nfaceCells_col = 0;
int nfaceNodes_col = 0;
int ninterface = 0;
//summing up values from all meshes
for ( int id = 0; id < _nmesh->size(); id++ ){
index_boun += _meshList.at(id)->getBoundaryGroupCount();
index_interface += _meshList.at(id)->getInterfaceGroupCount();
nnodes += _meshList.at(id)->getNodes().getCount();
nfaces += _meshList.at(id)->getFaces().getCount();
ncells += _meshList.at(id)->getCells().getCount();
nface_row += _meshList.at(id)->getAllFaceCells().getRow().getLength();
nfaceCells_col += _meshList.at(id)->getAllFaceCells().getCol().getLength();
nfaceNodes_col += _meshList.at(id)->getAllFaceNodes().getCol().getLength();
const StorageSite::ScatterMap& scatterMap = _meshList.at(id)->getCells().getScatterMap();
//loop over neighbour mesh to count interfaces
StorageSite::ScatterMap::const_iterator it;
for ( it = scatterMap.begin(); it != scatterMap.end(); it++ )
ninterface += it->second->getLength();
}
if ( index_boun > 0 ){
BOUN_TYPE_DIM = true;
_nBoun = _ncFile->add_dim("boun_type_dim", index_boun );
assert( _ncFile->add_att("boun_type_dim", "total count of boundary types") );
}
_charSize = _ncFile->add_dim("char_dim", MAX_CHAR );
assert( _ncFile->add_att("char_dim", "maximum capacity of char variable" ) );
if ( index_interface > 0 ){
NEIGH_MESH = true;
_nNeighMesh= _ncFile->add_dim("nNeighMesh", index_interface );
assert( _ncFile->add_att("nNeighMesh", "count of neighbour meshes") );
}
_nnodes = _ncFile->add_dim("nnodes", nnodes);
_nfaces = _ncFile->add_dim("nfaces", nfaces);
_ncells = _ncFile->add_dim("ncells", ncells);
assert( _ncFile->add_att("nnodes", "number of nodes" ) );
assert( _ncFile->add_att("nfaces", "number of faces" ) );
assert( _ncFile->add_att("ncells", "number of cells" ) );
_nfaceRow = _ncFile->add_dim("nface_row", nface_row);
_nfaceCellsCol = _ncFile->add_dim("nfaceCells_col", nfaceCells_col);
_nfaceNodesCol = _ncFile->add_dim("nfaceNodes_col", nfaceNodes_col);
assert( _ncFile->add_att("nface_row", "row dimension of face connectivity" ) );
assert( _ncFile->add_att("nfaceCells_col", "col dimension of faceCells connectivity" ) );
assert( _ncFile->add_att("nfaceNodes_col", "col dimension of faceNodes connectivity" ) );
if ( ninterface > 0 ){
INTERFACE = true;
_nInterface = _ncFile->add_dim("nInterface", ninterface);
assert( _ncFile->add_att("nInterface", "total interfaces") );
}
}
//set NcVars
void
NcDataWriter::setVars()
{
_dimension = _ncFile->add_var("dimension", ncInt, _nmesh );
_meshID = _ncFile->add_var("mesh_id" , ncInt, _nmesh );
_facesCount = _ncFile->add_var("faces_count", ncInt, _nmesh );
_cellsCount = _ncFile->add_var("cells_count", ncInt, _nmesh );
_ghostCellsCount = _ncFile->add_var("ghost_cells_count", ncInt, _nmesh);
_nodesCount = _ncFile->add_var("nodes_count", ncInt, _nmesh );
_mapCount = _ncFile->add_var("map_count", ncInt, _nmesh );
_interiorFaceGroup = _ncFile->add_var("interior_faces_group", ncInt, _nmesh);
_boundaryGroup = _ncFile->add_var("boundary_group", ncInt, _nmesh);
if ( BOUN_TYPE_DIM ){
_boundarySize = _ncFile->add_var("boundary_size", ncInt, _nBoun);
_boundaryOffset = _ncFile->add_var("boundary_offset", ncInt, _nBoun);
_boundaryID = _ncFile->add_var("boundary_id", ncInt, _nBoun);
_boundaryType = _ncFile->add_var("boundary_type", ncChar, _nBoun, _charSize );
}
_interfaceGroup = _ncFile->add_var("interface_group" , ncInt, _nmesh );
if ( NEIGH_MESH ){
_interfaceSize = _ncFile->add_var("interface_size" , ncInt, _nNeighMesh );
_interfaceOffset = _ncFile->add_var("interface_offset", ncInt, _nNeighMesh );
_interfaceID = _ncFile->add_var("interface_id" , ncInt, _nNeighMesh );
}
_x = _ncFile->add_var("x", ncDouble, _nnodes );
_y = _ncFile->add_var("y", ncDouble, _nnodes );
_z = _ncFile->add_var("z", ncDouble, _nnodes );
_faceCellsRowCount = _ncFile->add_var("face_cells_row_count", ncInt, _nmesh );
_faceCellsColCount = _ncFile->add_var("face_cells_col_count", ncInt, _nmesh );
_faceNodesRowCount = _ncFile->add_var("face_nodes_row_count", ncInt, _nmesh );
_faceNodesColCount = _ncFile->add_var("face_nodes_col_count", ncInt, _nmesh );
_faceCellsRow = _ncFile->add_var("face_cells_row", ncInt, _nfaceRow );
_faceCellsCol = _ncFile->add_var("face_cells_col", ncInt, _nfaceCellsCol );
_faceNodesRow = _ncFile->add_var("face_nodes_row", ncInt, _nfaceRow );
_faceNodesCol = _ncFile->add_var("face_nodes_col", ncInt, _nfaceNodesCol );
if ( INTERFACE ){
_gatherIndices = _ncFile->add_var("gather_indices", ncInt, _nInterface);
_scatterIndices = _ncFile->add_var("scatter_indices" , ncInt, _nInterface);
}
_bounBoolVar = _ncFile->add_var("is_bounTypeDim_Valid", ncInt);
_neighMeshBoolVar = _ncFile->add_var("is_neighMesh_Valid", ncInt);
_interfaceBoolVar = _ncFile->add_var("is_interface_Valid", ncInt);
}
//assign values to NcVars
void
NcDataWriter::set_var_values()
{
//get variable values from meshes
get_var_values();
//adding attirbutes
add_attributes();
//write values
write_values();
}
//getting values from meshes
//getting values from meshes
void
NcDataWriter::get_var_values()
{
assert( !_xVals );
assert( !_yVals );
assert( !_zVals );
assert( !_gatherIndicesVals );
assert( !_scatterIndicesVals );
_xVals = new double [ _nnodes->size() ];
_yVals = new double [ _nnodes->size() ];
_zVals = new double [ _nnodes->size() ];
if ( INTERFACE ){
_gatherIndicesVals = new int [ _nInterface->size() ];
_scatterIndicesVals = new int [ _nInterface->size() ];
}
for ( long id = 0; id < _nmesh->size(); id++ ){
//dimension-s
_dimensionVals.push_back( _meshList.at(id)->getDimension() );
//mesh id-s
_meshIDVals.push_back( _meshList.at(id)->getID() );
//faces, cell, and node counts
_facesCountVals.push_back( _meshList.at(id)->getFaces().getSelfCount() );
_cellsCountVals.push_back( _meshList.at(id)->getCells().getSelfCount() );
_ghostCellsCountVals.push_back( _meshList.at(id)->getCells().getCount() -
_meshList.at(id)->getCells().getSelfCount() );
_nodesCountVals.push_back( _meshList.at(id)->getNodes().getSelfCount() );
//neighbour counts
const Mesh::GhostCellSiteMap& ghostCellSiteScatterMap = _meshList.at(id)->getGhostCellSiteScatterMap();
_mapCountVals.push_back( ghostCellSiteScatterMap.size() );
//interior face counts
_interiorFaceGroupVals.push_back( _meshList.at(id)->getInteriorFaceGroup().site.getCount() );
//boundary values
get_boundary_vals( id );
//interface values
get_interface_vals( id );
//x, y, z
get_coords( id );
//connectivities
connectivities( id );
//mappers
if ( INTERFACE )
mappers( id );
}
}
//boundary face data
void
NcDataWriter::get_boundary_vals( int id )
{
//boundary face
const FaceGroupList& bounFaceList = _meshList.at(id)->getBoundaryFaceGroups();
_boundaryGroupVals.push_back ( bounFaceList.size() );
if ( BOUN_TYPE_DIM ) {
for ( int boun = 0; boun < int(bounFaceList.size()); boun++ ) {
_boundarySizeVals.push_back( bounFaceList.at(boun)->site.getCount() );
_boundaryOffsetVals.push_back( bounFaceList.at(boun)->site.getOffset() );
_boundaryIDVals.push_back( bounFaceList.at(boun)->id );
_boundaryTypeVals.push_back( bounFaceList.at(boun)->groupType.c_str() );
//assign values
_boundaryType->set_cur(boun);
assert( int(bounFaceList.at(boun)->groupType.size()) < MAX_CHAR );
_boundaryType->put( _boundaryTypeVals[boun], 1, bounFaceList.at(boun)->groupType.size() );
}
}
}
//interface data
void
NcDataWriter::get_interface_vals( int id )
{
//interface
const FaceGroupList& interfaceList = _meshList.at(id)->getInterfaceGroups();
_interfaceGroupVals.push_back ( interfaceList.size() );
if ( NEIGH_MESH ){
for ( int interface = 0; interface < int( interfaceList.size() ); interface++ ){
_interfaceSizeVals.push_back ( interfaceList.at(interface)->site.getCount() );
_interfaceOffsetVals.push_back( interfaceList.at(interface)->site.getOffset() );
_interfaceIDVals.push_back ( interfaceList.at(interface)->id );
}
}
}
//coordinate values
void
NcDataWriter::get_coords( int id )
{
int nn = _nodesCountVals.at(id);
const Mesh& mesh = *(_meshList.at(id));
const Array<Mesh::VecD3>& coord = mesh.getNodeCoordinates();
for ( int n = 0; n < nn; n++ ){
_xVals[n] = coord[n][0];
_yVals[n] = coord[n][1];
_zVals[n] = coord[n][2];
}
_x->put( _xVals, nn );
_y->put( _yVals, nn );
_z->put( _zVals, nn );
_x->set_cur( nn );
_y->set_cur( nn );
_z->set_cur( nn );
}
//connectivities
void
NcDataWriter::connectivities( int id )
{
//rows
const Mesh& mesh = *(_meshList.at(id));
const CRConnectivity& faceCells = mesh.getAllFaceCells();
const CRConnectivity& faceNodes = mesh.getAllFaceNodes();
int nRow = faceCells.getRow().getLength();
_faceCellsRowCountVals.push_back( nRow );
_faceNodesRowCountVals.push_back( nRow );
_faceCellsRow->put( reinterpret_cast<int*> (faceCells.getRow().getData()), nRow );
_faceNodesRow->put( reinterpret_cast<int*> (faceNodes.getRow().getData()), nRow );
_faceCellsRow->set_cur( nRow );
_faceNodesRow->set_cur( nRow );
//cols
int coldim = faceCells.getCol().getLength();
_faceCellsColCountVals.push_back ( coldim );
_faceCellsCol->put( reinterpret_cast<int*> (faceCells.getCol().getData()), coldim );
_faceCellsCol->set_cur( coldim );
//cols (faceNodes)
coldim = faceNodes.getCol().getLength();
_faceNodesColCountVals.push_back( coldim );
_faceNodesCol->put( reinterpret_cast<int*> (faceNodes.getCol().getData()), coldim );
_faceNodesCol->set_cur( coldim );
}
//MappersMap
void
NcDataWriter::mappers( int id )
{
const StorageSite::ScatterMap& cellScatterMap = _meshList.at(id)->getCells().getScatterMap();
const Mesh::GhostCellSiteMap & ghostCellSiteScatterMap = _meshList.at(id)->getGhostCellSiteScatterMap();
StorageSite::ScatterMap::const_iterator it_scatterMap;
Mesh::GhostCellSiteMap::const_iterator it_siteScatter;
int indx = mappers_index( id );
for ( it_siteScatter = ghostCellSiteScatterMap.begin(); it_siteScatter != ghostCellSiteScatterMap.end(); it_siteScatter++ ){
const StorageSite* site = it_siteScatter->second.get();
it_scatterMap = cellScatterMap.find( site );
int nend = it_scatterMap->second->getLength();
for ( int n = 0; n < nend; n++ ){
_scatterIndicesVals[indx] = (*it_scatterMap->second)[n];
indx++;
}
}
const StorageSite::GatherMap& cellGatherMap = _meshList.at(id)->getCells().getGatherMap();
const Mesh::GhostCellSiteMap & ghostCellSiteGatherMap = _meshList.at(id)->getGhostCellSiteGatherMap();
StorageSite::GatherMap ::const_iterator it_gatherMap;
Mesh::GhostCellSiteMap::const_iterator it_siteGather;
indx = mappers_index( id );
for ( it_siteGather = ghostCellSiteGatherMap.begin(); it_siteGather != ghostCellSiteGatherMap.end(); it_siteGather++ ){
const StorageSite* site = it_siteGather->second.get();
it_gatherMap = cellGatherMap.find( site );
int nend = it_gatherMap->second->getLength();
for ( int n = 0; n < nend; n++ ){
_gatherIndicesVals[indx] = (*it_gatherMap->second)[n];
indx++;
}
}
}
//mappers index
int
NcDataWriter::mappers_index( int mesh_end )
{
int ninterface = 0;
for ( int id = 0; id < mesh_end; id++ ){
const StorageSite::ScatterMap& scatterMap = _meshList.at(id)->getCells().getScatterMap();
//loop over neighbour mesh to count interfaces
StorageSite::ScatterMap::const_iterator it;
for ( it = scatterMap.begin(); it != scatterMap.end(); it++ )
ninterface += it->second->getLength();
}
return ninterface;
}
//attributes
void
NcDataWriter::add_attributes()
{
//add attributies
assert( _dimension->add_att("dim", "dimension of meshes, 1:1D, 2:2D, 3:3D." ) );
assert( _meshID->add_att("id", " mesh identificaton index" ) );
assert( _facesCount->add_att("StorageSite", "number of faces") );
assert( _cellsCount->add_att("StorageSite", "number of cells ") );
assert( _ghostCellsCount->add_att("StorageSite", "number of ghost cells") );
assert( _nodesCount->add_att("StorageSite", "number of nodes") );
assert( _mapCount->add_att("neigh_count", "total neighboorhood mesh counts") );
assert( _interiorFaceGroup->add_att("interior_face_group", "total interior faces") );
assert( _boundaryGroup->add_att("boundary_group", " total boundary faces") );
if ( BOUN_TYPE_DIM ){
assert( _boundarySize->add_att("boundary_size", " size of boundary" ) );
assert( _boundaryOffset->add_att("boundary_offset", " offset of boundary" ) );
assert( _boundaryID->add_att("boundary_id", " boundary id " ) );
assert( _boundaryType->add_att("boundary_type", " type of boundary condition ") );
}
assert( _interfaceGroup->add_att("interface_group", " total interfaces") );
if ( NEIGH_MESH ){
assert( _interfaceSize->add_att("interface_size", " size of interface" ) );
assert( _interfaceOffset->add_att("interface_offset", " offset of interface" ) );
assert( _interfaceID->add_att("interface_id", " interface id " ) );
}
assert( _x->add_att("x", "x-coordinate") );
assert( _y->add_att("y", "y-coordinate") );
assert( _z->add_att("z", "z-coordinate") );
assert( _faceCellsRowCount->add_att("face_cells_row_count", "count of row values of faceCells CRconnctivities") );
assert( _faceNodesRowCount->add_att("face_nodes_row_count", "count of row values of faceNodes CRconnctivities") );
assert( _faceCellsColCount->add_att("face_cells_col_count", "count of col values of faceCells CRconnctivities") );
assert( _faceNodesColCount->add_att("face_nodes_col_count", "count of col values of faceNodes CRconnctivities") );
assert( _faceCellsRow->add_att("face_cells_row", "row values of faceCells CRconnctivities") );
assert( _faceNodesRow->add_att("face_nodes_row", "row values of faceNodes CRconnctivities") );
assert( _faceCellsCol->add_att("face_cells_col", "col values of faceCells CRconnctivities") );
assert( _faceNodesCol->add_att("face_nodes_col", "col values of faceNodes CRconnctivities") );
if ( INTERFACE ){
assert( _gatherIndices->add_att("from_indices", "trom indices from other neightbour mesh " ) );
assert( _scatterIndices->add_att("to_indices", "to indices in current mesh") );
}
}
//write values
void
NcDataWriter::write_values()
{
_dimension->put( &_dimensionVals[0], _nmesh->size() );
_meshID->put( &_meshIDVals[0], _nmesh->size() );
_facesCount->put( &_facesCountVals[0], _nmesh->size() );
_cellsCount->put( &_cellsCountVals[0], _nmesh->size() );
_ghostCellsCount->put( &_ghostCellsCountVals[0], _nmesh->size() );
_nodesCount->put( &_nodesCountVals[0], _nmesh->size() );
_mapCount->put( &_mapCountVals[0], _nmesh->size() );
_interiorFaceGroup->put( &_interiorFaceGroupVals[0], _nmesh->size() );
_boundaryGroup->put(&_boundaryGroupVals[0], _nmesh->size() );
if ( BOUN_TYPE_DIM ){
_boundarySize->put( &_boundarySizeVals[0], _boundarySizeVals.size() );
_boundaryOffset->put( &_boundaryOffsetVals[0], _boundaryOffsetVals.size() );
_boundaryID->put( &_boundaryIDVals[0], _boundaryIDVals.size() );
}
_interfaceGroup->put(&_interfaceGroupVals[0], _nmesh->size() );
if ( NEIGH_MESH ){
_interfaceSize->put( &_interfaceSizeVals[0], _interfaceSizeVals.size() );
_interfaceOffset->put( &_interfaceOffsetVals[0], _interfaceOffsetVals.size() );
_interfaceID->put( &_interfaceIDVals[0], _interfaceIDVals.size() );
}
_faceCellsRowCount->put( &_faceCellsRowCountVals[0], _nmesh->size() );
_faceCellsColCount->put( &_faceCellsColCountVals[0], _nmesh->size() );
_faceNodesRowCount->put( &_faceNodesRowCountVals[0], _nmesh->size() );
_faceNodesColCount->put( &_faceNodesColCountVals[0], _nmesh->size() );
if ( INTERFACE ){
_gatherIndices->put( _gatherIndicesVals, _nInterface->size() );
_scatterIndices->put( _scatterIndicesVals, _nInterface->size() );
}
int boun_bool = int( BOUN_TYPE_DIM );
int neigh_bool= int( NEIGH_MESH );
int interface_bool = int ( INTERFACE );
_bounBoolVar->put( &boun_bool );
_neighMeshBoolVar->put( &neigh_bool );
_interfaceBoolVar->put( &interface_bool );
}
| 36.285981 | 129 | 0.65044 | [
"mesh",
"3d"
] |
fd0e1f54bb5e8f780b242a729ef9c7b67b4060d7 | 2,119 | cpp | C++ | renderer/vertex_array/VertexArray.cpp | hyper1423/SomeFPS | dcd353124d58e2696be7eaf44cddec17d6259629 | [
"BSD-3-Clause"
] | null | null | null | renderer/vertex_array/VertexArray.cpp | hyper1423/SomeFPS | dcd353124d58e2696be7eaf44cddec17d6259629 | [
"BSD-3-Clause"
] | null | null | null | renderer/vertex_array/VertexArray.cpp | hyper1423/SomeFPS | dcd353124d58e2696be7eaf44cddec17d6259629 | [
"BSD-3-Clause"
] | null | null | null | #include "vertex_array.hpp"
#include "../../logger/logger.hpp"
const VertexArray* VertexArray::lastBoundCache = nullptr;
unsigned int VertexArray::VBOLastCache = 0;
unsigned int VertexArray::IBOLastCache = 0;
VertexArray::VertexArray() {
glCreateVertexArrays(1, &VAO);
glCreateBuffers(1, &VBO);
glCreateBuffers(1, &IBO);
}
void VertexArray::setBufferAttribute(unsigned int elementsNumber,
numeralTypes::enumInt type, bool normalize, size_t stride, unsigned int offset) {
bind();
glVertexAttribPointer(VBO, elementsNumber, type, normalize, stride, reinterpret_cast<void*>(offset));
}
VertexArray& VertexArray::setVBOData(TypeVertices vertices, numeralTypes::enumInt usage) {
glNamedBufferData(VBO, vertices.size() * sizeof(TypeVertex), vertices.data(), usage);
glVertexArrayVertexBuffer(VAO, 0, VBO, 0, sizeof(TypeVertex));
glEnableVertexArrayAttrib(VAO, 0);
glEnableVertexArrayAttrib(VAO, 1);
glEnableVertexArrayAttrib(VAO, 2);
glVertexArrayAttribFormat(VAO, 0, vertexPositionSizeFloat, GL_FLOAT, GL_FALSE, vertexPositionIndexByte);
glVertexArrayAttribFormat(VAO, 1, vertexNormalSizeFloat, GL_FLOAT, GL_FALSE, vertexNormalIndexByte);
glVertexArrayAttribFormat(VAO, 2, vertexTexCoordSizeFloat, GL_FLOAT, GL_FALSE, vertexTexCoordIndexByte);
glVertexArrayAttribBinding(VAO, 0, 0);
glVertexArrayAttribBinding(VAO, 1, 0);
glVertexArrayAttribBinding(VAO, 2, 0);
return *this;
}
VertexArray& VertexArray::setIBOData(TypeIndices indexes, numeralTypes::enumInt usage) {
std::vector<unsigned short> indicesVector;
for (std::array<unsigned short, 3>& face : indexes) {
for (float element : face) {
indicesVector.push_back(element);
}
}
glNamedBufferData(IBO, indicesVector.size() * sizeof(unsigned short), indicesVector.data(), usage);
glVertexArrayElementBuffer(VAO, IBO);
return *this;
}
unsigned int VertexArray::getID() const {
return VAO;
}
unsigned int VertexArray::getVBO() const {
return VBO;
}
unsigned int VertexArray::getIBO() const {
return IBO;
}
void VertexArray::bind() const {
if (this != lastBoundCache) {
glBindVertexArray(VAO);
lastBoundCache = this;
}
} | 29.84507 | 105 | 0.766871 | [
"vector"
] |
fd1b2078bbefaf6351d494754c063186a0920f2b | 9,912 | cpp | C++ | SGPLibraryCode/modules/sgp_math/math/sgp_Ray.cpp | phoenixzz/VoronoiMapGen | 5afd852f8bb0212baba9d849178eb135f62df903 | [
"MIT"
] | 11 | 2017-03-03T03:31:15.000Z | 2019-03-01T17:09:12.000Z | SGPLibraryCode/modules/sgp_math/math/sgp_Ray.cpp | phoenixzz/VoronoiMapGen | 5afd852f8bb0212baba9d849178eb135f62df903 | [
"MIT"
] | null | null | null | SGPLibraryCode/modules/sgp_math/math/sgp_Ray.cpp | phoenixzz/VoronoiMapGen | 5afd852f8bb0212baba9d849178eb135f62df903 | [
"MIT"
] | 2 | 2017-03-03T03:31:17.000Z | 2021-05-27T21:50:43.000Z |
// transform ray into matrix space
void Ray::DeTransform(const Matrix4x4 &_m)
{
Matrix4x4 mInv;
Matrix4x4 m = _m;
// invert translation
m_vcOrig.x -= m._41;
m_vcOrig.y -= m._42;
m_vcOrig.z -= m._43;
// delete it from matrix
m._41 = m._42 = m._43 = 0.0f;
// invert matrix and applay to ray
mInv.InverseOf(m);
m_vcOrig = m_vcOrig * mInv;
m_vcDir = m_vcDir * mInv;
}
// test for intersection with triangle
bool Ray::Intersects(const Vector3D &vc0, const Vector3D &vc1, const Vector3D &vc2, bool bCull, float *t)
{
Vector3D pvec, tvec, qvec;
Vector3D edge1 = vc1 - vc0;
Vector3D edge2 = vc2 - vc0;
pvec.Cross(m_vcDir, edge2);
// if close to 0 ray is parallel
float det = edge1 * pvec;
if( (bCull) && (det < 0.0001f) )
return false;
else if( (det < 0.0001f) && (det > -0.0001f) )
return false;
// distance to plane, < 0 means beyond plane
tvec = m_vcOrig - vc0;
float u = tvec * pvec;
if(u < 0.0f || u > det)
return false;
qvec.Cross(tvec, edge1);
float v = m_vcDir * qvec;
if(v < 0.0f || u+v > det)
return false;
if(t)
{
*t = edge2 * qvec;
float fInvDet = 1.0f / det;
*t *= fInvDet;
}
return true;
}
// test for intersection with triangle at certain length (line segment),
// same as above but test distance to intersection vs segment length.
bool Ray::Intersects(const Vector3D &vc0, const Vector3D &vc1, const Vector3D &vc2, bool bCull, float fL, float *t)
{
Vector3D pvec, tvec, qvec;
Vector3D edge1 = vc1 - vc0;
Vector3D edge2 = vc2 - vc0;
pvec.Cross(m_vcDir, edge2);
// if close to 0 ray is parallel
float det = edge1 * pvec;
if( bCull && (det < 0.0001f) )
return false;
else if( (det < 0.0001f) && (det > -0.0001f) )
return false;
// distance to plane, < 0 means beyond plane
tvec = m_vcOrig - vc0;
float u = tvec * pvec;
if(u < 0.0f || u > det)
return false;
qvec.Cross(tvec, edge1);
float v = m_vcDir * qvec;
if(v < 0.0f || u+v > det)
return false;
if(t)
{
*t = edge2 * qvec;
float fInvDet = 1.0f / det;
*t *= fInvDet;
// collision but not on segment?
if(*t > fL)
return false;
}
else
{
// collision but not on segment?
float f = (edge2*qvec) * (1.0f / det);
if(f > fL)
return false;
}
return true;
}
// Intersection with Plane from origin till infinity.
bool Ray::Intersects(const Plane &plane, bool bCull, float *t, Vector3D *vcHit)
{
float Vd = plane.m_vcNormal * m_vcDir;
// ray parallel to plane
if( fabs(Vd) < 0.00001f )
return false;
// normal pointing away from ray dir
// => intersection backface if any
if( bCull && (Vd > 0.0f) )
return false;
float Vo = -( (plane.m_vcNormal * m_vcOrig) + plane.m_fDistance);
float _t = Vo / Vd;
// intersection behind ray origin
if(_t < 0.0f)
return false;
if(vcHit)
{
(*vcHit) = m_vcOrig + (m_vcDir * _t);
}
if(t)
(*t) = _t;
return true;
}
/*----------------------------------------------------------------*/
// Intersection with Plane at distance fL.
bool Ray::Intersects(const Plane &plane, bool bCull, float fL, float *t, Vector3D *vcHit)
{
float Vd = plane.m_vcNormal * m_vcDir;
// ray parallel to plane
if( fabs(Vd) < 0.00001f )
return false;
// normal pointing away from ray dir
// => intersection backface if any
if( bCull && (Vd > 0.0f) )
return false;
float Vo = -( (plane.m_vcNormal * m_vcOrig) + plane.m_fDistance);
float _t = Vo / Vd;
// intersection behind ray origin or beyond valid range
if( (_t < 0.0f) || (_t > fL) )
return false;
if(vcHit)
{
(*vcHit) = m_vcOrig + (m_vcDir * _t);
}
if(t)
(*t) = _t;
return true;
}
// test for intersection with aabb, original code by Andrew Woo,
// from "Geometric Tools...", Morgan Kaufmann Publ., 2002
bool Ray::Intersects(const AABBox &aabb, float *t)
{
float t0, t1, tmp;
float tNear = -999999.9f;
float tFar = 999999.9f;
float epsilon = 0.00001f;
// first pair of planes
if(fabs(m_vcDir.x) < epsilon)
{
if( (m_vcOrig.x < aabb.vcMin.x) || (m_vcOrig.x > aabb.vcMax.x) )
return false;
}
t0 = (aabb.vcMin.x - m_vcOrig.x) / m_vcDir.x;
t1 = (aabb.vcMax.x - m_vcOrig.x) / m_vcDir.x;
if(t0 > t1) { tmp=t0; t0=t1; t1=tmp; }
if(t0 > tNear) tNear = t0;
if(t1 < tFar) tFar = t1;
if(tNear > tFar) return false;
if(tFar < 0) return false;
// second pair of planes
if(fabs(m_vcDir.y) < epsilon)
{
if( (m_vcOrig.y < aabb.vcMin.y) || (m_vcOrig.y > aabb.vcMax.y) )
return false;
}
t0 = (aabb.vcMin.y - m_vcOrig.y) / m_vcDir.y;
t1 = (aabb.vcMax.y - m_vcOrig.y) / m_vcDir.y;
if(t0 > t1) { tmp=t0; t0=t1; t1=tmp; }
if(t0 > tNear) tNear = t0;
if(t1 < tFar) tFar = t1;
if(tNear > tFar) return false;
if(tFar < 0) return false;
// third pair of planes
if(fabs(m_vcDir.z) < epsilon)
{
if( (m_vcOrig.z < aabb.vcMin.z) || (m_vcOrig.z > aabb.vcMax.z) )
return false;
}
t0 = (aabb.vcMin.z - m_vcOrig.z) / m_vcDir.z;
t1 = (aabb.vcMax.z - m_vcOrig.z) / m_vcDir.z;
if(t0 > t1) { tmp=t0; t0=t1; t1=tmp; }
if(t0 > tNear) tNear = t0;
if(t1 < tFar) tFar = t1;
if(tNear > tFar) return false;
if(tFar < 0) return false;
if(tNear > 0)
{
if(t)
*t = tNear;
}
else
{
if(t)
*t = tFar;
}
return true;
}
// test for intersection with aabb, original code by Andrew Woo,
// from "Geometric Tools...", Morgan Kaufmann Publ., 2002
bool Ray::Intersects(const AABBox &aabb, float fL, float *t)
{
float t0, t1, tmp, tFinal;
float tNear = -999999.9f;
float tFar = 999999.9f;
float epsilon = 0.00001f;
// first pair of planes
if(fabs(m_vcDir.x) < epsilon)
{
if( (m_vcOrig.x < aabb.vcMin.x) || (m_vcOrig.x > aabb.vcMax.x) )
return false;
}
t0 = (aabb.vcMin.x - m_vcOrig.x) / m_vcDir.x;
t1 = (aabb.vcMax.x - m_vcOrig.x) / m_vcDir.x;
if (t0 > t1) { tmp=t0; t0=t1; t1=tmp; }
if (t0 > tNear) tNear = t0;
if (t1 < tFar) tFar = t1;
if (tNear > tFar) return false;
if (tFar < 0) return false;
// second pair of planes
if(fabs(m_vcDir.y) < epsilon)
{
if( (m_vcOrig.y < aabb.vcMin.y) || (m_vcOrig.y > aabb.vcMax.y) )
return false;
}
t0 = (aabb.vcMin.y - m_vcOrig.y) / m_vcDir.y;
t1 = (aabb.vcMax.y - m_vcOrig.y) / m_vcDir.y;
if(t0 > t1) { tmp=t0; t0=t1; t1=tmp; }
if(t0 > tNear) tNear = t0;
if(t1 < tFar) tFar = t1;
if(tNear > tFar) return false;
if(tFar < 0) return false;
// third pair of planes
if(fabs(m_vcDir.z) < epsilon)
{
if( (m_vcOrig.z < aabb.vcMin.z) || (m_vcOrig.z > aabb.vcMax.z) )
return false;
}
t0 = (aabb.vcMin.z - m_vcOrig.z) / m_vcDir.z;
t1 = (aabb.vcMax.z - m_vcOrig.z) / m_vcDir.z;
if(t0 > t1) { tmp=t0; t0=t1; t1=tmp; }
if(t0 > tNear) tNear = t0;
if(t1 < tFar) tFar = t1;
if(tNear > tFar) return false;
if(tFar < 0) return false;
if(tNear > 0)
tFinal = tNear;
else
tFinal = tFar;
if(tFinal > fL)
return false;
if(t)
*t = tFinal;
return true;
}
// test for intersection with obb, slaps method
bool Ray::Intersects(const OBBox &obb, float *t)
{
float e, f, t1, t2, temp;
float tmin = -99999.9f, tmax = +99999.9f;
Vector3D vcP = obb.vcCenter - m_vcOrig;
// 1st slap
e = obb.vcA0 * vcP;
f = obb.vcA0 * m_vcDir;
if(fabs(f) > 0.00001f)
{
t1 = (e + obb.fA0) / f;
t2 = (e - obb.fA0) / f;
if(t1 > t2) { temp=t1; t1=t2; t2=temp; }
if(t1 > tmin) tmin = t1;
if(t2 < tmax) tmax = t2;
if(tmin > tmax) return false;
if(tmax < 0.0f) return false;
}
else if( ((-e - obb.fA0) > 0.0f) || ((-e + obb.fA0) < 0.0f) )
return false;
// 2nd slap
e = obb.vcA1 * vcP;
f = obb.vcA1 * m_vcDir;
if(fabs(f) > 0.00001f)
{
t1 = (e + obb.fA1) / f;
t2 = (e - obb.fA1) / f;
if(t1 > t2) { temp=t1; t1=t2; t2=temp; }
if(t1 > tmin) tmin = t1;
if(t2 < tmax) tmax = t2;
if(tmin > tmax) return false;
if(tmax < 0.0f) return false;
}
else if( ((-e - obb.fA1) > 0.0f) || ((-e + obb.fA1) < 0.0f) )
return false;
// 3rd slap
e = obb.vcA2 * vcP;
f = obb.vcA2 * m_vcDir;
if(fabs(f) > 0.00001f)
{
t1 = (e + obb.fA2) / f;
t2 = (e - obb.fA2) / f;
if(t1 > t2) { temp=t1; t1=t2; t2=temp; }
if(t1 > tmin) tmin = t1;
if(t2 < tmax) tmax = t2;
if(tmin > tmax) return false;
if(tmax < 0.0f) return false;
}
else if( ((-e - obb.fA2) > 0.0f) || ((-e + obb.fA2) < 0.0f) )
return false;
if(tmin > 0.0f)
{
if(t)
*t = tmin;
return true;
}
if(t)
*t = tmax;
return true;
}
// test for intersection with obb at certain length (line segment),
// slaps method but compare result if true to length prior return.
bool Ray::Intersects(const OBBox &obb, float fL, float *t)
{
float e, f, t1, t2, temp;
float tmin = -99999.9f, tmax = +99999.9f;
Vector3D vcP = obb.vcCenter - m_vcOrig;
// 1st slap
e = obb.vcA0 * vcP;
f = obb.vcA0 * m_vcDir;
if(fabs(f) > 0.00001f)
{
t1 = (e + obb.fA0) / f;
t2 = (e - obb.fA0) / f;
if(t1 > t2) { temp=t1; t1=t2; t2=temp; }
if(t1 > tmin) tmin = t1;
if(t2 < tmax) tmax = t2;
if(tmin > tmax) return false;
if(tmax < 0.0f) return false;
}
else if( ((-e - obb.fA0) > 0.0f) || ((-e + obb.fA0) < 0.0f) )
return false;
// 2nd slap
e = obb.vcA1 * vcP;
f = obb.vcA1 * m_vcDir;
if(fabs(f) > 0.00001f)
{
t1 = (e + obb.fA1) / f;
t2 = (e - obb.fA1) / f;
if(t1 > t2) { temp=t1; t1=t2; t2=temp; }
if(t1 > tmin) tmin = t1;
if(t2 < tmax) tmax = t2;
if(tmin > tmax) return false;
if(tmax < 0.0f) return false;
}
else if( ((-e - obb.fA1) > 0.0f) || ((-e + obb.fA1) < 0.0f) )
return false;
// 3rd slap
e = obb.vcA2 * vcP;
f = obb.vcA2 * m_vcDir;
if(fabs(f) > 0.00001f)
{
t1 = (e + obb.fA2) / f;
t2 = (e - obb.fA2) / f;
if(t1 > t2) { temp=t1; t1=t2; t2=temp; }
if(t1 > tmin) tmin = t1;
if(t2 < tmax) tmax = t2;
if(tmin > tmax) return false;
if(tmax < 0.0f) return false;
}
else if( ((-e - obb.fA2) > 0.0f) || ((-e + obb.fA2) < 0.0f) )
return false;
if( (tmin > 0.0f) && (tmin <= fL) )
{
if (t)
*t = tmin;
return true;
}
// intersection on line but not on segment
if(tmax > fL)
return false;
if(t)
*t = tmax;
return true;
} | 21.547826 | 116 | 0.589487 | [
"transform"
] |
fd1b974eb92ca6237b0beb737ee04229d92e288a | 5,288 | cpp | C++ | examples/KF/EKF.cpp | shaolinbit/minisam_lib | e2e904d1b6753976de1dee102f0b53e778c0f880 | [
"BSD-3-Clause"
] | 104 | 2019-06-23T14:45:20.000Z | 2022-03-20T12:45:29.000Z | examples/KF/EKF.cpp | shaolinbit/minisam_lib | e2e904d1b6753976de1dee102f0b53e778c0f880 | [
"BSD-3-Clause"
] | 2 | 2019-06-28T08:23:23.000Z | 2019-07-17T02:37:08.000Z | examples/KF/EKF.cpp | shaolinbit/minisam_lib | e2e904d1b6753976de1dee102f0b53e778c0f880 | [
"BSD-3-Clause"
] | 28 | 2019-06-23T14:45:19.000Z | 2022-03-20T12:45:24.000Z | #include <iostream>
#include "nonlinear/ExtendedKalmanFilter.h"
#include "slam/PriorFactor.h"
#include "slam/BetweenFactor.h"
using namespace std;
using namespace minisam;
int main()
{
minivector* x_initial=new minivector(2,0.0);
minivector sigmanoise(2,0.1);
//DiagonalNoiseModel P_initial = DiagonalNoiseModel::Sigmas(sigmanoise);
GaussianNoiseModel* P_initial=new GaussianNoiseModel(sigmanoise);
// cout<<P_initial->thisR()<<endl;
// Create Key for initial pose
//Symbol x0('x',0);
// Create an ExtendedKalmanFilter object
ExtendedKalmanFilter ekf(0, x_initial, P_initial);
// Now predict the state at t=1, i.e. argmax_{x1} P(x1) = P(x1|x0) P(x0)
// In Kalman Filter notation, this is x_{t+1|t} and P_{t+1|t}
// For the Kalman Filter, this requires a motion model, f(x_{t}) = x_{t+1|t)
// Assuming the system is linear, this will be of the form f(x_{t}) = F*x_{t} + B*u_{t} + w
// where F is the state transition model/matrix, B is the control input model,
// and w is zero-mean, Gaussian white noise with covariance Q
// Note, in some models, Q is actually derived as G*w*G^T where w models uncertainty of some
// physical property, such as velocity or acceleration, and G is derived from physics
//
// For the purposes of this example, let us assume we are using a constant-position model and
// the controls are driving the point to the right at 1 m/s. Then, F = [1 0 ; 0 1], B = [1 0 ; 0 1]
// and u = [1 ; 0]. Let us also assume that the process noise Q = [0.1 0 ; 0 0.1].
minivector u(2);
u.data[0]=1.0;u.data[1]=0.0;
minivector sigmanoiseq(2,0.1);
//DiagonalNoiseModel Q = DiagonalNoiseModel::Sigmas(sigmanoiseq, false);
GaussianNoiseModel* Q =new GaussianNoiseModel(sigmanoiseq);
//cout<<Q->thisR()<<endl;
//cout<<Q<<endl;
// This simple motion can be modeled with a BetweenFactor
// Create Key for next pose
//Symbol x1('x',1);
// Predict delta based on controls
//Point2 difference(1,0);
minivector* difference=new minivector(2);
difference->data[0]=1.0;difference->data[1]=0.0;
//difference<<1.0, 0.0;
// Create Factor
BetweenFactor* factor1=new BetweenFactor(0, 1, difference, Q);
//cout<<Q->R()<<endl;
//cout<<Q->thisR()<<endl;
GaussianFactorGraph lngraph;
lngraph.reserve(2);
// Predict the new value with the EKF class
ekf.predict(factor1,lngraph);
lngraph.clearall();
//traits<Point2>::Print(x1_predict, "X1 Predict");
cout<<"x1_predict:"<<endl;
minimatrix_print(ekf.x_);
cout<<endl;
// Now, a measurement, z1, has been received, and the Kalman Filter should be "Updated"/"Corrected"
// This is equivalent to saying P(x1|z1) ~ P(z1|x1)*P(x1)
// For the Kalman Filter, this requires a measurement model h(x_{t}) = \hat{z}_{t}
// Assuming the system is linear, this will be of the form h(x_{t}) = H*x_{t} + v
// where H is the observation model/matrix, and v is zero-mean, Gaussian white noise with covariance R
//
// For the purposes of this example, let us assume we have something like a GPS that returns
// the current position of the robot. Then H = [1 0 ; 0 1]. Let us also assume that the measurement noise
// R = [0.25 0 ; 0 0.25].
minivector SigmaR(2,0.25);
GaussianNoiseModel* R=new GaussianNoiseModel(SigmaR);
// This simple measurement can be modeled with a PriorFactor
minivector* z1=new minivector(2);
z1->data[0]=1.0;
z1->data[1]=0.0;
PriorFactor* factor2=new PriorFactor(1, z1, R);
// Update the Kalman Filter with the measurement
ekf.update(factor2,lngraph);
lngraph.clearall();
// traits<Point2>::Print(x1_update, "X1 Update");
cout<<"x1_update:"<<endl;
minimatrix_print(ekf.x_);
cout<<endl;
// cout<<"ekf.x_:"<<endl<<ekf.x_<<endl;
// Do the same thing two more times...
// Predict
// Symbol x2('x',2);
minivector* difference3=new minivector(2);
difference3->data[0]=1.0;
difference3->data[1]=0.0;
BetweenFactor* factor3=new BetweenFactor(1, 2, difference3, Q);
ekf.predict(factor3,lngraph);
lngraph.clearall();
// traits<Point2>::Print(x2_predict, "X2 Predict");
cout<<"x2_predict:"<<endl;
minimatrix_print(ekf.x_);
cout<<endl;
// Update
minivector* z2=new minivector(2);
z2->data[0]=2.0;
z2->data[1]=0.0;
PriorFactor* factor4=new PriorFactor(2, z2, R);
ekf.update(factor4,lngraph);
lngraph.clearall();
//traits<Point2>::Print(x2_update, "X2 Update");
cout<<"x2_update:"<<endl;
minimatrix_print(ekf.x_);
cout<<endl;
// Do the same thing one more time...
// Predict
//Symbol x3('x',3);
minivector* difference4=new minivector(2);
difference4->data[0]=1.0;
difference4->data[1]=0.0;
BetweenFactor* factor5=new BetweenFactor(2, 3, difference4, Q);
ekf.predict(factor5,lngraph);
lngraph.clearall();
cout<<"x3_predict:"<<endl;
minimatrix_print(ekf.x_);
cout<<endl;
// Update
minivector* z3=new minivector(2);
z3->data[0]=3.0;
z3->data[1]=0.0;
PriorFactor* factor6=new PriorFactor(3, z3, R);
ekf.update(factor6,lngraph);
lngraph.clearall();
cout<<"x3_update:"<<endl;
minimatrix_print(ekf.x_);
cout<<endl;
delete P_initial;
delete factor1;
delete Q;
delete factor2;
delete R;
delete factor3;
delete factor5;
delete factor4;
delete factor6;
return 0;
}
| 28.12766 | 107 | 0.679085 | [
"object",
"model"
] |
fd1f62d2de299967efa823b2c6b97b06ad110d6a | 1,013 | cc | C++ | L8/anagram.cc | angelgomezsa/Cplusplus | 9fd1ed5b1beffcf253019e8376b2bd41dac6e449 | [
"MIT"
] | null | null | null | L8/anagram.cc | angelgomezsa/Cplusplus | 9fd1ed5b1beffcf253019e8376b2bd41dac6e449 | [
"MIT"
] | null | null | null | L8/anagram.cc | angelgomezsa/Cplusplus | 9fd1ed5b1beffcf253019e8376b2bd41dac6e449 | [
"MIT"
] | null | null | null | #include <iostream>
#include <vector>
using namespace std;
int main() {
// size of the vector has to be the number of letters from a to z
const int n = int('z')-int('a');
vector<int> count(n,0);
// read the first sentence
// count the number of occurrences of each letter
char c;
while (cin >> c and c != '.') {
if (c>='a' and c<='z') ++count[int(c)-int('a')];
if (c>='A' and c<='Z') ++count[int(c)-int('A')];
}
// read the second sentence
// discount the occurrence of each letter
// if the counter becomes negative, it's not an anagram
bool is_anagram = true;
while (cin >> c and c != '.' and is_anagram) {
if (c>='a' and c<='z') {
--count[int(c)-int('a')];
is_anagram = count[int(c)-int('a')] >= 0;
}
if (c>='A' and c<='Z') {
--count[int(c)-int('A')];
is_anagram = count[int(c)-int('A')] >= 0;
}
}
// all occurrences must default to 0 to be an anagram
for (int i=0;i<n and is_anagram;i++) {
is_anagram = count[i] == 0;
}
cout << is_anagram << endl;
} | 25.325 | 67 | 0.57848 | [
"vector"
] |
fd35c224b51271c82f63731484fdff9283ab7d8f | 3,531 | cc | C++ | main.cc | shikhin/wormhole | d39b436eac6ba20905e3d6b811d241186c29c518 | [
"MIT"
] | null | null | null | main.cc | shikhin/wormhole | d39b436eac6ba20905e3d6b811d241186c29c518 | [
"MIT"
] | null | null | null | main.cc | shikhin/wormhole | d39b436eac6ba20905e3d6b811d241186c29c518 | [
"MIT"
] | null | null | null | #include <algorithm>
#include <cassert>
#include <cstdlib>
#include <ctime>
#include "genus.h"
#include "graph.h"
#include "gauss.h"
#include <iostream>
#include "moves.h"
#include "subdiag.h"
#include <vector>
#include "virtual.h"
int main(int argc, char const *argv[])
{
if (argc > 1) {
code_t code = parse_code(std::string(argv[1]));
display_code(code);
std::cout << "Planar? " << (planar_knot(code) ? "true" : "false") << std::endl;
#ifndef FLAT_KNOTS
std::cout << "Genus: " << genus(code) << std::endl;
#endif
std::cout << "Enumerating r2 moves" << std::endl;
std::vector<code_t> list = r2_undo_enumerate(code);
std::sort(list.begin(), list.end());
list.erase(std::unique(list.begin(), list.end()), list.end());
for (size_t i = 0; i < list.size(); i++) {
display_code(list[i]);
}
std::vector<code_t> r2_done_list;
for (size_t i = 0; i < list.size(); i++) {
std::vector<code_t> app = r2_do_enumerate(list[i]);
r2_done_list.insert(r2_done_list.end(), app.begin(), app.end());
}
std::cout << "Un-enumerating r2 moves" << std::endl;
std::sort(r2_done_list.begin(), r2_done_list.end());
r2_done_list.erase(std::unique(r2_done_list.begin(), r2_done_list.end()), r2_done_list.end());
for (size_t i = 0; i < r2_done_list.size(); i++) {
display_code(r2_done_list[i]);
}
std::cout << "Enumerating r1 moves" << std::endl;
list = r1_undo_enumerate(code);
std::sort(list.begin(), list.end());
list.erase(std::unique(list.begin(), list.end()), list.end());
for (size_t i = 0; i < list.size(); i++) {
display_code(list[i]);
}
std::vector<code_t> r1_done_list;
for (size_t i = 0; i < list.size(); i++) {
std::vector<code_t> app = r1_do_enumerate(list[i]);
r1_done_list.insert(r1_done_list.end(), app.begin(), app.end());
}
std::cout << "Un-enumerating r1 moves" << std::endl;
std::sort(r1_done_list.begin(), r1_done_list.end());
r1_done_list.erase(std::unique(r1_done_list.begin(), r1_done_list.end()), r1_done_list.end());
for (size_t i = 0; i < r1_done_list.size(); i++) {
display_code(r1_done_list[i]);
}
std::cout << "All planar neighbors" << std::endl;
list = enumerate_complete_neighbors(code);
std::sort(list.begin(), list.end());
list.erase(std::unique(list.begin(), list.end()), list.end());
for (size_t i = 0; i < list.size(); i++) {
if (planar_knot(list[i])) {
display_code(list[i]);
}
}
// subdiagrams(code);
}
srand(time(NULL));
subsets_init();
#if 0
std::vector<std::string> movie;
movie.push_back("U-0U-1O-2O+3U+3U-2U+4O+5O-1O+4U+5O+6U+6O-0");
movie.push_back("U-0U-1U-2U+3O-4O+5U+5U-4U+6O+7O-1O+6O+3O-2U+7O+8U+8O-0");
movie.push_back("U-0U-1U-2U+3U+4O+5O-1O+4O+3O-2U+5O+6U+6O-0");
movie.push_back("U-0U-1U-2O-3O+4U+4U-3U+5U+6O+7O-1O+6O+5O-2U+7O+8U+8O-0");
movie.push_back("U-0U-1U-2O-3O+4U+4U-3U+5U+6O+7O-1O+6O+5O-2U+7O-0");
movie.push_back("U-0U-1U-2O-3O+4U+4U-3U+5U+6O-0O+7O+6O+5O-2O-1U+7");
movie.push_back("U-0O-0O+1O-2O-3U+4U-5U-3U-2O-6O+7U+7U-6U+8U+9O-5O+4O+9O+8U+1");
movie.push_back("U-0O-0O+1O-2O-3U-3U-2O-4O+5U+5U-4U+6U+7O+7O+6U+1");
cleanup_movie(movie);
#endif
explore();
return 0;
}
| 33.951923 | 102 | 0.568961 | [
"vector"
] |
fd44198db970d38c4b8d8e1f28efe2d27f98963a | 64,479 | cpp | C++ | priceless_planet/Classes/Native/Bulk_UnityEngine.ParticleSystemModule_0.cpp | rgoldfinger/vr | 31ac6c6830568ea26df2f99585c41f65506f1768 | [
"MIT"
] | null | null | null | priceless_planet/Classes/Native/Bulk_UnityEngine.ParticleSystemModule_0.cpp | rgoldfinger/vr | 31ac6c6830568ea26df2f99585c41f65506f1768 | [
"MIT"
] | null | null | null | priceless_planet/Classes/Native/Bulk_UnityEngine.ParticleSystemModule_0.cpp | rgoldfinger/vr | 31ac6c6830568ea26df2f99585c41f65506f1768 | [
"MIT"
] | null | null | null | #include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <cstring>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <limits>
#include <assert.h>
#include <stdint.h>
#include "il2cpp-class-internals.h"
#include "codegen/il2cpp-codegen.h"
#include "il2cpp-object-internals.h"
// UnityEngine.Component
struct Component_t1923634451;
// UnityEngine.ParticleSystem
struct ParticleSystem_t1800779281;
// UnityEngine.GameObject
struct GameObject_t1113636619;
// System.Collections.Generic.List`1<UnityEngine.ParticleCollisionEvent>
struct List_1_t1232140387;
// UnityEngine.Object
struct Object_t631007953;
// System.ArgumentNullException
struct ArgumentNullException_t1615371798;
// System.String
struct String_t;
// UnityEngine.ParticleSystem/Particle[]
struct ParticleU5BU5D_t3069227754;
// System.Char[]
struct CharU5BU5D_t3528271667;
// UnityEngine.ParticleCollisionEvent[]
struct ParticleCollisionEventU5BU5D_t4144522048;
// System.IntPtr[]
struct IntPtrU5BU5D_t4013366056;
// System.Collections.IDictionary
struct IDictionary_t1363984059;
// System.Void
struct Void_t1185182177;
extern RuntimeClass* Object_t631007953_il2cpp_TypeInfo_var;
extern RuntimeClass* ArgumentNullException_t1615371798_il2cpp_TypeInfo_var;
extern const RuntimeMethod* ParticlePhysicsExtensions_GetCollisionEvents_m1108737549_RuntimeMethod_var;
extern String_t* _stringLiteral3454777273;
extern String_t* _stringLiteral4178700366;
extern const uint32_t ParticlePhysicsExtensions_GetCollisionEvents_m1108737549_MetadataUsageId;
struct ParticleU5BU5D_t3069227754;
#ifndef U3CMODULEU3E_T692745537_H
#define U3CMODULEU3E_T692745537_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// <Module>
struct U3CModuleU3E_t692745537
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // U3CMODULEU3E_T692745537_H
#ifndef RUNTIMEOBJECT_H
#define RUNTIMEOBJECT_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Object
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // RUNTIMEOBJECT_H
struct Il2CppArrayBounds;
#ifndef RUNTIMEARRAY_H
#define RUNTIMEARRAY_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Array
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // RUNTIMEARRAY_H
#ifndef VALUETYPE_T3640485471_H
#define VALUETYPE_T3640485471_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.ValueType
struct ValueType_t3640485471 : public RuntimeObject
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// Native definition for P/Invoke marshalling of System.ValueType
struct ValueType_t3640485471_marshaled_pinvoke
{
};
// Native definition for COM marshalling of System.ValueType
struct ValueType_t3640485471_marshaled_com
{
};
#endif // VALUETYPE_T3640485471_H
#ifndef PARTICLESYSTEMEXTENSIONSIMPL_T490859600_H
#define PARTICLESYSTEMEXTENSIONSIMPL_T490859600_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.ParticleSystemExtensionsImpl
struct ParticleSystemExtensionsImpl_t490859600 : public RuntimeObject
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // PARTICLESYSTEMEXTENSIONSIMPL_T490859600_H
#ifndef STRING_T_H
#define STRING_T_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.String
struct String_t : public RuntimeObject
{
public:
// System.Int32 System.String::length
int32_t ___length_0;
// System.Char System.String::start_char
Il2CppChar ___start_char_1;
public:
inline static int32_t get_offset_of_length_0() { return static_cast<int32_t>(offsetof(String_t, ___length_0)); }
inline int32_t get_length_0() const { return ___length_0; }
inline int32_t* get_address_of_length_0() { return &___length_0; }
inline void set_length_0(int32_t value)
{
___length_0 = value;
}
inline static int32_t get_offset_of_start_char_1() { return static_cast<int32_t>(offsetof(String_t, ___start_char_1)); }
inline Il2CppChar get_start_char_1() const { return ___start_char_1; }
inline Il2CppChar* get_address_of_start_char_1() { return &___start_char_1; }
inline void set_start_char_1(Il2CppChar value)
{
___start_char_1 = value;
}
};
struct String_t_StaticFields
{
public:
// System.String System.String::Empty
String_t* ___Empty_2;
// System.Char[] System.String::WhiteChars
CharU5BU5D_t3528271667* ___WhiteChars_3;
public:
inline static int32_t get_offset_of_Empty_2() { return static_cast<int32_t>(offsetof(String_t_StaticFields, ___Empty_2)); }
inline String_t* get_Empty_2() const { return ___Empty_2; }
inline String_t** get_address_of_Empty_2() { return &___Empty_2; }
inline void set_Empty_2(String_t* value)
{
___Empty_2 = value;
Il2CppCodeGenWriteBarrier((&___Empty_2), value);
}
inline static int32_t get_offset_of_WhiteChars_3() { return static_cast<int32_t>(offsetof(String_t_StaticFields, ___WhiteChars_3)); }
inline CharU5BU5D_t3528271667* get_WhiteChars_3() const { return ___WhiteChars_3; }
inline CharU5BU5D_t3528271667** get_address_of_WhiteChars_3() { return &___WhiteChars_3; }
inline void set_WhiteChars_3(CharU5BU5D_t3528271667* value)
{
___WhiteChars_3 = value;
Il2CppCodeGenWriteBarrier((&___WhiteChars_3), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // STRING_T_H
#ifndef LIST_1_T1232140387_H
#define LIST_1_T1232140387_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Collections.Generic.List`1<UnityEngine.ParticleCollisionEvent>
struct List_1_t1232140387 : public RuntimeObject
{
public:
// T[] System.Collections.Generic.List`1::_items
ParticleCollisionEventU5BU5D_t4144522048* ____items_1;
// System.Int32 System.Collections.Generic.List`1::_size
int32_t ____size_2;
// System.Int32 System.Collections.Generic.List`1::_version
int32_t ____version_3;
public:
inline static int32_t get_offset_of__items_1() { return static_cast<int32_t>(offsetof(List_1_t1232140387, ____items_1)); }
inline ParticleCollisionEventU5BU5D_t4144522048* get__items_1() const { return ____items_1; }
inline ParticleCollisionEventU5BU5D_t4144522048** get_address_of__items_1() { return &____items_1; }
inline void set__items_1(ParticleCollisionEventU5BU5D_t4144522048* value)
{
____items_1 = value;
Il2CppCodeGenWriteBarrier((&____items_1), value);
}
inline static int32_t get_offset_of__size_2() { return static_cast<int32_t>(offsetof(List_1_t1232140387, ____size_2)); }
inline int32_t get__size_2() const { return ____size_2; }
inline int32_t* get_address_of__size_2() { return &____size_2; }
inline void set__size_2(int32_t value)
{
____size_2 = value;
}
inline static int32_t get_offset_of__version_3() { return static_cast<int32_t>(offsetof(List_1_t1232140387, ____version_3)); }
inline int32_t get__version_3() const { return ____version_3; }
inline int32_t* get_address_of__version_3() { return &____version_3; }
inline void set__version_3(int32_t value)
{
____version_3 = value;
}
};
struct List_1_t1232140387_StaticFields
{
public:
// T[] System.Collections.Generic.List`1::EmptyArray
ParticleCollisionEventU5BU5D_t4144522048* ___EmptyArray_4;
public:
inline static int32_t get_offset_of_EmptyArray_4() { return static_cast<int32_t>(offsetof(List_1_t1232140387_StaticFields, ___EmptyArray_4)); }
inline ParticleCollisionEventU5BU5D_t4144522048* get_EmptyArray_4() const { return ___EmptyArray_4; }
inline ParticleCollisionEventU5BU5D_t4144522048** get_address_of_EmptyArray_4() { return &___EmptyArray_4; }
inline void set_EmptyArray_4(ParticleCollisionEventU5BU5D_t4144522048* value)
{
___EmptyArray_4 = value;
Il2CppCodeGenWriteBarrier((&___EmptyArray_4), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // LIST_1_T1232140387_H
#ifndef EXCEPTION_T_H
#define EXCEPTION_T_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Exception
struct Exception_t : public RuntimeObject
{
public:
// System.IntPtr[] System.Exception::trace_ips
IntPtrU5BU5D_t4013366056* ___trace_ips_0;
// System.Exception System.Exception::inner_exception
Exception_t * ___inner_exception_1;
// System.String System.Exception::message
String_t* ___message_2;
// System.String System.Exception::help_link
String_t* ___help_link_3;
// System.String System.Exception::class_name
String_t* ___class_name_4;
// System.String System.Exception::stack_trace
String_t* ___stack_trace_5;
// System.String System.Exception::_remoteStackTraceString
String_t* ____remoteStackTraceString_6;
// System.Int32 System.Exception::remote_stack_index
int32_t ___remote_stack_index_7;
// System.Int32 System.Exception::hresult
int32_t ___hresult_8;
// System.String System.Exception::source
String_t* ___source_9;
// System.Collections.IDictionary System.Exception::_data
RuntimeObject* ____data_10;
public:
inline static int32_t get_offset_of_trace_ips_0() { return static_cast<int32_t>(offsetof(Exception_t, ___trace_ips_0)); }
inline IntPtrU5BU5D_t4013366056* get_trace_ips_0() const { return ___trace_ips_0; }
inline IntPtrU5BU5D_t4013366056** get_address_of_trace_ips_0() { return &___trace_ips_0; }
inline void set_trace_ips_0(IntPtrU5BU5D_t4013366056* value)
{
___trace_ips_0 = value;
Il2CppCodeGenWriteBarrier((&___trace_ips_0), value);
}
inline static int32_t get_offset_of_inner_exception_1() { return static_cast<int32_t>(offsetof(Exception_t, ___inner_exception_1)); }
inline Exception_t * get_inner_exception_1() const { return ___inner_exception_1; }
inline Exception_t ** get_address_of_inner_exception_1() { return &___inner_exception_1; }
inline void set_inner_exception_1(Exception_t * value)
{
___inner_exception_1 = value;
Il2CppCodeGenWriteBarrier((&___inner_exception_1), value);
}
inline static int32_t get_offset_of_message_2() { return static_cast<int32_t>(offsetof(Exception_t, ___message_2)); }
inline String_t* get_message_2() const { return ___message_2; }
inline String_t** get_address_of_message_2() { return &___message_2; }
inline void set_message_2(String_t* value)
{
___message_2 = value;
Il2CppCodeGenWriteBarrier((&___message_2), value);
}
inline static int32_t get_offset_of_help_link_3() { return static_cast<int32_t>(offsetof(Exception_t, ___help_link_3)); }
inline String_t* get_help_link_3() const { return ___help_link_3; }
inline String_t** get_address_of_help_link_3() { return &___help_link_3; }
inline void set_help_link_3(String_t* value)
{
___help_link_3 = value;
Il2CppCodeGenWriteBarrier((&___help_link_3), value);
}
inline static int32_t get_offset_of_class_name_4() { return static_cast<int32_t>(offsetof(Exception_t, ___class_name_4)); }
inline String_t* get_class_name_4() const { return ___class_name_4; }
inline String_t** get_address_of_class_name_4() { return &___class_name_4; }
inline void set_class_name_4(String_t* value)
{
___class_name_4 = value;
Il2CppCodeGenWriteBarrier((&___class_name_4), value);
}
inline static int32_t get_offset_of_stack_trace_5() { return static_cast<int32_t>(offsetof(Exception_t, ___stack_trace_5)); }
inline String_t* get_stack_trace_5() const { return ___stack_trace_5; }
inline String_t** get_address_of_stack_trace_5() { return &___stack_trace_5; }
inline void set_stack_trace_5(String_t* value)
{
___stack_trace_5 = value;
Il2CppCodeGenWriteBarrier((&___stack_trace_5), value);
}
inline static int32_t get_offset_of__remoteStackTraceString_6() { return static_cast<int32_t>(offsetof(Exception_t, ____remoteStackTraceString_6)); }
inline String_t* get__remoteStackTraceString_6() const { return ____remoteStackTraceString_6; }
inline String_t** get_address_of__remoteStackTraceString_6() { return &____remoteStackTraceString_6; }
inline void set__remoteStackTraceString_6(String_t* value)
{
____remoteStackTraceString_6 = value;
Il2CppCodeGenWriteBarrier((&____remoteStackTraceString_6), value);
}
inline static int32_t get_offset_of_remote_stack_index_7() { return static_cast<int32_t>(offsetof(Exception_t, ___remote_stack_index_7)); }
inline int32_t get_remote_stack_index_7() const { return ___remote_stack_index_7; }
inline int32_t* get_address_of_remote_stack_index_7() { return &___remote_stack_index_7; }
inline void set_remote_stack_index_7(int32_t value)
{
___remote_stack_index_7 = value;
}
inline static int32_t get_offset_of_hresult_8() { return static_cast<int32_t>(offsetof(Exception_t, ___hresult_8)); }
inline int32_t get_hresult_8() const { return ___hresult_8; }
inline int32_t* get_address_of_hresult_8() { return &___hresult_8; }
inline void set_hresult_8(int32_t value)
{
___hresult_8 = value;
}
inline static int32_t get_offset_of_source_9() { return static_cast<int32_t>(offsetof(Exception_t, ___source_9)); }
inline String_t* get_source_9() const { return ___source_9; }
inline String_t** get_address_of_source_9() { return &___source_9; }
inline void set_source_9(String_t* value)
{
___source_9 = value;
Il2CppCodeGenWriteBarrier((&___source_9), value);
}
inline static int32_t get_offset_of__data_10() { return static_cast<int32_t>(offsetof(Exception_t, ____data_10)); }
inline RuntimeObject* get__data_10() const { return ____data_10; }
inline RuntimeObject** get_address_of__data_10() { return &____data_10; }
inline void set__data_10(RuntimeObject* value)
{
____data_10 = value;
Il2CppCodeGenWriteBarrier((&____data_10), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // EXCEPTION_T_H
#ifndef PARTICLEPHYSICSEXTENSIONS_T1867354557_H
#define PARTICLEPHYSICSEXTENSIONS_T1867354557_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.ParticlePhysicsExtensions
struct ParticlePhysicsExtensions_t1867354557 : public RuntimeObject
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // PARTICLEPHYSICSEXTENSIONS_T1867354557_H
#ifndef INT32_T2950945753_H
#define INT32_T2950945753_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Int32
struct Int32_t2950945753
{
public:
// System.Int32 System.Int32::m_value
int32_t ___m_value_2;
public:
inline static int32_t get_offset_of_m_value_2() { return static_cast<int32_t>(offsetof(Int32_t2950945753, ___m_value_2)); }
inline int32_t get_m_value_2() const { return ___m_value_2; }
inline int32_t* get_address_of_m_value_2() { return &___m_value_2; }
inline void set_m_value_2(int32_t value)
{
___m_value_2 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // INT32_T2950945753_H
#ifndef BOOLEAN_T97287965_H
#define BOOLEAN_T97287965_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Boolean
struct Boolean_t97287965
{
public:
// System.Boolean System.Boolean::m_value
bool ___m_value_2;
public:
inline static int32_t get_offset_of_m_value_2() { return static_cast<int32_t>(offsetof(Boolean_t97287965, ___m_value_2)); }
inline bool get_m_value_2() const { return ___m_value_2; }
inline bool* get_address_of_m_value_2() { return &___m_value_2; }
inline void set_m_value_2(bool value)
{
___m_value_2 = value;
}
};
struct Boolean_t97287965_StaticFields
{
public:
// System.String System.Boolean::FalseString
String_t* ___FalseString_0;
// System.String System.Boolean::TrueString
String_t* ___TrueString_1;
public:
inline static int32_t get_offset_of_FalseString_0() { return static_cast<int32_t>(offsetof(Boolean_t97287965_StaticFields, ___FalseString_0)); }
inline String_t* get_FalseString_0() const { return ___FalseString_0; }
inline String_t** get_address_of_FalseString_0() { return &___FalseString_0; }
inline void set_FalseString_0(String_t* value)
{
___FalseString_0 = value;
Il2CppCodeGenWriteBarrier((&___FalseString_0), value);
}
inline static int32_t get_offset_of_TrueString_1() { return static_cast<int32_t>(offsetof(Boolean_t97287965_StaticFields, ___TrueString_1)); }
inline String_t* get_TrueString_1() const { return ___TrueString_1; }
inline String_t** get_address_of_TrueString_1() { return &___TrueString_1; }
inline void set_TrueString_1(String_t* value)
{
___TrueString_1 = value;
Il2CppCodeGenWriteBarrier((&___TrueString_1), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // BOOLEAN_T97287965_H
#ifndef SYSTEMEXCEPTION_T176217640_H
#define SYSTEMEXCEPTION_T176217640_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.SystemException
struct SystemException_t176217640 : public Exception_t
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // SYSTEMEXCEPTION_T176217640_H
#ifndef VOID_T1185182177_H
#define VOID_T1185182177_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Void
struct Void_t1185182177
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // VOID_T1185182177_H
#ifndef SINGLE_T1397266774_H
#define SINGLE_T1397266774_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Single
struct Single_t1397266774
{
public:
// System.Single System.Single::m_value
float ___m_value_7;
public:
inline static int32_t get_offset_of_m_value_7() { return static_cast<int32_t>(offsetof(Single_t1397266774, ___m_value_7)); }
inline float get_m_value_7() const { return ___m_value_7; }
inline float* get_address_of_m_value_7() { return &___m_value_7; }
inline void set_m_value_7(float value)
{
___m_value_7 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // SINGLE_T1397266774_H
#ifndef ENUM_T4135868527_H
#define ENUM_T4135868527_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Enum
struct Enum_t4135868527 : public ValueType_t3640485471
{
public:
public:
};
struct Enum_t4135868527_StaticFields
{
public:
// System.Char[] System.Enum::split_char
CharU5BU5D_t3528271667* ___split_char_0;
public:
inline static int32_t get_offset_of_split_char_0() { return static_cast<int32_t>(offsetof(Enum_t4135868527_StaticFields, ___split_char_0)); }
inline CharU5BU5D_t3528271667* get_split_char_0() const { return ___split_char_0; }
inline CharU5BU5D_t3528271667** get_address_of_split_char_0() { return &___split_char_0; }
inline void set_split_char_0(CharU5BU5D_t3528271667* value)
{
___split_char_0 = value;
Il2CppCodeGenWriteBarrier((&___split_char_0), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// Native definition for P/Invoke marshalling of System.Enum
struct Enum_t4135868527_marshaled_pinvoke
{
};
// Native definition for COM marshalling of System.Enum
struct Enum_t4135868527_marshaled_com
{
};
#endif // ENUM_T4135868527_H
#ifndef VECTOR3_T3722313464_H
#define VECTOR3_T3722313464_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.Vector3
struct Vector3_t3722313464
{
public:
// System.Single UnityEngine.Vector3::x
float ___x_1;
// System.Single UnityEngine.Vector3::y
float ___y_2;
// System.Single UnityEngine.Vector3::z
float ___z_3;
public:
inline static int32_t get_offset_of_x_1() { return static_cast<int32_t>(offsetof(Vector3_t3722313464, ___x_1)); }
inline float get_x_1() const { return ___x_1; }
inline float* get_address_of_x_1() { return &___x_1; }
inline void set_x_1(float value)
{
___x_1 = value;
}
inline static int32_t get_offset_of_y_2() { return static_cast<int32_t>(offsetof(Vector3_t3722313464, ___y_2)); }
inline float get_y_2() const { return ___y_2; }
inline float* get_address_of_y_2() { return &___y_2; }
inline void set_y_2(float value)
{
___y_2 = value;
}
inline static int32_t get_offset_of_z_3() { return static_cast<int32_t>(offsetof(Vector3_t3722313464, ___z_3)); }
inline float get_z_3() const { return ___z_3; }
inline float* get_address_of_z_3() { return &___z_3; }
inline void set_z_3(float value)
{
___z_3 = value;
}
};
struct Vector3_t3722313464_StaticFields
{
public:
// UnityEngine.Vector3 UnityEngine.Vector3::zeroVector
Vector3_t3722313464 ___zeroVector_4;
// UnityEngine.Vector3 UnityEngine.Vector3::oneVector
Vector3_t3722313464 ___oneVector_5;
// UnityEngine.Vector3 UnityEngine.Vector3::upVector
Vector3_t3722313464 ___upVector_6;
// UnityEngine.Vector3 UnityEngine.Vector3::downVector
Vector3_t3722313464 ___downVector_7;
// UnityEngine.Vector3 UnityEngine.Vector3::leftVector
Vector3_t3722313464 ___leftVector_8;
// UnityEngine.Vector3 UnityEngine.Vector3::rightVector
Vector3_t3722313464 ___rightVector_9;
// UnityEngine.Vector3 UnityEngine.Vector3::forwardVector
Vector3_t3722313464 ___forwardVector_10;
// UnityEngine.Vector3 UnityEngine.Vector3::backVector
Vector3_t3722313464 ___backVector_11;
// UnityEngine.Vector3 UnityEngine.Vector3::positiveInfinityVector
Vector3_t3722313464 ___positiveInfinityVector_12;
// UnityEngine.Vector3 UnityEngine.Vector3::negativeInfinityVector
Vector3_t3722313464 ___negativeInfinityVector_13;
public:
inline static int32_t get_offset_of_zeroVector_4() { return static_cast<int32_t>(offsetof(Vector3_t3722313464_StaticFields, ___zeroVector_4)); }
inline Vector3_t3722313464 get_zeroVector_4() const { return ___zeroVector_4; }
inline Vector3_t3722313464 * get_address_of_zeroVector_4() { return &___zeroVector_4; }
inline void set_zeroVector_4(Vector3_t3722313464 value)
{
___zeroVector_4 = value;
}
inline static int32_t get_offset_of_oneVector_5() { return static_cast<int32_t>(offsetof(Vector3_t3722313464_StaticFields, ___oneVector_5)); }
inline Vector3_t3722313464 get_oneVector_5() const { return ___oneVector_5; }
inline Vector3_t3722313464 * get_address_of_oneVector_5() { return &___oneVector_5; }
inline void set_oneVector_5(Vector3_t3722313464 value)
{
___oneVector_5 = value;
}
inline static int32_t get_offset_of_upVector_6() { return static_cast<int32_t>(offsetof(Vector3_t3722313464_StaticFields, ___upVector_6)); }
inline Vector3_t3722313464 get_upVector_6() const { return ___upVector_6; }
inline Vector3_t3722313464 * get_address_of_upVector_6() { return &___upVector_6; }
inline void set_upVector_6(Vector3_t3722313464 value)
{
___upVector_6 = value;
}
inline static int32_t get_offset_of_downVector_7() { return static_cast<int32_t>(offsetof(Vector3_t3722313464_StaticFields, ___downVector_7)); }
inline Vector3_t3722313464 get_downVector_7() const { return ___downVector_7; }
inline Vector3_t3722313464 * get_address_of_downVector_7() { return &___downVector_7; }
inline void set_downVector_7(Vector3_t3722313464 value)
{
___downVector_7 = value;
}
inline static int32_t get_offset_of_leftVector_8() { return static_cast<int32_t>(offsetof(Vector3_t3722313464_StaticFields, ___leftVector_8)); }
inline Vector3_t3722313464 get_leftVector_8() const { return ___leftVector_8; }
inline Vector3_t3722313464 * get_address_of_leftVector_8() { return &___leftVector_8; }
inline void set_leftVector_8(Vector3_t3722313464 value)
{
___leftVector_8 = value;
}
inline static int32_t get_offset_of_rightVector_9() { return static_cast<int32_t>(offsetof(Vector3_t3722313464_StaticFields, ___rightVector_9)); }
inline Vector3_t3722313464 get_rightVector_9() const { return ___rightVector_9; }
inline Vector3_t3722313464 * get_address_of_rightVector_9() { return &___rightVector_9; }
inline void set_rightVector_9(Vector3_t3722313464 value)
{
___rightVector_9 = value;
}
inline static int32_t get_offset_of_forwardVector_10() { return static_cast<int32_t>(offsetof(Vector3_t3722313464_StaticFields, ___forwardVector_10)); }
inline Vector3_t3722313464 get_forwardVector_10() const { return ___forwardVector_10; }
inline Vector3_t3722313464 * get_address_of_forwardVector_10() { return &___forwardVector_10; }
inline void set_forwardVector_10(Vector3_t3722313464 value)
{
___forwardVector_10 = value;
}
inline static int32_t get_offset_of_backVector_11() { return static_cast<int32_t>(offsetof(Vector3_t3722313464_StaticFields, ___backVector_11)); }
inline Vector3_t3722313464 get_backVector_11() const { return ___backVector_11; }
inline Vector3_t3722313464 * get_address_of_backVector_11() { return &___backVector_11; }
inline void set_backVector_11(Vector3_t3722313464 value)
{
___backVector_11 = value;
}
inline static int32_t get_offset_of_positiveInfinityVector_12() { return static_cast<int32_t>(offsetof(Vector3_t3722313464_StaticFields, ___positiveInfinityVector_12)); }
inline Vector3_t3722313464 get_positiveInfinityVector_12() const { return ___positiveInfinityVector_12; }
inline Vector3_t3722313464 * get_address_of_positiveInfinityVector_12() { return &___positiveInfinityVector_12; }
inline void set_positiveInfinityVector_12(Vector3_t3722313464 value)
{
___positiveInfinityVector_12 = value;
}
inline static int32_t get_offset_of_negativeInfinityVector_13() { return static_cast<int32_t>(offsetof(Vector3_t3722313464_StaticFields, ___negativeInfinityVector_13)); }
inline Vector3_t3722313464 get_negativeInfinityVector_13() const { return ___negativeInfinityVector_13; }
inline Vector3_t3722313464 * get_address_of_negativeInfinityVector_13() { return &___negativeInfinityVector_13; }
inline void set_negativeInfinityVector_13(Vector3_t3722313464 value)
{
___negativeInfinityVector_13 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // VECTOR3_T3722313464_H
#ifndef COLOR32_T2600501292_H
#define COLOR32_T2600501292_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.Color32
struct Color32_t2600501292
{
public:
union
{
#pragma pack(push, tp, 1)
struct
{
// System.Int32 UnityEngine.Color32::rgba
int32_t ___rgba_0;
};
#pragma pack(pop, tp)
struct
{
int32_t ___rgba_0_forAlignmentOnly;
};
#pragma pack(push, tp, 1)
struct
{
// System.Byte UnityEngine.Color32::r
uint8_t ___r_1;
};
#pragma pack(pop, tp)
struct
{
uint8_t ___r_1_forAlignmentOnly;
};
#pragma pack(push, tp, 1)
struct
{
char ___g_2_OffsetPadding[1];
// System.Byte UnityEngine.Color32::g
uint8_t ___g_2;
};
#pragma pack(pop, tp)
struct
{
char ___g_2_OffsetPadding_forAlignmentOnly[1];
uint8_t ___g_2_forAlignmentOnly;
};
#pragma pack(push, tp, 1)
struct
{
char ___b_3_OffsetPadding[2];
// System.Byte UnityEngine.Color32::b
uint8_t ___b_3;
};
#pragma pack(pop, tp)
struct
{
char ___b_3_OffsetPadding_forAlignmentOnly[2];
uint8_t ___b_3_forAlignmentOnly;
};
#pragma pack(push, tp, 1)
struct
{
char ___a_4_OffsetPadding[3];
// System.Byte UnityEngine.Color32::a
uint8_t ___a_4;
};
#pragma pack(pop, tp)
struct
{
char ___a_4_OffsetPadding_forAlignmentOnly[3];
uint8_t ___a_4_forAlignmentOnly;
};
};
public:
inline static int32_t get_offset_of_rgba_0() { return static_cast<int32_t>(offsetof(Color32_t2600501292, ___rgba_0)); }
inline int32_t get_rgba_0() const { return ___rgba_0; }
inline int32_t* get_address_of_rgba_0() { return &___rgba_0; }
inline void set_rgba_0(int32_t value)
{
___rgba_0 = value;
}
inline static int32_t get_offset_of_r_1() { return static_cast<int32_t>(offsetof(Color32_t2600501292, ___r_1)); }
inline uint8_t get_r_1() const { return ___r_1; }
inline uint8_t* get_address_of_r_1() { return &___r_1; }
inline void set_r_1(uint8_t value)
{
___r_1 = value;
}
inline static int32_t get_offset_of_g_2() { return static_cast<int32_t>(offsetof(Color32_t2600501292, ___g_2)); }
inline uint8_t get_g_2() const { return ___g_2; }
inline uint8_t* get_address_of_g_2() { return &___g_2; }
inline void set_g_2(uint8_t value)
{
___g_2 = value;
}
inline static int32_t get_offset_of_b_3() { return static_cast<int32_t>(offsetof(Color32_t2600501292, ___b_3)); }
inline uint8_t get_b_3() const { return ___b_3; }
inline uint8_t* get_address_of_b_3() { return &___b_3; }
inline void set_b_3(uint8_t value)
{
___b_3 = value;
}
inline static int32_t get_offset_of_a_4() { return static_cast<int32_t>(offsetof(Color32_t2600501292, ___a_4)); }
inline uint8_t get_a_4() const { return ___a_4; }
inline uint8_t* get_address_of_a_4() { return &___a_4; }
inline void set_a_4(uint8_t value)
{
___a_4 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // COLOR32_T2600501292_H
#ifndef INTPTR_T_H
#define INTPTR_T_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.IntPtr
struct IntPtr_t
{
public:
// System.Void* System.IntPtr::m_value
void* ___m_value_0;
public:
inline static int32_t get_offset_of_m_value_0() { return static_cast<int32_t>(offsetof(IntPtr_t, ___m_value_0)); }
inline void* get_m_value_0() const { return ___m_value_0; }
inline void** get_address_of_m_value_0() { return &___m_value_0; }
inline void set_m_value_0(void* value)
{
___m_value_0 = value;
}
};
struct IntPtr_t_StaticFields
{
public:
// System.IntPtr System.IntPtr::Zero
intptr_t ___Zero_1;
public:
inline static int32_t get_offset_of_Zero_1() { return static_cast<int32_t>(offsetof(IntPtr_t_StaticFields, ___Zero_1)); }
inline intptr_t get_Zero_1() const { return ___Zero_1; }
inline intptr_t* get_address_of_Zero_1() { return &___Zero_1; }
inline void set_Zero_1(intptr_t value)
{
___Zero_1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // INTPTR_T_H
#ifndef PARTICLESYSTEMSTOPBEHAVIOR_T2808326180_H
#define PARTICLESYSTEMSTOPBEHAVIOR_T2808326180_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.ParticleSystemStopBehavior
struct ParticleSystemStopBehavior_t2808326180
{
public:
// System.Int32 UnityEngine.ParticleSystemStopBehavior::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(ParticleSystemStopBehavior_t2808326180, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // PARTICLESYSTEMSTOPBEHAVIOR_T2808326180_H
#ifndef OBJECT_T631007953_H
#define OBJECT_T631007953_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.Object
struct Object_t631007953 : public RuntimeObject
{
public:
// System.IntPtr UnityEngine.Object::m_CachedPtr
intptr_t ___m_CachedPtr_0;
public:
inline static int32_t get_offset_of_m_CachedPtr_0() { return static_cast<int32_t>(offsetof(Object_t631007953, ___m_CachedPtr_0)); }
inline intptr_t get_m_CachedPtr_0() const { return ___m_CachedPtr_0; }
inline intptr_t* get_address_of_m_CachedPtr_0() { return &___m_CachedPtr_0; }
inline void set_m_CachedPtr_0(intptr_t value)
{
___m_CachedPtr_0 = value;
}
};
struct Object_t631007953_StaticFields
{
public:
// System.Int32 UnityEngine.Object::OffsetOfInstanceIDInCPlusPlusObject
int32_t ___OffsetOfInstanceIDInCPlusPlusObject_1;
public:
inline static int32_t get_offset_of_OffsetOfInstanceIDInCPlusPlusObject_1() { return static_cast<int32_t>(offsetof(Object_t631007953_StaticFields, ___OffsetOfInstanceIDInCPlusPlusObject_1)); }
inline int32_t get_OffsetOfInstanceIDInCPlusPlusObject_1() const { return ___OffsetOfInstanceIDInCPlusPlusObject_1; }
inline int32_t* get_address_of_OffsetOfInstanceIDInCPlusPlusObject_1() { return &___OffsetOfInstanceIDInCPlusPlusObject_1; }
inline void set_OffsetOfInstanceIDInCPlusPlusObject_1(int32_t value)
{
___OffsetOfInstanceIDInCPlusPlusObject_1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// Native definition for P/Invoke marshalling of UnityEngine.Object
struct Object_t631007953_marshaled_pinvoke
{
intptr_t ___m_CachedPtr_0;
};
// Native definition for COM marshalling of UnityEngine.Object
struct Object_t631007953_marshaled_com
{
intptr_t ___m_CachedPtr_0;
};
#endif // OBJECT_T631007953_H
#ifndef PARTICLE_T1882894987_H
#define PARTICLE_T1882894987_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.ParticleSystem/Particle
struct Particle_t1882894987
{
public:
// UnityEngine.Vector3 UnityEngine.ParticleSystem/Particle::m_Position
Vector3_t3722313464 ___m_Position_0;
// UnityEngine.Vector3 UnityEngine.ParticleSystem/Particle::m_Velocity
Vector3_t3722313464 ___m_Velocity_1;
// UnityEngine.Vector3 UnityEngine.ParticleSystem/Particle::m_AnimatedVelocity
Vector3_t3722313464 ___m_AnimatedVelocity_2;
// UnityEngine.Vector3 UnityEngine.ParticleSystem/Particle::m_InitialVelocity
Vector3_t3722313464 ___m_InitialVelocity_3;
// UnityEngine.Vector3 UnityEngine.ParticleSystem/Particle::m_AxisOfRotation
Vector3_t3722313464 ___m_AxisOfRotation_4;
// UnityEngine.Vector3 UnityEngine.ParticleSystem/Particle::m_Rotation
Vector3_t3722313464 ___m_Rotation_5;
// UnityEngine.Vector3 UnityEngine.ParticleSystem/Particle::m_AngularVelocity
Vector3_t3722313464 ___m_AngularVelocity_6;
// UnityEngine.Vector3 UnityEngine.ParticleSystem/Particle::m_StartSize
Vector3_t3722313464 ___m_StartSize_7;
// UnityEngine.Color32 UnityEngine.ParticleSystem/Particle::m_StartColor
Color32_t2600501292 ___m_StartColor_8;
// System.UInt32 UnityEngine.ParticleSystem/Particle::m_RandomSeed
uint32_t ___m_RandomSeed_9;
// System.Single UnityEngine.ParticleSystem/Particle::m_Lifetime
float ___m_Lifetime_10;
// System.Single UnityEngine.ParticleSystem/Particle::m_StartLifetime
float ___m_StartLifetime_11;
// System.Single UnityEngine.ParticleSystem/Particle::m_EmitAccumulator0
float ___m_EmitAccumulator0_12;
// System.Single UnityEngine.ParticleSystem/Particle::m_EmitAccumulator1
float ___m_EmitAccumulator1_13;
public:
inline static int32_t get_offset_of_m_Position_0() { return static_cast<int32_t>(offsetof(Particle_t1882894987, ___m_Position_0)); }
inline Vector3_t3722313464 get_m_Position_0() const { return ___m_Position_0; }
inline Vector3_t3722313464 * get_address_of_m_Position_0() { return &___m_Position_0; }
inline void set_m_Position_0(Vector3_t3722313464 value)
{
___m_Position_0 = value;
}
inline static int32_t get_offset_of_m_Velocity_1() { return static_cast<int32_t>(offsetof(Particle_t1882894987, ___m_Velocity_1)); }
inline Vector3_t3722313464 get_m_Velocity_1() const { return ___m_Velocity_1; }
inline Vector3_t3722313464 * get_address_of_m_Velocity_1() { return &___m_Velocity_1; }
inline void set_m_Velocity_1(Vector3_t3722313464 value)
{
___m_Velocity_1 = value;
}
inline static int32_t get_offset_of_m_AnimatedVelocity_2() { return static_cast<int32_t>(offsetof(Particle_t1882894987, ___m_AnimatedVelocity_2)); }
inline Vector3_t3722313464 get_m_AnimatedVelocity_2() const { return ___m_AnimatedVelocity_2; }
inline Vector3_t3722313464 * get_address_of_m_AnimatedVelocity_2() { return &___m_AnimatedVelocity_2; }
inline void set_m_AnimatedVelocity_2(Vector3_t3722313464 value)
{
___m_AnimatedVelocity_2 = value;
}
inline static int32_t get_offset_of_m_InitialVelocity_3() { return static_cast<int32_t>(offsetof(Particle_t1882894987, ___m_InitialVelocity_3)); }
inline Vector3_t3722313464 get_m_InitialVelocity_3() const { return ___m_InitialVelocity_3; }
inline Vector3_t3722313464 * get_address_of_m_InitialVelocity_3() { return &___m_InitialVelocity_3; }
inline void set_m_InitialVelocity_3(Vector3_t3722313464 value)
{
___m_InitialVelocity_3 = value;
}
inline static int32_t get_offset_of_m_AxisOfRotation_4() { return static_cast<int32_t>(offsetof(Particle_t1882894987, ___m_AxisOfRotation_4)); }
inline Vector3_t3722313464 get_m_AxisOfRotation_4() const { return ___m_AxisOfRotation_4; }
inline Vector3_t3722313464 * get_address_of_m_AxisOfRotation_4() { return &___m_AxisOfRotation_4; }
inline void set_m_AxisOfRotation_4(Vector3_t3722313464 value)
{
___m_AxisOfRotation_4 = value;
}
inline static int32_t get_offset_of_m_Rotation_5() { return static_cast<int32_t>(offsetof(Particle_t1882894987, ___m_Rotation_5)); }
inline Vector3_t3722313464 get_m_Rotation_5() const { return ___m_Rotation_5; }
inline Vector3_t3722313464 * get_address_of_m_Rotation_5() { return &___m_Rotation_5; }
inline void set_m_Rotation_5(Vector3_t3722313464 value)
{
___m_Rotation_5 = value;
}
inline static int32_t get_offset_of_m_AngularVelocity_6() { return static_cast<int32_t>(offsetof(Particle_t1882894987, ___m_AngularVelocity_6)); }
inline Vector3_t3722313464 get_m_AngularVelocity_6() const { return ___m_AngularVelocity_6; }
inline Vector3_t3722313464 * get_address_of_m_AngularVelocity_6() { return &___m_AngularVelocity_6; }
inline void set_m_AngularVelocity_6(Vector3_t3722313464 value)
{
___m_AngularVelocity_6 = value;
}
inline static int32_t get_offset_of_m_StartSize_7() { return static_cast<int32_t>(offsetof(Particle_t1882894987, ___m_StartSize_7)); }
inline Vector3_t3722313464 get_m_StartSize_7() const { return ___m_StartSize_7; }
inline Vector3_t3722313464 * get_address_of_m_StartSize_7() { return &___m_StartSize_7; }
inline void set_m_StartSize_7(Vector3_t3722313464 value)
{
___m_StartSize_7 = value;
}
inline static int32_t get_offset_of_m_StartColor_8() { return static_cast<int32_t>(offsetof(Particle_t1882894987, ___m_StartColor_8)); }
inline Color32_t2600501292 get_m_StartColor_8() const { return ___m_StartColor_8; }
inline Color32_t2600501292 * get_address_of_m_StartColor_8() { return &___m_StartColor_8; }
inline void set_m_StartColor_8(Color32_t2600501292 value)
{
___m_StartColor_8 = value;
}
inline static int32_t get_offset_of_m_RandomSeed_9() { return static_cast<int32_t>(offsetof(Particle_t1882894987, ___m_RandomSeed_9)); }
inline uint32_t get_m_RandomSeed_9() const { return ___m_RandomSeed_9; }
inline uint32_t* get_address_of_m_RandomSeed_9() { return &___m_RandomSeed_9; }
inline void set_m_RandomSeed_9(uint32_t value)
{
___m_RandomSeed_9 = value;
}
inline static int32_t get_offset_of_m_Lifetime_10() { return static_cast<int32_t>(offsetof(Particle_t1882894987, ___m_Lifetime_10)); }
inline float get_m_Lifetime_10() const { return ___m_Lifetime_10; }
inline float* get_address_of_m_Lifetime_10() { return &___m_Lifetime_10; }
inline void set_m_Lifetime_10(float value)
{
___m_Lifetime_10 = value;
}
inline static int32_t get_offset_of_m_StartLifetime_11() { return static_cast<int32_t>(offsetof(Particle_t1882894987, ___m_StartLifetime_11)); }
inline float get_m_StartLifetime_11() const { return ___m_StartLifetime_11; }
inline float* get_address_of_m_StartLifetime_11() { return &___m_StartLifetime_11; }
inline void set_m_StartLifetime_11(float value)
{
___m_StartLifetime_11 = value;
}
inline static int32_t get_offset_of_m_EmitAccumulator0_12() { return static_cast<int32_t>(offsetof(Particle_t1882894987, ___m_EmitAccumulator0_12)); }
inline float get_m_EmitAccumulator0_12() const { return ___m_EmitAccumulator0_12; }
inline float* get_address_of_m_EmitAccumulator0_12() { return &___m_EmitAccumulator0_12; }
inline void set_m_EmitAccumulator0_12(float value)
{
___m_EmitAccumulator0_12 = value;
}
inline static int32_t get_offset_of_m_EmitAccumulator1_13() { return static_cast<int32_t>(offsetof(Particle_t1882894987, ___m_EmitAccumulator1_13)); }
inline float get_m_EmitAccumulator1_13() const { return ___m_EmitAccumulator1_13; }
inline float* get_address_of_m_EmitAccumulator1_13() { return &___m_EmitAccumulator1_13; }
inline void set_m_EmitAccumulator1_13(float value)
{
___m_EmitAccumulator1_13 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // PARTICLE_T1882894987_H
#ifndef ARGUMENTEXCEPTION_T132251570_H
#define ARGUMENTEXCEPTION_T132251570_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.ArgumentException
struct ArgumentException_t132251570 : public SystemException_t176217640
{
public:
// System.String System.ArgumentException::param_name
String_t* ___param_name_12;
public:
inline static int32_t get_offset_of_param_name_12() { return static_cast<int32_t>(offsetof(ArgumentException_t132251570, ___param_name_12)); }
inline String_t* get_param_name_12() const { return ___param_name_12; }
inline String_t** get_address_of_param_name_12() { return &___param_name_12; }
inline void set_param_name_12(String_t* value)
{
___param_name_12 = value;
Il2CppCodeGenWriteBarrier((&___param_name_12), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // ARGUMENTEXCEPTION_T132251570_H
#ifndef PARTICLECOLLISIONEVENT_T4055032941_H
#define PARTICLECOLLISIONEVENT_T4055032941_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.ParticleCollisionEvent
struct ParticleCollisionEvent_t4055032941
{
public:
// UnityEngine.Vector3 UnityEngine.ParticleCollisionEvent::m_Intersection
Vector3_t3722313464 ___m_Intersection_0;
// UnityEngine.Vector3 UnityEngine.ParticleCollisionEvent::m_Normal
Vector3_t3722313464 ___m_Normal_1;
// UnityEngine.Vector3 UnityEngine.ParticleCollisionEvent::m_Velocity
Vector3_t3722313464 ___m_Velocity_2;
// System.Int32 UnityEngine.ParticleCollisionEvent::m_ColliderInstanceID
int32_t ___m_ColliderInstanceID_3;
public:
inline static int32_t get_offset_of_m_Intersection_0() { return static_cast<int32_t>(offsetof(ParticleCollisionEvent_t4055032941, ___m_Intersection_0)); }
inline Vector3_t3722313464 get_m_Intersection_0() const { return ___m_Intersection_0; }
inline Vector3_t3722313464 * get_address_of_m_Intersection_0() { return &___m_Intersection_0; }
inline void set_m_Intersection_0(Vector3_t3722313464 value)
{
___m_Intersection_0 = value;
}
inline static int32_t get_offset_of_m_Normal_1() { return static_cast<int32_t>(offsetof(ParticleCollisionEvent_t4055032941, ___m_Normal_1)); }
inline Vector3_t3722313464 get_m_Normal_1() const { return ___m_Normal_1; }
inline Vector3_t3722313464 * get_address_of_m_Normal_1() { return &___m_Normal_1; }
inline void set_m_Normal_1(Vector3_t3722313464 value)
{
___m_Normal_1 = value;
}
inline static int32_t get_offset_of_m_Velocity_2() { return static_cast<int32_t>(offsetof(ParticleCollisionEvent_t4055032941, ___m_Velocity_2)); }
inline Vector3_t3722313464 get_m_Velocity_2() const { return ___m_Velocity_2; }
inline Vector3_t3722313464 * get_address_of_m_Velocity_2() { return &___m_Velocity_2; }
inline void set_m_Velocity_2(Vector3_t3722313464 value)
{
___m_Velocity_2 = value;
}
inline static int32_t get_offset_of_m_ColliderInstanceID_3() { return static_cast<int32_t>(offsetof(ParticleCollisionEvent_t4055032941, ___m_ColliderInstanceID_3)); }
inline int32_t get_m_ColliderInstanceID_3() const { return ___m_ColliderInstanceID_3; }
inline int32_t* get_address_of_m_ColliderInstanceID_3() { return &___m_ColliderInstanceID_3; }
inline void set_m_ColliderInstanceID_3(int32_t value)
{
___m_ColliderInstanceID_3 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // PARTICLECOLLISIONEVENT_T4055032941_H
#ifndef ARGUMENTNULLEXCEPTION_T1615371798_H
#define ARGUMENTNULLEXCEPTION_T1615371798_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.ArgumentNullException
struct ArgumentNullException_t1615371798 : public ArgumentException_t132251570
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // ARGUMENTNULLEXCEPTION_T1615371798_H
#ifndef GAMEOBJECT_T1113636619_H
#define GAMEOBJECT_T1113636619_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.GameObject
struct GameObject_t1113636619 : public Object_t631007953
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // GAMEOBJECT_T1113636619_H
#ifndef COMPONENT_T1923634451_H
#define COMPONENT_T1923634451_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.Component
struct Component_t1923634451 : public Object_t631007953
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // COMPONENT_T1923634451_H
#ifndef PARTICLESYSTEM_T1800779281_H
#define PARTICLESYSTEM_T1800779281_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.ParticleSystem
struct ParticleSystem_t1800779281 : public Component_t1923634451
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // PARTICLESYSTEM_T1800779281_H
// UnityEngine.ParticleSystem/Particle[]
struct ParticleU5BU5D_t3069227754 : public RuntimeArray
{
public:
ALIGN_FIELD (8) Particle_t1882894987 m_Items[1];
public:
inline Particle_t1882894987 GetAt(il2cpp_array_size_t index) const
{
IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length);
return m_Items[index];
}
inline Particle_t1882894987 * GetAddressAt(il2cpp_array_size_t index)
{
IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length);
return m_Items + index;
}
inline void SetAt(il2cpp_array_size_t index, Particle_t1882894987 value)
{
IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length);
m_Items[index] = value;
}
inline Particle_t1882894987 GetAtUnchecked(il2cpp_array_size_t index) const
{
return m_Items[index];
}
inline Particle_t1882894987 * GetAddressAtUnchecked(il2cpp_array_size_t index)
{
return m_Items + index;
}
inline void SetAtUnchecked(il2cpp_array_size_t index, Particle_t1882894987 value)
{
m_Items[index] = value;
}
};
// UnityEngine.Component UnityEngine.ParticleCollisionEvent::InstanceIDToColliderComponent(System.Int32)
extern "C" Component_t1923634451 * ParticleCollisionEvent_InstanceIDToColliderComponent_m3582923694 (RuntimeObject * __this /* static, unused */, int32_t ___instanceID0, const RuntimeMethod* method) IL2CPP_METHOD_ATTR;
// UnityEngine.Component UnityEngine.ParticleCollisionEvent::get_colliderComponent()
extern "C" Component_t1923634451 * ParticleCollisionEvent_get_colliderComponent_m1489433520 (ParticleCollisionEvent_t4055032941 * __this, const RuntimeMethod* method) IL2CPP_METHOD_ATTR;
// System.Boolean UnityEngine.Object::op_Equality(UnityEngine.Object,UnityEngine.Object)
extern "C" bool Object_op_Equality_m1810815630 (RuntimeObject * __this /* static, unused */, Object_t631007953 * p0, Object_t631007953 * p1, const RuntimeMethod* method) IL2CPP_METHOD_ATTR;
// System.Void System.ArgumentNullException::.ctor(System.String)
extern "C" void ArgumentNullException__ctor_m1170824041 (ArgumentNullException_t1615371798 * __this, String_t* p0, const RuntimeMethod* method) IL2CPP_METHOD_ATTR;
// System.Int32 UnityEngine.ParticleSystemExtensionsImpl::GetCollisionEvents(UnityEngine.ParticleSystem,UnityEngine.GameObject,System.Object)
extern "C" int32_t ParticleSystemExtensionsImpl_GetCollisionEvents_m2141038518 (RuntimeObject * __this /* static, unused */, ParticleSystem_t1800779281 * ___ps0, GameObject_t1113636619 * ___go1, RuntimeObject * ___collisionEvents2, const RuntimeMethod* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.ParticleSystem::Play(System.Boolean)
extern "C" void ParticleSystem_Play_m163824593 (ParticleSystem_t1800779281 * __this, bool ___withChildren0, const RuntimeMethod* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.ParticleSystem::Stop(System.Boolean,UnityEngine.ParticleSystemStopBehavior)
extern "C" void ParticleSystem_Stop_m3396581118 (ParticleSystem_t1800779281 * __this, bool ___withChildren0, int32_t ___stopBehavior1, const RuntimeMethod* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.ParticleSystem::INTERNAL_CALL_Emit(UnityEngine.ParticleSystem,System.Int32)
extern "C" void ParticleSystem_INTERNAL_CALL_Emit_m662166748 (RuntimeObject * __this /* static, unused */, ParticleSystem_t1800779281 * ___self0, int32_t ___count1, const RuntimeMethod* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.ParticleSystem/Particle::set_position(UnityEngine.Vector3)
extern "C" void Particle_set_position_m4147191379 (Particle_t1882894987 * __this, Vector3_t3722313464 ___value0, const RuntimeMethod* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.Vector3::.ctor(System.Single,System.Single,System.Single)
extern "C" void Vector3__ctor_m3353183577 (Vector3_t3722313464 * __this, float p0, float p1, float p2, const RuntimeMethod* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.ParticleSystem/Particle::set_startSize(System.Single)
extern "C" void Particle_set_startSize_m2554682920 (Particle_t1882894987 * __this, float ___value0, const RuntimeMethod* method) IL2CPP_METHOD_ATTR;
// System.Void UnityEngine.ParticleSystem/Particle::set_startColor(UnityEngine.Color32)
extern "C" void Particle_set_startColor_m3825027702 (Particle_t1882894987 * __this, Color32_t2600501292 ___value0, const RuntimeMethod* method) IL2CPP_METHOD_ATTR;
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.Component UnityEngine.ParticleCollisionEvent::get_colliderComponent()
extern "C" Component_t1923634451 * ParticleCollisionEvent_get_colliderComponent_m1489433520 (ParticleCollisionEvent_t4055032941 * __this, const RuntimeMethod* method)
{
Component_t1923634451 * V_0 = NULL;
{
int32_t L_0 = __this->get_m_ColliderInstanceID_3();
Component_t1923634451 * L_1 = ParticleCollisionEvent_InstanceIDToColliderComponent_m3582923694(NULL /*static, unused*/, L_0, /*hidden argument*/NULL);
V_0 = L_1;
goto IL_0012;
}
IL_0012:
{
Component_t1923634451 * L_2 = V_0;
return L_2;
}
}
extern "C" Component_t1923634451 * ParticleCollisionEvent_get_colliderComponent_m1489433520_AdjustorThunk (RuntimeObject * __this, const RuntimeMethod* method)
{
ParticleCollisionEvent_t4055032941 * _thisAdjusted = reinterpret_cast<ParticleCollisionEvent_t4055032941 *>(__this + 1);
return ParticleCollisionEvent_get_colliderComponent_m1489433520(_thisAdjusted, method);
}
// UnityEngine.Component UnityEngine.ParticleCollisionEvent::InstanceIDToColliderComponent(System.Int32)
extern "C" Component_t1923634451 * ParticleCollisionEvent_InstanceIDToColliderComponent_m3582923694 (RuntimeObject * __this /* static, unused */, int32_t ___instanceID0, const RuntimeMethod* method)
{
typedef Component_t1923634451 * (*ParticleCollisionEvent_InstanceIDToColliderComponent_m3582923694_ftn) (int32_t);
static ParticleCollisionEvent_InstanceIDToColliderComponent_m3582923694_ftn _il2cpp_icall_func;
if (!_il2cpp_icall_func)
_il2cpp_icall_func = (ParticleCollisionEvent_InstanceIDToColliderComponent_m3582923694_ftn)il2cpp_codegen_resolve_icall ("UnityEngine.ParticleCollisionEvent::InstanceIDToColliderComponent(System.Int32)");
Component_t1923634451 * retVal = _il2cpp_icall_func(___instanceID0);
return retVal;
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Int32 UnityEngine.ParticlePhysicsExtensions::GetCollisionEvents(UnityEngine.ParticleSystem,UnityEngine.GameObject,System.Collections.Generic.List`1<UnityEngine.ParticleCollisionEvent>)
extern "C" int32_t ParticlePhysicsExtensions_GetCollisionEvents_m1108737549 (RuntimeObject * __this /* static, unused */, ParticleSystem_t1800779281 * ___ps0, GameObject_t1113636619 * ___go1, List_1_t1232140387 * ___collisionEvents2, const RuntimeMethod* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (ParticlePhysicsExtensions_GetCollisionEvents_m1108737549_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
int32_t V_0 = 0;
{
GameObject_t1113636619 * L_0 = ___go1;
IL2CPP_RUNTIME_CLASS_INIT(Object_t631007953_il2cpp_TypeInfo_var);
bool L_1 = Object_op_Equality_m1810815630(NULL /*static, unused*/, L_0, (Object_t631007953 *)NULL, /*hidden argument*/NULL);
if (!L_1)
{
goto IL_0018;
}
}
{
ArgumentNullException_t1615371798 * L_2 = (ArgumentNullException_t1615371798 *)il2cpp_codegen_object_new(ArgumentNullException_t1615371798_il2cpp_TypeInfo_var);
ArgumentNullException__ctor_m1170824041(L_2, _stringLiteral3454777273, /*hidden argument*/NULL);
IL2CPP_RAISE_MANAGED_EXCEPTION(L_2, NULL, ParticlePhysicsExtensions_GetCollisionEvents_m1108737549_RuntimeMethod_var);
}
IL_0018:
{
List_1_t1232140387 * L_3 = ___collisionEvents2;
if (L_3)
{
goto IL_0029;
}
}
{
ArgumentNullException_t1615371798 * L_4 = (ArgumentNullException_t1615371798 *)il2cpp_codegen_object_new(ArgumentNullException_t1615371798_il2cpp_TypeInfo_var);
ArgumentNullException__ctor_m1170824041(L_4, _stringLiteral4178700366, /*hidden argument*/NULL);
IL2CPP_RAISE_MANAGED_EXCEPTION(L_4, NULL, ParticlePhysicsExtensions_GetCollisionEvents_m1108737549_RuntimeMethod_var);
}
IL_0029:
{
ParticleSystem_t1800779281 * L_5 = ___ps0;
GameObject_t1113636619 * L_6 = ___go1;
List_1_t1232140387 * L_7 = ___collisionEvents2;
int32_t L_8 = ParticleSystemExtensionsImpl_GetCollisionEvents_m2141038518(NULL /*static, unused*/, L_5, L_6, L_7, /*hidden argument*/NULL);
V_0 = L_8;
goto IL_0037;
}
IL_0037:
{
int32_t L_9 = V_0;
return L_9;
}
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Void UnityEngine.ParticleSystem::set_time(System.Single)
extern "C" void ParticleSystem_set_time_m2501131202 (ParticleSystem_t1800779281 * __this, float ___value0, const RuntimeMethod* method)
{
typedef void (*ParticleSystem_set_time_m2501131202_ftn) (ParticleSystem_t1800779281 *, float);
static ParticleSystem_set_time_m2501131202_ftn _il2cpp_icall_func;
if (!_il2cpp_icall_func)
_il2cpp_icall_func = (ParticleSystem_set_time_m2501131202_ftn)il2cpp_codegen_resolve_icall ("UnityEngine.ParticleSystem::set_time(System.Single)");
_il2cpp_icall_func(__this, ___value0);
}
// System.Void UnityEngine.ParticleSystem::SetParticles(UnityEngine.ParticleSystem/Particle[],System.Int32)
extern "C" void ParticleSystem_SetParticles_m1018124896 (ParticleSystem_t1800779281 * __this, ParticleU5BU5D_t3069227754* ___particles0, int32_t ___size1, const RuntimeMethod* method)
{
typedef void (*ParticleSystem_SetParticles_m1018124896_ftn) (ParticleSystem_t1800779281 *, ParticleU5BU5D_t3069227754*, int32_t);
static ParticleSystem_SetParticles_m1018124896_ftn _il2cpp_icall_func;
if (!_il2cpp_icall_func)
_il2cpp_icall_func = (ParticleSystem_SetParticles_m1018124896_ftn)il2cpp_codegen_resolve_icall ("UnityEngine.ParticleSystem::SetParticles(UnityEngine.ParticleSystem/Particle[],System.Int32)");
_il2cpp_icall_func(__this, ___particles0, ___size1);
}
// System.Void UnityEngine.ParticleSystem::Play(System.Boolean)
extern "C" void ParticleSystem_Play_m163824593 (ParticleSystem_t1800779281 * __this, bool ___withChildren0, const RuntimeMethod* method)
{
typedef void (*ParticleSystem_Play_m163824593_ftn) (ParticleSystem_t1800779281 *, bool);
static ParticleSystem_Play_m163824593_ftn _il2cpp_icall_func;
if (!_il2cpp_icall_func)
_il2cpp_icall_func = (ParticleSystem_Play_m163824593_ftn)il2cpp_codegen_resolve_icall ("UnityEngine.ParticleSystem::Play(System.Boolean)");
_il2cpp_icall_func(__this, ___withChildren0);
}
// System.Void UnityEngine.ParticleSystem::Play()
extern "C" void ParticleSystem_Play_m882713458 (ParticleSystem_t1800779281 * __this, const RuntimeMethod* method)
{
bool V_0 = false;
{
V_0 = (bool)1;
bool L_0 = V_0;
ParticleSystem_Play_m163824593(__this, L_0, /*hidden argument*/NULL);
return;
}
}
// System.Void UnityEngine.ParticleSystem::Stop(System.Boolean,UnityEngine.ParticleSystemStopBehavior)
extern "C" void ParticleSystem_Stop_m3396581118 (ParticleSystem_t1800779281 * __this, bool ___withChildren0, int32_t ___stopBehavior1, const RuntimeMethod* method)
{
typedef void (*ParticleSystem_Stop_m3396581118_ftn) (ParticleSystem_t1800779281 *, bool, int32_t);
static ParticleSystem_Stop_m3396581118_ftn _il2cpp_icall_func;
if (!_il2cpp_icall_func)
_il2cpp_icall_func = (ParticleSystem_Stop_m3396581118_ftn)il2cpp_codegen_resolve_icall ("UnityEngine.ParticleSystem::Stop(System.Boolean,UnityEngine.ParticleSystemStopBehavior)");
_il2cpp_icall_func(__this, ___withChildren0, ___stopBehavior1);
}
// System.Void UnityEngine.ParticleSystem::Stop()
extern "C" void ParticleSystem_Stop_m3125854227 (ParticleSystem_t1800779281 * __this, const RuntimeMethod* method)
{
int32_t V_0 = 0;
bool V_1 = false;
{
V_0 = 1;
V_1 = (bool)1;
bool L_0 = V_1;
int32_t L_1 = V_0;
ParticleSystem_Stop_m3396581118(__this, L_0, L_1, /*hidden argument*/NULL);
return;
}
}
// System.Void UnityEngine.ParticleSystem::Emit(System.Int32)
extern "C" void ParticleSystem_Emit_m2162102900 (ParticleSystem_t1800779281 * __this, int32_t ___count0, const RuntimeMethod* method)
{
{
int32_t L_0 = ___count0;
ParticleSystem_INTERNAL_CALL_Emit_m662166748(NULL /*static, unused*/, __this, L_0, /*hidden argument*/NULL);
return;
}
}
// System.Void UnityEngine.ParticleSystem::INTERNAL_CALL_Emit(UnityEngine.ParticleSystem,System.Int32)
extern "C" void ParticleSystem_INTERNAL_CALL_Emit_m662166748 (RuntimeObject * __this /* static, unused */, ParticleSystem_t1800779281 * ___self0, int32_t ___count1, const RuntimeMethod* method)
{
typedef void (*ParticleSystem_INTERNAL_CALL_Emit_m662166748_ftn) (ParticleSystem_t1800779281 *, int32_t);
static ParticleSystem_INTERNAL_CALL_Emit_m662166748_ftn _il2cpp_icall_func;
if (!_il2cpp_icall_func)
_il2cpp_icall_func = (ParticleSystem_INTERNAL_CALL_Emit_m662166748_ftn)il2cpp_codegen_resolve_icall ("UnityEngine.ParticleSystem::INTERNAL_CALL_Emit(UnityEngine.ParticleSystem,System.Int32)");
_il2cpp_icall_func(___self0, ___count1);
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Void UnityEngine.ParticleSystem/Particle::set_position(UnityEngine.Vector3)
extern "C" void Particle_set_position_m4147191379 (Particle_t1882894987 * __this, Vector3_t3722313464 ___value0, const RuntimeMethod* method)
{
{
Vector3_t3722313464 L_0 = ___value0;
__this->set_m_Position_0(L_0);
return;
}
}
extern "C" void Particle_set_position_m4147191379_AdjustorThunk (RuntimeObject * __this, Vector3_t3722313464 ___value0, const RuntimeMethod* method)
{
Particle_t1882894987 * _thisAdjusted = reinterpret_cast<Particle_t1882894987 *>(__this + 1);
Particle_set_position_m4147191379(_thisAdjusted, ___value0, method);
}
// System.Void UnityEngine.ParticleSystem/Particle::set_startSize(System.Single)
extern "C" void Particle_set_startSize_m2554682920 (Particle_t1882894987 * __this, float ___value0, const RuntimeMethod* method)
{
{
float L_0 = ___value0;
float L_1 = ___value0;
float L_2 = ___value0;
Vector3_t3722313464 L_3;
memset(&L_3, 0, sizeof(L_3));
Vector3__ctor_m3353183577((&L_3), L_0, L_1, L_2, /*hidden argument*/NULL);
__this->set_m_StartSize_7(L_3);
return;
}
}
extern "C" void Particle_set_startSize_m2554682920_AdjustorThunk (RuntimeObject * __this, float ___value0, const RuntimeMethod* method)
{
Particle_t1882894987 * _thisAdjusted = reinterpret_cast<Particle_t1882894987 *>(__this + 1);
Particle_set_startSize_m2554682920(_thisAdjusted, ___value0, method);
}
// System.Void UnityEngine.ParticleSystem/Particle::set_startColor(UnityEngine.Color32)
extern "C" void Particle_set_startColor_m3825027702 (Particle_t1882894987 * __this, Color32_t2600501292 ___value0, const RuntimeMethod* method)
{
{
Color32_t2600501292 L_0 = ___value0;
__this->set_m_StartColor_8(L_0);
return;
}
}
extern "C" void Particle_set_startColor_m3825027702_AdjustorThunk (RuntimeObject * __this, Color32_t2600501292 ___value0, const RuntimeMethod* method)
{
Particle_t1882894987 * _thisAdjusted = reinterpret_cast<Particle_t1882894987 *>(__this + 1);
Particle_set_startColor_m3825027702(_thisAdjusted, ___value0, method);
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Int32 UnityEngine.ParticleSystemExtensionsImpl::GetCollisionEvents(UnityEngine.ParticleSystem,UnityEngine.GameObject,System.Object)
extern "C" int32_t ParticleSystemExtensionsImpl_GetCollisionEvents_m2141038518 (RuntimeObject * __this /* static, unused */, ParticleSystem_t1800779281 * ___ps0, GameObject_t1113636619 * ___go1, RuntimeObject * ___collisionEvents2, const RuntimeMethod* method)
{
typedef int32_t (*ParticleSystemExtensionsImpl_GetCollisionEvents_m2141038518_ftn) (ParticleSystem_t1800779281 *, GameObject_t1113636619 *, RuntimeObject *);
static ParticleSystemExtensionsImpl_GetCollisionEvents_m2141038518_ftn _il2cpp_icall_func;
if (!_il2cpp_icall_func)
_il2cpp_icall_func = (ParticleSystemExtensionsImpl_GetCollisionEvents_m2141038518_ftn)il2cpp_codegen_resolve_icall ("UnityEngine.ParticleSystemExtensionsImpl::GetCollisionEvents(UnityEngine.ParticleSystem,UnityEngine.GameObject,System.Object)");
int32_t retVal = _il2cpp_icall_func(___ps0, ___go1, ___collisionEvents2);
return retVal;
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
#ifdef __clang__
#pragma clang diagnostic pop
#endif
| 37.37913 | 281 | 0.814684 | [
"object"
] |
fd443e56d472ca2eecc133e7fd9464783c80c02d | 610 | cpp | C++ | port/GraphQLParser/GraphQLParser/AST/GraphQLObjectTypeDefinition.cpp | d0si/GraphQL-cpp | 42c35c97f239cc066455a11b37249697dcaed130 | [
"MIT"
] | null | null | null | port/GraphQLParser/GraphQLParser/AST/GraphQLObjectTypeDefinition.cpp | d0si/GraphQL-cpp | 42c35c97f239cc066455a11b37249697dcaed130 | [
"MIT"
] | null | null | null | port/GraphQLParser/GraphQLParser/AST/GraphQLObjectTypeDefinition.cpp | d0si/GraphQL-cpp | 42c35c97f239cc066455a11b37249697dcaed130 | [
"MIT"
] | null | null | null | #include <GraphQLParser/AST/GraphQLObjectTypeDefinition.h>
namespace GraphQLParser {
namespace AST {
GraphQLObjectTypeDefinition::GraphQLObjectTypeDefinition() : GraphQLTypeDefinition(ASTNodeKind::ObjectTypeDefinition) {
}
GraphQLObjectTypeDefinition::GraphQLObjectTypeDefinition(
std::shared_ptr<GraphQLName> name,
std::vector<GraphQLNamedType> interfaces,
std::vector<GraphQLDirective> directives,
std::vector<GraphQLFieldDefinition> fields)
: GraphQLTypeDefinition(ASTNodeKind::ObjectTypeDefinition, name), Interfaces(interfaces), Directives(directives), Fields(fields) {
}
}
}
| 32.105263 | 133 | 0.8 | [
"vector"
] |
fd4c633421b8b1a4ec0cf58cfc7e3e61a16b7997 | 354 | cpp | C++ | Museum/src/Scene.cpp | coolzoom/Museum | 7c177beda99bd47ac7c7af358fbad9cb08e74bbc | [
"Apache-2.0"
] | 1 | 2021-04-01T12:27:39.000Z | 2021-04-01T12:27:39.000Z | Museum/src/Scene.cpp | coolzoom/Museum | 7c177beda99bd47ac7c7af358fbad9cb08e74bbc | [
"Apache-2.0"
] | null | null | null | Museum/src/Scene.cpp | coolzoom/Museum | 7c177beda99bd47ac7c7af358fbad9cb08e74bbc | [
"Apache-2.0"
] | 1 | 2021-04-01T12:30:35.000Z | 2021-04-01T12:30:35.000Z | #include "Scene.h"
#include "Components/Transform.h"
#include <iostream>
struct SceneData {
SceneData() : transform{ false } {}
Transform transform;
};
std::unique_ptr<SceneData> sceneData;
void Scene::Init() {
sceneData = std::make_unique<SceneData>();
}
Transform& Scene::GetTransform() {
return sceneData->transform;
} | 16.090909 | 44 | 0.669492 | [
"transform"
] |
fd568d54405ae70589283c58911d4bba489161d2 | 14,640 | cpp | C++ | AllJoyn/Samples/MyLivingRoom/Models/org.alljoyn.Control/VolumeProducer.cpp | halitcan/samples | 995f850e0ed6c1cd2bc87c8af39b7a4cf41fe425 | [
"MIT"
] | 1,433 | 2015-04-30T09:26:53.000Z | 2022-03-26T12:44:12.000Z | AllJoyn/Samples/MyLivingRoom/Models/org.alljoyn.Control/VolumeProducer.cpp | buocnhay/samples-1 | ddd614bb5ae595f03811e3dfa15a5d107005d0fc | [
"MIT"
] | 530 | 2015-05-02T09:12:48.000Z | 2018-01-03T17:52:01.000Z | AllJoyn/Samples/MyLivingRoom/Models/org.alljoyn.Control/VolumeProducer.cpp | buocnhay/samples-1 | ddd614bb5ae595f03811e3dfa15a5d107005d0fc | [
"MIT"
] | 1,878 | 2015-04-30T04:18:57.000Z | 2022-03-15T16:51:17.000Z | #include "pch.h"
using namespace concurrency;
using namespace Microsoft::WRL;
using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::Devices::AllJoyn;
using namespace org::alljoyn::Control;
std::map<alljoyn_busobject, WeakReference*> VolumeProducer::SourceObjects;
std::map<alljoyn_interfacedescription, WeakReference*> VolumeProducer::SourceInterfaces;
VolumeProducer::VolumeProducer(AllJoynBusAttachment^ busAttachment)
: m_busAttachment(busAttachment),
m_sessionListener(nullptr),
m_busObject(nullptr),
m_sessionPort(0),
m_sessionId(0)
{
m_weak = new WeakReference(this);
ServiceObjectPath = ref new String(L"/Service");
m_signals = ref new VolumeSignals();
m_busAttachmentStateChangedToken.Value = 0;
}
VolumeProducer::~VolumeProducer()
{
UnregisterFromBus();
delete m_weak;
}
void VolumeProducer::UnregisterFromBus()
{
if ((nullptr != m_busAttachment) && (0 != m_busAttachmentStateChangedToken.Value))
{
m_busAttachment->StateChanged -= m_busAttachmentStateChangedToken;
m_busAttachmentStateChangedToken.Value = 0;
}
if (nullptr != SessionPortListener)
{
alljoyn_busattachment_unbindsessionport(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), m_sessionPort);
alljoyn_sessionportlistener_destroy(SessionPortListener);
SessionPortListener = nullptr;
}
if (nullptr != BusObject)
{
alljoyn_busattachment_unregisterbusobject(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), BusObject);
alljoyn_busobject_destroy(BusObject);
BusObject = nullptr;
}
if (nullptr != SessionListener)
{
alljoyn_sessionlistener_destroy(SessionListener);
SessionListener = nullptr;
}
}
bool VolumeProducer::OnAcceptSessionJoiner(_In_ alljoyn_sessionport sessionPort, _In_ PCSTR joiner, _In_ const alljoyn_sessionopts opts)
{
UNREFERENCED_PARAMETER(sessionPort); UNREFERENCED_PARAMETER(joiner); UNREFERENCED_PARAMETER(opts);
return true;
}
void VolumeProducer::OnSessionJoined(_In_ alljoyn_sessionport sessionPort, _In_ alljoyn_sessionid id, _In_ PCSTR joiner)
{
UNREFERENCED_PARAMETER(joiner);
// We initialize the Signals object after the session has been joined, because it needs
// the session id.
m_signals->Initialize(BusObject, id);
m_sessionPort = sessionPort;
m_sessionId = id;
alljoyn_sessionlistener_callbacks callbacks =
{
AllJoynHelpers::SessionLostHandler<VolumeProducer>,
AllJoynHelpers::SessionMemberAddedHandler<VolumeProducer>,
AllJoynHelpers::SessionMemberRemovedHandler<VolumeProducer>
};
SessionListener = alljoyn_sessionlistener_create(&callbacks, m_weak);
alljoyn_busattachment_setsessionlistener(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), id, SessionListener);
}
void VolumeProducer::OnSessionLost(_In_ alljoyn_sessionid sessionId, _In_ alljoyn_sessionlostreason reason)
{
if (sessionId == m_sessionId)
{
AllJoynSessionLostEventArgs^ args = ref new AllJoynSessionLostEventArgs(static_cast<AllJoynSessionLostReason>(reason));
SessionLost(this, args);
}
}
void VolumeProducer::OnSessionMemberAdded(_In_ alljoyn_sessionid sessionId, _In_ PCSTR uniqueName)
{
if (sessionId == m_sessionId)
{
auto args = ref new AllJoynSessionMemberAddedEventArgs(AllJoynHelpers::MultibyteToPlatformString(uniqueName));
SessionMemberAdded(this, args);
}
}
void VolumeProducer::OnSessionMemberRemoved(_In_ alljoyn_sessionid sessionId, _In_ PCSTR uniqueName)
{
if (sessionId == m_sessionId)
{
auto args = ref new AllJoynSessionMemberRemovedEventArgs(AllJoynHelpers::MultibyteToPlatformString(uniqueName));
SessionMemberRemoved(this, args);
}
}
void VolumeProducer::BusAttachmentStateChanged(_In_ AllJoynBusAttachment^ sender, _In_ AllJoynBusAttachmentStateChangedEventArgs^ args)
{
if (args->State == AllJoynBusAttachmentState::Connected)
{
QStatus result = AllJoynHelpers::CreateProducerSession<VolumeProducer>(m_busAttachment, m_weak);
if (ER_OK != result)
{
StopInternal(result);
return;
}
}
else if (args->State == AllJoynBusAttachmentState::Disconnected)
{
StopInternal(ER_BUS_STOPPING);
}
}
void VolumeProducer::CallAdjustVolumeHandler(_Inout_ alljoyn_busobject busObject, _In_ alljoyn_message message)
{
auto source = SourceObjects.find(busObject);
if (source == SourceObjects.end())
{
return;
}
VolumeProducer^ producer = source->second->Resolve<VolumeProducer>();
if (producer->Service != nullptr)
{
AllJoynMessageInfo^ callInfo = ref new AllJoynMessageInfo(AllJoynHelpers::MultibyteToPlatformString(alljoyn_message_getsender(message)));
int16 inputArg0;
TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "n", &inputArg0);
create_task(producer->Service->AdjustVolumeAsync(callInfo, inputArg0)).then([busObject, message](VolumeAdjustVolumeResult^ result)
{
size_t argCount = 0;
alljoyn_msgarg outputs = alljoyn_msgarg_array_create(argCount);
alljoyn_busobject_methodreply_args(busObject, message, outputs, argCount);
alljoyn_msgarg_destroy(outputs);
}).wait();
}
}
void VolumeProducer::CallMuteChangedSignalHandler(_In_ const alljoyn_interfacedescription_member* member, _In_ alljoyn_message message)
{
auto source = SourceInterfaces.find(member->iface);
if (source == SourceInterfaces.end())
{
return;
}
auto producer = source->second->Resolve<VolumeProducer>();
if (producer->Signals != nullptr)
{
auto callInfo = ref new AllJoynMessageInfo(AllJoynHelpers::MultibyteToPlatformString(alljoyn_message_getsender(message)));
auto eventArgs = ref new VolumeMuteChangedReceivedEventArgs();
eventArgs->MessageInfo = callInfo;
bool argument0;
TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "b", &argument0);
eventArgs->newMute = argument0;
producer->Signals->CallMuteChangedReceived(producer->Signals, eventArgs);
}
}
void VolumeProducer::CallVolumeChangedSignalHandler(_In_ const alljoyn_interfacedescription_member* member, _In_ alljoyn_message message)
{
auto source = SourceInterfaces.find(member->iface);
if (source == SourceInterfaces.end())
{
return;
}
auto producer = source->second->Resolve<VolumeProducer>();
if (producer->Signals != nullptr)
{
auto callInfo = ref new AllJoynMessageInfo(AllJoynHelpers::MultibyteToPlatformString(alljoyn_message_getsender(message)));
auto eventArgs = ref new VolumeVolumeChangedReceivedEventArgs();
eventArgs->MessageInfo = callInfo;
int16 argument0;
TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "n", &argument0);
eventArgs->newVolume = argument0;
producer->Signals->CallVolumeChangedReceived(producer->Signals, eventArgs);
}
}
QStatus VolumeProducer::AddMethodHandler(_In_ alljoyn_interfacedescription interfaceDescription, _In_ PCSTR methodName, _In_ alljoyn_messagereceiver_methodhandler_ptr handler)
{
alljoyn_interfacedescription_member member;
if (!alljoyn_interfacedescription_getmember(interfaceDescription, methodName, &member))
{
return ER_BUS_INTERFACE_NO_SUCH_MEMBER;
}
return alljoyn_busobject_addmethodhandler(
m_busObject,
member,
handler,
m_weak);
}
QStatus VolumeProducer::AddSignalHandler(_In_ alljoyn_busattachment busAttachment, _In_ alljoyn_interfacedescription interfaceDescription, _In_ PCSTR methodName, _In_ alljoyn_messagereceiver_signalhandler_ptr handler)
{
alljoyn_interfacedescription_member member;
if (!alljoyn_interfacedescription_getmember(interfaceDescription, methodName, &member))
{
return ER_BUS_INTERFACE_NO_SUCH_MEMBER;
}
return alljoyn_busattachment_registersignalhandler(busAttachment, handler, member, NULL);
}
QStatus VolumeProducer::OnPropertyGet(_In_ PCSTR interfaceName, _In_ PCSTR propertyName, _Inout_ alljoyn_msgarg value)
{
UNREFERENCED_PARAMETER(interfaceName);
if (0 == strcmp(propertyName, "Mute"))
{
auto task = create_task(Service->GetMuteAsync(nullptr));
auto result = task.get();
if (AllJoynStatus::Ok != result->Status)
{
return static_cast<QStatus>(result->Status);
}
return static_cast<QStatus>(TypeConversionHelpers::SetAllJoynMessageArg(value, "b", result->Mute));
}
if (0 == strcmp(propertyName, "Version"))
{
auto task = create_task(Service->GetVersionAsync(nullptr));
auto result = task.get();
if (AllJoynStatus::Ok != result->Status)
{
return static_cast<QStatus>(result->Status);
}
return static_cast<QStatus>(TypeConversionHelpers::SetAllJoynMessageArg(value, "q", result->Version));
}
if (0 == strcmp(propertyName, "Volume"))
{
auto task = create_task(Service->GetVolumeAsync(nullptr));
auto result = task.get();
if (AllJoynStatus::Ok != result->Status)
{
return static_cast<QStatus>(result->Status);
}
return static_cast<QStatus>(TypeConversionHelpers::SetAllJoynMessageArg(value, "n", result->Volume));
}
if (0 == strcmp(propertyName, "VolumeRange"))
{
auto task = create_task(Service->GetVolumeRangeAsync(nullptr));
auto result = task.get();
if (AllJoynStatus::Ok != result->Status)
{
return static_cast<QStatus>(result->Status);
}
return static_cast<QStatus>(TypeConversionHelpers::SetAllJoynMessageArg(value, "(nnn)", result->VolumeRange));
}
return ER_BUS_NO_SUCH_PROPERTY;
}
QStatus VolumeProducer::OnPropertySet(_In_ PCSTR interfaceName, _In_ PCSTR propertyName, _In_ alljoyn_msgarg value)
{
UNREFERENCED_PARAMETER(interfaceName);
if (0 == strcmp(propertyName, "Mute"))
{
bool argument;
TypeConversionHelpers::GetAllJoynMessageArg(value, "b", &argument);
auto task = create_task(Service->SetMuteAsync(nullptr, argument));
return static_cast<QStatus>(task.get());
}
if (0 == strcmp(propertyName, "Volume"))
{
int16 argument;
TypeConversionHelpers::GetAllJoynMessageArg(value, "n", &argument);
auto task = create_task(Service->SetVolumeAsync(nullptr, argument));
return static_cast<QStatus>(task.get());
}
return ER_BUS_NO_SUCH_PROPERTY;
}
void VolumeProducer::Start()
{
if (nullptr == m_busAttachment)
{
StopInternal(ER_FAIL);
return;
}
QStatus result = AllJoynHelpers::CreateInterfaces(m_busAttachment, c_VolumeIntrospectionXml);
if (result != ER_OK)
{
StopInternal(result);
return;
}
result = AllJoynHelpers::CreateBusObject<VolumeProducer>(m_weak);
if (result != ER_OK)
{
StopInternal(result);
return;
}
alljoyn_interfacedescription interfaceDescription = alljoyn_busattachment_getinterface(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), "org.alljoyn.Control.Volume");
if (interfaceDescription == nullptr)
{
StopInternal(ER_FAIL);
return;
}
alljoyn_busobject_addinterface_announced(BusObject, interfaceDescription);
result = AddMethodHandler(
interfaceDescription,
"AdjustVolume",
[](alljoyn_busobject busObject, const alljoyn_interfacedescription_member* member, alljoyn_message message) { UNREFERENCED_PARAMETER(member); CallAdjustVolumeHandler(busObject, message); });
if (result != ER_OK)
{
StopInternal(result);
return;
}
result = AddSignalHandler(
AllJoynHelpers::GetInternalBusAttachment(m_busAttachment),
interfaceDescription,
"MuteChanged",
[](const alljoyn_interfacedescription_member* member, PCSTR srcPath, alljoyn_message message) { UNREFERENCED_PARAMETER(srcPath); CallMuteChangedSignalHandler(member, message); });
if (result != ER_OK)
{
StopInternal(result);
return;
}
result = AddSignalHandler(
AllJoynHelpers::GetInternalBusAttachment(m_busAttachment),
interfaceDescription,
"VolumeChanged",
[](const alljoyn_interfacedescription_member* member, PCSTR srcPath, alljoyn_message message) { UNREFERENCED_PARAMETER(srcPath); CallVolumeChangedSignalHandler(member, message); });
if (result != ER_OK)
{
StopInternal(result);
return;
}
SourceObjects[m_busObject] = m_weak;
SourceInterfaces[interfaceDescription] = m_weak;
result = alljoyn_busattachment_registerbusobject(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), BusObject);
if (result != ER_OK)
{
StopInternal(result);
return;
}
m_busAttachmentStateChangedToken = m_busAttachment->StateChanged += ref new TypedEventHandler<AllJoynBusAttachment^,AllJoynBusAttachmentStateChangedEventArgs^>(this, &VolumeProducer::BusAttachmentStateChanged);
m_busAttachment->Connect();
}
void VolumeProducer::Stop()
{
StopInternal(AllJoynStatus::Ok);
}
void VolumeProducer::StopInternal(int32 status)
{
UnregisterFromBus();
Stopped(this, ref new AllJoynProducerStoppedEventArgs(status));
}
int32 VolumeProducer::RemoveMemberFromSession(_In_ String^ uniqueName)
{
return alljoyn_busattachment_removesessionmember(
AllJoynHelpers::GetInternalBusAttachment(m_busAttachment),
m_sessionId,
AllJoynHelpers::PlatformToMultibyteString(uniqueName).data());
}
PCSTR org::alljoyn::Control::c_VolumeIntrospectionXml = "<interface name=\"org.alljoyn.Control.Volume\">"
" <method name=\"AdjustVolume\">"
" <arg name=\"increments\" type=\"n\" direction=\"in\" />"
" </method>"
" <signal name=\"MuteChanged\">"
" <arg name=\"newMute\" type=\"b\" direction=\"out\" />"
" </signal>"
" <signal name=\"VolumeChanged\">"
" <arg name=\"newVolume\" type=\"n\" direction=\"out\" />"
" </signal>"
" <property name=\"Mute\" type=\"b\" access=\"readwrite\" />"
" <property name=\"Version\" type=\"q\" access=\"read\" />"
" <property name=\"Volume\" type=\"n\" access=\"readwrite\" />"
" <property name=\"VolumeRange\" type=\"(nnn)\" access=\"read\" />"
"</interface>"
;
| 35.107914 | 217 | 0.710656 | [
"object"
] |
fd5910c9ed06f96e8bf327f9e2ef7dcffc362d79 | 8,977 | cpp | C++ | src/rvs_util.cpp | jkottiku/ROCmValidationSuite | 18745cba0613886672109eb977708c03a830c9c1 | [
"MIT"
] | null | null | null | src/rvs_util.cpp | jkottiku/ROCmValidationSuite | 18745cba0613886672109eb977708c03a830c9c1 | [
"MIT"
] | null | null | null | src/rvs_util.cpp | jkottiku/ROCmValidationSuite | 18745cba0613886672109eb977708c03a830c9c1 | [
"MIT"
] | null | null | null | /********************************************************************************
*
* Copyright (c) 2018 ROCm Developer Tools
*
* MIT LICENSE:
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*******************************************************************************/
#include "include/rvs_util.h"
#include "include/rvsloglp.h"
#include "include/gpu_util.h"
#include <vector>
#include <string>
#include <regex>
#include <iomanip>
#include <algorithm>
#include "hip/hip_runtime.h"
#include "hip/hip_runtime_api.h"
/**
* splits a std::string based on a given delimiter
* @param str_val input std::string
* @param delimiter tokens' delimiter
* @return std::vector containing all tokens
*/
std::vector<std::string> str_split(const std::string& str_val,
const std::string& delimiter) {
std::vector<std::string> str_tokens;
int prev_pos = 0, cur_pos = 0;
do {
cur_pos = str_val.find(delimiter, prev_pos);
if (cur_pos == std::string::npos)
cur_pos = str_val.length();
std::string token = str_val.substr(prev_pos, cur_pos - prev_pos);
if (!token.empty())
str_tokens.push_back(token);
prev_pos = cur_pos + delimiter.length();
} while (cur_pos < str_val.length() && prev_pos < str_val.length());
return str_tokens;
}
/**
* checks if input std::string is a positive integer number
* @param str_val the input std::string
* @return true if std::string is a positive integer number, false otherwise
*/
bool is_positive_integer(const std::string& str_val) {
return !str_val.empty()
&& std::find_if(str_val.begin(), str_val.end(),
[](char c) {return !std::isdigit(c);}) == str_val.end();
}
int rvs_util_parse(const std::string& buff, bool* pval) {
if (buff.empty()) { // method empty
return 2; // not found
}
if (buff == "true") {
*pval = true;
return 0; // OK - true
}
if (buff == "false") {
*pval = false;
return 0; // OK - false
}
return 1; // syntax error
}
void *json_node_create(std::string module_name, std::string action_name,
int log_level){
unsigned int sec;
unsigned int usec;
rvs::lp::get_ticks(&sec, &usec);
void *json_node = rvs::lp::LogRecordCreate(module_name.c_str(),
action_name.c_str(), log_level, sec, usec, true);
return json_node;
}
/**
* summary: fethes gpu id to index map for valid set of GPUs as per config.
* Note: mcm_check is needed to output MCM specific messages while we iterate
* through list, because iet power readings vary on this.
* @out: map of gpu id to index in gpus_device_index and returns true if found
*/
bool fetch_gpu_list(int hip_num_gpu_devices, map<int, uint16_t>& gpus_device_index,
const std::vector<uint16_t>& property_device,
const int& property_device_id, bool property_device_all, bool mcm_check){
bool amd_gpus_found = false;
bool mcm_die = false;
bool amd_mcm_gpu_found = false;
for (int i = 0; i < hip_num_gpu_devices; i++) {
// get GPU device properties
hipDeviceProp_t props;
hipGetDeviceProperties(&props, i);
// compute device location_id (needed in order to identify this device
// in the gpus_id/gpus_device_id list
unsigned int dev_location_id =
((((unsigned int) (props.pciBusID)) << 8) | ((unsigned int)(props.pciDeviceID)) << 3);
uint16_t dev_domain = props.pciDomainID;
uint16_t devId;
uint16_t gpu_id;
if (rvs::gpulist::domlocation2gpu(dev_domain, dev_location_id, &gpu_id)) {
continue;
}
if (rvs::gpulist::gpu2device(gpu_id, &devId)){
continue;
}
// filter by device id if needed
if (property_device_id > 0 && property_device_id != devId)
continue;
// check if this GPU is part of the select ones as per config
// (device = "all" or the gpu_id is in the device: <gpu id> list)
bool cur_gpu_selected = false;
if (property_device_all) {
cur_gpu_selected = true;
} else {
// search for this gpu in the list
// provided under the <device> property
auto it_gpu_id = find(property_device.begin(),
property_device.end(),
gpu_id);
if (it_gpu_id != property_device.end())
cur_gpu_selected = true;
}
if (cur_gpu_selected) {
gpus_device_index.insert
(std::pair<int, uint16_t>(i, gpu_id));
amd_gpus_found = true;
}
// if mcm check enabled, print message if device is MCM
if (mcm_check){
std::stringstream msg_stream;
mcm_die = gpu_check_if_mcm_die(devId);
if (mcm_die) {
msg_stream.str("");
msg_stream << "GPU ID : " << std::setw(5) << gpu_id << " - " << "Device : " << std::setw(5) << devId <<
" - " << "GPU is a die/chiplet in Multi-Chip Module (MCM) GPU";
rvs::lp::Log(msg_stream.str(), rvs::logresults);
amd_mcm_gpu_found = true;
}
}
}
if (amd_mcm_gpu_found && mcm_check) {
std::stringstream msg_stream;
msg_stream.str("");
msg_stream << "Note: The system has Multi-Chip Module (MCM) GPU/s." << "\n"
<< "In MCM GPU, primary GPU die shows total socket (primary + secondary) power information." << "\n"
<< "Secondary GPU die does not have any power information associated with it independently."<< "\n";
rvs::lp::Log(msg_stream.str(), rvs::logresults);
}
return amd_gpus_found;
}
int display_gpu_info (void) {
struct device_info {
std::string bus;
std::string name;
int32_t node_id;
int32_t gpu_id;
int32_t device_id;
};
char buff[1024];
int hip_num_gpu_devices;
std::string errmsg = " No supported GPUs available.";
std::vector<device_info> gpu_info_list;
hipGetDeviceCount(&hip_num_gpu_devices);
if( hip_num_gpu_devices == 0){
std::cout << std::endl << errmsg << std::endl;
return 0;
}
for (int i = 0; i < hip_num_gpu_devices; i++) {
hipDeviceProp_t props;
hipGetDeviceProperties(&props, i);
// compute device location_id (needed in order to identify this device
// in the gpus_id/gpus_device_id list
unsigned int dev_location_id =
((((unsigned int) (props.pciBusID)) << 8) | ((unsigned int)(props.pciDeviceID)) << 3);
uint16_t dev_domain = props.pciDomainID;
uint16_t node_id;
if (rvs::gpulist::domlocation2node(dev_domain, dev_location_id, &node_id)) {
continue;
}
uint16_t gpu_id;
if (rvs::gpulist::domlocation2gpu(dev_domain, dev_location_id, &gpu_id)) {
continue;
}
uint16_t dev_id;
if (rvs::gpulist::gpu2device(gpu_id, &dev_id)){
continue;
}
snprintf(buff, sizeof(buff), "%04d:%02X:%02X.%d",props.pciDomainID, props.pciBusID, props.pciDeviceID, 0);
device_info info;
info.bus = buff;
info.name = props.name;
info.node_id = node_id;
info.gpu_id = gpu_id;
info.device_id = dev_id;
gpu_info_list.push_back(info);
}
std::sort(gpu_info_list.begin(), gpu_info_list.end(),
[](const struct device_info& a, const struct device_info& b) {
return a.node_id < b.node_id; });
if (!gpu_info_list.empty()) {
std::cout << "Supported GPUs available:\n";
for (const auto& info : gpu_info_list) {
std::cout << info.bus << " - GPU[" << std::setw(2) << info.node_id
<< " - " << std::setw(5) << info.gpu_id << "] " << info.name
<< " (Device " << info.device_id << ")\n";
}
} else {
std::cout << std::endl << errmsg << std::endl;
}
return 0;
}
| 36.052209 | 119 | 0.609558 | [
"vector"
] |
5b7e778c6b31bc3cc235882bc08f87f1b8e75315 | 8,592 | cc | C++ | net/rpc/client.cc | iceboy233/trunk | 83024a83f07a587e00a3f2e1906361de521d8f12 | [
"Apache-2.0"
] | 3 | 2021-12-23T06:36:48.000Z | 2021-12-23T10:49:01.000Z | net/rpc/client.cc | iceboy233/trunk | 83024a83f07a587e00a3f2e1906361de521d8f12 | [
"Apache-2.0"
] | null | null | null | net/rpc/client.cc | iceboy233/trunk | 83024a83f07a587e00a3f2e1906361de521d8f12 | [
"Apache-2.0"
] | null | null | null | #include "net/rpc/client.h"
#include <limits>
#include <utility>
#include <boost/icl/interval_set.hpp>
#include <boost/smart_ptr/intrusive_ptr.hpp>
#include <boost/smart_ptr/intrusive_ref_counter.hpp>
#include "absl/types/span.h"
#include "util/fibonacci-sequence.h"
namespace net {
namespace rpc {
class Client::Operation : public boost::intrusive_ref_counter<
Operation, boost::thread_unsafe_counter> {
public:
Operation(
Client &client,
const udp::endpoint &endpoint,
std::vector<uint8_t> request,
const RequestOptions &options,
std::function<void(std::error_code, std::vector<uint8_t>)> callback);
Operation(const Operation &) = delete;
Operation &operator=(const Operation &) = delete;
~Operation();
void send();
void unpack(absl::Span<uint8_t> fragment);
void abort(std::error_code ec);
private:
Client &client_;
steady_timer wait_timer_;
udp::endpoint endpoint_;
std::vector<uint8_t> request_;
RequestOptions options_;
std::function<void(std::error_code, std::vector<uint8_t>)> callback_;
uint64_t request_id_;
std::vector<std::vector<uint8_t>> request_buffers_;
util::FibonacciSequence<int> wait_sequence_;
bool finished_ = false;
std::error_code result_ec_ = make_error_code(std::errc::bad_address);
std::vector<uint8_t> response_;
boost::icl::interval_set<size_t> response_intervals_;
size_t response_size_ = std::numeric_limits<size_t>::max();
};
Client::Client(const any_io_executor &executor, const Options &options)
: executor_(executor),
options_(options) {
channels_.reserve(options_.num_channels);
for (int index = 0; index < options_.num_channels; ++index) {
// TODO(iceboy): Support IPv6.
channels_.push_back({
udp::socket(executor_, {udp::v4(), 0}),
std::make_unique<uint8_t[]>(options_.receive_buffer_size),
});
}
channels_iter_ = channels_.begin();
for (Channel &channel : channels_) {
receive(channel);
}
}
void Client::request(
const udp::endpoint &endpoint,
std::string_view method,
std::vector<uint8_t> request,
const RequestOptions &options,
std::function<void(std::error_code, std::vector<uint8_t>)> callback) {
if (!request.empty()) {
request.push_back(0);
}
request.insert(request.end(), method.begin(), method.end());
boost::intrusive_ptr<Operation>(new Operation(
*this, endpoint, std::move(request), options,
std::move(callback)))->send();
}
void Client::receive(Channel &channel) {
channel.socket.async_receive(
buffer(channel.receive_buffer.get(), options_.receive_buffer_size),
[this, &channel](std::error_code ec, size_t size) {
if (ec) {
if (ec == std::errc::operation_canceled) {
return;
}
receive(channel);
return;
}
channel.receive_size = size;
dispatch(channel);
});
}
void Client::dispatch(Channel &channel) {
if (channel.receive_size < sizeof(wire::response::Header)) {
receive(channel);
return;
}
const auto *response_header = reinterpret_cast<wire::response::Header *>(
&channel.receive_buffer[0]);
auto iter = operations_.find(
{response_header->key_fingerprint, response_header->request_id});
if (iter == operations_.end()) {
receive(channel);
return;
}
iter->second->unpack({channel.receive_buffer.get(), channel.receive_size});
receive(channel);
}
Client::Operation::Operation(
Client &client,
const udp::endpoint &endpoint,
std::vector<uint8_t> request,
const RequestOptions &options,
std::function<void(std::error_code, std::vector<uint8_t>)> callback)
: client_(client),
wait_timer_(client_.executor_),
endpoint_(endpoint),
request_(std::move(request)),
options_(options),
callback_(std::move(callback)) {
uint64_t key_fingerprint = options_.key.fingerprint();
do {
request_id_ = absl::Uniform<uint64_t>(client_.gen_);
} while (!client_.operations_.emplace(
OperationKey{key_fingerprint, request_id_}, this).second);
security::NonceArray nonce{};
*reinterpret_cast<uint64_t *>(&nonce[0]) = request_id_;
size_t offset = 0;
do {
size_t size = std::min(request_.size() - offset,
client_.options_.send_fragment_size);
request_buffers_.emplace_back(sizeof(wire::request::Header) + size +
security::Key::encrypt_overhead);
auto *request_header = reinterpret_cast<wire::request::Header *>(
&request_buffers_.back()[0]);
request_header->key_fingerprint = key_fingerprint;
request_header->request_id = request_id_;
request_header->offset = static_cast<uint16_t>(offset);
request_header->flags = 0;
if (offset + size < request_.size()) {
request_header->flags |= wire::request::flags::partial;
}
*reinterpret_cast<uint16_t *>(&nonce[8]) =
static_cast<uint16_t>(offset);
size_t encrypt_result = options_.key.encrypt(
{&request_[offset], size},
&nonce[0],
&request_buffers_.back()[sizeof(wire::request::Header)]);
request_buffers_.back().resize(
sizeof(wire::request::Header) + encrypt_result);
offset += size;
} while (offset < request_.size());
}
Client::Operation::~Operation() {
client_.operations_.erase({options_.key.fingerprint(), request_id_});
if (result_ec_) {
callback_(result_ec_, {});
return;
}
response_.resize(response_size_);
callback_({}, std::move(response_));
}
void Client::Operation::send() {
if (options_.timeout <= std::chrono::nanoseconds::zero()) {
abort(make_error_code(std::errc::timed_out));
return;
}
Channel &channel = *client_.channels_iter_++;
if (client_.channels_iter_ == client_.channels_.end()) {
client_.channels_iter_ = client_.channels_.begin();
}
for (const std::vector<uint8_t> &request_buffer : request_buffers_) {
channel.socket.async_send_to(
buffer(request_buffer),
endpoint_,
[_ = boost::intrusive_ptr<Operation>(this)](
std::error_code, size_t) {});
}
std::chrono::nanoseconds wait_period =
std::min(options_.initial_retry * wait_sequence_.a(), options_.timeout);
wait_sequence_.next();
options_.timeout -= wait_period;
wait_timer_.expires_after(wait_period);
wait_timer_.async_wait(
[this, _ = boost::intrusive_ptr<Operation>(this)](std::error_code ec) {
if (ec) {
if (ec != std::errc::operation_canceled) {
abort(ec);
}
return;
}
send();
});
}
void Client::Operation::unpack(absl::Span<uint8_t> fragment) {
if (finished_) {
return;
}
const auto *response_header = reinterpret_cast<wire::response::Header *>(
&fragment[0]);
size_t offset = response_header->offset;
size_t response_body_size =
fragment.size() - sizeof(wire::response::Header);
if (response_.size() < offset + response_body_size) {
response_.resize(offset + response_body_size);
}
security::NonceArray nonce{};
*reinterpret_cast<uint64_t *>(&nonce[0]) = response_header->request_id;
*reinterpret_cast<uint16_t *>(&nonce[8]) = response_header->offset;
nonce[11] = 1;
size_t decrypt_result = options_.key.decrypt(
{&fragment[sizeof(wire::response::Header)], response_body_size},
&nonce[0],
&response_[offset]);
if (decrypt_result == std::numeric_limits<size_t>::max()) {
return;
}
response_intervals_ += boost::icl::interval<size_t>::right_open(
offset, offset + decrypt_result);
if (!(response_header->flags & wire::response::flags::partial)) {
response_size_ = offset + decrypt_result;
}
if (contains(response_intervals_,
boost::icl::interval<size_t>::right_open(0, response_size_))) {
finished_ = true;
result_ec_ = {};
wait_timer_.cancel();
}
}
void Client::Operation::abort(std::error_code ec) {
if (finished_) {
return;
}
finished_ = true;
result_ec_ = ec;
wait_timer_.cancel();
}
} // namespace rpc
} // namespace net
| 34.506024 | 80 | 0.628492 | [
"vector"
] |
5b89208df86460fa81801fd030b4e663007143ef | 555 | cpp | C++ | src/zoneserver/controller/callback/EntityEvents.cpp | mark-online/server | ca24898e2e5a9ccbaa11ef1ade57bb25260b717f | [
"MIT"
] | null | null | null | src/zoneserver/controller/callback/EntityEvents.cpp | mark-online/server | ca24898e2e5a9ccbaa11ef1ade57bb25260b717f | [
"MIT"
] | null | null | null | src/zoneserver/controller/callback/EntityEvents.cpp | mark-online/server | ca24898e2e5a9ccbaa11ef1ade57bb25260b717f | [
"MIT"
] | null | null | null | #include "ZoneServerPCH.h"
#include "EntityEvents.h"
#include "EntityStatusCallback.h"
#include "../EntityController.h"
#include "../../model/gameobject/Entity.h"
namespace gideon { namespace zoneserver {
void TargetChangedEvent::call(go::Entity& entity)
{
gc::EntityStatusCallback* entityStatusCallback =
entity.getController().queryEntityStatusCallback();
if (entityStatusCallback != nullptr) {
entityStatusCallback->entityTargetChanged(entityInfo_, targetStatusInfo_);
}
}
}} // namespace gideon { namespace zoneserver {
| 29.210526 | 82 | 0.742342 | [
"model"
] |
5b8d236e0973b84adb51ec8aaf23c744a50697bb | 5,961 | cpp | C++ | context.cpp | qbit-t/qb | c1fd82df3838f8526fc5e335254529ab6f953f78 | [
"MIT"
] | 1 | 2021-02-14T04:04:50.000Z | 2021-02-14T04:04:50.000Z | context.cpp | qbit-t/qb | c1fd82df3838f8526fc5e335254529ab6f953f78 | [
"MIT"
] | null | null | null | context.cpp | qbit-t/qb | c1fd82df3838f8526fc5e335254529ab6f953f78 | [
"MIT"
] | 1 | 2021-08-28T07:42:43.000Z | 2021-08-28T07:42:43.000Z | #include "context.h"
#include <stdio.h>
#include <string.h>
#include <vector>
#include "include/secp256k1.h"
#include "include/secp256k1_ecdh.h"
#include "include/secp256k1_schnorrsig.h"
#include "include/secp256k1_generator.h"
#include "include/secp256k1_rangeproof.h"
#include "libsecp256k1-config.h"
#include "log/log.h"
#include <boost/thread.hpp>
#include "hash_impl.h"
#include "num_impl.h"
#include "field_impl.h"
#include "group_impl.h"
#include "scalar_impl.h"
using namespace qbit;
#include <signal.h>
Context::Context() {
}
Context::~Context() {
if (context_) {
secp256k1_context_destroy(context_);
secp256k1_context_destroy(none_);
}
if (scratch_) {
secp256k1_scratch_space_destroy(scratch_);
}
}
secp256k1_context* Context::noneContext() {
initialize();
return none_;
}
secp256k1_context* Context::signatureContext() {
initialize();
return context_;
}
ContextPtr Context::instance() {
//
static boost::thread_specific_ptr<ContextPtr> tContext;
if (!tContext.get()) {
tContext.reset(new ContextPtr(new Context()));
return ContextPtr(*tContext.get());
}
return ContextPtr(*tContext.get());
}
secp256k1_scratch_space* Context::signatureScratch() {
if (!scratch_) scratch_ = secp256k1_scratch_space_create(context_, 1024 * 1024 * 1024); // magic digits
return scratch_;
}
void Context::initialize()
{
if (!context_) {
none_ = secp256k1_context_create(SECP256K1_CONTEXT_NONE);
context_ = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY | SECP256K1_CONTEXT_SIGN);
}
}
bool Context::createCommitment(qbit::vector<unsigned char>& out, const uint256& blind, amount_t amount) {
secp256k1_pedersen_commitment lCommit;
unsigned char lSerialized[33];
if (secp256k1_pedersen_commit(signatureContext(), &lCommit, blind.begin(), amount, secp256k1_generator_h)) {
secp256k1_pedersen_commitment_serialize(signatureContext(), lSerialized, &lCommit);
out.insert(out.end(), lSerialized, lSerialized + sizeof(lSerialized));
return true;
}
return false;
}
bool Context::createRangeProof(qbit::vector<unsigned char>& out, const qbit::vector<unsigned char>& commit, const uint256& blind, const uint256& nonce, amount_t amount) {
unsigned char lProof[5134 + 1];
size_t lLen = 5134;
secp256k1_pedersen_commitment lCommit;
if (secp256k1_pedersen_commitment_parse(signatureContext(), &lCommit, &commit[0]))
if (secp256k1_rangeproof_sign(signatureContext(), lProof, &lLen, 0, &lCommit, blind.begin(), nonce.begin(), 0, 0, amount, NULL, 0, NULL, 0, secp256k1_generator_h)) {
out.insert(out.end(), lProof, lProof + lLen);
return true;
}
return false;
}
bool Context::verifyRangeProof(const unsigned char* commit, const unsigned char* proof, size_t size) {
uint64_t lMinValue;
uint64_t lMaxValue;
secp256k1_pedersen_commitment lCommit;
if (secp256k1_pedersen_commitment_parse(signatureContext(), &lCommit, commit))
if (secp256k1_rangeproof_verify(signatureContext(), &lMinValue, &lMaxValue, &lCommit, proof, size, NULL, 0, secp256k1_generator_h))
return true;
return false;
}
bool Context::rewindRangeProof(uint64_t* vout, uint256& blind, const uint256& nonce, const unsigned char* commit, const unsigned char* proof, size_t size) {
uint64_t lMinValue;
uint64_t lMaxValue;
secp256k1_pedersen_commitment lCommit;
if (secp256k1_pedersen_commitment_parse(signatureContext(), &lCommit, commit))
if (secp256k1_rangeproof_rewind(signatureContext(), blind.begin(), vout, NULL, NULL, nonce.begin(), &lMinValue, &lMaxValue, &lCommit, proof, size, NULL, 0, secp256k1_generator_h))
return true;
return false;
}
bool Context::verifyTally(const std::list<std::vector<unsigned char>>& in, const std::list<std::vector<unsigned char>>& out) {
std::vector<secp256k1_pedersen_commitment> lIn;
std::vector<secp256k1_pedersen_commitment> lOut;
std::vector<secp256k1_pedersen_commitment*> lInPtr;
std::vector<secp256k1_pedersen_commitment*> lOutPtr;
lIn.resize(in.size());
lOut.resize(out.size());
lInPtr.resize(in.size());
lOutPtr.resize(out.size());
int lIdx = 0;
for (std::list<std::vector<unsigned char>>::const_iterator lInIter = in.begin(); lInIter != in.end(); lInIter++, lIdx++) {
if (secp256k1_pedersen_commitment_parse(signatureContext(), &lIn[lIdx], &(*lInIter)[0])) {
lInPtr[lIdx] = &lIn[lIdx];
} else return false;
}
lIdx = 0;
for (std::list<std::vector<unsigned char>>::const_iterator lOutIter = out.begin(); lOutIter != out.end(); lOutIter++, lIdx++) {
if (secp256k1_pedersen_commitment_parse(signatureContext(), &lOut[lIdx], &(*lOutIter)[0])) {
lOutPtr[lIdx] = &lOut[lIdx];
} else return false;
}
if (!secp256k1_pedersen_verify_tally(signatureContext(), &lInPtr[0], lInPtr.size(), &lOutPtr[0], lOutPtr.size())) return false;
return true;
}
bool Math::add(uint256& c, const uint256& a, const uint256& b) {
int lOverflow;
secp256k1_scalar lA; secp256k1_scalar_set_b32(&lA, a.begin(), &lOverflow); if (lOverflow) return 0;
secp256k1_scalar lB; secp256k1_scalar_set_b32(&lB, b.begin(), &lOverflow); if (lOverflow) return 0;
secp256k1_scalar lC;
secp256k1_scalar_add(&lC, &lA, &lB);
unsigned char lRawC[32];
secp256k1_scalar_get_b32(lRawC, &lC);
c.set(lRawC);
return 1;
}
bool Math::mul(uint256& c, const uint256& a, const uint256& b) {
int lOverflow;
secp256k1_scalar lA; secp256k1_scalar_set_b32(&lA, a.begin(), &lOverflow); if (lOverflow) return 0;
secp256k1_scalar lB; secp256k1_scalar_set_b32(&lB, b.begin(), &lOverflow); if (lOverflow) return 0;
secp256k1_scalar lC;
secp256k1_scalar_mul(&lC, &lA, &lB);
unsigned char lRawC[32];
secp256k1_scalar_get_b32(lRawC, &lC);
c.set(lRawC);
return 1;
}
bool Math::neg(uint256& c, const uint256& a) {
int lOverflow;
secp256k1_scalar lA; secp256k1_scalar_set_b32(&lA, a.begin(), &lOverflow); if (lOverflow) return 0;
secp256k1_scalar lC;
secp256k1_scalar_negate(&lC, &lA);
unsigned char lRawC[32];
secp256k1_scalar_get_b32(lRawC, &lC);
c.set(lRawC);
return 1;
}
| 29.656716 | 181 | 0.742157 | [
"vector"
] |
5b8f8b0ed80be7ca718ea53e6cdab644acec15a4 | 30,257 | cc | C++ | source/src/Algorithm/Calorimetry/TrackFinderAlgorithm.cc | rete/Baboon | e5b2cfe6b9e5b5a41c2c68feda84b8df109eb086 | [
"FSFAP"
] | null | null | null | source/src/Algorithm/Calorimetry/TrackFinderAlgorithm.cc | rete/Baboon | e5b2cfe6b9e5b5a41c2c68feda84b8df109eb086 | [
"FSFAP"
] | null | null | null | source/src/Algorithm/Calorimetry/TrackFinderAlgorithm.cc | rete/Baboon | e5b2cfe6b9e5b5a41c2c68feda84b8df109eb086 | [
"FSFAP"
] | null | null | null | /// \file TrackFinderAlgorithm.cc
/*
*
* TrackFinderAlgorithm.cc source template generated by fclass
* Creation date : mar. oct. 8 2013
*
* This file is part of XXX libraries.
*
* XXX 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 3 of the License, or
* (at your option) any later version.
* based upon these libraries are permitted. Any copy of these libraries
* must include this copyright notice.
*
* XXX 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 XXX. If not, see <http://www.gnu.org/licenses/>.
*
* @author : Et� R�mi
* @version
* @copyright
*
*
*/
#include "Algorithm/Calorimetry/TrackFinderAlgorithm.hh"
using namespace std;
namespace baboon {
TrackFinderAlgorithm::Point::Point() {
connectors = new ConnectorCollection();
}
TrackFinderAlgorithm::Point::~Point() {
// no connector deletion since, there
// are not created in the Point object
connectors->clear();
delete connectors;
}
void TrackFinderAlgorithm::Point::AddConnector( TrackFinderAlgorithm::Connector *connector ) {
if( connector == 0 )
return;
if( !this->IsConnectedTo( connector ) ) {
connectors->push_back( connector );
}
return;
}
void TrackFinderAlgorithm::Point::RemoveConnector( TrackFinderAlgorithm::Connector *connector ) {
if( connector == 0 )
return;
std::vector<TrackFinderAlgorithm::Connector*>::iterator it = std::find( connectors->begin() , connectors->end() , connector );
if( it != connectors->end() ) {
connectors->erase( it );
}
return;
}
bool TrackFinderAlgorithm::Point::IsConnectedTo( Connector *connector ) {
return ( std::find( connectors->begin() , connectors->end() , connector ) != connectors->end() );
}
bool TrackFinderAlgorithm::Point::IsConnectedTo( Point *point ) {
for( unsigned int c=0 ; c<connectors->size() ; c++ )
if( connectors->at( c )->GetSecond() == point )
return true;
return false;
}
void TrackFinderAlgorithm::Point::SetCluster( Cluster *cl ) {
cluster = cl;
}
Cluster *TrackFinderAlgorithm::Point::GetCluster() {
return cluster;
}
bool TrackFinderAlgorithm::Point::HasNoConnection() {
return connectors->empty();
}
TrackFinderAlgorithm::ConnectorCollection *TrackFinderAlgorithm::Point::GetConnectors() {
return connectors;
}
int TrackFinderAlgorithm::Point::HowManyBackwardConnectors() {
int count = 0;
for( unsigned int c=0 ; c<connectors->size() ; c++ )
if( connectors->at( c )->GetSecond()->GetCluster()->GetPosition().z() < cluster->GetPosition().z() )
count++;
return count;
}
int TrackFinderAlgorithm::Point::HowManyForwardConnectors() {
int count = 0;
for( unsigned int c=0 ; c<connectors->size() ; c++ )
if( connectors->at( c )->GetSecond()->GetCluster()->GetPosition().z() > cluster->GetPosition().z() )
count++;
return count;
}
// -----------------------------------------------------------------------------------------------------
void TrackFinderAlgorithm::Connector::Connect( Point *point1 , Point *point2 ) {
if( point1 == 0 || point2 == 0 )
return;
pointPair.first = point1;
pointPair.second = point2;
}
void TrackFinderAlgorithm::Connector::Disconnect() {
pointPair.first = 0;
pointPair.second = 0;
}
TrackFinderAlgorithm::Point *TrackFinderAlgorithm::Connector::GetFirst() {
return pointPair.first;
}
TrackFinderAlgorithm::Point *TrackFinderAlgorithm::Connector::GetSecond() {
return pointPair.second;
}
//-------------------------------------------------------------------------------------------------
TrackFinderAlgorithm::TrackFinderAlgorithm()
: AbstractAlgorithm("TrackFinderAlgorithm") {
needData = true;
allPoints = new PointCollection();
connectorCollection = new ConnectorCollection();
pointHelpers = new PointHelperCollection();
}
TrackFinderAlgorithm::~TrackFinderAlgorithm() {
delete allPoints;
delete connectorCollection;
delete pointHelpers;
}
Return TrackFinderAlgorithm::Init() {
data.GetValue( "clusterSizeLimit" , &clusterSizeLimit );
data.GetValue( "minimumTrackSize" , &minimumTrackSize );
data.GetValue( "lookupDistanceX" , &lookupDistanceX );
data.GetValue( "lookupDistanceY" , &lookupDistanceY );
data.GetValue( "lookupDistanceZ" , &lookupDistanceZ );
data.GetValue( "maximumConnectorsAngle" , &maximumConnectorsAngle );
data.GetValue( "drawConnectors" , &drawConnectors);
return BABOON_SUCCESS();
}
Return TrackFinderAlgorithm::CheckConsistency() {
BABOON_CHECK_POINTER( calorimeter );
return BABOON_SUCCESS();
}
Return TrackFinderAlgorithm::Execute() {
ClusteringManager *clusteringManager = ClusteringManager::GetInstance();
ClusterCollection *clusters2D = clusteringManager->GetCluster2D();
// Return if there's no 2D clusters
if( clusters2D->empty() )
return BABOON_SUCCESS();
unsigned int nbOfLayers = calorimeter->GetNbOfLayers();
double cellSize0 = calorimeter->GetCellSize0();
double cellSize1 = calorimeter->GetCellSize1();
double layerThickness = calorimeter->GetLayerThickness();
double absorberThickness = calorimeter->GetAbsorberThickness();
int repeatX = calorimeter->GetRepeatX();
int repeatY = calorimeter->GetRepeatY();
double shiftXFactor = cellSize0*repeatX / 2.0;
double shiftYFactor = cellSize1*repeatY / 2.0;
double shiftZFactor = absorberThickness + ( layerThickness - absorberThickness ) / 2.0 ;
// Keep all the clusters that can be contained in tracks
OrderedPointCollection *orderedPoints = new OrderedPointCollection();
for( unsigned int cl=0 ; cl<clusters2D->size() ; cl++ ) {
Cluster *cluster = clusters2D->at( cl );
// Keep or not the cluster. See the function itself
if( !this->KeepCluster( cluster , clusters2D ) )
continue;
CaloHitCollection *caloHitCol = cluster->GetCaloHitCollection();
unsigned int clusterLayer = cluster->GetCaloHitCollection()->at(0)->GetIJK().at(2);
Point *point = new Point();
point->SetCluster( cluster );
if( (*orderedPoints)[ clusterLayer ] == 0 ) {
(*orderedPoints)[ clusterLayer ] = new PointCollection();
}
(*orderedPoints)[ clusterLayer ]->push_back( point );
allPoints->push_back( point );
}
for( unsigned int l=0 ; l<nbOfLayers ; l++ ) {
if( (*orderedPoints)[ l ] == 0 )
continue;
PointCollection *pointsInLayer = (*orderedPoints)[ l ];
for( unsigned int p=0 ; p<pointsInLayer->size() ; p++ ) {
Point *pointInLayer = pointsInLayer->at( p );
for( unsigned int nextL=l+1 ; (nextL-l)<=lookupDistanceZ ; nextL++ ) {
if( nextL > nbOfLayers )
continue;
PointCollection *nextPointCollection = (*orderedPoints)[ nextL ];
bool found = this->ConnectWithLayer( pointInLayer , nextPointCollection );
if( found )
break;
}
}
}
// Here all the possible connections are made. We need to remove some of them
// and keep only real track connectors and so track points
for( unsigned int p=0 ; p<allPoints->size() ; p++ ) {
Point *point = allPoints->at( p );
int nbOfForwardConnections = point->HowManyForwardConnectors();
// If no connection is the next planes,
// the cluster is not a good one to start with.
if( nbOfForwardConnections == 0 )
continue;
// Use a struct with the needed information to follow the connectors
PointHelper *pointHelper = new PointHelper();
pointHelper->point = point;
pointHelper->forwardPoint = 0;
pointHelper->forwardConnector = 0;
pointHelper->pointCollection = new PointCollection();
pointHelper->pointCollection->push_back( point );
pointHelper->isFirstPoint = true;
pointHelpers->push_back( pointHelper );
// The recursive function ...
this->FindPotentialTrack( pointHelper );
}
this->SortPotentialTracksBySize();
std::vector<PointCollection *> finalTracks;
PointCollection treatedPoints;
for( unsigned int pt=0 ; pt<potentialTrackPoints.size() ; pt++ ) {
PointCollection *potentialTrack = potentialTrackPoints.at( pt );
if( pt == 0 ) {
finalTracks.push_back( potentialTrack );
treatedPoints = PointCollection( *potentialTrack );
}
else {
// Check if some points are already used by treated tracks
for( unsigned int p=0 ; p<potentialTrack->size() ; p++ ) {
Point *point = potentialTrack->at( p );
if( std::find( treatedPoints.begin() , treatedPoints.end() , point ) != treatedPoints.end() ) {
potentialTrack->erase( potentialTrack->begin()+p );
p --;
}
}
// Keep the track if after removing the redundant clusters the track is long enough
if( potentialTrack->size() >= minimumTrackSize ) {
// First, find if there is a hole in the track, that is to
// say a track with at least two empty layers. In this case,
// delete this track ...
this->SortPointsByLayer( potentialTrack );
bool shouldKeep = true;
for( unsigned int p=0 ; p<potentialTrack->size() ; p++ ) {
if( p != potentialTrack->size() - 1 ) {
Point *point = potentialTrack->at( p );
Point *nextPoint = potentialTrack->at( p+1 );
if( fabs( point->GetCluster()->GetPosition().z() - nextPoint->GetCluster()->GetPosition().z() ) > 2 ) {
shouldKeep = false;
break;
}
}
}
// ... else keep this track ! This is a good one !
if( shouldKeep ) {
finalTracks.push_back( potentialTrack );
for( unsigned int p=0 ; p<potentialTrack->size() ; p++ ) {
treatedPoints.push_back( potentialTrack->at( p ) );
}
} // shouldKeep
} // if minimumTrackSize
} // else
} // for
// Here the tracks are made.
// We need to create "Track *" objects and register them in the TrackManager.
TrackCollection tempTrackCollection;
for( unsigned int pt=0 ; pt<finalTracks.size() ; pt++ ) {
PointCollection *trackPoints = finalTracks.at( pt );
// ClusterCollection *trackClusters = finalTracks.at( pt );
Track *track = new Track();
for( unsigned int cl=0 ; cl<trackPoints->size() ; cl++ ) {
CaloHitCollection *clusterHits = trackPoints->at( cl )->GetCluster()->GetCaloHitCollection();
for( unsigned int h=0 ; h<clusterHits->size() ; h++ ) {
BABOON_THROW_RESULT_IF( BABOON_SUCCESS() , != , track->AddCaloHit( clusterHits->at(h) ) );
clusterHits->at(h)->SetTag( TrackTag() );
}
}
if( drawConnectors )
this->DrawTrackConnectors( trackPoints , pt+2 );
track->SortHits();
CaloHitCollection *trackHits = track->GetCaloHitCollection();
int lastTrackLayer = track->GetCaloHitCollection()->at( track->Size() - 1 )->GetIJK().at(2);
int firstTrackLayer = track->GetCaloHitCollection()->at( 0 )->GetIJK().at(2);
ClusterCollection trackClusters;
Cluster *currentCluster = new Cluster();
for( unsigned int h=0 ; h<trackHits->size() ; h++ ) {
CaloHit *caloHit = trackHits->at( h );
if( h == trackHits->size() - 1 ) {
currentCluster->AddCaloHit( caloHit );
trackClusters.push_back( currentCluster );
break;
}
CaloHit *hit = trackHits->at( h );
CaloHit *nextHit = trackHits->at( h+1 );
if( hit->GetIJK().at(2) == nextHit->GetIJK().at(2) ) {
currentCluster->AddCaloHit( hit );
continue;
}
else {
currentCluster->AddCaloHit( hit );
trackClusters.push_back( currentCluster );
currentCluster = new Cluster();
}
}
currentCluster = 0;
ThreeVector tempBackwardThrust;
ThreeVector tempForwardThrust;
for( unsigned int cl=0 ; cl<trackClusters.size() ; cl++ ) {
if( cl == 0 )
track->SetBeginPosition( trackClusters.at( cl )->GetPosition( fComputePosition ) );
if( cl == trackClusters.size() - 1 ) {
track->SetEndPosition( trackClusters.at( cl )->GetPosition( fComputePosition ) );
break;
}
Cluster *cluster = trackClusters.at( cl );
Cluster *nextCluster = trackClusters.at( cl+1 );
ThreeVector difference = nextCluster->GetPosition( fComputePosition ) - cluster->GetPosition( fComputePosition );
if( difference.z() < 0 )
difference = -difference;
// for the track beginning
if( cl < 4 ) {
tempBackwardThrust += difference;
}
// for the track end
if( cl > trackClusters.size() - 4 ) {
tempForwardThrust += difference;
}
}
if( tempBackwardThrust != ThreeVector() )
tempBackwardThrust.setMag( 1.f );
if( tempForwardThrust != ThreeVector() )
tempForwardThrust.setMag( 1.f );
if( tempBackwardThrust.z() > 0 )
tempBackwardThrust = -tempBackwardThrust;
if( tempForwardThrust.z() < 0 )
tempForwardThrust = -tempForwardThrust;
track->SetBackwardThrust( tempBackwardThrust );
track->SetForwardThrust( tempForwardThrust );
tempTrackCollection.push_back( track );
for( unsigned int cl=0 ; cl<trackClusters.size() ; cl++ ) {
if( trackClusters.at( cl ) != 0 )
delete trackClusters.at( cl );
}
trackClusters.clear();
}
double angle1 = 0.14;
double angle2 = 0.14;
double difPos = 100;
// TO DO :
// Comparer le début des deux traces en cours.
// Broken track correction
for( unsigned int tr1=0 ; tr1<tempTrackCollection.size() ; tr1++ ) {
Track *track1 = tempTrackCollection.at( tr1 );
if( track1 == 0 )
continue;
for( unsigned int tr2=0 ; tr2<tempTrackCollection.size() ; tr2++ ) {
if( tr1 == tr2 )
continue;
Track *track2 = tempTrackCollection.at( tr2 );
if( track2 == 0 )
continue;
// if( track1 == 0 )
// continue;
// cout << endl;
// cout << "Track 1 end : " << track1->GetEndPosition()/26.131 << endl;
// cout << "Track 2 begin : " << track2->GetBeginPosition()/26.131 << endl;
// cout << "Angle 1 of : ";
// cout << track1->GetForwardThrust().angle( -track2->GetBackwardThrust() ) << endl;
// cout << " , an angle 2 of : ";
// cout << track1->GetForwardThrust().angle( track2->GetBeginPosition() - track1->GetEndPosition() ) << endl;
// cout << " and a pos dif of : ";
// cout << (track1->GetEndPosition() - track2->GetBeginPosition() ).mag() << endl;
// cout << endl;
if( track1->GetForwardThrust().angle( -track2->GetBackwardThrust() ) < angle1
// && track1->GetForwardThrust().angle( track2->GetBeginPosition() - track1->GetEndPosition() ) < angle2
&& (track1->GetEndPosition() - track2->GetBeginPosition() ).mag() < difPos ) {
for( unsigned int h=0 ; h<track2->Size() ; h++ ) {
track1->AddCaloHit( track2->GetCaloHitCollection()->at( h ) );
}
// cout << "!!! FOUND !!!" << endl;
// cout << "Track 1 end : " << track1->GetEndPosition()/26.131 << endl;
// cout << "Track 2 begin : " << track2->GetBeginPosition()/26.131 << endl;
// cout << "Broken tracks compatibles with an angle 1 of : ";
// cout << track1->GetForwardThrust().angle( -track2->GetBackwardThrust() ) << endl;
// cout << " , an angle 2 of : ";
// cout << track1->GetForwardThrust().angle( track2->GetBeginPosition() - track1->GetEndPosition() ) << endl;
// cout << " and a pos dif of : ";
// cout << (track1->GetEndPosition() - track2->GetBeginPosition() ).mag() << endl;
track1->SetEndPosition( track2->GetEndPosition() );
track1->SetForwardThrust( track2->GetForwardThrust() );
delete track2;
tempTrackCollection.at( tr2 ) = 0;
}
else if( track2->GetForwardThrust().angle( -track1->GetBackwardThrust() ) < angle1
// && track1->GetForwardThrust().angle( track2->GetBeginPosition() - track1->GetEndPosition() ) < angle2
&& ( track2->GetEndPosition() - track1->GetBeginPosition() ).mag() < difPos ) {
for( unsigned int h=0 ; h<track1->Size() ; h++ ) {
track2->AddCaloHit( track1->GetCaloHitCollection()->at( h ) );
}
// cout << "!!! FOUND !!!" << endl;
// cout << "Track 1 begin : " << track1->GetBeginPosition()/26.131 << endl;
// cout << "Track 2 end : " << track2->GetEndPosition()/26.131 << endl;
// cout << "Broken tracks compatibles with an angle 1 of : ";
// cout << track2->GetForwardThrust().angle( -track1->GetBackwardThrust() ) << endl;
// cout << " , an angle 2 of : ";
// cout << track2->GetForwardThrust().angle( track1->GetBeginPosition() - track2->GetEndPosition() ) << endl;
// cout << " and a pos dif of : ";
// cout << (track2->GetEndPosition() - track1->GetBeginPosition() ).mag() << endl;
track2->SetEndPosition( track1->GetEndPosition() );
track2->SetForwardThrust( track1->GetForwardThrust() );
delete track1;
tempTrackCollection.at( tr1 ) = 0;
break;
}
}
}
// cout << "nb of tracks (before) : " << tempTrackCollection.size() << endl;
for( unsigned int tr=0 ; tr<tempTrackCollection.size() ; tr++ ) {
if( tempTrackCollection.at( tr ) != 0 ) {
BABOON_THROW_RESULT_IF( BABOON_SUCCESS() , != , TrackManager::GetInstance()->AddTrack( tempTrackCollection.at( tr ) ) );
}
// if( drawConnectors )
// this->DrawTrackConnectors( trackPoints , pt+1 );
}
// cout << "nb of tracks (after): " << TrackManager::GetInstance()->GetTrackCollection()->size() << endl;
tempTrackCollection.clear();
// deletion area
for( unsigned int c=0 ; c<connectorCollection->size() ; c++ ) {
if( connectorCollection->at( c ) != 0 ) {
delete connectorCollection->at( c );
}
}
connectorCollection->clear();
for( unsigned int p=0 ; p<pointHelpers->size() ; p++ ) {
if( pointHelpers->at( p ) != 0 ) {
pointHelpers->at( p )->pointCollection->clear();
delete pointHelpers->at( p )->pointCollection;
delete pointHelpers->at( p );
}
}
pointHelpers->clear();
for( unsigned int p=0 ; p<allPoints->size() ; p++ ) {
if( allPoints->at( p ) != 0 ) {
delete allPoints->at( p );
}
}
allPoints->clear();
for( unsigned int pt=0 ; pt<potentialTrackPoints.size() ; pt++ ) {
potentialTrackPoints.at( pt )->clear();
delete potentialTrackPoints.at( pt );
}
potentialTrackPoints.clear();
OrderedPointCollection::iterator it;
for( it=orderedPoints->begin() ; it!=orderedPoints->end() ; it++ ) {
if( it->second != 0 ) {
it->second->clear();
delete it->second;
}
}
orderedPoints->clear();
return BABOON_SUCCESS();
}
Return TrackFinderAlgorithm::End() {
calorimeter = 0;
// VALGRIND_DO_QUICK_LEAK_CHECK;
return BABOON_SUCCESS();
}
bool TrackFinderAlgorithm::KeepCluster( Cluster *cluster , ClusterCollection *clusterCollection ) {
if( cluster == 0 )
return false;
if( cluster->Size() > clusterSizeLimit )
return false;
if( clusterCollection == 0 )
return true;
ThreeVector clusterPosition = cluster->GetPosition( fComputePosition );
int neighborClusters = 0;
for( unsigned int cl=0 ; cl<clusterCollection->size() ; cl++ ) {
Cluster *otherCluster = clusterCollection->at( cl );
if( otherCluster == cluster )
continue;
ThreeVector otherClusterPosition = otherCluster->GetPosition( fComputePosition );
// look in the same layer
if( otherClusterPosition.z() != clusterPosition.z() )
continue;
if( fabs( otherClusterPosition.x() - clusterPosition.x() ) < 40.1
&& fabs( otherClusterPosition.y() - clusterPosition.y() ) < 40.1 ) {
neighborClusters++;
if( otherCluster->Size() > clusterSizeLimit )
return false;
}
if( neighborClusters == 3 )
return false;
}
return true;
}
bool TrackFinderAlgorithm::ConnectWithLayer( Point *point , PointCollection *pointCollection ) {
bool found = false;
if( pointCollection == 0 )
return false;
if( pointCollection->empty() )
return false;
ThreeVector clusterPosition = point->GetCluster()->GetPosition();
for( unsigned int p=0 ; p<pointCollection->size() ; p++ ) {
Point *pointInNextLayer = pointCollection->at( p );
Cluster *clusterInLayer = pointInNextLayer->GetCluster();
ThreeVector clusterInLayerPosition = clusterInLayer->GetPosition();
if( fabs( clusterInLayerPosition.x() - clusterPosition.x() ) > lookupDistanceX
|| fabs( clusterInLayerPosition.y() - clusterPosition.y() ) > lookupDistanceY
|| fabs( clusterInLayerPosition.z() - clusterPosition.z() ) > lookupDistanceZ )
continue;
found = true;
if( !point->IsConnectedTo( pointInNextLayer ) && !pointInNextLayer->IsConnectedTo( point ) ) {
Connector *connector = new Connector();
connector->Connect( point , pointInNextLayer );
point->AddConnector( connector );
pointInNextLayer->AddConnector( connector );
connectorCollection->push_back( connector );
}
}
return found;
}
void TrackFinderAlgorithm::FindPotentialTrack( PointHelper *pointHelper ) {
double cellSize0 = calorimeter->GetCellSize0();
double cellSize1 = calorimeter->GetCellSize1();
double layerThickness = calorimeter->GetLayerThickness();
if( pointHelper->isFirstPoint ) {
Point *point = pointHelper->point;
Cluster *cluster = pointHelper->point->GetCluster();
ThreeVector clusterPosition = cluster->GetPosition();
clusterPosition.setX( clusterPosition.x()*cellSize0 );
clusterPosition.setY( clusterPosition.y()*cellSize1 );
clusterPosition.setZ( clusterPosition.z()*layerThickness );
ConnectorCollection *connectors = pointHelper->point->GetConnectors();
for( unsigned int c=0 ; c<connectors->size() ; c++ ) {
Connector *connector = connectors->at( c );
Point* nextPoint = connector->GetSecond();
Cluster *nextCluster = connector->GetSecond()->GetCluster();
ThreeVector nextClusterPosition = nextCluster->GetPosition();
nextClusterPosition.setX( nextClusterPosition.x()*cellSize0 );
nextClusterPosition.setY( nextClusterPosition.y()*cellSize1 );
nextClusterPosition.setZ( nextClusterPosition.z()*layerThickness );
if( cluster->GetPosition().z() >= nextCluster->GetPosition().z() )
continue;
ConnectorCollection *nextConnectors = nextPoint->GetConnectors();
bool connectorFound = false;
double bestAngle = 10.0;
Connector *bestNextConnector = 0;
Point *bestNextPoint = 0;
for( unsigned int c2=0 ; c2<nextConnectors->size() ; c2++ ) {
Connector *nextConnector = nextConnectors->at( c2 );
Point *nextNextPoint = nextConnector->GetSecond();
Cluster *nextNextCluster = nextNextPoint->GetCluster();
ThreeVector nextNextClusterPosition = nextNextCluster->GetPosition();
nextNextClusterPosition.setX( nextNextClusterPosition.x()*cellSize0 );
nextNextClusterPosition.setY( nextNextClusterPosition.y()*cellSize1 );
nextNextClusterPosition.setZ( nextNextClusterPosition.z()*layerThickness );
if( nextClusterPosition.z() >= nextNextClusterPosition.z() )
continue;
ThreeVector x1 = nextClusterPosition - clusterPosition;
ThreeVector x2 = nextNextClusterPosition - nextClusterPosition;
double angle = x1.angle( x2 );
if( angle < bestAngle ) {
bestAngle = angle;
bestNextConnector = nextConnector;
bestNextPoint = nextNextPoint;
}
}
if( bestAngle > maximumConnectorsAngle ) {
bestAngle = 10.0;
bestNextConnector = 0;
bestNextPoint = 0;
continue;
}
pointHelper->isFirstPoint = false;
pointHelper->point = nextPoint;
pointHelper->forwardPoint = bestNextPoint;
pointHelper->forwardConnector = bestNextConnector;
pointHelper->pointCollection->push_back( nextPoint );
this->FindPotentialTrack( pointHelper );
pointHelper->isFirstPoint = true;
pointHelper->point = point;
pointHelper->forwardPoint = 0;
pointHelper->forwardConnector = 0;
pointHelper->pointCollection->clear();
}
} // end isFirstPoint
else {
Point *point = pointHelper->point;
Cluster *cluster = point->GetCluster();
ThreeVector clusterPosition = cluster->GetPosition();
clusterPosition.setX( clusterPosition.x()*cellSize0 );
clusterPosition.setY( clusterPosition.y()*cellSize1 );
clusterPosition.setZ( clusterPosition.z()*layerThickness );
Connector *forwardConnector = pointHelper->forwardConnector;
Point *nextPoint = pointHelper->forwardPoint;
Cluster *nextCluster = nextPoint->GetCluster();
ThreeVector nextClusterPosition = nextCluster->GetPosition();
nextClusterPosition.setX( nextClusterPosition.x()*cellSize0 );
nextClusterPosition.setY( nextClusterPosition.y()*cellSize1 );
nextClusterPosition.setZ( nextClusterPosition.z()*layerThickness );
ConnectorCollection *nextConnectors = nextPoint->GetConnectors();
double bestAngle = 10.0;
Connector *bestNextConnector = 0;
Point *bestNextPoint = 0;
for( unsigned int c2=0 ; c2<nextConnectors->size() ; c2++ ) {
Connector *nextConnector = nextConnectors->at( c2 );
Point *nextNextPoint = nextConnector->GetSecond();
Cluster *nextNextCluster = nextNextPoint->GetCluster();
ThreeVector nextNextClusterPosition = nextNextCluster->GetPosition();
nextNextClusterPosition.setX( nextNextClusterPosition.x()*cellSize0 );
nextNextClusterPosition.setY( nextNextClusterPosition.y()*cellSize1 );
nextNextClusterPosition.setZ( nextNextClusterPosition.z()*layerThickness );
if( nextCluster->GetPosition().z() >= nextNextCluster->GetPosition().z() )
continue;
ThreeVector x1 = nextClusterPosition - clusterPosition;
ThreeVector x2 = nextNextClusterPosition - nextClusterPosition;
double angle = x1.angle( x2 );
if( angle < bestAngle ) {
bestAngle = angle;
bestNextConnector = nextConnector;
bestNextPoint = nextNextPoint;
}
}
if( bestAngle > maximumConnectorsAngle ) {
if( pointHelper->pointCollection->size() >= minimumTrackSize-1 ) {
pointHelper->pointCollection->push_back( nextPoint );
PointCollection *potentialTrack = new PointCollection( *pointHelper->pointCollection );
potentialTrackPoints.push_back( potentialTrack );
}
return;
}
unsigned int oldSize = pointHelper->pointCollection->size();
pointHelper->isFirstPoint = false;
pointHelper->point = nextPoint;
pointHelper->forwardPoint = bestNextPoint;
pointHelper->forwardConnector = bestNextConnector;
pointHelper->pointCollection->push_back( nextPoint );
this->FindPotentialTrack( pointHelper );
if( pointHelper->pointCollection->size() != oldSize ) {
pointHelper->pointCollection->erase( pointHelper->pointCollection->begin() + oldSize , pointHelper->pointCollection->end() );
}
pointHelper->isFirstPoint = false;
pointHelper->point = point;
pointHelper->forwardPoint = nextPoint;
pointHelper->forwardConnector = forwardConnector;
}
}
void TrackFinderAlgorithm::SortPotentialTracksBySize() {
int i = 0;
int j = 0;
PointCollection *pointCollection = 0;
for( j=1 ; j<potentialTrackPoints.size() ; j++ ) {
i = j-1;
while( potentialTrackPoints.at(j)->size() > potentialTrackPoints.at(i)->size() ) {
pointCollection = potentialTrackPoints.at(i);
potentialTrackPoints.at(i) = potentialTrackPoints.at(j);
potentialTrackPoints.at(j) = pointCollection;
i=i-1;
j=j-1;
if( i < 0 )
break;
}
}
}
void TrackFinderAlgorithm::SortPointsByLayer( PointCollection *pointCollection ) {
int i = 0;
int j = 0;
Point *point = 0;
for( j=1 ; j<pointCollection->size() ; j++ ) {
i = j-1;
while( pointCollection->at(j)->GetCluster()->GetPosition().z() > pointCollection->at(i)->GetCluster()->GetPosition().z() ) {
point = pointCollection->at(i);
pointCollection->at(i) = pointCollection->at(j);
pointCollection->at(j) = point;
i=i-1;
j=j-1;
if( i<0 ) break;
}
}
}
void TrackFinderAlgorithm::DrawEveArrow( double I1 , double J1 , double K1 ,
double I2 , double J2 , double K2 ,
int color ) {
if( BaboonMonitoring::IsEnable() && gEve ) {
unsigned int nbOfLayers = calorimeter->GetNbOfLayers();
double cellSize0 = calorimeter->GetCellSize0();
double cellSize1 = calorimeter->GetCellSize1();
double layerThickness = calorimeter->GetLayerThickness();
double absorberThickness = calorimeter->GetAbsorberThickness();
int repeatX = calorimeter->GetRepeatX();
int repeatY = calorimeter->GetRepeatY();
double shiftXFactor = cellSize0*repeatX / 2.0;
double shiftYFactor = cellSize1*repeatY / 2.0;
double shiftZFactor = absorberThickness + ( layerThickness - absorberThickness ) / 2.0 ;
BaboonMonitoring *monitoring = BaboonMonitoring::GetInstance();
TEveArrow *connectionArrow = new TEveArrow( cellSize0*I2-cellSize0*I1
, cellSize1*J2-cellSize1*J1
, layerThickness*K2-layerThickness*K1
, cellSize0*I1 - shiftXFactor
, cellSize1*J1 - shiftYFactor
, layerThickness*K1 + shiftZFactor );
connectionArrow->SetMainColor( color );
connectionArrow->SetPickable( true );
connectionArrow->SetTubeR( 0.05 );
connectionArrow->SetConeR( 0.008 );
connectionArrow->SetConeL( 0.008 );
monitoring->AddElement( connectionArrow );
}
}
void TrackFinderAlgorithm::DrawTrackConnectors( PointCollection *trackPoints , int color ) {
if( BaboonMonitoring::IsEnable() && gEve ) {
Cluster *currentCluster = 0;
Cluster *nextCluster = 0;
for( unsigned int p=0 ; p<trackPoints->size() ; p++ ) {
// The last cluster is not connected, since it is the last one ...
if( p == trackPoints->size() - 1 )
break;
currentCluster = trackPoints->at( p )->GetCluster();
nextCluster = trackPoints->at( p + 1 )->GetCluster();
ThreeVector currentClusterPosition = currentCluster->GetPosition();
ThreeVector nextClusterPosition = nextCluster->GetPosition();
this->DrawEveArrow( currentClusterPosition.x() , currentClusterPosition.y() , currentClusterPosition.z() ,
nextClusterPosition.x() , nextClusterPosition.y() , nextClusterPosition.z() ,
color );
}
}
}
} // namespace
| 28.788773 | 129 | 0.664243 | [
"object",
"vector"
] |
5b8fff373971f6832ac5fffb553aa44ba35a672c | 12,467 | cpp | C++ | src/Plugins/TundraLogic/KristalliProtocol.cpp | realXtend/tundra-urho3d | 436d41c3e3dd1a9b629703ee76fd0ef2ee212ef8 | [
"Apache-2.0"
] | 13 | 2015-02-25T02:42:38.000Z | 2018-07-31T11:40:56.000Z | src/Plugins/TundraLogic/KristalliProtocol.cpp | realXtend/tundra-urho3d | 436d41c3e3dd1a9b629703ee76fd0ef2ee212ef8 | [
"Apache-2.0"
] | 8 | 2015-02-12T22:27:05.000Z | 2017-01-21T15:59:17.000Z | src/Plugins/TundraLogic/KristalliProtocol.cpp | realXtend/tundra-urho3d | 436d41c3e3dd1a9b629703ee76fd0ef2ee212ef8 | [
"Apache-2.0"
] | 12 | 2015-03-25T21:10:50.000Z | 2019-04-10T09:03:10.000Z | // For conditions of distribution and use, see copyright notice in LICENSE
#include "StableHeaders.h"
#include "KristalliProtocol.h"
#include "TundraLogic.h"
#include "Framework.h"
#include "CoreStringUtils.h"
#include "ConsoleAPI.h"
#include "LoggingFunctions.h"
#include <Urho3D/Core/Profiler.h>
#include <kNet.h>
#include <kNet/UDPMessageConnection.h>
namespace Tundra
{
static const int cInitialAttempts = 0;
static const int cReconnectAttempts = 0;
KristalliProtocol::KristalliProtocol(TundraLogic* owner) :
Object(owner->GetContext()),
owner(owner),
server(0),
serverPort(0),
serverConnection(0),
connectionPending(false),
reconnectAttempts(0)
{
}
KristalliProtocol::~KristalliProtocol()
{
Disconnect();
}
void KristalliProtocol::Load()
{
Framework* framework = owner->GetFramework();
// Reflect --loglevel to kNet
if (framework->HasCommandLineParameter("--loglevel") || framework->HasCommandLineParameter("--loglevelnetwork"))
{
LogLevel level = framework->Console()->CurrentLogLevel();
if (framework->HasCommandLineParameter("--loglevelnetwork"))
{
// --loglevelnetwork overrides --loglevel.
StringVector llNetwork = framework->CommandLineParameters("--loglevelnetwork");
level = (!llNetwork.Empty() ? ConsoleAPI::LogLevelFromString(llNetwork.Front()) : level);
}
if (level == LogLevelNone || level == LogLevelWarning || level == LogLevelError)
kNet::SetLogChannels(kNet::LogError);
else if (level == LogLevelInfo)
kNet::SetLogChannels(kNet::LogError | kNet::LogUser);
else if (level == LogLevelDebug)
kNet::SetLogChannels(kNet::LogInfo | kNet::LogError | kNet::LogUser | kNet::LogVerbose);
else
kNet::SetLogChannels(kNet::LogInfo | kNet::LogError | kNet::LogUser);
}
// Enable all non verbose channels.
else
kNet::SetLogChannels(kNet::LogInfo | kNet::LogError | kNet::LogUser);
/* There seems to be no quiet mode for kNet logging, set to errors only.
This needs to be set explicitly as kNet does not log via Urho, which
will automatically suppress anything below LogLevelError. */
if (framework->HasCommandLineParameter("--quiet"))
kNet::SetLogChannels(kNet::LogError);
}
void KristalliProtocol::Initialize()
{
Framework* framework = owner->GetFramework();
defaultTransport = kNet::SocketOverUDP;
StringVector cmdLineParams = framework->CommandLineParameters("--protocol");
if (cmdLineParams.Size() > 0)
{
kNet::SocketTransportLayer transportLayer = kNet::StringToSocketTransportLayer(cmdLineParams.Front().Trimmed().CString());
if (transportLayer != kNet::InvalidTransportLayer)
defaultTransport = transportLayer;
}
}
void KristalliProtocol::Uninitialize()
{
Disconnect();
}
void KristalliProtocol::OpenKNetLogWindow()
{
LogError("Cannot open kNet logging window - kNet was not built with Qt enabled!");
}
void KristalliProtocol::Update(float /*frametime*/)
{
// Pulls all new inbound network messages and calls the message handler we've registered
// for each of them.
if (serverConnection)
{
URHO3D_PROFILE(KristalliProtocolModule_kNet_client_Process);
serverConnection->Process();
}
// Note: Calling the above serverConnection->Process() may set serverConnection to null if the connection gets disconnected.
// Therefore, in the code below, we cannot assume serverConnection is non-null, and must check it again.
// Our client->server connection is never kept half-open.
// That is, at the moment the server write-closes the connection, we also write-close the connection.
// Check here if the server has write-closed, and also write-close our end if so.
if (serverConnection && !serverConnection->IsReadOpen() && serverConnection->IsWriteOpen())
serverConnection->Disconnect(0);
// Process server incoming connections & messages if server up
if (server)
{
URHO3D_PROFILE(KristalliProtocolModule_kNet_server_Process);
server->Process();
// In Tundra, we *never* keep half-open server->client connections alive.
// (the usual case would be to wait for a file transfer to complete, but Tundra messaging mechanism doesn't use that).
// So, bidirectionally close all half-open connections.
kNet::NetworkServer::ConnectionMap connections = server->GetConnections();
for(kNet::NetworkServer::ConnectionMap::iterator iter = connections.begin(); iter != connections.end(); ++iter)
if (!iter->second->IsReadOpen() && iter->second->IsWriteOpen())
iter->second->Disconnect(0);
}
if ((!serverConnection || serverConnection->GetConnectionState() == kNet::ConnectionClosed ||
serverConnection->GetConnectionState() == kNet::ConnectionPending) && serverIp.length() != 0)
{
const float cReconnectTimeout = 5 * 1000.0f;
if (reconnectTimer.Test())
{
if (reconnectAttempts)
{
PerformConnection();
--reconnectAttempts;
}
else
{
LogInfo("Failed to connect to " + String(serverIp.c_str()) + String(":") + String(serverPort));
ConnectionAttemptFailed.Emit();
reconnectTimer.Stop();
serverIp = "";
}
}
else if (!reconnectTimer.Enabled())
reconnectTimer.StartMSecs(cReconnectTimeout);
}
// If connection was made, enable a larger number of reconnection attempts in case it gets lost
if (serverConnection && serverConnection->GetConnectionState() == kNet::ConnectionOK)
reconnectAttempts = cReconnectAttempts;
}
void KristalliProtocol::Connect(const char *ip, unsigned short port, kNet::SocketTransportLayer transport)
{
if (Connected() && serverConnection->RemoteEndPoint().IPToString() != serverIp)
Disconnect();
serverIp = ip;
serverPort = port;
serverTransport = transport;
reconnectAttempts = cInitialAttempts; // Initial attempts when establishing connection
if (!Connected())
PerformConnection(); // Start performing a connection attempt to the desired address/port/transport
}
void KristalliProtocol::PerformConnection()
{
if (serverConnection) // Make sure connection is fully closed before doing a potential reconnection.
serverConnection->Close();
// Connect to the server.
serverConnection = network.Connect(serverIp.c_str(), serverPort, serverTransport, this);
if (!serverConnection)
{
LogInfo("Unable to connect to " + String(serverIp.c_str()) + String(":") + String(serverPort));
return;
}
if (serverTransport == kNet::SocketOverUDP)
static_cast<kNet::UDPMessageConnection*>(serverConnection.ptr())->SetDatagramSendRate(500);
// For TCP mode sockets, set the TCP_NODELAY option to improve latency for the messages we send.
if (serverConnection->GetSocket() && serverConnection->GetSocket()->TransportLayer() == kNet::SocketOverTCP)
serverConnection->GetSocket()->SetNaglesAlgorithmEnabled(false);
}
void KristalliProtocol::Disconnect()
{
// Clear the remembered destination server ip address so that the automatic connection timer will not try to reconnect.
serverIp = "";
reconnectTimer.Stop();
if (Connected())
serverConnection->Disconnect();
}
bool KristalliProtocol::StartServer(unsigned short port, kNet::SocketTransportLayer transport)
{
StopServer();
const bool allowAddressReuse = true;
server = network.StartServer(port, transport, this, allowAddressReuse);
if (!server)
{
const String error = "Failed to start server on port " + String(port) + ".";
LogError(error);
LogError("Please make sure that the port is free and not used by another application.");
return false;
}
Framework* framework = owner->GetFramework();
std::cout << std::endl;
LogInfo("Server started");
LogInfo("* Port : " + String(port));
LogInfo("* Protocol : " + SocketTransportLayerToString(transport));
LogInfo("* Headless : " + String(framework->IsHeadless()));
return true;
}
void KristalliProtocol::StopServer()
{
if (server)
{
network.StopServer();
// We may have connections registered by other server modules. Only clear native connections
for(auto iter = connections.Begin(); iter != connections.End();)
{
if (dynamic_cast<KNetUserConnection*>(iter->Get()))
iter = connections.Erase(iter);
else
++iter;
}
LogInfo("Server stopped");
server = 0;
}
}
void KristalliProtocol::NewConnectionEstablished(kNet::MessageConnection *source)
{
assert(source);
if (!source)
return;
if (dynamic_cast<kNet::UDPMessageConnection*>(source))
static_cast<kNet::UDPMessageConnection*>(source)->SetDatagramSendRate(500);
source->RegisterInboundMessageHandler(this);
UserConnectionPtr connection = UserConnectionPtr(new KNetUserConnection(context_));
connection->userID = AllocateNewConnectionID();
Urho3D::StaticCast<KNetUserConnection>(connection)->connection = source;
connections.Push(connection);
// For TCP mode sockets, set the TCP_NODELAY option to improve latency for the messages we send.
if (source->GetSocket() && source->GetSocket()->TransportLayer() == kNet::SocketOverTCP)
source->GetSocket()->SetNaglesAlgorithmEnabled(false);
LogInfo(String("User connected from ") + String(source->RemoteEndPoint().ToString().c_str()) + String(", connection ID ") + String(connection->userID));
ClientConnectedEvent.Emit(connection.Get());
}
void KristalliProtocol::ClientDisconnected(kNet::MessageConnection *source)
{
// Delete from connection list if it was a known user
for(auto iter = connections.Begin(); iter != connections.End(); ++iter)
{
if ((*iter)->ConnectionType() == "knet" && Urho3D::StaticCast<KNetUserConnection>(*iter)->connection == source)
{
ClientDisconnectedEvent.Emit(iter->Get());
LogInfo("User disconnected, connection ID " + String((*iter)->userID));
connections.Erase(iter);
return;
}
}
LogInfo("Unknown user disconnected");
}
bool KristalliProtocol::Connected() const
{
return serverConnection != 0 && serverConnection->Connected();
}
void KristalliProtocol::HandleMessage(kNet::MessageConnection *source, kNet::packet_id_t packetId, kNet::message_id_t messageId, const char *data, size_t numBytes)
{
assert(source);
assert(data || numBytes == 0);
try
{
NetworkMessageReceived.Emit(source, packetId, messageId, data, numBytes);
}
catch(std::exception &e)
{
LogError("KristalliProtocolModule: Exception \"" + String(e.what()) + "\" thrown when handling network message id " +
String(messageId) + " size " + String(numBytes) + " from client " + source->ToString().c_str());
// Kill the connection. For debugging purposes, don't disconnect the client if the server is running a debug build.
#ifndef _DEBUG
source->Disconnect(0);
source->Close(0);
// kNet will call back to KristalliProtocolModule::ClientDisconnected() to clean up the high-level Tundra UserConnection object.
#endif
}
}
u32 KristalliProtocol::AllocateNewConnectionID() const
{
u32 newID = 1;
for(auto iter = connections.Begin(); iter != connections.End(); ++iter)
newID = Max(newID, (*iter)->userID+1);
return newID;
}
UserConnectionPtr KristalliProtocol::UserConnectionBySource(kNet::MessageConnection* source) const
{
for(auto iter = connections.Begin(); iter != connections.End(); ++iter)
if ((*iter)->ConnectionType() == "knet" && Urho3D::StaticCast<KNetUserConnection>(*iter)->connection == source)
return *iter;
return UserConnectionPtr();
}
UserConnectionPtr KristalliProtocol::UserConnectionById(u32 id) const
{
for(auto iter = connections.Begin(); iter != connections.End(); ++iter)
if ((*iter)->userID == id)
return *iter;
return UserConnectionPtr();
}
}
| 36.031792 | 163 | 0.669367 | [
"object"
] |
5b90c58ff600afd207f321d53ddc0952a45321f0 | 1,548 | cpp | C++ | detectors/ExtractedInfoStringChecker.cpp | Extended-Object-Detection-ROS/lib | 11865c85f9f46c28552bacf160f0639584310006 | [
"BSD-3-Clause"
] | 1 | 2022-02-01T22:46:45.000Z | 2022-02-01T22:46:45.000Z | detectors/ExtractedInfoStringChecker.cpp | Extended-Object-Detection-ROS/lib | 11865c85f9f46c28552bacf160f0639584310006 | [
"BSD-3-Clause"
] | null | null | null | detectors/ExtractedInfoStringChecker.cpp | Extended-Object-Detection-ROS/lib | 11865c85f9f46c28552bacf160f0639584310006 | [
"BSD-3-Clause"
] | null | null | null | #include "ExtractedInfoStringChecker.h"
#include <algorithm>
using namespace std;
using namespace cv;
namespace eod{
ExtractedInfoStringChecker::ExtractedInfoStringChecker(){
Type = EI_STR_CHECK_A;
}
ExtractedInfoStringChecker::ExtractedInfoStringChecker(string field_, vector<string> allowed_, bool partially_){
Type = EI_STR_CHECK_A;
field = field_;
allowed = allowed_;
partially = partially_;
}
vector<ExtendedObjectInfo> ExtractedInfoStringChecker::Detect2(const Mat& image, int seq){
vector<ExtendedObjectInfo> rects(0);
return rects;
}
void ExtractedInfoStringChecker::Extract2(const cv::Mat& image, ExtendedObjectInfo& rect){
}
bool ExtractedInfoStringChecker::Check2(const Mat& image, ExtendedObjectInfo& rect){
if( rect.extracted_info.count(field) > 0){
string value = rect.extracted_info[field];
if( allowed.size() == 0 ){
return false;
}
else{
if( ! partially ){
if( find(allowed.begin(), allowed.end(), value) != allowed.end() ){
return true;
}
}
else{
for(auto const& val: allowed){
if( value.find(val) != string::npos)
return true;
}
}
}
}
return false;
}
}
| 28.666667 | 113 | 0.528424 | [
"vector"
] |
5b96a277ca68896b8c7224fff29bdfc3ad6c3703 | 67,659 | cxx | C++ | main/svx/source/dialog/dlgctrl.cxx | jimjag/openoffice | 74746a22d8cc22b031b00fcd106f4496bf936c77 | [
"Apache-2.0"
] | 1 | 2019-12-27T19:25:34.000Z | 2019-12-27T19:25:34.000Z | main/svx/source/dialog/dlgctrl.cxx | ackza/openoffice | d49dfe9c625750e261c7ed8d6ccac8d361bf3418 | [
"Apache-2.0"
] | 1 | 2019-11-25T03:08:58.000Z | 2019-11-25T03:08:58.000Z | main/svx/source/dialog/dlgctrl.cxx | ackza/openoffice | d49dfe9c625750e261c7ed8d6ccac8d361bf3418 | [
"Apache-2.0"
] | 6 | 2019-11-19T00:28:25.000Z | 2019-11-22T06:48:49.000Z | /**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_svx.hxx"
// include ---------------------------------------------------------------
#include <tools/shl.hxx>
#include <vcl/svapp.hxx>
#include <svx/xtable.hxx>
#include <svx/xpool.hxx>
#include <svx/dialogs.hrc>
#include <accessibility.hrc>
#include <svx/dlgctrl.hxx>
#include <svx/dialmgr.hxx>
#include <tools/poly.hxx>
#include <vcl/region.hxx>
#include <vcl/gradient.hxx>
#include <vcl/hatch.hxx>
#ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTOBJECT_HPP_
#include <com/sun/star/accessibility/AccessibleEventObject.hpp>
#endif
#ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTID_HPP_
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
#endif
#ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLESTATETYPE_HPP_
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
#endif
#include "svxpixelctlaccessiblecontext.hxx"
#include <svtools/colorcfg.hxx>
#include <svxrectctaccessiblecontext.hxx>
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <basegfx/point/b2dpoint.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
#include <svx/svdorect.hxx>
#include <svx/svdmodel.hxx>
#include <svx/svdopath.hxx>
#include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
#include <svx/sdr/contact/displayinfo.hxx>
#include <vcl/bmpacc.hxx>
#include <svx/xbtmpit.hxx>
#define OUTPUT_DRAWMODE_COLOR (DRAWMODE_DEFAULT)
#define OUTPUT_DRAWMODE_CONTRAST (DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT)
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::accessibility;
/*************************************************************************
|*
|* Control zur Darstellung und Auswahl der Eckpunkte (und Mittelpunkt)
|* eines Objekts
|*
\************************************************************************/
Bitmap& SvxRectCtl::GetRectBitmap( void )
{
if( !pBitmap )
InitRectBitmap();
return *pBitmap;
}
SvxRectCtl::SvxRectCtl( Window* pParent, const ResId& rResId, RECT_POINT eRpt,
sal_uInt16 nBorder, sal_uInt16 nCircle, CTL_STYLE eStyle ) :
Control( pParent, rResId ),
pAccContext ( NULL ),
nBorderWidth( nBorder ),
nRadius ( nCircle),
eDefRP ( eRpt ),
eCS ( eStyle ),
pBitmap ( NULL ),
m_nState ( 0 ),
mbCompleteDisable(sal_False)
{
SetMapMode( MAP_100TH_MM );
Resize_Impl();
}
// -----------------------------------------------------------------------
SvxRectCtl::~SvxRectCtl()
{
delete pBitmap;
if( pAccContext )
pAccContext->release();
}
// -----------------------------------------------------------------------
void SvxRectCtl::Resize()
{
Resize_Impl();
Control::Resize();
}
// -----------------------------------------------------------------------
void SvxRectCtl::Resize_Impl()
{
aSize = GetOutputSize();
switch( eCS )
{
case CS_RECT:
case CS_ANGLE:
case CS_SHADOW:
aPtLT = Point( 0 + nBorderWidth, 0 + nBorderWidth );
aPtMT = Point( aSize.Width() / 2, 0 + nBorderWidth );
aPtRT = Point( aSize.Width() - nBorderWidth, 0 + nBorderWidth );
aPtLM = Point( 0 + nBorderWidth, aSize.Height() / 2 );
aPtMM = Point( aSize.Width() / 2, aSize.Height() / 2 );
aPtRM = Point( aSize.Width() - nBorderWidth, aSize.Height() / 2 );
aPtLB = Point( 0 + nBorderWidth, aSize.Height() - nBorderWidth );
aPtMB = Point( aSize.Width() / 2, aSize.Height() - nBorderWidth );
aPtRB = Point( aSize.Width() - nBorderWidth, aSize.Height() - nBorderWidth );
break;
case CS_LINE:
aPtLT = Point( 0 + 3 * nBorderWidth, 0 + nBorderWidth );
aPtMT = Point( aSize.Width() / 2, 0 + nBorderWidth );
aPtRT = Point( aSize.Width() - 3 * nBorderWidth, 0 + nBorderWidth );
aPtLM = Point( 0 + 3 * nBorderWidth, aSize.Height() / 2 );
aPtMM = Point( aSize.Width() / 2, aSize.Height() / 2 );
aPtRM = Point( aSize.Width() - 3 * nBorderWidth, aSize.Height() / 2 );
aPtLB = Point( 0 + 3 * nBorderWidth, aSize.Height() - nBorderWidth );
aPtMB = Point( aSize.Width() / 2, aSize.Height() - nBorderWidth );
aPtRB = Point( aSize.Width() - 3 * nBorderWidth, aSize.Height() - nBorderWidth );
break;
}
Reset();
InitSettings( sal_True, sal_True );
}
// -----------------------------------------------------------------------
void SvxRectCtl::InitRectBitmap( void )
{
if( pBitmap )
delete pBitmap;
const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
svtools::ColorConfig aColorConfig;
pBitmap = new Bitmap( SVX_RES( RID_SVXCTRL_RECTBTNS ) );
// set bitmap-colors
Color aColorAry1[7];
Color aColorAry2[7];
aColorAry1[0] = Color( 0xC0, 0xC0, 0xC0 ); // light-gray
aColorAry1[1] = Color( 0xFF, 0xFF, 0x00 ); // yellow
aColorAry1[2] = Color( 0xFF, 0xFF, 0xFF ); // white
aColorAry1[3] = Color( 0x80, 0x80, 0x80 ); // dark-gray
aColorAry1[4] = Color( 0x00, 0x00, 0x00 ); // black
aColorAry1[5] = Color( 0x00, 0xFF, 0x00 ); // green
aColorAry1[6] = Color( 0x00, 0x00, 0xFF ); // blue
aColorAry2[0] = rStyles.GetDialogColor(); // background
aColorAry2[1] = rStyles.GetWindowColor();
aColorAry2[2] = rStyles.GetLightColor();
aColorAry2[3] = rStyles.GetShadowColor();
aColorAry2[4] = rStyles.GetDarkShadowColor();
aColorAry2[5] = Color( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
aColorAry2[6] = rStyles.GetDialogColor();
#ifdef DBG_UTIL
static sal_Bool bModify = sal_False;
sal_Bool& rModify = bModify;
if( rModify )
{
static int n = 0;
static sal_uInt8 r = 0xFF;
static sal_uInt8 g = 0x00;
static sal_uInt8 b = 0xFF;
int& rn = n;
sal_uInt8& rr = r;
sal_uInt8& rg = g;
sal_uInt8& rb = b;
aColorAry2[ rn ] = Color( rr, rg, rb );
}
#endif
pBitmap->Replace( aColorAry1, aColorAry2, 7, NULL );
}
// -----------------------------------------------------------------------
void SvxRectCtl::InitSettings( sal_Bool bForeground, sal_Bool bBackground )
{
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
if( bForeground )
{
svtools::ColorConfig aColorConfig;
Color aTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
if ( IsControlForeground() )
aTextColor = GetControlForeground();
SetTextColor( aTextColor );
}
if( bBackground )
{
if ( IsControlBackground() )
SetBackground( GetControlBackground() );
else
SetBackground( rStyleSettings.GetWindowColor() );
}
delete pBitmap;
pBitmap = NULL; // forces new creating of bitmap
Invalidate();
}
/*************************************************************************
|*
|* Das angeklickte Rechteck (3 x 3) wird ermittelt und der Parent (Dialog)
|* wird benachrichtigt, dass der Punkt geaendert wurde
|*
\************************************************************************/
void SvxRectCtl::MouseButtonDown( const MouseEvent& rMEvt )
{
// #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
if(!IsCompletelyDisabled())
{
Point aPtLast = aPtNew;
aPtNew = GetApproxLogPtFromPixPt( rMEvt.GetPosPixel() );
if( aPtNew == aPtMM && ( eCS == CS_SHADOW || eCS == CS_ANGLE ) )
{
aPtNew = aPtLast;
}
else
{
Invalidate( Rectangle( aPtLast - Point( nRadius, nRadius ),
aPtLast + Point( nRadius, nRadius ) ) );
Invalidate( Rectangle( aPtNew - Point( nRadius, nRadius ),
aPtNew + Point( nRadius, nRadius ) ) );
eRP = GetRPFromPoint( aPtNew );
SetActualRP( eRP );
if( WINDOW_TABPAGE == GetParent()->GetType() )
( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
}
}
}
// -----------------------------------------------------------------------
void SvxRectCtl::KeyInput( const KeyEvent& rKeyEvt )
{
// #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
if(!IsCompletelyDisabled())
{
RECT_POINT eNewRP = eRP;
sal_Bool bUseMM = (eCS != CS_SHADOW) && (eCS != CS_ANGLE);
switch( rKeyEvt.GetKeyCode().GetCode() )
{
case KEY_DOWN:
{
if( !(m_nState & CS_NOVERT) )
switch( eNewRP )
{
case RP_LT: eNewRP = RP_LM; break;
case RP_MT: eNewRP = bUseMM ? RP_MM : RP_MB; break;
case RP_RT: eNewRP = RP_RM; break;
case RP_LM: eNewRP = RP_LB; break;
case RP_MM: eNewRP = RP_MB; break;
case RP_RM: eNewRP = RP_RB; break;
default: ; //prevent warning
}
}
break;
case KEY_UP:
{
if( !(m_nState & CS_NOVERT) )
switch( eNewRP )
{
case RP_LM: eNewRP = RP_LT; break;
case RP_MM: eNewRP = RP_MT; break;
case RP_RM: eNewRP = RP_RT; break;
case RP_LB: eNewRP = RP_LM; break;
case RP_MB: eNewRP = bUseMM ? RP_MM : RP_MT; break;
case RP_RB: eNewRP = RP_RM; break;
default: ; //prevent warning
}
}
break;
case KEY_LEFT:
{
if( !(m_nState & CS_NOHORZ) )
switch( eNewRP )
{
case RP_MT: eNewRP = RP_LT; break;
case RP_RT: eNewRP = RP_MT; break;
case RP_MM: eNewRP = RP_LM; break;
case RP_RM: eNewRP = bUseMM ? RP_MM : RP_LM; break;
case RP_MB: eNewRP = RP_LB; break;
case RP_RB: eNewRP = RP_MB; break;
default: ; //prevent warning
}
}
break;
case KEY_RIGHT:
{
if( !(m_nState & CS_NOHORZ) )
switch( eNewRP )
{
case RP_LT: eNewRP = RP_MT; break;
case RP_MT: eNewRP = RP_RT; break;
case RP_LM: eNewRP = bUseMM ? RP_MM : RP_RM; break;
case RP_MM: eNewRP = RP_RM; break;
case RP_LB: eNewRP = RP_MB; break;
case RP_MB: eNewRP = RP_RB; break;
default: ; //prevent warning
}
}
break;
default:
Control::KeyInput( rKeyEvt );
return;
}
if( eNewRP != eRP )
{
SetActualRP( eNewRP );
if( WINDOW_TABPAGE == GetParent()->GetType() )
( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
SetFocusRect();
}
}
}
// -----------------------------------------------------------------------
void SvxRectCtl::StateChanged( StateChangedType nType )
{
if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
InitSettings( sal_True, sal_False );
else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
InitSettings( sal_False, sal_True );
Window::StateChanged( nType );
}
// -----------------------------------------------------------------------
void SvxRectCtl::DataChanged( const DataChangedEvent& rDCEvt )
{
if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
InitSettings( sal_True, sal_True );
else
Window::DataChanged( rDCEvt );
}
/*************************************************************************
|*
|* Zeichnet das Control (Rechteck mit 9 Kreisen)
|*
\************************************************************************/
void SvxRectCtl::Paint( const Rectangle& )
{
Point aPtDiff( PixelToLogic( Point( 1, 1 ) ) );
const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
SetLineColor( rStyles.GetDialogColor() );
SetFillColor( rStyles.GetDialogColor() );
DrawRect( Rectangle( Point(0,0), GetOutputSize() ) );
if( IsEnabled() )
SetLineColor( rStyles.GetLabelTextColor() );
else
SetLineColor( rStyles.GetShadowColor() );
SetFillColor();
switch( eCS )
{
case CS_RECT:
case CS_SHADOW:
if( !IsEnabled() )
{
Color aOldCol = GetLineColor();
SetLineColor( rStyles.GetLightColor() );
DrawRect( Rectangle( aPtLT + aPtDiff, aPtRB + aPtDiff ) );
SetLineColor( aOldCol );
}
DrawRect( Rectangle( aPtLT, aPtRB ) );
break;
case CS_LINE:
if( !IsEnabled() )
{
Color aOldCol = GetLineColor();
SetLineColor( rStyles.GetLightColor() );
DrawLine( aPtLM - Point( 2 * nBorderWidth, 0) + aPtDiff,
aPtRM + Point( 2 * nBorderWidth, 0 ) + aPtDiff );
SetLineColor( aOldCol );
}
DrawLine( aPtLM - Point( 2 * nBorderWidth, 0),
aPtRM + Point( 2 * nBorderWidth, 0 ) );
break;
case CS_ANGLE:
if( !IsEnabled() )
{
Color aOldCol = GetLineColor();
SetLineColor( rStyles.GetLightColor() );
DrawLine( aPtLT + aPtDiff, aPtRB + aPtDiff );
DrawLine( aPtLB + aPtDiff, aPtRT + aPtDiff );
DrawLine( aPtLM + aPtDiff, aPtRM + aPtDiff );
DrawLine( aPtMT + aPtDiff, aPtMB + aPtDiff );
SetLineColor( aOldCol );
}
DrawLine( aPtLT, aPtRB );
DrawLine( aPtLB, aPtRT );
DrawLine( aPtLM, aPtRM );
DrawLine( aPtMT, aPtMB );
break;
default:
break;
}
SetFillColor( GetBackground().GetColor() );
Size aBtnSize( 11, 11 );
Size aDstBtnSize( PixelToLogic( aBtnSize ) );
Point aToCenter( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1);
Point aBtnPnt1( IsEnabled()?0:22,0 );
Point aBtnPnt2( 11,0 );
Point aBtnPnt3( 22,0 );
sal_Bool bNoHorz = (m_nState & CS_NOHORZ) != 0;
sal_Bool bNoVert = (m_nState & CS_NOVERT) != 0;
Bitmap& rBitmap = GetRectBitmap();
// #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
if(IsCompletelyDisabled())
{
DrawBitmap( aPtLT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
DrawBitmap( aPtMT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
DrawBitmap( aPtRT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
DrawBitmap( aPtLM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
if( eCS == CS_RECT || eCS == CS_LINE )
DrawBitmap( aPtMM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
DrawBitmap( aPtRM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
DrawBitmap( aPtLB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
DrawBitmap( aPtMB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
DrawBitmap( aPtRB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
}
else
{
DrawBitmap( aPtLT - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
DrawBitmap( aPtMT - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
DrawBitmap( aPtRT - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
DrawBitmap( aPtLM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
// Mittelpunkt bei Rechteck und Linie
if( eCS == CS_RECT || eCS == CS_LINE )
DrawBitmap( aPtMM - aToCenter, aDstBtnSize, aBtnPnt1, aBtnSize, rBitmap );
DrawBitmap( aPtRM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
DrawBitmap( aPtLB - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
DrawBitmap( aPtMB - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
DrawBitmap( aPtRB - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
}
// draw active button, avoid center pos for angle
// #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
if(!IsCompletelyDisabled())
{
if( IsEnabled() && (eCS != CS_ANGLE || aPtNew != aPtMM) )
{
Point aCenterPt( aPtNew );
aCenterPt -= aToCenter;
DrawBitmap( aCenterPt, aDstBtnSize, aBtnPnt2, aBtnSize, rBitmap );
}
}
}
/*************************************************************************
|*
|* Konvertiert RECT_POINT in Point
|*
\************************************************************************/
Point SvxRectCtl::GetPointFromRP( RECT_POINT _eRP) const
{
switch( _eRP )
{
case RP_LT: return aPtLT;
case RP_MT: return aPtMT;
case RP_RT: return aPtRT;
case RP_LM: return aPtLM;
case RP_MM: return aPtMM;
case RP_RM: return aPtRM;
case RP_LB: return aPtLB;
case RP_MB: return aPtMB;
case RP_RB: return aPtRB;
}
return( aPtMM ); // default
}
void SvxRectCtl::SetFocusRect( const Rectangle* pRect )
{
HideFocus();
if( pRect )
ShowFocus( *pRect );
else
ShowFocus( CalculateFocusRectangle() );
}
Point SvxRectCtl::SetActualRPWithoutInvalidate( RECT_POINT eNewRP )
{
Point aPtLast = aPtNew;
aPtNew = GetPointFromRP( eNewRP );
if( (m_nState & CS_NOHORZ) != 0 )
aPtNew.X() = aPtMM.X();
if( (m_nState & CS_NOVERT) != 0 )
aPtNew.Y() = aPtMM.Y();
eNewRP = GetRPFromPoint( aPtNew );
eDefRP = eNewRP;
eRP = eNewRP;
return aPtLast;
}
void SvxRectCtl::GetFocus()
{
SetFocusRect();
//Solution: Send the accessible focused event
Control::GetFocus();
// Send accessibility event.
if(pAccContext)
{
pAccContext->FireChildFocus(GetActualRP());
}
}
void SvxRectCtl::LoseFocus()
{
HideFocus();
}
Point SvxRectCtl::GetApproxLogPtFromPixPt( const Point& rPt ) const
{
Point aPt = PixelToLogic( rPt );
long x;
long y;
if( ( m_nState & CS_NOHORZ ) == 0 )
{
if( aPt.X() < aSize.Width() / 3 )
x = aPtLT.X();
else if( aPt.X() < aSize.Width() * 2 / 3 )
x = aPtMM.X();
else
x = aPtRB.X();
}
else
x = aPtMM.X();
if( ( m_nState & CS_NOVERT ) == 0 )
{
if( aPt.Y() < aSize.Height() / 3 )
y = aPtLT.Y();
else if( aPt.Y() < aSize.Height() * 2 / 3 )
y = aPtMM.Y();
else
y = aPtRB.Y();
}
else
y = aPtMM.Y();
return Point( x, y );
}
/*************************************************************************
|*
|* Konvertiert Point in RECT_POINT
|*
\************************************************************************/
RECT_POINT SvxRectCtl::GetRPFromPoint( Point aPt ) const
{
if ( aPt == aPtLT) return RP_LT;
else if( aPt == aPtMT) return RP_MT;
else if( aPt == aPtRT) return RP_RT;
else if( aPt == aPtLM) return RP_LM;
else if( aPt == aPtRM) return RP_RM;
else if( aPt == aPtLB) return RP_LB;
else if( aPt == aPtMB) return RP_MB;
else if( aPt == aPtRB) return RP_RB;
else
return RP_MM; // default
}
/*************************************************************************
|*
|* Bewirkt den Ursprungszustand des Controls
|*
\************************************************************************/
void SvxRectCtl::Reset()
{
aPtNew = GetPointFromRP( eDefRP );
eRP = eDefRP;
Invalidate();
}
/*************************************************************************
|*
|* Gibt den aktuell ausgewaehlten RECT_POINT zur�ck
|*
\************************************************************************/
RECT_POINT SvxRectCtl::GetActualRP() const
{
return( eRP );
}
/*************************************************************************
|*
|* Gibt den aktuell ausgewaehlten RECT_POINT zur�ck
|*
\************************************************************************/
void SvxRectCtl::SetActualRP( RECT_POINT eNewRP /* MT: , sal_Bool bFireFocus */ )
{
// MT: bFireFox as API parameter is ugly...
Point aPtLast( SetActualRPWithoutInvalidate( eNewRP ) );
Invalidate( Rectangle( aPtLast - Point( nRadius, nRadius ), aPtLast + Point( nRadius, nRadius ) ) );
Invalidate( Rectangle( aPtNew - Point( nRadius, nRadius ), aPtNew + Point( nRadius, nRadius ) ) );
// notify accessibility object about change
if( pAccContext )
pAccContext->selectChild( eNewRP /* MT, bFireFocus */ );
}
void SvxRectCtl::SetState( CTL_STATE nState )
{
m_nState = nState;
Point aPtLast( GetPointFromRP( eRP ) );
Point _aPtNew( aPtLast );
if( (m_nState & CS_NOHORZ) != 0 )
_aPtNew.X() = aPtMM.X();
if( (m_nState & CS_NOVERT) != 0 )
_aPtNew.Y() = aPtMM.Y();
eRP = GetRPFromPoint( _aPtNew );
Invalidate();
if( WINDOW_TABPAGE == GetParent()->GetType() )
( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
}
sal_uInt8 SvxRectCtl::GetNumOfChilds( void ) const
{
return ( eCS == CS_ANGLE )? 8 : 9;
}
Rectangle SvxRectCtl::CalculateFocusRectangle( void ) const
{
Size aDstBtnSize( PixelToLogic( Size( 15, 15 ) ) );
return Rectangle( aPtNew - Point( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1 ), aDstBtnSize );
}
Rectangle SvxRectCtl::CalculateFocusRectangle( RECT_POINT eRectPoint ) const
{
Rectangle aRet;
RECT_POINT eOldRectPoint = GetActualRP();
if( eOldRectPoint == eRectPoint )
aRet = CalculateFocusRectangle();
else
{
SvxRectCtl* pThis = const_cast< SvxRectCtl* >( this );
pThis->SetActualRPWithoutInvalidate( eRectPoint ); // no invalidation because it's only temporary!
aRet = CalculateFocusRectangle();
pThis->SetActualRPWithoutInvalidate( eOldRectPoint ); // no invalidation because nothing has changed!
}
return aRet;
}
Reference< XAccessible > SvxRectCtl::CreateAccessible()
{
Window* pParent = GetAccessibleParentWindow();
DBG_ASSERT( pParent, "-SvxRectCtl::CreateAccessible(): No Parent!" );
Reference< XAccessible > xAccParent = pParent->GetAccessible();
if( xAccParent.is() )
{
pAccContext = new SvxRectCtlAccessibleContext( xAccParent, *this );
pAccContext->acquire();
SetActualRP( GetActualRP() );
return pAccContext;
}
else
return Reference< XAccessible >();
}
RECT_POINT SvxRectCtl::GetApproxRPFromPixPt( const ::com::sun::star::awt::Point& r ) const
{
return GetRPFromPoint( GetApproxLogPtFromPixPt( Point( r.X, r.Y ) ) );
}
// #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
void SvxRectCtl::DoCompletelyDisable(sal_Bool bNew)
{
mbCompleteDisable = bNew;
Invalidate();
}
/*************************************************************************
|*
|* Konstruktor ohne Size-Parameter
|*
\************************************************************************/
SvxAngleCtl::SvxAngleCtl( Window* pParent, const ResId& rResId ) :
SvxRectCtl( pParent, rResId ),
aFont( Application::GetSettings().GetStyleSettings().GetAppFont() )
{
aFontSize = Size( 250, 400 );
Initialize();
}
/*************************************************************************
|*
|* Konstruktor mit Size-Parameter
|*
\************************************************************************/
SvxAngleCtl::SvxAngleCtl( Window* pParent, const ResId& rResId, Size _aSize ) :
SvxRectCtl( pParent, rResId ),
aFont( Application::GetSettings().GetStyleSettings().GetAppFont() )
{
aFontSize = _aSize;
Initialize();
}
/*************************************************************************
|*
|* Initialisierung
|*
\************************************************************************/
void SvxAngleCtl::Initialize()
{
bPositive = sal_True;
// aFont.SetName( "Helvetica" );
aFont.SetSize( aFontSize );
aFont.SetWeight( WEIGHT_NORMAL );
aFont.SetTransparent( sal_False );
SetFont( aFont );
}
/*************************************************************************
|*
|* Zeichnet das (Mini-)Koordinatensystem
|*
\************************************************************************/
void SvxAngleCtl::Paint( const Rectangle& )
{
SetLineColor( Color( COL_BLACK ) ); // PEN_DOT ???
DrawLine( aPtLT - Point( 0, 0), aPtRB + Point( 0, 0 ) );
DrawLine( aPtLB - Point( 0, 0), aPtRT + Point( 0, 0 ) );
SetLineColor( Color( COL_BLACK ) );
DrawLine( aPtLM - Point( 0, 0), aPtRM + Point( 0, 0 ) );
DrawLine( aPtMT - Point( 0, 0), aPtMB + Point( 0, 0 ) );
Point aDiff(aFontSize.Width() / 2, aFontSize.Height() / 2);
DrawText( aPtLT - aDiff, UniString::CreateFromAscii(
RTL_CONSTASCII_STRINGPARAM( "135" ) ) );
DrawText( aPtLM - aDiff, UniString::CreateFromAscii(
RTL_CONSTASCII_STRINGPARAM( "180" ) ) );
if ( bPositive )
DrawText( aPtLB - aDiff, UniString::CreateFromAscii(
RTL_CONSTASCII_STRINGPARAM( "225" ) ) );
else
DrawText( aPtLB - aDiff, UniString::CreateFromAscii(
RTL_CONSTASCII_STRINGPARAM( "-135" ) ) );
aDiff.X() = aFontSize.Width();
DrawText( aPtMT - aDiff, UniString::CreateFromAscii(
RTL_CONSTASCII_STRINGPARAM( "90" ) ) );
DrawText( aPtRT - aDiff, UniString::CreateFromAscii(
RTL_CONSTASCII_STRINGPARAM( "45" ) ) );
aDiff.X() = aDiff .X() * 3 / 2;
if ( bPositive )
DrawText( aPtMB - aDiff, UniString::CreateFromAscii(
RTL_CONSTASCII_STRINGPARAM( "270" ) ) );
else
DrawText( aPtMB - aDiff, UniString::CreateFromAscii(
RTL_CONSTASCII_STRINGPARAM( "-90" ) ) );
DrawText( aPtRM - Point( 0, aDiff.Y() ), UniString::CreateFromAscii(
RTL_CONSTASCII_STRINGPARAM( "0" ) ) );
aDiff.X() = aFontSize.Width() * 2;
if ( bPositive )
DrawText( aPtRB - aDiff, UniString::CreateFromAscii(
RTL_CONSTASCII_STRINGPARAM( "315" ) ) );
else
DrawText( aPtRB - aDiff, UniString::CreateFromAscii(
RTL_CONSTASCII_STRINGPARAM( "-45" ) ) );
}
/*************************************************************************
|*
|* Control zum Editieren von Bitmaps
|*
\************************************************************************/
::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SvxPixelCtl::CreateAccessible()
{
if(!m_xAccess.is())
{
m_xAccess = m_pAccess = new SvxPixelCtlAccessible(*this);
}
return m_xAccess;
}
//Logic Pixel
long SvxPixelCtl::PointToIndex(const Point &aPt) const
{
sal_uInt16 nX, nY;
nX = (sal_uInt16) ( aPt.X() * nLines / aRectSize.Width() );
nY = (sal_uInt16) ( aPt.Y() * nLines / aRectSize.Height() );
return nX + nY * nLines ;
}
Point SvxPixelCtl::IndexToPoint(long nIndex) const
{
DBG_ASSERT(nIndex >= 0 && nIndex < nSquares ," Check Index");
sal_uInt16 nXIndex = nIndex % nLines ;
sal_uInt16 nYIndex = sal_uInt16(nIndex / nLines) ;
Point aPtTl;
aPtTl.Y() = aRectSize.Height() * nYIndex / nLines + 1;
aPtTl.X() = aRectSize.Width() * nXIndex / nLines + 1;
return aPtTl;
}
long SvxPixelCtl::GetFoucsPosIndex() const
{
return aFocusPosition.getX() + aFocusPosition.getY() * nLines ;
}
long SvxPixelCtl::ShowPosition( const Point &pt)
{
Point aPt = PixelToLogic( pt );
sal_uInt16 nX, nY;
nX = (sal_uInt16) ( aPt.X() * nLines / aRectSize.Width() );
nY = (sal_uInt16) ( aPt.Y() * nLines / aRectSize.Height() );
ChangePixel( nX + nY * nLines );
//Solution:Set new focus position and repaint
//Invalidate( Rectangle( aPtTl, aPtBr ) );
aFocusPosition.setX(nX);
aFocusPosition.setY(nY);
Invalidate(Rectangle(Point(0,0),aRectSize));
if( WINDOW_TABPAGE == GetParent()->GetType() )
( (SvxTabPage*) GetParent() )->PointChanged( this, RP_MM ); // RectPoint ist dummy
return GetFoucsPosIndex();
}
SvxPixelCtl::SvxPixelCtl( Window* pParent, const ResId& rResId, sal_uInt16 nNumber ) :
Control ( pParent, rResId ),
nLines ( nNumber ),
bPaintable ( sal_True )
//Solution:Initialize it's value to Point(0,0)
,aFocusPosition(0,0)
{
// SetMapMode( MAP_100TH_MM );
aRectSize = GetOutputSize();
SetPixelColor( Color( COL_BLACK ) );
SetBackgroundColor( Color( COL_WHITE ) );
SetLineColor( Application::GetSettings().GetStyleSettings().GetShadowColor() );
nSquares = nLines * nLines;
pPixel = new sal_uInt16[ nSquares ];
rtl_zeroMemory(pPixel, nSquares * sizeof(sal_uInt16));
m_pAccess=NULL;
}
/*************************************************************************
|*
|* Destruktor dealociert dyn. Array
|*
\************************************************************************/
SvxPixelCtl::~SvxPixelCtl( )
{
delete []pPixel;
}
/*************************************************************************
|*
|* Wechselt die Vordergrund- ,bzw. Hintergrundfarbe
|*
\************************************************************************/
void SvxPixelCtl::ChangePixel( sal_uInt16 nPixel )
{
if( *( pPixel + nPixel) == 0 )
*( pPixel + nPixel) = 1; // koennte erweitert werden auf mehrere Farben
else
*( pPixel + nPixel) = 0;
}
/*************************************************************************
|*
|* Das angeklickte Rechteck wird ermittelt um die Farbe zu wechseln
|*
\************************************************************************/
void SvxPixelCtl::MouseButtonDown( const MouseEvent& rMEvt )
{
//Point aPt = PixelToLogic( rMEvt.GetPosPixel() );
//Point aPtTl, aPtBr;
//sal_uInt16 nX, nY;
//nX = (sal_uInt16) ( aPt.X() * nLines / aRectSize.Width() );
//nY = (sal_uInt16) ( aPt.Y() * nLines / aRectSize.Height() );
//ChangePixel( nX + nY * nLines );
//aPtTl.X() = aRectSize.Width() * nX / nLines + 1;
//aPtBr.X() = aRectSize.Width() * (nX + 1) / nLines - 1;
//aPtTl.Y() = aRectSize.Height() * nY / nLines + 1;
//aPtBr.Y() = aRectSize.Height() * (nY + 1) / nLines - 1;
//Invalidate( Rectangle( aPtTl, aPtBr ) );
//if( WINDOW_TABPAGE == GetParent()->GetType() )
// ( (SvxTabPage*) GetParent() )->PointChanged( this, RP_MM ); // RectPoint ist dummy
//Solution:Grab focus when click in window
if( !HasFocus() )
{
GrabFocus();
}
long nIndex = ShowPosition(rMEvt.GetPosPixel());
if(m_pAccess)
{
m_pAccess->NotifyChild(nIndex,sal_True,sal_True);
}
}
/*************************************************************************
|*
|* Zeichnet das Control (Rechteck mit 9 Kreisen)
|*
\************************************************************************/
void SvxPixelCtl::Paint( const Rectangle& )
{
sal_uInt16 i, j, nTmp;
Point aPtTl, aPtBr;
if( bPaintable )
{
// Linien Zeichnen
Control::SetLineColor( aLineColor );
for( i = 1; i < nLines; i++)
{
// horizontal
nTmp = (sal_uInt16) ( aRectSize.Height() * i / nLines );
DrawLine( Point( 0, nTmp ), Point( aRectSize.Width(), nTmp ) );
// vertikal
nTmp = (sal_uInt16) ( aRectSize.Width() * i / nLines );
DrawLine( Point( nTmp, 0 ), Point( nTmp, aRectSize.Height() ) );
}
// Rechtecke (Quadrate) zeichnen
Control::SetLineColor();
sal_uInt16 nLastPixel = *pPixel ? 0 : 1;
for( i = 0; i < nLines; i++)
{
aPtTl.Y() = aRectSize.Height() * i / nLines + 1;
aPtBr.Y() = aRectSize.Height() * (i + 1) / nLines - 1;
for( j = 0; j < nLines; j++)
{
aPtTl.X() = aRectSize.Width() * j / nLines + 1;
aPtBr.X() = aRectSize.Width() * (j + 1) / nLines - 1;
if ( *( pPixel + i * nLines + j ) != nLastPixel )
{
nLastPixel = *( pPixel + i * nLines + j );
// Farbe wechseln: 0 -> Hintergrundfarbe
SetFillColor( nLastPixel ? aPixelColor : aBackgroundColor );
}
DrawRect( Rectangle( aPtTl, aPtBr ) );
}
}
//Solution:Draw visual focus when has focus
if( HasFocus() )
{
ShowFocus(implCalFocusRect(aFocusPosition));
}
} // bPaintable
else
{
SetBackground( Wallpaper( Color( COL_LIGHTGRAY ) ) );
Control::SetLineColor( Color( COL_LIGHTRED ) );
DrawLine( Point( 0, 0 ), Point( aRectSize.Width(), aRectSize.Height() ) );
DrawLine( Point( 0, aRectSize.Height() ), Point( aRectSize.Width(), 0 ) );
}
}
//Solution:Caculate visual focus rectangle via focus position
Rectangle SvxPixelCtl::implCalFocusRect( const Point& aPosition )
{
long nLeft,nTop,nRight,nBottom;
long i,j;
i = aPosition.Y();
j = aPosition.X();
nLeft = aRectSize.Width() * j / nLines + 1;
nRight = aRectSize.Width() * (j + 1) / nLines - 1;
nTop = aRectSize.Height() * i / nLines + 1;
nBottom = aRectSize.Height() * (i + 1) / nLines - 1;
return Rectangle(nLeft,nTop,nRight,nBottom);
}
//Solution:Keyboard function
void SvxPixelCtl::KeyInput( const KeyEvent& rKEvt )
{
KeyCode aKeyCode = rKEvt.GetKeyCode();
sal_uInt16 nCode = aKeyCode.GetCode();
sal_Bool bIsMod = aKeyCode.IsShift() || aKeyCode.IsMod1() || aKeyCode.IsMod2();
if( !bIsMod )
{
Point pRepaintPoint( aRectSize.Width() *( aFocusPosition.getX() - 1)/ nLines - 1,
aRectSize.Height() *( aFocusPosition.getY() - 1)/ nLines -1
);
Size mRepaintSize( aRectSize.Width() *3/ nLines + 2,aRectSize.Height() *3/ nLines + 2);
Rectangle mRepaintRect( pRepaintPoint, mRepaintSize );
sal_Bool bFocusPosChanged=sal_False;
switch(nCode)
{
case KEY_LEFT:
if((aFocusPosition.getX() >= 1))
{
aFocusPosition.setX( aFocusPosition.getX() - 1 );
Invalidate(mRepaintRect);
bFocusPosChanged=sal_True;
}
break;
case KEY_RIGHT:
if( aFocusPosition.getX() < (nLines - 1) )
{
aFocusPosition.setX( aFocusPosition.getX() + 1 );
Invalidate(mRepaintRect);
bFocusPosChanged=sal_True;
}
break;
case KEY_UP:
if((aFocusPosition.getY() >= 1))
{
aFocusPosition.setY( aFocusPosition.getY() - 1 );
Invalidate(mRepaintRect);
bFocusPosChanged=sal_True;
}
break;
case KEY_DOWN:
if( aFocusPosition.getY() < ( nLines - 1 ) )
{
aFocusPosition.setY( aFocusPosition.getY() + 1 );
Invalidate(mRepaintRect);
bFocusPosChanged=sal_True;
}
break;
case KEY_SPACE:
ChangePixel( sal_uInt16(aFocusPosition.getX() + aFocusPosition.getY() * nLines) );
Invalidate( implCalFocusRect(aFocusPosition) );
break;
default:
Control::KeyInput( rKEvt );
return;
}
if(m_xAccess.is())
{
long nIndex = GetFoucsPosIndex();
switch(nCode)
{
case KEY_LEFT:
case KEY_RIGHT:
case KEY_UP:
case KEY_DOWN:
if (bFocusPosChanged)
{
m_pAccess->NotifyChild(nIndex,sal_False,sal_False);
}
break;
case KEY_SPACE:
m_pAccess->NotifyChild(nIndex,sal_False,sal_True);
break;
default:
break;
}
}
}
else
{
Control::KeyInput( rKEvt );
}
}
//Draw focus when get focus
void SvxPixelCtl::GetFocus()
{
Invalidate(implCalFocusRect(aFocusPosition));
if(m_pAccess)
{
m_pAccess->NotifyChild(GetFoucsPosIndex(),sal_True,sal_False);
}
Control::GetFocus();
}
//Hide focus when lose focus
void SvxPixelCtl::LoseFocus()
{
HideFocus();
if (m_pAccess)
{
m_pAccess->LoseFocus();
}
Control::LoseFocus();
}
/*************************************************************************
|*
|*
|*
\************************************************************************/
void SvxPixelCtl::SetXBitmap( const BitmapEx& rBitmapEx )
{
BitmapColor aBack;
BitmapColor aFront;
if(isHistorical8x8(rBitmapEx, aBack, aFront))
{
Bitmap aBitmap(rBitmapEx.GetBitmap());
BitmapReadAccess* pRead = aBitmap.AcquireReadAccess();
aBackgroundColor = aBack;
aPixelColor = aFront;
for(sal_uInt16 i(0); i < nSquares; i++)
{
const BitmapColor aColor(pRead->GetColor(i/8, i%8));
if(aColor == aBack)
{
*( pPixel + i ) = 0;
}
else
{
*( pPixel + i ) = 1;
}
}
aBitmap.ReleaseAccess(pRead);
}
}
/*************************************************************************
|*
|* Gibt ein bestimmtes Pixel zurueck
|*
\************************************************************************/
sal_uInt16 SvxPixelCtl::GetBitmapPixel( const sal_uInt16 nPixel )
{
return( *( pPixel + nPixel ) );
}
/*************************************************************************
|*
|* Bewirkt den Ursprungszustand des Controls
|*
\************************************************************************/
void SvxPixelCtl::Reset()
{
// clear pixel area
rtl_zeroMemory(pPixel, nSquares * sizeof(sal_uInt16));
Invalidate();
}
/*************************************************************************
|*
|* Ctor: BitmapCtl fuer SvxPixelCtl
|*
\************************************************************************/
SvxBitmapCtl::SvxBitmapCtl( Window* /*pParent*/, const Size& rSize )
{
aSize = rSize;
// aVD.SetOutputSizePixel( aSize );
}
/*************************************************************************
|*
|* Dtor
|*
\************************************************************************/
SvxBitmapCtl::~SvxBitmapCtl()
{
}
/*************************************************************************
|*
|* BitmapCtl: Gibt die Bitmap zurueck
|*
\************************************************************************/
BitmapEx SvxBitmapCtl::GetBitmapEx()
{
const Bitmap aRetval(createHistorical8x8FromArray(pBmpArray, aPixelColor, aBackgroundColor));
return BitmapEx(aRetval);
}
/*************************************************************************
|*
|* Fuellt die Listbox mit Farben und Strings
|*
\************************************************************************/
void ColorLB::Fill( const XColorListSharedPtr aColorTab )
{
long nCount = aColorTab->Count();
XColorEntry* pEntry;
SetUpdateMode( sal_False );
for( long i = 0; i < nCount; i++ )
{
pEntry = aColorTab->GetColor( i );
InsertEntry( pEntry->GetColor(), pEntry->GetName() );
}
AdaptDropDownLineCountToMaximum();
SetUpdateMode( sal_True );
}
/************************************************************************/
void ColorLB::Append( const XColorEntry& rEntry )
{
InsertEntry( rEntry.GetColor(), rEntry.GetName() );
AdaptDropDownLineCountToMaximum();
}
/************************************************************************/
void ColorLB::Modify( const XColorEntry& rEntry, sal_uInt16 nPos )
{
RemoveEntry( nPos );
InsertEntry( rEntry.GetColor(), rEntry.GetName(), nPos );
}
/*************************************************************************
|*
|* Fuellt die Listbox mit Farben und Strings
|*
\************************************************************************/
void FillAttrLB::Fill( const XColorListSharedPtr aColorTab )
{
long nCount = aColorTab->Count();
XColorEntry* pEntry;
SetUpdateMode( sal_False );
for( long i = 0; i < nCount; i++ )
{
pEntry = aColorTab->GetColor( i );
InsertEntry( pEntry->GetColor(), pEntry->GetName() );
}
AdaptDropDownLineCountToMaximum();
SetUpdateMode( sal_True );
}
/*************************************************************************
|*
|* Fuellt die Listbox (vorlaeufig) mit Strings
|*
\************************************************************************/
HatchingLB::HatchingLB( Window* pParent, ResId Id)
: ListBox( pParent, Id )
{
SetEdgeBlending(true);
}
HatchingLB::HatchingLB( Window* pParent, WinBits aWB)
: ListBox( pParent, aWB )
{
SetEdgeBlending(true);
}
void HatchingLB::Fill( const XHatchListSharedPtr aList )
{
XHatchEntry* pEntry;
long nCount = aList.get() ? aList->Count() : 0;
SetUpdateMode( sal_False );
for( long i = 0; i < nCount; i++ )
{
pEntry = aList->GetHatch( i );
const Bitmap aBitmap = aList->GetUiBitmap( i );
if( !aBitmap.IsEmpty() )
InsertEntry( pEntry->GetName(), aBitmap );
else
InsertEntry( pEntry->GetName() );
}
AdaptDropDownLineCountToMaximum();
SetUpdateMode( sal_True );
}
/************************************************************************/
void HatchingLB::Append( const XHatchEntry& rEntry, const Bitmap& rBitmap )
{
if(!rBitmap.IsEmpty())
{
InsertEntry( rEntry.GetName(), rBitmap );
}
else
{
InsertEntry( rEntry.GetName() );
}
AdaptDropDownLineCountToMaximum();
}
/************************************************************************/
void HatchingLB::Modify( const XHatchEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap )
{
RemoveEntry( nPos );
if( !rBitmap.IsEmpty() )
{
InsertEntry( rEntry.GetName(), rBitmap, nPos );
}
else
{
InsertEntry( rEntry.GetName(), nPos );
}
}
/************************************************************************/
void HatchingLB::SelectEntryByList( const XHatchListSharedPtr aList, const String& rStr, const XHatch& rHatch, sal_uInt16 nDist )
{
long nCount = aList.get() ? aList->Count() : 0;
XHatchEntry* pEntry;
sal_Bool bFound = sal_False;
String aStr;
long i;
for( i = 0; i < nCount && !bFound; i++ )
{
pEntry = aList->GetHatch( i );
aStr = pEntry->GetName();
if( rStr == aStr && rHatch == pEntry->GetHatch() )
bFound = sal_True;
}
if( bFound )
SelectEntryPos( (sal_uInt16) ( i - 1 + nDist ) );
}
/*************************************************************************
|*
|* Fuellt die Listbox (vorlaeufig) mit Strings
|*
\************************************************************************/
void FillAttrLB::Fill( const XHatchListSharedPtr aList )
{
long nCount = aList.get() ? aList->Count() : 0;
XHatchEntry* pEntry;
ListBox::SetUpdateMode( sal_False );
for( long i = 0; i < nCount; i++ )
{
pEntry = aList->GetHatch( i );
const Bitmap aBitmap = aList->GetUiBitmap( i );
if( !aBitmap.IsEmpty() )
ListBox::InsertEntry( pEntry->GetName(), aBitmap );
else
InsertEntry( pEntry->GetName() );
}
AdaptDropDownLineCountToMaximum();
ListBox::SetUpdateMode( sal_True );
}
/*************************************************************************
|*
|* Fuellt die Listbox (vorlaeufig) mit Strings
|*
\************************************************************************/
GradientLB::GradientLB( Window* pParent, ResId Id)
: ListBox( pParent, Id )
{
SetEdgeBlending(true);
}
GradientLB::GradientLB( Window* pParent, WinBits aWB)
: ListBox( pParent, aWB )
{
SetEdgeBlending(true);
}
void GradientLB::Fill( const XGradientListSharedPtr aList )
{
XGradientEntry* pEntry;
long nCount = aList.get() ? aList->Count() : 0;
SetUpdateMode( sal_False );
for( long i = 0; i < nCount; i++ )
{
pEntry = aList->GetGradient( i );
const Bitmap aBitmap = aList->GetUiBitmap( i );
if( !aBitmap.IsEmpty() )
InsertEntry( pEntry->GetName(), aBitmap );
else
InsertEntry( pEntry->GetName() );
}
AdaptDropDownLineCountToMaximum();
SetUpdateMode( sal_True );
}
/************************************************************************/
void GradientLB::Append( const XGradientEntry& rEntry, const Bitmap& rBitmap )
{
if(!rBitmap.IsEmpty())
{
InsertEntry( rEntry.GetName(), rBitmap );
}
else
{
InsertEntry( rEntry.GetName() );
}
AdaptDropDownLineCountToMaximum();
}
/************************************************************************/
void GradientLB::Modify( const XGradientEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap )
{
RemoveEntry( nPos );
if(!rBitmap.IsEmpty())
{
InsertEntry( rEntry.GetName(), rBitmap, nPos );
}
else
{
InsertEntry( rEntry.GetName(), nPos );
}
}
/************************************************************************/
void GradientLB::SelectEntryByList( const XGradientListSharedPtr aList, const String& rStr, const XGradient& rGradient, sal_uInt16 nDist )
{
long nCount = aList.get() ? aList->Count() : 0;
XGradientEntry* pEntry;
sal_Bool bFound = sal_False;
String aStr;
long i;
for( i = 0; i < nCount && !bFound; i++ )
{
pEntry = aList->GetGradient( i );
aStr = pEntry->GetName();
if( rStr == aStr && rGradient == pEntry->GetGradient() )
bFound = sal_True;
}
if( bFound )
SelectEntryPos( (sal_uInt16) ( i - 1 + nDist ) );
}
/*************************************************************************
|*
|* Fuellt die Listbox (vorlaeufig) mit Strings
|*
\************************************************************************/
void FillAttrLB::Fill( const XGradientListSharedPtr aList )
{
long nCount = aList.get() ? aList->Count() : 0;
XGradientEntry* pEntry;
ListBox::SetUpdateMode( sal_False );
for( long i = 0; i < nCount; i++ )
{
pEntry = aList->GetGradient( i );
const Bitmap aBitmap = aList->GetUiBitmap( i );
if( !aBitmap.IsEmpty() )
ListBox::InsertEntry( pEntry->GetName(), aBitmap );
else
InsertEntry( pEntry->GetName() );
}
AdaptDropDownLineCountToMaximum();
ListBox::SetUpdateMode( sal_True );
}
/*************************************************************************
|*
|* Konstruktor von BitmapLB
|*
\************************************************************************/
BitmapLB::BitmapLB(Window* pParent, ResId Id)
: ListBox(pParent, Id),
maBitmapEx()
{
SetEdgeBlending(true);
}
/************************************************************************/
namespace
{
void formatBitmapExToSize(BitmapEx& rBitmapEx, const Size& rSize)
{
if(!rBitmapEx.IsEmpty() && rSize.Width() > 0 && rSize.Height() > 0)
{
VirtualDevice aVirtualDevice;
aVirtualDevice.SetOutputSizePixel(rSize);
if(rBitmapEx.IsTransparent())
{
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
if(rStyleSettings.GetPreviewUsesCheckeredBackground())
{
const Point aNull(0, 0);
static const sal_uInt32 nLen(8);
static const Color aW(COL_WHITE);
static const Color aG(0xef, 0xef, 0xef);
aVirtualDevice.DrawCheckered(aNull, rSize, nLen, aW, aG);
}
else
{
aVirtualDevice.SetBackground(rStyleSettings.GetFieldColor());
aVirtualDevice.Erase();
}
}
if(rBitmapEx.GetSizePixel().Width() >= rSize.Width() && rBitmapEx.GetSizePixel().Height() >= rSize.Height())
{
static sal_uInt32 nScaleFlag(BMP_SCALE_FASTESTINTERPOLATE);
rBitmapEx.Scale(rSize, nScaleFlag);
aVirtualDevice.DrawBitmapEx(Point(0, 0), rBitmapEx);
}
else
{
const Size aBitmapSize(rBitmapEx.GetSizePixel());
for(sal_Int32 y(0); y < rSize.Height(); y += aBitmapSize.Height())
{
for(sal_Int32 x(0); x < rSize.Width(); x += aBitmapSize.Width())
{
aVirtualDevice.DrawBitmapEx(
Point(x, y),
rBitmapEx);
}
}
}
rBitmapEx = aVirtualDevice.GetBitmap(Point(0, 0), rSize);
}
}
} // end of anonymous namespace
/************************************************************************/
void BitmapLB::Fill(const XBitmapListSharedPtr aList)
{
XBitmapEntry* pEntry;
const long nCount(aList.get() ? aList->Count() : 0);
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
const Size aSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize());
SetUpdateMode(false);
for(long i(0); i < nCount; i++)
{
pEntry = aList->GetBitmap(i);
maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx();
formatBitmapExToSize(maBitmapEx, aSize);
InsertEntry(pEntry->GetName(), maBitmapEx);
}
AdaptDropDownLineCountToMaximum();
SetUpdateMode(true);
}
/************************************************************************/
void BitmapLB::Append(const Size& rSize, const XBitmapEntry& rEntry)
{
maBitmapEx = rEntry.GetGraphicObject().GetGraphic().GetBitmapEx();
if(!maBitmapEx.IsEmpty())
{
formatBitmapExToSize(maBitmapEx, rSize);
InsertEntry(rEntry.GetName(), maBitmapEx);
}
else
{
InsertEntry(rEntry.GetName());
}
AdaptDropDownLineCountToMaximum();
}
/************************************************************************/
void BitmapLB::Modify(const Size& rSize, const XBitmapEntry& rEntry, sal_uInt16 nPos)
{
RemoveEntry(nPos);
maBitmapEx = rEntry.GetGraphicObject().GetGraphic().GetBitmapEx();
if(!maBitmapEx.IsEmpty())
{
formatBitmapExToSize(maBitmapEx, rSize);
InsertEntry(rEntry.GetName(), maBitmapEx, nPos);
}
else
{
InsertEntry(rEntry.GetName());
}
}
/************************************************************************/
void BitmapLB::SelectEntryByList(const XBitmapListSharedPtr aList, const String& rStr)
{
const long nCount(aList.get() ? aList->Count() : 0);
XBitmapEntry* pEntry;
bool bFound(false);
long i(0);
for(i = 0; i < nCount && !bFound; i++)
{
pEntry = aList->GetBitmap(i);
const String aStr(pEntry->GetName());
if(rStr == aStr)
{
bFound = true;
}
}
if(bFound)
{
SelectEntryPos((sal_uInt16)(i - 1));
}
}
/*************************************************************************
|*
|* Konstruktor von FillAttrLB
|*
\************************************************************************/
FillAttrLB::FillAttrLB( Window* pParent, ResId Id )
: ColorListBox(pParent, Id),
maBitmapEx()
{
}
/************************************************************************/
FillAttrLB::FillAttrLB(Window* pParent, WinBits aWB)
: ColorListBox(pParent, aWB)
{
}
/************************************************************************/
void FillAttrLB::Fill(const XBitmapListSharedPtr aList)
{
const long nCount(aList.get() ? aList->Count() : 0);
XBitmapEntry* pEntry;
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
const Size aSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize());
ListBox::SetUpdateMode(false);
for(long i(0); i < nCount; i++)
{
pEntry = aList->GetBitmap( i );
maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx();
formatBitmapExToSize(maBitmapEx, aSize);
ListBox::InsertEntry(pEntry->GetName(), maBitmapEx);
}
AdaptDropDownLineCountToMaximum();
ListBox::SetUpdateMode(true);
}
/************************************************************************/
void FillAttrLB::SelectEntryByList( const XBitmapListSharedPtr aList, const String& rStr)
{
const long nCount(aList.get() ? aList->Count() : 0);
XBitmapEntry* pEntry;
bool bFound(false);
long i(0);
for(i = 0; i < nCount && !bFound; i++)
{
pEntry = aList->GetBitmap(i);
const String aStr(pEntry->GetName());
if(rStr == aStr)
{
bFound = true;
}
}
if(bFound)
{
SelectEntryPos((sal_uInt16)(i - 1));
}
}
/*************************************************************************
|*
|* Fuellt die Listbox (vorlaeufig) mit Strings
|*
\************************************************************************/
void FillTypeLB::Fill()
{
SetUpdateMode( sal_False );
InsertEntry( String( SVX_RES( RID_SVXSTR_INVISIBLE ) ) );
InsertEntry( String( SVX_RES( RID_SVXSTR_COLOR ) ) );
InsertEntry( String( SVX_RES( RID_SVXSTR_GRADIENT ) ) );
InsertEntry( String( SVX_RES( RID_SVXSTR_HATCH ) ) );
InsertEntry( String( SVX_RES( RID_SVXSTR_BITMAP ) ) );
AdaptDropDownLineCountToMaximum();
SetUpdateMode( sal_True );
}
/*************************************************************************
|*
|* Fuellt die Listbox (vorlaeufig) mit Strings
|*
\************************************************************************/
LineLB::LineLB(Window* pParent, ResId Id)
: ListBox(pParent, Id),
mbAddStandardFields(true)
{
// No EdgeBlending for LineStyle/Dash SetEdgeBlending(true);
}
LineLB::LineLB(Window* pParent, WinBits aWB)
: ListBox(pParent, aWB),
mbAddStandardFields(true)
{
// No EdgeBlending for LineStyle/Dash SetEdgeBlending(true);
}
LineLB::~LineLB()
{
}
void LineLB::setAddStandardFields(bool bNew)
{
if(getAddStandardFields() != bNew)
{
mbAddStandardFields = bNew;
}
}
void LineLB::Fill( const XDashListSharedPtr aList )
{
Clear();
if(getAddStandardFields() && aList.get())
{
// entry for 'none'
InsertEntry(aList->GetStringForUiNoLine());
// entry for solid line
InsertEntry(aList->GetStringForUiSolidLine(), aList->GetBitmapForUISolidLine());
}
// entries for dashed lines
long nCount = aList.get() ? aList->Count() : 0;
XDashEntry* pEntry;
SetUpdateMode( sal_False );
for( long i = 0; i < nCount; i++ )
{
pEntry = aList->GetDash( i );
const Bitmap aBitmap = aList->GetUiBitmap( i );
if( !aBitmap.IsEmpty() )
{
InsertEntry( pEntry->GetName(), aBitmap );
//delete pBitmap;
}
else
InsertEntry( pEntry->GetName() );
}
AdaptDropDownLineCountToMaximum();
SetUpdateMode( sal_True );
}
/************************************************************************/
void LineLB::Append( const XDashEntry& rEntry, const Bitmap& rBitmap )
{
if(!rBitmap.IsEmpty())
{
InsertEntry( rEntry.GetName(), rBitmap );
}
else
{
InsertEntry( rEntry.GetName() );
}
AdaptDropDownLineCountToMaximum();
}
/************************************************************************/
void LineLB::Modify( const XDashEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap )
{
RemoveEntry( nPos );
if(!rBitmap.IsEmpty())
{
InsertEntry( rEntry.GetName(), rBitmap, nPos );
}
else
{
InsertEntry( rEntry.GetName(), nPos );
}
}
/************************************************************************/
void LineLB::SelectEntryByList( const XDashListSharedPtr aList, const String& rStr, const XDash& rDash, sal_uInt16 nDist )
{
long nCount = aList.get() ? aList->Count() : 0;
XDashEntry* pEntry;
sal_Bool bFound = sal_False;
String aStr;
XDash aDash;
long i;
for( i = 0; i < nCount && !bFound; i++ )
{
pEntry = aList->GetDash( i );
aStr = pEntry->GetName();
aDash = pEntry->GetDash();
if( rStr == aStr && rDash == aDash )
bFound = sal_True;
}
if( bFound )
SelectEntryPos( (sal_uInt16) ( i - 1 + nDist ) );
}
/*************************************************************************
|*
|* Fuellt die Listbox (vorlaeufig) mit Strings
|*
\************************************************************************/
LineEndLB::LineEndLB( Window* pParent, ResId Id )
: ListBox( pParent, Id )
{
// No EdgeBlending for LineEnds SetEdgeBlending(true);
}
LineEndLB::LineEndLB( Window* pParent, WinBits aWB )
: ListBox( pParent, aWB )
{
// No EdgeBlending for LineEnds SetEdgeBlending(true);
}
LineEndLB::~LineEndLB(void)
{
}
void LineEndLB::Fill( const XLineEndListSharedPtr aList, bool bStart )
{
long nCount = aList.get() ? aList->Count() : 0;
XLineEndEntry* pEntry;
VirtualDevice aVD;
SetUpdateMode( sal_False );
for( long i = 0; i < nCount; i++ )
{
pEntry = aList->GetLineEnd( i );
const Bitmap aBitmap = aList->GetUiBitmap( i );
if( !aBitmap.IsEmpty() )
{
Size aBmpSize( aBitmap.GetSizePixel() );
aVD.SetOutputSizePixel( aBmpSize, sal_False );
aVD.DrawBitmap( Point(), aBitmap );
InsertEntry( pEntry->GetName(),
aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ),
Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ) );
//delete pBitmap;
}
else
InsertEntry( pEntry->GetName() );
}
AdaptDropDownLineCountToMaximum();
SetUpdateMode( sal_True );
}
/************************************************************************/
void LineEndLB::Append( const XLineEndEntry& rEntry, const Bitmap& rBitmap, bool bStart )
{
if(!rBitmap.IsEmpty())
{
VirtualDevice aVD;
const Size aBmpSize(rBitmap.GetSizePixel());
aVD.SetOutputSizePixel(aBmpSize, false);
aVD.DrawBitmap(Point(), rBitmap);
InsertEntry(
rEntry.GetName(),
aVD.GetBitmap(bStart ? Point() : Point(aBmpSize.Width() / 2, 0 ), Size(aBmpSize.Width() / 2, aBmpSize.Height())));
}
else
{
InsertEntry(rEntry.GetName());
}
AdaptDropDownLineCountToMaximum();
}
/************************************************************************/
void LineEndLB::Modify( const XLineEndEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap, bool bStart )
{
RemoveEntry( nPos );
if(!rBitmap.IsEmpty())
{
VirtualDevice aVD;
const Size aBmpSize(rBitmap.GetSizePixel());
aVD.SetOutputSizePixel(aBmpSize, false);
aVD.DrawBitmap(Point(), rBitmap);
InsertEntry(
rEntry.GetName(),
aVD.GetBitmap(bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ), Size( aBmpSize.Width() / 2, aBmpSize.Height())),
nPos);
}
else
{
InsertEntry(rEntry.GetName(), nPos);
}
}
//////////////////////////////////////////////////////////////////////////////
void SvxPreviewBase::InitSettings(bool bForeground, bool bBackground)
{
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
if(bForeground)
{
svtools::ColorConfig aColorConfig;
Color aTextColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor);
if(IsControlForeground())
{
aTextColor = GetControlForeground();
}
getBufferDevice().SetTextColor(aTextColor);
}
if(bBackground)
{
if(IsControlBackground())
{
getBufferDevice().SetBackground(GetControlBackground());
}
else
{
getBufferDevice().SetBackground(rStyleSettings.GetWindowColor());
}
}
// do not paint background self, it gets painted buffered
SetControlBackground();
SetBackground();
Invalidate();
}
SvxPreviewBase::SvxPreviewBase( Window* pParent, const ResId& rResId )
: Control( pParent, rResId ),
mpModel( new SdrModel() ),
mpBufferDevice( new VirtualDevice(*this) )
{
// Draw the control's border as a flat thin black line.
SetBorderStyle(WINDOW_BORDER_MONO);
SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
SetMapMode(MAP_100TH_MM);
// init model
mpModel->GetItemPool().FreezeIdRanges();
}
SvxPreviewBase::~SvxPreviewBase()
{
delete mpModel;
delete mpBufferDevice;
}
void SvxPreviewBase::LocalPrePaint()
{
// init BufferDevice
if(mpBufferDevice->GetOutputSizePixel() != GetOutputSizePixel())
{
mpBufferDevice->SetDrawMode(GetDrawMode());
mpBufferDevice->SetSettings(GetSettings());
mpBufferDevice->SetAntialiasing(GetAntialiasing());
mpBufferDevice->SetOutputSizePixel(GetOutputSizePixel());
mpBufferDevice->SetMapMode(GetMapMode());
}
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
if(rStyleSettings.GetPreviewUsesCheckeredBackground())
{
const Point aNull(0, 0);
static const sal_uInt32 nLen(8);
static const Color aW(COL_WHITE);
static const Color aG(0xef, 0xef, 0xef);
const bool bWasEnabled(mpBufferDevice->IsMapModeEnabled());
mpBufferDevice->EnableMapMode(false);
mpBufferDevice->DrawCheckered(aNull, mpBufferDevice->GetOutputSizePixel(), nLen, aW, aG);
mpBufferDevice->EnableMapMode(bWasEnabled);
}
else
{
mpBufferDevice->Erase();
}
}
void SvxPreviewBase::LocalPostPaint()
{
// copy to front (in pixel mode)
const bool bWasEnabledSrc(mpBufferDevice->IsMapModeEnabled());
const bool bWasEnabledDst(IsMapModeEnabled());
const Point aEmptyPoint;
mpBufferDevice->EnableMapMode(false);
EnableMapMode(false);
DrawOutDev(
aEmptyPoint, GetOutputSizePixel(),
aEmptyPoint, GetOutputSizePixel(),
*mpBufferDevice);
mpBufferDevice->EnableMapMode(bWasEnabledSrc);
EnableMapMode(bWasEnabledDst);
}
void SvxPreviewBase::StateChanged(StateChangedType nType)
{
Control::StateChanged(nType);
if(STATE_CHANGE_CONTROLFOREGROUND == nType)
{
InitSettings(true, false);
}
else if(STATE_CHANGE_CONTROLBACKGROUND == nType)
{
InitSettings(false, true);
}
}
void SvxPreviewBase::DataChanged(const DataChangedEvent& rDCEvt)
{
SetDrawMode(GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR);
if((DATACHANGED_SETTINGS == rDCEvt.GetType()) && (rDCEvt.GetFlags() & SETTINGS_STYLE))
{
InitSettings(true, true);
}
else
{
Control::DataChanged(rDCEvt);
}
}
/*************************************************************************
|*
|* SvxXLinePreview::SvxXLinePreview()
|*
*************************************************************************/
SvxXLinePreview::SvxXLinePreview( Window* pParent, const ResId& rResId )
: SvxPreviewBase( pParent, rResId ),
mpLineObjA( 0L ),
mpLineObjB( 0L ),
mpLineObjC( 0L ),
mpGraphic( 0L ),
mbWithSymbol( sal_False )
{
const Size aOutputSize(GetOutputSize());
InitSettings( sal_True, sal_True );
const sal_Int32 nDistance(500L);
const sal_Int32 nAvailableLength(aOutputSize.Width() - (4 * nDistance));
// create DrawObectA
const sal_Int32 aYPosA(aOutputSize.Height() / 2);
const basegfx::B2DPoint aPointA1( nDistance, aYPosA);
const basegfx::B2DPoint aPointA2( aPointA1.getX() + ((nAvailableLength * 14) / 20), aYPosA );
basegfx::B2DPolygon aPolygonA;
aPolygonA.append(aPointA1);
aPolygonA.append(aPointA2);
mpLineObjA = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPolygonA));
mpLineObjA->SetModel(&getModel());
// create DrawObectB
const sal_Int32 aYPosB1((aOutputSize.Height() * 3) / 4);
const sal_Int32 aYPosB2((aOutputSize.Height() * 1) / 4);
const basegfx::B2DPoint aPointB1( aPointA2.getX() + nDistance, aYPosB1);
const basegfx::B2DPoint aPointB2( aPointB1.getX() + ((nAvailableLength * 2) / 20), aYPosB2 );
const basegfx::B2DPoint aPointB3( aPointB2.getX() + ((nAvailableLength * 2) / 20), aYPosB1 );
basegfx::B2DPolygon aPolygonB;
aPolygonB.append(aPointB1);
aPolygonB.append(aPointB2);
aPolygonB.append(aPointB3);
mpLineObjB = new SdrPathObj(OBJ_PLIN, basegfx::B2DPolyPolygon(aPolygonB));
mpLineObjB->SetModel(&getModel());
// create DrawObectC
const basegfx::B2DPoint aPointC1( aPointB3.getX() + nDistance, aYPosB1);
const basegfx::B2DPoint aPointC2( aPointC1.getX() + ((nAvailableLength * 1) / 20), aYPosB2 );
const basegfx::B2DPoint aPointC3( aPointC2.getX() + ((nAvailableLength * 1) / 20), aYPosB1 );
basegfx::B2DPolygon aPolygonC;
aPolygonC.append(aPointC1);
aPolygonC.append(aPointC2);
aPolygonC.append(aPointC3);
mpLineObjC = new SdrPathObj(OBJ_PLIN, basegfx::B2DPolyPolygon(aPolygonC));
mpLineObjC->SetModel(&getModel());
}
SvxXLinePreview::~SvxXLinePreview()
{
SdrObject::Free( mpLineObjA );
SdrObject::Free( mpLineObjB );
SdrObject::Free( mpLineObjC );
}
// -----------------------------------------------------------------------
void SvxXLinePreview::SetSymbol(Graphic* p,const Size& s)
{
mpGraphic = p;
maSymbolSize = s;
}
// -----------------------------------------------------------------------
void SvxXLinePreview::ResizeSymbol(const Size& s)
{
if ( s != maSymbolSize )
{
maSymbolSize = s;
Invalidate();
}
}
// -----------------------------------------------------------------------
void SvxXLinePreview::SetLineAttributes(const SfxItemSet& rItemSet)
{
// Set ItemSet at objects
mpLineObjA->SetMergedItemSet(rItemSet);
// At line joints, do not use arrows
SfxItemSet aTempSet(rItemSet);
aTempSet.ClearItem(XATTR_LINESTART);
aTempSet.ClearItem(XATTR_LINEEND);
mpLineObjB->SetMergedItemSet(aTempSet);
mpLineObjC->SetMergedItemSet(aTempSet);
}
// -----------------------------------------------------------------------
void SvxXLinePreview::Paint( const Rectangle& )
{
LocalPrePaint();
// paint objects to buffer device
sdr::contact::SdrObjectVector aObjectVector;
aObjectVector.push_back(mpLineObjA);
aObjectVector.push_back(mpLineObjB);
aObjectVector.push_back(mpLineObjC);
sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
sdr::contact::DisplayInfo aDisplayInfo;
// do processing
aPainter.ProcessDisplay(aDisplayInfo);
if ( mbWithSymbol && mpGraphic )
{
const Size aOutputSize(GetOutputSize());
Point aPos = Point( aOutputSize.Width() / 3, aOutputSize.Height() / 2 );
aPos.X() -= maSymbolSize.Width() / 2;
aPos.Y() -= maSymbolSize.Height() / 2;
mpGraphic->Draw( &getBufferDevice(), aPos, maSymbolSize );
}
LocalPostPaint();
}
/*************************************************************************
|*
|* SvxXRectPreview::SvxXRectPreview()
|*
*************************************************************************/
SvxXRectPreview::SvxXRectPreview( Window* pParent, const ResId& rResId )
: SvxPreviewBase( pParent, rResId ),
mpRectangleObject(0)
{
InitSettings(true, true);
// create RectangleObject
const Rectangle aObjectSize(Point(), GetOutputSize());
mpRectangleObject = new SdrRectObj(aObjectSize);
mpRectangleObject->SetModel(&getModel());
}
SvxXRectPreview::~SvxXRectPreview()
{
SdrObject::Free(mpRectangleObject);
}
void SvxXRectPreview::SetAttributes(const SfxItemSet& rItemSet)
{
mpRectangleObject->SetMergedItemSet(rItemSet, true);
mpRectangleObject->SetMergedItem(XLineStyleItem(XLINE_NONE));
}
void SvxXRectPreview::Paint( const Rectangle& )
{
LocalPrePaint();
sdr::contact::SdrObjectVector aObjectVector;
aObjectVector.push_back(mpRectangleObject);
sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
sdr::contact::DisplayInfo aDisplayInfo;
aPainter.ProcessDisplay(aDisplayInfo);
LocalPostPaint();
}
/*************************************************************************
|*
|* SvxXShadowPreview::SvxXShadowPreview()
|*
*************************************************************************/
SvxXShadowPreview::SvxXShadowPreview( Window* pParent, const ResId& rResId )
: SvxPreviewBase( pParent, rResId ),
mpRectangleObject(0),
mpRectangleShadow(0)
{
InitSettings(true, true);
// prepare size
Size aSize = GetOutputSize();
aSize.Width() = aSize.Width() / 3;
aSize.Height() = aSize.Height() / 3;
// create RectangleObject
const Rectangle aObjectSize( Point( aSize.Width(), aSize.Height() ), aSize );
mpRectangleObject = new SdrRectObj(aObjectSize);
mpRectangleObject->SetModel(&getModel());
// create ShadowObject
const Rectangle aShadowSize( Point( aSize.Width(), aSize.Height() ), aSize );
mpRectangleShadow = new SdrRectObj(aShadowSize);
mpRectangleShadow->SetModel(&getModel());
}
SvxXShadowPreview::~SvxXShadowPreview()
{
SdrObject::Free(mpRectangleObject);
SdrObject::Free(mpRectangleShadow);
}
void SvxXShadowPreview::SetRectangleAttributes(const SfxItemSet& rItemSet)
{
mpRectangleObject->SetMergedItemSet(rItemSet, true);
mpRectangleObject->SetMergedItem(XLineStyleItem(XLINE_NONE));
}
void SvxXShadowPreview::SetShadowAttributes(const SfxItemSet& rItemSet)
{
mpRectangleShadow->SetMergedItemSet(rItemSet, true);
mpRectangleShadow->SetMergedItem(XLineStyleItem(XLINE_NONE));
}
void SvxXShadowPreview::SetShadowPosition(const Point& rPos)
{
Rectangle aObjectPosition(mpRectangleObject->GetSnapRect());
aObjectPosition.Move(rPos.X(), rPos.Y());
mpRectangleShadow->SetSnapRect(aObjectPosition);
}
void SvxXShadowPreview::Paint( const Rectangle& )
{
LocalPrePaint();
sdr::contact::SdrObjectVector aObjectVector;
aObjectVector.push_back(mpRectangleShadow);
aObjectVector.push_back(mpRectangleObject);
sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
sdr::contact::DisplayInfo aDisplayInfo;
aPainter.ProcessDisplay(aDisplayInfo);
LocalPostPaint();
}
// -----------------------------------------------------------------------
// eof
| 27.570905 | 138 | 0.582347 | [
"object",
"model",
"solid"
] |
5b9e66784fc855c8fba7467ab36499dbb4faf776 | 13,561 | hh | C++ | src/mmutil_diff.hh | YPARK/mmutil | 21729fc50ac4cefff58c1b71e8c5740d2045b111 | [
"MIT"
] | null | null | null | src/mmutil_diff.hh | YPARK/mmutil | 21729fc50ac4cefff58c1b71e8c5740d2045b111 | [
"MIT"
] | null | null | null | src/mmutil_diff.hh | YPARK/mmutil | 21729fc50ac4cefff58c1b71e8c5740d2045b111 | [
"MIT"
] | null | null | null | #include <getopt.h>
#include <unordered_map>
#include "mmutil.hh"
#include "mmutil_io.hh"
#include "mmutil_index.hh"
#include "utils/progress.hh"
#include "utils/std_util.hh"
#include "mmutil_pois.hh"
#ifndef MMUTIL_DIFF_HH_
#define MMUTIL_DIFF_HH_
struct diff_options_t {
diff_options_t()
{
mtx_file = "";
annot_prob_file = "";
annot_file = "";
annot_name_file = "";
trt_ind_file = "";
out = "output";
verbose = false;
gamma_a0 = 1;
gamma_b0 = 1;
discretize = true;
normalize = false;
}
std::string mtx_file;
std::string annot_prob_file;
std::string annot_file;
std::string col_file;
std::string row_file;
std::string trt_ind_file;
std::string annot_name_file;
std::string out;
// For Bayesian calibration and Wald stat
// Scalar wald_reg;
Scalar gamma_a0;
Scalar gamma_b0;
bool verbose;
// pois
bool discretize;
bool normalize;
};
struct diff_stat_collector_t {
using scalar_t = Scalar;
using index_t = Index;
explicit diff_stat_collector_t(const std::vector<Index> &_conditions,
const Index ncond,
const Mat &_Z)
: conditions(_conditions)
, Ncond(ncond)
, Z(_Z)
, K(Z.cols())
{
max_row = 0;
max_col = 0;
max_elem = 0;
}
void eval_after_header(const Index r, const Index c, const Index e)
{
std::tie(max_row, max_col, max_elem) = std::make_tuple(r, c, e);
ASSERT(max_col == conditions.size(),
"the size of the condition vector should match with the data");
ASSERT(Z.rows() == max_col, "rows(Z) must correspond to the columns");
sum_mat.resize(max_row, K * Ncond);
sum_mat.setZero();
// #ifdef DEBUG
// TLOG("Header: " << max_row << ", " << max_col << ", " << max_elem);
// #endif
}
void eval(const Index row, const Index col, const Scalar w)
{
if (row < max_row && col < max_col) {
const Index t = conditions[col];
const Index g = row;
for (Index k = 0; k < K; ++k) {
const Scalar z_jk = Z(col, k);
const Index j = pos(k, t);
// if (j < 0 || j > K * Ncond) {
// ELOG(j << ", " << k << ", " << t);
// }
sum_mat(g, j) += w * z_jk;
}
}
}
void eval_end_of_file()
{
#ifdef DEBUG
TLOG("Finished traversing");
#endif
}
inline Mat sum(const Index k) const
{
Mat ret(max_row, Ncond);
ret.setZero();
for (Index t = 0; t < Ncond; ++t)
ret.col(t) = sum_mat.col(pos(k, t));
return ret;
}
const std::vector<Index> &conditions; // condition for each column
const Index Ncond; // # of conditions
const Mat &Z; // annotation matrix
const Index K; // # of annotations
private:
Mat sum_mat; // max_row x (conditions * K)
Index max_row;
Index max_col;
Index max_elem;
inline Index pos(const Index k, const Index t) const
{
ASSERT(k >= 0 && k < K, "k out of range");
ASSERT(t >= 0 && t < Ncond, "t out of range");
return t * Ncond + k;
}
};
template <typename OPTIONS>
int
test_diff(const OPTIONS &options)
{
const std::string mtx_file = options.mtx_file;
const std::string annot_prob_file = options.annot_prob_file;
const std::string annot_file = options.annot_file;
const std::string col_file = options.col_file;
const std::string row_file = options.row_file;
const std::string annot_name_file = options.annot_name_file;
const std::string output = options.out;
const std::string trt_file = options.trt_ind_file;
const Scalar a0 = options.gamma_a0;
const Scalar b0 = options.gamma_b0;
//////////////////////////
// column and row names //
//////////////////////////
std::vector<std::string> cols;
CHECK(read_vector_file(col_file, cols));
const Index Nsample = cols.size();
std::vector<std::string> features;
CHECK(read_vector_file(row_file, features));
const Index Nfeature = features.size();
/////////////////
// label names //
/////////////////
std::vector<std::string> annot_name;
CHECK(read_vector_file(annot_name_file, annot_name));
auto lab_position = make_position_dict<std::string, Index>(annot_name);
const Index K = annot_name.size();
///////////////////////
// latent annotation //
///////////////////////
Mat Z;
if (annot_file.size() > 0) {
Z.resize(Nsample, K);
Z.setZero();
std::unordered_map<std::string, std::string> annot_dict;
CHECK(read_dict_file(annot_file, annot_dict));
for (Index j = 0; j < cols.size(); ++j) {
const std::string &s = cols.at(j);
if (annot_dict.count(s) > 0) {
const std::string &t = annot_dict.at(s);
if (lab_position.count(t) > 0) {
const Index k = lab_position.at(t);
Z(j, k) = 1.;
}
}
}
} else if (annot_prob_file.size() > 0) {
CHECK(read_data_file(annot_prob_file, Z));
} else {
return EXIT_FAILURE;
}
TLOG("Read latent annotations --> [" << Z.rows() << " x " << Z.cols()
<< "]");
std::vector<std::string> trt_membership;
CHECK(read_vector_file(trt_file, trt_membership));
ASSERT(trt_membership.size() == Nsample,
"Needs " << Nsample << " membership vector");
TLOG("Reading condition vector --> [" << Nsample << " x 1]");
std::vector<std::string> trt_id_name;
std::vector<Index> trt_lab; // map: col -> trt index
std::tie(trt_lab, trt_id_name, std::ignore) =
make_indexed_vector<std::string, Index>(trt_membership);
const Index T = trt_id_name.size();
TLOG("Found " << T << " treatment conditions");
diff_stat_collector_t collector(trt_lab, T, Z);
visit_matrix_market_file(mtx_file, collector);
TLOG("Collected sufficient statistics");
// log-likelihood
std::vector<std::tuple<std::string, std::string, Scalar, Scalar>> out_vec;
out_vec.reserve(K * Nfeature);
// lambda for each treatment condition
Mat lambda_out(Nfeature * K, T);
lambda_out.setZero();
Mat sum_out(Nfeature * K, T);
sum_out.setZero();
Mat n_out(Nfeature * K, T);
n_out.setZero();
Mat lambda_null_out(Nfeature * K, 1);
lambda_null_out.setZero();
poisson_t::rate_op_t rate_op(a0, b0);
for (Index k = 0; k < K; ++k) {
const Mat S1 = collector.sum(k);
const Index D = S1.rows();
if (features.size() != D) {
ELOG("{# features in .rows} != {# features in .mtx}");
return EXIT_FAILURE;
}
Mat N(D, T);
N.setZero();
for (Index j = 0; j < Z.rows(); ++j) {
const Index t = trt_lab[j];
N.col(t).array() += Z(j, k);
}
const Index ntot = N.sum();
TLOG("Testing on " << ntot << " columns");
const Mat lambda = S1.binaryExpr(N, rate_op);
const Mat ln_lambda =
lambda.unaryExpr([](const Scalar &x) { return fasterlog(x); });
const Mat lambda_null =
(S1 * Mat::Ones(T, 1)).binaryExpr(N * Mat::Ones(T, 1), rate_op);
const Mat ln_lambda_null =
lambda_null.unaryExpr([](const Scalar &x) { return fasterlog(x); });
const Vec llik1 =
(ln_lambda.cwiseProduct(S1) - lambda.cwiseProduct(N)) *
Mat::Ones(T, 1);
const Vec llik0 = ln_lambda_null.cwiseProduct(S1 * Mat::Ones(T, 1)) -
lambda_null.cwiseProduct(N * Mat::Ones(T, 1));
for (Index g = 0; g < D; ++g) {
out_vec.emplace_back(std::make_tuple<>(features[g],
annot_name[k],
llik1(g),
llik0(g)));
lambda_out.row(k * Nfeature + g) = lambda.row(g);
lambda_null_out.row(k * Nfeature + g) = lambda_null.row(g);
sum_out.row(k * Nfeature + g) = S1.row(g);
n_out.row(k * Nfeature + g) = N.row(g);
}
}
write_vector_file(output + ".cond.gz", trt_id_name);
write_tuple_file(output + ".stat.gz", out_vec);
write_data_file(output + ".lambda.gz", lambda_out);
write_data_file(output + ".lambda_null.gz", lambda_null_out);
write_data_file(output + ".sum.gz", sum_out);
write_data_file(output + ".n.gz", n_out);
return EXIT_SUCCESS;
}
template <typename OPTIONS>
int
parse_diff_options(const int argc, //
const char *argv[], //
OPTIONS &options)
{
const char *_usage =
"\n"
"[Arguments]\n"
"--mtx (-m) : data MTX file (M x N)\n"
"--data (-m) : data MTX file (M x N)\n"
"--feature (-f) : data row file (features)\n"
"--row (-f) : data row file (features)\n"
"--col (-c) : data column file (N x 1)\n"
"--annot (-a) : annotation/clustering assignment (N x 2)\n"
"--annot_prob (-A) : annotation/clustering probability (N x K)\n"
"--trt (-t) : N x 1 sample to case-control membership\n"
"--lab (-l) : K x 1 annotation label name (e.g., cell type) \n"
"--out (-o) : Output file header\n"
"\n"
"--gamma_a0 : prior for gamma distribution(a0,b0) (default: 1)\n"
"--gamma_b0 : prior for gamma distribution(a0,b0) (default: 1)\n"
"\n";
const char *const short_opts =
"m:c:f:a:A:l:t:o:LRS:r:u:w:g:G:BDPC:k:b:n:hzv0:1:";
const option long_opts[] = {
{ "mtx", required_argument, nullptr, 'm' }, //
{ "data", required_argument, nullptr, 'm' }, //
{ "annot_prob", required_argument, nullptr, 'A' }, //
{ "annot", required_argument, nullptr, 'a' }, //
{ "col", required_argument, nullptr, 'c' }, //
{ "row", required_argument, nullptr, 'f' }, //
{ "feature", required_argument, nullptr, 'f' }, //
{ "trt", required_argument, nullptr, 't' }, //
{ "trt_ind", required_argument, nullptr, 't' }, //
{ "lab", required_argument, nullptr, 'l' }, //
{ "label", required_argument, nullptr, 'l' }, //
{ "out", required_argument, nullptr, 'o' }, //
{ "discretize", no_argument, nullptr, 'D' }, //
{ "probabilistic", no_argument, nullptr, 'P' }, //
{ "a0", required_argument, nullptr, '0' }, //
{ "b0", required_argument, nullptr, '1' }, //
{ "gamma_a0", required_argument, nullptr, '0' }, //
{ "gamma_a1", required_argument, nullptr, '1' }, //
{ "verbose", no_argument, nullptr, 'v' }, //
{ nullptr, no_argument, nullptr, 0 }
};
while (true) {
const auto opt = getopt_long(argc, //
const_cast<char **>(argv), //
short_opts, //
long_opts, //
nullptr);
if (-1 == opt)
break;
switch (opt) {
case 'm':
options.mtx_file = std::string(optarg);
break;
case 'A':
options.annot_prob_file = std::string(optarg);
break;
case 'a':
options.annot_file = std::string(optarg);
break;
case 'c':
options.col_file = std::string(optarg);
break;
case 'f':
options.row_file = std::string(optarg);
break;
case 't':
options.trt_ind_file = std::string(optarg);
break;
case 'l':
options.annot_name_file = std::string(optarg);
break;
case 'o':
options.out = std::string(optarg);
break;
case 'P':
options.discretize = false;
break;
case 'D':
options.discretize = true;
break;
case '0':
options.gamma_a0 = std::stof(optarg);
break;
case '1':
options.gamma_b0 = std::stof(optarg);
break;
case 'v': // -v or --verbose
options.verbose = true;
break;
case 'h': // -h or --help
case '?': // Unrecognized option
std::cerr << _usage << std::endl;
return EXIT_FAILURE;
default: //
;
}
}
ERR_RET(!file_exists(options.mtx_file), "No MTX file");
ERR_RET(!file_exists(options.annot_prob_file) &&
!file_exists(options.annot_file),
"No ANNOT or ANNOT_PROB file");
ERR_RET(!file_exists(options.col_file), "No COL file");
ERR_RET(!file_exists(options.row_file), "No ROW data file");
ERR_RET(!file_exists(options.trt_ind_file), "No TRT file");
ERR_RET(!file_exists(options.annot_name_file), "No LAB file");
return EXIT_SUCCESS;
}
#endif
| 29.935982 | 80 | 0.515817 | [
"vector"
] |
5ba7c2092340373c6b0e0a02f04b2db78afadafe | 20,577 | hpp | C++ | include/opentxs/core/script/OTAgent.hpp | grealish/opentxs | 614999063079f5843428abcaa62974f5f19f88a1 | [
"Apache-2.0"
] | 1 | 2015-01-23T13:24:07.000Z | 2015-01-23T13:24:07.000Z | include/opentxs/core/script/OTAgent.hpp | grealish/opentxs | 614999063079f5843428abcaa62974f5f19f88a1 | [
"Apache-2.0"
] | null | null | null | include/opentxs/core/script/OTAgent.hpp | grealish/opentxs | 614999063079f5843428abcaa62974f5f19f88a1 | [
"Apache-2.0"
] | null | null | null | /************************************************************
*
* OTAgent.hpp
*
*/
/************************************************************
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
* OPEN TRANSACTIONS
*
* Financial Cryptography and Digital Cash
* Library, Protocol, API, Server, CLI, GUI
*
* -- Anonymous Numbered Accounts.
* -- Untraceable Digital Cash.
* -- Triple-Signed Receipts.
* -- Cheques, Vouchers, Transfers, Inboxes.
* -- Basket Currencies, Markets, Payment Plans.
* -- Signed, XML, Ricardian-style Contracts.
* -- Scripted smart contracts.
*
* Copyright (C) 2010-2013 by "Fellow Traveler" (A pseudonym)
*
* EMAIL:
* FellowTraveler@rayservers.net
*
* BITCOIN: 1NtTPVVjDsUfDWybS4BwvHpG2pdS9RnYyQ
*
* KEY FINGERPRINT (PGP Key in license file):
* 9DD5 90EB 9292 4B48 0484 7910 0308 00ED F951 BB8E
*
* OFFICIAL PROJECT WIKI(s):
* https://github.com/FellowTraveler/Moneychanger
* https://github.com/FellowTraveler/Open-Transactions/wiki
*
* WEBSITE:
* http://www.OpenTransactions.org/
*
* Components and licensing:
* -- Moneychanger..A Java client GUI.....LICENSE:.....GPLv3
* -- otlib.........A class library.......LICENSE:...LAGPLv3
* -- otapi.........A client API..........LICENSE:...LAGPLv3
* -- opentxs/ot....Command-line client...LICENSE:...LAGPLv3
* -- otserver......Server Application....LICENSE:....AGPLv3
* Github.com/FellowTraveler/Open-Transactions/wiki/Components
*
* All of the above OT components were designed and written by
* Fellow Traveler, with the exception of Moneychanger, which
* was contracted out to Vicky C (bitcointrader4@gmail.com).
* The open-source community has since actively contributed.
*
* -----------------------------------------------------
*
* LICENSE:
* This program is free software: you can redistribute it
* and/or modify it under the terms of the GNU Affero
* General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* ADDITIONAL PERMISSION under the GNU Affero GPL version 3
* section 7: (This paragraph applies only to the LAGPLv3
* components listed above.) If you modify this Program, or
* any covered work, by linking or combining it with other
* code, such other code is not for that reason alone subject
* to any of the requirements of the GNU Affero GPL version 3.
* (==> This means if you are only using the OT API, then you
* don't have to open-source your code--only your changes to
* Open-Transactions itself must be open source. Similar to
* LGPLv3, except it applies to software-as-a-service, not
* just to distributing binaries.)
*
* Extra WAIVER for OpenSSL, Lucre, and all other libraries
* used by Open Transactions: This program is released under
* the AGPL with the additional exemption that compiling,
* linking, and/or using OpenSSL is allowed. The same is true
* for any other open source libraries included in this
* project: complete waiver from the AGPL is hereby granted to
* compile, link, and/or use them with Open-Transactions,
* according to their own terms, as long as the rest of the
* Open-Transactions terms remain respected, with regard to
* the Open-Transactions code itself.
*
* Lucre License:
* This code is also "dual-license", meaning that Ben Lau-
* rie's license must also be included and respected, since
* the code for Lucre is also included with Open Transactions.
* See Open-Transactions/src/otlib/lucre/LUCRE_LICENSE.txt
* The Laurie requirements are light, but if there is any
* problem with his license, simply remove the Lucre code.
* Although there are no other blind token algorithms in Open
* Transactions (yet. credlib is coming), the other functions
* will continue to operate.
* See Lucre on Github: https://github.com/benlaurie/lucre
* -----------------------------------------------------
* You should have received a copy of the GNU Affero General
* Public License along with this program. If not, see:
* http://www.gnu.org/licenses/
*
* If you would like to use this software outside of the free
* software license, please contact FellowTraveler.
* (Unfortunately many will run anonymously and untraceably,
* so who could really stop them?)
*
* DISCLAIMER:
* 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 Affero General Public License for
* more details.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)
iQIcBAEBAgAGBQJRSsfJAAoJEAMIAO35UbuOQT8P/RJbka8etf7wbxdHQNAY+2cC
vDf8J3X8VI+pwMqv6wgTVy17venMZJa4I4ikXD/MRyWV1XbTG0mBXk/7AZk7Rexk
KTvL/U1kWiez6+8XXLye+k2JNM6v7eej8xMrqEcO0ZArh/DsLoIn1y8p8qjBI7+m
aE7lhstDiD0z8mwRRLKFLN2IH5rAFaZZUvj5ERJaoYUKdn4c+RcQVei2YOl4T0FU
LWND3YLoH8naqJXkaOKEN4UfJINCwxhe5Ke9wyfLWLUO7NamRkWD2T7CJ0xocnD1
sjAzlVGNgaFDRflfIF4QhBx1Ddl6wwhJfw+d08bjqblSq8aXDkmFA7HeunSFKkdn
oIEOEgyj+veuOMRJC5pnBJ9vV+7qRdDKQWaCKotynt4sWJDGQ9kWGWm74SsNaduN
TPMyr9kNmGsfR69Q2Zq/FLcLX/j8ESxU+HYUB4vaARw2xEOu2xwDDv6jt0j3Vqsg
x7rWv4S/Eh18FDNDkVRChiNoOIilLYLL6c38uMf1pnItBuxP3uhgY6COm59kVaRh
nyGTYCDYD2TK+fI9o89F1297uDCwEJ62U0Q7iTDp5QuXCoxkPfv8/kX6lS6T3y9G
M9mqIoLbIQ1EDntFv7/t6fUTS2+46uCrdZWbQ5RjYXdrzjij02nDmJAm2BngnZvd
kamH0Y/n11lCvo1oQxM+
=uSzz
-----END PGP SIGNATURE-----
**************************************************************/
#ifndef OPENTXS_CORE_SCRIPT_OTAGENT_HPP
#define OPENTXS_CORE_SCRIPT_OTAGENT_HPP
#include <opentxs/core/String.hpp>
#include <map>
namespace opentxs
{
class Account;
class OTAgent;
class Identifier;
class OTParty;
class OTPartyAccount;
class Nym;
class OTSmartContract;
typedef std::map<std::string, Nym*> mapOfNyms;
// Agent is always either the Owner Nym acting in his own interests,
// or is an employee Nym acting actively in a role on behalf of an Entity formed
// by contract
// or is a voting group acting passively in a role on behalf of an Entity formed
// by contract
//
// QUESTION: What about having an agent being one Nym representing another?
// NO: because then he needs a ROLE in order to act as agent. In which case, the
// other
// nym should just create an entity he controls, and make the first nym an agent
// for that entity.
//
class OTAgent
{
private:
bool m_bNymRepresentsSelf; // Whether this agent represents himself (a nym)
// or whether he represents an entity of some
// sort.
bool m_bIsAnIndividual; // Whether this agent is a voting group or Nym
// (whether Nym acting for himself or for some
// entity.)
// If agent is active (has a nym), here is the sometimes-available pointer
// to said Agent Nym.
Nym* m_pNym; // this pointer is not owned by this object, and is
// here for convenience only.
// someday may add a "role" pointer here.
OTParty* m_pForParty; // The agent probably has a pointer to the party it
// acts on behalf of.
/*
<Agent type=“group”// could be “nym”, or “role”, or “group”.
Nym_id=“” // In case of “nym”, this is the Nym’s ID. If “role”, this
is NymID of employee in role.
Role_id=“” // In case of “role”, this is the Role’s ID.
Entity_id=“this” // same as OwnerID if ever used. Should remove.
Group_Name=“class_A” // “class A shareholders” are the voting group
that controls this agent.
*/
String m_strName; // agent name (accessible within script language.)
// info about agent.
//
String m_strNymID; // If agent is a Nym, then this is the NymID of that
// Nym (whether that Nym is owner or not.)
// If agent is a group (IsAGroup()) then this will be blank. This is
// different than the
// Nym stored in OTParty, which if present ALWAYS refers to the OWNER Nym
// (Though this Nym
// MAY ALSO be the owner, that fact is purely incidental here AND this NymID
// could be blank.)
String m_strRoleID; // If agent is Nym working in a role on behalf of an
// entity, then this is its RoleID in Entity.
String m_strGroupName; // If agent is a voting group in an Entity, this is
// group's Name (inside Entity.)
public:
OTAgent();
OTAgent(std::string str_agent_name, Nym& theNym,
bool bNymRepresentsSelf = true);
/*IF false, then: ENTITY and ROLE parameters go here.*/
//
// Someday another constructor here like the above, for
// instantiating with an Entity/Group instead of with a Nym.
OTAgent(bool bNymRepresentsSelf, bool bIsAnIndividual,
const String& strName, const String& strNymID,
const String& strRoleID, const String& strGroupName);
virtual ~OTAgent();
void Serialize(String& strAppend) const;
// For pointers I don't own, but store for convenience.
// This clears them once we're done processing, so I don't
// end up stuck with bad pointers on the next go-around.
//
void ClearTemporaryPointers()
{
m_pNym = nullptr;
} /* Someday clear entity/role ptr here? And do NOT
clear party ptr here (since it's not temporary.) */
// NOTE: Current iteration, these functions ASSUME that m_pNym is loaded.
// They will definitely fail if you haven't already loaded the Nym.
//
bool VerifyIssuedNumber(const int64_t& lNumber, const String& strNotaryID);
bool VerifyTransactionNumber(const int64_t& lNumber,
const String& strNotaryID);
bool RemoveIssuedNumber(const int64_t& lNumber, const String& strNotaryID,
bool bSave = false, Nym* pSignerNym = nullptr);
bool RemoveTransactionNumber(const int64_t& lNumber,
const String& strNotaryID, Nym& SIGNER_NYM,
bool bSave = true);
bool HarvestTransactionNumber(
const int64_t& lNumber, const String& strNotaryID,
bool bSave = false, // Each agent's nym is used if pSignerNym is
// nullptr,
// whereas the server
Nym* pSignerNym = nullptr); // uses this optional arg to
// substitute serverNym as signer.
bool ReserveOpeningTransNum(const String& strNotaryID);
bool ReserveClosingTransNum(const String& strNotaryID,
OTPartyAccount& thePartyAcct);
EXPORT bool SignContract(Contract& theInput) const;
// Verify that this agent somehow has legitimate agency over this account.
// (According to the account.)
//
bool VerifyAgencyOfAccount(const Account& theAccount) const;
bool VerifySignature(const Contract& theContract) const; // Have the agent
// try
// to
// verify his own signature
// against any contract.
void SetParty(OTParty& theOwnerParty); // This happens when the agent is
// added to the party.
void SetNymPointer(Nym& theNym)
{
m_pNym = &theNym;
}
EXPORT bool IsValidSigner(Nym& theNym);
EXPORT bool IsValidSignerID(const Identifier& theNymID);
bool IsAuthorizingAgentForParty(); // true/false whether THIS agent is the
// authorizing agent for his party.
int32_t GetCountAuthorizedAccts(); // The number of accounts, owned by this
// agent's party, that this agent is the
// authorized agent FOR.
// Only one of these can be true:
// (I wrestle with making these 2 calls private, since technically it should
// be irrelevant to the external.)
//
bool DoesRepresentHimself() const; // If the agent is a Nym acting for
// himself, this will be true. Otherwise,
// if agent is a Nym acting in a role for
// an entity, or if agent is a voting
// group acting for the entity to which
// it belongs, either way, this will be
// false.
// ** OR **
bool DoesRepresentAnEntity() const; // Whether the agent is a voting group
// acting for an entity, or is a Nym
// acting in a Role for an entity, this
// will be true either way. (Otherwise,
// if agent is a Nym acting for himself,
// then this will be false.)
// Only one of these can be true:
// - Agent is either a Nym acting for himself or some entity,
// - or agent is a group acting for some entity.
EXPORT bool IsAnIndividual() const; // Agent is an individual Nym. (Meaning
// either he IS ALSO the party and thus
// represents himself, OR he is an agent
// for an entity who is the party, and
// he's acting in a role for that
// entity.) If agent were a group, this
// would be false.
// ** OR **
bool IsAGroup() const; // OR: Agent is a voting group, which cannot take
// proactive or instant action, but only passive and
// delayed. Entity-ONLY. (A voting group cannot
// decide on behalf of individual, but only on behalf
// of the entity it belongs to.)
// FYI: A Nym cannot act as agent for another Nym.
// Nor can a Group act as agent for a Nym.
//
// If you want those things, then the owner Nym should form an Entity, and
// then groups and nyms can act as agents for that entity. You cannot have
// an agent without an entity formed by contract, since you otherwise have
// no agency agreement.
// For when the agent is an individual:
//
EXPORT bool GetNymID(Identifier& theOutput) const; // If IsIndividual(),
// then this is his own
// personal NymID,
// (whether he DoesRepresentHimself() or DoesRepresentAnEntity()
// -- either way). Otherwise if IsGroup(), this returns false.
bool GetRoleID(Identifier& theOutput) const; // IF IsIndividual() AND
// DoesRepresentAnEntity(),
// then this is his RoleID
// within that Entity.
// Otherwise, if IsGroup() or
// DoesRepresentHimself(),
// then this returns false.
// Notice if the agent is a voting group, then it has no signer. (Instead it
// will have an election.)
// That is why certain agents are unacceptable in certain scripts.
// There is an "active" agent who has a signerID, but there is also a
// "passive" agent who only has
// a group name, and acts based on notifications and replies in the
// long-term, versus being immediately
// able to act as part of the operation of a script.
// Basically if !IsIndividual(), then GetSignerID() will fail and thus
// anything needing it as part of the
// script would also therefore be impossible.
//
bool GetSignerID(Identifier& theOutput) const;
// If IsIndividual() and DoesRepresentAnEntity() then this returns
// GetRoleID().
// else if Individual() and DoesRepresentHimself() then this returns
// GetNymID().
// else (if IsGroup()) then return false;
// For when the agent DoesRepresentAnEntity():
//
// Whether this agent IsGroup() (meaning he is a voting group that
// DoesRepresentAnEntity()),
// OR whether this agent is an individual acting in a role for an entity
// (IsIndividual() && DoesRepresentAnEntity())
// ...EITHER WAY, the agent DoesRepresentAnEntity(), and this function
// returns the ID of that Entity.
//
// Otherwise, if the agent DoesRepresentHimself(), then this returns false.
// I'm debating making this function private along with DoesRepresentHimself
// / DoesRepresentAnEntity().
//
bool GetEntityID(Identifier& theOutput) const; // IF represents an entity,
// this is its ID. Else
// fail.
EXPORT const String& GetName()
{
return m_strName;
} // agent's name as used in a script.
// For when the agent is a voting group:
//
bool GetGroupName(String& strGroupName); // The GroupName group will be
// found in the EntityID entity.
//
// If !IsGroup() aka IsIndividual(), then this will return false.
//
// bool DoesRepresentHimself();
// bool DoesRepresentAnEntity();
//
// bool IsIndividual();
// bool IsGroup();
// PARTY is either a NYM or an ENTITY. This returns ID for that Nym or
// Entity.
//
// If DoesRepresentHimself() then return GetNymID()
// else (thus DoesRepresentAnEntity()) so return GetEntityID()
//
bool GetPartyID(Identifier& theOutput) const;
OTParty* GetParty() const
{
return m_pForParty;
}
// IDEA: Put a Nym in the Nyms folder for each entity. While it may
// not have a public key in the pubkey folder, or embedded within it,
// it can still have information about the entity or role related to it,
// which becomes accessible when that Nym is loaded based on the Entity ID.
// This also makes sure that Nyms and Entities don't ever share IDs, so the
// IDs become more and more interchangeable.
// Often we endeavor to avoid loading the same Nym twice, and a higher-level
// function
// will ask an OTParty for a list of all the Nym pointers that it already
// has,
// so they can be checked for various things if they are already loaded
// (when they are needed)
// without having to load them again in order to check those things, purely
// out of blindness
// to the fact that they had infact already been loaded and were floating
// around in memory somewhere.
//
void RetrieveNymPointer(mapOfNyms& map_Nyms_Already_Loaded);
Nym* LoadNym(Nym& theServerNym);
bool DropFinalReceiptToNymbox(OTSmartContract& theSmartContract,
const int64_t& lNewTransactionNumber,
const String& strOrigCronItem,
String* pstrNote = nullptr,
String* pstrAttachment = nullptr,
Nym* pActualNym = nullptr);
bool DropFinalReceiptToInbox(
mapOfNyms* pNymMap, const String& strNotaryID, Nym& theServerNym,
OTSmartContract& theSmartContract, const Identifier& theAccountID,
const int64_t& lNewTransactionNumber, const int64_t& lClosingNumber,
const String& strOrigCronItem, String* pstrNote = nullptr,
String* pstrAttachment = nullptr);
bool DropServerNoticeToNymbox(
bool bSuccessMsg, // the notice can be "acknowledgment" or "rejection"
Nym& theServerNym, const Identifier& theNotaryID,
const int64_t& lNewTransactionNumber, const int64_t& lInReferenceTo,
const String& strReference, String* pstrNote = nullptr,
String* pstrAttachment = nullptr, Nym* pActualNym = nullptr);
};
} // namespace opentxs
#endif // OPENTXS_CORE_SCRIPT_OTAGENT_HPP
| 44.346983 | 80 | 0.613646 | [
"object"
] |
5bac281be2abcf6758a05ca8a30947dfa852eb0a | 1,546 | cpp | C++ | codes/usaco/promote_plat.cpp | chessbot108/solved-problems | 0945be829a8ea9f0d5896c89331460d70d076691 | [
"MIT"
] | 2 | 2021-03-07T03:34:02.000Z | 2021-03-09T01:22:21.000Z | codes/usaco/promote_plat.cpp | chessbot108/solved-problems | 0945be829a8ea9f0d5896c89331460d70d076691 | [
"MIT"
] | 1 | 2021-03-27T15:01:23.000Z | 2021-03-27T15:55:34.000Z | codes/usaco/promote_plat.cpp | chessbot108/solved-problems | 0945be829a8ea9f0d5896c89331460d70d076691 | [
"MIT"
] | 1 | 2021-03-27T05:02:33.000Z | 2021-03-27T05:02:33.000Z | #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <sstream>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#define max_v 1100000
#define int_max 0x3f3f3f3f
#define cont continue
#define byte_max 0x3f
#define pow_2(n) (1 << n)
#define lsb(n) ((n) & (-(n)))
using namespace std;
void setIO(const string& file_name){
freopen((file_name+".in").c_str(), "r", stdin);
freopen((file_name+".out").c_str(), "w+", stdout);
}
int rate[max_v];
int lab = 0, n;
list<int> arr[max_v];
int srt[max_v], BIT[max_v];
int L[max_v], R[max_v];
int get_ind(int key){
return lower_bound(srt + 1, srt + n + 1, key) - &srt[0];
}
int S(int i){
if(!i) return 0;
return BIT[i] + S(i - lsb(i));
}
void U(int i, int val){
if(i > n) return;
BIT[i] += val;
U(i + lsb(i), val);
}
void dfs(int cur){
L[cur] = S(get_ind(rate[cur]));
for(int ch : arr[cur]){
dfs(ch);
}
R[cur] = S(get_ind(rate[cur]));
U(get_ind(rate[cur]), 1);
}
int main(){
setIO("promote");
scanf("%d", &n);
for(int i = 1; i<=n; i++){
scanf("%d", &rate[i]);
rate[i] = (int)1e9 - rate[i];
srt[i] = rate[i];
}
sort(srt + 1, srt + n + 1);
for(int i = 2; i<=n; i++){
int par;
scanf("%d", &par);
arr[par].push_back(i);
}
dfs(1);
for(int i = 1; i<=n; i++){
printf("%d\n", R[i] - L[i]);
}
return 0;
}
| 16.623656 | 59 | 0.574386 | [
"vector"
] |
5bace6e2b444c85277eb563ff4e649a8aff9c9a1 | 34,982 | hpp | C++ | Libraries/D3D12RaytracingFallback/Include/D3D12RaytracingPrototypeHelpers.hpp | dblloyd/DirectX-Graphics-Samples | 6334fc5cd7b41701cdf15eba0f84547de2e94215 | [
"MIT"
] | null | null | null | Libraries/D3D12RaytracingFallback/Include/D3D12RaytracingPrototypeHelpers.hpp | dblloyd/DirectX-Graphics-Samples | 6334fc5cd7b41701cdf15eba0f84547de2e94215 | [
"MIT"
] | null | null | null | Libraries/D3D12RaytracingFallback/Include/D3D12RaytracingPrototypeHelpers.hpp | dblloyd/DirectX-Graphics-Samples | 6334fc5cd7b41701cdf15eba0f84547de2e94215 | [
"MIT"
] | null | null | null | #pragma once
#include <list>
#include <vector>
#include <atlbase.h>
//=============================================================================================================================
// D3D12 Raytracing prototype state object creation helpers
//
// Prototype Helper classes for creating new style state objects out of an arbitrary set of subobjects.
// Uses STL - clean implmentation could be made if needed.
//
// Start by instantiating CD3D12_STATE_OBJECT_DESC (see it's public methods).
// One of its methods is CreateSubobject(), which has a comment showing a couple of options for defining
// subobjects using the helper classes for each subobject (CD3D12_DXIL_LIBRARY_SUBOBJECT etc.).
// The subobject helpers each have methods specific to the subobject for configuring it's contents.
//
// At the end of the file is a large comment block showing 3 example state object creations.
//
//=============================================================================================================================
class CD3D12_STATE_OBJECT_DESC
{
public:
CD3D12_STATE_OBJECT_DESC()
{
Init(D3D12_STATE_OBJECT_TYPE_COLLECTION);
}
CD3D12_STATE_OBJECT_DESC(D3D12_STATE_OBJECT_TYPE Type)
{
Init(Type);
}
void SetStateObjectType(D3D12_STATE_OBJECT_TYPE Type) { m_Desc.Type = Type; }
operator const D3D12_STATE_OBJECT_DESC&()
{
m_RepointedAssociations.clear();
m_SubobjectArray.clear();
m_SubobjectArray.reserve(m_Desc.NumSubobjects);
// Flatten subobjects into an array (each flattened subobject still has a member that's a pointer to it's desc that's not flattened)
for (std::list<SUBOBJECT_WRAPPER>::iterator Iter = m_SubobjectList.begin();
Iter != m_SubobjectList.end(); Iter++)
{
m_SubobjectArray.push_back(*Iter);
Iter->pSubobjectArrayLocation = &m_SubobjectArray.back(); // Store new location in array so we can redirect pointers contained in subobjects
}
// For subobjects with pointer fields, create a new copy of those subobject definitions with fixed pointers
for (UINT i = 0; i < m_Desc.NumSubobjects; i++)
{
if (m_SubobjectArray[i].Type == D3D12_STATE_SUBOBJECT_TYPE_SUBOBJECT_TO_EXPORTS_ASSOCIATION)
{
const D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION* pOriginalSubobjectAssociation = (const D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION*)m_SubobjectArray[i].pDesc;
D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION Repointed = *pOriginalSubobjectAssociation;
const SUBOBJECT_WRAPPER* pWrapper = static_cast<const SUBOBJECT_WRAPPER*>(pOriginalSubobjectAssociation->pSubobjectToAssociate);
Repointed.pSubobjectToAssociate = pWrapper->pSubobjectArrayLocation;
m_RepointedAssociations.push_back(Repointed);
m_SubobjectArray[i].pDesc = &m_RepointedAssociations.back();
}
}
m_Desc.pSubobjects = m_SubobjectArray.data();
return m_Desc;
}
operator const D3D12_STATE_OBJECT_DESC*()
{
return &(const D3D12_STATE_OBJECT_DESC&)(*this);
}
// CreateSubobject creates a sububject helper (e.g. CD3D12_HIT_GROUP_SUBOBJECT) whose lifetime is owned by this class.
// e.g.
//
// CD3D12_STATE_OBJECT_DESC Collection1(D3D12_STATE_OBJECT_TYPE_COLLECTION);
// auto Lib0 = Collection1.CreateSubobject<CD3D12_DXIL_LIBRARY_SUBOBJECT>();
// Lib0->SetDXILLibrary(&pMyAppDxilLibs[0]);
// Lib0->DefineExport(L"rayGenShader0"); // in practice these export listings might be data/engine driven
// etc.
//
// Alternatively, users can instantiate sububject helpers explicitly, such as via local variables instead,
// passing the state object desc that should point to it into the helper constructor (or call mySubobjectHelper.AddToStateObject(Collection1)).
// In this alternative scenario, the user must keep the subobject alive as long as the state object it is associated with
// is alive, else it's pointer references will be stale.
// e.g.
//
// CD3D12_STATE_OBJECT_DESC RaytracingState2(D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE);
// CD3D12_DXIL_LIBRARY_SUBOBJECT LibA(RaytracingState2);
// LibA.SetDXILLibrary(&pMyAppDxilLibs[4]); // not manually specifying exports - meaning all exports in the libraries are exported
// etc.
template<typename T>
T* CreateSubobject()
{
T* pSubobject = new T(*this);
m_OwnedSubobjectHelpers.emplace_back(pSubobject);
return pSubobject;
}
private:
D3D12_STATE_SUBOBJECT* TrackSubobject(D3D12_STATE_SUBOBJECT_TYPE Type, void* pDesc)
{
SUBOBJECT_WRAPPER Subobject;
Subobject.pSubobjectArrayLocation = nullptr;
Subobject.Type = Type;
Subobject.pDesc = pDesc;
m_SubobjectList.push_back(Subobject);
m_Desc.NumSubobjects++;
return &m_SubobjectList.back();
}
void Init(D3D12_STATE_OBJECT_TYPE Type)
{
SetStateObjectType(Type);
m_Desc.pSubobjects = nullptr;
m_Desc.NumSubobjects = 0;
m_SubobjectList.clear();
m_SubobjectArray.clear();
m_RepointedAssociations.clear();
}
typedef struct SUBOBJECT_WRAPPER : public D3D12_STATE_SUBOBJECT
{
D3D12_STATE_SUBOBJECT* pSubobjectArrayLocation; // new location when flattened into array for repointing pointers in subobjects
} SUBOBJECT_WRAPPER;
D3D12_STATE_OBJECT_DESC m_Desc;
std::list<SUBOBJECT_WRAPPER> m_SubobjectList; // Pointers to list nodes handed out so
// these can be edited live
std::vector<D3D12_STATE_SUBOBJECT> m_SubobjectArray; // Built at the end, copying list contents
std::list<D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION> m_RepointedAssociations; // subobject type that contains pointers to other subobjects, repointed to flattened array
class StringContainer
{
public:
LPCWSTR LocalCopy(LPCWSTR string, bool bSingleString = false)
{
if (string)
{
if (bSingleString)
{
m_Strings.clear();
m_Strings.push_back(string);
}
else
{
m_Strings.push_back(string);
}
return m_Strings.back().c_str();
}
else
{
return nullptr;
}
}
void clear() { m_Strings.clear(); }
private:
std::list<std::wstring> m_Strings;
};
class SUBOBJECT_HELPER_BASE
{
public:
SUBOBJECT_HELPER_BASE() { Init(); };
virtual ~SUBOBJECT_HELPER_BASE() {};
virtual D3D12_STATE_SUBOBJECT_TYPE Type() = 0;
void AddToStateObject(CD3D12_STATE_OBJECT_DESC& ContainingStateObject)
{
m_pSubobject = ContainingStateObject.TrackSubobject(Type(), Data());
}
protected:
virtual void* Data() = 0;
void Init() { m_pSubobject = nullptr; }
D3D12_STATE_SUBOBJECT* m_pSubobject;
};
class OWNED_HELPER
{
public:
OWNED_HELPER(const SUBOBJECT_HELPER_BASE* pHelper) { m_pHelper = pHelper; }
~OWNED_HELPER() { delete m_pHelper; }
const SUBOBJECT_HELPER_BASE* m_pHelper;
};
std::list<OWNED_HELPER> m_OwnedSubobjectHelpers;
friend class CD3D12_DXIL_LIBRARY_SUBOBJECT;
friend class CD3D12_EXISTING_COLLECTION_SUBOBJECT;
friend class CD3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT;
friend class CD3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION;
friend class CD3D12_HIT_GROUP_SUBOBJECT;
friend class CD3D12_RAYTRACING_SHADER_CONFIG_SUBOBJECT;
friend class CD3D12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT;
friend class CD3D12_ROOT_SIGNATURE_SUBOBJECT;
friend class CD3D12_LOCAL_ROOT_SIGNATURE_SUBOBJECT;
};
class CD3D12_DXIL_LIBRARY_SUBOBJECT : public CD3D12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE
{
public:
CD3D12_DXIL_LIBRARY_SUBOBJECT()
{
Init();
}
CD3D12_DXIL_LIBRARY_SUBOBJECT(CD3D12_STATE_OBJECT_DESC& ContainingStateObject)
{
Init();
AddToStateObject(ContainingStateObject);
}
void SetDXILLibrary(D3D12_SHADER_BYTECODE*pCode) { static const D3D12_SHADER_BYTECODE Default = {}; m_Desc.DXILLibrary = pCode ? *pCode : Default; }
void DefineExport(LPCWSTR Name, LPCWSTR ExportToRename = nullptr, D3D12_EXPORT_FLAGS Flags = D3D12_EXPORT_FLAG_NONE)
{
D3D12_EXPORT_DESC Export;
Export.Name = m_Strings.LocalCopy(Name);
Export.ExportToRename = m_Strings.LocalCopy(ExportToRename);
Export.Flags = Flags;
m_Exports.push_back(Export);
m_Desc.pExports = m_Exports.data();
m_Desc.NumExports = (UINT)m_Exports.size();
}
D3D12_STATE_SUBOBJECT_TYPE Type() { return D3D12_STATE_SUBOBJECT_TYPE_DXIL_LIBRARY; }
operator const D3D12_STATE_SUBOBJECT&() const { return *m_pSubobject; }
operator const D3D12_DXIL_LIBRARY_DESC&() const { return m_Desc; }
private:
void Init()
{
SUBOBJECT_HELPER_BASE::Init();
m_Desc = {};
m_Strings.clear();
m_Exports.clear();
}
void* Data() { return &m_Desc; }
D3D12_DXIL_LIBRARY_DESC m_Desc;
CD3D12_STATE_OBJECT_DESC::StringContainer m_Strings;
std::vector<D3D12_EXPORT_DESC> m_Exports;
};
class CD3D12_EXISTING_COLLECTION_SUBOBJECT : public CD3D12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE
{
public:
CD3D12_EXISTING_COLLECTION_SUBOBJECT()
{
Init();
}
CD3D12_EXISTING_COLLECTION_SUBOBJECT(CD3D12_STATE_OBJECT_DESC& ContainingStateObject)
{
Init();
AddToStateObject(ContainingStateObject);
}
void SetExistingCollection(ID3D12StateObjectPrototype*pExistingCollection) { m_Desc.pExistingCollection = pExistingCollection; m_CollectionRef = pExistingCollection; }
void DefineExport(LPCWSTR Name, LPCWSTR ExportToRename = nullptr, D3D12_EXPORT_FLAGS Flags = D3D12_EXPORT_FLAG_NONE)
{
D3D12_EXPORT_DESC Export;
Export.Name = m_Strings.LocalCopy(Name);
Export.ExportToRename = m_Strings.LocalCopy(ExportToRename);
Export.Flags = Flags;
m_Exports.push_back(Export);
m_Desc.pExports = m_Exports.data();
m_Desc.NumExports = (UINT)m_Exports.size();
}
D3D12_STATE_SUBOBJECT_TYPE Type() { return D3D12_STATE_SUBOBJECT_TYPE_EXISTING_COLLECTION; }
operator const D3D12_STATE_SUBOBJECT&() const { return *m_pSubobject; }
operator const D3D12_EXISTING_COLLECTION_DESC&() const { return m_Desc; }
private:
void Init()
{
SUBOBJECT_HELPER_BASE::Init();
m_Desc = {};
m_CollectionRef = nullptr;
m_Strings.clear();
m_Exports.clear();
}
void* Data() { return &m_Desc; }
D3D12_EXISTING_COLLECTION_DESC m_Desc;
CComPtr<ID3D12StateObjectPrototype> m_CollectionRef;
CD3D12_STATE_OBJECT_DESC::StringContainer m_Strings;
std::vector<D3D12_EXPORT_DESC> m_Exports;
};
class CD3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT : public CD3D12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE
{
public:
CD3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT()
{
Init();
}
CD3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT(CD3D12_STATE_OBJECT_DESC& ContainingStateObject)
{
Init();
AddToStateObject(ContainingStateObject);
}
void SetSubobjectToAssociate(const D3D12_STATE_SUBOBJECT& SubobjectToAssociate) { m_Desc.pSubobjectToAssociate = &SubobjectToAssociate; }
void AddExport(LPCWSTR Export)
{
m_Desc.NumExports++;
m_Exports.push_back(m_Strings.LocalCopy(Export));
m_Desc.pExports = m_Exports.data();
}
D3D12_STATE_SUBOBJECT_TYPE Type() { return D3D12_STATE_SUBOBJECT_TYPE_SUBOBJECT_TO_EXPORTS_ASSOCIATION; }
operator const D3D12_STATE_SUBOBJECT&() const { return *m_pSubobject; }
operator const D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION&() const { return m_Desc; }
private:
void Init()
{
SUBOBJECT_HELPER_BASE::Init();
m_Desc = {};
m_Strings.clear();
m_Exports.clear();
}
void* Data() { return &m_Desc; }
D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION m_Desc;
CD3D12_STATE_OBJECT_DESC::StringContainer m_Strings;
std::vector<LPCWSTR> m_Exports;
};
class CD3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION : public CD3D12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE
{
public:
CD3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION()
{
Init();
}
CD3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION(CD3D12_STATE_OBJECT_DESC& ContainingStateObject)
{
Init();
AddToStateObject(ContainingStateObject);
}
void SetSubobjectNameAssociate(LPCWSTR SubobjectToAssociate) { m_Desc.SubobjectToAssociate = m_SubobjectName.LocalCopy(SubobjectToAssociate, true); }
void AddExport(LPCWSTR Export)
{
m_Desc.NumExports++;
m_Exports.push_back(m_Strings.LocalCopy(Export));
m_Desc.pExports = m_Exports.data();
}
D3D12_STATE_SUBOBJECT_TYPE Type() { return D3D12_STATE_SUBOBJECT_TYPE_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION; }
operator const D3D12_STATE_SUBOBJECT&() const { return *m_pSubobject; }
operator const D3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION&() const { return m_Desc; }
private:
void Init()
{
SUBOBJECT_HELPER_BASE::Init();
m_Desc = {};
m_Strings.clear();
m_SubobjectName.clear();
m_Exports.clear();
}
void* Data() { return &m_Desc; }
D3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION m_Desc;
CD3D12_STATE_OBJECT_DESC::StringContainer m_Strings;
CD3D12_STATE_OBJECT_DESC::StringContainer m_SubobjectName;
std::vector<LPCWSTR> m_Exports;
};
class CD3D12_HIT_GROUP_SUBOBJECT : public CD3D12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE
{
public:
CD3D12_HIT_GROUP_SUBOBJECT()
{
Init();
}
CD3D12_HIT_GROUP_SUBOBJECT(CD3D12_STATE_OBJECT_DESC& ContainingStateObject)
{
Init();
AddToStateObject(ContainingStateObject);
}
void SetHitGroupExport(LPCWSTR exportName) { m_Desc.HitGroupExport = m_Strings[0].LocalCopy(exportName, true); }
void SetAnyHitShaderImport(LPCWSTR importName) { m_Desc.AnyHitShaderImport = m_Strings[1].LocalCopy(importName, true); }
void SetClosestHitShaderImport(LPCWSTR importName) { m_Desc.ClosestHitShaderImport = m_Strings[2].LocalCopy(importName, true); }
void SetIntersectionShaderImport(LPCWSTR importName) { m_Desc.IntersectionShaderImport = m_Strings[3].LocalCopy(importName, true); }
D3D12_STATE_SUBOBJECT_TYPE Type() { return D3D12_STATE_SUBOBJECT_TYPE_HIT_GROUP; }
operator const D3D12_STATE_SUBOBJECT&() const { return *m_pSubobject; }
operator const D3D12_HIT_GROUP_DESC&() const { return m_Desc; }
private:
void Init()
{
SUBOBJECT_HELPER_BASE::Init();
m_Desc = {};
for (UINT i = 0; i < m_NumStrings; i++)
{
m_Strings[i].clear();
}
}
void* Data() { return &m_Desc; }
D3D12_HIT_GROUP_DESC m_Desc;
static const UINT m_NumStrings = 4;
CD3D12_STATE_OBJECT_DESC::StringContainer m_Strings[m_NumStrings]; // one string for every entrypoint name
};
class CD3D12_RAYTRACING_SHADER_CONFIG_SUBOBJECT : public CD3D12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE
{
public:
CD3D12_RAYTRACING_SHADER_CONFIG_SUBOBJECT()
{
Init();
}
CD3D12_RAYTRACING_SHADER_CONFIG_SUBOBJECT(CD3D12_STATE_OBJECT_DESC& ContainingStateObject)
{
Init();
AddToStateObject(ContainingStateObject);
}
void Config(UINT MaxPayloadSizeInBytes, UINT MaxAttributeSizeInBytes)
{
m_Desc.MaxPayloadSizeInBytes = MaxPayloadSizeInBytes;
m_Desc.MaxAttributeSizeInBytes = MaxAttributeSizeInBytes;
}
D3D12_STATE_SUBOBJECT_TYPE Type() { return D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_SHADER_CONFIG; }
operator const D3D12_STATE_SUBOBJECT&() const { return *m_pSubobject; }
operator const D3D12_RAYTRACING_SHADER_CONFIG&() const { return m_Desc; }
private:
void Init()
{
SUBOBJECT_HELPER_BASE::Init();
m_Desc = {};
}
void* Data() { return &m_Desc; }
D3D12_RAYTRACING_SHADER_CONFIG m_Desc;
};
class CD3D12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT : public CD3D12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE
{
public:
CD3D12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT()
{
Init();
}
CD3D12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT(CD3D12_STATE_OBJECT_DESC& ContainingStateObject)
{
Init();
AddToStateObject(ContainingStateObject);
}
void Config(UINT MaxTraceRecursionDepth)
{
m_Desc.MaxTraceRecursionDepth = MaxTraceRecursionDepth;
}
D3D12_STATE_SUBOBJECT_TYPE Type() { return D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_PIPELINE_CONFIG; }
operator const D3D12_STATE_SUBOBJECT&() const { return *m_pSubobject; }
operator const D3D12_RAYTRACING_PIPELINE_CONFIG&() const { return m_Desc; }
private:
void Init()
{
SUBOBJECT_HELPER_BASE::Init();
m_Desc = {};
}
void* Data() { return &m_Desc; }
D3D12_RAYTRACING_PIPELINE_CONFIG m_Desc;
};
class CD3D12_ROOT_SIGNATURE_SUBOBJECT : public CD3D12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE
{
public:
CD3D12_ROOT_SIGNATURE_SUBOBJECT()
{
Init();
}
CD3D12_ROOT_SIGNATURE_SUBOBJECT(CD3D12_STATE_OBJECT_DESC& ContainingStateObject)
{
Init();
AddToStateObject(ContainingStateObject);
}
void SetRootSignature(ID3D12RootSignature* pRootSig)
{
m_pRootSig = pRootSig;
}
D3D12_STATE_SUBOBJECT_TYPE Type() { return D3D12_STATE_SUBOBJECT_TYPE_ROOT_SIGNATURE; }
operator const D3D12_STATE_SUBOBJECT&() const { return *m_pSubobject; }
operator ID3D12RootSignature*() const { return m_pRootSig; }
private:
void Init()
{
SUBOBJECT_HELPER_BASE::Init();
m_pRootSig = nullptr;
}
void* Data() { return &m_pRootSig; }
CComPtr<ID3D12RootSignature> m_pRootSig;
};
class CD3D12_LOCAL_ROOT_SIGNATURE_SUBOBJECT : public CD3D12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE
{
public:
CD3D12_LOCAL_ROOT_SIGNATURE_SUBOBJECT()
{
Init();
}
CD3D12_LOCAL_ROOT_SIGNATURE_SUBOBJECT(CD3D12_STATE_OBJECT_DESC& ContainingStateObject)
{
Init();
AddToStateObject(ContainingStateObject);
}
void SetRootSignature(ID3D12RootSignature* pRootSig)
{
m_pRootSig = pRootSig;
}
D3D12_STATE_SUBOBJECT_TYPE Type() { return D3D12_STATE_SUBOBJECT_TYPE_LOCAL_ROOT_SIGNATURE; }
operator const D3D12_STATE_SUBOBJECT&() const { return *m_pSubobject; }
operator ID3D12RootSignature*() const { return m_pRootSig; }
private:
void Init()
{
SUBOBJECT_HELPER_BASE::Init();
m_pRootSig = nullptr;
}
void* Data() { return &m_pRootSig; }
CComPtr<ID3D12RootSignature> m_pRootSig;
};
//=============================================================================================================================
// Some dummy examples creating various state objects
//
// At the start is a bunch of init code, then 3 examples of creating state objects.
// As these examples were authored before state object validation has been authored in the D3D runtime,
// take these as examples of using the subobject helpers only. They may not be creating valid state objects (yet),
// due to missing some configuration or whatnot. Until validation is in place to help correctly build state objects,
// other samples that actually execute and the raytracing spec are better guides.
//=============================================================================================================================
//InitDeviceAndContext(&m_Ctx);
//CComPtr<ID3D12DeviceRaytracingPrototype> spFPDevice = m_Ctx.spFPDevice;
//CComPtr<ID3D12Device2> spDevice = m_Ctx.spDevice;
//CComPtr<ID3D12GraphicsCommandList1> spCL = m_Ctx.spCL;
//CComPtr<ID3D12CommandListRaytracingPrototype> spFPCL = m_Ctx.spFPCL;
//D3D12_SHADER_BYTECODE pMyAppDxilLibs[8] = {
// CD3DX12_SHADER_BYTECODE(g_Lib1,sizeof(g_Lib1)), // TODO, make actual different libraries with the appropriate content
// CD3DX12_SHADER_BYTECODE(g_Lib1,sizeof(g_Lib1)),
// CD3DX12_SHADER_BYTECODE(g_Lib1,sizeof(g_Lib1)),
// CD3DX12_SHADER_BYTECODE(g_Lib1,sizeof(g_Lib1)),
// CD3DX12_SHADER_BYTECODE(g_Lib1,sizeof(g_Lib1)),
// CD3DX12_SHADER_BYTECODE(g_Lib1,sizeof(g_Lib1)),
// CD3DX12_SHADER_BYTECODE(g_Lib1,sizeof(g_Lib1)),
// CD3DX12_SHADER_BYTECODE(g_Lib1,sizeof(g_Lib1))
//};
//CComPtr<ID3D12RootSignature> pMyAppRootSigs[4] = {}; // in practice these would not be null
//for (UINT i = 0; i < _countof(pMyAppRootSigs); i++)
//{
// // Make some dummy root signatures
// CD3DX12_DESCRIPTOR_RANGE dr[4];
// dr[0].Init(D3D12_DESCRIPTOR_RANGE_TYPE_CBV, 1, 0);
// dr[1].Init(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 1, 0);
// dr[2].Init(D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 1, 0);
// dr[3].Init(D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, 1, 0);
// CD3DX12_ROOT_PARAMETER rp[5];
// rp[0].InitAsDescriptorTable(3, dr);
// rp[1].InitAsDescriptorTable(1, &dr[3]);
// rp[2].InitAsConstantBufferView(2);
// rp[3].InitAsUnorderedAccessView(2);
// rp[4].InitAsShaderResourceView(2);
// CD3DX12_ROOT_SIGNATURE_DESC rs;
// rs.Init(5 - i, rp); // make each rs a bit different just for fun
// CComPtr<ID3DBlob> pRSBlob;
// VERIFY_SUCCEEDED(D3D12SerializeRootSignature(&rs, D3D_ROOT_SIGNATURE_VERSION_1, &pRSBlob, NULL));
// CComPtr<ID3D12RootSignature> pRS;
// VERIFY_SUCCEEDED(m_Ctx.spDevice->CreateRootSignature(GetFullNodeMask(m_Ctx.spDevice), pRSBlob->GetBufferPointer(), pRSBlob->GetBufferSize(), __uuidof(ID3D12RootSignature), (void**)&pMyAppRootSigs[i]));
//}
//CComPtr<ID3D12StateObjectPrototype> spRaytracingPipelineState;
//CComPtr<ID3D12StateObjectPrototype> spRaytracingPipelineState2;
////=============================================================================================================================
//// Example 1:
////
//// Collection 1:
//// 3 DXIL libraries, exporting various raytracing shaders
//// 5 hit shader definitions built from exports in the DXIL libraries
//// 2 raytracing shader configurations
//// 3 root signatures
////
//// Collection 2:
//// 2 DXIL libraries, exporting various raytracing shaders
//// (one of the libs is same as previous collection, just using different exports)
//// 4 hit shader definitions built from exports in the DXIL libraries
//// 1 raytracing shader configurations
//// 1 root signature
////
//// Raytracing PSO:
//// 2 collections
//// 1 raytracing configuration
////
////=============================================================================================================================
//{
// //=========================================================================================================================
// // Collection1
// //=========================================================================================================================
// CD3D12_STATE_OBJECT_DESC Collection1(D3D12_STATE_OBJECT_TYPE_COLLECTION);
// auto Lib0 = Collection1.CreateSubobject<CD3D12_DXIL_LIBRARY_SUBOBJECT>();
// Lib0->SetDXILLibrary(&pMyAppDxilLibs[0]);
// Lib0->DefineExport(L"rayGenShader0"); // in practice these export listings might be data/engine driven
// Lib0->DefineExport(L"rayGenShader1");
// Lib0->DefineExport(L"rayGenShader2", L"rayGenShader99"); // rename rayGenShader99 in the lib to rayGenShader2
// Lib0->DefineExport(L"anyHitShader0");
// Lib0->DefineExport(L"anyHitShader1");
// Lib0->DefineExport(L"anyHitShader2");
// Lib0->DefineExport(L"callableShader0");
// Lib0->DefineExport(L"intersectionShader0");
// Lib0->DefineExport(L"intersectionShader1");
// Lib0->DefineExport(L"closestHitShader0");
// Lib0->DefineExport(L"intersectionShader2");
// Lib0->DefineExport(L"closestHitShader1");
// Lib0->DefineExport(L"callableShader1");
// Lib0->DefineExport(L"callableShader2");
// Lib0->DefineExport(L"closestHitShader2");
// auto Lib1 = Collection1.CreateSubobject<CD3D12_DXIL_LIBRARY_SUBOBJECT>();
// Lib1->SetDXILLibrary(&pMyAppDxilLibs[1]);
// Lib1->DefineExport(L"rayGenShader3");
// Lib1->DefineExport(L"anyHitShader3");
// Lib1->DefineExport(L"closestHitShader3");
// Lib1->DefineExport(L"intersectionShader3");
// Lib1->DefineExport(L"hitGroup0"); // suppose this is defined in DXIL as {"anyHitShader4","closestHitShader1"}
// Lib1->DefineExport(L"missShader0");
// auto Lib2 = Collection1.CreateSubobject<CD3D12_DXIL_LIBRARY_SUBOBJECT>();
// Lib2->SetDXILLibrary(&pMyAppDxilLibs[2]);
// // Omitting export list for Lib2, which means export all the exports in the DXIL library.
// // Suppose they are:
// // anyHitShader4
// // closestHitShader4
// // intersectionShader4;
// // hitGroup1 = {"anyHitShader0","closestHitShader4","intersectionShader2"}
// // hitGroup2 = {"closestHitShader2"}
// // hitGroup3 = {"closestHitShader3"}
// auto LocalHitGroup = Collection1.CreateSubobject<CD3D12_HIT_GROUP_SUBOBJECT>();
// LocalHitGroup->SetHitGroupExport(L"hitGroup4");
// LocalHitGroup->SetAnyHitShaderImport(L"anyHitShader4");
// LocalHitGroup->SetClosestHitShaderImport(L"closestHitShader2");
// CD3D12_RAYTRACING_SHADER_CONFIG_SUBOBJECT* ShaderConfig[2];
// for (UINT i = 0; i < _countof(ShaderConfig); i++) { ShaderConfig[i] = Collection1.CreateSubobject<CD3D12_RAYTRACING_SHADER_CONFIG_SUBOBJECT>(); }
// ShaderConfig[0]->Config(8, 8);
// ShaderConfig[1]->Config(2, 2);
// CD3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT* ShaderConfigAssociation[2];
// for (UINT i = 0; i < _countof(ShaderConfigAssociation); i++) { ShaderConfigAssociation[i] = Collection1.CreateSubobject<CD3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT>(); }
// ShaderConfigAssociation[0]->SetSubobjectToAssociate(*ShaderConfig[0]);
// ShaderConfigAssociation[0]->AddExport(L"rayGenShader0");
// ShaderConfigAssociation[0]->AddExport(L"rayGenShader1");
// ShaderConfigAssociation[0]->AddExport(L"hitShader0");
// ShaderConfigAssociation[0]->AddExport(L"hitShader1");
// ShaderConfigAssociation[0]->AddExport(L"hitShader2");
// ShaderConfigAssociation[0]->AddExport(L"callableShader0");
// ShaderConfigAssociation[0]->AddExport(L"callableShader1");
// ShaderConfigAssociation[1]->SetSubobjectToAssociate(*ShaderConfig[1]);
// ShaderConfigAssociation[1]->AddExport(L"rayGenShader2");
// ShaderConfigAssociation[1]->AddExport(L"rayGenShader3");
// ShaderConfigAssociation[1]->AddExport(L"hitShader3");
// ShaderConfigAssociation[1]->AddExport(L"hitShader4");
// ShaderConfigAssociation[1]->AddExport(L"missShader0");
// ShaderConfigAssociation[1]->AddExport(L"callableShader2");
// ShaderConfigAssociation[1]->AddExport(L"callableShader3");
// ShaderConfigAssociation[1]->AddExport(L"callableShader4");
// CD3D12_LOCAL_ROOT_SIGNATURE_SUBOBJECT* RootSig[3];
// for (UINT i = 0; i < _countof(RootSig); i++) { RootSig[i] = Collection1.CreateSubobject<CD3D12_LOCAL_ROOT_SIGNATURE_SUBOBJECT>(); }
// RootSig[0]->SetRootSignature(pMyAppRootSigs[0]);
// RootSig[1]->SetRootSignature(pMyAppRootSigs[1]);
// RootSig[2]->SetRootSignature(pMyAppRootSigs[2]);
// CD3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT* RootSigAssociation[3];
// for (UINT i = 0; i < _countof(RootSigAssociation); i++) { RootSigAssociation[i] = Collection1.CreateSubobject<CD3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT>(); }
// RootSigAssociation[0]->SetSubobjectToAssociate(*RootSig[0]);
// RootSigAssociation[0]->AddExport(L"rayGenShader0");
// RootSigAssociation[0]->AddExport(L"rayGenShader1");
// RootSigAssociation[0]->AddExport(L"rayGenShader2");
// RootSigAssociation[0]->AddExport(L"rayGenShader3");
// RootSigAssociation[1]->SetSubobjectToAssociate(*RootSig[1]);
// RootSigAssociation[1]->AddExport(L"hitShader0");
// RootSigAssociation[1]->AddExport(L"hitShader1");
// RootSigAssociation[1]->AddExport(L"hitShader2");
// RootSigAssociation[1]->AddExport(L"hitShader3");
// RootSigAssociation[1]->AddExport(L"hitShader4");
// RootSigAssociation[2]->SetSubobjectToAssociate(*RootSig[2]);
// RootSigAssociation[2]->AddExport(L"callableShader0");
// RootSigAssociation[2]->AddExport(L"callableShader1");
// RootSigAssociation[2]->AddExport(L"callableShader2");
// RootSigAssociation[2]->AddExport(L"missShader0");
// CComPtr<ID3D12StateObjectPrototype> spCollection1;
// VERIFY_SUCCEEDED(spFPDevice->CreateStateObject(Collection1, IID_PPV_ARGS(&spCollection1)));
// //=========================================================================================================================
// // Collection2
// //=========================================================================================================================
// CD3D12_STATE_OBJECT_DESC Collection2(D3D12_STATE_OBJECT_TYPE_COLLECTION);
// auto Lib3 = Collection2.CreateSubobject<CD3D12_DXIL_LIBRARY_SUBOBJECT>();
// Lib3->SetDXILLibrary(&pMyAppDxilLibs[0]); // Note, same DXIL library as used in earlier collection,
// // but we're taking different exports
// Lib3->DefineExport(L"rayGenShaderA");
// Lib3->DefineExport(L"rayGenShaderB");
// Lib3->DefineExport(L"rayGenShaderC", L"rayGenShader99"); // rename rayGenShader99 in the lib to rayGenShaderC
// // (was also renamed to rayGenShader2 in earlier lib)
// Lib3->DefineExport(L"anyHitShaderA");
// Lib3->DefineExport(L"anyHitShaderB");
// Lib3->DefineExport(L"anyHitShaderC");
// Lib3->DefineExport(L"callableShaderA");
// Lib3->DefineExport(L"intersectionShaderA");
// Lib3->DefineExport(L"intersectionShaderB");
// Lib3->DefineExport(L"closestHitShaderA");
// Lib3->DefineExport(L"intersectionShaderC");
// Lib3->DefineExport(L"closestHitShaderB");
// Lib3->DefineExport(L"callableShaderB");
// Lib3->DefineExport(L"callableShaderC");
// Lib3->DefineExport(L"closestHitShaderC");
// auto Lib4 = Collection2.CreateSubobject<CD3D12_DXIL_LIBRARY_SUBOBJECT>();
// Lib4->SetDXILLibrary(&pMyAppDxilLibs[3]);
// Lib4->DefineExport(L"rayGenShaderD");
// Lib4->DefineExport(L"anyHitShaderD");
// Lib4->DefineExport(L"closestHitShaderD");
// Lib4->DefineExport(L"intersectionShaderD");
// Lib4->DefineExport(L"hitGroupA"); // suppose this is defined in DXIL as {"anyHitShaderD","closestHitShaderB"}
// Lib4->DefineExport(L"missShaderA");
// auto LocalHitGroupB = Collection2.CreateSubobject<CD3D12_HIT_GROUP_SUBOBJECT>();
// LocalHitGroupB->SetHitGroupExport(L"hitGroupB");
// LocalHitGroupB->SetAnyHitShaderImport(L"anyHitShaderA");
// LocalHitGroupB->SetClosestHitShaderImport(L"closestHitShaderC");
// LocalHitGroupB->SetIntersectionShaderImport(L"intersectionHitShaderB");
// auto LocalHitGroupC = Collection2.CreateSubobject<CD3D12_HIT_GROUP_SUBOBJECT>();
// LocalHitGroupC->SetHitGroupExport(L"hitGroupC");
// LocalHitGroupC->SetAnyHitShaderImport(L"anyHitShaderA");
// LocalHitGroupC->SetClosestHitShaderImport(L"closestHitShaderA");
// LocalHitGroupC->SetIntersectionShaderImport(L"intersectionShaderA");
// auto LocalHitGroupD = Collection2.CreateSubobject<CD3D12_HIT_GROUP_SUBOBJECT>();
// LocalHitGroupD->SetHitGroupExport(L"hitGroupD");
// LocalHitGroupD->SetAnyHitShaderImport(L"anyHitShaderD");
// auto ShaderConfigA = Collection2.CreateSubobject<CD3D12_RAYTRACING_SHADER_CONFIG_SUBOBJECT>();
// ShaderConfigA->Config(8, 8); // not specifying associations, so by default will map to all relevant exports
// auto RootSigA = Collection2.CreateSubobject<CD3D12_LOCAL_ROOT_SIGNATURE_SUBOBJECT>();
// RootSigA->SetRootSignature(pMyAppRootSigs[3]); // not specifying associations, so by default will map to all relevant exports
// CComPtr<ID3D12StateObjectPrototype> spCollection2;
// VERIFY_SUCCEEDED(spFPDevice->CreateStateObject(Collection2, IID_PPV_ARGS(&spCollection2)));
// //=========================================================================================================================
// // Raytracing Pipeline State
// //=========================================================================================================================
// CD3D12_STATE_OBJECT_DESC RaytracingPipelineState(D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE);
// auto ExistingLib0 = RaytracingPipelineState.CreateSubobject<CD3D12_EXISTING_COLLECTION_SUBOBJECT>();
// ExistingLib0->SetExistingCollection(spCollection1);
// auto ExistingLib1 = RaytracingPipelineState.CreateSubobject<CD3D12_EXISTING_COLLECTION_SUBOBJECT>();
// ExistingLib1->SetExistingCollection(spCollection2);
// auto RaytracingConfig = RaytracingPipelineState.CreateSubobject<CD3D12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT>();
// RaytracingConfig->Config(8); // not specifying associations, so by default will map to all relevant exports
// VERIFY_SUCCEEDED(spFPDevice->CreateStateObject(RaytracingPipelineState, IID_PPV_ARGS(&spRaytracingPipelineState)));
//}
////=============================================================================================================================
//// Example 2:
////
//// Raytracing PSO:
//// 4 DXIL libraries (entrypoints in the dxil already have root signatures and raytracing shader configs where applicable)
//// 1 raytracing configuration
////
//// This example uses alternative syntax for declaring subobjects, where the helpers for each subobject are declared as
//// stack variables.
////
////=============================================================================================================================
//{
// CD3D12_STATE_OBJECT_DESC RaytracingState2(D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE);
// CD3D12_DXIL_LIBRARY_SUBOBJECT LibA(RaytracingState2), LibB(RaytracingState2), LibC(RaytracingState2), LibD(RaytracingState2);
// LibA.SetDXILLibrary(&pMyAppDxilLibs[4]); // not manually specifying exports - meaning all exports in the libraries are exported
// LibB.SetDXILLibrary(&pMyAppDxilLibs[5]);
// LibC.SetDXILLibrary(&pMyAppDxilLibs[6]);
// LibD.SetDXILLibrary(&pMyAppDxilLibs[7]);
// CD3D12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT RaytracingConfigA(RaytracingState2);
// RaytracingConfigA.Config(16); // not specifying associations, so by default will map to all relevant exports
// VERIFY_SUCCEEDED(spFPDevice->CreateStateObject(RaytracingState2, IID_PPV_ARGS(&spRaytracingPipelineState2)));
//}
| 45.079897 | 207 | 0.683409 | [
"object",
"vector"
] |
5bb9ecc4449352031c295a7cec553bc3588470ae | 84,203 | cpp | C++ | src/Screens/CViewC64.cpp | slajerek/RetroDebugger | e761e4f9efd103a05e65ef283423b142fa4324c7 | [
"Apache-2.0",
"MIT"
] | 34 | 2021-05-29T07:04:17.000Z | 2022-03-10T20:16:03.000Z | src/Screens/CViewC64.cpp | slajerek/RetroDebugger | e761e4f9efd103a05e65ef283423b142fa4324c7 | [
"Apache-2.0",
"MIT"
] | 6 | 2021-12-25T13:05:21.000Z | 2022-01-19T17:35:17.000Z | src/Screens/CViewC64.cpp | slajerek/RetroDebugger | e761e4f9efd103a05e65ef283423b142fa4324c7 | [
"Apache-2.0",
"MIT"
] | 6 | 2021-12-24T18:37:41.000Z | 2022-02-06T23:06:02.000Z | //
// C64 Debugger (C) Marcin Skoczylas, slajerek@gmail.com
//
// created on 2016-02-22
// define also in CGuiMain
//#define DO_NOT_USE_AUDIO_QUEUE
// TODO: move me ..
#define MAX_BUFFER 2048
extern "C"{
#include "c64mem.h"
}
#include "FontProFontIIx.h"
#include "CViewC64.h"
#include "SYS_Defs.h"
#include "VID_Main.h"
#include "VID_Blits.h"
#include "CGuiMain.h"
#include "CLayoutManager.h"
#include "RES_ResourceManager.h"
#include "CSlrFontProportional.h"
#include "VID_ImageBinding.h"
#include "GAM_GamePads.h"
#include "CByteBuffer.h"
#include "CSlrKeyboardShortcuts.h"
#include "SYS_KeyCodes.h"
#include "C64SettingsStorage.h"
#include "SYS_PIPE.h"
#include "CAudioChannelVice.h"
#include "CAudioChannelAtari.h"
#include "CAudioChannelNes.h"
#include "RetroDebuggerEmbeddedData.h"
#include "CDebugDataAdapter.h"
#include "imgui_freetype.h"
#include "CViewDataDump.h"
#include "CViewDataWatch.h"
#include "CViewMemoryMap.h"
#include "CViewDisassembly.h"
#include "CViewSourceCode.h"
#include "CViewC64Screen.h"
#include "CViewC64ScreenWrapper.h"
#include "CViewC64StateCIA.h"
#include "CViewC64StateREU.h"
#include "CViewEmulationCounters.h"
#include "CViewC64StateSID.h"
#include "CViewC64StateVIC.h"
#include "CViewDrive1541StateVIA.h"
#include "CViewEmulationState.h"
#include "CViewC64VicDisplay.h"
#include "CViewC64VicControl.h"
#include "CViewC64SidPianoKeyboard.h"
#include "CViewC64MemoryDebuggerLayoutToolbar.h"
#include "CViewC64StateCPU.h"
#include "CViewInputEvents.h"
#include "CViewBreakpoints.h"
#include "CViewTimeline.h"
#include "CViewDriveStateCPU.h"
#include "CViewAtariScreen.h"
#include "CViewAtariStateCPU.h"
#include "CViewAtariStateANTIC.h"
#include "CViewAtariStatePIA.h"
#include "CViewAtariStateGTIA.h"
#include "CViewAtariStatePOKEY.h"
#include "CViewNesScreen.h"
#include "CViewNesStateCPU.h"
#include "CViewNesStateAPU.h"
#include "CViewNesPianoKeyboard.h"
#include "CViewNesStatePPU.h"
#include "CViewNesPpuPatterns.h"
#include "CViewNesPpuNametables.h"
#include "CViewNesPpuAttributes.h"
#include "CViewNesPpuOam.h"
#include "CViewNesPpuPalette.h"
#include "CViewMainMenu.h"
#include "CViewSettingsMenu.h"
#include "CViewFileD64.h"
#include "CViewC64KeyMap.h"
#include "CViewC64AllGraphics.h"
#include "CViewC64SidTrackerHistory.h"
#include "CViewKeyboardShortcuts.h"
#include "CViewMonitorConsole.h"
#include "CViewSnapshots.h"
#include "CViewColodore.h"
#include "CViewAbout.h"
#include "CViewVicEditor.h"
#include "CViewJukeboxPlaylist.h"
#include "CMainMenuBar.h"
#include "CDebugMemoryMap.h"
#include "CDebugMemoryMapCell.h"
#include "CJukeboxPlaylist.h"
#include "C64FileDataAdapter.h"
#include "C64KeyboardShortcuts.h"
#include "CSlrString.h"
#include "C64Tools.h"
#include "CDebugSymbols.h"
#include "C64Palette.h"
#include "C64KeyMap.h"
#include "C64CommandLine.h"
#include "C64SharedMemory.h"
#include "C64SIDFrequencies.h"
#include "SND_SoundEngine.h"
#include "CSlrFileFromOS.h"
#include "CColorsTheme.h"
#include "SYS_Threading.h"
#include "CDebugAsmSource.h"
#include "CDebuggerEmulatorPlugin.h"
#include "CSnapshotsManager.h"
#include "CDebugSymbolsSegmentC64.h"
#include "C64D_InitPlugins.h"
#include "CDebugInterfaceVice.h"
#include "CDebugInterfaceAtari.h"
#include "CDebugInterfaceNes.h"
CViewC64 *viewC64 = NULL;
unsigned long c64dStartupTime = 0;
#define TEXT_ADDR 0x0400
#define COLOR_ADDR 0xD800
void TEST_Editor();
void TEST_Editor_Render();
// TODO: refactor this. after transition to ImGui the CViewC64 is no longer a view, it is just a application holder of other views.
CViewC64::CViewC64(float posX, float posY, float posZ, float sizeX, float sizeY)
: CGuiView("CViewC64", posX, posY, posZ, sizeX, sizeY)
{
LOGM("CViewC64::CViewC64 starting init");
isInitialized = false;
this->name = "CViewC64";
viewC64 = this;
SYS_SetThreadName("CViewC64");
c64dStartupTime = SYS_GetCurrentTimeInMillis();
this->config = new CConfigStorageHjson(C64D_SETTINGS_HJSON_FILE_PATH);
defaultFontPath = NULL;
defaultFontSize = 13.0f;
// here comes windows shit:
this->config->GetFloat("mouseScrollWheelScaleX", &guiMain->mouseScrollWheelScaleX, 1.0f);
#if defined(WIN32)
this->config->GetFloat("mouseScrollWheelScaleY", &guiMain->mouseScrollWheelScaleY, 5.0f);
#else
this->config->GetFloat("mouseScrollWheelScaleY", &guiMain->mouseScrollWheelScaleY, 1.0f);
#endif
C64InitPalette();
this->debugInterfaceC64 = NULL;
this->emulationThreadC64 = NULL;
this->debugInterfaceAtari = NULL;
this->emulationThreadAtari = NULL;
this->debugInterfaceNes = NULL;
this->emulationThreadNes = NULL;
this->isDataDirectlyFromRAM = false;
memset(&viciiStateToShow, 0, sizeof(vicii_cycle_state_t));
memset(¤tViciiState, 0, sizeof(vicii_cycle_state_t));
C64DebuggerInitSharedMemory();
SYS_SharedMemoryRegisterCallback(viewC64);
C64DebuggerParseCommandLine1();
// restore pre-launch settings (paths to D64, PRG, CRT)
C64DebuggerRestoreSettings(C64DEBUGGER_BLOCK_PRELAUNCH);
LOGM("sound engine startup");
LOGTODO(" gSoundEngine->StartAudioUnit(true, false, 0)");
//#ifndef DO_NOT_USE_AUDIO_QUEUE
// gSoundEngine->StartAudioUnit(true, false, 0);
//#endif
SID_FrequenciesInit();
mappedC64Memory = NULL;
mappedC64MemoryDescriptor = NULL;
isSoundMuted = false;
keyboardShortcuts = new C64KeyboardShortcuts();
// init default key map
if (c64SettingsSkipConfig == false)
{
C64KeyMapLoadFromSettings();
}
else
{
C64KeyMapCreateDefault();
}
this->colorsTheme = new CColorsTheme(0);
// init the Commodore 64 object
this->InitViceC64();
GAM_InitGamePads();
// crude hack for now, we needed c64 only for fonts
#ifndef RUN_COMMODORE64
delete this->debugInterfaceC64;
this->debugInterfaceC64 = NULL;
#endif
#ifdef RUN_ATARI
// init the Atari 800 object
this->InitAtari800();
// TODO: create Atari fonts from kernel data
// this->CreateFonts();
#endif
#if defined(RUN_NES)
this->InitNestopia();
#endif
// create fonts from Commodore 64/Atari800 kerne/al data
this->CreateFonts();
guiRenderFrameCounter = 0;
isShowingRasterCross = false;
///
///
this->InitViews();
//
//
// THIS BELOW IS NOT USED ANYMORE, STORED HERE FOR HISTORICAL PURPOSES:
/*
// TODO: move me to CGuiMain
// loop of views for TAB & shift+TAB
if (debugInterfaceC64 != NULL)
{
traversalOfViews.push_back(viewC64ScreenWrapper);
}
if (debugInterfaceC64 != NULL)
{
traversalOfViews.push_back(viewC64Disassemble);
traversalOfViews.push_back(viewC64Disassemble2);
traversalOfViews.push_back(viewC64MemoryDataDump);
traversalOfViews.push_back(viewDrive1541MemoryDataDump);
traversalOfViews.push_back(viewDrive1541Disassemble);
traversalOfViews.push_back(viewDrive1541Disassemble2);
traversalOfViews.push_back(viewC64MemoryDataDump2);
traversalOfViews.push_back(viewDrive1541MemoryDataDump2);
traversalOfViews.push_back(viewC64MemoryDataDump3);
traversalOfViews.push_back(viewDrive1541MemoryDataDump3);
traversalOfViews.push_back(viewC64MemoryMap);
traversalOfViews.push_back(viewDrive1541MemoryMap);
traversalOfViews.push_back(viewC64MonitorConsole);
}
if (debugInterfaceC64 != NULL)
{
traversalOfViews.push_back(viewC64VicDisplay);
}
if (debugInterfaceAtari != NULL)
{
traversalOfViews.push_back(viewAtariScreen);
traversalOfViews.push_back(viewAtariDisassemble);
traversalOfViews.push_back(viewAtariMemoryDataDump);
traversalOfViews.push_back(viewAtariMemoryMap);
traversalOfViews.push_back(viewAtariMonitorConsole);
}
if (debugInterfaceNes != NULL)
{
traversalOfViews.push_back(viewNesScreen);
traversalOfViews.push_back(viewNesDisassemble);
traversalOfViews.push_back(viewNesMemoryDataDump);
traversalOfViews.push_back(viewNesMemoryMap);
traversalOfViews.push_back(viewNesPpuNametableMemoryDataDump);
traversalOfViews.push_back(viewNesPpuNametableMemoryMap);
traversalOfViews.push_back(viewNesMonitorConsole);
}
*/
// add screens
// DO NOT ADD YOUSELF YOU'VE BEEN ADDED ALREADY: guiMain->AddGuiElement(this);
// other screens. These screens are obsolete:
viewC64MainMenu = new CViewMainMenu(0, 0, -3.0, SCREEN_WIDTH, SCREEN_HEIGHT);
// guiMain->AddGuiElement(viewC64MainMenu);
viewC64SettingsMenu = new CViewSettingsMenu(0, 0, -3.0, SCREEN_WIDTH, SCREEN_HEIGHT);
// guiMain->AddGuiElement(viewC64SettingsMenu);
if (this->debugInterfaceC64 != NULL)
{
viewFileD64 = new CViewFileD64(0, 0, -3.0, SCREEN_WIDTH, SCREEN_HEIGHT);
// guiMain->AddGuiElement(viewFileD64);
// viewC64BreakpointsPC = new CViewBreakpoints(0, 0, -3.0, SCREEN_WIDTH, SCREEN_HEIGHT, this->debugInterfaceC64->breakpointsPC);
// guiMain->AddGuiElement(viewC64BreakpointsPC);
viewC64Snapshots = new CViewSnapshots(0, 0, -3.0, SCREEN_WIDTH, SCREEN_HEIGHT);
// guiMain->AddGuiElement(viewC64Snapshots);
viewC64KeyMap = new CViewC64KeyMap(0, 0, -3.0, SCREEN_WIDTH, SCREEN_HEIGHT);
// guiMain->AddGuiElement(viewC64KeyMap);
// viewColodore = new CViewColodore(0, 0, -3.0, SCREEN_WIDTH, SCREEN_HEIGHT);
// guiMain->AddGuiElement(viewColodore);
}
else
{
viewFileD64 = NULL;
viewC64BreakpointsPC = NULL;
viewC64Snapshots = NULL;
viewC64KeyMap = NULL;
}
if (this->debugInterfaceAtari != NULL)
{
viewAtariSnapshots = new CViewSnapshots(0, 0, -3.0, SCREEN_WIDTH, SCREEN_HEIGHT);
// guiMain->AddGuiElement(viewAtariSnapshots);
}
if (this->debugInterfaceNes != NULL)
{
viewNesSnapshots = new CViewSnapshots(0, 0, -3.0, SCREEN_WIDTH, SCREEN_HEIGHT);
// guiMain->AddGuiElement(viewNesSnapshots);
}
viewKeyboardShortcuts = new CViewKeyboardShortcuts(0, 0, -3.0, SCREEN_WIDTH, SCREEN_HEIGHT);
// guiMain->AddGuiElement(viewKeyboardShortcuts);
viewAbout = new CViewAbout(0, 0, -3.0, SCREEN_WIDTH, SCREEN_HEIGHT);
// guiMain->AddGuiElement(viewAbout);
// open/save file dialogs replacement
viewSelectFile = new CGuiViewSelectFile(0, 0, posZ, SCREEN_WIDTH-80.0, SCREEN_HEIGHT, false, this);
viewSelectFile->SetFont(fontCBMShifted, 2.0f);
// guiMain->AddGuiElement(viewSelectFile);
viewSaveFile = new CGuiViewSaveFile(0, 0, posZ, SCREEN_WIDTH-80.0, SCREEN_HEIGHT, this);
viewSaveFile->SetFont(fontCBMShifted, 2.0f);
// guiMain->AddGuiElement(viewSaveFile);
#if defined(RUN_COMMODORE64)
//
viewVicEditor = new CViewVicEditor("C64 VIC Editor", 0, 0, -3.0, SCREEN_WIDTH, SCREEN_HEIGHT);
// guiMain->AddGuiElement(viewVicEditor);
#endif
SYS_AddApplicationPauseResumeListener(this);
//
// Init menu bar
this->mainMenuBar = new CMainMenuBar();
//
// RESTORE settings that need to be set when emulation is initialized
//
C64DebuggerRestoreSettings(C64DEBUGGER_BLOCK_POSTLAUNCH);
LOGD("... settings restored");
// do additional parsing
C64DebuggerParseCommandLine2();
// memory map colors
C64DebuggerComputeMemoryMapColorTables(c64SettingsMemoryValuesStyle);
C64DebuggerSetMemoryMapMarkersStyle(c64SettingsMemoryMarkersStyle);
C64DebuggerSetMemoryMapCellsFadeSpeed((float)c64SettingsMemoryMapFadeSpeed / 100.0f);
bool isInVicEditor = c64SettingsIsInVicEditor;
// LOGD("... after parsing c64SettingsDefaultScreenLayoutId=%d", c64SettingsDefaultScreenLayoutId);
// if (c64SettingsDefaultScreenLayoutId >= SCREEN_LAYOUT_MAX)
// {
// LOGD("... c64SettingsDefaultScreenLayoutId=%d >= SCREEN_LAYOUT_MAX=%d", c64SettingsDefaultScreenLayoutId, SCREEN_LAYOUT_MAX);
//
// c64SettingsDefaultScreenLayoutId = SCREEN_LAYOUT_C64_DEBUGGER;
// LOGD("... corrected c64SettingsDefaultScreenLayoutId=%d", c64SettingsDefaultScreenLayoutId);
// }
// // TODO: temporary hack to run both emulators
//#if defined(RUN_COMMODORE64) && defined(RUN_ATARI)
// if (debugInterfaceC64 && debugInterfaceAtari)
// {
// this->SwitchToScreenLayout(SCREEN_LAYOUT_C64_AND_ATARI);
// }
//#endif
//
//
// Create plugins
this->CreateEmulatorPlugins();
//////////////////////
this->viewJukeboxPlaylist = NULL;
if (c64SettingsPathToJukeboxPlaylist != NULL)
{
this->InitJukebox(c64SettingsPathToJukeboxPlaylist);
}
// finished starting up
RES_SetStateIdle();
VID_SetFPS(FRAMES_PER_SECOND);
//
// Start PIPE integration
if (c64SettingsUsePipeIntegration)
{
PIPE_Init("retrodebugger");
}
//
// Start emulation threads (emulation should be already initialized, just run the processor)
//
if (c64SettingsRunVice)
{
StartEmulationThread(debugInterfaceC64);
}
if (c64SettingsRunAtari800)
{
StartEmulationThread(debugInterfaceAtari);
}
if (c64SettingsRunNestopia)
{
StartEmulationThread(debugInterfaceNes);
}
//
if (c64SettingsSkipConfig == false)
{
viewKeyboardShortcuts->RestoreKeyboardShortcuts();
}
viewKeyboardShortcuts->UpdateQuitShortcut();
//
C64SetPaletteNum(c64SettingsVicPalette);
#if defined(WIN32)
// set process priority
SYS_SetMainProcessPriorityBoostDisabled(c64SettingsIsProcessPriorityBoostDisabled);
SYS_SetMainProcessPriority(c64SettingsProcessPriority);
#endif
//
mouseCursorNumFramesToHideCursor = 60;
mouseCursorVisibilityCounter = 0;
// start
ShowMainScreen();
// TODO: generalize me, init plugins
if (debugInterfaceC64)
{
debugInterfaceC64->InitPlugins();
}
if (debugInterfaceAtari)
{
debugInterfaceAtari->InitPlugins();
}
if (debugInterfaceNes)
{
debugInterfaceNes->InitPlugins();
}
isInitialized = true;
// attach disks, cartridges etc
C64DebuggerPerformStartupTasks();
// restore selected layout
CLayoutData *layoutData = guiMain->layoutManager->currentLayout;
guiMain->layoutManager->SetLayoutAsync(layoutData, false);
// and settings
guiMain->fntConsole->image->SetLinearScaling(c64SettingsInterpolationOnDefaultFont);
guiMain->fntConsoleInverted->image->SetLinearScaling(c64SettingsInterpolationOnDefaultFont);
// register for dropfile callback
guiMain->AddGlobalDropFileCallback(this);
// restore open recent menu items
recentlyOpenedFiles = new CRecentlyOpenedFiles(new CSlrString(C64D_RECENTS_FILE_NAME), this);
TEST_Editor();
}
void CViewC64::ShowMainScreen()
{
return;
// if (c64SettingsIsInVicEditor)
// {
// guiMain->SetView(viewVicEditor);
// }
// else
// {
// guiMain->SetView(this);
// }
// guiMain->SetView(viewKeyboardShortcuts);
// guiMain->SetView(viewC64KeyMap);
// guiMain->SetView(viewAbout);
// guiMain->SetView(viewC64SettingsMenu);
// guiMain->SetView(viewC64MainMenu);
// guiMain->SetView(viewC64Breakpoints);
// guiMain->SetView(viewVicEditor);
// guiMain->SetView(this->viewColodore);
CheckMouseCursorVisibility();
}
CViewC64::~CViewC64()
{
}
void CViewC64::RegisterEmulatorPlugin(CDebuggerEmulatorPlugin *emuPlugin)
{
CDebugInterface *debugInterface = emuPlugin->GetDebugInterface();
debugInterface->RegisterPlugin(emuPlugin);
}
void CViewC64::InitJukebox(CSlrString *jukeboxJsonFilePath)
{
guiMain->LockMutex();
#if defined(MACOS) || defined(LINUX)
// set current folder to jukebox path
CSlrString *path = jukeboxJsonFilePath->GetFilePathWithoutFileNameComponentFromPath();
char *cPath = path->GetStdASCII();
LOGD("CViewC64::InitJukebox: chroot to %s", cPath);
chdir(cPath);
delete [] cPath;
delete path;
#endif
if (this->viewJukeboxPlaylist == NULL)
{
this->viewJukeboxPlaylist = new CViewJukeboxPlaylist(-10, -10, -3.0, 0.1, 0.1); //SCREEN_WIDTH, SCREEN_HEIGHT);
this->AddGuiElement(this->viewJukeboxPlaylist);
}
this->viewJukeboxPlaylist->DeletePlaylist();
this->viewJukeboxPlaylist->visible = true;
// start with black screen
this->viewJukeboxPlaylist->fadeState = JUKEBOX_PLAYLIST_FADE_STATE_FADE_OUT;
this->viewJukeboxPlaylist->fadeValue = 1.0f;
this->viewJukeboxPlaylist->fadeStep = 0.0f;
char *str = jukeboxJsonFilePath->GetStdASCII();
this->viewJukeboxPlaylist->InitFromFile(str);
delete [] str;
if ((this->debugInterfaceC64 && this->debugInterfaceC64->isRunning)
|| (this->debugInterfaceAtari && this->debugInterfaceAtari->isRunning)
|| (this->debugInterfaceNes && this->debugInterfaceNes->isRunning))
{
this->viewJukeboxPlaylist->StartPlaylist();
}
else
{
/*
// jukebox will be started by c64PerformStartupTasksThreaded()
if (this->viewJukeboxPlaylist->playlist->setLayoutViewNumber >= 0
&& this->viewJukeboxPlaylist->playlist->setLayoutViewNumber < SCREEN_LAYOUT_MAX)
{
// viewC64->SwitchToScreenLayout(this->viewJukeboxPlaylist->playlist->setLayoutViewNumber);
}
*/
}
guiMain->UnlockMutex();
}
void CViewC64::InitViceC64()
{
LOGM("CViewC64::InitViceC64");
if (c64SettingsPathToC64MemoryMapFile)
{
// Create debug interface and init Vice
char *asciiPath = c64SettingsPathToC64MemoryMapFile->GetStdASCII();
this->MapC64MemoryToFile(asciiPath);
LOGD(".. mapped C64 memory to file '%s'", asciiPath);
delete [] asciiPath;
}
else
{
this->mappedC64Memory = (uint8 *)malloc(C64_RAM_SIZE);
}
this->debugInterfaceC64 = new CDebugInterfaceVice(this, this->mappedC64Memory, c64SettingsFastBootKernalPatch);
this->debugInterfaces.push_back(this->debugInterfaceC64);
LOGM("CViewC64::InitViceC64: done");
}
void CViewC64::InitAtari800()
{
LOGM("CViewC64::InitAtari800");
if (debugInterfaceAtari != NULL)
{
delete debugInterfaceAtari;
debugInterfaceAtari = NULL;
}
// if (c64SettingsPathToC64MemoryMapFile)
// {
// // Create debug interface and init Vice
// char *asciiPath = c64SettingsPathToAtari800MemoryMapFile->GetStdASCII();
//
// this->MapC64MemoryToFile(asciiPath);
//
// LOGD(".. mapped Atari800 memory to file '%s'", asciiPath);
//
// delete [] asciiPath;
//
// }
// else
// {
// this->mappedC64Memory = (uint8 *)malloc(C64_RAM_SIZE);
// }
this->debugInterfaceAtari = new CDebugInterfaceAtari(this); //, this->mappedC64Memory, c64SettingsFastBootKernalPatch);
this->debugInterfaces.push_back(this->debugInterfaceAtari);
LOGM("CViewC64::InitViceC64: done");
}
void CViewC64::InitNestopia()
{
LOGM("CViewC64::InitNestopia");
this->debugInterfaceNes = new CDebugInterfaceNes(this);
this->debugInterfaces.push_back(this->debugInterfaceNes);
LOGM("CViewC64::InitNestopia: done");
}
void CViewC64::InitViews()
{
// set mouse cursor outside at startup
mouseCursorX = -SCREEN_WIDTH;
mouseCursorY = -SCREEN_HEIGHT;
InitViceViews();
InitAtari800Views();
InitNestopiaViews();
// add views to layout to serialize/deserialize them with layout
for (std::vector<CDebugInterface *>::iterator it = debugInterfaces.begin(); it != debugInterfaces.end(); it++)
{
CDebugInterface *debugInterface = *it;
for (std::list<CGuiView *>::iterator it = debugInterface->views.begin(); it != debugInterface->views.end(); it++)
{
CGuiView *view = *it;
guiMain->AddLayoutView(view);
}
}
}
void CViewC64::InitViceViews()
{
// create views
float minPosX = 10.0f;
float minPosY = 30.0f;
// note: views are created first to have dependencies fulfilled. They are added later to have them sorted.
// this is regular c64 screen
viewC64Screen = new CViewC64Screen("C64 Screen##direct", 510, 40, posZ, 540, 402, debugInterfaceC64);
// this->AddGuiElement(viewC64Screen); this will be added on the top
// wrapper wraps c64 screen with selectable display type: c64 screen, vic display, zoomed in c64 screen
// viewC64ScreenWrapper = new CViewC64ScreenWrapper("C64 Screen", 510, 40, posZ, 540, 402, debugInterfaceC64);
viewC64StateCPU = new CViewC64StateCPU("C64 CPU", 510, 5, posZ, 350, 35, debugInterfaceC64);
// views
viewC64MemoryMap = new CViewMemoryMap("C64 Memory map", 190, 20, posZ, 320, 280,
debugInterfaceC64, debugInterfaceC64->dataAdapterC64,
256, 256, 0x10000, true, false); // 256x256 = 64kB
viewDrive1541MemoryMap = new CViewMemoryMap("1541 Memory map", 120, 80, posZ, 200, 200,
debugInterfaceC64, debugInterfaceC64->dataAdapterDrive1541,
64, 1024, 0x10000, true, true);
viewC64Disassembly = new CViewDisassembly("C64 Disassembly", 0, 20, posZ, 190, 420,
debugInterfaceC64->symbols, NULL, viewC64MemoryMap);
viewC64Disassembly2 = new CViewDisassembly("C64 Disassembly 2", 100, 100, posZ, 200, 300,
debugInterfaceC64->symbols, NULL, viewC64MemoryMap);
viewDrive1541Disassembly = new CViewDisassembly("1541 Disassembly", 110, 110, posZ, 200, 300,
debugInterfaceC64->symbolsDrive1541, NULL, viewDrive1541MemoryMap);
viewDrive1541Disassembly2 = new CViewDisassembly("1541 Disassembly 2", 120, 120, posZ, 200, 300,
debugInterfaceC64->symbolsDrive1541, NULL, viewDrive1541MemoryMap);
viewC64MemoryDataDump = new CViewDataDump("C64 Memory", 190, 300, posZ, 320, 140,
debugInterfaceC64->symbols, viewC64MemoryMap, viewC64Disassembly);
viewC64Disassembly->SetViewDataDump(viewC64MemoryDataDump);
viewC64MemoryDataWatch = new CViewDataWatch("C64 Data watch", 140, 140, posZ, 300, 300,
debugInterfaceC64->symbols, viewC64MemoryMap);
//
viewC64MemoryDataDump2 = new CViewDataDump("C64 Memory 2", 10, 30, posZ, 300, 300,
debugInterfaceC64->symbols, viewC64MemoryMap, viewC64Disassembly);
viewC64Disassembly2->SetViewDataDump(viewC64MemoryDataDump2);
viewC64MemoryDataDump3 = new CViewDataDump("C64 Memory 3", 30, 40, posZ, 300, 300,
debugInterfaceC64->symbols, viewC64MemoryMap, viewC64Disassembly);
// set first data dump as main to be controlled by memory map
viewC64MemoryMap->SetDataDumpView(viewC64MemoryDataDump);
viewDrive1541MemoryDataDump = new CViewDataDump("1541 Memory", 20, 30, posZ, 300, 300,
debugInterfaceC64->symbols,
viewDrive1541MemoryMap, viewDrive1541Disassembly);
viewDrive1541Disassembly->SetViewDataDump(viewDrive1541MemoryDataDump);
viewDrive1541MemoryDataWatch = new CViewDataWatch("1541 Data watch", 40, 40, posZ, 300, 300,
debugInterfaceC64->symbolsDrive1541,
viewDrive1541MemoryMap);
//
viewDrive1541MemoryDataDump2 = new CViewDataDump("1541 Memory 2", 10, 10, posZ, 300, 300,
debugInterfaceC64->symbols, viewDrive1541MemoryMap, viewDrive1541Disassembly);
viewDrive1541Disassembly2->SetViewDataDump(viewDrive1541MemoryDataDump2);
//
viewDrive1541MemoryDataDump3 = new CViewDataDump("1541 Memory 3", 10, 10, posZ, 300, 300,
debugInterfaceC64->symbols, viewDrive1541MemoryMap, viewDrive1541Disassembly);
// set first drive data dump as main to be controlled by drive memory map
viewDrive1541MemoryMap->SetDataDumpView(viewDrive1541MemoryDataDump);
//
viewC64BreakpointsPC = new CViewBreakpoints("C64 PC Breakpoints", 10, 40, posZ, SCREEN_WIDTH, SCREEN_HEIGHT, this->debugInterfaceC64->symbols, BREAKPOINT_TYPE_CPU_PC);
viewC64BreakpointsMemory = new CViewBreakpoints("C64 Memory Breakpoints", 30, 50, posZ, SCREEN_WIDTH, SCREEN_HEIGHT, this->debugInterfaceC64->symbols, BREAKPOINT_TYPE_MEMORY);
viewC64BreakpointsRaster = new CViewBreakpoints("C64 Raster Breakpoints", 40, 40, posZ, SCREEN_WIDTH, SCREEN_HEIGHT, this->debugInterfaceC64->symbols, BREAKPOINT_TYPE_RASTER_LINE);
viewC64BreakpointsDrive1541PC = new CViewBreakpoints("1541 PC Breakpoints", 50, 50, posZ, SCREEN_WIDTH, SCREEN_HEIGHT, this->debugInterfaceC64->symbolsDrive1541, BREAKPOINT_TYPE_CPU_PC);
viewC64BreakpointsDrive1541Memory = new CViewBreakpoints("1541 Memory Breakpoints", 60, 60, posZ, SCREEN_WIDTH, SCREEN_HEIGHT, this->debugInterfaceC64->symbolsDrive1541, BREAKPOINT_TYPE_MEMORY);
//
viewC64CartridgeMemoryMap = new CViewMemoryMap("C64 Cartridge memory map", 40, 70, posZ, 400, 300,
debugInterfaceC64, debugInterfaceC64->dataAdapterCartridgeC64,
512, 1024, 512*1024, true, false); // 512*1024 = 512kB
viewC64CartridgeMemoryMap->updateMapNumberOfFps = 1.0f;
viewC64CartridgeMemoryMap->updateMapIsAnimateEvents = false;
viewC64CartridgeMemoryMap->showCurrentExecutePC = false;
viewC64CartridgeMemoryDataDump = new CViewDataDump("C64 Cartridge memory", 50, 50, posZ, 400, 300,
debugInterfaceC64->symbolsCartridgeC64, viewC64CartridgeMemoryMap, viewC64Disassembly);
viewC64CartridgeMemoryDataDump->SetNumDigitsInAddress(5);
//
viewC64SourceCode = new CViewSourceCode("C64 Assembler source", 40, 70, posZ, 500, 350,
debugInterfaceC64, debugInterfaceC64->dataAdapterC64, viewC64MemoryMap, viewC64Disassembly);
//
viewC64StateCIA = new CViewC64StateCIA("C64 CIA", 10, 40, posZ, 400, 200, debugInterfaceC64);
viewC64StateSID = new CViewC64StateSID("C64 SID", 10, 40, posZ, 250, 270, debugInterfaceC64);
viewC64StateVIC = new CViewC64StateVIC("C64 VIC", 10, 40, posZ, 300, 200, debugInterfaceC64);
viewC64StateREU = new CViewC64StateREU("C64 REU", 10, 40, posZ, 300, 200, debugInterfaceC64);
viewC64EmulationCounters = new CViewEmulationCounters("C64 Counters", 860, -1.25, posZ, 130, 43, debugInterfaceC64);
viewDrive1541StateVIA = new CViewDrive1541StateVIA("1541 VIA", 10, 40, posZ, 300, 200, debugInterfaceC64);
viewEmulationState = new CViewEmulationState("C64 Emulation", 10, 40, posZ, 350, 10, debugInterfaceC64);
viewC64VicDisplay = new CViewC64VicDisplay("C64 VIC Display", 50, 50, posZ, 400, 500, debugInterfaceC64);
viewC64VicControl = new CViewC64VicControl("C64 VIC Control", 10, 50, posZ, 100, 360, viewC64VicDisplay);
viewC64MonitorConsole = new CViewMonitorConsole("C64 Monitor console", 40, 70, posZ, 500, 300, debugInterfaceC64);
//
viewDriveStateCPU = new CViewDriveStateCPU("1541 CPU", 20, 50, posZ, 300, 35, debugInterfaceC64);
//
viewC64AllGraphics = new CViewC64AllGraphics("C64 All graphics", 0, 0, posZ, 500, 500, debugInterfaceC64);
//
viewC64SidTrackerHistory = new CViewC64SidTrackerHistory("C64 SID Tracker history", 150, 40, posZ, 600, 400, (CDebugInterfaceVice*)debugInterfaceC64);
viewC64SidPianoKeyboard = new CViewC64SidPianoKeyboard("C64 SID Piano keyboard", 50, 100, posZ, 400, 65, viewC64SidTrackerHistory);
float timelineHeight = 40;
viewC64Timeline = new CViewTimeline("C64 Timeline", 0, 440, posZ, 700, timelineHeight, debugInterfaceC64);
// add sorted views
debugInterfaceC64->AddView(viewC64Screen);
debugInterfaceC64->AddView(viewC64StateCPU);
debugInterfaceC64->AddView(viewC64Disassembly);
debugInterfaceC64->AddView(viewC64Disassembly2);
viewC64Disassembly2->visible = false;
debugInterfaceC64->AddView(viewC64SourceCode);
viewC64SourceCode->visible = false;
debugInterfaceC64->AddView(viewC64MemoryDataDump);
debugInterfaceC64->AddView(viewC64MemoryDataDump2);
viewC64MemoryDataDump2->visible = false;
debugInterfaceC64->AddView(viewC64MemoryDataDump3);
viewC64MemoryDataDump3->visible = false;
debugInterfaceC64->AddView(viewC64MemoryDataWatch);
viewC64MemoryDataWatch->visible = false;
debugInterfaceC64->AddView(viewC64MemoryMap);
debugInterfaceC64->AddView(viewC64BreakpointsPC);
viewC64BreakpointsPC->visible = false;
debugInterfaceC64->AddView(viewC64BreakpointsMemory);
viewC64BreakpointsMemory->visible = false;
debugInterfaceC64->AddView(viewC64BreakpointsRaster);
viewC64BreakpointsRaster->visible = false;
debugInterfaceC64->AddView(viewC64CartridgeMemoryDataDump);
viewC64CartridgeMemoryDataDump->visible = false;
debugInterfaceC64->AddView(viewC64CartridgeMemoryMap);
viewC64CartridgeMemoryMap->visible = false;
debugInterfaceC64->AddView(viewC64StateCIA);
viewC64StateCIA->visible = false;
debugInterfaceC64->AddView(viewC64StateSID);
viewC64StateSID->visible = false;
debugInterfaceC64->AddView(viewC64StateVIC);
viewC64StateVIC->visible = false;
debugInterfaceC64->AddView(viewC64StateREU);
viewC64StateREU->visible = false;
debugInterfaceC64->AddView(viewC64VicDisplay);
viewC64VicDisplay->visible = false;
debugInterfaceC64->AddView(viewC64VicControl);
viewC64VicControl->visible = false;
// debugInterfaceC64->AddView(viewC64AllGraphics);
// viewC64AllGraphics->visible = false;
debugInterfaceC64->AddView(viewC64SidTrackerHistory);
viewC64SidTrackerHistory->visible = false;
debugInterfaceC64->AddView(viewC64SidPianoKeyboard);
viewC64SidPianoKeyboard->visible = false;
debugInterfaceC64->AddView(viewDriveStateCPU);
viewDriveStateCPU->visible = false;
debugInterfaceC64->AddView(viewDrive1541Disassembly);
viewDrive1541Disassembly->visible = false;
debugInterfaceC64->AddView(viewDrive1541Disassembly2);
viewDrive1541Disassembly2->visible = false;
debugInterfaceC64->AddView(viewDrive1541MemoryDataDump);
viewDrive1541MemoryDataDump->visible = false;
debugInterfaceC64->AddView(viewDrive1541MemoryDataDump2);
viewDrive1541MemoryDataDump2->visible = false;
debugInterfaceC64->AddView(viewDrive1541MemoryDataDump3);
viewDrive1541MemoryDataDump3->visible = false;
debugInterfaceC64->AddView(viewDrive1541MemoryDataWatch);
viewDrive1541MemoryDataWatch->visible = false;
debugInterfaceC64->AddView(viewDrive1541MemoryMap);
viewDrive1541MemoryMap->visible = false;
debugInterfaceC64->AddView(viewC64BreakpointsDrive1541PC);
viewC64BreakpointsDrive1541PC->visible = false;
debugInterfaceC64->AddView(viewC64BreakpointsDrive1541Memory);
viewC64BreakpointsDrive1541Memory->visible = false;
debugInterfaceC64->AddView(viewDrive1541StateVIA);
viewDrive1541StateVIA->visible = false;
debugInterfaceC64->AddView(viewC64MonitorConsole);
viewC64MonitorConsole->visible = false;
debugInterfaceC64->AddView(viewEmulationState);
viewEmulationState->visible = false;
debugInterfaceC64->AddView(viewC64EmulationCounters);
viewC64EmulationCounters->visible = true;
debugInterfaceC64->AddView(viewC64Timeline);
// add c64 screen on top of all other views
// this->AddGuiElement(viewC64Screen);
// this->AddGuiElement(viewC64ScreenWrapper);
// guiMain->AddView(viewC64ScreenWrapper);
}
// ATARI800 views
void CViewC64::InitAtari800Views()
{
///
viewAtariScreen = new CViewAtariScreen("Atari Screen", 510, 40, posZ, 612, 402, debugInterfaceAtari);
viewAtariStateCPU = new CViewAtariStateCPU("Atari CPU", 510, 5, posZ, 350, 35, debugInterfaceAtari);
//
viewAtariMemoryMap = new CViewMemoryMap("Atari Memory map", 190, 20, posZ, 320, 280,
debugInterfaceAtari, debugInterfaceAtari->dataAdapter,
256, 256, 0x10000, true, false); // 256x256 = 64kB
viewAtariDisassembly = new CViewDisassembly("Atari Disassembly", 0, 20, posZ, 190, 420,
debugInterfaceAtari->symbols, NULL, viewAtariMemoryMap);
//
viewAtariBreakpointsPC = new CViewBreakpoints("Atari PC Breakpoints", 70, 70, posZ, 200, 300, this->debugInterfaceAtari->symbols, BREAKPOINT_TYPE_CPU_PC);
viewAtariBreakpointsMemory = new CViewBreakpoints("Atari Memory Breakpoints", 90, 70, posZ, 200, 300, this->debugInterfaceAtari->symbols, BREAKPOINT_TYPE_MEMORY);
//
viewAtariSourceCode = new CViewSourceCode("Atari Assembler source", 40, 70, posZ, 500, 350,
debugInterfaceAtari, debugInterfaceAtari->dataAdapter, viewAtariMemoryMap, viewAtariDisassembly);
viewAtariMemoryDataDump = new CViewDataDump("Atari Memory", 190, 300, posZ, 320, 140,
debugInterfaceAtari->symbols, viewAtariMemoryMap, viewAtariDisassembly);
viewAtariMemoryDataDump->selectedCharset = 2;
//
viewAtariDisassembly->SetViewDataDump(viewAtariMemoryDataDump);
//
viewAtariMemoryDataWatch = new CViewDataWatch("Atari Watches", 140, 140, posZ, 300, 300,
debugInterfaceAtari->symbols, viewAtariMemoryMap);
//
viewAtariStateANTIC = new CViewAtariStateANTIC("Atari ANTIC", 10, 40, posZ, 400, 200, debugInterfaceAtari);
viewAtariStateGTIA = new CViewAtariStateGTIA("Atari GTIA", 10, 40, posZ, 400, 100, debugInterfaceAtari);
viewAtariStatePIA = new CViewAtariStatePIA("Atari PIA", 10, 40, posZ, 200, 60, debugInterfaceAtari);
viewAtariStatePOKEY = new CViewAtariStatePOKEY("Atari POKEY", 10, 40, posZ, 530, 100, debugInterfaceAtari);
viewAtariMonitorConsole = new CViewMonitorConsole("Atari Monitor console", 40, 70, posZ, 500, 300, debugInterfaceAtari);
viewAtariEmulationCounters = new CViewEmulationCounters("Atari Counters", 860, -1.25, posZ, 140, 43, debugInterfaceAtari);
float timelineHeight = 40;
viewAtariTimeline = new CViewTimeline("Atari Timeline", 0, 440, posZ, 700, timelineHeight, debugInterfaceAtari);
// add sorted views
debugInterfaceAtari->AddView(viewAtariScreen);
debugInterfaceAtari->AddView(viewAtariStateCPU);
debugInterfaceAtari->AddView(viewAtariDisassembly);
debugInterfaceAtari->AddView(viewAtariSourceCode);
viewAtariSourceCode->visible = false;
debugInterfaceAtari->AddView(viewAtariMemoryDataDump);
debugInterfaceAtari->AddView(viewAtariMemoryDataWatch);
viewAtariMemoryDataWatch->visible = false;
debugInterfaceAtari->AddView(viewAtariMemoryMap);
debugInterfaceAtari->AddView(viewAtariBreakpointsPC);
viewAtariBreakpointsPC->visible = false;
debugInterfaceAtari->AddView(viewAtariBreakpointsMemory);
viewAtariBreakpointsMemory->visible = false;
debugInterfaceAtari->AddView(viewAtariStateANTIC);
viewAtariStateANTIC->visible = false;
debugInterfaceAtari->AddView(viewAtariStateGTIA);
viewAtariStateGTIA->visible = false;
debugInterfaceAtari->AddView(viewAtariStatePIA);
viewAtariStatePIA->visible = false;
debugInterfaceAtari->AddView(viewAtariStatePOKEY);
viewAtariStatePOKEY->visible = false;
debugInterfaceAtari->AddView(viewAtariMonitorConsole);
viewAtariMonitorConsole->visible = false;
debugInterfaceAtari->AddView(viewAtariEmulationCounters);
viewAtariEmulationCounters->visible = true;
debugInterfaceAtari->AddView(viewAtariTimeline);
}
void CViewC64::InitNestopiaViews()
{
///
viewNesScreen = new CViewNesScreen("NES Screen", 510, 40, posZ, 408, 402, debugInterfaceNes);
viewNesStateCPU = new CViewNesStateCPU("NES CPU", 510, 5, posZ, 290, 35, debugInterfaceNes);
viewNesMemoryMap = new CViewMemoryMap("NES Memory map", 190, 20, posZ, 320, 280,
debugInterfaceNes, debugInterfaceNes->dataAdapter,
256, 256, 0x10000, true, false); // 256x256 = 64kB
viewNesDisassembly = new CViewDisassembly("NES Disassembly", 0, 20, posZ, 190, 424,
debugInterfaceNes->symbols, NULL, viewNesMemoryMap);
//
viewNesBreakpointsPC = new CViewBreakpoints("NES PC Breakpoints", 70, 70, posZ, 200, 300, this->debugInterfaceNes->symbols, BREAKPOINT_TYPE_CPU_PC);
viewNesBreakpointsMemory = new CViewBreakpoints("NES Memory Breakpoints", 90, 70, posZ, 200, 300, this->debugInterfaceNes->symbols, BREAKPOINT_TYPE_MEMORY);
//
viewNesSourceCode = new CViewSourceCode("NES Assembler source", 40, 70, posZ, 500, 350,
debugInterfaceNes, debugInterfaceNes->dataAdapter, viewNesMemoryMap, viewNesDisassembly);
viewNesMemoryDataDump = new CViewDataDump("NES Memory", 190, 300, posZ, 320, 144,
debugInterfaceNes->symbols, viewNesMemoryMap, viewNesDisassembly);
viewNesDisassembly->SetViewDataDump(viewNesMemoryDataDump);
viewNesMemoryDataWatch = new CViewDataWatch("NES Watches", 140, 140, posZ, 300, 300,
debugInterfaceNes->symbols, viewNesMemoryMap);
viewNesPpuNametables = new CViewNesPpuNametables("NES Nametables", 10, 40, posZ, 400, 200, debugInterfaceNes);
viewNesPpuNametableMemoryMap = new CViewMemoryMap("NES Nametables Memory map", 140, 140, posZ, 300, 300, debugInterfaceNes,
debugInterfaceNes->dataAdapterPpuNmt, 64, 64, 0x1000, false, false);
viewNesPpuNametableMemoryDataDump = new CViewDataDump("NES Nametables Memory", 140, 250, posZ, 300, 150,
debugInterfaceNes->symbolsPpuNmt, viewNesPpuNametableMemoryMap, viewNesDisassembly);
debugInterfaceNes->dataAdapterPpuNmt->SetViewMemoryMap(viewNesPpuNametableMemoryMap);
// viewNesDisassemble->SetViewDataDump(viewNesMemoryDataDumpPpuNmt);
viewNesStateAPU = new CViewNesStateAPU("NES APU State", 10, 40, posZ, 820, 200, debugInterfaceNes);
viewNesPianoKeyboard = new CViewNesPianoKeyboard("NES APU Piano Keyboard", 10, 122, posZ, 393, 50, NULL);
viewNesStatePPU = new CViewNesStatePPU("NES PPU State", 10, 40, posZ, 200, 80, debugInterfaceNes);
viewNesPpuPatterns = new CViewNesPpuPatterns("NES PPU Patterns", 10, 40, posZ, 400, 200, debugInterfaceNes);
viewNesPpuAttributes = new CViewNesPpuAttributes("NES PPU Attributes", 10, 40, posZ, 400, 200, debugInterfaceNes);
viewNesPpuOam = new CViewNesPpuOam("NES PPU Oam", 10, 40, posZ, 400, 200, debugInterfaceNes);
viewNesPpuPalette = new CViewNesPpuPalette("NES PPU Palette", 700, 443, posZ, 220, 60, debugInterfaceNes);
viewNesInputEvents = new CViewInputEvents("NES Joysticks", 10, 40, posZ, 150, 310, debugInterfaceNes);
viewNesMonitorConsole = new CViewMonitorConsole("NES Monitor console", 40, 70, posZ, 500, 300, debugInterfaceNes);
viewNesEmulationCounters = new CViewEmulationCounters("NES Counters", 800, -1.25, posZ, 120, 43, debugInterfaceNes);
float timelineHeight = 60;
viewNesTimeline = new CViewTimeline("NES Timeline", 0, 443, posZ, 700, timelineHeight, debugInterfaceNes);
// add sorted views
debugInterfaceNes->AddView(viewNesScreen);
debugInterfaceNes->AddView(viewNesStateCPU);
debugInterfaceNes->AddView(viewNesDisassembly);
debugInterfaceNes->AddView(viewNesSourceCode);
viewNesSourceCode->visible = false;
debugInterfaceNes->AddView(viewNesMemoryDataDump);
debugInterfaceNes->AddView(viewNesMemoryDataWatch);
viewNesMemoryDataWatch->visible = false;
debugInterfaceNes->AddView(viewNesMemoryMap);
debugInterfaceNes->AddView(viewNesBreakpointsPC);
viewNesBreakpointsPC->visible = false;
debugInterfaceNes->AddView(viewNesBreakpointsMemory);
viewNesBreakpointsMemory->visible = false;
debugInterfaceNes->AddView(viewNesStateAPU);
viewNesStateAPU->visible = false;
debugInterfaceNes->AddView(viewNesPianoKeyboard);
viewNesPianoKeyboard->visible = false;
debugInterfaceNes->AddView(viewNesStatePPU);
viewNesStatePPU->visible = false;
debugInterfaceNes->AddView(viewNesPpuPalette);
debugInterfaceNes->AddView(viewNesPpuNametables);
viewNesPpuNametables->visible = false;
debugInterfaceNes->AddView(viewNesPpuNametableMemoryDataDump);
viewNesPpuNametableMemoryDataDump->visible = false;
debugInterfaceNes->AddView(viewNesPpuNametableMemoryMap);
viewNesPpuNametableMemoryMap->visible = false;
debugInterfaceNes->AddView(viewNesPpuPatterns);
viewNesPpuPatterns->visible = false;
debugInterfaceNes->AddView(viewNesPpuAttributes);
viewNesPpuAttributes->visible = false;
debugInterfaceNes->AddView(viewNesPpuOam);
viewNesPpuOam->visible = false;
debugInterfaceNes->AddView(viewNesInputEvents);
viewNesInputEvents->visible = false;
debugInterfaceNes->AddView(viewNesMonitorConsole);
viewNesMonitorConsole->visible = false;
debugInterfaceNes->AddView(viewNesEmulationCounters);
debugInterfaceNes->AddView(viewNesTimeline);
}
// TODO: generalize me
void CViewC64::StartEmulationThread(CDebugInterface *debugInterface)
{
if (debugInterface == debugInterfaceC64)
{
c64SettingsRunVice = true;
StartViceC64EmulationThread();
}
else if (debugInterface == debugInterfaceAtari)
{
c64SettingsRunAtari800 = true;
StartAtari800EmulationThread();
}
else if (debugInterface == debugInterfaceNes)
{
c64SettingsRunNestopia = true;
StartNestopiaEmulationThread();
}
C64DebuggerStoreSettings();
}
void CViewC64::StartViceC64EmulationThread()
{
LOGM("CViewC64::StartViceC64EmulationThread");
if (debugInterfaceC64 != NULL && debugInterfaceC64->IsEmulationRunning() == false)
{
guiMain->LockMutex();
if (emulationThreadC64 == NULL)
{
emulationThreadC64 = new CEmulationThreadC64();
SYS_StartThread(emulationThreadC64, NULL);
}
else
{
// TODO: move me to debuginterface
// restart emulation
debugInterfaceC64->isRunning = true;
debugInterfaceC64->snapshotsManager->ClearSnapshotsHistory();
debugInterfaceC64->HardReset();
debugInterfaceC64->SetDebugMode(DEBUGGER_MODE_RUNNING);
((CDebugInterfaceVice *)debugInterfaceC64)->audioChannel->Start();
((CDebugInterfaceVice *)debugInterfaceC64)->RefreshSync();
}
// add views
for (std::list<CGuiView *>::iterator it = debugInterfaceVice->views.begin(); it != debugInterfaceVice->views.end(); it++)
{
CGuiView *view = *it;
guiMain->AddView(view);
}
guiMain->UnlockMutex();
}
viewC64Screen->SetVisible(true);
// viewC64ScreenWrapper->SetVisible(true);
}
void CViewC64::StartAtari800EmulationThread()
{
LOGM("CViewC64::StartAtari800EmulationThread");
if (debugInterfaceAtari != NULL && debugInterfaceAtari->IsEmulationRunning() == false)
{
guiMain->LockMutex();
if (emulationThreadAtari == NULL)
{
emulationThreadAtari = new CEmulationThreadAtari();
SYS_StartThread(emulationThreadAtari, NULL);
}
else
{
// TODO: move me to debuginterface
// restart emulation
debugInterfaceAtari->isRunning = true;
debugInterfaceAtari->snapshotsManager->ClearSnapshotsHistory();
debugInterfaceAtari->HardReset();
debugInterfaceAtari->SetDebugMode(DEBUGGER_MODE_RUNNING);
debugInterfaceAtari->audioChannel->Start();
}
// add views
for (std::list<CGuiView *>::iterator it = debugInterfaceAtari->views.begin(); it != debugInterfaceAtari->views.end(); it++)
{
CGuiView *view = *it;
guiMain->AddView(view);
}
guiMain->UnlockMutex();
}
viewAtariScreen->SetVisible(true);
}
void CViewC64::StartNestopiaEmulationThread()
{
LOGM("CViewC64::StartNestopiaEmulationThread");
if (debugInterfaceNes != NULL && debugInterfaceNes->IsEmulationRunning() == false)
{
guiMain->LockMutex();
if (emulationThreadNes == NULL)
{
emulationThreadNes = new CEmulationThreadNes();
SYS_StartThread(emulationThreadNes, NULL);
}
else
{
// TODO: move me to debuginterface
// restart emulation
debugInterfaceNes->isRunning = true;
debugInterfaceNes->snapshotsManager->ClearSnapshotsHistory();
debugInterfaceNes->HardReset();
debugInterfaceNes->SetDebugMode(DEBUGGER_MODE_RUNNING);
debugInterfaceNes->audioChannel->Start();
}
// add views
for (std::list<CGuiView *>::iterator it = debugInterfaceNes->views.begin(); it != debugInterfaceNes->views.end(); it++)
{
CGuiView *view = *it;
guiMain->AddView(view);
}
guiMain->UnlockMutex();
}
viewNesScreen->SetVisible(true);
}
// TODO: generalize me
void CViewC64::StopEmulationThread(CDebugInterface *debugInterface)
{
if (debugInterface == debugInterfaceC64)
{
c64SettingsRunVice = false;
StopViceC64EmulationThread();
}
else if (debugInterface == debugInterfaceAtari)
{
c64SettingsRunAtari800 = false;
StopAtari800EmulationThread();
}
else if (debugInterface == debugInterfaceNes)
{
c64SettingsRunNestopia = false;
StopNestopiaEmulationThread();
}
C64DebuggerStoreSettings();
}
void CViewC64::StopViceC64EmulationThread()
{
guiMain->LockMutex();
debugInterfaceC64->LockMutex();
debugInterfaceC64->SetDebugMode(DEBUGGER_MODE_PAUSED);
debugInterfaceC64->snapshotsManager->ClearSnapshotsHistory();
debugInterfaceC64->isRunning = false;
((CDebugInterfaceVice *)debugInterfaceC64)->audioChannel->Stop();
// remove views
for (std::list<CGuiView *>::iterator it = debugInterfaceC64->views.begin(); it != debugInterfaceC64->views.end(); it++)
{
CGuiView *view = *it;
guiMain->RemoveView(view);
}
debugInterfaceC64->UnlockMutex();
guiMain->UnlockMutex();
}
void CViewC64::StopAtari800EmulationThread()
{
guiMain->LockMutex();
debugInterfaceAtari->LockMutex();
debugInterfaceAtari->SetDebugMode(DEBUGGER_MODE_PAUSED);
debugInterfaceAtari->snapshotsManager->ClearSnapshotsHistory();
debugInterfaceAtari->isRunning = false;
debugInterfaceAtari->audioChannel->Stop();
// remove views
for (std::list<CGuiView *>::iterator it = debugInterfaceAtari->views.begin(); it != debugInterfaceAtari->views.end(); it++)
{
CGuiView *view = *it;
guiMain->RemoveView(view);
}
debugInterfaceAtari->UnlockMutex();
guiMain->UnlockMutex();
}
void CViewC64::StopNestopiaEmulationThread()
{
guiMain->LockMutex();
debugInterfaceNes->LockMutex();
debugInterfaceNes->SetDebugMode(DEBUGGER_MODE_PAUSED);
debugInterfaceNes->snapshotsManager->ClearSnapshotsHistory();
debugInterfaceNes->isRunning = false;
debugInterfaceNes->audioChannel->Stop();
// remove views
for (std::list<CGuiView *>::iterator it = debugInterfaceNes->views.begin(); it != debugInterfaceNes->views.end(); it++)
{
CGuiView *view = *it;
guiMain->RemoveView(view);
}
debugInterfaceNes->UnlockMutex();
guiMain->UnlockMutex();
}
void CEmulationThreadC64::ThreadRun(void *data)
{
ThreadSetName("c64");
LOGD("CEmulationThreadC64::ThreadRun");
viewC64->debugInterfaceC64->RunEmulationThread();
LOGD("CEmulationThreadC64::ThreadRun: finished");
}
void CEmulationThreadAtari::ThreadRun(void *data)
{
ThreadSetName("atari");
viewC64->debugInterfaceAtari->SetMachineType(c64SettingsAtariMachineType);
viewC64->debugInterfaceAtari->SetRamSizeOption(c64SettingsAtariRamSizeOption);
viewC64->debugInterfaceAtari->SetVideoSystem(c64SettingsAtariVideoSystem);
LOGD("CEmulationThreadAtari::ThreadRun");
viewC64->debugInterfaceAtari->RunEmulationThread();
LOGD("CEmulationThreadAtari::ThreadRun: finished");
}
void CEmulationThreadNes::ThreadRun(void *data)
{
ThreadSetName("nes");
LOGD("CEmulationThreadNes::ThreadRun");
viewC64->debugInterfaceNes->RunEmulationThread();
LOGD("CEmulationThreadNes::ThreadRun: finished");
}
void CViewC64::DoLogic()
{
// viewC64MemoryMap->DoLogic();
// viewDrive1541MemoryMap->DoLogic();
// if (nextScreenUpdateFrame < frameCounter)
// {
// //RefreshScreen();
//
// nextScreenUpdateFrame = frameCounter;
//
// }
// CGuiView::DoLogic();
}
void CViewC64::Render()
{
// guiMain->fntConsole->BlitText("CViewC64", 0, 0, 0, 31, 1.0);
// Blit(guiMain->imgConsoleFonts, 50, 50, -1, 200, 200);
// BlitRectangle(50, 50, -1, 200, 200, 1, 0, 0, 1);
// // TODO: generalize this, we need a separate entity to run CellsAnimationLogic
//#if defined(RUN_COMMODORE64)
// viewC64MemoryMap->CellsAnimationLogic();
// viewDrive1541MemoryMap->CellsAnimationLogic();
//
// // workaround
// if (viewDrive1541MemoryDataDump->visible)
// {
// // TODO: this is a workaround, we need to store memory cells state in different object than a memory map view!
// // and run it once per frame if needed!!
// // workaround: run logic for cells in drive ROM area because it is not done by memory map view because it is not being displayed
// viewC64->viewDrive1541MemoryMap->DriveROMCellsAnimationLogic();
// }
//#endif
//
//#if defined(RUN_ATARI)
//
// viewAtariMemoryMap->CellsAnimationLogic();
//
//#endif
//
//#if defined(RUN_NES)
//
// viewNesMemoryMap->CellsAnimationLogic();
// viewNesPpuNametableMemoryMap->CellsAnimationLogic();
//
//#endif
guiRenderFrameCounter++;
// if (frameCounter % 2 == 0)
{
//if (viewC64ScreenWrapper->visible) always do this anyway
if (debugInterfaceC64 && debugInterfaceC64->isRunning && viewC64Screen)
{
viewC64StateVIC->UpdateSpritesImages();
viewC64Screen->RefreshScreen();
}
if (debugInterfaceAtari && debugInterfaceAtari->isRunning && viewAtariScreen)
{
viewAtariScreen->RefreshScreen();
}
if (debugInterfaceNes && debugInterfaceNes->isRunning && viewNesScreen)
{
viewNesScreen->RefreshScreen();
}
}
//////////
#ifdef RUN_COMMODORE64
// copy current state of VIC
c64d_vicii_copy_state(&(this->currentViciiState));
viewC64VicDisplay->UpdateViciiState();
this->UpdateViciiColors();
//////////
if (viewC64VicDisplay->canScrollDisassemble)
{
viewC64Disassembly->SetCurrentPC(viciiStateToShow.lastValidPC);
viewC64Disassembly2->SetCurrentPC(viciiStateToShow.lastValidPC);
}
else
{
viewC64Disassembly->SetCurrentPC(this->currentViciiState.lastValidPC);
viewC64Disassembly2->SetCurrentPC(this->currentViciiState.lastValidPC);
}
/// 1541 CPU
C64StateCPU diskCpuState;
debugInterfaceC64->GetDrive1541CpuState(&diskCpuState);
viewDrive1541Disassembly->SetCurrentPC(diskCpuState.lastValidPC);
viewDrive1541Disassembly2->SetCurrentPC(diskCpuState.lastValidPC);
#endif
///
#ifdef RUN_ATARI
viewAtariDisassembly->SetCurrentPC(debugInterfaceAtari->GetCpuPC());
#endif
#ifdef RUN_NES
viewNesDisassembly->SetCurrentPC(debugInterfaceNes->GetCpuPC());
#endif
//
//
// now render all visible views
//
//
// CGuiView::Render();
CGuiView::RenderImGui();
//
// and stuff what is left to render:
//
#ifdef RUN_COMMODORE64
// if (viewC64->viewC64ScreenWrapper->visible)
// {
// viewC64ScreenWrapper->RenderRaster(rasterToShowX, rasterToShowY);
// }
if (viewC64Screen->showZoomedScreen)
{
viewC64Screen->RenderZoomedScreen(rasterToShowX, rasterToShowY);
}
#endif
// check if we need to hide or display cursor
CheckMouseCursorVisibility();
// // debug render fps
// char buf[128];
// sprintf(buf, "%-6.2f %-6.2f", debugInterface->emulationSpeed, debugInterface->emulationFrameRate);
//
// guiMain->fntConsole->BlitText(buf, 0, 0, -1, 15);
}
void CViewC64::RenderImGui()
{
ImGui::SetCurrentFont(imFontDefault);
// ImGui::SetCurrentFont(imFontPro);
// ImGui::SetCurrentFont(imFontSweet16);
// LOGD("guiRenderFrameCounter=%d", guiRenderFrameCounter);
// if (guiRenderFrameCounter == 70)
// {
// viewC64MainMenu->LoadPRG(new CSlrString("/Volumes/Macintosh\ HD/Users/mars/develop/MTEngine/_RUNTIME_/Documents/c64/disks/PartyDog.prg"),
// true, false, true, true);
// }
if (guiMain->IsViewFullScreen() == false)
{
mainMenuBar->RenderImGui();
}
this->Render();
// viewC64Screen->RefreshScreen();
// viewC64Screen->Render();
// viewC64Screen->RenderImGui();
TEST_Editor_Render();
}
///////////////
void CViewC64::UpdateViciiColors()
{
int rasterX = viciiStateToShow.raster_cycle*8;
int rasterY = viciiStateToShow.raster_line;
// update current colors for rendering states
this->rasterToShowX = rasterX;
this->rasterToShowY = rasterY;
this->rasterCharToShowX = (viewC64->viciiStateToShow.raster_cycle - 0x11);
this->rasterCharToShowY = (viewC64->viciiStateToShow.raster_line - 0x32) / 8;
//LOGD(" | rasterCharToShowX=%3d rasterCharToShowY=%3d", rasterCharToShowX, rasterCharToShowY);
if (rasterCharToShowX < 0)
{
rasterCharToShowX = 0;
}
else if (rasterCharToShowX > 39)
{
rasterCharToShowX = 39;
}
if (rasterCharToShowY < 0)
{
rasterCharToShowY = 0;
}
else if (rasterCharToShowY > 24)
{
rasterCharToShowY = 24;
}
// get current VIC State's pointers and colors
u8 *screen_ptr;
u8 *color_ram_ptr;
u8 *chargen_ptr;
u8 *bitmap_low_ptr;
u8 *bitmap_high_ptr;
viewC64->viewC64VicDisplay->GetViciiPointers(&(viewC64->viciiStateToShow),
&screen_ptr, &color_ram_ptr, &chargen_ptr, &bitmap_low_ptr, &bitmap_high_ptr,
this->colorsToShow);
if (viewC64StateVIC->forceColorD800 == -1)
{
this->colorToShowD800 = color_ram_ptr[ rasterCharToShowY * 40 + rasterCharToShowX ] & 0x0F;
}
else
{
this->colorToShowD800 = viewC64StateVIC->forceColorD800;
}
// force D020-D02E colors?
for (int i = 0; i < 0x0F; i++)
{
if (viewC64StateVIC->forceColors[i] != -1)
{
colorsToShow[i] = viewC64StateVIC->forceColors[i];
viewC64->viciiStateToShow.regs[0x20 + i] = viewC64StateVIC->forceColors[i];
}
}
}
void CViewC64::Render(float posX, float posY)
{
CGuiView::Render(posX, posY);
}
bool CViewC64::ButtonClicked(CGuiButton *button)
{
return false;
}
bool CViewC64::ButtonPressed(CGuiButton *button)
{
/*
if (button == btnDone)
{
guiMain->SetView((CGuiView*)guiMain->viewMainEditor);
GUI_SetPressConsumed(true);
return true;
}
*/
return false;
}
bool CViewC64::ProcessKeyboardShortcut(u32 keyCode, u8 actionType, CSlrKeyboardShortcut *shortcut)
{
if (shortcut != NULL)
{
}
return false;
}
// TODO: refactor local viewC64MemoryDataDump->renderDataWithColors to global settings variable
void CViewC64::SwitchIsMulticolorDataDump()
{
if (viewC64->viewC64VicDisplay->visible
|| viewC64->viewVicEditor->visible)
{
viewC64->viewC64VicDisplay->backupRenderDataWithColors = !viewC64->viewC64VicDisplay->backupRenderDataWithColors;
}
else
{
viewC64MemoryDataDump->renderDataWithColors = !viewC64MemoryDataDump->renderDataWithColors;
viewC64->viewC64VicDisplay->backupRenderDataWithColors = viewC64MemoryDataDump->renderDataWithColors;
viewC64AllGraphics->UpdateRenderDataWithColors();
}
}
void CViewC64::SetIsMulticolorDataDump(bool isMultiColor)
{
if (viewC64->viewC64VicDisplay->visible
|| viewC64->viewVicEditor->visible)
{
viewC64->viewC64VicDisplay->backupRenderDataWithColors = isMultiColor;
}
else
{
viewC64MemoryDataDump->renderDataWithColors = isMultiColor;
viewC64->viewC64VicDisplay->backupRenderDataWithColors = isMultiColor;
viewC64AllGraphics->UpdateRenderDataWithColors();
}
}
void CViewC64::SwitchIsShowRasterBeam()
{
this->isShowingRasterCross = !this->isShowingRasterCross;
}
void CViewC64::StepOverInstruction()
{
for (std::vector<CDebugInterface *>::iterator it = debugInterfaces.begin(); it != debugInterfaces.end(); it++)
{
CDebugInterface *debugInterface = *it;
debugInterface->StepOverInstruction();
}
}
void CViewC64::StepOneCycle()
{
for (std::vector<CDebugInterface *>::iterator it = debugInterfaces.begin(); it != debugInterfaces.end(); it++)
{
CDebugInterface *debugInterface = *it;
debugInterface->StepOneCycle();
}
}
void CViewC64::StepBackInstruction()
{
guiMain->LockMutex();
for (std::vector<CDebugInterface *>::iterator it = viewC64->debugInterfaces.begin(); it != viewC64->debugInterfaces.end(); it++)
{
CDebugInterface *debugInterface = *it;
if (debugInterface->isRunning)
{
if (debugInterface->GetDebugMode() == DEBUGGER_MODE_RUNNING
&& !debugInterface->snapshotsManager->IsPerformingSnapshotRestore())
{
debugInterface->SetDebugMode(DEBUGGER_MODE_PAUSED);
}
debugInterface->snapshotsManager->RestoreSnapshotBackstepInstruction();
}
}
guiMain->UnlockMutex();
}
void CViewC64::RunContinueEmulation()
{
for (std::vector<CDebugInterface *>::iterator it = debugInterfaces.begin(); it != debugInterfaces.end(); it++)
{
CDebugInterface *debugInterface = *it;
debugInterface->RunContinueEmulation();
}
}
void CViewC64::HardReset()
{
if (c64SettingsRestartAudioOnEmulationReset)
{
// TODO: gSoundEngine->RestartAudioUnit();
}
// TODO: CViewC64::HardReset make generic & move execute markers to debug interface
if (debugInterfaceC64)
{
debugInterfaceC64->HardReset();
viewC64MemoryMap->ClearExecuteMarkers();
viewC64->viewDrive1541MemoryMap->ClearExecuteMarkers();
}
if (debugInterfaceAtari)
{
debugInterfaceAtari->HardReset();
viewAtariMemoryMap->ClearExecuteMarkers();
}
if (debugInterfaceNes)
{
debugInterfaceNes->HardReset();
LOGTODO(" viewNesMemoryMap !!!!!!!!!! ");
// viewNesMemoryMap->ClearExecuteMarkers();
}
if (c64SettingsIsInVicEditor)
{
viewC64->viewC64VicControl->UnlockAll();
}
}
void CViewC64::SoftReset()
{
if (c64SettingsRestartAudioOnEmulationReset)
{
// TODO: gSoundEngine->RestartAudioUnit();
}
// TODO: make a list of avaliable interfaces and iterate
if (debugInterfaceC64)
{
debugInterfaceC64->Reset();
}
if (debugInterfaceAtari)
{
debugInterfaceAtari->Reset();
}
if (debugInterfaceNes)
{
debugInterfaceNes->Reset();
}
if (c64SettingsIsInVicEditor)
{
viewC64->viewC64VicControl->UnlockAll();
}
}
CViewDisassembly *CViewC64::GetActiveDisassembleView()
{
if (debugInterfaceC64)
{
if (viewC64Disassembly->visible)
return viewC64Disassembly;
if (viewDrive1541Disassembly->visible)
return viewDrive1541Disassembly;
if (viewC64Disassembly2->visible)
return viewC64Disassembly;
if (viewDrive1541Disassembly2->visible)
return viewDrive1541Disassembly;
}
if (debugInterfaceAtari)
{
if (viewAtariDisassembly->visible)
return viewAtariDisassembly;
}
if (debugInterfaceNes)
{
if (viewNesDisassembly)
return viewNesDisassembly;
}
return NULL;
}
void CViewC64::SwitchUseKeyboardAsJoystick()
{
viewC64SettingsMenu->menuItemUseKeyboardAsJoystick->SwitchToNext();
}
// TODO: proper banking
void CViewC64::SwitchIsDataDirectlyFromRam()
{
LOGTODO("CViewC64::SwitchIsDataDirectlyFromRam(): make generic");
if (this->isDataDirectlyFromRAM == false)
{
SwitchIsDataDirectlyFromRam(true);
}
else
{
SwitchIsDataDirectlyFromRam(false);
}
}
void CViewC64::SwitchIsDataDirectlyFromRam(bool setIsDirectlyFromRam)
{
LOGTODO("CViewC64::SwitchIsDataDirectlyFromRam(): make generic");
this->isDataDirectlyFromRAM = setIsDirectlyFromRam;
if (viewC64->debugInterfaceC64)
{
if (setIsDirectlyFromRam == true)
{
viewC64MemoryMap->SetDataAdapter(debugInterfaceC64->dataAdapterC64DirectRam);
viewC64MemoryDataDump->SetDataAdapter(debugInterfaceC64->dataAdapterC64DirectRam);
viewDrive1541MemoryMap->SetDataAdapter(debugInterfaceC64->dataAdapterDrive1541DirectRam);
viewDrive1541MemoryDataDump->SetDataAdapter(debugInterfaceC64->dataAdapterDrive1541DirectRam);
// viewAtariMemoryMap->isDataDirectlyFromRAM = true;
// viewAtariMemoryDataDump->SetDataAdapter(debugInterfaceAtari->data)
}
else
{
viewC64MemoryMap->SetDataAdapter(debugInterfaceC64->dataAdapterC64);
viewC64MemoryDataDump->SetDataAdapter(debugInterfaceC64->dataAdapterC64);
viewDrive1541MemoryMap->SetDataAdapter(debugInterfaceC64->dataAdapterDrive1541);
viewDrive1541MemoryDataDump->SetDataAdapter(debugInterfaceC64->dataAdapterDrive1541);
}
viewC64->viewC64AllGraphics->UpdateShowIOButton();
}
else
{
LOGTODO("CViewC64::SwitchIsDataDirectlyFromRam is not supported for this emulator");
}
}
bool CViewC64::CanSelectView(CGuiView *view)
{
if (view->visible && view != viewC64MemoryMap && view != viewDrive1541MemoryMap)
return true;
return false;
}
// TODO: move this to CGuiView
void CViewC64::MoveFocusToNextView()
{
if (focusElement == NULL)
{
SetFocus(traversalOfViews[0]);
return;
}
int selectedViewNum = -1;
for (int i = 0; i < traversalOfViews.size(); i++)
{
CGuiView *view = traversalOfViews[i];
if (view == focusElement)
{
selectedViewNum = i;
break;
}
}
CGuiView *newView = NULL;
for (int z = 0; z < traversalOfViews.size(); z++)
{
selectedViewNum++;
if (selectedViewNum == traversalOfViews.size())
{
selectedViewNum = 0;
}
newView = traversalOfViews[selectedViewNum];
if (CanSelectView(newView))
break;
}
if (CanSelectView(newView))
{
SetFocus(traversalOfViews[selectedViewNum]);
}
else
{
LOGError("CViewC64::MoveFocusToNextView: no visible views");
}
}
void CViewC64::MoveFocusToPrevView()
{
if (focusElement == NULL)
{
SetFocus(traversalOfViews[0]);
return;
}
int selectedViewNum = -1;
for (int i = 0; i < traversalOfViews.size(); i++)
{
CGuiView *view = traversalOfViews[i];
if (view == focusElement)
{
selectedViewNum = i;
break;
}
}
if (selectedViewNum == -1)
{
LOGError("CViewC64::MoveFocusToPrevView: selected view not found");
return;
}
CGuiView *newView = NULL;
for (int z = 0; z < traversalOfViews.size(); z++)
{
selectedViewNum--;
if (selectedViewNum == -1)
{
selectedViewNum = traversalOfViews.size()-1;
}
newView = traversalOfViews[selectedViewNum];
if (CanSelectView(newView))
break;
}
if (CanSelectView(newView))
{
SetFocus(traversalOfViews[selectedViewNum]);
}
else
{
LOGError("CViewC64::MoveFocusToNextView: no visible views");
}
}
//////
extern "C" {
void machine_drive_flush(void);
}
bool CViewC64::KeyDown(u32 keyCode, bool isShift, bool isAlt, bool isControl, bool isSuper)
{
LOGI("CViewC64::KeyDown, keyCode=%4.4x (%d) %c", keyCode, keyCode, keyCode);
#if defined(LOG_KEYBOARD_PRESS_KEY_NAME)
CSlrString *keyCodeStr = SYS_KeyCodeToString(keyCode);
char *str = keyCodeStr->GetStdASCII();
LOGI(" KeyDown=%s", str);
delete [] str;
delete keyCodeStr;
#endif
if (mainMenuBar->KeyDown(keyCode, isShift, isAlt, isControl, isSuper))
return true;
return false;
//#if defined(DEBUG_TEST_CODE)
// if (keyCode == 'a' && isControl)
// {
// VID_TestMenu();
// }
//#endif
// if (keyCode == MTKEY_F2)
// {
// LOGD("@");
// ((CDebugInterfaceVice *)viewC64->debugInterface)->MakeBasicRunC64();
//// ((CDebugInterfaceVice *)viewC64->debugInterface)->SetStackPointerC64(0xFF);
//// ((CDebugInterfaceVice *)viewC64->debugInterface)->SetRegisterA1541(0xFF);
// }
// // debug only
// if (keyCode == MTKEY_F7 && isShift)
// {
// debugInterface->MakeJmpC64(0x2000);
// return true;
// }
//
// if (keyCode == MTKEY_F8 && isShift)
// {
// AddDebugCode();
// return true;
// }
//
//
// if (keyCode == MTKEY_F8 && isShift)
// {
//// debugInterface->SetC64ModelType(4);
//
// MapC64MemoryToFile ("/Users/mars/memorymap");
// guiMain->ShowMessage("mapped");
// return true;
// }
//
// these are very nasty UX workarounds just for now only
//
// if (this->currentScreenLayoutId == SCREEN_LAYOUT_C64_VIC_DISPLAY)
// {
// if (this->focusElement == NULL)
// {
// if (viewC64VicDisplay->KeyDown(keyCode, isShift, isAlt, isControl, isSuper))
// return true;
// }
// }
//
// if (this->currentScreenLayoutId == SCREEN_LAYOUT_C64_ALL_SIDS)
// {
// if (this->focusElement == NULL)
// {
// if (viewC64AllSids->KeyDown(keyCode, isShift, isAlt, isControl, isSuper))
// return true;
// }
// }
/*
// another UX workaround that can be fixed reviewing again the ui events paths
// but this will be anyway scrapped for the new imgui version
if (debugInterfaceC64 && currentScreenLayoutId == SCREEN_LAYOUT_C64_ALL_SIDS)
{
// make spacebar reset tracker views
if (focusElement != viewC64->viewC64Disassemble
&& focusElement != viewC64->viewC64MemoryDataDump
&& focusElement != viewC64->viewC64StateSID
&& focusElement != viewC64->viewC64Screen
&& focusElement != viewC64->viewC64ScreenWrapper)
{
if (keyCode == MTKEY_SPACEBAR || keyCode == MTKEY_ARROW_UP || keyCode == MTKEY_ARROW_DOWN
|| keyCode == MTKEY_PAGE_UP || keyCode == MTKEY_PAGE_DOWN)
{
return viewC64->viewC64AllSids->KeyDown(keyCode, isShift, isAlt, isControl, isSuper);
}
}
}
if (keyCode >= MTKEY_F1 && keyCode <= MTKEY_F8 && !isControl)
{
if (debugInterfaceC64 && viewC64ScreenWrapper->hasFocus)
{
return viewC64ScreenWrapper->KeyDown(keyCode, isShift, isAlt, isControl, isSuper);
}
if (debugInterfaceAtari && viewAtariScreen->hasFocus)
{
return viewAtariScreen->KeyDown(keyCode, isShift, isAlt, isControl, isSuper);
}
if (debugInterfaceNes && viewNesScreen->hasFocus)
{
return viewNesScreen->KeyDown(keyCode, isShift, isAlt, isControl, isSuper);
}
}
*/
// TODO: is this needed?
/*
// TODO: this is a temporary UX workaround for step over jsr
CSlrKeyboardShortcut *shortcut = guiMain->keyboardShortcuts->FindShortcut(KBZONE_DISASSEMBLE, keyCode, isShift, isAlt, isControl, isSuper);
if (shortcut == mainMenuBar->kbsStepOverJsr)
{
if (this->debugInterfaceC64)
{
if (focusElement != viewDrive1541Disassemble && viewC64Disassemble->visible)
{
viewC64Disassemble->StepOverJsr();
return true;
}
if (focusElement != viewC64Disassemble && viewDrive1541Disassemble->visible)
{
viewDrive1541Disassemble->StepOverJsr();
return true;
}
}
if (this->debugInterfaceAtari)
{
viewAtariDisassemble->StepOverJsr();
return true;
}
if (this->debugInterfaceNes)
{
viewNesDisassemble->StepOverJsr();
return true;
}
}
*/
//
// end of UX workarounds
//
// if (focusElement != NULL)
// {
// if (focusElement->KeyDown(keyCode, isShift, isAlt, isControl, isSuper))
// {
// keyDownCodes.push_back(keyCode);
// return true;
// }
// }
//
// UX workarounds
//
// // if in vic display layout key was not consumed key by focused view, pass it to vic display
// if (this->currentScreenLayoutId == SCREEN_LAYOUT_C64_VIC_DISPLAY)
// {
// if (viewC64VicDisplay->KeyDown(keyCode, isShift, isAlt, isControl, isSuper))
// return true;
// }
// if (debugInterfaceC64 && viewC64ScreenWrapper->hasFocus)
// {
// return viewC64ScreenWrapper->KeyDown(keyCode, isShift, isAlt, isControl, isSuper);
// }
//
// if (debugInterfaceAtari && viewAtariScreen->hasFocus)
// {
// return viewAtariScreen->KeyDown(keyCode, isShift, isAlt, isControl, isSuper);
// }
//
// if (debugInterfaceNes && viewNesScreen->hasFocus)
// {
// return viewNesScreen->KeyDown(keyCode, isShift, isAlt, isControl, isSuper);
// }
return false; //CGuiView::KeyDown(keyCode, isShift, isAlt, isControl, isSuper);
}
bool CViewC64::KeyUp(u32 keyCode, bool isShift, bool isAlt, bool isControl, bool isSuper)
{
LOGI("CViewC64::KeyUp, keyCode=%d isShift=%d isAlt=%d isControl=%d", keyCode, isShift, isAlt, isControl);
#if defined(LOG_KEYBOARD_PRESS_KEY_NAME)
CSlrString *keyCodeStr = SYS_KeyCodeToString(keyCode);
char *str = keyCodeStr->GetStdASCII();
LOGI(" KeyUp=%s", str);
delete [] str;
delete keyCodeStr;
#endif
if (keyCode >= MTKEY_F1 && keyCode <= MTKEY_F8 && !guiMain->isControlPressed)
{
if (debugInterfaceC64 && debugInterfaceC64->isRunning && viewC64Screen->hasFocus)
{
return viewC64Screen->KeyUp(keyCode, isShift, isAlt, isControl, isSuper);
}
if (debugInterfaceAtari && debugInterfaceAtari->isRunning && viewAtariScreen->hasFocus)
{
return viewAtariScreen->KeyUp(keyCode, isShift, isAlt, isControl, isSuper);
}
if (debugInterfaceNes && debugInterfaceNes->isRunning && viewNesScreen->hasFocus)
{
return viewNesScreen->KeyUp(keyCode, isShift, isAlt, isControl, isSuper);
}
}
//
// TODO: another nasty UX workaround for memory map, generalize me
//
if (debugInterfaceC64 && debugInterfaceC64->isRunning && viewC64MemoryMap->visible)
{
if (keyCode == MTKEY_SPACEBAR && !isShift && !isAlt && !isControl)
{
if (viewC64MemoryMap->IsInside(guiMain->mousePosX, guiMain->mousePosY))
{
this->SetFocus(viewC64MemoryMap);
if (viewC64MemoryMap->KeyUp(keyCode, isShift, isAlt, isControl, isSuper))
return true;
}
}
}
if (debugInterfaceAtari && debugInterfaceAtari->isRunning && viewAtariMemoryMap->visible)
{
if (keyCode == MTKEY_SPACEBAR && !isShift && !isAlt && !isControl)
{
if (viewAtariMemoryMap->IsInside(guiMain->mousePosX, guiMain->mousePosY))
{
this->SetFocus(viewAtariMemoryMap);
if (viewAtariMemoryMap->KeyUp(keyCode, isShift, isAlt, isControl, isSuper))
return true;
}
}
}
if (debugInterfaceNes && debugInterfaceNes->isRunning && viewNesMemoryMap->visible)
{
if (keyCode == MTKEY_SPACEBAR && !isShift && !isAlt && !isControl)
{
if (viewNesMemoryMap->IsInside(guiMain->mousePosX, guiMain->mousePosY))
{
this->SetFocus(viewNesMemoryMap);
if (viewNesMemoryMap->KeyUp(keyCode, isShift, isAlt, isControl, isSuper))
return true;
}
}
}
// // check if shortcut
// std::list<u32> zones;
// zones.push_back(KBZONE_GLOBAL);
//
// CSlrKeyboardShortcut *shortcut = guiMain->keyboardShortcuts->FindShortcut(zones, keyCode, isShift, isAlt, isControl, isSuper);
// if (shortcut != NULL)
// return true;
//
// if (focusElement != NULL)
// {
// if (focusElement->KeyUp(keyCode, isShift, isAlt, isControl, isSuper))
// {
// keyDownCodes.remove(keyCode);
// return true;
// }
// }
//
// for (std::list<u32>::iterator it = keyDownCodes.begin(); it != keyDownCodes.end(); it++)
// {
// if (keyCode == *it)
// {
// keyDownCodes.remove(keyCode);
// return true;
// }
// }
// TODO: is this correct?
if (debugInterfaceC64 && debugInterfaceC64->isRunning && viewC64Screen->visible)
{
viewC64Screen->KeyUp(keyCode, isShift, isAlt, isControl, isSuper);
}
if (debugInterfaceAtari && debugInterfaceAtari->isRunning && viewAtariScreen->visible)
{
viewAtariScreen->KeyUp(keyCode, isShift, isAlt, isControl, isSuper);
}
if (debugInterfaceNes && debugInterfaceNes->isRunning && viewNesScreen->visible)
{
viewNesScreen->KeyUp(keyCode, isShift, isAlt, isControl, isSuper);
}
return false; //CGuiView::KeyUp(keyCode, isShift, isAlt, isControl, isSuper);
}
bool CViewC64::KeyDownRepeat(u32 keyCode, bool isShift, bool isAlt, bool isControl, bool isSuper)
{
return false;
}
//@returns is consumed
bool CViewC64::DoTap(float x, float y)
{
LOGG("CViewC64::DoTap: x=%f y=%f", x, y);
for (std::vector<CDebugInterface *>::iterator it = viewC64->debugInterfaces.begin(); it != viewC64->debugInterfaces.end(); it++)
{
CDebugInterface *debugInterface = *it;
debugInterface->MouseDown(x, y);
}
// TODO: is this ok?
return false;
for (std::map<float, CGuiElement *, compareZupwards>::iterator enumGuiElems = guiElementsUpwards.begin();
enumGuiElems != guiElementsUpwards.end(); enumGuiElems++)
{
CGuiElement *guiElement = (*enumGuiElems).second;
LOGG("check inside=%s", guiElement->name);
if (guiElement->visible == false)
continue;
if (guiElement->IsInside(x, y))
{
LOGG("... is inside=%s", guiElement->name);
// let view decide what to do even if it does not have focus
guiElement->DoTap(x, y);
if (guiElement->IsFocusable() && ((focusElement != guiElement) || (guiElement->hasFocus == false)))
{
SetFocus((CGuiView *)guiElement);
}
}
}
return true;
//return CGuiView::DoTap(x, y);
}
bool CViewC64::DoRightClick(float x, float y)
{
return false;
}
bool CViewC64::DoFinishRightClick(float x, float y)
{
return false;
}
// scroll only where cursor is moving
bool CViewC64::DoNotTouchedMove(float x, float y)
{
// LOGG("CViewC64::DoNotTouchedMove, mouseCursor=%f %f", mouseCursorX, mouseCursorY);
if (guiMain->IsMouseCursorVisible() == false)
{
guiMain->SetMouseCursorVisible(true);
mouseCursorVisibilityCounter = 0;
}
mouseCursorX = x;
mouseCursorY = y;
return false;
return CGuiView::DoNotTouchedMove(x, y);
}
bool CViewC64::DoScrollWheel(float deltaX, float deltaY)
{
LOGG("CViewC64::DoScrollWheel, mouseCursor=%f %f", mouseCursorX, mouseCursorY);
// TODO: ugly hack, fix me
#if defined(RUN_COMMODORE64)
if (viewC64Screen->showZoomedScreen)
{
if (viewC64Screen->IsInsideZoomedScreen(mouseCursorX, mouseCursorY))
{
viewC64Screen->DoScrollWheel(deltaX, deltaY);
return true;
}
}
#endif
return false;
}
bool CViewC64::DoFinishTap(float x, float y)
{
LOGG("CViewC64::DoFinishTap: %f %f", x, y);
for (std::vector<CDebugInterface *>::iterator it = viewC64->debugInterfaces.begin(); it != viewC64->debugInterfaces.end(); it++)
{
CDebugInterface *debugInterface = *it;
debugInterface->MouseUp(x, y);
}
return false;
// return CGuiView::DoFinishTap(x, y);
}
//@returns is consumed
bool CViewC64::DoDoubleTap(float x, float y)
{
LOGG("CViewC64::DoDoubleTap: x=%f y=%f", x, y);
return false;
// return CGuiView::DoDoubleTap(x, y);
}
bool CViewC64::DoFinishDoubleTap(float x, float y)
{
LOGG("CViewC64::DoFinishTap: %f %f", x, y);
return false;
// return CGuiView::DoFinishDoubleTap(x, y);
}
bool CViewC64::DoMove(float x, float y, float distX, float distY, float diffX, float diffY)
{
// LOGD("CViewC64::DoMove");
return false;
return CGuiView::DoMove(x, y, distX, distY, diffX, diffY);
}
bool CViewC64::FinishMove(float x, float y, float distX, float distY, float accelerationX, float accelerationY)
{
return false;
// return CGuiView::FinishMove(x, y, distX, distY, accelerationX, accelerationY);
}
bool CViewC64::InitZoom()
{
return false;
return CGuiView::InitZoom();
}
bool CViewC64::DoZoomBy(float x, float y, float zoomValue, float difference)
{
return false;
return CGuiView::DoZoomBy(x, y, zoomValue, difference);
}
bool CViewC64::DoMultiTap(COneTouchData *touch, float x, float y)
{
return false;
return CGuiView::DoMultiTap(touch, x, y);
}
bool CViewC64::DoMultiMove(COneTouchData *touch, float x, float y)
{
return false;
return CGuiView::DoMultiMove(touch, x, y);
}
bool CViewC64::DoMultiFinishTap(COneTouchData *touch, float x, float y)
{
return false;
return CGuiView::DoMultiFinishTap(touch, x, y);
}
void CViewC64::FinishTouches()
{
return;
// return CGuiView::FinishTouches();
}
bool CViewC64::KeyPressed(u32 keyCode, bool isShift, bool isAlt, bool isControl, bool isSuper)
{
return false;
return CGuiView::KeyPressed(keyCode, isShift, isAlt, isControl, isSuper);
}
void CViewC64::ActivateView()
{
LOGG("CViewC64::ActivateView()");
}
void CViewC64::DeactivateView()
{
LOGG("CViewC64::DeactivateView()");
}
void CViewC64::ApplicationEnteredBackground()
{
LOGG("CViewC64::ApplicationEnteredBackground");
// workaround for alt+tab
// TODO: generalize me
if (this->debugInterfaceC64)
{
viewC64Screen->KeyUpModifierKeys(true, true, true);
}
if (this->debugInterfaceAtari)
{
viewAtariScreen->KeyUpModifierKeys(true, true, true);
}
if (this->debugInterfaceNes)
{
viewNesScreen->KeyUpModifierKeys(true, true, true);
}
}
void CViewC64::ApplicationEnteredForeground()
{
LOGG("CViewC64::ApplicationEnteredForeground");
// workaround for alt+tab
if (this->debugInterfaceC64)
{
viewC64Screen->KeyUpModifierKeys(true, true, true);
}
if (this->debugInterfaceAtari)
{
viewAtariScreen->KeyUpModifierKeys(true, true, true);
}
if (this->debugInterfaceNes)
{
viewNesScreen->KeyUpModifierKeys(true, true, true);
}
}
#if defined(RUN_ATARI)
extern "C" {
void MEMORY_GetCharsetScreenCodes(u8 *cs);
}
#endif
ImFont *AddSweet16MonoFont();
void CViewC64::CreateFonts()
{
fontDisassembly = guiMain->fntConsole;
fontDisassemblyInverted = guiMain->fntConsoleInverted;
CreateDefaultUIFont();
Create8BitFonts();
}
void CViewC64::Create8BitFonts()
{
// u64 t1 = SYS_GetCurrentTimeInMillis();
uint8 *charRom = debugInterfaceVice->GetCharRom();
uint8 *charData;
charData = charRom;
fontCBM1 = ProcessFonts(charData, true);
charData = charRom + 0x0800;
fontCBM2 = ProcessFonts(charData, true);
fontCBMShifted = ProcessFonts(charData, false);
fontAtari = NULL;
#if defined(RUN_ATARI)
u8 charRomAtari[0x0800];
MEMORY_GetCharsetScreenCodes(charRomAtari);
fontAtari = ProcessFonts(charRomAtari, true);
#endif
// u64 t2 = SYS_GetCurrentTimeInMillis();
// LOGD("time=%u", t2-t1);
}
void CViewC64::CreateDefaultUIFont()
{
ImGuiIO& io = ImGui::GetIO();
#if defined(MACOS)
config->GetString("uiDefaultFont", &defaultFontPath, "CousineRegular");
config->GetFloat("uiDefaultFontSize", &defaultFontSize, 16.0f);
config->GetInt("uiDefaultFontOversampling", &defaultFontOversampling, 8);
#else
config->GetString("uiDefaultFont", &defaultFontPath, "Sweet16");
config->GetFloat("uiDefaultFontSize", &defaultFontSize, 16.0f);
config->GetInt("uiDefaultFontOversampling", &defaultFontOversampling, 4);
#endif
defaultFontSize = URANGE(4, viewC64->defaultFontSize, 64);
defaultFontOversampling = URANGE(1, viewC64->defaultFontOversampling, 8);
if (!strcmp(defaultFontPath, "ProFontIIx"))
{
imFontDefault = AddProFontIIx(defaultFontSize, defaultFontOversampling);
}
else if (!strcmp(defaultFontPath, "Sweet16"))
{
imFontDefault = AddSweet16MonoFont(defaultFontSize, defaultFontOversampling);
}
else if (!strcmp(defaultFontPath, "CousineRegular"))
{
imFontDefault = AddCousineRegularFont(defaultFontSize, defaultFontOversampling);
}
else if (!strcmp(defaultFontPath, "DroidSans"))
{
imFontDefault = AddDroidSansFont(defaultFontSize, defaultFontOversampling);
}
else if (!strcmp(defaultFontPath, "KarlaRegular"))
{
imFontDefault = AddKarlaRegularFont(defaultFontSize, defaultFontOversampling);
}
else if (!strcmp(defaultFontPath, "RobotoMedium"))
{
imFontDefault = AddRobotoMediumFont(defaultFontSize, defaultFontOversampling);
}
else
{
ImFontConfig fontConfig = ImFontConfig();
fontConfig.SizePixels = defaultFontSize;
fontConfig.OversampleH = defaultFontOversampling;
fontConfig.OversampleV = defaultFontOversampling;
imFontDefault = io.Fonts->AddFontDefault();
}
// else if (!strcmp(defaultFontPath, "Custom"))
// {
//
// }
}
void CViewC64::UpdateDefaultUIFontFromSettings()
{
CUiThreadTaskSetDefaultUiFont *task = new CUiThreadTaskSetDefaultUiFont();
guiMain->AddUiThreadTask(task);
}
void CUiThreadTaskSetDefaultUiFont::RunUIThreadTask()
{
ImGuiIO& io = ImGui::GetIO();
io.Fonts->Clear();
viewC64->CreateDefaultUIFont();
guiMain->CreateUiFontsTexture();
}
// TODO: this is called by emulator code when frame is started (i.e. just after VSync)
// note that this assumes we have *ONE* emulator working (the C64 Vice is supported by now)
// this *MUST* be refactored as different emulation engines will have different frame rates/syncs
void CViewC64::EmulationStartFrameCallback(CDebugInterface *debugInterface)
{
// TODO: jukebox is supported only for C64
if (viewJukeboxPlaylist != NULL)
{
viewJukeboxPlaylist->EmulationStartFrame();
}
// TODO: we have a plugin->DoFrame() after frame canvas refresh, shall we have a VSync too for plugins?
// Note: VSync is before screen bitmap refresh
}
///
void CViewC64::MapC64MemoryToFile(char *filePath)
{
mappedC64Memory = SYS_MapMemoryToFile(C64_RAM_SIZE, filePath, (void**)&mappedC64MemoryDescriptor);
}
void CViewC64::UnMapC64MemoryFromFile()
{
SYS_UnMapMemoryFromFile(mappedC64Memory, C64_RAM_SIZE, (void**)&mappedC64MemoryDescriptor);
mappedC64Memory = NULL;
mappedC64MemoryDescriptor = NULL;
}
void CViewC64::SharedMemorySignalCallback(CByteBuffer *sharedMemoryData)
{
LOGD("CViewC64::SharedMemorySignalCallback");
C64DebuggerReceivedConfiguration(sharedMemoryData);
}
void CViewC64::InitRasterColors()
{
viewC64VicDisplay->InitRasterColorsFromScheme();
viewC64Screen->InitRasterColorsFromScheme();
viewVicEditor->viewVicDisplayMain->InitGridLinesColorFromSettings();
}
void CViewC64::ToggleSoundMute()
{
this->SetSoundMute(!this->isSoundMuted);
}
void CViewC64::SetSoundMute(bool isMuted)
{
this->isSoundMuted = isMuted;
UpdateSIDMute();
}
void CViewC64::UpdateSIDMute()
{
LOGD("CViewC64::UpdateSIDMute: isSoundMuted=%s", STRBOOL(isSoundMuted));
if (debugInterfaceC64 == NULL)
return;
// logic to control "only mute volume" or "skip SID emulation"
if (this->isSoundMuted == false)
{
// start sound
debugInterfaceC64->SetAudioVolume((float)(c64SettingsAudioVolume) / 100.0f);
debugInterfaceC64->SetRunSIDEmulation(c64SettingsRunSIDEmulation);
}
else
{
// stop sound
debugInterfaceC64->SetAudioVolume(0.0f);
if (c64SettingsMuteSIDMode == MUTE_SID_MODE_SKIP_EMULATION)
{
debugInterfaceC64->SetRunSIDEmulation(false);
}
}
}
void CViewC64::CheckMouseCursorVisibility()
{
// LOGD("CViewC64::CheckMouseCursorVisibility: %f %f %f %f", guiMain->mousePosX, guiMain->mousePosY, SCREEN_WIDTH, SCREEN_HEIGHT);
if (guiMain->IsViewFullScreen())
{
if (guiMain->IsMouseCursorVisible() == false)
{
// cursor is already hidden
return;
}
// cursor is visible
if (mouseCursorNumFramesToHideCursor > 0
&& mouseCursorVisibilityCounter > mouseCursorNumFramesToHideCursor)
{
// hide cursor
guiMain->SetMouseCursorVisible(false);
mouseCursorVisibilityCounter = 0;
}
else
{
mouseCursorVisibilityCounter++;
}
}
else
{
// not fullscreen, show cursor
if (guiMain->IsMouseCursorVisible() == false)
{
mouseCursorVisibilityCounter = 0;
guiMain->SetMouseCursorVisible(true);
}
}
}
void CViewC64::ShowMouseCursor()
{
guiMain->SetMouseCursorVisible(true);
}
void CViewC64::GoFullScreen(CGuiView *view)
{
if (view != NULL)
{
guiMain->SetViewFullScreen(view);
}
else
{
guiMain->SetApplicationWindowFullScreen(true);
}
}
void CViewC64::ToggleFullScreen(CGuiView *view)
{
if (guiMain->IsViewFullScreen())
{
guiMain->SetViewFullScreen(NULL);
return;
}
if (guiMain->IsApplicationWindowFullScreen())
{
guiMain->SetApplicationWindowFullScreen(false);
return;
}
if (view != NULL)
{
guiMain->SetViewFullScreen(view);
return;
}
guiMain->SetApplicationWindowFullScreen(true);
}
CDebugInterface *CViewC64::GetDebugInterface(u8 emulatorType)
{
switch(emulatorType)
{
case EMULATOR_TYPE_C64_VICE:
return (CDebugInterface*)viewC64->debugInterfaceC64;
case EMULATOR_TYPE_ATARI800:
return (CDebugInterface*)viewC64->debugInterfaceAtari;
case EMULATOR_TYPE_NESTOPIA:
return (CDebugInterface*)viewC64->debugInterfaceNes;
default:
return NULL;
}
}
int CViewC64::CountRunningDebugInterfaces()
{
int runningInterfaces = 0;
for (std::vector<CDebugInterface *>::iterator it = debugInterfaces.begin(); it != debugInterfaces.end(); it++)
{
CDebugInterface *debugInterface = *it;
if (debugInterface->isRunning)
{
runningInterfaces++;
}
}
return runningInterfaces;
}
bool CViewC64::IsOnlyOneDebugInterfaceRunning()
{
return (CountRunningDebugInterfaces() == 1);
}
void CViewC64::CreateEmulatorPlugins()
{
C64D_InitPlugins();
}
// REMOVE THESE OLD DIALOGS
void CViewC64::ShowDialogOpenFile(CSystemFileDialogCallback *callback, std::list<CSlrString *> *extensions,
CSlrString *defaultFolder,
CSlrString *windowTitle)
{
// return;
// LOGTODO("ShowDialogOpenFile CHECK MEMORY LEAKS");
if (c64SettingsUseSystemFileDialogs)
{
SYS_DialogOpenFile(callback, extensions, defaultFolder, windowTitle);
}
else
{
fileDialogPreviousView = guiMain->currentView;
systemFileDialogCallback = callback;
CSlrString *directoryPath;
if (defaultFolder != NULL)
{
directoryPath = new CSlrString(defaultFolder);
}
else
{
directoryPath = new CSlrString("/");
}
viewSelectFile->Init(directoryPath, extensions);
}
}
void CViewC64::FileSelected(CSlrString *filePath)
{
LOGTODO("ShowDialogOpenFile CHECK MEMORY LEAKS");
CSlrString *file = new CSlrString(filePath);
systemFileDialogCallback->SystemDialogFileOpenSelected(file);
}
void CViewC64::FileSelectionCancelled()
{
systemFileDialogCallback->SystemDialogFileOpenCancelled();
}
void CViewC64::ShowDialogSaveFile(CSystemFileDialogCallback *callback, std::list<CSlrString *> *extensions,
CSlrString *defaultFileName, CSlrString *defaultFolder,
CSlrString *windowTitle)
{
LOGTODO("ShowDialogOpenFile CHECK MEMORY LEAKS");
if (c64SettingsUseSystemFileDialogs)
{
SYS_DialogSaveFile(callback, extensions, defaultFileName, defaultFolder, windowTitle);
}
else
{
fileDialogPreviousView = guiMain->currentView;
systemFileDialogCallback = callback;
CSlrString *directoryPath;
if (defaultFolder != NULL)
{
directoryPath = new CSlrString(defaultFolder);
}
else
{
directoryPath = new CSlrString("/");
}
CSlrString *firstExtension = extensions->front();
viewSaveFile->Init(defaultFileName, firstExtension, directoryPath);
}
}
void CViewC64::SaveFileSelected(CSlrString *fullFilePath, CSlrString *fileName)
{
CSlrString *file = new CSlrString(fullFilePath);
systemFileDialogCallback->SystemDialogFileSaveSelected(file);
}
void CViewC64::SaveFileSelectionCancelled()
{
systemFileDialogCallback->SystemDialogFileSaveCancelled();
}
char *CViewC64::ATRD_GetPathForRoms_IMPL()
{
LOGD("CViewC64::ATRD_GetPathForRoms_IMPL");
char *buf;
if (c64SettingsPathToAtariROMs == NULL)
{
buf = new char[MAX_BUFFER];
sprintf(buf, ".");
}
else
{
buf = c64SettingsPathToAtariROMs->GetStdASCII();
}
// sprintf(buf, "%s/debugroms", gPathToDocuments);
LOGD("ATRD_GetPathForRoms_IMPL path=%s", buf);
LOGM("buf is=%s", buf);
return buf;
}
void CViewC64::ApplicationShutdown()
{
LOGD("CViewC64::ApplicationShutdown");
_exit(0);
guiMain->RemoveAllViews();
if (viewC64->debugInterfaceC64)
{
viewC64->debugInterfaceC64->Shutdown();
}
if (viewC64->debugInterfaceAtari)
{
viewC64->debugInterfaceAtari->Shutdown();
}
if (viewC64->debugInterfaceNes)
{
viewC64->debugInterfaceNes->Shutdown();
}
SYS_Sleep(100);
}
void CViewC64::GlobalDropFileCallback(char *filePath, bool consumedByView)
{
// Note: drop event is also routed to a window on which the file is dropped, so we can define how the drop is exactly consumed. if not consumed by window then this is just a global callback to open a file.
LOGD("CViewC64::GlobalDropFileCallback: filePath=%s consumedByView=%s", filePath, STRBOOL(consumedByView));
if (consumedByView == false)
{
if (SYS_GetCurrentTimeInMillis() - c64dStartupTime < 500)
{
LOGD("CViewC64::GlobalDropFileCallback: sleep 500ms");
SYS_Sleep(500);
}
CSlrString *slrPath = new CSlrString(filePath);
viewC64->viewC64MainMenu->LoadFile(slrPath);
delete slrPath;
}
}
void CViewC64::RecentlyOpenedFilesCallbackSelectedMenuItem(CSlrString *filePath)
{
viewC64->viewC64MainMenu->LoadFile(filePath);
}
| 27.580413 | 206 | 0.745769 | [
"render",
"object",
"vector",
"3d"
] |
5bbcb87e4fd2f5940e480bc423ebd4470924bbc4 | 4,491 | cc | C++ | horovod/common/ops/compressed/reducers/mpi_ps.cc | IST-DASLab/horovod | d2611353c33b299f04e47fae0de741702de3130e | [
"Apache-2.0"
] | null | null | null | horovod/common/ops/compressed/reducers/mpi_ps.cc | IST-DASLab/horovod | d2611353c33b299f04e47fae0de741702de3130e | [
"Apache-2.0"
] | null | null | null | horovod/common/ops/compressed/reducers/mpi_ps.cc | IST-DASLab/horovod | d2611353c33b299f04e47fae0de741702de3130e | [
"Apache-2.0"
] | null | null | null | #include "mpi_ps.h"
#include "../utils.h"
namespace horovod {
namespace common {
MPI_Allreduce_PS::MPI_Allreduce_PS(MPIContext* mpi_context,
GPUContext* gpu_context,
HorovodGlobalState* global_state,
Compressor* compressor)
: MPIReducer(mpi_context, gpu_context, global_state, compressor) {
if (global_state->controller->GetLocalRank() == 0) {
LOG(INFO) << "MPI Parameter-Server";
}
}
size_t MPI_Allreduce_PS::GetRequiredFreeSize() {
int world_size;
MPI_CHECK(MPI_Comm_size(comm_, &world_size));
int64_t chunk_size = tensor_fusion_threshold_;
return chunk_size + chunk_size * (world_size - 1);
}
Status MPI_Allreduce_PS::Init(
const std::vector<horovod::common::TensorTableEntry>& entries,
MPI_Comm comm) {
comm_ = comm;
auto& first_entry = entries[0];
int world_size;
MPI_CHECK(MPI_Comm_size(comm_, &world_size));
auto& timeline = global_state_->timeline;
int64_t chunk_size = tensor_fusion_threshold_;
int64_t buffer_size = chunk_size + chunk_size * (world_size - 1);
auto status = bufferManager_.InitializeBuffer(
buffer_size, first_entry.device, first_entry.context,
global_state_->current_nccl_stream,
[&]() { timeline.ActivityStartAll(entries, INIT_FUSION_BUFFER); },
[&]() { timeline.ActivityEndAll(entries); });
if (!status.ok()) {
for (auto& e : entries) {
e.callback(status);
}
return status;
}
auto buffer = bufferManager_.GetBuffer(first_entry.device,
first_entry.context->framework(),
global_state_->current_nccl_stream);
void* buffer_data =
const_cast<void*>(buffer->AccessData(first_entry.context));
gradients_send_ = (unsigned char*)buffer_data;
gradients_recv_ = (unsigned char*)gradients_send_ + chunk_size;
return Reducer::Init(entries);
}
Status MPI_Allreduce_PS::AllreduceDivision(
int num_elements, std::vector<horovod::common::TensorTableEntry>& entries,
unsigned char* buffer_ptr, int global_offset) {
int world_size, rank;
MPI_CHECK(MPI_Comm_size(comm_, &world_size));
MPI_CHECK(MPI_Comm_rank(comm_, &rank));
auto& timeline = global_state_->timeline;
gpuStream_t stream =
gpu_context_
->streams[global_state_->current_nccl_stream][entries[0].device];
timeline.ActivityStartAll(entries, Q_COMPRESSION);
int64_t send_rcv_size = 0;
int op;
if (rank == 0) {
std::vector<MPI_Request> requests;
std::vector<int> idx_map;
send_rcv_size =
ALIGNED_SIZE(compressor_->BufferSize(num_elements, entries, 0));
// First round.
// Collect all gradients, decompress and aggregate them.
for (int node_rank = 1; node_rank < world_size; node_rank++) {
requests.push_back(MPI_Request());
MPI_CHECK(MPI_Irecv(gradients_recv_ + (node_rank - 1) * send_rcv_size,
send_rcv_size, MPI_UNSIGNED_CHAR, node_rank, 0, comm_,
&requests.back()));
idx_map.push_back(node_rank - 1);
}
while (requests.size() > 0) {
int req_idx;
MPI_Waitany((int)requests.size(), requests.data(), &req_idx,
MPI_STATUSES_IGNORE);
int idx = idx_map[req_idx];
requests.erase(requests.begin() + req_idx);
idx_map.erase(idx_map.begin() + req_idx);
compressor_->Decompress(gradients_recv_ + idx * send_rcv_size, buffer_ptr,
entries, 0, num_elements, true, &stream);
}
// Second round.
// Broadcast the result
compressor_->Compress(buffer_ptr, gradients_send_, entries, 0,
global_offset, num_elements, true, &stream);
gpu_context_->StreamSynchronize(stream);
} else {
send_rcv_size = ALIGNED_SIZE(
compressor_->Compress(buffer_ptr, gradients_send_, entries, 0,
global_offset, num_elements, false, &stream));
gpu_context_->StreamSynchronize(stream);
MPI_CHECK(MPI_Send(gradients_send_, send_rcv_size, MPI_UNSIGNED_CHAR, 0, 0,
comm_));
}
MPI_CHECK(
MPI_Bcast(gradients_send_, send_rcv_size, MPI_UNSIGNED_CHAR, 0, comm_));
compressor_->Decompress(gradients_send_, buffer_ptr, entries, 0, num_elements,
false, &stream);
gpu_context_->StreamSynchronize(stream);
return Status::OK();
}
} // namespace common
} // namespace horovod | 37.739496 | 80 | 0.657537 | [
"vector"
] |
5bc06c6243450e578464c2d49161da3990d0279f | 3,922 | cpp | C++ | cpp/arrayMisc/minWindowSubstr.cpp | locmpham/codingtests | 3805fc98c0fa0dbee52e12531f6205e77b52899e | [
"MIT"
] | null | null | null | cpp/arrayMisc/minWindowSubstr.cpp | locmpham/codingtests | 3805fc98c0fa0dbee52e12531f6205e77b52899e | [
"MIT"
] | null | null | null | cpp/arrayMisc/minWindowSubstr.cpp | locmpham/codingtests | 3805fc98c0fa0dbee52e12531f6205e77b52899e | [
"MIT"
] | 1 | 2021-07-09T19:13:11.000Z | 2021-07-09T19:13:11.000Z | /*
LEETCODE# 76
Given two strings s and t of lengths m and n respectively, return the minimum window substring
of s such that every character in t (including duplicates) is included in the window.
If there is no such substring, return the empty string "".
The testcases will be generated such that the answer is unique.
A substring is a contiguous sequence of characters within the string.
Example 1:
Input: s = "ADOBECODEBANC", t = "ABC"
Output: "BANC"
Explanation: The minimum window substring "BANC" includes 'A', 'B', and 'C' from string t.
Example 2:
Input: s = "a", t = "a"
Output: "a"
Explanation: The entire string s is the minimum window.
Example 3:
Input: s = "a", t = "aa"
Output: ""
Explanation: Both 'a's from t must be included in the window.
Since the largest window of s only has one 'a', return empty string.
Constraints:
m == s.length
n == t.length
1 <= m, n <= 105
s and t consist of uppercase and lowercase English letters.
*/
#include <iostream>
#include <vector>
using namespace std;
// String t could have repetion of chars and thefore, could be very long.
// Characters in either string could be upper case or lower case.
//
// Use a unordered_map<char, int> (hash) to store chars in t to optimize space.
// char is used as the hash key and int is to count the repetition of char in string t.
// Use an int as counter to quickly check when all chars in t are matched.
//
string minWindow(string s, string t) {
string minStr; // keep track of minimun string
vector<int> tTable(128, INT_MIN); // record chars in string t with repetition cover a-z/A-Z
int tlen = t.length();
int slen = s.length();
int cnt = 0; // number of distinct chars
//cout << "s: " << s << endl;
//cout << "t: " << t << endl;
if (slen == 0 || slen < tlen)
return ""; // no match
if (tlen == 0) {
return s; // no matching need to be done
}
// 1. Conver t string into a table recording chars in string t and their repetition
// Location 0 of table records the tlen
//
tTable[0] = tlen;
for (int i = 0; i < tlen; i++) {
if (tTable[t[i]] == INT_MIN) {
tTable[t[i]] = 1;
cnt++; // number of distinct chars
}
else
tTable[t[i]]++; // same char could occur more than once
}
// 2. Use left and right pointers to scan for match of condition
// Move right pointer until the condition is met, then move left until the
// condition is unmet.
//
// 3. Record the min length of matching substring limited by left and right
//
int left = 0;
int right = 0;
for (int right = 0; right < slen; right++) {
char ch = s[right];
if (tTable[ch] == INT_MIN)
continue;
tTable[ch]--;
if (tTable[ch] == 0)
cnt--;
if (cnt == 0) { // All found?
// Move left pointer till condition is unmet
while (cnt == 0) {
char ch = s[left++];
if (tTable[ch] == 0) {
cnt++;
}
tTable[ch]++;
}
// Yes, record the shortest so far
int subStrLen = right - left + 2;
if (minStr.length() == 0 || minStr.length() > subStrLen) {
minStr = s.substr(left-1, subStrLen);
}
}
}
return minStr;
}
int main() {
cout << "s='ADOBECODEBANC', t='ABC' --> " << minWindow("ADOBECODEBANC", "ABC") << endl;
cout << "s='a', t='a' --> " << minWindow("a", "a") << endl;
cout << "s='a', t='aa' --> " << minWindow("a", "aa") << endl;
return 0;
}
| 29.938931 | 99 | 0.539266 | [
"vector"
] |
5bc79127b7e16881ce991c8fdd1a9d90ae7da82d | 7,823 | cpp | C++ | src/Mod2Engine/Mod2_Thread.cpp | karannewatia/SCALE-MAMBA | 467b33a6c80050789204ea3ee3b5cf0113354f85 | [
"BSD-2-Clause"
] | 196 | 2018-05-25T11:41:56.000Z | 2022-03-12T05:49:50.000Z | src/Mod2Engine/Mod2_Thread.cpp | karannewatia/SCALE-MAMBA | 467b33a6c80050789204ea3ee3b5cf0113354f85 | [
"BSD-2-Clause"
] | 49 | 2018-07-17T15:49:41.000Z | 2021-01-19T11:35:31.000Z | src/Mod2Engine/Mod2_Thread.cpp | karannewatia/SCALE-MAMBA | 467b33a6c80050789204ea3ee3b5cf0113354f85 | [
"BSD-2-Clause"
] | 90 | 2018-05-25T11:41:42.000Z | 2022-03-23T19:15:10.000Z | /*
Copyright (c) 2017, The University of Bristol, Senate House, Tyndall Avenue, Bristol, BS8 1TH, United Kingdom.
Copyright (c) 2021, COSIC-KU Leuven, Kasteelpark Arenberg 10, bus 2452, B-3001 Leuven-Heverlee, Belgium.
All rights reserved
*/
#include "Mod2_Thread.h"
#include <unistd.h>
#include "LSSS/Open_Protocol2.h"
#include "Mod2Maurer.h"
#include "Tools/Timer.h"
#include <fstream>
// Checks exit, by player zero making decisions and conveying this
// to all others. This means players are in sync with player zero. Even
// if they know themselves they should die gracefully/wait
// Returns
// 0 = OK, prepare some more stuff
// 1 = Exit
int check_exit(Player &P, unsigned int no_online_threads, offline_control_data &OCD)
{
int result= 1;
string ss= "E";
if (P.whoami() == 0)
{
// Do not die if main offline threads still working
for (unsigned int i= 0; i < no_online_threads; i++)
{
OCD.OCD_mutex[i].lock();
if (OCD.finish_offline[i] != 1)
{
ss= "-";
result= 0;
}
OCD.OCD_mutex[i].unlock();
}
// Do not die if an online thread is still working
for (unsigned int i= 0; i < OCD.finish_offline.size(); i++)
{
OCD.OCD_mutex[i].lock();
if (OCD.finished_online[i] == 0)
{
ss= "-";
result= 0;
}
OCD.OCD_mutex[i].unlock();
}
P.send_all(ss, 2);
}
else
{
P.receive_from_player(0, ss, 2);
if (ss.compare("-") == 0)
{
result= 0;
}
}
return result;
}
extern Mod2_Thread_Data MTD;
/* Entering here assumes the thread is locked */
void Mod2_Thread_Data::Tune(Player &P, PRSS2 &prss, int verbose)
{
B= 3;
C= 64;
// Require (B-1)*log_2 N > SP2017_stat_sec
N= 1UL << (SP2017_stat_sec / (B - 1));
vector<vector<Share2>> Gtriples;
Timer T;
unsigned int best_L= -1;
double bestv= 0;
// L is mult of 64
for (unsigned int L= 64; L <= 2048; L*= 2)
{
X= N / L + C;
T.reset();
T.start();
Gen_Checked_Triples(P, prss, Gtriples, B, C, X, L);
T.stop();
double persec= (Gtriples.size() * 64) / T.elapsed();
triples[0].insert(triples[0].end(), Gtriples.begin(), Gtriples.end());
if (verbose)
{
cout << "Batch Size = (" << N << "," << L << ")" << endl;
cout << "\tPer Second = " << persec << endl;
}
if (persec > bestv)
{
bestv= persec;
best_L= L;
}
}
if (verbose)
{
cout << "Best performance when L = " << best_L << endl;
cout << "\tPer Second = " << bestv << endl;
cout << "Finished Tuning: Generated " << (triples[0].size() * 64) << " triples" << endl;
}
// Player 0 makes the choice as to which L
if (P.whoami() == 0)
{
stringstream ss;
ss << best_L;
P.send_all(ss.str(), 2);
L= best_L;
}
else
{
string ss;
P.receive_from_player(0, ss, 2);
istringstream iss(ss);
iss >> L;
}
X= N / L + C;
if (verbose)
{
cout << "Chosen L = " << L << endl;
}
}
void Mod2_Thread_Data::Update_Queue(unsigned int q, Player &P, PRSS2 &prss)
{
static vector<vector<Share2>> Gtriples;
Gen_Checked_Triples(P, prss, Gtriples, B, C, X, L);
MD2_mutex.lock();
triples[q].insert(triples[q].end(), Gtriples.begin(), Gtriples.end());
MD2_mutex.unlock();
}
// Decide what to make
// Again player 0 makes the decision
// 0 = Nothing
// 1 = Queue 0 only
// 2 = Queue 1 only
// 3 = Queue 0 and 1 only
// 4 = Queue 2 only
// 5 = Queue 0 and 2 only
// .... and so on
int make_Mod2_Thread_decision(Player &P)
{
int result= 0;
string ss= "";
if (P.whoami() == 0)
{ // Decide whether to pause (lists are too big)
MTD.MD2_mutex.lock();
for (unsigned int j= 0; j < MTD.triples.size(); j++)
{
if (MTD.triples[j].size() < max_Mod2_Triple_queue)
{
result+= (1 << j);
ss= ss + "A";
}
else
{
ss= ss + "N";
}
}
MTD.MD2_mutex.unlock();
P.send_all(ss, 0);
}
else
{
P.receive_from_player(0, ss, 0);
for (unsigned int j= 0; j < MTD.triples.size(); j++)
{
if (ss.c_str()[j] == 'A')
{
result+= (1 << j);
}
}
}
return result;
}
void Mod2_Triple_Thread(Player &P, unsigned int no_online_threads,
offline_control_data &OCD, int verbose)
{
PRSS2 prss(P);
MTD.MD2_mutex.lock();
MTD.Tune(P, prss, verbose);
MTD.MD2_mutex.unlock();
while (0 == 0)
{ /* Decide whether to finish */
if (check_exit(P, no_online_threads, OCD) == 1)
{
printf("Exiting Mod2 Triple production thread\n");
return;
}
/* Decide whether to pause (lists are too big) */
int decide= make_Mod2_Thread_decision(P);
if (decide == 0)
{
nanosleep(&time_s, NULL);
}
else
{
for (unsigned int j= 0; j < MTD.triples.size(); j++)
{
if ((decide & 1) == 1)
{
MTD.Update_Queue(j, P, prss);
if (verbose)
{
printf("Size of Triple queue %d : %lu \n", j, MTD.triples[j].size());
}
}
decide>>= 1;
}
}
}
}
void Mod2_Thread_Data::get_Triple(vector<Share2> &T, unsigned int q)
{
bool wait= true;
while (wait)
{
wait= false;
MD2_mutex.lock();
if (triples[q].size() == 0)
{
wait= true;
MD2_mutex.unlock();
nanosleep(&time_s, NULL);
}
}
// At this point the mutex is locked
T= triples[q].front();
triples[q].pop_front();
MD2_mutex.unlock();
}
list<vector<Share2>> Mod2_Thread_Data::get_Triples(unsigned int q, unsigned int num)
{
if (num >= max_Mod2_Triple_queue)
{
throw Mod2Engine_Error("Too many Mod2 triples being requested. Contact the developers");
}
bool wait= true;
while (wait)
{
wait= false;
MD2_mutex.lock();
if (triples[q].size() < num)
{
wait= true;
MD2_mutex.unlock();
//cout << "Waiting to produce " << num << " Mod2Engine Triples" << endl;
nanosleep(&time_s, NULL);
}
}
// At this point the mutex is locked
list<vector<Share2>> ans;
ans.splice(ans.begin(), triples[q], triples[q].begin(), next(triples[q].begin(), num));
MD2_mutex.unlock();
return ans;
}
void Mod2_Thread_Data::get_Single_Triple(vector<Share2> &T, unsigned int q)
{
// Get a new triple if we have run out of the temporary one
if (T_cnt[q] == 64)
{
get_Triple(T_Store[q], q);
T_cnt[q]= 0;
}
T.resize(3);
for (unsigned int i= 0; i < 3; i++)
{
T[i].mul(T_Store[q][i], 1ULL);
T_Store[q][i].SHR(T_Store[q][i], 1);
}
T_cnt[q]++;
}
void Mod2_Thread_Data::get_Single_Triples(vector<vector<Share2>> &T, unsigned int q)
{
unsigned int sz= T.size();
unsigned int sz_big= T.size() / 64;
// First do the full word ones
list<vector<Share2>> lst= get_Triples(q, sz_big);
int cnt= 0;
for (unsigned int i= 0; i < sz_big; i++)
{
vector<Share2> v= lst.front();
lst.pop_front();
for (unsigned int j= 0; j < 64; j++)
{
for (unsigned int k= 0; k < 3; k++)
{
T[cnt][k].mul(v[k], 1ULL);
v[k].SHR(v[k], 1);
}
cnt++;
}
}
for (unsigned int i= cnt; i < sz; i++)
{
get_Single_Triple(T[i], q);
}
}
| 24.370717 | 110 | 0.521156 | [
"vector"
] |
5bcbe20971318642197ef6fb77afdf4acaf39fcd | 15,964 | cc | C++ | src/packet.cc | PetroShevchenko/lib-coap-cpp | f99bff174925257ea63480f598f5753ece0f392d | [
"Apache-2.0"
] | null | null | null | src/packet.cc | PetroShevchenko/lib-coap-cpp | f99bff174925257ea63480f598f5753ece0f392d | [
"Apache-2.0"
] | null | null | null | src/packet.cc | PetroShevchenko/lib-coap-cpp | f99bff174925257ea63480f598f5753ece0f392d | [
"Apache-2.0"
] | null | null | null | #include <cstring>
#include <cstdlib>
#include <climits>
#include <algorithm>
#include <ctime>
#ifdef STM32H747I_DISCO
#include "lwip.h"
#else
#include <arpa/inet.h>
#endif
#include "packet.h"
#include "log.h"
#include "error.h"
LOG_USING_NAMESPACE
LOG_EXTERN_DECLARE
namespace coap{
packet * packet::_instanceP = 0;
packetDestroyer packet::_destroyer;
error packet::_error;
packet & packet::createInstance()
{
if (!_instanceP) {
_instanceP = new packet();
_destroyer.initialize(_instanceP);
}
return *_instanceP;
}
bool packet::clearInstance(packet & instance)
{
if (&instance != _instanceP) {
return false;
}
//TODO: clear all fields of instance
_instanceP->_message.headerInfo.asByte = 0;
_instanceP->_message.code.asByte = 0;
_instanceP->_message.messageId = 0;
std::memset(_instanceP->_message.token, 0, TOKEN_MAX_LENGTH);
_instanceP->_message.payload.clear();
return true;
}
packet::packet(): _is_little_endian(true), _option_bitmap{0,0}, _message()
{
LOG(DEBUGGING,"Entering");
_message.headerInfo.asByte = 0;
_message.code.asByte = 0;
_message.messageId = 0;
_is_little_endian = is_little_endian_byte_order();
_option_bitmap[0] = 0;
_option_bitmap[1] = 0;
LOG(INFO,"Arhitecture of the CPU is (1 - Little Endian, 0 - Big Endian): ", _is_little_endian);
LOG(DEBUGGING,"Leaving");
}
packet::~packet()
{
//LOG_DELETE;
}
packetDestroyer::~packetDestroyer()
{
delete packetDestroyer::_instanceP;
}
void packetDestroyer::initialize(packet * p)
{
packetDestroyer::_instanceP = p;
}
std::ostream & operator<<(std::ostream & os,const packet::option_t &option)
{
os << "option #" << static_cast<unsigned short>(option.number) <<
" delta: " << static_cast<unsigned short>(option.header.asBitfield.delta) <<
" length: " << static_cast<unsigned short>(option.header.asBitfield.length) <<
" value: ";
for(auto v:option.value)
os << static_cast<int>(v) << " ";
return os;
}
std::ostream & operator<<(std::ostream & os,const packet::header_t &header)
{
os << " version: " << static_cast<unsigned short>(header.asBitfield.version) <<
" type: " << static_cast<unsigned short>(header.asBitfield.type) <<
" tokenLength: " << static_cast<unsigned short>(header.asBitfield.tokenLength)
;
return os;
}
std::ostream & operator<<(std::ostream & os,const packet::code_t &code)
{
os << " codeClass: " << static_cast<unsigned short>(code.asBitfield.codeClass) <<
" codeDetail: " << static_cast<unsigned short>(code.asBitfield.codeDetail)
;
return os;
}
template <typename T>
std::ostream & operator<<(std::ostream & os,const std::vector<T> &v)
{
for (auto i : v)
os << i << "\t";
return os;
}
std::ostream & operator<<(std::ostream & os,const packet::message_t &message)
{
os << message.headerInfo << message.code <<
" messageId: " << message.messageId <<
" token: ";
for(auto i : message.token)
os << static_cast<int>(i) << " ";
os <<
" options: " << message.options <<
" \npayloadOffset: " << message.payloadOffset <<
" \npayload: \n";
for(auto i : message.payload)
os << static_cast<int>(i) << " ";
os <<
" \npayload length: " << message.payload.size();
return os;
}
std::ostream & operator<<(std::ostream & os,const packet &object)
{
os << object._message;
return os;
}
bool packet::parse_header(const std::uint8_t * buffer, const size_t length)
{
assert(buffer != nullptr);
LOG(DEBUGGING, "Entering");
if (length < PACKET_MIN_LENGTH) {
_error.set_code(WRONG_ARGUMENT);
LOG(logging::ERROR, "Length of buffer is too short, must be at least ", PACKET_MIN_LENGTH, " bytes, but equals ", length);
return false;
}
set_message_headerInfo(buffer[0]);
if (COAP_VERSION != get_message_version()) {
_error.set_code(PROTOCOL_VERSION);
LOG(logging::ERROR, _error.get_message());
return false;
}
set_message_code(buffer[1]);
if (get_is_little_endian()) {
set_message_messageId(static_cast<std::uint16_t>(buffer[3] | (buffer[2] << 8)));
}
else {
set_message_messageId(static_cast<std::uint16_t>(buffer[2] | (buffer[3] << 8)));
}
LOG(DEBUGGING, "Leaving");
return true;
}
bool packet::parse_token(const std::uint8_t * buffer, const size_t length)
{
assert(buffer != nullptr);
std::memset(_message.token, 0, TOKEN_MAX_LENGTH);
if (0 == get_message_tokenLength()) {
LOG(DEBUGGING,"Token is not presented into the packet");
return true;
}
if (get_message_tokenLength() > TOKEN_MAX_LENGTH ||
length < PACKET_HEADER_SIZE + static_cast<size_t>(get_message_tokenLength())) {
_error.set_code(TOKEN_LENGTH);
LOG(logging::ERROR, "Wrong the token lenght, that equals ", get_message_tokenLength(), "(0...8), and a packet length is ", length);
return false;
}
std::memcpy(_message.token, static_cast<const void *>(buffer + PACKET_HEADER_SIZE), get_message_tokenLength());
return true;
}
bool packet::parse_options(const std::uint8_t * buffer, const size_t length)
{
assert(buffer != nullptr);
const std::uint8_t * startOptions = buffer + PACKET_HEADER_SIZE + _message.headerInfo.asBitfield.tokenLength;
const size_t optionsOffset = static_cast<size_t>(startOptions - buffer);
size_t i = 0;
option_t opt;
uint16_t optDelta = 0;
uint16_t optLength = 0;
uint16_t optNumber = 0;
LOG(DEBUGGING,"Entering");
LOG(DEBUGGING,"optionsOffset = ", optionsOffset);
clean_options();
for (i = optionsOffset; buffer[i] != _message.payloadMarker && i < length; i += optLength)
{
opt.header.asByte = buffer[i];
optDelta = opt.header.asBitfield.delta ;
optLength = opt.header.asBitfield.length;
LOG(DEBUGGING,"opt.header.asBitfield.delta = ", static_cast<int>(opt.header.asBitfield.delta));
LOG(DEBUGGING,"opt.header.asBitfield.length = ", static_cast<int>(opt.header.asBitfield.length));
auto option_parser = [&](std::uint8_t parsing, std::uint16_t * modifying )->bool
{
if (parsing == MINUS_THIRTEEN) {
if (i + 1 > length) return false;
*modifying = buffer[i + 1] + MINUS_THIRTEEN_OPT_VALUE;
i += sizeof(std::uint8_t);
}
else if (parsing == MINUS_TWO_HUNDRED_SIXTY_NINE) {
if (i + 2 > length) return false;
if (get_is_little_endian())
{
*modifying = buffer[i + 1] | (buffer[i + 2] << 8);
}
else {
*modifying = buffer[i + 2] | (buffer[i + 1] << 8);
}
*modifying += MINUS_TWO_HUNDRED_SIXTY_NINE_OPT_VALUE;
i += sizeof(std::uint16_t);
}
else if (parsing == RESERVED_FOR_FUTURE) return false;
return true;
};
if ( !option_parser (opt.header.asBitfield.delta, &optDelta) ) {
_error.set_code(WRONG_OPTION_DELTA);
LOG(logging::ERROR, _error.get_message());
return false;
}
if ( !option_parser (opt.header.asBitfield.length, &optLength) ) {
_error.set_code(WRONG_OPTION_LENGTH);
LOG(logging::ERROR, _error.get_message());
return false;
}
i++;
if ((buffer + i + optLength) > (buffer + length)) {
_error.set_code(WRONG_OPTION_LENGTH);
LOG(logging::ERROR,"Length of option is too long");
return false;
}
optNumber += optDelta;
opt.number = optNumber;
LOG(DEBUGGING,"optLength = ", optLength);
for (int j = 0; j < optLength; j++)
{
LOG(DEBUGGING,"buffer[i + j] = ", static_cast<int>(buffer[i + j]));
opt.value.push_back( buffer[i + j] );
}
_message.options.push_back(opt);
opt.clear();
}
_message.payloadOffset = i + sizeof(_message.payloadMarker);
LOG(DEBUGGING,"Leaving");
return true;
}
bool packet::parse_payload(const std::uint8_t * buffer, const size_t length)
{
assert(buffer != nullptr);
assert(length >= _message.payloadOffset);
const size_t maxPayloadOffset = length - _message.payloadOffset;
for (size_t i = 0; i < maxPayloadOffset; i++)
_message.payload.push_back(buffer[_message.payloadOffset + i]);
return true;
}
bool packet::parse(const std::uint8_t * buffer, const size_t length)
{
bool returnCode = false;
assert(buffer != nullptr);
assert(length != 0);
returnCode = parse_header(buffer, length);
if (!returnCode) return returnCode;
returnCode = parse_token(buffer, length);
if (!returnCode) return returnCode;
returnCode = parse_options(buffer, length);
if (!returnCode) return returnCode;
returnCode = parse_payload(buffer, length);
return returnCode;
}
void packet::set_option_bitmap (std::uint8_t number)
{
if (number > 31)
_option_bitmap[1] |= (1 << (number - 32));
else
_option_bitmap[0] |= (1 << number);
}
bool packet::is_option_set(std::uint8_t number)
{
if (number > 31)
return _option_bitmap[1] & (1 << (number - 32));
else
return _option_bitmap[0] & (1 << number);
}
const packet::option_t * packet::find_options(const std::uint16_t number, size_t * quantity)
{
int min = 0 , max = _message.options.size(), mid = 0;
assert(quantity != nullptr);
LOG(DEBUGGING, "Entering");
*quantity = 0;
std::sort(_message.options.begin(), _message.options.end(), compare_options);
for(auto opt: _message.options)
{
LOG(DEBUGGING, "opt = ", (int)opt.number);
}
LOG(DEBUGGING,"compared option number", (int)number);
while (min <= max)
{
mid = (min + max) >> 1;
LOG(DEBUGGING,"current option number is ", _message.options[mid].number);
if ( _message.options[mid].number < number) {
min = mid + 1;
}
else if (_message.options[mid].number > number) {
max = mid - 1;
}
else {
int index = mid;
while (index >= min)
{
if (_message.options[--index].number != number) {
min = index + 1;
break;
}
}
while (_message.options[++index].number == number)
{
(*quantity)++;
}
LOG(DEBUGGING, "Leaving");
return &_message.options[mid];
}
}
LOG(DEBUGGING, "Leaving");
return nullptr;
}
std::uint8_t packet::get_option_nibble(uint32_t value)
{
std::uint8_t nibble = 0;
if (value < MINUS_THIRTEEN_OPT_VALUE) {
nibble = value & 0xFF;
}
else if (value <= 0xFF + MINUS_THIRTEEN_OPT_VALUE) {
nibble = MINUS_THIRTEEN;
}
else if (value <= 0xFFFF + MINUS_TWO_HUNDRED_SIXTY_NINE_OPT_VALUE) {
nibble = MINUS_TWO_HUNDRED_SIXTY_NINE;
}
return nibble;
}
bool packet::serialize(std::uint8_t * buffer, size_t * length, bool checkBufferSizeOnly)
{
size_t offset = 0;
assert(length != nullptr);
if (!checkBufferSizeOnly) {
assert(buffer != nullptr);
assert(*length >= static_cast<unsigned>(PACKET_MIN_LENGTH + _message.headerInfo.asBitfield.tokenLength));
}
if (!checkBufferSizeOnly) {
buffer [HEADER_OFFSET] = _message.headerInfo.asByte;
buffer [CODE_OFFSET] = _message.code.asByte;
}
offset = MESSAGE_ID_OFFSET;
if (!checkBufferSizeOnly) {
if (get_is_little_endian()) {
buffer [offset] = (_message.messageId >> 8 ) & 0xFF;
buffer [offset + 1] = _message.messageId & 0xFF;
}
else {
buffer [offset] = _message.messageId & 0xFF;
buffer [offset + 1] = (_message.messageId >> 8 ) & 0xFF;
}
}
offset = TOKEN_OFFSET;
size_t tokenLength = static_cast<size_t>(_message.headerInfo.asBitfield.tokenLength);
if (tokenLength > TOKEN_MAX_LENGTH) {
LOG(DEBUGGING,"Token length is wrong");
_error.set_code(TOKEN_LENGTH);
return false;
}
if (tokenLength != 0 && !checkBufferSizeOnly) std::memcpy (buffer + offset, _message.token, tokenLength);
offset += tokenLength;
if (!checkBufferSizeOnly) assert(offset < *length);
std::uint8_t optNumDelta = 0;
std::uint32_t optDelta = 0;
for (auto opt : _message.options)
{
std::uint8_t lengthNibble = 0;
std::uint8_t deltaNibble = 0;
auto option_maker = [&](std::uint8_t firstParsing, std::uint8_t secondParsing)
{
if (firstParsing == MINUS_THIRTEEN) {
if (checkBufferSizeOnly) offset++;
else buffer [offset++] = secondParsing - MINUS_THIRTEEN_OPT_VALUE;
}
else if (firstParsing == MINUS_TWO_HUNDRED_SIXTY_NINE) {
if (checkBufferSizeOnly) offset += 2;
else {
buffer [offset++] = (secondParsing - MINUS_TWO_HUNDRED_SIXTY_NINE_OPT_VALUE) >> 8;
buffer [offset++] = (secondParsing - MINUS_TWO_HUNDRED_SIXTY_NINE_OPT_VALUE) & 0xFF;
}
}
if (!checkBufferSizeOnly) assert(offset < *length);
};
if (!checkBufferSizeOnly && offset > *length) {
LOG(DEBUGGING, "The buffer length is too small");
_error.set_code(BUFFER_LENGTH);
return false;
}
optDelta = opt.number - optNumDelta;
deltaNibble = get_option_nibble(optDelta);
lengthNibble = get_option_nibble(static_cast<std::uint32_t>(opt.value.size()));
if (!checkBufferSizeOnly) {
buffer [offset++] = (deltaNibble << 4 | lengthNibble) & 0xFF;
assert(offset < *length);
}
else offset++;
option_maker (deltaNibble, optDelta);
option_maker (lengthNibble, static_cast<std::uint8_t>(opt.value.size()));
if (!checkBufferSizeOnly) std::memcpy (buffer + offset, opt.value.data(), opt.value.size());
offset += opt.value.size();
if (!checkBufferSizeOnly) assert(offset <= *length);
optNumDelta = opt.number;
}
size_t optionsLength = offset - tokenLength - PACKET_HEADER_SIZE;
if (_message.payload.size() == 0) {
*length = offset;
}
else {
if (!checkBufferSizeOnly && *length < PACKET_HEADER_SIZE + tokenLength + optionsLength
+ sizeof(_message.payloadMarker) + _message.payload.size()) {
LOG(DEBUGGING, "The buffer length is too small");
_error.set_code(BUFFER_LENGTH);
return false;
}
offset = PACKET_HEADER_SIZE + tokenLength + optionsLength;
if (!checkBufferSizeOnly) {
assert(offset < *length);
buffer [offset] = _message.payloadMarker;
}
offset += sizeof(_message.payloadMarker);
if (!checkBufferSizeOnly) {
assert(offset < *length);
assert(offset + _message.payload.size() <= *length);
std::memcpy (buffer + offset, _message.payload.data(), _message.payload.size());
}
*length = offset + _message.payload.size();
}
return true;
}
/* value should be written in network byte order */
void packet::add_option(option_number_t number, const std::uint8_t * value, const size_t length)
{
assert(value != nullptr);
assert(number <= OPTION_MAX_NUMBER);
assert(length <= OPTION_MAX_LENGTH);
option_t option;
option.header.asByte = 0;
option.number = static_cast<std::uint8_t>(number);
for(size_t i = 0; i < length; i++)
{
option.value.push_back(value[i]);
}
_message.options.push_back(option);
std::sort(_message.options.begin(), _message.options.end());
set_option_bitmap(option.number);
}
bool packet::generate_token(int tokenLength)
{
if (tokenLength < 0 && tokenLength > 8) return false;
srand(time(nullptr));
for (int i = 0; i < tokenLength; i++)
{
_message.token[i] = static_cast<std::uint8_t>(rand() % (UCHAR_MAX + 1));
}
set_message_tokenLength(static_cast<std::uint8_t>(tokenLength));
return true;
}
std::uint16_t packet::generate_message_id()
{
srand(time(nullptr));
return static_cast<std::uint16_t>(rand() % (USHRT_MAX + 1));
}
/* Before calling of this method you should call add_option to create needed options.
payload should be in network bytes order
*/
void packet::make_request(message_type_t messageType, message_code_t code, std::uint16_t messageId,
std::size_t tokenLength, const std::uint8_t * payload, const size_t payloadLength)
{
assert(tokenLength <= 8);
LOG(DEBUGGING,"Entering");
set_message_version(COAP_VERSION);
set_message_type(static_cast<std::uint8_t>(messageType));
set_message_messageId(messageId);
set_message_code(static_cast<std::uint8_t>(code));
if (tokenLength > 0) generate_token(tokenLength);
_message.payload.clear();
if (payloadLength > 0) {
for (size_t i = 0; i < payloadLength; i++)
{
_message.payload.push_back(payload[i]);
}
}
LOG(DEBUGGING,"Leaving");
}
void packet::prepare_answer(message_type_t messageType, std::uint16_t messageId, message_code_t responseCode,
const std::uint8_t * payload, const size_t payloadLength)
{
set_message_version(COAP_VERSION);
set_message_type(static_cast<std::uint8_t>(messageType));
set_message_messageId(messageId);
set_message_code(static_cast<std::uint8_t>(responseCode));
_message.payload.clear();
if (payloadLength > 0) {
for (size_t i = 0; i < payloadLength; i++)
{
_message.payload.push_back(payload[i]);
}
}
}
}//coap
| 28.155203 | 133 | 0.69425 | [
"object",
"vector"
] |
5bcf00684f571b41da8382c3a26437529fad6436 | 5,737 | hpp | C++ | Versionen/2021_06_15/rmf_ws/install/rmf_traffic_msgs/include/rmf_traffic_msgs/msg/detail/timespan__struct.hpp | flitzmo-hso/flitzmo_agv_control_system | 99e8006920c03afbd93e4c7d38b4efff514c7069 | [
"MIT"
] | null | null | null | Versionen/2021_06_15/rmf_ws/install/rmf_traffic_msgs/include/rmf_traffic_msgs/msg/detail/timespan__struct.hpp | flitzmo-hso/flitzmo_agv_control_system | 99e8006920c03afbd93e4c7d38b4efff514c7069 | [
"MIT"
] | null | null | null | Versionen/2021_06_15/rmf_ws/install/rmf_traffic_msgs/include/rmf_traffic_msgs/msg/detail/timespan__struct.hpp | flitzmo-hso/flitzmo_agv_control_system | 99e8006920c03afbd93e4c7d38b4efff514c7069 | [
"MIT"
] | 2 | 2021-06-21T07:32:09.000Z | 2021-08-17T03:05:38.000Z | // generated from rosidl_generator_cpp/resource/idl__struct.hpp.em
// with input from rmf_traffic_msgs:msg/Timespan.idl
// generated code does not contain a copyright notice
#ifndef RMF_TRAFFIC_MSGS__MSG__DETAIL__TIMESPAN__STRUCT_HPP_
#define RMF_TRAFFIC_MSGS__MSG__DETAIL__TIMESPAN__STRUCT_HPP_
#include <rosidl_runtime_cpp/bounded_vector.hpp>
#include <rosidl_runtime_cpp/message_initialization.hpp>
#include <algorithm>
#include <array>
#include <memory>
#include <string>
#include <vector>
#ifndef _WIN32
# define DEPRECATED__rmf_traffic_msgs__msg__Timespan __attribute__((deprecated))
#else
# define DEPRECATED__rmf_traffic_msgs__msg__Timespan __declspec(deprecated)
#endif
namespace rmf_traffic_msgs
{
namespace msg
{
// message struct
template<class ContainerAllocator>
struct Timespan_
{
using Type = Timespan_<ContainerAllocator>;
explicit Timespan_(rosidl_runtime_cpp::MessageInitialization _init = rosidl_runtime_cpp::MessageInitialization::ALL)
{
if (rosidl_runtime_cpp::MessageInitialization::ALL == _init ||
rosidl_runtime_cpp::MessageInitialization::ZERO == _init)
{
this->has_lower_bound = false;
this->lower_bound = 0ll;
this->has_upper_bound = false;
this->upper_bound = 0ll;
}
}
explicit Timespan_(const ContainerAllocator & _alloc, rosidl_runtime_cpp::MessageInitialization _init = rosidl_runtime_cpp::MessageInitialization::ALL)
{
(void)_alloc;
if (rosidl_runtime_cpp::MessageInitialization::ALL == _init ||
rosidl_runtime_cpp::MessageInitialization::ZERO == _init)
{
this->has_lower_bound = false;
this->lower_bound = 0ll;
this->has_upper_bound = false;
this->upper_bound = 0ll;
}
}
// field types and members
using _maps_type =
std::vector<std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other>, typename ContainerAllocator::template rebind<std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other>>::other>;
_maps_type maps;
using _has_lower_bound_type =
bool;
_has_lower_bound_type has_lower_bound;
using _lower_bound_type =
int64_t;
_lower_bound_type lower_bound;
using _has_upper_bound_type =
bool;
_has_upper_bound_type has_upper_bound;
using _upper_bound_type =
int64_t;
_upper_bound_type upper_bound;
// setters for named parameter idiom
Type & set__maps(
const std::vector<std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other>, typename ContainerAllocator::template rebind<std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other>>::other> & _arg)
{
this->maps = _arg;
return *this;
}
Type & set__has_lower_bound(
const bool & _arg)
{
this->has_lower_bound = _arg;
return *this;
}
Type & set__lower_bound(
const int64_t & _arg)
{
this->lower_bound = _arg;
return *this;
}
Type & set__has_upper_bound(
const bool & _arg)
{
this->has_upper_bound = _arg;
return *this;
}
Type & set__upper_bound(
const int64_t & _arg)
{
this->upper_bound = _arg;
return *this;
}
// constant declarations
// pointer types
using RawPtr =
rmf_traffic_msgs::msg::Timespan_<ContainerAllocator> *;
using ConstRawPtr =
const rmf_traffic_msgs::msg::Timespan_<ContainerAllocator> *;
using SharedPtr =
std::shared_ptr<rmf_traffic_msgs::msg::Timespan_<ContainerAllocator>>;
using ConstSharedPtr =
std::shared_ptr<rmf_traffic_msgs::msg::Timespan_<ContainerAllocator> const>;
template<typename Deleter = std::default_delete<
rmf_traffic_msgs::msg::Timespan_<ContainerAllocator>>>
using UniquePtrWithDeleter =
std::unique_ptr<rmf_traffic_msgs::msg::Timespan_<ContainerAllocator>, Deleter>;
using UniquePtr = UniquePtrWithDeleter<>;
template<typename Deleter = std::default_delete<
rmf_traffic_msgs::msg::Timespan_<ContainerAllocator>>>
using ConstUniquePtrWithDeleter =
std::unique_ptr<rmf_traffic_msgs::msg::Timespan_<ContainerAllocator> const, Deleter>;
using ConstUniquePtr = ConstUniquePtrWithDeleter<>;
using WeakPtr =
std::weak_ptr<rmf_traffic_msgs::msg::Timespan_<ContainerAllocator>>;
using ConstWeakPtr =
std::weak_ptr<rmf_traffic_msgs::msg::Timespan_<ContainerAllocator> const>;
// pointer types similar to ROS 1, use SharedPtr / ConstSharedPtr instead
// NOTE: Can't use 'using' here because GNU C++ can't parse attributes properly
typedef DEPRECATED__rmf_traffic_msgs__msg__Timespan
std::shared_ptr<rmf_traffic_msgs::msg::Timespan_<ContainerAllocator>>
Ptr;
typedef DEPRECATED__rmf_traffic_msgs__msg__Timespan
std::shared_ptr<rmf_traffic_msgs::msg::Timespan_<ContainerAllocator> const>
ConstPtr;
// comparison operators
bool operator==(const Timespan_ & other) const
{
if (this->maps != other.maps) {
return false;
}
if (this->has_lower_bound != other.has_lower_bound) {
return false;
}
if (this->lower_bound != other.lower_bound) {
return false;
}
if (this->has_upper_bound != other.has_upper_bound) {
return false;
}
if (this->upper_bound != other.upper_bound) {
return false;
}
return true;
}
bool operator!=(const Timespan_ & other) const
{
return !this->operator==(other);
}
}; // struct Timespan_
// alias to use template instance with default allocator
using Timespan =
rmf_traffic_msgs::msg::Timespan_<std::allocator<void>>;
// constant definitions
} // namespace msg
} // namespace rmf_traffic_msgs
#endif // RMF_TRAFFIC_MSGS__MSG__DETAIL__TIMESPAN__STRUCT_HPP_
| 31.010811 | 298 | 0.738714 | [
"vector"
] |
5bd849be63b9ef68069dd7c1cbdebf22af853cd6 | 840 | cpp | C++ | src/dioptre/physics/component.cpp | tobscher/rts | 7f30faf6a13d309e4db828be8be3c05d28c05364 | [
"MIT"
] | 2 | 2015-05-14T16:07:30.000Z | 2015-07-27T21:08:48.000Z | src/dioptre/physics/component.cpp | tobscher/rts | 7f30faf6a13d309e4db828be8be3c05d28c05364 | [
"MIT"
] | null | null | null | src/dioptre/physics/component.cpp | tobscher/rts | 7f30faf6a13d309e4db828be8be3c05d28c05364 | [
"MIT"
] | null | null | null | #include "dioptre/physics/component.h"
#include "dioptre/locator.h"
namespace dioptre {
namespace physics {
Component::Component(RigidBody *rigidBody)
: dioptre::ComponentInterface("dioptre.physics.component"),
rigidBody_(rigidBody) {
auto physicsService = dioptre::Locator::getInstance<PhysicsInterface>(
dioptre::Module::M_PHYSICS);
auto world = physicsService->getWorld();
world->add(rigidBody);
rigidBody->setComponent(this);
transformObserver_ = new dioptre::physics::TransformObserver(this);
}
int Component::initialize() {
dioptre::ComponentInterface::initialize();
rigidBody_->initialize();
auto transform = object_->getTransform();
transform->attach(transformObserver_);
return 0;
}
void Component::update() {}
Component::~Component() { delete rigidBody_; }
} // physics
} // dioptre
| 22.702703 | 72 | 0.730952 | [
"transform"
] |
5bdd60015c85c75b7af266d5618e847aa1d60279 | 1,514 | cpp | C++ | cpp/src/pairwise_consistency_maximization/third_parties/fast_max-clique_finder/src/pcm.cpp | SiuKeungm/mixRobust_distributed_mapper | 034cae5e0cb5af75f921f48b0b897db6763292e4 | [
"BSD-3-Clause"
] | 2 | 2020-04-06T04:59:31.000Z | 2021-09-15T02:41:19.000Z | cpp/src/pairwise_consistency_maximization/third_parties/fast_max-clique_finder/src/pcm.cpp | SiuKeungm/mixRobust_distributed_mapper | 034cae5e0cb5af75f921f48b0b897db6763292e4 | [
"BSD-3-Clause"
] | null | null | null | cpp/src/pairwise_consistency_maximization/third_parties/fast_max-clique_finder/src/pcm.cpp | SiuKeungm/mixRobust_distributed_mapper | 034cae5e0cb5af75f921f48b0b897db6763292e4 | [
"BSD-3-Clause"
] | 2 | 2020-04-06T04:59:36.000Z | 2021-08-18T13:08:04.000Z | #include "pcm.h"
#include "graphIO.h"
#include "findClique.h"
using namespace FMC;
void build_CGraphIO_from_Matrix (Eigen::MatrixXi& data,CGraphIO& graph)
{
int n = data.rows ();
int edge_index = 0;
for (int i=0;i<n;i++){
graph.m_vi_Vertices.push_back(edge_index);
const Eigen::VectorXi& edge_list_i = data.col(i);
for (int j=0;j<n;j++){
if (i != j) {
if(edge_list_i(j)) {
graph.m_vi_Edges.push_back(j);
edge_index++;
}
}
}
}
graph.m_vi_Vertices.push_back(edge_index);
graph.CalculateVertexDegrees();
}
std::vector<bool>
PCM::PattabiramanMaxCliqueSolverExact::find_max_clique(Eigen::MatrixXi& adjacency_matrix)
{
CGraphIO graph;
build_CGraphIO_from_Matrix (adjacency_matrix, graph);
std::vector<int> max_clique_data;
maxClique(graph, 0, max_clique_data);
std::vector<bool> max_clique_map(adjacency_matrix.rows(), false);
for(int i=0;i<max_clique_data.size();i++)
{
max_clique_map[max_clique_data[i]] = true;
}
return max_clique_map;
}
std::vector<bool>
PCM::PattabiramanMaxCliqueSolverHeuristic::find_max_clique(Eigen::MatrixXi& adjacency_matrix)
{
CGraphIO graph;
build_CGraphIO_from_Matrix (adjacency_matrix, graph);
std::vector<int> max_clique_data;
maxCliqueHeu(graph, max_clique_data);
std::vector<bool> max_clique_map(adjacency_matrix.rows(), false);
for(int i=0;i<max_clique_data.size();i++)
{
max_clique_map[max_clique_data[i]] = true;
}
return max_clique_map;
}
| 21.942029 | 93 | 0.696169 | [
"vector"
] |
5be5e544a8baeb81d083a9247e7ced148a19361c | 44,352 | cpp | C++ | Client/src/StyledSourceCtrl.cpp | kluete/ddt3 | b8bf3b6daf275ec025b0c4a6401576560b671a3d | [
"Apache-2.0"
] | 6 | 2020-04-20T04:54:44.000Z | 2022-02-13T01:24:10.000Z | Client/src/StyledSourceCtrl.cpp | kluete/ddt3 | b8bf3b6daf275ec025b0c4a6401576560b671a3d | [
"Apache-2.0"
] | null | null | null | Client/src/StyledSourceCtrl.cpp | kluete/ddt3 | b8bf3b6daf275ec025b0c4a6401576560b671a3d | [
"Apache-2.0"
] | 1 | 2022-02-13T01:24:35.000Z | 2022-02-13T01:24:35.000Z | // Scintilla styled source control with Lua lexer
/* Notes:
- STC lines are ZERO-based in logic but DISPLAYED 1-based
- can't use mouse "dwelling" because needs FOCUS
int styl_bits = GetStyleBits(); // USED to be limited to 5 bits, but not anymore
- "Set the style number for the text margin for a line"
MarginSetStyle(ln, style)
- ignored by STC
SetIndicatorValue(int);
- nameless Lua functions EXIST
- 3rd party lexer is always a HACK with many corner cases
- Lua keywords 5 are FREE
*/
#include <sstream>
#include <utility>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include "wx/imaglist.h"
#include "wx/stringops.h"
#include "lx/misc/stopwatch.h"
#include "sigImp.h"
#include "logImp.h"
#include "TopFrame.h"
#include "TopNotebook.h"
#include "SourceFileClass.h"
#include "StyledSourceCtrl.h"
using namespace std;
using namespace LX;
using namespace DDT_CLIENT;
// stdPos ctor
//---- STC position -----------------------------------------------------------
class stcPos
{
public:
stcPos(const wxStyledTextCtrl &stc)
{
m_rawPos = stc.GetCurrentPos();
m_Line = stc.LineFromPosition(m_rawPos);
m_Col = stc.GetColumn(m_rawPos);
}
virtual ~stcPos() = default;
int Line(void) const {return m_Line;}
int Col(void) const {return m_Col;}
int RawPos(void) const {return m_rawPos;}
private:
int m_rawPos;
int m_Line;
int m_Col;
};
//---- Mute STC ---------------------------------------------------------------
class AutoMuteStc
{
public:
AutoMuteStc(IEditorCtrl &ed, wxStyledTextCtrl &stc)
: m_Editor(ed),
m_stc(stc),
m_SavedMask(stc.GetModEventMask()),
m_SavedLock(ed.HasLockFlag())
{
stc.SetModEventMask(0);
ed.SetLockFlag(false);
}
~AutoMuteStc()
{
m_stc.SetModEventMask(m_SavedMask);
m_Editor.SetLockFlag(m_SavedLock);
}
private:
IEditorCtrl &m_Editor;
wxStyledTextCtrl &m_stc;
const int m_SavedMask;
const bool m_SavedLock;
};
//==== Search Hit =============================================================
SearchHit::SearchHit(const int pos1, const int len, ISourceFileClass *sfc, const int line, const int line_pos)
: m_Pos1(pos1),
m_Len(len),
m_Sfc(sfc),
m_Line(line),
m_LinePos(line_pos)
{
assert(sfc);
}
void SearchHit::Clear(void)
{
m_Pos1 = -1;
m_Len = 0;
m_Sfc = nil;
m_Line = -1;
m_LinePos = -1;
}
int SearchHit::Pos1(void) const
{
return m_Pos1;
}
int SearchHit::Len(void) const
{
return m_Len;
}
int SearchHit::Pos2(void) const
{
return m_Pos1 + Len();
}
ISourceFileClass& SearchHit::GetSFC(void) const
{
return *m_Sfc;
}
int SearchHit::Line(void) const
{
return m_Line;
}
int SearchHit::GetLinePos(void) const
{
return m_LinePos;
}
int SearchHit::LineIndex(void) const
{
return Pos1() - GetLinePos();
}
// colors
const wxColour COLOR_CARRET_SELECTED_LINE (215, 243, 243); // light blue
const wxColour COLOR_VERTICAL_EDIT_EDGE (194, 235, 194); // faded green
const wxColour COLOR_CURRENT_EXECUTION_LINE ( 40, 255, 255); // cyan
const wxColour COLOR_LUA_ERROR_ANNOTATION (250, 100, 100); // light red
const wxColour COLOR_STROKE_BREAKPOINT (0, 0, 0);
const wxColour COLOR_FILL_BREAKPOINT (255, 0, 0); // red
const wxColour COLOR_STROKE_SEARCH_HIGHLIGHT (0, 0, 0);
const wxColour COLOR_FILL_SEARCH_HIGHLIGHT (255, 240, 50); // yellow
const wxColour COLOR_STROKE_TOOLTIP ( 0, 0, 0);
const wxColour COLOR_FILL_TOOLTIP (255, 240, 80); // bright yellow
const wxColour COLOR_STROKE_USER_BOOKMARK (255, 0, 128); // darker purple
const wxColour COLOR_FILL_USER_BOOKMARK (255, 102, 254); // bright purple
// transparencies
const int SEARCH_HIGHLIGHT_BRUSH_ALPHA = 130;
const int SEARCH_HIGHLIGHT_PEN_ALPHA = 150;
const string STC_FUNCTION_REFRESH_GROUP = "stc_function_refresh";
// function NAME()
// const regex re { "\\bfunction[[:space:]]*([[:alpha:]_][[:alnum:]_\\.\\:]*)\\(" };
// NAME = function(
// const regex re { "([[:alpha:]_][[:alnum:]_\\.\\:]*)[[:space:]]*=[[:space:]]*function[[:space:]]*\\(" };
// combo
static const regex LUA_FUNCTION_RE
{
"\\bfunction[[:space:]]*([[:alpha:]_][[:alnum:]_\\.\\:]*)\\("
"|"
"([[:alpha:]_][[:alnum:]_\\.\\:]*)[[:space:]]*=[[:space:]]*function[[:space:]]*\\(",
regex::ECMAScript | regex::optimize
};
#define lex_def(t) LUA_LEX_##t = wxSTC_LUA_##t
enum LEXER_T : uint8_t
{
lex_def(DEFAULT),
lex_def(COMMENT),
lex_def(COMMENTLINE),
lex_def(COMMENTDOC),
lex_def(NUMBER),
lex_def(WORD), // core Lua keywords, word group 0 (enum 5)
lex_def(STRING),
lex_def(CHARACTER),
lex_def(LITERALSTRING),
lex_def(PREPROCESSOR),
lex_def(OPERATOR),
lex_def(IDENTIFIER), // script variables, including functions (enum 11)
lex_def(STRINGEOL),
lex_def(WORD2),
lex_def(WORD3),
lex_def(WORD4),
lex_def(WORD5),
lex_def(WORD6), // scipt user functions
lex_def(WORD7),
lex_def(WORD8),
lex_def(LABEL),
LUA_LEX_ILLEGAL = 255
};
#undef lex_def
const int DDT_USER_VARIABLE = wxSTC_LUA_IDENTIFIER;
const int DDT_USER_LUA_FUNCTION = wxSTC_LUA_WORD6;
enum MARGIN_TYPES : int // REDUNDANT with enum below!
{
MARGIN_LINE_NUMBERS = 0,
MARGIN_BREAKPOINTS,
MARGIN_CURRENT_EXECUTION_LINE,
MARGIN_SELECTED_SEARCH_RESULT,
MARGIN_USER_BOOKMARK,
};
enum class MARKER_INDEX : int
{
BREAKPOINT = 1, // start at 1 so matches above margins -- or is completely REDUNDANT?
CURRENT_EXECUTION_LINE,
SELECTED_SEARCH_RESULT,
USER_BOOKMARK,
};
const int SEARCH_INDICATOR_ID = (int) MARKER_INDEX::SELECTED_SEARCH_RESULT;
static const
unordered_map<MARGIN_MARKER_T, MARKER_INDEX, hash<int>> s_HighlightToMarkerMap
{
{MARGIN_MARKER_T::EXECUTION_LINE, MARKER_INDEX::CURRENT_EXECUTION_LINE},
{MARGIN_MARKER_T::SEARCH_RESULT_LINE, MARKER_INDEX::SELECTED_SEARCH_RESULT},
{MARGIN_MARKER_T::USER_BOOKMARK, MARKER_INDEX::USER_BOOKMARK},
};
#if 0
static const
unordered_map<int, string> s_LuaStyleLUT
{
{wxSTC_LUA_DEFAULT, "default"},
{wxSTC_LUA_COMMENT, "comment"},
{wxSTC_LUA_COMMENTLINE, "commentline"},
{wxSTC_LUA_COMMENTDOC, "commentdoc"},
{wxSTC_LUA_NUMBER, "number"},
{wxSTC_LUA_WORD, "word"}, // word group 0 (enum 5)
{wxSTC_LUA_STRING, "string"},
{wxSTC_LUA_CHARACTER, "character"},
{wxSTC_LUA_LITERALSTRING, "litteralstring"},
{wxSTC_LUA_PREPROCESSOR, "preprocessor"},
{wxSTC_LUA_OPERATOR, "operator"},
{wxSTC_LUA_IDENTIFIER, "identifier"}, // Lua variable (enum 11)
{wxSTC_LUA_STRINGEOL, "stringeol"},
{wxSTC_LUA_WORD2, "word2"},
{wxSTC_LUA_WORD3, "word3"},
{wxSTC_LUA_WORD4, "word4"},
{wxSTC_LUA_WORD5, "word5"},
{wxSTC_LUA_WORD6, "word6"},
{wxSTC_LUA_WORD7, "word7"},
{wxSTC_LUA_WORD8, "word8"},
{wxSTC_LUA_LABEL, "label"}
};
#endif
static const
unordered_set<LEXER_T, EnumClassHash> s_CommentStyleSet
{
LUA_LEX_COMMENT,
LUA_LEX_COMMENTLINE,
LUA_LEX_COMMENTDOC,
LUA_LEX_LITERALSTRING, // multiline string/comment
};
static const
unordered_set<LEXER_T, EnumClassHash> s_DormantStyleSet
{
LUA_LEX_STRING, LUA_LEX_LITERALSTRING
};
static const
unordered_set<string> s_IgnoreFunctionsSet
{
"__index"
};
// wx/stc/stc.h:345
static const
unordered_map<int, string> s_ModMap =
{
{wxSTC_MOD_INSERTTEXT, "MOD_INSERTTEXT"},
{wxSTC_MOD_DELETETEXT, "MOD_DELETETEXT"},
{wxSTC_MOD_CHANGESTYLE, "MOD_CHANGESTYLE"},
{wxSTC_MOD_CHANGEFOLD, "MOD_CHANGEFOLD"},
{wxSTC_PERFORMED_USER, "PERFORMED_USER"},
{wxSTC_PERFORMED_UNDO, "PERFORMED_UNDO"},
{wxSTC_PERFORMED_REDO, "PERFORMED_REDO"},
{wxSTC_MULTISTEPUNDOREDO, "MULTISTEPUNDOREDO"},
{wxSTC_LASTSTEPINUNDOREDO, "LASTSTEPINUNDOREDO"},
{wxSTC_MOD_CHANGEMARKER, "MOD_CHANGEMARKER"}, // on breakpoint edit
{wxSTC_MOD_BEFOREINSERT, "MOD_BEFOREINSERT"},
{wxSTC_MOD_BEFOREDELETE, "MOD_BEFOREDELETE"},
{wxSTC_MULTILINEUNDOREDO, "MULTILINEUNDOREDO"},
{wxSTC_STARTACTION, "STARTACTION"},
{wxSTC_MOD_CHANGEINDICATOR, "MOD_CHANGEINDICATOR"}, // on search highlights
{wxSTC_MOD_CHANGELINESTATE, "MOD_CHANGELINESTATE"},
{wxSTC_MOD_CHANGEMARGIN, "MOD_CHANGEMARGIN"},
{wxSTC_MOD_CHANGEANNOTATION, "MOD_CHANGEANNOTATION"}, // on Lua errors
{wxSTC_MOD_CONTAINER, "MOD_CONTAINER"},
{wxSTC_MOD_LEXERSTATE, "MOD_LEXERSTATE"} // is 0x80000 = 19 bits
};
const int MAX_MOD_BIT_INDEX = 19;
static const
unordered_set<int> s_SilentModSet =
{
wxSTC_MOD_CHANGEINDICATOR,
wxSTC_MOD_CHANGEANNOTATION,
wxSTC_MOD_CHANGEMARKER,
wxSTC_PERFORMED_USER
};
const int ANNOTATION_STYLE = 24;
inline
string GetModString(const uint32_t mod_flags)
{
ostringstream ss;
for (int i = 0; i <= MAX_MOD_BIT_INDEX; i++)
{
const uint32_t flag = (1L << i);
assert(s_ModMap.count(flag));
if (!(mod_flags & flag)) continue; // flag not set
ss << s_ModMap.at(flag) << " ";
}
return ss.str();
}
//---- Source Code List Control Class -----------------------------------------
class EditorCtrl: public wxStyledTextCtrl, public IEditorCtrl, private SlotsMixin<CTX_WX>
{
public:
EditorCtrl(wxWindow *parent_win, int id, ITopNotePanel &topnotebook, wxImageList &img_list);
virtual ~EditorCtrl();
wxWindow* GetWxWindow(void) override {return this;}
void BindToPanel(wxWindow *panel, const size_t retry_ms) override
{
}
ISourceFileClass* GetCurrentSFC(void) const override {return m_CurrentSFC;}
EditorSignals& GetSignals(void) override {return m_Signals;}
void LoadFromSFC(ISourceFileClass *sfc) override;
void SaveToDisk(void) override
{
if (!m_CurrentSFC) return; // should be error?
assert(m_CurrentSFC->IsWritableFile());
const bool ok = m_CurrentSFC->SaveToDisk(*this);
assert(ok);
// save point in UNDO buffer
SetSavePoint();
}
int GetTotalLines(void) const override
{
return GetLineCount();
}
iPoint GetCursorPos(void) const override
{
const stcPos pos(*this);
// uMsg("GetCursorPos(pos = [%d; %d], raw = %d)", pos.Col(), pos.Line(), pos.RawPos());
return iPoint(pos.Col(), pos.Line());
}
void SetCursorPos(const iPoint &pt) override
{
const int raw_pos = FindColumn(pt.y(), pt.x());
GotoPos(raw_pos);
EnsureCaretVisible();
SetFocus();
}
void ShowLine(const int ln, const bool focus_f) override;
void ShowSpan(const int pos1, const int pos2) override;
void SetFocus(void) override
{
wxStyledTextCtrl::SetFocus();
}
bool HasLineMarker(const MARGIN_MARKER_T hl_typ, const int ln) override;
void ToggleLineMarker(const MARGIN_MARKER_T hl_typ, const int ln, const bool f) override;
void RemoveLineMarkers(const MARGIN_MARKER_T hl_typ) override;
void RemoveAllHighlights(void) override;
bool HasLockFlag(void) const override
{
return GetReadOnly();
}
void SetLockFlag(const bool lock_f) override
{
SetReadOnly(lock_f);
SetCaretStyle(lock_f ? wxSTC_CARETSTYLE_INVISIBLE : wxSTC_CARETSTYLE_LINE);
}
void ClearAnnotations(void) override;
void SetAnnotation(int ln, const string &annotation_s) override;
vector<int> GetBreakpointLines(void) override;
void SetBreakpointLines(const vector<int> &bp_list) override;
bool IsEditorDirty(void) const override;
void SetEditorDirty(const bool f) override;
int SearchText(const string &patt, const uint32_t mask, vector<SearchHit> &hit_list) override;
void RemoveSearchHighlights(void) override;
void SetAllTextLines(const vector<string> &text) override;
vector<string> GetAllTextLines(void) const override;
string GetUserSelection(void) override;
vector<int> GetUserBookmarks(void);
private:
void UnloadCurrentSFC(void);
void MarkDirty(void) override
{
// wxFAIL_MSG("not implemented");
}
string GetToolTipWord(const int pos, int &var_pos, int &styl);
// event handlers
void OnWindowCreated(wxWindowCreateEvent &e);
void OnMouseMove(wxMouseEvent &e);
void OnRightDown(wxMouseEvent &e);
void OnMarginClick(wxStyledTextEvent &e);
void OnSTCUpdateUI(wxStyledTextEvent &e);
void OnReadOnlyModifyAttempt(wxStyledTextEvent &e);
void OnStyleNeededEvent(wxStyledTextEvent &e);
void OnTextModifiedEvent(wxStyledTextEvent &e);
void OnCharAdddedEvent(wxStyledTextEvent &e);
// functions
void CancelToolTip(void);
void UpdateMarginWidth(void);
void ConfigureLexer(void);
void SetupKeywords(void);
void CalcFontDensity(const int &font_size);
void ReloadStylCache(void);
void OnReloadLuaFunctions(void);
ITopNotePanel &m_TopNotebook;
wxImageList &m_ImageList;
ISourceFileClass *m_CurrentSFC;
bool m_DirtyFlag;
bool m_WinCreatedFlag;
mutable int m_LastToolTipPos, m_LastWordPos; // mutable FAILS on gcc 4.9 ???
struct styl_pair
{
char m_char;
LEXER_T m_styl;
};
vector<styl_pair> m_CharStylBuff;
string m_CharBuff;
EditorSignals m_Signals;
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE(EditorCtrl, wxStyledTextCtrl)
EVT_WINDOW_CREATE( EditorCtrl::OnWindowCreated)
EVT_STC_UPDATEUI( -1, EditorCtrl::OnSTCUpdateUI) // to catch cursor movements
EVT_STC_ROMODIFYATTEMPT( -1, EditorCtrl::OnReadOnlyModifyAttempt)
EVT_STC_MODIFIED( -1, EditorCtrl::OnTextModifiedEvent)
EVT_STC_CHARADDED( -1, EditorCtrl::OnCharAdddedEvent)
EVT_STC_MARGINCLICK( -1, EditorCtrl::OnMarginClick)
EVT_MOTION( EditorCtrl::OnMouseMove)
EVT_RIGHT_DOWN( EditorCtrl::OnRightDown)
/*
EVT_SET_FOCUS( EditorCtrl::OnSetFocus)
EVT_KILL_FOCUS( EditorCtrl::OnKillFocus)
EVT_CHILD_FOCUS( EditorCtrl::OnChildFocus)
*/
END_EVENT_TABLE()
//---- CTOR -------------------------------------------------------------------
EditorCtrl::EditorCtrl(wxWindow *parent_win, int id, ITopNotePanel &topnotebook, wxImageList &img_list)
: wxStyledTextCtrl(parent_win, id, wxDefaultPosition, wxDefaultSize),
SlotsMixin(CTX_WX, "stc EditorCtrl"),
m_TopNotebook(topnotebook),
m_ImageList(img_list),
m_CurrentSFC(nil)
{
m_CharStylBuff.clear();
m_CharBuff.clear();
// SetCanFocus(false); // makes scintilla THINK it has focus, while in effect the search field does...
m_WinCreatedFlag = false;
// ! would remove default shortcuts
// CmdKeyClearAll();
/*
// ALT-keyboard shortcuts
CmdKeyAssign('Z', wxSTC_SCMOD_ALT, wxSTC_CMD_UNDO);
CmdKeyAssign('X', wxSTC_SCMOD_ALT, wxSTC_CMD_CUT);
CmdKeyAssign('C', wxSTC_SCMOD_ALT, wxSTC_CMD_COPY);
CmdKeyAssign('V', wxSTC_SCMOD_ALT, wxSTC_CMD_PASTE);
CmdKeyAssign('A', wxSTC_SCMOD_ALT, wxSTC_CMD_SELECTALL);
*/
ConfigureLexer();
SetTabWidth(TAB_NUM_CHARS);
SetIndent(TAB_NUM_CHARS);
SetTabIndents(true);
SetEdgeColumn(80); // in characters now (used to be in pixels?)
SetEdgeMode(wxSTC_EDGE_LINE);
SetEdgeColour(COLOR_VERTICAL_EDIT_EDGE);
vector<pair<int, int>> ranges {{'a', 'z'}, {'A', 'Z'}, {'0', '9'}, {'_', '_'}};
wxString word_s;
for (auto it : ranges)
{
for (int c = it.first; c <= it.second; c++) word_s.Append((char)c);
}
// for moving from word to word
SetWordChars(word_s);
SetWhitespaceChars(" \t");
SetPunctuationChars("().-=[]");
SetupKeywords();
// LEXER folding levels (smudges margin)
// SetProperty("fold", "1");
// SetProperty("fold.compact", "1"); // dunno what it does
// hex display for debugging but SCREWS UP line# display?
// SetFoldFlags(64);
// set caret line background color, alpha & show
SetCaretLineBackground(COLOR_CARRET_SELECTED_LINE);
SetCaretLineBackAlpha(0x40);
SetCaretLineVisible(true); // kindof sucks, blinks with window focus (?)
SetCaretStyle(wxSTC_CARETSTYLE_LINE);
// SetYCaretPolicy(wxSTC_CARET_SLOP | wxSTC_CARET_JUMPS, 2); // # lines excluded from top/bottom
SetYCaretPolicy(wxSTC_CARET_SLOP | wxSTC_CARET_EVEN, 3); // # lines excluded from top/bottom
// search result indicators
IndicatorSetStyle(SEARCH_INDICATOR_ID, wxSTC_INDIC_STRAIGHTBOX);
IndicatorSetForeground(SEARCH_INDICATOR_ID, COLOR_FILL_SEARCH_HIGHLIGHT);
IndicatorSetAlpha(SEARCH_INDICATOR_ID, SEARCH_HIGHLIGHT_BRUSH_ALPHA);
IndicatorSetOutlineAlpha(SEARCH_INDICATOR_ID, SEARCH_HIGHLIGHT_PEN_ALPHA);
// SetModEventMask(wxSTC_MOD_INSERTTEXT | wxSTC_MOD_DELETETEXT | wxSTC_PERFORMED_UNDO | wxSTC_PERFORMED_REDO | wxSTC_PERFORMED_USER);
SetModEventMask(wxSTC_MOD_INSERTTEXT | wxSTC_MOD_DELETETEXT | wxSTC_LASTSTEPINUNDOREDO);
}
//---- DTOR -------------------------------------------------------------------
EditorCtrl::~EditorCtrl()
{
uLog(DTOR, "STCEditorCtrl::DTOR");
}
//---- Unload Current SFC -----------------------------------------------------
void EditorCtrl::UnloadCurrentSFC(void)
{
MixZapGroup(STC_FUNCTION_REFRESH_GROUP);
if (m_CurrentSFC)
{
/*
void *doc_p = GetDocPointer();
assert(doc_p);
AddRefDocument(doc_p);
*/
m_CurrentSFC->SaveFromEditor(*this);
EmptyUndoBuffer();
}
ClearAll();
m_CurrentSFC = nil;
}
//---- Load From SFC ----------------------------------------------------------
void EditorCtrl::LoadFromSFC(ISourceFileClass *sfc)
{
if (sfc == m_CurrentSFC) return; // same as earlier
AutoMuteStc mute(*this, *this);
UnloadCurrentSFC();
m_CurrentSFC = sfc;
if (!sfc) return;
/*
void *doc_p = sfc->GetDocument(); // nil on 1st time
if (!doc_p)
{
doc_p = CreateDocument();
}
else SetDocPointer(doc_p);
*/
m_CurrentSFC->RestoreToEditor(*this);
// signal document is "clean"
// SetSavePoint();
}
//---- Get All Text Lines -----------------------------------------------------
vector<string> EditorCtrl::GetAllTextLines(void) const
{
const int end_pos = GetLastPosition();
const char *p = GetCharacterPointer();
assert(p);
int n_LF = 0;
int n_CR = 0;
for (int i = 0; i < end_pos; i++)
{
if (p[i] == '\n') n_LF++; // *nix only
if (p[i] == '\r') n_CR++; // Win too
}
const int n_lines = GetNumberOfLines();
uLog(STYLED, "LF %d, CR %d, lines %d", n_LF, n_CR, n_lines);
vector<string> res;
for (int i= 0; i < n_lines; i++)
res.emplace_back(GetLineText(i).ToStdString());
return res;
}
//---- Set All Text Lines -----------------------------------------------------
void EditorCtrl::SetAllTextLines(const vector<string> &text_lines)
{
Clear();
wxString s;
for (const string &ln : text_lines)
{
s << ln << "\n";
}
SetText(s);
// call lexer & assign fold levels
Colourise(0, -1);
CallAfter(&EditorCtrl::ReloadStylCache); // (parent may not be fully initialized)
UpdateMarginWidth();
EmptyUndoBuffer();
}
//---- On Window Created event ------------------------------------------------
void EditorCtrl::OnWindowCreated(wxWindowCreateEvent &e)
{
m_WinCreatedFlag = true;
}
//---- On Read-Only Modify Attempt event --------------------------------------
void EditorCtrl::OnReadOnlyModifyAttempt(wxStyledTextEvent &e)
{
uWarn("EditorCtrl::OnReadOnlyModifyAttempt()");
auto *sfc = GetCurrentSFC();
assert(sfc);
const bool edit_f = sfc->OnReadOnlyEditAttempt();
// unlock immediately so edit continues normally
SetLockFlag(!edit_f);
}
//---- Is Dirty ? -------------------------------------------------------------
bool EditorCtrl::IsEditorDirty(void) const
{
return IsModified();
}
//---- Clear Dirty ------------------------------------------------------------
void EditorCtrl::SetEditorDirty(const bool f)
{
const bool changed_f = (f != m_DirtyFlag);
m_DirtyFlag = f;
SetModified(f);
if (changed_f)
m_Signals.OnEditorDirtyChanged(CTX_WX, GetCurrentSFC(), f);
}
//---- On Text Modified event -------------------------------------------------
void EditorCtrl::OnTextModifiedEvent(wxStyledTextEvent &e)
{
// e.Skip();
if (!m_WinCreatedFlag) return; // ignore until window created
const string s = GetModString(e.GetModificationType());
const bool dirty_f = IsModified();
const bool dirty_changed_f = (dirty_f != m_DirtyFlag);
// uWarn("EditorCtrl::OnTextModifiedEvent(%S, dirty = %c)", s, dirty_f);
// always reload style cache -- AFTER processed event
CallAfter(&EditorCtrl::ReloadStylCache);
if (dirty_changed_f)
{ m_DirtyFlag = dirty_f;
uLog(STYLED, "EditorCtrl is %s", dirty_f ? "dirty" : "clean");
m_Signals.OnEditorDirtyChanged(CTX_WX, GetCurrentSFC(), dirty_f);
}
UpdateMarginWidth();
// to update breakpoints
// ! corner case could see unchanged total lines but still shift breakpoints (when pasting multi-line over selection)
m_Signals.OnEditorContentChanged(CTX_WX);
}
//----- On Margin Breakpoint clicked ------------------------------------------
void EditorCtrl::OnMarginClick(wxStyledTextEvent &e)
{
if (e.GetMargin() != MARGIN_BREAKPOINTS)
{ e.Skip();
return;
}
const int ln = LineFromPosition(e.GetPosition());
// completely IGNORE state from UI
m_Signals.OnEditorBreakpointClick(CTX_WX, GetCurrentSFC(), ln); // 0-based line
}
//---- On STC Update UI -------------------------------------------------------
// capture cursor movements
void EditorCtrl::OnSTCUpdateUI(wxStyledTextEvent &e)
{
// (do NOT get position from event, isn't updated)
e.Skip();
const stcPos stc_pos(*this);
m_Signals.OnEditorCursorChanged(CTX_WX, stc_pos.Col(), stc_pos.Line());
}
//---- Show Line (w/ highlight) -----------------------------------------------
void EditorCtrl::ShowLine(const int ln, const bool focus_f)
{
if (ln < 0)
{ // no highlight, show source top
GotoLine(0);
return;
}
GotoLine(ln - 1);
EnsureCaretVisible();
if (focus_f)
{
SetFocus();
}
}
//---- Get User Selection -----------------------------------------------------
string EditorCtrl::GetUserSelection(void)
{
long pos1 = -1, pos2 = -1;
GetSelection(&pos1, &pos2);
if (pos1 >= pos2) return ""; // selected nothing
int ln1, ln2;
ln1 = LineFromPosition(pos1);
ln2 = LineFromPosition(pos2);
if (ln1 != ln2) return ""; // selected > 1 line
while (isspace(GetCharAt(pos1)) && (pos1 < pos2)) pos1++; // crappy ?
while (isspace(GetCharAt(pos2 -1)) && (pos1 < pos2)) pos2--;
if (pos1 >= pos2) return ""; // selected nothing
const string selection_s = GetTextRange(pos1, pos2).ToStdString();
return selection_s;
}
//---- Search Text ------------------------------------------------------------
int EditorCtrl::SearchText(const string &patt, const uint32_t ext_mask, vector<SearchHit> &hit_list)
{
// clear all first...
RemoveSearchHighlights();
auto *sfc = GetCurrentSFC();
if (!sfc) return 0;
if (patt.size() == 0) return 0;
const uint32_t mask = ext_mask & FIND_FLAG::EXT_FIND_MASK;
(void)mask; // to implement !
const bool no_comment_f = (ext_mask & FIND_FLAG::EXT_NO_COMMENT);
const bool highlight_f = (ext_mask & FIND_FLAG::EXT_HIGHLIGHT);
const wxString wx_patt = wxString(patt);
// const int end_pos = GetLastPosition();
const size_t sz_bf = hit_list.size();
const regex SEARCH_RE(patt, regex::basic);
auto it = m_CharBuff.cbegin();
smatch matches;
while (regex_search(it, m_CharBuff.cend(), matches/*&*/, SEARCH_RE))
{
const size_t n_matches = matches.size(); // full match = single match (with no capture)
assert(n_matches == 1);
const size_t org_pos = it - m_CharBuff.cbegin();
const size_t offset = matches.position(0);
const size_t pos = org_pos + offset;
const auto len = matches.length(0);
// get style at position, exclude comment styles
if ((!no_comment_f) || (s_CommentStyleSet.count(m_CharStylBuff[pos].m_styl) == 0))
{
// (could be DELAYED?)
const int ln = LineFromPosition(pos) + 1;
const int ln_pos = PositionFromLine(ln -1);
hit_list.push_back(SearchHit(pos, len, sfc, ln, ln_pos));
if (highlight_f)
{ // filled background rectangle (should handle later?)
IndicatorFillRange(pos, len);
}
}
// skip over result
it += offset + len + 1;
assert(it < m_CharBuff.cend());
}
const size_t n_res = hit_list.size() - sz_bf;
if (n_res)
{
uLog(STOPWATCH, "EditorCtrl::SearchText() %6zu results", n_res);
}
return n_res;
}
//---- Remove Search Highlights -----------------------------------------------
void EditorCtrl::RemoveSearchHighlights(void)
{
SetIndicatorCurrent(SEARCH_INDICATOR_ID);
IndicatorClearRange(0, GetLastPosition());
}
//---- Clear Annotations ------------------------------------------------------
void EditorCtrl::ClearAnnotations(void)
{
AnnotationClearAll();
}
//---- Set Annotation ---------------------------------------------------------
void EditorCtrl::SetAnnotation(int ln, const string &annotation_s)
{
AnnotationClearAll();
AnnotationSetText(ln - 1, wxString(annotation_s));
AnnotationSetStyle(ln - 1, ANNOTATION_STYLE);
AnnotationSetVisible(true);
}
//---- Show Span --------------------------------------------------------------
void EditorCtrl::ShowSpan(const int pos1, const int pos2)
{
// should use RANGE ?
const int ln = LineFromPosition(pos1);
ShowLine(ln + 1, false/*focus?*/); // pre-offset so is identity in ShowLine()
}
//---- Has Line Marker of given type ? ----------------------------------------
bool EditorCtrl::HasLineMarker(const MARGIN_MARKER_T hl_typ, const int ln)
{
assert(s_HighlightToMarkerMap.count(hl_typ) > 0);
if (ln == -1) return false; // should be error?
assert(ln != 0);
const MARKER_INDEX marker_id = s_HighlightToMarkerMap.at(hl_typ);
const uint32_t mask = 1ul << (int) marker_id;
return MarkerGet(ln - 1) & mask;
}
//---- Set/Clear Line Marker of given type ------------------------------------
void EditorCtrl::ToggleLineMarker(const MARGIN_MARKER_T hl_typ, const int ln, const bool f)
{
assert(s_HighlightToMarkerMap.count(hl_typ) > 0);
if (ln == -1) return; // should be error?
assert(ln != 0);
const MARKER_INDEX marker_id = s_HighlightToMarkerMap.at(hl_typ);
if (f) MarkerAdd(ln - 1, (const int)marker_id);
else MarkerDelete(ln - 1, (const int)marker_id);
}
//---- Remove all Line Markers of given type ----------------------------------
void EditorCtrl::RemoveLineMarkers(const MARGIN_MARKER_T hl_typ)
{
assert(s_HighlightToMarkerMap.count(hl_typ) > 0);
const MARKER_INDEX marker_id = s_HighlightToMarkerMap.at(hl_typ);
MarkerDeleteAll((const int)marker_id);
}
//---- Remove All Highlight ---------------------------------------------------
void EditorCtrl::RemoveAllHighlights(void)
{
// uLog(UI, "EditorCtrl::RemoveAllHighlights()");
// SetCaretLineVisible(false);
RemoveLineMarkers(MARGIN_MARKER_T::EXECUTION_LINE);
RemoveLineMarkers(MARGIN_MARKER_T::SEARCH_RESULT_LINE);
RemoveSearchHighlights();
CancelToolTip();
}
//---- Get Breakpoint Lines ---------------------------------------------------
vector<int> EditorCtrl::GetBreakpointLines(void)
{
vector<int> res;
const int n_lines = GetNumberOfLines();
const uint32_t mask = 1L << (int) MARKER_INDEX::BREAKPOINT;
for (int i = 0; i < n_lines; i++)
{
if (!(MarkerGet(i) & mask)) continue; // non-const !
res.push_back(i + 1);
}
return res;
}
//---- Set Breakpoint Lines ---------------------------------------------------
void EditorCtrl::SetBreakpointLines(const vector<int> &breakpoint_lines)
{
uLog(BREAKPOINT_EDIT, "EditorCtrl::SetBreakpointLines(%zu lines)", breakpoint_lines.size());
AutoMuteStc mute(*this, *this);
// remove all breakpoints
MarkerDeleteAll((int)MARKER_INDEX::BREAKPOINT);
for (const auto ln : breakpoint_lines)
{
MarkerAdd(ln/*zero-based*/, (int) MARKER_INDEX::BREAKPOINT);
}
}
//---- On Character Add from user ---------------------------------------------
void EditorCtrl::OnCharAdddedEvent(wxStyledTextEvent &e)
{
// occurs AFTER char was already added
e.Skip();
const int c = e.GetKey();
if (c == '\n')
{ // auto-indent - DOESN'T WORK?
const int ln = GetCurrentLine();
assert(ln > 0);
// get previous line's indentation (in chars)
const int n_cols = GetLineIndentation(ln - 1);
// divide by tab size
const int n_tabs = n_cols / GetTabWidth();
// concat as many tab chars
wxString indent_s('\t', n_tabs);
// insert at current position
AddText(indent_s);
}
}
//---- On Mouse Move event ----------------------------------------------------
void EditorCtrl::OnMouseMove(wxMouseEvent &e)
{
e.Skip();
if (!e.ControlDown()) return CancelToolTip();
if (!m_TopNotebook.CanQueryDaemon()) return; // daemon not available now
const wxPoint pt = e.GetPosition();
const int pos = PositionFromPointClose(pt.x, pt.y);
if ((pos == wxSTC_INVALID_POSITION) || (pos == m_LastToolTipPos)) return;
m_LastToolTipPos = pos;
int var_pos = -1, styl = -1;
const string key = GetToolTipWord(pos, var_pos/*&*/, styl/*&*/);
if (key.empty() || (styl == DDT_USER_LUA_FUNCTION)) return CancelToolTip();
wxString res;
bool f = m_TopNotebook.SolveVar_ASYNC(key, res/*&*/);
if (!f)
{ // not cached yet (invalidate pos cache so will redo)
m_LastToolTipPos = -1;
return;
}
// was cached, check if is already up
if (CallTipActive() && (m_LastWordPos == var_pos)) return; // tooltip for this var already shown
m_LastWordPos = var_pos;
CallTipSetForeground(COLOR_STROKE_TOOLTIP);
CallTipSetBackground(COLOR_FILL_TOOLTIP);
CallTipShow(pos, res);
}
//---- Cancel Tooltip ---------------------------------------------------------
void EditorCtrl::CancelToolTip(void)
{
CallTipCancel();
m_LastToolTipPos = m_LastWordPos = -1;
}
//---- Get ToolTip Word -------------------------------------------------------
string EditorCtrl::GetToolTipWord(const int pos, int &var_pos, int &styl)
{
var_pos = -1;
const int w_start = WordStartPosition(pos, true/*only word chars*/);
const int w_end = WordEndPosition(pos, true/*only word chars*/);
const string word = GetTextRange(w_start, w_end);
for (int i = w_start; i < w_end; i++)
{ styl = GetStyleAt(i);
if ((styl != DDT_USER_VARIABLE) && (styl != DDT_USER_LUA_FUNCTION)) return ""; // wrong style
}
// check if picked a FIELD
if (w_start > 0)
{ const char prefix = GetCharAt(w_start - 1);
if ((prefix == '.') || (prefix == '['))
{ // caught a FIELD, back-track RECURSIVELY (?)
return GetToolTipWord(w_start - 2, var_pos/*&*/, styl/*&*/);
}
}
var_pos = w_start;
return word;
}
//---- On Mouse Right-Click Down ----------------------------------------------
void EditorCtrl::OnRightDown(wxMouseEvent &e)
{
const wxPoint pt = e.GetPosition();
const int pos = PositionFromPointClose(pt.x, pt.y);
if (pos == wxSTC_INVALID_POSITION)
{
uErr("illegal pos on right-click");
return;
}
int var_pos = -1, styl = -1;
const string var_name = GetToolTipWord(pos, var_pos/*&*/, styl/*&*/);
uMsg("selected %S", var_name);
// build context menu
wxMenu menu;
if (!var_name.empty()) menu.Append(CONTEXT_MENU_ID_STC_ADD_TO_WATCHES, "Add to Watches");
menu.Append(CONTEXT_MENU_ID_STC_COPY_LUA_ERROR, "Copy Lua Error");
// immediate popup menu -- will send FOCUS event
const int id = GetPopupMenuSelectionFromUser(menu);
e.Skip(); // release mouse
if (id < 0) return; // canceled
switch (id)
{
case CONTEXT_MENU_ID_STC_ADD_TO_WATCHES:
m_TopNotebook.AddToWatches(var_name);
break;
case CONTEXT_MENU_ID_STC_COPY_LUA_ERROR:
uWarn("CONTEXT_MENU_ID_STC_COPY_LUA_ERROR");
break;
default:
break;
}
}
//---- Update Margin Width (based on max #lines) ------------------------------
void EditorCtrl::UpdateMarginWidth(void)
{
const int n_tot_lines = GetLineCount();
const int n_digits = ((n_tot_lines > 0) ? log10(n_tot_lines) : 0) + 1;
const wxString test_string = wxString('9', n_digits) + "_";
const int n_pixels = TextWidth(wxSTC_STYLE_LINENUMBER, test_string);
if (n_pixels != GetMarginWidth(MARGIN_LINE_NUMBERS))
SetMarginWidth(MARGIN_LINE_NUMBERS, n_pixels);
}
//---- Configure Lua Lexer ----------------------------------------------------
void EditorCtrl::ConfigureLexer(void)
{
wxFont font_t = wxFont(10, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, "");
wxFont fontItalic = wxFont(10, wxFONTFAMILY_MODERN, wxFONTSTYLE_ITALIC, wxFONTWEIGHT_NORMAL, false, "");
SetBufferedDraw(true);
StyleClearAll();
SetFont(font_t);
StyleSetFont(wxSTC_STYLE_DEFAULT, font_t);
for (int i = 0; i < 32; i++) StyleSetFont(i, font_t); // assign font to all styles
StyleSetFont(ANNOTATION_STYLE, font_t);
#define CLR(r,g,b) wxColor(r, g, b)
StyleSetForeground(wxSTC_LUA_DEFAULT, CLR(128,128,128)); // white space
StyleSetForeground(wxSTC_LUA_COMMENT, CLR(0,100,20)); // block comment
StyleSetFont(wxSTC_LUA_COMMENT, fontItalic);
StyleSetForeground(wxSTC_LUA_COMMENTLINE, CLR(0,100,20)); // line comment
StyleSetFont(wxSTC_LUA_COMMENTLINE, fontItalic);
StyleSetForeground(wxSTC_LUA_COMMENTDOC, CLR(127,127,127)); // doc. comment (?)
StyleSetForeground(wxSTC_LUA_NUMBER, CLR(0,127,127)); // number
StyleSetForeground(wxSTC_LUA_WORD, CLR(0,0,255)); // Lua word
StyleSetBold(wxSTC_LUA_WORD, true);
StyleSetForeground(wxSTC_LUA_STRING, CLR(127,0,127));
StyleSetForeground(wxSTC_LUA_CHARACTER, CLR(127,0,127)); // (not used ?)
StyleSetForeground(wxSTC_LUA_LITERALSTRING, CLR(0,127,127));
StyleSetForeground(wxSTC_LUA_PREPROCESSOR, CLR(127,127,0));
StyleSetForeground(wxSTC_LUA_OPERATOR, CLR(0,0,0));
StyleSetForeground(wxSTC_LUA_IDENTIFIER, CLR(0,0,0)); // (user script functions)
StyleSetForeground(wxSTC_LUA_STRINGEOL, CLR(0,0,0)); // unterminated strings
StyleSetBackground(wxSTC_LUA_STRINGEOL, CLR(224,192,224));
StyleSetBold(wxSTC_LUA_STRINGEOL, true);
StyleSetEOLFilled(wxSTC_LUA_STRINGEOL, true);
// keyword groups
StyleSetForeground(wxSTC_LUA_WORD2, CLR(0,20,180)); // built-in Lua functions
StyleSetForeground(wxSTC_LUA_WORD3, CLR(128,64,0));
StyleSetForeground(wxSTC_LUA_WORD4, CLR(127,0,0));
StyleSetForeground(wxSTC_LUA_WORD5, CLR(127,0,95));
StyleSetForeground(wxSTC_LUA_WORD6, CLR(10,10,10)); // user Lua functions
StyleSetUnderline(wxSTC_LUA_WORD6, true);
StyleSetForeground(wxSTC_LUA_WORD7, CLR(0,127,127));
StyleSetBackground(wxSTC_LUA_WORD7, CLR(240,255,255));
StyleSetForeground(wxSTC_LUA_WORD8, CLR(255,127,127));
StyleSetBackground(wxSTC_LUA_WORD8, CLR(224,255,255));
StyleSetForeground(wxSTC_LUA_LABEL, CLR(0,127,127)); // (style #20)
StyleSetBackground(wxSTC_LUA_LABEL, CLR(192,255,255));
// no idea, just before folders
StyleSetForeground(21, CLR(0,0,127));
StyleSetBackground(21, CLR(176,255,255));
StyleSetForeground(22, CLR(0,127,0));
StyleSetBackground(22, CLR(255,0,0));
// find highlight style
StyleSetForeground(23, CLR(0,80,0));
StyleSetBackground(23, CLR(144,255,144));
// Lua error annotation style (id 24)
StyleSetForeground(ANNOTATION_STYLE, COLOR_LUA_ERROR_ANNOTATION);
StyleSetBackground(ANNOTATION_STYLE, CLR(255, 255, 255));
StyleSetItalic(ANNOTATION_STYLE, true);
// UI colors
// default UI color (don't set)
// StyleSetForeground(wxSTC_STYLE_DEFAULT, CLR(224,192,224));
// StyleSetBackground(wxSTC_STYLE_DEFAULT, CLR(224,192,224));
// braces
StyleSetForeground(wxSTC_STYLE_BRACELIGHT, CLR(0,0,255));
StyleSetBold(wxSTC_STYLE_BRACELIGHT, true);
StyleSetForeground(wxSTC_STYLE_BRACEBAD, CLR(255,0,0));
StyleSetBold(wxSTC_STYLE_BRACEBAD, true);
// indentation guides
StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, CLR(192, 192, 255));
StyleSetBackground(wxSTC_STYLE_INDENTGUIDE, CLR(255, 255, 255));
SetUseTabs(true);
SetIndentationGuides(true);
SetVisiblePolicy(wxSTC_VISIBLE_SLOP, 3/*num vertical lines*/); // how far from border can it be
// SetXCaretPolicy(wxSTC_CARET_SLOP, 10);
// SetYCaretPolicy(wxSTC_CARET_SLOP, 3);
// line numbering -- margin ZERO is reserved for line number (style #33)
StyleSetForeground(wxSTC_STYLE_LINENUMBER, wxColour(20, 20, 20));
// StyleSetBackground(wxSTC_STYLE_LINENUMBER, CLR(220,220,220));
SetMarginWidth(MARGIN_LINE_NUMBERS, TextWidth(wxSTC_STYLE_LINENUMBER, "999999")); // TEMPORARY line # margin pixel width (is recomputed in real-time)
SetMarginMask(MARGIN_LINE_NUMBERS, 0xFFFFFF00);
// MarkerSetAlpha(0, 10);
// 4 marker symbols = 4 bits = 0xF
const uint32_t combo_marker_mask = 0x7E000000ul | (0xFl << 1/*after line numbers*/);
// #define wxSTC_MASK_FOLDERS 0xFE000000
// breakpoint margin
SetMarginWidth(MARGIN_BREAKPOINTS, 20/*width*/); // (based on bitmap)
SetMarginType(MARGIN_BREAKPOINTS, wxSTC_MARGIN_SYMBOL);
// MarkerDefine((int)MARKER_INDEX::BREAKPOINT, wxSTC_MARK_CIRCLE, COLOR_STROKE_BREAKPOINT, COLOR_FILL_BREAKPOINT); // built-in looks bumpy
MarkerDefineBitmap((int)MARKER_INDEX::BREAKPOINT, m_ImageList.GetBitmap(BITMAP_ID_RED_DOT));
SetMarginMask(MARGIN_BREAKPOINTS, combo_marker_mask);
SetMarginSensitive(MARGIN_BREAKPOINTS, true);
// current execution line highlight
SetMarginWidth(MARGIN_CURRENT_EXECUTION_LINE, 0/*width*/);
SetMarginType(MARGIN_CURRENT_EXECUTION_LINE, wxSTC_MARGIN_SYMBOL);
MarkerDefine((int)MARKER_INDEX::CURRENT_EXECUTION_LINE, wxSTC_MARK_BACKGROUND, wxColour(0, 255, 0), COLOR_CURRENT_EXECUTION_LINE);
SetMarginSensitive(MARGIN_CURRENT_EXECUTION_LINE, false);
SetMarginMask(MARGIN_CURRENT_EXECUTION_LINE, 0);
// current search result marker (1 per project)
SetMarginWidth(MARGIN_SELECTED_SEARCH_RESULT, 0/*width*/);
SetMarginType(MARGIN_SELECTED_SEARCH_RESULT, wxSTC_MARGIN_SYMBOL);
MarkerDefine((int)MARKER_INDEX::SELECTED_SEARCH_RESULT, wxSTC_MARK_SHORTARROW, COLOR_STROKE_SEARCH_HIGHLIGHT, COLOR_FILL_SEARCH_HIGHLIGHT);
SetMarginMask(MARGIN_SELECTED_SEARCH_RESULT, combo_marker_mask);
SetMarginSensitive(MARGIN_SELECTED_SEARCH_RESULT, false);
// user bookmark marker
SetMarginWidth(MARGIN_USER_BOOKMARK, 0/*width*/);
SetMarginType(MARGIN_USER_BOOKMARK, wxSTC_MARGIN_SYMBOL);
MarkerDefine((int)MARKER_INDEX::USER_BOOKMARK, wxSTC_MARK_ROUNDRECT, COLOR_STROKE_USER_BOOKMARK, COLOR_FILL_USER_BOOKMARK);
SetMarginMask(MARGIN_USER_BOOKMARK, combo_marker_mask);
SetMarginSensitive(MARGIN_USER_BOOKMARK, false);
}
//---- Setup Keywords ---------------------------------------------------------
void EditorCtrl::SetupKeywords(void)
{
SetLexer(wxSTC_LEX_LUA);
// (keywords ripped from scite 1.68)
SetKeyWords(0, "and break do else elseif end false for function if in local nil not or repeat return then true until while ");
SetKeyWords(1, "_VERSION assert collectgarbage dofile error gcinfo loadfile loadstring print rawget rawset require tonumber tostring type unpack ");
SetKeyWords(2, "_G getfenv getmetatable ipairs loadlib next pairs pcall rawequal setfenv setmetatable xpcall "
"string table math coroutine io os debug load module select ");
SetKeyWords(3, "string.byte string.char string.dump string.find string.len "
"string.lower string.rep string.sub string.upper string.format string.gfind string.gsub "
"table.concat table.foreach table.foreachi table.getn table.sort table.insert table.remove table.setn "
"math.abs math.acos math.asin math.atan math.atan2 math.ceil math.cos math.deg math.exp "
"math.floor math.frexp math.ldexp math.log math.log10 math.max math.min math.mod "
"math.pi math.pow math.rad math.random math.randomseed math.sin math.sqrt math.tan "
"string.gmatch string.match string.reverse table.maxn "
"math.cosh math.fmod math.modf math.sinh math.tanh math.huge");
SetKeyWords(4, "coroutine.create coroutine.resume coroutine.status coroutine.wrap coroutine.yield "
"io.close io.flush io.input io.lines io.open io.output io.read io.tmpfile io.type io.write "
"io.stdin io.stdout io.stderr "
"os.clock os.date os.difftime os.execute os.exit os.getenv os.remove os.rename "
"os.setlocale os.time os.tmpname "
"coroutine.running package.cpath package.loaded package.loadlib package.path "
"package.preload package.seeall io.popen "
"debug.debug debug.getfenv debug.gethook debug.getinfo debug.getlocal "
"debug.getmetatable debug.getregistry debug.getupvalue debug.setfenv "
"debug.sethook debug.setlocal debug.setmetatable debug.setupvalue debug.traceback ");
}
//---- Reload Char/Style Cache ------------------------------------------------
void EditorCtrl::ReloadStylCache(void)
{
const int end_pos = GetLastPosition();
assert(end_pos);
const size_t sz = end_pos + 1;
uLog(STYLED, "EditorCtrl::ReloadStylCache(%zu chars)", sz);
// allocates only if needed
m_CharStylBuff.resize(sz, {0, LUA_LEX_ILLEGAL});
// implemented in stc.cpp:376
// const size_t received_bytes = wxStyledTextCtrl::OnGetStyledText2(&m_CharStylBuff[0].m_char, sz * sizeof(styl_pair), 0/*startPos*/, end_pos);
const wxMemoryBuffer buff = GetStyledText(0/*startPos*/, end_pos); // TOO SLOW ???
const size_t received_bytes = buff.GetDataLen();
assert((received_bytes & 1ul) == 0);
const size_t received_elms = received_bytes / sizeof(styl_pair);
assert(received_elms < sz);
const void *p = buff.GetData();
assert(p);
memcpy(&m_CharStylBuff[0].m_char, p, received_bytes);
// de-swizzle
m_CharBuff.resize(received_elms, 0);
for (size_t i = 0; i < received_elms; i++)
m_CharBuff[i] = m_CharStylBuff[i].m_char;
// terminator is IMPORTANT
m_CharBuff.push_back(0);
MixDelay(STC_FUNCTION_REFRESH_GROUP, STC_FUNCTION_REFRESH_DELAY_MS, this, &EditorCtrl::OnReloadLuaFunctions);
}
//---- On Reload Lua Functions ------------------------------------------------
void EditorCtrl::OnReloadLuaFunctions(void)
{
const string shortname = GetCurrentSFC()->GetShortName();
// copy to comment-free buffer
string char_buff;
vector<size_t> rawPosLUT;
const size_t len = m_CharStylBuff.size();
char_buff.reserve(len); // too conservative!
rawPosLUT.reserve(len);
for (size_t i = 0; i < len; i++)
{
const LEXER_T styl = m_CharStylBuff[i].m_styl;
if (s_CommentStyleSet.count(styl)) continue;
char_buff.push_back(m_CharStylBuff[i].m_char);
rawPosLUT.push_back(i);
}
#if 0
for (int ln = 0; ln <= LineFromPosition(GetLastPosition()); ln++)
{
const int raw_lvl = GetFoldLevel(ln);
const bool header_f = (raw_lvl & wxSTC_FOLDLEVELHEADERFLAG);
const int lvl = (raw_lvl & wxSTC_FOLDLEVELNUMBERMASK) - wxSTC_FOLDLEVELBASE;
if ((lvl == 0) && (!header_f)) continue;
const int parent_ln = GetFoldParent(ln); // & wxSTC_FOLDLEVELNUMBERMASK;
uLog(STC_FUNCTION, " [%3d] level %2d, parent ln %3d, header %c", ln, lvl, parent_ln, header_f);
}
#endif
StopWatch sw;
vector<Bookmark> bmks;
auto it = char_buff.cbegin();
smatch matches;
while (regex_search(it, char_buff.cend(), matches/*&*/, LUA_FUNCTION_RE))
{
const int n_matches = matches.size();
assert(n_matches == 3);
// const string full_match_s = matches[0];
assert(matches[1].matched ^ matches[2].matched); // matches either/or (not both or none)
const size_t match_ind = matches[1].matched ? 1 : 2;
const string fname_s = matches[match_ind];
assert(!fname_s.empty());
const auto fname_offset = matches.position(match_ind);
const size_t org_pos = it - char_buff.cbegin();
const size_t pos = org_pos + fname_offset;
assert(pos < rawPosLUT.size());
const size_t raw_pos = rawPosLUT[pos];
// string it_s(it, char_buff.cend());
it = char_buff.cbegin() + pos + fname_s.length() + 1; // (pre-advance)
assert(it < char_buff.cend());
// it_s.assign(it, char_buff.cend());
const LEXER_T styl = m_CharStylBuff[raw_pos].m_styl;
assert(s_CommentStyleSet.count(styl) == 0); // should no longer have comments (were stripped)
if (s_DormantStyleSet.count(styl)) continue; // inside string, skip
if (s_IgnoreFunctionsSet.count(fname_s)) continue; // reserved name, skip
const int ln = LineFromPosition(raw_pos) + 1;
uLog(STC_FUNCTION, " %s:%d", fname_s, ln);
bmks.emplace_back(fname_s, ln);
}
uLog(STOPWATCH, " regexed %zu chars, collected %zu functions, took %s", char_buff.size(), bmks.size(), sw.elap_str());
stringstream ss;
for (const auto &elm : bmks)
{
ss << elm.m_Name << " ";
}
// should be GLOBAL to project!!! (could take long time?)
SetKeyWords(5, wxString(ss.str()));
m_Signals.OnEditorFunctionsChanged(CTX_WX, shortname, bmks);
}
//---- Get User Bookmarks -----------------------------------------------------
vector<int> EditorCtrl::GetUserBookmarks(void)
{
const int n_lines = GetNumberOfLines();
const uint32_t mask = 1L << (int) MARKER_INDEX::USER_BOOKMARK;
vector<int> lines;
for (int i = 0; i < n_lines; i++)
{
if (!(MarkerGet(i) & mask)) continue; // non-const !
lines.push_back(i + 1);
}
return lines;
}
//---- INSTANTIATE ------------------------------------------------------------
// static
IEditorCtrl* IEditorCtrl::CreateStyled(wxWindow *parent_win, int id, ITopNotePanel &topnotebook, wxImageList &img_list)
{
return new EditorCtrl(parent_win, id, topnotebook, img_list);
}
// nada mas
| 28.070886 | 151 | 0.685313 | [
"vector",
"3d"
] |
5bea22c15c8daf97fe3946ef7e7dc24c482516d9 | 2,434 | cpp | C++ | Algorithms/Magic Squares In Grid/solution.cpp | MishaVernik/LeetCode | 5f4823706f472b59fbc0c936524477dc039a46ee | [
"MIT"
] | null | null | null | Algorithms/Magic Squares In Grid/solution.cpp | MishaVernik/LeetCode | 5f4823706f472b59fbc0c936524477dc039a46ee | [
"MIT"
] | null | null | null | Algorithms/Magic Squares In Grid/solution.cpp | MishaVernik/LeetCode | 5f4823706f472b59fbc0c936524477dc039a46ee | [
"MIT"
] | null | null | null | /**
A 3 x 3 magic square is a 3 x 3 grid filled with distinct numbers from 1 to 9 such that each row, column, and both diagonals all have the same sum.
Given an grid of integers, how many 3 x 3 "magic square" subgrids are there? (Each subgrid is contiguous).
Example 1:
Input: [[4,3,8,4],
[9,5,1,9],
[2,7,6,2]]
Output: 1
Explanation:
The following subgrid is a 3 x 3 magic square:
438
951
276
while this one is not:
384
519
762
In total, there is only one magic square inside the given grid.
Note:
1 <= grid.length <= 10
1 <= grid[0].length <= 10
0 <= grid[i][j] <= 15
*/
class Solution {
public:
bool isMagicSquare(vector<vector<int>> square, int curI, int curJ){
int sum = 0;
int arr[10] = {0,};
for (int i = 0 ;i < 3; i++){
for (int j = 0 ;j < 3; j++){
if (square[i+curI][j+curJ] <= 9 && square[i+curI][j+curJ] >= 1){
if (arr[square[i + curI][j + curJ]] == 0)
arr[square[i+curI][j+curJ]] = 1;
else
return false;} else return false;
}
}
for (int i = 0; i < 3; i++)
sum += square[i+curI][0+curJ];
// diagonals
int leftD = 0;
int rightD = 0;
for (int i = 0; i < 3; i++){
leftD += square[i+curI][i+curJ];
rightD += square[2-i+curI][i+curJ];
}
// cout << leftD << " " << rightD << endl;
if (leftD != sum || rightD != sum) return false;
for (int i = 0 ; i < 3; i++){
leftD = 0;
rightD = 0;
for (int j = 0; j < 3; j++){
rightD += square[i+curI][j+curJ];
// cout << square[j+curI][i+curJ] << endl;
leftD += square[j+curI][i+curJ];
}
// cout << leftD << " " << rightD << endl;
if (leftD != sum || rightD != sum) return false;
}
return true;
}
int numMagicSquaresInside(vector<vector<int>>& grid) {
if (grid.size() < 3) return 0;
if (grid[0].size() < 3) return 0;
int ans = 0;
for (int i = 0; i < grid.size()-2; i++){
for (int j = 0; j < grid[i].size()-2; j++){
if (isMagicSquare(grid, i, j)) ans++;
}
}
return ans;
}
}; | 28.302326 | 147 | 0.450288 | [
"vector"
] |
5bf97ed5609b858aa86c7e35d0518d0dbb59d3c4 | 2,957 | cpp | C++ | src/sources/Model.cpp | QwertygidQ/ModelViewer | 7808b9b81a26528016a5dc1216fb0bf51b166e87 | [
"MIT"
] | null | null | null | src/sources/Model.cpp | QwertygidQ/ModelViewer | 7808b9b81a26528016a5dc1216fb0bf51b166e87 | [
"MIT"
] | null | null | null | src/sources/Model.cpp | QwertygidQ/ModelViewer | 7808b9b81a26528016a5dc1216fb0bf51b166e87 | [
"MIT"
] | null | null | null | #include "../headers/Model.hpp"
#include <glad/glad.h>
#include <cstdlib>
#include <fstream>
#include <sstream>
#include <stdexcept>
void Model::load_model(const std::string &obj_path)
{
std::ifstream file(obj_path);
if (!file)
throw std::runtime_error("Failed to open the model file");
std::string line;
while(!file.eof())
{
std::getline(file, line);
std::stringstream ss(line);
std::string trash;
ss >> trash; // gets rid of v/vn/vt/f
if (line.compare(0, 2, "v ") == 0)
{
glm::vec3 vec;
for (size_t i = 0; i < 3; i++)
ss >> vec[i];
vertices.push_back(vec);
}
else if (line.compare(0, 3, "vn ") == 0)
{
glm::vec3 vec;
for (size_t i = 0; i < 3; i++)
ss >> vec[i];
normals.push_back(vec);
}
else if (line.compare(0, 3, "vt ") == 0)
{
glm::vec2 vec;
for (size_t i = 0; i < 2; i++)
ss >> vec[i];
uvs.push_back(vec);
}
else if (line.compare(0, 2, "f ") == 0)
{
char c_trash; // gets rid of slashes in f
std::vector<glm::vec3> f;
glm::vec3 vec;
while(ss >> vec[0] >> c_trash >> vec[1] >> c_trash >> vec[2])
{
for (size_t i = 0; i < 3; i++)
vec[i]--;
f.push_back(vec);
}
faces.push_back(f);
}
}
}
void Model::set_up_VAO()
{
std::vector<float> vertex_data;
for (size_t iface = 0; iface < faces.size(); iface++)
{
for (size_t ivertex = 0; ivertex < 3; ivertex++)
{
glm::vec3 vertex = vertices[faces[iface][ivertex][VERTEX]];
for (size_t i = 0; i < 3; i++)
vertex_data.push_back(vertex[i]);
glm::vec2 uv = uvs[faces[iface][ivertex][UV]];
for (size_t i = 0; i < 2; i++)
vertex_data.push_back(uv[i]);
}
}
const float *data = vertex_data.data();
size_t size = vertex_data.size() * sizeof(float);
glGenVertexArrays(1, &VAO);
glBindVertexArray(VAO);
unsigned int VBO;
glGenBuffers(1, &VBO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, size, data, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)0); // position
glEnableVertexAttribArray(0);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)(sizeof(float) * 3)); // uv
glEnableVertexAttribArray(1);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
Model::Model(const std::string &obj_path)
{
load_model(obj_path);
set_up_VAO();
}
void Model::draw() const
{
glBindVertexArray(VAO);
glDrawArrays(GL_TRIANGLES, 0, faces.size() * 3);
glBindVertexArray(0);
} | 25.273504 | 105 | 0.518431 | [
"vector",
"model"
] |
5bff1c462c57edef541905512bae3d6415975620 | 62,145 | cpp | C++ | projects/gui/darwin.cpp | exoad/drwn | 3cc9faaa99602cb7ab69af795ec6e4194ff1919f | [
"BSD-3-Clause"
] | 40 | 2015-01-26T21:58:25.000Z | 2021-11-03T13:52:40.000Z | projects/gui/darwin.cpp | exoad/drwn | 3cc9faaa99602cb7ab69af795ec6e4194ff1919f | [
"BSD-3-Clause"
] | 7 | 2015-04-08T23:44:17.000Z | 2016-05-09T11:29:38.000Z | projects/gui/darwin.cpp | exoad/drwn | 3cc9faaa99602cb7ab69af795ec6e4194ff1919f | [
"BSD-3-Clause"
] | 32 | 2015-01-12T01:47:58.000Z | 2022-01-12T10:08:59.000Z | /*****************************************************************************
** DARWIN: A FRAMEWORK FOR MACHINE LEARNING RESEARCH AND DEVELOPMENT
** Distributed under the terms of the BSD license (see the LICENSE file)
** Copyright (c) 2007-2017, Stephen Gould
** All rights reserved.
**
******************************************************************************
** FILENAME: darwin.cpp
** AUTHOR(S): Stephen Gould <stephen.gould@anu.edu.au>
**
*****************************************************************************/
#if defined(_WIN32)||defined(WIN32)||defined(__WIN32__)||(__VISUALC__)
#define _USE_MATH_DEFINES
#endif
// C++ Standard Headers
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <limits>
#include <iostream>
#include <fstream>
#include <deque>
#if defined(__LINUX__)
#include <dlfcn.h>
#endif
// wxWidgets Headers
#include "wx/wx.h"
#include "wx/utils.h"
#include "wx/wxprec.h"
#include "wx/dcbuffer.h"
#include "wx/splitter.h"
#include "wx/aboutdlg.h"
#include "wx/dynlib.h"
#ifdef __WXMAC__
#include <ApplicationServices/ApplicationServices.h>
#endif
// Darwin Library Headers
#include "drwnBase.h"
#include "drwnEngine.h"
// Application Headers
#include "darwin.h"
#include "drwnIconFactory.h"
#include "drwnOptionsEditor.h"
#include "drwnTextEditor.h"
#include "resources/darwin.xpm"
using namespace std;
#define NOT_IMPLEMENTED_YET wxMessageBox("Functionality not implementet yet.", \
"Error", wxOK | wxICON_EXCLAMATION, this);
// Global Variables and Tables -------------------------------------------------
MainWindow *gMainWindow = NULL;
// Event Tables ----------------------------------------------------------------
BEGIN_EVENT_TABLE(MainCanvas, wxWindow)
EVT_ERASE_BACKGROUND(MainCanvas::on_erase_background)
EVT_SIZE(MainCanvas::on_size)
EVT_PAINT(MainCanvas::on_paint)
EVT_CHAR(MainCanvas::on_key)
EVT_MOUSE_EVENTS(MainCanvas::on_mouse)
// node popup
EVT_MENU(NODE_POPUP_SET_NAME, MainCanvas::on_popup_menu)
EVT_MENU(NODE_POPUP_PROPERTIES, MainCanvas::on_popup_menu)
EVT_MENU(NODE_POPUP_SHOWHIDE, MainCanvas::on_popup_menu)
EVT_MENU(NODE_POPUP_EVALUATE, MainCanvas::on_popup_menu)
EVT_MENU(NODE_POPUP_UPDATE, MainCanvas::on_popup_menu)
EVT_MENU(NODE_POPUP_PROPBACK, MainCanvas::on_popup_menu)
EVT_MENU(NODE_POPUP_RESETPARAMS, MainCanvas::on_popup_menu)
EVT_MENU(NODE_POPUP_INITPARAMS, MainCanvas::on_popup_menu)
EVT_MENU_RANGE(NODE_POPUP_INPORT_BASE, NODE_POPUP_INPORT_BASE + 100,
MainCanvas::on_popup_menu)
EVT_MENU_RANGE(NODE_POPUP_OUTPORT_BASE, NODE_POPUP_OUTPORT_BASE + 100,
MainCanvas::on_popup_menu)
EVT_MENU(NODE_POPUP_DISCONNECT, MainCanvas::on_popup_menu)
EVT_MENU(NODE_POPUP_DELETE, MainCanvas::on_popup_menu)
// graph popup
EVT_MENU(POPUP_SET_TITLE, MainCanvas::on_popup_menu)
EVT_MENU_RANGE(POPUP_NODE_INSERT_BASE, POPUP_NODE_INSERT_BASE + 1000,
MainCanvas::on_popup_menu)
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(MainWindow, wxFrame)
EVT_IDLE(MainWindow::on_idle)
EVT_CLOSE(MainWindow::on_close)
EVT_MENU(FILE_NEW, MainWindow::on_file_menu)
EVT_MENU(FILE_OPEN, MainWindow::on_file_menu)
EVT_MENU(FILE_SAVE, MainWindow::on_file_menu)
EVT_MENU(FILE_SAVEAS, MainWindow::on_file_menu)
EVT_MENU(FILE_CLOSE, MainWindow::on_file_menu)
EVT_MENU(FILE_CLOSEALL, MainWindow::on_file_menu)
EVT_MENU(FILE_EXPORT_HTML, MainWindow::on_file_menu)
EVT_MENU(FILE_EXPORT_CODE, MainWindow::on_file_menu)
EVT_MENU(FILE_EXPORT_SCRIPT, MainWindow::on_file_menu)
EVT_MENU(FILE_EXIT, MainWindow::on_file_menu)
EVT_MENU(EDIT_UNDO, MainWindow::on_edit_menu)
EVT_MENU(EDIT_REDO, MainWindow::on_edit_menu)
EVT_MENU(EDIT_CUT, MainWindow::on_edit_menu)
EVT_MENU(EDIT_COPY, MainWindow::on_edit_menu)
EVT_MENU(EDIT_PASTE, MainWindow::on_edit_menu)
EVT_MENU(EDIT_DELETE, MainWindow::on_edit_menu)
EVT_MENU(EDIT_FIND, MainWindow::on_edit_menu)
EVT_MENU(EDIT_SELECTALL, MainWindow::on_edit_menu)
EVT_MENU(EDIT_DESELECTALL, MainWindow::on_edit_menu)
EVT_MENU(NETWORK_RESET, MainWindow::on_network_menu)
EVT_MENU(NETWORK_EVALUATE, MainWindow::on_network_menu)
EVT_MENU(NETWORK_UPDATE, MainWindow::on_network_menu)
EVT_MENU(NETWORK_BACKPROP, MainWindow::on_network_menu)
EVT_MENU(NETWORK_INITPARAMS, MainWindow::on_network_menu)
EVT_MENU(NETWORK_GRIDSNAP, MainWindow::on_network_menu)
EVT_MENU(DATABASE_CONNECT, MainWindow::on_database_menu)
EVT_MENU(DATABASE_VIEW_TABLES, MainWindow::on_database_menu)
EVT_MENU(DATABASE_VIEW_INSTANCES, MainWindow::on_database_menu)
EVT_MENU(DATABASE_IMPORT_COLOURS, MainWindow::on_database_menu)
EVT_MENU(DATABASE_RANDOMIZE_COLOURS, MainWindow::on_database_menu)
EVT_MENU(DATABASE_FLUSH_CACHE, MainWindow::on_database_menu)
EVT_MENU(OPTIONS_DISPLAY_VERBOSE, MainWindow::on_options_menu)
EVT_MENU(OPTIONS_DISPLAY_MESSAGE, MainWindow::on_options_menu)
EVT_MENU(OPTIONS_DISPLAY_WARNING, MainWindow::on_options_menu)
EVT_MENU(OPTIONS_BEEP, MainWindow::on_options_menu)
EVT_MENU(OPTIONS_CLEAR_LOG, MainWindow::on_options_menu)
EVT_MENU(OPTIONS_SAVE_LOG, MainWindow::on_options_menu)
EVT_MENU(OPTIONS_TILE_WINDOWS, MainWindow::on_options_menu)
EVT_MENU_RANGE(WINDOW_MENU_BASE, WINDOW_MENU_BASE + 99,
MainWindow::on_window_menu)
EVT_MENU(HELP_DRWN_CONTENTS, MainWindow::on_help_menu)
EVT_MENU(HELP_RELEASE_NOTES, MainWindow::on_help_menu)
EVT_MENU(HELP_ABOUT, MainWindow::on_help_menu)
END_EVENT_TABLE()
// GUI Callbacks ---------------------------------------------------------------
void messageCallback(const char *message)
{
if (gMainWindow == NULL) {
cout << "--- " << message << "\n";
} else {
if (drwnLogger::getLogLevel() >= DRWN_LL_DEBUG) {
cout << "--- " << message << "\n";
}
gMainWindow->logMessage(message);
}
}
void warningCallback(const char *message)
{
if (drwnLogger::getLogLevel() >= DRWN_LL_DEBUG) {
cerr << "-W- " << message << "\n";
}
gMainWindow->logMessage((string("WARNING: ") + string(message)).c_str(),
wxTextAttr(*wxBLUE));
}
void errorCallback(const char *message)
{
if (drwnLogger::getLogLevel() >= DRWN_LL_DEBUG) {
cerr << "-E- " << message << "\n";
}
gMainWindow->logMessage((string("ERROR: ") + string(message)).c_str(),
wxTextAttr(*wxRED));
}
void fatalCallback(const char *message)
{
cerr << "-*- " << message << "\n";
wxMessageBox(message, "Fatal Error", wxOK | wxICON_ERROR, NULL);
exit(-1);
}
void progressCallback(const char *status, double progress)
{
if (gMainWindow != NULL) {
gMainWindow->updateProgress(status, progress);
}
}
// MainCanvas Implementation ---------------------------------------------------
int MainCanvas::_creationCount = 0;
MainCanvas::MainCanvas(wxWindow *parent, wxWindowID id,const wxPoint& pos,
const wxSize& size, long style, const wxString& name) :
wxScrolledWindow(parent, id, pos, size, style, name), _graph(NULL),
_activeNode(NULL), _activePort(NULL), _bSnapToGrid(true), _mouseMode(MM_NONE),
_nodePopupMenu(NULL), _portSubMenuItem(NULL), _connectPopupMenu(NULL),
_newNodePopupMenu(NULL)
{
_creationCount += 1;
_graph = new drwnGraph(("New Network " + toString(_creationCount)).c_str());
// initialize GUI elements
this->SetBackgroundStyle(wxBG_STYLE_PAINT);
this->SetBackgroundColour(*wxWHITE);
//this->SetScrollbars(1, 1, 320, 240, 0, 0, true);
this->SetVirtualSize(1024, 1024); // TODO: set this dynamically (size of graph + delta)
this->SetScrollRate(1, 1);
// create node popup menu
_nodePopupMenu = new wxMenu();
_nodePopupMenu->Append(NODE_POPUP_SET_NAME, "Set &Name...");
_nodePopupMenu->Append(NODE_POPUP_PROPERTIES, "&Properties...");
_nodePopupMenu->AppendSeparator();
_nodePopupMenu->Append(NODE_POPUP_SHOWHIDE, "&Show...");
_nodePopupMenu->AppendSeparator();
_nodePopupMenu->Append(NODE_POPUP_EVALUATE, "&Evaluate Forwards");
_nodePopupMenu->Append(NODE_POPUP_UPDATE, "&Update Forwards");
_nodePopupMenu->Append(NODE_POPUP_PROPBACK, "&Propagate Backwards");
_nodePopupMenu->Append(NODE_POPUP_RESETPARAMS, "&Reset Parameters");
_nodePopupMenu->Append(NODE_POPUP_INITPARAMS, "&Estimate Parameters");
_nodePopupMenu->AppendSeparator();
_portSubMenuItem = _nodePopupMenu->AppendSubMenu(new wxMenu(), "Connect");
_connectPopupMenu = new wxMenu();
_nodePopupMenu->Append(NODE_POPUP_DISCONNECT, "Disconnect &All");
_nodePopupMenu->AppendSeparator();
_nodePopupMenu->Append(NODE_POPUP_DELETE, "&Delete");
// create new node popup menu
// TODO: put into own class
_newNodePopupMenu = new wxMenu();
_newNodePopupMenu->Append(POPUP_SET_TITLE, "Set &Title...");
_newNodePopupMenu->AppendSeparator();
int indx = 0;
vector<string> groupNames = drwnNodeFactory::get().getGroups();
for (vector<string>::const_iterator ig = groupNames.begin(); ig != groupNames.end(); ig++) {
wxMenu *groupMenu = new wxMenu();
// add nodes
vector<string> nodeNames = drwnNodeFactory::get().getNodes(ig->c_str());
for (vector<string>::const_iterator it = nodeNames.begin(); it != nodeNames.end(); it++) {
string name = drwn::strReplaceSubstr(drwn::strSpacifyCamelCase(*it), string("drwn "), string());
groupMenu->Append(POPUP_NODE_INSERT_BASE + indx, name);
indx++;
}
// add to popup
_newNodePopupMenu->AppendSubMenu(groupMenu, (string("Add ") + *ig).c_str());
}
}
MainCanvas::~MainCanvas()
{
// delete graph (database will be closed automtically)
if (_graph != NULL) {
delete _graph;
}
// delete gui elements
if (_nodePopupMenu != NULL) {
delete _nodePopupMenu;
}
if (_newNodePopupMenu != NULL) {
delete _newNodePopupMenu;
}
if (_connectPopupMenu != NULL) {
delete _connectPopupMenu;
}
}
void MainCanvas::on_erase_background(wxEraseEvent &event)
{
// do nothing (and avoid flicker)
}
void MainCanvas::on_paint(wxPaintEvent &WXUNUSED(event))
{
const int SELWIDTH = 3;
const int ARROWLEN = 7;
const int ARROWWTH = 4;
int width, height;
GetVirtualSize(&width, &height);
int clientX, clientY, clientWidth, clientHeight;
GetViewStart(&clientX, &clientY);
GetClientSize(&clientWidth, &clientHeight);
//wxPaintDC dc(this);
wxAutoBufferedPaintDC dc(this);
DoPrepareDC(dc); // for scroll window
dc.Clear();
dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
// draw grid
if (_bSnapToGrid) {
#ifdef __LINUX__
dc.SetPen(wxPen(*wxLIGHT_GREY, 1, wxSHORT_DASH));
#else
dc.SetPen(wxPen(*wxLIGHT_GREY, 1, wxDOT));
#endif
for (int y = 16; y < height - 1; y += 32) {
dc.DrawLine(0, y, width, y);
}
for (int x = 16; x < width - 1; x += 32) {
dc.DrawLine(x, 0, x, height);
}
}
DRWN_ASSERT(_graph != NULL);
// draw title (TODO: add titlebar?)
dc.SetTextForeground(wxColor(0, 0, 255));
wxSize s = dc.GetTextExtent(_graph->getTitle().c_str());
dc.DrawText(_graph->getTitle().c_str(), (int)(clientWidth - s.x)/2, 0);
// draw arrows
for (int i = 0; i < _graph->numNodes(); i++) {
const drwnNode *node = _graph->getNode(i);
const wxBitmap *nodeIcon = gIconFactory.getIcon(node->type());
int tx = node->getLocationX() + nodeIcon->GetWidth()/2;
int ty = node->getLocationY() + nodeIcon->GetHeight()/2;
for (int j = 0; j < node->numInputPorts(); j++) {
const drwnInputPort *port = node->getInputPort(j);
if (port->getSource() == NULL) continue;
const drwnNode *dstNode = port->getSource()->getOwner();
if (dstNode == NULL) continue;
int sx = dstNode->getLocationX() + nodeIcon->GetWidth()/2;
int sy = dstNode->getLocationY() + nodeIcon->GetHeight()/2;
double dx = tx - sx;
double dy = ty - sy;
double len = sqrt(dx * dx + dy * dy);
dx /= len;
dy /= len;
int ddx = (int)(nodeIcon->GetWidth() * dx * M_SQRT1_2);
int ddy = (int)(nodeIcon->GetHeight() * dy * M_SQRT1_2);
dc.SetPen(wxPen(*wxBLACK, 2));
dc.DrawLine((int)(sx + ddx), (int)(sy + ddy), (int)(tx - ddx), (int)(ty - ddy));
wxPoint arrow[3];
arrow[0] = wxPoint((int)(tx - ddx), (int)(ty - ddy));
arrow[1] = wxPoint((int)(tx - ddx - ARROWLEN * dx + ARROWWTH * dy),
(int)(ty - ddy - ARROWLEN * dy - ARROWWTH * dx));
arrow[2] = wxPoint((int)(tx - ddx - ARROWLEN * dx - ARROWWTH * dy),
(int)(ty - ddy - ARROWLEN * dy + ARROWWTH * dx));
dc.SetPen(wxPen(*wxBLACK, 1));
dc.SetBrush(*wxBLACK_BRUSH);
dc.DrawPolygon(3, arrow);
}
}
// draw nodes
wxBrush selBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT), wxSOLID);
for (int i = 0; i < _graph->numNodes(); i++) {
drwnNode *node = _graph->getNode(i);
int nx = node->getLocationX();
int ny = node->getLocationY();
bool bSelected = (_selectedNodes.find(node) != _selectedNodes.end()) &&
(_mouseMode != MM_DRAGGING);
// draw bitmap
const wxBitmap *nodeIcon = gIconFactory.getIcon(node->type());
if (bSelected) {
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(selBrush);
dc.DrawRectangle(nx - SELWIDTH, ny - SELWIDTH,
nodeIcon->GetWidth() + 2 * SELWIDTH, nodeIcon->GetHeight() + 2 * SELWIDTH);
}
dc.DrawBitmap(*nodeIcon, nx, ny, true);
// draw text
vector<string> nameTokens;
drwn::parseString(node->getName(), nameTokens);
DRWN_ASSERT_MSG(!nameTokens.empty(), "\"" << node->getName() << "\"");
vector<string> lines;
lines.push_back(nameTokens[0]);
for (int i = 1; i < (int)nameTokens.size(); i++) {
wxSize s = dc.GetTextExtent(lines.back() + string(" ") + nameTokens[i]);
if (s.x > 3 * nodeIcon->GetWidth()) {
if (!bSelected && (lines.size() == 2)) {
lines.push_back(string("..."));
break;
}
lines.push_back(nameTokens[i]);
} else {
lines.back() += string(" ") + nameTokens[i];
}
}
if (!bSelected) {
for (int i = 0; i < (int)lines.size(); i++) {
s = dc.GetTextExtent(lines[i]);
if (s.x > 3 * nodeIcon->GetWidth()) {
while (s.x > 3 * nodeIcon->GetWidth()) {
lines[i].resize(lines[i].length() - 1);
s = dc.GetTextExtent(lines[i] + string("..."));
}
lines[i] = lines[i] + string("...");
}
}
}
if (bSelected) {
int maxExtentX = 0;
for (int i = 0; i < (int)lines.size(); i++) {
s = dc.GetTextExtent(lines[i]);
maxExtentX = std::max(maxExtentX, s.x);
}
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(selBrush);
dc.DrawRectangle(nx + (nodeIcon->GetWidth() - maxExtentX)/2 - SELWIDTH,
ny + nodeIcon->GetHeight(),
maxExtentX + 2 * SELWIDTH, lines.size() * s.y + SELWIDTH);
}
// boundary around text
dc.SetTextForeground(bSelected ? wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT) :
dc.GetTextBackground());
for (int i = 0; i < (int)lines.size(); i++) {
s = dc.GetTextExtent(lines[i]);
dc.DrawText(lines[i].c_str(), nx + (nodeIcon->GetWidth() - s.x)/2 - 1,
ny + nodeIcon->GetHeight() + i * s.y + 2 - 1);
dc.DrawText(lines[i].c_str(), nx + (nodeIcon->GetWidth() - s.x)/2 + 1,
ny + nodeIcon->GetHeight() + i * s.y + 2 + 1);
dc.DrawText(lines[i].c_str(), nx + (nodeIcon->GetWidth() - s.x)/2 - 1,
ny + nodeIcon->GetHeight() + i * s.y + 2 + 1);
dc.DrawText(lines[i].c_str(), nx + (nodeIcon->GetWidth() - s.x)/2 + 1,
ny + nodeIcon->GetHeight() + i * s.y + 2 - 1);
dc.DrawText(lines[i].c_str(), nx + (nodeIcon->GetWidth() - s.x)/2 - 2,
ny + nodeIcon->GetHeight() + i * s.y + 2 - 2);
dc.DrawText(lines[i].c_str(), nx + (nodeIcon->GetWidth() - s.x)/2 + 2,
ny + nodeIcon->GetHeight() + i * s.y + 2 + 2);
dc.DrawText(lines[i].c_str(), nx + (nodeIcon->GetWidth() - s.x)/2 - 2,
ny + nodeIcon->GetHeight() + i * s.y + 2 + 2);
dc.DrawText(lines[i].c_str(), nx + (nodeIcon->GetWidth() - s.x)/2 + 2,
ny + nodeIcon->GetHeight() + i * s.y + 2 - 2);
}
//visible text
dc.SetTextForeground(bSelected ?
wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT) : wxColor(0, 0, 0));
for (int i = 0; i < (int)lines.size(); i++) {
s = dc.GetTextExtent(lines[i]);
dc.DrawText(lines[i].c_str(), nx + (nodeIcon->GetWidth() - s.x)/2,
ny + nodeIcon->GetHeight() + i * s.y + 2);
}
}
// draw connection
// TODO: move to on_mouse event like selection rubber-band
if ((_mouseMode == MM_CONNECTING_INPUT) || (_mouseMode == MM_CONNECTING_OUTPUT)) {
drwnNode *node = _activePort->getOwner();
dc.SetPen(wxPen(*wxRED, 2));
dc.DrawLine(node->getLocationX() + 32/2, node->getLocationY() + 32/2,
_lastMousePoint.x, _lastMousePoint.y);
}
}
void MainCanvas::on_size(wxSizeEvent &event)
{
int width, height;
GetClientSize(&width, &height);
this->Refresh(false);
this->Update();
}
void MainCanvas::on_key(wxKeyEvent &event)
{
switch (event.m_keyCode) {
case WXK_TAB:
{
if (_graph->numNodes() > 0) {
int indx = 0;
if (!_selectedNodes.empty()) {
// find currently selected node and move to next one
while (_graph->getNode(indx) != *_selectedNodes.begin()) {
indx++;
}
if (event.m_shiftDown) {
indx = (indx + _graph->numNodes() - 1) % _graph->numNodes();
} else {
indx = (indx + 1) % _graph->numNodes();
}
}
_selectedNodes.clear();
_selectedNodes.insert(_graph->getNode(indx));
}
break;
}
default:
event.Skip();
}
// refresh view
updateStatusBar();
this->Refresh(false);
this->Update();
}
void MainCanvas::on_mouse(wxMouseEvent &event)
{
//_mousePoint = wxPoint(event.m_x, event.m_y);
CalcUnscrolledPosition(event.m_x, event.m_y, &_mousePoint.x, &_mousePoint.y);
if (event.LeftDown()) {
//_buttonDownPoint = wxPoint(event.m_x, event.m_y);
CalcUnscrolledPosition(event.m_x, event.m_y, &_buttonDownPoint.x, &_buttonDownPoint.y);
// cancel connecting
if ((_mouseMode == MM_CONNECTING_INPUT) || (_mouseMode == MM_CONNECTING_OUTPUT)) {
if ((_activeNode == NULL) || (_activeNode == _activePort->getOwner())) {
if (_mouseMode == MM_CONNECTING_INPUT) {
((drwnInputPort *)_activePort)->disconnect();
} else {
((drwnOutputPort *)_activePort)->disconnect();
}
_mouseMode = MM_NONE;
_activePort = NULL;
} else if (_activeNode != NULL) {
updatePortSubMenu(_activeNode);
PopupMenu(_connectPopupMenu);
}
}
} else if (event.LeftUp() && (_mouseMode == MM_NONE)) {
// clicked on node or in empty space?
if (_activeNode != NULL) {
// node not already selected?
if (_selectedNodes.find(_activeNode) == _selectedNodes.end()) {
if (!event.ShiftDown() && !event.ControlDown()) {
_selectedNodes.clear();
}
_selectedNodes.insert(_activeNode);
} else {
if (!event.ShiftDown() && !event.ControlDown()) {
if (_selectedNodes.size() > 1) {
_selectedNodes.clear();
_selectedNodes.insert(_activeNode);
} else {
_selectedNodes.clear();
}
} else {
_selectedNodes.erase(_activeNode);
}
}
} else if (!event.ShiftDown()) {
_selectedNodes.clear();
}
// refresh display
this->Refresh(false);
this->Update();
} else if (event.LeftUp()) {
if ((_mouseMode == MM_SELECTING) || (_mouseMode == MM_SELECTING_NOERASE)) {
// finished selecting
if (!event.ShiftDown()) {
_selectedNodes.clear();
}
selectNodesInRegion(_buttonDownPoint.x, _buttonDownPoint.y,
_lastMousePoint.x - _buttonDownPoint.x, _lastMousePoint.y - _buttonDownPoint.y);
_mouseMode = MM_NONE;
} else if (_mouseMode == MM_DRAGGING) {
// finished moving
if (_bSnapToGrid) {
for (set<drwnNode *>::iterator it = _selectedNodes.begin();
it != _selectedNodes.end(); it++) {
int nx = 32 * ((int)((*it)->getLocationX() + 16) / 32);
int ny = 32 * ((int)((*it)->getLocationY() + 16) / 32);
(*it)->setLocation(nx, ny);
}
}
_mouseMode = MM_NONE;
}
// refresh display
this->Refresh(false);
this->Update();
} else if ((event.Entering() || event.Leaving()) && (_mouseMode == MM_SELECTING)) {
// refresh display
this->Refresh(false);
this->Update();
_mouseMode = MM_SELECTING_NOERASE;
} else if (event.Dragging()) {
if (_activeNode == NULL) {
// selecting
wxClientDC dc(this); // since not in on_paint event
DoPrepareDC(dc);
dc.SetPen(*wxBLACK_PEN);
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.SetLogicalFunction(wxINVERT);
if (_mouseMode == MM_SELECTING) {
dc.DrawRectangle(_buttonDownPoint.x, _buttonDownPoint.y,
_lastMousePoint.x - _buttonDownPoint.x, _lastMousePoint.y - _buttonDownPoint.y);
}
dc.DrawRectangle(_buttonDownPoint.x, _buttonDownPoint.y,
_mousePoint.x - _buttonDownPoint.x, _mousePoint.y - _buttonDownPoint.y);
_mouseMode = MM_SELECTING;
} else {
// node not already selected?
if (_mouseMode != MM_DRAGGING) {
if (_selectedNodes.find(_activeNode) == _selectedNodes.end()) {
if (!event.ShiftDown()) {
_selectedNodes.clear();
}
_selectedNodes.insert(_activeNode);
}
}
// move
for (set<drwnNode *>::iterator it = _selectedNodes.begin();
it != _selectedNodes.end(); it++) {
(*it)->setLocation((*it)->getLocationX() + _mousePoint.x - _lastMousePoint.x,
(*it)->getLocationY() + _mousePoint.y - _lastMousePoint.y);
}
_mouseMode = MM_DRAGGING;
this->Refresh(false);
this->Update();
}
} else if (event.RightDown()) {
if (_activeNode == NULL) {
// insert a new node
PopupMenu(_newNodePopupMenu);
} else {
// execute function on existing node
updatePortSubMenu(_activeNode);
if ((_mouseMode == MM_CONNECTING_INPUT) ||
(_mouseMode == MM_CONNECTING_OUTPUT)) {
PopupMenu(_connectPopupMenu);
} else {
PopupMenu(_nodePopupMenu);
}
}
} else if (event.LeftDClick()) {
if (_activeNode != NULL) {
drwnOptionsEditor dlg(this, _activeNode);
if (dlg.ShowModal() == wxID_OK) {
this->Refresh(false);
this->Update();
}
}
} else if (event.Moving()) {
int indx = findNodeAtLocation(_mousePoint.x, _mousePoint.y);
_activeNode = (indx < 0) ? NULL : _graph->getNode(indx);
}
// scroll
int delta = event.GetWheelRotation();
if (delta != 0) {
int clientX, clientY;
this->GetViewStart(&clientX, &clientY);
this->Scroll(clientX, std::max(0, clientY - delta));
}
// re-draw
if ((_mouseMode == MM_CONNECTING_INPUT) ||
(_mouseMode == MM_CONNECTING_OUTPUT)) {
this->Refresh(false);
this->Update();
}
//_lastMousePoint = wxPoint(event.m_x, event.m_y);
_lastMousePoint = _mousePoint;
updateStatusBar();
}
void MainCanvas::on_popup_menu(wxCommandEvent &event)
{
if (event.GetId() == NODE_POPUP_SET_NAME) {
DRWN_ASSERT(_activeNode != NULL);
drwnNode *a = _activeNode; // save active node (which may change after dialog clicked)
wxTextEntryDialog dlg(this, "Set the node's name:", "Set Name", _activeNode->getName());
if (dlg.ShowModal() == wxID_OK) {
a->setName(dlg.GetValue().ToStdString());
}
} else if (event.GetId() == NODE_POPUP_PROPERTIES) {
drwnOptionsEditor dlg(this, _activeNode);
if (dlg.ShowModal() == wxID_OK) {
this->Refresh(false);
this->Update();
}
} else if (event.GetId() == NODE_POPUP_SHOWHIDE) {
if (_activeNode->isShowingWindow()) {
_activeNode->hideWindow();
} else {
_activeNode->showWindow();
}
} else if (event.GetId() == NODE_POPUP_EVALUATE) {
drwnLogger::setRunning(true);
_activeNode->initializeForwards();
_activeNode->evaluateForwards();
_activeNode->finalizeForwards();
drwnLogger::setRunning(false);
} else if (event.GetId() == NODE_POPUP_UPDATE) {
drwnLogger::setRunning(true);
_activeNode->initializeForwards(false);
_activeNode->updateForwards();
_activeNode->finalizeForwards();
drwnLogger::setRunning(false);
} else if (event.GetId() == NODE_POPUP_RESETPARAMS) {
_activeNode->resetParameters();
} else if (event.GetId() == NODE_POPUP_INITPARAMS) {
drwnLogger::setRunning(true);
_activeNode->initializeParameters();
drwnLogger::setRunning(false);
} else if ((event.GetId() >= NODE_POPUP_INPORT_BASE) &&
(event.GetId() < NODE_POPUP_INPORT_BASE + 100)) {
int portId = event.GetId() - NODE_POPUP_INPORT_BASE;
if (_mouseMode == MM_CONNECTING_OUTPUT) {
DRWN_ASSERT(_activePort != NULL);
_activeNode->getInputPort(portId)->connect((drwnOutputPort *)_activePort);
_activeNode = NULL;
_mouseMode = MM_NONE;
} else {
_activePort = _activeNode->getInputPort(portId);
_mouseMode = MM_CONNECTING_INPUT;
}
} else if ((event.GetId() >= NODE_POPUP_OUTPORT_BASE) &&
(event.GetId() < NODE_POPUP_OUTPORT_BASE + 100)) {
int portId = event.GetId() - NODE_POPUP_OUTPORT_BASE;
if (_mouseMode == MM_CONNECTING_INPUT) {
DRWN_ASSERT(_activePort != NULL);
_activeNode->getOutputPort(portId)->connect((drwnInputPort *)_activePort);
_activeNode = NULL;
_mouseMode = MM_NONE;
} else {
_activePort = _activeNode->getOutputPort(portId);
_mouseMode = MM_CONNECTING_OUTPUT;
}
} else if (event.GetId() == NODE_POPUP_DISCONNECT) {
// disconnect input ports
for (int i = 0; i < _activeNode->numInputPorts(); i++) {
_activeNode->getInputPort(i)->disconnect();
}
// disconnect output ports
for (int i = 0; i < _activeNode->numOutputPorts(); i++) {
_activeNode->getOutputPort(i)->disconnect();
}
} else if (event.GetId() == NODE_POPUP_DELETE) {
DRWN_ASSERT(_activeNode != NULL);
drwnNode *a = _activeNode; // save active node (which may change after dialog clicked)
wxMessageDialog dlg(this, string("Delete node ") + a->getName() + string("?"),
"Confirm", wxYES_NO | wxICON_QUESTION);
if (dlg.ShowModal() == wxID_YES) {
_graph->delNode(a);
if (_activeNode == a)
_activeNode = NULL;
if (_selectedNodes.find(a) != _selectedNodes.end()) {
_selectedNodes.erase(a);
}
}
} else if (event.GetId() == POPUP_SET_TITLE) {
wxTextEntryDialog dlg(this, "Set title for the data flow network:",
"Set Title", _graph->getTitle());
if (dlg.ShowModal() == wxID_OK) {
_graph->setTitle(dlg.GetValue().ToStdString());
}
} else if (event.GetId() >= POPUP_NODE_INSERT_BASE) {
// TODO: retrieve node group and name more efficiently
DRWN_LOG_DEBUG("node insert popup selected (id: " <<
(event.GetId() - POPUP_NODE_INSERT_BASE) << ")");
drwnNode *node = NULL;
int indx = event.GetId() - POPUP_NODE_INSERT_BASE;
vector<string> groupNames = drwnNodeFactory::get().getGroups();
for (vector<string>::const_iterator ig = groupNames.begin(); ig != groupNames.end(); ig++) {
vector<string> nodeNames = drwnNodeFactory::get().getNodes(ig->c_str());
for (vector<string>::const_iterator it = nodeNames.begin(); it != nodeNames.end(); it++) {
if (--indx < 0) {
DRWN_LOG_VERBOSE("Creating new node of type \""
<< it->c_str() << "\" from group \"" << ig->c_str() << "\"");
node = drwnNodeFactory::get().create(it->c_str());
break;
}
}
if (node != NULL) break;
}
DRWN_ASSERT(node != NULL);
if (_bSnapToGrid) {
int nx = 32 * ((int)(_mousePoint.x + 16) / 32);
int ny = 32 * ((int)(_mousePoint.y + 16) / 32);
node->setLocation(nx, ny);
} else {
node->setLocation(_mousePoint.x, _mousePoint.y);
}
_graph->addNode(node); // unique node will be set by graph
}
this->Refresh(false);
this->Update();
}
// select nodes within rectangle
void MainCanvas::selectNodesInRegion(int x, int y, int w, int h)
{
// correct for negative widths and heights
if (w < 0) { x += w; w = -w; }
if (h < 0) { y += h; h = -h; }
// TODO: get correct icon size
for (int i = 0; i < _graph->numNodes(); i++) {
drwnNode *node = _graph->getNode(i);
if ((x < node->getLocationX()) && (x + w > node->getLocationX() + 32) &&
(y < node->getLocationY()) && (y + h > node->getLocationY() + 32)) {
_selectedNodes.insert(node);
}
}
this->Refresh(false);
this->Update();
}
void MainCanvas::selectAllNodes()
{
if ((int)_selectedNodes.size() == _graph->numNodes())
return;
for (int i = 0; i < _graph->numNodes(); i++) {
_selectedNodes.insert(_graph->getNode(i));
}
this->Refresh(false);
this->Update();
}
void MainCanvas::deselectAllNodes()
{
if (_selectedNodes.empty())
return;
_selectedNodes.clear();
this->Refresh(false);
this->Update();
}
void MainCanvas::undoableAction()
{
// TODO
}
void MainCanvas::updateImageBuffer()
{
// TODO
}
void MainCanvas::updateStatusBar()
{
if (_activeNode != NULL) {
gMainWindow->_statusBar->updateMessage(_activeNode->getName().c_str());
gMainWindow->_statusBar->SetStatusText(_activeNode->getDescription(), 3);
} else {
gMainWindow->_statusBar->updateMessage("");
gMainWindow->_statusBar->SetStatusText("", 3);
}
}
int MainCanvas::findNodeAtLocation(int x, int y) const
{
DRWN_ASSERT(_graph != NULL);
for (int i = 0; i < _graph->numNodes(); i++) {
const drwnNode *node = _graph->getNode(i);
int nx = node->getLocationX();
int ny = node->getLocationY();
if ((x > nx) && (x < nx + 32) && (y > ny) && (y < ny + 32)) {
return i;
}
}
return -1;
}
void MainCanvas::updatePortSubMenu(const drwnNode *node)
{
DRWN_ASSERT((node != NULL) && (_portSubMenuItem != NULL));
DRWN_ASSERT(_portSubMenuItem->GetSubMenu() != NULL);
// show/hide
if (node->isShowingWindow()) {
_nodePopupMenu->SetLabel(NODE_POPUP_SHOWHIDE, "&Hide");
} else {
_nodePopupMenu->SetLabel(NODE_POPUP_SHOWHIDE, "&Show...");
}
// port submenu
#if 0
delete _portSubMenuItem->GetSubMenu();
wxMenu *portMenu;
_portSubMenuItem->SetSubMenu(portMenu = new wxMenu());
#else
// TODO: hack?
wxMenu *portMenu = _portSubMenuItem->GetSubMenu();
while (portMenu->GetMenuItemCount() > 0) {
portMenu->Destroy(portMenu->FindItemByPosition(0));
}
#endif
delete _connectPopupMenu;
_connectPopupMenu = new wxMenu();
for (int i = 0; i < node->numInputPorts(); i++) {
portMenu->Append(NODE_POPUP_INPORT_BASE + i,
node->getInputPort(i)->getName());
_connectPopupMenu->Append(NODE_POPUP_INPORT_BASE + i,
node->getInputPort(i)->getName());
if (_mouseMode == MM_CONNECTING_INPUT) {
portMenu->Enable(NODE_POPUP_INPORT_BASE + i, false);
_connectPopupMenu->Enable(NODE_POPUP_INPORT_BASE + i, false);
}
}
if ((node->numInputPorts() > 0) && (node->numOutputPorts() > 0)) {
portMenu->AppendSeparator();
_connectPopupMenu->AppendSeparator();
}
for (int i = 0; i < node->numOutputPorts(); i++) {
portMenu->Append(NODE_POPUP_OUTPORT_BASE + i,
node->getOutputPort(i)->getName());
_connectPopupMenu->Append(NODE_POPUP_OUTPORT_BASE + i,
node->getOutputPort(i)->getName());
if (_mouseMode == MM_CONNECTING_OUTPUT) {
portMenu->Enable(NODE_POPUP_OUTPORT_BASE + i, false);
_connectPopupMenu->Enable(NODE_POPUP_OUTPORT_BASE + i, false);
}
}
}
// MainWindow Implementation ---------------------------------------------------
MainWindow::MainWindow(wxWindow* parent, wxWindowID id, const wxString& title,
const wxPoint& pos, const wxSize& size, long style) :
wxFrame(parent, id, title, pos, size, style),
_statusBar(NULL), _splitterWnd(NULL), _activeCanvas(NULL), _sessionLog(NULL)
{
SetIcon(wxICON(darwin));
wxMenu *file_menu = new wxMenu;
wxMenu *file_export_menu = new wxMenu;
wxMenu *edit_menu = new wxMenu;
wxMenu *network_menu = new wxMenu;
wxMenu *database_menu = new wxMenu;
wxMenu *options_menu = new wxMenu;
_windowMenu = new wxMenu;
wxMenu *help_menu = new wxMenu;
file_menu->Append(FILE_NEW, "&New\tCtrl-N", "New dataflow network");
file_menu->Append(FILE_OPEN, "&Open...\tCtrl-O", "Open dataflow network");
file_menu->AppendSeparator();
file_menu->Append(FILE_SAVE, "&Save\tCtrl-S", "Save dataflow network");
file_menu->Append(FILE_SAVEAS, "Save &As...", "Save dataflow network");
file_menu->AppendSeparator();
file_export_menu->Append(FILE_EXPORT_HTML, "Export &HTML...", "Export HTML report");
file_export_menu->Append(FILE_EXPORT_CODE, "Export &Code...", "Export source code");
file_export_menu->Append(FILE_EXPORT_SCRIPT, "Export &Script...", "Export network generation script");
file_menu->AppendSubMenu(file_export_menu, "&Export");
file_menu->AppendSeparator();
file_menu->Append(FILE_CLOSE, "&Close", "Close dataflow network");
file_menu->Append(FILE_CLOSEALL, "Close All", "Close all dataflow networks");
file_menu->AppendSeparator();
file_menu->Append(FILE_EXIT, "E&xit\tAlt-X", "Exit this program");
edit_menu->Append(EDIT_UNDO, "&Undo\tCtrl-Z", "Undo last change");
edit_menu->Append(EDIT_REDO, "&Redo\tCtrl-Y", "Redo last change");
edit_menu->AppendSeparator();
edit_menu->Append(EDIT_CUT, "&Cut\tCtrl-X", "Cut selected nodes");
edit_menu->Append(EDIT_COPY, "Copy\tCtrl-C", "Copy selected nodes");
edit_menu->Append(EDIT_PASTE, "&Paste\tCtrl-V", "Paste copied nodes");
edit_menu->Append(EDIT_DELETE, "&Delete\tDEL", "Delete selected nodes");
edit_menu->AppendSeparator();
edit_menu->Append(EDIT_FIND, "&Find...", "Find nodes");
edit_menu->AppendSeparator();
edit_menu->Append(EDIT_SELECTALL, "Select &all\tCtrl-A", "Select all nodes");
edit_menu->Append(EDIT_DESELECTALL, "Deselect all", "Deselect all nodes");
network_menu->Append(NETWORK_RESET, "&Reset", "Reset all network parameters and clear data");
network_menu->Append(NETWORK_EVALUATE, "&Evaluate\tF9", "Evaluate network forwards");
network_menu->Append(NETWORK_UPDATE, "&Update", "Evaluate network forwards (unprocessed records only)");
network_menu->Append(NETWORK_INITPARAMS, "&Initialize\tF5", "Initialize network parameters (updating forwards where necessary)");
network_menu->AppendSeparator();
network_menu->AppendCheckItem(NETWORK_GRIDSNAP, "Snap to &Grid", "Snap nodes to grid when inserting and moving");
database_menu->Append(DATABASE_CONNECT, "&Connect...", "Connect to data storage");
database_menu->Append(DATABASE_VIEW_TABLES, "&View Table...", "View database tables");
database_menu->Append(DATABASE_VIEW_INSTANCES, "View &Instance...", "View data instances");
database_menu->AppendSeparator();
database_menu->Append(DATABASE_IMPORT_COLOURS, "Import Colo&urs...", "Import data partitioning (colours)");
database_menu->Append(DATABASE_RANDOMIZE_COLOURS, "&Randomize Colours...", "Randomly sample data partitioning (colours)");
database_menu->AppendSeparator();
database_menu->Append(DATABASE_FLUSH_CACHE, "&Flush Cache", "Flush and clear the record cache");
options_menu->AppendRadioItem(OPTIONS_DISPLAY_VERBOSE, "Display &Audit Messages", "Display audit (verbose) messages");
options_menu->AppendRadioItem(OPTIONS_DISPLAY_MESSAGE, "Display &Messages", "Display messages, warnings and errors");
options_menu->AppendRadioItem(OPTIONS_DISPLAY_WARNING, "Display &Warnings", "Display warnings and errors only");
options_menu->AppendSeparator();
options_menu->AppendCheckItem(OPTIONS_BEEP, "&Beep", "Beep on completion");
options_menu->AppendSeparator();
options_menu->Append(OPTIONS_CLEAR_LOG, "&Clear log...", "Clear session log");
options_menu->Append(OPTIONS_SAVE_LOG, "&Save log...", "Save session log");
help_menu->Append(HELP_DRWN_CONTENTS, "&Contents...\tF1", "Show help information");
help_menu->Append(HELP_RELEASE_NOTES, "&Release Notes...", "Show release notes");
help_menu->Append(HELP_ABOUT, "&About...", "Show about dialog");
// add all submenus
wxMenuBar *menu_bar = new wxMenuBar();
menu_bar->Append(file_menu, "&File");
menu_bar->Append(edit_menu, "&Edit");
menu_bar->Append(network_menu, "&Network");
menu_bar->Append(database_menu, "&Database");
menu_bar->Append(options_menu, "&Options");
menu_bar->Append(_windowMenu, "&Window");
menu_bar->Append(help_menu, "&Help");
SetMenuBar(menu_bar);
// set default options
network_menu->Check(NETWORK_GRIDSNAP, true);
options_menu->Check(OPTIONS_BEEP, false);
options_menu->Check(OPTIONS_DISPLAY_VERBOSE, drwnLogger::getLogLevel() >= DRWN_LL_VERBOSE);
options_menu->Check(OPTIONS_DISPLAY_MESSAGE, drwnLogger::getLogLevel() == DRWN_LL_MESSAGE);
options_menu->Check(OPTIONS_DISPLAY_WARNING, drwnLogger::getLogLevel() <= DRWN_LL_WARNING);
// setup statusbar
_statusBar = new drwnStatusBar(this);
this->SetStatusBar(_statusBar);
this->SetStatusBarPane(3);
// setup subwindows
#if 0
_splitterWnd = new wxBoxSizer(wxVERTICAL);
_splitterWnd->SetMinSize(wxSize(320, 240));
_splitterWnd->Add(_activeCanvas = new MainCanvas(this), 1, wxEXPAND | wxALL);
_splitterWnd->Add(_sessionLog = new wxTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE | wxTE_PROCESS_ENTER | wxRESIZE_BORDER | wxVSCROLL | wxTE_RICH), 0, wxEXPAND | wxALL);
SetSizer(_splitterWnd);
#else
_splitterWnd = new wxSplitterWindow(this, wxID_ANY);
_splitterWnd->SetMinimumPaneSize(32);
_activeCanvas = new MainCanvas(_splitterWnd);
_sessionLog = new wxTextCtrl(_splitterWnd, wxID_ANY, "", wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE | wxTE_PROCESS_ENTER | wxRESIZE_BORDER | wxVSCROLL | wxTE_RICH);
_splitterWnd->SplitHorizontally(_activeCanvas, _sessionLog, -96);
_splitterWnd->SetSashGravity(1.0);
Center();
#endif
_sessionLog->SetBackgroundColour(wxColour(255, 255, 192));
_activeCanvas->SetFocus();
_canvases.push_back(_activeCanvas);
updateGUIElements();
// update session log with current date and time
_sessionLog->SetDefaultStyle(wxTextAttr(*wxBLACK));
wxDateTime now = wxDateTime::Now();
_sessionLog->AppendText(wxString("Session log started: ") + now.Format() + wxString("\n"));
}
MainWindow::~MainWindow()
{
SetStatusBar(NULL);
if (_statusBar != NULL)
delete _statusBar;
clearCopyBuffer();
// delete canvases (active canvas will be destroyed with window)
for (int i = 0; i < (int)_canvases.size(); i++) {
if (_canvases[i] != _activeCanvas) {
delete _canvases[i];
}
}
if (drwnCodeProfiler::enabled) {
drwnCodeProfiler::print();
}
}
void MainWindow::on_idle(wxIdleEvent& event)
{
// flush some data records
drwnDataCache::get().idleFlush();
}
void MainWindow::on_close(wxCloseEvent& event)
{
// not implemented yet
event.Skip();
}
void MainWindow::on_file_menu(wxCommandEvent& event)
{
if (event.GetId() == FILE_NEW) {
_canvases.push_back(new MainCanvas(_splitterWnd));
_splitterWnd->ReplaceWindow(_activeCanvas, _canvases.back());
_activeCanvas = _canvases.back();
updateGUIElements();
} else if (event.GetId() == FILE_OPEN) {
wxFileDialog dlg(this, "Open data flow graph",
"", "", "XML Files (*.xml)|*.xml|All Files (*.*)|*.*",
wxFD_OPEN | wxFD_CHANGE_DIR);
if (dlg.ShowModal() == wxID_OK) {
openGraphFile(dlg.GetPath().c_str());
}
} else if ((event.GetId() == FILE_SAVE) && !_activeCanvas->_filename.empty()) {
_activeCanvas->_graph->write(_activeCanvas->_filename.c_str());
// TODO: clear dirty flag
} else if ((event.GetId() == FILE_SAVEAS) || (event.GetId() == FILE_SAVE)) {
drwnGraph *graph = _activeCanvas->_graph;
wxFileDialog dlg(this, string("Save ") + graph->getTitle() + string(" as:"),
"", _activeCanvas->_filename, "XML Files (*.xml)|*.xml|All Files (*.*)|*.*",
wxFD_SAVE | wxFD_CHANGE_DIR);
if (dlg.ShowModal() == wxID_OK) {
_activeCanvas->_filename = dlg.GetPath();
graph->write(dlg.GetPath().c_str());
// TODO: clear dirty flag
}
} else if (event.GetId() == FILE_EXPORT_HTML) {
drwnGraph *graph = _activeCanvas->_graph;
string filenameProposal;
if (!_activeCanvas->_filename.empty()) {
filenameProposal = drwn::strReplaceExt(_activeCanvas->_filename, string(".html"));
}
wxFileDialog dlg(this, string("Export HTML for ") + graph->getTitle() + string(" as:"),
"", filenameProposal, "HTML Files (*.html)|*.html|All Files (*.*)|*.*",
wxFD_SAVE | wxFD_CHANGE_DIR);
if (dlg.ShowModal() == wxID_OK) {
drwnHTMLReport report;
report.write(dlg.GetPath().c_str(), graph);
}
} else if (event.GetId() == FILE_EXPORT_HTML) {
NOT_IMPLEMENTED_YET;
} else if (event.GetId() == FILE_EXPORT_SCRIPT) {
NOT_IMPLEMENTED_YET;
} else if (event.GetId() == FILE_CLOSE) {
// TODO: ask to save if dirty
if (_canvases.size() == 1) {
_canvases[0] = new MainCanvas(_splitterWnd);
} else {
for (vector<MainCanvas *>::iterator it = _canvases.begin(); it != _canvases.end(); it++) {
if (*it == _activeCanvas) {
_canvases.erase(it);
break;
}
}
}
_splitterWnd->ReplaceWindow(_activeCanvas, _canvases.back());
delete _activeCanvas;
_activeCanvas = _canvases.back();
updateGUIElements();
} else if (event.GetId() == FILE_CLOSEALL) {
// TODO: ask to save if dirty
for (vector<MainCanvas *>::iterator it = _canvases.begin(); it != _canvases.end(); it++) {
if (*it != _activeCanvas) {
delete *it;
}
}
_canvases.clear();
_canvases.push_back(new MainCanvas(_splitterWnd));
_splitterWnd->ReplaceWindow(_activeCanvas, _canvases.back());
delete _activeCanvas;
_activeCanvas = _canvases.back();
updateGUIElements();
} else if (event.GetId() == FILE_EXIT) {
Close(true);
}
Refresh(false);
Update();
}
void MainWindow::on_edit_menu(wxCommandEvent& event)
{
if (event.GetId() == EDIT_CUT) {
clearCopyBuffer();
_copyBuffer = _activeCanvas->_graph->copySubGraph(_activeCanvas->_selectedNodes);
for (set<drwnNode *>::iterator it = _activeCanvas->_selectedNodes.begin();
it != _activeCanvas->_selectedNodes.end(); it++) {
_activeCanvas->_graph->delNode(*it);
}
_activeCanvas->_selectedNodes.clear();
_activeCanvas->_activeNode = NULL;
DRWN_LOG_VERBOSE(_copyBuffer.size() << " nodes cut");
} else if (event.GetId() == EDIT_COPY) {
clearCopyBuffer();
_copyBuffer = _activeCanvas->_graph->copySubGraph(_activeCanvas->_selectedNodes);
DRWN_LOG_VERBOSE(_copyBuffer.size() << " nodes copied");
} else if (event.GetId() == EDIT_PASTE) {
int width, height, x, y;
_activeCanvas->GetClientSize(&width, &height);
_activeCanvas->CalcUnscrolledPosition(width / 2, height / 2, &x, &y);
if (_activeCanvas->_bSnapToGrid) {
x = 32 * ((int)(x + 16) / 32);
y = 32 * ((int)(y + 16) / 32);
}
_activeCanvas->_graph->pasteSubGraph(_copyBuffer, x, y);
_activeCanvas->_selectedNodes.clear();
for (int i = _activeCanvas->_graph->numNodes() - _copyBuffer.size();
i < _activeCanvas->_graph->numNodes(); i++) {
_activeCanvas->_selectedNodes.insert(_activeCanvas->_graph->getNode(i));
}
DRWN_LOG_VERBOSE(_copyBuffer.size() << " nodes pasted");
} else if (event.GetId() == EDIT_DELETE) {
if (_activeCanvas->_selectedNodes.empty()) {
wxMessageBox("No nodes selected.", "Delete", wxOK | wxICON_INFORMATION, this);
} else {
wxMessageDialog dlg(this,
wxString::Format("Delete %d nodes? All associated data will be lost.",
(int)_activeCanvas->_selectedNodes.size()), "Delete", wxYES_NO);
if (dlg.ShowModal() == wxID_YES) {
for (set<drwnNode *>::iterator it = _activeCanvas->_selectedNodes.begin();
it != _activeCanvas->_selectedNodes.end(); it++) {
_activeCanvas->_graph->delNode(*it);
}
_activeCanvas->_selectedNodes.clear();
_activeCanvas->_activeNode = NULL;
}
}
} else if (event.GetId() == EDIT_FIND) {
wxTextEntryDialog dlg(this, "Search string:", "Find");
if (dlg.ShowModal() == wxID_OK) {
string searchStr = string(dlg.GetValue().c_str());
const drwnGraph *g = _activeCanvas->_graph;
_activeCanvas->_selectedNodes.clear();
for (int i = 0; i < g->numNodes(); i++) {
if (g->getNode(i)->getName().find(searchStr) != string::npos) {
_activeCanvas->_selectedNodes.insert(g->getNode(i));
}
}
}
} else if (event.GetId() == EDIT_SELECTALL) {
_activeCanvas->selectAllNodes();
} else if (event.GetId() == EDIT_DESELECTALL) {
_activeCanvas->deselectAllNodes();
}
Refresh(false);
Update();
}
void MainWindow::on_network_menu(wxCommandEvent& event)
{
if (event.GetId() == NETWORK_RESET) {
_activeCanvas->_graph->resetParameters(_activeCanvas->_selectedNodes);
} else if (event.GetId() == NETWORK_EVALUATE) {
_activeCanvas->_graph->evaluateForwards(_activeCanvas->_selectedNodes);
} else if (event.GetId() == NETWORK_UPDATE) {
_activeCanvas->_graph->updateForwards(_activeCanvas->_selectedNodes);
} else if (event.GetId() == NETWORK_INITPARAMS) {
_activeCanvas->_graph->initializeParameters(_activeCanvas->_selectedNodes);
} else if (event.GetId() == NETWORK_GRIDSNAP) {
_activeCanvas->snapToGrid() = event.IsChecked();
}
Refresh(false);
Update();
}
void MainWindow::on_database_menu(wxCommandEvent& event)
{
if (event.GetId() == DATABASE_CONNECT) {
drwnDatabase *db = _activeCanvas->_graph->getDatabase();
wxDirDialog dlg(this, string("Select database for ") + _activeCanvas->_graph->getTitle(),
(db->isPersistent() ? drwn::strDirectory(db->name()).c_str() : ""), wxDD_DEFAULT_STYLE);
if (dlg.ShowModal() == wxID_OK) {
_activeCanvas->_graph->setDatabase(dlg.GetPath().c_str());
}
updateGUIElements();
} else if (event.GetId() == DATABASE_VIEW_TABLES) {
drwnDatabase *db = _activeCanvas->_graph->getDatabase();
vector<string> tblNames = db->getTableNames();
if (tblNames.empty()) {
DRWN_LOG_ERROR("database has no tables");
return;
}
wxString *choices = new wxString[tblNames.size()];
for (unsigned i = 0; i < tblNames.size(); i++) {
choices[i] = wxString::Format("%s (%d records)", tblNames[i].c_str(),
db->getTable(tblNames[i])->numRecords());
}
wxSingleChoiceDialog dlg(this, "Select table:", "View Table",
(int)tblNames.size(), choices);
if (dlg.ShowModal() == wxID_OK) {
DRWN_LOG_MESSAGE("TODO: show table " << tblNames[dlg.GetSelection()]);
NOT_IMPLEMENTED_YET;
}
delete[] choices;
} else if (event.GetId() == DATABASE_VIEW_INSTANCES) {
drwnDatabase *db = _activeCanvas->_graph->getDatabase();
vector<string> keys = db->getAllKeys();
if (keys.empty()) {
DRWN_LOG_ERROR("database has no records");
return;
}
wxString *choices = new wxString[keys.size()];
for (unsigned i = 0; i < keys.size(); i++) {
choices[i] = wxString::Format("%s (colour %d)", keys[i].c_str(),
db->getColour(keys[i]));
}
wxSingleChoiceDialog dlg(this, "Select data instance:", "View Records",
(int)keys.size(), choices);
if (dlg.ShowModal() == wxID_OK) {
string k = keys[dlg.GetSelection()];
drwnTextEditor recordDlg(this, k.c_str(), true);
vector<string> tblNames = db->getTableNames();
for (vector<string>::const_iterator it = tblNames.begin(); it != tblNames.end(); it++) {
drwnDataTable *tbl = db->getTable(*it);
recordDlg.addLine(it->c_str(), true);
if (tbl->hasKey(k)) {
drwnDataRecord *rec = tbl->lockRecord(k);
if (rec->isEmpty()) {
recordDlg.addLine(" empty");
} else {
const MatrixXd& d = rec->data();
for (int i = 0; i < d.rows(); i++) {
vector<double> v(d.cols());
Eigen::Map<VectorXd>(&v[0], v.size()) = d.row(i);
recordDlg.addLine((string(" ") + toString(v)).c_str());
}
}
tbl->unlockRecord(k);
} else {
recordDlg.addLine(" no data");
}
recordDlg.addLine();
}
recordDlg.ShowModal();
}
delete[] choices;
} else if (event.GetId() == DATABASE_IMPORT_COLOURS) {
NOT_IMPLEMENTED_YET;
} else if (event.GetId() == DATABASE_RANDOMIZE_COLOURS) {
wxTextEntryDialog dlg(this, "Enter number of data partitions (colours):",
"Randomize Colours", "2");
if (dlg.ShowModal()) {
drwnDatabase *db = _activeCanvas->_graph->getDatabase();
int numColours = atoi(dlg.GetValue().c_str());
if (numColours <= 0) {
db->clearColours();
} else {
// initialize random number generator
drwnInitializeRand();
// randomly assign colours
vector<string> keys = db->getAllKeys();
for (vector<string>::const_iterator it = keys.begin(); it != keys.end(); it++) {
db->setColour(*it, rand() % numColours);
}
}
}
} else if (event.GetId() == DATABASE_FLUSH_CACHE) {
drwnDataCache::get().flush();
drwnDataCache::get().clear();
}
Refresh(false);
Update();
}
void MainWindow::on_options_menu(wxCommandEvent& event)
{
if (event.GetId() == OPTIONS_DISPLAY_VERBOSE) {
drwnLogger::setLogLevel(DRWN_LL_VERBOSE);
} else if (event.GetId() == OPTIONS_DISPLAY_MESSAGE) {
drwnLogger::setLogLevel(DRWN_LL_MESSAGE);
} else if (event.GetId() == OPTIONS_DISPLAY_WARNING) {
drwnLogger::setLogLevel(DRWN_LL_WARNING);
} else if (event.GetId() == OPTIONS_BEEP) {
// TODO
::wxBell();
} else if (event.GetId() == OPTIONS_CLEAR_LOG) {
wxMessageDialog dlg(this, "Do you really want to clear all session log messages?",
"Session Log", wxYES_NO | wxICON_QUESTION);
if (dlg.ShowModal() == wxID_YES) {
_sessionLog->Clear();
// update session log with current date and time
_sessionLog->SetDefaultStyle(wxTextAttr(*wxBLACK));
wxDateTime now = wxDateTime::Now();
_sessionLog->AppendText(wxString("Session log restarted: ") + now.Format() + wxString("\n"));
}
} else if (event.GetId() == OPTIONS_SAVE_LOG) {
wxFileDialog dlg(this, "Save log file as:", "", "",
"Text Files (*.txt)|*.txt|All Files (*.*)|*.*", wxFD_SAVE);
if (dlg.ShowModal() == wxID_OK) {
// TODO: save current messages too
drwnLogger::initialize(dlg.GetPath().c_str(), false);
}
}
Refresh(false);
Update();
}
void MainWindow::on_window_menu(wxCommandEvent& event)
{
if ((event.GetId() >= WINDOW_MENU_BASE) &&
(event.GetId() < WINDOW_MENU_BASE + 100)) {
int windowId = event.GetId() - WINDOW_MENU_BASE;
if (_canvases[windowId] != _activeCanvas) {
_splitterWnd->ReplaceWindow(_activeCanvas, _canvases[windowId]);
_activeCanvas = _canvases[windowId];
}
updateGUIElements();
}
Refresh(false);
Update();
}
void MainWindow::on_help_menu(wxCommandEvent& event)
{
if (event.GetId() == HELP_DRWN_CONTENTS) {
::wxLaunchDefaultBrowser("http://drwn.anu.edu.au/", wxBROWSER_NEW_WINDOW);
DRWN_LOG_ERROR("Help|Contents not implemented yet");
} else if (event.GetId() == HELP_RELEASE_NOTES) {
::wxLaunchDefaultBrowser("http://drwn.anu.edu.au/", wxBROWSER_NEW_WINDOW);
DRWN_LOG_ERROR("Help|Release Notes not implemented yet");
} else if (event.GetId() == HELP_ABOUT) {
wxAboutDialogInfo info;
info.SetName("Darwin");
info.SetVersion(DRWN_VERSION);
info.SetDescription("A framework for machine learning\nresearch and development.");
info.SetCopyright(DRWN_COPYRIGHT);
wxAboutBox(info);
}
}
// status
void MainWindow::logMessage(const char *msg, const wxTextAttr style)
{
_sessionLog->SetDefaultStyle(style);
_sessionLog->AppendText(wxString(msg) + wxString("\n"));
}
void MainWindow::updateProgress(const char *status, double progress)
{
static clock_t _lastClock = clock();
_statusBar->updateMessage(wxString(status));
_statusBar->updateProgress(progress);
_statusBar->Refresh(false);
//_statusBar->Update(); // TODO: change to timer update
//_sessionLog->Refresh(false);
//_sessionLog->Update();
// throttle updates
clock_t thisClock = clock();
if (thisClock - _lastClock > CLOCKS_PER_SEC / 100) {
this->Update();
//::wxSafeYield(NULL, true);
_lastClock = thisClock;
}
// check for abort
if (::wxGetKeyState(WXK_ESCAPE)) {
if (drwnLogger::isRunning()) {
DRWN_LOG_WARNING("Terminating current operation. Please wait...");
drwnLogger::setRunning(false);
::wxSafeYield(NULL, true);
}
}
}
void MainWindow::updateGUIElements()
{
// hide non-active windows
for (int i = 0; i < (int)_canvases.size(); i++) {
_canvases[i]->Show(_canvases[i] == _activeCanvas);
}
// update window menu
// TODO: hack?
while (_windowMenu->GetMenuItemCount() > 0) {
_windowMenu->Destroy(_windowMenu->FindItemByPosition(0));
}
for (int i = 0; i < (int)_canvases.size(); i++) {
_windowMenu->Append(WINDOW_MENU_BASE + i,
_canvases[i]->_graph->getTitle());
if (_canvases[i] == _activeCanvas) {
_windowMenu->Enable(WINDOW_MENU_BASE + i, false);
}
}
// TODO: make Window menu hidden if only one window
// update status bar
_statusBar->updateDatabase(_activeCanvas->_graph->getDatabase());
}
void MainWindow::clearCopyBuffer()
{
for (set<drwnNode *>::iterator it = _copyBuffer.begin(); it != _copyBuffer.end(); it++) {
delete *it;
}
_copyBuffer.clear();
}
bool MainWindow::openGraphFile(const char *filename)
{
DRWN_ASSERT(filename != NULL);
// check if file is already open
for (vector<MainCanvas *>::const_iterator it = _canvases.begin();
it != _canvases.end(); it++) {
if ((*it)->_filename == string(filename)) {
wxMessageBox(wxString::Format("Dataflow graph \"%s\" is already open.", filename),
"Open...", wxOK | wxICON_EXCLAMATION, NULL);
if (*it != _activeCanvas) {
_splitterWnd->ReplaceWindow(_activeCanvas, *it);
_activeCanvas = *it;
updateGUIElements();
}
return true;
}
}
// otherwise open new file
if (_activeCanvas->_graph->numNodes() != 0) {
_canvases.push_back(new MainCanvas(_splitterWnd));
_splitterWnd->ReplaceWindow(_activeCanvas, _canvases.back());
_activeCanvas = _canvases.back();
}
_activeCanvas->_graph->read(filename);
_activeCanvas->_filename = string(filename);
_activeCanvas->Scroll(0, 0);
updateGUIElements();
return true;
}
// Darwin Implementation ------------------------------------------------------
void usage()
{
cerr << DRWN_USAGE_HEADER << "\n";
cerr << "USAGE: ./darwin [OPTIONS] (<network>)\n";
cerr << "OPTIONS:\n"
<< " -plugin <path> :: load plugin\n"
<< DRWN_STANDARD_OPTIONS_USAGE
<< endl;
}
bool DarwinApp::OnInit()
{
#ifdef __WXMAC__
// application registration (Mac OS X)
ProcessSerialNumber PSN;
GetCurrentProcess(&PSN);
TransformProcessType(&PSN, kProcessTransformToForegroundApplication);
#endif
// parse command-line options
int argc = wxAppConsole::argc;
char **argv = wxAppConsole::argv;
DRWN_BEGIN_CMDLINE_PROCESSING(argc, argv)
DRWN_CMDLINE_OPTION_BEGIN("-plugin", p)
#if defined(__LINUX__)
void *h = dlopen(p[0], RTLD_NOW);
if (h == NULL) {
DRWN_LOG_ERROR(dlerror());
}
#endif
DRWN_CMDLINE_OPTION_END(1)
DRWN_END_CMDLINE_PROCESSING(usage());
if (DRWN_CMDLINE_ARGC > 1) {
usage();
return false;
}
// setup main window
gMainWindow = new MainWindow(NULL, wxID_ANY, "Darwin GUI",
wxDefaultPosition, wxSize(640, 480));
SetTopWindow(gMainWindow);
gMainWindow->Show();
gMainWindow->SetFocus();
// initialize drwnLogger callbacks
drwnLogger::showMessageCallback = messageCallback;
drwnLogger::showWarningCallback = warningCallback;
drwnLogger::showErrorCallback = errorCallback;
drwnLogger::showFatalCallback = fatalCallback;
drwnLogger::showProgressCallback = progressCallback;
// load network
if (DRWN_CMDLINE_ARGC == 1) {
string fullPath = string(DRWN_CMDLINE_ARGV[0]);
drwnChangeCurrentDir(drwn::strDirectory(fullPath).c_str());
gMainWindow->openGraphFile(drwn::strFilename(fullPath).c_str());
}
return true;
}
int DarwinApp::OnExit()
{
// reset drwnLogger callbacks
drwnLogger::showMessageCallback = NULL;
drwnLogger::showWarningCallback = NULL;
drwnLogger::showErrorCallback = NULL;
drwnLogger::showFatalCallback = NULL;
drwnLogger::showProgressCallback = NULL;
return 0;
}
IMPLEMENT_APP(DarwinApp)
| 37.369212 | 133 | 0.597779 | [
"vector"
] |
970e71ce28938ed3ab433d79db09bdf6998d43f7 | 1,687 | cpp | C++ | graphs/chicago_106_miles_to_chicago.cpp | tricktron/Programming-Challenges | 0ece339a789529731eac8b908aa37d084fcdfe2a | [
"MIT"
] | null | null | null | graphs/chicago_106_miles_to_chicago.cpp | tricktron/Programming-Challenges | 0ece339a789529731eac8b908aa37d084fcdfe2a | [
"MIT"
] | null | null | null | graphs/chicago_106_miles_to_chicago.cpp | tricktron/Programming-Challenges | 0ece339a789529731eac8b908aa37d084fcdfe2a | [
"MIT"
] | null | null | null | //
// Created by Thibault Gagnaux on 2019-07-03.
//
#include <iostream>
#include <vector>
#include <queue>
#define FORN(i,a,b) for (int i = (a); i < (b); i++)
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define pb push_back
#define eb emplace_back
#define MAX_VERTICES 110
using namespace std;
struct Edge {
int to;
double weight;
Edge(int to, double weight) : to(to), weight(weight) {};
};
vector<Edge> graph[MAX_VERTICES];
double bfs(int target) {
double dist[MAX_VERTICES] = {};
bool visited[MAX_VERTICES] = {};
queue<int> pq;
dist[1] = 1.0;
visited[1] = true;
pq.push(1);
while (!pq.empty()) {
int u = pq.front();
visited[u] = false;
pq.pop();
for (const Edge &neighbours: graph[u]) {
int v = neighbours.to;
double probability = dist[u] * neighbours.weight;
if (probability > dist[v]) {
dist[v] = probability;
if (!visited[v]) {
pq.push(v);
visited[v] = true;
}
}
}
}
return dist[target];
}
int main() {
int n, m;
while (true) {
cin >> n;
if (n == 0) break;
cin >> m;
FOR(i, 0, 100) graph[i].clear();
FORN(i, 0, m) {
int from, to, percentage;
cin >> from >> to >> percentage;
double probability = (double) percentage / 100.0;
graph[from].eb(Edge(to, probability));
graph[to].eb(Edge(from, probability));
}
double max_probability = bfs(n);
printf("%.6f percent\n", max_probability * 100.0);
}
return 0;
}
| 24.1 | 61 | 0.503853 | [
"vector"
] |
97333b40677f2902faedc0ee5194d1ae8c78c656 | 5,738 | cc | C++ | test/integration/nested_multiple_elements_error.cc | koonpeng/sdformat | 6307392809541d15bd540e3db9dcd98b51431a3a | [
"ECL-2.0",
"Apache-2.0"
] | 67 | 2020-04-11T22:27:46.000Z | 2021-06-19T16:17:42.000Z | test/integration/nested_multiple_elements_error.cc | koonpeng/sdformat | 6307392809541d15bd540e3db9dcd98b51431a3a | [
"ECL-2.0",
"Apache-2.0"
] | 339 | 2020-04-13T23:15:09.000Z | 2021-06-28T13:57:17.000Z | test/integration/nested_multiple_elements_error.cc | koonpeng/sdformat | 6307392809541d15bd540e3db9dcd98b51431a3a | [
"ECL-2.0",
"Apache-2.0"
] | 45 | 2020-04-14T21:27:44.000Z | 2021-06-18T22:50:25.000Z | /*
* Copyright 2020 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <iostream>
#include <string>
#include <gtest/gtest.h>
#include "sdf/Actor.hh"
#include "sdf/Filesystem.hh"
#include "sdf/Geometry.hh"
#include "sdf/Light.hh"
#include "sdf/Model.hh"
#include "sdf/Root.hh"
#include "sdf/World.hh"
#include "test_config.h"
const auto g_testPath = sdf::testing::TestFile();
const auto g_modelsPath =
sdf::filesystem::append(g_testPath, "integration", "model");
const auto g_sdfPath = sdf::filesystem::append(g_testPath, "sdf");
/////////////////////////////////////////////////
std::string findFileCb(const std::string &_input)
{
return sdf::filesystem::append(g_testPath, "integration", "model", _input);
}
//////////////////////////////////////////////////
// Check that an error is emitted if there are multiple models in an included
// file. Despite the error, the first model should be loaded.
TEST(IncludesTest, NestedMultipleModelsError)
{
sdf::setFindCallback(findFileCb);
const auto sdfFile =
sdf::filesystem::append(g_modelsPath, "nested_multiple_models_error");
sdf::Root root;
sdf::Errors errors = root.Load(sdfFile);
ASSERT_FALSE(errors.empty());
EXPECT_EQ(sdf::ErrorCode::ELEMENT_INCORRECT_TYPE, errors[0].Code());
EXPECT_EQ("Found more than one model for <include>.", errors[0].Message());
const auto * model = root.Model();
ASSERT_NE(nullptr, model);
EXPECT_EQ("nested_model", model->Name());
ASSERT_EQ(1u, model->LinkCount());
EXPECT_EQ("link1", model->LinkByIndex(0)->Name());
EXPECT_EQ(nullptr, root.Actor());
EXPECT_EQ(nullptr, root.Light());
}
//////////////////////////////////////////////////
// Check that an error is emitted if there are multiple actors in an included
// file. Despite the error, the first actor should be loaded.
TEST(IncludesTest, NestedMultipleActorsError)
{
sdf::setFindCallback(findFileCb);
const auto sdfFile =
sdf::filesystem::append(g_modelsPath, "nested_multiple_actors_error");
sdf::Root root;
sdf::Errors errors = root.Load(sdfFile);
ASSERT_FALSE(errors.empty());
EXPECT_EQ(sdf::ErrorCode::ELEMENT_INCORRECT_TYPE, errors[0].Code());
EXPECT_EQ("Found more than one actor for <include>.", errors[0].Message());
EXPECT_EQ(nullptr, root.Model());
EXPECT_EQ(nullptr, root.Light());
const auto * actor = root.Actor();
ASSERT_NE(nullptr, actor);
EXPECT_EQ("nested_actor", actor->Name());
ASSERT_EQ(1u, actor->LinkCount());
EXPECT_EQ("link1", actor->LinkByIndex(0)->Name());
}
//////////////////////////////////////////////////
// Check that an error is emitted if there are multiple lights in an included
// file. Despite the error, the first light should be loaded.
TEST(IncludesTest, NestedMultipleLightsError)
{
sdf::setFindCallback(findFileCb);
const auto sdfFile =
sdf::filesystem::append(g_modelsPath, "nested_multiple_lights_error");
sdf::Root root;
sdf::Errors errors = root.Load(sdfFile);
ASSERT_FALSE(errors.empty());
EXPECT_EQ(sdf::ErrorCode::ELEMENT_INCORRECT_TYPE, errors[0].Code());
EXPECT_EQ("Found more than one light for <include>.", errors[0].Message());
EXPECT_EQ(nullptr, root.Model());
EXPECT_EQ(nullptr, root.Actor());
const auto * light = root.Light();
ASSERT_NE(nullptr, light);
EXPECT_EQ("nested_light", light->Name());
EXPECT_EQ(ignition::math::Vector3d(1, 0, 0), light->Direction());
}
//////////////////////////////////////////////////
// Check that an error is emitted if there are more than one of model, actor, or
// light in an included file. Despite the error, the
// the first model, actor, light should be loaded in that order of preference.
TEST(IncludesTest, NestedMultipleElementsError)
{
sdf::setFindCallback(findFileCb);
const auto sdfFile =
sdf::filesystem::append(g_modelsPath, "nested_multiple_elements_error");
sdf::Root root;
sdf::Errors errors = root.Load(sdfFile);
ASSERT_FALSE(errors.empty());
EXPECT_EQ(sdf::ErrorCode::ELEMENT_INCORRECT_TYPE, errors[0].Code());
EXPECT_EQ(
"Found other top level element <actor> in addition to <model> in include "
"file.",
errors[0].Message());
EXPECT_EQ(nullptr, root.Light());
EXPECT_EQ(nullptr, root.Actor());
const auto * model = root.Model();
ASSERT_NE(nullptr, model);
EXPECT_EQ("nested_model", model->Name());
}
//////////////////////////////////////////////////
TEST(IncludesTest, NestedMultipleElementsErrorWorld)
{
sdf::setFindCallback(findFileCb);
const auto sdfFile =
sdf::filesystem::append(
g_sdfPath, "nested_multiple_elements_error_world.sdf");
sdf::Root root;
sdf::Errors errors = root.Load(sdfFile);
ASSERT_FALSE(errors.empty());
EXPECT_EQ(sdf::ErrorCode::ELEMENT_INCORRECT_TYPE, errors[0].Code());
EXPECT_EQ(nullptr, root.Light());
EXPECT_EQ(nullptr, root.Actor());
EXPECT_EQ(nullptr, root.Model());
ASSERT_EQ(1u, root.WorldCount());
const auto * world = root.WorldByIndex(0);
ASSERT_NE(nullptr, world);
ASSERT_EQ(1u, world->ModelCount());
const auto model = world->ModelByIndex(0);
EXPECT_EQ("nested_model", model->Name());
ASSERT_EQ(1u, model->LinkCount());
EXPECT_EQ("link", model->LinkByIndex(0)->Name());
}
| 32.602273 | 80 | 0.681771 | [
"geometry",
"model"
] |
9733df9a256a0557c19a269be069a76263bbbecc | 703 | hpp | C++ | src/include/enums.hpp | N4G170/project_euler_net | f8ec89f0b88fed687d7bd599095274f7025895a2 | [
"MIT"
] | null | null | null | src/include/enums.hpp | N4G170/project_euler_net | f8ec89f0b88fed687d7bd599095274f7025895a2 | [
"MIT"
] | null | null | null | src/include/enums.hpp | N4G170/project_euler_net | f8ec89f0b88fed687d7bd599095274f7025895a2 | [
"MIT"
] | null | null | null | #ifndef ENUMS_HPP
#define ENUMS_HPP
enum TextAlignment
{
TOP_LEFT = 0,
CENTER = 1,
TOP_RIGHT = 2
};
enum Weekdays//for problems
{
SUNDAY,
MONDAY,
TUESDAY,
WEDNESDAY,
THURSDAY,
FRIDAY,
SATURDAY
};
enum Months//for problems
{
JANUARY,
FEBRUARY,
MARCH,
APRIL,
MAY,
JUNE,
JULY,
AUGUST,
SEPTEMBER,
OCTOBER,
NOVEMBER,
DECEMBER
};
enum TimeScale
{
SECONDS,
MILLISECONDS
};
enum FontRenderType
{
SOLID,
SHADED,
BLENDED
};
enum ResourceManagerContext
{
NONE,
SPLASH,
PROBLEMS
};
/**
* \brief this enum is tmp
*/
enum FontSizes
{
S_12 = 12,
S_20 = 20,
S_28 = 28
};
#endif
| 10.338235 | 27 | 0.578947 | [
"solid"
] |
97353e5e857e567c1d9eb011b5da982460618561 | 29,026 | hpp | C++ | src/nnfusion/core/kernels/cuda_gpu/kernels/reduce.hpp | lynex/nnfusion | 6332697c71b6614ca6f04c0dac8614636882630d | [
"MIT"
] | 1 | 2021-05-14T08:10:30.000Z | 2021-05-14T08:10:30.000Z | src/nnfusion/core/kernels/cuda_gpu/kernels/reduce.hpp | lynex/nnfusion | 6332697c71b6614ca6f04c0dac8614636882630d | [
"MIT"
] | null | null | null | src/nnfusion/core/kernels/cuda_gpu/kernels/reduce.hpp | lynex/nnfusion | 6332697c71b6614ca6f04c0dac8614636882630d | [
"MIT"
] | 1 | 2021-02-13T08:10:55.000Z | 2021-02-13T08:10:55.000Z | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#pragma once
#include "../cuda_emitter.hpp"
#include "../cuda_langunit.hpp"
#include "nnfusion/core/operators/generic_op/generic_op.hpp"
DECLARE_string(fdefault_device);
namespace nnfusion
{
namespace kernels
{
namespace cuda
{
template <class T>
class Reduce : public CudaEmitter
{
public:
Reduce(shared_ptr<KernelContext> ctx)
: CudaEmitter(ctx)
{
if (auto reduce =
dynamic_pointer_cast<nnfusion::op::Reduce>(ctx->gnode->get_op_ptr()))
{
reduce_axis = reduce->get_reduction_axes();
init_value = " = 0.0";
}
else if (auto reduce =
dynamic_pointer_cast<nnfusion::op::Max>(ctx->gnode->get_op_ptr()))
{
reduce_axis = reduce->get_reduction_axes();
init_value = " = input0[in_idx]";
}
else if (auto reduce =
dynamic_pointer_cast<nnfusion::op::Min>(ctx->gnode->get_op_ptr()))
{
reduce_axis = reduce->get_reduction_axes();
init_value = " = input0[in_idx]";
}
else if (auto reduce = dynamic_pointer_cast<nnfusion::op::Product>(
ctx->gnode->get_op_ptr()))
{
reduce_axis = reduce->get_reduction_axes();
init_value = " = 1.0";
}
else if (auto reduce =
dynamic_pointer_cast<nnfusion::op::Sum>(ctx->gnode->get_op_ptr()))
{
reduce_axis = reduce->get_reduction_axes();
init_value = " = 0.0";
}
else if (auto reduce = dynamic_pointer_cast<nnfusion::op::ReduceAny>(
ctx->gnode->get_op_ptr()))
{
reduce_axis = reduce->get_reduction_axes();
init_value = " = false";
}
else
{
NNFUSION_CHECK_FAIL() << "incorrect kernel for reduce";
}
reduce_rank = reduce_axis.size();
input_shape = nnfusion::Shape(ctx->inputs[0]->get_shape());
output_shape = nnfusion::Shape(ctx->outputs[0]->get_shape());
data_bytes = ctx->inputs[0]->get_element_type().size();
rank = input_shape.size();
out_rank = rank - reduce_rank;
reduce_op = CudaOpMap<T>::op;
// use to determine if it is RowReduction
std::vector<size_t> axes_flag(input_shape.size(), 0);
for (auto const& axis : reduce_axis)
{
axes_flag[axis] = 1;
}
height = 1;
width = 1;
is_row_reduction = true;
int i = 0;
for (; i < axes_flag.size() && (axes_flag[i] == 0 || input_shape[i] == 1); i++)
{
height *= input_shape[i];
}
for (; i < axes_flag.size() && (axes_flag[i] == 1 || input_shape[i] == 1); i++)
{
width *= input_shape[i];
}
if (i != axes_flag.size())
is_row_reduction = false;
// `is_row_reduction` is not working on ROCm, using old implementation
if (FLAGS_fdefault_device == "ROCm")
{
is_row_reduction = false;
}
// current row_reduction implementation is now working for max/min/prod reduction
if (reduce_op != "add") // || width % 32 != 0)
{
is_row_reduction = false;
}
if (is_row_reduction)
expected_block_size =
width > 512
? 512
: pow(2, static_cast<size_t>(log2(static_cast<float>(width))));
uint32_t block_size_x_acc = 256;
nthreads_acc = ctx->gpu_num_sm * block_size_x_acc;
input_type = ctx->inputs[0]->get_element_type().c_type_string();
output_type = ctx->outputs[0]->get_element_type().c_type_string();
std::stringstream tag;
tag << "cuda"
<< "_reduce"
<< "_" << reduce_op << "_" << input_type << "_" << output_type << "_s_"
<< join(input_shape, "_") << "_axis_" << join(reduce_axis, "_");
custom_tag = tag.str();
}
LanguageUnit_p emit_function_body() override
{
// Trivial case: no reduction axes.
if (reduce_rank == 0 || shape_size(input_shape) == shape_size(output_shape))
{
return nullptr;
}
else if (is_row_reduction)
{
return emit_row_reduction_body();
}
else if (out_rank != 0)
{
return emit_function_body_nd();
}
else
{
uint32_t nthreads = static_cast<uint32_t>(shape_size(input_shape));
// If the data size is large, call reduce_to_scalar_acc first and then reduce_to_scalar.
// Otherwise, call reduce to scalar directly.
const uint32_t unroll_size = 8;
if (nthreads > nthreads_acc * (unroll_size + 1))
{
// TODO(wenxh): Ignore this Case.
return nullptr;
}
else
{
return emit_function_body_scalar();
}
}
}
LanguageUnit_p emit_function_body_memcpy()
{
LanguageUnit_p _lu(new LanguageUnit(get_function_name()));
auto& lu = *_lu;
lu << "if (input0 != output0) {\n"
<< " cudaMemcpyAsync(output0, input0, "
<< static_cast<uint32_t>(shape_size(input_shape)) << " * sizeof("
<< input_type << ")"
<< ", cudaMemcpyDeviceToDevice, stream);\n"
<< "}\n";
return _lu;
}
LanguageUnit_p emit_row_reduction_body()
{
LanguageUnit_p _lu(new LanguageUnit(get_function_name()));
auto& lu = *_lu;
auto code = nnfusion::op::create_code_from_template(
R"(
int width = @width@;
int block_size = @block_size@;
const int warp_size = @warp_size@;
__shared__ float shm[warp_size];
int thread_idx = threadIdx.x;
int block_idx = blockIdx.x;
int data_idx_offset = block_idx * width;
float val = 0.0;
for (int tidx = thread_idx; tidx < width; tidx += block_size) {
int data_idx = tidx + data_idx_offset;
val += input0[data_idx];
}
val = reduceSum(val, thread_idx, block_size, shm);
if (thread_idx == 0) output0[block_idx] = val;
)",
{{"width", width}, {"block_size", expected_block_size}, {"warp_size", 32}});
lu << code << "\n";
return _lu;
}
LanguageUnit_p emit_function_body_nd()
{
LanguageUnit_p _lu(new LanguageUnit(get_function_name()));
auto& lu = *_lu;
Shape reduce_flag(rank, 0);
for (auto a : reduce_axis)
{
reduce_flag[a] = 1;
}
input_strides = row_major_strides(input_shape);
for (int i = 0; i < rank; i++)
{
if (reduce_flag[i] != 0)
{
reduce_shape.push_back(input_shape[i]);
reduce_strides.push_back(input_strides[i]);
}
else
{
non_reduce_strides.push_back(input_strides[i]);
//output_shape.push_back(input_shape[i]);
}
}
NVShape output_strides = row_major_strides(output_shape);
uint32_t nthreads = static_cast<uint32_t>(shape_size(output_shape));
// TODO: currently we set it to 64, will add tuning method later.
uint32_t block_size_x = 64;
uint32_t aligned_grid_size_x = align_to_block_size(nthreads, block_size_x);
auto expand_vector_uint32 = [](string name, vector<uint32_t>& d) {
stringstream ss;
for (int i = 0; i < d.size(); i++)
ss << "uint32_t " << name << i << " = " << to_string(d[i]) << ";\n";
return ss.str();
};
lu << expand_vector_uint32("out_strides", output_strides);
lu << expand_vector_uint32("non_reduce_strides", non_reduce_strides);
lu << expand_vector_uint32("reduce_shape", reduce_shape);
lu << expand_vector_uint32("reduce_strides", reduce_strides);
lu << "uint32_t tid = blockIdx.x * blockDim.x + threadIdx.x; \n";
lu << "if (tid < " << nthreads << ")\n";
lu.block_begin();
{
if (out_rank > 0)
{
lu << "uint32_t dim_idx_generator = tid;\n";
}
lu << "uint32_t in_idx = 0;\n";
// Loop through all reduction axis.
for (int64_t i = 0; i < static_cast<int64_t>(out_rank); i++)
{
lu << "in_idx += (dim_idx_generator / out_strides" << i
<< ") * non_reduce_strides" << i << ";\n";
lu << "dim_idx_generator %= out_strides" << i << ";\n";
}
lu << output_type << " r" << init_value << ";\n";
int64_t last_r_idx = static_cast<int64_t>(reduce_rank) - 1;
for (int64_t j = 0; j < last_r_idx; j++)
{
lu << "for(int idx" << j << " = 0; idx" << j << "< reduce_shape" << j
<< "; idx" << j << "++)\n";
lu.block_begin();
}
{
lu << "uint32_t reduce_idx = in_idx;\n";
for (int64_t j = 0; j < last_r_idx; j++)
{
lu << "reduce_idx += idx" << j << " * reduce_strides" << j << ";\n";
}
lu << "int idx" << last_r_idx << " = 0;\n";
lu << "uint32_t step = reduce_strides" << last_r_idx << ";\n";
// Unroll last reduction axis.
uint32_t unroll_num = 8;
uint32_t unroll_shift = 3;
lu << "for(; idx" << last_r_idx << " < (reduce_shape" << last_r_idx
<< " >> " << unroll_shift << "); idx" << last_r_idx << "++)\n";
lu.block_begin();
{
for (int k = 0; k < unroll_num; k++)
{
lu << "r = " << reduce_op << "(r , input0[reduce_idx]);\n";
lu << "reduce_idx += step;\n";
}
}
lu.block_end();
lu << "idx" << last_r_idx << " <<= " << unroll_shift << ";\n";
lu << "for(; idx" << last_r_idx << " < reduce_shape" << last_r_idx
<< "; idx" << last_r_idx << "++)\n";
lu.block_begin();
{
lu << "r = " << reduce_op << "(r , input0[reduce_idx]);\n";
lu << "reduce_idx += step;\n";
}
lu.block_end();
}
for (int64_t j = 0; j < last_r_idx; j++)
{
lu.block_end();
}
lu << "output0[tid] = r;\n";
}
lu.block_end();
return _lu;
}
LanguageUnit_p emit_function_body_scalar()
{
LanguageUnit_p _lu(new LanguageUnit(get_function_name()));
auto& lu = *_lu;
uint32_t nthreads = static_cast<uint32_t>(shape_size(input_shape));
uint32_t n = nthreads;
uint32_t block_size_x = 1;
while (n > 1)
{
block_size_x <<= 1;
n >>= 1;
}
block_size_x = fmin(512, block_size_x);
// TODO (yanhon): if sdata size is not specified, frozen_reduce_sum_2_graph.pb will crash
lu << "extern __shared__ " << output_type << " sdata[" << block_size_x
<< "];\n";
//lu << "extern __shared__ " << output_type << " sdata[];\n";
lu << "uint32_t tid = threadIdx.x; \n";
lu << "uint32_t step = blockDim.x; \n";
lu << "sdata[tid] = 0;\n";
lu << "uint32_t in_idx = tid;\n";
lu << output_type << " r" << init_value << ";\n";
lu << "if(in_idx < " << nthreads << ")\n";
lu.block_begin();
lu << "r = input0[in_idx];\n";
lu << "in_idx += step;\n";
lu.block_end();
// Accumulate reduction to blockDim.x threads.
uint32_t unroll_num = 8;
lu << "while(in_idx + (step * " << unroll_num - 1 << ") < " << nthreads
<< ")\n";
lu.block_begin();
{
for (int i = 0; i < unroll_num; i++)
{
lu << "r = " << reduce_op << "(r , input0[in_idx]);\n";
lu << "in_idx += step;\n";
}
}
lu.block_end();
lu << "while(in_idx < " << nthreads << ")\n";
lu.block_begin();
{
lu << "r = " << reduce_op << "(r , input0[in_idx]);\n";
lu << "in_idx += step;\n";
}
lu.block_end();
// Accumulate 32 threads for each warp.
for (int i = 16; i >= 1; i >>= 1)
{
if (block_size_x > i)
{
lu << "r = " << reduce_op << "(r, __shfl_down_sync(0xffffffff, r, " << i
<< ", 32));\n";
}
}
if (block_size_x > 32)
{
lu << "uint32_t lane_idx = tid & 0x1f; \n";
lu << "uint32_t warp_idx = tid >> 5; \n";
lu << "if(lane_idx == 0)\n";
lu.block_begin();
{
lu << "sdata[warp_idx] = r;\n";
}
lu.block_end();
lu << "__syncthreads();\n";
uint32_t warp_size = block_size_x >> 5;
lu << "if(tid < " << warp_size << ")\n";
lu.block_begin();
{
lu << "r = sdata[tid];\n";
}
lu.block_end();
// Accumulate 32 threads.
for (int i = 16; i >= 1; i >>= 1)
{
if (warp_size > i)
{
lu << "r = " << reduce_op << "(r, __shfl_down_sync(0xffffffff, r, "
<< i << ", 32));\n";
}
}
}
lu << "if(tid == 0)\n";
lu.block_begin();
{
lu << "output0[0] = r;\n";
}
lu.block_end();
return _lu;
}
LanguageUnit_p emit_dependency() override
{
LanguageUnit_p _lu(new LanguageUnit(get_function_name() + "_dep"));
_lu->require(header::cuda);
_lu->require(header::stdio);
_lu->require(macro::MIN);
_lu->require(declaration::num_SMs);
if (is_row_reduction)
{
_lu->require(declaration::cuda_reduce_primitive);
}
if (CudaOpMap<T>::math_kernel != nullptr)
{
auto math_kernel =
get_math_kernel(reduce_op,
CudaOpMap<T>::math_kernel,
vector<string>{input_type, input_type, output_type});
NNFUSION_CHECK_NOT_NULLPTR(math_kernel);
_lu->require(math_kernel);
}
return _lu;
}
void set_launch_config() override
{
if (is_row_reduction)
{
m_gridDim = dim3(height, 1, 1);
m_blockDim = dim3(expected_block_size, 1, 1);
}
else if (out_rank != 0)
{
uint32_t nthreads = static_cast<uint32_t>(shape_size(output_shape));
// TODO: currently we set it to 64, will add tuning method later.
uint32_t block_size_x = 64;
uint32_t aligned_grid_size_x = align_to_block_size(nthreads, block_size_x);
m_gridDim = dim3(aligned_grid_size_x, 1, 1);
m_blockDim = dim3(block_size_x, 1, 1);
}
else
{
uint32_t nthreads = static_cast<uint32_t>(shape_size(input_shape));
// If the data size is large, call reduce_to_scalar_acc first and then reduce_to_scalar.
// Otherwise, call reduce to scalar directly.
const uint32_t unroll_size = 8;
if (nthreads > nthreads_acc * (unroll_size + 1))
{
NNFUSION_CHECK_FAIL() << "No support for GPU memory allocation.";
}
else
{
uint32_t nthreads = static_cast<uint32_t>(shape_size(input_shape));
uint32_t n = nthreads;
uint32_t block_size_x = 1;
while (n > 1)
{
block_size_x <<= 1;
n >>= 1;
}
block_size_x = fmin(512, block_size_x);
m_gridDim = dim3(1, 1, 1);
m_blockDim = dim3(block_size_x, 1, 1);
}
}
}
private:
shared_ptr<KernelContext> kernel_ctx;
nnfusion::AxisSet reduce_axis;
nnfusion::Shape input_shape, output_shape;
nnfusion::NVShape input_strides, non_reduce_strides, reduce_strides, reduce_shape;
size_t data_bytes, rank, reduce_rank, out_rank;
uint32_t nthreads_acc;
string reduce_op, input_type, output_type, init_value;
size_t height, width, expected_block_size;
bool is_row_reduction;
};
template <class T>
class ReduceMemcpy : public CudaLibEmitter
{
public:
ReduceMemcpy(shared_ptr<KernelContext> ctx)
: CudaLibEmitter(ctx)
{
if (auto reduce =
dynamic_pointer_cast<nnfusion::op::Reduce>(ctx->gnode->get_op_ptr()))
{
reduce_axis = reduce->get_reduction_axes();
}
else if (auto reduce =
dynamic_pointer_cast<nnfusion::op::Max>(ctx->gnode->get_op_ptr()))
{
reduce_axis = reduce->get_reduction_axes();
}
else if (auto reduce =
dynamic_pointer_cast<nnfusion::op::Min>(ctx->gnode->get_op_ptr()))
{
reduce_axis = reduce->get_reduction_axes();
}
else if (auto reduce = dynamic_pointer_cast<nnfusion::op::Product>(
ctx->gnode->get_op_ptr()))
{
reduce_axis = reduce->get_reduction_axes();
}
else if (auto reduce =
dynamic_pointer_cast<nnfusion::op::Sum>(ctx->gnode->get_op_ptr()))
{
reduce_axis = reduce->get_reduction_axes();
}
else if (auto reduce = dynamic_pointer_cast<nnfusion::op::ReduceAny>(
ctx->gnode->get_op_ptr()))
{
reduce_axis = reduce->get_reduction_axes();
}
else
{
NNFUSION_CHECK_FAIL() << "incorrect kernel for reduce";
}
reduce_rank = reduce_axis.size();
input_shape = nnfusion::Shape(ctx->inputs[0]->get_shape());
output_shape = nnfusion::Shape(ctx->outputs[0]->get_shape());
rank = input_shape.size();
out_rank = rank - reduce_rank;
reduce_op = CudaOpMap<T>::op;
input_type = ctx->inputs[0]->get_element_type().c_type_string();
output_type = ctx->outputs[0]->get_element_type().c_type_string();
std::stringstream tag;
tag << "cuda"
<< "_reduce_Memcpy"
<< "_" << reduce_op << "_" << input_type << "_" << output_type << "_s_"
<< join(input_shape, "_") << "_axis_" << join(reduce_axis, "_");
custom_tag = tag.str();
// add inplace tag
if (reduce_rank == 0 || shape_size(input_shape) == shape_size(output_shape))
{
if (!ctx->annotations)
{
ctx->annotations = std::make_shared<Annotations>();
}
ctx->annotations->add_in_place_oi_pair({0, 0, false});
}
}
bool is_eliminative() override
{
if ((reduce_rank == 0 || shape_size(input_shape) == shape_size(output_shape)) &&
m_context->inputs[0]->is_same_address(m_context->outputs[0]))
return true;
else
return false;
}
LanguageUnit_p emit_function_body() override
{
if (reduce_rank != 0 && shape_size(input_shape) != shape_size(output_shape))
{
return nullptr;
}
LanguageUnit_p _lu(new LanguageUnit(get_function_name()));
auto& lu = *_lu;
auto& dst = m_context->outputs[0];
auto& src = m_context->inputs[0];
lu << dst->get_element_type().c_type_string() << "* " << dst->get_name()
<< " = output0;\n";
lu << src->get_element_type().c_type_string() << "* " << src->get_name()
<< " = input0;\n";
//emit_memcpyDtD(lu, dst, src);
lu << "if (input0 != output0) {\n"
<< " CUDA_SAFE_CALL(cudaMemcpyAsync(" << dst->get_name() << ", "
<< src->get_name() << ", " << dst->size()
<< ", cudaMemcpyDeviceToDevice, stream));\n"
<< "}\n";
return _lu;
}
LanguageUnit_p emit_dependency() override
{
LanguageUnit_p _lu(new LanguageUnit(get_function_name() + "_dep"));
_lu->require(header::cuda);
return _lu;
}
LanguageUnit_p emit_function_signature() override
{
LanguageUnit_p _lu(new LanguageUnit(this->m_kernel_name + "_sig"));
auto& lu = *_lu;
vector<string> params;
for (size_t i = 0; i < m_context->inputs.size(); i++)
{
stringstream ss;
ss << m_context->inputs[i]->get_element_type().c_type_string() << "* ";
ss << "input" << i;
params.push_back(ss.str());
}
for (size_t i = 0; i < m_context->outputs.size(); i++)
{
stringstream ss;
ss << m_context->outputs[i]->get_element_type().c_type_string() << "* ";
ss << "output" << i;
params.push_back(ss.str());
}
for (size_t i = 0; i < m_context->tensors.size(); i++)
{
stringstream ss;
ss << m_context->tensors[i]->get_element_type().c_type_string() << "* ";
// defult name is: "persit0", "persist1" ...
ss << m_context->tensors[i]->get_name();
params.push_back(ss.str());
}
lu << "void "
<< "(cudaStream_t stream, " << join(params, ", ") << ")";
return _lu;
}
private:
shared_ptr<KernelContext> kernel_ctx;
nnfusion::AxisSet reduce_axis;
nnfusion::Shape input_shape, output_shape;
size_t rank, reduce_rank, out_rank;
string reduce_op, input_type, output_type;
};
} // namespace cuda
} // namespace kernels
} // namespace nnfusion
| 44.179604 | 112 | 0.387825 | [
"shape",
"vector"
] |
9741337035ca25ae9806ec8ad774e89dddabc81c | 3,031 | hpp | C++ | include/lv_align_verify.hpp | FishInWave/lv_align_verify | fff5eb80ed6ba7c7b870e366377acc7e7e0cb13d | [
"BSD-3-Clause"
] | 2 | 2021-09-26T07:00:35.000Z | 2021-12-26T04:09:36.000Z | include/lv_align_verify.hpp | FishInWave/lv_align_verify | fff5eb80ed6ba7c7b870e366377acc7e7e0cb13d | [
"BSD-3-Clause"
] | null | null | null | include/lv_align_verify.hpp | FishInWave/lv_align_verify | fff5eb80ed6ba7c7b870e366377acc7e7e0cb13d | [
"BSD-3-Clause"
] | 1 | 2021-12-26T04:09:41.000Z | 2021-12-26T04:09:41.000Z | #ifndef LV_ALIGN_VERIFY_HPP
#define LV_ALIGN_VERIFY_HPP
// third party
#include <ros/ros.h>
#include <opencv2/opencv.hpp>
#include <sl/Camera.hpp>
#include <pcl/point_types.h>
#include <pcl/point_cloud.h>
#include <sensor_msgs/PointCloud2.h>
#include <dynamic_reconfigure/server.h>
#include "lv_align_verify/LVAlignVerifyConfig.h"
// STL
#include <mutex>
#include <atomic>
#include <fstream>
// self
#include "rslidar_utils.hpp"
using namespace sl;
// using PointT = pcl::PointXYZ;
using PointT = RsPointXYZIRT;
using PointCloud = pcl::PointCloud<PointT>;
// 前为zed,后为uwb
class LVAlignVerify
{
private:
// ros
ros::Subscriber points_sub_;
ros::Publisher points_pub_;
ros::Publisher points_pub_2;
ros::NodeHandle pnh_;
// ros 动态调参
dynamic_reconfigure::Server<lv_align_verify::LVAlignVerifyConfig> *dsrv_;
int margin_; // 激光点的margin,值越大越粗
double c_l_x_,c_l_y_,c_l_z_,c_l_roll_,c_l_pitch_,c_l_yaw_;
// zed intrinsic
Camera zed_;
InitParameters init_params_;
CalibrationParameters calibration_params_;
RuntimeParameters runtime_parameters_;
Eigen::Matrix4d K_intrinsic_;
float k1_,k2_,k3_,p1_,p2_; // 去畸变参数,可能用不上
float fx_,fy_,cx_,cy_; // 内参系数
// zed config
std::string camera_resolution_;
int image_width_,image_height_;// x and y
int camera_fps_;
bool enable_depth_;
std::string depth_mode_;
float depth_minimum_;
float depth_maximum_;
std::string coordinate_units_;
std::string coordinate_system_;
std::string sensing_mode_;
// lidar config
std::string points_topic_;
bool with_RT_field_;
// flag
char key_down_; // 按下的按键
// global
std::string output_directory_;
std::string pic_output_directory_;
std::ofstream transformation_ofs_;
double z_camera_to_uwb_;
Eigen::Matrix4d transform_c_ros_; // c_cv to c_ros 因为IMU的坐标系是符合ROS的
std::vector<double> transform_c_l_V_; // 行排列的向量
Eigen::Matrix4d transform_c_l_; // 外参矩阵
cv::Vec4b pixel_; // 激光点的颜色定义
std::mutex transform_mutex_;
ros::Time image_stamp_; // 图片时间戳
public:
LVAlignVerify(ros::NodeHandle nh, int argc, char **argv);
LVAlignVerify() = default;
~LVAlignVerify();
/**
* @brief 初始化需要用到的数组等
*
*/
void initialSystem();
void getROSParam();
// 接收激光雷达点云后,将其转换到zed2_left_camera_frame,进行图像采集。
void pointsCallback(const sensor_msgs::PointCloud2ConstPtr msg);
// 去畸变校正
// 旋转中心直接使用左目吧,省去一些操作。
void deskewPointCloud(PointCloud::ConstPtr raw_points,PointCloud::ConstPtr deskewed_points);
/**
* @brief 处理按键
*
*/
void processKeyEvent(cv::Mat& image);
void reconfigureCB(lv_align_verify::LVAlignVerifyConfig &config, uint32_t level);
//TODO 未被使用的函数,下次迭代时,考虑删除
//计算2D BBOX质心
bool calculateCentroidOfBbox(Mat &pointcloud_img, cv::Rect2d roi,pcl::PointXYZ& centroid_bbox);
void displayFrameStream(){}
void projectCloudIntoImage(const PointCloud::ConstPtr pointcloud, const cv::Mat image){}
};
#endif | 28.866667 | 99 | 0.713626 | [
"vector"
] |
974744b4fab531db6bd81163bb461fde4514acbf | 17,864 | cpp | C++ | Modified pong.cpp | AimAndIgnite/modified-pong-game | b9b72f301e217bd1b8859d00f4f07c09eec4062c | [
"MIT"
] | null | null | null | Modified pong.cpp | AimAndIgnite/modified-pong-game | b9b72f301e217bd1b8859d00f4f07c09eec4062c | [
"MIT"
] | null | null | null | Modified pong.cpp | AimAndIgnite/modified-pong-game | b9b72f301e217bd1b8859d00f4f07c09eec4062c | [
"MIT"
] | null | null | null | #include<iostream>
#include<time.h>
#include<conio.h>
#include<Windows.h>
using namespace std;
enum eDir { STOP = 0, LEFT = 1, UPLEFT = 2, DOWNLEFT = 3, RIGHT = 4, UPRIGHT = 5, DOWNRIGHT = 6 };
bool isFinished = false;
bool quit = false;
int menumain;
class Object
{
protected :
int x, y;
int originalX, originalY;
public :
virtual void Reset() = 0;
inline int getX() { return x; }
inline int getY() { return y; }
};
class Ball : public Object
{
private:
eDir direction;
public:
Ball(int posX, int posY)
{
originalX = posX;
originalY = posY;
x = posX;
y = posY;
direction = STOP;
}
void Reset()
{
x = originalX;
y = originalY;
direction = STOP;
}
void changeDirection(eDir d)
{
direction = d;
}
void randomDirection()
{
direction = (eDir)((rand() % 6) + 1);
}
inline eDir getDirection() { return direction; }
void Move()
{
switch (direction)
{
case STOP:
break;
case LEFT:
x--;
break;
case RIGHT:
x++;
break;
case UPLEFT:
x--; y--;
break;
case DOWNLEFT:
x--; y++;
break;
case UPRIGHT:
x++; y--;
break;
case DOWNRIGHT:
x++; y++;
break;
default:
break;
}
}
};
class Paddle : public Object
{
protected:
int score;
int min, max;
public:
Paddle()
{
x = y = 0;
}
Paddle(int posX, int posY)
{
originalX = posX;
originalY = posY;
x = posX;
y = posY;
}
int getMin()
{
return min;
}
int getMax()
{
return max;
}
void addMin()
{
this->min += 1;
}
void addMax()
{
this->max += 1;
}
inline void Reset() { x = originalX; y = originalY; }
inline void moveUp() { y--; }
inline void moveDown() { y++; }
};
class NormalPaddle : public Paddle
{
public:
NormalPaddle(int posX, int posY)
{
originalX = posX;
originalY = posY;
x = posX;
y = posY;
min = 0;
max = 6;
}
};
class GameManager
{
protected:
int menu;
int width, height;
int score1, score2;
char up1, down1, up2, down2;
char ans;
char current;
Ball *ball;
Paddle *player1, *obstacle1;
Paddle *player2, *obstacle2;
public:
GameManager()
{
}
GameManager(int width, int height/*int menu*/)
{
srand(time(NULL));
up1 = 'w'; up2 = 'i';
down1 = 's'; down2 = 'k';
score1 = score2 = 0;
this->width = width;
this->height = height;
//this->menu=menu;
ball = new Ball(width / 1, height / 2);
// if(menu == 1 || menu == 2 || menu == 3 || menu == 4)
// {
player1 = new NormalPaddle(1, height / 2 - 3);
obstacle1 = new NormalPaddle(2, height /3 - 4);
player2 = new NormalPaddle(width - 2, height / 2 - 3);
obstacle2 = new NormalPaddle(width / 2, height / 2);
// }
}
~GameManager()
{
delete ball, player1, player2;
}
void gotoxy(int x, int y)
{
COORD c = {x, y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c);
}
void scoreUp(Paddle *player)
{
if (player == player1) score1++;
else if (player == player2) score2++;
ball->Reset();
player1->Reset();
player2->Reset();
}
void returnMenu()
{
cout << "Do you want to play again? (y/n) ";
cin >> ans;
if(ans == 'y')
{
system("cls");
score1 = score2 = 0;
}
else
{
cout << "Back To Main Menu ? (y/n) ";
cin >> ans;
if(ans == 'y')
{
system("cls");
quit = true;
}
else
{
quit = true;
isFinished = true;
}
}
}
void validateScore()
{
if(score1 == 5)
{
cout << endl << "Player 1... YOU ARE THE WINNER" << endl;
returnMenu();
}
else if(score2 == 5)
{
cout << endl << "Player 2... YOU ARE THE WINNER" << endl;
returnMenu();
}
}
void validateExit()
{
if(current == 'q')
{
quit = true;
isFinished = true;
}
}
void draw(int drawType)
{
gotoxy(0, 0);
for (int i = 0; i < width + 2; i++) cout << "\xDB";
cout << endl;
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
int ballx = ball->getX();
int bally = ball->getY();
int player1x = player1->getX();
int obstacle1x = obstacle1->getX();
int obstacle1y = obstacle1->getY();
int obstacle2x = obstacle2->getX();
int obstacle2y = obstacle2->getY();
int player1y = player1->getY();
int player2x = player2->getX();
int player2y = player2->getY();
int minP1 = player1->getMin();
int maxP1 = player1->getMax();
int maxO1 = obstacle1->getMax();
int minO1 = obstacle1->getMin();
int minP2 = player2->getMin();
int maxP2 = player2->getMax();
int maxO2 = obstacle2->getMax();
int minO2 = obstacle2->getMin();
if (drawType == 1) //normal draw
{
if (j == 0) cout << "\xDB";
if (ballx == j && bally == i) cout << "O"; //ball
// else if (player1x == j && player1y == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
// else if (player1x == j && player1y + 1 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
// else if (player1x == j && player1y + 2 == i&&minP1<maxP1) cout << "\xDB";
// else if (player1x == j && player1y + 3 == i&&minP1<maxP1) cout << "\xDB";
// else if (player1x == j && player1y + 4 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
// else if (player1x == j && player1y + 5 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
//
else if (obstacle1x == j+1 && obstacle1y == i+5&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (obstacle1x == j+1 && obstacle1y + 1 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (obstacle1x == j+1 && obstacle1y + 2 == i&&minP1<maxP1) cout << "\xDB";
else if (obstacle1x == j+1 && obstacle1y + 3 == i&&minP1<maxP1) cout << "\xDB";
else if (obstacle1x == j+1 && obstacle1y + 4 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (obstacle1x == j+1 && obstacle1y + 5 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
// else if (player2x == 2 && player2y == i&&minP2<maxP2&&menu!=3&menu!=4) cout << "\xDB";
// else if (player2x == 21 && player2y + 1 == i&&minP2<maxP2&&menu!=3&menu!=4) cout << "\xDB";
// else if (player2x == 2 && player2y + 2 == i&&minP2<maxP2) cout << "\xDB";
// else if (player2x == 2 && player2y + 3 == i&&minP2<maxP2) cout << "\xDB";
// else if (player2x == 2 && player2y + 4 == i&&minP2<maxP2&&menu!=3&menu!=4) cout << "\xDB";
// else if (player2x == 2 && player2y + 5 == i&&minP2<maxP2&&menu!=3&menu!=4) cout << "\xDB";
//
else if (obstacle2x == j && obstacle2y == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (obstacle2x == j && obstacle2y + 1 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (obstacle2x == j && obstacle2y + 2 == i&&minP1<maxP1) cout << "\xDB";
else if (obstacle2x == j && obstacle2y + 3 == i&&minP1<maxP1) cout << "\xDB";
else if (obstacle2x == j && obstacle2y + 4 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (obstacle2x == j && obstacle2y + 5 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else cout << " ";
minP1++;
minP2++;
minO1++;
minO2++;
if (j == width - 1) cout << "\xDB";
}
else if (drawType == 2) //paddle 1 bolong
{
if (j == 0) cout << "\xDB";
if (ballx == j && bally == i) cout << "O"; //ball
else if (player1x == j && player1y == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (player1x == j && player1y + 1 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
//else if (player1x == j && player1y + 2 == i&&minP1<maxP1) cout << "\xDB";
//else if (player1x == j && player1y + 3 == i&&minP1<maxP1) cout << "\xDB";
else if (player1x == j && player1y + 4 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (player1x == j && player1y + 5 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (obstacle1x == j && obstacle1y == i+1&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (obstacle1x == j && obstacle1y + 1 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (obstacle1x == j && obstacle1y + 2 == i&&minP1<maxP1) cout << "\xDB";
else if (obstacle1x == j && obstacle1y + 3 == i&&minP1<maxP1) cout << "\xDB";
else if (obstacle1x == j && obstacle1y + 4 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (obstacle1x == j && obstacle1y + 5 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (player2x == j && player2y == i&&minP2<maxP2&&menu!=3&menu!=4) cout << "\xDB";
else if (player2x == j && player2y + 1 == i&&minP2<maxP2&&menu!=3&menu!=4) cout << "\xDB";
else if (player2x == j && player2y + 2 == i&&minP2<maxP2) cout << "\xDB";
else if (player2x == j && player2y + 3 == i&&minP2<maxP2) cout << "\xDB";
else if (player2x == j && player2y + 4 == i&&minP2<maxP2&&menu!=3&menu!=4) cout << "\xDB";
else if (player2x == j && player2y + 5 == i&&minP2<maxP2&&menu!=3&menu!=4) cout << "\xDB";
else cout << " ";
minP1++;
minP2++;
if (j == width - 1) cout << "\xDB";
}
else if (drawType == 3) //paddle 2 bolong
{
if (j == 0) cout << "\xDB";
if (ballx == j && bally == i) cout << "O"; //ball
else if (player1x == j && player1y == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (player1x == j && player1y + 1 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (player1x == j && player1y + 2 == i&&minP1<maxP1) cout << "\xDB";
else if (player1x == j && player1y + 3 == i&&minP1<maxP1) cout << "\xDB";
else if (player1x == j && player1y + 4 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (player1x == j && player1y + 5 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (obstacle1x == j && obstacle1y == i+1&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (obstacle1x == j && obstacle1y + 1 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (obstacle1x == j && obstacle1y + 2 == i&&minP1<maxP1) cout << "\xDB";
else if (obstacle1x == j && obstacle1y + 3 == i&&minP1<maxP1) cout << "\xDB";
else if (obstacle1x == j && obstacle1y + 4 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (obstacle1x == j && obstacle1y + 5 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (player2x == j && player2y == i&&minP2<maxP2&&menu!=3&menu!=4) cout << "\xDB";
else if (player2x == j && player2y + 1 == i&&minP2<maxP2&&menu!=3&menu!=4) cout << "\xDB";
//else if (player2x == j && player2y + 2 == i&&minP2<maxP2) cout << "\xDB";
//else if (player2x == j && player2y + 3 == i&&minP2<maxP2) cout << "\xDB";
else if (player2x == j && player2y + 4 == i&&minP2<maxP2&&menu!=3&menu!=4) cout << "\xDB";
else if (player2x == j && player2y + 5 == i&&minP2<maxP2&&menu!=3&menu!=4) cout << "\xDB";
else cout << " ";
minP1++;
minP2++;
if (j == width - 1) cout << "\xDB";
}
else if (drawType == 4) //paddle 2 bolong
{
if (j == 0) cout << "\xDB";
if (ballx == j && bally == i) cout << "O"; //ball
else if (player1x == j && player1y == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (player1x == j && player1y + 1 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
//else if (player1x == j && player1y + 2 == i&&minP1<maxP1) cout << "\xDB";
//else if (player1x == j && player1y + 3 == i&&minP1<maxP1) cout << "\xDB";
else if (player1x == j && player1y + 4 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (player1x == j && player1y + 5 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (obstacle1x == j && obstacle1y == i+1&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (obstacle1x == j && obstacle1y + 1 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (obstacle1x == j && obstacle1y + 2 == i&&minP1<maxP1) cout << "\xDB";
else if (obstacle1x == j && obstacle1y + 3 == i&&minP1<maxP1) cout << "\xDB";
else if (obstacle1x == j && obstacle1y + 4 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (obstacle1x == j && obstacle1y + 5 == i&&minP1<maxP1&&menu!=2&menu!=4) cout << "\xDB";
else if (player2x == j && player2y == i&&minP2<maxP2&&menu!=3&menu!=4) cout << "\xDB";
else if (player2x == j && player2y + 1 == i&&minP2<maxP2&&menu!=3&menu!=4) cout << "\xDB";
//else if (player2x == j && player2y + 2 == i&&minP2<maxP2) cout << "\xDB";
//else if (player2x == j && player2y + 3 == i&&minP2<maxP2) cout << "\xDB";
else if (player2x == j && player2y + 4 == i&&minP2<maxP2&&menu!=3&menu!=4) cout << "\xDB";
else if (player2x == j && player2y + 5 == i&&minP2<maxP2&&menu!=3&menu!=4) cout << "\xDB";
else cout << " ";
minP1++;
minP2++;
if (j == width - 1) cout << "\xDB";
}
}
cout << endl;
}
for (int i = 0; i < width + 2; i++) cout << "\xDB";
cout << endl;
cout << "Score 1: " << score1 << endl << "Score 2: " << score2 << endl << "You'll win if your score is 5" << endl << "Press 'q' to exit" << endl;
}
void validateMove(int drawType)
{
ball->Move();
int ballx = ball->getX();
int bally = ball->getY();
int player1x = player1->getX();
int player2x = player2->getX();
int player1y = player1->getY();
int player2y = player2->getY();
int min1,min2,max1,max2, minO1, minO2, maxO1, maxO2;
if(drawType==1){
min1 = 0;
min2 = 0;
max1 = 6;
max2 = 6;
minO1 = 0;
minO2 = 0;
maxO1 = 6;
maxO2 = 6;
}
if (_kbhit())
{
current = _getch();
if (current == up1) {if (player1y + min1 > 0) player1->moveUp();}
if (current == up2) {if (player2y + min2 > 0) player2->moveUp();}
if (current == down1) {if (player1y + max1 < height) player1->moveDown();}
if (current == down2) {if (player2y + max2 < height) player2->moveDown();}
if (ball->getDirection() == STOP) ball->randomDirection();
}
if (drawType == 1) //normal paddle
{
for (int i = min1; i < max1; i++) //left paddle
if (ballx == player1x + 1)
if (bally == player1y + i)
ball->changeDirection((eDir)((rand() % 3) + 4));
for (int i = min2; i < max2; i++) //right paddle
if (ballx == player2x - 1)
if (bally == player2y + i)
ball->changeDirection((eDir)((rand() % 3) + 1));
}
else if (drawType == 2) //left paddle bolong
{
for (int i = min1; i < max1; i++)
if (ballx == player1x + 1)
if (player1y + 3 != bally)
if (player1x == 1 && player1y + 2 != bally)
if (bally == player1y + i)
ball->changeDirection((eDir)((rand() % 3) + 4));
for (int i = min2; i < max2; i++) //right paddle
if (ballx == player2x - 1)
if (bally == player2y + i)
ball->changeDirection((eDir)((rand() % 3) + 1));
}
else if (drawType == 3) //right pdadle bolong
{
for (int i = min1; i < max1; i++) //left paddle
if (ballx == player1x + 1)
if (bally == player1y + i)
ball->changeDirection((eDir)((rand() % 3) + 4));
for (int i = min2; i < max2; i++)
if (ballx == player2x - 1)
if (player2y + 3 != bally)
if (player2y + 2 != bally)
if (bally == player2y + i)
ball->changeDirection((eDir)((rand() % 3) + 1));
}
else if (drawType == 4) //both paddle bolong
{
for (int i = min1; i < max1; i++)
if (ballx == player1x + 1)
if (player1y + 3 != bally)
if (player1x == 1 && player1y + 2 != bally)
if (bally == player1y + i)
ball->changeDirection((eDir)((rand() % 3) + 4));
for (int i = min2; i < max2; i++)
if (ballx == player2x - 1)
if (player2y + 3 != bally)
if (player2y + 2 != bally)
if (bally == player2y + i)
ball->changeDirection((eDir)((rand() % 3) + 1));
}
//bottom wall
if (bally == height - 1) ball->changeDirection(ball->getDirection() == DOWNRIGHT ? UPRIGHT : UPLEFT);
//top wall
if (bally == 0) ball->changeDirection(ball->getDirection() == UPRIGHT ? DOWNRIGHT : DOWNLEFT);
//right wall
if (ballx == width - 1) scoreUp(player1);
//left wall
if (ballx == 0) scoreUp(player2);
}
void run(int drawType)
{
while (!quit)
{
draw(menumain);
validateMove(menumain);
validateExit();
validateScore();
}
}
};
int main()
{
do
{
cout << "Welcome to PONG!" << endl;
cout << "================" << endl;
cout << "1. Normal" << endl;
cout << "2. Unfair Player 1" << endl;
cout << "3. Unfair Player 2" << endl;
cout << "4. Unfair Both" << endl;
cout << "5. Exit" << endl;
cout << "Select game mode: ";
cin >> menumain; cin.get();
GameManager *gameManager;
gameManager = new GameManager(100, 100);
gameManager->run(menumain);
break;
} while(isFinished == false);
return 0;
}
| 31.450704 | 150 | 0.503023 | [
"object"
] |
974cc9e439dff54ddfd0b7a48800800bd11e6c25 | 1,995 | cc | C++ | DetectorDescription/DDCMS/plugins/DDCMSDetector.cc | DBAnthony/cmssw | 6406d33feab56ab2af79b00b533f62b5368ac33e | [
"Apache-2.0"
] | null | null | null | DetectorDescription/DDCMS/plugins/DDCMSDetector.cc | DBAnthony/cmssw | 6406d33feab56ab2af79b00b533f62b5368ac33e | [
"Apache-2.0"
] | null | null | null | DetectorDescription/DDCMS/plugins/DDCMSDetector.cc | DBAnthony/cmssw | 6406d33feab56ab2af79b00b533f62b5368ac33e | [
"Apache-2.0"
] | null | null | null | #include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/ParameterSet/interface/FileInPath.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/ESTransientHandle.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h"
#include "DetectorDescription/DDCMS/interface/DDDetector.h"
#include "DetectorDescription/DDCMS/interface/DDVectorRegistryRcd.h"
#include "DetectorDescription/DDCMS/interface/DDVectorRegistry.h"
#include "DD4hep/Detector.h"
#include <memory>
#include <string>
using namespace std;
using namespace cms;
using namespace dd4hep;
class DDCMSDetector : public edm::one::EDAnalyzer<> {
public:
explicit DDCMSDetector(const edm::ParameterSet& p);
void beginJob() override {}
void analyze( edm::Event const& iEvent, edm::EventSetup const& ) override;
void endJob() override;
private:
string m_label;
};
DDCMSDetector::DDCMSDetector(const edm::ParameterSet& iConfig)
: m_label(iConfig.getUntrackedParameter<string>("fromDataLabel", ""))
{}
void
DDCMSDetector::analyze( const edm::Event&, const edm::EventSetup& iEventSetup)
{
edm::ESTransientHandle<DDDetector> det;
iEventSetup.get<DetectorDescriptionRcd>().get(m_label, det);
cout << "Iterate over the detectors:\n";
for( auto const& it : det->description->detectors()) {
dd4hep::DetElement det(it.second);
cout << it.first << ": " << det.path() << "\n";
}
cout << "..done!\n";
edm::ESTransientHandle<DDVectorRegistry> registry;
iEventSetup.get<DDVectorRegistryRcd>().get(m_label, registry);
cout << "DD Vector Registry size: " << registry->vectors.size() << "\n";
for( const auto& p: registry->vectors ) {
cout << " " << p.first << " => ";
for( const auto& i : p.second )
cout << i << ", ";
cout << '\n';
}
}
void
DDCMSDetector::endJob()
{
}
DEFINE_FWK_MODULE( DDCMSDetector );
| 29.776119 | 78 | 0.722306 | [
"vector"
] |
97532eecf383100e26d2ed68d90c3d0f3ff29f5d | 5,772 | cpp | C++ | whipstitch/wsAssets/wsAnimation.cpp | dsnettleton/whipstitch-game-engine | 1c91a2e90274f18723141ec57d0cb4930bd29b25 | [
"MIT"
] | null | null | null | whipstitch/wsAssets/wsAnimation.cpp | dsnettleton/whipstitch-game-engine | 1c91a2e90274f18723141ec57d0cb4930bd29b25 | [
"MIT"
] | null | null | null | whipstitch/wsAssets/wsAnimation.cpp | dsnettleton/whipstitch-game-engine | 1c91a2e90274f18723141ec57d0cb4930bd29b25 | [
"MIT"
] | null | null | null | /*
* wsAnimation.cpp
*
* Created on: Nov 25, 2012
* Author: dsnettleton
*
* This file defines the class wsAnimation, which extends the abstract base
* type wsAsset. A wsAnimation is only part of the more complete type,
* wsModel, though the same animation can be applied to multiple wsMesh objects.
*
* This software is provided under the terms of the MIT license
* Copyright (c) D. Scott Nettleton, 2013
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "wsAnimation.h"
#include <stdio.h>
#include "../wsGraphics.h"
wsAnimation::wsAnimation(const char* filepath) {
assetType = WS_ASSET_TYPE_ANIM;
wsEcho(WS_LOG_GRAPHICS, "Loading Animation from file \"%s\"\n", filepath);
FILE* pFile;
pFile = fopen(filepath, "r");
wsAssert( pFile, "Error Loading file." );
// Scan past the header
errorCheck( fscanf( pFile, "// Whipstitch Animation File\n// This Animation is for use with the Whipstitch Game Engine\n"
"// For more information, email dsnettleton@whipstitchgames.com\n\n") );
f32 versionNumber;
errorCheck( fscanf( pFile, "versionNumber %f\n", &versionNumber) );
errorCheck( fscanf( pFile, "animationType %u\n", &animType) );
char nameBuffer[256];
errorCheck( fscanf( pFile, "animationName %[^\t\n]\n", nameBuffer) );
errorCheck( fscanf( pFile, "framesPerSecond %f\n\n", &framesPerSecond) );
errorCheck( fscanf( pFile, "numJoints %u\n", &numJoints) );
errorCheck( fscanf( pFile, "numKeyFrames %u\n", &numKeyframes) );
errorCheck( fscanf( pFile, "bounds { %f %f %f }\n\n", &bounds.x, &bounds.y, &bounds.z) );
// Generate object arrays and place them on the current stack
joints = wsNewArray(wsAnimJoint, numJoints);
keyframes = wsNewArray(wsKeyframe, numKeyframes);
strcpy(name, nameBuffer);
errorCheck( fscanf( pFile, "joints {\n") );
u32 jointIndex = 0;
for (u32 j = 0; j < numJoints; ++j) {
errorCheck( fscanf( pFile, " joint %u {\n", &jointIndex) );
wsAssert( (jointIndex == j), "Current index does not relate to current joint.");
errorCheck( fscanf( pFile, " jointName %[^\t\n]\n", joints[j].name) );
errorCheck( fscanf( pFile, " parent %d\n", &joints[j].parent) );
errorCheck( fscanf( pFile, " pos_start { %f %f %f }\n", &joints[j].start.x, &joints[j].start.y, &joints[j].start.z) );
errorCheck( fscanf( pFile, " rotation { %f %f %f %f }\n", &joints[j].rot.x, &joints[j].rot.y, &joints[j].rot.z, &joints[j].rot.w) );
errorCheck( fscanf( pFile, " }\n") );
}// End for each joint
errorCheck( fscanf( pFile, "}\n\n") );
errorCheck( fscanf( pFile, "keyframes {\n") );
u32 frameIndex = 0;
for (u32 k = 0; k < numKeyframes; ++k) {
errorCheck( fscanf( pFile, " keyframe %u {\n", &frameIndex) );
wsAssert( (frameIndex == k), "Current index does not relate to current keyframe.");
errorCheck( fscanf( pFile, " frameNumber %f\n", &keyframes[k].frameIndex) );
// errorCheck( fscanf( pFile, " bounds {\n") );
// errorCheck( fscanf( pFile, " min { %f %f %f }\n", &keyframes[k].minX, &keyframes[k].minY, &keyframes[k].minZ) );
// errorCheck( fscanf( pFile, " max { %f %f %f }\n", &keyframes[k].maxX, &keyframes[k].maxY, &keyframes[k].maxZ) );
// errorCheck( fscanf( pFile, " }\n") );
errorCheck( fscanf( pFile, " jointsModified %u\n", &keyframes[k].numJointsModified) );
keyframes[k].mods = wsNewArray(wsJointMod, keyframes[k].numJointsModified);
for (u32 j = 0; j < keyframes[k].numJointsModified; ++j) {
errorCheck( fscanf( pFile, " joint %u {\n", &keyframes[k].mods[j].jointIndex) );
errorCheck( fscanf( pFile, " jointTranslation { %f %f %f }\n",
&keyframes[k].mods[j].location.x,
&keyframes[k].mods[j].location.y,
&keyframes[k].mods[j].location.z) );
keyframes[k].mods[j].location.w = 1.0f;
errorCheck( fscanf( pFile, " jointRotation { %f %f %f %f }\n",
&keyframes[k].mods[j].rotation.x,
&keyframes[k].mods[j].rotation.y,
&keyframes[k].mods[j].rotation.z,
&keyframes[k].mods[j].rotation.w) );
errorCheck( fscanf( pFile, " }\n") );
}// End for each joint modifier
errorCheck( fscanf( pFile, " }\n") );
}
errorCheck( fscanf( pFile, "}\n") );
if (numKeyframes) { animLength = keyframes[numKeyframes-1].frameIndex / framesPerSecond; }
if (fclose(pFile) == EOF) {
wsEcho(WS_LOG_ERROR, "Failed to close animation file \"%s\"", filepath);
}
}// End wsAnimation constructor
wsAnimation::~wsAnimation() {
// Nothing to do here.
}
void wsAnimation::errorCheck(const i32 my) {
if (my == EOF) {
wsEcho(WS_LOG_ERROR, "Error: premature end of file.");
}
}
| 49.333333 | 139 | 0.653326 | [
"object"
] |
97679c8cf47c54e69213ef50be946498531ebcfa | 7,021 | cpp | C++ | ecs/src/v2/model/SubJob.cpp | yangzhaofeng/huaweicloud-sdk-cpp-v3 | 4f3caac5ba9a9b75b4e5fd61683d1c4d57ec1c23 | [
"Apache-2.0"
] | 5 | 2021-03-03T08:23:43.000Z | 2022-02-16T02:16:39.000Z | ecs/src/v2/model/SubJob.cpp | yangzhaofeng/huaweicloud-sdk-cpp-v3 | 4f3caac5ba9a9b75b4e5fd61683d1c4d57ec1c23 | [
"Apache-2.0"
] | null | null | null | ecs/src/v2/model/SubJob.cpp | yangzhaofeng/huaweicloud-sdk-cpp-v3 | 4f3caac5ba9a9b75b4e5fd61683d1c4d57ec1c23 | [
"Apache-2.0"
] | 7 | 2021-02-26T13:53:35.000Z | 2022-03-18T02:36:43.000Z |
#include "huaweicloud/ecs/v2/model/SubJob.h"
namespace HuaweiCloud {
namespace Sdk {
namespace Ecs {
namespace V2 {
namespace Model {
SubJob::SubJob()
{
status_ = "";
statusIsSet_ = false;
entitiesIsSet_ = false;
jobId_ = "";
jobIdIsSet_ = false;
jobType_ = "";
jobTypeIsSet_ = false;
beginTime_ = "";
beginTimeIsSet_ = false;
endTime_ = "";
endTimeIsSet_ = false;
errorCode_ = "";
errorCodeIsSet_ = false;
failReason_ = "";
failReasonIsSet_ = false;
}
SubJob::~SubJob() = default;
void SubJob::validate()
{
}
web::json::value SubJob::toJson() const
{
web::json::value val = web::json::value::object();
if(statusIsSet_) {
val[utility::conversions::to_string_t("status")] = ModelBase::toJson(status_);
}
if(entitiesIsSet_) {
val[utility::conversions::to_string_t("entities")] = ModelBase::toJson(entities_);
}
if(jobIdIsSet_) {
val[utility::conversions::to_string_t("job_id")] = ModelBase::toJson(jobId_);
}
if(jobTypeIsSet_) {
val[utility::conversions::to_string_t("job_type")] = ModelBase::toJson(jobType_);
}
if(beginTimeIsSet_) {
val[utility::conversions::to_string_t("begin_time")] = ModelBase::toJson(beginTime_);
}
if(endTimeIsSet_) {
val[utility::conversions::to_string_t("end_time")] = ModelBase::toJson(endTime_);
}
if(errorCodeIsSet_) {
val[utility::conversions::to_string_t("error_code")] = ModelBase::toJson(errorCode_);
}
if(failReasonIsSet_) {
val[utility::conversions::to_string_t("fail_reason")] = ModelBase::toJson(failReason_);
}
return val;
}
bool SubJob::fromJson(const web::json::value& val)
{
bool ok = true;
if(val.has_field(utility::conversions::to_string_t("status"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("status"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setStatus(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("entities"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("entities"));
if(!fieldValue.is_null())
{
SubJobEntities refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setEntities(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("job_id"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("job_id"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setJobId(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("job_type"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("job_type"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setJobType(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("begin_time"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("begin_time"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setBeginTime(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("end_time"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("end_time"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setEndTime(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("error_code"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("error_code"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setErrorCode(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("fail_reason"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("fail_reason"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setFailReason(refVal);
}
}
return ok;
}
std::string SubJob::getStatus() const
{
return status_;
}
void SubJob::setStatus(const std::string& value)
{
status_ = value;
statusIsSet_ = true;
}
bool SubJob::statusIsSet() const
{
return statusIsSet_;
}
void SubJob::unsetstatus()
{
statusIsSet_ = false;
}
SubJobEntities SubJob::getEntities() const
{
return entities_;
}
void SubJob::setEntities(const SubJobEntities& value)
{
entities_ = value;
entitiesIsSet_ = true;
}
bool SubJob::entitiesIsSet() const
{
return entitiesIsSet_;
}
void SubJob::unsetentities()
{
entitiesIsSet_ = false;
}
std::string SubJob::getJobId() const
{
return jobId_;
}
void SubJob::setJobId(const std::string& value)
{
jobId_ = value;
jobIdIsSet_ = true;
}
bool SubJob::jobIdIsSet() const
{
return jobIdIsSet_;
}
void SubJob::unsetjobId()
{
jobIdIsSet_ = false;
}
std::string SubJob::getJobType() const
{
return jobType_;
}
void SubJob::setJobType(const std::string& value)
{
jobType_ = value;
jobTypeIsSet_ = true;
}
bool SubJob::jobTypeIsSet() const
{
return jobTypeIsSet_;
}
void SubJob::unsetjobType()
{
jobTypeIsSet_ = false;
}
std::string SubJob::getBeginTime() const
{
return beginTime_;
}
void SubJob::setBeginTime(const std::string& value)
{
beginTime_ = value;
beginTimeIsSet_ = true;
}
bool SubJob::beginTimeIsSet() const
{
return beginTimeIsSet_;
}
void SubJob::unsetbeginTime()
{
beginTimeIsSet_ = false;
}
std::string SubJob::getEndTime() const
{
return endTime_;
}
void SubJob::setEndTime(const std::string& value)
{
endTime_ = value;
endTimeIsSet_ = true;
}
bool SubJob::endTimeIsSet() const
{
return endTimeIsSet_;
}
void SubJob::unsetendTime()
{
endTimeIsSet_ = false;
}
std::string SubJob::getErrorCode() const
{
return errorCode_;
}
void SubJob::setErrorCode(const std::string& value)
{
errorCode_ = value;
errorCodeIsSet_ = true;
}
bool SubJob::errorCodeIsSet() const
{
return errorCodeIsSet_;
}
void SubJob::unseterrorCode()
{
errorCodeIsSet_ = false;
}
std::string SubJob::getFailReason() const
{
return failReason_;
}
void SubJob::setFailReason(const std::string& value)
{
failReason_ = value;
failReasonIsSet_ = true;
}
bool SubJob::failReasonIsSet() const
{
return failReasonIsSet_;
}
void SubJob::unsetfailReason()
{
failReasonIsSet_ = false;
}
}
}
}
}
}
| 21.53681 | 102 | 0.630822 | [
"object",
"model"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.