2016-07-19 17:35:25 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
2020-12-11 13:51:42 +00:00
|
|
|
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
2016-07-19 17:35:25 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2021-01-03 22:23:00 +00:00
|
|
|
* @file polygon_2d.cpp
|
2016-07-19 17:35:25 +00:00
|
|
|
*/
|
|
|
|
|
2021-01-03 22:23:00 +00:00
|
|
|
#include "polygon_2d.h"
|
2021-01-05 22:19:00 +00:00
|
|
|
#include "../ray.h"
|
2016-07-19 17:35:25 +00:00
|
|
|
#include <wx/debug.h>
|
|
|
|
|
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
static bool polygon_IsPointInside( const SEGMENTS& aSegments, const SFVEC2F& aPoint )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aSegments.size() >= 3 );
|
|
|
|
|
|
|
|
unsigned int i;
|
2020-12-11 13:51:42 +00:00
|
|
|
unsigned int j = aSegments.size() - 1;
|
|
|
|
bool oddNodes = false;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
for( i = 0; i < aSegments.size(); j = i++ )
|
|
|
|
{
|
|
|
|
const float polyJY = aSegments[j].m_Start.y;
|
|
|
|
const float polyIY = aSegments[i].m_Start.y;
|
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
if( ( ( polyIY <= aPoint.y ) && ( polyJY >= aPoint.y ) )
|
|
|
|
|| ( ( polyJY <= aPoint.y ) && ( polyIY >= aPoint.y ) ) )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
const float polyJX = aSegments[j].m_Start.x;
|
|
|
|
const float polyIX = aSegments[i].m_Start.x;
|
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
if( ( polyIX <= aPoint.x ) || ( polyJX <= aPoint.x ) )
|
|
|
|
oddNodes ^= ( ( polyIX + ( ( aPoint.y - polyIY ) * aSegments[i].m_inv_JY_minus_IY )
|
|
|
|
* aSegments[i].m_JX_minus_IX )
|
|
|
|
< aPoint.x );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return oddNodes;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
POLYGON_2D::POLYGON_2D( const SEGMENTS_WIDTH_NORMALS& aOpenSegmentList,
|
2021-01-07 19:33:43 +00:00
|
|
|
const OUTERS_AND_HOLES& aOuterAndHoles, const BOARD_ITEM& aBoardItem )
|
2021-01-02 21:05:29 +00:00
|
|
|
: OBJECT_2D( OBJECT_2D_TYPE::POLYGON, aBoardItem )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
m_open_segments.resize( aOpenSegmentList.size() );
|
|
|
|
|
|
|
|
// Copy vectors and structures
|
|
|
|
for( unsigned int i = 0; i < aOpenSegmentList.size(); i++ )
|
|
|
|
m_open_segments[i] = aOpenSegmentList[i];
|
|
|
|
|
2021-01-07 19:33:43 +00:00
|
|
|
m_outers_and_holes = aOuterAndHoles;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
// Compute bounding box with the points of the polygon
|
|
|
|
m_bbox.Reset();
|
|
|
|
|
|
|
|
for( unsigned int i = 0; i < m_outers_and_holes.m_Outers.size(); i++ )
|
|
|
|
{
|
|
|
|
for( unsigned int j = 0; j < m_outers_and_holes.m_Outers[i].size(); j++ )
|
2020-12-11 13:51:42 +00:00
|
|
|
m_bbox.Union( ( (SEGMENTS) m_outers_and_holes.m_Outers[i] )[j].m_Start );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_bbox.ScaleNextUp();
|
|
|
|
m_centroid = m_bbox.GetCenter();
|
|
|
|
|
|
|
|
// Some checks
|
2020-12-11 13:51:42 +00:00
|
|
|
wxASSERT( m_open_segments.size() == aOpenSegmentList.size() );
|
2016-07-19 17:35:25 +00:00
|
|
|
wxASSERT( m_open_segments.size() > 0 );
|
|
|
|
|
|
|
|
wxASSERT( m_outers_and_holes.m_Outers.size() > 0 );
|
2021-01-07 19:33:43 +00:00
|
|
|
wxASSERT( m_outers_and_holes.m_Outers.size() == aOuterAndHoles.m_Outers.size() );
|
|
|
|
wxASSERT( m_outers_and_holes.m_Holes.size() == aOuterAndHoles.m_Holes.size() );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
wxASSERT( m_outers_and_holes.m_Outers[0].size() >= 3 );
|
2021-01-07 19:33:43 +00:00
|
|
|
wxASSERT( m_outers_and_holes.m_Outers[0].size() == aOuterAndHoles.m_Outers[0].size() );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
wxASSERT( m_bbox.IsInitialized() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
bool POLYGON_2D::Intersects( const BBOX_2D& aBBox ) const
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
return m_bbox.Intersects( aBBox );
|
|
|
|
|
|
|
|
// !TODO: this is a quick not perfect implementation
|
|
|
|
// in order to make it perfect the box must be checked against all the
|
|
|
|
// polygons in the outers and not inside the holes
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
bool POLYGON_2D::Overlaps( const BBOX_2D& aBBox ) const
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2021-01-07 19:33:43 +00:00
|
|
|
// NOT IMPLEMENTED, why?
|
2016-07-19 17:35:25 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
bool POLYGON_2D::Intersect( const RAYSEG2D& aSegRay, float* aOutT, SFVEC2F* aNormalOut ) const
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2020-12-11 13:51:42 +00:00
|
|
|
int hitIndex = -1;
|
|
|
|
float hitU = 0.0f;
|
|
|
|
float tMin = 0.0f;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
for( unsigned int i = 0; i < m_open_segments.size(); i++ )
|
|
|
|
{
|
2020-12-11 13:51:42 +00:00
|
|
|
const SFVEC2F& s = m_open_segments[i].m_Precalc_slope;
|
|
|
|
const SFVEC2F& q = m_open_segments[i].m_Start;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
float rxs = aSegRay.m_End_minus_start.x * s.y - aSegRay.m_End_minus_start.y * s.x;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
if( fabs( rxs ) > FLT_EPSILON )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
const float inv_rxs = 1.0f / rxs;
|
|
|
|
|
|
|
|
const SFVEC2F pq = q - aSegRay.m_Start;
|
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
const float t = ( pq.x * s.y - pq.y * s.x ) * inv_rxs;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
if( ( t < 0.0f ) || ( t > 1.0f ) )
|
2016-07-19 17:35:25 +00:00
|
|
|
continue;
|
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
const float u =
|
|
|
|
( pq.x * aSegRay.m_End_minus_start.y - pq.y * aSegRay.m_End_minus_start.x )
|
|
|
|
* inv_rxs;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
if( ( u < 0.0f ) || ( u > 1.0f ) )
|
2016-07-19 17:35:25 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if( ( hitIndex == -1 ) || ( t <= tMin ) )
|
|
|
|
{
|
2020-12-11 13:51:42 +00:00
|
|
|
tMin = t;
|
2016-07-19 17:35:25 +00:00
|
|
|
hitIndex = i;
|
2020-12-11 13:51:42 +00:00
|
|
|
hitU = u;
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( hitIndex >= 0 )
|
|
|
|
{
|
2020-12-11 13:51:42 +00:00
|
|
|
wxASSERT( ( tMin >= 0.0f ) && ( tMin <= 1.0f ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-11-04 09:36:41 +00:00
|
|
|
if( aOutT )
|
|
|
|
*aOutT = tMin;
|
|
|
|
|
|
|
|
if( aNormalOut )
|
2020-12-11 13:51:42 +00:00
|
|
|
*aNormalOut = glm::normalize( m_open_segments[hitIndex].m_Normals.m_Start * hitU +
|
|
|
|
m_open_segments[hitIndex].m_Normals.m_End *
|
|
|
|
( 1.0f - hitU ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
INTERSECTION_RESULT POLYGON_2D::IsBBoxInside( const BBOX_2D& aBBox ) const
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
|
2019-12-30 13:01:06 +00:00
|
|
|
return INTERSECTION_RESULT::MISSES;
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
bool POLYGON_2D::IsPointInside( const SFVEC2F& aPoint ) const
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
// NOTE: we could add here a test for the bounding box, but because in the
|
|
|
|
// 3d object it already checked for a 3d bbox.
|
|
|
|
|
|
|
|
// First test if point is inside a hole.
|
|
|
|
// If true it can early exit
|
|
|
|
for( unsigned int i = 0; i < m_outers_and_holes.m_Holes.size(); i++ )
|
|
|
|
if( !m_outers_and_holes.m_Holes[i].empty() )
|
|
|
|
if( polygon_IsPointInside( m_outers_and_holes.m_Holes[i], aPoint ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// At this moment, the point is not inside a hole, so check if it is
|
|
|
|
// inside the polygon
|
|
|
|
for( unsigned int i = 0; i < m_outers_and_holes.m_Outers.size(); i++ )
|
2020-10-29 12:48:45 +00:00
|
|
|
if( !m_outers_and_holes.m_Outers[i].empty() )
|
2016-07-19 17:35:25 +00:00
|
|
|
if( polygon_IsPointInside( m_outers_and_holes.m_Outers[i], aPoint ) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// Miss the polygon
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
DUMMY_BLOCK_2D::DUMMY_BLOCK_2D( const SFVEC2F& aPbMin, const SFVEC2F& aPbMax,
|
|
|
|
const BOARD_ITEM& aBoardItem )
|
|
|
|
: OBJECT_2D( OBJECT_2D_TYPE::DUMMYBLOCK, aBoardItem )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
m_bbox.Set( aPbMin, aPbMax );
|
|
|
|
m_bbox.ScaleNextUp();
|
|
|
|
m_centroid = m_bbox.GetCenter();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
DUMMY_BLOCK_2D::DUMMY_BLOCK_2D( const BBOX_2D& aBBox, const BOARD_ITEM& aBoardItem )
|
|
|
|
: OBJECT_2D( OBJECT_2D_TYPE::DUMMYBLOCK, aBoardItem )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
m_bbox.Set( aBBox );
|
|
|
|
m_bbox.ScaleNextUp();
|
|
|
|
m_centroid = m_bbox.GetCenter();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
bool DUMMY_BLOCK_2D::Intersects( const BBOX_2D& aBBox ) const
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
return m_bbox.Intersects( aBBox );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
bool DUMMY_BLOCK_2D::Overlaps( const BBOX_2D& aBBox ) const
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
// Not implemented
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
bool DUMMY_BLOCK_2D::Intersect( const RAYSEG2D& aSegRay, float* aOutT, SFVEC2F* aNormalOut ) const
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
// The dummy block will be never intersected because it have no edges,
|
|
|
|
// only it have a plan surface of the size of the bounding box
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
INTERSECTION_RESULT DUMMY_BLOCK_2D::IsBBoxInside( const BBOX_2D& aBBox ) const
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
//!TODO:
|
2019-12-30 13:01:06 +00:00
|
|
|
return INTERSECTION_RESULT::MISSES;
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
bool DUMMY_BLOCK_2D::IsPointInside( const SFVEC2F& aPoint ) const
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
// The dummy is filled in all his bounding box, so if it hit the bbox
|
|
|
|
// it will hit this dummy
|
|
|
|
if( m_bbox.Inside( aPoint ) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
typedef std::vector<SFVEC2F> KF_POINTS;
|
|
|
|
|
|
|
|
#define MAX_NR_DIVISIONS 96
|
|
|
|
|
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
static bool intersect( const SEGMENT_WITH_NORMALS& aSeg, const SFVEC2F& aStart,
|
|
|
|
const SFVEC2F& aEnd )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
const SFVEC2F r = aEnd - aStart;
|
|
|
|
const SFVEC2F s = aSeg.m_Precalc_slope;
|
|
|
|
const SFVEC2F q = aSeg.m_Start;
|
|
|
|
|
|
|
|
const float rxs = r.x * s.y - r.y * s.x;
|
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
if( fabs( rxs ) > glm::epsilon<float>() )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
const float inv_rxs = 1.0f / rxs;
|
|
|
|
|
|
|
|
const SFVEC2F pq = q - aStart;
|
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
const float t = ( pq.x * s.y - pq.y * s.x ) * inv_rxs;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
if( ( t < 0.0f ) || ( t > 1.0f ) )
|
2016-07-19 17:35:25 +00:00
|
|
|
return false;
|
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
const float u = ( pq.x * r.y - pq.y * r.x ) * inv_rxs;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
if( ( u < 0.0f ) || ( u > 1.0f ) )
|
2016-07-19 17:35:25 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
static void extractPathsFrom( const SEGMENTS_WIDTH_NORMALS& aSegList, const BBOX_2D& aBBox,
|
2020-12-11 13:51:42 +00:00
|
|
|
SEGMENTS_WIDTH_NORMALS& aOutSegThatIntersect )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2020-12-11 13:51:42 +00:00
|
|
|
wxASSERT( aSegList.size() >= 3 );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
unsigned int i;
|
|
|
|
unsigned int j = aSegList.size() - 1;
|
|
|
|
|
|
|
|
const SFVEC2F p1( aBBox.Min().x, aBBox.Min().y );
|
|
|
|
const SFVEC2F p2( aBBox.Max().x, aBBox.Min().y );
|
|
|
|
const SFVEC2F p3( aBBox.Max().x, aBBox.Max().y );
|
|
|
|
const SFVEC2F p4( aBBox.Min().x, aBBox.Max().y );
|
|
|
|
|
|
|
|
aOutSegThatIntersect.clear();
|
|
|
|
|
|
|
|
for( i = 0; i < aSegList.size(); j = i++ )
|
|
|
|
{
|
2020-12-11 13:51:42 +00:00
|
|
|
if( aBBox.Inside( aSegList[i].m_Start ) || aBBox.Inside( aSegList[j].m_Start ) )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
// if the segment points are inside the bounding box then this
|
|
|
|
// segment is touching the bbox.
|
|
|
|
aOutSegThatIntersect.push_back( aSegList[i] );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Check if a segment intersects the bounding box
|
|
|
|
|
|
|
|
// Make a bounding box based on the segments start and end
|
2021-01-02 21:05:29 +00:00
|
|
|
BBOX_2D segmentBBox( aSegList[i].m_Start, aSegList[j].m_Start );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
if( aBBox.Intersects( segmentBBox ) )
|
|
|
|
{
|
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
const SEGMENT_WITH_NORMALS& seg = aSegList[i];
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
if( intersect( seg, p1, p2 ) || intersect( seg, p2, p3 ) || intersect( seg, p3, p4 )
|
|
|
|
|| intersect( seg, p4, p1 ) )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
aOutSegThatIntersect.push_back( seg );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
static void polygon_Convert( const SHAPE_LINE_CHAIN& aPath, SEGMENTS& aOutSegment,
|
2021-01-05 22:19:00 +00:00
|
|
|
float aBiuTo3dUnitsScale )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
aOutSegment.resize( aPath.PointCount() );
|
|
|
|
|
|
|
|
for( int j = 0; j < aPath.PointCount(); j++ )
|
|
|
|
{
|
2020-12-11 13:51:42 +00:00
|
|
|
const VECTOR2I& a = aPath.CPoint( j );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
aOutSegment[j].m_Start = SFVEC2F( (float) a.x * aBiuTo3dUnitsScale,
|
|
|
|
(float) -a.y * aBiuTo3dUnitsScale );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int i;
|
2020-12-11 13:51:42 +00:00
|
|
|
unsigned int j = aOutSegment.size() - 1;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
for( i = 0; i < aOutSegment.size(); j = i++ )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
// Calculate constants for each segment
|
2020-12-11 13:51:42 +00:00
|
|
|
aOutSegment[i].m_inv_JY_minus_IY = 1.0f /
|
|
|
|
( aOutSegment[j].m_Start.y - aOutSegment[i].m_Start.y );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
aOutSegment[i].m_JX_minus_IX = ( aOutSegment[j].m_Start.x - aOutSegment[i].m_Start.x );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-10 01:24:15 +00:00
|
|
|
void ConvertPolygonToBlocks( const SHAPE_POLY_SET& aMainPath, CONTAINER_2D_BASE& aDstContainer,
|
|
|
|
float aBiuTo3dUnitsScale, float aDivFactor,
|
|
|
|
const BOARD_ITEM& aBoardItem, int aPolyIndex )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
// Get the path
|
2020-01-04 20:50:37 +00:00
|
|
|
wxASSERT( aPolyIndex < aMainPath.OutlineCount() );
|
|
|
|
|
|
|
|
const SHAPE_LINE_CHAIN& path = aMainPath.COutline( aPolyIndex );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-01-04 20:50:37 +00:00
|
|
|
BOX2I pathBounds = path.BBox();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
// Convert the points to segments class
|
2021-01-02 21:05:29 +00:00
|
|
|
BBOX_2D bbox;
|
2016-07-19 17:35:25 +00:00
|
|
|
bbox.Reset();
|
|
|
|
|
|
|
|
// Contains the main list of segments and each segment normal interpolated
|
|
|
|
SEGMENTS_WIDTH_NORMALS segments_and_normals;
|
|
|
|
|
|
|
|
// Contains a closed polygon used to calc if points are inside
|
|
|
|
SEGMENTS segments;
|
|
|
|
|
2020-01-02 20:02:09 +00:00
|
|
|
segments_and_normals.reserve( path.PointCount() );
|
|
|
|
segments.reserve( path.PointCount() );
|
|
|
|
|
|
|
|
SFVEC2F prevPoint;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
for( int i = 0; i < path.PointCount(); i++ )
|
|
|
|
{
|
|
|
|
const VECTOR2I& a = path.CPoint( i );
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
const SFVEC2F point( (float) ( a.x ) * aBiuTo3dUnitsScale,
|
|
|
|
(float) ( -a.y ) * aBiuTo3dUnitsScale );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-01-02 20:02:09 +00:00
|
|
|
// Only add points that are not coincident
|
2020-12-11 13:51:42 +00:00
|
|
|
if( ( i == 0 ) || ( fabs( prevPoint.x - point.x ) > FLT_EPSILON )
|
|
|
|
|| ( fabs( prevPoint.y - point.y ) > FLT_EPSILON ) )
|
2020-01-02 20:02:09 +00:00
|
|
|
{
|
|
|
|
prevPoint = point;
|
|
|
|
|
|
|
|
bbox.Union( point );
|
|
|
|
|
|
|
|
SEGMENT_WITH_NORMALS sn;
|
|
|
|
sn.m_Start = point;
|
|
|
|
segments_and_normals.push_back( sn );
|
|
|
|
|
|
|
|
POLYSEGMENT ps;
|
|
|
|
ps.m_Start = point;
|
|
|
|
segments.push_back( ps );
|
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bbox.ScaleNextUp();
|
|
|
|
|
|
|
|
// Calc the slopes, normals and some statistics about this polygon
|
|
|
|
unsigned int i;
|
|
|
|
unsigned int j = segments_and_normals.size() - 1;
|
|
|
|
|
|
|
|
// Temporary normal to the segment, it will later be used for interpolation
|
2020-12-11 13:51:42 +00:00
|
|
|
std::vector<SFVEC2F> tmpSegmentNormals;
|
2016-07-19 17:35:25 +00:00
|
|
|
tmpSegmentNormals.resize( segments_and_normals.size() );
|
|
|
|
|
|
|
|
float medOfTheSquaresSegmentLength = 0.0f;
|
2020-12-11 13:51:42 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
#ifdef PRINT_STATISTICS_3D_VIEWER
|
|
|
|
float minLength = FLT_MAX;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for( i = 0; i < segments_and_normals.size(); j = i++ )
|
|
|
|
{
|
2020-12-11 13:51:42 +00:00
|
|
|
const SFVEC2F slope = segments_and_normals[j].m_Start - segments_and_normals[i].m_Start;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
segments_and_normals[i].m_Precalc_slope = slope;
|
|
|
|
|
|
|
|
// Calculate constants for each segment
|
2020-12-11 13:51:42 +00:00
|
|
|
segments[i].m_inv_JY_minus_IY =
|
|
|
|
1.0f / ( segments_and_normals[j].m_Start.y - segments_and_normals[i].m_Start.y );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
segments[i].m_JX_minus_IX =
|
|
|
|
( segments_and_normals[j].m_Start.x - segments_and_normals[i].m_Start.x );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
// The normal orientation expect a fixed polygon orientation (!TODO: which one?)
|
|
|
|
//tmpSegmentNormals[i] = glm::normalize( SFVEC2F( -slope.y, +slope.x ) );
|
|
|
|
tmpSegmentNormals[i] = glm::normalize( SFVEC2F( slope.y, -slope.x ) );
|
|
|
|
|
|
|
|
const float length = slope.x * slope.x + slope.y * slope.y;
|
|
|
|
|
|
|
|
#ifdef PRINT_STATISTICS_3D_VIEWER
|
|
|
|
if( length < minLength )
|
|
|
|
minLength = length;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
medOfTheSquaresSegmentLength += length;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef PRINT_STATISTICS_3D_VIEWER
|
|
|
|
float minSegmentLength = sqrt( minLength );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// This calc an approximation of medium lengths, that will be used to calc
|
|
|
|
// the size of the division.
|
|
|
|
medOfTheSquaresSegmentLength /= segments_and_normals.size();
|
|
|
|
medOfTheSquaresSegmentLength = sqrt( medOfTheSquaresSegmentLength );
|
|
|
|
|
|
|
|
// Compute the normal interpolation
|
|
|
|
// If calculate the dot between the segments, if they are above/below some
|
2020-12-11 13:51:42 +00:00
|
|
|
// threshold it will not interpolated it (ex: if you are in a edge corner
|
2016-07-19 17:35:25 +00:00
|
|
|
// or in a smooth transaction)
|
|
|
|
j = segments_and_normals.size() - 1;
|
2020-12-11 13:51:42 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
for( i = 0; i < segments_and_normals.size(); j = i++ )
|
|
|
|
{
|
|
|
|
const SFVEC2F normalBeforeSeg = tmpSegmentNormals[j];
|
|
|
|
const SFVEC2F normalSeg = tmpSegmentNormals[i];
|
2020-12-11 13:51:42 +00:00
|
|
|
const SFVEC2F normalAfterSeg = tmpSegmentNormals[( i + 1 ) % segments_and_normals.size()];
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
const float dotBefore = glm::dot( normalBeforeSeg, normalSeg );
|
2020-12-11 13:51:42 +00:00
|
|
|
const float dotAfter = glm::dot( normalAfterSeg, normalSeg );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
if( dotBefore < 0.7f )
|
|
|
|
segments_and_normals[i].m_Normals.m_Start = normalSeg;
|
|
|
|
else
|
|
|
|
segments_and_normals[i].m_Normals.m_Start =
|
2020-12-11 13:51:42 +00:00
|
|
|
glm::normalize( ( normalBeforeSeg * dotBefore ) + normalSeg );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
if( dotAfter < 0.7f )
|
|
|
|
segments_and_normals[i].m_Normals.m_End = normalSeg;
|
|
|
|
else
|
|
|
|
segments_and_normals[i].m_Normals.m_End =
|
2020-12-11 13:51:42 +00:00
|
|
|
glm::normalize( ( normalAfterSeg * dotAfter ) + normalSeg );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SFVEC2UI grid_divisions;
|
|
|
|
|
2020-11-01 08:10:08 +00:00
|
|
|
if( aDivFactor < 0.0f )
|
2020-10-31 23:31:55 +00:00
|
|
|
{
|
|
|
|
grid_divisions = SFVEC2UI( 1 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( aDivFactor <= FLT_EPSILON )
|
|
|
|
aDivFactor = medOfTheSquaresSegmentLength;
|
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
grid_divisions.x = (unsigned int) ( ( bbox.GetExtent().x / aDivFactor ) );
|
|
|
|
grid_divisions.y = (unsigned int) ( ( bbox.GetExtent().y / aDivFactor ) );
|
2020-10-31 23:31:55 +00:00
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
grid_divisions = glm::clamp(
|
|
|
|
grid_divisions, SFVEC2UI( 1, 1 ), SFVEC2UI( MAX_NR_DIVISIONS, MAX_NR_DIVISIONS ) );
|
2020-10-31 23:31:55 +00:00
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
// Calculate the steps advance of the grid
|
|
|
|
SFVEC2F blockAdvance;
|
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
blockAdvance.x = bbox.GetExtent().x / (float) grid_divisions.x;
|
|
|
|
blockAdvance.y = bbox.GetExtent().y / (float) grid_divisions.y;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
wxASSERT( blockAdvance.x > 0.0f );
|
|
|
|
wxASSERT( blockAdvance.y > 0.0f );
|
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
const int leftToRight_inc = ( pathBounds.GetRight() - pathBounds.GetLeft() ) / grid_divisions.x;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
const int topToBottom_inc = ( pathBounds.GetBottom() - pathBounds.GetTop() ) / grid_divisions.y;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
// Statistics
|
2020-12-11 13:51:42 +00:00
|
|
|
unsigned int stats_n_empty_blocks = 0;
|
|
|
|
unsigned int stats_n_dummy_blocks = 0;
|
|
|
|
unsigned int stats_n_poly_blocks = 0;
|
2016-07-19 17:35:25 +00:00
|
|
|
unsigned int stats_sum_size_of_polygons = 0;
|
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
// Step by each block of a grid trying to extract segments and create polygon blocks
|
|
|
|
int topToBottom = pathBounds.GetTop();
|
|
|
|
float blockY = bbox.Max().y;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
for( unsigned int iy = 0; iy < grid_divisions.y; iy++ )
|
|
|
|
{
|
2020-12-11 13:51:42 +00:00
|
|
|
int leftToRight = pathBounds.GetLeft();
|
|
|
|
float blockX = bbox.Min().x;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
for( unsigned int ix = 0; ix < grid_divisions.x; ix++ )
|
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
BBOX_2D blockBox( SFVEC2F( blockX, blockY - blockAdvance.y ),
|
|
|
|
SFVEC2F( blockX + blockAdvance.x, blockY ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
// Make the box large to it will catch (intersect) the edges
|
|
|
|
blockBox.ScaleNextUp();
|
|
|
|
blockBox.ScaleNextUp();
|
|
|
|
blockBox.ScaleNextUp();
|
|
|
|
|
|
|
|
SEGMENTS_WIDTH_NORMALS extractedSegments;
|
|
|
|
|
|
|
|
extractPathsFrom( segments_and_normals, blockBox, extractedSegments );
|
|
|
|
|
|
|
|
if( extractedSegments.empty() )
|
|
|
|
{
|
|
|
|
|
|
|
|
SFVEC2F p1( blockBox.Min().x, blockBox.Min().y );
|
|
|
|
SFVEC2F p2( blockBox.Max().x, blockBox.Min().y );
|
|
|
|
SFVEC2F p3( blockBox.Max().x, blockBox.Max().y );
|
|
|
|
SFVEC2F p4( blockBox.Min().x, blockBox.Max().y );
|
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
if( polygon_IsPointInside( segments, p1 ) || polygon_IsPointInside( segments, p2 )
|
|
|
|
|| polygon_IsPointInside( segments, p3 )
|
|
|
|
|| polygon_IsPointInside( segments, p4 ) )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
// In this case, the segments are not intersecting the
|
|
|
|
// polygon, so it means that if any point is inside it,
|
|
|
|
// then all other are inside the polygon.
|
|
|
|
// This is a full bbox inside, so add a dummy box
|
2021-01-02 21:05:29 +00:00
|
|
|
aDstContainer.Add( new DUMMY_BLOCK_2D( blockBox, aBoardItem ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
stats_n_dummy_blocks++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-12-11 13:51:42 +00:00
|
|
|
// Points are outside, so this block completely missed the polygon
|
2016-07-19 17:35:25 +00:00
|
|
|
// In this case, no objects need to be added
|
|
|
|
stats_n_empty_blocks++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// At this point, the borders of polygon were intersected by the
|
|
|
|
// bounding box, so we must calculate a new polygon that will
|
|
|
|
// close that small block.
|
|
|
|
// This block will be used to calculate if points are inside
|
|
|
|
// the (sub block) polygon.
|
|
|
|
|
|
|
|
SHAPE_POLY_SET subBlockPoly;
|
|
|
|
|
2019-03-24 13:54:56 +00:00
|
|
|
SHAPE_LINE_CHAIN sb = SHAPE_LINE_CHAIN( { VECTOR2I( leftToRight, topToBottom ),
|
|
|
|
VECTOR2I( leftToRight + leftToRight_inc, topToBottom ),
|
|
|
|
VECTOR2I( leftToRight + leftToRight_inc, topToBottom + topToBottom_inc ),
|
|
|
|
VECTOR2I( leftToRight, topToBottom + topToBottom_inc ) } );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
//sb.Append( leftToRight, topToBottom );
|
|
|
|
sb.SetClosed( true );
|
|
|
|
|
|
|
|
subBlockPoly.AddOutline( sb );
|
|
|
|
|
|
|
|
// We need here a strictly simple polygon with outlines and holes
|
|
|
|
SHAPE_POLY_SET solution;
|
2021-01-02 21:05:29 +00:00
|
|
|
solution.BooleanIntersection( aMainPath, subBlockPoly,
|
|
|
|
SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
OUTERS_AND_HOLES outersAndHoles;
|
|
|
|
|
|
|
|
outersAndHoles.m_Holes.clear();
|
|
|
|
outersAndHoles.m_Outers.clear();
|
|
|
|
|
|
|
|
for( int idx = 0; idx < solution.OutlineCount(); idx++ )
|
|
|
|
{
|
2020-12-11 13:51:42 +00:00
|
|
|
const SHAPE_LINE_CHAIN& outline = solution.Outline( idx );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
SEGMENTS solutionSegment;
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
polygon_Convert( outline, solutionSegment, aBiuTo3dUnitsScale );
|
2016-07-19 17:35:25 +00:00
|
|
|
outersAndHoles.m_Outers.push_back( solutionSegment );
|
|
|
|
|
|
|
|
stats_sum_size_of_polygons += solutionSegment.size();
|
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
for( int holeIdx = 0; holeIdx < solution.HoleCount( idx ); holeIdx++ )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2020-12-11 13:51:42 +00:00
|
|
|
const SHAPE_LINE_CHAIN& hole = solution.Hole( idx, holeIdx );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
polygon_Convert( hole, solutionSegment, aBiuTo3dUnitsScale );
|
2016-07-19 17:35:25 +00:00
|
|
|
outersAndHoles.m_Holes.push_back( solutionSegment );
|
|
|
|
stats_sum_size_of_polygons += solutionSegment.size();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !outersAndHoles.m_Outers.empty() )
|
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
aDstContainer.Add( new POLYGON_2D( extractedSegments, outersAndHoles,
|
|
|
|
aBoardItem ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
stats_n_poly_blocks++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
blockX += blockAdvance.x;
|
|
|
|
leftToRight += leftToRight_inc;
|
|
|
|
}
|
|
|
|
|
|
|
|
blockY -= blockAdvance.y;
|
|
|
|
topToBottom += topToBottom_inc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2020-12-11 13:51:42 +00:00
|
|
|
static void polygon_Convert( const ClipperLib::Path& aPath, SEGMENTS& aOutSegment,
|
2021-01-05 22:19:00 +00:00
|
|
|
float aBiuTo3dUnitsScale )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
aOutSegment.resize( aPath.size() );
|
|
|
|
|
|
|
|
for( unsigned i = 0; i < aPath.size(); i++ )
|
|
|
|
{
|
2020-12-11 13:51:42 +00:00
|
|
|
aOutSegment[i].m_Start = SFVEC2F(
|
2021-01-05 22:19:00 +00:00
|
|
|
(float) aPath[i].X * aBiuTo3dUnitsScale, (float) -aPath[i].Y * aBiuTo3dUnitsScale );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int i;
|
2020-12-11 13:51:42 +00:00
|
|
|
unsigned int j = aOutSegment.size() - 1;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
for( i = 0; i < aOutSegment.size(); j = i++ )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
// Calculate constants for each segment
|
2020-12-11 13:51:42 +00:00
|
|
|
aOutSegment[i].m_inv_JY_minus_IY =
|
|
|
|
1.0f / ( aOutSegment[j].m_Start.y - aOutSegment[i].m_Start.y );
|
|
|
|
aOutSegment[i].m_JX_minus_IX = ( aOutSegment[j].m_Start.x - aOutSegment[i].m_Start.x );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
void Polygon2d_TestModule()
|
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
// "This structure contains a sequence of IntPoint vertices defining a single contour"
|
2016-07-19 17:35:25 +00:00
|
|
|
ClipperLib::Path aPath;
|
|
|
|
|
|
|
|
SEGMENTS aSegments;
|
|
|
|
|
|
|
|
aPath.resize( 4 );
|
|
|
|
|
|
|
|
aPath[0] = ClipperLib::IntPoint( -2, -2 );
|
2020-12-11 13:51:42 +00:00
|
|
|
aPath[1] = ClipperLib::IntPoint( 2, -2 );
|
|
|
|
aPath[2] = ClipperLib::IntPoint( 2, 2 );
|
|
|
|
aPath[3] = ClipperLib::IntPoint( -2, 2 );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2019-08-20 17:02:28 +00:00
|
|
|
// It must be an outer polygon
|
2016-07-19 17:35:25 +00:00
|
|
|
wxASSERT( ClipperLib::Orientation( aPath ) );
|
|
|
|
|
|
|
|
polygon_Convert( aPath, aSegments, 1.0f );
|
|
|
|
|
|
|
|
wxASSERT( aPath.size() == aSegments.size() );
|
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
wxASSERT( aSegments[0].m_Start == SFVEC2F( -2.0f, 2.0f ) );
|
|
|
|
wxASSERT( aSegments[1].m_Start == SFVEC2F( 2.0f, 2.0f ) );
|
|
|
|
wxASSERT( aSegments[2].m_Start == SFVEC2F( 2.0f, -2.0f ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
wxASSERT( aSegments[3].m_Start == SFVEC2F( -2.0f, -2.0f ) );
|
|
|
|
|
2020-12-11 13:51:42 +00:00
|
|
|
wxASSERT( polygon_IsPointInside( aSegments, SFVEC2F( 0.0f, 0.0f ) ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
wxASSERT( polygon_IsPointInside( aSegments, SFVEC2F( -1.9f, -1.9f ) ) );
|
2020-12-11 13:51:42 +00:00
|
|
|
wxASSERT( polygon_IsPointInside( aSegments, SFVEC2F( -1.9f, 1.9f ) ) );
|
|
|
|
wxASSERT( polygon_IsPointInside( aSegments, SFVEC2F( 1.9f, 1.9f ) ) );
|
|
|
|
wxASSERT( polygon_IsPointInside( aSegments, SFVEC2F( 1.9f, -1.9f ) ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
wxASSERT( polygon_IsPointInside( aSegments, SFVEC2F( -2.1f, -2.0f ) ) == false );
|
2020-12-11 13:51:42 +00:00
|
|
|
wxASSERT( polygon_IsPointInside( aSegments, SFVEC2F( -2.1f, 2.0f ) ) == false );
|
|
|
|
wxASSERT( polygon_IsPointInside( aSegments, SFVEC2F( 2.1f, 2.0f ) ) == false );
|
|
|
|
wxASSERT( polygon_IsPointInside( aSegments, SFVEC2F( 2.1f, -2.0f ) ) == false );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
#endif
|