36std::shared_ptr<PNS_LOG_VIEWER_OVERLAY>
overlay;
43 std::vector<VECTOR2I> ips;
48 minDistSeg.
A = minDistSeg.
B = ips[0];
53 std::vector<VECTOR2I> ptsA;
54 std::vector<VECTOR2I> ptsB;
56 bool cocentered = ( mediatrix.
A == mediatrix.
B );
66 ptsA.push_back( a1.
GetP0() );
67 ptsA.push_back( a1.
GetP1() );
68 ptsB.push_back( a2.
GetP0() );
69 ptsB.push_back( a2.
GetP1() );
79 double minDist = std::numeric_limits<double>::max();
80 bool minDistFound =
false;
90 if( dist < clearance )
92 if( !minDistFound || dist < minDist )
95 minDistSeg =
SEG( ptA, ptB );
110 Pgm().App().SetTopWindow( frame );
115 double cx, cy, sx, sy, ca, w;
118 const ARC_DATA test_data [] =
120 {73.843527, 74.355869, 71.713528, 72.965869, -76.36664803, 0.2},
121 {71.236473, 74.704131, 73.366472, 76.094131, -76.36664803, 0.2},
122 {82.542335, 74.825975, 80.413528, 73.435869, -76.4, 0.2},
123 {76.491192, 73.839894, 78.619999, 75.23, -76.4, 0.2},
124 {89.318807, 74.810106, 87.19, 73.42, -76.4, 0.2},
125 {87.045667, 74.632941, 88.826472, 75.794131, -267.9, 0.2},
126 {94.665667, 73.772941, 96.446472, 74.934131, -267.9, 0.2},
127 {94.750009, 73.74012, 93.6551, 73.025482, -255.5, 0.2},
128 {72.915251, 80.493054, 73.570159, 81.257692, -260.5, 0.2},
129 {73.063537, 82.295989, 71.968628, 81.581351, -255.5, 0.2},
130 {79.279991, 80.67988, 80.3749, 81.394518, -255.5, 0.2},
131 {79.279991, 80.67988, 80.3749, 81.694518, -255.5, 0.2 },
132 {88.495265, 81.766089, 90.090174, 82.867869, -255.5, 0.2},
133 {86.995265, 81.387966, 89.090174, 82.876887, -255.5, 0.2},
134 {96.149734, 81.792126, 94.99, 83.37, -347.2, 0.2},
135 {94.857156, 81.240589, 95.91, 83.9, -288.5, 0.2},
136 {72.915251, 86.493054, 73.970159, 87.257692, -260.5, 0.2},
137 {73.063537, 88.295989, 71.968628, 87.581351, -255.5, 0.2},
138 {78.915251, 86.393054, 79.970159, 87.157692, 99.5, 0.2},
139 {79.063537, 88.295989, 77.968628, 87.581351, -255.5, 0.2},
140 {85.915251, 86.993054, 86.970159, 87.757692, 99.5, 0.2},
141 {86.063537, 88.295989, 84.968628, 87.581351, -255.5, 0.2},
142 {94.6551, 88.295989, 95.6551, 88.295989, 90.0, 0.2 },
143 {94.6551, 88.295989, 95.8551, 88.295989, 90.0, 0.2 },
144 {73.77532, 93.413654, 75.70532, 93.883054, 60.0, 0.1 },
145 {73.86532, 93.393054, 75.86532, 93.393054, 90.0, 0.3 },
146 {79.87532, 93.413654, 81.64532, 94.113054, 60.0, 0.1 },
147 {79.87532, 93.413654, 81.86532, 93.393054, 90.0, 0.3 }
155 overlay->SetLineWidth( 10000 );
157 std::vector<SHAPE_ARC> arcs;
158 int n_arcs =
sizeof( test_data ) /
sizeof( ARC_DATA );
162 for(
int i = 0; i < n_arcs; i++ )
164 const ARC_DATA& d = test_data[i];
170 arcs.push_back( arc );
178 printf(
"Read %zu arcs\n", arcs.size() );
183 for(
int i = 0; i < arcs.size(); i+= 2)
186 std::vector<VECTOR2I> ips;
187 bool collides =
collideArc2Arc( arcs[i], arcs[i+1], 0, closestDist );
188 int ni = arcs[i].Intersect( arcs[i+1], &ips );
190 overlay->SetLineWidth( 10000.0 );
193 for(
int j = 0; j < ni; j++ )
194 overlay->AnnotatedPoint( ips[j], arcs[i].GetWidth() );
199 overlay->Line( closestDist.
A, closestDist.
B );
200 overlay->SetLineWidth( 10000 );
201 overlay->SetGlyphSize( { 100000, 100000 } );
202 overlay->BitmapText( wxString::Format(
"dist=%d", closestDist.
Length() ),
203 closestDist.
A +
VECTOR2I( 0, -arcs[i].GetWidth() ),
207 overlay->SetLineWidth( 10000 );
209 overlay->AnnotatedPoint( arcs[i].GetP0(), arcs[i].GetWidth() / 2 );
210 overlay->AnnotatedPoint( arcs[i + 1].GetP0(), arcs[i + 1].GetWidth() / 2 );
211 overlay->AnnotatedPoint( arcs[i].GetArcMid(), arcs[i].GetWidth() / 2 );
212 overlay->AnnotatedPoint( arcs[i + 1].GetArcMid(), arcs[i + 1].GetWidth() / 2 );
213 overlay->AnnotatedPoint( arcs[i].GetP1(), arcs[i].GetWidth() / 2 );
214 overlay->AnnotatedPoint( arcs[i + 1].GetP1(), arcs[i + 1].GetWidth() / 2 );
234 VECTOR2I( 197822958, 136722959 ), 250000 );
245 Pgm().App().SetTopWindow( frame );
259 overlay->SetLineWidth( 80000.0 );
262 for(
int i = 0; i < lc.PointCount(); ++i )
264 int mult = ( i % 2 ) ? 1 : -1;
266 overlay->SetGlyphSize( { 800000, 800000 } );
267 overlay->BitmapText( wxString::Format(
"x=%d, y=%d",
269 lc.GetPoint( i ).y ),
277 vp.
Merge( lc.BBox() );
289 "Geometry/drawing playground",
constexpr EDA_IU_SCALE pcbIUScale
const Vec & GetOrigin() const
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
const Vec & GetSize() const
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
int Length() const
Return the length (this).
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
const VECTOR2I & GetP1() const
int IntersectLine(const SEG &aSeg, std::vector< VECTOR2I > *aIpsBuffer) const
Find intersection points between this arc and aSeg, treating aSeg as an infinite line.
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 segment aSeg than aClearance,...
int Intersect(const SHAPE_ARC &aArc, std::vector< VECTOR2I > *aIpsBuffer) const
Find intersection points between this arc and aArc.
VECTOR2I GetCenter() const
const VECTOR2I & GetP0() const
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
static bool Register(const KI_TEST::UTILITY_PROGRAM &aProgInfo)
Register a utility program factory function against an ID string.
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
int playground_main_func(int argc, char *argv[])
int drawShapes(int argc, char *argv[])
bool collideArc2Arc(const SHAPE_ARC &a1, const SHAPE_ARC &a2, int clearance, SEG &minDistSeg)
std::shared_ptr< PNS_LOG_VIEWER_OVERLAY > overlay
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
constexpr int mmToIU(double mm) const
double EuclideanNorm(const VECTOR2I &vector)
VECTOR2< double > VECTOR2D