예제 #1
0
Acad::ErrorStatus
AcRectJig::setPlane()
{
    // Acquire current UCS transformation matrix.
    // We save the matrix for later use.
    //
    acdbUcsMatrix(mUcsToWcsMat);
    mWcsToUcsMat = mUcsToWcsMat.inverse();

    // Get data from user coordinate system.
    //
    AcGePoint3d orgPt;
    AcGeVector3d xAxis, yAxis, zAxis;
    mUcsToWcsMat.getCoordSystem(orgPt, xAxis, yAxis, zAxis);

    // Get the current elevation w.r.t current UCS, w.r.t the current space.
    //
    struct resbuf rb;
    ads_getvar(/*MSG0*/"CVPORT", &rb);
    double elev;
    if (rb.resval.rint == 1)
        elev = mpDb->pelevation();  // Paper space
    else
        elev = mpDb->elevation();   // Model space

    // Convert elevation from UCS to WCS.
    //
    orgPt += elev * zAxis;
    mElevation = zAxis.dotProduct(orgPt.asVector());
    mNormal = zAxis;
    mHorizDir = xAxis;
    mVertDir = mNormal.crossProduct(mHorizDir);
    return Acad::eOk;
}
void
ArxDbgUtils::getUcsToWcsMatrix(AcGeMatrix3d& m, AcDbDatabase* db)
{
	ASSERT(db != NULL);

	if (!acdbUcsMatrix(m, db)) {
		m.setToIdentity();
		ASSERT(0);
	}
}
예제 #3
0
void AcRectangle::list() const
{
    assertReadEnabled();
	AcDbEntity::list();

    AcGeMatrix3d ucsToWcsMat, wcsToUcsMat;
    acdbUcsMatrix(ucsToWcsMat);
    wcsToUcsMat = ucsToWcsMat.inverse();
    AcGePoint3d cenPt = mCenter;
    cenPt.transformBy(wcsToUcsMat);

    acutPrintf(_T("\nWidth:  %f"), mWidth);
    acutPrintf(_T("\nHeight: %f"), mHeight);
    acutPrintf(_T("\nCenter: X= %f, Y= %f, Z= %f"), cenPt.x, cenPt.y, cenPt.z);
    acutPrintf(_T("\nNormal: X= %f, Y= %f, Z= %f"), mNormal.x, mNormal.y, mNormal.z);
    acutPrintf("\n");
}
AcGeVector3d
ArxDbgUtils::getUcsZAxis(AcDbDatabase* db)
{
	ASSERT(db != NULL);

    AcGeMatrix3d m;

	if (acdbUcsMatrix(m, db)) {
		AcGePoint3d origin;
		AcGeVector3d xDir, yDir, zDir;

		m.getCoordSystem(origin, xDir, yDir, zDir);
		return zDir;
	}
	else {
		ASSERT(0);
		return AcGeVector3d::kZAxis;
	}
}
AcGePlane
ArxDbgUtils::getUcsPlane(AcDbDatabase* db)
{
	ASSERT(db != NULL);

    AcGeMatrix3d m;

	if (acdbUcsMatrix(m, db)) {
		AcGePoint3d origin;
		AcGeVector3d xDir, yDir, zDir;

		m.getCoordSystem(origin, xDir, yDir, zDir);
		AcGePlane ucsPlane(origin, xDir, yDir);
		return ucsPlane;
	}
	else {
		ASSERT(0);
        AcGePlane ucsPlane(AcGePoint3d::kOrigin, AcGeVector3d::kIdentity);
        return ucsPlane;
	}
}
void
ArxDbgUtils::getUcsToWcsOriginMatrix(AcGeMatrix3d& m,
                        const AcGePoint3d& wcsBasePt, AcDbDatabase* db)
{
	ASSERT(db != NULL);

    AcGeMatrix3d tmpMat;

	if (acdbUcsMatrix(tmpMat, db)) {
		AcGePoint3d origin;
		AcGeVector3d xDir, yDir, zDir;

		tmpMat.getCoordSystem(origin, xDir, yDir, zDir);
		origin += wcsBasePt.asVector();

	    m.setToAlignCoordSys(origin, xDir, yDir, zDir,
            AcGePoint3d::kOrigin, AcGeVector3d::kXAxis,
            AcGeVector3d::kYAxis, AcGeVector3d::kZAxis);
	}
	else {
		ASSERT(0);
        m = AcGeMatrix3d::kIdentity;
	}
}