1 package org.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.processeditor.ProcessResource;
\r
13 import org.simantics.processeditor.common.PipingTools2;
\r
14 import org.simantics.proconf.g3d.base.Constraint;
\r
17 public class InlineComponentConstraintAdapter implements ResourceAdapter {
\r
18 @SuppressWarnings("unchecked")
\r
20 public <T> T adapt(Graph graph, Resource resource, Resource mia) throws AdaptionException {
\r
21 Constraint c = new Constraint();
\r
22 assert(graph.isInstanceOf(resource, ProcessResource.plant3Dresource.InlineComponent));
\r
23 IEntity ent = EntityFactory.create(graph,resource);
\r
24 Point3d center = new Point3d();
\r
25 Point3d p1 = new Point3d();
\r
26 Point3d p2 = new Point3d();
\r
27 Vector3d dir = new Vector3d();
\r
28 PipingTools2.getInlineComponentEnds(ent, center, p1, p2, dir);
\r
29 c.points.add(center);
\r