Exemple #1
0
        //------------------------------------------------

        public void SimplifyMesh(double threshold, TraceListener log, bool verbose)
        {
            var    edgePoints = EdgeIndices.Select(p => Vertices[p]).ToArray();
            double fudgeSq    = double.MaxValue;

            for (int i = 1; i < edgePoints.Length; i++)
            {
                var d = edgePoints[i].DeltaSq(ref edgePoints[i - 1]);
                if (d > 1.0E-10)
                {
                    fudgeSq = Math.Min(fudgeSq, d);
                }
            }

            fudgeSq /= 100.0;
            var mdFinal = new SimplifyMesh(log, Vertices, TriangleIndices, EdgeIndices, verbose);

            mdFinal.SimplifyMeshByThreshold(threshold);
            Vertices        = mdFinal.GetVertices();
            TriangleIndices = mdFinal.GetIndices();
            VertexNormals   = mdFinal.GetVertexNormals();
            EdgeIndices     = mdFinal.GetEdgeIndices();
            mdFinal         = null;

            VertexToImage = new Vector2d[Vertices.Length];
            GeoPolar3d buffGeoPolar = new GeoPolar3d();

            for (int i = 0; i < VertexToImage.Length; i++)
            {
                InvertTo(ref Vertices[i], ref VertexToImage[i], ref buffGeoPolar);
            }
        }
Exemple #2
0
 private void LogPossessionGraph(Action <string> log)
 {
     EdgeIndices.Execute(kvp =>
     {
         log(string.Format("{0} can pass to: ", kvp.Key.LastName));
         kvp.Value.Execute(n =>
                           log(string.Format("\t{0} at cost {1}", n.Vertex.LastName, n.Cost))
                           );
     });
 }
Exemple #3
0
        private static IRing StitchPaths(this IPath[] paths, EdgeIndices edgeIndices)
        {
            IRing result = new Ring();

            foreach (var edgeIndex in edgeIndices)
            {
                var path = paths[edgeIndex];
                if (path.PointCount == 0)
                {
                    continue;
                }

                if (result.PointCount == 0)
                {
                    result.AddPoints(path.ToArray());
                }
                else
                {
                    var lastPoint = result[result.PointCount - 1];
                    if (lastPoint.Equals(path[0]))
                    {
                        result.AddPoints(path.ToArray(1));
                    }
                    else if (lastPoint.Equals(path[path.PointCount - 1]))
                    {
                        result.AddPoints(path.ToArray(1, true));
                    }
                    else
                    {
                        throw new Exception("Can't stitch path to ring");
                    }
                }
            }

            return(result);
        }
Exemple #4
0
 private static bool Contains(this IEnumerable <EdgeIndices> bag, EdgeIndices indices)
 {
     return(bag.Where(i => i.Equals(indices)).FirstOrDefault() != null);
 }