ansys-speos-core 0.3.0__py3-none-any.whl → 0.4.0__py3-none-any.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.
- ansys/speos/core/generic/constants.py +36 -0
- ansys/speos/core/generic/general_methods.py +166 -1
- ansys/speos/core/generic/visualization_methods.py +289 -0
- ansys/speos/core/kernel/client.py +63 -34
- ansys/speos/core/launcher.py +81 -2
- ansys/speos/core/logger.py +1 -1
- ansys/speos/core/lxp.py +35 -14
- ansys/speos/core/project.py +88 -13
- ansys/speos/core/sensor.py +222 -0
- ansys/speos/core/source.py +1 -0
- ansys/speos/core/speos.py +26 -6
- {ansys_speos_core-0.3.0.dist-info → ansys_speos_core-0.4.0.dist-info}/METADATA +14 -5
- {ansys_speos_core-0.3.0.dist-info → ansys_speos_core-0.4.0.dist-info}/RECORD +15 -13
- {ansys_speos_core-0.3.0.dist-info → ansys_speos_core-0.4.0.dist-info}/WHEEL +1 -1
- {ansys_speos_core-0.3.0.dist-info → ansys_speos_core-0.4.0.dist-info/licenses}/LICENSE +0 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates.
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
#
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
# copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
|
|
23
|
+
"""Collection of all constants used in pySpeos."""
|
|
24
|
+
|
|
25
|
+
import os
|
|
26
|
+
|
|
27
|
+
DEFAULT_HOST = "localhost"
|
|
28
|
+
"""Default host used by Speos RPC server and client """
|
|
29
|
+
DEFAULT_PORT = "50098"
|
|
30
|
+
"""Default port used by Speos RPC server and client """
|
|
31
|
+
DEFAULT_VERSION = "251"
|
|
32
|
+
"""Latest supported Speos version of the current PySpeos Package"""
|
|
33
|
+
MAX_MESSAGE_LENGTH = int(os.environ.get("SPEOS_MAX_MESSAGE_LENGTH", 256 * 1024**2))
|
|
34
|
+
"""Maximum message length value accepted by the Speos RPC server,
|
|
35
|
+
By default, value stored in environment variable SPEOS_MAX_MESSAGE_LENGTH or 268 435 456.
|
|
36
|
+
"""
|
|
@@ -25,9 +25,24 @@
|
|
|
25
25
|
this includes decorator and methods
|
|
26
26
|
"""
|
|
27
27
|
|
|
28
|
-
from functools import wraps
|
|
28
|
+
from functools import lru_cache, wraps
|
|
29
|
+
import os
|
|
30
|
+
from pathlib import Path
|
|
31
|
+
from typing import List, Optional, Union
|
|
29
32
|
import warnings
|
|
30
33
|
|
|
34
|
+
import numpy as np
|
|
35
|
+
|
|
36
|
+
from ansys.speos.core.generic.constants import DEFAULT_VERSION
|
|
37
|
+
from ansys.tools.path import get_available_ansys_installations
|
|
38
|
+
|
|
39
|
+
_GRAPHICS_AVAILABLE = None
|
|
40
|
+
|
|
41
|
+
GRAPHICS_ERROR = (
|
|
42
|
+
"Preview unsupported without 'ansys-tools-visualization_interface' installed. "
|
|
43
|
+
"You can install this using `pip install ansys-speos-core[graphics]`."
|
|
44
|
+
)
|
|
45
|
+
|
|
31
46
|
|
|
32
47
|
def deprecate_kwargs(old_arguments: dict, removed_version="0.3.0"):
|
|
33
48
|
"""Issues deprecation warnings for arguments.
|
|
@@ -62,3 +77,153 @@ def deprecate_kwargs(old_arguments: dict, removed_version="0.3.0"):
|
|
|
62
77
|
return wrapper
|
|
63
78
|
|
|
64
79
|
return decorator
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
@lru_cache
|
|
83
|
+
def run_if_graphics_required(warning=False):
|
|
84
|
+
"""Check if graphics are available."""
|
|
85
|
+
global _GRAPHICS_AVAILABLE
|
|
86
|
+
if _GRAPHICS_AVAILABLE is None:
|
|
87
|
+
try:
|
|
88
|
+
import pyvista as pv # noqa: F401
|
|
89
|
+
|
|
90
|
+
from ansys.tools.visualization_interface import Plotter # noqa: F401
|
|
91
|
+
|
|
92
|
+
_GRAPHICS_AVAILABLE = True
|
|
93
|
+
except ImportError: # pragma: no cover
|
|
94
|
+
_GRAPHICS_AVAILABLE = False
|
|
95
|
+
|
|
96
|
+
if _GRAPHICS_AVAILABLE is False and warning is False: # pragma: no cover
|
|
97
|
+
raise ImportError(GRAPHICS_ERROR)
|
|
98
|
+
elif _GRAPHICS_AVAILABLE is False: # pragma: no cover
|
|
99
|
+
warnings.warn(GRAPHICS_ERROR)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def graphics_required(method):
|
|
103
|
+
"""Decorate a method as requiring graphics.
|
|
104
|
+
|
|
105
|
+
Parameters
|
|
106
|
+
----------
|
|
107
|
+
method : callable
|
|
108
|
+
Method to decorate.
|
|
109
|
+
|
|
110
|
+
Returns
|
|
111
|
+
-------
|
|
112
|
+
callable
|
|
113
|
+
Decorated method.
|
|
114
|
+
"""
|
|
115
|
+
|
|
116
|
+
def wrapper(*args, **kwargs):
|
|
117
|
+
run_if_graphics_required()
|
|
118
|
+
return method(*args, **kwargs)
|
|
119
|
+
|
|
120
|
+
return wrapper
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def magnitude_vector(vector: Union[List[float], np.array]) -> float:
|
|
124
|
+
"""
|
|
125
|
+
Compute the magnitude (length) of a 2D or 3D vector using NumPy.
|
|
126
|
+
|
|
127
|
+
Parameters
|
|
128
|
+
----------
|
|
129
|
+
vector: List[float]
|
|
130
|
+
A 2D or 3D vector as a list [x, y] or [x, y, z].
|
|
131
|
+
|
|
132
|
+
Returns
|
|
133
|
+
-------
|
|
134
|
+
float
|
|
135
|
+
The magnitude (length) of the vector.
|
|
136
|
+
"""
|
|
137
|
+
vector_np = np.array(vector, dtype=float)
|
|
138
|
+
if vector_np.size not in (2, 3):
|
|
139
|
+
raise ValueError("Input vector must be either 2D or 3D")
|
|
140
|
+
return np.linalg.norm(vector_np)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def normalize_vector(vector: Union[List[float], np.array]) -> List[float]:
|
|
144
|
+
"""
|
|
145
|
+
Normalize a 2D or 3D vector to have a length of 1 using NumPy.
|
|
146
|
+
|
|
147
|
+
Parameters
|
|
148
|
+
----------
|
|
149
|
+
vector: List[float]
|
|
150
|
+
A vector as a list [x, y] for 2D or [x, y, z] for 3D.
|
|
151
|
+
|
|
152
|
+
Returns
|
|
153
|
+
-------
|
|
154
|
+
List[float]
|
|
155
|
+
The normalized vector.
|
|
156
|
+
"""
|
|
157
|
+
vector_np = np.array(vector, dtype=float)
|
|
158
|
+
if vector_np.size not in (2, 3):
|
|
159
|
+
raise ValueError("Input vector must be either 2D or 3D")
|
|
160
|
+
|
|
161
|
+
magnitude = magnitude_vector(vector_np)
|
|
162
|
+
if magnitude == 0:
|
|
163
|
+
raise ValueError("Cannot normalize the zero vector")
|
|
164
|
+
|
|
165
|
+
return (vector_np / magnitude).tolist()
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def error_no_install(install_path: Union[Path, str], version: Union[int, str]):
|
|
169
|
+
"""Raise error that installation was not found at a location.
|
|
170
|
+
|
|
171
|
+
Parameters
|
|
172
|
+
----------
|
|
173
|
+
install_path : Union[Path, str]
|
|
174
|
+
Installation Path
|
|
175
|
+
version : Union[int, str]
|
|
176
|
+
Version
|
|
177
|
+
"""
|
|
178
|
+
install_loc_msg = ""
|
|
179
|
+
if install_path:
|
|
180
|
+
install_loc_msg = f"at {Path(install_path).parent}"
|
|
181
|
+
raise FileNotFoundError(
|
|
182
|
+
f"Ansys Speos RPC server installation not found{install_loc_msg}. "
|
|
183
|
+
f"Please define AWP_ROOT{version} environment variable"
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def retrieve_speos_install_dir(
|
|
188
|
+
speos_rpc_path: Optional[Union[Path, str]] = None, version: str = DEFAULT_VERSION
|
|
189
|
+
) -> Path:
|
|
190
|
+
"""Retrieve Speos install location based on Path or Environment.
|
|
191
|
+
|
|
192
|
+
Parameters
|
|
193
|
+
----------
|
|
194
|
+
speos_rpc_path : Optional[str, Path]
|
|
195
|
+
location of Speos rpc executable
|
|
196
|
+
version : Union[str, int]
|
|
197
|
+
The Speos server version to run, in the 3 digits format, such as "242".
|
|
198
|
+
If unspecified, the version will be chosen as
|
|
199
|
+
``ansys.speos.core.kernel.client.LATEST_VERSION``.
|
|
200
|
+
|
|
201
|
+
"""
|
|
202
|
+
if not speos_rpc_path:
|
|
203
|
+
speos_rpc_path = ""
|
|
204
|
+
if not speos_rpc_path or not Path(speos_rpc_path).exists():
|
|
205
|
+
if not Path(speos_rpc_path).exists():
|
|
206
|
+
warnings.warn(
|
|
207
|
+
"Provided executable location not found, looking for local installation",
|
|
208
|
+
UserWarning,
|
|
209
|
+
)
|
|
210
|
+
versions = get_available_ansys_installations()
|
|
211
|
+
ansys_loc = versions.get(int(version), False)
|
|
212
|
+
if not ansys_loc:
|
|
213
|
+
ansys_loc = os.environ.get("AWP_ROOT{}".format(version), False)
|
|
214
|
+
if not ansys_loc:
|
|
215
|
+
error_no_install(speos_rpc_path, int(version))
|
|
216
|
+
|
|
217
|
+
speos_rpc_path = Path(ansys_loc) / "Optical Products" / "SPEOS_RPC"
|
|
218
|
+
elif Path(speos_rpc_path).is_file():
|
|
219
|
+
if "SpeosRPC_Server" not in Path(speos_rpc_path).name:
|
|
220
|
+
error_no_install(speos_rpc_path, int(version))
|
|
221
|
+
else:
|
|
222
|
+
speos_rpc_path = Path(speos_rpc_path).parent
|
|
223
|
+
if os.name == "nt":
|
|
224
|
+
speos_exec = speos_rpc_path / "SpeosRPC_Server.exe"
|
|
225
|
+
else:
|
|
226
|
+
speos_exec = speos_rpc_path / "SpeosRPC_Server.x"
|
|
227
|
+
if not speos_exec.is_file():
|
|
228
|
+
error_no_install(speos_rpc_path, int(version))
|
|
229
|
+
return speos_rpc_path
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates.
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
#
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
# copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
|
|
23
|
+
"""Provides the ``VisualData`` class."""
|
|
24
|
+
|
|
25
|
+
from typing import TYPE_CHECKING, List
|
|
26
|
+
|
|
27
|
+
from ansys.speos.core.generic.general_methods import (
|
|
28
|
+
graphics_required,
|
|
29
|
+
magnitude_vector,
|
|
30
|
+
normalize_vector,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
if TYPE_CHECKING: # pragma: no cover
|
|
34
|
+
import pyvista as pv
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@graphics_required
|
|
38
|
+
class _VisualCoordinateSystem:
|
|
39
|
+
"""Visualization data for the coordinate system..
|
|
40
|
+
|
|
41
|
+
By default, there is empty visualization data.
|
|
42
|
+
|
|
43
|
+
Notes
|
|
44
|
+
-----
|
|
45
|
+
**Do not instantiate this class yourself**.
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
def __init__(self):
|
|
49
|
+
import pyvista as pv
|
|
50
|
+
|
|
51
|
+
self.__origin = [0.0, 0.0, 0.0]
|
|
52
|
+
self.__x_axis = pv.Arrow(
|
|
53
|
+
start=self.__origin,
|
|
54
|
+
direction=[1.0, 0.0, 0.0],
|
|
55
|
+
scale=10.0,
|
|
56
|
+
tip_radius=0.05,
|
|
57
|
+
shaft_radius=0.01,
|
|
58
|
+
)
|
|
59
|
+
self.__y_axis = pv.Arrow(
|
|
60
|
+
start=self.__origin,
|
|
61
|
+
direction=[0.0, 1.0, 0.0],
|
|
62
|
+
scale=10.0,
|
|
63
|
+
tip_radius=0.05,
|
|
64
|
+
shaft_radius=0.01,
|
|
65
|
+
)
|
|
66
|
+
self.__z_axis = pv.Arrow(
|
|
67
|
+
start=self.__origin,
|
|
68
|
+
direction=[0.0, 0.0, 1.0],
|
|
69
|
+
scale=10.0,
|
|
70
|
+
tip_radius=0.05,
|
|
71
|
+
shaft_radius=0.01,
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def origin(self) -> List[float]:
|
|
76
|
+
"""Returns the origin of the coordinate system.
|
|
77
|
+
|
|
78
|
+
Returns
|
|
79
|
+
-------
|
|
80
|
+
List[float]
|
|
81
|
+
The origin of the coordinate system.
|
|
82
|
+
|
|
83
|
+
"""
|
|
84
|
+
return self.__origin
|
|
85
|
+
|
|
86
|
+
@origin.setter
|
|
87
|
+
def origin(self, value: List[float]) -> None:
|
|
88
|
+
"""Set the origin of the coordinate system.
|
|
89
|
+
|
|
90
|
+
Parameters
|
|
91
|
+
----------
|
|
92
|
+
value: List[float]
|
|
93
|
+
The origin of the coordinate system.
|
|
94
|
+
|
|
95
|
+
Returns
|
|
96
|
+
-------
|
|
97
|
+
None
|
|
98
|
+
"""
|
|
99
|
+
if len(value) != 3:
|
|
100
|
+
raise ValueError("origin must be a List of three values.")
|
|
101
|
+
self.__origin = value
|
|
102
|
+
|
|
103
|
+
@property
|
|
104
|
+
def x_axis(self) -> "pv.Arrow":
|
|
105
|
+
"""Returns the x-axis of the coordinate system.
|
|
106
|
+
|
|
107
|
+
Returns
|
|
108
|
+
-------
|
|
109
|
+
pv.Arrow
|
|
110
|
+
pyvista.Arrow the x-axis of the coordinate system.
|
|
111
|
+
|
|
112
|
+
"""
|
|
113
|
+
return self.__x_axis
|
|
114
|
+
|
|
115
|
+
@x_axis.setter
|
|
116
|
+
def x_axis(self, x_vector: List[float]) -> None:
|
|
117
|
+
"""Set the x-axis of the coordinate system.
|
|
118
|
+
|
|
119
|
+
Parameters
|
|
120
|
+
----------
|
|
121
|
+
x_vector: List[float]
|
|
122
|
+
The x-axis of the coordinate system.
|
|
123
|
+
|
|
124
|
+
Returns
|
|
125
|
+
-------
|
|
126
|
+
None
|
|
127
|
+
"""
|
|
128
|
+
import pyvista as pv
|
|
129
|
+
|
|
130
|
+
if len(x_vector) != 3:
|
|
131
|
+
raise ValueError("x_axis must be a List of three values.")
|
|
132
|
+
self.__x_axis = pv.Arrow(
|
|
133
|
+
start=self.__origin,
|
|
134
|
+
direction=normalize_vector(vector=x_vector),
|
|
135
|
+
scale=magnitude_vector(vector=x_vector),
|
|
136
|
+
tip_radius=0.05,
|
|
137
|
+
shaft_radius=0.01,
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
@property
|
|
141
|
+
def y_axis(self) -> "pv.Arrow":
|
|
142
|
+
"""
|
|
143
|
+
Returns the y-axis of the coordinate system.
|
|
144
|
+
|
|
145
|
+
Returns
|
|
146
|
+
-------
|
|
147
|
+
pv.Arrow
|
|
148
|
+
pyvista.Arrow the y-axis of the coordinate system.
|
|
149
|
+
|
|
150
|
+
"""
|
|
151
|
+
return self.__y_axis
|
|
152
|
+
|
|
153
|
+
@y_axis.setter
|
|
154
|
+
def y_axis(self, y_vector: List[float]) -> None:
|
|
155
|
+
"""Set the y-axis of the coordinate system.
|
|
156
|
+
|
|
157
|
+
Parameters
|
|
158
|
+
----------
|
|
159
|
+
y_vector: List[float]
|
|
160
|
+
The y-axis of the coordinate system.
|
|
161
|
+
|
|
162
|
+
Returns
|
|
163
|
+
-------
|
|
164
|
+
None
|
|
165
|
+
"""
|
|
166
|
+
import pyvista as pv
|
|
167
|
+
|
|
168
|
+
if len(y_vector) != 3:
|
|
169
|
+
raise ValueError("y_axis must be a List of three values.")
|
|
170
|
+
self.__y_axis = pv.Arrow(
|
|
171
|
+
start=self.__origin,
|
|
172
|
+
direction=normalize_vector(vector=y_vector),
|
|
173
|
+
scale=magnitude_vector(vector=y_vector),
|
|
174
|
+
tip_radius=0.05,
|
|
175
|
+
shaft_radius=0.01,
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
@property
|
|
179
|
+
def z_axis(self) -> "pv.Arrow":
|
|
180
|
+
"""
|
|
181
|
+
Returns the z-axis of the coordinate system.
|
|
182
|
+
|
|
183
|
+
Returns
|
|
184
|
+
-------
|
|
185
|
+
pv.Arrow
|
|
186
|
+
pyvista.Arrow the z-axis of the coordinate system.
|
|
187
|
+
|
|
188
|
+
"""
|
|
189
|
+
return self.__z_axis
|
|
190
|
+
|
|
191
|
+
@z_axis.setter
|
|
192
|
+
def z_axis(self, z_vector: List[float]) -> None:
|
|
193
|
+
"""Set the z-axis of the coordinate system.
|
|
194
|
+
|
|
195
|
+
Parameters
|
|
196
|
+
----------
|
|
197
|
+
z_vector: List[float]
|
|
198
|
+
The z-axis of the coordinate system.
|
|
199
|
+
|
|
200
|
+
Returns
|
|
201
|
+
-------
|
|
202
|
+
None
|
|
203
|
+
"""
|
|
204
|
+
import pyvista as pv
|
|
205
|
+
|
|
206
|
+
if len(z_vector) != 3:
|
|
207
|
+
raise ValueError("z_axis must be a List of three values.")
|
|
208
|
+
self.__z_axis = pv.Arrow(
|
|
209
|
+
start=self.__origin,
|
|
210
|
+
direction=normalize_vector(vector=z_vector),
|
|
211
|
+
scale=magnitude_vector(vector=z_vector),
|
|
212
|
+
tip_radius=0.05,
|
|
213
|
+
shaft_radius=0.01,
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
@graphics_required
|
|
218
|
+
class _VisualData:
|
|
219
|
+
"""Visualization data for the sensor.
|
|
220
|
+
|
|
221
|
+
By default, there is empty visualization data.
|
|
222
|
+
|
|
223
|
+
Notes
|
|
224
|
+
-----
|
|
225
|
+
**Do not instantiate this class yourself**
|
|
226
|
+
"""
|
|
227
|
+
|
|
228
|
+
def __init__(self, coordinate_system=True):
|
|
229
|
+
import pyvista as pv
|
|
230
|
+
|
|
231
|
+
self.__data = pv.PolyData()
|
|
232
|
+
self.coordinates = _VisualCoordinateSystem() if coordinate_system else None
|
|
233
|
+
self.updated = False
|
|
234
|
+
|
|
235
|
+
@property
|
|
236
|
+
def data(self) -> "pv.PolyData":
|
|
237
|
+
"""
|
|
238
|
+
Returns the data of the sensor.
|
|
239
|
+
|
|
240
|
+
Returns
|
|
241
|
+
-------
|
|
242
|
+
pv.PolyData
|
|
243
|
+
The data of the surface visualization.
|
|
244
|
+
|
|
245
|
+
"""
|
|
246
|
+
return self.__data
|
|
247
|
+
|
|
248
|
+
def add_data_triangle(self, triangle_vertices: List[List[float]]) -> None:
|
|
249
|
+
"""
|
|
250
|
+
Add surface data triangle to Visualization data.
|
|
251
|
+
|
|
252
|
+
Parameters
|
|
253
|
+
----------
|
|
254
|
+
triangle_vertices: List[List[float]]
|
|
255
|
+
The vertices of the triangle.
|
|
256
|
+
|
|
257
|
+
Returns
|
|
258
|
+
-------
|
|
259
|
+
None
|
|
260
|
+
"""
|
|
261
|
+
import pyvista as pv
|
|
262
|
+
|
|
263
|
+
if len(triangle_vertices) != 3 or any(len(vertex) != 3 for vertex in triangle_vertices):
|
|
264
|
+
raise ValueError(
|
|
265
|
+
"triangle_vertices is expected to be composed of 3 vertices with 3 elements each."
|
|
266
|
+
)
|
|
267
|
+
faces = [[3, 0, 1, 2]]
|
|
268
|
+
self.__data = self.__data.append_polydata(pv.PolyData(triangle_vertices, faces))
|
|
269
|
+
|
|
270
|
+
def add_data_rectangle(self, rectangle_vertices: List[List[float]]) -> None:
|
|
271
|
+
"""
|
|
272
|
+
Add surface data rectangle to Visualization data.
|
|
273
|
+
|
|
274
|
+
Parameters
|
|
275
|
+
----------
|
|
276
|
+
rectangle_vertices: List[List[float]]
|
|
277
|
+
The vertices of the rectangle.
|
|
278
|
+
|
|
279
|
+
Returns
|
|
280
|
+
-------
|
|
281
|
+
None
|
|
282
|
+
"""
|
|
283
|
+
import pyvista as pv
|
|
284
|
+
|
|
285
|
+
if len(rectangle_vertices) != 3 or any(len(vertex) != 3 for vertex in rectangle_vertices):
|
|
286
|
+
raise ValueError(
|
|
287
|
+
"rectangle_vertices is expected to be composed of 3 vertices with 3 elements each."
|
|
288
|
+
)
|
|
289
|
+
self.__data = self.__data.append_polydata(pv.Rectangle(rectangle_vertices))
|