Exemple #1
0
        protected override void UpdateMultithreaded()
        {
            if (backbuffer.Count != entries.Count)
            {
                backbuffer.Capacity = entries.Capacity;
                backbuffer.Count    = entries.Count;
            }
            Overlaps.Clear();
            //Sort along x axis using insertion sort; the list will be nearly sorted, so very few swaps are necessary.
            for (int i = 1; i < entries.Count; i++)
            {
                var entry = entries.Elements[i];
                for (int j = i - 1; j >= 0; j--)
                {
                    if (entry.boundingBox.Min.X < entries.Elements[j].boundingBox.Min.X)
                    {
                        entries.Elements[j + 1] = entries.Elements[j];
                        entries.Elements[j]     = entry;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            //TODO: Multithreaded sorting could help in some large cases.
            //The overhead involved in this implementation is way too high for reasonable object counts.
            //for (int i = 0; i < sortSegmentCount; i++)
            //    SortSection(i);

            ////MergeSections(0, 1);
            ////MergeSections(2, 3);
            ////MergeSections(0, 2);
            ////MergeSections(1, 3);

            //MergeSections(0, 1);
            //MergeSections(2, 3);
            //MergeSections(4, 5);
            //MergeSections(6, 7);

            //MergeSections(0, 2);
            //MergeSections(1, 3);
            //MergeSections(4, 6);
            //MergeSections(5, 7);

            //MergeSections(0, 4);
            //MergeSections(1, 5);
            //MergeSections(2, 6);
            //MergeSections(3, 7);

            //var temp = backbuffer;
            //backbuffer = entries;
            //entries = temp;

            ParallelLooper.ForLoop(0, sweepSegmentCount, sweepSegment);
        }
Exemple #2
0
 public RemoveOverlapsResult RemoveOverlaps(IEnumerable <Feature> selectedFeatures,
                                            Overlaps overlapsToRemove,
                                            IList <Feature> overlappingFeatures,
                                            CancellationToken cancellationToken)
 {
     return(RemoveOverlapsClientUtils.RemoveOverlaps(
                RemoveOverlapsClient, selectedFeatures, overlapsToRemove, overlappingFeatures,
                cancellationToken));
 }
        protected override void UpdateSingleThreaded()
        {
            lock (Locker)
            {
                Overlaps.Clear();
                //Update the placement of objects.
                for (int i = 0; i < entries.Count; i++)
                {
                    //Compute the current cells occupied by the entry.
                    var  entry = entries.Elements[i];
                    Int2 min, max;
                    ComputeCell(ref entry.item.boundingBox.Min, out min);
                    ComputeCell(ref entry.item.boundingBox.Max, out max);
                    //For any cell that used to be occupied (defined by the previous min/max),
                    //remove the entry.
                    for (int j = entry.previousMin.Y; j <= entry.previousMax.Y; j++)
                    {
                        for (int k = entry.previousMin.Z; k <= entry.previousMax.Z; k++)
                        {
                            if (j >= min.Y && j <= max.Y && k >= min.Z && k <= max.Z)
                            {
                                continue; //This cell is currently occupied, do not remove.
                            }
                            var index = new Int2 {
                                Y = j, Z = k
                            };
                            cellSet.Remove(ref index, entry);
                        }
                    }
                    //For any cell that is newly occupied (was not previously contained),
                    //add the entry.
                    for (int j = min.Y; j <= max.Y; j++)
                    {
                        for (int k = min.Z; k <= max.Z; k++)
                        {
                            if (j >= entry.previousMin.Y && j <= entry.previousMax.Y && k >= entry.previousMin.Z && k <= entry.previousMax.Z)
                            {
                                continue; //This cell is already occupied, do not add.
                            }
                            var index = new Int2 {
                                Y = j, Z = k
                            };
                            cellSet.Add(ref index, entry);
                        }
                    }
                    entry.previousMin = min;
                    entry.previousMax = max;
                }

                //Update each cell to find the overlaps.
                for (int i = 0; i < cellSet.count; i++)
                {
                    cellSet.cells.Elements[i].UpdateOverlaps(this);
                }
            }
        }
Exemple #4
0
 // Inherited
 public override void Clear()
 {
     Layering.Clear();
     EventTriggers.Clear();
     ExitTriggers.Clear();
     NPCObjects.Clear();
     Overlaps.Clear();
     TileSwitches.Clear();
     CollisionSwitches.Clear();
 }
Exemple #5
0
 public void Insert(int index, Overlap value)
 {
     if (index < Overlaps.Count)
     {
         Overlaps.Insert(index, value);
     }
     else
     {
         Overlaps.Add(value);
     }
 }
Exemple #6
0
        /// <summary>
        /// Adds a broad phase overlap if the collision rules permit it.
        /// </summary>
        /// <param name="entryA">First entry of the overlap.</param>
        /// <param name="entryB">Second entry of the overlap.</param>
        protected internal void TryToAddOverlap(BroadPhaseEntry entryA, BroadPhaseEntry entryB)
        {
            CollisionRule rule;

            if ((rule = GetCollisionRule(entryA, entryB)) < CollisionRule.NoBroadPhase)
            {
                overlapAddLock.Enter();
                Overlaps.Add(new BroadPhaseOverlap(entryA, entryB, rule));
                overlapAddLock.Exit();
            }
        }
 protected override void UpdateMultithreaded()
 {
     lock (Locker)
     {
         Overlaps.Clear();
         //Update the entries!
         ParallelLooper.ForLoop(0, entries.Count, updateEntry);
         //Update the cells!
         ParallelLooper.ForLoop(0, cellSet.count, updateCell);
     }
 }
Exemple #8
0
 public bool Remove(Overlap value)
 {
     for (int i = 0; i < Overlaps.Count; i++)
     {
         if (Overlaps[i] == value)
         {
             Overlaps.RemoveAt(i);
             return(true);
         }
     }
     return(false);
 }
Exemple #9
0
 protected override void UpdateSingleThreaded()
 {
     Overlaps.Clear();
     for (int i = 0; i < entries.Count; i++)
     {
         for (int j = i + 1; j < entries.Count; j++)
         {
             if (entries[i].boundingBox.Intersects(entries[j].boundingBox))
             {
                 base.TryToAddOverlap(entries[i], entries[j]);
             }
         }
     }
 }
Exemple #10
0
        public void Insert(int index, Point p)
        {
            var e = new Overlap();

            e.X = (byte)p.X;
            e.Y = (byte)p.Y;
            if (index < Overlaps.Count)
            {
                Overlaps.Insert(index, e);
            }
            else
            {
                Overlaps.Add(e);
            }
        }
Exemple #11
0
        protected override void UpdateSingleThreaded()
        {
            lock (Locker)
            {
                Overlaps.Clear();
                if (root != null)
                {
                    root.Refit();

                    if (!root.IsLeaf) //If the root is a leaf, it's alone- nothing to collide against! This test is required by the assumptions of the leaf-leaf test.
                    {
                        root.GetOverlaps(root, this);
                    }
                }
            }
        }
Exemple #12
0
        private static OverlapsRemover RemoveOverlaps(
            [NotNull] IList <IFeature> selectedFeatureList,
            [NotNull] Overlaps overlaps,
            [NotNull] IList <IFeature> targetFeaturesForVertexInsertion,
            bool explodeMultiparts,
            bool storeOverlapsAsNewFeatures,
            [CanBeNull] ITrackCancel trackCancel)
        {
            var overlapsRemover =
                new OverlapsRemover(explodeMultiparts, storeOverlapsAsNewFeatures);

            overlapsRemover.CalculateResults(
                selectedFeatureList, overlaps, targetFeaturesForVertexInsertion, trackCancel);

            return(overlapsRemover);
        }
 public void OverLapTests()
 {
     bool[,] grid = new bool[8, 8]
     {
         { false, false, false, false, false, false, false, false },
         { false, false, false, true, false, false, false, false },
         { false, false, true, false, false, false, false, false },
         { false, true, false, false, false, false, false, false },
         { true, false, false, false, false, false, false, false },
         { false, false, false, false, false, false, false, false },
         { false, false, false, false, false, false, false, false },
         { false, false, false, false, false, false, false, false }
     };
     if (!Overlaps.DoesOverlap(grid))
     {
         throw new Exception("Failed!");
     }
 }
        protected override bool SelectAndProcessDerivedGeometry(
            Dictionary <MapMember, List <long> > selection,
            Geometry sketch,
            CancelableProgressor progressor)
        {
            Assert.NotNull(_overlaps);

            Overlaps overlapsToRemove = SelectOverlaps(_overlaps, sketch);

            if (!overlapsToRemove.HasOverlaps())
            {
                return(false);
            }

            IEnumerable <Feature> selectedFeatures = MapUtils.GetFeatures(selection);

            RemoveOverlapsResult result =
                MicroserviceClient.RemoveOverlaps(
                    selectedFeatures, overlapsToRemove, _overlappingFeatures,
                    progressor?.CancellationToken ?? new CancellationTokenSource().Token);

            var updates = new Dictionary <Feature, Geometry>();
            var inserts = new Dictionary <Feature, IList <Geometry> >();

            foreach (var resultPerFeature in result.ResultsByFeature)
            {
                updates.Add(resultPerFeature.OriginalFeature, resultPerFeature.UpdatedGeometry);

                if (resultPerFeature.InsertGeometries.Count > 0)
                {
                    inserts.Add(resultPerFeature.OriginalFeature,
                                resultPerFeature.InsertGeometries);
                }
            }

            bool saved = GdbPersistenceUtils.SaveInOperation("Remove overlaps", updates, inserts);

            var currentSelection = SelectionUtils.GetSelectedFeatures(MapView.Active).ToList();

            CalculateDerivedGeometries(currentSelection, progressor);

            return(saved);
        }
        /// <summary>
        /// Calculate a list of which views overlap this handle.
        /// </summary>
        /// <param name="group">The parent texture group, used to find a view's base CPU VA offset</param>
        /// <param name="views">The list of views to search for overlaps</param>
        public void RecalculateOverlaps(TextureGroup group, List <Texture> views)
        {
            // Overlaps can be accessed from the memory tracking signal handler, so access must be atomic.
            lock (Overlaps)
            {
                int endOffset = Offset + Size;

                Overlaps.Clear();

                foreach (Texture view in views)
                {
                    int viewOffset = group.FindOffset(view);
                    if (viewOffset < endOffset && Offset < viewOffset + (int)view.Size)
                    {
                        Overlaps.Add(view);
                    }
                }
            }
        }
Exemple #16
0
        protected override void UpdateSingleThreaded()
        {
            lock (Locker)
            {
                Overlaps.Clear();
                if (root != null)
                {
#if PROFILE
                    startRefit = Stopwatch.GetTimestamp();
#endif
                    SingleThreadedRefitPhase();
#if PROFILE
                    endRefit = Stopwatch.GetTimestamp();
#endif
                    SingleThreadedOverlapPhase();
#if PROFILE
                    endOverlap = Stopwatch.GetTimestamp();
#endif
                }
            }
        }
Exemple #17
0
        protected override void UpdateMultithreaded()
        {
            lock (Locker)
            {
                Overlaps.Clear();
                if (root != null)
                {
                    int splitDepth = GetSplitDepth();
#if PROFILE
                    startRefit = Stopwatch.GetTimestamp();
#endif
                    MultithreadedRefitPhase(splitDepth);
#if PROFILE
                    endRefit = Stopwatch.GetTimestamp();
#endif
                    MultithreadedOverlapPhase(splitDepth);
#if PROFILE
                    endOverlap = Stopwatch.GetTimestamp();
#endif
                }
            }
        }
Exemple #18
0
        protected override void UpdateSingleThreaded()
        {
            Overlaps.Clear();
            //Sort along x axis using insertion sort; the list will be nearly sorted, so very few swaps are necessary.
            for (int i = 1; i < entries.Count; i++)
            {
                BroadPhaseEntry entry = entries.Elements[i];
                for (int j = i - 1; j >= 0; j--)
                {
                    if (entry.boundingBox.Min.X < entries.Elements[j].boundingBox.Min.X)
                    {
                        entries.Elements[j + 1] = entries.Elements[j];
                        entries.Elements[j]     = entry;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            //Sweep the list looking for overlaps.
            for (int i = 0; i < entries.Count; i++)
            {
                BoundingBox a = entries.Elements[i].boundingBox;
                for (int j = i + 1; j < entries.Count && a.Max.X >= entries.Elements[j].boundingBox.Min.X; j++)
                {
                    if (!(a.Min.Y > entries.Elements[j].boundingBox.Max.Y ||
                          a.Max.Y <entries.Elements[j].boundingBox.Min.Y ||
                                   a.Min.Z> entries.Elements[j].boundingBox.Max.Z ||
                          a.Max.Z < entries.Elements[j].boundingBox.Min.Z))
                    {
                        TryToAddOverlap(entries.Elements[i], entries.Elements[j]);
                    }
                }
            }
        }
Exemple #19
0
 protected internal void AddOverlap(BroadPhaseOverlap overlap)
 {
     overlapAddLock.Enter();
     Overlaps.Add(overlap);
     overlapAddLock.Exit();
 }
Exemple #20
0
        protected override void UpdateSingleThreaded()
        {
            overlapCandidatesX.Clear();
            overlapCandidatesY.Clear();
            Overlaps.Clear();

            //Sort along x axis using insertion sort; the list will be nearly sorted, so very few swaps are necessary.
            for (int i = 1; i < entriesX.count; i++)
            {
                var entry = entriesX.Elements[i];
                for (int j = i - 1; j >= 0; j--)
                {
                    if (entry.boundingBox.Min.X < entriesX.Elements[j].boundingBox.Min.X)
                    {
                        entriesX.Elements[j + 1] = entriesX.Elements[j];
                        entriesX.Elements[j]     = entry;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            //Sort along y axis using insertion sort; the list will be nearly sorted, so very few swaps are necessary.
            for (int i = 1; i < entriesY.count; i++)
            {
                var entry = entriesY.Elements[i];
                for (int j = i - 1; j >= 0; j--)
                {
                    if (entry.boundingBox.Min.Y < entriesY.Elements[j].boundingBox.Min.Y)
                    {
                        entriesY.Elements[j + 1] = entriesY.Elements[j];
                        entriesY.Elements[j]     = entry;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            //Sort along z axis using insertion sort; the list will be nearly sorted, so very few swaps are necessary.
            for (int i = 1; i < entriesZ.count; i++)
            {
                var entry = entriesZ.Elements[i];
                for (int j = i - 1; j >= 0; j--)
                {
                    if (entry.boundingBox.Min.Z < entriesZ.Elements[j].boundingBox.Min.Z)
                    {
                        entriesZ.Elements[j + 1] = entriesZ.Elements[j];
                        entriesZ.Elements[j]     = entry;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            //Hash-set based sweeping is way too slow.  3D sap is really best suited to an incremental approach.

            //Sweep the list looking for overlaps.
            //Sweep the X axis first; in this phase, add overlaps to the hash set if they exist.
            for (int i = 0; i < entriesX.count; i++)
            {
                BoundingBox a = entriesX.Elements[i].boundingBox;
                for (int j = i + 1; j < entriesX.count && a.Max.X > entriesX.Elements[j].boundingBox.Min.X; j++)
                {
                    overlapCandidatesX.Add(new BroadPhaseOverlap(entriesX.Elements[i], entriesX.Elements[j]));
                }
            }
            //Sweep the Y axis second; same thing
            for (int i = 0; i < entriesY.count; i++)
            {
                BoundingBox a = entriesY.Elements[i].boundingBox;
                for (int j = i + 1; j < entriesY.count && a.Max.Y > entriesY.Elements[j].boundingBox.Min.Y; j++)
                {
                    overlapCandidatesY.Add(new BroadPhaseOverlap(entriesY.Elements[i], entriesY.Elements[j]));
                }
            }
            //Sweep the Z axis last
            for (int i = 0; i < entriesZ.count; i++)
            {
                BoundingBox a = entriesZ.Elements[i].boundingBox;
                for (int j = i + 1; j < entriesZ.count && a.Max.Z > entriesZ.Elements[j].boundingBox.Min.Z; j++)
                {
                    var overlap = new BroadPhaseOverlap(entriesZ.Elements[i], entriesZ.Elements[j]);
                    if (overlapCandidatesX.Contains(overlap) && overlapCandidatesY.Contains(overlap))
                    {
                        TryToAddOverlap(entriesZ.Elements[i], entriesZ.Elements[j]);
                    }
                }
            }
        }
 protected override void ResetDerivedGeometries()
 {
     _overlaps = null;
     _feedback.DisposeOverlays();
 }
Exemple #22
0
 public VirtualAxis(Input input, Overlaps overlapBehaviour)
 {
     Input            = input;
     OverlapBehaviour = overlapBehaviour;
 }
Exemple #23
0
        /// <summary>
        /// Construct initialization.
        /// </summary>
        /// <param name="fragList">Fragment list.</param>
        /// <param name="maxOverlapLen">Minimum overlap length.</param>
        private void Init(ObservableCollection <Fragment> fragList, DesignerSettings settings)
        {
            this.Overlaps = new List <Overlap>();
            this.Settings = settings;
            //forward
            String             seq5     = "";
            String             seq3     = "";
            String             name     = "";
            List <MiscFeature> featList = new List <MiscFeature>();

            for (int i = 0; i < fragList.Count; i++)
            {
                name += fragList[i].Name;
                seq3  = fragList[i].GetString();
                int         len5         = Math.Min(settings.MaxOverlapLen, seq5.Length);
                int         len3         = Math.Min(settings.MaxGeneSpecificLen, seq3.Length);
                String      overlapping  = seq5.Substring(seq5.Length - len5, len5);
                String      geneSpecific = seq3.Substring(0, len3);
                String      loc          = (seq5.Length + 1).ToString() + ".." + (seq5.Length + seq3.Length).ToString();
                MiscFeature gene         = new MiscFeature(loc);
                gene.StandardName = fragList[i].Name;
                featList.Add(gene);
                seq5 += seq3;
                if (i == 0)
                {
                    Overlaps.Add(new Overlap(fragList[i].Name + "_fwd", new Sequence(Alphabets.DNA, geneSpecific)));
                }
                else
                {
                    Overlaps.Add(new Overlap(fragList[i].Name + "_fwd", new Sequence(Alphabets.DNA, overlapping), new Sequence(Alphabets.DNA, geneSpecific)));
                }
            }

            this.Sequence = new Sequence(Alphabets.DNA, seq5);
            //meta
            GenBankMetadata meta = new GenBankMetadata();

            meta.Locus = new GenBankLocusInfo();
            meta.Locus.MoleculeType   = MoleculeType.DNA;
            meta.Locus.Name           = name;
            meta.Locus.Date           = System.DateTime.Now;
            meta.Locus.SequenceLength = seq5.Length;
            meta.Comments.Add("designed with mufasa");
            meta.Definition = "synthetic construct";
            meta.Features   = new SequenceFeatures();
            meta.Features.All.AddRange(featList);
            this.Sequence.Metadata.Add("GenBank", meta);

            //reverse
            fragList.Add(new Fragment(fragList[0]));
            fragList.RemoveAt(0);
            seq5 = "";
            seq3 = "";
            for (int i = fragList.Count - 1; i >= 0; i--)
            {
                seq5 = fragList[i].GetReverseComplementString();
                int    len3         = Math.Min(settings.MaxOverlapLen, seq3.Length);
                int    len5         = Math.Min(settings.MaxGeneSpecificLen, seq5.Length);
                String overlapping  = seq3.Substring(seq3.Length - len3, len3);
                String geneSpecific = seq5.Substring(0, len5);
                seq3 += seq5;
                if (i == fragList.Count - 1)
                {
                    Overlaps.Add(new Overlap(fragList[i].Name + "_rev", new Sequence(Alphabets.DNA, geneSpecific)));
                }
                else
                {
                    Overlaps.Add(new Overlap(fragList[i].Name + "_rev", new Sequence(Alphabets.DNA, overlapping), new Sequence(Alphabets.DNA, geneSpecific)));
                }
            }
            TermoOptimizeOverlaps();
        }
        protected override bool SelectAndProcessDerivedGeometry(
            Dictionary <MapMember, List <long> > selection,
            Geometry sketch,
            CancelableProgressor progressor)
        {
            Assert.NotNull(_overlaps);

            Overlaps overlapsToRemove = SelectOverlaps(_overlaps, sketch);

            if (!overlapsToRemove.HasOverlaps())
            {
                return(false);
            }

            IEnumerable <Feature> selectedFeatures = MapUtils.GetFeatures(selection);

            RemoveOverlapsResult result =
                MicroserviceClient.RemoveOverlaps(
                    selectedFeatures, overlapsToRemove, _overlappingFeatures,
                    progressor?.CancellationToken ?? new CancellationTokenSource().Token);

            var updates = new Dictionary <Feature, Geometry>();
            var inserts = new Dictionary <Feature, IList <Geometry> >();

            HashSet <long> editableClassHandles =
                MapUtils.GetLayers <BasicFeatureLayer>(MapView.Active, bfl => bfl.IsEditable)
                .Select(l => l.GetTable().Handle.ToInt64()).ToHashSet();

            foreach (OverlapResultGeometries resultPerFeature in result.ResultsByFeature)
            {
                if (!GdbPersistenceUtils.CanChange(resultPerFeature.OriginalFeature,
                                                   editableClassHandles, out string warning))
                {
                    _msg.WarnFormat("{0}: {1}",
                                    GdbObjectUtils.ToString(resultPerFeature.OriginalFeature),
                                    warning);
                    continue;
                }

                updates.Add(resultPerFeature.OriginalFeature, resultPerFeature.UpdatedGeometry);

                if (resultPerFeature.InsertGeometries.Count > 0)
                {
                    inserts.Add(resultPerFeature.OriginalFeature,
                                resultPerFeature.InsertGeometries);
                }
            }

            if (result.TargetFeaturesToUpdate != null)
            {
                foreach (KeyValuePair <Feature, Geometry> kvp in result.TargetFeaturesToUpdate)
                {
                    if (!GdbPersistenceUtils.CanChange(kvp.Key,
                                                       editableClassHandles, out string warning))
                    {
                        _msg.WarnFormat("{0}: {1}", GdbObjectUtils.ToString(kvp.Key), warning);
                        continue;
                    }

                    updates.Add(kvp.Key, kvp.Value);
                }
            }

            bool saved = GdbPersistenceUtils.SaveInOperation("Remove overlaps", updates, inserts);

            var currentSelection = GetApplicableSelectedFeatures(MapView.Active).ToList();

            CalculateDerivedGeometries(currentSelection, progressor);

            return(saved);
        }
Exemple #25
0
        public static RemoveOverlapsResponse RemoveOverlaps(
            [NotNull] RemoveOverlapsRequest request,
            [CanBeNull] ITrackCancel trackCancel = null)
        {
            // Unpack request
            bool explodeMultiparts          = request.ExplodeMultipartResults;
            bool storeOverlapsAsNewFeatures = request.StoreOverlapsAsNewFeatures;

            GdbTableContainer container = ProtobufConversionUtils.CreateGdbTableContainer(
                request.ClassDefinitions, null, out _);

            IList <IFeature> selectedFeatureList =
                ProtobufConversionUtils.FromGdbObjectMsgList(
                    request.SourceFeatures, container);

            IList <IFeature> targetFeaturesForVertexInsertion =
                ProtobufConversionUtils.FromGdbObjectMsgList(
                    request.UpdatableTargetFeatures, container);

            Overlaps overlaps = new Overlaps();

            foreach (OverlapMsg overlapMsg in request.Overlaps)
            {
                GdbObjectReference gdbRef = new GdbObjectReference(
                    overlapMsg.OriginalFeatureRef.ClassHandle,
                    overlapMsg.OriginalFeatureRef.ObjectId);

                IFeatureClass fClass = (IFeatureClass)container.GetByClassId(gdbRef.ClassId);

                List <IGeometry> overlapGeometries =
                    ProtobufGeometryUtils.FromShapeMsgList <IGeometry>(
                        overlapMsg.Overlaps,
                        DatasetUtils.GetSpatialReference(fClass));

                overlaps.AddGeometries(gdbRef, overlapGeometries);
            }

            // Remove overlaps
            OverlapsRemover overlapsRemover = RemoveOverlaps(
                selectedFeatureList, overlaps, targetFeaturesForVertexInsertion, explodeMultiparts,
                storeOverlapsAsNewFeatures, trackCancel);

            // Pack response
            var result = overlapsRemover.Result;

            var response = new RemoveOverlapsResponse();

            PackResultGeometries(result.ResultsByFeature,
                                 response.ResultsByFeature);

            response.NonStorableMessages.AddRange(result.NonStorableMessages);

            if (result.TargetFeaturesToUpdate != null)
            {
                foreach (var keyValuePair in result.TargetFeaturesToUpdate)
                {
                    IFeature  feature     = keyValuePair.Key;
                    IGeometry newGeometry = keyValuePair.Value;

                    GdbObjectMsg targetFeatureMsg =
                        ProtobufGdbUtils.ToGdbObjectMsg(
                            feature, newGeometry, feature.Class.ObjectClassID);

                    response.TargetFeaturesToUpdate.Add(targetFeatureMsg);
                }
            }

            response.ResultHasMultiparts = result.ResultHasMultiparts;

            return(response);
        }
Exemple #26
0
        public static CalculateOverlapsResponse CalculateOverlaps(
            [NotNull] CalculateOverlapsRequest request,
            [CanBeNull] ITrackCancel trackCancel)
        {
            var watch = Stopwatch.StartNew();

            IList <IFeature> sourceFeatures =
                ProtobufConversionUtils.FromGdbObjectMsgList(
                    request.SourceFeatures, request.ClassDefinitions);

            IList <IFeature> targetFeatures =
                ProtobufConversionUtils.FromGdbObjectMsgList(
                    request.TargetFeatures, request.ClassDefinitions);

            _msg.DebugStopTiming(watch, "Unpacked feature lists from request params");

            Overlaps selectableOverlaps = RemoveOverlapsUtils.GetSelectableOverlaps(
                sourceFeatures, targetFeatures, trackCancel);

            watch = Stopwatch.StartNew();

            var result = new CalculateOverlapsResponse();

            foreach (var overlapByGdbRef
                     in selectableOverlaps.OverlapsBySourceRef)
            {
                var gdbObjRefMsg = ProtobufGdbUtils.ToGdbObjRefMsg(overlapByGdbRef.Key);

                var overlap = overlapByGdbRef.Value;

                var overlapsMsg = new OverlapMsg()
                {
                    OriginalFeatureRef = gdbObjRefMsg
                };

                foreach (IGeometry geometry in overlap)
                {
                    // TODO: At some point the SR-XY tol/res should be transferred separately (via class-lookup?)
                    var shapeFormat = ShapeMsg.FormatOneofCase.EsriShape;
                    var srFormat    = SpatialReferenceMsg.FormatOneofCase.SpatialReferenceEsriXml;

                    overlapsMsg.Overlaps.Add(
                        ProtobufGeometryUtils.ToShapeMsg(
                            geometry, shapeFormat, srFormat));

                    if (_msg.IsVerboseDebugEnabled)
                    {
                        _msg.VerboseDebug(
                            $"Calculated overlap: {GeometryUtils.ToString(geometry)}");
                    }
                }

                result.Overlaps.Add(overlapsMsg);
            }

            foreach (var notification in selectableOverlaps.Notifications)
            {
                result.Notifications.Add(notification.Message);
            }

            _msg.DebugStopTiming(watch, "Packed overlaps into response");

            return(result);
        }
Exemple #27
0
 public void RemoveAt(int index)
 {
     Overlaps.RemoveAt(index);
 }