コード例 #1
0
        string getMaterialProfileSetString(IIfcMaterialProfileSet mProfileSet)
        {
            string material = string.Empty;

            foreach (IIfcMaterialProfile mProfile in mProfileSet.MaterialProfiles)
            {
                string profileName     = string.Empty;
                string materialProfile = "-";
                if (mProfile.Material != null)
                {
                    materialProfile = "(" + mProfile.Material.Name + ", ";
                }
                else
                {
                    materialProfile = "(-, ";
                }

                if (mProfile.Profile.ProfileName.HasValue)
                {
                    profileName = mProfile.Profile.ProfileName.ToString();
                }

                materialProfile += profileName + ")";

                BIMRLCommon.appendToString(materialProfile, ", ", ref material);
            }

            return(material);
        }
コード例 #2
0
 public BIMRLSpatialIndex(BIMRLCommon bimrlCommon)
 {
     _refBIMRLCommon = bimrlCommon;
     polyHFaceVertIdxList.Clear();
     polyHCoordListList.Clear();
     elemIDList.Clear();
 }
コード例 #3
0
        public MainWindow()
        {
            BIMRLCommon BIMRLCommonRef = new BIMRLCommon();

            InitializeComponent();

            // Connect to Oracle DB
            DBOperation.refBIMRLCommon = BIMRLCommonRef;      // important to ensure DBoperation has reference to this object!!
            if (DBOperation.Connect() == null)
            {
                BIMRLErrorDialog erroDlg = new BIMRLErrorDialog(BIMRLCommonRef);
                erroDlg.ShowDialog();
                return;
            }

            BIMRLQueryModel      _qModel   = new BIMRLQueryModel(BIMRLCommonRef);
            List <BIMRLFedModel> fedModels = new List <BIMRLFedModel>();

            fedModels = _qModel.getFederatedModels();

            DataGrid_Oracle.AutoGenerateColumns = true;
            DataGrid_Oracle.IsReadOnly          = true;
            DataGrid_Oracle.ItemsSource         = fedModels;
            DataGrid_Oracle.MinRowHeight        = 20;
            Button_Copy.IsEnabled = false;

            DataGrid_Cassandra.IsReadOnly          = true;
            DataGrid_Cassandra.AutoGenerateColumns = true;
            DataGrid_Cassandra.MinRowHeight        = 20;

            QueryCassDB          qCDB      = new QueryCassDB();
            List <BIMRLFedModel> modelList = qCDB.getCassFedModels();

            DataGrid_Cassandra.ItemsSource = modelList;
        }
コード例 #4
0
        string FormatTelecomAddress(IIfcTelecomAddress telecomAddress)
        {
            string formattedTelecomAddress = "";

            if (telecomAddress.TelephoneNumbers.Count > 0)
            {
                BIMRLCommon.appendToString("Tel: ", null, ref formattedTelecomAddress);
                foreach (IfcLabel telNo in telecomAddress.TelephoneNumbers)
                {
                    BIMRLCommon.appendToString(telNo.ToString(), ", ", ref formattedTelecomAddress);
                }
            }

            if (telecomAddress.FacsimileNumbers.Count > 0)
            {
                BIMRLCommon.appendToString("Fax: ", null, ref formattedTelecomAddress);
                foreach (IfcLabel faxNo in telecomAddress.FacsimileNumbers)
                {
                    BIMRLCommon.appendToString(faxNo.ToString(), ", ", ref formattedTelecomAddress);
                }
            }

            if (telecomAddress.PagerNumber.HasValue)
            {
                BIMRLCommon.appendToString("Pager: " + telecomAddress.PagerNumber.Value.ToString(), ", ", ref formattedTelecomAddress);
            }

            if (telecomAddress.ElectronicMailAddresses.Count > 0)
            {
                BIMRLCommon.appendToString("e-mail: ", null, ref formattedTelecomAddress);
                foreach (IfcLabel email in telecomAddress.ElectronicMailAddresses)
                {
                    BIMRLCommon.appendToString(email.ToString(), ", ", ref formattedTelecomAddress);
                }
            }

            if (telecomAddress.MessagingIDs.Count > 0)
            {
                BIMRLCommon.appendToString("Messaging ID: ", null, ref formattedTelecomAddress);
                foreach (IfcURIReference mesgID in telecomAddress.MessagingIDs)
                {
                    BIMRLCommon.appendToString(mesgID.ToString(), ", ", ref formattedTelecomAddress);
                }
            }

            if (telecomAddress.WWWHomePageURL.HasValue)
            {
                BIMRLCommon.appendToString("Website: " + telecomAddress.WWWHomePageURL.Value.ToString(), ", ", ref formattedTelecomAddress);
            }

            return(formattedTelecomAddress);
        }
コード例 #5
0
 public BuildGraph(BIMRLCommon bimrlCommon)
 {
     if (bimrlCommon == null)
     {
         GraphData.refBimrlCommon = new BIMRLCommon();
         refBimrlCommon           = GraphData.refBimrlCommon;
     }
     else
     {
         refBimrlCommon = bimrlCommon;
     }
     NodeDict           = new Dictionary <int, Tuple <string, string, string, Point3D> >();
     ElemIDToNodeIDDict = new Dictionary <string, int>();
     graph      = new UndirectedGraph <int, TaggedEdge <int, int> >();
     biDirGraph = new BidirectionalGraph <int, TaggedEdge <int, int> >();
 }
コード例 #6
0
        string FormatPostalAddress(IIfcPostalAddress postalAddress)
        {
            string formattedPostalAddress = "";

            if (postalAddress.InternalLocation.HasValue)
            {
                BIMRLCommon.appendToString(postalAddress.InternalLocation.Value.ToString(), " ,", ref formattedPostalAddress);
            }

            if (postalAddress.AddressLines != null)
            {
                foreach (IfcLabel addrLine in postalAddress.AddressLines)
                {
                    BIMRLCommon.appendToString(addrLine.ToString(), " ,", ref formattedPostalAddress);
                }
            }

            if (postalAddress.PostalBox.HasValue)
            {
                BIMRLCommon.appendToString("PO Box: " + postalAddress.PostalBox.Value.ToString(), " ,", ref formattedPostalAddress);
            }

            if (postalAddress.Town.HasValue)
            {
                BIMRLCommon.appendToString(postalAddress.Town.Value.ToString(), " ,", ref formattedPostalAddress);
            }

            if (postalAddress.Region.HasValue)
            {
                BIMRLCommon.appendToString(postalAddress.Region.Value.ToString(), " ,", ref formattedPostalAddress);
            }

            if (postalAddress.PostalCode.HasValue)
            {
                BIMRLCommon.appendToString(postalAddress.PostalCode.Value.ToString(), " - ", ref formattedPostalAddress);
            }

            if (postalAddress.Country.HasValue)
            {
                BIMRLCommon.appendToString(postalAddress.Country.Value.ToString(), " ,", ref formattedPostalAddress);
            }

            return(formattedPostalAddress);
        }
コード例 #7
0
ファイル: BIMRLUtils.cs プロジェクト: jdimyadi/BIMRL-DBETL
        /// <summary>
        /// This function is to patch data, updating element's major axes and their OBB at the same time
        /// </summary>
        /// <param name="fedID"></param>
        /// <param name="whereCond"></param>
        public static void updateMajorAxesAndOBB(int fedID, string whereCond)
        {
            BIMRLCommon bimrlCommon = new BIMRLCommon();

            string sqlStmt = "SELECT ELEMENTID, GEOMETRYBODY FROM " + DBOperation.formatTabName("BIMRL_ELEMENT", fedID) + " WHERE GEOMETRYBODY IS NOT NULL";

            if (!string.IsNullOrEmpty(whereCond))
            {
                sqlStmt += " AND " + whereCond;
            }

            OracleCommand    cmd    = new OracleCommand(sqlStmt, DBOperation.DBConn);
            OracleDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                string      elementid = reader.GetString(0);
                SdoGeometry geom      = reader.GetValue(1) as SdoGeometry;

                Polyhedron polyH;
                if (!SDOGeomUtils.generate_Polyhedron(geom, out polyH))
                {
                    continue;  // something wrong, unable to get the polyhedron, skip
                }
                BIMRLGeometryPostProcess postProc = new BIMRLGeometryPostProcess(elementid, polyH, bimrlCommon, fedID, null);
                postProc.deriveMajorAxes();
                postProc.trueOBBFaces();
                postProc.projectedFaces();

                //// create OBB topo face information
                //if (postProc.OBB != null)
                //{
                //    Polyhedron obbGeom;
                //    if (SDOGeomUtils.generate_Polyhedron(postProc.OBB, out obbGeom))
                //    {
                //        BIMRLGeometryPostProcess processFaces = new BIMRLGeometryPostProcess(elementid, obbGeom, bimrlCommon, fedID, "OBB");
                //        processFaces.simplifyAndMergeFaces();
                //        processFaces.insertIntoDB(false);
                //    }
                //}
            }
            reader.Close();
        }
コード例 #8
0
 public BIMRLDiffModels(int modelId1, int modelId2, BIMRLCommon bimrlCommon)
 {
     compNewModel     = modelId1;
     compRefModel     = modelId2;
     m_BIMRLCommonRef = bimrlCommon;
 }
コード例 #9
0
 public BIMRLClassification(IfcStore m, BIMRLCommon refBIMRLCommon)
 {
     _refBIMRLCommon = refBIMRLCommon;
     _model          = m;
 }
コード例 #10
0
        public void processOwnerHistory()
        {
            string currStep = string.Empty;

            DBOperation.beginTransaction();

            OracleCommand command = new OracleCommand(" ", DBOperation.DBConn);

            IEnumerable <IIfcOwnerHistory> ownerHistoryList = _model.Instances.OfType <IIfcOwnerHistory>();

            foreach (IIfcOwnerHistory ownH in ownerHistoryList)
            {
                string columnSpec = "ID, ModelID";
                int    ID         = Math.Abs(ownH.EntityLabel);
                string valueList  = ID.ToString() + ", " + BIMRLProcessModel.currModelID;

                IIfcPerson thePerson   = ownH.OwningUser.ThePerson;
                string     givenName   = string.Empty;
                string     familyName  = string.Empty;
                string     middleNames = string.Empty;
                if (thePerson.MiddleNames != null)
                {
                    foreach (string middleName in thePerson.MiddleNames)
                    {
                        BIMRLCommon.appendToString(middleName.Trim(), " ", ref middleNames);
                    }
                }
                if (thePerson.GivenName != null)
                {
                    givenName = thePerson.GivenName.ToString().Trim();
                }
                if (thePerson.FamilyName != null)
                {
                    familyName = thePerson.FamilyName.ToString().Trim();
                }
                string owningPersonName = givenName + " " + middleNames + " " + familyName;

                if (!string.IsNullOrEmpty(owningPersonName))
                {
                    columnSpec += ", OwningPersonName";
                    valueList  += ", '" + owningPersonName + "'";
                }

                if (ownH.OwningUser.Roles != null)
                {
                    string roleString = string.Empty;
                    foreach (var role in ownH.OwningUser.Roles)
                    {
                        string roleStr = role.RoleString;
                        if (roleStr.Equals("USERDEFINED") && role.UserDefinedRole.HasValue)
                        {
                            roleStr = role.UserDefinedRole.Value.ToString();
                        }
                        BIMRLCommon.appendToString(roleStr, ", ", ref roleString);
                    }
                    if (!string.IsNullOrEmpty(roleString))
                    {
                        columnSpec += ", OwningPersonRoles";
                        valueList  += ", '" + roleString + "'";
                    }
                }
                //if (ownH.OwningUser.RolesString != null)
                //    {
                //        string owningPersonRoles = ownH.OwningUser.RolesString.Trim();
                //        if (!string.IsNullOrEmpty(owningPersonRoles))
                //        {
                //            columnSpec += ", OwningPersonRoles";
                //            valueList += ", '" + owningPersonRoles + "'";
                //        }
                //    }

                if (ownH.OwningUser.ThePerson.Addresses != null)
                {
                    string owningPersonAddresses = "";
                    foreach (IIfcAddress addr in ownH.OwningUser.ThePerson.Addresses)
                    {
                        BIMRLAddressData addrData = new BIMRLAddressData(addr);
                        BIMRLCommon.appendToString(addrData.ToString(), "; ", ref owningPersonAddresses);
                    }

                    if (!string.IsNullOrEmpty(owningPersonAddresses))
                    {
                        columnSpec += ", OwningPersonAddresses";
                        valueList  += ", '" + owningPersonAddresses + "'";
                    }
                }

                if (ownH.OwningUser.TheOrganization.Identification != null)
                {
                    columnSpec += ", OwningOrganizationId";
                    valueList  += ", '" + ownH.OwningUser.TheOrganization.Identification + "'";
                }

                if (ownH.OwningUser.TheOrganization.Name != null)
                {
                    columnSpec += ", OwningOrganizationName";
                    valueList  += ", '" + ownH.OwningUser.TheOrganization.Name + "'";
                }

                if (ownH.OwningUser.TheOrganization.Description != null)
                {
                    columnSpec += ", OwningOrganizationDescription";
                    valueList  += ", '" + ownH.OwningUser.TheOrganization.Description + "'";
                }

                if (ownH.OwningUser.TheOrganization.Roles != null)
                {
                    string roleString = string.Empty;
                    foreach (var role in ownH.OwningUser.TheOrganization.Roles)
                    {
                        string roleStr = role.RoleString;
                        if (roleStr.Equals("USERDEFINED") && role.UserDefinedRole.HasValue)
                        {
                            roleStr = role.UserDefinedRole.Value.ToString();
                        }
                        BIMRLCommon.appendToString(roleStr, ", ", ref roleString);
                    }
                    if (!string.IsNullOrEmpty(roleString))
                    {
                        columnSpec += ", OwningOrganizationRoles";
                        valueList  += ", '" + roleString + "'";
                    }

                    //string owningOrganizationRoles = ownH.OwningUser.TheOrganization.RolesString.Trim();
                    //     if (!string.IsNullOrEmpty(owningOrganizationRoles))
                    //     {
                    //         columnSpec += ", OwningOrganizationRoles";
                    //         valueList += ", '" + owningOrganizationRoles + "'";
                    //     }
                }

                if (ownH.OwningUser.TheOrganization.Addresses != null)
                {
                    string owningOrganizationAddresses = "";
                    foreach (IIfcAddress addr in ownH.OwningUser.TheOrganization.Addresses)
                    {
                        BIMRLAddressData addrData = new BIMRLAddressData(addr);
                        BIMRLCommon.appendToString(addrData.ToString(), "; ", ref owningOrganizationAddresses);
                    }

                    if (!string.IsNullOrEmpty(owningOrganizationAddresses))
                    {
                        columnSpec += ", OwningOrganizationAddresses";
                        valueList  += ", '" + owningOrganizationAddresses + "'";
                    }
                }

                columnSpec += ", ApplicationName, ApplicationVersion, ApplicationDeveloper, ApplicationID";
                valueList  += ", '" + ownH.OwningApplication.ApplicationFullName + "', '" + ownH.OwningApplication.Version + "', '"
                              + ownH.OwningApplication.ApplicationDeveloper.Name + "', '" + ownH.OwningApplication.ApplicationIdentifier + "'";

                if (ownH.State != null)
                {
                    columnSpec += ", State";
                    valueList  += ", '" + ownH.State.ToString() + "'";
                }

                columnSpec += ", ChangeAction";
                valueList  += ", '" + ownH.ChangeAction.ToString() + "'";

                if (ownH.LastModifiedDate != null)
                {
                    long lastModTS = (long)ownH.LastModifiedDate.Value / 86400; // No of days
                    columnSpec += ", LastModifiedDate";
                    valueList  += ", to_date('01-01-1970 00:00:00','DD-MM-YYYY HH24:MI:SS')+" + lastModTS.ToString() + " ";
                }

                if (ownH.LastModifyingUser != null)
                {
                    columnSpec += ", LastModifyingUserID";
                    IIfcPerson modPerson           = ownH.LastModifyingUser.ThePerson;
                    string     LastModifyingUserId = modPerson.GivenName.ToString().Trim() + " " + modPerson.MiddleNames.ToString().Trim() + " " + modPerson.FamilyName.ToString().Trim();

                    valueList += ", '" + LastModifyingUserId + "'";
                }

                if (ownH.LastModifyingApplication != null)
                {
                    columnSpec += ", LastModifyingApplicationID";
                    valueList  += ", 'ID: " + ownH.LastModifyingApplication.ApplicationIdentifier + "; Name: " + ownH.LastModifyingApplication.ApplicationFullName
                                  + "; Ver: " + ownH.LastModifyingApplication.Version + "; Dev: " + ownH.LastModifyingApplication.ApplicationDeveloper.Name + "'";
                }

                long crDateTS = ownH.CreationDate / 86400; // No of days
                columnSpec += ", CreationDate";
                valueList  += ", to_date('01-01-1970 00:00:00','DD-MM-YYYY HH24:MI:SS')+" + crDateTS.ToString() + " ";

                string sqlStmt = "insert into " + DBOperation.formatTabName("BIMRL_OWNERHISTORY") + "(" + columnSpec + ") values (" + valueList + ")";
                currStep = sqlStmt;

                command.CommandText = sqlStmt;

                try
                {
                    int commandStatus          = command.ExecuteNonQuery();
                    Tuple <int, int> ownHEntry = new Tuple <int, int>(ID, BIMRLProcessModel.currModelID);
                    _refBIMRLCommon.OwnerHistoryAdd(ownHEntry);
                }
                catch (OracleException e)
                {
                    string excStr = "%%Insert Error - " + e.Message + "\n\t" + currStep;
                    _refBIMRLCommon.StackPushIgnorableError(excStr);
                }
                catch (SystemException e)
                {
                    string excStr = "%%Insert Error - " + e.Message + "\n\t" + currStep;
                    _refBIMRLCommon.StackPushError(excStr);
                    throw;
                }
            }

            DBOperation.commitTransaction();
            command.Dispose();
        }
コード例 #11
0
 public BIMRLOwnerHistory(IModel m, BIMRLCommon refBIMRLCommon)
 {
     _model          = m;
     _refBIMRLCommon = refBIMRLCommon;
 }
コード例 #12
0
        public BIMRLProcessModel(IModel model, bool update)
        {
            //IfcProject proj = model.IfcProject;
            IfcStore modelStore = model as IfcStore;
            string   currStep   = String.Empty;

            _bimrlCommon.resetAll();

            // Connect to Oracle DB
            DBOperation.refBIMRLCommon = _bimrlCommon;   // important to ensure DBoperation has reference to this object!!

            try
            {
                DBOperation.ExistingOrDefaultConnection();
            }
            catch
            {
                if (DBOperation.UIMode)
                {
                    BIMRLErrorDialog erroDlg = new BIMRLErrorDialog(_bimrlCommon);
                    erroDlg.ShowDialog();
                }
                else
                {
                    Console.Write(_bimrlCommon.ErrorMessages);
                }
                return;
            }

            DBOperation.commitInterval = 5000;

            // Initial Spatial index for later use
            BIMRLSpatialIndex spIdx = new BIMRLSpatialIndex(_bimrlCommon);

            try
            {
                DBOperation.beginTransaction();
                IIfcProject firstProject;
                if (modelStore.IsFederation)
                {
                    IfcStore firstModel = modelStore.ReferencedModels.FirstOrDefault().Model as IfcStore;
                    firstProject = firstModel.Instances.OfType <IIfcProject>().FirstOrDefault();
                }
                else
                {
                    firstProject = modelStore.Instances.OfType <IIfcProject>().FirstOrDefault();
                }
                string projLName;

                // Check whether Model has been defined before
                if (string.IsNullOrEmpty(firstProject.LongName))
                {
                    projLName = firstProject.Name + " - Federated";
                }
                else
                {
                    projLName = firstProject.LongName;
                }

                string modelNameFromFile;
                if (!string.IsNullOrEmpty(modelStore.FileName))
                {
                    modelNameFromFile = Path.GetFileNameWithoutExtension(modelStore.FileName);
                }
                else
                {
                    modelNameFromFile = firstProject.Name + " - " + firstProject.LongName;
                }

                currStep = "Getting Federated ID from BIMRL_FEDERATEDMODEL - Model name, Project name and longname: " + modelNameFromFile + "; " + firstProject.Name + "; " + firstProject.LongName;
                FederatedModelInfo fedModel;
                FedIDStatus        stat = DBOperation.getFederatedModel(modelNameFromFile, projLName, firstProject.Name, out fedModel);
                if (stat == FedIDStatus.FedIDNew)
                {
                    DBOperation.currFedModel = fedModel;
                    // Create new set of tables using the fedID as suffix
                    int retStat = DBOperation.createModelTables(DBOperation.currFedModel.FederatedID);
                }
                else
                {
                    DBOperation.currFedModel = fedModel;
                    if (!fedModel.Owner.Equals(DBOperation.DBUserID))
                    {
                        _bimrlCommon.StackPushError("%Error: Only the Owner (" + fedModel.Owner + ") can delete or override existing model (!" + fedModel.ModelName + ")");
                        throw new Exception("%Error: Unable to overwrite exisitng model");
                    }

                    // Drop and recreate tables
                    currStep = "Dropping existing model tables (ID: " + DBOperation.currFedModel.FederatedID.ToString("X4") + ")";
                    int retStat = DBOperation.dropModelTables(DBOperation.currFedModel.FederatedID);
                    currStep = "Creating model tables (ID: " + DBOperation.currFedModel.FederatedID.ToString("X4") + ")";
                    retStat  = DBOperation.createModelTables(DBOperation.currFedModel.FederatedID);
                }

                DBOperation.currSelFedID = DBOperation.currFedModel.FederatedID;    // set the static variable keeping the selected Fed Id

                if (modelStore.IsFederation)
                {
                    // get all models

                    foreach (IReferencedModel refModel in modelStore.ReferencedModels)
                    {
                        IfcStore m = refModel.Model as IfcStore;
                        currStep = "Getting Model ID for Federated model ID:" + DBOperation.currFedModel.FederatedID.ToString("X4");
                        _bimrlCommon.ClearDicts();

                        _ModelID = DBOperation.getModelID(DBOperation.currFedModel.FederatedID);
                        doModel(m);
                        BIMRLUtils.ResetIfcUnitDicts();
                    }
                }
                else
                {
                    currStep = "Getting Model ID for Federated model ID:" + DBOperation.currFedModel.FederatedID.ToString("X4");
                    _ModelID = DBOperation.getModelID(DBOperation.currFedModel.FederatedID);
                    doModel(modelStore);
                    BIMRLUtils.ResetIfcUnitDicts();
                }
            }
            catch (Exception e)
            {
                string excStr = "%%Error - " + e.Message + "\n\t" + currStep;
                _bimrlCommon.StackPushError(excStr);
                DBOperation.endTransaction(false); // rollback
            }

            DBOperation.endTransaction(true);  // Commit = true

            try
            {
                DBOperation.beginTransaction();
                OracleCommand cmd = new OracleCommand("", DBOperation.DBConn);

                // Define the spatial index metadata
                double marginX = (_bimrlCommon.URT_X - _bimrlCommon.LLB_X) * 0.2; // 20% margin
                double marginY = (_bimrlCommon.URT_Y - _bimrlCommon.LLB_Y) * 0.2; // 20% margin
                double marginZ = (_bimrlCommon.URT_Z - _bimrlCommon.LLB_Z) * 0.2; // 20% margin
                double lowerX  = _bimrlCommon.LLB_X - marginX;
                double upperX  = _bimrlCommon.URT_X + marginX;
                double lowerY  = _bimrlCommon.LLB_Y - marginY;
                double upperY  = _bimrlCommon.URT_Y + marginY;
                double lowerZ  = _bimrlCommon.LLB_Z - marginZ;
                double upperZ  = _bimrlCommon.URT_Z + marginZ;

                string sqlStmt = "insert into USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) VALUES "
                                 + "('BIMRL_ELEMENT_" + DBOperation.currFedModel.FederatedID.ToString("X4") + "','GEOMETRYBODY',"
                                 + "SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', " + lowerX.ToString() + ", " + upperX.ToString() + ", 0.000001),"
                                 + "SDO_DIM_ELEMENT('Y', " + lowerY.ToString() + ", " + upperY.ToString() + ", 0.000001),"
                                 + "SDO_DIM_ELEMENT('Z', " + lowerZ.ToString() + ", " + upperZ.ToString() + ", 0.000001)),"
                                 + "NULL)";
                currStep        = sqlStmt;
                cmd.CommandText = sqlStmt;
                cmd.ExecuteNonQuery();

                sqlStmt = "insert into USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) VALUES "
                          + "('BIMRL_ELEMENT_" + DBOperation.currFedModel.FederatedID.ToString("X4") + "','GEOMETRYBODY_BBOX',"
                          + "SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', " + lowerX.ToString() + ", " + upperX.ToString() + ", 0.000001),"
                          + "SDO_DIM_ELEMENT('Y', " + lowerY.ToString() + ", " + upperY.ToString() + ", 0.000001),"
                          + "SDO_DIM_ELEMENT('Z', " + lowerZ.ToString() + ", " + upperZ.ToString() + ", 0.000001)),"
                          + "NULL)";
                currStep        = sqlStmt;
                cmd.CommandText = sqlStmt;
                cmd.ExecuteNonQuery();

                sqlStmt = "insert into USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) VALUES "
                          + "('BIMRL_ELEMENT_" + DBOperation.currFedModel.FederatedID.ToString("X4") + "','GEOMETRYBODY_BBOX_CENTROID',"
                          + "SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', " + lowerX.ToString() + ", " + upperX.ToString() + ", 0.000001),"
                          + "SDO_DIM_ELEMENT('Y', " + lowerY.ToString() + ", " + upperY.ToString() + ", 0.000001),"
                          + "SDO_DIM_ELEMENT('Z', " + lowerZ.ToString() + ", " + upperZ.ToString() + ", 0.000001)),"
                          + "NULL)";
                currStep        = sqlStmt;
                cmd.CommandText = sqlStmt;
                cmd.ExecuteNonQuery();

                sqlStmt = "insert into USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) VALUES "
                          + "('BIMRL_ELEMENT_" + DBOperation.currFedModel.FederatedID.ToString("X4") + "','GEOMETRYFOOTPRINT',"
                          + "SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', " + lowerX.ToString() + ", " + upperX.ToString() + ", 0.000001),"
                          + "SDO_DIM_ELEMENT('Y', " + lowerY.ToString() + ", " + upperY.ToString() + ", 0.000001),"
                          + "SDO_DIM_ELEMENT('Z', " + lowerZ.ToString() + ", " + upperZ.ToString() + ", 0.000001)),"
                          + "NULL)";
                currStep        = sqlStmt;
                cmd.CommandText = sqlStmt;
                cmd.ExecuteNonQuery();

                sqlStmt = "insert into USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) VALUES "
                          + "('BIMRL_ELEMENT_" + DBOperation.currFedModel.FederatedID.ToString("X4") + "','GEOMETRYAXIS',"
                          + "SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', " + lowerX.ToString() + ", " + upperX.ToString() + ", 0.000001),"
                          + "SDO_DIM_ELEMENT('Y', " + lowerY.ToString() + ", " + upperY.ToString() + ", 0.000001),"
                          + "SDO_DIM_ELEMENT('Z', " + lowerZ.ToString() + ", " + upperZ.ToString() + ", 0.000001)),"
                          + "NULL)";
                currStep        = sqlStmt;
                cmd.CommandText = sqlStmt;
                cmd.ExecuteNonQuery();

                sqlStmt = "insert into USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) VALUES "
                          + "('BIMRL_ELEMENT_" + DBOperation.currFedModel.FederatedID.ToString("X4") + "','BODY_MAJOR_AXIS1',"
                          + "SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', -1.01, 1.01, 0.000001),"
                          + "SDO_DIM_ELEMENT('Y', -1.01, 1.01, 0.000001),"
                          + "SDO_DIM_ELEMENT('Z', -1.01, 1.01, 0.000001)),"
                          + "NULL)";
                currStep        = sqlStmt;
                cmd.CommandText = sqlStmt;
                cmd.ExecuteNonQuery();

                sqlStmt = "insert into USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) VALUES "
                          + "('BIMRL_ELEMENT_" + DBOperation.currFedModel.FederatedID.ToString("X4") + "','BODY_MAJOR_AXIS2',"
                          + "SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', -1.01, 1.01, 0.000001),"
                          + "SDO_DIM_ELEMENT('Y', -1.01, 1.01, 0.000001),"
                          + "SDO_DIM_ELEMENT('Z', -1.01, 1.01, 0.000001)),"
                          + "NULL)";
                currStep        = sqlStmt;
                cmd.CommandText = sqlStmt;
                cmd.ExecuteNonQuery();

                sqlStmt = "insert into USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) VALUES "
                          + "('BIMRL_ELEMENT_" + DBOperation.currFedModel.FederatedID.ToString("X4") + "','BODY_MAJOR_AXIS3',"
                          + "SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', -1.01, 1.01, 0.000001),"
                          + "SDO_DIM_ELEMENT('Y', -1.01, 1.01, 0.000001),"
                          + "SDO_DIM_ELEMENT('Z', -1.01, 1.01, 0.000001)),"
                          + "NULL)";
                currStep        = sqlStmt;
                cmd.CommandText = sqlStmt;
                cmd.ExecuteNonQuery();

                sqlStmt = "insert into USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) VALUES "
                          + "('BIMRL_ELEMENT_" + DBOperation.currFedModel.FederatedID.ToString("X4") + "','BODY_MAJOR_AXIS_CENTROID',"
                          + "SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', " + lowerX.ToString() + ", " + upperX.ToString() + ", 0.000001),"
                          + "SDO_DIM_ELEMENT('Y', " + lowerY.ToString() + ", " + upperY.ToString() + ", 0.000001),"
                          + "SDO_DIM_ELEMENT('Z', " + lowerZ.ToString() + ", " + upperZ.ToString() + ", 0.000001)),"
                          + "NULL)";
                currStep        = sqlStmt;
                cmd.CommandText = sqlStmt;
                cmd.ExecuteNonQuery();

                sqlStmt = "insert into USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) VALUES "
                          + "('BIMRL_TOPO_FACE_" + DBOperation.currFedModel.FederatedID.ToString("X4") + "','POLYGON',"
                          + "SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', " + lowerX.ToString() + ", " + upperX.ToString() + ", 0.000001),"
                          + "SDO_DIM_ELEMENT('Y', " + lowerY.ToString() + ", " + upperY.ToString() + ", 0.000001),"
                          + "SDO_DIM_ELEMENT('Z', " + lowerZ.ToString() + ", " + upperZ.ToString() + ", 0.000001)),"
                          + "NULL)";
                currStep        = sqlStmt;
                cmd.CommandText = sqlStmt;
                cmd.ExecuteNonQuery();

                sqlStmt = "insert into USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) VALUES "
                          + "('BIMRL_TOPO_FACE_" + DBOperation.currFedModel.FederatedID.ToString("X4") + "','NORMAL',"
                          + "SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', -1.01, 1.01, 0.000001),"
                          + "SDO_DIM_ELEMENT('Y', -1.01, 1.01, 0.000001),"
                          + "SDO_DIM_ELEMENT('Z', -1.01, 1.01, 0.000001)),"
                          + "NULL)";
                currStep        = sqlStmt;
                cmd.CommandText = sqlStmt;
                cmd.ExecuteNonQuery();

                sqlStmt = "insert into USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) VALUES "
                          + "('BIMRL_TOPO_FACE_" + DBOperation.currFedModel.FederatedID.ToString("X4") + "','CENTROID',"
                          + "SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', " + lowerX.ToString() + ", " + upperX.ToString() + ", 0.000001),"
                          + "SDO_DIM_ELEMENT('Y', " + lowerY.ToString() + ", " + upperY.ToString() + ", 0.000001),"
                          + "SDO_DIM_ELEMENT('Z', " + lowerZ.ToString() + ", " + upperZ.ToString() + ", 0.000001)),"
                          + "NULL)";
                currStep        = sqlStmt;
                cmd.CommandText = sqlStmt;
                cmd.ExecuteNonQuery();


                sqlStmt         = "Update BIMRL_FEDERATEDMODEL SET LastUpdateDate=sysdate WHERE FederatedID=" + DBOperation.currFedModel.FederatedID.ToString();
                currStep        = sqlStmt;
                cmd.CommandText = sqlStmt;
                cmd.ExecuteNonQuery();

                // get the world BBox coordinates and update the BIMRL_FEDERATEDMODEL Table
                SdoGeometry Bbox = new SdoGeometry();
                Bbox.Dimensionality = 3;
                Bbox.LRS            = 0;
                Bbox.GeometryType   = (int)SdoGeometryTypes.GTYPE.POINT;
                int gType = Bbox.PropertiesToGTYPE();

                int[] elemInfoArr = { 1, (int)SdoGeometryTypes.ETYPE_SIMPLE.POLYGON_EXTERIOR, 1 };
                Bbox.ElemArrayOfInts = elemInfoArr;

                double[] coordArr = new double[6];
                coordArr[0] = _bimrlCommon.LLB_X;
                coordArr[1] = _bimrlCommon.LLB_Y;
                coordArr[2] = _bimrlCommon.LLB_Z;
                coordArr[3] = _bimrlCommon.URT_X;
                coordArr[4] = _bimrlCommon.URT_Y;
                coordArr[5] = _bimrlCommon.URT_Z;
                Bbox.OrdinatesArrayOfDoubles = coordArr;

                // Create spatial index from the new model (list of triangles are accummulated during processing of geometries)
                sqlStmt  = "update BIMRL_FEDERATEDMODEL SET WORLDBBOX=:1 , MAXOCTREELEVEL=:2 WHERE FEDERATEDID=" + DBOperation.currFedModel.FederatedID.ToString();
                currStep = sqlStmt;
                OracleCommand command = new OracleCommand(" ", DBOperation.DBConn);
                command.CommandText = sqlStmt;

                OracleParameter[] sdoGeom2 = new OracleParameter[3];
                sdoGeom2[0]             = command.Parameters.Add("1", OracleDbType.Object);
                sdoGeom2[0].Direction   = ParameterDirection.Input;
                sdoGeom2[0].UdtTypeName = "MDSYS.SDO_GEOMETRY";
                sdoGeom2[0].Value       = Bbox;
                sdoGeom2[0].Size        = 1;
                sdoGeom2[1]             = command.Parameters.Add("2", OracleDbType.Int16);
                sdoGeom2[1].Direction   = ParameterDirection.Input;
                sdoGeom2[1].Value       = DBOperation.OctreeSubdivLevel;
                sdoGeom2[1].Size        = 1;

                int commandStatus = command.ExecuteNonQuery();

                if (DBOperation.OnepushETL)
                {
                    DBOperation.commitInterval = 10000;
                    int octreeLevel = DBOperation.computeRecomOctreeLevel(DBOperation.currFedModel.FederatedID);

                    // 1. Create Octree spatial indexes and the Brep Topology Faces
                    spIdx.createSpatialIndexFromBIMRLElement(DBOperation.currFedModel.FederatedID, null, true, true);

                    // 2. Update major Axes and OBB
                    BIMRLUtils.updateMajorAxesAndOBB(DBOperation.currFedModel.FederatedID, null);

                    // 3. Enhance Space Boundary
                    EnhanceBRep eBrep = new EnhanceBRep();
                    eBrep.enhanceSpaceBoundary(null);

                    // 4. Process Face orientations. We will procees the normal face first and then after that the spacial ones (OBB, PROJOBB)
                    string whereCond2 = "";
                    BIMRLCommon.appendToString(" TYPE NOT IN ('OBB','PROJOBB')", " AND ", ref whereCond2);
                    eBrep.ProcessOrientation(whereCond2);
                    whereCond2 = "";
                    BIMRLCommon.appendToString(" TYPE='OBB'", " AND ", ref whereCond2);
                    eBrep.ProcessOrientation(whereCond2);
                    whereCond2 = "";
                    BIMRLCommon.appendToString(" TYPE='PROJOBB'", " AND ", ref whereCond2);
                    eBrep.ProcessOrientation(whereCond2);

                    // 5. Create Graph Data
                    BIMRLGraph.GraphData graphData = new BIMRLGraph.GraphData();
                    graphData.createCirculationGraph(DBOperation.currFedModel.FederatedID);
                    graphData.createSpaceAdjacencyGraph(DBOperation.currFedModel.FederatedID);

                    sqlStmt = "UPDATE BIMRL_FEDERATEDMODEL SET LASTUPDATEDATE=sysdate";
                    BIMRLCommon.appendToString("MAXOCTREELEVEL=" + octreeLevel.ToString(), ", ", ref sqlStmt);
                    BIMRLCommon.appendToString("WHERE FEDERATEDID=" + DBOperation.currFedModel.FederatedID.ToString(), " ", ref sqlStmt);
                    DBOperation.executeSingleStmt(sqlStmt);
                }
                else
                {
                    // Minimum (without One-push ETL, create the bounding boxes (AABB)
                    spIdx.createSpatialIndexFromBIMRLElement(DBOperation.currFedModel.FederatedID, null, false, false);
                }

                var    location = new Uri(Assembly.GetEntryAssembly().GetName().CodeBase);
                string exePath  = new FileInfo(location.AbsolutePath).Directory.FullName;

                // (Re)-Create the spatial indexes
                DBOperation.executeScript(Path.Combine(exePath, "script", "BIMRL_Idx_SpatialIndexes.sql"), DBOperation.currFedModel.FederatedID);
                DBOperation.executeScript(Path.Combine(exePath, "script", "BIMRL_Idx_TopoFace.sql"), DBOperation.currFedModel.FederatedID);
                DBOperation.executeScript(Path.Combine(exePath, "script", "BIMRL_Idx_MajorAxes.sql"), DBOperation.currFedModel.FederatedID);

                //sqlStmt = "Create Index IDX_BIMRLELEM_GEOM_" + currFedID.ToString("X4") + " on BIMRL_ELEMENT_" + currFedID.ToString("X4")
                //            + " (GEOMETRYBODY) INDEXTYPE is MDSYS.SPATIAL_INDEX PARAMETERS ('sdo_indx_dims=3')";
                //currStep = sqlStmt;
                //cmd.CommandText = sqlStmt;
                //cmd.ExecuteNonQuery();

                //sqlStmt = "Create Index IDX_BIMRLELEM_GEOMBB_" + currFedID.ToString("X4") + " on BIMRL_ELEMENT_" + currFedID.ToString("X4")
                //            + " (GeometryBody_BBOX) INDEXTYPE is MDSYS.SPATIAL_INDEX PARAMETERS ('sdo_indx_dims=3')";
                //currStep = sqlStmt;
                //cmd.CommandText = sqlStmt;
                //cmd.ExecuteNonQuery();

                //sqlStmt = "Create Index IDX_BIMRLELEM_GEOMBBC_" + currFedID.ToString("X4") + " on BIMRL_ELEMENT_" + currFedID.ToString("X4")
                //            + " (GeometryBody_BBOX_CENTROID) INDEXTYPE is MDSYS.SPATIAL_INDEX PARAMETERS ('sdo_indx_dims=3')";
                //currStep = sqlStmt;
                //cmd.CommandText = sqlStmt;
                //cmd.ExecuteNonQuery();

                //sqlStmt = "Create Index IDX_BIMRLELEM_GEOMFP_" + currFedID.ToString("X4") + " on BIMRL_ELEMENT_" + currFedID.ToString("X4")
                //            + " (GeometryFootprint) INDEXTYPE is MDSYS.SPATIAL_INDEX PARAMETERS ('sdo_indx_dims=3')";
                //currStep = sqlStmt;
                //cmd.CommandText = sqlStmt;
                //cmd.ExecuteNonQuery();

                //sqlStmt = "Create Index IDX_BIMRLELEM_GEOMAX_" + currFedID.ToString("X4") + " on BIMRL_ELEMENT_" + currFedID.ToString("X4")
                //            + " (GeometryAxis) INDEXTYPE is MDSYS.SPATIAL_INDEX PARAMETERS ('sdo_indx_dims=3')";
                //currStep = sqlStmt;
                //cmd.CommandText = sqlStmt;
                //cmd.ExecuteNonQuery();

                //sqlStmt = "Create Index IDX_BIMRLELEM_GEOMMJ1_" + currFedID.ToString("X4") + " on BIMRL_ELEMENT_" + currFedID.ToString("X4")
                //            + " (BODY_MAJOR_AXIS1) INDEXTYPE is MDSYS.SPATIAL_INDEX PARAMETERS ('sdo_indx_dims=3')";
                //currStep = sqlStmt;
                //cmd.CommandText = sqlStmt;
                //cmd.ExecuteNonQuery();

                //sqlStmt = "Create Index IDX_BIMRLELEM_GEOMMJ2_" + currFedID.ToString("X4") + " on BIMRL_ELEMENT_" + currFedID.ToString("X4")
                //            + " (BODY_MAJOR_AXIS2) INDEXTYPE is MDSYS.SPATIAL_INDEX PARAMETERS ('sdo_indx_dims=3')";
                //currStep = sqlStmt;
                //cmd.CommandText = sqlStmt;
                //cmd.ExecuteNonQuery();

                //sqlStmt = "Create Index IDX_BIMRLELEM_GEOMMJ3_" + currFedID.ToString("X4") + " on BIMRL_ELEMENT_" + currFedID.ToString("X4")
                //            + " (BODY_MAJOR_AXIS3) INDEXTYPE is MDSYS.SPATIAL_INDEX PARAMETERS ('sdo_indx_dims=3')";
                //currStep = sqlStmt;
                //cmd.CommandText = sqlStmt;
                //cmd.ExecuteNonQuery();

                //sqlStmt = "Create Index IDX_BIMRLELEM_GEOMMJC_" + currFedID.ToString("X4") + " on BIMRL_ELEMENT_" + currFedID.ToString("X4")
                //            + " (BODY_MAJOR_AXIS_CENTROID) INDEXTYPE is MDSYS.SPATIAL_INDEX PARAMETERS ('sdo_indx_dims=3')";
                //currStep = sqlStmt;
                //cmd.CommandText = sqlStmt;
                //cmd.ExecuteNonQuery();

                //sqlStmt = "Create Index IDX_TOPOF_POLYGON_" + currFedID.ToString("X4") + " on BIMRL_TOPO_FACE_" + currFedID.ToString("X4")
                //            + " (POLYGON) INDEXTYPE is MDSYS.SPATIAL_INDEX PARAMETERS ('sdo_indx_dims=3')";
                //currStep = sqlStmt;
                //cmd.CommandText = sqlStmt;
                //cmd.ExecuteNonQuery();

                //sqlStmt = "Create Index IDX_TOPOF_NORMAL_" + currFedID.ToString("X4") + " on BIMRL_TOPO_FACE_" + currFedID.ToString("X4")
                //            + " (NORMAL) INDEXTYPE is MDSYS.SPATIAL_INDEX PARAMETERS ('sdo_indx_dims=3')";
                //currStep = sqlStmt;
                //cmd.CommandText = sqlStmt;
                //cmd.ExecuteNonQuery();

                //sqlStmt = "Create Index IDX_TOPOF_CENTROID_" + currFedID.ToString("X4") + " on BIMRL_TOPO_FACE_" + currFedID.ToString("X4")
                //            + " (CENTROID) INDEXTYPE is MDSYS.SPATIAL_INDEX PARAMETERS ('sdo_indx_dims=3')";
                //currStep = sqlStmt;
                //cmd.CommandText = sqlStmt;
                //cmd.ExecuteNonQuery();

                DBOperation.commitTransaction();
            }
            catch (Exception e)
            {
                string excStr = "%%Error - " + e.Message + "\n\t" + currStep;
                _bimrlCommon.StackPushError(excStr);
                if (DBOperation.UIMode)
                {
                    BIMRLErrorDialog errorDlg = new BIMRLErrorDialog(_bimrlCommon);
                    errorDlg.ShowDialog();
                }
                else
                {
                    Console.Write(_bimrlCommon.ErrorMessages);
                }
            }

            // There are entries in the error stack, show them at the end
            if (_bimrlCommon.BIMRLErrorStackCount > 0)
            {
                if (DBOperation.UIMode)
                {
                    BIMRLErrorDialog errorDlg = new BIMRLErrorDialog(_bimrlCommon);
                    errorDlg.ShowDialog();
                }
                else
                {
                    Console.Write(_bimrlCommon.ErrorMessages);
                }
            }
        }
コード例 #13
0
 public BIMRLSpatialStructure(IfcStore m, BIMRLCommon refBIMRLCommon)
 {
     _model          = m;
     _refBIMRLCommon = refBIMRLCommon;
 }
コード例 #14
0
        static void Main(string[] args)
        {
            if (args.Count() == 0 || args[0].Equals("-h"))
            {
                Console.WriteLine("Usage:");
                Console.WriteLine(" - The option below will load both model to BIMRL DB and compare them afterward:");
                Console.WriteLine("      BIMRLDiffModelCmd <DB connect string> -o <report json file> <the IFC file (New)> <the IFC file (Reference)> [<option file>]");
                Console.WriteLine(" - The option below will load the new model to BIMRL DB and compare it with the existing reference:");
                Console.WriteLine("      BIMRLDiffModelCmd <DB connect string> -o <report json file> -r <reference BIMRL model ID> <the IFC file (New)> [<option file>]");
                Console.WriteLine("  Supported file types: *.ifc|*.ifcxml|*.ifczip|*.xbimf");
                return;
            }

            if (!args[1].Equals("-o") && args.Length < 5)
            {
                Console.WriteLine("Usage: BIMRLDiffModelCmd <DB connect string> -o <report json file> <the IFC file(New)> <the IFC file(Reference)>");
                Console.WriteLine("   or: BIMRLDiffModelCmd <DB connect string> -o <report json file> -r <reference BIMRL model ID> <the IFC file (New)>");
                return;
            }

            string dbConnectStr = args[0];

            string[] conn = dbConnectStr.Split(new char[] { '/', '@' });
            if (conn.Count() < 3)
            {
                Console.WriteLine("%Error: Connection string is not in the right format. Use: <username>/<password>@<db>. For example: bimrl/bimrlpwd@pdborcl");
                return;
            }
            try
            {
                DBOperation.ConnectToDB(conn[0], conn[1], conn[2]);
            }
            catch
            {
                Console.WriteLine("%Error: Connection to DB Error");
                return;
            }

            string      newModelFile       = "";
            string      outputFileName     = args[2];
            string      outputFileFullPath = Path.GetFullPath(outputFileName);
            int         refModelID         = -1;
            int         newModelID         = -1;
            BIMRLCommon bimrlCommon        = new BIMRLCommon();

            DBOperation.UIMode = false;
            string optionFile = "";

            if (args[3].Equals("-r"))
            {
                if (!int.TryParse(args[4], out refModelID))
                {
                    Console.WriteLine("%Error: Referenced Model ID must be an integer number: " + args[4]);
                    return;
                }
                if (args.Count() < 6)
                {
                    Console.WriteLine("%Error: Missing IFC file name (New)!");
                    return;
                }

                // Check ID is a valid model ID in the DB
                BIMRLQueryModel bQM       = new BIMRLQueryModel(bimrlCommon);
                DataTable       modelInfo = bQM.checkModelExists(refModelID);
                if (modelInfo.Rows.Count == 0)
                {
                    Console.WriteLine("%Error: Referenced Model ID " + refModelID.ToString() + " does not exist in the DB, load it first!");
                    return;
                }

                newModelFile = args[5];
                if (!File.Exists(newModelFile))
                {
                    Console.WriteLine("%Error: New Model file is not found!");
                    return;
                }

                if (args.Count() >= 7)
                {
                    optionFile = args[6];
                }
            }
            else
            {
                string refModelFile = args[4];
                if (!File.Exists(refModelFile))
                {
                    Console.WriteLine("%Error: Referenced Model file is not found!");
                    return;
                }
                newModelFile = args[3];
                if (!File.Exists(newModelFile))
                {
                    Console.WriteLine("%Error: New Model file is not found!");
                    return;
                }

                // Load the referenced Model
                IfcStore refModel = LoadModel.OpenModel(refModelFile);
                if (refModel != null)
                {
                    refModelID = LoadModel.LoadModelToBIMRL(refModel);
                }

                if (refModel == null || refModelID == -1)
                {
                    Console.WriteLine("%Error: Load referenced Model " + refModelFile + " failed!");
                    return;
                }

                if (args.Count() >= 6)
                {
                    optionFile = args[5];
                }
            }

            // Load the new model
            IfcStore newModel = LoadModel.OpenModel(newModelFile);

            if (newModel != null)
            {
                newModelID = LoadModel.LoadModelToBIMRL(newModel);
            }

            if (newModel == null || newModelID == -1)
            {
                Console.WriteLine("%Error: Load referenced Model " + newModelFile + " failed!");
                return;
            }

            // Compare
            BIMRLDiffOptions options = new BIMRLDiffOptions();

            if (File.Exists(optionFile))
            {
                options = JsonConvert.DeserializeObject <BIMRLDiffOptions>(File.ReadAllText(optionFile));
                if (options == null)
                {
                    options = BIMRLDiffOptions.SelectAllOptions();
                }
            }
            else
            {
                options = BIMRLDiffOptions.SelectAllOptions();
            }

            // For the purpose of Model Diff, no enhanced BIMRL data processing is needed. This saves time and space.
            //   If the model requires the enhanced data, it can be done either load the model beforehand, or run the enhancement using BIMRL_ETLMain.XplorerPlugin UI
            DBOperation.OnepushETL = false;

            BIMRLDiffModels diffModels = new BIMRLDiffModels(newModelID, refModelID, bimrlCommon);

            diffModels.RunDiff(outputFileFullPath, options: options);
        }
コード例 #15
0
        private void Button_RegenGeometry_Click(object sender, RoutedEventArgs e)
        {
            BIMRLSpatialIndex spIdx = new BIMRLSpatialIndex(BIMRLCommonRef);

            DBOperation.commitInterval = 5000;
            double currentTol = MathUtils.tol;
            var    location   = new Uri(Assembly.GetEntryAssembly().GetName().CodeBase);
            string exePath    = new FileInfo(location.AbsolutePath).Directory.FullName;

            // Temporarily change the tolerance if it is set in the UI
            if (!string.IsNullOrEmpty(TextBox_Tolerance.Text))
            {
                double tolSetting;
                if (double.TryParse(TextBox_Tolerance.Text, out tolSetting))
                {
                    MathUtils.tol = tolSetting;
                }
            }

            if (!string.IsNullOrEmpty(TextBox_OctreeLevel.Text))
            {
                int level = -1;
                level = int.Parse(TextBox_OctreeLevel.Text);
                if (level > 0)
                {
                    DBOperation.OctreeSubdivLevel = level;
                }
            }

            int FedID = -1;
            FederatedModelInfo selFedModelsItem = DataGrid_FedModels.SelectedItem as FederatedModelInfo;

            if (selFedModelsItem == null)
            {
                return;     // do nothing, no selection made
            }
            else
            {
                FederatedModelInfo selFedModel = selFedModelsItem;
                FedID = selFedModel.FederatedID;
            }

            try
            {
                if (FedID >= 0)
                {
                    string whereCond      = null;
                    string updOctreeLevel = "";
                    if (!string.IsNullOrEmpty(TextBox_Additional_Condition.Text))
                    {
                        whereCond = TextBox_Additional_Condition.Text;
                        // Spatial always needs to be reconstructed even when one object is updated to maintain integrity of non-overlapping octree concept
                        if (regenSpatialIndex)
                        {
                            // We need the existing data to regenerate the dictionary. Truncate operation will be deferred until just before insert into the table
                            // DBOperation.executeSingleStmt("TRUNCATE TABLE BIMRL_SPATIALINDEX_" + FedID.ToString("X4"));
                            // DBOperation.executeSingleStmt("DELETE FROM BIMRL_SPATIALINDEX_" + FedID.ToString("X4") + " WHERE " + whereCond);
                        }
                        if (regenBoundaryFaces)
                        {
                            DBOperation.executeSingleStmt("DELETE FROM " + DBOperation.formatTabName("BIMRL_TOPO_FACE", FedID) + " WHERE " + whereCond);
                        }
                    }
                    else
                    {
                        FederatedModelInfo fedModel = DBOperation.getFederatedModelByID(FedID);
                        if (DBOperation.DBUserID.Equals(fedModel.Owner))
                        {
                            if (regenSpatialIndex)
                            {
                                DBOperation.executeSingleStmt("TRUNCATE TABLE " + DBOperation.formatTabName("BIMRL_SPATIALINDEX", FedID));
                            }
                            if (regenBoundaryFaces)
                            {
                                DBOperation.executeSingleStmt("TRUNCATE TABLE " + DBOperation.formatTabName("BIMRL_TOPO_FACE", FedID));
                            }
                        }
                        else
                        {
                            if (regenSpatialIndex)
                            {
                                DBOperation.executeSingleStmt("DELETE FROM " + DBOperation.formatTabName("BIMRL_SPATIALINDEX", FedID));
                            }
                            if (regenBoundaryFaces)
                            {
                                DBOperation.executeSingleStmt("DELETE FROM " + DBOperation.formatTabName("BIMRL_TOPO_FACE", FedID));
                            }
                        }
                    }

                    // Update Spatial index (including major axes and OBB) and Boundary faces
                    if (regenSpatialIndex && regenBoundaryFaces && _majorAxes)
                    {
                        spIdx.createSpatialIndexFromBIMRLElement(FedID, whereCond, true);
                        BIMRLUtils.updateMajorAxesAndOBB(FedID, whereCond);
                        DBOperation.executeScript(Path.Combine(exePath, "script", "BIMRL_Idx_SpatialIndexes.sql"), FedID);
                        DBOperation.executeScript(Path.Combine(exePath, "script", "BIMRL_Idx_TopoFace.sql"), FedID);
                        DBOperation.executeScript(Path.Combine(exePath, "script", "BIMRL_Idx_MajorAxes.sql"), FedID);
                        updOctreeLevel = "MAXOCTREELEVEL=" + DBOperation.OctreeSubdivLevel;
                    }
                    else if (regenSpatialIndex && regenBoundaryFaces && !_majorAxes)
                    {
                        spIdx.createSpatialIndexFromBIMRLElement(FedID, whereCond, true);
                        DBOperation.executeScript(Path.Combine(exePath, "script", "BIMRL_Idx_SpatialIndexes.sql"), FedID);
                        DBOperation.executeScript(Path.Combine(exePath, "script", "BIMRL_Idx_TopoFace.sql"), FedID);
                        updOctreeLevel = "MAXOCTREELEVEL=" + DBOperation.OctreeSubdivLevel;
                    }
                    // Update Spatial index (including major axes and OBB) only
                    else if (regenSpatialIndex && !regenBoundaryFaces && _majorAxes)
                    {
                        spIdx.createSpatialIndexFromBIMRLElement(FedID, whereCond, false);
                        BIMRLUtils.updateMajorAxesAndOBB(FedID, whereCond);
                        DBOperation.executeScript(Path.Combine(exePath, "script", "BIMRL_Idx_SpatialIndexes.sql"), FedID);
                        DBOperation.executeScript(Path.Combine(exePath, "script", "BIMRL_Idx_MajorAxes.sql"), FedID);
                        updOctreeLevel = "MAXOCTREELEVEL=" + DBOperation.OctreeSubdivLevel;
                    }
                    // Update Boundary faces and MajorAxes
                    else if (!regenSpatialIndex && regenBoundaryFaces && _majorAxes)
                    {
                        spIdx.createFacesFromBIMRLElement(FedID, whereCond);
                        DBOperation.executeScript(Path.Combine(exePath, "script", "BIMRL_Idx_TopoFace.sql"), FedID);
                        BIMRLUtils.updateMajorAxesAndOBB(FedID, whereCond);
                        DBOperation.executeScript(Path.Combine(exePath, "script", "BIMRL_Idx_MajorAxes.sql"), FedID);
                    }
                    // Update Spatial Index only
                    else if (regenSpatialIndex && !regenBoundaryFaces && !_majorAxes)
                    {
                        spIdx.createSpatialIndexFromBIMRLElement(FedID, whereCond, false);
                        DBOperation.executeScript(Path.Combine(exePath, "script", "BIMRL_Idx_SpatialIndexes.sql"), FedID);
                        updOctreeLevel = "MAXOCTREELEVEL=" + DBOperation.OctreeSubdivLevel;
                    }
                    // update faces only
                    else if (!regenSpatialIndex && regenBoundaryFaces && !_majorAxes)
                    {
                        spIdx.createFacesFromBIMRLElement(FedID, whereCond);
                        DBOperation.executeScript(Path.Combine(exePath, "script", "BIMRL_Idx_TopoFace.sql"), FedID);
                    }
                    // Update only the major axes and OBB only
                    else if (!regenSpatialIndex && !regenBoundaryFaces && _majorAxes)
                    {
                        BIMRLUtils.updateMajorAxesAndOBB(FedID, whereCond);
                        DBOperation.executeScript(Path.Combine(exePath, "script", "BIMRL_Idx_MajorAxes.sql"), FedID);
                    }
                    else
                    {
                        // Invalid option
                    }

                    string sqlStmt = "UPDATE BIMRL_FEDERATEDMODEL SET LASTUPDATEDATE=sysdate";
                    BIMRLCommon.appendToString(updOctreeLevel, ", ", ref sqlStmt);
                    BIMRLCommon.appendToString("WHERE FEDERATEDID=" + FedID, " ", ref sqlStmt);
                    DBOperation.executeSingleStmt(sqlStmt);
                }
            }
            catch (SystemException excp)
            {
                string excStr = "%% Error - " + excp.Message + "\n\t";
                BIMRLCommonRef.StackPushError(excStr);
                if (BIMRLCommonRef.BIMRLErrorStackCount > 0)
                {
                    showError(null);
                }
            }
            MathUtils.tol = currentTol;
        }
コード例 #16
0
 public BIMRLDiffModels(BIMRLCommon bimrlCommon)
 {
     compNewModel     = null;
     compRefModel     = null;
     m_BIMRLCommonRef = bimrlCommon;
 }
コード例 #17
0
ファイル: BIMRLUtils.cs プロジェクト: jdimyadi/BIMRL-DBETL
        public static void UpdateElementTransform(IfcStore _model, string projectNumber, string projectName)
        {
            DBOperation.beginTransaction();
            DBOperation.commitInterval = 5000;
            string      currStep        = string.Empty;
            BIMRLCommon _refBIMRLCommon = new BIMRLCommon();

            int commandStatus   = -1;
            int currInsertCount = 0;

            OracleCommand command = new OracleCommand(" ", DBOperation.DBConn);
            XbimMatrix3D  m3D     = new XbimMatrix3D();

            if (string.IsNullOrEmpty(projectName))
            {
                projectName = projectNumber + " - Federated";
            }

            string modelName;

            if (!string.IsNullOrEmpty(_model.FileName))
            {
                modelName = Path.GetFileNameWithoutExtension(_model.FileName);
            }
            else
            {
                modelName = projectNumber + " - " + projectName;
            }

            command.CommandText = "SELECT FEDERATEDID FROM bimrl_federatedmodel WHERE MODELNAME = '" + modelName + "' AND PROJECTNUMBER='" + projectNumber + "' AND PROJECTNAME='" + projectName + "'";
            object oFedID = command.ExecuteScalar();

            if (oFedID == null)
            {
                return;
            }

            int fedID = int.Parse(oFedID.ToString());

            command.CommandText = "SELECT ELEMENTID, LINENO FROM " + DBOperation.formatTabName("bimrl_element", fedID) + " WHERE GEOMETRYBODY IS NOT NULL";
            OracleDataReader reader = command.ExecuteReader();
            SortedDictionary <int, string> elemList = new SortedDictionary <int, string>();

            while (reader.Read())
            {
                string elemid = reader.GetString(0);
                int    lineNo = reader.GetInt32(1);
                elemList.Add(lineNo, elemid);
            }
            reader.Close();

            Xbim3DModelContext context = new Xbim3DModelContext(_model);

            foreach (KeyValuePair <int, string> elemListItem in elemList)
            {
                //IEnumerable<XbimGeometryData> geomDataList = _model.GetGeometryData(elemListItem.Key, XbimGeometryType.TriangulatedMesh);
                IIfcProduct product = _model.Instances[elemListItem.Key] as IIfcProduct;

                IEnumerable <XbimShapeInstance> shapeInstances = context.ShapeInstancesOf(product).Where(x => x.RepresentationType == XbimGeometryRepresentationType.OpeningsAndAdditionsIncluded);
                if (shapeInstances.Count() == 0)
                {
                    continue;    // SKip if the product has no geometry
                }
                XbimMeshGeometry3D     prodGeom  = new XbimMeshGeometry3D();
                IXbimShapeGeometryData shapeGeom = context.ShapeGeometry(shapeInstances.FirstOrDefault().ShapeGeometryLabel);
                //XbimModelExtensions.Read(prodGeom, shapeGeom.ShapeData, shapeInstances.FirstOrDefault().Transformation);

                //XbimGeometryData sdoGeomData = geomDataList.First();
                //m3D = sdoGeomData.Transform;
                //m3D = XbimMatrix3D.FromArray(sdoGeomData.DataArray2);       // Xbim 3.0 removes Tranform property
                m3D = shapeInstances.FirstOrDefault().Transformation;
                string sqlStmt = "update " + DBOperation.formatTabName("BIMRL_ELEMENT", fedID) + " set TRANSFORM_COL1=:1, TRANSFORM_COL2=:2, TRANSFORM_COL3=:3, TRANSFORM_COL4=:4"
                                 + " Where elementid = '" + elemListItem.Value + "'";
                // int status = DBOperation.updateGeometry(sqlStmt, sdoGeomData);
                currStep            = sqlStmt;
                command.CommandText = sqlStmt;

                try
                {
                    OracleParameter[] sdoGeom = new OracleParameter[4];
                    for (int i = 0; i < sdoGeom.Count(); ++i)
                    {
                        sdoGeom[i]             = command.Parameters.Add((i + 1).ToString(), OracleDbType.Object);
                        sdoGeom[i].Direction   = ParameterDirection.Input;
                        sdoGeom[i].UdtTypeName = "MDSYS.SDO_GEOMETRY";
                        sdoGeom[i].Size        = 1;
                    }

                    SdoGeometry trcol1 = new SdoGeometry();
                    trcol1.Dimensionality = 3;
                    trcol1.LRS            = 0;
                    trcol1.GeometryType   = (int)SdoGeometryTypes.GTYPE.POINT;
                    int      gType   = trcol1.PropertiesToGTYPE();
                    SdoPoint trcol1V = new SdoPoint();
                    trcol1V.XD       = m3D.M11;
                    trcol1V.YD       = m3D.M12;
                    trcol1V.ZD       = m3D.M13;
                    trcol1.SdoPoint  = trcol1V;
                    sdoGeom[1].Value = trcol1;

                    SdoGeometry trcol2 = new SdoGeometry();
                    trcol2.Dimensionality = 3;
                    trcol2.LRS            = 0;
                    trcol2.GeometryType   = (int)SdoGeometryTypes.GTYPE.POINT;
                    gType = trcol2.PropertiesToGTYPE();
                    SdoPoint trcol2V = new SdoPoint();
                    trcol2V.XD       = m3D.M21;
                    trcol2V.YD       = m3D.M22;
                    trcol2V.ZD       = m3D.M23;
                    trcol2.SdoPoint  = trcol2V;
                    sdoGeom[2].Value = trcol2;

                    SdoGeometry trcol3 = new SdoGeometry();
                    trcol3.Dimensionality = 3;
                    trcol3.LRS            = 0;
                    trcol3.GeometryType   = (int)SdoGeometryTypes.GTYPE.POINT;
                    gType = trcol3.PropertiesToGTYPE();
                    SdoPoint trcol3V = new SdoPoint();
                    trcol3V.XD       = m3D.M31;
                    trcol3V.YD       = m3D.M32;
                    trcol3V.ZD       = m3D.M33;
                    trcol3.SdoPoint  = trcol3V;
                    sdoGeom[3].Value = trcol3;

                    SdoGeometry trcol4 = new SdoGeometry();
                    trcol4.Dimensionality = 3;
                    trcol4.LRS            = 0;
                    trcol4.GeometryType   = (int)SdoGeometryTypes.GTYPE.POINT;
                    gType = trcol4.PropertiesToGTYPE();
                    SdoPoint trcol4V = new SdoPoint();
                    trcol4V.XD       = m3D.OffsetX;
                    trcol4V.YD       = m3D.OffsetY;
                    trcol4V.ZD       = m3D.OffsetZ;
                    trcol4.SdoPoint  = trcol4V;
                    sdoGeom[4].Value = trcol4;

                    commandStatus = command.ExecuteNonQuery();
                    command.Parameters.Clear();

                    currInsertCount++;

                    if (currInsertCount % DBOperation.commitInterval == 0)
                    {
                        //Do commit at interval but keep the long transaction (reopen)
                        DBOperation.commitTransaction();
                    }
                }
                catch (OracleException e)
                {
                    string excStr = "%%Error - " + e.Message + "\n\t" + currStep;
                    _refBIMRLCommon.StackPushError(excStr);
                    //command.Dispose();   // Log Oracle error and continue
                    command = new OracleCommand(" ", DBOperation.DBConn);
                    // throw;
                }
                catch (SystemException e)
                {
                    string excStr = "%%Insert Error - " + e.Message + "\n\t" + currStep;
                    _refBIMRLCommon.StackPushError(excStr);
                    throw;
                }

                DBOperation.commitTransaction();
                command.Dispose();
            }
        }
コード例 #18
0
 public BIMRLQueryModel(BIMRLCommon refBIMRLCommon)
 {
     _refBIMRLCommon = refBIMRLCommon;
 }
コード例 #19
0
 public Error_Dialog(BIMRLCommon bimrlCommonRef)
 {
     InitializeComponent();
     _refBIMRLCommon = bimrlCommonRef;
 }
コード例 #20
0
ファイル: BIMRLUtils.cs プロジェクト: jdimyadi/BIMRL-DBETL
        static bool getDerivedUnitRepStr(IIfcUnit unitDef, out IfcDerivedUnitEnum unitType, out string unitRepStr)
        {
            // Initialize the static Dicts, if it is still empty upon the first use. These Dicts do not need to be reset
            setupUnitRep();

            unitType = IfcDerivedUnitEnum.USERDEFINED;   // initial value
            IIfcDerivedUnit derivedUnit = unitDef as IIfcDerivedUnit;

            unitType = derivedUnit.UnitType;

            unitRepStr = string.Empty;
            IList <string> positiveExpUnits = new List <string>();
            IList <string> negativeExpUnits = new List <string>();

            foreach (IIfcDerivedUnitElement dUnitElem in derivedUnit.Elements)
            {
                IfcUnitEnum elemUnitType;
                string      elemUnitRepStr = string.Empty;
                int         exponent       = (int)dUnitElem.Exponent;
                if (getNamedUnitRepStr(dUnitElem.Unit, out elemUnitType, out elemUnitRepStr))
                {
                    if (exponent >= 0)
                    {
                        if (exponent > 1)
                        {
                            elemUnitRepStr = elemUnitRepStr + "^" + exponent.ToString();
                        }
                        //elemUnitRepStr = elemUnitRepStr + unicodeSuperScript(exponent);
                        positiveExpUnits.Add(elemUnitRepStr);
                    }
                    else
                    {
                        if (exponent < -1)
                        {
                            elemUnitRepStr = elemUnitRepStr + "^" + Math.Abs(exponent).ToString();
                        }
                        //elemUnitRepStr = elemUnitRepStr + unicodeSuperScript(Math.Abs(exponent));
                        negativeExpUnits.Add(elemUnitRepStr);
                    }
                }
            }

            if (positiveExpUnits.Count > 0)
            {
                foreach (string elemUnit in positiveExpUnits)
                {
                    BIMRLCommon.appendToString(elemUnit, ".", ref unitRepStr);
                    //BAIFCCommon.appendToString(elemUnit, "\u22C5", ref negUnitRepStr);
                }
            }
            else
            {
                if (negativeExpUnits.Count > 0)
                {
                    unitRepStr = "1";
                }
            }

            string negUnitRepStr = string.Empty;

            if (negativeExpUnits.Count > 0)
            {
                foreach (string elemUnit in negativeExpUnits)
                {
                    BIMRLCommon.appendToString(elemUnit, "·", ref negUnitRepStr);
                    //BAIFCCommon.appendToString(elemUnit, "\u22C5", ref negUnitRepStr);
                }
            }
            if (!string.IsNullOrEmpty(negUnitRepStr))
            {
                unitRepStr += "/" + negUnitRepStr;
            }

            if (!string.IsNullOrEmpty(unitRepStr))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #21
0
 public BIMRLMaterial(IfcStore m, BIMRLCommon refBIMRLCommon)
 {
     _model          = m;
     _refBIMRLCommon = refBIMRLCommon;
 }
コード例 #22
0
        public void processMaterials()
        {
            List <string> insTGuid    = new List <string>();
            List <string> insTMatName = new List <string>();
            List <string> insTSetName = new List <string>();
            List <OracleParameterStatus> insTSetNPS = new List <OracleParameterStatus>();
            List <int> insTMatSeq = new List <int>();
            List <OracleParameterStatus> insTMatSPS = new List <OracleParameterStatus>();
            List <double> insTMatThick = new List <double>();
            List <OracleParameterStatus> insTMatTPS = new List <OracleParameterStatus>();
            List <string> insTIsVentilated          = new List <string>();
            List <OracleParameterStatus> insTIsVPS  = new List <OracleParameterStatus>();

            List <string> insGuid    = new List <string>();
            List <string> insMatName = new List <string>();
            List <string> insSetName = new List <string>();
            List <OracleParameterStatus> insSetNPS = new List <OracleParameterStatus>();
            List <int> insMatSeq = new List <int>();
            List <OracleParameterStatus> insMatSPS = new List <OracleParameterStatus>();
            List <double> insMatThick = new List <double>();
            List <OracleParameterStatus> insMatTPS = new List <OracleParameterStatus>();
            List <string> insIsVentilated          = new List <string>();
            List <OracleParameterStatus> insIsVPS  = new List <OracleParameterStatus>();

            string currStep = "Processing Materials";

            DBOperation.beginTransaction();

            OracleCommand command  = new OracleCommand(" ", DBOperation.DBConn);
            OracleCommand command2 = new OracleCommand(" ", DBOperation.DBConn);

            // 2 columsn are not used: Category, ForProfile is only used in IFC4
            string sqlStmt = "insert into " + DBOperation.formatTabName("BIMRL_TYPEMATERIAL") + " (ElementID, MaterialName, SetName, IsVentilated, MaterialSequence, MaterialThickness) "
                             + " values (:1, :2, :3, :4, :5, :6)";

            command.CommandText = sqlStmt;
            OracleParameter[] Param = new OracleParameter[6];
            for (int i = 0; i < 4; i++)
            {
                Param[i]           = command.Parameters.Add(i.ToString(), OracleDbType.Varchar2);
                Param[i].Direction = ParameterDirection.Input;
            }
            Param[4]           = command.Parameters.Add("3", OracleDbType.Int16);
            Param[4].Direction = ParameterDirection.Input;
            Param[5]           = command.Parameters.Add("4", OracleDbType.Double);
            Param[5].Direction = ParameterDirection.Input;

            string sqlStmt2 = "insert into " + DBOperation.formatTabName("BIMRL_ELEMENTMATERIAL") + " (ElementID, MaterialName, SetName, IsVentilated, MaterialSequence, MaterialThickness) "
                              + " values (:1, :2, :3, :4, :5, :6)";

            command2.CommandText = sqlStmt2;
            OracleParameter[] Param2 = new OracleParameter[6];
            for (int i = 0; i < 4; i++)
            {
                Param2[i]           = command2.Parameters.Add(i.ToString(), OracleDbType.Varchar2);
                Param2[i].Direction = ParameterDirection.Input;
            }
            Param2[4]           = command2.Parameters.Add("3", OracleDbType.Int16);
            Param2[4].Direction = ParameterDirection.Input;
            Param2[5]           = command2.Parameters.Add("4", OracleDbType.Double);
            Param2[5].Direction = ParameterDirection.Input;

            IEnumerable <IIfcRelAssociatesMaterial> relMaterials = _model.Instances.OfType <IIfcRelAssociatesMaterial>();

            foreach (IIfcRelAssociatesMaterial relMat in relMaterials)
            {
                // reset Relating material data at the start
                List <string> arrMatName = new List <string>();
                List <string> arrSetName = new List <string>();
                List <OracleParameterStatus> arrSetNPS = new List <OracleParameterStatus>();
                List <int> arrMatSeq = new List <int>();
                List <OracleParameterStatus> arrMatSPS = new List <OracleParameterStatus>();
                List <double> arrMatThick = new List <double>();
                List <OracleParameterStatus> arrMatTPS = new List <OracleParameterStatus>();
                List <string> arrIsVentilated          = new List <string>();
                List <OracleParameterStatus> arrIsVPS  = new List <OracleParameterStatus>();

                // Handle various IfcMaterialSelect
                if (relMat.RelatingMaterial is IIfcMaterial)
                {
                    IIfcMaterial m = relMat.RelatingMaterial as IIfcMaterial;
                    arrMatName.Add(m.Name);
                    arrSetName.Add(string.Empty);
                    arrSetNPS.Add(OracleParameterStatus.NullInsert);
                    arrMatSeq.Add(0);
                    arrMatSPS.Add(OracleParameterStatus.NullInsert);
                    arrMatThick.Add(0.0);
                    arrMatTPS.Add(OracleParameterStatus.NullInsert);
                    arrIsVentilated.Add(string.Empty);
                    arrIsVPS.Add(OracleParameterStatus.NullInsert);
                }
                else if (relMat.RelatingMaterial is IIfcMaterialConstituent)
                {
                    IIfcMaterialConstituent m = relMat.RelatingMaterial as IIfcMaterialConstituent;
                    arrMatName.Add(m.Material.Name);
                    arrSetName.Add(string.Empty);
                    arrSetNPS.Add(OracleParameterStatus.NullInsert);
                    arrMatSeq.Add(0);
                    arrMatSPS.Add(OracleParameterStatus.NullInsert);
                    arrMatThick.Add(0.0);
                    arrMatTPS.Add(OracleParameterStatus.NullInsert);
                    arrIsVentilated.Add(string.Empty);
                    arrIsVPS.Add(OracleParameterStatus.NullInsert);
                }
                else if (relMat.RelatingMaterial is IIfcMaterialList)
                {
                    IIfcMaterialList mList = relMat.RelatingMaterial as IIfcMaterialList;
                    foreach (IIfcMaterial m in mList.Materials)
                    {
                        arrMatName.Add(m.Name);
                        arrSetName.Add(string.Empty);
                        arrSetNPS.Add(OracleParameterStatus.NullInsert);
                        arrMatSeq.Add(0);
                        arrMatSPS.Add(OracleParameterStatus.NullInsert);
                        arrMatThick.Add(0.0);
                        arrMatTPS.Add(OracleParameterStatus.NullInsert);
                        arrIsVentilated.Add(string.Empty);
                        arrIsVPS.Add(OracleParameterStatus.NullInsert);
                    }
                }
                else if (relMat.RelatingMaterial is IIfcMaterialConstituentSet)
                {
                    IIfcMaterialConstituentSet mConstSet = relMat.RelatingMaterial as IIfcMaterialConstituentSet;
                    foreach (IIfcMaterialConstituent mConst in mConstSet.MaterialConstituents)
                    {
                        arrMatName.Add(mConst.Material.Name);
                        arrSetName.Add(mConstSet.Name);
                        arrSetNPS.Add(OracleParameterStatus.Success);
                        arrMatSeq.Add(0);
                        arrMatSPS.Add(OracleParameterStatus.NullInsert);
                        arrMatThick.Add(0.0);
                        arrMatTPS.Add(OracleParameterStatus.NullInsert);
                        arrIsVentilated.Add(string.Empty);
                        arrIsVPS.Add(OracleParameterStatus.NullInsert);
                    }
                }
                else if (relMat.RelatingMaterial is IIfcMaterialLayer)
                {
                    IIfcMaterialLayer mLayer = relMat.RelatingMaterial as IIfcMaterialLayer;
                    if (mLayer.Material != null)
                    {
                        arrMatName.Add(mLayer.Material.Name);
                    }
                    else
                    {
                        arrMatName.Add("-");
                    }
                    arrSetName.Add(string.Empty);
                    arrSetNPS.Add(OracleParameterStatus.NullInsert);
                    arrMatSeq.Add(0);
                    arrMatSPS.Add(OracleParameterStatus.NullInsert);
                    arrMatThick.Add((double)mLayer.LayerThickness.Value);
                    arrMatTPS.Add(OracleParameterStatus.Success);
                    if (mLayer.IsVentilated != null)
                    {
                        arrIsVentilated.Add("TRUE");
                        arrIsVPS.Add(OracleParameterStatus.Success);
                    }
                    else
                    {
                        arrIsVentilated.Add(string.Empty);
                        arrIsVPS.Add(OracleParameterStatus.NullInsert);
                    }
                }
                else if (relMat.RelatingMaterial is IIfcMaterialLayerSet || relMat.RelatingMaterial is IIfcMaterialLayerSetUsage)
                {
                    IIfcMaterialLayerSet mLayerSet;
                    if (relMat.RelatingMaterial is IIfcMaterialLayerSetUsage)
                    {
                        // We do not handle LayerSetDirection, DirectionSense, OffserFromReference as they are mainly important for drawing construction
                        IIfcMaterialLayerSetUsage mLSU = relMat.RelatingMaterial as IIfcMaterialLayerSetUsage;
                        mLayerSet = mLSU.ForLayerSet;
                    }
                    else
                    {
                        mLayerSet = relMat.RelatingMaterial as IIfcMaterialLayerSet;
                    }

                    Int16 seqNo = 1;
                    foreach (IIfcMaterialLayer mLayer in mLayerSet.MaterialLayers)
                    {
                        if (mLayerSet.LayerSetName != null)
                        {
                            arrSetName.Add(mLayerSet.LayerSetName);
                            arrSetNPS.Add(OracleParameterStatus.Success);
                        }
                        else
                        {
                            arrSetName.Add(string.Empty);
                            arrSetNPS.Add(OracleParameterStatus.NullInsert);
                        }

                        if (mLayer.Material != null)
                        {
                            arrMatName.Add(mLayer.Material.Name);
                        }
                        else
                        {
                            arrMatName.Add("-");
                        }
                        arrMatSeq.Add(seqNo++);
                        arrMatSPS.Add(OracleParameterStatus.NullInsert);
                        arrMatThick.Add((double)mLayer.LayerThickness.Value);
                        arrMatTPS.Add(OracleParameterStatus.Success);
                        if (mLayer.IsVentilated != null)
                        {
                            arrIsVentilated.Add("TRUE");
                            arrIsVPS.Add(OracleParameterStatus.Success);
                        }
                        else
                        {
                            arrIsVentilated.Add(string.Empty);
                            arrIsVPS.Add(OracleParameterStatus.NullInsert);
                        }
                    }
                }
                else if (relMat.RelatingMaterial is IIfcMaterialProfile)
                {
                    IIfcMaterialProfile mProfile = relMat.RelatingMaterial as IIfcMaterialProfile;
                    string profileName           = "-";
                    string material;
                    if (mProfile.Material != null)
                    {
                        material = "(" + mProfile.Material.Name + ", ";
                    }
                    else
                    {
                        material = "(-, ";
                    }
                    if (mProfile.Profile.ProfileName.HasValue)
                    {
                        profileName = mProfile.Profile.ProfileName.ToString();
                    }

                    material += profileName + ")";
                    arrMatName.Add(material);

                    arrSetName.Add(string.Empty);
                    arrSetNPS.Add(OracleParameterStatus.NullInsert);
                    arrMatSeq.Add(0);
                    arrMatSPS.Add(OracleParameterStatus.NullInsert);
                    arrMatThick.Add(0);
                    arrMatTPS.Add(OracleParameterStatus.NullInsert);
                    arrIsVentilated.Add(string.Empty);
                    arrIsVPS.Add(OracleParameterStatus.NullInsert);
                }
                else if (relMat.RelatingMaterial is IIfcMaterialProfileSet ||
                         relMat.RelatingMaterial is IIfcMaterialProfileSetUsage ||
                         relMat.RelatingMaterial is IIfcMaterialProfileSetUsageTapering)
                {
                    IIfcMaterialProfileSet mProfileSet;
                    IIfcMaterialProfileSet mProfileSetEnd = null;
                    if (relMat.RelatingMaterial is IIfcMaterialProfileSetUsage)
                    {
                        // We do not handle other information, except the material name and the profile name
                        IIfcMaterialProfileSetUsage mPSU = relMat.RelatingMaterial as IIfcMaterialProfileSetUsage;
                        mProfileSet = mPSU.ForProfileSet;

                        if (relMat.RelatingMaterial is IIfcMaterialProfileSetUsageTapering)
                        {
                            mProfileSetEnd = (relMat.RelatingMaterial as IIfcMaterialProfileSetUsageTapering).ForProfileEndSet;
                        }
                    }
                    else
                    {
                        mProfileSet = relMat.RelatingMaterial as IIfcMaterialProfileSet;
                    }

                    string material = getMaterialProfileSetString(mProfileSet);
                    if (mProfileSetEnd != null)
                    {
                        BIMRLCommon.appendToString(getMaterialProfileSetString(mProfileSetEnd), " | ", ref material);
                    }

                    Int16 seqNo = 1;
                    foreach (IIfcMaterialProfile mProf in mProfileSet.MaterialProfiles)
                    {
                        if (mProfileSet.Name != null)
                        {
                            arrSetName.Add(mProfileSet.Name);
                            arrSetNPS.Add(OracleParameterStatus.Success);
                        }
                        else
                        {
                            arrSetName.Add(string.Empty);
                            arrSetNPS.Add(OracleParameterStatus.NullInsert);
                        }

                        arrMatName.Add(material);

                        arrMatSeq.Add(seqNo++);
                        arrMatSPS.Add(OracleParameterStatus.Success);
                        arrMatThick.Add(0);
                        arrMatTPS.Add(OracleParameterStatus.Success);
                        arrIsVentilated.Add(string.Empty);
                        arrIsVPS.Add(OracleParameterStatus.NullInsert);
                    }
                }
                else
                {
                    // Not supported type
                }

                IEnumerable <IIfcDefinitionSelect> relObjects = relMat.RelatedObjects;
                foreach (IIfcDefinitionSelect relObjSel in relObjects)
                {
                    IIfcObjectDefinition relObj = relObjSel as IIfcObjectDefinition;
                    if (!(relObj is IIfcProduct) && !(relObj is IIfcTypeProduct))
                    {
                        continue;
                    }

                    string guid = relObj.GlobalId.ToString();

                    for (int i = 0; i < arrMatName.Count; i++)
                    {
                        if (relObj is IIfcProduct)
                        {
                            insGuid.Add(guid);
                            insMatName.Add(arrMatName[i]);
                            insSetName.Add(arrSetName[i]);
                            insSetNPS.Add(arrSetNPS[i]);
                            insIsVentilated.Add(arrIsVentilated[i]);
                            insIsVPS.Add(arrIsVPS[i]);
                            insMatSeq.Add(arrMatSeq[i]);
                            insMatSPS.Add(arrMatSPS[i]);
                            insMatThick.Add(arrMatThick[i]);
                            insMatTPS.Add(arrMatTPS[i]);
                        }
                        else
                        {
                            insTGuid.Add(guid);
                            insTMatName.Add(arrMatName[i]);
                            insTSetName.Add(arrSetName[i]);
                            insTSetNPS.Add(arrSetNPS[i]);
                            insTIsVentilated.Add(arrIsVentilated[i]);
                            insTIsVPS.Add(arrIsVPS[i]);
                            insTMatSeq.Add(arrMatSeq[i]);
                            insTMatSPS.Add(arrMatSPS[i]);
                            insTMatThick.Add(arrMatThick[i]);
                            insTMatTPS.Add(arrMatTPS[i]);
                        }
                    }
                }

                if ((insGuid.Count + insTGuid.Count) >= DBOperation.commitInterval)
                {
                    int commandStatus;
                    try
                    {
                        if (insTGuid.Count > 0)
                        {
                            currStep                 = "Processing Type Materials";
                            Param[0].Value           = insTGuid.ToArray();
                            Param[1].Value           = insTMatName.ToArray();
                            Param[2].Value           = insTSetName.ToArray();
                            Param[2].ArrayBindStatus = insTSetNPS.ToArray();
                            Param[3].Value           = insTIsVentilated.ToArray();
                            Param[3].ArrayBindStatus = insTIsVPS.ToArray();
                            Param[4].Value           = insTMatSeq.ToArray();
                            Param[4].ArrayBindStatus = insTMatSPS.ToArray();
                            Param[5].Value           = insTMatThick.ToArray();
                            Param[5].ArrayBindStatus = insTMatTPS.ToArray();
                            for (int i = 0; i < 6; i++)
                            {
                                Param[i].Size = insTGuid.Count;
                            }
                            command.ArrayBindCount = insTGuid.Count;

                            commandStatus = command.ExecuteNonQuery();
                        }

                        if (insGuid.Count > 0)
                        {
                            currStep = "Processing Element Materials";

                            Param2[0].Value           = insGuid.ToArray();
                            Param2[1].Value           = insMatName.ToArray();
                            Param2[2].Value           = insSetName.ToArray();
                            Param2[2].ArrayBindStatus = insSetNPS.ToArray();
                            Param2[3].Value           = insIsVentilated.ToArray();
                            Param2[3].ArrayBindStatus = insIsVPS.ToArray();
                            Param2[4].Value           = insMatSeq.ToArray();
                            Param2[4].ArrayBindStatus = insMatSPS.ToArray();
                            Param2[5].Value           = insMatThick.ToArray();
                            Param2[5].ArrayBindStatus = insMatTPS.ToArray();
                            for (int i = 0; i < 6; i++)
                            {
                                Param2[i].Size = insGuid.Count;
                            }
                            command2.ArrayBindCount = insGuid.Count;

                            commandStatus = command2.ExecuteNonQuery();
                        }

                        DBOperation.commitTransaction();

                        insTGuid.Clear();
                        insTMatName.Clear();
                        insTSetName.Clear();
                        insTSetNPS.Clear();
                        insTIsVentilated.Clear();
                        insTIsVPS.Clear();
                        insTMatSeq.Clear();
                        insTMatSPS.Clear();
                        insTMatThick.Clear();
                        insTMatTPS.Clear();

                        insGuid.Clear();
                        insMatName.Clear();
                        insSetName.Clear();
                        insSetNPS.Clear();
                        insIsVentilated.Clear();
                        insIsVPS.Clear();
                        insMatSeq.Clear();
                        insMatSPS.Clear();
                        insMatThick.Clear();
                        insMatTPS.Clear();
                    }
                    catch (OracleException e)
                    {
                        string excStr = "%%Insert Error - " + e.Message + "\n\t" + currStep;
                        _refBIMRLCommon.StackPushIgnorableError(excStr);

                        arrMatName.Clear();
                        arrSetName.Clear();
                        arrSetNPS.Clear();
                        arrIsVentilated.Clear();
                        arrIsVPS.Clear();
                        arrMatSeq.Clear();
                        arrMatSPS.Clear();
                        arrMatThick.Clear();
                        arrMatTPS.Clear();

                        insTGuid.Clear();
                        insTMatName.Clear();
                        insTSetName.Clear();
                        insTSetNPS.Clear();
                        insTIsVentilated.Clear();
                        insTIsVPS.Clear();
                        insTMatSeq.Clear();
                        insTMatSPS.Clear();
                        insTMatThick.Clear();
                        insTMatTPS.Clear();

                        insGuid.Clear();
                        insMatName.Clear();
                        insSetName.Clear();
                        insSetNPS.Clear();
                        insIsVentilated.Clear();
                        insIsVPS.Clear();
                        insMatSeq.Clear();
                        insMatSPS.Clear();
                        insMatThick.Clear();
                        insMatTPS.Clear();

                        continue;
                    }
                    catch (SystemException e)
                    {
                        string excStr = "%%Insert Error - " + e.Message + "\n\t" + currStep;
                        _refBIMRLCommon.StackPushError(excStr);
                        throw;
                    }
                }
            }

            if ((insGuid.Count + insTGuid.Count) > 0)
            {
                int commandStatus;
                try
                {
                    if (insTGuid.Count > 0)
                    {
                        currStep                 = "Processing Type Materials";
                        Param[0].Value           = insTGuid.ToArray();
                        Param[1].Value           = insTMatName.ToArray();
                        Param[2].Value           = insTSetName.ToArray();
                        Param[2].ArrayBindStatus = insTSetNPS.ToArray();
                        Param[3].Value           = insTIsVentilated.ToArray();
                        Param[3].ArrayBindStatus = insTIsVPS.ToArray();
                        Param[4].Value           = insTMatSeq.ToArray();
                        Param[4].ArrayBindStatus = insTMatSPS.ToArray();
                        Param[5].Value           = insTMatThick.ToArray();
                        Param[5].ArrayBindStatus = insTMatTPS.ToArray();
                        for (int i = 0; i < 6; i++)
                        {
                            Param[i].Size = insTGuid.Count;
                        }
                        command.ArrayBindCount = insTGuid.Count;

                        commandStatus = command.ExecuteNonQuery();
                    }

                    if (insGuid.Count > 0)
                    {
                        currStep = "Processing Element Materials";

                        Param2[0].Value           = insGuid.ToArray();
                        Param2[1].Value           = insMatName.ToArray();
                        Param2[2].Value           = insSetName.ToArray();
                        Param2[2].ArrayBindStatus = insSetNPS.ToArray();
                        Param2[3].Value           = insIsVentilated.ToArray();
                        Param2[3].ArrayBindStatus = insIsVPS.ToArray();
                        Param2[4].Value           = insMatSeq.ToArray();
                        Param2[4].ArrayBindStatus = insMatSPS.ToArray();
                        Param2[5].Value           = insMatThick.ToArray();
                        Param2[5].ArrayBindStatus = insMatTPS.ToArray();
                        for (int i = 0; i < 6; i++)
                        {
                            Param2[i].Size = insGuid.Count;
                        }
                        command2.ArrayBindCount = insGuid.Count;

                        commandStatus = command2.ExecuteNonQuery();
                    }

                    DBOperation.commitTransaction();
                }
                catch (OracleException e)
                {
                    string excStr = "%%Insert Error - " + e.Message + "\n\t" + currStep;
                    _refBIMRLCommon.StackPushIgnorableError(excStr);
                }
                catch (SystemException e)
                {
                    string excStr = "%%Insert Error - " + e.Message + "\n\t" + currStep;
                    _refBIMRLCommon.StackPushError(excStr);
                    throw;
                }
            }

            DBOperation.commitTransaction();
            command.Dispose();
            command2.Dispose();
        }
コード例 #23
0
        private void Button_EnhanceSpB_Click(object sender, RoutedEventArgs e)
        {
            string whereCond  = string.Empty;
            double currentTol = MathUtils.tol;

            // Temporarily change the tolerance if it is set in the UI
            if (!string.IsNullOrEmpty(TextBox_Tolerance.Text))
            {
                double tolSetting;
                if (double.TryParse(TextBox_Tolerance.Text, out tolSetting))
                {
                    MathUtils.tol = tolSetting;
                }
            }

            int fedModelID = 0;
            FederatedModelInfo selFedModel;
            FederatedModelInfo selFedModelsItem = DataGrid_FedModels.SelectedItem as FederatedModelInfo;

            if (selFedModelsItem == null)
            {
                return;     // do nothing, no selection made
            }
            else
            {
                selFedModel = selFedModelsItem;
                fedModelID  = selFedModel.FederatedID;
            }

            try
            {
                if (!string.IsNullOrEmpty(TextBox_Additional_Condition.Text))
                {
                    BIMRLCommon.appendToString(TextBox_Additional_Condition.Text, " AND ", ref whereCond);
                    string whereCondD = Regex.Replace(whereCond, "elementid", "spaceelementid", RegexOptions.IgnoreCase);
                    DBOperation.executeSingleStmt("DELETE FROM " + DBOperation.formatTabName("BIMRL_RELSPACEB_DETAIL", fedModelID) + " WHERE " + whereCondD);
                }
                else
                {
                    if (DBOperation.DBUserID.Equals(selFedModel.Owner))
                    {
                        DBOperation.executeSingleStmt("TRUNCATE TABLE " + DBOperation.formatTabName("BIMRL_RELSPACEB_DETAIL", fedModelID));
                    }
                    else
                    {
                        DBOperation.executeSingleStmt("DELETE FROM " + DBOperation.formatTabName("BIMRL_RELSPACEB_DETAIL", fedModelID));
                    }
                }

                DBOperation.commitInterval = 5000;
                EnhanceBRep eBrep = new EnhanceBRep();
                eBrep.enhanceSpaceBoundary(whereCond);

                // We will procees the normal face first and then after that the spacial ones (OBB, PROJOBB)
                string whereCond2 = whereCond;
                BIMRLCommon.appendToString(" TYPE NOT IN ('OBB','PROJOBB')", " AND ", ref whereCond2);
                eBrep.ProcessOrientation(whereCond2);
                whereCond2 = whereCond;
                BIMRLCommon.appendToString(" TYPE='OBB'", " AND ", ref whereCond2);
                eBrep.ProcessOrientation(whereCond2);
                whereCond2 = whereCond;
                BIMRLCommon.appendToString(" TYPE='PROJOBB'", " AND ", ref whereCond2);
                eBrep.ProcessOrientation(whereCond2);
            }
            catch (SystemException excp)
            {
                string excStr = "%% Error - " + excp.Message + "\n\t";
                BIMRLCommonRef.StackPushError(excStr);
                if (BIMRLCommonRef.BIMRLErrorStackCount > 0)
                {
                    showError(null);
                }
            }
            MathUtils.tol = currentTol;
        }
コード例 #24
0
 public BIMRLTypeObject(IfcStore m, BIMRLCommon refBIMRLCommon)
 {
     _refBIMRLCommon = refBIMRLCommon;
     _model          = m;
 }