fibomat.backend.backendbase module#
Provides the BackendBase class.
- exception fibomat.backend.backendbase.ShapeNotSupportedError[source]#
Bases:
TypeErrorException is used in
BackendBasefor (all) unimplemented shape methods.- __init__(*args, **kwargs)#
- args#
- with_traceback()#
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- fibomat.backend.backendbase.shape_type(type_: Type[Shape]) Callable[source]#
Function is used as a decorator in
BackendBaseto mark shape methods. SeeBackendBaseclass and its implementation for details.Note
This decorator is only needed if a custom shape type is introduced and should be made available to the backend
- Args:
type_ (Type[Shape]): Type of shape.
- Returns:
Callable: Decorator
- class fibomat.backend.backendbase.BackendBase(**kwargs)[source]#
Bases:
objectBase class for any backend. For all default shapes (see …), a method stub is implemented.
TODO: UPDATE THIS!
Use
BackendBaseas base class for a custom backend and implement all shape methods with should be supported and ignore the rest. If any other new shape is introduced and should be supported by the custom backend, use the following example as a base structure.class MyNewBackendBase(BackendBase): def __init__(self): # is it needed? super().__init__() @availabe_shape_method('My_new_shape_name') def my_new_shape(self, parameters): raise ShapeNotSupportedError class MyNewBackend(MyNewBackendBase): ... def my_new_shape(self, parameters): ...
Actually not needed: Make sure, that the base methods of each pattern function (e.g.
fibomat.backend.backendbase.BackendBase.rect()) is called, e.g.def rect(self, ptn: Pattern): super().rect(pattern) # ... do your stuff here
- __init__(**kwargs)[source]#
- Args:
- **kwargs: optional parameters for the backend given by **kwargs in
fibomat.project.Project.export()
- process_pattern(ptn: Pattern) None[source]#
Add a pattern to the backend. The appropriate method is determined by the pattern’s shape class automatically.
If pattern contains a Layout, the contained shapes will be extracted automatically.
- Args:
ptn (Pattern): pattern to be added. on_unknown_shape:
- Returns:
None
- process_unknown(ptn: Pattern) None[source]#
Process a shape, which do not have a registered shape handler. Raises an exception by default.
- Args:
ptn (Pattern): pattern to be added.
- Returns:
None
- property implemented_shape_methods: Dict[Shape, Callable]#
Dict[Shape, str]: implemented shape methods of backend
- process_site(new_site: Site) None[source]#
Adds a
fibomat.site.Siteto the backend. Note, that this method processes all patterns contained in the site. Use the following example as reference, if a backend overwrites this method.... def process_site(self, site: Site): # ... # do the backend specific stuff here (e.g. initialize a new patterning site) # call base method to add all patterns automatically super().process_site(site) ...
- Args:
new_site (Site): site to be added.
- Returns:
None
- save(filename: str | Path) None[source]#
Saves the exported project to file. Args:
filename (PathLike): filename
- Returns:
None
- spot(ptn: Pattern[Spot]) None[source]#
Adds pattern with Spot as shape to the backend.
- Args:
ptn (Pattern): pattern with Spot as shape
- Returns:
None
- line(ptn: Pattern[Line]) None[source]#
Adds pattern with Line as shape to the backend.
- Args:
ptn (Pattern): pattern with Line as shape
- Returns:
None
- rect(ptn: Pattern[Rect]) None[source]#
Adds pattern with Rect as shape to the backend.
- Args:
ptn (Pattern): pattern with Rect as shape
- Returns:
None
- ellipse(ptn: Pattern[Ellipse]) None[source]#
Adds pattern with Ellipse as shape to the backend.
- Args:
ptn (Pattern): pattern with Ellipse as shape
- Returns:
None
- circle(ptn: Pattern[Circle]) None[source]#
Adds pattern with Ellipse as shape to the backend.
- Args:
ptn (Pattern): pattern with Ellipse as shape
- Returns:
None
- arc(ptn: Pattern[Arc]) None[source]#
Adds pattern with Arc as shape to the backend.
- Args:
ptn (Pattern): pattern with Arc as shape
- Returns:
None
- arc_spline(ptn: Pattern[ArcSpline]) None[source]#
Adds pattern with ArcSpline as shape to the backend.
- Args:
ptn (Pattern): pattern with ArcSpline as shape
- Returns:
None
- parametric_curve(ptn: Pattern[ParametricCurve]) None[source]#
Adds pattern with Curve as shape to the backend.
- Args:
ptn (Pattern): pattern with Curve as shape
- Returns:
None
- rasterized_points(ptn: Pattern[RasterizedPoints])[source]#
Adds pattern with RasterizedPoints as shape to the backend.
- Args:
ptn (Pattern): pattern with RasterizedPoints as shape
- Returns:
None
- rasterized_pattern(ptn: Pattern[RasterizedPattern])[source]#
Adds pattern with RasterizedPattern as shape to the backend.
- Args:
ptn (Pattern): pattern with RasterizedPattern as shape
- Returns:
None
- polyline(ptn: Pattern[Polyline]) None[source]#
Adds pattern with Ellipse as shape to the backend.
- Args:
ptn (Pattern): pattern with Ellipse as shape
- Returns:
None
- polygon(ptn: Pattern[Polygon]) None[source]#
Adds pattern with Ellipse as shape to the backend.
- Args:
ptn (Pattern): pattern with Ellipse as shape
- Returns:
None
- hollow_arc_spline(ptn: Pattern[HollowArcSpline]) None[source]#
Adds pattern with HollowArcSpline as shape to the backend.
- Args:
ptn (Pattern): pattern with HollowArcSpline as shape
- Returns:
None