From 0406f236a1c77003d872ddc0b424f7bdbff88172 Mon Sep 17 00:00:00 2001 From: Pawel Baran Date: Mon, 4 Nov 2019 20:54:44 +0100 Subject: [PATCH 1/2] Preview for trimmed surfaces added --- Grasshopper_Engine/Compute/RenderMeshes.cs | 2 +- Grasshopper_Engine/Compute/RenderWires.cs | 4 ++-- Grasshopper_Engine/Convert/FromGoo.cs | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Grasshopper_Engine/Compute/RenderMeshes.cs b/Grasshopper_Engine/Compute/RenderMeshes.cs index 7ef33499..e54c316a 100644 --- a/Grasshopper_Engine/Compute/RenderMeshes.cs +++ b/Grasshopper_Engine/Compute/RenderMeshes.cs @@ -160,7 +160,7 @@ public static void RenderMeshes(BHG.Loft surface, Rhino.Display.DisplayPipeline public static void RenderMeshes(BHG.NurbsSurface surface, Rhino.Display.DisplayPipeline pipeline, DisplayMaterial material) { - pipeline.DrawBrepShaded(RHG.Brep.CreateFromSurface(surface.ToRhino()), material); + pipeline.DrawBrepShaded(surface.ToRhino(), material); } /***************************************************/ diff --git a/Grasshopper_Engine/Compute/RenderWires.cs b/Grasshopper_Engine/Compute/RenderWires.cs index 75daa936..17774437 100644 --- a/Grasshopper_Engine/Compute/RenderWires.cs +++ b/Grasshopper_Engine/Compute/RenderWires.cs @@ -156,8 +156,8 @@ public static void RenderWires(BHG.Loft surface, Rhino.Display.DisplayPipeline p public static void RenderWires(BHG.NurbsSurface surface, Rhino.Display.DisplayPipeline pipeline, Color bhColour) { - RHG.Surface rSurface = surface.ToRhino(); - pipeline.DrawSurface(rSurface, bhColour, 2); + RHG.Brep rSurface = surface.ToRhino(); + pipeline.DrawBrepWires(rSurface, bhColour, 2); } /***************************************************/ diff --git a/Grasshopper_Engine/Convert/FromGoo.cs b/Grasshopper_Engine/Convert/FromGoo.cs index b5d7099d..66cdb5e3 100644 --- a/Grasshopper_Engine/Convert/FromGoo.cs +++ b/Grasshopper_Engine/Convert/FromGoo.cs @@ -75,7 +75,8 @@ public static T FromGoo(this GH_Surface goo, IGH_TypeHint hint = null) Brep brep = goo.ScriptVariable() as Brep; if (brep.IsSurface) return (T)(brep.Faces[0].UnderlyingSurface() as dynamic); - return default(T); + else + return (T)(brep as dynamic); } } } From d7b3a1b61cdec3fc3dbd189c487bdd30f6e5f196 Mon Sep 17 00:00:00 2001 From: Pawel Baran Date: Mon, 4 Nov 2019 21:11:58 +0100 Subject: [PATCH 2/2] Fix --- Grasshopper_Engine/Compute/RenderMeshes.cs | 6 +++++- Grasshopper_Engine/Compute/RenderWires.cs | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Grasshopper_Engine/Compute/RenderMeshes.cs b/Grasshopper_Engine/Compute/RenderMeshes.cs index e54c316a..5a51db57 100644 --- a/Grasshopper_Engine/Compute/RenderMeshes.cs +++ b/Grasshopper_Engine/Compute/RenderMeshes.cs @@ -160,7 +160,11 @@ public static void RenderMeshes(BHG.Loft surface, Rhino.Display.DisplayPipeline public static void RenderMeshes(BHG.NurbsSurface surface, Rhino.Display.DisplayPipeline pipeline, DisplayMaterial material) { - pipeline.DrawBrepShaded(surface.ToRhino(), material); + RHG.GeometryBase geometry = surface.ToRhino(); + if (geometry is RHG.Surface) + geometry = RHG.Brep.CreateFromSurface((RHG.Surface)geometry); + + pipeline.DrawBrepShaded((RHG.Brep)geometry, material); } /***************************************************/ diff --git a/Grasshopper_Engine/Compute/RenderWires.cs b/Grasshopper_Engine/Compute/RenderWires.cs index 17774437..0f0c0d9b 100644 --- a/Grasshopper_Engine/Compute/RenderWires.cs +++ b/Grasshopper_Engine/Compute/RenderWires.cs @@ -156,8 +156,11 @@ public static void RenderWires(BHG.Loft surface, Rhino.Display.DisplayPipeline p public static void RenderWires(BHG.NurbsSurface surface, Rhino.Display.DisplayPipeline pipeline, Color bhColour) { - RHG.Brep rSurface = surface.ToRhino(); - pipeline.DrawBrepWires(rSurface, bhColour, 2); + RHG.GeometryBase geometry = surface.ToRhino(); + if (geometry is RHG.Surface) + geometry = RHG.Brep.CreateFromSurface((RHG.Surface)geometry); + + pipeline.DrawBrepWires((RHG.Brep)geometry, bhColour, 2); } /***************************************************/