Exemple #1
0
        private static void ValidateForm([NotNull] IIndexedMultiPatch indexedMultiPatch,
                                         [NotNull] IEnumerable <WKSPointZ> projected)
        {
            var  pre      = new WKSPointZ();
            bool notFirst = false;
            IEnumerator <SegmentProxy> segments =
                indexedMultiPatch.GetSegments().GetEnumerator();

            foreach (WKSPointZ wksPoint in projected)
            {
                Assert.AreEqual(0, wksPoint.Z);

                if (notFirst)
                {
                    double dx     = wksPoint.X - pre.X;
                    double dy     = wksPoint.Y - pre.Y;
                    double length = Math.Sqrt(dx * dx + dy * dy);

                    Assert.IsTrue(segments.MoveNext());
                    Assert.IsNotNull(segments.Current);

                    const bool as3D          = true;
                    IPnt       start         = segments.Current.GetStart(as3D);
                    IPnt       end           = segments.Current.GetEnd(as3D);
                    double     segDx         = end.X - start.X;
                    double     segDy         = end.Y - start.Y;
                    double     segDz         = end[2] - start[2];
                    double     segmentLength = Math.Sqrt(segDx * segDx + segDy * segDy + segDz * segDz);
                    Assert.IsTrue(Math.Abs(segmentLength - length) < 1.0e-8);
                }

                pre      = wksPoint;
                notFirst = true;
            }
        }
        private SliverAreaProvider GetSliverAreaProvider([NotNull] IFeature feature)
        {
            Assert.ArgumentNotNull(feature, nameof(feature));

            if (_useFields)
            {
                return(new FromFieldsSliverAreaProvider(feature, _areaFieldIndex,
                                                        _lengthFieldIndex));
            }

            if (feature.Shape is IPolygon)
            {
                return(new PolygonRingsSliverAreaProvider((IPolygon)feature.Shape));
            }

            if (feature.Shape is IMultiPatch)
            {
                var indexedMultiPatchFeature = feature as IIndexedMultiPatchFeature;

                IIndexedMultiPatch indexedMultiPatch =
                    indexedMultiPatchFeature != null
                                                ? indexedMultiPatchFeature.IndexedMultiPatch
                                                : QaGeometryUtils.CreateIndexedMultiPatch((IMultiPatch)feature.Shape);

                return(new MultiPatchPartsSliverAreaProvider(indexedMultiPatch));
            }

            throw new InvalidOperationException("feature is unhandled");
        }
 public PlaneVerticalHelper([NotNull] SegmentsPlane segmentsPlane,
                            [NotNull] IIndexedMultiPatch indexedMultipatch)
     : base(segmentsPlane)
 {
     Assert.ArgumentNotNull(indexedMultipatch, nameof(indexedMultipatch));
     // not yet used
 }
 public MultipatchHeightSegmentPairProvider(double nearHeight,
                                            [NotNull] IIndexedMultiPatch
                                            multiPatch)
     : base(nearHeight)
 {
     _multiPatch = multiPatch;
 }
 public MultiPatchPartsSliverAreaProvider(
     [NotNull] IIndexedMultiPatch indexedMultiPatch)
 {
     _indexedMultiPatch = indexedMultiPatch;
     _segmentsEnum      = _indexedMultiPatch.GetSegments().GetEnumerator();
     _enumValid         = _segmentsEnum.MoveNext();
 }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SimpleFootprintProvider"/> class.
 /// </summary>
 /// <param name="multiPatchFeature">The multipatch feature.</param>
 /// <param name="alternateSpatialReference">
 /// An optional alternate spatial reference to get the multipatch in
 /// (must have the same coordinate system; resolution/tolerance may be different).</param>
 public SimpleFootprintProvider([NotNull] IFeature multiPatchFeature,
                                [CanBeNull] ISpatialReference
                                alternateSpatialReference)
     : base(alternateSpatialReference)
 {
     _multiPatch = GetIndexedMultipatch(multiPatchFeature);
 }
Exemple #7
0
 public SurfaceSegmentsPlaneProvider(
     [NotNull] IIndexedMultiPatch indexedMultiPatch)
     : base(indexedMultiPatch)
 {
     _indexedMultiPatch = indexedMultiPatch;
     _segmentsEnum      = _indexedMultiPatch.GetSegments().GetEnumerator();
     _enumValid         = _segmentsEnum.MoveNext();
 }
 public AllPerpendicularSegmentsProvider(double nearAngelRad,
                                         double horizontalToleranceRad,
                                         double xyResolution,
                                         [NotNull] IIndexedMultiPatch multiPatch)
     : base(nearAngelRad, horizontalToleranceRad, xyResolution)
 {
     _multiPatch = multiPatch;
 }
 public RingParallelSegmentPairProvider(double nearAngleRad,
                                        double horizontalToleranceRad,
                                        double xyResolution,
                                        [NotNull] IIndexedMultiPatch multiPatch)
     : base(nearAngleRad, horizontalToleranceRad, xyResolution)
 {
     _multiPatch = multiPatch;
 }
        private HeightSegmentPairProvider GetHeightSegmentPairProvider(
            [NotNull] IFeature feature)
        {
            var indexedFeature            = feature as IIndexedMultiPatchFeature;
            IIndexedMultiPatch multiPatch = indexedFeature?.IndexedMultiPatch ??
                                            QaGeometryUtils.CreateIndexedMultiPatch(
                (IMultiPatch)feature.Shape);

            return(new MultipatchHeightSegmentPairProvider(_nearHeight, multiPatch));
        }
        private static VerticalFaceProvider GetPlaneProvider([NotNull] IFeature feature)
        {
            var indexedMultiPatchFeature = feature as IIndexedMultiPatchFeature;

            IIndexedMultiPatch indexedMultiPatch =
                indexedMultiPatchFeature?.IndexedMultiPatch ??
                QaGeometryUtils.CreateIndexedMultiPatch((IMultiPatch)feature.Shape);

            return(new PartVerticalFaceProvider(indexedMultiPatch));
        }
            public ConnectedPerpendicularSegmentsProvider(double nearAngelRad,
                                                          double horizontalToleranceRad,
                                                          double connectedTolerance,
                                                          double xyResolution,
                                                          [NotNull] IIndexedMultiPatch
                                                          multiPatch)
                : base(nearAngelRad, horizontalToleranceRad, xyResolution)
            {
                _connectedTolerance = connectedTolerance;

                List <AzimuthSegment> horizontalSegments = ReadAllHorizontalSegments(multiPatch);

                horizontalSegments.Sort(AzimuthSegment.CompareAzimuth);

                _sortedHorizontalSegments = horizontalSegments;
            }
Exemple #13
0
            protected IIndexedMultiPatch GetIndexedMultipatch(
                [NotNull] IFeature multiPatchFeature)
            {
                Assert.ArgumentNotNull(multiPatchFeature, nameof(multiPatchFeature));

                var indexedMultiPatchFeature =
                    multiPatchFeature as IIndexedMultiPatchFeature;

                IIndexedMultiPatch result =
                    indexedMultiPatchFeature != null && _alternateSpatialReference == null
                                                ? indexedMultiPatchFeature.IndexedMultiPatch
                                                : QaGeometryUtils.CreateIndexedMultiPatch(
                        GetMultiPatch(multiPatchFeature));

                return(result);
            }
            public static PlaneHelper Create(
                [NotNull] SegmentsPlane segmentsPlane,
                [NotNull] IIndexedMultiPatch indexedMultipatch,
                [NotNull] QaMpVertexNotNearFace parent)
            {
                if (parent.CheckMethod != OffsetMethod.Vertical)
                {
                    throw new NotImplementedException();
                }

                PlaneHelper planeHelper =
                    new PlaneVerticalHelper(segmentsPlane, indexedMultipatch);

                planeHelper._parent = parent;

                return(planeHelper);
            }
Exemple #15
0
        public void IsPlaneVerticalTest()
        {
            var construction = new MultiPatchConstruction();

            construction.StartRing(0, 0, 0)
            .Add(5, 0, 0)
            .Add(5, 0, 5)
            .Add(0, 0, 5);
            IMultiPatch        multiPatch        = construction.MultiPatch;
            IIndexedMultiPatch indexedMultiPatch =
                QaGeometryUtils.CreateIndexedMultiPatch(multiPatch);

            Plane     plane  = QaGeometryUtils.CreatePlane(indexedMultiPatch.GetSegments());
            WKSPointZ normal = plane.GetNormalVector();

            Assert.AreEqual(0, normal.Z);
        }
Exemple #16
0
        public void CanProjectToPlaneTest()
        {
            var construction = new MultiPatchConstruction();

            construction.StartRing(0, 0, 0)
            .Add(5, 0, 0)
            .Add(5, 0, 5)
            .Add(0, 0, 5);
            IMultiPatch        multiPatch        = construction.MultiPatch;
            IIndexedMultiPatch indexedMultiPatch =
                QaGeometryUtils.CreateIndexedMultiPatch(multiPatch);

            IList <Pnt>       points    = QaGeometryUtils.GetPoints(indexedMultiPatch.GetSegments());
            Plane             plane     = QaGeometryUtils.CreatePlane(points);
            IList <WKSPointZ> projected = QaGeometryUtils.ProjectToPlane(plane, points);

            ValidateForm(indexedMultiPatch, projected);
        }
        private ParallelSegmentPairProvider GetParallelSegmentPairProvider(
            [NotNull] IFeature feature)
        {
            var indexedFeature            = feature as IIndexedMultiPatchFeature;
            IIndexedMultiPatch multiPatch = indexedFeature?.IndexedMultiPatch ??
                                            QaGeometryUtils.CreateIndexedMultiPatch(
                (IMultiPatch)feature.Shape);

            if (_perRing)
            {
                return(new RingParallelSegmentPairProvider(_nearAngleRad,
                                                           _horizontalToleranceRad,
                                                           _xyResolution, multiPatch));
            }

            return(new MultipatchParallelSegmentPairProvider(_nearAngleRad,
                                                             _horizontalToleranceRad,
                                                             _xyResolution, multiPatch));
        }
        private static NearFeatureCoincidence CreateCoincidenceChecker(
            [NotNull] IFeature feature)
        {
            var indexedSegmentsFeature = feature as IIndexedSegmentsFeature;

            if (indexedSegmentsFeature != null)
            {
                return(new IndexedSegmentsNearFeatureCoincidence(
                           feature, indexedSegmentsFeature.IndexedSegments));
            }

            IGeometry        shape     = feature.Shape;
            esriGeometryType shapeType = shape.GeometryType;

            if (shapeType == esriGeometryType.esriGeometryPolygon ||
                shapeType == esriGeometryType.esriGeometryPolyline)
            {
                var indexedPolycurve = new IndexedPolycurve((IPointCollection4)shape);
                return(new IndexedSegmentsNearFeatureCoincidence(feature, indexedPolycurve));
            }

            if (shapeType == esriGeometryType.esriGeometryMultiPatch)
            {
                IIndexedMultiPatch indexedMultiPatch =
                    QaGeometryUtils.CreateIndexedMultiPatch((IMultiPatch)shape);
                return(new IndexedSegmentsNearFeatureCoincidence(feature,
                                                                 indexedMultiPatch));
            }

            if (shapeType == esriGeometryType.esriGeometryPoint)
            {
                return(new PointNearFeatureCoincidence(feature, (IPoint)shape));
            }

            if (shapeType == esriGeometryType.esriGeometryMultipoint)
            {
                return(new MultipointNearFeatureCoincidence(feature, (IMultipoint)shape));
            }

            throw new InvalidOperationException("Unhandled geometry type: " +
                                                feature.Shape.GeometryType);
        }
        private PerpendicularSegmentsProvider GetPerpendicularSegmentsProvider(
            IFeature feature)
        {
            var indexedFeature            = feature as IIndexedMultiPatchFeature;
            IIndexedMultiPatch multiPatch = indexedFeature?.IndexedMultiPatch ??
                                            QaGeometryUtils.CreateIndexedMultiPatch(
                (IMultiPatch)feature.Shape);

            if (!_connectedOnly)
            {
                return(new AllPerpendicularSegmentsProvider(_nearAngleRad,
                                                            _horizontalToleranceRad,
                                                            _xyResolution, multiPatch));
            }

            return(new ConnectedPerpendicularSegmentsProvider(_nearAngleRad,
                                                              _horizontalToleranceRad,
                                                              _connectedTolerance,
                                                              _xyResolution, multiPatch));
        }
Exemple #20
0
        public void CanGetInnerPartIndexesOuterRingRing()
        {
            var construction = new MultiPatchConstruction();

            construction.StartOuterRing(5, 4, 0).Add(-5, 4, 0).Add(-5, -4, 0).Add(5, -4, 0)
            .StartRing(4, 3, 0).Add(-4, 3, 0).Add(-4, -3, 0).Add(4, -3, 0);

            IMultiPatch multiPatch = construction.MultiPatch;

            ((IGeometry)multiPatch).SpatialReference =
                SpatialReferenceUtils.CreateSpatialReference(
                    (int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95);

            IIndexedMultiPatch indexedMultiPatch =
                QaGeometryUtils.CreateIndexedMultiPatch(multiPatch);

            List <int> innerPartIndexes =
                MultiPatchUtils.GetInnerRingPartIndexes(indexedMultiPatch, 0);

            Assert.AreEqual(0, innerPartIndexes.Count);
        }
Exemple #21
0
        public static SegmentsPlaneProvider Create(
            [NotNull] IFeature feature,
            esriGeometryType shapeType,
            bool includeAssociatedParts)
        {
            if (shapeType == esriGeometryType.esriGeometryMultiPatch)
            {
                IIndexedMultiPatch indexedMultiPatch = GetIndexedMultiPatch(feature);

                return(includeAssociatedParts
                                               ? (SegmentsPlaneProvider)
                       new SurfaceSegmentsPlaneProvider(indexedMultiPatch)
                                               : new PartSegmentsPlaneProvider(indexedMultiPatch, shapeType));
            }

            IIndexedSegments indexedSegments = GetIndexedSegments(feature);

            return(includeAssociatedParts
                                       ? (SegmentsPlaneProvider)
                   new FullSegmentsPlaneProvider(indexedSegments, shapeType)
                                       : new PartSegmentsPlaneProvider(indexedSegments, shapeType));
        }
Exemple #22
0
        public static List <IPolygon> GetFaces(
            [NotNull] IIndexedMultiPatch indexedMultiPatch,
            int patchIndex)
        {
            IMultiPatch multiPatch = indexedMultiPatch.BaseGeometry;
            var         patches    = (IGeometryCollection)multiPatch;
            var         ring       = patches.Geometry[patchIndex] as IRing;

            if (ring != null)
            {
                bool beginning = false;
                multiPatch.GetRingType(ring, ref beginning);

                // TODO handle undefined/invalid ring types?
                return(beginning
                                               ? new List <IPolygon> {
                    GetFace(multiPatch, ring)
                }
                                               : new List <IPolygon>());
            }

            List <int> partIndexes = indexedMultiPatch.GetPartIndexes(patchIndex);

            var result = new List <IPolygon>(partIndexes.Count);

            foreach (int partIndex in partIndexes)
            {
                WKSPointZ[] wksPoints = GetWksPointZs(indexedMultiPatch, partIndex);

                IPolygon face = GeometryFactory.CreatePolygon(wksPoints,
                                                              multiPatch
                                                              .SpatialReference);

                result.Add(face);
            }

            return(result);
        }
Exemple #23
0
        public static List <int> GetInnerRingPartIndexes(
            [NotNull] IIndexedMultiPatch indexedMultiPatch,
            int outerRingPartIndex)
        {
            IMultiPatch multiPatch = indexedMultiPatch.BaseGeometry;

            int outerRingIndex = indexedMultiPatch.GetPatchIndex(outerRingPartIndex);

            var geometryCollection = (IGeometryCollection)multiPatch;
            var outerRing          = (IRing)geometryCollection.Geometry[outerRingIndex];

            int followingRingCount = multiPatch.FollowingRingCount[outerRing];

            // following rings must follow the outer ring directly
            var result = new List <int>(followingRingCount);

            for (int index = 0; index < followingRingCount; index++)
            {
                result.Add(index + outerRingPartIndex + 1);
            }

            return(result);
        }
Exemple #24
0
            private void Initialize()
            {
                _indexedMultipatch = GetAdaptedMultiPatch();
                IMultiPatch multiPatch = _indexedMultipatch.BaseGeometry;

                _verticalFaceSegments = new List <SegmentProxy>();

                var patches            = (IGeometryCollection)multiPatch;
                var verticalPatchParts = new Dictionary <int, List <int> >();

                int patchCount = patches.GeometryCount;

                for (int patchIndex = 0; patchIndex < patchCount; patchIndex++)
                {
                    List <int> partIndexes = _indexedMultipatch.GetPartIndexes(patchIndex);

                    foreach (int partIndex in partIndexes)
                    {
                        int partSegmentCount =
                            _indexedMultipatch.GetPartSegmentCount(partIndex);

                        var segments = new List <SegmentProxy>(partSegmentCount);
                        for (int segmentIndex = 0;
                             segmentIndex < partSegmentCount;
                             segmentIndex++)
                        {
                            segments.Add(
                                _indexedMultipatch.GetSegment(partIndex, segmentIndex));
                        }

                        Plane plane =
                            QaGeometryUtils.CreatePlane(
                                (IEnumerable <SegmentProxy>)segments);

                        if (Math.Abs(plane.GetNormalVector().Z) < double.Epsilon)
                        {
                            List <int> verticalParts;
                            if (!verticalPatchParts.TryGetValue(
                                    patchIndex, out verticalParts))
                            {
                                verticalParts = new List <int>();
                                verticalPatchParts.Add(patchIndex, verticalParts);
                            }

                            verticalParts.Add(partIndex);
                            _verticalFaceSegments.AddRange(segments);
                        }
                    }
                }

                if (verticalPatchParts.Count > 0)
                {
                    object      missing = Type.Missing;
                    IMultiPatch nonVerticalMultiPatch =
                        new MultiPatchClass
                    {
                        SpatialReference = multiPatch.SpatialReference
                    };

                    for (int patchIndex = 0; patchIndex < patchCount; patchIndex++)
                    {
                        List <int> verticalParts;
                        IGeometry  patch =
                            ((IGeometryCollection)multiPatch).Geometry[patchIndex];

                        if (!verticalPatchParts.TryGetValue(
                                patchIndex, out verticalParts))
                        {
                            IGeometry clone = GeometryFactory.Clone(patch);
                            ((IGeometryCollection)nonVerticalMultiPatch).AddGeometry(
                                clone,
                                ref missing,
                                ref missing);
                            var ring = patch as IRing;
                            if (ring != null)
                            {
                                bool isBeginning = false;
                                esriMultiPatchRingType ringType =
                                    multiPatch.GetRingType(ring, ref isBeginning);
                                nonVerticalMultiPatch.PutRingType(
                                    (IRing)clone, ringType);
                            }
                        }
                        else
                        {
                            if (patch is IRing)
                            {
                                continue;
                            }

                            List <int> partIndexes =
                                _indexedMultipatch.GetPartIndexes(patchIndex);

                            foreach (int partIndex in partIndexes)
                            {
                                if (verticalParts.Contains(partIndex))
                                {
                                    continue;
                                }

                                int partSegmentCount =
                                    _indexedMultipatch.GetPartSegmentCount(partIndex);

                                var points = new List <WKSPointZ>(3);

                                for (int segmentIndex = 0;
                                     segmentIndex < partSegmentCount;
                                     segmentIndex++)
                                {
                                    SegmentProxy segment =
                                        _indexedMultipatch.GetSegment(
                                            partIndex, segmentIndex);

                                    const bool as3D = true;
                                    Pnt        p    = segment.GetStart(as3D);

                                    points.Add(
                                        WKSPointZUtils.CreatePoint(p.X, p.Y, p[2]));
                                }

                                IRing ring = CreateRing(points);

                                ((IGeometryCollection)nonVerticalMultiPatch).AddGeometry(
                                    ring,
                                    ref missing,
                                    ref missing);
                            }
                        }
                    }

                    _nonVerticalMultipatch = nonVerticalMultiPatch;
                }
                else
                {
                    _nonVerticalMultipatch = multiPatch;
                }
            }