Commit d9a5fdb0 authored by Ivan Dages's avatar Ivan Dages
Browse files

regroup components

parent 3cba8951
......@@ -766,6 +766,31 @@ public class Component {
return roots;
}
public static Component ancestorOf(Set<Component> components) {
if (components.isEmpty()) {
return null;
}
Iterator<Component> iter = components.iterator();
Component curComp = iter.next();
if (curComp.isRoot()) {
return null;
}
Component ancestor = curComp.getParent();
while (iter.hasNext()) {
curComp = iter.next();
if (curComp.isRoot()) {
return null;
}
while (!curComp.isChild(ancestor)) {
if (ancestor.isRoot()) {
return null;
}
ancestor = ancestor.getParent();
}
}
return ancestor;
}
/**
* Computes the axes of this component and its sub-hierarchy for each configuration, merges the results and
* analyzes the configurations in order to set the min/median/max values.
......@@ -1429,6 +1454,9 @@ public class Component {
* @return The inserted component
*/
public Component insertBlock(HashSet<Component> block, boolean fixedBlock) {
return insertBlock(block, fixedBlock, "INSERTED");
}
public Component insertBlock(HashSet<Component> block, boolean fixedBlock, String tag) {
Component inserted = new Component();
for (Iterator<Component> iter = block.iterator() ; iter.hasNext() ; ) {
......@@ -1445,7 +1473,7 @@ public class Component {
inserted.addConfiguration(newConfig);
}
inserted.setName("NOMAD_3D_INSERTED-" + insertedIndex);
inserted.setName("NOMAD_3D_" + tag + "-" + insertedIndex);
inserted.setFileName("NOMAD_3D_INSERTED");
inserted.setAxis(Axis.FREE_AXIS.clone());
inserted.getAxis().setMethod(Axis.Method.TO_COMPUTE);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment