admin 发表于 2024-7-11 15:49:41

ObjectARX计算重复的

double overlapInDir(AcDbEntity *pline1, AcDbEntity *pline2, const AcGeVector3d &vDir)
{       
        double angle = vDir.angleTo(AcGeVector3d::kXAxis, AcGeVector3d::kZAxis);
        AcGeMatrix3d mat;
        mat.setToRotation(-angle, AcGeVector3d::kZAxis);
               
        AcDbEntity *plineRot1=nullptr, *plineRot2=nullptr;
        Acad::ErrorStatus es;
        es = pline1->getTransformedCopy(mat, plineRot1);
        es = pline2->getTransformedCopy(mat, plineRot2);

        AcDbExtents ext1, ext2;
        es = plineRot1->getGeomExtents(ext1);
        es = plineRot2->getGeomExtents(ext2);
        delete plineRot1;
        delete plineRot2;
        double l1 = ext1.minPoint().x, r1 = ext1.maxPoint().x;
        double l2 = ext2.minPoint().x, r2 = ext2.maxPoint().x;
        double l = std::max(l1,l2), r = std::min(r1,r2);
        double overlap = r - l;

        return overlap;
}
页: [1]
查看完整版本: ObjectARX计算重复的