Esempio n. 1
0
        public static List <FMEPoint> ConvertToFMEPointList(List <PointData> pointDataList)
        {
            List <FMEPoint> fmePointList = new List <FMEPoint>();

            try
            {
                foreach (PointData ptData in pointDataList)
                {
                    FMEPoint fmePoint = FMEDataUtil.ConvertToFMEPoint(ptData);
                    fmePointList.Add(fmePoint);
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }
            return(fmePointList);
        }
Esempio n. 2
0
        public static List <PointData> ConvertToPointDataList(Face revitFace, List <FMEPoint> fmePointList)
        {
            List <PointData> pointDataList = new List <PointData>();

            try
            {
                foreach (FMEPoint fmePoint in fmePointList)
                {
                    PointData ptData = FMEDataUtil.ConvertToPointData(revitFace, fmePoint);
                    pointDataList.Add(ptData);
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }
            return(pointDataList);
        }
Esempio n. 3
0
        private bool SaveResultData(Dictionary <int, RoomData> roomDictionary)
        {
            bool saved = false;

            try
            {
                if (!string.IsNullOrEmpty(settings.DataFileName))
                {
                    analysisDataCollection = new AnalysisDataCollection();

                    foreach (int roomId in roomDictionary.Keys)
                    {
                        RoomData roomData = roomDictionary[roomId];
                        int      index    = analysisDataCollection.AnalysisDataList.FindIndex(o => o.RoomId == roomId);
                        if (settings.OverwriteData)
                        {
                            if (index > -1)
                            {
                                analysisDataCollection.AnalysisDataList.RemoveAt(index);
                            }
                            AnalysisData aData = new AnalysisData();
                            aData.RoomId      = roomData.RoomId;
                            aData.RoomArea    = roomData.RoomArea;
                            aData.VisibleArea = roomData.AreaWithViews;
                            aData.RoomFace    = FMEDataUtil.ConvertRevitFaceToFMEArea(roomData.RoomFace);
                            aData.PointValues = FMEDataUtil.ConvertToFMEPointList(roomData.PointDataList);
                            analysisDataCollection.AnalysisDataList.Add(aData);
                        }
                        else if (index == -1)
                        {
                            //add new room data only if it doesn't exist
                            AnalysisData aData = new AnalysisData();
                            aData.RoomId      = roomData.RoomId;
                            aData.RoomArea    = roomData.RoomArea;
                            aData.VisibleArea = roomData.AreaWithViews;
                            aData.RoomFace    = FMEDataUtil.ConvertRevitFaceToFMEArea(roomData.RoomFace);
                            aData.PointValues = FMEDataUtil.ConvertToFMEPointList(roomData.PointDataList);
                            analysisDataCollection.AnalysisDataList.Add(aData);
                        }
                    }

                    if (analysisDataCollection.AnalysisDataList.Count > 0)
                    {
                        XmlSerializer serializer = new XmlSerializer(typeof(AnalysisDataCollection));
                        StreamWriter  writer     = new StreamWriter(settings.DataFileName);
                        serializer.Serialize(writer, analysisDataCollection);
                        writer.Close();
                        saved = true;
                    }
                }
                else
                {
                    saved = true;
                }
            }
            catch (Exception ex)
            {
                saved = false;
                System.Windows.MessageBox.Show("Failed to save analysis data.\n" + ex.Message, "Save Result Data", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            return(saved);
        }
        private RoomData FindVisibilityByPointData(RoomData rd, AnalysisData aData, ProgressBar progressBar)
        {
            RoomData updatedData = new RoomData(rd);

            try
            {
                updatedData.RoomFace = FMEDataUtil.CreateFacebyFMEData(aData.RoomFace);
                if (null != updatedData.RoomFace)
                {
                    updatedData.PointDataList = FMEDataUtil.ConvertToPointDataList(updatedData.RoomFace, aData.PointValues);

                    IList <UV>           uvPoints = new List <UV>();
                    IList <ValueAtPoint> valList  = new List <ValueAtPoint>();

                    progressBar.Value   = 0;
                    progressBar.Minimum = 0;
                    progressBar.Maximum = updatedData.PointDataList.Count;
                    UpdateProgressDelegate updateProgressDelegate = new UpdateProgressDelegate(progressBar.SetValue);

                    int    visibleCount  = 0;
                    double progressValue = 0;
                    foreach (PointData ptData in updatedData.PointDataList)
                    {
                        if (AbortFlag.GetAbortFlag())
                        {
                            return(updatedData);
                        }
                        Dispatcher.CurrentDispatcher.Invoke(updateProgressDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { ProgressBar.ValueProperty, progressValue });

                        if (null != ptData.UVPoint && null != ptData.ValueAtPoint)
                        {
                            uvPoints.Add(ptData.UVPoint);
                            valList.Add(ptData.ValueAtPoint);
                            if (ptData.PointValue > 0)
                            {
                                visibleCount++;
                            }
                        }
                        progressValue++;
                    }

                    double ratio = (double)visibleCount / (double)uvPoints.Count;
                    updatedData.VisiblityRatio = ratio;
                    updatedData.AreaWithViews  = rd.RoomArea * ratio;
                    updatedData.SetResultParameterValue(LEEDParameters.LEED_AreaWithViews.ToString(), rd.AreaWithViews);

                    //visualize
                    Transform transform = Transform.CreateTranslation(new XYZ(0, 0, offsetHeight));
                    int       index     = m_sfm.AddSpatialFieldPrimitive(updatedData.RoomFace, transform);

                    FieldDomainPointsByUV domainPoints = new FieldDomainPointsByUV(uvPoints);
                    FieldValues           values       = new FieldValues(valList);

                    m_sfm.UpdateSpatialFieldPrimitive(index, domainPoints, values, resultIndex);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to find visibility.\n" + ex.Message, "Find Visibility", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            return(updatedData);
        }