How to use the pygmsh.built_in.dummy.Dummy function in pygmsh

To help you get started, we’ve selected a few pygmsh examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nschloe / pygmsh / pygmsh / built_in / geometry.py View on Github external
one of the entities is not provided, this method will produce only
        translation or rotation.
        """
        self._EXTRUDE_ID += 1

        if isinstance(input_entity, str):
            entity = Dummy(input_entity)
        elif isinstance(input_entity, PointBase):
            entity = Dummy(f"Point{{{input_entity.id}}}")
        elif isinstance(input_entity, SurfaceBase):
            entity = Dummy(f"Surface{{{input_entity.id}}}")
        elif hasattr(input_entity, "surface"):
            entity = Dummy(f"Surface{{{input_entity.surface.id}}}")
        else:
            assert isinstance(input_entity, LineBase), "Illegal extrude entity."
            entity = Dummy(f"Line{{{input_entity.id}}}")

        extrusion_string = ""

        # out[] = Extrude{0,1,0}{ Line{1}; };
        name = f"ex{self._EXTRUDE_ID}"
        if translation_axis is not None:
            if rotation_axis is not None:
                extrusion_string += "{}[] = Extrude{{{{{}}}, {{{}}}, {{{}}}, {}}}{{{};".format(
                    name,
                    ",".join(repr(x) for x in translation_axis),
                    ",".join(repr(x) for x in rotation_axis),
                    ",".join(repr(x) for x in point_on_axis),
                    angle,
                    entity.id,
                )
            else:
github nschloe / pygmsh / pygmsh / built_in / geometry.py View on Github external
translation_axis=None,
        rotation_axis=None,
        point_on_axis=None,
        angle=None,
        num_layers=None,
        recombine=False,
    ):
        """Extrusion (translation + rotation) of any entity along a given
        translation_axis, around a given rotation_axis, about a given angle. If
        one of the entities is not provided, this method will produce only
        translation or rotation.
        """
        self._EXTRUDE_ID += 1

        if isinstance(input_entity, str):
            entity = Dummy(input_entity)
        elif isinstance(input_entity, PointBase):
            entity = Dummy(f"Point{{{input_entity.id}}}")
        elif isinstance(input_entity, SurfaceBase):
            entity = Dummy(f"Surface{{{input_entity.id}}}")
        elif hasattr(input_entity, "surface"):
            entity = Dummy(f"Surface{{{input_entity.surface.id}}}")
        else:
            assert isinstance(input_entity, LineBase), "Illegal extrude entity."
            entity = Dummy(f"Line{{{input_entity.id}}}")

        extrusion_string = ""

        # out[] = Extrude{0,1,0}{ Line{1}; };
        name = f"ex{self._EXTRUDE_ID}"
        if translation_axis is not None:
            if rotation_axis is not None:
github nschloe / pygmsh / pygmsh / built_in / geometry.py View on Github external
#
        top = f"{name}[0]"
        extruded = f"{name}[1]"

        if isinstance(input_entity, LineBase):
            top = LineBase(top)
            # A surface extruded from a single line has always 4 edges
            extruded = SurfaceBase(extruded, 4)
        elif isinstance(input_entity, (SurfaceBase, self.Polygon)):
            top = SurfaceBase(top, input_entity.num_edges)
            extruded = VolumeBase(extruded)
        elif isinstance(input_entity, PointBase):
            top = PointBase(top)
            extruded = LineBase(extruded)
        else:
            top = Dummy(top)
            extruded = Dummy(extruded)

        lat = []
        # lateral surfaces can be deduced only if we start from a SurfaceBase
        # or a Polygon
        if isinstance(input_entity, (SurfaceBase, self.Polygon)):
            # out[0]` is the surface, out[1] the top, and everything after that
            # the sides, cf.
            # . Each
            # lateral surface has 4 edges: the one from input_entity, the one
            # from top, and the two lines (or splines) connecting their extreme
            # points.
            lat = [
                SurfaceBase("{}[{}]".format(name, i + 2), 4)
                for i in range(input_entity.num_edges)
            ]
github nschloe / pygmsh / pygmsh / built_in / geometry.py View on Github external
top = f"{name}[0]"
        extruded = f"{name}[1]"

        if isinstance(input_entity, LineBase):
            top = LineBase(top)
            # A surface extruded from a single line has always 4 edges
            extruded = SurfaceBase(extruded, 4)
        elif isinstance(input_entity, (SurfaceBase, self.Polygon)):
            top = SurfaceBase(top, input_entity.num_edges)
            extruded = VolumeBase(extruded)
        elif isinstance(input_entity, PointBase):
            top = PointBase(top)
            extruded = LineBase(extruded)
        else:
            top = Dummy(top)
            extruded = Dummy(extruded)

        lat = []
        # lateral surfaces can be deduced only if we start from a SurfaceBase
        # or a Polygon
        if isinstance(input_entity, (SurfaceBase, self.Polygon)):
            # out[0]` is the surface, out[1] the top, and everything after that
            # the sides, cf.
            # . Each
            # lateral surface has 4 edges: the one from input_entity, the one
            # from top, and the two lines (or splines) connecting their extreme
            # points.
            lat = [
                SurfaceBase("{}[{}]".format(name, i + 2), 4)
                for i in range(input_entity.num_edges)
            ]
github nschloe / pygmsh / pygmsh / built_in / geometry.py View on Github external
point_on_axis=None,
        angle=None,
        num_layers=None,
        recombine=False,
    ):
        """Extrusion (translation + rotation) of any entity along a given
        translation_axis, around a given rotation_axis, about a given angle. If
        one of the entities is not provided, this method will produce only
        translation or rotation.
        """
        self._EXTRUDE_ID += 1

        if isinstance(input_entity, str):
            entity = Dummy(input_entity)
        elif isinstance(input_entity, PointBase):
            entity = Dummy(f"Point{{{input_entity.id}}}")
        elif isinstance(input_entity, SurfaceBase):
            entity = Dummy(f"Surface{{{input_entity.id}}}")
        elif hasattr(input_entity, "surface"):
            entity = Dummy(f"Surface{{{input_entity.surface.id}}}")
        else:
            assert isinstance(input_entity, LineBase), "Illegal extrude entity."
            entity = Dummy(f"Line{{{input_entity.id}}}")

        extrusion_string = ""

        # out[] = Extrude{0,1,0}{ Line{1}; };
        name = f"ex{self._EXTRUDE_ID}"
        if translation_axis is not None:
            if rotation_axis is not None:
                extrusion_string += "{}[] = Extrude{{{{{}}}, {{{}}}, {{{}}}, {}}}{{{};".format(
                    name,