Exemple #1
0
        public void LoadFromHullFile(string filename)
        {
            Bulkheads = new List <Bulkhead>();

            using (StreamReader file = File.OpenText(filename))
            {
                string line;
                int    num_chines;
                int    numBulkheads = 5;

                line = file.ReadLine();
                if (!int.TryParse(line, out num_chines))
                {
                    throw new Exception("Invalid HUL file format");
                }

                Bulkhead bulkhead = new Bulkhead(file, num_chines, Bulkhead.BulkheadType.BOW);
                Bulkheads.Add(bulkhead);

                for (int ii = 1; ii < numBulkheads - 1; ii++)
                {
                    bulkhead = new Bulkhead(file, num_chines, Bulkhead.BulkheadType.VERTICAL);
                    Bulkheads.Add(bulkhead);
                }

                bulkhead = new Bulkhead(file, num_chines, Bulkhead.BulkheadType.TRANSOM);
                Bulkheads.Add(bulkhead);
            }
            RepositionToZero();

            SetBulkheadHandler(bulkhead_PropertyChanged);

            Notify("HullData");
        }
Exemple #2
0
        public Hull(string filename)
        {
            Bulkheads = new List <Bulkhead>();

            Timestamp = DateTime.Now;

            using (StreamReader file = File.OpenText(filename))
            {
                string line;
                int    num_chines;
                int    numBulkheads = 5;

                line = file.ReadLine();
                if (!int.TryParse(line, out num_chines))
                {
                    throw new Exception("Invalid HUL file format");
                }

                Bulkhead bulkhead = new Bulkhead(file, num_chines, Bulkhead.BulkheadType.BOW);
                Bulkheads.Add(bulkhead);

                for (int ii = 1; ii < numBulkheads - 1; ii++)
                {
                    bulkhead = new Bulkhead(file, num_chines, Bulkhead.BulkheadType.VERTICAL);
                    Bulkheads.Add(bulkhead);
                }

                bulkhead = new Bulkhead(file, num_chines, Bulkhead.BulkheadType.TRANSOM);
                Bulkheads.Add(bulkhead);
            }
            RepositionToZero();
            CheckTransom();
            SetBulkheadHandler();
        }
Exemple #3
0
        public void ChangeChines(int numChines)
        {
            for (int ii = 0; ii < Bulkheads.Count; ii++)
            {
                Bulkheads[ii] = new Bulkhead(Bulkheads[ii], numChines);
            }

            Notify("HullData");
        }
Exemple #4
0
        public virtual void ChangeChines(int numChines)
        {
            Timestamp = DateTime.Now;

            for (int ii = 0; ii < Bulkheads.Count; ii++)
            {
                Bulkheads[ii] = new Bulkhead(Bulkheads[ii], numChines);
            }

            Notify("HullData");
        }
Exemple #5
0
        //**********************************************
        // IClonable implementation
        public object Clone()
        {
            Bulkhead copy = new Bulkhead
            {
                Type           = Type,
                m_transomAngle = TransomAngle,
                m_points       = m_points.Clone()
            };

            return(copy);
        }
Exemple #6
0
        public Panel(Bulkhead bulk)
        {
            double scaleFactor = Math.Sin(bulk.TransomAngle);

            m_panelPoints = new PointCollection();

            foreach (Point3D point in bulk.Points)
            {
                // FIXTHIS: only works for VERTICAL bulkheads
                m_panelPoints.Add(new Point(point.X, point.Y / scaleFactor));
            }
            ShiftTo(0, 0);
        }
Exemple #7
0
        public Panel(Bulkhead bulk)
        {
            double scaleFactor = 1;

            if (bulk.Type == Bulkhead.BulkheadType.TRANSOM)
            {
                scaleFactor = Math.Sin(bulk.TransomAngle);
            }

            m_panelPoints = new PointCollection();

            foreach (Point3D point in bulk.Points)
            {
                m_panelPoints.Add(new Point(point.X, point.Y / scaleFactor));
            }
            Center();
        }
Exemple #8
0
 private void CreateHandles()
 {
     m_handles.Clear();
     if (IsEditable && m_selectedBulkhead != NOT_SELECTED)
     {
         Bulkhead bulk = m_editableHull.Bulkheads[m_selectedBulkhead];
         foreach (Point3D point in bulk.Points)
         {
             Rect rect = new Rect();
             rect.Height = HANDLE_SIZE / m_scale;
             rect.Width  = HANDLE_SIZE / m_scale;
             rect.X      = point.X - HANDLE_SIZE / m_scale / 2;
             rect.Y      = point.Y - HANDLE_SIZE / m_scale / 2;
             RectangleGeometry geom = new RectangleGeometry(rect);
             geom.Transform = m_xform;
             m_handles.Add(geom);
         }
     }
 }
Exemple #9
0
        public Bulkhead(Bulkhead original, int num_chines)
        {
            const int PRECISION = 10;

            m_points = new Point3DCollection();
            Point3DCollection tempPoints = new Point3DCollection();

            IsFlatBottomed = original.IsFlatBottomed;
            HasClosedTop   = original.HasClosedTop;

            if (!IsFlatBottomed)
            {
                // centerline bulkhead
                int useable_chines = original.NumChines / 2 + 1;

                for (int ii = 0; ii < useable_chines; ii++)
                {
                    tempPoints.Add(original.Points[ii]);
                }

                Splines           shape   = new Splines(tempPoints, Splines.RELAXED);
                Point3DCollection outline = shape.GetPoints((num_chines + 1) * PRECISION);

                int index = 0;
                for (int ii = 0; ii < num_chines; ii++)
                {
                    m_points.Add(outline[index]);
                    index += PRECISION;
                }

                // Add the center point
                m_points.Add(original.Points[original.NumChines / 2]);

                // Add the other half
                index = PRECISION * num_chines;
                for (int ii = 0; ii < num_chines; ii++)
                {
                    index -= PRECISION;
                    Point3D point = outline[index];
                    point.X = -point.X;
                    m_points.Add(point);
                }
            }
            else
            {
                // flat floor bulkhead
                int useable_chines = original.NumChines / 2;

                for (int ii = 0; ii < useable_chines; ii++)
                {
                    tempPoints.Add(original.Points[ii]);
                }

                Splines           shape   = new Splines(tempPoints, Splines.RELAXED);
                Point3DCollection outline = shape.GetPoints((num_chines + 1) * PRECISION);

                int index = 0;
                for (int ii = 0; ii < num_chines; ii++)
                {
                    m_points.Add(outline[index]);
                    index += PRECISION;
                }

                // Add the center point
                m_points.Add(original.Points[original.NumChines / 2]);

                // Add the other half
                index = PRECISION * num_chines;
                for (int ii = 0; ii < num_chines; ii++)
                {
                    index -= PRECISION;
                    Point3D point = outline[index];
                    point.X = -point.X;
                    m_points.Add(point);
                }
            }
        }