Ejemplo n.º 1
0
  /**
   * Determine if this label intersects the view or pick frustum.
   *
   * @param dc Current draw context.
   * @return True if this label intersects the active frustum (view or pick). Otherwise false.
   */
  protected boolean intersectsFrustum(DrawContext dc) {
    View view = dc.getView();
    Frustum frustum = view.getFrustumInModelCoordinates();

    // Test the label's model coordinate point against the near and far clipping planes.
    if (this.placePoint != null
        && (frustum.getNear().distanceTo(this.placePoint) < 0
            || frustum.getFar().distanceTo(this.placePoint) < 0)) {
      return false;
    }

    if (dc.isPickingMode()) return dc.getPickFrustums().intersectsAny(this.screenExtent);
    else return view.getViewport().intersects(this.screenExtent);
  }
Ejemplo n.º 2
0
  /** {@inheritDoc} */
  public boolean intersects(Frustum frustum) {
    if (frustum == null) {
      String msg = Logging.getMessage("nullValue.FrustumIsNull");
      Logging.error(msg);
      throw new IllegalArgumentException(msg);
    }

    // FYI: this code is identical to that in Cylinder.intersects.

    double intersectionPoint;

    this.tmp1.set(this.bottomCenter);
    this.tmp2.set(this.topCenter);

    double effectiveRadius = this.getEffectiveRadius(frustum.getNear());
    intersectionPoint = this.intersectsAt(frustum.getNear(), effectiveRadius, this.tmp1, this.tmp2);
    if (intersectionPoint < 0) return false;

    // Near and far have the same effective radius.
    effectiveRadius = this.getEffectiveRadius(frustum.getFar());
    intersectionPoint = this.intersectsAt(frustum.getFar(), effectiveRadius, this.tmp1, this.tmp2);
    if (intersectionPoint < 0) return false;

    effectiveRadius = this.getEffectiveRadius(frustum.getLeft());
    intersectionPoint = this.intersectsAt(frustum.getLeft(), effectiveRadius, this.tmp1, this.tmp2);
    if (intersectionPoint < 0) return false;

    effectiveRadius = this.getEffectiveRadius(frustum.getRight());
    intersectionPoint =
        this.intersectsAt(frustum.getRight(), effectiveRadius, this.tmp1, this.tmp2);
    if (intersectionPoint < 0) return false;

    effectiveRadius = this.getEffectiveRadius(frustum.getTop());
    intersectionPoint = this.intersectsAt(frustum.getTop(), effectiveRadius, this.tmp1, this.tmp2);
    if (intersectionPoint < 0) return false;

    effectiveRadius = this.getEffectiveRadius(frustum.getBottom());
    intersectionPoint =
        this.intersectsAt(frustum.getBottom(), effectiveRadius, this.tmp1, this.tmp2);
    return intersectionPoint >= 0;
  }