BIM: rename obsolete Mesh property to HiRes (#27783)
* BIM: rename obsolete Mesh property to HiRes
* BIM: remove unused createMeshView function
* BIM: remove all remaining references of Mesh
(cherry picked from commit 99d142af38)
This commit is contained in:
+1
-1
@@ -393,7 +393,7 @@ def makeEquipment(baseobj=None, placement=None, name=None):
|
||||
# Initialize all relevant properties
|
||||
if baseobj:
|
||||
if baseobj.isDerivedFrom("Mesh::Feature"):
|
||||
equipment.Mesh = baseobj
|
||||
equipment.HiRes = baseobj
|
||||
else:
|
||||
equipment.Base = baseobj
|
||||
if placement:
|
||||
|
||||
@@ -848,7 +848,7 @@ class Component(ArchIFC.IfcProduct):
|
||||
if Draft.getType(o) == "Roof":
|
||||
continue
|
||||
o.ViewObject.hide()
|
||||
elif prop in ["Mesh"]:
|
||||
elif prop == "HiRes":
|
||||
if hasattr(obj, prop):
|
||||
o = getattr(obj, prop)
|
||||
if o:
|
||||
@@ -1863,7 +1863,7 @@ class ViewProviderComponent:
|
||||
if hasattr(self.Object, link):
|
||||
objlink = getattr(self.Object, link)
|
||||
c.extend(objlink)
|
||||
for link in ["Tool", "Subvolume", "Mesh", "HiRes"]:
|
||||
for link in ["Tool", "Subvolume", "HiRes"]:
|
||||
if hasattr(self.Object, link):
|
||||
objlink = getattr(self.Object, link)
|
||||
if objlink:
|
||||
|
||||
@@ -54,98 +54,6 @@ else:
|
||||
# \endcond
|
||||
|
||||
|
||||
def createMeshView(obj, direction=FreeCAD.Vector(0, 0, -1), outeronly=False, largestonly=False):
|
||||
"""createMeshView(obj,[direction,outeronly,largestonly]): creates a flat shape that is the
|
||||
projection of the given mesh object in the given direction (default = on the XY plane). If
|
||||
outeronly is True, only the outer contour is taken into consideration, discarding the inner
|
||||
holes. If largestonly is True, only the largest segment of the given mesh will be used."""
|
||||
|
||||
import math
|
||||
import DraftGeomUtils
|
||||
import Mesh
|
||||
import Part
|
||||
|
||||
if not obj.isDerivedFrom("Mesh::Feature"):
|
||||
return
|
||||
mesh = obj.Mesh
|
||||
|
||||
# 1. Flattening the mesh
|
||||
proj = []
|
||||
for f in mesh.Facets:
|
||||
nf = []
|
||||
for v in f.Points:
|
||||
v = FreeCAD.Vector(v)
|
||||
a = v.negative().getAngle(direction)
|
||||
l = math.cos(a) * v.Length
|
||||
p = v.add(FreeCAD.Vector(direction).multiply(l))
|
||||
p = DraftVecUtils.rounded(p)
|
||||
nf.append(p)
|
||||
proj.append(nf)
|
||||
flatmesh = Mesh.Mesh(proj)
|
||||
|
||||
# 2. Removing wrong faces
|
||||
facets = []
|
||||
for f in flatmesh.Facets:
|
||||
if f.Normal.getAngle(direction) < math.pi:
|
||||
facets.append(f)
|
||||
cleanmesh = Mesh.Mesh(facets)
|
||||
|
||||
# Mesh.show(cleanmesh)
|
||||
|
||||
# 3. Getting the bigger mesh from the planar segments
|
||||
if largestonly:
|
||||
c = cleanmesh.getSeparateComponents()
|
||||
# print(c)
|
||||
cleanmesh = c[0]
|
||||
segs = cleanmesh.getPlanarSegments(1)
|
||||
meshes = []
|
||||
for s in segs:
|
||||
f = [cleanmesh.Facets[i] for i in s]
|
||||
meshes.append(Mesh.Mesh(f))
|
||||
a = 0
|
||||
for m in meshes:
|
||||
if m.Area > a:
|
||||
boundarymesh = m
|
||||
a = m.Area
|
||||
# Mesh.show(boundarymesh)
|
||||
cleanmesh = boundarymesh
|
||||
|
||||
# 4. Creating a Part and getting the contour
|
||||
|
||||
shape = None
|
||||
for f in cleanmesh.Facets:
|
||||
p = Part.makePolygon(f.Points + [f.Points[0]])
|
||||
# print(p,len(p.Vertexes),p.isClosed())
|
||||
try:
|
||||
p = Part.Face(p)
|
||||
if shape:
|
||||
shape = shape.fuse(p)
|
||||
else:
|
||||
shape = p
|
||||
except Part.OCCError:
|
||||
pass
|
||||
shape = shape.removeSplitter()
|
||||
|
||||
# 5. Extracting the largest wire
|
||||
|
||||
if outeronly:
|
||||
count = 0
|
||||
largest = None
|
||||
for w in shape.Wires:
|
||||
if len(w.Vertexes) > count:
|
||||
count = len(w.Vertexes)
|
||||
largest = w
|
||||
if largest:
|
||||
try:
|
||||
f = Part.Face(w)
|
||||
except Part.OCCError:
|
||||
print("Unable to produce a face from the outer wire.")
|
||||
else:
|
||||
shape = f
|
||||
|
||||
return shape
|
||||
|
||||
|
||||
class _Equipment(ArchComponent.Component):
|
||||
"The Equipment object"
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ class Arch_Equipment:
|
||||
base = "FreeCAD.ActiveDocument." + base
|
||||
FreeCADGui.doCommand("obj = Arch.makeEquipment(" + base + ")")
|
||||
if mesh:
|
||||
FreeCADGui.doCommand("obj.Mesh = FreeCAD.ActiveDocument." + mesh)
|
||||
FreeCADGui.doCommand("obj.HiRes = FreeCAD.ActiveDocument." + mesh)
|
||||
FreeCADGui.addModule("Draft")
|
||||
FreeCADGui.doCommand("Draft.autogroup(obj)")
|
||||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
|
||||
Reference in New Issue
Block a user