Ejemplo n.º 1
0
        public Bulkhead CopyWithReflection()
        {
            Bulkhead bulk = Copy();

            //if (type != BulkheadType.BOW)
            {
                Point3DCollection newPoints = new Point3DCollection();

                // FIXTHIS: Eliminate duplicate at bottom/top?
                foreach (Point3D p in m_points)
                {
                    // mirror the X
                    Point3D point = new Point3D(-p.X, p.Y, p.Z);
                    newPoints.Add(point);
                }

                // closed at top or bottom, remove duplicates.
                //if (newPoints[newPoints.Count - 1] == m_points[m_points.Count - 1]) newPoints.RemoveAt(newPoints.Count - 1);
                //if (newPoints[0] == m_points[0]) newPoints.RemoveAt(0);

                foreach (Point3D p in newPoints)
                {
                    bulk.m_points.Insert(0, p);
                }

                bulk.m_IsValid = true;
            }

            return(bulk);
        }
Ejemplo n.º 2
0
        public Bulkhead Copy()
        {
            Bulkhead bulkhead = new Bulkhead();

            bulkhead.type      = type;
            bulkhead.m_IsValid = m_IsValid;
            bulkhead.m_points  = m_points.Clone();

            return(bulkhead);
        }
Ejemplo n.º 3
0
 public SerializableBulkhead(Bulkhead bulkhead)
 {
     transom_angle = bulkhead.TransomAngle;
     bulkheadType  = bulkhead.type;
     isValid       = bulkhead.IsValid;
     points        = new Point3DCollection();
     if (isValid)
     {
         points = bulkhead.m_points.Clone();
     }
 }
Ejemplo n.º 4
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            if (m_Hull == null || !m_Hull.IsValid)
            {
                return;
            }

            Rect background = new Rect(new Point(0, 0), new Point(ActualWidth, ActualHeight));

            drawingContext.DrawRectangle(this.Background, null, background);

            Pen pen = new Pen(System.Windows.Media.Brushes.Black, 1.0);

            for (int bulkhead = 0; bulkhead < m_Hull.numBulkheads(); bulkhead++)
            {
                Bulkhead bulk = m_Hull.GetBulkhead(bulkhead);
                for (int chine = 0; chine < bulk.Count - 1; chine++)
                {
                    Point p1 = new Point(bulk.GetPoint(chine).X, bulk.GetPoint(chine).Y);
                    Point p2 = new Point(bulk.GetPoint(chine + 1).X, bulk.GetPoint(chine + 1).Y);

                    drawingContext.DrawLine(pen, p1, p2);
                }
            }

            pen = new Pen(System.Windows.Media.Brushes.Gray, 1.0);

            for (int chine = 0; chine < m_Hull.numChines(); chine++)
            {
                Point3DCollection currChine = m_Hull.GetChine(chine);

                // FIXTHIS: use a foreach and simply remember the previous point
                for (int point = 0; point < currChine.Count - 1; point++)
                {
                    Point p1 = new Point(currChine[point].X, currChine[point].Y);
                    Point p2 = new Point(currChine[point + 1].X, currChine[point + 1].Y);

                    drawingContext.DrawLine(pen, p1, p2);
                }
            }

            DrawHandles(drawingContext);
        }
Ejemplo n.º 5
0
        public void LoadFromHullFile(string filename)
        {
            m_IsValid   = false;
            m_chines    = null;
            m_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();
                bulkhead.LoadFromHullFile(file, num_chines, Bulkhead.BulkheadType.BOW);
                m_bulkheads.Add(bulkhead);

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

                bulkhead = new Bulkhead();
                bulkhead.LoadFromHullFile(file, num_chines, Bulkhead.BulkheadType.TRANSOM);
                m_bulkheads.Add(bulkhead);
            }
            PrepareChines(POINTS_PER_CHINE);
            RepositionToZero();

            m_IsValid = true;
            HullData++;
            Notify("HullData");
        }
        private void Panelize(Hull hull)
        {
            Hull highResHull = hull.Copy();

            highResHull.PrepareChines(POINTS_PER_CHINE);

            int numPanels = highResHull.numChines() - 1;

            m_panels = new List <Panel>();

            for (int ii = 0; ii < numPanels; ii++)
            {
                Panel panel = new Panel(highResHull.GetChine(ii), highResHull.GetChine(ii + 1));
                panel.name = "Chine " + (ii + 1);
                m_panels.Add(panel);
            }

            //*********************************
            // bulkheads:
            int numBulkheads = hull.numBulkheads();

            if (hull.GetBulkhead(numBulkheads - 1).type == Bulkhead.BulkheadType.BOW)
            {
                numBulkheads--;
            }

            Hull fullHull = hull.CopyToFullHull();

            for (int bulkhead = 0; bulkhead < fullHull.numBulkheads(); bulkhead++)
            {
                int numChines = fullHull.numChines();

                if (fullHull.GetBulkhead(bulkhead).type != Bulkhead.BulkheadType.BOW)
                {
                    Bulkhead          bulk   = fullHull.GetBulkhead(bulkhead);
                    Point3DCollection points = new Point3DCollection();

                    Point3D basePoint = bulk.GetPoint(0);

                    for (int chine = 0; chine < numChines; chine++)
                    {
                        Point3D point = bulk.GetPoint(chine);
                        if (bulk.type == Bulkhead.BulkheadType.TRANSOM)
                        {
                            point.Y = basePoint.Y + (point.Y - basePoint.Y) / Math.Sin(bulk.TransomAngle);
                        }
                        points.Add(bulk.GetPoint(chine));
                    }

                    // close the shape
                    if (points[0].X != 0)
                    {
                        points.Add(points[0]);
                    }

                    Panel panel = new Panel(points);
                    panel.name = "Bulkhead " + (bulkhead + 1);
                    m_panels.Add(panel);
                }
            }
        }