Skip to content

Commit 8fd58cf

Browse files
committed
Removed commented code
1 parent 80c18f4 commit 8fd58cf

File tree

1 file changed

+0
-262
lines changed

1 file changed

+0
-262
lines changed

assembly_mesh_plugin/plugin.py

Lines changed: 0 additions & 262 deletions
Original file line numberDiff line numberDiff line change
@@ -233,158 +233,6 @@ def get_tagged_gmsh(self):
233233

234234
gmsh = get_gmsh(self, imprint=False)
235235

236-
# gmsh.initialize()
237-
# gmsh.option.setNumber("General.Terminal", 0)
238-
# gmsh.model.add("assembly")
239-
240-
# # The mesh volume and surface ids should line up with the order of solids and faces in the assembly
241-
# vol_id = 1
242-
# surface_id = 1
243-
244-
# # Tracks multi-surface physical groups
245-
# multi_material_groups = {}
246-
# surface_groups = {}
247-
248-
# # Holds the collection of individual faces that are tagged
249-
# tagged_faces = {}
250-
251-
# for obj, name, loc, _ in self:
252-
# # CadQuery assembly code prepends a UUID to names sometimes that we do not need
253-
# short_name = name.split("/")[-1]
254-
255-
# # Separate tagged faces by solid since they might be duplicates
256-
# tagged_faces[short_name] = {}
257-
258-
# # Extract the tagged faces and make sure they are in the appropriate relative locations
259-
# # in the assembly. Tags can hold multiple faces, so we have to extract all of them.
260-
# for tag, wp in self.objects[short_name].obj.ctx.tags.items():
261-
# for face in wp.faces().all():
262-
# # Check to see if we have found this tag before (multi-material tag)
263-
# if tag in tagged_faces[short_name]:
264-
# tagged_faces[short_name][tag].append(face.val())
265-
# else:
266-
# tagged_faces[short_name][tag] = [face.val()]
267-
268-
# # Extract the tagged faces that have been added by the addSubshape method of cq.Assembly
269-
# if self._subshape_names:
270-
# for subshape, subshape_tag in self._subshape_names.items():
271-
# if subshape_tag in tagged_faces[short_name]:
272-
# # Check to see if this is a duplicate
273-
# if subshape in tagged_faces[short_name][subshape_tag]:
274-
# print(
275-
# f"WARNING: Duplicate subshape found for tag {subshape_tag}."
276-
# )
277-
278-
# tagged_faces[short_name][subshape_tag].append(subshape)
279-
# else:
280-
# tagged_faces[short_name][subshape_tag] = [subshape]
281-
282-
# # Extract the tagged faces that have been added by the addSubshape method of cq.Assembly
283-
# if self._subshape_layers:
284-
# for subshape, subshape_tag in self._subshape_layers.items():
285-
# if subshape_tag in tagged_faces[short_name]:
286-
# # Check to see if this is a duplicate
287-
# if subshape in tagged_faces[short_name][subshape_tag]:
288-
# print(
289-
# f"WARNING: Duplicate subshape found for tag {subshape_tag}."
290-
# )
291-
292-
# tagged_faces[short_name][subshape_tag].append(subshape)
293-
# else:
294-
# tagged_faces[short_name][subshape_tag] = [subshape]
295-
296-
# # All the solids in the current part should be added to the mesh
297-
# for s in obj.moved(loc).Solids():
298-
# # Add the current solid to the mesh
299-
# with tempfile.NamedTemporaryFile(suffix=".brep") as temp_file:
300-
# s.exportBrep(temp_file.name)
301-
# ps = gmsh.model.occ.importShapes(temp_file.name)
302-
303-
# # TODO find a way to check if the OCC in gmsh is compatible with the
304-
# # OCC in CadQuery. When pip installed they tend to be incompatible
305-
# # and this importShapesNativePointer will seg fault. When both
306-
# # packages are conda installed the importShapesNativePointer works.
307-
# # Work around that works in both cases is to write a brep and import
308-
# # it into gmsh. This is slower but works in all cases.
309-
# # gmsh.model.occ.importShapesNativePointer(s.wrapped._address())
310-
311-
# gmsh.model.occ.synchronize()
312-
313-
# # Technically, importShapes could import multiple entities/dimensions, so filter those
314-
# vol_ents = []
315-
# for p in ps:
316-
# if p[0] == 3:
317-
# vol_ents.append(p[1])
318-
319-
# # Set the physical name to be the part name in the assembly for all the solids
320-
# ps2 = gmsh.model.addPhysicalGroup(3, vol_ents)
321-
# gmsh.model.setPhysicalName(3, ps2, f"{name.split('/')[-1]}")
322-
323-
# # All the faces in the current part should be added to the mesh
324-
# for face in s.Faces():
325-
# # Face name can be based on a tag, or just be a generic name
326-
# found_tag = False
327-
328-
# #
329-
# # Handle tagged faces
330-
# # Step through the faces in the solid and check them against all the tagged faces
331-
# #
332-
# for tag, tag_faces in tagged_faces[short_name].items():
333-
# for tag_face in tag_faces:
334-
# # Move the face to the correct location in the assembly
335-
# tag_face = tag_face.moved(loc)
336-
337-
# # If OpenCASCADE says the faces are the same, we have a match for the tag
338-
# if TopoDS_Shape.IsEqual(face.wrapped, tag_face.wrapped):
339-
# # Make sure a generic surface is not added for this face
340-
# found_tag = True
341-
342-
# # Find out if this is a multi-material tag
343-
# if tag.startswith("~"):
344-
# # Set the surface name to be the name of the tag without the ~
345-
# group_name = tag.replace("~", "").split("-")[0]
346-
347-
# # Add this face to the multi-material group
348-
# if group_name in multi_material_groups:
349-
# multi_material_groups[group_name].append(surface_id)
350-
# else:
351-
# multi_material_groups[group_name] = [surface_id]
352-
# else:
353-
# # We want to track all surfaces that might be in a tag group
354-
# cur_tag_name = f"{short_name}_{tag}"
355-
# if cur_tag_name in surface_groups:
356-
# print(
357-
# "Append: ", cur_tag_name, short_name, surface_id
358-
# )
359-
# surface_groups[cur_tag_name].append(surface_id)
360-
# else:
361-
# print("New: ", cur_tag_name, short_name, surface_id)
362-
# surface_groups[cur_tag_name] = [surface_id]
363-
364-
# # If no tag was found, set a physical group generic name
365-
# if not found_tag:
366-
# face_name = f"{short_name}_surface_{surface_id}"
367-
# ps = gmsh.model.addPhysicalGroup(2, [surface_id])
368-
# gmsh.model.setPhysicalName(2, ps, f"{face_name}")
369-
370-
# # Move to the next surface id
371-
# surface_id += 1
372-
373-
# # Move to the next volume id
374-
# vol_id += 1
375-
376-
# # Handle tagged surface groups
377-
# for t_name, surf_group in surface_groups.items():
378-
# ps = gmsh.model.addPhysicalGroup(2, surf_group)
379-
# gmsh.model.setPhysicalName(2, ps, t_name)
380-
381-
# # Handle multi-material tags
382-
# for group_name, mm_group in multi_material_groups.items():
383-
# ps = gmsh.model.addPhysicalGroup(2, mm_group)
384-
# gmsh.model.setPhysicalName(2, ps, f"{group_name}")
385-
386-
# gmsh.model.occ.synchronize()
387-
388236
return gmsh
389237

390238

@@ -412,116 +260,6 @@ def get_imprinted_gmsh(self):
412260

413261
gmsh = get_gmsh(self, imprint=True)
414262

415-
# Initialize gmsh and create a new model
416-
# gmsh.initialize()
417-
# gmsh.option.setNumber("General.Terminal", 0)
418-
# gmsh.model.add("assembly")
419-
420-
# # The mesh volume and surface ids should line up with the order of solids and faces in the assembly
421-
# vol_id = 1
422-
# surface_id = 1
423-
424-
# # Tracks multi-surface physical groups
425-
# multi_material_groups = {}
426-
# surface_groups = {}
427-
428-
# # Tracks the solids with tagged faces
429-
# tagged_faces = {}
430-
# solids_with_tagged_faces = {}
431-
432-
# # Imprint the assembly
433-
# imprinted_assembly, imprinted_solids_with_orginal_ids = (
434-
# cq.occ_impl.assembly.imprint(self)
435-
# )
436-
437-
# for solid, id in imprinted_solids_with_orginal_ids.items():
438-
# # Add the current solid to the mesh
439-
# # Work-around for a segfault with in-memory passing of OCCT objects
440-
# with tempfile.NamedTemporaryFile(suffix=".brep") as temp_file:
441-
# solid.exportBrep(temp_file.name)
442-
# ps = gmsh.model.occ.importShapes(temp_file.name)
443-
# gmsh.model.occ.synchronize()
444-
445-
# # Technically, importShapes could import multiple entities/dimensions, so filter those
446-
# vol_ents = []
447-
# for p in ps:
448-
# if p[0] == 3:
449-
# vol_ents.append(p[1])
450-
451-
# # Set the physical name to be the part name in the assembly for all the solids
452-
# ps2 = gmsh.model.addPhysicalGroup(3, vol_ents)
453-
# gmsh.model.setPhysicalName(3, ps2, f"{id[0].split('/')[-1]}")
454-
455-
# # Get the original assembly part
456-
# object_name = id[0].split("/")[-1]
457-
# assembly_part = self.objects[object_name]
458-
459-
# # Collect any tags from the part
460-
# for tag, wp in assembly_part.obj.ctx.tags.items():
461-
# tagged_face = wp.faces().all()[0].val()
462-
# for face in wp.faces().all():
463-
# tagged_faces[face.val()] = tag
464-
465-
# # Iterate over the faces of the assembly part
466-
# for face in assembly_part.obj.faces():
467-
# for tagged_face, tag in tagged_faces.items():
468-
# if TopoDS_Shape.IsEqual(face.wrapped, tagged_face.wrapped):
469-
# print(f"{vol_id}_{surface_id}", tag)
470-
# solids_with_tagged_faces[f"{vol_id}_{surface_id}"] = (
471-
# object_name,
472-
# tag,
473-
# )
474-
475-
# surface_id += 1
476-
# vol_id += 1
477-
478-
# # Reset the volume and surface IDs
479-
# vol_id = 1
480-
# surface_id = 1
481-
482-
# # Step through the imprinted assembly/shape and check for tagged faces
483-
# for solid in imprinted_assembly.solids():
484-
# for face in solid.faces().Faces():
485-
# # Check to see if this face has been tagged
486-
# if f"{vol_id}_{surface_id}" in solids_with_tagged_faces.keys():
487-
# short_name = solids_with_tagged_faces[f"{vol_id}_{surface_id}"][0]
488-
# tag = solids_with_tagged_faces[f"{vol_id}_{surface_id}"][1]
489-
490-
# # Find out if this is a multi-material tag
491-
# if tag.startswith("~"):
492-
# # Set the surface name to be the name of the tag without the ~
493-
# group_name = tag.replace("~", "").split("-")[0]
494-
495-
# # Add this face to the multi-material group
496-
# if group_name in multi_material_groups:
497-
# multi_material_groups[group_name].append(surface_id)
498-
# else:
499-
# multi_material_groups[group_name] = [surface_id]
500-
# else:
501-
# # We want to track all surfaces that might be in a tag group
502-
# cur_tag_name = f"{short_name}_{tag}"
503-
# if cur_tag_name in surface_groups:
504-
# print("Append: ", cur_tag_name, short_name, surface_id)
505-
# surface_groups[cur_tag_name].append(surface_id)
506-
# else:
507-
# print("New: ", cur_tag_name, short_name, surface_id)
508-
# surface_groups[cur_tag_name] = [surface_id]
509-
510-
# surface_id += 1
511-
# vol_id += 1
512-
513-
# # Handle tagged surface groups
514-
# for t_name, surf_group in surface_groups.items():
515-
# ps = gmsh.model.addPhysicalGroup(2, surf_group)
516-
# gmsh.model.setPhysicalName(2, ps, t_name)
517-
518-
# # Handle multi-material tags
519-
# for group_name, mm_group in multi_material_groups.items():
520-
# ps = gmsh.model.addPhysicalGroup(2, mm_group)
521-
# gmsh.model.setPhysicalName(2, ps, f"{group_name}")
522-
523-
# gmsh.model.occ.synchronize()
524-
525263
return gmsh
526264

527265

0 commit comments

Comments
 (0)