示例#1
0
        private static List <BCFv2.Schemas.Component> GetComponentsForViewpoint(BCFv21.Schemas.VisualizationInfo sourceViewpoint)
        {
            var components = new List <BCFv2.Schemas.Component>();

            // The 'ViewSetupHints' property is ignored

            if (!sourceViewpoint.ShouldSerializeComponents())
            {
                return(components);
            }

            if (sourceViewpoint.Components.ShouldSerializeColoring())
            {
                var srcColoring = sourceViewpoint.Components.Coloring;
                foreach (var srcColor in srcColoring)
                {
                    if (srcColor.ShouldSerializeComponent())
                    {
                        components.AddRange(srcColor.Component.Select(c => new BCFv2.Schemas.Component
                        {
                            AuthoringToolId   = c.AuthoringToolId,
                            Color             = srcColor.Color.ToByteArrayFromHexRgbColor(),
                            IfcGuid           = c.IfcGuid,
                            OriginatingSystem = c.OriginatingSystem,
                            Visible           = true,
                            Selected          = false
                        }));
                    }
                }
            }

            if (sourceViewpoint.Components.ShouldSerializeSelection())
            {
                var srcSelection = sourceViewpoint.Components.Selection;
                components.AddRange(srcSelection.Select(s => new BCFv2.Schemas.Component
                {
                    AuthoringToolId   = s.AuthoringToolId,
                    IfcGuid           = s.IfcGuid,
                    OriginatingSystem = s.OriginatingSystem,
                    Selected          = true,
                    Visible           = true
                }));
            }

            if (sourceViewpoint.Components.ShouldSerializeVisibility())
            {
                var srcVisibility = sourceViewpoint.Components.Visibility;
                if (srcVisibility.DefaultVisibility && srcVisibility.ShouldSerializeExceptions())
                {
                    components.AddRange(srcVisibility.Exceptions.Select(e => new BCFv2.Schemas.Component
                    {
                        AuthoringToolId   = e.AuthoringToolId,
                        IfcGuid           = e.IfcGuid,
                        OriginatingSystem = e.OriginatingSystem,
                        Visible           = true,
                        Selected          = false
                    }));
                }
            }

            return(components);
        }
示例#2
0
        private void GetSingleTopicViewpoint(BCFv2.BCFTopic topic, BCFv21.Schemas.VisualizationInfo sourceViewpoint)
        {
            var viewpoint = new BCFv2.Schemas.VisualizationInfo();

            if (sourceViewpoint.ShouldSerializeBitmap())
            {
                viewpoint.Bitmaps = sourceViewpoint.Bitmap
                                    .Select(bitmap => new BCFv2.Schemas.VisualizationInfoBitmaps
                {
                    Height    = bitmap.Height,
                    Location  = GetV2PointFromV21(bitmap.Location),
                    Normal    = GetV2DirectionFromV21(bitmap.Normal),
                    Up        = GetV2DirectionFromV21(bitmap.Up),
                    Reference = bitmap.Reference,
                    Bitmap    = bitmap.Bitmap == BCFv21.Schemas.BitmapFormat.JPG
                                ? BCFv2.Schemas.BitmapFormat.JPG
                                : BCFv2.Schemas.BitmapFormat.PNG
                })
                                    .ToList();
            }

            if (sourceViewpoint.ShouldSerializeClippingPlanes())
            {
                viewpoint.ClippingPlanes = sourceViewpoint.ClippingPlanes
                                           .Select(plane => new BCFv2.Schemas.ClippingPlane
                {
                    Direction = GetV2DirectionFromV21(plane.Direction),
                    Location  = GetV2PointFromV21(plane.Location)
                })
                                           .ToList();
            }

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

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

            if (sourceViewpoint.ShouldSerializeOrthogonalCamera())
            {
                viewpoint.OrthogonalCamera = new BCFv2.Schemas.OrthogonalCamera
                {
                    CameraDirection  = GetV2DirectionFromV21(sourceViewpoint.OrthogonalCamera.CameraDirection),
                    CameraUpVector   = GetV2DirectionFromV21(sourceViewpoint.OrthogonalCamera.CameraUpVector),
                    CameraViewPoint  = GetV2PointFromV21(sourceViewpoint.OrthogonalCamera.CameraViewPoint),
                    ViewToWorldScale = sourceViewpoint.OrthogonalCamera.ViewToWorldScale
                };
            }

            if (sourceViewpoint.ShouldSerializePerspectiveCamera())
            {
                viewpoint.PerspectiveCamera = new BCFv2.Schemas.PerspectiveCamera
                {
                    CameraDirection = GetV2DirectionFromV21(sourceViewpoint.PerspectiveCamera.CameraDirection),
                    CameraUpVector  = GetV2DirectionFromV21(sourceViewpoint.PerspectiveCamera.CameraUpVector),
                    CameraViewPoint = GetV2PointFromV21(sourceViewpoint.PerspectiveCamera.CameraViewPoint),
                    FieldOfView     = sourceViewpoint.PerspectiveCamera.FieldOfView
                };
            }

            viewpoint.GUID = sourceViewpoint.Guid;

            topic.Viewpoints.Add(viewpoint);
        }