コード例 #1
0
        private Money CreditGeneral(Money Input, CreditAs As, string OfferwallName, bool RequiresConversion = false, bool IsReversal = false)
        {
            Money Calculated = Money.MultiplyPercent(Input, base.User.Membership.OfferwallsProfitPercent);

            //Conversion?
            if (RequiresConversion)
            {
                if (As == CreditAs.Points)
                {
                    Calculated = new Money(PointsConverter.ToPoints(Calculated));
                }
                if (As == CreditAs.MainBalance)
                {
                    Calculated = PointsConverter.ToMoney(Calculated.ToDecimal());
                }
            }

            if (As == CreditAs.Points)
            {
                base.CreditPoints(Calculated.GetRealTotals(), "CrowdFlower", BalanceLogType.Other);
                base.CreditReferersPoints(Calculated.GetRealTotals(), "CrowdFlower /ref/ " + User.Name, BalanceLogType.Other);
            }
            if (As == CreditAs.MainBalance)
            {
                base.CreditMainBalance(Calculated, "CrowdFlower", BalanceLogType.Other);
                base.CreditReferersMainBalance(Calculated, "CrowdFlower /ref/ " + User.Name, BalanceLogType.Other);
            }

            History.AddOfferwalCompleted(User.Name, OfferwallName, Calculated, As);

            return(Calculated);
        }
コード例 #2
0
        public void Calculate(Wiring wiring)
        {
            var sourceMutuals = DatabaseManager.Instance.GetCalculatedMutualActionOfBCSAndBA();

            if (sourceMutuals == null)
            {
                return;
            }

            Remove();

            var wires = wiring.Wires;

            var influences = new List <(int a, int b, float value)>();

            var maxValue = sourceMutuals.Max(m => Math.Abs(m.value));
            var mutuals  = sourceMutuals.Select(m => (wire: wires.First(w => w.Name == m.name), wiresInfluences: m.influences.Select(i => (wires.First(w => w.Name == i.name), i.frequency, i.value)).ToList(), m.blocksInfluences, m.exceeded, m.value, color: _gradient.Evaluate((float)(Math.Abs(m.value) / maxValue)))).ToList();

            _wires = Wire.Factory.Create(mutuals, transform);

            foreach (var wire in _wires)
            {
                wire.Clicked += Wire_Clicked;
            }

            IsCalculated = true;
            Calculated.Invoke();

            FilterMaxValue = maxValue;
        }
コード例 #3
0
ファイル: Sky.cs プロジェクト: Astrarium/Astrarium
 public void Calculate()
 {
     foreach (var calc in Calculators)
     {
         calc.Calculate(Context);
     }
     Calculated?.Invoke();
 }
コード例 #4
0
 public void clearAll()
 {
     AdmissionNumber.Clear();
     StdName.Clear();
     FatheName.Clear();
     Grade.Clear();
     TotalFee.Clear();
     PreviousDues.Clear();
     Calculated.Clear();
     Paid.Clear();
     Dues.Clear();
 }
コード例 #5
0
        public async static void ComputeAsync(uint numberOfPoints)
        {
            var task = new Task <double>(new Func <object, double> ((n) => Compute(n)), numberOfPoints);

            task.Start();
            double result = await task;

            //var awaiter = task.GetAwaiter();
            //awaiter.OnCompleted(new Action(() => { result =  awaiter.GetResult();Console.WriteLine(""+result); }));
            Console.WriteLine("" + result);
            Calculated?.Invoke(result);
        }
コード例 #6
0
        public virtual int _GetUniqueIdentifier()
        {
            var hashCode = 399326290;

            hashCode = hashCode * -1521134295 + (Id?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (ValueOfLoC?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (IssuingBank?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Detail?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (UploadOfScan?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Calculated?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (DateOfValidity?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (DateOfExpiry?.GetHashCode() ?? 0);
            return(hashCode);
        }
コード例 #7
0
        public void Should_ReturnTrue(int CalculateInsurancePremium)
        {
            // Arrange
            var sut = new CalculateLifeInsurance();

            // Act
            var result = sut.CalculateInsurancePremium(CalculateInsurancePremium, 0);

            // Assert
            var expected = new Calculated {
                IsInsuranceCalculated = true
            };

            result.IsInsuranceCalculated.Should().Be(expected.IsInsuranceCalculated);
        }
コード例 #8
0
ファイル: OfferwallCrediter.cs プロジェクト: dovanduy/titan
        public static Money CalculatedAndConversion(Money Input, Member member, Offerwall Wall)
        {
            Money Calculated = new Money(Input.ToDecimal());

            //Money to Money in diffrent Currency
            if (Wall.WhatIsSent == WhatIsSent.Money && Wall.CreditAs == CreditAs.MainBalance && AppSettings.Site.CurrencyCode != Wall.CurrencyCode)
            {
                Calculated = Calculated.ExchangeFrom(Wall.CurrencyCode);
            }
            //Poinst to Money
            else if (Wall.WhatIsSent == WhatIsSent.Points && Wall.CreditAs == CreditAs.MainBalance)
            {
                if (AppSettings.Points.PointsEnabled && Wall.UseVirtualCurrencySetting)
                {
                    Calculated = PointsConverter.ToMoney(Calculated.ToDecimal());
                    Calculated = Calculated.ExchangeFrom(Wall.CurrencyCode);
                }
                else
                {
                    Calculated = PointsConverter.ToMoney(Calculated.ToDecimal(), Wall.MoneyToPointsRate.ToDecimal());
                    Calculated = Calculated.ExchangeFrom(Wall.CurrencyCode);
                }
            }
            //Money to Points
            else if (Wall.WhatIsSent == WhatIsSent.Money && Wall.CreditAs == CreditAs.Points)
            {
                Calculated = Calculated.ExchangeFrom(Wall.CurrencyCode);
                Calculated = new Money(PointsConverter.ToPoints(Calculated));
            }
            //Points to Points in diffrent Currency
            else if (Wall.WhatIsSent == WhatIsSent.Points && Wall.CreditAs == CreditAs.Points && AppSettings.Site.CurrencyCode != Wall.CurrencyCode)
            {
                Calculated = PointsConverter.ToMoney(Calculated.ToDecimal(), Wall.MoneyToPointsRate.ToDecimal());
                Calculated = Calculated.ExchangeFrom(Wall.CurrencyCode);
                Calculated = new Money(PointsConverter.ToPoints(Calculated));
            }
            //No conversion

            //Modify by credit percentage
            Calculated = Money.MultiplyPercent(Calculated, Wall.CreditPercentage);

            ///Membership fee
            Calculated = Money.MultiplyPercent(Calculated, member.Membership.OfferwallsProfitPercent);

            return(Calculated);
        }
コード例 #9
0
        public static Money CalculatePostback(Money Input, bool RequiresConversion, Member member, CreditAs As)
        {
            Money Calculated = Money.MultiplyPercent(Input, member.Membership.CPAProfitPercent);

            if (RequiresConversion)
            {
                if (As == CreditAs.Points)
                {
                    Calculated = new Money(PointsConverter.ToPoints(Calculated));
                }

                if (As == CreditAs.MainBalance)
                {
                    Calculated = PointsConverter.ToMoney(Calculated.GetRealTotals());
                }
            }

            return(Calculated);
        }
コード例 #10
0
        public async static void ComputeAsyncMultasks(int numberOfTasks, uint numberOfPoints)
        {
            var tasks   = new Task <double> [numberOfTasks];
            var results = new double[numberOfTasks];

            for (int i = 0; i < numberOfTasks; i++)
            {
                tasks[i] = new Task <double>(new Func <object, double>((n) => Compute(n)), numberOfPoints);
                tasks[i].Start();
            }
            for (int i = 0; i < numberOfTasks; i++)
            {
                results[i] = await tasks[i];
            }
            var result = 0.0;

            foreach (var r in results)
            {
                result += r;
            }
            Calculated?.Invoke(result / numberOfTasks);
        }
コード例 #11
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = Id != null
                    ? Id.GetHashCode()
                    : 0;

                hashCode = (hashCode * 397) ^ (Title != null
                    ? Title.GetHashCode()
                    : 0);
                hashCode = (hashCode * 397) ^ (Name != null
                    ? Name.GetHashCode()
                    : 0);
                hashCode = (hashCode * 397) ^ (int)Type;
                hashCode = (hashCode * 397) ^ (ExtraTitleInfo != null
                    ? ExtraTitleInfo.GetHashCode()
                    : 0);
                hashCode = (hashCode * 397) ^ (Category != null
                    ? Category.GetHashCode()
                    : 0);
                hashCode = (hashCode * 397) ^ Allocation.GetHashCode();
                hashCode = (hashCode * 397) ^ Precision.GetHashCode();
                hashCode = (hashCode * 397) ^ Calculated.GetHashCode();
                hashCode = (hashCode * 397) ^ Segmentable.GetHashCode();
                hashCode = (hashCode * 397) ^ (Description != null
                    ? Description.GetHashCode()
                    : 0);
                hashCode = (hashCode * 397) ^ (int)Polarity;
                hashCode = (hashCode * 397) ^ (HelpLink != null
                    ? HelpLink.GetHashCode()
                    : 0);
                hashCode = (hashCode * 397) ^ AllowedForReporting.GetHashCode();

                return(hashCode);
            }
        }
コード例 #12
0
ファイル: Program.cs プロジェクト: yingunjun/Get3DModel2
        static void Main(string[] args)
        {
            IParser      parser      = new Parser();
            ICalculated  calculated  = new Calculated(new MathematicialSearchPoint1());
            IPreserveOBJ preserveOBJ = new PreserveOBJ();
            IPreservePNG preservePNG = new PreservePNG();
            IElimination elimination = new Elimination();
            IAnalysis    analysis;
            Setting      setting = null;
            double       delta   = 0.0;

            List <string> filesImagesname;
            string        pathFolder;
            string        pathConfig;

            if (args.Length == 0)
            {
                Console.WriteLine("usage: Get3DModel.exe <path to folder>"); Environment.Exit(-1);
            }
            pathFolder = args[0];

            filesImagesname = Directory.GetFiles(pathFolder, "*.png").ToList <string>();
            if (args.Length > 1)
            {
                delta = Convert.ToDouble(args[1]);
            }

            pathConfig = Directory.GetFiles(pathFolder).ToList().First(
                x => x.EndsWith(".camera"));
            FileInfo fileInf = new FileInfo(pathConfig);

            if (fileInf.Exists)
            {
                setting = new Setting(pathConfig);
                Console.WriteLine("the verification of the optics configuration file completed successfully");
            }
            else
            {
                Console.WriteLine("the configuration file is not found");
                Environment.Exit(-1);
            }

            Stopwatch timeForParsing = new Stopwatch();

            for (int i = 0; i < filesImagesname.Count && i < 50; i++)
            {
                if (filesImagesname[i].EndsWith("sharpImage.png"))
                {
                    continue;
                }
                timeForParsing.Restart();
                Data.Image itemImage = new Data.Image(filesImagesname[i]);
                elimination.calculateGradientImage(itemImage);
                timeForParsing.Stop();
                Console.WriteLine(
                    string.Format("elimination of the {0} has finished\n\telapsed time: {1} milliseconds",
                                  filesImagesname[i], timeForParsing.ElapsedMilliseconds));
                GC.Collect();
            }
            List <Data.Point> goodPoint = elimination.getSolution();

            analysis = new Analysis(goodPoint);
            for (int i = 0; i < filesImagesname.Count; i++)
            // Parallel.For(0, filesImagesname.Count, i =>
            {
                if (filesImagesname[i].EndsWith("sharpImage.png"))
                {
                    continue;
                }
                timeForParsing.Restart();
                Data.Image itemImage = new Data.Image(filesImagesname[i]);
                lock (analysis) analysis.addImageAnalysis(itemImage);
                timeForParsing.Stop();
                Console.WriteLine(
                    string.Format("analysing of the {0} has finished\n\telapsed time: {1} milliseconds",
                                  filesImagesname[i], timeForParsing.ElapsedMilliseconds));
            } //);
            List <IMathematical> coreGoodPoint = analysis.getCore();

            analysis    = null;
            elimination = null;
            GC.Collect();
            calculated.createdBeginSolution();
            for (int i = 0; i < filesImagesname.Count; i++)
            {
                if (filesImagesname[i].EndsWith("sharpImage.png"))
                {
                    continue;
                }
                timeForParsing.Restart();
                Data.Image itemImage = new Data.Image(filesImagesname[i]);
                calculated.clarifySolution(itemImage, coreGoodPoint, goodPoint);
                timeForParsing.Stop();
                Console.WriteLine(
                    string.Format("processing of the {0} has finished\n\telapsed time: {1} milliseconds",
                                  filesImagesname[i], timeForParsing.ElapsedMilliseconds));
            }
            Solution solution = calculated.getSolution();

            Console.WriteLine("saving data was started");
            preserveOBJ.saveOBJ(solution, setting, pathFolder);
            preservePNG.savePNG(solution, pathFolder);
        }
コード例 #13
0
 private void OnCalculated(int result)
 {
     Calculated?.Invoke(this, result);
 }
コード例 #14
0
 protected virtual void OnCalculated(double result)
 {
     Calculated?.Invoke(this, result);
 }
コード例 #15
0
        private void RecieveClientAttackData(object source, Client client, Client target, string weaponName)
        {
            // Basic Failures. Just make sure there's a weapon and such.
            if (!client.Exists || !target.Exists || weaponName == "")
            {
                return;
            }

            WeaponHash hash = NAPI.Util.WeaponNameToModel(weaponName);

            if (!AccountUtil.DoesPlayerHaveWeapon(client, hash))
            {
                PlayerEvents.CancelAttack(client);
                return;
            }



            if (client == target)
            {
                PlayerEvents.CancelAttack(client);
                return;
            }

            if (weaponName.ToLower() != "unarmed")
            {
                if (!client.IsAiming)
                {
                    return;
                }
            }

            int   WeaponRange            = Weapons.GetWeaponRange(weaponName);
            float DistanceBetweenTargets = client.Position.DistanceTo(target.Position);

            // If it's too far there's no point in rolling.
            if (DistanceBetweenTargets > WeaponRange + 20)
            {
                return;
            }

            // Ternary Op - If the distance is greater than the weapon range return the distance between the targets. If they're in range set the penalty to zero.
            int RangePenalty = (DistanceBetweenTargets > WeaponRange) ? Convert.ToInt32((DistanceBetweenTargets - WeaponRange)) : 0;

            Account    account          = AccountUtil.RetrieveAccount(client);
            Account    targetAccount    = AccountUtil.RetrieveAccount(target);
            LevelRanks clientLevelRanks = AccountUtil.GetLevelRanks(client);

            LevelRankCooldowns levelRankCooldowns = AccountUtil.GetCooldowns(client);
            bool skipCheck    = false;
            int  deadeyeBonus = 0;

            // The target player's defense bonus.
            int targetDefenseBonus = 0;

            targetDefenseBonus = Quick.Use(target, targetDefenseBonus);

            if (account.IsDead || targetAccount.IsDead)
            {
                client.SendNotification("That player is already downed. Focus on someone else.");
                PlayerEvents.CancelAttack(client);
                return;
            }

            // Calculated Skill Check
            if (Calculated.Use(client))
            {
                skipCheck = true;
            }

            // Use Deadeye if Calculated wasn't triggered.
            if (Deadeye.Use(client) && !skipCheck)
            {
                deadeyeBonus = clientLevelRanks.Deadeye;
            }

            // Check if the player beats the other's score.
            if (!skipCheck)
            {
                if (!Skillcheck.SkillCheckPlayers(client, target, Skillcheck.Skills.endurance, clientModifier: (RangePenalty + deadeyeBonus), targetModifier: targetDefenseBonus) && weaponName != "unarmed")
                {
                    Utilities.NotifyPlayersOfTargetDamage(client, target, 0);
                    return;
                }
            }

            // Get the weapon dice and roll count for the damage calculation.
            int weaponDie       = Weapons.GetWeaponDamageDie(weaponName.ToLower()) + DamageRoll.Use(client);
            int weaponRollCount = Weapons.GetWeaponRollCount(weaponName.ToLower());

            // Roll for damage.
            int amountOfDamage = 0;

            for (int i = 0; i < weaponRollCount; i++)
            {
                amountOfDamage += Skills.Utility.RollDamage(weaponDie);
            }

            // Double damage if concentrate is available.
            amountOfDamage = Concentrate.Use(client, amountOfDamage);

            // Add fisticuffs damage if they're unarmed.
            amountOfDamage += weaponName.ToLower() == "unarmed" ? clientLevelRanks.Fisticuffs : 0;

            // Double Damage Skill
            if (clientLevelRanks.Concentrate > 0)
            {
                if (levelRankCooldowns.IsConcentrateReady)
                {
                    amountOfDamage *= 2;
                    levelRankCooldowns.IsConcentrateReady = false;
                    client.SendChatMessage("~g~Concentrate ~w~Your shot hit for ~r~DOUBLE ~w~damage.");
                }
            }

            if (target.Health - amountOfDamage <= 0)
            {
                target.Health = 1;
            }
            else
            {
                target.Health -= amountOfDamage;
            }

            // Update Health
            Account.PlayerUpdateEvent.Trigger(target, targetAccount);


            Utilities.NotifyPlayersOfTargetDamage(client, target, amountOfDamage);

            if (target.Health > 2)
            {
                return;
            }

            PlayerEvents.CancelAttack(client);
            DeathHandler.DeathEvent.Trigger(target, client); // Raise Death Event
        }
コード例 #16
0
 protected override void Calculate()
 {
     base.Calculate();
     Value = CharacteristicsCalculator.CalculateCombatStat(this);
     Calculated?.Invoke((this), new CombatStatCalculatedEventArgs(this));
 }
コード例 #17
0
        /// <summary>
        /// Perform all the calculations necessary to determine the
        /// usable text area from the given template and stationary image.
        /// </summary>
        /// <returns></returns>
        /// <remarks></remarks>
        protected Rectangle[] Calculate()
        {
            Rectangle[] CalculateRet = default;
            Bitmap      bmp;

            // what we're going to do is map every possible rectangular region in the image.
            // we will accept a certain percentage of white space to add that rectangle to the image.

            double minX;
            double minY;
            int    x;
            int    y;
            int    cx;
            int    cy;
            int    l;
            int    c = 0;
            int    d = 0;

            var rcCol     = new List <Rectangle>();
            var lineParts = new LineSegments();

            var ceArgs = new CalculatedEventArgs(null, 0, DateTime.MinValue, DateTime.MinValue);

            ceArgs.StartTimer();

            // Dim sMult As Double = 1.0#
            // Dim maxImg As Integer = 2400

            bmp = _img;

            // If _img.Width > maxImg OrElse _img.Height > maxImg Then

            // If _img.Width > _img.Height Then
            // x = maxImg
            // y = _img.Height * (maxImg / _img.Width)
            // sMult = maxImg / _img.Width
            // Else
            // y = maxImg
            // x = _img.Width * (maxImg / _img.Height)
            // sMult = maxImg / _img.Height
            // End If

            // bmp = New Bitmap(x, y, PixelFormat.Format32bppArgb)
            // Dim g As Graphics = Graphics.FromImage(bmp)

            // g.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality
            // g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
            // g.SmoothingMode = Drawing2D.SmoothingMode.None

            // g.DrawImage(_img, 0, 0, x, y)

            // g.Dispose()
            // _img = bmp
            // Else
            // bmp = _img
            // End If

            cx   = bmp.Width;
            cy   = bmp.Height;
            minX = _minUsableX * cx;
            minY = _minUsableY * cy;
            var    bm = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
            MemPtr mm = bm.Scan0;

            ceArgs.TotalCalculations = cx * cy * 2;

            for (y = 0; y < cy; y++)
            {
                c = -1;
                d = -1;

                for (x = 0; x < cx; x++)
                {
                    l = (y * cx + x) * 4;
                    if (mm.ByteAt(l) >= 250 && mm.ByteAt(l + 1) >= 250 && mm.ByteAt(l + 2) >= 250)

                    {
                        if (c == -1)
                        {
                            c = x;
                            d = 0;
                        }
                        else
                        {
                            d += 1;
                        }
                    }
                    else if (d != -1)
                    {
                        if (d > minX)
                        {
                            lineParts.Add(new LineSegment(c, d, y));
                        }

                        c = -1;
                        d = -1;
                    }
                }

                if (d > minX)
                {
                    lineParts.Add(new LineSegment(c, d, y));
                }
            }

            lineParts.Sort();
            _rawData = lineParts;
            var          experiment = new List <LineSegments>();
            LineSegments temp;
            // Dim temp2 As LineSegments

            double minArea = minX * minY;

            minArea *= 0.5d;
            ceArgs.TotalCalculations += cx * cy;

            var loopTo2 = cx - 1;

            for (x = 0; (int)(cx * 0.0375d) >= 0 ? x <= loopTo2 : x >= loopTo2; x += (int)(cx * 0.0375d))
            {
                var loopTo3 = cy - 1;

                for (y = 0; (int)(cy * 0.0375d) >= 0 ? y <= loopTo3 : y >= loopTo3; y += (int)(cy * 0.0375d))
                {
                    l    = (y * cx + x) * 4;
                    temp = _rawData.FindSet(x, cx - x, y, false);
                    if (temp is null || temp.Area < minArea)
                    {
                        continue;
                    }
                    for (l = temp.Count - 2; l >= 1; l -= 1)
                    {
                        if (temp[l].Index - temp[l - 1].Index > temp.OriginContinuityThreshold)
                        {
                            temp.RemoveAt(l - 1);
                        }
                    }

                    ceArgs.TotalCalculations += temp.Count + _rawData.Count;
                    experiment.Add(temp);
                }
            }

            experiment.Sort(new SortByArea());
            experiment.Reverse();
            LineSegments[] pps; // = lineParts.FindAllContiguousRegions
            pps = experiment.ToArray();
            Clear();
            bmp.UnlockBits(bm);
            ceArgs.TotalCalculations += pps.Count() + _rawData.Count;
            _Regions.Clear();
            foreach (var px in pps)
            {
                var rc = px.Bounds;
                temp = _rawData.FindSet(rc.Left, rc.Right, rc.Top, true, false);
                if (temp is null)
                {
                    continue;
                }
                rc = temp.Bounds;
                if (rc.Width < minX)
                {
                    continue;
                }
                if (rc.Height < minY)
                {
                    continue;
                }
                rc.Inflate(-20, -20);
                if (_purgeOverlaps)
                {
refor:
                    ;
                    foreach (var rcChk in rcCol)
                    {
                        if (rcChk.IntersectsWith(rc))
                        {
                            if (rcChk.Width * rcChk.Height > rc.Width * rc.Height) // AndAlso (rcChk.Width > rc.Width) Then
                            {
                                rc = rcChk;
                            }
                            else if (TestSquareness(rcChk) < TestSquareness(rc)) // AndAlso (rc.Width >= rcChk.Width) Then
                            {
                                rcCol.Remove(rcChk);
                                goto refor;
                            }
                            else
                            {
                                rc = Rectangle.Empty;
                            }

                            break;
                        }
                    }
                }

                if (temp is object)
                {
                    Add(temp);
                }
                if (rc != Rectangle.Empty)
                {
                    // If CheckRect(rc, cx, cy, mm) = False Then Continue For
                    rcCol.Add(rc);
                    _Regions.Add(rc);
                }
            }

            ceArgs.StopTimer();
            CalculateRet   = rcCol.ToArray();
            ceArgs.Regions = _Regions;
            OnPropertyChanged("Regions");
            OnPropertyChanged("RawOutput");
            Calculated?.Invoke(this, ceArgs);
            return(CalculateRet);
        }
コード例 #18
0
        static void Main(string[] args)
        {
            IParser      parser = new Parser();
            ICalculated  calculated;
            IPreserveOBJ preserveOBJ = new PreserveOBJ();
            IPreservePNG preservePNG = new PreservePNG();
            IElimination elimination;
            IAnalysis    analysis;
            Setting      setting = null;
            INIManager   manager;

            List <string> filesImagesname;
            string        pathFolder;
            string        pathConfig;
            string        pathSetting;
            string        saveFolder;

            if (args.Length == 0)
            {
                Console.WriteLine("usage: Get3DModel.exe <path to folder>"); Environment.Exit(-1);
            }
            pathFolder = args[0];

            pathSetting = pathFolder + "\\setting.ini";

            manager = new INIManager(pathSetting);

            string[] separators = { "\\" };
            string[] words      = pathFolder.Split(separators, StringSplitOptions.RemoveEmptyEntries);
            saveFolder = words[0];
            for (int i = 1; i < words.Length - 1; i++)
            {
                saveFolder = saveFolder + "\\" + words[i];
            }
            saveFolder = saveFolder + "\\Resulst_" + words[words.Length - 1];

            Directory.CreateDirectory(saveFolder);

            StreamWriter timeTxt = new StreamWriter(saveFolder + "\\time.txt");

            string[] listFileFolder = Directory.GetDirectories(pathFolder);
            foreach (string folder in listFileFolder)
            {
                FileInfo fileInfFolder     = new FileInfo(folder);
                string   nameFolder        = fileInfFolder.Name;
                string   saveFolderCurrent = saveFolder + "\\" + nameFolder;

                Directory.CreateDirectory(saveFolderCurrent);

                filesImagesname = Directory.GetFiles(folder, "*.png").ToList <string>();

                pathConfig = Directory.GetFiles(folder).ToList().First(
                    x => x.EndsWith(".camera") || x.EndsWith(".ini") || x.EndsWith("ConfigurationFile.txt"));

                FileInfo fileInf = new FileInfo(pathConfig);
                if (fileInf.Exists)
                {
                    setting = new Setting(pathConfig);
                }
                else
                {
                    Console.WriteLine("the configuration file is not found");
                    Environment.Exit(-1);
                }
                Stopwatch timeForParsing = new Stopwatch();
                timeForParsing.Restart();

                string        nameCoreElimination = manager.GetPrivateString("ELIMINATION", "core");
                IMathematical coreElimination     = getMathematical(nameCoreElimination);
                if (coreElimination != null)
                {
                    string thresholdElimination = manager.GetPrivateString("ELIMINATION", "threshold");
                    if (thresholdElimination != "default")
                    {
                        double deltaTheshold = Convert.ToDouble(thresholdElimination);
                        coreElimination.setDeltaThreshold(deltaTheshold);
                    }
                    elimination = new Elimination(coreElimination);
                }
                else
                {
                    elimination = new Elimination();
                }

                for (int i = 0; i < filesImagesname.Count; i++)
                {
                    if (filesImagesname[i].EndsWith("sharpImage.png"))
                    {
                        continue;
                    }
                    Data.Image itemImage = new Data.Image(filesImagesname[i]);
                    elimination.calculateGradientImage(itemImage);
                }
                List <Data.Point> goodPoint = elimination.getSolution();

                string boolSelectionCore = manager.GetPrivateString("SELECTION_CORE", "selection_core");
                if (boolSelectionCore == "true")
                {
                    string        nameCore3x3 = manager.GetPrivateString("CORE", "3_core");
                    IMathematical core3x3     = getMathematical(nameCore3x3);
                    if (core3x3 == null)
                    {
                        core3x3 = new MathematicialSearchPoint1();
                    }

                    string        nameCore5x5 = manager.GetPrivateString("CORE", "5_core");
                    IMathematical core5x5     = getMathematical(nameCore5x5);
                    if (core5x5 == null)
                    {
                        core5x5 = new MathematicialSearchPoint8();
                    }

                    string        nameCore7x7 = manager.GetPrivateString("CORE", "7_core");
                    IMathematical core7x7     = getMathematical(nameCore5x5);
                    if (core7x7 == null)
                    {
                        core7x7 = new MathematicialSearchPoint9();
                    }

                    analysis = new Analysis(goodPoint, core3x3, core5x5, core7x7);
                    for (int i = 0; i < filesImagesname.Count; i++)
                    {
                        if (filesImagesname[i].EndsWith("sharpImage.png"))
                        {
                            continue;
                        }
                        Data.Image itemImage = new Data.Image(filesImagesname[i]);
                        analysis.addImageAnalysis(itemImage);
                    }
                    List <IMathematical> coreGoodPoint = analysis.getCore();
                    calculated = new Calculated();
                    calculated.createdBeginSolution();
                    for (int i = 0; i < filesImagesname.Count; i++)
                    {
                        if (filesImagesname[i].EndsWith("sharpImage.png"))
                        {
                            continue;
                        }
                        Data.Image itemImage = new Data.Image(filesImagesname[i]);
                        calculated.clarifySolution(itemImage, coreGoodPoint, goodPoint);
                    }
                }
                else
                {
                    string        nameCore = manager.GetPrivateString("SELECTION_CORE", "default_core");
                    IMathematical core     = getMathematical(nameCore);
                    if (core == null)
                    {
                        core = new MathematicialSearchPoint1();
                    }

                    calculated = new Calculated(core);
                    calculated.createdBeginSolution();
                    for (int i = 0; i < filesImagesname.Count; i++)
                    {
                        if (filesImagesname[i].EndsWith("sharpImage.png"))
                        {
                            continue;
                        }
                        Data.Image itemImage = new Data.Image(filesImagesname[i]);
                        calculated.clarifySolution(itemImage, goodPoint);
                    }
                }

                Solution solution = calculated.getSolution();
                timeForParsing.Stop();
                timeTxt.WriteLine(nameFolder + " - " + timeForParsing.ElapsedMilliseconds + " timeForParsing");
                preserveOBJ.saveOBJ(solution, setting, saveFolderCurrent);
                preservePNG.savePNG(solution, saveFolderCurrent);
                saveDat(solution.Map, saveFolderCurrent);
            }
            timeTxt.Close();
        }
コード例 #19
0
 public LatestData()
 {
     calculated = new Calculated();
 }
コード例 #20
0
        public static Parameter CreateCalculated(bool isIndirect, bool isRIPRelative, Calculated @base, Calculated index, Calculated scale, Calculated offset) => new Parameter()
        {
            Base   = @base,
            Index  = index,
            Scale  = scale,
            Offset = offset,

            IsIndirect    = isIndirect,
            IsRIPRelative = isRIPRelative,
            Type          = ParameterType.Calculated,
        };
コード例 #21
0
 private void OnCalculated(decimal result)
 {
     Calculated?.Invoke(this, result);
 }