Skip to content

Commit

Permalink
Merge pull request #1207 from mcneel/1.26
Browse files Browse the repository at this point in the history
Fix on `GeometryObject.GetBoundingBox` extension method.
  • Loading branch information
kike-garbo authored Nov 13, 2024
2 parents 73fb4a5 + 6866571 commit c5b2588
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
15 changes: 12 additions & 3 deletions src/RhinoInside.Revit.External/DB/Extensions/GeometryObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@ public static BoundingBoxXYZ GetBoundingBox(this GeometryObject geometry, Transf
else
{
var bbox = element.GetTransformed(coordSystem.Inverse).GetBoundingBox();
if (bbox.IsNegative()) bbox = BoundingBoxXYZExtension.Empty;
bbox.Transform = coordSystem;
return bbox;
}
Expand All @@ -690,13 +691,15 @@ public static BoundingBoxXYZ GetBoundingBox(this GeometryObject geometry, Transf
else
{
var bbox = instance.GetSymbolGeometry(coordSystem.Inverse * instance.Transform).GetBoundingBox();
if (bbox.IsNegative()) bbox = BoundingBoxXYZExtension.Empty;
bbox.Transform = coordSystem;
return bbox;
}
}
else
{
var bbox = instance.SymbolGeometry.GetBoundingBox();
if (bbox.IsNegative()) bbox = BoundingBoxXYZExtension.Empty;
bbox.Transform = instance.Transform;
return bbox;
}
Expand Down Expand Up @@ -744,11 +747,11 @@ public static BoundingBoxXYZ GetBoundingBox(this GeometryObject geometry, Transf
{
if (!solid.Faces.IsEmpty)
{
var bbox = BoundingBoxXYZExtension.Empty;
if (coordSystem is object)
{
if (accurateSolid)
{
var bbox = BoundingBoxXYZExtension.Empty;
bbox.Transform = coordSystem;

foreach (Face face in solid.Faces)
Expand All @@ -761,7 +764,10 @@ public static BoundingBoxXYZ GetBoundingBox(this GeometryObject geometry, Transf
{
using (var transformed = SolidUtils.CreateTransformed(solid, coordSystem.Inverse))
{
var (min, max, transform, bounds) = transformed.GetBoundingBox();
bbox = transformed.GetBoundingBox();
if (bbox.IsNegative()) bbox = BoundingBoxXYZExtension.Empty;

var (min, max, transform, bounds) = bbox;
var (minX, minY, minZ) = transform.OfPoint(min);
var (maxX, maxY, maxZ) = transform.OfPoint(max);

Expand All @@ -774,7 +780,10 @@ public static BoundingBoxXYZ GetBoundingBox(this GeometryObject geometry, Transf
}
}
}
return solid.GetBoundingBox();

bbox = solid.GetBoundingBox();
if (bbox.IsNegative()) bbox = BoundingBoxXYZExtension.Empty;
return bbox;
}
}
break;
Expand Down
6 changes: 4 additions & 2 deletions src/RhinoInside.Revit/AssemblyResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -544,15 +544,17 @@ static Assembly GetRequestingAssembly()
int f = 0;
for (; f < frames.Length; ++f)
{
var frameAssembly = frames[f].GetMethod().DeclaringType.Assembly;
var method = frames[f].GetMethod();
var frameAssembly = method.DeclaringType?.Assembly ?? method.Module?.Assembly;
if (frameAssembly != callingAssembly)
break;
}

// Skip mscorlib
for (; f < frames.Length; ++f)
{
var frameAssembly = frames[f].GetMethod().DeclaringType.Assembly;
var method = frames[f].GetMethod();
var frameAssembly = method.DeclaringType?.Assembly ?? method.Module?.Assembly;
if (frameAssembly != typeof(object).Assembly)
return frameAssembly;
}
Expand Down

0 comments on commit c5b2588

Please sign in to comment.