예제 #1
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);
        }
        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);
                }
            }
        }