22from __future__ import division
33from __future__ import print_function
44
5- # from itertools import product
65from random import sample
76
87from compas .datastructures import Mesh
2827from compas .geometry import normal_polygon
2928from compas .geometry import normalize_vector
3029from compas .geometry import volume_polyhedron
31-
32- # from compas.topology import face_adjacency
3330from compas .geometry import add_vectors
3431from compas .geometry import bestfit_plane
3532from compas .geometry import project_point_plane
3633from compas .geometry import scale_vector
3734from compas .geometry import subtract_vectors
3835from compas .geometry import bounding_box
3936
40- # from compas.geometry import transform_points
41-
42- # from compas.utilities import linspace
4337from compas .utilities import pairwise
4438
4539from compas .tolerance import TOL
@@ -58,13 +52,11 @@ class CellNetwork(Datastructure):
5852 Default values for face attributes.
5953 default_cell_attributes: dict, optional
6054 Default values for cell attributes.
61- **kwargs : dict , optional
62- Additional attributes for the data structure itself .
55+ name : str , optional
56+ The name of the cell network .
6357
6458 Attributes
6559 ----------
66- attributes : dict[str, Any]
67- General attributes of the data structure which will be included in the data representation.
6860 default_vertex_attributes : dict[str, Any]
6961 Default attributes of the vertices.
7062 default_edge_attributes: dict[str, Any]
@@ -100,6 +92,28 @@ class CellNetwork(Datastructure):
10092 "patternProperties" : {"^[0-9]+$" : {"type" : "object" }},
10193 "additionalProperties" : False ,
10294 },
95+ "edge" : {
96+ "type" : "object" ,
97+ "patternProperties" : {
98+ "^[0-9]+$" : {
99+ "type" : "object" ,
100+ "patternProperties" : {"^[0-9]+$" : {"type" : "object" }},
101+ "additionalProperties" : False ,
102+ }
103+ },
104+ "additionalProperties" : False ,
105+ },
106+ "face" : {
107+ "type" : "object" ,
108+ "patternProperties" : {
109+ "^[0-9]+$" : {
110+ "type" : "array" ,
111+ "items" : {"type" : "integer" , "minimum" : 0 },
112+ "minItems" : 3 ,
113+ }
114+ },
115+ "additionalProperties" : False ,
116+ },
103117 "cell" : {
104118 "type" : "object" ,
105119 "patternProperties" : {
@@ -115,11 +129,6 @@ class CellNetwork(Datastructure):
115129 },
116130 "additionalProperties" : False ,
117131 },
118- "edge_data" : {
119- "type" : "object" ,
120- "patternProperties" : {"^\\ ([0-9]+, [0-9]+\\ )$" : {"type" : "object" }},
121- "additionalProperties" : False ,
122- },
123132 "face_data" : {
124133 "type" : "object" ,
125134 "patternProperties" : {"^\\ ([0-9]+(, [0-9]+){3, }\\ )$" : {"type" : "object" }},
@@ -140,8 +149,9 @@ class CellNetwork(Datastructure):
140149 "dfa" ,
141150 "dca" ,
142151 "vertex" ,
152+ "edge" ,
153+ "face" ,
143154 "cell" ,
144- "edge_data" ,
145155 "face_data" ,
146156 "cell_data" ,
147157 "max_vertex" ,
@@ -156,9 +166,9 @@ def __init__(
156166 default_edge_attributes = None ,
157167 default_face_attributes = None ,
158168 default_cell_attributes = None ,
159- ** kwargs
169+ name = None ,
160170 ):
161- super (Datastructure , self ).__init__ (** kwargs )
171+ super (CellNetwork , self ).__init__ (name = name )
162172 self ._max_vertex = - 1
163173 self ._max_face = - 1
164174 self ._max_cell = - 1
@@ -220,7 +230,6 @@ def data(self):
220230 cell [c ] = sorted (list (faces ))
221231
222232 return {
223- "attributes" : self .attributes ,
224233 "dva" : self .default_vertex_attributes ,
225234 "dea" : self .default_edge_attributes ,
226235 "dfa" : self .default_face_attributes ,
@@ -250,12 +259,10 @@ def from_data(cls, data):
250259 default_cell_attributes = dca ,
251260 )
252261
253- cell_network .attributes .update (data .get ("attributes" ) or {})
254-
255- vertex = data .get ("vertex" ) or {}
256- edge = data .get ("edge" ) or {}
257- face = data .get ("face" ) or {}
258- cell = data .get ("cell" ) or {}
262+ vertex = data ["vertex" ] or {}
263+ edge = data ["edge" ] or {}
264+ face = data ["face" ] or {}
265+ cell = data ["cell" ] or {}
259266
260267 for key , attr in iter (vertex .items ()):
261268 cell_network .add_vertex (key = key , attr_dict = attr )
0 commit comments