Skip to content

Commit

Permalink
update code
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanmele committed Jan 25, 2024
1 parent 20aed62 commit da66d43
Show file tree
Hide file tree
Showing 25 changed files with 349 additions and 302 deletions.
42 changes: 11 additions & 31 deletions src/compas_fd/__init__.py
Original file line number Diff line number Diff line change
@@ -1,47 +1,27 @@
"""
********************************************************************************
compas_fd
********************************************************************************
.. currentmodule:: compas_fd
.. toctree::
:maxdepth: 1
compas_fd.constraints
compas_fd.datastructures
compas_fd.fd
compas_fd.loads
"""

from __future__ import print_function

import os
import compas


__author__ = ['tom van mele <van.mele@arch.ethz.ch>']
__copyright__ = 'Block Research Group - ETH Zurich'
__license__ = 'MIT License'
__email__ = 'van.mele@arch.ethz.ch'
__version__ = '0.4.1'
__author__ = ["tom van mele <tom.v.mele@gmail.com>"]
__copyright__ = "Block Research Group - ETH Zurich"
__license__ = "MIT License"
__email__ = "tom.v.mele@gmail.com"
__version__ = "0.4.1"


get = compas.get


HERE = os.path.dirname(__file__)

HOME = os.path.abspath(os.path.join(HERE, '../../'))
DATA = os.path.abspath(os.path.join(HOME, 'data'))
DOCS = os.path.abspath(os.path.join(HOME, 'docs'))
TEMP = os.path.abspath(os.path.join(HOME, 'temp'))
HOME = os.path.abspath(os.path.join(HERE, "../../"))
DATA = os.path.abspath(os.path.join(HOME, "data"))
DOCS = os.path.abspath(os.path.join(HOME, "docs"))
TEMP = os.path.abspath(os.path.join(HOME, "temp"))


__all__ = ['HOME', 'DATA', 'DOCS', 'TEMP', 'get']
__all__ = ["HOME", "DATA", "DOCS", "TEMP", "get"]

__all_plugins__ = [
'compas_fd.install'
]
__all_plugins__ = ["compas_fd.install"]
33 changes: 0 additions & 33 deletions src/compas_fd/constraints/__init__.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,3 @@
"""
***************************
constraints
***************************
.. currentmodule:: compas_fd.constraints
Base Class
==========
.. autosummary::
:toctree: generated/
:nosignatures:
Constraint
Classes
=======
.. autosummary::
:toctree: generated/
:nosignatures:
CircleConstraint
CurveConstraint
FrameConstraint
LineConstraint
PlaneConstraint
SurfaceConstraint
VectorConstraint
"""

from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
Expand Down
9 changes: 2 additions & 7 deletions src/compas_fd/constraints/circleconstraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,14 @@ def __init__(self, curve, **kwargs):
super(CircleConstraint, self).__init__(geometry=curve, **kwargs)

@property
def data(self):
def __data__(self):
return {
"geometry": self.geometry.data,
"rhino_guid": str(self._rhino_guid),
}

@data.setter
def data(self, data):
self.geometry = Circle.from_data(data["geometry"])
self._rhino_guid = str(data["rhino_guid"])

@classmethod
def from_data(cls, data):
def __from_data__(cls, data):
curve = Circle.from_data(data["geometry"])
constraint = cls(curve)
constraint._rhino_guid = str(data["rhino_guid"])
Expand Down
12 changes: 6 additions & 6 deletions src/compas_fd/constraints/constraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ class Constraint(Data):

GEOMETRY_CONSTRAINT = {}

@staticmethod
def register(gtype, ctype):
Constraint.GEOMETRY_CONSTRAINT[gtype] = ctype

@staticmethod
def get_constraint_cls(geometry, **kwargs):
gtype = type(geometry)
Expand All @@ -37,8 +41,8 @@ def __new__(cls, *args, **kwargs):
cls = Constraint.get_constraint_cls(geometry)
return super(Constraint, cls).__new__(cls)

def __init__(self, geometry, **kwargs):
super(Constraint, self).__init__(**kwargs)
def __init__(self, geometry, name=None):
super(Constraint, self).__init__(name=name)
self._geometry = None
self._location = None
self._residual = None
Expand All @@ -48,10 +52,6 @@ def __init__(self, geometry, **kwargs):
self._param = None
self.geometry = geometry

@staticmethod
def register(gtype, ctype):
Constraint.GEOMETRY_CONSTRAINT[gtype] = ctype

@property
def geometry(self):
return self._geometry
Expand Down
9 changes: 2 additions & 7 deletions src/compas_fd/constraints/curveconstraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,14 @@ def __init__(self, curve, **kwargs):
super(CurveConstraint, self).__init__(geometry=curve, **kwargs)

@property
def data(self):
def __data__(self):
return {
"geometry": self.geometry.data,
"rhino_guid": str(self._rhino_guid),
}

@data.setter
def data(self, data):
self.geometry = NurbsCurve.from_data(data["geometry"])
self._rhino_guid = str(data["rhino_guid"])

@classmethod
def from_data(cls, data):
def __from_data__(cls, data):
curve = NurbsCurve.from_data(data["geometry"])
constraint = cls(curve)
constraint._rhino_guid = str(data["rhino_guid"])
Expand Down
9 changes: 2 additions & 7 deletions src/compas_fd/constraints/frameconstraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,14 @@ def __init__(self, frame, **kwargs):
super(FrameConstraint, self).__init__(geometry=frame, **kwargs)

@property
def data(self):
def __data__(self):
return {
"geometry": self.geometry.data,
"rhino_guid": str(self._rhino_guid),
}

@data.setter
def data(self, data):
self.geometry = Frame.from_data(data["geometry"])
self._rhino_guid = str(data["rhino_guid"])

@classmethod
def from_data(cls, data):
def __from_data__(cls, data):
frame = Frame.from_data(data["geometry"])
constraint = cls(frame)
constraint._rhino_guid = str(data["rhino_guid"])
Expand Down
9 changes: 2 additions & 7 deletions src/compas_fd/constraints/lineconstraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,14 @@ def __init__(self, line, **kwargs):
super(LineConstraint, self).__init__(geometry=line, **kwargs)

@property
def data(self):
def __data__(self):
return {
"geometry": self.geometry.data,
"rhino_guid": str(self._rhino_guid),
}

@data.setter
def data(self, data):
self.geometry = Line.from_data(data["geometry"])
self._rhino_guid = str(data["rhino_guid"])

@classmethod
def from_data(cls, data):
def __from_data__(cls, data):
line = Line.from_data(data["geometry"])
constraint = cls(line)
constraint._rhino_guid = str(data["rhino_guid"])
Expand Down
9 changes: 2 additions & 7 deletions src/compas_fd/constraints/planeconstraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,14 @@ def __init__(self, plane, **kwargs):
super(PlaneConstraint, self).__init__(geometry=plane, **kwargs)

@property
def data(self):
def __data__(self):
return {
"geometry": self.geometry.data,
"rhino_guid": str(self._rhino_guid),
}

@data.setter
def data(self, data):
self.geometry = Plane.from_data(data["geometry"])
self._rhino_guid = str(data["rhino_guid"])

@classmethod
def from_data(cls, data):
def __from_data__(cls, data):
plane = Plane.from_data(data["geometry"])
constraint = cls(plane)
constraint._rhino_guid = str(data["rhino_guid"])
Expand Down
9 changes: 2 additions & 7 deletions src/compas_fd/constraints/surfaceconstraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,14 @@ def __init__(self, surface, **kwargs):
super(SurfaceConstraint, self).__init__(geometry=surface, **kwargs)

@property
def data(self):
def __data__(self):
return {
"geometry": self.geometry.data,
"rhino_guid": str(self._rhino_guid),
}

@data.setter
def data(self, data):
self.geometry = NurbsSurface.from_data(data["geometry"])
self._rhino_guid = str(data["rhino_guid"])

@classmethod
def from_data(cls, data):
def __from_data__(cls, data):
srf = NurbsSurface.from_data(data["geometry"])
constraint = cls(srf)
constraint._rhino_guid = str(data["rhino_guid"])
Expand Down
9 changes: 2 additions & 7 deletions src/compas_fd/constraints/vectorconstraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,14 @@ def __init__(self, vector, **kwargs):
super(VectorConstraint, self).__init__(geometry=vector, **kwargs)

@property
def data(self):
def __data__(self):
return {
"geometry": self.geometry.data,
"rhino_guid": str(self._rhino_guid),
}

@data.setter
def data(self, data):
self.geometry = Vector.from_data(data["geometry"])
self._rhino_guid = str(data["rhino_guid"])

@classmethod
def from_data(cls, data):
def __from_data__(cls, data):
vector = Vector.from_data(data["geometry"]).unitized()
constraint = cls(vector)
constraint._rhino_guid = str(data["rhino_guid"])
Expand Down
17 changes: 0 additions & 17 deletions src/compas_fd/datastructures/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
"""
***************************
datastructures
***************************
.. currentmodule:: compas_fd.datastructures
Classes
=======
.. autosummary::
:toctree: generated/
:nosignatures:
CableMesh
"""
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
Expand Down
Loading

0 comments on commit da66d43

Please sign in to comment.