Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rotation to the ContentConfiguration #73

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
layoutInstantiated.ConfigName = key;
break;
}
else if (config.AllowRotatation && config.CellBoundary.Depth < width + 0.01 && config.CellBoundary.Width < length + 0.01)

Check failure on line 36 in LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs

View workflow job for this annotation

GitHub Actions / build

'ContentConfiguration' does not contain a definition for 'AllowRotatation' and no accessible extension method 'AllowRotatation' accepting a first argument of type 'ContentConfiguration' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 36 in LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs

View workflow job for this annotation

GitHub Actions / build

'ContentConfiguration' does not contain a definition for 'AllowRotatation' and no accessible extension method 'AllowRotatation' accepting a first argument of type 'ContentConfiguration' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 36 in LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs

View workflow job for this annotation

GitHub Actions / build

'ContentConfiguration' does not contain a definition for 'AllowRotatation' and no accessible extension method 'AllowRotatation' accepting a first argument of type 'ContentConfiguration' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 36 in LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs

View workflow job for this annotation

GitHub Actions / build

'ContentConfiguration' does not contain a definition for 'AllowRotatation' and no accessible extension method 'AllowRotatation' accepting a first argument of type 'ContentConfiguration' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 36 in LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs

View workflow job for this annotation

GitHub Actions / build

'ContentConfiguration' does not contain a definition for 'AllowRotatation' and no accessible extension method 'AllowRotatation' accepting a first argument of type 'ContentConfiguration' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 36 in LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs

View workflow job for this annotation

GitHub Actions / build

'ContentConfiguration' does not contain a definition for 'AllowRotatation' and no accessible extension method 'AllowRotatation' accepting a first argument of type 'ContentConfiguration' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 36 in LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs

View workflow job for this annotation

GitHub Actions / build

'ContentConfiguration' does not contain a definition for 'AllowRotatation' and no accessible extension method 'AllowRotatation' accepting a first argument of type 'ContentConfiguration' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 36 in LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs

View workflow job for this annotation

GitHub Actions / build

'ContentConfiguration' does not contain a definition for 'AllowRotatation' and no accessible extension method 'AllowRotatation' accepting a first argument of type 'ContentConfiguration' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 36 in LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs

View workflow job for this annotation

GitHub Actions / build

'ContentConfiguration' does not contain a definition for 'AllowRotatation' and no accessible extension method 'AllowRotatation' accepting a first argument of type 'ContentConfiguration' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 36 in LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs

View workflow job for this annotation

GitHub Actions / build

'ContentConfiguration' does not contain a definition for 'AllowRotatation' and no accessible extension method 'AllowRotatation' accepting a first argument of type 'ContentConfiguration' could be found (are you missing a using directive or an assembly reference?)
{
layoutInstantiated.Config = GetRotatedConfig(config, -90);
layoutInstantiated.ConfigName = key;
break;
}
}
if (layoutInstantiated.Config == null)
{
Expand Down Expand Up @@ -874,5 +880,33 @@
elementInstance.AdditionalProperties["Space"] = parentSpaceId;
}
}

private static ContentConfiguration GetRotatedConfig(ContentConfiguration config, double degrees)
{
var transform = new Transform().Rotated(Vector3.ZAxis, degrees);
var box = new BBox3(new List<Vector3> { transform.OfPoint(config.CellBoundary.Min), transform.OfPoint(config.CellBoundary.Max) });

// Create new config
var newConfig = new ContentConfiguration()
{
CellBoundary = new ContentConfiguration.BoundaryDefinition() { Min = box.Min, Max = box.Max, },
ContentItems = new List<ContentConfiguration.ContentItem>()
};

foreach (var item in config.ContentItems)
{
var newItem = new ContentConfiguration.ContentItem()
{
Url = item.Url,
Name = item.Name,
Transform = item.Transform.Concatenated(transform),
Anchor = transform.OfPoint(item.Anchor)
};

newConfig.ContentItems.Add(newItem);
}

return newConfig;
}
}
}
Loading