pyleecan.Classes.Segment module¶
Method code available at https://github.com/Eomys/pyleecan/tree/master/pyleecan/Methods/Geometry/Segment
- class Segment(begin=0, end=0, prop_dict=None, init_dict=None, init_str=None)[source]¶
Bases:
Line
A segment between two points
- VERSION = 1¶
- check()¶
assert that the line is correct (begin != end)
- Parameters:
self (Segment) – A Segment object
- Return type:
None
- Raises:
PointSegmentError – The beginning point and the ending point of an Segment can’t be the same
- comp_distance(Z)¶
Compute the distance of a point to the Segment
- Parameters:
self (Segment) – A Segment object
Z (complex) – Complex coordinate of the point
- Returns:
D – distance of a point to the Segment
- Return type:
float
- comp_length()¶
Compute the length of the line
- Parameters:
self (Segment) – A Segment object
- Returns:
length – lenght of the line [m]
- Return type:
float
- Raises:
PointSegmentError – Call Segment.check()
- discretize(nb_point=1)¶
Return the discretize version of the Segment. Begin and end are always returned
- Parameters:
self (Segment) – A Segment object
nb_point (int) – Number of points to add to discretize the line (Default value = LINE_NPOINT_D)
- Returns:
list_point – List of complex coordinate of the points
- Return type:
list
- Raises:
NbPointSegmentDError – nb_point must be an integer >=
- draw_FEMM(femm, nodeprop=None, propname=None, element_size=None, automesh=None, hide=False, group=None, is_draw=True)¶
< Draw the segment in FEMM and assign the property
- Parameters:
femm (FEMMHandler) – client to send command to a FEMM instance
nodeprop – Nodal property (Default value = None)
propname – Boundary property ’propname’ (Default value = None)
element_size – Local element size along segment no greater than element_size (Default value = None)
automesh – 0 = mesher defers to the element constraint defined by element_size, 1 = mesher automatically chooses mesh size along the selected segments (Default value = None)
hide – 0 = not hidden in post-processor, 1 == hidden in post processorc (Default value = False)
group – group the segment belongs (Default value = None)
is_draw (bool) – 1 to draw the list of surfaces given
- Return type:
None
- get_begin()¶
Return the begin point of the segment
- Parameters:
self (Segment) – A Segment object
- Returns:
begin – Begin point of the Segment
- Return type:
complex
- get_end()¶
Return the end point of the segment
- Parameters:
self (Segment) – A Segment object
- Returns:
end – End point of the Segment
- Return type:
complex
- get_middle()¶
Return the point at the middle of the Segment
- Parameters:
self (Segment) – A Segment object
- Returns:
Zmid – Complex coordinates of the middle of the Segment
- Return type:
complex
- intersect_line(Z1, Z2)¶
Return a list (0, 1 or 2 complex) of coordinates of the intersection of the segment with a line defined by two complex
- Parameters:
self (Segment) – A Segment object
- Returns:
Z_list – Complex coordinates of the intersection (if any, return [begin, end] if the segment is part of the line)
- Return type:
list
- is_on_line(Z)¶
Check is a point defined by its complex coordinate is on the segment
- Parameters:
self (Segment) – A Segment object
Z (complex) – Complex coordinate of the point
- Returns:
is_on_line – True if the point is on the segment
- Return type:
bool
- plot(fig=None, ax=None, is_arrow=False, linestyle='solid', linewidth=1, color='black', label=None, offset_label=0, fontsize=12)¶
Plot the segment
- Parameters:
self (Segment) – A Segment object
fig (Matplotlib.figure.Figure) – existing figure to use if None create a new one
ax (Matplotlib.axes.Axes object) – Axis on which to plot the data
is_arrow (bool) – True to draw a double headed arrow instead of a line
linestyle (str) – Line of the line (solid, dotted…)
linewidth (int) – Line Width
color (str) – Color of the line
label (str) – To add a label at the middle of the line
offset_label (complex) – Complex value to shift the label from the middle
fontsize (int) – Size of the font for the label (if any)
- Returns:
fig (Matplotlib.figure.Figure) – Figure containing the plot
ax (Matplotlib.axes.Axes object) – Axis containing the plot
- reverse()¶
Reverse the begin and end point of the Line
- Parameters:
self (Segment) – An Segment object
- rotate(angle)¶
Rotation of the Segment of angle
- Parameters:
self (Segment) – An Segment Object
angle (float) – the angle of rotation [rad]
- Return type:
None
- scale(scale_factor)¶
Scale the coordinates of the begin/end
- Parameters:
self (Segment) – A Segment Object
scale_factor (float) – the Scale factor [-]
- Return type:
None
- split_half(is_begin=True)¶
Cut the line in half (modify the object)
- Parameters:
self (Segment) – An Segment object
is_begin (bool) – True to keep the part begin=>middle, False for the part middle=>end
- split_line(Z1, Z2, is_join=False, prop_dict_join=None)¶
Cut the Segment according to a line defined by two complex “Above” is in the coordinate system with Z1 in 0 and Z2 on the X>0 axis
- Parameters:
self (Segment) – An Segment object
Z1 (complex) – First point of the cutting Line
Z2 (complex) – Second point of the cutting Line
is_join (bool) – True to join the split_list with Segment if there is more that one remaining parts
prop_dict_join (dict) – Property dict to set on the join line
- Returns:
top_split_list, bot_split_list – Both part of the Segment (1 or 2 segment depending on cutting point)
- Return type:
- translate(Zt)¶
Translate the Segment object
- Parameters:
self (Segment) – An Segment object
Zt (complex) – Complex value for translation
- Return type:
None
- split_point(Z1, is_begin=True)¶
Cut the Segment according to a point on the segment
- Parameters:
self (Segment) – An Segment object
Z1 (complex) – Cutting point on the line
is_begin (bool) – True to keep the part begin=>Z1, False for the part Z1=>end
- intersect_obj(other, is_on_line=True)¶
Find the intersection points between this line and another line object
- is_arc()¶
Check if the line is an Arc
- Parameters:
self (Segment) – A Segment object
- Returns:
is_arc – False for Segment
- Return type:
bool
- save(save_path='', is_folder=False, type_handle_old=2, type_compression=0)¶
Save the object to the save_path
- Parameters:
self – A pyleecan object
save_path (str) – path to the folder to save the object
is_folder (bool) – to split the object in different files: separate simulation machine and materials (json only)
type_handle_old (int) – How to handle old file in folder mode (0:Nothing, 1:Delete, 2:Move to “Backup” folder)
type_compression (int) – Available only for json, 0: no compression, 1: gzip
- get_logger()¶
Get the object logger or its parent’s one
- Parameters:
obj – A pyleecan object
- Returns:
logger – Pyleecan object dedicated logger
- Return type:
logging.Logger
- compare(other, name='self', ignore_list=None, is_add_value=False)[source]¶
Compare two objects and return list of differences
- as_dict(type_handle_ndarray=0, keep_function=False, **kwargs)[source]¶
Convert this object in a json serializable dict (can be use in __init__). type_handle_ndarray: int
How to handle ndarray (0: tolist, 1: copy, 2: nothing)
- keep_functionbool
True to keep the function object, else return str
Optional keyword input parameter is for internal use only and may prevent json serializability.
- property begin¶
begin point of the line
- Type:
complex
- property end¶
end point of the line
- Type:
complex