private static void SetVisibilitySessionRaster3DProperties(IRasterLayer rasterLayer, IObjectFactory objFactory, IFunctionalSurface surface, bool isDrapperyLayer = false) { var properties3D = (I3DProperties3)objFactory.Create("esrianalyst3d.Raster3DProperties"); properties3D.BaseOption = esriBaseOption.esriBaseSurface; properties3D.BaseSurface = surface; if (!isDrapperyLayer) { properties3D.OffsetExpressionString = "2"; properties3D.DepthPriorityValue = 1; } else { properties3D.DepthPriorityValue = 9; } properties3D.ZFactor = _zFactor; properties3D.RenderVisibility = esriRenderVisibility.esriRenderAlways; properties3D.RenderMode = esriRenderMode.esriRenderCache; properties3D.TextureDownsamplingFactor = 0.7; properties3D.AlphaThreshold = 0.1; properties3D.RenderRefreshRate = 0.75; properties3D.Illuminate = true; ILayerExtensions layerExtensions = (ILayerExtensions)rasterLayer; layerExtensions.AddExtension(properties3D); properties3D.Apply3DProperties(rasterLayer); }
private static void AddDraperyLayer(string draperyLayerName, IObjectFactory objFactory, IFunctionalSurface baseSurface, IBasicDocument document) { var rasterLayer = CreateRasterLayer(objFactory, draperyLayerName); if (rasterLayer != null) { SetVisibilitySessionRaster3DProperties(rasterLayer, objFactory, baseSurface, true); } document.AddLayer(rasterLayer); }
private static void SetFeatures3DProperties(IFeatureLayer layer, IObjectFactory objFactory, IFunctionalSurface surface, double height = double.NaN) { var properties3D = (I3DProperties)objFactory.Create("esrianalyst3d.Feature3DProperties"); properties3D.BaseOption = esriBaseOption.esriBaseSurface; properties3D.BaseSurface = surface; properties3D.ZFactor = _zFactor; properties3D.OffsetExpressionString = (height == double.NaN) ? "3" : height.ToString(); ILayerExtensions layerExtensions = (ILayerExtensions)layer; layerExtensions.AddExtension(properties3D); properties3D.Apply3DProperties(layer); }
public static IGeometry GetExample14() { const int PointCount = 100; const double ZMin = 0; const double ZMax = 4; //Extrusion: Square Shaped Base Geometry Extruded Between Single TIN-Based Functional Surface IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass(); //Base Geometry IEnvelope envelope = new EnvelopeClass(); envelope.XMin = -10; envelope.XMax = 10; envelope.YMin = -10; envelope.YMax = 10; IGeometry baseGeometry = envelope as IGeometry; //Upper Functional Surface ITinEdit tinEdit = new TinClass(); tinEdit.InitNew(envelope); Random random = new Random(); for (int i = 0; i < PointCount; i++) { double x = envelope.XMin + (envelope.XMax - envelope.XMin) * random.NextDouble(); double y = envelope.YMin + (envelope.YMax - envelope.YMin) * random.NextDouble(); double z = ZMin + (ZMax - ZMin) * random.NextDouble(); IPoint point = GeometryUtilities.ConstructPoint3D(x, y, z); tinEdit.AddPointZ(point, 0); } IFunctionalSurface functionalSurface = tinEdit as IFunctionalSurface; IConstructMultiPatch constructMultiPatch = new MultiPatchClass(); constructMultiPatch.ConstructExtrudeBetween(functionalSurface, functionalSurface, baseGeometry); return(constructMultiPatch as IGeometry); }
private static void AddVisibilityLayers(IEnumerable <VisibilityResultInfo> info, IObjectFactory objFactory, IBasicDocument document, IFunctionalSurface baseSurface) { Dictionary <ILayer, LayerTypeEnum> layers = new Dictionary <ILayer, LayerTypeEnum>(); foreach (var resultInfo in info) { var layer = GetVisibilityLayer(resultInfo, objFactory, baseSurface); if (layer.Key != null) { layers.Add(layer.Key, layer.Value); try { document.AddLayer(layer.Key); } catch (Exception ex) { logger.ErrorEx(ex.Message); } } } _viewCalcLayers.AddRange(layers.Keys); if (layers.ContainsValue(LayerTypeEnum.PointFeature)) { document.UpdateContents(); foreach (var layer in layers) { if (layer.Value == LayerTypeEnum.PointFeature && _layersWithDefaultRenderer.Contains(layer.Key.Name)) { document.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, PointsRender((IFeatureLayer)layer.Key, new RgbColor() { Red = 24, Blue = 255, Green = 163 }, objFactory), document.ActiveView.Extent); } } } }
private static void AddExtraLayers(Dictionary <ILayer, double> additionalLayers, IObjectFactory objFactory, IBasicDocument document, IFunctionalSurface surface) { foreach (var extraLayer in additionalLayers) { var featureLayer = CreateLayerCopy((IFeatureLayer)extraLayer.Key, objFactory); SetFeatures3DProperties(featureLayer, objFactory, surface, extraLayer.Value); try { document.AddLayer(featureLayer); } catch (Exception ex) { logger.ErrorEx(ex.Message); } } document.UpdateContents(); }
private static void SetSurface3DProperties(ILayer layer, IObjectFactory objFactory, IFunctionalSurface surface) { var properties3D = (I3DProperties)objFactory.Create("esrianalyst3d.Raster3DProperties"); properties3D.BaseOption = esriBaseOption.esriBaseSurface; properties3D.BaseSurface = surface; properties3D.ZFactor = 7; ILayerExtensions layerExtensions = (ILayerExtensions)layer; layerExtensions.AddExtension(properties3D); properties3D.Apply3DProperties(layer); }
private static void SetLine3DProperties(IFeatureLayer layer, IObjectFactory objFactory, IFunctionalSurface surface) { var properties3D = (I3DProperties)objFactory.Create("esrianalyst3d.Feature3DProperties"); properties3D.BaseOption = esriBaseOption.esriBaseSurface; properties3D.BaseSurface = surface; properties3D.ZFactor = 7; properties3D.OffsetExpressionString = "200"; ILayerExtensions layerExtensions = (ILayerExtensions)layer; layerExtensions.AddExtension(properties3D); properties3D.Apply3DProperties(layer); }
private static KeyValuePair <ILayer, LayerTypeEnum> GetVisibilityLayer(VisibilityResultInfo info, IObjectFactory objFactory, IFunctionalSurface baseSurface) { KeyValuePair <ILayer, LayerTypeEnum> layerKeyValuePair = new KeyValuePair <ILayer, LayerTypeEnum>(); Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory"); string typeFactoryID = factoryType.GUID.ToString("B"); IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)objFactory.Create(typeFactoryID); IWorkspace2 workspace = (IWorkspace2)workspaceFactory.OpenFromFile(info.GdbPath, 0); var rastersTypes = VisibilityCalcResults.GetRasterResults(); if (rastersTypes.Any(type => type == info.RessutType)) { var rasterLayer = CreateRasterLayer(info.ResultName, workspace, objFactory, info.GdbPath); if (rasterLayer != null) { SetVisibilitySessionRaster3DProperties(rasterLayer, objFactory, baseSurface); layerKeyValuePair = new KeyValuePair <ILayer, LayerTypeEnum>(rasterLayer, LayerTypeEnum.Raster); } } if (info.RessutType == VisibilityCalculationResultsEnum.ObservationPoints || info.RessutType == VisibilityCalculationResultsEnum.ObservationPointSingle) { var pointFeatureLayer = CreateFeatureLayer(info.ResultName, workspace, objFactory); if (pointFeatureLayer != null) { SetFeatures3DProperties(pointFeatureLayer, objFactory, baseSurface); layerKeyValuePair = new KeyValuePair <ILayer, LayerTypeEnum>(pointFeatureLayer, LayerTypeEnum.PointFeature); } } if (info.RessutType == VisibilityCalculationResultsEnum.VisibilityAreaPolygons || info.RessutType == VisibilityCalculationResultsEnum.ObservationObjects) { var polygonFeatureLayer = CreateFeatureLayer(info.ResultName, workspace, objFactory); if (polygonFeatureLayer != null) { SetFeatures3DProperties(polygonFeatureLayer, objFactory, baseSurface); layerKeyValuePair = new KeyValuePair <ILayer, LayerTypeEnum>(polygonFeatureLayer, LayerTypeEnum.PolygonFeature); } } Marshal.ReleaseComObject(workspaceFactory); return(layerKeyValuePair); }
public static IGeometry GetExample15() { const double CircleDegrees = 360.0; const int CircleDivisions = 36; const double VectorComponentOffset = 0.0000001; const double CircleRadius = 9.5; const int PointCount = 100; const double UpperZMin = 7; const double UpperZMax = 10; const double LowerZMin = 0; const double LowerZMax = 3; //Extrusion: Circle Shaped Base Geometry Extruded Between Two Different TIN-Based Functional Surfaces IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass(); //Base Geometry IPointCollection polygonPointCollection = new PolygonClass(); IPoint originPoint = GeometryUtilities.ConstructPoint3D(0, 0, 0); IVector3D upperAxisVector3D = GeometryUtilities.ConstructVector3D(0, 0, 10); IVector3D lowerAxisVector3D = GeometryUtilities.ConstructVector3D(0, 0, -10); lowerAxisVector3D.XComponent += VectorComponentOffset; IVector3D normalVector3D = upperAxisVector3D.CrossProduct(lowerAxisVector3D) as IVector3D; normalVector3D.Magnitude = CircleRadius; double rotationAngleInRadians = GeometryUtilities.GetRadians(CircleDegrees / CircleDivisions); for (int i = 0; i < CircleDivisions; i++) { normalVector3D.Rotate(-1 * rotationAngleInRadians, upperAxisVector3D); IPoint vertexPoint = GeometryUtilities.ConstructPoint2D(originPoint.X + normalVector3D.XComponent, originPoint.Y + normalVector3D.YComponent); polygonPointCollection.AddPoint(vertexPoint, ref _missing, ref _missing); } IPolygon polygon = polygonPointCollection as IPolygon; polygon.Close(); IGeometry baseGeometry = polygon as IGeometry; ITopologicalOperator topologicalOperator = polygon as ITopologicalOperator; topologicalOperator.Simplify(); //Functional Surfaces IEnvelope envelope = new EnvelopeClass(); envelope.XMin = -10; envelope.XMax = 10; envelope.YMin = -10; envelope.YMax = 10; Random random = new Random(); //Upper Functional Surface ITinEdit upperTinEdit = new TinClass(); upperTinEdit.InitNew(envelope); for (int i = 0; i < PointCount; i++) { double x = envelope.XMin + (envelope.XMax - envelope.XMin) * random.NextDouble(); double y = envelope.YMin + (envelope.YMax - envelope.YMin) * random.NextDouble(); double z = UpperZMin + (UpperZMax - UpperZMin) * random.NextDouble(); IPoint point = GeometryUtilities.ConstructPoint3D(x, y, z); upperTinEdit.AddPointZ(point, 0); } IFunctionalSurface upperFunctionalSurface = upperTinEdit as IFunctionalSurface; //Lower Functional Surface ITinEdit lowerTinEdit = new TinClass(); lowerTinEdit.InitNew(envelope); for (int i = 0; i < PointCount; i++) { double x = envelope.XMin + (envelope.XMax - envelope.XMin) * random.NextDouble(); double y = envelope.YMin + (envelope.YMax - envelope.YMin) * random.NextDouble(); double z = LowerZMin + (LowerZMax - LowerZMin) * random.NextDouble(); IPoint point = GeometryUtilities.ConstructPoint3D(x, y, z); lowerTinEdit.AddPointZ(point, 0); } IFunctionalSurface lowerFunctionalSurface = lowerTinEdit as IFunctionalSurface; IConstructMultiPatch constructMultiPatch = new MultiPatchClass(); constructMultiPatch.ConstructExtrudeBetween(upperFunctionalSurface, lowerFunctionalSurface, baseGeometry); return(constructMultiPatch as IGeometry); }