Rhino 8 ShrinkWrap component

Rhino 8 ShrinkWrap component: Offset and smoothing has no effect

2 Likes

hi @seghierkhaled
i Test by c# and offset and other option not effect too
and one question that:
*how do you Created PointCloude Like Point Cloud (P:7)? in python Code
i created by
var pc=new PointCloud( IEnumerable<Point3d> pt);
but the output not Set to Geometry input in ShrinkWrap Component in GrasshopperRhino.Geometry.PointCloudItem

srink wrap.gh (102.7 KB)

 private void RunScript(
	IEnumerable<Point3d> x,
	double edge,
	double offset,
	int Smoothing,
	int Optimization,
	bool FillHoles,
	out object a)
  {var pc=new PointCloud(x);
    var s=new ShrinkWrapParameters();
  s.TargetEdgeLength=edge;
  s.SmoothingIterations=Smoothing;
  s.Offset=offset;
  s.FillHolesInInputObjects=FillHoles;
  s.PolygonOptimization=Optimization;
   var m=Mesh.ShrinkWrap(pc,s);
    a = m;
  }

1 Like

Hi @Rh-3d-p

import Rhino.Geometry as rg

def PointsToCloud(pts):
    cloud = rg.PointCloud()
    for p in pts:
        cloud.Add(rg.Point3d(p.X,p.Y,p.Z))
    return [cloud]

a = PointsToCloud(points)
1 Like

Thanks
and in C# is True:
But in ShrinkWrap Offset and other Option not effect and have bug(in Grasshopper Component and C# Api Code)
@Gijs @wim

    private void RunScript(IEnumerable<Point3d> pt, out object a)
  {
 a= PointsToCloud(pt.ToList());
 
  }


public List<PointCloud> PointsToCloud(List<Point3d> pts)
{
    PointCloud cloud = new PointCloud();
    foreach (Point3d p in pts)
    {
        cloud.Add(new Point3d(p.X, p.Y, p.Z));
    }
    return new List<PointCloud> { cloud };
}
1 Like

In PointCloud object there are constructors as well as .AddRange methods that directly accept IEnumerable.


… a list of pointclouds?

2 Likes

Yes @maje90 , when input=PointCloud() separates result and when input=List<PointCloud> union result in ShrinkWrap

1 Like

@anon39580149
ShrinkWrap (offset and other Option)can be active when 2 Step :
first Created Mesh ShrinkWrap from PointCloud
Then pass the result to new ShrinkWrapComponent to offset effect
shrink wrap-cloudeto-N2- step.gh (23.8 KB)

1 Like

ShrinkWrap must work with pointcloud like in Rhino
I think this is a bug

2 Likes

Yes i think it is bug too because in construction APi no refer to it
@Trav
@BrianJ

1 Like

The component fixed in Rhino 8.1.23325

1 Like

hi
@anon39580149 i test the Component tn Rhino 8.2 and not fix error yet!

1 Like

In R8.1 and R8.2, It is certainly something related to point cloud. So the work around is to use 2 shrinkwrap component
And for the point cloud use Point Cloud attributes to make A point cloud


shrinkwrap R8.gh (5.5 KB)

It works for brep geometry

1 Like

hi @laurent_delrieu it is true and we can fix and mix this error in this c# Component:
SHRINK WRAP.gh (62.5 KB)

 private void RunScript(
	IEnumerable<Point3d> points,
	IEnumerable<Mesh> Mesh,
	double edge,
	double offset,
	int Smoothing,
	int Optimization,
	bool FillHoles,
	bool mix,
	out object Meshes,
	out object a)
  {Component.Name="ShrinkWrap";Component.NickName="C# ShrinkWrap";
 a=null;
 Meshes=null;
var m2=new Mesh();var m3=new Mesh();var m4=new List<Mesh>();var m5=new Mesh();
if( Component.Params.Input[0].VolatileDataCount != 0 ){
var m=wrap.shrinkPt(points.ToList(),edge,Smoothing,offset,Optimization,FillHoles);
 m2=wrap.shrinkM(new List<Mesh>(){m},edge,Smoothing,offset,Optimization,FillHoles);
Meshes=m2;
}
if(Mesh!=null){
 m3=wrap.shrinkM(Mesh.ToList(),edge,Smoothing,offset,Optimization,FillHoles);
Meshes=m3;
}
if(m2!=null && m3!=null){
m4.Add(m2);m4.Add(m3);Meshes=m4;
if(mix){
 m5=wrap.shrinkM(m4,edge,Smoothing,offset,Optimization,FillHoles);
Meshes=m5;
}

}


  }
public static class wrap{
public static Mesh shrinkM(List<Mesh> mesh,double edge,int Smoothing,double offset,int Optimization,bool FillHoles ){

 var s=new ShrinkWrapParameters();
  s.TargetEdgeLength=edge;
  s.SmoothingIterations=Smoothing;
  s.Offset=offset;
  s.FillHolesInInputObjects=FillHoles;
  s.PolygonOptimization=Optimization;
var m=Mesh.ShrinkWrap(mesh ,s);
return m;

}
public static Mesh shrinkPt(List<Point3d> pts,double edge,int Smoothing,double offset,int Optimization,bool FillHoles ){
var pc=new PointCloud(pts);
 var s=new ShrinkWrapParameters();
  s.TargetEdgeLength=edge;
  s.SmoothingIterations=Smoothing;
  s.Offset=offset;
  s.FillHolesInInputObjects=FillHoles;
  s.PolygonOptimization=Optimization;
var m=Mesh.ShrinkWrap(pc ,s);
return m;

}}

}

1 Like

This does appear to be a bug. I’ve created a YT to track this issue. I’ll look into it right away.

2 Likes

And as there is a bug tracker I also noticed this one
If Edge length is 0.7 there is no output but there is an output with other values




shrinkwrap R8. buggh.gh (6.6 KB)

1 Like

Got it. I think we’ve found the issue and are working to resolve it.

1 Like

yeah its my fault, apparently when doing the point clouds i left out the secondary smoothing and offsetting operations in the RhinoCommon function for point clouds which is what Grasshoppers component is utilizing… I’ve added this to my short list of things to do next. The weird .7 thing is up for examination as well.

4 Likes

Hello,
I try to use shrinkWrap in gh but I don’t have the seme result in Gh or in Rhino…

in rhino i’ve got that:

and in gh i’ve got this:

I use Version 8 SR5 (8.5.24072.13001, 2024-03-12)
an idea…

1 Like

The G input is a data tree and unless you flatten it, the objects in your tree are handled separately.

RMB the G input and then click flatten…

3 Likes

Of course!!! Thanks :+1:

2 Likes