private static BCFv21.Schemas.Components GetComponentsForViewpoint(BCFv2.Schemas.VisualizationInfo sourceViewpoint) { return(new BCFv21.Schemas.Components { Coloring = sourceViewpoint.Components .Where(comp => comp.Color != null) .GroupBy(comp => comp.Color.ToRgbHexColorString()) .Select(comp => new BCFv21.Schemas.ComponentColoringColor { Color = comp.Key, Component = comp.Select(c => new BCFv21.Schemas.Component { AuthoringToolId = c.AuthoringToolId, IfcGuid = c.IfcGuid, OriginatingSystem = c.OriginatingSystem }) .ToList() }) .ToList(), Selection = sourceViewpoint.Components .Where(comp => comp.ShouldSerializeSelected() && comp.Selected) .Select(comp => new BCFv21.Schemas.Component { AuthoringToolId = comp.AuthoringToolId, IfcGuid = comp.IfcGuid, OriginatingSystem = comp.OriginatingSystem }) .ToList(), Visibility = new BCFv21.Schemas.ComponentVisibility { DefaultVisibility = true, Exceptions = sourceViewpoint.Components .Where(comp => comp.ShouldSerializeVisible() && !comp.Visible) .Select(comp => new BCFv21.Schemas.Component { AuthoringToolId = comp.AuthoringToolId, IfcGuid = comp.IfcGuid, OriginatingSystem = comp.OriginatingSystem }) .ToList() } }); }
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); }