public override bool Run(FeatureContext context)
        {
            // Split box with two spheres.
            TopoShape box     = GlobalInstance.BrepTools.MakeBox(Vector3.ZERO, Vector3.UNIT_Z, new Vector3(150f, 150f, 150f));
            TopoShape sphere  = GlobalInstance.BrepTools.MakeSphere(Vector3.ZERO, 100f);
            TopoShape sphere2 = GlobalInstance.BrepTools.MakeSphere(Vector3.ZERO, 50f);

            TopoShapeGroup tools = new TopoShapeGroup();

            tools.Add(sphere);
            tools.Add(sphere2);
            TopoShape split = GlobalInstance.BrepTools.MakeSplit(box, tools);

            // Display the results with customized face styles.
            TopoExplor     expo   = new TopoExplor();
            TopoShapeGroup bodies = expo.ExplorSolids(split);


            Random random = new Random();

            for (int ii = 0; ii < bodies.Size(); ++ii)
            {
                SceneNode node = context.ShowGeometry(bodies.GetTopoShape(ii));
                FaceStyle fs   = new FaceStyle();
                fs.SetColor(new ColorValue((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble(), 0.5f));
                fs.SetTransparent(true);
                node.SetFaceStyle(fs);
            }

            return(true);
        }
        private void DancingBall_RenderTick()
        {
            timerOfObject += 0.5f;

            //z方向的位移
            heightOfObject = speedOfObject * timerOfObject - (9.8f * timerOfObject * timerOfObject) * 0.5f;
            //x方向的位移
            distanceX += xspeed;
            if (heightOfObject <= 0.0f)
            {
                distanceX     -= xspeed;
                timerOfObject  = 0;
                xspeed         = -xspeed;
                heightOfObject = 10;
            }

            //设置位移矩阵
            Matrix4 trf        = GlobalInstance.MatrixBuilder.MakeTranslate(new Vector3(distanceX, 0, heightOfObject));
            float   scaleValue = heightOfObject * 0.01f + 1;
            Matrix4 scale      = GlobalInstance.MatrixBuilder.MakeScale(new Vector3(scaleValue, scaleValue, scaleValue));

            m_Object.SetTransform(trf * scale);


            // Change color
            fs.SetColor((int)(random.NextDouble() * 100), (int)(random.NextDouble() * 100), (int)(random.NextDouble() * 100));

            m_RenderView.RequestDraw();
        }
示例#3
0
        public void UpdateGeometry()
        {
            if (_VisibleNode == null)
            {
                _VisibleNode = new GroupSceneNode();
                FaceStyle fs = new FaceStyle();
                fs.SetColor(new ColorValue(0, 0, 1.0f, 0.5f));
                fs.SetTransparent(true);
                _VisibleNode.SetFaceStyle(fs);
            }

            _VisibleNode.ClearAll();

            Path.BuildGeometry();

            TopoShape start = GlobalInstance.BrepTools.Extrude(Path.Section, Tool.ZStart, Vector3.UNIT_Z);
            TopoShape end   = GlobalInstance.BrepTools.Extrude(Path.Section, Tool.ZEnd, Vector3.UNIT_Z);

            _VisibleNode.AddNode(GlobalInstance.TopoShapeConvert.ToEntityNode(start, 0.1f));
            _VisibleNode.AddNode(GlobalInstance.TopoShapeConvert.ToEntityNode(end, 0.1f));

            Matrix4 trf = GlobalInstance.MatrixBuilder.MakeTranslate(Tool.Position);

            _VisibleNode.SetTransform(trf);
        }
        public override bool Run(FeatureContext context)
        {
            TopoShape box = GlobalInstance.BrepTools.MakeBox(Vector3.ZERO, Vector3.UNIT_Z, new Vector3(100, 2, 200));

            {
                SceneNode node = context.ShowGeometry(box);
                FaceStyle fs   = new FaceStyle();
                fs.SetColor(new ColorValue(0.5f, 0.5f, 1.0f, 0.5f));
                fs.SetTransparent(true);
                node.SetFaceStyle(fs);
            }
            context.RequestDraw();


            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter = "Texture File (*.jpg;*.png)|*.jpg;*png||";
            if (DialogResult.OK == dlg.ShowDialog())
            {
                SceneNode node2 = context.ShowGeometry(box);
                node2.SetTransform(GlobalInstance.MatrixBuilder.MakeTranslate(new Vector3(0, 50, 0)));
                FaceStyle fs2 = new FaceStyle();
                Texture   tex = new Texture();
                tex.SetName(dlg.SafeFileName);
                tex.SetFilePath(new Path(dlg.FileName));

                fs2.SetTexture(0, tex);

                node2.SetFaceStyle(fs2);
            }

            return(true);
        }
示例#5
0
        public override bool Run(FeatureContext context)
        {
            // build two surfaces
            TopoShape arc   = GlobalInstance.BrepTools.MakeArc(Vector3.ZERO, 100, 0, 135, Vector3.UNIT_Z);
            TopoShape cir   = GlobalInstance.BrepTools.MakeCircle(new Vector3(-200, 0, 0), 50, Vector3.UNIT_X);
            TopoShape surf1 = GlobalInstance.BrepTools.Extrude(arc, 100, Vector3.UNIT_Z);
            TopoShape surf2 = GlobalInstance.BrepTools.Extrude(cir, 400, Vector3.UNIT_X);

            SceneNode n1 = context.ShowGeometry(surf1);
            {
                FaceStyle fs1 = new FaceStyle();
                fs1.SetColor(new ColorValue(0, 0, 0.5f, 0.5f));
                fs1.SetTransparent(true);
                n1.SetFaceStyle(fs1);
            }
            SceneNode n2 = context.ShowGeometry(surf2);
            {
                FaceStyle fs2 = new FaceStyle();
                fs2.SetColor(new ColorValue(0, 0.5f, 0.5f, 0.5f));
                fs2.SetTransparent(true);
                n2.SetFaceStyle(fs2);
            }

            // compute section wire
            TopoShape wire = GlobalInstance.BrepTools.SurfaceSection(surf1, surf2);

            SceneNode sectionNode = context.ShowGeometry(wire);
            LineStyle lineStyle   = new LineStyle();

            lineStyle.SetLineWidth(4);
            lineStyle.SetColor(ColorValue.RED);
            sectionNode.SetLineStyle(lineStyle);

            return(true);
        }
示例#6
0
        public FindWireContext(FeatureContext context)
        {
            _Context = context;
            _LineStyle.SetLineWidth(2);
            _LineStyle.SetColor(255, 0, 0);

            _FaceStyle.SetColor(new ColorValue(0.5f, 0.5f, 0.5f, 0.5f));
            _FaceStyle.SetTransparent(true);
        }
示例#7
0
        private void cylinderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TopoShape cylinder  = GlobalInstance.BrepTools.MakeCylinder(new Vector3(80, 0, 0), new Vector3(0, 0, 1), 20, 100, 315);
            SceneNode sceneNode = renderView.ShowGeometry(cylinder, ++shapeId);
            FaceStyle style     = new FaceStyle();

            style.SetColor(new ColorValue(0.1f, 0.3f, 0.8f, 1));
            sceneNode.SetFaceStyle(style);
        }
示例#8
0
        private void boxToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TopoShape box = renderView.ShapeMaker.MakeBox(new Vector3(40, -20, 0), new Vector3(0, 0, 1), new Vector3(30, 40, 60));

            SceneNode sceneNode = renderView.ShowGeometry(box, ++shapeId);

            FaceStyle style = new FaceStyle();
            style.SetColor(new ColorValue(0.5f, 0.3f, 0, 1));
            sceneNode.SetFaceStyle(style);
        }
示例#9
0
        /// <summary>
        /// 绘制坐标轴
        /// </summary>
        private void CreatAxis()
        {
            try
            {
                Size   pnlCanvasSize = pnlMain.Size;
                float  AxisHeight    = 50;
                double Lenth         = 20;

                //X轴
                TopoShape CylindeX      = shapeMaker.MakeCylinder(new Vector3(-pnlCanvasSize.Width, -pnlCanvasSize.Height, AxisHeight), new Vector3(1, 0, 0), 1, Lenth, 360);
                FaceStyle CylindeXStyle = new FaceStyle();
                CylindeXStyle.SetColor(new ColorValue(2.55f, 2.55f, 0f, 1));
                SceneNode sceneNode = ShowTopoShape(CylindeX);
                sceneNode.SetFaceStyle(CylindeXStyle);
                TopoShape ConeX      = shapeMaker.MakeCone(new Vector3(-pnlCanvasSize.Width + (float)Lenth, -pnlCanvasSize.Height, AxisHeight), new Vector3(1, 0, 0), 2, 5, 0, 360);
                FaceStyle ConeXStyle = new FaceStyle();
                ConeXStyle.SetColor(new ColorValue(2.55f, 2.55f, 0f, 1));
                SceneNode sceneNodeConeX = ShowTopoShape(ConeX);
                sceneNodeConeX.SetFaceStyle(ConeXStyle);
                //Y轴
                TopoShape CylindeY      = shapeMaker.MakeCylinder(new Vector3(-pnlCanvasSize.Width, -pnlCanvasSize.Height, AxisHeight), new Vector3(0, 1, 0), 1, Lenth, 360);
                FaceStyle CylindeYStyle = new FaceStyle();
                CylindeYStyle.SetColor(new ColorValue(2.55f, 0.48f, 0.48f, 1));
                SceneNode sceneNodeX = ShowTopoShape(CylindeY);
                sceneNodeX.SetFaceStyle(CylindeYStyle);

                TopoShape ConeY      = shapeMaker.MakeCone(new Vector3(-pnlCanvasSize.Width, -pnlCanvasSize.Height + (float)Lenth, AxisHeight), new Vector3(0, 1, 0), 2, 5, 0, 360);
                FaceStyle ConeYStyle = new FaceStyle();
                ConeYStyle.SetColor(new ColorValue(2.55f, 0.48f, 0.48f, 1));
                SceneNode sceneNodeConeY = ShowTopoShape(ConeY);
                sceneNodeConeY.SetFaceStyle(ConeYStyle);

                //Z轴
                TopoShape CylindeZ      = shapeMaker.MakeCylinder(new Vector3(-pnlCanvasSize.Width, -pnlCanvasSize.Height, AxisHeight), new Vector3(0, 0, 1), 1, Lenth, 360);
                FaceStyle CylindeZStyle = new FaceStyle();
                CylindeZStyle.SetColor(new ColorValue(0.3f, 1.3f, 0.3f, 1));
                SceneNode sceneNodeZ = ShowTopoShape(CylindeZ);
                sceneNodeZ.SetFaceStyle(CylindeZStyle);

                TopoShape ConeZ      = shapeMaker.MakeCone(new Vector3(-pnlCanvasSize.Width, -pnlCanvasSize.Height, AxisHeight + (float)Lenth), new Vector3(0, 0, 1), 2, 5, 0, 360);
                FaceStyle ConeZStyle = new FaceStyle();
                ConeZStyle.SetColor(new ColorValue(0.3f, 1.3f, 0.3f, 1));
                SceneNode sceneNodeConeZ = ShowTopoShape(ConeZ);
                sceneNodeConeZ.SetFaceStyle(ConeZStyle);

                //重新绘制地面
                //TopoShape GroundShap = shapeMaker.MakeBox(new Vector3(-pnlCanvasSize.Width, pnlCanvasSize.Height, 0), new Vector3(pnlCanvasSize.Width, pnlCanvasSize.Height, 0), Width, GroudHeight);
                //FaceStyle GroundShapStyle = new FaceStyle();
                //GroundShapStyle.SetColor(new ColorValue(0.47f, 0.79f, 0.79f, 1));
                //SceneNode sceneNodeGround = ShowTopoShape(GroundShap);
                //sceneNodeGround.SetFaceStyle(GroundShapStyle);
            }
            catch (Exception ex)
            { throw ex; }
        }
示例#10
0
        private void boxToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TopoShape box = renderView.ShapeMaker.MakeBox(new Vector3(40, -20, 0), new Vector3(0, 0, 1), new Vector3(30, 40, 60));

            SceneNode sceneNode = renderView.ShowGeometry(box, ++shapeId);

            FaceStyle style = new FaceStyle();

            style.SetColor(new ColorValue(0.5f, 0.3f, 0, 1));
            sceneNode.SetFaceStyle(style);
        }
示例#11
0
        public TubeSystem()
        {
            Bolt = new BoltElement(100);
            Nut  = new NutElement(101);

            RedStyle = new FaceStyle();
            RedStyle.SetColor(255, 100, 100);

            BlueStyle = new FaceStyle();
            BlueStyle.SetColor(100, 100, 255);
        }
示例#12
0
        public override void OnSetFaceColor(ColorValue clr)
        {
            if (clr.ToRGBA() == faceStyle.GetColor().ToRGBA())
            {
                return;
            }

            if (!faceStyleDict.TryGetValue(clr.ToRGBA(), out faceStyle))
            {
                faceStyle = new FaceStyle();
                faceStyle.SetColor(clr);
                faceStyleDict.Add(clr.ToRGBA(), faceStyle);
            }
        }
        public override bool Run(FeatureContext context)
        {
            TopoShape oCircle1    = GlobalInstance.BrepTools.MakeCircle(Vector3.ZERO, 20, Vector3.UNIT_Z);
            TopoShape Pipe01_Surf = GlobalInstance.BrepTools.Extrude(oCircle1, 100, Vector3.UNIT_Z);

            context.ShowGeometry(Pipe01_Surf);

            TopoShape oCircle2    = GlobalInstance.BrepTools.MakeCircle(new Vector3(0.0f, 0.0f, 50.0f), 10, Vector3.UNIT_Y);
            TopoShape Pipe02_Surf = GlobalInstance.BrepTools.Extrude(oCircle2, 80, Vector3.UNIT_Y);
            {
                SceneNode node2 = context.ShowGeometry(Pipe02_Surf);
                FaceStyle fs    = new FaceStyle();
                fs.SetColor(new ColorValue(0.5f, 0.5f, 0.5f, 0.5f));
                fs.SetTransparent(true);
                node2.SetFaceStyle(fs);
            }

            // Compute the intersection curve
            TopoShape Inters1 = GlobalInstance.BrepTools.SurfaceSection(Pipe01_Surf, Pipe02_Surf);

            if (Inters1 != null)
            {
                SceneNode node = context.ShowGeometry(Inters1);
                LineStyle ls   = new LineStyle();
                ls.SetLineWidth(3);
                ls.SetColor(ColorValue.RED);
                node.SetLineStyle(ls);

                // Get the curve parameters
                GeomCurve curve = new GeomCurve();
                if (curve.Initialize(Inters1))
                {
                    LineStyle ls2 = new LineStyle();
                    ls2.SetColor(ColorValue.GREEN);

                    double start = curve.FirstParameter();
                    double end   = curve.LastParameter();
                    for (double ii = start; ii <= end; ii += 0.1)
                    {
                        List <Vector3> rt = curve.D1(ii);
                        LineNode       ln = new LineNode();
                        ln.SetLineStyle(ls2);
                        ln.Set(rt[0], rt[0] + rt[1]);
                        context.ShowSceneNode(ln);
                    }
                }
            }

            return(true);
        }
示例#14
0
        public CADBrower(System.Windows.Forms.TreeView _treeView, AnyCAD.Presentation.RenderWindow3d _renderView)
        {
            treeView   = _treeView;
            renderView = _renderView;
            faceStyle  = new FaceStyle();
            holeStyle  = new LineStyle();
            holeStyle.SetLineWidth(3);
            holeStyle.SetColor(0, 256, 0);

            System.Windows.Forms.TreeNode node = treeView.Nodes.Add("AnyCAD.net");
            nodeStack.Push(node);

            revolutionStyle = new FaceStyle();
            revolutionStyle.SetColor(255, 0, 0);
        }
示例#15
0
        private void timer_shine_Tick(object sender, EventArgs e)
        {
            n++;
            if (this.renderView != null && this.renderView.SceneManager == null)
            {
                return;
            }
            lock (objlock)
            {
                if (position_list != null)
                {
                    foreach (string ca in position_list)
                    {
                        int index = 0;
                        if (!int.TryParse(ca, out index))
                        {
                            continue;
                        }
                        SceneNode node = this.renderView.SceneManager.FindNode(new ElementId(index));

                        if (node != null)
                        {
                            FaceStyle value = null;
                            if (key_colors.TryGetValue(index, out value))
                            {
                                if (n % 2 == 0)
                                {
                                    node.SetFaceStyle(value);
                                }
                                else
                                {
                                    FaceStyle fa = new FaceStyle();
                                    fa.SetColor(new ColorValue(1, 1, 1));
                                    node.SetFaceStyle(fa);
                                }
                            }
                            else
                            {
                                FaceStyle cur_sty = node.GetFaceStyle();
                                key_colors.Add(index, cur_sty);
                            }
                        }
                    }
                }
            }
        }
示例#16
0
        public override void OnSetFaceColor(ColorValue clr)
        {
            if (clr.ToRGBA() == faceStyle.GetColor().ToRGBA())
                return;

            FaceStyle fs = null;
            if (!faceStyleDict.TryGetValue(clr.ToRGBA(), out fs))
            {
                fs = new FaceStyle();
                fs.SetColor(clr);
                faceStyleDict.Add(clr.ToRGBA(), fs);
            }

            faceStyle = fs;

            fileSys.WriteLine(String.Format("{0} {1} {2}", clr.R, clr.G, clr.B));
            fileSys.Flush();
        }
示例#17
0
        public override void OnSetFaceColor(ColorValue clr)
        {
            if (clr.ToRGBA() == faceStyle.GetColor().ToRGBA())
            {
                return;
            }

            FaceStyle fs = null;

            if (!faceStyleDict.TryGetValue(clr.ToRGBA(), out fs))
            {
                fs = new FaceStyle();
                fs.SetColor(clr);
                faceStyleDict.Add(clr.ToRGBA(), fs);
            }

            faceStyle = fs;
        }
        public override bool Run(FeatureContext context)
        {
            TopoShape tube = GlobalInstance.BrepTools.MakeTube(Vector3.ZERO, Vector3.UNIT_Z, 8, 2, 100);

            TopoShape cyl = GlobalInstance.BrepTools.MakeCylinder(new Vector3(0, 0, 50), Vector3.UNIT_X, 5, 10, 0);
            {
                SceneNode node = context.ShowGeometry(cyl);
                FaceStyle fs   = new FaceStyle();
                fs.SetColor(new ColorValue(0.5f, 0.5f, 0, 0.5f));
                fs.SetTransparent(true);
                node.SetFaceStyle(fs);
            }

            TopoShape cut = GlobalInstance.BrepTools.BooleanCut(tube, cyl);

            context.ShowGeometry(cut);

            return(true);
        }
        public override bool Run(FeatureContext context)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter = "STL (*.stl)|*.stl|IGES (*.igs;*.iges)|*.igs;*.iges|STEP (*.stp;*.step)|*.stp;*.step|BREP (*.brep)|*.brep|All Files(*.*)|*.*";

            if (DialogResult.OK != dlg.ShowDialog())
            {
                return(false);
            }

            context.RenderView.RenderTimer.Enabled = false;
            TopoShape shape = GlobalInstance.BrepTools.LoadFile(new AnyCAD.Platform.Path(dlg.FileName));

            context.RenderView.RenderTimer.Enabled = true;
            MessageBox.Show("loaded");
            if (shape != null)
            {
                //context.ShowGeometry(shape, new ElementId(100));
                //GlobalInstance.BrepTools.SaveFile(shape, new Path(dlg.FileName + ".brep"));

                AABox     bbox     = shape.GetBBox();
                Vector3   size     = bbox.Size();
                Vector3   start    = new Vector3(bbox.MinPt.X - 10, bbox.MinPt.Y + size.Y * 0.5f, bbox.MinPt.Z - 10);
                TopoShape boxShape = GlobalInstance.BrepTools.MakeBox(start, Vector3.UNIT_Z, new Vector3(size.X + 20, size.Y * 0.25f, size.Z + 20));

                shape = GlobalInstance.BrepTools.BooleanCut(shape, boxShape);

                MessageBox.Show("cut!");
                var groups = GlobalInstance.TopoExplor.ExplorSubShapes(shape);
                for (int ii = 0, len = groups.Size(); ii < len; ++ii)
                {
                    shape = groups.GetAt(ii);
                    var node = context.ShowGeometry(shape, new ElementId(100));
                    var fs   = new FaceStyle();
                    fs.SetColor(ii * 100, 0, ii + 200);
                    node.SetFaceStyle(fs);
                }
            }
            return(true);
        }
示例#20
0
 private void cylinderToolStripMenuItem_Click(object sender, EventArgs e)
 {
     TopoShape cylinder = renderView.ShapeMaker.MakeCylinder(new Vector3(80, 0, 0), new Vector3(0, 0, 1), 20, 100, 315);
     SceneNode sceneNode = renderView.ShowGeometry(cylinder, ++shapeId);
     FaceStyle style = new FaceStyle();
     style.SetColor(new ColorValue(0.1f, 0.3f, 0.8f, 1));
     sceneNode.SetFaceStyle(style);
 }
示例#21
0
        private void splitToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            TopoShape box = GlobalInstance.BrepTools.MakeBox(Vector3.ZERO, Vector3.UNIT_Z, new Vector3(150f, 150f, 150f));
            TopoShape sphere = GlobalInstance.BrepTools.MakeSphere(Vector3.ZERO, 100f);
            TopoShape sphere2 = GlobalInstance.BrepTools.MakeSphere(Vector3.ZERO, 50f);

            TopoShapeGroup tools = new TopoShapeGroup();
            tools.Add(sphere);
            tools.Add(sphere2);
            TopoShape split = GlobalInstance.BrepTools.MakeSplit(box, tools);


            TopoExplor expo = new TopoExplor();
            TopoShapeGroup faces = expo.ExplorFaces(split);
            TopoShapeGroup bodies = expo.ExplorSolids(split);


            Random random = new Random();
            for (int ii = 0; ii < bodies.Size(); ++ii)
            {
                SceneNode node = renderView.ShowGeometry(bodies.GetTopoShape(ii), ++shapeId);
                FaceStyle fs = new FaceStyle();
                fs.SetColor(new ColorValue((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble(), 0.5f));
                fs.SetTransparent(true);
                node.SetFaceStyle(fs);
            }


            renderView.RequestDraw();

            MessageBox.Show(String.Format("Face: {0} Solid: {1}", faces.Size(), bodies.Size()));

        }
示例#22
0
        private void rectangleRToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TopoShape rect = GlobalInstance.BrepTools.MakeRectangle(100, 50, 10, Coordinate3.UNIT_XYZ);
            rect = GlobalInstance.BrepTools.MakeFace(rect);

            SceneNode node = renderView.ShowGeometry(rect, ++shapeId);
            Texture texture = new Texture();
            texture.SetName("mytexture");
            texture.SetFilePath(new AnyCAD.Platform.Path("f:\\dimian.png"));

            FaceStyle style = new FaceStyle();
            style.SetTexture(0, texture);
            style.SetColor(255, 255, 255);
            node.SetFaceStyle(style);


            TopoShape line = GlobalInstance.BrepTools.MakeLine(Vector3.ZERO, new Vector3(0, 0, 100));
            TopoShape face = GlobalInstance.BrepTools.Extrude(line, 100, Vector3.UNIT_X);
            renderView.ShowGeometry(face, ++shapeId);
        }
示例#23
0
        /// <summary>
        /// 加载AGV调度系统地图
        /// </summary>
        public bool LoadAGVDispatchMap()
        {
            try
            {
                //将所有的地标抽离为3D物体
                IList <LandMarkShap> LandShaps = AGVDAccess.AGVSimulationDAccess.LoadLandShaps();
                if (LandShaps != null && LandShaps.Count > 0)
                {
                    foreach (LandMarkShap landShap in LandShaps)
                    {
                        float     X             = (float)Math.Round(landShap.LandX, 1) * 40f + (0.05f * 40f);
                        float     Y             = (float)Math.Round(landShap.LandY, 1) * 40f - (0.1f * 40f);
                        TopoShape LandShap      = shapeMaker.MakeCylinder(new Vector3(X, Y, 0f), new Vector3(0, 0, 1), 0.1f * 40f, GroudHeight + 0.3, 360);
                        FaceStyle LandShapStyle = new FaceStyle();
                        LandShapStyle.SetColor(new ColorValue(0f, 0f, 0f, 1));
                        SceneNode sceneNodeLandShap = ShowTopoShape(LandShap);
                        sceneNodeLandShap.SetFaceStyle(LandShapStyle);
                    }
                }
                //将所有路径
                IList <AllSegment> AllSegments = AGVDAccess.AGVClientDAccess.LoadAllSegment();
                if (AllSegments != null && AllSegments.Count > 0)
                {
                    foreach (AllSegment Segment in AllSegments)
                    {
                        LandMarkShap BeinLand = LandShaps.FirstOrDefault(p => p.LandmarkCode == Segment.BeginLandMakCode);
                        LandMarkShap EndLand  = LandShaps.FirstOrDefault(p => p.LandmarkCode == Segment.EndLandMarkCode);
                        if (BeinLand != null && EndLand != null)
                        {
                            float BeginX = (float)Math.Round(BeinLand.LandX, 1) * 40f + (0.05f * 40f);
                            float BeginY = (float)Math.Round(BeinLand.LandY, 1) * 40f - (0.1f * 40f);
                            float EndX   = (float)Math.Round(EndLand.LandX, 1) * 40f + (0.05f * 40f);
                            float EndY   = (float)Math.Round(EndLand.LandY, 1) * 40f - (0.1f * 40f);
                            if (Segment.SegmentType == 0)//直线
                            {
                                TopoShape RouteShap  = shapeMaker.MakeRoad(new Vector3(BeginX, BeginY, 0), new Vector3(EndX, EndY, 0), 2, GroudHeight + 0.2, 0.2, false);
                                FaceStyle RouteStyle = new FaceStyle();
                                RouteStyle.SetColor(new ColorValue(2.05f, 1.73f, 0f, 1));
                                SceneNode sceneNodeRouteShap = ShowTopoShape(RouteShap);
                                sceneNodeRouteShap.SetFaceStyle(RouteStyle);
                            }
                            else if (Segment.SegmentType == 1)//圆弧线
                            {
                                try
                                {
                                    PointF p1 = new PointF(BeginX, BeginY);
                                    PointF p2 = new PointF(EndX, EndY);
                                    PointF p3 = new PointF((float)(Segment.Point3X * 40f), (float)(Segment.Point3Y * 40));
                                    PointF p4 = new PointF((float)(Segment.Point4X * 40f), (float)(Segment.Point4Y * 40));

                                    PointF[] pointList = new PointF[] { p1, p4, p3, p2 };
                                    PointF[] list      = draw_bezier_curves(pointList, pointList.Length, 0.001f * 40);
                                    PointF[] unitlist  = list.Where(p => p.X != p3.X && p.Y != p3.Y && p.X != p4.X && p.Y != p4.Y).ToArray();
                                    for (int i = 1; i < list.Length; i++)
                                    {
                                        TopoShape RouteShap  = shapeMaker.MakeRoad(new Vector3(unitlist[i - 1].X, unitlist[i - 1].Y, 0), new Vector3(unitlist[i].X, unitlist[i].Y, 0), 2, GroudHeight + 0.2, 0.2, false);
                                        FaceStyle RouteStyle = new FaceStyle();
                                        RouteStyle.SetColor(new ColorValue(2.05f, 1.73f, 0f, 1));
                                        SceneNode sceneArc = ShowTopoShape(RouteShap);
                                        sceneArc.SetFaceStyle(RouteStyle);
                                    }
                                }
                                catch (Exception ex)
                                { }
                            }
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            { throw ex; }
        }
示例#24
0
        private void CreatCarModeByCarInfos()
        {
            try
            {
                //PointF CarP1 = new PointF();


                //float BeginX = (float)Math.Round(BeinLand.LandX, 1) * 40f + (0.05f * 40f);
                //float BeginY = (float)Math.Round(BeinLand.LandY, 1) * 40f - (0.1f * 40f);
                //float EndX = (float)Math.Round(EndLand.LandX, 1) * 40f + (0.05f * 40f);
                //float EndY = (float)Math.Round(EndLand.LandY, 1) * 40f - (0.1f * 40f);
                //if (Segment.SegmentType == 0)//直线
                //{
                //    TopoShape RouteShap = shapeMaker.MakeRoad(new Vector3(BeginX, BeginY, 0), new Vector3(EndX, EndY, 0), 2, GroudHeight + 0.2, 0.2, false);
                //    FaceStyle RouteStyle = new FaceStyle();
                //    RouteStyle.SetColor(new ColorValue(2.05f, 1.73f, 0f, 1));
                //    SceneNode sceneNodeRouteShap = ShowTopoShape(RouteShap);
                //    sceneNodeRouteShap.SetFaceStyle(RouteStyle);
                //}



                //IList<CarInfo> CarShaps = AGVDAccess.AGVSimulationDAccess.LoadCarShap();
                //if (CarShaps != null && CarShaps.Count > 0)
                //{
                //    foreach (CarInfo car in CarShaps)
                //    {
                //    }
                //}



                //testCarShap
                double    CarLenth       = 25;
                double    CarWidth       = 10;
                double    CarHeight      = 4;
                PointF    CarPoint       = new PointF(80, -300);
                TopoShape FrmackBoxShap  = shapeMaker.MakeBox(new Vector3(CarPoint.X, CarPoint.Y, 0), new Vector3(CarPoint.X + (float)CarLenth, CarPoint.Y, 0), CarWidth, CarHeight);
                FaceStyle FrmackBoxStyle = new FaceStyle();
                FrmackBoxStyle.SetColor(new ColorValue(0.3f, 1.44f, 2.55f, 1));
                SceneNode sceneFrmackBox = ShowTopoShape(FrmackBoxShap);
                sceneFrmackBox.SetFaceStyle(FrmackBoxStyle);


                TopoShape TrayBoxShap  = shapeMaker.MakeBox(new Vector3(CarPoint.X + 1, CarPoint.Y, (float)CarHeight - 1), new Vector3(CarPoint.X + (float)CarLenth - 1, CarPoint.Y, (float)CarHeight - 1), CarWidth - 0.5, 1.2);
                FaceStyle TrayBoxStyle = new FaceStyle();
                TrayBoxStyle.SetColor(new ColorValue(1.05f, 1.05f, 1.05f, 1));
                SceneNode sceneTrayBox = ShowTopoShape(TrayBoxShap);
                sceneTrayBox.SetFaceStyle(TrayBoxStyle);

                TopoShape wheelShap1 = shapeMaker.MakeCone(new Vector3(CarPoint.X + (float)CarLenth / 4f, CarPoint.Y - (float)CarWidth / 2f - 0.1f, (float)CarHeight / 3), new Vector3(0, 1, 0), (float)CarHeight / 4 * 2, 0.5, 0, 360);
                FaceStyle wheelStyle = new FaceStyle();
                wheelStyle.SetColor(new ColorValue(0f, 0f, 0f, 1));
                SceneNode scenewheel = ShowTopoShape(wheelShap1);
                scenewheel.SetFaceStyle(wheelStyle);


                TopoShape wheelShap2  = shapeMaker.MakeCone(new Vector3(CarPoint.X + (float)CarLenth / 4f * 3, CarPoint.Y - (float)CarWidth / 2f - 0.1f, (float)CarHeight / 3), new Vector3(0, 1, 0), (float)CarHeight / 4 * 2, 0.5, 0, 360);
                FaceStyle wheelStyle2 = new FaceStyle();
                wheelStyle2.SetColor(new ColorValue(2.55f, 0.48f, 0.48f, 1));
                SceneNode scenewhee2 = ShowTopoShape(wheelShap2);
                scenewhee2.SetFaceStyle(wheelStyle2);

                TopoShape wheelShap3  = shapeMaker.MakeCone(new Vector3(CarPoint.X + (float)CarLenth / 4f, CarPoint.Y + (float)CarWidth / 2f + 0.1f, (float)CarHeight / 3), new Vector3(0, -1, 0), (float)CarHeight / 4 * 2, 0.5, 0, 360);
                FaceStyle wheelStyle3 = new FaceStyle();
                wheelStyle3.SetColor(new ColorValue(2.55f, 0.48f, 0.48f, 1));
                SceneNode scenewheel3 = ShowTopoShape(wheelShap3);
                scenewheel3.SetFaceStyle(wheelStyle3);

                TopoShape wheelShap4  = shapeMaker.MakeCone(new Vector3(CarPoint.X + (float)CarLenth / 4f * 3, CarPoint.Y + (float)CarWidth / 2f + 0.1f, (float)CarHeight / 3), new Vector3(0, -1, 0), (float)CarHeight / 4 * 2, 0.5, 0, 360);
                FaceStyle wheelStyle4 = new FaceStyle();
                wheelStyle4.SetColor(new ColorValue(2.55f, 0.48f, 0.48f, 1));
                SceneNode scenewheel4 = ShowTopoShape(wheelShap4);
                scenewheel4.SetFaceStyle(wheelStyle4);
            }
            catch (Exception ex)
            { throw ex; }
        }