コード例 #1
0
ファイル: DxfPolyline2DBase.cs プロジェクト: 15831944/WW
        private void GetPolylines(
            DrawContext context,
            ILineTypeScaler lineTypeScaler,
            out IList <Polyline3D> polylines,
            out IList <FlatShape4D> shapes,
            out bool fill)
        {
            IList <IList <Polyline2D> > polylines1;
            IList <IList <Polyline2D> > polylines2;

            this.GetPolylines(context, lineTypeScaler, out polylines1, out polylines2, out shapes, out fill);
            polylines = (IList <Polyline3D>) new List <Polyline3D>();
            int      count     = polylines1.Count;
            Matrix4D transform = this.Transform;

            if (polylines2 != null && polylines2.Count != 0)
            {
                for (int index = 0; index < count; ++index)
                {
                    DxfUtil.smethod_14(polylines1[index], polylines2[index], transform, polylines, true);
                }
            }
            else
            {
                for (int index1 = 0; index1 < count; ++index1)
                {
                    IList <Polyline2D> polyline2DList = polylines1[index1];
                    for (int index2 = 0; index2 < polylines1.Count; ++index2)
                    {
                        polylines.Add(DxfUtil.smethod_42(polyline2DList[index2], transform));
                    }
                }
            }
        }
コード例 #2
0
ファイル: Class355.cs プロジェクト: 15831944/WW
        private void method_0(
            IShape2D path,
            Color color,
            Matrix4D transform,
            bool filled,
            double extrusion,
            bool isChar)
        {
            if (!path.HasSegments)
            {
                return;
            }
            ArgbColor plotColor = this.surface_0.GetPlotColor(this.dxfEntity_0, color);

            if (this.graphicElement1Node_0 == null)
            {
                this.graphicElement1Node_0 = new GraphicElement1Node(plotColor);
                this.graphics_0.AddNewGraphicElement(this.dxfEntity_0, this.igraphicElementBlock_0, (GraphicElement1)this.graphicElement1Node_0);
            }
            else if (this.graphicElement1Node_0.Color != plotColor)
            {
                this.graphicElement1Node_0.Next = new GraphicElement1Node(plotColor);
                this.graphicElement1Node_0      = this.graphicElement1Node_0.Next;
            }
            IList <Polyline2D> flattened = (IList <Polyline2D>)ShapeTool.GetFlattened(path, this.surface_0.Config.ShapeFlattenEpsilon);

            if (!filled)
            {
                IList <WW.Math.Geometry.Polyline3D> polyline3DList1 = DxfUtil.smethod_41(flattened, transform);
                foreach (WW.Math.Geometry.Polyline3D polyline in (IEnumerable <WW.Math.Geometry.Polyline3D>)polyline3DList1)
                {
                    this.graphicElement1Node_0.Geometry.Add(WW.Cad.Drawing.Surface.Polyline3D.CreatePrimitive(polyline));
                }
                if (extrusion == 0.0)
                {
                    return;
                }
                IList <WW.Math.Geometry.Polyline3D> polyline3DList2 = DxfUtil.smethod_41(flattened, transform * Transformation4D.Translation(0.0, 0.0, extrusion));
                foreach (WW.Math.Geometry.Polyline3D polyline in (IEnumerable <WW.Math.Geometry.Polyline3D>)polyline3DList2)
                {
                    this.graphicElement1Node_0.Geometry.Add(WW.Cad.Drawing.Surface.Polyline3D.CreatePrimitive(polyline));
                }
                for (int index1 = polyline3DList1.Count - 1; index1 >= 0; --index1)
                {
                    WW.Math.Geometry.Polyline3D polyline3D1 = polyline3DList1[index1];
                    WW.Math.Geometry.Polyline3D polyline3D2 = polyline3DList2[index1];
                    for (int index2 = polyline3D1.Count - 1; index2 >= 0; --index2)
                    {
                        this.graphicElement1Node_0.Geometry.Add((IPrimitive) new WW.Cad.Drawing.Surface.Segment(polyline3D1[index2], polyline3D2[index2]));
                    }
                }
            }
            else
            {
                List <Triangulator2D.Triangle> triangleList;
                List <WW.Math.Point2D>         point2DList;
                if (isChar)
                {
                    Class454 class454 = this.surface_0.CharTriangulationCache.method_0(path, this.surface_0.Config);
                    triangleList = class454.Triangles;
                    point2DList  = class454.Points;
                }
                else
                {
                    triangleList = new List <Triangulator2D.Triangle>();
                    point2DList  = new List <WW.Math.Point2D>();
                    IList <IList <WW.Math.Point2D> > polygons = (IList <IList <WW.Math.Point2D> >) new List <IList <WW.Math.Point2D> >();
                    foreach (Polyline2D polyline2D in (IEnumerable <Polyline2D>)flattened)
                    {
                        polygons.Add((IList <WW.Math.Point2D>)polyline2D);
                    }
                    Triangulator2D.Triangulate(polygons, (IList <Triangulator2D.Triangle>)triangleList, (IList <WW.Math.Point2D>)point2DList);
                }
                Polyline2D polyline = new Polyline2D((IEnumerable <WW.Math.Point2D>)point2DList);
                WW.Math.Geometry.Polyline3D polyline3D1 = DxfUtil.smethod_42(polyline, transform);
                if (extrusion == 0.0)
                {
                    for (int index = 0; index < triangleList.Count; ++index)
                    {
                        Triangulator2D.Triangle triangle = triangleList[index];
                        this.graphicElement1Node_0.Geometry.Add((IPrimitive) new WW.Cad.Drawing.Surface.Triangle(polyline3D1[triangle.I0], polyline3D1[triangle.I1], polyline3D1[triangle.I2]));
                    }
                }
                else
                {
                    if (extrusion == 0.0)
                    {
                        return;
                    }
                    IList <WW.Math.Geometry.Polyline3D> polyline3DList1 = DxfUtil.smethod_41(flattened, transform);
                    Matrix4D transform1 = transform * Transformation4D.Translation(0.0, 0.0, extrusion);
                    WW.Math.Geometry.Polyline3D         polyline3D2     = DxfUtil.smethod_42(polyline, transform1);
                    IList <WW.Math.Geometry.Polyline3D> polyline3DList2 = DxfUtil.smethod_41(flattened, transform1);
                    if (extrusion > 0.0)
                    {
                        for (int index = 0; index < triangleList.Count; ++index)
                        {
                            Triangulator2D.Triangle triangle = triangleList[index];
                            this.graphicElement1Node_0.Geometry.Add((IPrimitive) new WW.Cad.Drawing.Surface.Triangle(polyline3D1[triangle.I0], polyline3D1[triangle.I2], polyline3D1[triangle.I1]));
                        }
                        for (int index = 0; index < triangleList.Count; ++index)
                        {
                            Triangulator2D.Triangle triangle = triangleList[index];
                            this.graphicElement1Node_0.Geometry.Add((IPrimitive) new WW.Cad.Drawing.Surface.Triangle(polyline3D2[triangle.I0], polyline3D2[triangle.I1], polyline3D2[triangle.I2]));
                        }
                    }
                    else
                    {
                        for (int index = 0; index < triangleList.Count; ++index)
                        {
                            Triangulator2D.Triangle triangle = triangleList[index];
                            this.graphicElement1Node_0.Geometry.Add((IPrimitive) new WW.Cad.Drawing.Surface.Triangle(polyline3D1[triangle.I0], polyline3D1[triangle.I1], polyline3D1[triangle.I2]));
                        }
                        for (int index = 0; index < triangleList.Count; ++index)
                        {
                            Triangulator2D.Triangle triangle = triangleList[index];
                            this.graphicElement1Node_0.Geometry.Add((IPrimitive) new WW.Cad.Drawing.Surface.Triangle(polyline3D2[triangle.I0], polyline3D2[triangle.I2], polyline3D2[triangle.I1]));
                        }
                    }
                    for (int index1 = polyline3DList1.Count - 1; index1 >= 0; --index1)
                    {
                        WW.Math.Geometry.Polyline3D polyline3D3 = polyline3DList1[index1];
                        WW.Math.Geometry.Polyline3D polyline3D4 = polyline3DList2[index1];
                        Polyline2D       polyline2D             = flattened[index1];
                        IList <Vector3D> normals = (IList <Vector3D>) new List <Vector3D>(polyline3D3.Count + 1);
                        for (int index2 = 0; index2 < polyline3D3.Count; ++index2)
                        {
                            int      index3   = (index2 + 1) % polyline3D3.Count;
                            Vector2D vector2D = polyline2D[index3] - polyline2D[index2];
                            normals.Add(transform.Transform(new Vector3D(vector2D.Y, -vector2D.X, 0.0)));
                        }
                        normals.Add(normals[0]);
                        this.graphicElement1Node_0.Geometry.Add((IPrimitive) new QuadStrip2((IList <WW.Math.Point3D>)polyline3D3, (IList <WW.Math.Point3D>)polyline3D4, normals, 0, 0));
                    }
                }
            }
        }
コード例 #3
0
 internal static void smethod_14(
     DxfEntity entity,
     DrawContext.Surface context,
     WW.Cad.Drawing.Surface.Geometry geometry,
     Polyline2D polylineA,
     Polyline2D polylineB,
     Matrix4D transform,
     Vector3D normal,
     bool isSurface)
 {
     if (polylineA.Count == 1)
     {
         WW.Math.Point2D point1 = polylineA[0];
         WW.Math.Point2D point2 = polylineB[0];
         if (point1 == point2)
         {
             geometry.Add((IPrimitive) new WW.Cad.Drawing.Surface.Point(transform.TransformTo3D(point1)));
         }
         else
         {
             geometry.Add((IPrimitive) new WW.Cad.Drawing.Surface.Segment(transform.TransformTo3D(point1), transform.TransformTo3D(point2)));
         }
     }
     else if (polylineA.Count == 2)
     {
         WW.Math.Point2D point1 = polylineA[0];
         WW.Math.Point2D point2 = polylineA[1];
         WW.Math.Point2D point3 = polylineB[0];
         WW.Math.Point2D point4 = polylineB[1];
         if (isSurface)
         {
             geometry.Add((IPrimitive) new Quad(transform.TransformTo3D(point1), transform.TransformTo3D(point2), transform.TransformTo3D(point4), transform.TransformTo3D(point3)));
         }
         else
         {
             geometry.Add(WW.Cad.Drawing.Surface.Polyline3D.CreatePrimitive((IList <WW.Math.Point3D>) new WW.Math.Point3D[4]
             {
                 transform.TransformTo3D(point1),
                 transform.TransformTo3D(point2),
                 transform.TransformTo3D(point4),
                 transform.TransformTo3D(point3)
             }, true));
         }
     }
     else
     {
         int  count  = polylineA.Count;
         bool closed = polylineA.Closed;
         WW.Math.Geometry.Polyline3D polyline3D1 = DxfUtil.smethod_42(polylineA, transform);
         WW.Math.Geometry.Polyline3D polyline3D2 = DxfUtil.smethod_42(polylineB, transform);
         if (isSurface)
         {
             geometry.Add((IPrimitive) new QuadStrip1((IList <WW.Math.Point3D>)polyline3D1, (IList <WW.Math.Point3D>)polyline3D2, normal, closed));
         }
         else
         {
             int index1 = 0;
             int num    = 1;
             if (closed)
             {
                 index1 = count - 1;
                 num    = 0;
             }
             WW.Math.Point3D start = polyline3D1[index1];
             WW.Math.Point3D end   = polyline3D2[index1];
             for (int index2 = num; index2 < count; ++index2)
             {
                 WW.Math.Point3D point3D1 = polyline3D1[index2];
                 WW.Math.Point3D point3D2 = polyline3D2[index2];
                 geometry.Add((IPrimitive) new WW.Cad.Drawing.Surface.Segment(start, end));
                 start = point3D1;
                 end   = point3D2;
             }
             geometry.Add(WW.Cad.Drawing.Surface.Polyline3D.CreatePrimitive((IList <WW.Math.Point3D>)polyline3D1, closed));
             geometry.Add(WW.Cad.Drawing.Surface.Polyline3D.CreatePrimitive((IList <WW.Math.Point3D>)polyline3D2, closed));
         }
     }
 }