Ejemplo n.º 1
0
        /// <summary>
        /// unstable method, the level is 10
        /// </summary>
        public Mesh ComputeMeshTree(List<Line> x, Point3d y,double firstEnergy,double EnergyDecrease)
        {
            Vertice1.CreateCollection(x, out this.id, out this.vs);
            for (int i = 0; i < vs.Count; i++)
            {
                if (vs[i].equalTo(y)) { vs[i].energy = firstEnergy; break; }
            }
            for (int i = 0; i < 40; i++)
            {
                vs.ForEach(delegate(Vertice1 v) { v.transferenergy(EnergyDecrease, ref vs); });
            }

            for (int i = 0; i < vs.Count; i++)
            {
                vs[i].CrateEdges(vs);
                //Print(vs[i].edges.Count.ToString());
            }
            ////////////////

            Mesh mesh = new Mesh();
            for (int i = 0; i < id.Count; i++)
            {
                Polyline pl1 = new Polyline(); Polyline pl2 = new Polyline();
                if (vs[id[i].J].refer.Count == 3)
                {
                    for (int j = 0; j < 3; j++)
                    {
                        if (vs[id[i].J].refer[j] == id[i].I)
                        {
                            pl1 = vs[id[i].J].edges[j]; break;
                        }
                    }
                }
                if (vs[id[i].I].refer.Count == 3)
                {
                    for (int j = 0; j < 3; j++)
                    {
                        if (vs[id[i].I].refer[j] == id[i].J)
                        {
                            pl2 = vs[id[i].I].edges[j]; break;
                        }
                    }
                }
                //Print(pl1.Count.ToString());
                if (pl1.Count == 4 && pl2.Count == 0)
                {
                    Plane p = new Plane(vs[id[i].I].pos, vs[vs[id[i].I].refer[0]].pos - vs[id[i].I].pos);
                    pl2.AddRange(pl1);
                    pl2.Transform(Transform.PlanarProjection(p));

                }
                if (pl1.Count == 0 && pl2.Count == 4)
                {
                    Plane p = new Plane(vs[id[i].J].pos, vs[vs[id[i].J].refer[0]].pos - vs[id[i].J].pos);
                    pl1.AddRange(pl2);
                    pl1.Transform(Transform.PlanarProjection(p));

                }
                if (pl1.Count == 4 && pl2.Count == 4)
                {

                    Plane p1 = new Plane(pl1[0], pl1[1], pl1[2]);
                    Plane p2 = new Plane(pl2[0], pl2[1], pl2[2]);
                    if (Vector3d.VectorAngle(p1.Normal, p2.Normal) > Math.PI / 2) pl2.Reverse();
                    mesh.Append(mc.ClosedBridge(pl1, pl2));

                }
            }

              return mesh;
        }
Ejemplo n.º 2
0
 public Mesh MeshTorus(Circle c, double t)
 {
     double cut = 64;
     List<Polyline> ls2 = new List<Polyline>();
     for (int i = 0; i < cut; i++)
     {
         List<Point3d> ls = new List<Point3d>();
         ls.Add(new Point3d(1, 0, 0));
         ls.Add(new Point3d(0.707, 0, 0.707));
         ls.Add(new Point3d(0, 0, 1));
         ls.Add(new Point3d(-0.707, 0, 0.707));
         ls.Add(new Point3d(-1, 0, 0));
         ls.Add(new Point3d(-0.707, 0, -0.707));
         ls.Add(new Point3d(0, 0, -1));
         ls.Add(new Point3d(0.707, 0, -0.707));
         Polyline l1 = new Polyline();
         l1.AddRange(ls);
         l1.Reverse();
         l1.Transform(Transform.Scale(Point3d.Origin, t));
         //l1.Transform(Transform.Translation(new Vector3d(c.Radius - t, 0, 0)));
         l1.Transform(Transform.Translation(new Vector3d(c.Radius, 0, 0)));
         l1.Transform(Transform.Rotation(Math.PI / (double)cut * 2 * i, Point3d.Origin));
         ls2.Add(l1);
     }
     Mesh mesh1 = MeshLoft(ls2, true, true);
     mesh1.Transform(Transform.PlaneToPlane(Plane.WorldXY, c.Plane));
     return mesh1;
 }