Skip to content

Commit

Permalink
most work done regarding #2
Browse files Browse the repository at this point in the history
  • Loading branch information
fstwn committed Jul 6, 2020
1 parent a8c46c2 commit 6da8bcd
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions modules/Cockatoo/KnitNetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class KnitNetwork(KnitNetworkBase):

def __init__(self, data=None, **attr):
"""
Initialize a KnitNetwork (inherits NetworkX graph with edges, name,
Initialize a KnitNetwork (inherits NetworkX graph) with edges, name,
graph attributes.
Parameters
Expand All @@ -85,8 +85,10 @@ def __init__(self, data=None, **attr):
NetworkX graph object. If the corresponding optional Python
packages are installed the data can also be a NumPy matrix
or 2d ndarray, a SciPy sparse matrix, or a PyGraphviz graph.
name : string, optional (default='')
An optional name for the graph.
attr : keyword arguments, optional (default= no attributes)
Attributes to add to graph as key=value pairs.
"""
Expand Down Expand Up @@ -2479,10 +2481,6 @@ def CreateDual(self, mode=-1):
# first find the cycles of this network
cycles = self.FindCycles(mode=mode)

# we need a mapping between network edge -> containing cycles ... ??
# --> to determine if two cycles (dual nodes) are connected via
# a warp or weft edge

# get node data for all nodes once
node_data = {k: self.node[k] for k in self.nodes_iter()}

Expand Down Expand Up @@ -2521,15 +2519,15 @@ def CreateDual(self, mode=-1):

# get node attributes
is_leaf = True in [node_data[k]["leaf"] for k in cycle]
is_end = True in [node_data[k]["end"] for k in cycle]
#is_end = True in [node_data[k]["end"] for k in cycle]

# add node to dual network
DualNetwork.NodeFromPoint3d(ckey,
centroid_pt,
position=None,
num=None,
leaf=is_leaf,
end=is_end,
end=False,
segment=None)

# loop over original edges and create corresponding edges in dual
Expand All @@ -2546,6 +2544,10 @@ def CreateDual(self, mode=-1):
toNode = (cycle_keys[1], DualNetwork.node[cycle_keys[1]])
DualNetwork.CreateWarpEdge(fromNode, toNode)

# TODO: set 'end' attribute if node has two warp and one weft edge!
# TODO: set 'crease' attribute if node has two weft and one warp edge
# and is not a leaf!

return DualNetwork

# MAIN -------------------------------------------------------------------------
Expand Down

0 comments on commit 6da8bcd

Please sign in to comment.