Пример #1
0
 public DxfMeshLoader(IVertexFactory vertexFactory, IFaceFactory faceFactory)
 {
   if (vertexFactory == null) throw new ArgumentNullException("vertexFactory");
   if (faceFactory == null) throw new ArgumentNullException("faceFactory");
   _vertexFactory = vertexFactory;
   _faceFactory = faceFactory;
 }
Пример #2
0
 public MultiSourceSinkGraphAugmentorAlgorithm(
     IMutableBidirectionalGraph <TVertex, TEdge> visitedGraph,
     IVertexFactory <TVertex> vertexFactory,
     IEdgeFactory <TVertex, TEdge> edgeFactory)
     : this(null, visitedGraph, vertexFactory, edgeFactory)
 {
 }
Пример #3
0
 public MultiSourceSinkGraphAugmentorAlgorithm(
     IAlgorithmComponent host,
     IMutableBidirectionalGraph <TVertex, TEdge> visitedGraph,
     IVertexFactory <TVertex> vertexFactory,
     IEdgeFactory <TVertex, TEdge> edgeFactory)
     : base(host, visitedGraph, vertexFactory, edgeFactory)
 {
 }
Пример #4
0
 public AllVerticesGraphAugmentorAlgorithm(
     IMutableVertexAndEdgeListGraph <TVertex, TEdge> visitedGraph,
     IVertexFactory <TVertex> vertexFactory,
     IEdgeFactory <TVertex, TEdge> edgeFactory
     )
     : this(null, visitedGraph, vertexFactory, edgeFactory)
 {
 }
Пример #5
0
 public AllVerticesGraphAugmentorAlgorithm(
     IAlgorithmComponent host,
     IMutableVertexAndEdgeListGraph <TVertex, TEdge> visitedGraph,
     IVertexFactory <TVertex> vertexFactory,
     IEdgeFactory <TVertex, TEdge> edgeFactory
     )
     : base(host, visitedGraph, vertexFactory, edgeFactory)
 {
 }
Пример #6
0
 public NodeParser(IHyperLinkParser hyperLinkParser, IVertexFactory vertexFactory,
                   IProfileFactory profileFactory, IVertexCache cache, IPause pause)
 {
     _hyperLinkParser = hyperLinkParser;
     _vertexFactory   = vertexFactory;
     _profileFactory  = profileFactory;
     _cache           = cache;
     _pause           = pause;
 }
Пример #7
0
 public GraphAssemblerTests()
 {
     coordinateFactory = new TestCoordinateFactory();
     vertexFactory     = new TestVertexFactory();
     costFactory       = new TestCostFactory();
     graphFactory      = new TestGraphFactory();
     radarFactory      = new CoordinateAroundRadarFactory();
     graphAssembler    = new GraphAssemble(vertexFactory,
                                           coordinateFactory, graphFactory, costFactory, radarFactory);
 }
 public SmoothedGraphAssemble(
     IVertexFactory vertexFactory,
     ICoordinateFactory coordinateFactory,
     IGraphFactory graphFactory,
     IVertexCostFactory costFactory,
     INeighboursCoordinatesFactory radarFactory)
     : this(vertexFactory, coordinateFactory,
            graphFactory, costFactory, radarFactory, new MeanCost())
 {
 }
Пример #9
0
        public GraphBalancerAlgorithm(
            IMutableBidirectionalGraph <TVertex, TEdge> visitedGraph,
            TVertex source,
            TVertex sink,
            IVertexFactory <TVertex> vertexFactory,
            IEdgeFactory <TVertex, TEdge> edgeFactory
            )
        {
            if (visitedGraph == null)
            {
                throw new ArgumentNullException("visitedGraph");
            }
            if (vertexFactory == null)
            {
                throw new ArgumentNullException("vertexFactory");
            }
            if (edgeFactory == null)
            {
                throw new ArgumentNullException("edgeFactory");
            }
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (!visitedGraph.ContainsVertex(source))
            {
                throw new ArgumentException("source is not part of the graph");
            }
            if (sink == null)
            {
                throw new ArgumentNullException("sink");
            }
            if (!visitedGraph.ContainsVertex(sink))
            {
                throw new ArgumentException("sink is not part of the graph");
            }

            this.visitedGraph  = visitedGraph;
            this.vertexFactory = vertexFactory;
            this.edgeFactory   = edgeFactory;
            this.source        = source;
            this.sink          = sink;

            // setting capacities = u(e) = +infty
            foreach (var edge in this.VisitedGraph.Edges)
            {
                this.capacities.Add(edge, double.MaxValue);
            }

            // setting preflow = l(e) = 1
            foreach (var edge in this.VisitedGraph.Edges)
            {
                this.preFlow.Add(edge, 1);
            }
        }
Пример #10
0
        public IList <T> Paint3D <T>(IVertexFactory <T> factory)
        {
            var result = new List <T>(centers.Count * 3);

            //draw via triangles
            foreach (var c in centers)
            {
                DrawPolygon3D(c, GetColor(c.biome), factory, result);
            }
            return(result);
        }
Пример #11
0
        public void CreateVertexFactoryTwice()
        {
            IVertexFactory <object> factory = FactoryCompiler.GetVertexFactory <object>();

            Assert.IsNotNull(factory);
            Assert.IsNotNull(factory.CreateVertex());
            IVertexFactory <object> factory2 = FactoryCompiler.GetVertexFactory <object>();

            Assert.IsNotNull(factory2);
            Assert.IsNotNull(factory2.CreateVertex());
        }
Пример #12
0
 public GraphSerializerTests()
 {
     formatter       = new BinaryFormatter();
     graphFactory    = new TestGraphFactory();
     radarFactory    = new CoordinateAroundRadarFactory();
     vertexConverter = new TestVertexInfoSerializationConverter(radarFactory);
     vertexFactory   = new TestVertexFactory();
     notSerializableCoordinateFactory = new NotSerializableCoordinateFactory();
     coordinateFactory = new TestCoordinateFactory();
     costFactory       = new TestCostFactory();
 }
Пример #13
0
        public void CreateVertexFactory()
        {
            MethodInfo boo = typeof(Foo).GetMethod("Boo");

            IVertexFactory <Foo> factory = FactoryCompiler.GetVertexFactory <Foo>();

            Assert.IsNotNull(factory);
            Foo foo = factory.CreateVertex();

            Assert.IsNotNull(foo);
        }
 public SmoothedGraphAssemble(
     IVertexFactory vertexFactory,
     ICoordinateFactory coordinateFactory,
     IGraphFactory graphFactory,
     IVertexCostFactory costFactory,
     INeighboursCoordinatesFactory radarFactory,
     IMeanCost averageCost)
     : base(vertexFactory, coordinateFactory,
            graphFactory, costFactory, radarFactory)
 {
     this.averageCost = averageCost;
 }
Пример #15
0
        public static void Create <TVertex, TEdge>(
            IMutableVertexAndEdgeListGraph <TVertex, TEdge> g,
            IVertexFactory <TVertex> vertexFactory,
            IEdgeFactory <TVertex, TEdge> edgeFactory,
            Random rnd,
            int vertexCount,
            int edgeCount,
            bool selfEdges
            ) where TEdge : IEdge <TVertex>
        {
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }
            if (vertexFactory == null)
            {
                throw new ArgumentNullException("vertexFactory");
            }
            if (edgeFactory == null)
            {
                throw new ArgumentNullException("edgeFactory");
            }
            if (rnd == null)
            {
                throw new ArgumentNullException("random generator");
            }


            for (int i = 0; i < vertexCount; ++i)
            {
                g.AddVertex(vertexFactory.CreateVertex());
            }


            TVertex a;
            TVertex b;
            int     j = 0;

            while (j < edgeCount)
            {
                a = GetVertex(g, rnd);
                do
                {
                    b = GetVertex(g, rnd);
                }while (selfEdges == false && a.Equals(b));

                if (g.AddEdge(edgeFactory.CreateEdge(a, b)))
                {
                    ++j;
                }
            }
        }
 public DxfMeshLoader(IVertexFactory vertexFactory, IFaceFactory faceFactory)
 {
     if (vertexFactory == null)
     {
         throw new ArgumentNullException("vertexFactory");
     }
     if (faceFactory == null)
     {
         throw new ArgumentNullException("faceFactory");
     }
     _vertexFactory = vertexFactory;
     _faceFactory   = faceFactory;
 }
Пример #17
0
 public GraphAssemble(
     IVertexFactory vertexFactory,
     ICoordinateFactory coordinateFactory,
     IGraphFactory graphFactory,
     IVertexCostFactory costFactory,
     INeighboursCoordinatesFactory radarFactory)
 {
     this.vertexFactory     = vertexFactory;
     this.coordinateFactory = coordinateFactory;
     this.graphFactory      = graphFactory;
     this.costFactory       = costFactory;
     this.radarFactory      = radarFactory;
     percentRange           = new InclusiveValueRange <int>(99, 0);
 }
Пример #18
0
 public GraphAssemble(
     IVertexFactory vertexFactory,
     ICoordinateFactory coordinateFactory,
     IGraphFactory graphFactory,
     IVertexCostFactory costFactory,
     ICoordinateRadarFactory radarFactory)
 {
     this.vertexFactory     = vertexFactory;
     this.coordinateFactory = coordinateFactory;
     this.graphFactory      = graphFactory;
     this.costFactory       = costFactory;
     this.radarFactory      = radarFactory;
     percentRange           = new ValueRange(100, 0);
 }
Пример #19
0
        public AlgorithmTest()
        {
            radarFactory      = new CoordinateAroundRadarFactory();
            graphFactory      = new TestGraphFactory();
            vertexFactory     = new TestVertexFactory();
            costFactory       = new TestVertexCostFactory();
            coordinateFactory = new TestCoordinateFactory();

            graphAssemble = new GraphAssemble(vertexFactory,
                                              coordinateFactory,
                                              graphFactory,
                                              costFactory,
                                              radarFactory);

            testAssemble = new TestGraphAssemble(graphAssemble);
        }
Пример #20
0
        public MaximumBipartiteMatchingAlgorithm(
            IMutableVertexAndEdgeListGraph <TVertex, TEdge> visitedGraph,
            IVertexFactory <TVertex> vertexFactory,
            IEdgeFactory <TVertex, TEdge> edgeFactory
            )
            : base(visitedGraph)
        {
            if (vertexFactory == null)
            {
                throw new ArgumentNullException("vertexFactory");
            }
            if (edgeFactory == null)
            {
                throw new ArgumentNullException("edgeFactory");
            }

            this.vertexFactory = vertexFactory;
            this.edgeFactory   = edgeFactory;
        }
        public GraphAugmentorAlgorithmBase(
            TGraph visitedGraph,
            IVertexFactory <TVertex> vertexFactory,
            IEdgeFactory <TVertex, TEdge> edgeFactory
            )
            : base(visitedGraph)
        {
            if (vertexFactory == null)
            {
                throw new ArgumentNullException("vertexFactory");
            }
            if (edgeFactory == null)
            {
                throw new ArgumentNullException("edgeFactory");
            }

            this.vertexFactory = vertexFactory;
            this.edgeFactory   = edgeFactory;
        }
Пример #22
0
        protected GraphAugmentorAlgorithmBase(
            IAlgorithmComponent host,
            TGraph visitedGraph,
            IVertexFactory <TVertex> vertexFactory,
            IEdgeFactory <TVertex, TEdge> edgeFactory
            )
            : base(host, visitedGraph)
        {
            if (vertexFactory == null)
            {
                throw new ArgumentNullException("vertexFactory");
            }
            if (edgeFactory == null)
            {
                throw new ArgumentNullException("edgeFactory");
            }

            this.vertexFactory = vertexFactory;
            this.edgeFactory   = edgeFactory;
        }
Пример #23
0
        public GraphTypeHelper(IVertexFactory <TIdentity> VertexFactory, IEdgeFactory <TIdentity> EdgeFactory, IIdentityProvider <TIdentity> IdentityProvider)
        {
            if (VertexFactory == null)
            {
                throw new ArgumentNullException("VertexFactory");
            }

            if (EdgeFactory == null)
            {
                throw new ArgumentNullException("EdgeFactory");
            }

            if (IdentityProvider == null)
            {
                throw new ArgumentNullException("IdentityProvider");
            }

            this.VertexFactory    = VertexFactory;
            this.EdgeFactory      = EdgeFactory;
            this.IdentityProvider = IdentityProvider;
        }
Пример #24
0
        private void AddTriangle <T>(Vector3D a, Vector3D b, Vector3D c, PortableColor color, IVertexFactory <T> factory, List <T> vertexBuffer)
        {
            var normal = GetNormal(a, b, c);

            if (normal.Y >= 0)
            {
                var xchg = b;
                b      = c;
                c      = xchg;
                normal = GetNormal(a, b, c);
            }

            vertexBuffer.Add(factory.CreateVertex(a, normal, color));
            vertexBuffer.Add(factory.CreateVertex(b, normal, color));
            vertexBuffer.Add(factory.CreateVertex(c, normal, color));
        }
Пример #25
0
        private void DrawPolygon3D <T>(Center c, PortableColor color, IVertexFactory <T> factory, List <T> vertexBuffer)
        {
            //only used if Center c is on the edge of the graph. allows for completely filling in the outer polygons
            Corner edgeCorner1 = null;
            Corner edgeCorner2 = null;

            foreach (Center n in c.neighbors)
            {
                var e = EdgeWithCenters(c, n);

                if (e.v0 == null)
                {
                    //outermost voronoi edges aren't stored in the graph
                    continue;
                }

                //find a corner on the exterior of the graph
                //if this Edge e has one, then it must have two,
                //finding these two corners will give us the missing
                //triangle to render. this special triangle is handled
                //outside this for loop
                var cornerWithOneAdjacent = e.v0.border ? e.v0 : e.v1;
                if (cornerWithOneAdjacent.border)
                {
                    if (edgeCorner1 == null)
                    {
                        edgeCorner1 = cornerWithOneAdjacent;
                    }
                    else
                    {
                        edgeCorner2 = cornerWithOneAdjacent;
                    }
                }
                var p = Transform((float)c.loc.X, (float)c.loc.Y, (float)c.elevation);
                var q = Transform((float)e.v0.loc.X, (float)e.v0.loc.Y, (float)e.v0.elevation);
                var r = Transform((float)e.v1.loc.X, (float)e.v1.loc.Y, (float)e.v1.elevation);
                AddTriangle(p, r, q, color, factory, vertexBuffer);
            }

            //handle the missing triangle
            if (edgeCorner2 != null)
            {
                //if these two outer corners are NOT on the same exterior edge of the graph,
                //then we actually must render a polygon (w/ 4 points) and take into consideration
                //one of the four corners (either 0,0 or 0,height or width,0 or width,height)
                //note: the 'missing polygon' may have more than just 4 points. this
                //is common when the number of sites are quite low (less than 5), but not a problem
                //with a more useful number of sites.
                //TODO: find a way to fix this

                if (CloseEnough(edgeCorner1.loc.X, edgeCorner2.loc.X, 1))
                {
                    var p = Transform((float)c.loc.X, (float)c.loc.Y, (float)c.elevation);
                    var q = Transform((float)edgeCorner1.loc.X, (float)edgeCorner1.loc.Y, (float)edgeCorner1.elevation);
                    var r = Transform((float)edgeCorner2.loc.X, (float)edgeCorner2.loc.Y, (float)edgeCorner2.elevation);
                    AddTriangle(p, r, q, color, factory, vertexBuffer);
                }
                else
                {
                    /*
                     * var points = new PointInt32[] {
                     *  new PointInt32((int)c.loc.X, (int)c.loc.Y),
                     *  new PointInt32((int)edgeCorner1.loc.X, (int)edgeCorner1.loc.Y),
                     *  new PointInt32((int)((CloseEnough(edgeCorner1.loc.X, bounds.x, 1) || CloseEnough(edgeCorner2.loc.X, bounds.x, .5)) ? bounds.x : bounds.right), (int)((CloseEnough(edgeCorner1.loc.Y, bounds.y, 1) || CloseEnough(edgeCorner2.loc.Y, bounds.y, .5)) ? bounds.y : bounds.bottom)),
                     *  new PointInt32((int)edgeCorner2.loc.X, (int)edgeCorner2.loc.Y),
                     * };
                     *
                     * g.FillPolygon(color, points);
                     * c.area += 0; //TODO: area of polygon given vertices*/
                }
            }
        }
 public MeshLoaderFactory(IVertexFactory vertexFactory, IFaceFactory faceFactory)
 {
     _vertexFactory = vertexFactory;
     _faceFactory   = faceFactory;
 }
Пример #27
0
 public ObjMeshLoader(IVertexFactory vertexFactory, IFaceFactory faceFactory)
 {
   _vertexFactory = vertexFactory;
   _faceFactory = faceFactory;
 }