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
27 public class InlineComponentConstraintAdapter implements ResourceAdapter {
\r
28 @SuppressWarnings("unchecked")
\r
30 public <T> T adapt(Graph graph, Resource resource, Resource mia) throws AdaptionException {
\r
31 Constraint c = new Constraint();
\r
32 assert(graph.isInstanceOf(resource, ProcessResource.plant3Dresource.InlineComponent));
\r
33 IEntity ent = EntityFactory.create(graph,resource);
\r
34 Point3d center = new Point3d();
\r
35 Point3d p1 = new Point3d();
\r
36 Point3d p2 = new Point3d();
\r
37 Vector3d dir = new Vector3d();
\r
38 PipingTools2.getInlineComponentEnds(ent, center, p1, p2, dir);
\r
39 c.points.add(center);
\r