Skip to content

Commit 3d04d4c

Browse files
matscaliaphkahler
authored andcommitted
skip duplicate drilled holes
1 parent 7ccb0ff commit 3d04d4c

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/importidf.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,20 @@ static std::vector <std::string> splitString(const std::string line) {
5353
return v;
5454
}
5555

56+
static bool isHoleDuplicate(EntityList *el, double x, double y, double r) {
57+
bool duplicate = false;
58+
for(int i = 0; i < el->n && !duplicate; i++) {
59+
Entity &en = el->Get(i);
60+
if(en.type != Entity::Type::CIRCLE)
61+
continue;
62+
Entity *distance = el->FindById(en.distance);
63+
Entity *center = el->FindById(en.point[0]);
64+
duplicate =
65+
center->actPoint.x == x && center->actPoint.y == y && distance->actDistance == r;
66+
}
67+
return duplicate;
68+
}
69+
5670
//////////////////////////////////////////////////////////////////////////////
5771
// Functions for linking an IDF file - we need to create entities that
5872
// get remapped into a linked group similar to linking .slvs files
@@ -462,9 +476,10 @@ bool LinkIDF(const Platform::Path &filename, EntityList *el, SMesh *m, SShell *s
462476
double d = stof(values[0]);
463477
double x = stof(values[1]);
464478
double y = stof(values[2]);
479+
bool duplicate = isHoleDuplicate(el, x, y, d / 2);
465480
// Only show holes likely to be useful in MCAD to reduce complexity.
466-
if((d > 1.7) || (values[5].compare(0,3,"PIN") == 0)
467-
|| (values[5].compare(0,3,"MTG") == 0)) {
481+
if(((d > 1.7) || (values[5].compare(0,3,"PIN") == 0)
482+
|| (values[5].compare(0,3,"MTG") == 0)) && !duplicate) {
468483
// create the entity
469484
Vector cent = Vector::From(x,y,0.0);
470485
hEntity hcent = newPoint(el, &entityCount, cent);

0 commit comments

Comments
 (0)