Exemple #1
0
void ZIntCuboidFace::print() const
{
  std::cout << "Normal axis: ";
  if (m_isNormalPositive) {
    std::cout << "+";
  } else {
    std::cout << "-";
  }

  switch (getAxis()) {
  case NeuTube::X_AXIS:
    std::cout << "X";
    break;
  case NeuTube::Y_AXIS:
    std::cout << "Y";
    break;
  case NeuTube::Z_AXIS:
    std::cout << "Z";
    break;
  default:
    break;
  }
  std::cout << "(" << m_z << ")";
  std::cout << "; ";
  std::cout << "(" << getFirstCorner().getX() << ", " << getFirstCorner().getY()
            << ") --> (" << getLastCorner().getX() << ", "
            << getLastCorner().getY() << ")" << std::endl;
}
Exemple #2
0
bool ZIntCuboidObj::hit(double x, double y)
{
  return ((x >= getFirstCorner().getX() - 5 && y >= getFirstCorner().getY() - 5 &&
           x < getLastCorner().getX() + 5 && y < getLastCorner().getY() + 5) &&
          !(x >= getFirstCorner().getX() + 5 && y >= getFirstCorner().getY() + 5 &&
            x < getLastCorner().getX() - 5 && y < getLastCorner().getY() - 5));
}
Exemple #3
0
int ZIntCuboidFace::getUpperBound(int index) const
{
  if (index == 0) {
    return getLastCorner().getX();
  } else {
    return getLastCorner().getY();
  }
}
Exemple #4
0
ZIntCuboidFaceArray ZIntCuboidFace::cropBy(const ZIntCuboidFace &face) const
{
  ZIntCuboidFaceArray faceArray;
  if (hasOverlap(face)) {
    if (isWithin(face)) {
      return faceArray;
    } else {
      ZIntCuboidFace subface(getAxis(), isNormalPositive());
      subface.setZ(getPlanePosition());

      subface.set(getFirstCorner(),
                  Corner(getUpperBound(0), face.getLowerBound(1) - 1));
      faceArray.appendValid(subface);

      subface.set(Corner(getLowerBound(0),
                         imax2(getLowerBound(1), face.getLowerBound(1))),
                  Corner(face.getLowerBound(0) - 1, getUpperBound(1)));
      faceArray.appendValid(subface);

      subface.set(Corner(face.getUpperBound(0) + 1,
                         imax2(getLowerBound(1), face.getLowerBound(1))),
                  getLastCorner());
      faceArray.appendValid(subface);

      subface.set(Corner(imax2(getLowerBound(0), face.getLowerBound(0)),
                         face.getUpperBound(1) + 1),
                  Corner(imin2(getUpperBound(0), face.getUpperBound(0)),
                         getUpperBound(1)));
      faceArray.appendValid(subface);
    }
#if 0
    else if (face.isWithin(*this)) {
      ZIntCuboidFace subface(getAxis(), isNormalPositive());
      secondCorner.set(getUpperBound(0), face.getLowerBound(1));
      subface.set(getFirstCorner(), secondCorner);
      faceArray.appendValid(subface);

      subface.set(Corner(getLowerBound(0), face.getLowerBound(1)),
                  face.getCorner(2));
      faceArray.appendValid(subface);

      subface.set(Corner(getLowerBound(0), face.getUpperBound(1)),
                  getLastCorner());
      faceArray.appendValid(subface);
    } else {

    }
#endif
  } else {
Exemple #5
0
ZIntPoint ZIntCuboid::getCorner(int index) const
{
  switch (index) {
  case 0:
    return getFirstCorner();
  case 1:
    return ZIntPoint(getLastCorner().getX(),
                     getFirstCorner().getY(),
                     getFirstCorner().getZ());
  case 2:
    return ZIntPoint(getFirstCorner().getX(),
                     getLastCorner().getY(),
                     getFirstCorner().getZ());
  case 3:
    return ZIntPoint(getLastCorner().getX(),
                     getLastCorner().getY(),
                     getFirstCorner().getZ());
  case 4:
    return ZIntPoint(getFirstCorner().getX(),
                     getFirstCorner().getY(),
                     getLastCorner().getZ());
  case 5:
    return ZIntPoint(getLastCorner().getX(),
                     getFirstCorner().getY(),
                     getLastCorner().getZ());
  case 6:
    return ZIntPoint(getFirstCorner().getX(),
                     getLastCorner().getY(),
                     getLastCorner().getZ());
  case 7:
    return getLastCorner();
  default:
    break;
  }

  return ZIntPoint(0, 0, 0);
}
Exemple #6
0
ZIntCuboidFace::Corner ZIntCuboidFace::getCorner(int index) const
{
  switch (index) {
  case 0:
    return getFirstCorner();
  case 1:
    return Corner(getUpperBound(0), getLowerBound(1));
  case 2:
    return Corner(getLowerBound(0), getUpperBound(1));
  case 3:
    return getLastCorner();
  }

  return Corner(0, 0);
}
Exemple #7
0
bool ZIntCuboidObj::isOnSlice(int z) const
{
  return z >= getFirstCorner().getZ() && z <= getLastCorner().getZ();
}
Exemple #8
0
bool ZIntCuboidFace::isWithin(const ZIntCuboidFace &face) const
{
  return face.contains(getFirstCorner()) && face.contains(getLastCorner());
}