public object Clone() { SplittedSegment ss = new SplittedSegment(); ss.Segment = this.Segment; ss.UsedByObject1 = this.UsedByObject1; ss.UsedByObject2 = this.UsedByObject2; ss.Object1OccurrencesCount = this.Object1OccurrencesCount; ss.Object2OccurrencesCount = this.Object2OccurrencesCount; return ss; }
private void removeSplittedSegment(SplittedSegment ss) { if (_splittedSegmentIndex != null) _splittedSegmentIndex.Remove(ss); else _splittedSegments.Remove(ss); }
private void splitSegments() { double tolerance = PlanimetryAlgorithms.Tolerance; while (_sourceSegments.Count > 0) { SourceSegment currentSegment = _sourceSegments[_sourceSegments.Count - 1]; _sourceSegments.RemoveAt(_sourceSegments.Count - 1); normalizeSourceSegment(currentSegment); // calculate the lengths that can match the current or intersects with the List<SplittedSegment> relatedSegments = getRelatedSegments(currentSegment.Segment); // update previously treated segment in the case of complete coincidence, if it was a coincidence, continue if (updateSplittedSegment(relatedSegments, currentSegment)) continue; // Splits the current segment of the nodes if the segment was split, continue if (splitSegmentByNodes(currentSegment)) continue; // Splits the current segment of the other segment if the segment was split, continue if (splitSegmentBySegments(relatedSegments, currentSegment)) continue; // if we got here, then the segment does not require additional processing, add it to the list of processed segments SplittedSegment ss = new SplittedSegment(); ss.UsedByObject1 = currentSegment.ObjectNumber == 1; ss.UsedByObject2 = currentSegment.ObjectNumber == 2; ss.Object1OccurrencesCount = currentSegment.ObjectNumber == 1 ? 1 : 0; ss.Object2OccurrencesCount = currentSegment.ObjectNumber == 2 ? 1 : 0; ss.Segment = currentSegment.Segment; addSplittedSegment(ss); } }
private void addSplittedSegment(SplittedSegment ss) { if (_splittedSegmentIndex != null) _splittedSegmentIndex.Insert(ss); else { double tolerance = PlanimetryAlgorithms.Tolerance; double v1x = ss.Segment.V1.X; int startIndex = 0, endIndex = _splittedSegments.Count - 1; while (endIndex - startIndex > 1) { int index = startIndex + (endIndex - startIndex) / 2; if (_splittedSegments[index].Segment.V1.X < v1x) startIndex = index; else endIndex = index; } while (startIndex > 0 && _splittedSegments[startIndex].Segment.V1.X + tolerance > v1x) startIndex--; while (endIndex < _splittedSegments.Count - 1 && _splittedSegments[endIndex].Segment.V1.X - tolerance < v1x) endIndex++; for (int i = startIndex; i <= endIndex; i++) { if (_splittedSegments[i].Segment.V1.X > v1x) { _splittedSegments.Insert(i, ss); return; } } _splittedSegments.Add(ss); } }