hexsha stringlengths 40 40 | size int64 22 2.4M | ext stringclasses 5
values | lang stringclasses 1
value | max_stars_repo_path stringlengths 3 260 | max_stars_repo_name stringlengths 5 109 | max_stars_repo_head_hexsha stringlengths 40 78 | 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 260 | max_issues_repo_name stringlengths 5 109 | 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 260 | max_forks_repo_name stringlengths 5 109 | 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 22 2.4M | avg_line_length float64 5 169k | max_line_length int64 5 786k | alphanum_fraction float64 0.06 0.95 | matches listlengths 1 11 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cd3dd72024c615e6c9231e4ad72177ee557146ea | 412 | h | C | p3_3.h | TianYe2017/Run_Length_Encoder | 182025689a8850a62b8409a2bc2f3a5b54d89a01 | [
"MIT"
] | 1 | 2021-05-28T06:59:09.000Z | 2021-05-28T06:59:09.000Z | p3_3.h | LaTristan/Run_Length_Encoder | 182025689a8850a62b8409a2bc2f3a5b54d89a01 | [
"MIT"
] | null | null | null | p3_3.h | LaTristan/Run_Length_Encoder | 182025689a8850a62b8409a2bc2f3a5b54d89a01 | [
"MIT"
] | 1 | 2021-03-15T06:48:40.000Z | 2021-03-15T06:48:40.000Z | #pragma once
#ifndef P3_3_H
#define P3_3_H
#include "stdafx.h"
#include "io.h"
#include "data_pair.h"
#include "run_length_encode.h"
#include "bwt.h"
#include "shannon.h"
#include <vector>
#include <string>
#include <iostream>
#include <fstream>
using namespace std;
void HW1_Problem_three_part_three(void);
void Find_Optimal_length();
void Find_theoretical_bound();
void Find_how_many_symbols();
#endif | 17.166667 | 40 | 0.759709 | [
"vector"
] |
cd4b88ca7004c55bcb9e9eac05e46eba9d9bd2d9 | 973 | h | C | include/polyscope/point_cloud_scalar_quantity.h | hydrocarborane/polyscope | bee34c22cd7ac1b1e01686b55b7b8ceeee20d2fe | [
"MIT"
] | 930 | 2018-02-19T16:38:29.000Z | 2022-03-30T22:16:01.000Z | include/polyscope/point_cloud_scalar_quantity.h | hydrocarborane/polyscope | bee34c22cd7ac1b1e01686b55b7b8ceeee20d2fe | [
"MIT"
] | 142 | 2018-02-19T16:14:28.000Z | 2022-03-25T13:51:08.000Z | include/polyscope/point_cloud_scalar_quantity.h | hydrocarborane/polyscope | bee34c22cd7ac1b1e01686b55b7b8ceeee20d2fe | [
"MIT"
] | 92 | 2018-05-13T01:41:04.000Z | 2022-03-28T03:26:44.000Z | // Copyright 2017-2019, Nicholas Sharp and the Polyscope contributors. http://polyscope.run.
#pragma once
#include "polyscope/affine_remapper.h"
#include "polyscope/histogram.h"
#include "polyscope/point_cloud.h"
#include "polyscope/render/color_maps.h"
#include "polyscope/scalar_quantity.h"
#include <vector>
namespace polyscope {
class PointCloudScalarQuantity : public PointCloudQuantity, public ScalarQuantity<PointCloudScalarQuantity> {
public:
PointCloudScalarQuantity(std::string name, const std::vector<double>& values, PointCloud& pointCloud_,
DataType dataType);
virtual void draw() override;
virtual void buildCustomUI() override;
virtual void buildPickUI(size_t ind) override;
virtual void refresh() override;
virtual std::string niceName() override;
protected:
// === Visualization parameters
void createPointProgram();
std::shared_ptr<render::ShaderProgram> pointProgram;
};
} // namespace polyscope
| 25.605263 | 109 | 0.756423 | [
"render",
"vector"
] |
cd4c1222a1bcd387298976f7f0f11c9cf8a5d8a1 | 7,102 | c | C | cbits/qubes_backend.c | DemiMarie/qubes-wayland | aae3723a585c79ac9eb86b4ed55c07fbbda9a447 | [
"MIT"
] | 2 | 2022-02-09T23:42:15.000Z | 2022-03-21T13:31:48.000Z | cbits/qubes_backend.c | DemiMarie/qubes-wayland | aae3723a585c79ac9eb86b4ed55c07fbbda9a447 | [
"MIT"
] | null | null | null | cbits/qubes_backend.c | DemiMarie/qubes-wayland | aae3723a585c79ac9eb86b4ed55c07fbbda9a447 | [
"MIT"
] | 1 | 2022-03-01T15:23:53.000Z | 2022-03-01T15:23:53.000Z | // wlr_backend implementation
#include "common.h"
#include "qubes_backend.h"
#include <stdlib.h>
#include <wlr/backend.h>
#include <wlr/backend/interface.h>
#include <wlr/interfaces/wlr_input_device.h>
#include <wlr/interfaces/wlr_keyboard.h>
#include <wlr/interfaces/wlr_output.h>
#include <wlr/interfaces/wlr_pointer.h>
#include <wlr/types/wlr_buffer.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_pointer.h>
#include <wlr/types/wlr_seat.h>
#include <wlr/util/log.h>
#include <vchan-xen/libvchan.h>
#include <qubes-gui-protocol.h>
#include "qubes_output.h"
static const struct wlr_backend_impl qubes_backend_impl;
static uint32_t
qubes_backend_get_buffer_caps(struct wlr_backend *backend __attribute__((unused))) {
return WLR_BUFFER_CAP_DATA_PTR;
}
static void qubes_backend_destroy(struct qubes_backend *backend);
static void qubes_backend_handle_wlr_destroy(struct wlr_backend *raw_backend) {
assert(raw_backend->impl == &qubes_backend_impl);
struct qubes_backend *backend = wl_container_of(raw_backend, backend, backend);
wl_list_remove(&backend->display_destroy.link);
qubes_backend_destroy(backend);
}
static void qubes_backend_handle_display_destroy(struct wl_listener *listener, void *data __attribute__((unused))) {
struct qubes_backend *backend = wl_container_of(listener, backend, display_destroy);
qubes_backend_destroy(backend);
}
static bool qubes_backend_start(struct wlr_backend *raw_backend);
extern void qubes_rust_backend_free(void *ptr);
extern void *qubes_rust_backend_create(uint16_t domid);
typedef void (*qubes_parse_event_callback)(void *raw_view, void *raw_backend, uint32_t timestamp, struct msg_hdr hdr, const uint8_t *ptr);
static const struct wlr_backend_impl qubes_backend_impl = {
.start = qubes_backend_start,
.destroy = qubes_backend_handle_wlr_destroy,
.get_session = NULL,
.get_presentation_clock = NULL,
.get_drm_fd = NULL,
.get_buffer_caps = qubes_backend_get_buffer_caps,
};
static bool qubes_backend_start(struct wlr_backend *raw_backend) {
assert(raw_backend->impl == &qubes_backend_impl);
struct qubes_backend *backend = wl_container_of(raw_backend, backend, backend);
int fd = qubes_rust_backend_fd(backend->rust_backend);
struct wl_event_loop *loop = wl_display_get_event_loop(backend->display);
struct wl_event_source *source = wl_event_loop_add_fd(loop, fd,
WL_EVENT_READABLE | WL_EVENT_HANGUP | WL_EVENT_ERROR,
qubes_backend_on_fd,
backend);
if (!source) {
wlr_log(WLR_ERROR, "Cannot insert event source");
return false;
}
backend->source = source;
wl_signal_emit(&raw_backend->events.new_output, backend->output);
wl_signal_emit(&raw_backend->events.new_input, backend->keyboard_input);
wl_signal_emit(&raw_backend->events.new_input, backend->pointer_input);
wlr_log(WLR_DEBUG, "Qubes backend started successfully");
return true;
}
int qubes_backend_on_fd(int fd __attribute__((unused)), uint32_t mask, void *data) {
struct qubes_backend *backend = data;
assert(!(mask & WL_EVENT_WRITABLE));
qubes_rust_backend_on_fd_ready(
backend->rust_backend, mask & WL_EVENT_READABLE, qubes_parse_event, backend);
return 0;
}
static void
qubes_backend_destroy(struct qubes_backend *backend) {
// MUST come before freeing the Rust backend, as that closes the file descriptor.
if (backend->source)
wl_event_source_remove(backend->source);
qubes_rust_backend_free(backend->rust_backend);
wlr_output_destroy(backend->output);
wlr_input_device_destroy(backend->keyboard_input);
wlr_input_device_destroy(backend->pointer_input);
wl_list_remove(&backend->display_destroy.link);
free(backend);
}
static const struct wlr_keyboard_impl qubes_keyboard_impl = {
.destroy = NULL,
.led_update = NULL,
};
static const struct wlr_pointer_impl qubes_pointer_impl = {
.destroy = NULL,
};
static const struct wlr_input_device_impl qubes_input_device_impl = {
.destroy = NULL,
};
static bool qubes_backend_output_commit(struct wlr_output *unused __attribute__((unused))) {
assert(1 && "BUG: qubes_backend_output_commit should never be called!");
return true;
}
static const struct wlr_output_impl qubes_backend_output_impl = {
.set_cursor = NULL,
.move_cursor = NULL,
.destroy = NULL,
.test = NULL,
.commit = qubes_backend_output_commit,
.get_gamma_size = NULL,
.get_cursor_formats = NULL,
.get_cursor_size = NULL,
};
struct qubes_backend *
qubes_backend_create(struct wl_display *display, uint16_t domid, struct wl_list *views) {
struct qubes_backend *backend = calloc(sizeof(*backend), 1);
struct wlr_keyboard *keyboard = calloc(sizeof(*keyboard), 1);
struct wlr_output *output = calloc(sizeof(*output), 1);
struct wlr_pointer *pointer = calloc(sizeof(*pointer), 1);
struct wlr_input_device *keyboard_input = calloc(sizeof(*keyboard_input), 1);
struct wlr_input_device *pointer_input = calloc(sizeof(*pointer_input), 1);
if (backend == NULL || keyboard == NULL || output == NULL ||
pointer == NULL || keyboard_input == NULL || pointer_input == NULL)
goto fail;
if (!(backend->rust_backend = qubes_rust_backend_create(domid))) {
wlr_log(WLR_ERROR, "Cannot create Rust backend for domain %" PRIu16, domid);
goto fail;
}
backend->mode.width = 1920;
backend->mode.height = 1080;
backend->mode.refresh = 60000;
backend->mode.preferred = true;
wl_list_init(&backend->mode.link);
backend->views = views;
backend->output = output;
backend->display = display;
backend->keyboard_input = keyboard_input;
backend->pointer_input = pointer_input;
wlr_backend_init(&backend->backend, &qubes_backend_impl);
strncpy(output->make, "Qubes OS Virtual Output", sizeof output->make - 1);
strncpy(output->model, "GUI Agent", sizeof output->model - 1);
strncpy(output->serial, "1.0", sizeof output->model - 1);
output->phys_width = 344, output->phys_height = 194;
wlr_output_init(output, &backend->backend, &qubes_backend_output_impl, display);
wlr_output_set_description(output, "Qubes OS Virtual Output Device");
assert(wl_list_empty(&output->modes));
wlr_output_set_mode(output, &backend->mode);
wlr_output_enable(output, true);
wl_list_insert(&output->modes, &backend->mode.link);
assert(wlr_output_commit(output));
output->current_mode = &backend->mode;
assert(!wl_list_empty(&output->modes));
assert(output->current_mode);
wlr_keyboard_init(keyboard, &qubes_keyboard_impl);
wlr_keyboard_set_repeat_info(keyboard, 0, 0);
wlr_pointer_init(pointer, &qubes_pointer_impl);
wlr_input_device_init(keyboard_input, WLR_INPUT_DEVICE_KEYBOARD, &qubes_input_device_impl,
"Qubes OS Virtual Keyboard", 0, 0);
keyboard_input->keyboard = keyboard;
pointer_input->pointer = pointer;
wlr_input_device_init(pointer_input, WLR_INPUT_DEVICE_POINTER, &qubes_input_device_impl,
"Qubes OS Virtual Pointer", 0, 0);
backend->display_destroy.notify = qubes_backend_handle_display_destroy;
wl_display_add_destroy_listener(display, &backend->display_destroy);
return backend;
fail:
free(backend);
free(keyboard);
free(output);
free(pointer);
free(keyboard_input);
free(pointer_input);
return NULL;
}
// vim: set noet ts=3 sts=3 sw=3 ft=c fenc=UTF-8:
| 36.420513 | 138 | 0.778936 | [
"model"
] |
cd5089531c79989e2110067ec0532c70343a54a2 | 965 | h | C | src/CwRequestData.h | asanoic/catwalk | 8ce002278c03915a98477a111737f70c6a5e519d | [
"OLDAP-2.3"
] | 1 | 2020-11-13T20:24:12.000Z | 2020-11-13T20:24:12.000Z | src/CwRequestData.h | asanoic/catwalk | 8ce002278c03915a98477a111737f70c6a5e519d | [
"OLDAP-2.3"
] | null | null | null | src/CwRequestData.h | asanoic/catwalk | 8ce002278c03915a98477a111737f70c6a5e519d | [
"OLDAP-2.3"
] | null | null | null | #ifndef CWREQUESTDATA_H
#define CWREQUESTDATA_H
#include <optional>
#include <unordered_map>
using namespace std;
#include "CwCatwalk.h"
#include "CwObjectData.h"
#include "CwRouterData.h"
#include "engine/boost-headers.h"
class CwRequest;
struct CwRequestData : CwObjectData {
optional<bx_request_parser> beastRequestParser;
pair<CwBody, bool> bodyResult;
pair<vector<string_view>, bool> headersResult;
unordered_map<string_view, any> extraData;
unordered_map<string_view, string_view> param;
unordered_map<string_view, vector<string_view>> query;
void prepareData();
string_view target;
string_view path;
vector<string_view> preparedPath;
vector<string_view>::const_iterator pathPos;
vector<string_view>::const_iterator tokenMatchedUtil(const vector<string_view>& tokens);
vector<string_view> addMatchedParams(const vector<string_view>& tokens);
};
#endif // CWREQUESTDATA_H
| 30.15625 | 93 | 0.745078 | [
"vector"
] |
cd5e1f6e5cb3babbf575ded45de2ecb8904d6506 | 1,889 | h | C | CENG477/HW3/Source/parser.h | rabiavarol/METU-CENG | 87b6105135a514eca0b0a087dec066b531f1d9e2 | [
"MIT"
] | null | null | null | CENG477/HW3/Source/parser.h | rabiavarol/METU-CENG | 87b6105135a514eca0b0a087dec066b531f1d9e2 | [
"MIT"
] | null | null | null | CENG477/HW3/Source/parser.h | rabiavarol/METU-CENG | 87b6105135a514eca0b0a087dec066b531f1d9e2 | [
"MIT"
] | null | null | null | #ifndef __HW1__PARSER__
#define __HW1__PARSER__
#include <string>
#include <vector>
#include <math.h>
namespace parser
{
//Notice that all the structures are as simple as possible
//so that you are not enforced to adopt any style or design.
struct Vec3f
{
float x, y, z;
};
struct Vec3i
{
int x, y, z;
};
struct Vec4f
{
float x, y, z, w;
};
struct Camera
{
Vec3f position;
Vec3f gaze;
Vec3f up;
Vec4f near_plane;
float near_distance;
float far_distance;
int image_width, image_height;
};
struct PointLight
{
Vec3f position;
Vec3f intensity;
bool status;
};
struct Material
{
Vec3f ambient;
Vec3f diffuse;
Vec3f specular;
float phong_exponent;
};
struct Transformation
{
std::string transformation_type;
int id;
};
struct Face
{
int v0_id;
int v1_id;
int v2_id;
Vec3f normal;
};
struct Mesh
{
int material_id;
std::vector<Face> faces;
std::vector<Transformation> transformations;
std::string mesh_type;
};
struct Scene
{
//Data
Vec3i background_color;
int culling_enabled;
int culling_face;
Camera camera;
Vec3f ambient_light;
std::vector<PointLight> point_lights;
std::vector<Material> materials;
std::vector<Vec3f> vertex_data;
std::vector<Vec3f> translations;
std::vector<Vec3f> scalings;
std::vector<Vec4f> rotations;
std::vector<Mesh> meshes;
//Functions
void loadFromXml(const std::string& filepath);
};
}
#endif | 19.677083 | 65 | 0.530439 | [
"mesh",
"vector"
] |
cd6a17f34b13455d70eddd0355bb2c0619e3d600 | 10,292 | c | C | gcc-gcc-7_3_0-release/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/vrecpe.c | best08618/asylo | 5a520a9f5c461ede0f32acc284017b737a43898c | [
"Apache-2.0"
] | 7 | 2020-05-02T17:34:05.000Z | 2021-10-17T10:15:18.000Z | gcc-gcc-7_3_0-release/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/vrecpe.c | best08618/asylo | 5a520a9f5c461ede0f32acc284017b737a43898c | [
"Apache-2.0"
] | null | null | null | gcc-gcc-7_3_0-release/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/vrecpe.c | best08618/asylo | 5a520a9f5c461ede0f32acc284017b737a43898c | [
"Apache-2.0"
] | 2 | 2020-07-27T00:22:36.000Z | 2021-04-01T09:41:02.000Z | #include <arm_neon.h>
#include "arm-neon-ref.h"
#include "compute-ref-data.h"
#include <math.h>
/* Expected results with positive input. */
VECT_VAR_DECL(expected_positive,uint,32,2) [] = { 0xffffffff, 0xffffffff };
VECT_VAR_DECL(expected_positive,uint,32,4) [] = { 0xbf000000, 0xbf000000,
0xbf000000, 0xbf000000 };
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
VECT_VAR_DECL(expected_positive, hfloat, 16, 4) [] = { 0x3834, 0x3834,
0x3834, 0x3834 };
VECT_VAR_DECL(expected_positive, hfloat, 16, 8) [] = { 0x2018, 0x2018,
0x2018, 0x2018,
0x2018, 0x2018,
0x2018, 0x2018 };
#endif
VECT_VAR_DECL(expected_positive,hfloat,32,2) [] = { 0x3f068000, 0x3f068000 };
VECT_VAR_DECL(expected_positive,hfloat,32,4) [] = { 0x3c030000, 0x3c030000,
0x3c030000, 0x3c030000 };
/* Expected results with negative input. */
VECT_VAR_DECL(expected_negative,uint,32,2) [] = { 0x80000000, 0x80000000 };
VECT_VAR_DECL(expected_negative,uint,32,4) [] = { 0xee800000, 0xee800000,
0xee800000, 0xee800000 };
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
VECT_VAR_DECL(expected_negative, hfloat, 16, 4) [] = { 0xae64, 0xae64,
0xae64, 0xae64 };
VECT_VAR_DECL(expected_negative, hfloat, 16, 8) [] = { 0xa018, 0xa018,
0xa018, 0xa018,
0xa018, 0xa018,
0xa018, 0xa018 };
#endif
VECT_VAR_DECL(expected_negative,hfloat,32,2) [] = { 0xbdcc8000, 0xbdcc8000 };
VECT_VAR_DECL(expected_negative,hfloat,32,4) [] = { 0xbc030000, 0xbc030000,
0xbc030000, 0xbc030000 };
/* Expected results with FP special values (NaN, infinity). */
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
VECT_VAR_DECL(expected_fp1, hfloat, 16, 4) [] = { 0x7e00, 0x7e00,
0x7e00, 0x7e00 };
VECT_VAR_DECL(expected_fp1, hfloat, 16, 8) [] = { 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0 };
#endif
VECT_VAR_DECL(expected_fp1,hfloat,32,2) [] = { 0x7fc00000, 0x7fc00000 };
VECT_VAR_DECL(expected_fp1,hfloat,32,4) [] = { 0x0, 0x0, 0x0, 0x0 };
/* Expected results with FP special values (zero, large value). */
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
VECT_VAR_DECL(expected_fp2, hfloat, 16, 4) [] = { 0x7c00, 0x7c00,
0x7c00, 0x7c00 };
VECT_VAR_DECL(expected_fp2, hfloat, 16, 8) [] = { 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0 };
#endif
VECT_VAR_DECL(expected_fp2,hfloat,32,2) [] = { 0x7f800000, 0x7f800000 };
VECT_VAR_DECL(expected_fp2,hfloat,32,4) [] = { 0x0, 0x0, 0x0, 0x0 };
/* Expected results with FP special values (-0, -infinity). */
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
VECT_VAR_DECL(expected_fp3, hfloat, 16, 4) [] = { 0xfc00, 0xfc00,
0xfc00, 0xfc00};
VECT_VAR_DECL(expected_fp3, hfloat, 16, 8) [] = { 0x8000, 0x8000,
0x8000, 0x8000,
0x8000, 0x8000,
0x8000, 0x8000 };
#endif
VECT_VAR_DECL(expected_fp3,hfloat,32,2) [] = { 0xff800000, 0xff800000 };
VECT_VAR_DECL(expected_fp3,hfloat,32,4) [] = { 0x80000000, 0x80000000,
0x80000000, 0x80000000 };
/* Expected results with FP special large negative value. */
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
VECT_VAR_DECL(expected_fp4, hfloat, 16, 4) [] = { 0x8000, 0x8000,
0x8000, 0x8000 };
#endif
VECT_VAR_DECL(expected_fp4,hfloat,32,2) [] = { 0x80000000, 0x80000000 };
#define TEST_MSG "VRECPE/VRECPEQ"
void exec_vrecpe(void)
{
int i;
/* Basic test: y=vrecpe(x), then store the result. */
#define TEST_VRECPE(Q, T1, T2, W, N) \
VECT_VAR(vector_res, T1, W, N) = \
vrecpe##Q##_##T2##W(VECT_VAR(vector, T1, W, N)); \
vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), \
VECT_VAR(vector_res, T1, W, N))
/* No need for 64 bits variants. */
DECL_VARIABLE(vector, uint, 32, 2);
DECL_VARIABLE(vector, uint, 32, 4);
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
DECL_VARIABLE(vector, float, 16, 4);
DECL_VARIABLE(vector, float, 16, 8);
#endif
DECL_VARIABLE(vector, float, 32, 2);
DECL_VARIABLE(vector, float, 32, 4);
DECL_VARIABLE(vector_res, uint, 32, 2);
DECL_VARIABLE(vector_res, uint, 32, 4);
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
DECL_VARIABLE(vector_res, float, 16, 4);
DECL_VARIABLE(vector_res, float, 16, 8);
#endif
DECL_VARIABLE(vector_res, float, 32, 2);
DECL_VARIABLE(vector_res, float, 32, 4);
clean_results ();
/* Choose init value arbitrarily, positive. */
VDUP(vector, , uint, u, 32, 2, 0x12345678);
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
VDUP(vector, , float, f, 16, 4, 1.9f);
#endif
VDUP(vector, , float, f, 32, 2, 1.9f);
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
VDUP(vector, q, float, f, 16, 8, 125.0f);
#endif
VDUP(vector, q, uint, u, 32, 4, 0xABCDEF10);
VDUP(vector, q, float, f, 32, 4, 125.0f);
/* Apply the operator. */
TEST_VRECPE(, uint, u, 32, 2);
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
TEST_VRECPE(, float, f, 16, 4);
#endif
TEST_VRECPE(, float, f, 32, 2);
TEST_VRECPE(q, uint, u, 32, 4);
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
TEST_VRECPE(q, float, f, 16, 8);
#endif
TEST_VRECPE(q, float, f, 32, 4);
#define CMT " (positive input)"
CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected_positive, CMT);
CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_positive, CMT);
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
CHECK_FP(TEST_MSG, float, 16, 4, PRIx16, expected_positive, CMT);
CHECK_FP(TEST_MSG, float, 16, 8, PRIx16, expected_positive, CMT);
#endif
CHECK_FP(TEST_MSG, float, 32, 2, PRIx32, expected_positive, CMT);
CHECK_FP(TEST_MSG, float, 32, 4, PRIx32, expected_positive, CMT);
/* Choose init value arbitrarily,negative. */
VDUP(vector, , uint, u, 32, 2, 0xFFFFFFFF);
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
VDUP(vector, , float, f, 16, 4, -10.0f);
#endif
VDUP(vector, , float, f, 32, 2, -10.0f);
VDUP(vector, q, uint, u, 32, 4, 0x89081234);
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
VDUP(vector, q, float, f, 16, 8, -125.0f);
#endif
VDUP(vector, q, float, f, 32, 4, -125.0f);
/* Apply the operator. */
TEST_VRECPE(, uint, u, 32, 2);
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
TEST_VRECPE(, float, f, 16, 4);
#endif
TEST_VRECPE(, float, f, 32, 2);
TEST_VRECPE(q, uint, u, 32, 4);
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
TEST_VRECPE(q, float, f, 16, 8);
#endif
TEST_VRECPE(q, float, f, 32, 4);
#undef CMT
#define CMT " (negative input)"
CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected_negative, CMT);
CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_negative, CMT);
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
CHECK_FP(TEST_MSG, float, 16, 4, PRIx16, expected_negative, CMT);
CHECK_FP(TEST_MSG, float, 16, 8, PRIx16, expected_negative, CMT);
#endif
CHECK_FP(TEST_MSG, float, 32, 2, PRIx32, expected_negative, CMT);
CHECK_FP(TEST_MSG, float, 32, 4, PRIx32, expected_negative, CMT);
/* Test FP variants with special input values (NaN, infinity). */
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
VDUP(vector, , float, f, 16, 4, NAN);
VDUP(vector, q, float, f, 16, 8, HUGE_VALF);
#endif
VDUP(vector, , float, f, 32, 2, NAN);
VDUP(vector, q, float, f, 32, 4, HUGE_VALF);
/* Apply the operator. */
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
TEST_VRECPE(, float, f, 16, 4);
TEST_VRECPE(q, float, f, 16, 8);
#endif
TEST_VRECPE(, float, f, 32, 2);
TEST_VRECPE(q, float, f, 32, 4);
#undef CMT
#define CMT " FP special (NaN, infinity)"
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
CHECK_FP(TEST_MSG, float, 16, 4, PRIx16, expected_fp1, CMT);
CHECK_FP(TEST_MSG, float, 16, 8, PRIx16, expected_fp1, CMT);
#endif
CHECK_FP(TEST_MSG, float, 32, 2, PRIx32, expected_fp1, CMT);
CHECK_FP(TEST_MSG, float, 32, 4, PRIx32, expected_fp1, CMT);
/* Test FP variants with special input values (zero, large value). */
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
VDUP(vector, , float, f, 16, 4, 0.0f);
VDUP(vector, q, float, f, 16, 8, 8.97229e37f /*9.0e37f*/);
#endif
VDUP(vector, , float, f, 32, 2, 0.0f);
VDUP(vector, q, float, f, 32, 4, 8.97229e37f /*9.0e37f*/);
/* Apply the operator. */
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
TEST_VRECPE(, float, f, 16, 4);
TEST_VRECPE(q, float, f, 16, 8);
#endif
TEST_VRECPE(, float, f, 32, 2);
TEST_VRECPE(q, float, f, 32, 4);
#undef CMT
#define CMT " FP special (zero, large value)"
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
CHECK_FP(TEST_MSG, float, 16, 4, PRIx16, expected_fp2, CMT);
CHECK_FP(TEST_MSG, float, 16, 8, PRIx16, expected_fp2, CMT);
#endif
CHECK_FP(TEST_MSG, float, 32, 2, PRIx32, expected_fp2, CMT);
CHECK_FP(TEST_MSG, float, 32, 4, PRIx32, expected_fp2, CMT);
/* Test FP variants with special input values (-0, -infinity). */
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
VDUP(vector, , float, f, 16, 4, -0.0f);
VDUP(vector, q, float, f, 16, 8, -HUGE_VALF);
#endif
VDUP(vector, , float, f, 32, 2, -0.0f);
VDUP(vector, q, float, f, 32, 4, -HUGE_VALF);
/* Apply the operator. */
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
TEST_VRECPE(, float, f, 16, 4);
TEST_VRECPE(q, float, f, 16, 8);
#endif
TEST_VRECPE(, float, f, 32, 2);
TEST_VRECPE(q, float, f, 32, 4);
#undef CMT
#define CMT " FP special (-0, -infinity)"
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
CHECK_FP(TEST_MSG, float, 16, 4, PRIx16, expected_fp3, CMT);
CHECK_FP(TEST_MSG, float, 16, 8, PRIx16, expected_fp3, CMT);
#endif
CHECK_FP(TEST_MSG, float, 32, 2, PRIx32, expected_fp3, CMT);
CHECK_FP(TEST_MSG, float, 32, 4, PRIx32, expected_fp3, CMT);
/* Test FP variants with special input values (large negative value). */
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
VDUP(vector, , float, f, 16, 4, -9.0e37f);
#endif
VDUP(vector, , float, f, 32, 2, -9.0e37f);
/* Apply the operator. */
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
TEST_VRECPE(, float, f, 16, 4);
#endif
TEST_VRECPE(, float, f, 32, 2);
#undef CMT
#define CMT " FP special (large negative value)"
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
CHECK_FP(TEST_MSG, float, 16, 4, PRIx16, expected_fp4, CMT);
#endif
CHECK_FP(TEST_MSG, float, 32, 2, PRIx32, expected_fp4, CMT);
}
int main (void)
{
exec_vrecpe ();
return 0;
}
| 36.757143 | 77 | 0.687136 | [
"vector"
] |
28ae5ab9998daf6406e00e9cf7833c034ca34436 | 2,120 | h | C | ESAT_EDK3/include/EDK3/material.h | ESAT-jimenezur/Minecraft-C- | bf301a9bf09bf70c14eaad4bda3f96a5104b9136 | [
"MIT"
] | null | null | null | ESAT_EDK3/include/EDK3/material.h | ESAT-jimenezur/Minecraft-C- | bf301a9bf09bf70c14eaad4bda3f96a5104b9136 | [
"MIT"
] | null | null | null | ESAT_EDK3/include/EDK3/material.h | ESAT-jimenezur/Minecraft-C- | bf301a9bf09bf70c14eaad4bda3f96a5104b9136 | [
"MIT"
] | null | null | null | #ifndef INCLUDE_EDK3_MATERIAL_H_
#define INCLUDE_EDK3_MATERIAL_H_ 1
// ----------------------------------------------------------------------------
// Copyright (C) 2015 Jose L. Hidalgo
// Material Class.
// ----------------------------------------------------------------------------
#include "referenced.h"
#include "constants.h"
namespace EDK3 {
class MaterialSettings;
class Drawable;
class Material : public virtual Referenced {
public:
// Returns true if the material can be set with the given material
// settings
virtual bool enable(const MaterialSettings *) const = 0;
// called after enable to setup the camera matrix
virtual void setupCamera(const float projecton[16], const float view[16]) const = 0;
// called after enable to setup the model matrix
// model is the transform from local->world coordinates
virtual void setupModel(const float model[16]) const = 0;
virtual unsigned int num_attributes_required() const = 0;
virtual Attribute attribute_at_index(
const unsigned int attrib_idx) const = 0;
virtual Type attribute_type_at_index(
const unsigned int attrib_index) const = 0;
// draw a FullScreen Quad with the given material/material-settings
void drawFullScreenQuad(const MaterialSettings *ms) const;
// draws a portion of the screen with the given material/material-settings
// min_x, min_y, max_x, max-y are relative to current FB/Window, in the range
// from 0.0 to 1.0 each.
void drawRelativeToScreenQuad(
float min_x,
float min_y,
float max_x,
float max_y,
const MaterialSettings *mat) const;
// draws a portion of the screen with the given material/material-settings
// position is given in pixels
void drawScreenQuad(
float min_x,
float min_y,
float max_x,
float max_y,
const MaterialSettings *mat) const;
protected:
Material() {}
virtual ~Material() {}
private:
Material(const Material&);
Material& operator=(const Material &);
};
} /* end of EDK Namespace */
#endif
| 31.641791 | 88 | 0.638208 | [
"model",
"transform"
] |
28b60e3072b9a5f9f482a6d07cf8672f2a0c4941 | 7,010 | h | C | vpr/src/route/router_lookahead_map_utils.h | litghost/vtr-verilog-to-routing | 8980e46218542888fac879961b13aa7b0fba8432 | [
"MIT"
] | 1 | 2020-04-11T07:01:18.000Z | 2020-04-11T07:01:18.000Z | vpr/src/route/router_lookahead_map_utils.h | litghost/vtr-verilog-to-routing | 8980e46218542888fac879961b13aa7b0fba8432 | [
"MIT"
] | null | null | null | vpr/src/route/router_lookahead_map_utils.h | litghost/vtr-verilog-to-routing | 8980e46218542888fac879961b13aa7b0fba8432 | [
"MIT"
] | null | null | null | #ifndef ROUTER_LOOKAHEAD_MAP_UTILS_H_
#define ROUTER_LOOKAHEAD_MAP_UTILS_H_
/*
* The router lookahead provides an estimate of the cost from an intermediate node to the target node
* during directed (A*-like) routing.
*
* The VPR 7.0 lookahead (route/route_timing.c ==> get_timing_driven_expected_cost) lower-bounds the remaining delay and
* congestion by assuming that a minimum number of wires, of the same type as the current node being expanded, can be used
* to complete the route. While this method is efficient, it can run into trouble with architectures that use
* multiple interconnected wire types.
*
* The lookahead in this file pre-computes delay/congestion costs up and to the right of a starting tile. This generates
* delay/congestion tables for {CHANX, CHANY} channel types, over all wire types defined in the architecture file.
* See Section 3.2.4 in Oleg Petelin's MASc thesis (2016) for more discussion.
*
*/
#include <cmath>
#include <limits>
#include <vector>
#include <queue>
#include <unordered_map>
#include "vpr_types.h"
#include "rr_node.h"
namespace util {
/* when a list of delay/congestion entries at a coordinate in Cost_Entry is boiled down to a single
* representative entry, this enum is passed-in to specify how that representative entry should be
* calculated */
enum e_representative_entry_method {
FIRST = 0, //the first cost that was recorded
SMALLEST, //the smallest-delay cost recorded
AVERAGE,
GEOMEAN,
MEDIAN
};
/* f_cost_map is an array of these cost entries that specifies delay/congestion estimates
* to travel relative x/y distances */
class Cost_Entry {
public:
float delay;
float congestion;
bool fill;
Cost_Entry() {
delay = std::numeric_limits<float>::infinity();
congestion = std::numeric_limits<float>::infinity();
fill = false;
}
Cost_Entry(float set_delay, float set_congestion)
: delay(set_delay)
, congestion(set_congestion)
, fill(false) {}
Cost_Entry(float set_delay, float set_congestion, bool set_fill)
: delay(set_delay)
, congestion(set_congestion)
, fill(set_fill) {}
bool valid() const {
return std::isfinite(delay) && std::isfinite(congestion);
}
};
/* a class that stores delay/congestion information for a given relative coordinate during the Dijkstra expansion.
* since it stores multiple cost entries, it is later boiled down to a single representative cost entry to be stored
* in the final lookahead cost map */
class Expansion_Cost_Entry {
private:
std::vector<Cost_Entry> cost_vector;
Cost_Entry get_smallest_entry() const;
Cost_Entry get_average_entry() const;
Cost_Entry get_geomean_entry() const;
Cost_Entry get_median_entry() const;
public:
void add_cost_entry(e_representative_entry_method method,
float add_delay,
float add_congestion) {
Cost_Entry cost_entry(add_delay, add_congestion);
if (method == SMALLEST) {
/* taking the smallest-delay entry anyway, so no need to push back multple entries */
if (this->cost_vector.empty()) {
this->cost_vector.push_back(cost_entry);
} else {
if (add_delay < this->cost_vector[0].delay) {
this->cost_vector[0] = cost_entry;
}
}
} else {
this->cost_vector.push_back(cost_entry);
}
}
void clear_cost_entries() {
this->cost_vector.clear();
}
Cost_Entry get_representative_cost_entry(e_representative_entry_method method) const {
Cost_Entry entry;
if (!cost_vector.empty()) {
switch (method) {
case FIRST:
entry = cost_vector[0];
break;
case SMALLEST:
entry = this->get_smallest_entry();
break;
case AVERAGE:
entry = this->get_average_entry();
break;
case GEOMEAN:
entry = this->get_geomean_entry();
break;
case MEDIAN:
entry = this->get_median_entry();
break;
default:
break;
}
}
return entry;
}
};
/* a class that represents an entry in the Dijkstra expansion priority queue */
class PQ_Entry {
public:
int rr_node_ind; //index in device_ctx.rr_nodes that this entry represents
float cost; //the cost of the path to get to this node
/* store backward delay, R and congestion info */
float delay;
float R_upstream;
float congestion_upstream;
PQ_Entry(int set_rr_node_ind, int /*switch_ind*/, float parent_delay, float parent_R_upstream, float parent_congestion_upstream, bool starting_node, float Tsw_adjust);
bool operator<(const PQ_Entry& obj) const {
/* inserted into max priority queue so want queue entries with a lower cost to be greater */
return (this->cost > obj.cost);
}
};
// A version of PQ_Entry that only calculates and stores the delay.
class PQ_Entry_Delay {
public:
int rr_node_ind; //index in device_ctx.rr_nodes that this entry represents
float delay_cost; //the cost of the path to get to this node
PQ_Entry_Delay(int set_rr_node_ind, int /*switch_ind*/, const PQ_Entry_Delay* parent);
float cost() const {
return delay_cost;
}
void adjust_Tsw(float amount) {
delay_cost += amount;
}
bool operator>(const PQ_Entry_Delay& obj) const {
return (this->delay_cost > obj.delay_cost);
}
};
// A version of PQ_Entry that only calculates and stores the base cost.
class PQ_Entry_Base_Cost {
public:
int rr_node_ind; //index in device_ctx.rr_nodes that this entry represents
float base_cost;
PQ_Entry_Base_Cost(int set_rr_node_ind, int /*switch_ind*/, const PQ_Entry_Base_Cost* parent);
float cost() const {
return base_cost;
}
void adjust_Tsw(float /* amount */) {
// do nothing
}
bool operator>(const PQ_Entry_Base_Cost& obj) const {
return (this->base_cost > obj.base_cost);
}
};
struct Search_Path {
float cost;
int parent;
int edge;
};
/* iterates over the children of the specified node and selectively pushes them onto the priority queue */
template<typename Entry>
void expand_dijkstra_neighbours(const t_rr_graph_storage& rr_nodes,
const Entry& parent_entry,
std::vector<Search_Path>* paths,
std::vector<bool>* node_expanded,
std::priority_queue<Entry,
std::vector<Entry>,
std::greater<Entry>>* pq);
} // namespace util
#endif
| 33.864734 | 171 | 0.63709 | [
"vector"
] |
28b75ae7f2ee19f42766ddf16321597fe43c15dc | 7,399 | c | C | bin/R-3.5.1/src/main/debug.c | lifebit-ai/exomedepth | 5a775ae5e2a247aeadc5208a34e8717c7855d080 | [
"MIT"
] | 1 | 2019-07-28T20:32:29.000Z | 2019-07-28T20:32:29.000Z | bin/R-3.5.1/src/main/debug.c | lifebit-ai/exomedepth | 5a775ae5e2a247aeadc5208a34e8717c7855d080 | [
"MIT"
] | 1 | 2020-04-22T14:02:10.000Z | 2020-04-22T14:02:10.000Z | bin/R-3.5.1/src/main/debug.c | lifebit-ai/exomedepth | 5a775ae5e2a247aeadc5208a34e8717c7855d080 | [
"MIT"
] | 1 | 2018-08-29T09:43:52.000Z | 2018-08-29T09:43:52.000Z | /*
* R : A Computer Language for Statistical Data Analysis
* Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka
* Copyright (C) 1998-2015 The R Core Team.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, a copy is available at
* https://www.R-project.org/Licenses/
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#define R_USE_SIGNALS 1
#include <Defn.h>
#include <Internal.h>
SEXP attribute_hidden do_debug(SEXP call, SEXP op, SEXP args, SEXP rho)
{
SEXP ans = R_NilValue;
checkArity(op,args);
#define find_char_fun \
if (isValidString(CAR(args))) { \
SEXP s; \
PROTECT(s = installTrChar(STRING_ELT(CAR(args), 0))); \
SETCAR(args, findFun(s, rho)); \
UNPROTECT(1); \
}
find_char_fun
if (TYPEOF(CAR(args)) != CLOSXP &&
TYPEOF(CAR(args)) != SPECIALSXP &&
TYPEOF(CAR(args)) != BUILTINSXP)
error(_("argument must be a function"));
switch(PRIMVAL(op)) {
case 0: // debug()
SET_RDEBUG(CAR(args), 1);
break;
case 1: // undebug()
if( RDEBUG(CAR(args)) != 1 )
warning("argument is not being debugged");
SET_RDEBUG(CAR(args), 0);
break;
case 2: // isdebugged()
ans = ScalarLogical(RDEBUG(CAR(args)));
break;
case 3: // debugonce()
SET_RSTEP(CAR(args), 1);
break;
}
return ans;
}
/* primitives .primTrace() and .primUntrace() */
SEXP attribute_hidden do_trace(SEXP call, SEXP op, SEXP args, SEXP rho)
{
checkArity(op, args);
find_char_fun
if (TYPEOF(CAR(args)) != CLOSXP &&
TYPEOF(CAR(args)) != SPECIALSXP &&
TYPEOF(CAR(args)) != BUILTINSXP)
errorcall(call, _("argument must be a function"));
switch(PRIMVAL(op)) {
case 0:
SET_RTRACE(CAR(args), 1);
break;
case 1:
SET_RTRACE(CAR(args), 0);
break;
}
return R_NilValue;
}
/* maintain global trace & debug state */
static Rboolean tracing_state = TRUE, debugging_state = TRUE;
#define GET_TRACE_STATE tracing_state
#define GET_DEBUG_STATE debugging_state
#define SET_TRACE_STATE(value) tracing_state = value
#define SET_DEBUG_STATE(value) debugging_state = value
SEXP attribute_hidden do_traceOnOff(SEXP call, SEXP op, SEXP args, SEXP rho)
{
checkArity(op, args);
SEXP onOff = CAR(args);
Rboolean trace = (PRIMVAL(op) == 0),
prev = trace ? GET_TRACE_STATE : GET_DEBUG_STATE;
if(length(onOff) > 0) {
Rboolean _new = asLogical(onOff);
if(_new == TRUE || _new == FALSE)
if(trace) SET_TRACE_STATE(_new);
else SET_DEBUG_STATE(_new);
else
error(_("Value for '%s' must be TRUE or FALSE"),
trace ? "tracingState" : "debuggingState");
}
return ScalarLogical(prev);
}
// GUIs, packages, etc can query:
Rboolean R_current_debug_state() { return GET_DEBUG_STATE; }
Rboolean R_current_trace_state() { return GET_TRACE_STATE; }
/* memory tracing */
/* report when a traced object is duplicated */
#ifdef R_MEMORY_PROFILING
SEXP attribute_hidden do_tracemem(SEXP call, SEXP op, SEXP args, SEXP rho)
{
SEXP object;
char buffer[21];
checkArity(op, args);
check1arg(args, call, "x");
object = CAR(args);
if (TYPEOF(object) == CLOSXP ||
TYPEOF(object) == BUILTINSXP ||
TYPEOF(object) == SPECIALSXP)
errorcall(call, _("argument must not be a function"));
if(object == R_NilValue)
errorcall(call, _("cannot trace NULL"));
if(TYPEOF(object) == ENVSXP || TYPEOF(object) == PROMSXP)
errorcall(call,
_("'tracemem' is not useful for promise and environment objects"));
if(TYPEOF(object) == EXTPTRSXP || TYPEOF(object) == WEAKREFSXP)
errorcall(call,
_("'tracemem' is not useful for weak reference or external pointer objects"));
SET_RTRACE(object, 1);
snprintf(buffer, 21, "<%p>", (void *) object);
return mkString(buffer);
}
SEXP attribute_hidden do_untracemem(SEXP call, SEXP op, SEXP args, SEXP rho)
{
SEXP object;
checkArity(op, args);
check1arg(args, call, "x");
object=CAR(args);
if (TYPEOF(object) == CLOSXP ||
TYPEOF(object) == BUILTINSXP ||
TYPEOF(object) == SPECIALSXP)
errorcall(call, _("argument must not be a function"));
if (RTRACE(object))
SET_RTRACE(object, 0);
return R_NilValue;
}
#else
SEXP attribute_hidden NORET do_tracemem(SEXP call, SEXP op, SEXP args, SEXP rho)
{
checkArity(op, args);
check1arg(args, call, "x");
errorcall(call, _("R was not compiled with support for memory profiling"));
}
SEXP attribute_hidden NORET do_untracemem(SEXP call, SEXP op, SEXP args, SEXP rho)
{
checkArity(op, args);
check1arg(args, call, "x");
errorcall(call, _("R was not compiled with support for memory profiling"));
}
#endif /* R_MEMORY_PROFILING */
#ifndef R_MEMORY_PROFILING
void memtrace_report(void* old, void *_new) {
return;
}
#else
static void memtrace_stack_dump(void)
{
RCNTXT *cptr;
for (cptr = R_GlobalContext; cptr; cptr = cptr->nextcontext) {
if ((cptr->callflag & (CTXT_FUNCTION | CTXT_BUILTIN))
&& TYPEOF(cptr->call) == LANGSXP) {
SEXP fun = CAR(cptr->call);
Rprintf("%s ",
TYPEOF(fun) == SYMSXP ? translateChar(PRINTNAME(fun)) :
"<Anonymous>");
}
}
Rprintf("\n");
}
void memtrace_report(void * old, void * _new)
{
if (!R_current_trace_state()) return;
Rprintf("tracemem[%p -> %p]: ", (void *) old, _new);
memtrace_stack_dump();
}
#endif /* R_MEMORY_PROFILING */
SEXP attribute_hidden do_retracemem(SEXP call, SEXP op, SEXP args, SEXP rho)
{
#ifdef R_MEMORY_PROFILING
SEXP object, previous, ans, argList;
char buffer[21];
static SEXP do_retracemem_formals = NULL;
if (do_retracemem_formals == NULL)
do_retracemem_formals = allocFormalsList2(install("x"),
R_PreviousSymbol);
PROTECT(argList = matchArgs(do_retracemem_formals, args, call));
if(CAR(argList) == R_MissingArg) SETCAR(argList, R_NilValue);
if(CADR(argList) == R_MissingArg) SETCAR(CDR(argList), R_NilValue);
object = CAR(argList);
if (TYPEOF(object) == CLOSXP ||
TYPEOF(object) == BUILTINSXP ||
TYPEOF(object) == SPECIALSXP)
errorcall(call, _("argument must not be a function"));
previous = CADR(argList);
if(!isNull(previous) && (!isString(previous) || LENGTH(previous) != 1))
errorcall(call, _("invalid '%s' argument"), "previous");
if (RTRACE(object)) {
snprintf(buffer, 21, "<%p>", (void *) object);
ans = mkString(buffer);
} else {
R_Visible = 0;
ans = R_NilValue;
}
if (previous != R_NilValue){
SET_RTRACE(object, 1);
if (R_current_trace_state()) {
/* FIXME: previous will have <0x....> whereas other values are
without the < > */
Rprintf("tracemem[%s -> %p]: ",
translateChar(STRING_ELT(previous, 0)), (void *) object);
memtrace_stack_dump();
}
}
UNPROTECT(1);
return ans;
#else
R_Visible = 0; /* for consistency with other case */
return R_NilValue;
#endif
}
| 27.202206 | 82 | 0.667658 | [
"object"
] |
28b891194a6839ffa166d6765b53baa622f5f25e | 12,348 | c | C | emuboot/src/mainboard/via/epia-m700/wakeup.c | leetobin/firebrick | 9109e8025d949357a0320aa2903bbad876593143 | [
"Apache-2.0"
] | 9 | 2015-03-24T12:39:13.000Z | 2021-03-31T20:08:03.000Z | emuboot/src/mainboard/via/epia-m700/wakeup.c | leetobin/firebrickRemote | e825e194d09752b32db3c8d5a9b8d0e912030df9 | [
"Apache-2.0"
] | null | null | null | emuboot/src/mainboard/via/epia-m700/wakeup.c | leetobin/firebrickRemote | e825e194d09752b32db3c8d5a9b8d0e912030df9 | [
"Apache-2.0"
] | 3 | 2015-11-23T14:14:18.000Z | 2018-03-14T11:49:00.000Z | /*
* This file is part of the coreboot project.
*
* Copyright (C) 2008 Rudolf Marek <r.marek@assembler.cz>
* Copyright (C) 2009 One Laptop per Child, Association, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* FIXME This code should be dropped and instead the generic resume code
* should be used.
*/
/* Parts of this code is taken from reboot.c from Linux. */
/*
* This file mostly copied from Rudolf's S3 patch, some changes in
* acpi_jump_wake().
*/
#include <stdint.h>
#include <string.h>
#include <arch/io.h>
#include <console/console.h>
#include <delay.h>
#include "wakeup.h"
int enable_a20(void);
/*
* The following code and data reboots the machine by switching to real
* mode and jumping to the BIOS reset entry point, as if the CPU has
* really been reset. The previous version asked the keyboard
* controller to pulse the CPU reset line, which is more thorough, but
* doesn't work with at least one type of 486 motherboard. It is easy
* to stop this code working; hence the copious comments.
*/
static unsigned long long real_mode_gdt_entries[3] = {
0x0000000000000000ULL, /* Null descriptor */
0x00009a000000ffffULL, /* 16-bit real-mode 64k code at 0x00000000 */
0x000092000100ffffULL /* 16-bit real-mode 64k data at 0x00000100 */
};
struct Xgt_desc_struct {
unsigned short size;
unsigned long address __attribute__ ((packed));
unsigned short pad;
} __attribute__ ((packed));
static struct Xgt_desc_struct real_mode_gdt = {
sizeof(real_mode_gdt_entries) - 1,
(long)real_mode_gdt_entries
},
real_mode_idt = {0x3ff, 0},
no_idt = { 0, 0 };
/*
* This is 16-bit protected mode code to disable paging and the cache,
* switch to real mode and jump to the BIOS reset code.
*
* The instruction that switches to real mode by writing to CR0 must be
* followed immediately by a far jump instruction, which set CS to a
* valid value for real mode, and flushes the prefetch queue to avoid
* running instructions that have already been decoded in protected
* mode.
*
* Clears all the flags except ET, especially PG (paging), PE
* (protected-mode enable) and TS (task switch for coprocessor state
* save). Flushes the TLB after paging has been disabled. Sets CD and
* NW, to disable the cache on a 486, and invalidates the cache. This
* is more like the state of a 486 after reset. I don't know if
* something else should be done for other chips.
*
* More could be done here to set up the registers as if a CPU reset had
* occurred; hopefully real BIOSs don't assume much.
*/
// 0x66, 0x0d, 0x00, 0x00, 0x00, 0x60, /* orl $0x60000000, %eax */
static unsigned char real_mode_switch[] = {
0x66, 0x0f, 0x20, 0xc0, /* movl %cr0,%eax */
0x24, 0xfe, /* andb $0xfe,al */
0x66, 0x0f, 0x22, 0xc0 /* movl %eax,%cr0 */
};
static unsigned char jump_to_wakeup[] = {
0xea, 0x00, 0x00, 0x00, 0xe0 /* ljmp $0xffff, $0x0000 */
};
void acpi_jump_wake(u32 vector)
{
u32 dwEip;
struct Xgt_desc_struct *wake_thunk16_Xgt_desc;
printk(BIOS_DEBUG, "IN ACPI JUMP WAKE TO %x\n", vector);
if (enable_a20())
die("failed to enable A20\n");
printk(BIOS_DEBUG, "IN ACPI JUMP WAKE TO 3 %x\n", vector);
*((u16 *) (jump_to_wakeup + 3)) = (u16) (vector >> 4);
printk(BIOS_DEBUG, "%x %x %x %x %x\n", jump_to_wakeup[0], jump_to_wakeup[1],
jump_to_wakeup[2], jump_to_wakeup[3], jump_to_wakeup[4]);
memcpy((void *)(WAKE_THUNK16_ADDR - sizeof(real_mode_switch) - 100),
real_mode_switch, sizeof(real_mode_switch));
memcpy((void *)(WAKE_THUNK16_ADDR - 100), jump_to_wakeup,
sizeof(jump_to_wakeup));
//jason_tsc_count();
printk(BIOS_EMERG, "file '%s', line %d\n\n", __FILE__, __LINE__);
//jason_tsc_count_end();
unsigned long long *real_mode_gdt_entries_at_eseg;
real_mode_gdt_entries_at_eseg = (void *)WAKE_THUNK16_GDT; /* Copy from real_mode_gdt_entries and change limition to 1M and data base to 0; */
real_mode_gdt_entries_at_eseg[0] = 0x0000000000000000ULL; /* Null descriptor */
real_mode_gdt_entries_at_eseg[1] = 0x000f9a000000ffffULL; /* 16-bit real-mode 1M code at 0x00000000 */
real_mode_gdt_entries_at_eseg[2] = 0x000f93000000ffffULL; /* 16-bit real-mode 1M data at 0x00000000 */
wake_thunk16_Xgt_desc = (void *)WAKE_THUNK16_XDTR;
wake_thunk16_Xgt_desc[0].size = sizeof(real_mode_gdt_entries) - 1;
wake_thunk16_Xgt_desc[0].address = (long)real_mode_gdt_entries_at_eseg;
wake_thunk16_Xgt_desc[1].size = 0x3ff;
wake_thunk16_Xgt_desc[1].address = 0;
wake_thunk16_Xgt_desc[2].size = 0;
wake_thunk16_Xgt_desc[2].address = 0;
/* Added this code to get current value of EIP. */
__asm__ volatile (
"calll geip\n\t"
"geip: \n\t"
"popl %0\n\t"
: "=a" (dwEip)
);
unsigned char *dest, *src;
src = (unsigned char *)dwEip;
dest = (void *)WAKE_RECOVER1M_CODE;
u32 i;
for (i = 0; i < 0x200; i++)
dest[i] = src[i];
__asm__ __volatile__("ljmp $0x0010,%0" /* 08 error */
::"i"((void *)(WAKE_RECOVER1M_CODE + 0x20)));
/* Added 0x20 "nop" to make sure the ljmp will not jump then halt. */
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
__asm__ volatile (
/*
* Set new esp, maybe ebp should not equal to esp?, due to the
* variable in acpi_jump_wake?, anyway, this may be not a big
* problem. and I didn't clear the area (ef000+-0x200) to zero.
*/
"movl %0, %%ebp\n\t"
"movl %0, %%esp\n\t"::"a" (WAKE_THUNK16_STACK)
);
/*
* Only "src" and "dest" use the new stack, and the esp maybe also
* used in resumevector.
*/
#if PAYLOAD_IS_SEABIOS == 1
/* WAKE_MEM_INFO inited in get_set_top_available_mem in tables.c. */
src =
(unsigned char *)((*(u32 *) WAKE_MEM_INFO) - 64 * 1024 - 0x100000);
dest = 0;
/*
* If recovered 0-e0000, then when resume, before WinXP turn on the
* desktop screen, there is gray background which last 1sec.
*/
for (i = 0; i < 0xa0000; i++)
dest[i] = src[i];
#if 0
__asm__ volatile (
"movl %0, %%esi\n\t"
"movl $0, %%edi\n\t"
"movl $0xa0000, %%ecx\n\t"
"shrl $2, %%ecx\n\t"
"rep movsd\n\t"
::"a"(src)
);
#endif
src = (unsigned char *)((*(u32 *) WAKE_MEM_INFO) - 64 * 1024
- 0x100000 + 0xc0000);
#if 0
dest = 0xc0000;
for (i = 0; i < 0x20000; i++)
dest[i] = src[i];
__asm__ volatile (
"movl %0, %%esi\n\t"
"movl $0xc0000, %%edi\n\t"
"movl $0x20000, %%ecx\n\t"
"shrl $2, %%ecx\n\t"
"rep movsd\n\t"
::"a"(src)
);
#endif
src = (unsigned char *)((*(u32 *) WAKE_MEM_INFO) - 64 * 1024
- 0x100000 + 0xe0000 + WAKE_SPECIAL_SIZE);
/* dest = 0xf0000; */
/* for (i = 0; i < 0x10000; i++) */
/* dest[i] = src[i]; */
__asm__ volatile (
"movl %0, %%esi\n\t"
"movl %1, %%edi\n\t"
"movl %2, %%ecx\n\t"
"shrl $2, %%ecx\n\t"
"rep movsd\n\t"::"r" (src),
"r"(0xe0000 + WAKE_SPECIAL_SIZE),
"r"(0x10000 - WAKE_SPECIAL_SIZE)
);
src = (unsigned char *)((*(u32 *) WAKE_MEM_INFO) - 64 * 1024
- 0x100000 + 0xf0000);
/* dest = 0xf0000; */
/* for (i = 0; i < 0x10000; i++) */
/* dest[i] = src[i]; */
__asm__ volatile (
"movl %0, %%esi\n\t"
"movl $0xf0000, %%edi\n\t"
"movl $0x10000, %%ecx\n\t"
"shrl $2, %%ecx\n\t" "rep movsd\n\t"::"a" (src)
);
asm volatile ("wbinvd");
#endif
/* Set up the IDT for real mode. */
asm volatile ("lidt %0"::"m" (wake_thunk16_Xgt_desc[1]));
/*
* Set up a GDT from which we can load segment descriptors for real
* mode. The GDT is not used in real mode; it is just needed here to
* prepare the descriptors.
*/
asm volatile ("lgdt %0"::"m" (wake_thunk16_Xgt_desc[0]));
/*
* Load the data segment registers, and thus the descriptors ready for
* real mode. The base address of each segment is 0x100, 16 times the
* selector value being loaded here. This is so that the segment
* registers don't have to be reloaded after switching to real mode:
* the values are consistent for real mode operation already.
*/
__asm__ __volatile__(
"movl $0x0010,%%eax\n"
"\tmovl %%eax,%%ds\n"
"\tmovl %%eax,%%es\n"
"\tmovl %%eax,%%fs\n"
"\tmovl %%eax,%%gs\n"
"\tmovl %%eax,%%ss":::"eax"
);
/*
* Jump to the 16-bit code that we copied earlier. It disables paging
* and the cache, switches to real mode, and jumps to the BIOS reset
* entry point.
*/
__asm__ __volatile__(
"ljmp $0x0008,%0"::"i"
((void *)(WAKE_THUNK16_ADDR - sizeof(real_mode_switch) - 100))
);
}
/* -*- linux-c -*- ------------------------------------------------------- *
*
* Copyright (C) 1991, 1992 Linus Torvalds
* Copyright 2007 rPath, Inc. - All Rights Reserved
*
* This file is part of the Linux kernel, and is made available under
* the terms of the GNU General Public License version 2.
*
* ----------------------------------------------------------------------- */
/*
* arch/x86/boot/a20.c
*
* Enable A20 gate (return -1 on failure)
*/
#define MAX_8042_LOOPS 100000
static int empty_8042(void)
{
u8 status;
int loops = MAX_8042_LOOPS;
while (loops--) {
udelay(1);
status = inb(0x64);
if (status & 1) {
/* Read and discard input data */
udelay(1);
(void)inb(0x60);
} else if (!(status & 2)) {
/* Buffers empty, finished! */
return 0;
}
}
return -1;
}
/* Returns nonzero if the A20 line is enabled. The memory address
used as a test is the int $0x80 vector, which should be safe. */
#define A20_TEST_ADDR (4*0x80)
#define A20_TEST_SHORT 32
#define A20_TEST_LONG 2097152 /* 2^21 */
static int a20_test(int loops)
{
int ok = 0;
int saved, ctr;
saved = ctr = *((u32 *) A20_TEST_ADDR);
while (loops--) {
*((u32 *) A20_TEST_ADDR) = ++ctr;
udelay(1); /* Serialize and make delay constant */
ok = *((u32 *) A20_TEST_ADDR + 0xffff0 + 0x10) ^ ctr;
if (ok)
break;
}
*((u32 *) A20_TEST_ADDR) = saved;
return ok;
}
/* Quick test to see if A20 is already enabled */
static int a20_test_short(void)
{
return a20_test(A20_TEST_SHORT);
}
/* Longer test that actually waits for A20 to come on line; this
is useful when dealing with the KBC or other slow external circuitry. */
static int a20_test_long(void)
{
return a20_test(A20_TEST_LONG);
}
static void enable_a20_kbc(void)
{
empty_8042();
outb(0xd1, 0x64); /* Command write */
empty_8042();
outb(0xdf, 0x60); /* A20 on */
empty_8042();
}
static void enable_a20_fast(void)
{
u8 port_a;
port_a = inb(0x92); /* Configuration port A */
port_a |= 0x02; /* Enable A20 */
port_a &= ~0x01; /* Do not reset machine */
outb(port_a, 0x92);
}
/*
* Actual routine to enable A20; return 0 on ok, -1 on failure
*/
#define A20_ENABLE_LOOPS 255 /* Number of times to try */
int enable_a20(void)
{
int loops = A20_ENABLE_LOOPS;
while (loops--) {
/* First, check to see if A20 is already enabled
(legacy free, etc.) */
if (a20_test_short())
return 0;
/* Try enabling A20 through the keyboard controller */
empty_8042();
// if (a20_test_short())
// return 0; /* BIOS worked, but with delayed reaction */
enable_a20_kbc();
if (a20_test_long())
return 0;
/* Finally, try enabling the "fast A20 gate" */
enable_a20_fast();
if (a20_test_long())
return 0;
}
return -1;
}
| 27.318584 | 142 | 0.657839 | [
"vector"
] |
28c80d6a4eec882363e67bf07a4b863fff6c7527 | 4,252 | h | C | Patterns.h | quarterturn/aurora | 3995d724f9ae532d06befbb82fee3bd3caae9052 | [
"MIT"
] | 1 | 2020-08-14T00:45:28.000Z | 2020-08-14T00:45:28.000Z | Patterns.h | quarterturn/aurora | 3995d724f9ae532d06befbb82fee3bd3caae9052 | [
"MIT"
] | null | null | null | Patterns.h | quarterturn/aurora | 3995d724f9ae532d06befbb82fee3bd3caae9052 | [
"MIT"
] | null | null | null | /*
* Aurora: https://github.com/pixelmatix/aurora
* Copyright (c) 2014 Jason Coon
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef Patterns_H
#define Patterns_H
#include "Vector.h"
#include "Boid.h"
#include "Attractor.h"
#include "PatternFlowField.h"
#include "PatternPendulumWave.h"
#include "PatternSpin.h"
#include "PatternSimplexNoise.h"
#include "PatternWave.h"
#include "PatternAttract.h"
#include "PatternBounce.h"
#include "PatternFlock.h"
#include "PatternInfinity.h"
#include "PatternPlasma.h"
#include "PatternSnake.h"
#include "PatternInvaders.h"
#include "PatternFire.h"
#include "PatternLife.h"
#include "PatternMaze.h"
#include "PatternPulse.h"
#include "PatternRainbowSmoke.h"
#include "PatternSpark.h"
#include "PatternSpiral.h"
#include "PatternEffects.h"
class Patterns : public Playlist {
private:
PatternFlowField flowField;
PatternPendulumWave pendulumWave;
PatternSpin spin;
PatternSimplexNoise simplexNoise;
PatternWave wave;
PatternAttract attract;
PatternBounce bounce;
PatternFlock flock;
PatternInfinity infinity;
PatternPlasma plasma;
PatternInvaders invaders;
PatternSnake snake;
PatternFire fire;
PatternLife life;
PatternMaze maze;
PatternPulse pulse;
PatternRainbowSmoke rainbowSmoke;
PatternSpark spark;
PatternSpiral spiral;
PatternGhost ghost;
PatternDots1 dots1;
PatternDots2 dots2;
PatternSlowMandala slowMandala;
PatternMandala8 mandala8;
int currentIndex = 0;
Drawable* currentItem;
static const int PATTERN_COUNT = 24;
Drawable* items[PATTERN_COUNT] = {
&flowField,
&pendulumWave,
&spin,
&simplexNoise,
&wave,
&attract,
&bounce,
&flock,
&infinity,
&plasma,
&invaders,
&snake,
&fire,
&life,
&maze,
&pulse,
&rainbowSmoke,
&spark,
&spiral,
&ghost,
&dots1,
&dots2,
&slowMandala,
&mandala8,
};
public:
Patterns() {
this->currentItem = items[0];
this->currentItem->start();
}
char* Drawable::name = "Patterns";
void stop() {
if (currentItem)
currentItem->stop();
}
void start() {
if (currentItem)
currentItem->start();
}
void move(int step) {
currentIndex += step;
if (currentIndex >= PATTERN_COUNT) currentIndex = 0;
else if (currentIndex < 0) currentIndex = PATTERN_COUNT - 1;
if (currentItem)
currentItem->stop();
currentItem = items[currentIndex];
if (currentItem)
currentItem->start();
}
void moveRandom() {
currentIndex = random(0, PATTERN_COUNT);
if (currentIndex >= PATTERN_COUNT) currentIndex = 0;
else if (currentIndex < 0) currentIndex = PATTERN_COUNT - 1;
if (currentItem)
currentItem->stop();
currentItem = items[currentIndex];
effects.RandomPalette();
if (currentItem)
currentItem->start();
}
unsigned int drawFrame() {
return currentItem->drawFrame();
}
};
#endif | 25.614458 | 83 | 0.659925 | [
"vector"
] |
28d03f48269a71198f00a1e97aabfc4506faab5e | 712 | h | C | inst/ignore/geoops.h | ropensci/geoops | e83b0e98a3d532f9081f3adab787f8f719c9ffc1 | [
"MIT"
] | 11 | 2018-05-19T08:37:37.000Z | 2020-09-14T05:36:52.000Z | inst/ignore/geoops.h | cran/geoops | ec6c9300b7a48a4a604ba3a4243da7d0360e85a3 | [
"MIT"
] | 3 | 2018-03-19T18:37:19.000Z | 2020-05-15T21:49:48.000Z | inst/ignore/geoops.h | cran/geoops | ec6c9300b7a48a4a604ba3a4243da7d0360e85a3 | [
"MIT"
] | 2 | 2018-09-01T12:26:15.000Z | 2019-10-14T14:18:34.000Z | #include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::plugins(cpp11)]]
#include "json.h"
using json = nlohmann::json;
std::string get_coord(std::string x) {
std::string z = x;
auto j = json::parse(z);
if (j.is_array()) {
return z;
} else {
if ( j["type"].dump() == "\"Feature\"" &&
j.count("geometry") != 0 &&
j["geometry"]["type"].dump() == "\"Point\"" &&
j["geometry"]["coordinates"].is_array()
) {
std::string out = j["geometry"]["coordinates"].dump();
return out;
} else if (
j["type"].dump() == "\"Point\"" &&
j["coordinates"].is_array()
) {
std::string out = j["coordinates"].dump();
return out;
}
}
}
| 22.25 | 60 | 0.505618 | [
"geometry"
] |
939e65e4b07086b9422d2342bd96e9db9405452f | 2,030 | h | C | Source/Dynamics/EmbeddedMethod/EmbeddedFiniteElement.h | weikm/sandcarSimulation2 | fe499d0a3289c0ac1acce69c7dc78d8ce1b2708a | [
"Apache-2.0"
] | null | null | null | Source/Dynamics/EmbeddedMethod/EmbeddedFiniteElement.h | weikm/sandcarSimulation2 | fe499d0a3289c0ac1acce69c7dc78d8ce1b2708a | [
"Apache-2.0"
] | null | null | null | Source/Dynamics/EmbeddedMethod/EmbeddedFiniteElement.h | weikm/sandcarSimulation2 | fe499d0a3289c0ac1acce69c7dc78d8ce1b2708a | [
"Apache-2.0"
] | null | null | null | /**
* @author : ZHAO CHONGYAO (cyzhao@zju.edu.cn)
* @date : 2021-05-30
* @description: Finite Element method header for physika library
* @version : 2.2.1
*/
#pragma once
#include "ParticleSystem/ParticleSystem.h"
#include "Common/framework.h"
#include "EmbeddedIntegrator.h"
#include <boost/property_tree/ptree.hpp>
namespace PhysIKA {
template <typename>
class ElasticityModule;
template <typename>
class PointSetToPointSet;
/*!
* \class EmbeddedFiniteElement
* \brief Peridynamics-based elastic object.
*/
template <typename TDataType>
class EmbeddedFiniteElement : public ParticleSystem<TDataType>
{
DECLARE_CLASS_1(EmbeddedFiniteElement, TDataType)
public:
typedef typename TDataType::Real Real;
typedef typename TDataType::Coord Coord;
using pb_type = Problem<Real, 3>;
EmbeddedFiniteElement(std::string name = "default");
virtual ~EmbeddedFiniteElement();
bool initialize() override;
void advance(Real dt) override;
void updateTopology() override;
bool translate(Coord t) override;
bool scale(Real s) override;
void setElasticitySolver(std::shared_ptr<ElasticityModule<TDataType>> solver);
std::shared_ptr<ElasticityModule<TDataType>> getElasticitySolver();
void loadSurface(std::string filename);
std::shared_ptr<PointSetToPointSet<TDataType>> getTopologyMapping();
std::shared_ptr<Node> getSurfaceNode()
{
return m_surfaceNode;
}
virtual void init_problem_and_solver(const boost::property_tree::ptree& pt);
public:
/*VarField<Real> m_horizon;*/
DEF_EMPTY_VAR(Horizon, Real, "Horizon");
protected:
std::shared_ptr<Node> m_surfaceNode;
std::shared_ptr<embedded_elas_problem_builder<Real>> epb_fac;
};
#ifdef PRECISION_FLOAT
template class EmbeddedFiniteElement<DataType3f>;
#else
template class EmbeddedFiniteElement<DataType3d>;
#endif
} // namespace PhysIKA
| 29.42029 | 122 | 0.695074 | [
"object"
] |
93b1e947e6d54ac9f1515db12c94b45811a52487 | 11,814 | h | C | modules/tracktion_engine/utilities/tracktion_ConstrainedCachedValue.h | jbloit/tracktion_engine | b3fa7d6a3a404f64ae419abdf9c801d672cffb16 | [
"MIT",
"Unlicense"
] | 734 | 2018-11-16T09:39:40.000Z | 2022-03-30T16:56:14.000Z | modules/tracktion_engine/utilities/tracktion_ConstrainedCachedValue.h | jbloit/tracktion_engine | b3fa7d6a3a404f64ae419abdf9c801d672cffb16 | [
"MIT",
"Unlicense"
] | 100 | 2018-11-16T18:04:08.000Z | 2022-03-31T17:47:53.000Z | modules/tracktion_engine/utilities/tracktion_ConstrainedCachedValue.h | jbloit/tracktion_engine | b3fa7d6a3a404f64ae419abdf9c801d672cffb16 | [
"MIT",
"Unlicense"
] | 123 | 2018-11-16T15:51:50.000Z | 2022-03-29T12:21:27.000Z | /*
,--. ,--. ,--. ,--.
,-' '-.,--.--.,--,--.,---.| |,-.,-' '-.`--' ,---. ,--,--, Copyright 2018
'-. .-'| .--' ,-. | .--'| /'-. .-',--.| .-. || \ Tracktion Software
| | | | \ '-' \ `--.| \ \ | | | |' '-' '| || | Corporation
`---' `--' `--`--'`---'`--'`--' `---' `--' `---' `--''--' www.tracktion.com
Tracktion Engine uses a GPL/commercial licence - see LICENCE.md for details.
*/
namespace tracktion_engine
{
//==============================================================================
/**
A CachedValue that can take a std::function to constrain its value.
*/
template <typename Type>
class ConstrainedCachedValue : private juce::ValueTree::Listener
{
public:
//==============================================================================
/** Default constructor.
Creates a default CachedValue not referring to any property. To initialise the
object, call one of the referTo() methods.
*/
ConstrainedCachedValue();
/** Constructor.
Creates a CachedValue referring to a Value property inside a ValueTree.
If you use this constructor, the fallback value will be a default-constructed
instance of Type.
@param tree The ValueTree containing the property
@param propertyID The identifier of the property
@param undoManager The UndoManager to use when writing to the property
*/
ConstrainedCachedValue (juce::ValueTree& tree, const juce::Identifier& propertyID,
juce::UndoManager* undoManager);
/** Constructor.
Creates a default Cached Value referring to a Value property inside a ValueTree,
and specifies a fallback value to use if the property does not exist.
@param tree The ValueTree containing the property
@param propertyID The identifier of the property
@param undoManager The UndoManager to use when writing to the property
@param defaultToUse The fallback default value to use.
*/
ConstrainedCachedValue (juce::ValueTree& tree, const juce::Identifier& propertyID,
juce::UndoManager* undoManager, const Type& defaultToUse);
/** Sets a std::function to use to constain the value.
You must call this before setting any of the values.
*/
void setConstrainer (std::function<Type (Type)> constrainerToUse);
//==============================================================================
/** Returns the current value of the property. If the property does not exist,
returns the fallback default value.
This is the same as calling get().
*/
operator Type() const noexcept { return cachedValue; }
/** Returns the current value of the property. If the property does not exist,
returns the fallback default value.
*/
Type get() const noexcept { return cachedValue; }
/** Dereference operator. Provides direct access to the property. */
Type& operator*() noexcept { return cachedValue; }
/** Dereference operator. Provides direct access to members of the property
if it is of object type.
*/
Type* operator->() noexcept { return &cachedValue; }
/** Returns true if the current value of the property (or the fallback value)
is equal to other.
*/
template <typename OtherType>
bool operator== (const OtherType& other) const { return cachedValue == other; }
/** Returns true if the current value of the property (or the fallback value)
is not equal to other.
*/
template <typename OtherType>
bool operator!= (const OtherType& other) const { return cachedValue != other; }
//==============================================================================
/** Returns the current property as a Value object. */
juce::Value getPropertyAsValue();
/** Returns true if the current property does not exist and the CachedValue is using
the fallback default value instead.
*/
bool isUsingDefault() const;
/** Returns the current fallback default value. */
Type getDefault() const { return defaultValue; }
//==============================================================================
/** Sets the property. This will actually modify the property in the referenced ValueTree. */
ConstrainedCachedValue& operator= (const Type& newValue);
/** Sets the property. This will actually modify the property in the referenced ValueTree. */
void setValue (const Type& newValue, juce::UndoManager* undoManagerToUse);
/** Removes the property from the referenced ValueTree and makes the CachedValue
return the fallback default value instead.
*/
void resetToDefault();
/** Removes the property from the referenced ValueTree and makes the CachedValue
return the fallback default value instead.
*/
void resetToDefault (juce::UndoManager* undoManagerToUse);
/** Resets the fallback default value. */
void setDefault (const Type& value) { defaultValue = constrainer (value); }
//==============================================================================
/** Makes the CachedValue refer to the specified property inside the given ValueTree. */
void referTo (juce::ValueTree& tree, const juce::Identifier& property, juce::UndoManager*);
/** Makes the CachedValue refer to the specified property inside the given ValueTree,
and specifies a fallback value to use if the property does not exist.
*/
void referTo (juce::ValueTree& tree, const juce::Identifier& property, juce::UndoManager*, const Type& defaultVal);
/** Force an update in case the referenced property has been changed from elsewhere.
Note: The CachedValue is a ValueTree::Listener and therefore will be informed of
changes of the referenced property anyway (and update itself). But this may happen
asynchronously. forceUpdateOfCachedValue() forces an update immediately.
*/
void forceUpdateOfCachedValue();
//==============================================================================
/** Returns a reference to the ValueTree containing the referenced property. */
juce::ValueTree& getValueTree() noexcept { return targetTree; }
/** Returns the property ID of the referenced property. */
const juce::Identifier& getPropertyID() const noexcept { return targetProperty; }
private:
//==============================================================================
juce::ValueTree targetTree;
juce::Identifier targetProperty;
juce::UndoManager* undoManager;
Type defaultValue = Type();
Type cachedValue = Type();
std::function<Type (Type)> constrainer;
//==============================================================================
void referToWithDefault (juce::ValueTree&, const juce::Identifier&, juce::UndoManager*, const Type&);
Type getTypedValue() const;
void valueTreePropertyChanged (juce::ValueTree& changedTree, const juce::Identifier& changedProperty) override;
void valueTreeChildAdded (juce::ValueTree&, juce::ValueTree&) override {}
void valueTreeChildRemoved (juce::ValueTree&, juce::ValueTree&, int) override {}
void valueTreeChildOrderChanged (juce::ValueTree&, int, int) override {}
void valueTreeParentChanged (juce::ValueTree&) override {}
JUCE_DECLARE_NON_COPYABLE (ConstrainedCachedValue)
};
//==============================================================================
template <typename Type>
inline ConstrainedCachedValue<Type>::ConstrainedCachedValue() : undoManager (nullptr) {}
template <typename Type>
inline ConstrainedCachedValue<Type>::ConstrainedCachedValue (juce::ValueTree& v, const juce::Identifier& i, juce::UndoManager* um)
: targetTree (v), targetProperty (i), undoManager (um),
defaultValue(), cachedValue (getTypedValue())
{
targetTree.addListener (this);
}
template <typename Type>
inline ConstrainedCachedValue<Type>::ConstrainedCachedValue (juce::ValueTree& v, const juce::Identifier& i, juce::UndoManager* um, const Type& defaultToUse)
: targetTree (v), targetProperty (i), undoManager (um),
defaultValue (defaultToUse), cachedValue (getTypedValue())
{
targetTree.addListener (this);
}
template <typename Type>
inline void ConstrainedCachedValue<Type>::setConstrainer (std::function<Type (Type)> constrainerToUse)
{
constrainer = std::move (constrainerToUse);
jassert (constrainer);
if (targetTree.isValid())
{
setValue (constrainer (cachedValue), undoManager);
jassert (defaultValue == constrainer (defaultValue));
}
}
template <typename Type>
inline juce::Value ConstrainedCachedValue<Type>::getPropertyAsValue()
{
return targetTree.getPropertyAsValue (targetProperty, undoManager);
}
template <typename Type>
inline bool ConstrainedCachedValue<Type>::isUsingDefault() const
{
return ! targetTree.hasProperty (targetProperty);
}
template <typename Type>
inline ConstrainedCachedValue<Type>& ConstrainedCachedValue<Type>::operator= (const Type& newValue)
{
setValue (newValue, undoManager);
return *this;
}
template <typename Type>
inline void ConstrainedCachedValue<Type>::setValue (const Type& newValue, juce::UndoManager* undoManagerToUse)
{
jassert (constrainer);
auto constrainedValue = constrainer (newValue);
if (cachedValue != constrainedValue || isUsingDefault())
{
cachedValue = constrainedValue;
targetTree.setProperty (targetProperty, juce::VariantConverter<Type>::toVar (constrainedValue), undoManagerToUse);
}
}
template <typename Type>
inline void ConstrainedCachedValue<Type>::resetToDefault()
{
resetToDefault (undoManager);
}
template <typename Type>
inline void ConstrainedCachedValue<Type>::resetToDefault (juce::UndoManager* undoManagerToUse)
{
targetTree.removeProperty (targetProperty, undoManagerToUse);
forceUpdateOfCachedValue();
}
template <typename Type>
inline void ConstrainedCachedValue<Type>::referTo (juce::ValueTree& v, const juce::Identifier& i, juce::UndoManager* um)
{
referToWithDefault (v, i, um, Type());
}
template <typename Type>
inline void ConstrainedCachedValue<Type>::referTo (juce::ValueTree& v, const juce::Identifier& i, juce::UndoManager* um, const Type& defaultVal)
{
referToWithDefault (v, i, um, defaultVal);
}
template <typename Type>
inline void ConstrainedCachedValue<Type>::forceUpdateOfCachedValue()
{
cachedValue = getTypedValue();
}
template <typename Type>
inline void ConstrainedCachedValue<Type>::referToWithDefault (juce::ValueTree& v, const juce::Identifier& i, juce::UndoManager* um, const Type& defaultVal)
{
jassert (constrainer);
targetTree.removeListener (this);
targetTree = v;
targetProperty = i;
undoManager = um;
defaultValue = constrainer (defaultVal);
cachedValue = getTypedValue();
targetTree.addListener (this);
}
template <typename Type>
inline Type ConstrainedCachedValue<Type>::getTypedValue() const
{
jassert (constrainer);
if (const juce::var* property = targetTree.getPropertyPointer (targetProperty))
return constrainer (juce::VariantConverter<Type>::fromVar (*property));
return defaultValue;
}
template <typename Type>
inline void ConstrainedCachedValue<Type>::valueTreePropertyChanged (juce::ValueTree& changedTree, const juce::Identifier& changedProperty)
{
if (changedProperty == targetProperty && targetTree == changedTree)
forceUpdateOfCachedValue();
}
} // namespace tracktion_engine
| 39.38 | 156 | 0.638903 | [
"object"
] |
93bff332c774919080be8ff2bcffa21564693074 | 9,634 | h | C | MMOCoreORB/src/server/zone/objects/creature/commands/KillPlayerCommand.h | V-Fib/FlurryClone | 40e0ca7245ec31b3815eb6459329fd9e70f88936 | [
"Zlib",
"OpenSSL"
] | 18 | 2017-02-09T15:36:05.000Z | 2021-12-21T04:22:15.000Z | MMOCoreORB/src/server/zone/objects/creature/commands/KillPlayerCommand.h | V-Fib/FlurryClone | 40e0ca7245ec31b3815eb6459329fd9e70f88936 | [
"Zlib",
"OpenSSL"
] | 61 | 2016-12-30T21:51:10.000Z | 2021-12-10T20:25:56.000Z | MMOCoreORB/src/server/zone/objects/creature/commands/KillPlayerCommand.h | V-Fib/FlurryClone | 40e0ca7245ec31b3815eb6459329fd9e70f88936 | [
"Zlib",
"OpenSSL"
] | 71 | 2017-01-01T05:34:38.000Z | 2022-03-29T01:04:00.000Z | /*
Copyright <SWGEmu>
See file COPYING for copying conditions.*/
#ifndef KILLPLAYERCOMMAND_H_
#define KILLPLAYERCOMMAND_H_
#include "server/zone/objects/scene/SceneObject.h"
#include "server/zone/managers/player/PlayerManager.h"
class KillPlayerCommand : public QueueCommand {
public:
KillPlayerCommand(const String& name, ZoneProcessServer* server)
: QueueCommand(name, server) {
}
int doQueueCommand(CreatureObject* creature, const uint64& target, const UnicodeString& arguments) const {
if (!checkStateMask(creature))
return INVALIDSTATE;
if (!checkInvalidLocomotions(creature))
return INVALIDLOCOMOTION;
//Explain syntax
if (arguments.isEmpty() && target == 0) {
creature->sendSystemMessage("Syntax: /killPlayer [player name] [-area [range]] -wounds [<health> [action] [mind]]");
return GENERALERROR;
}
ManagedReference<CreatureObject*> targetPlayer = nullptr;
ManagedReference<SceneObject*> targetObject = server->getZoneServer()->getObject(target);
PlayerManager* playerManager = server->getZoneServer()->getPlayerManager();
if (targetObject != nullptr) {
if (targetObject->isPlayerCreature() || targetObject->isPet())
targetPlayer = cast<CreatureObject*>(targetObject.get());
else {
creature->sendSystemMessage("Invalid target.");
return INVALIDTARGET;
}
}
StringTokenizer args(arguments.toString());
//Initialize default damage amount
int healthDamage = 9999999;
int actionDamage = healthDamage;
int mindDamage = healthDamage;
//Initialize components used to kill nearby creatures
bool area = false;
bool wounds = false;
bool damage = false;
float range = 64;
while (args.hasMoreTokens()) {
String arg;
args.getStringToken(arg);
bool validOption = false;
//If first argument is player name, break loop and kill player
ManagedReference<CreatureObject*>findPlayer = playerManager->getPlayer(arg);
if (findPlayer != nullptr) {
targetPlayer = findPlayer;
break;
}
//Command Options
if (arg.charAt(0) == '-') {
//Help Syntax
if (arg.toLowerCase() == "-help" || arg == "-H") {
validOption = true;
creature->sendSystemMessage("Syntax: /kill [-area [range]] [-wounds] [<health> [action] [mind]]");
return GENERALERROR;
}
//Make command area affect with optional range
if (arg.toLowerCase() == "-area" || arg == "-a") {
validOption = true;
area = true;
if (args.hasMoreTokens()) {
range = args.getFloatToken();
if (range <= 0) {
creature->sendSystemMessage("Invalid range.");
return INVALIDPARAMETERS;
}
}
}
//Make command apply wounds as well as damage
if (arg.toLowerCase() == "-wounds" || arg == "-w") {
validOption = true;
wounds = true;
}
if (!validOption) {
creature->sendSystemMessage("Invalid option " + arg);
return INVALIDPARAMETERS;
}
}
else {
//Override default damage amount
try {
//Test if value is integer
for (int i = 0; i < arg.length(); i++) {
if (!Character::isDigit(arg.charAt(i)))
throw Exception("Invalid damage amount.");
}
damage = true;
healthDamage = Integer::valueOf(arg);
actionDamage = healthDamage;
mindDamage = healthDamage;
if (args.hasMoreTokens()) {
args.getStringToken(arg);
//Test if value is integer
for (int i = 0; i < arg.length(); i++) {
if (!Character::isDigit(arg.charAt(i)))
throw Exception("Invalid action damage amount.");
}
actionDamage = Integer::valueOf(arg);
mindDamage = 0;
if (args.hasMoreTokens()) {
args.getStringToken(arg);
//Test if value is integer
for (int i = 0; i < arg.length(); i++) {
if (!Character::isDigit(arg.charAt(i)))
throw Exception("Invalid mind damage amount.");
}
mindDamage = Integer::valueOf(arg);
if (args.hasMoreTokens())
throw Exception("Too many arguments.");
}
}
} catch (Exception& e) {
creature->sendSystemMessage(e.getMessage());
return INVALIDPARAMETERS;
}
}
}
//Deal area damage if specified
if (area) {
//Retrieve nearby objects
SortedVector<QuadTreeEntry*> closeObjects;
Zone* zone = creature->getZone();
if (creature->getCloseObjects() == nullptr) {
#ifdef COV_DEBUG
creature->info("Null closeobjects vector in KillPlayerCommand::doQueueCommand", true);
#endif
zone->getInRangeObjects(creature->getPositionX(), creature->getPositionY(), range, &closeObjects, true);
}
else {
CloseObjectsVector* closeVector = (CloseObjectsVector*) creature->getCloseObjects();
closeVector->safeCopyReceiversTo(closeObjects, CloseObjectsVector::CREOTYPE);
}
int count = 0;
//Deal area damage if specified
if (damage) {
for (int i = 0; i < closeObjects.size(); i++) {
SceneObject* targetObject = static_cast<SceneObject*>(closeObjects.get(i));
if (targetObject->isPlayerCreature() || targetObject->isPet()) {
targetPlayer = cast<CreatureObject*>(targetObject);
Locker locker(targetPlayer, creature);
//Deal damage if target is in range and is a player or pet
if (creature->isInRange(targetPlayer, range) && (targetPlayer->isPlayerCreature() || targetPlayer->isPet()) && targetPlayer != creature) {
targetPlayer->inflictDamage(creature, 0, healthDamage, true, true);
targetPlayer->inflictDamage(creature, 3, actionDamage, true, true);
targetPlayer->inflictDamage(creature, 6, mindDamage, true, true);
if( wounds ){
targetPlayer->addWounds( 0, healthDamage, true );
targetPlayer->addWounds( 1, healthDamage, true );
targetPlayer->addWounds( 2, healthDamage, true );
targetPlayer->addWounds( 3, actionDamage, true );
targetPlayer->addWounds( 4, actionDamage, true );
targetPlayer->addWounds( 5, actionDamage, true );
targetPlayer->addWounds( 6, mindDamage, true );
targetPlayer->addWounds( 7, mindDamage, true );
targetPlayer->addWounds( 8, mindDamage, true );
}
if (targetPlayer->isPlayerCreature())
targetPlayer->sendSystemMessage("You have been damaged!");
++count;
}
}
}
creature->sendSystemMessage(String::valueOf(count) + " players damaged.");
return SUCCESS;
}
//Kill players in area
else {
for (int i = 0; i < closeObjects.size(); i++) {
SceneObject* targetObject = static_cast<SceneObject*>(closeObjects.get(i));
if (targetObject->isPlayerCreature() || targetObject->isPet()) {
targetPlayer = cast<CreatureObject*>(targetObject);
if (targetPlayer->isPlayerCreature() && targetPlayer != creature) {
Locker locker (targetPlayer, creature);
playerManager->killPlayer(creature, targetPlayer, 1);
targetPlayer->notifyObservers(ObserverEventType::OBJECTDESTRUCTION, creature, 0);
++count;
} else if (targetPlayer->isPet()) {
AiAgent* pet = cast<AiAgent*>(targetPlayer.get());
if (pet != nullptr) {
Locker locker(pet, creature);
PetManager* petManager = server->getZoneServer()->getPetManager();
petManager->killPet(creature, pet);
pet->notifyObservers(ObserverEventType::OBJECTDESTRUCTION, creature, 0);
++count;
}
}
}
}
creature->sendSystemMessage(String::valueOf(count) + " players and/or pets killed.");
return SUCCESS;
}
}
//Deal damage to single target
else if (damage) {
if (targetPlayer != nullptr) {
if (targetPlayer->isPlayerCreature() || targetPlayer->isPet()) {
Locker locker(targetPlayer, creature);
targetPlayer->inflictDamage(creature, 0, healthDamage, true, true);
targetPlayer->inflictDamage(creature, 3, actionDamage, true, true);
targetPlayer->inflictDamage(creature, 6, mindDamage, true, true);
if( wounds ){
targetPlayer->addWounds( 0, healthDamage, true );
targetPlayer->addWounds( 1, healthDamage, true );
targetPlayer->addWounds( 2, healthDamage, true );
targetPlayer->addWounds( 3, actionDamage, true );
targetPlayer->addWounds( 4, actionDamage, true );
targetPlayer->addWounds( 5, actionDamage, true );
targetPlayer->addWounds( 6, mindDamage, true );
targetPlayer->addWounds( 7, mindDamage, true );
targetPlayer->addWounds( 8, mindDamage, true );
}
if (targetPlayer->isPlayerCreature())
creature->sendSystemMessage(targetPlayer->getFirstName() + " damaged.");
else
creature->sendSystemMessage(targetPlayer->getDisplayedName() + " damaged.");
return SUCCESS;
}
}
else {
creature->sendSystemMessage("Invalid target.");
return INVALIDTARGET;
}
}
//Kill single target
else {
if (targetPlayer != nullptr) {
if (targetPlayer->isPlayerCreature()) {
Locker locker(targetPlayer, creature);
playerManager->killPlayer(creature, targetPlayer, 1);
targetPlayer->notifyObservers(ObserverEventType::OBJECTDESTRUCTION, creature, 0);
} else if (targetPlayer->isPet()) {
AiAgent* pet = cast<AiAgent*>(targetPlayer.get());
if (pet != nullptr) {
Locker locker(pet, creature);
PetManager* petManager = server->getZoneServer()->getPetManager();
petManager->killPet(creature, pet);
pet->notifyObservers(ObserverEventType::OBJECTDESTRUCTION, creature, 0);
}
}
}
else {
creature->sendSystemMessage("Invalid target.");
return INVALIDTARGET;
}
}
return SUCCESS;
}
};
#endif //KILLPLAYERCOMMAND_H_
| 30.878205 | 144 | 0.655802 | [
"vector"
] |
93e20d2c824dcbbd77c205d06825a4db024bafc7 | 2,682 | h | C | include/linphone/api/c-participant.h | hihi-dev/linphone | 45814404943a0c8a4e341dbebf5da71fc6e44b67 | [
"BSD-2-Clause"
] | null | null | null | include/linphone/api/c-participant.h | hihi-dev/linphone | 45814404943a0c8a4e341dbebf5da71fc6e44b67 | [
"BSD-2-Clause"
] | null | null | null | include/linphone/api/c-participant.h | hihi-dev/linphone | 45814404943a0c8a4e341dbebf5da71fc6e44b67 | [
"BSD-2-Clause"
] | null | null | null | /*
* c-participant.h
* Copyright (C) 2010-2018 Belledonne Communications SARL
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _L_C_PARTICIPANT_H_
#define _L_C_PARTICIPANT_H_
#include "linphone/api/c-types.h"
// =============================================================================
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
/**
* @addtogroup misc
* @{
*/
/**
* Increment reference count of #LinphoneParticipant object.
**/
LINPHONE_PUBLIC LinphoneParticipant *linphone_participant_ref (LinphoneParticipant *participant);
/**
* Decrement reference count of #LinphoneParticipant object.
**/
LINPHONE_PUBLIC void linphone_participant_unref (LinphoneParticipant *participant);
/**
* Retrieve the user pointer associated with the conference participant.
* @param[in] participant A #LinphoneParticipant object
* @return The user pointer associated with the participant.
**/
LINPHONE_PUBLIC void * linphone_participant_get_user_data(const LinphoneParticipant *participant);
/**
* Assign a user pointer to the conference participant.
* @param[in] participant A #LinphoneParticipant object
* @param[in] ud The user pointer to associate with the participant
**/
LINPHONE_PUBLIC void linphone_participant_set_user_data(LinphoneParticipant *participant, void *ud);
/**
* Get the address of a conference participant.
* @param[in] participant A #LinphoneParticipant object
* @return The address of the participant
*/
LINPHONE_PUBLIC const LinphoneAddress * linphone_participant_get_address (const LinphoneParticipant *participant);
/**
* Tells whether a conference participant is an administrator of the conference.
* @param[in] participant A #LinphoneParticipant object
* @return A boolean value telling whether the participant is an administrator
*/
LINPHONE_PUBLIC bool_t linphone_participant_is_admin (const LinphoneParticipant *participant);
/**
* @}
*/
#ifdef __cplusplus
}
#endif // ifdef __cplusplus
#endif // ifndef _L_C_PARTICIPANT_H_
| 32.313253 | 114 | 0.748695 | [
"object"
] |
93f41f0ab5c48c852cfd1101579778213cd10efa | 343 | h | C | extras2/Spatiu Inchis/Pestera.h | stefanaciudin/CommandDefense | cae223bf72019b2098764664be5de2f052d57d6c | [
"MIT"
] | null | null | null | extras2/Spatiu Inchis/Pestera.h | stefanaciudin/CommandDefense | cae223bf72019b2098764664be5de2f052d57d6c | [
"MIT"
] | null | null | null | extras2/Spatiu Inchis/Pestera.h | stefanaciudin/CommandDefense | cae223bf72019b2098764664be5de2f052d57d6c | [
"MIT"
] | null | null | null | #pragma once
#include <string>
#include <vector>
using namespace std;
#include "SpatiuInchis.h"
class Pestera :public SpatiuInchis
{
private:
string miros;
bool lumina;
string nume;
public:
vector <SpatiuInchis*> pesteri;
Pestera(string smell, bool light, string name);
~Pestera();
void AddSpatiu(SpatiuInchis* s);
void PrintInfo();
}; | 19.055556 | 48 | 0.74344 | [
"vector"
] |
75c6568b32157881888576aa8c0f5c984f2c4711 | 3,730 | c | C | kernel/notify.c | moslevin/Mark3C | 4c10d71a62f0a7e06b12c9b58465e83155a1b5ec | [
"BSD-2-Clause"
] | null | null | null | kernel/notify.c | moslevin/Mark3C | 4c10d71a62f0a7e06b12c9b58465e83155a1b5ec | [
"BSD-2-Clause"
] | null | null | null | kernel/notify.c | moslevin/Mark3C | 4c10d71a62f0a7e06b12c9b58465e83155a1b5ec | [
"BSD-2-Clause"
] | null | null | null | /*===========================================================================
_____ _____ _____ _____
___| _|__ __|_ |__ __|__ |__ __| __ |__ ______
| \ / | || \ || | || |/ / ||___ |
| \/ | || \ || \ || \ ||___ |
|__/\__/|__|_||__|\__\ __||__|\__\ __||__|\__\ __||______|
|_____| |_____| |_____| |_____|
--[Mark3 Realtime Platform]--------------------------------------------------
Copyright (c) 2012-2015 Funkenstein Software Consulting, all rights reserved.
See license.txt for more information
===========================================================================*/
/*!
\file notify.c
\brief Lightweight thread notification - blocking object
*/
#include "mark3cfg.h"
#include "notify.h"
#if KERNEL_USE_NOTIFY
//---------------------------------------------------------------------------
void TimedNotify_Callback( Thread_t *pstOwner_, void *pvData_ )
{
Notify_t *pstNotify = (Notify_t*)(pvData_);
// Indicate that the semaphore has expired on the thread
Thread_SetExpired( pstOwner_, true );
// Wake up the thread that was blocked on this semaphore.
Notify_WakeMe( pstNotify, pstOwner_ );
if ( Thread_GetCurPriority( pstOwner_ ) >=
Thread_GetCurPriority( Scheduler_GetCurrentThread() ) )
{
Thread_Yield();
}
}
//---------------------------------------------------------------------------
void Notify_Init( Notify_t *pstNotify_ )
{
ThreadList_Init( (ThreadList_t*)pstNotify_ );
}
//---------------------------------------------------------------------------
void Notify_Signal( Notify_t *pstNotify_ )
{
bool bReschedule = false;
CS_ENTER();
Thread_t *pstCurrent = (Thread_t*)LinkList_GetHead((LinkListNode_t*)pstNotify_);
while (pstCurrent != NULL)
{
BlockingObject_UnBlock( pstCurrent );
if ( !bReschedule &&
( Thread_GetCurPriority( pstCurrent ) >=
Thread_GetCurPriority( Scheduler_GetCurrentThread() ) ) )
{
bReschedule = true;
}
pstCurrent = (Thread_t*)LinkList_GetHead(pstNotify_);
}
CS_EXIT();
if (bReschedule)
{
Thread_Yield();
}
}
//---------------------------------------------------------------------------
void Notify_Wait( Notify_t *pstNotify_, bool *pbFlag_ )
{
CS_ENTER();
BlockingObject_Block( (ThreadList_t*)pstNotify_, Scheduler_GetCurrentThread() );
if (pbFlag_)
{
*pbFlag_ = false;
}
CS_EXIT();
Thread_Yield();
if (pbFlag_)
{
*pbFlag_ = true;
}
}
//---------------------------------------------------------------------------
#if KERNEL_USER_TIMEOUTS
bool Notify_Wait( Notify_t *pstNotify_, K_ULONG ulWaitTimeMS_, bool *pbFlag_ )
{
bool bUseTimer = false;
Timer_t stNotifyTimer;
CS_ENTER();
if (ulWaitTimeMS_)
{
bUseTimer = true;
Thread_SetExpired( Scheduler_GetCurrentThread(), false );
Timer_Init( &stNotifyTimer );
Timer_Start( &stNotifyTimer, 0, ulWaitTimeMS_, TimedNotify_Callback, (void*)pstNotify_);
}
Block(g_pstCurrent);
if (pbFlag_)
{
*pbFlag_ = false;
}
CS_EXIT();
Thread_Yield();
if (pbFlag_)
{
*pbFlag_ = true;
}
if (bUseTimer)
{
Timer_Stop( &stNotifyTimer );
return ( Thread_GetExpired( Scheduler_GetCurrentThread() ) == false );
}
return true;
}
#endif
//---------------------------------------------------------------------------
void Notify_WakeMe( Notify_t *pstNotify_, Thread_t *pclChosenOne_ )
{
BlockingObject_UnBlock( pclChosenOne_ );
}
#endif
| 25.902778 | 96 | 0.494906 | [
"object"
] |
75cbfa604f5a265852a71374802b3e2fde89c5ce | 3,651 | h | C | parser/include/IvyscriptLine.h | Hitachi-Data-Systems/ivy | 07a77c271cad7f682d7fbff497bf74a76ecd5378 | [
"Apache-2.0"
] | 6 | 2016-09-12T16:23:53.000Z | 2021-12-16T23:08:34.000Z | parser/include/IvyscriptLine.h | Hitachi-Data-Systems/ivy | 07a77c271cad7f682d7fbff497bf74a76ecd5378 | [
"Apache-2.0"
] | null | null | null | parser/include/IvyscriptLine.h | Hitachi-Data-Systems/ivy | 07a77c271cad7f682d7fbff497bf74a76ecd5378 | [
"Apache-2.0"
] | null | null | null | //Copyright (c) 2016, 2017, 2018 Hitachi Vantara Corporation
//All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
//
//Authors: Allart Ian Vogelesang <ian.vogelesang@hitachivantara.com>
//
//Support: "ivy" is not officially supported by Hitachi Vantara.
// Contact one of the authors by email and as time permits, we'll help on a best efforts basis.
#pragma once
#include "ivytypes.h"
// a well-formed ivyscript line looks like "[section1] section 1 text [section2] section 2 text"
// Where all the [section] tokens don't contain white space and where the section name is an identifier
// starting with an alphabetic and continuing with alphanumerics and underscores.
class IvyscriptLine
{
typedef struct IvyscriptLineSection
{
std::string sectionNameWithBrackets;
std::string sectionText;
} IvyscriptLineSection;
public:
// variables
bool wellFormed {false};
std::vector<IvyscriptLineSection> sections;
std::map<std::string /*lowercasesectionname*/, int /*index_into_vector*/> section_indexes_by_name;
std::string parse_error_message;
std::string text;
unsigned int cursor = 0;
char next_char;
// methods
IvyscriptLine () {}
IvyscriptLine (std::string s) {parse(s);}
inline bool haveAnotherCharacter() { return cursor < text.length(); }
inline void consume_character() { cursor++; if (cursor<text.length()) next_char = text[cursor]; }
static bool isValidSectionNameWithBrackets(std::string);
bool parse(std::string); // returns true if well-formed.
// [section1] section1 text [section2] section2 text
// Where there are one or more "sections" of the form "[sectionName]sectionText",
// where the [sectionName] part has no whitespace and has an identifier token
// starting with an alphabetic and continuing with alphanumerics & underscores,
// and where no [sectionName] occurs more than once.
// Result of last parse() is remembered in wellFormed.
inline bool isNull() { return 0 == text.length(); } // if after removing comments what remains is at most whitespace
inline bool isWellFormed() {return wellFormed; }
std::string getParseErrorMessage() { return parse_error_message; }
std::string getText(){ return text; }
int numberOfSections() { return sections.size(); }
bool containsSection(std::string sectionNameWithBrackets); // lookups and matches are case insensitive so [host] and [Host] are the same.
bool getSectionTextBySectionName(std::string callers_error_message, std::string sectionNameWithBrackets, std::string& referenceToPutText);
// returns true on success
bool getSectionNameBySubscript(std::string callers_error_message, int, std::string& referenceToPutText);
// returns true on success
bool getSectionTextBySubscript(std::string callers_error_message, int, std::string& referenceToPutText);
// returns true on success
bool containsOnly(std::string& callers_error_message, std::list<std::string>& sectionNamesWithBrackets);
// returns true if we contain only section names in the list
// in C++11 hopefully you can say if xxxx.containsOnly(std::list<std::string>{"[hosts]", "[select]"}) ...
};
| 38.840426 | 139 | 0.746645 | [
"vector"
] |
75d68b2ca0b6fc1d15a3a2ae14e8fdfe5cefd465 | 10,975 | h | C | Design/Firmware/Arduino_Libraries/Walnut-Street-Utility/src/WSUtility.h | Dave1001/Scoreboard | 4e7753640fef9a8e1bb4ffbc34ecac80b06470f4 | [
"MIT"
] | 2 | 2018-05-12T06:30:33.000Z | 2021-08-05T01:58:44.000Z | Design/Firmware/Arduino_Libraries/Walnut-Street-Utility/src/WSUtility.h | Dave1001/Scoreboard | 4e7753640fef9a8e1bb4ffbc34ecac80b06470f4 | [
"MIT"
] | null | null | null | Design/Firmware/Arduino_Libraries/Walnut-Street-Utility/src/WSUtility.h | Dave1001/Scoreboard | 4e7753640fef9a8e1bb4ffbc34ecac80b06470f4 | [
"MIT"
] | 1 | 2020-01-24T18:07:34.000Z | 2020-01-24T18:07:34.000Z | /*
Creative Commons Attribution-ShareAlike 3.0 license
May 2016 @ http://www.walnut-street.net
*/
#ifndef _WS_UTILITY_H_
#define _WS_UTILITY_H_
#include <Arduino.h>
#include <Print.h>
#include <Wire.h>
#include <TimeLib.h>
#include <Streaming.h>
#ifdef ESP8266
extern "C" {
#include "user_interface.h"
}
#endif
// Add SERIAL_DEBUG or CONSOLE_DEBUG
// #define SERIAL_DEBUG
// Remember to initialise the "Serial" or "Console" object in your setup code with UBEGIN
#define UHEARTBEAT_BEGIN(pin) pinMode ( pin , OUTPUT )
#define UHEARTBEAT_UPDATE(pin, interval) static unsigned long updateMillis = millis(); if (millis() > updateMillis){ updateMillis += interval ; digitalWrite( pin , (digitalRead( pin ) == HIGH ? LOW : HIGH)); }
#define ULEDBEGIN pinMode(LED_BUILTIN, OUTPUT);
#define ULEDBLINK(x) for(uint8_t i = 0; i < x; i++){digitalWrite(LED_BUILTIN, HIGH);delay(10);digitalWrite(LED_BUILTIN, LOW);delay(150);}
#define ULEDON() digitalWrite(LED_BUILTIN,HIGH)
#define ULEDOFF() digitalWrite(LED_BUILTIN,LOW)
#define ULEDTOGGLE() digitalWrite(LED_BUILTIN,(digitalRead(LED_BUILTIN)==LOW?HIGH:LOW))
#define UARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
// Serial debugging macros for Arduino
#if defined (SERIAL_DEBUG)
#define UBEGIN(x) Serial.begin(x); //UDEBUGBEGIN is a macro, debug begin serial
#define UPRINT(...) Serial.print(__VA_ARGS__) //UPRINT is a macro, debug print
#define UPRINTLN(...) Serial.println(__VA_ARGS__) //UPRINTLN is a macro, debug print with new line
#define UPRINTF(...) Serial.printf(__VA_ARGS__)
#define USTREAM(...) Serial << __VA_ARGS__ //USTREAM is a macro, streams debug statements
#define UPRINTTAB Serial.print(F(" "))
#define UPRINTLNTAB Serial << endl << F(" ")
#define UPRINTLNPROMPT Serial << endl << F("> ")
#define UPRINTPROMPT Serial << F("> ")
#define UPRINTSPACER Serial << F ( "------------------------------------" ) << endl
// Console debugging macros for Arduino Yun
#elif defined(CONSOLE_DEBUG)
#define UBEGIN() Console.begin(); while (!Console) {} // See above
#define UPRINT(...) Console.print(__VA_ARGS__)
#define UPRINTLN(...) Console.println(__VA_ARGS__)
#define UPRINTF(...) Serial.printf(__VA_ARGS__)
#define USTREAM(...) Console << __VA_ARGS__
#define UPRINTTAB Console.print(F(" "))
#define UPRINTLNTAB Console << endl << F(" ")
#define UPRINTLNPROMPT Console << endl << F("> ")
#define UPRINTPROMPT Console << F("> ")
#define UPRINTSPACER Console << F ( "------------------------------------" ) << endl
// Serial debugging macros for ESP8266
#elif defined(ESP8266_DEBUG)
#define UBEGIN(x) Serial.begin(x); while (!Serial) {} // See above
#define UPRINT(...) Serial.print(__VA_ARGS__)
#define UPRINTLN(...) Serial.println(__VA_ARGS__)
#define UPRINTF(...) Serial.printf(__VA_ARGS__)
#define USTREAM(...) Serial << __VA_ARGS__
#define UPRINTTAB Serial.print(F(" "))
#define UPRINTLNTAB Serial << endl << F(" ")
#define UPRINTLNPROMPT Serial << endl << F("> ")
#define UPRINTPROMPT Serial << F("> ")
#define UPRINTSPACER Serial << F ( "------------------------------------" ) << endl
// Define blank lines to clear debugging statements during precompile
#else
#define UBEGIN(...)
#define UPRINT(...)
#define UPRINTLN(...)
#define UPRINTF(...)
#define USTREAM(...)
#define UPRINTTAB
#define UPRINTLNTAB
#define UPRINTLNPROMPT
#define UPRINTPROMPT
#define UPRINTSPACER
#endif
class WSUtility
{
private:
protected:
public:
// Print a number as 2 digits including leading zero
static void Print2Digits ( int number );
// Print a number as 2 digits including leading zero
static void Print2Digits ( int number, Print &output );
// Print a number as 3 digits including leading zero
static void Print3Digits ( int number );
// Print a number as 3 digits including leading zero
static void Print3Digits ( int number, Print &output );
// Print a number including leading zeros
static void PrintDigits ( int number, uint8_t digits );
// Print a number including leading zeros
static void PrintDigits ( int number, uint8_t digits, Print &output );
// Print a time_t value
static void PrintTime ( time_t tm );
// Print a time_t value
static void PrintTime ( time_t tm, Print &output );
// Print a tab
static void PrintTab();
// Print a tab
static void PrintTab ( Print &output );
// Print an 8 bit byte
static void PrintByte ( uint8_t b );
// Print an 8 bit byte
static void PrintByte ( uint8_t b, Print &output );
// Print a 16 bit word
static void PrintWord ( uint16_t b );
// Print a 16 bit word
static void PrintWord ( uint16_t b, Print &output );
// Print a spacer
static void PrintSpacer();
// Print a spacer
static void PrintSpacer ( Print &output );
// Print a number as HEX (could also just use UPRINT(n, HEX))
static void PrintHex ( uint8_t * buf, uint8_t len );
// Print a number as HEX (could also just use UPRINT(n, HEX))
static void PrintHex ( uint8_t * buf, uint8_t len, Print &output );
// Print the readable characters in a string
static void PrintReadableChars ( uint8_t *buf, uint8_t len );
// Print the readable characters in a string
static void PrintReadableChars ( uint8_t *buf, uint8_t len, Print &output );
// A small utility function to deselect SPI devices by setting
// their chipselect lines HIGH (otherwise the SPI devices will
// interfere with each other)
static void DeselectSPI ( const uint8_t *spi_cs_pins, uint8_t number_of_devices );
// Search for an I2C device - return true if detected
static bool FindWireDevice ( uint8_t addr, bool verbose = false );
#ifdef ESP8266
static void PrintSystemSpecs();
#endif
};
/*
class CircularBuffer_Uint8
{
protected:
uint8_t _buffersize;
uint8_t _bufferlen, _bufferhead, _buffertail;
uint8_t *_buffer;
public:
inline CircularBuffer_Uint8 ( uint8_t buffersize )
{
_bufferlen = 0;
_bufferhead = 0;
_buffertail = 0;
_buffersize = buffersize;
_buffer = new uint8_t[buffersize];
}
inline void Add ( uint8_t data )
{
// Is the buffer full and we need to overwrite oldest data?
if ( _bufferlen == _buffersize )
{
_bufferlen--;
_bufferhead = ( _bufferhead + 1 ) % _buffersize;
}
_buffer[_buffertail] = data;
_bufferlen++;
_buffertail = ( _buffertail + 1 ) % _buffersize;
}
inline uint8_t Size()
{
return _buffersize;
}
inline uint8_t Length()
{
return _bufferlen;
}
};
class CircularBuffer_Uint16
{
protected:
uint8_t _buffersize;
uint8_t _bufferlen, _bufferhead, _buffertail;
uint16_t *_buffer;
public:
inline CircularBuffer_Uint16 ( uint16_t buffersize )
{
_bufferlen = 0;
_bufferhead = 0;
_buffertail = 0;
_buffersize = buffersize;
_buffer = new uint16_t[buffersize];
}
inline void Add ( uint16_t data )
{
// Is the buffer full and we need to overwrite oldest data?
if ( _bufferlen == _buffersize )
{
_bufferlen--;
_bufferhead = ( _bufferhead + 1 ) % _buffersize;
}
_buffer[_buffertail] = data;
_bufferlen++;
_buffertail = ( _buffertail + 1 ) % _buffersize;
}
inline uint8_t Size()
{
return _buffersize;
}
inline uint8_t Length()
{
return _bufferlen;
}
};
*/
/* ====================================================================== */
// General purpose circular buffer for simple data types (e.g. chars)
// T = data type stored in this buffer
// L = index type e.g. uint8_t for buffer size of up to 255 elements
template<class T, class L> class UtilityBuffer
{
protected:
L _length, _first, _last, _available;
T *_buffer;
public:
inline UtilityBuffer ( L available )
{
_length = 0;
_first = 0;
_last = 0;
_available = available;
_buffer = new T[_available];
}
inline void Push ( T data )
{
// Is the buffer full and we need to overwrite oldest data?
// TODO add a switch to choose between overwriting oldest data, or discarding new data
if ( this->IsFull() )
{
_length--;
_first = ( _first + 1 ) % _length;
}
_buffer[_last] = data;
_length++;
_last = ( _last + 1 ) % _length;
}
inline T Pop ( void )
{
T data;
if ( _available > 0 )
{
data = _buffer[_first];
_first = ( _first - 1 ) % _length;
_length--;
}
return data;
}
inline T Peek ( void )
{
T data;
if ( _available > 0 )
{
data = _buffer[_first];
}
return data;
}
inline L Available()
{
return _available;
}
inline L Length()
{
return _length;
}
inline bool IsEmpty()
{
return ( _available == 0 );
}
inline bool IsFull()
{
return ( _available == _length );
}
};
/* ====================================================================== */
// General purpose queue for complex data types (e.g. user defined classes)
// T = data type stored in this buffer - MUST have the equals "=" operand implemented
// L = index type e.g. uint8_t for queue size of up to 255 elements
template<class T, class L> class UtilityQueue
{
private:
struct Node
{
T data;
Node *next;
};
Node *_first;
Node *_last;
uint8_t _available;
public:
inline UtilityQueue() : _first ( NULL ), _last ( NULL ), _available ( 0 )
{
}
inline ~UtilityQueue()
{
this->Clear();
}
inline void Clear()
{
Node *next;
while ( _first )
{
next = _first->next;
delete _first;
_first = next;
}
_first = _last = NULL;
_available = 0;
}
inline bool IsEmpty()
{
return ( _available == 0 );
}
inline uint8_t Available()
{
return _available;
}
inline void Push ( T data )
{
/*
Node newnode = new Node();
newnode.data = data;
newnode.next = NULL;
if ( IsEmpty() )
_first = newnode;
else
_last->next = newnode;
_last = newnode;
_available++;
*/
}
inline T Pop()
{
T data;
if ( !IsEmpty() )
{
data = _first->data;
Node *temp = _first;
if ( _first == _last )
_first = _last = NULL;
else
_first = _first->next;
delete temp;
_available--;
}
return data;
}
};
#endif // _UTILITY_H_
| 26.382212 | 209 | 0.59836 | [
"object"
] |
75da0b9ca4528feb1fa5872cd49abb8118f27310 | 675 | h | C | magneto_lib/types.h | s9w/ising2d | 16a8696637802b9c01186d0749f7a815c7650093 | [
"MIT"
] | 7 | 2016-05-23T19:41:19.000Z | 2021-05-06T16:43:36.000Z | magneto_lib/types.h | s9w/ising2d | 16a8696637802b9c01186d0749f7a815c7650093 | [
"MIT"
] | 1 | 2021-10-09T05:16:10.000Z | 2021-10-09T05:16:10.000Z | magneto_lib/types.h | s9w/ising2d | 16a8696637802b9c01186d0749f7a815c7650093 | [
"MIT"
] | 6 | 2015-05-15T06:25:14.000Z | 2021-03-08T12:59:52.000Z | #pragma once
#include <string>
#include <vector>
namespace magneto {
using IndexPairVector = std::vector<std::pair<int, int>>;
template<class T>
using LatticeTType = std::vector<std::vector<T>>;
using LatticeType = LatticeTType<char>;
using LatticeIType = LatticeTType<int>;
using LatticeDType = LatticeTType<double>;
template<class T>
std::pair<unsigned int, unsigned int> get_dimensions_of_lattice(const magneto::LatticeTType<T>& lattice) {
const unsigned int Ly = static_cast<unsigned int>(lattice.size());
const unsigned int Lx = static_cast<unsigned int>(lattice[0].size());
return { Lx, Ly };
}
}
| 29.347826 | 110 | 0.675556 | [
"vector"
] |
2f050a13b1ee6b023327ebb7778db2b1ee5407dd | 6,896 | h | C | agent/src/agent_win.h | chromium/content_analysis_sdk | 1a6e24f9ced8a4cf180ee7eafbc5fa0beb1046eb | [
"BSD-3-Clause"
] | null | null | null | agent/src/agent_win.h | chromium/content_analysis_sdk | 1a6e24f9ced8a4cf180ee7eafbc5fa0beb1046eb | [
"BSD-3-Clause"
] | 1 | 2022-03-30T21:06:11.000Z | 2022-03-30T21:06:11.000Z | agent/src/agent_win.h | chromium/content_analysis_sdk | 1a6e24f9ced8a4cf180ee7eafbc5fa0beb1046eb | [
"BSD-3-Clause"
] | 1 | 2022-03-14T23:15:39.000Z | 2022-03-14T23:15:39.000Z | // Copyright 2022 The Chromium Authors.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_ANALYSIS_AGENT_SRC_AGENT_WIN_H_
#define CONTENT_ANALYSIS_AGENT_SRC_AGENT_WIN_H_
#include <windows.h>
#include <memory>
#include <sstream>
#include <string>
#include <vector>
#include "agent_base.h"
namespace content_analysis {
namespace sdk {
// Agent implementaton for Windows.
class AgentWin : public AgentBase {
public:
// Creates a new agent given the specific configuration and handler.
// If an error occurs during creation, `rc` is set to the specific
// error. Otherwise `rc` is ResultCode::OK.
AgentWin(Config config, std::unique_ptr<AgentEventHandler> handler,
ResultCode* rc);
~AgentWin() override;
// Agent:
ResultCode HandleEvents() override;
ResultCode Stop() override;
std::string DebugString() const override;
// Handles one pipe event and returns. Used only in tests.
ResultCode HandleOneEventForTesting();
// Returns true if there is at least one client connected to this agent.
bool IsAClientConnectedForTesting();
private:
// Represents one connection to a Google Chrome browser, or one pipe
// listening for a Google Chrome browser to connect.
class Connection {
public:
// Starts listening on a pipe with the given name. `is_first_pipe` should
// be true only for the first pipe created by the agent. If an error
// occurs while creating the connction object it is returned in `rc`.
// If no errors occur then rc is set to ResultCode::OK.
//
// `Connection` objects cannot be copied or moved because the OVERLAPPED
// structure cannot be changed or moved in memory while an I/O operation
// is in progress.
Connection(const std::string& pipename,
AgentEventHandler* handler,
bool is_first_pipe,
ResultCode* rc);
Connection(const Connection& other) = delete;
Connection(Connection&& other) = delete;
Connection& operator=(const Connection& other) = delete;
Connection& operator=(Connection&& other) = delete;
~Connection();
bool IsValid() const { return handle_ != INVALID_HANDLE_VALUE; }
bool IsConnected() const { return is_connected_; }
HANDLE GetWaitHandle() const { return overlapped_.hEvent; }
// Resets this connection object to listen for a new Google Chrome browser.
ResultCode Reset(const std::string& pipename);
// Hnadles an event for this connection. `wait_handle` corresponds to
// this connections wait handle.
ResultCode HandleEvent(HANDLE wait_handle);
// Append debuf information to the string stream.
void AppendDebugString(std::stringstream& state) const;
private:
// Listens for a new connection from Google Chrome.
ResultCode ConnectPipe();
// Resets this connection object to listen for a new Google Chrome browser.
ResultCode ResetInternal(const std::string& pipename, bool is_first_pipe);
// Cleans up this connection object so that it can be reused with a new
// Google Chroem browser instance. The handles assocated with this object
// are not closed. On return, this object is neither connected nor
// listening and any buffer used to hold browser messages are cleared.
void Cleanup();
// Queues a read on the pipe to receive a message from Google Chrome.
// ERROR_SUCCESS, ERROR_IO_PENDING, and ERROR_MORE_DATA are successful
// return values. Other values represent an error with the connection.
// If `reset_cursor` is true the internal read buffer cursor is reset to
// the start of the buffer, otherwise it is unchanged.
ResultCode QueueReadFile(bool reset_cursor);
// Called when data from Google Chrome is available for reading from the
// pipe. ERROR_SUCCESS and ERROR_MORE_DATA are both successful return
// values. Other values represent an error with the connection.
//
// `done_reading` is true if the code has finished reading an entire message
// from chrome. Regardless of whether reading is done, `count` contains
// the number of bytes read.
//
// If `done_reading` is true, the data received from the browser is parsed
// as if it were a `ChromeToAgent` proto message and the handler is called
// as needed.
//
// If `done_reading` is false, the data received from the browser is
// appended to the data already received from the browser. `buffer_` is
// resized to allow reading more data from the browser.
//
// In all cases the caller is expected to use QueueReadFile() to continue
// reading data from the browser.
ResultCode OnReadFile(BOOL done_reading, DWORD count);
// Calls the appropriate method the handler depending on the message
// received from Google Chrome.
ResultCode CallHandler();
// Fills in the browser_info_ member of this Connection. Assumes
// IsConnected() is true.
ResultCode BuildBrowserInfo();
// The handler to call for various agent events.
AgentEventHandler* handler_ = nullptr;
// Members used to communicate with Google Chrome.
HANDLE handle_ = INVALID_HANDLE_VALUE;
OVERLAPPED overlapped_;
// True if this connection is assigned to a specific Google Chrome browser,
// otherwise this connection is listening for a new browser.
bool is_connected_ = false;
// Information about the Google Chrome browser process.
BrowserInfo browser_info_;
// Members used to read messages from Google Chrome.
std::vector<char> buffer_;
char* cursor_ = nullptr;
DWORD read_size_ = 0;
DWORD final_size_ = 0;
};
// Returns handles that can be used to wait for events from all handles
// managed by this agent. This includes all connection objects and the
// stop event. The stop event is always last in the list.
void GetHandles(std::vector<HANDLE>& wait_handles) const;
// Handles one pipe event and returns. If the return value is
// ResultCode::OK, the `stopped` argument is set to true if the agent
// should stop handling more events. If the return value is not
// ResultCode::OK, `stopped` is undefined.
ResultCode HandleOneEvent(std::vector<HANDLE>& wait_handles, bool* stopped);
// Performs a clean shutdown of the agent.
void Shutdown();
// Name used to create the pipes between the agent and Google Chrome browsers.
std::string pipename_;
// A list of pipes to already connected Google Chrome browsers.
// The first kNumPipeInstances pipes in the list correspond to listening
// pipes.
std::vector<std::unique_ptr<Connection>> connections_;
// An event that is set when the agent should stop. Set in Stop().
HANDLE stop_event_ = nullptr;
};
} // namespace sdk
} // namespace content_analysis
#endif // CONTENT_ANALYSIS_AGENT_SRC_AGENT_WIN_H_
| 38.960452 | 80 | 0.719548 | [
"object",
"vector"
] |
2f0ec90ac4e5f4d3626d5d2778fb4dcea103bef8 | 1,548 | h | C | apps/memkv/src/db.h | neverchanje/consensus-yaraft | 4138c85d999205068350f9b5caedf5a16ff576a3 | [
"Apache-2.0"
] | 33 | 2017-07-26T05:39:37.000Z | 2020-11-16T07:47:18.000Z | apps/memkv/src/db.h | neverchanje/yaraft-wal | 4138c85d999205068350f9b5caedf5a16ff576a3 | [
"Apache-2.0"
] | null | null | null | apps/memkv/src/db.h | neverchanje/yaraft-wal | 4138c85d999205068350f9b5caedf5a16ff576a3 | [
"Apache-2.0"
] | 8 | 2017-08-02T20:16:19.000Z | 2021-09-30T14:58:51.000Z | // Copyright 2017 Wu Tao
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <map>
#include "slice.h"
#include "status.h"
#include <brpc/server.h>
#include <consensus/raft_service.h>
#include <consensus/replicated_log.h>
namespace memkv {
// Abstract handle to particular state of a DB.
// A Snapshot is an immutable object and can therefore be safely
// accessed from multiple threads without any external synchronization.
class Snapshot {
protected:
virtual ~Snapshot();
};
class DBOptions {
public:
uint64_t member_id;
std::string wal_dir;
std::map<uint64_t, std::string> initial_cluster;
};
class DB {
public:
static StatusWith<DB *> Bootstrap(const DBOptions &options);
Status Write(const Slice &path, const Slice &value);
Status Delete(const Slice &path);
Status Get(const Slice &path, bool stale, std::string *data);
consensus::pb::RaftService *CreateRaftServiceInstance() const;
DB();
~DB();
private:
class Impl;
std::unique_ptr<Impl> impl_;
};
} // namespace memkv | 24.1875 | 75 | 0.728682 | [
"object"
] |
2f10a014bdb1d29f4e38c9ea5b55aa73a7b9e9bd | 2,485 | h | C | src/C/MQM/mqmprob.h | kbroman/qtlHD | d4df4fa318792e9a223f71cbb5b3a7a55c74e3ec | [
"BSD-2-Clause-FreeBSD"
] | 1 | 2019-04-25T11:46:10.000Z | 2019-04-25T11:46:10.000Z | src/C/MQM/mqmprob.h | kbroman/qtlHD | d4df4fa318792e9a223f71cbb5b3a7a55c74e3ec | [
"BSD-2-Clause-FreeBSD"
] | null | null | null | src/C/MQM/mqmprob.h | kbroman/qtlHD | d4df4fa318792e9a223f71cbb5b3a7a55c74e3ec | [
"BSD-2-Clause-FreeBSD"
] | null | null | null | /**********************************************************************
*
* mqmprob.h
*
* Copyright (c) 1996-2009 by
* Ritsert C Jansen, Danny Arends, Pjotr Prins and Karl W Broman
*
* initial MQM C code written between 1996-2002 by Ritsert C. Jansen
* improved for the R-language by Danny Arends, Pjotr Prins and Karl W. Broman
*
* Modified by Danny Arends and Pjotr Prins
* last modified September 2009
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License,
* version 3, as published by the Free Software Foundation.
*
* 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, version 3, for more details.
*
* A copy of the GNU General Public License, version 3, is available
* at http://www.r-project.org/Licenses/GPL-3
*
* C functions for the R/qtl package
*
**********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
cvector relative_marker_position(const unsigned int nmark,const ivector chr);
vector recombination_frequencies(const unsigned int nmark, const cvector position, const vector mapdistance);
double recombination_frequentie(const double cmdistance);
void validate_markertype(const MQMCrossType crosstype, const char markertype);
//double probright(const char c, const int j, const cvector imarker, const vector rs, const cvector position,const MQMCrossType crosstype);
double left_prob(const double r, const MQMMarker markerL,const MQMMarker markerR,const MQMCrossType crosstype);
double right_prob_F2(const char markerL, const int j, const MQMMarkerVector imarker, const vector rs, const cvector position);
double right_prob_BC(const char markerL, const int j, const MQMMarkerVector imarker, const vector rs, const cvector position);
double right_prob_RIL(const char markerL, const int j, const MQMMarkerVector imarker, const vector rs, const cvector position);
//double prob(const cmatrix loci, const vector rs, const int i, const int j, const char markertype, const MQMCrossType crosstype, const int ADJ);
double start_prob(const MQMCrossType crosstype,MQMMarker markertype);
bool is_knownMarker(const char marker,const MQMCrossType crosstype);
#ifdef __cplusplus
}
#endif
/* end of mqmprob.h */
| 44.375 | 145 | 0.723944 | [
"vector"
] |
2f15487ce6f63d7a9ac9046f5cf3a6f8ac03ca9c | 1,796 | h | C | mbed_project_Inverted-Pendulum_P/Sound.h | Dansato1203/3s_RobotDesign2 | b740eee1ddbd0254360cc140effac8011cfafd0b | [
"MIT"
] | null | null | null | mbed_project_Inverted-Pendulum_P/Sound.h | Dansato1203/3s_RobotDesign2 | b740eee1ddbd0254360cc140effac8011cfafd0b | [
"MIT"
] | null | null | null | mbed_project_Inverted-Pendulum_P/Sound.h | Dansato1203/3s_RobotDesign2 | b740eee1ddbd0254360cc140effac8011cfafd0b | [
"MIT"
] | null | null | null | // Chiba Institute of Technology
#ifndef MBED_SOUND_H
#define MBED_SOUND_H
#include "mbed.h"
#include "SoftwarePWM.h"
/** Class to control a motor on any pin, without using pwm pin
*
* Example:
* @code
* // Motor Control
* #include "mbed.h"
* #include "Sound.h"
*
* Motor motor(xp31, xp32, xp33);
* Motor motor(xp34, xp35, xp36);
*
* int main(){
* while(1) {
* for (int pos = 1000; pos < 2000; pos += 25) {
* Servo1.SetPosition(pos);
* wait_ms(20);
* }
* for (int pos = 2000; pos > 1000; pos -= 25) {
* Servo1.SetPosition(pos);
* wait_ms(20);
* }
* }
* @endcode
*/
typedef enum{
C2 = 130,
D2 = 146,
E2 = 164,
F2 = 174,
G2 = 195,
A3 = 220,
B3 = 246,
C4 = 261,
D4 = 293,
E4 = 329,
F4 = 349,
G4 = 391,
A4 = 440,
B4 = 493,
C5 = 523,
D5 = 587,
E5 = 659,
F5 = 698,
G5 = 783,
A5 = 880,
B5 = 987,
C6 = 1046,
D6 = 1174,
E6 = 1328,
F6 = 1396,
G6 = 1567,
A6 = 1760,
B6 = 1975,
} freq;
class Sound
{
public:
/** Create a new SoftwarePWM object on any mbed pin
*
* @param Pin Pin on mbed to connect PWM device to
*/
Sound(PinName Ppwm);
void setPeriod(float seconds);
void write(float value);
float read();
#ifdef MBED_OPERATORS
/** A operator shorthand for write()
*/
Sound& operator= (float value) {
write(value);
return *this;
}
Sound& operator= (Sound& rhs) {
write(rhs.read());
return *this;
}
/** An operator shorthand for read()
*/
operator float() {
return read();
}
#endif
private:
SoftwarePWM SoftwarePWMPin;
float frequency;
float period;
};
#endif
| 16.785047 | 63 | 0.517261 | [
"object"
] |
2f16dbbbd803657193aa5cfc2f8f475b0c7e1639 | 2,341 | h | C | utilities/SimpleRTK/Code/IO/include/srtkImageFileReader.h | ldqcarbon/RTK | 88df8ed953805aca3c5a73c22cb940164e7cc296 | [
"Apache-2.0",
"BSD-3-Clause"
] | null | null | null | utilities/SimpleRTK/Code/IO/include/srtkImageFileReader.h | ldqcarbon/RTK | 88df8ed953805aca3c5a73c22cb940164e7cc296 | [
"Apache-2.0",
"BSD-3-Clause"
] | null | null | null | utilities/SimpleRTK/Code/IO/include/srtkImageFileReader.h | ldqcarbon/RTK | 88df8ed953805aca3c5a73c22cb940164e7cc296 | [
"Apache-2.0",
"BSD-3-Clause"
] | null | null | null | /*=========================================================================
*
* Copyright Insight Software Consortium & RTK Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef __srtkImageFileReader_h
#define __srtkImageFileReader_h
#include "srtkMacro.h"
#include "srtkImage.h"
#include "srtkImageReaderBase.h"
#include "srtkMemberFunctionFactory.h"
namespace rtk {
namespace simple {
/** \class ImageFileReader
* \brief Read a 2D or 3D image and return a smart pointer to a SimpleRTK
* image
*
* This reader handles scalar and vector images and returns an image with
* the same type as the file on disk.
*
* \sa rtk::simple::ReadImage for the procedural interface
*/
class SRTKIO_EXPORT ImageFileReader
: public ImageReaderBase
{
public:
typedef ImageFileReader Self;
/** Print ourselves to string */
virtual std::string ToString() const;
/** return user readable name fo the filter */
virtual std::string GetName() const { return std::string("ImageFileReader"); }
Self& SetFileName ( std::string fn );
std::string GetFileName() const;
Image Execute();
ImageFileReader();
protected:
template <class TImageType> Image ExecuteInternal ( void );
private:
// function pointer type
typedef Image (Self::*MemberFunctionType)( void );
// friend to get access to executeInternal member
friend struct detail::MemberFunctionAddressor<MemberFunctionType>;
std::auto_ptr<detail::MemberFunctionFactory<MemberFunctionType> > m_MemberFactory;
std::string m_FileName;
};
SRTKIO_EXPORT Image ReadImage ( std::string filename );
}
}
#endif
| 30.402597 | 88 | 0.648868 | [
"vector",
"3d"
] |
2f1a30913de35870e759834b5c9140f166b7d2bb | 3,227 | h | C | MCUME/teensydoom/ff.h | DigiTorus86/Teensy-R4ge-Pro | d94a73f4f60957b3f28a27b7d6f74b01a61121fa | [
"MIT"
] | 1 | 2022-01-13T02:00:52.000Z | 2022-01-13T02:00:52.000Z | MCUME/teensydoom/ff.h | DigiTorus86/Teensy-R4ge-Pro | d94a73f4f60957b3f28a27b7d6f74b01a61121fa | [
"MIT"
] | null | null | null | MCUME/teensydoom/ff.h | DigiTorus86/Teensy-R4ge-Pro | d94a73f4f60957b3f28a27b7d6f74b01a61121fa | [
"MIT"
] | 1 | 2022-01-11T12:55:50.000Z | 2022-01-11T12:55:50.000Z |
#ifndef _FFWRAP
#define _FFWRAP
typedef int * FIL;
#define FA_READ 0x01 /* Specifies read access to the object. Data can be read from the file. Combine with FA_WRITE for read-write access. */
#define FA_OPEN_EXISTING 0x00 /* Opens the file. The function fails if the file is not existing. (Default) */
#define FA_WRITE 0x02 /* Specifies write access to the object. Data can be written to the file. Combine with FA_READ for read-write access. */
#define FA_CREATE_NEW 0x04 /* Creates a new file. The function fails with FR_EXIST if the file is existing. */
#define FA_CREATE_ALWAYS 0x08 /* Creates a new file. If the file is existing, it will be truncated and overwritten. */
#define FA_OPEN_ALWAYS 0x10 /* Opens the file if it is existing. If not, a new file is created. */
#define FA__WRITTEN 0x20
#define FA__DIRTY 0x40
typedef enum {
FR_OK = 0, /* (0) Succeeded */
FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */
FR_INT_ERR, /* (2) Assertion failed */
FR_NOT_READY, /* (3) The physical drive cannot work */
FR_NO_FILE, /* (4) Could not find the file */
FR_NO_PATH, /* (5) Could not find the path */
FR_INVALID_NAME, /* (6) The path name format is invalid */
FR_DENIED, /* (7) Access denied due to prohibited access or directory full */
FR_EXIST, /* (8) Access denied due to prohibited access */
FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */
FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */
FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */
FR_NOT_ENABLED, /* (12) The volume has no work area */
FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */
FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */
FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */
FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */
FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */
FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */
FR_INVALID_PARAMETER /* (19) Given parameter is invalid */
} FRESULT;
typedef struct {
signed long fsize; /* File size */
signed short fdate; /* Last modified date */
signed short ftime; /* Last modified time */
signed char fattrib; /* Attribute */
char * fname[13]; /* Short file name (8.3 format) */
} FILINFO;
#ifdef __cplusplus
extern "C" {
#endif
FRESULT f_open (FIL* fp, const char * path, unsigned char mode);
FRESULT f_close (FIL* fp);
FRESULT f_read (FIL* fp, void* buff, unsigned int btr, unsigned int * br);
FRESULT f_readn (FIL* fp, void* buff, unsigned int btr, unsigned int * br);
FRESULT f_write (FIL* fp, const void* buff, unsigned int btw, unsigned int * bw);
FRESULT f_writen (FIL* fp, const void* buff, unsigned int btw, unsigned int * bw);
FRESULT f_lseek (FIL* fp, unsigned long ofs);
FRESULT f_unlink (const char * path);
FRESULT f_rename (const char * path_old, const char * path_new);
FRESULT f_stat (const char * path, FILINFO* fno);
FRESULT f_mkdir (const char* path);
unsigned long f_tell (FIL * fp);
unsigned long f_size (FIL * fp);
#ifdef __cplusplus
}
#endif
#endif
| 44.205479 | 144 | 0.705299 | [
"object"
] |
2f2364070f8693e735883d2c65708ecd763a0bac | 2,715 | h | C | src/ExtLib/MediaInfo/MediaInfo/Audio/File_Dts.h | chinajeffery/MPC-BE--1.2.3 | 2229fde5535f565ba4a496a7f73267bd2c1ad338 | [
"MIT"
] | null | null | null | src/ExtLib/MediaInfo/MediaInfo/Audio/File_Dts.h | chinajeffery/MPC-BE--1.2.3 | 2229fde5535f565ba4a496a7f73267bd2c1ad338 | [
"MIT"
] | 1 | 2019-11-14T04:18:32.000Z | 2019-11-14T04:18:32.000Z | src/ExtLib/MediaInfo/MediaInfo/Audio/File_Dts.h | chinajeffery/MPC-BE--1.2.3 | 2229fde5535f565ba4a496a7f73267bd2c1ad338 | [
"MIT"
] | null | null | null | /* Copyright (c) MediaArea.net SARL. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license that can
* be found in the License.html file in the root of the source tree.
*/
//---------------------------------------------------------------------------
#ifndef MediaInfo_DtsH
#define MediaInfo_DtsH
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#include "MediaInfo/File__Analyze.h"
#ifdef ES
#undef ES //Solaris defines this somewhere
#endif
//---------------------------------------------------------------------------
namespace MediaInfoLib
{
//***************************************************************************
// Class File_Dts
//***************************************************************************
class File_Dts : public File__Analyze
{
public :
//In
int64u Frame_Count_Valid;
//Constructor/Destructor
File_Dts();
private :
//Streams management
void Streams_Fill();
void Streams_Finish();
//Buffer - File header
bool FileHeader_Begin();
//Buffer - Synchro
bool Synchronize();
bool Synched_Test();
void Read_Buffer_Unsynched();
//Buffer - Demux
#if MEDIAINFO_DEMUX
bool Demux_UnpacketizeContainer_Test();
#endif //MEDIAINFO_DEMUX
//Buffer - Per element
void Header_Parse();
void Data_Parse();
//Elements
void Core();
void Core_XCh(int64u Size);
void Core_XXCh(int64u Size);
void Core_X96k(int64u Size);
void HD();
void HD_XCh(int64u Size);
void HD_XXCh(int64u Size);
void HD_X96k(int64u Size);
void HD_XLL(int64u Size);
void HD_XBR(int64u Size);
void HD_XSA(int64u Size);
//Buffer
bool FrameSynchPoint_Test();
const int8u* Save_Buffer;
size_t Save_Buffer_Offset;
size_t Save_Buffer_Size;
//Temp
std::vector<ZenLib::int32u> Asset_Sizes;
Ztring Profile;
int32u Original_Size;
int32u HD_size;
int16u Primary_Frame_Byte_Size;
int16u Number_Of_PCM_Sample_Blocks;
int16u HD_SpeakerActivityMask;
int8u channel_arrangement;
int8u channel_arrangement_XCh;
int8u sample_frequency;
int8u sample_frequency_X96k;
int8u bit_rate;
int8u lfe_effects;
int8u bits_per_sample;
int8u ExtensionAudioDescriptor;
int8u HD_BitResolution;
int8u HD_MaximumSampleRate;
int8u HD_TotalNumberChannels;
int8u HD_ExSSFrameDurationCode;
bool ExtendedCoding;
bool Word;
bool BigEndian;
bool ES;
bool Core_Exists;
//Helpers
float64 BitRate_Get(bool WithHD=false);
};
} //NameSpace
#endif
| 24.908257 | 77 | 0.572744 | [
"vector"
] |
2f2d8212ca61c9ddad70d0fb8d387ddf8de3aa3e | 998 | c | C | d/dagger/Torm/road/path1.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 13 | 2019-07-19T05:24:44.000Z | 2021-11-18T04:08:19.000Z | d/dagger/Torm/road/path1.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 4 | 2021-03-15T18:56:39.000Z | 2021-08-17T17:08:22.000Z | d/dagger/Torm/road/path1.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 13 | 2019-09-12T06:22:38.000Z | 2022-01-31T01:15:12.000Z | #include <std.h>
inherit ROOM;
void create() {
::create();
set_terrain(SCRUB_LANDS);
set_travel(DIRT_ROAD);
set_property("light", 2);
// set_property("no teleport", 1);
//Don't know why in the world this was set...
//removing it ~Circe~ 4/27/08
set_short("Path to Torm");
set_long(
"%^CYAN%^"
"You are approaching the great Dagger seaport of Torm."
" To the southeast you can see the great town on the solid land, with its boardwalk along the ocean leading to the docks."
" Many boats are in several stages of movement, from docking to waiting to leaving for the great open waters."
" A dark forest lies to the south along the path to the city and it makes you wonder if you want to pass it."
);
set_items(([
"boardwalk" : "It is long and, well, wooden.",
"boats" : "They are those things that hold people and float on water.",
]));
set_exits(([
"north" : "/d/dagger/road/road16",
"south" : "/d/dagger/Torm/road/path2",
]));
}
| 32.193548 | 125 | 0.658317 | [
"solid"
] |
2f2f0c4c27f0cb3fa1b06eec7eb5a642ab96bba9 | 901 | h | C | final-project/src/Song.h | babichjacob/ECE-270-Final-Project | 9e4f226dc1e4a96e91a67b2f223125cf116af1ee | [
"MIT"
] | null | null | null | final-project/src/Song.h | babichjacob/ECE-270-Final-Project | 9e4f226dc1e4a96e91a67b2f223125cf116af1ee | [
"MIT"
] | null | null | null | final-project/src/Song.h | babichjacob/ECE-270-Final-Project | 9e4f226dc1e4a96e91a67b2f223125cf116af1ee | [
"MIT"
] | null | null | null | #pragma once
#include <filesystem>
#include <fstream>
#include "csv.h"
#include "ID3v2.h"
constexpr auto MUSIC_DIR = "bin/data/music";
constexpr auto CACHE_DIR = "bin/data/.MyTunes/cache";
namespace fs = std::experimental::filesystem;
using std::cout;
using std::endl;
using std::ifstream;
using std::invalid_argument;
using std::ofstream;
using std::runtime_error;
class Song
{
private:
fs::path cache_file_path;
void save_to_cache();
void set_from_cache(fs::path path);
void set_from_file(fs::path path);
public:
string title;
string album;
string artist;
string genre;
// Ex 4 (out of the total number of songs in the album)
int track_of_album;
int year;
// Out of order because this was added after the fact
string album_artist;
fs::path artwork_file_path;
fs::path music_file_path;
Song();
Song(fs::path path);
~Song();
void print();
};
typedef vector<Song> Songs; | 17.326923 | 56 | 0.72808 | [
"vector"
] |
2f34e6b9175d4827bc3818ec1ba42e32995cd98d | 5,937 | h | C | realizer/vrendererdx9.h | codetorex/realizer | adb06d3138cc039764c0859177a669fa485578bf | [
"MIT"
] | null | null | null | realizer/vrendererdx9.h | codetorex/realizer | adb06d3138cc039764c0859177a669fa485578bf | [
"MIT"
] | null | null | null | realizer/vrendererdx9.h | codetorex/realizer | adb06d3138cc039764c0859177a669fa485578bf | [
"MIT"
] | null | null | null |
#ifndef VRENDERERDX9_H
#define VRENDERERDX9_H
#include "tstring.h"
#include "tbitmap.h"
#include "cwindows.h" // this renderer is windows only
#include "vvertexstream.h"
#include "mmatrix.h"
#include "vmesh.h"
#include "vvertexbufferformat.h"
class RDLL VRendererDX9: public CRendererWindow
{
public:
LPDIRECT3DDEVICE9 D3DDevice; // D3D_Device
LPDIRECT3D9 D3D; // D3D_Object
private:
bool InitializeDirect3D();
void DestroyDirect3D();
D3DFORMAT BitmapToD3DFormat(ui32 bmpFormat);
public:
static void InitializeFormats();
bool InitializeRenderer(int _width,int _height,const String& _title,bool fullscr,int bits);
inline void Clear(ui32 flags, ui32 color)
{
D3DDevice->Clear(0, NULL,flags,color,1.0f,0);
}
inline void Clear(ui32 flags)
{
Clear(flags,0);
}
inline void BeginScene()
{
D3DDevice->BeginScene();
}
inline void EndScene()
{
D3DDevice->EndScene();
}
inline void SwapBackBuffer()
{
D3DDevice->Present(NULL, NULL, NULL, NULL);
}
inline rtex LoadTextureFromFile(ch8* filepath)
{
LPDIRECT3DTEXTURE9 rt;
D3DXCreateTextureFromFileA(D3DDevice,filepath,&rt);
return rt;
}
inline void DeleteTexture(rtex txtr)
{
txtr->Release();
}
inline void SetTexture(int stage,rtex txtr)
{
D3DDevice->SetTexture(stage,txtr);
}
inline void SetTextureFilter(int stage, int filterType, int value)
{
D3DDevice->SetSamplerState(stage,(D3DSAMPLERSTATETYPE)filterType,value);
}
/**
* DirectX has different texture coordinate than OpenGL so we can use this to conver them?
*/
inline void ProcessTextureCoordinate(Vector3& input)
{
input.y = 1.0f - input.y;
}
/*inline void SetTextureState(int stage, int stateType, int value)
{
}*/
inline void EnableTexturing(int stage)
{
D3DDevice->SetTextureStageState(stage,D3DTSS_COLOROP, D3DTOP_MODULATE);
}
inline void EnableTextureAlphaVertexColorAlpha(int stage)
{
D3DDevice->SetTextureStageState(stage, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
/*
Basically
Direct3D.TextureState(0).ColorOperation = Direct3D.TextureOperation.Modulate
Direct3D.TextureState(0).ColorArgument1 = Direct3D.TextureArgument.TextureColor
Direct3D.TextureState(0).ColorArgument2 = Direct3D.TextureArgument.Diffuse
Direct3D.TextureState(0).AlphaOperation = Direct3D.TextureOperation.Modulate
*/
}
inline void DisableTexturing(int stage)
{
D3DDevice->SetTextureStageState(stage, D3DTSS_COLOROP, D3DTOP_DISABLE);
}
/**
* We should get rid of FVF ASAP!!!
*/
inline void RenderMesh(VMesh* mesh)
{
D3DDevice->SetStreamSource(0,mesh->Vertices->BufferObject,0,mesh->Vertices->BufferFormat->BytesPerItem);
D3DDevice->SetFVF(((VVertexBufferFormat*)(mesh->Vertices->BufferFormat))->FormatDescriptor);
D3DDevice->DrawPrimitive((D3DPRIMITIVETYPE)mesh->MeshType,0,mesh->PrimitiveCount);
}
inline void RenderVertexBuffer(VVertexBuffer* buffer)
{
}
inline rvbf CreateVertexBuffer(VVertexBuffer* buffer, int capacity)
{
VVertexBufferFormat* bfmt = ((VVertexBufferFormat*)(buffer->BufferFormat));
LPDIRECT3DVERTEXBUFFER9 g_pVertexBuffer = NULL;
D3DDevice->CreateVertexBuffer(capacity,0,bfmt->FormatDescriptor,D3DPOOL_DEFAULT,&g_pVertexBuffer, NULL);
buffer->BufferObject = g_pVertexBuffer;
return g_pVertexBuffer;
}
inline void DeleteVertexBuffer(VVertexBuffer* buffer)
{
LPDIRECT3DVERTEXBUFFER9 g_pVertexBuffer = buffer->BufferObject;
g_pVertexBuffer->Release();
}
inline void LockVertexBuffer(VVertexBuffer* buffer, int offset, int length)
{
LPDIRECT3DVERTEXBUFFER9 g_pVertexBuffer = buffer->BufferObject;
void* k;
g_pVertexBuffer->Lock(offset,length,&k,NULL);
buffer->Data = (byte*)k;
}
inline void UnlockVertexBuffer(VVertexBuffer* buffer)
{
LPDIRECT3DVERTEXBUFFER9 g_pVertexBuffer = buffer->BufferObject;
g_pVertexBuffer->Unlock();
}
inline void SetView(const mat4& matrix)
{
D3DDevice->SetTransform(D3DTS_VIEW, (D3DXMATRIX*)&matrix);
}
inline void SetProjection(const mat4& matrix)
{
D3DDevice->SetTransform(D3DTS_PROJECTION,(D3DXMATRIX*)&matrix);
}
inline void SetDepthTest(bool enabled)
{
D3DDevice->SetRenderState(D3DRS_ZENABLE,enabled);
}
inline void SetWorld(const mat4& matrix)
{
D3DDevice->SetTransform(D3DTS_WORLD,(D3DXMATRIX*)&matrix);
}
/**
* Enables 2D rendering mode, thats good for rendering hud, gui and on screen stuff.
*/
inline void Enter2D()
{
MProjectionMatrix mOrtho;
mOrtho.OrthoOffCenterR(0,(float)vWidth,(float)vHeight,0.0f,0.0f,1.0f);
SetProjection(mOrtho);
SetDepthTest(false);
// save old projection ,view and world matrices
}
inline void Exit2D()
{
// restore old projection, view and world matrices
// set depth test back?
}
inline void EnableBlending(ui32 src = RL_SRCALPHA,ui32 dst = RL_INVSRCALPHA)
{
D3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
D3DDevice->SetRenderState( D3DRS_SRCBLEND, src );
D3DDevice->SetRenderState( D3DRS_DESTBLEND, dst );
}
inline void DisableBlending()
{
D3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
}
inline void EnableScissor(const IRectangle& clipRect)
{
RECT cwinRect;
cwinRect.left = clipRect.X;
cwinRect.top = clipRect.Y;
cwinRect.right = clipRect.Right();
cwinRect.bottom = clipRect.Bottom();
D3DDevice->SetScissorRect(&cwinRect);
D3DDevice->SetRenderState( D3DRS_SCISSORTESTENABLE, TRUE );
}
inline void DisableScissor()
{
D3DDevice->SetRenderState( D3DRS_SCISSORTESTENABLE, FALSE );
}
rtex LoadTextureFromBitmap(TBitmap* bmp, bool automipmap = true);
void UpdateTextureFromBitmap(rtex tx, TBitmap* bmp);
// Functions that shouldn't be needed to implemented by other drivers
private:
void LoadSurfaceFromBitmap( void* surf, TBitmap* bmp);
};
#endif | 25.480687 | 107 | 0.72444 | [
"mesh"
] |
2f5382fec25a555617ae04d54f47c34d880eba1c | 6,608 | h | C | GUI/KMapSolver/filterkmapresults.h | manashmndl/KMapSolver | 8144513dbade499d9dafe1b378ffa6cc0e25810a | [
"Apache-2.0"
] | 11 | 2016-09-18T17:09:36.000Z | 2018-09-21T19:06:21.000Z | Console/KMapSolver/filterkmapresults.h | manashmndl/KMapSolver | 8144513dbade499d9dafe1b378ffa6cc0e25810a | [
"Apache-2.0"
] | 4 | 2016-09-15T11:45:42.000Z | 2016-09-17T10:22:16.000Z | GUI/KMapSolver/filterkmapresults.h | manashmndl/KMapSolver | 8144513dbade499d9dafe1b378ffa6cc0e25810a | [
"Apache-2.0"
] | 3 | 2016-10-08T14:39:24.000Z | 2018-10-02T16:41:32.000Z | #ifndef FILTERKMAPRESULTS
#define FILTERKMAPRESULTS
#include "operation.h"
//this class is using for filtering results and giving
//all possibilites results
class FilterKmapTerms : public CompareKmapTerms, public ConverteTerms, public Combination
{
protected:
int temp, temp1, temp2, temp3; //temprature variables
vector<char> getTerm (vector<char> &result, int pos); //getting a term form an array
int getMintermCount(vector<char> &term);
int getLargestTermSize(vector<char> &result);
vector <vector<char>> getFilterResult(vector<vector < char>> &results, vector<char> &essentialTerms);
bool checkResult (vector<char> someResult, vector<int> ones );
vector <vector<char>> filter (vector<char> &result, vector<int> ones);
};//end filterKmapTerms
/***
The main function of the program that implement K-map by:
1- prompting for k-map type by its variable's number
2- prompting for one's position by getPos function
3- prompting for don't care position by getPos function
4- Minimizing and getting results
*/
//get a term from a vector of terms (result)
vector<char> FilterKmapTerms :: getTerm (vector<char> &result, int pos)
{
int temp;
vector<char> term;
for(temp = pos; temp < result.size(); temp++)
{
if(result[temp] != '+')
term.push_back(result[temp]);
else
break;
}
return term;
}//end getTerm
//Determine the larget size of minterms
int FilterKmapTerms :: getLargestTermSize(vector<char> &result)
{
int largestSize = 0;
vector<char> term;
for(int temp = 0; temp <result.size(); temp += term.size() + 1)
{
term = getTerm(result, temp);
if(getMintermCount(term) > largestSize)
largestSize = getMintermCount(term);
}//end for
return largestSize;
}//end get Largest Term size
//return a term's minterms count
int FilterKmapTerms :: getMintermCount(vector<char> &term)
{
int count = 0; //for return
for(int temp = 0; temp < term.size(); temp++)
{
if(isalpha(term[temp]) ) //search for alphabets
count++;
}
return count;
}//end get minterms count
vector<vector<char> > FilterKmapTerms :: filter (vector<char> &result, vector<int> ones)
{
vector<char> term, //reading all term alone
essentialTerms; //result after filtering
vector<vector<char>> filterResult;
int LargestTermSize;
vector<vector<char>>terms;
//setting essentials
LargestTermSize = getLargestTermSize(result);
for(int temp = 0 ; temp < result.size(); temp ++)
{
term = getTerm(result, temp);
//term is essential
if(LargestTermSize > getMintermCount(term) )
{
//add + for more than one term result
if(essentialTerms.size() > 0 )
{
essentialTerms.push_back('+');
}
for(int temp1 = 0 ; temp1 < term.size(); temp1 ++)
{
essentialTerms.push_back(term[temp1]); //add term to filter result
result.erase(result.begin()+temp); //remove term form main result
}
if(result.size() > 0)//erase + for more than one term
result.erase(result.begin()+temp);
resultTerms--; //decrement result terms
temp--;
}//end if of essential terms
else
temp += term.size();
}//end result covering loop
terms.push_back(vector<char> () );
for(int temp = 0; temp < result.size(); temp++)
{
if(result[temp] == '+' && temp < result.size())
terms.push_back(vector<char> () );
else
terms[terms.size()-1].push_back(result[temp]);
}
filterResult = getFilterResult(terms, essentialTerms);
return filterResult;
}//end filter
/***
* Getting terms position on k-map by:
* 1- Extracting comparelified terms and return it to
* it to its full-minterm terms
* 2- compute its positions by compute position of
* each full-minterm terms
*/
bool FilterKmapTerms :: checkResult (vector<char> someResult, vector<int> ones)
{
vector<int> resultPos; //saving someResult positions in k-map
resultPos = termToPos(someResult,type);
for(int temp = 0; temp < resultPos.size(); temp++)
{
for(int temp1= 0; temp1<ones.size(); temp1++)
{
if(ones[temp1] == resultPos[temp]) //searching for matching ones
ones.erase(ones.begin()+temp1); //erase matching ones
}
}
//results are covering all ones
if(ones.size() == 0)
return true;
else//results don't cover all ones
return false;
}//end check results
vector<vector<char>> FilterKmapTerms ::getFilterResult(vector<vector < char>> &results, vector<char> &essentialTerms)
{
vector<vector<char>> filterResult; //return variable
int filterResultCount = 0; //count filter results
int largestCombinationsCount = resultTerms; //set largest combinations count
vector<char> someResult;
vector<vector<int> > possibilites;
for(int temp = 1; temp <= largestCombinationsCount; temp++)
{
possibilites.clear();
possibilites = getCombination(results.size(), temp);
/* Adding other terms with combinational possibilites */
//covering possibilites
for(int temp1 = 0; temp1 < possibilites.size(); temp1++)
{
someResult.clear();
//add essential terms
for(int temp1 = 0; temp1 < essentialTerms.size(); temp1++)
someResult.push_back(essentialTerms[temp1]);
//covering all term alone
for(int temp2 = 0; temp2 < possibilites[temp1].size(); temp2++)
{
if(someResult.size() > 0) someResult.push_back('+'); //adding + for separating terms
for(int temp3 = 0; temp3 < results[ possibilites[temp1][temp2] ].size(); temp3++)
{
someResult.push_back(results[ possibilites[temp1][temp2] ] [temp3] );
}
}//end covering lonly terms
if(checkResult(someResult,ones) )
{
filterResult.push_back( vector<char> () );
for(int temp1 = 0; temp1 < someResult.size(); temp1++)
{
filterResult[filterResult.size() - 1].push_back(someResult[temp1]);
}
largestCombinationsCount = temp;
}//end check result
}//end covering possibilties
}//general loop
return filterResult;
}//end get Filter Result
#endif
| 29.110132 | 117 | 0.611229 | [
"vector"
] |
2f54ef8902b7848cae6795744c74642399fb5de9 | 3,524 | h | C | include/post3D/Camera.h | fernandomv3/post3D | f97e4e092f7e47a964d2420681e6c282e0dcb868 | [
"MIT"
] | null | null | null | include/post3D/Camera.h | fernandomv3/post3D | f97e4e092f7e47a964d2420681e6c282e0dcb868 | [
"MIT"
] | null | null | null | include/post3D/Camera.h | fernandomv3/post3D | f97e4e092f7e47a964d2420681e6c282e0dcb868 | [
"MIT"
] | null | null | null | #ifndef CAMERA_H
#define CAMERA_H
#include "post3D/Mat4.h"
#include "post3D/Vec3.h"
#include "post3D/Object3D.h"
#include <memory>
using namespace std;
using namespace object3D;
namespace scene{
/**
* Represents a virtual Camera
* This class stores the world and projection matrices as well as the gamma value.
* This camera class can act as a free camera or a lookup camera.
* The world matrix gets updated automatically with values from position, rotation and scale.
* @todo: enable overriding the automatic worldMatrix updating by setting a variable
*/
class Camera : public Object3D{
private:
shared_ptr<Mat4> projectionMatrix;/**< The projection Matrix. Stores the projection matrix as a shared_ptr<math3D::Mat4>*/
shared_ptr<Mat4> worldMatrix;/**< The world Matrix. Stores the world matrix as a shared_ptr<math3D::Mat4>*/
shared_ptr<Vec3> target;/**< The position of the target. Stores the position of the target for lookup camera*/
int matricesUBO;/**< Uniform Buffer Object. Stores the handle to the UBO whic stores both matrices. Currently not available*/
float gamma;/**< Gamma correction value. Stores a float for setting gamma correction*/
public:
/**
* Camera constructor.
* The constructor creates a free camera,
*/
Camera();
/**
* Camera copy constructor.
*/
Camera(const Camera& cam);
/**
* Camera move constructor.
*/
Camera(Camera&& cam);
/**
* Camera copy assignment.
*/
Camera& operator=(const Camera& cam);
/**
* Camera move assignment.
*/
Camera& operator=(Camera&& cam);
/**
* Camera destructor.
* The matrices are stored on shared_ptr(), they only get destroyed if no other object owns the resource.
* Generated by deafult
*/
~Camera()=default;
/**
* Gets the projection matrix.
* If not set or modified, the camera uses a default perspective projection.
*/
shared_ptr<Mat4> getProjectionMatrix()const;
/**
* Sets the projection matrix.
*/
Camera& setProjectionMatrix(shared_ptr<Mat4> mat);
/**
* Gets the world matrix.
* If not set or modified, the camera uses a default identity matrix.
*/
shared_ptr<Mat4> getWorldMatrix()const;
/**
* Sets the world matrix.
*/
Camera& setWorldMatrix(shared_ptr<Mat4> mat);
/**
* Updates the world matrix.
* Used to update the world matrix automatically.
*/
Camera& updateWorldMatrix();
/**
* Get matrices Uniform Buffer Object.
* Currently not in use
*/
int getMatricesUBO()const;
/**
* Set matrices Uniform Buffer Object.
* Currently not in use
*/
Camera& setMatricesUBO(int ubo);
/**
* Get matrices as an array of floats.
* Both matrices are returned in an array of floats wraped in a shared_ptr.
*/
shared_ptr<float> getMatricesArray()const;
/**
* Get the camera target.
* @return Returns a shared_ptr<Vec3> with the target of the lookup camera.
*/
shared_ptr<Vec3> getTarget()const;
/**
* Sets the camera target.
* By setting a target, the camera starts behaving as a lookup camera.
*/
Camera& setTarget(shared_ptr<Vec3> target);
/**
* Gets the gamma correction value.
*/
float getGamma()const;
/**
* Sets the gamma correction value.
*/
Camera& setGamma(float gamma);
/**
* Makes the camera look at the target.
* Method used for looking to a particular target.
*/
Mat4 lookAt() const;
};
}
#endif | 30.643478 | 128 | 0.665153 | [
"object"
] |
920e22ea0e835d2cd76e740405055a5d026442c9 | 8,099 | h | C | media_driver/agnostic/gen8/codec/hal/codechal_encoder_g8.h | xinfengz/media-driver | 310104a4693c476a215de13e7e9fabdf2afbad0a | [
"Intel",
"BSD-3-Clause",
"MIT"
] | 1 | 2019-09-26T23:48:34.000Z | 2019-09-26T23:48:34.000Z | media_driver/agnostic/gen8/codec/hal/codechal_encoder_g8.h | xinfengz/media-driver | 310104a4693c476a215de13e7e9fabdf2afbad0a | [
"Intel",
"BSD-3-Clause",
"MIT"
] | null | null | null | media_driver/agnostic/gen8/codec/hal/codechal_encoder_g8.h | xinfengz/media-driver | 310104a4693c476a215de13e7e9fabdf2afbad0a | [
"Intel",
"BSD-3-Clause",
"MIT"
] | 1 | 2017-12-11T03:28:35.000Z | 2017-12-11T03:28:35.000Z | /*
* Copyright (c) 2011-2017, Intel Corporation
*
* 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.
*/
//!
//! \file codechal_encoder_g8.h
//! \brief This modules implements Render interface layer for decoding to be used on all operating systems/DDIs, across CODECHAL components.
//!
#ifndef __CODECHAL_ENCODER_G75_H__
#define __CODECHAL_ENCODER_G75_H__
#include "codechal_encoder.h"
typedef enum _CODECHAL_ENCODE_BINDING_TABLE_OFFSET_SCALING_G75
{
CODECHAL_ENCODE_SCALING_FRAME_SRC_Y_G75 = 0,
CODECHAL_ENCODE_SCALING_FRAME_DST_Y_G75 = 24,
CODECHAL_ENCODE_SCALING_FIELD_TOP_SRC_Y_G75 = 0,
CODECHAL_ENCODE_SCALING_FIELD_BOT_SRC_Y_G75 = 3,
CODECHAL_ENCODE_SCALING_FIELD_TOP_DST_Y_G75 = 24,
CODECHAL_ENCODE_SCALING_FIELD_BOT_DST_Y_G75 = 27,
CODECHAL_ENCODE_SCALING_NUM_SURFACES_G75 = 4
} CODECHAL_ENCODE_BINDING_TABLE_OFFSET_SCALING_G75;
typedef enum _CODECHAL_BINDING_TABLE_OFFSET_SCALING_CM_G75
{
CODECHAL_SCALING_FRAME_SRC_Y_CM_G75 = 0,
CODECHAL_SCALING_FRAME_DST_Y_CM_G75 = 1,
CODECHAL_SCALING_FIELD_TOP_SRC_Y_CM_G75 = 0,
CODECHAL_SCALING_FIELD_TOP_DST_Y_CM_G75 = 1,
CODECHAL_SCALING_FIELD_BOT_SRC_Y_CM_G75 = 2,
CODECHAL_SCALING_FIELD_BOT_DST_Y_CM_G75 = 3,
CODECHAL_SCALING_FRAME_FLATNESS_DST_CM_G75 = 4,
CODECHAL_SCALING_FIELD_TOP_FLATNESS_DST_CM_G75 = 4,
CODECHAL_SCALING_FIELD_BOT_FLATNESS_DST_CM_G75 = 5,
CODECHAL_SCALING_FRAME_MBVPROCSTATS_DST_CM_G75 = 6,
CODECHAL_SCALING_FIELD_TOP_MBVPROCSTATS_DST_CM_G75 = 6,
CODECHAL_SCALING_FIELD_BOT_MBVPROCSTATS_DST_CM_G75 = 7,
CODECHAL_SCALING_NUM_SURFACES_CM_G75 = 8
} CODECHAL_BINDING_TABLE_OFFSET_SCALING_CM_G75;
typedef enum _CODECHAL_BINDING_TABLE_OFFSET_2xSCALING_CM_G75
{
CODECHAL_2xSCALING_FRAME_SRC_Y_CM_G75 = 0,
CODECHAL_2xSCALING_FRAME_DST_Y_CM_G75 = 1,
CODECHAL_2xSCALING_FIELD_TOP_SRC_Y_CM_G75 = 0,
CODECHAL_2xSCALING_FIELD_TOP_DST_Y_CM_G75 = 1,
CODECHAL_2xSCALING_FIELD_BOT_SRC_Y_CM_G75 = 2,
CODECHAL_2xSCALING_FIELD_BOT_DST_Y_CM_G75 = 3,
CODECHAL_2xSCALING_NUM_SURFACES_CM_G75 = 4
}CODECHAL_BINDING_TABLE_OFFSET_2xSCALING_CM_G75;
typedef struct _MEDIA_OBJECT_SCALING_INLINE_DATA_G75
{
// uint32_t 0 - GRF R7.0
union
{
// All
struct
{
uint32_t DestinationBlockHorizontalOrigin : 16;
uint32_t DestinationBlockVerticalOrigin : 16;
};
// Block Copy
struct
{
uint32_t BlockHeight : 16;
uint32_t BufferOffset : 16;
};
// FMD Summation
struct
{
uint32_t StartRowOffset;
};
uint32_t Value;
} DW00;
// uint32_t 1 - GRF R7.1
union
{
// Composite
struct
{
uint32_t HorizontalBlockCompositeMaskLayer0 : 16;
uint32_t VerticalBlockCompositeMaskLayer0 : 16;
};
// FMD Summation
struct
{
uint32_t TotalRows;
};
uint32_t Value;
} DW01;
// uint32_t 2 - GRF R7.2
union
{
// Composite
struct
{
uint32_t HorizontalBlockCompositeMaskLayer1 : 16;
uint32_t VerticalBlockCompositeMaskLayer1 : 16;
};
// FMD Summation
struct
{
uint32_t StartColumnOffset;
};
uint32_t Value;
} DW02;
// uint32_t 3 - GRF R7.3
union
{
// Composite
struct
{
uint32_t HorizontalBlockCompositeMaskLayer2 : 16;
uint32_t VerticalBlockCompositeMaskLayer2 : 16;
};
// FMD Summation
struct
{
uint32_t TotalColumns;
};
uint32_t Value;
} DW03;
// uint32_t 4 - GRF R7.4
union
{
// Sampler Load
struct
{
float VideoXScalingStep;
};
uint32_t Value;
} DW04;
// uint32_t 5 - GRF R7.5
union
{
// NLAS
struct
{
float VideoStepDelta;
};
uint32_t Value;
} DW05;
// uint32_t 6 - GRF R7.6
union
{
// AVScaling
struct
{
uint32_t VerticalBlockNumber :17;
uint32_t AreaOfInterest :1;
uint32_t :14;
};
uint32_t Value;
} DW06;
// uint32_t 7 - GRF R7.7
union
{
// AVScaling
struct
{
uint32_t GroupIDNumber;
};
uint32_t Value;
} DW07;
// uint32_t 8 - GRF R8.0
union
{
// Composite
struct
{
uint32_t HorizontalBlockCompositeMaskLayer3 : 16;
uint32_t VerticalBlockCompositeMaskLayer3 : 16;
};
uint32_t Value;
} DW08;
// uint32_t 9 - GRF R8.1
union
{
// Composite
struct
{
uint32_t HorizontalBlockCompositeMaskLayer4 : 16;
uint32_t VerticalBlockCompositeMaskLayer4 : 16;
};
uint32_t Value;
} DW09;
// uint32_t 10 - GRF R8.2
union
{
// Composite
struct
{
uint32_t HorizontalBlockCompositeMaskLayer5 : 16;
uint32_t VerticalBlockCompositeMaskLayer5 : 16;
};
uint32_t Value;
} DW10;
// uint32_t 11 - GRF R8.3
union
{
// Composite
struct
{
uint32_t HorizontalBlockCompositeMaskLayer6 : 16;
uint32_t VerticalBlockCompositeMaskLayer6 : 16;
};
uint32_t Value;
} DW11;
// uint32_t 12 - GRF R8.4
union
{
// Composite
struct
{
uint32_t HorizontalBlockCompositeMaskLayer7 : 16;
uint32_t VerticalBlockCompositeMaskLayer7 : 16;
};
uint32_t Value;
} DW12;
// uint32_t 13 - GRF R8.5
union
{
struct
{
uint32_t Reserved;
};
uint32_t Value;
} DW13;
// uint32_t 14 - GRF R8.6
union
{
struct
{
uint32_t Reserved;
};
uint32_t Value;
} DW14;
// uint32_t 15 - GRF R8.7
union
{
struct
{
uint32_t Reserved;
};
uint32_t Value;
} DW15;
} MEDIA_OBJECT_SCALING_INLINE_DATA_G75, *PMEDIA_OBJECT_SCALING_INLINE_DATA_G75;
#endif // __CODECHAL_ENCODER_G75_H__
| 26.554098 | 164 | 0.573898 | [
"render"
] |
921673c0c35039a9d58de4f4859215a57e86fdf4 | 35,326 | c | C | astroem/jsfitsio/jsfitsio.c | jbroll/js9 | 05b748dd9391144dbb829fba1642d48a5f9bbe82 | [
"MIT"
] | 6 | 2015-08-13T06:02:03.000Z | 2019-04-09T07:48:22.000Z | astroem/jsfitsio/jsfitsio.c | jbroll/js9 | 05b748dd9391144dbb829fba1642d48a5f9bbe82 | [
"MIT"
] | 1 | 2022-01-23T08:35:54.000Z | 2022-01-23T08:35:54.000Z | astroem/jsfitsio/jsfitsio.c | volodymyrss/js9 | 50e35de88e647c54a92855608da4629bdd8b9fde | [
"MIT"
] | 2 | 2015-10-13T10:26:38.000Z | 2018-02-26T03:18:08.000Z | /*
*
* jsfitsio.c -- extra routines for javascript version
*
*/
/*
Notes:
passing arrays and passing by reference:
http://stackoverflow.com/questions/17883799/how-to-handle-passing-returning-array-pointers-to-emscripten-compiled-code
https://groups.google.com/forum/#!topic/emscripten-discuss/JDaNHIRQ_G4
*/
#include <stdio.h>
#include <unistd.h>
#include <ctype.h>
#include <string.h>
#include <sys/time.h>
#include <math.h>
#include "fitsio.h"
#include "jsfitsio.h"
#include "healpix.h"
#if WITH_IDX
#include "idx.h"
#endif
/*
* http://stackoverflow.com/questions/3599160/unused-parameter-warnings-in-c-code
*/
#ifndef UNUSED
#ifdef __GNUC__
# define UNUSED(x) UNUSED_ ## x __attribute__((__unused__))
#else
# define UNUSED(x) UNUSED_ ## x
#endif
#endif
int ffpxsz(int datatype);
/*
*----------------------------------------------------------------------------
*
*
* Private Routines and Data
*
*
*----------------------------------------------------------------------------
*/
// emscripten does not have access to unlimited memory
#if __EMSCRIPTEN__
#define HAVE_MEMORY_LIMIT 1
#else
#define HAVE_MEMORY_LIMIT 0
#endif
// ffhist3 was added to cfitsio v3.39
#if (CFITSIO_MAJOR < 3) || ((CFITSIO_MAJOR == 3) && (CFITSIO_MINOR < 39))
#error ffhist3() required: please upgrade cfitsio to v3.39 or higher
#endif
/* must match what cfitsio expects (i.e., 4 for histogramming) */
#define IDIM 4
#define IFILE "mem://"
#define MFILE "cfitsio_memfile"
#define MAXINT 2147483647
#define MININT -2147483648
#ifndef min
#define min(a,b) (a<=b?a:b)
#endif
#ifndef max
#define max(a,b) (a>=b?a:b)
#endif
#ifndef SZ_LINE
#define SZ_LINE 1024
#endif
#if HAVE_MEMORY_LIMIT
#define DEF_MAX_MEMORY 2000000000
#else
#define DEF_MAX_MEMORY 0
#endif
static long def_max_memory = DEF_MAX_MEMORY;
/*
*
* Routine: keyword
*
* Purpose: look for a keyword=<value> string inside another string,
* remove and return the <value> in another buffer
*
* Returns: len if keyword was found, 0 otherwise
*
*/
static int keyword (char *ibuf, char *key, char *env, char *obuf, int maxlen){
int qlev;
int len = 0;
char *s;
char *t;
char *u;
char *v;
char *ibase = NULL;
char *iptr=NULL;
char quote='\0';
/* if we have no input string, we are done */
if( !ibuf || !*ibuf || !key || !*key ) return 0;
/* start out pessimistically */
ibase = strdup(ibuf);
iptr = ibase;
*obuf = '\0';
/* maxlen generally is 1 more than we can handle */
maxlen--;
/* keep trying */
while( *iptr ){
/* look for key from current position */
if( (s = (char *)strstr(iptr, key)) == NULL ) goto done;
/* if we found a key, we need to make sure ... */
/* it must be preceeded by beginning of string, beginning of bracket,
or by a "," from previous keyword */
if( (s == ibase) || (*(s-1) == ',') || (*(s-1) == '[') ){
/* it can be followed by spaces ... */
t = s + strlen(key);
while( isspace((int)*t) ) t++;
/* but must be followed by an "=" */
if( *t == '=' ){
t++;
/* skip spaces again */
while( isspace((int)*t) ) t++;
/* this is where the actual value part of the string begins */
u = t;
/* this will be where it ends */
v = t;
/* gather up everything to the next "," or end of filter */
if( (*t == '"') || (*t == '\'') || (*t == '(') || (*t == '[') ){
switch(*t){
case '"':
case '\'':
quote = *t;
break;
case '(':
quote = ')';
break;
case '[':
quote = ']';
break;
}
/* bump past opening quote char */
t++; u++; v++;
while( *t && (*t != quote) ){
t++; v++;
}
if( *t == quote ){
t++;
}
}
else{
qlev = 0;
while( *t &&
((qlev != 0) || (*t != ',')) &&
((qlev != 0) || (*t != ']')) ){
if( *t == '[' ){
qlev++;
} else if( *t == ']' ){
qlev--;
}
t++; v++;
}
}
len = min(maxlen, v - u);
strncpy(obuf, u, len);
obuf[len] = '\0';
/* remove keyword=value string from the original buffer */
/* first remove preceding comma, if necessary */
if( (s > ibase) && (*(s-1) == ',') ){
s--;
}
/* but leave 1 comma in place */
else if( *t == ',' ){
t++;
}
/* now overwrite original from where the keyword started */
memmove(s, t, strlen(t)+1);
/* return success */
goto done;
}
}
/* start next search just past this one */
iptr = s+1;
}
/* didn't find anything */
len = 0;
done:
if( ibase ) free(ibase);
/* if not found, check for environment variable, if necessary */
if( !len && env && (s = (char *)getenv(env)) ){
strncpy(obuf, s, maxlen);
len = strlen(obuf);
}
return len;
}
/*
*
* getcolinfo -- read a string containing tlmin, tlmax, binsiz of a column
*
* col[:tlmin[:tmlax[:binsiz]]]
*
* If only one arg is given, it's assumed to be the binsize
*
*
*/
static int getcolinfo(char *s, char *col, int clen,
double *tlmin, double *tlmax, double *binsiz){
int i, got, tlen;
char *v;
char vbuf[SZ_LINE];
double val[3];
/* initialize */
*col = '\0';
/* make sure we have something to do */
if( !s || !*s ){
return 0;
}
/* get column name */
for(v=col, tlen=0; *s && (*s != ':') && tlen < clen; tlen++ ){
*v++ = *s++;
}
*v = '\0';
/* get image dimensions and bin size */
for(i=0, got=0; i<3; i++, got++){
if( *s != ':' ){
break;
}
/* skip past ':' */
s++;
/* fill buffer with next value */
*vbuf = '\0';
for(v=vbuf; *s && (*s != ':') && tlen < SZ_LINE; tlen++){
*v++ = *s++;
}
*v = '\0';
/* convert string to double */
val[i] = atof(vbuf);
}
switch(got){
case 0:
*binsiz = 1;
got = 1;
break;
case 1:
*binsiz = val[0];
break;
case 2:
*tlmin = val[0];
*tlmax = val[1];
break;
case 3:
default:
*tlmin = val[0];
*tlmax = val[1];
*binsiz = val[2];
break;
}
return got;
}
// give a bitpix, return type
int fitstypeof(int bitpix){
switch(bitpix){
case 8:
return TBYTE;
case 16:
return TSHORT;
case -16:
return TUSHORT;
case 32:
return TINT;
case 64:
return TLONGLONG;
case -32:
return TFLOAT;
case -64:
return TDOUBLE;
default:
return TINT;
}
}
// gotoFITSHDU: try to go to a reasonable HDU if the primary is useless
// we look for specified extensions and if not found, go to hdu #2
// this is how xray binary tables are imaged automatically
static fitsfile *gotoFITSHDU(fitsfile *fptr,
char *extlist, int *hdutype, int *status){
int hdunum, naxis, thdutype, gotext=0;
long naxes[IDIM] = {0, 0, 0, 0};
char *ext, *textlist;
// if this is the primary array and it does not contain an image,
// try to move to something more reasonble
fits_get_hdu_num(fptr, &hdunum); *status = 0;
fits_get_img_dim(fptr, &naxis, status); *status = 0;
fits_get_img_size(fptr, min(IDIM,naxis), naxes, status); *status = 0;
if( (hdunum == 1) && ((naxis == 0) || naxes[0] == 0) ){
// look through the extension list
if( extlist ){
gotext = 0;
textlist = (char *)strdup(extlist);
for(ext=(char *)strtok(textlist, " "); ext != NULL;
ext=(char *)strtok(NULL," ")){
fits_movnam_hdu(fptr, ANY_HDU, ext, 0, status);
if( *status == 0 ){
gotext = 1;
break;
} else {
*status = 0;
}
}
free(textlist);
}
if( !gotext ){
// if all else fails, move to extension #2 and hope for the best
fits_movabs_hdu(fptr, 2, &thdutype, status);
}
}
fits_get_hdu_type(fptr, hdutype, status);
return fptr;
}
/*
*----------------------------------------------------------------------------
*
*
* Public Routines and Data
*
*
*----------------------------------------------------------------------------
*/
// openFITSFile: open a FITS file for reading and go to a useful HDU
//
fitsfile *openFITSFile(char *ifile, int iomode, char *extlist,
char *UNUSED(opts), int *hdutype, int *status){
fitsfile *fptr;
// open fits file
fits_open_file(&fptr, ifile, iomode, status);
// bail out if there is an error at this point
if( *status ) return NULL;
return gotoFITSHDU(fptr, extlist, hdutype, status);
}
// openFITSMem: open a FITS memory buffer for reading and go to a useful HDU
fitsfile *openFITSMem(void **buf, size_t *buflen, char *extlist,
char *UNUSED(opts), int *hdutype, int *status){
fitsfile *fptr;
// open fits file
fits_open_memfile(&fptr, MFILE, READWRITE, buf, buflen, 0, NULL, status);
// bail out if there is an error at this point
if( *status ) return NULL;
return gotoFITSHDU(fptr, extlist, hdutype, status);
}
// getHeaderToString: get header as a string
void getHeaderToString(fitsfile *fptr,
char **cardstr, int *ncard, int *status){
fits_convert_hdr2str(fptr, 0, NULL, 0, cardstr, ncard, status);
}
// update/add WCS params
// update/add LTM and LTV header params
// ftp://iraf.noao.edu/iraf/web/projects/fitswcs/specwcs.html
void updateWCS(fitsfile *fptr, fitsfile *ofptr,
int xcen, int ycen, int dim1, int dim2, double bin,
double *amin){
int status;
double x1, y1;
double dval;
char comment[FLEN_CARD];
if( !bin ){
bin = 1;
}
// use amin to calculate CRPIX values, if present
if( amin != NULL ){
x1 = (double)amin[0];
y1 = (double)amin[1];
dval = 0.0; *comment = '\0'; status = 0;
fits_read_key(fptr, TDOUBLE, "CRPIX1", &dval, comment, &status);
if( status == 0 ){
// funtools-style: see funtools/funcopy.c/_FunCopy2ImageHeader
dval = (dval + 1.0 - x1 - 0.5) / bin + 0.5;
// cfitsio-style: see cfitsio/histo.c
// dval = (dval - x1) / bin + 0.5;
// zhtools-style: see zhtools/src/images/imblock
// dval = (dval - x1 - 0.5) / bin + 0.5;
fits_update_key(ofptr, TDOUBLE, "CRPIX1", &dval, comment, &status);
}
dval = 0.0; *comment = '\0'; status = 0;
fits_read_key(fptr, TDOUBLE, "CRPIX2", &dval, comment, &status);
if( status == 0 ){
// funtools-style: see funtools/funcopy.c/_FunCopy2ImageHeader
dval = (dval + 1.0 - y1 - 0.5) / bin + 0.5;
// cfitsio-style: see cfitsio/histo.c
// dval = (dval - y1) / bin + 0.5;
// zhtools-style: see zhtools/src/images/imblock
// dval = (dval - y1 - 0.5) / bin + 0.5;
fits_update_key(ofptr, TDOUBLE, "CRPIX2", &dval, comment, &status);
}
dval = 0.0; *comment = '\0'; status = 0;
fits_read_key(fptr, TDOUBLE, "CDELT1", &dval, comment, &status);
if( status == 0 ){
dval = dval * bin;
fits_update_key(ofptr, TDOUBLE, "CDELT1", &dval, comment, &status);
}
dval = 0.0; *comment = '\0'; status = 0;
fits_read_key(fptr, TDOUBLE, "CDELT2", &dval, comment, &status);
if( status == 0 ){
dval = dval * bin;
fits_update_key(ofptr, TDOUBLE, "CDELT2", &dval, comment, &status);
}
dval = 0.0; *comment = '\0'; status = 0;
fits_read_key(fptr, TDOUBLE, "CD1_1", &dval, comment, &status);
if( status == 0 ){
dval = dval * bin;
fits_update_key(ofptr, TDOUBLE, "CD1_1", &dval, comment, &status);
}
dval = 0.0; *comment = '\0'; status = 0;
fits_read_key(fptr, TDOUBLE, "CD1_2", &dval, comment, &status);
if( status == 0 ){
dval = dval * bin;
fits_update_key(ofptr, TDOUBLE, "CD1_2", &dval, comment, &status);
}
dval = 0.0; *comment = '\0'; status = 0;
fits_read_key(fptr, TDOUBLE, "CD2_1", &dval, comment, &status);
if( status == 0 ){
dval = dval * bin;
fits_update_key(ofptr, TDOUBLE, "CD2_1", &dval, comment, &status);
}
dval = 0.0; *comment = '\0'; status = 0;
fits_read_key(fptr, TDOUBLE, "CD2_2", &dval, comment, &status);
if( status == 0 ){
dval = dval * bin;
fits_update_key(ofptr, TDOUBLE, "CD2_2", &dval, comment, &status);
}
}
// update ltm/ltv values, using center to calculate ltv values
if( dim1 && dim2 ){
x1 = (xcen - (dim1 / 2.0));
y1 = (ycen - (dim2 / 2.0));
dval = 1.0; *comment = '\0'; status = 0;
fits_read_key(fptr, TDOUBLE, "LTM1_1", &dval, comment, &status);
dval = dval / bin; status = 0;
fits_update_key(ofptr, TDOUBLE, "LTM1_1", &dval, comment, &status);
dval = 0.0; *comment = '\0'; status = 0;
fits_read_key(fptr, TDOUBLE, "LTM1_2", &dval, comment, &status);
dval = dval / bin; status = 0;
fits_update_key(ofptr, TDOUBLE, "LTM1_2", &dval, comment, &status);
dval = 0.0; *comment = '\0'; status = 0;
fits_read_key(fptr, TDOUBLE, "LTM2_1", &dval, comment, &status);
dval = dval / bin; status = 0;
fits_update_key(ofptr, TDOUBLE, "LTM2_1", &dval, comment, &status);
dval = 1.0; *comment = '\0'; status = 0;
fits_read_key(fptr, TDOUBLE, "LTM2_2", &dval, comment, &status);
dval = dval / bin; status = 0;
fits_update_key(ofptr, TDOUBLE, "LTM2_2", &dval, comment, &status);
dval = 0.0; *comment = '\0'; status = 0;
fits_read_key(fptr, TDOUBLE, "LTV1", &dval, comment, &status);
dval = (dval - x1 - 0.5) / bin + 0.5; status = 0;
fits_update_key(ofptr, TDOUBLE, "LTV1", &dval, comment, &status);
dval = 0.0; *comment = '\0'; status = 0;
fits_read_key(fptr, TDOUBLE, "LTV2", &dval, comment, &status);
dval = (dval - y1 - 0.5) / bin + 0.5; status = 0;
fits_update_key(ofptr, TDOUBLE, "LTV2", &dval, comment, &status);
}
}
// getImageToArray: extract a sub-section from an image HDU, return array
void *getImageToArray(fitsfile *fptr,
int *dims, double *cens, double bin, int binMode,
char *slice, char *opts,
int *start, int *end, int *bitpix, int *status){
int b, i, j, k, naxis;
int idim1, idim2, idim3, sdim1, sdim2, hidim1, hidim2, hidim3;
int ttype, tsize;
int bsize = 0;
int biter = 1;
int ooff = 0;
int ojoff = 0;
int tstatus = 0;
int doscale = 0;
int dobin = 0;
#if __EMSCRIPTEN__
int doconvert64 = 0;
#endif
void *obuf, *rbuf;
long totim, totpix, totbytes;
long naxes[IDIM], fpixel[IDIM], lpixel[IDIM], myfpixel[IDIM], inc[IDIM];
double bin2;
double xcen, ycen;
double bscale = 1.0;
double bzero = 0.0;
char comment[FLEN_CARD];
char tbuf[SZ_LINE];
char *s, *tslice;
char *bptr = NULL;
int nslice, iaxis0=0, iaxis1=0, iaxis2=0;
int iaxes[3] = {0, 1, 2};
int saxes[IDIM] = {0, 0, 0, 0};
long max_memory = def_max_memory;
unsigned char *crbuf=NULL, *cobuf=NULL;
short *srbuf=NULL, *sobuf=NULL;
unsigned short *usrbuf=NULL, *usobuf=NULL;
int *irbuf=NULL, *iobuf=NULL;
long long *lrbuf=NULL, *lobuf=NULL;
float *frbuf=NULL, *fobuf=NULL;
double *drbuf=NULL, *dobuf=NULL;
// get options
if( keyword(opts, "maxsize", "JSFITSIO_MAXMEMORY", tbuf, SZ_LINE) ){
max_memory = strtol(tbuf, NULL, 10);
}
// seed buffers
for(i=0; i<IDIM; i++){
naxes[i] = 0;
fpixel[i] = 1;
lpixel[i] = 1;
inc[i] = 1;
}
// get image dimensions and type
fits_get_img_dim(fptr, &naxis, status);
fits_get_img_size(fptr, min(IDIM,naxis), naxes, status);
fits_get_img_type(fptr, bitpix, status);
if( naxis < 2 ){
*status = BAD_DIMEN;
return NULL;
}
// get binning parameter
// negative bin => 1/abs(bin)
if( bin == 0 ){
bin = 1.0;
} else if( bin < 0 ){
bin = 1.0 / fabs(bin);
}
// parse slice string into primary axes and slice axes
if( slice && *slice ){
if( !strcmp(slice, "all") ){
tslice = (char *)strdup("*:*:all");
} else {
if( strchr(slice, ':') || strchr(slice, ',') ){
tslice = (char *)strdup(slice);
} else {
snprintf(tbuf, SZ_LINE, "*:*:%s", slice);
tslice = (char *)strdup(tbuf);
}
}
for(s=(char *)strtok(tslice, ":,"), nslice=0, i=0;
(s != NULL) && (nslice < IDIM);
s=(char *)strtok(NULL,":,"), nslice++){
if( !strcmp(s, "*") ){
if( i < 2 ){
iaxes[i++] = nslice;
}
} else {
// all slices (i.e. the whole data cube)?
if( !strcmp(s, "all") ){
saxes[nslice] = -naxes[nslice];
iaxis2 = nslice;
} else {
// specific slice
saxes[nslice] = atoi(s);
if( (saxes[nslice] < 1) || (saxes[nslice] > naxes[nslice]) ){
*status = SEEK_ERROR;
return NULL;
}
}
}
}
free(tslice);
}
// convenience variables for the primary axis indexes
iaxis0 = iaxes[0];
iaxis1 = iaxes[1];
// max dimension of each input axis for integral binning
if( bin >= 1 ){
idim1 = (int)(naxes[iaxis0] / bin) * bin;
idim2 = (int)(naxes[iaxis1] / bin) * bin;
} else {
idim1 = naxes[iaxis0];
idim2 = naxes[iaxis1];
}
// get limits of extracted section taking binning into account
if( dims && dims[0] && dims[1] ){
sdim1 = min(dims[0], idim1);
sdim2 = min(dims[1], idim2);
// read image section
if( cens && cens[0] && cens[1] ){
xcen = cens[0];
ycen = cens[1];
} else {
xcen = idim1/2.0;
ycen = idim2/2.0;
}
// min and max of input section, indexed from 1
fpixel[iaxis0] = (int)(xcen - (sdim1/2.0) + 1);
fpixel[iaxis1] = (int)(ycen - (sdim2/2.0) + 1);
lpixel[iaxis0] = (int)(xcen + (sdim1/2.0));
if( sdim1 % 2 == 1 ){ lpixel[iaxis0] += 1; }
lpixel[iaxis1] = (int)(ycen + (sdim2/2.0));
if( sdim2 % 2 == 1 ){ lpixel[iaxis1] += 1; }
} else {
// read entire input image
fpixel[iaxis0] = 1;
fpixel[iaxis1] = 1;
lpixel[iaxis0] = idim1;
lpixel[iaxis1] = idim2;
}
// stay within image limits
fpixel[iaxis0] = max(fpixel[iaxis0], 1);
fpixel[iaxis0] = min(fpixel[iaxis0], naxes[iaxis0]);
lpixel[iaxis0] = max(lpixel[iaxis0], 1);
lpixel[iaxis0] = min(lpixel[iaxis0], naxes[iaxis0]);
fpixel[iaxis1] = max(fpixel[iaxis1], 1);
fpixel[iaxis1] = min(fpixel[iaxis1], naxes[iaxis1]);
lpixel[iaxis1] = max(lpixel[iaxis1], 1);
lpixel[iaxis1] = min(lpixel[iaxis1], naxes[iaxis1]);
/* get output dimensions, ensuring that bin divides dimensions evenly */
if( fmod(bin,1) == 0.0 ){
for(i=0; i<bin; i++){
idim1 = (lpixel[iaxis0] - fpixel[iaxis0] + 1);
if( (idim1 <= 0 ) || fmod(((float)idim1/(float)bin), 1) == 0.0 ){
break;
}
lpixel[iaxis0] -= 1;
}
for(i=0; i<bin; i++){
idim2 = (lpixel[iaxis1] - fpixel[iaxis1] + 1);
if( (idim2 <= 0 ) || fmod(((float)idim2/(float)bin), 1) == 0.0 ){
break;
}
lpixel[iaxis1] -= 1;
}
} else {
idim1 = (lpixel[iaxis0] - fpixel[iaxis0] + 1);
idim2 = (lpixel[iaxis1] - fpixel[iaxis1] + 1);
}
// for sliced dimensions, set first and last pixel to the specified slice
idim3 = 1;
for(i=0; i<min(IDIM,naxis); i++){
if( saxes[i] ){
if( saxes[i] < 0 ){
// entire slice dimension
fpixel[i] = 1;
lpixel[i] = naxes[i];
idim3 = naxes[i];
} else {
// 1 pixel slice in this dimension
fpixel[i] = saxes[i];
lpixel[i] = saxes[i];
}
// stay within image limits
fpixel[i] = max(fpixel[i], 1);
fpixel[i] = min(fpixel[i], naxes[i]);
lpixel[i] = max(lpixel[i], 1);
lpixel[i] = min(lpixel[i], naxes[i]);
}
}
// save section limits
if( start ){
start[0] = fpixel[iaxis0];
start[1] = fpixel[iaxis1];
if( iaxis2 ){
start[2] = fpixel[iaxis2];
}
}
if( end ){
end[0] = lpixel[iaxis0];
end[1] = lpixel[iaxis1];
if( iaxis2 ){
end[2] = lpixel[iaxis2];
}
}
// total pixels in one slice of the image
totim = idim1 * idim2;
// total pixels in the image
totpix = idim1 * idim2 * idim3;
// make sure we have an image with valid dimensions size
if( totpix <= 1 ){
*status = NEG_AXIS;
return NULL;
}
// are we scaling?
fits_read_key(fptr, TDOUBLE, "BSCALE", &bscale, comment, &tstatus);
if( tstatus != VALUE_UNDEFINED ){
fits_read_key(fptr, TDOUBLE, "BZERO", &bzero, comment, &tstatus);
}
if( (bscale != 1.0) || (bzero != 0.0) ){
doscale = 1;
}
if( bin != 1 ){
if( (binMode == 0) || (binMode == 's') ){
dobin = 's';
} else {
dobin = 'a';
}
}
// in javascript, there is no 64-bit typed array support other than BitInt64,
// which strictly requires bigint values, so we convert to double float
#if __EMSCRIPTEN__
if( *bitpix == 64 ){
*bitpix = -64;
doconvert64 = 1;
}
#endif
// allocate space for the pixel array
// scaled integer data => float
// binned sum integer data => int
// binned avg integer data => float
switch(*bitpix){
case 8:
if( doscale ){
*bitpix = -32;
ttype = TFLOAT;
tsize = sizeof(float);
} else if( dobin == 's' ){
*bitpix = 32;
ttype = TINT;
tsize = sizeof(int);
} else if( dobin == 'a' ){
*bitpix = -32;
ttype = TFLOAT;
tsize = sizeof(float);
} else {
ttype = TBYTE;
tsize = sizeof(char);
}
break;
case 16:
if( doscale ){
*bitpix = -32;
ttype = TFLOAT;
tsize = sizeof(float);
} else if( dobin == 's' ){
*bitpix = 32;
ttype = TINT;
tsize = sizeof(int);
} else if( dobin == 'a' ){
*bitpix = -32;
ttype = TFLOAT;
tsize = sizeof(float);
} else {
ttype = TSHORT;
tsize = sizeof(short);
}
break;
case -16:
if( doscale ){
*bitpix = -32;
ttype = TFLOAT;
tsize = sizeof(float);
} else if( dobin == 's' ){
*bitpix = 32;
ttype = TINT;
tsize = sizeof(int);
} else if( dobin == 'a' ){
*bitpix = -32;
ttype = TFLOAT;
tsize = sizeof(float);
} else {
ttype = TUSHORT;
tsize = sizeof(unsigned short);
}
break;
case 32:
if( doscale ){
*bitpix = -32;
ttype = TFLOAT;
tsize = sizeof(float);
} else if( dobin == 'a' ){
*bitpix = -32;
ttype = TFLOAT;
tsize = sizeof(float);
} else {
ttype = TINT;
tsize = sizeof(int);
}
break;
case 64:
if( doscale ){
*bitpix = -32;
ttype = TFLOAT;
tsize = sizeof(float);
} else if( dobin == 'a' ){
*bitpix = -32;
ttype = TFLOAT;
tsize = sizeof(float);
} else {
ttype = TLONGLONG;
tsize = sizeof(long long);
}
break;
case -32:
ttype = TFLOAT;
tsize = sizeof(float);
break;
case -64:
ttype = TDOUBLE;
tsize = sizeof(double);
break;
default:
return NULL;
}
if( bin == 1 ){
totbytes = totpix * tsize;
// sanity check on memory limits
if( max_memory && totbytes > max_memory ){
*status = MEMORY_ALLOCATION;
return NULL;
}
// allocate memory for the whole image section
if(!(obuf = (void *)calloc(totbytes, sizeof(char)))){
*status = MEMORY_ALLOCATION;
return NULL;
}
/* read the image section */
fits_read_subset(fptr, ttype, fpixel, lpixel, inc, 0, obuf, 0, status);
} else {
// allocate memory for one full row of input data
if(!(rbuf = (void *)calloc(idim1 * tsize, sizeof(char)))){
*status = MEMORY_ALLOCATION;
return NULL;
}
// get total bytes
totbytes = (int)((int)(idim1 / bin) * (int)(idim2 / bin) * idim3 * tsize);
/* allocate memory for the output binned image section */
if( !(obuf = (void *)calloc(totbytes, sizeof(char))) ){
*status = MEMORY_ALLOCATION;
return NULL;
}
switch(*bitpix){
case 8:
crbuf = (unsigned char *)rbuf;
cobuf = (unsigned char *)obuf;
break;
case 16:
srbuf = (short *)rbuf;
sobuf = (short *)obuf;
break;
case -16:
usrbuf = (unsigned short *)rbuf;
usobuf = (unsigned short *)obuf;
break;
case 32:
irbuf = (int *)rbuf;
iobuf = (int *)obuf;
break;
case 64:
lrbuf = (long long *)rbuf;
lobuf = (long long *)obuf;
break;
case -32:
frbuf = (float *)rbuf;
fobuf = (float *)obuf;
break;
case -64:
drbuf = (double *)rbuf;
dobuf = (double *)obuf;
break;
}
/* seed section limits */
for(i=0; i<IDIM; i++){
myfpixel[i] = fpixel[i];
}
// loop limits
if( bin >= 1 ){
hidim1 = (int)(idim1 / bin) * bin;
hidim2 = (int)(idim2 / bin) * bin;
hidim3 = idim3;
} else {
hidim1 = idim1;
hidim2 = idim2;
hidim3 = idim3;
biter = (int)(1.0 / bin);
bsize = (int)(idim1 / bin) * tsize;
}
/* for each input slice */
for(k=0; k<hidim3; k++){
/* read thus slice slice */
myfpixel[2] = fpixel[2] + k;
/* for each input row */
for(j=0; j<hidim2; j++){
/* read next line of the input section */
myfpixel[1] = fpixel[1] + j;
tstatus = 0;
fits_read_pix(fptr, ttype, myfpixel, idim1, NULL, rbuf, NULL, &tstatus);
/* exit on error, perhaps we still have something to show */
if( tstatus ){
break;
}
// offset into output image for this line
ojoff = (int)(k * totim) + (int)(j / bin) * (int)(idim1 / bin);
/* for each pixel in the input line */
for(i=0; i<hidim1; i++){
/* index of output image pixel */
ooff = ojoff + (int)(i / bin);
switch(*bitpix){
case 8:
for(b=0; b<biter; b++){
cobuf[ooff+b] += crbuf[i];
}
break;
case 16:
for(b=0; b<biter; b++){
sobuf[ooff+b] += srbuf[i];
}
break;
case -16:
for(b=0; b<biter; b++){
usobuf[ooff+b] += usrbuf[i];
}
break;
case 32:
for(b=0; b<biter; b++){
iobuf[ooff+b] += irbuf[i];
}
break;
case 64:
for(b=0; b<biter; b++){
lobuf[ooff+b] += lrbuf[i];
}
break;
case -32:
for(b=0; b<biter; b++){
fobuf[ooff+b] += frbuf[i];
}
break;
case -64:
for(b=0; b<biter; b++){
dobuf[ooff+b] += drbuf[i];
}
break;
}
}
if( bin < 1 ){
bptr = obuf + (ojoff * tsize);
for(b=1; b<biter; b++){
memcpy(bptr + b * bsize, bptr, bsize);
}
}
}
free(rbuf);
}
}
// average, if necessary
if( dobin == 'a' ){
if( bin >= 1 ){
bin2 = bin * bin;
} else {
bin2 = 1 / (bin * bin);
}
totpix = totbytes / tsize;
for(i=0; i<totpix; i++){
switch(*bitpix){
case 8:
cobuf[i] /= bin2;
break;
case 16:
sobuf[i] /= bin2;
break;
case -16:
usobuf[i] /= bin2;
break;
case 32:
iobuf[i] /= bin2;
break;
case 64:
lobuf[i] /= bin2;
break;
case -32:
fobuf[i] /= bin2;
break;
case -64:
dobuf[i] /= bin2;
break;
}
}
}
// if we converted bitpix 64 to -64, check if we can convert back to 32
#if __EMSCRIPTEN__
if( doconvert64 ){
// ensure dobuf points to obuf (in case we read the whole section)
dobuf = (double *)obuf;
// are all pixel values are in range of 32 bit ints?
for(i=0; i<totpix; i++){
if( (dobuf[i] > MAXINT) || (dobuf[i] < MININT) ){
// data is out of 32-bit range, leave as double
doconvert64 = 0;
break;
}
}
// if so, we can convert the output to int 32 data
if( doconvert64 ){
// allocate buffer for int data
if( !(iobuf = (int *)calloc(totpix, sizeof(int))) ){
*status = MEMORY_ALLOCATION;
return NULL;
}
// convert to int
for(i=0; i<totpix; i++){
iobuf[i] = (int)round(dobuf[i]);
}
// free original double data
free(obuf);
// point to int data
obuf = iobuf;
// change bitpix to int 32
*bitpix = 32;
}
}
#endif
// return pixel buffer
return obuf;
}
// filterTableToImage: filter a binary table, create a temp image
fitsfile *filterTableToImage(fitsfile *fptr,
char *filter, char *cols,
int *dims, double *cens, double bin,
char *opts,
int *status){
int i, dim1, dim2, hpx, tstatus;
int imagetype=TINT, naxis=2, recip=0;
#if WITH_IDX
int got=-1;
#endif
long nirow, norow, totbytes;
long max_memory = def_max_memory;
float weight=1;
double xcen, ycen;
double minin[IDIM], maxin[IDIM], binsizein[IDIM];
char *s, *t;
char tbuf[SZ_LINE];
char filename[SZ_LINE];
char keyname[FLEN_KEYWORD];
char param[FLEN_CARD];
char comment[FLEN_CARD];
char *rowselect=NULL;
char *outfile=IFILE;
char wtcol[FLEN_VALUE];
char colname[IDIM][FLEN_VALUE];
char minname[IDIM][FLEN_VALUE];
char maxname[IDIM][FLEN_VALUE];
char binname[IDIM][FLEN_VALUE];
int colnum[IDIM];
long haxes[IDIM];
long naxes[IDIM];
float amin[IDIM];
float amax[IDIM];
float binsize[IDIM];
fitsfile *ofptr;
// look for opts directives
if( keyword(opts, "bitpix", "JSFITSIO_TABLEBITPIX", tbuf, SZ_LINE) ){
imagetype = fitstypeof(strtol(tbuf, NULL, 10));
}
if( keyword(opts, "maxsize", "JSFITSIO_MAXMEMORY", tbuf, SZ_LINE) ){
max_memory = strtol(tbuf, NULL, 10);
}
if( keyword(opts, "ofile", "JSFITSIO_OFILE", filename, SZ_LINE) ){
outfile = filename;
}
// check for HEALPix table, which is handled specially
hpx = 0;
param[0] = '\0';
tstatus = 0;
fits_read_key(fptr, TSTRING, "PIXTYPE", param, comment, &tstatus);
// look for pixtype param with value of "healpix" ...
if( (tstatus == 0) && !strcasecmp(param, "HEALPIX") ){
hpx = 1;
} else {
param[0] = '\0';
tstatus = 0;
// ... or nside param with non-negative value
fits_read_key(fptr, TSTRING, "NSIDE", param, comment, &tstatus);
if( (tstatus == 0) && atoi(param) > 0 ){
hpx = 2;
}
}
// if either case holds, it's HEALPix ...
if( hpx ){
ofptr = healpixToImage(fptr, status);
if( *status ) return NULL;
// if 0,0 was input, change to center of image
if( cens && ((cens[0] == 0) || (cens[1] == 0)) ){
tstatus = 0;
fits_get_img_size(ofptr, 2, naxes, &tstatus);
if( cens[0] == 0 ){
cens[0] = naxes[0]/2;
}
if( cens[1] == 0 ){
cens[1] = naxes[1]/2;
}
}
return ofptr;
}
// otherwise, it's an ordinary binary table, set up defaults
// get binning parameter
// negative bin => 1/abs(bin)
if( bin == 0 ){
bin = 1.0;
} else if( bin < 0 ){
bin = 1.0 / fabs(bin);
}
wtcol[0] = '\0';
for(i=0; i<IDIM; i++){
minin[i] = DOUBLENULLVALUE;
maxin[i] = DOUBLENULLVALUE;
binsizein[i] = bin;
minname[i][0] = '\0';
maxname[i][0] = '\0';
binname[i][0] = '\0';
}
if( cols ){
s = (char *)strdup(cols);
// x column
t = (char *)strtok(s, " ,");
if( t ){
strncpy(colname[0], t, FLEN_VALUE);
colname[0][FLEN_VALUE-1] = '\0';
}
// y column
t = (char *)strtok(NULL, " ,");
if( t ){
strncpy(colname[1], t, FLEN_VALUE);
colname[1][FLEN_VALUE-1] = '\0';
}
// cube column[:min:max][:binsize]
t = (char *)strtok(NULL, " ,");
if( getcolinfo(t, colname[2], FLEN_VALUE,
&minin[2], &maxin[2], &binsizein[2]) ){
naxis = naxis + 1;
}
free(s);
} else {
colname[0][0] = '\0';
colname[1][0] = '\0';
}
// get total number of rows in input file
fits_get_num_rows(fptr, &nirow, status);
// and allocate memory for selected rows array
rowselect = calloc(nirow+1, sizeof(char));
// filter the input file and generate selected rows array
if( filter && *filter ){
#if WITH_IDX
got = idx_find_rows(fptr, filter, 0, nirow, &norow, rowselect, status);
if( got < 0 ){
#endif
fits_find_rows(fptr, filter, 0, nirow, &norow, rowselect, status);
if( *status ) return NULL;
#if WITH_IDX
}
#endif
} else {
for(i=0; i<nirow+1; i++){
rowselect[i] = TRUE;
}
}
// get binning parameters so we can know the image dims for these cols
// and from that, get the default center of the image
fits_calc_binning(fptr, naxis, colname, minin, maxin, binsizein,
minname, maxname, binname,
colnum, haxes, amin, amax, binsize, status);
if( *status ) return NULL;
// add bin factor back into haxes to get table dimensions
haxes[0] = (int)(haxes[0] * bin);
haxes[1] = (int)(haxes[1] * bin);
// why truncate to int? otherwise, cfitsio is 0.5 pixels off from js9 ...
xcen = (int)((amax[0] + amin[0])/2.0);
ycen = (int)((amax[1] + amin[1])/2.0);
dim1 = haxes[0];
dim2 = haxes[1];
// get limits of extracted section
if( dims && dims[0] && dims[1] ){
// read image section
if( cens && cens[0] && cens[1] ){
xcen = cens[0];
ycen = cens[1];
dim1 = dims[0];
dim2 = dims[1];
} else {
if( haxes[0] >= dims[0] ){
dim1 = dims[0];
}
if( haxes[1] >= dims[1] ){
dim2 = dims[1];
}
}
// min and max, indexed from 1
minin[0] = (int)(xcen - (dim1/2.0));
minin[1] = (int)(ycen - (dim2/2.0));
maxin[0] = (int)(xcen + (dim1/2.0));
maxin[1] = (int)(ycen + (dim2/2.0));
}
// sanity check on memory limits
if( max_memory ){
for(i=0, totbytes=1; i<naxis; i++){
totbytes *= (maxin[i] - minin[i]) / binsizein[i];
}
totbytes *= ffpxsz(imagetype);
if( totbytes > max_memory ){
*status = MEMORY_ALLOCATION;
return NULL;
}
}
// make histogram from selected rows
ofptr = ffhist3(fptr, outfile, imagetype, naxis, colname,
minin, maxin, binsizein, minname, maxname, binname,
weight, wtcol, recip, rowselect, status);
if( *status ) return NULL;
// store original table info needed by JS9 in header
for(i=0; i<2; i++){
tstatus = 0;
ffkeyn("TFORM", colnum[i], keyname, &tstatus);
fits_read_key(fptr, TSTRING, keyname, param, comment, &tstatus);
ffkeyn("TABTYP", i+1, keyname, &tstatus);
fits_update_key(ofptr, TSTRING, keyname, param,
"original table data type", &tstatus);
tstatus = 0;
ffkeyn("TABMIN", i+1, keyname, &tstatus);
fits_update_key(ofptr, TFLOAT, keyname, &amin[i],
"original table lower bound", &tstatus);
tstatus = 0;
ffkeyn("TABMAX", i+1, keyname, &tstatus);
fits_update_key(ofptr, TFLOAT, keyname, &amax[i],
"original table upper bound", &tstatus);
tstatus = 0;
ffkeyn("TABDIM", i+1, keyname, &tstatus);
fits_update_key(ofptr, TLONG, keyname, &haxes[i],
"original table dimensions", &tstatus);
}
// update/add LTM and LTV header params
updateWCS(fptr, ofptr, xcen, ycen, dim1, dim2, bin, NULL);
// return the center and dims used
if( dims ){
dims[0] = dim1;
dims[1] = dim2;
}
if( cens ){
cens[0] = xcen;
cens[1] = ycen;
}
// if we are writing a disk file, flush to ensure header is updated completely
if( strcmp(outfile, IFILE) ){
fits_flush_file(ofptr, &tstatus);
}
// free up space
if( rowselect ) free(rowselect);
// return new file pointer
return ofptr;
}
// create a data cube from a FITS bianry table
fitsfile *createCubeFromTable(fitsfile *fptr, char *filter, char *cols,
int *dims, double *cens, double bin, char *opts,
int *status){
int got = 0;
char *s = NULL;
char *t = NULL;
char tbuf[SZ_LINE];
fitsfile *ofptr = NULL;
// 1 col (X Y is implied) or 3 cols
t = strdup(cols);
for(s=(char *)strtok(t, " ,"); s; s=(char *)strtok(NULL," ,")){ got++; }
if( t ) free(t);
switch(got){
case 1:
snprintf(tbuf, SZ_LINE-1, "X Y %s", cols);
break;
case 3:
strncpy(tbuf, cols, SZ_LINE-1);
break;
default:
*status = NGP_BAD_ARG;
return NULL;
}
// convert table to image
ofptr = filterTableToImage(fptr, filter, tbuf, dims, cens, bin, opts, status);
return ofptr;
}
// closeFITSFile: close a FITS file or memory object
void closeFITSFile(fitsfile *fptr, int *status){
fits_close_file(fptr, status);
}
// maxFITSMemory: set limit of size of memory available for a FITS image
int maxFITSMemory(int limit){
int old = def_max_memory;
// if 0, don't set, just return current
if( limit ){
def_max_memory = limit;
}
// return prev value
return old;
}
| 27.069732 | 118 | 0.570005 | [
"object"
] |
92169644b41816daa7027a9cc1a481ba487ec767 | 6,122 | h | C | src/ffmpegMediaHandlers.h | hokiedsp/libffmpegio | 633f71017d33a5e4ac129e80945aec436de72aa7 | [
"BSD-2-Clause"
] | 1 | 2019-10-18T09:09:37.000Z | 2019-10-18T09:09:37.000Z | src/ffmpegMediaHandlers.h | hokiedsp/libffmpegio | 633f71017d33a5e4ac129e80945aec436de72aa7 | [
"BSD-2-Clause"
] | null | null | null | src/ffmpegMediaHandlers.h | hokiedsp/libffmpegio | 633f71017d33a5e4ac129e80945aec436de72aa7 | [
"BSD-2-Clause"
] | 1 | 2019-10-18T09:09:37.000Z | 2019-10-18T09:09:37.000Z | #pragma once
extern "C"
{
#include <libavutil/channel_layout.h> // av_get_pix_fmt_name()
#include <libavutil/pixdesc.h> // av_get_pix_fmt_name()
}
#include "ffmpegMediaHandlerInterfaces.h"
#include "ffmpegMediaStructs.h"
namespace ffmpeg
{
/**
* ffmpeg::MediaHandler/VideoHandler/AudioHandler
*/
class MediaHandler : virtual public IMediaHandler
{
protected:
MediaParams *params; // set to the allocated object by derived class,
// destroyed by this class
MediaHandler(MediaParams *p = nullptr)
: params(p) {} // only constructible via derived class
public:
virtual ~MediaHandler() { delete params; }
const MediaParams &getMediaParams() const override { return *params; }
virtual void setMediaParams(const MediaParams &new_params) override
{
if (params->type != new_params.type)
throw Exception("Mismatched media type.");
*params = new_params;
}
void setMediaParams(const IMediaHandler &other) override
{
*params = other.getMediaParams();
}
AVMediaType getMediaType() const override { return params->type; }
std::string getMediaTypeString() const override
{
return (params->type == AVMEDIA_TYPE_UNKNOWN)
? "unknown"
: av_get_media_type_string(params->type);
}
AVRational getTimeBase() const override { return params->time_base; }
virtual void setTimeBase(const AVRational &tb) override
{
params->time_base = tb;
}
virtual bool ready() const override
{
return params->type != AVMEDIA_TYPE_UNKNOWN && params->time_base.num > 0 &&
params->time_base.den > 0;
}
};
struct VideoHandler : virtual public MediaHandler, public IVideoHandler
{
VideoHandler(const AVRational &tb = {0, 0},
const AVPixelFormat fmt = AV_PIX_FMT_NONE, const int w = 0,
const int h = 0, const AVRational &sar = {0, 0})
{
if (!params) params = new VideoParams(tb, fmt, w, h, sar);
}
virtual void setMediaParams(const MediaParams &new_params) override
{
*params = static_cast<const VideoParams &>(new_params);
}
AVPixelFormat getFormat() const override
{
return static_cast<VideoParams *>(params)->format;
}
std::string getFormatName() const override
{
return av_get_pix_fmt_name(getFormat());
}
const AVPixFmtDescriptor &getFormatDescriptor() const override
{
return *av_pix_fmt_desc_get(getFormat());
}
int getWidth() const override
{
return static_cast<VideoParams *>(params)->width;
};
int getHeight() const override
{
return static_cast<VideoParams *>(params)->height;
};
AVRational getSAR() const override
{
return static_cast<VideoParams *>(params)->sample_aspect_ratio;
}
AVRational getFrameRate() const override
{
return static_cast<VideoParams *>(params)->frame_rate;
}
virtual void setFormat(const AVPixelFormat fmt) override
{
static_cast<VideoParams *>(params)->format = fmt;
}
virtual void setWidth(const int w) override
{
static_cast<VideoParams *>(params)->width = w;
};
virtual void setHeight(const int h) override
{
static_cast<VideoParams *>(params)->height = h;
};
virtual void setSAR(const AVRational &sar) override
{
static_cast<VideoParams *>(params)->sample_aspect_ratio = sar;
}
virtual void setFrameRate(const AVRational &fs) override
{
static_cast<VideoParams *>(params)->sample_aspect_ratio = fs;
}
virtual bool ready() const override
{
VideoParams &vparams = *static_cast<VideoParams *>(params);
return MediaHandler::ready() && vparams.format != AV_PIX_FMT_NONE &&
vparams.width != 0 && vparams.height != 0 &&
vparams.sample_aspect_ratio.den != 0 &&
vparams.sample_aspect_ratio.num != 0 &&
vparams.frame_rate.den != 0 && vparams.frame_rate.num != 0;
}
};
struct AudioHandler : virtual public MediaHandler, public IAudioHandler
{
AudioHandler(const AVRational &tb = {0, 0},
const AVSampleFormat fmt = AV_SAMPLE_FMT_NONE,
const uint64_t layout = 0, const int fs = 0)
{
if (!params) params = new AudioParams(tb, fmt, layout, fs);
}
void setMediaParams(const MediaParams &new_params) override
{
*params = static_cast<const AudioParams &>(new_params);
}
AVSampleFormat getFormat() const override
{
return static_cast<AudioParams *>(params)->format;
}
std::string getFormatName() const override
{
return av_get_sample_fmt_name(getFormat());
}
int getChannels() const override
{
return av_get_channel_layout_nb_channels(
static_cast<AudioParams *>(params)->channel_layout);
};
uint64_t getChannelLayout() const override
{
return static_cast<AudioParams *>(params)->channel_layout;
};
std::string getChannelLayoutName() const override
{
int nb_channels = av_get_channel_layout_nb_channels(
static_cast<AudioParams *>(params)->channel_layout);
if (nb_channels)
{
char buf[1024];
av_get_channel_layout_string(
buf, 1024, nb_channels,
static_cast<AudioParams *>(params)->channel_layout);
return buf;
}
else
return "";
}
int getSampleRate() const override
{
return static_cast<AudioParams *>(params)->sample_rate;
}
virtual void setFormat(const AVSampleFormat fmt) override
{
static_cast<AudioParams *>(params)->format = fmt;
}
virtual void setChannelLayout(const uint64_t layout) override
{
static_cast<AudioParams *>(params)->channel_layout = layout;
};
virtual void setChannelLayoutByName(const std::string &name) override
{
static_cast<AudioParams *>(params)->channel_layout =
av_get_channel_layout(name.c_str());
}
virtual void setSampleRate(const int fs) override
{
static_cast<AudioParams *>(params)->sample_rate = fs;
}
virtual bool ready() const override
{
AudioParams &aparams = *static_cast<AudioParams *>(params);
return MediaHandler::ready() && aparams.format != AV_SAMPLE_FMT_NONE &&
!aparams.channel_layout && aparams.sample_rate > 0;
}
};
} // namespace ffmpeg
| 28.474419 | 79 | 0.683437 | [
"object"
] |
923e638421a69a51910b9b84c6483d99cf270546 | 342 | h | C | gui/include/ChessEngineGui/logger.h | maede97/ChessEngine | 24697e75a7375b68a47e08e0ef4fb4b363f08619 | [
"MIT"
] | 1 | 2021-02-20T11:09:59.000Z | 2021-02-20T11:09:59.000Z | gui/include/ChessEngineGui/logger.h | maede97/ChessEngine | 24697e75a7375b68a47e08e0ef4fb4b363f08619 | [
"MIT"
] | 2 | 2021-02-13T22:53:59.000Z | 2021-02-21T12:43:28.000Z | gui/include/ChessEngineGui/logger.h | maede97/ChessEngine | 24697e75a7375b68a47e08e0ef4fb4b363f08619 | [
"MIT"
] | null | null | null | #pragma once
#include "utils.h"
#include <imgui.h>
#include <vector>
CHESS_NAMESPACE_BEGIN
class Logger {
public:
static void logInfo(std::string what);
static void logWarning(std::string what);
static void displayConsole(int max = -1);
private:
static std::vector<std::pair<ImVec4, std::string>> entries;
};
CHESS_NAMESPACE_END | 17.1 | 61 | 0.733918 | [
"vector"
] |
92428824e2f95ad6c65f23f76b28e8cdd9d7632c | 2,251 | h | C | export/release/windows/obj/include/Event.h | bobisdabbing/Vs-The-United-Lands-stable | 0807e58b6d8ad1440bdd350bf006b37a1b7ca9b5 | [
"MIT"
] | null | null | null | export/release/windows/obj/include/Event.h | bobisdabbing/Vs-The-United-Lands-stable | 0807e58b6d8ad1440bdd350bf006b37a1b7ca9b5 | [
"MIT"
] | null | null | null | export/release/windows/obj/include/Event.h | bobisdabbing/Vs-The-United-Lands-stable | 0807e58b6d8ad1440bdd350bf006b37a1b7ca9b5 | [
"MIT"
] | null | null | null | // Generated by Haxe 4.1.5
#ifndef INCLUDED_Event
#define INCLUDED_Event
#ifndef HXCPP_H
#include <hxcpp.h>
#endif
HX_DECLARE_STACK_FRAME(_hx_pos_cee7d4ca3e3c4fc7_18_new)
HX_DECLARE_CLASS0(Event)
class HXCPP_CLASS_ATTRIBUTES Event_obj : public ::hx::Object
{
public:
typedef ::hx::Object super;
typedef Event_obj OBJ_;
Event_obj();
public:
enum { _hx_ClassId = 0x54eb3572 };
void __construct(::String name,Float pos,Float value,::String type);
inline void *operator new(size_t inSize, bool inContainer=true,const char *inName="Event")
{ return ::hx::Object::operator new(inSize,inContainer,inName); }
inline void *operator new(size_t inSize, int extra)
{ return ::hx::Object::operator new(inSize+extra,true,"Event"); }
inline static ::hx::ObjectPtr< Event_obj > __new(::String name,Float pos,Float value,::String type) {
::hx::ObjectPtr< Event_obj > __this = new Event_obj();
__this->__construct(name,pos,value,type);
return __this;
}
inline static ::hx::ObjectPtr< Event_obj > __alloc(::hx::Ctx *_hx_ctx,::String name,Float pos,Float value,::String type) {
Event_obj *__this = (Event_obj*)(::hx::Ctx::alloc(_hx_ctx, sizeof(Event_obj), true, "Event"));
*(void **)__this = Event_obj::_hx_vtable;
{
HX_STACKFRAME(&_hx_pos_cee7d4ca3e3c4fc7_18_new)
HXLINE( 19) ( ( ::Event)(__this) )->name = name;
HXLINE( 20) ( ( ::Event)(__this) )->position = pos;
HXLINE( 21) ( ( ::Event)(__this) )->value = value;
HXLINE( 22) ( ( ::Event)(__this) )->type = type;
}
return __this;
}
static void * _hx_vtable;
static Dynamic __CreateEmpty();
static Dynamic __Create(::hx::DynamicArray inArgs);
//~Event_obj();
HX_DO_RTTI_ALL;
::hx::Val __Field(const ::String &inString, ::hx::PropertyAccess inCallProp);
::hx::Val __SetField(const ::String &inString,const ::hx::Val &inValue, ::hx::PropertyAccess inCallProp);
void __GetFields(Array< ::String> &outFields);
static void __register();
void __Mark(HX_MARK_PARAMS);
void __Visit(HX_VISIT_PARAMS);
bool _hx_isInstanceOf(int inClassId);
::String __ToString() const { return HX_("Event",fa,37,f2,08); }
::String name;
Float position;
Float value;
::String type;
};
#endif /* INCLUDED_Event */
| 30.835616 | 124 | 0.690804 | [
"object"
] |
924643b3c4b1fb9bc1e4964415dbb12138a389dd | 1,762 | h | C | CTaskManager.h | hidenorly/STLTaskManager | fda95c47d6df5c44aeb53d8202b1f5a005475cf0 | [
"Apache-2.0"
] | 2 | 2017-07-09T11:32:52.000Z | 2021-01-06T14:03:38.000Z | CTaskManager.h | hidenorly/STLTaskManager | fda95c47d6df5c44aeb53d8202b1f5a005475cf0 | [
"Apache-2.0"
] | null | null | null | CTaskManager.h | hidenorly/STLTaskManager | fda95c47d6df5c44aeb53d8202b1f5a005475cf0 | [
"Apache-2.0"
] | null | null | null | /*
Copyright (C) 2016 hidenorly
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef TASKMANAGER_CTASKMANAGER_H
#define TASKMANAGER_CTASKMANAGER_H
#include <vector>
#include <mutex>
#include <thread>
#include <map>
class CTaskManager;
class CTask
{
public:
CTask(void):isRunning(false),mStopRunning(false){};
virtual ~CTask(void){};
// for override
virtual void onExecute(void)=0;
virtual void onComplete(void){};
// for task manager
public:
static void execute(CTask *pTask);
virtual void cancel(void);
public:
std::atomic<bool> isRunning;
CTaskManager* pTaskManager = NULL;
protected:
void _onComplete(void);
protected:
std::atomic<bool> mStopRunning;
};
class CTaskManager
{
public:
CTaskManager(int nMaxThread=4);
virtual ~CTaskManager();
public:
void addTask(CTask* pTask);
void cancelTask(CTask* pTask);
void executeAllTasks(void);
void stopAllTasks(void);
bool isRunning(void);
bool isRemainingTasks(void);
void finalize(void);
void _onTaskCompletion(CTask* pTask);
protected:
int mMaxThread;
std::atomic<int> mNumOfRunningTasks;
std::atomic<bool> mStopping;
std::vector<CTask*> mTasks;
std::map<CTask*,std::thread> mThreads;
std::mutex mMutexTasks;
std::mutex mMutexThreads;
};
#endif //TASKMANAGER_CTASKMANAGER_H
| 20.97619 | 73 | 0.754824 | [
"vector"
] |
924fc07a66a6e21100e7c085755faf2ab238a2a3 | 2,262 | h | C | chrome/browser/password_manager/password_store_win.h | rwatson/chromium-capsicum | b03da8e897f897c6ad2cda03ceda217b760fd528 | [
"BSD-3-Clause"
] | 11 | 2015-03-20T04:08:08.000Z | 2021-11-15T15:51:36.000Z | chrome/browser/password_manager/password_store_win.h | rwatson/chromium-capsicum | b03da8e897f897c6ad2cda03ceda217b760fd528 | [
"BSD-3-Clause"
] | null | null | null | chrome/browser/password_manager/password_store_win.h | rwatson/chromium-capsicum | b03da8e897f897c6ad2cda03ceda217b760fd528 | [
"BSD-3-Clause"
] | null | null | null | // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_WIN_H_
#define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_WIN_H_
#include <map>
#include <vector>
#include "base/file_path.h"
#include "base/scoped_ptr.h"
#include "chrome/browser/password_manager/password_store.h"
#include "chrome/browser/password_manager/password_store_default.h"
#include "chrome/browser/webdata/web_data_service.h"
#include "chrome/browser/webdata/web_database.h"
// Windows PasswordStore implementation that uses the default implementation,
// but also uses IE7 passwords if no others found.
class PasswordStoreWin : public PasswordStoreDefault {
public:
// FilePath specifies path to WebDatabase.
explicit PasswordStoreWin(WebDataService* web_data_service);
// Overridden so that we can save the form for later use.
virtual int GetLogins(const webkit_glue::PasswordForm& form,
PasswordStoreConsumer* consumer);
virtual void CancelLoginsQuery(int handle);
private:
virtual ~PasswordStoreWin() {}
// See PasswordStoreDefault.
void OnWebDataServiceRequestDone(WebDataService::Handle h,
const WDTypedResult* result);
// Removes the form for |handle| from pending_request_forms_ (if any).
void DeleteFormForRequest(int handle);
// Cleans up internal state related to |request|, and sends its results to
// the request's consumer.
void CompleteRequest(GetLoginsRequest* request,
const std::vector<webkit_glue::PasswordForm*>& forms);
// Gets logins from IE7 if no others are found. Also copies them into
// Chrome's WebDatabase so we don't need to look next time.
webkit_glue::PasswordForm* GetIE7Result(
const WDTypedResult* result,
const webkit_glue::PasswordForm& form);
// Holds forms associated with in-flight GetLogin queries.
typedef std::map<int, webkit_glue::PasswordForm> PendingRequestFormMap;
PendingRequestFormMap pending_request_forms_;
DISALLOW_COPY_AND_ASSIGN(PasswordStoreWin);
};
#endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_WIN_H_
| 38.338983 | 77 | 0.762599 | [
"vector"
] |
92713edc5ecf8d050d22bba26943ad19c779f917 | 5,780 | c | C | SlimeSim/Library/Il2cppBuildCache/UWP/x64/il2cppOutput/UnityEngine.ParticleSystemModule_CodeGen.c | shibigami/Hobby | be30565a4e1a90adb1a3b286b792b4ffea0d7f3d | [
"Apache-2.0"
] | null | null | null | SlimeSim/Library/Il2cppBuildCache/UWP/x64/il2cppOutput/UnityEngine.ParticleSystemModule_CodeGen.c | shibigami/Hobby | be30565a4e1a90adb1a3b286b792b4ffea0d7f3d | [
"Apache-2.0"
] | null | null | null | SlimeSim/Library/Il2cppBuildCache/UWP/x64/il2cppOutput/UnityEngine.ParticleSystemModule_CodeGen.c | shibigami/Hobby | be30565a4e1a90adb1a3b286b792b4ffea0d7f3d | [
"Apache-2.0"
] | null | null | null | #include "pch-c.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include "codegen/il2cpp-codegen-metadata.h"
// 0x00000001 System.Void UnityEngine.ParticleSystem::Emit(UnityEngine.Vector3,UnityEngine.Vector3,System.Single,System.Single,UnityEngine.Color32)
extern void ParticleSystem_Emit_mC489C467AAF3C3721AC3315AF78DC4CE469E7AAC (void);
// 0x00000002 System.Void UnityEngine.ParticleSystem::Emit(UnityEngine.ParticleSystem/Particle)
extern void ParticleSystem_Emit_mF1E108B9BF7E0094C35CF71870B5B0EA72ABB485 (void);
// 0x00000003 System.Void UnityEngine.ParticleSystem::Emit(System.Int32)
extern void ParticleSystem_Emit_m07EF0D2DA84EB04814DA7EE6B8618B008DE75F28 (void);
// 0x00000004 System.Void UnityEngine.ParticleSystem::Emit_Internal(System.Int32)
extern void ParticleSystem_Emit_Internal_m7C72C31F7F4875B54B00E255A450B045A4449646 (void);
// 0x00000005 System.Void UnityEngine.ParticleSystem::Emit(UnityEngine.ParticleSystem/EmitParams,System.Int32)
extern void ParticleSystem_Emit_m1598252E2EF701A5010EFA395A87368495E9F9F7 (void);
// 0x00000006 System.Void UnityEngine.ParticleSystem::EmitOld_Internal(UnityEngine.ParticleSystem/Particle&)
extern void ParticleSystem_EmitOld_Internal_m4F094DC523986298D5626F0F3F2335DFF596C993 (void);
// 0x00000007 System.Void UnityEngine.ParticleSystem::Emit_Injected(UnityEngine.ParticleSystem/EmitParams&,System.Int32)
extern void ParticleSystem_Emit_Injected_mC31E36D577A2D3135436438BFC27B6C76D9ADC72 (void);
// 0x00000008 System.Void UnityEngine.ParticleSystem/Particle::set_lifetime(System.Single)
extern void Particle_set_lifetime_mCE97F9D17D1E660DB9D9F3244150CB6624A74DC3_AdjustorThunk (void);
// 0x00000009 System.Void UnityEngine.ParticleSystem/Particle::set_position(UnityEngine.Vector3)
extern void Particle_set_position_mB749E41CD3C4C6DF501C0D68B6211CF7E2217FC2_AdjustorThunk (void);
// 0x0000000A System.Void UnityEngine.ParticleSystem/Particle::set_velocity(UnityEngine.Vector3)
extern void Particle_set_velocity_m4894BD6A75E7A1FCD433927F93396AA29A59709B_AdjustorThunk (void);
// 0x0000000B System.Void UnityEngine.ParticleSystem/Particle::set_remainingLifetime(System.Single)
extern void Particle_set_remainingLifetime_mE521DF9387892C00B3F21D4F76F3A55E77AFC6BE_AdjustorThunk (void);
// 0x0000000C System.Void UnityEngine.ParticleSystem/Particle::set_startLifetime(System.Single)
extern void Particle_set_startLifetime_m7AC09262BBFE8818EA6B61BDB62264184CD27A82_AdjustorThunk (void);
// 0x0000000D System.Void UnityEngine.ParticleSystem/Particle::set_startColor(UnityEngine.Color32)
extern void Particle_set_startColor_mA7B0363E82B7A7CBB1C83F8C5D49FB7B7AF75554_AdjustorThunk (void);
// 0x0000000E System.Void UnityEngine.ParticleSystem/Particle::set_randomSeed(System.UInt32)
extern void Particle_set_randomSeed_m8FD7A4DB7F8E7EBDEF2C51A28197F8D9D7CB6E04_AdjustorThunk (void);
// 0x0000000F System.Void UnityEngine.ParticleSystem/Particle::set_startSize(System.Single)
extern void Particle_set_startSize_m7CDEE5B620B3D26B4CC5C1DA7C6E24ACCCF64466_AdjustorThunk (void);
// 0x00000010 System.Void UnityEngine.ParticleSystem/Particle::set_rotation3D(UnityEngine.Vector3)
extern void Particle_set_rotation3D_m0F402760524A81307FA4940751751C44DF2F77D0_AdjustorThunk (void);
// 0x00000011 System.Void UnityEngine.ParticleSystem/Particle::set_angularVelocity3D(UnityEngine.Vector3)
extern void Particle_set_angularVelocity3D_mE9A9544DF33CD0CCF4F1CA14994A2C436E4DF1F8_AdjustorThunk (void);
// 0x00000012 System.Int32 UnityEngine.ParticleSystemRenderer::GetMeshes(UnityEngine.Mesh[])
extern void ParticleSystemRenderer_GetMeshes_m1B36A6BFF152AAE5520D727976E3DA26722C3A75 (void);
static Il2CppMethodPointer s_methodPointers[18] =
{
ParticleSystem_Emit_mC489C467AAF3C3721AC3315AF78DC4CE469E7AAC,
ParticleSystem_Emit_mF1E108B9BF7E0094C35CF71870B5B0EA72ABB485,
ParticleSystem_Emit_m07EF0D2DA84EB04814DA7EE6B8618B008DE75F28,
ParticleSystem_Emit_Internal_m7C72C31F7F4875B54B00E255A450B045A4449646,
ParticleSystem_Emit_m1598252E2EF701A5010EFA395A87368495E9F9F7,
ParticleSystem_EmitOld_Internal_m4F094DC523986298D5626F0F3F2335DFF596C993,
ParticleSystem_Emit_Injected_mC31E36D577A2D3135436438BFC27B6C76D9ADC72,
Particle_set_lifetime_mCE97F9D17D1E660DB9D9F3244150CB6624A74DC3_AdjustorThunk,
Particle_set_position_mB749E41CD3C4C6DF501C0D68B6211CF7E2217FC2_AdjustorThunk,
Particle_set_velocity_m4894BD6A75E7A1FCD433927F93396AA29A59709B_AdjustorThunk,
Particle_set_remainingLifetime_mE521DF9387892C00B3F21D4F76F3A55E77AFC6BE_AdjustorThunk,
Particle_set_startLifetime_m7AC09262BBFE8818EA6B61BDB62264184CD27A82_AdjustorThunk,
Particle_set_startColor_mA7B0363E82B7A7CBB1C83F8C5D49FB7B7AF75554_AdjustorThunk,
Particle_set_randomSeed_m8FD7A4DB7F8E7EBDEF2C51A28197F8D9D7CB6E04_AdjustorThunk,
Particle_set_startSize_m7CDEE5B620B3D26B4CC5C1DA7C6E24ACCCF64466_AdjustorThunk,
Particle_set_rotation3D_m0F402760524A81307FA4940751751C44DF2F77D0_AdjustorThunk,
Particle_set_angularVelocity3D_mE9A9544DF33CD0CCF4F1CA14994A2C436E4DF1F8_AdjustorThunk,
ParticleSystemRenderer_GetMeshes_m1B36A6BFF152AAE5520D727976E3DA26722C3A75,
};
static const int32_t s_InvokerIndices[18] =
{
278,
2046,
1953,
1953,
1225,
1917,
997,
2002,
2020,
2020,
2002,
2002,
1926,
1953,
2002,
2020,
2020,
1411,
};
extern const CustomAttributesCacheGenerator g_UnityEngine_ParticleSystemModule_AttributeGenerators[];
IL2CPP_EXTERN_C const Il2CppCodeGenModule g_UnityEngine_ParticleSystemModule_CodeGenModule;
const Il2CppCodeGenModule g_UnityEngine_ParticleSystemModule_CodeGenModule =
{
"UnityEngine.ParticleSystemModule.dll",
18,
s_methodPointers,
s_InvokerIndices,
0,
NULL,
0,
NULL,
0,
NULL,
NULL,
g_UnityEngine_ParticleSystemModule_AttributeGenerators,
NULL, // module initializer,
NULL,
NULL,
NULL,
};
| 50.701754 | 147 | 0.88737 | [
"mesh"
] |
f37cf1c1ca664f384de217e4551c088df18ef484 | 2,643 | h | C | include/voxigen/volume/regular2DGrid.h | caseymcc/voxigen | cfb7c7e999a02cdf40fd7344b2d744bf9446837c | [
"MIT"
] | 38 | 2017-05-13T20:14:18.000Z | 2022-01-20T12:39:59.000Z | include/voxigen/volume/regular2DGrid.h | caseymcc/voxigen | cfb7c7e999a02cdf40fd7344b2d744bf9446837c | [
"MIT"
] | null | null | null | include/voxigen/volume/regular2DGrid.h | caseymcc/voxigen | cfb7c7e999a02cdf40fd7344b2d744bf9446837c | [
"MIT"
] | 6 | 2018-01-04T23:59:27.000Z | 2021-02-19T03:48:50.000Z | #ifndef _voxigen_regular2DGrid_h_
#define _voxigen_regular2DGrid_h_
#include <vector>
#include <glm/glm.hpp>
namespace voxigen
{
template<typename _Cell>
class Regular2DGrid
{
public:
typedef _Cell CellType;
// Regular2DGrid() {};
Regular2DGrid(size_t width, size_t height):m_size(width, height), m_cells(width*height){}
Regular2DGrid(size_t width, size_t height, CellType value):m_size(width, height), m_cells(width*height, value) {}
~Regular2DGrid() {};
glm::ivec2 findEmpty(const glm::ivec2 &size);
bool fill(const glm::ivec2 &index, const glm::ivec2 &size, const CellType &value);
private:
bool isEmpty(const glm::ivec2 &index, const glm::ivec2 &size);
std::vector<CellType> m_cells;
glm::ivec2 m_size;
};
template<typename _Cell>
bool Regular2DGrid<_Cell>::isEmpty(const glm::ivec2 &index, const glm::ivec2 &size)
{
size_t posX;
size_t posY=index.y*m_size.x;
if(index.x+size.x>m_size.x)
return false;
if(index.y+size.y>m_size.y)
return false;
for(size_t y=0; y<size.y; ++y)
{
posX=index.x;
for(size_t x=0; x<size.x; ++x)
{
if(!empty(m_cells[posY+posX]))
return false;
++posX;
}
posY+=m_size.x;
}
return true;
}
template<typename _Cell>
bool Regular2DGrid<_Cell>::fill(const glm::ivec2 &index, const glm::ivec2 &size, const CellType &value)
{
size_t posX;
size_t posY=index.y*m_size.x;
if(index.x+size.x>m_size.x)
return false;
if(index.y+size.y>m_size.y)
return false;
for(size_t y=0; y<size.y; ++y)
{
posX=index.x;
for(size_t x=0; x<size.x; ++x)
{
m_cells[posY+posX]=value;
++posX;
}
posY+=m_size.x;
}
return true;
}
template<typename _Cell>
glm::ivec2 Regular2DGrid<_Cell>::findEmpty(const glm::ivec2 &size)
{
glm::ivec2 index={0, 0};
bool valid=false;
while((index.x<m_size.x) && (index.y<m_size.y))
{
size_t posX=index.x;
size_t posY=index.y*m_size.x;
if(isEmpty(index, size))
{
valid=true;
break;
}
if(index.x<index.y)
index.x++;
else if(index.x==index.y)
{
index.x++;
index.y=0;
}
else
{
index.y++;
if(index.x==index.y)
index.x=0;
}
}
if(valid)
{
// fill(index, size);
return index;
}
return glm::ivec2(-1, -1);
}
}//namespace voxigen
#endif//_voxigen_regular2DGrid_h_
| 20.648438 | 117 | 0.564888 | [
"vector"
] |
f37d1e1600e4000aee1c5c23f6bd28bd89e1eb83 | 59,052 | h | C | CLI/FK_CLI/include/IndexFace_CLI.h | rita0222/FK | bc5786a5da0dd732e2f411c1a953b331323ee432 | [
"BSD-3-Clause"
] | 4 | 2020-05-15T03:43:53.000Z | 2021-06-05T16:21:31.000Z | CLI/FK_CLI/include/IndexFace_CLI.h | rita0222/FK | bc5786a5da0dd732e2f411c1a953b331323ee432 | [
"BSD-3-Clause"
] | 1 | 2020-05-19T09:27:16.000Z | 2020-05-21T02:12:54.000Z | CLI/FK_CLI/include/IndexFace_CLI.h | rita0222/FK | bc5786a5da0dd732e2f411c1a953b331323ee432 | [
"BSD-3-Clause"
] | null | null | null | #pragma once
#include <FK/IndexFace.h>
#include "Shape_CLI.h"
#include "Vector_CLI.h"
#include "BVHMotion_CLI.h"
namespace FK_CLI
{
using namespace System::Collections::Generic;
ref class fk_Solid;
//! インデックスフェースセットによる任意形状を生成、管理するクラス
/*!
* このクラスは、
* 「インデックスフェースセット」による任意形状を制御する機能を提供します。
*
* fk_IndexFaceSet の主な用途は、3次元形状データファイルからデータを読み込み、
* それを表示することです。以下のデータフォーマットをサポートしています。
* - VRML 形式
* - STL 形式
* - SMF 形式
* - HRC 形式
* - RDS (Ray Dream Studio) 形式
* - DXF 形式
* - MQO (Metasequoia) 形式
* - D3DX (DirectX) 形式
*
* また、これらのデータファイル入力の他に、
* 頂点座標データとインデックスフェースデータから
* 形状を自前で生成することも可能です。
* ただし、作成できる形状には制限があります。
* この機能の詳細は makeIFSet() を参照して下さい。
*
* 入力した形状に対し、各頂点を移動してアニメーションを表現することが可能です。
* この機能の詳細は MoveVPosition() を参照して下さい。
* 位相変化を伴う変形は、 fk_IndexFaceSet では行うことができません。
* 位相変化を伴う変形を行うには、 fk_Solid クラスを用いてください。
*
* D3DX 形式ではボーンアニメーションをサポートしていますが、
* その再生を行うことも可能です。
* この機能の詳細は setAnimationTime() を参照して下さい。
* また、ボーンアニメーションデータのみのデータとして BVH 形式を入力し、
* アニメーションをすることも可能になっています。
* この機能の詳細は setBVHMotion() を参照して下さい。
*
* 任意の形状を表現するクラスとして、
* fk_IndexFaceSet の他に fk_Solid があります。
* fk_IndexFaceSet は、
* fk_Solid と比較して高速な描画が行えるという長所があります。
* しかしその一方で、
* fk_IndexFaceSet は面が3角形か4角形のみ(そして混在は不可)
* という制限があります。
* また、位相変化を伴う変形には対応していません。
* より高度な形状表現や位相変化を伴う変形を利用する場合は
* fk_Solid を利用して下さい。
*
* fk_IndexFaceSet 自体は、テクスチャ描画に対応していません。
* テクスチャによる形状描画を行いたい場合は、
* fk_IFSTexture クラスを用いて下さい。
*
* \sa fk_IFSTexture, fk_Solid, fk_Shape, fk_Model,
* fk_Block, fk_Circle, fk_Sphere, fk_Prism, fk_Cone, fk_Capsule
*/
public ref class fk_IndexFaceSet : fk_Shape {
internal:
::FK::fk_IndexFaceSet * GetP(void);
public:
#ifndef FK_DOXYGEN_USER_PROCESS
fk_IndexFaceSet(bool argNewFlg);
#endif
//! コンストラクタ
fk_IndexFaceSet();
//! デストラクタ
~fk_IndexFaceSet();
//! ファイナライザ
!fk_IndexFaceSet();
//! 頂点数プロパティ
/*!
* 形状データの頂点数を参照します。
*/
property int PosSize {
int get();
}
//! 面数プロパティ
/*!
* 形状データの面数を参照します。
*/
property int FaceSize {
int get();
}
//! アニメーション時間プロパティ
/*!
* D3DX形式からの入力や、
* BVH情報からの入力によってアニメーションが設定されている場合、
* このプロパティを用いることで形状状態を任意のアニメーション時間に設定することができます。
*
* \sa ReadD3DXFile(), BVHMotion, fk_BVHMotion
*/
property double AnimationTime {
void set(double);
}
//! BVHデータプロパティ
/*!
* 形状に対し、BVH 形式によるアニメーションを設定します。
*
* \sa AnimationTime, ReadD3DXFile(), fk_BVHMotion
*/
property fk_BVHMotion^ BVHMotion {
void set(fk_BVHMotion^);
}
//! \name 形状ファイル・形状データ入力メソッド
///@{
//! SMFファイル入力メソッド
/*!
* SMF形式のファイルからデータを入力します。
*
* \param[in] name ファイル名
*
* \return 成功すれば true を、失敗すれば false を返します。
*/
bool ReadSMFFile(String^ name);
//! VRML ファイル入力メソッド1
/*!
* VRML形式のファイルからデータを入力します。
* VRMLでは、形状を表す様々なノードがありますが、
* 本メソッドが対応しているのは「IndexedFaceSet」
* ノードに記述された形状のみです。
*
* \param[in] name ファイル名
*
* \param[in] materialFlg
* true の場合、
* VRMLファイル中で設定されているマテリアル情報を入力します。
* false の場合は、マテリアル情報を無視します。
*
* \param[in] solidFlg
* true の場合、位相の隣接関係を最適化します。
* ただし、結果として入力に失敗する場合があります。
* false の場合は隣接関係を最適化せず、
* 入力データのままインデックスフェースセットを構築します。
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \note
* VRML形式は、1994年に策定された通称「VRML1.0」と、
* 1997年に策定された「VRML97」の2種類があり、
* VRML97は「VRML2.0」とも呼ばれます。
* 本メソッドでは入力フォーマットとして VRML2.0 を想定しています。
*
* \note
* VRMLは文法解釈、
* 特にセパレータの扱い方についてはあまり厳密になっておらず、
* 様々なデータによって異なる解釈がなされているようです。
* そのため、構文解析がうまくいかずに入力失敗する場合がありえます。
*/
bool ReadVRMLFile(String^ name, bool materialFlg, bool solidFlg);
//! VRML ファイル入力メソッド2
/*!
* VRML形式のファイルからデータを入力します。
* VRMLでは、形状を表す様々なノードがありますが、
* 本メソッドが対応しているのは「IndexedFaceSet」
* ノードに記述された形状のみです。
*
* なお、本メソッドは ReadVRMLFile(String^, bool, bool) において、
* 第3引数に true を入力した場合と同義となります。
*
* \param[in] name ファイル名
*
* \param[in] materialFlg
* true の場合、
* VRMLファイル中で設定されているマテリアル情報を入力します。
* false の場合は、マテリアル情報を無視します。
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \note
* VRML形式は、1994年に策定された通称「VRML1.0」と、
* 1997年に策定された「VRML97」の2種類があり、
* VRML97は「VRML2.0」とも呼ばれます。
* 本メソッドでは入力フォーマットとして VRML2.0 を想定しています。
*
* \note
* VRMLは文法解釈、
* 特にセパレータの扱い方についてはあまり厳密になっておらず、
* 様々なデータによって異なる解釈がなされているようです。
* そのため、構文解析がうまくいかずに入力失敗する場合がありえます。
*/
bool ReadVRMLFile(String^ name, bool materialFlg);
//! VRML ファイル入力メソッド3
/*!
* VRML形式のファイルからデータを入力します。
* VRMLでは、形状を表す様々なノードがありますが、
* 本メソッドが対応しているのは「IndexedFaceSet」
* ノードに記述された形状のみです。
*
* なお、本メソッドは ReadVRMLFile(String^, bool, bool) において、
* 第2引数と第3引数で共に true を入力した場合と同義となります。
*
* \param[in] name ファイル名
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \note
* VRML形式は、1994年に策定された通称「VRML1.0」と、
* 1997年に策定された「VRML97」の2種類があり、
* VRML97は「VRML2.0」とも呼ばれます。
* 本メソッドでは入力フォーマットとして VRML2.0 を想定しています。
*
* \note
* VRMLは文法解釈、
* 特にセパレータの扱い方についてはあまり厳密になっておらず、
* 様々なデータによって異なる解釈がなされているようです。
* そのため、構文解析がうまくいかずに入力失敗する場合がありえます。
*/
bool ReadVRMLFile(String^ name);
//! STL ファイル入力メソッド1
/*!
* STL形式のファイルからデータを入力します。
* 対応しているのは面データのみです。
* また、以下の条件に当てはまるデータは
* fk_IndexFaceSet では入力できません。
* - 5以上の角数である面が存在する。
* - 3角形面と4角形面が混在している。
*
* \param[in] name ファイル名
*
* \param[in] solidFlg
* true の場合、位相の隣接関係を最適化します。
* ただし、結果として入力に失敗する場合があります。
* false の場合は隣接関係を最適化せず、
* すべての面が独立した状態として形状を構築します。
*
* \param[in] tolerance
* solidFlg で true を指定した場合、
* 頂点同士が同一かどうかを判断するための距離許容誤差を指定します。
* solidFlg が false であった場合、この値は無視されます。
*
* \return 成功すれば true を、失敗すれば false を返します。
*/
bool ReadSTLFile(String^ name, bool solidFlg, double tolerance);
//! STL ファイル入力メソッド2
/*!
* STL形式のファイルからデータを入力します。
* 対応しているのは面データのみです。
* また、以下の条件に当てはまるデータは
* fk_IndexFaceSet では入力できません。
* - 5以上の角数である面が存在する。
* - 3角形面と4角形面が混在している。
*
* なお、本メソッドは ReadSTLFile(String^, bool, double) において、
* 第3引数に 1.0e-0.8 を入力した場合と同義となります。
*
* \param[in] name ファイル名
*
* \param[in] solidFlg
* true の場合、位相の隣接関係を最適化します。
* ただし、結果として入力に失敗する場合があります。
* false の場合は隣接関係を最適化せず、
* すべての面が独立した状態として形状を構築します。
*
* \return 成功すれば true を、失敗すれば false を返します。
*/
bool ReadSTLFile(String^ name, bool solidFlg);
//! STL ファイル入力メソッド3
/*!
* STL形式のファイルからデータを入力します。
* 対応しているのは面データのみです。
* また、以下の条件に当てはまるデータは
* fk_IndexFaceSet では入力できません。
* - 5以上の角数である面が存在する。
* - 3角形面と4角形面が混在している。
*
* なお、本メソッドは ReadSTLFile(String^, bool, double) において、
* 第2引数に true、第3引数に 1.0e-0.8 を入力した場合と同義となります。
*
* \param[in] name ファイル名
*
* \return 成功すれば true を、失敗すれば false を返します。
*/
bool ReadSTLFile(String^ name);
//! HRCファイル入力メソッド
/*!
* HRC形式のファイルからデータを入力します。
*
* \param[in] name ファイル名
*
* \return 成功すれば true を、失敗すれば false を返します。
*/
bool ReadHRCFile(String^ name);
//! RDSファイル入力メソッド1
/*!
* RDS (Ray Dream Studio) 形式のファイルからデータを入力します。
*
* \param[in] name ファイル名
*
* \param[in] solidFlg
* true の場合、位相の隣接関係を最適化します。
* ただし、結果として入力に失敗する場合があります。
* false の場合は隣接関係を最適化せず、
* すべての面が独立した状態として形状を構築します。
*
* \return 成功すれば true を、失敗すれば false を返します。
*/
bool ReadRDSFile(String^ name, bool solidFlg);
//! RDSファイル入力メソッド2
/*!
* RDS (Ray Dream Studio) 形式のファイルからデータを入力します。
* 本メソッドは、 ReadRDSFile(String^, bool) において、
* 第2引数に true を入力した場合と同義となります。
*
* \param[in] name ファイル名
*
* \return 成功すれば true を、失敗すれば false を返します。
*/
bool ReadRDSFile(String^ name);
//! DXFファイル入力メソッド1
/*!
* DXF 形式のファイルからデータを入力します。
*
* \param[in] name ファイル名
* \param[in] solidFlg
* true の場合、位相の隣接関係を最適化します。
* ただし、結果として入力に失敗する場合があります。
* false の場合は隣接関係を最適化せず、
* すべての面が独立した状態として形状を構築します。
*
* \return 成功すれば true を、失敗すれば false を返します。
*/
bool ReadDXFFile(String^ name, bool solidFlg);
//! DXFファイル入力メソッド1
/*!
* DXF 形式のファイルからデータを入力します。
* 本メソッドは、 ReadDXFFile(String^, bool) において、
* 第2引数に true を入力した場合と同義となります。
*
* \param[in] name ファイル名
*
* \return 成功すれば true を、失敗すれば false を返します。
*/
bool ReadDXFFile(String^ name);
//! MQOファイル入力メソッド1-1
/*!
* MQO 形式のファイルからデータを入力します。
*
* 本メソッドは、テクスチャ用のデータの入力は行いません。
* テクスチャデータも併せて表示を行いたい場合は、
* fk_IFSTexture クラスを利用して下さい。
*
* MQOデータには「オブジェクト」という概念があり、
* 1つの形状データが複数のオブジェクトによって構成されていることがあります。
* 本メソッドでは、ファイル名とともにオブジェクト名を指定する必要があります。
*
* \param[in] fileName ファイル名
* \param[in] objName オブジェクト名
*
* \param[in] solidFlg
* true の場合、位相の隣接関係を最適化します。
* ただし、結果として入力に失敗する場合があります。
* false の場合は隣接関係を最適化せず、
* すべての面が独立した状態として形状を構築します。
*
* \param[in] contFlg
* テクスチャ断絶の設定を指定します。これは、テクスチャ座標が不連続な箇所に対し、
* 形状の位相を断絶する操作を行うためのものです。
* これを true にした場合は断裂操作が行われ、
* テクスチャ座標が不連続な箇所が幾何的にも不連続となるように表示されます。
* ほとんどの場合は、断裂操作を行った方が良好な描画結果となります。
* ただし、断裂操作を行う際に新たな位相要素を生成するため、
* 本来のデータよりも頂点、稜線、面が若干増加する場合があります。
* false にした場合は、断裂操作を行わずに通常のデータ通り読み込みます。
*
* \param[in] materialFlg
* true の場合、MQOファイル中で設定されているマテリアル情報を入力します。
* false の場合は、マテリアル情報を無視します。
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \sa ReadMQOData(), fk_IFSTexture::ReadMQOFile()
*/
bool ReadMQOFile(String^ fileName, String^ objName,
bool solidFlg, bool contFlg, bool materialFlg);
//! MQOファイル入力メソッド1-2
/*!
* MQO 形式のファイルからデータを入力します。
*
* 本メソッドは、テクスチャ用のデータの入力は行いません。
* テクスチャデータも併せて表示を行いたい場合は、
* fk_IFSTexture クラスを利用して下さい。
*
* MQOデータには「オブジェクト」という概念があり、
* 1つの形状データが複数のオブジェクトによって構成されていることがあります。
* 本メソッドでは、ファイル名とともにオブジェクト名を指定する必要があります。
*
* なお、本メソッドは ReadMQOFile(String^, String^, bool, bool, bool) において、
* 第5引数に false を入力した場合と同義となります。
*
* \param[in] fileName ファイル名
* \param[in] objName オブジェクト名
*
* \param[in] solidFlg
* true の場合、位相の隣接関係を最適化します。
* ただし、結果として入力に失敗する場合があります。
* false の場合は隣接関係を最適化せず、
* すべての面が独立した状態として形状を構築します。
*
* \param[in] contFlg
* テクスチャ断絶の設定を指定します。これは、テクスチャ座標が不連続な箇所に対し、
* 形状の位相を断絶する操作を行うためのものです。
* これを true にした場合は断裂操作が行われ、
* テクスチャ座標が不連続な箇所が幾何的にも不連続となるように表示されます。
* ほとんどの場合は、断裂操作を行った方が良好な描画結果となります。
* ただし、断裂操作を行う際に新たな位相要素を生成するため、
* 本来のデータよりも頂点、稜線、面が若干増加する場合があります。
* false にした場合は、断裂操作を行わずに通常のデータ通り読み込みます。
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \sa ReadMQOData(), fk_IFSTexture::ReadMQOFile()
*/
bool ReadMQOFile(String^ fileName, String^ objName, bool solidFlg, bool contFlg);
//! MQOファイル入力メソッド1-3
/*!
* MQO 形式のファイルからデータを入力します。
*
* 本メソッドは、テクスチャ用のデータの入力は行いません。
* テクスチャデータも併せて表示を行いたい場合は、
* fk_IFSTexture クラスを利用して下さい。
*
* MQOデータには「オブジェクト」という概念があり、
* 1つの形状データが複数のオブジェクトによって構成されていることがあります。
* 本メソッドでは、ファイル名とともにオブジェクト名を指定する必要があります。
*
* なお、本メソッドは ReadMQOFile(String^, String^, bool, bool, bool) において、
* 第4引数に true を、第5引数に false を入力した場合と同義となります。
*
* \param[in] fileName ファイル名
* \param[in] objName オブジェクト名
* \param[in] solidFlg
* true の場合、位相の隣接関係を最適化します。
* ただし、結果として入力に失敗する場合があります。
* false の場合は隣接関係を最適化せず、
* すべての面が独立した状態として形状を構築します。
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \sa ReadMQOData(), fk_IFSTexture::ReadMQOFile()
*/
bool ReadMQOFile(String^ fileName, String^ objName, bool solidFlg);
//! MQOファイル入力メソッド1-4
/*!
* MQO 形式のファイルからデータを入力します。
*
* 本メソッドは、テクスチャ用のデータの入力は行いません。
* テクスチャデータも併せて表示を行いたい場合は、
* fk_IFSTexture クラスを利用して下さい。
*
* MQOデータには「オブジェクト」という概念があり、
* 1つの形状データが複数のオブジェクトによって構成されていることがあります。
* 本メソッドでは、ファイル名とともにオブジェクト名を指定する必要があります。
*
* なお、本メソッドは ReadMQOFile(String^, String^, bool, bool, bool) において、
* 第3引数に true を、第4引数に true を、第5引数に false を入力した場合と同義となります。
*
* \param[in] fileName ファイル名
* \param[in] objName オブジェクト名
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \sa ReadMQOData(), fk_IFSTexture::ReadMQOFile()
*/
bool ReadMQOFile(String^ fileName, String^ objName);
//! MQOファイル入力メソッド2-1
/*!
* MQO 形式のファイルからデータを入力します。
*
* 本メソッドは、テクスチャ用のデータの入力は行いません。
* テクスチャデータも併せて表示を行いたい場合は、
* fk_IFSTexture クラスを利用して下さい。
*
* MQOデータには「オブジェクト」という概念があり、
* 1つの形状データが複数のオブジェクトによって構成されていることがあります。
* 本メソッドでは、ファイル名とともにオブジェクト名を指定する必要があります。
*
* \param[in] fileName ファイル名
*
* \param[in] objName オブジェクト名
*
* \param[in] materialID
* MQOデータではマテリアルを複数設定することができ、
* 各ポリゴンに対してどのマテリアルを割り振るかのIDが設定されています。
* この引数にマテリアルIDを指定すると、そのIDを持つポリゴンのみを読み込みます。
* materialID に -1 を入力した場合は、すべてのポリゴンを読み込みます。
*
* \param[in] solidFlg
* true の場合、位相の隣接関係を最適化します。
* ただし、結果として入力に失敗する場合があります。
* false の場合は隣接関係を最適化せず、
* すべての面が独立した状態として形状を構築します。
*
* \param[in] contFlg
* テクスチャ断絶の設定を指定します。これは、テクスチャ座標が不連続な箇所に対し、
* 形状の位相を断絶する操作を行うためのものです。
* これを true にした場合は断裂操作が行われ、
* テクスチャ座標が不連続な箇所が幾何的にも不連続となるように表示されます。
* ほとんどの場合は、断裂操作を行った方が良好な描画結果となります。
* ただし、断裂操作を行う際に新たな位相要素を生成するため、
* 本来のデータよりも頂点、稜線、面が若干増加する場合があります。
* false にした場合は、断裂操作を行わずに通常のデータ通り読み込みます。
*
* \param[in] materialFlg
* true の場合、MQOファイル中で設定されているマテリアル情報を入力します。
* false の場合は、マテリアル情報を無視します。
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \sa ReadMQOData(), fk_IFSTexture::ReadMQOFile()
*/
bool ReadMQOFile(String^ fileName, String^ objName,
int materialID, bool solidFlg, bool contFlg, bool materialFlg);
//! MQOファイル入力メソッド2-2
/*!
* MQO 形式のファイルからデータを入力します。
*
* 本メソッドは、テクスチャ用のデータの入力は行いません。
* テクスチャデータも併せて表示を行いたい場合は、
* fk_IFSTexture クラスを利用して下さい。
*
* MQOデータには「オブジェクト」という概念があり、
* 1つの形状データが複数のオブジェクトによって構成されていることがあります。
* 本メソッドでは、ファイル名とともにオブジェクト名を指定する必要があります。
*
* なお、本メソッドは ReadMQOFile(String^, String^, int, bool, bool, bool) において、
* 第6引数に false を入力している場合と同義となります。
*
* \param[in] fileName ファイル名
*
* \param[in] objName オブジェクト名
*
* \param[in] materialID
* MQOデータではマテリアルを複数設定することができ、
* 各ポリゴンに対してどのマテリアルを割り振るかのIDが設定されています。
* この引数にマテリアルIDを指定すると、そのIDを持つポリゴンのみを読み込みます。
* materialID に -1 を入力した場合は、すべてのポリゴンを読み込みます。
*
* \param[in] solidFlg
* true の場合、位相の隣接関係を最適化します。
* ただし、結果として入力に失敗する場合があります。
* false の場合は隣接関係を最適化せず、
* すべての面が独立した状態として形状を構築します。
*
* \param[in] contFlg
* テクスチャ断絶の設定を指定します。これは、テクスチャ座標が不連続な箇所に対し、
* 形状の位相を断絶する操作を行うためのものです。
* これを true にした場合は断裂操作が行われ、
* テクスチャ座標が不連続な箇所が幾何的にも不連続となるように表示されます。
* ほとんどの場合は、断裂操作を行った方が良好な描画結果となります。
* ただし、断裂操作を行う際に新たな位相要素を生成するため、
* 本来のデータよりも頂点、稜線、面が若干増加する場合があります。
* false にした場合は、断裂操作を行わずに通常のデータ通り読み込みます。
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \sa ReadMQOData(), fk_IFSTexture::ReadMQOFile()
*/
bool ReadMQOFile(String^ fileName, String^ objName,
int materialID, bool solidFlg, bool contFlg);
//! MQOファイル入力メソッド2-3
/*!
* MQO 形式のファイルからデータを入力します。
*
* 本メソッドは、テクスチャ用のデータの入力は行いません。
* テクスチャデータも併せて表示を行いたい場合は、
* fk_IFSTexture クラスを利用して下さい。
*
* MQOデータには「オブジェクト」という概念があり、
* 1つの形状データが複数のオブジェクトによって構成されていることがあります。
* 本メソッドでは、ファイル名とともにオブジェクト名を指定する必要があります。
*
* なお、本メソッドは ReadMQOFile(String^, String^, int, bool, bool, bool) において、
* 第5引数に true を、第6引数に false を入力している場合と同義となります。
*
* \param[in] fileName ファイル名
*
* \param[in] objName オブジェクト名
*
* \param[in] materialID
* MQOデータではマテリアルを複数設定することができ、
* 各ポリゴンに対してどのマテリアルを割り振るかのIDが設定されています。
* この引数にマテリアルIDを指定すると、そのIDを持つポリゴンのみを読み込みます。
* materialID に -1 を入力した場合は、すべてのポリゴンを読み込みます。
*
* \param[in] solidFlg
* true の場合、位相の隣接関係を最適化します。
* ただし、結果として入力に失敗する場合があります。
* false の場合は隣接関係を最適化せず、
* すべての面が独立した状態として形状を構築します。
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \sa ReadMQOData(), fk_IFSTexture::ReadMQOFile()
*/
bool ReadMQOFile(String^ fileName, String^ objName,
int materialID, bool solidFlg);
//! MQOファイル入力メソッド2-4
/*!
* MQO 形式のファイルからデータを入力します。
*
* 本メソッドは、テクスチャ用のデータの入力は行いません。
* テクスチャデータも併せて表示を行いたい場合は、
* fk_IFSTexture クラスを利用して下さい。
*
* MQOデータには「オブジェクト」という概念があり、
* 1つの形状データが複数のオブジェクトによって構成されていることがあります。
* 本メソッドでは、ファイル名とともにオブジェクト名を指定する必要があります。
*
* なお、本メソッドは ReadMQOFile(String^, String^, int, bool, bool, bool) において、
* 第4引数に true を、第5引数に true を、第6引数に false を入力している場合と同義となります。
*
* \param[in] fileName ファイル名
*
* \param[in] objName オブジェクト名
*
* \param[in] materialID
* MQOデータではマテリアルを複数設定することができ、
* 各ポリゴンに対してどのマテリアルを割り振るかのIDが設定されています。
* この引数にマテリアルIDを指定すると、そのIDを持つポリゴンのみを読み込みます。
* materialID に -1 を入力した場合は、すべてのポリゴンを読み込みます。
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \sa ReadMQOData(), fk_IFSTexture::ReadMQOFile()
*/
bool ReadMQOFile(String^ fileName, String^ objName, int materialID);
//! MQOデータ入力メソッド1-1
/*!
* MQO形式のデータを入力します。
* 本メソッドでは、MQO形式のデータが既に
* Byte 型の配列中に入力されていると仮定し、
* ReadMQOFile() メソッドと同様の処理を行います。
*
* 本メソッドは、テクスチャ用のデータの入力は行いません。
* テクスチャデータも併せて表示を行いたい場合は、
* fk_IFSTexture クラスを利用して下さい。
*
* MQOデータには「オブジェクト」という概念があり、
* 1つの形状データが複数のオブジェクトによって構成されていることがあります。
* 本メソッドでは、ファイル名とともにオブジェクト名を指定する必要があります。
*
* \param[in] buffer データが格納されているバッファ
*
* \param[in] objName オブジェクト名
*
* \param[in] solidFlg
* true の場合、位相の隣接関係を最適化します。
* ただし、結果として入力に失敗する場合があります。
* false の場合は隣接関係を最適化せず、
* すべての面が独立した状態として形状を構築します。
*
* \param[in] contFlg
* テクスチャ断絶の設定を指定します。これは、テクスチャ座標が不連続な箇所に対し、
* 形状の位相を断絶する操作を行うためのものです。
* これを true にした場合は断裂操作が行われ、
* テクスチャ座標が不連続な箇所が幾何的にも不連続となるように表示されます。
* ほとんどの場合は、断裂操作を行った方が良好な描画結果となります。
* ただし、断裂操作を行う際に新たな位相要素を生成するため、
* 本来のデータよりも頂点、稜線、面が若干増加する場合があります。
* false にした場合は、断裂操作を行わずに通常のデータ通り読み込みます。
*
* \param[in] materialFlg
* true の場合、MQOデータ中で設定されているマテリアル情報を入力します。
* false の場合は、マテリアル情報を無視します。
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \sa ReadMQOFile()
*/
bool ReadMQOData(IEnumerable<Byte>^ buffer, String^ objName,
bool solidFlg, bool contFlg, bool materialFlg);
//! MQOデータ入力メソッド1-2
/*!
* MQO形式のデータを入力します。
* 本メソッドでは、MQO形式のデータが既に
* Byte 型の配列中に入力されていると仮定し、
* ReadMQOFile() メソッドと同様の処理を行います。
*
* 本メソッドは、テクスチャ用のデータの入力は行いません。
* テクスチャデータも併せて表示を行いたい場合は、
* fk_IFSTexture クラスを利用して下さい。
*
* MQOデータには「オブジェクト」という概念があり、
* 1つの形状データが複数のオブジェクトによって構成されていることがあります。
* 本メソッドでは、ファイル名とともにオブジェクト名を指定する必要があります。
*
* なお、本メソッドは ReadMQOData(IEnumerable<Byte>^, String^, bool, bool, bool) において、
* 第5引数に false を入力している場合と同義となります。
*
* \param[in] buffer データが格納されているバッファ
*
* \param[in] objName オブジェクト名
*
* \param[in] solidFlg
* true の場合、位相の隣接関係を最適化します。
* ただし、結果として入力に失敗する場合があります。
* false の場合は隣接関係を最適化せず、
* すべての面が独立した状態として形状を構築します。
*
* \param[in] contFlg
* テクスチャ断絶の設定を指定します。これは、テクスチャ座標が不連続な箇所に対し、
* 形状の位相を断絶する操作を行うためのものです。
* これを true にした場合は断裂操作が行われ、
* テクスチャ座標が不連続な箇所が幾何的にも不連続となるように表示されます。
* ほとんどの場合は、断裂操作を行った方が良好な描画結果となります。
* ただし、断裂操作を行う際に新たな位相要素を生成するため、
* 本来のデータよりも頂点、稜線、面が若干増加する場合があります。
* false にした場合は、断裂操作を行わずに通常のデータ通り読み込みます。
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \sa ReadMQOFile()
*/
bool ReadMQOData(IEnumerable<Byte>^ buffer, String^ objName, bool solidFlg, bool contFlg);
//! MQOデータ入力メソッド1-3
/*!
* MQO形式のデータを入力します。
* 本メソッドでは、MQO形式のデータが既に
* Byte 型の配列中に入力されていると仮定し、
* ReadMQOFile() メソッドと同様の処理を行います。
*
* 本メソッドは、テクスチャ用のデータの入力は行いません。
* テクスチャデータも併せて表示を行いたい場合は、
* fk_IFSTexture クラスを利用して下さい。
*
* MQOデータには「オブジェクト」という概念があり、
* 1つの形状データが複数のオブジェクトによって構成されていることがあります。
* 本メソッドでは、ファイル名とともにオブジェクト名を指定する必要があります。
*
* なお、本メソッドは ReadMQOData(IEnumerable<Byte>^, String^, bool, bool, bool) において、
* 第4引数に true を、第5引数に false を入力している場合と同義となります。
*
* \param[in] buffer データが格納されているバッファ
*
* \param[in] objName オブジェクト名
*
* \param[in] solidFlg
* true の場合、位相の隣接関係を最適化します。
* ただし、結果として入力に失敗する場合があります。
* false の場合は隣接関係を最適化せず、
* すべての面が独立した状態として形状を構築します。
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \sa ReadMQOFile()
*/
bool ReadMQOData(IEnumerable<Byte>^ buffer, String^ objName, bool solidFlg);
//! MQOデータ入力メソッド1-4
/*!
* MQO形式のデータを入力します。
* 本メソッドでは、MQO形式のデータが既に
* Byte 型の配列中に入力されていると仮定し、
* ReadMQOFile() メソッドと同様の処理を行います。
*
* 本メソッドは、テクスチャ用のデータの入力は行いません。
* テクスチャデータも併せて表示を行いたい場合は、
* fk_IFSTexture クラスを利用して下さい。
*
* MQOデータには「オブジェクト」という概念があり、
* 1つの形状データが複数のオブジェクトによって構成されていることがあります。
* 本メソッドでは、ファイル名とともにオブジェクト名を指定する必要があります。
*
* なお、本メソッドは ReadMQOData(IEnumerable<Byte>^, String^, bool, bool, bool) において、
* 第3引数に true を、第4引数に true を、第5引数に false を入力している場合と同義となります。
*
* \param[in] buffer データが格納されているバッファ
*
* \param[in] objName オブジェクト名
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \sa ReadMQOFile()
*/
bool ReadMQOData(IEnumerable<Byte>^ buffer, String^ objName);
//! MQOデータ入力メソッド2-1
/*!
* MQO形式のデータを入力します。
* 本メソッドでは、MQO形式のデータが既に
* Byte 型の配列中に入力されていると仮定し、
* ReadMQOFile() メソッドと同様の処理を行います。
*
* 本メソッドは、テクスチャ用のデータの入力は行いません。
* テクスチャデータも併せて表示を行いたい場合は、
* fk_IFSTexture クラスを利用して下さい。
*
* MQOデータには「オブジェクト」という概念があり、
* 1つの形状データが複数のオブジェクトによって構成されていることがあります。
* 本メソッドでは、ファイル名とともにオブジェクト名を指定する必要があります。
*
* \param[in] buffer データが格納されているバッファ
*
* \param[in] objName オブジェクト名
*
* \param[in] materialID
* MQOデータではマテリアルを複数設定することができ、
* 各ポリゴンに対してどのマテリアルを割り振るかのIDが設定されています。
* この引数にマテリアルIDを指定すると、そのIDを持つポリゴンのみを読み込みます。
* materialID に -1 を入力した場合は、すべてのポリゴンを読み込みます。
*
* \param[in] solidFlg
* true の場合、位相の隣接関係を最適化します。
* ただし、結果として入力に失敗する場合があります。
* false の場合は隣接関係を最適化せず、
* すべての面が独立した状態として形状を構築します。
*
* \param[in] contFlg
* テクスチャ断絶の設定を指定します。これは、テクスチャ座標が不連続な箇所に対し、
* 形状の位相を断絶する操作を行うためのものです。
* これを true にした場合は断裂操作が行われ、
* テクスチャ座標が不連続な箇所が幾何的にも不連続となるように表示されます。
* ほとんどの場合は、断裂操作を行った方が良好な描画結果となります。
* ただし、断裂操作を行う際に新たな位相要素を生成するため、
* 本来のデータよりも頂点、稜線、面が若干増加する場合があります。
* false にした場合は、断裂操作を行わずに通常のデータ通り読み込みます。
*
* \param[in] materialFlg
* true の場合、MQOデータ中で設定されているマテリアル情報を入力します。
* false の場合は、マテリアル情報を無視します。
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \sa ReadMQOFile()
*/
bool ReadMQOData(IEnumerable<Byte>^ buffer, String^ objName,
int materialID, bool solidFlg, bool contFlg, bool materialFlg);
//! MQOデータ入力メソッド2-2
/*!
* MQO形式のデータを入力します。
* 本メソッドでは、MQO形式のデータが既に
* Byte 型の配列中に入力されていると仮定し、
* ReadMQOFile() メソッドと同様の処理を行います。
*
* 本メソッドは、テクスチャ用のデータの入力は行いません。
* テクスチャデータも併せて表示を行いたい場合は、
* fk_IFSTexture クラスを利用して下さい。
*
* MQOデータには「オブジェクト」という概念があり、
* 1つの形状データが複数のオブジェクトによって構成されていることがあります。
* 本メソッドでは、ファイル名とともにオブジェクト名を指定する必要があります。
*
* なお、本メソッドは ReadMQOData(IEnumerable<Byte>^, String^, int, bool, bool, bool) において、
* 第6引数に false を入力している場合と同義となります。
*
* \param[in] buffer データが格納されているバッファ
*
* \param[in] objName オブジェクト名
*
* \param[in] materialID
* MQOデータではマテリアルを複数設定することができ、
* 各ポリゴンに対してどのマテリアルを割り振るかのIDが設定されています。
* この引数にマテリアルIDを指定すると、そのIDを持つポリゴンのみを読み込みます。
* materialID に -1 を入力した場合は、すべてのポリゴンを読み込みます。
*
* \param[in] solidFlg
* true の場合、位相の隣接関係を最適化します。
* ただし、結果として入力に失敗する場合があります。
* false の場合は隣接関係を最適化せず、
* すべての面が独立した状態として形状を構築します。
*
* \param[in] contFlg
* テクスチャ断絶の設定を指定します。これは、テクスチャ座標が不連続な箇所に対し、
* 形状の位相を断絶する操作を行うためのものです。
* これを true にした場合は断裂操作が行われ、
* テクスチャ座標が不連続な箇所が幾何的にも不連続となるように表示されます。
* ほとんどの場合は、断裂操作を行った方が良好な描画結果となります。
* ただし、断裂操作を行う際に新たな位相要素を生成するため、
* 本来のデータよりも頂点、稜線、面が若干増加する場合があります。
* false にした場合は、断裂操作を行わずに通常のデータ通り読み込みます。
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \sa ReadMQOFile()
*/
bool ReadMQOData(IEnumerable<Byte>^ buffer, String^ objName,
int materialID, bool solidFlg, bool contFlg);
//! MQOデータ入力メソッド2-3
/*!
* MQO形式のデータを入力します。
* 本メソッドでは、MQO形式のデータが既に
* Byte 型の配列中に入力されていると仮定し、
* ReadMQOFile() メソッドと同様の処理を行います。
*
* 本メソッドは、テクスチャ用のデータの入力は行いません。
* テクスチャデータも併せて表示を行いたい場合は、
* fk_IFSTexture クラスを利用して下さい。
*
* MQOデータには「オブジェクト」という概念があり、
* 1つの形状データが複数のオブジェクトによって構成されていることがあります。
* 本メソッドでは、ファイル名とともにオブジェクト名を指定する必要があります。
*
* なお、本メソッドは ReadMQOData(IEnumerable<Byte>^, String^, int, bool, bool, bool) において、
* 第5引数に true を、第6引数に false を入力している場合と同義となります。
*
* \param[in] buffer データが格納されているバッファ
*
* \param[in] objName オブジェクト名
*
* \param[in] materialID
* MQOデータではマテリアルを複数設定することができ、
* 各ポリゴンに対してどのマテリアルを割り振るかのIDが設定されています。
* この引数にマテリアルIDを指定すると、そのIDを持つポリゴンのみを読み込みます。
* materialID に -1 を入力した場合は、すべてのポリゴンを読み込みます。
*
* \param[in] solidFlg
* true の場合、位相の隣接関係を最適化します。
* ただし、結果として入力に失敗する場合があります。
* false の場合は隣接関係を最適化せず、
* すべての面が独立した状態として形状を構築します。
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \sa ReadMQOFile()
*/
bool ReadMQOData(IEnumerable<Byte>^ buffer, String^ objName, int materialID, bool solidFlg);
//! MQOデータ入力メソッド2-4
/*!
* MQO形式のデータを入力します。
* 本メソッドでは、MQO形式のデータが既に
* Byte 型の配列中に入力されていると仮定し、
* ReadMQOFile() メソッドと同様の処理を行います。
*
* 本メソッドは、テクスチャ用のデータの入力は行いません。
* テクスチャデータも併せて表示を行いたい場合は、
* fk_IFSTexture クラスを利用して下さい。
*
* MQOデータには「オブジェクト」という概念があり、
* 1つの形状データが複数のオブジェクトによって構成されていることがあります。
* 本メソッドでは、ファイル名とともにオブジェクト名を指定する必要があります。
*
* なお、本メソッドは ReadMQOData(IEnumerable<Byte>^, String^, int, bool, bool, bool) において、
* 第4引数に true を、第5引数に true を、第6引数に false を入力している場合と同義となります。
*
* \param[in] buffer データが格納されているバッファ
*
* \param[in] objName オブジェクト名
*
* \param[in] materialID
* MQOデータではマテリアルを複数設定することができ、
* 各ポリゴンに対してどのマテリアルを割り振るかのIDが設定されています。
* この引数にマテリアルIDを指定すると、そのIDを持つポリゴンのみを読み込みます。
* materialID に -1 を入力した場合は、すべてのポリゴンを読み込みます。
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \sa ReadMQOFile()
*/
bool ReadMQOData(IEnumerable<Byte>^ buffer, String^ objName, int materialID);
//! DirectX (D3DX) ファイル入力メソッド1-1
/*!
* DirectX 形式 (X 形式と呼ばれることもあります) のフォーマット
* (以下、「D3DX形式」) であるファイルからデータを入力します。
* 本メソッドで入力できるのは形状データとアニメーションデータです。
* テクスチャデータを入力したい場合は、
* fk_IndexFaceSet クラスではなく fk_IFSTexture クラスを利用して下さい。
*
* D3DXデータには「オブジェクト」という概念があり、
* 1つの形状データが複数のオブジェクトによって構成されていることがあります。
* 本メソッドでは、ファイル名とともにオブジェクト名を指定する必要があります。
*
* \param[in] fileName ファイル名
*
* \param[in] objName オブジェクト名。
* D3DX 形式では、オブジェクト名を省略することが許容されています。
* そのような場合は、この引数に空文字列 ( "" ) を入れてください。
* この場合、ファイル中で最初に存在するオブジェクトのデータを入力します。
*
* \param[in] solidFlg
* true の場合、位相の隣接関係を最適化します。
* ただし、結果として入力に失敗する場合があります。
* false の場合は隣接関係を最適化せず、
* すべての面が独立した状態として形状を構築します。
*
* \return ファイルの入力に成功した場合 true を、失敗した場合 false を返します。
*
* \sa fk_IFSTexture::ReadD3DXFile()
*/
bool ReadD3DXFile(String^ fileName, String^ objName, bool solidFlg);
//! DirectX (D3DX) ファイル入力メソッド1-2
/*!
* DirectX 形式 (X 形式と呼ばれることもあります) のフォーマット
* (以下、「D3DX形式」) であるファイルからデータを入力します。
* 本メソッドで入力できるのは形状データとアニメーションデータです。
* テクスチャデータを入力したい場合は、
* fk_IndexFaceSet クラスではなく fk_IFSTexture クラスを利用して下さい。
*
* D3DXデータには「オブジェクト」という概念があり、
* 1つの形状データが複数のオブジェクトによって構成されていることがあります。
* 本メソッドでは、ファイル名とともにオブジェクト名を指定する必要があります。
*
* なお、本メソッドは ReadD3DXFile(String^, String^, bool) において、
* 第3引数に true を入力している場合と同義となります。
*
* \param[in] fileName ファイル名
*
* \param[in] objName オブジェクト名。
* D3DX 形式では、オブジェクト名を省略することが許容されています。
* そのような場合は、この引数に空文字列 ( "" ) を入れてください。
* この場合、ファイル中で最初に存在するオブジェクトのデータを入力します。
*
* \return ファイルの入力に成功した場合 true を、失敗した場合 false を返します。
*
* \sa fk_IFSTexture::ReadD3DXFile()
*/
bool ReadD3DXFile(String^ fileName, String^ objName);
//! DirectX (D3DX) ファイル入力メソッド2-1
/*!
* DirectX 形式 (X 形式と呼ばれることもあります) のフォーマット
* (以下、「D3DX形式」) であるファイルからデータを入力します。
* 本メソッドで入力できるのは形状データとアニメーションデータです。
* テクスチャデータを入力したい場合は、
* fk_IndexFaceSet クラスではなく fk_IFSTexture クラスを利用して下さい。
*
* D3DXデータには「オブジェクト」という概念があり、
* 1つの形状データが複数のオブジェクトによって構成されていることがあります。
* 本メソッドでは、ファイル名とともにオブジェクト名を指定する必要があります。
*
* \param[in] fileName ファイル名
*
* \param[in] objName オブジェクト名。
* D3DX 形式では、オブジェクト名を省略することが許容されています。
* そのような場合は、この引数に空文字列 ( "" ) を入れてください。
* この場合、ファイル中で最初に存在するオブジェクトのデータを入力します。
*
* \param[in] materialID
* D3DXデータではマテリアルを複数設定することができ、
* 各ポリゴンに対してどのマテリアルを割り振るかのIDが設定されています。
* この引数にマテリアルIDを指定すると、そのIDを持つポリゴンのみを読み込みます。
* materialID に -1 を入力した場合は、すべてのポリゴンを読み込みます。
*
* \param[in] solidFlg
* true の場合、位相の隣接関係を最適化します。
* ただし、結果として入力に失敗する場合があります。
* false の場合は隣接関係を最適化せず、
* すべての面が独立した状態として形状を構築します。
*
* \return ファイルの入力に成功した場合 true を、失敗した場合 false を返します。
*
* \sa fk_IFSTexture::ReadD3DXFile()
*/
bool ReadD3DXFile(String^ fileName, String^ objName, int materialID, bool solidFlg);
//! DirectX (D3DX) ファイル入力メソッド2-2
/*!
* DirectX 形式 (X 形式と呼ばれることもあります) のフォーマット
* (以下、「D3DX形式」) であるファイルからデータを入力します。
* 本メソッドで入力できるのは形状データとアニメーションデータです。
* テクスチャデータを入力したい場合は、
* fk_IndexFaceSet クラスではなく fk_IFSTexture クラスを利用して下さい。
*
* D3DXデータには「オブジェクト」という概念があり、
* 1つの形状データが複数のオブジェクトによって構成されていることがあります。
* 本メソッドでは、ファイル名とともにオブジェクト名を指定する必要があります。
*
* なお、本メソッドは ReadD3DXFile(String^, String^, int, bool) において、
* 第4引数に true を入力している場合と同義となります。
*
* \param[in] fileName ファイル名
*
* \param[in] objName オブジェクト名。
* D3DX 形式では、オブジェクト名を省略することが許容されています。
* そのような場合は、この引数に空文字列 ( "" ) を入れてください。
* この場合、ファイル中で最初に存在するオブジェクトのデータを入力します。
*
* \param[in] materialID
* D3DXデータではマテリアルを複数設定することができ、
* 各ポリゴンに対してどのマテリアルを割り振るかのIDが設定されています。
* この引数にマテリアルIDを指定すると、そのIDを持つポリゴンのみを読み込みます。
* materialID に -1 を入力した場合は、すべてのポリゴンを読み込みます。
*
* \return ファイルの入力に成功した場合 true を、失敗した場合 false を返します。
*
* \sa fk_IFSTexture::ReadD3DXFile()
*/
bool ReadD3DXFile(String^ fileName, String^ objName, int materialID);
///@}
//! \name 形状ファイル・形状データ出力メソッド
///@{
//! VRML ファイル出力メソッド1-1
/*!
* VRML (VRML2.0) 形式で形状データを出力します。
*
* \param[in] fileName ファイル名
*
* \param[in] material
* VRMLファイル中に「Material」ノードとしてマテリアル情報を保存します。
* null を代入した場合は、VRMLファイル中に「Material」ノードを生成しません。
*
* \param[in] triFlg
* 仮想メソッドからの継承のために存在する引数で、処理には一切影響しません。
*
* \return ファイルの出力に成功した場合 true を、失敗した場合 false を返します。
*/
bool WriteVRMLFile(String^ fileName, fk_Material^ material, bool triFlg);
//! VRML ファイル出力メソッド1-2
/*!
* VRML (VRML2.0) 形式で形状データを出力します。
*
* なお、本メソッドは WriteVRMLFile(String^, fk_Material^, bool) において、
* 第3引数に false を入力している場合と同義となります。
*
* \param[in] fileName ファイル名
*
* \param[in] material
* VRMLファイル中に「Material」ノードとしてマテリアル情報を保存します。
* null を代入した場合は、VRMLファイル中に「Material」ノードを生成しません。
*
* \return ファイルの出力に成功した場合 true を、失敗した場合 false を返します。
*/
bool WriteVRMLFile(String^ fileName, fk_Material^ material);
//! VRML ファイル出力メソッド1-3
/*!
* VRML (VRML2.0) 形式で形状データを出力します。
*
* なお、本メソッドは WriteVRMLFile(String^, fk_Material^, bool) において、
* 第2引数に null を、第3引数に false を入力している場合と同義となります。
*
* \param[in] fileName ファイル名
*
* \return ファイルの出力に成功した場合 true を、失敗した場合 false を返します。
*/
bool WriteVRMLFile(String^ fileName);
//! VRML ファイル出力メソッド2-1
/*!
* VRML (VRML2.0) 形式で形状データを出力します。
* この引数形式の場合は、
* CoordinateInterpolator ノードを用いた
* アニメーションデータを出力することが可能です。
*
* \param[in] fileName ファイル名
*
* \param[in] time
* CoordinateInterpolator における時間配列 (key) を入力します。
*
* \param[in] pos
* CoordinateInterpolator における位置ベクトル配列 (keyValue) を入力します。
*
* \param[in] material
* VRMLファイル中に「Material」ノードとしてマテリアル情報を保存します。
* nullptr を代入した場合は、VRMLファイル中に「Material」ノードを生成しません。
*
* \param[in] triFlg
* 仮想メソッドからの継承のために存在する引数で、処理には一切影響しません。
*
* \return ファイルの出力に成功した場合 true を、失敗した場合 false を返します。
*/
bool WriteVRMLFile(String^ fileName, IEnumerable<double>^ time,
IEnumerable<fk_Vector^>^ pos, fk_Material^ material, bool triFlg);
//! VRML ファイル出力メソッド2-2
/*!
* VRML (VRML2.0) 形式で形状データを出力します。
* この引数形式の場合は、
* CoordinateInterpolator ノードを用いた
* アニメーションデータを出力することが可能です。
*
* なお、本メソッドは
* WriteVRMLFile(String^, IEnumerable<double>^,
* IEnumerable<fk_Vector^>^, fk_Material^, bool) において、
* 第5引数に false を入力している場合と同義となります。
*
* \param[in] fileName ファイル名
*
* \param[in] time
* CoordinateInterpolator における時間配列 (key) を入力します。
*
* \param[in] pos
* CoordinateInterpolator における位置ベクトル配列 (keyValue) を入力します。
*
* \param[in] material
* VRMLファイル中に「Material」ノードとしてマテリアル情報を保存します。
* nullptr を代入した場合は、VRMLファイル中に「Material」ノードを生成しません。
*
* \return ファイルの出力に成功した場合 true を、失敗した場合 false を返します。
*/
bool WriteVRMLFile(String^ fileName, IEnumerable<double>^ time,
IEnumerable<fk_Vector^>^ pos, fk_Material^ material);
//! VRML ファイル出力メソッド2-3
/*!
* VRML (VRML2.0) 形式で形状データを出力します。
* この引数形式の場合は、
* CoordinateInterpolator ノードを用いた
* アニメーションデータを出力することが可能です。
*
* なお、本メソッドは
* WriteVRMLFile(String^, IEnumerable<double>^,
* IEnumerable<fk_Vector^>^, fk_Material^, bool) において、
* 第4引数に null を、第5引数に false を入力している場合と同義となります。
*
* \param[in] fileName ファイル名
*
* \param[in] time
* CoordinateInterpolator における時間配列 (key) を入力します。
*
* \param[in] pos
* CoordinateInterpolator における位置ベクトル配列 (keyValue) を入力します。
*
* \return ファイルの出力に成功した場合 true を、失敗した場合 false を返します。
*/
bool WriteVRMLFile(String^ fileName, IEnumerable<double>^ time, IEnumerable<fk_Vector^>^ pos);
//! STL ファイル出力メソッド
/*!
* STL 形式で形状データを出力します。
*
* \param[in] fileName ファイル名
*
* \return ファイルの出力に成功した場合 true を、失敗した場合 false を返します。
*/
bool WriteSTLFile(String^ fileName);
//! DXF ファイル出力メソッド1
/*!
* DXF 形式で形状データを出力します。
*
* \param[in] fileName ファイル名
*
* \param[in] triFlg
* 面情報を3角形として出力したい場合は、true を代入します。
* false の場合、3角形面を2点が重複している4角形面として出力します。
*
* \return ファイルの出力に成功した場合 true を、失敗した場合 false を返します。
*/
bool WriteDXFFile(String^ fileName, bool triFlg);
//! DXF ファイル出力メソッド1
/*!
* DXF 形式で形状データを出力します。
*
* なお、本メソッドは WriteDXFFile(String^, bool) において、
* 第2引数に false を入力した場合と同義となります。
*
* \param[in] fileName ファイル名
*
* \return ファイルの出力に成功した場合 true を、失敗した場合 false を返します。
*/
bool WriteDXFFile(String^ fileName);
//! MQO ファイル出力メソッド
/*!
* MQO 形式で形状データを出力します。
*
* \param[in] fileName ファイル名
*
* \return ファイルの出力に成功した場合 true を、失敗した場合 false を返します。
*/
bool WriteMQOFile(String^ fileName);
///@}
//! \name 形状情報参照メソッド
///@{
//! 頂点位置ベクトル参照メソッド
/*!
* 形状データ中の、頂点の位置ベクトルを取得します。
*
* \param[in] vertexID
* 頂点ID。一番最初の頂点IDは 0 になります。
* 最後の ID は頂点数から 1 を引いたものとなります。
*
* \return 頂点の位置ベクトル
*
* \sa MoveVPosition()
*/
fk_Vector^ GetPosVec(int vertexID);
//! 頂点 ID 配列参照メソッド
/*!
* 面を構成する頂点 ID の配列を取得します。
*
* \param[in] faceID
* 面 ID。一番最初の面IDは 0 になります。
* 最後の ID は面数から 1 を引いたものとなります。
*
* \return 頂点 ID 配列
*/
cli::array<int>^ GetFaceData(int faceID);
//! 頂点 ID 参照メソッド
/*!
* 面を構成する頂点 ID を取得します。
*
* \param[in] faceID
* 面 ID。一番最初の面IDは 0 になります。
* 最後の ID は面数から 1 を引いたものとなります。
*
* \param[in] vertexNum
* 面の中での頂点番号。
* 3角形であれば 0 から 2、
* 4角形であれば 0 から 3 のいずれかを入力すると、
* 格納されている頂点 ID を取得できます。
*
* \return 頂点 ID
*/
int GetFaceData(int faceID, int vertexNum);
//! 面法線ベクトル取得メソッド1
/*!
* 面の法線ベクトルを取得します。
*
* \param[in] faceID 面ID
*
* \param[in] order
* 最初の面IDを補正するオーダー。通常は 0 を入力して下さい。
*
* \return 面の法線ベクトル
*
* \sa SetPNorm(), GetVNorm()
*/
fk_Vector^ GetPNorm(int faceID, int order);
//! 面法線ベクトル取得メソッド2
/*!
* 面の法線ベクトルを取得します。
*
* なお、本メソッドは GetPNorm(int, int) において、
* 第2引数に 0 を入力した場合と同義となります。
*
* \param[in] faceID 面ID
*
* \return 面の法線ベクトル
*
* \sa SetPNorm(), GetVNorm()
*/
fk_Vector^ GetPNorm(int faceID);
//! 頂点法線ベクトル取得メソッド1
/*!
* 頂点の法線ベクトルを取得します。
*
* \param[in] vertexID 頂点ID
*
* \param[in] order
* 最初の頂点IDを補正するオーダー。通常は 0 を入力して下さい。
*
* \return 頂点の法線ベクトル
*
* \sa SetVNorm(), GetPNorm()
*/
fk_Vector^ GetVNorm(int vertexID, int order);
//! 頂点法線ベクトル取得メソッド2
/*!
* 頂点の法線ベクトルを取得します。
*
* なお、本メソッドは GetVNorm(int, int) において、
* 第2引数に 0 を入力した場合と同義となります。
*
* \param[in] vertexID 頂点ID
*
* \return 頂点の法線ベクトル
*
* \sa SetVNorm(), GetPNorm()
*/
fk_Vector^ GetVNorm(int vertexID);
//! マテリアルID取得メソッド
/*!
* 面に対して個別に設定してあるマテリアル ID を取得します。
* マテリアルの個別設定については
* fk_Shape::SetMaterialMode() および
* fk_Shape::SetPalette() を参照して下さい。
*
* \param[in] faceID 面ID
*
* \return マテリアルID
*
* \sa SetElemMaterialID(), fk_Shape
*/
int GetElemMaterialID(int faceID);
///@}
//! \name 形状操作メソッド
///@{
//! 頂点移動メソッド1-1
/*!
* 指定された頂点を移動します。
* なお、 SetVNorm() によって法線ベクトルが設定されていた場合や、
* SetPNorm() によって周辺の面に放線ベクトルが設定されていた場合、
* 本メソッドによって破棄されます。
*
* \param[in] vertexID 頂点ID
*
* \param[in] pos 移動先の位置ベクトル
*
* \param[in] order
* 最初の頂点IDを補正するオーダー。通常は 0 を入力して下さい。
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \sa GetPosVec()
*/
bool MoveVPosition(int vertexID, fk_Vector^ pos, int order);
//! 頂点移動メソッド1-2
/*!
* 指定された頂点を移動します。
* なお、 SetVNorm() によって法線ベクトルが設定されていた場合や、
* SetPNorm() によって周辺の面に放線ベクトルが設定されていた場合、
* 本メソッドによって破棄されます。
*
* なお、本メソッドは MoveVPosition(int, fk_Vector^, int) において、
* 第3引数に 0 を入力した場合と同義になります。
*
* \param[in] vertexID 頂点ID
* \param[in] pos 移動先の位置ベクトル
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \sa GetPosVec()
*/
bool MoveVPosition(int vertexID, fk_Vector^ pos);
//! 頂点移動メソッド2-1
/*!
* 指定された頂点を移動します。
* なお、 SetVNorm() によって法線ベクトルが設定されていた場合や、
* SetPNorm() によって周辺の面に放線ベクトルが設定されていた場合、
* 本メソッドによって破棄されます。
*
* \param[in] vertexID 頂点ID
* \param[in] x 移動先位置ベクトルの x 成分
* \param[in] y 移動先位置ベクトルの y 成分
* \param[in] z 移動先位置ベクトルの z 成分
*
* \param[in] order
* 最初の頂点IDを補正するオーダー。通常は 0 を入力して下さい。
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \sa GetPosVec()
*/
bool MoveVPosition(int vertexID, double x, double y, double z, int order);
//! 頂点移動メソッド2-1
/*!
* 指定された頂点を移動します。
* なお、 SetVNorm() によって法線ベクトルが設定されていた場合や、
* SetPNorm() によって周辺の面に放線ベクトルが設定されていた場合、
* 本メソッドによって破棄されます。
*
* なお、本メソッドは MoveVPosition(int, double, double, double, int) において、
* 第5引数に 0 を入力した場合と同義になります。
*
* \param[in] vertexID 頂点ID
* \param[in] x 移動先位置ベクトルの x 成分
* \param[in] y 移動先位置ベクトルの y 成分
* \param[in] z 移動先位置ベクトルの z 成分
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \sa GetPosVec()
*/
bool MoveVPosition(int vertexID, double x, double y, double z);
//! 頂点移動メソッド3-1
/*!
* 指定された頂点を移動します。
* なお、 SetVNorm() によって法線ベクトルが設定されていた場合や、
* SetPNorm() によって周辺の面に放線ベクトルが設定されていた場合、
* 本メソッドによって破棄されます。
*
* \param[in] vertexID 頂点ID
*
* \param[in] array
* 移動先位置ベクトルの各成分が入った double 型配列。
*
* \param[in] order
* 最初の頂点IDを補正するオーダー。通常は 0 を入力して下さい。
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \sa GetPosVec()
*/
bool MoveVPosition(int vertexID, IEnumerable<double>^ array, int order);
//! 頂点移動メソッド3-2
/*!
* 指定された頂点を移動します。
* なお、 SetVNorm() によって法線ベクトルが設定されていた場合や、
* SetPNorm() によって周辺の面に放線ベクトルが設定されていた場合、
* 本メソッドによって破棄されます。
*
* なお、本メソッドは MoveVPosition(int, IEnumerable<double>^, int) において、
* 第3引数に 0 を入力した場合と同義になります。
*
* \param[in] vertexID 頂点ID
*
* \param[in] array
* 移動先位置ベクトルの各成分が入った double 型配列。
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \sa GetPosVec()
*/
bool MoveVPosition(int vertexID, IEnumerable<double>^ array);
//! 任意形状生成メソッド1
/*!
* 与えられたインデックスフェースセット情報から、形状を生成します。
*
* \param[in] faceNum 面数
*
* \param[in] polyNum
* 面の角数。現在、ここに入力できる数値は 3 か 4 のみです。
*
* \param[in] IFSet
* インデックスフェースセット配列。
* この配列は、各面を構成する頂点 ID を並べたものになります。
* たとえば、頂点 ID が [0, 1, 2] と [2, 1, 3] という構成を持つ
* 2面からなる形状を生成する場合、
* int 型の配列に対して [0, 1, 2, 2, 1, 3] という数値を入力しておきます。
* 4角形の場合も同様です。
* 結果的に、この配列の長さは面数と角数を掛けたもの以上である必要があります。
*
* \param[in] vertexNum 頂点数
*
* \param[in] posArray
* 頂点位置ベクトルの配列。配列の長さは頂点数以上である必要があります。
*
* \param[in] order
* 最初の頂点IDを補正するオーダー。通常は 0 を入力して下さい。
*
* \sa fk_Solid
*/
void MakeIFSet(int faceNum, int polyNum, IEnumerable<int>^ IFSet,
int vertexNum, IEnumerable<fk_Vector^>^ posArray, int order);
//! 任意形状生成メソッド2
/*!
* 与えられたインデックスフェースセット情報から、形状を生成します。
*
* なお、本メソッドは MakeIFSet(int, int, IEnumerable<int>^, int, IEnumerable<fk_Vector^>^, int) において、
* 第6引数に 0 を入力した場合と同義となります。
*
* \param[in] faceNum 面数
*
* \param[in] polyNum
* 面の角数。現在、ここに入力できる数値は 3 か 4 のみです。
*
* \param[in] IFSet
* インデックスフェースセット配列。
* この配列は、各面を構成する頂点 ID を並べたものになります。
* たとえば、頂点 ID が [0, 1, 2] と [2, 1, 3] という構成を持つ
* 2面からなる形状を生成する場合、
* int 型の配列に対して [0, 1, 2, 2, 1, 3] という数値を入力しておきます。
* 4角形の場合も同様です。
* 結果的に、この配列の長さは面数と角数を掛けたもの以上である必要があります。
*
* \param[in] vertexNum 頂点数
*
* \param[in] posArray
* 頂点位置ベクトルの配列。配列の長さは頂点数以上である必要があります。
*
* \sa fk_Solid
*/
void MakeIFSet(int faceNum, int polyNum, IEnumerable<int>^ IFSet,
int vertexNum, IEnumerable<fk_Vector^>^ posArray);
//! 面法線ベクトル設定メソッド1
/*!
* 面の法線ベクトルを設定します。
*
* 通常、面の法線ベクトルは自前で設定しなくても、
* 形状から自動的に算出されます。
* しかし、バンプマッピングなどの技法を用いる場合など、
* 自前で計算した法線ベクトルを与える場合は、このメソッドを用います。
*
* なお、 MoveVPosition() メソッドによって面上の点が移動された場合、
* 設定した法線ベクトルは破棄されます。
*
* \param[in] faceID 面ID
*
* \param[in] norm
* 法線ベクトル。あらかじめ正規化しておく必要があります。
* 正規化されていない放線ベクトルを入力した場合、
* 動作が異常となる場合があります。
*
* \param[in] order
* 最初の頂点IDを補正するオーダー。通常は省略して問題ありません。
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \sa GetPNorm(), SetVNorm()
*/
bool SetPNorm(int faceID, fk_Vector^ norm, int order);
//! 面法線ベクトル設定メソッド2
/*!
* 面の法線ベクトルを設定します。
*
* 通常、面の法線ベクトルは自前で設定しなくても、
* 形状から自動的に算出されます。
* しかし、バンプマッピングなどの技法を用いる場合など、
* 自前で計算した法線ベクトルを与える場合は、このメソッドを用います。
*
* なお、 MoveVPosition() メソッドによって面上の点が移動された場合、
* 設定した法線ベクトルは破棄されます。
*
* 本メソッドは SetPNorm(int, fk_Vector^, int) において、
* 第3引数に 0 を入力した場合と同義となります。
*
* \param[in] faceID 面ID
*
* \param[in] norm
* 法線ベクトル。あらかじめ正規化しておく必要があります。
* 正規化されていない放線ベクトルを入力した場合、
* 動作が異常となる場合があります。
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \sa GetPNorm(), SetVNorm()
*/
bool SetPNorm(int faceID, fk_Vector^ norm);
//! 頂点法線ベクトル設定メソッド1
/*!
* 頂点の法線ベクトルを設定します。
*
* 通常、頂点の法線ベクトルは自前で設定しなくても、
* 形状から自動的に算出されます。
* しかし、バンプマッピングなどの技法を用いる場合など、
* 自前で計算した法線ベクトルを与える場合は、このメソッドを用います。
*
* なお、 MoveVPosition() メソッドによって頂点が移動された場合、
* 設定した法線ベクトルは破棄されます。
*
* \param[in] vertexID 頂点ID
*
* \param[in] norm
* 法線ベクトル。あらかじめ正規化しておく必要があります。
* 正規化されていない放線ベクトルを入力した場合、
* 動作が異常となる場合があります。
*
* \param[in] order
* 最初の頂点IDを補正するオーダー。通常は 0 を入力して下さい。
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \sa GetVNorm(), SetPNorm()
*/
bool SetVNorm(int vertexID, fk_Vector^ norm, int order);
//! 頂点法線ベクトル設定メソッド1
/*!
* 頂点の法線ベクトルを設定します。
*
* 通常、頂点の法線ベクトルは自前で設定しなくても、
* 形状から自動的に算出されます。
* しかし、バンプマッピングなどの技法を用いる場合など、
* 自前で計算した法線ベクトルを与える場合は、このメソッドを用います。
*
* なお、 MoveVPosition() メソッドによって頂点が移動された場合、
* 設定した法線ベクトルは破棄されます。
*
* 本メソッドは SetVNorm(int, fk_Vector^, int) において、
* 第3引数に 0 を入力した場合と同義となります。
*
* \param[in] vertexID 頂点ID
*
* \param[in] norm
* 法線ベクトル。あらかじめ正規化しておく必要があります。
* 正規化されていない放線ベクトルを入力した場合、
* 動作が異常となる場合があります。
*
* \return 成功すれば true を、失敗すれば false を返します。
*
* \sa GetVNorm(), SetPNorm()
*/
bool SetVNorm(int vertexID, fk_Vector^ norm);
//! マテリアルID設定メソッド
/*!
* 面に対してマテリアルIDを設定します。
* マテリアルの個別設定については
* fk_Shape::MaterialMode および
* fk_Shape::SetPalette() を参照して下さい。
*
* \param[in] faceID 面ID
*
* \param[in] materialID マテリアルID
*
* \return 設定に成功すれば true を、失敗すれば false を返します。
*
* \sa GetElemMaterialID(), fk_Shape
*/
bool SetElemMaterialID(int faceID, int materialID);
//! 法線ベクトル強制計算メソッド
/*!
* fk_IndexFaceSet では、
* 面や頂点の法線ベクトルは形状生成した時点ではまだ算出しません。
* 描画時など、実際に法線ベクトルが必要となった場合に随時計算が行われます。
* この仕様は、必ずしも法線ベクトルを必要としない状況において
* 計算量を削減する効果がありますが、
* 一方でアプリケーションの実行において不都合を生じる場合があります。
* 例えば、対象形状が初めてシーンに登録された時点で
* 画面が一瞬止まってしまうといった状況が想定されます。
*
* 本メソッドは、形状中のすべての面と頂点に対して法線ベクトルを強制的に算出します。
* なお、 SetPNorm() や SetVNorm() で設定した法線ベクトルは全て破棄されます。
*
* \sa GetPNorm(), GetVNorm(), SetPNorm(), SetVNorm()
*/
void Flush(void);
///@}
//! \name 直方体形状制御メソッド
///@{
//! 直方体生成メソッド
/*!
* 直方体を生成します。
*
* 直方体は、原点の物体の中心が来るように配置されます。
* 従って、(x, y, z) という大きさで直方体を生成した場合、
* 各頂点の位置ベクトルは以下のようになります。
* - (x/2, y/2, z/2)
* - (-x/2, y/2, z/2)
* - (-x/2, -y/2, z/2)
* - (x/2, -y/2, z/2)
* - (x/2, y/2, -z/2)
* - (-x/2, y/2, -z/2)
* - (-x/2, -y/2, -z/2)
* - (x/2, -y/2, -z/2)
*
* このメソッドを呼ぶ前に生成されていた形状や各種属性は破棄されます。
*
* \param[in] x x方向の辺長
* \param[in] y y方向の辺長
* \param[in] z z方向の辺長
*
* \sa fk_Block
*/
void MakeBlock(double x, double y, double z);
//! 直方体辺長変更メソッド
/*!
* MakeBlock() によって直方体を生成した後に、
* 直方体の辺長を一括して設定しなおします。
* このメソッドは、 MakeBlock() によって直方体を生成した場合のみ有効であり、
* それ以外の形状状態に対してこのメソッドを呼んだときの挙動は保証されません。
*
* \param[in] x x方向の辺長
* \param[in] y y方向の辺長
* \param[in] z z方向の辺長
*
* \sa MakeBlock(), fk_Block
*/
void SetBlockSize(double x, double y, double z);
//! 直方体個別辺長設定メソッド
/*!
* MakeBlock() によって直方体を生成した後に、
* 直方体の辺長を個別に設定します。
* このメソッドは、 MakeBlock() によって直方体を生成した場合のみ有効であり、
* それ以外の形状状態に対してこのメソッドを呼んだときの挙動は保証されません。
*
* \param[in] length 辺長
* \param[in] axis 軸方向。以下のいずれかを指定します。
* - fk_Axis.X x方向
* - fk_Axis.Y y方向
* - fk_Axis.Z z方向
*
* \sa MakeBlock(), fk_Block
*/
void SetBlockSize(double length, fk_Axis axis);
//! 直方体全体拡大縮小メソッド
/*!
* MakeBlock() によって直方体を生成した後に、
* 直方体全体を指定された倍率で拡大・縮小します。
* このメソッドは、 MakeBlock() によって直方体を生成した場合のみ有効であり、
* それ以外の形状状態に対してこのメソッドを呼んだときの挙動は保証されません。
*
* \param[in] scale 倍率
*
* \sa MakeBlock(), fk_Block
*/
void SetBlockScale(double scale);
//! 直方体軸方向拡大縮小メソッド
/*!
* MakeBlock() によって直方体を生成した後に、
* 指定された軸方向についてのみ拡大・縮小します。
* このメソッドは、 MakeBlock() によって直方体を生成した場合のみ有効であり、
* それ以外の形状状態に対してこのメソッドを呼んだときの挙動は保証されません。
*
* \param[in] scale 倍率
* \param[in] axis 軸方向。以下のいずれかを指定します。
* - fk_Axis.X x方向
* - fk_Axis.Y y方向
* - fk_Axis.Z z方向
*
* \sa MakeBlock(), fk_Block
*/
void SetBlockScale(double scale, fk_Axis axis);
//! 直方体軸方向個別拡大縮小メソッド
/*!
* MakeBlock() によって直方体を生成した後に、
* 各軸方向に対し個別の倍率で拡大・縮小します。
* このメソッドは、 MakeBlock() によって直方体を生成した場合のみ有効であり、
* それ以外の形状状態に対してこのメソッドを呼んだときの挙動は保証されません。
*
* \param[in] x x方向の倍率
* \param[in] y y方向の倍率
* \param[in] z z方向の倍率
*
* \sa MakeBlock(), fk_Block
*/
void SetBlockScale(double x, double y, double z);
///@}
//! \name 円形状制御メソッド
///@{
//! 円形状生成メソッド
/*!
* 円形状を生成します。
*
* ここでの「円」は実際には正多角形を円に近似して扱っています。
* 多角形の角数は (分割数) * 4 となっています。
* この多角形は、実質的には設定された半径の円に内接するものです。
* 円としての見栄えを良くするには分割数を大きめに設定すべきですが、
* 分割数の大きい円を大量に利用すると描画処理が遅くなるという問題が生じます。
*
* 初期状態では、中心を原点とし、
* 面の法線ベクトルが (0, 0, 1) となるように配置されます。
*
* このメソッドを呼ぶ前に生成されていた形状や各種属性は破棄されます。
*
* \param[in] div 分割数。実際には円弧全体をこの数値の 4 倍で分割します。
* \param[in] rad 半径
*
* \sa fk_Circle
*/
void MakeCircle(int div, double rad);
//! 円形状半径設定メソッド
/*!
* MakeCircle() によって円形状を生成した後に、
* 半径を設定しなおします。
* このメソッドは、 MakeCircle() によって円形状を生成した場合のみ有効であり、
* それ以外の形状状態に対してこのメソッドを呼んだときの挙動は保証されません。
*
* \param[in] rad 半径
*
* \sa MakeCircle(), fk_Circle
*/
void SetCircleRadius(double rad);
//! 円形状分割数設定メソッド
/*!
* MakeCircle() によって円形状を生成した後に、
* 分割数を設定しなおします。
* このメソッドは、 MakeCircle() によって円形状を生成した場合のみ有効であり、
* それ以外の形状状態に対してこのメソッドを呼んだときの挙動は保証されません。
*
* \param[in] div 分割数
*
* \sa MakeCircle(), fk_Circle
*/
void SetCircleDivide(int div);
//! 円形状拡大縮小メソッド
/*!
* MakeCircle() によって円形状を生成した後に、
* 形状全体を与えられた倍率で拡大・縮小します。
* このメソッドは、 MakeCircle() によって円形状を生成した場合のみ有効であり、
* それ以外の形状状態に対してこのメソッドを呼んだときの挙動は保証されません。
*
* \param[in] scale 倍率
*
* \sa MakeCircle(), fk_Circle
*/
void SetCircleScale(double scale);
///@}
//! \name 球形状制御メソッド
///@{
//! 球形状生成メソッド
/*!
* 球形状を生成します。
*
* 実際には、球を近似する3角形面集合として表現されています。
* 3角形面の数は分割数を \f$ d \f$ とした場合 \f$ 8d(d-1) \f$ 枚となります。
* 分割数が高いほど球としての描画精度は高くなりますが、
* 面数も多くなるため描画速度が低下することになります。
* 特に多くのオブジェクトを同時に配置する場合は注意が必要です。
*
* 初期状態では、中心を原点とするように配置されます。
*
* このメソッドを呼ぶ前に生成されていた形状や各種属性は破棄されます。
*
* \param[in] div 分割数
* \param[in] rad 半径
*
* \sa fk_Sphere
*/
void MakeSphere(int div, double rad);
//! 球形状半径設定メソッド
/*!
* MakeSphere() によって球形状を生成した後に、
* 半径を設定しなおします。
* このメソッドは、 MakeSphere() によって球形状を生成した場合のみ有効であり、
* それ以外の形状状態に対してこのメソッドを呼んだときの挙動は保証されません。
*
* \param[in] rad 半径
*
* \sa MakeSphere(), fk_Sphere
*/
void SetSphereRadius(double rad);
//! 球形状分割数設定メソッド
/*!
* MakeSphere() によって球形状を生成した後に、
* 分割数を設定しなおします。
* このメソッドは、 MakeSphere() によって球形状を生成した場合のみ有効であり、
* それ以外の形状状態に対してこのメソッドを呼んだときの挙動は保証されません。
*
* \param[in] div 分割数
*
* \sa MakeSphere(), fk_Sphere
*/
void SetSphereDivide(int div);
//! 球形状拡大縮小メソッド
/*!
* MakeSphere() によって球形状を生成した後に、
* 形状全体を与えられた倍率で拡大・縮小します。
* このメソッドは、 MakeSphere() によって球形状を生成した場合のみ有効であり、
* それ以外の形状状態に対してこのメソッドを呼んだときの挙動は保証されません。
*
* \param[in] scale 倍率
*
* \sa MakeSphere(), fk_Sphere
*/
void SetSphereScale(double scale);
///@}
//! \name 正多角柱(円柱)形状制御メソッド
///@{
//! 正多角柱(円柱)形状生成メソッド
/*!
* 正多角柱(円柱)を生成します。
*
* 円柱は、分割数の多い正多角柱として生成します。
* 通常、分割数が 20 を超える程度でほとんど円柱と見分けがつかなくなります。
* 配置は、底面の中心が原点となり、
* 多角柱の上面が -z 方向、底面が +z 方向となります。
*
* 設定できる要素は角数、上面半径、底面半径、高さの4要素です。
* 上面と底面の半径とは、それぞれの面を構成する正多角形の外接円半径を指します。
*
* このメソッドを呼ぶ前に生成されていた形状や各種属性は破棄されます。
*
* \param[in] div 角数
* \param[in] top 上面半径
* \param[in] bottom 底面半径
* \param[in] height 高さ
*
* \sa fk_Prism
*/
void MakePrism(int div, double top, double bottom, double height);
//! 正多角柱(円柱)角数設定メソッド
/*!
* MakePrism() によって正多角柱(円柱)を生成した後に、
* 角数を設定しなおします。
* このメソッドは、 MakePrism() によって球形状を生成した場合のみ有効であり、
* それ以外の形状状態に対してこのメソッドを呼んだときの挙動は保証されません。
*
* \param[in] div 角数
*
* \sa MakePrism(), fk_Prism
*/
void SetPrismDivide(int div);
//! 正多角柱(円柱)上面半径設定メソッド
/*!
* MakePrism() によって正多角柱(円柱)を生成した後に、
* 上面の外接円半径を設定しなおします。
* このメソッドは、 MakePrism() によって球形状を生成した場合のみ有効であり、
* それ以外の形状状態に対してこのメソッドを呼んだときの挙動は保証されません。
*
* \param[in] top 上面半径
*
* \sa MakePrism(), fk_Prism
*/
void SetPrismTopRadius(double top);
//! 正多角柱(円柱)角数設定メソッド
/*!
* MakePrism() によって正多角柱(円柱)を生成した後に、
* 底面の外接円半径を設定しなおします。
* このメソッドは、 MakePrism() によって球形状を生成した場合のみ有効であり、
* それ以外の形状状態に対してこのメソッドを呼んだときの挙動は保証されません。
*
* \param[in] bottom 底面半径
*
* \sa MakePrism(), fk_Prism
*/
void SetPrismBottomRadius(double bottom);
//! 正多角柱(円柱)高さ設定メソッド
/*!
* MakePrism() によって正多角柱(円柱)を生成した後に、
* 高さを設定しなおします。
* このメソッドは、 MakePrism() によって球形状を生成した場合のみ有効であり、
* それ以外の形状状態に対してこのメソッドを呼んだときの挙動は保証されません。
*
* \param[in] height 高さ
*
* \sa MakePrism(), fk_Prism
*/
void SetPrismHeight(double height);
///@}
//! \name 正多角錐(円錐)形状制御メソッド
///@{
//! 正多角錐(円錐)形状生成メソッド
/*!
* 正多角錐(円錐)を生成します。
*
* 円錐は、分割数の多い正多角錐として生成します。
* 通常、分割数が 20 を超える程度でほとんど円錐と見分けがつかなくなります。
* 配置は、底面の中心が原点となり、
* 頂点 -z 方向、底面が +z 方向となります。
*
* 設定できる要素は角数、底面半径、高さの3要素です。
* 底面半径とは、面を構成する正多角形の外接円半径を指します。
*
* このメソッドを呼ぶ前に生成されていた形状や各種属性は破棄されます。
*
* \param[in] div 角数
* \param[in] rad 底面半径
* \param[in] height 高さ
*
* \sa fk_Cone
*/
void MakeCone(int div, double rad, double height);
//! 正多角錐(円錐)角数設定メソッド
/*!
* MakeCone() によって正多角錐(円錐)を生成した後に、
* 角数を設定しなおします。
* このメソッドは、 MakeCone() によって球形状を生成した場合のみ有効であり、
* それ以外の形状状態に対してこのメソッドを呼んだときの挙動は保証されません。
*
* \param[in] div 角数
*
* \sa MakeCone(), fk_Cone
*/
void SetConeDivide(int div);
//! 正多角錐(円錐)底面半径設定メソッド
/*!
* MakeCone() によって正多角錐(円錐)を生成した後に、
* 底面外接円半径を設定しなおします。
* このメソッドは、 MakeCone() によって球形状を生成した場合のみ有効であり、
* それ以外の形状状態に対してこのメソッドを呼んだときの挙動は保証されません。
*
* \param[in] rad 底面半径
*
* \sa MakeCone(), fk_Cone
*/
void SetConeRadius(double rad);
//! 正多角錐(円錐)高さ設定メソッド
/*!
* MakeCone() によって正多角錐(円錐)を生成した後に、
* 高さを設定しなおします。
* このメソッドは、 MakeCone() によって球形状を生成した場合のみ有効であり、
* それ以外の形状状態に対してこのメソッドを呼んだときの挙動は保証されません。
*
* \param[in] height 高さ
*
* \sa MakeCone(), fk_Cone
*/
void SetConeHeight(double height);
///@}
//! \name カプセル型形状制御メソッド
///@{
//! カプセル型形状生成メソッド
/*!
* カプセル型を生成します。
* カプセル型は半径の等しい円柱側面と半球面によって構成されています。
* 数学的には、カプセル型の内部は1本の線分より一定距離以下の部分の集合であり、
* その一定距離は前述の半径と等しくなります。この線分を「中心軸」と呼びます。
* 初期状態は中心軸の中点が原点に配置され、z軸方向と中心軸が平行となります。
* 設定できる要素は中心軸長、半径、分割数です。
* 実際のカプセル型の全長は「中心軸長 + (半径)*2」となります。
*
* このメソッドを呼ぶ前に生成されていた形状や各種属性は破棄されます。
*
* \param[in] div 分割数
* \param[in] len 中心軸長
* \param[in] rad 半径
*
* \sa fk_Capsule
*/
void MakeCapsule(int div, double len, double rad);
//! カプセル型形状寸法設定メソッド
/*!
* MakeCapsule() によってカプセル型形状を生成した後に、
* 中心軸長と半径を再度設定します。
* このメソッドは、 MakeCapsule() によってカプセル型形状を生成した場合のみ有効であり、
* それ以外の形状状態に対してこのメソッドを呼んだときの挙動は保証されません。
*
* \param[in] len 中心軸長
* \param[in] rad 半径
*
* \sa MakeCapsule(), fk_Capsule
*/
void SetCapsuleSize(double len, double rad);
///@}
//! \name 形状コピー操作メソッド
///@{
//! fk_Solid 出力メソッド
/*!
* fk_IndexFaceSet 型にある形状情報を、
* fk_Solid 型のインスタンスにコピーします。
* fk_Solid 側に格納されている形状情報や属性情報は破棄されます。
* なお、マテリアル情報や法線ベクトル情報はコピーされません。
*
* \param[in] solid fk_Solid 型インスタンスのアドレス
*
* \sa fk_Solid
*/
void PutSolid(fk_Solid^ solid);
//! 形状コピーメソッド
/*!
* 引数として与えられたインスタンス中の形状をコピーします。
* 各種属性およびマテリアル情報は写しません。
*
* \param[in] ifs 複写元インスタンス
*/
void CloneShape(fk_IndexFaceSet^ ifs);
///@}
};
}
/****************************************************************************
*
* Copyright (c) 1999-2020, Fine Kernel Project, All rights reserved.
*
* Redistribution and use in source and binary forms,
* with or without modification, are permitted provided that the
* following conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* - Neither the name of the copyright holders nor the names
* of its contributors may be used to endorse or promote
* products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
*
* Copyright (c) 1999-2020, Fine Kernel Project, All rights reserved.
*
* 本ソフトウェアおよびソースコードのライセンスは、基本的に
* 「修正 BSD ライセンス」に従います。以下にその詳細を記します。
*
* ソースコード形式かバイナリ形式か、変更するかしないかを問わず、
* 以下の条件を満たす場合に限り、再頒布および使用が許可されます。
*
* - ソースコードを再頒布する場合、上記の著作権表示、本条件一覧、
* および下記免責条項を含めること。
*
* - バイナリ形式で再頒布する場合、頒布物に付属のドキュメント等の
* 資料に、上記の著作権表示、本条件一覧、および下記免責条項を
* 含めること。
*
* - 書面による特別の許可なしに、本ソフトウェアから派生した製品の
* 宣伝または販売促進に、本ソフトウェアの著作権者の名前または
* コントリビューターの名前を使用してはならない。
*
* 本ソフトウェアは、著作権者およびコントリビューターによって「現
* 状のまま」提供されており、明示黙示を問わず、商業的な使用可能性、
* および特定の目的に対する適合性に関す暗黙の保証も含め、またそれ
* に限定されない、いかなる保証もないものとします。著作権者もコン
* トリビューターも、事由のいかんを問わず、損害発生の原因いかんを
* 問わず、かつ責任の根拠が契約であるか厳格責任であるか(過失その
* 他の)不法行為であるかを問わず、仮にそのような損害が発生する可
* 能性を知らされていたとしても、本ソフトウェアの使用によって発生
* した(代替品または代用サービスの調達、使用の喪失、データの喪失、
* 利益の喪失、業務の中断も含め、またそれに限定されない)直接損害、
* 間接損害、偶発的な損害、特別損害、懲罰的損害、または結果損害に
* ついて、一切責任を負わないものとします。
*
****************************************************************************/
| 25.820726 | 97 | 0.635101 | [
"solid"
] |
f384c3bb91f47c1b0b03154ef8e1a0755adf3dd3 | 565 | h | C | glx/str.h | MAPSWorks/bigView--bigView-glx-Examples-latlon.C | 099071d483f7b3d056f41c15424b2e3e93ffb22e | [
"NASA-1.3"
] | null | null | null | glx/str.h | MAPSWorks/bigView--bigView-glx-Examples-latlon.C | 099071d483f7b3d056f41c15424b2e3e93ffb22e | [
"NASA-1.3"
] | null | null | null | glx/str.h | MAPSWorks/bigView--bigView-glx-Examples-latlon.C | 099071d483f7b3d056f41c15424b2e3e93ffb22e | [
"NASA-1.3"
] | null | null | null | #ifndef _STR_H_
#define _STR_H_
#include <iostream>
#include <string>
#include <vector>
namespace str {
void tokenize(std::string, std::vector<std::string>&, std::string=" \t\n");
std::string trim(std::string);
void trim(std::vector<std::string>&);
std::string lower(std::string);
void lower(std::vector<std::string>&);
std::string replace(std::string, char, char);
std::string replace(std::string, std::string, char);
std::string strip(std::string, char);
std::string strip(std::string, std::string);
std::string itoa(int);
};
#endif
| 20.925926 | 79 | 0.669027 | [
"vector"
] |
f3885d468e84a314df0ab5ba19395fa32f228f62 | 1,088 | h | C | dev/Code/Sandbox/Editor/Include/ISubObjectSelectionReferenceFrameCalculator.h | jeikabu/lumberyard | 07228c605ce16cbf5aaa209a94a3cb9d6c1a4115 | [
"AML"
] | 1,738 | 2017-09-21T10:59:12.000Z | 2022-03-31T21:05:46.000Z | dev/Code/Sandbox/Editor/Include/ISubObjectSelectionReferenceFrameCalculator.h | jeikabu/lumberyard | 07228c605ce16cbf5aaa209a94a3cb9d6c1a4115 | [
"AML"
] | 427 | 2017-09-29T22:54:36.000Z | 2022-02-15T19:26:50.000Z | dev/Code/Sandbox/Editor/Include/ISubObjectSelectionReferenceFrameCalculator.h | jeikabu/lumberyard | 07228c605ce16cbf5aaa209a94a3cb9d6c1a4115 | [
"AML"
] | 671 | 2017-09-21T08:04:01.000Z | 2022-03-29T14:30:07.000Z | /*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
// Description : Calculate the reference frame for sub-object selections.
#ifndef CRYINCLUDE_EDITOR_INCLUDE_ISUBOBJECTSELECTIONREFERENCEFRAMECALCULATOR_H
#define CRYINCLUDE_EDITOR_INCLUDE_ISUBOBJECTSELECTIONREFERENCEFRAMECALCULATOR_H
#pragma once
class ISubObjectSelectionReferenceFrameCalculator
{
public:
virtual void SetExplicitFrame(bool bAnySelected, const Matrix34& refFrame) = 0;
};
#endif // CRYINCLUDE_EDITOR_INCLUDE_ISUBOBJECTSELECTIONREFERENCEFRAMECALCULATOR_H
| 37.517241 | 85 | 0.806985 | [
"object"
] |
f389f60f235a22101379372f7dff52bf5ccc28cd | 331 | h | C | src/mesh.h | gheshu/meshing | ca3bd657a02a38c0b6c4e2a5aca8835d2d031e7f | [
"Apache-2.0"
] | 48 | 2016-03-01T07:49:38.000Z | 2022-03-11T16:24:04.000Z | src/mesh.h | gheshu/meshing | ca3bd657a02a38c0b6c4e2a5aca8835d2d031e7f | [
"Apache-2.0"
] | null | null | null | src/mesh.h | gheshu/meshing | ca3bd657a02a38c0b6c4e2a5aca8835d2d031e7f | [
"Apache-2.0"
] | 4 | 2017-03-21T08:35:23.000Z | 2020-08-24T07:34:32.000Z | #ifndef MESH_H
#define MESH_H
#include "glm/glm.hpp"
#include "vertexbuffer.h"
class Mesh {
unsigned vao, vbo, num_vertices;
bool is_init;
public:
Mesh() : num_vertices(0), is_init(false){};
~Mesh(){ destroy(); }
void draw();
void update(VertexBuffer& vb);
void init();
void destroy();
};
#endif
| 16.55 | 47 | 0.628399 | [
"mesh"
] |
f3a211dfb8f7374586d3a2acaba2d935938636e0 | 844 | h | C | Fractal/FractalPhysics/include/collision/AABBCollision.h | talislincoln/fractals | a9ed52e99b9737ce0a6bba715f61e4d122e37dd5 | [
"MIT"
] | 2 | 2016-09-22T16:11:17.000Z | 2016-09-22T16:11:55.000Z | Fractal/FractalPhysics/include/collision/AABBCollision.h | talislincoln/FractalGameEngine | a9ed52e99b9737ce0a6bba715f61e4d122e37dd5 | [
"MIT"
] | null | null | null | Fractal/FractalPhysics/include/collision/AABBCollision.h | talislincoln/FractalGameEngine | a9ed52e99b9737ce0a6bba715f61e4d122e37dd5 | [
"MIT"
] | null | null | null | #ifndef _AABB_COLISION
#define _AABB_COLISION
#include "AABB.h"
#include <FractalMath\Vector.h>
namespace fractal {
namespace fphysics {
class AABBCollision
{
public:
AABBCollision();
~AABBCollision();
static inline bool isCollide(const AABB& a,const AABB& b) {
return(a.max.x > b.min.x && a.min.x < b.max.x &&
a.max.y > b.min.y && a.min.y < b.max.y &&
a.max.z > b.min.z && a.min.z < b.max.z);
}
static inline bool isCollide(AABB& a, fmath::Point3 p) {
return(p.x > a.min.x && p.x < a.max.x &&
p.y > a.min.y && p.y < a.max.y &&
p.z > a.min.z && p.z < a.max.z);
}
static inline bool isCollide( fmath::Point3 p, AABB& a) {
return(p.x > a.min.x && p.x < a.max.x &&
p.y > a.min.y && p.y < a.max.y &&
p.z > a.min.z && p.z < a.max.z);
}
};
}
}
#endif // !_AABB_COLISION
| 24.114286 | 62 | 0.556872 | [
"vector"
] |
f3b0d8dba362613b2dbe85b5e3ad60e57c3a79d9 | 712 | h | C | project2D/SceneObject.h | Sloth113/MathforGames | 2e056c827a549d8c7f9d870627b982a60b97cf75 | [
"MIT"
] | null | null | null | project2D/SceneObject.h | Sloth113/MathforGames | 2e056c827a549d8c7f9d870627b982a60b97cf75 | [
"MIT"
] | null | null | null | project2D/SceneObject.h | Sloth113/MathforGames | 2e056c827a549d8c7f9d870627b982a60b97cf75 | [
"MIT"
] | null | null | null | #pragma once
#include <vector>
#include "Matrix3.h"
#include "Renderer2D.h"
#include "Input.h"
class SceneObject {
//2D game object, static sprite
public:
SceneObject();
virtual ~SceneObject();
void addChild(SceneObject * child);
void removeChild(int i);
void removeChild(SceneObject * child);
void removeChildren();
virtual void update(float deltaTime);
virtual void draw(aie::Renderer2D* renderer);
void updateGlobalTransform();
void setLocal(Matrix3);
Matrix3 getLocal();
///////MAKE MOVE THINGS N STUFF
//CHANGE UP THE LOCAL THEN CALL UPDATE GLOBAL
protected:
Matrix3 m_globalTransform;
Matrix3 m_localTransform;
SceneObject * m_parent;
std::vector<SceneObject*> m_children;
}; | 18.25641 | 46 | 0.740169 | [
"object",
"vector"
] |
f3b3313bbe5783720693d1288e71a9c86282b056 | 7,787 | c | C | libgda/src/rbgdadatasource.c | pkorenev/ruby-gnome2 | 08011d8535529a3866f877817f29361b1b0703d7 | [
"Ruby"
] | 2 | 2016-05-08T20:57:12.000Z | 2017-07-28T21:00:42.000Z | libgda/src/rbgdadatasource.c | pkorenev/ruby-gnome2 | 08011d8535529a3866f877817f29361b1b0703d7 | [
"Ruby"
] | null | null | null | libgda/src/rbgdadatasource.c | pkorenev/ruby-gnome2 | 08011d8535529a3866f877817f29361b1b0703d7 | [
"Ruby"
] | 2 | 2016-07-23T09:53:08.000Z | 2021-07-13T07:21:05.000Z |
/*
* Copyright (C) 2003, 2004 Laurent Sansonetti <lrz@gnome.org>
*
* This file is part of Ruby/Libgda.
*
* Ruby/Libgda is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Ruby/Libgda 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Ruby/Libgda; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "rbgda.h"
/*
* Class: Gda::DataSource
* Data sources.
*/
VALUE cGdaDataSource;
/*
* Class method: datasources
*
* Returns: a list of all data sources currently configured in the system, as
* an Array of Gda::DataSource objects.
*/
static VALUE rb_gda_get_datasources(self)
VALUE self;
{
GList *list, *node;
VALUE arr;
list = gda_config_get_data_source_list();
arr = rb_ary_new();
for (node = g_list_first(list);
node != NULL;
node = g_list_next(node))
{
VALUE v = RGDA_DATASOURCE_NEW(node->data);
rb_ary_push(arr, v);
}
gda_config_free_data_source_list(list);
return arr;
}
/*
* Class method: each { |datasource| ... }
*
* Calls the block for each data source which is currently configured in the
* system, passing a reference to a Gda::DataSource object as parameter.
*
* Returns: always nil.
*/
static VALUE rb_gda_datasource_each(self)
VALUE self;
{
rb_ary_each(rb_gda_get_datasources(self));
return Qnil;
}
/*
* Class method: find(name)
* name: name of the data source to search to.
*
* Gets a Gda::DataSource object givin its name.
*
* Returns: a Gda::DataSource reference if found, nil if not found.
*/
static VALUE rb_gda_datasource_find(self, name)
VALUE self, name;
{
GdaDataSourceInfo *info = gda_config_find_data_source(RVAL2CSTR(name));
return info != NULL
? RGDA_DATASOURCE_NEW(info)
: Qnil;
}
/*
* Class method: model
*
* Fills and returns a new Gda::DataModel object using information from all
* data sources which are currently configured in the system.
*
* Rows are separated in 6 columns: 'Name', 'Provider', 'Connection string',
* 'Description', 'Username' and 'Password'.
*
* Returns: a newly created Gda::DataModel object.
*/
static VALUE rb_gda_datasource_model(self)
VALUE self;
{
GdaDataModel *model = gda_config_get_data_source_model();
return model != NULL
? RGDA_DATAMODEL_NEW(model)
: Qnil;
}
/*
* Class method: new(name, provider, cnc_string, description, username, password)
* name: name of the data source to create.
* provider: name of the provider to use.
* cnc_string: connection string that will be used to connect to the data source.
* description: a short description of the data source.
* username: user name to use for the connection (may be nil).
* password: password to use for the connection (may be nil).
*
* Returns: a newly created Gda::DataSource object.
*/
static VALUE rb_gda_datasource_new(self, name, provider, cnc_string,
description, username, password)
VALUE self, name, provider, cnc_string,
description, username, password;
{
GdaDataSourceInfo *new = g_new(GdaDataSourceInfo, sizeof(GdaDataSourceInfo));
new->name = RVAL2CSTR(name);
new->provider = RVAL2CSTR(provider);
new->cnc_string = RVAL2CSTR(cnc_string);
new->description = RVAL2CSTR(description);
new->username = NIL_P(username) ? NULL : RVAL2CSTR(username);
new->password = NIL_P(password) ? NULL : RVAL2CSTR(password);
G_INITIALIZE(self, new);
return Qnil;
}
/*
* Method: save
*
* Saves the data source in the libgda configuration.
*
* Returns: self.
*/
static VALUE rb_gda_datasource_save(self)
VALUE self;
{
gda_config_save_data_source_info(RGDA_DATASOURCE(self));
return self;
}
/*
* Method: remove
*
* Removes the data source from the libgda configuration.
*
* Returns: self.
*/
static VALUE rb_gda_datasource_remove(self)
VALUE self;
{
gda_config_remove_data_source(RGDA_DATASOURCE(self)->name);
return self;
}
/*
* Method: name
*
* Returns: the name of the data source.
*/
static VALUE rb_gda_datasource_get_name(self)
VALUE self;
{
GdaDataSourceInfo *info = RGDA_DATASOURCE(self);
return CSTR2RVAL(info->name);
}
/*
* Method: provider
*
* Returns: the name of the provider this data source is using.
*/
static VALUE rb_gda_datasource_get_provider(self)
VALUE self;
{
GdaDataSourceInfo *info = RGDA_DATASOURCE(self);
return CSTR2RVAL(info->provider);
}
/*
* Method: cnc_string
*
* Returns: the connection string this data source will be using to connect
* to the provider.
*/
static VALUE rb_gda_datasource_get_cnc_string(self)
VALUE self;
{
GdaDataSourceInfo *info = RGDA_DATASOURCE(self);
return CSTR2RVAL(info->cnc_string);
}
/*
* Method: description
*
* Returns: a short description of the data source.
*/
static VALUE rb_gda_datasource_get_description(self)
VALUE self;
{
GdaDataSourceInfo *info = RGDA_DATASOURCE(self);
return CSTR2RVAL(info->description);
}
/*
* Method: username
*
* Returns: the user name that will be used for the connection,
* or nil of no user name has been specified.
*/
static VALUE rb_gda_datasource_get_username(self)
VALUE self;
{
GdaDataSourceInfo *info = RGDA_DATASOURCE(self);
return CSTR2RVAL(info->username);
}
/*
* Method: password
*
* Returns: the password that will be used for the connection,
* or nil of no password has been specified.
*/
static VALUE rb_gda_datasource_get_password(self)
VALUE self;
{
GdaDataSourceInfo *info = RGDA_DATASOURCE(self);
return CSTR2RVAL(info->password);
}
/*
* Method: ==(an_other_datasource)
* an_other_datasource: a Gda::DataSource object.
*
* Checks if two Gda::DataSource objects are representing the same
* data source.
*
* Returns: true on success, false on failure.
*/
static VALUE rb_gda_datasource_is_equal(self, other_data)
VALUE self, other_data;
{
return NIL_P(other_data)
? Qfalse
: rb_equal(rb_gda_datasource_get_name(self),
rb_gda_datasource_get_name(other_data));
}
void Init_gda_datasource(void) {
VALUE c = G_DEF_CLASS(GDA_TYPE_DATA_SOURCE_INFO, "DataSource", mGda);
rb_define_singleton_method(c, "datasources", rb_gda_get_datasources, 0);
rb_define_singleton_method(c, "each", rb_gda_datasource_each, 0);
rb_define_singleton_method(c, "find", rb_gda_datasource_find, 1);
rb_define_singleton_method(c, "model", rb_gda_datasource_model, 0);
rb_define_method(c, "initialize", rb_gda_datasource_new, 6);
rb_define_method(c, "save", rb_gda_datasource_save, 0);
rb_define_method(c, "remove", rb_gda_datasource_remove, 0);
rb_define_method(c, "name", rb_gda_datasource_get_name, 0);
rb_define_method(c, "provider", rb_gda_datasource_get_provider, 0);
rb_define_method(c, "cnc_string", rb_gda_datasource_get_cnc_string, 0);
rb_define_method(c, "description", rb_gda_datasource_get_description, 0);
rb_define_method(c, "username", rb_gda_datasource_get_username, 0);
rb_define_method(c, "password", rb_gda_datasource_get_password, 0);
rb_define_method(c, "==", rb_gda_datasource_is_equal, 1);
cGdaDataSource = c;
}
| 27.515901 | 81 | 0.70348 | [
"object",
"model"
] |
f3b775086fa4ceed2cc12d0ab7cbe3de47687f7e | 11,666 | h | C | usr/src/uts/i86pc/sys/apix.h | AsahiOS/gate | 283d47da4e17a5871d9d575e7ffb81e8f6c52e51 | [
"MIT"
] | null | null | null | usr/src/uts/i86pc/sys/apix.h | AsahiOS/gate | 283d47da4e17a5871d9d575e7ffb81e8f6c52e51 | [
"MIT"
] | null | null | null | usr/src/uts/i86pc/sys/apix.h | AsahiOS/gate | 283d47da4e17a5871d9d575e7ffb81e8f6c52e51 | [
"MIT"
] | 1 | 2020-12-30T00:04:16.000Z | 2020-12-30T00:04:16.000Z | /*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2017 Joyent, Inc.
*/
#ifndef __SYS_APIX_APIX_H
#define __SYS_APIX_APIX_H
#include <sys/note.h>
#include <sys/avintr.h>
#include <sys/traptrace.h>
#include <sys/apic.h>
#include <sys/apic_common.h>
#include <sys/apic_timer.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef DEBUG
#ifndef TRAPTRACE
#define TRAPTRACE
#endif
#endif
#define APIX_NAME "apix"
#define APIX_NVECTOR 256 /* max number of per-cpu vectors */
#define APIX_NIRQ 256 /* maximum number of IRQs */
#define APIX_INVALID_VECT 0 /* invalid vector */
/* vector type */
#define APIX_TYPE_FIXED DDI_INTR_TYPE_FIXED /* 1 */
#define APIX_TYPE_MSI DDI_INTR_TYPE_MSI /* 2 */
#define APIX_TYPE_MSIX DDI_INTR_TYPE_MSIX /* 4 */
#define APIX_TYPE_IPI 8
/* vector states */
enum {
APIX_STATE_FREED = 0,
APIX_STATE_OBSOLETED, /* 1 */
APIX_STATE_ALLOCED, /* 2 */
APIX_STATE_ENABLED, /* 3 */
APIX_STATE_DISABLED /* 4 */
};
#define IS_VECT_FREE(p) \
(((p) == NULL) || ((p)->v_state == APIX_STATE_FREED))
#define IS_VECT_OBSOL(p) \
(((p) != NULL) && ((p)->v_state == APIX_STATE_OBSOLETED))
#define IS_VECT_ENABLED(p) \
(((p) != NULL) && ((p)->v_state == APIX_STATE_ENABLED))
/* flags */
#define APIX_VECT_USER_BOUND 0x1
#define APIX_VECT_MASKABLE 0x2
/*
* Number of interrupt vectors reserved by software on each LOCAL APIC:
* 1. Dtrace
* 2. int80
* 3. system-call
* 4. fast-trap
* 5. apix-reserved
*/
#define APIX_SW_RESERVED_VECTORS 5
/*
* Macros to help deal with shared interrupts and to differentiate
* between vector and irq number when passing arguments to interfaces
* xxx_avintr()
*/
#define APIX_VIRTVEC_VECMASK 0xff
#define APIX_VIRTVEC_FLAG 0x80000000
#define APIX_VIRTVECTOR(cpuid, v) \
(APIX_VIRTVEC_FLAG | ((cpuid) << 8) | (v))
#define APIX_IS_VIRTVEC(vv) \
((vv) & APIX_VIRTVEC_FLAG)
#define APIX_VIRTVEC_VECTOR(vv) \
(((uchar_t)(vv)) & APIX_VIRTVEC_VECMASK)
#define APIX_VIRTVEC_CPU(vv) \
(((uint32_t)(vv) & ~APIX_VIRTVEC_FLAG) >> 8)
struct apix_dev_vector;
typedef struct apix_vector {
ushort_t v_state;
ushort_t v_type; /* interrupt type */
processorid_t v_cpuid; /* current target cpu */
uchar_t v_vector; /* vector */
uchar_t v_share; /* intrs at this vector */
int v_inum; /* irq for fixed, inum for msi/x */
uint_t v_flags;
processorid_t v_bound_cpuid; /* binding cpu */
uint_t v_busy; /* How frequently did clock */
/* find us in this */
uint_t v_pri; /* maximum priority */
struct autovec *v_autovect; /* ISR linked list */
void *v_intrmap_private; /* intr remap data */
struct apix_dev_vector *v_devp; /* pointer to device */
struct apix_vector *v_next; /* next on per-cpu obosoletes chain */
} apix_vector_t;
typedef struct apix_impl {
processorid_t x_cpuid; /* cpu number */
uint16_t x_intr_pending; /* pending intr by IPL */
/* pointer to head of interrupt pending list */
struct autovec *x_intr_head[PIL_MAX + 1];
/* pointer to tail of interrupt pending list */
struct autovec *x_intr_tail[PIL_MAX + 1];
apix_vector_t *x_obsoletes; /* obosoleted vectors */
apix_vector_t *x_vectbl[APIX_NVECTOR]; /* vector table */
lock_t x_lock;
} apix_impl_t;
#define HILEVEL_PENDING(cpu) \
(apixs[(cpu)->cpu_id]->x_intr_pending & CPU_INTR_ACTV_HIGH_LEVEL_MASK)
#define LOWLEVEL_PENDING(cpu) \
(apixs[(cpu)->cpu_id]->x_intr_pending & ~CPU_INTR_ACTV_HIGH_LEVEL_MASK)
#define IS_HILEVEL_RUNNING(cpu) \
(((ushort_t)((cpu)->intr_actv)) & CPU_INTR_ACTV_HIGH_LEVEL_MASK)
#define IS_LOWLEVEL_RUNNING(cpu) \
(((ushort_t)((cpu)->intr_actv)) & ~CPU_INTR_ACTV_HIGH_LEVEL_MASK)
#define INTR_PENDING(apixp, ipl) \
((ipl) <= LOCK_LEVEL ? \
((apixp)->x_intr_pending & (1 << (ipl))) : \
((apixp)->x_intr_pending >> (LOCK_LEVEL + 1)))
/*
* We need a way to find allocated vector for a device. One option
* is to maintain a mapping table in pcplusmp. Another option would
* be to record vector or irq with interrupt handler hdlp->ih_vector or
* hdlp->ih_irq.
* Second option requires interface changes, such as, a new interface
* for noticing vector changes caused by interrupt re-targeting.
* Currently we choose the first option cause it doesn't require
* new interfaces.
*/
typedef struct apix_dev_vector {
dev_info_t *dv_dip;
int dv_inum; /* interrupt number */
int dv_type; /* interrupt type */
apix_vector_t *dv_vector; /* vector */
struct apix_dev_vector *dv_next; /* per major chain */
} apix_dev_vector_t;
extern lock_t apix_lock;
extern apix_impl_t *apixs[];
extern int apix_nipis;
extern int apix_cpu_nvectors;
extern apix_dev_vector_t **apix_dev_vector;
extern processorid_t *apix_major_to_cpu;
extern kmutex_t apix_mutex;
#define xv_vector(cpu, v) apixs[(cpu)]->x_vectbl[(v)]
#define xv_intrmap_private(cpu, v) (xv_vector(cpu, v))->v_intrmap_private
#define APIX_IPI_MAX APIC_MAX_VECTOR
#define APIX_IPI_MIN (APIX_NVECTOR - apix_nipis)
#define APIX_AVINTR_MIN 0x20
#define APIX_NAVINTR \
(apix_cpu_nvectors - apix_nipis - APIX_AVINTR_MIN)
#define APIX_AVINTR_MAX \
((APIX_NAVINTR <= 0) ? 0 : \
(((APIX_AVINTR_MIN + APIX_NAVINTR) > APIX_IPI_MIN) ? \
(APIX_IPI_MIN - 2) : \
(APIX_AVINTR_MIN + APIX_NAVINTR - 2)))
#define APIX_RESV_VECTOR (APIX_AVINTR_MAX + 1)
#define IS_VALID_AVINTR(v) \
((v) >= APIX_AVINTR_MIN && (v) <= APIX_AVINTR_MAX)
#define APIX_ENTER_CPU_LOCK(cpuid) lock_set(&apixs[(cpuid)]->x_lock)
#define APIX_LEAVE_CPU_LOCK(cpuid) lock_clear(&apixs[(cpuid)]->x_lock)
#define APIX_CPU_LOCK_HELD(cpuid) LOCK_HELD(&apixs[(cpuid)]->x_lock)
/* Get dip for msi/x */
#define APIX_GET_DIP(v) \
((v)->v_devp->dv_dip)
/*
* For irq
*/
extern apic_irq_t *apic_irq_table[APIC_MAX_VECTOR+1];
#define IS_IRQ_FREE(p) \
((p) == NULL || ((p)->airq_mps_intr_index == FREE_INDEX))
#define UNREFERENCED_1PARAMETER(_p) _NOTE(ARGUNUSED(_p))
#define UNREFERENCED_3PARAMETER(_p, _q, _r) _NOTE(ARGUNUSED(_p, _q, _r))
/*
* From mp_platform_common.c
*/
extern int apic_intr_policy;
extern iflag_t apic_sci_flags;
extern int apic_hpet_vect;
extern iflag_t apic_hpet_flags;
extern int apic_redist_cpu_skip;
extern int apic_num_imbalance;
extern int apic_num_rebind;
extern struct apic_io_intr *apic_io_intrp;
extern int apic_use_acpi_madt_only;
extern uint32_t eisa_level_intr_mask;
extern int apic_pci_bus_total;
extern uchar_t apic_single_pci_busid;
extern ACPI_MADT_INTERRUPT_OVERRIDE *acpi_isop;
extern int acpi_iso_cnt;
extern int apic_defconf;
extern int apic_irq_translate;
extern int apic_max_reps_clear_pending;
extern int apic_probe_common(char *modname);
extern uchar_t acpi_find_ioapic(int irq);
extern int apic_find_bus_id(int bustype);
extern int apic_find_intin(uchar_t ioapic, uchar_t intin);
extern struct apic_io_intr *apic_find_io_intr_w_busid(int irqno, int busid);
extern int apic_acpi_translate_pci_irq(dev_info_t *dip, int busid, int devid,
int ipin, int *pci_irqp, iflag_t *intr_flagp);
extern int apic_handle_pci_pci_bridge(dev_info_t *idip, int child_devno,
int child_ipin, struct apic_io_intr **intrp);
extern void apic_record_rdt_entry(apic_irq_t *irqptr, int irq);
/*
* From apic_regops.c
*/
extern int apic_have_32bit_cr8;
/*
* apix_intr.c
*/
extern void apix_do_interrupt(struct regs *rp, trap_trace_rec_t *ttp);
/*
* apix_utils.c
*/
typedef struct apix_rebind_info {
int i_go; /* if rebinding op is in progress */
uint_t i_pri;
processorid_t i_old_cpuid;
struct autovec *i_old_av;
processorid_t i_new_cpuid;
struct autovec *i_new_av;
} apix_rebind_info_t;
extern struct apix_rebind_info apix_rebindinfo;
#define APIX_SET_REBIND_INFO(_ovp, _nvp)\
if (((_ovp)->v_flags & APIX_VECT_MASKABLE) == 0) {\
apix_rebindinfo.i_pri = (_ovp)->v_pri;\
apix_rebindinfo.i_old_cpuid = (_ovp)->v_cpuid;\
apix_rebindinfo.i_old_av = (_ovp)->v_autovect;\
apix_rebindinfo.i_new_cpuid = (_nvp)->v_cpuid;\
apix_rebindinfo.i_new_av = (_nvp)->v_autovect;\
apix_rebindinfo.i_go = 1;\
}
#define APIX_CLR_REBIND_INFO() \
apix_rebindinfo.i_go = 0
#define APIX_IS_FAKE_INTR(_vector)\
(apix_rebindinfo.i_go && (_vector) == APIX_RESV_VECTOR)
#define APIX_DO_FAKE_INTR(_cpu, _vector)\
if (APIX_IS_FAKE_INTR(_vector)) {\
struct autovec *tp = NULL;\
if ((_cpu) == apix_rebindinfo.i_old_cpuid)\
tp = apix_rebindinfo.i_old_av;\
else if ((_cpu) == apix_rebindinfo.i_new_cpuid)\
tp = apix_rebindinfo.i_new_av;\
ASSERT(tp != NULL);\
if (tp->av_vector != NULL &&\
(tp->av_flags & AV_PENTRY_PEND) == 0) {\
tp->av_flags |= AV_PENTRY_PEND;\
apix_insert_pending_av(apixs[(_cpu)], tp,\
tp->av_prilevel);\
apixs[(_cpu)]->x_intr_pending |=\
(1 << tp->av_prilevel);\
}\
}
extern int apix_add_avintr(void *intr_id, int ipl, avfunc xxintr, char *name,
int vector, caddr_t arg1, caddr_t arg2, uint64_t *ticksp, dev_info_t *dip);
extern void apix_rem_avintr(void *intr_id, int ipl, avfunc xxintr,
int virt_vect);
extern uint32_t apix_bind_cpu_locked(dev_info_t *dip);
extern apix_vector_t *apix_rebind(apix_vector_t *vecp, processorid_t tocpu,
int count);
extern uchar_t apix_alloc_ipi(int ipl);
extern apix_vector_t *apix_alloc_intx(dev_info_t *dip, int inum, int irqno);
extern int apix_alloc_msi(dev_info_t *dip, int inum, int count, int behavior);
extern int apix_alloc_msix(dev_info_t *dip, int inum, int count, int behavior);
extern void apix_free_vectors(dev_info_t *dip, int inum, int count, int type);
extern void apix_enable_vector(apix_vector_t *vecp);
extern void apix_disable_vector(apix_vector_t *vecp);
extern int apix_obsolete_vector(apix_vector_t *vecp);
extern int apix_find_cont_vector_oncpu(uint32_t cpuid, int count);
extern void apix_set_dev_map(apix_vector_t *vecp, dev_info_t *dip, int inum);
extern apix_vector_t *apix_get_dev_map(dev_info_t *dip, int inum, int type);
extern apix_vector_t *apix_setup_io_intr(apix_vector_t *vecp);
extern void ioapix_init_intr(int mask_apic);
extern int apix_get_min_dev_inum(dev_info_t *dip, int type);
extern int apix_get_max_dev_inum(dev_info_t *dip, int type);
/*
* apix.c
*/
extern int apix_addspl(int virtvec, int ipl, int min_ipl, int max_ipl);
extern int apix_delspl(int virtvec, int ipl, int min_ipl, int max_ipl);
extern void apix_intx_set_vector(int irqno, uint32_t cpuid, uchar_t vector);
extern apix_vector_t *apix_intx_get_vector(int irqno);
extern void apix_intx_enable(int irqno);
extern void apix_intx_disable(int irqno);
extern void apix_intx_free(int irqno);
extern int apix_intx_rebind(int irqno, processorid_t cpuid, uchar_t vector);
extern apix_vector_t *apix_set_cpu(apix_vector_t *vecp, int new_cpu,
int *result);
extern apix_vector_t *apix_grp_set_cpu(apix_vector_t *vecp, int new_cpu,
int *result);
extern void apix_level_intr_pre_eoi(int irq);
extern void apix_level_intr_post_dispatch(int irq);
#ifdef __cplusplus
}
#endif
#endif /* __SYS_APIX_APIX_H */
| 32.769663 | 79 | 0.746443 | [
"vector"
] |
f3bf197241179824841aa9f9298e2f1d799451de | 5,176 | h | C | lib/akari/scenegraph.h | shiinamiyuki/nano-akari | 09bc4d83a39df27668a9905c025f10ed543c6e85 | [
"Apache-2.0"
] | 5 | 2020-11-23T05:16:27.000Z | 2021-09-15T10:29:21.000Z | lib/akari/scenegraph.h | shiinamiyuki/nano-akari | 09bc4d83a39df27668a9905c025f10ed543c6e85 | [
"Apache-2.0"
] | null | null | null | lib/akari/scenegraph.h | shiinamiyuki/nano-akari | 09bc4d83a39df27668a9905c025f10ed543c6e85 | [
"Apache-2.0"
] | null | null | null | // Copyright 2020 shiinamiyuki
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <akari/util.h>
#include <akari/macro.h>
#include <cereal/cereal.hpp>
namespace akari::scene {
template <typename T>
using P = std::shared_ptr<T>;
class Texture {
public:
Texture() : value(0.0) {}
Texture(Float v) : value(v) {}
Texture(Spectrum s) : value(s) {}
Texture(std::string s) : value(s) {}
std::variant<Float, Spectrum, std::string> value;
AKR_SER(value)
void clear() { value = Float(0.0); }
void set_image_texture(const std::string &path) { value = path; }
void set_color(Spectrum color) { value = color; }
void set_float(Float v) { value = v; }
};
class Material {
public:
P<Texture> color;
P<Texture> specular;
P<Texture> metallic;
P<Texture> roughness;
P<Texture> emission;
P<Texture> transmission;
Material();
void commit() {}
AKR_SER(color, specular, metallic, roughness, emission, transmission)
};
struct Mesh {
bool loaded = false;
public:
std::string name;
std::vector<vec3> vertices;
std::vector<ivec3> indices;
std::vector<vec3> normals;
std::vector<vec2> texcoords;
std::string path;
AKR_SER(name, path)
void save_to_file(const std::string &file) const;
void load();
void unload();
};
class Instance {
public:
std::string name;
TRSTransform transform;
P<Mesh> mesh;
P<Material> material;
void commit() { material->commit(); }
AKR_SER(name, transform, mesh, material)
};
class Node {
public:
TRSTransform transform;
std::vector<P<Instance>> instances;
std::vector<P<Node>> children;
void commit() {
for (auto &child : children) {
child->commit();
}
}
AKR_SER(transform, instances, children)
};
#define AKR_DECL_RTTI(Class) \
template <class T> \
bool isa() const { \
return type() == T::static_type; \
} \
template <class T> \
const T *as() const { \
return isa<T>() ? dynamic_cast<const T *>(this) : nullptr; \
} \
template <class T> \
T *as() { \
return isa<T>() ? dynamic_cast<T *>(this) : nullptr; \
}
#define AKR_DECL_TYPEID(Class, TypeId) \
static const Type static_type = Type::TypeId; \
Type type() const override { return Type::TypeId; }
class Camera {
public:
enum class Type { Perspective };
AKR_DECL_RTTI(Camera)
virtual Type type() const = 0;
TRSTransform transform;
ivec2 resolution = ivec2(512, 512);
AKR_SER(transform, resolution)
};
class PerspectiveCamera final : public Camera {
public:
AKR_DECL_TYPEID(PerspectiveCamera, Perspective)
Float fov = glm::radians(80.0);
Float lens_radius = 0.0;
Float focal_distance = 0.0;
AKR_SER_POLY(Camera, fov, lens_radius, focal_distance)
};
class SceneGraph {
public:
P<Camera> camera;
P<Node> root;
std::vector<P<Mesh>> meshes;
std::vector<P<Instance>> instances;
void commit();
AKR_SER(camera, meshes, instances, root)
};
} // namespace akari::scene | 40.755906 | 120 | 0.450348 | [
"mesh",
"vector",
"transform"
] |
f3ca9a984621d5367f82200b7314de531c2c17fe | 1,045 | h | C | gstd/src/Stat.h | georgephilipp/cppgstd_legacy | e130860da7700aae42b915bc36a7efa4cae06d56 | [
"MIT"
] | null | null | null | gstd/src/Stat.h | georgephilipp/cppgstd_legacy | e130860da7700aae42b915bc36a7efa4cae06d56 | [
"MIT"
] | null | null | null | gstd/src/Stat.h | georgephilipp/cppgstd_legacy | e130860da7700aae42b915bc36a7efa4cae06d56 | [
"MIT"
] | null | null | null | /*
* File: Stat.h
* Author: gschoenh
*
* Created on November 14, 2013, 8:14 PM
*/
#include "stdafx.h"
#ifndef STAT_H
#define STAT_H
#include"standard.h"
#include"Rand.h"
namespace msii810161816
{
namespace gstd
{
namespace stat
{
double MSII810161816_GSTD_API normcum(double x);
double MSII810161816_GSTD_API normcuminv(double p);
double MSII810161816_GSTD_API randnorm(int mode);
std::vector<double> MSII810161816_GSTD_API covarianceMatrix(int dim1, int dim2, std::vector<double>& input);
std::pair<double,double> MSII810161816_GSTD_API meanAndVar(std::vector<double> input);
double MSII810161816_GSTD_API meanPval(double targetMean, std::vector<double> vals);
double MSII810161816_GSTD_API varPval(double targetVariance, std::vector<double> vals);
double MSII810161816_GSTD_API combineTestPs(std::vector<double> inputs);
bool MSII810161816_GSTD_API test();
}
}
}
#endif /* STAT_H */
| 27.5 | 120 | 0.670813 | [
"vector"
] |
f3d68f87415a5e91110c71d207616c161630dc0e | 5,794 | h | C | Orbit/include/Render/VulkanBuffer.h | JusticesHand/orbit-engine | fd9bd160f6e54fb49a9e720f0c409ae5deb6e676 | [
"MIT"
] | null | null | null | Orbit/include/Render/VulkanBuffer.h | JusticesHand/orbit-engine | fd9bd160f6e54fb49a9e720f0c409ae5deb6e676 | [
"MIT"
] | 8 | 2017-09-05T04:12:03.000Z | 2017-10-26T03:17:07.000Z | Orbit/include/Render/VulkanBuffer.h | JusticesHand/orbit-engine | fd9bd160f6e54fb49a9e720f0c409ae5deb6e676 | [
"MIT"
] | null | null | null | /*! @file Render/VulkanMemoryBuffer.h */
#ifndef RENDER_VULKANMEMORYBUFFER_H
#define RENDER_VULKANMEMORYBUFFER_H
#pragma once
#include <cstdint>
#include <memory>
#include <vector>
#include <vulkan/vulkan.hpp>
namespace Orbit
{
class VulkanBase;
class VulkanImage;
/*!
@brief Wrapper class containing a vk::Buffer and vk::DeviceMemory object.
Handles memory allocation through a simple block framework - block sizes are supplied and their access
(read/write) is allowed through the getBlock() method.
*/
class VulkanBuffer final
{
public:
/*!
@brief Default constructor for the class. Does not allocate any memory - serves as a blank slate to be overriden.
*/
VulkanBuffer(std::nullptr_t);
/*!
@brief Constructs a VulkanMemoryBuffer object with the objects in parameter.
@param base The base of the Vulkan renderer.
@param blockSizes A collection of sizes for the blocks. The constructor computes the total size from these.
@param createInfo The create info used to create the buffer. Its size property is set by the contructor.
@param memFlags The flags that the memory should possess.
*/
explicit VulkanBuffer(
std::shared_ptr<const VulkanBase> base,
const std::vector<vk::DeviceSize>& blockSizes,
vk::BufferCreateInfo createInfo,
vk::MemoryPropertyFlags memFlags);
VulkanBuffer(const VulkanBuffer&) = delete;
VulkanBuffer& operator=(const VulkanBuffer& rhs) = delete;
/*!
@brief Move constructor for a VulkanMemoryBuffer. Transfers the owned objects.
@param rhs The right hand side of the operation.
*/
VulkanBuffer(VulkanBuffer&& rhs);
/*!
@brief Move assignment operator for a VulkanMemoryBuffer. Transfers the owned objects.
@param rhs The right hand side of the operation.
@return A reference to this.
*/
VulkanBuffer& operator=(VulkanBuffer&& rhs);
/*!
@brief Destructor for the class. Ensures that the inner buffer and memory are correctly destroyed.
*/
~VulkanBuffer();
/*!
@brief Helper function to generate a command buffer that handles transfers to another buffer.
@param rhs The buffer to be the destination of the data.
@param dstOffset The offset into the destination memory.
@return A recorded command buffer describing the transfer operation, ready to be submitted.
*/
vk::CommandBuffer transferToBuffer(VulkanBuffer& rhs, vk::DeviceSize dstOffset = 0Ui64);
/*!
@brief Helper function to generate a command buffer that handles transfers to an image.
Assumes that both the buffer and image are the same size - any discrepancy is fairly bad news.
@param rhs The image to be the destination of the data.
@return A recorded command buffer describing the transfer operation, ready to be submitted.
*/
vk::CommandBuffer transferToImage(VulkanImage& rhs);
/*!
@brief Destroys the Buffer and DeviceMemory members, essentially recreating a blank slate.
*/
void clear();
/*!
@brief Getter for the interior buffer.
@return The inner vk::Buffer.
*/
vk::Buffer buffer() const;
/*!
@brief Block class describing a block of memory in a buffer.
*/
class Block final
{
/*! Only allow a VulkanMemoryBuffer access to the constructor. */
friend class VulkanBuffer;
public:
/*!
@brief Copy the data in parameter to the underlying memory (using memcpy) with the size in parameter.
@throw std::runtime_error Throws if the size parameter is different from the Block's size.
@param data The data source to copy.
@param size The size of the data to copy.
*/
void copy(const void* data, vk::DeviceSize size);
/*!
@brief Getter for the size property of the class.
@return The size property of the class.
*/
vk::DeviceSize size() const;
/*!
@brief Getter for the offset property of the class.
@return The offset property of the class.
*/
vk::DeviceSize offset() const;
private:
/*!
@brief Constructor for the class. Constructs the Block object with the parameters.
@param base The base of the Vulkan renderer.
@param memory The memory on which the block is based.
@param size The size of the memory block.
@param offset The offset of the memory block.
*/
Block(
std::shared_ptr<const VulkanBase> base,
vk::DeviceMemory memory,
vk::DeviceSize size,
vk::DeviceSize offset);
/*! The Vulkan base. */
std::shared_ptr<const VulkanBase> _base;
/*! The actual underlying memory containing the Block. */
vk::DeviceMemory _memory;
/*! The size of the block's memory. */
vk::DeviceSize _size;
/*! The offset of the block's memory in the underlying memory. */
vk::DeviceSize _offset;
};
/*!
@brief Indexed getter for a block.
@throw std::out_of_range Throws if the index is out of range - passed on by std::vector.
@param index The index of the block to retrieve.
@return The block.
*/
Block& getBlock(size_t index);
/*! @copydoc VulkanBuffer::getBlock(size_t) */
const Block& getBlock(size_t index) const;
/*!
@brief Indexing operator for getting a block. Simply calls VulkanMemoryBuffer::getBlock().
@throw std::out_of_range Throws if the index is out of range - passed on by std::vector.
@param index The index of the block to retrieve.
@return The block.
*/
Block& operator[](size_t index);
/*! @copydoc VulkanBuffer::operator[](size_t) */
const Block& operator[](size_t index) const;
private:
/*! The renderer's base. */
std::shared_ptr<const VulkanBase> _base;
/*! Created and owned buffer. */
vk::Buffer _buffer;
/*! Created and owned memory. */
vk::DeviceMemory _memory;
/*! The total size of the DeviceMemory. */
vk::DeviceSize _totalSize = 0;
/*! The blocks making up the memory scheme. */
std::vector<Block> _blocks;
};
}
#endif //RENDER_VULKANMEMORYBUFFER_H | 31.835165 | 115 | 0.718329 | [
"render",
"object",
"vector"
] |
f3e31faaf7c6edd3cc0703f7923f8a5e5aa072a9 | 3,075 | h | C | src/lib/Common/include/kfuzz/Common/ClangDataTypes.h | Myriad-Dreamin/clang-diag | 96c6b3118100d9a2694e8a10d273521ae55b44c0 | [
"Apache-2.0"
] | null | null | null | src/lib/Common/include/kfuzz/Common/ClangDataTypes.h | Myriad-Dreamin/clang-diag | 96c6b3118100d9a2694e8a10d273521ae55b44c0 | [
"Apache-2.0"
] | null | null | null | src/lib/Common/include/kfuzz/Common/ClangDataTypes.h | Myriad-Dreamin/clang-diag | 96c6b3118100d9a2694e8a10d273521ae55b44c0 | [
"Apache-2.0"
] | null | null | null | //
// Created by kamiyoru on 2020/10/19.
//
#ifndef KERNEL_FUZZER_COMMON_CLANG_DATA_TYPES_H
#define KERNEL_FUZZER_COMMON_CLANG_DATA_TYPES_H
#include <map>
#include <queue>
#include <utility>
#include <clang/Tooling/Tooling.h>
#include <kfuzz/Common/IncompleteTypeDecls.h>
namespace kfuzz {
struct Inclusion {
llvm::StringRef file_name;
const clang::FileEntry *included_file{};
};
struct SymbolInfo {
std::vector<symbol_hash_t> dependency;
llvm::StringRef filePath;
llvm::StringRef absFilePath;
symbol_hash_t id;
file_offset_t file_offset;
explicit SymbolInfo(symbol_hash_t id);
SymbolInfo(SymbolInfo &&rhs) noexcept;
};
struct ExternalVarInfo : public SymbolInfo {
const clang::VarDecl *decl;
const clang::Stmt *var;
explicit ExternalVarInfo(symbol_hash_t id);
ExternalVarInfo(ExternalVarInfo &&rhs) noexcept;
};
struct FunctionInfo : public SymbolInfo {
using func_char_underlying_t = uint64_t;
func_char_underlying_t trait;
const clang::FunctionType *type;
const clang::FunctionDecl *decl;
explicit FunctionInfo(symbol_hash_t id);
FunctionInfo(FunctionInfo &&rhs) noexcept;
enum FuncChar : func_char_underlying_t {
NoChar = 0ULL,
IsDefinition = 1ULL << 1ULL,
IsUsed = 1ULL << 2ULL,
};
};
struct DeclInfo : public SymbolInfo {
using decl_char_underlying_t = uint64_t;
decl_char_underlying_t trait;
const clang::Type *type = nullptr;
const clang::NamedDecl *decl = nullptr;
explicit DeclInfo(symbol_hash_t id);
DeclInfo(symbol_hash_t id, const clang::Type *type, const clang::NamedDecl *decl, decl_char_underlying_t trait);
DeclInfo(DeclInfo &&rhs) noexcept;
DeclInfo(const DeclInfo &rhs) = delete;
void init(const clang::Type *in_type, const clang::NamedDecl *in_decl, decl_char_underlying_t in_trait);
enum DeclChar : decl_char_underlying_t {
NoChar = 0ULL,
IsDefinition = 1ULL << 1ULL,
/// to work around the following situation:
///
/// ```code
/// type struct { int b; } a;
/// ```
IsTypedefEmbeddedAnonymousStruct = 1ULL << 2ULL,
/// to work around the following situation:
///
/// // a_t.h
/// ```code
/// type struct A* a_t;
/// ```
///
/// // a.h
/// ```code
/// struct A { a_t a; };
/// ```
///
/// todo: FIX ME: however there exists the other situation:
/// typedef void (*f_t) (struct depA*, struct depB*)
/// struct depA { f_t f };
/// struct depB { f_t f };
IsTypedefUsingIncompleteType = 1ULL << 3ULL,
IsEmbeddedDecl = 1ULL << 4ULL,
};
};
}
#endif //KERNEL_FUZZER_COMMON_CLANG_DATA_TYPES_H
| 27.702703 | 120 | 0.583415 | [
"vector"
] |
137b416c85d38591a64e8f6f89a065eaf4eb6995 | 3,004 | h | C | connectivity/shill/dbus/chromeos_ipconfig_dbus_adaptor.h | Keneral/asystem | df12381b72ef3d629c8efc61100cc8c714195320 | [
"Unlicense"
] | null | null | null | connectivity/shill/dbus/chromeos_ipconfig_dbus_adaptor.h | Keneral/asystem | df12381b72ef3d629c8efc61100cc8c714195320 | [
"Unlicense"
] | null | null | null | connectivity/shill/dbus/chromeos_ipconfig_dbus_adaptor.h | Keneral/asystem | df12381b72ef3d629c8efc61100cc8c714195320 | [
"Unlicense"
] | null | null | null | //
// Copyright (C) 2015 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef SHILL_DBUS_CHROMEOS_IPCONFIG_DBUS_ADAPTOR_H_
#define SHILL_DBUS_CHROMEOS_IPCONFIG_DBUS_ADAPTOR_H_
#include <string>
#include <vector>
#include <base/macros.h>
#include "dbus_bindings/org.chromium.flimflam.IPConfig.h"
#include "shill/adaptor_interfaces.h"
#include "shill/dbus/chromeos_dbus_adaptor.h"
namespace shill {
class IPConfig;
// Subclass of DBusAdaptor for IPConfig objects
// There is a 1:1 mapping between IPConfig and ChromeosIPConfigDBusAdaptor
// instances. Furthermore, the IPConfig owns the ChromeosIPConfigDBusAdaptor
// and manages its lifetime, so we're OK with ChromeosIPConfigDBusAdaptor
// having a bare pointer to its owner ipconfig.
class ChromeosIPConfigDBusAdaptor
: public org::chromium::flimflam::IPConfigAdaptor,
public org::chromium::flimflam::IPConfigInterface,
public ChromeosDBusAdaptor,
public IPConfigAdaptorInterface {
public:
static const char kInterfaceName[];
static const char kPath[];
ChromeosIPConfigDBusAdaptor(const scoped_refptr<dbus::Bus>& bus,
IPConfig* ipconfig);
~ChromeosIPConfigDBusAdaptor() override;
// Implementation of IPConfigAdaptorInterface.
const std::string& GetRpcIdentifier() override { return dbus_path().value(); }
void EmitBoolChanged(const std::string& name, bool value) override;
void EmitUintChanged(const std::string& name, uint32_t value) override;
void EmitIntChanged(const std::string& name, int value) override;
void EmitStringChanged(const std::string& name,
const std::string& value) override;
void EmitStringsChanged(const std::string& name,
const std::vector<std::string>& value) override;
// Implementation of IPConfigAdaptor
bool GetProperties(brillo::ErrorPtr* error,
brillo::VariantDictionary* properties) override;
bool SetProperty(brillo::ErrorPtr* error,
const std::string& name,
const brillo::Any& value) override;
bool ClearProperty(brillo::ErrorPtr* error,
const std::string& name) override;
bool Remove(brillo::ErrorPtr* error) override;
bool Refresh(brillo::ErrorPtr* error) override;
private:
IPConfig* ipconfig_;
DISALLOW_COPY_AND_ASSIGN(ChromeosIPConfigDBusAdaptor);
};
} // namespace shill
#endif // SHILL_DBUS_CHROMEOS_IPCONFIG_DBUS_ADAPTOR_H_
| 37.55 | 80 | 0.733356 | [
"vector"
] |
137c6b34a6076baf45df7f601e9fe906f34b7022 | 102,483 | h | C | src/catkin_ws/src/failsafe_nodelets/util/reflexxesTypeIV/include/RMLOutputParameters.h | JakobThumm/safe_rl_manipulators | 1724aee2ec4cbbd8fecfbf1653991e182d4ca48b | [
"MIT"
] | null | null | null | src/catkin_ws/src/failsafe_nodelets/util/reflexxesTypeIV/include/RMLOutputParameters.h | JakobThumm/safe_rl_manipulators | 1724aee2ec4cbbd8fecfbf1653991e182d4ca48b | [
"MIT"
] | null | null | null | src/catkin_ws/src/failsafe_nodelets/util/reflexxesTypeIV/include/RMLOutputParameters.h | JakobThumm/safe_rl_manipulators | 1724aee2ec4cbbd8fecfbf1653991e182d4ca48b | [
"MIT"
] | null | null | null | // ---------------------- Doxygen info ----------------------
//! \file RMLOutputParameters.h
//!
//! \brief
//! Header file for the classes RMLOutputParameters, RMLOutputPolynomials,
//! and RMLPolynomial
//!
//! \details
//! The class RMLOutputParameters constitutes the basis class for the
//! actual interface classes RMLPositionOutputParameters and
//! RMLVelocityOutputParameters, which are both derived from this one.
//! Objects of the class RMLOutputPolynomials are used within the class
//! RMLOutputParameters, which consists of objects of the class
//! RMLPolynomial.
//!
//! \sa RMLInputParameters.h
//! \sa RMLVelocityOutputParameters.h
//! \sa RMLPositionOutputParameters.h
//! \n
//! \n
//! \n
//! Reflexxes GmbH\n
//! Sandknoell 7\n
//! D-24805 Hamdorf\n
//! GERMANY\n
//! \n
//! http://www.reflexxes.com\n
//!
//! \date October 2013
//!
//! \version 1.3.2
//!
//! \author Torsten Kroeger, <info@reflexxes.com>
//!
//!
//! \note Copyright (C) 2013 Reflexxes GmbH.
// ----------------------------------------------------------
// For a convenient reading of this file's source code,
// please use a tab width of four characters.
// ----------------------------------------------------------
#ifndef __RMLOutputParameters__
#define __RMLOutputParameters__
#include <RMLVector.h>
#include <string.h>
#include <math.h>
// ---------------------- Doxygen info ----------------------
//! \class RMLPolynomial
//!
//! \brief
//! Contains the parameters of a section of polynomials for position,
//! velocity, and acceleration for one single degree of freedom
//!
//! \details
//! The three polynomials
//!
//! - \f$ p(t)\ =\ p_3t^3\ +\ p_2t^2\ +\ p_1t\ +\ p_0 \f$
//! - \f$ v(t)\ =\ v_2t^2\ +\ v_1t\ +\ v_0 \f$
//! - \f$ a(t)\ =\ a_1t\ +\ a_0 \f$
//!
//! describe the trajectory within one section and are valid until the
//! time RMLPolynomial::Time_ValidUntil. An entire trajectory for one degree
//! of freedom consists of a set of such polynomial segments.
//!
//! \sa RMLOutputPolynomials
//! \sa RMLOutputParameters
//! \sa \ref page_Code_02_RMLPositionSampleApplication
//! \sa \ref page_Code_05_RMLVelocitySampleApplication
// ----------------------------------------------------------
class RMLPolynomial
{
public:
// ---------------------- Doxygen info ----------------------
//! \fn RMLPolynomial(void)
//!
//! \brief
//! Constructor of class RMLPolynomial
// ----------------------------------------------------------
RMLPolynomial(void)
{
Time_ValidUntil = 0.0 ;
memset(PositionPolynomialCoefficients, 0x0, 4 * sizeof(double)) ;
memset(VelocityPolynomialCoefficients, 0x0, 3 * sizeof(double)) ;
memset(AccelerationPolynomialCoefficients, 0x0, 2 * sizeof(double)) ;
}
// ---------------------- Doxygen info ----------------------
//! \fn RMLPolynomial(const RMLPolynomial &P)
//!
//! \brief
//! Copy constructor of class RMLPolynomial
//!
//! \param P
//! Object to be copied
// ----------------------------------------------------------
RMLPolynomial(const RMLPolynomial &P)
{
*this = P;
}
// ---------------------- Doxygen info ----------------------
//! \fn ~RMLPolynomial(void)
//!
//! \brief
//! Destructor of class RMLPolynomial
// ----------------------------------------------------------
~RMLPolynomial(void)
{
}
// ---------------------- Doxygen info ----------------------
//! \fn inline RMLPolynomial &operator = (const RMLPolynomial &P)
//!
//! \brief
//! Copy operator
//!
//! \param P
//! RMLPolynomial object to be copied
//!
//! \return
//! The duplicated object
// ----------------------------------------------------------
inline RMLPolynomial &operator = (const RMLPolynomial &P)
{
memcpy(this, &P, sizeof(RMLPolynomial));
return(*this);
}
// ---------------------- Doxygen info ----------------------
//! \fn void Echo(FILE* FileHandler = stdout) const
//!
//! \brief
//! Prints all polynomial coefficients to *FileHandler
//!
//! \param FileHandler
//! File handler for the output
//!
//! \warning
//! The usage of this method is \b not real-time capable.
// ----------------------------------------------------------
void Echo(FILE* FileHandler = stdout) const
{
if (FileHandler == NULL)
{
return;
}
fprintf(FileHandler, "Valid until : %.6le seconds\n", this->Time_ValidUntil);
fprintf(FileHandler, "Position : p(t)= %.6lft^3 %c %.6lft^2 %c %.6lft %c %.6lf\n"
, this->PositionPolynomialCoefficients[3]
, (this->PositionPolynomialCoefficients[2]>=0)?('+'):('-')
, fabs(this->PositionPolynomialCoefficients[2])
, (this->PositionPolynomialCoefficients[1]>=0)?('+'):('-')
, fabs(this->PositionPolynomialCoefficients[1])
, (this->PositionPolynomialCoefficients[0]>=0)?('+'):('-')
, fabs(this->PositionPolynomialCoefficients[0]));
fprintf(FileHandler, "Velocity : v(t)= %.6lft^2 %c %.6lft %c %.6lf\n"
, this->VelocityPolynomialCoefficients[2]
, (this->VelocityPolynomialCoefficients[1]>=0)?('+'):('-')
, fabs(this->VelocityPolynomialCoefficients[1])
, (this->VelocityPolynomialCoefficients[0]>=0)?('+'):('-')
, fabs(this->VelocityPolynomialCoefficients[0]));
fprintf(FileHandler, "Acceleration: a(t)= %.6lft %c %.6lf\n"
, this->AccelerationPolynomialCoefficients[1]
, (this->AccelerationPolynomialCoefficients[0]>=0)?('+'):('-')
, fabs(this->AccelerationPolynomialCoefficients[0]));
}
// ---------------------- Doxygen info ----------------------
//! \var double PositionPolynomialCoefficients[4]
//!
//! \brief
//! Array containing the coefficients of the position polynomial
//!
//! \details
//! The four elements of this \c double array contain the coefficients
//! of the polynomial
//!
//! \f$ p(t)\ =\ p_3t^3\ +\ p_2t^2\ +\ p_1t\ +\ p_0 \f$
//!
//! - <c>PositionPolynomialCoefficients[0]</c> \f$\Longleftrightarrow\ \ \ p_0\f$
//! - <c>PositionPolynomialCoefficients[1]</c> \f$\Longleftrightarrow\ \ \ p_1\f$
//! - <c>PositionPolynomialCoefficients[2]</c> \f$\Longleftrightarrow\ \ \ p_2\f$
//! - <c>PositionPolynomialCoefficients[3]</c> \f$\Longleftrightarrow\ \ \ p_3\f$
//!
//! This polynomial segment is valid until the time instant
//! RMLPolynomial::Time_ValidUntil.
// ----------------------------------------------------------
double PositionPolynomialCoefficients[4];
// ---------------------- Doxygen info ----------------------
//! \var double VelocityPolynomialCoefficients[3]
//!
//! \brief
//! Array containing the coefficients of the velocity polynomial
//!
//! \details
//! The three elements of this \c double array contain the coefficients
//! of the polynomial
//!
//! \f$ v(t)\ =\ v_2t^2\ +\ v_1t\ +\ v_0 \f$
//!
//! - <c>VelocityPolynomialCoefficients[0]</c> \f$\Longleftrightarrow\ \ \ v_0\f$
//! - <c>VelocityPolynomialCoefficients[1]</c> \f$\Longleftrightarrow\ \ \ v_1\f$
//! - <c>VelocityPolynomialCoefficients[2]</c> \f$\Longleftrightarrow\ \ \ v_2\f$
//!
//! This polynomial segment is valid until the time instant
//! RMLPolynomial::Time_ValidUntil.
// ----------------------------------------------------------
double VelocityPolynomialCoefficients[3];
// ---------------------- Doxygen info ----------------------
//! \var double AccelerationPolynomialCoefficients[2]
//!
//! \brief
//! Array containing the coefficients of the acceleration polynomial
//!
//! \details
//! The two elements of this \c double array contain the coefficients
//! of the polynomial
//!
//! \f$ a(t)\ =\ a_1t\ +\ a_0 \f$
//!
//! - <c>AccelerationPolynomialCoefficients[0]</c> \f$\Longleftrightarrow\ \ \ a_0\f$
//! - <c>AccelerationPolynomialCoefficients[1]</c> \f$\Longleftrightarrow\ \ \ a_1\f$
//!
//! This polynomial segment is valid until the time instant
//! RMLPolynomial::Time_ValidUntil.
// ----------------------------------------------------------
double AccelerationPolynomialCoefficients[2];
// ---------------------- Doxygen info ----------------------
//! \var double Time_ValidUntil
//!
//! \brief
//! Time in seconds until this polynomial is valid
// ----------------------------------------------------------
double Time_ValidUntil;
};// class RMLPolynomial
// ---------------------- Doxygen info ----------------------
//! \class RMLOutputPolynomials
//!
//! \brief
//! Contains all polynomial coefficients for all selected degrees of
//! freedom
//!
//! \details
//! The class contains a set of piecewise polynomials for position
//! velocity, and acceleration progressions of all selected degrees of
//! freedom. It contains a 2D array of RMLPolynomial objects that
//! contain the coefficients of the actual polynomials.
//!
//! \sa RMLPolynomial
//! \sa RMLOutputParameters
//! \sa \ref page_Code_02_RMLPositionSampleApplication
//! \sa \ref page_Code_05_RMLVelocitySampleApplication
// ----------------------------------------------------------
class RMLOutputPolynomials
{
public:
// ---------------------- Doxygen info ----------------------
//! \fn RMLOutputPolynomials(const unsigned int DegreesOfFreedom)
//!
//! \brief
//! Constructor of class RMLOutputPolynomials
//!
//! \warning
//! The constructor is \b not real-time capable as heap memory has to be
//! allocated.
//!
//! \param DegreesOfFreedom
//! Specifies the number of degrees of freedom
// ----------------------------------------------------------
RMLOutputPolynomials(const unsigned int DegreesOfFreedom)
{
unsigned int i = 0 ;
this->NumberOfDOFs = DegreesOfFreedom ;
this->NumberOfCurrentlyValidSegments = new int [this->NumberOfDOFs] ;
this->Coefficients = new RMLPolynomial* [this->NumberOfDOFs] ;
memset(this->NumberOfCurrentlyValidSegments, 0x0, this->NumberOfDOFs * sizeof(unsigned int));
for (i = 0; i < this->NumberOfDOFs; i++)
{
(this->Coefficients)[i] = new RMLPolynomial[14];
}
}
// ---------------------- Doxygen info ----------------------
//! \fn RMLOutputPolynomials(const RMLOutputPolynomials &P)
//!
//! \brief
//! Copy constructor of class RMLOutputPolynomials
//!
//! \warning
//! The constructor is \b not real-time capable as heap memory has to be
//! allocated.
//!
//! \param P
//! Object to be copied
// ----------------------------------------------------------
RMLOutputPolynomials(const RMLOutputPolynomials &P)
{
unsigned int i = 0 ;
this->Coefficients = new RMLPolynomial* [P.NumberOfDOFs] ;
this->NumberOfCurrentlyValidSegments = new int [P.NumberOfDOFs] ;
for (i = 0; i < P.NumberOfDOFs; i++)
{
(this->Coefficients)[i] = new RMLPolynomial[14];
}
*this = P;
}
// ---------------------- Doxygen info ----------------------
//! \fn ~RMLOutputPolynomials(void)
//!
//! \brief
//! Destructor of class RMLOutputPolynomials
// ----------------------------------------------------------
~RMLOutputPolynomials(void)
{
unsigned int i = 0 ;
delete[] this->NumberOfCurrentlyValidSegments ;
for (i = 0; i < this->NumberOfDOFs; i++)
{
delete[] (this->Coefficients)[i] ;
}
delete[] this->Coefficients ;
this->Coefficients = NULL ;
this->NumberOfCurrentlyValidSegments = NULL ;
this->NumberOfDOFs = 0 ;
}
// ---------------------- Doxygen info ----------------------
//! \fn RMLOutputPolynomials &operator = (const RMLOutputPolynomials &P)
//!
//! \brief
//! Copy operator
//!
//! \param P
//! RMLOutputPolynomials object to be copied
//!
//! \return
//! The duplicated object
// ----------------------------------------------------------
RMLOutputPolynomials &operator = (const RMLOutputPolynomials &P)
{
unsigned int i = 0 ;
int j = 0 ;
this->NumberOfDOFs = P.NumberOfDOFs ;
for (i = 0; i < this->NumberOfDOFs; i++)
{
this->NumberOfCurrentlyValidSegments[i] = P.NumberOfCurrentlyValidSegments[i];
for (j = 0; j < this->NumberOfCurrentlyValidSegments[i]; j++)
{
this->Coefficients[i][j] = P.Coefficients[i][j];
}
}
return(*this);
}
// ---------------------- Doxygen info ----------------------
//! \var unsigned int NumberOfDOFs
//!
//! \brief
//! The number of degrees of freedom \f$ K \f$
// ----------------------------------------------------------
unsigned int NumberOfDOFs;
// ---------------------- Doxygen info ----------------------
//! \var int NumberOfDOFs
//!
//! \brief
//! Pointer to an array of integer numbers with
//! RMLOutputPolynomials::NumberOfDOFs elements that contain the number of
//! valid polynomial segments per degree of freedom \f$ k \f$
// ----------------------------------------------------------
int *NumberOfCurrentlyValidSegments;
// ---------------------- Doxygen info ----------------------
//! \var RMLPolynomial **Coefficients
//!
//! \brief
//! Pointer to a 2D array of \c RMLPolynomial objects
//!
//! \details
//! This heap-allocated two-dimensional array contains all coefficients of
//! all polynomial segments for all \f$ K \f$ degrees of freedom. A
//! trajectory for one single degree of freedom may consist of up to 14
//! polynomial segments. The coefficients of a single polynomial can be
//! accessed by <c>RMLPolynomial::Coefficients[k][l]</c>, where \c k is the
//! index of a degree of freedom \f$ k\ \in\ \{0,\,\dots,\,K\} \f$ and
//! \c l is the index of a polynomial segment
//! \f$ l\ \in\ \{0,\,\dots,\,14\} \f$.
//!
//! \sa RMLPolynomial
// ----------------------------------------------------------
RMLPolynomial **Coefficients;
};// class RMLOutputPolynomials
// ---------------------- Doxygen info ----------------------
//! \class RMLOutputParameters
//!
//! \brief
//! Class for the output parameters of the Online
//! Trajectory Generation algorithm
//!
//! \details
//! The class RMLOutputParameters constitutes the basis class for the
//! actual interface classes RMLPositionOutputParameters and
//! RMLVelocityOutputParameters, which are both derived from this one.
//!
//! \sa ReflexxesAPI
//! \sa RMLPositionOutputParameters
//! \sa RMLVelocityOutputParameters
//! \sa RMLInputParameters
//! \sa \ref page_OutputValues
// ----------------------------------------------------------
class RMLOutputParameters
{
public:
// ---------------------- Doxygen info ----------------------
//! \enum ReturnValue
//!
//! \brief
//! Return values for the methods of the class RMLOutputParameters
// ----------------------------------------------------------
enum ReturnValue
{
RETURN_SUCCESS = 0,
RETURN_ERROR = -1
};
protected:
// ---------------------- Doxygen info ----------------------
//! \fn RMLOutputParameters(const unsigned int DegreesOfFreedom)
//!
//! \brief
//! Constructor of class RMLOutputParameters
//!
//! \warning
//! The constructor is \b not real-time capable as heap memory has to be
//! allocated.
//!
//! \param DegreesOfFreedom
//! Specifies the number of degrees of freedom
//!
//! \note
//! This is only the base class for the classes\n\n
//! <ul>
//! <li>RMLPositionOutputParameters and</li>
//! <li>RMLVelocityOutputParameters,\n\n</li>
//! </ul>
//! such that the constructor is declared \c protected.
// ----------------------------------------------------------
RMLOutputParameters(const unsigned int DegreesOfFreedom)
{
unsigned int i = 0 ;
this->TrajectoryIsPhaseSynchronized = false ;
this->NumberOfDOFs = DegreesOfFreedom ;
this->SynchronizationTime = 0.0 ;
this->ANewCalculationWasPerformed = false ;
this->DOFWithTheGreatestExecutionTime = 0 ;
this->ResultValue = -1 ;
this->OverrideFilterIsActive = false ;
this->CurrentOverrideValue = 1.0 ;
this->NewPositionVector = new RMLDoubleVector(DegreesOfFreedom) ;
this->NewVelocityVector = new RMLDoubleVector(DegreesOfFreedom) ;
this->NewAccelerationVector = new RMLDoubleVector(DegreesOfFreedom) ;
this->MinExtremaTimesVector = new RMLDoubleVector(DegreesOfFreedom) ;
this->MaxExtremaTimesVector = new RMLDoubleVector(DegreesOfFreedom) ;
this->MinPosExtremaPositionVectorOnly = new RMLDoubleVector(DegreesOfFreedom) ;
this->MaxPosExtremaPositionVectorOnly = new RMLDoubleVector(DegreesOfFreedom) ;
this->ExecutionTimes = new RMLDoubleVector(DegreesOfFreedom) ;
this->Polynomials = new RMLOutputPolynomials(DegreesOfFreedom) ;
memset(this->NewPositionVector->VecData , 0x0 , DegreesOfFreedom * sizeof(double)) ;
memset(this->NewVelocityVector->VecData , 0x0 , DegreesOfFreedom * sizeof(double)) ;
memset(this->NewAccelerationVector->VecData , 0x0 , DegreesOfFreedom * sizeof(double)) ;
memset(this->MinExtremaTimesVector->VecData , 0x0 , DegreesOfFreedom * sizeof(double)) ;
memset(this->MaxExtremaTimesVector->VecData , 0x0 , DegreesOfFreedom * sizeof(double)) ;
memset(this->MinPosExtremaPositionVectorOnly->VecData , 0x0 , DegreesOfFreedom * sizeof(double)) ;
memset(this->MaxPosExtremaPositionVectorOnly->VecData , 0x0 , DegreesOfFreedom * sizeof(double)) ;
memset(this->ExecutionTimes->VecData , 0x0 , DegreesOfFreedom * sizeof(double)) ;
this->MinPosExtremaPositionVectorArray = new RMLDoubleVector*[DegreesOfFreedom] ;
this->MinPosExtremaVelocityVectorArray = new RMLDoubleVector*[DegreesOfFreedom] ;
this->MinPosExtremaAccelerationVectorArray = new RMLDoubleVector*[DegreesOfFreedom] ;
this->MaxPosExtremaPositionVectorArray = new RMLDoubleVector*[DegreesOfFreedom] ;
this->MaxPosExtremaVelocityVectorArray = new RMLDoubleVector*[DegreesOfFreedom] ;
this->MaxPosExtremaAccelerationVectorArray = new RMLDoubleVector*[DegreesOfFreedom] ;
for (i = 0; i < DegreesOfFreedom; i++)
{
(this->MinPosExtremaPositionVectorArray) [i] = new RMLDoubleVector(DegreesOfFreedom);
(this->MinPosExtremaVelocityVectorArray) [i] = new RMLDoubleVector(DegreesOfFreedom);
(this->MinPosExtremaAccelerationVectorArray) [i] = new RMLDoubleVector(DegreesOfFreedom);
(this->MaxPosExtremaPositionVectorArray) [i] = new RMLDoubleVector(DegreesOfFreedom);
(this->MaxPosExtremaVelocityVectorArray) [i] = new RMLDoubleVector(DegreesOfFreedom);
(this->MaxPosExtremaAccelerationVectorArray) [i] = new RMLDoubleVector(DegreesOfFreedom);
memset(((this->MinPosExtremaPositionVectorArray) [i])->VecData , 0x0 , DegreesOfFreedom * sizeof(double)) ;
memset(((this->MinPosExtremaVelocityVectorArray) [i])->VecData , 0x0 , DegreesOfFreedom * sizeof(double)) ;
memset(((this->MinPosExtremaAccelerationVectorArray) [i])->VecData , 0x0 , DegreesOfFreedom * sizeof(double)) ;
memset(((this->MaxPosExtremaPositionVectorArray) [i])->VecData , 0x0 , DegreesOfFreedom * sizeof(double)) ;
memset(((this->MaxPosExtremaVelocityVectorArray) [i])->VecData , 0x0 , DegreesOfFreedom * sizeof(double)) ;
memset(((this->MaxPosExtremaAccelerationVectorArray) [i])->VecData , 0x0 , DegreesOfFreedom * sizeof(double)) ;
}
}
// ---------------------- Doxygen info ----------------------
//! \fn RMLOutputParameters(const RMLOutputParameters &OP)
//!
//! \brief
//! Copy constructor of class RMLPositionOutputParameters
//!
//! \warning
//! The constructor is \b not real-time capable as heap memory has to be
//! allocated.
//!
//! \param OP
//! Object to be copied
//!
//! \note
//! This is only the base class for the classes\n\n
//! <ul>
//! <li>RMLPositionOutputParameters and</li>
//! <li>RMLVelocityOutputParameters,\n\n</li>
//! </ul>
//! such that the constructor is declared \c protected.
// ----------------------------------------------------------
RMLOutputParameters(const RMLOutputParameters &OP)
{
unsigned int i = 0 ;
this->NewPositionVector = new RMLDoubleVector(OP.NumberOfDOFs) ;
this->NewVelocityVector = new RMLDoubleVector(OP.NumberOfDOFs) ;
this->NewAccelerationVector = new RMLDoubleVector(OP.NumberOfDOFs) ;
this->MinExtremaTimesVector = new RMLDoubleVector(OP.NumberOfDOFs) ;
this->MaxExtremaTimesVector = new RMLDoubleVector(OP.NumberOfDOFs) ;
this->MinPosExtremaPositionVectorOnly = new RMLDoubleVector(OP.NumberOfDOFs) ;
this->MaxPosExtremaPositionVectorOnly = new RMLDoubleVector(OP.NumberOfDOFs) ;
this->ExecutionTimes = new RMLDoubleVector(OP.NumberOfDOFs) ;
this->Polynomials = new RMLOutputPolynomials(OP.NumberOfDOFs) ;
this->MinPosExtremaPositionVectorArray = new RMLDoubleVector *[OP.NumberOfDOFs] ;
this->MinPosExtremaVelocityVectorArray = new RMLDoubleVector *[OP.NumberOfDOFs] ;
this->MinPosExtremaAccelerationVectorArray = new RMLDoubleVector *[OP.NumberOfDOFs] ;
this->MaxPosExtremaPositionVectorArray = new RMLDoubleVector *[OP.NumberOfDOFs] ;
this->MaxPosExtremaVelocityVectorArray = new RMLDoubleVector *[OP.NumberOfDOFs] ;
this->MaxPosExtremaAccelerationVectorArray = new RMLDoubleVector *[OP.NumberOfDOFs] ;
for (i = 0; i < OP.NumberOfDOFs; i++)
{
(this->MinPosExtremaPositionVectorArray) [i] = new RMLDoubleVector(OP.NumberOfDOFs) ;
(this->MinPosExtremaVelocityVectorArray) [i] = new RMLDoubleVector(OP.NumberOfDOFs) ;
(this->MinPosExtremaAccelerationVectorArray) [i] = new RMLDoubleVector(OP.NumberOfDOFs) ;
(this->MaxPosExtremaPositionVectorArray) [i] = new RMLDoubleVector(OP.NumberOfDOFs) ;
(this->MaxPosExtremaVelocityVectorArray) [i] = new RMLDoubleVector(OP.NumberOfDOFs) ;
(this->MaxPosExtremaAccelerationVectorArray) [i] = new RMLDoubleVector(OP.NumberOfDOFs) ;
}
*this = OP ;
}
// ---------------------- Doxygen info ----------------------
//! \fn void Echo(FILE* FileHandler = stdout) const
//!
//! \brief
//! Prints the new state of motion of the output parameters to *FileHandler
//!
//! \param FileHandler
//! File handler for the output
//!
//! \warning
//! The usage of this method is \b not real-time capable.
// ----------------------------------------------------------
void Echo(FILE* FileHandler = stdout) const
{
unsigned int i = 0;
if (FileHandler == NULL)
{
return;
}
fprintf(FileHandler, "New position vector : ");
for (i = 0; i < this->NumberOfDOFs; i++)
{
fprintf(FileHandler, " %.20le ", this->NewPositionVector->VecData[i]);
}
fprintf(FileHandler, "\nNew velocity vector : ");
for (i = 0; i < this->NumberOfDOFs; i++)
{
fprintf(FileHandler, " %.20le ", this->NewVelocityVector->VecData[i]);
}
fprintf(FileHandler, "\nNew acceleration vector : ");
for (i = 0; i < this->NumberOfDOFs; i++)
{
fprintf(FileHandler, " %.20le ", this->NewAccelerationVector->VecData[i]);
}
fprintf(FileHandler, "\n");
return;
}
public:
// ---------------------- Doxygen info ----------------------
//! \fn ~RMLOutputParameters(void)
//!
//! \brief
//! Destructor of class RMLOutputParameters
// ----------------------------------------------------------
~RMLOutputParameters(void)
{
unsigned int i = 0;
for (i = 0; i < this->NumberOfDOFs; i++)
{
delete ((this->MinPosExtremaPositionVectorArray) [i]) ;
delete ((this->MinPosExtremaVelocityVectorArray) [i]) ;
delete ((this->MinPosExtremaAccelerationVectorArray) [i]) ;
delete ((this->MaxPosExtremaPositionVectorArray) [i]) ;
delete ((this->MaxPosExtremaVelocityVectorArray) [i]) ;
delete ((this->MaxPosExtremaAccelerationVectorArray) [i]) ;
}
delete this->NewPositionVector ;
delete this->NewVelocityVector ;
delete this->NewAccelerationVector ;
delete[] this->MinPosExtremaPositionVectorArray ;
delete[] this->MinPosExtremaVelocityVectorArray ;
delete[] this->MinPosExtremaAccelerationVectorArray ;
delete[] this->MaxPosExtremaPositionVectorArray ;
delete[] this->MaxPosExtremaVelocityVectorArray ;
delete[] this->MaxPosExtremaAccelerationVectorArray ;
delete this->MinExtremaTimesVector ;
delete this->MaxExtremaTimesVector ;
delete this->MinPosExtremaPositionVectorOnly ;
delete this->MaxPosExtremaPositionVectorOnly ;
delete this->ExecutionTimes ;
delete this->Polynomials ;
this->NewPositionVector = NULL ;
this->NewVelocityVector = NULL ;
this->NewAccelerationVector = NULL ;
this->MinPosExtremaPositionVectorArray = NULL ;
this->MinPosExtremaVelocityVectorArray = NULL ;
this->MinPosExtremaAccelerationVectorArray = NULL ;
this->MaxPosExtremaPositionVectorArray = NULL ;
this->MaxPosExtremaVelocityVectorArray = NULL ;
this->MaxPosExtremaAccelerationVectorArray = NULL ;
this->MinExtremaTimesVector = NULL ;
this->MaxExtremaTimesVector = NULL ;
this->MinPosExtremaPositionVectorOnly = NULL ;
this->MaxPosExtremaPositionVectorOnly = NULL ;
this->ExecutionTimes = NULL ;
this->Polynomials = NULL ;
this->NumberOfDOFs = 0 ;
}
// ---------------------- Doxygen info ----------------------
//! \fn RMLOutputParameters &operator = (const RMLOutputParameters &OP)
//!
//! \brief
//! Copy operator
//!
//! \param OP
//! RMLOutputParameters object to be copied
//!
//! \return
//! The duplicated object
// ----------------------------------------------------------
RMLOutputParameters &operator = (const RMLOutputParameters &OP)
{
unsigned int i = 0 ;
this->NumberOfDOFs = OP.NumberOfDOFs ;
this->TrajectoryIsPhaseSynchronized = OP.TrajectoryIsPhaseSynchronized ;
this->ANewCalculationWasPerformed = OP.ANewCalculationWasPerformed ;
this->ResultValue = OP.ResultValue ;
this->OverrideFilterIsActive = OP.OverrideFilterIsActive ;
this->SynchronizationTime = OP.SynchronizationTime ;
this->DOFWithTheGreatestExecutionTime = OP.DOFWithTheGreatestExecutionTime ;
this->CurrentOverrideValue = OP.CurrentOverrideValue ;
*(this->NewPositionVector) = *(OP.NewPositionVector) ;
*(this->NewVelocityVector) = *(OP.NewVelocityVector) ;
*(this->NewAccelerationVector) = *(OP.NewAccelerationVector) ;
*(this->MinExtremaTimesVector) = *(OP.MinExtremaTimesVector) ;
*(this->MaxExtremaTimesVector) = *(OP.MaxExtremaTimesVector) ;
*(this->ExecutionTimes) = *(OP.ExecutionTimes) ;
*(this->MinPosExtremaPositionVectorOnly) = *(OP.MinPosExtremaPositionVectorOnly) ;
*(this->MaxPosExtremaPositionVectorOnly) = *(OP.MaxPosExtremaPositionVectorOnly) ;
for (i = 0; i < this->NumberOfDOFs; i++)
{
OP.GetMotionStateAtMinPosForOneDOF( i
, (this->MinPosExtremaPositionVectorArray)[i]
, (this->MinPosExtremaVelocityVectorArray)[i]
, (this->MinPosExtremaAccelerationVectorArray)[i]);
OP.GetMotionStateAtMaxPosForOneDOF( i
, (this->MaxPosExtremaPositionVectorArray)[i]
, (this->MaxPosExtremaVelocityVectorArray)[i]
, (this->MaxPosExtremaAccelerationVectorArray)[i]);
}
*(this->Polynomials) = *(OP.Polynomials);
return(*this);
}
// ---------------------- Doxygen info ----------------------
//! \fn inline void GetNewPositionVector(RMLDoubleVector *OutputVector) const
//!
//! \brief
//! Copies the contents of the \c RMLDoubleVector object containing the
//! new position vector \f$ \vec{P}_{i+1} \f$ to the \c RMLDoubleVector
//! object referred to by \c OutputVector
//!
//! \param OutputVector
//! A pointer to an \c RMLDoubleVector object, to which the data will be
//! copied
//!
//! \sa GetNewPositionVector(double *OutputVector, const unsigned int &SizeInBytes) const
//! \sa GetNewPositionVectorElement(double *OutputValue, const unsigned int &Index) const
// ----------------------------------------------------------
inline void GetNewPositionVector(RMLDoubleVector *OutputVector) const
{
*OutputVector = *(this->NewPositionVector);
}
// ---------------------- Doxygen info ----------------------
//! \fn inline void GetNewPositionVector(double *OutputVector, const unsigned int &SizeInBytes) const
//!
//! \brief
//! Copies the array of \c double values representing the new
//! position vector \f$ \vec{P}_{i+1} \f$ to the memory pointed to by
//! \c OutputVector
//!
//! \param OutputVector
//! A pointer to an array of \c double values, to which the data will be
//! copied
//!
//! \param SizeInBytes
//! The size of available memory at the location pointed to by
//! \c OutputVector. To assure safety and to prevent from prohibited writing
//! into protected memory areas, the user has to specify the amount
//! of available memory in bytes. For a correct operation, the value of
//! \c SizeInBytes has to equal the number of vector elements multiplied
//! by the size of a \c double value.
//!
//! \sa GetNewPositionVector(RMLDoubleVector *OutputVector) const
//! \sa GetNewPositionVectorElement(double *OutputValue, const unsigned int &Index) const
// ----------------------------------------------------------
inline void GetNewPositionVector( double *OutputVector
, const unsigned int &SizeInBytes) const
{
memcpy( (void*)OutputVector
, (void*)this->NewPositionVector->VecData
, SizeInBytes );
}
// ---------------------- Doxygen info ----------------------
//! \fn inline void GetNewPositionVectorElement(double *OutputValue, const unsigned int &Index) const
//!
//! \brief
//! Copies one element of the new selection vector
//! \f$ \vec{P}_{i+1} \f$ to the memory pointed to by \c OutputValue
//!
//! \param OutputValue
//! A pointer to one \c double value, to which the desired vector element
//! will be copied
//!
//! \param Index
//! Specifies the desired element of the vector. The element numbering
//! starts with \em 0 (zero). If this value is greater the number
//! of vector elements, a value of \em 0.0 will be written to the memory
//! pointed to by \c OutputValue.
//!
//! \sa GetNewPositionVector(RMLDoubleVector *OutputVector) const
//! \sa GetNewPositionVectorElement(double *OutputValue, const unsigned int &Index) const
//! \sa GetNewPositionVectorElement(const unsigned int &Index) const
// ----------------------------------------------------------
inline void GetNewPositionVectorElement( double *OutputValue
, const unsigned int &Index) const
{
if ( ( Index + 1 ) > ((unsigned int) this->NewPositionVector->GetVecDim() ) )
{
*OutputValue = 0.0;
}
else
{
*OutputValue = (*this->NewPositionVector)[Index];
}
}
// ---------------------- Doxygen info ----------------------
//! \fn inline double GetNewPositionVectorElement(const unsigned int &Index) const
//!
//! \brief
//! Returns one single element of the new selection vector
//! \f$ \vec{P}_{i+1} \f$
//!
//! \param Index
//! Specifies the desired element of the vector. The index of the first
//! vector element is \em 0 (zero). If the value of \c Index value is
//! greater the number of vector elements, a value of \em 0.0 will be
//! written to the memory pointed to by \c OutputValue.
//!
//! \sa GetNewPositionVectorElement(double *OutputValue, const unsigned int &Index) const
// ----------------------------------------------------------
inline double GetNewPositionVectorElement(const unsigned int &Index) const
{
if ( ( Index + 1 ) > ((unsigned int) this->NewPositionVector->GetVecDim() ) )
{
return(0.0);
}
else
{
return( (*this->NewPositionVector)[Index] );
}
}
// #############################################################################
// ---------------------- Doxygen info ----------------------
//! \fn inline void GetNewVelocityVector(RMLDoubleVector *OutputVector) const
//!
//! \brief
//! Copies the contents of the \c RMLDoubleVector object containing the
//! new velocity vector \f$ \vec{V}_{i+1} \f$ to the \c RMLDoubleVector
//! object referred to by \c OutputVector
//!
//! \param OutputVector
//! A pointer to an \c RMLDoubleVector object, to which the data will be
//! copied
//!
//! \sa GetNewVelocityVector(double *OutputVector, const unsigned int &SizeInBytes) const
//! \sa GetNewVelocityVectorElement(double *OutputValue, const unsigned int &Index) const
// ----------------------------------------------------------
inline void GetNewVelocityVector(RMLDoubleVector *OutputVector) const
{
*OutputVector = *(this->NewVelocityVector);
}
// ---------------------- Doxygen info ----------------------
//! \fn inline void GetNewVelocityVector(double *OutputVector, const unsigned int &SizeInBytes) const
//!
//! \brief
//! Copies the array of \c double values representing the new
//! velocity vector \f$ \vec{V}_{i+1} \f$ to the memory pointed to by
//! \c OutputVector
//!
//! \param OutputVector
//! A pointer to an array of \c double values, to which the data will be
//! copied
//!
//! \param SizeInBytes
//! The size of available memory at the location pointed to by
//! \c OutputVector. To assure safety and to prevent from prohibited writing
//! into protected memory areas, the user has to specify the amount
//! of available memory in bytes. For a correct operation, the value of
//! \c SizeInBytes has to equal the number of vector elements multiplied
//! by the size of a \c double value.
//!
//! \sa GetNewVelocityVector(RMLDoubleVector *OutputVector) const
//! \sa GetNewVelocityVectorElement(double *OutputValue, const unsigned int &Index) const
// ----------------------------------------------------------
inline void GetNewVelocityVector( double *OutputVector
, const unsigned int &SizeInBytes) const
{
memcpy( (void*)OutputVector
, (void*)this->NewVelocityVector->VecData
, SizeInBytes );
}
// ---------------------- Doxygen info ----------------------
//! \fn inline void GetNewVelocityVectorElement(double *OutputValue, const unsigned int &Index) const
//!
//! \brief
//! Copies one element of the new selection vector
//! \f$ \vec{V}_{i+1} \f$ to the memory pointed to by \c OutputValue
//!
//! \param OutputValue
//! A pointer to one \c double value, to which the desired vector element
//! will be copied
//!
//! \param Index
//! Specifies the desired element of the vector. The element numbering
//! starts with \em 0 (zero). If this value is greater the number
//! of vector elements, a value of \em 0.0 will be written to the memory
//! pointed to by \c OutputValue.
//!
//! \sa GetNewVelocityVector(RMLDoubleVector *OutputVector) const
//! \sa GetNewVelocityVectorElement(double *OutputValue, const unsigned int &Index) const
//! \sa GetNewVelocityVectorElement(const unsigned int &Index) const
// ----------------------------------------------------------
inline void GetNewVelocityVectorElement( double *OutputValue
, const unsigned int &Index) const
{
if ( ( Index + 1 ) > ((unsigned int) this->NewVelocityVector->GetVecDim() ) )
{
*OutputValue = 0.0;
}
else
{
*OutputValue = (*this->NewVelocityVector)[Index];
}
}
// ---------------------- Doxygen info ----------------------
//! \fn inline double GetNewVelocityVectorElement(const unsigned int &Index) const
//!
//! \brief
//! Returns one single element of the new selection vector
//! \f$ \vec{V}_{i+1} \f$
//!
//! \param Index
//! Specifies the desired element of the vector. The index of the first
//! vector element is \em 0 (zero). If the value of \c Index value is
//! greater the number of vector elements, a value of \em 0.0 will be
//! written to the memory pointed to by \c OutputValue.
//!
//! \sa GetNewVelocityVectorElement(double *OutputValue, const unsigned int &Index) const
// ----------------------------------------------------------
inline double GetNewVelocityVectorElement(const unsigned int &Index) const
{
if ( ( Index + 1 ) > ((unsigned int) this->NewVelocityVector->GetVecDim() ) )
{
return(0.0);
}
else
{
return( (*this->NewVelocityVector)[Index] );
}
}
// #############################################################################
// ---------------------- Doxygen info ----------------------
//! \fn inline void GetNewAccelerationVector(RMLDoubleVector *OutputVector) const
//!
//! \brief
//! Copies the contents of the \c RMLDoubleVector object containing the
//! new acceleration vector \f$ \vec{A}_{i+1} \f$ to the \c RMLDoubleVector
//! object referred to by \c OutputVector
//!
//! \param OutputVector
//! A pointer to an \c RMLDoubleVector object, to which the data will be
//! copied
//!
//! \sa GetNewAccelerationVector(double *OutputVector, const unsigned int &SizeInBytes) const
//! \sa GetNewAccelerationVectorElement(double *OutputValue, const unsigned int &Index) const
// ----------------------------------------------------------
inline void GetNewAccelerationVector(RMLDoubleVector *OutputVector) const
{
*OutputVector = *(this->NewAccelerationVector);
}
// ---------------------- Doxygen info ----------------------
//! \fn inline void GetNewAccelerationVector(double *OutputVector, const unsigned int &SizeInBytes) const
//!
//! \brief
//! Copies the array of \c double values representing the new
//! acceleration vector \f$ \vec{A}_{i+1} \f$ to the memory pointed to by
//! \c OutputVector
//!
//! \param OutputVector
//! A pointer to an array of \c double values, to which the data will be
//! copied
//!
//! \param SizeInBytes
//! The size of available memory at the location pointed to by
//! \c OutputVector. To assure safety and to prevent from prohibited writing
//! into protected memory areas, the user has to specify the amount
//! of available memory in bytes. For a correct operation, the value of
//! \c SizeInBytes has to equal the number of vector elements multiplied
//! by the size of a \c double value.
//!
//! \sa GetNewAccelerationVector(RMLDoubleVector *OutputVector) const
//! \sa GetNewAccelerationVectorElement(double *OutputValue, const unsigned int &Index) const
// ----------------------------------------------------------
inline void GetNewAccelerationVector( double *OutputVector
, const unsigned int &SizeInBytes) const
{
memcpy( (void*)OutputVector
, (void*)this->NewAccelerationVector->VecData
, SizeInBytes );
}
// ---------------------- Doxygen info ----------------------
//! \fn inline void GetNewAccelerationVectorElement(double *OutputValue, const unsigned int &Index) const
//!
//! \brief
//! Copies one element of the new selection vector
//! \f$ \vec{A}_{i+1} \f$ to the memory pointed to by \c OutputValue
//!
//! \param OutputValue
//! A pointer to one \c double value, to which the desired vector element
//! will be copied
//!
//! \param Index
//! Specifies the desired element of the vector. The element numbering
//! starts with \em 0 (zero). If this value is greater the number
//! of vector elements, a value of \em 0.0 will be written to the memory
//! pointed to by \c OutputValue.
//!
//! \sa GetNewAccelerationVector(RMLDoubleVector *OutputVector) const
//! \sa GetNewAccelerationVectorElement(double *OutputValue, const unsigned int &Index) const
//! \sa GetNewAccelerationVectorElement(const unsigned int &Index) const
// ----------------------------------------------------------
inline void GetNewAccelerationVectorElement( double *OutputValue
, const unsigned int &Index) const
{
if ( ( Index + 1 ) > ((unsigned int) this->NewAccelerationVector->GetVecDim() ) )
{
*OutputValue = 0.0;
}
else
{
*OutputValue = (*this->NewAccelerationVector)[Index];
}
}
// ---------------------- Doxygen info ----------------------
//! \fn inline double GetNewAccelerationVectorElement(const unsigned int &Index) const
//!
//! \brief
//! Returns one single element of the new selection vector
//! \f$ \vec{A}_{i+1} \f$
//!
//! \param Index
//! Specifies the desired element of the vector. The index of the first
//! vector element is \em 0 (zero). If the value of \c Index value is
//! greater the number of vector elements, a value of \em 0.0 will be
//! written to the memory pointed to by \c OutputValue.
//!
//! \sa GetNewAccelerationVectorElement(double *OutputValue, const unsigned int &Index) const
// ----------------------------------------------------------
inline double GetNewAccelerationVectorElement(const unsigned int &Index) const
{
if ( ( Index + 1 ) > ((unsigned int) this->NewAccelerationVector->GetVecDim() ) )
{
return(0.0);
}
else
{
return( (*this->NewAccelerationVector)[Index] );
}
}
// ---------------------- Doxygen info ----------------------
//! \fn inline void GetPositionalExtrema(RMLDoubleVector *MinimumPositionVector, RMLDoubleVector *MaximumPositionVector) const
//!
//! \brief
//! Copies two \c RMLDoubleVector objects that contain the minimum and
//! maximum positions, which are reached until the target state of motion
//! is reached.
//!
//! \param MinimumPositionVector
//! A pointer to an \c RMLDoubleVector object, to which the vector of
//! minimum positions will be copied to.
//!
//! \param MaximumPositionVector
//! A pointer to an \c RMLDoubleVector object, to which the vector of
//! maximum positions will be copied to.
//!
//! \sa GetPositionalExtrema(double *MinimumPositionVector, double *MaximumPositionVector, const unsigned int &SizeInBytes) const
//! \sa RMLVector
//! \sa RMLDoubleVector
// ----------------------------------------------------------
inline void GetPositionalExtrema( RMLDoubleVector *MinimumPositionVector
, RMLDoubleVector *MaximumPositionVector) const
{
*MinimumPositionVector = *(this->MinPosExtremaPositionVectorOnly);
*MaximumPositionVector = *(this->MaxPosExtremaPositionVectorOnly);
}
// ---------------------- Doxygen info ----------------------
//! \fn inline void GetPositionalExtrema(double *MinimumPositionVector, double *MaximumPositionVector, const unsigned int &SizeInBytes) const
//!
//! \brief
//! Copies two \c RMLDoubleVector objects that contain the minimum and
//! maximum positions, which are reached until the target state of motion
//! is reached.
//!
//! \param MinimumPositionVector
//! A pointer to a \c double array, to which the elements of the vector of
//! minimum positions will be copied to.
//!
//! \param MaximumPositionVector
//! A pointer to a \c double array, to which the elements of the vector of
//! maximum positions will be copied to.
//!
//! \param SizeInBytes
//! The size of available memory at the location pointed to by
//! \c MinimumPositionVector or MaximumPositionVector, respectively.
//! To assure safety and to prevent from prohibited writing
//! into protected memory areas, the user has to specify the amount
//! of available memory in bytes. For a correct operation, the value of
//! \c SizeInBytes has to equal the number of vector elements multiplied
//! by the size of a \c double value.
//!
//! \sa GetPositionalExtrema(RMLDoubleVector *MinimumPositionVector, RMLDoubleVector *MaximumPositionVector) const
// ----------------------------------------------------------
inline void GetPositionalExtrema( double *MinimumPositionVector
, double *MaximumPositionVector
, const unsigned int &SizeInBytes) const
{
memcpy( (void*)MinimumPositionVector
, (void*)(this->MinPosExtremaPositionVectorOnly->VecData)
, SizeInBytes );
memcpy( (void*)MaximumPositionVector
, (void*)(this->MaxPosExtremaPositionVectorOnly->VecData)
, SizeInBytes );
}
// ---------------------- Doxygen info ----------------------
//! \fn inline void GetTimesAtMinPosition(RMLDoubleVector *ExtremaTimes) const
//!
//! \brief
//! Copies the contents of a \c RMLDoubleVector object that contains the
//! times (in seconds) at which the minimum positions are reached to the
//! \c RMLDoubleVector object referred to by \c ExtremaTimes
//!
//! \param ExtremaTimes
//! A pointer to an \c RMLDoubleVector object, to which the data will be
//! copied
//!
//! \sa GetTimesAtMaxPosition(RMLDoubleVector *ExtremaTimes) const
//! \sa GetPositionalExtrema(RMLDoubleVector *MinimumPositionVector, RMLDoubleVector *MaximumPositionVector) const
//! \sa GetPositionalExtrema(double *MinimumPositionVector, double *MaximumPositionVector, const unsigned int &SizeInBytes) const
//! \sa RMLDoubleVector
// ----------------------------------------------------------
inline void GetTimesAtMinPosition(RMLDoubleVector *ExtremaTimes) const
{
*ExtremaTimes = *(this->MinExtremaTimesVector);
}
// ---------------------- Doxygen info ----------------------
//! \fn inline void GetTimesAtMaxPosition(RMLDoubleVector *ExtremaTimes) const
//!
//! \brief
//! Copies the contents of a \c RMLDoubleVector object that contains the
//! times (in seconds) at which the maximum positions are reached to the
//! \c RMLDoubleVector object referred to by \c ExtremaTimes
//!
//! \param ExtremaTimes
//! A pointer to an \c RMLDoubleVector object, to which the data will be
//! copied
//!
//! \sa GetTimesAtMinPosition(RMLDoubleVector *ExtremaTimes) const
//! \sa GetPositionalExtrema(RMLDoubleVector *MinimumPositionVector, RMLDoubleVector *MaximumPositionVector) const
//! \sa GetPositionalExtrema(double *MinimumPositionVector, double *MaximumPositionVector, const unsigned int &SizeInBytes) const
//! \sa RMLDoubleVector
// ----------------------------------------------------------
inline void GetTimesAtMaxPosition(RMLDoubleVector *ExtremaTimes) const
{
*ExtremaTimes = *(this->MaxExtremaTimesVector);
}
// ---------------------- Doxygen info ----------------------
//! \fn inline void GetTimesAtMinPosition(double*ExtremaTimes, const unsigned int &SizeInBytes) const
//!
//! \brief
//! Copies the array of \c double values that contain the time values
//! (in seconds) at which the minimum positions are reached to the array
//! of \c double values referred to by \c ExtremaTimes
//!
//! \param ExtremaTimes
//! A pointer to an array of \c double values, to which the data will be
//! copied
//!
//! \param SizeInBytes
//! The size of available memory at the location pointed to by
//! \c ExtremaTimes. To assure safety and to prevent from prohibited writing
//! into protected memory areas, the user has to specify the amount
//! of available memory in bytes. For a correct operation, the value of
//! \c SizeInBytes has to equal the number of vector elements multiplied
//! by the size of a \c double value.
//!
//! \sa GetTimesAtMinPosition(RMLDoubleVector *ExtremaTimes) const
//! \sa GetTimesAtMaxPosition(double*ExtremaTimes, const unsigned int &SizeInBytes) const
// ----------------------------------------------------------
inline void GetTimesAtMinPosition( double *ExtremaTimes
, const unsigned int &SizeInBytes) const
{
memcpy( (void*)ExtremaTimes
, (void*)(this->MinExtremaTimesVector->VecData)
, SizeInBytes );
}
// ---------------------- Doxygen info ----------------------
//! \fn inline void GetTimesAtMaxPosition(double*ExtremaTimes, const unsigned int &SizeInBytes) const
//!
//! \brief
//! Copies the array of \c double values that contain the time values
//! (in seconds) at which the maximum positions are reached to the array
//! of \c double values referred to by \c ExtremaTimes
//!
//! \param ExtremaTimes
//! A pointer to an array of \c double values, to which the data will be
//! copied
//!
//! \param SizeInBytes
//! The size of available memory at the location pointed to by
//! \c ExtremaTimes. To assure safety and to prevent from prohibited writing
//! into protected memory areas, the user has to specify the amount
//! of available memory in bytes. For a correct operation, the value of
//! \c SizeInBytes has to equal the number of vector elements multiplied
//! by the size of a \c double value.
//!
//! \sa GetTimesAtMaxPosition(RMLDoubleVector *ExtremaTimes) const
//! \sa GetTimesAtMinPosition(double*ExtremaTimes, const unsigned int &SizeInBytes) const
// ----------------------------------------------------------
inline void GetTimesAtMaxPosition( double *ExtremaTimes
, const unsigned int &SizeInBytes) const
{
memcpy( (void*)ExtremaTimes
, (void*)(this->MaxExtremaTimesVector->VecData)
, SizeInBytes );
}
// ---------------------- Doxygen info ----------------------
//! \fn inline int GetMotionStateAtMinPosForOneDOF(const unsigned int &DOF, RMLDoubleVector *PositionVector, RMLDoubleVector *VelocityVector, RMLDoubleVector *AccelerationVector) const
//!
//! \brief
//! Copies the motion state, at which the position of the degree of freedom
//! with the index \c DOF has reached its minimum, to the three referred
//! \c RMLDoubleVector objects.
//!
//! \param DOF
//! The index of the degree of freedom, whose minimum position is regarded.
//! The motion state of the time instant, at which the minimum position
//! value of this degree of freedom is reached, will be copied to
//! \c PositionVector, \c VelocityVector, and \c AccelerationVector.
//!
//! \param PositionVector
//! A pointer to an \c RMLDoubleVector object, to which the position
//! vector at the instant, at which the minimum position for the degree of
//! freedom \c DOF is reached, will be copied.
//!
//! \param VelocityVector
//! A pointer to an \c RMLDoubleVector object, to which the velocity
//! vector at the instant, at which the minimum position for the degree of
//! freedom \c DOF is reached, will be copied.
//!
//! \param AccelerationVector
//! A pointer to an \c RMLDoubleVector object, to which the acceleration
//! vector at the instant, at which the minimum position for the degree of
//! freedom \c DOF is reached, will be copied.
//!
//! \return
//! - RMLOutputParameters::RETURN_ERROR, if the value of \c DOF is greater
//! than or equal to the number of degrees of freedom
//! - RMLOutputParameters::RETURN_SUCCESS, else
//!
//! \sa GetMotionStateAtMaxPosForOneDOF(const unsigned int &DOF, RMLDoubleVector *PositionVector, RMLDoubleVector *VelocityVector, RMLDoubleVector *AccelerationVector) const
//! \sa GetMotionStateAtMinPosForOneDOF(const unsigned int &DOF, double *PositionVector, double *VelocityVector, double *AccelerationVector, const unsigned int &SizeInBytes) const
//! \sa GetTimesAtMinPosition(RMLDoubleVector *ExtremaTimes) const
//! \sa GetPositionalExtrema(RMLDoubleVector *MinimumPositionVector, RMLDoubleVector *MaximumPositionVector) const
//! \sa RMLDoubleVector
// ----------------------------------------------------------
inline int GetMotionStateAtMinPosForOneDOF( const unsigned int &DOF
, RMLDoubleVector *PositionVector
, RMLDoubleVector *VelocityVector
, RMLDoubleVector *AccelerationVector) const
{
if (DOF >= this->NumberOfDOFs)
{
return(RMLOutputParameters::RETURN_ERROR);
}
*PositionVector = *((this->MinPosExtremaPositionVectorArray )[DOF]) ;
*VelocityVector = *((this->MinPosExtremaVelocityVectorArray )[DOF]) ;
*AccelerationVector = *((this->MinPosExtremaAccelerationVectorArray )[DOF]) ;
return(RMLOutputParameters::RETURN_SUCCESS);
}
// ---------------------- Doxygen info ----------------------
//! \fn inline int GetMotionStateAtMinPosForOneDOF(const unsigned int &DOF, double *PositionVector, double *VelocityVector, double *AccelerationVector, const unsigned int &SizeInBytes) const
//!
//! \brief
//! Copies the motion state, at which the position of the degree of freedom
//! with the index \c DOF has reached its minimum, to the three referred
//! arrays of \c double values.
//!
//! \param DOF
//! The index of the degree of freedom, whose minimum position is regarded.
//! The motion state of the time instant, at which the minimum position
//! value of this degree of freedom is reached, will be copied to
//! \c PositionVector, \c VelocityVector, and \c AccelerationVector.
//!
//! \param PositionVector
//! A pointer to an array of \c double values, to which the position
//! vector at the instant, at which the minimum position for the degree of
//! freedom \c DOF is reached, will be copied.
//!
//! \param VelocityVector
//! A pointer to an array of \c double values, to which the velocity
//! vector at the instant, at which the minimum position for the degree of
//! freedom \c DOF is reached, will be copied.
//!
//! \param AccelerationVector
//! A pointer to an array of \c double values, to which the acceleration
//! vector at the instant, at which the minimum position for the degree of
//! freedom \c DOF is reached, will be copied.
//!
//! \param SizeInBytes
//! The size of available memory at the each of the locations pointed to by
//! \c PositionVector, \c VelocityVector, and \c AccelerationVector.
//! To assure safety and to prevent from prohibited writing
//! into protected memory areas, the user has to specify the amount
//! of available memory in bytes. For a correct operation, the value of
//! \c SizeInBytes has to equal the number of vector elements multiplied
//! by the size of a \c double value.
//!
//! \return
//! - RMLOutputParameters::RETURN_ERROR, if the value of \c DOF is greater
//! than or equal to the number of degrees of freedom
//! - RMLOutputParameters::RETURN_SUCCESS, else
//!
//! \sa GetMotionStateAtMinPosForOneDOF(const unsigned int &DOF, RMLDoubleVector *PositionVector, RMLDoubleVector *VelocityVector, RMLDoubleVector *AccelerationVector) const
//! \sa GetMotionStateAtMaxPosForOneDOF(const unsigned int &DOF, double *PositionVector, double *VelocityVector, double *AccelerationVector, const unsigned int &SizeInBytes) const
//! \sa GetTimesAtMinPosition(RMLDoubleVector *ExtremaTimes) const
//! \sa GetPositionalExtrema(RMLDoubleVector *MinimumPositionVector, RMLDoubleVector *MaximumPositionVector) const
//! \sa RMLDoubleVector
// ----------------------------------------------------------
inline int GetMotionStateAtMinPosForOneDOF( const unsigned int &DOF
, double *PositionVector
, double *VelocityVector
, double *AccelerationVector
, const unsigned int &SizeInBytes) const
{
if (DOF >= this->NumberOfDOFs)
{
return(RMLOutputParameters::RETURN_ERROR);
}
memcpy( (void*)PositionVector
, (void*)(((this->MinPosExtremaPositionVectorArray)[DOF])->VecData)
, SizeInBytes );
memcpy( (void*)VelocityVector
, (void*)(((this->MinPosExtremaVelocityVectorArray)[DOF])->VecData)
, SizeInBytes );
memcpy( (void*)AccelerationVector
, (void*)(((this->MinPosExtremaAccelerationVectorArray)[DOF])->VecData)
, SizeInBytes );
return(RMLOutputParameters::RETURN_SUCCESS);
}
// ---------------------- Doxygen info ----------------------
//! \fn inline int GetMotionStateAtMaxPosForOneDOF(const unsigned int &DOF, RMLDoubleVector *PositionVector, RMLDoubleVector *VelocityVector, RMLDoubleVector *AccelerationVector) const
//!
//! \brief
//! Copies the motion state, at which the position of the degree of freedom
//! with the index \c DOF has reached its maximum, to the three referred
//! \c RMLDoubleVector objects.
//!
//! \param DOF
//! The index of the degree of freedom, whose maximum position is regarded.
//! The motion state of the time instant, at which the maximum position
//! value of this degree of freedom is reached, will be copied to
//! \c PositionVector, \c VelocityVector, and \c AccelerationVector.
//!
//! \param PositionVector
//! A pointer to an \c RMLDoubleVector object, to which the position
//! vector at the instant, at which the maximum position for the degree of
//! freedom \c DOF is reached, will be copied.
//!
//! \param VelocityVector
//! A pointer to an \c RMLDoubleVector object, to which the velocity
//! vector at the instant, at which the maximum position for the degree of
//! freedom \c DOF is reached, will be copied.
//!
//! \param AccelerationVector
//! A pointer to an \c RMLDoubleVector object, to which the acceleration
//! vector at the instant, at which the maximum position for the degree of
//! freedom \c DOF is reached, will be copied.
//!
//! \return
//! - RMLOutputParameters::RETURN_ERROR, if the value of \c DOF is greater
//! than or equal to the number of degrees of freedom
//! - RMLOutputParameters::RETURN_SUCCESS, else
//!
//! \sa GetMotionStateAtMinPosForOneDOF(const unsigned int &DOF, RMLDoubleVector *PositionVector, RMLDoubleVector *VelocityVector, RMLDoubleVector *AccelerationVector) const
//! \sa GetMotionStateAtMaxPosForOneDOF(const unsigned int &DOF, double *PositionVector, double *VelocityVector, double *AccelerationVector, const unsigned int &SizeInBytes) const
//! \sa GetTimesAtMaxPosition(RMLDoubleVector *ExtremaTimes) const
//! \sa GetPositionalExtrema(RMLDoubleVector *MinimumPositionVector, RMLDoubleVector *MaximumPositionVector) const
//! \sa RMLDoubleVector
// ----------------------------------------------------------
inline int GetMotionStateAtMaxPosForOneDOF( const unsigned int &DOF
, RMLDoubleVector *PositionVector
, RMLDoubleVector *VelocityVector
, RMLDoubleVector *AccelerationVector) const
{
if (DOF >= this->NumberOfDOFs)
{
return(RMLOutputParameters::RETURN_ERROR);
}
*PositionVector = *((this->MaxPosExtremaPositionVectorArray )[DOF]) ;
*VelocityVector = *((this->MaxPosExtremaVelocityVectorArray )[DOF]) ;
*AccelerationVector = *((this->MaxPosExtremaAccelerationVectorArray )[DOF]) ;
return(RMLOutputParameters::RETURN_SUCCESS);
}
// ---------------------- Doxygen info ----------------------
//! \fn inline int GetMotionStateAtMaxPosForOneDOF(const unsigned int &DOF, double *PositionVector, double *VelocityVector, double *AccelerationVector, const unsigned int &SizeInBytes) const
//!
//! \brief
//! Copies the motion state, at which the position of the degree of freedom
//! with the index \c DOF has reached its maximum, to the three referred
//! arrays of \c double values.
//!
//! \param DOF
//! The index of the degree of freedom, whose maximum position is regarded.
//! The motion state of the time instant, at which the maximum position
//! value of this degree of freedom is reached, will be copied to
//! \c PositionVector, \c VelocityVector, and \c AccelerationVector.
//!
//! \param PositionVector
//! A pointer to an array of \c double values, to which the position
//! vector at the instant, at which the maximum position for the degree of
//! freedom \c DOF is reached, will be copied.
//!
//! \param VelocityVector
//! A pointer to an array of \c double values, to which the velocity
//! vector at the instant, at which the maximum position for the degree of
//! freedom \c DOF is reached, will be copied.
//!
//! \param AccelerationVector
//! A pointer to an array of \c double values, to which the acceleration
//! vector at the instant, at which the maximum position for the degree of
//! freedom \c DOF is reached, will be copied.
//!
//! \param SizeInBytes
//! The size of available memory at the each of the locations pointed to by
//! \c PositionVector, \c VelocityVector, and \c AccelerationVector.
//! To assure safety and to prevent from prohibited writing
//! into protected memory areas, the user has to specify the amount
//! of available memory in bytes. For a correct operation, the value of
//! \c SizeInBytes has to equal the number of vector elements multiplied
//! by the size of a \c double value.
//!
//! \return
//! - RMLOutputParameters::RETURN_ERROR, if the value of \c DOF is greater
//! than or equal to the number of degrees of freedom
//! - RMLOutputParameters::RETURN_SUCCESS, else
//!
//! \sa GetMotionStateAtMaxPosForOneDOF(const unsigned int &DOF, RMLDoubleVector *PositionVector, RMLDoubleVector *VelocityVector, RMLDoubleVector *AccelerationVector) const
//! \sa GetMotionStateAtMinPosForOneDOF(const unsigned int &DOF, double *PositionVector, double *VelocityVector, double *AccelerationVector, const unsigned int &SizeInBytes) const
//! \sa GetTimesAtMaxPosition(RMLDoubleVector *ExtremaTimes) const
//! \sa GetPositionalExtrema(RMLDoubleVector *MinimumPositionVector, RMLDoubleVector *MaximumPositionVector) const
//! \sa RMLDoubleVector
// ----------------------------------------------------------
inline int GetMotionStateAtMaxPosForOneDOF( const unsigned int &DOF
, double *PositionVector
, double *VelocityVector
, double *AccelerationVector
, const unsigned int &SizeInBytes) const
{
if (DOF >= this->NumberOfDOFs)
{
return(RMLOutputParameters::RETURN_ERROR);
}
memcpy( (void*)PositionVector
, (void*)(((this->MaxPosExtremaPositionVectorArray)[DOF])->VecData)
, SizeInBytes );
memcpy( (void*)VelocityVector
, (void*)(((this->MaxPosExtremaVelocityVectorArray)[DOF])->VecData)
, SizeInBytes );
memcpy( (void*)AccelerationVector
, (void*)(((this->MaxPosExtremaAccelerationVectorArray)[DOF])->VecData)
, SizeInBytes );
return(RMLOutputParameters::RETURN_SUCCESS);
}
// ---------------------- Doxygen info ----------------------
//! \fn inline unsigned int GetNumberOfDOFs(void) const
//!
//! \brief
//! Returns the number of degrees of freedom
//!
//! \return
//! The number of degrees of freedom.
// ----------------------------------------------------------
inline unsigned int GetNumberOfDOFs(void) const
{
return(this->NumberOfDOFs);
}
// ---------------------- Doxygen info ----------------------
//! \fn inline bool WasACompleteComputationPerformedDuringTheLastCycle(void) const
//!
//! \brief
//! Indicates, whether a new computation was performed in the last cycle
//!
//! \details
//! \copydetails RMLOutputParameters::ANewCalculationWasPerformed
//!
//! \returns
//! - \c true if a new computation was performed
//! - \c false if the previously calculated trajectory parameters did not
//! change and were used.
// ----------------------------------------------------------
inline bool WasACompleteComputationPerformedDuringTheLastCycle(void) const
{
return(this->ANewCalculationWasPerformed);
}
// ---------------------- Doxygen info ----------------------
//! \fn inline bool IsTrajectoryPhaseSynchronized(void) const
//!
//! \brief
//! Indicates whether the currently calculated trajectory is phase-
//! synchronized or only time-synchronized
//!
//! \return
//! The method returns \c true if the trajectory is phase-synchronized
//! and \c false if it is time-synchronized.
// ----------------------------------------------------------
inline bool IsTrajectoryPhaseSynchronized(void) const
{
return(this->TrajectoryIsPhaseSynchronized);
}
// ---------------------- Doxygen info ----------------------
//! \fn inline double GetSynchronizationTime(void) const
//!
//! \brief
//! Returns the synchronization time
//!
//! \details
//! The position-based Online Trajectory Generation algorithm transfers
//! all selected degrees of freedom into their desired target state of
//! motion, such that all of them reach the target state of motion
//! \f$_{k}\vec{M}_{i}^{\,trgt} \f$ at the very same time instant, that is,
//! at the minimum possible synchronization time \f$ t_{i}^{,sync} \f$.
//! If this value is used as an output value of the velocity-based
//! Online Trajectory Generation algorithm, this time determines when
//! all selected degree of freedom will reach the desired target velocity.
//!
//! \return
//! The value of the synchronization time in seconds
//!
//! \sa RMLOutputParameters::SynchronizationTime
// ----------------------------------------------------------
inline double GetSynchronizationTime(void) const
{
return(this->SynchronizationTime);
}
// ---------------------- Doxygen info ----------------------
//! \fn inline double GetCurrentOverrideValue(void) const
//!
//! \brief
//! Returns the currently applied override value
//!
//! \details
//! As the override value may not change abruptly, a filter is used to
//! soothly progress towards the desired override value
//! (cf. RMLInputParameters::OverrideValue). This output value
//! contains the currently applied override value.
//!
//! \return
//! The currently applied override value
//!
//! \sa RMLOutputParameters::CurrentOverrideValue
//! \sa RMLInputParameters::OverrideValue
//! \sa \ref page_Override
// ----------------------------------------------------------
inline double GetCurrentOverrideValue(void) const
{
return(this->CurrentOverrideValue);
}
// ---------------------- Doxygen info ----------------------
//! \fn inline bool IsTheOverrideFilterActive(void) const
//!
//! \brief
//! Returns true if the desired override value is not yet applied, because
//! the filter is still active
//!
//! \details
//! As the override value may not change abruptly, a filter is used to
//! soothly progress towards the desired override value
//! (cf. RMLInputParameters::OverrideValue). This output value
//! is true if the desired override values is not yet applied and the
//! override filter is still active.
//!
//! \return
//! - \c true if the override filter is active and the desired override value is not yet applied
//! - \c false if the override filter is not active anymore and the desired override value is already applied
//!
//! \sa RMLOutputParameters::OverrideFilterIsActive
//! \sa RMLInputParameters::OverrideValue
//! \sa \ref page_Override
// ----------------------------------------------------------
inline bool IsTheOverrideFilterActive(void) const
{
return(this->OverrideFilterIsActive);
}
// ---------------------- Doxygen info ----------------------
//! \fn inline unsigned int GetDOFWithTheGreatestExecutionTime(void) const
//!
//! \brief
//! Returns the index of the degree of freedom with the greatest trajectory
//! execution time
//!
//! \sa RMLOutputParameters::GetGreatestExecutionTime()
// ----------------------------------------------------------
inline unsigned int GetDOFWithTheGreatestExecutionTime(void) const
{
return(this->DOFWithTheGreatestExecutionTime);
}
// ---------------------- Doxygen info ----------------------
//! \fn inline void GetExecutionTimes(RMLDoubleVector *OutputVector) const
//!
//! \brief
//! Copies the contents of the \c RMLDoubleVector object containing the
//! execution times for each degree of freedom, at which the
//! desired target velocity \f$\ _{k}V_{i}^{\,trgt} \f$ is reached, to the
//! \c RMLDoubleVector object referred to by \c OutputVector
//!
//! \param OutputVector
//! A pointer to an \c RMLDoubleVector object, to which the data will be
//! copied
//!
//! \sa GetExecutionTimes(double *OutputVector, const unsigned int &SizeInBytes) const
//! \sa GetExecutionTimesElement(double *OutputValue, const unsigned int &Index) const
//! \sa RMLOutputParameters::ExecutionTimes
// ----------------------------------------------------------
inline void GetExecutionTimes(RMLDoubleVector *OutputVector) const
{
*OutputVector = *(this->ExecutionTimes);
}
// ---------------------- Doxygen info ----------------------
//! \fn inline void GetExecutionTimes(double *OutputVector, const unsigned int &SizeInBytes) const
//!
//! \brief
//! Copies the array of \c double values representing the execution times
//! for each degree of freedom, at which the desired target velocity
//! \f$\ _{k}V_{i}^{\,trgt} \f$ is reached, to the memory pointed to by
//! \c OutputVector
//!
//! \param OutputVector
//! A pointer to an array of \c double values, to which the data will be
//! copied
//!
//! \param SizeInBytes
//! The size of available memory at the location pointed to by
//! \c OutputVector. To assure safety and to prevent from prohibited writing
//! into protected memory areas, the user has to specify the amount
//! of available memory in bytes. For a correct operation, the value of
//! \c SizeInBytes has to equal the number of vector elements multiplied
//! by the size of a \c double value.
//!
//! \sa GetExecutionTimes(RMLDoubleVector *OutputVector) const
//! \sa GetExecutionTimesElement(double *OutputValue, const unsigned int &Index) const
//! \sa RMLOutputParameters::ExecutionTimes
// ----------------------------------------------------------
inline void GetExecutionTimes( double *OutputVector
, const unsigned int &SizeInBytes) const
{
memcpy( (void*)OutputVector
, (void*)this->ExecutionTimes->VecData
, SizeInBytes );
}
// ---------------------- Doxygen info ----------------------
//! \fn inline void GetExecutionTimesElement(double *OutputValue, const unsigned int &Index) const
//!
//! \brief
//! Copies one element of the execution times for each degree of freedom,
//! at which the desired target velocity \f$\ _{k}V_{i}^{\,trgt} \f$
//! is reached, to the memory pointed to by \c OutputValue
//!
//! \param OutputValue
//! A pointer to one \c double value, to which the desired vector element
//! will be copied
//!
//! \param Index
//! Specifies the desired element of the vector. The element numbering
//! starts with \em 0 (zero). If this value is greater the number
//! of vector elements, a value of \em 0.0 will be written to the memory
//! pointed to by \c OutputValue.
//!
//! \sa GetExecutionTimes(RMLDoubleVector *OutputVector) const
//! \sa GetExecutionTimesElement(double *OutputValue, const unsigned int &Index) const
//! \sa GetExecutionTimesElement(const unsigned int &Index) const
//! \sa RMLOutputParameters::ExecutionTimes
// ----------------------------------------------------------
inline void GetExecutionTimesElement( double *OutputValue
, const unsigned int &Index) const
{
if ( ( Index + 1 ) > ((unsigned int) this->ExecutionTimes->GetVecDim() ) )
{
*OutputValue = 0.0;
}
else
{
*OutputValue = (*this->ExecutionTimes)[Index];
}
}
// ---------------------- Doxygen info ----------------------
//! \fn inline double GetExecutionTimesElement(const unsigned int &Index) const
//!
//! \brief
//! Returns one single element of the execution times
//! for each degree of freedom, at which the desired target velocity
//! \f$\ _{k}V_{i}^{\,trgt} \f$ is reached
//!
//! \param Index
//! Specifies the desired element of the vector. The index of the first
//! vector element is \em 0 (zero). If the value of \c Index value is
//! greater the number of vector elements, a value of \em 0.0 will be
//! written to the memory pointed to by \c OutputValue.
//!
//! \sa GetExecutionTimesElement(double *OutputValue, const unsigned int &Index) const
//! \sa RMLOutputParameters::ExecutionTimes
// ----------------------------------------------------------
inline double GetExecutionTimesElement(const unsigned int &Index) const
{
if ( ( Index + 1 ) > ((unsigned int) this->ExecutionTimes->GetVecDim() ) )
{
return(0.0);
}
else
{
return( (*this->ExecutionTimes)[Index] );
}
}
// ---------------------- Doxygen info ----------------------
//! \fn inline double GetGreatestExecutionTime(void) const
//!
//! \brief
//! Returns the time value in seconds which is required by the degree
//! with the greatest execution to reach its desired target velocity
//!
//! \sa GetGreatestExecutionTime (void) const
// ----------------------------------------------------------
inline double GetGreatestExecutionTime(void) const
{
return((this->ExecutionTimes->VecData)[this->DOFWithTheGreatestExecutionTime]);
}
// ---------------------- Doxygen info ----------------------
//! \fn inline char* GetErrorString(void) const
//!
//! \brief
//! Creates a C-string containing an error message for the last call of
//! ReflexxesAPI::RMLPosition(), ReflexxesAPI::RMLVelocity(),
//! ReflexxesAPI::RMLPositionAtAGivenSampleTime(), or
//! ReflexxesAPI::RMLVelocityAtAGivenSampleTime()
//!
//! \details
//! A string is created that contains a description of the return value
//! of
//!
//! - ReflexxesAPI::RMLPosition(),
//! - ReflexxesAPI::RMLPositionAtAGivenSampleTime(),
//! - ReflexxesAPI::RMLVelocity(), or
//! - ReflexxesAPI::RMLVelocityAtAGivenSampleTime().
//!
//! Possible return values are are:
//! - ReflexxesAPI::RML_WORKING: \copydoc ReflexxesAPI::RML_WORKING
//! - ReflexxesAPI::RML_FINAL_STATE_REACHED: \copydoc ReflexxesAPI::RML_FINAL_STATE_REACHED
//! - ReflexxesAPI::RML_ERROR_INVALID_INPUT_VALUES: \copydoc ReflexxesAPI::RML_ERROR_INVALID_INPUT_VALUES
//! - ReflexxesAPI::RML_ERROR_EXECUTION_TIME_CALCULATION: \copydoc ReflexxesAPI::RML_ERROR_EXECUTION_TIME_CALCULATION
//! - ReflexxesAPI::RML_ERROR_SYNCHRONIZATION: \copydoc ReflexxesAPI::RML_ERROR_SYNCHRONIZATION
//! - ReflexxesAPI::RML_ERROR_NUMBER_OF_DOFS: \copydoc ReflexxesAPI::RML_ERROR_NUMBER_OF_DOFS
//! - ReflexxesAPI::RML_ERROR_NO_PHASE_SYNCHRONIZATION: \copydoc ReflexxesAPI::RML_ERROR_NO_PHASE_SYNCHRONIZATION
//! - ReflexxesAPI::RML_ERROR_NULL_POINTER: \copydoc ReflexxesAPI::RML_ERROR_NULL_POINTER
//! - ReflexxesAPI::RML_ERROR_EXECUTION_TIME_TOO_BIG: \copydoc ReflexxesAPI::RML_ERROR_EXECUTION_TIME_TOO_BIG
//! - ReflexxesAPI::RML_ERROR_USER_TIME_OUT_OF_RANGE: \copydoc ReflexxesAPI::RML_ERROR_USER_TIME_OUT_OF_RANGE
//! - ReflexxesAPI::RML_ERROR_POSITIONAL_LIMITS: \copydoc ReflexxesAPI::RML_ERROR_POSITIONAL_LIMITS
//! - ReflexxesAPI::RML_ERROR_OVERRIDE_OUT_OF_RANGE: \copydoc ReflexxesAPI::RML_ERROR_OVERRIDE_OUT_OF_RANGE
//!
//!\n\n
//!
//! \return
//! A pointer to a character array containing the error description.
//!
//! \sa RMLOutputParameters::ResultValue
//! \sa ReflexxesAPI::RMLResultValue
// ----------------------------------------------------------
inline char* GetErrorString(void) const
{
if (this == NULL) // this->ResultValue == -105
{
return((char*)"RML_ERROR_NULL_POINTER: One of the pointers to the input objects is NULL.");
}
switch (this->ResultValue)
{
case 0:
return((char*)"RML_WORKING: The Online Trajectory Generation algorithm is working; the final state of motion has not been reached yet.");
break;
case 1:
return((char*)"RML_FINAL_STATE_REACHED: The desired final state of motion has been reached.");
break;
case 2:
return((char*)"RML_NO_ERROR: No error.");
break;
case -100:
return((char*)"RML_ERROR_INVALID_INPUT_VALUES: The applied input values are invalid.");
break;
case -101:
return((char*)"RML_ERROR_EXECUTION_TIME_CALCULATION: An error occurred during the calculation of the synchronization time.");
break;
case -102:
return((char*)"RML_ERROR_SYNCHRONIZATION: An error occurred during the synchronization of the trajectory.");
break;
case -103:
return((char*)"RML_ERROR_NUMBER_OF_DOFS: The number of degree of freedom of th input parameters, the output parameters, and the Online Trajectory Generation algorithm do not match.");
break;
case -104:
return((char*)"RML_ERROR_NO_PHASE_SYNCHRONIZATION: The input flag RMLFlags::ONLY_PHASE_SYNCHRONIZATION is set, but a phase-synchronized trajectory cannot be executed.");
break;
case -106:
return((char*)"RML_ERROR_EXECUTION_TIME_TOO_BIG: The execution time of the computed trajectory is to big (>1e10 seconds).");
break;
case -107:
return((char*)"RML_ERROR_USER_TIME_OUT_OF_RANGE: The sample time for the previously computed trajectory is out of range.");
break;
case -108:
return((char*)"RML_ERROR_POSITIONAL_LIMITS: The computed trajectory will exceed the positional limits.");
break;
case -109:
return((char*)"RML_ERROR_OVERRIDE_OUT_OF_RANGE: The override value is out of range (0.0-10.0).");
break;
case -1:
default:
return((char*)"RML_ERROR: An unknown error has occurred.");
break;
}
}
// ---------------------- Doxygen info ----------------------
//! \var bool ANewCalculationWasPerformed
//!
//! \brief
//! Indicates, whether a new computation was performed in the last cycle
//!
//! \details
//! If the computation of completely new trajectory parameters
//! was performed, this flag will be set to \c true. If the input values
//! remained constant and the output parameters of the last computation
//! cycle were directly fed back to the input parameters, such that the
//! previously computed trajectory did not change, the flag will be set
//! to \c false.
//!
//! This attribute can be accessed directly or by using one of the
//! following methods:\n\n
//! - WasACompleteComputationPerformedDuringTheLastCycle(void) const\n\n
// ----------------------------------------------------------
bool ANewCalculationWasPerformed ;
// ---------------------- Doxygen info ----------------------
//! \var bool TrajectoryIsPhaseSynchronized
//!
//! \brief
//! Boolean flag that indicates whether the current trajectory is
//! phase-synchronized
//!
//! \details
//! This attribute can be accessed directly or by using one of the method
//! IsTrajectoryPhaseSynchronized().
// ----------------------------------------------------------
bool TrajectoryIsPhaseSynchronized ;
// ---------------------- Doxygen info ----------------------
//! \var bool OverrideFilterIsActive
//!
//! \brief
//! Boolean flag that indicates whether the desired override value of
//! RMLInputParameters::OverrideValue has been reached
//!
//! \details
//! This attribute is (\c true) if the value of
//! RMLInputParameters::OverrideValue has been reached, and is (\c false)
//! if the filter is still active.
//!
//! \sa RMLInputParameters::OverrideValue
//! \sa RMLOutputParameters::CurrentOverrideValue
//! \sa \ref page_InputValues
//! \sa \ref page_OutputValues
//! \sa \ref page_Override
// ----------------------------------------------------------
bool OverrideFilterIsActive ;
// ---------------------- Doxygen info ----------------------
//! \var unsigned int NumberOfDOFs
//!
//! \brief
//! The number of degrees of freedom \f$ K \f$
//!
//! \details
//! This attribute can be accessed directly or by using one of the method
//! RMLOutputParameters::GetNumberOfDOFs().
// ----------------------------------------------------------
unsigned int NumberOfDOFs ;
// ---------------------- Doxygen info ----------------------
//! \var unsigned int DOFWithTheGreatestExecutionTime
//!
//! \brief
//! Index of the degree of freedom that requires the greatest execution
//! time to reach its desired target velocity value
//!
//! \details
//! <ul>
//! <li>In case of non-synchronized trajectories, this integer value
//! specifies the index of the degree-of-freedom with the greatest
//! execution time.</li>
//! <li>In case of time- or phase-synchronized trajectories, this integer
//! value specifies the degree of freedom that determined the
//! synchronization time.</li>
//! <li>If more that one degree of freedom feature the (same)
//! execution time, the lowest index will be used.\n\n</li>
//! </ul>
//!
//! This attribute can be accessed directly or by using the method
//! GetDOFWithTheGreatestExecutionTime().
// ----------------------------------------------------------
unsigned int DOFWithTheGreatestExecutionTime ;
// ---------------------- Doxygen info ----------------------
//! \var unsigned int ResultValue
//!
//! \brief
//! The result value of the call of ReflexxesAPI::RMLPosition() or
//! ReflexxesAPI::RMLVelocity()
//!
//! \details
//! The return value of the last call of
//!
//! - ReflexxesAPI::RMLPosition(),
//! - ReflexxesAPI::RMLPositionAtAGivenSampleTime(),
//! - ReflexxesAPI::RMLVelocity(), or
//! - ReflexxesAPI::RMLVelocityAtAGivenSampleTime()
//!
//! is stored in this variable (cf. ReflexxesAPI::RMLResultValue).
//! The function RMLOutputParameters::GetErrorString() creates
//! an error message based on the return value.
//!
//! \sa ReflexxesAPI::RMLResultValue
//! \sa RMLOutputParameters::GetErrorString()
// ----------------------------------------------------------
int ResultValue ;
// ---------------------- Doxygen info ----------------------
//! \var double SynchronizationTime
//!
//! \brief
//! The synchronization time \f$ t_{i}^{\,sync} \f$ in seconds
//!
//! \details
//! If the trajectory is time- or phase-synchronized, this attribute
//! will contain the synchronization time. Otherwise, it is set to zero.
//!
//! This attribute can be accessed directly or by using the method
//! GetSynchronizationTime().
// ----------------------------------------------------------
double SynchronizationTime ;
// ---------------------- Doxygen info ----------------------
//! \var double CurrentOverrideValue
//!
//! \brief
//! The currently applied override value
//!
//! \details
//! The applied override value is not allowed to change abruptly, and a
//! filter is applied to guarantee smooth transitions for the applied
//! value. The desired value can be found in
//! RMLInputParameters::OverrideValue.
//!
//! It can be accessed with the method GetCurrentOverrideValue().
//!
//! \sa RMLInputParameters::OverrideValue
//! \sa RMLOutputParameters::OverrideFilterIsActive
//! \sa RMLOutputParameters::GetCurrentOverrideValue()
//! \sa \ref page_InputValues
//! \sa \ref page_OutputValues
//! \sa \ref page_Override
// ----------------------------------------------------------
double CurrentOverrideValue ;
// ---------------------- Doxygen info ----------------------
//! \var RMLDoubleVector *NewPositionVector
//!
//! \brief
//! A pointer to the new position vector \f$ \vec{P}_{i+1} \f$
//!
//! \details
//! This attribute can be accessed directly or by using one of the following methods:\n\n
//! - GetNewPositionVector(RMLDoubleVector *OutputVector) const\n\n
//! - GetNewPositionVector(double *OutputVector, const unsigned int &SizeInBytes) const\n\n
//! - GetNewPositionVectorElement(double *OutputValue, const unsigned int &Index) const\n\n
//! - GetNewPositionVectorElement(const unsigned int &Index) const\n\n
// ----------------------------------------------------------
RMLDoubleVector *NewPositionVector ;
// ---------------------- Doxygen info ----------------------
//! \var RMLDoubleVector *NewVelocityVector
//!
//! \brief
//! A pointer to the new velocity vector \f$ \vec{V}_{i+1} \f$
//!
//! \details
//! This attribute can be accessed directly or by using one of the following methods:\n\n
//! - GetNewVelocityVector(RMLDoubleVector *OutputVector) const\n\n
//! - GetNewVelocityVector(double *OutputVector, const unsigned int &SizeInBytes) const\n\n
//! - GetNewVelocityVectorElement(double *OutputValue, const unsigned int &Index) const\n\n
//! - GetNewVelocityVectorElement(const unsigned int &Index) const\n\n
// ----------------------------------------------------------
RMLDoubleVector *NewVelocityVector ;
// ---------------------- Doxygen info ----------------------
//! \var RMLDoubleVector *NewAccelerationVector
//!
//! \brief
//! A pointer to the new acceleration vector \f$ \vec{A}_{i+1} \f$
//!
//! \details
//! This attribute can be accessed directly or by using one of the following methods:\n\n
//! - GetNewAccelerationVector(RMLDoubleVector *OutputVector) const\n\n
//! - GetNewAccelerationVector(double *OutputVector, const unsigned int &SizeInBytes) const\n\n
//! - GetNewAccelerationVectorElement(double *OutputValue, const unsigned int &Index) const\n\n
//! - GetNewAccelerationVectorElement(const unsigned int &Index) const\n\n
// ----------------------------------------------------------
RMLDoubleVector *NewAccelerationVector ;
// ---------------------- Doxygen info ----------------------
//! \var RMLDoubleVector *MinExtremaTimesVector
//!
//! \brief
//! A pointer to an \c RMLDoubleVector object that contains
//! the times at which each degree of freedom reaches its minimum
//! position during the execution of the calculated trajectory.
//!
//! \details
//! This attribute can be accessed directly or by using one of the following methods:\n\n
//! - GetTimesAtMinPosition(RMLDoubleVector *ExtremaTimes) const\n\n
//! - GetTimesAtMinPosition(double *ExtremaTimes, const unsigned int &SizeInBytes) const\n\n
// ----------------------------------------------------------
RMLDoubleVector *MinExtremaTimesVector ;
// ---------------------- Doxygen info ----------------------
//! \var RMLDoubleVector *MaxExtremaTimesVector
//!
//! \brief
//! A pointer to an \c RMLDoubleVector object that contains
//! the times at which each degree of freedom reaches its maximum
//! position during the execution of the calculated trajectory.
//!
//! \details
//! This attribute can be accessed directly or by using one of the following methods:\n\n
//! - GetTimesAtMaxPosition(RMLDoubleVector *ExtremaTimes) const\n\n
//! - GetTimesAtMaxPosition(double *ExtremaTimes, const unsigned int &SizeInBytes) const\n\n
// ----------------------------------------------------------
RMLDoubleVector *MaxExtremaTimesVector ;
// ---------------------- Doxygen info ----------------------
//! \var RMLDoubleVector *MinPosExtremaPositionVectorOnly
//!
//! \brief
//! A pointer to an \c RMLDoubleVector object that contains
//! the maximum positions for all degrees of freedom that
//! occur during the execution of the calculated trajectory.
//!
//! \details
//! This attribute can be accessed directly or by using one of the following methods:\n\n
//! - GetPositionalExtrema(RMLDoubleVector *MinimumPositionVector, RMLDoubleVector *MaximumPositionVector) const\n\n
//! - GetPositionalExtrema(double *MinimumPositionVector, double *MaximumPositionVector, const unsigned int &SizeInBytes) const\n\n
// ----------------------------------------------------------
RMLDoubleVector *MinPosExtremaPositionVectorOnly ;
// ---------------------- Doxygen info ----------------------
//! \var RMLDoubleVector *MaxPosExtremaPositionVectorOnly
//!
//! \brief
//! A pointer to an \c RMLDoubleVector object that contains
//! the maximum positions for all degrees of freedom that
//! occur during the execution of the calculated trajectory.
//!
//! \details
//! This attribute can be accessed directly or by using one of the following methods:\n\n
//! - GetPositionalExtrema(RMLDoubleVector *MinimumPositionVector, RMLDoubleVector *MaximumPositionVector) const\n\n
//! - GetPositionalExtrema(double *MinimumPositionVector, double *MaximumPositionVector, const unsigned int &SizeInBytes) const\n\n
// ----------------------------------------------------------
RMLDoubleVector *MaxPosExtremaPositionVectorOnly ;
// ---------------------- Doxygen info ----------------------
//! \var RMLDoubleVector *ExecutionTimes
//!
//! \brief
//! A pointer to an \c RMLDoubleVector object that contains
//! the execution times of all selected degrees of freedom in the case
//! non-synchronized trajectories
//!
//! \details
//! <ul>
//! <li>In case of non-synchronized trajectories, this vector contains
//! the execution times of all selected degrees of freedom.</li>
//! <li>In the case of time- and phase-synchronized trajectories, this
//! vector contains the synchronization time for all selected
//! degree of freedom.</li>
//! <li>The values non-selected degrees of freedom is zero.\n\n</li>
//! </ul>
//!
//! This attribute can be accessed directly or by using one of the following methods:\n\n
//! - GetExecutionTimes(RMLDoubleVector *OutputVector) const\n\n
//! - GetExecutionTimes(double *OutputVector, const unsigned int &SizeInBytes) const\n\n
//! - GetExecutionTimesElement(double *OutputValue, const unsigned int &Index) const\n\n
//! - GetExecutionTimesElement(const unsigned int &Index) const\n\n
// ----------------------------------------------------------
RMLDoubleVector *ExecutionTimes;
// ---------------------- Doxygen info ----------------------
//! \var RMLDoubleVector *MinPosExtremaPositionVectorArray
//!
//! \brief
//! A pointer to an array of pointers to \c RMLDoubleVector
//! objects. The number of array elements equals the number of
//! degrees of freedom, and each of these \c RMLDOubleVector
//! objects consists of the same number of entries, such that it
//! is a square matrix. A single vector contains the position
//! vector, that will be achieved when the respective degree of
//! freedom reaches its minimum position.
//!
//! \details
//! This attribute can be accessed directly or by using one of the following methods:\n\n
//! - GetMotionStateAtMinPosForOneDOF(const unsigned int &DOF, RMLDoubleVector *PositionVector, RMLDoubleVector *VelocityVector, RMLDoubleVector *AccelerationVector) const\n\n
//! - GetMotionStateAtMinPosForOneDOF(const unsigned int &DOF, double *PositionVector, double *VelocityVector, double *AccelerationVector, const unsigned int &SizeInBytes) const\n\n
// ----------------------------------------------------------
RMLDoubleVector **MinPosExtremaPositionVectorArray ;
// ---------------------- Doxygen info ----------------------
//! \var RMLDoubleVector *MinPosExtremaVelocityVectorArray
//!
//! \brief
//! A pointer to an array of pointers to \c RMLDoubleVector
//! objects. The number of array elements equals the number of
//! degrees of freedom, and each of these \c RMLDOubleVector
//! objects consists of the same number of entries, such that it
//! is a square matrix. A single vector contains the velocity
//! vector, that will be achieved when the respective degree of
//! freedom reaches its minimum position.
//!
//! \details
//! This attribute can be accessed directly or by using one of the following methods:\n\n
//! - GetMotionStateAtMinPosForOneDOF(const unsigned int &DOF, RMLDoubleVector *PositionVector, RMLDoubleVector *VelocityVector, RMLDoubleVector *AccelerationVector) const\n\n
//! - GetMotionStateAtMinPosForOneDOF(const unsigned int &DOF, double *PositionVector, double *VelocityVector, double *AccelerationVector, const unsigned int &SizeInBytes) const\n\n
// ----------------------------------------------------------
RMLDoubleVector **MinPosExtremaVelocityVectorArray ;
// ---------------------- Doxygen info ----------------------
//! \var RMLDoubleVector **MinPosExtremaAccelerationVectorArray
//!
//! \brief
//! A pointer to an array of pointers to \c RMLDoubleVector
//! objects. The number of array elements equals the number of
//! degrees of freedom, and each of these \c RMLDOubleVector
//! objects consists of the same number of entries, such that it
//! is a square matrix. A single vector contains the position
//! vector, that will be achieved when the respective degree of
//! freedom reaches its minimum position.
//!
//! \details
//! This attribute can be accessed directly or by using one of the following methods:\n\n
//! - GetMotionStateAtMinPosForOneDOF(const unsigned int &DOF, RMLDoubleVector *PositionVector, RMLDoubleVector *VelocityVector, RMLDoubleVector *AccelerationVector) const\n\n
//! - GetMotionStateAtMinPosForOneDOF(const unsigned int &DOF, double *PositionVector, double *VelocityVector, double *AccelerationVector, const unsigned int &SizeInBytes) const\n\n
// ----------------------------------------------------------
RMLDoubleVector **MinPosExtremaAccelerationVectorArray ;
// ---------------------- Doxygen info ----------------------
//! \var RMLDoubleVector *MaxPosExtremaPositionVectorArray
//!
//! \brief
//! A pointer to an array of pointers to \c RMLDoubleVector
//! objects. The number of array elements equals the number of
//! degrees of freedom, and each of these \c RMLDOubleVector
//! objects consists of the same number of entries, such that it
//! is a square matrix. A single vector contains the position
//! vector, that will be achieved when the respective degree of
//! freedom reaches its maximum position.
//!
//! \details
//! This attribute can be accessed directly or by using one of the following methods:\n\n
//! - GetMotionStateAtMaxPosForOneDOF(const unsigned int &DOF, RMLDoubleVector *PositionVector, RMLDoubleVector *VelocityVector, RMLDoubleVector *AccelerationVector) const\n\n
//! - GetMotionStateAtMaxPosForOneDOF(const unsigned int &DOF, double *PositionVector, double *VelocityVector, double *AccelerationVector, const unsigned int &SizeInBytes) const\n\n
// ----------------------------------------------------------
RMLDoubleVector **MaxPosExtremaPositionVectorArray ;
// ---------------------- Doxygen info ----------------------
//! \var RMLDoubleVector *MaxPosExtremaVelocityVectorArray
//!
//! \brief
//! A pointer to an array of pointers to \c RMLDoubleVector
//! objects. The number of array elements equals the number of
//! degrees of freedom, and each of these \c RMLDOubleVector
//! objects consists of the same number of entries, such that it
//! is a square matrix. A single vector contains the velocity
//! vector, that will be achieved when the respective degree of
//! freedom reaches its maximum position.
//!
//! \details
//! This attribute can be accessed directly or by using one of the following methods:\n\n
//! - GetMotionStateAtMaxPosForOneDOF(const unsigned int &DOF, RMLDoubleVector *PositionVector, RMLDoubleVector *VelocityVector, RMLDoubleVector *AccelerationVector) const\n\n
//! - GetMotionStateAtMaxPosForOneDOF(const unsigned int &DOF, double *PositionVector, double *VelocityVector, double *AccelerationVector, const unsigned int &SizeInBytes) const\n\n
// ----------------------------------------------------------
RMLDoubleVector **MaxPosExtremaVelocityVectorArray ;
// ---------------------- Doxygen info ----------------------
//! \var RMLDoubleVector *MaxPosExtremaAccelerationVectorArray
//!
//! \brief
//! A pointer to an array of pointers to \c RMLDoubleVector
//! objects. The number of array elements equals the number of
//! degrees of freedom, and each of these \c RMLDOubleVector
//! objects consists of the same number of entries, such that it
//! is a square matrix. A single vector contains the acceleration
//! vector, that will be achieved when the respective degree of
//! freedom reaches its maximum position.
//!
//! \details
//! This attribute can be accessed directly or by using one of the following methods:\n\n
//! - GetMotionStateAtMaxPosForOneDOF(const unsigned int &DOF, RMLDoubleVector *PositionVector, RMLDoubleVector *VelocityVector, RMLDoubleVector *AccelerationVector) const\n\n
//! - GetMotionStateAtMaxPosForOneDOF(const unsigned int &DOF, double *PositionVector, double *VelocityVector, double *AccelerationVector, const unsigned int &SizeInBytes) const\n\n
// ----------------------------------------------------------
RMLDoubleVector **MaxPosExtremaAccelerationVectorArray ;
// ---------------------- Doxygen info ----------------------
//! \var RMLOutputPolynomials *Polynomials
//!
//! \brief
//! Pointer to an RMLOutputPolynomials object that contains the coefficients
//! of all polynomials that represent the current trajectory
//!
//! \details
//! Besides a new state of motion consisting of \c NewPositionVector,
//! \c NewVelocityVector, and \c NewAccelerationVector, the entire
//! trajectory represented by piecewise polynomials for the position
//! velocity, and acceleration progressions are returned by the Reflexxes
//! API methods ReflexxesAPI::RMLPosition() and ReflexxesAPI::RMLVelocity().
//! The coefficients may be used to add time-scaling algorithms or to
//! add custom sample algorithms for the currently computed trajectory.
//!
//! \sa \ref page_Code_02_RMLPositionSampleApplication
//! \sa \ref page_Code_05_RMLVelocitySampleApplication
// ----------------------------------------------------------
RMLOutputPolynomials *Polynomials ;
};// class RMLOutputParameters
#endif
| 42.915829 | 191 | 0.60533 | [
"object",
"vector"
] |
137fa3613122fb5afb81ab8c7c9dfdf2671ac421 | 3,303 | h | C | Includes/Core/Searcher/PointNeighborSearcher3.h | utilForever/CubbyFlow-v1 | d85c136d8eaa91ecce456c3356c7e578dda5d5bd | [
"MIT"
] | 3 | 2020-04-15T13:41:16.000Z | 2020-12-29T11:23:59.000Z | Includes/Core/Searcher/PointNeighborSearcher3.h | utilForever/CubbyFlow-v1 | d85c136d8eaa91ecce456c3356c7e578dda5d5bd | [
"MIT"
] | null | null | null | Includes/Core/Searcher/PointNeighborSearcher3.h | utilForever/CubbyFlow-v1 | d85c136d8eaa91ecce456c3356c7e578dda5d5bd | [
"MIT"
] | null | null | null | /*************************************************************************
> File Name: PointNeighborSearcher3.h
> Project Name: CubbyFlow
> Author: Chan-Ho Chris Ohk
> Purpose: Abstract base class for 3-D neighbor point searcher.
> Created Time: 2017/05/07
> Copyright (c) 2018, Chan-Ho Chris Ohk
*************************************************************************/
#ifndef CUBBYFLOW_POINT_NEIGHBOR_SEARCHER3_H
#define CUBBYFLOW_POINT_NEIGHBOR_SEARCHER3_H
#include <Core/Utils/Serialization.h>
#include <Core/Vector/Vector3.h>
#include <functional>
#include <memory>
#include <string>
namespace CubbyFlow
{
//!
//! \brief Abstract base class for 3-D neighbor point searcher.
//!
//! This class provides interface for 3-D neighbor point searcher. For given
//! list of points, the class builds internal cache to accelerate the search.
//! Once built, the data structure is used to search nearby points for given
//! origin point.
//!
class PointNeighborSearcher3 : public Serializable
{
public:
//! Callback function for nearby search query. The first parameter is the
//! index of the nearby point, and the second is the position of the point.
using ForEachNearbyPointFunc = std::function<void(size_t, const Vector3D&)>;
//! Default constructor.
PointNeighborSearcher3();
//! Destructor.
virtual ~PointNeighborSearcher3();
//! Returns the type name of the derived class.
virtual std::string TypeName() const = 0;
//! Builds internal acceleration structure for given points list.
virtual void Build(const ConstArrayAccessor1<Vector3D>& points) = 0;
//!
//! Invokes the callback function for each nearby point around the origin
//! within given radius.
//!
//! \param[in] origin The origin position.
//! \param[in] radius The search radius.
//! \param[in] callback The callback function.
//!
virtual void ForEachNearbyPoint(const Vector3D& origin, double radius, const ForEachNearbyPointFunc& callback) const = 0;
//!
//! Returns true if there are any nearby points for given origin within
//! radius.
//!
//! \param[in] origin The origin.
//! \param[in] radius The radius.
//!
//! \return True if has nearby point, false otherwise.
//!
virtual bool HasNearbyPoint(const Vector3D& origin, double radius) const = 0;
//!
//! \brief Creates a new instance of the object with same properties
//! than original.
//!
//! \return Copy of this object.
//!
virtual std::shared_ptr<PointNeighborSearcher3> Clone() const = 0;
};
//! Shared pointer for the PointNeighborSearcher3 type.
using PointNeighborSearcher3Ptr = std::shared_ptr<PointNeighborSearcher3>;
//! Abstract base class for 3-D point neighbor searcher builders.
class PointNeighborSearcherBuilder3
{
public:
virtual ~PointNeighborSearcherBuilder3();
//! Returns shared pointer of PointNeighborSearcher3 type.
virtual PointNeighborSearcher3Ptr BuildPointNeighborSearcher() const = 0;
};
//! Shared pointer for the PointNeighborSearcherBuilder3 type.
using PointNeighborSearcherBuilder3Ptr = std::shared_ptr<PointNeighborSearcherBuilder3>;
#define CUBBYFLOW_NEIGHBOR_SEARCHER3_TYPE_NAME(DerivedClassName) \
std::string TypeName() const override \
{ \
return #DerivedClassName; \
}
}
#endif | 32.70297 | 123 | 0.695731 | [
"object",
"vector"
] |
138ac5b04f0958a370a4618cd2e68fb316e60d98 | 1,103 | c | C | 08_140609/test-mmx.c | wkentaro-archive/lecture2014s-utmech-soft2 | 4b4d831433d7b3cdce98b33d60740c4c08972b50 | [
"MIT"
] | 1 | 2019-03-11T12:16:48.000Z | 2019-03-11T12:16:48.000Z | 08_140609/test-mmx.c | wkentaro-archive/lecture2014s-utmech-soft2 | 4b4d831433d7b3cdce98b33d60740c4c08972b50 | [
"MIT"
] | null | null | null | 08_140609/test-mmx.c | wkentaro-archive/lecture2014s-utmech-soft2 | 4b4d831433d7b3cdce98b33d60740c4c08972b50 | [
"MIT"
] | null | null | null | #include <stdio.h>
/* test-mmx.c*/
int main(int argc, char *argv[]) {
short a[4] = {1, 2, 3, 4};
short b[4] = {-4, -3, -2, -1};
int c[2];
int i=4, j=1, k=0;
# if 0
asm ( assembler template
: output operands
: input operands
: list of clobbered registers
);
# endif
asm volatile ("movq %0,%%mm0": :"m"(a[0]));
asm volatile ("movq %0,%%mm1": :"m"(b[0]));
/* PMADDWD--Packed Multiply and Add */
/* SRC : | X3 | X2 | X1 | X0 | */
/* DEST: | Y3 | Y2 | Y1 | Y0 | */
/* DEST: |X3*Y3+X2*Y2+X1*Y1+X0*Y0| */
// asm volatile ("pmaddwd %%mm1,%%mm0"::); // mm0 の mm1 最大値
asm volatile ("nop" :: "a" (a[0]));
asm volatile ("nop" :: "b" (b[0]));
asm volatile ("add %eax,%ebx");
asm volatile ("nop" :"=b"(c[0]));
// asm volatile ("movq %%mm0,%0":"=m"(c[0]));
asm volatile ("emms");
printf("%3d\n", k);
for (i=0; i<4; i++) printf(" %3d", a[i]); printf("\n");
for (i=0; i<4; i++) printf(" %3d", b[i]); printf("\n");
for (i=0; i<2; i++) printf(" %3d", c[i]); printf("\n");
return 0;
}
| 29.810811 | 63 | 0.458749 | [
"3d"
] |
139af0f306ca87f4672b23d9e36fa152dc143fe9 | 2,396 | c | C | texture_example/src/main.c | RossMeikleham/Vita_SDL2_Examples | b9c259517e17495c9fa54285b4f3151a0fd1b5da | [
"MIT"
] | 1 | 2017-12-15T07:33:47.000Z | 2017-12-15T07:33:47.000Z | texture_example/src/main.c | RossMeikleham/Vita_SDL2_Examples | b9c259517e17495c9fa54285b4f3151a0fd1b5da | [
"MIT"
] | null | null | null | texture_example/src/main.c | RossMeikleham/Vita_SDL2_Examples | b9c259517e17495c9fa54285b4f3151a0fd1b5da | [
"MIT"
] | null | null | null | // Example of Initializing and Updating a SDL2 Texture
#include <SDL2/SDL.h>
#ifdef PSVITA
#include <psp2/kernel/processmgr.h>
#endif
#define TEXTURE_PIXELS_X 160
#define TEXTURE_PIXELS_Y 140
#define VITA_SCREEN_WIDTH 960
#define VITA_SCREEN_HEIGHT 544
static SDL_Window *screen;
static SDL_Renderer *renderer;
static SDL_Texture *texture;
static Uint32 texture_pixels[TEXTURE_PIXELS_X * TEXTURE_PIXELS_Y];
/* Initialise graphics and create win_x by win_y pixel
* screen. Returns 1 if successful, 0 otherwise */
int init_screen(int win_x, int win_y) {
if((SDL_Init(SDL_INIT_VIDEO)==-1)) {
return 0;
}
// Setup Window
screen = SDL_CreateWindow("Vita Texture Example",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
win_x, win_y,
0);
if (screen == NULL) {
return 0;
}
// Setup Renderer
renderer = SDL_CreateRenderer(screen, -1, 0);
if (renderer == NULL) {
return 0;
}
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
// Setup texture for blitting the pixels
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING, TEXTURE_PIXELS_X, TEXTURE_PIXELS_Y);
if (texture == NULL) {
return 0;
}
return 1;
}
/* Update the texture and render it to the screen */
void draw_screen() {
SDL_DisplayMode current;
SDL_UpdateTexture(texture, NULL, texture_pixels, TEXTURE_PIXELS_X * sizeof (Uint32));
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);
}
int main() {
if (!init_screen(VITA_SCREEN_WIDTH, VITA_SCREEN_HEIGHT)) {
return 1;
};
// Red
for (int i = 0; i < TEXTURE_PIXELS_X * TEXTURE_PIXELS_Y; i++) {
texture_pixels[i] = 0xFFFF0000;
}
draw_screen();
SDL_Delay(3000);
// Green
for (int i = 0; i < TEXTURE_PIXELS_X * TEXTURE_PIXELS_Y; i++) {
texture_pixels[i] = 0xFF00FF00;
}
draw_screen();
SDL_Delay(3000);
// Blue
for (int i = 0; i < TEXTURE_PIXELS_X * TEXTURE_PIXELS_Y; i++) {
texture_pixels[i] = 0xFF0000FF;
}
draw_screen();
SDL_Delay(3000);
#ifdef PSVITA
sceKernelExitProcess(0);
#endif
}
| 22.392523 | 86 | 0.6298 | [
"render"
] |
13a92e3fa68254b2d2cdc3279dcc9a2ccf6939ad | 464 | h | C | src/area.h | KostyaKulakov/Russian_System_of_ANPR | 5fdb6874a333939fe8560b29b5d72304029a3c2a | [
"BSD-2-Clause"
] | 83 | 2015-06-23T08:42:24.000Z | 2022-03-30T12:21:10.000Z | src/area.h | sophronesis/Russian_System_of_ANPR | 3f2d45dd7a6d9f4de71620e83bf9949adf79df84 | [
"BSD-2-Clause"
] | 5 | 2017-08-23T06:11:58.000Z | 2021-11-16T12:07:48.000Z | src/area.h | sophronesis/Russian_System_of_ANPR | 3f2d45dd7a6d9f4de71620e83bf9949adf79df84 | [
"BSD-2-Clause"
] | 38 | 2015-06-23T16:27:41.000Z | 2021-11-07T07:17:10.000Z | /*
* Name: area.h
* Description: This class contains a structure for storing location symbols
* Author: Konstantin Kulakov
* Website: http://kostyakulakov.ru
* Version: 1.1
* License: BSD
*/
#pragma once
#include <opencv2/opencv.hpp>
#include <vector>
struct mArea
{
mArea(std::vector<cv::Point>& vec);
cv::Point min;
cv::Point max;
unsigned height;
unsigned width;
bool operator < (const mArea& a) const;
bool operator == (const mArea& a) const;
}; | 17.846154 | 75 | 0.698276 | [
"vector"
] |
13a98fc8c46527de7369cbae7b567efc5a91dc6f | 10,052 | h | C | Chapter5/Main/hgt-qfunc.v.0.5.2/deps/simdpp/simd/extract.h | dunarel/dunphd-thesis | 7c6286b5134024a8a67f97c4bfba8d6b94dc21c9 | [
"BSD-3-Clause"
] | null | null | null | Chapter5/Main/hgt-qfunc.v.0.5.2/deps/simdpp/simd/extract.h | dunarel/dunphd-thesis | 7c6286b5134024a8a67f97c4bfba8d6b94dc21c9 | [
"BSD-3-Clause"
] | null | null | null | Chapter5/Main/hgt-qfunc.v.0.5.2/deps/simdpp/simd/extract.h | dunarel/dunphd-thesis | 7c6286b5134024a8a67f97c4bfba8d6b94dc21c9 | [
"BSD-3-Clause"
] | null | null | null | /* libsimdpp
Copyright (C) 2011-2013 Povilas Kanapickas tir5c3@yahoo.co.uk
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef LIBSIMDPP_SIMD_EXTRACT_H
#define LIBSIMDPP_SIMD_EXTRACT_H
#ifndef LIBSIMDPP_SIMD_H
#error "This file must be included through simd.h"
#endif
#include <simdpp/simd/fwd.h>
#include <simdpp/simd/types.h>
#include <simdpp/simd/shuffle.h>
#include <simdpp/simd/cast.h>
#include <simdpp/simd/detail/word_size.h>
namespace simdpp {
#ifndef DOXYGEN_SHOULD_SKIP_THIS
namespace SIMDPP_ARCH_NAMESPACE {
#endif
/// @ingroup simd_insert_extract
/// @{
/// @{
/** Extracts the @a id-th element from int8x16 vector
@code
r = a[id]
@endcode
This function may have very high latency.
@icost{SSE2-SSSE3, 1-2}
@icost{SSE4.1-AVX, 1}
@icost{ALTIVEC, 2}
*/
template<unsigned id>
uint8_t extract(basic_int8x16 a)
{
static_assert(id < 16, "index out of bounds");
#if SIMDPP_USE_NULL
return a[id];
#elif SIMDPP_USE_SSE4_1
// Explicit cast is needed due to bug in Clang headers (intrinsic
// implemented as a macro with no appropriate casts) and a bug in Clang
// (thinks explicit conversion operators have the same rank as the regular
// ones)
return _mm_extract_epi8(a.operator __m128i(), id);
#elif SIMDPP_USE_SSE2
unsigned shift = (id % 2 == 1) ? 8 : 0;
return _mm_extract_epi16(a, id/2) >> shift;
#elif SIMDPP_USE_NEON
return vgetq_lane_u8(a, id);
#elif SIMDPP_USE_ALTIVEC
detail::mem_block<uint8x16> ax(a);
vec_ste((__vector uint8_t)a, 0, &ax[id]);
return ax[id];
#endif
}
template<unsigned id>
int8_t extract(int8x16 a)
{
return extract<id>(basic_int8x16(a));
}
/// @}
/// @{
/** Extracts the @a id-th element from int16x8 vector
@code
r = a[id]
@endcode
This function may have very high latency.
@icost{ALTIVEC, 2}
*/
template<unsigned id>
uint16_t extract(basic_int16x8 a)
{
static_assert(id < 8, "index out of bounds");
#if SIMDPP_USE_NULL
return a[id];
#elif SIMDPP_USE_SSE2
return _mm_extract_epi16(a, id);
#elif SIMDPP_USE_NEON
return vgetq_lane_u16(a, id);
#elif SIMDPP_USE_ALTIVEC
detail::mem_block<uint16x8> ax(a);
vec_ste((__vector uint16_t)a, 0, &ax[id]);
return ax[id];
#endif
}
template<unsigned id>
int16_t extract(int16x8 a)
{
return extract<id>(basic_int16x8(a));
}
/// @}
/// @{
/** Extracts the @a id-th element from int32x4 vector
@code
r = a[id]
@endcode
This function may have very high latency.
@icost{SSE2, SSE3, SSSE3, 1-2}
@icost{ALTIVEC, 2}
*/
template<unsigned id>
uint32_t extract(basic_int32x4 a)
{
static_assert(id < 4, "index out of bounds");
#if SIMDPP_USE_NULL
return a[id];
#elif SIMDPP_USE_SSE4_1
return _mm_extract_epi32(a.operator __m128i(), id);
#elif SIMDPP_USE_SSE2
return _mm_cvtsi128_si32(move_l<id>(a)); // when id==0, move_l is template-specialized and does nothing
#elif SIMDPP_USE_NEON
return vgetq_lane_u32(a, id);
#elif SIMDPP_USE_ALTIVEC
detail::mem_block<uint32x4> ax(a);
vec_ste((__vector uint32_t)a, 0, &ax[id]);
return ax[id];
#endif
}
template<unsigned id>
int32_t extract(int32x4 a)
{
return extract<id>(basic_int32x4(a));
}
/// @}
/// @{
/** Extracts an element from int64x2 vector
@code
r = a[id]
@endcode
This function may have very high latency.
@icost{SSE2, SSE3, SSSE3, 1-2}
@icost{SSE4_1, 1}
@icost{SSE2_32bit, SSE3_32bit, SSSE3_32bit, 3-4}
@icost{SSE4_1_32bit, 2}
@icost{ALTIVEC, 2}
*/
template<unsigned id>
uint64_t extract(basic_int64x2 a)
{
static_assert(id < 2, "index out of bounds");
#if SIMDPP_USE_NULL
return a[id];
#elif SIMDPP_USE_SSE4_1
#if SIMDPP_SSE_32_BITS
basic_int32x4 t = a;
uint64_t r = extract<id*2>(t);
r |= uint64_t(extract<id*2+1>(t)) << 32;
return r;
#else
return _mm_extract_epi64(a.operator __m128i(), id);
#endif
#elif SIMDPP_USE_SSE2
#if SIMDPP_SSE_32_BITS
basic_int32x4 t = a;
uint64_t r = 0;
t = move_l<id*2>(t); // when id==0, move_l is template-specialized and does nothing
r = extract<0>(t);
t = move_l<1>(t);
r |= uint64_t(extract<0>(t)) << 32;
return r;
#else
uint64x2 t = a;
if (id != 0) {
t = move_l<id>(t);
}
return _mm_cvtsi128_si64(t);
#endif
#elif SIMDPP_USE_NEON
return vgetq_lane_u64(a, id);
#elif SIMDPP_USE_ALTIVEC
detail::mem_block<uint64x2> ax(a);
return ax[id];
#endif
}
template<unsigned id>
int64_t extract(int64x2 a)
{
return extract<id>(basic_int64x2(a));
}
/// @}
/** Extracts an element from float32x4 vector
@code
r = a[id]
@endcode
This function may have very high latency.
@icost{SSE2, SSE3, SSSE3, 1-2}
@icost{ALTIVEC, 2}
*/
template<unsigned id>
float extract(float32x4 a)
{
static_assert(id < 4, "index out of bounds");
#if SIMDPP_USE_NULL
return a[id];
#elif SIMDPP_USE_SSE2
return bit_cast<float>(extract<id>(int32x4(a)));
#elif SIMDPP_USE_NEON
return vgetq_lane_f32(a, id);
#elif SIMDPP_USE_ALTIVEC
detail::mem_block<float32x4> ax(a);
vec_ste((__vector float)a, 0, &ax[id]);
return ax[id];
#endif
}
/** Extracts an element from float64x2 vector
@code
r = a[id]
@endcode
This function may have very high latency.
@icost{NEON, ALTIVEC, 2}
*/
template<unsigned id>
double extract(float64x2 a)
{
static_assert(id < 2, "index out of bounds");
#if SIMDPP_USE_NULL
return a[id];
#elif SIMDPP_USE_SSE2
return bit_cast<double>(extract<id>(int64x2(a)));
#elif SIMDPP_USE_NEON || SIMDPP_USE_ALTIVEC
detail::mem_block<float64x2> ax(a);
return a[id];
#endif
}
/** Extracts a bit from each byte of each element of a int8x16 vector.
This operation is only sensible if each byte within the vector is either
0x00 or 0xff.
@code
r = ((a[0] & 0x??) ? 0x01 : 0) |
((a[1] & 0x??) ? 0x02 : 0) |
...
((a[15] & 0x??) ? 0x80 : 0)
@endcode
@icost{NEON, 6-7}
@icost{ALTIVEC, 8-9}
*/
inline uint16_t extract_bits_any(uint8x16 a)
{
// extract_bits_impl depends on the exact implementation of this function
#if SIMDPP_USE_NULL
uint16_t r = 0;
null::foreach<uint8x16>(a, [&r](uint8_t x){
x = x & 1;
r = (r >> 1) | (uint16_t(x) << 15);
return 0; // dummy
});
return r;
#elif SIMDPP_USE_SSE2
return _mm_movemask_epi8(a);
#elif SIMDPP_USE_NEON
uint8x16 mask = uint8x16::make_const(0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80);
a = bit_and(a, mask);
a = vpaddlq_u8(a);
a = vpaddlq_u16(a);
a = vpaddlq_u32(a);
uint8x8_t r = vzip_u8(vget_low_u8(a), vget_high_u8(a)).val[0];
return vget_lane_u16(vreinterpret_u16_u8(r), 0);
#elif SIMDPP_USE_ALTIVEC
uint8x16 mask = uint8x16::make_const(0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80);
a = bit_and(a, mask);
uint32x4 s = vec_sum4s((__vector uint8_t)a,
(__vector uint32_t)uint32x4::zero());
uint32x4 s2 = (__vector uint32_t)vec_mergel((__vector uint8_t)a,
(__vector uint8_t)uint8x16::zero());
s = bit_or(s, s2);
s = (int32x4)vec_sums((__vector int32_t)s,
(__vector int32_t)int32x4::zero());
return extract<7>(uint16x8(s));
#endif
}
/** Extracts specific bit from each byte of each element of a int8x16 vector.
The default template argument selects the bits from each byte in most
efficient way.
@code
r = (a[0] & 0x80 >> 7) | (a[1] & 0x80 >> 6) | ... | (a[15] & 0x80 << 8)
@endcode
@icost{SSE2-AVX2, 2}
@icost{NEON, 7-9}
@icost{ALTIVEC, 9-11}
*/
template<unsigned id>
uint16_t extract_bits(uint8x16 a)
{
static_assert(id < 8, "index out of bounds");
#if SIMDPP_USE_NULL
uint16_t r = 0;
null::foreach<uint8x16>(a, [&r](uint8_t x){
x = (x >> id) & 1;
r = (r >> 1) | (uint16_t(x) << 15);
return 0; // dummy
});
return r;
#elif SIMDPP_USE_SSE2
a = shift_l<7-id>((uint16x8) a);
return extract_bits_any(a);
#elif SIMDPP_USE_NEON
int8x16 shift_mask = int8x16::make_const(0-int(id), 1-int(id), 2-int(id), 3-int(id),
4-int(id), 5-int(id), 6-int(id), 7-int(id));
a = vshlq_u8(a, shift_mask);
return extract_bits_any(a);
#elif SIMDPP_USE_ALTIVEC
uint8x16 rot_mask = int8x16::make_const(0-int(id), 1-int(id), 2-int(id), 3-int(id),
4-int(id), 5-int(id), 6-int(id), 7-int(id));
a = vec_rl((__vector uint8_t)a, (__vector uint8_t)rot_mask);
return extract_bits_any(a);
#endif
}
/// @} -- end ingroup
#ifndef DOXYGEN_SHOULD_SKIP_THIS
} // namespace SIMDPP_ARCH_NAMESPACE
#endif
} // namespace simdpp
#endif
| 26.314136 | 107 | 0.660665 | [
"vector"
] |
13b15d73f95ccb892358d65bca50c1e9cb6df399 | 2,655 | h | C | trunk/libcvact/include/actSCardOSReg.h | flomar/CrypTool-VS2015 | 6468257af2e1002418882f22a9ed9fabddde096d | [
"Apache-2.0"
] | null | null | null | trunk/libcvact/include/actSCardOSReg.h | flomar/CrypTool-VS2015 | 6468257af2e1002418882f22a9ed9fabddde096d | [
"Apache-2.0"
] | null | null | null | trunk/libcvact/include/actSCardOSReg.h | flomar/CrypTool-VS2015 | 6468257af2e1002418882f22a9ed9fabddde096d | [
"Apache-2.0"
] | 5 | 2016-07-02T12:59:28.000Z | 2021-10-02T14:58:30.000Z | // ---------------------------------------------------------------------------
// Name: actSCardOSReg.h
// Product: cv act library
// Purpose: factory functions registry to create SCardOS objects.
//
// Copyright: (c) 2002 cv cryptovision GmbH
// all rights reserved
// Licence: The conditions for the use of this software are regulated
// in the cv act library licence agreement.
//
// Autor: Dr. Xiangdong Wang (XWG)
// Date: 04/09/2002
// ---------------------------------------------------------------------------
#ifndef ACT_SCardOSReg_h
#define ACT_SCardOSReg_h
#include "actBlob.h"
#include "actFactoryReg.h"
namespace act
{
# define ACT_ISO7816OS_NAME "ISO7816OS"
class ISCardOS;
class ISCardAccess;
typedef ISCardOS* (*CreateSCardOSPtr)(ISCardAccess*);
typedef bool (*DetectSCardOSPtr)(const Blob&, ISCardAccess*);
struct SCardOSMapEntry
{
const char* Name;
CreateSCardOSPtr CreatePtr;
};
struct SCardOSAtrMaskEntry
{
// const might be nice here, but it collides with the way std::vector works.
byte_array ATR;
byte_array Mask;
CreateSCardOSPtr CreatePtr;
};
struct SCardOSFactoryEntry
{
DetectSCardOSPtr DetectPtr;
CreateSCardOSPtr CreatePtr;
};
struct SCardOSRegInfo;
class SCardOSReg
{
public:
enum Type
{
DEFAULT = 0,
ATR = 1,
MODEL_ID = 2, //!< By default the ModelId equals the ATR-Historical Bytes
};
static ISCardOS* CreateSCardOS(const SCardOSRegInfo& info, ISCardAccess* ac);
static CreateSCardOSPtr GetCreatePointer(const SCardOSRegInfo& info, ISCardAccess* ac);
static CreateSCardOSPtr GetCreatePointer(const char* name);
static const char* GetName(void* createptr);
static const char* GetNextName(const char* name);
static void Insert(const char* name, CreateSCardOSPtr createptr);
static void Insert(const SCardOSMapEntry* entry);
static void Insert(const SCardOSAtrMaskEntry* entry);
static void Insert(const SCardOSFactoryEntry* entry);
};
// ---------------------------------------------------------------------------
typedef ISCardOS* (*DeriveSCardOSPtr)(ISCardOS*);
typedef FactoryMapEntry<DeriveSCardOSPtr> SCardOSDerivationMapEntry;
typedef FactoryReg
< ISCardOS, DeriveSCardOSPtr, SCardOSDerivationMapEntry
> SCardOSDerivationReg;
// ---------------------------------------------------------------------------
struct SCardOSRegInfo
{
const SCardOSReg::Type m_type;
const Blob m_data;
SCardOSRegInfo(SCardOSReg::Type type = SCardOSReg::DEFAULT, const Blob& data = Blob())
: m_type(type)
, m_data(data)
{ }
};
} // namespace act
#endif // ACT_SCardOSReg_h
| 27.371134 | 89 | 0.643315 | [
"vector"
] |
13b3ff4b0502199a9dd417bd5ecc9e9c19e9801c | 666 | h | C | Shared/AbstractModel.h | deminew/cocosMNC | 3ed97dfec07f1bffaae0a54f5719dd33a9f808bf | [
"Unlicense"
] | 1 | 2015-11-05T05:47:38.000Z | 2015-11-05T05:47:38.000Z | Shared/AbstractModel.h | deminew/cocosMNC | 3ed97dfec07f1bffaae0a54f5719dd33a9f808bf | [
"Unlicense"
] | null | null | null | Shared/AbstractModel.h | deminew/cocosMNC | 3ed97dfec07f1bffaae0a54f5719dd33a9f808bf | [
"Unlicense"
] | null | null | null | //
// AbstractModel.h
// OMGTTT
//
// Created by Jeremy on 1/11/10.
// Copyright 2010 Jeremy Flores. All rights reserved.
//
#import <Foundation/Foundation.h>
@class AbstractModel;
@protocol ModelDelegate <NSObject>
@required
-(void)modelDidChange:(AbstractModel *)model;
@end
// private methods for AbstractModel
@protocol AbstractModel <NSObject>
@required
-(void)didChange; // notifies delegates of change. object is responsible for calling this internally
@end
@interface AbstractModel : NSObject<AbstractModel> {
NSMutableSet *delegates;
}
-(void)addDelegate:(id<ModelDelegate>)delegate;
-(void)removeDelegate:(id<ModelDelegate>)delegate;
@end
| 18 | 100 | 0.753754 | [
"object",
"model"
] |
13b63434419b32114dcdb187e570bb15bf4a6863 | 1,403 | h | C | CCAPI/CCAPI/DumpTask.h | primetime00/CCCheat | 827fcfb0f06946ed9cde5a10dd489b4a677209ff | [
"Apache-2.0"
] | 16 | 2017-01-30T05:51:34.000Z | 2022-01-26T21:04:26.000Z | CCAPI/CCAPI/DumpTask.h | ps3lib/CCCheat | 827fcfb0f06946ed9cde5a10dd489b4a677209ff | [
"Apache-2.0"
] | 2 | 2016-06-24T15:15:44.000Z | 2018-10-16T15:10:36.000Z | CCAPI/CCAPI/DumpTask.h | ps3lib/CCCheat | 827fcfb0f06946ed9cde5a10dd489b4a677209ff | [
"Apache-2.0"
] | 3 | 2015-09-26T17:04:15.000Z | 2020-06-09T16:09:22.000Z | #ifndef _DUMPTASK_
#define _DUMPTASK_
#include <vector>
#include <utility>
#include <map>
#include "Task.h"
#ifdef _WIN32
#include <direct.h>
#define GetCurrentDir _getcwd
#else
#include <unistd.h>
#define GetCurrentDir getcwd
#endif
using namespace std;
class DumpTask: public Task
{
public:
DumpTask(string ip, unsigned long long offset, unsigned long long length, unsigned int id, string name);
~DumpTask();
virtual void run(void);
int connectAndAttach(int retry=3);
int connect(int loops=10);
int attach();
void setProgressCallback(function<void(DumpTask*, long long, long long)> cb) { m_progressCallback = cb; }
void setErrorCallback(function<unsigned int(void)> cb) { m_errorCallback = cb; }
long long getLastOffset() { return m_length+m_offset; }
long long getFirstOffset() { return m_offset; }
long long getLength() { return m_length; }
char *getBuffer() {return m_buffer;}
protected:
function<void(DumpTask*, long long, long long)> m_progressCallback;
function<unsigned int(void)> m_errorCallback;
private:
void disconnect();
int doDump();
void calculateReads(unsigned long interval, unsigned long &rounds, unsigned long &remain);
unsigned int waitForFire();
void progressCallback(DumpTask* task, long long c, long long t) { if (m_progressCallback != nullptr) { m_progressCallback(task,c,t); } }
bool m_connected;
char *m_buffer;
};
#endif
| 21.584615 | 137 | 0.735567 | [
"vector"
] |
13cf06670c97de486baf7c6ae4bb6709a8a42674 | 2,323 | h | C | zoo-project/zoo-kernel/service_internal_ruby.h | jmckenna/ZOO-Project | 3d150095060600920040470d8329d85c67473a79 | [
"MIT"
] | 11 | 2021-05-22T23:14:52.000Z | 2022-03-26T15:32:05.000Z | zoo-project/zoo-kernel/service_internal_ruby.h | jmckenna/ZOO-Project | 3d150095060600920040470d8329d85c67473a79 | [
"MIT"
] | 13 | 2021-06-17T14:22:28.000Z | 2022-03-10T23:08:52.000Z | zoo-project/zoo-kernel/service_internal_ruby.h | jmckenna/ZOO-Project | 3d150095060600920040470d8329d85c67473a79 | [
"MIT"
] | 9 | 2021-06-25T15:28:37.000Z | 2022-03-20T05:51:01.000Z | /*
* Author : Gérald FENOY
*
* Copyright (c) 2014 GeoLabs SARL
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef ZOO_SERVICE_INTERNAL_RUBY_H
#define ZOO_SERVICE_INTERNAL_RUBY_H 1
#pragma once
#define RUBY_GLOBAL_SETUP
#undef NEED_STRLCAT
#undef NEED_STRLCPY
#include "service.h"
#include "service_internal.h"
#undef RUBY_EXPORT
#undef STRCASECMP
#undef STRNCASECMP
#undef _
#include <ruby.h>
#if ZRUBY_VERSION < 2
#include <version.h>
#else
#include <ruby/version.h>
#endif
#if RUBY_VERSION_MINOR==8
#include <st.h>
#else
#include <ruby/st.h>
#endif
#define MAX_ARGS 3
/**
* The Ruby method pointer
*/
struct my_callback {
VALUE obj; //!< Object used to call a method
ID method_id; //!< The method to call
int nargs; //!< The arguments number
VALUE args[MAX_ARGS]; //!< The arguments values
};
void ruby_trace_error(maps*);
VALUE FunCallWrap(VALUE);
VALUE LoadWrap(VALUE);
VALUE RubyHash_FromMaps(maps*);
VALUE RubyHash_FromMap(map*);
maps* mapsFromRubyHash(VALUE);
void createMapsFromRubyHash(maps**,VALUE);
map* mapFromRubyHash(VALUE);
int zoo_ruby_support(maps**,map*,service*,maps**,maps**);
VALUE RubyTranslate(int,VALUE*,VALUE);
VALUE RubyUpdateStatus(int,VALUE*,VALUE);
#endif
| 29.405063 | 81 | 0.73009 | [
"object"
] |
13cf891eb4b1aebb685bf3f138c95067ffd928c1 | 20,956 | c | C | Src/collision.c | lidl/xtank | 14e6d42efdc0318fbf37717b21cc9f6027dc7e9f | [
"BSD-2-Clause"
] | 14 | 2017-04-20T22:12:33.000Z | 2022-03-19T22:54:41.000Z | Src/collision.c | lidl/xtank | 14e6d42efdc0318fbf37717b21cc9f6027dc7e9f | [
"BSD-2-Clause"
] | null | null | null | Src/collision.c | lidl/xtank | 14e6d42efdc0318fbf37717b21cc9f6027dc7e9f | [
"BSD-2-Clause"
] | 5 | 2017-06-16T01:45:00.000Z | 2022-03-19T23:58:49.000Z | /*-
* Copyright (c) 1988 Terry Donahue
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "xtank.h"
#include "vstructs.h"
#include "screen.h"
#include "bullet.h"
#include "lowlib.h"
#include "globals.h"
#include "assert.h"
#include "graphics.h"
#include "terminal.h"
#include "proto.h"
extern Weapon_stat weapon_stat[];
extern Map real_map;
/*
** Handles collisions between specified vehicle and all walls
*/
void
coll_vehicle_walls(Vehicle *v)
{
Loc *loc, *oloc;
Picture *pic;
int min_x, min_y, max_x, max_y, dx, dy, grid_x, grid_y, vx, vy, hx, hy;
int check_vert, check_hor, crash_vert, crash_hor;
WallSide hdir, vdir;
if (v->just_ported) {
v->just_ported = FALSE;
return;
}
loc = v->loc;
oloc = v->old_loc;
pic = &v->obj->pic[v->vector.rot];
/* Compute box coordinates of bounding rectangle around vehicle.
Base from old location in case we switch boxes this frame. */
#ifdef SCROLL_INTO_WALL_BUG
min_x = oloc->box_x + v->vector.xspeed - pic->offset_x;
min_y = oloc->box_y + v->vector.yspeed - pic->offset_y;
#else
min_x = oloc->box_x + (loc->x - oloc->x) - pic->offset_x;
min_y = oloc->box_y + (loc->y - oloc->y) - pic->offset_y;
#endif
max_x = min_x + pic->width;
max_y = min_y + pic->height;
/* Determine which sides of box, if any, intersect the bounding rectangle
*/
if (min_x <= 0) {
grid_x = oloc->grid_x;
check_hor = -1;
} else if (max_x >= BOX_WIDTH) {
grid_x = oloc->grid_x + 1;
check_hor = 1;
} else {
grid_x = oloc->grid_x;
check_hor = 0;
}
if (min_y <= 0) {
grid_y = oloc->grid_y;
check_vert = -1;
} else if (max_y >= BOX_HEIGHT) {
grid_y = oloc->grid_y + 1;
check_vert = 1;
} else {
grid_y = oloc->grid_y;
check_vert = 0;
}
/* Check for crashes against the two walls closest to the vehicle */
if (check_vert && (real_map[oloc->grid_x][grid_y].flags & NORTH_WALL)) {
crash_vert = check_vert;
vx = oloc->grid_x;
vy = grid_y;
} else {
crash_vert = 0;
}
if (check_hor && (real_map[grid_x][oloc->grid_y].flags & WEST_WALL)) {
crash_hor = check_hor;
hx = grid_x;
hy = oloc->grid_y;
} else {
crash_hor = 0;
}
/* * If we are overlapping a corner, and we didn't collide with * the
first two, check the two farther away. */
if (check_vert && check_hor && !(crash_vert || crash_hor)) {
if (real_map[grid_x][oloc->grid_y + check_vert].flags & WEST_WALL) {
crash_hor = check_hor;
hx = grid_x;
hy = oloc->grid_y + check_vert;
}
if (real_map[oloc->grid_x + check_hor][grid_y].flags & NORTH_WALL) {
crash_vert = check_vert;
vx = oloc->grid_y + check_hor;
vy = grid_y;
}
/* We cannot crash into both of these walls, so pick the closest one */
if (crash_hor && crash_vert) {
dx = ((check_hor == 1) ? (max_y - BOX_HEIGHT) : -min_y);
dy = ((check_vert == 1) ? (max_x - BOX_WIDTH) : -min_x);
if (dx > dy) {
crash_hor = 0;
} else {
crash_vert = 0;
}
}
}
/* If there was a crash, adjust the vehicle's location to against the
wall */
if (crash_vert || crash_hor) {
if (crash_vert == -1) {
vdir = NORTH;
dy = -min_y + 1;
} else {
if (crash_vert == 1) {
vdir = SOUTH;
dy = BOX_HEIGHT - max_y - 1;
} else {
dy = 0;
}
}
if (crash_hor == -1) {
hdir = WEST;
dx = -min_x + 1;
} else {
if (crash_hor == 1) {
hdir = EAST;
dx = BOX_WIDTH - max_x - 1;
} else {
dx = 0;
}
}
adjust_loc(loc, dx, dy);
if (crash_vert) {
vehicle_hit_wall(v, vx, vy, vdir);
}
if (crash_hor) {
vehicle_hit_wall(v, hx, hy, hdir);
}
}
}
/*
** Handles all collisions between bullets and maze.
*/
void
coll_bullets_maze(void)
{
extern Bset *bset;
Bullet *b;
Box *bbox;
Loc *loc, *old_loc;
register int gx, gy, ogx, ogy;
int i;
for (i = 0; i < bset->number; i++) {
b = bset->list[i];
if (b->life < 0)
continue;
loc = b->loc;
old_loc = b->old_loc;
gx = b->loc->grid_x;
gy = b->loc->grid_y;
ogx = b->old_loc->grid_x;
ogy = b->old_loc->grid_y;
/*
* some things fly overhead, and don't hit walls (most of the time)
*/
/*
* If this bullet is not flying overhead...
* perform normal bullet/wall checks
* If bullet is past outer boundry destroy bullet
*/
/*
* modifing my own code again...
*
* I think in general it would be safer to destroy ANYTHING
* that makes it off the grid.
*
* bullet get zapped next update cycle when update_bull
* notices that it's ran out of life..
*
* define DESTROY_ONLY_FLYING for original behavior -ane
*/
if ((int) b->loc->z <= 4) {
/* A bullet with no owner can not hit an outpost in the first 5 frames
of its life. This prevents outposts from shooting themselves. There
is no identifier in the bullet to say that the outpost fired it. */
bbox = &real_map[gx][gy];
if (bbox->type == OUTPOST &&
(b->owner != (Vehicle *) NULL ||
b->life < weapon_stat[(int) b->type].frames - 5) &&
coll_outpost(bbox, loc))
bul_hit_outpost(b, bbox, gx, gy);
/* Check for walls
**
** The following massive special casing is primarily done for speed.
** There are 9 cases to consider, one for each of the nine boxes in
** the area of the bullet.
**
** For the 4 diagonal cases, there is further special casing to
** determine which side of the box the bullet passed through
**
** If the bullet does hit a wall, then the distances to move the
** bullet back are computed (dx and dy). These are sent to
** bullet_hit_wall() which determines the actual results of the
** collision.
**
****
** Aug 13, 90, changed bul_hit_wall to boolean (see hit.c) to stop
** bullets from bouncing through corners. Basically, it returns
** whether a ricochet occured (ie the "bullet" is a disc or ricochet
** bullet). TRUE means that a bounce occured and this code should
** keep tracking the bullet... FALSE means the bullet is dead and we
** dont need to bother. This also meant the initial if of the
** diagonal cases had to be changed to call the second check if the
** bullet still existed. And also at a different location since the
** bounce changes the coordinates of the second box hit.
*/
if (gx == ogx) {
if (gy == ogy) {
/* has not moved into a new box */
continue;
} else if (gy > ogy) {
/* moved south into new box */
if (real_map[gx][gy].flags & NORTH_WALL)
bul_hit_wall(b, gx, gy, SOUTH);
} else {
/* moved north into new box */
if (real_map[ogx][ogy].flags & NORTH_WALL)
bul_hit_wall(b, ogx, ogy, NORTH);
}
} else if (gx > ogx) {
if (gy == ogy) {
/* moved east into new box */
if (real_map[gx][gy].flags & WEST_WALL)
bul_hit_wall(b, gx, gy, EAST);
} else if (gy > ogy) {
/* moved southeast into new box */
if (b->xspeed * loc->box_y > b->yspeed * loc->box_x) {
/* hit south side */
if (real_map[ogx][gy].flags & NORTH_WALL) {
if (bul_hit_wall(b, ogx, gy, SOUTH))
if (real_map[gx][ogy].flags & WEST_WALL)
bul_hit_wall(b, gx, ogy, EAST);
} else if (real_map[gx][gy].flags & WEST_WALL)
bul_hit_wall(b, gx, gy, EAST);
} else {
/* hit east side */
if (real_map[gx][ogy].flags & WEST_WALL) {
if (bul_hit_wall(b, gx, ogy, EAST))
if (real_map[ogx][gy].flags & NORTH_WALL)
bul_hit_wall(b, ogx, gy, SOUTH);
} else if (real_map[gx][gy].flags & NORTH_WALL)
bul_hit_wall(b, gx, gy, SOUTH);
}
} else {
/* moved northeast into new box */
if (b->xspeed * (BOX_HEIGHT - loc->box_y) >
b->yspeed * loc->box_x) {
/* hit east side */
if (real_map[gx][ogy].flags & WEST_WALL) {
if (bul_hit_wall(b, gx, ogy, EAST))
if (real_map[ogx][ogy].flags & NORTH_WALL)
bul_hit_wall(b, ogx, ogy, NORTH);
} else if (real_map[gx][ogy].flags & NORTH_WALL)
bul_hit_wall(b, gx, ogy, NORTH);
} else {
/* hit north side */
if (real_map[ogx][gy].flags & NORTH_WALL) {
if (bul_hit_wall(b, ogx, gy, NORTH))
if (real_map[gx][ogy].flags & WEST_WALL)
bul_hit_wall(b, gx, ogy, EAST);
} else if (real_map[gx][gy].flags & WEST_WALL)
bul_hit_wall(b, gx, gy, EAST);
}
}
} else {
if (gy == ogy) {
/* moved west into new box */
if (real_map[ogx][ogy].flags & WEST_WALL)
bul_hit_wall(b, ogx, ogy, WEST);
} else if (gy > ogy) {
/* moved southwest into new box */
if (b->xspeed * loc->box_y > b->yspeed * (BOX_WIDTH - loc->box_x)) {
/* hit west side */
if (real_map[ogx][ogy].flags & WEST_WALL) {
if (bul_hit_wall(b, ogx, ogy, WEST))
if (real_map[ogx][gy].flags & NORTH_WALL)
bul_hit_wall(b, ogx, gy, SOUTH);
} else if (real_map[gx][gy].flags & NORTH_WALL)
bul_hit_wall(b, gx, gy, SOUTH);
} else {
/* hit south side */
if (real_map[ogx][gy].flags & NORTH_WALL) {
if (bul_hit_wall(b, ogx, gy, SOUTH))
if (real_map[ogx][ogy].flags & WEST_WALL)
bul_hit_wall(b, ogx, ogy, WEST);
} else if (real_map[ogx][gy].flags & WEST_WALL)
bul_hit_wall(b, ogx, gy, WEST);
}
} else {
/* moved northwest into new box */
if (b->xspeed * (BOX_HEIGHT - loc->box_y) >
b->yspeed * (BOX_WIDTH - loc->box_x)) {
/* hit north side */
if (real_map[ogx][ogy].flags & NORTH_WALL) {
if (bul_hit_wall(b, ogx, ogy, NORTH))
if (real_map[ogx][ogy].flags & WEST_WALL)
bul_hit_wall(b, ogx, ogy, WEST);
} else if (real_map[ogx][gy].flags & WEST_WALL)
bul_hit_wall(b, ogx, gy, WEST);
} else {
/* hit west side */
if (real_map[ogx][ogy].flags & WEST_WALL) {
if (bul_hit_wall(b, ogx, ogy, WEST))
if (real_map[ogx][ogy].flags & NORTH_WALL)
bul_hit_wall(b, gx, ogy, NORTH);
} else if (real_map[gx][ogy].flags & NORTH_WALL)
bul_hit_wall(b, ogx, ogy, NORTH);
}
}
}
}
#ifdef DESTROY_ONLY_FLYING
if ((int) b->loc->z > 4) {
#endif
if ((b->loc->grid_x > MAZE_HEIGHT + 1) ||
(b->loc->grid_y > MAZE_WIDTH + 1) ||
(b->loc->grid_x < 2) ||
(b->loc->grid_y < 2)) {
if (b->life == weapon_stat[(int) b->type].frames - 1)
b->life = -2; /* undisplayed bullet */
else
b->life = -1;
}
continue;
#ifdef DESTROY_ONLY_FLYING
}
#endif
}
}
#define LINE_BULLETS
/*
** Handles all collisions between bullets and tanks.
*/
void
coll_bullets_vehicles(void)
{
extern Bset *bset;
Bullet *b;
Vehicle *v;
Loc *bloc, *vloc;
Picture *pic;
int i, j;
int dx, dy, max_dx, max_dy;
int vehicles_flag;
int vx, vy, tx, ty; /* Should these all be float? */
for (i = 0; i < bset->number; i++) {
b = bset->list[i];
if (b->life < 0)
continue;
bloc = b->loc;
/*
* only worry about bullets down here
*/
if ((int) bloc->z > 4)
continue;
/* first see if there are any vehicles around */
/*
** get_flags(bloc,vehicles_flag);
** THIS ISN'T A MACRO BECAUSE LATTICE C's 512 BYTE MACRO LIMIT
**
** Sets flag to the logical OR of the vehicle flags of the 4
** boxes closest to the specified location.
*/
{
register int grid_x;
register int grid_y;
grid_x = bloc->grid_x;
grid_y = bloc->grid_y;
if (bloc->box_x > BOX_WIDTH / 2)
if (bloc->box_y > BOX_HEIGHT / 2)
vehicles_flag = real_map[grid_x][grid_y].flags |
real_map[grid_x + 1][grid_y].flags |
real_map[grid_x][grid_y + 1].flags |
real_map[grid_x + 1][grid_y + 1].flags;
else
vehicles_flag = real_map[grid_x][grid_y].flags |
real_map[grid_x + 1][grid_y].flags |
real_map[grid_x][grid_y - 1].flags |
real_map[grid_x + 1][grid_y - 1].flags;
else if (bloc->box_y > BOX_HEIGHT / 2)
vehicles_flag = real_map[grid_x][grid_y].flags |
real_map[grid_x - 1][grid_y].flags |
real_map[grid_x][grid_y + 1].flags |
real_map[grid_x - 1][grid_y + 1].flags;
else
vehicles_flag = real_map[grid_x][grid_y].flags |
real_map[grid_x - 1][grid_y].flags |
real_map[grid_x][grid_y - 1].flags |
real_map[grid_x - 1][grid_y - 1].flags;
vehicles_flag &= ANY_VEHICLE;
}
/*
** END OF WOULD-BE MACRO
*/
/* If there are no vehicles to collide with, exit quickly */
if (vehicles_flag == 0 || (b->owner != (Vehicle *) NULL &&
vehicles_flag == b->owner->flag && !b->hurt_owner)) {
continue;
}
for (j = 0; j < num_veh_alive; j++) {
v = live_vehicles[j];
if ((v->flag & vehicles_flag) == 0) {
continue;
}
/* He could have been killed earlier in
* this frame, but he still would be on the
* live vehicle list... (HAK)
*/
if(!tstflag(v->status, VS_is_alive))
continue;
/* If the bullet shouldn't hurt this vehicle, ignore it */
if (v == b->owner && !b->hurt_owner) {
continue;
}
/* ignore low weapons if we have hovers */
if(bloc->z < 0 && v->vdesc->treads == HOVER_TREAD
&& !((b->hit_flgs & F_HOVER) && !rnd(4)))
continue;
if(b->hit_flgs & F_NOHIT)
continue;
vloc = v->loc;
pic = &v->obj->pic[v->vector.rot];
/* Check to see if attacker's bullet is near the vehicle */
#ifdef LINE_BULLETS
{
int x1, y1, x2, y2;
x1 = b->old_loc->x - vloc->x + pic->offset_x;
x2 = bloc->x - vloc->x + pic->offset_x;
y1 = b->old_loc->y - vloc->y + pic->offset_y;
y2 = bloc->y - vloc->y + pic->offset_y;
/* line_in_rect will return the results
* of the clip calculation in x1,y1,x2,y2
* HAK 3/93
*/
if (!line_in_rect(&x1, &y1, &x2, &y2, 0, 0, pic->width, pic->height)) {
continue;
}
/* The clipping algorithm that is used by line_in_rect should
* return the point at which the bullet originally collided in
* either x1,y1 or x2,y2. Find out which using the bullet's
* x and y velocities. (HAK)
*/
if (((b->xspeed < 0) && (x2 > x1))
|| ((b->yspeed < 0) && (y2 > y1))
|| ((b->xspeed > 0) && (x2 < x1))
|| ((b->yspeed > 0) && (y2 < y1))) {
x1 = x2; y1 = y2;
}
dx = x1 - pic->offset_x;
dy = y1 - pic->offset_y;
/* A little hack... change the bullet's loc so
* make_explosion() will put the explosion in the
* right place.
*/
{
FLOAT temp;
temp = b->loc->z;
update_loc(vloc, b->loc, dx, dy);
b->loc->z = temp;
}
}
#else /*LINE_BULLETS*/
max_dx = pic->width >> 1;
max_dy = pic->height >> 1;
#ifdef SLOWER /* About 40 times slower on a 68020, on a SPARC ??? */
dx = bloc->x - vloc->x;
#else /* SLOWER */
dx = (int) bloc->x - (int) vloc->x;
#endif /* SLOWER */
if (dx < -max_dx || dx > max_dx)
continue;
#ifdef SLOWER
dy = bloc->y - vloc->y;
#else /* SLOWER */
dy = (int) bloc->y - (int) vloc->y;
#endif /* SLOWER */
if (dy < -max_dy || dy > max_dy)
continue;
/* now find the REAL location of the collision */
/* find relative velocity */
vx = b->xspeed - v->vector.xspeed;
vy = b->yspeed - v->vector.yspeed;
/* check possible adjust along both */
if ((vx != 0) && (vy != 0)) {
/* find 100 * time to reach x edge */
if (vx > 0) {
tx = (100 * (max_dx + dx)) / vx;
} else {
tx = (100 * -(max_dx - dx)) / vx;
}
/* find 100 * time to reach y edge */
if (vy > 0) {
ty = (100 * (max_dy + dy)) / vy;
} else {
ty = (100 * -(max_dy - dy)) / vy;
}
/* which hit first? */
if (tx > ty) {
/* y did; put it on y edge */
dy = SIGN(-vy) * max_dy;
dx -= (ty * vx) / 100;
} else {
/* x did; put it on x edge */
dx = SIGN(-vx) * max_dx;
dy -= (tx * vy) / 100;
}
} else {
if (vx != 0) {
dx = SIGN(-vx) * max_dx;
} else {
if (vy != 0) {
dy = SIGN(-vy) * max_dy;
}
}
}
#endif /*LINE_BULLETS*/
/* Bullet has hit the vehicle */
bul_hit_vehicle(v, b, dx, dy);
}
}
}
/*
** Handles all collisions between vehicles and other vehicles.
*/
void
coll_vehicles_vehicles(void)
{
Vehicle *v1, *v2;
Loc *v1loc, *v2loc;
Loc v1oloc, v2oloc;
Picture *pic1, *pic2;
unsigned int vehicles_flag;
float x1off, y1off, x2off, y2off;
int dx, dy, max_dx, max_dy, shx1, shy1, shx2, shy2;
int i, j, k;
for (i = 0; i < num_veh_alive - 1; i++) {
v1 = live_vehicles[i];
v1loc = v1->loc;
/* First see if there is anyone around */
/*
** get_flags(v1loc,vehicles_flag);
** THIS ISN'T A MACRO BECAUSE LATTICE C's 512 BYTE MACRO LIMIT
**
** Sets flag to the logical OR of the vehicle flags of the 4
** boxes closest to the specified location.
*/
{
register int grid_x;
register int grid_y;
grid_x = v1loc->grid_x;
grid_y = v1loc->grid_y;
if (v1loc->box_x > BOX_WIDTH / 2)
if (v1loc->box_y > BOX_HEIGHT / 2)
vehicles_flag = real_map[grid_x][grid_y].flags |
real_map[grid_x + 1][grid_y].flags |
real_map[grid_x][grid_y + 1].flags |
real_map[grid_x + 1][grid_y + 1].flags;
else
vehicles_flag = real_map[grid_x][grid_y].flags |
real_map[grid_x + 1][grid_y].flags |
real_map[grid_x][grid_y - 1].flags |
real_map[grid_x + 1][grid_y - 1].flags;
else if (v1loc->box_y > BOX_HEIGHT / 2)
vehicles_flag = real_map[grid_x][grid_y].flags |
real_map[grid_x - 1][grid_y].flags |
real_map[grid_x][grid_y + 1].flags |
real_map[grid_x - 1][grid_y + 1].flags;
else
vehicles_flag = real_map[grid_x][grid_y].flags |
real_map[grid_x - 1][grid_y].flags |
real_map[grid_x][grid_y - 1].flags |
real_map[grid_x - 1][grid_y - 1].flags;
vehicles_flag &= ANY_VEHICLE;
}
/*
** END OF WOULD-BE MACRO
*/
if ((vehicles_flag & ~v1->flag) == 0)
continue;
pic1 = &v1->obj->pic[v1->vector.rot];
for (j = i + 1; j < num_veh_alive; j++) {
v2 = live_vehicles[j];
/* See if this vehicle is nearby */
if ((vehicles_flag & v2->flag) == 0)
continue;
#define NUM_CHK 3
v2loc = v2->loc;
pic2 = &v2->obj->pic[v2->vector.rot];
v1oloc = *(v1->old_loc);
v2oloc = *(v2->old_loc);
x1off = (v1loc->x - v1oloc.x) / NUM_CHK;
y1off = (v1loc->y - v1oloc.y) / NUM_CHK;
x2off = (v2loc->x - v2oloc.x) / NUM_CHK;
y2off = (v2loc->y - v2oloc.y) / NUM_CHK;
max_dx = (pic1->width + pic2->width) >> 1;
max_dy = (pic1->height + pic2->height) >> 1;
for(k=0; k < NUM_CHK+1; k++) {
if(k) {
v1oloc.x += x1off;
v1oloc.y += y1off;
v2oloc.x += x2off;
v2oloc.y += y2off;
}
/* Check if bounding boxes overlap in x coordinates */
dx = v2oloc.x - v1oloc.x;
if (dx < -max_dx || dx > max_dx)
continue;
/* Check if bounding boxes overlap in y coordinates */
dy = v2oloc.y - v1oloc.y;
if (dy < -max_dy || dy > max_dy)
continue;
break;
}
if(k == NUM_CHK+1)
continue;
if(!k) {
dx = v2loc->x - v1loc->x;
if (dx < -max_dx || dx > max_dx)
continue;
dy = v2loc->y - v1loc->y;
if (dy < -max_dy || dy > max_dy)
continue;
}
shx2 = ((dx > 0) ? (max_dx - dx) : (-max_dx - dx)) >> 1;
shy2 = ((dy > 0) ? (max_dy - dy) : (-max_dy - dy)) >> 1;
if (ABS(shx2) < ABS(shy2))
shy2 = 0;
else
shx2 = 0;
shy1 = -shy2; shx1 = -shx2;
if(k) {
shx1 += (int)(v1oloc.x - v1loc->x);
shy1 += (int)(v1oloc.y - v1loc->y);
shx2 += (int)(v2oloc.x - v2loc->x);
shy2 += (int)(v2oloc.y - v2loc->y);
}
adjust_loc(v1->loc, shx1, shy1);
adjust_loc(v2->loc, shx2, shy2);
vehicle_hit_vehicle(v1, v2, max_dx, max_dy, dx, dy);
}
}
}
| 27.867021 | 78 | 0.58828 | [
"vector"
] |
13dea03d9b10bc3f5343bea83a9390a67340a9b8 | 5,715 | h | C | Nesis/Common/CanUnitInfo/UnitInfoBase.h | jpoirier/x-gauges | 8261b19a9678ad27db44eb8c354f5e66bd061693 | [
"BSD-3-Clause"
] | 3 | 2015-11-08T07:17:46.000Z | 2019-04-05T17:08:05.000Z | Nesis/Common/CanUnitInfo/UnitInfoBase.h | jpoirier/x-gauges | 8261b19a9678ad27db44eb8c354f5e66bd061693 | [
"BSD-3-Clause"
] | null | null | null | Nesis/Common/CanUnitInfo/UnitInfoBase.h | jpoirier/x-gauges | 8261b19a9678ad27db44eb8c354f5e66bd061693 | [
"BSD-3-Clause"
] | null | null | null | #ifndef UNIT_INFO_BASE_H
#define UNIT_INFO_BASE_H
/***************************************************************************
* *
* Copyright (C) 2008 by Kanardia d.o.o. [see www.kanardia.eu] *
* Writen by: *
* Ales Krajnc [ales.krajnc@kanardia.eu] *
* *
* Status: Open Source *
* *
* Licence: GPL - GNU General Public License *
* See 'COPYING.html' for more details about the license. *
* *
***************************************************************************/
#include <QObject>
#include <QVector>
#include <QTime>
#include <QDomElement>
#include "Matrix/Matrix.h"
#include "JulianDay.h"
#include "CanAerospace/AbstractAerospaceDataManager.h"
// ------------------------------------------------------------------------
//#define TAG_VERSION "version"
// ------------------------------------------------------------------------
namespace can {
// ------------------------------------------------------------------------
class UnitInfoBase
{
public:
//! Constructor
UnitInfoBase(uint8_t byNodeId=0, uint8_t byHwId=0,
uint32_t uiSerial=0, common::JulianDay jdDate=common::JulianDay());
//! Copy constructor
UnitInfoBase(const UnitInfoBase& C);
//! Destructor
virtual ~UnitInfoBase();
//! Return Node id.
uint8_t GetNodeId() const { return m_byNodeId; }
//! Set new node id.
void SetNodeId(uint8_t byNewId)
{ m_byNodeId = byNewId; }
//! Return Original node id.
uint8_t GetHardwareId() const { return m_byHardwareId; }
//! Set original node id.
void SetHardwareId(uint8_t byHWId)
{ m_byHardwareId = byHWId; }
//! Return serial number.
uint32_t GetSerial() const { return m_uiSerial; }
//! Set serial number
void SetSerial(uint32_t uiSerial)
{ m_uiSerial = uiSerial; }
//! Set the date in JulianDay format.
void SetDate(common::JulianDay jdDate)
{ m_jdDate = jdDate; }
//! Return date when serial number was burned.
common::JulianDay GetDate() const { return m_jdDate; }
//! Set version (it containes both, sw and hw version)
void SetVersion(uint16_t uiVersions);
//! Get hardware version.
uint8_t GetHardwareVersion() const
{ return m_byHWVersion; }
//! Get software version.
uint8_t GetSoftwareVersion() const
{ return m_bySWVersion; }
//! Get hardware version formated as string (x.x).
QString GetHardwareVersionString() const;
//! Get software version formated as string (x.x).
QString GetSoftwareVersionString() const;
//! Get vendor number - this is a kind of cryptic id.
uint32_t GetVendorNumber() const
{ return m_uiVendorNumber; }
//! Set vendor number.
void SetVendorNumber(uint32_t uiVN)
{ m_uiVendorNumber = uiVN; }
//! Set SVN revision.
void SetSVN(uint32_t uiSVN)
{ m_uiSVN = uiSVN; }
//! Get SVN revision. This is from CAN.
uint32_t GetSVN() const
{ return m_uiSVN; }
//! Update the sign of life status. We may also request some info.
virtual void UpdateSignOfLife(AbstractAerospaceDataManager *pADM);
//! Time since the last sign of life call.
int GetTimeSinceSignOfLife() const;
//! Is it a valid object?
virtual bool IsValid() const;
//! Static wait function.
static void Wait(can::AbstractAerospaceDataManager* m_pADM, qint32 msToWait);
#if defined (USE_CAN_DUS_A)
//! Store uploading message.
bool StoreUploadMessage(const can::MessageAerospace& msg);
#endif
#if defined (USE_CAN_DDS_A)
//! Do the download service for this node.
virtual bool Download(can::AbstractAerospaceDataManager* pADM,
uint32_t uiDwnDataId, const QVector<float>& vData);
//! Get proper value from the download buffer.
virtual bool GetDownloadData(uint8_t byIndex, can::DataType& eDataType, can::Register& rData);
#endif
//! Derive classes may process responce from the Module Configuration Service.
virtual void ProcessModuleConfigResponse(const can::MessageAerospace& msg);
//! Process MIS response
virtual void ProcessModuleInfoResponse(const can::MessageAerospace& msg);
protected:
#if defined (USE_CAN_DUS_A)
//! The upload service which takes vector of floats.
bool Upload(can::AbstractAerospaceDataManager* pADM, uint32_t uiUplDataId, QVector<float>& vData, int iSize=0);
//! Do the upload service. The receiving buffer must be set by the caller.
virtual bool Upload(can::AbstractAerospaceDataManager* pADM, uint32_t uiUplDataId);
#endif
#if defined (USE_CAN_DDS_A)
//! Do the download service for this node.
virtual bool Download(can::AbstractAerospaceDataManager* pADM, uint32_t uiDwnDataId);
#endif
protected:
//! Node id
uint8_t m_byNodeId;
//! Original node id
uint8_t m_byHardwareId;
//! Date when the serial was created.
common::JulianDay m_jdDate;
//! Serial number (0 means no number).
uint32_t m_uiSerial;
//! Hardware version
uint8_t m_byHWVersion;
//! Software version
uint8_t m_bySWVersion;
//! Vendor number
uint32_t m_uiVendorNumber;
//! SVN revision
uint32_t m_uiSVN;
//! Upload transfer buffer
QVector<can::Register> m_vUploadBuffer;
//! Download transfer buffer
QVector<can::Register> m_vDownloadBuffer;
//! Current download data type
can::DataType m_eDataType;
//! Time of the last "SignOfLive" message.
QTime m_tLastSOL;
};
// --------------------------------------------------------------------------
} // namespace
#endif
| 32.471591 | 112 | 0.613298 | [
"object",
"vector"
] |
13e30e691bfe4cb3e28d4776d695d664e82b9c1d | 1,060 | h | C | src/services/pcn-loadbalancer-dsr/src/serializer/BackendJsonObject.h | francescomessina/polycube | 38f2fb4ffa13cf51313b3cab9994be738ba367be | [
"ECL-2.0",
"Apache-2.0"
] | 337 | 2018-12-12T11:50:15.000Z | 2022-03-15T00:24:35.000Z | src/services/pcn-loadbalancer-dsr/src/serializer/BackendJsonObject.h | l1b0k/polycube | 7af919245c131fa9fe24c5d39d10039cbb81e825 | [
"ECL-2.0",
"Apache-2.0"
] | 253 | 2018-12-17T21:36:15.000Z | 2022-01-17T09:30:42.000Z | src/services/pcn-loadbalancer-dsr/src/serializer/BackendJsonObject.h | l1b0k/polycube | 7af919245c131fa9fe24c5d39d10039cbb81e825 | [
"ECL-2.0",
"Apache-2.0"
] | 90 | 2018-12-19T15:49:38.000Z | 2022-03-27T03:56:07.000Z | /**
* lbdsr API
* lbdsr API generated from lbdsr.yang
*
* OpenAPI spec version: 1.0.0
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/polycube-network/swagger-codegen.git
* branch polycube
*/
/* Do not edit this file manually */
/*
* BackendJsonObject.h
*
*
*/
#pragma once
#include "JsonObjectBase.h"
#include "BackendPoolJsonObject.h"
#include <vector>
namespace io {
namespace swagger {
namespace server {
namespace model {
/// <summary>
///
/// </summary>
class BackendJsonObject : public JsonObjectBase {
public:
BackendJsonObject();
BackendJsonObject(const nlohmann::json &json);
~BackendJsonObject() final = default;
nlohmann::json toJson() const final;
/// <summary>
/// pool of backend servers serving requests
/// </summary>
const std::vector<BackendPoolJsonObject>& getPool() const;
void addBackendPool(BackendPoolJsonObject value);
bool poolIsSet() const;
void unsetPool();
private:
std::vector<BackendPoolJsonObject> m_pool;
bool m_poolIsSet;
};
}
}
}
}
| 16.5625 | 75 | 0.712264 | [
"vector",
"model"
] |
13e6590f627833a6d107994aed758b0bb9aad3f7 | 10,614 | c | C | cras/src/server/cras_bt_battery_provider.c | dgreid/adhd | 3b124e06ef9a563cc7c9eb6a9888aa9b68654c7e | [
"BSD-1-Clause",
"BSD-3-Clause"
] | 1 | 2021-03-08T11:49:58.000Z | 2021-03-08T11:49:58.000Z | cras/src/server/cras_bt_battery_provider.c | dgreid/adhd | 3b124e06ef9a563cc7c9eb6a9888aa9b68654c7e | [
"BSD-1-Clause",
"BSD-3-Clause"
] | 1 | 2021-03-23T18:17:08.000Z | 2021-03-23T18:17:08.000Z | cras/src/server/cras_bt_battery_provider.c | dgreid/adhd | 3b124e06ef9a563cc7c9eb6a9888aa9b68654c7e | [
"BSD-1-Clause",
"BSD-3-Clause"
] | 1 | 2016-10-19T08:33:40.000Z | 2016-10-19T08:33:40.000Z | /* Copyright 2020 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include <dbus/dbus.h>
#include <errno.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include "cras_bt_adapter.h"
#include "cras_bt_battery_provider.h"
#include "cras_bt_constants.h"
#include "cras_dbus_util.h"
#include "cras_observer.h"
#include "utlist.h"
/* CRAS registers one battery provider to BlueZ, so we use a singleton. */
static struct cras_bt_battery_provider battery_provider = {
.object_path = CRAS_DEFAULT_BATTERY_PROVIDER,
.interface = BLUEZ_INTERFACE_BATTERY_PROVIDER,
.conn = NULL,
.is_registered = false,
.observer = NULL,
.batteries = NULL,
};
static int cmp_battery_address(const struct cras_bt_battery *battery,
const char *address)
{
return strcmp(battery->address, address);
}
static void replace_colon_with_underscore(char *str)
{
for (int i = 0; str[i]; i++) {
if (str[i] == ':')
str[i] = '_';
}
}
/* Converts address XX:XX:XX:XX:XX:XX to Battery Provider object path:
* /org/chromium/Cras/Bluetooth/BatteryProvider/XX_XX_XX_XX_XX_XX
*/
static char *address_to_battery_path(const char *address)
{
char *object_path = malloc(strlen(CRAS_DEFAULT_BATTERY_PROVIDER) +
strlen(address) + 2);
sprintf(object_path, "%s/%s", CRAS_DEFAULT_BATTERY_PROVIDER, address);
replace_colon_with_underscore(object_path);
return object_path;
}
/* Converts address XX:XX:XX:XX:XX:XX to device object path:
* /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX
*/
static char *address_to_device_path(const char *address)
{
char *object_path = malloc(strlen(CRAS_DEFAULT_BATTERY_PREFIX) +
strlen(address) + 1);
sprintf(object_path, "%s%s", CRAS_DEFAULT_BATTERY_PREFIX, address);
replace_colon_with_underscore(object_path);
return object_path;
}
static struct cras_bt_battery *battery_new(const char *address, uint32_t level)
{
struct cras_bt_battery *battery;
battery = calloc(1, sizeof(struct cras_bt_battery));
battery->address = strdup(address);
battery->object_path = address_to_battery_path(address);
battery->device_path = address_to_device_path(address);
battery->level = level;
return battery;
}
static void battery_free(struct cras_bt_battery *battery)
{
if (battery->address)
free(battery->address);
if (battery->object_path)
free(battery->object_path);
if (battery->device_path)
free(battery->device_path);
free(battery);
}
static void populate_battery_properties(DBusMessageIter *iter,
const struct cras_bt_battery *battery)
{
DBusMessageIter dict, entry, variant;
const char *property_percentage = "Percentage";
const char *property_device = "Device";
uint8_t level = battery->level;
dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, "{sv}", &dict);
dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL,
&entry);
dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING,
&property_percentage);
dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
DBUS_TYPE_BYTE_AS_STRING, &variant);
dbus_message_iter_append_basic(&variant, DBUS_TYPE_BYTE, &level);
dbus_message_iter_close_container(&entry, &variant);
dbus_message_iter_close_container(&dict, &entry);
dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL,
&entry);
dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING,
&property_device);
dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
DBUS_TYPE_OBJECT_PATH_AS_STRING,
&variant);
dbus_message_iter_append_basic(&variant, DBUS_TYPE_OBJECT_PATH,
&battery->device_path);
dbus_message_iter_close_container(&entry, &variant);
dbus_message_iter_close_container(&dict, &entry);
dbus_message_iter_close_container(iter, &dict);
}
/* Creates a new battery object and exposes it on D-Bus. */
static struct cras_bt_battery *
get_or_create_battery(struct cras_bt_battery_provider *provider,
const char *address, uint32_t level)
{
struct cras_bt_battery *battery;
DBusMessage *msg;
DBusMessageIter iter, dict, entry;
LL_SEARCH(provider->batteries, battery, address, cmp_battery_address);
if (battery)
return battery;
syslog(LOG_DEBUG, "Creating new battery for %s", address);
battery = battery_new(address, level);
LL_APPEND(provider->batteries, battery);
msg = dbus_message_new_signal(CRAS_DEFAULT_BATTERY_PROVIDER,
DBUS_INTERFACE_OBJECT_MANAGER,
DBUS_SIGNAL_INTERFACES_ADDED);
dbus_message_iter_init_append(msg, &iter);
dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
&battery->object_path);
dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sa{sv}}",
&dict);
dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL,
&entry);
dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING,
&provider->interface);
populate_battery_properties(&entry, battery);
dbus_message_iter_close_container(&dict, &entry);
dbus_message_iter_close_container(&iter, &dict);
if (!dbus_connection_send(provider->conn, msg, NULL)) {
syslog(LOG_ERR,
"Error sending " DBUS_SIGNAL_INTERFACES_ADDED " signal");
}
dbus_message_unref(msg);
return battery;
}
/* Updates the level of a battery object and signals it on D-Bus. */
static void
update_battery_level(const struct cras_bt_battery_provider *provider,
struct cras_bt_battery *battery, uint32_t level)
{
DBusMessage *msg;
DBusMessageIter iter;
if (battery->level == level)
return;
battery->level = level;
msg = dbus_message_new_signal(battery->object_path,
DBUS_INTERFACE_PROPERTIES,
DBUS_SIGNAL_PROPERTIES_CHANGED);
dbus_message_iter_init_append(msg, &iter);
dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING,
&provider->interface);
populate_battery_properties(&iter, battery);
if (!dbus_connection_send(provider->conn, msg, NULL)) {
syslog(LOG_ERR, "Error sending " DBUS_SIGNAL_PROPERTIES_CHANGED
" signal");
}
dbus_message_unref(msg);
}
/* Invoked when HFP sends an alert about a battery value change. */
static void on_bt_battery_changed(void *context, const char *address,
uint32_t level)
{
struct cras_bt_battery_provider *provider = context;
syslog(LOG_DEBUG, "Battery changed for address %s, level %d", address,
level);
if (!provider->is_registered) {
syslog(LOG_WARNING, "Received battery level update while "
"battery provider is not registered");
return;
}
struct cras_bt_battery *battery =
get_or_create_battery(provider, address, level);
update_battery_level(provider, battery, level);
}
/* Invoked when we receive a D-Bus return of RegisterBatteryProvider from
* BlueZ.
*/
static void
cras_bt_on_battery_provider_registered(DBusPendingCall *pending_call,
void *data)
{
DBusMessage *reply;
struct cras_bt_battery_provider *provider = data;
struct cras_observer_ops observer_ops;
reply = dbus_pending_call_steal_reply(pending_call);
dbus_pending_call_unref(pending_call);
if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) {
syslog(LOG_ERR, "RegisterBatteryProvider returned error: %s",
dbus_message_get_error_name(reply));
dbus_message_unref(reply);
return;
}
syslog(LOG_INFO, "RegisterBatteryProvider succeeded");
provider->is_registered = true;
memset(&observer_ops, 0, sizeof(observer_ops));
observer_ops.bt_battery_changed = on_bt_battery_changed;
provider->observer = cras_observer_add(&observer_ops, provider);
dbus_message_unref(reply);
}
int cras_bt_register_battery_provider(DBusConnection *conn,
const struct cras_bt_adapter *adapter)
{
const char *adapter_path;
DBusMessage *method_call;
DBusMessageIter message_iter;
DBusPendingCall *pending_call;
if (battery_provider.is_registered) {
syslog(LOG_ERR, "Battery Provider already registered");
return -EBUSY;
}
if (battery_provider.conn)
dbus_connection_unref(battery_provider.conn);
battery_provider.conn = conn;
dbus_connection_ref(battery_provider.conn);
adapter_path = cras_bt_adapter_object_path(adapter);
method_call = dbus_message_new_method_call(
BLUEZ_SERVICE, adapter_path,
BLUEZ_INTERFACE_BATTERY_PROVIDER_MANAGER,
"RegisterBatteryProvider");
if (!method_call)
return -ENOMEM;
dbus_message_iter_init_append(method_call, &message_iter);
dbus_message_iter_append_basic(&message_iter, DBUS_TYPE_OBJECT_PATH,
&battery_provider.object_path);
if (!dbus_connection_send_with_reply(conn, method_call, &pending_call,
DBUS_TIMEOUT_USE_DEFAULT)) {
dbus_message_unref(method_call);
return -ENOMEM;
}
dbus_message_unref(method_call);
if (!pending_call)
return -EIO;
if (!dbus_pending_call_set_notify(
pending_call, cras_bt_on_battery_provider_registered,
&battery_provider, NULL)) {
dbus_pending_call_cancel(pending_call);
dbus_pending_call_unref(pending_call);
return -ENOMEM;
}
return 0;
}
/* Removes a battery object and signals the removal on D-Bus as well. */
static void cleanup_battery(struct cras_bt_battery_provider *provider,
struct cras_bt_battery *battery)
{
DBusMessage *msg;
DBusMessageIter iter, entry;
if (!battery)
return;
LL_DELETE(provider->batteries, battery);
msg = dbus_message_new_signal(CRAS_DEFAULT_BATTERY_PROVIDER,
DBUS_INTERFACE_OBJECT_MANAGER,
DBUS_SIGNAL_INTERFACES_REMOVED);
dbus_message_iter_init_append(msg, &iter);
dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
&battery->object_path);
dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
DBUS_TYPE_STRING_AS_STRING, &entry);
dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING,
&provider->interface);
dbus_message_iter_close_container(&iter, &entry);
if (!dbus_connection_send(provider->conn, msg, NULL)) {
syslog(LOG_ERR, "Error sending " DBUS_SIGNAL_INTERFACES_REMOVED
" signal");
}
dbus_message_unref(msg);
battery_free(battery);
}
void cras_bt_battery_provider_reset()
{
struct cras_bt_battery *battery;
syslog(LOG_INFO, "Resetting battery provider");
if (!battery_provider.is_registered)
return;
battery_provider.is_registered = false;
LL_FOREACH (battery_provider.batteries, battery) {
cleanup_battery(&battery_provider, battery);
}
if (battery_provider.conn) {
dbus_connection_unref(battery_provider.conn);
battery_provider.conn = NULL;
}
if (battery_provider.observer) {
cras_observer_remove(battery_provider.observer);
battery_provider.observer = NULL;
}
}
| 28.532258 | 79 | 0.764274 | [
"object"
] |
13ed8737fd6a781d20187b80a344b058fb77c0b4 | 2,711 | c | C | StreamServiceUI/StreamServiceUI/AppWindow.c | spark83/StreamServiceFrontPageExample | 369129405b84484eb8b48a40e2f1faf7bbcd3866 | [
"BSD-3-Clause"
] | null | null | null | StreamServiceUI/StreamServiceUI/AppWindow.c | spark83/StreamServiceFrontPageExample | 369129405b84484eb8b48a40e2f1faf7bbcd3866 | [
"BSD-3-Clause"
] | null | null | null | StreamServiceUI/StreamServiceUI/AppWindow.c | spark83/StreamServiceFrontPageExample | 369129405b84484eb8b48a40e2f1faf7bbcd3866 | [
"BSD-3-Clause"
] | null | null | null | /*
*! \brief Creates an application window, and provides update callback with
* system key input events.
*! \author Sang Park
*! \date Oct 2021
*/
#include <gl\glew.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include <SDL.h>
#include "Logging/logger.h"
#include "Types.h"
#include "AppWindow.h"
#ifdef __cplusplus
extern "C" {
#endif
static void RunAppWindow(SDLAppWindow* window) {
window->app_running = 1;
while (window->app_running) {
window->app_running =
window->on_update_callback(window, window->user_data);
}
}
static void SwapWindow(SDLAppWindow* window) {
SDL_GL_SwapWindow(window->window);
}
s8 InitWindow(SDLAppWindow* window, u16 width, u16 height, u8 fullscreen,
const s8* name, void* user, OnUpdate callback) {
s8 ret = 1;
SDL_WindowFlags screen_type_flags = SDL_WINDOW_SHOWN;
window->width = width;
window->height = height;
window->fullscreen = fullscreen;
window->app_running = 0;
window->on_update_callback = callback;
window->user_data = user;
window->RunAppWindow = RunAppWindow;
window->SwapWindow = SwapWindow;
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
LOG_ERROR("Fail to initalize SDL! SDL Error: %s\n", SDL_GetError());
ret = 0;
}
// TODO: Update this to support lower versions of OpenGL ES since only OpenGLES
// are supported on setup boxes.
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 6);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
if (fullscreen) {
screen_type_flags = SDL_WINDOW_FULLSCREEN;
}
window->window =
SDL_CreateWindow(name, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
width, height, SDL_WINDOW_OPENGL | screen_type_flags);
if (!window->window) {
LOG_ERROR("Window could not be created! SDL Error: %s\n", SDL_GetError());
ret = 0;
}
else {
window->context = SDL_GL_CreateContext(window->window);
if (!window->context) {
LOG_ERROR("OpenGL context could not be created! SDL Error: %s\n", SDL_GetError());
ret = 0;
}
else {
glewExperimental = GL_TRUE;
GLenum glewError = glewInit();
if (glewError != GLEW_OK) {
LOG_ERROR("Error initializing GLEW! %s\n", glewGetErrorString(glewError));
}
// Vsync setting. Make sure they sync with the screen frame rate to make sure we don't
// render more than necessary.
if (SDL_GL_SetSwapInterval(1) < 0) {
LOG_ERROR("Warning: Unable to set VSync! SDL Error: %s\n", SDL_GetError());
}
}
}
// TODO: Create input structure to handle the input setting.
return ret;
}
void ReleaseWindow(SDLAppWindow* window) {
SDL_DestroyWindow(window->window);
SDL_Quit();
window->window = NULL;
}
#ifdef __cplusplus
}
#endif
| 26.067308 | 90 | 0.718923 | [
"render"
] |
13f58fbd10c2d042984d87e9688f9b8054dec3d9 | 17,441 | h | C | include/motive/vector_motivator.h | google/motive | 8e6e850de1f645a690920eaaaa6e6e57ca934cc4 | [
"Apache-2.0"
] | 210 | 2015-04-09T19:26:48.000Z | 2022-02-08T12:49:13.000Z | include/motive/vector_motivator.h | google/motive | 8e6e850de1f645a690920eaaaa6e6e57ca934cc4 | [
"Apache-2.0"
] | 1 | 2019-05-11T05:20:51.000Z | 2019-05-11T05:20:51.000Z | include/motive/vector_motivator.h | google/motive | 8e6e850de1f645a690920eaaaa6e6e57ca934cc4 | [
"Apache-2.0"
] | 53 | 2015-04-12T01:52:38.000Z | 2022-01-17T00:12:15.000Z | // Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MOTIVE_VECTOR_MOTIVATOR_H_
#define MOTIVE_VECTOR_MOTIVATOR_H_
#include "motive/motivator.h"
#include "motive/vector_processor.h"
namespace motive {
/// @class MotivatorNfBase
/// @brief Animate an array of N-floats, where N is set by the `dimension` in
/// the constructor.
class MotivatorNf : public Motivator {
public:
/// Motivator is created in a reset state. When in the reset state,
/// it is not being driven, and Value(), Velocity(), etc. cannot be called.
MotivatorNf() {}
/// Initialize to the motion algorithm specified by `init`.
/// Current and target values are not set.
MotivatorNf(const MotivatorInit& init, MotiveEngine* engine,
MotiveDimension dimensions)
: Motivator(init, engine, dimensions) {}
/// Initialize to the motion algorithm specified by `init`.
/// Set current and target values as specified by `ts`.
MotivatorNf(const MotivatorInit& init, MotiveEngine* engine,
MotiveDimension dimensions, const MotiveTarget1f* ts)
: Motivator(init, engine, dimensions) {
SetTargets(ts);
}
/// Initialize this Motivator to the type specified in init.type.
/// @param init Defines the type and initial state of the Motivator.
/// @param engine The engine that will update this Motivator when
/// engine->AdvanceFrame() is called.
/// @param dimensions The number of slots to occupy. For example, a 3D
/// position would occupy three slots.
void Initialize(const MotivatorInit& init, MotiveEngine* engine,
MotiveDimension dimensions) {
InitializeWithDimension(init, engine, dimensions);
}
/// Initialize to the motion algorithm specified by `init`.
/// Set current and target values as specified by `targets`, an array of
/// length `dimensions`.
void InitializeWithTargets(const MotivatorInit& init, MotiveEngine* engine,
MotiveDimension dimensions,
const MotiveTarget1f* targets) {
Initialize(init, engine, dimensions);
SetTargets(targets);
}
/// Initialize to the motion algorithm specified by `init`.
/// Set target values and velocities as specified by 'target_values' and
/// 'target_velocities', arrays of length `dimensions`, with shape specified
/// by 'shape'.
void InitializeWithTargetShape(const MotivatorInit& init,
MotiveEngine* engine,
MotiveDimension dimensions,
const MotiveCurveShape& shape,
const float* target_values,
const float* target_velocities) {
InitializeWithDimension(init, engine, dimensions);
SetTargetWithShape(target_values, target_velocities, shape);
}
/// Initialize to the motion algorithm specified by `init`.
/// Set movement to follow the curves specified in `splines`, an array of
/// length `dimensions, and modified by `playback`.
void InitializeWithSplines(const MotivatorInit& init, MotiveEngine* engine,
MotiveDimension dimensions,
const CompactSpline* splines,
const SplinePlayback& playback) {
Initialize(init, engine, dimensions);
SetSplines(splines, playback);
}
// Get array of length `dimensions`.
const float* Values() const { return Processor().Values(index_); }
void Velocities(float* out) const {
return Processor().Velocities(index_, Dimensions(), out);
}
void Directions(float* out) const {
return Processor().Directions(index_, Dimensions(), out);
}
void TargetValues(float* out) const {
return Processor().TargetValues(index_, Dimensions(), out);
}
void TargetVelocities(float* out) const {
return Processor().TargetVelocities(index_, Dimensions(), out);
}
void Differences(float* out) const {
return Processor().Differences(index_, Dimensions(), out);
}
/// Returns time remaining until target is reached.
/// The unit of time is determined by the calling program.
MotiveTime TargetTime() const {
return Processor().TargetTime(index_, Dimensions());
}
/// Returns the shape of the current curve.
MotiveCurveShape MotiveShape() const {
return Processor().MotiveShape(index_);
}
/// Returns the current time (i.e. the x-value) in the current spline.
/// If Motivator is not being driven by a spline, returns 0.
/// Whenever SetSpline() is called, this value will be reset to the
/// start_time specified in SplinePlayback. Every time
/// MotiveEngine::AdvanceFrame() is called, it will increment by
/// `delta_time` * `playback_rate`. If the SplinePlayback has repeat=true,
/// then SplineTime() will periodically loop back to time 0.
MotiveTime SplineTime() const { return Processor().SplineTime(index_); }
/// Gather pointers to the splines currently being played, on each dimension.
/// @param splines Output array of length Dimensions().
void Splines(const CompactSpline** splines) const {
Processor().Splines(index_, Dimensions(), splines);
}
/// Follow the curve specified in `spline`. Overrides the existing current
/// value.
/// @param spline The spline to follow. Array of length Dimensions().
/// @param playback The time into the splines to initiate playback,
/// the blend time to the splines, and whether to repeat
/// from the beginning after the end of the spline is reached.
void SetSpline(const CompactSpline& spline, const SplinePlayback& playback) {
assert(Dimensions() == 1);
Processor().SetSplines(index_, Dimensions(), &spline, playback);
}
/// Follow the curves specified in `splines`. Overrides the existing current
/// value.
/// @param splines The splines that the curves should follow.
/// Array of length Dimensions().
/// @param playback The time into the splines to initiate playback,
/// the blend time to the splines, and whether to repeat
/// from the beginning after the end of the spline is reached.
void SetSplines(const CompactSpline* splines,
const SplinePlayback& playback) {
Processor().SetSplines(index_, Dimensions(), splines, playback);
}
/// Seek to a specific time in the spline.
/// @param time The time (in the spline's x-axis) to seek to.
void SetSplineTime(MotiveTime time) {
Processor().SetSplineTime(index_, Dimensions(), time);
}
/// Set rate at which we consume the spline set in SetSpline().
/// 0 ==> paused
/// 0.5 ==> half speed (slow motion)
/// 1 ==> authored speed
/// 2 ==> double speed (fast forward)
void SetSplinePlaybackRate(float playback_rate) {
Processor().SetSplinePlaybackRate(index_, Dimensions(), playback_rate);
}
/// Set the repeat state for the spline set in SetSpline().
void SetSplineRepeating(bool repeat) {
Processor().SetSplineRepeating(index_, Dimensions(), repeat);
}
/// Set the target and (optionally the current) motivator values.
/// Use this call to procedurally drive the Motivator towards a specific
/// target. The Motivator will transition smoothly to the new target.
/// @param targets The targets that each value should achieve.
/// An array of length Dimensions().
void SetTargets(const MotiveTarget1f* targets) {
Processor().SetTargets(index_, Dimensions(), targets);
}
/// Set the target values, velocities, and curve shape for the motivator.
/// Procedurally drive the Motivator to 'target_values' and
/// 'target_velocities' following a curve defined by 'shape'.
/// Setting the target with the shape makes it so that a time does not need
/// to be specified, as it will be calculated. In contrast, if the time needed
/// to achieve a value is to be user-provided, @ref SetTarget should be used
/// instead.
/// @param target_value Array of target values with length Dimensions.
/// @param target_velocity Array of target velocities with length Dimensions.
/// @param shape The shape of the curve we'll create, as determined by the
/// curve's typical delta value, typical total time, and bias.
void SetTargetWithShape(const float* target_values,
const float* target_velocities,
const MotiveCurveShape& shape) {
Processor().SetTargetWithShape(index_, Dimensions(), target_values,
target_velocities, shape);
}
/// Drive some channels with splines and others with targets.
/// For i between 0 and Dimensions()-1, if splines[i] != NULL drive
/// channel i with splines[i]. Otherwise, drive channel i with targets[i].
/// @param splines Array of pointers to splines, length Dimensions().
/// Pointers can be NULL.
/// @param playback Various parameters for `splines`.
/// @param targets Array of targets that are used when splines are not
/// specified. Length Dimensions().
void SetSplinesAndTargets(const CompactSpline* const* splines,
const SplinePlayback& playback,
const MotiveTarget1f* targets) {
Processor().SetSplinesAndTargets(index_, Dimensions(), splines, playback,
targets);
}
protected:
MotiveProcessorNf& Processor() {
return *static_cast<MotiveProcessorNf*>(processor_);
}
const MotiveProcessorNf& Processor() const {
return *static_cast<const MotiveProcessorNf*>(processor_);
}
};
/// @class MotivatorXfTemplate
/// @brief Animate a vector of floating-point values.
///
/// Wraps `MotivatorNf` to return by value, instead of using `out` arrays.
/// For `kDimension = 1`, the vector type is just `float`.
/// For `kDimension > 1`, the vector type is determined by `VectorConverter`.
/// We use `MathFuVectorConverter` below to create 2, 3, and 4 dimensional
/// motivators (see Motivator2f, Motivator3f, and Motivator4f).
/// You can use your own VectorConverter to create Motivators of that match
/// your vector types.
///
template <class VectorConverter, MotiveDimension kDimensionsParam>
class MotivatorXfTemplate : public MotivatorNf {
public:
typedef VectorConverter C;
static const MotiveDimension kDimensions = kDimensionsParam;
typedef typename VectorT<C, kDimensions>::type Vec;
typedef typename MotiveTargetT<kDimensions>::type Target;
typedef MotiveTargetBuilderTemplate<C, kDimensions> TargetBuilder;
/// Motivator is created in a reset state. When in the reset state,
/// it is not being driven, and Value(), Velocity(), etc. cannot be called.
MotivatorXfTemplate() {}
/// Initialize to the motion algorithm specified by `init`.
/// Current and target values are not set.
MotivatorXfTemplate(const MotivatorInit& init, MotiveEngine* engine)
: MotivatorNf(init, engine, kDimensions) {}
/// Initialize to the motion algorithm specified by `init`.
/// Set current and target values as specified by `t`.
MotivatorXfTemplate(const MotivatorInit& init, MotiveEngine* engine,
const Target& t)
: MotivatorNf(init, engine, kDimensions) {
SetTarget(t);
}
/// Initialize to the motion algorithm specified by `init`.
void Initialize(const MotivatorInit& init, MotiveEngine* engine) {
InitializeWithDimension(init, engine, kDimensions);
}
/// Initialize to the motion algorithm specified by `init`.
/// Set current and target values as specified by `t`.
void InitializeWithTarget(const MotivatorInit& init, MotiveEngine* engine,
const Target& t) {
InitializeWithDimension(init, engine, kDimensions);
SetTarget(t);
}
/// Initialize to the motion algorithm specified by `init`.
/// Set target values and velocities as specified by 'target_values' and
/// 'target_velocities', arrays of length `dimensions`, with shape specified
/// by 'shape'.
void InitializeWithTargetShape(const MotivatorInit& init,
MotiveEngine* engine,
MotiveDimension dimensions,
const MotiveCurveShape& shape,
const Vec& target_values,
const Vec& target_velocities) {
InitializeWithDimension(init, engine, dimensions);
SetTargetWithShape(target_values, target_velocities, shape);
}
/// Returns the current motivator value. The current value is updated when
/// engine->AdvanceFrame() is called on the `engine` that initialized this
/// Motivator.
/// Note that the "Vec()" parameter is just a syntactic hack used to access
/// the correct overloaded function in the processor.
Vec Value() const { return C::FromPtr(Processor().Values(index_), Vec()); }
/// Returns the current rate of change of this motivator. For example,
/// if this Motivator is being driven by a spline, returns the derivative
/// at the current time in the spline curve.
Vec Velocity() const {
Vec r;
Processor().Velocities(index_, kDimensions, C::ToPtr(r));
return r;
}
/// Returns the velocity when playback rate is 1. Useful to know the
/// direction of a multi-dimensional motivator, even when playback rate
/// is 0.
Vec Direction() const {
Vec r;
Processor().Directions(index_, kDimensions, C::ToPtr(r));
return r;
}
/// Returns the value this Motivator is driving towards.
/// If being driven by a spline, returns the value at the end of the spline.
Vec TargetValue() const {
Vec r;
Processor().TargetValues(index_, kDimensions, C::ToPtr(r));
return r;
}
/// Returns the rate-of-change of this Motivator once it reaches
/// TargetValue().
Vec TargetVelocity() const {
Vec r;
Processor().TargetVelocities(index_, kDimensions, C::ToPtr(r));
return r;
}
/// Returns TargetValue() minus Value(). If we're driving a
/// modular type (e.g. an angle), this may not be the naive subtraction.
/// For example, if TargetValue() = 170 degrees, Value() = -170 degrees,
/// then Difference() = -20 degrees.
Vec Difference() const {
Vec r;
Processor().Differences(index_, kDimensions, C::ToPtr(r));
return r;
}
/// Set the target and (optionally the current) motivator values.
/// Use this call to procedurally drive the Motivator towards a specific
/// target. The Motivator will transition smoothly to the new target.
/// You can change the target value every frame if you like, and the
/// Motivator value should behave calmly but responsively, with the
/// movement qualities of the underlying MotiveProcessor.
/// Note that the underlying MotiveProcessor is allowed to ignore
/// parts of `t` that are irrelevent to its algorithm.
/// Note also that if the time needed to achieve a value is to be
/// user-provided, this function should be used. If the time should
/// be calculated instead of user-specified, @ref SetTargetWithShape
/// should be used instead.
/// @param t A set of waypoints to hit, optionally including the current
/// value. If the current value is not included, maintain the
/// existing current value.
void SetTarget(const Target& t) {
Processor().SetTargets(index_, kDimensions, t.targets());
}
/// Set the target values, velocity, and curve shape for the motivator.
/// Use this call to procedurally drive the Motivator towards that target.
/// Setting the target with the shape makes it so that a time does not need
/// to be specified, as it will be calculated. In contrast, if the time needed
/// to achieve a value is to be user-provided, @ref SetTarget should be used
/// instead.
/// @param target_value The target value to hit.
/// @param target_velocity The velocity with which to hit the target value.
/// @param shape The shape of the curve we'll create, such as the curve's
/// typical delta value, typical total time, and bias.
void SetTargetWithShape(const Vec& target_value, const Vec& target_velocity,
const MotiveCurveShape& shape) {
Processor().SetTargetWithShape(index_, kDimensions, C::ToPtr(target_value),
C::ToPtr(target_velocity), shape);
}
MotiveDimension Dimensions() const { return kDimensions; }
};
// These Motivator types use mathfu in their external API.
typedef MotivatorXfTemplate<MathFuVectorConverter, 1> Motivator1f;
typedef MotivatorXfTemplate<MathFuVectorConverter, 2> Motivator2f;
typedef MotivatorXfTemplate<MathFuVectorConverter, 3> Motivator3f;
typedef MotivatorXfTemplate<MathFuVectorConverter, 4> Motivator4f;
} // namespace motive
#endif // MOTIVE_VECTOR_MOTIVATOR_H_
| 44.492347 | 80 | 0.683332 | [
"shape",
"vector",
"3d"
] |
13f6bc1d1b5df6222ef0642067c572a839b41180 | 3,892 | h | C | embedded/common/target/nearby_platform_bt.h | google/nearby | 1aeb1093a9864c73394d27598684f2e9287d6e4e | [
"Apache-2.0"
] | 69 | 2021-10-18T00:37:29.000Z | 2022-03-20T19:53:38.000Z | embedded/common/target/nearby_platform_bt.h | google/nearby | 1aeb1093a9864c73394d27598684f2e9287d6e4e | [
"Apache-2.0"
] | 14 | 2021-10-13T19:49:27.000Z | 2022-03-31T22:19:13.000Z | embedded/common/target/nearby_platform_bt.h | google/nearby | 1aeb1093a9864c73394d27598684f2e9287d6e4e | [
"Apache-2.0"
] | 22 | 2021-10-20T12:36:47.000Z | 2022-03-31T18:39:46.000Z | // Copyright 2022 Google LLC
//
// 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef NEARBY_PLATFORM_BT_H
#define NEARBY_PLATFORM_BT_H
// clang-format off
#include "nearby_config.h"
// clang-format on
#include "nearby.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct {
void (*on_pairing_request)(uint64_t peer_address);
void (*on_paired)(uint64_t peer_address);
void (*on_pairing_failed)(uint64_t peer_address);
#ifdef NEARBY_FP_MESSAGE_STREAM
void (*on_message_stream_connected)(uint64_t peer_address);
void (*on_message_stream_disconnected)(uint64_t peer_address);
void (*on_message_stream_received)(uint64_t peer_address,
const uint8_t* message, size_t length);
#endif /* NEARBY_FP_MESSAGE_STREAM */
} nearby_platform_BtInterface;
// Returns Fast Pair Model Id.
uint32_t nearby_platform_GetModelId();
// Returns tx power level.
int8_t nearby_platform_GetTxLevel();
// Returns public BR/EDR address
uint64_t nearby_platform_GetPublicAddress();
// Returns passkey used during pairing
uint32_t nearby_platfrom_GetPairingPassKey();
// Provides the passkey received from the remote party.
// The system should compare local and remote party and accept/decline pairing
// request accordingly.
//
// passkey - Passkey
void nearby_platform_SetRemotePasskey(uint32_t passkey);
// Sends a pairing request to the Seeker
//
// remote_party_br_edr_address - BT address of peer.
nearby_platform_status nearby_platform_SendPairingRequest(
uint64_t remote_party_br_edr_address);
// Switches the device capabilities field back to default so that new
// pairings continue as expected.
nearby_platform_status nearby_platform_SetDefaultCapabilities();
// Switches the device capabilities field to Fast Pair required configuration:
// DisplayYes/No so that `confirm passkey` pairing method will be used.
nearby_platform_status nearby_platform_SetFastPairCapabilities();
// Sets null-terminated device name string in UTF-8 encoding
//
// name - Zero terminated string name of device.
nearby_platform_status nearby_platform_SetDeviceName(const char* name);
// Gets null-terminated device name string in UTF-8 encoding
// pass buffer size in char, and get string length in char.
//
// name - Buffer to return name string.
// length - On input, the size of the name buffer.
// On output, returns size of name in buffer.
nearby_platform_status nearby_platform_GetDeviceName(char* name,
size_t* length);
// Returns true if the device is in pairing mode (either fast-pair or manual).
bool nearby_platform_IsInPairingMode();
#ifdef NEARBY_FP_MESSAGE_STREAM
// Sends message stream through RFCOMM channel initiated by Seeker
//
// peer_address - Peer address.
// message - Contents of message.
// length - Length of message
nearby_platform_status nearby_platform_SendMessageStream(uint64_t peer_address,
const uint8_t* message,
size_t length);
#endif /* NEARBY_FP_MESSAGE_STREAM */
// Initializes BT module
//
// bt_interface - BT callbacks event structure.
nearby_platform_status nearby_platform_BtInit(
const nearby_platform_BtInterface* bt_interface);
#ifdef __cplusplus
}
#endif
#endif /* NEARBY_PLATFORM_BT_H */
| 35.063063 | 80 | 0.743063 | [
"model"
] |
13fae7476b2ebe4b93bdda22c80bd864c8b1ab8e | 67,714 | c | C | vendor/samsung/external/ims_voice_engine/codec/evs/float_c/lib_dec/swb_tbe_dec.c | cesarmo759/android_kernel_samsung_msm8916 | f19717ef6c984b64a75ea600a735dc937b127c25 | [
"Apache-2.0"
] | 1 | 2020-06-28T00:49:21.000Z | 2020-06-28T00:49:21.000Z | vendor/samsung/external/ims_voice_engine/codec/evs/float_c/lib_dec/swb_tbe_dec.c | cesarmo759/android_kernel_samsung_msm8916 | f19717ef6c984b64a75ea600a735dc937b127c25 | [
"Apache-2.0"
] | null | null | null | vendor/samsung/external/ims_voice_engine/codec/evs/float_c/lib_dec/swb_tbe_dec.c | cesarmo759/android_kernel_samsung_msm8916 | f19717ef6c984b64a75ea600a735dc937b127c25 | [
"Apache-2.0"
] | 1 | 2021-03-05T16:54:52.000Z | 2021-03-05T16:54:52.000Z | /*====================================================================================
EVS Codec 3GPP TS26.443 Oct 20, 2015. Version 12.4.0
====================================================================================*/
#include <math.h>
#include <stdlib.h>
#include "options.h"
#include "cnst.h"
#include "prot.h"
#include "rom_com.h"
#include "rom_dec.h"
/*-----------------------------------------------------------------*
* Local functions
*-----------------------------------------------------------------*/
static void dequantizeSHBparams( Decoder_State *st, const short extl, long extl_brate, float *Q_lsf, float *Q_subgain,
float *Q_framegrain, short *uv_flag, float *Q_shb_ener_sf, float *Q_shb_res_gshape, float *Q_mixFactors );
static void Dequant_lower_LSF( const short lsf_idx[], float lsf_q[] );
static void Map_higher_LSF(float lsf_q[], const float m, const float grid_in[]);
static void Dequant_mirror_point(const float lsf_q[], const short m_idx, float *m);
void InitSWBdecBuffer(
Decoder_State *st /* i/o: SHB decoder structure */
)
{
set_f(st->old_bwe_exc, 0.0f, (PIT16k_MAX * 2));
st->bwe_seed[0] = 23; /* 1; */
st->bwe_seed[1] = 59; /* 10000; */
set_f( st->old_bwe_exc_extended, 0.0f, NL_BUFF_OFFSET );
st->bwe_non_lin_prev_scale = 0;
st->last_voice_factor = 0.0f;
set_f(st->genSHBsynth_Hilbert_Mem, 0.0f,HILBERT_MEM_SIZE);
set_f(st->genSHBsynth_state_lsyn_filt_shb_local, 0.0f,2 * ALLPASSSECTIONS_STEEP);
st->syn_dm_phase = 0;
st->prev_fbbwe_ratio = 1.0f;
st->prev_wb_bwe_frame_pow = 0.001f;
st->prev_swb_bwe_frame_pow = 0.001f;
st->prev_fb_ener_adjust = 0.0f;
return;
}
void ResetSHBbuffer_Dec(
Decoder_State *st /* i/o: SHB encoder structure */
)
{
short i;
float f;
float inc;
if ( st->extl != WB_TBE )
{
f = 1.0f/22.0f;
inc = 1.0f/22.0f;
}
else
{
f = 1.0f/6.0f;
inc = 1.0f/6.0f;
}
/* states for the filters used in generating SHB excitation from WB excitation*/
set_f(st->mem_csfilt,0,2);
/* states for the filters used in generating SHB signal from SHB excitation*/
set_f(st->state_syn_shbexc,0,L_SHB_LAHEAD);
set_f( st->state_lpc_syn, 0, LPC_SHB_ORDER);
if( sub(st->extl, FB_TBE) == 0 )
{
set_f( st->fb_state_lpc_syn, 0, LPC_SHB_ORDER );
st->fb_tbe_demph = 0;
fb_tbe_reset_synth( st->fbbwe_hpf_mem,&st->prev_fbbwe_ratio);
}
/* states for the filters used in generating SHB signal from SHB excitation in wideband*/
set_f( st->mem_genSHBexc_filt_down_shb, 0.0f, (2*ALLPASSSECTIONS_STEEP+1) );
set_f( st->mem_genSHBexc_filt_down_wb2, 0.0f, (2*ALLPASSSECTIONS_STEEP+1) );
set_f( st->mem_genSHBexc_filt_down_wb3, 0.0f, (2*ALLPASSSECTIONS_STEEP+1) );
set_f( st->state_lsyn_filt_shb,0, 2 * ALLPASSSECTIONS_STEEP );
set_f( st->state_lsyn_filt_dwn_shb,0, 2 * ALLPASSSECTIONS_STEEP );
set_f( st->mem_resamp_HB, 0, INTERP_3_1_MEM_LEN );
/* States for the local synthesis filters */
set_f(st->syn_overlap,0,L_SHB_LAHEAD);
/* States for FEC */
if ( st->extl != WB_TBE )
{
for (i=0; i<LPC_SHB_ORDER; i++)
{
st->lsp_prevfrm[i] = f;
f += inc;
}
}
else
{
for (i=0; i<LPC_SHB_ORDER_WB; i++)
{
st->lsp_prevfrm[i] = f;
f += inc;
}
}
st->GainFrame_prevfrm = 0.0f;
st->GainAttn = 1.0;
st->tbe_demph = 0.0f;
st->tbe_premph = 0.0f;
set_f(st->mem_stp_swb, 0, LPC_SHB_ORDER);
st->gain_prec_swb = 1.0f;
set_f( &st->GainShape_Delay[0], 0, NUM_SHB_SUBFR/2 );
set_f(st->old_core_synth, 0, L_FRAME16k);
set_f(st->old_tbe_synth, 0, L_SHB_TRANSITION_LENGTH);
st->tilt_swb_fec = 0.0f;
return;
}
/*-------------------------------------------------------------------*
* wb_tbe_dec()
*
* WB TBE decoder, 6 - 8 kHz band decoding module
*-------------------------------------------------------------------*/
void wb_tbe_dec(
Decoder_State *st, /* i/o: decoder state structure */
const short coder_type, /* i : coding type */
const float *bwe_exc_extended,/* i : bandwidth extended excitation */
const float voice_factors[], /* i : voicing factors */
float *synth /* o : WB synthesis/final synthesis */
)
{
short i;
float shaped_wb_excitation [ (L_FRAME16k + L_SHB_LAHEAD)/4 ];
float exc4kWhtnd [L_FRAME16k / 4];
float lsf_wb[LPC_SHB_ORDER_WB], lpc_wb[LPC_SHB_ORDER_WB + 1], GainShape[NUM_SHB_SUBFR], GainFrame ;
float error[L_FRAME16k];
float upsampled_synth[L_FRAME48k];
float prev_pow, curr_pow, scale;
float temp, curr_frame_pow;
short j;
float vf_modified[NB_SUBFR16k];
short uv_flag = 0;
if( st->bws_cnt == 0 )
{
if( !st->bfi )
{
if( st->use_partial_copy )
{
if(st->last_extl != WB_TBE)
{
st->GainFrame_prevfrm = 0;
st->lsp_prevfrm[0] = 0.1f;
for (i=1; i<LPC_SHB_ORDER_LBR_WB; i++)
{
st->lsp_prevfrm[i] = st->lsp_prevfrm[i-i] + 0.1f;
}
}
mvr2r( st->lsp_prevfrm, lsf_wb, LPC_SHB_ORDER_LBR_WB );
set_f( GainShape, RECIP_ROOT_EIGHT, NUM_SHB_SUBFR/2 );
if( st->rf_frame_type == RF_NELP )
{
/* Frame gain */
/* only four LSBs are valid */
st->rf_indx_tbeGainFr &= 0xF;
mvr2r( SHBCB_FrameGain16 + st->rf_indx_tbeGainFr, &GainFrame, 1 );
if( st->core == ACELP_CORE && st->last_core == ACELP_CORE && !st->prev_use_partial_copy && st->prev_coder_type == UNVOICED && GainFrame != st->GainFrame_prevfrm && st->last_extl == WB_TBE)
{
GainFrame = 0.2f*GainFrame + 0.8f*st->GainFrame_prevfrm;
}
}
else
{
/* Frame gain */
temp = 0.0f;
switch (st->rf_indx_tbeGainFr)
{
case 0:
GainFrame = 0.5f;
if(st->GainFrame_prevfrm <= 1.25) temp = 0.8f;
break;
case 1:
GainFrame = 2.0f;
if(st->GainFrame_prevfrm > 1.25 && st->GainFrame_prevfrm <= 3) temp = 0.8f;
break;
case 2:
GainFrame = 4.0f;
if(st->GainFrame_prevfrm > 3 && st->GainFrame_prevfrm <= 6) temp = 0.8f;
break;
case 3:
GainFrame = 8.0f;
if(st->GainFrame_prevfrm > 6 && st->GainFrame_prevfrm <= 16) temp = 0.8f;
break;
default:
GainFrame = 1.0f;
fprintf(stderr, "RF WB-TBE gain bits not supported.");
break;
}
if(st->last_extl == WB_TBE)
{
GainFrame = (1 - temp)*GainFrame + temp*(st->GainFrame_prevfrm);
}
if (st->core == ACELP_CORE && st->last_core == ACELP_CORE)
{
if (!st->prev_use_partial_copy && st->last_coder_type == VOICED && st->rf_frame_type == RF_GENPRED
&& st->prev_tilt_code_dec < 0.046f && st->prev_tilt_code_dec > 0.006f )
{
GainFrame *= 0.3f;
}
}
}
}
else
{
/* de-quantization */
dequantizeSHBparams( st, st->extl, st->extl_brate, lsf_wb, GainShape, &GainFrame, &uv_flag, 0, 0, 0 );
}
}
else
{
if ( st->extl_brate == WB_TBE_0k35 )
{
mvr2r( st->lsp_prevfrm, lsf_wb, LPC_SHB_ORDER_LBR_WB );
}
else
{
mvr2r( st->lsp_prevfrm, lsf_wb, LPC_SHB_ORDER_WB );
}
set_f( GainShape, RECIP_ROOT_EIGHT, NUM_SHB_SUBFR/2 );
st->GainAttn *= 0.85f;
if( st->codec_mode == MODE1 )
{
GainFrame = st->GainAttn * st->GainFrame_prevfrm;
}
else
{
GainFrame = st->GainFrame_prevfrm;
}
}
if ( st->extl_brate == WB_TBE_0k35 )
{
/* convert LSPs back into LP coeffs */
lsp2a( lpc_wb, lsf_wb, LPC_SHB_ORDER_LBR_WB );
set_f( lpc_wb + LPC_SHB_ORDER_LBR_WB+1, 0.0f, (LPC_SHB_ORDER_WB - LPC_SHB_ORDER_LBR_WB) );
}
else
{
/* convert LSPs back into LP coeffs */
lsp2a( lpc_wb, lsf_wb, LPC_SHB_ORDER_WB );
}
lpc_wb[0] = 1.0f;
mvr2r( voice_factors, vf_modified, NB_SUBFR16k );
if( coder_type == VOICED )
{
for (i = 1; i < NB_SUBFR; i++)
{
vf_modified[i] = 0.8f * voice_factors[i] + 0.2f * voice_factors[i-1];
}
if(st->L_frame != L_FRAME )
{
vf_modified[4] = 0.8f * voice_factors[4] + 0.2f * voice_factors[3];
}
}
if(st->use_partial_copy && st->nelp_mode_dec)
{
set_f( vf_modified, 0.0f, NB_SUBFR16k );
}
/* From low band excitation, generate highband excitation */
mvr2r( st->state_syn_shbexc, shaped_wb_excitation, L_SHB_LAHEAD / 4);
GenShapedWBExcitation( shaped_wb_excitation+ L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, st->mem_csfilt, st->mem_genSHBexc_filt_down_shb,
st->mem_genSHBexc_filt_down_wb2, st->mem_genSHBexc_filt_down_wb3, st->state_lpc_syn, coder_type,
bwe_exc_extended, st->bwe_seed, vf_modified, uv_flag, st->igf );
prev_pow = sum2_f( shaped_wb_excitation, L_SHB_LAHEAD/4 );
curr_pow = sum2_f( shaped_wb_excitation + L_SHB_LAHEAD/4, L_SHB_LAHEAD/4 );
if( voice_factors[0] > 0.75f )
{
curr_pow *= 0.25;
}
if( prev_pow == 0 )
{
scale = 0;
}
else
{
scale = sqrt(curr_pow / prev_pow);
}
for (i=0; i<L_SHB_LAHEAD/4 - 1; i++)
{
shaped_wb_excitation[i] *= scale;
}
scale = sqrt(scale);
shaped_wb_excitation[L_SHB_LAHEAD/4 - 1] *= scale;
/* Update SHB excitation */
mvr2r( shaped_wb_excitation + L_FRAME16k/4, st->state_syn_shbexc, L_SHB_LAHEAD/4 );
/* Adjust the subframe and frame gain of the synthesized shb signal */
/* Scale the shaped excitation */
ScaleShapedSHB( SHB_OVERLAP_LEN/2, shaped_wb_excitation, st->syn_overlap, GainShape, GainFrame, window_wb, subwin_wb );
curr_frame_pow = sum2_f( shaped_wb_excitation, L_FRAME16k/4 ) + 0.001f;
if( !st->bfi && (st->prev_bfi || st->prev_use_partial_copy) )
{
if( curr_frame_pow > 2.0f * st->prev_wb_bwe_frame_pow )
{
scale = root_a_over_b( st->prev_wb_bwe_frame_pow, curr_frame_pow );
temp = (float) pow(scale, 0.125f);
}
else
{
scale = 1.0f;
temp = 1.0f;
}
for( j=0; j<8; j++ )
{
GainShape[2*j] *= scale;
GainShape[2*j+1] *= scale;
for( i=0; i<L_FRAME16k/(4*8); i++ )
{
shaped_wb_excitation[i + j*L_FRAME16k/(4*8)] *= scale;
}
scale /= temp;
}
}
st->prev_wb_bwe_frame_pow = curr_frame_pow;
/* generate 16kHz SHB signal (6 - 8 kHz) from 2kHz signal */
GenWBSynth( shaped_wb_excitation, error , st->state_lsyn_filt_shb, st->state_lsyn_filt_dwn_shb );
mvr2r( error + L_FRAME16k - L_SHB_TRANSITION_LENGTH, st->old_tbe_synth, L_SHB_TRANSITION_LENGTH );
for ( i=0; i<L_FRAME16k; i++ )
{
synth[i] = 0.65f * error[i];
}
st->last_wb_bwe_ener = 0.0f;
for( i=0; i<L_FRAME16k; i++ )
{
st->last_wb_bwe_ener += synth[i]*synth[i];
}
st->last_wb_bwe_ener = (float)sqrt(st->last_wb_bwe_ener/L_FRAME16k);
if( st->output_Fs == 32000 ) /* 32kHz sampling rate, but only WB output - interpolate */
{
Interpolate_allpass_steep( synth, st->mem_resamp_HB, L_FRAME16k, upsampled_synth );
mvr2r( upsampled_synth, synth, L_FRAME32k );
}
else if(st->output_Fs == 48000 )
{
interpolate_3_over_1_allpass( synth, L_FRAME16k, upsampled_synth, st->mem_resamp_HB, allpass_poles_3_ov_2 );
mvr2r( upsampled_synth, synth, L_FRAME48k );
}
}
else
{
for ( i = 0; i < LPC_SHB_ORDER_WB; i++ )
{
lsf_wb[i] = i/6;
}
GainFrame = 0;
st->prev_wb_bwe_frame_pow = 0.001f;
}
/* Update previous frame parameters for FEC */
mvr2r( lsf_wb, st->lsp_prevfrm, LPC_SHB_ORDER_WB);
st->GainFrame_prevfrm = GainFrame;
if( !st->bfi )
{
st->GainAttn = 1.0f;
}
return;
}
/*-------------------------------------------------------------------*
* swb_tbe_dec()
*
* SWB TBE decoder, 6 - 14 kHz (or 7.5 - 15.5 kHz) band decoding module
*-------------------------------------------------------------------*/
void swb_tbe_dec(
Decoder_State *st, /* i/o: decoder state structure */
const short coder_type, /* i : coding type */
const float *bwe_exc_extended,/* i : bandwidth extended excitation */
const float voice_factors[], /* i : voicing factors */
const float old_syn_12k8_16k[],/*i : low band synthesis*/
float *White_exc16k, /* o : shaped white excitation for the FB TBE */
float *synth, /* o : SHB synthesis/final synthesis */
float *pitch_buf
)
{
short i, j;
short stemp;
float shaped_shb_excitation [ L_FRAME16k + L_SHB_LAHEAD ];
float lsf_shb[LPC_SHB_ORDER], lpc_shb[LPC_SHB_ORDER + 1], GainShape[NUM_SHB_SUBFR], GainFrame;
float error[L_FRAME32k];
float ener;
short is_fractive;
float prev_pow, curr_pow, scale;
float curr_frame_pow, temp;
float GainShapeTemp[NUM_SHB_SUBFR/4], GainGrad0[3], GainGrad1[3], GainGradFEC[4];
float vf_modified[NB_SUBFR16k];
float f, inc;
float GainFrame_prevfrm;
float tilt_swb_fec;
float prev_ener_ratio;
float lsp_shb_1[LPC_SHB_ORDER], lsp_shb_2[LPC_SHB_ORDER], lsp_temp[LPC_SHB_ORDER];
float lpc_shb_sf[4*(LPC_SHB_ORDER+1)];
const float *ptr_lsp_interp_coef;
float shb_ener_sf;
float shb_res_gshape[NB_SUBFR16k];
float mixFactors;
short vind;
float shb_res_dummy[L_FRAME16k];
float shaped_shb_excitationTemp[L_FRAME16k];
float ener_tmp[NUM_SHB_SUBGAINS];
float GainShape_tmp[NUM_SHB_SUBGAINS];
float pitch;
short l_subframe;
float formant_fac;
float synth_scale;
float lsf_diff[LPC_SHB_ORDER], w[LPC_SHB_ORDER];
float refl[M];
float tilt_para;
/* initializations */
GainFrame = 0.0f;
mixFactors = 0.0f;
shb_ener_sf = 0.0f;
set_f( shaped_shb_excitationTemp, 0.0f, L_FRAME16k );
st->shb_dtx_count = 0;
is_fractive = 0;
/* find tilt */
calc_tilt_bwe( old_syn_12k8_16k, &tilt_swb_fec, L_FRAME);
if( st->bfi && st->clas_dec != UNVOICED_CLAS )
{
tilt_swb_fec = st->tilt_swb_fec;
}
/* WB/SWB bandwidth switching */
if( (st->tilt_wb > 5 && st->clas_dec == UNVOICED_CLAS) || st->tilt_wb > 10 )
{
if( (st->prev_fractive == 0
&& st->prev_enerLH < 2.0f*st->enerLH && st->prev_enerLH > 0.5f*st->enerLH
&& st->prev_enerLL < 2.0f*st->enerLL && st->prev_enerLL > 0.5f*st->enerLL )
|| (st->prev_fractive == 1 && st->prev_enerLH > 3.0f*st->enerLH)
|| (st->enerLL > 1.5f*st->enerLH && st->tilt_wb < 10.0f) )
{
is_fractive = 0;
}
else
{
is_fractive = 1;
}
}
/* WB/SWB bandwidth switching */
if( st->bws_cnt > 0 )
{
f = 1.0f/22.0f;
inc = 1.0f/22.0f;
if ( is_fractive == 1 )
{
mvr2r(lsf_tab, st->lsp_prevfrm, LPC_SHB_ORDER);
}
else
{
for (i=0; i<LPC_SHB_ORDER; i++)
{
st->lsp_prevfrm[i] = f;
f += inc;
}
}
if( (st->last_extl != SWB_TBE && st->last_extl != FB_TBE && !(st->prev_enerLH < 2.0f*st->enerLH && st->prev_enerLH > 0.5f*st->enerLH))
|| st->last_core != ACELP_CORE || (st->last_core == ACELP_CORE && labs(st->last_core_brate - st->core_brate) > 3600) || (is_fractive ^ st->prev_fractive) == 1 )
{
set_f( GainShape, 0.3536f, NUM_SHB_SUBFR );
}
else
{
st->prev_GainShape = (st->prev_GainShape > 0.3536f) ? 0.353f : st->prev_GainShape;
set_f( GainShape, st->prev_GainShape, NUM_SHB_SUBFR );
}
/* this never happens */
mvr2r( st->lsp_prevfrm, lsf_shb, LPC_SHB_ORDER );
set_f( shb_res_gshape, 0.2f, NB_SUBFR16k );
}
else
{
if ( st->last_extl != SWB_TBE && st->last_extl != FB_TBE )
{
f = 1.0f/22.0f;
inc = 1.0f/22.0f;
for (i=0; i<LPC_SHB_ORDER; i++)
{
st->lsp_prevfrm[i] = f;
f += inc;
}
}
if( !st->bfi )
{
if( st->use_partial_copy )
{
if(st->last_extl != SWB_TBE)
{
st->GainFrame_prevfrm = 0;
f = 1.0f/22.0f;
inc = 1.0f/22.0f;
for (i=0; i<LPC_SHB_ORDER; i++)
{
st->lsp_prevfrm[i] = f;
f += inc;
}
}
mvr2r( st->lsp_prevfrm, lsf_shb, LPC_SHB_ORDER );
set_f( GainShape, RECIP_ROOT_EIGHT, NUM_SHB_SUBFR );
if( st->rf_frame_type == RF_NELP )
{
/* Frame gain */
GainFrame = usdequant(st->rf_indx_tbeGainFr, SHB_GAIN_QLOW, SHB_GAIN_QDELTA);
GainFrame = (float) pow(10.0, GainFrame);
if( st->core == ACELP_CORE && st->last_core == ACELP_CORE && !st->prev_use_partial_copy
&& st->prev_coder_type == UNVOICED && GainFrame != st->GainFrame_prevfrm && st->next_coder_type != GENERIC && st->last_extl == SWB_TBE )
{
GainFrame = 0.2f*GainFrame + 0.8f*st->GainFrame_prevfrm;
}
}
else
{
temp = 0.0f;
/* Frame gain */
switch (st->rf_indx_tbeGainFr)
{
case 0:
GainFrame = 0.5f;
if(st->GainFrame_prevfrm <= 1.25) temp = 0.8f;
break;
case 1:
GainFrame = 2.0f;
if(st->GainFrame_prevfrm > 1.25 && st->GainFrame_prevfrm <= 3) temp = 0.8f;
break;
case 2:
GainFrame = 4.0f;
if(st->GainFrame_prevfrm > 3 && st->GainFrame_prevfrm <= 6) temp = 0.8f;
break;
case 3:
GainFrame = 8.0f;
if(st->GainFrame_prevfrm > 6 && st->GainFrame_prevfrm <= 16) temp = 0.8f;
break;
default:
fprintf(stderr, "RF SWB-TBE gain bits not supported.");
}
if(st->last_extl == SWB_TBE)
{
GainFrame = (1 - temp)*GainFrame + temp*(st->GainFrame_prevfrm);
}
if( st->core == ACELP_CORE && st->last_core == ACELP_CORE )
{
if( !st->prev_use_partial_copy && st->last_coder_type == VOICED && st->rf_frame_type == RF_GENPRED && GainFrame > 8.0f && GainFrame < 11.67f )
{
GainFrame *= 0.3f;
}
}
}
}
else
{
/* de-quantization */
dequantizeSHBparams( st, st->extl, st->extl_brate, lsf_shb, GainShape, &GainFrame, &stemp, &shb_ener_sf, shb_res_gshape, &mixFactors );
}
}
else
{
mvr2r( st->lsp_prevfrm, lsf_shb, LPC_SHB_ORDER );
if( st->codec_mode == MODE1 )
{
/* the previous frame gainshape gradient and the gainshape gradient pattern for the current frame */
for(j=0; j<3; j++)
{
GainGrad0[j] = st->GainShape_Delay[j+1] - st->GainShape_Delay[j];
GainGrad1[j] = st->GainShape_Delay[j+5] - st->GainShape_Delay[j+4];
GainGradFEC[j+1] = GainGrad0[j]*0.4f + GainGrad1[j]*0.6f;
}
/* gradient for the first gainshape */
if( ( GainGrad1[2] > 2 * GainGrad1[1] && GainGrad1[1] > 2 * GainGrad1[0] ) ||
( GainGrad1[2] < 2 * GainGrad1[1] && GainGrad1[1] < 2 * GainGrad1[0] ) )
{
GainGradFEC[0] = GainGrad1[1] * 0.1f + GainGrad1[2] * 0.9f;
}
else
{
GainGradFEC[0] = GainGrad1[0] * 0.2f + GainGrad1[1] * 0.3f + GainGrad1[2] * 0.5f;
}
/* get the first gainshape template */
if( (st->prev_coder_type == UNVOICED || st->last_good == UNVOICED_CLAS) && GainGradFEC[0] > 0 )
{
GainShapeTemp[0] = st->GainShape_Delay[7] + GainGradFEC[0];
}
else if( GainGradFEC[0] > 0 )
{
GainShapeTemp[0] = st->GainShape_Delay[7] + GainGradFEC[0] * 0.5f;
}
else
{
GainShapeTemp[0] = st->GainShape_Delay[7];
}
/*Get the second the third and the fourth gainshape template*/
if( ( GainGrad1[2] > 10.0f * GainGrad1[1] ) && GainGrad1[1] > 0 )
{
for(i=1; i<NUM_SHB_SUBFR/4; i++)
{
GainShapeTemp[i] = GainShapeTemp[i-1] + GainGradFEC[i] * 0.8f;
GainShapeTemp[i] = max(GainShapeTemp[i], 0.01f);
}
}
else if( ( GainGrad1[2] > 10.0f * GainGrad1[1] ) && GainGrad1[1] < 0 )
{
for( i=1; i<NUM_SHB_SUBFR/4; i++)
{
GainShapeTemp[i] = GainShapeTemp[i-1] + GainGradFEC[i] * 0.2f;
GainShapeTemp[i] = max(GainShapeTemp[i], 0.01f);
}
}
else
{
for( i=1; i<NUM_SHB_SUBFR/4; i++)
{
GainShapeTemp[i] = GainShapeTemp[i-1] + GainGradFEC[i];
GainShapeTemp[i] = max(GainShapeTemp[i], 0.01f);
}
}
/* Get the gainshape and gain frame for the current frame*/
if( (st->prev_coder_type == UNVOICED || st->last_good == UNVOICED_CLAS) && st->nbLostCmpt == 1 )
{
for( i=0; i<NUM_SHB_SUBFR/4; i++)
{
for(j=0; j<4; j++)
{
GainShape[i * 4 + j ] = GainShapeTemp[i] * 1.2f;
}
}
st->GainAttn *= 0.95f;
}
else if( st->prev_coder_type == UNVOICED || st->last_good == UNVOICED_CLAS )
{
for( i=0; i<NUM_SHB_SUBFR/4; i++)
{
for(j=0; j<4; j++)
{
GainShape[i * 4 + j ] = GainShapeTemp[i];
}
}
st->GainAttn *= 0.95f;
}
else if( st->nbLostCmpt > 1 )
{
for( i=0; i<NUM_SHB_SUBFR/4; i++)
{
for(j=0; j<4; j++)
{
GainShape[i * 4 + j ] = GainShapeTemp[i] * 0.5f;
}
}
st->GainAttn *= 0.5f;
}
else
{
for( i=0; i<NUM_SHB_SUBFR/4; i++)
{
for(j=0; j<4; j++)
{
GainShape[i * 4 + j] = GainShapeTemp[i];
}
}
st->GainAttn *= 0.85f;
}
GainFrame = st->GainAttn * st->GainFrame_prevfrm;
}
else
{
for( i=0; i<NUM_SHB_SUBFR/4; i++)
{
for(j=0; j<4; j++)
{
GainShape[i * 4 + j] = st->cummulative_damping * st->GainShape_Delay[4+i];
}
}
if( tilt_swb_fec > 8 )
{
if( st->nbLostCmpt == 1 )
{
GainFrame = 0.6* st->cummulative_damping * st->GainFrame_prevfrm;
}
else if( st->nbLostCmpt == 2 )
{
GainFrame = 0.35* st->cummulative_damping * st->GainFrame_prevfrm;
}
else
{
GainFrame = 0.2* st->cummulative_damping * st->GainFrame_prevfrm;
}
}
else
{
GainFrame = st->GainFrame_prevfrm; /* gain locking */
}
}
if( st->total_brate == ACELP_24k40 || st->total_brate == ACELP_32k )
{
if( st->codec_mode == MODE1 )
{
scale = st->prev1_shb_ener_sf/sqrt((st->prev2_shb_ener_sf * st->prev3_shb_ener_sf) +0.0001);
scale = st->prev_res_shb_gshape * min(scale, 1.0f);
if(st->prev2_shb_ener_sf > 2.0f * st->prev1_shb_ener_sf || st->prev3_shb_ener_sf > 2.0f * st->prev2_shb_ener_sf)
{
shb_ener_sf = 0.5f * scale * st->prev1_shb_ener_sf;
if(st->nbLostCmpt > 1)
{
shb_ener_sf *= 0.5f;
}
}
else
{
shb_ener_sf = scale * scale * st->prev1_shb_ener_sf;
}
}
else
{
if( st->prev2_shb_ener_sf > 2.0f * st->prev1_shb_ener_sf || st->prev3_shb_ener_sf > 2.0f * st->prev2_shb_ener_sf )
{
shb_ener_sf = 0.5f* st->cummulative_damping * st->prev1_shb_ener_sf;
}
else
{
shb_ener_sf = st->cummulative_damping * st->prev1_shb_ener_sf;
}
}
}
shb_ener_sf = max(shb_ener_sf, 1.0f);
mixFactors = st->prev_mixFactors;
if( st->codec_mode == MODE2 )
{
set_f( shb_res_gshape, 1.0f, NB_SUBFR16k );
}
else
{
set_f( shb_res_gshape, 0.2f, NB_SUBFR16k );
}
}
}
/* get the gainshape delay */
mvr2r( &st->GainShape_Delay[4], &st->GainShape_Delay[0], NUM_SHB_SUBFR/4 );
for( i = 0; i<NUM_SHB_SUBFR/4; i++ )
{
st->GainShape_Delay[i+4] = GainShape[i*4];
}
mvr2r( voice_factors, vf_modified, NB_SUBFR16k );
if( coder_type == VOICED || mean(voice_factors, 4) > 0.4f )
{
for( i = 1; i < NB_SUBFR; i++ )
{
vf_modified[i] = 0.8f * voice_factors[i] + 0.2f * voice_factors[i-1];
}
if(st->L_frame != L_FRAME )
{
vf_modified[4] = 0.8f * voice_factors[4] + 0.2f * voice_factors[3];
}
}
if(st->use_partial_copy && st->nelp_mode_dec)
{
set_f( vf_modified, 0.0f, NB_SUBFR16k );
}
/* SHB LSF from current frame; and convert to LSP for interpolation */
lsf2lsp( lsf_shb, lsp_shb_2, LPC_SHB_ORDER, 1.0f );
if( st->last_extl == SWB_TBE || st->last_extl == FB_TBE )
{
/* SHB LSP values from prev. frame for interpolation */
mvr2r( st->swb_lsp_prev_interp, lsp_shb_1, LPC_SHB_ORDER );
}
else
{
/* Use current frame's LSPs; in effect no interpolation */
mvr2r( lsp_shb_2, lsp_shb_1, LPC_SHB_ORDER );
}
if( st->bws_cnt == 0 && st->bws_cnt1 == 0 && st->prev_use_partial_copy == 0 && st->use_partial_copy == 0)
{
lsf_diff[0] = lsf_diff[LPC_SHB_ORDER-1] = 0.5f;
for(i=1; i<(LPC_SHB_ORDER-1); i++)
{
lsf_diff[i] = lsf_shb[i] - lsf_shb[i-1];
}
a2rc (st->cur_sub_Aq+1, refl, (short) M);
tilt_para = 6.6956f * (1.0f + refl[0]) * (1.0f + refl[0]) - 3.8714f * (1.0f + refl[0]) + 1.3041f;
if( st->last_extl != SWB_TBE && st->last_extl != FB_TBE )
{
for( i=1; i<LPC_SHB_ORDER-1; i++ )
{
st->prev_lsf_diff[i-1] = 0.5f*lsf_diff[i];
}
}
if( st->total_brate <= ACELP_16k40 )
{
if(!(st->prev_tilt_para > 5.0f && (coder_type == TRANSITION || tilt_para < 1.0f)) && !(((st->prev_tilt_para < 3.0f && st->prev_coder_type >= VOICED)) && tilt_para > 5.0f))
{
for( i = 1; i < (LPC_SHB_ORDER-1); i++ )
{
if( lsf_diff[i] < 0 || st->prev_lsf_diff[i-1] <= 0 ) /* safety check in case of bit errors */
{
w[i] = 0;
st->BER_detect = 1;
}
else
{
w[i] = (lsf_diff[i] < st->prev_lsf_diff[i-1]) ? min(max(0.8f*lsf_diff[i]/st->prev_lsf_diff[i-1], 0.5f), 1.0f) : min(max(0.8f*st->prev_lsf_diff[i-1]/lsf_diff[i], 0.5f), 1.0f);
}
}
w[0] = w[1];
w[LPC_SHB_ORDER-1] = w[LPC_SHB_ORDER-2];
for( i = 0; i < LPC_SHB_ORDER; i++ )
{
lsp_temp[i] = lsp_shb_1[i]*(1.0f-w[i]) + lsp_shb_2[i]*w[i];
}
}
else
{
mvr2r( lsp_shb_2, lsp_temp, LPC_SHB_ORDER );
}
/* convert from lsp to lsf */
lsp2lsf( lsp_temp, lsf_shb, LPC_SHB_ORDER, 1.0f );
}
mvr2r( lsf_diff+1, st->prev_lsf_diff, LPC_SHB_ORDER-2 );
st->prev_tilt_para = tilt_para;
}
else
{
mvr2r(lsp_shb_2, lsp_temp, LPC_SHB_ORDER);
}
if( st->total_brate == ACELP_24k40 || st->total_brate == ACELP_32k )
{
/* SHB LSP interpolation */
ptr_lsp_interp_coef = interpol_frac_shb;
for( j = 0; j < 4; j++ )
{
for( i = 0; i < LPC_SHB_ORDER; i++ )
{
lsp_temp[i] = lsp_shb_1[i]*(*ptr_lsp_interp_coef) + lsp_shb_2[i]*(*(ptr_lsp_interp_coef+1));
}
ptr_lsp_interp_coef += 2;
/* convert from lsp to lsf */
lsp2lsf( lsp_temp, lsp_temp, LPC_SHB_ORDER, 1.0f );
/* convert lsf to lpc for SHB synthesis */
lsp2a( lpc_shb_sf+j*(LPC_SHB_ORDER+1), lsp_temp, LPC_SHB_ORDER );
lpc_shb_sf[j*(LPC_SHB_ORDER+1)] = 1.0f;
}
}
/* Save the SWB LSP values from current frame for interpolation */
mvr2r( lsp_shb_2, st->swb_lsp_prev_interp, LPC_SHB_ORDER );
/* save the shb_ener and mixFactor values */
st->prev3_shb_ener_sf = st->prev2_shb_ener_sf;
st->prev2_shb_ener_sf = st->prev1_shb_ener_sf;
st->prev1_shb_ener_sf = shb_ener_sf;
st->prev_res_shb_gshape = shb_res_gshape[4];
st->prev_mixFactors = mixFactors;
/* SWB CNG/DTX - update memories */
mvr2r( st->lsp_shb_prev, st->lsp_shb_prev_prev, LPC_SHB_ORDER );
mvr2r( lsf_shb, st->lsp_shb_prev, LPC_SHB_ORDER );
/* convert LSPs back into LP coeffs */
lsp2a( lpc_shb, lsf_shb, LPC_SHB_ORDER );
lpc_shb[0] = 1.0;
vind = (short)(mixFactors*8.0f);
/* Determine formant PF strength */
formant_fac = swb_formant_fac( lpc_shb[1], &st->tilt_mem );
if(st->total_brate > ACELP_32k)
{
for( j = 0; j < 4; j++ )
{
mvr2r(lpc_shb, &lpc_shb_sf[j*(LPC_SHB_ORDER+1)], LPC_SHB_ORDER+1);
}
}
/* From low band excitation, generate highband excitation */
mvr2r( st->state_syn_shbexc, shaped_shb_excitation, L_SHB_LAHEAD);
GenShapedSHBExcitation( shaped_shb_excitation + L_SHB_LAHEAD, lpc_shb, White_exc16k, st->mem_csfilt, st->mem_genSHBexc_filt_down_shb, st->state_lpc_syn,
coder_type, bwe_exc_extended, st->bwe_seed, vf_modified, st->extl, &(st->tbe_demph), &(st->tbe_premph), lpc_shb_sf,
&shb_ener_sf, shb_res_gshape, shb_res_dummy, &vind, formant_fac, st->fb_state_lpc_syn, &(st->fb_tbe_demph), st->total_brate , st->prev_bfi);
for( i=0; i<L_FRAME16k; i+=L_SUBFR16k )
{
/* TD BWE post-processing */
PostShortTerm( &shaped_shb_excitation[L_SHB_LAHEAD+i], lpc_shb, &shaped_shb_excitationTemp[i], st->mem_stp_swb,
st->ptr_mem_stp_swb, &(st->gain_prec_swb), st->mem_zero_swb, formant_fac );
}
mvr2r( shaped_shb_excitationTemp, &shaped_shb_excitation[L_SHB_LAHEAD], L_FRAME16k );
prev_pow = sum2_f( shaped_shb_excitation, L_SHB_LAHEAD + 10 );
curr_pow = sum2_f( shaped_shb_excitation + L_SHB_LAHEAD + 10, L_SHB_LAHEAD + 10 );
if( voice_factors[0] > 0.75f )
{
curr_pow *= 0.25;
}
if( prev_pow == 0 )
{
scale = 0;
}
else
{
scale = sqrt(curr_pow/prev_pow);
}
for( i=0; i<L_SHB_LAHEAD; i++ )
{
shaped_shb_excitation[i] *= scale;
}
for( ; i<L_SHB_LAHEAD + 10 ; i++)
{
temp = (i-19)/10.0f;
shaped_shb_excitation[i] *= (temp*1.0f + (1.0f-temp)*scale);
}
/* Update SHB excitation */
mvr2r( shaped_shb_excitation + L_FRAME16k, st->state_syn_shbexc, L_SHB_LAHEAD );
l_subframe = L_FRAME16k/NUM_SHB_SUBGAINS;
ener = EPSILON;
for(i=0; i<NUM_SHB_SUBGAINS; i++)
{
ener_tmp[i] = EPSILON;
for(j=0; j<l_subframe; j++)
{
ener_tmp[i] += shaped_shb_excitation[i*l_subframe+j] * shaped_shb_excitation[i*l_subframe+j] * 0.0125f;
}
ener_tmp[i] = sqrt(ener_tmp[i]);
ener += ener_tmp[i];
}
ener /= NUM_SHB_SUBGAINS;
/* WB/SWB bandwidth switching */
if( st->bws_cnt > 0 )
{
ener *= 0.35f;
if( st->tilt_swb > 8 )
{
st->prev_fractive = 1;
}
if( is_fractive == 0 )
{
if( st->tilt_wb > 1.0 )
{
st->tilt_wb = 1.0f;
}
else if( st->tilt_wb < 0.5 )
{
st->tilt_wb = 0.5f;
}
if( st->prev_fractive == 1 && st->tilt_wb > 0.5 )
{
st->tilt_wb = 0.5f;
}
}
else
{
if ( st->tilt_wb > 4)
{
if ( st->prev_fractive == 0)
{
st->tilt_wb = 4;
}
else
{
st->tilt_wb = 8;
}
}
else
{
st->tilt_wb *= 2;
}
}
if( ener != 0 )
{
if( ener*st->tilt_wb > st->enerLH )
{
st->tilt_wb = 0.5f*st->enerLH/ener;
}
else if( ener*st->tilt_wb < 0.05f*st->enerLH && is_fractive == 1 )
{
st->tilt_wb = 0.25f*st->enerLH/ener;
}
GainFrame_prevfrm = st->prev_ener_shb/ener;
}
else
{
GainFrame_prevfrm = 0;
}
if ( is_fractive == 1)
{
GainFrame = 8.0f*st->tilt_wb;
}
else
{
GainFrame = 2.0f*st->tilt_wb;
}
if ( (is_fractive & st->prev_fractive) == 1 && GainFrame > GainFrame_prevfrm )
{
GainFrame = 0.2f*GainFrame + 0.8f*GainFrame_prevfrm;
}
else
{
if ( (st->prev_enerLH < 2.0f*st->enerLH && st->prev_enerLH > 0.5f*st->enerLH )
&& (st->prev_enerLL < 2.0f*st->enerLL && st->prev_enerLL > 0.5f*st->enerLL)
&& (is_fractive ^ st->prev_fractive) == 0)
{
GainFrame = 0.5f*GainFrame + 0.5f*GainFrame_prevfrm;
}
else
{
if ( is_fractive == 0 && st->prev_fractive == 1 )
{
GainFrame = (1.0f-0.1f*GainFrame)*GainFrame + 0.1f*GainFrame*GainFrame_prevfrm;
}
else
{
GainFrame = 0.5f*GainFrame + 0.5f*GainFrame_prevfrm;
}
}
}
GainFrame *= ((float)N_WS2N_FRAMES - (float)st->bws_cnt) / (float)N_WS2N_FRAMES;
}
else
{
if( st->bws_cnt1 > 0 )
{
GainFrame *= (float)st->bws_cnt1 / (float)N_WS2N_FRAMES;
}
if( st->nbLostCmpt == 1 )
{
prev_ener_ratio = st->prev_ener_shb/ener;
if( st->clas_dec != UNVOICED_CLAS && st->clas_dec != UNVOICED_TRANSITION &&st->tilt_swb_fec < 8.0 &&
((st->enerLL > 0.5f*st->prev_enerLL && st->enerLL < 2.0f*st->prev_enerLL)|| (st->enerLH > 0.5f*st->prev_enerLH && st->enerLH < 2.0f*st->prev_enerLH)))
{
if( prev_ener_ratio > 4.0f * GainFrame )
{
GainFrame = 0.4f * prev_ener_ratio + 0.6f * GainFrame;
}
else if( prev_ener_ratio > 2.0f * GainFrame )
{
GainFrame = 0.8f * prev_ener_ratio + 0.2f * GainFrame;
}
else
{
GainFrame = 0.2f * prev_ener_ratio + 0.8f * GainFrame;
}
if( tilt_swb_fec > st->tilt_swb_fec )
{
GainFrame *= st->tilt_swb_fec > 0 ? (min(5.0f,tilt_swb_fec/st->tilt_swb_fec)) : 1.0f;
}
}
else if( (st->clas_dec != UNVOICED_CLAS || st->tilt_swb_fec > 8.0) && prev_ener_ratio > 4.0f * GainFrame &&
(st->enerLL > 0.5f*st->prev_enerLL ||st->enerLH > 0.5f*st->prev_enerLH) )
{
GainFrame = 0.2f * prev_ener_ratio + 0.8f * GainFrame;
}
}
else if( st->nbLostCmpt > 1 )
{
prev_ener_ratio = st->prev_ener_shb/ener;
if((prev_ener_ratio > 4.0 * GainFrame) && ((st->codec_mode == MODE1 && st->enerLL > st->prev_enerLL && st->enerLH > st->prev_enerLH) || st->codec_mode == MODE2))
{
if( tilt_swb_fec > 10.0f && st->tilt_swb_fec >10.0f )
{
GainFrame = min((prev_ener_ratio *0.8f + GainFrame * 0.2f),4.0f * GainFrame);
}
else
{
GainFrame = min((prev_ener_ratio *0.5f + GainFrame * 0.5f),4.0f * GainFrame);
}
}
else if((prev_ener_ratio > GainFrame) &&((st->codec_mode == MODE1 && st->enerLL > st->prev_enerLL && st->enerLH > st->prev_enerLH) || st->codec_mode == MODE2))
{
if( tilt_swb_fec > 10.0f && st->tilt_swb_fec >10.0f )
{
GainFrame = 0.5f * prev_ener_ratio + 0.5f * GainFrame;
}
else
{
GainFrame = 0.2f * prev_ener_ratio + 0.8f * GainFrame;
}
}
}
}
st->prev_fractive = is_fractive;
/* Adjust the subframe and frame gain of the synthesized shb signal */
/* Scale the shaped excitation */
if( st->L_frame == L_FRAME )
{
pitch = 0.25f*sum_f(pitch_buf, 4);
}
else
{
pitch = 0.2f*sum_f(pitch_buf, 5);
}
if( ((st->total_brate >= ACELP_24k40 && st->prev_coder_type == coder_type && coder_type != UNVOICED)
|| (st->total_brate <= ACELP_16k40 && (st->prev_coder_type == coder_type || (st->prev_coder_type == VOICED && coder_type == GENERIC) || (st->prev_coder_type == GENERIC && coder_type == VOICED))))
&& pitch > 70 && st->extl < FB_TBE)
{
for( i=0; i<NUM_SHB_SUBGAINS; i++ )
{
GainShape_tmp[i] = GainShape[i*4];
}
for( i=0; i<NUM_SHB_SUBGAINS; i++ )
{
if( ener_tmp[i]*GainShape_tmp[i] > st->prev_ener*st->prev_GainShape )
{
GainShape_tmp[i] = 0.5f*(st->prev_ener*st->prev_GainShape/ener_tmp[i] + GainShape_tmp[i]);
}
st->prev_ener = ener_tmp[i];
st->prev_GainShape = GainShape_tmp[i];
}
for( i=0; i<NUM_SHB_SUBFR; i++ )
{
GainShape[i] = GainShape_tmp[i*NUM_SHB_SUBGAINS/NUM_SHB_SUBFR];
}
}
ScaleShapedSHB( SHB_OVERLAP_LEN, shaped_shb_excitation, st->syn_overlap,GainShape,GainFrame,window_shb,subwin_shb );
curr_frame_pow = sum2_f( shaped_shb_excitation, L_FRAME16k ) + 0.001f;
if( !st->bfi && (st->prev_bfi || st->prev_use_partial_copy ) )
{
if( ( curr_frame_pow > 2.0f * st->prev_swb_bwe_frame_pow ) &&
( curr_frame_pow < 30.0f * st->prev_swb_bwe_frame_pow ) &&
st->prev_coder_type == UNVOICED )
{
scale = sqrt( st->prev_swb_bwe_frame_pow/curr_frame_pow );
if ((curr_frame_pow)==0) scale = 0;
temp = (float)pow( scale, 0.125f );
}
else
{
scale = 1.0f;
temp = 1.0f;
}
for( j=0; j<8; j++ )
{
GainShape[2*j] *= scale;
GainShape[2*j+1] *= scale;
for( i=0; i<L_FRAME16k/8; i++ )
{
shaped_shb_excitation[i + j*L_FRAME16k/8] *= scale;
}
scale /= temp;
}
}
/* adjust the FEC frame energy */
if( st->bfi )
{
scale = 1.0f;
temp = 1.0f;
if( st->nbLostCmpt == 1 )
{
if( curr_frame_pow > st->prev_swb_bwe_frame_pow &&
st->prev_coder_type != UNVOICED &&
st->last_good != UNVOICED_CLAS )
{
scale = sqrt( st->prev_swb_bwe_frame_pow/curr_frame_pow );
if ((curr_frame_pow)==0) scale = 0;
temp = (float) pow( scale, 0.125f );
}
else if( curr_frame_pow < 0.5f *st->prev_swb_bwe_frame_pow && st->nbLostCmpt == 1 &&
(st->enerLL > 0.5 * st->prev_enerLL || st->enerLH > 0.5 *st->prev_enerLH) &&
(st->prev_coder_type == UNVOICED || st->last_good == UNVOICED_CLAS || st->tilt_swb_fec > 5.0f) )
{
scale = sqrt(st->prev_swb_bwe_frame_pow / curr_frame_pow);
if ((curr_frame_pow)==0) scale = 0;
temp = (float) pow(scale, 0.125f);
}
}
else if ( st->nbLostCmpt > 1 )
{
if( curr_frame_pow > st->prev_swb_bwe_frame_pow )
{
scale = sqrt( st->prev_swb_bwe_frame_pow / curr_frame_pow );
if ((curr_frame_pow)==0) scale = 0;
temp = (float) pow( scale, 0.125f );
}
else if( curr_frame_pow < 0.5f *st->prev_swb_bwe_frame_pow &&
(st->enerLL > 0.5 * st->prev_enerLL || st->enerLH > 0.5 *st->prev_enerLH) &&
(st->prev_coder_type == UNVOICED || st->last_good == UNVOICED_CLAS || st->tilt_swb_fec > 5.0f) )
{
scale = min(2.0f,sqrt(st->prev_swb_bwe_frame_pow/curr_frame_pow));
if ((curr_frame_pow)==0) scale = 0;
temp = (float) pow(scale, 0.125f);
}
}
for( j=0; j<8; j++ )
{
GainShape[2 * j] *= scale;
GainShape[2 * j + 1] *= scale;
for( i=0; i<L_FRAME16k/8; i++ )
{
shaped_shb_excitation[i + j * L_FRAME16k/8] *= scale;
}
scale /= temp;
}
}
st->prev_swb_bwe_frame_pow = curr_frame_pow;
st->prev_ener_shb = EPSILON;
for( i=0; i<L_FRAME16k; i++ )
{
st->prev_ener_shb += shaped_shb_excitation[i] * shaped_shb_excitation[i];
}
st->prev_ener_shb = (float)sqrt(st->prev_ener_shb/L_FRAME16k);
for(i=0; i<SWB_FENV; i++)
{
st->prev_SWB_fenv[i] = (float)sqrt(curr_frame_pow/L_FRAME16k);
}
/* generate 32kHz SHB synthesis from 12.8(16)kHz signal */
GenSHBSynth( shaped_shb_excitation, error, st->genSHBsynth_Hilbert_Mem,
st->genSHBsynth_state_lsyn_filt_shb_local, st->L_frame, &(st->syn_dm_phase) );
mvr2r( error + L_FRAME32k - L_SHB_TRANSITION_LENGTH, st->old_tbe_synth, L_SHB_TRANSITION_LENGTH );
/* resample SHB synthesis (if needed) and scale down */
synth_scale = (st->codec_mode == MODE1) ? 0.9f : 1.f;
if( st->output_Fs == 48000 )
{
if ( st->extl == FB_TBE)
{
for( i=0; i<L_FRAME16k; i++ )
{
White_exc16k[i] *= GainFrame * GainShape[NUM_SHB_SUBFR*i/L_FRAME16k];
}
}
for( i=0; i<L_FRAME32k; i++ )
{
error[i] *= synth_scale;
}
interpolate_3_over_2_allpass( error, L_FRAME32k, synth, st->int_3_over_2_tbemem_dec, allpass_poles_3_ov_2 );
}
else if( st->output_Fs == 32000 )
{
for( i=0; i<L_FRAME32k; i++ )
{
synth[i] = synth_scale * error[i];
}
}
else if( st->output_Fs == 16000 )
{
for( i=0; i<L_FRAME32k; i++ )
{
error[i] *= synth_scale;
}
Decimate_allpass_steep( error, st->mem_resamp_HB_32k, L_FRAME32k, synth );
}
/* Update previous frame parameters for FEC */
mvr2r( lsf_shb, st->lsp_prevfrm, LPC_SHB_ORDER );
if( st->codec_mode == MODE1 )
{
st->GainFrame_prevfrm = GainFrame;
st->tilt_swb_fec = tilt_swb_fec;
if( !st->bfi )
{
st->GainAttn = 1.0f;
}
}
else
{
if( !st->bfi )
{
st->tilt_swb_fec = tilt_swb_fec;
st->GainFrame_prevfrm = GainFrame; /* gain locking on lost frame */
st->GainAttn = 1.0f;
}
}
st->prev_ener = ener_tmp[NUM_SHB_SUBGAINS-1];
st->prev_GainShape = GainShape[NUM_SHB_SUBFR-1];
return;
}
/*-------------------------------------------------------------------*
* Dequant_lower_LSF()
*
* Dequantized the lower LSFs
*-------------------------------------------------------------------*/
static void Dequant_lower_LSF(
const short lsf_idx[], /* i : LSF indices */
float lsf_q[] /* o : Quantized LSFs */
)
{
short i;
lsf_q[0] = lsf_q_cb[0][lsf_idx[0]];
for (i = 1; i < NUM_Q_LSF; i++)
{
lsf_q[i] = lsf_q_cb[i][lsf_idx[i]] + lsf_q[i-1];
}
return;
}
/*-------------------------------------------------------------------*
* Map_higher_LSF()
*
* Map the higher LSFs from the lower LSFs
*-------------------------------------------------------------------*/
static void Map_higher_LSF(
float lsf_q[], /* i/o : Quantized lower LSFs */
const float m, /* i : Mirroring point */
const float grid_in[] /* i : Input LSF smoohthing grid */
)
{
float lsf_map[NUM_MAP_LSF];
float grid[NUM_MAP_LSF];
float last_q_lsf;
float lsf_smooth[NUM_MAP_LSF];
float offset;
short i;
float scale;
for (i = 0; i < NUM_MAP_LSF; i++)
{
lsf_map[i] = 2*m - lsf_q[NUM_MAP_LSF - 1 - i];
}
if (m > MAX_LSF/2)
{
offset = lsf_map[0];
scale = (MAX_LSF - m)/m;
for (i = 0; i < NUM_MAP_LSF; i++)
{
lsf_map[i] = (lsf_map[i] - offset)*scale + offset;
}
}
last_q_lsf = lsf_q[NUM_Q_LSF - 1];
scale = MAX_LSF - last_q_lsf;
for (i = 0; i < NUM_MAP_LSF; i++)
{
grid[i] = grid_in[i]*scale + last_q_lsf;
}
for (i = 0; i < NUM_MAP_LSF; i++)
{
lsf_smooth[i] = (1 - grid_smoothing[i])*lsf_map[i] + grid_smoothing[i]*grid[i];
}
for (i = 0; i < NUM_MAP_LSF; i++)
{
lsf_q[NUM_Q_LSF + i] = lsf_smooth[i];
}
return;
}
/*-------------------------------------------------------------------*
* Map_higher_LSF()
*
* Map the higher LSFs from the lower LSFs
*-------------------------------------------------------------------*/
static void Dequant_mirror_point(
const float lsf_q[], /* i/o : Quantized lower LSFs */
const short m_idx, /* i : Mirror point index */
float *m /* i : Mirroring point */
)
{
*m = mirror_point_q_cb[m_idx] + lsf_q[NUM_Q_LSF - 1];
return;
}
/*-------------------------------------------------------------------*
* dequantizeSHBparams()
*
* Dequantize super highband spectral envolope, temporal gains and frame gain
*-------------------------------------------------------------------*/
static void dequantizeSHBparams(
Decoder_State *st, /* i/o: decoder state structure */
const short extl, /* i : extension layer */
long extl_brate, /* i : extensiuon layer bitrate */
float *Q_lsf, /* o : SHB LSF from de-quantization */
float *Q_subgain, /* o : SHB subframe gains from de-quantization */
float *Q_framegrain, /* o : SHB frame gain from de-quantization */
short *uv_flag, /* o : unvoiced flag */
float *Q_shb_ener_sf,
float *Q_shb_res_gshape,
float *Q_mixFactors
)
{
short i, j, idxLSF, idxSubGain, idxFrameGain;
float Q_combined_gains[NUM_SHB_SUBFR/4];
float lsf_q[LPC_SHB_ORDER];
short lsf_idx[NUM_Q_LSF];
short m_idx, grid_idx;
float m;
short idx_shb_fr_gain, idx_res_gs[5], idx_mixFac;
/* LSFs */
if( extl == WB_TBE )
{
if ( extl_brate == WB_TBE_0k35 )
{
idxFrameGain = st->gFrame_WB;
idxLSF = st->lsf_WB;
mvr2r( lbr_wb_bwe_lsfvq_cbook_2bit + idxLSF*LPC_SHB_ORDER_LBR_WB, Q_lsf, LPC_SHB_ORDER_LBR_WB );
set_f( Q_subgain, RECIP_ROOT_EIGHT, NUM_SHB_SUBFR/2 );
mvr2r( SHBCB_FrameGain16 + idxFrameGain, Q_framegrain, 1 );
}
else
{
/* read the information about UNVOICED frame */
*uv_flag = (short)get_next_indice( st, 1 );
idxSubGain = (short)get_next_indice( st, NUM_BITS_SHB_SUBGAINS );
idxFrameGain = (short)get_next_indice( st, NUM_BITS_SHB_FrameGain );
idxLSF = (short)get_next_indice( st, NUM_BITS_WB_LSF );
mvr2r( wb_bwe_lsfvq_cbook_8bit + idxLSF*LPC_SHB_ORDER_WB, Q_lsf, LPC_SHB_ORDER_WB );
mvr2r( HBCB_SubGain5bit + idxSubGain * NUM_SHB_SUBFR/4, Q_combined_gains, NUM_SHB_SUBFR/4 );
for( i=0; i<NUM_SHB_SUBFR/4; i++ )
{
Q_combined_gains[i] = (float) pow(10.0f, Q_combined_gains[i] / 20.0f);
}
for( i=0; i<NUM_SHB_SUBFR/2; i+=2 )
{
Q_subgain[i] = Q_combined_gains[i/2];
Q_subgain[i+1] = Q_combined_gains[i/2];
}
/* frame gain */
mvr2r( SHBCB_FrameGain64 + idxFrameGain, Q_framegrain, 1 );
}
}
else
{
if( st->codec_mode == MODE2 )
{
idxSubGain = st->idxSubGains;
idxFrameGain = st->idxFrameGain;
}
else
{
idxSubGain = (short)get_next_indice( st, NUM_BITS_SHB_SUBGAINS );
idxFrameGain = (short)get_next_indice( st, NUM_BITS_SHB_FRAMEGAIN );
}
if( st->total_brate == ACELP_24k40 || st->total_brate == ACELP_32k )
{
if( st->codec_mode == MODE2 )
{
idx_shb_fr_gain = st->idx_shb_fr_gain;
}
else
{
idx_shb_fr_gain = (short)get_next_indice( st, NUM_BITS_SHB_ENER_SF );
}
*Q_shb_ener_sf = usdequant(idx_shb_fr_gain, 0, 0.042f);
*Q_shb_ener_sf = (float)pow(10.0, *Q_shb_ener_sf );
for( i=0; i<5; i++ )
{
if( st->codec_mode == MODE2 )
{
idx_res_gs[i] = st->idx_res_gs[i];
}
else
{
idx_res_gs[i] = (short)get_next_indice( st, NUM_BITS_SHB_RES_GS );
}
Q_shb_res_gshape[i] = usdequant(idx_res_gs[i], 0.125f, 0.125f);
}
if( st->codec_mode == MODE2 )
{
idx_mixFac = st->idx_mixFac;
}
else
{
idx_mixFac = (short)get_next_indice( st, NUM_BITS_SHB_VF );
}
*Q_mixFactors = usdequant(idx_mixFac, 0.125f, 0.125f);
}
else
{
*Q_shb_ener_sf = 0;
*Q_mixFactors = 0;
set_f(Q_shb_res_gshape, 0, 5);
}
if( st->rf_flag == 0 && !((st->total_brate == ACELP_9k60) || ( (st->total_brate == 0) && ((st->last_total_brate == ACELP_9k60) || (st->last_total_brate == ACELP_13k20 && st->rf_flag_last)) )) )
{
/* LSFs */
if( extl_brate == SWB_TBE_1k6 || extl_brate == FB_TBE_1k8 || extl_brate == SWB_TBE_2k8 || extl_brate == FB_TBE_3k0 )
{
for( i = 0; i < NUM_Q_LSF; i++ )
{
if( st->codec_mode == MODE2 )
{
lsf_idx[i] = st->lsf_idx[i];
}
else
{
lsf_idx[i] = (short)get_next_indice(st, lsf_q_num_bits[i]);
}
}
}
Dequant_lower_LSF( lsf_idx, lsf_q );
if( st->codec_mode == MODE2 )
{
m_idx = st->m_idx;
grid_idx = st->grid_idx;
}
else
{
m_idx = (short)get_next_indice( st, MIRROR_POINT_BITS );
grid_idx = (short)get_next_indice( st, NUM_LSF_GRID_BITS );
}
Dequant_mirror_point(lsf_q, m_idx, &m);
/* safety check in case of bit errors */
if( m > MAX_LSF )
{
st->BER_detect = 1;
m = MAX_LSF;
}
Map_higher_LSF(lsf_q, m, lsf_grid[grid_idx]);
for( i = 0; i < LPC_SHB_ORDER; i++ )
{
/* safety check in case of bit errors */
if ( lsf_q[LPC_SHB_ORDER - 1 - i] > MAX_LSF )
{
st->BER_detect = 1;
lsf_q[LPC_SHB_ORDER - 1 - i] = MAX_LSF;
}
Q_lsf[i] = 0.5f - lsf_q[LPC_SHB_ORDER - 1 - i];
}
}
else
{
set_s(lsf_idx, 0, 5);
mvs2s(st->lsf_idx, lsf_idx, 5);
grid_idx = 0;
m_idx = 0;
mvr2r( swb_tbe_lsfvq_cbook_8b + lsf_idx[0]*LPC_SHB_ORDER, Q_lsf, LPC_SHB_ORDER );
}
space_lsfs( Q_lsf, LPC_SHB_ORDER );
/* Dequantize subgain indices */
j = idxSubGain*NUM_SHB_SUBGAINS;
for ( i = 0; i < NUM_SHB_SUBGAINS; i++)
{
Q_subgain[i] = (float) pow(10.0, SHBCB_SubGain5bit[j++]);
}
for (i=NUM_SHB_SUBFR-1; i>=0; i--)
{
Q_subgain[i] = Q_subgain[i*NUM_SHB_SUBGAINS/NUM_SHB_SUBFR];
}
/* Frame gain */
*Q_framegrain = usdequant(idxFrameGain, SHB_GAIN_QLOW, SHB_GAIN_QDELTA);
*Q_framegrain = (float) pow(10.0, *Q_framegrain);
}
return;
}
/*-------------------------------------------------------------------*
* fb_tbe_dec()
*
* FB TBE decoder, 14(resp. 15.5) - 20 kHz band decoding module
*-------------------------------------------------------------------*/
void fb_tbe_dec(
Decoder_State *st, /* i/o: encoder state structure */
const float fb_exc[], /* i : FB excitation from the SWB part */
float *hb_synth /* o : high-band synthesis */
)
{
short i;
float ratio = 0, fb_exc_energy = 0;
float fb_synth[L_FRAME48k];
/* decode FB slope information */
if ( st->extl == FB_TBE && !st->bfi )
{
if( st->codec_mode == MODE2 )
{
i = st->idxGain;
}
else
{
i = (short)get_next_indice( st, 4 );
}
ratio = (float)(1 << i);
}
else if ( st->extl == FB_TBE && st->bfi )
{
ratio = st->prev_fbbwe_ratio;
}
fb_exc_energy = sum2_f(fb_exc,L_FRAME16k);
/* FB TBE synthesis */
synthesise_fb_high_band( fb_exc,fb_synth,fb_exc_energy,ratio, st->L_frame, st->bfi, &(st->prev_fbbwe_ratio), st->fbbwe_hpf_mem );
/* add the fb_synth component to the hb_synth component */
v_add( hb_synth, fb_synth, hb_synth, L_FRAME48k );
return;
}
/*---------------------------------------------------------------------*
* tbe_read_bitstream()
*
* Read TBE bitstream and populate the parameters for TD-BWE decoder.
*---------------------------------------------------------------------*/
void tbe_read_bitstream(
Decoder_State *st
)
{
short i;
if ( (st->rf_flag || st->total_brate == ACELP_9k60) && st->bwidth == WB)
{
/* WB LSF */
st->lsf_WB = get_next_indice(st, NUM_BITS_LBR_WB_LSF);
/* WB frame gain */
st->gFrame_WB = get_next_indice(st, NUM_BITS_SHB_FrameGain_LBR_WB);
}
else if( st->total_brate >= ACELP_9k60 && st->total_brate <= ACELP_32k && (st->bwidth == SWB || st->bwidth == FB) )
{
if(st->rf_flag == 0 && st->total_brate > ACELP_9k60)
{
for (i=0; i<NUM_Q_LSF; i++)
{
st->lsf_idx[i] = get_next_indice(st, lsf_q_num_bits[i]);
}
st->m_idx = get_next_indice(st, MIRROR_POINT_BITS);
st->grid_idx = get_next_indice(st, NUM_LSF_GRID_BITS);
}
else
{
st->lsf_idx[0] = get_next_indice(st, 8);
st->m_idx = 0;
st->grid_idx = 0;
}
/* shape gains */
st->idxSubGains = get_next_indice(st, NUM_BITS_SHB_SUBGAINS);
/* frame gain */
st->idxFrameGain = get_next_indice(st, NUM_BITS_SHB_FRAMEGAIN);
if( st->total_brate >= ACELP_24k40 )
{
/* sub frame energy*/
st->idx_shb_fr_gain = get_next_indice(st, NUM_BITS_SHB_ENER_SF);
/* gain shapes residual */
for (i = 0; i < NB_SUBFR16k; i++)
{
st->idx_res_gs[i] = get_next_indice(st, NUM_BITS_SHB_RES_GS);
}
/* voicing factor */
st->idx_mixFac = get_next_indice(st, NUM_BITS_SHB_VF);
}
if( st->tec_tfa == 1 )
{
st->tec_flag = get_next_indice(st, BITS_TEC);
st->tfa_flag = get_next_indice(st, BITS_TFA);
if( st->tfa_flag && st->tec_flag )
{
st->tec_flag = 2;
st->tfa_flag = 0;
}
}
else
{
st->tec_flag = 0;
st->tfa_flag = 0;
}
}
if( st->bwidth == FB )
{
st->idxGain = get_next_indice(st, 4);
}
return;
}
/*---------------------------------------------------------------------*
* GenTransition()
*
* Generate a highband transition signal from the gain shape overlap
* buffer to fill the gap caused by the delay alignment buffer when
* switching from TBE to IGF
*---------------------------------------------------------------------*/
void GenTransition(
const float *input, /* i : gain shape overlap buffer */
const float *old_hb_synth, /* i : synthesized HB from previous frame */
short length, /* i : targeted length of transition signal */
float *output, /* o : synthesized transitions signal */
float Hilbert_Mem[], /* i/o: memory */
float state_lsyn_filt_shb_local[], /* i/o: memory */
short *syn_dm_phase,
int output_Fs,
float *up_mem,
int rf_flag
, int bitrate
)
{
short i;
float syn_overlap_32k[L_FRAME32k];
/* upsample overlap snippet */
Interpolate_allpass_steep( input, state_lsyn_filt_shb_local, SHB_OVERLAP_LEN, syn_overlap_32k );
/* perform spectral flip and downmix with overlap snippet to match HB synth */
if (rf_flag || bitrate == ACELP_9k60)
{
flip_and_downmix_generic( syn_overlap_32k, syn_overlap_32k, 2*SHB_OVERLAP_LEN, Hilbert_Mem,
Hilbert_Mem + HILBERT_ORDER1, Hilbert_Mem + (HILBERT_ORDER1+2*HILBERT_ORDER2), syn_dm_phase );
}
else
{
for(i = 0; i < 2*SHB_OVERLAP_LEN; i++)
{
syn_overlap_32k[i] = ((i%2)==0)?(-syn_overlap_32k[i]):(syn_overlap_32k[i]);
}
}
/* cross fade of overlap snippet and mirrored HB synth from previous frame */
for (i=0; i<2*L_SHB_LAHEAD; i++)
{
output[i] = window_shb_32k[i]*old_hb_synth[L_SHB_TRANSITION_LENGTH-1-i] + window_shb_32k[2*L_SHB_LAHEAD-1-i]*syn_overlap_32k[i];
}
/* fill transition signal with mirrored HB synth from previous frame to fully fill delay alignment buffer gap */
for ( ; i < length; i++)
{
output[i] = old_hb_synth[L_SHB_TRANSITION_LENGTH-1-i];
}
if( output_Fs == 48000 )
{
interpolate_3_over_2_allpass( output, length, output, up_mem, allpass_poles_3_ov_2 );
}
return;
}
void GenTransition_WB(
const float *input, /* i : gain shape overlap buffer */
const float *old_hb_synth, /* i : synthesized HB from previous frame */
short length, /* i : targeted length of transition signal */
float *output, /* o : synthesized transitions signal */
float state_lsyn_filt_shb1[],
float state_lsyn_filt_shb2[],
int output_Fs,
float *up_mem
)
{
short i;
float speech_buf_16k1[L_FRAME16k], speech_buf_16k2[L_FRAME16k];
float upsampled_synth[L_FRAME48k];
/* upsample overlap snippet */
Interpolate_allpass_steep( input, state_lsyn_filt_shb1, SHB_OVERLAP_LEN/2, speech_buf_16k1);
Interpolate_allpass_steep( speech_buf_16k1, state_lsyn_filt_shb2, SHB_OVERLAP_LEN, speech_buf_16k2);
/* perform spectral flip and downmix with overlap snippet to match HB synth */
for(i = 0; i < SHB_OVERLAP_LEN; i++)
{
speech_buf_16k2[i] = ((i%2)==0)?(-speech_buf_16k2[i]):(speech_buf_16k2[i]);
}
/* cross fade of overlap snippet and mirrored HB synth from previous frame */
for (i=0; i<L_SHB_LAHEAD; i++)
{
output[i] = window_shb[i]*old_hb_synth[L_SHB_TRANSITION_LENGTH-1-i] + window_shb[L_SHB_LAHEAD-1-i]*speech_buf_16k2[i];
output[i] *= 0.65f;
}
/* fill transition signal with mirrored HB synth from previous frame to fully fill delay alignment buffer gap */
for ( ; i < length; i++)
{
output[i] = old_hb_synth[L_SHB_TRANSITION_LENGTH-1-i];
output[i] *= 0.65f;
}
/* upsampling if necessary */
if( output_Fs == 32000 )
{
Interpolate_allpass_steep( output, up_mem, L_FRAME16k, upsampled_synth );
mvr2r( upsampled_synth, output, L_FRAME32k );
}
else if( output_Fs == 48000 )
{
interpolate_3_over_1_allpass( output, L_FRAME16k, upsampled_synth, up_mem, allpass_poles_3_ov_2 );
mvr2r( upsampled_synth, output, L_FRAME48k );
}
return;
}
void TBEreset_dec(
Decoder_State *st, /* i/o: decoder state structure */
short bandwidth /* i : bandwidth mode */
)
{
if( st->last_core != ACELP_CORE )
{
set_f( st->old_bwe_exc, 0.0f, PIT16k_MAX * 2 );
st->bwe_non_lin_prev_scale = 0.f;
}
if( bandwidth == WB )
{
wb_tbe_extras_reset( st->mem_genSHBexc_filt_down_wb2, st->mem_genSHBexc_filt_down_wb3 );
wb_tbe_extras_reset_synth( st->state_lsyn_filt_shb, st->state_lsyn_filt_dwn_shb, st->mem_resamp_HB );
set_f( st->mem_genSHBexc_filt_down_shb, 0, 7 );
set_f( st->state_lpc_syn, 0, 10 );
set_f( st->state_syn_shbexc, 0, L_SHB_LAHEAD/4 );
set_f( st->syn_overlap, 0, L_SHB_LAHEAD );
set_f( st->mem_csfilt, 0, 2 );
}
else if( bandwidth == SWB || bandwidth == FB )
{
swb_tbe_reset( st->mem_csfilt, st->mem_genSHBexc_filt_down_shb, st->state_lpc_syn,
st->syn_overlap, st->state_syn_shbexc, &(st->tbe_demph), &(st->tbe_premph),
st->mem_stp_swb, &(st->gain_prec_swb) );
set_f( st->GainShape_Delay, 0, NUM_SHB_SUBFR/2 );
set_f( st->int_3_over_2_tbemem_dec, 0.f, INTERP_3_2_MEM_LEN );
set_f( st->mem_resamp_HB_32k, 0, 2*ALLPASSSECTIONS_STEEP+1 );
swb_tbe_reset_synth( st->genSHBsynth_Hilbert_Mem, st->genSHBsynth_state_lsyn_filt_shb_local );
if ( bandwidth == FB )
{
st->prev_fb_ener_adjust = 0.0f;
set_f(st->fb_state_lpc_syn, 0, LPC_SHB_ORDER);
st->fb_tbe_demph = 0;
fb_tbe_reset_synth( st->fbbwe_hpf_mem, &st->prev_fbbwe_ratio );
}
}
return;
}
| 34.512742 | 208 | 0.486916 | [
"shape"
] |
cd0700f506694b689cf5f9fbf3d726539bce2fe9 | 1,142 | h | C | sort/countingsort.h | GillisWerrebrouck/Algorithms | ce3fc58f5e95afd1542413da2b3204027c7e8edb | [
"MIT"
] | 5 | 2020-03-09T09:14:56.000Z | 2021-05-01T18:13:15.000Z | sort/countingsort.h | GillisWerrebrouck/Algorithms | ce3fc58f5e95afd1542413da2b3204027c7e8edb | [
"MIT"
] | null | null | null | sort/countingsort.h | GillisWerrebrouck/Algorithms | ce3fc58f5e95afd1542413da2b3204027c7e8edb | [
"MIT"
] | 3 | 2020-03-20T20:02:01.000Z | 2021-11-01T19:58:20.000Z | #ifndef COUNTINGNSORT_H
#define COUNTINGNSORT_H
#include <vector>
using std::vector;
using std::swap;
template <typename T>
class CountingSort {
public:
void operator()(vector<T> & v);
};
template <typename T>
void getMinAndMax(vector<T> & v, T & min, T & max) {
if(v.size() == 0) return;
min = max = v[0];
for(int i = 1; i < v.size()-1; i++) {
if(min > v[i]) {
min = v[i];
} else if(max < v[i]) {
max = v[i];
}
}
}
template <typename T>
void CountingSort<T>::operator()(vector<T> & v) {
T min, max;
getMinAndMax(v, min, max);
T range = max - min + 1;
vector<T> count(range), output(v.size());
// count relative frequency of each element
for(int i = 0; i < v.size(); i++)
count[v[i]-min]++;
// count cumulative frequency of each element
for(int i = 1; i < count.size(); i++)
count[i] += count[i-1];
for(int i = v.size()-1; i >= 0; i--) {
output[ count[v[i]-min] -1 ] = v[i];
count[v[i]-min]--;
}
for(int i=0; i < v.size(); i++)
v[i] = output[i];
}
#endif
| 20.763636 | 52 | 0.504378 | [
"vector"
] |
cd074439582c4e38697e60a0e3a4759adb5c905a | 13,027 | c | C | step2.build_gstreamer_project/gst_plugin_tutorial/gst-plugins-bad/ext/dash/gstmpdrepresentationbasenode.c | zhang-jinyu/Smart-Fruit-Scale-based-on-the-VITIS-AI-and-ZCU104 | 3b389cbaa0a4f472d9dd5bb6b994a904fdc6c832 | [
"Apache-2.0"
] | 1 | 2021-03-05T08:43:24.000Z | 2021-03-05T08:43:24.000Z | step2.build_gstreamer_project/gst_plugin_tutorial/gst-plugins-bad/ext/dash/gstmpdrepresentationbasenode.c | zhang-jinyu/Smart-Fruit-Scale-based-on-the-VITIS-AI-and-ZCU104 | 3b389cbaa0a4f472d9dd5bb6b994a904fdc6c832 | [
"Apache-2.0"
] | null | null | null | step2.build_gstreamer_project/gst_plugin_tutorial/gst-plugins-bad/ext/dash/gstmpdrepresentationbasenode.c | zhang-jinyu/Smart-Fruit-Scale-based-on-the-VITIS-AI-and-ZCU104 | 3b389cbaa0a4f472d9dd5bb6b994a904fdc6c832 | [
"Apache-2.0"
] | null | null | null | /* GStreamer
*
* Copyright (C) 2019 Collabora Ltd.
* Author: Stéphane Cerveau <scerveau@collabora.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "gstmpdrepresentationbasenode.h"
#include "gstmpdparser.h"
G_DEFINE_TYPE (GstMPDRepresentationBaseNode, gst_mpd_representation_base_node,
GST_TYPE_MPD_NODE);
enum
{
PROP_MPD_REPRESENTATION_BASE_0 = 100,
PROP_MPD_REPRESENTATION_BASE_PROFILES,
PROP_MPD_REPRESENTATION_BASE_WIDTH,
PROP_MPD_REPRESENTATION_BASE_HEIGHT,
PROP_MPD_REPRESENTATION_BASE_SAR,
PROP_MPD_REPRESENTATION_BASE_MIN_FRAME_RATE,
PROP_MPD_REPRESENTATION_BASE_MAX_FRAME_RATE,
PROP_MPD_REPRESENTATION_BASE_FRAME_RATE,
PROP_MPD_REPRESENTATION_BASE_AUDIO_SAMPLING_RATE,
PROP_MPD_REPRESENTATION_BASE_MIMETYPE,
PROP_MPD_REPRESENTATION_BASE_SEGMENT_PROFILES,
PROP_MPD_REPRESENTATION_BASE_CODECS,
PROP_MPD_REPRESENTATION_BASE_MAX_SAP_PERIOD,
PROP_MPD_REPRESENTATION_BASE_START_WITH_SAP,
PROP_MPD_REPRESENTATION_BASE_MAX_PLAYOUT_RATE,
PROP_MPD_REPRESENTATION_BASE_CODING_DEPENDENCY,
PROP_MPD_REPRESENTATION_BASE_SCAN_TYPE,
};
/* GObject VMethods */
static void
gst_mpd_representation_base_node_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstMPDRepresentationBaseNode *self =
GST_MPD_REPRESENTATION_BASE_NODE (object);
switch (prop_id) {
case PROP_MPD_REPRESENTATION_BASE_PROFILES:
g_free (self->profiles);
self->profiles = g_value_dup_string (value);
break;
case PROP_MPD_REPRESENTATION_BASE_WIDTH:
self->width = g_value_get_uint (value);
break;
case PROP_MPD_REPRESENTATION_BASE_HEIGHT:
self->height = g_value_get_uint (value);
break;
case PROP_MPD_REPRESENTATION_BASE_SAR:
g_slice_free (GstXMLRatio, self->sar);
self->sar = gst_xml_helper_clone_ratio (g_value_get_pointer (value));
break;
case PROP_MPD_REPRESENTATION_BASE_MIN_FRAME_RATE:
g_slice_free (GstXMLFrameRate, self->minFrameRate);
self->minFrameRate =
gst_xml_helper_clone_frame_rate (g_value_get_pointer (value));
break;
case PROP_MPD_REPRESENTATION_BASE_MAX_FRAME_RATE:
g_slice_free (GstXMLFrameRate, self->maxFrameRate);
self->maxFrameRate =
gst_xml_helper_clone_frame_rate (g_value_get_pointer (value));
break;
case PROP_MPD_REPRESENTATION_BASE_FRAME_RATE:
g_slice_free (GstXMLFrameRate, self->frameRate);
self->frameRate =
gst_xml_helper_clone_frame_rate (g_value_get_pointer (value));
break;
case PROP_MPD_REPRESENTATION_BASE_AUDIO_SAMPLING_RATE:
g_free (self->audioSamplingRate);
self->audioSamplingRate =
g_strdup_printf ("%u", g_value_get_uint (value));
break;
case PROP_MPD_REPRESENTATION_BASE_MIMETYPE:
g_free (self->mimeType);
self->mimeType = g_value_dup_string (value);
break;
case PROP_MPD_REPRESENTATION_BASE_SEGMENT_PROFILES:
g_free (self->segmentProfiles);
self->segmentProfiles = g_value_dup_string (value);
break;
case PROP_MPD_REPRESENTATION_BASE_CODECS:
g_free (self->codecs);
self->codecs = g_value_dup_string (value);
break;
case PROP_MPD_REPRESENTATION_BASE_MAX_SAP_PERIOD:
self->maximumSAPPeriod = g_value_get_double (value);
break;
case PROP_MPD_REPRESENTATION_BASE_START_WITH_SAP:
self->startWithSAP = g_value_get_int (value);
break;
case PROP_MPD_REPRESENTATION_BASE_MAX_PLAYOUT_RATE:
self->maxPlayoutRate = g_value_get_double (value);
break;
case PROP_MPD_REPRESENTATION_BASE_CODING_DEPENDENCY:
self->codingDependency = g_value_get_boolean (value);
break;
case PROP_MPD_REPRESENTATION_BASE_SCAN_TYPE:
g_free (self->scanType);
self->scanType = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_mpd_representation_base_node_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstMPDRepresentationBaseNode *self =
GST_MPD_REPRESENTATION_BASE_NODE (object);
switch (prop_id) {
case PROP_MPD_REPRESENTATION_BASE_PROFILES:
g_value_set_string (value, self->profiles);
break;
case PROP_MPD_REPRESENTATION_BASE_WIDTH:
g_value_set_uint (value, self->width);
break;
case PROP_MPD_REPRESENTATION_BASE_HEIGHT:
g_value_set_uint (value, self->height);
break;
case PROP_MPD_REPRESENTATION_BASE_SAR:
g_value_set_pointer (value, self->sar);
break;
case PROP_MPD_REPRESENTATION_BASE_MIN_FRAME_RATE:
g_value_set_pointer (value, self->minFrameRate);
break;
case PROP_MPD_REPRESENTATION_BASE_MAX_FRAME_RATE:
g_value_set_pointer (value, self->maxFrameRate);
break;
case PROP_MPD_REPRESENTATION_BASE_FRAME_RATE:
g_value_set_pointer (value, self->frameRate);
break;
case PROP_MPD_REPRESENTATION_BASE_AUDIO_SAMPLING_RATE:
g_value_set_uint (value, atoi (self->audioSamplingRate));
break;
case PROP_MPD_REPRESENTATION_BASE_MIMETYPE:
g_value_set_string (value, self->mimeType);
break;
case PROP_MPD_REPRESENTATION_BASE_SEGMENT_PROFILES:
g_value_set_string (value, self->segmentProfiles);
break;
case PROP_MPD_REPRESENTATION_BASE_CODECS:
g_value_set_string (value, self->codecs);
break;
case PROP_MPD_REPRESENTATION_BASE_MAX_SAP_PERIOD:
g_value_set_double (value, self->maximumSAPPeriod);
break;
case PROP_MPD_REPRESENTATION_BASE_START_WITH_SAP:
g_value_set_int (value, self->startWithSAP);
break;
case PROP_MPD_REPRESENTATION_BASE_MAX_PLAYOUT_RATE:
g_value_set_double (value, self->maxPlayoutRate);
break;
case PROP_MPD_REPRESENTATION_BASE_CODING_DEPENDENCY:
g_value_set_boolean (value, self->codingDependency);
self->codingDependency = g_value_get_boolean (value);
break;
case PROP_MPD_REPRESENTATION_BASE_SCAN_TYPE:
g_value_set_string (value, self->scanType);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_mpd_representation_base_node_finalize (GObject * object)
{
GstMPDRepresentationBaseNode *self =
GST_MPD_REPRESENTATION_BASE_NODE (object);
if (self->profiles)
xmlFree (self->profiles);
g_slice_free (GstXMLRatio, self->sar);
g_slice_free (GstXMLFrameRate, self->frameRate);
g_slice_free (GstXMLFrameRate, self->minFrameRate);
g_slice_free (GstXMLFrameRate, self->maxFrameRate);
if (self->audioSamplingRate)
xmlFree (self->audioSamplingRate);
if (self->mimeType)
xmlFree (self->mimeType);
if (self->segmentProfiles)
xmlFree (self->segmentProfiles);
if (self->codecs)
xmlFree (self->codecs);
if (self->scanType)
xmlFree (self->scanType);
g_list_free_full (self->FramePacking,
(GDestroyNotify) gst_mpd_descriptor_type_node_free);
g_list_free_full (self->AudioChannelConfiguration,
(GDestroyNotify) gst_mpd_descriptor_type_node_free);
g_list_free_full (self->ContentProtection,
(GDestroyNotify) gst_mpd_descriptor_type_node_free);
G_OBJECT_CLASS (gst_mpd_representation_base_node_parent_class)->finalize
(object);
}
/* Base class */
static void
gst_mpd_representation_base_get_xml_node (GstMPDNode * node,
xmlNodePtr representation_base_node)
{
GstMPDRepresentationBaseNode *self = GST_MPD_REPRESENTATION_BASE_NODE (node);
if (self->profiles)
gst_xml_helper_set_prop_string (representation_base_node, "profiles",
self->profiles);
if (self->width)
gst_xml_helper_set_prop_uint (representation_base_node, "width",
self->width);
if (self->height)
gst_xml_helper_set_prop_uint (representation_base_node, "height",
self->height);
gst_xml_helper_set_prop_ratio (representation_base_node, "sar", self->sar);
gst_xml_helper_set_prop_framerate (representation_base_node, "minFrameRate",
self->minFrameRate);
gst_xml_helper_set_prop_framerate (representation_base_node, "maxFrameRate",
self->maxFrameRate);
gst_xml_helper_set_prop_framerate (representation_base_node, "frameRate",
self->frameRate);
gst_xml_helper_set_prop_string (representation_base_node,
"audioSamplingRate", self->audioSamplingRate);
gst_xml_helper_set_prop_string (representation_base_node, "mimeType",
self->mimeType);
gst_xml_helper_set_prop_string (representation_base_node, "segmentProfiles",
self->segmentProfiles);
gst_xml_helper_set_prop_string (representation_base_node, "codecs",
self->codecs);
if (self->maximumSAPPeriod)
gst_xml_helper_set_prop_double (representation_base_node,
"maximumSAPPeriod", self->maximumSAPPeriod);
if (self->startWithSAP)
gst_xml_helper_set_prop_int (representation_base_node, "startWithSAP",
self->startWithSAP);
if (self->maxPlayoutRate)
gst_xml_helper_set_prop_double (representation_base_node, "maxPlayoutRate",
self->maxPlayoutRate);
if (self->codingDependency)
gst_xml_helper_set_prop_boolean (representation_base_node,
"codingDependency", self->codingDependency);
gst_xml_helper_set_prop_string (representation_base_node, "scanType",
self->scanType);
g_list_foreach (self->FramePacking,
gst_mpd_node_get_list_item, representation_base_node);
g_list_foreach (self->AudioChannelConfiguration,
gst_mpd_node_get_list_item, representation_base_node);
g_list_foreach (self->ContentProtection,
gst_mpd_node_get_list_item, representation_base_node);
}
static void
gst_mpd_representation_base_node_class_init (GstMPDRepresentationBaseNodeClass *
klass)
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gst_mpd_representation_base_node_finalize;
object_class->set_property = gst_mpd_representation_base_node_set_property;
object_class->get_property = gst_mpd_representation_base_node_get_property;
g_object_class_install_property (object_class,
PROP_MPD_REPRESENTATION_BASE_WIDTH, g_param_spec_uint ("width",
"width", "representation width", 0, G_MAXUINT, 0,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class,
PROP_MPD_REPRESENTATION_BASE_HEIGHT, g_param_spec_uint ("height",
"height", "representation height", 0, G_MAXUINT, 0,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class,
PROP_MPD_REPRESENTATION_BASE_MIMETYPE, g_param_spec_string ("mime-type",
"mimetype", "representation mimetype", NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class,
PROP_MPD_REPRESENTATION_BASE_CODECS, g_param_spec_string ("codecs",
"codecs", "representation codec", NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class,
PROP_MPD_REPRESENTATION_BASE_AUDIO_SAMPLING_RATE,
g_param_spec_uint ("audio-sampling-rate", "audio sampling rate",
"representation audio sampling rate", 0, G_MAXUINT, 0,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
static void
gst_mpd_representation_base_node_init (GstMPDRepresentationBaseNode * self)
{
self->profiles = NULL;
self->width = 0;
self->height = 0;
self->sar = NULL;
self->minFrameRate = NULL;
self->maxFrameRate = NULL;
self->frameRate = NULL;
self->audioSamplingRate = NULL;
self->mimeType = NULL;
self->segmentProfiles = NULL;
self->codecs = NULL;
self->maximumSAPPeriod = 0;
self->startWithSAP = GST_SAP_TYPE_0;
self->maxPlayoutRate = 0.0;
self->codingDependency = FALSE;
self->scanType = NULL;
self->FramePacking = NULL;
self->AudioChannelConfiguration = NULL;
self->ContentProtection = NULL;
}
void
gst_mpd_representation_base_node_get_list_item (gpointer data,
gpointer user_data)
{
GstMPDNode *node = (GstMPDNode *) data;
xmlNodePtr parent_xml_node = (xmlNodePtr) user_data;
xmlNodePtr new_xml_node = gst_mpd_node_get_xml_pointer (node);
gst_mpd_representation_base_get_xml_node (node, new_xml_node);
xmlAddChild (parent_xml_node, new_xml_node);
}
| 37.326648 | 80 | 0.759423 | [
"object"
] |
fa5a57d8e5b1a238d1aa95ed12e03f3b7998c34a | 6,140 | h | C | src/WeatherAPI_com/64x64/night/359.h | MHotchin/RLEBitmap | ebea6f7f032c235ff2301e2aced1e6180b71882e | [
"MIT"
] | 8 | 2020-07-05T17:00:15.000Z | 2022-02-08T04:34:50.000Z | src/WeatherAPI_com/64x64/night/359.h | MHotchin/RLEBitmap | ebea6f7f032c235ff2301e2aced1e6180b71882e | [
"MIT"
] | 2 | 2020-07-04T21:11:49.000Z | 2020-08-11T20:23:06.000Z | src/WeatherAPI_com/64x64/night/359.h | MHotchin/RLEBitmap | ebea6f7f032c235ff2301e2aced1e6180b71882e | [
"MIT"
] | 3 | 2020-07-05T17:00:22.000Z | 2020-11-03T11:18:34.000Z |
//
// This file is AUTOMATICALLY GENERATED, and should not be edited unless you are certain
// that it will not be re-generated anytime in the future. As generated code, the
// copyright owner(s) of the generating program do NOT claim any copyright on the code
// generated.
//
// Run Length Encoded (RLE) bitmaps. Each run is encoded as either one or two bytes,
// with NO PADDING. Thus, the data for each line of the bitmap is VARIABLE LENGTH, and
// there is no way of determining where any line other than the first starts without
// walking though the data.
//
// Note that one byte encoding ONLY occurs if the total number of colors is 16 or less,
// and in that case the 'flags' member of the 'RLEBitmapInfo' will have the first bit
// (0x01) set.
//
// In that case, if the high 4 bits of the first byte are ZERO, then this is a 2 byte
// run. The first byte is the index of the color in the color palette, and the second
// byte is the length.
//
// Else, the lower 4 bits are the color index, and the upper 4 bits are the run length.
//
// If the 'flags' member first bit is zero, then ALL runs are 2 byte runs. The first
// byte is the palette index, and the second is the run length.
//
// In order to save PROGMEM for other uses, the bitmap data is placed in a section that
// occurs near the END of the used FLASH. So, this data should only be accessed using
// the 'far' versions of the progmem functions - the usual versions are limited to the
// first 64K of FLASH.
//
// Data is from file '64x64\night\Processed\359.bmp'.
//
const byte 359_RLEBM_data[] PROGMEM_LATE =
{
0x00, 0x40,
0x00, 0x40,
0x00, 0x40,
0x00, 0x40,
0xe0, 0x21, 0x32, 0x21, 0x00, 0x2b,
0xc0, 0x11, 0x93, 0x11, 0x00, 0x29,
0xb0, 0xc3, 0x11, 0x00, 0x28,
0xa0, 0x43, 0x14, 0x35, 0x14, 0x33, 0x11, 0x00, 0x29,
0x90, 0x43, 0x55, 0x33, 0x11, 0x00, 0x2a,
0x80, 0x11, 0x33, 0x55, 0x14, 0x23, 0x12, 0x00, 0x2b,
0x80, 0x33, 0x65, 0x33, 0x00, 0x2c,
0x70, 0x11, 0x23, 0x14, 0x65, 0x23, 0x12, 0x00, 0x2c,
0x70, 0x11, 0x23, 0x65, 0x14, 0x23, 0x11, 0x00, 0x2c,
0x70, 0x12, 0x23, 0x65, 0x14, 0x23, 0x00, 0x2d,
0x70, 0x12, 0x23, 0x65, 0x33, 0x00, 0x2d,
0x70, 0x12, 0x23, 0x65, 0x14, 0x23, 0x11, 0x00, 0x2c,
0x70, 0x11, 0x23, 0x14, 0x55, 0x14, 0x23, 0x11, 0x00, 0x2c,
0x80, 0x33, 0x65, 0x23, 0x12, 0x00, 0x10, 0x96, 0x00, 0x13,
0x80, 0x12, 0x23, 0x14, 0x55, 0x33, 0x11, 0xd0, 0xd6, 0x00, 0x11,
0x90, 0x33, 0x14, 0x55, 0x33, 0xb0, 0x76, 0x31, 0x66, 0x00, 0x10,
0x90, 0x11, 0x33, 0x14, 0x45, 0x14, 0x23, 0x12, 0x90, 0x56, 0x21, 0x57, 0x21, 0x46, 0xf0,
0xa0, 0x11, 0x53, 0x34, 0x43, 0x11, 0x60, 0x46, 0x21, 0x97, 0x21, 0x36, 0xe0,
0xb0, 0x11, 0xb3, 0x70, 0x36, 0x11, 0xd7, 0x11, 0x36, 0xd0,
0xd0, 0x11, 0x63, 0x12, 0x11, 0x70, 0x36, 0x11, 0xf7, 0x11, 0x36, 0xc0,
0x00, 0x10, 0x21, 0x80, 0x66, 0x11, 0xf7, 0x11, 0x36, 0xc0,
0x00, 0x17, 0x86, 0x11, 0x07, 0x11, 0x11, 0x36, 0xb0,
0x00, 0x16, 0x96, 0x11, 0x07, 0x11, 0x11, 0x36, 0xb0,
0x00, 0x15, 0x46, 0x61, 0x07, 0x13, 0x36, 0xb0,
0x00, 0x14, 0x46, 0x11, 0x07, 0x19, 0x36, 0xb0,
0x00, 0x13, 0x46, 0x11, 0x07, 0x1a, 0x36, 0xb0,
0x00, 0x13, 0x36, 0x11, 0x07, 0x1b, 0x56, 0x90,
0x00, 0x12, 0x36, 0x11, 0x07, 0x1c, 0x66, 0x80,
0x00, 0x11, 0x46, 0x11, 0x07, 0x1d, 0x21, 0x46, 0x70,
0x00, 0x10, 0x56, 0x07, 0x20, 0x11, 0x36, 0x70,
0xf0, 0x56, 0x11, 0x07, 0x21, 0x11, 0x36, 0x60,
0xe0, 0x46, 0x11, 0x07, 0x23, 0x11, 0x36, 0x60,
0xe0, 0x36, 0x11, 0x07, 0x25, 0x36, 0x60,
0xd0, 0x36, 0x11, 0x07, 0x26, 0x11, 0x26, 0x60,
0xd0, 0x36, 0x11, 0x07, 0x26, 0x11, 0x26, 0x60,
0xd0, 0x36, 0x11, 0x07, 0x26, 0x36, 0x60,
0xd0, 0x36, 0x11, 0x07, 0x25, 0x11, 0x36, 0x60,
0xe0, 0x26, 0x11, 0x07, 0x25, 0x46, 0x60,
0xe0, 0x36, 0x11, 0x07, 0x22, 0x21, 0x36, 0x70,
0xf0, 0x36, 0x31, 0x07, 0x1c, 0x31, 0x46, 0x80,
0xf0, 0x06, 0x28, 0x90,
0x00, 0x10, 0x06, 0x26, 0xa0,
0x00, 0x12, 0x06, 0x22, 0xc0,
0x00, 0x40,
0x00, 0x40,
0x00, 0x40,
0x00, 0x13, 0x11, 0x24, 0x13, 0x20, 0x11, 0x24, 0x13, 0x20, 0x11, 0x24, 0x13, 0x20, 0x11, 0x24, 0x13, 0x20, 0x11, 0x24, 0x13, 0x20, 0x11, 0x24, 0x13, 0xb0,
0x00, 0x13, 0x13, 0x24, 0x11, 0x20, 0x13, 0x24, 0x11, 0x20, 0x13, 0x24, 0x11, 0x20, 0x13, 0x24, 0x11, 0x20, 0x13, 0x24, 0x11, 0x20, 0x13, 0x24, 0x11, 0xb0,
0x00, 0x12, 0x11, 0x24, 0x13, 0x20, 0x11, 0x24, 0x13, 0x20, 0x11, 0x24, 0x13, 0x20, 0x11, 0x24, 0x13, 0x20, 0x11, 0x24, 0x13, 0x20, 0x11, 0x24, 0x13, 0xc0,
0x00, 0x12, 0x13, 0x24, 0x11, 0x20, 0x13, 0x24, 0x11, 0x20, 0x13, 0x24, 0x11, 0x20, 0x13, 0x24, 0x11, 0x20, 0x13, 0x24, 0x11, 0x20, 0x13, 0x24, 0x11, 0xc0,
0x00, 0x11, 0x11, 0x24, 0x13, 0x20, 0x11, 0x24, 0x13, 0x20, 0x11, 0x24, 0x13, 0x20, 0x11, 0x24, 0x13, 0x20, 0x11, 0x24, 0x13, 0x20, 0x11, 0x24, 0x13, 0xd0,
0x00, 0x11, 0x13, 0x24, 0x11, 0x20, 0x13, 0x24, 0x11, 0x20, 0x13, 0x24, 0x11, 0x20, 0x13, 0x24, 0x11, 0x20, 0x13, 0x24, 0x11, 0x20, 0x13, 0x24, 0x11, 0xd0,
0x00, 0x10, 0x11, 0x24, 0x13, 0x20, 0x11, 0x24, 0x13, 0x20, 0x11, 0x24, 0x13, 0x20, 0x11, 0x24, 0x13, 0x20, 0x11, 0x24, 0x13, 0x20, 0x11, 0x24, 0x13, 0xe0,
0x00, 0x10, 0x13, 0x24, 0x11, 0x20, 0x13, 0x24, 0x11, 0x20, 0x13, 0x24, 0x11, 0x20, 0x13, 0x24, 0x11, 0x20, 0x13, 0x24, 0x11, 0x20, 0x13, 0x24, 0x11, 0xe0,
0xf0, 0x11, 0x24, 0x13, 0x20, 0x11, 0x24, 0x13, 0x20, 0x11, 0x24, 0x13, 0x20, 0x11, 0x24, 0x13, 0x20, 0x11, 0x24, 0x13, 0x20, 0x11, 0x24, 0x13, 0xf0,
0x00, 0x40,
0x00, 0x40,
0x00, 0x40,
0x00, 0x40,
0x00, 0x40,
}; // 64x64 Bitmap (4096 pixels) in 615 bytes
const uint16_t 359_RLEBM_palette[] PROGMEM_LATE =
{
// Palette has 8 entries
0x0000, 0x2a0a, 0x2b33, 0x0bba, 0x345b, 0xdf1d, 0x2966, 0x8c72,
};
// Some platforms don't fully implement the pgmspace.h interface. Assume ordinary
// addresses will do.
#if not defined pgm_get_far_address
#define pgm_get_far_address(x) ((uint32_t)(&(x)))
#endif
// Returns the info needed to render the bitmap.
inline void get_359_RLEBM(
RLEBitmapInfo &bmInfo)
{
bmInfo.pRLEBM_data_far = pgm_get_far_address(359_RLEBM_data);
bmInfo.pRLEBM_palette_far = pgm_get_far_address(359_RLEBM_palette);
bmInfo.width = 64;
bmInfo.height = 64;
bmInfo.flags = 0x01;
}
| 48.346457 | 157 | 0.67557 | [
"render"
] |
fa6899c6a7035b35a348a67276f1ec50a7357b0f | 1,716 | h | C | ui/ozone/platform/wayland/host/wayland_data_device_manager.h | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 14,668 | 2015-01-01T01:57:10.000Z | 2022-03-31T23:33:32.000Z | ui/ozone/platform/wayland/host/wayland_data_device_manager.h | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 86 | 2015-10-21T13:02:42.000Z | 2022-03-14T07:50:50.000Z | ui/ozone/platform/wayland/host/wayland_data_device_manager.h | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 5,941 | 2015-01-02T11:32:21.000Z | 2022-03-31T16:35:46.000Z | // Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_DATA_DEVICE_MANAGER_H_
#define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_DATA_DEVICE_MANAGER_H_
#include <memory>
#include "ui/ozone/platform/wayland/common/wayland_object.h"
#include "ui/ozone/platform/wayland/host/wayland_data_source.h"
namespace ui {
class WaylandConnection;
class WaylandDataDevice;
class WaylandDataDeviceManager
: public wl::GlobalObjectRegistrar<WaylandDataDeviceManager> {
public:
static constexpr char kInterfaceName[] = "wl_data_device_manager";
static void Instantiate(WaylandConnection* connection,
wl_registry* registry,
uint32_t name,
const std::string& interface,
uint32_t version);
using DataSource = WaylandDataSource;
using DataDevice = WaylandDataDevice;
WaylandDataDeviceManager(wl_data_device_manager* device_manager,
WaylandConnection* connection);
WaylandDataDeviceManager(const WaylandDataDeviceManager&) = delete;
WaylandDataDeviceManager& operator=(const WaylandDataDeviceManager&) = delete;
~WaylandDataDeviceManager();
WaylandDataDevice* GetDevice();
std::unique_ptr<WaylandDataSource> CreateSource(
WaylandDataSource::Delegate* delegate);
private:
wl::Object<wl_data_device_manager> device_manager_;
WaylandConnection* const connection_;
std::unique_ptr<WaylandDataDevice> device_;
};
} // namespace ui
#endif // UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_DATA_DEVICE_MANAGER_H_
| 32.377358 | 80 | 0.752331 | [
"object"
] |
fa6ad88309283e7de7403ac4541b44fb960cb582 | 2,051 | c | C | nitan/d/hangzhou/jiudian.c | cantona/NT6 | 073f4d491b3cfe6bfbe02fbad12db8983c1b9201 | [
"MIT"
] | 1 | 2019-03-27T07:25:16.000Z | 2019-03-27T07:25:16.000Z | nitan/d/hangzhou/jiudian.c | cantona/NT6 | 073f4d491b3cfe6bfbe02fbad12db8983c1b9201 | [
"MIT"
] | null | null | null | nitan/d/hangzhou/jiudian.c | cantona/NT6 | 073f4d491b3cfe6bfbe02fbad12db8983c1b9201 | [
"MIT"
] | null | null | null | //Cracked by Roath
// /d/hangzhou/jiudian.c 牛家村酒店
// by maco 99/12/22
#include <room.h>
#include <ansi.h>
inherit ROOM;
void create()
{ set("short", "酒店");
set("long", @LONG
這是座單門獨户的小酒店,檐下襬着兩張板桌,桌上罩着厚厚一
層灰塵,東首擺了個碗櫥。小酒店的主人是個跛子,可以向他打酒(f
ill)。店中似乎也沒什麼菜色,無非是些蠶豆、花生等下酒之物。
LONG );
set("exits", ([ /* sizeof() == 2 */
"west" : __DIR__"village",
])
);
set("objects", ([
CLASS_D("taohua") + "/qusan" : 1
]));
set("cost", 1);
set("outdoors", "hangzhou");
set("coor/x", 3890);
set("coor/y", -1800);
set("coor/z", 0);
setup();
}
void init()
{
add_action("do_fill", "fill");
}
int do_fill(string arg)
{
object ob, obj, me = this_player();
if (!objectp(obj = present("qu san", environment(me))))
{ write("掌櫃的不在!\n");
return 1;
}
if (!living(obj)){
write("你還是等掌櫃的醒過來再説吧。\n");
return 1;
}
if( !arg || !(ob=present(arg,this_player())) || !query("liquid", ob)){
write("你要把酒裝在哪兒?\n");
return 1;
}
switch (MONEY_D->player_pay(this_player(), 20)) {
case 0: {
write("窮光蛋,一邊呆着去!\n");
return 1;
}
case 2: {
write("您的零錢不夠了,銀票又沒人找得開。\n");
return 1;
}
}
if( query("liquid/remaining", ob) )
message_vision("$N將"+ob->name()+"裏剩下的"+query("liquid/name", ob)+
"倒掉。\n", this_player());
message_vision("$N給曲三二十文銅板。\n曲三給$N的"+ob->name()+"裝滿燒酒。\n", this_player());
if( this_player()->is_fighting() ) this_player()->start_busy(2);
set("liquid/type", "alcohol", ob);
set("liquid/name", "燒酒", ob);
set("liquid/remaining", query("max_liquid"), ob);
set("liquid/drink_func", 0, ob);
set("liquid/drunk_apply", 4, ob);
return 1;
} | 25.012195 | 82 | 0.462701 | [
"object"
] |
fa74a6a2f0eee77b1e7b5b0caa1bb9f6d1a6b434 | 3,113 | h | C | include/MediaParser/H264UserData.h | MultiSight/multisight-mediaparser | a7627fcd0b0cad467bba436a0363c04ea74c5574 | [
"BSL-1.0"
] | 2 | 2017-09-16T13:59:15.000Z | 2019-04-24T03:25:36.000Z | include/MediaParser/H264UserData.h | MultiSight/multisight-mediaparser | a7627fcd0b0cad467bba436a0363c04ea74c5574 | [
"BSL-1.0"
] | null | null | null | include/MediaParser/H264UserData.h | MultiSight/multisight-mediaparser | a7627fcd0b0cad467bba436a0363c04ea74c5574 | [
"BSL-1.0"
] | 1 | 2019-04-24T03:25:40.000Z | 2019-04-24T03:25:40.000Z |
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//
// XSDK
// Copyright (c) 2015 Schneider Electric
//
// Use, modification, and distribution is subject to the Boost Software License,
// Version 1.0 (See accompanying file LICENSE).
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#ifndef _H264UserData_H_
#define _H264UserData_H_
#include <vector>
#include "XSDK/Types.h"
#include "XSDK/XRef.h"
#include "XSDK/XBaseObject.h"
#include "XSDK/XMemory.h"
#include "XSDK/XString.h"
#include "XSDK/XUuid.h"
class H264UserDataTest;
namespace MEDIA_PARSER
{
///
class SEIPayload : public XSDK::XBaseObject
{
public:
/// Constructor
///
/// AFAIK, the UUID really doesn't matter unless we decide to do something
/// in particular with it. The default comes from uuidgen and has no
/// significance. You should be able to ignore the fact that a UUID is used
/// at all.
X_API SEIPayload(const XIRef<XSDK::XMemory> data,
const XSDK::XUuid& uuid = XSDK::XString("7e0858c4-38fe-48ea-852d-dace39badb30"))
: XBaseObject(),
_data(data),
_uuid(uuid)
{}
///
X_API SEIPayload(const uint8_t* data,
size_t length,
const XSDK::XUuid uuid = XSDK::XString("7e0858c4-38fe-48ea-852d-dace39badb30"));
///
X_API const XIRef<XSDK::XMemory> GetData() const {return _data;}
///
X_API const XSDK::XUuid& GetUUID() const {return _uuid;}
private:
XIRef<XSDK::XMemory> _data;
XSDK::XUuid _uuid;
};
///
class H264UserData
{
friend class ::H264UserDataTest;
public:
/// Reads in an existing SEI nal unit from a buffer.
X_API H264UserData(const uint8_t* buffer, size_t length);
///
X_API H264UserData(XRef<SEIPayload> payload)
: _payloads(1, payload)
{}
///
X_API H264UserData(std::vector<XRef<SEIPayload> > payloads)
: _payloads(payloads)
{
X_ASSERT(!_payloads.empty());
}
///
X_API XIRef<XSDK::XMemory> GenSEI() const;
///
X_API const std::vector<XRef<SEIPayload> >& GetPayloads() const {return _payloads;}
private:
static void _AddPayloadData(XIRef<XSDK::XMemory> data, const XIRef<XSDK::XMemory> payloadData);
static void _AddPayloadNum(XIRef<XSDK::XMemory> data, int n);
static void _AddSEIMessage(XIRef<XSDK::XMemory> data, XRef<SEIPayload> payload);
static void _AddUUID(XIRef<XSDK::XMemory> data, const X_UUID& uuid);
X_API static XIRef<XSDK::XMemory> _Denalify(const uint8_t* buffer, size_t length);
X_API static XIRef<XSDK::XMemory> _Nalify(const XIRef<XSDK::XMemory> data);
static XRef<SEIPayload> _ProcessSEIMessage(const XIRef<XSDK::XMemory> data, size_t& i);
static XRef<SEIPayload> _ProcessPayload(const XIRef<XSDK::XMemory> data,
size_t& i,
uint32_t payloadType,
size_t payloadSize);
std::vector<XRef<SEIPayload> > _payloads;
};
}
#endif
| 27.794643 | 101 | 0.608095 | [
"vector"
] |
fa759ac9bf425b1bd9afc7024ab2434cfa692736 | 9,434 | h | C | src/infact/interpreter.h | alex-quiterio/infact | 478b005263534b5809dcd67bef280fbdecec6392 | [
"BSD-3-Clause"
] | null | null | null | src/infact/interpreter.h | alex-quiterio/infact | 478b005263534b5809dcd67bef280fbdecec6392 | [
"BSD-3-Clause"
] | null | null | null | src/infact/interpreter.h | alex-quiterio/infact | 478b005263534b5809dcd67bef280fbdecec6392 | [
"BSD-3-Clause"
] | null | null | null | // Copyright 2014, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// -----------------------------------------------------------------------------
//
//
/// \file
/// Provides an interpreter for assigning primitives and Factory-constructible
/// objects to named variables, as well as vectors thereof.
/// \author dbikel@google.com (Dan Bikel)
#ifndef INFACT_INTERPRETER_H_
#define INFACT_INTERPRETER_H_
#include <iostream>
#include <fstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include "environment-impl.h"
namespace infact {
using std::iostream;
using std::ifstream;
class EnvironmentImpl;
/// Provides an interpreter for assigning primitives and
/// Factory-constructible objects to named variables, as well as
/// vectors thereof. The interpreter maintains an internal
/// environment whereby previously defined variables may be used in
/// the definition of subsequent ones. The syntax of this language
/// extends the syntax of the \link infact::Factory Factory \endlink
/// class, described in the documentation of the \link
/// infact::Factory::CreateOrDie Factory::CreateOrDie \endlink
/// method.
///
/// Statements in this language look like the following:
/// \code
/// // This is a comment.
/// bool b = true; // assigns the value true to the boolean variable "b"
/// int f = 1; // assigns the int value 1 to the variable "f"
/// double g = 2.4; // assigns the double value 2.4 to the variable "g"
/// string n = "foo" // assigns the string value "foo" to the variable "n"
/// bool[] b_vec = {true, false, true}; // assigns a vector of bool to "b_vec"
///
/// // Constructs an object of abstract type Model and assigns it to "m1"
/// Model m1 = PerceptronModel(name("foo"));
///
/// // Constructs an object of type Model and assigns it to "m2", crucially
/// // using the previously defined string variable "n" as the value for
/// // the PerceptronModel's name parameter.
/// Model m2 = PerceptronModel(name(n));
///
/// // Constructs a vector of Model objects and assigns it to "m_vec".
/// Model[] m_vec = {m2, PerceptronModel(name("bar"))};
/// \endcode
///
/// Additionally, the interpreter can do type inference, so all the type
/// specifiers in the previous examples are optional. For example, one may
/// write the following statements:
/// \code
/// b = true; // assigns the value true to the boolean variable "b"
///
/// // Constructs an object of abstract type Model and assigns it to "m1"
/// m1 = PerceptronModel(name("foo"));
///
/// // Constructs a vector of Model objects and assigns it to "m_vec".
/// m_vec = {m1, PerceptronModel(name("bar"))};
/// \endcode
///
/// Here's an example of using the interpreter after it has read the
/// three statements from the previous example from a file called
/// <tt>"example.infact"</tt>:
/// \code
/// #include "interpreter.h"
/// // ...
/// Interpreter i;
/// i.Eval("example.infact");
/// shared_ptr<Model> model;
/// vector<shared_ptr<Model> > model_vector;
/// bool b;
/// // The next statement only assigns a value to b if a variable "b"
/// // exists in the interpreter's environment.
/// i.Get("b", &b);
/// i.Get("m1", &model);
/// i.Get("m_vec", &model_vector);
/// \endcode
///
/// More formally, a statement in this language must conform to the
/// following grammar, defined on top of the BNF syntax in the
/// documentation of the \link infact::Factory::CreateOrDie
/// Factory::CreateOrDie \endlink method:
/// <table border=0>
/// <tr>
/// <td><tt>\<statement_list\></tt></td>
/// <td><tt>::=</tt></td>
/// <td><tt>[ \<statement\> ]*</tt></td>
/// </tr>
/// <tr>
/// <td><tt>\<statement\></tt></td>
/// <td><tt>::=</tt></td>
/// <td>
/// <tt>[ \<type_specifier\> ] \<variable_name\> '=' \<value\> ';' </tt>
/// </td>
/// </tr>
/// <tr>
/// <td valign=top><tt>\<type_specifier\></tt></td>
/// <td valign=top><tt>::=</tt></td>
/// <td valign=top>
/// <table border="0">
/// <tr><td><tt>"bool" | "int" | "string" | "double" | "bool[]" | "int[]"
/// "string[]" | "double[]" | T | T[]</tt></td></tr>
/// <tr><td>where <tt>T</tt> is any \link infact::Factory
/// Factory\endlink-constructible type.</td></tr>
/// </table>
/// </td>
/// </tr>
/// <tr>
/// <td><tt>\<variable_name\></tt></td>
/// <td><tt>::=</tt></td>
/// <td>any valid C++ identifier</td>
/// </tr>
/// <tr>
/// <td valign=top><tt>\<value\></tt></td>
/// <td valign=top><tt>::=</tt></td>
/// <td valign=top><tt>\<literal\> | '{' \<literal_list\> '}' |<br>
/// \<spec_or_null\> | '{' \<spec_list\> '}'</tt>
/// </td>
/// </tr>
/// </table>
///
/// The above grammar doesn’t contain rules covering C++ style
/// line comments, but they have the same behavior in this language as
/// they do in C++, i.e., everything after the <tt>//</tt> to the end
/// of the current line is treated as a comment and ignored. There
/// are no C-style comments in this language.
class Interpreter {
public:
/// Constructs a new instance with the specified debug level. The
/// wrapped \link infact::Environment Environment \endlink will
/// also have the specified debug level.
Interpreter(int debug = 0) {
env_ = new EnvironmentImpl(debug);
}
/// Destroys this interpreter.
virtual ~Interpreter() {
delete env_;
}
/// Evaluates the statements in the specified text file.
void Eval(const string &filename) {
filename_ = filename;
ifstream file(filename_.c_str());
Eval(file);
}
/// Evaluates the statements in the specified string.
void EvalString(const string& input) {
StreamTokenizer st(input);
Eval(st);
}
/// Evaluates the statements in the specified stream.
void Eval(istream &is) {
StreamTokenizer st(is);
Eval(st);
}
void PrintEnv(ostream &os) const {
env_->Print(os);
}
void PrintFactories(ostream &os) const {
env_->PrintFactories(os);
}
/// Retrieves the value of the specified variable. It is an error
/// if the type of the specified pointer to a value object is different
/// from the specified variable in this interpreter’s environment.
///
/// \tparam the type of value object being set by this method
///
/// \param varname the name of the variable for which to retrieve the value
/// \param value a pointer to the object whose value to be set by this
/// method
template<typename T>
bool Get(const string &varname, T *value) const {
return env_->Get(varname, value);
}
/// Returns a pointer to the environment of this interpreter.
/// Crucially, this method returns a pointer to the Environment
/// implementation class, \link infact::EnvironmentImpl
/// EnvironmentImpl\endlink, so that its templated \link
/// infact::EnvironmentImpl::Get EnvironmentImpl::Get \endlink
/// method may be invoked.
EnvironmentImpl *env() { return env_; }
private:
/// Evalutes the expressions contained in the specified token stream.
void Eval(StreamTokenizer &st);
void WrongTokenError(size_t pos,
const string &expected,
const string &found,
StreamTokenizer::TokenType found_type) const;
void WrongTokenTypeError(size_t pos,
StreamTokenizer::TokenType expected,
StreamTokenizer::TokenType found,
const string &token) const;
void WrongTokenTypeError(size_t pos,
const string &expected_type,
const string &found_type,
const string &token) const;
/// The environment of this interpreter.
EnvironmentImpl *env_;
/// The name of the file being interpreted, or the empty string if there
/// is no file associated with the stream being interpreted.
string filename_;
};
} // namespace infact
#endif
| 36.42471 | 80 | 0.650095 | [
"object",
"vector",
"model"
] |
fa7fea93dad1385d464944cee82a4597872a5d93 | 3,259 | h | C | vs2017/sdk/pc_win/include/interface/IMailService.h | cheechang/cppcc | 0292e9a9b27e0579970c83b4f6a75dcdae1558bf | [
"MIT"
] | null | null | null | vs2017/sdk/pc_win/include/interface/IMailService.h | cheechang/cppcc | 0292e9a9b27e0579970c83b4f6a75dcdae1558bf | [
"MIT"
] | null | null | null | vs2017/sdk/pc_win/include/interface/IMailService.h | cheechang/cppcc | 0292e9a9b27e0579970c83b4f6a75dcdae1558bf | [
"MIT"
] | null | null | null | #pragma once
#include "../model/SDKTypes.h"
#include "IService.h"
#include "../extModel/mailpacket.h"
#include <string>
#include <vector>
#define VER_MAIL INTERFACE_VERSION(1,0)
static const VRVIID IID_IMailService = { 0x92dc7e53, 0x4a7c, 0x4436, 0xac, 0x5e, 0x29, 0x2f, 0xe8, 0x66, 0xbd, 0x2 };
namespace service
{
class IMailService : public IService
{
public:
virtual ~IMailService(){}
/**
* \brief 监听邮箱拉取推送
* @param[out] cb 传入接收结果回调 _1 邮箱账号; _2 推送的信息类型 0,邮箱文件夹信息 1,邮箱邮件信息; _3 邮件; _4 邮箱文件夹;
*/
virtual void regAutoFetchMailCb(SFunction<void(std::string&, int, std::vector<mail>&, std::vector<mailFolder>&) > cb) = 0;
/**
* \brief 获取邮箱帐号
* @param[in] type 0 获取所有帐号 1,获取指定帐号
* @param[in] Account 若type = 1,获取指定帐号
* @param[in] verify_info 传入验证信息
* @param[out] cb 传入接收结果回调 _1错误信息
*/
virtual void getMailAccount(int type, std::string&Account, SFunction<void(ErrorInfo, std::vector<mailSetting>&)> cb) = 0;
/**
* \brief 删除邮箱账号
* @param[in] account 要删除的账号
* @param[out] cb 传入接收结果回调 _1错误信息
*/
virtual void delMailAccount(std::string& account, SFunction<void(ErrorInfo)> cb) = 0;
/**
* \brief 新增邮箱账号
* @param[in] account 新增的账号信息
* @param[out] cb 传入接收结果回调 _1错误信息
*/
virtual void addMailAccount(mailSetting& account, SFunction<void(ErrorInfo)> cb) = 0;
/**
* \brief 更新邮箱账号信息
* @param[in] account 更新的账号信息
* @param[out] cb 传入接收结果回调 _1错误信息
*/
virtual void updateMailAccount(mailSetting& account, SFunction<void(ErrorInfo)> cb) = 0;
/**
* \brief 获取本地邮件
* @param[in] account 账号信息
* @param[in] folder 邮箱文件夹
* @param[out] cb 传入接收结果回调 _1错误信息 _2 邮件
*/
virtual void getlocalMail(std::string& account, std::string& folder, SFunction<void(ErrorInfo, std::vector<mail>&)> cb) = 0;
/**
* \brief 获取邮箱文件夹信息
* @param[in] account 账号信息
* @param[out] cb 传入接收结果回调 _1错误信息 _2 邮件文件夹
*/
virtual void getMailFolder(std::string& account, SFunction<void(ErrorInfo, std::vector<mailFolder>&)> cb) = 0;
/**
* \brief 获取邮箱头信息
* @param[in] account 账号信息
* @param[in] folder 邮箱文件夹
* @param[in] type 拉新邮件 0; 拉旧邮件 1
* @param[in] num 拉旧邮件时需要填 拉取数目
* @param[out] cb 传入接收结果回调 _1错误信息 _2 邮件
*/
virtual void fetchMailHeader(std::string& account, std::string& folder, int type, int num, SFunction<void(ErrorInfo, std::vector<mail>&)> cb) = 0;
/**
* \brief 获取邮箱头信息
* @param[in] mail 要发送的邮件信息 见stsendMail注释
* @param[out] cb 传入接收结果回调 _1错误信息
*/
virtual void sendMail(stsendMail& mail, SFunction<void(ErrorInfo)> cb) = 0;
/**
* \brief 删除邮件
* @param[in] account 账号信息
* @param[in] folder 邮箱文件夹
* @param[in] UID 邮件UID
* @param[out] cb 传入接收结果回调 _1错误信息
*/
virtual void delMail(std::string& account, std::string& folder,std::string& UID, SFunction<void(ErrorInfo)> cb) = 0;
/**
* \brief 分段拉取邮件内容
* @param[in] account 账号信息
* @param[in] folder 邮箱文件夹
* @param[in] UID 邮件UID
* @param[in] sectionNum 内容编号
* @param[out] cb 传入接收结果回调 _1错误信息 _2 邮件
* @param[out] pro 拉取进度回调 _1 额外的请求信息 _2 进度百分比 progess _3 描述信息 info.
*/
virtual void fetchMailSection(std::string& account, std::string& folder, std::string& UID, int sectionNum, SFunction<void(ErrorInfo, mail&)> cb, SFunction<void(int32, int32, const std::string&)> pro = NULL) = 0;
};
} | 33.255102 | 213 | 0.670144 | [
"vector",
"model"
] |
fa8a14f0a649b6649f9eaaf8515cc0223ff00ea3 | 6,674 | h | C | include/External/stlib/packages/shortest_paths/GraphDijkstra.h | bxl295/m4extreme | 2a4a20ebb5b4e971698f7c981de140d31a5e550c | [
"BSD-3-Clause"
] | null | null | null | include/External/stlib/packages/shortest_paths/GraphDijkstra.h | bxl295/m4extreme | 2a4a20ebb5b4e971698f7c981de140d31a5e550c | [
"BSD-3-Clause"
] | null | null | null | include/External/stlib/packages/shortest_paths/GraphDijkstra.h | bxl295/m4extreme | 2a4a20ebb5b4e971698f7c981de140d31a5e550c | [
"BSD-3-Clause"
] | null | null | null | // -*- C++ -*-
/*!
\file GraphDijkstra.h
\brief Implements a class for a weighted, directed graph.
*/
#if !defined(__GraphDijkstra_h__)
#define __GraphDijkstra_h__
#include "Graph.h"
#include "VertexDijkstra.h"
#include "EdgeCompare.h"
#include <vector>
#include <functional>
namespace shortest_paths {
//! A weighted, directed graph.
template <typename WeightType, typename HeapType>
class GraphDijkstra :
public Graph< VertexDijkstra<WeightType> > {
private:
typedef Graph< VertexDijkstra<WeightType> > base_type;
public:
//
// Public types.
//
//! The vertex type.
typedef typename base_type::vertex_type vertex_type;
//! The weight type.
typedef typename vertex_type::weight_type weight_type;
//! The size type is a signed integer.
typedef typename base_type::size_type size_type;
protected:
//
// Protected types.
//
//! Vertex container.
typedef typename base_type::vertex_container vertex_container;
//! Vertex iterator.
typedef typename base_type::vertex_iterator vertex_iterator;
//! Vertex const iterator.
typedef typename base_type::vertex_const_iterator vertex_const_iterator;
//! Edge.
typedef typename base_type::edge_type edge_type;
//! Edge container.
typedef typename base_type::edge_container edge_container;
//! Edge iterator.
typedef typename base_type::edge_iterator edge_iterator;
//! Edge const iterator.
typedef typename base_type::edge_const_iterator edge_const_iterator;
//! A heap.
typedef HeapType heap_type;
//! Half edge.
typedef HalfEdge<vertex_type> half_edge_type;
//! Half edge container.
typedef std::vector< half_edge_type > half_edge_container;
//! Half edge iterator.
typedef typename half_edge_container::iterator half_edge_iterator;
//! Half edge const iterator.
typedef typename half_edge_container::const_iterator
half_edge_const_iterator;
private:
//
// Not implemented.
//
//! Copy constructor not implemented.
GraphDijkstra(const GraphDijkstra&);
//! Assignment operator not implemented.
GraphDijkstra&
operator=(const GraphDijkstra&);
private:
//
// Member data
//
half_edge_container _half_edges;
public:
//------------------------------------------------------------------------
//! \name Constructors, etc.
//@{
//! Default constructor.
GraphDijkstra() :
base_type(),
_half_edges() {}
//! Destructor.
virtual
~GraphDijkstra() {}
//@}
//------------------------------------------------------------------------
//! \name Accessors.
//@{
//! Return the vertices.
const vertex_container&
vertices() const {
return base_type::vertices();
}
//! Return the edges.
const edge_container&
edges() const {
return base_type::edges();
}
//@}
//------------------------------------------------------------------------
//! \name Manipulators.
//@{
//! Return the vertices.
vertex_container&
vertices() {
return base_type::vertices();
}
//! Return the edges.
edge_container&
edges() {
return base_type::edges();
}
//@}
//------------------------------------------------------------------------
//! \name Mathematical operations.
//@{
//! Add an edge to the graph.
void
add_edge(const int source_index, const int target_index,
const weight_type weight) {
base_type::add_edge(source_index, target_index, weight);
}
//! Make a rectangular grid.
/*!
The vertices are lattice points. Each vertex is doubly
connected to its adjacent vertices.
\param x_size: The number of vertices in the x direction.
\param y_size: The number of vertices in the y direction.
\param edge_weight A functional with no arguments giving the edge weight.
*/
template <typename Generator>
void
rectangular_grid(const size_type x_size, const size_type y_size,
Generator& edge_weight) {
base_type::rectangular_grid(x_size, y_size, edge_weight);
}
//! Make a dense graph.
/*!
Each vertex is doubly connected to every other vertex.
\param num_vertices The number of vertices in the graph.
\param edge_weight A functional with no arguments giving the edge weight.
*/
template <typename Generator>
void
dense(const size_type num_vertices, Generator& edge_weight) {
base_type::dense(num_vertices, edge_weight);
}
//! Make a graph with random edges.
/*!
\param num_vertices The number of vertices in the graph.
\param num_adjacent_edges_per_vertex Each vertex has this many
adjacent edges.
\param edge_weight A functional with no arguments giving the edge weight.
*/
template <typename Generator>
void
random(const size_type num_vertices,
const size_type num_adjacent_edges_per_vertex,
Generator& edge_weight) {
base_type::random(num_vertices, num_adjacent_edges_per_vertex,
edge_weight);
}
//! Compute the shortest path tree from the given vertex.
/*!
\param root_vertex_index is the index of the root vertex.
*/
void
dijkstra(const int root_vertex_index);
//@}
private:
//! Build the adjacency information for the vertices.
void
build();
//! Initialize for a shortest path computation.
/*!
\param source_index is the index of the root vertex of the tree.
*/
void
initialize(const int source_index);
//! Label self from a vertex and a weight.
/*!
If the status is UNLABELED, change the status to LABELED,
set the distance and predecessor and add the vertex to the heap.
Otherwise, see if the distance
from the vertex is lower than the current distance and if so,
update the distance and predecessor and update the heap.
*/
void
label(heap_type& heap, vertex_type& vertex,
const vertex_type& known_vertex, weight_type edge_weight);
//! Label the unkown neighbors of the specified vertex.
/*!
\param heap Add the neighbors that were unlabeled to the this heap.
\param known_vertex The vertex with known distance.
*/
void
label_adjacent(heap_type& heap, const vertex_type* known_vertex);
};
} // namespace shortest_paths
#define __GraphDijkstra_ipp__
#include "GraphDijkstra.ipp"
#undef __GraphDijkstra_ipp__
#endif
| 26.484127 | 79 | 0.62751 | [
"vector"
] |
fa8ac558bed266331eaa95bfd5739575e486f17b | 4,210 | h | C | src/Cria/source/Definition.h | oicawa/cria | 53a7630990ca0ddf3680d879b032d2b55f0fd9ef | [
"MIT"
] | null | null | null | src/Cria/source/Definition.h | oicawa/cria | 53a7630990ca0ddf3680d879b032d2b55f0fd9ef | [
"MIT"
] | null | null | null | src/Cria/source/Definition.h | oicawa/cria | 53a7630990ca0ddf3680d879b032d2b55f0fd9ef | [
"MIT"
] | null | null | null | /*
* $Id$
*
* ===============================================================================
*
* Copyright (C) 2008-2009 Masamitsu Oikawa <oicawa@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* ===============================================================================
*/
#ifndef PUBLIC_DEFINITION_H_INCLUDED
#define PUBLIC_DEFINITION_H_INCLUDED
#include "Cria.h"
#include "Expression.h"
#include "Interpreter.h"
#include "List.h"
#include "CriaId.h"
#include "Parser.h"
#include "String.h"
struct DefinitionVariableNormalTag
{
void* object;
String name;
Boolean isStatic;
Boolean isConstant;
};
struct DefinitionVariableTag
{
DefinitionVariableType type;
union
{
DefinitionVariableNormal normal;
Item item;
} of;
};
struct DefinitionFunctionTag
{
String name;
Boolean isNative;
Boolean isStatic;
union
{
struct
{
List parameterList;
List statementList;
} cria;
struct
{
CriaNativeFunction* function;
} native;
} of;
};
struct DefinitionClassTag
{
String name;
Boolean isNative;
List baseList;
Hash i_fields;
Hash s_fields;
Hash i_methods;
Hash s_methods;
};
//==============================
//DefinitionVariable
//==============================
DefinitionVariable
DefinitionVariable_search(
List parameters,
String name
);
String
DefinitionVariable_name(
DefinitionVariable variable
);
void
DefinitionVariable_set(
DefinitionVariable variable,
CriaId id
);
void*
DefinitionVariable_getObject(
DefinitionVariable variable
);
DefinitionVariable
DefinitionVariable_parse(
Parser parser
);
//==============================
//DefinitionFunction
//==============================
List
DefinitionFunction_parse_parameters(
Parser parser
);
DefinitionFunction
DefinitionFunction_parse(
Parser parser
);
DefinitionFunction
DefinitionFunction_search(
List functions,
String name
);
CriaId
DefinitionFunction_evaluate(
Interpreter interpreter,
CriaId id,
List parameterList,
CriaBlock block,
DefinitionFunction function,
List parameters,
CriaId parent
);
List
DefinitionFunction_getParameterList(
DefinitionFunction function
);
//==============================
//DefinitionClass
//==============================
String
DefinitionClass_getName(
DefinitionClass klass
);
DefinitionClass
DefinitionClass_search(
List classList,
String name
);
CriaId
DefinitionClass_evaluate(
Interpreter interpreter,
CriaId id,
List parameterList,
CriaBlock block,
String name,
Boolean isStatic,
DefinitionClass klass,
List parameters
);
Hash
DefinitionClass_getFields(
DefinitionClass klass,
Boolean isStatic
);
Hash
DefinitionClass_getMethods(
DefinitionClass klass,
Boolean isStatic
);
DefinitionClass
DefinitionClass_parse(
Parser parser
);
CriaId
DefinitionClass_generateInstance(
Interpreter interpreter,
DefinitionClass klass,
List parameters,
CriaBlock block
);
#endif
| 16.907631 | 83 | 0.658432 | [
"object"
] |
fa8da0401d274408908bd701e8e7c12fd1617e07 | 10,926 | h | C | plugins/flowvis/src/implicit_topology.h | UniStuttgart-VISUS/implicit-topology | a7e0d5dd7253264e9feb2ae3d4dd44db5321d3e5 | [
"BSD-3-Clause"
] | 2 | 2020-10-16T10:15:37.000Z | 2021-01-21T13:06:00.000Z | plugins/flowvis/src/implicit_topology.h | UniStuttgart-VISUS/implicit-topology | a7e0d5dd7253264e9feb2ae3d4dd44db5321d3e5 | [
"BSD-3-Clause"
] | null | null | null | plugins/flowvis/src/implicit_topology.h | UniStuttgart-VISUS/implicit-topology | a7e0d5dd7253264e9feb2ae3d4dd44db5321d3e5 | [
"BSD-3-Clause"
] | 1 | 2021-01-28T01:19:54.000Z | 2021-01-28T01:19:54.000Z | /*
* implicit_topology.h
*
* Copyright (C) 2019 by Universitaet Stuttgart (VIS).
* Alle Rechte vorbehalten.
*/
#pragma once
#include "implicit_topology_computation.h"
#include "implicit_topology_results.h"
#include "triangulation.h"
#include "mmcore/Call.h"
#include "mmcore/CalleeSlot.h"
#include "mmcore/CallerSlot.h"
#include "mmcore/Module.h"
#include "mmcore/param/ParamSlot.h"
#include "glad/glad.h"
#include <array>
#include <iostream>
#include <memory>
#include <type_traits>
#include <vector>
namespace megamol
{
namespace flowvis
{
/**
* Module for computing and visualizing the implicit topology of a vector field.
*
* @author Alexander Straub
* @author Grzegorz K. Karch
*/
class implicit_topology : public core::Module
{
static_assert(std::is_same<GLfloat, float>::value, "'GLfloat' and 'float' must be the same type!");
static_assert(std::is_same<GLuint, unsigned int>::value, "'GLuint' and 'unsigned int' must be the same type!");
public:
/**
* Answer the name of this module.
*
* @return The name of this module.
*/
static inline const char* ClassName() { return "implicit_topology"; }
/**
* Answer a human readable description of this module.
*
* @return A human readable description of this module.
*/
static inline const char* Description() { return "Compute and visualize implicit topology of a 2D vector field"; }
/**
* Answers whether this module is available on the current system.
*
* @return 'true' if the module is available, 'false' otherwise.
*/
static inline bool IsAvailable() { return true; }
/**
* Initialises a new instance.
*/
implicit_topology();
/**
* Finalises an instance.
*/
virtual ~implicit_topology();
protected:
/**
* Implementation of 'Create'.
*
* @return 'true' on success, 'false' otherwise.
*/
virtual bool create() override;
/**
* Implementation of 'Release'.
*/
virtual void release() override;
private:
/** Callbacks for the triangle mesh */
bool get_triangle_data_callback(core::Call& call);
bool get_triangle_extent_callback(core::Call& call);
/** Callbacks for the mesh data */
bool get_data_data_callback(core::Call& call);
bool get_data_extent_callback(core::Call& call);
/** Callback for the result writer */
bool get_result_writer_cb_callback(core::Call& call);
std::function<bool(const implicit_topology_results&)> get_result_writer_callback;
/** Callback for the screen shooter */
bool get_screenshot_cb_callback(core::Call& call);
std::function<void()> get_screenshot_callback;
/** Callbacks for the log stream */
bool get_log_cb_callback(core::Call& call);
std::function<std::ostream&()> get_log_callback;
/** Callbacks for the performance log stream */
bool get_performance_cb_callback(core::Call& call);
std::function<std::ostream&()> get_performance_callback;
/** Callbacks for starting/stopping/resetting the computation */
bool start_computation_callback(core::param::ParamSlot& parameter);
bool stop_computation_callback(core::param::ParamSlot& parameter);
bool reset_computation_callback(core::param::ParamSlot& parameter);
bool load_computation_callback(core::param::ParamSlot& parameter);
bool save_computation_callback(core::param::ParamSlot& parameter);
/**
* Initialize computation.
*
* @return Success
*/
bool initialize_computation();
/**
* Load input from file.
*
* @param resolution Domain resolution (number of vectors per direction)
* @param domain Domain size (minimum and maximum coordinates)
* @param positions Positions of the vectors, also used as initial seed
* @param vectors Vectors of the vector field
* @param points Convergence structure points (e.g., critical points, periodic orbits, ...)
* @param point_ids Unique IDs (or labels) of the given points
* @param lines Convergence structure lines (e.g., domain boundaries, obstacles, ...)
* @param line_ids (Unique) IDs (or labels) of the given lines
*
* @return Success
*/
bool load_input(std::array<unsigned int, 2>& resolution, std::array<float, 4>& domain, std::vector<float>& positions, std::vector<float>& vectors,
std::vector<float>& points, std::vector<int>& point_ids, std::vector<float>& lines, std::vector<int>& line_ids);
/**
* Update results obtained from computation.
*/
void update_results();
/**
* Manipulate accessibility of fixed parameters
*
* @param read_only True: read-only, false: writable
*/
void set_readonly_fixed_parameters(bool read_only);
/**
* Manipulate accessibility of variable parameters
*
* @param read_only True: read-only, false: writable
*/
void set_readonly_variable_parameters(bool read_only);
/** Output slot for the triangle mesh */
core::CalleeSlot triangle_mesh_slot;
/** Output slot for data attached to the triangles or their nodes */
core::CalleeSlot mesh_data_slot;
/** Output slot for writing results to file */
core::CalleeSlot result_writer_slot;
/** Output slot for taking screenshots */
core::CalleeSlot screenshot_slot;
/** Output slots for logging */
core::CalleeSlot log_slot;
core::CalleeSlot performance_slot;
/** Input slot for getting the vector field */
core::CallerSlot vector_field_slot;
/** Input slot for getting convergence structures */
core::CallerSlot convergence_structures_slot;
/** Input slot for reading results from file */
core::CallerSlot result_reader_slot;
/** Start or reset the computation */
core::param::ParamSlot start_computation;
core::param::ParamSlot stop_computation;
core::param::ParamSlot reset_computation;
core::param::ParamSlot load_computation;
core::param::ParamSlot save_computation;
/** Settings for labels */
core::param::ParamSlot label_transfer_function;
core::param::ParamSlot label_fixed_range;
core::param::ParamSlot label_range_min, label_range_max;
core::param::ParamSlot num_labels_combined;
/** Settings for distances */
core::param::ParamSlot distance_transfer_function;
core::param::ParamSlot distance_fixed_range;
core::param::ParamSlot distance_range_min, distance_range_max;
/** Settings for reasons of termination */
core::param::ParamSlot termination_transfer_function;
core::param::ParamSlot termination_fixed_range;
core::param::ParamSlot termination_range_min, termination_range_max;
/** Settings for gradients */
core::param::ParamSlot gradient_transfer_function;
core::param::ParamSlot gradient_fixed_range;
core::param::ParamSlot gradient_range_min, gradient_range_max;
/** Parameters for stream line computation */
core::param::ParamSlot integration_method;
core::param::ParamSlot num_integration_steps;
core::param::ParamSlot integration_timestep;
core::param::ParamSlot max_integration_error;
core::param::ParamSlot num_particles_per_batch;
core::param::ParamSlot num_integration_steps_per_batch;
/** Parameters for grid refinement */
core::param::ParamSlot refinement_threshold;
core::param::ParamSlot refine_at_labels;
core::param::ParamSlot distance_difference_threshold;
/** Parameters for automatical saving of results and screenshots */
core::param::ParamSlot auto_save_results;
core::param::ParamSlot auto_save_screenshots;
/** Input information */
std::array<unsigned int, 2> resolution;
/** Indicator for changed output */
bool computation_running;
bool mesh_output_changed;
bool data_output_changed;
/** Output vertices and indices of the triangle mesh */
std::shared_ptr<std::vector<GLfloat>> vertices;
std::shared_ptr<std::vector<GLuint>> indices;
/** Output labels */
std::shared_ptr<std::vector<GLfloat>> labels;
std::shared_ptr<std::vector<GLfloat>> labels_forward;
std::shared_ptr<std::vector<GLfloat>> labels_backward;
/** Output distances */
std::shared_ptr<std::vector<GLfloat>> distances;
std::shared_ptr<std::vector<GLfloat>> distances_forward;
std::shared_ptr<std::vector<GLfloat>> distances_backward;
/** Output reasons for termination */
std::shared_ptr<std::vector<GLfloat>> terminations_forward;
std::shared_ptr<std::vector<GLfloat>> terminations_backward;
/** Output gradients */
std::shared_ptr<std::vector<GLfloat>> gradients;
std::shared_ptr<std::vector<GLfloat>> gradients_forward;
std::shared_ptr<std::vector<GLfloat>> gradients_backward;
/** Output mask */
std::shared_ptr<std::vector<GLfloat>> valid_all;
std::shared_ptr<std::vector<GLfloat>> valid_one;
std::shared_ptr<std::vector<GLfloat>> valid_forward;
std::shared_ptr<std::vector<GLfloat>> valid_backward;
/** Computation class */
std::unique_ptr<implicit_topology_computation> computation;
/** Store last promised result */
std::shared_future<implicit_topology_results> last_result;
/** Store previous result */
std::unique_ptr<implicit_topology_results> previous_result;
};
}
} | 39.021429 | 158 | 0.598206 | [
"mesh",
"vector"
] |
fa9ffa22d6d549f6812abadebf75b1b21ec5ff7a | 3,017 | h | C | Pod/Classes/Backend/PMSDKConstants.h | PayMaya/Checkout-SDK-iOS | cd8be53554cd67d808d24fd137018744469b5f0e | [
"MIT"
] | 4 | 2016-02-03T03:37:58.000Z | 2020-02-27T05:16:35.000Z | Pod/Classes/Backend/PMSDKConstants.h | PayMaya/Checkout-SDK-iOS | cd8be53554cd67d808d24fd137018744469b5f0e | [
"MIT"
] | 7 | 2016-08-16T05:50:45.000Z | 2019-12-09T11:07:11.000Z | Pod/Classes/Backend/PMSDKConstants.h | PayMaya/Checkout-SDK-iOS | cd8be53554cd67d808d24fd137018744469b5f0e | [
"MIT"
] | 7 | 2016-08-16T05:28:57.000Z | 2019-12-11T04:27:31.000Z | //
// PMSDKConstants.h
// Pods
//
// Copyright (c) 2016 PayMaya Philippines, Inc.
//
// 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.
//
#import <Foundation/Foundation.h>
@interface PMSDKConstants : NSObject
/*
@abstract The error domain for errors from PayMayaSDK.
*/
extern NSString *const PMSDKErrorDomain;
/*
@typedef NS_ENUM(NSInteger, PMSDKErrorCode)
@abstract Error codes for PMSDKErrorDomain.
*/
typedef NS_ENUM(NSInteger, PMSDKErrorCode)
{
/*
@abstract Reserved.
*/
PMSDKReservedErrorCode = 0,
/*
@abstract A request failed due to a network error. Use NSUnderlyingErrorKey to retrieve
the error object from the NSURLConnection for more information.
*/
PMSDKNetworkErrorCode,
/*
@abstract Indicates an operation failed because a required access token was not found.
*/
PMSDKAuthorizationHeaderRequiredErrorCode
};
/*
@abstract The error domain for errors related to Checkout.
*/
extern NSString *const PMSDKCheckoutErrorDomain;
/*
@typedef NS_ENUM(NSInteger, PMSDKErrorCode)
@abstract Error codes for PMSDKCheckoutErrorDomain.
*/
typedef NS_ENUM(NSInteger, PMSDKCheckoutErrorCode)
{
/*
@abstract Reserved.
*/
PMSDKCheckoutReservedErrorCode = 0,
/*
@abstract SDK not initialized.
*/
PMSDKCheckoutNotInitializedErrorCode,
/*
@abstract Checkout API error
*/
PMSDKCheckoutAPIErrorCode
};
/*
@abstract The error domain for errors related to Payments.
*/
extern NSString *const PMSDKPaymentsErrorDomain;
/*
@typedef NS_ENUM(NSInteger, PMSDKErrorCode)
@abstract Error codes for PMSDKCheckoutErrorDomain.
*/
typedef NS_ENUM(NSInteger, PMSDKPaymentsErrorCode)
{
/*
@abstract Reserved.
*/
PMSDKPaymentsReservedErrorCode = 0,
/*
@abstract SDK not initialized.
*/
PMSDKPaymentsNotInitializedErrorCode,
/*
@abstract Payments API error
*/
PMSDKPaymentsAPIErrorCode
};
@end
| 27.427273 | 101 | 0.723235 | [
"object"
] |
faa39f58e24658474e571bd4aa95668b8a7c02f8 | 8,774 | h | C | include/linux/wacom_i2c.h | CaelestisZ/IrisCore | 6f0397e43335434ee58e418c9d1528833c57aea2 | [
"MIT"
] | 1 | 2021-07-15T06:44:32.000Z | 2021-07-15T06:44:32.000Z | include/linux/wacom_i2c.h | CaelestisZ/AetherAura | 1b30acb7e6921042722bc4aff160dc63a975abc2 | [
"MIT"
] | null | null | null | include/linux/wacom_i2c.h | CaelestisZ/AetherAura | 1b30acb7e6921042722bc4aff160dc63a975abc2 | [
"MIT"
] | 4 | 2020-05-26T12:40:11.000Z | 2021-07-15T06:46:33.000Z |
#ifndef _LINUX_WACOM_I2C_H
#define _LINUX_WACOM_I2C_H
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/input.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/slab.h>
#include <linux/hrtimer.h>
#include <linux/gpio.h>
#include <linux/irq.h>
#include <linux/delay.h>
#include <linux/wakelock.h>
#include <linux/cpufreq.h>
#ifdef CONFIG_HAS_EARLYSUSPEND
#include <linux/earlysuspend.h>
#endif
#include <linux/pinctrl/consumer.h>
#ifdef CONFIG_COMMON_INPUT_BOOSTER
#include <linux/input/input_booster.h>
#define WACOM_BOOSTER
#endif
/* WACOM NOISE from LCD OSC.
* read Vsync frequency value at wacom firmware.
*/
#if defined(CONFIG_SEC_H_PROJECT)
#define USE_WACOM_LCD_WORKAROUND
#else
#undef USE_WACOM_LCD_WORKAROUND
#endif
/* wacom region : touch region, touchkey region,
* HW team request : block touchkey event between touch release ~ 100msec.
*/
#define USE_WACOM_BLOCK_KEYEVENT
/* FW UPDATE @ SYSTEM REVISION -- DIGITIGER CHANGED */
#if defined(CONFIG_SEC_GT510_PROJECT) || defined(CONFIG_SEC_GT58_PROJECT)
#define WACOM_FW_UPDATE_REVISION 0x00
#else
#define WACOM_FW_UPDATE_REVISION 0x05
#endif
/* FW UPDATE @ SYSTEM REVISION -- BOOT VERSION CHANGED */
#if defined(CONFIG_SEC_GT510_PROJECT)|| defined(CONFIG_SEC_GT58_PROJECT)
#define WACOM_BOOT_REVISION 0x0
#else
#define WACOM_BOOT_REVISION 0x7
#endif
/* FW UPDATE FEATURE */
#define WACOM_UMS_UPDATE
#define WACOM_MAX_FW_PATH 64
#define WACOM_FW_NAME_W9001 "epen/W9001_B911.bin"
#define WACOM_FW_NAME_W9002 "epen/W9002_B781.bin"
#if defined(CONFIG_MACH_HLTESKT) || defined(CONFIG_MACH_HLTEKTT) || defined(CONFIG_MACH_HLTELGT) ||\
defined(CONFIG_MACH_HLTEDCM) || defined(CONFIG_MACH_HLTEKDI)
#define WACOM_FW_NAME_W9010 "epen/W9010_0208.bin"
#else
#define WACOM_FW_NAME_W9010 "epen/W9010_0174.bin"
#endif
#ifdef CONFIG_SEC_LT03_PROJECT
#define WACOM_FW_NAME_W9007_BL92 "epen/W9007A_0267.bin"
#define WACOM_FW_NAME_W9007_BL91 "epen/W9007A_0267.bin"
#elif defined(CONFIG_SEC_GT510_PROJECT)
#define WACOM_FW_NAME_W9007_BL92 "epen/W9007A_C483.bin"
#define WACOM_FW_NAME_W9007_BL91 "epen/W9007A_C430.bin"
#else
#define WACOM_FW_NAME_W9007_BL92 "epen/W9007A_0450.bin"
#define WACOM_FW_NAME_W9007_BL91 "epen/W9007_0200.bin"
#endif
#define WACOM_FW_PATH "/sdcard/firmware/wacom_firm.bin"
#define WACOM_FW_NAME_NONE NULL
#define NAMEBUF 12
#define WACNAME "WAC_I2C_EMR"
#define WACFLASH "WAC_I2C_FLASH"
extern unsigned int system_rev;
/*Wacom Command*/
#define COM_COORD_NUM 8
#define COM_COORD_NUM_W9010 12
#define COM_QUERY_NUM 9
#define COM_CONNECTOR_CHECK_NUM 4
#define COM_SAMPLERATE_STOP 0x30
#define COM_SAMPLERATE_40 0x33
#define COM_SAMPLERATE_80 0x32
#define COM_SAMPLERATE_133 0x31
#define COM_SURVEYSCAN 0x2B
#define COM_QUERY 0x2A
#define COM_FLASH 0xff
#define COM_CHECKSUM 0x63
#define COM_STOP_SEND 0x30
#define COM_START_SEND 0x31
#define COM_TEST_START 0xC9
#define COM_REQUEST_TESTDATA 0xD8
#if defined(CONFIG_SEC_LT03_PROJECT) || defined(CONFIG_SEC_VIENNA_PROJECT) || defined(CONFIG_SEC_GT510_PROJECT)|| defined(CONFIG_SEC_GT58_PROJECT)
#define WACOM_RESETPIN_DELAY
#endif
#if defined(CONFIG_SEC_GT510_PROJECT)
#define WACOM_DISTINGUISH_DIGITIZER
#endif
/*I2C address for digitizer and its boot loader*/
#define WACOM_I2C_ADDR 0x56
#define WACOM_I2C_BOOT 0x09
#define WACOM_I2C_9001_BOOT 0x57
/*Information for input_dev*/
#define EMR 0
#define WACOM_PKGLEN_I2C_EMR 0
/*Enable/disable irq*/
#define ENABLE_IRQ 1
#define DISABLE_IRQ 0
/*Special keys*/
#define EPEN_TOOL_PEN 0x220
#define EPEN_TOOL_RUBBER 0x221
#define EPEN_STYLUS 0x22b
#define EPEN_STYLUS2 0x22c
#define WACOM_DELAY_FOR_RST_RISING 200
/* #define INIT_FIRMWARE_FLASH */
#define WACOM_PDCT_WORK_AROUND
#define WACOM_CONNECTOR_PASS_LINE_C430 12000
#define WACOM_CONNECTOR_PASS_LINE_C483 5000
#define WACOM_CONNECTOR_PASS_LINE_NONE 100
/*****************/
#define WACOM_USE_QUERY_DATA
/*PDCT Signal*/
#define PDCT_NOSIGNAL 1
#define PDCT_DETECT_PEN 0
/*Digitizer Type*/
#define EPEN_DTYPE_B660 1
#define EPEN_DTYPE_B713 2
#define EPEN_DTYPE_B746 3
#define EPEN_DTYPE_B887 4
#define EPEN_DTYPE_B911 5
#define EPEN_DTYPE_B930 6
#define EPEN_DTYPE_B934 7
#define EPEN_DTYPE_B968 8
#define WACOM_HAVE_FWE_PIN
#define WACOM_USE_SOFTKEY
#define COOR_WORK_AROUND
#define WACOM_IMPORT_FW_ALGO
/*#define WACOM_USE_OFFSET_TABLE*/
#undef WACOM_USE_AVERAGING
#if 0
#define WACOM_USE_AVE_TRANSITION
#define WACOM_USE_BOX_FILTER
#define WACOM_USE_TILT_OFFSET
#define WACOM_USE_HEIGHT
#endif
#define WACOM_USE_GAIN
#define MAX_ROTATION 4
#define MAX_HAND 2
#define WACOM_PEN_DETECT
/*****************/
/* origin offset */
#define EPEN_B660_ORG_X 456
#define EPEN_B660_ORG_Y 504
#define EPEN_B713_ORG_X 676
#define EPEN_B713_ORG_Y 724
#define BATTERY_SAVING_MODE
#define WACOM_CONNECTION_CHECK
/**************/
/*HWID to distinguish Detect Switch*/
#define WACOM_DETECT_SWITCH_HWID 0xFFFF
/*HWID to distinguish FWE1*/
#define WACOM_FWE1_HWID 0xFFFF
/*HWID to distinguish B911 Digitizer*/
#define WACOM_DTYPE_B911_HWID 1
/*End of Model config*/
#ifdef BATTERY_SAVING_MODE
#ifndef WACOM_PEN_DETECT
#define WACOM_PEN_DETECT
#endif
#endif
#ifdef WACOM_USE_PDATA
#undef WACOM_USE_QUERY_DATA
#endif
#define WACOM_COORDS_ARR_SIZE 9
/*Parameters for wacom own features*/
struct wacom_features {
int x_min;
int x_max;
int y_min;
int y_max;
int pressure_max;
char comstat;
u8 data[COM_COORD_NUM_W9010];
unsigned int fw_ic_version;
unsigned int fw_version;
int firm_update_status;
u8 check_error_code;
unsigned int min_adc_value;
};
/*sec_class sysfs*/
extern struct class *sec_class;
#ifdef CONFIG_SAMSUNG_LPM_MODE
extern int poweroff_charging;
#endif
struct wacom_g5_callbacks {
int (*check_prox)(struct wacom_g5_callbacks *);
};
/*Parameters for i2c driver*/
struct wacom_i2c {
struct i2c_client *client;
struct i2c_client *client_boot;
struct input_dev *input_dev;
struct pinctrl *pinctrl;
#ifdef CONFIG_HAS_EARLYSUSPEND
struct early_suspend early_suspend;
#endif
struct mutex lock;
#if defined(CONFIG_SEC_LT03_PROJECT) || defined(CONFIG_SEC_VIENNA_PROJECT) || defined(CONFIG_SEC_GT510_PROJECT) || defined(CONFIG_SEC_GT58_PROJECT)
struct mutex irq_lock;
#endif
#ifdef WACOM_BOOSTER
struct input_booster *wacom_booster;
#endif
struct device *dev;
int irq;
#ifdef WACOM_PDCT_WORK_AROUND
int irq_pdct;
bool rdy_pdct;
#endif
int pen_pdct;
int gpio;
int irq_flag;
int pen_prox;
int pen_pressed;
int side_pressed;
int tool;
s16 last_x;
s16 last_y;
#ifdef WACOM_PEN_DETECT
int irq_pen_insert;
struct delayed_work pen_insert_dwork;
bool pen_insert;
int gpio_pen_insert;
#endif
#ifdef WACOM_RESETPIN_DELAY
struct delayed_work work_wacom_reset;
#endif
int invert_pen_insert;
#ifdef WACOM_HAVE_FWE_PIN
int gpio_fwe;
bool have_fwe_pin;
#endif
#ifdef WACOM_IMPORT_FW_ALGO
bool use_offset_table;
bool use_aveTransition;
#endif
bool checksum_result;
const char name[NAMEBUF];
struct wacom_features *wac_feature;
struct wacom_g5_platform_data *wac_pdata;
struct wacom_g5_callbacks callbacks;
int (*power)(int on);
struct delayed_work resume_work;
#ifdef BATTERY_SAVING_MODE
bool battery_saving_mode;
#endif
bool power_enable;
bool boot_mode;
bool query_status;
int ic_mpu_ver;
int boot_ver;
bool init_fail;
#ifdef USE_WACOM_LCD_WORKAROUND
unsigned int vsync;
struct delayed_work read_vsync_work;
struct delayed_work boot_done_work;
bool wait_done;
bool boot_done;
unsigned int delay_time;
#endif
#ifdef USE_WACOM_BLOCK_KEYEVENT
struct delayed_work touch_pressed_work;
unsigned int key_delay_time;
bool touchkey_skipped;
bool touch_pressed;
#endif
bool enabled;
};
struct wacom_g5_platform_data {
char *name;
/* using dts feature */
const char *basic_model;
bool i2c_pull_up;
int gpio_int;
u32 irq_gpio_flags;
int gpio_sda;
u32 sda_gpio_flags;
int gpio_scl;
u32 scl_gpio_flags;
int gpio_pdct;
u32 pdct_gpio_flags;
int vdd_en;
u32 vdd_en_flags;
int gpio_pen_reset_n;
u32 pen_reset_n_gpio_flags;
int gpio_pen_fwe1;
u32 pen_fwe1_gpio_flags;
int gpio_pen_pdct;
u32 pen_pdct_gpio_flags;
int x_invert;
int y_invert;
int xy_switch;
int min_x;
int max_x;
int min_y;
int max_y;
int max_pressure;
int min_pressure;
int gpio_pendct;
u32 ic_mpu_ver;
u32 irq_flags;
/* using dts feature */
#ifdef WACOM_PEN_DETECT
int gpio_pen_insert;
u32 gpio_pen_insert_flags;
#endif
#ifdef WACOM_HAVE_FWE_PIN
void (*compulsory_flash_mode)(struct wacom_i2c *, bool);
#endif
int (*reset_platform_hw)(struct wacom_i2c *);
int (*wacom_start)(struct wacom_i2c *);
int (*wacom_stop)(struct wacom_i2c *);
void (*register_cb)(struct wacom_g5_callbacks *);
};
#endif /* _LINUX_WACOM_I2C_H */
| 23.21164 | 147 | 0.794848 | [
"model"
] |
faa5d2d83b6b6ac7fe9f6a015d780a6592ff10de | 11,596 | c | C | ni/src/lib/nfp/cz2ccmW.c | tenomoto/ncl | a87114a689a1566e9aa03d85bcf6dc7325b47633 | [
"Apache-2.0"
] | 210 | 2016-11-24T09:05:08.000Z | 2022-03-24T19:15:32.000Z | ni/src/lib/nfp/cz2ccmW.c | tenomoto/ncl | a87114a689a1566e9aa03d85bcf6dc7325b47633 | [
"Apache-2.0"
] | 156 | 2017-09-22T09:56:48.000Z | 2022-03-30T07:02:21.000Z | ni/src/lib/nfp/cz2ccmW.c | tenomoto/ncl | a87114a689a1566e9aa03d85bcf6dc7325b47633 | [
"Apache-2.0"
] | 58 | 2016-12-14T00:15:22.000Z | 2022-03-15T09:13:00.000Z | #include <stdio.h>
#include <math.h>
#include "wrapper.h"
extern void NGCALLF(dcz2ccm,DCZ2CCM)(double*,double*,double*,double*,double*,
double*,double*,double*,int*,int*,int*,
int*,double*,double*,double*,double*,
double*,double*,double*,double*,double*);
NhlErrorTypes cz2ccm_W( void )
{
/*
* Input array variables
*/
void *ps, *phis, *tv, *p0, *hyam, *hybm, *hyai, *hybi;
double *tmp, *tmp_p0;
double *tmp_ps = NULL;
double *tmp_phis = NULL;
double *tmp_tv = NULL;
double *tmp_hyam, *tmp_hybm, *tmp_hyai, *tmp_hybi;
int ndims_ps;
ng_size_t dsizes_ps[NCL_MAX_DIMENSIONS];
int ndims_phis;
ng_size_t dsizes_phis[NCL_MAX_DIMENSIONS];
int ndims_tv;
ng_size_t dsizes_tv[NCL_MAX_DIMENSIONS];
ng_size_t dsizes_hyam[NCL_MAX_DIMENSIONS];
ng_size_t dsizes_hybm[NCL_MAX_DIMENSIONS];
ng_size_t dsizes_hyai[NCL_MAX_DIMENSIONS];
ng_size_t dsizes_hybi[NCL_MAX_DIMENSIONS];
NclBasicDataTypes type_ps, type_phis, type_tv, type_p0;
NclBasicDataTypes type_hyam, type_hybm, type_hyai, type_hybi;
/*
* Output array variables
*/
void *z2;
double *tmp_z2 = NULL;
int size_leftmost;
NclBasicDataTypes type_z2;
/*
* work arrays
*/
double *pmln, *hypdln, *hyalph, *zslice, *hyba, *hybb, *pterm, *tv2;
/*
* Declare various variables for random purposes.
*/
ng_size_t i, index_ps, index_z2, scalar_phis;
ng_size_t nlat, mlon, klev, klev1, nlatmlon, klevnlatmlon;
ng_size_t size_z2;
int imlon, inlat, iklev, iklev1;
/*
* Retrieve arguments.
*/
ps = (void*)NclGetArgValue(
0,
8,
&ndims_ps,
dsizes_ps,
NULL,
NULL,
&type_ps,
DONT_CARE);
phis = (void*)NclGetArgValue(
1,
8,
&ndims_phis,
dsizes_phis,
NULL,
NULL,
&type_phis,
DONT_CARE);
tv = (void*)NclGetArgValue(
2,
8,
&ndims_tv,
dsizes_tv,
NULL,
NULL,
&type_tv,
DONT_CARE);
p0 = (void*)NclGetArgValue(
3,
8,
NULL,
NULL,
NULL,
NULL,
&type_p0,
DONT_CARE);
hyam = (void*)NclGetArgValue(
4,
8,
NULL,
dsizes_hyam,
NULL,
NULL,
&type_hyam,
DONT_CARE);
hybm = (void*)NclGetArgValue(
5,
8,
NULL,
dsizes_hybm,
NULL,
NULL,
&type_hybm,
DONT_CARE);
hyai = (void*)NclGetArgValue(
6,
8,
NULL,
dsizes_hyai,
NULL,
NULL,
&type_hyai,
DONT_CARE);
hybi = (void*)NclGetArgValue(
7,
8,
NULL,
dsizes_hybi,
NULL,
NULL,
&type_hybi,
DONT_CARE);
/*
* ps must be at least two dimensions.
*/
if( ndims_ps < 2 ) {
NhlPError(NhlFATAL,NhlEUNKNOWN,"cz2ccm: The input array 'ps' must be at least 2 dimensions");
return(NhlFATAL);
}
/*
* tv must have the same dimensions as ps, only with one more dimension
* 'klev'.
*/
if( ndims_tv != ndims_ps+1 ) {
NhlPError(NhlFATAL,NhlEUNKNOWN,"cz2ccm: The input array 'tv' must have one more dimension than 'ps'");
return(NhlFATAL);
}
/*
* Check phis dimension sizes. phis can be scalar, 2D or 3D. If 2D or 3D,
* then ps must be exact same size.
*/
scalar_phis = is_scalar(ndims_phis,dsizes_phis);
if(!scalar_phis) {
if(ndims_phis < 2) {
NhlPError(NhlFATAL,NhlEUNKNOWN,"cz2ccm: The input array 'phis' must be a scalar or at least 2 dimensions");
return(NhlFATAL);
}
else if(ndims_phis > 2 && ndims_phis != ndims_ps) {
NhlPError(NhlFATAL,NhlEUNKNOWN,"cz2ccm: The input array 'phis' must be a scalar, 2 dimensions, or the same size as 'ps'");
return(NhlFATAL);
}
for( i = 1; i <= ndims_phis; i++ ) {
if( dsizes_ps[ndims_ps-i] != dsizes_phis[ndims_phis-i] ) {
NhlPError(NhlFATAL,NhlEUNKNOWN,"cz2ccm: The input array 'phis' must be a scalar or the same rightmost dimensions as 'ps'");
return(NhlFATAL);
}
}
}
/*
* Get nlat, mlon, klev, klev1.
*/
nlat = dsizes_ps[ndims_ps-2];
mlon = dsizes_ps[ndims_ps-1];
klev = dsizes_tv[ndims_tv-3];
klev1 = dsizes_hyai[0];
nlatmlon = nlat * mlon;
klevnlatmlon = klev * nlatmlon;
/*
* Test dimension sizes to make sure they are <= INT_MAX.
*/
if((mlon > INT_MAX) || (nlat > INT_MAX) ||
(klev > INT_MAX) || (klev1 > INT_MAX)) {
NhlPError(NhlFATAL,NhlEUNKNOWN,"cz2ccm: one or more dimension sizes are greater than INT_MAX");
return(NhlFATAL);
}
imlon = (int) mlon;
inlat = (int) nlat;
iklev = (int) klev;
iklev1 = (int) klev1;
/*
* Check dimension sizes of tv.
*/
if( dsizes_tv[ndims_tv-1] != mlon || dsizes_tv[ndims_tv-2] != nlat ) {
NhlPError(NhlFATAL,NhlEUNKNOWN,"cz2ccm: The last two dimensions of tv must be nlat x mlon");
return(NhlFATAL);
}
/*
* Check dimension sizes of tv and ps.
*/
for( i = 0; i < ndims_tv-3; i++ ) {
if( dsizes_tv[i] != dsizes_ps[i] ) {
NhlPError(NhlFATAL,NhlEUNKNOWN,"cz2ccm: The rightmost dimensions of 'ps' and 'tv' must be the same");
return(NhlFATAL);
}
}
/*
* hyam and hybm must be the same dimension sizes and
* hyai and hybi must be the same dimension sizes.
*/
if( dsizes_hyam[0] != klev || dsizes_hybm[0] != klev ) {
NhlPError(NhlFATAL,NhlEUNKNOWN,"cz2ccm: The dimension size of 'hyam' and 'hybm' must be 'klev'");
return(NhlFATAL);
}
if( dsizes_hybi[0] != klev1 ) {
NhlPError(NhlFATAL,NhlEUNKNOWN,"cz2ccm: The dimension size of 'hyai' and 'hybi' must be 'klev1'");
return(NhlFATAL);
}
/*
* Compute the size of the leftmost dimensions of the output array
* (minus the nlat,mlon,klev dims).
*/
size_leftmost = 1;
for( i = 0; i < ndims_tv-3; i++ ) size_leftmost *= dsizes_tv[i];
size_z2 = size_leftmost*klev*nlat*mlon;
/*
* Allocate space for ps if necessary.
*/
if(type_ps != NCL_double) {
tmp_ps = (double *)calloc(nlatmlon,sizeof(double));
if( tmp_ps == NULL ) {
NhlPError(NhlFATAL,NhlEUNKNOWN,"cz2ccm: Unable to allocate memory for coercing ps array to double precision");
return(NhlFATAL);
}
}
/*
* Allocate space for tv if necessary.
*/
if(type_tv != NCL_double) {
tmp_tv = (double *)calloc(klevnlatmlon,sizeof(double));
if( tmp_tv == NULL ) {
NhlPError(NhlFATAL,NhlEUNKNOWN,"cz2ccm: Unable to allocate memory for coercing tv array double precision");
return(NhlFATAL);
}
}
/*
* Allocate space for phis and coerce if necessary.
* The case of ndims_phis > 2 will be handled in for
* loop below.
*/
if(scalar_phis) {
tmp_phis = (double *)malloc(nlatmlon*sizeof(double*));
tmp = coerce_input_double(phis,type_phis,1,0,NULL,NULL);
for(i = 0; i < nlatmlon; i++) tmp_phis[i] = tmp[0];
if(type_phis != NCL_double) free(tmp);
}
else if(ndims_phis == 2) {
tmp_phis = coerce_input_double(phis,type_phis,nlatmlon,0,NULL,NULL);
}
else if(ndims_phis > 2) {
tmp_phis = (double *)malloc(nlatmlon*sizeof(double*));
}
/*
* Coerce input arrays to double if necessary.
*/
tmp_p0 = coerce_input_double(p0,type_p0,1,0,NULL,NULL);
tmp_hyam = coerce_input_double(hyam,type_hyam,klev,0,NULL,NULL);
tmp_hybm = coerce_input_double(hybm,type_hybm,klev,0,NULL,NULL);
tmp_hyai = coerce_input_double(hyai,type_hyai,klev1,0,NULL,NULL);
tmp_hybi = coerce_input_double(hybi,type_hybi,klev1,0,NULL,NULL);
if(tmp_phis == NULL || tmp_p0 == NULL ||
tmp_hyam == NULL || tmp_hybm == NULL ||
tmp_hyai == NULL || tmp_hybi == NULL) {
NhlPError(NhlFATAL,NhlEUNKNOWN,"cz2ccm: Unable to allocate memory for coercing input arrays to double precision");
return(NhlFATAL);
}
/*
* Allocate space for output value.
*/
if(type_ps != NCL_double || type_tv != NCL_double) {
type_z2 = NCL_float;
tmp_z2 = (double *)calloc(klevnlatmlon,sizeof(double));
z2 = (float *)NclMalloc(size_z2*sizeof(float));
if(tmp_z2 == NULL || z2 == NULL ) {
NhlPError(NhlFATAL,NhlEUNKNOWN,"cz2ccm: Unable to allocate memory for output array");
return(NhlFATAL);
}
}
else {
type_z2 = NCL_double;
z2 = (double *)NclMalloc(size_z2*sizeof(double));
if( z2 == NULL ) {
NhlPError(NhlFATAL,NhlEUNKNOWN,"cz2ccm: Unable to allocate memory for output array");
return(NhlFATAL);
}
}
/*
* Allocate space for scratch arrays.
*/
tv2 = (double *)NclMalloc( klev*mlon*sizeof(double));
pmln = (double *)NclMalloc((klev+1)*mlon*sizeof(double));
hypdln = (double *)NclMalloc( klev*mlon*sizeof(double));
hyalph = (double *)NclMalloc( klev*mlon*sizeof(double));
zslice = (double *)NclMalloc( klev*mlon*sizeof(double));
hyba = (double *)NclMalloc( 2*(klev+1)*sizeof(double));
hybb = (double *)NclMalloc( 2*(klev+1)*sizeof(double));
pterm = (double *)NclMalloc( klev*mlon*sizeof(double));
if( pmln == NULL || hypdln == NULL || hyalph == NULL || zslice == NULL ||
hyba == NULL || hybb == NULL || pterm == NULL ) {
NhlPError(NhlFATAL,NhlEUNKNOWN,"cz2ccm: Unable to allocate memory for work arrays");
return(NhlFATAL);
}
/*
* Call the Fortran version of this routine.
*/
index_ps = index_z2 = 0;
for( i = 0; i < size_leftmost; i++ ) {
/*
* Coerce subsection of ps/tv array to double.
*/
if(type_ps != NCL_double) {
coerce_subset_input_double(ps,tmp_ps,index_ps,type_ps,nlatmlon,0,
NULL,NULL);
}
else {
tmp_ps = &((double*)ps)[index_ps];
}
if(type_tv != NCL_double) {
coerce_subset_input_double(tv,tmp_tv,index_z2,type_tv,klevnlatmlon,0,
NULL,NULL);
}
else {
tmp_tv = &((double*)tv)[index_z2];
}
/*
* Coerce subsection of phis to double if necessary.
*/
if(ndims_phis > 2) {
if(type_phis != NCL_double) {
coerce_subset_input_double(phis,tmp_phis,index_ps,type_phis,
nlatmlon,0,NULL,NULL);
}
else {
tmp_phis = &((double*)phis)[index_ps];
}
}
if(type_z2 == NCL_double) tmp_z2 = &((double*)z2)[index_z2];
NGCALLF(dcz2ccm,DCZ2CCM)(tmp_ps,tmp_phis,tmp_tv,tmp_p0,
tmp_hyam,tmp_hybm,tmp_hyai,tmp_hybi,
&imlon,&inlat,&iklev,&iklev1,tmp_z2,pmln,
hypdln,hyalph,zslice,hyba,hybb,pterm,tv2);
/*
* Coerce output to float if necessary.
*/
if(type_z2 != NCL_double) {
coerce_output_float_only(z2,tmp_z2,klevnlatmlon,index_z2);
}
index_ps += nlatmlon;
index_z2 += klevnlatmlon;
}
/*
* Free memory.
*/
NclFree(tv2);
NclFree(pmln);
NclFree(hypdln);
NclFree(hyalph);
NclFree(zslice);
NclFree(hyba);
NclFree(hybb);
NclFree(pterm);
if(type_ps != NCL_double) NclFree(tmp_ps);
if(type_tv != NCL_double) NclFree(tmp_tv);
if(type_p0 != NCL_double) NclFree(tmp_p0);
if(type_hyam != NCL_double) NclFree(tmp_hyam);
if(type_hybm != NCL_double) NclFree(tmp_hybm);
if(type_hyai != NCL_double) NclFree(tmp_hyai);
if(type_hybi != NCL_double) NclFree(tmp_hybi);
if(type_z2 != NCL_double) NclFree(tmp_z2);
if(ndims_phis == 2 && type_phis != NCL_double) NclFree(tmp_phis);
/*
* Return.
*/
return(NclReturnValue(z2,ndims_tv,dsizes_tv,NULL,type_z2,0));
}
| 29.062657 | 131 | 0.608486 | [
"3d"
] |
faaf79c0db60f7aee5dec3b46c61fc2aab5a1760 | 956 | h | C | bsdlibc/include/pdp/autoconfig.h | jguillaumes/muxx | 2b9e20dcef9d42e6abfe0024fef16ad98b78facf | [
"BSD-2-Clause"
] | 3 | 2018-07-18T19:41:50.000Z | 2021-03-08T23:00:04.000Z | bsdlibc/include/pdp/autoconfig.h | jguillaumes/muxx | 2b9e20dcef9d42e6abfe0024fef16ad98b78facf | [
"BSD-2-Clause"
] | null | null | null | bsdlibc/include/pdp/autoconfig.h | jguillaumes/muxx | 2b9e20dcef9d42e6abfe0024fef16ad98b78facf | [
"BSD-2-Clause"
] | null | null | null | /*
* Copyright (c) 1986 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
* @(#)autoconfig.h 1.1 (2.10BSD Berkeley) 12/1/86
*/
/*
* Possible error codes of the auto configuration program
*/
#define AC_OK 0 /* Everything A-OK for system go */
#define AC_SETUP 1 /* Error in initializing autoconf program */
#define AC_SINGLE 2 /* Non serious error, come to single user */
#define ACI_BADINTR -1 /* device interrupted through wrong vector */
#define ACP_EXISTS 1 /* device exists */
#define ACI_GOODINTR 1 /* interrupt OK */
#define ACP_IFINTR 0 /* device exists if interrupts OK */
#define ACI_NOINTR 0 /* device didn't interrupt */
#define ACP_NXDEV -1 /* no such device */
#define YES 1 /* general yes */
#define NO 0 /* general no */
/*
* Magic number to verify that autoconfig runs only once.
*/
#define CONF_MAGIC 0x1960
| 31.866667 | 68 | 0.714435 | [
"vector"
] |
fab743acb01b5960e33aee320514da4cfe06726c | 16,109 | c | C | java/jni/src/main/c/jni/daos_jni.c | gczsjdy/daos | abbd900010562f3acea9c6b1dc2ca98a8d3c71fa | [
"Apache-2.0"
] | null | null | null | java/jni/src/main/c/jni/daos_jni.c | gczsjdy/daos | abbd900010562f3acea9c6b1dc2ca98a8d3c71fa | [
"Apache-2.0"
] | null | null | null | java/jni/src/main/c/jni/daos_jni.c | gczsjdy/daos | abbd900010562f3acea9c6b1dc2ca98a8d3c71fa | [
"Apache-2.0"
] | null | null | null | #include "daos_jni_common.h"
static const char* server_group = "daos_server";
static jint JNI_VERSION = JNI_VERSION_1_8;
static const int max_svc_nreplicas = 13;
static const unsigned int default_svc_nreplicas = 1;
jclass JC_String;
jclass JC_Exception;
/** A-key name of DFS Layout Version */
#define LAYOUT_NAME "DFS_LAYOUT_VERSION"
/** D-key name of SB metadata */
#define SB_DKEY "DFS_SB_METADATA"
#define SB_AKEYS 5
/** A-key name of SB magic */
#define MAGIC_NAME "DFS_MAGIC"
/** A-key name of SB version */
#define SB_VERSION_NAME "DFS_SB_VERSION"
/** A-key name of DFS Layout Version */
#define LAYOUT_NAME "DFS_LAYOUT_VERSION"
/** A-key name of Default chunk size */
#define CS_NAME "DFS_CHUNK_SIZE"
/** A-key name of Default Object Class */
#define OC_NAME "DFS_OBJ_CLASS"
/** Magic Value */
#define DFS_SB_MAGIC 0xda05df50da05df50
/** DFS Layout version value */
#define DFS_SB_VERSION 1
/** DFS SB Version Value */
#define DFS_LAYOUT_VERSION 1
/** Array object stripe size for regular files */
#define DFS_DEFAULT_CHUNK_SIZE 1048576
#define DFS_DEFAULT_OBJ_CLASS OC_SX
/** Number of A-keys for attributes in any object entry */
#define INODE_AKEYS 7
/** A-key name of mode_t value */
#define MODE_NAME "mode"
/** A-key name of object ID value */
#define OID_NAME "oid"
/** A-key name of chunk size; will be stored only if not default */
#define CSIZE_NAME "chunk_size"
/** A-key name of last access time */
#define ATIME_NAME "atime"
/** A-key name of last modify time */
#define MTIME_NAME "mtime"
/** A-key name of last change time */
#define CTIME_NAME "ctime"
/** A-key name of symlink value */
#define SYML_NAME "syml"
/** OIDs for Superblock and Root objects */
#define RESERVED_LO 0
#define SB_HI 0
#define ROOT_HI 1
struct dfs_entry {
/** mode (permissions + entry type) */
mode_t mode;
/** Object ID if not a symbolic link */
daos_obj_id_t oid;
/** chunk size of file */
daos_size_t chunk_size;
/** Sym Link value */
char *value;
/* Time of last access */
time_t atime;
/* Time of last modification */
time_t mtime;
/* Time of last status change */
time_t ctime;
};
static int
insert_entry(daos_handle_t oh, daos_handle_t th, const char *name,
struct dfs_entry entry)
{
d_sg_list_t sgls[INODE_AKEYS];
d_iov_t sg_iovs[INODE_AKEYS];
daos_iod_t iods[INODE_AKEYS];
daos_key_t dkey;
unsigned int akeys_nr, i;
int rc;
d_iov_set(&dkey, (void *)name, strlen(name));
i = 0;
/** Add the mode */
d_iov_set(&sg_iovs[i], &entry.mode, sizeof(mode_t));
d_iov_set(&iods[i].iod_name, MODE_NAME, strlen(MODE_NAME));
iods[i].iod_size = sizeof(mode_t);
i++;
/** Add the oid */
d_iov_set(&sg_iovs[i], &entry.oid, sizeof(daos_obj_id_t));
d_iov_set(&iods[i].iod_name, OID_NAME, strlen(OID_NAME));
iods[i].iod_size = sizeof(daos_obj_id_t);
i++;
/** Add the chunk size if set */
if (entry.chunk_size) {
d_iov_set(&sg_iovs[i], &entry.chunk_size, sizeof(daos_size_t));
d_iov_set(&iods[i].iod_name, CSIZE_NAME, strlen(CSIZE_NAME));
iods[i].iod_size = sizeof(daos_size_t);
i++;
}
/** Add the access time */
d_iov_set(&sg_iovs[i], &entry.atime, sizeof(time_t));
d_iov_set(&iods[i].iod_name, ATIME_NAME, strlen(ATIME_NAME));
iods[i].iod_size = sizeof(time_t);
i++;
/** Add the modify time */
d_iov_set(&sg_iovs[i], &entry.mtime, sizeof(time_t));
d_iov_set(&iods[i].iod_name, MTIME_NAME, strlen(MTIME_NAME));
iods[i].iod_size = sizeof(time_t);
i++;
/** Add the change time */
d_iov_set(&sg_iovs[i], &entry.ctime, sizeof(time_t));
d_iov_set(&iods[i].iod_name, CTIME_NAME, strlen(CTIME_NAME));
iods[i].iod_size = sizeof(time_t);
i++;
/** Add symlink value if Symlink */
if (S_ISLNK(entry.mode)) {
d_iov_set(&sg_iovs[i], entry.value, strlen(entry.value) + 1);
d_iov_set(&iods[i].iod_name, SYML_NAME, strlen(SYML_NAME));
iods[i].iod_size = strlen(entry.value) + 1;
i++;
}
akeys_nr = i;
for (i = 0; i < akeys_nr; i++) {
sgls[i].sg_nr = 1;
sgls[i].sg_nr_out = 0;
sgls[i].sg_iovs = &sg_iovs[i];
dcb_set_null(&iods[i].iod_kcsum);
iods[i].iod_nr = 1;
iods[i].iod_recxs = NULL;
iods[i].iod_eprs = NULL;
iods[i].iod_csums = NULL;
iods[i].iod_type = DAOS_IOD_SINGLE;
}
rc = daos_obj_update(oh, th, &dkey, akeys_nr, iods, sgls, NULL);
if (rc) {
D_ERROR("Failed to insert entry %s (%d)\n", name, rc);
return daos_der2errno(rc);
}
return 0;
}
jint JNI_OnLoad(JavaVM* vm, void *reserved) {
JNIEnv* env;
if ((*vm)->GetEnv(vm, (void**)&env, JNI_VERSION) != JNI_OK) {
return JNI_ERR;
}
jclass localString, localException;
localString = (*env)->FindClass(env, "java/lang/String");
localException = (*env)->FindClass(env, "com/intel/daos/DaosNativeException");
JC_String = (jclass) (*env)->NewGlobalRef(env, localString);
JC_Exception = (jclass) (*env)->NewGlobalRef(env, localException);
(*env)->DeleteLocalRef(env, localString);
(*env)->DeleteLocalRef(env, localException);
int rc = daos_init();
if (rc) {
D_ERROR("daos init failed with rc = %d", rc);
return rc;
}
return JNI_VERSION;
}
static int
open_sb(daos_handle_t coh, bool create, dfs_attr_t *attr, daos_handle_t *oh)
{
d_sg_list_t sgls[SB_AKEYS];
d_iov_t sg_iovs[SB_AKEYS];
daos_iod_t iods[SB_AKEYS];
daos_key_t dkey;
uint64_t magic;
uint16_t sb_ver;
uint16_t layout_ver;
daos_size_t chunk_size = 0;
daos_oclass_id_t oclass = OC_UNKNOWN;
daos_obj_id_t super_oid;
int i, rc;
if (oh == NULL)
return EINVAL;
/** Open SB object */
super_oid.lo = RESERVED_LO;
super_oid.hi = SB_HI;
daos_obj_generate_id(&super_oid, 0, OC_RP_XSF, 0);
rc = daos_obj_open(coh, super_oid, create ? DAOS_OO_RW : DAOS_OO_RO,
oh, NULL);
if (rc) {
D_ERROR("daos_obj_open() Failed (%d)\n", rc);
return daos_der2errno(rc);
}
d_iov_set(&dkey, SB_DKEY, strlen(SB_DKEY));
i = 0;
d_iov_set(&sg_iovs[i], &magic, sizeof(uint64_t));
d_iov_set(&iods[i].iod_name, MAGIC_NAME, strlen(MAGIC_NAME));
i++;
d_iov_set(&sg_iovs[i], &sb_ver, sizeof(uint64_t));
d_iov_set(&iods[i].iod_name, SB_VERSION_NAME, strlen(SB_VERSION_NAME));
i++;
d_iov_set(&sg_iovs[i], &layout_ver, sizeof(uint64_t));
d_iov_set(&iods[i].iod_name, LAYOUT_NAME, strlen(LAYOUT_NAME));
i++;
d_iov_set(&sg_iovs[i], &chunk_size, sizeof(daos_size_t));
d_iov_set(&iods[i].iod_name, CS_NAME, strlen(CS_NAME));
i++;
d_iov_set(&sg_iovs[i], &oclass, sizeof(daos_oclass_id_t));
d_iov_set(&iods[i].iod_name, OC_NAME, strlen(OC_NAME));
i++;
for (i = 0; i < SB_AKEYS; i++) {
sgls[i].sg_nr = 1;
sgls[i].sg_nr_out = 0;
sgls[i].sg_iovs = &sg_iovs[i];
dcb_set_null(&iods[i].iod_kcsum);
iods[i].iod_nr = 1;
iods[i].iod_size = DAOS_REC_ANY;
iods[i].iod_recxs = NULL;
iods[i].iod_eprs = NULL;
iods[i].iod_csums = NULL;
iods[i].iod_type = DAOS_IOD_SINGLE;
}
/** create the SB and exit */
if (create) {
iods[0].iod_size = sizeof(uint64_t);
magic = DFS_SB_MAGIC;
iods[1].iod_size = sizeof(uint16_t);
sb_ver = DFS_SB_VERSION;
iods[2].iod_size = sizeof(uint16_t);
layout_ver = DFS_LAYOUT_VERSION;
iods[3].iod_size = sizeof(daos_size_t);
if (attr && attr->da_chunk_size != 0)
chunk_size = attr->da_chunk_size;
else
chunk_size = DFS_DEFAULT_CHUNK_SIZE;
iods[4].iod_size = sizeof(daos_oclass_id_t);
if (attr && attr->da_oclass_id != OC_UNKNOWN)
oclass = attr->da_oclass_id;
else
oclass = DFS_DEFAULT_OBJ_CLASS;
rc = daos_obj_update(*oh, DAOS_TX_NONE, &dkey, SB_AKEYS, iods,
sgls, NULL);
if (rc) {
D_ERROR("Failed to update SB info (%d)\n", rc);
D_GOTO(err, rc = daos_der2errno(rc));
}
return 0;
}
/* otherwise fetch the values and verify SB */
rc = daos_obj_fetch(*oh, DAOS_TX_NONE, &dkey, SB_AKEYS, iods, sgls,
NULL, NULL);
if (rc) {
D_ERROR("Failed to fetch SB info (%d)\n", rc);
D_GOTO(err, rc = daos_der2errno(rc));
}
/** check if SB info exists */
if (iods[0].iod_size == 0) {
D_ERROR("SB does not exist.\n");
D_GOTO(err, rc = ENOENT);
}
if (magic != DFS_SB_MAGIC) {
D_ERROR("SB MAGIC verification failed\n");
D_GOTO(err, rc = EINVAL);
}
D_ASSERT(attr);
attr->da_chunk_size = (chunk_size) ? chunk_size :
DFS_DEFAULT_CHUNK_SIZE;
attr->da_oclass_id = (oclass != OC_UNKNOWN) ? oclass :
DFS_DEFAULT_OBJ_CLASS;
/** TODO - check SB & layout versions */
return 0;
err:
daos_obj_close(*oh, NULL);
return rc;
}
void JNI_OnUnload(JavaVM* vm, void *reserved) {
JNIEnv* env;
(*vm)->GetEnv(vm, (void**)&env, JNI_VERSION);
(*env)->DeleteGlobalRef(env, JC_String);
(*env)->DeleteGlobalRef(env, JC_Exception);
daos_fini();
}
JNIEXPORT jint JNICALL Java_com_intel_daos_DaosJNI_daosInit
(JNIEnv *env, jobject obj){
int rc = daos_init();
return rc;
}
JNIEXPORT jstring JNICALL Java_com_intel_daos_DaosJNI_daosPoolCreate
(JNIEnv *env, jobject obj, jlong scm, jlong nvme) {
printf(" daosPoolCreate \n");
d_rank_t svc[max_svc_nreplicas];
d_rank_list_t svcl = {};
memset(svc, 0, sizeof(svc));
svcl.rl_ranks = svc;
svcl.rl_nr = default_svc_nreplicas;
if (scm < 0 || nvme < 0) {
D_ERROR("Size provided is negative!");
D_GOTO(out_daos, EINVAL);
}
uuid_t pool_uuid;
int i;
printf(" daosPoolCreate 1 \n");
int rc = daos_pool_create(0731 /* mode */,
geteuid() /* user owner */,
getegid() /* group owner */,
server_group /* daos server process set ID */,
NULL /* list of targets, NULL = all */,
"pmem" /* storage type to use, use default */,
scm ,
nvme ,
NULL ,
&svcl /* pool service nodes, used for connect */,
pool_uuid, /* the uuid of the pool created */
NULL /* event, use blocking call for now */);
printf(" daosPoolCreate 2 ,rc =%d \n",rc);
if (rc) {
D_ERROR("daos native error in create_pool():failed to create pool with rc = %d", rc);
D_GOTO(out_daos, rc);
}
char tmp[50];
uuid_unparse(pool_uuid, tmp);
strcat(tmp," ");
/* Print the pool service replica ranks. */
for (i = 0; i < svcl.rl_nr - 1; i++){
if(i) strcpy(tmp,",");
strcat(tmp,svcl.rl_ranks[i]);
}
char *buf[sizeof(svcl.rl_ranks[svcl.rl_nr - 1])];
sprintf(buf,"%d",svcl.rl_ranks[svcl.rl_nr - 1]);
strcat(tmp,buf);
return (*env)->NewStringUTF(env, tmp);
out_daos:
daos_fini();
return rc;
}
JNIEXPORT jlong JNICALL Java_com_intel_daos_DaosJNI_daosPoolConnect
(JNIEnv *env, jobject obj, jstring p_uuid, jint mode,jstring p_svc) {
daos_handle_t poh;
int rc;
const char *pool_str = (*env)->GetStringUTFChars(env, p_uuid, NULL);\
const char *svc = (*env)->GetStringUTFChars(env, p_svc, NULL);
uuid_t pool_uuid;
uuid_parse(pool_str, pool_uuid);
d_rank_list_t *svcl=daos_rank_list_parse(svc, ":");
if (svcl == NULL) {
D_ERROR("Invalid pool service rank list");
D_GOTO(out_daos, rc = -DER_INVAL);
}
rc = daos_pool_connect(pool_uuid, server_group, svcl,
mode,
&poh /* returned pool handle */,
NULL /* returned pool info */,
NULL /* event */);
(*env)->ReleaseStringUTFChars(env, p_uuid, pool_str);
if (rc != -DER_SUCCESS) {
D_ERROR("Failed to connect to pool (%d)", rc);
D_GOTO(out_daos, rc=daos_errno2der(rc));
}else {
jlong java_poh;
memcpy(&java_poh, &poh, sizeof(daos_handle_t));
return java_poh;
}
out_daos:
daos_fini();
return rc;
}
JNIEXPORT jint JNICALL Java_com_intel_daos_DaosJNI_daosPoolDisconnect
(JNIEnv *env, jobject obj, jlong java_poh) {
daos_handle_t poh;
memcpy(&poh, &java_poh, sizeof(daos_handle_t));
return daos_pool_disconnect(poh, NULL);
}
JNIEXPORT jint JNICALL Java_com_intel_daos_DaosJNI_daosContCreate
(JNIEnv *env, jobject obj, jlong java_poh, jstring c_uuid) {
daos_handle_t poh;
memcpy(&poh, &java_poh, sizeof(daos_handle_t));
const char *cont_str = (*env)->GetStringUTFChars(env, c_uuid, NULL);
uuid_t cont_uuid;
uuid_parse(cont_str, cont_uuid);
daos_prop_t *prop = NULL;
prop = daos_prop_alloc(1);
if (prop == NULL) {
D_ERROR("Failed to allocate container prop.");
return ENOMEM;
}
prop->dpp_entries[0].dpe_type = DAOS_PROP_CO_LAYOUT_TYPE;
prop->dpp_entries[0].dpe_val = DAOS_PROP_CO_LAYOUT_POSIX;
int rc = daos_cont_create(poh, cont_uuid, prop, NULL /* event */);
daos_prop_free(prop);
if (rc) {
D_ERROR("daos_cont_create() failed (%d)\n", rc);
return daos_der2errno(rc);
}
(*env)->ReleaseStringUTFChars(env, c_uuid, cont_str);
return rc;
}
JNIEXPORT jlong JNICALL Java_com_intel_daos_DaosJNI_daosContOpen
(JNIEnv *env, jobject obj, jlong java_poh, jstring c_uuid, jint mode) {
daos_handle_t poh,super_oh;
daos_cont_info_t co_info;
struct dfs_entry entry = {0};
memcpy(&poh, &java_poh, sizeof(daos_handle_t));
const char *cont_str = (*env)->GetStringUTFChars(env, c_uuid, NULL);
uuid_t cont_uuid;
uuid_parse(cont_str, cont_uuid);
daos_handle_t coh;
int rc = daos_cont_open(poh, cont_uuid, mode, &coh, &co_info, NULL);
if (rc) {
D_ERROR("daos_cont_open() failed (%d)\n", rc);
D_GOTO(err_destroy, rc=daos_der2errno(rc));
}
(*env)->ReleaseStringUTFChars(env, c_uuid, cont_str);
dfs_attr_t dattr;
dattr.da_chunk_size = DFS_DEFAULT_CHUNK_SIZE;
dattr.da_oclass_id = DFS_DEFAULT_OBJ_CLASS;
/** Create SB */
rc = open_sb(coh, true, &dattr, &super_oh);
if (rc)
D_GOTO(err_close, rc);
/** Add root object */
entry.oid.lo = RESERVED_LO;
entry.oid.hi = ROOT_HI;
daos_obj_generate_id(&entry.oid, 0, dattr.da_oclass_id, 0);
entry.mode = S_IFDIR | 0777;
entry.atime = entry.mtime = entry.ctime = time(NULL);
entry.chunk_size = dattr.da_chunk_size;
rc = insert_entry(super_oh, DAOS_TX_NONE, "/", entry);
if (rc) {
D_ERROR("Failed to insert root entry (%d).", rc);
D_GOTO(err_super, rc);
}
daos_obj_close(super_oh, NULL);
jlong java_coh;
memcpy(&java_coh, &coh, sizeof(daos_handle_t));
return java_coh;
err_super:
daos_obj_close(super_oh, NULL);
return rc;
err_close:
daos_cont_close(coh, NULL);
return rc;
err_destroy:
daos_cont_destroy(poh, cont_uuid, 1, NULL);
return rc;
}
JNIEXPORT jint JNICALL Java_com_intel_daos_DaosJNI_daosContClose
(JNIEnv *env, jobject obj, jlong java_coh) {
daos_handle_t coh;
memcpy(&coh, &java_coh, sizeof(daos_handle_t));
return daos_cont_close(coh, NULL);
}
JNIEXPORT jlong JNICALL Java_com_intel_daos_DaosJNI_daosEventQueueCreate
(JNIEnv *env, jobject obj) {
daos_handle_t eq;
int rc = daos_eq_create(&eq);
if (rc) {
D_ERROR("daos native error in eq_create():failed to create event queue with rc = %d", rc);
return daos_errno2der(rc);
}
jlong java_eq;
memcpy(&java_eq, &eq, sizeof(daos_handle_t));
return java_eq;
}
JNIEXPORT jint JNICALL Java_com_intel_daos_DaosJNI_daosEventPoll
(JNIEnv *env, jobject obj, jlong java_eq, jint num) {
int acc = 0, rc = 0;
daos_handle_t eq;
memcpy(&eq, &java_eq, sizeof(daos_handle_t));
// daos_event_t **c_evp = (daos_event_t**) (*env)->GetDirectBufferAddress(env, evp);
daos_event_t **evp = malloc(num * sizeof(daos_event_t*));
while (acc < num) {
rc = daos_eq_poll(eq, 0, DAOS_EQ_WAIT, num, evp);
if (rc >= 0) {
for (int i = 0; i < rc; ++i) {
if (evp[i]->ev_error != 0) {
rc = evp[i]->ev_error;
goto out;
}
}
acc += rc;
} else {
goto out;
}
}
out:
free(evp);
return rc;
}
JNIEXPORT jint JNICALL Java_com_intel_daos_DaosJNI_daosFinish
(JNIEnv *env, jobject obj) {
return daos_fini();
}
JNIEXPORT jint JNICALL Java_com_intel_daos_DaosJNI_daosPoolDestroy
(JNIEnv *env, jobject obj, jstring p_uuid){
daos_handle_t poh;
int rc;
const char *pool_str = (*env)->GetStringUTFChars(env, p_uuid, NULL);
uuid_t pool_uuid;
uuid_parse(pool_str, pool_uuid);
/** destroy the pool created in pool_create */
rc = daos_pool_destroy(pool_uuid, server_group, 1 /* force */,
NULL /* event */);
return rc;
}
| 28.663701 | 95 | 0.668384 | [
"object"
] |
fab74e1d230dfefa3dc7ea3e43c8635dc91d2ee8 | 1,246 | h | C | Util/genutil/Ranges.h | rwharton/psrchive_dsn | 9584862167154fa48db89b86151c4221ad4bb96b | [
"AFL-2.1"
] | null | null | null | Util/genutil/Ranges.h | rwharton/psrchive_dsn | 9584862167154fa48db89b86151c4221ad4bb96b | [
"AFL-2.1"
] | null | null | null | Util/genutil/Ranges.h | rwharton/psrchive_dsn | 9584862167154fa48db89b86151c4221ad4bb96b | [
"AFL-2.1"
] | 1 | 2020-02-13T20:08:14.000Z | 2020-02-13T20:08:14.000Z | //-*-C++-*-
/***************************************************************************
*
* Copyright (C) 2016 by Willem van Straten
* Licensed under the Academic Free License version 2.1
*
***************************************************************************/
// psrchive/Util/units/Ranges.h
#ifndef __Ranges_H
#define __Ranges_H
#include <vector>
#include <iostream>
class Range
{
protected:
bool gt, lt, eq;
double x0,x1;
void clear () { gt = lt = eq = false; }
public:
Range () { clear(); x0 = x1 = 0; }
friend std::ostream& operator<< (std::ostream&, const Range&);
friend std::istream& operator>> (std::istream&, Range&);
bool is_range () const { return !(eq || gt || lt); }
std::pair<double,double> get_range () const;
void set_range (double _0, double _1) { x0=_0; x1=_1; clear(); }
bool is_value () const { return eq; }
double get_value () const;
void set_value (double x) { x0=x; clear(); eq=true; }
bool within (double x) const;
};
class Ranges
{
protected:
std::vector<Range> ranges;
public:
friend std::ostream& operator<< (std::ostream&, const Ranges&);
friend std::istream& operator>> (std::istream&, Ranges&);
bool within (double x) const;
};
#endif // !__Ranges_H
| 23.074074 | 77 | 0.55939 | [
"vector"
] |
fabbd36cb6509f492735e0e95e3836a5914f9aee | 1,051 | h | C | onnxruntime/core/providers/cpu/tensor/copy.h | asamadiya/onnxruntime | 6b3645d97ab222d28bd515f4990af8868194eb52 | [
"MIT"
] | 1 | 2020-06-18T01:35:31.000Z | 2020-06-18T01:35:31.000Z | onnxruntime/core/providers/cpu/tensor/copy.h | asamadiya/onnxruntime | 6b3645d97ab222d28bd515f4990af8868194eb52 | [
"MIT"
] | 19 | 2021-08-21T08:43:10.000Z | 2022-03-18T21:52:45.000Z | onnxruntime/core/providers/cpu/tensor/copy.h | asamadiya/onnxruntime | 6b3645d97ab222d28bd515f4990af8868194eb52 | [
"MIT"
] | 3 | 2019-01-08T12:19:04.000Z | 2020-05-09T21:33:12.000Z | #include "core/providers/common.h"
#include "core/platform/threadpool.h"
#include <vector>
namespace onnxruntime {
void CoalesceDimensions(
std::initializer_list<std::reference_wrapper<std::vector<int64_t>>>&& tensors_strides, std::vector<int64_t>& shape);
Status DispatchStridedCopy(concurrency::ThreadPool* thread_pool,
Tensor& dst,
std::ptrdiff_t dst_offset,
const std::vector<int64_t> dst_strides,
const TensorShape& copy_shape,
const Tensor& src,
const std::vector<int64_t> src_strides);
template <typename T>
void StridedCopy(concurrency::ThreadPool* thread_pool,
T* dst,
const std::vector<int64_t>& dst_strides,
const TensorShape& copy_shape,
const T* src,
const std::vector<int64_t>& src_strides);
std::vector<int64_t> StridesForTensor(const Tensor& tensor);
} // namespace onnxruntime
| 37.535714 | 120 | 0.600381 | [
"shape",
"vector"
] |
fabc7b048893cb78a57424e98b9c044086d6abe6 | 605 | h | C | src/nvilidar/nvilidar_filter.h | nvilidar/nvilidar_sdk | a2a323ba89fd04396341e4699a5ce743f12113af | [
"BSD-3-Clause"
] | null | null | null | src/nvilidar/nvilidar_filter.h | nvilidar/nvilidar_sdk | a2a323ba89fd04396341e4699a5ce743f12113af | [
"BSD-3-Clause"
] | 1 | 2021-11-22T06:44:48.000Z | 2021-12-09T02:53:01.000Z | sdk/src/nvilidar/nvilidar_filter.h | nvilidar/nvilidar_ros | dc03c44e581cb328f6dbdd23f63344c0e6a73d4b | [
"BSD-3-Clause"
] | null | null | null | #pragma once
#include "nvilidar_def.h"
#include "nvilidar_protocol.h"
//---定义库信息 VS系列的生成库文件
#ifdef WIN32
#define NVILIDAR_FILTER_API __declspec(dllexport)
#else
#define NVILIDAR_FILTER_API
#endif // ifdef WIN32
namespace nvilidar
{
//lidar driver
class NVILIDAR_FILTER_API LidarFilter
{
public:
LidarFilter();
~LidarFilter();
void LidarFilterLoadPara(Nvilidar_UserConfigTypeDef cfg); //加载参数信息
void LidarJumpFilter(std::vector<Nvilidar_Node_Info> &in); //跳动点过滤
private:
Nvilidar_UserConfigTypeDef lidar_cfg; //雷达型号
};
}
| 20.166667 | 72 | 0.687603 | [
"vector"
] |
fac8353c466487135bfd03c96c855e5b432b2dab | 9,610 | h | C | ray_tracing__advance/hello_vulkan.h | enomis101/vk_raytracing_tutorial_KHR | 945fd67bc0786c2cb03c407b4e8ae8f7c985e494 | [
"Apache-2.0"
] | null | null | null | ray_tracing__advance/hello_vulkan.h | enomis101/vk_raytracing_tutorial_KHR | 945fd67bc0786c2cb03c407b4e8ae8f7c985e494 | [
"Apache-2.0"
] | null | null | null | ray_tracing__advance/hello_vulkan.h | enomis101/vk_raytracing_tutorial_KHR | 945fd67bc0786c2cb03c407b4e8ae8f7c985e494 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (c) 2014-2021, NVIDIA CORPORATION. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-FileCopyrightText: Copyright (c) 2014-2021 NVIDIA CORPORATION
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "nvvk/appbase_vk.hpp"
#include "nvvk/debug_util_vk.hpp"
#include "nvvk/resourceallocator_vk.hpp"
#include "shaders/host_device.h"
// #VKRay
#include "nvvk/raytraceKHR_vk.hpp"
#include "offscreen.hpp"
#include "obj.hpp"
#include "raytrace.hpp"
#include <memory>
// Choosing the allocator to use
#define ALLOC_DMA
//#define ALLOC_DEDICATED
//#define ALLOC_VMA
#include <nvvk/resourceallocator_vk.hpp>
#if defined(ALLOC_DMA)
#include <nvvk/memallocator_dma_vk.hpp>
using Allocator = nvvk::ResourceAllocatorDma;
#elif defined(ALLOC_VMA)
#include <nvvk/memallocator_vma_vk.hpp>
using Allocator = nvvk::ResourceAllocatorVma;
#else
using Allocator = nvvk::ResourceAllocatorDedicated;
#endif
//--------------------------------------------------------------------------------------------------
// Simple rasterizer of OBJ objects
// - Each OBJ loaded are stored in an `ObjModel` and referenced by a `ObjInstance`
// - It is possible to have many `ObjInstance` referencing the same `ObjModel`
// - Rendering is done in an offscreen framebuffer
// - The image of the framebuffer is displayed in post-process in a full-screen quad
//
class HelloVulkan : public nvvk::AppBaseVk
{
public:
HelloVulkan();
void setup(const VkInstance& instance, const VkDevice& device, const VkPhysicalDevice& physicalDevice, uint32_t queueFamily) override;
void createDescriptorSetLayout();
void createGraphicsPipeline();
void loadModel(const std::string& filename, nvmath::mat4f transform = nvmath::mat4f(1));
void updateDescriptorSet();
void createUniformBuffer();
void createObjDescriptionBuffer();
void createTextureImages(const VkCommandBuffer& cmdBuf, const std::vector<std::string>& textures);
void updateUniformBuffer(const VkCommandBuffer& cmdBuf);
void onResize(int /*w*/, int /*h*/) override;
void destroyResources();
void rasterize(const VkCommandBuffer& cmdBuff);
Offscreen& offscreen() { return m_offscreen; }
Raytracer& raytracer() { return m_raytrace; }
// Information pushed at each draw call
PushConstantRaster m_pcRaster;
// Array of objects and instances in the scene
std::vector<ObjModel> m_objModel; // Model on host
std::vector<ObjDesc> m_objDesc; // Model description for device access
std::vector<ObjInstance> m_instances; // Scene model instances
// Graphic pipeline
VkPipelineLayout m_pipelineLayout;
VkPipeline m_graphicsPipeline;
nvvk::DescriptorSetBindings m_descSetLayoutBind;
VkDescriptorPool m_descPool;
VkDescriptorSetLayout m_descSetLayout;
VkDescriptorSet m_descSet;
int m_maxFrames{50};
void resetFrame();
void updateFrame();
std::string m_saveFile = "SaveScene.txt";
void saveScene();
void loadScene();
std::vector<Light> lights{ NUM_LIGHTS };
nvvk::Buffer m_bGlobals; // Device-Host of the camera matrices
nvvk::Buffer m_bObjDesc; // Device buffer of the OBJ descriptions
std::vector<nvvk::Texture> m_textures; // vector of all textures of the scene
Allocator m_alloc; // Allocator for buffer, images, acceleration structures
nvvk::DebugUtil m_debug; // Utility to name objects
// #Post
Offscreen m_offscreen;
void initOffscreen();
// #VKRay
Raytracer m_raytrace;
void initRayTracing();
void raytrace(const VkCommandBuffer& cmdBuf, const nvmath::vec4f& clearColor);
// Implicit
ImplInst m_implObjects;
void addImplSphere(nvmath::vec3f center, float radius, int matId);
void addImplCube(nvmath::vec3f minumum, nvmath::vec3f maximum, int matId);
void addImplMaterial(const MaterialObj& mat);
void createImplictBuffers();
void modifyObjTransform();
};
#include <memory>
#include <string>
#include <stdexcept>
template <typename... Args>
std::string string_format(const std::string& format, Args... args)
{
int size_s = std::snprintf(nullptr, 0, format.c_str(), args...) + 1; // Extra space for '\0'
if(size_s <= 0)
{
throw std::runtime_error("Error during formatting.");
}
auto size = static_cast<size_t>(size_s);
auto buf = std::make_unique<char[]>(size);
std::snprintf(buf.get(), size, format.c_str(), args...);
return std::string(buf.get(), buf.get() + size - 1); // We don't want the '\0' inside
}
class TestSampleSphere
{
public:
static void CoordinateSystem(const nvmath::vec3f& v1, nvmath::vec3f& v2, nvmath::vec3f& v3);
static bool TestHandedness(const nvmath::vec3f& v1, const nvmath::vec3f& v2, const nvmath::vec3f& v3);
static void Test();
static std::string ToString(const nvmath::vec3f& v1)
{
std::string str;
return string_format("[ %f, %f, %f]", v1.x, v1.y, v1.z);
}
static std::string ToString(const nvmath::mat3f& m)
{
std::string str;
return string_format("| %f, %f, %f|\n| %f, %f, %f|\n| %f, %f, %f|", m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2]);
}
static vec3 Reflect(const nvmath::vec3f& wo, const nvmath::vec3f& n) {
return -wo + 2.f * dot(wo, n) * n;
}
static void TestReflectVector();
#define Spectrum vec3
// BSDF Declarations
const uint BSDF_REFLECTION = 1 << 0;
const uint BSDF_TRANSMISSION = 1 << 1;
const uint BSDF_DIFFUSE = 1 << 2;
const uint BSDF_GLOSSY = 1 << 3;
const uint BSDF_SPECULAR = 1 << 4;
const uint BSDF_ALL = BSDF_DIFFUSE | BSDF_GLOSSY | BSDF_SPECULAR | BSDF_REFLECTION |
BSDF_TRANSMISSION;
const uint BXDF_LAMBERTIAN_REFLECTION = 1;
struct BSDF
{
uint reflectionType;
uint bxdf;
WaveFrontMaterial mat;
mat4 worldToLocal;
mat4 localToWorld;
};
struct SurfaceInteraction
{
vec3 p;
vec3 wo;
vec3 n;
BSDF bsdf;
};
struct SphereAreaLight
{
vec3 position;
mat4 transform;
float radius;
float intensity;
};
//UTILITY
float absCosTheta( vec3 v)
{
return std::abs(v.z);
}
static bool sameHemisphere( vec3 v1, vec3 v2) {
return v1.z * v2.z > 0;
}
vec2 concentricSampleDisk( vec2 u) {
// Map uniform random numbers to $[-1,1]^2$
vec2 uOffset = 2.f * u - vec2(1, 1);
// Handle degeneracy at the origin
if (uOffset.x == 0 && uOffset.y == 0) return vec2(0, 0);
// Apply concentric mapping to point
float theta, r;
if (abs(uOffset.x) > abs(uOffset.y)) {
r = uOffset.x;
theta = PI_OVER4 * (uOffset.y / uOffset.x);
}
else {
r = uOffset.y;
theta = PI_OVER2 - PI_OVER4 * (uOffset.x / uOffset.y);
}
return r * vec2(cos(theta), sin(theta));
}
vec3 cosineSampleHemisphere( vec2 u) {
vec2 d = concentricSampleDisk(u);
float z = sqrt(std::max(0.f, 1 - d.x * d.x - d.y * d.y));
return vec3(d.x, d.y, z);
}
//BSDF FUNCTIONS
Spectrum getBSDFValue( BSDF bsdf, vec3 woW, vec3 wiW)
{
Spectrum f;
//transform woW, wiW to local Coordinates
vec3 wo = vec3(bsdf.worldToLocal * vec4(woW, 0.f));
vec3 wi = vec3(bsdf.worldToLocal * vec4(wiW, 0.f));
Spectrum r = bsdf.mat.diffuse;
f = r * INV_PI;
}
float getBSDFPdf( BSDF bsdf, vec3 woW, vec3 wiW)
{
float pdf;
//transform woW, wiW to local Coordinates
vec3 wo = vec3(bsdf.worldToLocal * vec4(woW, 0.f));
vec3 wi = vec3(bsdf.worldToLocal * vec4(wiW, 0.f));
pdf = sameHemisphere(wo, wi) ? absCosTheta(wi) * INV_PI : 0;
return pdf;
}
Spectrum sampleBSDF( BSDF bsdf, vec3 woW, vec2 u, vec3 wiW, float pdf)
{
Spectrum f;
//transform woW, wiW to local Coordinates
vec3 wo = vec3(bsdf.worldToLocal * vec4(woW, 0.f));
vec3 wi;
// Cosine-sample the hemisphere, flipping the direction if necessary
// to make sure wi and wo are on the same hemisphere
wi = cosineSampleHemisphere(u);
if (wo.z < 0)
{
wi.z *= -1;
}
pdf = getBSDFPdf(bsdf, wo, wi);
f = getBSDFValue(bsdf, wo, wi);
wiW = vec3(bsdf.localToWorld * vec4(wi, 0.f));
return f;
}
static void testRandom();
//RANDOM
// Generate a random unsigned int from two unsigned int values, using 16 pairs
// of rounds of the Tiny Encryption Algorithm. See Zafar, Olano, and Curtis,
// "GPU Random Numbers via the Tiny Encryption Algorithm"
static uint tea(uint val0, uint val1)
{
uint v0 = val0;
uint v1 = val1;
uint s0 = 0;
for (uint n = 0; n < 16; n++)
{
s0 += 0x9e3779b9;
v0 += ((v1 << 4) + 0xa341316c) ^ (v1 + s0) ^ ((v1 >> 5) + 0xc8013ea4);
v1 += ((v0 << 4) + 0xad90777d) ^ (v0 + s0) ^ ((v0 >> 5) + 0x7e95761e);
}
return v0;
}
// Generate a random unsigned int in [0, 2^24) given the previous RNG state
// using the Numerical Recipes linear congruential generator
static uint lcg(uint& prev)
{
uint LCG_A = 1664525u;
uint LCG_C = 1013904223u;
prev = (LCG_A * prev + LCG_C);
return prev & 0x00FFFFFF;
}
// Generate a random float in [0, 1) given the previous RNG state
static float rnd(uint& prev)
{
return (float(lcg(prev)) / float(0x01000000));
}
}; | 28.181818 | 152 | 0.671488 | [
"vector",
"model",
"transform"
] |
facca3bf5e2d8c469a71c63c1e7b62ccdb3e5269 | 5,240 | h | C | afl/random.h | sandialabs/wafl | 8be5cfe782d2da88167f9d8c1425ae729c15afa9 | [
"Apache-2.0",
"BSD-2-Clause"
] | 2 | 2021-10-09T14:09:29.000Z | 2022-02-09T01:56:25.000Z | afl/random.h | sandialabs/wafl | 8be5cfe782d2da88167f9d8c1425ae729c15afa9 | [
"Apache-2.0",
"BSD-2-Clause"
] | null | null | null | afl/random.h | sandialabs/wafl | 8be5cfe782d2da88167f9d8c1425ae729c15afa9 | [
"Apache-2.0",
"BSD-2-Clause"
] | 1 | 2021-09-28T20:17:40.000Z | 2021-09-28T20:17:40.000Z | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "alloc-inl.h"
#include "config.h"
#include "types.h"
#include "debug.h"
struct alias {
u8* fname; /* File name for the weight vector */
u32 length; /* length of {alias,prob}_table */
u32* alias_table; /* the actual alias table */
u32* prob_table; /* the actual probability table */
};
/* undefine to revert to standard UR() behavior */
#define ALIAS_USE_TABLES
/* some additional safety checks */
#define ALIAS_DO_CHECKS
/* stop rolling random numbers after this many tries */
#define ALIAS_MAX_RETRIES 5
#define ALIAS_THRESHOLD 32
// The probabilities in the probability table will be scaled from a float [0,1)
// to an integer [0,ALIAS_MAX). Thus, (1./ALIAS_MAX) becomes our maximum
// precision and RAND_MAX needs to be at least as large as ALIAS_MAX. Needs to
// match the value in dist2alias.py.
#define ALIAS_MAX (unsigned)(1<<30)
_Static_assert(RAND_MAX >= ALIAS_MAX, "RAND_MAX needs to be bigger than ALIAS_MAX");
extern s32 dev_urandom_fd;
extern u32 rand_cnt;
/* Generate a random number (from 0 to limit - 1). This may
have slight bias. */
static inline u32 UR(u32 limit) {
if (unlikely(!rand_cnt--)) {
u32 seed[2];
ck_read(dev_urandom_fd, &seed, sizeof(seed), "/dev/urandom");
srandom(seed[0]);
rand_cnt = (RESEED_RNG / 2) + (seed[1] % RESEED_RNG);
#if 0
printf("reseeding! next reseed: %d\n", rand_cnt);
#endif
}
return random() % limit;
}
/* Generate a random number according to the given alias table. This
is a fast method for picking random numbers according to an
arbitrary non-uniform distribution. For details see:
* http://keithschwarz.com/darts-dice-coins/
* https://lips.cs.princeton.edu/the-alias-method-efficient-sampling-with-many-discrete-outcomes/
* https://github.com/asmith26/Vose-Alias-Method/
*/
static inline u32 UR_alias(u32 table_length, u32* alias_table, u32* prob_table) {
// determine which column of prob_table to inspect
#if 1
u32 col = UR(table_length);
#else
// This code fixes a slight bias when using "random()%limit". I think the
// bias is small enough for the small buffer size (relative to ALIAS_MAX) to
// not matter so sticking with the faster version for now.
u32 col;
u32 threshold = table_length*(RAND_MAX/table_length);
do {
col = random();
} while(col >= threshold);
col = col % table_length;
#endif
// determine which outcome to pick in that column
if(UR(ALIAS_MAX) <= prob_table[col])
return col;
else
return alias_table[col];
}
/* Update the alias and probability tables. Will allocate new tables if necessary. */
static void update_alias_table(char* fname, u32* table_length, u32** alias_table, u32** prob_table) {
s32 fd = open(fname, O_RDONLY);
if (fd < 0) {
/* fail if we can't read the file and we don't have a table length */
if(!*table_length) PFATAL("Unable to open '%s'", fname);
u32 len = *table_length * sizeof(u32);
/* alloc and init alias table if necessary */
if(!*alias_table) {
*alias_table = ck_alloc(len);
/* initialize table to uniform */
for(u32 i = 0; i < *table_length; i++) { (*alias_table)[i] = i; }
}
/* alloc and init probability table if necessary */
if(!*prob_table) {
*prob_table = ck_alloc(len);
for(u32 i = 0; i < *table_length; i++) { (*prob_table)[i] = 0; }
}
} else {
u32 new_length;
ck_read(fd, &new_length, sizeof(new_length), fname);
if(*table_length && new_length != *table_length)
FATAL("length of alias table in '%s' changed from %d to %d", fname, *table_length, new_length);
u32 len = new_length * sizeof(u32);
if(!*alias_table) *alias_table = ck_alloc(len);
if(!*prob_table) *prob_table = ck_alloc(len);
ck_read(fd, *alias_table, len, fname);
ck_read(fd, *prob_table, len, fname);
close(fd);
*table_length = new_length;
}
}
/* Helper function to calculate a random number according to the given alias
table. */
#ifndef ALIAS_USE_TABLES
static inline u32 URa(u32 limit, struct alias* alias) {
(void)(alias);
return UR(limit);
}
#else
static inline u32 URa(u32 limit, struct alias* alias) {
u32 ret;
u32 retries = ALIAS_MAX_RETRIES;
#ifdef ALIAS_DO_CHECKS
if(!alias) FATAL("alias table is NULL");
if(limit > alias->length) FATAL("alias table lengths got messed up");
#endif
/* Skip the alias code on small buffers. This makes it less likely that we
will do a bunch of retries trying to hit a single value in a small buffer. */
if(limit < ALIAS_THRESHOLD) return UR(limit);
do {
ret = UR_alias(alias->length, alias->alias_table, alias->prob_table);
} while(ret >= limit && (--retries) > 0);
#if 0
if(ret >= limit) FATAL("reached max retries");
#endif
/* fallback behavior */
if(ret >= limit) return UR(limit);
return ret;
}
#endif
| 28.172043 | 107 | 0.64542 | [
"vector"
] |
fadea24877776ccca1f2b11c7a01a2148f2bc635 | 4,064 | h | C | src/PostProcessor.h | crocs-muni/oneclick | 30504a6bcb1b07d94f3875d4a219f41191bcaad1 | [
"MIT"
] | 1 | 2019-02-10T00:02:46.000Z | 2019-02-10T00:02:46.000Z | src/PostProcessor.h | DalavanCloud/oneclick | 30504a6bcb1b07d94f3875d4a219f41191bcaad1 | [
"MIT"
] | 10 | 2016-03-01T16:54:09.000Z | 2016-06-26T18:21:29.000Z | src/PostProcessor.h | DalavanCloud/oneclick | 30504a6bcb1b07d94f3875d4a219f41191bcaad1 | [
"MIT"
] | 1 | 2019-02-10T00:02:37.000Z | 2019-02-10T00:02:37.000Z | #ifndef POSTPROCESSOR_H
#define POSTPROCESSOR_H
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
/** Class for storing result of single batch. Used by PostProcessors.
*/
class Score {
private:
//Algorithm name - usually in format Project: Algorithm - N rounds
std::string algName;
//Number of jobs processed
int jobCount = 0;
//Result value
float val = 0;
public:
/** Sets attribute algName.
* @param a will be algName
*/
void setAlgName(std::string a) { algName = a; }
/** Sets attribute val.
* @param s will be val
*/
void setVal(float s) { val = s; }
/** Sets number of jobs processed in batch.
* @jc number of jobs processed in batch
*/
void setJobCount(int jc) { jobCount = jc; }
/** Returns val in string format. Fixed 6 decimal points.
* @return val in string
*/
std::string valToString() {
if (val == ERROR_NO_VALID_FILES) return "no valid results";
std::stringstream valSStr;
valSStr << std::setprecision(6);
valSStr << std::fixed;
valSStr << val;
return valSStr.str();
}
/** Returns formatted string, contains algname jobCount val.
* @return formatted result
*/
std::string toString() {
std::stringstream result;
result << std::setw(60);
result << std::left;
result << algName;
result << std::setw(5);
result << std::right;
result << jobCount;
result << std::setw(10);
result << std::left;
result << " runs";
result << std::setprecision(6);
result << std::fixed;
if(val == ERROR_NO_VALID_FILES) {
result << "no valid results";
} else {
result << val;
}
return result.str();
}
};
/** Interface for result post-processors. Stores results, calculates values,
* creates result files. Used in class ResultProcessor.
*/
class PostProcessor {
protected:
std::string batchDirPath;
std::string batchName;
//Stores results of all processed batches. Is dumped to file at the end of processing
std::vector<Score> scores;
public:
virtual ~PostProcessor() {}
/** Sets directory of batch that is being processed.
* @param path full path to batch directory
Have to end with directory separator!
*/
void setBatchDirectoryPath(std::string path) { batchDirPath = path; }
/** Sets name of batch that is currently processed. This name should be
* human-readable and used in result files to identify batch.
* @param name name of the batch
*/
void setBatchName(std::string name) { batchName = name; }
/** Returns last added batch score. Used for saving batch results into batch logs.
*/
Score getLastScore() { return scores.back(); }
/** Add directory to process in current batch. Argument is
* path to directory with results of single workunit. In there
* you can process all files you need.
* @param path path to directory with wu results
* @return success true on success, false if files are not
* in valid format (too many results, etc...)
*/
virtual bool process(std::string path) = 0;
/** Called at end of work with single batch, when all wu directories
* are processed. Should store result from the batch, generate batch-specific files
* and erase all other results. Same instance will be then used on another batches.
* Erase batchDirPath and batchName.
*/
virtual void calculateBatchResults() = 0;
/** Called at the end of processing of results. All batches are processed,
* should generate file(s) with global results for all workunits. PostProcessor won't
* be used after calling this method.
*/
virtual void saveResults() = 0;
};
#endif //POSTPROCESSOR_H
| 32.253968 | 90 | 0.608268 | [
"vector"
] |
fadfbfd4727df6d86df95ef6fd9fdb04802cc8fa | 4,797 | h | C | win/win_cli_args.h | dbj-data/dbj-fwk | 88e276e8973b7412c3d50b275ab457ab98f88bc5 | [
"BSD-3-Clause"
] | null | null | null | win/win_cli_args.h | dbj-data/dbj-fwk | 88e276e8973b7412c3d50b275ab457ab98f88bc5 | [
"BSD-3-Clause"
] | null | null | null | win/win_cli_args.h | dbj-data/dbj-fwk | 88e276e8973b7412c3d50b275ab457ab98f88bc5 | [
"BSD-3-Clause"
] | null | null | null | #pragma once
#include "windows_includer.h"
#include "dbj_start_stop.h"
#pragma warning( push )
#pragma warning( disable : 26451 )
#pragma warning( disable : 28182 )
#ifdef __cplusplus
extern "C" {
#endif
/*
* http://alter.org.ua/docs/win/args/
*
* for some reason it is not on MS DOCS any more
* and not in Win32 any more
*/
// http://alter.org.ua/docs/win/args/
inline PCHAR*
CommandLineToArgvA(
PCHAR CmdLine,
int* _argc
)
{
PCHAR* argv = NULL;
PCHAR _argv = NULL;
ULONG len = 0UL;
ULONG argc = 0UL;
CHAR a = 0;
ULONG i = 0UL, j = 0UL;
BOOLEAN in_QM = FALSE;
BOOLEAN in_TEXT = FALSE;
BOOLEAN in_SPACE = FALSE;
len = (ULONG)strlen(CmdLine);
i = ((len + 2UL) / 2) * sizeof(PVOID) + sizeof(PVOID);
argv = (PCHAR*)LocalAlloc(GMEM_FIXED,
i + (len + 2UL) * sizeof(CHAR));
_argv = (PCHAR)(((PUCHAR)argv) + i);
argc = 0;
argv[argc] = _argv;
in_QM = FALSE;
in_TEXT = FALSE;
in_SPACE = TRUE;
i = 0;
j = 0;
while ((a = CmdLine[i])) {
if (in_QM) {
if (a == '\"') {
in_QM = FALSE;
}
else {
_argv[j] = a;
j++;
}
}
else {
switch (a) {
case '\"':
in_QM = TRUE;
in_TEXT = TRUE;
if (in_SPACE) {
argv[argc] = _argv + j;
argc++;
}
in_SPACE = FALSE;
break;
case ' ':
case '\t':
case '\n':
case '\r':
if (in_TEXT) {
_argv[j] = '\0';
j++;
}
in_TEXT = FALSE;
in_SPACE = TRUE;
break;
default:
in_TEXT = TRUE;
if (in_SPACE) {
argv[argc] = _argv + j;
argc++;
}
_argv[j] = a;
j++;
in_SPACE = FALSE;
break;
}
}
i++;
}
_argv[j] = '\0';
argv[argc] = NULL;
(*_argc) = argc;
return argv;
}
#pragma warning( pop )
#ifdef __cplusplus
} // "C"
#endif // __cplusplus
namespace dbj {
//---------------------------------------------------------------------
namespace {
namespace detail {
struct app_args_ final {
int argc;
char** argv;
};
}
inline detail::app_args_ app_cli_args = { 0,0 };
inline void* harvest_app_args_(void*)
{
if (app_cli_args.argc < 1) {
app_cli_args.argv =
CommandLineToArgvA(
GetCommandLineA(), &app_cli_args.argc
);
}
_ASSERTE(app_cli_args.argc > 0);
return 0;
}
inline void* free_app_args_(void*)
{
if (app_cli_args.argc > 0) {
LocalFree(app_cli_args.argv);
app_cli_args.argc = 0;
}
return 0;
}
inline dbj::start_stop< harvest_app_args_, free_app_args_> cli_args_guardian_;
}
// arguments parsing/handling signals
enum class app_args_result { proceed, stop };
inline app_args_result app_args_stop(const char*) { return app_args_result::stop; }
inline app_args_result app_args_proceed(const char*) { return app_args_result::proceed; }
/*
if arg not found return proceed
otherwise return callback result
note: this model does check only for arguments , not for arguments and their values
"+help" will match
"+help=whatever" will NOT match
*/
inline app_args_result app_args_callback_(const char arg_name[], app_args_result(*callb_)(const char*))
{
// DBJ TODO: conditional MT lock here
// must have more than 0 args
DBJ_VERIFY(app_cli_args.argc > 0);
if (app_cli_args.argc < 2)
return app_args_result::proceed;
size_t arg_name_len = strnlen_s(arg_name, 0xFF);
DBJ_VERIFY(arg_name_len);
// start from 1
for (int index = 1; index < app_cli_args.argc; ++index)
{
if (0 == strncmp(app_cli_args.argv[index], arg_name, arg_name_len)) {
// argument is found
DBJ_VERIFY((void*)callb_);
return callb_(arg_name);
}
}
return app_args_result::proceed;
}
#if 0
namespace win {
//---------------------------------------------------------------------
// this is simpler but each instance will make a copy of cli args
struct cli_args final
{
int argc{};
char** argv{};
~cli_args() noexcept {
if (argv != 0) {
::LocalFree(argv);
argc = 0;
argv = nullptr;
if (app_cli_args.argc < 1) {
app_cli_args.argc = 0;
app_cli_args.argv = nullptr;
}
}
}
// NOTE: rezult of GetCommandLineA() must NOT be freed
// NOTE: rezult of CommandLineToArgvA() must be freed
cli_args() noexcept : argv(
CommandLineToArgvA(
::GetCommandLineA(), &argc
)
)
{
if (app_cli_args.argc < 1) {
// populate the C struct above
app_cli_args.argc = this->argc;
app_cli_args.argv = this->argv;
}
}
// no copy
cli_args(cli_args const&) = delete;
cli_args& operator = (cli_args const&) = delete;
// no move
cli_args(cli_args&&) = delete;
cli_args& operator = (cli_args&&) = delete;
}; // cli_args
inline cli_args command_line_{};
}
} // dbj::win
#endif // 0
} // dbj
| 19.659836 | 104 | 0.585157 | [
"model"
] |
fae1f0eb9c4d3e79d9c6cba2d38cb8891ed8bb72 | 880 | h | C | src/sgmwcs/include/primal_heuristic.h | ctlab/rmwcs | 354d47304e0d605906037fb6c6285363e1b34fba | [
"Apache-2.0"
] | 7 | 2017-09-06T09:55:00.000Z | 2022-02-25T03:57:13.000Z | src/sgmwcs/include/primal_heuristic.h | ctlab/rmwcs | 354d47304e0d605906037fb6c6285363e1b34fba | [
"Apache-2.0"
] | 2 | 2021-11-14T00:58:01.000Z | 2021-11-21T14:46:17.000Z | src/sgmwcs/include/primal_heuristic.h | ctlab/rmwcs | 354d47304e0d605906037fb6c6285363e1b34fba | [
"Apache-2.0"
] | 2 | 2020-10-18T02:23:30.000Z | 2021-12-21T10:55:05.000Z | //
// Created by Alexander Loboda on 9/15/21.
//
#ifndef MWCSR_PRIMAL_HEURISTIC_H
#define MWCSR_PRIMAL_HEURISTIC_H
#include "../../include/graph.h"
#include "solution.h"
#include <functional>
#include <unordered_set>
namespace relax {
class PrimalHeuristic {
mwcsr::Graph g;
std::function<double(size_t)> weight;
std::vector<size_t> active;
std::vector<bool> current;
std::unordered_map<size_t, size_t> visit;
std::unordered_map<size_t, double> shortest_distance;
std::unordered_map<size_t, int> previous;
size_t iteration = 0;
Solution best;
public:
PrimalHeuristic(mwcsr::Graph g, std::function<double(size_t)> wf, std::vector<size_t> active,
std::vector<bool> current);
Solution run_heuristic();
private:
void run_from_point(size_t e);
double wei(size_t e);
};
}
#endif //MWCSR_PRIMAL_HEURISTIC_H
| 22.564103 | 97 | 0.697727 | [
"vector"
] |
fae8d570a2d3e6693657d7104c6cf63637768a6a | 2,569 | h | C | 3party/gtk+-3.12.1/modules/input/gtkimcontextthai.h | kongaraju/antkorp | 3453d543d659e3420d5bc4b536016bb1d097d7ec | [
"CC-BY-3.0",
"Apache-2.0"
] | 1 | 2016-01-02T14:39:07.000Z | 2016-01-02T14:39:07.000Z | 3party/gtk+-3.12.1/modules/input/gtkimcontextthai.h | kongaraju/antkorp | 3453d543d659e3420d5bc4b536016bb1d097d7ec | [
"CC-BY-3.0",
"Apache-2.0"
] | 4 | 2019-12-20T06:13:24.000Z | 2021-07-03T16:28:18.000Z | 3party/gtk+-3.12.1/modules/input/gtkimcontextthai.h | kongaraju/antkorp | 3453d543d659e3420d5bc4b536016bb1d097d7ec | [
"CC-BY-3.0",
"Apache-2.0"
] | 2 | 2015-09-17T16:40:10.000Z | 2016-11-17T15:56:42.000Z | /* GTK - The GIMP Toolkit
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Author: Theppitak Karoonboonyanan <thep@linux.thai.net>
*
*/
#ifndef __GTK_IM_CONTEXT_THAI_H__
#define __GTK_IM_CONTEXT_THAI_H__
#include <gtk/gtk.h>
G_BEGIN_DECLS
extern GType gtk_type_im_context_thai;
#define GTK_TYPE_IM_CONTEXT_THAI (gtk_type_im_context_thai)
#define GTK_IM_CONTEXT_THAI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_IM_CONTEXT_THAI, GtkIMContextThai))
#define GTK_IM_CONTEXT_THAI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_IM_CONTEXT_THAI, GtkIMContextThaiClass))
#define GTK_IS_IM_CONTEXT_THAI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_IM_CONTEXT_THAI))
#define GTK_IS_IM_CONTEXT_THAI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_IM_CONTEXT_THAI))
#define GTK_IM_CONTEXT_THAI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_IM_CONTEXT_THAI, GtkIMContextThaiClass))
typedef struct _GtkIMContextThai GtkIMContextThai;
typedef struct _GtkIMContextThaiClass GtkIMContextThaiClass;
typedef enum
{
ISC_PASSTHROUGH,
ISC_BASICCHECK,
ISC_STRICT
} GtkIMContextThaiISCMode;
#define GTK_IM_CONTEXT_THAI_BUFF_SIZE 2
struct _GtkIMContextThai
{
GtkIMContext object;
#ifndef GTK_IM_CONTEXT_THAI_NO_FALLBACK
gunichar char_buff[GTK_IM_CONTEXT_THAI_BUFF_SIZE];
#endif /* !GTK_IM_CONTEXT_THAI_NO_FALLBACK */
GtkIMContextThaiISCMode isc_mode;
};
struct _GtkIMContextThaiClass
{
GtkIMContextClass parent_class;
};
void gtk_im_context_thai_register_type (GTypeModule *type_module);
GtkIMContext *gtk_im_context_thai_new (void);
GtkIMContextThaiISCMode
gtk_im_context_thai_get_isc_mode (GtkIMContextThai *context_thai);
GtkIMContextThaiISCMode
gtk_im_context_thai_set_isc_mode (GtkIMContextThai *context_thai,
GtkIMContextThaiISCMode mode);
G_END_DECLS
#endif /* __GTK_IM_CONTEXT_THAI_H__ */
| 33.802632 | 128 | 0.789412 | [
"object"
] |
faecd383600e7f937bdbbcebcf8c9a4528481464 | 753 | h | C | include/canvas/renderer/immediate_renderer.h | fizixx/canvas | 697974249027deac449fa1aaa7516e6d773509a1 | [
"MIT"
] | 6 | 2015-08-26T20:14:43.000Z | 2021-05-01T18:32:58.000Z | include/canvas/renderer/immediate_renderer.h | fizixx/canvas | 697974249027deac449fa1aaa7516e6d773509a1 | [
"MIT"
] | null | null | null | include/canvas/renderer/immediate_renderer.h | fizixx/canvas | 697974249027deac449fa1aaa7516e6d773509a1 | [
"MIT"
] | 1 | 2017-06-27T07:23:34.000Z | 2017-06-27T07:23:34.000Z | #pragma once
#include "canvas/renderer/immediate_mesh.h"
#include "canvas/renderer/types.h"
#include "canvas/utils/color.h"
#include "floats/mat4.h"
#include "floats/vec3.h"
#include "nucleus/containers/dynamic_array.h"
#include "nucleus/macros.h"
namespace ca {
class Renderer;
class ImmediateRenderer {
NU_DELETE_COPY(ImmediateRenderer);
public:
explicit ImmediateRenderer(Renderer* renderer);
~ImmediateRenderer();
NU_DEFAULT_MOVE(ImmediateRenderer);
NU_NO_DISCARD ImmediateMesh& create_mesh(DrawType draw_type,
const fl::Mat4& transform = fl::Mat4::identity);
void submit_to_renderer();
private:
Renderer* renderer_;
nu::DynamicArray<ImmediateMesh> meshes_;
};
} // namespace ca
| 21.514286 | 91 | 0.722444 | [
"transform"
] |
782d69cdb869d23af8c78f5768d818b0efdade41 | 923 | h | C | enemymanager.h | Jmeggesto/Glamour | 82244adeb91fa882fb8cfbafe74e6fd4bea876a3 | [
"MIT"
] | null | null | null | enemymanager.h | Jmeggesto/Glamour | 82244adeb91fa882fb8cfbafe74e6fd4bea876a3 | [
"MIT"
] | null | null | null | enemymanager.h | Jmeggesto/Glamour | 82244adeb91fa882fb8cfbafe74e6fd4bea876a3 | [
"MIT"
] | null | null | null | #ifndef ENEMY_MANAGER_H
#define ENEMY_MANAGER_H
#include "gameworld.h"
#include "scoreboard.h"
#include <vector>
namespace glamour {
class EnemyManager {
public:
EnemyManager(GameWorld& world, Context& ctxt, Scoreboard& sboard);
~EnemyManager();
void shoot(Window* origin);
void updateEntities(double delta_time);
void refreshEntities();
private:
GameWorld& gameWorld;
Context& factory;
Scoreboard& board;
Window* projectile = nullptr;
std::vector<Window*> entities;
Rect* rect = nullptr;
const int enemy_rows = 5;
const int enemy_columns = 11;
const int enemy_width = 7;
const int enemy_height = 3;
const int enemy_spacingX = 3;
const int enemy_spacingY = 1;
double x_velocity = 2.0;
void calculateProjectile(double dtime);
bool checkHit();
void removeEntity(Window* entity);
};
} //namespace glamour
#endif
| 17.75 | 70 | 0.67714 | [
"vector"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.