### ===================================================================================================================
###   NoConnectionDetail class
### ===================================================================================================================
# Copyright ©VIIA 2025
### ===================================================================================================================
###   1. Import modules
### ===================================================================================================================
# General imports
from __future__ import annotations
from typing import TYPE_CHECKING, List, Dict, Type, Optional
# References for functions and classes in the haskoning_structural package
from haskoning_structural.shapes import Shapes
from haskoning_structural.connections import NoConnection
# References for functions and classes in the viiaPackage
if TYPE_CHECKING:
    from viiapackage.viiaStatus import ViiaProject
from viiapackage.connections.details import Detail
### ===================================================================================================================
###   2. Class NoConnectionDetail
### ===================================================================================================================
[docs]class NoConnectionDetail(Detail):
    """ This is the class with information from the UPR regarding the detail numbers for no-connection details."""
[docs]    def __init__(
            self, detail_nr: str, geometry_type: str, source_shape_type: Optional[Type[Shapes]] = None,
            target_shape_type: Optional[Type[Shapes]] = None):
        """
        Input:
            - detail_nr (str): Name of the requested detail, see the Basis of Design (UPR).
            - geometry_type (str): The type of geometry for the no-connection detail. Select from 'point' or 'line'.
            - source_shape_type (cls): Class for the source shape-type. The provided source shape will be checked if it
              is an instance of this class. Available are classes that inherit from Shapes.
            - target_shape_type (cls): Class for the target shape-type. The provided target shape will be checked if it
              is an instance of this class. Available are classes that inherit from Shapes.
        """
        # __init__ method of Detail class is carried out
        Detail.__init__(
            self, detail_nr=detail_nr, geometry_type=geometry_type,
            source_shape_type=source_shape_type, target_shape_type=target_shape_type) 
    @property
    def name(self):
        """ Method of 'NoConnectionDetail' to return the VIIA name for the no-connection detail."""
        return 'GEEN-IF'
[docs]    def create(self, project: ViiaProject, connecting_shapes: List[Dict[str, any]]) -> List[NoConnection]:
        """
        Method of 'NoConnectionDetail' class to create the no-connection detail.
        Input:
            - project (obj): VIIA project object containing collections of fem objects and project variables.
            - connecting_shapes (list): List of dictionaries with the connecting shapes (see 'NoConnection' class in
              DataFusr structural documentation).
        Output:
            - Returns list of instances of NoConnection class created and added to project.
        """
        connections = []
        for connecting in connecting_shapes:
            # Generate name
            name = self.generate_name(
                project=project, source=connecting['source_connecting_shape'],
                target=connecting['target_connecting_shape'])
            # Creation of the object and add to project
            connections.append(project.create_no_connection(name=name, connecting_shapes=connecting))
        # Return all created connections
        return connections  
### ===================================================================================================================
###    3. End of script
### ===================================================================================================================