mindelec.geometry.CSGXOR

class mindelec.geometry.CSGXOR(geom1, geom2, sampling_config=None)[源代码]

用于几何异或计算的CSG类。

参数:
  • geom1 (Geometry) - 几何体对象。

  • geom2 (Geometry) - 要与 geom1 求异或的几何体对象。

  • sampling_config (SamplingConfig) - 采样配置。默认值:None。

支持平台:

Ascend

样例:

>>> from easydict import EasyDict as edict
>>> from mindelec.geometry import create_config_from_edict, Disk, Rectangle, CSGXOR
>>> 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))
>>> xor = CSGXOR(rect, disk)
>>> xor.set_sampling_config(create_config_from_edict(sampling_config_csg))
>>> domain = xor.sampling(geom_type="domain")
>>> bc, bc_normal = xor.sampling(geom_type="bc")
>>> print(domain.shape)
(1000, 2)