Fixed Geometry merging. Solves issue #99.

This commit is contained in:
Juan Pablo Caram 2015-01-18 20:23:37 -05:00
parent 840cfcf9ff
commit 34a6b60053
4 changed files with 27 additions and 12 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
*.pyc *.pyc
.idea/

View File

@ -53,8 +53,8 @@ class App(QtCore.QObject):
## Logging ## ## Logging ##
log = logging.getLogger('base') log = logging.getLogger('base')
#log.setLevel(logging.DEBUG) log.setLevel(logging.DEBUG)
log.setLevel(logging.WARNING) #log.setLevel(logging.WARNING)
formatter = logging.Formatter('[%(levelname)s][%(threadName)s] %(message)s') formatter = logging.Formatter('[%(levelname)s][%(threadName)s] %(message)s')
handler = logging.StreamHandler() handler = logging.StreamHandler()
handler.setFormatter(formatter) handler.setFormatter(formatter)

View File

@ -875,16 +875,28 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
:param geo_final: Destination FlatCAMGeometry object. :param geo_final: Destination FlatCAMGeometry object.
:return: None :return: None
""" """
geo_final.solid_geometry = []
if geo_final.solid_geometry is None:
geo_final.solid_geometry = []
if type(geo_final.solid_geometry) is not list:
geo_final.solid_geometry = [geo_final.solid_geometry]
for geo in geo_list: for geo in geo_list:
try: # Iterable # Expand lists
for shape in geo.solid_geometry: if type(geo) is list:
geo_final.solid_geometry.append(shape) FlatCAMGeometry.merge(geo, geo_final)
except TypeError: # Non-iterable # If not list, just append
geo_final.solid_geometry.append(geo) else:
geo_final.solid_geometry.append(geo.solid_geometry)
# try: # Iterable
# for shape in geo.solid_geometry:
# geo_final.solid_geometry.append(shape)
#
# except TypeError: # Non-iterable
# geo_final.solid_geometry.append(geo.solid_geometry)
def __init__(self, name): def __init__(self, name):
FlatCAMObj.__init__(self, name) FlatCAMObj.__init__(self, name)

View File

@ -42,8 +42,8 @@ import simplejson as json
import logging import logging
log = logging.getLogger('base2') log = logging.getLogger('base2')
#log.setLevel(logging.DEBUG) log.setLevel(logging.DEBUG)
log.setLevel(logging.WARNING) #log.setLevel(logging.WARNING)
#log.setLevel(logging.INFO) #log.setLevel(logging.INFO)
formatter = logging.Formatter('[%(levelname)s] %(message)s') formatter = logging.Formatter('[%(levelname)s] %(message)s')
handler = logging.StreamHandler() handler = logging.StreamHandler()
@ -1908,7 +1908,7 @@ class Excellon(Geometry):
try: try:
for eline in elines: for eline in elines:
line_num += 1 line_num += 1
log.debug("%3d %s" % (line_num, str(eline))) #log.debug("%3d %s" % (line_num, str(eline)))
### Cleanup lines ### Cleanup lines
eline = eline.strip(' \r\n') eline = eline.strip(' \r\n')
@ -1966,6 +1966,7 @@ class Excellon(Geometry):
continue continue
self.drills.append({'point': Point((x, y)), 'tool': current_tool}) self.drills.append({'point': Point((x, y)), 'tool': current_tool})
log.debug("{:15} {:8} {:8}".format(eline, x, y))
continue continue
## Coordinates with period: Use literally. ## ## Coordinates with period: Use literally. ##
@ -1988,6 +1989,7 @@ class Excellon(Geometry):
continue continue
self.drills.append({'point': Point((x, y)), 'tool': current_tool}) self.drills.append({'point': Point((x, y)), 'tool': current_tool})
log.debug("{:15} {:8} {:8}".format(eline, x, y))
continue continue
#### Header #### #### Header ####