Unwrap some std::library typedefs.

This commit is contained in:
Jeff Young 2021-07-28 21:04:53 +01:00
parent 87e4a1c672
commit 46338403e7
19 changed files with 125 additions and 223 deletions

View File

@ -958,7 +958,10 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
}
// Init initial lights
m_lights.Clear();
for( LIGHT* light : m_lights )
delete light;
m_lights.clear();
auto IsColorZero =
[]( const SFVEC3F& aSource )
@ -972,19 +975,23 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
m_cameraLight->SetCastShadows( false );
if( !IsColorZero( m_boardAdapter.m_RtCameraLightColor ) )
m_lights.Add( m_cameraLight );
m_lights.push_back( m_cameraLight );
const SFVEC3F& boardCenter = m_boardAdapter.GetBBox().GetCenter();
if( !IsColorZero( m_boardAdapter.m_RtLightColorTop ) )
m_lights.Add( new POINT_LIGHT( SFVEC3F( boardCenter.x, boardCenter.y,
{
m_lights.push_back( new POINT_LIGHT( SFVEC3F( boardCenter.x, boardCenter.y,
+RANGE_SCALE_3D * 2.0f ),
m_boardAdapter.m_RtLightColorTop ) );
}
if( !IsColorZero( m_boardAdapter.m_RtLightColorBottom ) )
m_lights.Add( new POINT_LIGHT( SFVEC3F( boardCenter.x, boardCenter.y,
{
m_lights.push_back( new POINT_LIGHT( SFVEC3F( boardCenter.x, boardCenter.y,
-RANGE_SCALE_3D * 2.0f ),
m_boardAdapter.m_RtLightColorBottom ) );
}
wxASSERT( m_boardAdapter.m_RtLightColor.size()
== m_boardAdapter.m_RtLightSphericalCoords.size() );
@ -995,7 +1002,7 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
{
const SFVEC2F sc = m_boardAdapter.m_RtLightSphericalCoords[i];
m_lights.Add( new DIRECTIONAL_LIGHT(
m_lights.push_back( new DIRECTIONAL_LIGHT(
SphericalToCartesian( glm::pi<float>() * sc.x, glm::pi<float>() * sc.y ),
m_boardAdapter.m_RtLightColor[i] ) );
}
@ -1003,20 +1010,13 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
}
// Create an accelerator
if( m_accelerator )
{
delete m_accelerator;
}
m_accelerator = 0;
m_accelerator = new BVH_PBRT( m_objectContainer, 8, SPLITMETHOD::MIDDLE );
if( aStatusReporter )
{
// Calculation time in seconds
const double calculation_time =
(double) ( GetRunningMicroSecs() - stats_startReloadTime ) / 1e6;
double calculation_time = (double) GetRunningMicroSecs() - stats_startReloadTime / 1e6;
aStatusReporter->Report( wxString::Format( _( "Reload time %.3f s" ), calculation_time ) );
}
@ -1051,9 +1051,12 @@ void RENDER_3D_RAYTRACE::insertHole( const PCB_VIA* aVia )
if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
objPtr->SetColor( ConvertSRGBToLinear( (SFVEC3F) m_boardAdapter.m_CopperColor ) );
else if( aVia->GetViaType() == VIATYPE::MICROVIA )
objPtr->SetColor( ConvertSRGBToLinear( m_boardAdapter.GetItemColor( LAYER_VIA_MICROVIA ) ) );
else if( aVia->GetViaType() == VIATYPE::BLIND_BURIED )
objPtr->SetColor( ConvertSRGBToLinear( m_boardAdapter.GetItemColor( LAYER_VIA_BBLIND ) ) );
else
objPtr->SetColor( ConvertSRGBToLinear( m_boardAdapter.GetItemColor(
LAYER_VIAS + static_cast<int>( aVia->GetViaType() ) ) ) );
objPtr->SetColor( ConvertSRGBToLinear( m_boardAdapter.GetItemColor( LAYER_VIAS ) ) );
m_objectContainer.Add( objPtr );
}

View File

@ -147,56 +147,4 @@ private:
};
typedef std::list<LIGHT*> LIST_LIGHT;
/**
* A container for light sources.
*
* @todo Do we really need this object? Wouldn't it be cleaner to just use std::list directly?
*/
class LIGHT_SOURCES
{
public:
LIGHT_SOURCES() {}
~LIGHT_SOURCES() { Clear(); }
/**
* Remove all lights from the container.
*/
void Clear()
{
if( !m_lights.empty() )
{
for( LIST_LIGHT::iterator ii = m_lights.begin(); ii != m_lights.end(); ++ii )
{
delete *ii;
*ii = nullptr;
}
m_lights.clear();
}
}
/**
* Add a light source to the container.
*/
void Add( LIGHT* aLight )
{
if( aLight )
m_lights.push_back( aLight );
}
/**
* Get light list of this container.
*
* @return a list of lights
*/
const LIST_LIGHT& GetList() const { return m_lights; }
private:
LIST_LIGHT m_lights; ///< list of lights
};
#endif // _LIGHT_H_

View File

@ -1567,8 +1567,6 @@ SFVEC3F RENDER_3D_RAYTRACE::shadeHit( const SFVEC3F& aBgColor, const RAY& aRay,
const SFVEC3F diffuseColorObj = aHitInfo.pHitObject->GetDiffuseColor( aHitInfo );
const LIST_LIGHT& lightList = m_lights.GetList();
#if USE_EXPERIMENTAL_SOFT_SHADOWS
const bool is_aa_enabled = m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING ) &&
(!m_isPreview);
@ -1578,10 +1576,8 @@ SFVEC3F RENDER_3D_RAYTRACE::shadeHit( const SFVEC3F& aBgColor, const RAY& aRay,
unsigned int nr_lights_that_can_cast_shadows = 0;
for( LIST_LIGHT::const_iterator ii = lightList.begin(); ii != lightList.end(); ++ii )
for( const LIGHT* light : m_lights )
{
const LIGHT* light = (LIGHT *)*ii;
SFVEC3F vectorToLight;
SFVEC3F colorOfLight;
float distToLight;

View File

@ -161,7 +161,7 @@ private:
POST_SHADER_SSAO m_postShaderSsao;
LIGHT_SOURCES m_lights;
std::list<LIGHT*> m_lights;
DIRECTIONAL_LIGHT* m_cameraLight;

View File

@ -45,8 +45,6 @@ extern const wxChar BOM_TRACE[];
class BOM_GENERATOR_HANDLER
{
public:
typedef std::unique_ptr<BOM_GENERATOR_HANDLER> PTR;
/**
* @param aFile is path to the plugin file.
*/

View File

@ -55,7 +55,7 @@ wxString s_bomHelpInfo =
// BOM "plugins" are not actually plugins. They are external tools
// (scripts or executables) called by this dialog.
typedef std::vector<BOM_GENERATOR_HANDLER::PTR> BOM_GENERATOR_ARRAY;
typedef std::vector< std::unique_ptr<BOM_GENERATOR_HANDLER> > BOM_GENERATOR_ARRAY;
// The main dialog frame to run scripts to build bom

View File

@ -223,7 +223,7 @@ bool DIALOG_SIM_SETTINGS::TransferDataFromWindow()
}
else if( page == m_pgNoise ) // Noise analysis
{
const NETLIST_EXPORTER_PSPICE::NET_INDEX_MAP& netMap = m_exporter->GetNetIndexMap();
const std::map<wxString, int>& netMap = m_exporter->GetNetIndexMap();
if( empty( m_noiseMeas ) || empty( m_noiseSrc ) || empty( m_noisePointsNumber )
|| empty( m_noiseFreqStart ) || empty( m_noiseFreqStop ) )

View File

@ -270,10 +270,8 @@ wxString NETLIST_EXPORTER_PSPICE::GetSpiceFieldDefVal( SPICE_FIELD aField, SCH_S
bool NETLIST_EXPORTER_PSPICE::ProcessNetlist( unsigned aCtl )
{
const wxString delimiters( "{:,; }" );
SCH_SHEET_LIST sheetList = m_schematic->GetSheets();
// Set of reference names, to check for duplication
std::set<wxString> refNames;
std::set<wxString> refNames; // Set of reference names, to check for duplication
m_netMap.clear();
m_netMap["GND"] = 0; // 0 is reserved for "GND"
@ -468,9 +466,7 @@ void NETLIST_EXPORTER_PSPICE::UpdateDirectives( unsigned aCtl )
void NETLIST_EXPORTER_PSPICE::writeDirectives( OUTPUTFORMATTER* aFormatter, unsigned aCtl ) const
{
for( const wxString& dir : m_directives )
{
aFormatter->Print( 0, "%s\n", TO_UTF8( dir ) );
}
}

View File

@ -71,27 +71,16 @@ enum SPICE_PRIMITIVE {
*/
struct SPICE_ITEM
{
///< Schematic symbol represented by this SPICE_ITEM.
SCH_SYMBOL* m_parent;
///< Spice primitive type (@see SPICE_PRIMITIVE).
wxChar m_primitive;
///< Library model (for semiconductors and subcircuits), component value (for passive
///< components) or voltage/current (for sources).
wxString m_model;
///<
SCH_SYMBOL* m_parent; ///< Schematic symbol represented by this SPICE_ITEM.
wxChar m_primitive; ///< Spice primitive type (@see SPICE_PRIMITIVE).
wxString m_model; ///< Library model (for semiconductors and subcircuits),
///< component value (for passive components) or
///< voltage/current (for sources).
wxString m_refName;
///< Flag to indicate whether the symbol should be used in simulation.
bool m_enabled;
///< Array containing Standard Pin Name
std::vector<wxString> m_pins;
///< Numeric indices into m_SortedSymbolPinList
std::vector<int> m_pinSequence;
bool m_enabled; ///< Whether the symbol should be used in simulation.
std::vector<wxString> m_pins; ///< Array containing Standard Pin Name
std::vector<int> m_pinSequence; ///< Numeric indices into m_SortedSymbolPinList
};
@ -110,15 +99,10 @@ public:
{
}
typedef std::list<SPICE_ITEM> SPICE_ITEM_LIST;
///< Net name to circuit node number mapping
typedef std::map<wxString, int> NET_INDEX_MAP;
/**
* Return list of items representing schematic components in the Spice world.
*/
const SPICE_ITEM_LIST& GetSpiceItems() const
const std::list<SPICE_ITEM>& GetSpiceItems() const
{
return m_spiceItems;
}
@ -153,15 +137,13 @@ public:
/**
* Replace illegal spice net name characters with an underscore.
*
* @param aNetName is the net name to modify.
*/
static void ReplaceForbiddenChars( wxString& aNetName );
/**
* Return a map of circuit nodes to net names.
*/
const NET_INDEX_MAP& GetNetIndexMap() const
const std::map<wxString, int>& GetNetIndexMap() const
{
return m_netMap;
}
@ -226,20 +208,12 @@ protected:
virtual void writeDirectives( OUTPUTFORMATTER* aFormatter, unsigned aCtl ) const;
private:
///< Spice simulation title found in the processed schematic sheet
wxString m_title;
///< Spice directives found in the processed schematic sheet
std::vector<wxString> m_directives;
///< Libraries used by the simulated circuit
std::set<wxString> m_libraries;
///< Map circuit nodes to net names
NET_INDEX_MAP m_netMap;
///< List of items representing schematic components in the Spice world
SPICE_ITEM_LIST m_spiceItems;
wxString m_title; ///< Spice simulation title found in the schematic sheet
std::vector<wxString> m_directives; ///< Spice directives found in the schematic sheet
std::set<wxString> m_libraries; ///< Spice libraries used by the simulated circuit
std::map<wxString, int> m_netMap; ///< Map spice nodes to net codes
std::list<SPICE_ITEM> m_spiceItems; ///< Items representing schematic symbols in Spice world
// Component fields that are processed during netlist export & simulation
static const std::vector<wxString> m_spiceFields;

View File

@ -108,7 +108,7 @@ wxString PIN_NUMBERS::GetSummary() const
}
int PIN_NUMBERS::Compare( const PinNumber& lhs, const PinNumber& rhs )
int PIN_NUMBERS::Compare( const wxString& lhs, const wxString& rhs )
{
wxString::size_type cursor1 = 0;
wxString::size_type cursor2 = 0;

View File

@ -913,8 +913,8 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::CreateBuffer( LIB_SYMBOL* aCopy, SCH_SC
}
bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::UpdateBuffer(
SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER::PTR aSymbolBuf, LIB_SYMBOL* aCopy )
bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::UpdateBuffer( std::shared_ptr<SYMBOL_BUFFER> aSymbolBuf,
LIB_SYMBOL* aCopy )
{
wxCHECK( aCopy && aSymbolBuf, false );
@ -929,8 +929,7 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::UpdateBuffer(
}
bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::DeleteBuffer(
SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER::PTR aSymbolBuf )
bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::DeleteBuffer( std::shared_ptr<SYMBOL_BUFFER> aSymbolBuf )
{
auto symbolBufIt = std::find( m_symbols.begin(), m_symbols.end(), aSymbolBuf );
wxCHECK( symbolBufIt != m_symbols.end(), false );
@ -952,8 +951,8 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::DeleteBuffer(
}
bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer(
SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER::PTR aSymbolBuf, SYMBOL_LIB_TABLE* aLibTable )
bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( std::shared_ptr<SYMBOL_BUFFER> aSymbolBuf,
SYMBOL_LIB_TABLE* aLibTable )
{
wxCHECK( aSymbolBuf, false );
LIB_SYMBOL* libSymbol = aSymbolBuf->GetSymbol();
@ -1000,8 +999,7 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer(
result = aLibTable->SaveSymbol( m_libName, newCachedSymbol );
wxCHECK( result == SYMBOL_LIB_TABLE::SAVE_OK, false );
SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER::PTR originalBufferedParent =
GetBuffer( bufferedParent->GetName() );
auto originalBufferedParent = GetBuffer( bufferedParent->GetName() );
wxCHECK( originalBufferedParent, false );
originalSymbol = new LIB_SYMBOL( *libSymbol );
originalSymbol->SetParent( originalBufferedParent->GetSymbol() );
@ -1026,7 +1024,7 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer(
for( auto entry : derivedSymbols )
{
SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER::PTR symbol = GetBuffer( entry );
std::shared_ptr<SYMBOL_BUFFER> symbol = GetBuffer( entry );
LIB_SYMBOL* derivedSymbol = new LIB_SYMBOL( *symbol->GetSymbol() );
derivedSymbol->SetParent( parentSymbol );
result = aLibTable->SaveSymbol( m_libName, derivedSymbol );
@ -1040,8 +1038,8 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer(
}
bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer(
SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER::PTR aSymbolBuf, const wxString& aFileName,
bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( std::shared_ptr<SYMBOL_BUFFER> aSymbolBuf,
const wxString& aFileName,
SCH_PLUGIN* aPlugin, bool aBuffer )
{
wxCHECK( aSymbolBuf, false );
@ -1129,8 +1127,7 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer(
return false;
}
SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER::PTR originalBufferedParent =
GetBuffer( bufferedParent->GetName() );
auto originalBufferedParent = GetBuffer( bufferedParent->GetName() );
wxCHECK( originalBufferedParent, false );
originalSymbol = new LIB_SYMBOL( *libSymbol );
originalSymbol->SetParent( originalBufferedParent->GetSymbol() );
@ -1178,7 +1175,7 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer(
// Save the derived symbols.
for( auto entry : derivedSymbols )
{
SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER::PTR symbol = GetBuffer( entry );
std::shared_ptr<SYMBOL_BUFFER> symbol = GetBuffer( entry );
LIB_SYMBOL* derivedSymbol = new LIB_SYMBOL( *symbol->GetSymbol() );
derivedSymbol->SetParent( parentSymbol );
@ -1202,7 +1199,7 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer(
}
SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER::PTR
std::shared_ptr<SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER>
SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::GetBuffer( const wxString& aAlias ) const
{
for( auto entry : m_symbols )
@ -1211,7 +1208,7 @@ SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::GetBuffer( const wxString& aAlias ) const
return entry;
}
return SYMBOL_BUFFER::PTR( nullptr );
return std::shared_ptr<SYMBOL_BUFFER>( nullptr );
}
@ -1270,13 +1267,12 @@ size_t SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::GetDerivedSymbolNames( const wxString
}
int SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::removeChildSymbols(
SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER::PTR aSymbolBuf )
int SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::removeChildSymbols( std::shared_ptr<SYMBOL_BUFFER> aSymbolBuf )
{
wxCHECK( aSymbolBuf && aSymbolBuf->GetSymbol()->IsRoot(), 0 );
int cnt = 0;
std::deque< SYMBOL_LIBRARY_MANAGER::SYMBOL_BUFFER::PTR >::iterator it = m_symbols.begin();
std::deque< std::shared_ptr<SYMBOL_BUFFER> >::iterator it = m_symbols.begin();
while( it != m_symbols.end() )
{

View File

@ -300,9 +300,6 @@ private:
return ret;
}
typedef std::shared_ptr<SYMBOL_BUFFER> PTR;
typedef std::weak_ptr<SYMBOL_BUFFER> WEAK_PTR;
private:
std::unique_ptr<SCH_SCREEN> m_screen;
@ -325,7 +322,7 @@ private:
if( !m_deleted.empty() )
return true;
for( const auto& symbolBuf : m_symbols )
for( const std::shared_ptr<SYMBOL_BUFFER>& symbolBuf : m_symbols )
{
if( symbolBuf->IsModified() )
return true;
@ -343,9 +340,9 @@ private:
bool CreateBuffer( LIB_SYMBOL* aCopy, SCH_SCREEN* aScreen );
///< Update the buffered symbol with the contents of \a aCopy.
bool UpdateBuffer( SYMBOL_BUFFER::PTR aSymbolBuf, LIB_SYMBOL* aCopy );
bool UpdateBuffer( std::shared_ptr<SYMBOL_BUFFER> aSymbolBuf, LIB_SYMBOL* aCopy );
bool DeleteBuffer( SYMBOL_BUFFER::PTR aSymbolBuf );
bool DeleteBuffer( std::shared_ptr<SYMBOL_BUFFER> aSymbolBuf );
void ClearDeletedBuffer()
{
@ -354,18 +351,18 @@ private:
///< Save stored modifications to Symbol Lib Table. It may result in saving the symbol
///< to disk as well, depending on the row properties.
bool SaveBuffer( SYMBOL_BUFFER::PTR aSymbolBuf, SYMBOL_LIB_TABLE* aLibTable );
bool SaveBuffer( std::shared_ptr<SYMBOL_BUFFER> aSymbolBuf, SYMBOL_LIB_TABLE* aLibTable );
///< Save stored modifications using a plugin. aBuffer decides whether the changes
///< should be cached or stored directly to the disk (for SCH_LEGACY_PLUGIN).
bool SaveBuffer( SYMBOL_BUFFER::PTR aSymbolBuf, const wxString& aFileName,
bool SaveBuffer( std::shared_ptr<SYMBOL_BUFFER> aSymbolBuf, const wxString& aFileName,
SCH_PLUGIN* aPlugin, bool aBuffer );
///< Return a symbol buffer with LIB_SYMBOL holding a symbolicular alias
SYMBOL_BUFFER::PTR GetBuffer( const wxString& aAlias ) const;
std::shared_ptr<SYMBOL_BUFFER> GetBuffer( const wxString& aAlias ) const;
///< Return all buffered symbols
const std::deque<SYMBOL_BUFFER::PTR>& GetBuffers() const { return m_symbols; }
const std::deque< std::shared_ptr<SYMBOL_BUFFER> >& GetBuffers() const { return m_symbols; }
/**
* Check to see any symbols in the buffer are derived from a parent named \a aParentName.
@ -400,12 +397,12 @@ private:
* @param aParent is the #SYMBOL_BUFFER to check against.
* @return the count of #SYMBOL_BUFFER objects removed from the library.
*/
int removeChildSymbols( SYMBOL_BUFFER::PTR aSymbolBuf );
int removeChildSymbols( std::shared_ptr<SYMBOL_BUFFER> aSymbolBuf );
std::deque<SYMBOL_BUFFER::PTR> m_symbols;
std::deque< std::shared_ptr<SYMBOL_BUFFER> > m_symbols;
///< Buffer for deleted symbols until library is saved.
std::deque<SYMBOL_BUFFER::PTR> m_deleted;
std::deque< std::shared_ptr<SYMBOL_BUFFER> > m_deleted;
const wxString m_libName; // Buffered library name
int m_hash;
};

View File

@ -183,7 +183,6 @@ struct LibSymbolMapSort
/// Symbol map used by symbol library object.
typedef std::map< wxString, LIB_SYMBOL*, LibSymbolMapSort > LIB_SYMBOL_MAP;
typedef std::vector< LIB_SYMBOL* > LIB_SYMBOLS;
typedef boost::ptr_vector< SYMBOL_LIB > SYMBOL_LIBS_BASE;

View File

@ -27,8 +27,6 @@ class DRC_RULE;
class DRC_LENGTH_REPORT
{
public:
typedef std::set<BOARD_CONNECTED_ITEM*> CITEMS;
struct ENTRY
{
int netcode;
@ -38,7 +36,7 @@ public:
DRC_RULE* matchingRule;
wxString from;
wxString to;
CITEMS items;
std::set<BOARD_CONNECTED_ITEM*> items;
int viaCount;
int totalRoute;
int totalVia;

View File

@ -79,13 +79,11 @@ private:
bool runInternal( bool aDelayReportMode = false );
using LENGTH_ENTRY = DRC_LENGTH_REPORT::ENTRY;
typedef std::set<BOARD_CONNECTED_ITEM*> CITEMS;
typedef std::vector<LENGTH_ENTRY> LENGTH_ENTRIES;
using CONNECTION = DRC_LENGTH_REPORT::ENTRY;
void checkLengthViolations( DRC_CONSTRAINT& aConstraint, LENGTH_ENTRIES& aMatchedConnections );
void checkSkewViolations( DRC_CONSTRAINT& aConstraint, LENGTH_ENTRIES& aMatchedConnections );
void checkViaCountViolations( DRC_CONSTRAINT& aConstraint, LENGTH_ENTRIES& aMatchedConnections );
void checkLengths( DRC_CONSTRAINT& aConstraint, std::vector<CONNECTION>& aMatchedConnections );
void checkSkews( DRC_CONSTRAINT& aConstraint, std::vector<CONNECTION>& aMatchedConnections );
void checkViaCounts( DRC_CONSTRAINT& aConstraint, std::vector<CONNECTION>& aMatchedConnections );
BOARD* m_board;
DRC_LENGTH_REPORT m_report;
@ -98,10 +96,10 @@ static int computeViaThruLength( PCB_VIA *aVia, const std::set<BOARD_CONNECTED_I
}
void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkLengthViolations( DRC_CONSTRAINT& aConstraint,
LENGTH_ENTRIES& matchedConnections )
void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkLengths( DRC_CONSTRAINT& aConstraint,
std::vector<CONNECTION>& aMatchedConnections )
{
for( const DRC_LENGTH_REPORT::ENTRY& ent : matchedConnections )
for( const DRC_LENGTH_REPORT::ENTRY& ent : aMatchedConnections )
{
bool minViolation = false;
bool maxViolation = false;
@ -150,17 +148,17 @@ void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkLengthViolations( DRC_CONSTRAINT& aC
}
}
void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkSkewViolations( DRC_CONSTRAINT& aConstraint,
LENGTH_ENTRIES& matchedConnections )
void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkSkews( DRC_CONSTRAINT& aConstraint,
std::vector<CONNECTION>& aMatchedConnections )
{
int avgLength = 0;
for( const DRC_LENGTH_REPORT::ENTRY& ent : matchedConnections )
for( const DRC_LENGTH_REPORT::ENTRY& ent : aMatchedConnections )
avgLength += ent.total;
avgLength /= matchedConnections.size();
avgLength /= aMatchedConnections.size();
for( const auto& ent : matchedConnections )
for( const auto& ent : aMatchedConnections )
{
int skew = ent.total - avgLength;
if( aConstraint.GetValue().HasMax() && abs( skew ) > aConstraint.GetValue().Max() )
@ -187,10 +185,10 @@ void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkSkewViolations( DRC_CONSTRAINT& aCon
}
void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkViaCountViolations( DRC_CONSTRAINT& aConstraint,
LENGTH_ENTRIES& matchedConnections )
void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkViaCounts( DRC_CONSTRAINT& aConstraint,
std::vector<CONNECTION>& aMatchedConnections )
{
for( const auto& ent : matchedConnections )
for( const auto& ent : aMatchedConnections )
{
if( aConstraint.GetValue().HasMax() && ent.viaCount > aConstraint.GetValue().Max() )
{
@ -231,7 +229,7 @@ bool DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal( bool aDelayReportMode )
return false;
}
std::map<DRC_RULE*, CITEMS> itemSets;
std::map<DRC_RULE*, std::set<BOARD_CONNECTED_ITEM*> > itemSets;
auto evaluateLengthConstraints =
[&]( BOARD_ITEM *item ) -> bool
@ -265,11 +263,11 @@ bool DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal( bool aDelayReportMode )
forEachGeometryItem( { PCB_TRACE_T, PCB_VIA_T, PCB_ARC_T }, LSET::AllCuMask(),
evaluateLengthConstraints );
std::map<DRC_RULE*, LENGTH_ENTRIES> matches;
std::map<DRC_RULE*, std::vector<CONNECTION> > matches;
for( auto it : itemSets )
{
std::map<int, CITEMS> netMap;
std::map<int, std::set<BOARD_CONNECTED_ITEM*> > netMap;
for( auto citem : it.second )
netMap[ citem->GetNetCode() ].insert( citem );
@ -277,7 +275,7 @@ bool DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal( bool aDelayReportMode )
for( auto nitem : netMap )
{
LENGTH_ENTRY ent;
CONNECTION ent;
ent.items = nitem.second;
ent.netcode = nitem.first;
ent.netname = m_board->GetNetInfo().GetNetItem( ent.netcode )->GetNetname();
@ -340,7 +338,7 @@ bool DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal( bool aDelayReportMode )
auto& matchedConnections = it.second;
std::sort( matchedConnections.begin(), matchedConnections.end(),
[] ( const LENGTH_ENTRY&a, const LENGTH_ENTRY&b ) -> int
[] ( const CONNECTION&a, const CONNECTION&b ) -> int
{
return a.netname < b.netname;
} );
@ -369,17 +367,17 @@ bool DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal( bool aDelayReportMode )
OPT<DRC_CONSTRAINT> lengthConstraint = rule->FindConstraint( LENGTH_CONSTRAINT );
if( lengthConstraint )
checkLengthViolations( *lengthConstraint, matchedConnections );
checkLengths( *lengthConstraint, matchedConnections );
OPT<DRC_CONSTRAINT> skewConstraint = rule->FindConstraint( SKEW_CONSTRAINT );
if( skewConstraint )
checkSkewViolations( *skewConstraint, matchedConnections );
checkSkews( *skewConstraint, matchedConnections );
OPT<DRC_CONSTRAINT> viaCountConstraint = rule->FindConstraint( VIA_COUNT_CONSTRAINT );
if( viaCountConstraint )
checkViaCountViolations( *viaCountConstraint, matchedConnections );
checkViaCounts( *viaCountConstraint, matchedConnections );
}
reportRuleStatistics();

View File

@ -2198,7 +2198,7 @@ void PCB_IO::format( const ZONE* aZone, int aNestLevel ) const
}
// Save the filling segments list
const auto& segs = aZone->FillSegments( layer );
const std::vector<SEG>& segs = aZone->FillSegments( layer );
if( segs.size() )
{
@ -2206,11 +2206,11 @@ void PCB_IO::format( const ZONE* aZone, int aNestLevel ) const
m_out->Print( aNestLevel + 2, "(layer %s)\n",
TO_UTF8( BOARD::GetStandardLayerName( layer ) ) );
for( ZONE_SEGMENT_FILL::const_iterator it = segs.begin(); it != segs.end(); ++it )
for( const SEG& seg : segs )
{
m_out->Print( aNestLevel + 2, "(pts (xy %s) (xy %s))\n",
FormatInternalUnits( wxPoint( it->A ) ).c_str(),
FormatInternalUnits( wxPoint( it->B ) ).c_str() );
FormatInternalUnits( wxPoint( seg.A ) ).c_str(),
FormatInternalUnits( wxPoint( seg.B ) ).c_str() );
}
m_out->Print( aNestLevel + 1, ")\n" );

View File

@ -5255,7 +5255,7 @@ ZONE* PCB_PARSER::parseZONE( BOARD_ITEM_CONTAINER* aParent )
case T_fill_segments:
{
ZONE_SEGMENT_FILL segs;
std::vector<SEG> segs;
for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{

View File

@ -196,7 +196,7 @@ bool ZONE::UnFill()
pair.second.RemoveAllContours();
}
for( std::pair<const PCB_LAYER_ID, ZONE_SEGMENT_FILL>& pair : m_FillSegmList )
for( std::pair<const PCB_LAYER_ID, std::vector<SEG> >& pair : m_FillSegmList )
{
change |= !pair.second.empty();
pair.second.clear();
@ -678,7 +678,7 @@ void ZONE::Move( const wxPoint& offset )
for( std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET>& pair : m_FilledPolysList )
pair.second.Move( offset );
for( std::pair<const PCB_LAYER_ID, ZONE_SEGMENT_FILL>& pair : m_FillSegmList )
for( std::pair<const PCB_LAYER_ID, std::vector<SEG> >& pair : m_FillSegmList )
{
for( SEG& seg : pair.second )
{
@ -715,7 +715,7 @@ void ZONE::Rotate( const wxPoint& aCentre, double aAngle )
for( std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET>& pair : m_FilledPolysList )
pair.second.Rotate( aAngle, VECTOR2I( aCentre ) );
for( std::pair<const PCB_LAYER_ID, ZONE_SEGMENT_FILL>& pair : m_FillSegmList )
for( std::pair<const PCB_LAYER_ID, std::vector<SEG> >& pair : m_FillSegmList )
{
for( SEG& seg : pair.second )
{
@ -752,7 +752,7 @@ void ZONE::Mirror( const wxPoint& aMirrorRef, bool aMirrorLeftRight )
for( std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET>& pair : m_FilledPolysList )
pair.second.Mirror( aMirrorLeftRight, !aMirrorLeftRight, VECTOR2I( aMirrorRef ) );
for( std::pair<const PCB_LAYER_ID, ZONE_SEGMENT_FILL>& pair : m_FillSegmList )
for( std::pair<const PCB_LAYER_ID, std::vector<SEG> >& pair : m_FillSegmList )
{
for( SEG& seg : pair.second )
{

View File

@ -43,7 +43,6 @@ class BOARD;
class ZONE;
class MSG_PANEL_ITEM;
typedef std::vector<SEG> ZONE_SEGMENT_FILL;
/**
* Handle a list of polygons defining a copper zone.
@ -306,13 +305,13 @@ public:
int GetLocalFlags() const { return m_localFlgs; }
void SetLocalFlags( int aFlags ) { m_localFlgs = aFlags; }
ZONE_SEGMENT_FILL& FillSegments( PCB_LAYER_ID aLayer )
std::vector<SEG>& FillSegments( PCB_LAYER_ID aLayer )
{
wxASSERT( m_FillSegmList.count( aLayer ) );
return m_FillSegmList.at( aLayer );
}
const ZONE_SEGMENT_FILL& FillSegments( PCB_LAYER_ID aLayer ) const
const std::vector<SEG>& FillSegments( PCB_LAYER_ID aLayer ) const
{
wxASSERT( m_FillSegmList.count( aLayer ) );
return m_FillSegmList.at( aLayer );
@ -711,7 +710,7 @@ public:
void AddPolygon( const SHAPE_LINE_CHAIN& aPolygon );
void SetFillSegments( PCB_LAYER_ID aLayer, const ZONE_SEGMENT_FILL& aSegments )
void SetFillSegments( PCB_LAYER_ID aLayer, const std::vector<SEG>& aSegments )
{
m_FillSegmList[aLayer] = aSegments;
}
@ -905,7 +904,7 @@ protected:
* Segments used to fill the zone (#m_FillMode ==1 ), when fill zone by segment is used.
* In this case the segments have #m_ZoneMinThickness width.
*/
std::map<PCB_LAYER_ID, ZONE_SEGMENT_FILL> m_FillSegmList;
std::map<PCB_LAYER_ID, std::vector<SEG> > m_FillSegmList;
/* set of filled polygons used to draw a zone as a filled area.
* from outlines (m_Poly) but unlike m_Poly these filled polygons have no hole