Search in sources :

Example 36 with Group

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();
}
Also used : Group(facetmodeller.groups.Group) GroupVector(facetmodeller.groups.GroupVector) NodeVector(facetmodeller.plc.NodeVector) FacetVector(facetmodeller.plc.FacetVector) SplitGroupCommand(facetmodeller.commands.SplitGroupCommand)

Example 37 with Group

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();
}
Also used : Group(facetmodeller.groups.Group) NodeVector(facetmodeller.plc.NodeVector) Node(facetmodeller.plc.Node) AddNodeCommandVector(facetmodeller.commands.AddNodeCommandVector) Section(facetmodeller.sections.Section) NodeOnSection(facetmodeller.plc.NodeOnSection) MyPoint2D(geometry.MyPoint2D) NodeOnSection(facetmodeller.plc.NodeOnSection)

Aggregations

Group (facetmodeller.groups.Group)37 Node (facetmodeller.plc.Node)16 GroupVector (facetmodeller.groups.GroupVector)14 Section (facetmodeller.sections.Section)14 Facet (facetmodeller.plc.Facet)11 NodeOnSection (facetmodeller.plc.NodeOnSection)11 NodeVector (facetmodeller.plc.NodeVector)11 FacetVector (facetmodeller.plc.FacetVector)9 NodeOffSection (facetmodeller.plc.NodeOffSection)9 MyPoint3D (geometry.MyPoint3D)9 Color (java.awt.Color)8 MyPoint2D (geometry.MyPoint2D)7 Region (facetmodeller.plc.Region)6 SnapshotSection (facetmodeller.sections.SnapshotSection)6 File (java.io.File)6 PLC (facetmodeller.plc.PLC)5 ImageCrossSection (facetmodeller.sections.ImageCrossSection)5 NoImageCrossSection (facetmodeller.sections.NoImageCrossSection)5 NoImageDepthSection (facetmodeller.sections.NoImageDepthSection)5 SectionVector (facetmodeller.sections.SectionVector)5