KiCad PCB EDA Suite
SHAPE_RECT Class Reference

#include <shape_rect.h>

Inheritance diagram for SHAPE_RECT:
SHAPE SHAPE_BASE

Public Member Functions

 SHAPE_RECT ()
 Create an empty (0-sized) rectangle. More...
 
 SHAPE_RECT (const BOX2I &aBox)
 Create a rectangle defined by a BOX2. More...
 
 SHAPE_RECT (int aX0, int aY0, int aW, int aH)
 Create a rectangle defined by top-left corner (aX0, aY0), width aW and height aH. More...
 
 SHAPE_RECT (const VECTOR2I &aP0, int aW, int aH)
 Create a rectangle defined by top-left corner aP0, width aW and height aH. More...
 
 SHAPE_RECT (const SHAPE_RECT &aOther)
 
SHAPEClone () const override
 Return a dynamically allocated copy of the shape. More...
 
const BOX2I BBox (int aClearance=0) const override
 Compute a bounding box of the shape, with a margin of aClearance a collision. More...
 
int Diagonal () const
 Return length of the diagonal of the rectangle. More...
 
bool Collide (const SHAPE *aShape, int aClearance, VECTOR2I *aMTV) const override
 Check if the boundary of shape (this) lies closer to the shape aShape than aClearance, indicating a collision. More...
 
bool Collide (const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
 
bool Collide (const SEG &aSeg, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
 Check if the boundary of shape (this) lies closer to the point aP than aClearance, indicating a collision. More...
 
const VECTOR2IGetPosition () const
 
const VECTOR2I GetSize () const
 
const int GetWidth () const
 
const int GetHeight () const
 
void Move (const VECTOR2I &aVector) override
 
void Rotate (const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
 This function has limited utility for SHAPE_RECT as non-cartesian rotations will distort the rectangle. More...
 
bool IsSolid () const override
 
const SHAPE_LINE_CHAIN Outline () const
 
virtual const std::string Format (bool aCplusPlus=true) const override
 
int GetClearance (const SHAPE *aOther) const
 Return the actual minimum distance between two shapes. More...
 
bool IsNull () const
 Return true if the shape is a null shape. More...
 
virtual bool Collide (const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const
 Check if the boundary of shape (this) lies closer to the point aP than aClearance, indicating a collision. More...
 
virtual VECTOR2I Centre () const
 Compute a center-of-mass of the shape. More...
 
virtual bool Parse (std::stringstream &aStream)
 
FACETNewFacet ()
 
SGNODECalcShape (SGNODE *aParent, SGNODE *aColor, WRL1_ORDER aVertexOrder, float aCreaseLimit=0.74317, bool isVRML2=false)
 
SHAPE_TYPE Type () const
 Return the type of the shape. More...
 
wxString TypeName () const
 
virtual bool HasIndexableSubshapes () const
 
virtual size_t GetIndexableSubshapeCount () const
 
virtual void GetIndexableSubshapes (std::vector< const SHAPE * > &aSubshapes) const
 

Static Public Attributes

static const int MIN_PRECISION_IU = 4
 This is the minimum precision for all the points in a shape. More...
 

Protected Types

typedef VECTOR2I::extended_type ecoord
 

Protected Attributes

SHAPE_TYPE m_type
 < type of our shape More...
 

Private Attributes

VECTOR2I m_p0
 Top-left corner. More...
 
int m_w
 Width. More...
 
int m_h
 Height. More...
 
std::list< FACET * > facets
 

Detailed Description

Definition at line 37 of file shape_rect.h.

Member Typedef Documentation

◆ ecoord

typedef VECTOR2I::extended_type SHAPE::ecoord
protectedinherited

Definition at line 250 of file shape.h.

Constructor & Destructor Documentation

◆ SHAPE_RECT() [1/5]

SHAPE_RECT::SHAPE_RECT ( )
inline

Create an empty (0-sized) rectangle.

Definition at line 43 of file shape_rect.h.

43 :
44 SHAPE( SH_RECT ),
45 m_w( 0 ),
46 m_h( 0 )
47 {}
int m_h
Height.
Definition: shape_rect.h:196
int m_w
Width.
Definition: shape_rect.h:195
SHAPE(SHAPE_TYPE aType)
Create an empty shape of type aType.
Definition: shape.h:134
@ SH_RECT
axis-aligned rectangle
Definition: shape.h:45

Referenced by Clone().

◆ SHAPE_RECT() [2/5]

SHAPE_RECT::SHAPE_RECT ( const BOX2I aBox)
inline

Create a rectangle defined by a BOX2.

Definition at line 52 of file shape_rect.h.

52 :
53 SHAPE( SH_RECT ),
54 m_p0( aBox.GetPosition() ),
55 m_w( aBox.GetWidth() ),
56 m_h( aBox.GetHeight() )
57 {}
const Vec & GetPosition() const
Definition: box2.h:184
coord_type GetHeight() const
Definition: box2.h:188
coord_type GetWidth() const
Definition: box2.h:187
VECTOR2I m_p0
Top-left corner.
Definition: shape_rect.h:194

◆ SHAPE_RECT() [3/5]

SHAPE_RECT::SHAPE_RECT ( int  aX0,
int  aY0,
int  aW,
int  aH 
)
inline

Create a rectangle defined by top-left corner (aX0, aY0), width aW and height aH.

Definition at line 62 of file shape_rect.h.

62 :
63 SHAPE( SH_RECT ),
64 m_p0( aX0, aY0 ),
65 m_w( aW ),
66 m_h( aH )
67 {}

◆ SHAPE_RECT() [4/5]

SHAPE_RECT::SHAPE_RECT ( const VECTOR2I aP0,
int  aW,
int  aH 
)
inline

Create a rectangle defined by top-left corner aP0, width aW and height aH.

Definition at line 72 of file shape_rect.h.

72 :
73 SHAPE( SH_RECT ),
74 m_p0( aP0 ),
75 m_w( aW ),
76 m_h( aH )
77 {}

◆ SHAPE_RECT() [5/5]

SHAPE_RECT::SHAPE_RECT ( const SHAPE_RECT aOther)
inline

Definition at line 79 of file shape_rect.h.

79 :
80 SHAPE( SH_RECT ),
81 m_p0( aOther.m_p0 ),
82 m_w( aOther.m_w ),
83 m_h( aOther.m_h )
84 {};

Member Function Documentation

◆ BBox()

const BOX2I SHAPE_RECT::BBox ( int  aClearance = 0) const
inlineoverridevirtual

Compute a bounding box of the shape, with a margin of aClearance a collision.

Parameters
aClearancehow much the bounding box is expanded wrs to the minimum enclosing rectangle for the shape.
Returns
the bounding box.

Implements SHAPE.

Definition at line 92 of file shape_rect.h.

93 {
94 BOX2I bbox( VECTOR2I( m_p0.x - aClearance, m_p0.y - aClearance ),
95 VECTOR2I( m_w + 2 * aClearance, m_h + 2 * aClearance ) );
96 return bbox;
97 }
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590

References m_h, m_p0, m_w, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Collide(), and Collide().

◆ CalcShape()

SGNODE * SHAPE::CalcShape ( SGNODE aParent,
SGNODE aColor,
WRL1_ORDER  aVertexOrder,
float  aCreaseLimit = 0.74317,
bool  isVRML2 = false 
)
inherited

Definition at line 703 of file wrlfacet.cpp.

705{
706 if( facets.empty() || !facets.front()->HasMinPoints() )
707 return nullptr;
708
709 std::vector< std::list< FACET* > > flist;
710
711 // determine the max. index and size flist as appropriate
712 std::list< FACET* >::iterator sF = facets.begin();
713 std::list< FACET* >::iterator eF = facets.end();
714
715 int maxIdx = 0;
716 int tmi;
717 float maxV = 0.0;
718 float tV = 0.0;
719
720 while( sF != eF )
721 {
722 tV = ( *sF )->CalcFaceNormal();
723 tmi = ( *sF )->GetMaxIndex();
724
725 if( tmi > maxIdx )
726 maxIdx = tmi;
727
728 if( tV > maxV )
729 maxV = tV;
730
731 ++sF;
732 }
733
734 ++maxIdx;
735
736 if( maxIdx < 3 )
737 return nullptr;
738
739 flist.resize( maxIdx );
740
741 // create the lists of facets common to indices
742 sF = facets.begin();
743
744 while( sF != eF )
745 {
746 ( *sF )->Renormalize( tV );
747 ( *sF )->CollectVertices( flist );
748 ++sF;
749 }
750
751 // calculate the normals
752 size_t vs = flist.size();
753
754 for( size_t i = 0; i < vs; ++i )
755 {
756 sF = flist[i].begin();
757 eF = flist[i].end();
758
759 while( sF != eF )
760 {
761 ( *sF )->CalcVertexNormal( static_cast<int>( i ), flist[i], aCreaseLimit );
762 ++sF;
763 }
764 }
765
766 std::vector< WRLVEC3F > vertices;
767 std::vector< WRLVEC3F > normals;
768 std::vector< SGCOLOR > colors;
769
770 // push the facet data to the final output list
771 sF = facets.begin();
772 eF = facets.end();
773
774 while( sF != eF )
775 {
776 ( *sF )->GetData( vertices, normals, colors, aVertexOrder );
777 ++sF;
778 }
779
780 flist.clear();
781
782 if( vertices.size() < 3 )
783 return nullptr;
784
785 IFSG_SHAPE shapeNode( false );
786
787 if( !isVRML2 )
788 {
789 shapeNode.NewNode( aParent );
790
791 if( aColor )
792 {
793 if( nullptr == S3D::GetSGNodeParent( aColor ) )
794 shapeNode.AddChildNode( aColor );
795 else
796 shapeNode.AddRefNode( aColor );
797 }
798 }
799
800 std::vector< SGPOINT > lCPts; // vertex points in SGPOINT (double) format
801 std::vector< SGVECTOR > lCNorm; // per-vertex normals
802 vs = vertices.size();
803
804 for( size_t i = 0; i < vs; ++i )
805 {
806 SGPOINT pt;
807 pt.x = vertices[i].x;
808 pt.y = vertices[i].y;
809 pt.z = vertices[i].z;
810 lCPts.push_back( pt );
811 lCNorm.emplace_back( normals[i].x, normals[i].y, normals[i].z );
812 }
813
814 vertices.clear();
815 normals.clear();
816
817 IFSG_FACESET fsNode( false );
818
819 if( !isVRML2 )
820 fsNode.NewNode( shapeNode );
821 else
822 fsNode.NewNode( aParent );
823
824 IFSG_COORDS cpNode( fsNode );
825 cpNode.SetCoordsList( lCPts.size(), &lCPts[0] );
826 IFSG_COORDINDEX ciNode( fsNode );
827
828 for( int i = 0; i < (int)lCPts.size(); ++i )
829 ciNode.AddIndex( i );
830
831 IFSG_NORMALS nmNode( fsNode );
832 nmNode.SetNormalList( lCNorm.size(), &lCNorm[0] );
833
834 if( !colors.empty() )
835 {
836 IFSG_COLORS nmColor( fsNode );
837 nmColor.SetColorList( colors.size(), &colors[0] );
838 colors.clear();
839 }
840
841 if( !isVRML2 )
842 return shapeNode.GetRawPtr();
843
844 return fsNode.GetRawPtr();
845}
IFSG_COLORS is the wrapper for SGCOLORS.
Definition: ifsg_colors.h:42
IFSG_COORDINDEX is the wrapper for SGCOORDINDEX.
IFSG_COORDS is the wrapper for SGCOORDS.
Definition: ifsg_coords.h:41
IFSG_FACESET is the wrapper for the SGFACESET class.
Definition: ifsg_faceset.h:41
IFSG_NORMALS is the wrapper for the SGNORMALS class.
Definition: ifsg_normals.h:41
IFSG_SHAPE is the wrapper for the SGSHAPE class.
Definition: ifsg_shape.h:41
double z
Definition: sg_base.h:72
double x
Definition: sg_base.h:70
double y
Definition: sg_base.h:71
std::list< FACET * > facets
Definition: wrlfacet.h:143
SGLIB_API SGNODE * GetSGNodeParent(SGNODE *aNode)
Definition: ifsg_api.cpp:494

References IFSG_NODE::AddChildNode(), IFSG_INDEX::AddIndex(), IFSG_NODE::AddRefNode(), SHAPE::facets, IFSG_NODE::GetRawPtr(), S3D::GetSGNodeParent(), IFSG_FACESET::NewNode(), IFSG_SHAPE::NewNode(), IFSG_COLORS::SetColorList(), IFSG_COORDS::SetCoordsList(), IFSG_NORMALS::SetNormalList(), SGPOINT::x, SGPOINT::y, and SGPOINT::z.

Referenced by WRL2FACESET::TranslateToSG(), X3DIFACESET::TranslateToSG(), and WRL1FACESET::TranslateToSG().

◆ Centre()

virtual VECTOR2I SHAPE::Centre ( ) const
inlinevirtualinherited

Compute a center-of-mass of the shape.

Returns
the center-of-mass point

Definition at line 230 of file shape.h.

231 {
232 return BBox( 0 ).Centre(); // if nothing better is available....
233 }
Vec Centre() const
Definition: box2.h:70
virtual const BOX2I BBox(int aClearance=0) const =0
Compute a bounding box of the shape, with a margin of aClearance a collision.

References SHAPE::BBox(), and BOX2< Vec >::Centre().

Referenced by Collide().

◆ Clone()

SHAPE * SHAPE_RECT::Clone ( ) const
inlineoverridevirtual

Return a dynamically allocated copy of the shape.

Return values
copyof the shape

Reimplemented from SHAPE.

Definition at line 86 of file shape_rect.h.

87 {
88 return new SHAPE_RECT( *this );
89 }
SHAPE_RECT()
Create an empty (0-sized) rectangle.
Definition: shape_rect.h:43

References SHAPE_RECT().

◆ Collide() [1/4]

bool SHAPE_RECT::Collide ( const SEG aSeg,
int  aClearance = 0,
int *  aActual = nullptr,
VECTOR2I aLocation = nullptr 
) const
overridevirtual

Check if the boundary of shape (this) lies closer to the point aP than aClearance, indicating a collision.

Parameters
aActual[out] an optional pointer to an int to store the actual distance in the event of a collision.
aLocation[out] an option pointer to a point to store a nearby location in the event of a collision.
Returns
true, if there is a collision.

Implements SHAPE.

Definition at line 29 of file shape_rect.cpp.

30{
31 BOX2I bbox( BBox() );
32
33 if( bbox.Contains( aSeg.A ) )
34 {
35 if( aLocation )
36 *aLocation = aSeg.A;
37
38 if( aActual )
39 *aActual = 0;
40
41 return true;
42 }
43
44 if( bbox.Contains( aSeg.B ) )
45 {
46 if( aLocation )
47 *aLocation = aSeg.B;
48
49 if( aActual )
50 *aActual = 0;
51
52 return true;
53 }
54
55 VECTOR2I corners[] = { VECTOR2I( m_p0.x, m_p0.y ),
56 VECTOR2I( m_p0.x, m_p0.y + m_h ),
57 VECTOR2I( m_p0.x + m_w, m_p0.y + m_h ),
58 VECTOR2I( m_p0.x + m_w, m_p0.y ),
59 VECTOR2I( m_p0.x, m_p0.y ) };
60
61 SEG::ecoord closest_dist_sq = VECTOR2I::ECOORD_MAX;
62 VECTOR2I nearest;
63
64 for( int i = 0; i < 4; i++ )
65 {
66 SEG side( corners[i], corners[ i + 1] );
67 SEG::ecoord dist_sq = side.SquaredDistance( aSeg );
68
69 if( dist_sq < closest_dist_sq )
70 {
71 if ( aLocation )
72 {
73 nearest = side.NearestPoint( aSeg );
74 }
75
76 closest_dist_sq = dist_sq;
77 }
78 }
79
80 if( closest_dist_sq == 0 || closest_dist_sq < SEG::Square( aClearance ) )
81 {
82 if( aActual )
83 *aActual = sqrt( closest_dist_sq );
84
85 if( aLocation )
86 *aLocation = nearest;
87
88 return true;
89 }
90
91 return false;
92}
Definition: seg.h:42
VECTOR2I A
Definition: seg.h:49
VECTOR2I::extended_type ecoord
Definition: seg.h:44
VECTOR2I B
Definition: seg.h:50
static SEG::ecoord Square(int a)
Definition: seg.h:123
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
Definition: shape_rect.h:92
static constexpr extended_type ECOORD_MAX
Definition: vector2d.h:75

References SEG::A, SEG::B, BBox(), BOX2< Vec >::Contains(), VECTOR2< int >::ECOORD_MAX, m_h, m_p0, m_w, SEG::NearestPoint(), SEG::Square(), SEG::SquaredDistance(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ Collide() [2/4]

bool SHAPE_RECT::Collide ( const SHAPE aShape,
int  aClearance,
VECTOR2I aMTV 
) const
inlineoverridevirtual

Check if the boundary of shape (this) lies closer to the shape aShape than aClearance, indicating a collision.

Parameters
aShapeshape to check collision against
aClearanceminimum clearance
aMTVminimum translation vector
aActual[out] an optional pointer to an int to store the actual distance in the event of a collision.
aLocation[out] an option pointer to a point to store a nearby location in the event of a collision.
Returns
true, if there is a collision.

Reimplemented from SHAPE.

Definition at line 109 of file shape_rect.h.

110 {
111 return SHAPE::Collide( aShape, aClearance, aMTV );
112 }
virtual bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const
Check if the boundary of shape (this) lies closer to the point aP than aClearance,...
Definition: shape.h:179

References SHAPE::Collide().

Referenced by Collide(), EE_SELECTION_TOOL::GuessSelectionCandidates(), and SCH_JUNCTION::HitTest().

◆ Collide() [3/4]

bool SHAPE_RECT::Collide ( const SHAPE aShape,
int  aClearance = 0,
int *  aActual = nullptr,
VECTOR2I aLocation = nullptr 
) const
inlineoverridevirtual

Reimplemented from SHAPE.

Definition at line 114 of file shape_rect.h.

116 {
117 return SHAPE::Collide( aShape, aClearance, aActual, aLocation );
118 }

References SHAPE::Collide().

◆ Collide() [4/4]

virtual bool SHAPE::Collide ( const VECTOR2I aP,
int  aClearance = 0,
int *  aActual = nullptr,
VECTOR2I aLocation = nullptr 
) const
inlinevirtualinherited

Check if the boundary of shape (this) lies closer to the point aP than aClearance, indicating a collision.

Parameters
aActual[out] an optional pointer to an int to store the actual distance in the event of a collision.
aLocation[out] an option pointer to a point to store a nearby location in the event of a collision.
Returns
true, if there is a collision.

Reimplemented in SHAPE_LINE_CHAIN_BASE, SHAPE_ARC, SHAPE_LINE_CHAIN, SHAPE_POLY_SET, and SHAPE_SEGMENT.

Definition at line 179 of file shape.h.

181 {
182 return Collide( SEG( aP, aP ), aClearance, aActual, aLocation );
183 }

References SHAPE::Collide().

Referenced by BOOST_AUTO_TEST_CASE(), DRC_RTREE::CheckColliding(), FOOTPRINT::CheckShortingPads(), SHAPE_COMPOUND::Collide(), Collide(), SHAPE_SEGMENT::Collide(), SHAPE_ARC::Collide(), SHAPE_POLY_SET::Collide(), SHAPE::Collide(), CN_ZONE_LAYER::Collide(), collide(), PNS::ITEM::collideSimple(), PNS::SHOVE::onCollidingVia(), PNS::HIT_VISITOR::operator()(), RN_NET::optimizeRNEdges(), PNS::VIA::PushoutForce(), DRC_RTREE::QueryColliding(), PNS::OPTIMIZER::smartPadsSingle(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::testAgainstEdge(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstItem(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem(), and DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem().

◆ Diagonal()

int SHAPE_RECT::Diagonal ( ) const
inline

Return length of the diagonal of the rectangle.

Returns
diagonal length

Definition at line 104 of file shape_rect.h.

105 {
106 return VECTOR2I( m_w, m_h ).EuclideanNorm();
107 }
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
Definition: vector2d.h:265

References VECTOR2< T >::EuclideanNorm(), m_h, and m_w.

◆ Format()

const std::string SHAPE_RECT::Format ( bool  aCplusPlus = true) const
overridevirtual

Reimplemented from SHAPE.

Definition at line 94 of file shape_rect.cpp.

95{
96 std::stringstream ss;
97
98 ss << "SHAPE_RECT( ";
99 ss << m_p0.x;
100 ss << ", ";
101 ss << m_p0.y;
102 ss << ", ";
103 ss << m_w;
104 ss << ", ";
105 ss << m_h;
106 ss << ");";
107
108 return ss.str();
109}

References m_h, m_p0, m_w, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ GetClearance()

int SHAPE::GetClearance ( const SHAPE aOther) const
inherited

Return the actual minimum distance between two shapes.

Return values
distancein IU

Definition at line 49 of file shape.cpp.

50{
51 int actual_clearance = std::numeric_limits<int>::max();
52 std::vector<const SHAPE*> a_shapes;
53 std::vector<const SHAPE*> b_shapes;
54
55 GetIndexableSubshapes( a_shapes );
56 aOther->GetIndexableSubshapes( b_shapes );
57
58 if( GetIndexableSubshapeCount() == 0 )
59 a_shapes.push_back( this );
60
61 if( aOther->GetIndexableSubshapeCount() == 0 )
62 b_shapes.push_back( aOther );
63
64 for( const SHAPE* a : a_shapes )
65 {
66 for( const SHAPE* b : b_shapes )
67 {
68 int temp_dist = 0;
69 a->Collide( b, std::numeric_limits<int>::max() / 2, &temp_dist );
70
71 if( temp_dist < actual_clearance )
72 actual_clearance = temp_dist;
73 }
74 }
75
76 return actual_clearance;
77}
virtual size_t GetIndexableSubshapeCount() const
Definition: shape.h:111
virtual void GetIndexableSubshapes(std::vector< const SHAPE * > &aSubshapes) const
Definition: shape.h:113
An abstract shape on 2D plane.
Definition: shape.h:124

References SHAPE_BASE::GetIndexableSubshapeCount(), and SHAPE_BASE::GetIndexableSubshapes().

◆ GetHeight()

const int SHAPE_RECT::GetHeight ( ) const
inline
Returns
the height of the rectangle.

Definition at line 151 of file shape_rect.h.

152 {
153 return m_h;
154 }

References m_h.

Referenced by KIGFX::PCB_PAINTER::draw().

◆ GetIndexableSubshapeCount()

virtual size_t SHAPE_BASE::GetIndexableSubshapeCount ( ) const
inlinevirtualinherited

Reimplemented in SHAPE_COMPOUND, and SHAPE_POLY_SET.

Definition at line 111 of file shape.h.

111{ return 0; }

Referenced by SHAPE::GetClearance().

◆ GetIndexableSubshapes()

virtual void SHAPE_BASE::GetIndexableSubshapes ( std::vector< const SHAPE * > &  aSubshapes) const
inlinevirtualinherited

Reimplemented in SHAPE_COMPOUND, and SHAPE_POLY_SET.

Definition at line 113 of file shape.h.

113{ }

Referenced by SHAPE_COMPOUND::AddShape(), SHAPE::GetClearance(), and ROUTER_PREVIEW_ITEM::ViewDraw().

◆ GetPosition()

const VECTOR2I & SHAPE_RECT::GetPosition ( ) const
inline
Returns
the top left corner of the rectangle.

Definition at line 127 of file shape_rect.h.

128 {
129 return m_p0;
130 }

References m_p0.

Referenced by PNS::buildHullForPrimitiveShape(), Collide(), BOARD_ADAPTER::createPadWithMargin(), KIGFX::PCB_PAINTER::draw(), ROUTER_PREVIEW_ITEM::drawShape(), and PNS::OPTIMIZER::rectBreakouts().

◆ GetSize()

const VECTOR2I SHAPE_RECT::GetSize ( ) const
inline
Returns
the size of the rectangle.

Definition at line 135 of file shape_rect.h.

136 {
137 return VECTOR2I( m_w, m_h );
138 }

References m_h, and m_w.

Referenced by PNS::buildHullForPrimitiveShape(), Collide(), BOARD_ADAPTER::createPadWithMargin(), KIGFX::PCB_PAINTER::draw(), ROUTER_PREVIEW_ITEM::drawShape(), and PNS::OPTIMIZER::rectBreakouts().

◆ GetWidth()

const int SHAPE_RECT::GetWidth ( ) const
inline
Returns
the width of the rectangle.

Definition at line 143 of file shape_rect.h.

144 {
145 return m_w;
146 }

References m_w.

Referenced by KIGFX::PCB_PAINTER::draw().

◆ HasIndexableSubshapes()

virtual bool SHAPE_BASE::HasIndexableSubshapes ( ) const
inlinevirtualinherited

Reimplemented in SHAPE_COMPOUND, and SHAPE_POLY_SET.

Definition at line 106 of file shape.h.

107 {
108 return false;
109 }

Referenced by SHAPE_COMPOUND::AddShape(), and ROUTER_PREVIEW_ITEM::ViewDraw().

◆ IsNull()

bool SHAPE::IsNull ( ) const
inlineinherited

Return true if the shape is a null shape.

Return values
trueif null :-)

Definition at line 164 of file shape.h.

165 {
166 return m_type == SH_NULL;
167 }
SHAPE_TYPE m_type
< type of our shape
Definition: shape.h:117
@ SH_NULL
empty shape (no shape...),
Definition: shape.h:53

References SHAPE_BASE::m_type, and SH_NULL.

◆ IsSolid()

bool SHAPE_RECT::IsSolid ( ) const
inlineoverridevirtual

Implements SHAPE.

Definition at line 174 of file shape_rect.h.

175 {
176 return true;
177 }

◆ Move()

void SHAPE_RECT::Move ( const VECTOR2I aVector)
inlineoverridevirtual

Implements SHAPE.

Definition at line 156 of file shape_rect.h.

157 {
158 m_p0 += aVector;
159 }

References m_p0.

◆ NewFacet()

FACET * SHAPE::NewFacet ( )
inherited

Definition at line 695 of file wrlfacet.cpp.

696{
697 FACET* fp = new FACET;
698 facets.push_back( fp );
699 return fp;
700}
Definition: wrlfacet.h:43

References SHAPE::facets.

Referenced by WRL2FACESET::TranslateToSG(), X3DIFACESET::TranslateToSG(), and WRL1FACESET::TranslateToSG().

◆ Outline()

const SHAPE_LINE_CHAIN SHAPE_RECT::Outline ( ) const
inline

Definition at line 179 of file shape_rect.h.

180 {
182 rv.Append( m_p0 );
183 rv.Append( m_p0.x, m_p0.y + m_h );
184 rv.Append( m_p0.x + m_w, m_p0.y + m_h );
185 rv.Append( m_p0.x + m_w, m_p0.y );
186 rv.Append( m_p0 );
187 rv.SetClosed( true );
188 return rv;
189 }
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.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.

References SHAPE_LINE_CHAIN::Append(), m_h, m_p0, m_w, SHAPE_LINE_CHAIN::SetClosed(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Collide(), and PAD::MergePrimitivesAsPolygon().

◆ Parse()

bool SHAPE::Parse ( std::stringstream &  aStream)
virtualinherited

Reimplemented in SHAPE_LINE_CHAIN, and SHAPE_POLY_SET.

Definition at line 34 of file shape.cpp.

35{
36 assert( false );
37 return false;
38}

◆ Rotate()

void SHAPE_RECT::Rotate ( const EDA_ANGLE aAngle,
const VECTOR2I aCenter = { 0, 0 } 
)
inlineoverridevirtual

This function has limited utility for SHAPE_RECT as non-cartesian rotations will distort the rectangle.

If you might need to handle non-90° rotations then the SHAPE_RECT should first be converted to a SHAPE_SIMPLE which can then be free-rotated.

Implements SHAPE.

Definition at line 166 of file shape_rect.h.

166 { 0, 0 } ) override
167 {
168 RotatePoint( m_p0, aCenter, aAngle );
169
170 if( abs( aAngle.Sin() ) == 1 )
171 std::swap( m_h, m_w );
172 }
double Sin() const
Definition: eda_angle.h:206
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:418
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183

◆ Type()

◆ TypeName()

wxString SHAPE_BASE::TypeName ( ) const
inlineinherited

Definition at line 101 of file shape.h.

102 {
103 return SHAPE_TYPE_asString( m_type );
104 }
static wxString SHAPE_TYPE_asString(SHAPE_TYPE a)
Definition: shape.h:57

References SHAPE_BASE::m_type, and SHAPE_TYPE_asString().

Referenced by Collide().

Member Data Documentation

◆ facets

std::list< FACET* > SHAPE::facets
privateinherited

Definition at line 143 of file wrlfacet.h.

Referenced by SHAPE::CalcShape(), and SHAPE::NewFacet().

◆ m_h

int SHAPE_RECT::m_h
private

Height.

Definition at line 196 of file shape_rect.h.

Referenced by BBox(), Collide(), Diagonal(), Format(), GetHeight(), GetSize(), and Outline().

◆ m_p0

VECTOR2I SHAPE_RECT::m_p0
private

Top-left corner.

Definition at line 194 of file shape_rect.h.

Referenced by BBox(), Collide(), Format(), GetPosition(), Move(), and Outline().

◆ m_type

SHAPE_TYPE SHAPE_BASE::m_type
protectedinherited

< type of our shape

Definition at line 117 of file shape.h.

Referenced by SHAPE::Format(), SHAPE::IsNull(), SHAPE_BASE::Type(), and SHAPE_BASE::TypeName().

◆ m_w

int SHAPE_RECT::m_w
private

Width.

Definition at line 195 of file shape_rect.h.

Referenced by BBox(), Collide(), Diagonal(), Format(), GetSize(), GetWidth(), and Outline().

◆ MIN_PRECISION_IU

const int SHAPE::MIN_PRECISION_IU = 4
staticinherited

This is the minimum precision for all the points in a shape.

Definition at line 129 of file shape.h.

Referenced by BOOST_AUTO_TEST_CASE(), DIRECTION_45::BuildInitialTrace(), CompareLength(), CIRCLE::Contains(), EDIT_TOOL::FilletTracks(), and CIRCLE::IntersectLine().


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