Skip to content

Commit

Permalink
use shape.proximity(s) to test for overlapping faces in CSG import
Browse files Browse the repository at this point in the history
  • Loading branch information
5263 authored and wwmayer committed Mar 21, 2015
1 parent 565a875 commit 01b491b
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/Mod/OpenSCAD/OpenSCAD2Dgeom.py
Expand Up @@ -51,6 +51,11 @@ def vertsinface(f1,verts,tol=0.001,inface=True):
return all([f1.isInside(vert.Point,tol,inface) for vert in verts])
return vertsinface(bigface,smallface.Vertexes)

@staticmethod
def dofacesoverlapproximity(bigface,smallface):
l1,l2 = bigface.proximity(smallface)
return len(l1) > 0 or len(l2) > 0

@staticmethod
def dofacesoverlapboolean(bigface,smallface):
#import FreeCAD,FreeCADGui
Expand All @@ -64,13 +69,20 @@ def builddepdict(self):
#isinsidelist = []
self.isinsidedict = {}
#for bigface, smallface in itertools.combinations(sortedfaces,2):
for bigfacei, smallfacei in itertools.combinations(range(len(self.sortedfaces)),2):
for bigfacei, smallfacei in\
itertools.combinations(range(len(self.sortedfaces)),2):
try:
overlap = Overlappingfaces.dofacesoverlapboolean(\
self.sortedfaces[bigfacei],self.sortedfaces[smallfacei])
except Part.OCCError:
overlap = Overlappingfaces.dofacesoverlapallverts(\
overlap = Overlappingfaces.dofacesoverlapproximity(\
self.sortedfaces[bigfacei],self.sortedfaces[smallfacei])
except (NotImplementedError, Part.OCCError) as e:
try:
overlap = Overlappingfaces.dofacesoverlapboolean(\
self.sortedfaces[bigfacei],\
self.sortedfaces[smallfacei])
except Part.OCCError:
overlap = Overlappingfaces.dofacesoverlapallverts(\
self.sortedfaces[bigfacei],\
self.sortedfaces[smallfacei])
if overlap:
#isinsidelist.append((bigfacei,smallfacei))
smallinbig = self.isinsidedict.get(bigfacei,[])
Expand Down Expand Up @@ -158,8 +170,10 @@ def addfeature(faceindex,isinsidedict):
if len(directchildren) == 1:
obj.Tool = addfeature(directchildren[0],subdict)
else:
obj.Tool = doc.addObject("Part::MultiFuse","facesfromedges_union")
obj.Tool.Shapes = [addfeature(child,subdict) for child in directchildren]
obj.Tool = doc.addObject("Part::MultiFuse",\
"facesfromedges_union")
obj.Tool.Shapes = [addfeature(child,subdict)\
for child in directchildren]
obj.Tool.ViewObject.hide()
obj.ViewObject.hide()
return obj
Expand Down

0 comments on commit 01b491b

Please sign in to comment.