internal static Polygon3D ToPolygon3D(IPolyLine2D outline, IMatrix44 lcs) { /// pozor - konvertuje pouze koncove body - tzn. zadne obloucky var count = outline.Segments.Count; var polygon = new Polygon3D(count + 1); var point = outline.StartPoint; var point3D = lcs.TransformToGCS(new WM.Point3D(0, point.X, point.Y)); polygon.Add(point3D); for (var i = 0; i < count; ++i) { point = outline.Segments[i].EndPoint; point3D = lcs.TransformToGCS(new WM.Point3D(0, point.X, point.Y)); polygon.Add(point3D); } return(polygon); }
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]))); } } }
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); } } }
public virtual void vmethod_2(Class95 firstLoop, Class608 wires) { Interface26 pointParamMapper = this.PointParamMapper; if (pointParamMapper != null) { List <Polygon2D> polygon2DList1 = new List <Polygon2D>(); List <Polygon2D> polygon2DList2 = new List <Polygon2D>(); foreach (Class95 loop in (IEnumerable <Class95>)Class80.smethod_0 <Class95>(firstLoop)) { Class917 approximation = new Class917(); Polygon2D polygon2D1 = new Polygon2D(); foreach (ns9.Class107 coedge in (IEnumerable <ns9.Class107>)loop.Coedges) { ns9.Class88 curve = (ns9.Class88)coedge.Edge.Curve; if (curve != null) { curve.CurvePrimitive.imethod_3(loop, curve, coedge, approximation, wires.Accuracy); } else { Polyline2D polyline2D = this.vmethod_1(coedge); polygon2D1.AddRange((IEnumerable <Point2D>)polyline2D); } } if (polygon2D1.Count > 0) { if (pointParamMapper.IsRightHandedParametric) { if (polygon2D1.GetArea() >= 0.0) { polygon2DList1.Add(polygon2D1); } else { polygon2DList2.Add(polygon2D1); } } else if (polygon2D1.GetArea() < 0.0) { polygon2DList1.Add(polygon2D1); } else { polygon2DList2.Add(polygon2D1); } } Point3D[] points = approximation.Points; if (points.Length > 0) { Polygon2D polygon2D2 = new Polygon2D(points.Length); foreach (Point3D point in points) { polygon2D2.Add(pointParamMapper.imethod_0(point)); } if (pointParamMapper.IsRightHandedParametric) { if (polygon2D2.GetArea() >= 0.0) { polygon2DList1.Add(polygon2D2); } else { polygon2DList2.Add(polygon2D2); } } else if (polygon2D2.GetArea() < 0.0) { polygon2DList1.Add(polygon2D2); } else { polygon2DList2.Add(polygon2D2); } } } if (polygon2DList1.Count == 0 && polygon2DList2.Count != 0) { foreach (List <Point2D> point2DList in polygon2DList2) { point2DList.Reverse(); } polygon2DList1.AddRange((IEnumerable <Polygon2D>)polygon2DList2); polygon2DList2.Clear(); } Polygon2D[] paramShape = Class794.smethod_9(this.ExtendedIntervalU, this.ExtendedIntervalV, polygon2DList1.ToArray(), polygon2DList2.ToArray(), pointParamMapper.IsRightHandedParametric, wires.Accuracy.Epsilon); if (paramShape == null) { return; } foreach (Polygon2D polygon2D in paramShape) { Polygon3D polygon3D = new Polygon3D(polygon2D.Count); foreach (Point2D point2D in (List <Point2D>)polygon2D) { polygon3D.Add(pointParamMapper.imethod_1(point2D.X, point2D.Y)); } wires.method_9((ICollection <Point3D>)polygon3D, true); } this.vmethod_0(wires, paramShape, pointParamMapper); } else { Class80.smethod_2((Class80)firstLoop, wires); } }