From 86bb3b778ac6f652e674cf0ec8b66d4370467eee Mon Sep 17 00:00:00 2001 From: LittleGuo Date: Sun, 25 Oct 2026 19:16:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20transfromRegion=EF=BC=9A?= =?UTF-8?q?=E6=97=8B=E8=BD=AC=E4=B8=8E=E5=B9=B3=E7=A7=BB=E5=90=88=E6=88=90?= =?UTF-8?q?=E4=B8=80=E6=AC=A1=20region=20=E5=8F=98=E6=8D=A2=EF=BC=88E3?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原来对 AcDbRegion 连做两次 transformBy(先转到平面、再平移), region 是 ACIS body,每次变换都要重建拓扑,而该函数在 DrawPipe(pCurve, pRegion, ptCenInRgn) 里每个管件都会调用。 改为先算出 ptOnRegion 变换后的落点,把平移量用 preMultBy 合成进 同一个矩阵,region 只做一次 ACIS 变换;顺带删掉 plan.get(pt0,pt1,pt2) 这三个未使用的局部变量。 --- .../Code2026/AecRxBase/GiDrawUtility.cpp | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/SourceCode/Code2026/AecRxBase/GiDrawUtility.cpp b/SourceCode/Code2026/AecRxBase/GiDrawUtility.cpp index 59c5931..931cb3e 100644 --- a/SourceCode/Code2026/AecRxBase/GiDrawUtility.cpp +++ b/SourceCode/Code2026/AecRxBase/GiDrawUtility.cpp @@ -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 -- 2.54.0