curvey.shape_structure_dataset¤
shape_structure_dataset
¤
Interface to the 2D Shape Structure Dataset
Download the shapes zip file here.
The dataset groups shapes by class; shapes can be loaded either by an exact name or a class name and an index.
from curvey.shape_structure_dataset import ShapeStructureDataset
try:
dataset = ShapeStructureDataset('~/Downloads/ShapesJSON.zip')
except FileNotFoundError:
print("Couldn't find the ShapesJSON.zip file")
else:
print(', '.join(dataset.class_names))
curve = dataset.load_curve('elephant-1') # or load_curve('elephant', 0)
curve.plot()
ShapeStructureDataset
¤
Interface to the 2D Shape Structure Dataset zip file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset |
str | Path
|
the path to the |
required |
Notes
Shapes in the dataset are actually a 2d triangular mesh, not a curve. Curves are loaded without any processing, assuming vertices are listed in order, so they may have irregularities, such as repeated points or self-intersections. Shapes with topological holes like the coffee cup are returned as a single curve without a care in the world.
Source code in src\curvey\shape_structure_dataset.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
all_names: set[str]
cached
property
¤
Names of the shapes in the dataset
class_names: tuple[str, ...]
cached
property
¤
Names of the unique shape classes in the dataset
names_by_class: dict[str, tuple[str, ...]]
cached
property
¤
Shape names grouped by their class
Returns:
Name | Type | Description |
---|---|---|
classes |
dict[str, tuple[str, ...]]
|
|
load_curve(name: str, idx: int | None = None) -> Curve
¤
Construct a Curve
from the named shape in the dataset
Can load curves by explicit name, e.g. dataset.load_curve('Bone-13')
,
or a class name and an index, e.g. dataset.load_curve('Bone', 1)
.
Names are case-insensitive.
Source code in src\curvey\shape_structure_dataset.py
load_triangulation(name: str, idx: int | None = None) -> Triangulation
¤
The triangulated shape