KiCad PCB EDA Suite
CADSTAR_ARCHIVE_PARSER::SHAPE Struct Reference

#include <cadstar_archive_parser.h>

Inheritance diagram for CADSTAR_ARCHIVE_PARSER::SHAPE:
CADSTAR_ARCHIVE_PARSER::PARSER

Public Member Functions

void Parse (XNODE *aNode, PARSER_CONTEXT *aContext) override
 
SHAPE_LINE_CHAIN OutlineAsChain (const std::function< VECTOR2I(const VECTOR2I &)> aCadstarToKicadPointCallback, double aAccuracy) const
 
SHAPE_POLY_SET ConvertToPolySet (const std::function< VECTOR2I(const VECTOR2I &)> aCadstarToKicadPointCallback, double aAccuracy) const
 

Static Public Member Functions

static bool IsShape (XNODE *aNode)
 

Public Attributes

SHAPE_TYPE Type
 
std::vector< VERTEXVertices
 
std::vector< CUTOUTCutouts
 Not Applicable to OPENSHAPE Type. More...
 
wxString HatchCodeID
 Only Applicable for HATCHED Type. More...
 

Detailed Description

Definition at line 476 of file cadstar_archive_parser.h.

Member Function Documentation

◆ ConvertToPolySet()

SHAPE_POLY_SET CADSTAR_ARCHIVE_PARSER::SHAPE::ConvertToPolySet ( const std::function< VECTOR2I(const VECTOR2I &)>  aCadstarToKicadPointCallback,
double  aAccuracy 
) const

Definition at line 613 of file cadstar_archive_parser.cpp.

616{
617 SHAPE_POLY_SET polyset;
618
619 wxCHECK( Type != SHAPE_TYPE::OPENSHAPE, polyset ); // We shouldn't convert openshapes to polyset!
620
621 polyset.AddOutline( OutlineAsChain( aCadstarToKicadPointCallback, aAccuracy ) );
622
623 for( const auto& cutout : Cutouts )
624 {
625 SHAPE_LINE_CHAIN hole;
626
627 if( cutout.Vertices.size() == 0 )
628 continue;
629
630 for( const auto& cutoutVertex : cutout.Vertices )
631 cutoutVertex.AppendToChain( &hole, aCadstarToKicadPointCallback, aAccuracy );
632
633 hole.SetClosed( true );
634
635 // Append after closing, to ensre first and last point remain the same
636 cutout.Vertices.at( 0 ).AppendToChain( &hole, aCadstarToKicadPointCallback, aAccuracy );
637
638 polyset.AddHole( hole );
639 }
640
641 return polyset;
642}
@ OPENSHAPE
Unfilled open shape. Cannot have cutouts.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
Represent a set of closed polygons.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
int AddHole(const SHAPE_LINE_CHAIN &aHole, int aOutline=-1)
Return the area of this poly set.
SHAPE_LINE_CHAIN OutlineAsChain(const std::function< VECTOR2I(const VECTOR2I &)> aCadstarToKicadPointCallback, double aAccuracy) const
std::vector< CUTOUT > Cutouts
Not Applicable to OPENSHAPE Type.

References SHAPE_POLY_SET::AddHole(), SHAPE_POLY_SET::AddOutline(), CADSTAR_ARCHIVE_PARSER::OPENSHAPE, and SHAPE_LINE_CHAIN::SetClosed().

Referenced by CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary().

◆ IsShape()

bool CADSTAR_ARCHIVE_PARSER::SHAPE::IsShape ( XNODE aNode)
static

Definition at line 533 of file cadstar_archive_parser.cpp.

534{
535 wxString aNodeName = aNode->GetName();
536
537 if( aNodeName == wxT( "OPENSHAPE" ) || aNodeName == wxT( "OUTLINE" )
538 || aNodeName == wxT( "SOLID" ) || aNodeName == wxT( "HATCHED" ) )
539 {
540 return true;
541 }
542 else
543 {
544 return false;
545 }
546}

Referenced by CADSTAR_SCH_ARCHIVE_PARSER::BUS::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COMPONENT_AREA::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::CADSTAR_BOARD::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::AREA::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::TEMPLATE::Parse(), and CADSTAR_PCB_ARCHIVE_PARSER::COPPER::Parse().

◆ OutlineAsChain()

SHAPE_LINE_CHAIN CADSTAR_ARCHIVE_PARSER::SHAPE::OutlineAsChain ( const std::function< VECTOR2I(const VECTOR2I &)>  aCadstarToKicadPointCallback,
double  aAccuracy 
) const

Definition at line 589 of file cadstar_archive_parser.cpp.

592{
593 SHAPE_LINE_CHAIN outline;
594
595 if( Vertices.size() == 0 )
596 return outline;
597
598 for( const auto& vertex : Vertices )
599 vertex.AppendToChain( &outline, aCadstarToKicadPointCallback, aAccuracy );
600
602 {
603 outline.SetClosed( true );
604
605 // Append after closing, to ensre first and last point remain the same
606 Vertices.at( 0 ).AppendToChain( &outline, aCadstarToKicadPointCallback, aAccuracy );
607 }
608
609 return outline;
610}

References CADSTAR_ARCHIVE_PARSER::OPENSHAPE, and SHAPE_LINE_CHAIN::SetClosed().

◆ Parse()

void CADSTAR_ARCHIVE_PARSER::SHAPE::Parse ( XNODE aNode,
PARSER_CONTEXT aContext 
)
overridevirtual

Implements CADSTAR_ARCHIVE_PARSER::PARSER.

Definition at line 549 of file cadstar_archive_parser.cpp.

550{
551 wxASSERT( IsShape( aNode ) );
552
553 wxString aNodeName = aNode->GetName();
554
555 if( aNodeName == wxT( "OPENSHAPE" ) )
556 {
558 Vertices = ParseAllChildVertices( aNode, aContext, true );
559 Cutouts.clear();
560 HatchCodeID = wxEmptyString;
561 }
562 else if( aNodeName == wxT( "OUTLINE" ) )
563 {
565 Vertices = ParseAllChildVertices( aNode, aContext, false );
566 Cutouts = ParseAllChildCutouts( aNode, aContext, false );
567 HatchCodeID = wxEmptyString;
568 }
569 else if( aNodeName == wxT( "SOLID" ) )
570 {
572 Vertices = ParseAllChildVertices( aNode, aContext, false );
573 Cutouts = ParseAllChildCutouts( aNode, aContext, false );
574 HatchCodeID = wxEmptyString;
575 }
576 else if( aNodeName == wxT( "HATCHED" ) )
577 {
579 Vertices = ParseAllChildVertices( aNode, aContext, false );
580 Cutouts = ParseAllChildCutouts( aNode, aContext, false );
582 }
583 else
584 {
585 wxASSERT_MSG( true, wxT( "Unknown SHAPE type" ) );
586 }
587}
static std::vector< CUTOUT > ParseAllChildCutouts(XNODE *aNode, PARSER_CONTEXT *aContext, bool aTestAllChildNodes=false)
if no children are present, it just returns an empty vector (without throwing an exception)
static std::vector< VERTEX > ParseAllChildVertices(XNODE *aNode, PARSER_CONTEXT *aContext, bool aTestAllChildNodes=false)
if no children are present, it just returns an empty vector (without throwing an exception)
@ OUTLINE
Unfilled closed shape.
@ SOLID
Filled closed shape (solid fill).
@ HATCHED
Filled closed shape (hatch fill).
static wxString GetXmlAttributeIDString(XNODE *aNode, unsigned int aID, bool aIsRequired=true)
wxString HatchCodeID
Only Applicable for HATCHED Type.

References CADSTAR_ARCHIVE_PARSER::GetXmlAttributeIDString(), CADSTAR_ARCHIVE_PARSER::HATCHED, CADSTAR_ARCHIVE_PARSER::OPENSHAPE, CADSTAR_ARCHIVE_PARSER::OUTLINE, CADSTAR_ARCHIVE_PARSER::ParseAllChildCutouts(), CADSTAR_ARCHIVE_PARSER::ParseAllChildVertices(), and CADSTAR_ARCHIVE_PARSER::SOLID.

Member Data Documentation

◆ Cutouts

◆ HatchCodeID

wxString CADSTAR_ARCHIVE_PARSER::SHAPE::HatchCodeID

Only Applicable for HATCHED Type.

Definition at line 481 of file cadstar_archive_parser.h.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::loadCoppers().

◆ Type

◆ Vertices


The documentation for this struct was generated from the following files: