IFCFile.js 1008 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * IfcFile
  3. *
  4. * @author realor
  5. */
  6. import { IFC_SCHEMAS } from './BaseEntity.js'
  7. class IFCFile {
  8. constructor() {
  9. this.schema = IFC_SCHEMAS.IFC4
  10. this.entities = {}
  11. this.products = []
  12. this.typeProducts = []
  13. this.relationships = []
  14. }
  15. add(entity) {
  16. let entities = this.entities
  17. let ifcClassName = entity.constructor.name
  18. let classEntities = entities[ifcClassName]
  19. if (classEntities === undefined) {
  20. classEntities = []
  21. entities[ifcClassName] = classEntities
  22. }
  23. classEntities.push(entity)
  24. if (entity instanceof this.schema.IfcProduct) {
  25. this.products.push(entity)
  26. } else if (entity instanceof this.schema.IfcTypeProduct) {
  27. this.typeProducts.push(entity)
  28. } else if (entity instanceof this.schema.IfcRelationship) {
  29. this.relationships.push(entity)
  30. }
  31. }
  32. }
  33. export { IFCFile }