// Copyright (C) Stichting Deltares 2017. All rights reserved.
//
// This file is part of the application DAM - UI.
//
// DAM - UI is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
//
// All names, logos, and references to "Deltares" are registered trademarks of
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Deltares.Geometry;
namespace Deltares.Dam.Data
{
public class NonWaterRetainingObjectException : ApplicationException
{
public NonWaterRetainingObjectException(string message)
: base(message)
{
}
}
public class NonWaterRetainingObject
{
public virtual string NwoId { get; set; }
public virtual NonWaterRetainingObjectCategory Category { get; set; }
public virtual NonWaterRetainingObjectType Type { get; set; }
public virtual PhreaticAdaptionType PhreaticAdaption { get; set; }
public virtual double H1 { get; set; }
public virtual double H2 { get; set; }
public virtual double N1 { get; set; }
public virtual double N2 { get; set; }
public virtual double B { get; set; }
public virtual double StepSizeX { get; set; }
public virtual double MaxDistanceFromToe { get; set; }
public double Btotal ()
{
double bTotal = (H1 * N1) + (Math.Sqrt((B*B - (Math.Pow(H2-H1, 2))))) + (H2 * N2);
return bTotal;
}
public GeometryPoint Point1 { get; set; }
public GeometryPoint Point2 { get; set; }
public GeometryPoint Point3 { get; set; }
public GeometryPoint Point4 { get; set; }
///
///
///
///
public void GetDefaultValuesPerTreeType(NonWaterRetainingObjectType type)
{
switch (type)
{
case NonWaterRetainingObjectType.Oak:
H1 = 2;
H2 = 2;
N1 = 2;
N2 = 2;
B = 2;
break;
case NonWaterRetainingObjectType.Alder:
H1 = 2;
H2 = 2;
N1 = 2;
N2 = 2;
B = 2;
break;
case NonWaterRetainingObjectType.Poplar:
H1 = 2;
H2 = 2;
N1 = 2;
N2 = 2;
B = 2;
break;
default:
H1 = 2;
H2 = 2;
N1 = 2;
N2 = 2;
B = 2;
break;
}
}
///
///
///
///
public void GetDefaultValuesPerMainType(NonWaterRetainingObjectType type)
{
switch (type)
{
case NonWaterRetainingObjectType.GasMain:
H1 = 2;
H2 = 2;
N1 = 2;
N2 = 2;
B = 2;
break;
case NonWaterRetainingObjectType.WaterMain:
H1 = 2;
H2 = 2;
N1 = 2;
N2 = 2;
B = 2;
break;
default:
H1 = 2;
H2 = 2;
N1 = 2;
N2 = 2;
B = 2;
break;
}
}
///
///
///
///
///
public void GetDefaultValuesPerCategoryAndType(NonWaterRetainingObjectCategory category, NonWaterRetainingObjectType type)
{
switch (category)
{
case NonWaterRetainingObjectCategory.Tree: GetDefaultValuesPerTreeType(type);
break;
case NonWaterRetainingObjectCategory.Main: GetDefaultValuesPerMainType(type);
break;
}
}
public void Validate()
{
if (Btotal() <= 0)
throw new NonWaterRetainingObjectException("NonWaterReatiningObject is invalid. Its total width is smaller than or equal to 0.");
if (MaxDistanceFromToe <= Btotal())
throw new NonWaterRetainingObjectException("NonWaterReatiningObject is invalid. The required maximum distance from toe is smaller than or equal to the total width.");
}
}
}