示例#1
0
Acad::ErrorStatus
ArxDbgDbEntity::setNormal(const AcGeVector3d& nvec)
{
    if (nvec.isZeroLength()) {
        ASSERT(0);
        return Acad::eInvalidInput;
    }

    if (nvec != m_zDir) {
        assertWriteEnabled();

        AcGeVector3d txdir, tydir;
        AcGeVector3d txdiro, tydiro;

        ArxDbgUtils::getEcsXAxis(nvec, txdir);       // get AutoCAD's arbitrary X-Axis for this normal
        ArxDbgUtils::getEcsXAxis(m_zDir, txdiro);    // get AutoCAD's arbitrary X-Axis for this normal

        tydir = nvec.crossProduct(txdir);
        tydir.normalize();

        tydiro = m_zDir.crossProduct(txdiro);
        tydiro.normalize();

        AcGeMatrix3d mat;
        mat.setToAlignCoordSys(m_origin, txdiro, tydiro, m_zDir,
                               m_origin, txdir,  tydir,  nvec);

        m_xDir.transformBy(mat);
        m_zDir.transformBy(mat);
        m_origin.transformBy(mat);
    }

    return Acad::eOk;
}
/*!
* 根据已经输入到类中的参数,修正终点和偏心方向,使其值正确。
*
* @param none
*
* @return Acad::ErrorStatus  : 永远为Acad::eOk
*/
Acad::ErrorStatus PDEcone::CalActParameter()
{
    assertWriteEnabled();
    AcGeVector3d centerVect = (m_ptEnd - m_ptStart).normalize();
    if(centerVect.isZeroLength() && m_vect.isZeroLength())
    {
        m_ptEnd = m_ptStart + AcGeVector3d(0, 0, 1);
        m_vect.set(1, 0, 0);
    }
    else if(centerVect.isZeroLength())
    {
        AcGeVector3d Wy(0, 1, 0), Wz(0, 0, 1), Ax;// Ay;
        if (fabs(m_vect[X]) <1.0/64 && fabs(m_vect[Y])<1.0/64) 
            Ax = Wy.crossProduct(m_vect);
        else
            Ax = Wz.crossProduct(m_vect);
        Ax.normalize();
        //Ay = vect.crossProduct(Ax);
        //Ay.normalize();

        m_ptEnd = m_ptStart + Ax;
    }
    else if(m_vect.isZeroLength() || m_vect.isParallelTo(centerVect))
    {
        AcGeVector3d Wy(0, 1, 0), Wz(0, 0, 1), Ax;// Ay;
        if (fabs(centerVect[X]) <1.0/64 && fabs(centerVect[Y])<1.0/64) 
            Ax = Wy.crossProduct(centerVect);
        else
            Ax = Wz.crossProduct(centerVect);
        Ax.normalize();
        //Ay = vect.crossProduct(Ax);
        //Ay.normalize();

        m_vect = Ax;
    }
    return Acad::eOk;
}
示例#3
0
Acad::ErrorStatus
ArxDbgDbEntity::moveGripPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset)
{
    if (offset.isZeroLength() == Adesk::kTrue)
        return Acad::eInvalidOffset;

    if (indices.length() == 1) {
        if (indices[0] == 0) {
            setLocation(m_origin + offset);
            return Acad::eOk;
        }
    }

    return Acad::eOk;
}
示例#4
0
// 至少需要2个元素才能正确的闭合
static void EdgeJunctionClosureImpl( const AcGePoint3d& junctionPt, EdgeInfo& ges )
{
    //acutPrintf(_T("\n队列中的元素个数:%d"), ges.size());
    if( ges.size() == 1 )
    {
        ges.push_back( ges.front() );
    }

    // 把第1个添加到末尾,构成循环
    ges.push_back( ges.front() );

    // 记录每次处理闭合的当前向量
    AcGeVector3d v3 = ges.front().angle;
    v3.rotateBy( PI / 2, AcGeVector3d::kZAxis );

    AcTransaction* pTrans = actrTransactionManager->startTransaction();
    if( pTrans == 0 ) return;

    for( EdgeInfoIter itr = ges.begin(); itr != ges.end(); itr++ )
    {
        EdgeInfoIter itr2 = itr + 1;
        if( itr2 == ges.end() ) break;

        //acutPrintf(_T("\n巷道1角度:%.3f, 巷道2角度:%.3f"),
        //	itr->angle.angleTo(AcGeVector3d::kXAxis, -AcGeVector3d::kZAxis),
        //	itr2->angle.angleTo(AcGeVector3d::kXAxis, -AcGeVector3d::kZAxis));

        AcGeVector3d cv = itr->angle.crossProduct( itr2->angle ); // 叉乘(如果夹角等=0或PI,则向量=0)
        //if(cv.length() > 0.001)
        if( !cv.isZeroLength() )
        {
            //acutPrintf(_T("\n叉乘长度=%.3f"), cv.length());
            //v3 = CaclAverageVector3(itr->angle, itr2->angle);
            v3 = CaclAverageVector2( itr->angle, 1, itr2->angle, 1 );
        }
        else
        {
            // 平行(夹角=0或PI)
            //acutPrintf(_T("\n叉乘=0"));
            v3.negate();
        }

        DealWithBoundary2( pTrans, *itr, junctionPt, v3 );
        DealWithBoundary2( pTrans, *itr2, junctionPt, v3 );
    }
    actrTransactionManager->endTransaction();
}