public BasicForceStrategy(Molecula[] moleculas, 
            ForceCalculatingService forceCalculatingService, 
            MoleculasUpdatingService moleculasUpdatingService)
        {
            _moleculas = moleculas;
            _forceCalculatingService = forceCalculatingService;
            _moleculasUpdatingService = moleculasUpdatingService;

            _forces = new Vector2[moleculas.Length][];
            for (int i = 0; i < moleculas.Length; i++)
            {
                _forces[i] = new Vector2[moleculas.Length];
            }
        }
        protected void UpdateForBounds(Molecula molecula)
        {
            var position = molecula.Position;
            if (position.X < 0 || position.X > Width)
            {
                molecula.Speed = molecula.Speed.NegateX();
                molecula.Position = new Vector2(position.X < 0 ? 0 : Width, position.Y);
            }

            if (position.Y < 0 || position.Y > Height)
            {
                molecula.Speed = molecula.Speed.NegateY();
                molecula.Position = new Vector2(position.X, position.Y < 0 ? 0 : Height);
            }
        }
        public ParallelForceStratagy(Molecula[] moleculas, 
            ForceCalculatingService forceCalculatingService, 
            MoleculasUpdatingService moleculasUpdatingService, int threadCount)
        {
            _moleculas = moleculas;
            _forceCalculatingService = forceCalculatingService;
            _moleculasUpdatingService = moleculasUpdatingService;
            _threadCount = threadCount;

            _barrier = new Barrier(_threadCount);

            _forces = new Vector2[moleculas.Length][];
            for (int i = 0; i < moleculas.Length; i++)
            {
                _forces[i] = new Vector2[moleculas.Length];
            }
        }
 public BaseForceStrategy GetBasicForceStrategy(Molecula[] moleculas,
     ForceCalculatingService forceCalculatingService,
     MoleculasUpdatingService moleculasUpdatingService)
 {
     return new BasicForceStrategy(moleculas, forceCalculatingService, moleculasUpdatingService);
 }
 public BaseForceStrategy GetParallelForceStratagy(Molecula[] moleculas,
     ForceCalculatingService forceCalculatingService,
     MoleculasUpdatingService moleculasUpdatingService, int threadCount)
 {
     return new ParallelForceStratagy(moleculas, forceCalculatingService, moleculasUpdatingService, threadCount);
 }
Exemplo n.º 6
0
    private string getStringEvowave(Random random, List <Molecula> moleculasRegiao, List <Node> lista, string color, int complexity)
    {
        foreach (Node n in lista)
        {
            int qtdDados = n.QteAcidentes;

            for (int i = 1; i <= 10; i++)
            {
                Molecula molecula = new Molecula();
                molecula.color   = color;
                molecula.posicao = random.Next(1, 10);

                for (int j = 0; j <= random.Next(1, qtdDados); j++)
                {
                    Dados dado = new Dados();
                    dado.Complexity = random.Next(1, 3);
                    dado.LOC        = n.Ano;


                    molecula.dados.Add(dado);
                }

                moleculasRegiao.Add(molecula);
            }
        }

        //[{"position":1,"molecules":[ {"color":"FFFF0000","data":{"complexity":2,"LOC":500}}]}]

        //[{"position":1,"molecules":[{"color":"FFFF00FF","data":{"complexity":"Doenca Do Trabalho","LOC":2010}}]}]

        //[{"position":1,"molecules":[{"color":"FFFF00FF","data":{"complexity":"Doenca Do Trabalho","LOC":2010}},{"color":"FFFF00FF","data":{"complexity":"Doenca Do Trabalho","LOC":2010}}] }]


        string formatadaInicio = string.Empty;
        string formatadaFinal  = string.Empty;



        foreach (Molecula mol in moleculasRegiao)
        {
            int countDados = 0;

            formatadaInicio = "{ 'position': " + mol.posicao + ",'molecules':[ ";

            foreach (Dados d in mol.dados)
            {
                formatadaInicio += "{ 'color':'" + mol.color + "','data':{ 'complexity':" + complexity + ",'LOC':" + d.LOC + "} }";

                countDados++;

                if (countDados < mol.dados.Count)
                {
                    formatadaInicio += " , ";
                }
            }

            formatadaInicio += "]},";

            formatadaFinal += formatadaInicio;
            formatadaInicio = string.Empty;
        }

        return(formatadaFinal);
    }