コード例 #1
0
        private void DrawRect2D(Vector3d p0, Vector3d p1, DrawPen pen)
        {
            Vector3d v0 = Vector3d.Zero;
            Vector3d v1 = Vector3d.Zero;
            Vector3d v2 = Vector3d.Zero;
            Vector3d v3 = Vector3d.Zero;

            v0.X = System.Math.Max(p0.X, p1.X);
            v0.Y = System.Math.Min(p0.Y, p1.Y);

            v1.X = v0.X;
            v1.Y = System.Math.Max(p0.Y, p1.Y);

            v2.X = System.Math.Min(p0.X, p1.X);
            v2.Y = v1.Y;

            v3.X = v2.X;
            v3.Y = v0.Y;

            Start2D();

            GL.Begin(PrimitiveType.LineStrip);

            GL.Color4(pen.Color4());
            GL.Vertex3(v0);
            GL.Vertex3(v1);
            GL.Vertex3(v2);
            GL.Vertex3(v3);
            GL.Vertex3(v0);

            GL.End();

            End2D();
        }
コード例 #2
0
        public void DrawDot(DrawPen pen, Vector3d p)
        {
            GL.Color4(pen.Color4());

            GL.Begin(PrimitiveType.Points);

            GL.Vertex3(p);

            GL.End();
        }
コード例 #3
0
        private void DrawLineRaw(DrawPen pen, Vector3d a, Vector3d b)
        {
            GL.Color4(pen.Color4());

            GL.Begin(PrimitiveType.LineStrip);

            GL.Vertex3(a);
            GL.Vertex3(b);

            GL.End();
        }
コード例 #4
0
        // Snap時にハイライトされるポイントを描画する
        public void DrawHighlightPoint(Vector3d pt, DrawPen pen)
        {
            GL.LineWidth(DrawingConst.HighlightPointLineWidth);

            Start2D();

            GL.Color4(pen.Color4());
            //DrawCross2D(DC.WorldPointToDevPoint(pt), DrawingConst.HighlightPointLineLength);
            DrawX2D(DC.WorldPointToDevPoint(pt), DrawingConst.HighlightPointLineLength);

            End2D();

            GL.LineWidth(1);
        }
コード例 #5
0
        public void DrawLine(DrawPen pen, Vector3d a, Vector3d b)
        {
            a *= DC.WorldScale;
            b *= DC.WorldScale;

            GL.Color4(pen.Color4());

            GL.Begin(PrimitiveType.LineStrip);

            GL.Vertex3(a);
            GL.Vertex3(b);

            GL.End();
        }
コード例 #6
0
        public void DrawSelectedPoint(Vector3d pt, DrawPen pen)
        {
            Vector3d p = DC.WorldPointToDevPoint(pt);

            Start2D();
            GL.Color4(pen.Color4());
            GL.PointSize(4);

            GL.Begin(PrimitiveType.Points);

            GL.Vertex3(p);

            GL.End();
            End2D();
        }
コード例 #7
0
        public void DrawSelectedPoints(VertexList pointList, DrawPen pen)
        {
            Start2D();
            GL.Color4(pen.Color4());
            GL.PointSize(4);

            GL.Begin(PrimitiveType.Points);

            foreach (CadVertex p in pointList)
            {
                if (p.Selected)
                {
                    GL.Vertex3(DC.WorldPointToDevPoint(p.vector));
                }
            }

            GL.End();
            End2D();
        }
コード例 #8
0
        public void DrawExtSnapPoints(Vector3dList pointList, DrawPen pen)
        {
            GL.Disable(EnableCap.Lighting);
            GL.Disable(EnableCap.Light0);

            Start2D();

            GL.LineWidth(DrawingConst.HighlightPointLineWidth);
            GL.Color4(pen.Color4());

            pointList.ForEach(v =>
            {
                DrawCross2D(DC.WorldPointToDevPoint(v), DrawingConst.HighlightPointLineLength);
            });

            GL.LineWidth(1);

            End2D();
        }
コード例 #9
0
        private void DrawHeEdges(DrawPen borderPen, DrawPen edgePen, double edgeThreshold, HeModel model)
        {
            bool drawBorder = !borderPen.IsNullPen;
            bool drawEdge   = !edgePen.IsNullPen;

            if (!drawBorder && !drawEdge)
            {
                return;
            }

            DisableLight();

            GL.LineWidth(1.0f);

            Color4 color     = borderPen.Color4();
            Color4 edgeColor = edgePen.Color4();

            Vector3d shift = GetShiftForOutLine();

            Vector3d p0;
            Vector3d p1;

            for (int i = 0; i < model.FaceStore.Count; i++)
            {
                HeFace f = model.FaceStore[i];

                HalfEdge head = f.Head;

                HalfEdge c = head;

                HalfEdge pair;

                p0 = model.VertexStore.Ref(c.Vertex).vector *DC.WorldScale + shift;

                for (; ;)
                {
                    bool drawAsEdge = false;

                    pair = c.Pair;

                    if (drawEdge)
                    {
                        if (pair == null)
                        {
                            drawAsEdge = true;
                        }
                        else
                        {
                            if (edgeThreshold != 0)
                            {
                                double s = CadMath.InnerProduct(model.NormalStore[c.Normal], model.NormalStore[pair.Normal]);

                                if (Math.Abs(s) <= edgeThreshold)
                                {
                                    drawAsEdge = true;
                                }
                            }
                        }
                    }

                    p1 = model.VertexStore.Ref(c.Next.Vertex).vector *DC.WorldScale + shift;

                    if (drawAsEdge)
                    {
                        GL.Color4(edgeColor);
                        GL.Begin(PrimitiveType.Lines);
                        GL.Vertex3(p0);
                        GL.Vertex3(p1);
                        GL.End();
                    }
                    else
                    {
                        if (drawBorder)
                        {
                            GL.Color4(color);
                            GL.Begin(PrimitiveType.Lines);
                            GL.Vertex3(p0);
                            GL.Vertex3(p1);
                            GL.End();
                        }
                    }

                    p0 = p1;

                    c = c.Next;

                    if (c == head)
                    {
                        break;
                    }
                }
            }
        }