/// <summary> /// 创建并加载点云 /// </summary> /// <returns></returns> IRenderModelPoint CreatePointCloud() { //准备容器 IModel model = new ResourceFactory().CreateModel(); IDrawGroup drawGroup = new DrawGroup(); IDrawPrimitive drawPrimitive = new DrawPrimitive(); IFloatArray verList = new FloatArray(); //点集 IUInt32Array colorList = new UInt32Array(); //点色 //点坐标 float x = 3.3f, y = 4.4f, z = 5.5f; //点色 byte a = 128, r = 255, g = 255, b = 255; uint col = (uint)(b | g << 8 | r << 16 | a << 24); //argb => uint for (int i = 0; i < 10; i++) { verList.Append(x); verList.Append(y); verList.Append(z); colorList.Append(col); } //塞入容器 drawPrimitive.VertexArray = verList; drawPrimitive.ColorArray = colorList; drawPrimitive.Material.EnableBlend = false; //关闭融合 drawPrimitive.Material.EnableLight = false; //关闭光照 drawPrimitive.PrimitiveMode = gviPrimitiveMode.gviPrimitiveModeLineList; //设置绘制模式为点 drawGroup.AddPrimitive(drawPrimitive); //塞入渲染组 model.AddGroup(drawGroup); //塞入model axRenderControl.ObjectManager.AddModel("modelName", model); //塞入三维对象,与modelPoint通过名称匹配 //创建modelPoint,用于索引模型 IModelPoint mp = (IModelPoint) new GeometryFactory().CreateGeometry(gviGeometryType.gviGeometryModelPoint, gviVertexAttribute.gviVertexAttributeZ); mp.SpatialCRS = (SpatialCRS)CRSFactory.CreateFromWKT("wkt"); //设置坐标系 mp.ModelEnvelope = model.Envelope; // 排除不显示BUG mp.SetCoords(3.3, 4.4, 5.5, 0, 0); mp.ModelName = "modelName"; //匹配模型 return(axRenderControl.ObjectManager.CreateRenderModelPoint(mp, null, Guid.Empty)); //创建完成 }
private IModel CreateModel(float lenght, float width, float height, uint color) { IModel model = new ResourceFactory().CreateModel(); IDrawGroup group = new DrawGroup(); IDrawPrimitive primitive = new DrawPrimitive(); IFloatArray vertexArray = new FloatArray(); IFloatArray textureArray = new FloatArray(); IUInt32Array colorArray = new UInt32Array(); #region //顶点数组3个为一组(三角面1) vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(0.0f); //顶点数组3个为一组(三角面2) vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(0.0f); //顶点数组3个为一组(三角面3) vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); //顶点数组3个为一组(三角面4) vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); //顶点数组3个为一组(三角面5) vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(lenght); //顶点数组3个为一组(三角面6) vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(lenght); //顶点数组3个为一组(三角面7) vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(0.0f); //顶点数组3个为一组(三角面8) vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(lenght); //顶点数组3个为一组(三角面9) vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(lenght); //顶点数组3个为一组(三角面10) vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(lenght); //顶点数组3个为一组(三角面11) vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); //顶点数组3个为一组(三角面12) vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(lenght); #endregion #region //颜色数组1个为一组 colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); #endregion #region //纹理数组2个为一组 textureArray.Append(0.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); #endregion primitive.ColorArray = colorArray; primitive.TexcoordArray = textureArray; primitive.VertexArray = vertexArray; IDrawMaterial material = new DrawMaterial(); material.EnableLight = true; primitive.Material = material; group.AddPrimitive(primitive); //光照效果,跟法向有关 group.ComputeNormal(); model.AddGroup(group); return(model); }
public void Visit(UInt32Array array) => CompareArrays(array);
public void Visit(UInt32Array array) => CreateBuffers(array);
public static Func <int, T> GetGetter <T>(IArrowArray array) { if (array is null) { return(null); } // TODO: determine fastest way to read out a value from the array. if (typeof(T) == typeof(bool)) { var booleanArray = new BooleanArray(array.Data); return((Func <int, T>)(object) new Func <int, bool>( index => booleanArray.GetBoolean(index).GetValueOrDefault())); } if (typeof(T) == typeof(bool?)) { var booleanArray = new BooleanArray(array.Data); return((Func <int, T>)(object) new Func <int, bool?>(booleanArray.GetBoolean)); } if (typeof(T) == typeof(sbyte)) { var int8Array = new Int8Array(array.Data); return((Func <int, T>)(object) new Func <int, sbyte>( index => int8Array.GetValue(index).GetValueOrDefault())); } if (typeof(T) == typeof(sbyte?)) { var int8Array = new Int8Array(array.Data); return((Func <int, T>)(object) new Func <int, sbyte?>(int8Array.GetValue)); } if (typeof(T) == typeof(byte)) { var uint8Array = new UInt8Array(array.Data); return((Func <int, T>)(object) new Func <int, byte>( index => uint8Array.GetValue(index).GetValueOrDefault())); } if (typeof(T) == typeof(byte?)) { var uint8Array = new UInt8Array(array.Data); return((Func <int, T>)(object) new Func <int, byte?>(uint8Array.GetValue)); } if (typeof(T) == typeof(short)) { var int16Array = new Int16Array(array.Data); return((Func <int, T>)(object) new Func <int, short>( index => int16Array.GetValue(index).GetValueOrDefault())); } if (typeof(T) == typeof(short?)) { var int16Array = new Int16Array(array.Data); return((Func <int, T>)(object) new Func <int, short?>(int16Array.GetValue)); } if (typeof(T) == typeof(ushort)) { var uint16Array = new UInt16Array(array.Data); return((Func <int, T>)(object) new Func <int, ushort>( index => uint16Array.GetValue(index).GetValueOrDefault())); } if (typeof(T) == typeof(ushort?)) { var uint16Array = new UInt16Array(array.Data); return((Func <int, T>)(object) new Func <int, ushort?>(uint16Array.GetValue)); } if (typeof(T) == typeof(int)) { var int32Array = new Int32Array(array.Data); return((Func <int, T>)(object) new Func <int, int>( index => int32Array.GetValue(index).GetValueOrDefault())); } if (typeof(T) == typeof(int?)) { var int32Array = new Int32Array(array.Data); return((Func <int, T>)(object) new Func <int, int?>(int32Array.GetValue)); } if (typeof(T) == typeof(uint)) { var uint32Array = new UInt32Array(array.Data); return((Func <int, T>)(object) new Func <int, uint>( index => uint32Array.GetValue(index).GetValueOrDefault())); } if (typeof(T) == typeof(uint?)) { var uint32Array = new UInt32Array(array.Data); return((Func <int, T>)(object) new Func <int, uint?>(uint32Array.GetValue)); } if (typeof(T) == typeof(long)) { var int64Array = new Int64Array(array.Data); return((Func <int, T>)(object) new Func <int, long>( index => int64Array.GetValue(index).GetValueOrDefault())); } if (typeof(T) == typeof(long?)) { var int64Array = new Int64Array(array.Data); return((Func <int, T>)(object) new Func <int, long?>(int64Array.GetValue)); } if (typeof(T) == typeof(ulong)) { var uint64Array = new UInt64Array(array.Data); return((Func <int, T>)(object) new Func <int, ulong>( index => uint64Array.GetValue(index).GetValueOrDefault())); } if (typeof(T) == typeof(ulong?)) { var uint64Array = new UInt64Array(array.Data); return((Func <int, T>)(object) new Func <int, ulong?>(uint64Array.GetValue)); } if (typeof(T) == typeof(double)) { var doubleArray = new DoubleArray(array.Data); return((Func <int, T>)(object) new Func <int, double>( index => doubleArray.GetValue(index).GetValueOrDefault())); } if (typeof(T) == typeof(double?)) { var doubleArray = new DoubleArray(array.Data); return((Func <int, T>)(object) new Func <int, double?>(doubleArray.GetValue)); } if (typeof(T) == typeof(float)) { var floatArray = new FloatArray(array.Data); return((Func <int, T>)(object) new Func <int, float>( index => floatArray.GetValue(index).GetValueOrDefault())); } if (typeof(T) == typeof(float?)) { var floatArray = new FloatArray(array.Data); return((Func <int, T>)(object) new Func <int, float?>(floatArray.GetValue)); } if (typeof(T) == typeof(DateTime)) { if (array.Data.DataType.TypeId == ArrowTypeId.Date32) { var date32Array = new Date32Array(array.Data); return((Func <int, T>)(object) new Func <int, DateTime>( index => date32Array.GetDate(index).GetValueOrDefault().DateTime)); } else if (array.Data.DataType.TypeId == ArrowTypeId.Date64) { var date64Array = new Date64Array(array.Data); return((Func <int, T>)(object) new Func <int, DateTime>( index => date64Array.GetDate(index).GetValueOrDefault().DateTime)); } } if (typeof(T) == typeof(DateTime?)) { if (array.Data.DataType.TypeId == ArrowTypeId.Date32) { var date32Array = new Date32Array(array.Data); return((Func <int, T>)(object) new Func <int, DateTime?>( index => date32Array.GetDate(index)?.DateTime)); } else if (array.Data.DataType.TypeId == ArrowTypeId.Date64) { var date64Array = new Date64Array(array.Data); return((Func <int, T>)(object) new Func <int, DateTime?>( index => date64Array.GetDate(index)?.DateTime)); } } if (typeof(T) == typeof(DateTimeOffset)) { if (array.Data.DataType.TypeId == ArrowTypeId.Date32) { var date32Array = new Date32Array(array.Data); return((Func <int, T>)(object) new Func <int, DateTimeOffset>( index => date32Array.GetDate(index).GetValueOrDefault())); } else if (array.Data.DataType.TypeId == ArrowTypeId.Date64) { var date64Array = new Date64Array(array.Data); return((Func <int, T>)(object) new Func <int, DateTimeOffset>( index => date64Array.GetDate(index).GetValueOrDefault())); } } if (typeof(T) == typeof(DateTimeOffset?)) { if (array.Data.DataType.TypeId == ArrowTypeId.Date32) { var date32Array = new Date32Array(array.Data); return((Func <int, T>)(object) new Func <int, DateTimeOffset?>( date32Array.GetDate)); } else if (array.Data.DataType.TypeId == ArrowTypeId.Date64) { var date64Array = new Date64Array(array.Data); return((Func <int, T>)(object) new Func <int, DateTimeOffset?>( date64Array.GetDate)); } } if (typeof(T) == typeof(TimeSpan)) { var timestampArray = new TimestampArray(array.Data); return((Func <int, T>)(object) new Func <int, TimeSpan>( index => timestampArray.GetTimestamp(index).GetValueOrDefault().TimeOfDay)); } if (typeof(T) == typeof(TimeSpan?)) { var timestampArray = new TimestampArray(array.Data); return((Func <int, T>)(object) new Func <int, TimeSpan?>( index => timestampArray.GetTimestamp(index)?.TimeOfDay)); } if (typeof(T) == typeof(byte[])) { var binaryArray = new BinaryArray(array.Data); return((Func <int, T>)(object) new Func <int, byte[]>( // TODO: how to avoid this allocation/copy? index => binaryArray.GetBytes(index).ToArray())); } if (typeof(T) == typeof(string)) { var stringArray = new StringArray(array.Data); return((Func <int, T>)(object) new Func <int, string>( index => stringArray.GetString(index))); } // It's something else we don't yet support. switch (array.Data.DataType.TypeId) { case ArrowTypeId.Decimal: case ArrowTypeId.Dictionary: case ArrowTypeId.FixedSizedBinary: case ArrowTypeId.HalfFloat: case ArrowTypeId.Interval: case ArrowTypeId.List: case ArrowTypeId.Map: case ArrowTypeId.Null: case ArrowTypeId.Struct: case ArrowTypeId.Time32: case ArrowTypeId.Time64: case ArrowTypeId.Union: default: // TODO: support additional types? throw new NotSupportedException( $"Not supported array type: {array.Data.DataType.TypeId}"); } }