/// <summary>
  ///Initialize a viewer
  /// </summary>
  /// <param name="theWnd">System.IntPtr that contains the window handle (HWND) of the control</param>
  bool InitViewer()
  {
    myGraphicDriver() = new D3DHost_GraphicDriver();
    myGraphicDriver()->ChangeOptions().buffersNoSwap = true;
    //myGraphicDriver()->ChangeOptions().contextDebug = true;

    TCollection_ExtendedString a3DName ("Visu3D");
    myViewer() = new V3d_Viewer (myGraphicDriver(), a3DName.ToExtString(), "", 1000.0,
                                 V3d_XposYnegZpos, Quantity_NOC_GRAY30,
                                 V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT,
                                 Standard_True, Standard_False);

    myViewer()->SetDefaultLights();
    myViewer()->SetLightOn();
    myView() = myViewer()->CreateView();

    static Handle(WNT_WClass) aWClass = new WNT_WClass ("OCC_Viewer", NULL, CS_OWNDC);
    Handle(WNT_Window) aWNTWindow = new WNT_Window ("OCC_Viewer", aWClass, WS_POPUP, 64, 64, 64, 64);
    aWNTWindow->SetVirtual (Standard_True);
    myView()->SetWindow(aWNTWindow);
    myAISContext() = new AIS_InteractiveContext (myViewer());
    myAISContext()->UpdateCurrentViewer();
    myView()->MustBeResized();
    return true;
  }
Beispiel #2
0
		 int testView(imbxUint32 frameNumber, std::string fileName)
		{
			cout << "testView begin" << endl;
			string path = "C:\\Users\\maro\\Documents\\DicomFiles\\digest_article\\brain_001.dcm";
			cout << "frame number = " << frameNumber << endl;
			cout << "file name = " << fileName << endl;

			ptr<stream> readStream(new stream);
			readStream->openFile(fileName, std::ios::in);
			//parse content of the file
			ptr<streamReader> reader(new streamReader(readStream));
			//create dataSet structure, that contains the dicom tags defined in the file
			//Get a codec factory and let it use the right codec to create a dataset
			//from the input stream	
			ptr<dataSet> testDataSet = codecs::codecFactory::getCodecFactory()->load(reader);
			//read image
			ptr<image> firstImage = testDataSet->getImage(frameNumber);
			imbxUint32 width, height;
			firstImage->getSize(&width, &height);
			// Build the transforms chain
			ptr<transforms::transformsChain> chain(new transforms::transformsChain);
			//image should be processed by the modalityVOILUT
			ptr<transforms::transform> modVOILUT(new transforms::modalityVOILUT(testDataSet));
			chain->addTransform(modVOILUT);
			ptr<image> convertedImage(modVOILUT->allocateOutputImage(firstImage, width, height));
			//modVOILUT->runTransform(firstImage, 0, 0, width, height, convertedImage, 0, 0);
			//sometimes further processing may be required for presentation on the screen
			//voilut is used for converting pixel values
			ptr<transforms::VOILUT> myVoiLut(new transforms::VOILUT(testDataSet));
			//Apply the first VOI or LUT
			imbxUint32 lutId = myVoiLut->getVOILUTId(0);
			myVoiLut->setVOILUT(lutId);
			//prepare image for presentation
			ptr<image> presentationImage(myVoiLut->allocateOutputImage(convertedImage, width, height));
			myVoiLut->runTransform(convertedImage, 0, 0, width, height, presentationImage, 0, 0);
			//chain->addTransform(myVoiLut);

			//====================================================================================================View Test
			imbxInt32 iheight = height;
			imbxInt32 iwidth = width;

			myView myViewer(1, false);
			myViewer.setImage(convertedImage, chain);

			drawBitmap testBitmap(convertedImage, chain);
			//ptr<unsigned> bitMapMemory = NULL;
			//double * pointerToBitmap = reinterpret_cast <double*>( testBitmap.getBitmap<drawBitmapBGRA, 1 >(iheight, iwidth, (imbxInt32)0, (imbxInt32)0, iheight, iwidth, NULL));
			//myViewer.draw()
			//viev is an abstract class
			//====================================================================================================View Test

			cout << "testView end" << endl;

			return 0;
		}