1 /*******************************************************************************
2 * Copyright (c) 2012, 2013 Association for Decentralized Information Management in
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.g3d.csg.actions;
14 import java.util.ArrayList;
15 import java.util.Collection;
16 import java.util.HashMap;
19 import javax.vecmath.Quat4d;
20 import javax.vecmath.Vector3d;
22 import org.eclipse.jface.action.Action;
23 import org.simantics.g3d.csg.scenegraph2.CSGparentNode;
24 import org.simantics.g3d.csg.scenegraph2.CSGrootNode;
25 import org.simantics.g3d.csg.scenegraph2.ICSGnode;
27 public class SplitBooleanOpAction2 extends Action {
28 private CSGrootNode root;
29 private CSGparentNode booleanOp;
31 public SplitBooleanOpAction2(CSGrootNode root, CSGparentNode booleanOp) {
34 this.booleanOp = booleanOp;
40 Collection<ICSGnode> nodes = new ArrayList<ICSGnode>();
41 nodes.addAll(booleanOp.getPrimaryChild());
42 nodes.addAll(booleanOp.getSecondaryChild());
43 Map<ICSGnode,Vector3d> positions = new HashMap<ICSGnode, Vector3d>();
44 Map<ICSGnode,Quat4d> orientations = new HashMap<ICSGnode, Quat4d>();
45 for (ICSGnode node : nodes) {
46 positions.put(node, node.getWorldPosition());
47 orientations.put(node, node.getWorldOrientation());
50 for (ICSGnode node : nodes) {
52 node.setWorldPosition(positions.get(node));
53 node.setWorldOrientation(orientations.get(node));
55 root.remChild(booleanOp);
56 root.getNodeMap().commit("Split");