ansys-speos-core 0.7.1__tar.gz → 0.7.2__tar.gz
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-0.7.1 → ansys_speos_core-0.7.2}/PKG-INFO +1 -1
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/pyproject.toml +1 -1
- ansys_speos_core-0.7.2/src/ansys/speos/core/ground_plane.py +247 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/launcher.py +4 -1
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/project.py +60 -5
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/source.py +729 -1
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/LICENSE +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/README.rst +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/__init__.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/body.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/bsdf.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/face.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/generic/constants.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/generic/general_methods.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/generic/visualization_methods.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/geo_ref.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/intensity.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/kernel/__init__.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/kernel/body.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/kernel/client.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/kernel/crud.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/kernel/face.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/kernel/grpc/transport_options.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/kernel/intensity_template.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/kernel/job.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/kernel/part.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/kernel/proto_message_utils.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/kernel/scene.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/kernel/sensor_template.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/kernel/simulation_template.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/kernel/sop_template.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/kernel/source_template.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/kernel/spectrum.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/kernel/vop_template.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/logger.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/lxp.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/opt_prop.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/part.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/proto_message_utils.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/py.typed +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/sensor.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/simulation.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/spectrum.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/speos.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/workflow/__init__.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/workflow/combine_speos.py +0 -0
- {ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/workflow/open_result.py +0 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
# Copyright (C) 2021 - 2026 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
|
+
"""Provides a way to interact with Speos feature: ground plane."""
|
|
23
|
+
|
|
24
|
+
from __future__ import annotations
|
|
25
|
+
|
|
26
|
+
from difflib import SequenceMatcher
|
|
27
|
+
from typing import List, Optional
|
|
28
|
+
|
|
29
|
+
from ansys.speos.core.kernel.scene import ProtoScene
|
|
30
|
+
import ansys.speos.core.project as project
|
|
31
|
+
import ansys.speos.core.proto_message_utils as proto_message_utils
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class GroundPlane:
|
|
35
|
+
"""Speos feature: ground plane.
|
|
36
|
+
|
|
37
|
+
Only usable when there is at least one Ambient Environment Source in the project.
|
|
38
|
+
|
|
39
|
+
Parameters
|
|
40
|
+
----------
|
|
41
|
+
project : project.Project
|
|
42
|
+
Project that will own the feature.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
def __init__(self, project: project.Project, ground: Optional[ProtoScene.GroundPlane] = None):
|
|
46
|
+
self._project = project
|
|
47
|
+
self._name = ""
|
|
48
|
+
|
|
49
|
+
if ground is None:
|
|
50
|
+
# Create local ground
|
|
51
|
+
self._ground = ProtoScene.GroundPlane()
|
|
52
|
+
self.ground_origin = [0.0, 0.0, 0.0]
|
|
53
|
+
self.ground_zenith = [0.0, 0.0, 1.0]
|
|
54
|
+
self.ground_height = 1000.0
|
|
55
|
+
self._committed = False
|
|
56
|
+
else:
|
|
57
|
+
# Retrieve ground from input
|
|
58
|
+
self._committed = True
|
|
59
|
+
self._ground = ground
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def ground_origin(self) -> List[float]:
|
|
63
|
+
"""Ground origin.
|
|
64
|
+
|
|
65
|
+
This property gets and sets the origin of the ground plane.
|
|
66
|
+
Default as [0, 0, 0]
|
|
67
|
+
|
|
68
|
+
Parameters
|
|
69
|
+
----------
|
|
70
|
+
value: List[float]
|
|
71
|
+
Ground origin.
|
|
72
|
+
|
|
73
|
+
Returns
|
|
74
|
+
-------
|
|
75
|
+
List[float]
|
|
76
|
+
Ground origin.
|
|
77
|
+
"""
|
|
78
|
+
return self._ground.ground_origin
|
|
79
|
+
|
|
80
|
+
@ground_origin.setter
|
|
81
|
+
def ground_origin(self, value: List[float]) -> None:
|
|
82
|
+
self._ground.ground_origin[:] = value
|
|
83
|
+
|
|
84
|
+
@property
|
|
85
|
+
def ground_zenith(self) -> List[float]:
|
|
86
|
+
"""Zenith direction.
|
|
87
|
+
|
|
88
|
+
This property gets and sets the zenith direction of the ground plane.
|
|
89
|
+
Default as [0, 0, 1]
|
|
90
|
+
|
|
91
|
+
Parameters
|
|
92
|
+
----------
|
|
93
|
+
value: List[float]
|
|
94
|
+
Zenith direction.
|
|
95
|
+
|
|
96
|
+
Returns
|
|
97
|
+
-------
|
|
98
|
+
List[float]
|
|
99
|
+
Zenith direction.
|
|
100
|
+
"""
|
|
101
|
+
return self._ground.zenith_direction
|
|
102
|
+
|
|
103
|
+
@ground_zenith.setter
|
|
104
|
+
def ground_zenith(self, value: List[float]) -> None:
|
|
105
|
+
self._ground.zenith_direction[:] = value
|
|
106
|
+
|
|
107
|
+
@property
|
|
108
|
+
def ground_height(self) -> float:
|
|
109
|
+
"""Ground height.
|
|
110
|
+
|
|
111
|
+
This property gets and sets the height of the ground plane.
|
|
112
|
+
Default as 1000.0
|
|
113
|
+
|
|
114
|
+
Parameters
|
|
115
|
+
----------
|
|
116
|
+
value: float
|
|
117
|
+
Ground height.
|
|
118
|
+
|
|
119
|
+
Returns
|
|
120
|
+
-------
|
|
121
|
+
float
|
|
122
|
+
Ground height.
|
|
123
|
+
"""
|
|
124
|
+
return self._ground.ground_height
|
|
125
|
+
|
|
126
|
+
@ground_height.setter
|
|
127
|
+
def ground_height(self, value: float) -> None:
|
|
128
|
+
self._ground.ground_height = value
|
|
129
|
+
|
|
130
|
+
def _to_dict(self) -> dict:
|
|
131
|
+
out_dict = {}
|
|
132
|
+
|
|
133
|
+
if self._project.scene_link:
|
|
134
|
+
scene_data = self._project.scene_link.get()
|
|
135
|
+
|
|
136
|
+
if self._committed:
|
|
137
|
+
out_dict = proto_message_utils._replace_guids(
|
|
138
|
+
speos_client=self._project.client, message=scene_data.ground
|
|
139
|
+
)
|
|
140
|
+
else:
|
|
141
|
+
out_dict = proto_message_utils._replace_guids(
|
|
142
|
+
speos_client=self._project.client, message=self._ground
|
|
143
|
+
)
|
|
144
|
+
else:
|
|
145
|
+
out_dict = proto_message_utils._replace_guids(
|
|
146
|
+
speos_client=self._project.client, message=self._ground
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
proto_message_utils._replace_properties(json_dict=out_dict)
|
|
150
|
+
|
|
151
|
+
return out_dict
|
|
152
|
+
|
|
153
|
+
def get(self, key: str = "") -> str | dict:
|
|
154
|
+
"""Get dictionary corresponding to the ground plane - read only.
|
|
155
|
+
|
|
156
|
+
Parameters
|
|
157
|
+
----------
|
|
158
|
+
key: str
|
|
159
|
+
|
|
160
|
+
Returns
|
|
161
|
+
-------
|
|
162
|
+
str | dict
|
|
163
|
+
"""
|
|
164
|
+
if key == "":
|
|
165
|
+
return self._to_dict()
|
|
166
|
+
info = proto_message_utils._value_finder_key_startswith(dict_var=self._to_dict(), key=key)
|
|
167
|
+
content = list(info)
|
|
168
|
+
if len(content) != 0:
|
|
169
|
+
content.sort(
|
|
170
|
+
key=lambda x: SequenceMatcher(None, x[0], key).ratio(),
|
|
171
|
+
reverse=True,
|
|
172
|
+
)
|
|
173
|
+
return content[0][1]
|
|
174
|
+
info = proto_message_utils._flatten_dict(dict_var=self._to_dict())
|
|
175
|
+
print("Used key: {} not found in key list: {}.".format(key, info.keys()))
|
|
176
|
+
|
|
177
|
+
def __str__(self):
|
|
178
|
+
"""Return the string representation of the ground plane property."""
|
|
179
|
+
out_str = ""
|
|
180
|
+
|
|
181
|
+
if self._project.scene_link:
|
|
182
|
+
if not self._committed:
|
|
183
|
+
out_str += "local: "
|
|
184
|
+
else:
|
|
185
|
+
out_str += "local: "
|
|
186
|
+
|
|
187
|
+
out_str += proto_message_utils.dict_to_str(dict=self._to_dict())
|
|
188
|
+
return out_str
|
|
189
|
+
|
|
190
|
+
def commit(self) -> GroundPlane:
|
|
191
|
+
"""Save feature: send the local data to the speos server database.
|
|
192
|
+
|
|
193
|
+
Returns
|
|
194
|
+
-------
|
|
195
|
+
ansys.speos.core.ground_plane.GroundPlane
|
|
196
|
+
Ground plane feature.
|
|
197
|
+
"""
|
|
198
|
+
# This boolean allows to keep track if the ground plane is committed
|
|
199
|
+
self._committed = True
|
|
200
|
+
|
|
201
|
+
# Update the scene with the ground plane
|
|
202
|
+
if self._project.scene_link:
|
|
203
|
+
scene_data = self._project.scene_link.get() # retrieve scene data
|
|
204
|
+
|
|
205
|
+
# In case the ground is different from what is stored on server -> update
|
|
206
|
+
if scene_data.ground != self._ground:
|
|
207
|
+
scene_data.ground.CopyFrom(self._ground)
|
|
208
|
+
self._project.scene_link.set(data=scene_data) # update scene data
|
|
209
|
+
|
|
210
|
+
return self
|
|
211
|
+
|
|
212
|
+
def reset(self) -> GroundPlane:
|
|
213
|
+
"""Reset feature: override local data by the one from the speos server database.
|
|
214
|
+
|
|
215
|
+
Returns
|
|
216
|
+
-------
|
|
217
|
+
ansys.speos.core.ground_plane.GroundPlane
|
|
218
|
+
Ground plane feature.
|
|
219
|
+
"""
|
|
220
|
+
# Reset ground plane
|
|
221
|
+
if self._project.scene_link is not None:
|
|
222
|
+
scene_data = self._project.scene_link.get() # retrieve scene data
|
|
223
|
+
self._ground = scene_data.ground # store locally the ground from server data
|
|
224
|
+
|
|
225
|
+
return self
|
|
226
|
+
|
|
227
|
+
def delete(self) -> GroundPlane:
|
|
228
|
+
"""Delete feature: delete data from the speos server database.
|
|
229
|
+
|
|
230
|
+
The local data are still available
|
|
231
|
+
|
|
232
|
+
Returns
|
|
233
|
+
-------
|
|
234
|
+
ansys.speos.core.ground_plane.GroundPlane
|
|
235
|
+
Ground plane feature.
|
|
236
|
+
"""
|
|
237
|
+
# Remove the ground from the scene
|
|
238
|
+
scene_data = self._project.scene_link.get() # retrieve scene data
|
|
239
|
+
|
|
240
|
+
if scene_data.HasField("ground"):
|
|
241
|
+
scene_data.ClearField("ground")
|
|
242
|
+
self._project.scene_link.set(data=scene_data) # update scene data
|
|
243
|
+
|
|
244
|
+
# _committed to false -> this feature is no longer committed
|
|
245
|
+
self._committed = False
|
|
246
|
+
|
|
247
|
+
return self
|
|
@@ -101,7 +101,10 @@ def launch_remote_speos(
|
|
|
101
101
|
pim = pypim.connect()
|
|
102
102
|
instance = pim.create_instance(product_name="speos", product_version=version)
|
|
103
103
|
instance.wait_for_ready()
|
|
104
|
-
|
|
104
|
+
# build_grpc_channel() returns an grpc._interceptor._Channel
|
|
105
|
+
# As we need a grpc.Channel in Speos object -> build_grpc_channel()._channel
|
|
106
|
+
# Not doing that was leading to issue when trying to find the target() of the channel.
|
|
107
|
+
channel = instance.build_grpc_channel()._channel
|
|
105
108
|
return Speos(channel=channel, remote_instance=instance)
|
|
106
109
|
|
|
107
110
|
|
|
@@ -35,6 +35,7 @@ import ansys.speos.core.body as body
|
|
|
35
35
|
import ansys.speos.core.face as face
|
|
36
36
|
from ansys.speos.core.generic.general_methods import graphics_required
|
|
37
37
|
from ansys.speos.core.generic.visualization_methods import local2absolute
|
|
38
|
+
from ansys.speos.core.ground_plane import GroundPlane
|
|
38
39
|
from ansys.speos.core.kernel.body import BodyLink
|
|
39
40
|
from ansys.speos.core.kernel.face import FaceLink
|
|
40
41
|
from ansys.speos.core.kernel.part import ProtoPart
|
|
@@ -55,6 +56,7 @@ from ansys.speos.core.simulation import (
|
|
|
55
56
|
SimulationVirtualBSDF,
|
|
56
57
|
)
|
|
57
58
|
from ansys.speos.core.source import (
|
|
59
|
+
SourceAmbientEnvironment,
|
|
58
60
|
SourceAmbientNaturalLight,
|
|
59
61
|
SourceLuminaire,
|
|
60
62
|
SourceRayFile,
|
|
@@ -158,7 +160,13 @@ class Project:
|
|
|
158
160
|
description: str = "",
|
|
159
161
|
feature_type: type = SourceSurface,
|
|
160
162
|
metadata: Optional[Mapping[str, str]] = None,
|
|
161
|
-
) -> Union[
|
|
163
|
+
) -> Union[
|
|
164
|
+
SourceSurface,
|
|
165
|
+
SourceRayFile,
|
|
166
|
+
SourceLuminaire,
|
|
167
|
+
SourceAmbientNaturalLight,
|
|
168
|
+
SourceAmbientEnvironment,
|
|
169
|
+
]:
|
|
162
170
|
"""Create a new Source feature.
|
|
163
171
|
|
|
164
172
|
Parameters
|
|
@@ -174,7 +182,8 @@ class Project:
|
|
|
174
182
|
Allowed types:
|
|
175
183
|
Union[ansys.speos.core.source.SourceSurface, ansys.speos.core.source.SourceRayFile, \
|
|
176
184
|
ansys.speos.core.source.SourceLuminaire, \
|
|
177
|
-
ansys.speos.core.source.SourceAmbientNaturalLight
|
|
185
|
+
ansys.speos.core.source.SourceAmbientNaturalLight, \
|
|
186
|
+
ansys.speos.core.source.SourceAmbientEnvironment].
|
|
178
187
|
metadata : Optional[Mapping[str, str]]
|
|
179
188
|
Metadata of the feature.
|
|
180
189
|
By default, ``{}``.
|
|
@@ -182,7 +191,8 @@ class Project:
|
|
|
182
191
|
Returns
|
|
183
192
|
-------
|
|
184
193
|
Union[ansys.speos.core.source.SourceSurface,ansys.speos.core.source.SourceRayFile,\
|
|
185
|
-
ansys.speos.core.source.SourceLuminaire, ansys.speos.core.source.SourceAmbientNaturalLight
|
|
194
|
+
ansys.speos.core.source.SourceLuminaire, ansys.speos.core.source.SourceAmbientNaturalLight,\
|
|
195
|
+
ansys.speos.core.source.SourceAmbientEnvironment]
|
|
186
196
|
Source class instance.
|
|
187
197
|
"""
|
|
188
198
|
if metadata is None:
|
|
@@ -224,10 +234,20 @@ class Project:
|
|
|
224
234
|
description=description,
|
|
225
235
|
metadata=metadata,
|
|
226
236
|
)
|
|
237
|
+
case "SourceAmbientEnvironment":
|
|
238
|
+
feature = SourceAmbientEnvironment(
|
|
239
|
+
project=self, name=name, description=description, metadata=metadata
|
|
240
|
+
)
|
|
227
241
|
case _:
|
|
228
242
|
msg = "Requested feature {} does not exist in supported list {}".format(
|
|
229
243
|
feature_type,
|
|
230
|
-
[
|
|
244
|
+
[
|
|
245
|
+
SourceSurface,
|
|
246
|
+
SourceLuminaire,
|
|
247
|
+
SourceRayFile,
|
|
248
|
+
SourceAmbientNaturalLight,
|
|
249
|
+
SourceAmbientEnvironment,
|
|
250
|
+
],
|
|
231
251
|
)
|
|
232
252
|
raise TypeError(msg)
|
|
233
253
|
self._features.append(feature)
|
|
@@ -437,6 +457,25 @@ class Project:
|
|
|
437
457
|
self._features.append(feature)
|
|
438
458
|
return feature
|
|
439
459
|
|
|
460
|
+
def create_ground_plane(self) -> GroundPlane:
|
|
461
|
+
"""Create ground plane feature.
|
|
462
|
+
|
|
463
|
+
Only one ground plane per project.
|
|
464
|
+
Only usable when there is at least one Ambient Environment Source in the project.
|
|
465
|
+
|
|
466
|
+
Returns
|
|
467
|
+
-------
|
|
468
|
+
ansys.speos.core.ground_plane.GroundPlane
|
|
469
|
+
Ground plane feature.
|
|
470
|
+
"""
|
|
471
|
+
existing_features = self.find(name="", feature_type=GroundPlane)
|
|
472
|
+
if len(existing_features) != 0:
|
|
473
|
+
return existing_features[0]
|
|
474
|
+
|
|
475
|
+
feature = GroundPlane(project=self)
|
|
476
|
+
self._features.append(feature)
|
|
477
|
+
return feature
|
|
478
|
+
|
|
440
479
|
def find(
|
|
441
480
|
self,
|
|
442
481
|
name: str,
|
|
@@ -461,6 +500,7 @@ class Project:
|
|
|
461
500
|
body.Body,
|
|
462
501
|
face.Face,
|
|
463
502
|
part.Part.SubPart,
|
|
503
|
+
GroundPlane,
|
|
464
504
|
]
|
|
465
505
|
]:
|
|
466
506
|
"""Find feature(s) by name (possibility to use regex) and by feature type.
|
|
@@ -490,7 +530,8 @@ class Project:
|
|
|
490
530
|
ansys.speos.core.simulation.SimulationInteractive, \
|
|
491
531
|
ansys.speos.core.simulation.SimulationInverse, ansys.speos.core.part.Part, \
|
|
492
532
|
ansys.speos.core.body.Body, \
|
|
493
|
-
ansys.speos.core.face.Face, ansys.speos.core.part.Part.SubPart
|
|
533
|
+
ansys.speos.core.face.Face, ansys.speos.core.part.Part.SubPart, \
|
|
534
|
+
ansys.speos.core.ground_plane.GroundPlane]]
|
|
494
535
|
Found features.
|
|
495
536
|
|
|
496
537
|
Examples
|
|
@@ -836,9 +877,23 @@ class Project:
|
|
|
836
877
|
source_instance=src_inst,
|
|
837
878
|
default_values=False,
|
|
838
879
|
)
|
|
880
|
+
elif src_inst.ambient_properties.HasField("environment_map_properties"):
|
|
881
|
+
src_feat = SourceAmbientEnvironment(
|
|
882
|
+
project=self,
|
|
883
|
+
name=src_inst.name,
|
|
884
|
+
source_instance=src_inst,
|
|
885
|
+
default_values=False,
|
|
886
|
+
)
|
|
839
887
|
if src_feat is not None:
|
|
840
888
|
self._features.append(src_feat)
|
|
841
889
|
|
|
890
|
+
# ground plane
|
|
891
|
+
if scene_data.HasField("ground"):
|
|
892
|
+
ground_feat = GroundPlane(project=self, ground=scene_data.ground)
|
|
893
|
+
|
|
894
|
+
if ground_feat is not None:
|
|
895
|
+
self._features.append(ground_feat)
|
|
896
|
+
|
|
842
897
|
for ssr_inst in scene_data.sensors:
|
|
843
898
|
if ssr_inst.name in [_._name for _ in self._features]:
|
|
844
899
|
continue
|
|
@@ -26,10 +26,12 @@ from __future__ import annotations
|
|
|
26
26
|
|
|
27
27
|
import datetime
|
|
28
28
|
from difflib import SequenceMatcher
|
|
29
|
+
from pathlib import Path
|
|
29
30
|
from typing import List, Mapping, Optional, Union
|
|
30
31
|
import uuid
|
|
31
32
|
|
|
32
33
|
from ansys.api.speos.scene.v2 import scene_pb2
|
|
34
|
+
from ansys.api.speos.source.v1 import source_pb2
|
|
33
35
|
import numpy as np
|
|
34
36
|
|
|
35
37
|
from ansys.speos.core import (
|
|
@@ -73,6 +75,395 @@ class BaseSource:
|
|
|
73
75
|
This is a Super class, **Do not instantiate this class yourself**
|
|
74
76
|
"""
|
|
75
77
|
|
|
78
|
+
class UserDefinedColorSpace:
|
|
79
|
+
"""Type of color space is user defined.
|
|
80
|
+
|
|
81
|
+
Parameters
|
|
82
|
+
----------
|
|
83
|
+
userdefined_color_space : source_pb2.SourceTemplate.UserDefinedRGBSpace
|
|
84
|
+
source_pb2.SourceTemplate.UserDefinedRGBSpace
|
|
85
|
+
default_values : bool
|
|
86
|
+
Uses default values when True.
|
|
87
|
+
stable_ctr : bool
|
|
88
|
+
Variable to indicate if usage is inside class scope
|
|
89
|
+
|
|
90
|
+
Notes
|
|
91
|
+
-----
|
|
92
|
+
**Do not instantiate this class yourself**, use set_userdefined_color_space() method.
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
class UserDefinedWhitePoint:
|
|
96
|
+
"""Type of white point is user defined.
|
|
97
|
+
|
|
98
|
+
Parameters
|
|
99
|
+
----------
|
|
100
|
+
userdefined_white_point : source_pb2.SourceTemplate.UserDefinedWhitePoint
|
|
101
|
+
source_pb2.SourceTemplate.UserDefinedWhitePoint
|
|
102
|
+
default_values : bool
|
|
103
|
+
Uses default values when True.
|
|
104
|
+
stable_ctr : bool
|
|
105
|
+
Variable to indicate if usage is inside class scope
|
|
106
|
+
|
|
107
|
+
Notes
|
|
108
|
+
-----
|
|
109
|
+
**Do not instantiate this class yourself**,
|
|
110
|
+
use set_white_point_type_user_defined() method.
|
|
111
|
+
"""
|
|
112
|
+
|
|
113
|
+
def __init__(
|
|
114
|
+
self,
|
|
115
|
+
userdefined_white_point: source_pb2.SourceTemplate.UserDefinedWhitePoint,
|
|
116
|
+
default_values: bool = True,
|
|
117
|
+
stable_ctr: bool = True,
|
|
118
|
+
):
|
|
119
|
+
if not stable_ctr:
|
|
120
|
+
msg = "UserDefinedWhitePoint class instantiated outside of class scope"
|
|
121
|
+
raise RuntimeError(msg)
|
|
122
|
+
self._userdefined_white_point = userdefined_white_point
|
|
123
|
+
|
|
124
|
+
if default_values:
|
|
125
|
+
self.white_point = [0.31271, 0.32902]
|
|
126
|
+
|
|
127
|
+
@property
|
|
128
|
+
def white_point(self):
|
|
129
|
+
"""White point coordinate.
|
|
130
|
+
|
|
131
|
+
This property gets or sets the white point coordinate [x, y]
|
|
132
|
+
|
|
133
|
+
Parameters
|
|
134
|
+
----------
|
|
135
|
+
value: List[float]
|
|
136
|
+
The white point coordinate, [0.31271, 0.32902] by default.
|
|
137
|
+
|
|
138
|
+
Returns
|
|
139
|
+
-------
|
|
140
|
+
List[float]
|
|
141
|
+
User defined white point coordinate
|
|
142
|
+
|
|
143
|
+
"""
|
|
144
|
+
return self._userdefined_white_point.white_point
|
|
145
|
+
|
|
146
|
+
@white_point.setter
|
|
147
|
+
def white_point(self, value: List[float]):
|
|
148
|
+
self._userdefined_white_point.white_point[:] = value
|
|
149
|
+
|
|
150
|
+
def __init__(
|
|
151
|
+
self,
|
|
152
|
+
project: project.Project,
|
|
153
|
+
userdefined_color_space: source_pb2.SourceTemplate.UserDefinedRGBSpace,
|
|
154
|
+
default_values: bool = True,
|
|
155
|
+
stable_ctr: bool = True,
|
|
156
|
+
):
|
|
157
|
+
self._project = project
|
|
158
|
+
if not stable_ctr:
|
|
159
|
+
msg = "UserDefinedColorSpace class instantiated outside of class scope"
|
|
160
|
+
raise RuntimeError(msg)
|
|
161
|
+
self._userdefined_color_space = userdefined_color_space
|
|
162
|
+
self._white_point_type = None
|
|
163
|
+
|
|
164
|
+
self._red_spectrum = BaseSource._Spectrum(
|
|
165
|
+
speos_client=self._project.client,
|
|
166
|
+
name="",
|
|
167
|
+
message_to_complete=self._userdefined_color_space,
|
|
168
|
+
field_name_to_complete="red_spectrum_guid",
|
|
169
|
+
spectrum_guid=self._userdefined_color_space.red_spectrum_guid,
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
self._green_spectrum = BaseSource._Spectrum(
|
|
173
|
+
speos_client=self._project.client,
|
|
174
|
+
name="",
|
|
175
|
+
message_to_complete=self._userdefined_color_space,
|
|
176
|
+
field_name_to_complete="green_spectrum_guid",
|
|
177
|
+
spectrum_guid=self._userdefined_color_space.green_spectrum_guid,
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
self._blue_spectrum = BaseSource._Spectrum(
|
|
181
|
+
speos_client=self._project.client,
|
|
182
|
+
name="",
|
|
183
|
+
message_to_complete=self._userdefined_color_space,
|
|
184
|
+
field_name_to_complete="blue_spectrum_guid",
|
|
185
|
+
spectrum_guid=self._userdefined_color_space.blue_spectrum_guid,
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
if default_values:
|
|
189
|
+
# Default values
|
|
190
|
+
self.set_white_point_type_d65()
|
|
191
|
+
|
|
192
|
+
@property
|
|
193
|
+
def red_spectrum(self) -> dict:
|
|
194
|
+
"""Get red spectrum.
|
|
195
|
+
|
|
196
|
+
Returns
|
|
197
|
+
-------
|
|
198
|
+
dict
|
|
199
|
+
Red spectrum dictionary
|
|
200
|
+
|
|
201
|
+
"""
|
|
202
|
+
return self._red_spectrum._spectrum._to_dict()
|
|
203
|
+
|
|
204
|
+
@red_spectrum.setter
|
|
205
|
+
def red_spectrum(self, red_spectrum_file_uri: str) -> None:
|
|
206
|
+
"""Set red spectrum.
|
|
207
|
+
|
|
208
|
+
Parameters
|
|
209
|
+
----------
|
|
210
|
+
red_spectrum_file_uri: str
|
|
211
|
+
Red spectrum file uri.
|
|
212
|
+
|
|
213
|
+
Returns
|
|
214
|
+
-------
|
|
215
|
+
None
|
|
216
|
+
"""
|
|
217
|
+
if self._red_spectrum._message_to_complete is not self._userdefined_color_space:
|
|
218
|
+
# Happens in case of feature reset (to be sure to always modify correct data)
|
|
219
|
+
self._red_spectrum._message_to_complete = self._userdefined_color_space
|
|
220
|
+
|
|
221
|
+
# name for the spectrum chosen: <file_uri>.Spectrum
|
|
222
|
+
self._red_spectrum._spectrum._spectrum.name = Path(red_spectrum_file_uri).name
|
|
223
|
+
self._red_spectrum._spectrum.set_library(file_uri=red_spectrum_file_uri)
|
|
224
|
+
|
|
225
|
+
@property
|
|
226
|
+
def green_spectrum(self) -> dict:
|
|
227
|
+
"""Get green spectrum.
|
|
228
|
+
|
|
229
|
+
Returns
|
|
230
|
+
-------
|
|
231
|
+
dict
|
|
232
|
+
Green spectrum dictionary
|
|
233
|
+
|
|
234
|
+
"""
|
|
235
|
+
return self._green_spectrum._spectrum._to_dict()
|
|
236
|
+
|
|
237
|
+
@green_spectrum.setter
|
|
238
|
+
def green_spectrum(self, green_spectrum_file_uri: str) -> None:
|
|
239
|
+
"""Set green spectrum.
|
|
240
|
+
|
|
241
|
+
Parameters
|
|
242
|
+
----------
|
|
243
|
+
green_spectrum_file_uri: str
|
|
244
|
+
Green spectrum file uri.
|
|
245
|
+
|
|
246
|
+
Returns
|
|
247
|
+
-------
|
|
248
|
+
None
|
|
249
|
+
"""
|
|
250
|
+
if self._green_spectrum._message_to_complete is not self._userdefined_color_space:
|
|
251
|
+
# Happens in case of feature reset (to be sure to always modify correct data)
|
|
252
|
+
self._green_spectrum._message_to_complete = self._userdefined_color_space
|
|
253
|
+
|
|
254
|
+
# name for the spectrum chosen: <file_uri>.Spectrum
|
|
255
|
+
self._green_spectrum._spectrum._spectrum.name = Path(green_spectrum_file_uri).name
|
|
256
|
+
self._green_spectrum._spectrum.set_library(file_uri=green_spectrum_file_uri)
|
|
257
|
+
|
|
258
|
+
@property
|
|
259
|
+
def blue_spectrum(self) -> dict:
|
|
260
|
+
"""Get blue spectrum.
|
|
261
|
+
|
|
262
|
+
Returns
|
|
263
|
+
-------
|
|
264
|
+
dict
|
|
265
|
+
Blue spectrum dictionary
|
|
266
|
+
|
|
267
|
+
"""
|
|
268
|
+
return self._blue_spectrum._spectrum._to_dict()
|
|
269
|
+
|
|
270
|
+
@blue_spectrum.setter
|
|
271
|
+
def blue_spectrum(self, blue_spectrum_file_uri: str) -> None:
|
|
272
|
+
"""Set blue spectrum.
|
|
273
|
+
|
|
274
|
+
Parameters
|
|
275
|
+
----------
|
|
276
|
+
blue_spectrum_file_uri: str
|
|
277
|
+
Blue spectrum file uri.
|
|
278
|
+
|
|
279
|
+
Returns
|
|
280
|
+
-------
|
|
281
|
+
None
|
|
282
|
+
"""
|
|
283
|
+
if self._blue_spectrum._message_to_complete is not self._userdefined_color_space:
|
|
284
|
+
# Happens in case of feature reset (to be sure to always modify correct data)
|
|
285
|
+
self._blue_spectrum._message_to_complete = self._userdefined_color_space
|
|
286
|
+
|
|
287
|
+
# name for the spectrum chosen: <file_uri>.Spectrum
|
|
288
|
+
self._blue_spectrum._spectrum._spectrum.name = Path(blue_spectrum_file_uri).name
|
|
289
|
+
self._blue_spectrum._spectrum.set_library(file_uri=blue_spectrum_file_uri)
|
|
290
|
+
|
|
291
|
+
@property
|
|
292
|
+
def white_point_type(
|
|
293
|
+
self,
|
|
294
|
+
) -> Union[
|
|
295
|
+
None,
|
|
296
|
+
source_pb2.SourceTemplate.PredefinedWhitePoint.WhitePointType.D65,
|
|
297
|
+
source_pb2.SourceTemplate.PredefinedWhitePoint.WhitePointType.D50,
|
|
298
|
+
source_pb2.SourceTemplate.PredefinedWhitePoint.WhitePointType.C,
|
|
299
|
+
source_pb2.SourceTemplate.PredefinedWhitePoint.WhitePointType.E,
|
|
300
|
+
UserDefinedWhitePoint,
|
|
301
|
+
]:
|
|
302
|
+
"""Get the white point type.
|
|
303
|
+
|
|
304
|
+
Returns
|
|
305
|
+
-------
|
|
306
|
+
Union
|
|
307
|
+
[
|
|
308
|
+
None,
|
|
309
|
+
source_pb2.SourceTemplate.PredefinedWhitePoint.WhitePointType.D65,
|
|
310
|
+
source_pb2.SourceTemplate.PredefinedWhitePoint.WhitePointType.D50,
|
|
311
|
+
source_pb2.SourceTemplate.PredefinedWhitePoint.WhitePointType.C,
|
|
312
|
+
source_pb2.SourceTemplate.PredefinedWhitePoint.WhitePointType.E,
|
|
313
|
+
UserDefinedWhitePoint,
|
|
314
|
+
]
|
|
315
|
+
Predefined White Point Type or User Defined White Point Type.
|
|
316
|
+
|
|
317
|
+
"""
|
|
318
|
+
return self._white_point_type
|
|
319
|
+
|
|
320
|
+
def set_white_point_type_d65(self) -> None:
|
|
321
|
+
"""Set white point type to D65.
|
|
322
|
+
|
|
323
|
+
Returns
|
|
324
|
+
-------
|
|
325
|
+
None
|
|
326
|
+
|
|
327
|
+
"""
|
|
328
|
+
self._userdefined_color_space.pre_defined_white_point.white_point_type = (
|
|
329
|
+
source_pb2.SourceTemplate.PredefinedWhitePoint.WhitePointType.D65
|
|
330
|
+
)
|
|
331
|
+
self._white_point_type = (
|
|
332
|
+
source_pb2.SourceTemplate.PredefinedWhitePoint.WhitePointType.D65
|
|
333
|
+
)
|
|
334
|
+
|
|
335
|
+
def set_white_point_type_c(self) -> None:
|
|
336
|
+
"""Set white point type to C.
|
|
337
|
+
|
|
338
|
+
Returns
|
|
339
|
+
-------
|
|
340
|
+
None
|
|
341
|
+
|
|
342
|
+
"""
|
|
343
|
+
self._userdefined_color_space.pre_defined_white_point.white_point_type = (
|
|
344
|
+
source_pb2.SourceTemplate.PredefinedWhitePoint.WhitePointType.C
|
|
345
|
+
)
|
|
346
|
+
self._white_point_type = source_pb2.SourceTemplate.PredefinedWhitePoint.WhitePointType.C
|
|
347
|
+
|
|
348
|
+
def set_white_point_type_d50(self) -> None:
|
|
349
|
+
"""Set white point type to D50.
|
|
350
|
+
|
|
351
|
+
Returns
|
|
352
|
+
-------
|
|
353
|
+
None
|
|
354
|
+
|
|
355
|
+
"""
|
|
356
|
+
self._userdefined_color_space.pre_defined_white_point.white_point_type = (
|
|
357
|
+
source_pb2.SourceTemplate.PredefinedWhitePoint.WhitePointType.D50
|
|
358
|
+
)
|
|
359
|
+
self._white_point_type = (
|
|
360
|
+
source_pb2.SourceTemplate.PredefinedWhitePoint.WhitePointType.D50
|
|
361
|
+
)
|
|
362
|
+
|
|
363
|
+
def set_white_point_type_e(self) -> None:
|
|
364
|
+
"""Set white point type to E.
|
|
365
|
+
|
|
366
|
+
Returns
|
|
367
|
+
-------
|
|
368
|
+
None
|
|
369
|
+
|
|
370
|
+
"""
|
|
371
|
+
self._userdefined_color_space.pre_defined_white_point.white_point_type = (
|
|
372
|
+
source_pb2.SourceTemplate.PredefinedWhitePoint.WhitePointType.E
|
|
373
|
+
)
|
|
374
|
+
self._white_point_type = source_pb2.SourceTemplate.PredefinedWhitePoint.WhitePointType.E
|
|
375
|
+
|
|
376
|
+
def set_white_point_type_user_defined(self) -> UserDefinedWhitePoint:
|
|
377
|
+
"""Set white point type to user_defined.
|
|
378
|
+
|
|
379
|
+
Returns
|
|
380
|
+
-------
|
|
381
|
+
UserDefinedWhitePoint
|
|
382
|
+
User defined white point settings.
|
|
383
|
+
|
|
384
|
+
"""
|
|
385
|
+
if self._white_point_type is None and self._userdefined_color_space.HasField(
|
|
386
|
+
"user_defined_white_point"
|
|
387
|
+
):
|
|
388
|
+
self._white_point_type = BaseSource.UserDefinedColorSpace.UserDefinedWhitePoint(
|
|
389
|
+
userdefined_white_point=self._userdefined_color_space.user_defined_white_point,
|
|
390
|
+
default_values=False,
|
|
391
|
+
stable_ctr=True,
|
|
392
|
+
)
|
|
393
|
+
if not isinstance(
|
|
394
|
+
self._white_point_type, BaseSource.UserDefinedColorSpace.UserDefinedWhitePoint
|
|
395
|
+
):
|
|
396
|
+
# if the _type is not UserDefinedWhitePoint then we create a new type.
|
|
397
|
+
self._white_point_type = BaseSource.UserDefinedColorSpace.UserDefinedWhitePoint(
|
|
398
|
+
userdefined_white_point=self._userdefined_color_space.user_defined_white_point,
|
|
399
|
+
stable_ctr=True,
|
|
400
|
+
)
|
|
401
|
+
elif (
|
|
402
|
+
self._white_point_type._userdefined_white_point
|
|
403
|
+
is not self._userdefined_color_space.user_defined_white_point
|
|
404
|
+
):
|
|
405
|
+
# Happens in case of feature reset (to be sure to always modify correct data)
|
|
406
|
+
self._white_point_type._userdefined_white_point = (
|
|
407
|
+
self._userdefined_color_space.user_defined_white_point
|
|
408
|
+
)
|
|
409
|
+
return self._white_point_type
|
|
410
|
+
|
|
411
|
+
class PredefinedColorSpace:
|
|
412
|
+
"""Type of color space is predefined value.
|
|
413
|
+
|
|
414
|
+
Parameters
|
|
415
|
+
----------
|
|
416
|
+
predefined_color_space :
|
|
417
|
+
ansys.api.speos.source.v1.source_pb2.SourceTemplate.PredefinedColorSpace
|
|
418
|
+
default_values : bool
|
|
419
|
+
Uses default values when True.
|
|
420
|
+
stable_ctr : bool
|
|
421
|
+
Variable to indicate if usage is inside class scope
|
|
422
|
+
|
|
423
|
+
Notes
|
|
424
|
+
-----
|
|
425
|
+
**Do not instantiate this class yourself**, use set_predefined_color_space() method.
|
|
426
|
+
"""
|
|
427
|
+
|
|
428
|
+
def __init__(
|
|
429
|
+
self,
|
|
430
|
+
predefined_color_space: source_pb2.SourceTemplate.PredefinedColorSpace,
|
|
431
|
+
default_values: bool = True,
|
|
432
|
+
stable_ctr: bool = False,
|
|
433
|
+
) -> None:
|
|
434
|
+
if not stable_ctr:
|
|
435
|
+
msg = "PredefinedColorSpace class instantiated outside of class scope"
|
|
436
|
+
raise RuntimeError(msg)
|
|
437
|
+
self._predefined_color_space = predefined_color_space
|
|
438
|
+
|
|
439
|
+
if default_values:
|
|
440
|
+
# Default values
|
|
441
|
+
self.set_color_space_srgb()
|
|
442
|
+
|
|
443
|
+
def set_color_space_srgb(self) -> SourceAmbientEnvironment.PredefinedColorSpace:
|
|
444
|
+
"""Set the color space to the srgb preset.
|
|
445
|
+
|
|
446
|
+
Returns
|
|
447
|
+
-------
|
|
448
|
+
ansys.speos.core.source.SourceAmbientEnvironment.PredefinedColorSpace
|
|
449
|
+
"""
|
|
450
|
+
self._predefined_color_space.color_space_type = (
|
|
451
|
+
source_pb2.SourceTemplate.PredefinedColorSpace.sRGB
|
|
452
|
+
)
|
|
453
|
+
return self
|
|
454
|
+
|
|
455
|
+
def set_color_space_adobergb(self) -> SourceAmbientEnvironment.PredefinedColorSpace:
|
|
456
|
+
"""Set the color space to the Adobe RGB preset.
|
|
457
|
+
|
|
458
|
+
Returns
|
|
459
|
+
-------
|
|
460
|
+
ansys.speos.core.source.SourceAmbientEnvironment.PredefinedColorSpace
|
|
461
|
+
"""
|
|
462
|
+
self._predefined_color_space.color_space_type = (
|
|
463
|
+
source_pb2.SourceTemplate.PredefinedColorSpace.AdobeRGB
|
|
464
|
+
)
|
|
465
|
+
return self
|
|
466
|
+
|
|
76
467
|
def __init__(
|
|
77
468
|
self,
|
|
78
469
|
project: project.Project,
|
|
@@ -116,9 +507,11 @@ class BaseSource:
|
|
|
116
507
|
ProtoSourceTemplate.Surface,
|
|
117
508
|
ProtoSourceTemplate.Luminaire,
|
|
118
509
|
],
|
|
510
|
+
field_name_to_complete="",
|
|
119
511
|
spectrum_guid: str = "",
|
|
120
512
|
) -> None:
|
|
121
513
|
self._message_to_complete = message_to_complete
|
|
514
|
+
self._field_name_to_complete = field_name_to_complete
|
|
122
515
|
if spectrum_guid != "":
|
|
123
516
|
self._spectrum = Spectrum(
|
|
124
517
|
speos_client=speos_client,
|
|
@@ -143,7 +536,14 @@ class BaseSource:
|
|
|
143
536
|
def _commit(self) -> BaseSource._Spectrum:
|
|
144
537
|
if not self._no_spectrum_local:
|
|
145
538
|
self._spectrum.commit()
|
|
146
|
-
self.
|
|
539
|
+
if self._field_name_to_complete == "":
|
|
540
|
+
self._message_to_complete.spectrum_guid = self._spectrum.spectrum_link.key
|
|
541
|
+
elif self._field_name_to_complete == "red_spectrum_guid":
|
|
542
|
+
self._message_to_complete.red_spectrum_guid = self._spectrum.spectrum_link.key
|
|
543
|
+
elif self._field_name_to_complete == "green_spectrum_guid":
|
|
544
|
+
self._message_to_complete.green_spectrum_guid = self._spectrum.spectrum_link.key
|
|
545
|
+
elif self._field_name_to_complete == "blue_spectrum_guid":
|
|
546
|
+
self._message_to_complete.blue_spectrum_guid = self._spectrum.spectrum_link.key
|
|
147
547
|
self._no_spectrum = self._no_spectrum_local
|
|
148
548
|
return self
|
|
149
549
|
|
|
@@ -1945,3 +2345,331 @@ class SourceAmbientNaturalLight(BaseSourceAmbient):
|
|
|
1945
2345
|
# Happens in case of feature reset (to be sure to always modify correct data)
|
|
1946
2346
|
self._type._sun = natural_light_properties.sun_axis_system.manual_sun
|
|
1947
2347
|
return self._type
|
|
2348
|
+
|
|
2349
|
+
|
|
2350
|
+
class SourceAmbientEnvironment(BaseSourceAmbient):
|
|
2351
|
+
"""Environment ambient source.
|
|
2352
|
+
|
|
2353
|
+
By default [0, 0, 1] is used as zenith direction, [0, 1, 0] as north direction.
|
|
2354
|
+
|
|
2355
|
+
Parameters
|
|
2356
|
+
----------
|
|
2357
|
+
project : ansys.speos.core.project.Project
|
|
2358
|
+
Project that will own the feature.
|
|
2359
|
+
name : str
|
|
2360
|
+
Name of the feature.
|
|
2361
|
+
description : str
|
|
2362
|
+
Description of the feature.
|
|
2363
|
+
By default, ``""``.
|
|
2364
|
+
metadata : Optional[Mapping[str, str]]
|
|
2365
|
+
Metadata of the feature.
|
|
2366
|
+
By default, ``{}``.
|
|
2367
|
+
default_values : bool
|
|
2368
|
+
Uses default values when True.
|
|
2369
|
+
"""
|
|
2370
|
+
|
|
2371
|
+
# source_type = "SourceAmbientEnvironment"
|
|
2372
|
+
def __init__(
|
|
2373
|
+
self,
|
|
2374
|
+
project: project.Project,
|
|
2375
|
+
name: str,
|
|
2376
|
+
description: str = "",
|
|
2377
|
+
metadata: Optional[Mapping[str, str]] = None,
|
|
2378
|
+
source_instance: Optional[ProtoScene.SourceInstance] = None,
|
|
2379
|
+
default_values: bool = True,
|
|
2380
|
+
) -> None:
|
|
2381
|
+
if metadata is None:
|
|
2382
|
+
metadata = {}
|
|
2383
|
+
|
|
2384
|
+
super().__init__(
|
|
2385
|
+
project=project,
|
|
2386
|
+
name=name,
|
|
2387
|
+
description=description,
|
|
2388
|
+
metadata=metadata,
|
|
2389
|
+
source_instance=source_instance,
|
|
2390
|
+
)
|
|
2391
|
+
self._speos_client = self._project.client
|
|
2392
|
+
self._name = name
|
|
2393
|
+
self._type = None
|
|
2394
|
+
|
|
2395
|
+
if default_values:
|
|
2396
|
+
# Default values
|
|
2397
|
+
self.zenith_direction = [0, 0, 1]
|
|
2398
|
+
self.north_direction = [0, 1, 0]
|
|
2399
|
+
self.reverse_north_direction = False
|
|
2400
|
+
self.reverse_zenith_direction = False
|
|
2401
|
+
self.luminance = 1000
|
|
2402
|
+
self.set_predefined_color_space() # defaults to sRGB
|
|
2403
|
+
|
|
2404
|
+
@property
|
|
2405
|
+
def zenith_direction(self) -> List[float]:
|
|
2406
|
+
"""Zenith direction of the environment light source.
|
|
2407
|
+
|
|
2408
|
+
This property get and set the zenith direction of the environment source.
|
|
2409
|
+
|
|
2410
|
+
Parameters
|
|
2411
|
+
----------
|
|
2412
|
+
direction: Optional[List[float]]
|
|
2413
|
+
direction defines the zenith direction of the environment light source.
|
|
2414
|
+
|
|
2415
|
+
Returns
|
|
2416
|
+
-------
|
|
2417
|
+
List[float]
|
|
2418
|
+
direction defines the zenith direction of the environment light source.
|
|
2419
|
+
|
|
2420
|
+
"""
|
|
2421
|
+
return self._source_instance.ambient_properties.zenith_direction
|
|
2422
|
+
|
|
2423
|
+
@zenith_direction.setter
|
|
2424
|
+
def zenith_direction(self, direction: Optional[List[float]]) -> None:
|
|
2425
|
+
self._source_instance.ambient_properties.zenith_direction[:] = direction
|
|
2426
|
+
|
|
2427
|
+
@property
|
|
2428
|
+
def reverse_zenith_direction(self) -> bool:
|
|
2429
|
+
"""Reverse zenith direction of the environment light source.
|
|
2430
|
+
|
|
2431
|
+
This property get and set if reverse zenith direction is True.
|
|
2432
|
+
|
|
2433
|
+
|
|
2434
|
+
Parameters
|
|
2435
|
+
----------
|
|
2436
|
+
value: bool
|
|
2437
|
+
True to reverse zenith direction, False otherwise.
|
|
2438
|
+
|
|
2439
|
+
Returns
|
|
2440
|
+
-------
|
|
2441
|
+
bool
|
|
2442
|
+
True to reverse zenith direction, False otherwise.
|
|
2443
|
+
|
|
2444
|
+
"""
|
|
2445
|
+
return self._source_instance.ambient_properties.reverse_zenith
|
|
2446
|
+
|
|
2447
|
+
@reverse_zenith_direction.setter
|
|
2448
|
+
def reverse_zenith_direction(self, value: bool) -> None:
|
|
2449
|
+
self._source_instance.ambient_properties.reverse_zenith = value
|
|
2450
|
+
|
|
2451
|
+
@property
|
|
2452
|
+
def north_direction(self) -> List[float]:
|
|
2453
|
+
"""North direction of the environment light source.
|
|
2454
|
+
|
|
2455
|
+
This property get and set the north direction of the environment source.
|
|
2456
|
+
|
|
2457
|
+
Parameters
|
|
2458
|
+
----------
|
|
2459
|
+
direction: List[float]
|
|
2460
|
+
direction defines the north direction, default value to be [0, 1, 0].
|
|
2461
|
+
|
|
2462
|
+
Returns
|
|
2463
|
+
-------
|
|
2464
|
+
List[float]
|
|
2465
|
+
direction defines the north direction of the environment source.
|
|
2466
|
+
|
|
2467
|
+
"""
|
|
2468
|
+
return self._source_instance.ambient_properties.environment_map_properties.north_direction
|
|
2469
|
+
|
|
2470
|
+
@north_direction.setter
|
|
2471
|
+
def north_direction(self, direction: List[float]) -> None:
|
|
2472
|
+
self._source_instance.ambient_properties.environment_map_properties.north_direction[:] = (
|
|
2473
|
+
direction
|
|
2474
|
+
)
|
|
2475
|
+
|
|
2476
|
+
@property
|
|
2477
|
+
def reverse_north_direction(self) -> bool:
|
|
2478
|
+
"""Reverse north direction of the environment light source.
|
|
2479
|
+
|
|
2480
|
+
This property get and set if reverse north direction is True.
|
|
2481
|
+
|
|
2482
|
+
Parameters
|
|
2483
|
+
----------
|
|
2484
|
+
value: bool
|
|
2485
|
+
True to reverse north direction, False otherwise.
|
|
2486
|
+
|
|
2487
|
+
Returns
|
|
2488
|
+
-------
|
|
2489
|
+
bool
|
|
2490
|
+
True as reverse north direction, False otherwise.
|
|
2491
|
+
|
|
2492
|
+
"""
|
|
2493
|
+
return self._source_instance.ambient_properties.environment_map_properties.reverse_north
|
|
2494
|
+
|
|
2495
|
+
@reverse_north_direction.setter
|
|
2496
|
+
def reverse_north_direction(self, value: bool) -> None:
|
|
2497
|
+
self._source_instance.ambient_properties.environment_map_properties.reverse_north = value
|
|
2498
|
+
|
|
2499
|
+
@property
|
|
2500
|
+
def luminance(self) -> float:
|
|
2501
|
+
"""Luminance of the environment light source.
|
|
2502
|
+
|
|
2503
|
+
This property get and set the Luminance value of the source.
|
|
2504
|
+
|
|
2505
|
+
Parameters
|
|
2506
|
+
----------
|
|
2507
|
+
value: float
|
|
2508
|
+
set value of Luminance (cd/m^2).
|
|
2509
|
+
|
|
2510
|
+
Returns
|
|
2511
|
+
-------
|
|
2512
|
+
float
|
|
2513
|
+
value of Luminance setting (cd/m^2).
|
|
2514
|
+
|
|
2515
|
+
"""
|
|
2516
|
+
return self._source_template.ambient.environment_map.luminance
|
|
2517
|
+
|
|
2518
|
+
@luminance.setter
|
|
2519
|
+
def luminance(self, value: float) -> None:
|
|
2520
|
+
self._source_template.ambient.environment_map.luminance = value
|
|
2521
|
+
|
|
2522
|
+
@property
|
|
2523
|
+
def image_file_uri(self) -> str:
|
|
2524
|
+
"""Location of the environment image file.
|
|
2525
|
+
|
|
2526
|
+
This property gets or sets the environment image file used by the
|
|
2527
|
+
ambient environment source.
|
|
2528
|
+
|
|
2529
|
+
Parameters
|
|
2530
|
+
----------
|
|
2531
|
+
uri : Union[str, Path]
|
|
2532
|
+
format file uri (hdr, exr, png, bmp, jpg, tiff, rgb).
|
|
2533
|
+
|
|
2534
|
+
Returns
|
|
2535
|
+
-------
|
|
2536
|
+
uri : str
|
|
2537
|
+
format file uri (hdr, exr, png, bmp, jpg, tiff, rgb).
|
|
2538
|
+
"""
|
|
2539
|
+
return self._source_template.ambient.environment_map.image_uri
|
|
2540
|
+
|
|
2541
|
+
@image_file_uri.setter
|
|
2542
|
+
def image_file_uri(self, uri: Union[str, Path]) -> None:
|
|
2543
|
+
self._source_template.ambient.environment_map.image_uri = str(uri)
|
|
2544
|
+
|
|
2545
|
+
@property
|
|
2546
|
+
def color_space(
|
|
2547
|
+
self,
|
|
2548
|
+
) -> Union[
|
|
2549
|
+
None,
|
|
2550
|
+
SourceAmbientEnvironment.PredefinedColorSpace,
|
|
2551
|
+
SourceAmbientEnvironment.UserDefinedColorSpace,
|
|
2552
|
+
]:
|
|
2553
|
+
"""Property containing all options in regard to the color space properties.
|
|
2554
|
+
|
|
2555
|
+
Returns
|
|
2556
|
+
-------
|
|
2557
|
+
Union[
|
|
2558
|
+
None,
|
|
2559
|
+
ansys.speos.core.source.SourceAmbientEnvironment.PredefinedColorSpace,
|
|
2560
|
+
ansys.speos.core.source.SourceAmbientEnvironment.UserDefinedColorSpace
|
|
2561
|
+
]
|
|
2562
|
+
Instance of Predefined Color Space class
|
|
2563
|
+
"""
|
|
2564
|
+
return self._type
|
|
2565
|
+
|
|
2566
|
+
def set_userdefined_color_space(self) -> SourceAmbientEnvironment.UserDefinedColorSpace:
|
|
2567
|
+
"""Set the color space to user-defined.
|
|
2568
|
+
|
|
2569
|
+
Returns
|
|
2570
|
+
-------
|
|
2571
|
+
SourceAmbientEnvironment.UserDefinedColorSpace
|
|
2572
|
+
Settings for user defined color space.
|
|
2573
|
+
|
|
2574
|
+
"""
|
|
2575
|
+
if self._type is None and self._source_template.ambient.environment_map.HasField(
|
|
2576
|
+
"user_defined_rgb_space"
|
|
2577
|
+
):
|
|
2578
|
+
self._type = SourceAmbientEnvironment.UserDefinedColorSpace(
|
|
2579
|
+
project=self._project,
|
|
2580
|
+
userdefined_color_space=self._source_template.ambient.environment_map.user_defined_rgb_space,
|
|
2581
|
+
default_values=False,
|
|
2582
|
+
stable_ctr=True,
|
|
2583
|
+
)
|
|
2584
|
+
if not isinstance(self._type, SourceAmbientEnvironment.UserDefinedColorSpace):
|
|
2585
|
+
# if the _type is not UserDefinedColorSpace then we create a new type.
|
|
2586
|
+
self._type = SourceAmbientEnvironment.UserDefinedColorSpace(
|
|
2587
|
+
project=self._project,
|
|
2588
|
+
userdefined_color_space=self._source_template.ambient.environment_map.user_defined_rgb_space,
|
|
2589
|
+
stable_ctr=True,
|
|
2590
|
+
)
|
|
2591
|
+
elif (
|
|
2592
|
+
self._type._userdefined_color_space
|
|
2593
|
+
is not self._source_template.ambient.environment_map.user_defined_rgb_space
|
|
2594
|
+
):
|
|
2595
|
+
# Happens in case of feature reset (to be sure to always modify correct data)
|
|
2596
|
+
self._type._userdefined_color_space = (
|
|
2597
|
+
self._source_template.ambient.environment_map.user_defined_rgb_space
|
|
2598
|
+
)
|
|
2599
|
+
return self._type
|
|
2600
|
+
|
|
2601
|
+
def set_predefined_color_space(self) -> SourceAmbientEnvironment.PredefinedColorSpace:
|
|
2602
|
+
"""Set the color space to use one of the presets.
|
|
2603
|
+
|
|
2604
|
+
Returns
|
|
2605
|
+
-------
|
|
2606
|
+
ansys.speos.core.source.SourceAmbientEnvironment.PredefinedColorSpace
|
|
2607
|
+
Environment source color space for sRGB or AdobeRGB
|
|
2608
|
+
"""
|
|
2609
|
+
if self._type is None and self._source_template.ambient.environment_map.HasField(
|
|
2610
|
+
"predefined_color_space"
|
|
2611
|
+
):
|
|
2612
|
+
self._type = SourceAmbientEnvironment.PredefinedColorSpace(
|
|
2613
|
+
predefined_color_space=self._source_template.ambient.environment_map.predefined_color_space,
|
|
2614
|
+
default_values=False,
|
|
2615
|
+
stable_ctr=True,
|
|
2616
|
+
)
|
|
2617
|
+
if not isinstance(self._type, SourceAmbientEnvironment.PredefinedColorSpace):
|
|
2618
|
+
# if the _type is not PredefinedColorSpace then we create a new type.
|
|
2619
|
+
self._type = SourceAmbientEnvironment.PredefinedColorSpace(
|
|
2620
|
+
predefined_color_space=self._source_template.ambient.environment_map.predefined_color_space,
|
|
2621
|
+
stable_ctr=True,
|
|
2622
|
+
)
|
|
2623
|
+
elif (
|
|
2624
|
+
self._type._predefined_color_space
|
|
2625
|
+
is not self._source_template.ambient.environment_map.predefined_color_space
|
|
2626
|
+
):
|
|
2627
|
+
# Happens in case of feature reset (to be sure to always modify correct data)
|
|
2628
|
+
self._type._predefined_color_space = (
|
|
2629
|
+
self._source_template.ambient.environment_map.predefined_color_space
|
|
2630
|
+
)
|
|
2631
|
+
return self._type
|
|
2632
|
+
|
|
2633
|
+
def commit(self) -> SourceAmbientEnvironment:
|
|
2634
|
+
"""Save feature: send the local data to the speos server database.
|
|
2635
|
+
|
|
2636
|
+
Returns
|
|
2637
|
+
-------
|
|
2638
|
+
ansys.speos.core.source.SourceAmbientEnvironment
|
|
2639
|
+
Ambient environment Source feature.
|
|
2640
|
+
"""
|
|
2641
|
+
if isinstance(self._type, BaseSource.UserDefinedColorSpace):
|
|
2642
|
+
self._type._red_spectrum._commit()
|
|
2643
|
+
self._type._green_spectrum._commit()
|
|
2644
|
+
self._type._blue_spectrum._commit()
|
|
2645
|
+
super().commit()
|
|
2646
|
+
|
|
2647
|
+
def reset(self) -> SourceAmbientEnvironment:
|
|
2648
|
+
"""Reset feature: override local data by the one from the speos server database.
|
|
2649
|
+
|
|
2650
|
+
Returns
|
|
2651
|
+
-------
|
|
2652
|
+
ansys.speos.core.source.SourceAmbientEnvironment
|
|
2653
|
+
Ambient environment Source feature.
|
|
2654
|
+
"""
|
|
2655
|
+
if isinstance(self._type, BaseSource.UserDefinedColorSpace):
|
|
2656
|
+
self._type._red_spectrum._reset()
|
|
2657
|
+
self._type._green_spectrum._reset()
|
|
2658
|
+
self._type._blue_spectrum._reset()
|
|
2659
|
+
super().reset()
|
|
2660
|
+
|
|
2661
|
+
def delete(self) -> SourceAmbientEnvironment:
|
|
2662
|
+
"""Delete feature: delete data from the speos server database.
|
|
2663
|
+
|
|
2664
|
+
The local data are still available
|
|
2665
|
+
|
|
2666
|
+
Returns
|
|
2667
|
+
-------
|
|
2668
|
+
ansys.speos.core.source.SourceAmbientEnvironment
|
|
2669
|
+
Ambient environment Source feature.
|
|
2670
|
+
"""
|
|
2671
|
+
if isinstance(self._type, BaseSource.UserDefinedColorSpace):
|
|
2672
|
+
self._type._red_spectrum._delete()
|
|
2673
|
+
self._type._green_spectrum._delete()
|
|
2674
|
+
self._type._blue_spectrum._delete()
|
|
2675
|
+
super().delete()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/generic/general_methods.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/kernel/intensity_template.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/kernel/proto_message_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
{ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/kernel/sensor_template.py
RENAMED
|
File without changes
|
{ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/kernel/simulation_template.py
RENAMED
|
File without changes
|
{ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/kernel/sop_template.py
RENAMED
|
File without changes
|
{ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/kernel/source_template.py
RENAMED
|
File without changes
|
|
File without changes
|
{ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/kernel/vop_template.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/proto_message_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/workflow/combine_speos.py
RENAMED
|
File without changes
|
{ansys_speos_core-0.7.1 → ansys_speos_core-0.7.2}/src/ansys/speos/core/workflow/open_result.py
RENAMED
|
File without changes
|