Beispiel #1
0
        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));
                    }
                }
            }
        }
Beispiel #2
0
        private void method_0(
            IShape2D path,
            Color color,
            Matrix4D transform,
            bool filled,
            double extrusion,
            bool isChar)
        {
            if (!path.HasSegments)
            {
                return;
            }
            ISurfaceGraphicsFactory graphicsFactory0 = this.isurfaceGraphicsFactory_0;
            IList <Polyline2D>      flattened        = (IList <Polyline2D>)ShapeTool.GetFlattened(path, this.surface_0.Config.ShapeFlattenEpsilon);

            this.isurfaceGraphicsFactory_0.SetColor(this.surface_0.GetPlotColor(this.dxfEntity_0, color));
            Interface41 transformer = (Interface41)this.surface_0.GetTransformer().Clone();

            transformer.SetPreTransform(transform);
            if (!filled)
            {
                IList <Polyline4D> polyline4DList1 = DxfUtil.smethod_48(flattened, transformer);
                foreach (Polyline4D polyline4D in (IEnumerable <Polyline4D>)polyline4DList1)
                {
                    graphicsFactory0.CreatePolyline((IList <Vector4D>)polyline4D, polyline4D.Closed);
                }
                if (extrusion == 0.0)
                {
                    return;
                }
                transformer.SetPreTransform(Transformation4D.Translation(0.0, 0.0, extrusion));
                IList <Polyline4D> polyline4DList2 = DxfUtil.smethod_48(flattened, transformer);
                foreach (Polyline4D polyline4D in (IEnumerable <Polyline4D>)polyline4DList2)
                {
                    graphicsFactory0.CreatePolyline((IList <Vector4D>)polyline4D, polyline4D.Closed);
                }
                Polyline4D polyline4D1 = new Polyline4D(2);
                polyline4D1.Add(Vector4D.Zero);
                polyline4D1.Add(Vector4D.Zero);
                for (int index1 = polyline4DList1.Count - 1; index1 >= 0; --index1)
                {
                    Polyline4D polyline4D2 = polyline4DList1[index1];
                    Polyline4D polyline4D3 = polyline4DList2[index1];
                    for (int index2 = polyline4D2.Count - 1; index2 >= 0; --index2)
                    {
                        polyline4D1[0] = polyline4D2[index2];
                        polyline4D1[1] = polyline4D3[index2];
                        graphicsFactory0.CreatePolyline((IList <Vector4D>)polyline4D1, false);
                    }
                }
            }
            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);
                Polyline4D polyline4D1 = DxfUtil.smethod_49(polyline, transformer);
                if (extrusion == 0.0)
                {
                    for (int index = 0; index < triangleList.Count; ++index)
                    {
                        Triangulator2D.Triangle triangle = triangleList[index];
                        this.isurfaceGraphicsFactory_0.CreateTriangle(polyline4D1[triangle.I0], polyline4D1[triangle.I1], polyline4D1[triangle.I2], (IList <bool>)null);
                    }
                }
                else
                {
                    if (extrusion == 0.0)
                    {
                        return;
                    }
                    IList <Polyline4D> polyline4DList1 = DxfUtil.smethod_48(flattened, transformer);
                    transformer.SetPreTransform(Transformation4D.Translation(0.0, 0.0, extrusion));
                    Polyline4D         polyline4D2     = DxfUtil.smethod_49(polyline, transformer);
                    IList <Polyline4D> polyline4DList2 = DxfUtil.smethod_48(flattened, transformer);
                    if (extrusion > 0.0)
                    {
                        for (int index = 0; index < triangleList.Count; ++index)
                        {
                            Triangulator2D.Triangle triangle = triangleList[index];
                            this.isurfaceGraphicsFactory_0.CreateTriangle(polyline4D1[triangle.I0], polyline4D1[triangle.I2], polyline4D1[triangle.I1], (IList <bool>)null);
                        }
                        for (int index = 0; index < triangleList.Count; ++index)
                        {
                            Triangulator2D.Triangle triangle = triangleList[index];
                            this.isurfaceGraphicsFactory_0.CreateTriangle(polyline4D2[triangle.I0], polyline4D2[triangle.I1], polyline4D2[triangle.I2], (IList <bool>)null);
                        }
                    }
                    else
                    {
                        for (int index = 0; index < triangleList.Count; ++index)
                        {
                            Triangulator2D.Triangle triangle = triangleList[index];
                            this.isurfaceGraphicsFactory_0.CreateTriangle(polyline4D1[triangle.I0], polyline4D1[triangle.I1], polyline4D1[triangle.I2], (IList <bool>)null);
                        }
                        for (int index = 0; index < triangleList.Count; ++index)
                        {
                            Triangulator2D.Triangle triangle = triangleList[index];
                            this.isurfaceGraphicsFactory_0.CreateTriangle(polyline4D2[triangle.I0], polyline4D2[triangle.I2], polyline4D2[triangle.I1], (IList <bool>)null);
                        }
                    }
                    for (int index1 = polyline4DList1.Count - 1; index1 >= 0; --index1)
                    {
                        Polyline4D       polyline4D3 = polyline4DList1[index1];
                        Polyline4D       polyline4D4 = polyline4DList2[index1];
                        Polyline2D       polyline2D  = flattened[index1];
                        IList <Vector3D> normals     = (IList <Vector3D>) new List <Vector3D>(polyline4D3.Count + 1);
                        for (int index2 = 0; index2 < polyline4D3.Count; ++index2)
                        {
                            int      index3   = (index2 + 1) % polyline4D3.Count;
                            Vector2D vector2D = polyline2D[index3] - polyline2D[index2];
                            normals.Add(transformer.Transform(new Vector3D(vector2D.Y, -vector2D.X, 0.0)));
                        }
                        normals.Add(normals[0]);
                        this.isurfaceGraphicsFactory_0.CreateQuadStrip((IList <Vector4D>)polyline4D3, (IList <Vector4D>)polyline4D4, normals, 0, 0);
                    }
                }
            }
        }