mindelec.geometry.CSGIntersection

class mindelec.geometry.CSGIntersection(geom1, geom2, sampling_config=None)[source]

Constructive Solid Geometry(CSG) class for intersection of geometries.

Parameters
  • geom1 (Geometry) – a geometry object.

  • geom2 (Geometry) – a geometry object to be subtracted from geom1.

  • sampling_config (SamplingConfig) – sampling configuration. Default: None.

Supported Platforms:

Ascend

Examples

>>> from easydict import EasyDict as edict
>>> from mindelec.geometry import create_config_from_edict, Disk, Rectangle, CSGIntersection
>>> sampling_config_csg = edict({
...     'domain': edict({
...         'random_sampling': True,
...         'size': 1000,
...         'sampler': 'uniform'
...     }),
...     'BC': edict({
...         'random_sampling': True,
...         'size': 200,
...         'sampler': 'uniform',
...         'with_normal': True,
...     }),
... })
>>> disk = Disk("disk", (1.2, 0.5), 0.8)
>>> rect = Rectangle("rect", (-1.0, 0), (1, 1))
>>> inter = CSGIntersection(rect, disk)
>>> inter.set_sampling_config(create_config_from_edict(sampling_config_csg))
>>> domain = inter.sampling(geom_type="domain")
>>> bc, bc_normal = inter.sampling(geom_type="bc")
>>> print(domain.shape)
(1000, 2)