コード例 #1
0
            protected override bool GetNextSliverArea(out double area, out double perimeter)
            {
                _latestPartSegments = null;
                if (!_enumValid)
                {
                    area      = double.NaN;
                    perimeter = double.NaN;
                    return(false);
                }

                SegmentProxy segment = Assert.NotNull(_segmentsEnum.Current);

                int currentPart  = segment.PartIndex;
                int segmentCount = _indexedMultiPatch.GetPartSegmentCount(currentPart);
                var partSegments = new List <SegmentProxy>(segmentCount)
                {
                    segment
                };

                while ((_enumValid = _segmentsEnum.MoveNext()) &&
                       Assert.NotNull(_segmentsEnum.Current).PartIndex == currentPart)
                {
                    partSegments.Add(_segmentsEnum.Current);
                }

                List <Pnt> planePoints = QaGeometryUtils.GetPoints(partSegments);
                Plane      plane       = QaGeometryUtils.CreatePlane((IEnumerable <SegmentProxy>)partSegments);

                QaGeometryUtils.CalculateProjectedArea(plane, planePoints, out area, out perimeter);

                _latestPartSegments = partSegments;

                return(true);
            }
コード例 #2
0
            public override SegmentsPlane ReadPlane()
            {
                if (!_enumValid)
                {
                    return(null);
                }

                int currentPart = Assert.NotNull(_segmentsEnum.Current).PartIndex;
                int patchIndex  = _indexedMultiPatch.GetPatchIndex(currentPart);

                int endPart = currentPart;

                var geometryCollection =
                    (IGeometryCollection)_indexedMultiPatch.BaseGeometry;
                var maybeOuterRing = geometryCollection.Geometry[patchIndex] as IRing;

                if (maybeOuterRing != null)
                {
                    var  multiPatch  = (IMultiPatch)geometryCollection;
                    bool isBeginning = false;
                    multiPatch.GetRingType(maybeOuterRing, ref isBeginning);
                    if (isBeginning)
                    {
                        int followingRingCount =
                            multiPatch.FollowingRingCount[maybeOuterRing];
                        endPart += followingRingCount;
                    }
                }

                int segmentCount    = _indexedMultiPatch.GetPartSegmentCount(currentPart);
                var surfaceSegments = new List <SegmentProxy>(segmentCount)
                {
                    _segmentsEnum.Current
                };

                while ((_enumValid = _segmentsEnum.MoveNext()) &&
                       Assert.NotNull(_segmentsEnum.Current).PartIndex <= endPart)
                {
                    surfaceSegments.Add(_segmentsEnum.Current);
                }

                return(new SegmentsPlane(surfaceSegments,
                                         esriGeometryType.esriGeometryMultiPatch));
            }
コード例 #3
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;
                }
            }