当前位置: 首页>>代码示例>>C++>>正文


C++ PNS_SEGMENT::Seg方法代码示例

本文整理汇总了C++中PNS_SEGMENT::Seg方法的典型用法代码示例。如果您正苦于以下问题:C++ PNS_SEGMENT::Seg方法的具体用法?C++ PNS_SEGMENT::Seg怎么用?C++ PNS_SEGMENT::Seg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PNS_SEGMENT的用法示例。


在下文中一共展示了PNS_SEGMENT::Seg方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getDanglingAnchor

OPT_VECTOR2I PNS_DIFF_PAIR_PLACER::getDanglingAnchor( PNS_NODE* aNode, PNS_ITEM* aItem )
{
    switch( aItem->Kind() )
    {
    case PNS_ITEM::VIA:
    case PNS_ITEM::SOLID:
        return aItem->Anchor( 0 );

    case PNS_ITEM::SEGMENT:
    {
        PNS_SEGMENT* s =static_cast<PNS_SEGMENT*>( aItem );

        PNS_JOINT* jA = aNode->FindJoint( s->Seg().A, s );
        PNS_JOINT* jB = aNode->FindJoint( s->Seg().B, s );

        if( jA->LinkCount() == 1 )
            return s->Seg().A;
        else if( jB->LinkCount() == 1 )
            return s->Seg().B;
        else
            return OPT_VECTOR2I();
    }

    default:
        return OPT_VECTOR2I();
        break;
    }
}
开发者ID:blairbonnett-mirrors,项目名称:kicad,代码行数:28,代码来源:pns_diff_pair_placer.cpp

示例2: anchorDirection

DIRECTION_45 PNS_DP_PRIMITIVE_PAIR::anchorDirection( PNS_ITEM* aItem, const VECTOR2I& aP ) const
{
    if( !aItem->OfKind ( PNS_ITEM::SEGMENT ) )
        return DIRECTION_45();

    PNS_SEGMENT* s = static_cast<PNS_SEGMENT*>( aItem );

    if( s->Seg().A == aP )
        return DIRECTION_45( s->Seg().A - s->Seg().B );
    else
        return DIRECTION_45( s->Seg().B - s->Seg().A );
}
开发者ID:OpenEE,项目名称:micad,代码行数:12,代码来源:pns_diff_pair.cpp

示例3: Log

void PNS_LOGGER::Log ( const PNS_ITEM* aItem, int aKind, const std::string aName )
{
	m_theLog << "aItem " << aKind << " " << aName << " ";
	m_theLog << aItem->Net() << " " << aItem->Layers().Start() << " " <<
	            aItem->Layers().End() << " " << aItem->Marker() << " " << aItem->Rank();

	switch( aItem->Kind() )
	{
		case PNS_ITEM::LINE:
		{
			PNS_LINE* l = (PNS_LINE*) aItem;
			m_theLog << " line ";
			m_theLog << l->Width() << " " << ( l->EndsWithVia() ? 1 : 0 ) << " ";
			dumpShape ( l->Shape() );
			m_theLog << std::endl;
			break;
		}

		case PNS_ITEM::VIA:
		{
			m_theLog << " via 0 0 "; 
			dumpShape ( aItem->Shape() );
			m_theLog << std::endl;
			break;
		}

		case PNS_ITEM::SEGMENT:
		{
			PNS_SEGMENT* s =(PNS_SEGMENT*) aItem;
			m_theLog << " line ";
			m_theLog << s->Width() << " 0 linechain 2 0 " << s->Seg().A.x << " " <<
			            s->Seg().A.y << " " << s->Seg().B.x << " " <<s->Seg().B.y << std::endl;
			break;
		}

		case PNS_ITEM::SOLID:
		{
			PNS_SOLID* s = (PNS_SOLID*) aItem;
			m_theLog << " solid 0 0 ";
			dumpShape( s->Shape() );
			m_theLog << std::endl;
			break;	
		}

		default:
		    break;
	}
}
开发者ID:LDavis4559,项目名称:kicad-source-mirror,代码行数:48,代码来源:pns_logger.cpp

示例4: while

const PNS_TOPOLOGY::JOINT_SET PNS_TOPOLOGY::ConnectedJoints( PNS_JOINT* aStart )
{
    std::deque<PNS_JOINT*> searchQueue;
    JOINT_SET processed;

    searchQueue.push_back( aStart );
    processed.insert( aStart );

    while( !searchQueue.empty() )
    {
        PNS_JOINT* current = searchQueue.front();
        searchQueue.pop_front();

        for( PNS_ITEM* item : current->LinkList() )
        {
            if( item->OfKind( PNS_ITEM::SEGMENT ) )
            {
                PNS_SEGMENT* seg = static_cast<PNS_SEGMENT*>( item );
                PNS_JOINT* a = m_world->FindJoint( seg->Seg().A, seg );
                PNS_JOINT* b = m_world->FindJoint( seg->Seg().B, seg );
                PNS_JOINT* next = ( *a == *current ) ? b : a;

                if( processed.find( next ) == processed.end() )
                {
                    processed.insert( next );
                    searchQueue.push_back( next );
                }
            }
        }
    }

    return processed;
}
开发者ID:RyuKojiro,项目名称:kicad-source-mirror,代码行数:33,代码来源:pns_topology.cpp

示例5: if

const VECTOR2I PNS_TOOL_BASE::snapToItem( PNS_ITEM* aItem, VECTOR2I aP, bool& aSplitsSegment )
{
    VECTOR2I anchor;

    if( !aItem )
    {
        aSplitsSegment = false;
        return aP;
    }

    switch( aItem->Kind() )
    {
    case PNS_ITEM::SOLID:
        anchor = static_cast<PNS_SOLID*>( aItem )->Pos();
        aSplitsSegment = false;
        break;

    case PNS_ITEM::VIA:
        anchor = static_cast<PNS_VIA*>( aItem )->Pos();
        aSplitsSegment = false;
        break;

    case PNS_ITEM::SEGMENT:
    {
        PNS_SEGMENT* seg = static_cast<PNS_SEGMENT*>( aItem );
        const SEG& s = seg->Seg();
        int w = seg->Width();

        aSplitsSegment = false;

        if( ( aP - s.A ).EuclideanNorm() < w / 2 )
            anchor = s.A;
        else if( ( aP - s.B ).EuclideanNorm() < w / 2 )
            anchor = s.B;
        else
        {
            anchor = s.NearestPoint( aP );
            aSplitsSegment = true;

            anchor = m_gridHelper->AlignToSegment( aP, s );
            aSplitsSegment = ( anchor != s.A && anchor != s.B );
        }

        break;
    }

    default:
        break;
    }

    return anchor;
}
开发者ID:blairbonnett-mirrors,项目名称:kicad,代码行数:52,代码来源:pns_tool_base.cpp

示例6: AssembleDiffPair

bool PNS_TOPOLOGY::AssembleDiffPair( PNS_ITEM* aStart, PNS_DIFF_PAIR& aPair )
{
    int refNet = aStart->Net();
    int coupledNet = DpCoupledNet( refNet );

    if( coupledNet < 0 )
        return false;

    std::set<PNS_ITEM*> coupledItems;

    m_world->AllItemsInNet( coupledNet, coupledItems );

    PNS_SEGMENT* coupledSeg = NULL, *refSeg;
    int minDist = std::numeric_limits<int>::max();

    if( ( refSeg = dyn_cast<PNS_SEGMENT*>( aStart ) ) != NULL )
    {
        for( PNS_ITEM* item : coupledItems )
        {
            if( PNS_SEGMENT* s = dyn_cast<PNS_SEGMENT*>( item ) )
            {
                if( s->Layers().Start() == refSeg->Layers().Start() && s->Width() == refSeg->Width() )
                {
                    int dist = s->Seg().Distance( refSeg->Seg() );
		    		bool isParallel = refSeg->Seg().ApproxParallel( s->Seg() );
                    SEG p_clip, n_clip;

                    bool isCoupled = commonParallelProjection( refSeg->Seg(), s->Seg(), p_clip, n_clip );

                    if( isParallel && isCoupled && dist < minDist )
                    {
                        minDist = dist;
                        coupledSeg = s;
                    }
                }
            }
        }
    }
    else
    {
        return false;
    }

    if( !coupledSeg )
        return false;

    PNS_LINE lp = m_world->AssembleLine( refSeg );
    PNS_LINE ln = m_world->AssembleLine( coupledSeg );

    if( DpNetPolarity( refNet ) < 0 )
    {
        std::swap( lp, ln );
    }

    int gap = -1;

    if( refSeg->Seg().ApproxParallel( coupledSeg->Seg() ) )
    {
        // Segments are parallel -> compute pair gap
        const VECTOR2I refDir       = refSeg->Anchor( 1 ) - refSeg->Anchor( 0 );
        const VECTOR2I displacement = refSeg->Anchor( 1 ) - coupledSeg->Anchor( 1 );
        gap = (int) std::abs( refDir.Cross( displacement ) / refDir.EuclideanNorm() ) - lp.Width();
    }

    aPair = PNS_DIFF_PAIR( lp, ln );
    aPair.SetWidth( lp.Width() );
    aPair.SetLayers( lp.Layers() );
    aPair.SetGap( gap );

    return true;
}
开发者ID:RyuKojiro,项目名称:kicad-source-mirror,代码行数:71,代码来源:pns_topology.cpp

示例7: CommitRouting

void PNS_ROUTER::CommitRouting( PNS_NODE* aNode )
{
    PNS_NODE::ITEM_VECTOR removed, added;

    aNode->GetUpdatedItems( removed, added );

    for( unsigned int i = 0; i < removed.size(); i++ )
    {
        BOARD_CONNECTED_ITEM* parent = removed[i]->Parent();

        if( parent )
        {
            m_view->Remove( parent );
            m_board->Remove( parent );
            m_undoBuffer.PushItem( ITEM_PICKER( parent, UR_DELETED ) );
        }
    }

    for( PNS_ITEM* item : added )
    {
        BOARD_CONNECTED_ITEM* newBI = NULL;

        switch( item->Kind() )
        {
        case PNS_ITEM::SEGMENT:
        {
            PNS_SEGMENT* seg = static_cast<PNS_SEGMENT*>( item );
            TRACK* track = new TRACK( m_board );
            const SEG& s = seg->Seg();

            track->SetStart( wxPoint( s.A.x, s.A.y ) );
            track->SetEnd( wxPoint( s.B.x, s.B.y ) );
            track->SetWidth( seg->Width() );
            track->SetLayer( ToLAYER_ID( seg->Layers().Start() ) );
            track->SetNetCode( seg->Net() > 0 ? seg->Net() : 0 );
            newBI = track;
            break;
        }

        case PNS_ITEM::VIA:
        {
            VIA* via_board = new VIA( m_board );
            PNS_VIA* via = static_cast<PNS_VIA*>( item );
            via_board->SetPosition( wxPoint( via->Pos().x, via->Pos().y ) );
            via_board->SetWidth( via->Diameter() );
            via_board->SetDrill( via->Drill() );
            via_board->SetNetCode( via->Net() > 0 ? via->Net() : 0 );
            via_board->SetViaType( via->ViaType() ); // MUST be before SetLayerPair()
            via_board->SetLayerPair( ToLAYER_ID( via->Layers().Start() ),
                                     ToLAYER_ID( via->Layers().End() ) );
            newBI = via_board;
            break;
        }

        default:
            break;
        }

        if( newBI )
        {
            item->SetParent( newBI );
            newBI->ClearFlags();
            m_view->Add( newBI );
            m_board->Add( newBI );
            m_undoBuffer.PushItem( ITEM_PICKER( newBI, UR_NEW ) );
            newBI->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
        }
    }

    m_board->GetRatsnest()->Recalculate();
    m_world->Commit( aNode );
}
开发者ID:RyuKojiro,项目名称:kicad-source-mirror,代码行数:72,代码来源:pns_router.cpp


注:本文中的PNS_SEGMENT::Seg方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。