Exemplo n.º 1
0
        /// <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;
            //        }
            //    }
            //}
        }
Exemplo n.º 2
0
        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)
                ;
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
 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));
     }
 }
Exemplo n.º 6
0
 /// <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;
 }
Exemplo n.º 7
0
 public XbimGeometryHandle(int geometryLabel)
 {
     GeometryLabel     = geometryLabel;
     GeometryType      = XbimGeometryType.Undefined;
     SurfaceStyleLabel = 0;
     ProductLabel      = 0;
     ExpressTypeId     = 0;
     GeometryHashCode  = null;
 }
Exemplo n.º 8
0
 /// <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;
 }
Exemplo n.º 9
0
 public XbimGeometryHandle(int geometryLabel)
 {
     GeometryLabel = geometryLabel;
     GeometryType = XbimGeometryType.Undefined;
     SurfaceStyleLabel = 0;
     ProductLabel = 0;
     IfcTypeId = 0;
     GeometryHashCode = null;
 }
Exemplo n.º 10
0
 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;
         }
     }
 }
Exemplo n.º 11
0
 /// <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;
 }
Exemplo n.º 12
0
 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;
 }
Exemplo n.º 13
0
        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);
            }
        }
Exemplo n.º 14
0
        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);
            }
        }
Exemplo n.º 15
0
        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);
            }
        }
Exemplo n.º 16
0
        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);
            }
        }
Exemplo n.º 17
0
        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");
            }
        }
Exemplo n.º 18
0
 /// <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));
         }
     }
 }
Exemplo n.º 19
0
        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);
        }
Exemplo n.º 20
0
        /// <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));
                }
            }
            
        }
Exemplo n.º 21
0
        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;
        }
Exemplo n.º 22
0
        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;
        }
Exemplo n.º 23
0
 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");
     }
 }
Exemplo n.º 24
0
 public XbimGeometryHandleCollection GetGeometryHandles(XbimGeometryType geomType = XbimGeometryType.TriangulatedMesh, XbimGeometrySort sortOrder = XbimGeometrySort.OrderByIfcSurfaceStyleThenIfcType)
 {
     return(InstanceCache.GetGeometryHandles(geomType, sortOrder));
 }
Exemplo n.º 25
0
        /// <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);
        }
Exemplo n.º 26
0
 public XbimGeometryHandle(int geometryLabel, XbimGeometryType geometryType, int productLabel, short ifcTypeId, int surfaceStyleLabel)
     : this(geometryLabel, geometryType, productLabel, ifcTypeId, surfaceStyleLabel, null)
 {
 }
Exemplo n.º 27
0
 public IXbimShapeGeometryData CreateShapeGeometry(IXbimGeometryObject geometryObject, double precision, double deflection,
     double angle, XbimGeometryType storageType)
 {
     return _engine.CreateShapeGeometry(geometryObject, precision, deflection, angle, storageType);
 }
Exemplo n.º 28
0
 public IEnumerable <XbimGeometryData> GetGeometryData(XbimGeometryType ofType)
 {
     return(InstanceCache.GetGeometryData(ofType));
 }
Exemplo n.º 29
0
 public IXbimShapeGeometryData CreateShapeGeometry(IXbimGeometryObject geometryObject, double precision, double deflection,
                                                   double angle, XbimGeometryType storageType)
 {
     return(_engine.CreateShapeGeometry(geometryObject, precision, deflection, angle, storageType));
 }
Exemplo n.º 30
0
 public XbimTessellator(IModel model, XbimGeometryType geometryType, bool reduceLargeCoordinates = true)
 {
     _model                  = model;
     _geometryType           = geometryType;
     _reduceLargeCoordinates = reduceLargeCoordinates;
 }
Exemplo n.º 31
0
        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);
                }
            }
        }
Exemplo n.º 32
0
 public IEnumerable <XbimGeometryData> GetGeometryData(IfcProduct product, XbimGeometryType geomType)
 {
     return(InstanceCache.GetGeometry(Metadata.ExpressTypeId(product), product.EntityLabel, geomType));
 }
Exemplo n.º 33
0
        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));
                }
            }
        }
Exemplo n.º 34
0
 public XbimGeometryHandle(int geometryLabel, XbimGeometryType geometryType, int productLabel, short expressTypeId, int surfaceStyleLabel)
     : this(geometryLabel, geometryType, productLabel, expressTypeId, surfaceStyleLabel, null)
 {
 }
Exemplo n.º 35
0
 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));
         }
     }
 }
Exemplo n.º 36
0
        /// <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;
        }
Exemplo n.º 37
0
        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);
                }
            }
        }
Exemplo n.º 38
0
 public XbimTessellator(IModel model, XbimGeometryType geometryType)
 {
     _model        = model;
     _geometryType = geometryType;
 }
Exemplo n.º 39
0
 public XbimTessellator(XbimModel model, XbimGeometryType geometryType)
 {
     _model = model;
     _geometryType = geometryType;
 }