Commit 75b5c247 authored by jean-pierre charras's avatar jean-pierre charras

Updated boost::polygon from http://svn.boost.org/svn/boost/trunk/boost/polygon...

Updated boost::polygon from http://svn.boost.org/svn/boost/trunk/boost/polygon (boost 1.44) Seems fix some issues.
parent 8d777fc6
......@@ -29,7 +29,7 @@ private:
public:
iterator_geometry_to_set() : rectangle_(), vertex_(), corner_(4), orient_(), is_hole_() {}
iterator_geometry_to_set(const rectangle_type& rectangle, direction_1d dir,
orientation_2d orient = HORIZONTAL, bool is_hole = false) :
orientation_2d orient = HORIZONTAL, bool is_hole = false, bool = false, direction_1d = CLOCKWISE) :
rectangle_(), vertex_(), corner_(0), orient_(orient), is_hole_(is_hole) {
assign(rectangle_, rectangle);
if(dir == HIGH) corner_ = 4;
......@@ -93,7 +93,7 @@ private:
int polygon_index;
public:
iterator_geometry_to_set() : vertex_(), itrb(), itre(), last_vertex_(), is_hole_(), multiplier_(), first_pt(), second_pt(), pts(), use_wrap(), orient_(), polygon_index(-1) {}
iterator_geometry_to_set(const polygon_type& polygon, direction_1d dir, orientation_2d orient = HORIZONTAL, bool is_hole = false) :
iterator_geometry_to_set(const polygon_type& polygon, direction_1d dir, orientation_2d orient = HORIZONTAL, bool is_hole = false, bool winding_override = false, direction_1d w = CLOCKWISE) :
vertex_(), itrb(), itre(), last_vertex_(),
is_hole_(is_hole), multiplier_(), first_pt(), second_pt(), pts(), use_wrap(),
orient_(orient), polygon_index(0) {
......@@ -103,7 +103,9 @@ public:
if(itrb == itre || dir == HIGH || size(polygon) < 4) {
polygon_index = -1;
} else {
direction_1d wdir = winding(polygon);
direction_1d wdir = w;
if(!winding_override)
wdir = winding(polygon);
multiplier_ = wdir == LOW ? -1 : 1;
if(is_hole_) multiplier_ *= -1;
first_pt = pts[0] = *itrb;
......@@ -182,9 +184,7 @@ public:
vertex_.second.first =pts[1].get(orient_);
if(pts[1] == pts[2]) {
vertex_.second.second = 0;
return;
}
if(pts[0].get(HORIZONTAL) != pts[1].get(HORIZONTAL)) {
} else if(pts[0].get(HORIZONTAL) != pts[1].get(HORIZONTAL)) {
vertex_.second.second = -1;
} else if(pts[0].get(VERTICAL) != pts[1].get(VERTICAL)) {
vertex_.second.second = 1;
......@@ -214,7 +214,7 @@ private:
public:
iterator_geometry_to_set() : itrb(), itre(), itrhib(), itrhie(), itrhb(), itrhe(), orient_(), is_hole_(), started_holes() {}
iterator_geometry_to_set(const polygon_with_holes_type& polygon, direction_1d dir,
orientation_2d orient = HORIZONTAL, bool is_hole = false) :
orientation_2d orient = HORIZONTAL, bool is_hole = false, bool = false, direction_1d = CLOCKWISE) :
itrb(), itre(), itrhib(), itrhie(), itrhb(), itrhe(), orient_(orient), is_hole_(is_hole), started_holes() {
itre = iterator_geometry_to_set<polygon_90_concept, polygon_with_holes_type>(polygon, HIGH, orient, is_hole_);
itrhe = end_holes(polygon);
......
......@@ -251,12 +251,14 @@ namespace boost { namespace polygon{
return;
}
Unit firstY = (*iter).y();
Unit firstX = (*iter).x();
++iter;
if(iter == tailp_->points.end()) {
tailp_->points.push_front(point);
return;
}
if(iter->y() == point.y() && firstY == point.y()) {
if((iter->y() == point.y() && firstY == point.y()) ||
(iter->x() == point.x() && firstX == point.x())){
--iter;
*iter = point;
} else {
......@@ -274,12 +276,14 @@ namespace boost { namespace polygon{
return;
}
Unit firstY = (*iter).y();
Unit firstX = (*iter).x();
++iter;
if(iter == tailp_->points.rend()) {
tailp_->points.push_back(point);
return;
}
if(iter->y() == point.y() && firstY == point.y()) {
if((iter->y() == point.y() && firstY == point.y()) ||
(iter->x() == point.x() && firstX == point.x())){
--iter;
*iter = point;
} else {
......@@ -474,7 +478,7 @@ namespace boost { namespace polygon{
ct counts[4];
};
typedef Vertex45CountT<int> Vertex45Count;
typedef Vertex45CountT<signed char> Vertex45Count;
// inline std::ostream& operator<< (std::ostream& o, const Vertex45Count& c) {
// o << c[0] << ", " << c[1] << ", ";
......@@ -492,7 +496,8 @@ namespace boost { namespace polygon{
inline Vertex45CompactT(const Point& point, int riseIn, int countIn) : pt(point), count() {
count[riseIn+1] = countIn;
}
inline Vertex45CompactT(const Vertex45T& vertex) : pt(vertex.pt), count() {
template <typename ct2>
inline Vertex45CompactT(const typename boolean_op_45<Unit>::template Vertex45T<ct2>& vertex) : pt(vertex.pt), count() {
count[vertex.rise+1] = vertex.count;
}
inline Vertex45CompactT(const Vertex45CompactT& vertex) : pt(vertex.pt), count(vertex.count) {}
......@@ -2244,6 +2249,7 @@ namespace boost { namespace polygon{
struct geometry_concept<PolyLine45PolygonData<T> > { typedef polygon_45_with_holes_concept type; };
template <typename T>
struct geometry_concept<PolyLine45HoleData<T> > { typedef polygon_45_concept type; };
}
}
#endif
......@@ -124,13 +124,13 @@ namespace boost { namespace polygon{
};
template <typename ltype, typename rtype, int op_type>
typename polygon_45_set_view<ltype, rtype, op_type>::iterator_type
typename polygon_45_set_traits<polygon_45_set_view<ltype, rtype, op_type> >::iterator_type
polygon_45_set_traits<polygon_45_set_view<ltype, rtype, op_type> >::
begin(const polygon_45_set_view<ltype, rtype, op_type>& polygon_45_set) {
return polygon_45_set.begin();
}
template <typename ltype, typename rtype, int op_type>
typename polygon_45_set_view<ltype, rtype, op_type>::iterator_type
typename polygon_45_set_traits<polygon_45_set_view<ltype, rtype, op_type> >::iterator_type
polygon_45_set_traits<polygon_45_set_view<ltype, rtype, op_type> >::
end(const polygon_45_set_view<ltype, rtype, op_type>& polygon_45_set) {
return polygon_45_set.end();
......
......@@ -140,13 +140,13 @@ namespace boost { namespace polygon{
};
template <typename ltype, typename rtype, typename op_type>
typename polygon_90_set_view<ltype, rtype, op_type>::iterator_type
typename polygon_90_set_traits<polygon_90_set_view<ltype, rtype, op_type> >::iterator_type
polygon_90_set_traits<polygon_90_set_view<ltype, rtype, op_type> >::
begin(const polygon_90_set_view<ltype, rtype, op_type>& polygon_set) {
return polygon_set.begin();
}
template <typename ltype, typename rtype, typename op_type>
typename polygon_90_set_view<ltype, rtype, op_type>::iterator_type
typename polygon_90_set_traits<polygon_90_set_view<ltype, rtype, op_type> >::iterator_type
polygon_90_set_traits<polygon_90_set_view<ltype, rtype, op_type> >::
end(const polygon_90_set_view<ltype, rtype, op_type>& polygon_set) {
return polygon_set.end();
......
......@@ -42,7 +42,7 @@ namespace boost { namespace polygon{
ivlIds_.second = that.ivlIds_.second;
incremented_ = that.incremented_;
return *this;
};
}
inline bool operator==(const iterator& that) { return itr_ == that.itr_; }
inline bool operator!=(const iterator& that) { return itr_ != that.itr_; }
inline iterator& operator++() {
......
......@@ -1721,7 +1721,7 @@ namespace polygon_formation {
unsigned int get_polygons(output_container& container, iterator_type begin, iterator_type end,
orientation_2d orient, bool fracture_holes, concept_type ) {
typedef typename output_container::value_type polygon_type;
typedef typename iterator_type::value_type::first_type coordinate_type;
typedef typename std::iterator_traits<iterator_type>::value_type::first_type coordinate_type;
polygon_type poly;
unsigned int countPolygons = 0;
typedef typename geometry_concept<polygon_type>::type polygon_concept_type;
......
......@@ -153,13 +153,13 @@ namespace boost { namespace polygon{
};
template <typename ltype, typename rtype, int op_type>
typename polygon_set_view<ltype, rtype, op_type>::iterator_type
typename polygon_set_traits<polygon_set_view<ltype, rtype, op_type> >::iterator_type
polygon_set_traits<polygon_set_view<ltype, rtype, op_type> >::
begin(const polygon_set_view<ltype, rtype, op_type>& polygon_set) {
return polygon_set.begin();
}
template <typename ltype, typename rtype, int op_type>
typename polygon_set_view<ltype, rtype, op_type>::iterator_type
typename polygon_set_traits<polygon_set_view<ltype, rtype, op_type> >::iterator_type
polygon_set_traits<polygon_set_view<ltype, rtype, op_type> >::
end(const polygon_set_view<ltype, rtype, op_type>& polygon_set) {
return polygon_set.end();
......
......@@ -34,17 +34,29 @@ namespace boost { namespace polygon{
#endif
{ (*this) = that; }
template <typename other>
point_data(const other& that) : coords_() { (*this) = that; }
point_data(const other& that)
#ifndef BOOST_POLYGON_MSVC
:coords_()
#endif
{ (*this) = that; }
inline point_data& operator=(const point_data& that) {
coords_[0] = that.coords_[0]; coords_[1] = that.coords_[1]; return *this;
}
template<typename T1, typename T2>
inline point_data(const T1& x, const T2& y):coords_() {
inline point_data(const T1& x, const T2& y)
#ifndef BOOST_POLYGON_MSVC
:coords_()
#endif
{
coords_[HORIZONTAL] = (coordinate_type)x;
coords_[VERTICAL] = (coordinate_type)y;
}
template <typename T2>
inline point_data(const point_data<T2>& rvalue):coords_() {
inline point_data(const point_data<T2>& rvalue)
#ifndef BOOST_POLYGON_MSVC
:coords_()
#endif
{
coords_[HORIZONTAL] = (coordinate_type)(rvalue.x());
coords_[VERTICAL] = (coordinate_type)(rvalue.y());
}
......
......@@ -62,7 +62,7 @@ public:
inline std::size_t size() const { return coords_.size(); }
private:
public:
std::vector<point_data<coordinate_type> > coords_;
};
......
......@@ -1541,11 +1541,11 @@ namespace boost { namespace polygon{
polygon_90_set_data<Unit> l90sd(VERTICAL), r90sd(VERTICAL), output(VERTICAL);
for(typename value_type::const_iterator itr = data_.begin(); itr != data_.end(); ++itr) {
if((*itr).count[3] == 0) continue; //skip all non vertical edges
l90sd.insert(std::make_pair((*itr).pt.x(), std::make_pair((*itr).pt.y(), (*itr).count[3])), false, VERTICAL);
l90sd.insert(std::make_pair((*itr).pt.x(), std::make_pair<Unit, int>((*itr).pt.y(), (*itr).count[3])), false, VERTICAL);
}
for(typename value_type::const_iterator itr = rvalue.data_.begin(); itr != rvalue.data_.end(); ++itr) {
if((*itr).count[3] == 0) continue; //skip all non vertical edges
r90sd.insert(std::make_pair((*itr).pt.x(), std::make_pair((*itr).pt.y(), (*itr).count[3])), false, VERTICAL);
r90sd.insert(std::make_pair((*itr).pt.x(), std::make_pair<Unit, int>((*itr).pt.y(), (*itr).count[3])), false, VERTICAL);
}
l90sd.sort();
r90sd.sort();
......@@ -1673,7 +1673,7 @@ namespace boost { namespace polygon{
polygon_90_set_data<Unit> l90sd(VERTICAL);
for(typename value_type::const_iterator itr = data_.begin(); itr != data_.end(); ++itr) {
if((*itr).count[3] == 0) continue; //skip all non vertical edges
l90sd.insert(std::make_pair((*itr).pt.x(), std::make_pair((*itr).pt.y(), (*itr).count[3])), false, VERTICAL);
l90sd.insert(std::make_pair((*itr).pt.x(), std::make_pair<Unit, int>((*itr).pt.y(), (*itr).count[3])), false, VERTICAL);
}
l90sd.sort();
#ifdef BOOST_POLYGON_MSVC
......
......@@ -137,7 +137,7 @@ namespace boost { namespace polygon{
static inline bool clean(const polygon_45_set_data<T>& polygon_set) { polygon_set.clean(); return true; }
static inline bool sorted(const polygon_45_set_data<T>& polygon_set) { int untested = 0;polygon_set.sort(); return true; }
static inline bool sorted(const polygon_45_set_data<T>& polygon_set) { polygon_set.sort(); return true; }
};
}
......
......@@ -96,10 +96,12 @@ public:
return holes_.size();
}
private:
public:
polygon_45_data<coordinate_type> self_;
std::list<hole_type> holes_;
};
}
}
#endif
......
......@@ -60,7 +60,7 @@ public:
inline std::size_t size() const { return coords_.size(); }
private:
public:
std::vector<point_data<coordinate_type> > coords_;
};
......
This diff is collapsed.
......@@ -121,7 +121,7 @@ namespace boost { namespace polygon{
static inline bool clean(const polygon_set_data<T>& polygon_set) { polygon_set.clean(); return true; }
static inline bool sorted(const polygon_set_data<T>& polygon_set) { int untested = 0;polygon_set.sort(); return true; }
static inline bool sorted(const polygon_set_data<T>& polygon_set) { polygon_set.sort(); return true; }
};
}
......
......@@ -96,7 +96,7 @@ public:
return holes_.size();
}
private:
public:
polygon_data<coordinate_type> self_;
std::list<hole_type> holes_;
};
......
......@@ -131,33 +131,10 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
* so m_ZoneMinThickness is the min thickness of the filled zones areas
* the main polygon is stored in polyset_zone_solid_areas
*/
#if 1
{
/* creates the main polygon (i.e. the filled area using only one outline)
* in GroupA in Bool_Engine to do a BOOL_CORRECTION operation
* to reserve a m_ZoneMinThickness/2 margin around the outlines
*/
Bool_Engine* booleng = new Bool_Engine();
ArmBoolEng( booleng, true );
CopyPolygonsFromFilledPolysListToBoolengine( booleng, GROUP_A );
booleng->SetCorrectionFactor( (double) -margin );
booleng->Do_Operation( BOOL_CORRECTION );
/* Now copy the new outline in m_FilledPolysList */
m_FilledPolysList.clear();
CopyPolygonsFromBoolengineToFilledPolysList( booleng );
delete booleng;
CopyPolygonsFromFilledPolysListTotKPolygonList( this, polyset_zone_solid_areas );
}
#else
/* currently does not work well.
* using kbool gives reliable results
* using boost::polygone gives erroneous results
*/
CopyPolygonsFromFilledPolysListTotKPolygonList( this,
polyset_zone_solid_areas );
polyset_zone_solid_areas -= margin;
#endif
if( polyset_zone_solid_areas.size() == 0 )
return;
......@@ -523,82 +500,6 @@ void AddUnconnectedThermalStubsToKPolygonList( std::vector<CPolyPt>& aCornerBuff
}
/** Function CopyPolygonsFromFilledPolysListToBoolengine
* Copy (Add) polygons found in m_FilledPolysList to kbool BoolEngine
* m_FilledPolysList may have more than one polygon
* @param aBoolengine = kbool engine
* @param aGroup = group in kbool engine (GROUP_A or GROUP_B only)
* @return the corner count
*/
int ZONE_CONTAINER::CopyPolygonsFromFilledPolysListToBoolengine(
Bool_Engine* aBoolengine, GroupType aGroup )
{
unsigned corners_count = m_FilledPolysList.size();
int count = 0;
unsigned ic = 0;
while( ic < corners_count )
{
if( aBoolengine->StartPolygonAdd( aGroup ) )
{
for( ; ic < corners_count; ic++ )
{
CPolyPt* corner = &m_FilledPolysList[ic];
aBoolengine->AddPoint( corner->x, corner->y );
count++;
if( corner->end_contour )
{
ic++;
break;
}
}
aBoolengine->EndPolygonAdd();
}
}
return count;
}
/** Function CopyPolygonsFromBoolengineToFilledPolysList
* Copy (Add) polygons created by kbool (after Do_Operation) to m_FilledPolysList
* @param aBoolengine = kbool engine
* @return the corner count
*/
int ZONE_CONTAINER::CopyPolygonsFromBoolengineToFilledPolysList(
Bool_Engine* aBoolengine )
{
int count = 0;
while( aBoolengine->StartPolygonGet() )
{
CPolyPt corner( 0, 0, false );
while( aBoolengine->PolygonHasMorePoints() )
{
corner.x = (int) aBoolengine->GetPolygonXPoint();
corner.y = (int) aBoolengine->GetPolygonYPoint();
corner.end_contour = false;
// Flag this corner if starting a hole connection segment:
// This is used by draw functions to draw only useful segments (and not extra segments)
corner.utility =
(aBoolengine->GetPolygonPointEdgeType() ==
KB_FALSE_EDGE) ? 1 : 0;
m_FilledPolysList.push_back( corner );
count++;
}
corner.end_contour = true;
m_FilledPolysList.pop_back();
m_FilledPolysList.push_back( corner );
aBoolengine->EndPolygonGet();
}
return count;
}
void AddPolygonCornersToKPolygonList( std::vector <CPolyPt>&
aCornersBuffer,
KPolygonSet& aKPolyList )
......
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