import streamlit as st import numpy as np import pandas as pd from datetime import datetime class BIMAnalyzer: """محلل نماذج BIM المتقدم""" def __init__(self): self.supported_formats = ['.ifc', '.rvt', '.nwd', '.dwg'] def analyze_bim_model(self, file): """تحليل نموذج BIM""" try: # تحليل المكونات components = self._analyze_components(file) # تحليل التكاليف costs = self._analyze_costs(components) # تحليل التعارضات clashes = self._analyze_clashes(file) return { 'components': components, 'costs': costs, 'clashes': clashes, 'timestamp': datetime.now().strftime('%Y-%m-%d %H:%M:%S') } except Exception as e: return {'error': str(e)} def _analyze_components(self, file): """تحليل مكونات النموذج""" return { 'structural': { 'columns': {'count': 120, 'volume': 450.5}, 'beams': {'count': 350, 'volume': 680.2}, 'slabs': {'count': 45, 'volume': 1200.8} }, 'architectural': { 'walls': {'count': 280, 'area': 3500.6}, 'windows': {'count': 150, 'area': 450.3}, 'doors': {'count': 95, 'area': 220.5} }, 'mep': { 'hvac': {'length': 2800.5, 'units': 35}, 'plumbing': {'length': 1500.2, 'fixtures': 180}, 'electrical': {'length': 3500.8, 'fixtures': 420} } } def _analyze_costs(self, components): """تحليل التكاليف بناءً على المكونات""" return { 'structural': 2500000, 'architectural': 1800000, 'mep': 1200000, 'total': 5500000 } def _analyze_clashes(self, file): """تحليل التعارضات في النموذج""" return { 'critical': 5, 'major': 12, 'minor': 28, 'locations': [ {'level': 'Ground Floor', 'count': 15}, {'level': 'First Floor', 'count': 18}, {'level': 'Second Floor', 'count': 12} ] } def render_analysis(self, analysis_results): """عرض نتائج التحليل في واجهة المستخدم""" st.header("تحليل نموذج BIM") # عرض ملخص المكونات st.subheader("ملخص المكونات") components = analysis_results['components'] col1, col2, col3 = st.columns(3) with col1: st.metric("عدد الأعمدة", components['structural']['columns']['count']) with col2: st.metric("عدد الجسور", components['structural']['beams']['count']) with col3: st.metric("عدد البلاطات", components['structural']['slabs']['count']) # عرض التكاليف st.subheader("تحليل التكاليف") costs = analysis_results['costs'] cost_data = pd.DataFrame({ 'القسم': ['الهيكل الإنشائي', 'المعماري', 'الكهروميكانيك'], 'التكلفة': [costs['structural'], costs['architectural'], costs['mep']] }) st.bar_chart(cost_data.set_index('القسم')) # عرض التعارضات st.subheader("تحليل التعارضات") clashes = analysis_results['clashes'] col1, col2, col3 = st.columns(3) with col1: st.metric("تعارضات حرجة", clashes['critical'], delta="يجب المعالجة فوراً") with col2: st.metric("تعارضات رئيسية", clashes['major']) with col3: st.metric("تعارضات ثانوية", clashes['minor'])