topologicpy 0.5.8__py3-none-any.whl → 6.0.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.
- topologicpy/Aperture.py +72 -72
- topologicpy/Cell.py +2169 -2169
- topologicpy/CellComplex.py +1137 -1137
- topologicpy/Cluster.py +1288 -1280
- topologicpy/Color.py +423 -393
- topologicpy/Context.py +79 -79
- topologicpy/DGL.py +3213 -3136
- topologicpy/Dictionary.py +698 -695
- topologicpy/Edge.py +1187 -1187
- topologicpy/EnergyModel.py +1180 -1171
- topologicpy/Face.py +2141 -2141
- topologicpy/Graph.py +7768 -7700
- topologicpy/Grid.py +353 -353
- topologicpy/Helper.py +507 -507
- topologicpy/Honeybee.py +461 -461
- topologicpy/Matrix.py +271 -271
- topologicpy/Neo4j.py +521 -521
- topologicpy/Plotly.py +2 -2
- topologicpy/Polyskel.py +541 -541
- topologicpy/Shell.py +1768 -1768
- topologicpy/Speckle.py +508 -508
- topologicpy/Topology.py +7060 -6988
- topologicpy/Vector.py +905 -905
- topologicpy/Vertex.py +1585 -1585
- topologicpy/Wire.py +3050 -3050
- topologicpy/__init__.py +22 -38
- topologicpy/version.py +1 -0
- {topologicpy-0.5.8.dist-info → topologicpy-6.0.0.dist-info}/LICENSE +661 -704
- topologicpy-6.0.0.dist-info/METADATA +751 -0
- topologicpy-6.0.0.dist-info/RECORD +32 -0
- topologicpy/bin/linux/topologic/__init__.py +0 -2
- topologicpy/bin/linux/topologic/libTKBO-6bdf205d.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKBRep-2960a069.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKBool-c44b74bd.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKFillet-9a670ba0.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKG2d-8f31849e.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKG3d-4c6bce57.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKGeomAlgo-26066fd9.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKGeomBase-2116cabe.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKMath-72572fa8.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKMesh-2a060427.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKOffset-6cab68ff.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKPrim-eb1262b3.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKShHealing-e67e5cc7.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKTopAlgo-e4c96c33.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libTKernel-fb7fe3b7.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic/libgcc_s-32c1665e.so.1 +0 -0
- topologicpy/bin/linux/topologic/libstdc++-672d7b41.so.6.0.30 +0 -0
- topologicpy/bin/linux/topologic/topologic.cpython-310-x86_64-linux-gnu.so +0 -0
- topologicpy/bin/linux/topologic/topologic.cpython-311-x86_64-linux-gnu.so +0 -0
- topologicpy/bin/linux/topologic/topologic.cpython-38-x86_64-linux-gnu.so +0 -0
- topologicpy/bin/linux/topologic/topologic.cpython-39-x86_64-linux-gnu.so +0 -0
- topologicpy/bin/linux/topologic.libs/libTKBO-6bdf205d.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKBRep-2960a069.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKBool-c44b74bd.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKFillet-9a670ba0.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKG2d-8f31849e.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKG3d-4c6bce57.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKGeomAlgo-26066fd9.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKGeomBase-2116cabe.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKMath-72572fa8.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKMesh-2a060427.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKOffset-6cab68ff.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKPrim-eb1262b3.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKShHealing-e67e5cc7.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKTopAlgo-e4c96c33.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKernel-fb7fe3b7.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libgcc_s-32c1665e.so.1 +0 -0
- topologicpy/bin/linux/topologic.libs/libstdc++-672d7b41.so.6.0.30 +0 -0
- topologicpy/bin/macos/topologic/__init__.py +0 -2
- topologicpy/bin/windows/topologic/TKBO-f6b191de.dll +0 -0
- topologicpy/bin/windows/topologic/TKBRep-e56a600e.dll +0 -0
- topologicpy/bin/windows/topologic/TKBool-7b8d47ae.dll +0 -0
- topologicpy/bin/windows/topologic/TKFillet-0ddbf0a8.dll +0 -0
- topologicpy/bin/windows/topologic/TKG2d-2e2dee3d.dll +0 -0
- topologicpy/bin/windows/topologic/TKG3d-6674513d.dll +0 -0
- topologicpy/bin/windows/topologic/TKGeomAlgo-d240e370.dll +0 -0
- topologicpy/bin/windows/topologic/TKGeomBase-df87aba5.dll +0 -0
- topologicpy/bin/windows/topologic/TKMath-45bd625a.dll +0 -0
- topologicpy/bin/windows/topologic/TKMesh-d6e826b1.dll +0 -0
- topologicpy/bin/windows/topologic/TKOffset-79b9cc94.dll +0 -0
- topologicpy/bin/windows/topologic/TKPrim-aa430a86.dll +0 -0
- topologicpy/bin/windows/topologic/TKShHealing-bb48be89.dll +0 -0
- topologicpy/bin/windows/topologic/TKTopAlgo-7d0d1e22.dll +0 -0
- topologicpy/bin/windows/topologic/TKernel-08c8cfbb.dll +0 -0
- topologicpy/bin/windows/topologic/__init__.py +0 -2
- topologicpy/bin/windows/topologic/topologic.cp310-win_amd64.pyd +0 -0
- topologicpy/bin/windows/topologic/topologic.cp311-win_amd64.pyd +0 -0
- topologicpy/bin/windows/topologic/topologic.cp38-win_amd64.pyd +0 -0
- topologicpy/bin/windows/topologic/topologic.cp39-win_amd64.pyd +0 -0
- topologicpy-0.5.8.dist-info/METADATA +0 -96
- topologicpy-0.5.8.dist-info/RECORD +0 -91
- {topologicpy-0.5.8.dist-info → topologicpy-6.0.0.dist-info}/WHEEL +0 -0
- {topologicpy-0.5.8.dist-info → topologicpy-6.0.0.dist-info}/top_level.txt +0 -0
topologicpy/Grid.py
CHANGED
@@ -1,354 +1,354 @@
|
|
1
|
-
# Copyright (C) 2024
|
2
|
-
# Wassim Jabi <wassim.jabi@gmail.com>
|
3
|
-
#
|
4
|
-
# This program is free software: you can redistribute it and/or modify it under
|
5
|
-
# the terms of the GNU Affero General Public License as published by the Free Software
|
6
|
-
# Foundation, either version 3 of the License, or (at your option) any later
|
7
|
-
# version.
|
8
|
-
#
|
9
|
-
# This program is distributed in the hope that it will be useful, but WITHOUT
|
10
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
11
|
-
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
12
|
-
# details.
|
13
|
-
#
|
14
|
-
# You should have received a copy of the GNU Affero General Public License along with
|
15
|
-
# this program. If not, see <https://www.gnu.org/licenses/>.
|
16
|
-
|
17
|
-
import topologic
|
18
|
-
|
19
|
-
class Grid(topologic.Cluster):
|
20
|
-
@staticmethod
|
21
|
-
def EdgesByDistances(face=None, uOrigin=None, vOrigin=None, uRange=[-0.5,-0.25,0, 0.25,0.5], vRange=[-0.5,-0.25,0, 0.25,0.5], clip=False, tolerance=0.0001):
|
22
|
-
"""
|
23
|
-
Creates a grid (cluster of edges).
|
24
|
-
|
25
|
-
Parameters
|
26
|
-
----------
|
27
|
-
face : topologic.Face , optional
|
28
|
-
The input face. If set to None, the grid will be created on the XY plane. The default is None.
|
29
|
-
uOrigin : topologic.Vertex , optional
|
30
|
-
The origin of the *u* grid lines. If set to None: if the face is set, the uOrigin will be set to vertex at the face's 0,0 paratmer. If the face is set to None, the uOrigin will be set to the origin. The default is None.
|
31
|
-
vOrigin : topologic.Vertex , optional
|
32
|
-
The origin of the *v* grid lines. If set to None: if the face is set, the vOrigin will be set to vertex at the face's 0,0 paratmer. If the face is set to None, the vOrigin will be set to the origin. The default is None.
|
33
|
-
uRange : list , optional
|
34
|
-
A list of distances for the *u* grid lines from the uOrigin. The default is [-0.5,-0.25,0, 0.25,0.5].
|
35
|
-
vRange : list , optional
|
36
|
-
A list of distances for the *v* grid lines from the vOrigin. The default is [-0.5,-0.25,0, 0.25,0.5].
|
37
|
-
clip : bool , optional
|
38
|
-
If True the grid will be clipped by the shape of the input face. The default is False.
|
39
|
-
tolerance : float , optional
|
40
|
-
The desired tolerance. The default is 0.0001.
|
41
|
-
|
42
|
-
Returns
|
43
|
-
-------
|
44
|
-
topologic.Cluster
|
45
|
-
The created grid. Edges in the grid have an identifying dictionary with two keys: "dir" and "offset". The "dir" key can have one of two values: "u" or "v", the "offset" key contains the offset distance of that grid edge from the specified origin.
|
46
|
-
|
47
|
-
"""
|
48
|
-
from topologicpy.Vertex import Vertex
|
49
|
-
from topologicpy.Edge import Edge
|
50
|
-
from topologicpy.Face import Face
|
51
|
-
from topologicpy.Cluster import Cluster
|
52
|
-
from topologicpy.Topology import Topology
|
53
|
-
from topologicpy.Dictionary import Dictionary
|
54
|
-
from topologicpy.Vector import Vector
|
55
|
-
if len(uRange) < 1 or len(vRange) < 1:
|
56
|
-
return None
|
57
|
-
if not uOrigin:
|
58
|
-
if not isinstance(face, topologic.Face):
|
59
|
-
uOrigin = Vertex.ByCoordinates(0, 0, 0)
|
60
|
-
else:
|
61
|
-
uOrigin = Face.VertexByParameters(face, 0, 0)
|
62
|
-
if not vOrigin:
|
63
|
-
if not isinstance(face, topologic.Face):
|
64
|
-
vOrigin = Vertex.ByCoordinates(0, 0, 0)
|
65
|
-
else:
|
66
|
-
vOrigin = Face.VertexByParameters(face, 0, 0)
|
67
|
-
|
68
|
-
if isinstance(face, topologic.Face):
|
69
|
-
v1 = Face.VertexByParameters(face, 0, 0)
|
70
|
-
v2 = Face.VertexByParameters(face, 1, 0)
|
71
|
-
v3 = Face.VertexByParameters(face, 0, 0)
|
72
|
-
v4 = Face.VertexByParameters(face, 0, 1)
|
73
|
-
else:
|
74
|
-
v1 = Vertex.ByCoordinates(0, 0, 0)
|
75
|
-
v2 = Vertex.ByCoordinates(max(uRange),0,0)
|
76
|
-
v3 = Vertex.ByCoordinates(0, 0, 0)
|
77
|
-
v4 = Vertex.ByCoordinates(0,max(vRange),0)
|
78
|
-
|
79
|
-
uVector = [v2.X()-v1.X(), v2.Y()-v1.Y(),v2.Z()-v1.Z()]
|
80
|
-
vVector = [v4.X()-v3.X(), v4.Y()-v3.Y(),v4.Z()-v3.Z()]
|
81
|
-
gridEdges = []
|
82
|
-
if len(uRange) > 0:
|
83
|
-
uRange.sort()
|
84
|
-
uuVector = Vector.Normalize(uVector)
|
85
|
-
for u in uRange:
|
86
|
-
tempVec = Vector.Multiply(uuVector, u, tolerance)
|
87
|
-
v1 = Vertex.ByCoordinates(uOrigin.X()+tempVec[0], uOrigin.Y()+tempVec[1], uOrigin.Z()+tempVec[2])
|
88
|
-
v2 = Vertex.ByCoordinates(v1.X()+vVector[0], v1.Y()+vVector[1], v1.Z()+vVector[2])
|
89
|
-
e = Edge.ByVertices([v1, v2], tolerance=tolerance)
|
90
|
-
if clip and isinstance(face, topologic.Face):
|
91
|
-
e = e.Intersect(face, False)
|
92
|
-
if e:
|
93
|
-
if isinstance(e, topologic.Edge):
|
94
|
-
d = Dictionary.ByKeysValues(["dir", "offset"],["u",u])
|
95
|
-
e.SetDictionary(d)
|
96
|
-
gridEdges.append(e)
|
97
|
-
elif e.Type() > topologic.Edge.Type():
|
98
|
-
tempEdges = []
|
99
|
-
_ = e.Edges(None, tempEdges)
|
100
|
-
for tempEdge in tempEdges:
|
101
|
-
d = Dictionary.ByKeysValues(["dir", "offset"],["u",u])
|
102
|
-
tempEdge.SetDictionary(d)
|
103
|
-
gridEdges.append(tempEdge)
|
104
|
-
if len(vRange) > 0:
|
105
|
-
vRange.sort()
|
106
|
-
uvVector = Vector.Normalize(vVector)
|
107
|
-
for v in vRange:
|
108
|
-
tempVec = Vector.Multiply(uvVector, v, tolerance)
|
109
|
-
v1 = Vertex.ByCoordinates(vOrigin.X()+tempVec[0], vOrigin.Y()+tempVec[1], vOrigin.Z()+tempVec[2])
|
110
|
-
v2 = Vertex.ByCoordinates(v1.X()+uVector[0], v1.Y()+uVector[1], v1.Z()+uVector[2])
|
111
|
-
e = Edge.ByVertices([v1, v2], tolerance=tolerance)
|
112
|
-
if clip and isinstance(face, topologic.Face):
|
113
|
-
e = e.Intersect(face, False)
|
114
|
-
if e:
|
115
|
-
if isinstance(e, topologic.Edge):
|
116
|
-
d = Dictionary.ByKeysValues(["dir", "offset"],["v",v])
|
117
|
-
e.SetDictionary(d)
|
118
|
-
gridEdges.append(e)
|
119
|
-
elif e.Type() > topologic.Edge.Type():
|
120
|
-
tempEdges = []
|
121
|
-
_ = e.Edges(None, tempEdges)
|
122
|
-
for tempEdge in tempEdges:
|
123
|
-
d = Dictionary.ByKeysValues(["dir", "offset"],["v",v])
|
124
|
-
tempEdge.SetDictionary(d)
|
125
|
-
gridEdges.append(tempEdge)
|
126
|
-
grid = None
|
127
|
-
if len(gridEdges) > 0:
|
128
|
-
grid = Cluster.ByTopologies(gridEdges)
|
129
|
-
return grid
|
130
|
-
|
131
|
-
@staticmethod
|
132
|
-
def EdgesByParameters(face, uRange=[0,0.25,0.5,0.75,1.0], vRange=[0,0.25,0.5,0.75,1.0], clip=False, tolerance=0.0001):
|
133
|
-
"""
|
134
|
-
Creates a grid (cluster of edges).
|
135
|
-
|
136
|
-
Parameters
|
137
|
-
----------
|
138
|
-
face : topologic.Face
|
139
|
-
The input face.
|
140
|
-
uRange : list , optional
|
141
|
-
A list of *u* parameters for the *u* grid lines. The default is [0,0.25,0.5, 0.75, 1.0].
|
142
|
-
vRange : list , optional
|
143
|
-
A list of *v* parameters for the *v* grid lines. The default is [0,0.25,0.5, 0.75, 1.0].
|
144
|
-
clip : bool , optional
|
145
|
-
If True the grid will be clipped by the shape of the input face. The default is False.
|
146
|
-
tolerance : float , optional
|
147
|
-
The desired tolerance. The default is 0.0001.
|
148
|
-
|
149
|
-
Returns
|
150
|
-
-------
|
151
|
-
topologic.Cluster
|
152
|
-
The created grid. Edges in the grid have an identifying dictionary with two keys: "dir" and "offset". The "dir" key can have one of two values: "u" or "v", the "offset" key contains the offset parameter of that grid edge.
|
153
|
-
|
154
|
-
"""
|
155
|
-
from topologicpy.Vertex import Vertex
|
156
|
-
from topologicpy.Edge import Edge
|
157
|
-
from topologicpy.Face import Face
|
158
|
-
from topologicpy.Cluster import Cluster
|
159
|
-
from topologicpy.Dictionary import Dictionary
|
160
|
-
|
161
|
-
if not isinstance(face, topologic.Face):
|
162
|
-
return None
|
163
|
-
if len(uRange) < 1 and len(vRange) < 1:
|
164
|
-
return None
|
165
|
-
if len(uRange) > 0:
|
166
|
-
if (min(uRange) < 0) or (max(uRange) > 1):
|
167
|
-
return None
|
168
|
-
if len(vRange) > 0:
|
169
|
-
if (min(vRange) < 0) or (max(vRange) > 1):
|
170
|
-
return None
|
171
|
-
|
172
|
-
uRange.sort()
|
173
|
-
vRange.sort()
|
174
|
-
gridEdges = []
|
175
|
-
for u in uRange:
|
176
|
-
v1 = Face.VertexByParameters(face, u, 0)
|
177
|
-
v2 = Face.VertexByParameters(face, u, 1)
|
178
|
-
e = Edge.ByVertices([v1, v2], tolerance=tolerance)
|
179
|
-
if clip and isinstance(face, topologic.Face):
|
180
|
-
e = e.Intersect(face, False)
|
181
|
-
if e:
|
182
|
-
if isinstance(e, topologic.Edge):
|
183
|
-
d = Dictionary.ByKeysValues(["dir", "offset"],["u",u])
|
184
|
-
e.SetDictionary(d)
|
185
|
-
gridEdges.append(e)
|
186
|
-
elif e.Type() > topologic.Edge.Type():
|
187
|
-
tempEdges = []
|
188
|
-
_ = e.Edges(None, tempEdges)
|
189
|
-
for tempEdge in tempEdges:
|
190
|
-
d = Dictionary.ByKeysValues(["dir", "offset"],["u",u])
|
191
|
-
tempEdge.SetDictionary(d)
|
192
|
-
gridEdges.append(tempEdge)
|
193
|
-
for v in vRange:
|
194
|
-
v1 = Face.VertexByParameters(face, 0, v)
|
195
|
-
v2 = Face.VertexByParameters(face, 1, v)
|
196
|
-
e = Edge.ByVertices([v1, v2], tolerance=tolerance)
|
197
|
-
if clip and isinstance(face, topologic.Face):
|
198
|
-
e = e.Intersect(face, False)
|
199
|
-
if e:
|
200
|
-
if isinstance(e, topologic.Edge):
|
201
|
-
d = Dictionary.ByKeysValues(["dir", "offset"],["v",v])
|
202
|
-
e.SetDictionary(d)
|
203
|
-
gridEdges.append(e)
|
204
|
-
elif e.Type() > topologic.Edge.Type():
|
205
|
-
tempEdges = []
|
206
|
-
_ = e.Edges(None, tempEdges)
|
207
|
-
for tempEdge in tempEdges:
|
208
|
-
d = Dictionary.ByKeysValues(["dir", "offset"],["v",v])
|
209
|
-
tempEdge.SetDictionary(d)
|
210
|
-
gridEdges.append(tempEdge)
|
211
|
-
grid = None
|
212
|
-
if len(gridEdges) > 0:
|
213
|
-
grid = Cluster.ByTopologies(gridEdges)
|
214
|
-
return grid
|
215
|
-
|
216
|
-
|
217
|
-
@staticmethod
|
218
|
-
def VerticesByDistances(face=None, origin=None, uRange=[-0.5,-0.25,0, 0.25,0.5], vRange=[-0.5,-0.25,0,0.25,0.5], clip=False, tolerance=0.0001):
|
219
|
-
"""
|
220
|
-
Creates a grid (cluster of vertices).
|
221
|
-
|
222
|
-
Parameters
|
223
|
-
----------
|
224
|
-
face : topologic.Face , optional
|
225
|
-
The input face. If set to None, the grid will be created on the XY plane. The default is None.
|
226
|
-
origin : topologic.Vertex , optional
|
227
|
-
The origin of the grid vertices. If set to None: if the face is set, the origin will be set to vertex at the face's 0,0 paratmer. If the face is set to None, the origin will be set to (0, 0, 0). The default is None.
|
228
|
-
uRange : list , optional
|
229
|
-
A list of distances for the *u* grid lines from the uOrigin. The default is [-0.5,-0.25,0, 0.25,0.5].
|
230
|
-
vRange : list , optional
|
231
|
-
A list of distances for the *v* grid lines from the vOrigin. The default is [-0.5,-0.25,0, 0.25,0.5].
|
232
|
-
clip : bool , optional
|
233
|
-
If True the grid will be clipped by the shape of the input face. The default is False.
|
234
|
-
tolerance : float , optional
|
235
|
-
The desired tolerance. The default is 0.0001.
|
236
|
-
|
237
|
-
Returns
|
238
|
-
-------
|
239
|
-
topologic.Cluster
|
240
|
-
The created grid. Vertices in the grid have an identifying dictionary with two keys: "u" and "v". The "dir" key can have one of two values: "u" or "v" that contain the *u* and *v* offset distances of that grid vertex from the specified origin.
|
241
|
-
|
242
|
-
"""
|
243
|
-
from topologicpy.Vertex import Vertex
|
244
|
-
from topologicpy.Edge import Edge
|
245
|
-
from topologicpy.Face import Face
|
246
|
-
from topologicpy.Cluster import Cluster
|
247
|
-
from topologicpy.Topology import Topology
|
248
|
-
from topologicpy.Dictionary import Dictionary
|
249
|
-
from topologicpy.Vector import Vector
|
250
|
-
if len(uRange) < 1 or len(vRange) < 1:
|
251
|
-
return None
|
252
|
-
if not origin:
|
253
|
-
if not isinstance(face, topologic.Face):
|
254
|
-
origin = Vertex.ByCoordinates(0, 0, 0)
|
255
|
-
else:
|
256
|
-
origin = Face.VertexByParameters(face, 0, 0)
|
257
|
-
|
258
|
-
if isinstance(face, topologic.Face):
|
259
|
-
v1 = Face.VertexByParameters(face, 0, 0)
|
260
|
-
v2 = Face.VertexByParameters(face, 1, 0)
|
261
|
-
v3 = Face.VertexByParameters(face, 0, 0)
|
262
|
-
v4 = Face.VertexByParameters(face, 0, 1)
|
263
|
-
else:
|
264
|
-
v1 = Vertex.ByCoordinates(0, 0, 0)
|
265
|
-
v2 = Vertex.ByCoordinates(max(uRange),0,0)
|
266
|
-
v3 = Vertex.ByCoordinates(0, 0, 0)
|
267
|
-
v4 = Vertex.ByCoordinates(0,max(vRange),0)
|
268
|
-
|
269
|
-
uVector = [v2.X()-v1.X(), v2.Y()-v1.Y(),v2.Z()-v1.Z()]
|
270
|
-
vVector = [v4.X()-v3.X(), v4.Y()-v3.Y(),v4.Z()-v3.Z()]
|
271
|
-
gridVertices = []
|
272
|
-
if len(uRange) > 0:
|
273
|
-
uRange.sort()
|
274
|
-
uuVector = Vector.Normalize(uVector)
|
275
|
-
uvVector = Vector.Normalize(vVector)
|
276
|
-
for u in uRange:
|
277
|
-
for v in vRange:
|
278
|
-
uTempVec = Vector.Multiply(uuVector, u, tolerance)
|
279
|
-
vTempVec = Vector.Multiply(uvVector, v, tolerance)
|
280
|
-
gridVertex = Vertex.ByCoordinates(origin.X()+uTempVec[0], origin.Y()+vTempVec[1], origin.Z()+uTempVec[2])
|
281
|
-
if clip and isinstance(face, topologic.Face):
|
282
|
-
gridVertex = gridVertex.Intersect(face, False)
|
283
|
-
if isinstance(gridVertex, topologic.Vertex):
|
284
|
-
d = Dictionary.ByKeysValues(["u","v"],[u,v])
|
285
|
-
if d:
|
286
|
-
gridVertex.SetDictionary(d)
|
287
|
-
gridVertices.append(gridVertex)
|
288
|
-
grid = None
|
289
|
-
if len(gridVertices) > 0:
|
290
|
-
grid = Cluster.ByTopologies(gridVertices)
|
291
|
-
return grid
|
292
|
-
|
293
|
-
@staticmethod
|
294
|
-
def VerticesByParameters(face=None, uRange=[0.0,0.25,0.5,0.75,1.0], vRange=[0.0,0.25,0.5,0.75,1.0], clip=False, tolerance=0.0001):
|
295
|
-
"""
|
296
|
-
Creates a grid (cluster of vertices).
|
297
|
-
|
298
|
-
Parameters
|
299
|
-
----------
|
300
|
-
face : topologic.Face , optional
|
301
|
-
The input face. If set to None, the grid will be created on the XY plane. The default is None.
|
302
|
-
origin : topologic.Vertex , optional
|
303
|
-
The origin of the grid vertices. If set to None: if the face is set, the origin will be set to vertex at the face's 0,0 paratmer. If the face is set to None, the origin will be set to (0, 0, 0). The default is None.
|
304
|
-
uRange : list , optional
|
305
|
-
A list of *u* parameters for the *u* grid lines from the uOrigin. The default is [0.0,0.25,0.5,0.75,1.0].
|
306
|
-
vRange : list , optional
|
307
|
-
A list of *v* parameters for the *v* grid lines from the vOrigin. The default is [0.0,0.25,0.5,0.75,1.0].
|
308
|
-
clip : bool , optional
|
309
|
-
If True the grid will be clipped by the shape of the input face. The default is False.
|
310
|
-
tolerance : float , optional
|
311
|
-
The desired tolerance. The default is 0.0001.
|
312
|
-
|
313
|
-
Returns
|
314
|
-
-------
|
315
|
-
topologic.Cluster
|
316
|
-
The created grid. Vertices in the grid have an identifying dictionary with two keys: "u" and "v". The "dir" key can have one of two values: "u" or "v" that contain the *u* and *v* offset distances of that grid vertex from the specified origin.
|
317
|
-
|
318
|
-
"""
|
319
|
-
from topologicpy.Vertex import Vertex
|
320
|
-
from topologicpy.Edge import Edge
|
321
|
-
from topologicpy.Face import Face
|
322
|
-
from topologicpy.Cluster import Cluster
|
323
|
-
from topologicpy.Topology import Topology
|
324
|
-
from topologicpy.Dictionary import Dictionary
|
325
|
-
from topologicpy.Vector import Vector
|
326
|
-
|
327
|
-
if not isinstance(face, topologic.Face):
|
328
|
-
return None
|
329
|
-
if len(uRange) < 1 or len(vRange) < 1:
|
330
|
-
return None
|
331
|
-
if (min(uRange) < 0) or (max(uRange) > 1):
|
332
|
-
return None
|
333
|
-
if (min(vRange) < 0) or (max(vRange) > 1):
|
334
|
-
return None
|
335
|
-
|
336
|
-
uRange.sort()
|
337
|
-
vRange.sort()
|
338
|
-
gridVertices = []
|
339
|
-
if len(uRange) > 0:
|
340
|
-
uRange.sort()
|
341
|
-
for u in uRange:
|
342
|
-
for v in vRange:
|
343
|
-
gridVertex = Face.VertexByParameters(face, u, v)
|
344
|
-
if clip and isinstance(face, topologic.Face):
|
345
|
-
gridVertex = gridVertex.Intersect(face, False)
|
346
|
-
if isinstance(gridVertex, topologic.Vertex):
|
347
|
-
d = Dictionary.ByKeysValues(["u","v"],[u,v])
|
348
|
-
if d:
|
349
|
-
gridVertex.SetDictionary(d)
|
350
|
-
gridVertices.append(gridVertex)
|
351
|
-
grid = None
|
352
|
-
if len(gridVertices) > 0:
|
353
|
-
grid = Cluster.ByTopologies(gridVertices)
|
1
|
+
# Copyright (C) 2024
|
2
|
+
# Wassim Jabi <wassim.jabi@gmail.com>
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify it under
|
5
|
+
# the terms of the GNU Affero General Public License as published by the Free Software
|
6
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
7
|
+
# version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
10
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
11
|
+
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
12
|
+
# details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU Affero General Public License along with
|
15
|
+
# this program. If not, see <https://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
import topologic_core as topologic
|
18
|
+
|
19
|
+
class Grid(topologic.Cluster):
|
20
|
+
@staticmethod
|
21
|
+
def EdgesByDistances(face=None, uOrigin=None, vOrigin=None, uRange=[-0.5,-0.25,0, 0.25,0.5], vRange=[-0.5,-0.25,0, 0.25,0.5], clip=False, tolerance=0.0001):
|
22
|
+
"""
|
23
|
+
Creates a grid (cluster of edges).
|
24
|
+
|
25
|
+
Parameters
|
26
|
+
----------
|
27
|
+
face : topologic.Face , optional
|
28
|
+
The input face. If set to None, the grid will be created on the XY plane. The default is None.
|
29
|
+
uOrigin : topologic.Vertex , optional
|
30
|
+
The origin of the *u* grid lines. If set to None: if the face is set, the uOrigin will be set to vertex at the face's 0,0 paratmer. If the face is set to None, the uOrigin will be set to the origin. The default is None.
|
31
|
+
vOrigin : topologic.Vertex , optional
|
32
|
+
The origin of the *v* grid lines. If set to None: if the face is set, the vOrigin will be set to vertex at the face's 0,0 paratmer. If the face is set to None, the vOrigin will be set to the origin. The default is None.
|
33
|
+
uRange : list , optional
|
34
|
+
A list of distances for the *u* grid lines from the uOrigin. The default is [-0.5,-0.25,0, 0.25,0.5].
|
35
|
+
vRange : list , optional
|
36
|
+
A list of distances for the *v* grid lines from the vOrigin. The default is [-0.5,-0.25,0, 0.25,0.5].
|
37
|
+
clip : bool , optional
|
38
|
+
If True the grid will be clipped by the shape of the input face. The default is False.
|
39
|
+
tolerance : float , optional
|
40
|
+
The desired tolerance. The default is 0.0001.
|
41
|
+
|
42
|
+
Returns
|
43
|
+
-------
|
44
|
+
topologic.Cluster
|
45
|
+
The created grid. Edges in the grid have an identifying dictionary with two keys: "dir" and "offset". The "dir" key can have one of two values: "u" or "v", the "offset" key contains the offset distance of that grid edge from the specified origin.
|
46
|
+
|
47
|
+
"""
|
48
|
+
from topologicpy.Vertex import Vertex
|
49
|
+
from topologicpy.Edge import Edge
|
50
|
+
from topologicpy.Face import Face
|
51
|
+
from topologicpy.Cluster import Cluster
|
52
|
+
from topologicpy.Topology import Topology
|
53
|
+
from topologicpy.Dictionary import Dictionary
|
54
|
+
from topologicpy.Vector import Vector
|
55
|
+
if len(uRange) < 1 or len(vRange) < 1:
|
56
|
+
return None
|
57
|
+
if not uOrigin:
|
58
|
+
if not isinstance(face, topologic.Face):
|
59
|
+
uOrigin = Vertex.ByCoordinates(0, 0, 0)
|
60
|
+
else:
|
61
|
+
uOrigin = Face.VertexByParameters(face, 0, 0)
|
62
|
+
if not vOrigin:
|
63
|
+
if not isinstance(face, topologic.Face):
|
64
|
+
vOrigin = Vertex.ByCoordinates(0, 0, 0)
|
65
|
+
else:
|
66
|
+
vOrigin = Face.VertexByParameters(face, 0, 0)
|
67
|
+
|
68
|
+
if isinstance(face, topologic.Face):
|
69
|
+
v1 = Face.VertexByParameters(face, 0, 0)
|
70
|
+
v2 = Face.VertexByParameters(face, 1, 0)
|
71
|
+
v3 = Face.VertexByParameters(face, 0, 0)
|
72
|
+
v4 = Face.VertexByParameters(face, 0, 1)
|
73
|
+
else:
|
74
|
+
v1 = Vertex.ByCoordinates(0, 0, 0)
|
75
|
+
v2 = Vertex.ByCoordinates(max(uRange),0,0)
|
76
|
+
v3 = Vertex.ByCoordinates(0, 0, 0)
|
77
|
+
v4 = Vertex.ByCoordinates(0,max(vRange),0)
|
78
|
+
|
79
|
+
uVector = [v2.X()-v1.X(), v2.Y()-v1.Y(),v2.Z()-v1.Z()]
|
80
|
+
vVector = [v4.X()-v3.X(), v4.Y()-v3.Y(),v4.Z()-v3.Z()]
|
81
|
+
gridEdges = []
|
82
|
+
if len(uRange) > 0:
|
83
|
+
uRange.sort()
|
84
|
+
uuVector = Vector.Normalize(uVector)
|
85
|
+
for u in uRange:
|
86
|
+
tempVec = Vector.Multiply(uuVector, u, tolerance)
|
87
|
+
v1 = Vertex.ByCoordinates(uOrigin.X()+tempVec[0], uOrigin.Y()+tempVec[1], uOrigin.Z()+tempVec[2])
|
88
|
+
v2 = Vertex.ByCoordinates(v1.X()+vVector[0], v1.Y()+vVector[1], v1.Z()+vVector[2])
|
89
|
+
e = Edge.ByVertices([v1, v2], tolerance=tolerance)
|
90
|
+
if clip and isinstance(face, topologic.Face):
|
91
|
+
e = e.Intersect(face, False)
|
92
|
+
if e:
|
93
|
+
if isinstance(e, topologic.Edge):
|
94
|
+
d = Dictionary.ByKeysValues(["dir", "offset"],["u",u])
|
95
|
+
e.SetDictionary(d)
|
96
|
+
gridEdges.append(e)
|
97
|
+
elif e.Type() > topologic.Edge.Type():
|
98
|
+
tempEdges = []
|
99
|
+
_ = e.Edges(None, tempEdges)
|
100
|
+
for tempEdge in tempEdges:
|
101
|
+
d = Dictionary.ByKeysValues(["dir", "offset"],["u",u])
|
102
|
+
tempEdge.SetDictionary(d)
|
103
|
+
gridEdges.append(tempEdge)
|
104
|
+
if len(vRange) > 0:
|
105
|
+
vRange.sort()
|
106
|
+
uvVector = Vector.Normalize(vVector)
|
107
|
+
for v in vRange:
|
108
|
+
tempVec = Vector.Multiply(uvVector, v, tolerance)
|
109
|
+
v1 = Vertex.ByCoordinates(vOrigin.X()+tempVec[0], vOrigin.Y()+tempVec[1], vOrigin.Z()+tempVec[2])
|
110
|
+
v2 = Vertex.ByCoordinates(v1.X()+uVector[0], v1.Y()+uVector[1], v1.Z()+uVector[2])
|
111
|
+
e = Edge.ByVertices([v1, v2], tolerance=tolerance)
|
112
|
+
if clip and isinstance(face, topologic.Face):
|
113
|
+
e = e.Intersect(face, False)
|
114
|
+
if e:
|
115
|
+
if isinstance(e, topologic.Edge):
|
116
|
+
d = Dictionary.ByKeysValues(["dir", "offset"],["v",v])
|
117
|
+
e.SetDictionary(d)
|
118
|
+
gridEdges.append(e)
|
119
|
+
elif e.Type() > topologic.Edge.Type():
|
120
|
+
tempEdges = []
|
121
|
+
_ = e.Edges(None, tempEdges)
|
122
|
+
for tempEdge in tempEdges:
|
123
|
+
d = Dictionary.ByKeysValues(["dir", "offset"],["v",v])
|
124
|
+
tempEdge.SetDictionary(d)
|
125
|
+
gridEdges.append(tempEdge)
|
126
|
+
grid = None
|
127
|
+
if len(gridEdges) > 0:
|
128
|
+
grid = Cluster.ByTopologies(gridEdges)
|
129
|
+
return grid
|
130
|
+
|
131
|
+
@staticmethod
|
132
|
+
def EdgesByParameters(face, uRange=[0,0.25,0.5,0.75,1.0], vRange=[0,0.25,0.5,0.75,1.0], clip=False, tolerance=0.0001):
|
133
|
+
"""
|
134
|
+
Creates a grid (cluster of edges).
|
135
|
+
|
136
|
+
Parameters
|
137
|
+
----------
|
138
|
+
face : topologic.Face
|
139
|
+
The input face.
|
140
|
+
uRange : list , optional
|
141
|
+
A list of *u* parameters for the *u* grid lines. The default is [0,0.25,0.5, 0.75, 1.0].
|
142
|
+
vRange : list , optional
|
143
|
+
A list of *v* parameters for the *v* grid lines. The default is [0,0.25,0.5, 0.75, 1.0].
|
144
|
+
clip : bool , optional
|
145
|
+
If True the grid will be clipped by the shape of the input face. The default is False.
|
146
|
+
tolerance : float , optional
|
147
|
+
The desired tolerance. The default is 0.0001.
|
148
|
+
|
149
|
+
Returns
|
150
|
+
-------
|
151
|
+
topologic.Cluster
|
152
|
+
The created grid. Edges in the grid have an identifying dictionary with two keys: "dir" and "offset". The "dir" key can have one of two values: "u" or "v", the "offset" key contains the offset parameter of that grid edge.
|
153
|
+
|
154
|
+
"""
|
155
|
+
from topologicpy.Vertex import Vertex
|
156
|
+
from topologicpy.Edge import Edge
|
157
|
+
from topologicpy.Face import Face
|
158
|
+
from topologicpy.Cluster import Cluster
|
159
|
+
from topologicpy.Dictionary import Dictionary
|
160
|
+
|
161
|
+
if not isinstance(face, topologic.Face):
|
162
|
+
return None
|
163
|
+
if len(uRange) < 1 and len(vRange) < 1:
|
164
|
+
return None
|
165
|
+
if len(uRange) > 0:
|
166
|
+
if (min(uRange) < 0) or (max(uRange) > 1):
|
167
|
+
return None
|
168
|
+
if len(vRange) > 0:
|
169
|
+
if (min(vRange) < 0) or (max(vRange) > 1):
|
170
|
+
return None
|
171
|
+
|
172
|
+
uRange.sort()
|
173
|
+
vRange.sort()
|
174
|
+
gridEdges = []
|
175
|
+
for u in uRange:
|
176
|
+
v1 = Face.VertexByParameters(face, u, 0)
|
177
|
+
v2 = Face.VertexByParameters(face, u, 1)
|
178
|
+
e = Edge.ByVertices([v1, v2], tolerance=tolerance)
|
179
|
+
if clip and isinstance(face, topologic.Face):
|
180
|
+
e = e.Intersect(face, False)
|
181
|
+
if e:
|
182
|
+
if isinstance(e, topologic.Edge):
|
183
|
+
d = Dictionary.ByKeysValues(["dir", "offset"],["u",u])
|
184
|
+
e.SetDictionary(d)
|
185
|
+
gridEdges.append(e)
|
186
|
+
elif e.Type() > topologic.Edge.Type():
|
187
|
+
tempEdges = []
|
188
|
+
_ = e.Edges(None, tempEdges)
|
189
|
+
for tempEdge in tempEdges:
|
190
|
+
d = Dictionary.ByKeysValues(["dir", "offset"],["u",u])
|
191
|
+
tempEdge.SetDictionary(d)
|
192
|
+
gridEdges.append(tempEdge)
|
193
|
+
for v in vRange:
|
194
|
+
v1 = Face.VertexByParameters(face, 0, v)
|
195
|
+
v2 = Face.VertexByParameters(face, 1, v)
|
196
|
+
e = Edge.ByVertices([v1, v2], tolerance=tolerance)
|
197
|
+
if clip and isinstance(face, topologic.Face):
|
198
|
+
e = e.Intersect(face, False)
|
199
|
+
if e:
|
200
|
+
if isinstance(e, topologic.Edge):
|
201
|
+
d = Dictionary.ByKeysValues(["dir", "offset"],["v",v])
|
202
|
+
e.SetDictionary(d)
|
203
|
+
gridEdges.append(e)
|
204
|
+
elif e.Type() > topologic.Edge.Type():
|
205
|
+
tempEdges = []
|
206
|
+
_ = e.Edges(None, tempEdges)
|
207
|
+
for tempEdge in tempEdges:
|
208
|
+
d = Dictionary.ByKeysValues(["dir", "offset"],["v",v])
|
209
|
+
tempEdge.SetDictionary(d)
|
210
|
+
gridEdges.append(tempEdge)
|
211
|
+
grid = None
|
212
|
+
if len(gridEdges) > 0:
|
213
|
+
grid = Cluster.ByTopologies(gridEdges)
|
214
|
+
return grid
|
215
|
+
|
216
|
+
|
217
|
+
@staticmethod
|
218
|
+
def VerticesByDistances(face=None, origin=None, uRange=[-0.5,-0.25,0, 0.25,0.5], vRange=[-0.5,-0.25,0,0.25,0.5], clip=False, tolerance=0.0001):
|
219
|
+
"""
|
220
|
+
Creates a grid (cluster of vertices).
|
221
|
+
|
222
|
+
Parameters
|
223
|
+
----------
|
224
|
+
face : topologic.Face , optional
|
225
|
+
The input face. If set to None, the grid will be created on the XY plane. The default is None.
|
226
|
+
origin : topologic.Vertex , optional
|
227
|
+
The origin of the grid vertices. If set to None: if the face is set, the origin will be set to vertex at the face's 0,0 paratmer. If the face is set to None, the origin will be set to (0, 0, 0). The default is None.
|
228
|
+
uRange : list , optional
|
229
|
+
A list of distances for the *u* grid lines from the uOrigin. The default is [-0.5,-0.25,0, 0.25,0.5].
|
230
|
+
vRange : list , optional
|
231
|
+
A list of distances for the *v* grid lines from the vOrigin. The default is [-0.5,-0.25,0, 0.25,0.5].
|
232
|
+
clip : bool , optional
|
233
|
+
If True the grid will be clipped by the shape of the input face. The default is False.
|
234
|
+
tolerance : float , optional
|
235
|
+
The desired tolerance. The default is 0.0001.
|
236
|
+
|
237
|
+
Returns
|
238
|
+
-------
|
239
|
+
topologic.Cluster
|
240
|
+
The created grid. Vertices in the grid have an identifying dictionary with two keys: "u" and "v". The "dir" key can have one of two values: "u" or "v" that contain the *u* and *v* offset distances of that grid vertex from the specified origin.
|
241
|
+
|
242
|
+
"""
|
243
|
+
from topologicpy.Vertex import Vertex
|
244
|
+
from topologicpy.Edge import Edge
|
245
|
+
from topologicpy.Face import Face
|
246
|
+
from topologicpy.Cluster import Cluster
|
247
|
+
from topologicpy.Topology import Topology
|
248
|
+
from topologicpy.Dictionary import Dictionary
|
249
|
+
from topologicpy.Vector import Vector
|
250
|
+
if len(uRange) < 1 or len(vRange) < 1:
|
251
|
+
return None
|
252
|
+
if not origin:
|
253
|
+
if not isinstance(face, topologic.Face):
|
254
|
+
origin = Vertex.ByCoordinates(0, 0, 0)
|
255
|
+
else:
|
256
|
+
origin = Face.VertexByParameters(face, 0, 0)
|
257
|
+
|
258
|
+
if isinstance(face, topologic.Face):
|
259
|
+
v1 = Face.VertexByParameters(face, 0, 0)
|
260
|
+
v2 = Face.VertexByParameters(face, 1, 0)
|
261
|
+
v3 = Face.VertexByParameters(face, 0, 0)
|
262
|
+
v4 = Face.VertexByParameters(face, 0, 1)
|
263
|
+
else:
|
264
|
+
v1 = Vertex.ByCoordinates(0, 0, 0)
|
265
|
+
v2 = Vertex.ByCoordinates(max(uRange),0,0)
|
266
|
+
v3 = Vertex.ByCoordinates(0, 0, 0)
|
267
|
+
v4 = Vertex.ByCoordinates(0,max(vRange),0)
|
268
|
+
|
269
|
+
uVector = [v2.X()-v1.X(), v2.Y()-v1.Y(),v2.Z()-v1.Z()]
|
270
|
+
vVector = [v4.X()-v3.X(), v4.Y()-v3.Y(),v4.Z()-v3.Z()]
|
271
|
+
gridVertices = []
|
272
|
+
if len(uRange) > 0:
|
273
|
+
uRange.sort()
|
274
|
+
uuVector = Vector.Normalize(uVector)
|
275
|
+
uvVector = Vector.Normalize(vVector)
|
276
|
+
for u in uRange:
|
277
|
+
for v in vRange:
|
278
|
+
uTempVec = Vector.Multiply(uuVector, u, tolerance)
|
279
|
+
vTempVec = Vector.Multiply(uvVector, v, tolerance)
|
280
|
+
gridVertex = Vertex.ByCoordinates(origin.X()+uTempVec[0], origin.Y()+vTempVec[1], origin.Z()+uTempVec[2])
|
281
|
+
if clip and isinstance(face, topologic.Face):
|
282
|
+
gridVertex = gridVertex.Intersect(face, False)
|
283
|
+
if isinstance(gridVertex, topologic.Vertex):
|
284
|
+
d = Dictionary.ByKeysValues(["u","v"],[u,v])
|
285
|
+
if d:
|
286
|
+
gridVertex.SetDictionary(d)
|
287
|
+
gridVertices.append(gridVertex)
|
288
|
+
grid = None
|
289
|
+
if len(gridVertices) > 0:
|
290
|
+
grid = Cluster.ByTopologies(gridVertices)
|
291
|
+
return grid
|
292
|
+
|
293
|
+
@staticmethod
|
294
|
+
def VerticesByParameters(face=None, uRange=[0.0,0.25,0.5,0.75,1.0], vRange=[0.0,0.25,0.5,0.75,1.0], clip=False, tolerance=0.0001):
|
295
|
+
"""
|
296
|
+
Creates a grid (cluster of vertices).
|
297
|
+
|
298
|
+
Parameters
|
299
|
+
----------
|
300
|
+
face : topologic.Face , optional
|
301
|
+
The input face. If set to None, the grid will be created on the XY plane. The default is None.
|
302
|
+
origin : topologic.Vertex , optional
|
303
|
+
The origin of the grid vertices. If set to None: if the face is set, the origin will be set to vertex at the face's 0,0 paratmer. If the face is set to None, the origin will be set to (0, 0, 0). The default is None.
|
304
|
+
uRange : list , optional
|
305
|
+
A list of *u* parameters for the *u* grid lines from the uOrigin. The default is [0.0,0.25,0.5,0.75,1.0].
|
306
|
+
vRange : list , optional
|
307
|
+
A list of *v* parameters for the *v* grid lines from the vOrigin. The default is [0.0,0.25,0.5,0.75,1.0].
|
308
|
+
clip : bool , optional
|
309
|
+
If True the grid will be clipped by the shape of the input face. The default is False.
|
310
|
+
tolerance : float , optional
|
311
|
+
The desired tolerance. The default is 0.0001.
|
312
|
+
|
313
|
+
Returns
|
314
|
+
-------
|
315
|
+
topologic.Cluster
|
316
|
+
The created grid. Vertices in the grid have an identifying dictionary with two keys: "u" and "v". The "dir" key can have one of two values: "u" or "v" that contain the *u* and *v* offset distances of that grid vertex from the specified origin.
|
317
|
+
|
318
|
+
"""
|
319
|
+
from topologicpy.Vertex import Vertex
|
320
|
+
from topologicpy.Edge import Edge
|
321
|
+
from topologicpy.Face import Face
|
322
|
+
from topologicpy.Cluster import Cluster
|
323
|
+
from topologicpy.Topology import Topology
|
324
|
+
from topologicpy.Dictionary import Dictionary
|
325
|
+
from topologicpy.Vector import Vector
|
326
|
+
|
327
|
+
if not isinstance(face, topologic.Face):
|
328
|
+
return None
|
329
|
+
if len(uRange) < 1 or len(vRange) < 1:
|
330
|
+
return None
|
331
|
+
if (min(uRange) < 0) or (max(uRange) > 1):
|
332
|
+
return None
|
333
|
+
if (min(vRange) < 0) or (max(vRange) > 1):
|
334
|
+
return None
|
335
|
+
|
336
|
+
uRange.sort()
|
337
|
+
vRange.sort()
|
338
|
+
gridVertices = []
|
339
|
+
if len(uRange) > 0:
|
340
|
+
uRange.sort()
|
341
|
+
for u in uRange:
|
342
|
+
for v in vRange:
|
343
|
+
gridVertex = Face.VertexByParameters(face, u, v)
|
344
|
+
if clip and isinstance(face, topologic.Face):
|
345
|
+
gridVertex = gridVertex.Intersect(face, False)
|
346
|
+
if isinstance(gridVertex, topologic.Vertex):
|
347
|
+
d = Dictionary.ByKeysValues(["u","v"],[u,v])
|
348
|
+
if d:
|
349
|
+
gridVertex.SetDictionary(d)
|
350
|
+
gridVertices.append(gridVertex)
|
351
|
+
grid = None
|
352
|
+
if len(gridVertices) > 0:
|
353
|
+
grid = Cluster.ByTopologies(gridVertices)
|
354
354
|
return grid
|