变换函数
该类提供两个转换函数。该函数将矩阵应用于实体。该函数使实体能够返回应用了转换的自身副本。AcDbEntitytransformBy()getTransformedCopy() 如果实体是均匀缩放和正交的,则函数的默认实现将克隆该实体,然后在克隆的实体上调用该函数。(使用该函数确定输入矩阵是否均匀缩放和正交。AcDbEntity::getTransformedCopy()transformBy()AcGeMatrix3d::isUniScaledOrtho() 若要修改默认行为,请重写自定义实体和函数,它们分别由 和 调用。subGetTransformedCopy()subTransformBy()getTransformedCopy()transformBy() 自定义类重写函数和函数。当不均匀缩放时,它将成为折线。AsdkPolysubTransformBy()subGetTransformedCopy()AsdkPoly
Acad::ErrorStatus
AsdkPoly::subTransformBy(const AcGeMatrix3d& xform)
{
// If we're dragging, we aren't really going to change our
// data, so we don't want to make an undo recording nor do
// we really care if the object's open for write.
//
if (mDragDataFlags & kCloneMeForDraggingCalled) {
mDragDataFlags |= kUseDragCache;
mDragPlaneNormal = mPlaneNormal;
mDragElevation = mElevation;
AcGeMatrix2d xform2d(xform.convertToLocal(mDragPlaneNormal,
mDragElevation));
mDragCenter = mCenter;
mDragCenter.transformBy(xform2d);
mDragStartPoint = mStartPoint;
mDragStartPoint.transformBy(xform2d);
mDragPlaneNormal.normalize();
} else {
assertWriteEnabled();
AcGeMatrix2d xform2d(xform.convertToLocal(mPlaneNormal,
mElevation));
mCenter.transformBy(xform2d);
mStartPoint.transformBy(xform2d);
mPlaneNormal.normalize();
}
return Acad::eOk;
}
// Transform points and create a polyline out of them.
//
Acad::ErrorStatus AsdkPoly::subGetTransformedCopy(
const AcGeMatrix3d& mat,
AcDbEntity*& ent) const
{
assertReadEnabled();
Acad::ErrorStatus es = Acad::eOk;
AcGePoint3dArray vertexArray;
if ((es = getVertices3d(vertexArray))
!= Acad::eOk)
{
return es;
}
for (int i = 0; i < vertexArray.length(); i++) {
vertexArray[i].transformBy(mat);
}
AcDbSpline *pSpline = NULL;
if ((es = rx_makeSpline(vertexArray, pSpline))
!= Acad::eOk)
{
return es;
}
assert(pSpline != NULL);
pSpline->setPropertiesFrom(this);
ent = pSpline;
return es;
}
父主题: |
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-30 23:17
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.