pythonocc-core
pythonocc-core copied to clipboard
Brep transformation doesn't seem to have any effect
I'm trying to transform a Brep represented by a TopoDS_Solid but either the transformation doesn't work (or I'm doing it wrong) or I'm looking at the wrong properties.
As a minimal example, I'm using a simple box brep from this zipped STEP file, and a simple translation matrix.
> occ_brep
<class 'TopoDS_Solid'>
The transformation matrix
t = gp_Trsf()
t.SetValues(
1., 0., 0., 4.,
0., 1., 0., 3.,
0., 0., 1., 0.,
)
I'm expecting to see the effect in occ_brep.Location().Transformation(). Prior to the transformation, the values of Transformation() are as follows:
> l = occ_brep.Location().Transformation()
> print(f"{l.Value(1,1)} - {l.Value(1,2)} - {l.Value(1,3)}")
> print(f"{l.Value(2, 1)} - {l.Value(2, 2)} - {l.Value(2, 3)}")
> print(f"{l.Value(3, 1)} - {l.Value(3, 2)} - {l.Value(3, 3)}\n")
1.0 - 0.0 - 0.0
0.0 - 1.0 - 0.0
0.0 - 0.0 - 1.0
As per the examples I could find, I am using BRepBuilderAPI_Transform to apply the transformation:
builder = BRepBuilderAPI_Transform(occ_brep, t, False)
Printing occ_brep.Location().Transformation() after that shows the values have not changed.
> l = occ_brep.Location().Transformation()
> print(f"{l.Value(1,1)} - {l.Value(1,2)} - {l.Value(1,3)}")
> print(f"{l.Value(2, 1)} - {l.Value(2, 2)} - {l.Value(2, 3)}")
> print(f"{l.Value(3, 1)} - {l.Value(3, 2)} - {l.Value(3, 3)}\n")
1.0 - 0.0 - 0.0
0.0 - 1.0 - 0.0
0.0 - 0.0 - 1.0
I've tried the following variation as well:
builder = BRepBuilderAPI_Transform(occ_brep, t, False)
builder.Perform(occ_brep)
builder.Shape().Location().Transformation as well as builder.ModifiedShape().Location().Transformation are also unchanged.
Using occ_brep.Move(TopLoc_Location(t)) directly also made no difference.
Would appreciate any help understanding what I'm doing wrong. Thanks!