BowlerKernel
PrintBedObject.java
Go to the documentation of this file.
1 package com.neuronrobotics.bowlerstudio.printbed;
2 
3 import java.util.Arrays;
4 import java.util.List;
5 
6 import com.neuronrobotics.bowlerkernel.Bezier3d.manipulation;
7 import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR;
8 
9 import eu.mihosoft.vrl.v3d.CSG;
10 import eu.mihosoft.vrl.v3d.Vector3d;
11 import javafx.scene.transform.Affine;
12 
13 public class PrintBedObject {
14  private double xMax;
15  private double xMin;
16  private double yMax;
17  private double yMin;
18  private CSG part;
19  private String name;
21  private Affine affine = new Affine();
23  public PrintBedObject(String name, CSG part, double xMax, double xMin, double yMax, double yMin, TransformNR startPose){
24  this.part = part;
25  this.name = name;
26  this.xMax = xMax;
27  this.xMin = xMin;
28  this.yMax = yMax;
29  this.yMin = yMin;
30  this.globalPose = startPose;
31 
32  manip = new manipulation(affine, new Vector3d(1, 1, 0), part, startPose);
33  manip.addSaveListener(() -> System.out.println("Saving PrintBedObject "+name));
34  checkBounds();
35  }
36  public void addEventListener(Runnable r) {
38  }
39 
40  public void addSaveListener(Runnable r) {
42  }
43  public List<CSG> get() {
44  return Arrays.asList(part);
45  }
46 
47  public double getX() {
48  return manip.currentPose.getX();
49  }
50 
51  public double getY() {
52  return manip.currentPose.getY();
53  }
54 
55  public double getZ() {
56  return manip.currentPose.getZ();
57  }
58  public void checkBounds() {
59  double minYTest = part.getMinY()-yMin+globalPose.getY();
60  double maxYTest = part.getMaxY()-yMax+globalPose.getY();
61  double minXTest = part.getMinX()-xMin+globalPose.getX();
62  double maxXTest = part.getMaxX()-xMax+globalPose.getX();
63  if(minYTest<0)
64  globalPose.translateY(-minYTest);
65  if(minXTest<0)
66  globalPose.translateX(-minXTest);
67  if(maxYTest>0)
68  globalPose.translateY(-maxYTest);
69  if(maxXTest>0)
70  globalPose.translateX(-maxXTest);
72  }
73 
74 }
void set(double newX, double newY, double newZ)
PrintBedObject(String name, CSG part, double xMax, double xMin, double yMax, double yMin, TransformNR startPose)