你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-07 23:14:03 +08:00
Make Rotatable a proper Mixin class
这个提交包含在:
@@ -23,7 +23,7 @@ import numpy as np
|
||||
from gprMax.fractals import FractalSurface, Grass
|
||||
from gprMax.grid.fdtd_grid import FDTDGrid
|
||||
from gprMax.materials import create_grass
|
||||
from gprMax.user_objects.rotatable import Rotatable
|
||||
from gprMax.user_objects.rotatable import RotatableMixin
|
||||
from gprMax.user_objects.user_objects import GeometryUserObject
|
||||
from gprMax.utilities.utilities import round_value
|
||||
|
||||
@@ -32,7 +32,7 @@ from .cmds_geometry import rotate_2point_object
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class AddGrass(GeometryUserObject, Rotatable):
|
||||
class AddGrass(RotatableMixin, GeometryUserObject):
|
||||
"""Adds grass with roots to a FractalBox class in the model.
|
||||
|
||||
Attributes:
|
||||
|
@@ -22,7 +22,7 @@ import numpy as np
|
||||
|
||||
from gprMax.fractals import FractalSurface
|
||||
from gprMax.grid.fdtd_grid import FDTDGrid
|
||||
from gprMax.user_objects.rotatable import Rotatable
|
||||
from gprMax.user_objects.rotatable import RotatableMixin
|
||||
from gprMax.user_objects.user_objects import GeometryUserObject
|
||||
from gprMax.utilities.utilities import round_value
|
||||
|
||||
@@ -31,7 +31,7 @@ from .cmds_geometry import rotate_2point_object
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class AddSurfaceRoughness(GeometryUserObject, Rotatable):
|
||||
class AddSurfaceRoughness(RotatableMixin, GeometryUserObject):
|
||||
"""Adds surface roughness to a FractalBox class in the model.
|
||||
|
||||
Attributes:
|
||||
|
@@ -22,7 +22,7 @@ import numpy as np
|
||||
|
||||
from gprMax.grid.fdtd_grid import FDTDGrid
|
||||
from gprMax.materials import create_water
|
||||
from gprMax.user_objects.rotatable import Rotatable
|
||||
from gprMax.user_objects.rotatable import RotatableMixin
|
||||
from gprMax.user_objects.user_objects import GeometryUserObject
|
||||
from gprMax.utilities.utilities import round_value
|
||||
|
||||
@@ -31,7 +31,7 @@ from .cmds_geometry import rotate_2point_object
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class AddSurfaceWater(GeometryUserObject, Rotatable):
|
||||
class AddSurfaceWater(RotatableMixin, GeometryUserObject):
|
||||
"""Adds surface water to a FractalBox class in the model.
|
||||
|
||||
Attributes:
|
||||
|
@@ -24,7 +24,7 @@ import gprMax.config as config
|
||||
from gprMax.cython.geometry_primitives import build_box
|
||||
from gprMax.grid.fdtd_grid import FDTDGrid
|
||||
from gprMax.materials import Material
|
||||
from gprMax.user_objects.rotatable import Rotatable
|
||||
from gprMax.user_objects.rotatable import RotatableMixin
|
||||
from gprMax.user_objects.user_objects import GeometryUserObject
|
||||
|
||||
from .cmds_geometry import rotate_2point_object
|
||||
@@ -32,7 +32,7 @@ from .cmds_geometry import rotate_2point_object
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Box(GeometryUserObject, Rotatable):
|
||||
class Box(RotatableMixin, GeometryUserObject):
|
||||
"""Introduces an orthogonal parallelepiped with specific properties into
|
||||
the model.
|
||||
|
||||
|
@@ -22,7 +22,7 @@ import numpy as np
|
||||
|
||||
from gprMax.cython.geometry_primitives import build_edge_x, build_edge_y, build_edge_z
|
||||
from gprMax.grid.fdtd_grid import FDTDGrid
|
||||
from gprMax.user_objects.rotatable import Rotatable
|
||||
from gprMax.user_objects.rotatable import RotatableMixin
|
||||
from gprMax.user_objects.user_objects import GeometryUserObject
|
||||
|
||||
from .cmds_geometry import rotate_2point_object
|
||||
@@ -30,7 +30,7 @@ from .cmds_geometry import rotate_2point_object
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Edge(GeometryUserObject, Rotatable):
|
||||
class Edge(RotatableMixin, GeometryUserObject):
|
||||
"""Introduces a wire with specific properties into the model.
|
||||
|
||||
Attributes:
|
||||
|
@@ -26,13 +26,13 @@ from gprMax.fractals import FractalVolume
|
||||
from gprMax.grid.fdtd_grid import FDTDGrid
|
||||
from gprMax.materials import ListMaterial
|
||||
from gprMax.user_objects.cmds_geometry.cmds_geometry import rotate_2point_object
|
||||
from gprMax.user_objects.rotatable import Rotatable
|
||||
from gprMax.user_objects.rotatable import RotatableMixin
|
||||
from gprMax.user_objects.user_objects import GeometryUserObject
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class FractalBox(GeometryUserObject, Rotatable):
|
||||
class FractalBox(RotatableMixin, GeometryUserObject):
|
||||
"""Introduces an orthogonal parallelepiped with fractal distributed
|
||||
properties which are related to a mixing model or normal material into
|
||||
the model.
|
||||
|
@@ -22,7 +22,7 @@ import numpy as np
|
||||
|
||||
from gprMax.cython.geometry_primitives import build_face_xy, build_face_xz, build_face_yz
|
||||
from gprMax.grid.fdtd_grid import FDTDGrid
|
||||
from gprMax.user_objects.rotatable import Rotatable
|
||||
from gprMax.user_objects.rotatable import RotatableMixin
|
||||
from gprMax.user_objects.user_objects import GeometryUserObject
|
||||
|
||||
from .cmds_geometry import rotate_2point_object
|
||||
@@ -30,7 +30,7 @@ from .cmds_geometry import rotate_2point_object
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Plate(GeometryUserObject, Rotatable):
|
||||
class Plate(RotatableMixin, GeometryUserObject):
|
||||
"""Introduces a plate with specific properties into the model.
|
||||
|
||||
Attributes:
|
||||
|
@@ -23,7 +23,7 @@ import numpy as np
|
||||
from gprMax.cython.geometry_primitives import build_triangle
|
||||
from gprMax.grid.fdtd_grid import FDTDGrid
|
||||
from gprMax.materials import Material
|
||||
from gprMax.user_objects.rotatable import Rotatable
|
||||
from gprMax.user_objects.rotatable import RotatableMixin
|
||||
from gprMax.user_objects.user_objects import GeometryUserObject
|
||||
|
||||
from .cmds_geometry import rotate_point
|
||||
@@ -31,7 +31,7 @@ from .cmds_geometry import rotate_point
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Triangle(GeometryUserObject, Rotatable):
|
||||
class Triangle(RotatableMixin, GeometryUserObject):
|
||||
"""Introduces a triangular patch or a triangular prism with specific
|
||||
properties into the model.
|
||||
|
||||
|
@@ -49,7 +49,7 @@ from gprMax.user_objects.cmds_geometry.cmds_geometry import (
|
||||
rotate_2point_object,
|
||||
rotate_polarisation,
|
||||
)
|
||||
from gprMax.user_objects.rotatable import Rotatable
|
||||
from gprMax.user_objects.rotatable import RotatableMixin
|
||||
from gprMax.user_objects.user_objects import GridUserObject
|
||||
from gprMax.utilities.utilities import round_value
|
||||
from gprMax.waveforms import Waveform as WaveformUser
|
||||
@@ -291,7 +291,7 @@ class Waveform(GridUserObject):
|
||||
grid.waveforms.append(w)
|
||||
|
||||
|
||||
class VoltageSource(GridUserObject, Rotatable):
|
||||
class VoltageSource(RotatableMixin, GridUserObject):
|
||||
"""Specifies a voltage source at an electric field location.
|
||||
|
||||
Attributes:
|
||||
@@ -435,7 +435,7 @@ class VoltageSource(GridUserObject, Rotatable):
|
||||
grid.voltagesources.append(v)
|
||||
|
||||
|
||||
class HertzianDipole(GridUserObject, Rotatable):
|
||||
class HertzianDipole(RotatableMixin, GridUserObject):
|
||||
"""Specifies a current density term at an electric field location.
|
||||
|
||||
The simplest excitation, often referred to as an additive or soft source.
|
||||
@@ -582,7 +582,7 @@ class HertzianDipole(GridUserObject, Rotatable):
|
||||
grid.hertziandipoles.append(h)
|
||||
|
||||
|
||||
class MagneticDipole(GridUserObject, Rotatable):
|
||||
class MagneticDipole(RotatableMixin, GridUserObject):
|
||||
"""Simulates an infinitesimal magnetic dipole.
|
||||
|
||||
Often referred to as an additive or soft source.
|
||||
@@ -720,7 +720,7 @@ class MagneticDipole(GridUserObject, Rotatable):
|
||||
grid.magneticdipoles.append(m)
|
||||
|
||||
|
||||
class TransmissionLine(GridUserObject, Rotatable):
|
||||
class TransmissionLine(RotatableMixin, GridUserObject):
|
||||
"""Specifies a one-dimensional transmission line model at an electric
|
||||
field location.
|
||||
|
||||
@@ -879,7 +879,7 @@ class TransmissionLine(GridUserObject, Rotatable):
|
||||
grid.transmissionlines.append(t)
|
||||
|
||||
|
||||
class Rx(GridUserObject, Rotatable):
|
||||
class Rx(RotatableMixin, GridUserObject):
|
||||
"""Specifies output points in the model.
|
||||
|
||||
These are locations where the values of the electric and magnetic field
|
||||
|
@@ -4,7 +4,7 @@ from typing import Optional, Tuple
|
||||
from gprMax.grid.fdtd_grid import FDTDGrid
|
||||
|
||||
|
||||
class Rotatable(ABC):
|
||||
class RotatableMixin(ABC):
|
||||
"""Stores parameters and defines an interface for rotatable objects.
|
||||
|
||||
Attributes:
|
||||
@@ -18,7 +18,8 @@ class Rotatable(ABC):
|
||||
otherwise. Default False.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs) # Forward all unused arguments
|
||||
self.axis = "x"
|
||||
self.angle = 0
|
||||
self.origin = None
|
||||
|
在新工单中引用
屏蔽一个用户