Пример #1
0
SegmentList ShapeInfo<RenderType>::computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight) const
{
    ASSERT(lineHeight >= 0);
    SegmentList segments;

    getIntervals((lineTop - logicalTopOffset()), std::min(lineHeight, shapeLogicalBottom() - lineTop), segments);

    for (size_t i = 0; i < segments.size(); i++) {
        segments[i].logicalLeft += logicalLeftOffset();
        segments[i].logicalRight += logicalLeftOffset();
    }

    return segments;
}
Пример #2
0
std::vector<index_type> Algorithm2A::calculateLCP(std::string BWT) {
    std::vector<index_type> LCP;
    
    LCP.push_back(-1);
    for(int i=0; i<BWT.size()-1; i++) {
        LCP.push_back(-2);
    }
    LCP.push_back(-1);
    
    Interval firstInterval;
    firstInterval.startIndex = 1;
    firstInterval.endIndex = BWT.size();
    
    QueueElement firstElement;
    firstElement.interval = firstInterval;
    firstElement.l = 0;
    
    queue<QueueElement> queueLCP;
    queueLCP.push(firstElement);
    
    while(!queueLCP.empty()) {
        QueueElement element;
        element = queueLCP.front();
        queueLCP.pop();
        
        vector<Interval> intervals = getIntervals(element.interval.startIndex,
                                                  element.interval.endIndex);
        
        for(vector<Interval>::iterator it = intervals.begin(); it != intervals.end(); ++it) {
            if(LCP[it->endIndex] == -2) {
                QueueElement newElement;
                newElement.interval = *it;
                newElement.l = element.l + 1;
                queueLCP.push(newElement);
                LCP[it->endIndex] = element.l;
            }
        }
    }
    return LCP;
}
Пример #3
0
void mitk::PlaneGeometryDataMapper2D::CreateVtkCrosshair(mitk::BaseRenderer *renderer)
{
  bool visible = true;
  LocalStorage* ls = m_LSH.GetLocalStorage(renderer);
  ls->m_CrosshairActor->SetVisibility(0);
  ls->m_ArrowActor->SetVisibility(0);
  ls->m_CrosshairHelperLineActor->SetVisibility(0);

  GetDataNode()->GetVisibility(visible, renderer, "visible");

  if(!visible)
  {
    return;
  }

  PlaneGeometryData::Pointer input = const_cast< PlaneGeometryData * >(this->GetInput());
  mitk::DataNode* geometryDataNode = renderer->GetCurrentWorldPlaneGeometryNode();
  const PlaneGeometryData* rendererWorldPlaneGeometryData = dynamic_cast< PlaneGeometryData * >(geometryDataNode->GetData());

  // intersecting with ourself?
  if ( input.IsNull() || input.GetPointer() == rendererWorldPlaneGeometryData)
  {
    return; //nothing to do in this case
  }

  const PlaneGeometry *inputPlaneGeometry = dynamic_cast< const PlaneGeometry * >( input->GetPlaneGeometry() );

  const PlaneGeometry* worldPlaneGeometry = dynamic_cast< const PlaneGeometry* >(
        rendererWorldPlaneGeometryData->GetPlaneGeometry() );

  if ( worldPlaneGeometry && dynamic_cast<const AbstractTransformGeometry*>(worldPlaneGeometry)==NULL
       && inputPlaneGeometry && dynamic_cast<const AbstractTransformGeometry*>(input->GetPlaneGeometry() )==NULL)
  {
    const BaseGeometry *referenceGeometry = inputPlaneGeometry->GetReferenceGeometry();

    // calculate intersection of the plane data with the border of the
    // world geometry rectangle
    Point3D point1, point2;

    Line3D crossLine;

    // Calculate the intersection line of the input plane with the world plane
    if ( worldPlaneGeometry->IntersectionLine( inputPlaneGeometry, crossLine ) )
    {
      bool hasIntersection = referenceGeometry ? CutCrossLineWithReferenceGeometry(referenceGeometry, crossLine) :
                                                 CutCrossLineWithPlaneGeometry(inputPlaneGeometry, crossLine);

      if (!hasIntersection)
      {
        return;
      }

      point1 = crossLine.GetPoint1();
      point2 = crossLine.GetPoint2();

      vtkSmartPointer<vtkCellArray> lines = vtkSmartPointer<vtkCellArray>::New();
      vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
      vtkSmartPointer<vtkPolyData> linesPolyData = vtkSmartPointer<vtkPolyData>::New();


      // Now iterate through all other lines displayed in this window and
      // calculate the positions of intersection with the line to be
      // rendered; these positions will be stored in lineParams to form a
      // gap afterwards.
      NodesVectorType::iterator otherPlanesIt = m_OtherPlaneGeometries.begin();
      NodesVectorType::iterator otherPlanesEnd = m_OtherPlaneGeometries.end();

      otherPlanesIt = m_OtherPlaneGeometries.begin();
      int gapSize = 32;
      this->GetDataNode()->GetPropertyValue("Crosshair.Gap Size", gapSize, NULL);


      auto intervals = IntervalSet<double>( SimpleInterval<double>(0, 1));

      ScalarType lineLength = point1.EuclideanDistanceTo(point2);
      ScalarType gapInMM = gapSize * renderer->GetScaleFactorMMPerDisplayUnit();
      float gapSizeParam = gapInMM / lineLength;

      if( gapSize != 0 )
      {
        while ( otherPlanesIt != otherPlanesEnd )
        {
          bool ignorePlane = false;
          (*otherPlanesIt)->GetPropertyValue("Crosshair.Ignore", ignorePlane);
          if (ignorePlane)
          {
              ++otherPlanesIt;
              continue;
          }

          PlaneGeometry *otherPlaneGeometry = static_cast< PlaneGeometry * >(
                static_cast< PlaneGeometryData * >((*otherPlanesIt)->GetData() )->GetPlaneGeometry() );

          if (otherPlaneGeometry != inputPlaneGeometry && otherPlaneGeometry != worldPlaneGeometry)
          {
              double intersectionParam;
              if (otherPlaneGeometry->IntersectionPointParam(crossLine, intersectionParam) && intersectionParam > 0 &&
                  intersectionParam < 1)
              {
                Point3D point = crossLine.GetPoint() + intersectionParam * crossLine.GetDirection();

                bool intersectionPointInsideOtherPlane =
                  otherPlaneGeometry->HasReferenceGeometry() ?
                    TestPointInReferenceGeometry(otherPlaneGeometry->GetReferenceGeometry(), point) :
                    TestPointInPlaneGeometry(otherPlaneGeometry, point);

                if (intersectionPointInsideOtherPlane)
                {
                  intervals -= SimpleInterval<double>(intersectionParam - gapSizeParam, intersectionParam + gapSizeParam);
                }
              }
          }
          ++otherPlanesIt;
        }
      }

      for (const auto& interval : intervals.getIntervals()) {
          this->DrawLine(crossLine.GetPoint(interval.GetLowerBoundary()), crossLine.GetPoint(interval.GetUpperBoundary()), lines, points);
      }

      // Add the points to the dataset
      linesPolyData->SetPoints(points);
      // Add the lines to the dataset
      linesPolyData->SetLines(lines);

      Vector3D orthogonalVector;
      orthogonalVector = inputPlaneGeometry->GetNormal();
      worldPlaneGeometry->Project(orthogonalVector,orthogonalVector);
      orthogonalVector.Normalize();

      // Visualize
      ls->m_Mapper->SetInputData(linesPolyData);
      ls->m_CrosshairActor->SetMapper(ls->m_Mapper);

      // Determine if we should draw the area covered by the thick slicing, default is false.
      // This will also show the area of slices that do not have thick slice mode enabled
      bool showAreaOfThickSlicing = false;
      GetDataNode()->GetBoolProperty( "reslice.thickslices.showarea", showAreaOfThickSlicing );

      // determine the pixelSpacing in that direction
      double thickSliceDistance = SlicedGeometry3D::CalculateSpacing(
        referenceGeometry ? referenceGeometry->GetSpacing() : inputPlaneGeometry->GetSpacing(), orthogonalVector);

      IntProperty *intProperty=0;
      if( GetDataNode()->GetProperty( intProperty, "reslice.thickslices.num" ) && intProperty )
        thickSliceDistance *= intProperty->GetValue()+0.5;
      else
        showAreaOfThickSlicing = false;

      // not the nicest place to do it, but we have the width of the visible bloc in MM here
      // so we store it in this fancy property
      GetDataNode()->SetFloatProperty( "reslice.thickslices.sizeinmm", thickSliceDistance*2 );

      ls->m_CrosshairActor->SetVisibility(1);

      vtkSmartPointer<vtkPolyData> arrowPolyData = vtkSmartPointer<vtkPolyData>::New();
      ls->m_Arrowmapper->SetInputData(arrowPolyData);
      if(this->m_RenderOrientationArrows)
      {
        ScalarType triangleSizeMM = 7.0 * renderer->GetScaleFactorMMPerDisplayUnit();

        vtkSmartPointer<vtkCellArray> triangles = vtkSmartPointer<vtkCellArray>::New();
        vtkSmartPointer<vtkPoints> triPoints = vtkSmartPointer<vtkPoints>::New();

        DrawOrientationArrow(triangles,triPoints,triangleSizeMM,orthogonalVector,point1,point2);
        DrawOrientationArrow(triangles,triPoints,triangleSizeMM,orthogonalVector,point2,point1);
        arrowPolyData->SetPoints(triPoints);
        arrowPolyData->SetPolys(triangles);
        ls->m_ArrowActor->SetVisibility(1);
      }

      // Visualize
      vtkSmartPointer<vtkPolyData> helperlinesPolyData = vtkSmartPointer<vtkPolyData>::New();
      ls->m_HelperLinesmapper->SetInputData(helperlinesPolyData);
      if ( showAreaOfThickSlicing )
      {
        vtkSmartPointer<vtkCellArray> helperlines = vtkSmartPointer<vtkCellArray>::New();
        // vectorToHelperLine defines how to reach the helperLine from the mainLine
        // got the right direction, so we multiply the width
        Vector3D vecToHelperLine = orthogonalVector * thickSliceDistance;

        this->DrawLine(point1 - vecToHelperLine, point2 - vecToHelperLine,helperlines,points);
        this->DrawLine(point1 + vecToHelperLine, point2 + vecToHelperLine,helperlines,points);

        // Add the points to the dataset
        helperlinesPolyData->SetPoints(points);

        // Add the lines to the dataset
        helperlinesPolyData->SetLines(helperlines);

        ls->m_CrosshairActor->GetProperty()->SetLineStipplePattern(0xf0f0);
        ls->m_CrosshairActor->GetProperty()->SetLineStippleRepeatFactor(1);
        ls->m_CrosshairHelperLineActor->SetVisibility(1);
      }
    }
  }
}
int calculate_offset(Exprs expr, int reg, char* id, char* proc_id){
    int stackNo;
    int curr_reg = reg;
    int next_reg;
    int dimension;
    int currentD = 2;
    int size;
    Intervals array_interval;
    print_exprs(expr, curr_reg, proc_id);
    /* Getting all the array details from symbol table */
    stackNo = getStackSlotNum(proc_id, id);
    dimension = getArrayDimension(proc_id, id);
    next_reg = curr_reg + dimension;
    size = getArraySize(proc_id, id);
    array_interval = getIntervals(proc_id, id);
    /**/
    int j = 0;
    
    int high_bounds[dimension];
    int low_bounds[dimension];
    while (array_interval != NULL){
        high_bounds[j] = array_interval->first->end;
        low_bounds[j] = array_interval->first->start;
        j++;
        array_interval = array_interval->rest;
    }
    int aNum;
    int array = 0;
    for (aNum = 1; aNum <= dimension; aNum++){
        printf("int_const r%d, %d\n", next_reg, low_bounds[array]);
        printf("sub_int r%d, r%d, r%d\n", curr_reg, curr_reg, next_reg);
        array += 1;
        curr_reg++;
    }
    curr_reg = reg;
    while (currentD <= dimension){
        print_offset(next_reg, high_bounds[currentD-1],
            low_bounds[currentD-1]);
        next_reg++;
        currentD++;
    }
    int new_reg = curr_reg + dimension;
    for (aNum = 2; aNum <= dimension; aNum++){
        while (new_reg < next_reg){
            printf("mul_int r%d, r%d, r%d\n", curr_reg, curr_reg, new_reg);
            new_reg++;
        }
        new_reg--;
        curr_reg++;
    }
    curr_reg = reg;
    int loop = 0;
    while (loop < dimension-1){
        printf("add_int r%d, r%d, r%d\n", curr_reg, curr_reg, 
            curr_reg+loop+1);
        loop++;
    }
    printf("load_address r%d, %d\n", curr_reg+1, stackNo);
    printf("sub_offset r%d, r%d, r%d\n", curr_reg, curr_reg+1, curr_reg);
    
    return curr_reg;
}