use of facetmodeller.groups.Group in project facetmodeller by pglelievre.
the class SplitGroupBoundaryMenuTask method execute.
@Override
public void execute() {
// Check for the required information:
if (!check()) {
return;
}
// Get the facets for the current group:
Group currentGroup = controller.getSelectedCurrentGroup();
FacetVector facets = currentGroup.getFacets();
// Find the boundary nodes:
NodeVector boundaryNodes = facets.findBoundaryNodes();
// Check for an error:
if (boundaryNodes == null) {
Dialogs.error(controller, "All facets must be triangular.", title());
return;
}
if (boundaryNodes.size() == 0) {
Dialogs.inform(controller, "No boundary nodes were found.", title());
return;
}
// Define a new group:
String name = currentGroup.getName() + "_NodeBoundary";
Group newGroup = new Group(name);
newGroup.setNodeColor(Color.WHITE);
// Get the index of the current group object:
int ind = controller.getSelectedCurrentGroupIndex();
// Get the currently selected node and facet groups, so we can maintain the selections,
// and adjust them as required:
GroupVector selectedNodeGroups = controller.getSelectedNodeGroups();
GroupVector selectedFacetGroups = controller.getSelectedFacetGroups();
// Split the group, adding the new group object to the list of groups just after the current group:
SplitGroupCommand com = new SplitGroupCommand(controller, currentGroup, null, newGroup, boundaryNodes, null, ind + 1, title());
com.execute();
controller.undoVectorAdd(com);
// Add the new group to the group selections:
selectedNodeGroups.add(newGroup);
controller.setSelectedCurrentGroupIndex(ind);
controller.setSelectedNodeGroups(selectedNodeGroups);
controller.setSelectedFacetGroups(selectedFacetGroups);
// Enable or disable menu items:
controller.checkItemsEnabled();
// Repaint:
controller.redraw();
}
use of facetmodeller.groups.Group in project facetmodeller by pglelievre.
the class NodesAtCalibrationMenuTask method execute.
@Override
public void execute() {
// Check for the required information:
if (!check()) {
return;
}
// Get the current section and group:
Section currentSection = controller.getSelectedCurrentSection();
Group currentGroup = controller.getSelectedCurrentGroup();
// Add 4 new nodes to the section,
MyPoint2D p1 = currentSection.getClicked1();
MyPoint2D p2 = currentSection.getClicked2();
MyPoint2D[] p = new MyPoint2D[4];
p[0] = p1.deepCopy();
p[1] = p2.deepCopy();
p[2] = new MyPoint2D(p1.getX(), p2.getY());
p[3] = new MyPoint2D(p2.getX(), p1.getY());
NodeVector nodes = new NodeVector();
for (int i = 0; i < 4; i++) {
// new node is not added to the section or group yet
Node n = new NodeOnSection(p[i], currentSection, currentGroup);
nodes.add(n);
}
// adds the node to the section and group
AddNodeCommandVector com = new AddNodeCommandVector(controller.getModelManager(), nodes, title());
// adds the node to the section and group
com.execute();
controller.undoVectorAdd(com);
// Enable or disable menu items:
controller.checkItemsEnabled();
// Redraw:
controller.redraw();
}
Aggregations