Index: trunk/src/board.c =================================================================== --- trunk/src/board.c (revision 19254) +++ trunk/src/board.c (revision 19255) @@ -199,6 +199,21 @@ return PCB_R_DIR_FOUND_CONTINUE; } +static pcb_r_dir_t slot_counting_callback(const pcb_box_t *b, void *cl) +{ + pcb_pstk_t *ps = (pcb_pstk_t *)b; + pcb_pstk_proto_t *proto = pcb_pstk_get_proto(ps); + HoleCountStruct *hcs = (HoleCountStruct *)cl; + + if ((proto != NULL) && (proto->mech_idx >= 0)) { + if (proto->hplated) + hcs->nplated++; + else + hcs->nunplated++; + } + return PCB_R_DIR_FOUND_CONTINUE; +} + void pcb_board_count_holes(pcb_board_t *pcb, int *plated, int *unplated, const pcb_box_t *within_area) { HoleCountStruct hcs = { 0, 0 }; @@ -211,6 +226,18 @@ *unplated = hcs.nunplated; } +void pcb_board_count_slots(pcb_board_t *pcb, int *plated, int *unplated, const pcb_box_t *within_area) +{ + HoleCountStruct hcs = { 0, 0 }; + + pcb_r_search(pcb->Data->padstack_tree, within_area, NULL, slot_counting_callback, &hcs, NULL); + + if (plated != NULL) + *plated = hcs.nplated; + if (unplated != NULL) + *unplated = hcs.nunplated; +} + const char *pcb_board_get_filename(void) { return PCB->Filename; Index: trunk/src/board.h =================================================================== --- trunk/src/board.h (revision 19254) +++ trunk/src/board.h (revision 19255) @@ -118,10 +118,10 @@ force is non-zero, overwrite even existing colors. */ void pcb_layer_colors_from_conf(pcb_board_t *pcb, int force); -/* counts the number of plated and unplated holes in the design within - a given area of the board. To count for the whole board, pass NULL - within_area. */ -void pcb_board_count_holes(pcb_board_t *pcb, int *plated, int *unplated, const pcb_box_t * within_area); +/* counts the number of plated and unplated holes or slots in the design within + a given area of the board. To count for the whole board, pass NULL within_area. */ +void pcb_board_count_holes(pcb_board_t *pcb, int *plated, int *unplated, const pcb_box_t *within_area); +void pcb_board_count_slots(pcb_board_t *pcb, int *plated, int *unplated, const pcb_box_t *within_area); #define PCB_SWAP_X(x) (PCB_SWAP_SIGN_X(x)) #define PCB_SWAP_Y(y) (PCB->MaxHeight +PCB_SWAP_SIGN_Y(y))