-
Notifications
You must be signed in to change notification settings - Fork 70
/
a2p_topomapper.py
703 lines (655 loc) · 29.2 KB
/
a2p_topomapper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
#***************************************************************************
#* *
#* Copyright (c) 2018 kbwbe *
#* *
#* Portions of code based on hamish's assembly 2 *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* This program is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with this program; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************
"""
Experimental mapper for a2p related topological naming.
It is used during first level import of fcstd documents to a2p
Working principle:
- History of toplevel shapes within the fcstd doc is analyzed starting from
the very first basefeature (found recursively from toplevel shapes)
- The algorithm analyses the vertexes/edges/faces of each shape in history
- Each topo element is described by geometrical values (position,axis,etc)
- A dictionary is build, the geometrical values are used as keys and the
values are the names of the topo-elements.
- during processing of a new shape/feature, it's keys are calculated and looked
up in the dictionary. If a key already exists, the algo assumes, that the
geometry belongs to a former analysed shape. If the key does not exist,
a new key/name pair is added to the dictionary.
- When all shapes are processed, there exists a dict with (multiple) entries
of all geometry.
- Some geometry causes multiple keys. So for plane faces there are stored
two keys per vertex. One with positive axis value, one with neg.axis value.
This is necessary because normals can flip during build history.
Key-generation:
keys for vertexes: "xvalue;yvalue;zvalue"
keys for edges: (different ones for different edge types)
straight lines
2 keys are uses, each consists of:
- vertexkey of the endpoint
- an axiskey pointing to the other endpoint
circles:
two keys are used for each vertex on the curve
- key consisting of center-vertex and positive axis data + radius
- key consisting of center-vertex and negative axis data + radius
- both marked with "CIRC" at the beginning
other edge types are put to dict with dummy entries.
keys for faces:
Plane faces are described by vertex/normal for each vertex.
Additionally a second entry by vertex/neg.normal for each vertex.
Spheres are described by center-vertex + radius
Cylindrical faces are described by vertex/pos.axis+radius and second one
with neg.axis per vertex.
Newer shapes in history can delete geo elements of previous ones. If the algorithm
finds one relicting key of an old shape in the dict, it assumes that the geo element
belongs to the old shape. Newly created geo elements, which belong together, then get
the old name, otherwise a new name is defined and put to the dict.
Example:
A new feature cuts away an endpoint of a line, but one still exists:
the newly linesegment belongs logically to the old existing one. The new vertex gets the existing name.
So if a constraint was linked to the old linesegment, we can map it to the new linesegment and the
assembly keeps consistent.
After building the dict, the compound shape of total doc is analysed. Keys of this are build
and looked up in the dict to get the names.
A List of names (same indexes as vertexes[n],edges[],faces[] is generated for output.
All this helps A2plus to identify the correct subelements for constraints, if imported
parts are been edited.
"""
import FreeCAD
import Part
from FreeCAD import Base
from a2p_translateUtils import *
import a2plib
class TopoMapper(object):
def __init__(self,doc):
self.doc = doc
self.fileName = self.doc.FileName
self.shapeDict = {}
self.vertexNames = []
self.edgeNames = []
self.faceNames = []
self.treeNodes = {}
self.topLevelShapes = []
self.doneObjects = []
self.totalNumVertexes = 0
self.totalNumEdges = 0
self.totalNumFaces = 0
self.isPartDesignDocument = False
def calcFloatKey(self,val):
return "%014.3f;" % val
def calcVertexKey(self,inOb):
"""
Create a unique key defined by vertex-position,
accepts also vectors as input
"""
try:
coords = (
inOb.Point.x,
inOb.Point.y,
inOb.Point.z
)
except:
coords = (
inOb.x,
inOb.y,
inOb.z,
)
key = ''
for value in coords:
keyPartial = "%014.3f;" % value
if keyPartial == "-000000000.000;": keyPartial = "0000000000.000;"
key += keyPartial
return key
def calcAxisKey(self,axis):
"""
Create a unique key defined by axis-direction.
"""
coords = (
axis.x,
axis.y,
axis.z
)
key = ''
for value in coords:
keyPartial = "%012.9f;" % value
if keyPartial == "-0.000000000;": keyPartial = "00.000000000;"
key += keyPartial
return key
def calcEdgeKeys(self, edge, pl):
keys = []
# workaround for hasattr(edge,"Curve"), which does not work with spheres on conda builds
curveAttributeExists = False
try:
if hasattr(edge,"Curve"): # throws exception on Conda build (spheres),
curveAttributeExists = True
except:
pass
# circular edge #hasattr(edge,"Curve") because of spheres...
if (
curveAttributeExists and
hasattr(edge.Curve,'Axis') and
hasattr(edge.Curve,'Radius')
):
axisStart = pl.multVec(edge.Curve.Center)
axisEnd = pl.multVec(edge.Curve.Center.add(edge.Curve.Axis))
axis = axisEnd.sub(axisStart)
keys.append(
'CIRC;'+
self.calcVertexKey(pl.multVec(edge.Curve.Center))+
self.calcAxisKey(axis)+
self.calcFloatKey(edge.Curve.Radius)
)
else:
endPoint1 = pl.multVec(edge.Vertexes[0].Point)
endPoint2 = pl.multVec(edge.Vertexes[-1].Point)
direction1 = endPoint2.sub(endPoint1)
direction2 = endPoint1.sub(endPoint2)
try:
direction1.normalize()
direction2.normalize()
except:
pass
keys.append(
self.calcVertexKey(endPoint1)+
self.calcAxisKey(direction1)
)
keys.append(
self.calcVertexKey(endPoint2)+
self.calcAxisKey(direction2)
)
return keys
def calcFaceKeys(self, face, pl):
keys = []
# A sphere...
if str( face.Surface ).startswith('Sphere'):
keys.append(
'SPH;'+
self.calcVertexKey(pl.multVec(face.Surface.Center))+
self.calcFloatKey(face.Surface.Radius)
)
# a cylindric face...
elif all( hasattr(face.Surface,a) for a in ['Axis','Center','Radius'] ):
axisStart = pl.multVec(face.Surface.Center)
axisEnd = pl.multVec(face.Surface.Center.add(face.Surface.Axis))
axis = axisEnd.sub(axisStart)
axisKey = self.calcAxisKey(axis)
negativeAxis = Base.Vector(axis)
negativeAxis.multiply(-1.0)
negativeAxisKey = self.calcAxisKey(negativeAxis)
radiusKey = self.calcFloatKey(face.Surface.Radius)
#
for v in face.Vertexes:
vertexKey = self.calcVertexKey(pl.multVec(v.Point))
keys.append(
'CYL;'+
vertexKey+
axisKey+
radiusKey
)
keys.append(
'CYL;'+
vertexKey+
negativeAxisKey+
radiusKey
)
elif str( face.Surface ) == '<Plane object>':
pt = face.Vertexes[0].Point
uv=face.Surface.parameter(pt)
u=uv[0]
v=uv[1]
normal=face.normalAt(u,v)
normalStart = pl.multVec(pt)
normalEnd = pl.multVec(pt.add(normal))
normal = normalEnd.sub(normalStart)
negativeNormal = Base.Vector(normal)
negativeNormal.multiply(-1.0)
normalKey = self.calcAxisKey(normal)
negativeNormalKey = self.calcAxisKey(negativeNormal)
for vert in face.Vertexes:
vertexKey = self.calcVertexKey(pl.multVec(vert.Point))
keys.append(
'PLANE;'+
vertexKey+
normalKey
)
keys.append(
'PLANE;'+
vertexKey+
negativeNormalKey
)
else:
keys.append("NOTRACE")
return keys #FIXME
def populateShapeDict(self,objName):
self.doneObjects.append(objName)
ob = self.doc.getObject(objName)
shape = ob.Shape
if objName.startswith("Link"):
pl = ob.Placement
else:
pl = ob.getGlobalPlacement().multiply(ob.Placement.inverse())
#
# Populate vertex entries...
vertexes = shape.Vertexes
numNewlyCreatedVertexes = len(shape.Vertexes) - self.totalNumVertexes
self.totalNumVertexes = len(shape.Vertexes)
vertexNamePrefix = 'V;'+objName + ';'
vertexNameSuffix = str(numNewlyCreatedVertexes)+';' #only correct for PartDesign, PartWB gives false counts
i = 1 # do not enumerate the following, count new vertexes !
for vertex in vertexes:
vertexKey = self.calcVertexKey(pl.multVec(vertex.Point))
if self.isPartDesignDocument:
vertexName = vertexNamePrefix + str(i) + ';' + vertexNameSuffix
else:
vertexName = vertexNamePrefix + str(i) + ';'
vertexFound = self.shapeDict.get(vertexKey,False)
if vertexFound == False:
self.shapeDict[vertexKey] = vertexName
i+=1 # new vertex counting per feature
#
# populate edge entries...
edges = shape.Edges
numNewlyCreatedEdges = len(edges) - self.totalNumEdges
self.totalNumEdges = len(edges)
edgeNamePrefix = 'E;' + objName + ';'
edgeNameSuffix = str(numNewlyCreatedEdges)+';' #only correct for PartDesign, PartWB gives false counts
i = 1 # do not enumerate the following, count new Edges !
for edge in edges:
edgeKeys = self.calcEdgeKeys(edge, pl) # 2 keys for a linear edge, 1 key per circular edge
entryFound=False
for k in edgeKeys:
tmp = self.shapeDict.get(k,False)
if tmp != False:
entryFound = True
break
if not entryFound:
if self.isPartDesignDocument:
edgeName = edgeNamePrefix + str(i) + ';' + edgeNameSuffix
else:
edgeName = edgeNamePrefix + str(i) + ';'
i+=1
else:
edgeName = tmp # the old edge name...
for k in edgeKeys:
self.shapeDict[k] = edgeName
#
# populate face entries...
faces = shape.Faces
self.totalNumFaces = 0
numNewlyCreatedFaces = len(faces) - self.totalNumFaces
self.totalNumFaces = len(faces)
faceNamePrefix = 'F;' + objName + ';'
faceNameSuffix = str(numNewlyCreatedFaces)+';' #only correct for PartDesign, PartWB gives false counts
i = 1 # do not enumerate the following, count new Faces !
for face in faces:
faceKeys = self.calcFaceKeys(face, pl) # one key per vertex of a face
entryFound=False
# if one key matches, it is the old face name
for k in faceKeys:
tmp = self.shapeDict.get(k,False)
if tmp != False:
entryFound = True
break
if not entryFound:
if self.isPartDesignDocument:
faceName = faceNamePrefix + str(i) + ';' + faceNameSuffix
else:
faceName = faceNamePrefix + str(i) + ';'
i+=1
else:
faceName = tmp # the old face name...
for k in faceKeys:
self.shapeDict[k] = faceName
def processTopoData(self,objName,level=0):
"""
Recursive function which populates the
shapeDict with geometricKey/toponame entries
"""
level+=1
if not objName.startswith("Link"):
inList, outList = self.treeNodes[objName]
for ob in outList:
self.processTopoData(ob.Name,level)
if (
not objName.startswith("Body") and
objName not in self.doneObjects
):
self.populateShapeDict(objName)
def makePlacedShape(self,obj):
"""
Return a copy of obj.Shape with proper placement applied.
"""
tempShape = obj.Shape.copy()
plmGlobal = obj.Placement
try:
plmGlobal = obj.getGlobalPlacement();
except:
pass
tempShape.Placement = plmGlobal
return tempShape
def addedByPathWB(self,obName):
"""
Function detects, whether special object belongs to
a milling job of Path WB
It is looking for "Stock" and contents of Model-group
"""
ob = self.doc.getObject(obName)
if ob.Name.startswith('Stock'):
for o in ob.InList:
if o.Name.startswith('Job'):
return True
for o in ob.InList:
if o.Name.startswith('Model'):
for o1 in o.InList:
if o1.Name.startswith('Job'):
return True
return False
def isTopLevelInList(self,lst):
if len(lst) == 0: return True
for ob in lst:
if ob.isDerivedFrom('PartDesign::SubShapeBinder'): continue
if ob.isDerivedFrom('Part::SubShapeBinder'): continue
if ob.Name.startswith("Group"): continue
if ob.Name.startswith("ShapeBinder"): continue
if ob.Name.startswith("Clone"): continue
if ob.Name.startswith("Part__Mirroring"): continue
if ob.Name.startswith("mirror"): continue
if ob.hasExtension('App::GeoFeatureGroupExtension') and ob.Name.startswith("Part"): continue
else: return False
return True
def getTopLevelObjects(self, allowSketches=False):
#-------------------------------------------
# Create treenodes of the importable Objects with a shape
#-------------------------------------------
self.treeNodes = {}
shapeObs = a2plib.filterShapeObs(self.doc.Objects,allowSketches)
S = set(shapeObs)
for ob in S:
inList = a2plib.filterShapeObs(ob.InList,allowSketches)
outList = a2plib.filterShapeObs(ob.OutList,allowSketches)
self.treeNodes[ob.Name] = (
inList,
outList
)
#-------------------------------------------
# nodes with empty inList are top level shapes for sure
# (cloned objects could be missing)
#-------------------------------------------
self.topLevelShapes = []
for objName in self.treeNodes.keys():
inList,dummy = self.treeNodes[objName]
if self.isTopLevelInList(inList):
self.topLevelShapes.append(objName)
elif allowSketches==True and objName.startswith('Sketch'): # want to have all sketches
self.topLevelShapes.append(objName)
else:
#-------------------------------------------
# search for missing non top-level clone-basefeatures
# Maybe a clone as basefeature of a body..
#-------------------------------------------
numBodies = 0
numClones = 0
invalidObjects = False
if len(inList) % 2 == 0: # pairs of Clone/Bodies
for o in inList:
if o.Name.startswith('Clone'):
numClones += 1
elif o.Name.startswith('Body'):
numBodies += 1
else:
invalidObjects = True
break
if not invalidObjects:
if numBodies == numClones:
self.topLevelShapes.append(objName)
#-------------------------------------------
# search for missing non top-level objects,
# as they are referenced by fasteners WB objects
#-------------------------------------------
allObjectsAreFasteners = True
for o in inList:
if not a2plib.isFastenerObject(o):
allObjectsAreFasteners = False
break
if allObjectsAreFasteners == True:
self.topLevelShapes.append(objName)
#-------------------------------------------
# Got some shapes used by sections?
# collect them to a blacklist
# InLists of objects used by section are empty, therefore they
# are recognized falsely as topLevelShapes
#
# 2020-02-23: "Group" added to blackList
#-------------------------------------------
blackList = []
for ob in self.doc.Objects:
if ob.Name.startswith("Group"):
blackList.append(ob.Name)
elif ob.Name.startswith("Section"):
if hasattr(ob,"Base"):
if ob.Base is not None:
blackList.append(ob.Base.Name)
if hasattr(ob,"Tool"):
if ob.Tool is not None:
blackList.append(ob.Tool.Name)
#-------------------------------------------
# Got some shapes created by PathWB? filter out...
# also filter out invisible shapes...
# also filter out the blackList
#-------------------------------------------
tmp = []
for n in self.topLevelShapes:
if self.addedByPathWB(n): continue
if n in blackList: continue
#
if a2plib.doNotImportInvisibleShapes():
ob = self.doc.getObject(n)
if hasattr(ob,"ViewObject"):
if hasattr(ob.ViewObject,"Visibility"):
if ob.ViewObject.Visibility == False or not a2plib.isGlobalVisible(ob):
print(
translate("A2plus", "Import ignored invisible shape: '{}'").format(
ob.Name
)
)
continue
tmp.append(n)
self.topLevelShapes = tmp
#-------------------------------------------
# return complete topLevel document objects for external use
#-------------------------------------------
outObs = []
for objName in self.topLevelShapes:
outObs.append(self.doc.getObject(objName))
return outObs
def detectPartDesignDocument(self):
self.isPartDesignDocument = False
for ob in self.doc.Objects:
if ob.Name.startswith('Body'):
self.isPartDesignDocument = True
break
def getLinkedObjectRecursive(self,ob):
if ob.ViewObject.TypeId == "Gui::ViewProviderLinkPython": # a link is involved...
linkedObject = None
for p in ob.PropertiesList:
try:
linkedObject = getattr(ob,p).getLinkedObject()
if linkedObject is not None:
linkedObject = self.getLinkedObjectRecursive(linkedObject)
break
except:
pass
if linkedObject is not None:
return linkedObject
else:
return ob
else:
return ob
def createTopoNames(self, desiredShapeLabel = None):
"""
creates a combined shell of all toplevel objects and
assigns toponames to its geometry if toponaming is
enabled.
"""
if desiredShapeLabel is not None:
allowSketches = True
else:
allowSketches = False
self.detectPartDesignDocument()
self.getTopLevelObjects(allowSketches)
# filter topLevelShapes if there is a desiredShapeLabel
# means: extract only one desired shape out of whole file...
if desiredShapeLabel: #is not None
tmp = []
for objName in self.topLevelShapes:
o = self.doc.getObject(objName)
if o.Label == desiredShapeLabel:
tmp.append(o.Name)
self.topLevelShapes = tmp
#-------------------------------------------
# analyse the toplevel shapes
#-------------------------------------------
if a2plib.getUseTopoNaming():
for n in self.topLevelShapes:
self.totalNumVertexes = 0
self.totalNumEdges = 0
self.totalNumFaces = 0
self.processTopoData(n) # analyse each toplevel object...
#
#-------------------------------------------
# MUX the toplevel shapes
#-------------------------------------------
faces = []
faceColors = []
transparency = 0
shape_list = []
if len(self.topLevelShapes)==1 and self.topLevelShapes[0].startswith("Sketch"):
importingSketch = True
else:
importingSketch = False
if importingSketch == True:
# We are importing a sketch object
objName = self.topLevelShapes[0]
sketchOb = self.doc.getObject(objName)
solid = sketchOb.Shape
else:
# We are importing no sketch object
for objName in self.topLevelShapes:
ob = self.doc.getObject(objName)
tempShape = self.makePlacedShape(ob)
faces.extend(tempShape.Faces) #let python libs extend faces, much faster
#manage colors of faces
if ob.ViewObject.TypeId == "Gui::ViewProviderLinkPython": # a link is involved...
linkedObject = self.getLinkedObjectRecursive(ob)
needDiffuseExtension = ( len(linkedObject.ViewObject.DiffuseColor) < len(linkedObject.Shape.Faces) )
shapeCol = linkedObject.ViewObject.ShapeColor
diffuseCol = linkedObject.ViewObject.DiffuseColor
transparency = linkedObject.ViewObject.Transparency
shape_list.append(ob.Shape)
if needDiffuseExtension:
diffuseElement = a2plib.makeDiffuseElement(shapeCol,transparency)
for i in range(0,len(tempShape.Faces)):
faceColors.append(diffuseElement)
else:
count = len(ob.Shape.Faces)//len(linkedObject.Shape.Faces)
for c in range(0,count): # add colors to multiple representations of linkedObject
faceColors.extend(diffuseCol)
else: # no link is involved...
if hasattr(ob.ViewObject, "ShapeColor") and hasattr(ob.ViewObject,"DiffuseColor"):
needDiffuseExtension = ( len(ob.ViewObject.DiffuseColor) < len(ob.Shape.Faces) )
shapeCol = ob.ViewObject.ShapeColor
diffuseCol = ob.ViewObject.DiffuseColor
transparency = ob.ViewObject.Transparency
shape_list.append(ob.Shape)
if needDiffuseExtension:
diffuseElement = a2plib.makeDiffuseElement(shapeCol,transparency)
for i in range(0,len(tempShape.Faces)):
faceColors.append(diffuseElement)
else:
faceColors.extend(diffuseCol)
elif hasattr(ob.ViewObject, "ShapeColor"):
shapeCol = ob.ViewObject.ShapeColor
transparency = ob.Color[3]
shape_list.append(ob.Shape)
diffuseElement = a2plib.makeDiffuseElement(shapeCol,transparency)
for i in range(0,len(tempShape.Faces)):
faceColors.append(diffuseElement)
else:
shapeCol = ob.Color
transparency = ob.Color[3]
shape_list.append(ob.Shape)
diffuseElement = a2plib.makeDiffuseElement(shapeCol,transparency)
for i in range(0,len(tempShape.Faces)):
faceColors.append(diffuseElement)
shell = Part.makeShell(faces)
try:
if a2plib.getUseSolidUnion():
if len(shape_list) > 1:
shape_base=shape_list[0]
shapes=shape_list[1:]
solid = shape_base.fuse(shapes)
else: #one shape only
solid = Part.Solid(shape_list[0])
else:
solid = Part.Solid(shell) # fails with missing faces if shell contains spheres
if len(shell.Faces) != len(solid.Faces):
solid = shell # fall back to shell if faces are missing
except:
# keeping a shell if solid is failing
FreeCAD.Console.PrintWarning(translate("A2plus", "Union of Shapes FAILED") + "\n")
solid = shell
#-------------------------------------------
# if toponaming is used, assign toponames to
# shells geometry
#-------------------------------------------
muxInfo = []
if a2plib.getUseTopoNaming():
#-------------------------------------------
# map vertexnames to the MUX
#-------------------------------------------
muxInfo.append("[VERTEXES]")
for i,v in enumerate(solid.Vertexes):
k = self.calcVertexKey(v)
defaultVal = "V;NONAME;{};".format(i)
name = self.shapeDict.get(k,defaultVal)
muxInfo.append(name)
#-------------------------------------------
# map edgenames to the MUX
#-------------------------------------------
muxInfo.append("[EDGES]")
pl = FreeCAD.Placement()
for i,edge in enumerate(solid.Edges):
keys = self.calcEdgeKeys(edge, pl)
defaultVal = "E;NONAME;{};".format(i)
name = self.shapeDict.get(keys[0],defaultVal)
muxInfo.append(name)
#-------------------------------------------
# map facenames to the MUX
#-------------------------------------------
muxInfo.append("[FACES]")
pl = FreeCAD.Placement()
for i,face in enumerate(solid.Faces):
keys = self.calcFaceKeys(face, pl)
defaultVal = "F;NONAME;{};".format(i)
name = self.shapeDict.get(keys[0],defaultVal)
muxInfo.append(name)
return muxInfo, solid, faceColors, transparency