public void Paint(RenderingContext renderingContext, int width, int height) { if (renderingContext == null) { return; } renderingContext.MakeCurrent(); if (this.bool_0) { GL.glMatrixMode(MatrixMode.Projection); GL.glClear(ClearBufferFlags.AccumBuffer); int length = this.vector2D_0.Length; Matrix4D parameters; GL.glGetDoublev_1(GetTarget.ProjectionMatrix, out parameters); for (int index = 0; index < length; ++index) { GL.glClear(ClearBufferFlags.ColorBuffer | ClearBufferFlags.DepthBuffer); Vector2D vector2D = this.vector2D_0[index]; Matrix4D m = Transformation4D.Translation(vector2D.X / (double)width, vector2D.Y / (double)height, 0.0) * parameters; GL.glLoadMatrixd_1(ref m); this.DrawSceneHelper(); GL.glAccum(index > 0 ? AccumulationOperation.Accumulate : AccumulationOperation.Load, 1f / (float)length); GL.glAccum(AccumulationOperation.Return, 1f); } GL.glLoadMatrixd_1(ref parameters); } else { GL.glClear(ClearBufferFlags.ColorBuffer | ClearBufferFlags.DepthBuffer); this.DrawSceneHelper(); } GL.glFlush(); WGL.wglSwapBuffers(renderingContext.HDC); }
public static Point3D?GetCentroid(IList <Point3D> polygon, out Plane3D?plane) { int count = polygon.Count; Point3D point3D1 = polygon[0]; if (count < 3) { plane = new Plane3D?(); switch (count) { case 0: return(new Point3D?()); case 1: return(new Point3D?(polygon[0])); case 2: Point3D point3D2 = polygon[0]; return(new Point3D?(new Point3D(0.5 * (point3D1.X + point3D2.X), 0.5 * (point3D1.Y + point3D2.Y), 0.5 * (point3D1.Z + point3D2.Z)))); } } plane = Polygon3D.GetPlane(polygon); if (!plane.HasValue) { return(new Point3D?()); } Matrix4D matrix4D = Transformation4D.Translation(point3D1.X, point3D1.Y, point3D1.Z) * Transformation4D.GetArbitraryCoordSystem(plane.Value.Normal); Matrix4D inverse = matrix4D.GetInverse(); Point2D point2D = Polygon3D.GetProjection2D(polygon, inverse).GetCentroid().Value; return(new Point3D?(matrix4D.Transform(new Point3D(point2D.X, point2D.Y, 0.0)))); }
private void DrawInternal(IPathDrawer pathDrawer, Color color, short lineWeight) { DxfTolerance.Class397[] class397Array = this.method_13(); Matrix4D transform = this.Transform; Vector3D zero = Vector3D.Zero; double num1 = this.dxfDimensionStyleOverrides_0.TextHeight * 2.0; double scale = this.dxfDimensionStyleOverrides_0.ScaleFactor; if (System.Math.Abs(scale) < 1E-10) { scale = 1.0; } if (this.IsAnnotative) { scale /= DxfAnnotationScaleObjectContextData.smethod_9((DxfEntity)this, this.Model.Header.CurrentAnnotationScale); } double num2 = num1 * scale; foreach (DxfTolerance.Class397 class397 in class397Array) { double num3 = class397.Draw(this, pathDrawer, transform * Transformation4D.Translation(zero), color, lineWeight, scale); if (class397.NewLineAfterField) { zero.X = 0.0; zero.Y -= num2; } else { zero.X += num3; } } }
internal Matrix4D method_14() { Matrix4D toWcsTransform = DxfUtil.GetToWCSTransform(this.vector3D_0); toWcsTransform.Transpose(); Matrix4D matrix4D1 = Transformation4D.RotateZ(this.double_6) * toWcsTransform; Matrix4D matrix4D2; Matrix4D matrix4D3; Matrix4D matrix4D4; if (this.PerspectiveMode) { double num1 = Class484.smethod_0(this.size2D_0, this.double_1, this.double_4); matrix4D2 = this.method_24(); matrix4D3 = new Matrix4D(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0 / this.double_1, 0.0, 0.0, -1.0 / this.double_1, 0.0) * Transformation4D.Translation(0.0, 0.0, -num1); double num2 = System.Math.Sqrt(this.size2D_0.X * this.size2D_0.X + this.size2D_0.Y * this.size2D_0.Y) / 42.0; matrix4D4 = Transformation4D.Scaling(num2, num2, 1.0); } else { matrix4D2 = this.method_25(); matrix4D3 = Matrix4D.Identity; double num = this.size2D_0.Y / this.double_4; matrix4D4 = Transformation4D.Scaling(num, num, 1.0); } Matrix4D matrix4D5 = Transformation4D.Translation(-this.point2D_0.X, -this.point2D_0.Y, 0.0); return(matrix4D2 * matrix4D4 * matrix4D5 * matrix4D3 * matrix4D1 * Transformation4D.Translation(-(WW.Math.Vector3D) this.point3D_1)); }
public static Matrix4D GetBoundsToScreenTransform( Bounds2D bounds, int width, int height) { return(Transformation4D.GetBoundsToScreenTransform(bounds, width, height, 0)); }
private void method_15( DrawContext.Wireframe context, Bitmap bitmap, out DxfRasterImage rasterImage, out Vector4D transformedOrigin, out Vector4D transformedXAxis, out Vector4D transformedYAxis) { GdiBitmap gdiBitmap = new GdiBitmap(bitmap); rasterImage = (DxfRasterImage) new DxfImage(); DxfImageDef imageDef = new DxfImageDef(context.Model); imageDef.SetBitmap((IBitmap)gdiBitmap); rasterImage.SetImageDef(imageDef, true); IClippingTransformer clippingTransformer = (IClippingTransformer)context.GetTransformer().Clone(); Matrix4D preTransform1 = Transformation4D.Translation((WW.Math.Vector3D) this.point3D_3); clippingTransformer.SetPreTransform(preTransform1); Matrix4D preTransform2 = Transformation4D.Scaling((this.point3D_2 - this.point3D_3).GetLength() / (double)bitmap.Width, (this.point3D_0 - this.point3D_3).GetLength() / (double)bitmap.Height, 1.0); clippingTransformer.SetPreTransform(preTransform2); Matrix4D matrix = clippingTransformer.Matrix; WW.Math.Point3D zero = WW.Math.Point3D.Zero; transformedOrigin = matrix.TransformTo4D(zero); transformedXAxis = matrix.TransformTo4D(zero + WW.Math.Vector3D.XAxis); transformedYAxis = matrix.TransformTo4D(zero + WW.Math.Vector3D.YAxis); }
public Matrix4D CalculateTo2DTransform1() { Matrix4D to2DTransform = Matrix4D.Identity; if (model != null && bounds != null) { double halfHeight = ImageControl.ClientSize.Height / 2; double halfWidth = ImageControl.ClientSize.Width / 2; double margin = 5d; // 5 pixels margin on each size. to2DTransform = Transformation4D.Translation(translation) * Transformation4D.Translation(halfWidth, halfHeight, 0) * Transformation4D.Scaling(scaleFactor) * DxfUtil.GetScaleTransform( bounds.Corner1, bounds.Corner2, bounds.Center, new Point3D(margin, ImageControl.ClientSize.Height - margin, 0d), new Point3D(ImageControl.ClientSize.Width - margin, margin, 0d), Point3D.Zero ); } gdiGraphics3D.To2DTransform = to2DTransform * modelTransform; from2DTransform = gdiGraphics3D.To2DTransform.GetInverse(); return(to2DTransform); }
public static Matrix4D GetBoundsToScreenTransform( Point2D min, Point2D max, int width, int height) { return(Transformation4D.GetBoundsToScreenTransform(min, max, width, height, 0)); }
private Matrix4D method_24() { double num1 = Class484.smethod_0(this.size2D_0, this.double_1, this.double_4); double num2 = this.double_3 - num1; double num3 = this.double_2 - num1; double num4 = this.bool_6 ? 1.0 / num2 : 0.0; return(Transformation4D.Scaling(1.0 / this.size2D_0.X, 1.0 / this.size2D_0.Y, !this.bool_5 ? -1.0 : 1.0 / (1.0 / num3 - num4)) * Transformation4D.Translation(this.size2D_0.X * 0.5, this.size2D_0.Y * 0.5, -num4)); }
public static Matrix4D GetBoundsToScreenTransform( Point2D min, Point2D max, int width, int height, int margin) { return(Transformation4D.GetBoundsToScreenTransform(min.X, min.Y, max.X, max.Y, width, height, margin)); }
public Matrix4D GetTransform(Size2D targetSize) { Matrix4D toWcsTransform = DxfUtil.GetToWCSTransform(this.vector3D_0); toWcsTransform.Transpose(); Matrix4D matrix4D = Transformation4D.RotateZ(this.double_6) * toWcsTransform; return(Transformation4D.Translation(this.point2D_2.X, this.point2D_2.Y, 0.0) * (!this.PerspectiveMode ? Matrix4D.Identity : new Matrix4D(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0 / this.double_2, 0.0, 0.0, -1.0 / this.double_2, 0.0) * Transformation4D.Translation(0.0, 0.0, -Class484.smethod_0(new Size2D(targetSize.X * this.double_1, targetSize.Y), this.double_2, this.double_0))) * matrix4D * Transformation4D.Translation(-this.point3D_0.X, -this.point3D_0.Y, -this.point3D_0.Z)); }
public static void GetScaleToIntegralTransforms( Bounds2D bounds, long maxTargetCoordinate, out Matrix4D scaleTransform, out Matrix4D inverseScaleTransform) { scaleTransform = Transformation4D.GetScaleAndTranslateTransform(bounds.Min, bounds.Max, new Point2D((double)-maxTargetCoordinate + 0.5, (double)-maxTargetCoordinate + 0.5), new Point2D((double)maxTargetCoordinate + 0.5, (double)maxTargetCoordinate + 0.5)); inverseScaleTransform = Transformation4D.GetScaleAndTranslateTransform(new Point2D((double)-maxTargetCoordinate, (double)-maxTargetCoordinate), new Point2D((double)maxTargetCoordinate, (double)maxTargetCoordinate), bounds.Min, bounds.Max); }
public Matrix4D GetTransform() { Matrix4D toWcsTransform = DxfUtil.GetToWCSTransform(this.vector3D_0); toWcsTransform.Transpose(); Matrix4D matrix4D = Transformation4D.RotateZ(this.double_3) * toWcsTransform; return((!this.PerspectiveMode ? Matrix4D.Identity : new Matrix4D(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0 / this.double_0, 0.0, 0.0, -1.0 / this.double_0, 0.0) * Transformation4D.Translation(0.0, 0.0, -this.vector3D_0.GetLength())) * Transformation4D.Translation(-this.point2D_0.X, -this.point2D_0.Y, 0.0) * matrix4D * Transformation4D.Translation(-(Vector3D)this.point3D_0)); }
private void DrawInternal(DxfInsert.Interface46 drawHandler, bool drawBlock) { Matrix4D toWcsTransform = DxfUtil.GetToWCSTransform(this.ZAxis); Matrix4D matrix4D1 = Transformation4D.Translation((WW.Math.Vector3D) this.InsertionPoint); Matrix4D matrix4D2 = Transformation4D.RotateZ(this.Rotation); Matrix4D matrix4D3 = Transformation4D.Scaling(this.ScaleFactor); ushort num1 = this.RowCount; if (num1 < (ushort)1) { num1 = (ushort)1; } ushort num2 = this.ColumnCount; if (num2 < (ushort)1) { num2 = (ushort)1; } for (int row = 0; row < (int)num1; ++row) { for (int column = 0; column < (int)num2; ++column) { if (drawBlock) { Matrix4D matrix4D4 = toWcsTransform * matrix4D1 * matrix4D2 * Transformation4D.Translation((double)column * this.ColumnSpacing, (double)row * this.RowSpacing, 0.0) * matrix4D3; drawHandler.imethod_0(row, column, matrix4D4); if (this.Block != null) { switch (this.method_16(matrix4D4, drawHandler)) { case DxfInsert.Enum44.const_1: case DxfInsert.Enum44.const_2: drawHandler.Draw(this.Block, true); break; case DxfInsert.Enum44.const_3: drawHandler.Draw(this.Block, true); drawHandler.InsertCellDrawContext.vmethod_1(); break; } } } if (this.Attributes.Count > 0) { WW.Math.Vector3D vector = new WW.Math.Vector3D((double)column * this.ColumnSpacing, (double)row * this.RowSpacing, 0.0); vector = (toWcsTransform * matrix4D2).Transform(vector); Matrix4D instanceTransform = Transformation4D.Translation(vector.X, vector.Y, vector.Z); drawHandler.imethod_1(row, column, instanceTransform); foreach (DxfAttribute attribute in (IEnumerable <DxfAttribute>) this.Attributes) { drawHandler.Draw(attribute); } } } } }
public static Matrix4D GetBoundsToScreenTransform( double minX, double minY, double maxX, double maxY, int width, int height) { return(Transformation4D.GetBoundsToScreenTransform(minX, minY, maxX, maxY, width, height, 0)); }
public void DrawPath( IShape2D path, Matrix4D transform, Color color, short lineWeight, bool filled, bool forText, double extrusion) { if (!path.HasSegments) { return; } IClippingTransformer transformer = (IClippingTransformer)this.wireframe_0.GetTransformer().Clone(); transformer.SetPreTransform(transform); if (extrusion == 0.0) { IShape4D shape1 = (IShape4D) new FlatShape4D(path, filled); IShape4D shape2 = transformer.Transform(shape1); if (shape2.IsEmpty) { return; } this.iwireframeGraphicsFactory2_0.BeginGeometry(this.dxfEntity_0, this.wireframe_0, this.wireframe_0.GetPlotColor(this.dxfEntity_0, color), false, filled, !filled, true); this.iwireframeGraphicsFactory2_0.CreateShape(this.dxfEntity_0, shape2); this.iwireframeGraphicsFactory2_0.EndGeometry(); } else { IList <Polyline2D> flattened = (IList <Polyline2D>)ShapeTool.GetFlattened(path, this.wireframe_0.Config.ShapeFlattenEpsilon); IList <Polyline4D> polylines1 = DxfUtil.smethod_39(flattened, filled, transformer); ArgbColor plotColor = this.wireframe_0.GetPlotColor(this.dxfEntity_0, color); Class940.smethod_3(this.dxfEntity_0, this.wireframe_0, this.iwireframeGraphicsFactory2_0, plotColor, forText, false, true, polylines1); transformer.SetPreTransform(Transformation4D.Translation(0.0, 0.0, extrusion)); IList <Polyline4D> polylines2 = DxfUtil.smethod_39(flattened, filled, transformer); Class940.smethod_3(this.dxfEntity_0, this.wireframe_0, this.iwireframeGraphicsFactory2_0, plotColor, forText, false, true, polylines2); Polyline4D polyline4D1 = new Polyline4D(2); polyline4D1.Add(Vector4D.Zero); polyline4D1.Add(Vector4D.Zero); IList <Polyline4D> polylines3 = (IList <Polyline4D>) new List <Polyline4D>(1); polylines3.Add(polyline4D1); for (int index1 = polylines1.Count - 1; index1 >= 0; --index1) { Polyline4D polyline4D2 = polylines1[index1]; Polyline4D polyline4D3 = polylines2[index1]; for (int index2 = polyline4D2.Count - 1; index2 >= 0; --index2) { polyline4D1[0] = polyline4D2[index2]; polyline4D1[1] = polyline4D3[index2]; Class940.smethod_2(this.dxfEntity_0, this.wireframe_0, this.iwireframeGraphicsFactory2_0, plotColor, forText, false, true, polylines3); } } } }
public static Matrix4D GetBoundsToScreenTransform( double minX, double minY, double maxX, double maxY, int width, int height, int margin) { return(Transformation4D.GetScaleTransform(new Point3D(minX, minY, 0.0), new Point3D(maxX, maxY, 0.0), new Point3D(0.5 * (minX + maxX), 0.5 * (minY + maxY), 0.0), new Point3D((double)margin, (double)(height - 1 - margin), 0.0), new Point3D((double)(width - 1 - margin), (double)margin, 0.0), new Point3D(0.5 * (double)(width - 1), 0.5 * (double)(height - 1), 0.0))); }
public static Matrix4D GetScaleTransform( Point3D fromPoint1, Point3D fromPoint2, Point3D fromReferencePoint, Point3D toPoint1, Point3D toPoint2, Point3D toReferencePoint) { double scaling; return(Transformation4D.GetScaleTransform(fromPoint1, fromPoint2, fromReferencePoint, toPoint1, toPoint2, toReferencePoint, out scaling)); }
public static Matrix4D GetBoundsToScreenTransform( Bounds2D bounds, int width, int height, int margin) { if (!bounds.Initialized) { return(Matrix4D.Identity); } return(Transformation4D.GetBoundsToScreenTransform(bounds.Min, bounds.Max, width, height, margin)); }
public static Matrix4D GetBasicModelToViewportTransform(IViewDescription view) { Matrix4D matrix4D1 = view.IsTargetPaper ? Transformation4D.Translation(-view.ViewCenter.X, -view.ViewCenter.Y, 0.0) : Transformation4D.Translation(-view.ViewCenter.X, -view.ViewCenter.Y, -view.ViewDirection.GetLength()) * Transformation4D.RotateZ(view.ViewTwistAngle) * DxfUtil.GetToWCSTransform(view.ViewDirection).GetTranspose() * Transformation4D.Translation(-(Vector3D)view.ViewTarget); if ((view.ViewModeFlags & ViewportStatusFlags.PerspectiveMode) != ViewportStatusFlags.None) { double num1 = 1.0 / System.Math.Tan(0.5 * (2.0 * System.Math.Atan(18.0 / view.FocalLength))); double num2 = 0.5 * view.ViewWidth; Matrix4D matrix4D2 = new Matrix4D(num2, 0.0, 0.0, 0.0, 0.0, num2, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0, 0.0); matrix4D1 = Transformation4D.Scaling(num1, num1, 1.0) * matrix4D2 * matrix4D1; } return(matrix4D1); }
public static Matrix4D GetTransform( IViewDescription view, Rectangle2D targetRectangle, bool invertY) { Matrix4D viewportTransform = ViewUtil.GetBasicModelToViewportTransform(view); double num = System.Math.Min(targetRectangle.Width * view.ViewportWidth / view.ViewWidth, targetRectangle.Height * view.ViewportHeight / view.ViewHeight); double x = targetRectangle.Center.X + (view.ViewportCenter.X - 0.5) * targetRectangle.Width; double y1 = targetRectangle.Center.Y; double y2 = !invertY ? y1 + (view.ViewportCenter.Y - 0.5) * targetRectangle.Height : y1 - (view.ViewportCenter.Y - 0.5) * targetRectangle.Height; return(Transformation4D.Translation(x, y2, 0.0) * Transformation4D.Scaling(num, invertY ? -num : num, num) * viewportTransform); }
public static Matrix4D GetScaleAndTranslateTransform( Point2D fromP1, Point2D fromP2, Point2D toP1, Point2D toP2) { double x = (toP2.X - toP1.X) / (fromP2.X - fromP1.X); double y = (toP2.Y - toP1.Y) / (fromP2.Y - fromP1.Y); Point2D midPoint1 = Point2D.GetMidPoint(toP1, toP2); Point2D midPoint2 = Point2D.GetMidPoint(fromP1, fromP2); return(Transformation4D.Translation(midPoint1.X, midPoint1.Y, 0.0) * Transformation4D.Scaling(x, y, 1.0) * Transformation4D.Translation(-midPoint2.X, -midPoint2.Y, 0.0)); }
public Vector3D Draw(IPathDrawer drawer, Matrix4D transformation, double extrusion) { Matrix4D matrix4D = Matrix4D.Multiply(transformation, this.matrix2D_0); Vector2D zero = Vector2D.Zero; Matrix4D transform = matrix4D; foreach (Interface35 nterface35 in this.interface35_0) { drawer.DrawPath(nterface35.Path, transform, this.color_0, this.short_0, this.Filled, true, extrusion); zero += nterface35.Advance; transform = matrix4D * Transformation4D.Translation(new Vector3D(zero.X * this.double_0, zero.Y, 0.0)); } return((Vector3D)transform.TransformTo3D((WW.Math.Point2D) this.vector2D_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]))); } } }
public void DrawPath( IShape2D path, Matrix4D transform, Color color, short lineWeight, bool filled, bool forText, double extrusion) { if (!path.HasSegments) { return; } IClippingTransformer transformer = (IClippingTransformer)this.wireframe_0.GetTransformer().Clone(); transformer.SetPreTransform(transform); IWireframeGraphicsFactory graphicsFactory0 = this.iwireframeGraphicsFactory_0; if (extrusion == 0.0) { IShape4D shape1 = (IShape4D) new FlatShape4D((IShape2D)(path as GeneralShape2D ?? new GeneralShape2D(path, true)), filled); IShape4D shape2 = transformer.Transform(shape1); if (shape2.IsEmpty) { return; } graphicsFactory0.CreateShape(this.dxfEntity_0, this.wireframe_0, this.wireframe_0.GetPlotColor(this.dxfEntity_0, color), forText, shape2); } else { IList <Polyline2D> flattened = (IList <Polyline2D>)ShapeTool.GetFlattened(path, this.wireframe_0.Config.ShapeFlattenEpsilon); IList <Polyline4D> polylines1 = DxfUtil.smethod_39(flattened, filled, transformer); ArgbColor plotColor = this.wireframe_0.GetPlotColor(this.dxfEntity_0, color); graphicsFactory0.CreatePathAsOne(this.dxfEntity_0, this.wireframe_0, plotColor, forText, polylines1, false, true); transformer.SetPreTransform(Transformation4D.Translation(0.0, 0.0, extrusion)); IList <Polyline4D> polylines2 = DxfUtil.smethod_39(flattened, filled, transformer); graphicsFactory0.CreatePathAsOne(this.dxfEntity_0, this.wireframe_0, plotColor, forText, polylines2, false, true); for (int index1 = polylines1.Count - 1; index1 >= 0; --index1) { Polyline4D polyline4D1 = polylines1[index1]; Polyline4D polyline4D2 = polylines2[index1]; for (int index2 = polyline4D1.Count - 1; index2 >= 0; --index2) { graphicsFactory0.CreateLine(this.dxfEntity_0, this.wireframe_0, plotColor, forText, polyline4D1[index2], polyline4D2[index2]); } } } }
internal static Matrix4D smethod_6( ILeader leader, IList <WW.Math.Point3D> vertices, Vector3D zaxis) { WW.Math.Point3D vertex1 = vertices[0]; WW.Math.Point3D vertex2 = vertices[1]; Matrix4D toWcsTransform = DxfUtil.GetToWCSTransform(zaxis); Vector3D v1 = new Vector3D(toWcsTransform.M00, toWcsTransform.M10, toWcsTransform.M20); Vector3D v2 = new Vector3D(toWcsTransform.M01, toWcsTransform.M11, toWcsTransform.M21); Vector3D u = vertex1 - vertex2; double angle = System.Math.Atan2(Vector3D.DotProduct(u, v2), Vector3D.DotProduct(u, v1)); double effectiveArrowSize = leader.GetEffectiveArrowSize(); return(Transformation4D.Translation((Vector3D)vertex1) * toWcsTransform * Transformation4D.RotateZ(angle) * Transformation4D.Scaling(effectiveArrowSize, effectiveArrowSize, effectiveArrowSize)); }
public static Matrix4D GetArbitraryCoordSystem(Vector3D zaxis) { Vector3D xaxis; if (System.Math.Abs(zaxis.X) > System.Math.Abs(zaxis.Y)) { double num = 1.0 / System.Math.Sqrt(zaxis.X * zaxis.X + zaxis.Z * zaxis.Z); xaxis = new Vector3D(-zaxis.Z * num, 0.0, zaxis.X * num); } else { double num = 1.0 / System.Math.Sqrt(zaxis.Y * zaxis.Y + zaxis.Z * zaxis.Z); xaxis = new Vector3D(0.0, zaxis.Z * num, -zaxis.Y * num); } return(Transformation4D.smethod_0(xaxis, zaxis)); }
private DxfLayout.PlotInfo GetPlotInfo( bool invertY, DxfLayout.BasicLayoutRenderInfo layoutRenderInfo) { Size2D plotPaperSize = this.PlotPaperSize; if (plotPaperSize.X == 0.0 || plotPaperSize.Y == 0.0) { return((DxfLayout.PlotInfo)null); } double y = invertY ? this.UnprintableMarginBottom : plotPaperSize.Y - this.UnprintableMarginTop; WW.Math.Point3D toPoint1 = new WW.Math.Point3D(this.UnprintableMarginLeft, invertY ? plotPaperSize.Y - this.UnprintableMarginTop : this.UnprintableMarginBottom, 0.0); WW.Math.Point3D toPoint2 = new WW.Math.Point3D(plotPaperSize.X - this.UnprintableMarginRight, y, 0.0); WW.Math.Point3D toReferencePoint = new WW.Math.Point3D(0.5 * (toPoint1.X + toPoint2.X), 0.5 * (toPoint1.Y + toPoint2.Y), 0.0); Matrix4D matrix4D1 = Matrix4D.Identity; switch (this.PlotRotation) { case PlotRotation.QuarterCounterClockwise: matrix4D1 = Transformation4D.RotateZ(System.Math.PI / 2.0); break; case PlotRotation.Half: matrix4D1 = Transformation4D.RotateZ(System.Math.PI); break; case PlotRotation.QuarterClockwise: matrix4D1 = Transformation4D.RotateZ(-1.0 * System.Math.PI / 2.0); break; } if (invertY) { matrix4D1 *= Transformation4D.Scaling(1.0, -1.0, 1.0); } WW.Math.Point3D point3D1 = new WW.Math.Point3D(layoutRenderInfo.LayoutViewport.Min, 0.0); WW.Math.Point3D point3D2 = new WW.Math.Point3D(layoutRenderInfo.LayoutViewport.Max, 0.0); WW.Math.Point3D fromReferencePoint = new WW.Math.Point3D(layoutRenderInfo.LayoutViewport.Center, 0.0); Matrix4D matrix4D2 = Transformation4D.Translation((WW.Math.Vector3D)fromReferencePoint) * matrix4D1 * Transformation4D.Translation(-(WW.Math.Vector3D)fromReferencePoint); WW.Math.Point3D point3D3 = matrix4D2 * point3D1; point3D2 = matrix4D2 * point3D2; double scaling; Matrix4D toPaperTransform = DxfUtil.GetScaleTransform(new WW.Math.Point3D(System.Math.Min(point3D3.X, point3D2.X), System.Math.Min(point3D3.Y, point3D2.Y), 0.0), new WW.Math.Point3D(System.Math.Max(point3D3.X, point3D2.X), System.Math.Max(point3D3.Y, point3D2.Y), 0.0), fromReferencePoint, toPoint1, toPoint2, toReferencePoint, out scaling) * matrix4D2; return(new DxfLayout.PlotInfo(this, plotPaperSize, new Rectangle2D(toPoint1.X, System.Math.Min(toPoint1.Y, toPoint2.Y), toPoint2.X, System.Math.Max(toPoint1.Y, toPoint2.Y)), toPaperTransform, scaling)); }
void ILeader.imethod_0( DrawContext context, IList <WW.Math.Point3D> points, IList <WW.Math.Point3D> polyline) { DxfEntity entity = this.dxfObjectReference_6.Value as DxfEntity; if (entity == null) { return; } WW.Math.Point3D point = points[points.Count - 1]; Vector3D zaxis = this.HorizontalDirection; zaxis.Normalize(); if (this.hookLineDirection_0 == HookLineDirection.Same) { zaxis = -zaxis; } BoundsCalculator boundsCalculator = new BoundsCalculator(context.Config); Matrix4D transpose = DxfUtil.GetToWCSTransform(zaxis).GetTranspose(); Matrix4D matrix4D = Transformation4D.Translation(-(Vector3D)point); boundsCalculator.GetBounds(context.Model, entity, transpose * matrix4D); Bounds3D bounds = boundsCalculator.Bounds; if (!bounds.Initialized) { return; } double z1 = bounds.Min.Z; double z2 = bounds.Max.Z; double num1 = 0.5 * (z1 + z2); bool flag = this.dxfDimensionStyleOverrides_0.TextVerticalAlignment != DimensionTextVerticalAlignment.Above && this.dxfDimensionStyleOverrides_0.TextVerticalPosition >= -0.7 && this.dxfDimensionStyleOverrides_0.TextVerticalPosition <= 0.7; double num2 = this.dxfDimensionStyleOverrides_0.ScaleFactor; if (num2 == 0.0) { num2 = 1.0; } double num3 = this.dxfDimensionStyleOverrides_0.DimensionLineGap * num2; double num4 = !flag ? (num1 < 0.0 ? z1 : z2) : System.Math.Max(z1 - num3, 0.0); polyline.Add(point + zaxis * num4); }
public void Transform(ITransformer4D transformer) { WW.Math.Point3D position = this.Position; Vector4D vector4D1 = new Vector4D(position.X, position.Y, position.Z, 1.0); WW.Math.Point3D point3D1 = transformer.TransformToPoint3D(this.matrix4D_0 * vector4D1); Bounds2D bounds = this.interface34_0.Font.Metrics.GetBounds(this.interface34_0.Text, Enum24.flag_0); Vector4D vector4D2 = vector4D1 + new Vector4D(bounds.Delta.X, 0.0, 0.0, 0.0); WW.Math.Point3D point3D2 = transformer.TransformToPoint3D(this.matrix4D_0 * vector4D2); Vector4D vector4D3 = vector4D1 + new Vector4D(0.0, bounds.Delta.Y, 0.0, 0.0); WW.Math.Point3D point3D3 = transformer.TransformToPoint3D(this.matrix4D_0 * vector4D3); Vector3D vector3D1 = (point3D2 - point3D1) / bounds.Delta.X; Vector3D vector3D2 = (point3D3 - point3D1) / bounds.Delta.Y; Vector3D zaxis = Vector3D.CrossProduct(vector3D1, vector3D2); this.matrix4D_0 = Transformation4D.GetCoordSystem(vector3D1, vector3D2, zaxis, point3D1); }