/// <summary> /// Returns all the geometries for the geometry type /// Typically bounding box returns a single object, triangulated mesh mes may return multiple geometry meshes /// where an object is made of multiple materials /// </summary> /// <param name="productLabel"></param> /// <param name="geomType"></param> /// <returns></returns> public IEnumerable <XbimGeometryData> GetGeometryData(int productLabel, XbimGeometryType geomType) { var entity = InstanceCache.GetInstance(productLabel, false, true); if (entity != null) { foreach (var item in InstanceCache.GetGeometry(Metadata.ExpressTypeId(entity), productLabel, geomType)) { yield return(item); } } // RefencedModels must NOT be iterated because of potential entityLabel clashes. // identity needs instead to be tested at the model level of children first, then call this function on the matching child. //else // look in referenced models //{ // foreach (XbimReferencedModel refModel in this.RefencedModels) // { // foreach (var item in refModel.Model.GetGeometryData(productLabel, geomType)) // { // yield return item; // } // } //} }
public void Test_Large_Coordinates_Reduction() { XbimGeometryType tp = Xbim.Common.Geometry.XbimGeometryType.PolyhedronBinary; using (var model = IfcStore.Open("TestFiles\\LargeTriangulatedCoordinates.ifc")) { var xbimTessellator = new XbimTessellator(model, tp); var representation = model.Instances.FirstOrDefault <IIfcFacetedBrep>(); var shape = xbimTessellator.Mesh(representation); // geometry should have a local displacement Assert.IsTrue(shape.LocalShapeDisplacement.HasValue); // it should be more than 6 200 000 var distance = shape.LocalShapeDisplacement.Value.Length; Assert.IsTrue(distance > 6200000); var ms = new MemoryStream(((IXbimShapeGeometryData)shape).ShapeData); var br = new BinaryReader(ms); var geometry = br.ReadShapeTriangulation(); // vertex geometry should be small var vertex = geometry.Vertices.First(); Assert.IsTrue(vertex.X < 1000); Assert.IsTrue(vertex.Y < 1000); Assert.IsTrue(vertex.Z < 1000); // bounding box should be at [0,0,0] position var bb = shape.BoundingBox; var pos = bb.Location; var test = Math.Abs(pos.X + pos.Y + pos.Z); Assert.IsTrue(test < 0.1) ; } }
private XbimGeometryHandleCollection GetGeometryHandlesByIfcType(XbimGeometryType geomType) { var result = new XbimGeometryHandleCollection(); Api.JetSetCurrentIndex(Sesid, Table, GeometryTableGeomTypeIndex); Api.MakeKey(Sesid, Table, (byte)geomType, MakeKeyGrbit.NewKey); if (Api.TrySeek(Sesid, Table, SeekGrbit.SeekGE)) { Api.MakeKey(Sesid, Table, (byte)geomType, MakeKeyGrbit.NewKey | MakeKeyGrbit.FullColumnEndLimit); if (Api.TrySetIndexRange(Sesid, Table, SetIndexRangeGrbit.RangeUpperLimit | SetIndexRangeGrbit.RangeInclusive)) { do { var style = Api.RetrieveColumnAsInt32(Sesid, Table, _colIdStyleLabel, RetrieveColumnGrbit.RetrieveFromIndex); var expressType = Api.RetrieveColumnAsInt16(Sesid, Table, _colIdProductIfcTypeId, RetrieveColumnGrbit.RetrieveFromIndex); var product = Api.RetrieveColumnAsInt32(Sesid, Table, _colIdProductLabel, RetrieveColumnGrbit.RetrieveFromIndex); var geomId = Api.RetrieveColumnAsInt32(Sesid, Table, _colIdGeometryLabel, RetrieveColumnGrbit.RetrieveFromIndex); //srl note casting to UINT, needs to be resolved at database level result.Add(new XbimGeometryHandle(geomId.Value, geomType, product.Value, expressType.Value, style.Value, geomId.Value)); } while (Api.TryMoveNext(Sesid, Table)); } } return(result); }
private XbimGeometryHandleCollection GetGeometryHandlesById(XbimGeometryType geomType) { XbimGeometryHandleCollection result = new XbimGeometryHandleCollection(); Api.JetSetCurrentIndex(sesid, table, geometryTablePrimaryIndex); Api.MakeKey(sesid, table, (byte)geomType, MakeKeyGrbit.NewKey); if (Api.TrySeek(sesid, table, SeekGrbit.SeekGE)) { Api.MakeKey(sesid, table, (byte)geomType, MakeKeyGrbit.NewKey | MakeKeyGrbit.FullColumnEndLimit); if (Api.TrySetIndexRange(sesid, table, SetIndexRangeGrbit.RangeUpperLimit | SetIndexRangeGrbit.RangeInclusive)) { do { int? style = Api.RetrieveColumnAsInt32(sesid, table, _colIdStyleLabel); short?ifcType = Api.RetrieveColumnAsInt16(sesid, table, _colIdProductIfcTypeId); int? product = Api.RetrieveColumnAsInt32(sesid, table, _colIdProductLabel); int? geomId = Api.RetrieveColumnAsInt32(sesid, table, _colIdGeometryLabel); int? hashId = Api.RetrieveColumnAsInt32(sesid, table, _colIdGeometryHash); //srl note casting to UINT, needs to be resolved at database level result.Add(new XbimGeometryHandle(geomId.Value, geomType, product.Value, ifcType.Value, style.Value, hashId.Value)); } while (Api.TryMoveNext(sesid, table)); } } return(result); }
public XbimShapeGeometry CreateShapeGeometry(IXbimGeometryObject geometryObject, double precision, double deflection, double angle, XbimGeometryType storageType, ILogger logger) { using (new Tracer(LogHelper.CurrentFunctionName(), this._logger, geometryObject)) { return(_engine.CreateShapeGeometry(geometryObject, precision, deflection, angle, storageType, logger)); } }
/// <summary> /// A handle to a geometry object /// </summary> /// <param name="geometryLabel">The unique ID of the geometry</param> /// <param name="geometryType">The type of geometric representation</param> /// <param name="productLabel">The label of the Ifc Entity that the geomtry represents</param> /// <param name="ifcTypeId">The id of the Ifc Type of the Product represented</param> /// <param name="surfaceStyleLabel">The label of the Ifc Entity that holds the surface style render</param> /// <param name="geometryHashCode"></param> public XbimGeometryHandle(int geometryLabel, XbimGeometryType geometryType, int productLabel, short ifcTypeId, int surfaceStyleLabel, int? geometryHashCode) { GeometryLabel = geometryLabel; SurfaceStyleLabel = surfaceStyleLabel; ProductLabel = productLabel; IfcTypeId = ifcTypeId; GeometryType = geometryType; GeometryHashCode = geometryHashCode; }
public XbimGeometryHandle(int geometryLabel) { GeometryLabel = geometryLabel; GeometryType = XbimGeometryType.Undefined; SurfaceStyleLabel = 0; ProductLabel = 0; ExpressTypeId = 0; GeometryHashCode = null; }
/// <summary> /// A handle to a geometry object /// </summary> /// <param name="geometryLabel">The unique ID of the geometry</param> /// <param name="geometryType">The type of geometric representation</param> /// <param name="productLabel">The label of the Ifc Entity that the geomtry represents</param> /// <param name="expressTypeId">The id of the Ifc Type of the Product represented</param> /// <param name="surfaceStyleLabel">The label of the Ifc Entity that holds the surface style render</param> /// <param name="geometryHashCode"></param> public XbimGeometryHandle(int geometryLabel, XbimGeometryType geometryType, int productLabel, short expressTypeId, int surfaceStyleLabel, int?geometryHashCode) { GeometryLabel = geometryLabel; SurfaceStyleLabel = surfaceStyleLabel; ProductLabel = productLabel; ExpressTypeId = expressTypeId; GeometryType = geometryType; GeometryHashCode = geometryHashCode; }
public XbimGeometryHandle(int geometryLabel) { GeometryLabel = geometryLabel; GeometryType = XbimGeometryType.Undefined; SurfaceStyleLabel = 0; ProductLabel = 0; IfcTypeId = 0; GeometryHashCode = null; }
public static IEnumerable<XbimGeometryData> GeometryData(this IfcProduct product, XbimGeometryType geomType) { XbimModel model = product.ModelOf as XbimModel; if (model != null) { foreach (var item in model.GetGeometryData(product, geomType)) { yield return item; } } }
/// <summary> /// The constructs an XbimGeoemtryData object, the geometry hash is calculated from the array of shape data /// </summary> /// <param name="geometrylabel"></param> /// <param name="productLabel"></param> /// <param name="geomType"></param> /// <param name="ifcTypeId"></param> /// <param name="shape"></param> /// <param name="transform"></param> /// <param name="styleLabel"></param> public XbimGeometryData(int geometrylabel, int productLabel, XbimGeometryType geomType, short ifcTypeId, byte[] shape, byte[] transform, int styleLabel) { GeometryLabel = geometrylabel; GeometryType = geomType; IfcTypeId = ifcTypeId; ShapeData = shape; DataArray2 = transform; IfcProductLabel = productLabel; GeometryHash = GenerateGeometryHash(ShapeData); StyleLabel = styleLabel; }
public XbimGeometryData(int geometrylabel, int productLabel, XbimGeometryType geomType, short ifcTypeId, byte[] shape, byte[] dataArray2, int geometryHash, int styleLabel, int counter) { GeometryLabel = geometrylabel; GeometryType = geomType; IfcTypeId = ifcTypeId; ShapeData = shape; IfcProductLabel = productLabel; GeometryHash = geometryHash; StyleLabel = styleLabel; DataArray2 = dataArray2; Counter = counter; }
public void Test_Large_Coordinates_Reduction() { XbimGeometryType tp = Xbim.Common.Geometry.XbimGeometryType.PolyhedronBinary; using (var model = IfcStore.Open("LargeTriangulatedCoordinates.ifc")) { var xbimTessellator = new XbimTessellator(model, tp); var shape = model.Instances.FirstOrDefault <IIfcFacetedBrep>(); var shapeGeom = xbimTessellator.Mesh(shape); Assert.IsTrue(shapeGeom.LocalShapeDisplacement.HasValue); } }
public void TestBoundingBoxSize() { XbimGeometryType tp = Xbim.Common.Geometry.XbimGeometryType.PolyhedronBinary; using (var model = IfcStore.Open("Roof-01_BCAD.ifc")) { var xbimTessellator = new XbimTessellator(model, tp); XbimShapeGeometry shapeGeom = null; var shape = model.Instances[1192] as IIfcGeometricRepresentationItem; shapeGeom = xbimTessellator.Mesh(shape); Debug.WriteLine(shapeGeom.BoundingBox); } }
public void TestPnSize_Add2_Support() { XbimGeometryType tp = Xbim.Common.Geometry.XbimGeometryType.PolyhedronBinary; using (var model = IfcStore.Open("TestFiles\\IfcTriangulatedFaceSet.ifc")) { var xbimTessellator = new XbimTessellator(model, tp); XbimShapeGeometry shapeGeom = null; var shape = model.Instances[48] as IIfcGeometricRepresentationItem; shapeGeom = xbimTessellator.Mesh(shape); Debug.WriteLine(shapeGeom.BoundingBox); } }
public void Test_PolygonalFaceSet_Tessellation() { XbimGeometryType tp = Xbim.Common.Geometry.XbimGeometryType.PolyhedronBinary; using (var model = IfcStore.Open("TestFiles\\polygonal-face-tessellation.ifc")) { var xbimTessellator = new XbimTessellator(model, tp); XbimShapeGeometry shapeGeom = null; var shape = model.Instances.FirstOrDefault <IIfcPolygonalFaceSet>(); shapeGeom = xbimTessellator.Mesh(shape); Assert.AreEqual(8000000000000, shapeGeom.BoundingBox.Volume); } }
internal XbimGeometryHandleCollection GetGeometryHandles(XbimGeometryType geomType, XbimGeometrySort sortOrder) { switch (sortOrder) { case XbimGeometrySort.OrderByIfcSurfaceStyleThenIfcType: return(GetGeometryHandlesBySurfaceStyle(geomType)); case XbimGeometrySort.OrderByIfcTypeThenIfcProduct: return(GetGeometryHandlesByIfcType(geomType)); case XbimGeometrySort.OrderByGeometryID: return(GetGeometryHandlesById(geomType)); default: throw new XbimException("Illegal geometry sort order"); } }
/// <summary> /// Returns the records for all geometries of the specified type /// </summary> /// <param name="xbimGeometryType"></param> /// <returns></returns> public IEnumerable <XbimGeometryData> GeometryData(XbimGeometryType xbimGeometryType) { Api.JetSetCurrentIndex(Sesid, Table, GeometryTableGeomTypeIndex); Api.MakeKey(Sesid, Table, (byte)xbimGeometryType, MakeKeyGrbit.NewKey); if (Api.TrySeek(Sesid, Table, SeekGrbit.SeekGE)) { Api.MakeKey(Sesid, Table, (byte)xbimGeometryType, MakeKeyGrbit.NewKey | MakeKeyGrbit.FullColumnEndLimit); if (Api.TrySetIndexRange(Sesid, Table, SetIndexRangeGrbit.RangeUpperLimit | SetIndexRangeGrbit.RangeInclusive)) { do { Api.RetrieveColumns(Sesid, Table, _colValues); Debug.Assert((byte)xbimGeometryType == _colValGeomType.Value); _colValGeometryLabel.Value = Api.RetrieveColumnAsInt32(Sesid, Table, _colIdGeometryLabel); yield return(new XbimGeometryData(_colValGeometryLabel.Value.Value, _colValProductLabel.Value.Value, (XbimGeometryType)_colValGeomType.Value, _colValProductIfcTypeId.Value.Value, _colValShapeData.Value, _colValTransformMatrix.Value, _colValGeometryHash.Value.Value, _colValStyleLabel.Value.HasValue ? _colValStyleLabel.Value.Value : 0, _colValSubPart.Value.HasValue ? _colValSubPart.Value.Value : 0)); } while (Api.TryMoveNext(Sesid, Table)); } } }
private XbimGeometryHandleCollection GetGeometryHandlesBySurfaceStyle(XbimGeometryType geomType) { XbimGeometryHandleCollection result = new XbimGeometryHandleCollection(); Api.JetSetCurrentIndex(sesid, table, geometryTableStyleIndex); Api.MakeKey(sesid, table, (byte)geomType, MakeKeyGrbit.NewKey); if (Api.TrySeek(sesid, table, SeekGrbit.SeekGE)) { Api.MakeKey(sesid, table, (byte)geomType, MakeKeyGrbit.NewKey | MakeKeyGrbit.FullColumnEndLimit); if (Api.TrySetIndexRange(sesid, table, SetIndexRangeGrbit.RangeUpperLimit | SetIndexRangeGrbit.RangeInclusive)) { do { int? style = Api.RetrieveColumnAsInt32(sesid, table, _colIdStyleLabel, RetrieveColumnGrbit.RetrieveFromIndex); short?ifcType = Api.RetrieveColumnAsInt16(sesid, table, _colIdProductIfcTypeId, RetrieveColumnGrbit.RetrieveFromIndex); int? product = Api.RetrieveColumnAsInt32(sesid, table, _colIdProductLabel, RetrieveColumnGrbit.RetrieveFromIndex); int? geomId = Api.RetrieveColumnAsInt32(sesid, table, _colIdGeometryLabel, RetrieveColumnGrbit.RetrieveFromIndex); result.Add(new XbimGeometryHandle(geomId.Value, geomType, product.Value, ifcType.Value, style.Value)); } while (Api.TryMoveNext(sesid, table)); } } return(result); }
/// <summary> /// Returns the records for all geometries of the specified type /// </summary> /// <param name="xbimGeometryType"></param> /// <returns></returns> public IEnumerable<XbimGeometryData> GeometryData(XbimGeometryType xbimGeometryType) { Api.JetSetCurrentIndex(sesid, table, geometryTableGeomTypeIndex); Api.MakeKey(sesid, table, (byte)xbimGeometryType, MakeKeyGrbit.NewKey); if (Api.TrySeek(sesid, table, SeekGrbit.SeekGE)) { Api.MakeKey(sesid, table, (byte)xbimGeometryType, MakeKeyGrbit.NewKey | MakeKeyGrbit.FullColumnEndLimit); if (Api.TrySetIndexRange(sesid, table, SetIndexRangeGrbit.RangeUpperLimit | SetIndexRangeGrbit.RangeInclusive)) { do { Api.RetrieveColumns(sesid, table, _colValues); System.Diagnostics.Debug.Assert((byte)xbimGeometryType == _colValGeomType.Value); _colValGeometryLabel.Value = Api.RetrieveColumnAsInt32(sesid, table, _colIdGeometryLabel); yield return new XbimGeometryData(_colValGeometryLabel.Value.Value, _colValProductLabel.Value.Value, (XbimGeometryType)_colValGeomType.Value, _colValProductIfcTypeId.Value.Value, _colValShapeData.Value, _colValTransformMatrix.Value, _colValGeometryHash.Value.Value, _colValStyleLabel.Value.HasValue ? _colValStyleLabel.Value.Value : 0, _colValSubPart.Value.HasValue ? _colValSubPart.Value.Value : 0); } while (Api.TryMoveNext(sesid, table)); } } }
private XbimGeometryHandleCollection GetGeometryHandlesBySurfaceStyle(XbimGeometryType geomType) { XbimGeometryHandleCollection result = new XbimGeometryHandleCollection(); Api.JetSetCurrentIndex(sesid, table, geometryTableStyleIndex); Api.MakeKey(sesid, table, (byte)geomType, MakeKeyGrbit.NewKey); if (Api.TrySeek(sesid, table, SeekGrbit.SeekGE)) { Api.MakeKey(sesid, table, (byte)geomType, MakeKeyGrbit.NewKey | MakeKeyGrbit.FullColumnEndLimit); if (Api.TrySetIndexRange(sesid, table, SetIndexRangeGrbit.RangeUpperLimit | SetIndexRangeGrbit.RangeInclusive)) { do { int? style = Api.RetrieveColumnAsInt32(sesid, table, _colIdStyleLabel, RetrieveColumnGrbit.RetrieveFromIndex); short? ifcType = Api.RetrieveColumnAsInt16(sesid, table, _colIdProductIfcTypeId, RetrieveColumnGrbit.RetrieveFromIndex); int? product = Api.RetrieveColumnAsInt32(sesid, table, _colIdProductLabel, RetrieveColumnGrbit.RetrieveFromIndex); int? geomId = Api.RetrieveColumnAsInt32(sesid, table, _colIdGeometryLabel, RetrieveColumnGrbit.RetrieveFromIndex); result.Add(new XbimGeometryHandle(geomId.Value, geomType, product.Value, ifcType.Value, style.Value)); } while (Api.TryMoveNext(sesid, table)); } } return result; }
private XbimGeometryHandleCollection GetGeometryHandlesById(XbimGeometryType geomType) { XbimGeometryHandleCollection result = new XbimGeometryHandleCollection(); Api.JetSetCurrentIndex(sesid, table, geometryTablePrimaryIndex); Api.MakeKey(sesid, table, (byte)geomType, MakeKeyGrbit.NewKey); if (Api.TrySeek(sesid, table, SeekGrbit.SeekGE)) { Api.MakeKey(sesid, table, (byte)geomType, MakeKeyGrbit.NewKey | MakeKeyGrbit.FullColumnEndLimit); if (Api.TrySetIndexRange(sesid, table, SetIndexRangeGrbit.RangeUpperLimit | SetIndexRangeGrbit.RangeInclusive)) { do { int? style = Api.RetrieveColumnAsInt32(sesid, table, _colIdStyleLabel); short? ifcType = Api.RetrieveColumnAsInt16(sesid, table, _colIdProductIfcTypeId); int? product = Api.RetrieveColumnAsInt32(sesid, table, _colIdProductLabel); int? geomId = Api.RetrieveColumnAsInt32(sesid, table, _colIdGeometryLabel); int? hashId = Api.RetrieveColumnAsInt32(sesid, table, _colIdGeometryHash); //srl note casting to UINT, needs to be resolved at database level result.Add(new XbimGeometryHandle(geomId.Value, geomType, product.Value, ifcType.Value, style.Value, hashId.Value)); } while (Api.TryMoveNext(sesid, table)); } } return result; }
internal XbimGeometryHandleCollection GetGeometryHandles(XbimGeometryType geomType, XbimGeometrySort sortOrder) { switch (sortOrder) { case XbimGeometrySort.OrderByIfcSurfaceStyleThenIfcType: return GetGeometryHandlesBySurfaceStyle(geomType); case XbimGeometrySort.OrderByIfcTypeThenIfcProduct: return GetGeometryHandlesByIfcType(geomType); case XbimGeometrySort.OrderByGeometryID: return GetGeometryHandlesById(geomType); default: throw new XbimException("Illegal geometry sort order"); } }
public XbimGeometryHandleCollection GetGeometryHandles(XbimGeometryType geomType = XbimGeometryType.TriangulatedMesh, XbimGeometrySort sortOrder = XbimGeometrySort.OrderByIfcSurfaceStyleThenIfcType) { return(InstanceCache.GetGeometryHandles(geomType, sortOrder)); }
/// <summary> /// Adds a geometry record and returns the hash of the geometry data /// </summary> /// <param name="prodLabel"></param> /// <param name="type"></param> /// <param name="expressType"></param> /// <param name="transform"></param> /// <param name="shapeData"></param> /// <param name="subPart"></param> /// <param name="styleLabel"></param> /// <param name="geometryHash"></param> /// <returns></returns> public int AddGeometry(int prodLabel, XbimGeometryType type, short expressType, byte[] transform, byte[] shapeData, short subPart = 0, int styleLabel = 0, int?geometryHash = null) { var mainId = -1; using (var update = new Update(Sesid, Table, JET_prep.Insert)) { _colValProductLabel.Value = prodLabel; _colValGeomType.Value = (Byte)type; _colValProductIfcTypeId.Value = expressType; _colValSubPart.Value = subPart; _colValTransformMatrix.Value = transform; _colValShapeData.Value = shapeData; _colValGeometryHash.Value = geometryHash ?? 0;// geomHash; // if (styleLabel > 0) _colValStyleLabel.Value = styleLabel; // else // _colValStyleLabel.Value = -expressType; //use the negative type id as a style for object that have no render material Api.SetColumns(Sesid, Table, _colValues); try { var columnAsInt32 = Api.RetrieveColumnAsInt32(Sesid, Table, _colIdGeometryLabel, RetrieveColumnGrbit.RetrieveCopy); if ( columnAsInt32 != null) { mainId = columnAsInt32.Value; } update.Save(); UpdateCount(1); } catch (Exception ex) { Debug.WriteLine("Error saving geometry for: " + prodLabel + "Error is " + ex.Message); } } #if CREATEGEOMHASH if (type == XbimGeometryType.TriangulatedMesh && shapeData.Length > 0) { int hashId; Api.JetSetCurrentIndex(sesid, table, geometryTablePrimaryIndex); Api.MakeKey(sesid, table, mainId, MakeKeyGrbit.NewKey); Api.TrySeek(sesid, table, SeekGrbit.SeekEQ); //Create a hash provider var Sha = new SHA1CryptoServiceProvider(); Byte[] hashdata = Sha.ComputeHash(shapeData); using (var update = new Update(sesid, table, JET_prep.InsertCopy)) { Api.SetColumn(sesid, table, _colIdShapeData, hashdata); //change the shapeData variable Api.SetColumn(sesid, table, _colIdGeomType, (Byte)XbimGeometryType.TriangulatedMeshHash); Api.SetColumn(sesid, table, _colIdGeometryHash, mainId); // id of main geom this is a hash of; UpdateCount(1); hashId = Api.RetrieveColumnAsInt32(sesid, table, _colIdGeometryLabel, RetrieveColumnGrbit.RetrieveCopy).Value; update.Save(); } Api.MakeKey(sesid, table, mainId, MakeKeyGrbit.NewKey); if (Api.TrySeek(sesid, table, SeekGrbit.SeekEQ)) //find the main geometry { using (var update = new Update(sesid, table, JET_prep.Replace)) { Api.SetColumn(sesid, table, _colIdGeometryHash, hashId);// id of main geom this is a hash of; update.Save(); } } } #endif return(mainId); }
public XbimGeometryHandle(int geometryLabel, XbimGeometryType geometryType, int productLabel, short ifcTypeId, int surfaceStyleLabel) : this(geometryLabel, geometryType, productLabel, ifcTypeId, surfaceStyleLabel, null) { }
public IXbimShapeGeometryData CreateShapeGeometry(IXbimGeometryObject geometryObject, double precision, double deflection, double angle, XbimGeometryType storageType) { return _engine.CreateShapeGeometry(geometryObject, precision, deflection, angle, storageType); }
public IEnumerable <XbimGeometryData> GetGeometryData(XbimGeometryType ofType) { return(InstanceCache.GetGeometryData(ofType)); }
public IXbimShapeGeometryData CreateShapeGeometry(IXbimGeometryObject geometryObject, double precision, double deflection, double angle, XbimGeometryType storageType) { return(_engine.CreateShapeGeometry(geometryObject, precision, deflection, angle, storageType)); }
public XbimTessellator(IModel model, XbimGeometryType geometryType, bool reduceLargeCoordinates = true) { _model = model; _geometryType = geometryType; _reduceLargeCoordinates = reduceLargeCoordinates; }
public static IEnumerable <XbimGeometryData> GeometryData(this IfcProduct product, XbimGeometryType geomType) { XbimModel model = product.ModelOf as XbimModel; if (model != null) { foreach (var item in model.GetGeometryData(product, geomType)) { yield return(item); } } }
public IEnumerable <XbimGeometryData> GetGeometryData(IfcProduct product, XbimGeometryType geomType) { return(InstanceCache.GetGeometry(Metadata.ExpressTypeId(product), product.EntityLabel, geomType)); }
internal IEnumerable<XbimGeometryData> GeometryData(short typeId, int productLabel, XbimGeometryType geomType) { Api.JetSetCurrentIndex(sesid, table, geometryTableGeomTypeIndex); Api.MakeKey(sesid, table, (byte)geomType, MakeKeyGrbit.NewKey); Api.MakeKey(sesid, table, typeId, MakeKeyGrbit.None); Api.MakeKey(sesid, table, productLabel, MakeKeyGrbit.None); if (Api.TrySeek(sesid, table, SeekGrbit.SeekGE)) { Api.MakeKey(sesid, table, (byte)geomType, MakeKeyGrbit.NewKey); Api.MakeKey(sesid, table, typeId, MakeKeyGrbit.None); Api.MakeKey(sesid, table, productLabel, MakeKeyGrbit.FullColumnEndLimit); if (Api.TrySetIndexRange(sesid, table, SetIndexRangeGrbit.RangeUpperLimit | SetIndexRangeGrbit.RangeInclusive)) { do { Api.RetrieveColumns(sesid, table, _colValues); // System.Diagnostics.Debug.Assert((byte)geomType == _colValGeomType.Value); _colValGeometryLabel.Value = Api.RetrieveColumnAsInt32(sesid, table, _colIdGeometryLabel); //SRL note this method needs to be modified to support UINT rather than int, the casting below should be removed yield return new XbimGeometryData(_colValGeometryLabel.Value.Value, productLabel, (XbimGeometryType)_colValGeomType.Value, _colValProductIfcTypeId.Value.Value, _colValShapeData.Value, _colValTransformMatrix.Value, _colValGeometryHash.Value.Value, _colValStyleLabel.Value.HasValue ? _colValStyleLabel.Value.Value : 0, _colValSubPart.Value.HasValue ? _colValSubPart.Value.Value : 0); } while (Api.TryMoveNext(sesid, table)); } } }
public XbimGeometryHandle(int geometryLabel, XbimGeometryType geometryType, int productLabel, short expressTypeId, int surfaceStyleLabel) : this(geometryLabel, geometryType, productLabel, expressTypeId, surfaceStyleLabel, null) { }
internal IEnumerable <XbimGeometryData> GeometryData(short typeId, int productLabel, XbimGeometryType geomType) { Api.JetSetCurrentIndex(Sesid, Table, GeometryTableGeomTypeIndex); Api.MakeKey(Sesid, Table, (byte)geomType, MakeKeyGrbit.NewKey); Api.MakeKey(Sesid, Table, typeId, MakeKeyGrbit.None); Api.MakeKey(Sesid, Table, productLabel, MakeKeyGrbit.None); if (Api.TrySeek(Sesid, Table, SeekGrbit.SeekGE)) { Api.MakeKey(Sesid, Table, (byte)geomType, MakeKeyGrbit.NewKey); Api.MakeKey(Sesid, Table, typeId, MakeKeyGrbit.None); Api.MakeKey(Sesid, Table, productLabel, MakeKeyGrbit.FullColumnEndLimit); if (Api.TrySetIndexRange(Sesid, Table, SetIndexRangeGrbit.RangeUpperLimit | SetIndexRangeGrbit.RangeInclusive)) { do { Api.RetrieveColumns(Sesid, Table, _colValues); // System.Diagnostics.Debug.Assert((byte)geomType == _colValGeomType.Value); _colValGeometryLabel.Value = Api.RetrieveColumnAsInt32(Sesid, Table, _colIdGeometryLabel); //SRL note this method needs to be modified to support UINT rather than int, the casting below should be removed yield return(new XbimGeometryData(_colValGeometryLabel.Value.Value, productLabel, (XbimGeometryType)_colValGeomType.Value, _colValProductIfcTypeId.Value.Value, _colValShapeData.Value, _colValTransformMatrix.Value, _colValGeometryHash.Value.Value, _colValStyleLabel.Value.HasValue ? _colValStyleLabel.Value.Value : 0, _colValSubPart.Value.HasValue ? _colValSubPart.Value.Value : 0)); } while (Api.TryMoveNext(Sesid, Table)); } } }
/// <summary> /// Adds a geometry record and returns the hash of the geometry data /// </summary> /// <param name="prodLabel"></param> /// <param name="type"></param> /// <param name="ifcType"></param> /// <param name="transform"></param> /// <param name="shapeData"></param> /// <param name="subPart"></param> /// <param name="styleLabel"></param> /// <param name="geometryHash"></param> /// <returns></returns> public int AddGeometry(int prodLabel, XbimGeometryType type, short ifcType, byte[] transform, byte[] shapeData, short subPart = 0, int styleLabel = 0, int? geometryHash = null) { int mainId = -1; using (var update = new Update(sesid, table, JET_prep.Insert)) { _colValProductLabel.Value = prodLabel; _colValGeomType.Value = (Byte)type; _colValProductIfcTypeId.Value = ifcType; _colValSubPart.Value = subPart; _colValTransformMatrix.Value = transform; _colValShapeData.Value = shapeData; _colValGeometryHash.Value = geometryHash.HasValue ? geometryHash.Value : 0;// geomHash; // if (styleLabel > 0) _colValStyleLabel.Value = styleLabel; // else // _colValStyleLabel.Value = -ifcType; //use the negative type id as a style for object that have no render material Api.SetColumns(sesid, table, _colValues); try { mainId = Api.RetrieveColumnAsInt32(sesid, table, _colIdGeometryLabel, RetrieveColumnGrbit.RetrieveCopy).Value; update.Save(); UpdateCount(1); } catch (Exception ex) { Debug.WriteLine("Error saving geometry for: " + prodLabel + "Error is " + ex.Message); } } #if CREATEGEOMHASH if (type == XbimGeometryType.TriangulatedMesh && shapeData.Length > 0) { int hashId; Api.JetSetCurrentIndex(sesid, table, geometryTablePrimaryIndex); Api.MakeKey(sesid, table, mainId, MakeKeyGrbit.NewKey); Api.TrySeek(sesid, table, SeekGrbit.SeekEQ); //Create a hash provider var Sha = new SHA1CryptoServiceProvider(); Byte[] hashdata = Sha.ComputeHash(shapeData); using (var update = new Update(sesid, table, JET_prep.InsertCopy)) { Api.SetColumn(sesid, table, _colIdShapeData, hashdata); //change the shapeData variable Api.SetColumn(sesid, table, _colIdGeomType, (Byte)XbimGeometryType.TriangulatedMeshHash); Api.SetColumn(sesid, table, _colIdGeometryHash, mainId);// id of main geom this is a hash of; UpdateCount(1); hashId = Api.RetrieveColumnAsInt32(sesid, table, _colIdGeometryLabel, RetrieveColumnGrbit.RetrieveCopy).Value; update.Save(); } Api.MakeKey(sesid, table, mainId, MakeKeyGrbit.NewKey); if (Api.TrySeek(sesid, table, SeekGrbit.SeekEQ)) //find the main geometry { using (var update = new Update(sesid, table, JET_prep.Replace)) { Api.SetColumn(sesid, table, _colIdGeometryHash, hashId);// id of main geom this is a hash of; update.Save(); } } } #endif return mainId; }
public static IEnumerable <XbimGeometryData> GeometryData(this IfcProduct product, XbimGeometryType geomType) { var model = product.Model as EsentModel; if (model != null) { foreach (var item in model.GetGeometryData(product.EntityLabel, geomType)) { yield return(item); } } }
public XbimTessellator(IModel model, XbimGeometryType geometryType) { _model = model; _geometryType = geometryType; }
public XbimTessellator(XbimModel model, XbimGeometryType geometryType) { _model = model; _geometryType = geometryType; }