[Dcmlib] #include <vtkActor.h> #include <vtkAppendPolyData.h> #include <vtkCellData.h> #include <vtkClipPolyData.h> #include <vtkCutter.h>

Mathieu Malaterre mathieu.malaterre at kitware.com
Fri Feb 25 20:51:26 CET 2005


 #include <vtkDataSetSurfaceFilter.h>
	#include <vtkFloatArray.h>
	#include
 <vtkOutlineFilter.h>
	#include <vtkPlane.h>
	#include <vtkPolyDataMapper.h>

 #include <vtkProperty.h>
	#include <vtkRenderer.h>
	#include <vtkRenderWindow.h>

 #include <vtkRenderWindowInteractor.h>
	#include <vtkScalarBarActor.h>

 #include <vtkScalarsToColors.h>
	#include <vtkStructuredPoints.h>
	
	#define
 CLIP 0
	
	int main()
	{
	  vtkFloatArray* pData = vtkFloatArray::New();

   pData->SetNumberOfValues(5);
	  pData->SetValue(0, 0.f);
	  pData->SetValue(1,
 1.f);
	  pData->SetValue(2, 2.f);
	  pData->SetValue(3, 1.f);
	  pData->SetValue(4,
 0.f);
	
	  vtkStructuredPoints* pGrid = vtkStructuredPoints::New();
	
  pGrid->SetDimensions(6, 2, 2);
	  pGrid->GetCellData()->SetScalars(pData);

   pData->Delete();
	
	  vtkDataSetSurfaceFilter* pSurface = vtkDataSetSurfaceFilter::New();

   pSurface->SetInput(pGrid);
	
	  vtkPlane* pPlane = vtkPlane::New();

   pPlane->SetOrigin(2.5, 0.0, 0.0);
	  pPlane->SetNormal(1.0, 0.0, 0.0);

 
	  vtkClipPolyData* pClipper = vtkClipPolyData::New();
	  pClipper->SetInput(pSurface->GetOutput());

   pClipper->SetClipFunction(pPlane);
	
	  vtkCutter* pCutter = vtkCutter::New();

   pCutter->SetInput(pSurface->GetOutput());
	  pCutter->SetCutFunction(pPlane);

   pPlane->Delete();
	
	  vtkAppendPolyData* pAppender = vtkAppendPolyData::New();

 #if CLIP
	  pAppender->AddInput(pClipper->GetOutput());
	  pAppender->AddInput(pCutter->GetOutput());

 #else
	  pAppender->AddInput(pSurface->GetOutput());
	#endif // CLIP

   pSurface->Delete();
	  pClipper->Delete();
	  pCutter->Delete();
	

   vtkPolyDataMapper* pMapper = vtkPolyDataMapper::New();
	  pMapper->SetInput(pAppender->GetOutput());

   pMapper->SetScalarRange(0.0, 2.0);
	
	  vtkScalarBarActor* pSB = vtkScalarBarActor::New();

   pMapper->CreateDefaultLookupTable();
	  pSB->SetLookupTable(pMapper->GetLookupTable());

 
	  vtkActor* pActor = vtkActor::New();
	  pActor->SetMapper(pMapper);

   pMapper->Delete();
	
	  vtkRenderer* pRenderer = vtkRenderer::New();

   pRenderer->AddActor(pActor);
	  pActor->Delete();
	  pRenderer->AddActor(pSB);

   pSB->Delete();
	
	  vtkOutlineFilter* pOutline = vtkOutlineFilter::New();

   pOutline->SetInput(pGrid);
	  pGrid->Delete();
	
	  pMapper = vtkPolyDataMapper::New();

   pMapper->SetInput(pOutline->GetOutput());
	  pOutline->Delete();
	

   pActor = vtkActor::New();
	  pActor->SetMapper(pMapper);
	  pActor->GetProperty()->SetColor(1.0,
 1.0, 1.0);
	  pMapper->Delete();
	
	  pRenderer->AddActor(pActor);
	
  pActor->Delete();
	
	  vtkRenderWindow* pWindow = vtkRenderWindow::New();

   pWindow->AddRenderer(pRenderer);
	  pRenderer->Delete();
	
	  vtkRenderWindowInteractor*
 pInteractor = vtkRenderWindowInteractor::New();
	  pInteractor->SetRenderWindow(pWindow);

   pWindow->Delete();
	
	  pInteractor->Start();
	
	  pInteractor->Delete();

  str.setf( std::ios::fixed );
	
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Yo,

	J'ai rajouter  str.setf( std::ios::fixed ); / str.unsetf(...) car 
d'apres la baseline on dirait que toutes les images ont le %f (et pas le 
%g) de printf:


Commentaires ?

Mathieu

$ for i in `ls *.dcm`; do PrintHeader $i | grep "Image Position"; done

V 0020|0032[DS] [Image Position Patient] [-85.000000\ 21.600000\108.699997]
V 0020|0032[DS] [Image Position Patient] [-74.853516\-196.85352\-670.5]
V 0020|0032[DS] [Image Position Patient] 
[-1.197656e02\-3.997656e02\-2.800000e02]
V 0020|0032[DS] [Image Position Patient] [-256.0000000\0.0000000\+50.00 ]
V 0020|0032[DS] [Image Position Patient] [-180.000000\ -159.500000\ 
-542.000000 ]
V 0020|0032[DS] [Image Position Patient] 
[-72.3173828125\-228.3173828125\-197.8 ]
V 0020|0032[DS] [Image Position Patient] 
[-158.135803\-179.035797\-75.699997]
V 0020|0032[DS] [Image Position Patient] 
[-158.135803\-179.035797\-75.699997]
V 0020|0032[DS] [Image Position Patient] 
[-158.135803\-179.035797\-75.699997]
V 0020|0032[DS] [Image Position Patient] 
[-158.135803\-179.035797\-75.699997]
V 0020|0032[DS] [Image Position Patient] 
[-158.135803\-179.035797\-75.699997]
V 0020|0032[DS] [Image Position Patient] 
[-158.135803\-179.035797\-75.699997]
V 0020|0032[DS] [Image Position Patient] 
[-120.000000\-120.000000\-545.000000 ]
V 0020|0032[DS] [Image Position Patient] 
[-120.000000\-120.000000\-545.000000 ]
V 0020|0032[DS] [Image Position Patient] [-83.9063\-91.2000\6.6406]
V 0020|0032[DS] [Image Position Patient] [-83.9063\-91.2000\6.6406]
V 0020|0032[DS] [Image Position Patient] [-83.9063\-91.2000\6.6406]
V 0020|0032[DS] [Image Position Patient] 
[-180.058222\-97.147766\112.827990 ]
V 0020|0032[DS] [Image Position Patient] 
[-180.058222\-97.147766\112.827990 ]
V 0020|0032[DS] [Image Position Patient] 
[-180.058222\-97.147766\112.827990 ]
V 0020|0032[DS] [Image Position Patient] [-105.500000\15.600000\75.000000 ]
V 0020|0032[DS] [Image Position Patient] [-105.500000\15.600000\75.000000 ]
V 0020|0032[DS] [Image Position Patient] [-105.500000\15.600000\75.000000 ]
V 0020|0032[DS] [Image Position Patient] 
[-125.000992\-122.842384\32.496708 ]
V 0020|0032[DS] [Image Position Patient] 
[-125.000992\-122.842384\32.496708 ]
V 0020|0032[DS] [Image Position Patient] 
[-125.000992\-122.842384\32.496708 ]
V 0020|0032[DS] [Image Position Patient] [0.000000\0.000000\300.000000]
V 0020|0032[DS] [Image Position Patient] [-85.37207\-202.37207\-47.6]
V 0020|0032[DS] [Image Position Patient] [-85.37207\-202.37207\-47.6]
V 0020|0032[DS] [Image Position Patient] [-63\-235\-220.5 ]
V 0020|0030[DS] [Image Position (RET)] []
V 0020|0032[DS] [Image Position Patient] [ 
-89.672856\-135.729964\-15.642382]
V 0020|0032[DS] [Image Position Patient] [ -56.526302\-3.406109\4.418855]
V 0020|0032[DS] [Image Position Patient] [-23.900000\ 
-170.000000\245.300003]
V 0020|0032[DS] [Image Position Patient] [ -110.000000\ -110.000000\ 
36.500000]
V 0020|0032[DS] [Image Position Patient] 
[-158.135803\-179.035797\-75.699997]
V 0020|0032[DS] [Image Position Patient] 
[-114.070184\-105.989742\69.695065 ]
V 0020|0032[DS] [Image Position Patient] 
[-180.058222\-97.147766\112.827990 ]
V 0020|0032[DS] [Image Position Patient] [-110.000000\ 
-109.800003\-47.500000 ]
V 0020|0032[DS] [Image Position Patient] [57.368793\-118.022224\122.223611]
V 0020|0032[DS] [Image Position Patient] [57.368793\-118.022224\122.223611]
V 0020|0032[DS] [Image Position Patient] [10.802154\-112.24518\193.11131]
V 0020|0030[DS] [Image Position (RET)] []
V 0020|0032[DS] [Image Position Patient] [-224.999936\-5.000000\224.999936]
V 0020|0030[DS] [Image Position (RET)] []
V 0020|0032[DS] [Image Position Patient] [ 
-119.543446\-116.022104\72.101449]
V 0020|0032[DS] [Image Position Patient] [57.368793\-118.022224\122.223611]
V 0020|0032[DS] [Image Position Patient] 
[-73.1953735\-64.1519318\55.9903603]
V 0020|0032[DS] [Image Position Patient] 
[-1.579301e+01\-1.825949e+02\1.716627e+02]
V 0020|0032[DS] [Image Position Patient] [-255.5\-176\285.5 ]
V 0020|0030[DS] [Image Position (RET)] 
[002.574374E+02\-1.291855E+01\-2.656296E+02]
V 0020|0030[DS] [Image Position (RET)] 
[-01.190625E+02\-1.190625E+02\-3.003830E+01]
V 0020|0032[DS] [Image Position Patient] [-120\-120\-30.0383]
V 0020|0030[DS] [Image Position (RET)] 
[-01.190625E+02\-1.190625E+02\-3.553830E+01]
V 0020|0032[DS] [Image Position Patient] [-120\-120\-35.5383]
V 0020|0030[DS] [Image Position (RET)] 
[-01.190625E+02\-1.190625E+02\-4.103830E+01]
V 0020|0032[DS] [Image Position Patient] [-120\-120\-41.0383]
V 0020|0030[DS] [Image Position (RET)] 
[-01.190625E+02\-1.190625E+02\-4.653830E+01]
V 0020|0032[DS] [Image Position Patient] [-120\-120\-46.5383]
V 0020|0030[DS] [Image Position (RET)] [-216.4583\-40.13982\222.6627]
V 0020|0032[DS] [Image Position Patient] [-216.89778\-40.116819\223.10159 ]
V 0020|0032[DS] [Image Position Patient] [-120\-130.89866\-31.008121]
V 0020|0032[DS] [Image Position Patient] [-82.416765\-128.82503\-3.5856232]
V 0020|0032[DS] [Image Position Patient] []
V 0020|0032[DS] [Image Position Patient] 
[-117.697512\-176.058871\-10.171498]
V 0020|0032[DS] [Image Position Patient] [0.080000\0.005586\-0.075430 ]



More information about the Dcmlib mailing list