Пример #1
0
 public IntersectedMeshOutputAveraging(Model2D_old model, ICrackDescription crackGeometry, string pathNoExtension)
 {
     this.crackGeometry   = crackGeometry;
     this.model           = model;
     this.pathNoExtension = pathNoExtension;
     this.triangulator    = new Triangulator2D <CartesianPoint>((x, y) => new CartesianPoint(x, y));
 }
Пример #2
0
 public BasicCrackLSM(double tipEnrichmentAreaRadius = 0.0)
 {
     this.tipEnrichmentAreaRadius = tipEnrichmentAreaRadius;
     this.triangulator            = new Triangulator2D <CartesianPoint>((x, y) => new CartesianPoint(x, y));
     this.tipElements             = new List <XContinuumElement2D>();
     levelSetsBody = new Dictionary <XNode, double>();
     levelSetsTip  = new Dictionary <XNode, double>();
 }
Пример #3
0
        public BasicExplicitCrack2D(double tipEnrichmentAreaRadius = 0.0)
        {
            this.tipEnrichmentAreaRadius = tipEnrichmentAreaRadius;
            this.triangulator            = new Triangulator2D <CartesianPoint>((x, y) => new CartesianPoint(x, y));
            this.tipElements             = new List <XContinuumElement2D>();

            Vertices = new List <CartesianPoint>();
            Segments = new List <DirectedSegment2D>();
            Angles   = new List <double>();
        }
Пример #4
0
        public BasicExplicitInteriorCrack(double enrichmentRadiusOverElementSize = 0.0)
        {
            this.enrichmentRadiusOverElementSize = enrichmentRadiusOverElementSize;
            this.triangulator     = new Triangulator2D <CartesianPoint>((x, y) => new CartesianPoint(x, y));
            this.startTipElements = new List <XContinuumElement2D>();
            this.endTipElements   = new List <XContinuumElement2D>();

            Vertices = new LinkedList <CartesianPoint>();
            Segments = new LinkedList <DirectedSegment2D>();
            Angles   = new LinkedList <double>();
        }
Пример #5
0
        public override void DrawInternal(
            DrawContext.Surface context,
            Graphics graphics,
            IGraphicElementBlock parentGraphicElementBlock)
        {
            DxfImageDef imageDef = this.ImageDef;

            if (imageDef == null || !imageDef.Bitmap.IsValid)
            {
                return;
            }
            List <WW.Math.Point2D> clipBoundary = (List <WW.Math.Point2D>) this.GetClipBoundary((DrawContext)context);

            if (clipBoundary == null || clipBoundary.Count <= 0 || !graphics.AddExistingGraphicElement1(parentGraphicElementBlock, (DxfEntity)this, ArgbColor.Empty))
            {
                return;
            }
            List <Triangulator2D.Triangle> triangleList = new List <Triangulator2D.Triangle>();
            List <WW.Math.Point2D>         point2DList  = new List <WW.Math.Point2D>();

            Triangulator2D.Triangulate((IList <IList <WW.Math.Point2D> >) new List <WW.Math.Point2D>[1]
            {
                clipBoundary
            }, (IList <Triangulator2D.Triangle>)triangleList, (IList <WW.Math.Point2D>)point2DList);
            Matrix4D matrix4D = this.method_15();

            WW.Math.Point2D[] point2DArray        = new WW.Math.Point2D[point2DList.Count];
            WW.Math.Point3D[] point3DArray        = new WW.Math.Point3D[point2DList.Count];
            Size2D            referencedImageSize = this.ReferencedImageSize;
            double            num1     = 1.0 / referencedImageSize.X;
            double            num2     = 1.0 / referencedImageSize.Y;
            Vector2D          vector2D = new Vector2D(0.5, 0.5);

            for (int index = point2DList.Count - 1; index >= 0; --index)
            {
                WW.Math.Point2D point = point2DList[index] + vector2D;
                point2DArray[index] = new WW.Math.Point2D(num1 * point.X, 1.0 - num2 * point.Y);
                point3DArray[index] = matrix4D.TransformTo3D(point);
            }
            GraphicElement1 graphicElement = new GraphicElement1(ArgbColor.Empty);

            graphics.AddNewGraphicElement((DxfEntity)this, parentGraphicElementBlock, graphicElement);
            TexturedTriangleList texturedTriangleList = new TexturedTriangleList();

            graphicElement.Geometry.Add((IPrimitive)texturedTriangleList);
            texturedTriangleList.RgbaBytes          = imageDef.Bitmap.GetRgbaBytes();
            texturedTriangleList.Width              = imageDef.Bitmap.Width;
            texturedTriangleList.Height             = imageDef.Bitmap.Height;
            texturedTriangleList.Normal             = matrix4D.Transform(WW.Math.Vector3D.ZAxis);
            texturedTriangleList.Triangles          = (IList <Triangulator2D.Triangle>)triangleList;
            texturedTriangleList.TextureCoordinates = (IList <WW.Math.Point2D>)point2DArray;
            texturedTriangleList.Points             = (IList <WW.Math.Point3D>)point3DArray;
        }
Пример #6
0
        private void TestTriangulate2D()
        {
            var vertices = Triangulator2D.Triangulate(new List <Vector3>()
            {
                new Vector3(0, 0),
                new Vector3(0, 1),
                new Vector3(1, 0),
                new Vector3(1, 1),
            });

            Assert.Equal(vertices.Count / 3, 2);
        }
Пример #7
0
 public static void smethod_22(WW.Cad.Drawing.Surface.Geometry geometry, IList <WW.Math.Point3D> boundary)
 {
     if (boundary.Count == 0)
     {
         return;
     }
     if (boundary.Count == 1)
     {
         geometry.Add((IPrimitive) new WW.Cad.Drawing.Surface.Point(boundary[0]));
     }
     else if (boundary.Count == 2)
     {
         geometry.Add((IPrimitive) new WW.Cad.Drawing.Surface.Segment(boundary[0], boundary[1]));
     }
     else if (boundary.Count == 3)
     {
         geometry.Add((IPrimitive) new WW.Cad.Drawing.Surface.Triangle(boundary[0], boundary[1], boundary[2]));
     }
     else if (boundary.Count == 4)
     {
         geometry.Add((IPrimitive) new Quad(boundary[0], boundary[1], boundary[2], boundary[3]));
     }
     else
     {
         int       count     = boundary.Count;
         Polygon3D polygon3D = new Polygon3D(count);
         for (int index = 0; index < count; ++index)
         {
             polygon3D.Add(boundary[index]);
         }
         Plane3D?plane = polygon3D.GetPlane();
         if (!plane.HasValue)
         {
             return;
         }
         Matrix4D  matrix4D     = Transformation4D.Translation(plane.Value.Distance * plane.Value.Normal) * Transformation4D.GetArbitraryCoordSystem(plane.Value.Normal);
         Matrix4D  inverse      = matrix4D.GetInverse();
         Polygon2D projection2D = polygon3D.GetProjection2D(inverse);
         List <Triangulator2D.Triangle> triangleList = new List <Triangulator2D.Triangle>();
         List <WW.Math.Point2D>         point2DList  = new List <WW.Math.Point2D>();
         Triangulator2D.Triangulate((IList <IList <WW.Math.Point2D> >) new Polygon2D[1]
         {
             projection2D
         }, (IList <Triangulator2D.Triangle>)triangleList, (IList <WW.Math.Point2D>)point2DList);
         foreach (Triangulator2D.Triangle triangle in triangleList)
         {
             geometry.Add((IPrimitive) new WW.Cad.Drawing.Surface.Triangle(matrix4D.TransformTo3D(point2DList[triangle.I0]), matrix4D.TransformTo3D(point2DList[triangle.I1]), matrix4D.TransformTo3D(point2DList[triangle.I2])));
         }
     }
 }
Пример #8
0
        public override void DrawInternal(
            DrawContext.Surface context,
            ISurfaceGraphicsFactory graphicsFactory)
        {
            DxfImageDef imageDef = this.ImageDef;

            if (imageDef == null || !imageDef.Bitmap.IsValid)
            {
                return;
            }
            List <WW.Math.Point2D> clipBoundary = (List <WW.Math.Point2D>) this.GetClipBoundary((DrawContext)context);

            if (clipBoundary == null || clipBoundary.Count <= 0)
            {
                return;
            }
            List <Triangulator2D.Triangle> triangleList = new List <Triangulator2D.Triangle>();
            List <WW.Math.Point2D>         point2DList  = new List <WW.Math.Point2D>();

            Triangulator2D.Triangulate((IList <IList <WW.Math.Point2D> >) new List <WW.Math.Point2D>[1]
            {
                clipBoundary
            }, (IList <Triangulator2D.Triangle>)triangleList, (IList <WW.Math.Point2D>)point2DList);
            Interface41 nterface41   = (Interface41)context.GetTransformer().Clone();
            Matrix4D    preTransform = this.method_15();

            nterface41.SetPreTransform(preTransform);
            WW.Math.Point2D[] point2DArray        = new WW.Math.Point2D[point2DList.Count];
            Vector4D[]        vector4DArray       = new Vector4D[point2DList.Count];
            Size2D            referencedImageSize = this.ReferencedImageSize;
            double            num1     = 1.0 / referencedImageSize.X;
            double            num2     = 1.0 / referencedImageSize.Y;
            Vector2D          vector2D = new Vector2D(0.5, 0.5);

            for (int index = point2DList.Count - 1; index >= 0; --index)
            {
                WW.Math.Point2D point2D = point2DList[index] + vector2D;
                point2DArray[index]  = new WW.Math.Point2D(num1 * point2D.X, 1.0 - num2 * point2D.Y);
                vector4DArray[index] = nterface41.Transform(new WW.Math.Point3D(point2D.X, point2D.Y, 0.0));
            }
            byte[] rgbaBytes = imageDef.Bitmap.GetRgbaBytes();
            graphicsFactory.CreateTexturedTriangles(rgbaBytes, imageDef.Bitmap.Width, imageDef.Bitmap.Height, preTransform.Transform(WW.Math.Vector3D.ZAxis), (IList <Triangulator2D.Triangle>)triangleList, (IList <WW.Math.Point2D>)point2DArray, (IList <Vector4D>)vector4DArray);
        }
Пример #9
0
        Polygon CreateRoughPlane(float tileSize = 5f, int numTiles = 10)
        {
            var half     = (tileSize * numTiles) / 2;
            var offset   = new Vector3(-half, -half, 0f);
            var vertices = new List <Vector3>();

            foreach (var i in Enumerable.Range(0, numTiles))
            {
                foreach (var j in Enumerable.Range(0, numTiles))
                {
                    var noise = Random.insideUnitSphere * tileSize / 2;
                    vertices.Add(offset + new Vector3(tileSize * i + noise.x, tileSize * j + noise.y, noise.z));
                }
            }
            var polygon = new Polygon2D(
                new GameObject("Rough Plane"),
                Triangulator2D.Triangulate(vertices)
                ).Build();

            polygon.gameObject.transform.Rotate(new Vector3(-90, 0, 0));
            return(polygon);
        }
Пример #10
0
        internal Class454(IShape2D shape, GraphicsConfig config)
        {
            IList <Polyline2D> flattened = (IList <Polyline2D>)ShapeTool.GetFlattened(shape, config.ShapeFlattenEpsilon);

            if (flattened != null)
            {
                IList <Polygon2D> input1        = (IList <Polygon2D>) new List <Polygon2D>(flattened.Count);
                IList <Polygon2D> polygon2DList = (IList <Polygon2D>) new List <Polygon2D>();
                for (int index = 0; index < flattened.Count; ++index)
                {
                    Polygon2D polygon2D = new Polygon2D((IEnumerable <Point2D>)flattened[index]);
                    if (polygon2D.IsClockwise())
                    {
                        polygon2DList.Add(polygon2D);
                    }
                    else if (input1.Count == 0)
                    {
                        input1.Add(polygon2D);
                    }
                    else
                    {
                        input1 = (IList <Polygon2D>)Polygon2D.GetUnion(input1, (IList <Polygon2D>) new Polygon2D[1]
                        {
                            polygon2D
                        });
                    }
                }
                List <IList <Point2D> > point2DListList = new List <IList <Point2D> >(input1.Count + polygon2DList.Count);
                point2DListList.AddRange((IEnumerable <IList <Point2D> >)input1);
                point2DListList.AddRange((IEnumerable <IList <Point2D> >)polygon2DList);
                Triangulator2D.Triangulate((IList <IList <Point2D> >)point2DListList, (IList <Triangulator2D.Triangle>) this.list_0, (IList <Point2D>) this.list_1);
            }
            else
            {
                this.list_0 = (List <Triangulator2D.Triangle>)null;
                this.list_1 = (List <Point2D>)null;
            }
        }
Пример #11
0
    void Start()
    {
        //根据精确度,把圆描述成周长上的点
        //已知角度m,圆上点的坐标分别是(r*cos,r*sin)
        Vector2[] vertices2D = new Vector2[this.accuracy];
        for (int i = 0; i < this.accuracy; i++)
        {
            float angle = 2 * Mathf.PI / this.accuracy * i;
            vertices2D[i] = new Vector2(this.radius * Mathf.Cos(angle), this.radius * Mathf.Sin(angle));
        }


        //2D多边形割三角形算法,来源http://wiki.unity3d.com/index.php/Triangulator
        Triangulator2D tr = new Triangulator2D(vertices2D);

        int[] indices = tr.Triangulate();

        //映射到三维空间当中的点
        Vector3[] vertices = new Vector3[vertices2D.Length];
        for (int i = 0; i < vertices.Length; i++)
        {
            vertices[i] = new Vector3(vertices2D[i].x, vertices2D[i].y, 0);
        }

        //创建Mesh
        Mesh msh = new Mesh();

        msh.vertices  = vertices;
        msh.triangles = indices;

        //设置Mesh
        gameObject.AddComponent <MeshRenderer>();
        MeshFilter filter = gameObject.AddComponent <MeshFilter>();

        filter.mesh = msh;
    }
Пример #12
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));
                    }
                }
            }
        }
 public RelativeAreaResolver(double relativeAreaTolerance = 1E-4, double zeroDistanceTolerance = 1E-10)
 {
     this.relativeAreaTolerance = relativeAreaTolerance;
     this.zeroDistanceTolerance = zeroDistanceTolerance;
     this.triangulator          = new Triangulator2D <CartesianPoint>((x, y) => new CartesianPoint(x, y));
 }
Пример #14
0
 public HeavisideResolverOLD(double relativeAreaTolerance = 1e-4)
 {
     this.relativeAreaTolerance = relativeAreaTolerance;
     this.triangulator          = new Triangulator2D <CartesianPoint>((x, y) => new CartesianPoint(x, y));
 }
Пример #15
0
 public override bool ContainsPoint(Vector2 point)
 {
     return(Triangulator2D.IsPointInShape(point, _properties.WorldPoints.ToArray( )));
 }
Пример #16
0
 public static void smethod_20(
     DxfEntity entity,
     DrawContext.Surface context,
     ISurfaceGraphicsFactory graphicsFactory,
     Polyline4D boundary,
     List <bool> edgeVisibleList)
 {
     if (boundary.Count == 0)
     {
         return;
     }
     if (boundary.Count == 1)
     {
         graphicsFactory.CreatePoint(boundary[0]);
     }
     else if (boundary.Count == 2)
     {
         bool flag = true;
         if (edgeVisibleList.Count != 0 && !edgeVisibleList[0])
         {
             flag = false;
         }
         if (!flag)
         {
             return;
         }
         graphicsFactory.CreateSegment(boundary[0], boundary[1]);
     }
     else if (boundary.Count == 3)
     {
         bool[] flagArray = (bool[])null;
         if (edgeVisibleList != null)
         {
             flagArray = edgeVisibleList.ToArray();
         }
         graphicsFactory.CreateTriangle(boundary[0], boundary[1], boundary[2], (IList <bool>)flagArray);
     }
     else if (boundary.Count == 4)
     {
         bool[] flagArray = (bool[])null;
         if (edgeVisibleList != null)
         {
             flagArray = edgeVisibleList.ToArray();
         }
         graphicsFactory.CreateQuad((IList <Vector4D>)boundary.ToArray(), (IList <bool>)flagArray);
     }
     else
     {
         int       count     = boundary.Count;
         Polygon3D polygon3D = new Polygon3D(count);
         for (int index = 0; index < count; ++index)
         {
             polygon3D.Add((WW.Math.Point3D)boundary[index]);
         }
         Plane3D?plane = polygon3D.GetPlane();
         if (!plane.HasValue)
         {
             return;
         }
         Matrix4D  matrix4D     = Transformation4D.Translation(plane.Value.Distance * plane.Value.Normal) * Transformation4D.GetArbitraryCoordSystem(plane.Value.Normal);
         Matrix4D  inverse      = matrix4D.GetInverse();
         Polygon2D projection2D = polygon3D.GetProjection2D(inverse);
         List <Triangulator2D.Triangle> triangleList = new List <Triangulator2D.Triangle>();
         List <WW.Math.Point2D>         point2DList  = new List <WW.Math.Point2D>();
         Triangulator2D.Triangulate((IList <IList <WW.Math.Point2D> >) new Polygon2D[1]
         {
             projection2D
         }, (IList <Triangulator2D.Triangle>)triangleList, (IList <WW.Math.Point2D>)point2DList);
         foreach (Triangulator2D.Triangle triangle in triangleList)
         {
             graphicsFactory.CreateTriangle(matrix4D.TransformTo4D(point2DList[triangle.I0]), matrix4D.TransformTo4D(point2DList[triangle.I1]), matrix4D.TransformTo4D(point2DList[triangle.I2]), (IList <bool>)null);
         }
     }
 }
Пример #17
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);
                    }
                }
            }
        }