示例#1
0
        public override void imethod_3(
            Class95 loop,
            Class88 curve,
            Class107 coedge,
            Class917 approximation,
            Class258 accuracy)
        {
            Matrix4D    canonicalTransformation = this.FromCanonicalTransformation;
            Interface27 interval          = this.Interval;
            bool        directionReversed = coedge.DirectionReversed;
            Class102    startVertex       = coedge.StartVertex;
            Class102    endVertex         = coedge.EndVertex;
            Interface27 nterface27;

            if (startVertex != endVertex)
            {
                Matrix4D inverse  = canonicalTransformation.GetInverse();
                Class105 point1   = startVertex.Point;
                Class105 point2   = endVertex.Point;
                Point3D  point3D1 = point1.method_4(inverse);
                Point3D  point3D2 = point2.method_4(inverse);
                nterface27 = (Interface27) new Class437(System.Math.Atan2(point3D1.Y, point3D1.X), System.Math.Atan2(point3D2.Y, point3D2.X));
            }
            else
            {
                Matrix4D inverse = canonicalTransformation.GetInverse();
                Point3D  point3D = startVertex.Point.method_4(inverse);
                double   start   = System.Math.Atan2(point3D.Y, point3D.X);
                double   end     = directionReversed ? start - 2.0 * System.Math.PI : start + 2.0 * System.Math.PI;
                nterface27 = (Interface27) new Class437(start, end);
            }
            int    num1   = Class247.smethod_7(this.vector3D_1.GetLength(), accuracy);
            double start1 = nterface27.Start;
            double end1   = nterface27.End;

            if (directionReversed)
            {
                if (start1 < end1)
                {
                    end1 -= 2.0 * System.Math.PI;
                }
            }
            else if (start1 > end1)
            {
                end1 += 2.0 * System.Math.PI;
            }
            double num2 = (end1 - start1) / (double)num1;

            approximation.method_0(coedge.StartLocation);
            for (int index = 1; index < num1; ++index)
            {
                double  num3  = (double)index * num2 + start1;
                double  x     = System.Math.Cos(num3);
                double  y     = System.Math.Sin(num3);
                Point3D point = canonicalTransformation.Transform(new Point3D(x, y, 0.0));
                approximation.method_0(point);
            }
            approximation.method_0(coedge.EndLocation);
        }
 public void SetPreTransform(Matrix4D preTransform)
 {
     this.matrix4D_0 *= preTransform;
     this.interface32_0.imethod_0(preTransform.GetInverse());
     this.matrix3D_0       *= new Matrix3D(preTransform.M00, preTransform.M01, preTransform.M02, preTransform.M10, preTransform.M11, preTransform.M12, preTransform.M20, preTransform.M21, preTransform.M22);
     this.ilineTypeScaler_0 = Class624.Create(this.matrix3D_0);
 }
示例#3
0
        public virtual void ImageControl_OnMouseWheel(object sender, MouseEventArgs e)
        {
            base.OnMouseWheel(e);

            Matrix4D oldTo2DTransform = CalculateTo2DTransform1();
            int      compare          = Math.Sign(e.Delta);

            // wheel movement is forward
            if (compare > 0)
            {
                scaleFactor *= 1.1d;
            }
            // wheel movement is backward
            else if (compare < 0)
            {
                scaleFactor /= 1.1d;
            }

            // --- Begin of correction on the translation to zoom into mouse position.
            // Comment out this section to zoom into center of model.
            Point3D  currentScreenPoint        = new Point3D(e.X, e.Y, 0d);
            Point3D  modelPoint                = oldTo2DTransform.GetInverse().Transform(currentScreenPoint);
            Matrix4D intermediateTo2DTransform = CalculateTo2DTransform1();
            Point3D  screenPoint               = intermediateTo2DTransform.Transform(modelPoint);

            translation += (currentScreenPoint - screenPoint);
            // --- End of translation correction.

            CalculateTo2DTransform1();

            ImageControl.Invalidate();
        }
示例#4
0
文件: Polygon3D.cs 项目: 15831944/WW
        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))));
        }
示例#5
0
 public Class436(double angle, Matrix4D fromCanonical, Class190 outer)
 {
     this.double_0   = System.Math.Sin(angle);
     this.double_1   = System.Math.Cos(angle);
     this.matrix4D_0 = fromCanonical;
     this.matrix4D_1 = fromCanonical.GetInverse();
     this.class190_0 = outer;
 }
示例#6
0
        private Matrix4D method_1()
        {
            this.simpleTransformationProviderBase_0.ViewWindow = this.method_2();
            Matrix4D completeTransform = this.simpleTransformationProviderBase_0.CompleteTransform;

            this.matrix4D_0 = completeTransform.GetInverse();
            return(completeTransform);
        }
示例#7
0
文件: Class808.cs 项目: 15831944/WW
        public void imethod_0(Matrix4D transform)
        {
            Matrix4D inverse = transform.GetInverse();

            inverse.Transpose();
            foreach (BlinnClipper4D.ClipPlane clipPlane in this.list_0)
            {
                clipPlane.TransformBy(transform, inverse);
            }
        }
示例#8
0
文件: Class455.cs 项目: 15831944/WW
        public Class455(Matrix4D clipBoundaryTransform, Polygon2D clipPolygon, bool inverseClip)
        {
            this.matrix4D_0 = clipBoundaryTransform;
            this.class461_0 = new Class455.Class461(clipPolygon, inverseClip);
            bool couldInvert;

            this.matrix4D_1 = clipBoundaryTransform.GetInverse(out couldInvert);
            if (!couldInvert)
            {
                throw new ArgumentException("Non-invertable clipBoundaryTransform!");
            }
        }
示例#9
0
 public InteractionContext(
     Rectangle2D canvasRectangle,
     Matrix4D projectionTransform,
     bool projectionFlipsOrientation,
     ArgbColor backgroundColor)
 {
     this.rectangle2D_0 = canvasRectangle;
     this.matrix4D_0    = projectionTransform;
     this.matrix4D_1    = projectionTransform.GetInverse();
     this.argbColor_0   = backgroundColor;
     this.bool_0        = projectionFlipsOrientation;
 }
示例#10
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])));
         }
     }
 }
        /// <summary>
        /// Zoom in/out.
        /// </summary>
        private void Canvas_MouseWheel(object sender, MouseWheelEventArgs e)
        {
            int sign = Math.Sign(e.Delta);

            double newScaling = scaling;

            // wheel movement is forward
            if (sign > 0)
            {
                newScaling *= 1.1d;
            }
            // wheel movement is backward
            else if (sign < 0)
            {
                newScaling /= 1.1d;
            }
            System.Windows.Point p = e.GetPosition(dockPanel);

            // This is the post-zoom position.
            Point3D postZoomPosition =
                new Point3D(p.X / canvas.ActualWidth * 2d - 1d, -p.Y / canvas.ActualHeight * 2d + 1, 0d);

            // This is the pre-zoom position.
            Matrix4D zoomTranslation =
                Transformation4D.Translation((Vector3D)translation) *
                Transformation4D.Scaling(scaling);
            Point3D preZoomPosition = zoomTranslation.GetInverse().Transform(postZoomPosition);

            Matrix4D newZoomTranslation =
                Transformation4D.Translation((Vector3D)translation) *
                Transformation4D.Scaling(newScaling);
            Point3D uncorrectedPostZoomPosition = newZoomTranslation.Transform(preZoomPosition);

            translation += postZoomPosition - uncorrectedPostZoomPosition;
            scaling      = newScaling;

            UpdateRenderTransform();
        }
示例#12
0
        internal IClippingTransformer method_17(
            DxfModel model,
            GraphicsConfig graphicsConfig,
            Matrix4D postTransform)
        {
            IClippingTransformer  clippingTransformer    = (IClippingTransformer)null;
            IClipBoundaryProvider clippingBoundaryEntity = this.ClippingBoundaryEntity as IClipBoundaryProvider;

            if (this.UseNonRectangularClipBoundary && clippingBoundaryEntity != null)
            {
                IList <Polygon2D> clipBoundary = clippingBoundaryEntity.GetClipBoundary(graphicsConfig);
                if (clipBoundary.Count == 1)
                {
                    Matrix4D transform = this.GetTransform();
                    clippingTransformer = (IClippingTransformer) new ModelSpaceClippingTransformer(postTransform * transform, new Matrix3D(transform.M00, transform.M01, transform.M02, transform.M10, transform.M11, transform.M12, transform.M20, transform.M21, transform.M22), (Interface32) new Class455(transform.GetInverse(), clipBoundary[0], false), graphicsConfig.ShapeFlattenEpsilon, graphicsConfig.ShapeFlattenEpsilonForBoundsCalculation);
                }
            }
            if (clippingTransformer == null)
            {
                clippingTransformer = (IClippingTransformer) new Class938(this, postTransform, graphicsConfig.ShapeFlattenEpsilon, graphicsConfig.ShapeFlattenEpsilonForBoundsCalculation, model.Header.PaperSpaceAnnotationScalingEnabled);
            }
            return(clippingTransformer);
        }
示例#13
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);
         }
     }
 }
示例#14
0
文件: DxfInsert.cs 项目: 15831944/WW
        private DxfInsert.Enum44 method_16(
            Matrix4D insertionTransform,
            DxfInsert.Interface46 drawHandler)
        {
            if (drawHandler.InsertCellDrawContext.Config.UseSpatialFilters)
            {
                DxfSpatialFilter spatialFilter = this.SpatialFilter;
                if (spatialFilter != null && spatialFilter.ClipBoundaryDisplayEnabled)
                {
                    Polygon2D clipPolygon = spatialFilter.GetClipBoundaryPolygon();
                    if (clipPolygon.Count < 3)
                    {
                        return(DxfInsert.Enum44.const_1);
                    }
                    if (clipPolygon.GetArea() < 0.0)
                    {
                        clipPolygon = clipPolygon.GetReverse();
                    }
                    Matrix4D         boundaryTransform     = spatialFilter.ClipBoundaryTransform;
                    Matrix4D         transform             = insertionTransform * this.Block.BaseTransformation * spatialFilter.InverseInsertionTransform;
                    Matrix4D         inverse1              = boundaryTransform.GetInverse();
                    Matrix4D         clipBoundaryTransform = transform * inverse1;
                    DxfInsert.Enum44 enum44;
                    if (clipPolygon.IsConvex())
                    {
                        List <BlinnClipper4D.ClipPlane> clipPlaneList = new List <BlinnClipper4D.ClipPlane>();
                        WW.Math.Point2D  point2D             = clipPolygon[clipPolygon.Count - 1];
                        WW.Math.Vector3D boundaryPlaneNormal = spatialFilter.ClipBoundaryPlaneNormal;
                        Matrix4D         inverse2            = transform.GetInverse();
                        inverse2.Transpose();
                        foreach (WW.Math.Point2D point in (List <WW.Math.Point2D>)clipPolygon)
                        {
                            Vector2D v = point - point2D;
                            BlinnClipper4D.ClipPlane clipPlane = new BlinnClipper4D.ClipPlane(WW.Math.Vector3D.CrossProduct(inverse1.TransformTo3D(v), boundaryPlaneNormal), inverse1.TransformTo3D(point));
                            clipPlane.TransformBy(transform, inverse2);
                            clipPlaneList.Add(clipPlane);
                            point2D = point;
                        }
                        BoundsCalculator boundsCalculator = new BoundsCalculator();
                        boundsCalculator.GetBounds(drawHandler.InsertCellDrawContext.Model, (IEnumerable <DxfEntity>) this.Block.Entities, insertionTransform * this.Block.BaseTransformation);
                        switch (new BlinnClipper4D((ICollection <BlinnClipper4D.ClipPlane>)clipPlaneList).TryIsInside(boundsCalculator.Bounds))
                        {
                        case InsideTestResult.Inside:
                            enum44 = DxfInsert.Enum44.const_2;
                            break;

                        case InsideTestResult.Outside:
                            enum44 = DxfInsert.Enum44.const_0;
                            break;

                        default:
                            enum44 = DxfInsert.Enum44.const_3;
                            break;
                        }
                        if (enum44 == DxfInsert.Enum44.const_3)
                        {
                            Class808 class808 = new Class808((ICollection <BlinnClipper4D.ClipPlane>)clipPlaneList);
                            class808.imethod_0(insertionTransform.GetInverse());
                            GraphicsConfig config = drawHandler.InsertCellDrawContext.Config;
                            ModelSpaceClippingTransformer clippingTransformer = new ModelSpaceClippingTransformer(Matrix4D.Identity, (Interface32)class808, config.ShapeFlattenEpsilon, config.ShapeFlattenEpsilonForBoundsCalculation);
                            drawHandler.InsertCellDrawContext.vmethod_0((IClippingTransformer)clippingTransformer);
                        }
                    }
                    else
                    {
                        Class455         class455         = new Class455(clipBoundaryTransform, clipPolygon, false);
                        BoundsCalculator boundsCalculator = new BoundsCalculator();
                        boundsCalculator.GetBounds(drawHandler.InsertCellDrawContext.Model, (IEnumerable <DxfEntity>) this.Block.Entities, insertionTransform * this.Block.BaseTransformation);
                        switch (class455.TryIsInside(boundsCalculator.Bounds))
                        {
                        case InsideTestResult.Inside:
                            enum44 = DxfInsert.Enum44.const_2;
                            break;

                        case InsideTestResult.Outside:
                            enum44 = DxfInsert.Enum44.const_0;
                            break;

                        default:
                            enum44 = DxfInsert.Enum44.const_3;
                            break;
                        }
                        if (enum44 == DxfInsert.Enum44.const_3)
                        {
                            Matrix4D inverse2 = insertionTransform.GetInverse();
                            class455.imethod_0(inverse2);
                            GraphicsConfig config = drawHandler.InsertCellDrawContext.Config;
                            ModelSpaceClippingTransformer clippingTransformer = new ModelSpaceClippingTransformer(Matrix4D.Identity, (Interface32)class455, config.ShapeFlattenEpsilon, config.ShapeFlattenEpsilonForBoundsCalculation);
                            drawHandler.InsertCellDrawContext.vmethod_0((IClippingTransformer)clippingTransformer);
                        }
                    }
                    if ((!spatialFilter.ClipBoundaryDisplayEnabled || drawHandler.InsertCellDrawContext.Model.Header.ExternalReferenceClippingBoundaryType == WW.Cad.Model.SimpleLineType.Off ? 0 : (this.IsEntityVisibleInContext(drawHandler.InsertCellDrawContext, true) ? 1 : 0)) != 0)
                    {
                        WW.Math.Geometry.Polyline3D polygon = new WW.Math.Geometry.Polyline3D(clipPolygon.Count);
                        foreach (WW.Math.Point2D point in (List <WW.Math.Point2D>)clipPolygon)
                        {
                            polygon.Add(clipBoundaryTransform.TransformTo3D(point));
                        }
                        polygon.Closed = true;
                        drawHandler.Draw(polygon);
                    }
                    return(enum44);
                }
            }
            return(DxfInsert.Enum44.const_1);
        }
示例#15
0
        public virtual void ImageControl_OnMouseUp(object sender, MouseEventArgs e)
        {
            base.OnMouseUp(e);
            mouseDown = false;

            // Use shift key for rectangle zoom.
            if (shiftPressed)
            {
                DrawReversibleRectangle(mouseClickLocation, lastMouseLocation);
                Point2D corner1 = new Point2D(
                    Math.Min(mouseClickLocation.X, e.Location.X),
                    Math.Min(mouseClickLocation.Y, e.Location.Y)
                    );
                Point2D corner2 =
                    new Point2D(
                        Math.Max(mouseClickLocation.X, e.Location.X),
                        Math.Max(mouseClickLocation.Y, e.Location.Y)
                        );
                Vector2D delta = corner2 - corner1;
                if (!(MathUtil.AreApproxEqual(delta.X, 0d) || MathUtil.AreApproxEqual(delta.Y, 0d)))
                {
                    Matrix4D oldTo2DTransform = CalculateTo2DTransform1();

                    // Update scaleFactor
                    double scale = Math.Min(ImageControl.ClientSize.Width / delta.X, ImageControl.ClientSize.Height / delta.Y);
                    scaleFactor *= scale;

                    //// Update translation
                    Point3D  screenSpaceCenter         = new Point3D(corner1 + 0.5d * delta, 0d);
                    Point3D  newModelSpaceCenter       = oldTo2DTransform.GetInverse().Transform(new Point3D(corner1 + 0.5d * delta, 0d));
                    Matrix4D intermediateTo2DTransform = CalculateTo2DTransform1();
                    intermediateTo2DTransform.TransformTo2D(newModelSpaceCenter);
                    Point3D intermediateScreenSpaceCenter = intermediateTo2DTransform.Transform(newModelSpaceCenter);
                    translation += (
                        new Point3D(0.5d * ImageControl.ClientSize.Width, 0.5d * ImageControl.ClientSize.Height, 0d) -
                        intermediateScreenSpaceCenter
                        );

                    CalculateTo2DTransform1();
                    ImageControl.Invalidate();
                    shiftPressed = false;
                }
            }
            else
            {
                // Select entity at mouse location if mouse didn't move
                // and show entity in property grid.
                if (mouseClickLocation == e.Location)
                {
                    try
                    {
                        Point2D referencePoint = new Point2D(e.X, e.Y);
                        double  distance;
                        IList <RenderedEntityInfo> closestEntities =
                            EntitySelector.GetClosestEntities(
                                model,
                                GraphicsConfig.BlackBackgroundCorrectForBackColor,
                                gdiGraphics3D.To2DTransform,
                                referencePoint,
                                out distance
                                );
                        if (closestEntities.Count > 0)
                        {
                            DxfEntity entity = closestEntities[0].Entity;
                            OnEntitySelected(new EntityEventArgs(entity));
                        }
                    }
                    catch
                    {
                    }
                }
            }
        }