Exemplo n.º 1
0
        private List<int> GetFileBadLabels(string fileName1, string fileName2)
        {
            List<int> badLabels = new List<int>();
                using (XbimModel modelServer = new XbimModel())
                {
                    modelServer.Open(fileName1);
                    using (XbimModel modelServer2 = new XbimModel())
                    {
                        modelServer2.Open(fileName2);
                        foreach (var entity in modelServer.Instances)
                        {
                            int entityLabel = entity.EntityLabel;
                            byte[] b1 = modelServer.GetEntityBinaryData(entity);

                            int posLabel = Math.Abs(entityLabel);

                            // we have entityLabel from 1st file, this should be in second file as well
                            IPersistIfcEntity entity2 = null;
                            bool isBadEntity = false;
                            entity2 = modelServer2.Instances[entityLabel]; //GetInstance(modelServer2, entityLabel); //modelServer2.GetInstance(entityLabel);

                            if (entity2 != null)
                            {
                                byte[] b2 = modelServer2.GetEntityBinaryData(entity2);

                                IStructuralEquatable eqb1 = b1;
                                bool isEqual = eqb1.Equals(b2, StructuralComparisons.StructuralEqualityComparer);
                                if (!isEqual)
                                {
                                    // they may be equal but showing unequal because of decimal precision
                                    // check if its decimal and if yes, then lower the precision and compare

                                    //if (!CompareBytes(modelServer, entity, b1, b2))
                                    isBadEntity = true;
                                    throw new Exception("Entity mismatch: EntityLabel: " + posLabel + " \n" + b1.ToString() + " \n" + b2.ToString());
                                }
                            }
                            else
                            {
                                // file1 entity dosent exist in file2
                                isBadEntity = true;

                            }
                            if (isBadEntity)
                            {
                                // add label to badLabels List
                                badLabels.Add(posLabel);
                            }

                        }
                        modelServer2.Close();
                    }
                    modelServer.Close();
                }
                return badLabels;
        }