# Path: airconics/primitives.py
# class Airfoil(object):
#     def __init__(self,
#                  LeadingEdgePoint=[0., 0., 0.],
#                  ChordLength=1,
#                  Rotation=0,
#                  Twist=0,
#                  SeligProfile=None,
#                  Naca4Profile=None,
#                  Naca5Profile=None,
#                  CRMProfile=None,
#                  CRM_Epsilon=0.,
#                  InterpProfile=None,
#                  Epsilon=0, Af1=None, Af2=None, Eps1=0, Eps2=1,
#                  EnforceSharpTE=False):
#     def points(self):
#     def points(self, newpoints):
#     def _make_airfoil(self, SeligProfile, Naca4Profile, Naca5Profile,
#                       CRMProfile, CRM_Epsilon,
#                       InterpProfile, Epsilon, Af1, Af2, Eps1, Eps2):
#     def _fitAirfoiltoPoints(self):
#     def _AirfoilPointsSeligFormat(self, SeligProfile):
#     def _NACA4cambercurve(self, MaxCamberLocTenthChord, MaxCamberPercChord):
#     def _NACA4halfthickness(self, ChordCoord, MaxThicknessPercChord):
#     def _camberplusthickness(self, ChordCoord, zcam, dzcamdx, t):
#     def _mergesurfaces(self, xu, zu, xl, zl):
#     def _NACA4digitPnts(self, MaxCamberPercChord, MaxCamberLocTenthChord,
#                         MaxThicknessPercChord):
#     def _TransformAirfoil(self):
#     def AddAirfoilFromSeligFile(self, SeligProfile, Smoothing=1):
#     def AddNACA4(self, Naca4Profile, Smoothing=1):
#     def AddCRMLinear(self, CRM_Epsilon, Smoothing=1):
#     def AddLinear2(self, Eps, Af1, Af2, Eps1=0, Eps2=1):
#         N = np.shape(self._points)[0]
#         N = len(data)
#         RLE = 1.1019*(MaxThicknessPercChord/100.0)**2.0
# 
# Path: airconics/liftingsurface.py
# def airfoilfunct(ProfileFunct):
#     def AirfoilFunct(Epsilon, LEPoint, ChordFunct, ChordFactor,
#                      DihedralFunct, TwistFunct):
#     def uniform_parametric_function(epsilon):
#     def __init__(self, ApexPoint=gp_Pnt(0, 0, 0),
#                  SweepFunct=False,
#                  DihedralFunct=False,
#                  TwistFunct=False,
#                  ChordFunct=False,
#                  AirfoilFunct=False,
#                  ChordFactor=1,
#                  ScaleFactor=1,
#                  OptimizeChordScale=0,
#                  LooseSurf=1,
#                  SegmentNo=11,
#                  TipRequired=False,
#                  max_degree=8,
#                  continuity=GeomAbs_C2,
#                  construct_geometry=True,
#                  ):
#     def ApexPoint(self):
#     def ApexPoint(self, newApexPoint):
#     def SweepFunct(self):
#     def SweepFunct(self, newSweepFunct):
#     def DihedralFunct(self):
#     def DihedralFunct(self, newDihedralFunct):
#     def TwistFunct(self):
#     def TwistFunct(self, newTwistFunct):
#     def ChordFunct(self):
#     def ChordFunct(self, newChordFunct):
#     def AirfoilFunct(self):
#     def AirfoilFunct(self, newAirfoilFunct):
#     def NSegments(self):
#     def NSegments(self, newNSegments):
#     def ChordFactor(self):
#     def ChordFactor(self, newChordFactor):
#     def ScaleFactor(self):
#     def ScaleFactor(self, newScaleFactor):
#     def Sections(self):
#     def CreateConstructionGeometry(self):
#     def Build(self):
#     def GenerateLeadingEdge(self):
#     def GenerateSectionCurves(self):
#     def GenerateLiftingSurface(self):
#     def CalculateProjectedArea(self):
#     def CalculateSemiSpan(self):
#     def CalculateAspectRatio(self):
#     def Fit_BlendedTipDevice(self, rootchord_norm, spanfraction=0.1, cant=40,
#                              transition=0.1, sweep=40, taper=0.7):
#         def AirfoilFunctWinglet(Epsilon):
# class LiftingSurface(AirconicsShape):
#         LS = act.AddSurfaceLoft(self._Sections,
#                                 max_degree=self.max_degree,
#                                 continuity=self.Cont,
#                                 solid=False)
#                 SA = act.CalculateSurfaceArea(LSPsegment)
#         BB = self.Extents(as_vec=True)
#         AR = ((ActualSemiSpan) ** 2.0) / (LSP_area)


import numpy as np
    import airconics
from airconics import primitives
from airconics import liftingsurface
    from OCC.Display.SimpleGui import init_display
    # A simple model of a loaded wing shape:
    return BaseDihedral + Epsilon*Epsilon*10


def myTwistFunctionAirliner(Epsilon):
    """User-defined function describing the variation of twist as a function
    of the leading edge coordinate. The coefficients of the polynomial below
    come from the following twist values taken off the CRM (used for the AIAA
    drag prediction workshops):
    Epsilon = 0: twist = 4.24
    Epsilon =0.3: twist = 0.593
    Epsilon = 1: twist = -3.343"""
    return -(6.53*Epsilon*Epsilon - 14.1*Epsilon + 4.24)


def myChordFunctionAirliner(Epsilon):
    """User-defined function describing the variation of chord as a function of
    the leading edge coordinate"""
    ChordLengths = np.array([0.5, 0.3792, 0.2867, 0.232, 0.1763, 0.1393, 0.1155,
                             0.093, 0.0713, 0.055, 0.007])

    EpsArray = np.linspace(0, 1, 11)
    return np.interp(Epsilon, EpsArray, ChordLengths)


def myAirfoilFunctionAirliner(Epsilon, LEPoint, ChordFunct, ChordFactor,
                              DihedralFunct, TwistFunct):
    """Defines the variation of cross section as a function of Epsilon"""
    AfChord = ((ChordFactor*ChordFunct(Epsilon)) /
               np.cos(np.radians(TwistFunct(Epsilon))))

# Path: airconics/primitives.py
# class Airfoil(object):
#     def __init__(self,
#                  LeadingEdgePoint=[0., 0., 0.],
#                  ChordLength=1,
#                  Rotation=0,
#                  Twist=0,
#                  SeligProfile=None,
#                  Naca4Profile=None,
#                  Naca5Profile=None,
#                  CRMProfile=None,
#                  CRM_Epsilon=0.,
#                  InterpProfile=None,
#                  Epsilon=0, Af1=None, Af2=None, Eps1=0, Eps2=1,
#                  EnforceSharpTE=False):
#     def points(self):
#     def points(self, newpoints):
#     def _make_airfoil(self, SeligProfile, Naca4Profile, Naca5Profile,
#                       CRMProfile, CRM_Epsilon,
#                       InterpProfile, Epsilon, Af1, Af2, Eps1, Eps2):
#     def _fitAirfoiltoPoints(self):
#     def _AirfoilPointsSeligFormat(self, SeligProfile):
#     def _NACA4cambercurve(self, MaxCamberLocTenthChord, MaxCamberPercChord):
#     def _NACA4halfthickness(self, ChordCoord, MaxThicknessPercChord):
#     def _camberplusthickness(self, ChordCoord, zcam, dzcamdx, t):
#     def _mergesurfaces(self, xu, zu, xl, zl):
#     def _NACA4digitPnts(self, MaxCamberPercChord, MaxCamberLocTenthChord,
#                         MaxThicknessPercChord):
#     def _TransformAirfoil(self):
#     def AddAirfoilFromSeligFile(self, SeligProfile, Smoothing=1):
#     def AddNACA4(self, Naca4Profile, Smoothing=1):
#     def AddCRMLinear(self, CRM_Epsilon, Smoothing=1):
#     def AddLinear2(self, Eps, Af1, Af2, Eps1=0, Eps2=1):
#         N = np.shape(self._points)[0]
#         N = len(data)
#         RLE = 1.1019*(MaxThicknessPercChord/100.0)**2.0
# 
# Path: airconics/liftingsurface.py
# def airfoilfunct(ProfileFunct):
#     def AirfoilFunct(Epsilon, LEPoint, ChordFunct, ChordFactor,
#                      DihedralFunct, TwistFunct):
#     def uniform_parametric_function(epsilon):
#     def __init__(self, ApexPoint=gp_Pnt(0, 0, 0),
#                  SweepFunct=False,
#                  DihedralFunct=False,
#                  TwistFunct=False,
#                  ChordFunct=False,
#                  AirfoilFunct=False,
#                  ChordFactor=1,
#                  ScaleFactor=1,
#                  OptimizeChordScale=0,
#                  LooseSurf=1,
#                  SegmentNo=11,
#                  TipRequired=False,
#                  max_degree=8,
#                  continuity=GeomAbs_C2,
#                  construct_geometry=True,
#                  ):
#     def ApexPoint(self):
#     def ApexPoint(self, newApexPoint):
#     def SweepFunct(self):
#     def SweepFunct(self, newSweepFunct):
#     def DihedralFunct(self):
#     def DihedralFunct(self, newDihedralFunct):
#     def TwistFunct(self):
#     def TwistFunct(self, newTwistFunct):
#     def ChordFunct(self):
#     def ChordFunct(self, newChordFunct):
#     def AirfoilFunct(self):
#     def AirfoilFunct(self, newAirfoilFunct):
#     def NSegments(self):
#     def NSegments(self, newNSegments):
#     def ChordFactor(self):
#     def ChordFactor(self, newChordFactor):
#     def ScaleFactor(self):
#     def ScaleFactor(self, newScaleFactor):
#     def Sections(self):
#     def CreateConstructionGeometry(self):
#     def Build(self):
#     def GenerateLeadingEdge(self):
#     def GenerateSectionCurves(self):
#     def GenerateLiftingSurface(self):
#     def CalculateProjectedArea(self):
#     def CalculateSemiSpan(self):
#     def CalculateAspectRatio(self):
#     def Fit_BlendedTipDevice(self, rootchord_norm, spanfraction=0.1, cant=40,
#                              transition=0.1, sweep=40, taper=0.7):
#         def AirfoilFunctWinglet(Epsilon):
# class LiftingSurface(AirconicsShape):
#         LS = act.AddSurfaceLoft(self._Sections,
#                                 max_degree=self.max_degree,
#                                 continuity=self.Cont,
#                                 solid=False)
#                 SA = act.CalculateSurfaceArea(LSPsegment)
#         BB = self.Extents(as_vec=True)
#         AR = ((ActualSemiSpan) ** 2.0) / (LSP_area)


# Path: airconics/examples/wing_example_transonic_airliner.py
import numpy as np
    import airconics
from airconics import primitives
from airconics import liftingsurface
    from OCC.Display.SimpleGui import init_display

    # A simple model of a loaded wing shape:
    return BaseDihedral + Epsilon*Epsilon*10


def myTwistFunctionAirliner(Epsilon):
    """User-defined function describing the variation of twist as a function
    of the leading edge coordinate. The coefficients of the polynomial below
    come from the following twist values taken off the CRM (used for the AIAA
    drag prediction workshops):
    Epsilon = 0: twist = 4.24
    Epsilon =0.3: twist = 0.593
    Epsilon = 1: twist = -3.343"""
    return -(6.53*Epsilon*Epsilon - 14.1*Epsilon + 4.24)


def myChordFunctionAirliner(Epsilon):
    """User-defined function describing the variation of chord as a function of
    the leading edge coordinate"""
    ChordLengths = np.array([0.5, 0.3792, 0.2867, 0.232, 0.1763, 0.1393, 0.1155,
                             0.093, 0.0713, 0.055, 0.007])

    EpsArray = np.linspace(0, 1, 11)
    return np.interp(Epsilon, EpsArray, ChordLengths)


def myAirfoilFunctionAirliner(Epsilon, LEPoint, ChordFunct, ChordFactor,
                              DihedralFunct, TwistFunct):
    """Defines the variation of cross section as a function of Epsilon"""
    AfChord = ((ChordFactor*ChordFunct(Epsilon)) /
               np.cos(np.radians(TwistFunct(Epsilon))))

    Af = primitives.Airfoil(LEPoint, ChordLength=AfChord,