Merge pull request #444 from looooo/python3-fixes

python3: neutral fixes
This commit is contained in:
wwmayer 2017-01-15 16:00:19 +01:00 committed by GitHub
commit adb9353d27
2 changed files with 20 additions and 18 deletions

View File

@ -110,11 +110,13 @@ def myCustomFusionRoutine(list_of_shapes):
types.add(piece.ShapeType) types.add(piece.ShapeType)
types_to_extract = types.intersection(nonaggregate_types) types_to_extract = types.intersection(nonaggregate_types)
extractor = lambda(sh):(
(sh.Vertexes if "Vertex" in types_to_extract else []) def extractor(sh):
+ (sh.Edges if "Edge" in types_to_extract else []) return (
+ (sh.Faces if "Face" in types_to_extract else []) (sh.Vertexes if "Vertex" in types_to_extract else []) +
+ (sh.Solids if "Solid" in types_to_extract else []) (sh.Edges if "Edge" in types_to_extract else []) +
(sh.Faces if "Face" in types_to_extract else []) +
(sh.Solids if "Solid" in types_to_extract else [])
) )
aggregate_sources_indexes = [self.indexOfSource(sh) for sh in self.source_shapes if sh.ShapeType in aggregate_types] aggregate_sources_indexes = [self.indexOfSource(sh) for sh in self.source_shapes if sh.ShapeType in aggregate_types]
@ -298,14 +300,14 @@ def myCustomFusionRoutine(list_of_shapes):
original shape.""" original shape."""
if shape.ShapeType == "Wire": if shape.ShapeType == "Wire":
bit_extractor = lambda(sh): sh.Edges bit_extractor = lambda sh: sh.Edges
joint_extractor = lambda(sh): sh.Vertexes joint_extractor = lambda sh: sh.Vertexes
elif shape.ShapeType == "Shell": elif shape.ShapeType == "Shell":
bit_extractor = lambda(sh): sh.Faces bit_extractor = lambda sh: sh.Faces
joint_extractor = lambda(sh): sh.Edges joint_extractor = lambda sh: sh.Edges
elif shape.ShapeType == "CompSolid": elif shape.ShapeType == "CompSolid":
bit_extractor = lambda(sh): sh.Solids bit_extractor = lambda sh: sh.Solids
joint_extractor = lambda(sh): sh.Faces joint_extractor = lambda sh: sh.Faces
else: else:
#can't split the shape #can't split the shape
return [shape] return [shape]

View File

@ -50,9 +50,9 @@ def isConnected(shape1, shape2, shape_dim = -1):
if shape_dim == -1: if shape_dim == -1:
shape_dim = dimensionOfShapes([shape1, shape2]) shape_dim = dimensionOfShapes([shape1, shape2])
extractor = {0: None, extractor = {0: None,
1: (lambda(sh): sh.Vertexes), 1: (lambda sh: sh.Vertexes),
2: (lambda(sh): sh.Edges), 2: (lambda sh: sh.Edges),
3: (lambda(sh): sh.Faces) }[shape_dim] 3: (lambda sh: sh.Faces) }[shape_dim]
return len(findSharedElements([shape1, shape2], extractor))>0 return len(findSharedElements([shape1, shape2], extractor))>0
def splitIntoGroupsBySharing(list_of_shapes, element_extractor, split_connections = []): def splitIntoGroupsBySharing(list_of_shapes, element_extractor, split_connections = []):
@ -132,7 +132,7 @@ def mergeSolids(list_of_solids_compsolids, flag_single = False, split_connection
else: else:
if len(solids)==0: if len(solids)==0:
return Part.Compound([]) return Part.Compound([])
groups = splitIntoGroupsBySharing(solids, lambda(sh): sh.Faces, split_connections) groups = splitIntoGroupsBySharing(solids, lambda sh: sh.Faces, split_connections)
if bool_compsolid: if bool_compsolid:
merged_solids = [Part.CompSolid(group) for group in groups] merged_solids = [Part.CompSolid(group) for group in groups]
else: else:
@ -146,7 +146,7 @@ def mergeShells(list_of_faces_shells, flag_single = False, split_connections = [
if flag_single: if flag_single:
return Part.makeShell(faces) return Part.makeShell(faces)
else: else:
groups = splitIntoGroupsBySharing(faces, lambda(sh): sh.Edges, split_connections) groups = splitIntoGroupsBySharing(faces, lambda sh: sh.Edges, split_connections)
return Part.makeCompound([Part.Shell(group) for group in groups]) return Part.makeCompound([Part.Shell(group) for group in groups])
def mergeWires(list_of_edges_wires, flag_single = False, split_connections = []): def mergeWires(list_of_edges_wires, flag_single = False, split_connections = []):
@ -156,7 +156,7 @@ def mergeWires(list_of_edges_wires, flag_single = False, split_connections = [])
if flag_single: if flag_single:
return Part.Wire(edges) return Part.Wire(edges)
else: else:
groups = splitIntoGroupsBySharing(edges, lambda(sh): sh.Vertexes, split_connections) groups = splitIntoGroupsBySharing(edges, lambda sh: sh.Vertexes, split_connections)
return Part.makeCompound([Part.Wire(Part.getSortedClusters(group)[0]) for group in groups]) return Part.makeCompound([Part.Wire(Part.getSortedClusters(group)[0]) for group in groups])
def mergeVertices(list_of_vertices, flag_single = False, split_connections = []): def mergeVertices(list_of_vertices, flag_single = False, split_connections = []):