Commit 0c24113d authored by jean-pierre charras's avatar jean-pierre charras

Libedit: minor enhancements. Update Boost::Polygon

parent b6eb58c5
...@@ -4,6 +4,26 @@ KiCad ChangeLog 2010 ...@@ -4,6 +4,26 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2010-oct-22 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================
Component library editor bug fixes and other minor fixes.
* Fix bug that prevented component from being replaced in library when
the component root name was changed.
* Fix drawing bug when changing text or field item string while move in
progress.
* Fix drawing bug when rotating text item while move in progress.
* Prevent undo or redo when editing a component draw item.
* Fix assert bug when replacing component in library when the component
root name was changed.
* Fix bug in field editor caused by new root alias implementation that
prevented any field from being changed.
* Fix minor spacing issues with EESchema find dialog.
* Deprecate remaining internal linked list code from component library
objects.
* Rename pin object files to match new library object file naming
scheme.
* Move LIB_TEXT object definition into it's own header file.
2010-Oct-20 UPDATE Dick Hollenbeck <dick@softplc.com> 2010-Oct-20 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================ ================================================================================
++richio: ++richio:
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -111,15 +111,12 @@ static Ki_HotkeyInfo HkMirrorXComponent( wxT( "Mirror X Component" ), ...@@ -111,15 +111,12 @@ static Ki_HotkeyInfo HkMirrorXComponent( wxT( "Mirror X Component" ),
HK_MIRROR_X_COMPONENT, 'X' ); HK_MIRROR_X_COMPONENT, 'X' );
static Ki_HotkeyInfo HkOrientNormalComponent( wxT( "Orient Normal Component" ), static Ki_HotkeyInfo HkOrientNormalComponent( wxT( "Orient Normal Component" ),
HK_ORIENT_NORMAL_COMPONENT, 'N' ); HK_ORIENT_NORMAL_COMPONENT, 'N' );
static Ki_HotkeyInfo HkRotate( wxT( "Rotate Schematic Item" ), static Ki_HotkeyInfo HkRotate( wxT( "Rotate Item" ), HK_ROTATE, 'R' );
HK_ROTATE, 'R' ); static Ki_HotkeyInfo HkEdit( wxT( "Edit Schematic Item" ), HK_EDIT, 'E' );
static Ki_HotkeyInfo HkEdit( wxT( "Edit Schematic Item" ),
HK_EDIT, 'E' );
static Ki_HotkeyInfo HkEditComponentValue( wxT( "Edit Component Value" ), static Ki_HotkeyInfo HkEditComponentValue( wxT( "Edit Component Value" ),
HK_EDIT_COMPONENT_VALUE, 'V' ); HK_EDIT_COMPONENT_VALUE, 'V' );
static Ki_HotkeyInfo HkEditComponentFootprint( wxT( "Edit Component Footprint" ), static Ki_HotkeyInfo HkEditComponentFootprint( wxT( "Edit Component Footprint" ),
HK_EDIT_COMPONENT_FOOTPRINT, HK_EDIT_COMPONENT_FOOTPRINT, 'F' );
'F' );
static Ki_HotkeyInfo HkMove( wxT( "Move Schematic Item" ), static Ki_HotkeyInfo HkMove( wxT( "Move Schematic Item" ),
HK_MOVE_COMPONENT_OR_ITEM, 'M', HK_MOVE_COMPONENT_OR_ITEM, 'M',
ID_POPUP_SCH_MOVE_CMP_REQUEST ); ID_POPUP_SCH_MOVE_CMP_REQUEST );
...@@ -143,7 +140,7 @@ static Ki_HotkeyInfo HkFindNextDrcMarker( wxT( "Find next DRC marker" ), HK_FIND ...@@ -143,7 +140,7 @@ static Ki_HotkeyInfo HkFindNextDrcMarker( wxT( "Find next DRC marker" ), HK_FIND
// Special keys for library editor: // Special keys for library editor:
static Ki_HotkeyInfo HkCreatePin( wxT( "Create Pin" ), HK_LIBEDIT_CREATE_PIN, 'P' ); static Ki_HotkeyInfo HkCreatePin( wxT( "Create Pin" ), HK_LIBEDIT_CREATE_PIN, 'P' );
static Ki_HotkeyInfo HkInsertPin( wxT( "Repeat Pin" ), HK_REPEAT_LAST, WXK_INSERT ); static Ki_HotkeyInfo HkInsertPin( wxT( "Repeat Pin" ), HK_REPEAT_LAST, WXK_INSERT );
static Ki_HotkeyInfo HkMovePin( wxT( "Move Pin" ), HK_LIBEDIT_MOVE_GRAPHIC_ITEM, 'M' ); static Ki_HotkeyInfo HkMoveLibItem( wxT( "Move Lib Item" ), HK_LIBEDIT_MOVE_GRAPHIC_ITEM, 'M' );
// List of common hotkey descriptors // List of common hotkey descriptors
...@@ -193,7 +190,7 @@ Ki_HotkeyInfo* s_LibEdit_Hotkey_List[] = ...@@ -193,7 +190,7 @@ Ki_HotkeyInfo* s_LibEdit_Hotkey_List[] =
&HkCreatePin, &HkCreatePin,
&HkInsertPin, &HkInsertPin,
&HkEdit, &HkEdit,
&HkMovePin, &HkMoveLibItem,
&HkDelete, &HkDelete,
&HkRotate, &HkRotate,
&HkDrag, &HkDrag,
...@@ -816,6 +813,11 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawSt ...@@ -816,6 +813,11 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawSt
GetEventHandler()->ProcessEvent( cmd ); GetEventHandler()->ProcessEvent( cmd );
break; break;
case COMPONENT_FIELD_DRAW_TYPE:
cmd.SetId( ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM );
GetEventHandler()->ProcessEvent( cmd );
break;
default: default:
break; break;
} }
...@@ -839,6 +841,11 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawSt ...@@ -839,6 +841,11 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawSt
GetEventHandler()->ProcessEvent( cmd ); GetEventHandler()->ProcessEvent( cmd );
break; break;
case COMPONENT_FIELD_DRAW_TYPE:
cmd.SetId( ID_POPUP_LIBEDIT_FIELD_ROTATE_ITEM );
GetEventHandler()->ProcessEvent( cmd );
break;
default: default:
break; break;
} }
......
...@@ -80,7 +80,7 @@ bool WinEDA_LibeditFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ...@@ -80,7 +80,7 @@ bool WinEDA_LibeditFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu
case COMPONENT_ARC_DRAW_TYPE: case COMPONENT_ARC_DRAW_TYPE:
if( DrawEntry->m_Flags == 0 ) if( DrawEntry->m_Flags == 0 )
{ {
msg = AddHotkeyName( _( "Move Arc " ), s_Libedit_Hokeys_Descr, msg = AddHotkeyName( _( "Move Arc" ), s_Libedit_Hokeys_Descr,
HK_LIBEDIT_MOVE_GRAPHIC_ITEM ); HK_LIBEDIT_MOVE_GRAPHIC_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST,
msg, move_arc_xpm ); msg, move_arc_xpm );
...@@ -97,7 +97,7 @@ bool WinEDA_LibeditFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ...@@ -97,7 +97,7 @@ bool WinEDA_LibeditFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu
if( DrawEntry->m_Flags == 0 ) if( DrawEntry->m_Flags == 0 )
{ {
msg = AddHotkeyName( _( "Delete Arc " ), s_Libedit_Hokeys_Descr, msg = AddHotkeyName( _( "Delete Arc" ), s_Libedit_Hokeys_Descr,
HK_DELETE ); HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM,
msg, delete_arc_xpm ); msg, delete_arc_xpm );
...@@ -107,7 +107,7 @@ bool WinEDA_LibeditFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ...@@ -107,7 +107,7 @@ bool WinEDA_LibeditFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu
case COMPONENT_CIRCLE_DRAW_TYPE: case COMPONENT_CIRCLE_DRAW_TYPE:
if( DrawEntry->m_Flags == 0 ) if( DrawEntry->m_Flags == 0 )
{ {
msg = AddHotkeyName( _( "Move Circle " ), s_Libedit_Hokeys_Descr, msg = AddHotkeyName( _( "Move Circle" ), s_Libedit_Hokeys_Descr,
HK_LIBEDIT_MOVE_GRAPHIC_ITEM ); HK_LIBEDIT_MOVE_GRAPHIC_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST,
msg, move_circle_xpm ); msg, move_circle_xpm );
...@@ -128,7 +128,7 @@ bool WinEDA_LibeditFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ...@@ -128,7 +128,7 @@ bool WinEDA_LibeditFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu
if( DrawEntry->m_Flags == 0 ) if( DrawEntry->m_Flags == 0 )
{ {
msg = AddHotkeyName( _( "Delete Circle " ), msg = AddHotkeyName( _( "Delete Circle" ),
s_Libedit_Hokeys_Descr, HK_DELETE ); s_Libedit_Hokeys_Descr, HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM,
msg, delete_circle_xpm ); msg, delete_circle_xpm );
...@@ -138,7 +138,7 @@ bool WinEDA_LibeditFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ...@@ -138,7 +138,7 @@ bool WinEDA_LibeditFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu
case COMPONENT_RECT_DRAW_TYPE: case COMPONENT_RECT_DRAW_TYPE:
if( DrawEntry->m_Flags == 0 ) if( DrawEntry->m_Flags == 0 )
{ {
msg = AddHotkeyName( _( "Move Rectangle " ), s_Libedit_Hokeys_Descr, msg = AddHotkeyName( _( "Move Rectangle" ), s_Libedit_Hokeys_Descr,
HK_LIBEDIT_MOVE_GRAPHIC_ITEM ); HK_LIBEDIT_MOVE_GRAPHIC_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST,
msg, move_rectangle_xpm ); msg, move_rectangle_xpm );
...@@ -159,7 +159,7 @@ bool WinEDA_LibeditFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ...@@ -159,7 +159,7 @@ bool WinEDA_LibeditFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu
if( DrawEntry->m_Flags == 0 ) if( DrawEntry->m_Flags == 0 )
{ {
msg = AddHotkeyName( _( "Delete Rectangle " ), s_Libedit_Hokeys_Descr, msg = AddHotkeyName( _( "Delete Rectangle" ), s_Libedit_Hokeys_Descr,
HK_DELETE ); HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM,
msg, delete_rectangle_xpm ); msg, delete_rectangle_xpm );
...@@ -170,25 +170,25 @@ bool WinEDA_LibeditFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ...@@ -170,25 +170,25 @@ bool WinEDA_LibeditFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
if( DrawEntry->m_Flags == 0 ) if( DrawEntry->m_Flags == 0 )
{ {
msg = AddHotkeyName( _( "Move Text " ), s_Libedit_Hokeys_Descr, msg = AddHotkeyName( _( "Move Text" ), s_Libedit_Hokeys_Descr,
HK_LIBEDIT_MOVE_GRAPHIC_ITEM ); HK_LIBEDIT_MOVE_GRAPHIC_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST,
msg, move_text_xpm ); msg, move_text_xpm );
} }
msg = AddHotkeyName( _( "Edit Text " ), s_Libedit_Hokeys_Descr, msg = AddHotkeyName( _( "Edit Text" ), s_Libedit_Hokeys_Descr,
HK_EDIT ); HK_EDIT );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM, ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM,
msg, edit_text_xpm ); msg, edit_text_xpm );
msg = AddHotkeyName( _( "Rotate Text " ), s_Libedit_Hokeys_Descr, msg = AddHotkeyName( _( "Rotate Text" ), s_Libedit_Hokeys_Descr,
HK_ROTATE ); HK_ROTATE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT, ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT,
msg, edit_text_xpm ); msg, edit_text_xpm );
if( DrawEntry->m_Flags == 0 ) if( DrawEntry->m_Flags == 0 )
{ {
msg = AddHotkeyName( _( "Delete Text " ), s_Libedit_Hokeys_Descr, msg = AddHotkeyName( _( "Delete Text" ), s_Libedit_Hokeys_Descr,
HK_DELETE ); HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM,
msg, delete_text_xpm ); msg, delete_text_xpm );
...@@ -198,7 +198,7 @@ bool WinEDA_LibeditFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ...@@ -198,7 +198,7 @@ bool WinEDA_LibeditFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu
case COMPONENT_POLYLINE_DRAW_TYPE: case COMPONENT_POLYLINE_DRAW_TYPE:
if( DrawEntry->m_Flags == 0 ) if( DrawEntry->m_Flags == 0 )
{ {
msg = AddHotkeyName( _( "Move Line " ), s_Libedit_Hokeys_Descr, msg = AddHotkeyName( _( "Move Line" ), s_Libedit_Hokeys_Descr,
HK_LIBEDIT_MOVE_GRAPHIC_ITEM ); HK_LIBEDIT_MOVE_GRAPHIC_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST,
msg, move_line_xpm ); msg, move_line_xpm );
...@@ -230,7 +230,7 @@ bool WinEDA_LibeditFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ...@@ -230,7 +230,7 @@ bool WinEDA_LibeditFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu
{ {
if( ( (LIB_POLYLINE*) DrawEntry )->GetCornerCount() > 2 ) if( ( (LIB_POLYLINE*) DrawEntry )->GetCornerCount() > 2 )
{ {
msg = AddHotkeyName( _( "Delete Segment " ), msg = AddHotkeyName( _( "Delete Segment" ),
s_Libedit_Hokeys_Descr, HK_DELETE ); s_Libedit_Hokeys_Descr, HK_DELETE );
ADD_MENUITEM( PopMenu, ADD_MENUITEM( PopMenu,
ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT, ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT,
...@@ -243,15 +243,19 @@ bool WinEDA_LibeditFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ...@@ -243,15 +243,19 @@ bool WinEDA_LibeditFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu
case COMPONENT_FIELD_DRAW_TYPE: case COMPONENT_FIELD_DRAW_TYPE:
if( DrawEntry->m_Flags == 0 ) if( DrawEntry->m_Flags == 0 )
{ {
msg = AddHotkeyName( _( "Move Field " ), s_Libedit_Hokeys_Descr, msg = AddHotkeyName( _( "Move Field" ), s_Libedit_Hokeys_Descr,
HK_LIBEDIT_MOVE_GRAPHIC_ITEM ); HK_LIBEDIT_MOVE_GRAPHIC_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST,
msg, move_field_xpm ); msg, move_field_xpm );
} }
msg = AddHotkeyName( _( "Field Rotate" ), s_Libedit_Hokeys_Descr,
HK_ROTATE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_FIELD_ROTATE_ITEM, ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_FIELD_ROTATE_ITEM,
_( "Field Rotate" ), rotate_field_xpm ); msg, rotate_field_xpm );
msg = AddHotkeyName( _( "Field Edit" ), s_Libedit_Hokeys_Descr,
HK_EDIT );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM, ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM,
_( "Field Edit" ), edit_text_xpm ); msg, edit_text_xpm );
break; break;
......
...@@ -165,7 +165,7 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( WinEDA_SchematicFrame* aParent, ...@@ -165,7 +165,7 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( WinEDA_SchematicFrame* aParent,
SetShowDeMorgan( false ); SetShowDeMorgan( false );
m_drawSpecificConvert = true; m_drawSpecificConvert = true;
m_drawSpecificUnit = false; m_drawSpecificUnit = false;
m_savedComponent = NULL; m_tempCopyComponent = NULL;
m_HotkeysZoomAndGridList = s_Libedit_Hokeys_Descr; m_HotkeysZoomAndGridList = s_Libedit_Hokeys_Descr;
// Give an icon // Give an icon
...@@ -238,6 +238,9 @@ WinEDA_LibeditFrame::~WinEDA_LibeditFrame() ...@@ -238,6 +238,9 @@ WinEDA_LibeditFrame::~WinEDA_LibeditFrame()
frame->m_LibeditFrame = NULL; frame->m_LibeditFrame = NULL;
m_drawItem = m_lastDrawItem = NULL; m_drawItem = m_lastDrawItem = NULL;
if ( m_tempCopyComponent )
delete m_tempCopyComponent;
m_tempCopyComponent = NULL;
} }
...@@ -969,11 +972,26 @@ void WinEDA_LibeditFrame::SetLanguage( wxCommandEvent& event ) ...@@ -969,11 +972,26 @@ void WinEDA_LibeditFrame::SetLanguage( wxCommandEvent& event )
} }
void WinEDA_LibeditFrame::DeleteSavedComponent() /** Function TempCopyComponent
* create a temporary copy of the current edited component
* Used to prepare an Undo ant/or abort command before editing the component
*/
void WinEDA_LibeditFrame::TempCopyComponent()
{ {
if( m_savedComponent ) if( m_tempCopyComponent )
{ delete m_tempCopyComponent;
delete m_savedComponent; if( m_component )
m_savedComponent = NULL; m_tempCopyComponent = new LIB_COMPONENT( *m_component );
} }
/** Function RestoreComponent
* Restore the current edited component from its temporary copy.
* Used to abort a command
*/
void WinEDA_LibeditFrame::RestoreComponent()
{
if( m_component )
delete m_component;
m_component = m_tempCopyComponent;
m_tempCopyComponent = NULL;
} }
...@@ -23,10 +23,10 @@ class Dialog_BodyGraphicText_Properties; ...@@ -23,10 +23,10 @@ class Dialog_BodyGraphicText_Properties;
*/ */
class WinEDA_LibeditFrame : public WinEDA_DrawFrame class WinEDA_LibeditFrame : public WinEDA_DrawFrame
{ {
LIB_COMPONENT* m_savedComponent; ///< Temporary copy of current component during edit. LIB_COMPONENT* m_tempCopyComponent; ///< Temporary copy of current component during edit.
wxString m_oldRootName; ///< The actual pointer of the component loaded from wxString m_oldRootName; ///< The actual pointer of the component loaded from
///< a library. Do not do anything with this pointer. ///< a library. Do not do anything with this pointer.
///< It is to be used for reference purposes only. ///< It is to be used for reference purposes only.
public: public:
WinEDAChoiceBox* m_SelpartBox; // a Box to select a part to edit (if any) WinEDAChoiceBox* m_SelpartBox; // a Box to select a part to edit (if any)
...@@ -171,7 +171,22 @@ public: ...@@ -171,7 +171,22 @@ public:
FILL_T GetFillStyle( void ) { return m_drawFillStyle; } FILL_T GetFillStyle( void ) { return m_drawFillStyle; }
void DeleteSavedComponent(); /** Function TempCopyComponent
* create a temporary copy of the current edited component
* Used to prepare an Undo ant/or abort command before editing the component
*/
void TempCopyComponent();
/** Function RestoreComponent
* Restore the current edited component from its temporary copy.
* Used to abort a command
*/
void RestoreComponent();
/** Function GetTempCopyComponent
* @return the temporary copy of the current component.
*/
LIB_COMPONENT* GetTempCopyComponent() { return m_tempCopyComponent; }
bool IsEditingDrawItem() { return m_drawItem && m_drawItem->InEditMode(); } bool IsEditingDrawItem() { return m_drawItem && m_drawItem->InEditMode(); }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "eeschema_id.h" #include "eeschema_id.h"
#include "program.h" #include "program.h"
#include "general.h"
#include "libeditframe.h" #include "libeditframe.h"
#include "class_libentry.h" #include "class_libentry.h"
#include "dialog_lib_edit_draw_item.h" #include "dialog_lib_edit_draw_item.h"
...@@ -61,14 +62,14 @@ void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC, LIB_DRAW_ITEM* DrawItem ) ...@@ -61,14 +62,14 @@ void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC, LIB_DRAW_ITEM* DrawItem )
/* TODO: see if m_drawFillStyle must retain the last fill option or not. /* TODO: see if m_drawFillStyle must retain the last fill option or not.
* if the last is Filled, having next new graphic items created * if the last is Filled, having next new graphic items created
* with filled body is often bad. * with filled body is often bad.
* currently m_drawFillStyle is left with the defualt value (not filled) * currently m_drawFillStyle is left with the default value (not filled)
*/ */
if( DrawItem->IsFillable() ) if( DrawItem->IsFillable() )
m_drawFillStyle = (FILL_T) dialog.GetFillStyle(); m_drawFillStyle = (FILL_T) dialog.GetFillStyle();
#endif #endif
// Save copy for undo is done before place. // Save copy for undo if not in edit (edit command already handle the save copy)
if( !( DrawItem->m_Flags & IS_NEW ) ) if( DrawItem->m_Flags == 0 )
SaveCopyInUndoList( DrawItem->GetParent() ); SaveCopyInUndoList( DrawItem->GetParent() );
if( m_drawSpecificUnit ) if( m_drawSpecificUnit )
...@@ -106,19 +107,17 @@ static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -106,19 +107,17 @@ static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC )
Panel->ManageCurseur = NULL; Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL; Panel->ForceCloseManageCurseur = NULL;
bool deleteItem = item->IsNew(); bool newItem = item->IsNew();
item->EndEdit( parent->GetScreen()->GetCursorDrawPosition(), true ); item->EndEdit( parent->GetScreen()->GetCursorDrawPosition(), true );
// This draw is required to restore the item to it's last state. if( newItem )
item->Draw( Panel, DC, wxPoint( 0, 0 ), -1, g_XorMode, NULL, DefaultTransform );
if( deleteItem )
{ {
SAFE_DELETE( item ); delete item;
parent->SetDrawItem( NULL ); parent->SetDrawItem( NULL );
} }
else
parent->RestoreComponent();
parent->DeleteSavedComponent();
Panel->Refresh(); Panel->Refresh();
} }
...@@ -187,7 +186,7 @@ LIB_DRAW_ITEM* WinEDA_LibeditFrame::CreateGraphicItem( LIB_COMPONENT* LibEntry, ...@@ -187,7 +186,7 @@ LIB_DRAW_ITEM* WinEDA_LibeditFrame::CreateGraphicItem( LIB_COMPONENT* LibEntry,
if( m_drawSpecificConvert ) if( m_drawSpecificConvert )
m_drawItem->m_Convert = m_convert; m_drawItem->m_Convert = m_convert;
m_savedComponent = new LIB_COMPONENT( *m_component ); TempCopyComponent();
} }
else else
{ {
...@@ -236,6 +235,7 @@ static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool era ...@@ -236,6 +235,7 @@ static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool era
BASE_SCREEN* Screen = panel->GetScreen(); BASE_SCREEN* Screen = panel->GetScreen();
item->SetEraseLastDrawItem( erase );
item->Draw( panel, DC, Screen->GetCursorDrawPosition(), -1, g_XorMode, NULL, item->Draw( panel, DC, Screen->GetCursorDrawPosition(), -1, g_XorMode, NULL,
DefaultTransform ); DefaultTransform );
} }
...@@ -251,7 +251,7 @@ void WinEDA_LibeditFrame::StartMoveDrawSymbol( wxDC* DC ) ...@@ -251,7 +251,7 @@ void WinEDA_LibeditFrame::StartMoveDrawSymbol( wxDC* DC )
if( m_drawItem->m_Unit != m_unit ) if( m_drawItem->m_Unit != m_unit )
m_drawItem->m_Unit = m_unit; m_drawItem->m_Unit = m_unit;
m_savedComponent = new LIB_COMPONENT( *m_component ); TempCopyComponent();
m_drawItem->BeginEdit( IS_MOVED, GetScreen()->GetCursorDrawPosition() ); m_drawItem->BeginEdit( IS_MOVED, GetScreen()->GetCursorDrawPosition() );
DrawPanel->ManageCurseur = RedrawWhileMovingCursor; DrawPanel->ManageCurseur = RedrawWhileMovingCursor;
DrawPanel->ForceCloseManageCurseur = AbortSymbolTraceOn; DrawPanel->ForceCloseManageCurseur = AbortSymbolTraceOn;
...@@ -265,7 +265,7 @@ void WinEDA_LibeditFrame::StartModifyDrawSymbol( wxDC* DC ) ...@@ -265,7 +265,7 @@ void WinEDA_LibeditFrame::StartModifyDrawSymbol( wxDC* DC )
if( m_drawItem == NULL ) if( m_drawItem == NULL )
return; return;
m_savedComponent = new LIB_COMPONENT( *m_component ); TempCopyComponent();
m_drawItem->BeginEdit( IS_RESIZED, GetScreen()->GetCursorDrawPosition() ); m_drawItem->BeginEdit( IS_RESIZED, GetScreen()->GetCursorDrawPosition() );
DrawPanel->ManageCurseur = SymbolDisplayDraw; DrawPanel->ManageCurseur = SymbolDisplayDraw;
DrawPanel->ForceCloseManageCurseur = AbortSymbolTraceOn; DrawPanel->ForceCloseManageCurseur = AbortSymbolTraceOn;
...@@ -300,8 +300,7 @@ void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC ) ...@@ -300,8 +300,7 @@ void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC )
else else
SetCursor( wxCURSOR_ARROW ); SetCursor( wxCURSOR_ARROW );
SaveCopyInUndoList( m_savedComponent ); SaveCopyInUndoList( GetTempCopyComponent() );
DeleteSavedComponent();
if( m_drawItem->IsNew() ) if( m_drawItem->IsNew() )
m_component->AddDrawItem( m_drawItem ); m_component->AddDrawItem( m_drawItem );
......
...@@ -445,7 +445,7 @@ namespace boost { namespace polygon{ ...@@ -445,7 +445,7 @@ namespace boost { namespace polygon{
}; };
template <typename S45V> template <typename S45V>
static inline void sortScan45Vector(S45V& vec) { static inline void sortScan45Vector(S45V& vec) {
std::sort(vec.begin(), vec.end(), lessScan45Vertex()); gtlsort(vec.begin(), vec.end(), lessScan45Vertex());
} }
template <typename CountType, typename output_functor> template <typename CountType, typename output_functor>
......
...@@ -213,7 +213,7 @@ namespace boost { namespace polygon{ ...@@ -213,7 +213,7 @@ namespace boost { namespace polygon{
Interval rectIvl = nodep->rect.get(orient); Interval rectIvl = nodep->rect.get(orient);
leadingEdges.push_back(EdgeAssociation(std::pair<Unit, Interval>(leading, rectIvl), nodep)); leadingEdges.push_back(EdgeAssociation(std::pair<Unit, Interval>(leading, rectIvl), nodep));
} }
std::sort(leadingEdges.begin(), leadingEdges.end(), lessEdgeAssociation()); gtlsort(leadingEdges.begin(), leadingEdges.end(), lessEdgeAssociation());
typename std::vector<EdgeAssociation>::iterator leadingBegin = leadingEdges.begin(); typename std::vector<EdgeAssociation>::iterator leadingBegin = leadingEdges.begin();
iT trailingBegin = beginNode; iT trailingBegin = beginNode;
while(leadingBegin != leadingEdges.end()) { while(leadingBegin != leadingEdges.end()) {
......
...@@ -904,7 +904,7 @@ namespace boost { namespace polygon{ ...@@ -904,7 +904,7 @@ namespace boost { namespace polygon{
data.push_back(Vertex45(Point(10, 0), 2, -1)); data.push_back(Vertex45(Point(10, 0), 2, -1));
data.push_back(Vertex45(Point(10, 10), 2, 1)); data.push_back(Vertex45(Point(10, 10), 2, 1));
data.push_back(Vertex45(Point(10, 10), 0, 1)); data.push_back(Vertex45(Point(10, 10), 0, 1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -928,7 +928,7 @@ namespace boost { namespace polygon{ ...@@ -928,7 +928,7 @@ namespace boost { namespace polygon{
data.push_back(Vertex45(Point(10, 10), 2, -1)); data.push_back(Vertex45(Point(10, 10), 2, -1));
data.push_back(Vertex45(Point(10, 20), 2, 1)); data.push_back(Vertex45(Point(10, 20), 2, 1));
data.push_back(Vertex45(Point(10, 20), 1, 1)); data.push_back(Vertex45(Point(10, 20), 1, 1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -953,7 +953,7 @@ namespace boost { namespace polygon{ ...@@ -953,7 +953,7 @@ namespace boost { namespace polygon{
data.push_back(Vertex45(Point(10, 10), 0, -1)); data.push_back(Vertex45(Point(10, 10), 0, -1));
data.push_back(Vertex45(Point(20, 10), 1, -1)); data.push_back(Vertex45(Point(20, 10), 1, -1));
data.push_back(Vertex45(Point(20, 10), 0, 1)); data.push_back(Vertex45(Point(20, 10), 0, 1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -1018,7 +1018,7 @@ namespace boost { namespace polygon{ ...@@ -1018,7 +1018,7 @@ namespace boost { namespace polygon{
data.push_back(Vertex45(Point(12, 8), 1, -1)); data.push_back(Vertex45(Point(12, 8), 1, -1));
// result == 12 8 -1 1 // result == 12 8 -1 1
data.push_back(Vertex45(Point(12, 8), -1, 1)); data.push_back(Vertex45(Point(12, 8), -1, 1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -1051,7 +1051,7 @@ namespace boost { namespace polygon{ ...@@ -1051,7 +1051,7 @@ namespace boost { namespace polygon{
stdcout << "scanning\n"; stdcout << "scanning\n";
scan45.scan(result, vertices.begin(), vertices.end()); scan45.scan(result, vertices.begin(), vertices.end());
std::sort(result.begin(), result.end()); gtlsort(result.begin(), result.end());
pf.scan(polys, result.begin(), result.end()); pf.scan(polys, result.begin(), result.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -1123,7 +1123,7 @@ namespace boost { namespace polygon{ ...@@ -1123,7 +1123,7 @@ namespace boost { namespace polygon{
data.push_back(Vertex45(Point(8, 6), -1, -1)); data.push_back(Vertex45(Point(8, 6), -1, -1));
data.push_back(Vertex45(Point(8, 6), 1, 1)); data.push_back(Vertex45(Point(8, 6), 1, 1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -1195,7 +1195,7 @@ namespace boost { namespace polygon{ ...@@ -1195,7 +1195,7 @@ namespace boost { namespace polygon{
data.push_back(Vertex45(Point(10, 8), -1, -1)); data.push_back(Vertex45(Point(10, 8), -1, -1));
data.push_back(Vertex45(Point(10, 8), 1, 1)); data.push_back(Vertex45(Point(10, 8), 1, 1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -1239,7 +1239,7 @@ namespace boost { namespace polygon{ ...@@ -1239,7 +1239,7 @@ namespace boost { namespace polygon{
data.push_back(Vertex45(Point(10, 22), 2, -1)); data.push_back(Vertex45(Point(10, 22), 2, -1));
data.push_back(Vertex45(Point(10, 22), 0, -1)); data.push_back(Vertex45(Point(10, 22), 0, -1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -1668,7 +1668,7 @@ namespace boost { namespace polygon{ ...@@ -1668,7 +1668,7 @@ namespace boost { namespace polygon{
data.push_back(Vertex45(Point(10, 0), 2, -1)); data.push_back(Vertex45(Point(10, 0), 2, -1));
data.push_back(Vertex45(Point(10, 10), 2, 1)); data.push_back(Vertex45(Point(10, 10), 2, 1));
data.push_back(Vertex45(Point(10, 10), 0, 1)); data.push_back(Vertex45(Point(10, 10), 0, 1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -1692,7 +1692,7 @@ namespace boost { namespace polygon{ ...@@ -1692,7 +1692,7 @@ namespace boost { namespace polygon{
data.push_back(Vertex45(Point(10, 10), 2, -1)); data.push_back(Vertex45(Point(10, 10), 2, -1));
data.push_back(Vertex45(Point(10, 20), 2, 1)); data.push_back(Vertex45(Point(10, 20), 2, 1));
data.push_back(Vertex45(Point(10, 20), 1, 1)); data.push_back(Vertex45(Point(10, 20), 1, 1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -1716,7 +1716,7 @@ namespace boost { namespace polygon{ ...@@ -1716,7 +1716,7 @@ namespace boost { namespace polygon{
data.push_back(Vertex45(Point(10, 10), 0, -1)); data.push_back(Vertex45(Point(10, 10), 0, -1));
data.push_back(Vertex45(Point(20, 10), 1, -1)); data.push_back(Vertex45(Point(20, 10), 1, -1));
data.push_back(Vertex45(Point(20, 10), 0, 1)); data.push_back(Vertex45(Point(20, 10), 0, 1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -1742,7 +1742,7 @@ namespace boost { namespace polygon{ ...@@ -1742,7 +1742,7 @@ namespace boost { namespace polygon{
data.push_back(Vertex45(Point(10, 10), 0, 1)); data.push_back(Vertex45(Point(10, 10), 0, 1));
data.push_back(Vertex45(Point(20, 20), 1, 1)); data.push_back(Vertex45(Point(20, 20), 1, 1));
data.push_back(Vertex45(Point(20, 20), 2, 1)); data.push_back(Vertex45(Point(20, 20), 2, 1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -1768,7 +1768,7 @@ namespace boost { namespace polygon{ ...@@ -1768,7 +1768,7 @@ namespace boost { namespace polygon{
data.push_back(Vertex45(Point(20, 10), 0, 1)); data.push_back(Vertex45(Point(20, 10), 0, 1));
data.push_back(Vertex45(Point(20, -10), -1, -1)); data.push_back(Vertex45(Point(20, -10), -1, -1));
data.push_back(Vertex45(Point(20, -10), 2, -1)); data.push_back(Vertex45(Point(20, -10), 2, -1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -1801,7 +1801,7 @@ namespace boost { namespace polygon{ ...@@ -1801,7 +1801,7 @@ namespace boost { namespace polygon{
data.push_back(Vertex45(Point(2, 2), 0, 1)); data.push_back(Vertex45(Point(2, 2), 0, 1));
data.push_back(Vertex45(Point(3, 2), 1, 1)); data.push_back(Vertex45(Point(3, 2), 1, 1));
data.push_back(Vertex45(Point(3, 2), 0, -1)); data.push_back(Vertex45(Point(3, 2), 0, -1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -1835,7 +1835,7 @@ namespace boost { namespace polygon{ ...@@ -1835,7 +1835,7 @@ namespace boost { namespace polygon{
data.push_back(Vertex45(Point(2, 2), 2, -1)); data.push_back(Vertex45(Point(2, 2), 2, -1));
data.push_back(Vertex45(Point(2, 2), 0, -1)); data.push_back(Vertex45(Point(2, 2), 0, -1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -1899,7 +1899,7 @@ namespace boost { namespace polygon{ ...@@ -1899,7 +1899,7 @@ namespace boost { namespace polygon{
data.push_back(Vertex45(Point(12, 8), 1, -1)); data.push_back(Vertex45(Point(12, 8), 1, -1));
// result == 12 8 -1 1 // result == 12 8 -1 1
data.push_back(Vertex45(Point(12, 8), -1, 1)); data.push_back(Vertex45(Point(12, 8), -1, 1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -1933,7 +1933,7 @@ namespace boost { namespace polygon{ ...@@ -1933,7 +1933,7 @@ namespace boost { namespace polygon{
stdcout << "scanning\n"; stdcout << "scanning\n";
scan45.scan(result, vertices.begin(), vertices.end()); scan45.scan(result, vertices.begin(), vertices.end());
std::sort(result.begin(), result.end()); gtlsort(result.begin(), result.end());
pf.scan(polys, result.begin(), result.end()); pf.scan(polys, result.begin(), result.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -2005,7 +2005,7 @@ namespace boost { namespace polygon{ ...@@ -2005,7 +2005,7 @@ namespace boost { namespace polygon{
data.push_back(Vertex45(Point(8, 6), -1, -1)); data.push_back(Vertex45(Point(8, 6), -1, -1));
data.push_back(Vertex45(Point(8, 6), 1, 1)); data.push_back(Vertex45(Point(8, 6), 1, 1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -2077,7 +2077,7 @@ namespace boost { namespace polygon{ ...@@ -2077,7 +2077,7 @@ namespace boost { namespace polygon{
data.push_back(Vertex45(Point(10, 8), -1, -1)); data.push_back(Vertex45(Point(10, 8), -1, -1));
data.push_back(Vertex45(Point(10, 8), 1, 1)); data.push_back(Vertex45(Point(10, 8), 1, 1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -2121,7 +2121,7 @@ namespace boost { namespace polygon{ ...@@ -2121,7 +2121,7 @@ namespace boost { namespace polygon{
data.push_back(Vertex45(Point(10, 22), 2, -1)); data.push_back(Vertex45(Point(10, 22), 2, -1));
data.push_back(Vertex45(Point(10, 22), 0, -1)); data.push_back(Vertex45(Point(10, 22), 0, -1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
......
...@@ -119,7 +119,7 @@ namespace boost { namespace polygon{ ...@@ -119,7 +119,7 @@ namespace boost { namespace polygon{
// orient_ = orient; // orient_ = orient;
// output_.clear(); // output_.clear();
// output_.insert(output_.end(), input_begin, input_end); // output_.insert(output_.end(), input_begin, input_end);
// std::sort(output_.begin(), output_.end()); // gtlsort(output_.begin(), output_.end());
// } // }
}; };
......
...@@ -186,7 +186,7 @@ namespace boost { namespace polygon{ ...@@ -186,7 +186,7 @@ namespace boost { namespace polygon{
template <typename graph_type> template <typename graph_type>
static void performTouch(graph_type& graph, TouchSetData& tsd) { static void performTouch(graph_type& graph, TouchSetData& tsd) {
std::sort(tsd.begin(), tsd.end(), lessVertex45Compact()); gtlsort(tsd.begin(), tsd.end(), lessVertex45Compact());
typedef std::vector<std::pair<Point, typename boolean_op_45<Unit>::template Scan45CountT<CountTouch> > > TSD; typedef std::vector<std::pair<Point, typename boolean_op_45<Unit>::template Scan45CountT<CountTouch> > > TSD;
TSD tsd_; TSD tsd_;
tsd_.reserve(tsd.size()); tsd_.reserve(tsd.size());
......
...@@ -33,56 +33,91 @@ namespace boost { namespace polygon{ ...@@ -33,56 +33,91 @@ namespace boost { namespace polygon{
static inline bool sorted(const polygon_90_set_view<ltype, rtype, op_type>& polygon_set); static inline bool sorted(const polygon_90_set_view<ltype, rtype, op_type>& polygon_set);
}; };
template <typename value_type, typename ltype, typename rtype, typename op_type> template <typename value_type, typename ltype, typename rtype, typename op_type>
struct compute_90_set_value { struct compute_90_set_value {
static static
void value(value_type& output_, const ltype& lvalue_, const rtype& rvalue_, orientation_2d orient_) { void value(value_type& output_, const ltype& lvalue_, const rtype& rvalue_, orientation_2d orient_) {
value_type linput_(orient_); value_type linput_(orient_);
value_type rinput_(orient_); value_type rinput_(orient_);
insert_into_view_arg(linput_, lvalue_, orient_); orientation_2d orient_l = polygon_90_set_traits<ltype>::orient(lvalue_);
insert_into_view_arg(rinput_, rvalue_, orient_); orientation_2d orient_r = polygon_90_set_traits<rtype>::orient(rvalue_);
output_.applyBooleanBinaryOp(linput_.begin(), linput_.end(), //std::cout << "compute_90_set_value-0 orientations (left, right, out):\t" << orient_l.to_int()
rinput_.begin(), rinput_.end(), boolean_op::BinaryCount<op_type>()); // << "," << orient_r.to_int() << "," << orient_.to_int() << std::endl;
} insert_into_view_arg(linput_, lvalue_, orient_l);
}; insert_into_view_arg(rinput_, rvalue_, orient_r);
output_.applyBooleanBinaryOp(linput_.begin(), linput_.end(),
template <typename value_type, typename lcoord, typename rcoord, typename op_type> rinput_.begin(), rinput_.end(), boolean_op::BinaryCount<op_type>());
struct compute_90_set_value<value_type, polygon_90_set_data<lcoord>, polygon_90_set_data<rcoord>, op_type> { }
static };
void value(value_type& output_, const polygon_90_set_data<lcoord>& lvalue_,
const polygon_90_set_data<rcoord>& rvalue_, orientation_2d) { template <typename value_type, typename lcoord, typename rcoord, typename op_type>
lvalue_.sort(); struct compute_90_set_value<value_type, polygon_90_set_data<lcoord>, polygon_90_set_data<rcoord>, op_type> {
rvalue_.sort(); static
output_.applyBooleanBinaryOp(lvalue_.begin(), lvalue_.end(), void value(value_type& output_, const polygon_90_set_data<lcoord>& lvalue_,
rvalue_.begin(), rvalue_.end(), boolean_op::BinaryCount<op_type>()); const polygon_90_set_data<rcoord>& rvalue_, orientation_2d orient_) {
} orientation_2d orient_l = lvalue_.orient();
}; orientation_2d orient_r = rvalue_.orient();
value_type linput_(orient_);
template <typename value_type, typename lcoord, typename rtype, typename op_type> value_type rinput_(orient_);
struct compute_90_set_value<value_type, polygon_90_set_data<lcoord>, rtype, op_type> { //std::cout << "compute_90_set_value-1 orientations (left, right, out):\t" << orient_l.to_int()
static // << "," << orient_r.to_int() << "," << orient_.to_int() << std::endl;
void value(value_type& output_, const polygon_90_set_data<lcoord>& lvalue_, if((orient_ == orient_l) && (orient_== orient_r)){ // assume that most of the time this condition is met
const rtype& rvalue_, orientation_2d orient_) { lvalue_.sort();
value_type rinput_(orient_); rvalue_.sort();
lvalue_.sort(); output_.applyBooleanBinaryOp(lvalue_.begin(), lvalue_.end(),
insert_into_view_arg(rinput_, rvalue_, orient_); rvalue_.begin(), rvalue_.end(), boolean_op::BinaryCount<op_type>());
output_.applyBooleanBinaryOp(lvalue_.begin(), lvalue_.end(), }else if((orient_ != orient_l) && (orient_!= orient_r)){ // both the orientations are not equal to input
rinput_.begin(), rinput_.end(), boolean_op::BinaryCount<op_type>()); // easier way is to ignore the input orientation and use the input data's orientation, but not done so
} insert_into_view_arg(linput_, lvalue_, orient_l);
}; insert_into_view_arg(rinput_, rvalue_, orient_r);
output_.applyBooleanBinaryOp(linput_.begin(), linput_.end(),
template <typename value_type, typename ltype, typename rcoord, typename op_type> rinput_.begin(), rinput_.end(), boolean_op::BinaryCount<op_type>());
struct compute_90_set_value<value_type, ltype, polygon_90_set_data<rcoord>, op_type> { }else if(orient_ != orient_l){ // left hand side orientation is different
static insert_into_view_arg(linput_, lvalue_, orient_l);
void value(value_type& output_, const ltype& lvalue_, rvalue_.sort();
const polygon_90_set_data<rcoord>& rvalue_, orientation_2d orient_) { output_.applyBooleanBinaryOp(linput_.begin(), linput_.end(),
value_type linput_(orient_); rvalue_.begin(), rvalue_.end(), boolean_op::BinaryCount<op_type>());
insert_into_view_arg(linput_, lvalue_, orient_); } else if(orient_ != orient_r){ // right hand side orientation is different
rvalue_.sort(); insert_into_view_arg(rinput_, rvalue_, orient_r);
output_.applyBooleanBinaryOp(linput_.begin(), linput_.end(), lvalue_.sort();
rvalue_.begin(), rvalue_.end(), boolean_op::BinaryCount<op_type>()); output_.applyBooleanBinaryOp(lvalue_.begin(), lvalue_.end(),
} rinput_.begin(), rinput_.end(), boolean_op::BinaryCount<op_type>());
}; }
}
};
template <typename value_type, typename lcoord, typename rtype, typename op_type>
struct compute_90_set_value<value_type, polygon_90_set_data<lcoord>, rtype, op_type> {
static
void value(value_type& output_, const polygon_90_set_data<lcoord>& lvalue_,
const rtype& rvalue_, orientation_2d orient_) {
value_type rinput_(orient_);
lvalue_.sort();
orientation_2d orient_r = polygon_90_set_traits<rtype>::orient(rvalue_);
//std::cout << "compute_90_set_value-2 orientations (right, out):\t" << orient_r.to_int()
// << "," << orient_.to_int() << std::endl;
insert_into_view_arg(rinput_, rvalue_, orient_r);
output_.applyBooleanBinaryOp(lvalue_.begin(), lvalue_.end(),
rinput_.begin(), rinput_.end(), boolean_op::BinaryCount<op_type>());
}
};
template <typename value_type, typename ltype, typename rcoord, typename op_type>
struct compute_90_set_value<value_type, ltype, polygon_90_set_data<rcoord>, op_type> {
static
void value(value_type& output_, const ltype& lvalue_,
const polygon_90_set_data<rcoord>& rvalue_, orientation_2d orient_) {
value_type linput_(orient_);
orientation_2d orient_l = polygon_90_set_traits<ltype>::orient(lvalue_);
insert_into_view_arg(linput_, lvalue_, orient_l);
rvalue_.sort();
//std::cout << "compute_90_set_value-3 orientations (left, out):\t" << orient_l.to_int()
// << "," << orient_.to_int() << std::endl;
output_.applyBooleanBinaryOp(linput_.begin(), linput_.end(),
rvalue_.begin(), rvalue_.end(), boolean_op::BinaryCount<op_type>());
}
};
template <typename ltype, typename rtype, typename op_type> template <typename ltype, typename rtype, typename op_type>
class polygon_90_set_view { class polygon_90_set_view {
...@@ -129,7 +164,7 @@ namespace boost { namespace polygon{ ...@@ -129,7 +164,7 @@ namespace boost { namespace polygon{
// orient_ = orient; // orient_ = orient;
// output_.clear(); // output_.clear();
// output_.insert(output_.end(), input_begin, input_end); // output_.insert(output_.end(), input_begin, input_end);
// std::sort(output_.begin(), output_.end()); // gtlsort(output_.begin(), output_.end());
// } // }
void sort() const {} //is always sorted void sort() const {} //is always sorted
}; };
...@@ -206,23 +241,34 @@ namespace boost { namespace polygon{ ...@@ -206,23 +241,34 @@ namespace boost { namespace polygon{
typedef type_1 type; typedef type_1 type;
}; };
template <typename geometry_type_1, typename geometry_type_2, typename op_type> template <typename geometry_type_1, typename geometry_type_2, typename op_type>
geometry_type_1& self_assignment_boolean_op(geometry_type_1& lvalue_, const geometry_type_2& rvalue_) { geometry_type_1& self_assignment_boolean_op(geometry_type_1& lvalue_, const geometry_type_2& rvalue_) {
typedef geometry_type_1 ltype; typedef geometry_type_1 ltype;
typedef geometry_type_2 rtype; typedef geometry_type_2 rtype;
typedef typename polygon_90_set_traits<ltype>::coordinate_type coordinate_type; typedef typename polygon_90_set_traits<ltype>::coordinate_type coordinate_type;
typedef polygon_90_set_data<coordinate_type> value_type; typedef polygon_90_set_data<coordinate_type> value_type;
orientation_2d orient_ = polygon_90_set_traits<ltype>::orient(lvalue_); orientation_2d orient_ = polygon_90_set_traits<ltype>::orient(lvalue_);
value_type linput_(orient_); //BM: rvalue_ data set may have its own orientation for scanline
value_type rinput_(orient_); orientation_2d orient_r = polygon_90_set_traits<rtype>::orient(rvalue_);
value_type output_(orient_); //std::cout << "self-assignment boolean-op (left, right, out):\t" << orient_.to_int()
insert_into_view_arg(linput_, lvalue_, orient_); // << "," << orient_r.to_int() << "," << orient_.to_int() << std::endl;
insert_into_view_arg(rinput_, rvalue_, orient_); value_type linput_(orient_);
output_.applyBooleanBinaryOp(linput_.begin(), linput_.end(), // BM: the rinput_ set's (that stores the rvalue_ dataset polygons) scanline orientation is *forced*
rinput_.begin(), rinput_.end(), boolean_op::BinaryCount<op_type>()); // to be same as linput
polygon_90_set_mutable_traits<geometry_type_1>::set(lvalue_, output_.begin(), output_.end(), orient_); value_type rinput_(orient_);
return lvalue_; //BM: The output dataset's scanline orient is set as equal to first input dataset's (lvalue_) orientation
} value_type output_(orient_);
insert_into_view_arg(linput_, lvalue_, orient_);
// BM: The last argument orient_r is the user initialized scanline orientation for rvalue_ data set.
// But since rinput (see above) is initialized to scanline orientation consistent with the lvalue_
// data set, this insertion operation will change the incoming rvalue_ dataset's scanline orientation
insert_into_view_arg(rinput_, rvalue_, orient_r);
// BM: boolean operation and output uses lvalue_ dataset's scanline orientation.
output_.applyBooleanBinaryOp(linput_.begin(), linput_.end(),
rinput_.begin(), rinput_.end(), boolean_op::BinaryCount<op_type>());
polygon_90_set_mutable_traits<geometry_type_1>::set(lvalue_, output_.begin(), output_.end(), orient_);
return lvalue_;
}
namespace operators { namespace operators {
struct y_ps90_b : gtl_yes {}; struct y_ps90_b : gtl_yes {};
......
...@@ -1203,7 +1203,7 @@ namespace boost { namespace polygon{ ...@@ -1203,7 +1203,7 @@ namespace boost { namespace polygon{
static inline void sort_vertex_arbitrary_count(vertex_arbitrary_count& count, const Point& pt) { static inline void sort_vertex_arbitrary_count(vertex_arbitrary_count& count, const Point& pt) {
less_half_edge_count lfec(pt); less_half_edge_count lfec(pt);
std::sort(count.begin(), count.end(), lfec); gtlsort(count.begin(), count.end(), lfec);
} }
typedef std::vector<std::pair<std::pair<std::pair<Point, Point>, int>, active_tail_arbitrary*> > incoming_count; typedef std::vector<std::pair<std::pair<std::pair<Point, Point>, int>, active_tail_arbitrary*> > incoming_count;
...@@ -1227,7 +1227,7 @@ namespace boost { namespace polygon{ ...@@ -1227,7 +1227,7 @@ namespace boost { namespace polygon{
static inline void sort_incoming_count(incoming_count& count, const Point& pt) { static inline void sort_incoming_count(incoming_count& count, const Point& pt) {
less_incoming_count lfec(pt); less_incoming_count lfec(pt);
std::sort(count.begin(), count.end(), lfec); gtlsort(count.begin(), count.end(), lfec);
} }
static inline void compact_vertex_arbitrary_count(const Point& pt, vertex_arbitrary_count &count) { static inline void compact_vertex_arbitrary_count(const Point& pt, vertex_arbitrary_count &count) {
...@@ -1798,7 +1798,7 @@ namespace boost { namespace polygon{ ...@@ -1798,7 +1798,7 @@ namespace boost { namespace polygon{
data.push_back(vertex_half_edge(Point(10, 0), Point(10, 10), -1)); data.push_back(vertex_half_edge(Point(10, 0), Point(10, 10), -1));
data.push_back(vertex_half_edge(Point(10, 10), Point(10, 0), 1)); data.push_back(vertex_half_edge(Point(10, 10), Point(10, 0), 1));
data.push_back(vertex_half_edge(Point(10, 10), Point(0, 10), 1)); data.push_back(vertex_half_edge(Point(10, 10), Point(0, 10), 1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -1822,7 +1822,7 @@ namespace boost { namespace polygon{ ...@@ -1822,7 +1822,7 @@ namespace boost { namespace polygon{
data.push_back(vertex_half_edge(Point(10, 10), Point(10, 20), -1)); data.push_back(vertex_half_edge(Point(10, 10), Point(10, 20), -1));
data.push_back(vertex_half_edge(Point(10, 20), Point(10, 10), 1)); data.push_back(vertex_half_edge(Point(10, 20), Point(10, 10), 1));
data.push_back(vertex_half_edge(Point(10, 20), Point(0, 10), 1)); data.push_back(vertex_half_edge(Point(10, 20), Point(0, 10), 1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -1846,7 +1846,7 @@ namespace boost { namespace polygon{ ...@@ -1846,7 +1846,7 @@ namespace boost { namespace polygon{
data.push_back(vertex_half_edge(Point(2, -4), Point(2, 4), -1)); data.push_back(vertex_half_edge(Point(2, -4), Point(2, 4), -1));
data.push_back(vertex_half_edge(Point(2, 4), Point(-2, 2), 1)); data.push_back(vertex_half_edge(Point(2, 4), Point(-2, 2), 1));
data.push_back(vertex_half_edge(Point(2, 4), Point(2, -4), 1)); data.push_back(vertex_half_edge(Point(2, 4), Point(2, -4), 1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -1892,7 +1892,7 @@ namespace boost { namespace polygon{ ...@@ -1892,7 +1892,7 @@ namespace boost { namespace polygon{
data.push_back(vertex_half_edge(Point(10, 22), Point(10, 12), -1)); data.push_back(vertex_half_edge(Point(10, 22), Point(10, 12), -1));
data.push_back(vertex_half_edge(Point(10, 22), Point(2, 22), -1)); data.push_back(vertex_half_edge(Point(10, 22), Point(2, 22), -1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -1939,7 +1939,7 @@ namespace boost { namespace polygon{ ...@@ -1939,7 +1939,7 @@ namespace boost { namespace polygon{
data.push_back(vertex_half_edge(Point(7, 2), Point(5, 5), -1)); data.push_back(vertex_half_edge(Point(7, 2), Point(5, 5), -1));
data.push_back(vertex_half_edge(Point(7, 2), Point(5, 2), 1)); data.push_back(vertex_half_edge(Point(7, 2), Point(5, 2), 1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -1979,7 +1979,7 @@ namespace boost { namespace polygon{ ...@@ -1979,7 +1979,7 @@ namespace boost { namespace polygon{
data.push_back(vertex_half_edge(Point(7, 2), Point(5, 5), -1)); data.push_back(vertex_half_edge(Point(7, 2), Point(5, 5), -1));
data.push_back(vertex_half_edge(Point(7, 2), Point(4, 1), 1)); data.push_back(vertex_half_edge(Point(7, 2), Point(4, 1), 1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -2019,7 +2019,7 @@ namespace boost { namespace polygon{ ...@@ -2019,7 +2019,7 @@ namespace boost { namespace polygon{
data.push_back(vertex_half_edge(Point(7, 2), Point(5, 5), -1)); data.push_back(vertex_half_edge(Point(7, 2), Point(5, 5), -1));
data.push_back(vertex_half_edge(Point(7, 2), Point(4, 1), 1)); data.push_back(vertex_half_edge(Point(7, 2), Point(4, 1), 1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -2047,7 +2047,7 @@ namespace boost { namespace polygon{ ...@@ -2047,7 +2047,7 @@ namespace boost { namespace polygon{
data.push_back(vertex_half_edge(Point(-1, 4), Point(0, 2), -1)); data.push_back(vertex_half_edge(Point(-1, 4), Point(0, 2), -1));
data.push_back(vertex_half_edge(Point(0, 2), Point(-1, 4), 1)); data.push_back(vertex_half_edge(Point(0, 2), Point(-1, 4), 1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -2753,7 +2753,7 @@ namespace boost { namespace polygon{ ...@@ -2753,7 +2753,7 @@ namespace boost { namespace polygon{
data.push_back(vertex_half_edge(Point(10, 0), Point(10, 10), -1)); data.push_back(vertex_half_edge(Point(10, 0), Point(10, 10), -1));
data.push_back(vertex_half_edge(Point(10, 10), Point(10, 0), 1)); data.push_back(vertex_half_edge(Point(10, 10), Point(10, 0), 1));
data.push_back(vertex_half_edge(Point(10, 10), Point(0, 10), 1)); data.push_back(vertex_half_edge(Point(10, 10), Point(0, 10), 1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -2776,7 +2776,7 @@ namespace boost { namespace polygon{ ...@@ -2776,7 +2776,7 @@ namespace boost { namespace polygon{
data.push_back(vertex_half_edge(Point(10, 10), Point(10, 20), -1)); data.push_back(vertex_half_edge(Point(10, 10), Point(10, 20), -1));
data.push_back(vertex_half_edge(Point(10, 20), Point(10, 10), 1)); data.push_back(vertex_half_edge(Point(10, 20), Point(10, 10), 1));
data.push_back(vertex_half_edge(Point(10, 20), Point(0, 10), 1)); data.push_back(vertex_half_edge(Point(10, 20), Point(0, 10), 1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -2799,7 +2799,7 @@ namespace boost { namespace polygon{ ...@@ -2799,7 +2799,7 @@ namespace boost { namespace polygon{
data.push_back(vertex_half_edge(Point(2, -4), Point(2, 4), -1)); data.push_back(vertex_half_edge(Point(2, -4), Point(2, 4), -1));
data.push_back(vertex_half_edge(Point(2, 4), Point(-2, 2), 1)); data.push_back(vertex_half_edge(Point(2, 4), Point(-2, 2), 1));
data.push_back(vertex_half_edge(Point(2, 4), Point(2, -4), 1)); data.push_back(vertex_half_edge(Point(2, 4), Point(2, -4), 1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -2844,7 +2844,7 @@ namespace boost { namespace polygon{ ...@@ -2844,7 +2844,7 @@ namespace boost { namespace polygon{
data.push_back(vertex_half_edge(Point(10, 22), Point(10, 12), -1)); data.push_back(vertex_half_edge(Point(10, 22), Point(10, 12), -1));
data.push_back(vertex_half_edge(Point(10, 22), Point(2, 22), -1)); data.push_back(vertex_half_edge(Point(10, 22), Point(2, 22), -1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
...@@ -2891,7 +2891,7 @@ namespace boost { namespace polygon{ ...@@ -2891,7 +2891,7 @@ namespace boost { namespace polygon{
data.push_back(vertex_half_edge(Point(7, 2), Point(5, 5), -1)); data.push_back(vertex_half_edge(Point(7, 2), Point(5, 5), -1));
data.push_back(vertex_half_edge(Point(7, 2), Point(5, 2), 1)); data.push_back(vertex_half_edge(Point(7, 2), Point(5, 2), 1));
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(polys, data.begin(), data.end()); pf.scan(polys, data.begin(), data.end());
stdcout << "result size: " << polys.size() << std::endl; stdcout << "result size: " << polys.size() << std::endl;
for(std::size_t i = 0; i < polys.size(); ++i) { for(std::size_t i = 0; i < polys.size(); ++i) {
......
...@@ -112,7 +112,7 @@ public: ...@@ -112,7 +112,7 @@ public:
inline void perform_merge(result_type& result, property_merge_data& data) { inline void perform_merge(result_type& result, property_merge_data& data) {
if(data.empty()) return; if(data.empty()) return;
//sort //sort
std::sort(data.begin(), data.end(), less_vertex_data<vertex_property>()); gtlsort(data.begin(), data.end(), less_vertex_data<vertex_property>());
//scanline //scanline
bool firstIteration = true; bool firstIteration = true;
scanlinePosition = scanline.end(); scanlinePosition = scanline.end();
...@@ -156,7 +156,7 @@ private: ...@@ -156,7 +156,7 @@ private:
class less_vertex_data { class less_vertex_data {
public: public:
less_vertex_data() {} less_vertex_data() {}
bool operator()(const T& lvalue, const T& rvalue) { bool operator()(const T& lvalue, const T& rvalue) const {
if(lvalue.first.x() < rvalue.first.x()) return true; if(lvalue.first.x() < rvalue.first.x()) return true;
if(lvalue.first.x() > rvalue.first.x()) return false; if(lvalue.first.x() > rvalue.first.x()) return false;
if(lvalue.first.y() < rvalue.first.y()) return true; if(lvalue.first.y() < rvalue.first.y()) return true;
...@@ -442,7 +442,7 @@ private: ...@@ -442,7 +442,7 @@ private:
inline void performExtract(T& result, property_merge_data& data) { inline void performExtract(T& result, property_merge_data& data) {
if(data.empty()) return; if(data.empty()) return;
//sort //sort
std::sort(data.begin(), data.end(), less_vertex_data<vertex_property>()); gtlsort(data.begin(), data.end(), less_vertex_data<vertex_property>());
//scanline //scanline
bool firstIteration = true; bool firstIteration = true;
......
...@@ -111,7 +111,7 @@ namespace boost { namespace polygon{ ...@@ -111,7 +111,7 @@ namespace boost { namespace polygon{
template <typename output_type> template <typename output_type>
static void performMerge(output_type& result, MergeSetData& tsd) { static void performMerge(output_type& result, MergeSetData& tsd) {
std::sort(tsd.begin(), tsd.end(), lessVertex45Compact()); gtlsort(tsd.begin(), tsd.end(), lessVertex45Compact());
typedef std::vector<std::pair<Point, typename boolean_op_45<Unit>::template Scan45CountT<CountMerge> > > TSD; typedef std::vector<std::pair<Point, typename boolean_op_45<Unit>::template Scan45CountT<CountMerge> > > TSD;
TSD tsd_; TSD tsd_;
tsd_.reserve(tsd.size()); tsd_.reserve(tsd.size());
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#ifdef BOOST_POLYGON_DEBUG_FILE #ifdef BOOST_POLYGON_DEBUG_FILE
#include <fstream> #include <fstream>
#endif #endif
#include "polygon_sort_adaptor.hpp"
namespace boost { namespace polygon{ namespace boost { namespace polygon{
template <typename Unit> template <typename Unit>
...@@ -75,7 +76,7 @@ namespace boost { namespace polygon{ ...@@ -75,7 +76,7 @@ namespace boost { namespace polygon{
ends.push_back(std::make_pair((*itr).first.first.y(), count)); ends.push_back(std::make_pair((*itr).first.first.y(), count));
ends.push_back(std::make_pair((*itr).first.second.y(), -count)); ends.push_back(std::make_pair((*itr).first.second.y(), -count));
} }
std::sort(ends.begin(), ends.end()); gtlsort(ends.begin(), ends.end());
histogram.reserve(ends.size()); histogram.reserve(ends.size());
histogram.push_back(std::make_pair(ends.front().first, std::make_pair(0, 0))); histogram.push_back(std::make_pair(ends.front().first, std::make_pair(0, 0)));
for(typename std::vector<std::pair<Unit, int> >::iterator itr = ends.begin(); itr != ends.end(); ++itr) { for(typename std::vector<std::pair<Unit, int> >::iterator itr = ends.begin(); itr != ends.end(); ++itr) {
...@@ -160,7 +161,7 @@ namespace boost { namespace polygon{ ...@@ -160,7 +161,7 @@ namespace boost { namespace polygon{
} }
} }
typename scanline_base<Unit>::compute_intersection_pack pack_; typename scanline_base<Unit>::compute_intersection_pack pack_;
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
//find all intersection points //find all intersection points
for(typename std::vector<std::pair<half_edge, segment_id> >::iterator outer = data.begin(); for(typename std::vector<std::pair<half_edge, segment_id> >::iterator outer = data.begin();
outer != data.end(); ++outer) { outer != data.end(); ++outer) {
...@@ -195,7 +196,7 @@ namespace boost { namespace polygon{ ...@@ -195,7 +196,7 @@ namespace boost { namespace polygon{
} }
} }
} }
std::sort(pts.begin(), pts.end()); gtlsort(pts.begin(), pts.end());
typename std::vector<Point>::iterator newend = std::unique(pts.begin(), pts.end()); typename std::vector<Point>::iterator newend = std::unique(pts.begin(), pts.end());
typename std::vector<Point>::iterator lfinger = pts.begin(); typename std::vector<Point>::iterator lfinger = pts.begin();
//find all segments that interact with intersection points //find all segments that interact with intersection points
...@@ -286,7 +287,7 @@ namespace boost { namespace polygon{ ...@@ -286,7 +287,7 @@ namespace boost { namespace polygon{
std::swap(data[i].first.first, data[i].first.second); std::swap(data[i].first.first, data[i].first.second);
} }
} }
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
for(typename std::vector<std::pair<half_edge, segment_id> >::iterator outer = data.begin(); for(typename std::vector<std::pair<half_edge, segment_id> >::iterator outer = data.begin();
outer != data.end(); ++outer) { outer != data.end(); ++outer) {
const half_edge& he1 = (*outer).first; const half_edge& he1 = (*outer).first;
...@@ -356,7 +357,7 @@ namespace boost { namespace polygon{ ...@@ -356,7 +357,7 @@ namespace boost { namespace polygon{
tmpPts.reserve(pts.size()); tmpPts.reserve(pts.size());
tmpPts.insert(tmpPts.end(), pts.begin(), pts.end()); tmpPts.insert(tmpPts.end(), pts.begin(), pts.end());
less_point_down_slope lpds; less_point_down_slope lpds;
std::sort(tmpPts.begin(), tmpPts.end(), lpds); gtlsort(tmpPts.begin(), tmpPts.end(), lpds);
segment_edge(output_segments, he, id, tmpPts.begin(), tmpPts.end()); segment_edge(output_segments, he, id, tmpPts.begin(), tmpPts.end());
} else { } else {
segment_edge(output_segments, he, id, pts.begin(), pts.end()); segment_edge(output_segments, he, id, pts.begin(), pts.end());
...@@ -498,7 +499,7 @@ namespace boost { namespace polygon{ ...@@ -498,7 +499,7 @@ namespace boost { namespace polygon{
// } // }
// //merge sloping element data // //merge sloping element data
// std::sort(sloping_ends.begin(), sloping_ends.end()); // gtlsort(sloping_ends.begin(), sloping_ends.end());
// std::map<Unit, std::set<iterator> > sloping_elements; // std::map<Unit, std::set<iterator> > sloping_elements;
// std::set<iterator> merge_elements; // std::set<iterator> merge_elements;
// for(typename std::vector<std::pair<Unit, iterator> >::iterator slop_iter = sloping_ends.begin(); // for(typename std::vector<std::pair<Unit, iterator> >::iterator slop_iter = sloping_ends.begin();
...@@ -1310,7 +1311,7 @@ namespace boost { namespace polygon{ ...@@ -1310,7 +1311,7 @@ namespace boost { namespace polygon{
output.push_back(vertex_half_edge(he.first, he.second, count)); output.push_back(vertex_half_edge(he.first, he.second, count));
output.push_back(vertex_half_edge(he.second, he.first, -count)); output.push_back(vertex_half_edge(he.second, he.first, -count));
} }
std::sort(output.begin(), output.end()); gtlsort(output.begin(), output.end());
} }
class test_functor { class test_functor {
...@@ -1514,7 +1515,7 @@ namespace boost { namespace polygon{ ...@@ -1514,7 +1515,7 @@ namespace boost { namespace polygon{
public: public:
less_vertex_data() : pack_() {} less_vertex_data() : pack_() {}
less_vertex_data(typename scanline_base<Unit>::evalAtXforYPack* pack) : pack_(pack) {} less_vertex_data(typename scanline_base<Unit>::evalAtXforYPack* pack) : pack_(pack) {}
bool operator()(const vertex_data_type& lvalue, const vertex_data_type& rvalue) { bool operator() (const vertex_data_type& lvalue, const vertex_data_type& rvalue) const {
less_point lp; less_point lp;
if(lp(lvalue.first.first, rvalue.first.first)) return true; if(lp(lvalue.first.first, rvalue.first.first)) return true;
if(lp(rvalue.first.first, lvalue.first.first)) return false; if(lp(rvalue.first.first, lvalue.first.first)) return false;
...@@ -1528,7 +1529,7 @@ namespace boost { namespace polygon{ ...@@ -1528,7 +1529,7 @@ namespace boost { namespace polygon{
inline void sort_property_merge_data() { inline void sort_property_merge_data() {
less_vertex_data<vertex_property> lvd(&evalAtXforYPack_); less_vertex_data<vertex_property> lvd(&evalAtXforYPack_);
std::sort(pmd.begin(), pmd.end(), lvd); gtlsort(pmd.begin(), pmd.end(), lvd);
} }
public: public:
inline property_merge_data& get_property_merge_data() { return pmd; } inline property_merge_data& get_property_merge_data() { return pmd; }
...@@ -1573,7 +1574,7 @@ namespace boost { namespace polygon{ ...@@ -1573,7 +1574,7 @@ namespace boost { namespace polygon{
pts.push_back(lines[i].first.first); pts.push_back(lines[i].first.first);
pts.push_back(lines[i].first.second); pts.push_back(lines[i].first.second);
} }
std::sort(pts.begin(), pts.end()); gtlsort(pts.begin(), pts.end());
for(std::size_t i = 0; i < pts.size(); i+=2) { for(std::size_t i = 0; i < pts.size(); i+=2) {
if(pts[i] != pts[i+1]) { if(pts[i] != pts[i+1]) {
//stdcout << "Non-closed figures after line intersection!\n"; //stdcout << "Non-closed figures after line intersection!\n";
...@@ -1683,7 +1684,7 @@ namespace boost { namespace polygon{ ...@@ -1683,7 +1684,7 @@ namespace boost { namespace polygon{
static inline void sort_vertex_half_edges(vertex_data& vertex) { static inline void sort_vertex_half_edges(vertex_data& vertex) {
less_half_edge_pair lessF(vertex.first); less_half_edge_pair lessF(vertex.first);
std::sort(vertex.second.begin(), vertex.second.end(), lessF); gtlsort(vertex.second.begin(), vertex.second.end(), lessF);
} }
class less_half_edge_pair { class less_half_edge_pair {
...@@ -2165,7 +2166,7 @@ pts.push_back(Point(12344171, 6695983 )); pts.push_back(Point(12287208, 6672388 ...@@ -2165,7 +2166,7 @@ pts.push_back(Point(12344171, 6695983 )); pts.push_back(Point(12287208, 6672388
outpts.push_back((*itr).first.first); outpts.push_back((*itr).first.first);
outpts.push_back((*itr).first.second); outpts.push_back((*itr).first.second);
} }
std::sort(outpts.begin(), outpts.end()); gtlsort(outpts.begin(), outpts.end());
for(std::size_t i = 0; i < outpts.size(); i+=2) { for(std::size_t i = 0; i < outpts.size(); i+=2) {
if(outpts[i] != outpts[i+1]) { if(outpts[i] != outpts[i+1]) {
stdcout << "Polygon set not a closed figure\n"; stdcout << "Polygon set not a closed figure\n";
...@@ -2514,7 +2515,7 @@ pts.push_back(Point(12344171, 6695983 )); pts.push_back(Point(12287208, 6672388 ...@@ -2514,7 +2515,7 @@ pts.push_back(Point(12344171, 6695983 )); pts.push_back(Point(12287208, 6672388
public: public:
less_vertex_data() : pack_() {} less_vertex_data() : pack_() {}
less_vertex_data(typename scanline_base<Unit>::evalAtXforYPack* pack) : pack_(pack) {} less_vertex_data(typename scanline_base<Unit>::evalAtXforYPack* pack) : pack_(pack) {}
bool operator()(const vertex_data_type& lvalue, const vertex_data_type& rvalue) { bool operator()(const vertex_data_type& lvalue, const vertex_data_type& rvalue) const {
less_point lp; less_point lp;
if(lp(lvalue.first.first, rvalue.first.first)) return true; if(lp(lvalue.first.first, rvalue.first.first)) return true;
if(lp(rvalue.first.first, lvalue.first.first)) return false; if(lp(rvalue.first.first, lvalue.first.first)) return false;
...@@ -2580,7 +2581,7 @@ pts.push_back(Point(12344171, 6695983 )); pts.push_back(Point(12287208, 6672388 ...@@ -2580,7 +2581,7 @@ pts.push_back(Point(12344171, 6695983 )); pts.push_back(Point(12287208, 6672388
inline void sort_property_merge_data() { inline void sort_property_merge_data() {
less_vertex_data<vertex_property> lvd(&evalAtXforYPack_); less_vertex_data<vertex_property> lvd(&evalAtXforYPack_);
std::sort(pmd.begin(), pmd.end(), lvd); gtlsort(pmd.begin(), pmd.end(), lvd);
} }
public: public:
inline arbitrary_boolean_op() : pmd(), evalAtXforYPack_() {} inline arbitrary_boolean_op() : pmd(), evalAtXforYPack_() {}
...@@ -2732,7 +2733,7 @@ pts.push_back(Point(12344171, 6695983 )); pts.push_back(Point(12287208, 6672388 ...@@ -2732,7 +2733,7 @@ pts.push_back(Point(12344171, 6695983 )); pts.push_back(Point(12287208, 6672388
public: public:
less_vertex_data() : pack_() {} less_vertex_data() : pack_() {}
less_vertex_data(typename scanline_base<Unit>::evalAtXforYPack* pack) : pack_(pack) {} less_vertex_data(typename scanline_base<Unit>::evalAtXforYPack* pack) : pack_(pack) {}
bool operator()(const vertex_data_type& lvalue, const vertex_data_type& rvalue) { bool operator()(const vertex_data_type& lvalue, const vertex_data_type& rvalue) const {
less_point lp; less_point lp;
if(lp(lvalue.first.first, rvalue.first.first)) return true; if(lp(lvalue.first.first, rvalue.first.first)) return true;
if(lp(rvalue.first.first, lvalue.first.first)) return false; if(lp(rvalue.first.first, lvalue.first.first)) return false;
...@@ -2804,7 +2805,7 @@ pts.push_back(Point(12344171, 6695983 )); pts.push_back(Point(12287208, 6672388 ...@@ -2804,7 +2805,7 @@ pts.push_back(Point(12344171, 6695983 )); pts.push_back(Point(12287208, 6672388
inline void sort_property_merge_data() { inline void sort_property_merge_data() {
less_vertex_data<vertex_property> lvd(&evalAtXforYPack_); less_vertex_data<vertex_property> lvd(&evalAtXforYPack_);
std::sort(pmd.begin(), pmd.end(), lvd); gtlsort(pmd.begin(), pmd.end(), lvd);
} }
public: public:
inline arbitrary_connectivity_extraction() : pmd(), evalAtXforYPack_() {} inline arbitrary_connectivity_extraction() : pmd(), evalAtXforYPack_() {}
......
...@@ -471,7 +471,7 @@ namespace boost { namespace polygon{ ...@@ -471,7 +471,7 @@ namespace boost { namespace polygon{
typedef typename interval_traits<interval_type>::coordinate_type Unit; typedef typename interval_traits<interval_type>::coordinate_type Unit;
Unit coords[4] = {low(interval), high(interval), low(b), high(b)}; Unit coords[4] = {low(interval), high(interval), low(b), high(b)};
//consider implementing faster sorting of small fixed length range //consider implementing faster sorting of small fixed length range
std::sort(coords, coords+4); gtlsort(coords, coords+4);
low(interval, coords[1]); low(interval, coords[1]);
high(interval, coords[2]); high(interval, coords[2]);
return interval; return interval;
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
*/ */
#ifndef BOOST_POLYGON_POLYGON_HPP #ifndef BOOST_POLYGON_POLYGON_HPP
#define BOOST_POLYGON_POLYGON_HPP #define BOOST_POLYGON_POLYGON_HPP
#define BOOST_POLYGON_VERSION 014401
#include "isotropy.hpp" #include "isotropy.hpp"
......
...@@ -212,7 +212,7 @@ namespace boost { namespace polygon{ ...@@ -212,7 +212,7 @@ namespace boost { namespace polygon{
void sort() const{ void sort() const{
if(unsorted_) { if(unsorted_) {
std::sort(data_.begin(), data_.end()); gtlsort(data_.begin(), data_.end());
unsorted_ = false; unsorted_ = false;
} }
} }
...@@ -1262,7 +1262,7 @@ namespace boost { namespace polygon{ ...@@ -1262,7 +1262,7 @@ namespace boost { namespace polygon{
//std::cout << "SCAN " << currentX << "\n"; //std::cout << "SCAN " << currentX << "\n";
//scan event //scan event
scan45.scan(eventOut, eventIn.begin(), eventIn.end()); scan45.scan(eventOut, eventIn.begin(), eventIn.end());
std::sort(eventOut.begin(), eventOut.end()); gtlsort(eventOut.begin(), eventOut.end());
std::size_t ptCount = 0; std::size_t ptCount = 0;
for(std::size_t i = 0; i < eventOut.size(); ++i) { for(std::size_t i = 0; i < eventOut.size(); ++i) {
if(!result_data.empty() && if(!result_data.empty() &&
...@@ -1333,7 +1333,7 @@ namespace boost { namespace polygon{ ...@@ -1333,7 +1333,7 @@ namespace boost { namespace polygon{
} }
} }
scan45.scan(eventOut, eventIn.begin(), eventIn.end()); scan45.scan(eventOut, eventIn.begin(), eventIn.end());
std::sort(eventOut.begin(), eventOut.end()); gtlsort(eventOut.begin(), eventOut.end());
std::size_t ptCount = 0; std::size_t ptCount = 0;
for(std::size_t i = 0; i < eventOut.size(); ++i) { for(std::size_t i = 0; i < eventOut.size(); ++i) {
...@@ -1385,7 +1385,7 @@ namespace boost { namespace polygon{ ...@@ -1385,7 +1385,7 @@ namespace boost { namespace polygon{
//std::cout << "SCAN " << currentX << "\n"; //std::cout << "SCAN " << currentX << "\n";
//scan event //scan event
scan45.scan(eventOut, eventIn.begin(), eventIn.end()); scan45.scan(eventOut, eventIn.begin(), eventIn.end());
std::sort(eventOut.begin(), eventOut.end()); gtlsort(eventOut.begin(), eventOut.end());
std::size_t ptCount = 0; std::size_t ptCount = 0;
for(std::size_t i = 0; i < eventOut.size(); ++i) { for(std::size_t i = 0; i < eventOut.size(); ++i) {
if(!result_data.empty() && if(!result_data.empty() &&
...@@ -1422,7 +1422,7 @@ namespace boost { namespace polygon{ ...@@ -1422,7 +1422,7 @@ namespace boost { namespace polygon{
++iter1; ++iter1;
} }
scan45.scan(eventOut, eventIn.begin(), eventIn.end()); scan45.scan(eventOut, eventIn.begin(), eventIn.end());
std::sort(eventOut.begin(), eventOut.end()); gtlsort(eventOut.begin(), eventOut.end());
std::size_t ptCount = 0; std::size_t ptCount = 0;
for(std::size_t i = 0; i < eventOut.size(); ++i) { for(std::size_t i = 0; i < eventOut.size(); ++i) {
...@@ -1639,7 +1639,7 @@ namespace boost { namespace polygon{ ...@@ -1639,7 +1639,7 @@ namespace boost { namespace polygon{
result.error_data_.push_back(ci); result.error_data_.push_back(ci);
} }
Data2 new_result_data; Data2 new_result_data;
std::sort(result_data.begin(), result_data.end()); gtlsort(result_data.begin(), result_data.end());
applyUnary45OpOnVectors<Unit2, 0>(new_result_data, result_data); //OR operation applyUnary45OpOnVectors<Unit2, 0>(new_result_data, result_data); //OR operation
result_data.swap(new_result_data); result_data.swap(new_result_data);
} }
...@@ -1749,7 +1749,7 @@ namespace boost { namespace polygon{ ...@@ -1749,7 +1749,7 @@ namespace boost { namespace polygon{
result.error_data_.push_back(ci); result.error_data_.push_back(ci);
} }
Data2 new_result_data; Data2 new_result_data;
std::sort(result_data.begin(), result_data.end()); gtlsort(result_data.begin(), result_data.end());
applyUnary45OpOnVectors<Unit2, 0>(new_result_data, result_data); //OR operation applyUnary45OpOnVectors<Unit2, 0>(new_result_data, result_data); //OR operation
result_data.swap(new_result_data); result_data.swap(new_result_data);
} }
......
...@@ -286,7 +286,7 @@ namespace boost { namespace polygon{ ...@@ -286,7 +286,7 @@ namespace boost { namespace polygon{
void sort() const{ void sort() const{
if(unsorted_) { if(unsorted_) {
std::sort(data_.begin(), data_.end()); gtlsort(data_.begin(), data_.end());
unsorted_ = false; unsorted_ = false;
} }
} }
......
/* /*
Copyright 2008 Intel Corporation Copyright 2008 Intel Corporation
Use, modification and distribution are subject to the Boost Software License, Use, modification and distribution are subject to the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt). http://www.boost.org/LICENSE_1_0.txt).
...@@ -22,7 +22,7 @@ namespace boost { namespace polygon { ...@@ -22,7 +22,7 @@ namespace boost { namespace polygon {
template <typename T> template <typename T>
static inline T round_down(double val) { static inline T round_down(double val) {
T rounded_val = (T)(val); T rounded_val = (T)(val);
if(val < (double)rounded_val) if(val < (double)rounded_val)
--rounded_val; --rounded_val;
return rounded_val; return rounded_val;
} }
...@@ -57,11 +57,11 @@ namespace boost { namespace polygon { ...@@ -57,11 +57,11 @@ namespace boost { namespace polygon {
} }
// copy constructor // copy constructor
inline polygon_set_data(const polygon_set_data& that) : inline polygon_set_data(const polygon_set_data& that) :
data_(that.data_), dirty_(that.dirty_), unsorted_(that.unsorted_), is_45_(that.is_45_) {} data_(that.data_), dirty_(that.dirty_), unsorted_(that.unsorted_), is_45_(that.is_45_) {}
// copy constructor // copy constructor
template <typename ltype, typename rtype, int op_type> template <typename ltype, typename rtype, int op_type>
inline polygon_set_data(const polygon_set_view<ltype, rtype, op_type>& that); inline polygon_set_data(const polygon_set_view<ltype, rtype, op_type>& that);
// destructor // destructor
...@@ -150,10 +150,10 @@ namespace boost { namespace polygon { ...@@ -150,10 +150,10 @@ namespace boost { namespace polygon {
insert(polygon_object, is_hole, polygon_concept()); } insert(polygon_object, is_hole, polygon_concept()); }
template <typename polygon_with_holes_type> template <typename polygon_with_holes_type>
inline void insert(const polygon_with_holes_type& polygon_with_holes_object, bool is_hole, inline void insert(const polygon_with_holes_type& polygon_with_holes_object, bool is_hole,
polygon_with_holes_concept ) { polygon_with_holes_concept ) {
insert(polygon_with_holes_object, is_hole, polygon_concept()); insert(polygon_with_holes_object, is_hole, polygon_concept());
for(typename polygon_with_holes_traits<polygon_with_holes_type>::iterator_holes_type itr = for(typename polygon_with_holes_traits<polygon_with_holes_type>::iterator_holes_type itr =
begin_holes(polygon_with_holes_object); begin_holes(polygon_with_holes_object);
itr != end_holes(polygon_with_holes_object); ++itr) { itr != end_holes(polygon_with_holes_object); ++itr) {
insert(*itr, !is_hole, polygon_concept()); insert(*itr, !is_hole, polygon_concept());
...@@ -161,12 +161,12 @@ namespace boost { namespace polygon { ...@@ -161,12 +161,12 @@ namespace boost { namespace polygon {
} }
template <typename polygon_with_holes_type> template <typename polygon_with_holes_type>
inline void insert(const polygon_with_holes_type& polygon_with_holes_object, bool is_hole, inline void insert(const polygon_with_holes_type& polygon_with_holes_object, bool is_hole,
polygon_45_with_holes_concept ) { polygon_45_with_holes_concept ) {
insert(polygon_with_holes_object, is_hole, polygon_with_holes_concept()); } insert(polygon_with_holes_object, is_hole, polygon_with_holes_concept()); }
template <typename polygon_with_holes_type> template <typename polygon_with_holes_type>
inline void insert(const polygon_with_holes_type& polygon_with_holes_object, bool is_hole, inline void insert(const polygon_with_holes_type& polygon_with_holes_object, bool is_hole,
polygon_90_with_holes_concept ) { polygon_90_with_holes_concept ) {
insert(polygon_with_holes_object, is_hole, polygon_with_holes_concept()); } insert(polygon_with_holes_object, is_hole, polygon_with_holes_concept()); }
...@@ -212,7 +212,7 @@ namespace boost { namespace polygon { ...@@ -212,7 +212,7 @@ namespace boost { namespace polygon {
first_point = previous_point = current_point; first_point = previous_point = current_point;
} else { } else {
if(previous_point != current_point) { if(previous_point != current_point) {
element_type elem(edge_type(previous_point, current_point), element_type elem(edge_type(previous_point, current_point),
( previous_point.get(HORIZONTAL) == current_point.get(HORIZONTAL) ? -1 : 1) * multiplier); ( previous_point.get(HORIZONTAL) == current_point.get(HORIZONTAL) ? -1 : 1) * multiplier);
insert_clean(elem); insert_clean(elem);
} }
...@@ -222,7 +222,7 @@ namespace boost { namespace polygon { ...@@ -222,7 +222,7 @@ namespace boost { namespace polygon {
current_point = first_point; current_point = first_point;
if(!first_iteration) { if(!first_iteration) {
if(previous_point != current_point) { if(previous_point != current_point) {
element_type elem(edge_type(previous_point, current_point), element_type elem(edge_type(previous_point, current_point),
( previous_point.get(HORIZONTAL) == current_point.get(HORIZONTAL) ? -1 : 1) * multiplier); ( previous_point.get(HORIZONTAL) == current_point.get(HORIZONTAL) ? -1 : 1) * multiplier);
insert_clean(elem); insert_clean(elem);
} }
...@@ -248,7 +248,7 @@ namespace boost { namespace polygon { ...@@ -248,7 +248,7 @@ namespace boost { namespace polygon {
data.push_back(vertex_half_edge((*itr).first.first, (*itr).first.second, (*itr).second)); data.push_back(vertex_half_edge((*itr).first.first, (*itr).first.second, (*itr).second));
data.push_back(vertex_half_edge((*itr).first.second, (*itr).first.first, -1 * (*itr).second)); data.push_back(vertex_half_edge((*itr).first.second, (*itr).first.first, -1 * (*itr).second));
} }
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(container, data.begin(), data.end()); pf.scan(container, data.begin(), data.end());
//std::cout << "DONE FORMING POLYGONS\n"; //std::cout << "DONE FORMING POLYGONS\n";
} }
...@@ -270,14 +270,14 @@ namespace boost { namespace polygon { ...@@ -270,14 +270,14 @@ namespace boost { namespace polygon {
} }
} }
// equivalence operator // equivalence operator
inline bool operator==(const polygon_set_data& p) const { inline bool operator==(const polygon_set_data& p) const {
clean(); clean();
p.clean(); p.clean();
return data_ == p.data_; return data_ == p.data_;
} }
// inequivalence operator // inequivalence operator
inline bool operator!=(const polygon_set_data& p) const { inline bool operator!=(const polygon_set_data& p) const {
return !((*this) == p); return !((*this) == p);
} }
...@@ -321,7 +321,7 @@ namespace boost { namespace polygon { ...@@ -321,7 +321,7 @@ namespace boost { namespace polygon {
void sort() const{ void sort() const{
if(unsorted_) { if(unsorted_) {
std::sort(data_.begin(), data_.end()); gtlsort(data_.begin(), data_.end());
unsorted_ = false; unsorted_ = false;
} }
} }
...@@ -335,7 +335,7 @@ namespace boost { namespace polygon { ...@@ -335,7 +335,7 @@ namespace boost { namespace polygon {
} }
void set(const value_type& value) { void set(const value_type& value) {
data_ = value; data_ = value;
dirty_ = true; dirty_ = true;
unsorted_ = true; unsorted_ = true;
} }
...@@ -364,7 +364,7 @@ namespace boost { namespace polygon { ...@@ -364,7 +364,7 @@ namespace boost { namespace polygon {
if(resizing < 0) if(resizing < 0)
return shrink(-resizing); return shrink(-resizing);
if(resizing > 0) if(resizing > 0)
return bloat(-resizing); return bloat(resizing);
return *this; return *this;
} }
if(resizing == 0) return *this; if(resizing == 0) return *this;
...@@ -379,7 +379,7 @@ namespace boost { namespace polygon { ...@@ -379,7 +379,7 @@ namespace boost { namespace polygon {
} }
template <typename transform_type> template <typename transform_type>
inline polygon_set_data& inline polygon_set_data&
transform(const transform_type& tr) { transform(const transform_type& tr) {
std::vector<polygon_with_holes_data<T> > polys; std::vector<polygon_with_holes_data<T> > polys;
get(polys); get(polys);
...@@ -393,7 +393,7 @@ namespace boost { namespace polygon { ...@@ -393,7 +393,7 @@ namespace boost { namespace polygon {
return *this; return *this;
} }
inline polygon_set_data& inline polygon_set_data&
scale_up(typename coordinate_traits<coordinate_type>::unsigned_area_type factor) { scale_up(typename coordinate_traits<coordinate_type>::unsigned_area_type factor) {
for(typename value_type::iterator itr = data_.begin(); itr != data_.end(); ++itr) { for(typename value_type::iterator itr = data_.begin(); itr != data_.end(); ++itr) {
::boost::polygon::scale_up((*itr).first.first, factor); ::boost::polygon::scale_up((*itr).first.first, factor);
...@@ -401,8 +401,8 @@ namespace boost { namespace polygon { ...@@ -401,8 +401,8 @@ namespace boost { namespace polygon {
} }
return *this; return *this;
} }
inline polygon_set_data& inline polygon_set_data&
scale_down(typename coordinate_traits<coordinate_type>::unsigned_area_type factor) { scale_down(typename coordinate_traits<coordinate_type>::unsigned_area_type factor) {
for(typename value_type::iterator itr = data_.begin(); itr != data_.end(); ++itr) { for(typename value_type::iterator itr = data_.begin(); itr != data_.end(); ++itr) {
::boost::polygon::scale_down((*itr).first.first, factor); ::boost::polygon::scale_down((*itr).first.first, factor);
...@@ -412,9 +412,9 @@ namespace boost { namespace polygon { ...@@ -412,9 +412,9 @@ namespace boost { namespace polygon {
dirty_ = true; dirty_ = true;
return *this; return *this;
} }
template <typename scaling_type> template <typename scaling_type>
inline polygon_set_data& scale(polygon_set_data& polygon_set, inline polygon_set_data& scale(polygon_set_data& polygon_set,
const scaling_type& scaling) { const scaling_type& scaling) {
for(typename value_type::iterator itr = begin(); itr != end(); ++itr) { for(typename value_type::iterator itr = begin(); itr != end(); ++itr) {
::boost::polygon::scale((*itr).first.first, scaling); ::boost::polygon::scale((*itr).first.first, scaling);
...@@ -425,7 +425,7 @@ namespace boost { namespace polygon { ...@@ -425,7 +425,7 @@ namespace boost { namespace polygon {
return *this; return *this;
} }
static inline void compute_offset_edge(point_data<coordinate_type>& pt1, point_data<coordinate_type>& pt2, static inline void compute_offset_edge(point_data<coordinate_type>& pt1, point_data<coordinate_type>& pt2,
const point_data<coordinate_type>& prev_pt, const point_data<coordinate_type>& prev_pt,
const point_data<coordinate_type>& current_pt, const point_data<coordinate_type>& current_pt,
coordinate_type distance, int multiplier) { coordinate_type distance, int multiplier) {
...@@ -566,8 +566,8 @@ namespace boost { namespace polygon { ...@@ -566,8 +566,8 @@ namespace boost { namespace polygon {
} }
template <typename geometry_type> template <typename geometry_type>
inline polygon_set_data& inline polygon_set_data&
insert_with_resize_dispatch(const geometry_type& poly, coordinate_type resizing, bool corner_fill_arc, unsigned int num_circle_segments, bool hole, insert_with_resize_dispatch(const geometry_type& poly, coordinate_type resizing, bool corner_fill_arc, unsigned int num_circle_segments, bool hole,
polygon_with_holes_concept tag) { polygon_with_holes_concept tag) {
insert_with_resize_dispatch(poly, resizing, corner_fill_arc, num_circle_segments, hole, polygon_concept()); insert_with_resize_dispatch(poly, resizing, corner_fill_arc, num_circle_segments, hole, polygon_concept());
for(typename polygon_with_holes_traits<geometry_type>::iterator_holes_type itr = for(typename polygon_with_holes_traits<geometry_type>::iterator_holes_type itr =
...@@ -579,14 +579,14 @@ namespace boost { namespace polygon { ...@@ -579,14 +579,14 @@ namespace boost { namespace polygon {
} }
template <typename geometry_type> template <typename geometry_type>
inline polygon_set_data& inline polygon_set_data&
insert_with_resize_dispatch(const geometry_type& poly, coordinate_type resizing, bool corner_fill_arc, unsigned int num_circle_segments, bool hole, insert_with_resize_dispatch(const geometry_type& poly, coordinate_type resizing, bool corner_fill_arc, unsigned int num_circle_segments, bool hole,
polygon_concept tag) { polygon_concept tag) {
if (resizing==0) if (resizing==0)
return *this; return *this;
// one dimensional used to store CCW/CW flag // one dimensional used to store CCW/CW flag
//direction_1d wdir = winding(poly); //direction_1d wdir = winding(poly);
// LOW==CLOCKWISE just faster to type // LOW==CLOCKWISE just faster to type
...@@ -631,7 +631,7 @@ namespace boost { namespace polygon { ...@@ -631,7 +631,7 @@ namespace boost { namespace polygon {
point_data<coordinate_type> normal2( third->y()-second->y(), second->x()-third->x()); point_data<coordinate_type> normal2( third->y()-second->y(), second->x()-third->x());
double direction = normal1.x()*normal2.y()- normal2.x()*normal1.y(); double direction = normal1.x()*normal2.y()- normal2.x()*normal1.y();
bool convex = direction>0; bool convex = direction>0;
bool treat_as_concave = !convex; bool treat_as_concave = !convex;
if(sizing_sign) if(sizing_sign)
treat_as_concave = convex; treat_as_concave = convex;
...@@ -644,12 +644,12 @@ namespace boost { namespace polygon { ...@@ -644,12 +644,12 @@ namespace boost { namespace polygon {
if (prev_concave) if (prev_concave)
//TODO missing round_down() //TODO missing round_down()
curr_prev = point_data<T>(first->x()+v.x(),first->y()+v.y()); curr_prev = point_data<T>(first->x()+v.x(),first->y()+v.y());
else else
curr_prev = prev_point; curr_prev = prev_point;
// around concave corners - insert rectangle // around concave corners - insert rectangle
// if previous corner is concave it's point info may be ignored // if previous corner is concave it's point info may be ignored
if ( treat_as_concave) { if ( treat_as_concave) {
std::vector<point_data<T> > pts; std::vector<point_data<T> > pts;
pts.push_back(point_data<T>(second->x()+v.x(),second->y()+v.y())); pts.push_back(point_data<T>(second->x()+v.x(),second->y()+v.y()));
...@@ -670,13 +670,13 @@ namespace boost { namespace polygon { ...@@ -670,13 +670,13 @@ namespace boost { namespace polygon {
direction_1d winding; direction_1d winding;
winding = convex?COUNTERCLOCKWISE:CLOCKWISE; winding = convex?COUNTERCLOCKWISE:CLOCKWISE;
if (make_resizing_vertex_list(pts, curr_prev, prev_concave, *first, *second, *third, resizing if (make_resizing_vertex_list(pts, curr_prev, prev_concave, *first, *second, *third, resizing
, num_circle_segments, corner_fill_arc)) , num_circle_segments, corner_fill_arc))
{ {
if (first_pts.size()) { if (first_pts.size()) {
for (unsigned int i=0; i<pts.size(); i++) { for (unsigned int i=0; i<pts.size(); i++) {
sizingSet.insert_vertex_sequence(pts[i].begin(),pts[i].end(),winding,false); sizingSet.insert_vertex_sequence(pts[i].begin(),pts[i].end(),winding,false);
} }
} else { } else {
first_pts = pts[0]; first_pts = pts[0];
first_wdir = resize_wdir; first_wdir = resize_wdir;
...@@ -685,7 +685,7 @@ namespace boost { namespace polygon { ...@@ -685,7 +685,7 @@ namespace boost { namespace polygon {
} }
} }
prev_point = curr_prev; prev_point = curr_prev;
} else { } else {
treat_as_concave = true; treat_as_concave = true;
} }
...@@ -708,7 +708,7 @@ namespace boost { namespace polygon { ...@@ -708,7 +708,7 @@ namespace boost { namespace polygon {
first_pts[first_pts.size()-1]=prev_point; first_pts[first_pts.size()-1]=prev_point;
} }
sizingSet.insert_vertex_sequence(first_pts.begin(),first_pts.end(),first_wdir,false); sizingSet.insert_vertex_sequence(first_pts.begin(),first_pts.end(),first_wdir,false);
polygon_set_data<coordinate_type> tmp; polygon_set_data<coordinate_type> tmp;
//insert original shape //insert original shape
...@@ -722,7 +722,7 @@ namespace boost { namespace polygon { ...@@ -722,7 +722,7 @@ namespace boost { namespace polygon {
inline polygon_set_data& inline polygon_set_data&
interact(const polygon_set_data& that); interact(const polygon_set_data& that);
inline bool downcast(polygon_45_set_data<coordinate_type>& result) const { inline bool downcast(polygon_45_set_data<coordinate_type>& result) const {
if(!is_45_) return false; if(!is_45_) return false;
...@@ -791,7 +791,7 @@ namespace boost { namespace polygon { ...@@ -791,7 +791,7 @@ namespace boost { namespace polygon {
data.push_back(vertex_half_edge((*itr).first.first, (*itr).first.second, (*itr).second)); data.push_back(vertex_half_edge((*itr).first.first, (*itr).first.second, (*itr).second));
data.push_back(vertex_half_edge((*itr).first.second, (*itr).first.first, -1 * (*itr).second)); data.push_back(vertex_half_edge((*itr).first.second, (*itr).first.first, -1 * (*itr).second));
} }
std::sort(data.begin(), data.end()); gtlsort(data.begin(), data.end());
pf.scan(container, data.begin(), data.end()); pf.scan(container, data.begin(), data.end());
} }
}; };
...@@ -811,7 +811,7 @@ namespace boost { namespace polygon { ...@@ -811,7 +811,7 @@ namespace boost { namespace polygon {
// } // }
template <typename T> template <typename T>
inline int make_resizing_vertex_list(std::vector<std::vector<point_data< T> > >& return_points, inline int make_resizing_vertex_list(std::vector<std::vector<point_data< T> > >& return_points,
point_data<T>& curr_prev, bool ignore_prev_point, point_data<T>& curr_prev, bool ignore_prev_point,
point_data< T> start, point_data<T> middle, point_data< T> end, point_data< T> start, point_data<T> middle, point_data< T> end,
double sizing_distance, unsigned int num_circle_segments, bool corner_fill_arc) { double sizing_distance, unsigned int num_circle_segments, bool corner_fill_arc) {
...@@ -844,7 +844,7 @@ namespace boost { namespace polygon { ...@@ -844,7 +844,7 @@ namespace boost { namespace polygon {
int num = make_arc(return_points[return_points.size()-1],mid1_offset,mid2_offset,dmid,sizing_distance,num_circle_segments); int num = make_arc(return_points[return_points.size()-1],mid1_offset,mid2_offset,dmid,sizing_distance,num_circle_segments);
curr_prev = round_down<T>(mid2_offset); curr_prev = round_down<T>(mid2_offset);
return num; return num;
} }
std::pair<point_data<double>,point_data<double> > he1(start_offset,mid1_offset); std::pair<point_data<double>,point_data<double> > he1(start_offset,mid1_offset);
...@@ -882,21 +882,21 @@ namespace boost { namespace polygon { ...@@ -882,21 +882,21 @@ namespace boost { namespace polygon {
// returnPoints will start with the first point after start // returnPoints will start with the first point after start
// returnPoints vector may be empty // returnPoints vector may be empty
template <typename T> template <typename T>
inline int make_arc(std::vector<point_data< T> >& return_points, inline int make_arc(std::vector<point_data< T> >& return_points,
point_data< double> start, point_data< double> end, point_data< double> start, point_data< double> end,
point_data< double> center, double r, unsigned int num_circle_segments) { point_data< double> center, double r, unsigned int num_circle_segments) {
const double our_pi=3.1415926535897932384626433832795028841971; const double our_pi=3.1415926535897932384626433832795028841971;
// derive start and end angles // derive start and end angles
double ps = atan2(start.y()-center.y(), start.x()-center.x()); double ps = atan2(start.y()-center.y(), start.x()-center.x());
double pe = atan2(end.y()-center.y(), end.x()-center.x()); double pe = atan2(end.y()-center.y(), end.x()-center.x());
if (ps < 0.0) if (ps < 0.0)
ps += 2.0 * our_pi; ps += 2.0 * our_pi;
if (pe <= 0.0) if (pe <= 0.0)
pe += 2.0 * our_pi; pe += 2.0 * our_pi;
if (ps >= 2.0 * our_pi) if (ps >= 2.0 * our_pi)
ps -= 2.0 * our_pi; ps -= 2.0 * our_pi;
while (pe <= ps) while (pe <= ps)
pe += 2.0 * our_pi; pe += 2.0 * our_pi;
double delta_angle = (2.0 * our_pi) / (double)num_circle_segments; double delta_angle = (2.0 * our_pi) / (double)num_circle_segments;
if ( start==end) // full circle? if ( start==end) // full circle?
...@@ -942,12 +942,12 @@ namespace boost { namespace polygon { ...@@ -942,12 +942,12 @@ namespace boost { namespace polygon {
inline connectivity_extraction() : ce_(), nodeCount_(0) {} inline connectivity_extraction() : ce_(), nodeCount_(0) {}
inline connectivity_extraction(const connectivity_extraction& that) : ce_(that.ce_), inline connectivity_extraction(const connectivity_extraction& that) : ce_(that.ce_),
nodeCount_(that.nodeCount_) {} nodeCount_(that.nodeCount_) {}
inline connectivity_extraction& operator=(const connectivity_extraction& that) { inline connectivity_extraction& operator=(const connectivity_extraction& that) {
ce_ = that.ce_; ce_ = that.ce_;
nodeCount_ = that.nodeCount_; {} nodeCount_ = that.nodeCount_; {}
return *this; return *this;
} }
//insert a polygon set graph node, the value returned is the id of the graph node //insert a polygon set graph node, the value returned is the id of the graph node
inline unsigned int insert(const polygon_set_data<coordinate_type>& ps) { inline unsigned int insert(const polygon_set_data<coordinate_type>& ps) {
ps.clean(); ps.clean();
...@@ -960,7 +960,7 @@ namespace boost { namespace polygon { ...@@ -960,7 +960,7 @@ namespace boost { namespace polygon {
ps.insert(geoObj); ps.insert(geoObj);
return insert(ps); return insert(ps);
} }
//extract connectivity and store the edges in the graph //extract connectivity and store the edges in the graph
//graph must be indexable by graph node id and the indexed value must be a std::set of //graph must be indexable by graph node id and the indexed value must be a std::set of
//graph node id //graph node id
......
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