Пример #1
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();
}
Пример #2
0
void LinkedGEJunctionClosure_Helper( const AcGePoint3d& junctionPt )
{
    //acutPrintf(_T("\n闭合点:(%.3f, %.3f)"), junctionPt.x, junctionPt.y);
    AcDbObjectIdArray objIds;
    FindLinesByPoint( junctionPt, objIds );

    int len = objIds.length();
    //acutPrintf(_T("\n找到要处理闭合的分支个数:%d"), len);
    if( len < 1 ) return;

    EdgeInfo ges;
    BuildJunctionEdgeInfo( objIds, junctionPt, ges );          // 查找junctionPt坐标处的关联分支类图元
    if( ges.size() > 0 )
    {
        SortJunctionEdge( ges );                          // 调整顺序,按角度大小逆时针排列
        EdgeJunctionClosureImpl( junctionPt, ges );            // 处理并修改相邻巷道的参数
    }
    UpdateEdge( objIds );                                          // 更新实体
}