Пример #1
0
        internal override void EndHeaderEntity()
        {
            _processStack.Pop();

            _currentInstance = null;
            // Console.WriteLine("EndHeaderEntity - " + CurrentSemanticValue.strVal);
        }
Пример #2
0
 internal override void BeginNestedType(string value)
 {
     int[] reqProps;
     _currentInstance = new Part21Entity(EntityCreate(value, null, InHeader, out reqProps));
     _currentInstance.RequiredParameters = reqProps;
     _processStack.Push(_currentInstance);
 }
Пример #3
0
        internal override void EndList()
        {
            _listNestLevel--;
            Part21Entity p21 = _processStack.Peek();

            p21.CurrentParamIndex++;
            //Console.WriteLine("EndList");
        }
Пример #4
0
        internal override void EndList()
        {
            _listNestLevel--;
            Part21Entity p21 = _processStack.Peek();

            p21.CurrentParamIndex++;
            if (!InHeader)
            {
                _binaryWriter.Write((byte)P21ParseAction.EndList);
            }
        }
Пример #5
0
        internal override void BeginList()
        {
            Part21Entity p21 = _processStack.Peek();

            if (p21.CurrentParamIndex == -1)
            {
                p21.CurrentParamIndex++; //first time in take the first argument
            }
            _listNestLevel++;
            //  Console.WriteLine("BeginList");
        }
Пример #6
0
        internal override void BeginList()
        {
            Part21Entity p21 = _processStack.Peek();

            if (p21.CurrentParamIndex == -1)
            {
                p21.CurrentParamIndex++; //first time in take the first argument
            }
            _listNestLevel++;
            if (!InHeader)
            {
                _binaryWriter.Write((byte)P21ParseAction.BeginList);
            }
        }
Пример #7
0
        internal override void EndEntity()
        {
            Part21Entity p21 = _processStack.Pop();

            //Debug.Assert(_processStack.Count == 0);
            _currentInstance = null;
            if (p21.Entity != null)
            {
                _entities.Add(p21.EntityLabel, p21.Entity);
            }


            // Console.WriteLine("EndEntity - " + CurrentSemanticValue.strVal);
        }
Пример #8
0
 internal override void NewEntity(string entityLabel)
 {
     _currentInstance = new Part21Entity(entityLabel);
     // Console.WriteLine(CurrentSemanticValue.strVal);
     _processStack.Push(_currentInstance);
     if (_streamSize != -1 && ProgressStatus != null)
     {
         Scanner sc            = (Scanner)this.Scanner;
         double  pos           = sc.Buffer.Pos;
         int     newPercentage = Convert.ToInt32(pos / _streamSize * 100.0);
         if (newPercentage > _percentageParsed)
         {
             _percentageParsed = newPercentage;
             ProgressStatus(_percentageParsed, "Parsing");
         }
     }
 }
Пример #9
0
        internal override void SetType(string entityTypeName)
        {
            Scanner sc = (Scanner)this.Scanner;

            if (InHeader)
            {
                int[] reqParams;
                _currentInstance = new Part21Entity(EntityCreate(entityTypeName, null, InHeader, out reqParams));
                _currentInstance.RequiredParameters = reqParams;
                _processStack.Push(_currentInstance);
            }
            else
            {
                Part21Entity p21 = _processStack.Peek();
                int[]        reqProps;
                p21.Entity             = EntityCreate(entityTypeName, p21.EntityLabel, InHeader, out reqProps);
                p21.RequiredParameters = reqProps;
            }
        }
Пример #10
0
        private void SetEntityParameter(string value)
        {
            try
            {
                if (_currentInstance.Entity != null)
                {
                    _currentInstance.ParameterSetter(_currentInstance.CurrentParamIndex, _propertyValue);
                }
            }
            catch (Exception)
            {
                if (_errorCount > MaxErrorCount)
                {
                    throw new Exception("Too many errors in file, parser execution terminated");
                }
                _errorCount++;
                Part21Entity mainEntity = _processStack.Last();
                if (mainEntity != null)
                {
                    IfcType ifcType = IfcMetaData.IfcType(mainEntity.Entity);

                    string propertyName = mainEntity.CurrentParamIndex + 1 > ifcType.IfcProperties.Count ? "[UnknownProperty]" :
                                          ifcType.IfcProperties[mainEntity.CurrentParamIndex + 1].PropertyInfo.Name;

                    Logger.ErrorFormat("Entity #{0,-5} {1}, error at parameter {2}-{3} value = {4}",
                                       mainEntity.EntityLabel,
                                       mainEntity.Entity.GetType().Name.ToUpper(),
                                       mainEntity.CurrentParamIndex + 1,
                                       propertyName,
                                       value);
                }
                else
                {
                    Logger.Error("Unhandled Parser error, in Parser.cs SetEntityParameter");
                }
            }
            if (_listNestLevel == 0)
            {
                _currentInstance.CurrentParamIndex++;
                _deferListItems = false;
            }
        }
Пример #11
0
        internal override void EndEntity()
        {
            Part21Entity p21 = _processStack.Pop();

            Debug.Assert(_processStack.Count == 0);
            _currentInstance = null;
            if (_currentType != null)
            {
                _binaryWriter.Write((byte)P21ParseAction.EndEntity);
                IfcType      ifcType = IfcMetaData.IfcType(_currentType);
                MemoryStream data    = _binaryWriter.BaseStream as MemoryStream;
                byte[]       bytes   = data.ToArray();
                List <int>   keys    = new List <int>(_indexKeyValues);
                toStore.Add(new Tuple <int, short, List <int>, byte[], bool>(_currentLabel, ifcType.TypeId, keys, bytes, ifcType.IndexedClass));
                if (this.modelCache.IsCaching)
                {
                    toProcess.Add(new Tuple <int, Type, byte[]>(_currentLabel, ifcType.Type, bytes));
                }
            }
        }
Пример #12
0
        internal override void SetType(string entityTypeName)
        {
            if (InHeader)
            {
                IPersistIfc currentHeaderEntity;
                switch (entityTypeName)
                {
                case "FILE_DESCRIPTION":
                    currentHeaderEntity = _header.FileDescription;
                    break;

                case "FILE_NAME":
                    currentHeaderEntity = _header.FileName;
                    break;

                case "FILE_SCHEMA":
                    currentHeaderEntity = _header.FileSchema;
                    break;

                default:
                    throw new ArgumentException(string.Format("Invalid Header entity type {0}", entityTypeName));
                }
                _currentInstance = new Part21Entity(currentHeaderEntity);
                _processStack.Push(_currentInstance);
            }
            else
            {
                _currentType = entityTypeName;
                IfcType ifcType = IfcMetaData.IfcType(_currentType);
                if (ifcType == null)
                {
                    throw new ArgumentException(string.Format("Invalid entity type {0}", _currentType));
                }

                _indexKeys = ifcType.IndexedValues;
            }
        }
Пример #13
0
        internal override void NewEntity(string entityLabel)
        {
            _currentInstance = new Part21Entity(entityLabel);
            _processStack.Push(_currentInstance);
            _entityCount++;
            _indexKeyValues.Clear();
            _currentLabel = Convert.ToInt32(entityLabel.TrimStart('#'));
            MemoryStream data = _binaryWriter.BaseStream as MemoryStream;

            data.SetLength(0);


            if (_streamSize != -1 && ProgressStatus != null)
            {
                Scanner sc            = (Scanner)this.Scanner;
                double  pos           = sc.Buffer.Pos;
                int     newPercentage = Convert.ToInt32(pos / _streamSize * 100.0);
                if (newPercentage > _percentageParsed)
                {
                    _percentageParsed = newPercentage;
                    ProgressStatus(_percentageParsed, "Parsing");
                }
            }
        }
Пример #14
0
 internal override void EndHeaderEntity()
 {
     _processStack.Pop();
     _currentInstance = null;
 }