Simplification in prep for fixing some via dragging issues.
There should be no change in logic with this commit.
This commit is contained in:
parent
29e9b9f792
commit
8c77d31d4d
|
@ -42,9 +42,7 @@ void SHOVE::replaceItems( ITEM* aOld, std::unique_ptr< ITEM > aNew )
|
||||||
OPT_BOX2I changed_area = ChangedArea( aOld, aNew.get() );
|
OPT_BOX2I changed_area = ChangedArea( aOld, aNew.get() );
|
||||||
|
|
||||||
if( changed_area )
|
if( changed_area )
|
||||||
{
|
m_affectedArea = m_affectedArea ? m_affectedArea->Merge( *changed_area ) : *changed_area;
|
||||||
m_affectedAreaSum = m_affectedAreaSum ? m_affectedAreaSum->Merge( *changed_area ) : *changed_area;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_currentNode->Replace( aOld, std::move( aNew ) );
|
m_currentNode->Replace( aOld, std::move( aNew ) );
|
||||||
}
|
}
|
||||||
|
@ -54,9 +52,7 @@ void SHOVE::replaceLine( LINE& aOld, LINE& aNew )
|
||||||
OPT_BOX2I changed_area = ChangedArea( aOld, aNew );
|
OPT_BOX2I changed_area = ChangedArea( aOld, aNew );
|
||||||
|
|
||||||
if( changed_area )
|
if( changed_area )
|
||||||
{
|
m_affectedArea = m_affectedArea ? m_affectedArea->Merge( *changed_area ) : *changed_area;
|
||||||
m_affectedAreaSum = m_affectedAreaSum ? m_affectedAreaSum->Merge( *changed_area ) : *changed_area;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_currentNode->Replace( aOld, aNew );
|
m_currentNode->Replace( aOld, aNew );
|
||||||
}
|
}
|
||||||
|
@ -126,7 +122,6 @@ SHOVE::SHOVE_STATUS SHOVE::walkaroundLoneVia( LINE& aCurrent, LINE& aObstacle, L
|
||||||
const SHAPE_LINE_CHAIN hull = aCurrent.Via().Hull( clearance, aObstacle.Width() );
|
const SHAPE_LINE_CHAIN hull = aCurrent.Via().Hull( clearance, aObstacle.Width() );
|
||||||
SHAPE_LINE_CHAIN path_cw;
|
SHAPE_LINE_CHAIN path_cw;
|
||||||
SHAPE_LINE_CHAIN path_ccw;
|
SHAPE_LINE_CHAIN path_ccw;
|
||||||
VECTOR2I dummy;
|
|
||||||
|
|
||||||
if( ! aObstacle.Walkaround( hull, path_cw, true ) )
|
if( ! aObstacle.Walkaround( hull, path_cw, true ) )
|
||||||
return SH_INCOMPLETE;
|
return SH_INCOMPLETE;
|
||||||
|
@ -558,8 +553,7 @@ bool SHOVE::reduceSpringback( const ITEM_SET& aHeadSet )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SHOVE::pushSpringback( NODE* aNode, const ITEM_SET& aHeadItems,
|
bool SHOVE::pushSpringback( NODE* aNode, const OPT_BOX2I& aAffectedArea )
|
||||||
const COST_ESTIMATOR& aCost, const OPT_BOX2I& aAffectedArea )
|
|
||||||
{
|
{
|
||||||
SPRINGBACK_TAG st;
|
SPRINGBACK_TAG st;
|
||||||
OPT_BOX2I prev_area;
|
OPT_BOX2I prev_area;
|
||||||
|
@ -568,8 +562,6 @@ bool SHOVE::pushSpringback( NODE* aNode, const ITEM_SET& aHeadItems,
|
||||||
prev_area = m_nodeStack.back().m_affectedArea;
|
prev_area = m_nodeStack.back().m_affectedArea;
|
||||||
|
|
||||||
st.m_node = aNode;
|
st.m_node = aNode;
|
||||||
st.m_cost = aCost;
|
|
||||||
st.m_headItems = aHeadItems;
|
|
||||||
|
|
||||||
if( aAffectedArea )
|
if( aAffectedArea )
|
||||||
{
|
{
|
||||||
|
@ -586,13 +578,17 @@ bool SHOVE::pushSpringback( NODE* aNode, const ITEM_SET& aHeadItems,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SHOVE::SHOVE_STATUS SHOVE::pushVia( VIA* aVia, const VECTOR2I& aForce, int aCurrentRank, bool aDryRun )
|
SHOVE::SHOVE_STATUS SHOVE::pushVia( VIA* aVia, const VECTOR2I& aForce, int aCurrentRank )
|
||||||
{
|
{
|
||||||
LINE_PAIR_VEC draggedLines;
|
LINE_PAIR_VEC draggedLines;
|
||||||
VECTOR2I p0( aVia->Pos() );
|
VECTOR2I p0( aVia->Pos() );
|
||||||
JOINT* jt = m_currentNode->FindJoint( p0, aVia );
|
JOINT* jt = m_currentNode->FindJoint( p0, aVia );
|
||||||
VECTOR2I p0_pushed( p0 + aForce );
|
VECTOR2I p0_pushed( p0 + aForce );
|
||||||
|
|
||||||
|
// nothing to do...
|
||||||
|
if ( aForce.x == 0 && aForce.y == 0 )
|
||||||
|
return SH_OK;
|
||||||
|
|
||||||
if( !jt )
|
if( !jt )
|
||||||
{
|
{
|
||||||
wxLogTrace( "PNS", "weird, can't find the center-of-via joint\n" );
|
wxLogTrace( "PNS", "weird, can't find the center-of-via joint\n" );
|
||||||
|
@ -602,27 +598,21 @@ SHOVE::SHOVE_STATUS SHOVE::pushVia( VIA* aVia, const VECTOR2I& aForce, int aCurr
|
||||||
if( aVia->IsLocked() )
|
if( aVia->IsLocked() )
|
||||||
return SH_TRY_WALK;
|
return SH_TRY_WALK;
|
||||||
|
|
||||||
if( jt->IsStitchingVia() )
|
|
||||||
return SH_TRY_WALK;
|
|
||||||
|
|
||||||
if( jt->IsLocked() )
|
if( jt->IsLocked() )
|
||||||
return SH_INCOMPLETE;
|
return SH_INCOMPLETE;
|
||||||
|
|
||||||
// nothing to push...
|
// make sure pushed via does not overlap with any existing joint
|
||||||
if ( aForce.x == 0 && aForce.y == 0 )
|
while( true )
|
||||||
return SH_OK;
|
|
||||||
|
|
||||||
while( aForce.x != 0 || aForce.y != 0 )
|
|
||||||
{
|
{
|
||||||
JOINT* jt_next = m_currentNode->FindJoint( p0_pushed, aVia );
|
JOINT* jt_next = m_currentNode->FindJoint( p0_pushed, aVia );
|
||||||
|
|
||||||
if( !jt_next )
|
if( !jt_next )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
p0_pushed += aForce.Resize( 2 ); // make sure pushed via does not overlap with any existing joint
|
p0_pushed += aForce.Resize( 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr< VIA > pushedVia = Clone( *aVia );
|
std::unique_ptr<VIA> pushedVia = Clone( *aVia );
|
||||||
pushedVia->SetPos( p0_pushed );
|
pushedVia->SetPos( p0_pushed );
|
||||||
pushedVia->Mark( aVia->Marker() );
|
pushedVia->Mark( aVia->Marker() );
|
||||||
|
|
||||||
|
@ -648,17 +638,9 @@ SHOVE::SHOVE_STATUS SHOVE::pushVia( VIA* aVia, const VECTOR2I& aForce, int aCurr
|
||||||
lp.second.DragCorner( p0_pushed, lp.second.CLine().Find( p0 ) );
|
lp.second.DragCorner( p0_pushed, lp.second.CLine().Find( p0 ) );
|
||||||
lp.second.AppendVia( *pushedVia );
|
lp.second.AppendVia( *pushedVia );
|
||||||
draggedLines.push_back( lp );
|
draggedLines.push_back( lp );
|
||||||
|
|
||||||
if( aVia->Marker() & MK_HEAD )
|
|
||||||
m_draggedViaHeadSet.Add( lp.second );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_draggedViaHeadSet.Add( pushedVia.get() );
|
|
||||||
|
|
||||||
if( aDryRun )
|
|
||||||
return SH_OK;
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
m_logger.Log( aVia, 0, "obstacle-via" );
|
m_logger.Log( aVia, 0, "obstacle-via" );
|
||||||
#endif
|
#endif
|
||||||
|
@ -670,10 +652,7 @@ SHOVE::SHOVE_STATUS SHOVE::pushVia( VIA* aVia, const VECTOR2I& aForce, int aCurr
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if( aVia->Marker() & MK_HEAD )
|
if( aVia->Marker() & MK_HEAD )
|
||||||
{
|
|
||||||
m_draggedVia = pushedVia.get();
|
m_draggedVia = pushedVia.get();
|
||||||
m_draggedViaHeadSet.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
replaceItems( aVia, std::move( pushedVia ) );
|
replaceItems( aVia, std::move( pushedVia ) );
|
||||||
|
|
||||||
|
@ -937,11 +916,9 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
|
||||||
NODE::OPT_OBSTACLE nearest;
|
NODE::OPT_OBSTACLE nearest;
|
||||||
SHOVE_STATUS st = SH_NULL;
|
SHOVE_STATUS st = SH_NULL;
|
||||||
|
|
||||||
ITEM::PnsKind search_order[] = { ITEM::SOLID_T, ITEM::VIA_T, ITEM::SEGMENT_T };
|
for( ITEM::PnsKind search_order : { ITEM::SOLID_T, ITEM::VIA_T, ITEM::SEGMENT_T } )
|
||||||
|
|
||||||
for( int i = 0; i < 3; i++ )
|
|
||||||
{
|
{
|
||||||
nearest = m_currentNode->NearestObstacle( ¤tLine, search_order[i] );
|
nearest = m_currentNode->NearestObstacle( ¤tLine, search_order );
|
||||||
|
|
||||||
if( nearest )
|
if( nearest )
|
||||||
break;
|
break;
|
||||||
|
@ -1037,7 +1014,7 @@ SHOVE::SHOVE_STATUS SHOVE::shoveMainLoop()
|
||||||
{
|
{
|
||||||
SHOVE_STATUS st = SH_OK;
|
SHOVE_STATUS st = SH_OK;
|
||||||
|
|
||||||
m_affectedAreaSum = OPT_BOX2I();
|
m_affectedArea = OPT_BOX2I();
|
||||||
|
|
||||||
wxLogTrace( "PNS", "ShoveStart [root: %d jts, current: %d jts]", m_root->JointCount(),
|
wxLogTrace( "PNS", "ShoveStart [root: %d jts, current: %d jts]", m_root->JointCount(),
|
||||||
m_currentNode->JointCount() );
|
m_currentNode->JointCount() );
|
||||||
|
@ -1069,16 +1046,14 @@ SHOVE::SHOVE_STATUS SHOVE::shoveMainLoop()
|
||||||
OPT_BOX2I SHOVE::totalAffectedArea() const
|
OPT_BOX2I SHOVE::totalAffectedArea() const
|
||||||
{
|
{
|
||||||
OPT_BOX2I area;
|
OPT_BOX2I area;
|
||||||
|
|
||||||
if( !m_nodeStack.empty() )
|
if( !m_nodeStack.empty() )
|
||||||
area = m_nodeStack.back().m_affectedArea;
|
area = m_nodeStack.back().m_affectedArea;
|
||||||
|
|
||||||
if( area )
|
if( area && m_affectedArea)
|
||||||
{
|
area->Merge( *m_affectedArea );
|
||||||
if( m_affectedAreaSum )
|
else if( !area )
|
||||||
area->Merge( *m_affectedAreaSum );
|
area = m_affectedArea;
|
||||||
}
|
|
||||||
else
|
|
||||||
area = m_affectedAreaSum;
|
|
||||||
|
|
||||||
return area;
|
return area;
|
||||||
}
|
}
|
||||||
|
@ -1161,7 +1136,7 @@ SHOVE::SHOVE_STATUS SHOVE::ShoveLines( const LINE& aCurrentHead )
|
||||||
|
|
||||||
if( st == SH_OK || st == SH_HEAD_MODIFIED )
|
if( st == SH_OK || st == SH_HEAD_MODIFIED )
|
||||||
{
|
{
|
||||||
pushSpringback( m_currentNode, headSet, COST_ESTIMATOR(), m_affectedAreaSum );
|
pushSpringback( m_currentNode, m_affectedArea );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1256,7 +1231,7 @@ SHOVE::SHOVE_STATUS SHOVE::ShoveMultiLines( const ITEM_SET& aHeadSet )
|
||||||
|
|
||||||
if( st == SH_OK )
|
if( st == SH_OK )
|
||||||
{
|
{
|
||||||
pushSpringback( m_currentNode, ITEM_SET(), COST_ESTIMATOR(), m_affectedAreaSum );
|
pushSpringback( m_currentNode, m_affectedArea );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1276,14 +1251,9 @@ SHOVE::SHOVE_STATUS SHOVE::ShoveDraggingVia( VIA* aVia, const VECTOR2I& aWhere,
|
||||||
m_optimizerQueue.clear();
|
m_optimizerQueue.clear();
|
||||||
m_newHead = OPT_LINE();
|
m_newHead = OPT_LINE();
|
||||||
m_draggedVia = NULL;
|
m_draggedVia = NULL;
|
||||||
m_draggedViaHeadSet.Clear();
|
|
||||||
|
|
||||||
NODE* parent = m_nodeStack.empty() ? m_root : m_nodeStack.back().m_node;
|
NODE* parent = m_nodeStack.empty() ? m_root : m_nodeStack.back().m_node;
|
||||||
|
|
||||||
m_currentNode = parent;
|
|
||||||
|
|
||||||
parent = m_nodeStack.empty() ? m_root : m_nodeStack.back().m_node;
|
|
||||||
|
|
||||||
m_currentNode = parent->Branch();
|
m_currentNode = parent->Branch();
|
||||||
m_currentNode->ClearRanks();
|
m_currentNode->ClearRanks();
|
||||||
|
|
||||||
|
@ -1297,18 +1267,14 @@ SHOVE::SHOVE_STATUS SHOVE::ShoveDraggingVia( VIA* aVia, const VECTOR2I& aWhere,
|
||||||
|
|
||||||
if( st == SH_OK || st == SH_HEAD_MODIFIED )
|
if( st == SH_OK || st == SH_HEAD_MODIFIED )
|
||||||
{
|
{
|
||||||
if( aNewVia )
|
wxLogTrace( "PNS","setNewV %p", m_draggedVia );
|
||||||
{
|
*aNewVia = m_draggedVia;
|
||||||
wxLogTrace( "PNS","setNewV %p", m_draggedVia );
|
|
||||||
*aNewVia = m_draggedVia;
|
|
||||||
}
|
|
||||||
|
|
||||||
pushSpringback( m_currentNode, m_draggedViaHeadSet, COST_ESTIMATOR(), m_affectedAreaSum );
|
pushSpringback( m_currentNode, m_affectedArea );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( aNewVia )
|
*aNewVia = nullptr;
|
||||||
*aNewVia = nullptr;
|
|
||||||
|
|
||||||
delete m_currentNode;
|
delete m_currentNode;
|
||||||
m_currentNode = parent;
|
m_currentNode = parent;
|
||||||
|
|
|
@ -68,8 +68,7 @@ public:
|
||||||
SHOVE_STATUS ShoveMultiLines( const ITEM_SET& aHeadSet );
|
SHOVE_STATUS ShoveMultiLines( const ITEM_SET& aHeadSet );
|
||||||
|
|
||||||
SHOVE_STATUS ShoveDraggingVia( VIA* aVia, const VECTOR2I& aWhere, VIA** aNewVia );
|
SHOVE_STATUS ShoveDraggingVia( VIA* aVia, const VECTOR2I& aWhere, VIA** aNewVia );
|
||||||
SHOVE_STATUS ProcessSingleLine( LINE& aCurrent, LINE& aObstacle,
|
SHOVE_STATUS ProcessSingleLine( LINE& aCurrent, LINE& aObstacle, LINE& aShoved );
|
||||||
LINE& aShoved );
|
|
||||||
|
|
||||||
void ForceClearance ( bool aEnabled, int aClearance )
|
void ForceClearance ( bool aEnabled, int aClearance )
|
||||||
{
|
{
|
||||||
|
@ -97,8 +96,6 @@ private:
|
||||||
int m_segments;
|
int m_segments;
|
||||||
VECTOR2I m_p;
|
VECTOR2I m_p;
|
||||||
NODE* m_node;
|
NODE* m_node;
|
||||||
ITEM_SET m_headItems;
|
|
||||||
COST_ESTIMATOR m_cost;
|
|
||||||
OPT_BOX2I m_affectedArea;
|
OPT_BOX2I m_affectedArea;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -106,8 +103,7 @@ private:
|
||||||
LINE& aShoved, const HULL_SET& hulls );
|
LINE& aShoved, const HULL_SET& hulls );
|
||||||
|
|
||||||
bool reduceSpringback( const ITEM_SET& aHeadItems );
|
bool reduceSpringback( const ITEM_SET& aHeadItems );
|
||||||
bool pushSpringback( NODE* aNode, const ITEM_SET& aHeadItems,
|
bool pushSpringback( NODE* aNode, const OPT_BOX2I& aAffectedArea );
|
||||||
const COST_ESTIMATOR& aCost, const OPT_BOX2I& aAffectedArea );
|
|
||||||
|
|
||||||
SHOVE_STATUS walkaroundLoneVia( LINE& aCurrent, LINE& aObstacle, LINE& aShoved );
|
SHOVE_STATUS walkaroundLoneVia( LINE& aCurrent, LINE& aObstacle, LINE& aShoved );
|
||||||
bool checkBumpDirection( const LINE& aCurrent, const LINE& aShoved ) const;
|
bool checkBumpDirection( const LINE& aCurrent, const LINE& aShoved ) const;
|
||||||
|
@ -117,7 +113,7 @@ private:
|
||||||
SHOVE_STATUS onCollidingSolid( LINE& aCurrent, ITEM* aObstacle );
|
SHOVE_STATUS onCollidingSolid( LINE& aCurrent, ITEM* aObstacle );
|
||||||
SHOVE_STATUS onCollidingVia( ITEM* aCurrent, VIA* aObstacleVia );
|
SHOVE_STATUS onCollidingVia( ITEM* aCurrent, VIA* aObstacleVia );
|
||||||
SHOVE_STATUS onReverseCollidingVia( LINE& aCurrent, VIA* aObstacleVia );
|
SHOVE_STATUS onReverseCollidingVia( LINE& aCurrent, VIA* aObstacleVia );
|
||||||
SHOVE_STATUS pushVia( VIA* aVia, const VECTOR2I& aForce, int aCurrentRank, bool aDryRun = false );
|
SHOVE_STATUS pushVia( VIA* aVia, const VECTOR2I& aForce, int aCurrentRank );
|
||||||
|
|
||||||
OPT_BOX2I totalAffectedArea() const;
|
OPT_BOX2I totalAffectedArea() const;
|
||||||
|
|
||||||
|
@ -134,7 +130,7 @@ private:
|
||||||
void replaceItems( ITEM* aOld, std::unique_ptr< ITEM > aNew );
|
void replaceItems( ITEM* aOld, std::unique_ptr< ITEM > aNew );
|
||||||
void replaceLine( LINE& aOld, LINE& aNew );
|
void replaceLine( LINE& aOld, LINE& aNew );
|
||||||
|
|
||||||
OPT_BOX2I m_affectedAreaSum;
|
OPT_BOX2I m_affectedArea;
|
||||||
|
|
||||||
SHOVE_STATUS shoveIteration( int aIter );
|
SHOVE_STATUS shoveIteration( int aIter );
|
||||||
SHOVE_STATUS shoveMainLoop();
|
SHOVE_STATUS shoveMainLoop();
|
||||||
|
@ -152,7 +148,6 @@ private:
|
||||||
|
|
||||||
LOGGER m_logger;
|
LOGGER m_logger;
|
||||||
VIA* m_draggedVia;
|
VIA* m_draggedVia;
|
||||||
ITEM_SET m_draggedViaHeadSet;
|
|
||||||
|
|
||||||
int m_iter;
|
int m_iter;
|
||||||
int m_forceClearance;
|
int m_forceClearance;
|
||||||
|
|
Loading…
Reference in New Issue