]> gerrit.simantics Code Review - simantics/3d.git/blob
33b8075fa6b61210f4d11c9c1d89c635b5f7e028
[simantics/3d.git] /
1 package fi.vtt.simantics.processeditor.adapters;\r
2 \r
3 import javax.vecmath.Point3d;\r
4 import javax.vecmath.Vector3d;\r
5 \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
14 \r
15 import fi.vtt.simantics.processeditor.ProcessResource;\r
16 import fi.vtt.simantics.processeditor.common.PipingTools2;\r
17 \r
18 public class NozzleConstraintAdapter implements ResourceAdapter {\r
19         @SuppressWarnings("unchecked")\r
20         @Override\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
28                 c.dirs.add(dir);\r
29                 return (T) c;\r
30         }\r
31 \r
32 }\r