public override void OnButtonDownEvent(InputEvent evt)
        {
            if (evt.IsRButtonDown())
            {
                this.Exit(1);
                return;
            }
            this.RemoveAllTempNodes();

            Renderer rv = GetRenderer();

            PickHelper pickHelper = new PickHelper();

            pickHelper.Initialize(rv);

            if (!pickHelper.Pick(evt.GetMousePosition()))
            {
                return;
            }


            TopoShape   shape   = pickHelper.GetGeometry();
            GeomSurface surface = new GeomSurface();

            if (!surface.Initialize(shape))
            {
                return;
            }

            IntersectionLineSurface intersector = new IntersectionLineSurface();

            intersector.SetSurface(shape);
            if (!intersector.Perform(rv.ComputeScreenRay(evt.GetMousePosition())))
            {
                return;
            }

            int nCount = intersector.GetPointCount();

            if (nCount < 1)
            {
                return;
            }

            double u = intersector.GetParameterU(1);
            double v = intersector.GetParameterV(1);

            Vector3 pt     = surface.Value(u, v);
            Vector3 normal = surface.GetNormal(u, v);

            LineNode lineNode = new LineNode();

            lineNode.Set(pt, pt + normal);

            this.ShowTempNode(lineNode);
            rv.RequestDraw(1);
        }
        public override void OnButtonDownEvent(InputEvent evt)
        {

            if (evt.IsRButtonDown())
            {
                this.Exit(1);
                return;
            }
            this.RemoveAllTempNodes();

            Renderer rv = GetRenderer();

            PickHelper pickHelper = new PickHelper();
            pickHelper.Initialize(rv);

            if (!pickHelper.Pick(evt.GetMousePosition()))
                return;


            TopoShape shape = pickHelper.GetGeometry();
            GeomSurface surface = new GeomSurface();
            if (!surface.Initialize(shape))
                return;

            IntersectionLineSurface intersector = new IntersectionLineSurface();
            intersector.SetSurface(shape);
            if (!intersector.Perform(rv.ComputeScreenRay(evt.GetMousePosition())))
            {
                return;
            }

            int nCount = intersector.GetPointCount();
            if(nCount < 1)
                return;

            float u = intersector.GetParameterU(1);
            float v = intersector.GetParameterV(1);

            Vector3 pt = surface.Value(u, v);
            Vector3 normal = surface.GetNormal(u, v);

            LineNode lineNode = new LineNode();
            lineNode.Set(pt, pt + normal);

            this.ShowTempNode(lineNode);
            rv.RequestDraw(1);
        }
Ejemplo n.º 3
0
        public void drawSpiral(Vector3 startPoint, List<TopoShape> shapes)
        {
            radius = Math.Sqrt((startPoint.X * startPoint.X) + (startPoint.Y * startPoint.Y));
            double b = radius;

            double bx = 0;
            double by = 0;
            decrease = 0.01;
            double countersizeX = Math.Round(radius / decrease);
            cunterarray = 0; //countersizeX;
            int i = 1;
            while (b > 0)
            {
                b = b - (decrease);

                bx = Math.Cos(3 * i * Math.PI / 180) * b;
                double bxsqr = Math.Pow(bx, 2);
                double bsqr = Math.Pow(b, 2);

                by = Math.Sqrt(bsqr - bxsqr);

                // Set y value to negative if degrees is below y = 0
                if (i * 3 > 180 && i * 2 <= 360)
                    by = -1 * by;

                // Trying to get Z index of Shape Point by using spiral coordinate...
                Vector3 to = new Vector3((float)bx, (float)by, (float)1000.0);
                Ray r = new Ray(to, new Vector3(0, 0, -1000));

                for (int ii = 0; ii < shapes.Count; ++ii)
                {
                    IntersectionLineSurface intersector = new IntersectionLineSurface();
                    intersector.SetSurface(shapes[ii]);
                    if (intersector.Perform(r) && intersector.GetPointCount() > 0)
                    {
                        Vector3 intersect = intersector.GetPoint(1);
                        to.Z = intersect.Z;

                        break;
                    }
                }

                cunterarray = cunterarray + 1;
                TopoShape line = GlobalInstance.BrepTools.MakeLine(startPoint, to);
                startPoint = to;
                renderView.ShowGeometry(line, 103);
                i = i * 3 > 356 ? i = 0 : i + 1;
            }
        }