Skip to content

Commit

Permalink
Merge master into dashed-lines
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewheumann authored Aug 12, 2022
2 parents e522942 + ea464c6 commit bd46217
Show file tree
Hide file tree
Showing 349 changed files with 17,916 additions and 5,353 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ jobs:
runs-on: windows-2019
steps:
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 10
token: ${{ secrets.HYPAR_GITHUB_BOT_PAT }}
- name: Setup Git
run: |
git config user.name "hypar-eric-bot"
git config user.email "[email protected]"
- name: Setup dotnet
uses: actions/setup-dotnet@v1
with:
Expand All @@ -24,11 +29,7 @@ jobs:
dotnet test --filter Category=Examples
docfx ./doc/docfx.json -f
- name: Deploy Docs
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-west-1
run: |
aws s3 sync ./docs s3://${{ secrets.AWS_BUCKET }} --delete --exclude '*.js'
aws s3 sync ./docs s3://${{ secrets.AWS_BUCKET }} --delete --exclude '*' --include '*.js' --content-type 'text/javascript'
aws cloudfront create-invalidation --distribution-id E2PS0S8A6ZSOKE --paths "/*"
uses: EndBug/add-and-commit@v9
with:
add: 'docs'
message: 'Update documentation'
30 changes: 25 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,30 @@

## 1.2.0

### Added
- `Polygon(IList<Vector3> @vertices, bool disableValidation = false)`
- `Polygon(bool disableValidation, params Vector3[] vertices)`
- `Polyline(IList<Vector3> @vertices, bool disableValidation = false)`
- `Polyline(bool disableValidation, params Vector3[] vertices)`
- `Mesh.Intersects(Ray)` (same as `Ray.Intersects(Mesh)`)
- `Ray.NearbyPoints()`
- `PointOctree<T>`
- `Message` class along with helper creation methods.

### Changed

- MeshElement constructor signature modified to be compatible with code generation.
- Improved performance of mesh/ray intersection
- `BBox3.Extend` method is public now
- `AdaptiveGrid.Boundary` can be left null.
- `Obstacle` properties `Points`, `Offset`, `Perimeter` and `Transform` can be modified from outside.

### Fixed

- Fixed a bug where `Polyline.Frames` would return inconsistently-oriented transforms.
- `Obstacle.FromBox` works properly with `AdaptiveGrid` transformation.
- `AdaptiveGrid.SubtractObstacle` worked incorrectly in `AdaptiveGrid.Boundary` had elevation.
- #805

## 1.1.0

Expand Down Expand Up @@ -50,6 +72,7 @@
- Fixed a mathematical error in `MercatorProjection.MetersToLatLon`, which was returning longitude values that were skewed.
- `Grid2d.IsTrimmed` would occasionally return `true` for cells that were not actually trimmed.
- `Vector3[].AreCoplanar()` computed its tolerance for deviation incorrectly, this is fixed.
- `Polyline.Intersects(Line line, out List<Vector3> intersections, bool infinite = false, bool includeEnds = false)` fix wrong results when infinite flag is set, fix for overlapping points when include ends is set.

## 1.0.1

Expand All @@ -61,11 +84,6 @@
- `ContinuousDimension`
- `Vector3.AreCollinearByAngle(Vector3 a, Vector3 b, Vector3 c, double tolerance)`


### Fixed

- #805

### Fixed

- `Line.IsCollinear(Line line)` would return `false` if lines are close to each other but not collinear
Expand All @@ -74,11 +92,13 @@
- `Line.GetUParameter(Vector 3)` - calculate U parameter for point on line
- `Line.MergeCollinearLine(Line line)` creates new line containing all four collinear vertices
- `Line.Projected(Plane plane)` create new line projected onto plane
- `Profile.Split` would sometimes fail if the profile being split contained voids.

### Changed

- Simplified `IEnumerable<Vector3>.ToGraphicsBuffers()`
- `TryToGraphicsBuffers` is now public
- `Solid SweepFaceAlongCurve` now has an additional parameter, `profileRotation`, which enables the caller to pass a profile rotation into sweep creation.

## 1.0.0

Expand Down
74 changes: 74 additions & 0 deletions Elements.Benchmarks/Mesh.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
using Elements.Geometry;

namespace Elements.Benchmarks
{
public class MeshRayIntersection
{
private Mesh _mesh;
private List<Ray> _rays;

public MeshRayIntersection()
{
var random = new Random(10);
_mesh = new Mesh();
_rays = new List<Ray>();
var xCount = 100;
var yCount = 300;
MeshConstruction.BuildRandomMesh(_mesh, random, xCount, yCount);

// create 1000 random rays
for (int i = 0; i < 1000; i++)
{
var ray = new Ray(new Vector3(random.NextDouble() * xCount, random.NextDouble() * yCount, 2.1), new Vector3(random.NextDouble() * 2 - 1, random.NextDouble() * 2 - 1, -1));
_rays.Add(ray);
}
}


[Benchmark(Description = "Intersect 1000 rays with mesh.")]
public void IntersectRays()
{
foreach (var ray in _rays)
{
ray.Intersects(_mesh, out var _);
}
}
}
public class MeshConstruction
{
public static void BuildRandomMesh(Mesh m, Random random, int xCount, int yCount)
{
for (int i = 0; i < xCount; i++)
{
for (int j = 0; j < yCount; j++)
{
var point = new Vector3(i, j, random.NextDouble() * 2);
var c = m.AddVertex(point);
if (i != 0 && j != 0)
{
// add faces
var d = m.Vertices[i * yCount + j - 1];
var a = m.Vertices[(i - 1) * yCount + j - 1];
var b = m.Vertices[(i - 1) * yCount + j];
m.AddTriangle(a, b, c);
m.AddTriangle(c, d, a);
}
}
}
}

[Params(1000, 5000, 10000, 30000)]
public int VertexCount { get; set; }

[Benchmark(Description = "Construct Mesh")]
public void ConstructMesh()
{
var mesh = new Mesh();
BuildRandomMesh(mesh, new Random(10), 100, VertexCount / 100);
}

}
}
1 change: 1 addition & 0 deletions Elements.Benchmarks/Trace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public void TraceModelCreation()
}

[EventPipeProfiler(EventPipeProfile.CpuSampling)]
[MemoryDiagnoser]
[SimpleJob]
public class TraceGltfSerialization
{
Expand Down
54 changes: 54 additions & 0 deletions Elements/src/Annotations/Message.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Elements.Geometry;
using Newtonsoft.Json;

namespace Elements.Annotations
{
/// <summary>An element that stores warning messages.</summary>
[JsonConverter(typeof(Elements.Serialization.JSON.JsonInheritanceConverter), "discriminator")]
// TODO: We probably don't want to inherit from GeometricElement for ever. It would be better for Messages to
// behave more like actual Annotation elements while still being capable of having an appearance in 3D in some circumstances.
public partial class Message : GeometricElement
{
/// <summary>
/// Default json constructor for a message that may have geometry.
/// </summary>
/// <param name="message"></param>
/// <param name="stackTrace"></param>
/// <param name="severity"></param>
/// <param name="transform"></param>
/// <param name="material"></param>
/// <param name="representation"></param>
/// <param name="isElementDefinition"></param>
/// <param name="id"></param>
/// <param name="name"></param>
[JsonConstructor]
public Message(string @message, string @stackTrace, MessageSeverity @severity, Transform @transform = null, Material @material = null, Representation @representation = null, bool @isElementDefinition = false, System.Guid @id = default, string @name = null)
: base(transform, material, representation, isElementDefinition, id, name)
{
this.MessageText = @message;
this.StackTrace = @stackTrace;
this.Severity = @severity;
}

/// <summary>
/// Empty constructor.
/// </summary>
public Message()
: base()
{
}

/// <summary>A warning message for the user.</summary>
[JsonProperty("Message", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string MessageText { get; set; }

/// <summary>Developer specific message about the failure in the code.</summary>
[JsonProperty("Stack Trace", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string StackTrace { get; set; }

/// <summary>Developer specific message about the failure in the code.</summary>
[JsonProperty("Severity", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
public MessageSeverity Severity { get; set; }
}
}
23 changes: 23 additions & 0 deletions Elements/src/Annotations/MessageSeverity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace Elements.Annotations
{
/// <summary>
/// The severity of a given message.
/// </summary>
public enum MessageSeverity
{
/// <summary>
/// Message is for information purposes only.
/// </summary>
Info,

/// <summary>
/// Message is for a warning.
/// </summary>
Warning,

/// <summary>
/// Message is for an error.
/// </summary>
Error
};
}
Loading

0 comments on commit bd46217

Please sign in to comment.