Beispiel #1
0
 static public void AlignHcenter(GeoObjectList gl, Projection projection, Project pr)
 {
     using (pr.Undo.UndoFrame)
     {
         BoundingRect re1     = IGeoObjectImpl.GetExtent(gl[gl.Count - 1], projection, false);
         double       center1 = (re1.Left + re1.Right) / 2;
         if (gl.Count == 1)
         {
             center1 = 0.0;                // um den Ursprung, wenns nur eines ist
         }
         for (int i = 0; i < Math.Max(1, gl.Count - 1); ++i)
         {
             BoundingRect re      = IGeoObjectImpl.GetExtent(gl[i], projection, false);
             GeoVector2D  trans2D = new GeoVector2D(center1 - (re.Left + re.Right) / 2, 0);
             GeoVector    trans   = projection.DrawingPlane.ToGlobal(trans2D);
             ModOp        m       = ModOp.Translate(trans);
             gl[i].Modify(m);
         }
     }
 }
Beispiel #2
0
        public static int ClipCode(ref GeoPoint2D p, ref BoundingRect rect)
        {
            int res = 0;

            if (p.x < rect.Left)
            {
                res = ClipLeft;
            }
            else if (p.x > rect.Right)
            {
                res = ClipRight;
            }
            if (p.y < rect.Bottom)
            {
                res = res | ClipBottom;
            }
            else if (p.y > rect.Top)
            {
                res = res | ClipTop;
            }
            return(res);
        }
Beispiel #3
0
 public override bool SameGeometry(BoundingRect thisBounds, ISurface other, BoundingRect otherBounds, double precision, out ModOp2D firstToSecond)
 {
     if (other is RuledSurface)
     {
         RuledSurface rsother = other as RuledSurface;
         if ((firstCurve.SameGeometry(rsother.firstCurve, precision) && secondCurve.SameGeometry(rsother.secondCurve, precision)) ||
             (firstCurve.SameGeometry(rsother.secondCurve, precision) && secondCurve.SameGeometry(rsother.firstCurve, precision)))
         {
             GeoPoint2D[] srcPoints = new GeoPoint2D[] { GeoPoint2D.Origin, new GeoPoint2D(1, 0), new GeoPoint2D(0, 1) };
             GeoPoint2D[] dstPoints = new GeoPoint2D[3];
             for (int i = 0; i < dstPoints.Length; i++)
             {
                 dstPoints[i] = rsother.PositionOf(this.PointAt(srcPoints[i]));
             }
             firstToSecond = ModOp2D.Fit(srcPoints, dstPoints, true);
             return(true);
         }
         firstToSecond = ModOp2D.Null;
         return(false);
     }
     return(base.SameGeometry(thisBounds, other, otherBounds, precision, out firstToSecond));
 }
Beispiel #4
0
 bool IQuadTreeInsertable.HitTest(ref BoundingRect rect, bool includeControlPoints)
 {
     return(rect.Contains(p));
 }
 bool IQuadTreeInsertable.HitTest(ref BoundingRect rect, bool includeControlPoints)
 {
     throw new NotImplementedException();
 }
Beispiel #6
0
 public ICurve Intersect(BoundingRect thisBounds, ISurface other, BoundingRect otherBounds, GeoPoint seed)
 {
     throw new NotImplementedException();
 }
Beispiel #7
0
        public ProjectedCurve(ICurve curve3D, ISurface surface, double startParam, double endParam, BoundingRect domain)
        {
#if DEBUG
            debugCount = debugCounter++;
#endif
            this.curve3D    = curve3D;
            this.surface    = surface;
            this.startParam = startParam;
            this.endParam   = endParam;
            periodicDomain  = domain;
        }
Beispiel #8
0
 bool IQuadTreeInsertable.HitTest(ref BoundingRect rect, bool includeControlPoints)
 {
     return(theCurve.HitTest(ref rect, includeControlPoints));
 }
Beispiel #9
0
        private void OnPrintPage(object sender, PrintPageEventArgs e)
        {
            Rectangle r = e.PageBounds; // ist IMMER in 100 dpi
            // die Pixelauflösung des Druckers ist in e.Graphics.DpiX bzw. DpiY
            double fctpap = 100 / 25.4;
            //double fct = 100 / 25.4;
            double fct = e.Graphics.DpiX / 25.4; // das ist die echte Auflösung

            // fct /= 2; war nur ein Test

            e.Graphics.PageScale = (float)(1.0);

            for (int i = 0; i < layout.PatchCount; ++i)
            {
                LayoutPatch lp = layout.Patches[i];
                e.Graphics.Transform = new System.Drawing.Drawing2D.Matrix((float)fctpap, 0.0f, 0.0f, (float)-fctpap, 0.0f, (float)(layout.PaperHeight * fctpap));

                BoundingRect ext;
                if (lp.Area != null)
                {
                    ext = lp.Area.Extent;
                }
                else
                {
                    ext = new BoundingRect(0.0, 0.0, layout.PaperWidth, layout.PaperHeight);
                }

                // der Faktor fct ist willkürlich, macht man ihn zu groß, gibt es ein OutOfMemory in OpenGl
                // zu klein, wird die Auflösung beim Drucken zu grob. Abhilfe würde es schaffen, wenn man nicht ein
                // Bitmap erzeugt, sondern dieses kachelt. Ob man es aber nahtlos zusammensetzen kann?
                // eigentlich gefragt wäre hier die Pixelauflösung des Graphics, aber vielleicht gibt es die garnicht
                // und es ist ein Metafile, der zum Drucker weitergereicht wird.
                GeoPoint2D            ll            = ext.GetLowerLeft();
                GeoPoint2D            ur            = ext.GetUpperRight();
                Rectangle             clipRectangle = Rectangle.FromLTRB((int)ll.x, (int)ll.y, (int)ur.x, (int)ur.y);
                System.Drawing.Bitmap PaintToBitmap;
                int bitmapwidth  = (int)(clipRectangle.Width * fct);
                int bitmapheight = (int)(clipRectangle.Height * fct);
                PaintToBitmap = new System.Drawing.Bitmap(bitmapwidth, bitmapheight);

                IPaintTo3D ipaintTo3D = Frame.UIService.CreatePaintInterface(PaintToBitmap, lp.Model.Extent.Size / 1000);
                ipaintTo3D.MakeCurrent();
                ipaintTo3D.Clear(Color.White);
                ipaintTo3D.AvoidColor(Color.White);

                Projection pr = lp.Projection.Clone();
                pr.SetUnscaledProjection(new ModOp(1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0) * pr.UnscaledProjection);
                double factor, dx, dy;
                pr.GetPlacement(out factor, out dx, out dy);
                //new System.Drawing.Drawing2D.Matrix((float)factor, 0.0f, 0.0f, (float)-factor, 0.0f, (float)(layout.PaperHeight * factor));
                pr.SetPlacement(fct * factor, fct * (dx - ext.Left), fct * (dy - ext.Bottom));
                ipaintTo3D.SetProjection(pr, lp.Model.Extent);
                ipaintTo3D.UseZBuffer(true);
                ipaintTo3D.PaintFaces(PaintTo3D.PaintMode.All);
                ipaintTo3D.UseLineWidth = true;
                // hier darf nicht mit Listen gearbeitet werden, sonst macht OpanGL die Krätsche
                foreach (IGeoObject go in lp.Model)
                {
                    PaintFlatVisibleLayer(ipaintTo3D, go, lp.visibleLayers);
                }

                //CategorizedDislayLists displayLists = new CategorizedDislayLists();
                //// beim Zeichnen auf Bitmaps müssen die Displaylisten lokal zu diesem rendercontext gehören
                //// obwohl sharelists angegeben wurde und das keinen Fehler bringt
                //// leider wird alles hierbei flach. Man könnte das höchstens damit übertricksen,
                //// dass man bei tringle die Farbe an jedem Eckpunkt mit dem Normalenvektor verrechnet
                //// aber ob das hilft?
                //foreach (IGeoObject go in lp.Model)
                //{
                //    go.PaintTo3DList(ipaintTo3D, displayLists);
                //}
                //displayLists.Finish(ipaintTo3D);
                //ipaintTo3D.PaintFaces(PaintTo3D.PaintMode.FacesOnly);
                //foreach (KeyValuePair<Layer, IPaintTo3DList> kv in displayLists.layerFaceDisplayList)
                //{
                //    if (lp.IsLayerVisible(kv.Key) || displayLists.NullLayer == kv.Key)
                //    {
                //        ipaintTo3D.List(kv.Value);
                //    }
                //}
                //ipaintTo3D.PaintFaces(PaintTo3D.PaintMode.CurvesOnly);
                //foreach (KeyValuePair<Layer, IPaintTo3DList> kv in displayLists.layerCurveDisplayList)
                //{
                //    if (lp.IsLayerVisible(kv.Key) || displayLists.NullLayer == kv.Key)
                //    {
                //        ipaintTo3D.List(kv.Value);
                //    }
                //}
                //// wozu war das folgende noch?
                ////foreach (IGeoObject go in lp.Model)
                ////{
                ////    go.PaintTo3D(ipaintTo3D);
                ////}
                //// ipaintTo3D.Dispose(); gibt OpenGL Fehler
                //ipaintTo3D.FinishPaint();

                //gr.ReleaseHdc(dc);
                //displayLists = null;
                //System.GC.Collect();
                //System.GC.WaitForPendingFinalizers();
                //ipaintTo3D.Dispose();

                PaintToBitmap.MakeTransparent(Color.White);
                //e.Graphics.DrawImageUnscaled(PaintToBitmap, clipRectangle);
                PointF[] dest = new PointF[3];
                dest[0].X = (float)ll.x;
                dest[0].Y = (float)ur.y;
                dest[1].X = (float)ur.x;
                dest[1].Y = (float)ur.y;
                dest[2].X = (float)ll.x;
                dest[2].Y = (float)ll.y;
                RectangleF src = new RectangleF(new PointF(0.0f, 0.0f), PaintToBitmap.Size);
                e.Graphics.DrawImage(PaintToBitmap, dest, src, GraphicsUnit.Pixel);
            }
        }
Beispiel #10
0
 public GeoPoint[] GetTouchingPoints(BoundingRect thisBounds, ISurface other, BoundingRect otherBounds)
 {
     throw new NotImplementedException();
 }
Beispiel #11
0
 public IDualSurfaceCurve[] GetDualSurfaceCurves(BoundingRect thisBounds, ISurface other, BoundingRect otherBounds, List <GeoPoint> seeds)
 {
     throw new NotImplementedException();
 }
Beispiel #12
0
 public void GetPatchHull(BoundingRect uvpatch, out GeoPoint loc, out GeoVector dir1, out GeoVector dir2, out GeoVector dir3)
 {
     throw new NotImplementedException();
 }
Beispiel #13
0
 public void SetBounds(BoundingRect boundingRect)
 {
     throw new NotImplementedException();
 }
Beispiel #14
0
 public BoundingCube GetPatchExtent(BoundingRect uvPatch, bool rough)
 {
     throw new NotImplementedException();
 }
Beispiel #15
0
 public double IsParallel(BoundingRect thisBounds, ISurface other, BoundingRect otherBounds)
 {
     return(double.MaxValue);
 }
Beispiel #16
0
 public bool SameGeometry(BoundingRect thisBounds, ISurface other, BoundingRect otherBounds, double precision, out ModOp2D firstToSecond)
 {
     throw new NotImplementedException();
 }
Beispiel #17
0
        public static bool LineHitTest(GeoPoint2D p1, GeoPoint2D p2, ref BoundingRect rect)
        {
            int c;
            int c1 = ClipCode(ref p1, ref rect);
            int c2 = ClipCode(ref p2, ref rect);

            if ((c1 & c2) != 0)
            {
                return(false);
            }
            if (!(c1 != 0 && c2 != 0))
            {
                return(true);
            }
            while ((c1 | c2) != 0)
            {
                GeoPoint2D p = new GeoPoint2D();
                if (c1 != 0)
                {
                    c = c1;
                }
                else
                {
                    c = c2;
                }
                if ((ClipLeft & c) != 0)
                {
                    p.y = p1.y + (p2.y - p1.y) / (p2.x - p1.x) * (rect.Left - p1.x);
                    p.x = rect.Left;
                }
                else
                if ((ClipRight & c) != 0)
                {
                    p.y = p1.y + (p2.y - p1.y) / (p2.x - p1.x) * (rect.Right - p1.x);
                    p.x = rect.Right;
                }
                else
                if ((ClipBottom & c) != 0)
                {
                    p.x = p1.x + (p2.x - p1.x) / (p2.y - p1.y) * (rect.Bottom - p1.y);
                    p.y = rect.Bottom;
                }
                else
                if ((ClipTop & c) != 0)
                {
                    p.x = p1.x + (p2.x - p1.x) / (p2.y - p1.y) * (rect.Top - p1.y);
                    p.y = rect.Top;
                }
                else
                {   // nur um den Compiler zufrieden zu stellen
                    throw new ClipRectException();
                }
                if (c == c1)
                {
                    p1 = p; c1 = ClipCode(ref p, ref rect);
                }
                else
                {
                    p2 = p; c2 = ClipCode(ref p, ref rect);
                }
                if ((c1 & c2) != 0)
                {
                    return(false);
                }
                if (!(c1 != 0 && c2 != 0))
                {
                    return(true);
                }
            }
            return(true);
        }
Beispiel #18
0
 public int GetExtremePositions(BoundingRect thisBounds, ISurface other, BoundingRect otherBounds, out List <Tuple <double, double, double, double> > extremePositions)
 {
     // the 2d points cannot be transformed, because maybe one component is NaN
     return(original.GetExtremePositions(thisBounds, other, otherBounds, out extremePositions));
 }
Beispiel #19
0
        void IView.OnPaint(PaintEventArgs e)
        {
            IPaintTo3D paintTo3D = canvas.PaintTo3D;
            Rectangle  clr       = e.ClipRectangle;

            if (!IsInitialized)
            {
                ZoomTotal(1.1);
            }

            //PaintToOpenGl paintTo3D = new PaintToOpenGl(1e-3); // woher nehmen?
            // IntPtr dc = e.Graphics.GetHdc();
            //paintTo3D.Init(dc, condorCtrl.ClientRectangle.Width, condorCtrl.ClientRectangle.Height, false);
            IPaintTo3D ipaintTo3D = paintTo3D;

            // ipaintTo3D.Init(condorCtrl); // das erzeugt jedesmal einen neuen renderContext, das kann doch nicht richtig sein
            ipaintTo3D.MakeCurrent();
            ipaintTo3D.Clear(Color.Black); // damit ist black die Backgroundcolor

            //e.Graphics.FillRectangle(Brushes.Black, e.Graphics.ClipBounds);
            GeoPoint2D ll        = layoutToScreen * new GeoPoint2D(0.0, 0.0);
            GeoPoint2D ur        = layoutToScreen * new GeoPoint2D(layout.PaperWidth, layout.PaperHeight);
            RectangleF paperrect = RectangleF.FromLTRB((float)ll.x, (float)ur.y, (float)ur.x, (float)ll.y);

            //e.Graphics.FillRectangle(Brushes.White, paperrect);

            //BoundingCube bc = new BoundingCube(ll.x, ur.x, ll.y, ur.y, -1.0, 1.0);
            //ipaintTo3D.SetProjection(new Projection(Projection.StandardProjection.FromTop), bc);
            ipaintTo3D.UseZBuffer(false);
            ipaintTo3D.SetColor(Color.White);
            ipaintTo3D.FillRect2D(ll.PointF, ur.PointF);

            //ipaintTo3D.FinishPaint();// DEBUG
            //return; // DEBUG

            ipaintTo3D.AvoidColor(Color.White);

            if (RepaintActionEvent != null)
            {
                RepaintActionEvent(this, ipaintTo3D);
            }

            for (int i = 0; i < layout.Patches.Length; ++i)
            {
                LayoutPatch  lp        = layout.Patches[i];
                BoundingRect paperRect = new BoundingRect(0.0, 0.0, layout.PaperWidth, layout.PaperHeight);

                BoundingRect ext;
                if (lp.Area != null)
                {
                    ext = lp.Area.Extent;
                }
                else
                {
                    ext = paperRect;
                }

                GeoPoint2D clipll = layoutToScreen * ext.GetLowerLeft();
                GeoPoint2D clipur = layoutToScreen * ext.GetUpperRight();
                Rectangle  clipRectangle = Rectangle.FromLTRB((int)clipll.x, (int)clipur.y, (int)clipur.x, (int)clipll.y);
                Projection pr = lp.Projection.Clone();
                double     factor, dx, dy;
                pr.GetPlacement(out factor, out dx, out dy);
                pr.SetPlacement(layoutToScreen.Factor * factor, ll.x + layoutToScreen.Factor * dx, ll.y - layoutToScreen.Factor * dy);
                pr.Precision = lp.Model.Extent.Size / 1000;

                ipaintTo3D.Precision = pr.Precision;
                ipaintTo3D.SetProjection(pr, lp.Model.Extent);
                ipaintTo3D.UseZBuffer(true);
                ipaintTo3D.SetClip(clipRectangle);
                ipaintTo3D.PaintFaces(PaintTo3D.PaintMode.All);
                // lp.Model.ClearDisplayLists();
                lp.Model.RecalcDisplayLists(ipaintTo3D);
                if (lp.Projection.ShowFaces)
                {
                    ipaintTo3D.PaintFaces(PaintTo3D.PaintMode.FacesOnly);
                    foreach (KeyValuePair <Layer, IPaintTo3DList> kv in lp.Model.layerFaceDisplayList)
                    {
                        if (lp.IsLayerVisible(kv.Key) || lp.Model.nullLayer == kv.Key)
                        {
                            ipaintTo3D.List(kv.Value);
                        }
                    }
                }
                ipaintTo3D.PaintFaces(PaintTo3D.PaintMode.CurvesOnly);
                foreach (KeyValuePair <Layer, IPaintTo3DList> kv in lp.Model.layerCurveDisplayList)
                {
                    if (lp.IsLayerVisible(kv.Key) || lp.Model.nullLayer == kv.Key)
                    {
                        ipaintTo3D.List(kv.Value);
                    }
                }
                ipaintTo3D.SetClip(Rectangle.Empty);
            }
            ipaintTo3D.FinishPaint();
        }
Beispiel #20
0
 public IDualSurfaceCurve[] GetDualSurfaceCurves(BoundingRect thisBounds, ISurface other, BoundingRect otherBounds, List <GeoPoint> seeds, List <Tuple <double, double, double, double> > extremePositions = null)
 {
     return(original.GetDualSurfaceCurves(thisBounds, other, otherBounds, seeds, extremePositions));
 }
Beispiel #21
0
        virtual public bool OnCommand(string MenuId)
        {
            if (MenuId.StartsWith("FromModelView_"))
            {
                string name = MenuId.Substring("FromModelView_".Length);
                for (int i = 0; i < project.ModelViewCount; i++)
                {
                    if (project.GetProjectedModel(i).Name == name)
                    {
                        Projection = project.GetProjectedModel(i).Projection.Clone();
                        projectionDirection.SetGeoVector(Projection.Direction);
                        propertyTreeView.SelectEntry(projectionDirection);
                        projectionDirection.Refresh();
                        Projection = project.GetProjectedModel(i).Projection.Clone();
                        // und noch zentrieren (von unten kopiert)
                        double       f  = 1.0;
                        BoundingRect br = model.GetExtent(Projection);
                        f = Math.Min(section.Width / br.Width, section.Height / br.Height) * 0.9;
                        layout.CenterPatch(this, f, Layout.HorizontalCenter.center, Layout.VerticalCenter.center);
                        layoutView.Repaint();
                        scalingProperty.Refresh();

                        return(true);
                    }
                }
            }
            switch (MenuId)
            {
            case "MenuId.Layout.Scale.1To1":
                Scale(1.0);
                return(true);

            case "MenuId.Layout.Scale.1To5":
                Scale(1.0 / 5.0);
                return(true);

            case "MenuId.Layout.Scale.1To10":
                Scale(1.0 / 10.0);
                return(true);

            case "MenuId.Layout.Scale.1To50":
                Scale(1.0 / 50.0);
                return(true);

            case "MenuId.Layout.Scale.1To100":
                Scale(1.0 / 100.0);
                return(true);

            case "MenuId.Layout.Scale.1To1000":
                Scale(1.0 / 1000.0);
                return(true);

            case "MenuId.Layout.Scale.10To1":
                Scale(10.0);
                return(true);

            case "MenuId.Layout.Scale.100To1":
                Scale(100.0);
                return(true);

            case "MenuId.Layout.Scale.Fit":
            {
                double       f  = 1.0;
                BoundingRect br = model.GetExtent(Projection);
                f = Math.Min(section.Width / br.Width, section.Height / br.Height);
                layout.CenterPatch(this, f, Layout.HorizontalCenter.center, Layout.VerticalCenter.center);
                layoutView.Repaint();
                scalingProperty.Refresh();
            }
                return(true);

            case "MenuId.Layout.Horizontal.Left":
                Center(Layout.HorizontalCenter.left, Layout.VerticalCenter.unchanged);
                return(true);

            case "MenuId.Layout.Horizontal.Center":
                Center(Layout.HorizontalCenter.center, Layout.VerticalCenter.unchanged);
                return(true);

            case "MenuId.Layout.Horizontal.Right":
                Center(Layout.HorizontalCenter.right, Layout.VerticalCenter.unchanged);
                return(true);

            case "MenuId.Layout.Vertical.Bottom":
                Center(Layout.HorizontalCenter.unchanged, Layout.VerticalCenter.bottom);
                return(true);

            case "MenuId.Layout.Vertical.Center":
                Center(Layout.HorizontalCenter.unchanged, Layout.VerticalCenter.center);
                return(true);

            case "MenuId.Layout.Vertical.Top":
                Center(Layout.HorizontalCenter.unchanged, Layout.VerticalCenter.top);
                return(true);

            case "MenuId.LayoutPatch.Rename":
                propertyTreeView.StartEditLabel(this);
                return(true);

            case "MenuId.LayoutPatch.Remove":
                layout.RemovePatch(this);
                layoutView.Refresh();
                return(true);

            case "MenuId.LayoutPatch.FillLayout":
                section.Left   = 0;
                section.Right  = layout.PaperWidth;
                section.Bottom = 0;
                section.Top    = layout.PaperHeight;
                SetSection();
                return(true);

            case "MenuId.LayoutPatch.Center":
                Center(Layout.HorizontalCenter.center, Layout.VerticalCenter.center);
                return(true);
            }
            return(false);
        }
Beispiel #22
0
 public int GetExtremePositions(BoundingRect domain, ICurve curve3D, out List <Tuple <double, double, double> > positions)
 {
     throw new NotImplementedException();
 }
Beispiel #23
0
        private int debugCount; // to identify instance when debugging
#endif

        public ProjectedCurve(ICurve curve3D, ISurface surface, bool forward, BoundingRect domain, double precision = 0.0)
        {
#if DEBUG
            debugCount = debugCounter++;
#endif
            this.curve3D = curve3D; // keep in mind, the curve is not cloned, curve3D should not be modified after this
            this.surface = surface;
            List <GeoPoint>   lpoles   = new List <GeoPoint>();
            List <GeoPoint2D> lpoles2d = new List <GeoPoint2D>();
            GeoPoint2D        cnt2d    = domain.GetCenter();
            GeoPoint          sp       = curve3D.StartPoint;
            GeoPoint          ep       = curve3D.EndPoint;
            double[]          us       = surface.GetUSingularities();
            double            prec     = precision;
            if (prec == 0.0)
            {
                prec = curve3D.Length * 1e-3;              // changed to 1e-3, it is used to snap endpoints to poles
            }
            startPoint2d = surface.PositionOf(curve3D.StartPoint);
            endPoint2d   = surface.PositionOf(curve3D.EndPoint);
            bool distinctStartEndPoint = false;
            if ((surface.IsUPeriodic && Math.Abs(startPoint2d.x - endPoint2d.x) < surface.UPeriod * 1e-3) ||
                (surface.IsVPeriodic && Math.Abs(startPoint2d.y - endPoint2d.y) < surface.VPeriod * 1e-3))
            {   // adjust start and endpoint according to its neighbors
                GeoPoint2D p2d = surface.PositionOf(curve3D.PointAt(0.1));
                SurfaceHelper.AdjustPeriodic(surface, periodicDomain, ref p2d);
                BoundingRect ext = new BoundingRect(p2d);
                SurfaceHelper.AdjustPeriodic(surface, ext, ref startPoint2d);
                p2d = surface.PositionOf(curve3D.PointAt(0.9));
                SurfaceHelper.AdjustPeriodic(surface, periodicDomain, ref p2d);
                ext = new BoundingRect(p2d);
                SurfaceHelper.AdjustPeriodic(surface, ext, ref endPoint2d);
                distinctStartEndPoint = true;
            }
            periodicDomain = domain;
            if (periodicDomain.IsEmpty() && (surface.IsUPeriodic || surface.IsVPeriodic))
            {
                // make a few points and assure that they don't jump over the periodic seam
                // if the curve3d doesn't jump around wildly, this should work. Maybe use curve3D.GetSavePositions?
                GeoPoint2D[] point2Ds = new GeoPoint2D[11];
                for (int i = 0; i < 11; i++)
                {
                    point2Ds[i] = surface.PositionOf(curve3D.PointAt(i / 10.0));
                }
                for (int i = 0; i < 10; i++)
                {
                    GeoVector2D offset = GeoVector2D.NullVector;
                    if (surface.IsUPeriodic && Math.Abs(point2Ds[i + 1].x - point2Ds[i].x) > surface.UPeriod / 2.0)
                    {
                        if ((point2Ds[i + 1].x - point2Ds[i].x) < 0)
                        {
                            offset.x = surface.UPeriod;
                        }
                        else
                        {
                            offset.x = -surface.UPeriod;
                        }
                    }
                    if (surface.IsVPeriodic && Math.Abs(point2Ds[i + 1].y - point2Ds[i].y) > surface.VPeriod / 2.0)
                    {
                        if ((point2Ds[i + 1].y - point2Ds[i].y) < 0)
                        {
                            offset.y = surface.VPeriod;
                        }
                        else
                        {
                            offset.y = -surface.VPeriod;
                        }
                    }
                    point2Ds[i + 1] += offset;
                }
                for (int i = 0; i < 11; i++)
                {
                    periodicDomain.MinMax(point2Ds[i]);
                }
                startPoint2d = point2Ds[0];
                endPoint2d   = point2Ds[10];
            }
            if (!periodicDomain.IsEmpty() && (!surface.IsUPeriodic || periodicDomain.Width < surface.UPeriod * (1 - 1e-6)) && (!surface.IsVPeriodic || periodicDomain.Height < surface.VPeriod * (1 - 1e-6)))
            {
                SurfaceHelper.AdjustPeriodic(surface, periodicDomain, ref startPoint2d);
                SurfaceHelper.AdjustPeriodic(surface, periodicDomain, ref endPoint2d);
            }
            startPointIsPole = endPointIsPole = false;
            for (int i = 0; i < us.Length; i++)
            {
                GeoPoint pl = surface.PointAt(new GeoPoint2D(us[i], cnt2d.y));
                if ((pl | sp) < prec)
                {
                    GeoPoint2D tmp = surface.PositionOf(curve3D.PointAt(0.1));
                    startPoint2d     = new GeoPoint2D(us[i], tmp.y);
                    startPointIsPole = true;
                    spu = true;
                }
                if ((pl | ep) < prec)
                {
                    GeoPoint2D tmp = surface.PositionOf(curve3D.PointAt(0.9));
                    endPoint2d     = new GeoPoint2D(us[i], tmp.y);
                    endPointIsPole = true;
                    epu            = true;
                }
            }
            double[] vs = surface.GetVSingularities();
            for (int i = 0; i < vs.Length; i++)
            {
                GeoPoint pl = surface.PointAt(new GeoPoint2D(cnt2d.x, vs[i]));
                if ((pl | sp) < prec)
                {
                    GeoPoint2D tmp = surface.PositionOf(curve3D.PointAt(0.1));
                    startPoint2d     = new GeoPoint2D(tmp.x, vs[i]);
                    startPointIsPole = true;
                    spu = false;
                }
                if ((pl | ep) < prec)
                {
                    GeoPoint2D tmp = surface.PositionOf(curve3D.PointAt(0.9));
                    endPoint2d     = new GeoPoint2D(tmp.x, vs[i]);
                    endPointIsPole = true;
                    epu            = false;
                }
            }
            if (forward)
            {
                startParam = 0.0;
                endParam   = 1.0;
            }
            else
            {
                startParam = 1.0;
                endParam   = 0.0;
            }
#if DEBUG
            this.MakeTriangulation();
#endif
        }
Beispiel #24
0
        internal void CenterPatch(LayoutPatch patch, double scale, HorizontalCenter hor, VerticalCenter ver)
        {
            // die Projektion ist ja zwei Anteile, unscaledProjection hält immer den Nullpunkt
            // fest und skaliert nicht, und Placement platziert
            BoundingRect areaext;

            if (patch.Area != null)
            {
                areaext = patch.Area.Extent;
            }
            else
            {
                areaext = new BoundingRect(0.0, 0.0, paperWidth, paperHeight);
            }
            BoundingRect modelext = patch.Model.GetExtent(patch.Projection);

            if (modelext.IsEmpty())
            {
                return;
            }
            GeoPoint2D modelcnt = modelext.GetCenter();
            GeoPoint2D areacnt = areaext.GetCenter();
            double     factor, dx, dy;

            patch.Projection.GetPlacement(out factor, out dx, out dy);
            if (scale != 0.0)
            {
                factor = scale;
            }
            switch (hor)
            {
            case HorizontalCenter.left:
                dx = areaext.Left - (modelext.Left * factor);
                break;

            case HorizontalCenter.center:
                dx = areacnt.x - (modelcnt.x * factor);
                break;

            case HorizontalCenter.right:
                dx = areaext.Right - (modelext.Right * factor);
                break;

            default:
                break;
            }
            switch (ver)
            {
            case VerticalCenter.bottom:
                dy = areaext.Bottom - (modelext.Bottom * factor);
                break;

            case VerticalCenter.center:
                dy = areacnt.y - (modelcnt.y * factor);
                break;

            case VerticalCenter.top:
                dy = areaext.Top - (modelext.Top * factor);
                break;

            default:
                break;
            }
            patch.Projection.SetPlacement(factor, dx, dy);
        }
Beispiel #25
0
 bool IOctTreeInsertable.HitTest(Projection projection, BoundingRect rect, bool onlyInside)
 {   // kommt nicht dran
     throw new NotImplementedException();
 }
Beispiel #26
0
 public void Intersect(ICurve curve, BoundingRect uvExtent, out GeoPoint[] ips, out GeoPoint2D[] uvOnFaces, out double[] uOnCurve3Ds)
 {
     throw new NotImplementedException();
 }