Fix: faces after extrusion had shared object
This commit is contained in:
parent
f0ce49a0d8
commit
e977c39496
@ -29,41 +29,13 @@ def pos(self) -> numpy.array:
|
||||
# ISSUE: netgen.occ.Face.Extrude: the opposite face has the same name and normal vector as an initial face.
|
||||
def reconstruct(shape):
|
||||
"""Reconstruct shape with new objects.
|
||||
|
||||
Warning: not works with curved edges.
|
||||
"""
|
||||
|
||||
facesNew = []
|
||||
faces = []
|
||||
|
||||
for face in shape.faces:
|
||||
vs = numpy.array([ v.p.pos() for v in face.vertices ])
|
||||
mass = []
|
||||
|
||||
for nroll in range(len(vs)):
|
||||
vs_roll = numpy.roll(vs, nroll, axis = 0)
|
||||
face_roll = occ.Face(occ.Wire([ occ.Segment(occ.Pnt(*vs_roll[nv]), occ.Pnt(*vs_roll[nv + 1])) for nv in range(0, len(vs_roll), 2) ]))
|
||||
mass.append(face_roll.mass)
|
||||
|
||||
max_roll = mass.index(max(mass))
|
||||
vs_roll = numpy.roll(vs, max_roll, axis = 0)
|
||||
facesNew.append(occ.Face(occ.Wire([ occ.Segment(occ.Pnt(*vs_roll[nv]), occ.Pnt(*vs_roll[nv + 1])) for nv in range(0, len(vs_roll), 2) ])))
|
||||
|
||||
shapeNew = occ.Solid(occ.Compound.ToShell(facesNew))
|
||||
|
||||
return shapeNew
|
||||
|
||||
#facesNew = []
|
||||
|
||||
#for face in shape.faces:
|
||||
# edgesNew = []
|
||||
# for edge in face.edges:
|
||||
# v = edge.vertices
|
||||
# edgesNew.append(occ.Segment(v[0].p, v[1].p))
|
||||
|
||||
# faceNew = occ.Face(occ.Wire(edgesNew))
|
||||
# faceNew.name = face.name
|
||||
# facesNew.append(faceNew)
|
||||
|
||||
#return numpy.array(facesNew).sum()
|
||||
faceNew = occ.Face(face.wires[0])
|
||||
faceNew.name = face.name
|
||||
faces.append(faceNew)
|
||||
|
||||
return occ.Solid(faces)
|
||||
|
||||
|
@ -132,7 +132,7 @@ class Simple(Periodic):
|
||||
|
||||
vecFlow = self.normal(inletface)
|
||||
self.cell = inletface.Extrude(extr * Vec(*vecFlow))
|
||||
#self.cell = reconstruct(self.cell)
|
||||
self.cell = reconstruct(self.cell)
|
||||
|
||||
# Boundaries
|
||||
symetryId = 0
|
||||
|
Loading…
Reference in New Issue
Block a user