//-----------------------------------------------------------------------
//
// Copyright (c) 2011 Deltares. All rights reserved.
//
// J. Bokma
// john.bokma@deltares.nl
// 13-10-2011
// n.a.
//-----------------------------------------------------------------------
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.");
}
}
}