power-grid-model 1.10.17__py3-none-win_amd64.whl → 1.12.119__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of power-grid-model might be problematic. Click here for more details.
- power_grid_model/__init__.py +54 -29
- power_grid_model/_core/__init__.py +3 -3
- power_grid_model/_core/buffer_handling.py +507 -478
- power_grid_model/_core/data_handling.py +195 -141
- power_grid_model/_core/data_types.py +142 -0
- power_grid_model/_core/dataset_definitions.py +109 -109
- power_grid_model/_core/enum.py +226 -0
- power_grid_model/_core/error_handling.py +215 -198
- power_grid_model/_core/errors.py +134 -0
- power_grid_model/_core/index_integer.py +17 -17
- power_grid_model/_core/options.py +71 -69
- power_grid_model/_core/power_grid_core.py +577 -562
- power_grid_model/_core/power_grid_dataset.py +545 -490
- power_grid_model/_core/power_grid_meta.py +262 -244
- power_grid_model/_core/power_grid_model.py +1025 -687
- power_grid_model/_core/power_grid_model_c/__init__.py +3 -0
- power_grid_model/_core/power_grid_model_c/bin/power_grid_model_c.dll +0 -0
- power_grid_model/_core/power_grid_model_c/get_pgm_dll_path.py +63 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/basics.h +251 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/buffer.h +108 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/dataset.h +332 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/dataset_definitions.h +1060 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/handle.h +111 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/meta_data.h +189 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/model.h +130 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/options.h +142 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/serialization.h +118 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c.h +36 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/basics.hpp +65 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/buffer.hpp +61 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/dataset.hpp +224 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/handle.hpp +108 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/meta_data.hpp +84 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/model.hpp +63 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/options.hpp +52 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/serialization.hpp +124 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/utils.hpp +81 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp.hpp +19 -0
- power_grid_model/_core/power_grid_model_c/lib/cmake/power_grid_model/power_grid_modelConfig.cmake +37 -0
- power_grid_model/_core/power_grid_model_c/lib/cmake/power_grid_model/power_grid_modelConfigVersion.cmake +65 -0
- power_grid_model/_core/power_grid_model_c/lib/cmake/power_grid_model/power_grid_modelTargets-release.cmake +19 -0
- power_grid_model/_core/power_grid_model_c/lib/cmake/power_grid_model/power_grid_modelTargets.cmake +144 -0
- power_grid_model/_core/power_grid_model_c/lib/power_grid_model_c.lib +0 -0
- power_grid_model/_core/power_grid_model_c/share/LICENSE +292 -0
- power_grid_model/_core/power_grid_model_c/share/README.md +15 -0
- power_grid_model/_core/serialization.py +319 -317
- power_grid_model/_core/typing.py +20 -0
- power_grid_model/{_utils.py → _core/utils.py} +798 -783
- power_grid_model/data_types.py +321 -319
- power_grid_model/enum.py +27 -214
- power_grid_model/errors.py +37 -119
- power_grid_model/typing.py +43 -48
- power_grid_model/utils.py +529 -400
- power_grid_model/validation/__init__.py +25 -10
- power_grid_model/validation/{rules.py → _rules.py} +1167 -962
- power_grid_model/validation/{validation.py → _validation.py} +1172 -1015
- power_grid_model/validation/assertions.py +93 -92
- power_grid_model/validation/errors.py +602 -524
- power_grid_model/validation/utils.py +313 -318
- {power_grid_model-1.10.17.dist-info → power_grid_model-1.12.119.dist-info}/METADATA +162 -165
- power_grid_model-1.12.119.dist-info/RECORD +65 -0
- {power_grid_model-1.10.17.dist-info → power_grid_model-1.12.119.dist-info}/WHEEL +1 -1
- power_grid_model-1.12.119.dist-info/entry_points.txt +3 -0
- power_grid_model/_core/_power_grid_core.dll +0 -0
- power_grid_model-1.10.17.dist-info/RECORD +0 -32
- power_grid_model-1.10.17.dist-info/top_level.txt +0 -1
- {power_grid_model-1.10.17.dist-info → power_grid_model-1.12.119.dist-info/licenses}/LICENSE +0 -0
|
Binary file
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import platform
|
|
7
|
+
from importlib.resources import files
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def get_pgm_dll_path() -> Path:
|
|
12
|
+
"""
|
|
13
|
+
Returns the path to PGM dynamic library.
|
|
14
|
+
"""
|
|
15
|
+
package_dir = Path(str(files(__package__)))
|
|
16
|
+
platform_name = platform.uname().system
|
|
17
|
+
if platform_name == "Windows":
|
|
18
|
+
lib_dir_1 = package_dir / "bin"
|
|
19
|
+
lib_dir_2 = package_dir / "bin"
|
|
20
|
+
else:
|
|
21
|
+
lib_dir_1 = package_dir / "lib"
|
|
22
|
+
lib_dir_2 = package_dir / "lib64"
|
|
23
|
+
|
|
24
|
+
# determine DLL file name
|
|
25
|
+
if platform_name == "Windows":
|
|
26
|
+
dll_file = Path("power_grid_model_c.dll")
|
|
27
|
+
elif platform_name == "Darwin":
|
|
28
|
+
dll_file = Path("libpower_grid_model_c.dylib")
|
|
29
|
+
elif platform.system() == "Linux":
|
|
30
|
+
dll_file = Path("libpower_grid_model_c.so")
|
|
31
|
+
else:
|
|
32
|
+
raise NotImplementedError(f"Unsupported platform: {platform_name}")
|
|
33
|
+
lib_dll_path_1 = lib_dir_1 / dll_file
|
|
34
|
+
lib_dll_path_2 = lib_dir_2 / dll_file
|
|
35
|
+
|
|
36
|
+
# determine editable path to the DLL
|
|
37
|
+
# __file__
|
|
38
|
+
# -> power_grid_model_c (..)
|
|
39
|
+
# -> _core (..)
|
|
40
|
+
# -> power_grid_model (..)
|
|
41
|
+
# -> src (..)
|
|
42
|
+
# -> repo_root (..)
|
|
43
|
+
# -> build
|
|
44
|
+
# -> bin
|
|
45
|
+
editable_dir = Path(__file__).resolve().parent.parent.parent.parent.parent / "build" / "bin"
|
|
46
|
+
editable_dll_path = editable_dir / dll_file
|
|
47
|
+
|
|
48
|
+
# first try to load from lib_dll_path
|
|
49
|
+
# then editable_dll_path
|
|
50
|
+
# then if it is inside conda, just load dll_file, the system tries to find it in the PATH
|
|
51
|
+
# then for anything else, raise an error
|
|
52
|
+
if lib_dll_path_1.exists():
|
|
53
|
+
final_dll_path = lib_dll_path_1
|
|
54
|
+
elif lib_dll_path_2.exists():
|
|
55
|
+
final_dll_path = lib_dll_path_2
|
|
56
|
+
elif editable_dll_path.exists():
|
|
57
|
+
final_dll_path = editable_dll_path
|
|
58
|
+
elif os.environ.get("CONDA_PREFIX"):
|
|
59
|
+
final_dll_path = dll_file
|
|
60
|
+
else:
|
|
61
|
+
raise ImportError(f"Could not find shared library: {dll_file}. Your PGM installation may be broken.")
|
|
62
|
+
|
|
63
|
+
return final_dll_path
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @brief Header file which includes basic type definitions
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
#ifndef POWER_GRID_MODEL_C_BASICS_H
|
|
12
|
+
#define POWER_GRID_MODEL_C_BASICS_H
|
|
13
|
+
|
|
14
|
+
// Generic helper definitions for shared library support
|
|
15
|
+
// API_MACRO_BLOCK
|
|
16
|
+
#if defined _WIN32
|
|
17
|
+
#define PGM_HELPER_DLL_IMPORT __declspec(dllimport)
|
|
18
|
+
#define PGM_HELPER_DLL_EXPORT __declspec(dllexport)
|
|
19
|
+
#define PGM_HELPER_DLL_LOCAL
|
|
20
|
+
#else
|
|
21
|
+
#if __GNUC__ >= 4
|
|
22
|
+
#define PGM_HELPER_DLL_IMPORT __attribute__((visibility("default")))
|
|
23
|
+
#define PGM_HELPER_DLL_EXPORT __attribute__((visibility("default")))
|
|
24
|
+
#define PGM_HELPER_DLL_LOCAL __attribute__((visibility("hidden")))
|
|
25
|
+
#else
|
|
26
|
+
#define PGM_HELPER_DLL_IMPORT
|
|
27
|
+
#define PGM_HELPER_DLL_EXPORT
|
|
28
|
+
#define PGM_HELPER_DLL_LOCAL
|
|
29
|
+
#endif
|
|
30
|
+
#endif
|
|
31
|
+
// Now we use the generic helper definitions above to define PGM_API and PGM_LOCAL.
|
|
32
|
+
#ifdef PGM_DLL_EXPORTS // defined if we are building the POWER_GRID_MODEL DLL (instead of using it)
|
|
33
|
+
#define PGM_API PGM_HELPER_DLL_EXPORT
|
|
34
|
+
#else
|
|
35
|
+
#define PGM_API PGM_HELPER_DLL_IMPORT
|
|
36
|
+
#endif // PGM_DLL_EXPORTS
|
|
37
|
+
#define PGM_LOCAL PGM_HELPER_DLL_LOCAL
|
|
38
|
+
// API_MACRO_BLOCK
|
|
39
|
+
|
|
40
|
+
// integers
|
|
41
|
+
#ifdef __cplusplus
|
|
42
|
+
#include <cstddef>
|
|
43
|
+
#include <cstdint>
|
|
44
|
+
#else
|
|
45
|
+
#include <stddef.h>
|
|
46
|
+
#include <stdint.h>
|
|
47
|
+
#endif
|
|
48
|
+
|
|
49
|
+
// C linkage
|
|
50
|
+
#ifdef __cplusplus
|
|
51
|
+
extern "C" {
|
|
52
|
+
#endif
|
|
53
|
+
|
|
54
|
+
// NOLINTBEGIN(modernize-use-using)
|
|
55
|
+
|
|
56
|
+
// index type
|
|
57
|
+
typedef int64_t PGM_Idx;
|
|
58
|
+
typedef int32_t PGM_ID;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @brief Opaque struct for the PowerGridModel class.
|
|
62
|
+
*
|
|
63
|
+
*/
|
|
64
|
+
typedef struct PGM_PowerGridModel PGM_PowerGridModel;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @brief Opaque struct for the handle class.
|
|
68
|
+
*
|
|
69
|
+
* The handle class is used to store error and information.
|
|
70
|
+
*
|
|
71
|
+
*/
|
|
72
|
+
typedef struct PGM_Handle PGM_Handle;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @brief Opaque struct for the option class.
|
|
76
|
+
*
|
|
77
|
+
* The option class is used to set calculation options like calculation method.
|
|
78
|
+
*
|
|
79
|
+
*/
|
|
80
|
+
typedef struct PGM_Options PGM_Options;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* @brief Opaque struct for the attribute meta class.
|
|
84
|
+
*
|
|
85
|
+
* The attribute class contains all the meta information of a single attribute.
|
|
86
|
+
*
|
|
87
|
+
*/
|
|
88
|
+
typedef struct PGM_MetaAttribute PGM_MetaAttribute;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @brief Opaque struct for the component meta class.
|
|
92
|
+
*
|
|
93
|
+
* The component class contains all the meta information of a single component.
|
|
94
|
+
*
|
|
95
|
+
*/
|
|
96
|
+
typedef struct PGM_MetaComponent PGM_MetaComponent;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @brief Opaque struct for the dataset meta class
|
|
100
|
+
*
|
|
101
|
+
* The dataset class contains all the meta information of a single dataset.
|
|
102
|
+
*
|
|
103
|
+
*/
|
|
104
|
+
typedef struct PGM_MetaDataset PGM_MetaDataset;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @brief Opaque struct for the serializer class.
|
|
108
|
+
*/
|
|
109
|
+
typedef struct PGM_Serializer PGM_Serializer;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @brief Opaque struct for the deserializer class.
|
|
113
|
+
*/
|
|
114
|
+
typedef struct PGM_Deserializer PGM_Deserializer;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @brief Opaque struct for the const dataset class.
|
|
118
|
+
*/
|
|
119
|
+
typedef struct PGM_ConstDataset PGM_ConstDataset;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @brief Opaque struct for the multable dataset class.
|
|
123
|
+
* The mutable dataset is meant for the user to provide buffers to store the output of calculations.
|
|
124
|
+
*/
|
|
125
|
+
typedef struct PGM_MutableDataset PGM_MutableDataset;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @brief Opaque struct for the writable dataset class.
|
|
129
|
+
* The writable dataset is meant for the user to provide buffers for the deserializer.
|
|
130
|
+
*/
|
|
131
|
+
typedef struct PGM_WritableDataset PGM_WritableDataset;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @brief Opaque struct for the information of the dataset.
|
|
135
|
+
*/
|
|
136
|
+
typedef struct PGM_DatasetInfo PGM_DatasetInfo;
|
|
137
|
+
|
|
138
|
+
// NOLINTEND(modernize-use-using)
|
|
139
|
+
|
|
140
|
+
// NOLINTBEGIN(performance-enum-size)
|
|
141
|
+
|
|
142
|
+
// enums
|
|
143
|
+
/**
|
|
144
|
+
* @brief Enumeration for calculation type.
|
|
145
|
+
*
|
|
146
|
+
*/
|
|
147
|
+
enum PGM_CalculationType {
|
|
148
|
+
PGM_power_flow = 0, /**< power flow calculation */
|
|
149
|
+
PGM_state_estimation = 1, /**< state estimation calculation */
|
|
150
|
+
PGM_short_circuit = 2 /**< short circuit calculation */
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* @brief Enumeration for calculation method.
|
|
155
|
+
*
|
|
156
|
+
*/
|
|
157
|
+
enum PGM_CalculationMethod {
|
|
158
|
+
PGM_default_method = -128, /**< the default method for each calculation type, e.g. Newton-Raphson for power flow */
|
|
159
|
+
PGM_linear = 0, /**< linear constant impedance method for power flow */
|
|
160
|
+
PGM_newton_raphson = 1, /**< Newton-Raphson method for power flow or state estimation */
|
|
161
|
+
PGM_iterative_linear = 2, /**< iterative linear method for state estimation */
|
|
162
|
+
PGM_iterative_current = 3, /**< linear current method for power flow */
|
|
163
|
+
PGM_linear_current = 4, /**< iterative constant impedance method for power flow */
|
|
164
|
+
PGM_iec60909 = 5 /**< fault analysis for short circuits using the iec60909 standard */
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* @brief Enumeration for calculation and/or component symmetry
|
|
169
|
+
*/
|
|
170
|
+
enum PGM_SymmetryType {
|
|
171
|
+
PGM_asymmetric = 0, /** < asymmetric calculation and/or component */
|
|
172
|
+
PGM_symmetric = 1 /** < symmetric calculation and/or component */
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* @brief Enumeration of error codes.
|
|
177
|
+
*
|
|
178
|
+
*/
|
|
179
|
+
enum PGM_ErrorCode {
|
|
180
|
+
PGM_no_error = 0, /**< no error occurred */
|
|
181
|
+
PGM_regular_error = 1, /**< some error occurred which is not in the batch calculation */
|
|
182
|
+
PGM_batch_error = 2, /**< some error occurred which is in the batch calculation */
|
|
183
|
+
PGM_serialization_error = 3, /**< some error occurred which is in the (de)serialization process */
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* @brief Enumeration of C basic data types.
|
|
188
|
+
*
|
|
189
|
+
*/
|
|
190
|
+
enum PGM_CType {
|
|
191
|
+
PGM_int32 = 0, /**< int32_t */
|
|
192
|
+
PGM_int8 = 1, /**< int8_t */
|
|
193
|
+
PGM_double = 2, /**< double */
|
|
194
|
+
PGM_double3 = 3, /**< double[3] */
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* @brief Enumeration of serialization types.
|
|
199
|
+
*
|
|
200
|
+
*/
|
|
201
|
+
enum PGM_SerializationFormat {
|
|
202
|
+
PGM_json = 0, /**< JSON serialization format */
|
|
203
|
+
PGM_msgpack = 1, /**< msgpack serialization format */
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* @brief Enumeration of short circuit voltage scaling.
|
|
208
|
+
*
|
|
209
|
+
*/
|
|
210
|
+
enum PGM_ShortCircuitVoltageScaling {
|
|
211
|
+
PGM_short_circuit_voltage_scaling_minimum = 0, /**< voltage scaling for minimum short circuit currents */
|
|
212
|
+
PGM_short_circuit_voltage_scaling_maximum = 1, /**< voltage scaling for maximum short circuit currents */
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* @brief Enumeration of tap changing strategies.
|
|
217
|
+
*
|
|
218
|
+
*/
|
|
219
|
+
enum PGM_TapChangingStrategy {
|
|
220
|
+
PGM_tap_changing_strategy_disabled = 0, /**< disable automatic tap adjustment */
|
|
221
|
+
PGM_tap_changing_strategy_any_valid_tap =
|
|
222
|
+
1, /**< adjust tap position automatically; optimize for any value in the voltage band */
|
|
223
|
+
PGM_tap_changing_strategy_min_voltage_tap =
|
|
224
|
+
2, /**< adjust tap position automatically; optimize for the lower end of the voltage band */
|
|
225
|
+
PGM_tap_changing_strategy_max_voltage_tap =
|
|
226
|
+
3, /**< adjust tap position automatically; optimize for the higher end of the voltage band */
|
|
227
|
+
PGM_tap_changing_strategy_fast_any_tap =
|
|
228
|
+
4, /**< adjust tap position automatically; optimize for any value in the voltage band; binary search */
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* @brief Enumeration of experimental features.
|
|
233
|
+
*
|
|
234
|
+
* [Danger mode]
|
|
235
|
+
*
|
|
236
|
+
* The behavior of experimental features may not be final and no stability guarantees are made to the users.
|
|
237
|
+
* Which features (if any) are enabled in experimental mode may change over time.
|
|
238
|
+
*
|
|
239
|
+
*/
|
|
240
|
+
enum PGM_ExperimentalFeatures {
|
|
241
|
+
PGM_experimental_features_disabled = 0, /**< disable experimental features */
|
|
242
|
+
PGM_experimental_features_enabled = 1, /**< enable experimental features */
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
// NOLINTEND(performance-enum-size)
|
|
246
|
+
|
|
247
|
+
#ifdef __cplusplus
|
|
248
|
+
}
|
|
249
|
+
#endif
|
|
250
|
+
|
|
251
|
+
#endif
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @brief header file which includes buffer functions
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
#ifndef POWER_GRID_MODEL_C_BUFFER_H
|
|
12
|
+
#define POWER_GRID_MODEL_C_BUFFER_H
|
|
13
|
+
|
|
14
|
+
#include "basics.h"
|
|
15
|
+
|
|
16
|
+
#ifdef __cplusplus
|
|
17
|
+
extern "C" {
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @brief Create a buffer with certain size and component type.
|
|
22
|
+
*
|
|
23
|
+
* You can use this function to allocate a (row-based) component buffer.
|
|
24
|
+
* You can also use your own allocation function to do that
|
|
25
|
+
* with size and alignment obtained from PGM_meta_component_size() and PGM_meta_component_alignment().
|
|
26
|
+
* The buffer created by this function should be freed by PGM_destroy_buffer().
|
|
27
|
+
*
|
|
28
|
+
* It is recommended to call PGM_buffer_set_nan() after you create an input or update buffer.
|
|
29
|
+
* In this way all the attributes will be set to NaN.
|
|
30
|
+
* Additionally, if there is a new optional attribute added in the future,
|
|
31
|
+
* compatibility with your code is guaranteed: that optional attribute will be set to NaN
|
|
32
|
+
* and the default value will be used.
|
|
33
|
+
*
|
|
34
|
+
* @param handle
|
|
35
|
+
* @param component A component pointer.
|
|
36
|
+
* @param size The size of the buffer in terms of number of elements.
|
|
37
|
+
* @return A pointer to the buffer, or NULL if the input is invalid.
|
|
38
|
+
*/
|
|
39
|
+
PGM_API void* PGM_create_buffer(PGM_Handle* handle, PGM_MetaComponent const* component, PGM_Idx size);
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @brief Destroy the buffer you created using PGM_create_buffer().
|
|
43
|
+
*
|
|
44
|
+
* NOTE: Do not call this function on the buffer you created using your own function.
|
|
45
|
+
*
|
|
46
|
+
* @param ptr The pointer to the buffer created using PGM_create_buffer().
|
|
47
|
+
*/
|
|
48
|
+
PGM_API void PGM_destroy_buffer(void* ptr);
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @brief Set all the attributes of a buffer to NaN.
|
|
52
|
+
*
|
|
53
|
+
* @param handle
|
|
54
|
+
* @param component A component pointer.
|
|
55
|
+
* @param ptr pointer to buffer, created either by PGM_create_buffer() or your own function.
|
|
56
|
+
* @param buffer_offset The offset in the buffer where you begin to set nan, in terms of number of elements.
|
|
57
|
+
* @param size The size of the buffer in terms of number of elements.
|
|
58
|
+
*/
|
|
59
|
+
PGM_API void PGM_buffer_set_nan(PGM_Handle* handle, PGM_MetaComponent const* component, void* ptr,
|
|
60
|
+
PGM_Idx buffer_offset, PGM_Idx size);
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @brief Set value of a certain attribute from an array to the component buffer.
|
|
64
|
+
*
|
|
65
|
+
* You can use this function to set value.
|
|
66
|
+
* You can also set value by proper pointer arithmetric and casting,
|
|
67
|
+
* using the offset information returned by PGM_meta_attribute_offset().
|
|
68
|
+
*
|
|
69
|
+
* @param handle
|
|
70
|
+
* @param attribute An attribute pointer.
|
|
71
|
+
* @param buffer_ptr A pointer to the buffer.
|
|
72
|
+
* @param src_ptr A pointer to the source array you want to retrieve the value from.
|
|
73
|
+
* @param buffer_offset The offset in the buffer where you begin to set value, in terms of number of elements
|
|
74
|
+
* @param size The size of the buffer in terms of number of elements.
|
|
75
|
+
* @param src_stride The stride of the source array in bytes.
|
|
76
|
+
* You can set it to -1, the default stride of the size of the attribute type (like sizeof(double)).
|
|
77
|
+
* If you set it to a positive number, the i-th set-value will retrieve the source data at
|
|
78
|
+
* (void const*)((char const*)src_ptr + i * src_stride)
|
|
79
|
+
*/
|
|
80
|
+
PGM_API void PGM_buffer_set_value(PGM_Handle* handle, PGM_MetaAttribute const* attribute, void* buffer_ptr,
|
|
81
|
+
void const* src_ptr, PGM_Idx buffer_offset, PGM_Idx size, PGM_Idx src_stride);
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @brief Get value of a certain attribute from the component buffer to an array.
|
|
85
|
+
*
|
|
86
|
+
* You can use this function to get value.
|
|
87
|
+
* You can also get value by proper pointer arithmetric and casting,
|
|
88
|
+
* using the offset information returned by PGM_meta_attribute_offset().
|
|
89
|
+
*
|
|
90
|
+
* @param handle
|
|
91
|
+
* @param attribute An attribute pointer.
|
|
92
|
+
* @param buffer_ptr A pointer to the buffer.
|
|
93
|
+
* @param dest_ptr A pointer to the destination array you want to save the value to.
|
|
94
|
+
* @param buffer_offset The offset in the buffer where you begin to get value; in terms of number of elements.
|
|
95
|
+
* @param size The size of the buffer in terms of number of elements.
|
|
96
|
+
* @param dest_stride The stride of the destination array in bytes.
|
|
97
|
+
* You can set it to -1, the default stride of the size of the attribute type (like sizeof(double)).
|
|
98
|
+
* If you set it to a positive number, the i-th get-value will retrieve the source data at
|
|
99
|
+
* (void*)((char*)dest_ptr + i * dest_stride)
|
|
100
|
+
*/
|
|
101
|
+
PGM_API void PGM_buffer_get_value(PGM_Handle* handle, PGM_MetaAttribute const* attribute, void const* buffer_ptr,
|
|
102
|
+
void* dest_ptr, PGM_Idx buffer_offset, PGM_Idx size, PGM_Idx dest_stride);
|
|
103
|
+
|
|
104
|
+
#ifdef __cplusplus
|
|
105
|
+
}
|
|
106
|
+
#endif
|
|
107
|
+
|
|
108
|
+
#endif
|