Mon, 11/07/2022 - 20:56
With older occ versions i mirrored (maybe rather clumpsy) shapes by setting a TopLoc_Location
with a scale of -1.0, f.e. such a transformation matrix:
1 0 0
0 -1 0
0 0 1
or simply uniformly scaled shapes (mostly with values > 0).
Newer versions don't don't allow this because of this fix (0027457: Modeling - Raise exception if scaled transformation is used for shape location)
The fact is that use of transformations with non-unit scale factor in shape locations (e.g. method TopoDS_Shape::Moved()) is not well supported in OCCT: in most cases (especially if underlying geometry is elementary) this will lead to invalid shape, and most algorithms will fail due to being not able to handle effect of scaling on parameterization. It is quite regular that users get confused by this possibility (see e.g. https://github.com/tpaviot/oce/issues/615).
To prevent confusion, we can raise exception when scaled transformation is used for shape (e.g. in TopLoc_Location).
with this new source code which throws a domain error exception for such cases:
void Location (const TopLoc_Location& theLoc, const Standard_Boolean theRaiseExc = Standard_True)
{
const gp_Trsf& aTrsf = theLoc.Transformation();
if ((Abs(Abs(aTrsf.ScaleFactor()) - 1.) > TopLoc_Location::ScalePrec() || aTrsf.IsNegative()) && theRaiseExc)
{
//Exception
throw Standard_DomainError("Location with scaling transformation is forbidden");
}
else
{
myLocation = theLoc;
}
}
Is there another way to scale shapes (maybe also along X, Y, Z or even arbitrary axes) or, which might be a simpler case, "mirror" along X, Y, or Z?
Mon, 11/07/2022 - 23:57
Hello,
To make any tranformation on shape you can use "BRepBuilderAPI_Transform" which get gp_Trsf or "BRepBuilderAPI_GTransform" which get "gp_GTrsf".
Best regards, Dmitrii.
Tue, 11/08/2022 - 00:06
Use BRepBuilderAPI_Transform and BRepBuilderAPI_GTransform algorithms to perform such transformations.
Thu, 04/25/2024 - 05:50
Hi, when I read a step file into a label, get shape from label and scale my shape with BRepBuilderAPI_GTransform then assign it to the label, now all the attribute (name, material,..) is loss, how do I do it correctly?
Thu, 04/25/2024 - 10:36
Hello, replace operation for label is not accepted in general case.
When you get shape, you extract cascade labels. Modifications of shapes changes their cache code. As I know there is no fast solution for replace object in CAF. I think recreate tree will be better. And when you perform modification it is better to work with deep copy in that case.
Best regards, Dmitrii.
Thu, 04/25/2024 - 14:54
For modification transformation of label, please check XCAFDoc_Editor.
Best regards, Dmitrii.
Fri, 04/26/2024 - 09:33
Thank you very much!!!
Fri, 04/26/2024 - 10:10