mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-02-05 16:34:17 +05:00
[bos #38044][EDF] (2023-T3) Support for automatic reparation. Fixed import error on loading a dump file. Fixed removing of created group and double publishing revealed with locate_subshapes plugin.
This commit is contained in:
parent
a1f2f31d35
commit
2d8e99ee89
@ -205,6 +205,13 @@ namespace
|
||||
{
|
||||
MESSAGE("Start check function dependencies...");
|
||||
|
||||
// Special case for function dumped from Python, because it's appended to
|
||||
// description of other function that should be rejected early.
|
||||
if (IsFunctionSetFromPython(aDescr)) {
|
||||
MESSAGE("Function set from Python. Do process with updated description.");
|
||||
return UPDATE_DESCRIPTION;
|
||||
}
|
||||
|
||||
TDF_LabelSequence aSeq;
|
||||
theFunction->GetDependency(aSeq);
|
||||
const Standard_Integer aLen = aSeq.Length();
|
||||
@ -236,16 +243,6 @@ namespace
|
||||
}
|
||||
|
||||
if (!theProcessed.Contains(aDepLabel)) {
|
||||
// Special case for function dumped from Python, because it's appended to
|
||||
// description of other function that should be rejected early.
|
||||
// TODO: it's not clear if we need to check every given function or
|
||||
// checking on this level is enough. At this moment it's better to stay here
|
||||
// for performance reason.
|
||||
if (IsFunctionSetFromPython(aDescr)) {
|
||||
MESSAGE("Function set from Python. Do process with updated description.");
|
||||
return UPDATE_DESCRIPTION;
|
||||
}
|
||||
|
||||
MESSAGE("The dependency label is not in processed list. Do not process.");
|
||||
return NOT_PROCESS;
|
||||
}
|
||||
|
@ -85,6 +85,60 @@ def module_from_filename(filename):
|
||||
return module
|
||||
|
||||
|
||||
def make_dump_args(algo_name, args_dict_str, is_dump_on, is_copy_on):
|
||||
"""
|
||||
Prepares a string with arguments for writing the execute() function to a python dump.
|
||||
|
||||
Args:
|
||||
algo_name - an algorithm's name.
|
||||
args_dict_str - string with all the args passed into the given algo.
|
||||
is_dump_on - do we need to write to dump.
|
||||
is_copy_on - do we need to copy selected object.
|
||||
|
||||
Returns:
|
||||
A string with arguments divided by comma.
|
||||
"""
|
||||
|
||||
algo_name_str = str(algo_name)
|
||||
is_dump_str = str(is_dump_on)
|
||||
is_copy_str = str(is_copy_on)
|
||||
|
||||
return '\'' + algo_name_str + '\', ' + args_dict_str + ', ' + is_dump_str + ', ' + is_copy_str
|
||||
|
||||
|
||||
def save_to_dump(geompy, selected_object, result_object, args_str):
|
||||
"""
|
||||
Record the function call for a python dump.
|
||||
|
||||
Args:
|
||||
geompy - geomBuilder object.
|
||||
selected_object - an object selected for repairation.
|
||||
result_object - a result object after algo applied.
|
||||
args_str - string with all the args for execute() function.
|
||||
|
||||
Returns:
|
||||
None.
|
||||
"""
|
||||
|
||||
# Importing everything from GEOM is a shorter way to fix arguments like GEOM.EDGE,
|
||||
# because calling str(GEOM.EDGE) results with 'EDGE' instead of 'GEOM.EDGE',
|
||||
# that leads to 'NameError: name 'EDGE' is not defined' on attempt to load the dump.
|
||||
# Could be narrowed down to 'from GEOM import EDGE, FACE' and so on,
|
||||
# if we are sure about limited set of definitions.
|
||||
import_str = 'from salome.geom.geomrepairadv import geomrepairadv_execute\nfrom GEOM import *\n'
|
||||
func_name = 'geomrepairadv_execute.execute'
|
||||
|
||||
geompy.FuncToPythonDump(
|
||||
selected_object,
|
||||
result_object,
|
||||
import_str,
|
||||
func_name,
|
||||
args_str
|
||||
)
|
||||
|
||||
logger.debug(f'{func_name} function prepared for Python dump with args: \n\t{args_str}')
|
||||
|
||||
|
||||
def execute(selected_object, algo_name, args_dict, is_dump_on = True, is_copy_on = True):
|
||||
"""
|
||||
Executes GEOM advanced repair algorithm.
|
||||
@ -143,13 +197,8 @@ def execute(selected_object, algo_name, args_dict, is_dump_on = True, is_copy_on
|
||||
return None
|
||||
|
||||
if is_dump_on:
|
||||
geompy.FuncToPythonDump(
|
||||
selected_object,
|
||||
result_object,
|
||||
'from salome.geom.geomrepairadv import geomrepairadv_execute\n',
|
||||
'geomrepairadv_execute.execute',
|
||||
'\'' + str(algo_name) + '\', ' + args_dict_str
|
||||
)
|
||||
args_str = make_dump_args(algo_name, args_dict_str, is_dump_on, is_copy_on)
|
||||
save_to_dump(geompy, selected_object, result_object, args_str)
|
||||
|
||||
return result_object
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user