Exemplo n.º 1
0
bool CVideoMode::SetFullscreen(bool fullscreen)
{
	// This might get called before initialisation by psDisplayError;
	// if so then silently fail
	if (!m_IsInitialised)
		return false;

	// Check whether this is actually a change
	if (fullscreen == m_IsFullscreen)
		return true;

	if (!m_IsFullscreen)
	{
		// Windowed -> fullscreen:

		int w = 0, h = 0;

		// If a fullscreen size was configured, use that; else use the desktop size; else use a default
		if (m_ConfigFullscreen)
		{
			w = m_ConfigW;
			h = m_ConfigH;
		}
		if (w == 0 || h == 0)
		{
			w = m_PreferredW;
			h = m_PreferredH;
		}
		if (w == 0 || h == 0)
		{
			w = DEFAULT_FULLSCREEN_W;
			h = DEFAULT_FULLSCREEN_H;
		}

		int bpp = GetBestBPP();

		if (!SetVideoMode(w, h, bpp, fullscreen))
			return false;

		UpdateRenderer(m_CurrentW, m_CurrentH);

		return true;
	}
	else
	{
		// Fullscreen -> windowed:

		// Go back to whatever the previous window size was
		int w = m_WindowedW, h = m_WindowedH;

		int bpp = GetBestBPP();

		if (!SetVideoMode(w, h, bpp, fullscreen))
			return false;

		UpdateRenderer(w, h);

		return true;
	}
}
Exemplo n.º 2
0
void
CanvasClientSharedSurface::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
{
  Renderer renderer;
  renderer.construct<ClientCanvasLayer*>(aLayer);
  UpdateRenderer(aSize, renderer);
}
Exemplo n.º 3
0
void
CanvasClientSharedSurface::UpdateAsync(AsyncCanvasRenderer* aRenderer)
{
  Renderer renderer;
  renderer.construct<AsyncCanvasRenderer*>(aRenderer);
  UpdateRenderer(aRenderer->GetSize(), renderer);
}
void mitk::SurfaceRefinementTool::SubdivideSurface()
{
	std::cout << "hi from " << __FUNCSIG__ << std::endl;

	// Try VTK subdivision filters
	vtkSmartPointer<vtkPolyDataAlgorithm> subdivisionFilter;
    switch(m_SubdivisionMethode)
    {
      case 0:
        subdivisionFilter = vtkSmartPointer<vtkLinearSubdivisionFilter>::New();
        break;
      case 1:
        subdivisionFilter =  vtkSmartPointer<vtkLoopSubdivisionFilter>::New();
        break;
      case 2: 
        subdivisionFilter = vtkSmartPointer<vtkButterflySubdivisionFilter>::New();
        break;
      default:
        break;
    }

	subdivisionFilter->SetInput(m_Ext->GetSurfacePolyData());
    //subdivisionFilter->SetNumberOfSubdivisions(2);
    subdivisionFilter->Update();
	m_Ext->SetSurfacePolyData(subdivisionFilter->GetOutput());
	UpdateRenderer();

	std::cout << "ciao from " << __FUNCSIG__ << std::endl;
}
Exemplo n.º 5
0
void ImageBrowser5D::SetMode(RenderMode mode)
{
	if(mode != m_mode)
	{
		m_mode = mode;
		UpdateVSlider();
		UpdateRenderer();
	}
}
Exemplo n.º 6
0
void ImageBrowser5D::Setup()
{
	if(!img) return;

	for(int c=0; c<img->GetImageInfo()->numChannels; ++c)
		m_chflag.push_back(true);
	
	CreateObjects();
	CreateLayout();
	CreateLookupTable();
	CreateVolumeProperties();
	CreateInteractorStyle();

	UpdateVSlider();
	UpdateHSlider();
	UpdateRenderer();

	this->resize(img->GetImageInfo()->numColumns, img->GetImageInfo()->numRows);
	this->setAttribute ( Qt::WA_DeleteOnClose );
	this->setWindowTitle(tr("Image Browser"));
}
Exemplo n.º 7
0
bool CVideoMode::ResizeWindow(int w, int h)
{
	ENSURE(m_IsInitialised);

	// Ignore if not windowed
	if (m_IsFullscreen)
		return true;

	// Ignore if the size hasn't changed
	if (w == m_WindowedW && h == m_WindowedH)
		return true;

	int bpp = GetBestBPP();

	if (!SetVideoMode(w, h, bpp, false))
		return false;

	m_WindowedW = w;
	m_WindowedH = h;

	UpdateRenderer(w, h);

	return true;
}
void mitk::SurfaceRefinementTool::SubdivideByPoint()
{
	std::cout << "hi from " << __FUNCSIG__ << std::endl;

	std::vector<vtkIdType> cellsToBeRemoved;
	// For all selected cells:
	for(std::vector<vtkIdType>::iterator it = m_SelectedCells.begin(); it != m_SelectedCells.end(); it++)
	{
		// Get Points of hit cell
		vtkIdType ntps, *pts;
		m_Ext->GetSurfacePolyData()->GetCellPoints(*it, ntps, pts);
		//std::cout << "Number of Points in Cell: " << ntps << "\n";
		if(ntps != 3)
			std::cout << "Error -> Triangulate!\n"; // TODO
		double pt1[3], pt2[3], pt3[3];
		m_Ext->GetSurfacePolyData()->GetPoint(pts[0], pt1);
		m_Ext->GetSurfacePolyData()->GetPoint(pts[1], pt2);
		m_Ext->GetSurfacePolyData()->GetPoint(pts[2], pt3);
		
		// Mark old cell for deletion
		cellsToBeRemoved.push_back(*it);

		// Calculate centroid of the cell
		double weightSum = 0.0;
		double centroid[3] = {0.0, 0.0, 0.0};
		std::cout << "Centroid: " << centroid[0] << " " << centroid[0] << " " << centroid[0] << "\n";

		double currentWeight12 = sqrt(vtkMath::Distance2BetweenPoints(pt1, pt2));
		double currentWeight13 = sqrt(vtkMath::Distance2BetweenPoints(pt1, pt3));
		double currentWeight23 = sqrt(vtkMath::Distance2BetweenPoints(pt2, pt3));

		centroid[0] += pt1[0] * (currentWeight12 + currentWeight13); // Produkt oder Summe der Gewichte?
		centroid[1] += pt1[1] * (currentWeight12 + currentWeight13);
		centroid[2] += pt1[2] * (currentWeight12 + currentWeight13);

		centroid[0] += pt2[0] * (currentWeight12 + currentWeight23);
		centroid[1] += pt2[1] * (currentWeight12 + currentWeight23);
		centroid[2] += pt2[2] * (currentWeight12 + currentWeight23);

		centroid[0] += pt3[0] * (currentWeight13 + currentWeight23);
		centroid[1] += pt3[1] * (currentWeight13 + currentWeight23);
		centroid[2] += pt3[2] * (currentWeight13 + currentWeight23);

		weightSum = currentWeight12 + currentWeight13 + currentWeight23;
		
		if(0)
		{
			std::cout << "Point 1: " << pt1[0] << " " << pt1[1] << " " << pt1[2] << "\n";
			std::cout << "Point 2: " << pt2[0] << " " << pt2[1] << " " << pt2[2] << "\n";
			std::cout << "Distance between two points: " << sqrt(vtkMath::Distance2BetweenPoints(pt1, pt2)) << "\n";
		}

		centroid[0] /= (weightSum * 2);
		centroid[1] /= (weightSum * 2);
		centroid[2] /= (weightSum * 2);

		// Add three new cells with new point
		vtkIdType *pts1, *pts2, *pts3, ptsNewPoint, pt1Id, pt2Id, pt3Id;
		pts1 = new vtkIdType[3];
		pts2 = new vtkIdType[3];
		pts3 = new vtkIdType[3];		

		vtkSmartPointer<vtkPolyData> newTriangles = vtkSmartPointer<vtkPolyData>::New();
		vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
		ptsNewPoint = points->InsertNextPoint(centroid[0], centroid[1], centroid[2]);
		pt1Id = points->InsertNextPoint(pt1);
		pt2Id = points->InsertNextPoint(pt2);
		pt3Id = points->InsertNextPoint(pt3);

		pts1[0] = ptsNewPoint;
		pts1[1] = pt2Id;
		pts1[2] = pt3Id; 
		pts2[0] = pt1Id;
		pts2[1] = ptsNewPoint;
		pts2[2] = pt3Id; 
		pts3[0] = pt1Id;
		pts3[1] = pt2Id;
		pts3[2] = ptsNewPoint;
		newTriangles->SetPoints ( points );
		
		newTriangles->Allocate();
		newTriangles->InsertNextCell(VTK_TRIANGLE, 3, pts1);
		newTriangles->InsertNextCell(VTK_TRIANGLE, 3, pts2);
		newTriangles->InsertNextCell(VTK_TRIANGLE, 3, pts3);

		vtkAppendPolyData *app = vtkAppendPolyData::New();
		app->AddInput(m_Ext->GetSurfacePolyData());
		app->AddInput(newTriangles);
		app->Update();
		m_Ext->SetSurfacePolyData(app->GetOutput());

		// Fill generated holes
		m_Ext->GetSurfacePolyData()->BuildCells();
		m_Ext->GetSurfacePolyData()->BuildCells();
	}

	// Forum Thread: easiest to rebuild polydata from scratch
	vtkSmartPointer<vtkPolyData> newSurface = vtkSmartPointer<vtkPolyData>::New();
	newSurface->Allocate(10000,10000); 
	vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
	points->Allocate(10000);

	vtkCellArray* cells = m_Ext->GetSurfacePolyData()->GetPolys();
	vtkIdType *pts, npts, cellId;

	for(cellId=0, cells->InitTraversal(); cells->GetNextCell(npts,pts); cellId++)
	{
		if(!std::binary_search(cellsToBeRemoved.begin(),cellsToBeRemoved.end(), cellId))
		{
			// CellId is not deleted -> add to new mesh
			double pt1[3], pt2[3], pt3[3];
			vtkIdType t1, t2, t3;
			m_Ext->GetSurfacePolyData()->GetPoint(pts[0], pt1);
			m_Ext->GetSurfacePolyData()->GetPoint(pts[1], pt2);
			m_Ext->GetSurfacePolyData()->GetPoint(pts[2], pt3);
			
			t1 = points->InsertNextPoint(pt1);
			t2 = points->InsertNextPoint(pt2);
			t3 = points->InsertNextPoint(pt3);

			vtkIdList* newPts = vtkIdList::New();
			newPts->InsertNextId(t1);
			newPts->InsertNextId(t2);
			newPts->InsertNextId(t3);

			newSurface->SetPoints(points);			
			newSurface->InsertNextCell(VTK_TRIANGLE, newPts);
		}
		else
		{
			//std::cout << "Vector includes cell.\n";
			// add clipped part
		}
	}

	vtkSmartPointer<vtkCleanPolyData> removeDuplicatedPoints = vtkSmartPointer<vtkCleanPolyData>::New(); 
	removeDuplicatedPoints->SetInput(newSurface);
	removeDuplicatedPoints->Update();
	newSurface = removeDuplicatedPoints->GetOutput();

	m_Ext->SetSurfacePolyData(newSurface);

	ResetNormals();
	UpdateRenderer();

	std::cout << "ciao from " << __FUNCSIG__ << std::endl;
}
Exemplo n.º 9
0
void ImageBrowser5D::SetT(int t)
{
	m_T = t;
	UpdateRenderer();
}