Exemplo n.º 1
0
void CPWL_CBButton::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
  CPWL_Wnd::GetThisAppearanceStream(sAppStream);

  CPDF_Rect rectWnd = CPWL_Wnd::GetWindowRect();

  if (IsVisible() && !rectWnd.IsEmpty()) {
    CFX_ByteTextBuf sButton;

    CPDF_Point ptCenter = GetCenterPoint();

    CPDF_Point pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,
                   ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
    CPDF_Point pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,
                   ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
    CPDF_Point pt3(ptCenter.x,
                   ptCenter.y - PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);

    if (IsFloatBigger(rectWnd.right - rectWnd.left,
                      PWL_CBBUTTON_TRIANGLE_HALFLEN * 2) &&
        IsFloatBigger(rectWnd.top - rectWnd.bottom,
                      PWL_CBBUTTON_TRIANGLE_HALFLEN)) {
      sButton << "0 g\n";
      sButton << pt1.x << " " << pt1.y << " m\n";
      sButton << pt2.x << " " << pt2.y << " l\n";
      sButton << pt3.x << " " << pt3.y << " l\n";
      sButton << pt1.x << " " << pt1.y << " l f\n";

      sAppStream << "q\n" << sButton << "Q\n";
    }
  }
}
Exemplo n.º 2
0
void CPWL_CBButton::DrawThisAppearance(CFX_RenderDevice* pDevice,
                                       CPDF_Matrix* pUser2Device) {
  CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);

  CPDF_Rect rectWnd = CPWL_Wnd::GetWindowRect();

  if (IsVisible() && !rectWnd.IsEmpty()) {
    CPDF_Point ptCenter = GetCenterPoint();

    CPDF_Point pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,
                   ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
    CPDF_Point pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,
                   ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
    CPDF_Point pt3(ptCenter.x,
                   ptCenter.y - PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);

    if (IsFloatBigger(rectWnd.right - rectWnd.left,
                      PWL_CBBUTTON_TRIANGLE_HALFLEN * 2) &&
        IsFloatBigger(rectWnd.top - rectWnd.bottom,
                      PWL_CBBUTTON_TRIANGLE_HALFLEN)) {
      CFX_PathData path;

      path.SetPointCount(4);
      path.SetPoint(0, pt1.x, pt1.y, FXPT_MOVETO);
      path.SetPoint(1, pt2.x, pt2.y, FXPT_LINETO);
      path.SetPoint(2, pt3.x, pt3.y, FXPT_LINETO);
      path.SetPoint(3, pt1.x, pt1.y, FXPT_LINETO);

      pDevice->DrawPath(&path, pUser2Device, NULL,
                        CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_BLACKCOLOR,
                                                      GetTransparency()),
                        0, FXFILL_ALTERNATE);
    }
  }
}
Exemplo n.º 3
0
void CPWL_CBButton::DrawThisAppearance(CFX_RenderDevice* pDevice,
                                       CFX_Matrix* pUser2Device) {
  CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);

  CFX_FloatRect rectWnd = CPWL_Wnd::GetWindowRect();

  if (IsVisible() && !rectWnd.IsEmpty()) {
    CFX_PointF ptCenter = GetCenterPoint();

    CFX_PointF pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,
                   ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
    CFX_PointF pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,
                   ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
    CFX_PointF pt3(ptCenter.x,
                   ptCenter.y - PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);

    if (IsFloatBigger(rectWnd.right - rectWnd.left,
                      PWL_CBBUTTON_TRIANGLE_HALFLEN * 2) &&
        IsFloatBigger(rectWnd.top - rectWnd.bottom,
                      PWL_CBBUTTON_TRIANGLE_HALFLEN)) {
      CFX_PathData path;
      path.AppendPoint(pt1, FXPT_TYPE::MoveTo, false);
      path.AppendPoint(pt2, FXPT_TYPE::LineTo, false);
      path.AppendPoint(pt3, FXPT_TYPE::LineTo, false);
      path.AppendPoint(pt1, FXPT_TYPE::LineTo, false);

      pDevice->DrawPath(&path, pUser2Device, nullptr,
                        PWL_DEFAULT_BLACKCOLOR.ToFXColor(GetTransparency()), 0,
                        FXFILL_ALTERNATE);
    }
  }
}
Exemplo n.º 4
0
  void MultiresImagePlugin::Draw(double x, double y, double scale)
  {
    if (transformed_ && tile_set_ != NULL && tile_view_ != NULL)
    {
      GetCenterPoint(x, y);
      tile_view_->SetView(center_x_, center_y_, 1, scale);

      tile_view_->Draw();

      PrintInfo("OK");
    }
  }
Exemplo n.º 5
0
void GPSView::RefreshBackground(){

	int w,h ;
	GetClientSize(&w,&h);

	if (w != _currentWidth || h != _currentHeight){
		delete (_memBitmap);
		_currentWidth = w;
		_currentHeight = h;
		_memBitmap = new wxBitmap(_currentWidth, _currentHeight);
	}

	/////////////////
	// Create a memory DC
	wxMemoryDC dc;
	dc.SelectObject(*_memBitmap);

	wxColor backColor = *wxBLACK;
	dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(backColor,wxSOLID));
	dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(backColor,wxSOLID));
	dc.Clear();

	dc.SetPen(*wxThePenList->FindOrCreatePen(*wxLIGHT_GREY, 1, wxSOLID));

	Point centerPoint = GetCenterPoint(_currentWidth, _currentHeight);
	int currentSize = GetDominantSize(_currentWidth, _currentHeight);

	Point minPoint = ScalePoint(m_minPoint, h);
	Point maxPoint = ScalePoint(m_maxPoint, h);

	Point lastZoomedPoint;
	for (size_t i = 0; i < m_trackPoints.size(); i++){
		Point point = m_trackPoints[i];
		Point offsetPoint = OffsetPoint(point);
		Point scaledPoint = ScalePoint(offsetPoint, h);
		Point zoomedPoint = ZoomPoint(scaledPoint, centerPoint, minPoint, maxPoint, currentSize, m_zoom);
		if (0 == i){
			lastZoomedPoint = zoomedPoint;
		}
		else{
			dc.DrawLine(lastZoomedPoint.x, lastZoomedPoint.y, zoomedPoint.x, zoomedPoint.y);
			lastZoomedPoint = zoomedPoint;
		}
	}
    Refresh();
}
Exemplo n.º 6
0
void ImageExpand(IplImage* srcImage,IplImage* dstImage,vector<REGION>& rgn)
{
	int i,j;
	for(i=0;i<rgn.size();++i)
	{
		CvPoint center=GetCenterPoint(rgn[i].contour);
		for(j=0;j<rgn[i].contour.size();++j)
		{
			double k;
			if(center.x!=rgn[i].contour[j].x)
			{
				k=double(rgn[i].contour[j].y-center.y) / (rgn[i].contour[j].x-center.x);
                CvPoint pre=rgn[i].contour[j];
				int delta=-1;
				CvPoint boundaryPoint=pre;
				for(int exp=1;exp<=10;++exp)
				{
                    CvPoint cur;
					int step=1;
					cur.x=pre.x+step;
					cur.y=k*step+pre.y;
					if(cur.x<0 || cur.x>=srcImage->width || cur.y<0 || cur.y >=srcImage->height)
						break;
					int valPre=(unsigned char)srcImage->imageData[pre.y*srcImage->widthStep+pre.x];
					int valCur=(unsigned char)srcImage->imageData[cur.y*srcImage->widthStep+cur.x];
                    if(abs(valPre-valCur) > delta)
					{
                        delta=abs(valPre-valCur);
						boundaryPoint = valCur < valPre ? cur:pre;
					}
					pre=cur;
				}
				rgn[i].contour[j]=boundaryPoint;
			}
		}
	}
	for(i=0;i<rgn.size();++i)
	{
		for(j=0;j<rgn[i].contour.size();++j)
		{
			CvPoint pt=rgn[i].contour[j];
			dstImage->imageData[pt.y*dstImage->widthStep+pt.x]=0;
		}
	}
}
static mitk::Point2D GetCenterPoint(mitk::PlanarFigure* planarFigure)
{
  mitk::Point2D centerPoint;

  centerPoint[0] = 0;
  centerPoint[1] = 0;

  size_t numPolyLines = planarFigure->GetPolyLinesSize();

  for (size_t i = 0; i < numPolyLines; ++i)
  {
    mitk::Point2D polyLineCenterPoint = GetCenterPoint(planarFigure->GetPolyLine(i));

    centerPoint[0] += polyLineCenterPoint[0];
    centerPoint[1] += polyLineCenterPoint[1];
  }

  centerPoint[0] /= numPolyLines;
  centerPoint[1] /= numPolyLines;

  return centerPoint;
}
Exemplo n.º 8
0
void GPSView::OnPaint( wxPaintEvent& event )
{
	wxPaintDC mainDc(this);

	wxMemoryDC dc;
	dc.SelectObject(*_memBitmap);

	//blit into the real DC
	mainDc.Blit(0,0,_currentWidth,_currentHeight,&dc,0,0);

	Point centerPoint = GetCenterPoint(_currentWidth, _currentHeight);
	int currentSize = GetDominantSize(_currentWidth, _currentHeight);
	Point minPoint = ScalePoint(m_minPoint, _currentHeight);
	Point maxPoint = ScalePoint(m_maxPoint, _currentHeight);

    mainDc.SetPen(*wxThePenList->FindOrCreatePen(*wxRED, 10, wxSOLID));
	mainDc.SetBrush(*wxTheBrushList->FindOrCreateBrush(*wxRED,wxSOLID));
    Point offsetMarker = OffsetPoint(m_marker);
    Point scaledMarker = ScalePoint(offsetMarker, _currentHeight);
    Point zoomedPoint = ZoomPoint(scaledMarker, centerPoint, minPoint, maxPoint, currentSize, m_zoom);
    mainDc.DrawCircle(wxPoint(zoomedPoint.x, zoomedPoint.y), 4);
}
//-----------------------------------------------------------------------------
// Purpose: Given two non-intersecting rectangles, finds one, two or three segments
//  which connect the midpoints of two of the sides of the items together with only
//  axial lines.
// Input  : x1 - 
//			y1 - 
//			w1 - 
//			h1 - 
//			x2 - 
//			y2 - 
//			w2 - 
//			h2 - 
//			output - 
//-----------------------------------------------------------------------------
static void FindConnectingLines_Axial( 
	int x1, int y1, int w1, int h1, 
	int x2, int y2, int w2, int h2, 
	CUtlVector< CConnectingLine >& output )
{
	// Reset output
	output.RemoveAll();

	// If the rectangles intersect, no line needed
	wrect_t r1;
	r1.left = x1;
	r1.top = y1;
	r1.right = x1 + w1;
	r1.bottom = y1 + h1;

	wrect_t r2;
	r2.left = x2;
	r2.top = y2;
	r2.right = x2 + w2;
	r2.bottom = y2 + h2;
	wrect_t dummy;

	if ( GetRectIntersection( &r1, &r2, &dummy ) )
		return;

	int center1[2];
	int center2[2];

	center1[ 0 ] = x1 + w1/2;
	center1[ 1 ] = y1 + h1/2;

	center2[ 0 ] = x2 + w2/2;
	center2[ 1 ] = y2 + h2/2;

	int gaph;
	int gapv;

	LINEEDGE_t edge1 = TOPCENTER;
	LINEEDGE_t edge2 = BOTTOMCENTER;

	// Top
	gaph = max( r2.left - r1.right, r1.left - r2.right );
	gapv = max( r1.top - r2.bottom, r2.top - r1.bottom );

	if ( gapv > gaph )
	{
		// vertical
		if ( ( r1.top - r2.bottom ) > ( r2.top - r1.bottom ) )
		{
			edge2 = BOTTOMCENTER;
			edge1 = TOPCENTER;
		}
		else
		{
			edge2 = TOPCENTER;
			edge1 = BOTTOMCENTER;
		}
	}
	else
	{
		if ( ( r1.left - r2.right ) > ( r2.left - r1.right ) )
		{
			// horizontal
			edge2 = RIGHTCENTER;
			edge1 = LEFTCENTER;
		}
		else
		{
			edge2 = LEFTCENTER;
			edge1 = RIGHTCENTER;
		}
	}

	int pt1[ 2 ];
	int pt2[ 2 ];

	GetCenterPoint( pt1[ 0 ], pt1[ 1 ], r1, edge1, 3 );
	GetCenterPoint( pt2[ 0 ], pt2[ 1 ], r2, edge2, 3 );

	CConnectingLine line;

	int mid[ 2 ];
	int size1[ 2 ];
	int size2[ 2 ];

	mid[ 0 ] = ( pt1[ 0 ] + pt2[ 0 ] ) / 2;
	mid[ 1 ] = ( pt1[ 1 ] + pt2[ 1 ] ) / 2;

	size1[ 0 ] = r1.right - r1.left;
	size1[ 1 ] = r1.bottom - r1.top;

	size2[ 0 ] = r2.right - r2.left;
	size2[ 1 ] = r2.bottom - r2.top;

	float sizefrac = 0.25f;

	if ( edge1 == TOPCENTER || edge1 == BOTTOMCENTER )
	{
		int dx = abs( mid[ 0 ] - pt1[ 0 ] );
		if ( dx < ( sizefrac * size1[ 0 ] ) && 
			 dx < ( sizefrac * size2[ 0 ] ) )
		{
			// Gap is small, just use midpoint to align both
			line.m_ptStart[ 0 ] = mid[ 0 ];
			line.m_ptStart[ 1 ] = pt1[ 1 ];
			line.m_ptEnd[ 0 ] = mid[ 0 ];
			line.m_ptEnd[ 1 ] = pt2[ 1 ];

			output.AddToTail( line );
		}
		else
		{
			// Draw an L
			line.m_ptStart[ 0 ] = pt1[ 0 ];
			line.m_ptStart[ 1 ] = pt1[ 1 ];
			line.m_ptEnd[ 0 ] = pt1[ 0 ];
			line.m_ptEnd[ 1 ] = mid[ 1 ];

			output.AddToTail( line );

			line.m_ptStart[ 0 ] = pt1[ 0 ];
			line.m_ptStart[ 1 ] = mid[ 1 ];
			line.m_ptEnd[ 0 ] = pt2[ 0 ];
			line.m_ptEnd[ 1 ] = mid[ 1 ];

			output.AddToTail( line );

			line.m_ptStart[ 0 ] = pt2[ 0 ];
			line.m_ptStart[ 1 ] = mid[ 1 ];
			line.m_ptEnd[ 0 ] = pt2[ 0 ];
			line.m_ptEnd[ 1 ] = pt2[ 1 ];

			output.AddToTail( line );
		}
	}
	else
	{
		int dy = abs( mid[ 1 ] - pt1[ 1 ] );
		if ( dy < ( sizefrac * size1[ 1] ) && 
			 dy < ( sizefrac * size2[ 1 ] ) )
		{
			// Gap is small, just use midpoint to align both
			line.m_ptStart[ 0 ] = pt1[ 0 ];
			line.m_ptStart[ 1 ] = mid[ 1 ];
			line.m_ptEnd[ 0 ] = pt2[ 0 ];
			line.m_ptEnd[ 1 ] = mid[ 1 ];

			output.AddToTail( line );
		}
		else
		{
			// Draw an L
			line.m_ptStart[ 0 ] = pt1[ 0 ];
			line.m_ptStart[ 1 ] = pt1[ 1 ];
			line.m_ptEnd[ 0 ] = mid[ 0 ];
			line.m_ptEnd[ 1 ] = pt1[ 1 ];

			output.AddToTail( line );

			line.m_ptStart[ 0 ] = mid[ 0 ];
			line.m_ptStart[ 1 ] = pt1[ 1 ];
			line.m_ptEnd[ 0 ] = mid[ 0 ];
			line.m_ptEnd[ 1 ] = pt2[ 1 ];

			output.AddToTail( line );

			line.m_ptStart[ 0 ] = mid[ 0 ];
			line.m_ptStart[ 1 ] = pt2[ 1 ];
			line.m_ptEnd[ 0 ] = pt2[ 0 ];
			line.m_ptEnd[ 1 ] = pt2[ 1 ];

			output.AddToTail( line );
		}
	}

}
Exemplo n.º 10
0
//-----------------------------------------------------------------------------
// Purpose: Given two rectangles, finds a direct line between the two rectangles, unless
//  they overlap, in which case no line is output.
// Input  : x1 - 
//			y1 - 
//			w1 - 
//			h1 - 
//			x2 - 
//			y2 - 
//			w2 - 
//			h2 - 
//			output - 
//-----------------------------------------------------------------------------
static void FindConnectingLines_Straight( 
	int x1, int y1, int w1, int h1, 
	int x2, int y2, int w2, int h2, 
	CUtlVector< CConnectingLine >& output )
{
	// Reset output
	output.RemoveAll();

	// If the rectangles intersect, no line needed
	wrect_t r1;
	r1.left = x1;
	r1.top = y1;
	r1.right = x1 + w1;
	r1.bottom = y1 + h1;

	wrect_t r2;
	r2.left = x2;
	r2.top = y2;
	r2.right = x2 + w2;
	r2.bottom = y2 + h2;

	wrect_t dummy;

	if ( GetRectIntersection( &r1, &r2, &dummy ) )
		return;

	int center1[2];
	int center2[2];

	center1[ 0 ] = x1 + w1/2;
	center1[ 1 ] = y1 + h1/2;

	center2[ 0 ] = x2 + w2/2;
	center2[ 1 ] = y2 + h2/2;

	int gaph;
	int gapv;

	LINEEDGE_t edge1 = TOPCENTER;
	LINEEDGE_t edge2 = BOTTOMCENTER;

	// Top
	gaph = max( r2.left - r1.right, r1.left - r2.right );
	gapv = max( r1.top - r2.bottom, r2.top - r1.bottom );

	if ( gapv > gaph )
	{
		// vertical
		if ( ( r1.top - r2.bottom ) > ( r2.top - r1.bottom ) )
		{
			edge2 = BOTTOMCENTER;
			edge1 = TOPCENTER;
		}
		else
		{
			edge2 = TOPCENTER;
			edge1 = BOTTOMCENTER;
		}
	}
	else
	{
		if ( ( r1.left - r2.right ) > ( r2.left - r1.right ) )
		{
			// horizontal
			edge2 = RIGHTCENTER;
			edge1 = LEFTCENTER;
		}
		else
		{
			edge2 = LEFTCENTER;
			edge1 = RIGHTCENTER;
		}
	}

	int pt1[ 2 ];
	int pt2[ 2 ];

	GetCenterPoint( pt1[ 0 ], pt1[ 1 ], r1, edge1, 3 );
	GetCenterPoint( pt2[ 0 ], pt2[ 1 ], r2, edge2, 3 );

	CConnectingLine line;
	line.m_ptStart[ 0 ] = pt1[ 0 ];
	line.m_ptStart[ 1 ] = pt1[ 1 ];
	line.m_ptEnd[ 0 ] = pt2[ 0 ];
	line.m_ptEnd[ 1 ] = pt2[ 1 ];

	output.AddToTail( line );
}
void mitk::ExtrudePlanarFigureFilter::GenerateData()
{
  typedef PlanarFigure::PolyLineType PolyLine;
  typedef PolyLine::const_iterator PolyLineConstIter;

  if (m_Length <= 0)
    mitkThrow() << "Length is not positive!";

  if (m_NumberOfSegments == 0)
    mitkThrow() << "Number of segments is zero!";

  if (m_BendAngle != 0 && m_BendDirection[0] == 0 && m_BendDirection[1] == 0)
    mitkThrow() << "Bend direction is zero-length vector!";

  PlanarFigure* input = dynamic_cast<PlanarFigure*>(this->GetPrimaryInput());

  if (input == NULL)
    mitkThrow() << "Primary input is not a planar figure!";

  size_t numPolyLines = input->GetPolyLinesSize();

  if (numPolyLines == 0)
    mitkThrow() << "Primary input does not contain any poly lines!";

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

  if (planeGeometry == NULL)
    mitkThrow() << "Could not get plane geometry from primary input!";

  Vector3D planeNormal = planeGeometry->GetNormal();
  planeNormal.Normalize();

  Point2D centerPoint2d = GetCenterPoint(input);

  Point3D centerPoint3d;
  planeGeometry->Map(centerPoint2d, centerPoint3d);

  Vector3D bendDirection3d = m_BendAngle != 0
    ? ::GetBendDirection(planeGeometry, centerPoint2d, m_BendDirection)
    : Vector3D();

  ScalarType radius = m_Length * (360 / m_BendAngle) / (2 * vnl_math::pi);
  Vector3D scaledBendDirection3d = bendDirection3d * radius;

  Vector3D bendAxis = itk::CrossProduct(planeNormal, bendDirection3d);
  bendAxis.Normalize();

  vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
  vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New();
  vtkIdType baseIndex = 0;

  for (size_t i = 0; i < numPolyLines; ++i)
  {
    PolyLine polyLine = input->GetPolyLine(i);
    size_t numPoints = polyLine.size();

    if (numPoints < 2)
      mitkThrow() << "Poly line " << i << " of primary input consists of less than two points!";

    std::vector<mitk::Point3D> crossSection;

    PolyLineConstIter polyLineEnd = polyLine.end();

    for (PolyLineConstIter polyLineIter = polyLine.begin(); polyLineIter != polyLineEnd; ++polyLineIter)
    {
      Point3D point;
      planeGeometry->Map(*polyLineIter, point);
      crossSection.push_back(point);
    }

    ScalarType segmentLength = m_Length / m_NumberOfSegments;
    Vector3D translation = planeNormal * segmentLength;

    bool bend = std::abs(m_BendAngle) > mitk::eps;
    bool twist = std::abs(m_TwistAngle) > mitk::eps;

    ScalarType twistAngle = twist
      ? m_TwistAngle / m_NumberOfSegments * vnl_math::pi / 180
      : 0;

    ScalarType bendAngle = bend
      ? m_BendAngle / m_NumberOfSegments * vnl_math::pi / 180
      : 0;

    if (m_FlipDirection)
    {
      translation *= -1;
      bendAngle *= -1;
    }

    for (size_t k = 0; k < numPoints; ++k)
      points->InsertNextPoint(crossSection[k].GetDataPointer());

    for (size_t j = 1; j <= m_NumberOfSegments; ++j)
    {
      mitk::AffineTransform3D::Pointer transform = mitk::AffineTransform3D::New();

      if (bend || twist)
        transform->Translate(centerPoint3d.GetVectorFromOrigin(), true);

      if (bend)
      {
        transform->Translate(scaledBendDirection3d, true);
        transform->Rotate3D(bendAxis, bendAngle * j, true);
        transform->Translate(-scaledBendDirection3d, true);
      }
      else
      {
        transform->Translate(translation * j, true);
      }

      if (twist)
        transform->Rotate3D(planeNormal, twistAngle * j, true);

      if (bend || twist)
        transform->Translate(-centerPoint3d.GetVectorFromOrigin(), true);

      for (size_t k = 0; k < numPoints; ++k)
      {
        mitk::Point3D transformedPoint = transform->TransformPoint(crossSection[k]);
        points->InsertNextPoint(transformedPoint.GetDataPointer());
      }
    }

    for (size_t j = 0; j < m_NumberOfSegments; ++j)
    {
      for (size_t k = 1; k < numPoints; ++k)
      {
        vtkIdType cell[3];
        cell[0] = baseIndex + j * numPoints + (k - 1);
        cell[1] = baseIndex + (j + 1) * numPoints + (k - 1);
        cell[2] = baseIndex + j * numPoints + k;

        cells->InsertNextCell(3, cell);

        cell[0] = cell[1];
        cell[1] = baseIndex + (j + 1) * numPoints + k;

        cells->InsertNextCell(3, cell);
      }

      if (input->IsClosed() && numPoints > 2)
      {
        vtkIdType cell[3];
        cell[0] = baseIndex + j * numPoints + (numPoints - 1);
        cell[1] = baseIndex + (j + 1) * numPoints + (numPoints - 1);
        cell[2] = baseIndex + j * numPoints;

        cells->InsertNextCell(3, cell);

        cell[0] = cell[1];
        cell[1] = baseIndex + (j + 1) * numPoints;

        cells->InsertNextCell(3, cell);
      }
    }

    baseIndex += points->GetNumberOfPoints();
  }

  vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New();
  polyData->SetPoints(points);
  polyData->SetPolys(cells);

  vtkSmartPointer<vtkPolyDataNormals> polyDataNormals = vtkSmartPointer<vtkPolyDataNormals>::New();
  polyDataNormals->SetFlipNormals(m_FlipNormals);
  polyDataNormals->SetInputData(polyData);
  polyDataNormals->SplittingOff();

  polyDataNormals->Update();

  Surface* output = static_cast<Surface*>(this->GetPrimaryOutput());
  output->SetVtkPolyData(polyDataNormals->GetOutput());
}
Exemplo n.º 12
0
	//获取包围中心点(非外接圆)
	HawkVector2D HawkRect2D::GetBoundCenter() const
	{
		return GetCenterPoint();
	}
Exemplo n.º 13
0
	void  HawkRect2D::SetCenterPoint(const HawkVector2D& oPt)
	{
		HawkVector2D vCenter = GetCenterPoint();
		HawkVector2D vDelta  = vCenter - oPt;
		Point = Point + vDelta;
	}