[分享] 继续提供ARX开发实用的函数代码
充填你的函数库,函数如下:static AcGePoint3d midPoint(const AcGePoint3d& pt1, const AcGePoint3d& pt2);
static AcGePoint3d wcsToUcs(const AcGePoint3d& pt);
static AcGeVector3d wcsToUcs(const AcGeVector3d& vec);
static void wcsToUcs(AcGePoint3dArray& ptArray);
static void wcsToUcs(AcGePoint2dArray& ptArray);
static AcGePoint3d ucsToWcs(const AcGePoint3d& pt);
static AcGePoint2ducsToWcs(const AcGePoint2d& pt);
static AcGeVector3d ucsToWcs(const AcGeVector3d& vec);
static void ucsToWcs(AcGePoint3dArray& ptArray);
static void ucsToWcs(AcGePoint2dArray& ptArray);
static AcGePoint3d ecsToWcs(const AcGePoint3d& pt, const AcGeVector3d& entNormal);
static AcGeVector3d ecsToWcs(const AcGeVector3d& vec, const AcGeVector3d& entNormal);
static AcGePoint2d ucsToDcs(const AcGePoint3d& pt);
static AcGePoint3d dcsToUcs(const AcGePoint2d& pt);
以下内容需要积分高于 100 才可浏览
/****************************************************************************
**
** XdGeUtils::midpoint
**
** **jma
**
*************************************/
AcGePoint3d
XdGeUtils::midPoint(const AcGePoint3d& pt1, const AcGePoint3d& pt2)
{
AcGePoint3d newPt;
newPt.x =(pt1.x + pt2.x) / 2.0;
newPt.y =(pt1.y + pt2.y) / 2.0;
newPt.z =(pt1.z + pt2.z) / 2.0;
return(newPt);
}
/****************************************************************************
**
** XdGeUtils::wcsToUcs
**
** **jma
**
*************************************/
AcGePoint3d
XdGeUtils::wcsToUcs(const AcGePoint3d& pt)
{
AcGeMatrix3d m;
XdDbUtils::getWcsToUcsMatrix(m);
return(m * pt);
}
/****************************************************************************
**
** XdGeUtils::wcsToUcs
**
** **jma
**
*************************************/
AcGeVector3d
XdGeUtils::wcsToUcs(const AcGeVector3d& vec)
{
AcGeMatrix3d m;
XdDbUtils::getWcsToUcsMatrix(m);
AcGeVector3d newv = vec;
newv.transformBy(m);
return(newv);
}
/****************************************************************************
**
** XdGeUtils::wcsToUcs
**
** **jma
**
*************************************/
void
XdGeUtils::wcsToUcs(AcGePoint3dArray& ptArray)
{
AcGeMatrix3d m;
XdDbUtils::getWcsToUcsMatrix(m);
int len = ptArray.length();
for (int i=0; i<len; i++)
ptArray = m * ptArray;
}
void
XdGeUtils::wcsToUcs(AcGePoint2dArray& ptArray)
{
AcGeMatrix3d m;
XdDbUtils::getWcsToUcsMatrix(m);
AcGePoint3dArray pt3d;
trans2DTo3D(&ptArray,pt3d);
int len = pt3d.length();
for (int i=0; i<len; i++)
pt3d = m * pt3d;
trans3DTo2D(&pt3d,ptArray);
}
/****************************************************************************
**
** XdGeUtils::ucsToWcs
**
** **jma
**
*************************************/
AcGePoint3d
XdGeUtils::ucsToWcs(const AcGePoint3d& pt)
{
AcGeMatrix3d m;
XdDbUtils::getUcsToWcsMatrix(m);
return(m * pt);
}
AcGePoint2d
XdGeUtils::ucsToWcs(const AcGePoint2d& pt)
{
AcGeMatrix3d m;
AcGePoint3d temp;
temp.set(pt.x,pt.y,0.0);
XdDbUtils::getUcsToWcsMatrix(m);
temp.transformBy(m);
AcGePoint2d p(temp.x,temp.y);
return(p);
}
/****************************************************************************
**
** XdGeUtils::ucsToWcs
**
** **jma
**
*************************************/
AcGeVector3d
XdGeUtils::ucsToWcs(const AcGeVector3d& vec)
{
AcGeMatrix3d m;
XdDbUtils::getUcsToWcsMatrix(m);
AcGeVector3d newv = vec;
newv.transformBy(m);
return(newv);
}
/****************************************************************************
**
** XdGeUtils::ucsToWcs
**
** **jma
**
*************************************/
void
XdGeUtils::ucsToWcs(AcGePoint3dArray& ptArray)
{
AcGeMatrix3d m;
XdDbUtils::getUcsToWcsMatrix(m);
int len = ptArray.length();
for (int i=0; i<len; i++)
ptArray = m * ptArray;
}
void
XdGeUtils::ucsToWcs(AcGePoint2dArray& ptArray)
{
AcGeMatrix3d m;
XdDbUtils::getUcsToWcsMatrix(m);
AcGePoint3dArray pt3d;
trans2DTo3D(&ptArray,pt3d,0.0);
int len = ptArray.length();
for (int i=0; i<len; i++)
pt3d = m * pt3d;
trans3DTo2D(&pt3d,ptArray);
return;
}
/************************************************************************
**
** XdGeUtils::ecsToWcs
**
** **jma
**
***************************************/
AcGePoint3d
XdGeUtils::ecsToWcs(const AcGePoint3d& pt, const AcGeVector3d& entNormal)
{
AcGeMatrix3d m;
XdDbUtils::getEcsToWcsMatrix(AcGePoint3d::kOrigin, entNormal, m);
return(m * pt);
}
/************************************************************************
**
** XdGeUtils::ecsToWcs
**
** **jma
**
***************************************/
AcGeVector3d
XdGeUtils::ecsToWcs(const AcGeVector3d& vec, const AcGeVector3d& entNormal)
{
AcGeMatrix3d m;
XdDbUtils::getEcsToWcsMatrix(AcGePoint3d::kOrigin, entNormal, m);
return(m * vec);
}
/************************************************************************
**
** XdGeUtils::dcsToUcs
**
** **jma
**
***************************************/
AcGePoint3d
XdGeUtils::dcsToUcs(const AcGePoint2d& pt)
{
resbuf fromRb, toRb;
ads采用point newPt;
fromRb.restype = RTSHORT;
fromRb.resval.rint = AcDb::kCurDisplayCS;
toRb.restype = RTSHORT;
toRb.resval.rint = AcDb::kUserCS;
short result = ads采用trans(asDblArray(pt), &fromRb, &toRb, FALSE, newPt);
ASSERT(result == RTNORM);
return(asPnt3d(newPt));
}
/************************************************************************
**
** XdGeUtils::ucsToDcs
**
** **jma
**
***************************************/
AcGePoint2d XdGeUtils::ucsToDcs(const AcGePoint3d& pt)
{
resbuf fromRb, toRb;
ads采用point newPt;
fromRb.restype = RTSHORT;
fromRb.resval.rint = AcDb::kUserCS;
toRb.restype = RTSHORT;
toRb.resval.rint = AcDb::kCurDisplayCS;
short result = ads采用trans(asDblArray(pt), &fromRb, &toRb, FALSE, newPt);
ASSERT(result == RTNORM);
return(asPnt2d(newPt));
}
页:
[1]