Exemple #1
0
        private void dumpButton_Click(object sender, EventArgs e)
        {
            Entity[] entList = model1.Entities.ToArray();

            for (int i = 0; i < entList.Length; i++)
            {
                Entity ent = entList[i];

                DetailsWindow df;

                StringBuilder sb = new StringBuilder();
#if NURBS
                if (ent is Brep)
                {
                    Brep solid3D = (Brep)ent;

                    switch (model1.SelectionFilterMode)
                    {
                    case selectionFilterType.Vertex:
                        for (int j = 0; j < solid3D.Vertices.Length; j++)
                        {
                            Brep.Vertex sv = (Brep.Vertex)solid3D.Vertices[j];

                            if (solid3D.GetVertexSelection(j))
                            {
                                sb.AppendLine("Vertex ID: " + j);
                                sb.AppendLine(sv.ToString());
                                sb.AppendLine("----------------------");
                                sb.Append(sv.Dump());
                                break;
                            }
                        }
                        break;

                    case selectionFilterType.Edge:
                        for (int j = 0; j < solid3D.Edges.Length; j++)
                        {
                            Brep.Edge se = solid3D.Edges[j];

                            if (solid3D.GetEdgeSelection(j))
                            {
                                sb.AppendLine("Edge ID: " + j);
                                sb.AppendLine(se.ToString());
                                sb.AppendLine("----------------------");
                                sb.Append(se.Dump());
                                break;
                            }
                        }
                        break;

                    case selectionFilterType.Face:

                        for (int j = 0; j < solid3D.Faces.Length; j++)
                        {
                            Brep.Face sf = solid3D.Faces[j];

                            if (solid3D.GetFaceSelection(j))
                            {
                                sb.AppendLine("Face ID: " + j);
                                sb.AppendLine(sf.Surface.ToString());
                                sb.AppendLine("----------------------");
                                sb.Append(sf.Dump());
                                break;
                            }
                        }
                        break;
                    }

                    if (sb.Length > 0)
                    {
                        df = new DetailsWindow();

                        df.contentTextBox.Text = sb.ToString();

                        df.Show();
                        return;
                    }
                }
#endif
                if (ent.Selected)
                {
                    sb.AppendLine("Entity ID: " + i);

                    sb.Append(ent.Dump());

                    df = new DetailsWindow();

                    df.contentTextBox.Text = sb.ToString();

                    df.Show();

                    break;
                }
            }
        }
Exemple #2
0
        private Brep BuildBrep()
        {
            double height = 12;
            double radius = 4;
            double offset = 1.5;

            Point3D[] vertices = new Point3D[4];

            vertices[0] = new Brep.Vertex(radius, 0, 0);
            vertices[1] = new Brep.Vertex(radius, 0, height);

            Brep.Edge[] edges = new Brep.Edge[6];
            Brep.Face[] faces = new Brep.Face[3];

            Circle c1 = new Circle(Plane.XY, radius);

            edges[0] = new Brep.Edge(c1, 0, 0);

            Circle c2 = new Circle(Plane.XY, radius);

            c2.Translate(0, 0, height);
            edges[1] = new Brep.Edge(c2, 1, 1);

            Line l1 = new Line((Point3D)vertices[0].Clone(), (Point3D)vertices[1].Clone());

            edges[2] = new Brep.Edge(l1, 0, 1);

            Brep.OrientedEdge[] bottomLoop = new Brep.OrientedEdge[1];
            bottomLoop[0] = new Brep.OrientedEdge(0, false);


            Brep.OrientedEdge[] sideLoop = new Brep.OrientedEdge[4];

            sideLoop[0] = new Brep.OrientedEdge(0);
            sideLoop[1] = new Brep.OrientedEdge(2);
            sideLoop[2] = new Brep.OrientedEdge(1, false);
            sideLoop[3] = new Brep.OrientedEdge(2, false);


            Brep.OrientedEdge[] topLoop = new Brep.OrientedEdge[1];
            topLoop[0] = new Brep.OrientedEdge(1);


            PlanarSurf      top    = new PlanarSurf(vertices[1], Vector3D.AxisZ, Vector3D.AxisX);
            CylindricalSurf side   = new CylindricalSurf(Point3D.Origin, Vector3D.AxisZ, Vector3D.AxisX, radius);
            PlanarSurf      bottom = new PlanarSurf(vertices[0], Vector3D.AxisZ, Vector3D.AxisX);

            faces[0] = new Brep.Face(bottom, new Brep.Loop(bottomLoop), false);
            faces[1] = new Brep.Face(side, new Brep.Loop(sideLoop));
            faces[2] = new Brep.Face(top, new Brep.Loop(topLoop));


            Brep solid3D = new Brep(vertices, edges, faces);

            // Inner void
            vertices[2] = new Brep.Vertex(radius - offset, 0, offset);
            vertices[3] = new Brep.Vertex(radius - offset, 0, height - offset);

            Circle c11 = new Circle(new Point3D(0, 0, offset), radius - offset);

            edges[3] = new Brep.Edge(c11, 2, 2);

            Circle c22 = new Circle(new Point3D(0, 0, height - offset), radius - offset);

            edges[4] = new Brep.Edge(c22, 3, 3);

            Line l7 = new Line((Point3D)vertices[3].Clone(), (Point3D)vertices[2].Clone());

            edges[5] = new Brep.Edge(l7, 2, 3);

            Brep.OrientedEdge[] voidBottomLoop = new Brep.OrientedEdge[]
            {
                new Brep.OrientedEdge(3)
            };

            Brep.OrientedEdge[] voidSideLoop = new Brep.OrientedEdge[]
            {
                new Brep.OrientedEdge(3, false),
                new Brep.OrientedEdge(5),
                new Brep.OrientedEdge(4),
                new Brep.OrientedEdge(5, false)
            };

            Brep.OrientedEdge[] voidTopLoop = new Brep.OrientedEdge[]
            {
                new Brep.OrientedEdge(4, false)
            };

            PlanarSurf      voidBottom = new PlanarSurf(vertices[2], Vector3D.AxisZ, Vector3D.AxisX);
            CylindricalSurf voidSide   = new CylindricalSurf((Point3D)c11.Center.Clone(), Vector3D.AxisZ, Vector3D.AxisX, radius - offset);
            PlanarSurf      voidTop    = new PlanarSurf(vertices[3], Vector3D.AxisZ, Vector3D.AxisX);

            Brep.Face[] innerVoid = new Brep.Face[]
            {
                new Brep.Face(voidBottom, new Brep.Loop(voidBottomLoop)),
                new Brep.Face(voidSide, new Brep.Loop(voidSideLoop), false),
                new Brep.Face(voidTop, new Brep.Loop(voidTopLoop), false)
            };

            solid3D.Inners = new Brep.Face[][] { innerVoid };

            solid3D.ColorMethod = colorMethodType.byEntity;
            solid3D.Color       = System.Drawing.Color.FromArgb(124, System.Drawing.Color.Red);
            solid3D.Translate(28, 15, -5);

            return(solid3D);
        }