Beispiel #1
0
        public static ushort[] CreateIndexArray(Triangulatable t)
        {
            IList<TriangulationPoint> points = t.Points;
            List<ushort> indices = new List<ushort>();
            foreach (DelaunayTriangle triangle in t.Triangles)
            {
                int[] indexCCW = new[]
                                     {
                                         triangle.IndexCCWFrom(triangle.Points[0]),
                                         triangle.IndexCCWFrom(triangle.Points[1]),
                                         triangle.IndexCCWFrom(triangle.Points[2]),
                                     };

                ushort[] indexArray = new[]
                                       {
                                           (ushort) points.IndexOf(triangle.Points[indexCCW[0]]),
                                           (ushort) points.IndexOf(triangle.Points[indexCCW[1]]),
                                           (ushort) points.IndexOf(triangle.Points[indexCCW[2]]),
                                       };

                indices.AddRange(indexArray);
            }

            //indices.AddRange(new ushort[]
            //                     {
            //                         (ushort)(points.Count - 1),1,0
            //                     });

            return indices.ToArray();
        }
Beispiel #2
0
 public static void Triangulate(TriangulationAlgorithm algorithm, Triangulatable t)
 {
     //        long time = System.nanoTime();
     TriangulationContext tcx = CreateContext(algorithm);
     tcx.PrepareTriangulation(t);
     Triangulate(tcx);
     //        logger.info( "Triangulation of {} points [{}ms]", tcx.getPoints().size(), ( System.nanoTime() - time ) / 1e6 );
 }
 /// <summary>
 /// Add a hole to the polygon.
 /// </summary>
 /// <param name="poly">A subtraction polygon fully contained inside this polygon.</param>
 public void AddHole(Triangulatable poly)
 {
     if (holes == null) holes = new List<Triangulatable>();
     holes.Add(poly);
     // XXX: tests could be made here to be sure it is fully inside
     //        addSubtraction( poly.getPoints() );
 }
Beispiel #4
0
 //public static void Triangulate(Polygon ps) {
 //    TriangulationContext tcx = CreateContext(DefaultAlgorithm);
 //    foreach (Polygon p in ps.Polygons) {
 //        tcx.PrepareTriangulation(p);
 //        Triangulate(tcx);
 //        tcx.Clear();
 //    }
 //}
 public static void Triangulate(Triangulatable p)
 {
     Triangulate(DefaultAlgorithm, p);
 }
 public virtual void PrepareTriangulation(Triangulatable t)
 {
     Triangulatable = t;
     TriangulationMode = t.TriangulationMode;
     t.Prepare(this);
 }