예제 #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;
}
예제 #2
0
void ZIntCuboidObj::display(ZPainter &painter, int slice, EDisplayStyle /*option*/) const
{
  if (m_cuboid.isEmpty()) {
    return;
  }

  int z = painter.getZ(slice);

  if (!(isSliceVisible(z) || (slice < 0))) {
    return;
  }

  QColor color = m_color;
  QPen pen(color);

  if(isOnSlice(z) || slice < 0) {
    if (isSelected()) {
      pen.setStyle(Qt::DashLine);
    } else {
      pen.setStyle(Qt::SolidLine);
    }
  } else {
    pen.setStyle(Qt::DotLine);
  }

  if (isSelected()) {
    pen.setWidth(pen.width() + 5);
  }

  painter.setPen(pen);
  painter.setBrush(Qt::NoBrush);

  painter.drawRect(getFirstCorner().getX(), getFirstCorner().getY(),
                   getWidth(), getHeight());
}
예제 #3
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));
}
예제 #4
0
int ZIntCuboidFace::getLowerBound(int index) const
{
  if (index == 0) {
    return getFirstCorner().getX();
  } else {
    return getFirstCorner().getY();
  }
}
예제 #5
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 {
예제 #6
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);
}
예제 #7
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);
}
예제 #8
0
bool ZIntCuboidObj::isOnSlice(int z) const
{
  return z >= getFirstCorner().getZ() && z <= getLastCorner().getZ();
}
예제 #9
0
bool ZIntCuboidFace::isWithin(const ZIntCuboidFace &face) const
{
  return face.contains(getFirstCorner()) && face.contains(getLastCorner());
}