router: implement area constraint in optimizer
This commit is contained in:
parent
64cf593ee9
commit
14ce7a0ad7
|
@ -237,8 +237,7 @@ bool PRESERVE_VERTEX_CONSTRAINT::Check( int aVertex1, int aVertex2, const LINE*
|
||||||
|
|
||||||
for( int i = aVertex1; i < aVertex2; i++ )
|
for( int i = aVertex1; i < aVertex2; i++ )
|
||||||
{
|
{
|
||||||
SEG::ecoord dist = aCurrentPath.CSegment(i).SquaredDistance( m_v );
|
int dist = aCurrentPath.CSegment(i).Distance( m_v );
|
||||||
|
|
||||||
if ( dist <= 1 )
|
if ( dist <= 1 )
|
||||||
{
|
{
|
||||||
cv = true;
|
cv = true;
|
||||||
|
@ -254,7 +253,9 @@ bool PRESERVE_VERTEX_CONSTRAINT::Check( int aVertex1, int aVertex2, const LINE*
|
||||||
SEG::ecoord dist = aReplacement.CSegment(i).SquaredDistance( m_v );
|
SEG::ecoord dist = aReplacement.CSegment(i).SquaredDistance( m_v );
|
||||||
|
|
||||||
if ( dist <= 1 )
|
if ( dist <= 1 )
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -600,6 +601,13 @@ bool OPTIMIZER::Optimize( LINE* aLine, LINE* aResult )
|
||||||
AddConstraint( c );
|
AddConstraint( c );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( m_effortLevel & RESTRICT_AREA )
|
||||||
|
{
|
||||||
|
auto c = new AREA_CONSTRAINT( m_world, m_restrictArea );
|
||||||
|
AddConstraint( c );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if( m_effortLevel & KEEP_TOPOLOGY )
|
if( m_effortLevel & KEEP_TOPOLOGY )
|
||||||
{
|
{
|
||||||
auto c = new KEEP_TOPOLOGY_CONSTRAINT( m_world );
|
auto c = new KEEP_TOPOLOGY_CONSTRAINT( m_world );
|
||||||
|
|
|
@ -100,10 +100,11 @@ public:
|
||||||
SMART_PADS = 0x02, ///< Reroute pad exits
|
SMART_PADS = 0x02, ///< Reroute pad exits
|
||||||
MERGE_OBTUSE = 0x04, ///< Reduce corner cost by merging obtuse segments
|
MERGE_OBTUSE = 0x04, ///< Reduce corner cost by merging obtuse segments
|
||||||
FANOUT_CLEANUP = 0x08, ///< Simplify pad-pad and pad-via connections if possible
|
FANOUT_CLEANUP = 0x08, ///< Simplify pad-pad and pad-via connections if possible
|
||||||
KEEP_TOPOLOGY = 0x10,
|
KEEP_TOPOLOGY = 0x10,
|
||||||
PRESERVE_VERTEX = 0x20,
|
PRESERVE_VERTEX = 0x20,
|
||||||
RESTRICT_VERTEX_RANGE = 0x40,
|
RESTRICT_VERTEX_RANGE = 0x40,
|
||||||
MERGE_COLINEAR = 0x80 ///< Merge co-linear segments
|
MERGE_COLINEAR = 0x80, ///< Merge co-linear segments
|
||||||
|
RESTRICT_AREA = 0x100
|
||||||
};
|
};
|
||||||
|
|
||||||
OPTIMIZER( NODE* aWorld );
|
OPTIMIZER( NODE* aWorld );
|
||||||
|
@ -194,17 +195,19 @@ private:
|
||||||
ITEM* findPadOrVia( int aLayer, int aNet, const VECTOR2I& aP ) const;
|
ITEM* findPadOrVia( int aLayer, int aNet, const VECTOR2I& aP ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SHAPE_INDEX_LIST<ITEM*> m_cache;
|
SHAPE_INDEX_LIST<ITEM*> m_cache;
|
||||||
std::vector<OPT_CONSTRAINT*> m_constraints;
|
std::vector<OPT_CONSTRAINT*> m_constraints;
|
||||||
std::unordered_map<ITEM*, CACHED_ITEM> m_cacheTags;
|
std::unordered_map<ITEM*, CACHED_ITEM> m_cacheTags;
|
||||||
|
|
||||||
NODE* m_world;
|
NODE* m_world;
|
||||||
int m_collisionKindMask;
|
int m_collisionKindMask;
|
||||||
int m_effortLevel;
|
int m_effortLevel;
|
||||||
|
bool m_keepPostures;
|
||||||
|
|
||||||
VECTOR2I m_preservedVertex;
|
|
||||||
|
VECTOR2I m_preservedVertex;
|
||||||
std::pair<int, int> m_restrictedVertexRange;
|
std::pair<int, int> m_restrictedVertexRange;
|
||||||
BOX2I m_restrictArea;
|
BOX2I m_restrictArea;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -213,9 +216,9 @@ class OPT_CONSTRAINT
|
||||||
public:
|
public:
|
||||||
OPT_CONSTRAINT( NODE* aWorld ) :
|
OPT_CONSTRAINT( NODE* aWorld ) :
|
||||||
m_world( aWorld )
|
m_world( aWorld )
|
||||||
{
|
{
|
||||||
m_priority = 0;
|
m_priority = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~OPT_CONSTRAINT()
|
virtual ~OPT_CONSTRAINT()
|
||||||
{
|
{
|
||||||
|
@ -230,9 +233,28 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NODE* m_world;
|
NODE* m_world;
|
||||||
int m_priority;
|
int m_priority;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ANGLE_CONSTRAINT_45: public OPT_CONSTRAINT
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ANGLE_CONSTRAINT_45( NODE* aWorld, int aEntryDirectionMask = -1, int aExitDirectionMask = -1 ) :
|
||||||
|
OPT_CONSTRAINT( aWorld ),
|
||||||
|
m_entryDirectionMask( aEntryDirectionMask ),
|
||||||
|
m_exitDirectionMask( aExitDirectionMask )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~ANGLE_CONSTRAINT_45() {};
|
||||||
|
|
||||||
|
virtual bool Check ( int aVertex1, int aVertex2, LINE* aOriginLine, const SHAPE_LINE_CHAIN& aCurrentPath, const SHAPE_LINE_CHAIN& aReplacement ) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_entryDirectionMask;
|
||||||
|
int m_exitDirectionMask;
|
||||||
|
};
|
||||||
|
|
||||||
class AREA_CONSTRAINT : public OPT_CONSTRAINT
|
class AREA_CONSTRAINT : public OPT_CONSTRAINT
|
||||||
{
|
{
|
||||||
|
@ -249,6 +271,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BOX2I m_allowedArea;
|
BOX2I m_allowedArea;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -279,6 +302,7 @@ public:
|
||||||
const SHAPE_LINE_CHAIN& aCurrentPath,
|
const SHAPE_LINE_CHAIN& aCurrentPath,
|
||||||
const SHAPE_LINE_CHAIN& aReplacement ) override;
|
const SHAPE_LINE_CHAIN& aReplacement ) override;
|
||||||
private:
|
private:
|
||||||
|
|
||||||
VECTOR2I m_v;
|
VECTOR2I m_v;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -297,6 +321,7 @@ public:
|
||||||
const SHAPE_LINE_CHAIN& aCurrentPath,
|
const SHAPE_LINE_CHAIN& aCurrentPath,
|
||||||
const SHAPE_LINE_CHAIN& aReplacement ) override;
|
const SHAPE_LINE_CHAIN& aReplacement ) override;
|
||||||
private:
|
private:
|
||||||
|
|
||||||
int m_start;
|
int m_start;
|
||||||
int m_end;
|
int m_end;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue