scale of a curve

Dear all,

I am working on scaling a curve only in x direction and the Y and Z value of the curve keep the same. The class used is BRepBuilderAPI_Transform which required a gp_Trsf as an iput. However, the SetScale() function in gp_Trsf only accept a scale center and a scale value. It can not do this job.

Does anyone know how to make this happen in OCCT? Thanks in advance!


Mauro Mariotti's picture

You need a gp_GTrsf to describe that "stretching" transformation.
We convert the curve to NURBS and transform its control points, but maybe there is a class which does it.


Haiqiang's picture

Hi Mauro,

Thanks! Indeed it needs the gp_GTrsf.


Andrey Pozdeev's picture

//you need to define a vector for the X direction, (it could be facing any direction):

gp_Vector dir(1,0,0);

//define a center of scaling, used the origin here, but use the center of gravity of the object

gp_Pnt center(0,0,0)

//create a gp_Ax2 using the center point of scaling and the X vector

gp_Ax2 xdir(center, dir);

//create a transform using the 2axis system and the scaling amount x

gp_GTrsf x_aff;

// apply transform to shape

BRepBuilderAPI_GTransform aBRepGTrsf(theobj, x_aff,Standard_False);

//get the result


Haiqiang's picture

Hi AP,

Thanks for the piece of codes. It works!