FEM: geom tools, move get element
This commit is contained in:
@@ -39,7 +39,7 @@ import FreeCAD
|
||||
import FreeCADGui
|
||||
import FreeCADGui as Gui
|
||||
|
||||
from femmesh import meshtools
|
||||
from femtools import geomtools
|
||||
|
||||
|
||||
class _Selector(QtGui.QWidget):
|
||||
@@ -375,7 +375,7 @@ class GeometryElementsSelection(QtGui.QWidget):
|
||||
# since only Subelements can be selected
|
||||
# we're going to select all Faces of said Solids
|
||||
# the method getElement(element)doesn't return Solid elements
|
||||
solid = meshtools.get_element(ref[0], ref[1])
|
||||
solid = geomtools.get_element(ref[0], ref[1])
|
||||
if not solid:
|
||||
return
|
||||
faces = []
|
||||
@@ -553,7 +553,7 @@ class GeometryElementsSelection(QtGui.QWidget):
|
||||
def has_equal_references_shape_types(self, ref_shty=""):
|
||||
for ref in self.references:
|
||||
# the method getElement(element) does not return Solid elements
|
||||
r = meshtools.get_element(ref[0], ref[1])
|
||||
r = geomtools.get_element(ref[0], ref[1])
|
||||
if not r:
|
||||
FreeCAD.Console.PrintError(
|
||||
"Problem in retrieving element: {} \n".format(ref[1])
|
||||
|
||||
@@ -414,7 +414,7 @@ class GmshTools():
|
||||
# Shape to mesh and use the found element as elems
|
||||
# the method getElement(element)
|
||||
# does not return Solid elements
|
||||
ele_shape = meshtools.get_element(sub[0], elems)
|
||||
ele_shape = geomtools.get_element(sub[0], elems)
|
||||
found_element = geomtools.find_element_in_shape(
|
||||
self.part_obj.Shape, ele_shape
|
||||
)
|
||||
@@ -451,7 +451,7 @@ class GmshTools():
|
||||
)
|
||||
for eleml in self.ele_length_map:
|
||||
# the method getElement(element) does not return Solid elements
|
||||
ele_shape = meshtools.get_element(self.part_obj, eleml)
|
||||
ele_shape = geomtools.get_element(self.part_obj, eleml)
|
||||
ele_vertexes = geomtools.get_vertexes_by_element(self.part_obj.Shape, ele_shape)
|
||||
self.ele_node_map[eleml] = ele_vertexes
|
||||
Console.PrintMessage(" {}\n".format(self.ele_length_map))
|
||||
@@ -502,7 +502,7 @@ class GmshTools():
|
||||
# we try to find the element it in the Shape to mesh
|
||||
# and use the found element as elems
|
||||
# the method getElement(element) does not return Solid elements
|
||||
ele_shape = meshtools.get_element(sub[0], elems)
|
||||
ele_shape = geomtools.get_element(sub[0], elems)
|
||||
found_element = geomtools.find_element_in_shape(
|
||||
self.part_obj.Shape,
|
||||
ele_shape
|
||||
|
||||
@@ -115,7 +115,7 @@ def get_femnodes_by_refshape(
|
||||
nodes = []
|
||||
for refelement in ref[1]:
|
||||
# the following method getElement(element) does not return Solid elements
|
||||
r = get_element(ref[0], refelement)
|
||||
r = geomtools.get_element(ref[0], refelement)
|
||||
FreeCAD.Console.PrintMessage(
|
||||
" "
|
||||
"ReferenceShape ... Type: {0}, "
|
||||
@@ -1936,7 +1936,7 @@ def get_reference_group_elements(
|
||||
# FreeCAD.Console.PrintMessage("{}\n".format(childs))
|
||||
for child in childs:
|
||||
# the method getElement(element) does not return Solid elements
|
||||
ref_shape = get_element(parent, child)
|
||||
ref_shape = geomtools.get_element(parent, child)
|
||||
if not stype:
|
||||
stype = ref_shape.ShapeType
|
||||
elif stype != ref_shape.ShapeType:
|
||||
@@ -2058,24 +2058,6 @@ def get_anlysis_empty_references_group_elements(
|
||||
return group_elements
|
||||
|
||||
|
||||
# ************************************************************************************************
|
||||
def get_element(
|
||||
part,
|
||||
element
|
||||
):
|
||||
if element.startswith("Solid"):
|
||||
index = int(element.lstrip("Solid")) - 1
|
||||
if index >= len(part.Shape.Solids):
|
||||
FreeCAD.Console.PrintError(
|
||||
"Index out of range. This Solid does not exist in the Shape!\n"
|
||||
)
|
||||
return None
|
||||
else:
|
||||
return part.Shape.Solids[index] # Solid
|
||||
else:
|
||||
return part.Shape.getElement(element) # Face, Edge, Vertex
|
||||
|
||||
|
||||
# ************************************************************************************************
|
||||
def femelements_count_ok(
|
||||
len_femelement_table,
|
||||
|
||||
@@ -309,10 +309,10 @@ def get_refshape_type(fem_doc_object):
|
||||
:note:
|
||||
Undefined behaviour if constraint contains no references (empty list).
|
||||
"""
|
||||
import femmesh.meshtools as FemMeshTools
|
||||
from femtools.geomtools import get_element
|
||||
if hasattr(fem_doc_object, "References") and fem_doc_object.References:
|
||||
first_ref_obj = fem_doc_object.References[0]
|
||||
first_ref_shape = FemMeshTools.get_element(first_ref_obj[0], first_ref_obj[1][0])
|
||||
first_ref_shape = get_element(first_ref_obj[0], first_ref_obj[1][0])
|
||||
st = first_ref_shape.ShapeType
|
||||
FreeCAD.Console.PrintMessage(
|
||||
"References: {} in {}, {}\n". format(st, fem_doc_object.Name, fem_doc_object.Label)
|
||||
|
||||
@@ -173,6 +173,24 @@ def is_same_geometry(
|
||||
return False
|
||||
|
||||
|
||||
# ************************************************************************************************
|
||||
def get_element(
|
||||
part,
|
||||
element
|
||||
):
|
||||
if element.startswith("Solid"):
|
||||
index = int(element.lstrip("Solid")) - 1
|
||||
if index >= len(part.Shape.Solids):
|
||||
FreeCAD.Console.PrintError(
|
||||
"Index out of range. This Solid does not exist in the Shape!\n"
|
||||
)
|
||||
return None
|
||||
else:
|
||||
return part.Shape.Solids[index] # Solid
|
||||
else:
|
||||
return part.Shape.getElement(element) # Face, Edge, Vertex
|
||||
|
||||
|
||||
# ************************************************************************************************
|
||||
def get_rectangular_coords(
|
||||
obj
|
||||
|
||||
Reference in New Issue
Block a user