1 package fi.vtt.simantics.processeditor.adapters;
\r
3 import javax.vecmath.Point3d;
\r
4 import javax.vecmath.Vector3d;
\r
6 import org.simantics.db.Graph;
\r
7 import org.simantics.db.Resource;
\r
8 import org.simantics.db.adaption.AdaptionException;
\r
9 import org.simantics.db.adaption.ResourceAdapter;
\r
10 import org.simantics.layer0.utils.EntityFactory;
\r
11 import org.simantics.layer0.utils.IEntity;
\r
12 import org.simantics.proconf.g3d.base.Constraint;
\r
13 import org.simantics.proconf.g3d.base.G3DTools;
\r
15 import fi.vtt.simantics.processeditor.ProcessResource;
\r
16 import fi.vtt.simantics.processeditor.common.PipingTools2;
\r
18 public class NozzleConstraintAdapter implements ResourceAdapter {
\r
19 @SuppressWarnings("unchecked")
\r
21 public <T> T adapt(Graph graph, Resource resource, Resource mia) throws AdaptionException {
\r
22 Constraint c = new Constraint();
\r
23 assert(graph.isInstanceOf(resource, ProcessResource.plant3Dresource.Nozzle));
\r
24 IEntity ent = EntityFactory.create(graph,resource);
\r
25 Vector3d dir = PipingTools2.getNozzleDirection(ent);
\r
26 Point3d center = G3DTools.getPoint(ent.getSingleRelatedObject(ProcessResource.g3dResource.HasWorldPosition));
\r
27 c.points.add(center);
\r