internal MultiValueFunctionND(long _id, string _name, bool _can_interpolate, MultiValPointer _disp_vect, string _unit_x, string _unit_y, string _unit_z, Point4D _bounds, List <double> _Zs, List <List <Point3D> > _Functions, List <string> _Fct_Names) : base(_id, MultiValueType.FUNCTION_ND, _name, _can_interpolate, _disp_vect) { this.MVUnitX = _unit_x; this.MVUnitY = _unit_y; this.MVUnitZ = _unit_z; this.MinX = _bounds.X; this.MaxX = _bounds.Y; this.MinY = _bounds.Z; this.MaxY = _bounds.W; this.zs = _Zs; this.NrZ = _Zs.Count; this.MinZ = this.zs.Min(); this.MaxZ = this.zs.Max(); this.graphs = new List <List <Point3D> >(); foreach (List <Point3D> funct in _Functions) { if (funct == null || funct.Count < 1) { continue; } this.graphs.Add(funct); } this.graph_names = new List <string>(_Fct_Names); }
internal MultiValueTable3D(long _id, string _name, bool _can_interpolate, MultiValPointer _disp_vect, int _nr_x, double _min_x, double _max_x, string _unit_x, int _nr_y, double _min_y, double _max_y, string _unit_y, int _nr_z, double _min_z, double _max_z, string _unit_z, List <double> _Xs, List <double> _Ys, List <double> _Zs, Dictionary <Point3D, double> _Fxyzs) : base(_id, MultiValueType.FIELD_3D, _name, _can_interpolate, _disp_vect) { this.NrX = _nr_x; this.MinX = _min_x; this.MaxX = _max_x; this.MVUnitX = _unit_x; this.NrY = _nr_y; this.MinY = _min_y; this.MaxY = _max_y; this.MVUnitY = _unit_y; this.NrZ = _nr_z; this.MinZ = _min_z; this.MaxZ = _max_z; this.MVUnitZ = _unit_z; this.xs = _Xs; this.ys = _Ys; this.zs = _Zs; this.field = _Fxyzs; }
public static bool AreEqual(MultiValPointer _p1, MultiValPointer _p2) { if (_p1 == null && _p2 != null) { return(false); } if (_p1 != null && _p2 == null) { return(false); } if (_p1 == null && _p2 == null) { return(true); } int dim = _p1.CellIndices.Count; if (dim != _p2.CellIndices.Count) { return(false); } bool positions_equal = (_p1.PosInCell_AbsolutePx.X == _p2.PosInCell_AbsolutePx.X && _p1.PosInCell_AbsolutePx.Y == _p2.PosInCell_AbsolutePx.Y); bool indices_equal = true; for (int i = 0; i < dim; i++) { indices_equal &= (_p1.CellIndices[i] == _p2.CellIndices[i]); } return(positions_equal && indices_equal); }
// only call when parsing internal MultiValueBigTable ReconstructBigTable(long _id, string _name, MultiValPointer _disp_vect, string _unit_x, string _unit_y, string _unit_z, List <string> _names, List <string> _units, List <List <double> > _values, List <string> _row_names) { if (_id < 0) { return(null); } MultiValueBigTable created = new MultiValueBigTable(_id, _name, _disp_vect, _unit_x, _unit_y, _unit_z, _names, _units, _values, _row_names); // check if a valid value table was created if (created == null) { return(null); } if (created.Values.Count == 0) { return(null); } // create this.value_record.Add(created); // adjust type counter MultiValue.NR_MULTI_VALUES = Math.Max(MultiValue.NR_MULTI_VALUES, created.MVID); // done return(created); }
static MultiValPointer() { RectangularValue rv = new RectangularValue() { LeftBottom = double.NaN, RightBottom = double.NaN, RightTop = double.NaN, LeftTop = double.NaN }; MultiValPointer.INVALID = new MultiValPointer(new List <int>(), new Point(0, 0), new Point(0, 0), true, rv, false); }
internal MultiValueTable1D(long _id, string _name, bool _can_interpolate, MultiValPointer _disp_vect, int _nr_x, double _min_x, double _max_x, string _unit_x, List <double> _Xs, string _unit_y, string _unit_z, Dictionary <Point3D, double> _Fxs) : base(_id, MultiValueType.FIELD_1D, _name, _can_interpolate, _disp_vect) { this.NrX = _nr_x; this.MinX = _min_x; this.MaxX = _max_x; this.MVUnitX = _unit_x; this.MVUnitY = _unit_y; this.MVUnitZ = _unit_z; this.xs = _Xs; this.field = _Fxs; }
public MultiValPointer(MultiValPointer _original) { if (_original == null) { this.NrDim = 0; this.cell_indices = new List <int>(); this.cell_size = new Point(0, 0); this.pos_in_cell_relative = new Point(0, 0); this.pos_in_cell_abs_Px = new Point(0, 0); this.Value = double.NaN; } else { this.NrDim = _original.NrDim; this.cell_indices = new List <int>(_original.cell_indices); this.cell_size = new Point(_original.cell_size.X, _original.cell_size.Y); this.pos_in_cell_relative = new Point(_original.pos_in_cell_relative.X, _original.pos_in_cell_relative.Y); this.pos_in_cell_abs_Px = new Point(_original.pos_in_cell_abs_Px.X, _original.pos_in_cell_abs_Px.Y); this.Value = _original.Value; } }
public MultiValPointer(List <int> _cell_indices, Point _cell_size, Point _position, bool _pos_is_absolute, RectangularValue _cell_values, bool _can_interpolate, double _abs_offset_x = 0, double _abs_offset_y = 0) { this.NrDim = 0; this.cell_indices = new List <int>(); this.cell_size = new Point(0, 0); this.pos_in_cell_relative = new Point(0, 0); this.pos_in_cell_abs_Px = new Point(0, 0); this.Value = double.NaN; if (!MultiValPointer.InputValid(_cell_indices, _cell_size, _position, _pos_is_absolute)) { return; } // calculate position this.NrDim = _cell_indices.Count; this.cell_indices = _cell_indices; this.cell_size = _cell_size; if (_pos_is_absolute) { this.pos_in_cell_abs_Px = new Point(_position.X + _abs_offset_x, _position.Y + _abs_offset_y); this.pos_in_cell_relative = new Point(0, 0); this.pos_in_cell_relative.X = (_cell_size.X < Parameter.Calculation.MIN_DOUBLE_VAL) ? 1 : _position.X / _cell_size.X; this.pos_in_cell_relative.Y = (_cell_size.Y < Parameter.Calculation.MIN_DOUBLE_VAL) ? 1 : (_cell_size.Y - _position.Y) / _cell_size.Y; } else { this.pos_in_cell_relative = _position; this.pos_in_cell_abs_Px = new Point(_cell_size.X * _position.X + _abs_offset_x, _cell_size.Y * (1 - _position.Y) + _abs_offset_y); } // calculate value double result = double.NaN; if (_can_interpolate) { double resultY_bottom = _cell_values.LeftBottom * (1.0 - this.pos_in_cell_relative.X) + _cell_values.RightBottom * this.pos_in_cell_relative.X; double resultY_top = _cell_values.LeftTop * (1.0 - this.pos_in_cell_relative.X) + _cell_values.RightTop * this.pos_in_cell_relative.X; result = resultY_bottom * (1.0 - this.pos_in_cell_relative.Y) + resultY_top * this.pos_in_cell_relative.Y; } else { bool take_right = (this.pos_in_cell_relative.X > 0.5); bool take_bottom = (this.pos_in_cell_relative.Y < 0.5); if (take_right && take_bottom) { result = _cell_values.RightBottom; } else if (take_right && !take_bottom) { result = _cell_values.RightTop; } else if (!take_right && take_bottom) { result = _cell_values.LeftBottom; } else { result = _cell_values.LeftTop; } } this.Value = result; }
// only call when parsing internal MultiValueTable ReconstructTable(long _id, string _name, bool _can_interpolate, MultiValPointer _disp_vect, int _nr_x, double _min_x, double _max_x, string _unit_x, int _nr_y, double _min_y, double _max_y, string _unit_y, int _nr_z, double _min_z, double _max_z, string _unit_z, List <double> _Xs, List <double> _Ys, List <double> _Zs, Dictionary <Point3D, double> _Fs) { if (_id < 0) { return(null); } // determine which constructor to call if (_Fs == null || _Fs.Count < 1) { return(null); } if (_Xs == null || _Xs.Count < 1) { return(null); } MultiValueTable created = null; if (_Ys == null || _Ys.Count < 2) { created = new MultiValueTable1D(_id, _name, _can_interpolate, _disp_vect, _nr_x, _min_x, _max_x, _unit_x, _Xs, _unit_y, _unit_z, _Fs); } else if (_Zs == null || _Zs.Count < 2) { created = new MultiValueTable2D(_id, _name, _can_interpolate, _disp_vect, _nr_x, _min_x, _max_x, _unit_x, _nr_y, _min_y, _max_y, _unit_y, _Xs, _Ys, _unit_z, _Fs); } else { created = new MultiValueTable3D(_id, _name, _can_interpolate, _disp_vect, _nr_x, _min_x, _max_x, _unit_x, _nr_y, _min_y, _max_y, _unit_y, _nr_z, _min_z, _max_z, _unit_z, _Xs, _Ys, _Zs, _Fs); } // check if a valid value table was created if (created == null) { return(null); } if (created.NrX == 0) { return(null); } // create this.value_record.Add(created); // adjust type counter MultiValue.NR_MULTI_VALUES = Math.Max(MultiValue.NR_MULTI_VALUES, created.MVID); // done return(created); }
// call only when parsing internal MultiValueFunction ReconstructFunction(long _id, string _name, bool _can_interpolate, MultiValPointer _disp_vect, string _unit_x, string _unit_y, string _unit_z, Point4D _bounds, List <double> _Zs, List <List <Point3D> > _Functions, List <string> _Fct_Names) { if (_id < 0) { return(null); } if (_Zs == null || _Zs.Count < 1) { return(null); } if (_Functions == null || _Functions.Count < 1) { return(null); } if (_Fct_Names == null || _Fct_Names.Count != _Functions.Count) { return(null); } MultiValueFunction created = new MultiValueFunctionND(_id, _name, _can_interpolate, _disp_vect, _unit_x, _unit_y, _unit_z, _bounds, _Zs, _Functions, _Fct_Names); // check if a valid function table was created if (created == null) { return(null); } if (created.NrZ == 0) { return(null); } // create this.value_record.Add(created); // adjust type counter MultiValue.NR_MULTI_VALUES = Math.Max(MultiValue.NR_MULTI_VALUES, created.MVID); // done return(created); }