compas-cem 0.9.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.
- compas_cem/__init__.py +46 -0
- compas_cem/data/__init__.py +13 -0
- compas_cem/data/data.py +22 -0
- compas_cem/diagrams/__init__.py +14 -0
- compas_cem/diagrams/diagram.py +555 -0
- compas_cem/diagrams/form.py +167 -0
- compas_cem/diagrams/topology/__init__.py +15 -0
- compas_cem/diagrams/topology/mesh_mixins.py +122 -0
- compas_cem/diagrams/topology/topology.py +1016 -0
- compas_cem/elements/__init__.py +16 -0
- compas_cem/elements/deviation.py +50 -0
- compas_cem/elements/edge.py +78 -0
- compas_cem/elements/node.py +62 -0
- compas_cem/elements/trail.py +57 -0
- compas_cem/equilibrium/__init__.py +19 -0
- compas_cem/equilibrium/force.py +442 -0
- compas_cem/equilibrium/force_numpy.py +483 -0
- compas_cem/ghpython/__init__.py +24 -0
- compas_cem/ghpython/components_cpython/CompasCem_Colors/code.py +33 -0
- compas_cem/ghpython/components_cpython/CompasCem_Colors/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_Colors/metadata.json +66 -0
- compas_cem/ghpython/components_cpython/CompasCem_ConstrainedFormFinding/code.py +68 -0
- compas_cem/ghpython/components_cpython/CompasCem_ConstrainedFormFinding/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_ConstrainedFormFinding/metadata.json +103 -0
- compas_cem/ghpython/components_cpython/CompasCem_DisassembleForm/code.py +22 -0
- compas_cem/ghpython/components_cpython/CompasCem_DisassembleForm/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_DisassembleForm/metadata.json +35 -0
- compas_cem/ghpython/components_cpython/CompasCem_DisassembleTopology/code.py +40 -0
- compas_cem/ghpython/components_cpython/CompasCem_DisassembleTopology/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_DisassembleTopology/metadata.json +65 -0
- compas_cem/ghpython/components_cpython/CompasCem_DrawForm/code.py +44 -0
- compas_cem/ghpython/components_cpython/CompasCem_DrawForm/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_DrawForm/metadata.json +68 -0
- compas_cem/ghpython/components_cpython/CompasCem_DrawTopology/code.py +56 -0
- compas_cem/ghpython/components_cpython/CompasCem_DrawTopology/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_DrawTopology/metadata.json +84 -0
- compas_cem/ghpython/components_cpython/CompasCem_EdgeDeviation/code.py +23 -0
- compas_cem/ghpython/components_cpython/CompasCem_EdgeDeviation/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_EdgeDeviation/metadata.json +31 -0
- compas_cem/ghpython/components_cpython/CompasCem_EdgeTrail/code.py +35 -0
- compas_cem/ghpython/components_cpython/CompasCem_EdgeTrail/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_EdgeTrail/metadata.json +36 -0
- compas_cem/ghpython/components_cpython/CompasCem_FormFinding/code.py +29 -0
- compas_cem/ghpython/components_cpython/CompasCem_FormFinding/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_FormFinding/metadata.json +40 -0
- compas_cem/ghpython/components_cpython/CompasCem_GoalDeviationEdgeLength/code.py +27 -0
- compas_cem/ghpython/components_cpython/CompasCem_GoalDeviationEdgeLength/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_GoalDeviationEdgeLength/metadata.json +35 -0
- compas_cem/ghpython/components_cpython/CompasCem_GoalEdgeDirection/code.py +30 -0
- compas_cem/ghpython/components_cpython/CompasCem_GoalEdgeDirection/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_GoalEdgeDirection/metadata.json +35 -0
- compas_cem/ghpython/components_cpython/CompasCem_GoalNodeLine/code.py +30 -0
- compas_cem/ghpython/components_cpython/CompasCem_GoalNodeLine/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_GoalNodeLine/metadata.json +36 -0
- compas_cem/ghpython/components_cpython/CompasCem_GoalNodePlane/code.py +30 -0
- compas_cem/ghpython/components_cpython/CompasCem_GoalNodePlane/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_GoalNodePlane/metadata.json +36 -0
- compas_cem/ghpython/components_cpython/CompasCem_GoalNodePoint/code.py +30 -0
- compas_cem/ghpython/components_cpython/CompasCem_GoalNodePoint/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_GoalNodePoint/metadata.json +36 -0
- compas_cem/ghpython/components_cpython/CompasCem_GoalNodePolyline/code.py +30 -0
- compas_cem/ghpython/components_cpython/CompasCem_GoalNodePolyline/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_GoalNodePolyline/metadata.json +36 -0
- compas_cem/ghpython/components_cpython/CompasCem_GoalReactionForce/code.py +30 -0
- compas_cem/ghpython/components_cpython/CompasCem_GoalReactionForce/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_GoalReactionForce/metadata.json +36 -0
- compas_cem/ghpython/components_cpython/CompasCem_GoalTrailEdgeForce/code.py +27 -0
- compas_cem/ghpython/components_cpython/CompasCem_GoalTrailEdgeForce/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_GoalTrailEdgeForce/metadata.json +35 -0
- compas_cem/ghpython/components_cpython/CompasCem_Info/code.py +30 -0
- compas_cem/ghpython/components_cpython/CompasCem_Info/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_Info/metadata.json +19 -0
- compas_cem/ghpython/components_cpython/CompasCem_JSONExportDiagram/code.py +22 -0
- compas_cem/ghpython/components_cpython/CompasCem_JSONExportDiagram/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_JSONExportDiagram/metadata.json +29 -0
- compas_cem/ghpython/components_cpython/CompasCem_JSONImportForm/code.py +21 -0
- compas_cem/ghpython/components_cpython/CompasCem_JSONImportForm/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_JSONImportForm/metadata.json +25 -0
- compas_cem/ghpython/components_cpython/CompasCem_JSONImportTopology/code.py +21 -0
- compas_cem/ghpython/components_cpython/CompasCem_JSONImportTopology/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_JSONImportTopology/metadata.json +25 -0
- compas_cem/ghpython/components_cpython/CompasCem_NodeLoad/code.py +30 -0
- compas_cem/ghpython/components_cpython/CompasCem_NodeLoad/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_NodeLoad/metadata.json +31 -0
- compas_cem/ghpython/components_cpython/CompasCem_NodeSupport/code.py +23 -0
- compas_cem/ghpython/components_cpython/CompasCem_NodeSupport/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_NodeSupport/metadata.json +26 -0
- compas_cem/ghpython/components_cpython/CompasCem_OriginNodesMove/code.py +35 -0
- compas_cem/ghpython/components_cpython/CompasCem_OriginNodesMove/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_OriginNodesMove/metadata.json +36 -0
- compas_cem/ghpython/components_cpython/CompasCem_ParameterDeviationEdge/code.py +25 -0
- compas_cem/ghpython/components_cpython/CompasCem_ParameterDeviationEdge/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_ParameterDeviationEdge/metadata.json +35 -0
- compas_cem/ghpython/components_cpython/CompasCem_ParameterNodeLoadX/code.py +25 -0
- compas_cem/ghpython/components_cpython/CompasCem_ParameterNodeLoadX/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_ParameterNodeLoadX/metadata.json +36 -0
- compas_cem/ghpython/components_cpython/CompasCem_ParameterNodeLoadY/code.py +25 -0
- compas_cem/ghpython/components_cpython/CompasCem_ParameterNodeLoadY/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_ParameterNodeLoadY/metadata.json +36 -0
- compas_cem/ghpython/components_cpython/CompasCem_ParameterNodeLoadZ/code.py +25 -0
- compas_cem/ghpython/components_cpython/CompasCem_ParameterNodeLoadZ/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_ParameterNodeLoadZ/metadata.json +36 -0
- compas_cem/ghpython/components_cpython/CompasCem_ParameterNodeOriginX/code.py +25 -0
- compas_cem/ghpython/components_cpython/CompasCem_ParameterNodeOriginX/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_ParameterNodeOriginX/metadata.json +36 -0
- compas_cem/ghpython/components_cpython/CompasCem_ParameterNodeOriginY/code.py +25 -0
- compas_cem/ghpython/components_cpython/CompasCem_ParameterNodeOriginY/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_ParameterNodeOriginY/metadata.json +36 -0
- compas_cem/ghpython/components_cpython/CompasCem_ParameterNodeOriginZ/code.py +25 -0
- compas_cem/ghpython/components_cpython/CompasCem_ParameterNodeOriginZ/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_ParameterNodeOriginZ/metadata.json +36 -0
- compas_cem/ghpython/components_cpython/CompasCem_ParameterTrailEdge/code.py +25 -0
- compas_cem/ghpython/components_cpython/CompasCem_ParameterTrailEdge/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_ParameterTrailEdge/metadata.json +35 -0
- compas_cem/ghpython/components_cpython/CompasCem_ResultsEdges/code.py +27 -0
- compas_cem/ghpython/components_cpython/CompasCem_ResultsEdges/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_ResultsEdges/metadata.json +35 -0
- compas_cem/ghpython/components_cpython/CompasCem_ResultsSupportNodes/code.py +27 -0
- compas_cem/ghpython/components_cpython/CompasCem_ResultsSupportNodes/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_ResultsSupportNodes/metadata.json +30 -0
- compas_cem/ghpython/components_cpython/CompasCem_SearchEdgeKey/code.py +30 -0
- compas_cem/ghpython/components_cpython/CompasCem_SearchEdgeKey/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_SearchEdgeKey/metadata.json +30 -0
- compas_cem/ghpython/components_cpython/CompasCem_SearchNodeKey/code.py +25 -0
- compas_cem/ghpython/components_cpython/CompasCem_SearchNodeKey/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_SearchNodeKey/metadata.json +30 -0
- compas_cem/ghpython/components_cpython/CompasCem_TopologyDiagram/code.py +50 -0
- compas_cem/ghpython/components_cpython/CompasCem_TopologyDiagram/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_TopologyDiagram/metadata.json +46 -0
- compas_cem/ghpython/components_cpython/CompasCem_TrailsShift/code.py +32 -0
- compas_cem/ghpython/components_cpython/CompasCem_TrailsShift/icon.png +0 -0
- compas_cem/ghpython/components_cpython/CompasCem_TrailsShift/metadata.json +36 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_Colors.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_ConstrainedFormFinding.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_DisassembleForm.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_DisassembleTopology.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_DrawForm.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_DrawTopology.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_EdgeDeviation.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_EdgeTrail.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_FormFinding.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_GoalDeviationEdgeLength.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_GoalEdgeDirection.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_GoalNodeLine.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_GoalNodePlane.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_GoalNodePoint.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_GoalNodePolyline.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_GoalReactionForce.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_GoalTrailEdgeForce.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_Info.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_JSONExportDiagram.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_JSONImportForm.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_JSONImportTopology.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_NodeLoad.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_NodeSupport.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_OriginNodesMove.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_ParameterDeviationEdge.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_ParameterNodeLoadX.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_ParameterNodeLoadY.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_ParameterNodeLoadZ.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_ParameterNodeOriginX.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_ParameterNodeOriginY.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_ParameterNodeOriginZ.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_ParameterTrailEdge.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_ResultsEdges.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_ResultsSupportNodes.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_SearchEdgeKey.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_SearchNodeKey.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_TopologyDiagram.ghuser +0 -0
- compas_cem/ghpython/components_cpython/ghuser/CompasCem_TrailsShift.ghuser +0 -0
- compas_cem/ghpython/scene_objects.py +406 -0
- compas_cem/ghpython/yak_template/icon.png +0 -0
- compas_cem/ghpython/yak_template/manifest.yml +18 -0
- compas_cem/loads/__init__.py +13 -0
- compas_cem/loads/node.py +65 -0
- compas_cem/optimization/__init__.py +23 -0
- compas_cem/optimization/goals/__init__.py +24 -0
- compas_cem/optimization/goals/direction.py +183 -0
- compas_cem/optimization/goals/force.py +120 -0
- compas_cem/optimization/goals/goal.py +216 -0
- compas_cem/optimization/goals/length.py +34 -0
- compas_cem/optimization/goals/line.py +106 -0
- compas_cem/optimization/goals/mesh.py +30 -0
- compas_cem/optimization/goals/plane.py +27 -0
- compas_cem/optimization/goals/point.py +22 -0
- compas_cem/optimization/goals/polyline.py +140 -0
- compas_cem/optimization/grad.py +53 -0
- compas_cem/optimization/nlopt.py +149 -0
- compas_cem/optimization/objective_func.py +20 -0
- compas_cem/optimization/optimizer.py +415 -0
- compas_cem/optimization/parameters/__init__.py +19 -0
- compas_cem/optimization/parameters/deviation.py +27 -0
- compas_cem/optimization/parameters/edge.py +75 -0
- compas_cem/optimization/parameters/load.py +123 -0
- compas_cem/optimization/parameters/node.py +69 -0
- compas_cem/optimization/parameters/origin.py +124 -0
- compas_cem/optimization/parameters/parameter.py +75 -0
- compas_cem/optimization/parameters/trail.py +27 -0
- compas_cem/plotters/__init__.py +26 -0
- compas_cem/plotters/plotter.py +14 -0
- compas_cem/plotters/scene_objects.py +787 -0
- compas_cem/supports/__init__.py +13 -0
- compas_cem/supports/node.py +64 -0
- compas_cem/viewers/__init__.py +26 -0
- compas_cem/viewers/scene_objects.py +582 -0
- compas_cem/viewers/viewer.py +14 -0
- compas_cem-0.9.0.dist-info/METADATA +167 -0
- compas_cem-0.9.0.dist-info/RECORD +212 -0
- compas_cem-0.9.0.dist-info/WHEEL +5 -0
- compas_cem-0.9.0.dist-info/licenses/AUTHORS.md +37 -0
- compas_cem-0.9.0.dist-info/licenses/LICENSE +21 -0
- compas_cem-0.9.0.dist-info/top_level.txt +1 -0
compas_cem/__init__.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""
|
|
2
|
+
The Combinatorial Equilibrium Modeling framework for COMPAS.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from __future__ import print_function
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
|
|
9
|
+
__author__ = ["Rafael Pastrana"]
|
|
10
|
+
__copyright__ = "Copyright 2020 - Princeton University"
|
|
11
|
+
__license__ = "MIT License"
|
|
12
|
+
__email__ = "arpj@princeton.edu"
|
|
13
|
+
__version__ = "0.9.0"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# Directories
|
|
17
|
+
HERE = os.path.dirname(__file__)
|
|
18
|
+
HOME = os.path.abspath(os.path.join(HERE, "../../"))
|
|
19
|
+
DATA = os.path.abspath(os.path.join(HOME, "data"))
|
|
20
|
+
DOCS = os.path.abspath(os.path.join(HOME, "docs"))
|
|
21
|
+
TEMP = os.path.abspath(os.path.join(HOME, "temp"))
|
|
22
|
+
JSON_DATA = os.path.abspath(os.path.join(DATA, "json"))
|
|
23
|
+
|
|
24
|
+
# RGB color scheme
|
|
25
|
+
COLORS = {
|
|
26
|
+
"tension": (227, 6, 75), # red
|
|
27
|
+
"compression": (12, 119, 184), # blue
|
|
28
|
+
"edge": (50, 50, 50), # dark gray
|
|
29
|
+
"node": (255, 255, 255), # white
|
|
30
|
+
"node_black": (0, 0, 0), # black
|
|
31
|
+
"node_support": (0, 150, 10), # green
|
|
32
|
+
"node_origin": (155, 100, 255), # purple
|
|
33
|
+
"edge_trail": (180, 0, 255), # purple
|
|
34
|
+
"edge_deviation": (127, 255, 0), # lime (127, 155, 0)
|
|
35
|
+
"edge_deviation_indirect": (255, 100, 47), # coral
|
|
36
|
+
"support_force": (75, 75, 75), # dark gray
|
|
37
|
+
"load": (0, 150, 10), # green
|
|
38
|
+
"trail": (250, 80, 210), # pink
|
|
39
|
+
"auxiliary_trail": (255, 155, 15), # orange
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
# TODO: add static equilibrium plugin
|
|
43
|
+
# The plotter, viewer and Grasshopper scene objects register themselves when
|
|
44
|
+
# their package is imported, so no plugin module is declared here.
|
|
45
|
+
|
|
46
|
+
__all__ = ["HOME", "DATA", "DOCS", "TEMP", "JSON_DATA", "COLORS"]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""
|
|
2
|
+
The base class every serializable COMPAS CEM object inherits from.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from __future__ import absolute_import
|
|
6
|
+
from __future__ import division
|
|
7
|
+
from __future__ import print_function
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# from .<module> import *
|
|
11
|
+
from .data import * # noqa F403
|
|
12
|
+
|
|
13
|
+
__all__ = [name for name in dir() if not name.startswith("_")]
|
compas_cem/data/data.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from compas.data import Data
|
|
2
|
+
|
|
3
|
+
__all__ = ["Data"]
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
# ==============================================================================
|
|
7
|
+
# Data base class
|
|
8
|
+
# ==============================================================================
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Data(Data):
|
|
12
|
+
"""
|
|
13
|
+
The base class every serializable COMPAS CEM object inherits from.
|
|
14
|
+
|
|
15
|
+
Notes
|
|
16
|
+
-----
|
|
17
|
+
This exists as a single seam over the COMPAS base class, so the package can
|
|
18
|
+
change what all of its serializable objects share without touching each one.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def __init__(self, **kwargs):
|
|
22
|
+
super(Data, self).__init__(**kwargs)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Topology and form diagrams.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from __future__ import absolute_import
|
|
6
|
+
from __future__ import division
|
|
7
|
+
from __future__ import print_function
|
|
8
|
+
|
|
9
|
+
from .diagram import * # noqa F403
|
|
10
|
+
from .topology import * # noqa F403
|
|
11
|
+
from .form import * # noqa F403
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
__all__ = [name for name in dir() if not name.startswith("_")]
|
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
from compas.data import Data
|
|
2
|
+
from compas.datastructures import Graph
|
|
3
|
+
from compas.geometry import length_vector
|
|
4
|
+
from compas.tolerance import TOL
|
|
5
|
+
|
|
6
|
+
from compas_cem.elements import Edge
|
|
7
|
+
from compas_cem.elements import Node
|
|
8
|
+
|
|
9
|
+
__all__ = ["Diagram"]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# ==============================================================================
|
|
13
|
+
# Diagram
|
|
14
|
+
# ==============================================================================
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Diagram(Graph):
|
|
18
|
+
"""
|
|
19
|
+
Base class that shares functionality across diagrams.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __init__(self, *args, **kwargs):
|
|
23
|
+
super(Diagram, self).__init__(*args, **kwargs)
|
|
24
|
+
|
|
25
|
+
self.update_default_node_attributes(
|
|
26
|
+
{
|
|
27
|
+
"x": 0.0,
|
|
28
|
+
"y": 0.0,
|
|
29
|
+
"z": 0.0,
|
|
30
|
+
"qx": 0.0,
|
|
31
|
+
"qy": 0.0,
|
|
32
|
+
"qz": 0.0,
|
|
33
|
+
"rx": 0.0,
|
|
34
|
+
"ry": 0.0,
|
|
35
|
+
"rz": 0.0,
|
|
36
|
+
"_k": None,
|
|
37
|
+
"type": None,
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
self.update_default_edge_attributes({"type": None, "length": 0.0, "force": 0.0})
|
|
42
|
+
|
|
43
|
+
self.attributes["gkey_node"] = {}
|
|
44
|
+
self.attributes["tol"] = 3
|
|
45
|
+
|
|
46
|
+
# ==============================================================================
|
|
47
|
+
# Properties
|
|
48
|
+
# ==============================================================================
|
|
49
|
+
|
|
50
|
+
@property
|
|
51
|
+
def tol(self):
|
|
52
|
+
"""
|
|
53
|
+
The number of decimal places used to compare node coordinates.
|
|
54
|
+
"""
|
|
55
|
+
return self.attributes["tol"]
|
|
56
|
+
|
|
57
|
+
@tol.setter
|
|
58
|
+
def tol(self, tol):
|
|
59
|
+
self.attributes["tol"] = tol
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def gkey_node(self):
|
|
63
|
+
"""
|
|
64
|
+
A dictionary that maps geometric keys to node keys.
|
|
65
|
+
|
|
66
|
+
Notes
|
|
67
|
+
-----
|
|
68
|
+
This shadows the base graph method of the same name. The mapping here is
|
|
69
|
+
a cache maintained as elements are added, rather than one recomputed from
|
|
70
|
+
the current node coordinates on every call.
|
|
71
|
+
"""
|
|
72
|
+
return self.attributes["gkey_node"]
|
|
73
|
+
|
|
74
|
+
# ==============================================================================
|
|
75
|
+
# Elements
|
|
76
|
+
# ==============================================================================
|
|
77
|
+
|
|
78
|
+
def add_node(self, node=None, key=None, attr_dict=None, **kwattr):
|
|
79
|
+
"""
|
|
80
|
+
Add a node to the diagram, from a node element or from a key.
|
|
81
|
+
|
|
82
|
+
Parameters
|
|
83
|
+
----------
|
|
84
|
+
node :
|
|
85
|
+
A node element, or a node key given positionally.
|
|
86
|
+
key :
|
|
87
|
+
A node key. If `None`, the next available key is assigned.
|
|
88
|
+
attr_dict :
|
|
89
|
+
The attributes to store on the node.
|
|
90
|
+
**kwattr :
|
|
91
|
+
Extra attributes to store on the node.
|
|
92
|
+
|
|
93
|
+
Returns
|
|
94
|
+
-------
|
|
95
|
+
key :
|
|
96
|
+
The key of the added node.
|
|
97
|
+
|
|
98
|
+
Notes
|
|
99
|
+
-----
|
|
100
|
+
This accepts both vocabularies. A node element carries its own
|
|
101
|
+
coordinates and is indexed by its geometric key, which is how a diagram
|
|
102
|
+
is authored. A bare key with attributes is how the base graph adds a
|
|
103
|
+
node, and how deserialization replays one.
|
|
104
|
+
"""
|
|
105
|
+
if isinstance(node, Node):
|
|
106
|
+
return self._add_node_element(node)
|
|
107
|
+
|
|
108
|
+
if isinstance(node, Edge):
|
|
109
|
+
raise TypeError("an edge element must be added with add_edge")
|
|
110
|
+
|
|
111
|
+
if node is not None:
|
|
112
|
+
if key is not None:
|
|
113
|
+
raise ValueError("a node key was given both positionally and by name")
|
|
114
|
+
key = node
|
|
115
|
+
|
|
116
|
+
if isinstance(key, Data):
|
|
117
|
+
raise TypeError(f"{key!r} is not a node key")
|
|
118
|
+
|
|
119
|
+
return super(Diagram, self).add_node(key=key, attr_dict=attr_dict, **kwattr)
|
|
120
|
+
|
|
121
|
+
def add_edge(self, edge=None, v=None, attr_dict=None, **kwattr):
|
|
122
|
+
"""
|
|
123
|
+
Add an edge to the diagram, from an edge element or from two node keys.
|
|
124
|
+
|
|
125
|
+
Parameters
|
|
126
|
+
----------
|
|
127
|
+
edge :
|
|
128
|
+
An edge element, or the first node of the edge given positionally.
|
|
129
|
+
v :
|
|
130
|
+
The second node of the edge, when the first was given as a key.
|
|
131
|
+
attr_dict :
|
|
132
|
+
The attributes to store on the edge.
|
|
133
|
+
**kwattr :
|
|
134
|
+
Extra attributes to store on the edge.
|
|
135
|
+
|
|
136
|
+
Returns
|
|
137
|
+
-------
|
|
138
|
+
key :
|
|
139
|
+
The two node keys of the added edge.
|
|
140
|
+
|
|
141
|
+
Notes
|
|
142
|
+
-----
|
|
143
|
+
This accepts both vocabularies, as `add_node` does. An edge element
|
|
144
|
+
carries its own attributes and may name its end nodes by coordinates,
|
|
145
|
+
creating them if no node sits there yet.
|
|
146
|
+
"""
|
|
147
|
+
if isinstance(edge, Edge):
|
|
148
|
+
if v is not None:
|
|
149
|
+
raise ValueError("an edge element already names both of its nodes")
|
|
150
|
+
return self._add_edge_element(edge)
|
|
151
|
+
|
|
152
|
+
if isinstance(edge, Node):
|
|
153
|
+
raise TypeError("a node element must be added with add_node")
|
|
154
|
+
|
|
155
|
+
return super(Diagram, self).add_edge(edge, v, attr_dict=attr_dict, **kwattr)
|
|
156
|
+
|
|
157
|
+
def _add_node_element(self, node):
|
|
158
|
+
"""
|
|
159
|
+
Add a node element and index it by its geometric key.
|
|
160
|
+
"""
|
|
161
|
+
xyz = node.xyz
|
|
162
|
+
x, y, z = xyz
|
|
163
|
+
|
|
164
|
+
key = super(Diagram, self).add_node(key=node.key, x=x, y=y, z=z)
|
|
165
|
+
self.gkey_node[self.gkey(xyz)] = key
|
|
166
|
+
|
|
167
|
+
return key
|
|
168
|
+
|
|
169
|
+
def _add_edge_element(self, edge):
|
|
170
|
+
"""
|
|
171
|
+
Add an edge element, creating any of its end nodes that do not exist yet.
|
|
172
|
+
"""
|
|
173
|
+
edge_keys = []
|
|
174
|
+
|
|
175
|
+
for node in edge:
|
|
176
|
+
key = self.node_key(node)
|
|
177
|
+
|
|
178
|
+
if key is None:
|
|
179
|
+
key = self._add_node_element(Node(xyz=node))
|
|
180
|
+
|
|
181
|
+
edge_keys.append(key)
|
|
182
|
+
|
|
183
|
+
u, v = edge_keys
|
|
184
|
+
attr = {k: v for k, v in edge.attributes.items()}
|
|
185
|
+
|
|
186
|
+
return super(Diagram, self).add_edge(u, v, attr_dict=attr)
|
|
187
|
+
|
|
188
|
+
# ==============================================================================
|
|
189
|
+
# Node lookups
|
|
190
|
+
# ==============================================================================
|
|
191
|
+
|
|
192
|
+
def node_exists(self, value):
|
|
193
|
+
"""
|
|
194
|
+
Check whether a node key or a point resolves to a node in the diagram.
|
|
195
|
+
|
|
196
|
+
Parameters
|
|
197
|
+
----------
|
|
198
|
+
value :
|
|
199
|
+
A node key, or the xyz coordinates of a point.
|
|
200
|
+
|
|
201
|
+
Returns
|
|
202
|
+
-------
|
|
203
|
+
flag :
|
|
204
|
+
`True` if the value resolves to a node. `False` otherwise.
|
|
205
|
+
"""
|
|
206
|
+
if self.node_key(value) is not None:
|
|
207
|
+
return True
|
|
208
|
+
return False
|
|
209
|
+
|
|
210
|
+
def node_key(self, value):
|
|
211
|
+
"""
|
|
212
|
+
Resolve a node key or a point to a node key.
|
|
213
|
+
|
|
214
|
+
Parameters
|
|
215
|
+
----------
|
|
216
|
+
value :
|
|
217
|
+
A node key, or the xyz coordinates of a point.
|
|
218
|
+
|
|
219
|
+
Returns
|
|
220
|
+
-------
|
|
221
|
+
key :
|
|
222
|
+
The node key, or `None` if no node sits at the given point.
|
|
223
|
+
|
|
224
|
+
Notes
|
|
225
|
+
-----
|
|
226
|
+
An integer is taken to be a node key and is returned unchanged, whether
|
|
227
|
+
or not a node with that key exists.
|
|
228
|
+
"""
|
|
229
|
+
if isinstance(value, int):
|
|
230
|
+
return value
|
|
231
|
+
return self.gkey_node.get(self.gkey(value))
|
|
232
|
+
|
|
233
|
+
def update_node_xyz(self, key, xyz):
|
|
234
|
+
"""
|
|
235
|
+
Move a node to new coordinates and reindex its geometric key.
|
|
236
|
+
|
|
237
|
+
Parameters
|
|
238
|
+
----------
|
|
239
|
+
key :
|
|
240
|
+
A node key.
|
|
241
|
+
xyz :
|
|
242
|
+
The new xyz coordinates of the node.
|
|
243
|
+
"""
|
|
244
|
+
gkey = self.gkey(xyz)
|
|
245
|
+
if gkey in self.gkey_node:
|
|
246
|
+
del self.gkey_node[gkey]
|
|
247
|
+
self._add_node_element(Node(key, xyz))
|
|
248
|
+
|
|
249
|
+
def node_xyz(self, key, xyz=None):
|
|
250
|
+
"""
|
|
251
|
+
Get or set the coordinates of a node.
|
|
252
|
+
|
|
253
|
+
Parameters
|
|
254
|
+
----------
|
|
255
|
+
key :
|
|
256
|
+
A node key.
|
|
257
|
+
xyz :
|
|
258
|
+
The new xyz coordinates of the node. If `None`, the current
|
|
259
|
+
coordinates are returned instead.
|
|
260
|
+
|
|
261
|
+
Returns
|
|
262
|
+
-------
|
|
263
|
+
xyz :
|
|
264
|
+
The coordinates of the node, or `None` when setting them.
|
|
265
|
+
"""
|
|
266
|
+
if xyz is None:
|
|
267
|
+
return self.node_coordinates(key)
|
|
268
|
+
self.update_node_xyz(key, xyz)
|
|
269
|
+
|
|
270
|
+
def gkey(self, xyz):
|
|
271
|
+
"""
|
|
272
|
+
Compute the geometric key of a point at the tolerance of the diagram.
|
|
273
|
+
|
|
274
|
+
Parameters
|
|
275
|
+
----------
|
|
276
|
+
xyz :
|
|
277
|
+
The xyz coordinates of a point.
|
|
278
|
+
|
|
279
|
+
Returns
|
|
280
|
+
-------
|
|
281
|
+
gkey :
|
|
282
|
+
The geometric key of the point.
|
|
283
|
+
"""
|
|
284
|
+
return TOL.geometric_key(xyz, self.tol)
|
|
285
|
+
|
|
286
|
+
# ==============================================================================
|
|
287
|
+
# Edge collections
|
|
288
|
+
# ==============================================================================
|
|
289
|
+
|
|
290
|
+
def node_connected_edges(self, node):
|
|
291
|
+
"""
|
|
292
|
+
The edges incident to a node.
|
|
293
|
+
|
|
294
|
+
Parameters
|
|
295
|
+
----------
|
|
296
|
+
node :
|
|
297
|
+
A node key.
|
|
298
|
+
|
|
299
|
+
Returns
|
|
300
|
+
-------
|
|
301
|
+
edges :
|
|
302
|
+
The keys of the edges connected to the node.
|
|
303
|
+
|
|
304
|
+
Notes
|
|
305
|
+
-----
|
|
306
|
+
Each edge is reported in the direction it is stored in, so that the key
|
|
307
|
+
returned here can be used to look edge attributes up directly.
|
|
308
|
+
"""
|
|
309
|
+
edges = []
|
|
310
|
+
|
|
311
|
+
for neighbor in self.neighbors(node):
|
|
312
|
+
if neighbor in self.edge[node]:
|
|
313
|
+
edges.append((node, neighbor))
|
|
314
|
+
else:
|
|
315
|
+
edges.append((neighbor, node))
|
|
316
|
+
|
|
317
|
+
return edges
|
|
318
|
+
|
|
319
|
+
# ==============================================================================
|
|
320
|
+
# Node collections
|
|
321
|
+
# ==============================================================================
|
|
322
|
+
|
|
323
|
+
def support_nodes(self):
|
|
324
|
+
"""
|
|
325
|
+
Nodes where a support has been assigned.
|
|
326
|
+
|
|
327
|
+
Yields
|
|
328
|
+
------
|
|
329
|
+
support_node :
|
|
330
|
+
The key of the next node with a support.
|
|
331
|
+
"""
|
|
332
|
+
return self.nodes_where({"type": "support"})
|
|
333
|
+
|
|
334
|
+
def loaded_nodes(self, min_force=1e-6):
|
|
335
|
+
"""
|
|
336
|
+
Iterate over all the nodes with a large-enough load applied.
|
|
337
|
+
|
|
338
|
+
Parameters
|
|
339
|
+
----------
|
|
340
|
+
min_force :
|
|
341
|
+
The minimum force magnitude to consider a node loaded.
|
|
342
|
+
|
|
343
|
+
Yields
|
|
344
|
+
------
|
|
345
|
+
loaded_node :
|
|
346
|
+
The key of the next loaded node.
|
|
347
|
+
"""
|
|
348
|
+
for node in self.nodes():
|
|
349
|
+
if self.is_node_loaded(node, min_force):
|
|
350
|
+
yield node
|
|
351
|
+
|
|
352
|
+
# ==============================================================================
|
|
353
|
+
# Counters
|
|
354
|
+
# ==============================================================================
|
|
355
|
+
|
|
356
|
+
def number_of_support_nodes(self):
|
|
357
|
+
"""
|
|
358
|
+
Number of nodes in the diagram with an assigned support.
|
|
359
|
+
|
|
360
|
+
Returns
|
|
361
|
+
-------
|
|
362
|
+
number :
|
|
363
|
+
The number of nodes with a support.
|
|
364
|
+
"""
|
|
365
|
+
return len(list(self.support_nodes()))
|
|
366
|
+
|
|
367
|
+
def number_of_loaded_nodes(self):
|
|
368
|
+
"""
|
|
369
|
+
Number of nodes in the diagram where a load is applied.
|
|
370
|
+
|
|
371
|
+
Returns
|
|
372
|
+
-------
|
|
373
|
+
number :
|
|
374
|
+
The number of nodes with an applied load.
|
|
375
|
+
"""
|
|
376
|
+
return len(list(self.loaded_nodes()))
|
|
377
|
+
|
|
378
|
+
# ==============================================================================
|
|
379
|
+
# Node Filters
|
|
380
|
+
# ==============================================================================
|
|
381
|
+
|
|
382
|
+
def is_node_support(self, node):
|
|
383
|
+
"""
|
|
384
|
+
Check if a node is a support.
|
|
385
|
+
|
|
386
|
+
Parameters
|
|
387
|
+
----------
|
|
388
|
+
node :
|
|
389
|
+
A node key.
|
|
390
|
+
|
|
391
|
+
Returns
|
|
392
|
+
-------
|
|
393
|
+
flag :
|
|
394
|
+
`True` if the node is a support. `False` otherwise.
|
|
395
|
+
"""
|
|
396
|
+
return self.node_attribute(key=node, name="type") == "support"
|
|
397
|
+
|
|
398
|
+
def is_node_loaded(self, node, min_force=1e-6):
|
|
399
|
+
"""
|
|
400
|
+
Check if there is a large-enough load applied to a node.
|
|
401
|
+
|
|
402
|
+
Parameters
|
|
403
|
+
----------
|
|
404
|
+
node :
|
|
405
|
+
A node key.
|
|
406
|
+
min_force :
|
|
407
|
+
The minimum force magnitude to consider a node loaded.
|
|
408
|
+
|
|
409
|
+
Returns
|
|
410
|
+
-------
|
|
411
|
+
flag :
|
|
412
|
+
`True` if the node is loaded. `False` otherwise.
|
|
413
|
+
"""
|
|
414
|
+
return length_vector(self.node_load(node)) > min_force
|
|
415
|
+
|
|
416
|
+
# ==============================================================================
|
|
417
|
+
# Edge Filters
|
|
418
|
+
# ==============================================================================
|
|
419
|
+
|
|
420
|
+
def is_edge_supported(self, edge):
|
|
421
|
+
"""
|
|
422
|
+
Check if any of the nodes of an edge is a support.
|
|
423
|
+
|
|
424
|
+
Parameters
|
|
425
|
+
----------
|
|
426
|
+
edge :
|
|
427
|
+
An edge key.
|
|
428
|
+
|
|
429
|
+
Returns
|
|
430
|
+
-------
|
|
431
|
+
flag :
|
|
432
|
+
`True` if any of the edge nodes is a support. `False` otherwise.
|
|
433
|
+
"""
|
|
434
|
+
return any([self.is_node_support(node) for node in edge])
|
|
435
|
+
|
|
436
|
+
# ==============================================================================
|
|
437
|
+
# Node Attributes
|
|
438
|
+
# ==============================================================================
|
|
439
|
+
|
|
440
|
+
def node_load(self, node):
|
|
441
|
+
"""
|
|
442
|
+
Get the load applied at a node.
|
|
443
|
+
|
|
444
|
+
Parameters
|
|
445
|
+
----------
|
|
446
|
+
node :
|
|
447
|
+
A node key.
|
|
448
|
+
|
|
449
|
+
Returns
|
|
450
|
+
-------
|
|
451
|
+
load_vector :
|
|
452
|
+
A vector with the xyz components of the load.
|
|
453
|
+
"""
|
|
454
|
+
return self.node_attributes(key=node, names=["qx", "qy", "qz"])
|
|
455
|
+
|
|
456
|
+
def reaction_force(self, node):
|
|
457
|
+
"""
|
|
458
|
+
Get the reaction force vector at a node.
|
|
459
|
+
|
|
460
|
+
Parameters
|
|
461
|
+
----------
|
|
462
|
+
node :
|
|
463
|
+
A node key.
|
|
464
|
+
|
|
465
|
+
Returns
|
|
466
|
+
-------
|
|
467
|
+
reaction_vector :
|
|
468
|
+
A vector with the xyz components of the reaction force.
|
|
469
|
+
"""
|
|
470
|
+
return self.node_attributes(key=node, names=["rx", "ry", "rz"])
|
|
471
|
+
|
|
472
|
+
# ==============================================================================
|
|
473
|
+
# Edge Attributes
|
|
474
|
+
# ==============================================================================
|
|
475
|
+
|
|
476
|
+
def edge_force(self, edge):
|
|
477
|
+
"""
|
|
478
|
+
Get the force value at an edge.
|
|
479
|
+
|
|
480
|
+
Parameters
|
|
481
|
+
----------
|
|
482
|
+
edge :
|
|
483
|
+
An edge key.
|
|
484
|
+
|
|
485
|
+
Returns
|
|
486
|
+
-------
|
|
487
|
+
force :
|
|
488
|
+
The force value in the edge. Negative in compression, positive in
|
|
489
|
+
tension.
|
|
490
|
+
"""
|
|
491
|
+
return self.edge_attribute(key=edge, name="force")
|
|
492
|
+
|
|
493
|
+
def edge_length_2(self, edge):
|
|
494
|
+
"""
|
|
495
|
+
Get the stored length attribute of an edge.
|
|
496
|
+
|
|
497
|
+
Parameters
|
|
498
|
+
----------
|
|
499
|
+
edge :
|
|
500
|
+
An edge key.
|
|
501
|
+
|
|
502
|
+
Returns
|
|
503
|
+
-------
|
|
504
|
+
length :
|
|
505
|
+
The signed length of the edge.
|
|
506
|
+
|
|
507
|
+
Notes
|
|
508
|
+
-----
|
|
509
|
+
This is the length carried as an edge attribute, which is signed and set
|
|
510
|
+
by the user, not the distance between the two end nodes.
|
|
511
|
+
"""
|
|
512
|
+
return self.edge_attribute(key=edge, name="length")
|
|
513
|
+
|
|
514
|
+
def edge_plane(self, edge):
|
|
515
|
+
"""
|
|
516
|
+
Get the projection plane at an edge.
|
|
517
|
+
|
|
518
|
+
Parameters
|
|
519
|
+
----------
|
|
520
|
+
edge :
|
|
521
|
+
An edge key.
|
|
522
|
+
|
|
523
|
+
Returns
|
|
524
|
+
-------
|
|
525
|
+
plane :
|
|
526
|
+
The projection plane of the edge, or `None` if it has none.
|
|
527
|
+
"""
|
|
528
|
+
return self.edge_attribute(key=edge, name="plane")
|
|
529
|
+
|
|
530
|
+
# ==============================================================================
|
|
531
|
+
# Magic methods
|
|
532
|
+
# ==============================================================================
|
|
533
|
+
|
|
534
|
+
def __repr__(self):
|
|
535
|
+
tpl = "{}(\n\tEdges: {}\n\tNodes: {}\n\tSupport Nodes: {}\n\tLoaded nodes: {}\n\t)"
|
|
536
|
+
data = [
|
|
537
|
+
self.__class__.__name__,
|
|
538
|
+
self.number_of_edges(),
|
|
539
|
+
self.number_of_nodes(),
|
|
540
|
+
self.number_of_support_nodes(),
|
|
541
|
+
self.number_of_loaded_nodes(),
|
|
542
|
+
]
|
|
543
|
+
return tpl.format(*data)
|
|
544
|
+
|
|
545
|
+
def __str__(self):
|
|
546
|
+
return self.__repr__()
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
# ==============================================================================
|
|
550
|
+
# Main
|
|
551
|
+
# ==============================================================================
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
if __name__ == "__main__":
|
|
555
|
+
pass
|