Invaild Brep after transform

I’m having this same issue but with rhino8.16, was the cause found?

I was able to fix the issue using brep.Repair(0.01), but I’m still not sure why this is needed?

the transform that is causing my brep to become invalid is:
R0=(0.9950125627347625,0,-0.009999873742953282,0),
R1=(0,1,0,0),
R2=(8.673617379884035E-19,0,0.9949623121129386,0),
R3=(0,0,0,1)
^ result of transform.ToString()

As you can see, this transform is not doing much (scaling by about one percent along the (1,0,1) vector, then rotating to keep the xy plane flat), so It is strange that there would be issues.

Here is the geometry that is being broken by the transform.
problematicGeometry.3dm (1.0 MB)
Also, brep.Transform is returning true, so It seems like it should have succeeded.
Also, projecting some curves onto the invalid brep proved that it has the shape I expected, but it is invisible otherwise.

Rather re-opening a 6 year old topic, we should start a new one.

Hi @Nick_Drian,

Can you show me, in code, how you construct the transform?

Thanks,

– Dale

Here is the code for constructing the transform


// Create a transform for scaling non uniformly on some plane
// Scale factor XY = 1, scale factor Z = 0.99, layerNormal = (1,0,1)
Plane plane = new Plane(Point3d.Origin, layerNormal);
Transform scale = Transform.Scale(plane, scaleFactorXY, scaleFactorXY, scaleFactorZ);

// Add a rotation so that the world XY plane remains flat after transforming.
Plane transformed = Plane.WorldXY;
transformed.Transform(scale);
Transform toFlat = Transform.PlaneToPlane(transformed, Plane.WorldXY);

// This is the transform I used
scale = toFlat * scale;

Hi @Nick_Drian,

// Add a rotation so that the world XY plane remains flat after transforming.
Plane transformed = Plane.WorldXY;
transformed.Transform(scale);
Transform toFlat = Transform.PlaneToPlane(transformed, Plane.WorldXY);

The above makes no sense to me. Perhaps you can explain what this is supposed to be doing?

See the attached.

TestNick.cs (1.9 KB)

– Dale

The ‘scale’ matrix is scaling things non uniformly on some arbitrary plane. Depending on parameters, this transform may take points that are on the XY plane, and move them off the XY plane. This is not desirable. I want a flat base to remain flat, even after scaling.

I am fixing this issue by transforming the XY plane using the scale matrix, to see where it ends up, then using the XY planes new location to construct a rotation that will bring the base of the geometry back onto the world XY plane. As far as I can tell, the code that I have does what I intend.

Thanks for looking into this! And let me know if I can do anything else to help.

Hi @Nick_Drian, probably because you’re doing a sqishy transform on a complex brep which often causes errors with trims going out of tolerance. The error i got with your brep and transforms via code is:

Distance from start of ON_Brep.m_T[56] to 3d edge is 0.716099. (edge tol = 0.00449251, trim tol ~ 4.05504e-05).\n’)

I’ve only tested this with python but was able to prevent that the brep gets invalid by making it deformable before the transform using something like:

bcopy.MakeDeformable();

btw. using bcopy.SetTolerancesBoxesAndFlags(); seems to be quite expensive (0.414 sec) over here and resulted in a max brep edge tolerance of 0.74279645767 while bcopy.MakeDeformable(); runs in 0.001 sec with a max edge tolerance of 0.039309585937 …
_
c.

1 Like

Very interesting, this is exactly what I need, thanks Clement!