Commit f85ade75 authored by CHARRAS's avatar CHARRAS

see changelog

parent ed0265cb
......@@ -3,6 +3,15 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
email address.
2007-Dec-16 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+pcbnew:
Move Zone outlines added
Zone outline DRC works (needs improvements)
some bugs solved, but polyline.cpp still needs work.
gendrill: code cleaning.
2007-Dec-14 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+pcbnew:
......
#define MACHINE "PC"
#define NB_CLES 16
#define POSITION_LICENCE 50
#define POSITION_CLE 250
#define TAILLE_LICENCE 256
......@@ -228,25 +228,40 @@ wxString FullFileName, ShortLibName, mask;
Update();
mask = wxT("*") + LibExtBuffer;
FullFileName = EDA_FileSelector( _("Libraries"),
g_RealLibDirBuffer, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */
LibExtBuffer, /* extension par defaut */
mask, /* Masque d'affichage */
this,
0,
TRUE /* ne chage pas de repertoire courant */
);
if (FullFileName == wxEmptyString ) return;
ShortLibName = MakeReducedFileName(FullFileName,g_RealLibDirBuffer,LibExtBuffer);
wxFileDialog FilesDialog(this, _("Library Files:"), g_RealLibDirBuffer,
wxEmptyString, mask,
wxFD_DEFAULT_STYLE | wxFD_MULTIPLE);
FilesDialog.ShowModal();
wxArrayString Filenames;
FilesDialog.GetFilenames(Filenames);
if ( Filenames.GetCount() == 0 )
return;
for ( unsigned jj = 0; jj < Filenames.GetCount(); jj ++ )
{
FullFileName = Filenames[jj];
ShortLibName = MakeReducedFileName(FullFileName,g_RealLibDirBuffer,LibExtBuffer);
g_LibName_List.Insert(ShortLibName, ii);
//Add or insert new library name
if ( g_LibName_List.Index(ShortLibName) == wxNOT_FOUND)
{
ListModIsModified = 1;
g_LibName_List.Insert(ShortLibName, ii++);
}
else
{
wxString msg;
msg << wxT("<") << ShortLibName << wxT("> : ") << _("Library already in use");
DisplayError(this, msg);
}
}
g_UserLibDirBuffer = m_LibDirCtrl->GetValue();
SetRealLibraryPath( wxT("modules") );
listlib();
ListModIsModified = 1;
m_Parent->BuildFootprintListBox();
......@@ -282,23 +297,37 @@ wxString FullFileName, ShortLibName, mask;
Update();
mask = wxT("*") + g_EquivExtBuffer;
FullFileName = EDA_FileSelector( _("Equiv"),
g_RealLibDirBuffer, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */
g_EquivExtBuffer, /* extension par defaut */
mask, /* Masque d'affichage */
this,
0,
TRUE /* ne chage pas de repertoire courant */
);
if (FullFileName == wxEmptyString ) return;
wxFileDialog FilesDialog(this, _("Equiv Files:"), g_RealLibDirBuffer,
wxEmptyString, mask,
wxFD_DEFAULT_STYLE | wxFD_MULTIPLE);
ShortLibName = MakeReducedFileName(FullFileName,g_RealLibDirBuffer,g_EquivExtBuffer);
FilesDialog.ShowModal();
wxArrayString Filenames;
FilesDialog.GetFilenames(Filenames);
if ( Filenames.GetCount() == 0 )
return;
for ( unsigned jj = 0; jj < Filenames.GetCount(); jj ++ )
{
FullFileName = Filenames[jj];
ShortLibName = MakeReducedFileName(FullFileName,g_RealLibDirBuffer,g_EquivExtBuffer);
g_ListName_Equ.Insert(ShortLibName, ii);
//Add or insert new equiv library name
if ( g_ListName_Equ.Index(ShortLibName) == wxNOT_FOUND)
{
g_ListName_Equ.Insert(ShortLibName, ii++);
}
else
{
wxString msg;
msg << wxT("<") << ShortLibName << wxT("> : ") << _("Library already in use");
DisplayError(this, msg);
}
}
/* Mise a jour de l'affichage */
/* Update display list */
g_UserLibDirBuffer = m_LibDirCtrl->GetValue();
SetRealLibraryPath( wxT("modules") );
listlib();
......
......@@ -364,31 +364,38 @@ wxString FullLibName,ShortLibName, Mask;
}
Mask = wxT("*") + g_LibExtBuffer;
FullLibName = EDA_FileSelector( _("Library files:"),
g_RealLibDirBuffer, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */
g_LibExtBuffer, /* extension par defaut */
Mask, /* Masque d'affichage */
this,
wxFD_OPEN,
TRUE
);
if ( FullLibName.IsEmpty() ) return;
ShortLibName = MakeReducedFileName(FullLibName,g_RealLibDirBuffer,g_LibExtBuffer);
//Add or insert new library name
if (FindLibrary(ShortLibName) == NULL)
wxFileDialog FilesDialog(this, _("Library files:"), g_RealLibDirBuffer,
wxEmptyString, Mask,
wxFD_DEFAULT_STYLE | wxFD_MULTIPLE);
FilesDialog.ShowModal();
wxArrayString Filenames;
FilesDialog.GetFilenames(Filenames);
for ( unsigned jj = 0; jj < Filenames.GetCount(); jj ++ )
{
m_LibListChanged = TRUE;
g_LibName_List.Insert(ShortLibName, ii);
m_ListLibr->Clear();
m_ListLibr->InsertItems(g_LibName_List, 0);
FullLibName = Filenames[jj];
ShortLibName = MakeReducedFileName(FullLibName,g_RealLibDirBuffer,g_LibExtBuffer);
if ( ShortLibName.IsEmpty() ) //Just in case...
continue;
//Add or insert new library name
if (FindLibrary(ShortLibName) == NULL)
{
m_LibListChanged = TRUE;
g_LibName_List.Insert(ShortLibName, ii);
m_ListLibr->Clear();
m_ListLibr->InsertItems(g_LibName_List, 0);
}
else
{
wxString msg;
msg << wxT("<") << ShortLibName << wxT("> : ") << _("Library already in use");
DisplayError(this, msg);
}
}
else DisplayError(this, _("Library already in use"));
}
......
......@@ -561,8 +561,8 @@ enum main_id {
ID_POPUP_PCB_ZONE_ADD_SIMILAR_ZONE,
ID_POPUP_PCB_ZONE_ADD_CUTOUT_ZONE,
ID_POPUP_PCB_DELETE_ZONE_CUTOUT,
ID_POPUP_ZONE_UNUSED2,
ID_POPUP_ZONE_UNUSED3,
ID_POPUP_PCB_MOVE_ZONE_OUTLINES,
ID_POPUP_PCB_PLACE_ZONE_OUTLINES,
ID_POPUP_ZONE_UNUSED4,
ID_POPUP_PCB_DELETE_MARKER,
......
......@@ -554,13 +554,15 @@ public:
bool IsNewCorner );
/**
* Function End_Move_Zone_Corner
* Terminates a move corner in a zone outline
* Function End_Move_Zone_Corner_Or_Outlines
* Terminates a move corner in a zone outline, or a move zone outlines
* @param DC = current Device Context (can be NULL)
* @param zone_container: the given zone
*/
void End_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_container );
void End_Move_Zone_Corner_Or_Outlines( wxDC* DC, ZONE_CONTAINER* zone_container );
/**
* Function End_Move_Zone_Corner
* Function End_Move_Zone_Corner_Or_Outlines
* Remove the currently selected corner in a zone outline
* the .m_CornerSelection is used as corner selection
*/
......@@ -577,7 +579,15 @@ public:
*/
void Delete_Zone_Contour( wxDC* DC, ZONE_CONTAINER* zone_container );
// Target handling
/**
* Function Start_Move_Zone_Outlines
* Initialise parametres to move an existing zone outlines.
* @param DC = current Device Context (can be NULL)
* @param zone_container: the given zone to move
*/
void Start_Move_Zone_Outlines( wxDC* DC, ZONE_CONTAINER* zone_container );
// Target handling
MIREPCB* Create_Mire( wxDC* DC );
void Delete_Mire( MIREPCB* MirePcb, wxDC* DC );
void StartMove_Mire( MIREPCB* MirePcb, wxDC* DC );
......
......@@ -3,13 +3,13 @@
// Purpose:
// Author: jean-pierre Charras
// Modified by:
// Created: 13/01/2008 17:26:27
// Created: 13/01/2008 17:26:dialog_gendrill
// RCS-ID:
// Copyright: License GNU
// Licence:
/////////////////////////////////////////////////////////////////////////////
// Generated by DialogBlocks (unregistered), 13/01/2008 17:26:27
// Generated by DialogBlocks (unregistered), 13/01/2008 17:26:dialog_gendrill
#ifndef _DIALOG_GENDRILL_H_
#define _DIALOG_GENDRILL_H_
......@@ -149,14 +149,15 @@ private:
void InitDisplayParams(void);
void SetParams(void);
void GenDrillFiles( wxCommandEvent& event );
void GenDrillMap( int format );
void GenDrillMap( std::vector<DRILL_TOOL> & buffer, int format );
void UpdatePrecisionOptions( wxCommandEvent& event );
void UpdateConfig();
int Plot_Drill_PcbMap( DRILL_TOOL* buffer, int format );
void GenDrillReport();
int Gen_Liste_Forets( DRILL_TOOL* buffer, bool print_header );
int Create_Drill_File_EXCELLON( DRILL_TOOL* buffer );
int Plot_Drill_PcbMap( std::vector<DRILL_TOOL> & buffer, int format );
void GenDrillReport( std::vector<DRILL_TOOL> & buffer );
int Gen_Liste_Forets( std::vector<DRILL_TOOL> & buffer, bool print_header );
int Create_Drill_File_EXCELLON( std::vector<DRILL_TOOL> & buffer );
void Init_Drill();
int Gen_Liste_Tools( std::vector<DRILL_TOOL> & buffer, bool print_header );
};
#endif
......
......@@ -364,29 +364,34 @@ wxString mask = wxT("*");
mask += LibExtBuffer;
g_RealLibDirBuffer.Replace( wxT("\\"), wxT("/"));
fullfilename = EDA_FileSelector( _("library files:"),
g_RealLibDirBuffer, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */
LibExtBuffer, /* extension par defaut */
mask, /* Masque d'affichage */
this,
0,
TRUE
);
if ( fullfilename.IsEmpty() ) return;
ShortLibName =
MakeReducedFileName(fullfilename, g_RealLibDirBuffer, LibExtBuffer);
//Add or insert new library name
if ( g_LibName_List.Index(ShortLibName) == wxNOT_FOUND)
wxFileDialog FilesDialog(this, _("Library Files:"), g_RealLibDirBuffer,
wxEmptyString, mask,
wxFD_DEFAULT_STYLE | wxFD_MULTIPLE);
FilesDialog.ShowModal();
wxArrayString Filenames;
FilesDialog.GetFilenames(Filenames);
for ( unsigned jj = 0; jj < Filenames.GetCount(); jj ++ )
{
m_LibModified = TRUE;
g_LibName_List.Insert(ShortLibName, ii);
m_ListLibr->Clear();
m_ListLibr->InsertItems(g_LibName_List, 0);
fullfilename = Filenames[jj];
ShortLibName =
MakeReducedFileName(fullfilename, g_RealLibDirBuffer, LibExtBuffer);
//Add or insert new library name
if ( g_LibName_List.Index(ShortLibName) == wxNOT_FOUND)
{
m_LibModified = TRUE;
g_LibName_List.Insert(ShortLibName, ii);
m_ListLibr->Clear();
m_ListLibr->InsertItems(g_LibName_List, 0);
}
else
{
wxString msg;
msg << wxT("<") << ShortLibName << wxT("> : ") << _("Library already in use");
DisplayError(this, msg);
}
}
else DisplayError(this, _("Library exists! No Change"));
}
......@@ -69,8 +69,12 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_DELETE_EDGE_ZONE:
case ID_POPUP_PCB_FILL_ALL_ZONES:
case ID_POPUP_PCB_PLACE_ZONE_CORNER:
case ID_POPUP_PCB_PLACE_ZONE_OUTLINES:
case ID_POPUP_PCB_EDIT_ZONE_PARAMS:
case ID_POPUP_PCB_DELETE_ZONE:
case ID_POPUP_PCB_MOVE_ZONE_CORNER:
case ID_POPUP_PCB_MOVE_ZONE_OUTLINES:
case ID_POPUP_PCB_ADD_ZONE_CORNER:
case ID_POPUP_PCB_DELETE_TRACKSEG:
case ID_POPUP_PCB_DELETE_TRACK:
case ID_POPUP_PCB_DELETE_TRACKNET:
......@@ -488,6 +492,14 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break;
}
case ID_POPUP_PCB_MOVE_ZONE_OUTLINES:
{
DrawPanel->MouseToCursorSchema();
ZONE_CONTAINER * zone_cont = (ZONE_CONTAINER*)GetCurItem();
Start_Move_Zone_Outlines(&dc, zone_cont);
break;
}
case ID_POPUP_PCB_ADD_ZONE_CORNER:
{
DrawPanel->MouseToCursorSchema();
......@@ -505,11 +517,12 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break;
}
case ID_POPUP_PCB_PLACE_ZONE_OUTLINES:
case ID_POPUP_PCB_PLACE_ZONE_CORNER:
{
DrawPanel->MouseToCursorSchema();
ZONE_CONTAINER * zone_cont = (ZONE_CONTAINER*)GetCurItem();
End_Move_Zone_Corner(&dc, zone_cont);
End_Move_Zone_Corner_Or_Outlines(&dc, zone_cont);
break;
}
......
This diff is collapsed.
......@@ -39,7 +39,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
switch( DrawStruct->Type() )
{
case TYPEZONE_CONTAINER:
End_Move_Zone_Corner( DC, (ZONE_CONTAINER *) DrawStruct );
End_Move_Zone_Corner_Or_Outlines( DC, (ZONE_CONTAINER *) DrawStruct );
exit = true;
break;
......
......@@ -644,8 +644,12 @@ void WinEDA_PcbFrame::createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu
{
if( edge_zone->m_Flags )
{
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_PLACE_ZONE_CORNER,
_( "Place Corner" ), apply_xpm );
if( (edge_zone->m_Flags & IN_EDIT ) )
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_PLACE_ZONE_CORNER,
_( "Place Corner" ), apply_xpm );
else
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_PLACE_ZONE_OUTLINES,
_( "Place Zone" ), apply_xpm );
}
else
{
......@@ -677,9 +681,13 @@ void WinEDA_PcbFrame::createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu
ADD_MENUITEM( zones_menu, ID_POPUP_PCB_FILL_ZONE,
_( "Fill Zone" ), fill_zone_xpm );
ADD_MENUITEM( zones_menu, ID_POPUP_PCB_MOVE_ZONE_OUTLINES,
_( "Move Zone" ), move_xpm );
ADD_MENUITEM( zones_menu, ID_POPUP_PCB_EDIT_ZONE_PARAMS,
_( "Edit Zone Params" ), edit_xpm );
zones_menu->AppendSeparator();
if ( index >= 0 && edge_zone->m_Poly->IsCutoutContour( edge_zone->m_CornerSelection ) )
ADD_MENUITEM( zones_menu, ID_POPUP_PCB_DELETE_ZONE_CUTOUT,
_( "Delete Cutout" ), delete_xpm );
......
This diff is collapsed.
......@@ -183,10 +183,10 @@ int BOARD::TestAreaPolygon( ZONE_CONTAINER* CurrArea )
if( ret )
{
// intersection between non-adjacent sides
bInt = TRUE;
bInt = true;
if( style != CPolyLine::STRAIGHT || style2 != CPolyLine::STRAIGHT )
{
bArcInt = TRUE;
bArcInt = true;
break;
}
}
......@@ -219,8 +219,8 @@ int BOARD::TestAreaPolygon( ZONE_CONTAINER* CurrArea )
* Function ClipAreaPolygon
* Process an area that has been modified, by clipping its polygon against itself.
* This may change the number and order of copper areas in the net.
* @param bMessageBoxInt == TRUE, shows message when clipping occurs.
* @param bMessageBoxArc == TRUE, shows message when clipping can't be done due to arcs.
* @param bMessageBoxInt == true, shows message when clipping occurs.
* @param bMessageBoxArc == true, shows message when clipping can't be done due to arcs.
* @return:
* -1 if arcs intersect other sides, so polygon can't be clipped
* 0 if no intersecting sides
......@@ -230,7 +230,7 @@ int BOARD::TestAreaPolygon( ZONE_CONTAINER* CurrArea )
int BOARD::ClipAreaPolygon( ZONE_CONTAINER* CurrArea,
bool bMessageBoxArc, bool bMessageBoxInt, bool bRetainArcs )
{
CPolyLine* p = CurrArea->m_Poly;
CPolyLine* curr_polygon = CurrArea->m_Poly;
int test = TestAreaPolygon( CurrArea ); // this sets utility2 flag
if( test == -1 && !bRetainArcs )
......@@ -241,7 +241,7 @@ int BOARD::ClipAreaPolygon( ZONE_CONTAINER* CurrArea,
if( bMessageBoxArc && bDontShowSelfIntersectionArcsWarning == false )
{
wxString str;
str.Printf( wxT( "Area %X of net \"%s\" has arcs intersecting other sides.\n" ),
str.Printf( wxT( "Area %8.8X of net \"%s\" has arcs intersecting other sides.\n" ),
CurrArea->m_TimeStamp, CurrArea->m_Netname.GetData() );
str += wxT( "This may cause problems with other editing operations,\n" );
str += wxT( "such as adding cutouts. It can't be fixed automatically.\n" );
......@@ -265,7 +265,7 @@ int BOARD::ClipAreaPolygon( ZONE_CONTAINER* CurrArea,
if( bMessageBoxInt && bDontShowSelfIntersectionWarning == false )
{
wxString str;
str.Printf( wxT( "Area %d of net \"%s\" is self-intersecting and will be clipped.\n" ),
str.Printf( wxT( "Area %8.8X of net \"%s\" is self-intersecting and will be clipped.\n" ),
CurrArea->m_TimeStamp, CurrArea->m_Netname.GetData() );
str += wxT( "This may result in splitting the area.\n" );
str += wxT( "If the area is complex, this may take a few seconds." );
......@@ -279,25 +279,26 @@ int BOARD::ClipAreaPolygon( ZONE_CONTAINER* CurrArea,
//** if( test == 1 )
{
std::vector<CPolyLine*> * pa = new std::vector<CPolyLine*>;
p->Undraw();
curr_polygon->Undraw();
int n_poly = CurrArea->m_Poly->NormalizeWithGpc( pa, bRetainArcs );
if( n_poly > 1 ) // i.e if clippinf has created some polygons, we must add these new copper areas
if( n_poly > 1 ) // i.e if clipping has created some polygons, we must add these new copper areas
{
ZONE_CONTAINER* NewArea;
for( int ip = 1; ip < n_poly; ip++ )
{
// create new copper area and copy poly into it
CPolyLine* new_p = (*pa)[ip - 1];
CurrArea = AddArea( CurrArea->GetNet(), CurrArea->GetLayer(), 0, 0, 0 );
NewArea = AddArea( CurrArea->GetNet(), CurrArea->GetLayer(), 0, 0, 0 );
// remove the poly that was automatically created for the new area
// and replace it with a poly from NormalizeWithGpc
delete CurrArea->m_Poly;
CurrArea->m_Poly = new_p;
CurrArea->m_Poly->Draw();
CurrArea->utility = 1;
delete NewArea->m_Poly;
NewArea->m_Poly = new_p;
NewArea->m_Poly->Draw();
NewArea->utility = 1;
}
}
p->Draw();
curr_polygon->Draw();
delete pa;
}
return test;
......@@ -309,7 +310,7 @@ int BOARD::ClipAreaPolygon( ZONE_CONTAINER* CurrArea,
* itself and the polygons for any other areas on the same net.
* This may change the number and order of copper areas in the net.
* @param modified_area = area to test
* @param bMessageBox : if TRUE, shows message boxes when clipping occurs.
* @param bMessageBox : if true, shows message boxes when clipping occurs.
* @return :
* -1 if arcs intersect other sides, so polygon can't be clipped
* 0 if no intersecting sides
......@@ -328,11 +329,11 @@ int BOARD::AreaPolygonModified( ZONE_CONTAINER* modified_area,
// now see if we need to clip against other areas
bool bCheckAllAreas = false;
if( test == 1 )
bCheckAllAreas = TRUE;
bCheckAllAreas = true;
else
bCheckAllAreas = TestAreaIntersections( modified_area );
if( bCheckAllAreas )
CombineAllAreasInNet( modified_area->GetNet(), bMessageBoxInt, TRUE );
CombineAllAreasInNet( modified_area->GetNet(), bMessageBoxInt, true );
return test;
}
......@@ -400,7 +401,7 @@ int BOARD::CombineAllAreasInNet( int aNetCode, bool bMessageBox, bool bUseUtilit
// bDontShowIntersectionWarning = dlg.bDontShowBoxState;
}
mod_ia1 = TRUE;
mod_ia1 = true;
}
else if( ret == 2 )
{
......@@ -508,12 +509,33 @@ bool BOARD::TestAreaIntersections( ZONE_CONTAINER* area_to_test )
int n_int = FindSegmentIntersections( xi1, yi1, xf1, yf1, style1,
xi2, yi2, xf2, yf2, style2 );
if( n_int )
return TRUE;
return true;
}
}
}
}
}
// If a contour is inside an other contour, no segments intersects, but the zones can be combined
// test a corner inside an outline (only one corner is enought)
/* for( int ic2 = 0; ic2 < poly2->GetNumCorners(); ic2++ )
{
int x = poly2->GetX( ic2 );
int y = poly2->GetY( ic2 );
if( poly1->TestPointInside( x, y ) )
{
return true;
}
}
for( int ic1 = 0; ic1 < poly1->GetNumCorners(); ic1++ )
{
int x = poly1->GetX( ic1 );
int y = poly1->GetY( ic1 );
if( poly2->TestPointInside( x, y ) )
{
return true;
}
}
*/ }
return false;
}
......@@ -594,9 +616,9 @@ int BOARD::TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_
xi2, yi2, xf2, yf2, style2 );
if( n_int )
{
bInt = TRUE;
bInt = true;
if( style1 != CPolyLine::STRAIGHT || style2 != CPolyLine::STRAIGHT )
bArcInt = TRUE;
bArcInt = true;
break;
}
}
......@@ -614,7 +636,32 @@ int BOARD::TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_
}
if( !bInt )
return 0;
{
/* if( bArcInt ) return 0;
// If a contour is inside an other contour, no segments intersects, but the zones can be combined
// test a corner inside an outline (only one corner is enought)
for( int ic2 = 0; ic2 < poly2->GetNumCorners(); ic2++ )
{
int x = poly2->GetX( ic2 );
int y = poly2->GetY( ic2 );
if( poly1->TestPointInside( x, y ) )
{
return 1;
}
}
for( int ic1 = 0; ic1 < poly1->GetNumCorners(); ic1++ )
{
int x = poly1->GetX( ic1 );
int y = poly1->GetY( ic1 );
if( poly2->TestPointInside( x, y ) )
{
return 1;
}
}
*/ return 0;
}
if( bArcInt )
return 2;
return 1;
......
......@@ -10,6 +10,9 @@ using namespace std;
#include <math.h>
#include <vector>
#include "fctsys.h"
#include "PolyLine.h"
#define to_int(x) (int)round((x))
......@@ -83,8 +86,7 @@ int CPolyLine::NormalizeWithGpc( std::vector<CPolyLine*> * pa, bool bRetainArcs
{
// next external contour, create new poly
CPolyLine * poly = new CPolyLine;
pa->SetSize(n_ext_cont); // put in array
(*pa)[n_ext_cont-1] = poly;
pa->push_back(poly); // put in array
for( int i=0; i<m_gpc_poly->contour[ic].num_vertices; i++ )
{
int x = to_int(((m_gpc_poly->contour)[ic].vertex)[i].x);
......@@ -136,7 +138,7 @@ int CPolyLine::NormalizeWithGpc( std::vector<CPolyLine*> * pa, bool bRetainArcs
}
}
if( !ext_poly )
ASSERT(0);
wxASSERT(0);
for( int i=0; i<m_gpc_poly->contour[ic].num_vertices; i++ )
{
int x = to_int(((m_gpc_poly->contour)[ic].vertex)[i].x);
......@@ -422,7 +424,7 @@ int CPolyLine::MakeGpcPoly( int icontour, std::vector<CArc> * arc_array )
}
}
if( n_vertices != ivtx )
ASSERT(0);
wxASSERT(0);
// add vertex_list to gpc
gpc_add_contour( gpc, g_v_list, 0 );
// now clip m_gpc_poly with gpc, put new poly into result
......@@ -641,7 +643,7 @@ void CPolyLine::AppendCorner( int x, int y, int style, bool bDraw )
else if( style == CPolyLine::ARC_CCW )
dl_type = DL_ARC_CCW;
else
ASSERT(0);
wxASSERT(0);
if( bDraw )
Draw();
}
......@@ -651,7 +653,7 @@ void CPolyLine::AppendCorner( int x, int y, int style, bool bDraw )
void CPolyLine::Close( int style, bool bDraw )
{
if( GetClosed() )
ASSERT(0);
wxASSERT(0);
Undraw();
side_style[corner.size()-1] = style;
corner[corner.size()-1].end_contour = TRUE;
......@@ -720,7 +722,7 @@ void CPolyLine::RemoveContour( int icont )
if( icont == 0 && GetNumContours() == 1 )
{
// remove the only contour
ASSERT(0);
wxASSERT(0);
}
else if( icont == GetNumContours()-1 )
{
......@@ -919,7 +921,7 @@ int CPolyLine::GetContourStart( int icont )
return i+1;
}
}
ASSERT(0);
wxASSERT(0);
return 0;
}
......@@ -941,7 +943,7 @@ int CPolyLine::GetContourEnd( int icont )
ncont++;
}
}
ASSERT(0);
wxASSERT(0);
return 0;
}
......@@ -1062,7 +1064,7 @@ void CPolyLine::Hatch()
else if( layer < (LAY_TOP_COPPER+16) )
offset = 7*spacing/8;
else
ASSERT(0);
wxASSERT(0);
min_a += offset;
// now calculate and draw hatch lines
......@@ -1104,20 +1106,20 @@ void CPolyLine::Hatch()
xx[npts] = (int)x;
yy[npts] = (int)y;
npts++;
ASSERT( npts<MAXPTS ); // overflow
wxASSERT( npts<MAXPTS ); // overflow
}
if( ok == 2 )
{
xx[npts] = (int)x2;
yy[npts] = (int)y2;
npts++;
ASSERT( npts<MAXPTS ); // overflow
wxASSERT( npts<MAXPTS ); // overflow
}
}
nloops++;
a += PCBU_PER_MIL/100;
} while( npts%2 != 0 && nloops < 3 );
ASSERT( npts%2==0 ); // odd number of intersection points, error
wxASSERT( npts%2==0 ); // odd number of intersection points, error
// sort points in order of descending x (if more than 2)
if( npts>2 )
......@@ -1177,7 +1179,7 @@ bool CPolyLine::TestPointInside( int x, int y )
{
enum { MAXPTS = 100 };
if( !GetClosed() )
ASSERT(0);
wxASSERT(0);
// define line passing through (x,y), with slope = 2/3;
// get intersection points
......@@ -1216,21 +1218,21 @@ bool CPolyLine::TestPointInside( int x, int y )
xx[npts] = (int)x;
yy[npts] = (int)y;
npts++;
ASSERT( npts<MAXPTS ); // overflow
wxASSERT( npts<MAXPTS ); // overflow
}
if( ok == 2 )
{
xx[npts] = (int)x2;
yy[npts] = (int)y2;
npts++;
ASSERT( npts<MAXPTS ); // overflow
wxASSERT( npts<MAXPTS ); // overflow
}
}
}
nloops++;
a += PCBU_PER_MIL/100;
} while( npts%2 != 0 && nloops < 3 );
ASSERT( npts%2==0 ); // odd number of intersection points, error
wxASSERT( npts%2==0 ); // odd number of intersection points, error
// count intersection points to right of (x,y), if odd (x,y) is inside polyline
int ncount = 0;
......@@ -1256,7 +1258,7 @@ bool CPolyLine::TestPointInsideContour( int icont, int x, int y )
enum { MAXPTS = 100 };
if( !GetClosed() )
ASSERT(0);
wxASSERT(0);
// define line passing through (x,y), with slope = 2/3;
// get intersection points
......@@ -1293,20 +1295,20 @@ bool CPolyLine::TestPointInsideContour( int icont, int x, int y )
xx[npts] = (int)x;
yy[npts] = (int)y;
npts++;
ASSERT( npts<MAXPTS ); // overflow
wxASSERT( npts<MAXPTS ); // overflow
}
if( ok == 2 )
{
xx[npts] = (int)x2;
yy[npts] = (int)y2;
npts++;
ASSERT( npts<MAXPTS ); // overflow
wxASSERT( npts<MAXPTS ); // overflow
}
}
nloops++;
a += PCBU_PER_MIL/100;
} while( npts%2 != 0 && nloops < 3 );
ASSERT( npts%2==0 ); // odd number of intersection points, error
wxASSERT( npts%2==0 ); // odd number of intersection points, error
// count intersection points to right of (x,y), if odd (x,y) is inside polyline
int ncount = 0;
......@@ -1328,9 +1330,9 @@ bool CPolyLine::TestPointInsideContour( int icont, int x, int y )
int CPolyLine::TestIntersection( CPolyLine * poly )
{
if( !GetClosed() )
ASSERT(0);
wxASSERT(0);
if( !poly->GetClosed() )
ASSERT(0);
wxASSERT(0);
for( int ic=0; ic<GetNumContours(); ic++ )
{
int istart = GetContourStart(ic);
......
......@@ -36,6 +36,4 @@
#define TRACE printf
#define ASSERT(x) // todo : change to wxASSERT, under wxWidgets
#endif // ifndef DEFS_MACROS_H
......@@ -50,6 +50,9 @@
#include <math.h>
#include "fctsys.h"
#include "php_polygon_vertex.h"
#include "php_polygon.h"
......@@ -427,9 +430,9 @@ BOOL polygon::ints( vertex * p1, vertex * p2, vertex * q1, vertex * q2,
double tua = ((tx4-tx3)*(ty1-ty3)-(ty4-ty3)*(tx1-tx3))/td;
double tub = ((tx2-tx1)*(ty1-ty3)-(ty2-ty1)*(tx1-tx3))/td;
if( abs(tua)<=eps || abs(1.0-tua)<=eps || abs(tub)<=eps || abs(1.0-tub)<=eps )
ASSERT(0);
wxASSERT(0);
else if( (tua > 0 && tua < 1) && (tub > 0 && tub < 1) )
ASSERT(0);
wxASSERT(0);
TRACE( " perturb:\n new s = (%f,%f) to (%f,%f)\n new c = (%f,%f) to (%f,%f)\n new ua = %.17f, ub = %.17f\n",
tx1, ty1, tx2, ty2, tx3, ty3, tx4, ty4, tua, tub );
}
......@@ -650,7 +653,7 @@ BOOL polygon::isInside( vertex * v )
{
//** modified for testing
if( v->isIntersect() )
ASSERT(0);
wxASSERT(0);
int winding_number = 0;
int winding_number2 = 0;
int winding_number3 = 0;
......@@ -689,7 +692,7 @@ BOOL polygon::isInside( vertex * v )
if( winding_number%2 != winding_number2%2
|| winding_number3%2 != winding_number4%2
|| winding_number%2 != winding_number3%2 )
ASSERT(0);
wxASSERT(0);
if( winding_number%2 == 0 ) // Check even or odd
return FALSE; // even == outside
else
......@@ -780,9 +783,9 @@ polygon * polygon::boolean( polygon * polyB, int oper )
s = s->Next();
} while( s->id() != polyB->m_first->id() );
if( n_ints != n_polyB_ints )
ASSERT(0);
wxASSERT(0);
if( n_ints%2 != 0 )
ASSERT(0);
wxASSERT(0);
//** end test
/*
......@@ -817,7 +820,7 @@ polygon * polygon::boolean( polygon * polyB, int oper )
s = m_first;
//** testing
if( s->isIntersect() )
ASSERT(0);
wxASSERT(0);
//** end test
BOOL entry;
if (polyB->isInside(s)) // if we are already inside
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment