Commit eb22bf42 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: very minor fixes and update: update clipper version. uncrustify...

Pcbnew: very minor fixes and update:  update clipper version. uncrustify polytri/* and fix some warning compil.
parent 6e56aa2f
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#ifndef DRW_BASE_H #ifndef DRW_BASE_H
#define DRW_BASE_H #define DRW_BASE_H
#define DRW_VERSION "0.5.10" #define DRW_VERSION "0.5.11"
#include <string> #include <string>
#include <cmath> #include <cmath>
......
...@@ -27,7 +27,7 @@ class dxfRW ...@@ -27,7 +27,7 @@ class dxfRW
public: public:
dxfRW( const char* name ); dxfRW( const char* name );
~dxfRW(); ~dxfRW();
// / reads the file specified in constructor /// reads the file specified in constructor
/*! /*!
* An interface must be provided. It is used by the class to signal various * An interface must be provided. It is used by the class to signal various
* components being added. * components being added.
...@@ -71,7 +71,7 @@ public: ...@@ -71,7 +71,7 @@ public:
void setEllipseParts( int parts ) { elParts = parts; } /*!< set parts munber when convert ellipse to polyline */ void setEllipseParts( int parts ) { elParts = parts; } /*!< set parts munber when convert ellipse to polyline */
private: private:
// / used by read() to parse the content of the file /// used by read() to parse the content of the file
bool processDxf(); bool processDxf();
bool processHeader(); bool processHeader();
bool processTables(); bool processTables();
......
...@@ -88,8 +88,8 @@ CPolyLine::~CPolyLine() ...@@ -88,8 +88,8 @@ CPolyLine::~CPolyLine()
#include "clipper.hpp" #include "clipper.hpp"
int CPolyLine::NormalizeAreaOutlines( std::vector<CPolyLine*>* aNewPolygonList ) int CPolyLine::NormalizeAreaOutlines( std::vector<CPolyLine*>* aNewPolygonList )
{ {
ClipperLib::Polygon raw_polygon; ClipperLib::Path raw_polygon;
ClipperLib::Polygons normalized_polygons; ClipperLib::Paths normalized_polygons;
unsigned corners_count = m_CornersList.GetCornersCount(); unsigned corners_count = m_CornersList.GetCornersCount();
...@@ -115,7 +115,7 @@ int CPolyLine::NormalizeAreaOutlines( std::vector<CPolyLine*>* aNewPolygonList ) ...@@ -115,7 +115,7 @@ int CPolyLine::NormalizeAreaOutlines( std::vector<CPolyLine*>* aNewPolygonList )
// enter main outline // enter main outline
for( unsigned ii = 0; ii < normalized_polygons.size(); ii++ ) for( unsigned ii = 0; ii < normalized_polygons.size(); ii++ )
{ {
ClipperLib::Polygon& polygon = normalized_polygons[ii]; ClipperLib::Path& polygon = normalized_polygons[ii];
cornerslist.clear(); cornerslist.clear();
for( unsigned jj = 0; jj < polygon.size(); jj++ ) for( unsigned jj = 0; jj < polygon.size(); jj++ )
cornerslist.push_back( KI_POLY_POINT( KiROUND( polygon[jj].X ), cornerslist.push_back( KI_POLY_POINT( KiROUND( polygon[jj].X ),
...@@ -142,7 +142,7 @@ int CPolyLine::NormalizeAreaOutlines( std::vector<CPolyLine*>* aNewPolygonList ) ...@@ -142,7 +142,7 @@ int CPolyLine::NormalizeAreaOutlines( std::vector<CPolyLine*>* aNewPolygonList )
ClipperLib::SimplifyPolygon( raw_polygon, normalized_polygons ); ClipperLib::SimplifyPolygon( raw_polygon, normalized_polygons );
for( unsigned ii = 0; ii < normalized_polygons.size(); ii++ ) for( unsigned ii = 0; ii < normalized_polygons.size(); ii++ )
{ {
ClipperLib::Polygon& polygon = normalized_polygons[ii]; ClipperLib::Path& polygon = normalized_polygons[ii];
cornerslist.clear(); cornerslist.clear();
for( unsigned jj = 0; jj < polygon.size(); jj++ ) for( unsigned jj = 0; jj < polygon.size(); jj++ )
cornerslist.push_back( KI_POLY_POINT( KiROUND( polygon[jj].X ), cornerslist.push_back( KI_POLY_POINT( KiROUND( polygon[jj].X ),
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* /*
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/ * http://code.google.com/p/poly2tri/
* *
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef UTILS_H #ifndef UTILS_H
#define UTILS_H #define UTILS_H
...@@ -39,12 +39,13 @@ ...@@ -39,12 +39,13 @@
#include <math.h> #include <math.h>
namespace p2t { namespace p2t {
const double PI_3div4 = 3 * M_PI / 4;
const double PI_div2 = 1.57079632679489661923;
const double EPSILON = 1e-12;
const double PI_3div4 = 3 * M_PI / 4; enum Orientation {
const double PI_div2 = 1.57079632679489661923; CW, CCW, COLLINEAR
const double EPSILON = 1e-12; };
enum Orientation { CW, CCW, COLLINEAR };
/** /**
* Forumla to calculate signed area<br> * Forumla to calculate signed area<br>
...@@ -56,68 +57,77 @@ enum Orientation { CW, CCW, COLLINEAR }; ...@@ -56,68 +57,77 @@ enum Orientation { CW, CCW, COLLINEAR };
* = (x1-x3)*(y2-y3) - (y1-y3)*(x2-x3) * = (x1-x3)*(y2-y3) - (y1-y3)*(x2-x3)
* </pre> * </pre>
*/ */
Orientation Orient2d(Point& pa, Point& pb, Point& pc) Orientation Orient2d( Point& pa, Point& pb, Point& pc )
{ {
double detleft = (pa.x - pc.x) * (pb.y - pc.y); double detleft = (pa.x - pc.x) * (pb.y - pc.y);
double detright = (pa.y - pc.y) * (pb.x - pc.x); double detright = (pa.y - pc.y) * (pb.x - pc.x);
double val = detleft - detright; double val = detleft - detright;
if (val > -EPSILON && val < EPSILON) {
return COLLINEAR; if( val > -EPSILON && val < EPSILON )
} else if (val > 0) { {
return CCW; return COLLINEAR;
} }
return CW; else if( val > 0 )
{
return CCW;
}
return CW;
} }
/*
bool InScanArea(Point& pa, Point& pb, Point& pc, Point& pd)
{
double pdx = pd.x;
double pdy = pd.y;
double adx = pa.x - pdx;
double ady = pa.y - pdy;
double bdx = pb.x - pdx;
double bdy = pb.y - pdy;
double adxbdy = adx * bdy;
double bdxady = bdx * ady;
double oabd = adxbdy - bdxady;
if (oabd <= EPSILON) { /*
return false; * bool InScanArea(Point& pa, Point& pb, Point& pc, Point& pd)
} * {
* double pdx = pd.x;
double cdx = pc.x - pdx; * double pdy = pd.y;
double cdy = pc.y - pdy; * double adx = pa.x - pdx;
* double ady = pa.y - pdy;
* double bdx = pb.x - pdx;
* double bdy = pb.y - pdy;
*
* double adxbdy = adx * bdy;
* double bdxady = bdx * ady;
* double oabd = adxbdy - bdxady;
*
* if (oabd <= EPSILON) {
* return false;
* }
*
* double cdx = pc.x - pdx;
* double cdy = pc.y - pdy;
*
* double cdxady = cdx * ady;
* double adxcdy = adx * cdy;
* double ocad = cdxady - adxcdy;
*
* if (ocad <= EPSILON) {
* return false;
* }
*
* return true;
* }
*
*/
double cdxady = cdx * ady; bool InScanArea( Point& pa, Point& pb, Point& pc, Point& pd )
double adxcdy = adx * cdy; {
double ocad = cdxady - adxcdy; double oadb = (pa.x - pb.x) * (pd.y - pb.y) - (pd.x - pb.x) * (pa.y - pb.y);
if (ocad <= EPSILON) { if( oadb >= -EPSILON )
return false; {
} return false;
}
return true; double oadc = (pa.x - pc.x) * (pd.y - pc.y) - (pd.x - pc.x) * (pa.y - pc.y);
}
*/ if( oadc <= EPSILON )
{
return false;
}
bool InScanArea(Point& pa, Point& pb, Point& pc, Point& pd) return true;
{
double oadb = (pa.x - pb.x)*(pd.y - pb.y) - (pd.x - pb.x)*(pa.y - pb.y);
if (oadb >= -EPSILON) {
return false;
}
double oadc = (pa.x - pc.x)*(pd.y - pc.y) - (pd.x - pc.x)*(pa.y - pc.y);
if (oadc <= EPSILON) {
return false;
}
return true;
} }
} }
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment