コード例 #1
0
ファイル: Feature.cpp プロジェクト: chahuistle/OpenMS
  ConvexHull2D& Feature::getConvexHull() const
  {
    //recalculate convex hull if necessary
    if (convex_hulls_modified_)
    {
      //only one mass trace convex hull => use it as overall convex hull
      if (convex_hulls_.size() == 1)
      {
        convex_hull_ = convex_hulls_[0];
      }
      else
      {
        convex_hull_.clear();
        if (convex_hulls_.size() > 0)
        {
          /*
          -- this does not work with our current approach of "non-convex"hull computation as the mass traces of features cannot be combined
          -- meaningfully. We thus print only the bounding box of the traces (for now)

          for (Size hull=0; hull<convex_hulls_.size(); ++hull)
          {
              convex_hull_.addPoints(convex_hulls_[hull].getHullPoints());
          }
          */

          DBoundingBox<2> box;
          for (Size hull = 0; hull < convex_hulls_.size(); ++hull)
          {
            box.enlarge(convex_hulls_[hull].getBoundingBox().minPosition()[0], convex_hulls_[hull].getBoundingBox().minPosition()[1]);
            box.enlarge(convex_hulls_[hull].getBoundingBox().maxPosition()[0], convex_hulls_[hull].getBoundingBox().maxPosition()[1]);
          }
          convex_hull_.addPoint(ConvexHull2D::PointType(box.minX(), box.minY()));
          convex_hull_.addPoint(ConvexHull2D::PointType(box.maxX(), box.minY()));
          convex_hull_.addPoint(ConvexHull2D::PointType(box.minX(), box.maxY()));
          convex_hull_.addPoint(ConvexHull2D::PointType(box.maxX(), box.maxY()));
        }

      }

      convex_hulls_modified_ = false;
    }

    return convex_hull_;
  }
コード例 #2
0
  void markFeatureLocations_(FeatureMap & feature_map, MSExperiment<> & exp, QImage & image, bool transpose, QColor color)
  {
    double xcoef = image.width(), ycoef = image.height();
    if (transpose)
    {
      xcoef /= exp.getMaxRT() - exp.getMinRT();
      ycoef /= exp.getMaxMZ() - exp.getMinMZ();
    }
    else
    {
      xcoef /= exp.getMaxMZ() - exp.getMinMZ();
      ycoef /= exp.getMaxRT() - exp.getMinRT();
    }

    for (FeatureMap::Iterator feat_iter = feature_map.begin();
         feat_iter != feature_map.end(); ++feat_iter)
    {
      const ConvexHull2D convex_hull = feat_iter->getConvexHull();
      DBoundingBox<2> box = convex_hull.getBoundingBox();
      double rt = feat_iter->getRT();
      double mz = feat_iter->getMZ();
      double lower_mz = box.minY();
      double lower_rt = box.minX();
      double upper_mz = box.maxY();
      double upper_rt = box.maxX();

      int lx, ly, ux, uy, cx, cy;
      if (transpose)
      {
        lx = int(xcoef * (lower_rt - exp.getMinRT()));
        ly = int(ycoef * (exp.getMaxMZ() - lower_mz));
        ux = int(xcoef * (upper_rt - exp.getMinRT()));
        uy = int(ycoef * (exp.getMaxMZ() - upper_mz));
        cx = int(xcoef * (rt - exp.getMinRT()));
        cy = int(ycoef * (mz - lower_mz));
      }
      else
      {
        lx = int(xcoef * (lower_mz - exp.getMinMZ()));
        ly = int(ycoef * (exp.getMaxRT() - lower_rt));
        ux = int(xcoef * (upper_mz - exp.getMinMZ()));
        uy = int(ycoef * (exp.getMaxRT() - upper_rt));
        cx = int(xcoef * (mz - exp.getMinMZ()));
        cy = int(ycoef * (exp.getMaxRT() - rt));
      }

      addFeatureBox_(ly, lx, uy, ux, image, color);
      addPoint_(cx, cy, image, Qt::black); // mark center
    }
  }