Beispiel #1
0
        void GenerateGeometry(long ifcModel, IFCItemX64 ifcItem, ref int a)
        {
            while (ifcItem != null)
            {
                Int64 setting = 0, mask = 0;
                mask += IfcEngine.x64.flagbit2;        //    PRECISION (32/64 bit)
                mask += IfcEngine.x64.flagbit3;        //    INDEX ARRAY (32/64 bit)
                mask += IfcEngine.x64.flagbit5;        //    NORMALS
                mask += IfcEngine.x64.flagbit8;        //    TRIANGLES
                mask += IfcEngine.x64.flagbit12;       //    WIREFRAME

                setting += 0;                          //    SINGLE PRECISION (float)
                setting += 0;                          //    32 BIT INDEX ARRAY (Int32)
                setting += IfcEngine.x64.flagbit5;     //    NORMALS ON
                setting += IfcEngine.x64.flagbit8;     //    TRIANGLES ON
                setting += 0;                          //    WIREFRAME OFF
                IfcEngine.x64.setFormat(ifcModel, setting, mask);

                GenerateFacesGeometry(ifcModel, ifcItem);

                IfcEngine.x64.cleanMemory(ifcModel, 0);

                GenerateGeometry(ifcModel, ifcItem.child, ref a);
                ifcItem = ifcItem.next;
            }
        }
Beispiel #2
0
        private void GenerateFacesGeometry(long ifcModel, IFCItemX64 ifcItem)
        {
            if (ifcItem.ifcID != 0)
            {
                long noVertices = 0, noIndices = 0;
                IfcEngine.x64.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[6 * noVertices];
                    ifcItem.indicesForFaces      = new int[noIndices];



                    IfcEngine.x64.finalizeModelling(ifcModel, ifcItem.verticesForFaces, ifcItem.indicesForFaces, 0);


                    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()));
                }
            }
        }
Beispiel #3
0
        private void RetrieveObjects(long ifcModel, string objectDisplayName)
        {
            long ifcObjectInstances  = IfcEngine.x64.sdaiGetEntityExtentBN(ifcModel, objectDisplayName),
                 noIfcObjectIntances = IfcEngine.x64.sdaiGetMemberCount(ifcObjectInstances);

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

                    NewItem = _rootIfcItem;
                }
                else
                {
                    IFCItemX64 LastItem = _rootIfcItem;
                    while (LastItem != null)
                    {
                        if (LastItem.next == null)
                        {
                            LastItem.next = new IFCItemX64();
                            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);
                }
            }
        }
Beispiel #4
0
        private static void NormalEntityProcessing(string objectDisplayName, long ifcObjectInstances, int i, IFCItemX64 NewItem)
        {
            long ifcObjectIns = 0;

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

            IntPtr value = IntPtr.Zero;

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

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

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

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

                return;
            }

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

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

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

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

            IFCItemX64 subItem = new IFCItemX64();

            subItem.CreateItem(NewItem, ifcObjectIns, objectDisplayName, globalID, name, description);
        }
Beispiel #5
0
        public void CreateItem(IFCItemX64 parent, long 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
                {
                    IFCItemX64 NextChild = parent;

                    while (true)
                    {
                        if (NextChild.next == null)
                        {
                            NextChild.next = this;
                            break;
                        }
                        else
                        {
                            NextChild = NextChild.next;
                        }
                    }
                }
            }
        }
Beispiel #6
0
 public IList <Tuple <string, int[], double[]> > OpenIfcFile(string ifcFilePath)
 {
     _rootIfcItem = null;
     return(ParseIfcFile(ifcFilePath));
 }