topologicpy 0.7.5__py3-none-any.whl → 0.7.6__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/Cell.py +62 -53
- topologicpy/CellComplex.py +10 -8
- topologicpy/Edge.py +21 -16
- topologicpy/EnergyModel.py +20 -13
- topologicpy/Face.py +23 -25
- topologicpy/Graph.py +60 -37
- topologicpy/Grid.py +10 -7
- topologicpy/Honeybee.py +16 -15
- topologicpy/Neo4j.py +22 -10
- topologicpy/Plotly.py +49 -62
- topologicpy/Shell.py +79 -54
- topologicpy/Topology.py +95 -50
- topologicpy/Vector.py +4 -2
- topologicpy/Vertex.py +64 -42
- topologicpy/Wire.py +23 -12
- topologicpy/version.py +1 -1
- {topologicpy-0.7.5.dist-info → topologicpy-0.7.6.dist-info}/METADATA +1 -1
- topologicpy-0.7.6.dist-info/RECORD +33 -0
- topologicpy-0.7.5.dist-info/RECORD +0 -33
- {topologicpy-0.7.5.dist-info → topologicpy-0.7.6.dist-info}/LICENSE +0 -0
- {topologicpy-0.7.5.dist-info → topologicpy-0.7.6.dist-info}/WHEEL +0 -0
- {topologicpy-0.7.5.dist-info → topologicpy-0.7.6.dist-info}/top_level.txt +0 -0
topologicpy/Face.py
CHANGED
@@ -942,7 +942,7 @@ class Face():
|
|
942
942
|
return eb
|
943
943
|
|
944
944
|
@staticmethod
|
945
|
-
def FacingToward(face, direction: list = [0,0,-1], asVertex: bool = False, tolerance: float = 0.0001) -> bool:
|
945
|
+
def FacingToward(face, direction: list = [0,0,-1], asVertex: bool = False, mantissa: int = 6, tolerance: float = 0.0001) -> bool:
|
946
946
|
"""
|
947
947
|
Returns True if the input face is facing toward the input direction.
|
948
948
|
|
@@ -954,6 +954,8 @@ class Face():
|
|
954
954
|
The input direction. The default is [0,0,-1].
|
955
955
|
asVertex : bool , optional
|
956
956
|
If set to True, the direction is treated as an actual vertex in 3D space. The default is False.
|
957
|
+
mantissa : int , optional
|
958
|
+
The desired length of the mantissa. The default is 6.
|
957
959
|
tolerance : float , optional
|
958
960
|
The desired tolerance. The default is 0.0001.
|
959
961
|
|
@@ -963,22 +965,16 @@ class Face():
|
|
963
965
|
True if the face is facing toward the direction. False otherwise.
|
964
966
|
|
965
967
|
"""
|
968
|
+
from topologicpy.Vertex import Vertex
|
966
969
|
from topologicpy.Vector import Vector
|
967
970
|
|
968
|
-
faceNormal = Face.Normal(face)
|
971
|
+
faceNormal = Face.Normal(face, mantissa=mantissa)
|
969
972
|
faceCenter = Face.VertexByParameters(face,0.5,0.5)
|
970
|
-
cList = [
|
971
|
-
try:
|
972
|
-
vList = [direction.X(), direction.Y(), direction.Z()]
|
973
|
-
except:
|
974
|
-
try:
|
975
|
-
vList = [direction[0], direction[1], direction[2]]
|
976
|
-
except:
|
977
|
-
raise Exception("Face.FacingToward - Error: Could not get the vector from the input direction")
|
973
|
+
cList = [Vertex.X(faceCenter, mantissa=mantissa), Vertex.Y(faceCenter, mantissa=mantissa), Vertex.Z(faceCenter, mantissa=mantissa)]
|
978
974
|
if asVertex:
|
979
|
-
dV = [
|
975
|
+
dV = [direction[0]-cList[0], direction[1]-cList[1], direction[2]-cList[2]]
|
980
976
|
else:
|
981
|
-
dV =
|
977
|
+
dV = direction
|
982
978
|
uV = Vector.Normalize(dV)
|
983
979
|
dot = sum([i*j for (i, j) in zip(uV, faceNormal)])
|
984
980
|
if dot < tolerance:
|
@@ -1322,9 +1318,10 @@ class Face():
|
|
1322
1318
|
max_d = distances[-1]*1.05
|
1323
1319
|
edges = []
|
1324
1320
|
for target in targets:
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1321
|
+
if Vertex.Distance(vertex, target) > tolerance:
|
1322
|
+
e = Edge.ByVertices(vertex, target)
|
1323
|
+
e = Edge.SetLength(e, length=max_d, bothSides=False)
|
1324
|
+
edges.append(e)
|
1328
1325
|
shell = Topology.Slice(face, Cluster.ByTopologies(edges))
|
1329
1326
|
faces = Topology.Faces(shell)
|
1330
1327
|
final_faces = []
|
@@ -1987,7 +1984,7 @@ class Face():
|
|
1987
1984
|
return Face.ByWire(wire, tolerance=tolerance)
|
1988
1985
|
|
1989
1986
|
@staticmethod
|
1990
|
-
def Triangulate(face, mode: int = 0, meshSize: float = None, tolerance: float = 0.0001) -> list:
|
1987
|
+
def Triangulate(face, mode: int = 0, meshSize: float = None, mantissa: int = 6, tolerance: float = 0.0001) -> list:
|
1991
1988
|
"""
|
1992
1989
|
Triangulates the input face and returns a list of faces.
|
1993
1990
|
|
@@ -1995,8 +1992,6 @@ class Face():
|
|
1995
1992
|
----------
|
1996
1993
|
face : topologic_core.Face
|
1997
1994
|
The input face.
|
1998
|
-
tolerance : float , optional
|
1999
|
-
The desired tolerance. The default is 0.0001.
|
2000
1995
|
mode : int , optional
|
2001
1996
|
The desired mode of meshing algorithm. Several options are available:
|
2002
1997
|
0: Classic
|
@@ -2012,6 +2007,10 @@ class Face():
|
|
2012
2007
|
meshSize : float , optional
|
2013
2008
|
The desired size of the mesh when using the "mesh" option. If set to None, it will be
|
2014
2009
|
calculated automatically and set to 10% of the overall size of the face.
|
2010
|
+
mantissa : int , optional
|
2011
|
+
The desired length of the mantissa. The default is 6.
|
2012
|
+
tolerance : float , optional
|
2013
|
+
The desired tolerance. The default is 0.0001.
|
2015
2014
|
|
2016
2015
|
Returns
|
2017
2016
|
-------
|
@@ -2073,7 +2072,6 @@ class Face():
|
|
2073
2072
|
warnings.warn("Face.Triangulate - Error: Could not import gmsh. Please try to install gmsh manually. Returning None.")
|
2074
2073
|
return None
|
2075
2074
|
|
2076
|
-
import topologic_core as topologic
|
2077
2075
|
from topologicpy.Vertex import Vertex
|
2078
2076
|
from topologicpy.Wire import Wire
|
2079
2077
|
from topologicpy.Face import Face
|
@@ -2084,8 +2082,8 @@ class Face():
|
|
2084
2082
|
if not meshSize:
|
2085
2083
|
bounding_face = Face.BoundingRectangle(face)
|
2086
2084
|
bounding_face_vertices = Face.Vertices(bounding_face)
|
2087
|
-
bounding_face_vertices_x = [Vertex.X(i) for i in bounding_face_vertices]
|
2088
|
-
bounding_face_vertices_y = [Vertex.Y(i) for i in bounding_face_vertices]
|
2085
|
+
bounding_face_vertices_x = [Vertex.X(i, mantissa=mantissa) for i in bounding_face_vertices]
|
2086
|
+
bounding_face_vertices_y = [Vertex.Y(i, mantissa=mantissa) for i in bounding_face_vertices]
|
2089
2087
|
width = max(bounding_face_vertices_x)-min(bounding_face_vertices_x)
|
2090
2088
|
length = max(bounding_face_vertices_y)-min(bounding_face_vertices_y)
|
2091
2089
|
meshSize = max([width,length])//10
|
@@ -2095,7 +2093,7 @@ class Face():
|
|
2095
2093
|
external_vertices = Wire.Vertices(face_external_boundary)
|
2096
2094
|
external_vertex_number = len(external_vertices)
|
2097
2095
|
for i in range(external_vertex_number):
|
2098
|
-
gmsh.model.geo.addPoint(Vertex.X(external_vertices[i]), Vertex.Y(external_vertices[i]), Vertex.Z(external_vertices[i]), meshSize, i+1)
|
2096
|
+
gmsh.model.geo.addPoint(Vertex.X(external_vertices[i], mantissa=mantissa), Vertex.Y(external_vertices[i], mantissa=mantissa), Vertex.Z(external_vertices[i], mantissa=mantissa), meshSize, i+1)
|
2099
2097
|
for i in range(external_vertex_number):
|
2100
2098
|
if i < external_vertex_number-1:
|
2101
2099
|
gmsh.model.geo.addLine(i+1, i+2, i+1)
|
@@ -2114,7 +2112,7 @@ class Face():
|
|
2114
2112
|
internal_vertices = Wire.Vertices(face_internal_boundary)
|
2115
2113
|
internal_vertex_number = len(internal_vertices)
|
2116
2114
|
for j in range(internal_vertex_number):
|
2117
|
-
gmsh.model.geo.addPoint(Vertex.X(internal_vertices[j]), Vertex.Y(internal_vertices[j]), Vertex.Z(internal_vertices[j]), meshSize, current_vertex_number+j+1)
|
2115
|
+
gmsh.model.geo.addPoint(Vertex.X(internal_vertices[j]), Vertex.Y(internal_vertices[j], mantissa=mantissa), Vertex.Z(internal_vertices[j], mantissa=mantissa), meshSize, current_vertex_number+j+1)
|
2118
2116
|
for j in range(internal_vertex_number):
|
2119
2117
|
if j < internal_vertex_number-1:
|
2120
2118
|
gmsh.model.geo.addLine(current_vertex_number+j+1, current_vertex_number+j+2, current_edge_number+j+1)
|
@@ -2160,7 +2158,7 @@ class Face():
|
|
2160
2158
|
if len(vertices) == 3: # Already a triangle
|
2161
2159
|
return [face]
|
2162
2160
|
origin = Topology.Centroid(face)
|
2163
|
-
normal = Face.Normal(face)
|
2161
|
+
normal = Face.Normal(face, mantissa=mantissa)
|
2164
2162
|
flatFace = Topology.Flatten(face, origin=origin, direction=normal)
|
2165
2163
|
|
2166
2164
|
if mode == 0:
|
@@ -2179,7 +2177,7 @@ class Face():
|
|
2179
2177
|
finalFaces = []
|
2180
2178
|
for f in shell_faces:
|
2181
2179
|
f = Topology.Unflatten(f, origin=origin, direction=normal)
|
2182
|
-
if Face.Angle(face, f) > 90:
|
2180
|
+
if Face.Angle(face, f, mantissa=mantissa) > 90:
|
2183
2181
|
wire = Face.ExternalBoundary(f)
|
2184
2182
|
wire = Wire.Invert(wire)
|
2185
2183
|
f = Face.ByWire(wire)
|
topologicpy/Graph.py
CHANGED
@@ -62,8 +62,6 @@ except:
|
|
62
62
|
except:
|
63
63
|
warnings.warn("Graph - Error: Could not import tqdm.")
|
64
64
|
|
65
|
-
|
66
|
-
|
67
65
|
class _Tree:
|
68
66
|
def __init__(self, node="", *children):
|
69
67
|
self.node = node
|
@@ -94,7 +92,6 @@ class _Tree:
|
|
94
92
|
return len(self.children)
|
95
93
|
|
96
94
|
|
97
|
-
|
98
95
|
class _DrawTree(object):
|
99
96
|
def __init__(self, tree, parent=None, depth=0, number=1):
|
100
97
|
self.x = -1.0
|
@@ -557,7 +554,8 @@ class Graph:
|
|
557
554
|
slabType = "slab",
|
558
555
|
doorType = "door",
|
559
556
|
windowType = "window",
|
560
|
-
contentType = "content"
|
557
|
+
contentType = "content",
|
558
|
+
namespace = "http://github.com/wassimj/topologicpy/resources"
|
561
559
|
):
|
562
560
|
"""
|
563
561
|
Creates an RDF graph according to the BOT ontology. See https://w3c-lbd-cg.github.io/bot/.
|
@@ -621,7 +619,7 @@ class Graph:
|
|
621
619
|
try:
|
622
620
|
from rdflib import Graph as RDFGraph
|
623
621
|
from rdflib import URIRef, Literal, Namespace
|
624
|
-
from rdflib.namespace import RDF, RDFS
|
622
|
+
from rdflib.namespace import RDF, RDFS, XSD
|
625
623
|
except:
|
626
624
|
print("Graph.BOTGraph - Information: Installing required rdflib library.")
|
627
625
|
try:
|
@@ -646,9 +644,12 @@ class Graph:
|
|
646
644
|
# Define namespaces
|
647
645
|
rdf = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#")
|
648
646
|
bot = Namespace("https://w3id.org/bot#")
|
647
|
+
top = Namespace(namespace)
|
649
648
|
|
650
649
|
# Define a custom prefix mapping
|
651
650
|
bot_graph.namespace_manager.bind("bot", bot)
|
651
|
+
bot_graph.namespace_manager.bind("xsd", XSD)
|
652
|
+
bot_graph.namespace_manager.bind("top", top)
|
652
653
|
|
653
654
|
# Add site
|
654
655
|
site_uri = URIRef(siteLabel)
|
@@ -705,7 +706,7 @@ class Graph:
|
|
705
706
|
|
706
707
|
# Add vertices as RDF resources
|
707
708
|
for node, attributes in json_data['vertices'].items():
|
708
|
-
node_uri = URIRef(node)
|
709
|
+
node_uri = URIRef(top[node])
|
709
710
|
if spaceType.lower() in attributes[typeKey].lower():
|
710
711
|
bot_graph.add((node_uri, rdf.type, bot.Space))
|
711
712
|
# Find the storey it is on
|
@@ -730,6 +731,8 @@ class Graph:
|
|
730
731
|
|
731
732
|
if includeAttributes:
|
732
733
|
for key, value in attributes.items():
|
734
|
+
if key == "brepType":
|
735
|
+
print("Key = brepType, Value =", value, value.__class__)
|
733
736
|
if key == geometryKey:
|
734
737
|
if includeGeometry:
|
735
738
|
bot_graph.add((node_uri, bot.hasSimpleGeometry, Literal(value)))
|
@@ -737,7 +740,17 @@ class Graph:
|
|
737
740
|
if includeLabel:
|
738
741
|
bot_graph.add((node_uri, RDFS.label, Literal(value)))
|
739
742
|
elif key != typeKey and key != geometryKey:
|
740
|
-
|
743
|
+
if isinstance(value, float):
|
744
|
+
datatype = XSD.float
|
745
|
+
elif isinstance(value, bool):
|
746
|
+
print("got boolean")
|
747
|
+
datatype = XSD.boolean
|
748
|
+
elif isinstance(value, int):
|
749
|
+
print("got integer")
|
750
|
+
datatype = XSD.integer
|
751
|
+
elif isinstance(value, str):
|
752
|
+
datatype = XSD.string
|
753
|
+
bot_graph.add((node_uri, top[key], Literal(value, datatype=datatype)))
|
741
754
|
if includeLabel:
|
742
755
|
for key, value in attributes.items():
|
743
756
|
if key == labelKey:
|
@@ -747,8 +760,8 @@ class Graph:
|
|
747
760
|
for edge, attributes in json_data['edges'].items():
|
748
761
|
source = attributes["source"]
|
749
762
|
target = attributes["target"]
|
750
|
-
source_uri = URIRef(source)
|
751
|
-
target_uri = URIRef(target)
|
763
|
+
source_uri = URIRef(top[source])
|
764
|
+
target_uri = URIRef(top[target])
|
752
765
|
if spaceType.lower() in json_data['vertices'][source][typeKey].lower() and spaceType.lower() in json_data['vertices'][target][typeKey].lower():
|
753
766
|
bot_graph.add((source_uri, bot.adjacentTo, target_uri))
|
754
767
|
if bidirectional:
|
@@ -4347,6 +4360,7 @@ class Graph:
|
|
4347
4360
|
def ExportToBOT(graph,
|
4348
4361
|
path,
|
4349
4362
|
format="turtle",
|
4363
|
+
namespace = "http://github.com/wassimj/topologicpy/resources",
|
4350
4364
|
overwrite = False,
|
4351
4365
|
bidirectional=False,
|
4352
4366
|
includeAttributes=False,
|
@@ -4386,6 +4400,8 @@ class Graph:
|
|
4386
4400
|
trig : Trig , Turtle-like format for RDF triples + context (RDF quads) and thus multiple graphs
|
4387
4401
|
trix : Trix , RDF/XML-like format for RDF quads
|
4388
4402
|
nquads : N-Quads , N-Triples-like format for RDF quads
|
4403
|
+
namespace : str , optional
|
4404
|
+
The desired namespace for creating IRIs for entities. The default is "http://github.com/wassimj/topologicpy/resources".
|
4389
4405
|
path : str
|
4390
4406
|
The desired path to where the RDF/BOT file will be saved.
|
4391
4407
|
overwrite : bool , optional
|
@@ -4465,7 +4481,8 @@ class Graph:
|
|
4465
4481
|
slabType = slabType,
|
4466
4482
|
doorType = doorType,
|
4467
4483
|
windowType = windowType,
|
4468
|
-
contentType = contentType
|
4484
|
+
contentType = contentType,
|
4485
|
+
namespace = namespace
|
4469
4486
|
)
|
4470
4487
|
if "turtle" in format.lower() or "ttl" in format.lower() or "turtle2" in format.lower():
|
4471
4488
|
ext = ".ttl"
|
@@ -4759,7 +4776,7 @@ class Graph:
|
|
4759
4776
|
node_features = node_features + ","+ str(round(float(Dictionary.ValueAtKey(nd, node_feature_key)),mantissa))
|
4760
4777
|
else:
|
4761
4778
|
node_features = str(round(float(Dictionary.ValueAtKey(nd, node_feature_key)),mantissa))
|
4762
|
-
single_node_data = [graph_id, i, vLabel, train_mask, validate_mask, test_mask, node_features,
|
4779
|
+
single_node_data = [graph_id, i, vLabel, train_mask, validate_mask, test_mask, node_features, float(Vertex.X(v, mantissa=mantissa)), float(Vertex.Y(v,mantissa)), float(Vertex.Z(v,mantissa))]
|
4763
4780
|
node_data.append(single_node_data)
|
4764
4781
|
|
4765
4782
|
# Write Node Data to CSV file
|
@@ -4871,11 +4888,11 @@ class Graph:
|
|
4871
4888
|
return True
|
4872
4889
|
|
4873
4890
|
@staticmethod
|
4874
|
-
def ExportToGEXF(graph, path, graphWidth=20, graphLength=20, graphHeight=20,
|
4875
|
-
defaultVertexColor="black", defaultVertexSize=3,
|
4876
|
-
vertexLabelKey=None, vertexColorKey=None, vertexSizeKey=None,
|
4877
|
-
defaultEdgeColor="black", defaultEdgeWeight=1, defaultEdgeType="undirected",
|
4878
|
-
edgeLabelKey=None, edgeColorKey=None, edgeWeightKey=None, overwrite=False):
|
4891
|
+
def ExportToGEXF(graph, path: str = None, graphWidth: float = 20, graphLength: float = 20, graphHeight: float = 20,
|
4892
|
+
defaultVertexColor: str = "black", defaultVertexSize: float = 3,
|
4893
|
+
vertexLabelKey: str = None, vertexColorKey: str = None, vertexSizeKey: str = None,
|
4894
|
+
defaultEdgeColor: str = "black", defaultEdgeWeight: float = 1, defaultEdgeType: str = "undirected",
|
4895
|
+
edgeLabelKey: str = None, edgeColorKey: str = None, edgeWeightKey: str = None, overwrite: bool = False, mantissa: int = 6):
|
4879
4896
|
"""
|
4880
4897
|
Exports the input graph to a Graph Exchange XML (GEXF) file format. See https://gexf.net/
|
4881
4898
|
|
@@ -4921,6 +4938,8 @@ class Graph:
|
|
4921
4938
|
the edge weight is set to the value defined by defaultEdgeWeight parameter. The default is None.
|
4922
4939
|
overwrite : bool , optional
|
4923
4940
|
If set to True, any existing file is overwritten. Otherwise, it is not. The default is False.
|
4941
|
+
mantissa : int , optional
|
4942
|
+
The desired length of the mantissa. The default is 6.
|
4924
4943
|
|
4925
4944
|
Returns
|
4926
4945
|
-------
|
@@ -5049,9 +5068,9 @@ class Graph:
|
|
5049
5068
|
'size': 'double'}
|
5050
5069
|
nodes = {}
|
5051
5070
|
# Resize the graph
|
5052
|
-
xList = [Vertex.X(v) for v in g_vertices]
|
5053
|
-
yList = [Vertex.Y(v) for v in g_vertices]
|
5054
|
-
zList = [Vertex.Z(v) for v in g_vertices]
|
5071
|
+
xList = [Vertex.X(v, mantissa=mantissa) for v in g_vertices]
|
5072
|
+
yList = [Vertex.Y(v, mantissa=mantissa) for v in g_vertices]
|
5073
|
+
zList = [Vertex.Z(v, mantissa=mantissa) for v in g_vertices]
|
5055
5074
|
xMin = min(xList)
|
5056
5075
|
xMax = max(xList)
|
5057
5076
|
yMin = min(yList)
|
@@ -5073,9 +5092,9 @@ class Graph:
|
|
5073
5092
|
d = Topology.Dictionary(v)
|
5074
5093
|
keys = Dictionary.Keys(d)
|
5075
5094
|
values = Dictionary.Values(d)
|
5076
|
-
x = (Vertex.X(v) - x_avg)*x_sf + x_avg
|
5077
|
-
y = (Vertex.Y(v) - y_avg)*y_sf + y_avg
|
5078
|
-
z = (Vertex.Z(v) - z_avg)*z_sf + z_avg
|
5095
|
+
x = (Vertex.X(v, mantissa=mantissa) - x_avg)*x_sf + x_avg
|
5096
|
+
y = (Vertex.Y(v, mantissa=mantissa) - y_avg)*y_sf + y_avg
|
5097
|
+
z = (Vertex.Z(v, mantissa=mantissa) - z_avg)*z_sf + z_avg
|
5079
5098
|
node_dict['x'] = x
|
5080
5099
|
node_dict['y'] = y
|
5081
5100
|
node_dict['z'] = z
|
@@ -5944,17 +5963,17 @@ class Graph:
|
|
5944
5963
|
|
5945
5964
|
@staticmethod
|
5946
5965
|
def JSONData(graph,
|
5947
|
-
verticesKey="vertices",
|
5948
|
-
edgesKey="edges",
|
5949
|
-
vertexLabelKey="",
|
5950
|
-
edgeLabelKey="",
|
5951
|
-
sourceKey="source",
|
5952
|
-
targetKey="target",
|
5953
|
-
xKey="x",
|
5954
|
-
yKey="y",
|
5955
|
-
zKey="z",
|
5956
|
-
geometryKey="brep",
|
5957
|
-
mantissa=6):
|
5966
|
+
verticesKey: str = "vertices",
|
5967
|
+
edgesKey: str = "edges",
|
5968
|
+
vertexLabelKey: str = "",
|
5969
|
+
edgeLabelKey: str = "",
|
5970
|
+
sourceKey: str = "source",
|
5971
|
+
targetKey: str = "target",
|
5972
|
+
xKey: str = "x",
|
5973
|
+
yKey: str = "y",
|
5974
|
+
zKey: str = "z",
|
5975
|
+
geometryKey: str = "brep",
|
5976
|
+
mantissa: int = 6):
|
5958
5977
|
"""
|
5959
5978
|
Converts the input graph into JSON data.
|
5960
5979
|
|
@@ -5975,7 +5994,7 @@ class Graph:
|
|
5975
5994
|
sourceKey : str , optional
|
5976
5995
|
The dictionary key used to store the source vertex. The default is "source".
|
5977
5996
|
targetKey : str , optional
|
5978
|
-
The dictionary key used to store the target vertex. The default is "
|
5997
|
+
The dictionary key used to store the target vertex. The default is "target".
|
5979
5998
|
xKey : str , optional
|
5980
5999
|
The desired key name to use for x-coordinates. The default is "x".
|
5981
6000
|
yKey : str , optional
|
@@ -6709,7 +6728,7 @@ class Graph:
|
|
6709
6728
|
return nearestVertex
|
6710
6729
|
|
6711
6730
|
@staticmethod
|
6712
|
-
def NetworkXGraph(graph, tolerance=0.0001):
|
6731
|
+
def NetworkXGraph(graph, mantissa: int = 6, tolerance: float = 0.0001):
|
6713
6732
|
"""
|
6714
6733
|
converts the input graph into a NetworkX Graph. See http://networkx.org
|
6715
6734
|
|
@@ -6717,6 +6736,10 @@ class Graph:
|
|
6717
6736
|
----------
|
6718
6737
|
graph : topologic_core.Graph
|
6719
6738
|
The input graph.
|
6739
|
+
mantissa : int , optional
|
6740
|
+
The desired length of the mantissa. The default is 6.
|
6741
|
+
tolerance : float , optional
|
6742
|
+
The desired tolerance. The default is 0.0001.
|
6720
6743
|
|
6721
6744
|
Returns
|
6722
6745
|
-------
|
@@ -6763,7 +6786,7 @@ class Graph:
|
|
6763
6786
|
values = []
|
6764
6787
|
keys += ["x","y","z"]
|
6765
6788
|
import random
|
6766
|
-
values += [Vertex.X(v), Vertex.Y(v), Vertex.Z(v)]
|
6789
|
+
values += [Vertex.X(v, mantissa=mantissa), Vertex.Y(v, mantissa=mantissa), Vertex.Z(v, mantissa=mantissa)]
|
6767
6790
|
d = Dictionary.ByKeysValues(keys,values)
|
6768
6791
|
pythonD = Dictionary.PythonDictionary(d)
|
6769
6792
|
nodes.append((i, pythonD))
|
@@ -6776,7 +6799,7 @@ class Graph:
|
|
6776
6799
|
for adjVertex in adjVertices:
|
6777
6800
|
adjIndex = Vertex.Index(vertex=adjVertex, vertices=vertices, strict=True, tolerance=tolerance)
|
6778
6801
|
if not adjIndex == None:
|
6779
|
-
nxGraph.add_edge(i,adjIndex, length=(Vertex.Distance(v, adjVertex)))
|
6802
|
+
nxGraph.add_edge(i,adjIndex, length=(Vertex.Distance(v, adjVertex, mantissa=mantissa)))
|
6780
6803
|
|
6781
6804
|
pos=nx.spring_layout(nxGraph, k=0.2)
|
6782
6805
|
nx.set_node_attributes(nxGraph, pos, "pos")
|
topologicpy/Grid.py
CHANGED
@@ -18,7 +18,7 @@ import topologic_core as topologic
|
|
18
18
|
|
19
19
|
class Grid():
|
20
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):
|
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, mantissa: int = 6, tolerance=0.0001):
|
22
22
|
"""
|
23
23
|
Creates a grid (cluster of edges).
|
24
24
|
|
@@ -36,6 +36,8 @@ class Grid():
|
|
36
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
37
|
clip : bool , optional
|
38
38
|
If True the grid will be clipped by the shape of the input face. The default is False.
|
39
|
+
mantissa : int , optional
|
40
|
+
The desired length of the mantissa. The default is 6.
|
39
41
|
tolerance : float , optional
|
40
42
|
The desired tolerance. The default is 0.0001.
|
41
43
|
|
@@ -52,6 +54,7 @@ class Grid():
|
|
52
54
|
from topologicpy.Topology import Topology
|
53
55
|
from topologicpy.Dictionary import Dictionary
|
54
56
|
from topologicpy.Vector import Vector
|
57
|
+
|
55
58
|
if len(uRange) < 1 or len(vRange) < 1:
|
56
59
|
return None
|
57
60
|
if not uOrigin:
|
@@ -76,16 +79,16 @@ class Grid():
|
|
76
79
|
v3 = Vertex.ByCoordinates(0, 0, 0)
|
77
80
|
v4 = Vertex.ByCoordinates(0,max(vRange),0)
|
78
81
|
|
79
|
-
uVector = [
|
80
|
-
vVector = [
|
82
|
+
uVector = [Vertex.X(v2, mantissa=mantissa)-Vertex.X(v1, mantissa=mantissa), Vertex.Y(v2, mantissa=mantissa)-Vertex.Y(v1, mantissa=mantissa),Vertex.Z(v2, mantissa=mantissa)-Vertex.Z(v1, mantissa=mantissa)]
|
83
|
+
vVector = [Vertex.X(v4, mantissa=mantissa)-Vertex.X(v3, mantissa=mantissa), Vertex.Y(v4, mantissa=mantissa)-Vertex.Y(v3, mantissa=mantissa),Vertex.Z(v4, mantissa=mantissa)-Vertex.Z(v3, mantissa=mantissa)]
|
81
84
|
gridEdges = []
|
82
85
|
if len(uRange) > 0:
|
83
86
|
uRange.sort()
|
84
87
|
uuVector = Vector.Normalize(uVector)
|
85
88
|
for u in uRange:
|
86
89
|
tempVec = Vector.Multiply(uuVector, u, tolerance)
|
87
|
-
v1 = Vertex.ByCoordinates(
|
88
|
-
v2 = Vertex.ByCoordinates(
|
90
|
+
v1 = Vertex.ByCoordinates(Vertex.X(uOrigin, mantissa=mantissa)+tempVec[0], Vertex.Y(uOrigin, mantissa=mantissa)+tempVec[1], Vertex.Z(uOrigin, mantissa=mantissa)+tempVec[2])
|
91
|
+
v2 = Vertex.ByCoordinates(Vertex.X(v1, mantissa=mantissa)+vVector[0], Vertex.Y(v1, mantissa=mantissa)+vVector[1], Vertex.Z(v1, mantissa=mantissa)+vVector[2])
|
89
92
|
e = Edge.ByVertices([v1, v2], tolerance=tolerance)
|
90
93
|
if clip and Topology.IsInstance(face, "Face"):
|
91
94
|
e = e.Intersect(face, False)
|
@@ -105,8 +108,8 @@ class Grid():
|
|
105
108
|
uvVector = Vector.Normalize(vVector)
|
106
109
|
for v in vRange:
|
107
110
|
tempVec = Vector.Multiply(uvVector, v, tolerance)
|
108
|
-
v1 = Vertex.ByCoordinates(
|
109
|
-
v2 = Vertex.ByCoordinates(
|
111
|
+
v1 = Vertex.ByCoordinates(Vertex.X(vOrigin, mantissa=mantissa)+tempVec[0], Vertex.Y(vOrigin, mantissa=mantissa)+tempVec[1], Vertex.Z(vOrigin, mantissa=mantissa)+tempVec[2])
|
112
|
+
v2 = Vertex.ByCoordinates(Vertex.X(v1, mantissa=mantissa)+uVector[0], Vertex.Y(v1, mantissa=mantissa)+uVector[1], Vertex.Z(v1, mantissa=mantissa)+uVector[2])
|
110
113
|
e = Edge.ByVertices([v1, v2], tolerance=tolerance)
|
111
114
|
if clip and Topology.IsInstance(face, "Face"):
|
112
115
|
e = e.Intersect(face, False)
|
topologicpy/Honeybee.py
CHANGED
@@ -195,17 +195,18 @@ class Honeybee:
|
|
195
195
|
@staticmethod
|
196
196
|
def ModelByTopology(tpBuilding,
|
197
197
|
tpShadingFacesCluster = None,
|
198
|
-
buildingName = "Generic_Building",
|
199
|
-
defaultProgramIdentifier = "Generic Office Program",
|
200
|
-
defaultConstructionSetIdentifier = "Default Generic Construction Set",
|
201
|
-
coolingSetpoint = 25.0,
|
202
|
-
heatingSetpoint = 20.0,
|
203
|
-
humidifyingSetpoint = 30.0,
|
204
|
-
dehumidifyingSetpoint = 55.0,
|
205
|
-
roomNameKey = "TOPOLOGIC_name",
|
206
|
-
roomTypeKey = "TOPOLOGIC_type",
|
207
|
-
apertureTypeKey = "TOPOLOGIC_type",
|
208
|
-
addSensorGrid = False
|
198
|
+
buildingName: str = "Generic_Building",
|
199
|
+
defaultProgramIdentifier: str = "Generic Office Program",
|
200
|
+
defaultConstructionSetIdentifier: str = "Default Generic Construction Set",
|
201
|
+
coolingSetpoint: float = 25.0,
|
202
|
+
heatingSetpoint: float = 20.0,
|
203
|
+
humidifyingSetpoint: float = 30.0,
|
204
|
+
dehumidifyingSetpoint: float = 55.0,
|
205
|
+
roomNameKey: str = "TOPOLOGIC_name",
|
206
|
+
roomTypeKey: str = "TOPOLOGIC_type",
|
207
|
+
apertureTypeKey: str = "TOPOLOGIC_type",
|
208
|
+
addSensorGrid: bool = False,
|
209
|
+
mantissa: int = 6):
|
209
210
|
"""
|
210
211
|
Creates an HB Model from the input Topology.
|
211
212
|
|
@@ -330,11 +331,11 @@ class Honeybee:
|
|
330
331
|
if tpCellFaces:
|
331
332
|
hbRoomFaces = []
|
332
333
|
for tpFaceNumber, tpCellFace in enumerate(tpCellFaces):
|
333
|
-
tpCellFaceNormal = Face.
|
334
|
+
tpCellFaceNormal = Face.Normal(tpCellFace, mantissa=mantissa)
|
334
335
|
hbRoomFacePoints = []
|
335
336
|
tpFaceVertices = Wire.Vertices(Face.ExternalBoundary(tpCellFace))
|
336
337
|
for tpVertex in tpFaceVertices:
|
337
|
-
hbRoomFacePoints.append(Point3D(
|
338
|
+
hbRoomFacePoints.append(Point3D(Vertex.X(tpVertex, mantissa=mantissa), Vertex.Y(tpVertex, mantissa=mantissa), Vertex.Z(tpVertex, mantissa=mantissa)))
|
338
339
|
hbRoomFace = HBFace(tpCellName+'_Face_'+str(tpFaceNumber+1), Face3D(hbRoomFacePoints))
|
339
340
|
tpFaceApertures = []
|
340
341
|
_ = tpCellFace.Apertures(tpFaceApertures)
|
@@ -349,7 +350,7 @@ class Honeybee:
|
|
349
350
|
tpFaceApertureVertices = []
|
350
351
|
tpFaceApertureVertices = Wire.Vertices(Face.ExternalBoundary(apertureTopology))
|
351
352
|
for tpFaceApertureVertex in tpFaceApertureVertices:
|
352
|
-
hbFaceAperturePoints.append(Point3D(
|
353
|
+
hbFaceAperturePoints.append(Point3D(Vertex.X(tpFaceApertureVertex, mantissa=mantissa), Vertex.Y(tpFaceApertureVertex, mantissa=mantissa), Vertex.Z(tpFaceApertureVertex, mantissa=mantissa)))
|
353
354
|
if(tpFaceApertureType):
|
354
355
|
if ("door" in tpFaceApertureType.lower()):
|
355
356
|
hbFaceAperture = HBDoor(tpCellName+'_Face_'+str(tpFaceNumber+1)+'_Door_'+str(tpFaceApertureNumber), Face3D(hbFaceAperturePoints))
|
@@ -398,7 +399,7 @@ class Honeybee:
|
|
398
399
|
faceVertices = Wire.Vertices(Face.ExternalBoundary(tpShadingFace))
|
399
400
|
facePoints = []
|
400
401
|
for aVertex in faceVertices:
|
401
|
-
facePoints.append(Point3D(
|
402
|
+
facePoints.append(Point3D(Vertex.X(aVertex, mantissa=mantissa), Vertex.Y(aVertex, mantissa=mantissa), Vertex.Z(aVertex, mantissa=mantissa)))
|
402
403
|
hbShadingFace = Face3D(facePoints, None, [])
|
403
404
|
hbShade = HBShade("SHADINGSURFACE_" + str(faceIndex+1), hbShadingFace)
|
404
405
|
hbShades.append(hbShade)
|
topologicpy/Neo4j.py
CHANGED
@@ -276,7 +276,7 @@ class Neo4j:
|
|
276
276
|
return Graph.ByVerticesEdges(vertices,edges)
|
277
277
|
|
278
278
|
@staticmethod
|
279
|
-
def AddGraph(neo4jGraph, graph, labelKey=None, relationshipKey=None, bidirectional=True, deleteAll=True, tolerance=0.0001):
|
279
|
+
def AddGraph(neo4jGraph, graph, labelKey=None, relationshipKey=None, bidirectional=True, deleteAll=True, mantissa: int = 6, tolerance: float = 0.0001):
|
280
280
|
"""
|
281
281
|
Adds the input topologic graph to the input neo4j graph
|
282
282
|
|
@@ -288,6 +288,8 @@ class Neo4j:
|
|
288
288
|
The input topologic graph.
|
289
289
|
categoryKey : str
|
290
290
|
The category key in the dictionary under which to look for the category value.
|
291
|
+
mantissa : int, optional
|
292
|
+
The desired length of the mantissa. The default is 6.
|
291
293
|
tolerance : float , optional
|
292
294
|
The desired tolerance. The default is 0.0001.
|
293
295
|
|
@@ -301,6 +303,7 @@ class Neo4j:
|
|
301
303
|
from topologicpy.Topology import Topology
|
302
304
|
from topologicpy.Graph import Graph
|
303
305
|
from topologicpy.Dictionary import Dictionary
|
306
|
+
|
304
307
|
gmt = time.gmtime()
|
305
308
|
timestamp = str(gmt.tm_zone)+"_"+str(gmt.tm_year)+"_"+str(gmt.tm_mon)+"_"+str(gmt.tm_wday)+"_"+str(gmt.tm_hour)+"_"+str(gmt.tm_min)+"_"+str(gmt.tm_sec)
|
306
309
|
vertices = Graph.Vertices(graph)
|
@@ -316,11 +319,11 @@ class Neo4j:
|
|
316
319
|
keys.append("z")
|
317
320
|
keys.append("timestamp")
|
318
321
|
keys.append("location")
|
319
|
-
values.append(vertices[i]
|
320
|
-
values.append(vertices[i]
|
321
|
-
values.append(vertices[i]
|
322
|
+
values.append(Vertex.X(vertices[i], mantissa=mantissa))
|
323
|
+
values.append(Vertex.Y(vertices[i], mantissa=mantissa))
|
324
|
+
values.append(Vertex.Z(vertices[i], mantissa=mantissa))
|
322
325
|
values.append(timestamp)
|
323
|
-
values.append(sp.CartesianPoint([
|
326
|
+
values.append(sp.CartesianPoint([Vertex.X(vertices[i], mantissa=mantissa), Vertex.Y(vertices[i], mantissa=mantissa), Vertex.Z(vertices[i], mantissa=mantissa)]))
|
324
327
|
zip_iterator = zip(keys, values)
|
325
328
|
pydict = dict(zip_iterator)
|
326
329
|
if labelKey == 'None':
|
@@ -427,7 +430,14 @@ class Neo4j:
|
|
427
430
|
return list(neo4jGraph.schema.relationship_types)
|
428
431
|
|
429
432
|
@staticmethod
|
430
|
-
def SetGraph(neo4jGraph,
|
433
|
+
def SetGraph(neo4jGraph,
|
434
|
+
graph,
|
435
|
+
labelKey: str = None,
|
436
|
+
relationshipKey: str = None,
|
437
|
+
bidirectional: bool = True,
|
438
|
+
deleteAll: bool = True,
|
439
|
+
mantissa: int = 6,
|
440
|
+
tolerance: float = 0.0001):
|
431
441
|
"""
|
432
442
|
Sets the input topologic graph to the input neo4jGraph.
|
433
443
|
|
@@ -445,6 +455,8 @@ class Neo4j:
|
|
445
455
|
If set to True, the edges in the neo4j graph are set to be bi-drectional.
|
446
456
|
deleteAll : bool , optional
|
447
457
|
If set to True, all previous entities are deleted before adding the new entities.
|
458
|
+
mantissa : int , optional
|
459
|
+
The desired length of the mantissa. The default is 6.
|
448
460
|
tolerance : float , optional
|
449
461
|
The desired tolerance. The default is 0.0001.
|
450
462
|
|
@@ -484,11 +496,11 @@ class Neo4j:
|
|
484
496
|
keys.append("z")
|
485
497
|
keys.append("timestamp")
|
486
498
|
keys.append("location")
|
487
|
-
values.append(vertices[i]
|
488
|
-
values.append(vertices[i]
|
489
|
-
values.append(vertices[i]
|
499
|
+
values.append(Vertex.X(vertices[i], mantissa=mantissa))
|
500
|
+
values.append(Vertex.Y(vertices[i], mantissa=mantissa))
|
501
|
+
values.append(Vertex.Z(vertices[i], mantissa=mantissa))
|
490
502
|
values.append(timestamp)
|
491
|
-
values.append(sp.CartesianPoint([
|
503
|
+
values.append(sp.CartesianPoint([Vertex.X(vertices[i], mantissa=mantissa), Vertex.Y(vertices[i], mantissa=mantissa), Vertex.Z(vertices[i], mantissa=mantissa)]))
|
492
504
|
zip_iterator = zip(keys, values)
|
493
505
|
pydict = dict(zip_iterator)
|
494
506
|
if (labelKey == 'None') or (not (labelKey)):
|