Exemple #1
0
        private void GetTopicViewpoints(BCFv2.BCFTopic topic, BCFv21.BCFTopic sourceTopic)
        {
            if (sourceTopic.Viewpoints?.Any() != true)
            {
                return;
            }

            foreach (var sourceViewpoint in sourceTopic.Viewpoints)
            {
                GetSingleTopicViewpoint(topic, sourceViewpoint);
            }

            if (sourceTopic.ViewpointBitmaps.Any())
            {
                foreach (var sourceBitmap in sourceTopic.ViewpointBitmaps)
                {
                    topic.ViewpointBitmaps.Add(topic.Viewpoints.Single(vp => vp.GUID == sourceBitmap.Key.Guid), sourceBitmap.Value.ToList());
                }
            }

            if (sourceTopic.ViewpointSnapshots.Any())
            {
                foreach (var sourceSnapshot in sourceTopic.ViewpointSnapshots)
                {
                    topic.AddOrUpdateSnapshot(sourceSnapshot.Key, sourceSnapshot.Value);
                }
            }
        }
Exemple #2
0
        private void GetMarkupComment(BCFv2.Schemas.Markup markup, BCFv21.BCFTopic sourceTopic)
        {
            if (!sourceTopic.Markup.ShouldSerializeComment())
            {
                return;
            }

            markup.Comment = sourceTopic.Markup.Comment
                             .Select(source => new BCFv2.Schemas.Comment
            {
                Author         = source.Author,
                Comment1       = source.Comment1,
                Date           = source.Date,
                Guid           = source.Guid,
                ModifiedAuthor = source.ModifiedAuthor,
                ModifiedDate   = source.ModifiedDate,
                Viewpoint      = source.Viewpoint == null
                                ? null
                                : new BCFv2.Schemas.CommentViewpoint
                {
                    Guid = source.Viewpoint.Guid
                }
            })
                             .ToList();
        }
Exemple #3
0
        private void GetSingleTopic(BCFv21.BCFTopic sourceTopic)
        {
            var topic = new BCFv2.BCFTopic();

            topic.SnippetData = sourceTopic.SnippetData;

            topic.Markup = GetMarkup(sourceTopic);

            GetTopicViewpoints(topic, sourceTopic);

            _destination.Topics.Add(topic);
        }
Exemple #4
0
        private BCFv2.Schemas.Markup GetMarkup(BCFv21.BCFTopic sourceTopic)
        {
            if (sourceTopic.Markup == null)
            {
                return(null);
            }

            var markup = new BCFv2.Schemas.Markup();

            GetMarkupHeader(markup, sourceTopic);
            GetMarkupComment(markup, sourceTopic);
            GetMarkupTopic(markup, sourceTopic);
            GetMarkupViewpoints(markup, sourceTopic);

            return(markup);
        }
Exemple #5
0
        private void GetMarkupViewpoints(BCFv2.Schemas.Markup markup, BCFv21.BCFTopic sourceTopic)
        {
            if (!sourceTopic.Markup.ShouldSerializeViewpoints())
            {
                return;
            }

            // The source viewpoints have an 'Index' property that could be used
            // for ordering. However, this isn't often used in practice, so it's
            // safer to simply use the same ordering as in the original input file
            markup.Viewpoints = sourceTopic.Markup.Viewpoints
                                .Select((source, index) => new BCFv2.Schemas.ViewPoint
            {
                Guid      = source.Guid,
                Snapshot  = source.Snapshot,
                Viewpoint = source.Viewpoint
            })
                                .ToList();
        }
Exemple #6
0
        private void GetMarkupHeader(BCFv2.Schemas.Markup markup, BCFv21.BCFTopic sourceTopic)
        {
            if (!sourceTopic.Markup.ShouldSerializeHeader())
            {
                return;
            }

            markup.Header = sourceTopic.Markup.Header
                            .Select(source => new BCFv2.Schemas.HeaderFile
            {
                Date       = source.Date,
                Filename   = source.Filename,
                IfcProject = source.IfcProject,
                IfcSpatialStructureElement = source.IfcSpatialStructureElement,
                isExternal = source.isExternal,
                Reference  = source.Reference
            })
                            .ToList();
        }
Exemple #7
0
        private void GetMarkupTopic(BCFv2.Schemas.Markup markup, BCFv21.BCFTopic sourceTopic)
        {
            if (!sourceTopic.Markup.ShouldSerializeTopic())
            {
                return;
            }

            var srcTopic = sourceTopic.Markup.Topic;

            markup.Topic = new BCFv2.Schemas.Topic();

            {
                if (srcTopic.ShouldSerializeAssignedTo())
                {
                    markup.Topic.AssignedTo = srcTopic.AssignedTo;
                }
                if (srcTopic.ShouldSerializeBimSnippet())
                {
                    markup.Topic.BimSnippet = srcTopic.BimSnippet == null
                        ? null
                        : new BCFv2.Schemas.BimSnippet
                    {
                        isExternal      = srcTopic.BimSnippet.isExternal,
                        Reference       = srcTopic.BimSnippet.Reference,
                        ReferenceSchema = srcTopic.BimSnippet.ReferenceSchema,
                        SnippetType     = srcTopic.BimSnippet.SnippetType
                    };
                }
                if (srcTopic.ShouldSerializeCreationAuthor())
                {
                    markup.Topic.CreationAuthor = srcTopic.CreationAuthor;
                }
                if (srcTopic.ShouldSerializeCreationDate())
                {
                    markup.Topic.CreationDate = srcTopic.CreationDate;
                }
                if (srcTopic.ShouldSerializeDescription())
                {
                    markup.Topic.Description = srcTopic.Description;
                }

                if (srcTopic.ShouldSerializeDocumentReference())
                {
                    markup.Topic.DocumentReferences = srcTopic.DocumentReference
                                                      .Select(src => new BCFv2.Schemas.TopicDocumentReferences
                    {
                        Description        = src.Description,
                        Guid               = src.Guid,
                        isExternal         = src.isExternal,
                        ReferencedDocument = src.ReferencedDocument
                    })
                                                      .ToList();
                }
                if (srcTopic.ShouldSerializeGuid())
                {
                    markup.Topic.Guid = srcTopic.Guid;
                }
                if (srcTopic.ShouldSerializeLabels())
                {
                    markup.Topic.Labels = srcTopic.Labels?.ToList();
                }
                if (srcTopic.ShouldSerializeModifiedAuthor())
                {
                    markup.Topic.ModifiedAuthor = srcTopic.ModifiedAuthor;
                }
                if (srcTopic.ShouldSerializeModifiedDate())
                {
                    markup.Topic.ModifiedDate = srcTopic.ModifiedDate;
                }
                if (srcTopic.ShouldSerializePriority())
                {
                    markup.Topic.Priority = srcTopic.Priority;
                }
                if (srcTopic.ShouldSerializeReferenceLink() && srcTopic.ReferenceLink.Any())
                {
                    markup.Topic.ReferenceLink = srcTopic.ReferenceLink.First();
                }
                if (srcTopic.ShouldSerializeTitle())
                {
                    markup.Topic.Title = srcTopic.Title;
                }
                if (srcTopic.ShouldSerializeRelatedTopic())
                {
                    markup.Topic.RelatedTopics = srcTopic.RelatedTopic?
                                                 .Select(src => new BCFv2.Schemas.TopicRelatedTopics
                    {
                        Guid = src.Guid
                    })
                                                 .ToList();
                }
                if (srcTopic.ShouldSerializeTopicStatus())
                {
                    markup.Topic.TopicStatus = srcTopic.TopicStatus;
                }
                if (srcTopic.ShouldSerializeTopicType())
                {
                    markup.Topic.TopicType = srcTopic.TopicType;
                }
            };
        }
Exemple #8
0
        private void GetSingleTopicViewpoint(BCFv21.BCFTopic topic, BCFv2.Schemas.VisualizationInfo sourceViewpoint)
        {
            var viewpoint = new BCFv21.Schemas.VisualizationInfo();

            if (sourceViewpoint.ShouldSerializeBitmaps())
            {
                viewpoint.Bitmap = sourceViewpoint.Bitmaps
                                   .Select(bitmap => new BCFv21.Schemas.VisualizationInfoBitmap
                {
                    Height    = bitmap.Height,
                    Location  = GetV21PointFromV2(bitmap.Location),
                    Normal    = GetV21DirectionFromV2(bitmap.Normal),
                    Up        = GetV21DirectionFromV2(bitmap.Up),
                    Reference = bitmap.Reference,
                    Bitmap    = bitmap.Bitmap == BCFv2.Schemas.BitmapFormat.JPG
                                ? BCFv21.Schemas.BitmapFormat.JPG
                                : BCFv21.Schemas.BitmapFormat.PNG
                })
                                   .ToList();
            }

            if (sourceViewpoint.ShouldSerializeClippingPlanes())
            {
                viewpoint.ClippingPlanes = sourceViewpoint.ClippingPlanes
                                           .Select(plane => new BCFv21.Schemas.ClippingPlane
                {
                    Direction = GetV21DirectionFromV2(plane.Direction),
                    Location  = GetV21PointFromV2(plane.Location)
                })
                                           .ToList();
            }

            if (sourceViewpoint.ShouldSerializeComponents())
            {
                viewpoint.Components = GetComponentsForViewpoint(sourceViewpoint);
            }

            if (sourceViewpoint.ShouldSerializeLines())
            {
                viewpoint.Lines = sourceViewpoint.Lines
                                  .Select(line => new BCFv21.Schemas.Line
                {
                    EndPoint   = GetV21PointFromV2(line.EndPoint),
                    StartPoint = GetV21PointFromV2(line.StartPoint)
                })
                                  .ToList();
            }

            if (sourceViewpoint.ShouldSerializeOrthogonalCamera())
            {
                viewpoint.OrthogonalCamera = new BCFv21.Schemas.OrthogonalCamera
                {
                    CameraDirection  = GetV21DirectionFromV2(sourceViewpoint.OrthogonalCamera.CameraDirection),
                    CameraUpVector   = GetV21DirectionFromV2(sourceViewpoint.OrthogonalCamera.CameraUpVector),
                    CameraViewPoint  = GetV21PointFromV2(sourceViewpoint.OrthogonalCamera.CameraViewPoint),
                    ViewToWorldScale = sourceViewpoint.OrthogonalCamera.ViewToWorldScale
                };
            }

            if (sourceViewpoint.ShouldSerializePerspectiveCamera())
            {
                viewpoint.PerspectiveCamera = new BCFv21.Schemas.PerspectiveCamera
                {
                    CameraDirection = GetV21DirectionFromV2(sourceViewpoint.PerspectiveCamera.CameraDirection),
                    CameraUpVector  = GetV21DirectionFromV2(sourceViewpoint.PerspectiveCamera.CameraUpVector),
                    CameraViewPoint = GetV21PointFromV2(sourceViewpoint.PerspectiveCamera.CameraViewPoint),
                    FieldOfView     = sourceViewpoint.PerspectiveCamera.FieldOfView
                };
            }

            viewpoint.Guid = sourceViewpoint.GUID;

            topic.Viewpoints.Add(viewpoint);
        }