1 /*******************************************************************************
\r
2 * Copyright (c) 2007- VTT Technical Research Centre of Finland.
\r
3 * All rights reserved. This program and the accompanying materials
\r
4 * are made available under the terms of the Eclipse Public License v1.0
\r
5 * which accompanies this distribution, and is available at
\r
6 * http://www.eclipse.org/legal/epl-v10.html
\r
9 * VTT Technical Research Centre of Finland - initial API and implementation
\r
10 *******************************************************************************/
\r
11 package org.simantics.processeditor.adapters;
\r
13 import javax.vecmath.Point3d;
\r
14 import javax.vecmath.Vector3d;
\r
16 import org.simantics.db.Graph;
\r
17 import org.simantics.db.Resource;
\r
18 import org.simantics.db.adaption.AdaptionException;
\r
19 import org.simantics.db.adaption.ResourceAdapter;
\r
20 import org.simantics.layer0.utils.EntityFactory;
\r
21 import org.simantics.layer0.utils.IEntity;
\r
22 import org.simantics.processeditor.ProcessResource;
\r
23 import org.simantics.processeditor.common.PipingTools2;
\r
24 import org.simantics.proconf.g3d.base.Constraint;
\r
25 import org.simantics.proconf.g3d.base.G3DTools;
\r
28 public class NozzleConstraintAdapter implements ResourceAdapter {
\r
29 @SuppressWarnings("unchecked")
\r
31 public <T> T adapt(Graph graph, Resource resource, Resource mia) throws AdaptionException {
\r
32 Constraint c = new Constraint();
\r
33 assert(graph.isInstanceOf(resource, ProcessResource.plant3Dresource.Nozzle));
\r
34 IEntity ent = EntityFactory.create(graph,resource);
\r
35 Vector3d dir = PipingTools2.getNozzleDirection(ent);
\r
36 Point3d center = G3DTools.getPoint(ent.getSingleRelatedObject(ProcessResource.g3dResource.HasWorldPosition));
\r
37 c.points.add(center);
\r