Using on_xform to move and rotate a object one time

I want using On_xform to move and rotate a object one time,so I write a function like this,but this not work fine.

void MoveToAndRotate(ON_3dPoint from,ON_3dPoint to,ON_3dVector fromV,ON_3dVector toV,ON_3dPoint centerP,ON_Brep*brep,)
{
ON_Xform xform;
xform.Identity();
xform.Rotation(fromV,toV,centerP);
ON_3dVector v(to.x-from.x,to.y-from.y,to.z-from.z);
xform.Translation(v);

brep->Transform(xform);//just Transform One Time

}

Can you explain what exactly is going wrong? I’ve never used openNURBS explicitly, but a cursory look at the source leads me to believe that you’re overwriting xform each time you call one of its methods, not compounding them; i.e. your call to xform.Translation is making the matrix you’re transforming with a translation ONLY. I would try something like the following:

ON_Xform xTranslation;
ON_Xform xRotation;
xTranslation.Translation(v);
xRotation.Rotation(…);
brep->Transform(xTranslation*xRotation);

(I believe the * operator is overloaded for transforms)

Something like this would do the trick.

ON_Xform xf_translate(1), xf_scale(1), ON_Xform xform_rotate(1);

// TODO: define transformations here

// Final transformation
ON_Xform xf_final = xf_translate * xf_scale * xf_rotate;

// TODO: transform geometry