# Copyright (C) 2021 - 2024 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

"""Module providing the SetSolidAdd class."""
import typing
from ansys.dyna.core.lib.card import Card, Field, Flag
from ansys.dyna.core.lib.field_schema import FieldSchema
from ansys.dyna.core.lib.option_card import OptionCardSet, OptionSpec
from ansys.dyna.core.lib.keyword_base import KeywordBase
from ansys.dyna.core.lib.keyword_base import LinkType

_SETSOLIDADD_CARD0 = (
    FieldSchema("sid", int, 0, 10, None),
    FieldSchema("solver", str, 10, 10, "MECH"),
)

_SETSOLIDADD_CARD1 = (
    FieldSchema("dsid1", int, 0, 10, None),
    FieldSchema("dsid2", int, 10, 10, None),
    FieldSchema("dsid3", int, 20, 10, None),
    FieldSchema("dsid4", int, 30, 10, None),
    FieldSchema("dsid5", int, 40, 10, None),
    FieldSchema("dsid6", int, 50, 10, None),
    FieldSchema("dsid7", int, 60, 10, None),
    FieldSchema("dsid8", int, 70, 10, None),
)

_SETSOLIDADD_OPTION0_CARD0 = (
    FieldSchema("title", str, 0, 80, None),
)

class SetSolidAdd(KeywordBase):
    """DYNA SET_SOLID_ADD keyword"""

    keyword = "SET"
    subkeyword = "SOLID_ADD"
    option_specs = [
        OptionSpec("TITLE", -1, 1),
    ]
    _link_fields = {
        "dsid1": LinkType.SET_SOLID,
        "dsid2": LinkType.SET_SOLID,
        "dsid3": LinkType.SET_SOLID,
        "dsid4": LinkType.SET_SOLID,
        "dsid5": LinkType.SET_SOLID,
        "dsid6": LinkType.SET_SOLID,
        "dsid7": LinkType.SET_SOLID,
        "dsid8": LinkType.SET_SOLID,
    }

    def __init__(self, **kwargs):
        """Initialize the SetSolidAdd class."""
        super().__init__(**kwargs)
        kwargs["parent"] = self
        self._cards = [
            Card.from_field_schemas_with_defaults(
                _SETSOLIDADD_CARD0,
                **kwargs,
            ),            Card.from_field_schemas_with_defaults(
                _SETSOLIDADD_CARD1,
                **kwargs,
            ),            OptionCardSet(
                option_spec = SetSolidAdd.option_specs[0],
                cards = [
                    Card.from_field_schemas_with_defaults(
                        _SETSOLIDADD_OPTION0_CARD0,
                        **kwargs,
                    ),
                ],
                **kwargs
            ),
        ]
    @property
    def sid(self) -> typing.Optional[int]:
        """Get or set the Solid element set ID. All shell sets should have a unique set ID.
        """ # nopep8
        return self._cards[0].get_value("sid")

    @sid.setter
    def sid(self, value: int) -> None:
        """Set the sid property."""
        self._cards[0].set_value("sid", value)

    @property
    def solver(self) -> str:
        """Get or set the EQ.MECH: mechanics.
        EQ.CESE: CE/SE compressible fluid flow solver.
        EQ.ICFD: Incompressible fluid flow solver.
        """ # nopep8
        return self._cards[0].get_value("solver")

    @solver.setter
    def solver(self, value: str) -> None:
        """Set the solver property."""
        if value not in ["MECH", "CESE", "ICFD", None]:
            raise Exception("""solver must be `None` or one of {"MECH","CESE","ICFD"}.""")
        self._cards[0].set_value("solver", value)

    @property
    def dsid1(self) -> typing.Optional[int]:
        """Get or set the First solid set ID.
        """ # nopep8
        return self._cards[1].get_value("dsid1")

    @dsid1.setter
    def dsid1(self, value: int) -> None:
        """Set the dsid1 property."""
        self._cards[1].set_value("dsid1", value)

    @property
    def dsid2(self) -> typing.Optional[int]:
        """Get or set the Second solid set ID.
        """ # nopep8
        return self._cards[1].get_value("dsid2")

    @dsid2.setter
    def dsid2(self, value: int) -> None:
        """Set the dsid2 property."""
        self._cards[1].set_value("dsid2", value)

    @property
    def dsid3(self) -> typing.Optional[int]:
        """Get or set the Third solid set ID.
        """ # nopep8
        return self._cards[1].get_value("dsid3")

    @dsid3.setter
    def dsid3(self, value: int) -> None:
        """Set the dsid3 property."""
        self._cards[1].set_value("dsid3", value)

    @property
    def dsid4(self) -> typing.Optional[int]:
        """Get or set the Fourth solid set ID.
        """ # nopep8
        return self._cards[1].get_value("dsid4")

    @dsid4.setter
    def dsid4(self, value: int) -> None:
        """Set the dsid4 property."""
        self._cards[1].set_value("dsid4", value)

    @property
    def dsid5(self) -> typing.Optional[int]:
        """Get or set the Fifth solid set ID.
        """ # nopep8
        return self._cards[1].get_value("dsid5")

    @dsid5.setter
    def dsid5(self, value: int) -> None:
        """Set the dsid5 property."""
        self._cards[1].set_value("dsid5", value)

    @property
    def dsid6(self) -> typing.Optional[int]:
        """Get or set the Sixth solid set ID.
        """ # nopep8
        return self._cards[1].get_value("dsid6")

    @dsid6.setter
    def dsid6(self, value: int) -> None:
        """Set the dsid6 property."""
        self._cards[1].set_value("dsid6", value)

    @property
    def dsid7(self) -> typing.Optional[int]:
        """Get or set the Seventh solid set ID.
        """ # nopep8
        return self._cards[1].get_value("dsid7")

    @dsid7.setter
    def dsid7(self, value: int) -> None:
        """Set the dsid7 property."""
        self._cards[1].set_value("dsid7", value)

    @property
    def dsid8(self) -> typing.Optional[int]:
        """Get or set the Eighth solid set ID.
        """ # nopep8
        return self._cards[1].get_value("dsid8")

    @dsid8.setter
    def dsid8(self, value: int) -> None:
        """Set the dsid8 property."""
        self._cards[1].set_value("dsid8", value)

    @property
    def title(self) -> typing.Optional[str]:
        """Get or set the Additional title line
        """ # nopep8
        return self._cards[2].cards[0].get_value("title")

    @title.setter
    def title(self, value: str) -> None:
        """Set the title property."""
        self._cards[2].cards[0].set_value("title", value)

        if value:
            self.activate_option("TITLE")

    @property
    def dsid1_link(self) -> typing.Optional[KeywordBase]:
        """Get the SET_SOLID_* keyword for dsid1."""
        return self._get_set_link("SOLID", self.dsid1)

    @dsid1_link.setter
    def dsid1_link(self, value: KeywordBase) -> None:
        """Set the SET_SOLID_* keyword for dsid1."""
        self.dsid1 = value.sid

    @property
    def dsid2_link(self) -> typing.Optional[KeywordBase]:
        """Get the SET_SOLID_* keyword for dsid2."""
        return self._get_set_link("SOLID", self.dsid2)

    @dsid2_link.setter
    def dsid2_link(self, value: KeywordBase) -> None:
        """Set the SET_SOLID_* keyword for dsid2."""
        self.dsid2 = value.sid

    @property
    def dsid3_link(self) -> typing.Optional[KeywordBase]:
        """Get the SET_SOLID_* keyword for dsid3."""
        return self._get_set_link("SOLID", self.dsid3)

    @dsid3_link.setter
    def dsid3_link(self, value: KeywordBase) -> None:
        """Set the SET_SOLID_* keyword for dsid3."""
        self.dsid3 = value.sid

    @property
    def dsid4_link(self) -> typing.Optional[KeywordBase]:
        """Get the SET_SOLID_* keyword for dsid4."""
        return self._get_set_link("SOLID", self.dsid4)

    @dsid4_link.setter
    def dsid4_link(self, value: KeywordBase) -> None:
        """Set the SET_SOLID_* keyword for dsid4."""
        self.dsid4 = value.sid

    @property
    def dsid5_link(self) -> typing.Optional[KeywordBase]:
        """Get the SET_SOLID_* keyword for dsid5."""
        return self._get_set_link("SOLID", self.dsid5)

    @dsid5_link.setter
    def dsid5_link(self, value: KeywordBase) -> None:
        """Set the SET_SOLID_* keyword for dsid5."""
        self.dsid5 = value.sid

    @property
    def dsid6_link(self) -> typing.Optional[KeywordBase]:
        """Get the SET_SOLID_* keyword for dsid6."""
        return self._get_set_link("SOLID", self.dsid6)

    @dsid6_link.setter
    def dsid6_link(self, value: KeywordBase) -> None:
        """Set the SET_SOLID_* keyword for dsid6."""
        self.dsid6 = value.sid

    @property
    def dsid7_link(self) -> typing.Optional[KeywordBase]:
        """Get the SET_SOLID_* keyword for dsid7."""
        return self._get_set_link("SOLID", self.dsid7)

    @dsid7_link.setter
    def dsid7_link(self, value: KeywordBase) -> None:
        """Set the SET_SOLID_* keyword for dsid7."""
        self.dsid7 = value.sid

    @property
    def dsid8_link(self) -> typing.Optional[KeywordBase]:
        """Get the SET_SOLID_* keyword for dsid8."""
        return self._get_set_link("SOLID", self.dsid8)

    @dsid8_link.setter
    def dsid8_link(self, value: KeywordBase) -> None:
        """Set the SET_SOLID_* keyword for dsid8."""
        self.dsid8 = value.sid

