コード例 #1
0
ファイル: IFCViewerWrapperX86.cs プロジェクト: tumcms/QL4BIM
        private void RetrieveObjects(int ifcModel, string objectDisplayName)
        {
            int ifcObjectInstances  = IfcEngine.x86.sdaiGetEntityExtentBN(ifcModel, objectDisplayName),
                noIfcObjectIntances = IfcEngine.x86.sdaiGetMemberCount(ifcObjectInstances);

            if (noIfcObjectIntances != 0)
            {
                IFCItem NewItem = null;
                if (_rootIfcItem == null)
                {
                    _rootIfcItem = new IFCItem();
                    _rootIfcItem.CreateItem(null, 0, "", objectDisplayName, "", "");

                    NewItem = _rootIfcItem;
                }
                else
                {
                    IFCItem LastItem = _rootIfcItem;
                    while (LastItem != null)
                    {
                        if (LastItem.next == null)
                        {
                            LastItem.next = new IFCItem();
                            LastItem.next.CreateItem(null, 0, "", objectDisplayName, "", "");

                            NewItem = LastItem.next;

                            break;
                        }
                        else
                        {
                            LastItem = LastItem.next;
                        }
                    }
                    ;
                }


                for (int i = 0; i < noIfcObjectIntances; ++i)
                {
                    NormalEntityProcessing(objectDisplayName, ifcObjectInstances, i, NewItem);
                }
            }
        }
コード例 #2
0
ファイル: IFCViewerWrapperX86.cs プロジェクト: tumcms/QL4BIM
        private void GenerateFacesGeometry(int ifcModel, IFCItem ifcItem)
        {
            if (ifcItem.ifcID != 0)
            {
                int noVertices = 0, noIndices = 0;
                IfcEngine.x86.initializeModellingInstance(ifcModel, ref noVertices, ref noIndices, 0, ifcItem.ifcID);

                if (noVertices != 0 && noIndices != 0)
                {
                    ifcItem.noVerticesForFaces   = noVertices;
                    ifcItem.noPrimitivesForFaces = noIndices / 3;
                    ifcItem.verticesForFaces     = new float[3 * noVertices];
                    ifcItem.indicesForFaces      = new int[noIndices];

                    float[] pVertices = new float[noVertices * 3];

                    IfcEngine.x86.finalizeModelling(ifcModel, pVertices, ifcItem.indicesForFaces, 0);

                    int i = 0;
                    while (i < noVertices)
                    {
                        ifcItem.verticesForFaces[3 * i + 0] = pVertices[3 * i + 0];
                        ifcItem.verticesForFaces[3 * i + 1] = pVertices[3 * i + 1];
                        ifcItem.verticesForFaces[3 * i + 2] = pVertices[3 * i + 2];
                        i++;
                    }

                    var doubleList = new List <double>();
                    if (modelInMilimeters)
                    {
                        doubleList.AddRange(ifcItem.verticesForFaces.Select(value => (double)value / 1000));
                    }
                    else
                    {
                        doubleList.AddRange(ifcItem.verticesForFaces.Select(value => (double)value));
                    }



                    indicesVerticesPerId.Add(new Tuple <string, int[], double[]>(ifcItem.globalID, ifcItem.indicesForFaces, doubleList.ToArray()));
                }
            }
        }
コード例 #3
0
ファイル: IFCViewerWrapperX86.cs プロジェクト: tumcms/QL4BIM
        private static void NormalEntityProcessing(string objectDisplayName, int ifcObjectInstances, int i,
                                                   IFCItem NewItem)
        {
            int ifcObjectIns = 0;

            IfcEngine.x86.engiGetAggrElement(ifcObjectInstances, i, IfcEngine.x86.sdaiINSTANCE, out ifcObjectIns);

            IntPtr value = IntPtr.Zero;

            IfcEngine.x86.sdaiGetAttrBN(ifcObjectIns, "GlobalId", IfcEngine.x86.sdaiSTRING, out value);

            string globalID = Marshal.PtrToStringAnsi((IntPtr)value);

            if (string.CompareOrdinal(objectDisplayName, "IfcSIUnit") == 0)
            {
                value = IntPtr.Zero;
                IfcEngine.x86.sdaiGetAttrBN(ifcObjectIns, "Prefix", IfcEngine.x86.sdaiSTRING, out value);
                string milInicator = Marshal.PtrToStringAnsi((IntPtr)value);

                if (string.CompareOrdinal(milInicator, ".MILLI.") == 0)
                {
                    modelInMilimeters = true;
                }

                return;
            }

            value = IntPtr.Zero;
            IfcEngine.x86.sdaiGetAttrBN(ifcObjectIns, "Name", IfcEngine.x86.sdaiSTRING, out value);

            string name = Marshal.PtrToStringAnsi((IntPtr)value);

            value = IntPtr.Zero;
            IfcEngine.x86.sdaiGetAttrBN(ifcObjectIns, "Description", IfcEngine.x86.sdaiSTRING, out value);

            string description = Marshal.PtrToStringAnsi((IntPtr)value);

            IFCItem subItem = new IFCItem();

            subItem.CreateItem(NewItem, ifcObjectIns, objectDisplayName, globalID, name, description);
        }
コード例 #4
0
ファイル: IFCViewerWrapperX86.cs プロジェクト: tumcms/QL4BIM
        public void CreateItem(IFCItem parent, int ifcID, string ifcType, string globalID, string name, string desc)
        {
            this.parent      = parent;
            this.next        = null;
            this.child       = null;
            this.globalID    = globalID;
            this.ifcID       = ifcID;
            this.ifcType     = ifcType;
            this.description = desc;
            this.name        = name;

            if (parent != null)
            {
                if (parent.child == null)
                {
                    parent.child = this;
                }
                else
                {
                    IFCItem NextChild = parent;

                    while (true)
                    {
                        if (NextChild.next == null)
                        {
                            NextChild.next = this;
                            break;
                        }
                        else
                        {
                            NextChild = NextChild.next;
                        }
                    }
                }
            }
        }
コード例 #5
0
ファイル: IFCViewerWrapperX86.cs プロジェクト: tumcms/QL4BIM
        private void GetDimensions(IFCItem ifcItem, ref double[] min, ref double[] max, ref bool InitMinMax)
        {
            while (ifcItem != null)
            {
                if (ifcItem.noVerticesForFaces != 0)
                {
                    if (InitMinMax == false)
                    {
                        min[0] = ifcItem.verticesForFaces[3 * 0 + 0];
                        min[1] = ifcItem.verticesForFaces[3 * 0 + 1];
                        min[2] = ifcItem.verticesForFaces[3 * 0 + 2];
                        max    = min;

                        InitMinMax = true;
                    }

                    int i = 0;
                    while (i < ifcItem.noVerticesForFaces)
                    {
                        min[0] = Math.Min(min[0], ifcItem.verticesForFaces[6 * i + 0]);
                        min[1] = Math.Min(min[1], ifcItem.verticesForFaces[6 * i + 1]);
                        min[2] = Math.Min(min[2], ifcItem.verticesForFaces[6 * i + 2]);

                        max[0] = Math.Max(max[0], ifcItem.verticesForFaces[6 * i + 0]);
                        max[1] = Math.Max(max[1], ifcItem.verticesForFaces[6 * i + 1]);
                        max[2] = Math.Max(max[2], ifcItem.verticesForFaces[6 * i + 2]);

                        i++;
                    }
                }

                GetDimensions(ifcItem.child, ref min, ref max, ref InitMinMax);

                ifcItem = ifcItem.next;
            }
        }
コード例 #6
0
ファイル: IFCViewerWrapperX86.cs プロジェクト: tumcms/QL4BIM
 public IList <Tuple <string, int[], double[]> > OpenIfcFile(string ifcFilePath)
 {
     _rootIfcItem = null;
     return(ParseIfcFile(ifcFilePath));
 }
コード例 #7
0
ファイル: IFCViewerWrapperX86.cs プロジェクト: tumcms/QL4BIM
        void GenerateGeometry(int ifcModel, IFCItem ifcItem, ref int a)
        {
            while (ifcItem != null)
            {
                // -----------------------------------------------------------------
                // Generate WireFrames Geometry

                int setting = 0, mask = 0;
                mask    += IfcEngine.x86.flagbit2;  //    PRECISION (32/64 bit)
                mask    += IfcEngine.x86.flagbit3;  //	   INDEX ARRAY (32/64 bit)
                mask    += IfcEngine.x86.flagbit5;  //    NORMALS
                mask    += IfcEngine.x86.flagbit8;  //    TRIANGLES
                mask    += IfcEngine.x86.flagbit12; //    WIREFRAME
                setting += 0;                       //    DOUBLE PRECISION (double)

                if (IntPtr.Size == 4)               // indication for 32
                {
                    setting += 0;                   //    32 BIT INDEX ARRAY (Int32)
                }
                else
                {
                    if (IntPtr.Size == 8)
                    {
                        setting += IfcEngine.x86.flagbit3;     // 64 BIT INDEX ARRAY (Int64)
                    }
                }

                setting += 0;                       //    NORMALS OFF
                setting += 0;                       //    TRIANGLES OFF
                setting += IfcEngine.x86.flagbit12; //    WIREFRAME ON


                IfcEngine.x86.setFormat(ifcModel, setting, mask);

                //GenerateWireFrameGeometry(ifcModel, ifcItem);
                // -----------------------------------------------------------------
                // Generate Faces Geometry

                setting  = 0;
                setting += 0;         //    SINGLE PRECISION (float)
                if (IntPtr.Size == 4) // indication for 32
                {
                    setting += 0;     //    32 BIT INDEX ARRAY (Int32)
                }
                else
                {
                    if (IntPtr.Size == 8)
                    {
                        setting += IfcEngine.x86.flagbit3;     //    64 BIT INDEX ARRAY (Int64)
                    }
                }

                setting += 0;                      // IfcEngine.x86.flagbit5;     //    NORMALS ON
                setting += IfcEngine.x86.flagbit8; //    TRIANGLES ON
                setting += 0;                      //    WIREFRAME OFF
                IfcEngine.x86.setFormat(ifcModel, setting, mask);

                GenerateFacesGeometry(ifcModel, ifcItem);

                IfcEngine.x86.cleanMemory(ifcModel, 0);

                GenerateGeometry(ifcModel, ifcItem.child, ref a);
                ifcItem = ifcItem.next;
            }
        }