优化 transfromRegion:旋转与平移合成一次 region 变换(E3)

原来对 AcDbRegion 连做两次 transformBy(先转到平面、再平移),
region 是 ACIS body,每次变换都要重建拓扑,而该函数在
DrawPipe(pCurve, pRegion, ptCenInRgn) 里每个管件都会调用。

改为先算出 ptOnRegion 变换后的落点,把平移量用 preMultBy 合成进
同一个矩阵,region 只做一次 ACIS 变换;顺带删掉 plan.get(pt0,pt1,pt2)
这三个未使用的局部变量。
This commit is contained in:
gjm committed 2026-10-25 19:16:43 +08:00
1 parent bc7bf7b15b
commit 86bb3b778a
1 file changed
+7 -14
@@ -223,27 +223,20 @@ AECDLLIMPEXP void GiDrawUtility::transfromRegion(AcDbRegion *pRegion
{
AcGePlane plan;
plan.set(ptOnPlan, vtNormal);
AcGePoint3d pt0, pt1, pt2;
plan.get(pt0, pt1, pt2);
AcGeMatrix3d xform;
xform.setToPlaneToWorld(plan);
// 把region转到此面上
pRegion->transformBy(xform);
// 把 region 上的点也转到面上
// 先把 region 上的点转到面上,求出还需要平移多少
AcGePoint3d pt(ptOnRegion);
pt.transformBy(xform);
// 再把region在面上平移
AcGeVector3d vtm = ptOnPlan - pt;
if (!vtm.isZeroLength())
{
xform.setToIdentity();
xform.setToTranslation(ptOnPlan - pt);
pRegion->transformBy(xform);
}
// 旋转与平移合成一个矩阵,region 只做一次 ACIS 变换
AcGeMatrix3d matMove;
matMove.setToTranslation(ptOnPlan - pt);
xform.preMultBy(matMove);
pRegion->transformBy(xform);
}
AECDLLIMPEXP AcGeMatrix3d GiDrawUtility::RotateAndMove(const AcGeVector3d &vtOrig