Remove Kbool from Kicad. Use Clipper instead.
Clipper is, by far, more easier to use than Kbool, and is currently actively maintained. It is used only to normalize polygons, i.e. to convert self intersecting polygons to simple polygons, which is not possible with boost::polygon.
This commit is contained in:
commit
c82b878787
|
@ -170,12 +170,8 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
|
|||
if( g_Parm_3D_Visu.m_Layers < 2 )
|
||||
g_Parm_3D_Visu.m_Layers = 2;
|
||||
|
||||
g_Parm_3D_Visu.m_BoardScale = 2.0 / max( g_Parm_3D_Visu.m_BoardSize.x,
|
||||
g_Parm_3D_Visu.m_BoardSize.y );
|
||||
|
||||
// @TODO: epoxy_width (board thickness) must be set by user,
|
||||
// because all boards thickness no not match with this setup:
|
||||
// double epoxy_width = 1.6; // epoxy width in mm
|
||||
g_Parm_3D_Visu.m_BoardScale = 2.0 / std::max( g_Parm_3D_Visu.m_BoardSize.x,
|
||||
g_Parm_3D_Visu.m_BoardSize.y );
|
||||
|
||||
g_Parm_3D_Visu.m_Epoxy_Width = pcb->GetDesignSettings().GetBoardThickness()
|
||||
* g_Parm_3D_Visu.m_BoardScale;
|
||||
|
|
|
@ -55,11 +55,11 @@ option(KICAD_SCRIPTING
|
|||
option(KICAD_SCRIPTING_MODULES
|
||||
"set this option ON to build kicad modules that can be used from scripting languages"
|
||||
)
|
||||
|
||||
|
||||
option(KICAD_SCRIPTING_WXPYTHON
|
||||
"set this option ON to build wxpython implementation for wx interface building in python and py.shell"
|
||||
)
|
||||
|
||||
|
||||
|
||||
#Set version option (stable or testing)
|
||||
|
||||
|
@ -314,7 +314,6 @@ add_subdirectory(gerbview)
|
|||
add_subdirectory(kicad)
|
||||
add_subdirectory(pcbnew)
|
||||
add_subdirectory(polygon)
|
||||
add_subdirectory(polygon/kbool/src)
|
||||
add_subdirectory(potrace)
|
||||
add_subdirectory(bitmap2component)
|
||||
add_subdirectory(pcb_calculator)
|
||||
|
|
|
@ -46,7 +46,7 @@ endif(APPLE)
|
|||
target_link_libraries( bitmap2component common polygon bitmaps
|
||||
${wxWidgets_LIBRARIES}
|
||||
potrace
|
||||
kbool )
|
||||
)
|
||||
|
||||
install(TARGETS bitmap2component
|
||||
DESTINATION ${KICAD_BIN}
|
||||
|
|
|
@ -70,7 +70,7 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
|
|||
|
||||
for( unsigned i=0; i<fpnames.GetCount(); ++i )
|
||||
{
|
||||
auto_ptr<MODULE> m( pi->FootprintLoad( libPath, fpnames[i] ) );
|
||||
std::auto_ptr<MODULE> m( pi->FootprintLoad( libPath, fpnames[i] ) );
|
||||
|
||||
// we're loading what we enumerated, all must be there.
|
||||
wxASSERT( m.get() );
|
||||
|
|
|
@ -98,7 +98,6 @@ target_link_libraries(cvpcb
|
|||
common
|
||||
bitmaps
|
||||
polygon
|
||||
kbool
|
||||
${wxWidgets_LIBRARIES}
|
||||
${OPENGL_LIBRARIES}
|
||||
${GDI_PLUS_LIBRARIES}
|
||||
|
|
|
@ -217,7 +217,6 @@ target_link_libraries(eeschema
|
|||
common
|
||||
bitmaps
|
||||
polygon
|
||||
kbool
|
||||
${wxWidgets_LIBRARIES}
|
||||
${GDI_PLUS_LIBRARIES}
|
||||
)
|
||||
|
|
|
@ -121,7 +121,7 @@ endif(APPLE)
|
|||
###
|
||||
# Link executable target gerbview with correct libraries
|
||||
###
|
||||
target_link_libraries(gerbview common polygon bitmaps kbool
|
||||
target_link_libraries(gerbview common polygon bitmaps
|
||||
${OPENGL_LIBRARIES}
|
||||
${wxWidgets_LIBRARIES}
|
||||
${GDI_PLUS_LIBRARIES})
|
||||
|
|
|
@ -51,7 +51,6 @@ if(APPLE)
|
|||
common
|
||||
bitmaps
|
||||
polygon
|
||||
kbool
|
||||
${wxWidgets_LIBRARIES}
|
||||
)
|
||||
else(APPLE)
|
||||
|
@ -59,7 +58,6 @@ else(APPLE)
|
|||
common
|
||||
bitmaps
|
||||
polygon
|
||||
kbool
|
||||
${wxWidgets_LIBRARIES}
|
||||
${GDI_PLUS_LIBRARIES}
|
||||
)
|
||||
|
|
|
@ -82,7 +82,6 @@ target_link_libraries( pcb_calculator
|
|||
common
|
||||
bitmaps
|
||||
polygon
|
||||
kbool
|
||||
${wxWidgets_LIBRARIES}
|
||||
)
|
||||
|
||||
|
|
|
@ -285,7 +285,7 @@ if (KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES)
|
|||
endif(KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES)
|
||||
|
||||
if (KICAD_SCRIPTING)
|
||||
|
||||
|
||||
SET(SWIG_OPTS -python -c++ -outdir ${CMAKE_CURRENT_BINARY_DIR} ${SWIG_FLAGS} )
|
||||
|
||||
add_custom_command(
|
||||
|
@ -325,7 +325,6 @@ if (KICAD_SCRIPTING_MODULES)
|
|||
common
|
||||
bitmaps
|
||||
polygon
|
||||
kbool
|
||||
${wxWidgets_LIBRARIES}
|
||||
${OPENGL_LIBRARIES}
|
||||
${GDI_PLUS_LIBRARIES}
|
||||
|
@ -418,7 +417,6 @@ target_link_libraries(pcbnew
|
|||
common
|
||||
bitmaps
|
||||
polygon
|
||||
kbool
|
||||
${wxWidgets_LIBRARIES}
|
||||
${OPENGL_LIBRARIES}
|
||||
${GDI_PLUS_LIBRARIES}
|
||||
|
@ -438,8 +436,8 @@ if(KICAD_SCRIPTING)
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/../scripting/fixswigimports.py ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/pcbnew
|
||||
COMMENT "Fixing swig_import_helper"
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
|
||||
install(FILES ${CMAKE_BINARY_DIR}/pcbnew/pcbnew.py
|
||||
DESTINATION ${PYTHON_DEST})
|
||||
|
@ -450,8 +448,8 @@ if (KICAD_SCRIPTING_MODULES)
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/../scripting/fixswigimports.py ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/_pcbnew
|
||||
COMMENT "Fixing swig_import_helper"
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
|
||||
install(FILES ${CMAKE_BINARY_DIR}/pcbnew/pcbnew.py
|
||||
DESTINATION ${PYTHON_DEST})
|
||||
|
|
|
@ -186,7 +186,7 @@ void DIALOG_GENDRILL::InitDisplayParams()
|
|||
}
|
||||
else
|
||||
{
|
||||
if( min( pad->GetDrillSize().x, pad->GetDrillSize().y ) != 0 )
|
||||
if( std::min( pad->GetDrillSize().x, pad->GetDrillSize().y ) != 0 )
|
||||
{
|
||||
if( pad->GetAttribute() == PAD_HOLE_NOT_PLATED )
|
||||
m_notplatedPadsHoleCount++;
|
||||
|
|
|
@ -76,6 +76,7 @@ Load() TODO's
|
|||
#include <class_pcb_text.h>
|
||||
|
||||
using namespace boost::property_tree;
|
||||
using namespace std;
|
||||
|
||||
typedef EAGLE_PLUGIN::BIU BIU;
|
||||
typedef PTREE::const_assoc_iterator CA_ITER;
|
||||
|
|
|
@ -63,7 +63,7 @@ static bool s_AddCutoutToCurrentZone; // if true, the next outline
|
|||
static ZONE_CONTAINER* s_CurrentZone; // if != NULL, these ZONE_CONTAINER params will be used for the next zone
|
||||
static wxPoint s_CursorLastPosition; // in move zone outline, last cursor position. Used to calculate the move vector
|
||||
static PICKED_ITEMS_LIST s_PickedList; // a picked list to save zones for undo/redo command
|
||||
static PICKED_ITEMS_LIST _AuxiliaryList; // a picked list to store zones that are deleted or added when combined
|
||||
static PICKED_ITEMS_LIST s_AuxiliaryList; // a picked list to store zones that are deleted or added when combined
|
||||
|
||||
|
||||
void PCB_EDIT_FRAME::Add_Similar_Zone( wxDC* DC, ZONE_CONTAINER* aZone )
|
||||
|
@ -128,7 +128,7 @@ void PCB_EDIT_FRAME::duplicateZone( wxDC* aDC, ZONE_CONTAINER* aZone )
|
|||
zoneSettings.ExportSetting( *newZone );
|
||||
newZone->m_Poly->Hatch();
|
||||
|
||||
_AuxiliaryList.ClearListAndDeleteItems();
|
||||
s_AuxiliaryList.ClearListAndDeleteItems();
|
||||
s_PickedList.ClearListAndDeleteItems();
|
||||
SaveCopyOfZones( s_PickedList, GetBoard(), newZone->GetNet(), newZone->GetLayer() );
|
||||
GetBoard()->Add( newZone );
|
||||
|
@ -139,7 +139,7 @@ void PCB_EDIT_FRAME::duplicateZone( wxDC* aDC, ZONE_CONTAINER* aZone )
|
|||
GetScreen()->SetCurItem( NULL ); // This outline may be deleted when merging outlines
|
||||
|
||||
// Combine zones if possible
|
||||
GetBoard()->OnAreaPolygonModified( &_AuxiliaryList, newZone );
|
||||
GetBoard()->OnAreaPolygonModified( &s_AuxiliaryList, newZone );
|
||||
|
||||
// Redraw zones
|
||||
GetBoard()->RedrawAreasOutlines( m_canvas, aDC, GR_OR, newZone->GetLayer() );
|
||||
|
@ -151,7 +151,7 @@ void PCB_EDIT_FRAME::duplicateZone( wxDC* aDC, ZONE_CONTAINER* aZone )
|
|||
DisplayError( this, _( "Duplicate Zone: The outline of the duplicated zone fails DRC check!" ) );
|
||||
}
|
||||
|
||||
UpdateCopyOfZonesList( s_PickedList, _AuxiliaryList, GetBoard() );
|
||||
UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );
|
||||
SaveCopyInUndoList( s_PickedList, UR_UNSPECIFIED );
|
||||
s_PickedList.ClearItemsList();
|
||||
|
||||
|
@ -245,7 +245,7 @@ void PCB_EDIT_FRAME::Start_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* aZone,
|
|||
if ( IsNewCorner )
|
||||
aZone->m_Poly->DeleteCorner( corner_id );
|
||||
|
||||
_AuxiliaryList.ClearListAndDeleteItems();
|
||||
s_AuxiliaryList.ClearListAndDeleteItems();
|
||||
s_PickedList.ClearListAndDeleteItems();
|
||||
|
||||
SaveCopyOfZones( s_PickedList, GetBoard(), aZone->GetNet(),
|
||||
|
@ -277,7 +277,7 @@ void PCB_EDIT_FRAME::Start_Move_Zone_Drag_Outline_Edge( wxDC* DC,
|
|||
s_CurrentZone = NULL;
|
||||
|
||||
s_PickedList.ClearListAndDeleteItems();
|
||||
_AuxiliaryList.ClearListAndDeleteItems();
|
||||
s_AuxiliaryList.ClearListAndDeleteItems();
|
||||
SaveCopyOfZones( s_PickedList, GetBoard(), aZone->GetNet(),
|
||||
aZone->GetLayer() );
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ void PCB_EDIT_FRAME::Start_Move_Zone_Outlines( wxDC* DC, ZONE_CONTAINER* aZone )
|
|||
}
|
||||
|
||||
s_PickedList.ClearListAndDeleteItems();
|
||||
_AuxiliaryList.ClearListAndDeleteItems();
|
||||
s_AuxiliaryList.ClearListAndDeleteItems();
|
||||
SaveCopyOfZones( s_PickedList, GetBoard(), aZone->GetNet(),
|
||||
aZone->GetLayer() );
|
||||
|
||||
|
@ -332,7 +332,7 @@ void PCB_EDIT_FRAME::End_Move_Zone_Corner_Or_Outlines( wxDC* DC, ZONE_CONTAINER*
|
|||
|
||||
// Combine zones if possible
|
||||
wxBusyCursor dummy;
|
||||
GetBoard()->OnAreaPolygonModified( &_AuxiliaryList, aZone );
|
||||
GetBoard()->OnAreaPolygonModified( &s_AuxiliaryList, aZone );
|
||||
m_canvas->Refresh();
|
||||
|
||||
|
||||
|
@ -341,7 +341,7 @@ void PCB_EDIT_FRAME::End_Move_Zone_Corner_Or_Outlines( wxDC* DC, ZONE_CONTAINER*
|
|||
if( ii < 0 )
|
||||
aZone = NULL; // was removed by combining zones
|
||||
|
||||
UpdateCopyOfZonesList( s_PickedList, _AuxiliaryList, GetBoard() );
|
||||
UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );
|
||||
SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED);
|
||||
s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
|
||||
|
||||
|
@ -380,14 +380,14 @@ void PCB_EDIT_FRAME::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* aZone )
|
|||
GetBoard()->RedrawFilledAreas( m_canvas, DC, GR_XOR, layer );
|
||||
}
|
||||
|
||||
_AuxiliaryList.ClearListAndDeleteItems();
|
||||
s_AuxiliaryList.ClearListAndDeleteItems();
|
||||
s_PickedList. ClearListAndDeleteItems();
|
||||
SaveCopyOfZones( s_PickedList, GetBoard(), aZone->GetNet(),
|
||||
aZone->GetLayer() );
|
||||
aZone->m_Poly->DeleteCorner( aZone->m_CornerSelection );
|
||||
|
||||
// modify zones outlines according to the new aZone shape
|
||||
GetBoard()->OnAreaPolygonModified( &_AuxiliaryList, aZone );
|
||||
GetBoard()->OnAreaPolygonModified( &s_AuxiliaryList, aZone );
|
||||
|
||||
if( DC )
|
||||
{
|
||||
|
@ -395,7 +395,7 @@ void PCB_EDIT_FRAME::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* aZone )
|
|||
GetBoard()->RedrawFilledAreas( m_canvas, DC, GR_OR, layer );
|
||||
}
|
||||
|
||||
UpdateCopyOfZonesList( s_PickedList, _AuxiliaryList, GetBoard() );
|
||||
UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );
|
||||
SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED);
|
||||
s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
|
||||
|
||||
|
@ -448,7 +448,7 @@ void Abort_Zone_Move_Corner_Or_Outlines( EDA_DRAW_PANEL* Panel, wxDC* DC )
|
|||
}
|
||||
|
||||
Panel->SetMouseCapture( NULL, NULL );
|
||||
_AuxiliaryList.ClearListAndDeleteItems();
|
||||
s_AuxiliaryList.ClearListAndDeleteItems();
|
||||
s_PickedList. ClearListAndDeleteItems();
|
||||
Panel->Refresh();
|
||||
|
||||
|
@ -733,7 +733,7 @@ bool PCB_EDIT_FRAME::End_Zone( wxDC* DC )
|
|||
GetBoard()->RedrawFilledAreas( m_canvas, DC, GR_XOR, layer );
|
||||
|
||||
// Save initial zones configuration, for undo/redo, before adding new zone
|
||||
_AuxiliaryList.ClearListAndDeleteItems();
|
||||
s_AuxiliaryList.ClearListAndDeleteItems();
|
||||
s_PickedList.ClearListAndDeleteItems();
|
||||
SaveCopyOfZones(s_PickedList, GetBoard(), zone->GetNet(), zone->GetLayer() );
|
||||
|
||||
|
@ -766,7 +766,7 @@ bool PCB_EDIT_FRAME::End_Zone( wxDC* DC )
|
|||
GetScreen()->SetCurItem( NULL ); // This outline can be deleted when merging outlines
|
||||
|
||||
// Combine zones if possible :
|
||||
GetBoard()->OnAreaPolygonModified( &_AuxiliaryList, zone );
|
||||
GetBoard()->OnAreaPolygonModified( &s_AuxiliaryList, zone );
|
||||
|
||||
// Redraw the real edge zone :
|
||||
GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_OR, layer );
|
||||
|
@ -784,7 +784,7 @@ bool PCB_EDIT_FRAME::End_Zone( wxDC* DC )
|
|||
DisplayError( this, _( "Area: DRC outline error" ) );
|
||||
}
|
||||
|
||||
UpdateCopyOfZonesList( s_PickedList, _AuxiliaryList, GetBoard() );
|
||||
UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );
|
||||
SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED);
|
||||
s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
|
||||
|
||||
|
@ -838,7 +838,7 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* aZone )
|
|||
|
||||
// Save initial zones configuration, for undo/redo, before adding new zone
|
||||
// note the net name and the layer can be changed, so we must save all zones
|
||||
_AuxiliaryList.ClearListAndDeleteItems();
|
||||
s_AuxiliaryList.ClearListAndDeleteItems();
|
||||
s_PickedList.ClearListAndDeleteItems();
|
||||
SaveCopyOfZones(s_PickedList, GetBoard(), -1, -1 );
|
||||
|
||||
|
@ -866,7 +866,7 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* aZone )
|
|||
|
||||
if( edited == ZONE_ABORT )
|
||||
{
|
||||
_AuxiliaryList.ClearListAndDeleteItems();
|
||||
s_AuxiliaryList.ClearListAndDeleteItems();
|
||||
s_PickedList.ClearListAndDeleteItems();
|
||||
return;
|
||||
}
|
||||
|
@ -875,7 +875,7 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* aZone )
|
|||
|
||||
if( edited == ZONE_EXPORT_VALUES )
|
||||
{
|
||||
UpdateCopyOfZonesList( s_PickedList, _AuxiliaryList, GetBoard() );
|
||||
UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );
|
||||
SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED);
|
||||
s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
|
||||
return;
|
||||
|
@ -896,12 +896,12 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* aZone )
|
|||
aZone->SetNetName( net->GetNetname() );
|
||||
|
||||
// Combine zones if possible
|
||||
GetBoard()->OnAreaPolygonModified( &_AuxiliaryList, aZone );
|
||||
GetBoard()->OnAreaPolygonModified( &s_AuxiliaryList, aZone );
|
||||
|
||||
// Redraw the real new zone outlines
|
||||
GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_OR, -1 );
|
||||
|
||||
UpdateCopyOfZonesList( s_PickedList, _AuxiliaryList, GetBoard() );
|
||||
UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );
|
||||
SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED);
|
||||
|
||||
s_PickedList.ClearItemsList(); // s_ItemsListPicker is no longer owner of picked items
|
||||
|
|
|
@ -174,19 +174,26 @@ int SaveCopyOfZones( PICKED_ITEMS_LIST& aPickList, BOARD* aPcb, int aNetCode, in
|
|||
* @param aPcb = the Board
|
||||
*
|
||||
* aAuxiliaryList is a list of pickers updated by zone algorithms:
|
||||
* This list cointains zones which were added or deleted during the zones combine process
|
||||
* This list contains zones which were added or deleted during the zones combine process
|
||||
* aPickList :is a list of zones that can be modified (changed or deleted, or not modified)
|
||||
* Typically, this is the list of existing zones on the layer of the edited zone,
|
||||
* before any change.
|
||||
* >> if the picked zone is not changed, it is removed from list
|
||||
* >> if the picked zone was deleted (i.e. not found in boad list), the picker is modified:
|
||||
* - its status becomes UR_DELETED
|
||||
* - the aAuxiliaryList corresponding picker is removed (if not found : set an error)
|
||||
* >> if the picked zone was flagged as UR_NEW, and was deleted (i.e. not found in boad list),
|
||||
* - the picker is removed
|
||||
* - the zone itself if really deleted
|
||||
* - the aAuxiliaryList corresponding picker is removed (if not found : set an error)
|
||||
* >> if the picked zone was deleted (i.e. not found in board list), the picker is modified:
|
||||
* its status becomes UR_DELETED
|
||||
* the aAuxiliaryList corresponding picker is removed (if not found : set an error)
|
||||
* >> if the picked zone was flagged as UR_NEW, and was after deleted ,
|
||||
* perhaps combined with an other zone (i.e. not found in board list):
|
||||
* the picker is removed
|
||||
* the zone itself if really deleted
|
||||
* the aAuxiliaryList corresponding picker is removed (if not found : set an error)
|
||||
* After aPickList is cleaned, the aAuxiliaryList is read
|
||||
* All pickers flagged UR_NEW are moved to aPickList
|
||||
* (the corresponding zones are zone that were created by the zone combine process, mainly when adding cutaout areas)
|
||||
* (the corresponding zones are zone that were created by the zone normalize and combine process,
|
||||
* mainly when adding cutout areas, or creating self intersecting contours)
|
||||
* All pickers flagged UR_DELETED are removed, and the coresponding zones actually deleted
|
||||
* (the corresponding zones are new zone that were created by the zone normalize process,
|
||||
* when creating self intersecting contours, and after combined with an existing zone.
|
||||
* At the end of the update process the aAuxiliaryList must be void,
|
||||
* because all pickers created by the combine process
|
||||
* must have been removed (removed for new and deleted zones, or moved in aPickList.)
|
||||
|
@ -274,15 +281,21 @@ void UpdateCopyOfZonesList( PICKED_ITEMS_LIST& aPickList,
|
|||
|
||||
|
||||
// Add new zones in main pick list, and remove pickers from Auxiliary List
|
||||
for( unsigned ii = 0; ii < aAuxiliaryList.GetCount(); ii++ )
|
||||
for( unsigned ii = 0; ii < aAuxiliaryList.GetCount(); )
|
||||
{
|
||||
if( aAuxiliaryList.GetPickedItemStatus( ii ) == UR_NEW )
|
||||
{
|
||||
ITEM_PICKER picker = aAuxiliaryList.GetItemWrapper( ii );
|
||||
aPickList.PushItem( picker );
|
||||
aAuxiliaryList.RemovePicker( ii );
|
||||
ii--;
|
||||
}
|
||||
else if( aAuxiliaryList.GetPickedItemStatus( ii ) == UR_DELETED )
|
||||
{
|
||||
delete aAuxiliaryList.GetPickedItemLink( ii );
|
||||
aAuxiliaryList.RemovePicker( ii );
|
||||
}
|
||||
else
|
||||
ii++;
|
||||
}
|
||||
|
||||
// Should not occur:
|
||||
|
|
|
@ -211,12 +211,12 @@ bool BOARD::OnAreaPolygonModified( PICKED_ITEMS_LIST* aModifiedZonesList,
|
|||
|
||||
// Test for bad areas: all zones must have more than 2 corners:
|
||||
// Note: should not happen, but just in case.
|
||||
for( unsigned ia1 = 0; ia1 < m_ZoneDescriptorList.size() - 1; )
|
||||
for( unsigned ii = 0; ii < m_ZoneDescriptorList.size(); )
|
||||
{
|
||||
ZONE_CONTAINER* zone = m_ZoneDescriptorList[ia1];
|
||||
ZONE_CONTAINER* zone = m_ZoneDescriptorList[ii];
|
||||
|
||||
if( zone->GetNumCorners() >= 3 )
|
||||
ia1++;
|
||||
ii++;
|
||||
else // Remove zone because it is incorrect:
|
||||
RemoveArea( aModifiedZonesList, zone );
|
||||
}
|
||||
|
@ -267,25 +267,25 @@ bool BOARD::CombineAllAreasInNet( PICKED_ITEMS_LIST* aDeletedList, int aNetCode,
|
|||
if( curr_area->GetIsKeepout() != area2->GetIsKeepout() )
|
||||
continue;
|
||||
|
||||
if( curr_area->GetLayer() == area2->GetLayer() )
|
||||
if( curr_area->GetLayer() != area2->GetLayer() )
|
||||
continue;
|
||||
|
||||
CRect b2 = area2->m_Poly->GetCornerBounds();
|
||||
if( !( b1.left > b2.right || b1.right < b2.left
|
||||
|| b1.bottom > b2.top || b1.top < b2.bottom ) )
|
||||
{
|
||||
CRect b2 = area2->m_Poly->GetCornerBounds();
|
||||
if( !( b1.left > b2.right || b1.right < b2.left
|
||||
|| b1.bottom > b2.top || b1.top < b2.bottom ) )
|
||||
// check area2 against curr_area
|
||||
if( curr_area->utility || area2->utility || aUseUtility == false )
|
||||
{
|
||||
// check area2 against curr_area
|
||||
if( curr_area->utility || area2->utility || aUseUtility == false )
|
||||
bool ret = TestAreaIntersection( curr_area, area2 );
|
||||
|
||||
if( ret )
|
||||
ret = CombineAreas( aDeletedList, curr_area, area2 );
|
||||
|
||||
if( ret )
|
||||
{
|
||||
bool ret = TestAreaIntersection( curr_area, area2 );
|
||||
|
||||
if( ret )
|
||||
ret = CombineAreas( aDeletedList, curr_area, area2 );
|
||||
|
||||
if( ret )
|
||||
{
|
||||
mod_ia1 = true;
|
||||
modified = true;
|
||||
}
|
||||
mod_ia1 = true;
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -424,7 +424,7 @@ bool BOARD::TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area
|
|||
|
||||
if( poly1->TestPointInside( x, y ) )
|
||||
{
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -435,11 +435,11 @@ bool BOARD::TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area
|
|||
|
||||
if( poly2->TestPointInside( x, y ) )
|
||||
{
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -465,10 +465,6 @@ bool BOARD::CombineAreas( PICKED_ITEMS_LIST* aDeletedList, ZONE_CONTAINER* area_
|
|||
}
|
||||
|
||||
// polygons intersect, combine them
|
||||
// TODO: test here if areas intersect and combine only if so
|
||||
|
||||
#if 0
|
||||
// do not set to 1 (not fully working): only for me (JP. Charras) until this code is finished
|
||||
KI_POLYGON_WITH_HOLES areaRefPoly;
|
||||
KI_POLYGON_WITH_HOLES areaToMergePoly;
|
||||
CopyPolysListToKiPolygonWithHole( area_ref->m_Poly->m_CornersList, areaRefPoly );
|
||||
|
@ -478,10 +474,20 @@ bool BOARD::CombineAreas( PICKED_ITEMS_LIST* aDeletedList, ZONE_CONTAINER* area_
|
|||
mergedOutlines.push_back( areaRefPoly );
|
||||
mergedOutlines |= areaToMergePoly;
|
||||
|
||||
// We can have more than one polygon with holes in mergedOutlines
|
||||
// depending on the complexity of outlines
|
||||
// We should have one polygon with hole
|
||||
// We can have 2 polygons with hole, if the 2 initial polygons have only one common corner
|
||||
// and therefore cannot be merged (they are dectected as intersecting)
|
||||
// but we should never have more than 2 polys
|
||||
if( mergedOutlines.size() > 2 )
|
||||
{
|
||||
wxLogMessage(wxT("BOARD::CombineAreas error: more than 2 polys after merging") );
|
||||
return false;
|
||||
}
|
||||
|
||||
areaRefPoly = mergedOutlines[0]; // TODO: read and create all created polygons
|
||||
if( mergedOutlines.size() > 1 )
|
||||
return false;
|
||||
|
||||
areaRefPoly = mergedOutlines[0];
|
||||
area_ref->m_Poly->RemoveAllContours();
|
||||
|
||||
KI_POLYGON_WITH_HOLES::iterator_type corner = areaRefPoly.begin();
|
||||
|
@ -509,76 +515,6 @@ bool BOARD::CombineAreas( PICKED_ITEMS_LIST* aDeletedList, ZONE_CONTAINER* area_
|
|||
area_ref->m_Poly->CloseLastContour();
|
||||
hole++;
|
||||
}
|
||||
#else
|
||||
void armBoolEng( Bool_Engine* aBooleng, bool aConvertHoles = false );
|
||||
Bool_Engine* booleng = new Bool_Engine();
|
||||
armBoolEng( booleng );
|
||||
|
||||
area_ref->m_Poly->AddPolygonsToBoolEng( booleng, GROUP_A );
|
||||
area_to_combine->m_Poly->AddPolygonsToBoolEng(booleng, GROUP_B );
|
||||
booleng->Do_Operation( BOOL_OR );
|
||||
|
||||
// create area with external contour: Recreate only area edges, NOT holes
|
||||
if( booleng->StartPolygonGet() )
|
||||
{
|
||||
if( booleng->GetPolygonPointEdgeType() == KB_INSIDE_EDGE )
|
||||
{
|
||||
DisplayError( NULL, wxT( "BOARD::CombineAreas() error: unexpected hole descriptor" ) );
|
||||
}
|
||||
|
||||
area_ref->m_Poly->RemoveAllContours();
|
||||
|
||||
// foreach point in the polygon
|
||||
bool first = true;
|
||||
|
||||
while( booleng->PolygonHasMorePoints() )
|
||||
{
|
||||
int x = (int) booleng->GetPolygonXPoint();
|
||||
int y = (int) booleng->GetPolygonYPoint();
|
||||
|
||||
if( first )
|
||||
{
|
||||
first = false;
|
||||
area_ref->m_Poly->Start( area_ref->GetLayer(
|
||||
), x, y, area_ref->m_Poly->GetHatchStyle() );
|
||||
}
|
||||
else
|
||||
{
|
||||
area_ref->m_Poly->AppendCorner( x, y );
|
||||
}
|
||||
}
|
||||
|
||||
booleng->EndPolygonGet();
|
||||
area_ref->m_Poly->CloseLastContour();
|
||||
}
|
||||
|
||||
// add holes
|
||||
bool show_error = true;
|
||||
|
||||
while( booleng->StartPolygonGet() )
|
||||
{
|
||||
// we expect all vertex are holes inside the main outline
|
||||
if( booleng->GetPolygonPointEdgeType() != KB_INSIDE_EDGE )
|
||||
{
|
||||
if( show_error ) // show this error only once, if happens
|
||||
DisplayError( NULL,
|
||||
wxT( "BOARD::CombineAreas() error: unexpected outside contour descriptor" ) );
|
||||
|
||||
show_error = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
while( booleng->PolygonHasMorePoints() )
|
||||
{
|
||||
int x = (int) booleng->GetPolygonXPoint();
|
||||
int y = (int) booleng->GetPolygonYPoint();
|
||||
area_ref->m_Poly->AppendCorner( x, y );
|
||||
}
|
||||
|
||||
area_ref->m_Poly->CloseLastContour();
|
||||
booleng->EndPolygonGet();
|
||||
}
|
||||
#endif
|
||||
|
||||
RemoveArea( aDeletedList, area_to_combine );
|
||||
|
||||
|
@ -822,7 +758,7 @@ bool DRC::doEdgeZoneDrc( ZONE_CONTAINER* aArea, int aCornerIndex )
|
|||
for( int ia2 = 0; ia2 < m_pcb->GetAreaCount(); ia2++ )
|
||||
{
|
||||
ZONE_CONTAINER* area_to_test = m_pcb->GetArea( ia2 );
|
||||
int zone_clearance = max( area_to_test->m_ZoneClearance,
|
||||
int zone_clearance = std::max( area_to_test->m_ZoneClearance,
|
||||
aArea->m_ZoneClearance );
|
||||
|
||||
// test for same layer
|
||||
|
|
|
@ -8,6 +8,7 @@ set(POLYGON_SRCS
|
|||
math_for_graphics.cpp
|
||||
PolyLine.cpp
|
||||
polygon_test_point_inside.cpp
|
||||
clipper.cpp
|
||||
)
|
||||
|
||||
add_library(polygon STATIC ${POLYGON_SRCS})
|
||||
|
|
|
@ -16,16 +16,12 @@
|
|||
#include <math_for_graphics.h>
|
||||
#include <polygon_test_point_inside.h>
|
||||
|
||||
enum m_SideStyle { STRAIGHT }; // side styles
|
||||
|
||||
|
||||
CPolyLine::CPolyLine()
|
||||
{
|
||||
m_hatchStyle = NO_HATCH;
|
||||
m_hatchPitch = 0;
|
||||
m_layer = 0;
|
||||
m_utility = 0;
|
||||
m_Kbool_Poly_Engine = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,409 +30,6 @@ CPolyLine::CPolyLine()
|
|||
CPolyLine::~CPolyLine()
|
||||
{
|
||||
UnHatch();
|
||||
|
||||
if( m_Kbool_Poly_Engine )
|
||||
delete m_Kbool_Poly_Engine;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function armBoolEng
|
||||
* Initialise parameters used in kbool
|
||||
* @param aBooleng = pointer to the Bool_Engine to initialise
|
||||
* @param aConvertHoles = mode for holes when a boolean operation is made
|
||||
* true: holes are linked into outer contours by double overlapping segments
|
||||
* false: holes are not linked: in this mode contours are added clockwise
|
||||
* and polygons added counter clockwise are holes (default)
|
||||
*/
|
||||
void armBoolEng( Bool_Engine* aBooleng, bool aConvertHoles = false );
|
||||
|
||||
/**
|
||||
* Function NormalizeWithKbool
|
||||
* Use the Kbool Library to clip contours: if outlines are crossing, the self-crossing polygon
|
||||
* is converted to non self-crossing polygon by adding extra points at the crossing locations
|
||||
* and reordering corners
|
||||
* if more than one outside contour are found, extra CPolyLines will be created
|
||||
* because copper areas have only one outside contour
|
||||
* Therefore, if this results in new CPolyLines, return them as std::vector pa
|
||||
* @param aExtraPolyList: pointer on a std::vector<CPolyLine*> to store extra CPolyLines
|
||||
* (when after normalization, there is more than one polygon with holes)
|
||||
* @return number of external contours, or -1 if error
|
||||
*/
|
||||
int CPolyLine::NormalizeWithKbool( std::vector<CPolyLine*>* aExtraPolyList )
|
||||
{
|
||||
std::vector <void*> hole_array; // list of holes
|
||||
std::vector<int>* hole; // used to store corners for a given hole
|
||||
CPolyLine* polyline;
|
||||
int n_ext_cont = 0; // CPolyLine count
|
||||
|
||||
/* Creates a bool engine from this CPolyLine.
|
||||
* Normalized outlines and holes will be in m_Kbool_Poly_Engine
|
||||
* If some polygons are self crossing, after running the Kbool Engine, self crossing polygons
|
||||
* will be converted in non self crossing polygons by inserting extra points at the crossing locations
|
||||
* True holes are combined if possible
|
||||
*/
|
||||
MakeKboolPoly();
|
||||
|
||||
UnHatch();
|
||||
|
||||
/* now, recreate polys
|
||||
* if more than one outside contour are found, extra CPolyLines will be created
|
||||
* because copper areas have only one outside contour
|
||||
* the first outside contour found is the new "this" outside contour
|
||||
* if others outside contours are found we create new CPolyLines
|
||||
* Note: if there are holes in polygons, we must store them
|
||||
* and when all outside contours are found, search the corresponding outside contour for each hole
|
||||
*/
|
||||
while( m_Kbool_Poly_Engine->StartPolygonGet() )
|
||||
{
|
||||
// See if the current polygon is flagged as a hole
|
||||
if( m_Kbool_Poly_Engine->GetPolygonPointEdgeType() == KB_INSIDE_EDGE )
|
||||
{
|
||||
hole = new std::vector<int>;
|
||||
hole_array.push_back( hole );
|
||||
|
||||
while( m_Kbool_Poly_Engine->PolygonHasMorePoints() ) // store hole
|
||||
{
|
||||
int x = (int) m_Kbool_Poly_Engine->GetPolygonXPoint();
|
||||
int y = (int) m_Kbool_Poly_Engine->GetPolygonYPoint();
|
||||
hole->push_back( x );
|
||||
hole->push_back( y );
|
||||
}
|
||||
|
||||
m_Kbool_Poly_Engine->EndPolygonGet();
|
||||
}
|
||||
else if( n_ext_cont == 0 )
|
||||
{
|
||||
// first external contour, replace this poly
|
||||
m_CornersList.clear();
|
||||
bool first = true;
|
||||
|
||||
while( m_Kbool_Poly_Engine->PolygonHasMorePoints() )
|
||||
{
|
||||
// foreach point in the polygon
|
||||
int x = (int) m_Kbool_Poly_Engine->GetPolygonXPoint();
|
||||
int y = (int) m_Kbool_Poly_Engine->GetPolygonYPoint();
|
||||
|
||||
if( first )
|
||||
{
|
||||
first = false;
|
||||
Start( GetLayer(), x, y, GetHatchStyle() );
|
||||
}
|
||||
else
|
||||
AppendCorner( x, y );
|
||||
}
|
||||
|
||||
m_Kbool_Poly_Engine->EndPolygonGet();
|
||||
CloseLastContour();
|
||||
n_ext_cont++;
|
||||
}
|
||||
else if( aExtraPolyList ) // a new outside contour is found: create a new CPolyLine
|
||||
{
|
||||
polyline = new CPolyLine;
|
||||
polyline->ImportSettings( this );
|
||||
aExtraPolyList->push_back( polyline ); // put it in array
|
||||
bool first = true;
|
||||
|
||||
while( m_Kbool_Poly_Engine->PolygonHasMorePoints() ) // read next external contour
|
||||
{
|
||||
int x = (int) m_Kbool_Poly_Engine->GetPolygonXPoint();
|
||||
int y = (int) m_Kbool_Poly_Engine->GetPolygonYPoint();
|
||||
|
||||
if( first )
|
||||
{
|
||||
first = false;
|
||||
polyline->Start( GetLayer(), x, y, GetHatchStyle() );
|
||||
}
|
||||
else
|
||||
polyline->AppendCorner( x, y );
|
||||
}
|
||||
|
||||
m_Kbool_Poly_Engine->EndPolygonGet();
|
||||
polyline->CloseLastContour();
|
||||
n_ext_cont++;
|
||||
}
|
||||
}
|
||||
|
||||
// now add cutouts to the corresponding CPolyLine(s)
|
||||
for( unsigned ii = 0; ii < hole_array.size(); ii++ )
|
||||
{
|
||||
hole = (std::vector<int>*)hole_array[ii];
|
||||
polyline = NULL;
|
||||
|
||||
if( n_ext_cont == 1 )
|
||||
{
|
||||
polyline = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
// find the polygon that contains this hole
|
||||
// testing one corner inside is enought because a hole is entirely inside the polygon
|
||||
// so we test only the first corner
|
||||
int x = (*hole)[0];
|
||||
int y = (*hole)[1];
|
||||
|
||||
if( TestPointInside( x, y ) )
|
||||
polyline = this;
|
||||
else if( aExtraPolyList )
|
||||
{
|
||||
for( int ext_ic = 0; ext_ic<n_ext_cont - 1; ext_ic++ )
|
||||
{
|
||||
if( (*aExtraPolyList)[ext_ic]->TestPointInside( x, y ) )
|
||||
{
|
||||
polyline = (*aExtraPolyList)[ext_ic];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !polyline )
|
||||
wxASSERT( 0 );
|
||||
else
|
||||
{
|
||||
for( unsigned ii = 0; ii< (*hole).size(); ii++ )
|
||||
{
|
||||
int x = (*hole)[ii]; ii++;
|
||||
int y = (*hole)[ii];
|
||||
polyline->AppendCorner( x, y );
|
||||
}
|
||||
|
||||
polyline->CloseLastContour();
|
||||
}
|
||||
}
|
||||
|
||||
delete m_Kbool_Poly_Engine;
|
||||
m_Kbool_Poly_Engine = NULL;
|
||||
|
||||
// free hole list
|
||||
for( unsigned ii = 0; ii < hole_array.size(); ii++ )
|
||||
delete (std::vector<int>*)hole_array[ii];
|
||||
|
||||
return n_ext_cont;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function AddPolygonsToBoolEng
|
||||
* Add a CPolyLine to a kbool engine, preparing a boolean op between polygons
|
||||
* @param aBooleng : pointer on a bool engine (handle a set of polygons)
|
||||
* @param aGroup : group to fill (aGroup = GROUP_A or GROUP_B) operations are made between GROUP_A and GROUP_B
|
||||
*/
|
||||
int CPolyLine::AddPolygonsToBoolEng( Bool_Engine* aBooleng, GroupType aGroup )
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
/* Convert the current polyline contour to a kbool polygon: */
|
||||
MakeKboolPoly();
|
||||
|
||||
/* add the resulting kbool set of polygons to the current kcool engine */
|
||||
while( m_Kbool_Poly_Engine->StartPolygonGet() )
|
||||
{
|
||||
if( aBooleng->StartPolygonAdd( GROUP_A ) )
|
||||
{
|
||||
while( m_Kbool_Poly_Engine->PolygonHasMorePoints() )
|
||||
{
|
||||
int x = (int) m_Kbool_Poly_Engine->GetPolygonXPoint();
|
||||
int y = (int) m_Kbool_Poly_Engine->GetPolygonYPoint();
|
||||
aBooleng->AddPoint( x, y );
|
||||
count++;
|
||||
}
|
||||
|
||||
aBooleng->EndPolygonAdd();
|
||||
}
|
||||
m_Kbool_Poly_Engine->EndPolygonGet();
|
||||
}
|
||||
|
||||
delete m_Kbool_Poly_Engine;
|
||||
m_Kbool_Poly_Engine = NULL;
|
||||
|
||||
return count;
|
||||
}
|
||||
/**
|
||||
* Function MakeKboolPoly
|
||||
* fill a kbool engine with a closed polyline contour
|
||||
* normalize self-intersecting contours
|
||||
* @return error: 0 if Ok, 1 if error
|
||||
*/
|
||||
int CPolyLine::MakeKboolPoly()
|
||||
{
|
||||
if( m_Kbool_Poly_Engine )
|
||||
{
|
||||
delete m_Kbool_Poly_Engine;
|
||||
m_Kbool_Poly_Engine = NULL;
|
||||
}
|
||||
|
||||
if( !GetClosed() )
|
||||
return 1; // error
|
||||
|
||||
int polycount = GetContoursCount();
|
||||
int last_contour = polycount - 1;
|
||||
|
||||
for( int icont = 0; icont <= last_contour; icont++ )
|
||||
{
|
||||
// Fill a kbool engine for this contour,
|
||||
// and combine it with previous contours
|
||||
Bool_Engine* booleng = new Bool_Engine();
|
||||
armBoolEng( booleng, false );
|
||||
|
||||
if( m_Kbool_Poly_Engine ) // a previous contour exists. Put it in new engine
|
||||
{
|
||||
while( m_Kbool_Poly_Engine->StartPolygonGet() )
|
||||
{
|
||||
if( booleng->StartPolygonAdd( GROUP_A ) )
|
||||
{
|
||||
while( m_Kbool_Poly_Engine->PolygonHasMorePoints() )
|
||||
{
|
||||
int x = (int) m_Kbool_Poly_Engine->GetPolygonXPoint();
|
||||
int y = (int) m_Kbool_Poly_Engine->GetPolygonYPoint();
|
||||
booleng->AddPoint( x, y );
|
||||
}
|
||||
|
||||
booleng->EndPolygonAdd();
|
||||
}
|
||||
m_Kbool_Poly_Engine->EndPolygonGet();
|
||||
}
|
||||
}
|
||||
|
||||
int ic_st = GetContourStart( icont );
|
||||
int ic_end = GetContourEnd( icont );
|
||||
|
||||
if( !booleng->StartPolygonAdd( GROUP_B ) )
|
||||
{
|
||||
wxASSERT( 0 );
|
||||
return 1; // error
|
||||
}
|
||||
|
||||
// Enter this contour to booleng
|
||||
for( int ic = ic_st; ic <= ic_end; ic++ )
|
||||
{
|
||||
int x1 = m_CornersList[ic].x;
|
||||
int y1 = m_CornersList[ic].y;
|
||||
booleng->AddPoint( x1, y1 );
|
||||
}
|
||||
|
||||
// close list added to the bool engine
|
||||
booleng->EndPolygonAdd();
|
||||
|
||||
/* now combine polygon to the previous polygons.
|
||||
* note: the first polygon is the outline contour, and others are holes inside the first polygon
|
||||
* The first polygon is ORed with nothing, but is is a trick to sort corners (vertex)
|
||||
* clockwise with the kbool engine.
|
||||
* Others polygons are substract to the outline and corners will be ordered counter clockwise
|
||||
* by the kbool engine
|
||||
*/
|
||||
if( icont != 0 ) // substract hole to outside ( if the outline contour is take in account)
|
||||
{
|
||||
booleng->Do_Operation( BOOL_A_SUB_B );
|
||||
}
|
||||
else // add outside or add holes if we do not use the outline contour
|
||||
{
|
||||
booleng->Do_Operation( BOOL_OR );
|
||||
}
|
||||
|
||||
// now use result as new polygon (delete the old one if exists)
|
||||
if( m_Kbool_Poly_Engine )
|
||||
delete m_Kbool_Poly_Engine;
|
||||
|
||||
m_Kbool_Poly_Engine = booleng;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function armBoolEng
|
||||
* Initialise parameters used in kbool
|
||||
* @param aBooleng = pointer to the Bool_Engine to initialise
|
||||
* @param aConvertHoles = mode for holes when a boolean operation is made
|
||||
* true: in resulting polygon, holes are linked into outer contours by double overlapping segments
|
||||
* false: in resulting polygons, holes are not linked: they are separate polygons
|
||||
*/
|
||||
void armBoolEng( Bool_Engine* aBooleng, bool aConvertHoles )
|
||||
{
|
||||
// set some global vals to arm the boolean engine
|
||||
|
||||
// input points are scaled up with GetDGrid() * GetGrid()
|
||||
|
||||
// DGRID is only meant to make fractional parts of input data which
|
||||
/*
|
||||
* The input data scaled up with DGrid is related to the accuracy the user has in his input data.
|
||||
* User data with a minimum accuracy of 0.001, means set the DGrid to 1000.
|
||||
* The input data may contain data with a minimum accuracy much smaller, but by setting the DGrid
|
||||
* everything smaller than 1/DGrid is rounded.
|
||||
*
|
||||
* DGRID is only meant to make fractional parts of input data which can be
|
||||
* doubles, part of the integers used in vertexes within the boolean algorithm.
|
||||
* And therefore DGRID bigger than 1 is not usefull, you would only loose accuracy.
|
||||
* Within the algorithm all input data is multiplied with DGRID, and the result
|
||||
* is rounded to an integer.
|
||||
*/
|
||||
double DGRID = 1000.0; // round coordinate X or Y value in calculations to this (initial value = 1000.0 in kbool example)
|
||||
// kbool uses DGRID to convert float user units to integer
|
||||
// kbool unit = (int)(user unit * DGRID)
|
||||
// Note: in kicad, coordinates are already integer so DGRID could be set to 1
|
||||
// we can choose 1.0,
|
||||
// but choose DGRID = 1000.0 solves some filling problems
|
||||
// (perhaps because this allows a better precision in kbool internal calculations
|
||||
|
||||
double MARGE = 1.0 / DGRID; // snap with in this range points to lines in the intersection routines
|
||||
// should always be >= 1/DGRID a MARGE >= 10/DGRID is ok
|
||||
// this is also used to remove small segments and to decide when
|
||||
// two segments are in line. ( initial value = 0.001 )
|
||||
// For kicad we choose MARGE = 1/DGRID
|
||||
|
||||
double CORRECTIONFACTOR = 0.0; // correct the polygons by this number: used in BOOL_CORRECTION operation
|
||||
// this operation shrinks a polygon if CORRECTIONFACTOR < 0
|
||||
// or stretch it if CORRECTIONFACTOR > 0
|
||||
// the size change is CORRECTIONFACTOR (holes are correctly handled)
|
||||
double CORRECTIONABER = 1.0; // the accuracy for the rounded shapes used in correction
|
||||
double ROUNDFACTOR = 1.5; // when will we round the correction shape to a circle
|
||||
double SMOOTHABER = 10.0; // accuracy when smoothing a polygon
|
||||
double MAXLINEMERGE = 1000.0; // leave as is, segments of this length in smoothen
|
||||
|
||||
|
||||
/*
|
||||
* Grid makes sure that the integer data used within the algorithm has room for extra intersections
|
||||
* smaller than the smallest number within the input data.
|
||||
* The input data scaled up with DGrid is related to the accuracy the user has in his input data.
|
||||
* Another scaling with Grid is applied on top of it to create space in the integer number for
|
||||
* even smaller numbers.
|
||||
*/
|
||||
int GRID = (int) ( 10000.0 / DGRID ); // initial value = 10000 in kbool example but we use
|
||||
|
||||
// 10000/DGRID because the scaling is made by DGRID
|
||||
// on integer pcbnew units and the global scaling
|
||||
// ( GRID*DGRID) must be < 30000 to avoid overflow
|
||||
// in calculations (made in long long in kbool)
|
||||
if( GRID <= 1 ) // Cannot be null!
|
||||
GRID = 1;
|
||||
|
||||
aBooleng->SetMarge( MARGE );
|
||||
aBooleng->SetGrid( GRID );
|
||||
aBooleng->SetDGrid( DGRID );
|
||||
aBooleng->SetCorrectionFactor( CORRECTIONFACTOR );
|
||||
aBooleng->SetCorrectionAber( CORRECTIONABER );
|
||||
aBooleng->SetSmoothAber( SMOOTHABER );
|
||||
aBooleng->SetMaxlinemerge( MAXLINEMERGE );
|
||||
aBooleng->SetRoundfactor( ROUNDFACTOR );
|
||||
aBooleng->SetWindingRule( true ); // This is the default kbool value
|
||||
|
||||
if( aConvertHoles )
|
||||
{
|
||||
#if 1 // Can be set to 1 for kbool version >= 2.1, must be set to 0 for previous versions
|
||||
// SetAllowNonTopHoleLinking() exists only in kbool >= 2.1
|
||||
aBooleng->SetAllowNonTopHoleLinking( false ); // Default = true, but i have problems (filling errors) when true
|
||||
#endif
|
||||
aBooleng->SetLinkHoles( true ); // holes will be connected by double overlapping segments
|
||||
aBooleng->SetOrientationEntryMode( false ); // all polygons are contours, not holes
|
||||
}
|
||||
else
|
||||
{
|
||||
aBooleng->SetLinkHoles( false ); // holes will not be connected by double overlapping segments
|
||||
aBooleng->SetOrientationEntryMode( true ); // holes are entered counter clockwise
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -445,12 +38,119 @@ void armBoolEng( Bool_Engine* aBooleng, bool aConvertHoles )
|
|||
* Convert a self-intersecting polygon to one (or more) non self-intersecting polygon(s)
|
||||
* @param aNewPolygonList = a std::vector<CPolyLine*> reference where to store new CPolyLine
|
||||
* needed by the normalization
|
||||
* @return the polygon count (always >= 1, becuse there is at lesat one polygon)
|
||||
* @return the polygon count (always >= 1, because there is at least one polygon)
|
||||
* There are new polygons only if the polygon count is > 1
|
||||
*/
|
||||
#include "clipper.hpp"
|
||||
int CPolyLine::NormalizeAreaOutlines( std::vector<CPolyLine*>* aNewPolygonList )
|
||||
{
|
||||
return NormalizeWithKbool( aNewPolygonList );
|
||||
ClipperLib::Polygon raw_polygon;
|
||||
ClipperLib::Polygons normalized_polygons;
|
||||
|
||||
unsigned corners_count = m_CornersList.size();
|
||||
|
||||
KI_POLYGON_SET polysholes;
|
||||
KI_POLYGON_WITH_HOLES mainpoly;
|
||||
std::vector<KI_POLY_POINT> cornerslist;
|
||||
KI_POLYGON_WITH_HOLES_SET all_contours;
|
||||
KI_POLYGON poly_tmp;
|
||||
|
||||
// Normalize first contour
|
||||
unsigned ic = 0;
|
||||
while( ic < corners_count )
|
||||
{
|
||||
const CPolyPt& corner = m_CornersList[ic++];
|
||||
raw_polygon.push_back( ClipperLib::IntPoint( corner.x, corner.y ) );
|
||||
|
||||
if( corner.end_contour )
|
||||
break;
|
||||
}
|
||||
ClipperLib::SimplifyPolygon( raw_polygon, normalized_polygons );
|
||||
|
||||
// enter main outline
|
||||
for( unsigned ii = 0; ii < normalized_polygons.size(); ii++ )
|
||||
{
|
||||
ClipperLib::Polygon& polygon = normalized_polygons[ii];
|
||||
cornerslist.clear();
|
||||
for( unsigned jj = 0; jj < polygon.size(); jj++ )
|
||||
cornerslist.push_back( KI_POLY_POINT( (int)polygon[jj].X, (int)polygon[jj].Y ) );
|
||||
mainpoly.set( cornerslist.begin(), cornerslist.end() );
|
||||
all_contours.push_back( mainpoly );
|
||||
}
|
||||
|
||||
// Enter holes
|
||||
while( ic < corners_count )
|
||||
{
|
||||
cornerslist.clear();
|
||||
raw_polygon.clear();
|
||||
normalized_polygons.clear();
|
||||
|
||||
// Normalize current hole and add it to hole list
|
||||
while( ic < corners_count )
|
||||
{
|
||||
const CPolyPt& corner = m_CornersList[ic++];
|
||||
raw_polygon.push_back( ClipperLib::IntPoint( corner.x, corner.y ) );
|
||||
|
||||
if( corner.end_contour )
|
||||
{
|
||||
ClipperLib::SimplifyPolygon( raw_polygon, normalized_polygons );
|
||||
for( unsigned ii = 0; ii < normalized_polygons.size(); ii++ )
|
||||
{
|
||||
ClipperLib::Polygon& polygon = normalized_polygons[ii];
|
||||
cornerslist.clear();
|
||||
for( unsigned jj = 0; jj < polygon.size(); jj++ )
|
||||
cornerslist.push_back( KI_POLY_POINT( (int)polygon[jj].X, (int)polygon[jj].Y ) );
|
||||
bpl::set_points( poly_tmp, cornerslist.begin(), cornerslist.end() );
|
||||
polysholes.push_back( poly_tmp );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
all_contours -= polysholes;
|
||||
|
||||
// copy polygon with holes to destination
|
||||
RemoveAllContours();
|
||||
|
||||
#define outlines all_contours
|
||||
|
||||
for( unsigned ii = 0; ii < outlines.size(); ii++ )
|
||||
{
|
||||
CPolyLine* polyline = this;
|
||||
if( ii > 0 )
|
||||
{
|
||||
polyline = new CPolyLine;
|
||||
polyline->ImportSettings( this );
|
||||
aNewPolygonList->push_back( polyline );
|
||||
}
|
||||
|
||||
KI_POLYGON_WITH_HOLES& curr_poly = outlines[ii];
|
||||
KI_POLYGON_WITH_HOLES::iterator_type corner = curr_poly.begin();
|
||||
// enter main contour
|
||||
while( corner != curr_poly.end() )
|
||||
{
|
||||
polyline->AppendCorner( corner->x(), corner->y() );
|
||||
corner++;
|
||||
}
|
||||
polyline->CloseLastContour();
|
||||
|
||||
// add holes (set of polygons)
|
||||
KI_POLYGON_WITH_HOLES::iterator_holes_type hole = curr_poly.begin_holes();
|
||||
while( hole != curr_poly.end_holes() )
|
||||
{
|
||||
KI_POLYGON::iterator_type hole_corner = hole->begin();
|
||||
// create area with external contour: Recreate only area edges, NOT holes
|
||||
while( hole_corner != hole->end() )
|
||||
{
|
||||
polyline->AppendCorner( hole_corner->x(), hole_corner->y() );
|
||||
hole_corner++;
|
||||
}
|
||||
polyline->CloseLastContour();
|
||||
hole++;
|
||||
}
|
||||
}
|
||||
|
||||
return outlines.size();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -862,10 +562,10 @@ CRect CPolyLine::GetCornerBounds()
|
|||
|
||||
for( unsigned i = 0; i<m_CornersList.size(); i++ )
|
||||
{
|
||||
r.left = min( r.left, m_CornersList[i].x );
|
||||
r.right = max( r.right, m_CornersList[i].x );
|
||||
r.bottom = min( r.bottom, m_CornersList[i].y );
|
||||
r.top = max( r.top, m_CornersList[i].y );
|
||||
r.left = std::min( r.left, m_CornersList[i].x );
|
||||
r.right = std::max( r.right, m_CornersList[i].x );
|
||||
r.bottom = std::min( r.bottom, m_CornersList[i].y );
|
||||
r.top = std::max( r.top, m_CornersList[i].y );
|
||||
}
|
||||
|
||||
return r;
|
||||
|
@ -883,10 +583,10 @@ CRect CPolyLine::GetCornerBounds( int icont )
|
|||
|
||||
for( int i = istart; i<=iend; i++ )
|
||||
{
|
||||
r.left = min( r.left, m_CornersList[i].x );
|
||||
r.right = max( r.right, m_CornersList[i].x );
|
||||
r.bottom = min( r.bottom, m_CornersList[i].y );
|
||||
r.top = max( r.top, m_CornersList[i].y );
|
||||
r.left = std::min( r.left, m_CornersList[i].x );
|
||||
r.right = std::max( r.right, m_CornersList[i].x );
|
||||
r.bottom = std::min( r.bottom, m_CornersList[i].y );
|
||||
r.top = std::max( r.top, m_CornersList[i].y );
|
||||
}
|
||||
|
||||
return r;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
#include <kbool/include/kbool/booleng.h>
|
||||
//#include <kbool/include/kbool/booleng.h>
|
||||
#include <pad_shapes.h>
|
||||
#include <wx/gdicmn.h> // for wxPoint definition
|
||||
|
||||
|
@ -210,42 +210,11 @@ public:
|
|||
* Convert a self-intersecting polygon to one (or more) non self-intersecting polygon(s)
|
||||
* @param aNewPolygonList = a std::vector<CPolyLine*> reference where to store new CPolyLine
|
||||
* needed by the normalization
|
||||
* @return the polygon count (always >= 1, becuse there is at lesat one polygon)
|
||||
* @return the polygon count (always >= 1, because there is at least one polygon)
|
||||
* There are new polygons only if the polygon count is > 1
|
||||
*/
|
||||
int NormalizeAreaOutlines( std::vector<CPolyLine*>* aNewPolygonList );
|
||||
|
||||
// KBOOL functions
|
||||
|
||||
/**
|
||||
* Function AddPolygonsToBoolEng
|
||||
* Add a CPolyLine to a kbool engine, preparing a boolean op between polygons
|
||||
* @param aBooleng : pointer on a bool engine (handle a set of polygons)
|
||||
* @param aGroup : group to fill (aGroup = GROUP_A or GROUP_B) operations are made between GROUP_A and GROUP_B
|
||||
*/
|
||||
int AddPolygonsToBoolEng( Bool_Engine* aBooleng, GroupType aGroup );
|
||||
|
||||
/**
|
||||
* Function MakeKboolPoly
|
||||
* fill a kbool engine with a closed polyline contour
|
||||
* @return error: 0 if Ok, 1 if error
|
||||
*/
|
||||
int MakeKboolPoly();
|
||||
|
||||
/**
|
||||
* Function NormalizeWithKbool
|
||||
* Use the Kbool Library to clip contours: if outlines are crossing, the self-crossing polygon
|
||||
* is converted to non self-crossing polygon by adding extra points at the crossing locations
|
||||
* and reordering corners
|
||||
* if more than one outside contour are found, extra CPolyLines will be created
|
||||
* because copper areas have only one outside contour
|
||||
* Therefore, if this results in new CPolyLines, return them as std::vector pa
|
||||
* @param aExtraPolyList: pointer on a std::vector<CPolyLine*> to store extra CPolyLines
|
||||
* (when after normalization, there is more than one polygon with holes)
|
||||
* @return number of contours, or -1 if error
|
||||
*/
|
||||
int NormalizeWithKbool( std::vector<CPolyLine*>* aExtraPolyList );
|
||||
|
||||
// Bezier Support
|
||||
void AppendBezier( int x1, int y1, int x2, int y2, int x3, int y3 );
|
||||
void AppendBezier( int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4 );
|
||||
|
@ -277,7 +246,7 @@ private:
|
|||
// and the len of eacvh segment
|
||||
// for DIAGONAL_FULL, the pitch is twice this value
|
||||
int m_utility; // a flag used in some calculations
|
||||
Bool_Engine* m_Kbool_Poly_Engine; // polygons set in kbool engine data
|
||||
|
||||
public:
|
||||
std::vector <CPolyPt> m_CornersList; // array of points for corners
|
||||
std::vector <CSegment> m_HatchLines; // hatch lines showing the polygon area
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,306 @@
|
|||
/*******************************************************************************
|
||||
* *
|
||||
* Author : Angus Johnson *
|
||||
* Version : 4.8.5 *
|
||||
* Date : 15 July 2012 *
|
||||
* Website : http://www.angusj.com *
|
||||
* Copyright : Angus Johnson 2010-2012 *
|
||||
* *
|
||||
* License: *
|
||||
* Use, modification & distribution is subject to Boost Software License Ver 1. *
|
||||
* http://www.boost.org/LICENSE_1_0.txt *
|
||||
* *
|
||||
* Attributions: *
|
||||
* The code in this library is an extension of Bala Vatti's clipping algorithm: *
|
||||
* "A generic solution to polygon clipping" *
|
||||
* Communications of the ACM, Vol 35, Issue 7 (July 1992) pp 56-63. *
|
||||
* http://portal.acm.org/citation.cfm?id=129906 *
|
||||
* *
|
||||
* Computer graphics and geometric modeling: implementation and algorithms *
|
||||
* By Max K. Agoston *
|
||||
* Springer; 1 edition (January 4, 2005) *
|
||||
* http://books.google.com/books?q=vatti+clipping+agoston *
|
||||
* *
|
||||
* See also: *
|
||||
* "Polygon Offsetting by Computing Winding Numbers" *
|
||||
* Paper no. DETC2005-85513 pp. 565-575 *
|
||||
* ASME 2005 International Design Engineering Technical Conferences *
|
||||
* and Computers and Information in Engineering Conference (IDETC/CIE2005) *
|
||||
* September 24–28, 2005 , Long Beach, California, USA *
|
||||
* http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef clipper_hpp
|
||||
#define clipper_hpp
|
||||
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <ostream>
|
||||
|
||||
namespace ClipperLib {
|
||||
|
||||
enum ClipType { ctIntersection, ctUnion, ctDifference, ctXor };
|
||||
enum PolyType { ptSubject, ptClip };
|
||||
//By far the most widely used winding rules for polygon filling are
|
||||
//EvenOdd & NonZero (GDI, GDI+, XLib, OpenGL, Cairo, AGG, Quartz, SVG, Gr32)
|
||||
//Others rules include Positive, Negative and ABS_GTR_EQ_TWO (only in OpenGL)
|
||||
//see http://glprogramming.com/red/chapter11.html
|
||||
enum PolyFillType { pftEvenOdd, pftNonZero, pftPositive, pftNegative };
|
||||
|
||||
typedef signed long long long64;
|
||||
typedef unsigned long long ulong64;
|
||||
|
||||
struct IntPoint {
|
||||
public:
|
||||
long64 X;
|
||||
long64 Y;
|
||||
IntPoint(long64 x = 0, long64 y = 0): X(x), Y(y) {};
|
||||
friend std::ostream& operator <<(std::ostream &s, IntPoint &p);
|
||||
};
|
||||
|
||||
typedef std::vector< IntPoint > Polygon;
|
||||
typedef std::vector< Polygon > Polygons;
|
||||
|
||||
std::ostream& operator <<(std::ostream &s, Polygon &p);
|
||||
std::ostream& operator <<(std::ostream &s, Polygons &p);
|
||||
|
||||
struct ExPolygon {
|
||||
Polygon outer;
|
||||
Polygons holes;
|
||||
};
|
||||
typedef std::vector< ExPolygon > ExPolygons;
|
||||
|
||||
enum JoinType { jtSquare, jtRound, jtMiter };
|
||||
|
||||
bool Orientation(const Polygon &poly);
|
||||
double Area(const Polygon &poly);
|
||||
void OffsetPolygons(const Polygons &in_polys, Polygons &out_polys,
|
||||
double delta, JoinType jointype = jtSquare, double MiterLimit = 2);
|
||||
void SimplifyPolygon(const Polygon &in_poly, Polygons &out_polys);
|
||||
void SimplifyPolygons(const Polygons &in_polys, Polygons &out_polys);
|
||||
void SimplifyPolygons(Polygons &polys);
|
||||
|
||||
void ReversePoints(Polygon& p);
|
||||
void ReversePoints(Polygons& p);
|
||||
|
||||
//used internally ...
|
||||
enum EdgeSide { esNeither = 0, esLeft = 1, esRight = 2, esBoth = 3 };
|
||||
enum IntersectProtects { ipNone = 0, ipLeft = 1, ipRight = 2, ipBoth = 3 };
|
||||
|
||||
struct TEdge {
|
||||
long64 xbot;
|
||||
long64 ybot;
|
||||
long64 xcurr;
|
||||
long64 ycurr;
|
||||
long64 xtop;
|
||||
long64 ytop;
|
||||
double dx;
|
||||
long64 tmpX;
|
||||
PolyType polyType;
|
||||
EdgeSide side;
|
||||
int windDelta; //1 or -1 depending on winding direction
|
||||
int windCnt;
|
||||
int windCnt2; //winding count of the opposite polytype
|
||||
int outIdx;
|
||||
TEdge *next;
|
||||
TEdge *prev;
|
||||
TEdge *nextInLML;
|
||||
TEdge *nextInAEL;
|
||||
TEdge *prevInAEL;
|
||||
TEdge *nextInSEL;
|
||||
TEdge *prevInSEL;
|
||||
};
|
||||
|
||||
struct IntersectNode {
|
||||
TEdge *edge1;
|
||||
TEdge *edge2;
|
||||
IntPoint pt;
|
||||
IntersectNode *next;
|
||||
};
|
||||
|
||||
struct LocalMinima {
|
||||
long64 Y;
|
||||
TEdge *leftBound;
|
||||
TEdge *rightBound;
|
||||
LocalMinima *next;
|
||||
};
|
||||
|
||||
struct Scanbeam {
|
||||
long64 Y;
|
||||
Scanbeam *next;
|
||||
};
|
||||
|
||||
struct OutPt; //forward declaration
|
||||
|
||||
struct OutRec {
|
||||
int idx;
|
||||
bool isHole;
|
||||
OutRec *FirstLeft;
|
||||
OutRec *AppendLink;
|
||||
OutPt *pts;
|
||||
OutPt *bottomPt;
|
||||
OutPt *bottomFlag;
|
||||
EdgeSide sides;
|
||||
};
|
||||
|
||||
struct OutPt {
|
||||
int idx;
|
||||
IntPoint pt;
|
||||
OutPt *next;
|
||||
OutPt *prev;
|
||||
};
|
||||
|
||||
struct JoinRec {
|
||||
IntPoint pt1a;
|
||||
IntPoint pt1b;
|
||||
int poly1Idx;
|
||||
IntPoint pt2a;
|
||||
IntPoint pt2b;
|
||||
int poly2Idx;
|
||||
};
|
||||
|
||||
struct HorzJoinRec {
|
||||
TEdge *edge;
|
||||
int savedIdx;
|
||||
};
|
||||
|
||||
struct IntRect { long64 left; long64 top; long64 right; long64 bottom; };
|
||||
|
||||
typedef std::vector < OutRec* > PolyOutList;
|
||||
typedef std::vector < TEdge* > EdgeList;
|
||||
typedef std::vector < JoinRec* > JoinList;
|
||||
typedef std::vector < HorzJoinRec* > HorzJoinList;
|
||||
|
||||
//ClipperBase is the ancestor to the Clipper class. It should not be
|
||||
//instantiated directly. This class simply abstracts the conversion of sets of
|
||||
//polygon coordinates into edge objects that are stored in a LocalMinima list.
|
||||
class ClipperBase
|
||||
{
|
||||
public:
|
||||
ClipperBase();
|
||||
virtual ~ClipperBase();
|
||||
bool AddPolygon(const Polygon &pg, PolyType polyType);
|
||||
bool AddPolygons( const Polygons &ppg, PolyType polyType);
|
||||
virtual void Clear();
|
||||
IntRect GetBounds();
|
||||
protected:
|
||||
void DisposeLocalMinimaList();
|
||||
TEdge* AddBoundsToLML(TEdge *e);
|
||||
void PopLocalMinima();
|
||||
virtual void Reset();
|
||||
void InsertLocalMinima(LocalMinima *newLm);
|
||||
LocalMinima *m_CurrentLM;
|
||||
LocalMinima *m_MinimaList;
|
||||
bool m_UseFullRange;
|
||||
EdgeList m_edges;
|
||||
};
|
||||
|
||||
class Clipper : public virtual ClipperBase
|
||||
{
|
||||
public:
|
||||
Clipper();
|
||||
~Clipper();
|
||||
bool Execute(ClipType clipType,
|
||||
Polygons &solution,
|
||||
PolyFillType subjFillType = pftEvenOdd,
|
||||
PolyFillType clipFillType = pftEvenOdd);
|
||||
bool Execute(ClipType clipType,
|
||||
ExPolygons &solution,
|
||||
PolyFillType subjFillType = pftEvenOdd,
|
||||
PolyFillType clipFillType = pftEvenOdd);
|
||||
void Clear();
|
||||
bool ReverseSolution() {return m_ReverseOutput;};
|
||||
void ReverseSolution(bool value) {m_ReverseOutput = value;};
|
||||
protected:
|
||||
void Reset();
|
||||
virtual bool ExecuteInternal(bool fixHoleLinkages);
|
||||
private:
|
||||
PolyOutList m_PolyOuts;
|
||||
JoinList m_Joins;
|
||||
HorzJoinList m_HorizJoins;
|
||||
ClipType m_ClipType;
|
||||
Scanbeam *m_Scanbeam;
|
||||
TEdge *m_ActiveEdges;
|
||||
TEdge *m_SortedEdges;
|
||||
IntersectNode *m_IntersectNodes;
|
||||
bool m_ExecuteLocked;
|
||||
PolyFillType m_ClipFillType;
|
||||
PolyFillType m_SubjFillType;
|
||||
bool m_ReverseOutput;
|
||||
void DisposeScanbeamList();
|
||||
void SetWindingCount(TEdge& edge);
|
||||
bool IsEvenOddFillType(const TEdge& edge) const;
|
||||
bool IsEvenOddAltFillType(const TEdge& edge) const;
|
||||
void InsertScanbeam(const long64 Y);
|
||||
long64 PopScanbeam();
|
||||
void InsertLocalMinimaIntoAEL(const long64 botY);
|
||||
void InsertEdgeIntoAEL(TEdge *edge);
|
||||
void AddEdgeToSEL(TEdge *edge);
|
||||
void CopyAELToSEL();
|
||||
void DeleteFromSEL(TEdge *e);
|
||||
void DeleteFromAEL(TEdge *e);
|
||||
void UpdateEdgeIntoAEL(TEdge *&e);
|
||||
void SwapPositionsInSEL(TEdge *edge1, TEdge *edge2);
|
||||
bool IsContributing(const TEdge& edge) const;
|
||||
bool IsTopHorz(const long64 XPos);
|
||||
void SwapPositionsInAEL(TEdge *edge1, TEdge *edge2);
|
||||
void DoMaxima(TEdge *e, long64 topY);
|
||||
void ProcessHorizontals();
|
||||
void ProcessHorizontal(TEdge *horzEdge);
|
||||
void AddLocalMaxPoly(TEdge *e1, TEdge *e2, const IntPoint &pt);
|
||||
void AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &pt);
|
||||
void AppendPolygon(TEdge *e1, TEdge *e2);
|
||||
void DoEdge1(TEdge *edge1, TEdge *edge2, const IntPoint &pt);
|
||||
void DoEdge2(TEdge *edge1, TEdge *edge2, const IntPoint &pt);
|
||||
void DoBothEdges(TEdge *edge1, TEdge *edge2, const IntPoint &pt);
|
||||
void IntersectEdges(TEdge *e1, TEdge *e2,
|
||||
const IntPoint &pt, IntersectProtects protects);
|
||||
OutRec* CreateOutRec();
|
||||
void AddOutPt(TEdge *e, const IntPoint &pt);
|
||||
void DisposeBottomPt(OutRec &outRec);
|
||||
void DisposeAllPolyPts();
|
||||
void DisposeOutRec(PolyOutList::size_type index);
|
||||
bool ProcessIntersections(const long64 botY, const long64 topY);
|
||||
void AddIntersectNode(TEdge *e1, TEdge *e2, const IntPoint &pt);
|
||||
void BuildIntersectList(const long64 botY, const long64 topY);
|
||||
void ProcessIntersectList();
|
||||
void ProcessEdgesAtTopOfScanbeam(const long64 topY);
|
||||
void BuildResult(Polygons& polys);
|
||||
void BuildResultEx(ExPolygons& polys);
|
||||
void SetHoleState(TEdge *e, OutRec *OutRec);
|
||||
void DisposeIntersectNodes();
|
||||
bool FixupIntersections();
|
||||
void FixupOutPolygon(OutRec &outRec);
|
||||
bool IsHole(TEdge *e);
|
||||
void FixHoleLinkage(OutRec *outRec);
|
||||
void CheckHoleLinkages1(OutRec *outRec1, OutRec *outRec2);
|
||||
void CheckHoleLinkages2(OutRec *outRec1, OutRec *outRec2);
|
||||
void AddJoin(TEdge *e1, TEdge *e2, int e1OutIdx = -1, int e2OutIdx = -1);
|
||||
void ClearJoins();
|
||||
void AddHorzJoin(TEdge *e, int idx);
|
||||
void ClearHorzJoins();
|
||||
void JoinCommonEdges(bool fixHoleLinkages);
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
class clipperException : public std::exception
|
||||
{
|
||||
public:
|
||||
clipperException(const char* description): m_descr(description) {}
|
||||
virtual ~clipperException() throw() {}
|
||||
virtual const char* what() const throw() {return m_descr.c_str();}
|
||||
private:
|
||||
std::string m_descr;
|
||||
};
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
} //ClipperLib namespace
|
||||
|
||||
#endif //clipper_hpp
|
||||
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
project(kbool)
|
||||
|
||||
subdirs(src)
|
File diff suppressed because it is too large
Load Diff
|
@ -1,407 +0,0 @@
|
|||
/*! \file _dl_itr.h
|
||||
\author Klaas Holwerda
|
||||
|
||||
Copyright: 2001-2004 (C) Klaas Holwerda
|
||||
|
||||
Licence: see kboollicense.txt
|
||||
|
||||
RCS-ID: $Id: _dl_itr.h,v 1.6 2009/09/10 17:04:09 titato Exp $
|
||||
*/
|
||||
|
||||
//! author="Klaas Holwerda"
|
||||
/*
|
||||
* Definitions of classes, for list implementation
|
||||
* template list and iterator for any list node type
|
||||
*/
|
||||
|
||||
#ifndef _DL_Iter_H
|
||||
#define _DL_Iter_H
|
||||
|
||||
#define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES 1
|
||||
#define _CRT_SECURE_NO_DEPRECATE 1
|
||||
|
||||
#include "kbool/booleng.h"
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#ifndef _STATUS_ENUM
|
||||
#define _STATUS_ENUM
|
||||
//!<enum Error codes for List and iterator class
|
||||
enum Lerror {
|
||||
NO_MES, /*!<No Message will be generated */
|
||||
NO_LIST, /*!<List is not attached to the iterator*/
|
||||
NO_LIST_OTHER, /*!<no attached list on other iter*/
|
||||
AC_ITER_LIST_OTHER, /*!<iter not allowed on other list */
|
||||
SAME_LIST, /*!<same list not allowed*/
|
||||
NOT_SAME_LIST, /*!<must be same list*/
|
||||
ITER_GT_1, /*!<more then one iteriter at root*/
|
||||
ITER_GT_0, /*!<iter not allowed*/
|
||||
ITER_HITROOT, /*!<iter at root*/
|
||||
NO_ITEM, /*!<no item at current*/
|
||||
NO_NEXT, /*!<no next after current*/
|
||||
NO_PREV, /*!<no prev before current */
|
||||
EMPTY, /*!<list is empty*/
|
||||
NOT_ALLOW, /*!<not allowed*/
|
||||
ITER_NEG /*!<to much iters deleted*/
|
||||
};
|
||||
#endif
|
||||
|
||||
#define SWAP(x,y,t)((t)=(x),(x)=(y),(y)=(t))
|
||||
#define RT _list->_root
|
||||
#define HD _list->_root->_next
|
||||
#define TL _list->_root->_prev
|
||||
#define NB _list->_nbitems
|
||||
|
||||
template <class Dtype> class DL_List;
|
||||
template <class Dtype> class DL_Iter;
|
||||
template <class Dtype> class DL_SortIter;
|
||||
|
||||
//! Template class DL_Node
|
||||
template <class Dtype> class DL_Node
|
||||
{
|
||||
friend class DL_List<Dtype>;
|
||||
friend class DL_Iter<Dtype>;
|
||||
friend class DL_SortIter<Dtype>;
|
||||
|
||||
//!Public members
|
||||
public:
|
||||
//!Template constructor no contents
|
||||
//!Construct a node for a list object
|
||||
DL_Node();
|
||||
|
||||
//!constructor with init of Dtype
|
||||
DL_Node( Dtype n );
|
||||
|
||||
//!Destructor
|
||||
~DL_Node();
|
||||
|
||||
//!Public members
|
||||
public:
|
||||
//!data in node
|
||||
Dtype _item;
|
||||
|
||||
//!pointer to next node
|
||||
DL_Node* _next;
|
||||
|
||||
//!pointer to previous node
|
||||
DL_Node* _prev;
|
||||
};
|
||||
|
||||
//!Template class DL_List
|
||||
template <class Dtype> class DL_List
|
||||
{
|
||||
friend class DL_Iter<Dtype>;
|
||||
friend class DL_SortIter<Dtype>;
|
||||
|
||||
public:
|
||||
//!Constructor
|
||||
//!Construct a list object
|
||||
//!!tcarg class | Dtype | list object
|
||||
DL_List();
|
||||
|
||||
//!destructor
|
||||
~DL_List();
|
||||
|
||||
//!Report off List Errors
|
||||
void Error( string function, Lerror a_error );
|
||||
|
||||
//!Number of items in the list
|
||||
int count();
|
||||
|
||||
//!Empty List?
|
||||
bool empty();
|
||||
|
||||
//!insert the object given at the end of the list, after tail
|
||||
DL_Node<Dtype>* insend( Dtype n );
|
||||
|
||||
//!insert the object given at the begin of the list, before head
|
||||
DL_Node<Dtype>* insbegin( Dtype n );
|
||||
|
||||
//!remove the object at the begin of the list (head)
|
||||
void removehead();
|
||||
|
||||
//! remove the object at the end of the list (tail)
|
||||
void removetail();
|
||||
|
||||
//!remove all objects from the list
|
||||
void remove_all( bool deleteObject = false );
|
||||
|
||||
//!Get the item at the head of the list
|
||||
Dtype headitem();
|
||||
|
||||
//!Get the item at the tail of the list
|
||||
Dtype tailitem();
|
||||
|
||||
//! to move all objects in a list to this list.
|
||||
void takeover( DL_List<Dtype>* otherlist );
|
||||
|
||||
public:
|
||||
//!the root node pointer of the list, the first and last node
|
||||
//! in the list are connected to the root node. The root node is used
|
||||
//! to detect the end / beginning of the list while traversing it.
|
||||
DL_Node<Dtype>* _root;
|
||||
|
||||
//!the number of items in the list, if empty list it is 0
|
||||
int _nbitems;
|
||||
|
||||
//!number of iterators on the list, Attaching or instantiating an iterator to list,
|
||||
//! will increment this member, detaching and
|
||||
//! destruction of iterator for a list will decrement this number
|
||||
short int _iterlevel;
|
||||
};
|
||||
|
||||
//! Template class DL_Iter for iterator on DL_List
|
||||
template <class Dtype>
|
||||
class DL_Iter
|
||||
{
|
||||
public:
|
||||
//!Construct an iterator object for a given list of type Dtype
|
||||
DL_Iter( DL_List<Dtype>* newlist );
|
||||
|
||||
//!Constructor of iterator for the same list as another iterator
|
||||
DL_Iter( DL_Iter* otheriter );
|
||||
|
||||
//!Constructor without an attached list
|
||||
DL_Iter();
|
||||
|
||||
//!destructor
|
||||
~DL_Iter();
|
||||
|
||||
//!Report off Iterator Errors
|
||||
void Error( string function, Lerror a_error );
|
||||
|
||||
//!This attaches an iterator to a list of a given type.
|
||||
void Attach( DL_List<Dtype>* newlist );
|
||||
|
||||
//!This detaches an iterator from a list
|
||||
void Detach();
|
||||
|
||||
//!execute given function for each item in the list/iterator
|
||||
void foreach_f( void ( *fp ) ( Dtype n ) );
|
||||
|
||||
//! list mutations
|
||||
|
||||
//!insert after tail item
|
||||
DL_Node<Dtype>* insend( Dtype n );
|
||||
|
||||
//!insert before head item
|
||||
DL_Node<Dtype>* insbegin( Dtype n );
|
||||
|
||||
//!insert before current iterator position
|
||||
DL_Node<Dtype>* insbefore( Dtype n );
|
||||
|
||||
//!insert after current iterator position
|
||||
DL_Node<Dtype>* insafter( Dtype n );
|
||||
|
||||
//!to move all objects in a list to the list of the iterator.
|
||||
void takeover( DL_List<Dtype>* otherlist );
|
||||
|
||||
//!to move all objects in a list (using iterator of that list) to the list of the iterator
|
||||
void takeover( DL_Iter* otheriter );
|
||||
|
||||
//! to move maxcount objects in a list (using iterator of that list) to the list of the iterator
|
||||
void takeover( DL_Iter* otheriter, int maxcount );
|
||||
|
||||
//!remove object at current iterator position from the list.
|
||||
void remove();
|
||||
|
||||
//!Remove head item
|
||||
void removehead();
|
||||
|
||||
//!Remove tail item
|
||||
void removetail();
|
||||
|
||||
//!Remove all items
|
||||
void remove_all();
|
||||
|
||||
|
||||
/* void foreach_mf(void (Dtype::*mfp)() ); //call Dtype::mfp for each item */
|
||||
|
||||
//!is list empty (contains items or not)?
|
||||
bool empty();
|
||||
|
||||
//!is iterator at root node (begin or end)?
|
||||
bool hitroot();
|
||||
|
||||
//!is iterator at head/first node?
|
||||
bool athead();
|
||||
|
||||
//!is iterator at tail/last node?
|
||||
bool attail();
|
||||
|
||||
//!is given item member of the list
|
||||
bool has( Dtype otheritem );
|
||||
|
||||
//!Number of items in the list
|
||||
int count();
|
||||
|
||||
/* cursor movements */
|
||||
|
||||
//!go to last item, if list is empty goto hite
|
||||
void totail();
|
||||
|
||||
//!go to first item, if list is empty goto hite
|
||||
void tohead();
|
||||
|
||||
//!set the iterator position to the root (empty dummy) object in the list.
|
||||
void toroot();
|
||||
|
||||
//! set the iterator position to next object in the list ( can be the root also).
|
||||
void operator++ ( void );
|
||||
|
||||
//!set iterator to next item (pre fix)
|
||||
void operator++ ( int );
|
||||
|
||||
//!set the iterator position to previous object in the list ( can be the root also)(postfix).
|
||||
void operator-- ( void );
|
||||
|
||||
//!set the iterator position to previous object in the list ( can be the root also)(pre fix).
|
||||
void operator-- ( int );
|
||||
|
||||
//!set the iterator position n objects in the next direction ( can be the root also).
|
||||
void operator>> ( int );
|
||||
|
||||
//!set the iterator position n objects in the previous direction ( can be the root also).
|
||||
void operator<< ( int );
|
||||
|
||||
//!set the iterator position to next object in the list, if this would be the root object,
|
||||
//!then set the iterator at the head object
|
||||
void next_wrap();
|
||||
|
||||
//!set the iterator position to previous object in the list, if this would be the root object,
|
||||
//!then set the iterator at the tail object
|
||||
void prev_wrap();
|
||||
|
||||
//!move root in order to make the current node the tail
|
||||
void reset_tail();
|
||||
|
||||
//!move root in order to make the current node the head
|
||||
void reset_head();
|
||||
|
||||
//!put the iterator at the position of the given object in the list.
|
||||
bool toitem( Dtype );
|
||||
|
||||
//!put the iterator at the same position as the given iterator in the list.
|
||||
void toiter( DL_Iter* otheriter );
|
||||
|
||||
//!put the iterator at the position of the given node in the list.
|
||||
bool tonode( DL_Node<Dtype>* );
|
||||
|
||||
//!iterate through all items of the list
|
||||
bool iterate( void );
|
||||
|
||||
//!To get the item at the current iterator position
|
||||
Dtype item();
|
||||
|
||||
//! get node at iterator
|
||||
DL_Node<Dtype>* node();
|
||||
|
||||
//!sort list with mergesort
|
||||
void mergesort( int ( *fcmp ) ( Dtype, Dtype ) );
|
||||
|
||||
//!sort list with cocktailsort
|
||||
/*!
|
||||
\return number of swaps done.
|
||||
*/
|
||||
int cocktailsort( int ( * )( Dtype, Dtype ), bool ( * )( Dtype, Dtype ) = NULL );
|
||||
|
||||
protected:
|
||||
|
||||
//!sort list with mergesort
|
||||
void mergesort_rec( int ( *fcmp )( Dtype, Dtype ), DL_Node<Dtype> *RT1, int n );
|
||||
|
||||
//!sort list with mergesort
|
||||
void mergetwo( int ( *fcmp )( Dtype, Dtype ), DL_Node<Dtype> *RT1, DL_Node<Dtype> *RT2 );
|
||||
|
||||
//!set the iterator position to next object in the list ( can be the root also).
|
||||
void next();
|
||||
|
||||
//!set the iterator position to previous object in the list ( can be the root also).
|
||||
void prev();
|
||||
|
||||
//!the list for this iterator
|
||||
DL_List<Dtype> *_list;
|
||||
|
||||
//!the current position of the iterator
|
||||
DL_Node<Dtype> *_current;
|
||||
};
|
||||
|
||||
|
||||
//! template class DL_StackIter class for stack iterator on DL_List
|
||||
template <class Dtype>
|
||||
class DL_StackIter : protected DL_Iter<Dtype>
|
||||
{
|
||||
public:
|
||||
//!Constructor of stack iterator for given list
|
||||
DL_StackIter( DL_List<Dtype> * );
|
||||
//!Constructor of stack iterator no list attached
|
||||
DL_StackIter();
|
||||
|
||||
//!Destructor of stack iterator
|
||||
~DL_StackIter();
|
||||
|
||||
//!Remove all items from the stack
|
||||
void remove_all();
|
||||
//!push given item on the stack
|
||||
void push( Dtype n );
|
||||
//!get last inserted item from stack
|
||||
Dtype pop();
|
||||
//!is stack empty?
|
||||
bool empty();
|
||||
//!number of items on the stack
|
||||
int count();
|
||||
};
|
||||
|
||||
//!template class DL_SortIter
|
||||
template <class DType> class DL_SortIter : public DL_Iter<DType>
|
||||
{
|
||||
public:
|
||||
//!Constructor of sort iterator for given list and sort function
|
||||
DL_SortIter( DL_List<DType>* nw_list, int ( *new_func )( DType , DType ) );
|
||||
|
||||
//!Constructor of sort iterator with sort function and no list attached
|
||||
DL_SortIter( int ( *newfunc )( DType, DType ) );
|
||||
|
||||
//!Destructor of sort iterator
|
||||
~DL_SortIter();
|
||||
|
||||
//!insert item in sorted order
|
||||
void insert ( DType new_item );
|
||||
|
||||
/*override following functions to give an error */
|
||||
//!Not allowed
|
||||
void insend ( bool n ){sortitererror();};
|
||||
//!Not allowed
|
||||
void insbegin ( bool n ){sortitererror();};
|
||||
//!Not allowed
|
||||
void insbefore ( bool n ){sortitererror();};
|
||||
//!Not allowed
|
||||
void insafter ( bool n ){sortitererror();};
|
||||
//!Not allowed
|
||||
void takeover ( DL_List<DType>* ){sortitererror();};
|
||||
//!Not allowed
|
||||
void takeover ( DL_Iter<DType>* ){sortitererror();};
|
||||
//!Not allowed
|
||||
void takeover ( DL_Iter<DType>* otheriter, int maxcount ){sortitererror();};
|
||||
//!Not allowed
|
||||
void next_wrap() {sortitererror();};
|
||||
//!Not allowed
|
||||
void prev_wrap() {sortitererror();};
|
||||
//!Not allowed
|
||||
void reset_tail() {sortitererror();};
|
||||
//!Not allowed
|
||||
void reset_head() {sortitererror();};
|
||||
|
||||
private:
|
||||
//!Report off Iterator Errors
|
||||
void sortitererror();
|
||||
|
||||
//!comparefunction used to insert items in sorted order
|
||||
int ( *comparef )( DType, DType );
|
||||
};
|
||||
|
||||
#include "kbool/_dl_itr.cpp"
|
||||
|
||||
#endif
|
|
@ -1,257 +0,0 @@
|
|||
/*! \file _lnk_itr.cpp
|
||||
\author Probably Klaas Holwerda
|
||||
|
||||
Copyright: 2001-2004 (C) Probably Klaas Holwerda
|
||||
|
||||
Licence: see kboollicense.txt
|
||||
|
||||
RCS-ID: $Id: _lnk_itr.cpp,v 1.4 2009/02/06 21:33:03 titato Exp $
|
||||
*/
|
||||
|
||||
#ifdef __UNIX__
|
||||
#include "kbool/_lnk_itr.h"
|
||||
#endif
|
||||
|
||||
//=======================================================================
|
||||
// implementation class LinkBaseIter
|
||||
//=======================================================================
|
||||
|
||||
template<class Type>
|
||||
TDLI<Type>::TDLI( DL_List<void*>* newlist ): DL_Iter<void*>( newlist )
|
||||
{}
|
||||
|
||||
template<class Type>
|
||||
TDLI<Type>::TDLI( DL_Iter<void*>* otheriter ): DL_Iter<void*>( otheriter )
|
||||
{}
|
||||
|
||||
template<class Type>
|
||||
TDLI<Type>::TDLI(): DL_Iter<void*>()
|
||||
{}
|
||||
|
||||
// destructor TDLI
|
||||
template<class Type>
|
||||
TDLI<Type>::~TDLI()
|
||||
{}
|
||||
|
||||
template<class Type>
|
||||
void TDLI<Type>::delete_all()
|
||||
{
|
||||
DL_Node<void*>* node;
|
||||
Type* obj;
|
||||
for ( int i = 0; i < NB; i++ )
|
||||
{
|
||||
node = HD;
|
||||
HD = node->_next;
|
||||
obj = ( Type* )( node->_item );
|
||||
delete obj;
|
||||
delete node;
|
||||
}
|
||||
NB = 0; //reset memory used (no lost pointers)
|
||||
TL = RT;
|
||||
_current = RT;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
void TDLI<Type>::foreach_f( void ( *fp ) ( Type* item ) )
|
||||
{
|
||||
DL_Iter<void*>::foreach_f( ( void ( * )( void* ) )fp ); //call fp for each item
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
void TDLI<Type>::foreach_mf( void ( Type::*mfp ) () )
|
||||
{
|
||||
|
||||
DL_Node<void*>* node = HD; //can be 0 if empty
|
||||
Type* obj;
|
||||
for( int i = 0; i < NB; i++ )
|
||||
{
|
||||
obj = ( Type* )( node->_item );
|
||||
( obj->*mfp )();
|
||||
node = node->_next;
|
||||
}
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
void TDLI<Type>::takeover( DL_List<void*>* otherlist )
|
||||
{
|
||||
DL_Iter<void*>::takeover( ( DL_List<void*>* ) otherlist );
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
void TDLI<Type>::takeover( TDLI* otheriter )
|
||||
{
|
||||
DL_Iter<void*>::takeover( ( DL_Iter<void*>* ) otheriter );
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
void TDLI<Type>::takeover( TDLI* otheriter, int maxcount )
|
||||
{
|
||||
DL_Iter<void*>::takeover( ( DL_Iter<void*>* ) otheriter, maxcount );
|
||||
}
|
||||
|
||||
// is item element of the list?
|
||||
template<class Type>
|
||||
bool TDLI<Type>::has( Type* otheritem )
|
||||
{
|
||||
return DL_Iter<void*>::has( ( void* ) otheritem );
|
||||
}
|
||||
|
||||
// goto to item
|
||||
template<class Type>
|
||||
bool TDLI<Type>::toitem( Type* item )
|
||||
{
|
||||
return DL_Iter<void*>::toitem( ( void* ) item );
|
||||
}
|
||||
|
||||
// get current item
|
||||
template<class Type>
|
||||
Type* TDLI<Type>::item()
|
||||
{
|
||||
return ( Type* ) DL_Iter<void*>::item();
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
void TDLI<Type>::insend( Type* newitem )
|
||||
{
|
||||
DL_Iter<void*>::insend( ( void* ) newitem );
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
void TDLI<Type>::insbegin( Type* newitem )
|
||||
{
|
||||
DL_Iter<void*>::insbegin( ( void* ) newitem );
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
void TDLI<Type>::insbefore( Type* newitem )
|
||||
{
|
||||
DL_Iter<void*>::insbefore( ( void* ) newitem );
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
void TDLI<Type>::insafter( Type* newitem )
|
||||
{
|
||||
DL_Iter<void*>::insafter( ( void* ) newitem );
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
void TDLI<Type>::insend_unsave( Type* newitem )
|
||||
{
|
||||
short int iterbackup = _list->_iterlevel;
|
||||
_list->_iterlevel = 0;
|
||||
DL_Iter<void*>::insend( ( void* ) newitem );
|
||||
_list->_iterlevel = iterbackup;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
void TDLI<Type>::insbegin_unsave( Type* newitem )
|
||||
{
|
||||
short int iterbackup = _list->_iterlevel;
|
||||
_list->_iterlevel = 0;
|
||||
DL_Iter<void*>::insbegin( ( void* ) newitem );
|
||||
_list->_iterlevel = iterbackup;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
void TDLI<Type>::insbefore_unsave( Type* newitem )
|
||||
{
|
||||
short int iterbackup = _list->_iterlevel;
|
||||
_list->_iterlevel = 0;
|
||||
DL_Iter<void*>::insbefore( ( void* ) newitem );
|
||||
_list->_iterlevel = iterbackup;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
void TDLI<Type>::insafter_unsave( Type* newitem )
|
||||
{
|
||||
short int iterbackup = _list->_iterlevel;
|
||||
_list->_iterlevel = 0;
|
||||
DL_Iter<void*>::insafter( ( void* ) newitem );
|
||||
_list->_iterlevel = iterbackup;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
void TDLI<Type>::mergesort( int ( *f )( Type* a, Type* b ) )
|
||||
{
|
||||
DL_Iter<void*>::mergesort( ( int ( * )( void*, void* ) ) f );
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
int TDLI<Type>::cocktailsort( int ( *f )( Type* a, Type* b ), bool ( *f2 )( Type* c, Type* d ) )
|
||||
{
|
||||
return DL_Iter<void*>::cocktailsort( ( int ( * )( void*, void* ) ) f, ( bool( * )( void*, void* ) ) f2 );
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
TDLISort<Type>::TDLISort( DL_List<void*>* lista, int ( *newfunc )( void*, void* ) )
|
||||
: DL_SortIter<void*>( lista, newfunc )
|
||||
{}
|
||||
|
||||
template<class Type>
|
||||
TDLISort<Type>::~TDLISort()
|
||||
{}
|
||||
|
||||
template<class Type>
|
||||
void TDLISort<Type>::delete_all()
|
||||
{
|
||||
DL_Node<void*>* node;
|
||||
Type* obj;
|
||||
for ( int i = 0; i < NB; i++ )
|
||||
{
|
||||
node = HD;
|
||||
HD = node->_next;
|
||||
obj = ( Type* )( node->_item );
|
||||
delete obj;
|
||||
delete node;
|
||||
}
|
||||
NB = 0; //reset memory used (no lost pointers)
|
||||
TL = RT;
|
||||
_current = RT;
|
||||
}
|
||||
|
||||
// is item element of the list?
|
||||
template<class Type>
|
||||
bool TDLISort<Type>::has( Type* otheritem )
|
||||
{
|
||||
return DL_Iter<void*>::has( ( void* ) otheritem );
|
||||
}
|
||||
|
||||
// goto to item
|
||||
template<class Type>
|
||||
bool TDLISort<Type>::toitem( Type* item )
|
||||
{
|
||||
return DL_Iter<void*>::toitem( ( void* ) item );
|
||||
}
|
||||
|
||||
// get current item
|
||||
template<class Type>
|
||||
Type* TDLISort<Type>::item()
|
||||
{
|
||||
return ( Type* ) DL_Iter<void*>::item();
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
TDLIStack<Type>::TDLIStack( DL_List<void*>* newlist ): DL_StackIter<void*>( newlist )
|
||||
{}
|
||||
|
||||
// destructor TDLI
|
||||
template<class Type>
|
||||
TDLIStack<Type>::~TDLIStack()
|
||||
{}
|
||||
|
||||
// plaats nieuw item op stack
|
||||
template<class Type>
|
||||
void TDLIStack<Type>::push( Type* newitem )
|
||||
{
|
||||
DL_StackIter<void*>::push( ( Type* ) newitem );
|
||||
}
|
||||
|
||||
|
||||
// haal bovenste item van stack
|
||||
template<class Type>
|
||||
Type* TDLIStack<Type>::pop()
|
||||
{
|
||||
return ( Type* ) DL_StackIter<void*>::pop();
|
||||
}
|
||||
|
||||
|
|
@ -1,159 +0,0 @@
|
|||
/*! \file _lnk_itr.h
|
||||
\author Klaas Holwerda
|
||||
|
||||
Copyright: 2001-2004 (C) Klaas Holwerda
|
||||
|
||||
Licence: see kboollicense.txt
|
||||
|
||||
RCS-ID: $Id: _lnk_itr.h,v 1.4 2009/09/10 17:04:09 titato Exp $
|
||||
*/
|
||||
|
||||
//! author="Klaas Holwerda"
|
||||
//! version="1.0"
|
||||
/*
|
||||
* Definitions of classes, for list implementation
|
||||
* template list and iterator for any list node type
|
||||
*/
|
||||
#ifndef _LinkBaseIter_H
|
||||
#define _LinkBaseIter_H
|
||||
|
||||
//! headerfiles="_dl_itr.h stdlib.h misc.h gdsmes.h"
|
||||
#include <stdlib.h>
|
||||
#include "kbool/booleng.h"
|
||||
|
||||
#define SWAP(x,y,t)((t)=(x),(x)=(y),(y)=(t))
|
||||
|
||||
#include "kbool/_dl_itr.h"
|
||||
|
||||
//! codefiles="_dl_itr.cpp"
|
||||
|
||||
//! Template class TDLI
|
||||
/*!
|
||||
class for iterator on DL_List<void*> that is type casted version of DL_Iter
|
||||
\sa DL_Iter for further documentation
|
||||
*/
|
||||
template<class Type> class TDLI : public DL_Iter<void*>
|
||||
{
|
||||
public:
|
||||
//!constructor
|
||||
/*!
|
||||
\param list to iterate on.
|
||||
*/
|
||||
TDLI( DL_List<void*>* list );
|
||||
|
||||
//!constructor
|
||||
TDLI( DL_Iter<void*>* otheriter );
|
||||
|
||||
//! nolist constructor
|
||||
TDLI();
|
||||
|
||||
//! destructor
|
||||
~TDLI();
|
||||
|
||||
//!call fp for each item
|
||||
void foreach_f( void ( *fp ) ( Type* item ) );
|
||||
|
||||
//!call fp for each item
|
||||
void foreach_mf( void ( Type::*fp ) () );
|
||||
|
||||
/* list mutations */
|
||||
|
||||
|
||||
//! delete all items
|
||||
void delete_all ();
|
||||
|
||||
|
||||
//! insert at end
|
||||
void insend ( Type* n );
|
||||
|
||||
//! insert at begin
|
||||
void insbegin ( Type* n );
|
||||
|
||||
//! insert before current
|
||||
void insbefore ( Type* n );
|
||||
|
||||
//! insert after current
|
||||
void insafter ( Type* n );
|
||||
|
||||
//! insert at end unsave (works even if more then one iterator is on the list
|
||||
//! the user must be sure not to delete/remove items where other iterators
|
||||
//! are pointing to.
|
||||
void insend_unsave ( Type* n );
|
||||
|
||||
//! insert at begin unsave (works even if more then one iterator is on the list
|
||||
//! the user must be sure not to delete/remove items where other iterators
|
||||
//! are pointing to.
|
||||
void insbegin_unsave ( Type* n );
|
||||
|
||||
//! insert before iterator position unsave (works even if more then one iterator is on the list
|
||||
//! the user must be sure not to delete/remove items where other iterators
|
||||
//! are pointing to.
|
||||
void insbefore_unsave ( Type* n );
|
||||
|
||||
//! insert after iterator position unsave (works even if more then one iterator is on the list
|
||||
//! the user must be sure not to delete/remove items where other iterators
|
||||
//! are pointing to.
|
||||
void insafter_unsave ( Type* n );
|
||||
|
||||
//! \sa DL_Iter::takeover(DL_List< Dtype >* otherlist )
|
||||
void takeover ( DL_List<void*>* otherlist );
|
||||
//! \sa DL_Iter::takeover(DL_Iter* otheriter)
|
||||
void takeover ( TDLI* otheriter );
|
||||
//! \sa DL_Iter::takeover(DL_Iter* otheriter, int maxcount)
|
||||
void takeover ( TDLI* otheriter, int maxcount );
|
||||
|
||||
//! \sa DL_Iter::has
|
||||
bool has ( Type* );
|
||||
//! \sa DL_Iter::toitem
|
||||
bool toitem ( Type* );
|
||||
|
||||
//!get the item then iterator is pointing at
|
||||
Type* item ();
|
||||
|
||||
//! \sa DL_Iter::mergesort
|
||||
void mergesort ( int ( *f )( Type* a, Type* b ) );
|
||||
//! \sa DL_Iter::cocktailsort
|
||||
int cocktailsort( int ( * ) ( Type* a, Type* b ), bool ( * ) ( Type* c, Type* d ) = NULL );
|
||||
|
||||
};
|
||||
|
||||
//! Template class TDLIsort
|
||||
/*!
|
||||
// class for sort iterator on DL_List<void*> that is type casted version of DL_SortIter
|
||||
// see also inhereted class DL_SortIter for further documentation
|
||||
*/
|
||||
template<class Type> class TDLISort : public DL_SortIter<void*>
|
||||
{
|
||||
public:
|
||||
|
||||
//!constructor givin a list and a sort function
|
||||
TDLISort( DL_List<void*>* list, int ( *newfunc )( void*, void* ) );
|
||||
~TDLISort();
|
||||
|
||||
//!delete all items from the list
|
||||
void delete_all();
|
||||
bool has ( Type* );
|
||||
bool toitem ( Type* );
|
||||
Type* item ();
|
||||
};
|
||||
|
||||
//! Template class TDLIStack
|
||||
/*!
|
||||
class for iterator on DL_List<void*> that is type casted version of DL_StackIter
|
||||
see also inhereted class DL_StackIter for further documentation
|
||||
*/
|
||||
template<class Type> class TDLIStack : public DL_StackIter<void*>
|
||||
{
|
||||
public:
|
||||
//constructor givin a list
|
||||
TDLIStack( DL_List<void*>* list );
|
||||
|
||||
~TDLIStack();
|
||||
|
||||
void push( Type* );
|
||||
Type* pop();
|
||||
};
|
||||
|
||||
#include"kbool/_lnk_itr.cpp"
|
||||
|
||||
#endif
|
|
@ -1,596 +0,0 @@
|
|||
/*! \file booleng.h
|
||||
\author Klaas Holwerda
|
||||
|
||||
Copyright: 2001-2004 (C) Klaas Holwerda
|
||||
|
||||
Licence: see kboollicense.txt
|
||||
|
||||
RCS-ID: $Id: booleng.h,v 1.9 2009/09/14 18:18:03 titato Exp $
|
||||
*/
|
||||
|
||||
#ifndef BOOLENG_H
|
||||
#define BOOLENG_H
|
||||
|
||||
#undef _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES
|
||||
#define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES 1
|
||||
#define _CRT_SECURE_NO_DEPRECATE 1
|
||||
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
#if 0 // Kicad does not use kbool in dll version
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
/*
|
||||
__declspec works in BC++ 5 and later, Watcom C++ 11.0 and later as well
|
||||
as VC++ and gcc
|
||||
*/
|
||||
# if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__GNUC__) || defined(__WATCOMC__)
|
||||
# define WXEXPORT __declspec(dllexport)
|
||||
# define WXIMPORT __declspec(dllimport)
|
||||
# else /* compiler doesn't support __declspec() */
|
||||
# define WXEXPORT
|
||||
# define WXIMPORT
|
||||
# endif
|
||||
#elif defined(__WXPM__)
|
||||
# if defined (__WATCOMC__)
|
||||
# define WXEXPORT __declspec(dllexport)
|
||||
/*
|
||||
__declspec(dllimport) prepends __imp to imported symbols. We do NOT
|
||||
want that!
|
||||
*/
|
||||
# define WXIMPORT
|
||||
# elif defined(__EMX__)
|
||||
# define WXEXPORT
|
||||
# define WXIMPORT
|
||||
# elif (!(defined(__VISAGECPP__) && (__IBMCPP__ < 400 || __IBMC__ < 400 )))
|
||||
# define WXEXPORT _Export
|
||||
# define WXIMPORT _Export
|
||||
# endif
|
||||
#elif defined(__WXMAC__) || defined(__WXCOCOA__)
|
||||
# ifdef __MWERKS__
|
||||
# define WXEXPORT __declspec(export)
|
||||
# define WXIMPORT __declspec(import)
|
||||
# endif
|
||||
#elif defined(__CYGWIN__)
|
||||
# define WXEXPORT __declspec(dllexport)
|
||||
# define WXIMPORT __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#endif // if 0 for kicad
|
||||
|
||||
/* for other platforms/compilers we don't anything */
|
||||
#ifndef WXEXPORT
|
||||
# define WXEXPORT
|
||||
# define WXIMPORT
|
||||
#endif
|
||||
|
||||
#ifdef A2DKBOOLMAKINGDLL
|
||||
#define A2DKBOOLDLLEXP WXEXPORT
|
||||
#define A2DKBOOLDLLEXP_DATA(type) WXEXPORT type
|
||||
#define A2DKBOOLDLLEXP_CTORFN
|
||||
#elif defined(WXART2D_USINGDLL)
|
||||
#define A2DKBOOLDLLEXP WXIMPORT
|
||||
#define A2DKBOOLDLLEXP_DATA(type) WXIMPORT type
|
||||
#define A2DKBOOLDLLEXP_CTORFN
|
||||
#else // not making nor using DLL
|
||||
#define A2DKBOOLDLLEXP
|
||||
#define A2DKBOOLDLLEXP_DATA(type) type
|
||||
#define A2DKBOOLDLLEXP_CTORFN
|
||||
#endif
|
||||
|
||||
#define KBOOL_VERSION "2.1"
|
||||
|
||||
#define KBOOL_DEBUG 0
|
||||
#define KBOOL_LOG 0
|
||||
#define KBOOL_INT64 1
|
||||
|
||||
class kbLink;
|
||||
|
||||
#define LINELENGTH 200
|
||||
|
||||
#ifdef MAXDOUBLE
|
||||
#undef MAXDOUBLE
|
||||
#endif
|
||||
#define MAXDOUBLE 1.7976931348623158e+308
|
||||
|
||||
#ifdef KBOOL_INT64
|
||||
|
||||
#if defined(__UNIX__) || defined(__GNUG__)
|
||||
|
||||
typedef long long B_INT; // 8 bytes integer
|
||||
//#define MAXB_INT LONG_LONG_MAX
|
||||
//#define MINB_INT LONG_LONG_MIN // 8 bytes integer
|
||||
const B_INT MAXB_INT = ( 0x7fffffffffffffffLL ); // 8 bytes integer
|
||||
const B_INT MINB_INT = ( 0x8000000000000000LL );
|
||||
|
||||
#else //defined(__UNIX__) || defined(__GNUG__)
|
||||
|
||||
typedef __int64 B_INT; // 8 bytes integer
|
||||
#undef MAXB_INT
|
||||
#undef MINB_INT
|
||||
|
||||
const B_INT MAXB_INT = ( 0x7fffffffffffffff ); // 8 bytes integer
|
||||
const B_INT MINB_INT = ( 0x8000000000000000 );
|
||||
|
||||
#endif //defined(__UNIX__) || defined(__GNUG__)
|
||||
|
||||
#else //KBOOL_INT64
|
||||
|
||||
#if defined(__UNIX__) || defined(__GNUG__)
|
||||
typedef long B_INT; // 8 bytes integer
|
||||
const B_INT MAXB_INT = ( 0x7fffffffL ); // 8 bytes integer
|
||||
const B_INT MINB_INT = ( 0x80000000L );
|
||||
#else
|
||||
typedef long B_INT; // 8 bytes integer
|
||||
const B_INT MAXB_INT = ( 0x7fffffff ); // 8 bytes integer
|
||||
const B_INT MINB_INT = ( 0x80000000 );
|
||||
#endif
|
||||
|
||||
#endif //KBOOL_INT64
|
||||
|
||||
B_INT babs( B_INT );
|
||||
|
||||
#ifdef M_PI
|
||||
#undef M_PI
|
||||
#endif
|
||||
#define M_PI (3.1415926535897932384626433832795028841972)
|
||||
|
||||
#ifdef M_PI_2
|
||||
#undef M_PI_2
|
||||
#endif
|
||||
#define M_PI_2 1.57079632679489661923
|
||||
|
||||
#ifdef M_PI_4
|
||||
#undef M_PI_4
|
||||
#endif
|
||||
#define M_PI_4 0.785398163397448309616
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
B_INT bmin( B_INT const value1, B_INT const value2 );
|
||||
B_INT bmax( B_INT const value1, B_INT const value2 );
|
||||
|
||||
B_INT bmin( B_INT value1, B_INT value2 );
|
||||
B_INT bmax( B_INT value1, B_INT value2 );
|
||||
|
||||
#include <string.h>
|
||||
|
||||
//! errors in the boolean algorithm will be thrown using this class
|
||||
class A2DKBOOLDLLEXP Bool_Engine_Error
|
||||
{
|
||||
public:
|
||||
Bool_Engine_Error( string message, string header = 0, int degree = 9, int fatal = 0 );
|
||||
Bool_Engine_Error( const Bool_Engine_Error& a );
|
||||
~Bool_Engine_Error();
|
||||
string GetErrorMessage();
|
||||
string GetHeaderMessage();
|
||||
int GetErrorDegree();
|
||||
int GetFatal();
|
||||
|
||||
protected:
|
||||
string _message;
|
||||
string _header;
|
||||
int _degree;
|
||||
int _fatal;
|
||||
};
|
||||
|
||||
|
||||
#define KBOOL_LOGFILE "kbool.log"
|
||||
|
||||
enum kbEdgeType
|
||||
{
|
||||
KB_OUTSIDE_EDGE, /*!< edge of the outside contour of a polygon */
|
||||
KB_INSIDE_EDGE, /*!< edge of the inside hole a polygon */
|
||||
KB_FALSE_EDGE /*!< edge to connect holes into polygons */
|
||||
} ;
|
||||
|
||||
enum GroupType
|
||||
{
|
||||
GROUP_A, /*!< to set Group A for polygons */
|
||||
GROUP_B /*!< to set Group A for polygons */
|
||||
};
|
||||
|
||||
enum BOOL_OP
|
||||
{
|
||||
BOOL_NON, /*!< No operation */
|
||||
BOOL_OR, /*!< boolean OR operation */
|
||||
BOOL_AND, /*!< boolean AND operation */
|
||||
BOOL_EXOR, /*!< boolean EX_OR operation */
|
||||
BOOL_A_SUB_B, /*!< boolean Group A - Group B operation */
|
||||
BOOL_B_SUB_A, /*!< boolean Group B - Group A operation */
|
||||
BOOL_CORRECTION, /*!< polygon correction/offset operation */
|
||||
BOOL_SMOOTHEN, /*!< smooth operation */
|
||||
BOOL_MAKERING /*!< create a ring on all polygons */
|
||||
};
|
||||
|
||||
class kbGraphList;
|
||||
class kbGraph;
|
||||
class kbLink;
|
||||
class kbNode;
|
||||
template<class Type> class TDLI;
|
||||
|
||||
//! boolean engine to perform operation on two sets of polygons.
|
||||
/*
|
||||
First the engine needs to be filled with polygons.
|
||||
The first operand in the operation is called group A polygons, the second group B.
|
||||
The boolean operation ( BOOL_OR, BOOL_AND, BOOL_EXOR, BOOL_A_SUB_B, BOOL_B_SUB_A )
|
||||
are based on the two sets of polygons in group A and B.
|
||||
The other operation on group A only.
|
||||
|
||||
At the end of the operation the resulting polygons can be extracted.
|
||||
*/
|
||||
class A2DKBOOLDLLEXP Bool_Engine
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
Bool_Engine();
|
||||
|
||||
//! destructor
|
||||
virtual ~Bool_Engine();
|
||||
|
||||
string GetVersion() { return KBOOL_VERSION; }
|
||||
|
||||
//! reports progress of algorithm.
|
||||
virtual void SetState( string );
|
||||
|
||||
//! called at an internal error.
|
||||
virtual void error( string text, string title );
|
||||
|
||||
//! called at an internal generated possible error.
|
||||
virtual void info( string text, string title );
|
||||
|
||||
bool Do_Operation( BOOL_OP operation );
|
||||
|
||||
|
||||
//! distance within which points and lines will be snapped towards lines and other points
|
||||
/*
|
||||
The algorithm takes into account gaps and inaccuracies caused by rounding to integer coordinates
|
||||
in the original data.
|
||||
Imagine two rectangles one with a side ( 0,0 ) ( 2.0, 17.0 )
|
||||
and the other has a side ( 0,0 ) ( 1.0, 8.5 )
|
||||
If for some reason those coordinates where round to ( 0,0 ) ( 2, 17 ) ( 0,0 ) ( 1, 9 ),
|
||||
there will be clearly a gap or overlap that was not intended.
|
||||
Even without rounding this effect takes place since there is always a minimum significant bit
|
||||
also when using doubles.
|
||||
|
||||
If the user used as minimum accuracy 0.001, you need to choose Marge > 0.001
|
||||
The boolean engine scales up the input data with GetDGrid() * GetGrid() and rounds the result to
|
||||
integer, So (assuming GRID = 100 DGRID = 1000) a vertex of 123.001 in the user data will
|
||||
become 12300100 internal.
|
||||
At the end of the algorithm the internal vertexes are scaled down again with GetDGrid() * GetGrid(),
|
||||
so 12300103 becomes 123.00103 eventually.
|
||||
So indeed the minimum accuracy might increase, you are free to round again if needed.
|
||||
*/
|
||||
void SetMarge( double marge );
|
||||
double GetMarge();
|
||||
|
||||
//! input points are scaled up with GetDGrid() * GetGrid()
|
||||
/*
|
||||
Grid makes sure that the integer data used within the algorithm has room for extra intersections
|
||||
smaller than the smallest number within the input data.
|
||||
The input data scaled up with DGrid is related to the accuracy the user has in his input data.
|
||||
Another scaling with Grid is applied on top of it to create space in the integer number for
|
||||
even smaller numbers.
|
||||
*/
|
||||
void SetGrid( B_INT grid );
|
||||
|
||||
//! See SetGrid
|
||||
B_INT GetGrid();
|
||||
|
||||
//! input points are scaled up with GetDGrid() * GetGrid()
|
||||
/*
|
||||
The input data scaled up with DGrid is related to the accuracy the user has in his input data.
|
||||
User data with a minimum accuracy of 0.001, means set the DGrid to 1000.
|
||||
The input data may contain data with a minimum accuracy much smaller, but by setting the DGrid
|
||||
everything smaller than 1/DGrid is rounded.
|
||||
|
||||
DGRID is only meant to make fractional parts of input data which can be
|
||||
doubles, part of the integers used in vertexes within the boolean algorithm.
|
||||
And therefore DGRID bigger than 1 is not usefull, you would only loose accuracy.
|
||||
Within the algorithm all input data is multiplied with DGRID, and the result
|
||||
is rounded to an integer.
|
||||
*/
|
||||
void SetDGrid( double dgrid );
|
||||
|
||||
//! See SetDGrid
|
||||
double GetDGrid();
|
||||
|
||||
//! When doing a correction operation ( also known as process offset )
|
||||
//! this defines the detail in the rounded corners.
|
||||
/*
|
||||
Depending on the round factor the corners of the polygon may be rounding within the correction
|
||||
algorithm. The detail within this rounded corner is set here.
|
||||
It defines the deviation the generated segments in arc like polygon may have towards the ideal
|
||||
rounded corner using a perfect arc.
|
||||
*/
|
||||
void SetCorrectionAber( double aber );
|
||||
|
||||
//! see SetCorrectionAber
|
||||
double GetCorrectionAber();
|
||||
|
||||
//! When doing a correction operation ( also known as process offset )
|
||||
//! this defines the amount of correction.
|
||||
/*
|
||||
The correction algorithm can apply positive and negative offset to polygons.
|
||||
It takes into account closed in areas within a polygon, caused by overlapping/selfintersecting
|
||||
polygons. So holes form that way are corrected proberly, but the overlapping parts itself
|
||||
are left alone. An often used trick to present polygons with holes by linking to the outside
|
||||
boundary, is therefore also handled properly.
|
||||
The algoritm first does a boolean OR operation on the polygon, and seperates holes and
|
||||
outside contours.
|
||||
After this it creates a ring shapes on the above holes and outside contours.
|
||||
This ring shape is added or subtracted from the holes and outside contours.
|
||||
The result is the corrected polygon.
|
||||
If the correction factor is > 0, the outside contours will become larger, while the hole contours
|
||||
will become smaller.
|
||||
*/
|
||||
void SetCorrectionFactor( double aber );
|
||||
|
||||
//! see SetCorrectionFactor
|
||||
double GetCorrectionFactor();
|
||||
|
||||
//! used within the smooth algorithm to define how much the smoothed curve may deviate
|
||||
//! from the original.
|
||||
void SetSmoothAber( double aber );
|
||||
|
||||
//! see SetSmoothAber
|
||||
double GetSmoothAber();
|
||||
|
||||
//! segments of this size will be left alone in the smooth algorithm.
|
||||
void SetMaxlinemerge( double maxline );
|
||||
|
||||
//! see SetMaxlinemerge
|
||||
double GetMaxlinemerge();
|
||||
|
||||
//! Polygon may be filled in different ways (alternate and winding rule).
|
||||
//! This here defines which method will be assumed within the algorithm.
|
||||
void SetWindingRule( bool rule );
|
||||
|
||||
//! see SetWindingRule
|
||||
bool GetWindingRule();
|
||||
|
||||
//! when set not only the top vertex of a hole is linked to the other holes and contours,
|
||||
//! but also vertex other vertexes close to a hole can be used.
|
||||
void SetAllowNonTopHoleLinking( bool allow ) { m_allowNonTopHoleLinking = allow; }
|
||||
|
||||
//! see SetWindingRule
|
||||
bool GetAllowNonTopHoleLinking() { return m_allowNonTopHoleLinking; }
|
||||
|
||||
//! the smallest accuracy used within the algorithm for comparing two real numbers.
|
||||
double GetAccur();
|
||||
|
||||
//! Used with in correction/offset algorithm.
|
||||
/*
|
||||
When the polygon contains sharp angles ( < 90 ), after a positive correction the
|
||||
extended parrallel constructed offset lines may leed to extreme offsets on the angles.
|
||||
The length of the crossing generated by the parrallel constructed offset lines
|
||||
towards the original point in the polygon is compared to the offset which needs to be applied.
|
||||
The Roundfactor then decides if this corner will be rounded.
|
||||
A Roundfactor of 1 means that the resulting offset will not be bigger then the correction factor
|
||||
set in the algorithm. Meaning even straight 90 degrees corners will be rounded.
|
||||
A Roundfactor of > sqrt(2) is where 90 corners will be left alone, and smaller corners will be rounded.
|
||||
*/
|
||||
void SetRoundfactor( double roundfac );
|
||||
|
||||
//! see SetRoundfactor
|
||||
double GetRoundfactor();
|
||||
|
||||
// the following are only be used within the algorithm,
|
||||
// since they are scaled with m_DGRID
|
||||
|
||||
//! only used internal.
|
||||
void SetInternalMarge( B_INT marge );
|
||||
//! only used internal.
|
||||
B_INT GetInternalMarge();
|
||||
|
||||
//! only used internal.
|
||||
double GetInternalCorrectionAber();
|
||||
|
||||
//! only used internal.
|
||||
double GetInternalCorrectionFactor();
|
||||
|
||||
//! only used internal.
|
||||
double GetInternalSmoothAber();
|
||||
|
||||
//! only used internal.
|
||||
B_INT GetInternalMaxlinemerge();
|
||||
|
||||
//! in this mode polygons add clockwise, or contours,
|
||||
/*!
|
||||
and polygons added counter clockwise or holes.
|
||||
*/
|
||||
void SetOrientationEntryMode( bool orientationEntryMode ) { m_orientationEntryMode = orientationEntryMode; }
|
||||
|
||||
//! see SetOrientationEntryMode()
|
||||
bool GetOrientationEntryMode() { return m_orientationEntryMode; }
|
||||
|
||||
//! if set true holes are linked into outer contours by double overlapping segments.
|
||||
/*!
|
||||
This mode is needed when the software using the boolean algorithm does
|
||||
not understand hole polygons. In that case a contour and its holes form one
|
||||
polygon. In cases where software understands the concept of holes, contours
|
||||
are clockwise oriented, while holes are anticlockwise oriented.
|
||||
The output of the boolean operations, is following those rules also.
|
||||
But even if extracting the polygons from the engine, each segment is marked such
|
||||
that holes and non holes and linksegments to holes can be recognized.
|
||||
*/
|
||||
void SetLinkHoles( bool doLinkHoles ) { m_doLinkHoles = doLinkHoles; }
|
||||
|
||||
//! see SetLinkHoles()
|
||||
bool GetLinkHoles() { return m_doLinkHoles; }
|
||||
|
||||
//!lof file will be created when set True
|
||||
void SetLog( bool OnOff );
|
||||
|
||||
//! used to write to log file
|
||||
void Write_Log( string);
|
||||
//! used to write to log file
|
||||
void Write_Log( string, string );
|
||||
//! used to write to log file
|
||||
void Write_Log( string, double );
|
||||
//! used to write to log file
|
||||
void Write_Log( string, B_INT );
|
||||
|
||||
FILE* GetLogFile() { return m_logfile; }
|
||||
|
||||
// methods used to add polygons to the eng using points
|
||||
|
||||
//! Start adding a polygon to the engine
|
||||
/*
|
||||
The boolean operation work on two groups of polygons ( group A or B ),
|
||||
other algorithms are only using group A.
|
||||
|
||||
You add polygons like this to the engine.
|
||||
|
||||
// foreach point in a polygon ...
|
||||
if (booleng->StartPolygonAdd(GROUP_A))
|
||||
{
|
||||
booleng->AddPoint(100,100);
|
||||
booleng->AddPoint(-100,100);
|
||||
booleng->AddPoint(-100,-100);
|
||||
booleng->AddPoint(100,-100);
|
||||
}
|
||||
booleng->EndPolygonAdd();
|
||||
|
||||
\param A_or_B defines if the new polygon will be of group A or B
|
||||
|
||||
Holes or added by adding an inside polygons with opposite orientation compared
|
||||
to another polygon added.
|
||||
So the contour polygon ClockWise, then add counterclockwise polygons for holes, and visa versa.
|
||||
BUT only if m_orientationEntryMode is set true, else all polygons are redirected, and become
|
||||
individual areas without holes.
|
||||
Holes in such a case must be linked into the contour using two extra segments.
|
||||
*/
|
||||
bool StartPolygonAdd( GroupType A_or_B );
|
||||
|
||||
//! see StartPolygonAdd
|
||||
bool AddPoint( double x, double y );
|
||||
|
||||
//! see StartPolygonAdd
|
||||
bool EndPolygonAdd();
|
||||
|
||||
// methods used to extract polygons from the eng by getting its points
|
||||
|
||||
//! Use after StartPolygonGet()
|
||||
int GetNumPointsInPolygon() { return m_numPtsInPolygon ; }
|
||||
|
||||
//! get resulting polygons at end of an operation
|
||||
/*!
|
||||
// foreach resultant polygon in the booleng ...
|
||||
while ( booleng->StartPolygonGet() )
|
||||
{
|
||||
// foreach point in the polygon
|
||||
while ( booleng->PolygonHasMorePoints() )
|
||||
{
|
||||
fprintf(stdout,"x = %f\t", booleng->GetPolygonXPoint());
|
||||
fprintf(stdout,"y = %f\n", booleng->GetPolygonYPoint());
|
||||
}
|
||||
booleng->EndPolygonGet();
|
||||
}
|
||||
*/
|
||||
bool StartPolygonGet();
|
||||
|
||||
//! see StartPolygonGet
|
||||
/*!
|
||||
This iterates through the first graph in the graphlist.
|
||||
Setting the current kbNode properly by following the links in the graph
|
||||
through its nodes.
|
||||
*/
|
||||
bool PolygonHasMorePoints();
|
||||
|
||||
//! see StartPolygonGet
|
||||
double GetPolygonXPoint();
|
||||
|
||||
//! see StartPolygonGet
|
||||
double GetPolygonYPoint();
|
||||
|
||||
//! in the resulting polygons this tells if the current polygon segment is one
|
||||
//! used to link holes into the outer contour of the surrounding polygon
|
||||
bool GetHoleConnectionSegment();
|
||||
|
||||
//! in the resulting polygons this tells if the current polygon segment is part
|
||||
//! of a hole within a polygon.
|
||||
bool GetHoleSegment();
|
||||
|
||||
//! an other way to get the type of segment.
|
||||
kbEdgeType GetPolygonPointEdgeType();
|
||||
|
||||
//! see StartPolygonGet()
|
||||
/*!
|
||||
Removes a graph from the graphlist.
|
||||
Called after an extraction of an output polygon was done.
|
||||
*/
|
||||
void EndPolygonGet();
|
||||
|
||||
private:
|
||||
|
||||
bool m_doLog;
|
||||
|
||||
//! contains polygons in graph form
|
||||
kbGraphList* m_graphlist;
|
||||
|
||||
double m_MARGE;
|
||||
B_INT m_GRID;
|
||||
double m_DGRID;
|
||||
double m_CORRECTIONABER;
|
||||
double m_CORRECTIONFACTOR;
|
||||
double m_SMOOTHABER;
|
||||
double m_MAXLINEMERGE;
|
||||
bool m_WINDINGRULE;
|
||||
double m_ACCUR;
|
||||
double m_ROUNDFACTOR;
|
||||
|
||||
bool m_orientationEntryMode;
|
||||
|
||||
bool m_doLinkHoles;
|
||||
bool m_allowNonTopHoleLinking;
|
||||
|
||||
//! used in the StartPolygonAdd, AddPt, EndPolygonAdd sequence
|
||||
kbGraph* m_GraphToAdd;
|
||||
//! used in the StartPolygonAdd, AddPt, EndPolygonAdd sequence
|
||||
kbNode* m_lastNodeToAdd;
|
||||
//! used in the StartPolygonAdd, AddPt, EndPolygonAdd sequence
|
||||
kbNode* m_firstNodeToAdd;
|
||||
|
||||
//! the current group type ( group A or B )
|
||||
GroupType m_groupType;
|
||||
|
||||
//! used in extracting the points from the resultant polygons
|
||||
kbGraph* m_getGraph;
|
||||
//! used in extracting the points from the resultant polygons
|
||||
kbLink* m_getLink;
|
||||
//! used in extracting the points from the resultant polygons
|
||||
kbNode* m_getNode;
|
||||
//! used in extracting the points from the resultant polygons
|
||||
double m_PolygonXPoint;
|
||||
//! used in extracting the points from the resultant polygons
|
||||
double m_PolygonYPoint;
|
||||
//! used in extracting the points from the resultant polygons
|
||||
int m_numPtsInPolygon;
|
||||
//! used in extracting the points from the resultant polygons
|
||||
int m_numNodesVisited;
|
||||
|
||||
FILE* m_logfile;
|
||||
|
||||
public:
|
||||
|
||||
//! use in kbNode to iterate links.
|
||||
TDLI<kbLink>* _linkiter;
|
||||
|
||||
//! how many time run intersections fase.
|
||||
unsigned int m_intersectionruns;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,207 +0,0 @@
|
|||
/*! \file graph.h
|
||||
\author Klaas Holwerda
|
||||
|
||||
Copyright: 2001-2004 (C) Klaas Holwerda
|
||||
|
||||
Licence: see kboollicense.txt
|
||||
|
||||
RCS-ID: $Id: graph.h,v 1.5 2009/09/10 17:04:09 titato Exp $
|
||||
*/
|
||||
|
||||
/* @@(#) $Source: /cvsroot/wxart2d/wxArt2D/thirdparty/kbool/include/kbool/graph.h,v $ $Revision: 1.5 $ $Date: 2009/09/10 17:04:09 $ */
|
||||
|
||||
/*
|
||||
Program GRAPH.H
|
||||
Purpose Used to Intercect and other process functions
|
||||
Last Update 03-04-1996
|
||||
*/
|
||||
|
||||
#ifndef GRAPH_H
|
||||
#define GRAPH_H
|
||||
|
||||
#include "kbool/booleng.h"
|
||||
#include "kbool/_lnk_itr.h"
|
||||
#include "kbool/link.h"
|
||||
#include "kbool/line.h"
|
||||
#include "kbool/scanbeam.h"
|
||||
|
||||
class kbNode;
|
||||
|
||||
class kbGraphList;
|
||||
|
||||
//! one graph containing links that cab be connected.
|
||||
class A2DKBOOLDLLEXP kbGraph
|
||||
{
|
||||
protected:
|
||||
Bool_Engine* _GC;
|
||||
public:
|
||||
|
||||
kbGraph( Bool_Engine* GC );
|
||||
kbGraph( kbLink*, Bool_Engine* GC );
|
||||
|
||||
kbGraph( kbGraph* other );
|
||||
|
||||
~kbGraph();
|
||||
|
||||
bool GetBin() { return _bin; };
|
||||
void SetBin( bool b ) { _bin = b; };
|
||||
|
||||
void Prepare( int intersectionruns );
|
||||
void RoundInt( B_INT grid );
|
||||
void Rotate( bool plus90 );
|
||||
|
||||
//! adds a link to the linklist
|
||||
void AddLink( kbNode *begin, kbNode *end );
|
||||
|
||||
//! adds a link to the linklist
|
||||
void AddLink( kbLink *a_link );
|
||||
|
||||
bool AreZeroLines( B_INT Marge );
|
||||
|
||||
//! Delete parallel lines
|
||||
void DeleteDoubles();
|
||||
|
||||
//! delete zerolines
|
||||
bool DeleteZeroLines( B_INT Marge );
|
||||
bool RemoveNullLinks();
|
||||
|
||||
//! Process found intersections
|
||||
void ProcessCrossings();
|
||||
//! set flags for operations based on group
|
||||
void Set_Operation_Flags();
|
||||
|
||||
//! Left Right values
|
||||
void Remove_IN_Links();
|
||||
|
||||
//! reset bin and mark flags in links.
|
||||
void ResetBinMark();
|
||||
|
||||
// Remove unused links
|
||||
void ReverseAllLinks();
|
||||
|
||||
//! Simplify the kbGraph
|
||||
bool Simplify( B_INT Marge );
|
||||
|
||||
|
||||
//! Takes over all links of the argument
|
||||
bool Smoothen( B_INT Marge );
|
||||
|
||||
void TakeOver( kbGraph* );
|
||||
|
||||
//! function for maximum performance
|
||||
|
||||
//! Get the First link from the kbGraph
|
||||
kbLink* GetFirstLink();
|
||||
kbNode* GetTopNode();
|
||||
void SetBeenHere( bool );
|
||||
void Reset_flags();
|
||||
|
||||
//! Set the group of a kbGraph
|
||||
void SetGroup( GroupType );
|
||||
|
||||
//! Set the number of the kbGraph
|
||||
void SetNumber( int );
|
||||
void Reset_Mark_and_Bin();
|
||||
bool GetBeenHere();
|
||||
int GetGraphNum();
|
||||
int GetNumberOfLinks();
|
||||
|
||||
void Boolean( BOOL_OP operation, kbGraphList* Result );
|
||||
void Correction( kbGraphList* Result, double factor );
|
||||
void MakeRing( kbGraphList* Result, double factor );
|
||||
void CreateRing( kbGraphList *ring, double factor );
|
||||
void CreateRing_fast( kbGraphList *ring, double factor );
|
||||
void CreateArc( kbNode* center, kbLine* incoming, kbNode* end, double radius, double aber );
|
||||
void CreateArc( kbNode* center, kbNode* begin, kbNode* end, double radius, bool clock, double aber );
|
||||
void MakeOneDirection();
|
||||
void Make_Rounded_Shape( kbLink* a_link, double factor );
|
||||
bool MakeClockWise();
|
||||
bool writegraph( bool linked );
|
||||
bool writeintersections();
|
||||
void WriteKEY( Bool_Engine* GC, FILE* file = NULL );
|
||||
void WriteGraphKEY( Bool_Engine* GC );
|
||||
|
||||
protected:
|
||||
|
||||
//! Extracts partical polygons from the graph
|
||||
/*
|
||||
Links are sorted in XY at beginpoint. Bin and mark flag are reset.
|
||||
Next start to collect subparts from the graph, setting the links bin for all found parts.
|
||||
The parts are searched starting at a topleft corner NON set bin flag link.
|
||||
Found parts are numbered, to be easily split into to real sperate graphs by Split()
|
||||
|
||||
\param operation operation to collect for.
|
||||
\param detecthole if you want holes detected, influences also way of extraction.
|
||||
\param foundholes when holes are found this flag is set true, but only if detecthole is set true.
|
||||
*/
|
||||
void Extract_Simples( BOOL_OP operation, bool detecthole, bool& foundholes );
|
||||
|
||||
//! split graph into small graph, using the numbers in links.
|
||||
void Split( kbGraphList* partlist );
|
||||
|
||||
//! Collect a graph by starting at argument link
|
||||
/*
|
||||
Called from Extract_Simples, and assumes sorted links with bin flag unset for non extarted piece
|
||||
|
||||
Collect graphs pieces from a total graph, by following links set to a given boolean operation.
|
||||
\param current_node start node to collect
|
||||
\param operation operation to collect for.
|
||||
\param detecthole if you want holes detected, influences also way of extraction.
|
||||
\param graphnumber number to be given to links in the extracted graph piece
|
||||
\param foundholes when holes are found this flag is set true.
|
||||
*/
|
||||
void CollectGraph( kbNode *current_node, BOOL_OP operation, bool detecthole, int graphnumber, bool& foundholes );
|
||||
|
||||
void CollectGraphLast( kbNode *current_node, BOOL_OP operation, bool detecthole, int graphnumber, bool& foundholes );
|
||||
|
||||
//! find a link not bin in the top left corner ( links should be sorted already )
|
||||
/*!
|
||||
Last found position is used to find it quickly.
|
||||
Used in ExtractSimples()
|
||||
*/
|
||||
kbNode* GetMostTopLeft( TDLI<kbLink>* _LI );
|
||||
|
||||
//! calculates crossing for all links in a graph, and add those as part of the graph.
|
||||
/*
|
||||
It is not just crossings calculation, snapping close nodes is part of it.
|
||||
This is not done at maximum stability in economic time.
|
||||
There are faster ways, but hardly ever they solve the problems, and they do not snap.
|
||||
Here it is on purpose split into separate steps, to get a better result in snapping, and
|
||||
to reach a better stability.
|
||||
|
||||
\param Marge nodes and lines closer to eachother then this, are merged.
|
||||
*/
|
||||
bool CalculateCrossings( B_INT Marge );
|
||||
|
||||
//! equal nodes in position are merged into one.
|
||||
int Merge_NodeToNode( B_INT Marge );
|
||||
|
||||
//! basic scan algorithm with a sweeping beam are line.
|
||||
/*!
|
||||
\param scantype a different face in the algorithm.
|
||||
\param holes to detect hole when needed.
|
||||
*/
|
||||
int ScanGraph2( SCANTYPE scantype, bool& holes );
|
||||
|
||||
//! links not used for a certain operation can be deleted, simplifying extraction
|
||||
void DeleteNonCond( BOOL_OP operation );
|
||||
|
||||
//! links not used for a certain operation can be set bin, simplifying extraction
|
||||
void HandleNonCond( BOOL_OP operation );
|
||||
|
||||
//! debug
|
||||
bool checksort();
|
||||
|
||||
//! used in correction/offset algorithm
|
||||
bool Small( B_INT howsmall );
|
||||
|
||||
|
||||
bool _bin;
|
||||
|
||||
DL_List<void*>* _linklist;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
/*! \file graphlst.h
|
||||
\author Klaas Holwerda
|
||||
|
||||
Copyright: 2001-2004 (C) Klaas Holwerda
|
||||
|
||||
Licence: see kboollicense.txt
|
||||
|
||||
RCS-ID: $Id: graphlst.h,v 1.4 2009/09/10 17:04:09 titato Exp $
|
||||
*/
|
||||
|
||||
/* @@(#) $Source: /cvsroot/wxart2d/wxArt2D/thirdparty/kbool/include/kbool/graphlst.h,v $ $Revision: 1.4 $ $Date: 2009/09/10 17:04:09 $ */
|
||||
|
||||
/*
|
||||
Program GRAPHLST.H
|
||||
Purpose Implements a list of graphs (header)
|
||||
Last Update 11-03-1996
|
||||
*/
|
||||
|
||||
#ifndef GRAPHLIST_H
|
||||
#define GRAPHLIST_H
|
||||
|
||||
#include "kbool/booleng.h"
|
||||
|
||||
#include "kbool/_lnk_itr.h"
|
||||
|
||||
#include "kbool/graph.h"
|
||||
|
||||
class Debug_driver;
|
||||
|
||||
|
||||
class A2DKBOOLDLLEXP kbGraphList: public DL_List<void*>
|
||||
{
|
||||
protected:
|
||||
Bool_Engine* _GC;
|
||||
public:
|
||||
|
||||
kbGraphList( Bool_Engine* GC );
|
||||
|
||||
kbGraphList( kbGraphList* other );
|
||||
|
||||
~kbGraphList();
|
||||
|
||||
void MakeOneGraph( kbGraph *total );
|
||||
|
||||
void Prepare( kbGraph *total );
|
||||
void MakeRings();
|
||||
void Correction();
|
||||
|
||||
void Simplify( double marge );
|
||||
void Smoothen( double marge );
|
||||
void Merge();
|
||||
void Boolean( BOOL_OP operation, int intersectionRunsMax );
|
||||
|
||||
void WriteGraphs();
|
||||
void WriteGraphsKEY( Bool_Engine* GC );
|
||||
|
||||
protected:
|
||||
void Renumber();
|
||||
void UnMarkAll();
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
#ifndef __A2D_KBOOLMOD_H__
|
||||
#define __A2D_KBOOLMOD_H__
|
||||
|
||||
#include "kbool/booleng.h"
|
||||
#include "kbool/graph.h"
|
||||
#include "kbool/graphlst.h"
|
||||
#include "kbool/line.h"
|
||||
#include "kbool/link.h"
|
||||
#include "kbool/lpoint.h"
|
||||
#include "kbool/node.h"
|
||||
#include "kbool/record.h"
|
||||
#include "kbool/scanbeam.h"
|
||||
|
||||
#endif
|
||||
|
|
@ -1,107 +0,0 @@
|
|||
/*! \file line.h
|
||||
\brief Mainy used for calculating crossings
|
||||
\author Klaas Holwerda
|
||||
|
||||
Copyright: 2001-2004 (C) Klaas Holwerda
|
||||
|
||||
Licence: see kboollicense.txt
|
||||
|
||||
RCS-ID: $Id: line.h,v 1.5 2009/09/10 17:04:09 titato Exp $
|
||||
*/
|
||||
|
||||
#ifndef LINE_H
|
||||
#define LINE_H
|
||||
|
||||
#include "kbool/booleng.h"
|
||||
#include "kbool/link.h"
|
||||
|
||||
class A2DKBOOLDLLEXP Bool_Engine;
|
||||
|
||||
// Status of a point to a line
|
||||
enum PointStatus {LEFT_SIDE, RIGHT_SIDE, ON_AREA, IN_AREA};
|
||||
|
||||
class A2DKBOOLDLLEXP kbGraph;
|
||||
|
||||
class A2DKBOOLDLLEXP kbLine
|
||||
{
|
||||
protected:
|
||||
Bool_Engine* m_GC;
|
||||
public:
|
||||
|
||||
// constructors and destructor
|
||||
kbLine( Bool_Engine* GC );
|
||||
kbLine( kbLink*, Bool_Engine* GC );
|
||||
~kbLine();
|
||||
|
||||
void Set( kbLink * );
|
||||
kbLink* GetLink();
|
||||
|
||||
//! Get the beginnode from a line
|
||||
kbNode* GetBeginNode();
|
||||
|
||||
//! Get the endnode from a line
|
||||
kbNode* GetEndNode();
|
||||
|
||||
//! Check if two lines intersects
|
||||
int CheckIntersect( kbLine*, double Marge );
|
||||
|
||||
//! Intersects two lines
|
||||
int Intersect( kbLine*, double Marge );
|
||||
int Intersect_simple( kbLine * lijn );
|
||||
bool Intersect2( kbNode* crossing, kbLine * lijn );
|
||||
|
||||
//!For an infinite line
|
||||
PointStatus PointOnLine( kbNode* a_node, double& Distance, double Marge );
|
||||
|
||||
//!For a non-infinite line
|
||||
PointStatus PointInLine( kbNode* a_node, double& Distance, double Marge );
|
||||
|
||||
//! Caclulate Y if X is known
|
||||
B_INT Calculate_Y( B_INT X );
|
||||
B_INT Calculate_Y_from_X( B_INT X );
|
||||
void Virtual_Point( kbLPoint *a_point, double distance );
|
||||
|
||||
//! assignment operator
|
||||
kbLine& operator=( const kbLine& );
|
||||
|
||||
kbNode* OffsetContour( kbLine* const nextline, kbNode* last_ins, double factor, kbGraph *shape );
|
||||
kbNode* OffsetContour_rounded( kbLine* const nextline, kbNode* _last_ins, double factor, kbGraph *shape );
|
||||
bool OkeForContour( kbLine* const nextline, double factor, kbNode* LastLeft, kbNode* LastRight, LinkStatus& _outproduct );
|
||||
bool Create_Ring_Shape( kbLine* nextline, kbNode** _last_ins_left, kbNode** _last_ins_right, double factor, kbGraph *shape );
|
||||
void Create_Begin_Shape( kbLine* nextline, kbNode** _last_ins_left, kbNode** _last_ins_right, double factor, kbGraph *shape );
|
||||
void Create_End_Shape( kbLine* nextline, kbNode* _last_ins_left, kbNode* _last_ins_right, double factor, kbGraph *shape );
|
||||
|
||||
//! Calculate the parameters if nessecary
|
||||
void CalculateLineParameters();
|
||||
|
||||
//! Adds a crossing between the intersecting lines
|
||||
void AddLineCrossing( B_INT , B_INT , kbLine * );
|
||||
|
||||
void AddCrossing( kbNode *a_node );
|
||||
kbNode* AddCrossing( B_INT X, B_INT Y );
|
||||
bool ProcessCrossings( TDLI<kbLink>* _LI );
|
||||
|
||||
// Linecrosslist
|
||||
void SortLineCrossings();
|
||||
bool CrossListEmpty();
|
||||
DL_List<void*>* GetCrossList();
|
||||
// bool HasInCrossList(kbNode*);
|
||||
|
||||
private:
|
||||
|
||||
//! Function needed for Intersect
|
||||
int ActionOnTable1( PointStatus, PointStatus );
|
||||
//! Function needed for Intersect
|
||||
int ActionOnTable2( PointStatus, PointStatus );
|
||||
|
||||
double m_AA;
|
||||
double m_BB;
|
||||
double m_CC;
|
||||
kbLink* m_link;
|
||||
bool m_valid_parameters;
|
||||
|
||||
//! List with crossings through this link
|
||||
DL_List<void*> *linecrosslist;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,230 +0,0 @@
|
|||
/*! \file link.h
|
||||
\brief Part of a graph, connection between nodes (Header)
|
||||
\author Klaas Holwerda or Julian Smart
|
||||
|
||||
Copyright: 2001-2004 (C) Klaas Holwerda
|
||||
|
||||
Licence: see kboollicense.txt
|
||||
|
||||
RCS-ID: $Id: link.h,v 1.5 2009/09/10 17:04:09 titato Exp $
|
||||
*/
|
||||
|
||||
#ifndef LINK_H
|
||||
#define LINK_H
|
||||
|
||||
#include "kbool/booleng.h"
|
||||
#include "kbool/_lnk_itr.h"
|
||||
|
||||
enum LinkStatus {IS_LEFT, IS_ON, IS_RIGHT};
|
||||
|
||||
class kbLPoint;
|
||||
class kbNode;
|
||||
class kbRecord;
|
||||
|
||||
//! segment within a graph
|
||||
/*
|
||||
A Graph contains a list of kbLink, the kbLink or connected by Node's.
|
||||
Several kbLink can be connected to one Node.
|
||||
A kbLink has a direction defined by its begin and end node.
|
||||
Node do have a list of connected kbLink's.
|
||||
So one can walk trough a graph in two ways:
|
||||
1- via its kbLink list
|
||||
2- via the node connected to the kbLink's
|
||||
*/
|
||||
class A2DKBOOLDLLEXP kbLink
|
||||
{
|
||||
protected:
|
||||
Bool_Engine* _GC;
|
||||
public:
|
||||
|
||||
//! contructors
|
||||
kbLink( Bool_Engine* GC );
|
||||
|
||||
//! contructors
|
||||
kbLink( int graphnr, kbNode* begin, kbNode* end, Bool_Engine* GC );
|
||||
|
||||
//! contructors
|
||||
kbLink( kbNode *begin, kbNode *end, Bool_Engine* GC );
|
||||
|
||||
//! destructors
|
||||
~kbLink();
|
||||
|
||||
|
||||
//! Merges the other node with argument
|
||||
void MergeNodes( kbNode* const );
|
||||
|
||||
//! outproduct of two links
|
||||
LinkStatus OutProduct( kbLink* const two, double accur );
|
||||
|
||||
//! link three compared to this and two
|
||||
LinkStatus PointOnCorner( kbLink* const, kbLink* const );
|
||||
|
||||
//! Removes argument from the link
|
||||
void Remove( kbNode* );
|
||||
|
||||
//! replaces olddone in the link by newnode
|
||||
void Replace( kbNode* oldnode, kbNode* newnode );
|
||||
|
||||
//!top hole marking
|
||||
void SetTopHole( bool value );
|
||||
|
||||
//!top hole marking
|
||||
bool IsTopHole();
|
||||
|
||||
//! Marking functions
|
||||
void UnMark();
|
||||
//! Marking functions
|
||||
void Mark();
|
||||
//! Marking functions
|
||||
void SetMark( bool );
|
||||
//! Marking functions
|
||||
bool IsMarked();
|
||||
|
||||
//! holelink Marking functions
|
||||
void SetHoleLink( bool val ){ m_holelink = val;};
|
||||
|
||||
//! holelink Marking functions
|
||||
bool GetHoleLink(){ return m_holelink;};
|
||||
|
||||
//! Bin functions
|
||||
void SetNotBeenHere();
|
||||
//! Bin functions
|
||||
void SetBeenHere();
|
||||
//! Have you been here ??
|
||||
bool BeenHere();
|
||||
|
||||
//! Removes all the references to this
|
||||
void UnLink();
|
||||
|
||||
//! functions for maximum performance
|
||||
kbNode* GetBeginNode();
|
||||
|
||||
//! Datamember access functions
|
||||
kbNode* GetEndNode();
|
||||
kbNode* GetLowNode();
|
||||
kbNode* GetHighNode();
|
||||
|
||||
//! Returns a next link beginning with argument
|
||||
kbLink* Forth( kbNode* );
|
||||
|
||||
int GetGraphNum();
|
||||
bool GetInc();
|
||||
bool GetLeftA();
|
||||
bool GetLeftB();
|
||||
bool GetRightA();
|
||||
bool GetRightB();
|
||||
void GetLRO( kbLPoint*, int&, int&, double );
|
||||
|
||||
//! Return a node not equal to arg.
|
||||
kbNode* GetOther( const kbNode* const );
|
||||
//! Is this link unused ?
|
||||
bool IsUnused();
|
||||
|
||||
//! Used for given operation ?
|
||||
bool IsMarked( BOOL_OP operation );
|
||||
|
||||
//! return true if Left side is marked true for operation
|
||||
bool IsMarkedLeft( BOOL_OP operation );
|
||||
|
||||
//! return true if Right side is marked true for operation
|
||||
bool IsMarkedRight( BOOL_OP operation );
|
||||
|
||||
//! is this a hole link for given operation
|
||||
bool IsHole( BOOL_OP operation );
|
||||
|
||||
//! set the hole mark
|
||||
void SetHole( bool );
|
||||
|
||||
//! is the hole mark set?
|
||||
bool GetHole();
|
||||
|
||||
//! Are the nodes on about the same coordinates ?
|
||||
bool IsZero( B_INT marge );
|
||||
bool ShorterThan( B_INT marge );
|
||||
|
||||
//! Resets the link
|
||||
void Reset( kbNode* begin, kbNode* end, int graphnr = 0 );
|
||||
void Set( kbNode* begin, kbNode* end );
|
||||
void SetBeginNode( kbNode* );
|
||||
void SetEndNode( kbNode* );
|
||||
void SetGraphNum( int );
|
||||
void SetInc( bool );
|
||||
void SetLeftA( bool );
|
||||
void SetLeftB( bool );
|
||||
void SetRightA( bool );
|
||||
void SetRightB( bool );
|
||||
void SetGroup( GroupType );
|
||||
GroupType Group();
|
||||
|
||||
//! Flag calculation (internal only)
|
||||
void SetLineTypes();
|
||||
void Reset();
|
||||
void Reset_flags();
|
||||
|
||||
//!put in this direction
|
||||
void Redirect( kbNode* a_node );
|
||||
|
||||
void TakeOverOperationFlags( kbLink* link );
|
||||
|
||||
void SetRecordNode( DL_Node<kbRecord*>* recordNode ) { m_record = recordNode; }
|
||||
|
||||
DL_Node<kbRecord*>* GetRecordNode() { return m_record; }
|
||||
|
||||
protected:
|
||||
|
||||
//! The mainitems of a link
|
||||
kbNode *m_beginnode, *m_endnode;
|
||||
//! Marker for walking over the graph
|
||||
bool m_bin : 1;
|
||||
//! Is this a part of hole ?
|
||||
bool m_hole : 1;
|
||||
//! link that is toplink of hole?
|
||||
bool m_hole_top : 1;
|
||||
//! going in one more time in this graph if true else going out one time
|
||||
bool m_Inc : 1;
|
||||
//! Is left in polygongroup A
|
||||
bool m_LeftA : 1;
|
||||
//! Is right in polygon group A
|
||||
bool m_RightA : 1;
|
||||
//! Is left in polygon group B
|
||||
bool m_LeftB : 1;
|
||||
//! Is right in polygongroup B
|
||||
bool m_RightB : 1;
|
||||
//! General purose marker, internally unused
|
||||
bool m_mark : 1;
|
||||
//! link for linking holes
|
||||
bool m_holelink : 1;
|
||||
|
||||
//! Marker for Merge Left
|
||||
bool m_merge_L : 1;
|
||||
//! Marker for substract a-b Left
|
||||
bool m_a_substract_b_L: 1;
|
||||
//! Marker for substract b-a Left
|
||||
bool m_b_substract_a_L: 1;
|
||||
//! Marker for intersect Left
|
||||
bool m_intersect_L: 1;
|
||||
//! Marker for X-OR Left
|
||||
bool m_exor_L: 1;
|
||||
|
||||
//! Marker for Merge Right
|
||||
bool m_merge_R : 1;
|
||||
//! Marker for substract a-b Right
|
||||
bool m_a_substract_b_R: 1;
|
||||
//! Marker for substract b-a Right
|
||||
bool m_b_substract_a_R: 1;
|
||||
//! Marker for intersect Right
|
||||
bool m_intersect_R: 1;
|
||||
//! Marker for X-OR Right
|
||||
bool m_exor_R: 1;
|
||||
|
||||
//! belongs to group A or B
|
||||
GroupType m_group : 1;
|
||||
|
||||
//! belongs to this polygon part in the graph.
|
||||
int m_graphnum;
|
||||
|
||||
DL_Node<kbRecord*>* m_record;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
/*! \file lpoint.h
|
||||
\author Klaas Holwerda
|
||||
|
||||
Copyright: 2001-2004 (C) Klaas Holwerda
|
||||
|
||||
Licence: see kboollicense.txt
|
||||
|
||||
RCS-ID: $Id: lpoint.h,v 1.4 2009/09/10 17:04:09 titato Exp $
|
||||
*/
|
||||
|
||||
/* @@(#) $Source: /cvsroot/wxart2d/wxArt2D/thirdparty/kbool/include/kbool/lpoint.h,v $ $Revision: 1.4 $ $Date: 2009/09/10 17:04:09 $ */
|
||||
|
||||
/*
|
||||
Program LPOINT.H
|
||||
Purpose Definition of GDSII pointtype structure
|
||||
Last Update 12-12-1995
|
||||
*/
|
||||
|
||||
#ifndef LPOINT_H
|
||||
#define LPOINT_H
|
||||
|
||||
#include "kbool/booleng.h"
|
||||
|
||||
class A2DKBOOLDLLEXP kbLPoint
|
||||
{
|
||||
public:
|
||||
kbLPoint();
|
||||
kbLPoint( B_INT const , B_INT const );
|
||||
kbLPoint( kbLPoint* const );
|
||||
|
||||
void Set( const B_INT, const B_INT );
|
||||
void Set( const kbLPoint & );
|
||||
|
||||
kbLPoint GetPoint();
|
||||
B_INT GetX();
|
||||
B_INT GetY();
|
||||
void SetX( B_INT );
|
||||
void SetY( B_INT );
|
||||
bool Equal( const kbLPoint a_point, B_INT Marge );
|
||||
bool Equal( const B_INT, const B_INT , B_INT Marge );
|
||||
bool ShorterThan( const kbLPoint a_point, B_INT marge );
|
||||
bool ShorterThan( const B_INT X, const B_INT Y, B_INT );
|
||||
|
||||
kbLPoint &operator=( const kbLPoint & );
|
||||
kbLPoint &operator+( const kbLPoint & );
|
||||
kbLPoint &operator-( const kbLPoint & );
|
||||
|
||||
kbLPoint &operator*( int );
|
||||
kbLPoint &operator/( int );
|
||||
|
||||
int operator==( const kbLPoint & ) const;
|
||||
int operator!=( const kbLPoint & ) const;
|
||||
|
||||
protected:
|
||||
B_INT _x;
|
||||
B_INT _y;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,87 +0,0 @@
|
|||
/*! \file node.h
|
||||
\brief Holds a GDSII node structure (Header)
|
||||
\author Klaas Holwerda
|
||||
|
||||
Copyright: 2001-2004 (C) Klaas Holwerda
|
||||
|
||||
Licence: see kboollicense.txt
|
||||
|
||||
RCS-ID: $Id: node.h,v 1.7 2009/09/14 16:50:12 titato Exp $
|
||||
*/
|
||||
|
||||
#ifndef NODE_H
|
||||
#define NODE_H
|
||||
|
||||
#include "kbool/booleng.h"
|
||||
|
||||
#include "kbool/lpoint.h"
|
||||
|
||||
#include "kbool/link.h"
|
||||
#include "kbool/_lnk_itr.h" // LinkBaseIter
|
||||
#include <math.h>
|
||||
|
||||
enum NodePosition { N_LEFT, N_ON, N_RIGHT};
|
||||
|
||||
class A2DKBOOLDLLEXP kbNode : public kbLPoint
|
||||
{
|
||||
protected:
|
||||
Bool_Engine* _GC;
|
||||
public:
|
||||
// friend must be deleted in the final version!
|
||||
friend class Debug_driver;
|
||||
|
||||
// constructors and destructors
|
||||
kbNode( Bool_Engine* GC );
|
||||
|
||||
kbNode( const B_INT, const B_INT, Bool_Engine* GC );
|
||||
|
||||
kbNode( kbLPoint* const a_point, Bool_Engine* GC );
|
||||
kbNode( kbNode * const, Bool_Engine* GC );
|
||||
kbNode& operator=( const kbNode &other_node );
|
||||
~kbNode();
|
||||
|
||||
//public member functions
|
||||
void AddLink( kbLink* );
|
||||
DL_List<void*>* GetLinklist();
|
||||
|
||||
//! check two link for its operation flags to be the same when coming from the prev link.
|
||||
bool SameSides( kbLink* const prev , kbLink* const link, BOOL_OP operation );
|
||||
|
||||
//! get the link most right or left to the current link, but with the specific operation
|
||||
/*! flags the same on the sides of the new link.
|
||||
*/
|
||||
kbLink* GetMost( kbLink* const prev , LinkStatus whatside, BOOL_OP operation );
|
||||
|
||||
//! get link that is leading to a hole ( hole segment or linking segment )
|
||||
kbLink* GetMostHole( kbLink* const prev , LinkStatus whatside, BOOL_OP operation,
|
||||
bool searchholelink = true );
|
||||
|
||||
//! get link that is not vertical.
|
||||
kbLink* GetNotFlat();
|
||||
|
||||
//! get a link to a hole or from a hole.
|
||||
kbLink* GetHoleLink( kbLink* const prev, LinkStatus whatside,
|
||||
bool checkbin, BOOL_OP operation );
|
||||
|
||||
int Merge( kbNode* );
|
||||
void RemoveLink( kbLink* );
|
||||
bool Simplify( kbNode* First, kbNode* Second, B_INT Marge );
|
||||
|
||||
// memberfunctions for maximum performance
|
||||
void RoundInt( B_INT grid );
|
||||
kbLink* GetIncomingLink();
|
||||
|
||||
int GetNumberOfLinks();
|
||||
kbLink* GetNextLink();
|
||||
kbLink* GetOtherLink( kbLink* );
|
||||
kbLink* GetOutgoingLink();
|
||||
kbLink* GetPrevLink();
|
||||
|
||||
kbLink* Follow( kbLink* const prev );
|
||||
kbLink* GetBinHighest( bool binset );
|
||||
|
||||
protected:
|
||||
DL_List<void*>* _linklist;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,78 +0,0 @@
|
|||
/*! \file record.h
|
||||
\author Klaas Holwerda
|
||||
|
||||
Copyright: 2001-2004 (C) Klaas Holwerda
|
||||
|
||||
Licence: see kboollicense.txt
|
||||
|
||||
RCS-ID: $Id: record.h,v 1.5 2009/09/10 17:04:09 titato Exp $
|
||||
*/
|
||||
|
||||
#ifndef RECORD_H
|
||||
#define RECORD_H
|
||||
|
||||
class kbNode;
|
||||
#include "kbool/booleng.h"
|
||||
|
||||
#include "kbool/link.h"
|
||||
#include "kbool/line.h"
|
||||
|
||||
enum BEAM_TYPE { NORMAL, FLAT};
|
||||
|
||||
enum DIRECTION {GO_LEFT, GO_RIGHT};
|
||||
|
||||
//extern void DeleteRecordPool();
|
||||
class A2DKBOOLDLLEXP Bool_Engine;
|
||||
|
||||
class A2DKBOOLDLLEXP kbRecord
|
||||
{
|
||||
protected:
|
||||
Bool_Engine* _GC;
|
||||
public:
|
||||
// void deletepool();
|
||||
|
||||
kbRecord( kbLink* link, Bool_Engine* GC );
|
||||
|
||||
~kbRecord();
|
||||
|
||||
// void* operator new(size_t size);
|
||||
|
||||
// void operator delete(void* recordptr);
|
||||
|
||||
void SetNewLink( kbLink* link );
|
||||
|
||||
void Set_Flags();
|
||||
|
||||
void Calc_Ysp( kbNode* low );
|
||||
|
||||
kbLink* GetLink();
|
||||
|
||||
kbLine* GetLine();
|
||||
|
||||
B_INT Ysp();
|
||||
|
||||
void SetYsp( B_INT ysp );
|
||||
|
||||
DIRECTION Direction();
|
||||
|
||||
bool Calc_Left_Right( kbRecord* record_above_me );
|
||||
|
||||
bool Equal( kbRecord* );
|
||||
|
||||
private:
|
||||
kbLine _line;
|
||||
|
||||
B_INT _ysp;
|
||||
|
||||
//! going left are right in beam
|
||||
DIRECTION _dir;
|
||||
|
||||
//! how far in group_a
|
||||
int _a;
|
||||
|
||||
//! how far in group_b
|
||||
int _b;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,58 +0,0 @@
|
|||
/*! \file scanbeam.h
|
||||
\author Klaas Holwerda
|
||||
|
||||
Copyright: 2001-2004 (C) Klaas Holwerda
|
||||
|
||||
Licence: see kboollicense.txt
|
||||
|
||||
RCS-ID: $Id: scanbeam.h,v 1.6 2009/09/10 17:04:09 titato Exp $
|
||||
*/
|
||||
|
||||
#ifndef SCANBEAM_H
|
||||
#define SCANBEAM_H
|
||||
|
||||
#include "kbool/booleng.h"
|
||||
#include "kbool/_lnk_itr.h"
|
||||
|
||||
#include "kbool/record.h"
|
||||
#include "kbool/link.h"
|
||||
|
||||
enum SCANTYPE{NODELINK, LINKLINK, GENLR, LINKHOLES, INOUT};
|
||||
|
||||
#if defined(WXART2D_USINGDLL)
|
||||
template class A2DKBOOLDLLEXP DL_Iter<kbRecord*>;
|
||||
#endif
|
||||
|
||||
class A2DKBOOLDLLEXP ScanBeam : public DL_List<kbRecord*>
|
||||
{
|
||||
protected:
|
||||
Bool_Engine* _GC;
|
||||
|
||||
public:
|
||||
ScanBeam( Bool_Engine* GC );
|
||||
~ScanBeam();
|
||||
void SetType( kbNode* low, kbNode* high );
|
||||
|
||||
bool FindNew( SCANTYPE scantype, TDLI<kbLink>* _I, bool& holes );
|
||||
bool RemoveOld( SCANTYPE scantype, TDLI<kbLink>* _I, bool& holes );
|
||||
|
||||
private:
|
||||
|
||||
bool ProcessHoles( bool atinsert, TDLI<kbLink>* _LI );
|
||||
int Process_LinkToLink_Crossings(); // find crossings
|
||||
int Process_PointToLink_Crossings();
|
||||
int Process_LinkToLink_Flat( kbLine* flatline );
|
||||
void SortTheBeam( bool backangle );
|
||||
bool checksort();
|
||||
bool writebeam();
|
||||
void Calc_Ysp();
|
||||
//int FindCloseLinksAndCross(TDLI<kbLink>* _I,kbNode* _lowf);
|
||||
void Generate_INOUT( int graphnumber );
|
||||
|
||||
kbNode* _low;
|
||||
DL_Iter<kbRecord*> _BI;
|
||||
int lastinserted;
|
||||
BEAM_TYPE _type;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,54 +0,0 @@
|
|||
/*! \file statusb.h
|
||||
\author Probably Klaas Holwerda
|
||||
|
||||
Copyright: 2001-2004 (C) Probably Klaas Holwerda
|
||||
|
||||
Licence: see kboollicense.txt
|
||||
|
||||
RCS-ID: $Id: statusb.h,v 1.3 2009/02/06 21:33:03 titato Exp $
|
||||
*/
|
||||
|
||||
/* @@(#) $Source: /cvsroot/wxart2d/wxArt2D/thirdparty/kbool/include/kbool/statusb.h,v $ $Revision: 1.3 $ $Date: 2009/02/06 21:33:03 $ */
|
||||
|
||||
/*
|
||||
Program STATUSB.H
|
||||
Purpose Controls the statusbar of the application (header)
|
||||
This statusbar is a typical Windows statusbar
|
||||
For porting to another platform there must be a StatusBar class
|
||||
derived from this.
|
||||
User interface element (See documentation for more details
|
||||
about the functions needed in this class)
|
||||
*/
|
||||
|
||||
#ifndef STATUSB_H
|
||||
#define STATUSB_H
|
||||
#include <time.h>
|
||||
|
||||
// abstract base class for own statusbar inherite from it
|
||||
class A2DKBOOLDLLEXP StatusBar
|
||||
{
|
||||
public:
|
||||
// constructor & destructor
|
||||
StatusBar(){};
|
||||
~StatusBar(){};
|
||||
|
||||
virtual void SetXY( double = 0.0, double = 0.0 ) = 0;
|
||||
virtual void ResetCoord() = 0;
|
||||
virtual void SetFile( char* = 0 ) = 0;
|
||||
virtual void SetProcess( char* = 0 ) = 0;
|
||||
virtual void SetTime( time_t seconds = 0 ) = 0;
|
||||
virtual void SetRecording( int status = 0 ) = 0;
|
||||
virtual void SetZoom( float factor = 1 ) = 0;
|
||||
virtual void Reset() = 0;
|
||||
void StartDTimer();
|
||||
void EndDTimer();
|
||||
int GetDTimerOn();
|
||||
time_t GetDTimer();
|
||||
|
||||
protected:
|
||||
int timer;
|
||||
time_t oldtime;
|
||||
time_t curtime;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,9 +0,0 @@
|
|||
/*! \file valuesvc.h
|
||||
\author Probably Klaas Holwerda
|
||||
|
||||
Copyright: 2001-2004 (C) Probably Klaas Holwerda
|
||||
|
||||
Licence: see kboollicense.txt
|
||||
|
||||
RCS-ID: $Id: valuesvc.h,v 1.2 2009/02/06 21:33:03 titato Exp $
|
||||
*/
|
|
@ -1,7 +0,0 @@
|
|||
Boolean: GDSII viewer/editor + (boolean) operations on sets of 2d polygons.
|
||||
Boolean Web Site:
|
||||
http://boolean.klaasholwerda.nl/bool.html
|
||||
|
||||
kbool is also used in wxArt2D
|
||||
see www.wxart2d.org
|
||||
the last version of kbool can be found on this site.
|
|
@ -1,684 +0,0 @@
|
|||
The kbool library is dual licensed.
|
||||
The GPL applies for open source, but for commercial use it is proprietary.
|
||||
Contact copyright holder for more information on other licensing schemes.
|
||||
|
||||
Software library is provided "AS IS" without warranty of any kind, conform point 16 and 17 down here.
|
||||
|
||||
Next a copy of the GPL license text.
|
||||
|
||||
==========================================================================
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
|
@ -1,11 +0,0 @@
|
|||
add_executable(boolonly boolonly.cpp)
|
||||
|
||||
if(WIN32)
|
||||
add_definitions(-D_MSWVC_)
|
||||
else(WIN32)
|
||||
add_definitions(-D__UNIX__)
|
||||
endif(WIN32)
|
||||
|
||||
include_directories(${kbool_SOURCE_DIR}/..)
|
||||
|
||||
target_link_libraries(boolonly kbool)
|
|
@ -1,373 +0,0 @@
|
|||
/*! \file samples/boolonly/boolonly.cpp
|
||||
\brief boolonly demonstrates the use of the boolean algorithm
|
||||
\author Probably Klaas Holwerda
|
||||
|
||||
Copyright: 2001-2004 (C) Probably Klaas Holwerda
|
||||
|
||||
Licence: see kboollicense.txt
|
||||
|
||||
RCS-ID: $Id: boolonly.cpp,v 1.7 2009/05/28 19:49:48 titato Exp $
|
||||
*/
|
||||
|
||||
|
||||
#include "boolonly.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
// Constructors
|
||||
KBoolPoint::KBoolPoint()
|
||||
{
|
||||
_x = 0.0;
|
||||
_y = 0.0;
|
||||
}
|
||||
|
||||
KBoolPoint::KBoolPoint( double const X, double const Y )
|
||||
{
|
||||
_x = X;
|
||||
_y = Y;
|
||||
}
|
||||
|
||||
double KBoolPoint::GetX()
|
||||
{
|
||||
return _x;
|
||||
}
|
||||
|
||||
double KBoolPoint::GetY()
|
||||
{
|
||||
return _y;
|
||||
}
|
||||
|
||||
template class TDLI<KBoolPoint>;
|
||||
|
||||
|
||||
void ArmBoolEng( Bool_Engine* booleng )
|
||||
{
|
||||
// set some global vals to arm the boolean engine
|
||||
double DGRID = 1000; // round coordinate X or Y value in calculations to this
|
||||
double MARGE = 0.001; // snap with in this range points to lines in the intersection routines
|
||||
// should always be > DGRID a MARGE >= 10*DGRID is oke
|
||||
// this is also used to remove small segments and to decide when
|
||||
// two segments are in line.
|
||||
double CORRECTIONFACTOR = 500.0; // correct the polygons by this number
|
||||
double CORRECTIONABER = 1.0; // the accuracy for the rounded shapes used in correction
|
||||
double ROUNDFACTOR = 1.5; // when will we round the correction shape to a circle
|
||||
double SMOOTHABER = 10.0; // accuracy when smoothing a polygon
|
||||
double MAXLINEMERGE = 1000.0; // leave as is, segments of this length in smoothen
|
||||
|
||||
|
||||
// DGRID is only meant to make fractional parts of input data which
|
||||
// are doubles, part of the integers used in vertexes within the boolean algorithm.
|
||||
// Within the algorithm all input data is multiplied with DGRID
|
||||
|
||||
// space for extra intersection inside the boolean algorithms
|
||||
// only change this if there are problems
|
||||
int GRID = 10000;
|
||||
|
||||
booleng->SetMarge( MARGE );
|
||||
booleng->SetGrid( GRID );
|
||||
booleng->SetDGrid( DGRID );
|
||||
booleng->SetCorrectionFactor( CORRECTIONFACTOR );
|
||||
booleng->SetCorrectionAber( CORRECTIONABER );
|
||||
booleng->SetSmoothAber( SMOOTHABER );
|
||||
booleng->SetMaxlinemerge( MAXLINEMERGE );
|
||||
booleng->SetRoundfactor( ROUNDFACTOR );
|
||||
|
||||
}
|
||||
|
||||
void AddPolygonsToBoolEng2( Bool_Engine* booleng )
|
||||
{
|
||||
int x1 = 100;
|
||||
int x2 = 200;
|
||||
int y1 = 100;
|
||||
int y2 = 200;
|
||||
int pitch1 = 200;
|
||||
int numRowsAndCols = 120;
|
||||
int i, j;
|
||||
|
||||
for ( i = 0; i < numRowsAndCols; i++ )
|
||||
{
|
||||
for ( j = 0; j < numRowsAndCols; j++ )
|
||||
{
|
||||
// foreach point in a polygon ...
|
||||
if ( booleng->StartPolygonAdd( GROUP_A ) )
|
||||
{
|
||||
// Counter-Clockwise
|
||||
booleng->AddPoint( x1, y1 );
|
||||
booleng->AddPoint( x2, y1 );
|
||||
booleng->AddPoint( x2, y2 );
|
||||
booleng->AddPoint( x1, y2 );
|
||||
|
||||
}
|
||||
booleng->EndPolygonAdd();
|
||||
x1 += pitch1;
|
||||
x2 += pitch1;
|
||||
}
|
||||
x1 = 100;
|
||||
x2 = 200;
|
||||
|
||||
y1 += pitch1;
|
||||
y2 += pitch1;
|
||||
|
||||
}
|
||||
|
||||
x1 = 150;
|
||||
x2 = 250;
|
||||
y1 = 150;
|
||||
y2 = 250;
|
||||
|
||||
for ( i = 0; i < numRowsAndCols; i++ )
|
||||
{
|
||||
for ( int j = 0; j < numRowsAndCols; j++ )
|
||||
{
|
||||
// foreach point in a polygon ...
|
||||
if ( booleng->StartPolygonAdd( GROUP_B ) )
|
||||
{
|
||||
// Counter Clockwise
|
||||
booleng->AddPoint( x1, y1 );
|
||||
booleng->AddPoint( x2, y1 );
|
||||
booleng->AddPoint( x2, y2 );
|
||||
booleng->AddPoint( x1, y2 );
|
||||
|
||||
}
|
||||
booleng->EndPolygonAdd();
|
||||
x1 += pitch1;
|
||||
x2 += pitch1;
|
||||
}
|
||||
x1 = 150;
|
||||
x2 = 250;
|
||||
|
||||
y1 += pitch1;
|
||||
y2 += pitch1;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void AddPolygonsToBoolEng( Bool_Engine* booleng )
|
||||
{
|
||||
// foreach point in a polygon ...
|
||||
if ( booleng->StartPolygonAdd( GROUP_A ) )
|
||||
{
|
||||
booleng->AddPoint( 28237.480000, 396.364000 );
|
||||
booleng->AddPoint( 28237.980000, 394.121000 );
|
||||
booleng->AddPoint( 28242.000000, 395.699000 );
|
||||
booleng->AddPoint( 28240.830000, 397.679000 );
|
||||
}
|
||||
booleng->EndPolygonAdd();
|
||||
|
||||
// foreach point in a polygon ...
|
||||
if ( booleng->StartPolygonAdd( GROUP_B ) )
|
||||
{
|
||||
booleng->AddPoint( 28242.100000, 398.491000 );
|
||||
booleng->AddPoint( 28240.580000, 397.485000 );
|
||||
booleng->AddPoint( 28237.910000, 394.381000 );
|
||||
}
|
||||
booleng->EndPolygonAdd();
|
||||
|
||||
if ( booleng->StartPolygonAdd( GROUP_B ) )
|
||||
{
|
||||
booleng->AddPoint( 28243.440000, 399.709000 );
|
||||
booleng->AddPoint( 28237.910000, 394.381000 );
|
||||
booleng->AddPoint( 28239.290000, 394.763000 );
|
||||
}
|
||||
booleng->EndPolygonAdd();
|
||||
}
|
||||
|
||||
void AddPolygonsToBoolEng3( Bool_Engine* booleng )
|
||||
{
|
||||
// foreach point in a polygon ...
|
||||
if ( booleng->StartPolygonAdd( GROUP_A ) )
|
||||
{
|
||||
booleng->AddPoint( 100, 100 );
|
||||
booleng->AddPoint( -100, 100 );
|
||||
booleng->AddPoint( -100, -100 );
|
||||
booleng->AddPoint( 100, -100 );
|
||||
}
|
||||
booleng->EndPolygonAdd();
|
||||
|
||||
// foreach point in a polygon ...
|
||||
if ( booleng->StartPolygonAdd( GROUP_B ) )
|
||||
{
|
||||
booleng->AddPoint( 50, 50 );
|
||||
booleng->AddPoint( -50, 50 );
|
||||
booleng->AddPoint( -50, -50 );
|
||||
booleng->AddPoint( 50, -50 );
|
||||
booleng->EndPolygonAdd();
|
||||
}
|
||||
booleng->EndPolygonAdd();
|
||||
}
|
||||
|
||||
void AddPolygonsToBoolEng4( Bool_Engine* booleng )
|
||||
{
|
||||
// foreach point in a polygon ...
|
||||
if ( booleng->StartPolygonAdd( GROUP_A ) )
|
||||
{
|
||||
booleng->AddPoint( 0, 0 );
|
||||
booleng->AddPoint( 0, 1000 );
|
||||
booleng->AddPoint( 1000, 1000 );
|
||||
booleng->AddPoint( 1000, 0 );
|
||||
}
|
||||
booleng->EndPolygonAdd();
|
||||
}
|
||||
|
||||
void GetPolygonsFromBoolEng( Bool_Engine* booleng )
|
||||
{
|
||||
// foreach resultant polygon in the booleng ...
|
||||
while ( booleng->StartPolygonGet() )
|
||||
{
|
||||
// foreach point in the polygon
|
||||
while ( booleng->PolygonHasMorePoints() )
|
||||
{
|
||||
fprintf( stderr, "x = %f\t", booleng->GetPolygonXPoint() );
|
||||
fprintf( stderr, "y = %f\n", booleng->GetPolygonYPoint() );
|
||||
}
|
||||
booleng->EndPolygonGet();
|
||||
}
|
||||
}
|
||||
|
||||
void GetPolygonsFromBoolEngKEY( Bool_Engine* booleng )
|
||||
{
|
||||
FILE * file = fopen( "keyfile.key", "w" );
|
||||
|
||||
fprintf( file, "\
|
||||
HEADER 5; \
|
||||
BGNLIB; \
|
||||
LASTMOD {2-11-15 15:39:21}; \
|
||||
LASTACC {2-11-15 15:39:21}; \
|
||||
LIBNAME trial; \
|
||||
UNITS; \
|
||||
USERUNITS 0.0001; PHYSUNITS 2.54e-009; \
|
||||
\
|
||||
BGNSTR; \
|
||||
CREATION {2-11-15 15:39:21}; \
|
||||
LASTMOD {2-11-15 15:39:21}; \
|
||||
STRNAME top; \
|
||||
");
|
||||
// foreach resultant polygon in the booleng ...
|
||||
while ( booleng->StartPolygonGet() )
|
||||
{
|
||||
fprintf(file,"BOUNDARY; LAYER 2; DATATYPE 0;\n");
|
||||
fprintf(file," XY % d; \n",booleng->GetNumPointsInPolygon()+1 );
|
||||
|
||||
booleng->PolygonHasMorePoints();
|
||||
double firstx = booleng->GetPolygonXPoint();
|
||||
double firsty = booleng->GetPolygonYPoint();
|
||||
fprintf(file,"X % f;\t", firstx);
|
||||
fprintf(file,"Y % f; \n", firsty);
|
||||
|
||||
// foreach point in the polygon
|
||||
while ( booleng->PolygonHasMorePoints() )
|
||||
{
|
||||
fprintf(file,"X % f;\t", booleng->GetPolygonXPoint());
|
||||
fprintf(file,"Y % f; \n", booleng->GetPolygonYPoint());
|
||||
}
|
||||
booleng->EndPolygonGet();
|
||||
fprintf(file,"X % f;\t", firstx);
|
||||
fprintf(file,"Y % f; \n", firsty);
|
||||
fprintf(file,"ENDEL;\n");
|
||||
}
|
||||
|
||||
fprintf(file,"\
|
||||
ENDSTR top; \
|
||||
ENDLIB; \
|
||||
");
|
||||
fclose (file);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
printf( "------------------------------------------------------\n" );
|
||||
printf( " | Unit test of the KBool Engine | \n" );
|
||||
printf( "------------------------------------------------------\n" );
|
||||
|
||||
float correction;
|
||||
char a = '1';
|
||||
while (a != '0')
|
||||
{
|
||||
Bool_Engine* booleng = new Bool_Engine();
|
||||
ArmBoolEng( booleng );
|
||||
|
||||
AddPolygonsToBoolEng3( booleng );
|
||||
|
||||
printf( "\n***********************************\n" );
|
||||
printf( "*** version: % s \n", booleng->GetVersion().c_str() );
|
||||
printf( "***********************************\n" );
|
||||
printf( "1: OR operation\n" );
|
||||
printf( "2: AND operation\n" );
|
||||
printf( "3: EXOR operation\n" );
|
||||
printf( "4: A subtract B\n" );
|
||||
printf( "5: B subtract A\n" );
|
||||
printf( "6: Correct each polygon with a factor\n" );
|
||||
printf( "7: Smoothen each polygon\n" );
|
||||
printf( "8: Make a ring around each polygon\n" );
|
||||
printf( "9: No operation\n" );
|
||||
printf( "0: Quit\n" );
|
||||
printf( "***********************************\n" );
|
||||
|
||||
printf( "type a number and <return>" );
|
||||
scanf("%c", &a, 1);
|
||||
//scanf( " % c", &a );
|
||||
|
||||
switch (a)
|
||||
{
|
||||
case ('0'):
|
||||
{
|
||||
GetPolygonsFromBoolEng( booleng );
|
||||
break;
|
||||
}
|
||||
case ('1'):
|
||||
booleng->Do_Operation(BOOL_OR);
|
||||
break;
|
||||
case ('2'):
|
||||
booleng->Do_Operation(BOOL_AND);
|
||||
break;
|
||||
case ('3'):
|
||||
booleng->Do_Operation(BOOL_EXOR);
|
||||
break;
|
||||
case ('4'):
|
||||
booleng->Do_Operation(BOOL_A_SUB_B);
|
||||
break;
|
||||
case ('5'):
|
||||
booleng->Do_Operation(BOOL_B_SUB_A);
|
||||
break;
|
||||
case ('6'):
|
||||
printf( "give correction factor ( eg. 100.0 or - 100.0 )<return>: ");
|
||||
scanf(" % f", &correction ); // correct the polygons by this number
|
||||
booleng->SetCorrectionFactor( correction );
|
||||
booleng->Do_Operation(BOOL_CORRECTION);
|
||||
break;
|
||||
case ('7'):
|
||||
booleng->Do_Operation(BOOL_SMOOTHEN);
|
||||
break;
|
||||
case ('8'):
|
||||
printf("give width of ring <return>: ");
|
||||
scanf(" % f", &correction );
|
||||
// create a ring of this size
|
||||
booleng->SetCorrectionFactor( fabs( correction / 2.0) );
|
||||
booleng->Do_Operation(BOOL_MAKERING);
|
||||
break;
|
||||
case ('9'):
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (a != '0')
|
||||
{
|
||||
printf("\nresulting polygons\n" );
|
||||
|
||||
GetPolygonsFromBoolEng( booleng );
|
||||
|
||||
//OR USE THIS
|
||||
//GetPolygonsFromBoolEngKEY( booleng );
|
||||
|
||||
printf( "\n\ntype a character and <return>");
|
||||
scanf( " % c", &a );
|
||||
}
|
||||
delete booleng;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/*! \file kbool/samples/boolonly/boolonly.h
|
||||
\author Probably Klaas Holwerda
|
||||
|
||||
Copyright: 2001-2004 (C) Probably Klaas Holwerda
|
||||
|
||||
Licence: see kboollicense.txt
|
||||
|
||||
RCS-ID: $Id: boolonly.h,v 1.5 2009/02/06 21:33:03 titato Exp $
|
||||
*/
|
||||
|
||||
#include "kbool/booleng.h"
|
||||
#include "kbool/_lnk_itr.h"
|
||||
|
||||
class KBoolPoint
|
||||
{
|
||||
public:
|
||||
|
||||
KBoolPoint();
|
||||
KBoolPoint( double const , double const );
|
||||
double GetX();
|
||||
double GetY();
|
||||
|
||||
private:
|
||||
double _x;
|
||||
double _y;
|
||||
|
||||
};
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
mondrian ICON "sample.ico"
|
||||
#include "wx/msw/wx.rc"
|
|
@ -1,21 +0,0 @@
|
|||
if(WIN32)
|
||||
add_definitions(-D_MSWVC_)
|
||||
else(WIN32)
|
||||
add_definitions(-D__UNIX__)
|
||||
endif(WIN32)
|
||||
|
||||
|
||||
include_directories(../include)
|
||||
|
||||
set(KBOOL_SRCS
|
||||
booleng.cpp
|
||||
graph.cpp
|
||||
graphlst.cpp
|
||||
line.cpp
|
||||
link.cpp
|
||||
lpoint.cpp
|
||||
node.cpp
|
||||
record.cpp
|
||||
scanbeam.cpp)
|
||||
|
||||
add_library(kbool STATIC ${KBOOL_SRCS})
|
|
@ -1,585 +0,0 @@
|
|||
/*! \file src/booleng.cpp
|
||||
\author Klaas Holwerda
|
||||
|
||||
Copyright: 2001-2004 (C) Klaas Holwerda
|
||||
|
||||
Licence: see kboollicense.txt
|
||||
|
||||
RCS-ID: $Id: booleng.cpp,v 1.7 2009/09/14 16:50:12 titato Exp $
|
||||
*/
|
||||
|
||||
#include "kbool/booleng.h"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "kbool/link.h"
|
||||
#include "kbool/line.h"
|
||||
#include "kbool/node.h"
|
||||
#include "kbool/graph.h"
|
||||
#include "kbool/graphlst.h"
|
||||
|
||||
B_INT bmin( B_INT const value1, B_INT const value2 )
|
||||
{
|
||||
return( ( value1 < value2 ) ? value1 : value2 );
|
||||
}
|
||||
|
||||
B_INT bmax( B_INT const value1, B_INT const value2 )
|
||||
{
|
||||
return( ( value1 > value2 ) ? value1 : value2 );
|
||||
}
|
||||
|
||||
B_INT babs( B_INT a )
|
||||
{
|
||||
if ( a < 0 ) a = -a;
|
||||
return a;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------/
|
||||
//----------------- Bool_Engine_Error -------------------------------/
|
||||
//-------------------------------------------------------------------/
|
||||
|
||||
Bool_Engine_Error::Bool_Engine_Error( string message, string header, int degree, int fatal )
|
||||
{
|
||||
_message = message;
|
||||
_header = header;
|
||||
|
||||
_degree = degree;
|
||||
_fatal = fatal;
|
||||
|
||||
}
|
||||
|
||||
Bool_Engine_Error::Bool_Engine_Error( const Bool_Engine_Error& a )
|
||||
{
|
||||
_message = a._message;
|
||||
_header = a._header;
|
||||
|
||||
_degree = a._degree;
|
||||
_fatal = a._fatal;
|
||||
|
||||
}
|
||||
|
||||
Bool_Engine_Error::~Bool_Engine_Error()
|
||||
{
|
||||
_message = "";
|
||||
_header = "";
|
||||
}
|
||||
|
||||
string Bool_Engine_Error::GetErrorMessage()
|
||||
{
|
||||
return _message;
|
||||
}
|
||||
|
||||
string Bool_Engine_Error::GetHeaderMessage()
|
||||
{
|
||||
return _header;
|
||||
}
|
||||
|
||||
int Bool_Engine_Error::GetErrorDegree()
|
||||
{
|
||||
return _degree;
|
||||
}
|
||||
|
||||
int Bool_Engine_Error::GetFatal()
|
||||
{
|
||||
return _fatal;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------/
|
||||
//----------------- Bool_Engine -------------------------------------/
|
||||
//-------------------------------------------------------------------/
|
||||
|
||||
Bool_Engine::Bool_Engine()
|
||||
{
|
||||
_linkiter = new TDLI<kbLink>();
|
||||
m_intersectionruns = 1;
|
||||
|
||||
m_orientationEntryMode = false;
|
||||
m_doLinkHoles = true;
|
||||
m_allowNonTopHoleLinking = true;
|
||||
|
||||
m_graphlist = new kbGraphList( this );
|
||||
m_ACCUR = 1e-4;
|
||||
m_WINDINGRULE = true;
|
||||
m_GraphToAdd = NULL;
|
||||
m_firstNodeToAdd = NULL;
|
||||
m_lastNodeToAdd = NULL;
|
||||
|
||||
m_logfile = NULL;
|
||||
|
||||
#if KBOOL_LOG == 1
|
||||
SetLog( true );
|
||||
#else
|
||||
SetLog( false );
|
||||
#endif
|
||||
}
|
||||
|
||||
Bool_Engine::~Bool_Engine()
|
||||
{
|
||||
if ( m_logfile != NULL )
|
||||
fclose ( m_logfile );
|
||||
|
||||
delete _linkiter;
|
||||
delete m_graphlist;
|
||||
}
|
||||
|
||||
void Bool_Engine::SetLog( bool OnOff )
|
||||
{
|
||||
m_doLog = OnOff;
|
||||
if ( m_doLog )
|
||||
{
|
||||
if ( m_logfile == NULL )
|
||||
{
|
||||
// create a new logfile
|
||||
m_logfile = fopen( KBOOL_LOGFILE, "w" );
|
||||
if ( m_logfile == NULL )
|
||||
fprintf( stderr, "Bool_Engine: Unable to write to Boolean Engine logfile\n" );
|
||||
else
|
||||
{
|
||||
time_t timer;
|
||||
struct tm * today;
|
||||
timer = time( NULL );
|
||||
today = localtime( &timer );
|
||||
|
||||
fprintf( m_logfile, "Logfile created on:\t\t\t%s", ctime( &timer ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_logfile != NULL )
|
||||
{
|
||||
fclose ( m_logfile );
|
||||
m_logfile = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Bool_Engine::SetState( string process )
|
||||
{
|
||||
Write_Log( process );
|
||||
}
|
||||
|
||||
void Bool_Engine::error( string text, string title )
|
||||
{
|
||||
Write_Log( "FATAL ERROR: ", title );
|
||||
Write_Log( "FATAL ERROR: ", text );
|
||||
throw Bool_Engine_Error( " Fatal Error", "Fatal Error", 9, 1 );
|
||||
}
|
||||
|
||||
void Bool_Engine::info( string text, string title )
|
||||
{
|
||||
Write_Log( "FATAL ERROR: ", title );
|
||||
Write_Log( "FATAL ERROR: ", text );
|
||||
}
|
||||
|
||||
void Bool_Engine::SetMarge( double marge )
|
||||
{
|
||||
m_MARGE = marge;
|
||||
Write_Log( "Bool_Engine::m_MARGE = %f\n", m_MARGE );
|
||||
}
|
||||
|
||||
double Bool_Engine::GetAccur()
|
||||
{
|
||||
return m_ACCUR;
|
||||
}
|
||||
|
||||
void Bool_Engine::SetRoundfactor( double roundfac )
|
||||
{
|
||||
m_ROUNDFACTOR = roundfac;
|
||||
Write_Log( "Bool_Engine::m_ROUNDFACTOR = %f\n", m_ROUNDFACTOR );
|
||||
}
|
||||
|
||||
double Bool_Engine::GetRoundfactor()
|
||||
{
|
||||
return m_ROUNDFACTOR;
|
||||
}
|
||||
|
||||
double Bool_Engine::GetMarge()
|
||||
{
|
||||
return m_MARGE;
|
||||
}
|
||||
|
||||
void Bool_Engine::SetDGrid( double dgrid )
|
||||
{
|
||||
m_DGRID = dgrid;
|
||||
Write_Log( "Bool_Engine::m_DGRID = %f\n", m_DGRID );
|
||||
}
|
||||
|
||||
double Bool_Engine::GetDGrid()
|
||||
{
|
||||
return m_DGRID;
|
||||
}
|
||||
|
||||
void Bool_Engine::SetGrid( B_INT grid )
|
||||
{
|
||||
m_GRID = grid;
|
||||
Write_Log( "Bool_Engine::m_GRID = %lld\n", m_GRID );
|
||||
}
|
||||
|
||||
B_INT Bool_Engine::GetGrid()
|
||||
{
|
||||
return m_GRID;
|
||||
}
|
||||
|
||||
void Bool_Engine::SetCorrectionAber( double aber )
|
||||
{
|
||||
m_CORRECTIONABER = aber;
|
||||
Write_Log( "Bool_Engine::m_CORRECTIONABER = %f\n", m_CORRECTIONABER );
|
||||
}
|
||||
|
||||
double Bool_Engine::GetCorrectionAber()
|
||||
{
|
||||
return m_CORRECTIONABER;
|
||||
}
|
||||
|
||||
void Bool_Engine::SetCorrectionFactor( double aber )
|
||||
{
|
||||
m_CORRECTIONFACTOR = aber;
|
||||
Write_Log( "Bool_Engine::m_CORRECTIONFACTOR = %f\n", m_CORRECTIONFACTOR );
|
||||
}
|
||||
|
||||
double Bool_Engine::GetCorrectionFactor()
|
||||
{
|
||||
return m_CORRECTIONFACTOR;
|
||||
}
|
||||
|
||||
void Bool_Engine::SetSmoothAber( double aber )
|
||||
{
|
||||
m_SMOOTHABER = aber;
|
||||
Write_Log( "Bool_Engine::m_SMOOTHABER = %f\n", m_SMOOTHABER );
|
||||
}
|
||||
|
||||
double Bool_Engine::GetSmoothAber()
|
||||
{
|
||||
return m_SMOOTHABER;
|
||||
}
|
||||
|
||||
void Bool_Engine::SetMaxlinemerge( double maxline )
|
||||
{
|
||||
m_MAXLINEMERGE = maxline;
|
||||
Write_Log( "Bool_Engine::m_MAXLINEMERGE = %f\n", m_MAXLINEMERGE );
|
||||
}
|
||||
|
||||
double Bool_Engine::GetMaxlinemerge()
|
||||
{
|
||||
return m_MAXLINEMERGE;
|
||||
}
|
||||
|
||||
void Bool_Engine::SetWindingRule( bool rule )
|
||||
{
|
||||
m_WINDINGRULE = rule;
|
||||
}
|
||||
|
||||
bool Bool_Engine::GetWindingRule()
|
||||
{
|
||||
return m_WINDINGRULE;
|
||||
}
|
||||
|
||||
|
||||
void Bool_Engine::SetInternalMarge( B_INT marge )
|
||||
{
|
||||
m_MARGE = ( double )marge / m_GRID / m_DGRID;
|
||||
}
|
||||
|
||||
B_INT Bool_Engine::GetInternalMarge()
|
||||
{
|
||||
return ( B_INT ) ( m_MARGE * m_GRID * m_DGRID );
|
||||
}
|
||||
|
||||
double Bool_Engine::GetInternalCorrectionAber()
|
||||
{
|
||||
return m_CORRECTIONABER * m_GRID * m_DGRID;
|
||||
}
|
||||
|
||||
double Bool_Engine::GetInternalCorrectionFactor()
|
||||
{
|
||||
return m_CORRECTIONFACTOR * m_GRID * m_DGRID;
|
||||
}
|
||||
|
||||
double Bool_Engine::GetInternalSmoothAber()
|
||||
{
|
||||
return m_SMOOTHABER * m_GRID * m_DGRID;
|
||||
}
|
||||
|
||||
B_INT Bool_Engine::GetInternalMaxlinemerge()
|
||||
{
|
||||
return ( B_INT ) ( m_MAXLINEMERGE * m_GRID * m_DGRID );
|
||||
}
|
||||
|
||||
#define TRIALS 30
|
||||
|
||||
bool Bool_Engine::Do_Operation( BOOL_OP operation )
|
||||
{
|
||||
|
||||
#if KBOOL_DEBUG
|
||||
kbGraphList * saveme = new kbGraphList( m_graphlist );
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
switch ( operation )
|
||||
{
|
||||
case ( BOOL_OR ):
|
||||
case ( BOOL_AND ):
|
||||
case ( BOOL_EXOR ):
|
||||
case ( BOOL_A_SUB_B ):
|
||||
case ( BOOL_B_SUB_A ):
|
||||
m_graphlist->Boolean( operation, m_intersectionruns );
|
||||
break;
|
||||
case ( BOOL_CORRECTION ):
|
||||
m_graphlist->Correction();
|
||||
break;
|
||||
case ( BOOL_MAKERING ):
|
||||
m_graphlist->MakeRings();
|
||||
break;
|
||||
case ( BOOL_SMOOTHEN ):
|
||||
m_graphlist->Smoothen( GetInternalSmoothAber() );
|
||||
break;
|
||||
default:
|
||||
{
|
||||
error( "Wrong operation", "Command Error" );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( Bool_Engine_Error & error )
|
||||
{
|
||||
|
||||
#if KBOOL_DEBUG
|
||||
delete m_graphlist;
|
||||
m_graphlist = new kbGraphList( saveme );
|
||||
m_graphlist->WriteGraphsKEY( this );
|
||||
#endif
|
||||
|
||||
if ( m_logfile != NULL )
|
||||
{
|
||||
fclose ( m_logfile );
|
||||
m_logfile = NULL;
|
||||
}
|
||||
|
||||
info( error.GetErrorMessage(), "error" );
|
||||
throw error;
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
|
||||
#if KBOOL_DEBUG
|
||||
delete m_graphlist;
|
||||
m_graphlist = new kbGraphList( saveme );
|
||||
m_graphlist->WriteGraphsKEY( this );
|
||||
#endif
|
||||
|
||||
if ( m_logfile != NULL )
|
||||
{
|
||||
fclose ( m_logfile );
|
||||
m_logfile = NULL;
|
||||
}
|
||||
|
||||
info( "Unknown exception", "error" );
|
||||
throw ;
|
||||
}
|
||||
|
||||
#if KBOOL_DEBUG
|
||||
delete saveme;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Bool_Engine::StartPolygonAdd( GroupType A_or_B )
|
||||
{
|
||||
#if KBOOL_DEBUG
|
||||
if ( m_logfile != NULL )
|
||||
fprintf( m_logfile, "-> StartPolygonAdd(%d)\n", A_or_B );
|
||||
#endif
|
||||
if ( m_GraphToAdd != NULL )
|
||||
return false;
|
||||
|
||||
kbGraph *myGraph = new kbGraph( this );
|
||||
m_graphlist->insbegin( myGraph );
|
||||
m_GraphToAdd = myGraph;
|
||||
m_groupType = A_or_B;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Bool_Engine::AddPoint( double x, double y )
|
||||
{
|
||||
if ( m_GraphToAdd == NULL ){return false;}
|
||||
|
||||
double scaledx = x * m_DGRID * m_GRID;
|
||||
double scaledy = y * m_DGRID * m_GRID;
|
||||
|
||||
if ( scaledx > MAXB_INT || scaledx < MINB_INT )
|
||||
error( "X coordinate of vertex to big", "" );
|
||||
if ( scaledy > MAXB_INT || scaledy < MINB_INT )
|
||||
error( "Y coordinate of vertex to big", "" );
|
||||
|
||||
|
||||
B_INT rintx = ( ( B_INT ) ( x * m_DGRID ) ) * m_GRID;
|
||||
B_INT rinty = ( ( B_INT ) ( y * m_DGRID ) ) * m_GRID;
|
||||
kbNode *myNode = new kbNode( rintx, rinty, this );
|
||||
|
||||
// adding first point to graph
|
||||
if ( m_firstNodeToAdd == NULL )
|
||||
{
|
||||
#if KBOOL_DEBUG
|
||||
if ( m_logfile != NULL )
|
||||
{
|
||||
fprintf( m_logfile, "-> AddPt() *FIRST* :" );
|
||||
fprintf( m_logfile, " input: x = %f, y = %f\n", x, y );
|
||||
fprintf( m_logfile, " input: x = %I64d, y = %I64d\n", rintx, rinty ) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
m_firstNodeToAdd = ( kbNode * ) myNode;
|
||||
m_lastNodeToAdd = ( kbNode * ) myNode;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if KBOOL_DEBUG
|
||||
if ( m_logfile != NULL )
|
||||
{
|
||||
fprintf( m_logfile, "-> AddPt():" );
|
||||
fprintf( m_logfile, " input: x = %f, y = %f\n", x, y );
|
||||
fprintf( m_logfile, " input: x = %I64d, y = %I64d\n", rintx, rinty ) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
m_GraphToAdd->AddLink( m_lastNodeToAdd, myNode );
|
||||
m_lastNodeToAdd = ( kbNode * ) myNode;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Bool_Engine::EndPolygonAdd()
|
||||
{
|
||||
if ( m_GraphToAdd == NULL ) {return false;}
|
||||
|
||||
m_GraphToAdd->AddLink( m_lastNodeToAdd, m_firstNodeToAdd );
|
||||
m_GraphToAdd->SetGroup( m_groupType );
|
||||
m_GraphToAdd = NULL;
|
||||
m_lastNodeToAdd = NULL;
|
||||
m_firstNodeToAdd = NULL;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Bool_Engine::StartPolygonGet()
|
||||
{
|
||||
if ( !m_graphlist->empty() )
|
||||
{
|
||||
m_getGraph = ( kbGraph* ) m_graphlist->headitem();
|
||||
m_getLink = m_getGraph->GetFirstLink();
|
||||
m_getNode = m_getLink->GetBeginNode();
|
||||
m_numPtsInPolygon = m_getGraph->GetNumberOfLinks();
|
||||
m_numNodesVisited = 0;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Bool_Engine::PolygonHasMorePoints()
|
||||
{
|
||||
// see if first point
|
||||
if ( m_numNodesVisited == 0 )
|
||||
{
|
||||
// don't need to touch the m_getNode
|
||||
m_numNodesVisited++;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( m_numNodesVisited < m_numPtsInPolygon )
|
||||
{
|
||||
// traverse to the next node
|
||||
m_getNode = m_getLink->GetOther( m_getNode );
|
||||
m_getLink = m_getLink->Forth( m_getNode );
|
||||
|
||||
m_numNodesVisited++;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void Bool_Engine::EndPolygonGet()
|
||||
{
|
||||
m_graphlist->removehead();
|
||||
delete m_getGraph;
|
||||
}
|
||||
|
||||
double Bool_Engine::GetPolygonXPoint()
|
||||
{
|
||||
return m_getNode->GetX() / m_GRID / m_DGRID;
|
||||
}
|
||||
|
||||
double Bool_Engine::GetPolygonYPoint()
|
||||
{
|
||||
return m_getNode->GetY() / m_GRID / m_DGRID;
|
||||
}
|
||||
|
||||
bool Bool_Engine::GetHoleSegment()
|
||||
{
|
||||
if ( m_getLink->GetHole() )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Bool_Engine::GetHoleConnectionSegment()
|
||||
{
|
||||
if ( m_getLink->GetHoleLink() )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
kbEdgeType Bool_Engine::GetPolygonPointEdgeType()
|
||||
{
|
||||
// see if the point is the beginning of a false edge
|
||||
if ( m_getLink->GetHoleLink() )
|
||||
return KB_FALSE_EDGE;
|
||||
else
|
||||
// it's either an outside or inside edge
|
||||
if ( m_getLink->GetHole() )
|
||||
return KB_INSIDE_EDGE;
|
||||
else
|
||||
return KB_OUTSIDE_EDGE;
|
||||
}
|
||||
|
||||
|
||||
void Bool_Engine::Write_Log( string msg1 )
|
||||
{
|
||||
if ( m_logfile == NULL )
|
||||
return;
|
||||
|
||||
fprintf( m_logfile, "%s \n", msg1.c_str() );
|
||||
}
|
||||
|
||||
void Bool_Engine::Write_Log( string msg1, string msg2 )
|
||||
{
|
||||
if ( m_logfile == NULL )
|
||||
return;
|
||||
|
||||
fprintf( m_logfile, "%s %s\n", msg1.c_str(), msg2.c_str() );
|
||||
}
|
||||
|
||||
void Bool_Engine::Write_Log( string fmt, double dval )
|
||||
{
|
||||
if ( m_logfile == NULL )
|
||||
return;
|
||||
|
||||
fprintf( m_logfile, fmt.c_str(), dval );
|
||||
}
|
||||
|
||||
void Bool_Engine::Write_Log( string fmt, B_INT bval )
|
||||
{
|
||||
if ( m_logfile == NULL )
|
||||
return;
|
||||
|
||||
fprintf( m_logfile, fmt.c_str(), bval );
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,392 +0,0 @@
|
|||
/*! \file src/graphlst.cpp
|
||||
\brief Implements a list of graphs
|
||||
\author Klaas Holwerda
|
||||
|
||||
Copyright: 2001-2004 (C) Klaas Holwerda
|
||||
|
||||
Licence: see kboollicense.txt
|
||||
|
||||
RCS-ID: $Id: graphlst.cpp,v 1.4 2009/09/10 17:04:09 titato Exp $
|
||||
*/
|
||||
|
||||
//#include "debugdrv.h"
|
||||
#include "kbool/booleng.h"
|
||||
#include "kbool/graphlst.h"
|
||||
|
||||
//extern Debug_driver* _debug_driver;
|
||||
//this here is to initialize the static iterator of graphlist
|
||||
//with NOLIST constructor
|
||||
|
||||
int graphsorterX( kbGraph *, kbGraph * );
|
||||
int graphsorterY( kbGraph *, kbGraph * );
|
||||
|
||||
kbGraphList::kbGraphList( Bool_Engine* GC )
|
||||
{
|
||||
_GC = GC;
|
||||
}
|
||||
|
||||
kbGraphList::kbGraphList( kbGraphList* other )
|
||||
{
|
||||
_GC = other->_GC;
|
||||
|
||||
TDLI<kbGraph> _LI = TDLI<kbGraph>( other );
|
||||
_LI.tohead();
|
||||
while ( !_LI.hitroot() )
|
||||
{
|
||||
insend( new kbGraph( _LI.item() ) );
|
||||
_LI++;
|
||||
}
|
||||
}
|
||||
|
||||
kbGraphList::~kbGraphList()
|
||||
{
|
||||
TDLI<kbGraph> _LI = TDLI<kbGraph>( this );
|
||||
//first empty the graph
|
||||
_LI.delete_all();
|
||||
}
|
||||
|
||||
//prepare the graphlist for the boolean operations
|
||||
//group all graphs into ONE graph
|
||||
void kbGraphList::Prepare( kbGraph* total )
|
||||
{
|
||||
if ( empty() )
|
||||
return;
|
||||
|
||||
//round to grid and put in one graph
|
||||
_GC->SetState( "Simplify" );
|
||||
|
||||
// Simplify all graphs in the list
|
||||
Simplify( ( double ) _GC->GetGrid() );
|
||||
|
||||
if ( ! _GC->GetOrientationEntryMode() )
|
||||
{
|
||||
TDLI<kbGraph> _LI = TDLI<kbGraph>( this );
|
||||
_LI.tohead();
|
||||
while ( !_LI.hitroot() )
|
||||
{
|
||||
_LI.item()->MakeClockWise();
|
||||
_LI++;
|
||||
}
|
||||
}
|
||||
|
||||
Renumber();
|
||||
|
||||
//the graplist contents will be transferred to one graph
|
||||
MakeOneGraph( total );
|
||||
}
|
||||
|
||||
// the function will make from all the graphs in the graphlist one graph,
|
||||
// simply by throwing all the links in one graph, the graphnumbers will
|
||||
// not be changed
|
||||
void kbGraphList::MakeOneGraph( kbGraph* total )
|
||||
{
|
||||
TDLI<kbGraph> _LI = TDLI<kbGraph>( this );
|
||||
_LI.tohead();
|
||||
while( !_LI.hitroot() )
|
||||
{
|
||||
total->TakeOver( _LI.item() );
|
||||
delete _LI.item();
|
||||
_LI.remove();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Renumber all the graphs
|
||||
//
|
||||
void kbGraphList::Renumber()
|
||||
{
|
||||
if ( _GC->GetOrientationEntryMode() )
|
||||
{
|
||||
TDLI<kbGraph> _LI = TDLI<kbGraph>( this );
|
||||
_LI.tohead();
|
||||
while ( !_LI.hitroot() )
|
||||
{
|
||||
if ( _LI.item()->GetFirstLink()->Group() == GROUP_A )
|
||||
_LI.item()->SetNumber( 1 );
|
||||
else
|
||||
_LI.item()->SetNumber( 2 );
|
||||
_LI++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned int Number = 1;
|
||||
TDLI<kbGraph> _LI = TDLI<kbGraph>( this );
|
||||
_LI.tohead();
|
||||
while ( !_LI.hitroot() )
|
||||
{
|
||||
_LI.item()->SetNumber( Number++ );
|
||||
_LI++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Simplify the graphs
|
||||
void kbGraphList::Simplify( double marge )
|
||||
{
|
||||
TDLI<kbGraph> _LI = TDLI<kbGraph>( this );
|
||||
_LI.foreach_mf( &kbGraph::Reset_Mark_and_Bin );
|
||||
|
||||
_LI.tohead();
|
||||
while ( !_LI.hitroot() )
|
||||
{
|
||||
if ( _LI.item()->Simplify( ( B_INT ) marge ) )
|
||||
{
|
||||
if ( _LI.item()->GetNumberOfLinks() < 3 )
|
||||
// delete this graph from the graphlist
|
||||
{
|
||||
delete _LI.item();
|
||||
_LI.remove();
|
||||
}
|
||||
}
|
||||
else
|
||||
_LI++;
|
||||
}
|
||||
}
|
||||
|
||||
// Smoothen the graphs
|
||||
void kbGraphList::Smoothen( double marge )
|
||||
{
|
||||
TDLI<kbGraph> _LI = TDLI<kbGraph>( this );
|
||||
_LI.foreach_mf( &kbGraph::Reset_Mark_and_Bin );
|
||||
|
||||
_LI.tohead();
|
||||
while ( !_LI.hitroot() )
|
||||
{
|
||||
if ( _LI.item()->Smoothen( ( B_INT ) marge ) )
|
||||
{
|
||||
if ( _LI.item()->GetNumberOfLinks() < 3 )
|
||||
// delete this graph from the graphlist
|
||||
{
|
||||
delete _LI.item();
|
||||
_LI.remove();
|
||||
}
|
||||
}
|
||||
else
|
||||
_LI++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Turn off all markers in all the graphs
|
||||
void kbGraphList::UnMarkAll()
|
||||
{
|
||||
TDLI<kbGraph> _LI = TDLI<kbGraph>( this );
|
||||
_LI.foreach_mf( &kbGraph::Reset_Mark_and_Bin );
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//
|
||||
//======================== BOOLEAN FUNCTIONS ===================================
|
||||
//
|
||||
//==============================================================================
|
||||
|
||||
void kbGraphList::Correction()
|
||||
{
|
||||
TDLI<kbGraph> _LI = TDLI<kbGraph>( this );
|
||||
int todo = _LI.count();
|
||||
|
||||
if ( _GC->GetInternalCorrectionFactor() ) //not zero
|
||||
{
|
||||
_LI.tohead();
|
||||
for( int i = 0; i < todo ; i++ )
|
||||
{
|
||||
//the input graph will be empty in the end
|
||||
kbGraphList *_correct = new kbGraphList( _GC );
|
||||
{
|
||||
_LI.item()->MakeClockWise();
|
||||
_LI.item()->Correction( _correct, _GC->GetInternalCorrectionFactor() );
|
||||
|
||||
delete _LI.item();
|
||||
_LI.remove();
|
||||
|
||||
//move corrected graphlist to result
|
||||
while ( !_correct->empty() )
|
||||
{
|
||||
//add to end
|
||||
_LI.insend( ( kbGraph* )_correct->headitem() );
|
||||
_correct->removehead();
|
||||
}
|
||||
}
|
||||
delete _correct;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void kbGraphList::MakeRings()
|
||||
{
|
||||
TDLI<kbGraph> _LI = TDLI<kbGraph>( this );
|
||||
int todo = _LI.count();
|
||||
|
||||
_LI.tohead();
|
||||
for( int i = 0; i < todo ; i++ )
|
||||
{
|
||||
//the input graph will be empty in the end
|
||||
kbGraphList *_ring = new kbGraphList( _GC );
|
||||
{
|
||||
_LI.item()->MakeClockWise();
|
||||
_LI.item()->MakeRing( _ring, _GC->GetInternalCorrectionFactor() );
|
||||
|
||||
delete _LI.item();
|
||||
_LI.remove();
|
||||
|
||||
//move created rings graphs to this
|
||||
while ( !_ring->empty() )
|
||||
{
|
||||
//add to end
|
||||
( ( kbGraph* )_ring->headitem() )->MakeClockWise();
|
||||
_LI.insend( ( kbGraph* )_ring->headitem() );
|
||||
_ring->removehead();
|
||||
}
|
||||
}
|
||||
delete _ring;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//merge the graphs in the list and return the merged result
|
||||
void kbGraphList::Merge()
|
||||
{
|
||||
if ( count() <= 1 )
|
||||
return;
|
||||
|
||||
{
|
||||
TDLI<kbGraph> _LI = TDLI<kbGraph>( this );
|
||||
_LI.tohead();
|
||||
while ( !_LI.hitroot() )
|
||||
{
|
||||
_LI.item()->SetGroup( GROUP_A );
|
||||
_LI++;
|
||||
}
|
||||
}
|
||||
|
||||
kbGraph* _tomerge = new kbGraph( _GC );
|
||||
|
||||
Renumber();
|
||||
|
||||
//the graplist contents will be transferred to one graph
|
||||
MakeOneGraph( _tomerge );
|
||||
//the original is empty now
|
||||
|
||||
_tomerge->Prepare( 1 );
|
||||
_tomerge->Boolean( BOOL_OR, this );
|
||||
|
||||
delete _tomerge;
|
||||
}
|
||||
|
||||
#define TRIALS 30
|
||||
#define SAVEME 1
|
||||
|
||||
//perform boolean operation on the graphs in the list
|
||||
void kbGraphList::Boolean( BOOL_OP operation, int intersectionRunsMax )
|
||||
{
|
||||
_GC->SetState( "Performing Boolean Operation" );
|
||||
|
||||
if ( count() == 0 )
|
||||
return;
|
||||
|
||||
kbGraph* _prepared = new kbGraph( _GC );
|
||||
|
||||
if ( empty() )
|
||||
return;
|
||||
|
||||
//round to grid and put in one graph
|
||||
_GC->SetState( "Simplify" );
|
||||
|
||||
int intersectionruns = 1;
|
||||
|
||||
while ( intersectionruns <= intersectionRunsMax )
|
||||
{
|
||||
try
|
||||
{
|
||||
Prepare( _prepared );
|
||||
|
||||
if ( _prepared->GetNumberOfLinks() )
|
||||
{
|
||||
//calculate intersections etc.
|
||||
_GC->SetState( "prepare" );
|
||||
_prepared->Prepare( intersectionruns );
|
||||
//_prepared->writegraph(true);
|
||||
_prepared->Boolean( operation, this );
|
||||
}
|
||||
intersectionruns = intersectionRunsMax + 1;
|
||||
}
|
||||
catch ( Bool_Engine_Error & error )
|
||||
{
|
||||
#if KBOOL_DEBUG
|
||||
_prepared->WriteGraphKEY( _GC );
|
||||
#endif
|
||||
intersectionruns++;
|
||||
if ( intersectionruns == intersectionRunsMax )
|
||||
{
|
||||
_prepared->WriteGraphKEY( _GC );
|
||||
_GC->info( error.GetErrorMessage(), "error" );
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
|
||||
#if KBOOL_DEBUG
|
||||
_prepared->WriteGraphKEY( _GC );
|
||||
#endif
|
||||
intersectionruns++;
|
||||
if ( intersectionruns == intersectionRunsMax )
|
||||
{
|
||||
_prepared->WriteGraphKEY( _GC );
|
||||
_GC->info( "Unknown exception", "error" );
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete _prepared;
|
||||
}
|
||||
|
||||
|
||||
void kbGraphList::WriteGraphs()
|
||||
{
|
||||
TDLI<kbGraph> _LI = TDLI<kbGraph>( this );
|
||||
_LI.tohead();
|
||||
while( !_LI.hitroot() )
|
||||
{
|
||||
_LI.item()->writegraph( false );
|
||||
_LI++;
|
||||
}
|
||||
}
|
||||
|
||||
void kbGraphList::WriteGraphsKEY( Bool_Engine* GC )
|
||||
{
|
||||
FILE * file = fopen( "graphkeyfile.key", "w" );
|
||||
|
||||
fprintf( file, "\
|
||||
HEADER 5; \
|
||||
BGNLIB; \
|
||||
LASTMOD {2-11-15 15:39:21}; \
|
||||
LASTACC {2-11-15 15:39:21}; \
|
||||
LIBNAME trial; \
|
||||
UNITS; \
|
||||
USERUNITS 0.0001; PHYSUNITS 1e-009; \
|
||||
\
|
||||
BGNSTR; \
|
||||
CREATION {2-11-15 15:39:21}; \
|
||||
LASTMOD {2-11-15 15:39:21}; \
|
||||
STRNAME top; \
|
||||
");
|
||||
|
||||
TDLI<kbGraph> _LI=TDLI<kbGraph>(this);
|
||||
_LI.tohead();
|
||||
while(!_LI.hitroot())
|
||||
{
|
||||
_LI.item()->WriteKEY( GC, file );
|
||||
_LI++;
|
||||
}
|
||||
|
||||
fprintf(file,"\
|
||||
ENDSTR top; \
|
||||
ENDLIB; \
|
||||
");
|
||||
|
||||
fclose (file);
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
/*! \file kbool/src/instonly.cpp
|
||||
\author Probably Klaas Holwerda
|
||||
|
||||
Copyright: 2001-2004 (C) Probably Klaas Holwerda
|
||||
|
||||
Licence: see kboollicense.txt
|
||||
|
||||
RCS-ID: $Id: instonly.cpp,v 1.3 2009/02/06 21:33:03 titato Exp $
|
||||
*/
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma option -Jgd
|
||||
|
||||
#include "kbool/_dl_itr.h"
|
||||
#include "kbool/node.h"
|
||||
#include "kbool/record.h"
|
||||
#include "kbool/link.h"
|
||||
#include "kbool/_lnk_itr.h"
|
||||
#include "kbool/scanbeam.h"
|
||||
#include "kbool/graph.h"
|
||||
#include "kbool/graphlst.h"
|
||||
//#include "kbool/misc.h"
|
||||
|
||||
template class DL_Node<void *>;
|
||||
template class DL_Iter<void *>;
|
||||
template class DL_List<void *>;
|
||||
|
||||
template class DL_Node<int>;
|
||||
template class DL_Iter<int>;
|
||||
template class DL_List<int>;
|
||||
|
||||
template class TDLI<Node>;
|
||||
template class TDLI<LPoint>;
|
||||
template class TDLI<Record>;
|
||||
template class TDLI<KBoolLink>;
|
||||
template class TDLI<Graph>;
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -1,721 +0,0 @@
|
|||
/*! \file src/link.cpp
|
||||
\author Klaas Holwerda
|
||||
|
||||
Copyright: 2001-2004 (C) Klaas Holwerda
|
||||
|
||||
Licence: see kboollicense.txt
|
||||
|
||||
RCS-ID: $Id: link.cpp,v 1.4 2009/09/07 19:23:28 titato Exp $
|
||||
*/
|
||||
|
||||
#include "kbool/booleng.h"
|
||||
|
||||
#include "kbool/link.h"
|
||||
#include "kbool/line.h"
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "kbool/node.h"
|
||||
#include "kbool/graph.h"
|
||||
#include "kbool/graphlst.h"
|
||||
|
||||
int linkXYsorter( kbLink *, kbLink * );
|
||||
|
||||
//
|
||||
// Default constructor
|
||||
//
|
||||
kbLink::kbLink( Bool_Engine* GC )
|
||||
{
|
||||
_GC = GC;
|
||||
Reset();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// This constructor makes this link a valid part of a graph
|
||||
//
|
||||
kbLink::kbLink( int graphnr, kbNode *begin, kbNode *end, Bool_Engine* GC )
|
||||
{
|
||||
_GC = GC;
|
||||
Reset();
|
||||
|
||||
// Set the references of the node and of this link correct
|
||||
begin->AddLink( this );
|
||||
end->AddLink( this );
|
||||
m_beginnode = begin;
|
||||
m_endnode = end;
|
||||
m_graphnum = graphnr;
|
||||
}
|
||||
|
||||
//
|
||||
// This constructor makes this link a valid part of a graph
|
||||
//
|
||||
kbLink::kbLink( kbNode *begin, kbNode *end, Bool_Engine* GC )
|
||||
{
|
||||
_GC = GC;
|
||||
Reset();
|
||||
|
||||
// Set the references of the node and of this link correct
|
||||
begin->AddLink( this );
|
||||
end->AddLink( this );
|
||||
m_beginnode = begin;
|
||||
m_endnode = end;
|
||||
m_graphnum = 0;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Destructor
|
||||
//
|
||||
kbLink::~kbLink()
|
||||
{
|
||||
UnLink();
|
||||
}
|
||||
|
||||
//
|
||||
// Checks whether the current algorithm has been on this link
|
||||
//
|
||||
bool kbLink::BeenHere()
|
||||
{
|
||||
if ( m_bin ) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void kbLink::TakeOverOperationFlags( kbLink* link )
|
||||
{
|
||||
m_merge_L = link->m_merge_L;
|
||||
m_a_substract_b_L = link->m_a_substract_b_L;
|
||||
m_b_substract_a_L = link->m_b_substract_a_L;
|
||||
m_intersect_L = link->m_intersect_L;
|
||||
m_exor_L = link->m_exor_L;
|
||||
|
||||
m_merge_R = link->m_merge_R;
|
||||
m_a_substract_b_R = link->m_a_substract_b_R;
|
||||
m_b_substract_a_R = link->m_b_substract_a_R;
|
||||
m_intersect_R = link->m_intersect_R;
|
||||
m_exor_R = link->m_exor_R;
|
||||
}
|
||||
//
|
||||
// Returns the next link from the argument
|
||||
//
|
||||
kbLink* kbLink::Forth( kbNode *node )
|
||||
{
|
||||
assert( node == m_beginnode || node == m_endnode );
|
||||
return node->GetOtherLink( this );
|
||||
}
|
||||
|
||||
//
|
||||
// Returns the Beginnode
|
||||
//
|
||||
kbNode *kbLink::GetBeginNode()
|
||||
{
|
||||
return m_beginnode;
|
||||
}
|
||||
|
||||
//
|
||||
// Returns the endnode
|
||||
//
|
||||
kbNode* kbLink::GetEndNode()
|
||||
{
|
||||
return m_endnode;
|
||||
}
|
||||
|
||||
kbNode* kbLink::GetLowNode()
|
||||
{
|
||||
return ( ( m_beginnode->GetY() < m_endnode->GetY() ) ? m_beginnode : m_endnode );
|
||||
}
|
||||
|
||||
kbNode* kbLink::GetHighNode()
|
||||
{
|
||||
return ( ( m_beginnode->GetY() > m_endnode->GetY() ) ? m_beginnode : m_endnode );
|
||||
}
|
||||
|
||||
//
|
||||
// Returns the graphnumber
|
||||
//
|
||||
int kbLink::GetGraphNum()
|
||||
{
|
||||
return m_graphnum;
|
||||
}
|
||||
|
||||
bool kbLink::GetInc()
|
||||
{
|
||||
return m_Inc;
|
||||
// if (Inc) return true;
|
||||
// return false;
|
||||
}
|
||||
|
||||
void kbLink::SetInc( bool inc )
|
||||
{
|
||||
m_Inc = inc;
|
||||
// Inc=0;
|
||||
// if (inc) Inc=1;
|
||||
}
|
||||
|
||||
bool kbLink::GetLeftA()
|
||||
{
|
||||
return m_LeftA;
|
||||
}
|
||||
|
||||
void kbLink::SetLeftA( bool la )
|
||||
{
|
||||
m_LeftA = la;
|
||||
}
|
||||
|
||||
bool kbLink::GetLeftB()
|
||||
{
|
||||
return m_LeftB;
|
||||
}
|
||||
|
||||
void kbLink::SetLeftB( bool lb )
|
||||
{
|
||||
m_LeftB = lb;
|
||||
}
|
||||
|
||||
bool kbLink::GetRightA()
|
||||
{
|
||||
return m_RightA;
|
||||
}
|
||||
|
||||
void kbLink::SetRightA( bool ra )
|
||||
{
|
||||
m_RightA = ra;
|
||||
}
|
||||
|
||||
bool kbLink::GetRightB()
|
||||
{
|
||||
return m_RightB;
|
||||
}
|
||||
|
||||
void kbLink::SetRightB( bool rb )
|
||||
{
|
||||
m_RightB = rb;
|
||||
}
|
||||
|
||||
//
|
||||
// This function is very popular by GP-faults
|
||||
// It returns the node different from a
|
||||
//
|
||||
kbNode* kbLink::GetOther( const kbNode *const a )
|
||||
{
|
||||
return ( ( a != m_beginnode ) ? m_beginnode : m_endnode );
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Is this marked for given operation
|
||||
//
|
||||
bool kbLink::IsMarked( BOOL_OP operation )
|
||||
{
|
||||
switch ( operation )
|
||||
{
|
||||
case( BOOL_OR ): return m_merge_L || m_merge_R;
|
||||
case( BOOL_AND ): return m_intersect_L || m_intersect_R;
|
||||
case( BOOL_A_SUB_B ): return m_a_substract_b_L || m_a_substract_b_R;
|
||||
case( BOOL_B_SUB_A ): return m_b_substract_a_L || m_b_substract_a_R;
|
||||
case( BOOL_EXOR ): return m_exor_L || m_exor_R;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool kbLink::IsMarkedLeft( BOOL_OP operation )
|
||||
{
|
||||
switch ( operation )
|
||||
{
|
||||
case( BOOL_OR ): return m_merge_L;
|
||||
case( BOOL_AND ): return m_intersect_L;
|
||||
case( BOOL_A_SUB_B ): return m_a_substract_b_L;
|
||||
case( BOOL_B_SUB_A ): return m_b_substract_a_L;
|
||||
case( BOOL_EXOR ): return m_exor_L;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool kbLink::IsMarkedRight( BOOL_OP operation )
|
||||
{
|
||||
switch ( operation )
|
||||
{
|
||||
case( BOOL_OR ): return m_merge_R;
|
||||
case( BOOL_AND ): return m_intersect_R;
|
||||
case( BOOL_A_SUB_B ): return m_a_substract_b_R;
|
||||
case( BOOL_B_SUB_A ): return m_b_substract_a_R;
|
||||
case( BOOL_EXOR ): return m_exor_R;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Is this a hole for given operation
|
||||
// beginnode must be to the left
|
||||
bool kbLink::IsHole( BOOL_OP operation )
|
||||
{
|
||||
|
||||
bool topsideA, topsideB;
|
||||
|
||||
if ( m_beginnode->GetX() < m_endnode->GetX() ) //going to the right?
|
||||
{ topsideA = m_RightA; topsideB = m_RightB; }
|
||||
else
|
||||
{ topsideA = m_LeftA; topsideB = m_LeftB; }
|
||||
|
||||
switch ( operation )
|
||||
{
|
||||
case( BOOL_OR ): return ( !topsideB && !topsideA );
|
||||
case( BOOL_AND ): return ( !topsideB || !topsideA );
|
||||
case( BOOL_A_SUB_B ): return ( topsideB || !topsideA );
|
||||
case( BOOL_B_SUB_A ): return ( topsideA || !topsideB );
|
||||
case( BOOL_EXOR ): return !( ( topsideB && !topsideA ) || ( !topsideB && topsideA ) );
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Is this a part of a hole
|
||||
//
|
||||
bool kbLink::GetHole()
|
||||
{
|
||||
return ( m_hole );
|
||||
}
|
||||
|
||||
|
||||
void kbLink::SetHole( bool h )
|
||||
{
|
||||
m_hole = h;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Is this not marked at all
|
||||
//
|
||||
bool kbLink::IsUnused()
|
||||
{
|
||||
return
|
||||
!( m_merge_L || m_merge_R ||
|
||||
m_a_substract_b_L || m_a_substract_b_R ||
|
||||
m_b_substract_a_L || m_b_substract_a_R ||
|
||||
m_intersect_L || m_intersect_R ||
|
||||
m_exor_L || m_exor_R );
|
||||
}
|
||||
|
||||
|
||||
bool kbLink::IsZero( B_INT marge )
|
||||
{
|
||||
return ( m_beginnode->Equal( m_endnode, marge ) ) ;
|
||||
}
|
||||
|
||||
|
||||
bool kbLink::ShorterThan( B_INT marge )
|
||||
{
|
||||
return ( m_beginnode->ShorterThan( m_endnode, marge ) ) ;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Mark this link
|
||||
//
|
||||
void kbLink::Mark()
|
||||
{
|
||||
m_mark = true;
|
||||
}
|
||||
|
||||
|
||||
#ifndef ABS
|
||||
#define ABS(a) (((a)<0) ? -(a) : (a))
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// This makes from the begin and endnode one node (argument begin_or_end_node)
|
||||
// The references to this link in the node will also be deleted
|
||||
// After doing that, link link can be deleted or be recycled.
|
||||
//
|
||||
void kbLink::MergeNodes( kbNode *const begin_or_end_node )
|
||||
{
|
||||
// assert(beginnode && endnode);
|
||||
// assert ((begin_or_end_node == beginnode)||(begin_or_end_node == endnode));
|
||||
|
||||
m_beginnode->RemoveLink( this );
|
||||
m_endnode->RemoveLink( this );
|
||||
|
||||
if ( m_endnode != m_beginnode )
|
||||
{ // only if beginnode and endnode are different nodes
|
||||
begin_or_end_node->Merge( GetOther( begin_or_end_node ) );
|
||||
}
|
||||
m_endnode = NULL;
|
||||
m_beginnode = NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Return the position of the second link compared to this link
|
||||
// Result = IS_ON | IS_LEFT | IS_RIGHT
|
||||
// Here Left and Right is defined as being left or right from
|
||||
// the this link towards the center (common) node
|
||||
//
|
||||
LinkStatus kbLink::OutProduct( kbLink* const two, double accur )
|
||||
{
|
||||
kbNode * center;
|
||||
double distance;
|
||||
if ( two->GetBeginNode()->Equal( two->GetEndNode(), 1 ) )
|
||||
assert( !two );
|
||||
if ( GetBeginNode()->Equal( GetEndNode(), 1 ) )
|
||||
assert( !this );
|
||||
kbLine* temp_line = new kbLine( this, _GC );
|
||||
|
||||
//the this link should connect to the other two link at at least one node
|
||||
if ( m_endnode == two->m_endnode || m_endnode == two->m_beginnode )
|
||||
center = m_endnode;
|
||||
else
|
||||
{
|
||||
center = m_beginnode;
|
||||
// assert(center==two->endnode || center==two->beginnode);
|
||||
}
|
||||
|
||||
//here something tricky
|
||||
// the factor 10000.0 is needed to asure that the pointonline
|
||||
// is more accurate in this case compared to the intersection for graphs
|
||||
int uitp = temp_line->PointOnLine( two->GetOther( center ), distance, accur );
|
||||
|
||||
delete temp_line;
|
||||
|
||||
/*double uitp= (_x - first._x) * (third._y - _y) -
|
||||
(_y - first._y) * (third._x - _x);
|
||||
if (uitp>0) return IS_LEFT;
|
||||
if (uitp<0) return IS_RIGHT;
|
||||
return IS_ON;*/
|
||||
|
||||
//depending on direction of this link (going to or coming from centre)
|
||||
if ( center == m_endnode )
|
||||
{
|
||||
if ( uitp == LEFT_SIDE )
|
||||
return IS_LEFT;
|
||||
if ( uitp == RIGHT_SIDE )
|
||||
return IS_RIGHT;
|
||||
}
|
||||
else //center=beginnode
|
||||
{
|
||||
if ( uitp == LEFT_SIDE )
|
||||
return IS_RIGHT;
|
||||
if ( uitp == RIGHT_SIDE )
|
||||
return IS_LEFT;
|
||||
}
|
||||
return IS_ON;
|
||||
}
|
||||
|
||||
//
|
||||
// Return the position of the third link compared to this link and
|
||||
// the second link
|
||||
// Result = IS_ON | IS_LEFT | IS_RIGHT
|
||||
//
|
||||
LinkStatus kbLink::PointOnCorner( kbLink* const two, kbLink* const third )
|
||||
{
|
||||
LinkStatus
|
||||
TwoToOne, // Position of two to this line
|
||||
ThirdToOne, // Position of third to this line
|
||||
ThirdToTwo, // Position of third to two
|
||||
Result;
|
||||
|
||||
//m kbNode* center;
|
||||
|
||||
//the this link should connect to the other two link at at least one node
|
||||
//m if (endnode==two->endnode || endnode==two->beginnode)
|
||||
//m center=endnode;
|
||||
//m else
|
||||
//m { center=beginnode;
|
||||
// assert(center==two->endnode || center==two->beginnode);
|
||||
//m }
|
||||
// assert(center==third->endnode || center==third->beginnode);
|
||||
|
||||
|
||||
|
||||
// Calculate the position of the links compared to eachother
|
||||
TwoToOne = OutProduct( two, _GC->GetAccur() );
|
||||
ThirdToOne = OutProduct( third, _GC->GetAccur() );
|
||||
//center is used in outproduct to give de direction of two
|
||||
// this is why the result should be swapped
|
||||
ThirdToTwo = two->OutProduct( third, _GC->GetAccur() );
|
||||
if ( ThirdToTwo == IS_RIGHT )
|
||||
ThirdToTwo = IS_LEFT;
|
||||
else if ( ThirdToTwo == IS_LEFT )
|
||||
ThirdToTwo = IS_RIGHT;
|
||||
|
||||
// Select the result
|
||||
switch( TwoToOne )
|
||||
{
|
||||
// Line 2 lies on leftside of this line
|
||||
case IS_LEFT : if ( ( ThirdToOne == IS_RIGHT ) || ( ThirdToTwo == IS_RIGHT ) ) return IS_RIGHT;
|
||||
else if ( ( ThirdToOne == IS_LEFT ) && ( ThirdToTwo == IS_LEFT ) ) return IS_LEFT;
|
||||
else Result = IS_ON; break;
|
||||
// Line 2 lies on this line
|
||||
case IS_ON : if ( ( ThirdToOne == IS_RIGHT ) && ( ThirdToTwo == IS_RIGHT ) ) return IS_RIGHT;
|
||||
else if ( ( ThirdToOne == IS_LEFT ) && ( ThirdToTwo == IS_LEFT ) ) return IS_LEFT;
|
||||
// else if ((ThirdToOne==IS_RIGHT) && (ThirdToTwo==IS_LEFT)) return IS_RIGHT;
|
||||
// else if ((ThirdToOne==IS_LEFT) && (ThirdToTwo==IS_RIGHT)) return IS_LEFT;
|
||||
else Result = IS_ON; break;
|
||||
// Line 2 lies on right side of this line
|
||||
case IS_RIGHT : if ( ( ThirdToOne == IS_RIGHT ) && ( ThirdToTwo == IS_RIGHT ) ) return IS_RIGHT;
|
||||
else if ( ( ThirdToOne == IS_LEFT ) || ( ThirdToTwo == IS_LEFT ) ) return IS_LEFT;
|
||||
else Result = IS_ON; break;
|
||||
default: Result = IS_ON; assert( false );
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
|
||||
//
|
||||
// Remove the reference from this link to a_node
|
||||
//
|
||||
void kbLink::Remove( kbNode *a_node )
|
||||
{
|
||||
( m_beginnode == a_node ) ? m_beginnode = NULL : m_endnode = NULL;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Replace oldnode by newnode and correct the references
|
||||
//
|
||||
void kbLink::Replace( kbNode *oldnode, kbNode *newnode )
|
||||
{
|
||||
if ( m_beginnode == oldnode )
|
||||
{
|
||||
m_beginnode->RemoveLink( this ); // remove the reference to this
|
||||
newnode->AddLink( this ); // let newnode refer to this
|
||||
m_beginnode = newnode; // let this refer to newnode
|
||||
}
|
||||
else
|
||||
{ //assert(endnode==oldnode);
|
||||
m_endnode->RemoveLink( this );
|
||||
newnode->AddLink( this );
|
||||
m_endnode = newnode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Reset all values
|
||||
//
|
||||
void kbLink::Reset()
|
||||
{
|
||||
m_beginnode = 0;
|
||||
m_endnode = 0;
|
||||
Reset_flags();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Reset all flags
|
||||
//
|
||||
void kbLink::Reset_flags()
|
||||
{
|
||||
m_bin = false; // Marker for walking over the graph
|
||||
m_hole = false; // Is this a part of hole ?
|
||||
m_hole_top = false; // link that is toplink of hole?
|
||||
m_group = GROUP_A; // Does this belong to group A or B ( o.a. for boolean operations between graphs)
|
||||
m_LeftA = false; // Is left in polygongroup A
|
||||
m_RightA = false; // Is right in polygon group A
|
||||
m_LeftB = false; // Is left in polygon group B
|
||||
m_RightB = false; // Is right in polygongroup B
|
||||
m_mark = false; // General purose marker, internally unused
|
||||
m_holelink = false;
|
||||
|
||||
m_merge_L = m_merge_R = false; // Marker for Merge
|
||||
m_a_substract_b_L = m_a_substract_b_R = false; // Marker for substract
|
||||
m_b_substract_a_L = m_b_substract_a_R = false; // Marker for substract
|
||||
m_intersect_L = m_intersect_R = false; // Marker for intersect
|
||||
m_exor_L = m_exor_R = false; // Marker for Exor
|
||||
}
|
||||
|
||||
//
|
||||
// Refill this link by the arguments
|
||||
//
|
||||
void kbLink::Reset( kbNode *begin, kbNode *end, int graphnr )
|
||||
{
|
||||
// Remove all the previous references
|
||||
UnLink();
|
||||
Reset();
|
||||
// Set the references of the node and of this link correct
|
||||
begin->AddLink( this );
|
||||
end->AddLink( this );
|
||||
m_beginnode = begin;
|
||||
m_endnode = end;
|
||||
if ( graphnr != 0 )
|
||||
m_graphnum = graphnr;
|
||||
}
|
||||
|
||||
|
||||
void kbLink::Set( kbNode *begin, kbNode *end )
|
||||
{
|
||||
m_beginnode = begin;
|
||||
m_endnode = end;
|
||||
}
|
||||
|
||||
void kbLink::SetBeenHere()
|
||||
{
|
||||
m_bin = true;
|
||||
}
|
||||
|
||||
void kbLink::SetNotBeenHere()
|
||||
{
|
||||
m_bin = false;
|
||||
}
|
||||
|
||||
void kbLink::SetBeginNode( kbNode* new_node )
|
||||
{
|
||||
m_beginnode = new_node;
|
||||
}
|
||||
|
||||
|
||||
void kbLink::SetEndNode( kbNode* new_node )
|
||||
{
|
||||
m_endnode = new_node;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Sets the graphnumber to argument num
|
||||
//
|
||||
void kbLink::SetGraphNum( int num )
|
||||
{
|
||||
m_graphnum = num;
|
||||
}
|
||||
|
||||
GroupType kbLink::Group()
|
||||
{
|
||||
return m_group;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Reset the groupflag to argument groep
|
||||
//
|
||||
void kbLink::SetGroup( GroupType groep )
|
||||
{
|
||||
m_group = groep;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Remove all references to this link and from this link
|
||||
//
|
||||
void kbLink::UnLink()
|
||||
{
|
||||
if ( m_beginnode )
|
||||
{
|
||||
m_beginnode->RemoveLink( this );
|
||||
if ( !m_beginnode->GetNumberOfLinks() ) delete m_beginnode;
|
||||
}
|
||||
m_beginnode = NULL;
|
||||
if ( m_endnode )
|
||||
{
|
||||
m_endnode->RemoveLink( this );
|
||||
if ( !m_endnode->GetNumberOfLinks() ) delete m_endnode;
|
||||
}
|
||||
m_endnode = NULL;
|
||||
}
|
||||
|
||||
|
||||
void kbLink::UnMark()
|
||||
{
|
||||
m_mark = false;
|
||||
m_bin = false;
|
||||
}
|
||||
|
||||
void kbLink::SetMark( bool value )
|
||||
{
|
||||
m_mark = value;
|
||||
}
|
||||
|
||||
//
|
||||
// general purpose mark checker
|
||||
//
|
||||
bool kbLink::IsMarked() { return m_mark; }
|
||||
|
||||
void kbLink::SetTopHole( bool value ) { m_hole_top = value; }
|
||||
|
||||
bool kbLink::IsTopHole() { return m_hole_top; }
|
||||
|
||||
//
|
||||
// Calculates the merge/substact/exor/intersect flags
|
||||
//
|
||||
void kbLink::SetLineTypes()
|
||||
{
|
||||
m_merge_R =
|
||||
m_a_substract_b_R =
|
||||
m_b_substract_a_R =
|
||||
m_intersect_R =
|
||||
m_exor_R =
|
||||
m_merge_L =
|
||||
m_a_substract_b_L =
|
||||
m_b_substract_a_L =
|
||||
m_intersect_L =
|
||||
m_exor_L = false;
|
||||
|
||||
//if left side is in group A and B then it is for the merge
|
||||
m_merge_L = m_LeftA || m_LeftB;
|
||||
m_merge_R = m_RightA || m_RightB;
|
||||
//both in mean does not add to result.
|
||||
if ( m_merge_L && m_merge_R )
|
||||
m_merge_L = m_merge_R = false;
|
||||
|
||||
m_a_substract_b_L = m_LeftA && !m_LeftB;
|
||||
m_a_substract_b_R = m_RightA && !m_RightB;
|
||||
//both in mean does not add to result.
|
||||
if ( m_a_substract_b_L && m_a_substract_b_R )
|
||||
m_a_substract_b_L = m_a_substract_b_R = false;
|
||||
|
||||
m_b_substract_a_L = m_LeftB && !m_LeftA;
|
||||
m_b_substract_a_R = m_RightB && !m_RightA;
|
||||
//both in mean does not add to result.
|
||||
if ( m_b_substract_a_L && m_b_substract_a_R )
|
||||
m_b_substract_a_L = m_b_substract_a_R = false;
|
||||
|
||||
m_intersect_L = m_LeftB && m_LeftA;
|
||||
m_intersect_R = m_RightB && m_RightA;
|
||||
//both in mean does not add to result.
|
||||
if ( m_intersect_L && m_intersect_R )
|
||||
m_intersect_L = m_intersect_R = false;
|
||||
|
||||
m_exor_L = !( ( m_LeftB && m_LeftA ) || ( !m_LeftB && !m_LeftA ) );
|
||||
m_exor_R = !( ( m_RightB && m_RightA ) || ( !m_RightB && !m_RightA ) );
|
||||
//both in mean does not add to result.
|
||||
if ( m_exor_L && m_exor_R )
|
||||
m_exor_L = m_exor_R = false;
|
||||
}
|
||||
|
||||
|
||||
//put in direction with a_node as beginnode
|
||||
void kbLink::Redirect( kbNode* a_node )
|
||||
{
|
||||
if ( a_node != m_beginnode )
|
||||
{
|
||||
// swap the begin- and endnode of the current link
|
||||
kbNode * dummy = m_beginnode;
|
||||
m_beginnode = m_endnode;
|
||||
m_endnode = dummy;
|
||||
|
||||
bool swap = m_LeftA;
|
||||
m_LeftA = m_RightA;
|
||||
m_RightA = swap;
|
||||
|
||||
swap = m_LeftB;
|
||||
m_LeftB = m_RightB;
|
||||
m_RightB = swap;
|
||||
|
||||
swap = m_merge_L ;
|
||||
m_merge_L = m_merge_R;
|
||||
m_merge_R = swap;
|
||||
|
||||
swap = m_a_substract_b_L;
|
||||
m_a_substract_b_L = m_a_substract_b_R;
|
||||
m_a_substract_b_R = swap;
|
||||
|
||||
swap = m_b_substract_a_L;
|
||||
m_b_substract_a_L = m_b_substract_a_R;
|
||||
m_b_substract_a_R = swap;
|
||||
|
||||
swap = m_intersect_L;
|
||||
m_intersect_L = m_intersect_R;
|
||||
m_intersect_R = swap;
|
||||
|
||||
swap = m_exor_L;
|
||||
m_exor_L = m_exor_R;
|
||||
m_exor_R = swap;
|
||||
}
|
||||
}
|
|
@ -1,199 +0,0 @@
|
|||
/*! \file src/lpoint.cpp
|
||||
\brief Definition of GDSII kbLPoint type structure
|
||||
\author Klaas Holwerda
|
||||
|
||||
Copyright: 2001-2004 (C) Klaas Holwerda
|
||||
|
||||
Licence: see kboollicense.txt
|
||||
|
||||
RCS-ID: $Id: lpoint.cpp,v 1.4 2009/09/10 17:04:09 titato Exp $
|
||||
*/
|
||||
|
||||
#include "kbool/lpoint.h"
|
||||
#include <math.h>
|
||||
|
||||
// Constructors
|
||||
kbLPoint::kbLPoint()
|
||||
{
|
||||
_x = 0;
|
||||
_y = 0;
|
||||
}
|
||||
|
||||
|
||||
kbLPoint::kbLPoint( B_INT const X, B_INT const Y )
|
||||
{
|
||||
_x = X;
|
||||
_y = Y;
|
||||
}
|
||||
|
||||
|
||||
kbLPoint::kbLPoint( kbLPoint* const a_point )
|
||||
{
|
||||
if ( !a_point )
|
||||
throw Bool_Engine_Error( "Cannot copy a NULL Point Object.\n\nCould not create a kbLPoint Object.",
|
||||
"Fatal Creation Error", 0, 1 );
|
||||
_x = a_point->_x;
|
||||
_y = a_point->_y;
|
||||
}
|
||||
|
||||
|
||||
B_INT kbLPoint::GetX()
|
||||
{
|
||||
return _x;
|
||||
}
|
||||
|
||||
B_INT kbLPoint::GetY()
|
||||
{
|
||||
return _y;
|
||||
}
|
||||
|
||||
|
||||
void kbLPoint::SetX( B_INT a_point_x )
|
||||
{
|
||||
_x = a_point_x;
|
||||
}
|
||||
|
||||
|
||||
void kbLPoint::SetY( B_INT a_point_y )
|
||||
{
|
||||
_y = a_point_y;
|
||||
}
|
||||
|
||||
|
||||
kbLPoint kbLPoint::GetPoint()
|
||||
{
|
||||
return * this;
|
||||
}
|
||||
|
||||
|
||||
void kbLPoint::Set( const B_INT X, const B_INT Y )
|
||||
{
|
||||
_x = X;
|
||||
_y = Y;
|
||||
}
|
||||
|
||||
|
||||
void kbLPoint::Set( const kbLPoint &a_point )
|
||||
{
|
||||
_x = a_point._x;
|
||||
_y = a_point._y;
|
||||
}
|
||||
|
||||
bool kbLPoint::Equal( const kbLPoint a_point, B_INT Marge )
|
||||
{
|
||||
B_INT delta_x, delta_y;
|
||||
|
||||
delta_x = babs( ( _x - a_point._x ) );
|
||||
delta_y = babs( ( _y - a_point._y ) );
|
||||
|
||||
if ( ( delta_x <= Marge ) && ( delta_y <= Marge ) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool kbLPoint::Equal( const B_INT X, const B_INT Y, B_INT Marge )
|
||||
{
|
||||
return ( bool )( ( babs( _x - X ) <= Marge ) && ( babs( _y - Y ) <= Marge ) );
|
||||
}
|
||||
|
||||
bool kbLPoint::ShorterThan( const kbLPoint a_point, B_INT Marge )
|
||||
{
|
||||
double a, b;
|
||||
a = ( double ) ( a_point._x - _x );
|
||||
a *= a;
|
||||
b = ( double ) ( a_point._y - _y );
|
||||
b *= b;
|
||||
|
||||
return ( bool ) ( ( a + b ) <= Marge * Marge ? true : false ) ;
|
||||
}
|
||||
|
||||
|
||||
bool kbLPoint::ShorterThan( const B_INT X, const B_INT Y, B_INT Marge )
|
||||
{
|
||||
double a, b;
|
||||
a = ( double ) ( X - _x );
|
||||
a *= a;
|
||||
b = ( double ) ( Y - _y );
|
||||
b *= b;
|
||||
|
||||
return ( bool ) ( a + b <= Marge * Marge ? true : false ) ;
|
||||
}
|
||||
|
||||
|
||||
// overload the assign (=) operator
|
||||
// usage : a_point = another_point;
|
||||
|
||||
kbLPoint &kbLPoint::operator=( const kbLPoint &other_point )
|
||||
{
|
||||
_x = other_point._x;
|
||||
_y = other_point._y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// overload the + operator
|
||||
// usage : a_point = point1 + point2;
|
||||
|
||||
kbLPoint &kbLPoint::operator+( const kbLPoint &other_point )
|
||||
{
|
||||
_x += other_point._x;
|
||||
_y += other_point._y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// overload the - operator
|
||||
// usage : a_point = point1 - point2;
|
||||
|
||||
kbLPoint &kbLPoint::operator-( const kbLPoint &other_point )
|
||||
{
|
||||
_x -= other_point._x;
|
||||
_y -= other_point._y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// overload the * operator
|
||||
// usage: a_point = point1 * 100;
|
||||
|
||||
kbLPoint &kbLPoint::operator*( int factor )
|
||||
{
|
||||
_x *= factor;
|
||||
_y *= factor;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// overload the / operator
|
||||
// usage: a_point = point1 / 100;
|
||||
|
||||
kbLPoint &kbLPoint::operator/( int factor )
|
||||
{
|
||||
_x /= factor;
|
||||
_y /= factor;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// overload the compare (==) operator
|
||||
// usage: if (point1 == point2) { };
|
||||
|
||||
int kbLPoint::operator==( const kbLPoint &other_point ) const
|
||||
{
|
||||
return ( ( other_point._x == _x ) && ( other_point._y == _y ) );
|
||||
}
|
||||
|
||||
|
||||
// overload the diffrent (!=) operator
|
||||
// usage: if (point1 != point2) { };
|
||||
|
||||
int kbLPoint::operator!=( const kbLPoint &other_point ) const
|
||||
{
|
||||
return ( ( other_point._x != _x ) || ( other_point._y != _y ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,620 +0,0 @@
|
|||
/*! \file src/node.cpp
|
||||
\brief Holds a GDSII node structure
|
||||
\author Klaas Holwerda
|
||||
|
||||
Copyright: 2001-2004 (C) Klaas Holwerda
|
||||
|
||||
Licence: see kboollicense.txt
|
||||
|
||||
RCS-ID: $Id: node.cpp,v 1.7 2009/09/14 16:50:12 titato Exp $
|
||||
*/
|
||||
|
||||
#include "kbool/node.h"
|
||||
#include "kbool/link.h"
|
||||
#include "kbool/line.h"
|
||||
#include <math.h>
|
||||
|
||||
//this here is to initialize the static iterator of node
|
||||
//with NOLIST constructor
|
||||
//TDLI<kbLink> kbNode::_linkiter=TDLI<kbLink>(_GC);
|
||||
|
||||
kbNode::kbNode( Bool_Engine* GC ) : kbLPoint( 0, 0 )
|
||||
{
|
||||
_GC = GC;
|
||||
_linklist = new DL_List<void*>();
|
||||
}
|
||||
|
||||
|
||||
kbNode::kbNode( B_INT const X, B_INT const Y, Bool_Engine* GC ) : kbLPoint( X, Y )
|
||||
{
|
||||
_GC = GC;
|
||||
_linklist = new DL_List<void*>();
|
||||
}
|
||||
|
||||
|
||||
kbNode::kbNode( kbLPoint* const a_point, Bool_Engine* GC ) : kbLPoint( a_point )
|
||||
{
|
||||
_GC = GC;
|
||||
_linklist = new DL_List<void*>();
|
||||
}
|
||||
|
||||
|
||||
//kbNode::kbNode(kbNode * const other) : kbLPoint(other)
|
||||
kbNode::kbNode( kbNode * const other, Bool_Engine* GC )
|
||||
{
|
||||
_GC = GC;
|
||||
_x = other->_x;
|
||||
_y = other->_y;
|
||||
_linklist = new DL_List<void*>();
|
||||
}
|
||||
|
||||
kbNode& kbNode::operator=( const kbNode &other_node )
|
||||
{
|
||||
_x = other_node._x;
|
||||
_y = other_node._y;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// x and y of the point will be rounded to the nearest
|
||||
// xnew=N*grid and ynew=N*grid
|
||||
void kbNode::RoundInt( B_INT grid )
|
||||
{
|
||||
_x = ( B_INT ) floor( ( _x + grid * 0.5 ) / grid ) * grid;
|
||||
_y = ( B_INT ) floor( ( _y + grid * 0.5 ) / grid ) * grid;
|
||||
}
|
||||
|
||||
kbNode::~kbNode()
|
||||
{
|
||||
delete _linklist;
|
||||
}
|
||||
|
||||
DL_List<void*>* kbNode::GetLinklist()
|
||||
{
|
||||
return _linklist;
|
||||
}
|
||||
|
||||
void kbNode::AddLink( kbLink *a_link )
|
||||
{
|
||||
// assert(a_link);
|
||||
_linklist->insbegin( a_link );
|
||||
}
|
||||
|
||||
kbLink* kbNode::GetIncomingLink()
|
||||
{
|
||||
if ( ( ( kbLink* )_linklist->headitem() )->GetEndNode() == this )
|
||||
return ( kbLink* )_linklist->headitem();
|
||||
else
|
||||
return ( kbLink* )_linklist->tailitem();
|
||||
}
|
||||
|
||||
kbLink* kbNode::GetOutgoingLink()
|
||||
{
|
||||
if ( ( ( kbLink* )_linklist->headitem() )->GetBeginNode() == this )
|
||||
return ( kbLink* )_linklist->headitem();
|
||||
else
|
||||
return ( kbLink* )_linklist->tailitem();
|
||||
}
|
||||
|
||||
//
|
||||
// Returns the number of connected links
|
||||
//
|
||||
int kbNode::GetNumberOfLinks()
|
||||
{
|
||||
return _linklist->count();
|
||||
}
|
||||
|
||||
kbLink* kbNode::GetOtherLink( kbLink* prev )
|
||||
{
|
||||
if ( prev == ( kbLink* )_linklist->headitem() )
|
||||
return ( kbLink* )_linklist->tailitem();
|
||||
if ( prev == ( kbLink* )_linklist->tailitem() )
|
||||
return ( kbLink* )_linklist->headitem();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int kbNode::Merge( kbNode *other )
|
||||
{
|
||||
if ( this == other ) //they are already merged dummy
|
||||
return 0;
|
||||
|
||||
_GC->_linkiter->Attach( _linklist );
|
||||
int Counter;
|
||||
// used to delete Iterator on other->_linklist
|
||||
// otherwise there can't be a takeover, because for takeover there can't
|
||||
// be an iterator on other->_linklist;
|
||||
{
|
||||
TDLI<kbLink> Iother( other->_linklist );
|
||||
kbLink* temp;
|
||||
|
||||
Counter = Iother.count();
|
||||
|
||||
Iother.tohead();
|
||||
while ( !Iother.hitroot() )
|
||||
{
|
||||
temp = Iother.item();
|
||||
//need to test both nodes because it may be a zero length link
|
||||
if ( temp->GetEndNode() == other )
|
||||
temp->SetEndNode( this );
|
||||
if ( temp->GetBeginNode() == other )
|
||||
temp->SetBeginNode( this );
|
||||
Iother++;
|
||||
}
|
||||
_GC->_linkiter->takeover( &Iother );
|
||||
}
|
||||
_GC->_linkiter->Detach();
|
||||
|
||||
//at this moment the other nodes has no link pointing to it so it needs to be deleted
|
||||
delete other;
|
||||
return Counter;
|
||||
}
|
||||
|
||||
|
||||
void kbNode::RemoveLink( kbLink *a_link )
|
||||
{
|
||||
// assert(a_link);
|
||||
_GC->_linkiter->Attach( _linklist );
|
||||
|
||||
if ( _GC->_linkiter->toitem( a_link ) ) // find the link
|
||||
_GC->_linkiter->remove();
|
||||
_GC->_linkiter->Detach();
|
||||
}
|
||||
|
||||
// This function will determinate if the given three points
|
||||
// can be simplified to two points
|
||||
//
|
||||
// input : three nodes, the first and the second must be points of
|
||||
// a line in correct order, the third point is a point of another
|
||||
// line.
|
||||
// output: -
|
||||
// return: true if points can be simplified
|
||||
// false if points can't be simplified
|
||||
bool kbNode::Simplify( kbNode *First, kbNode *Second, B_INT Marge )
|
||||
{
|
||||
double distance = 0;
|
||||
|
||||
// The first and second point are a zero line, if so we can
|
||||
// make a line between the first and third point
|
||||
if ( First->Equal( Second, Marge ) )
|
||||
return true;
|
||||
|
||||
// Are the first and third point equal, if so
|
||||
// we can delete the second point
|
||||
if ( First->Equal( this, Marge ) )
|
||||
return true;
|
||||
|
||||
// Used tmp_link.set here, because the link may not be linked in the graph,
|
||||
// because the point of the graphs are used, after use of the line we have
|
||||
//to set the link to zero so the nodes will not be destructed by exit of the function
|
||||
kbLink tmp_link( _GC );
|
||||
tmp_link.Set( First, Second );
|
||||
kbLine tmp_line( _GC );
|
||||
tmp_line.Set( &tmp_link );
|
||||
|
||||
// If third point is on the same line which is made from the first
|
||||
// and second point then we can delete the second point
|
||||
if ( tmp_line.PointOnLine( this, distance, ( double ) Marge ) == ON_AREA )
|
||||
{
|
||||
tmp_link.Set( NULL, NULL );
|
||||
return true;
|
||||
}
|
||||
//
|
||||
//
|
||||
tmp_link.Set( Second, this );
|
||||
tmp_line.Set( &tmp_link );
|
||||
if ( tmp_line.PointOnLine( First, distance, ( double ) Marge ) == ON_AREA )
|
||||
{
|
||||
tmp_link.Set( NULL, NULL );
|
||||
return true;
|
||||
}
|
||||
tmp_link.Set( NULL, NULL );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
kbLink* kbNode::GetNextLink()
|
||||
{
|
||||
int Aantal = _linklist->count();
|
||||
|
||||
// assert (Aantal != 0);
|
||||
|
||||
// there is one link, so there is no previous link
|
||||
if ( Aantal == 1 )
|
||||
return NULL;
|
||||
int Marked_Counter = 0;
|
||||
kbLink *the_link = NULL;
|
||||
|
||||
// count the marked links
|
||||
_GC->_linkiter->Attach( _linklist );
|
||||
_GC->_linkiter->tohead();
|
||||
while ( !_GC->_linkiter->hitroot() )
|
||||
{
|
||||
if ( _GC->_linkiter->item()->IsMarked() )
|
||||
Marked_Counter++;
|
||||
else
|
||||
{
|
||||
if ( !the_link )
|
||||
the_link = _GC->_linkiter->item();
|
||||
}
|
||||
( *_GC->_linkiter )++;
|
||||
}
|
||||
_GC->_linkiter->Detach();
|
||||
if ( Aantal - Marked_Counter != 1 )
|
||||
// there arent two unmarked links
|
||||
return NULL;
|
||||
else
|
||||
{
|
||||
if ( the_link->GetBeginNode() == this )
|
||||
return the_link;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
kbLink* kbNode::GetPrevLink()
|
||||
{
|
||||
int Aantal;
|
||||
if ( !_linklist )
|
||||
return NULL;
|
||||
|
||||
Aantal = _linklist->count();
|
||||
|
||||
// assert (Aantal != 0);
|
||||
|
||||
// there is one link, so there is no previous link
|
||||
if ( Aantal == 1 )
|
||||
return NULL;
|
||||
|
||||
int Marked_Counter = 0;
|
||||
kbLink *the_link = NULL;
|
||||
|
||||
_GC->_linkiter->Attach( _linklist );
|
||||
// count the marked links
|
||||
_GC->_linkiter->tohead();
|
||||
while ( !_GC->_linkiter->hitroot() )
|
||||
{
|
||||
if ( _GC->_linkiter->item()->IsMarked() )
|
||||
Marked_Counter++;
|
||||
else
|
||||
{
|
||||
if ( !the_link )
|
||||
the_link = _GC->_linkiter->item();
|
||||
}
|
||||
( *_GC->_linkiter )++;
|
||||
}
|
||||
_GC->_linkiter->Detach();
|
||||
if ( Aantal - Marked_Counter != 1 )
|
||||
// there arent two unmarked links
|
||||
return NULL;
|
||||
else
|
||||
{
|
||||
if ( the_link->GetEndNode() == this )
|
||||
return the_link;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool kbNode::SameSides( kbLink* const prev , kbLink* const link, BOOL_OP operation )
|
||||
{
|
||||
bool directedLeft;
|
||||
bool directedRight;
|
||||
if ( prev->GetEndNode() == this ) //forward direction
|
||||
{
|
||||
directedLeft = prev->IsMarkedLeft( operation );
|
||||
directedRight = prev->IsMarkedRight( operation );
|
||||
if ( link->GetBeginNode() == this ) //forward direction
|
||||
{
|
||||
return directedLeft == link->IsMarkedLeft( operation ) &&
|
||||
directedRight == link->IsMarkedRight( operation );
|
||||
}
|
||||
|
||||
return directedLeft == link->IsMarkedRight( operation ) &&
|
||||
directedRight == link->IsMarkedLeft( operation );
|
||||
}
|
||||
|
||||
directedLeft = prev->IsMarkedRight( operation );
|
||||
directedRight = prev->IsMarkedLeft( operation );
|
||||
if ( link->GetBeginNode() == this ) //forward direction
|
||||
{
|
||||
return directedLeft == link->IsMarkedLeft( operation ) &&
|
||||
directedRight == link->IsMarkedRight( operation );
|
||||
}
|
||||
return directedLeft == link->IsMarkedRight( operation ) &&
|
||||
directedRight == link->IsMarkedLeft( operation );
|
||||
}
|
||||
|
||||
// on the node get the link
|
||||
// is the most right or left one
|
||||
// This function is used to collect the simple graphs from a graph
|
||||
kbLink* kbNode::GetMost( kbLink* const prev , LinkStatus whatside, BOOL_OP operation )
|
||||
{
|
||||
kbLink * reserve = 0;
|
||||
kbLink *Result = NULL, *link;
|
||||
kbNode* prevbegin = prev->GetOther( this );
|
||||
|
||||
if ( _linklist->count() == 2 ) // only two links to this node take the one != prev
|
||||
{
|
||||
if ( ( link = ( kbLink* )_linklist->headitem() ) == prev ) //this is NOT the one to go on
|
||||
link = ( kbLink* )_linklist->tailitem();
|
||||
if ( !link->BeenHere() && SameSides( prev, link, operation ) )
|
||||
//we are back where we started (bin is true) return Null
|
||||
return link;
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
_GC->_linkiter->Attach( _linklist );
|
||||
_GC->_linkiter->tohead();
|
||||
//more then 2 links to the kbNode
|
||||
while( !_GC->_linkiter->hitroot() )
|
||||
{
|
||||
link = _GC->_linkiter->item();
|
||||
if ( !link->BeenHere() &&
|
||||
SameSides( prev, link, operation ) &&
|
||||
link != prev //should be set to bin already
|
||||
)
|
||||
{
|
||||
if ( prevbegin == link->GetOther( this ) )//pointers equal
|
||||
//we are going back in the same direction on a parallel link
|
||||
//only take this possibility if nothing else is possible
|
||||
reserve = link;
|
||||
else
|
||||
{ //this link is in a different direction
|
||||
if ( !Result )
|
||||
Result = link; //first one found sofar
|
||||
else
|
||||
{
|
||||
if ( prev->PointOnCorner( Result, link ) == whatside )
|
||||
//more to the whatside than take this one
|
||||
Result = link;
|
||||
}
|
||||
}
|
||||
}
|
||||
( *_GC->_linkiter )++;
|
||||
}
|
||||
|
||||
// if there is a next link found return it
|
||||
// else if a parallel link is found return that one
|
||||
// else return NULL
|
||||
_GC->_linkiter->Detach();
|
||||
return ( ( Result ) ? Result : reserve );
|
||||
}
|
||||
|
||||
// on the node get the link
|
||||
// is the most right or left one
|
||||
// This function is used to collect the simple graphs from a graph
|
||||
kbLink* kbNode::GetMostHole( kbLink* const prev, LinkStatus whatside, BOOL_OP operation, bool searchholelink )
|
||||
{
|
||||
kbLink * reserve = 0;
|
||||
kbLink *Result = NULL, *link;
|
||||
kbNode* prevbegin = prev->GetOther( this );
|
||||
|
||||
if ( _linklist->count() == 2 ) // only two links to this node take the one != prev
|
||||
{
|
||||
if ( ( link = ( kbLink* )_linklist->headitem() ) == prev ) //this is NOT the one to go on
|
||||
link = ( kbLink* )_linklist->tailitem();
|
||||
if (
|
||||
!link->BeenHere() &&
|
||||
link->GetHole() &&
|
||||
( searchholelink && link->GetHoleLink() || !link->GetHoleLink() ) &&
|
||||
SameSides( prev, link, operation ) )
|
||||
//we are back where we started (bin is true) return Null
|
||||
return link;
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
_GC->_linkiter->Attach( _linklist );
|
||||
_GC->_linkiter->tohead();
|
||||
//more then 2 links to the kbNode
|
||||
while( !_GC->_linkiter->hitroot() )
|
||||
{
|
||||
link = _GC->_linkiter->item();
|
||||
if (
|
||||
!link->BeenHere() &&
|
||||
link->GetHole() &&
|
||||
( searchholelink && link->GetHoleLink() || !link->GetHoleLink() ) &&
|
||||
SameSides( prev, link, operation ) &&
|
||||
link != prev //should be set to bin already
|
||||
)
|
||||
{
|
||||
if ( prevbegin == link->GetOther( this ) )//pointers equal
|
||||
//we are going back in the same direction on a parallel link
|
||||
//only take this possibility if nothing else is possible
|
||||
reserve = link;
|
||||
else
|
||||
{ //this link is in a different direction
|
||||
if ( !Result )
|
||||
Result = link; //first one found sofar
|
||||
else
|
||||
{
|
||||
if ( prev->PointOnCorner( Result, link ) == whatside )
|
||||
//more to the whatside than take this one
|
||||
Result = link;
|
||||
}
|
||||
}
|
||||
}
|
||||
( *_GC->_linkiter )++;
|
||||
}
|
||||
|
||||
// if there is a next link found return it
|
||||
// else if a parallel link is found return that one
|
||||
// else return NULL
|
||||
_GC->_linkiter->Detach();
|
||||
return ( ( Result ) ? Result : reserve );
|
||||
}
|
||||
|
||||
// this function gets the highest not flat link
|
||||
kbLink* kbNode::GetHoleLink( kbLink* const prev, LinkStatus whatside, bool checkbin, BOOL_OP operation )
|
||||
{
|
||||
kbLink * Result = NULL, *link;
|
||||
|
||||
_GC->_linkiter->Attach( _linklist );
|
||||
|
||||
for( _GC->_linkiter->tohead();!_GC->_linkiter->hitroot();( *_GC->_linkiter )++ )
|
||||
{
|
||||
link = _GC->_linkiter->item();
|
||||
if ( link->GetHoleLink() &&
|
||||
( !checkbin || ( checkbin && !link->BeenHere() ) ) &&
|
||||
SameSides( prev, link, operation )
|
||||
)
|
||||
{
|
||||
if ( !Result )
|
||||
Result = link; //first one found sofar
|
||||
else
|
||||
{
|
||||
if ( prev->PointOnCorner( Result, link ) == whatside )
|
||||
//more to the whatside than take this one
|
||||
Result = link;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_GC->_linkiter->Detach();
|
||||
return ( Result );
|
||||
}
|
||||
|
||||
// this function gets the highest not flat link
|
||||
kbLink* kbNode::GetNotFlat()
|
||||
{
|
||||
kbLink * Result = NULL, *link;
|
||||
|
||||
_GC->_linkiter->Attach( _linklist );
|
||||
|
||||
double tangold = 0.0;
|
||||
double tangnew = 0.0;
|
||||
|
||||
for( _GC->_linkiter->tohead();!_GC->_linkiter->hitroot();( *_GC->_linkiter )++ )
|
||||
{
|
||||
link = _GC->_linkiter->item();
|
||||
if ( !_GC->_linkiter->item()->BeenHere() )
|
||||
{
|
||||
B_INT dx = link->GetOther( this )->GetX() - _x;
|
||||
B_INT dy = link->GetOther( this )->GetY() - _y;
|
||||
if ( dx != 0 )
|
||||
{
|
||||
tangnew = fabs( ( double ) dy / ( double ) dx );
|
||||
}
|
||||
else
|
||||
{
|
||||
tangnew = MAXDOUBLE;
|
||||
}
|
||||
|
||||
if ( !Result )
|
||||
{
|
||||
//this link is in a different direction
|
||||
Result = link; //first one found sofar
|
||||
tangold = tangnew;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( tangnew < tangold )
|
||||
{
|
||||
//this one is higher (more horizontal) then the old Result
|
||||
Result = link;
|
||||
tangold = tangnew;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if there is a next link found return it
|
||||
// else if a parallel link is found return that one
|
||||
// else return NULL
|
||||
_GC->_linkiter->Detach();
|
||||
return ( Result );
|
||||
}
|
||||
|
||||
// on the node get the link that is not BIN
|
||||
// and that has the same graphnumber and is in same direction
|
||||
kbLink *kbNode::Follow( kbLink* const prev )
|
||||
{
|
||||
kbLink * temp;
|
||||
_GC->_linkiter->Attach( _linklist );
|
||||
|
||||
_GC->_linkiter->tohead();
|
||||
while( !_GC->_linkiter->hitroot() )
|
||||
{
|
||||
if ( ( _GC->_linkiter->item() != prev ) &&
|
||||
( !_GC->_linkiter->item()->BeenHere() ) &&
|
||||
( _GC->_linkiter->item()->GetGraphNum() == prev->GetGraphNum() ) &&
|
||||
(
|
||||
( ( prev->GetEndNode() == this ) &&
|
||||
( _GC->_linkiter->item()->GetEndNode() != this )
|
||||
)
|
||||
||
|
||||
( ( prev->GetBeginNode() == this ) &&
|
||||
( _GC->_linkiter->item()->GetBeginNode() != this )
|
||||
)
|
||||
)
|
||||
)
|
||||
{
|
||||
temp = _GC->_linkiter->item();
|
||||
_GC->_linkiter->Detach();
|
||||
return( temp );
|
||||
}
|
||||
( *_GC->_linkiter )++;
|
||||
}
|
||||
|
||||
_GC->_linkiter->Detach();
|
||||
return ( 0 );
|
||||
}
|
||||
|
||||
// this function gets the highest (other node) link ascending from the node
|
||||
// that has the bin flag set as the argument binset
|
||||
// if no such link exists return 0
|
||||
kbLink* kbNode::GetBinHighest( bool binset )
|
||||
{
|
||||
kbLink * Result = NULL, *link;
|
||||
_GC->_linkiter->Attach( _linklist );
|
||||
|
||||
double tangold = 0.0;
|
||||
double tangnew = 0.0;
|
||||
|
||||
for( _GC->_linkiter->tohead();!_GC->_linkiter->hitroot();( *_GC->_linkiter )++ )
|
||||
{
|
||||
link = _GC->_linkiter->item();
|
||||
if ( _GC->_linkiter->item()->BeenHere() == binset )
|
||||
{
|
||||
B_INT dx = link->GetOther( this )->GetX() - _x;
|
||||
B_INT dy = link->GetOther( this )->GetY() - _y;
|
||||
if ( dx != 0 )
|
||||
{
|
||||
tangnew = ( double ) dy / ( double ) dx;
|
||||
}
|
||||
else if ( dy > 0 )
|
||||
{
|
||||
tangnew = MAXDOUBLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
tangnew = -MAXDOUBLE;
|
||||
}
|
||||
|
||||
if ( !Result )
|
||||
{
|
||||
Result = link; //first one found sofar
|
||||
tangold = tangnew;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( tangnew > tangold )
|
||||
{
|
||||
//this one is higher then the old Result
|
||||
Result = link;
|
||||
tangold = tangnew;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if there is a link found return it
|
||||
// else return NULL
|
||||
_GC->_linkiter->Detach();
|
||||
return ( Result );
|
||||
}
|
||||
|
||||
|
|
@ -1,352 +0,0 @@
|
|||
/*! \file src/record.cpp
|
||||
\author Klaas Holwerda or Julian Smart
|
||||
|
||||
Copyright: 2001-2004 (C) Klaas Holwerda
|
||||
|
||||
Licence: see kboollicense.txt
|
||||
|
||||
RCS-ID: $Id: record.cpp,v 1.5 2009/09/10 17:04:09 titato Exp $
|
||||
*/
|
||||
|
||||
#include "kbool/booleng.h"
|
||||
#include "kbool/record.h"
|
||||
#include "kbool/node.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#define LNK _line.GetLink()
|
||||
|
||||
//int r_index=-1;
|
||||
//void* _Record_Pool[30];
|
||||
|
||||
//void DeleteRecordPool()
|
||||
//{
|
||||
// while (r_index!=-1)
|
||||
// {
|
||||
// free( _Record_Pool[r_index--]);
|
||||
// }
|
||||
//}
|
||||
|
||||
kbRecord::~kbRecord()
|
||||
{}
|
||||
|
||||
|
||||
//void* kbRecord::operator new(size_t size)
|
||||
//{
|
||||
//
|
||||
// if (r_index!=-1)
|
||||
// {
|
||||
// return _Record_Pool[r_index--];
|
||||
// }
|
||||
//
|
||||
// return malloc(size);
|
||||
//}
|
||||
|
||||
//void kbRecord::operator delete(void* recordptr)
|
||||
//{
|
||||
//
|
||||
// if (r_index < 28)
|
||||
// {
|
||||
// _Record_Pool[++r_index]= recordptr;
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// free (recordptr);
|
||||
//}
|
||||
|
||||
//void kbRecord::deletepool()
|
||||
//{
|
||||
//
|
||||
// while (r_index!=-1)
|
||||
// {
|
||||
// free( _Record_Pool[r_index--]);
|
||||
// }
|
||||
//}
|
||||
|
||||
kbRecord::kbRecord( kbLink* link, Bool_Engine* GC )
|
||||
: _line( GC )
|
||||
{
|
||||
_GC = GC;
|
||||
_dir = GO_RIGHT;
|
||||
_a = 0;
|
||||
_b = 0;
|
||||
_line.Set( link );
|
||||
_line.CalculateLineParameters();
|
||||
}
|
||||
|
||||
|
||||
//when the dimensions of a link for a record changes, its line parameters need to be recalculated
|
||||
void kbRecord::SetNewLink( kbLink* link )
|
||||
{
|
||||
_line.Set( link );
|
||||
_line.CalculateLineParameters();
|
||||
}
|
||||
|
||||
//for beams calculate the ysp on the low scanline
|
||||
void kbRecord::Calc_Ysp( kbNode* low )
|
||||
{
|
||||
if ( ( LNK->GetEndNode() == low ) || ( LNK->GetBeginNode() == low ) )
|
||||
{
|
||||
_ysp = low->GetY();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( LNK->GetEndNode()->GetX() == LNK->GetBeginNode()->GetX() )
|
||||
_ysp = low->GetY(); //flatlink only in flatbeams
|
||||
else if ( LNK->GetEndNode()->GetX() == low->GetX() )
|
||||
_ysp = LNK->GetEndNode()->GetY();
|
||||
else if ( LNK->GetBeginNode()->GetX() == low->GetX() )
|
||||
_ysp = LNK->GetBeginNode()->GetY();
|
||||
else
|
||||
_ysp = _line.Calculate_Y_from_X( low->GetX() );
|
||||
}
|
||||
|
||||
//to set the _dir for new links in the beam
|
||||
void kbRecord::Set_Flags()
|
||||
{
|
||||
if ( LNK->GetEndNode()->GetX() == LNK->GetBeginNode()->GetX() ) //flatlink ?
|
||||
{ //only happens in flat beams
|
||||
if ( LNK->GetEndNode()->GetY() < LNK->GetBeginNode()->GetY() )
|
||||
_dir = GO_RIGHT;
|
||||
else
|
||||
_dir = GO_LEFT;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( LNK->GetEndNode()->GetX() > LNK->GetBeginNode()->GetX() )
|
||||
_dir = GO_RIGHT;
|
||||
else
|
||||
_dir = GO_LEFT;
|
||||
}
|
||||
}
|
||||
|
||||
kbLink* kbRecord::GetLink()
|
||||
{
|
||||
return LNK;
|
||||
}
|
||||
|
||||
B_INT kbRecord::Ysp()
|
||||
{
|
||||
return _ysp;
|
||||
}
|
||||
|
||||
void kbRecord::SetYsp( B_INT ysp )
|
||||
{
|
||||
_ysp = ysp;
|
||||
}
|
||||
|
||||
DIRECTION kbRecord::Direction()
|
||||
{
|
||||
return DIRECTION( _dir );
|
||||
}
|
||||
|
||||
bool kbRecord::Calc_Left_Right( kbRecord* record_above_me )
|
||||
{
|
||||
bool par = false;
|
||||
|
||||
if ( !record_above_me ) //null if no record above
|
||||
{ _a = 0;_b = 0; }
|
||||
else
|
||||
{
|
||||
_a = record_above_me->_a;
|
||||
_b = record_above_me->_b;
|
||||
}
|
||||
|
||||
switch ( _dir & 1 )
|
||||
{
|
||||
case GO_LEFT : if ( LNK->Group() == GROUP_A )
|
||||
{
|
||||
LNK->SetRightA( ( bool )( _a > 0 ) );
|
||||
|
||||
if ( _GC->GetWindingRule() )
|
||||
LNK->GetInc() ? _a++ : _a--;
|
||||
else
|
||||
{ //ALTERNATE
|
||||
if ( _a )
|
||||
_a = 0;
|
||||
else
|
||||
_a = 1;
|
||||
}
|
||||
|
||||
LNK->SetLeftA( ( bool )( _a > 0 ) );
|
||||
LNK->SetLeftB( ( bool )( _b > 0 ) );
|
||||
LNK->SetRightB( ( bool )( _b > 0 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
LNK->SetRightA( ( bool )( _a > 0 ) );
|
||||
LNK->SetLeftA( ( bool )( _a > 0 ) );
|
||||
LNK->SetRightB( ( bool )( _b > 0 ) );
|
||||
|
||||
if ( _GC->GetWindingRule() )
|
||||
LNK->GetInc() ? _b++ : _b--;
|
||||
else //ALTERNATE
|
||||
{
|
||||
if ( _b )
|
||||
_b = 0;
|
||||
else
|
||||
_b = 1;
|
||||
}
|
||||
|
||||
LNK->SetLeftB( ( bool )( _b > 0 ) );
|
||||
}
|
||||
break;
|
||||
case GO_RIGHT : if ( LNK->Group() == GROUP_A )
|
||||
{
|
||||
LNK->SetLeftA( ( bool )( _a > 0 ) );
|
||||
|
||||
if ( _GC->GetWindingRule() )
|
||||
LNK->GetInc() ? _a++ : _a--;
|
||||
else
|
||||
{ //ALTERNATE
|
||||
if ( _a )
|
||||
_a = 0;
|
||||
else
|
||||
_a = 1;
|
||||
}
|
||||
|
||||
LNK->SetRightA( ( bool )( _a > 0 ) );
|
||||
LNK->SetLeftB( ( bool )( _b > 0 ) );
|
||||
LNK->SetRightB( ( bool )( _b > 0 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
LNK->SetRightA( ( bool )( _a > 0 ) );
|
||||
LNK->SetLeftA( ( bool )( _a > 0 ) );
|
||||
LNK->SetLeftB( ( bool )( _b > 0 ) );
|
||||
|
||||
if ( _GC->GetWindingRule() )
|
||||
LNK->GetInc() ? _b++ : _b--;
|
||||
else
|
||||
{ //ALTERNATE
|
||||
if ( _b )
|
||||
_b = 0;
|
||||
else
|
||||
_b = 1;
|
||||
}
|
||||
|
||||
LNK->SetRightB( ( bool )( _b > 0 ) );
|
||||
}
|
||||
break;
|
||||
default : _GC->error( "Undefined Direction of link", "function IScanBeam::Calc_Set_Left_Right()" );
|
||||
break;
|
||||
}
|
||||
|
||||
//THE NEXT WILL WORK for MOST windingrule polygons,
|
||||
//even when not taking into acount windingrule
|
||||
// not all
|
||||
/*
|
||||
switch (_dir&1)
|
||||
{
|
||||
case GO_LEFT : if (LNK->Group() == GROUP_A)
|
||||
{
|
||||
LNK->SetRightA((bool)(_a>0));
|
||||
|
||||
if (booleng->Get_WindingRule())
|
||||
LNK->GetInc() ? _a++ : _a--;
|
||||
else
|
||||
_a--;
|
||||
|
||||
LNK->SetLeftA((bool)(_a>0));
|
||||
LNK->SetLeftB((bool)(_b>0));
|
||||
LNK->SetRightB((bool)(_b>0));
|
||||
}
|
||||
else
|
||||
{
|
||||
LNK->SetRightA((bool)(_a > 0));
|
||||
LNK->SetLeftA((bool)(_a>0));
|
||||
LNK->SetRightB((bool)(_b>0));
|
||||
|
||||
if (booleng->Get_WindingRule())
|
||||
LNK->GetInc() ? _b++ : _b--;
|
||||
else
|
||||
_b--;
|
||||
|
||||
LNK->SetLeftB((bool)(_b>0));
|
||||
}
|
||||
break;
|
||||
case GO_RIGHT : if (LNK->Group() == GROUP_A)
|
||||
{
|
||||
LNK->SetLeftA((bool)(_a>0));
|
||||
|
||||
if (booleng->Get_WindingRule())
|
||||
LNK->GetInc() ? _a++ : _a--;
|
||||
else
|
||||
_a++;
|
||||
|
||||
LNK->SetRightA((bool)(_a>0));
|
||||
LNK->SetLeftB((bool)(_b>0));
|
||||
LNK->SetRightB((bool)(_b>0));
|
||||
}
|
||||
else
|
||||
{
|
||||
LNK->SetRightA((bool)(_a>0));
|
||||
LNK->SetLeftA((bool)(_a>0));
|
||||
LNK->SetLeftB((bool)(_b>0));
|
||||
|
||||
if (booleng->Get_WindingRule())
|
||||
LNK->GetInc() ? _b++ : _b--;
|
||||
else
|
||||
_b++;
|
||||
|
||||
LNK->SetRightB((bool)(_b>0));
|
||||
}
|
||||
break;
|
||||
default : _messagehandler->error("Undefined Direction of link","function IScanBeam::Calc_Set_Left_Right()");
|
||||
break;
|
||||
}
|
||||
*/
|
||||
//if the records are parallel (same begin/endnodes)
|
||||
//the above link a/b flag are adjusted to the current a/b depth
|
||||
if ( record_above_me && Equal( record_above_me ) )
|
||||
{
|
||||
par = true;
|
||||
LNK->Mark();
|
||||
record_above_me->_a = _a;
|
||||
record_above_me->_b = _b;
|
||||
if ( Direction() == GO_LEFT )
|
||||
{
|
||||
//set the bottom side of the above link
|
||||
if ( record_above_me->Direction() == GO_LEFT )
|
||||
{
|
||||
record_above_me->LNK->SetLeftA( LNK->GetLeftA() );
|
||||
record_above_me->LNK->SetLeftB( LNK->GetLeftB() );
|
||||
}
|
||||
else
|
||||
{
|
||||
record_above_me->LNK->SetRightA( LNK->GetLeftA() );
|
||||
record_above_me->LNK->SetRightB( LNK->GetLeftB() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//set the bottom side of the above link
|
||||
if ( record_above_me->Direction() == GO_LEFT )
|
||||
{
|
||||
record_above_me->LNK->SetLeftA( LNK->GetRightA() );
|
||||
record_above_me->LNK->SetLeftB( LNK->GetRightB() );
|
||||
}
|
||||
else
|
||||
{
|
||||
record_above_me->LNK->SetRightA( LNK->GetRightA() );
|
||||
record_above_me->LNK->SetRightB( LNK->GetRightB() );
|
||||
}
|
||||
}
|
||||
}
|
||||
return par;
|
||||
}
|
||||
|
||||
bool kbRecord::Equal( kbRecord *a )
|
||||
{
|
||||
return( ( bool )( ( LNK->GetOther( a->LNK->GetBeginNode() ) == a->LNK->GetEndNode() ) &&
|
||||
( LNK->GetOther( a->LNK->GetEndNode() ) == a->LNK->GetBeginNode() ) ) );
|
||||
}
|
||||
|
||||
|
||||
kbLine* kbRecord::GetLine()
|
||||
{
|
||||
return & _line;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -88,10 +88,10 @@ bool TestLineHit( int xi, int yi, int xf, int yf, int x, int y, double dist )
|
|||
bool FindSegmentIntersections( int xi, int yi, int xf, int yf,
|
||||
int xi2, int yi2, int xf2, int yf2 )
|
||||
{
|
||||
if( max( xi, xf ) < min( xi2, xf2 )
|
||||
|| min( xi, xf ) > max( xi2, xf2 )
|
||||
|| max( yi, yf ) < min( yi2, yf2 )
|
||||
|| min( yi, yf ) > max( yi2, yf2 ) )
|
||||
if( std::max( xi, xf ) < std::min( xi2, xf2 )
|
||||
|| std::min( xi, xf ) > std::max( xi2, xf2 )
|
||||
|| std::max( yi, yf ) < std::min( yi2, yf2 )
|
||||
|| std::min( yi, yf ) > std::max( yi2, yf2 ) )
|
||||
return false;
|
||||
|
||||
return TestForIntersectionOfStraightLineSegments( xi, yi, xf, yf,
|
||||
|
@ -135,7 +135,7 @@ bool FindLineSegmentIntersection( double a, double b, int xi, int yi, int xf, in
|
|||
else
|
||||
{
|
||||
if( dist )
|
||||
*dist = min( abs( a - xi ), abs( a - xf ) );
|
||||
*dist = std::min( abs( a - xi ), abs( a - xf ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -450,16 +450,16 @@ int GetClearanceBetweenSegments( int x1i, int y1i, int x1f, int y1f, int w1,
|
|||
// check clearance between bounding rectangles
|
||||
int min_dist = max_cl + ( (w1 + w2) / 2 );
|
||||
|
||||
if( min( x1i, x1f ) - max( x2i, x2f ) > min_dist )
|
||||
if( std::min( x1i, x1f ) - std::max( x2i, x2f ) > min_dist )
|
||||
return max_cl+1;
|
||||
|
||||
if( min( x2i, x2f ) - max( x1i, x1f ) > min_dist )
|
||||
if( std::min( x2i, x2f ) - std::max( x1i, x1f ) > min_dist )
|
||||
return max_cl+1;
|
||||
|
||||
if( min( y1i, y1f ) - max( y2i, y2f ) > min_dist )
|
||||
if( std::min( y1i, y1f ) - std::max( y2i, y2f ) > min_dist )
|
||||
return max_cl+1;
|
||||
|
||||
if( min( y2i, y2f ) - max( y1i, y1f ) > min_dist )
|
||||
if( std::min( y2i, y2f ) - std::max( y1i, y1f ) > min_dist )
|
||||
return max_cl+1;
|
||||
|
||||
int xx, yy;
|
||||
|
@ -535,7 +535,7 @@ double GetPointToLineSegmentDistance( int x, int y, int xi, int yi, int xf, int
|
|||
if( InRange( y, yi, yf ) )
|
||||
return abs( x - xi );
|
||||
else
|
||||
return min( Distance( x, y, xi, yi ), Distance( x, y, xf, yf ) );
|
||||
return std::min( Distance( x, y, xi, yi ), Distance( x, y, xf, yf ) );
|
||||
}
|
||||
else if( yf==yi )
|
||||
{
|
||||
|
@ -543,7 +543,7 @@ double GetPointToLineSegmentDistance( int x, int y, int xi, int yi, int xf, int
|
|||
if( InRange( x, xi, xf ) )
|
||||
return abs( y - yi );
|
||||
else
|
||||
return min( Distance( x, y, xi, yi ), Distance( x, y, xf, yf ) );
|
||||
return std::min( Distance( x, y, xi, yi ), Distance( x, y, xf, yf ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -564,7 +564,7 @@ double GetPointToLineSegmentDistance( int x, int y, int xi, int yi, int xf, int
|
|||
if( InRange( xp, xi, xf ) && InRange( yp, yi, yf ) )
|
||||
return Distance( x, y, xp, yp );
|
||||
else
|
||||
return min( Distance( x, y, xi, yi ), Distance( x, y, xf, yf ) );
|
||||
return std::min( Distance( x, y, xi, yi ), Distance( x, y, xf, yf ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue