⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 presetotf.cpp

📁 3D reconstruction, medical image processing from colons, using intel image processing for based clas
💻 CPP
字号:
// PresetWindowing.cpp: implementation of the RxPresetWindowing class.////////////////////////////////////////////////////////////////////////#include "stdafx.h"#include "fusion.h"#include "PresetOTF.h"#include "DlgPresetOTF.h"//////////////////////////////////////////////////////////////////////// Construction/Destruction//////////////////////////////////////////////////////////////////////RxPresetOTF::RxPresetOTF(){	m_nModality			= 1;	m_ArrayPresetOTF.SetSize(0, 5);}RxPresetOTF::~RxPresetOTF(){	RemoveAllPresetOTF();}void RxPresetOTF::CreatePresetOTFFile(UINT nModality){	int				i, iCount;	_PRESET_OTF		*pPresetOTF	= NULL;	int				iLevel		= 75;	int				iWidth		= 250;	if(nModality == 0)			// MR Default preset	{		iCount		= 0;	}	else if(nModality == 1)		// CT Default preset	{		iCount		= 15;		pPresetOTF	= new _PRESET_OTF[iCount];		// Aorta		_tcscpy(pPresetOTF[0].strTitle, _T("Aorta"));		pPresetOTF[0].iThreshold[0] =  150;		pPresetOTF[0].iThreshold[1] =  350;		pPresetOTF[0].iThreshold[2] = 1280;		pPresetOTF[0].iThreshold[3] = 1480;		for(i = 0; i < 4; i++)			pPresetOTF[0].crColor[i] = RGB(255, 255, 255);		pPresetOTF[0].iShadedLevel		= (pPresetOTF[0].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[0].iShadedWidth		= iWidth;		pPresetOTF[0].fShadedOpacity	= 1.0f;		pPresetOTF[0].iUnshadedLevel	= (pPresetOTF[0].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[0].iUnshadedWidth	= iWidth;		pPresetOTF[0].fUnshadedOpacity	= 0.6f;		// Artery		_tcscpy(pPresetOTF[1].strTitle, _T("Artery"));		pPresetOTF[1].iThreshold[0] =  150;		pPresetOTF[1].iThreshold[1] =  250;		pPresetOTF[1].iThreshold[2] = 1475;		pPresetOTF[1].iThreshold[3] = 1544;		for(i = 0; i < 4; i++)			pPresetOTF[1].crColor[i] = RGB(255, 255, 255);		pPresetOTF[1].iShadedLevel		= (pPresetOTF[1].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[1].iShadedWidth		= iWidth;		pPresetOTF[1].fShadedOpacity	= 1.0f;		pPresetOTF[1].iUnshadedLevel	= (pPresetOTF[1].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[1].iUnshadedWidth	= iWidth;		pPresetOTF[1].fUnshadedOpacity	= 0.6f;		// Bone		_tcscpy(pPresetOTF[2].strTitle, _T("Bone"));		pPresetOTF[2].iThreshold[0] =  120;		pPresetOTF[2].iThreshold[1] =  320;		pPresetOTF[2].iThreshold[2] = 1129;		pPresetOTF[2].iThreshold[3] = 1300;		for(i = 0; i < 4; i++)			pPresetOTF[2].crColor[i] = RGB(255, 255, 255);		pPresetOTF[2].iShadedLevel		= (pPresetOTF[2].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[2].iShadedWidth		= iWidth;		pPresetOTF[2].fShadedOpacity	= 1.0f;		pPresetOTF[2].iUnshadedLevel	= (pPresetOTF[2].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[2].iUnshadedWidth	= iWidth;		pPresetOTF[2].fUnshadedOpacity	= 0.6f;		// Circle of Willis		_tcscpy(pPresetOTF[3].strTitle, _T("Circle of Willis"));		pPresetOTF[3].iThreshold[0] =  170;		pPresetOTF[3].iThreshold[1] =  370;		pPresetOTF[3].iThreshold[2] =  965;		pPresetOTF[3].iThreshold[3] = 1165;		for(i = 0; i < 4; i++)			pPresetOTF[3].crColor[i] = RGB(255, 255, 255);		pPresetOTF[3].iShadedLevel		= (pPresetOTF[3].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[3].iShadedWidth		= iWidth;		pPresetOTF[3].fShadedOpacity	= 1.0f;		pPresetOTF[3].iUnshadedWidth	= iWidth;		pPresetOTF[3].iUnshadedLevel	= (pPresetOTF[3].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[3].fUnshadedOpacity	= 0.6f;		// Colon		_tcscpy(pPresetOTF[4].strTitle, _T("Colon"));		pPresetOTF[4].iThreshold[0] = -800;		pPresetOTF[4].iThreshold[1] = -720;		pPresetOTF[4].iThreshold[2] = -300;		pPresetOTF[4].iThreshold[3] = -220;		for(i = 0; i < 4; i++)			pPresetOTF[4].crColor[i] = RGB(255, 255, 255);		pPresetOTF[4].iShadedLevel		= (pPresetOTF[4].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[4].iShadedWidth		= iWidth;		pPresetOTF[4].fShadedOpacity	= 1.0f;		pPresetOTF[4].iUnshadedLevel	= (pPresetOTF[4].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[4].iUnshadedWidth	= iWidth;		pPresetOTF[4].fUnshadedOpacity	= 0.6f;		// Duct		_tcscpy(pPresetOTF[5].strTitle, _T("Duct"));		pPresetOTF[5].iThreshold[0] = -24;		pPresetOTF[5].iThreshold[1] = -13;		pPresetOTF[5].iThreshold[2] =  48;		pPresetOTF[5].iThreshold[3] =  59;		for(i = 0; i < 4; i++)			pPresetOTF[5].crColor[i] = RGB(255, 255, 255);			pPresetOTF[5].iShadedLevel		= (pPresetOTF[5].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[5].iShadedWidth		= iWidth;		pPresetOTF[5].fShadedOpacity	= 0.2f;		pPresetOTF[5].iUnshadedLevel	= (pPresetOTF[5].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[5].iUnshadedWidth	= iWidth;		pPresetOTF[5].fUnshadedOpacity	= 0.2f;		// Ext Vein		_tcscpy(pPresetOTF[6].strTitle, _T("Ext Vein"));		pPresetOTF[6].iThreshold[0] =  100;		pPresetOTF[6].iThreshold[1] =  200;		pPresetOTF[6].iThreshold[2] = 2000;		pPresetOTF[6].iThreshold[3] = 2100;		for(i = 0; i < 4; i++)			pPresetOTF[6].crColor[i] = RGB(255, 255, 255);		pPresetOTF[6].iShadedLevel		= (pPresetOTF[6].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[6].iShadedWidth		= iWidth;		pPresetOTF[6].fShadedOpacity	= 1.0f;		pPresetOTF[6].iUnshadedLevel	= (pPresetOTF[6].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[6].iUnshadedWidth	= iWidth;		pPresetOTF[6].fUnshadedOpacity	= 0.6f;		// Liver		_tcscpy(pPresetOTF[7].strTitle, _T("Liver"));		pPresetOTF[7].iThreshold[0] =  78;		pPresetOTF[7].iThreshold[1] = 108;		pPresetOTF[7].iThreshold[2] = 199;		pPresetOTF[7].iThreshold[3] = 218;		for(i = 0; i < 4; i++)			pPresetOTF[7].crColor[i] = RGB(255, 255, 255);		pPresetOTF[7].iShadedLevel		= (pPresetOTF[7].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[7].iShadedWidth		= iWidth;		pPresetOTF[7].fShadedOpacity	= 0.13f;		pPresetOTF[7].iUnshadedLevel	= (pPresetOTF[7].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[7].iUnshadedWidth	= iWidth;		pPresetOTF[7].fUnshadedOpacity	= 0.13f;		// Metalic Stent		_tcscpy(pPresetOTF[8].strTitle, _T("Metalic Stent"));		pPresetOTF[8].iThreshold[0] = 412;		pPresetOTF[8].iThreshold[1] = 585;		pPresetOTF[8].iThreshold[2] = 2926;		pPresetOTF[8].iThreshold[3] = 3071;		for(i = 0; i < 4; i++)			pPresetOTF[8].crColor[i] = RGB(255, 255, 255);		pPresetOTF[8].iShadedLevel		= (pPresetOTF[8].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[8].iShadedWidth		= iWidth;		pPresetOTF[8].fShadedOpacity	= 1.0f;		pPresetOTF[8].iUnshadedLevel	= (pPresetOTF[8].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[8].iUnshadedWidth	= iWidth;		pPresetOTF[8].fUnshadedOpacity	= 0.6f;				// Muscle		_tcscpy(pPresetOTF[9].strTitle, _T("Muscle"));		pPresetOTF[9].iThreshold[0] = 5;		pPresetOTF[9].iThreshold[1] = 25;		pPresetOTF[9].iThreshold[2] = 64;		pPresetOTF[9].iThreshold[3] = 74;		for(i = 0; i < 4; i++)			pPresetOTF[9].crColor[i] = RGB(255, 255, 255);		pPresetOTF[9].iShadedLevel		= (pPresetOTF[9].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[9].iShadedWidth		= iWidth;		pPresetOTF[9].fShadedOpacity	= 0.3f;		pPresetOTF[9].iUnshadedLevel	= (pPresetOTF[9].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[9].iUnshadedWidth	= iWidth;		pPresetOTF[9].fUnshadedOpacity	= 0.3f;		// Portal Vein		_tcscpy(pPresetOTF[10].strTitle, _T("Portal Vein"));		pPresetOTF[10].iThreshold[0] = 222;		pPresetOTF[10].iThreshold[1] = 282;		pPresetOTF[10].iThreshold[2] = 1023;		pPresetOTF[10].iThreshold[3] = 1129;		for(i = 0; i < 4; i++)			pPresetOTF[10].crColor[i] = RGB(255, 255, 255);		pPresetOTF[10].iShadedLevel		= (pPresetOTF[10].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[10].iShadedWidth		= iWidth;		pPresetOTF[10].fShadedOpacity	= 1.0f;		pPresetOTF[10].iUnshadedLevel	= (pPresetOTF[10].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[10].iUnshadedWidth	= iWidth;		pPresetOTF[10].fUnshadedOpacity	= 0.6f;		// Skin		_tcscpy(pPresetOTF[11].strTitle, _T("Skin"));		pPresetOTF[11].iThreshold[0] = -810;		pPresetOTF[11].iThreshold[1] = -766;		pPresetOTF[11].iThreshold[2] = -369;		pPresetOTF[11].iThreshold[3] = -325;		for(i = 0; i < 4; i++)			pPresetOTF[11].crColor[i] = RGB(255, 255, 255);		pPresetOTF[11].iShadedLevel		= (pPresetOTF[11].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[11].iShadedWidth		= iWidth;		pPresetOTF[11].fShadedOpacity	= 0.3f;		pPresetOTF[11].iUnshadedLevel	= (pPresetOTF[11].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[11].iUnshadedWidth	= iWidth;		pPresetOTF[11].fUnshadedOpacity	= 0.3f;		// Stomach		_tcscpy(pPresetOTF[12].strTitle, _T("Stomach"));		pPresetOTF[12].iThreshold[0] = -800;		pPresetOTF[12].iThreshold[1] = -720;		pPresetOTF[12].iThreshold[2] = -300;		pPresetOTF[12].iThreshold[3] = -220;		for(i = 0; i < 4; i++)			pPresetOTF[12].crColor[i] = RGB(255, 255, 255);		pPresetOTF[12].iShadedLevel		= (pPresetOTF[12].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[12].iShadedWidth		= iWidth;		pPresetOTF[12].fShadedOpacity	= 1.0f;		pPresetOTF[12].iUnshadedLevel	= (pPresetOTF[12].iThreshold[0] -iLevel) + 250 / 2;		pPresetOTF[12].iUnshadedWidth	= iWidth;		pPresetOTF[12].fUnshadedOpacity	= 0.6f;		// Tendon		_tcscpy(pPresetOTF[13].strTitle, _T("Tendon"));		pPresetOTF[13].iThreshold[0] =  44;		pPresetOTF[13].iThreshold[1] =  69;		pPresetOTF[13].iThreshold[2] = 143;		pPresetOTF[13].iThreshold[3] = 168;		pPresetOTF[13].crColor[0] = RGB(255, 255, 255);		pPresetOTF[13].crColor[1] = RGB(255, 0, 0);		pPresetOTF[13].crColor[2] = RGB(255, 0, 0);		pPresetOTF[13].crColor[3] = RGB(255, 255, 255);		pPresetOTF[13].iShadedLevel		= (pPresetOTF[13].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[13].iShadedWidth		= iWidth;		pPresetOTF[13].fShadedOpacity	= 0.5f;		pPresetOTF[13].iUnshadedLevel	= (pPresetOTF[13].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[13].iUnshadedWidth	= iWidth;		pPresetOTF[13].fUnshadedOpacity = 0.5f;		// Trachea		_tcscpy(pPresetOTF[14].strTitle, _T("Trachea"));		pPresetOTF[14].iThreshold[0] = -800;		pPresetOTF[14].iThreshold[1] = -720;		pPresetOTF[14].iThreshold[2] = -300;		pPresetOTF[14].iThreshold[3] = -220;			for(i = 0; i < 4; i++)			pPresetOTF[14].crColor[i] = RGB(255, 255, 255);		pPresetOTF[14].iShadedLevel		= (pPresetOTF[14].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[14].iShadedWidth		= iWidth;		pPresetOTF[14].fShadedOpacity	= 1.0f;		pPresetOTF[14].iUnshadedLevel	= (pPresetOTF[14].iThreshold[0] - iLevel) + 250 / 2;		pPresetOTF[14].iUnshadedWidth	= iWidth;		pPresetOTF[14].fUnshadedOpacity	= 1.0f;	}		CFile		file;	if(file.Open(m_strFileName, CFile::modeCreate|CFile::modeReadWrite))	{		file.Write(pPresetOTF, sizeof(_PRESET_OTF) * iCount);		file.Close();	}	if(pPresetOTF)			delete []pPresetOTF;}void RxPresetOTF::ReadPresetOTFFile(UINT nModality, LPCTSTR lpszFileName){	RemoveAllPresetOTF();	m_strFileName	= lpszFileName;	CFile	file;	// 蜡瓤己 八荤饶 利钦窍瘤 臼阑版快 颇老阑 积己茄促.	if(file.Open(m_strFileName, CFile::modeRead))	{		int		nFileLength = file.GetLength();		file.Close();		if(nFileLength == 0 || nFileLength % sizeof(_PRESET_OTF) != 0)			CreatePresetOTFFile(nModality);	}	else		CreatePresetOTFFile(nModality);	file.Open(m_strFileName, CFile::modeRead);	int			iFileLength	= file.GetLength();	int			iSizeStruct	= sizeof(_PRESET_OTF);	_PRESET_OTF	stPresetOTF;	for(int i = 0; i < iFileLength; i += iSizeStruct)	{		file.Seek(i, 0);		file.Read(&stPresetOTF, iSizeStruct);				AddPresetOTF(&stPresetOTF);	}	file.Close();}void RxPresetOTF::WritePresetOTFFile(){	CFile	file;	file.Open(m_strFileName, CFile::modeCreate|CFile::modeReadWrite);	int			iCount = m_ArrayPresetOTF.GetSize();	_PRESET_OTF_PTR	stpPresetOTF;	int				iSizeStruct	= sizeof(_PRESET_OTF);	for(int i = 0; i < iCount; i++)	{		stpPresetOTF = (_PRESET_OTF_PTR)m_ArrayPresetOTF.GetAt(i);		file.Seek(i * iSizeStruct, 0);		file.Write(stpPresetOTF, iSizeStruct);	}	file.Close();}int  RxPresetOTF::AddPresetOTF(_PRESET_OTF_PTR stpPresetOTF){	_PRESET_OTF_PTR	stpNewPresetOTF = new _PRESET_OTF;	memcpy(stpNewPresetOTF, stpPresetOTF, sizeof(_PRESET_OTF));	int		iArrayCount = m_ArrayPresetOTF.GetSize();	if(iArrayCount == 0)		m_ArrayPresetOTF.Add(stpNewPresetOTF);	else	{		_PRESET_OTF_PTR	stpCmpPresetOTF;		for(int i = 0; i <= iArrayCount; i++)		{			if(i == iArrayCount)				m_ArrayPresetOTF.Add(stpNewPresetOTF);			else			{				stpCmpPresetOTF = (_PRESET_OTF_PTR)m_ArrayPresetOTF.GetAt(i);				if(_tcsicmp(stpNewPresetOTF->strTitle, stpCmpPresetOTF->strTitle) < 0)				{					m_ArrayPresetOTF.InsertAt(i, stpNewPresetOTF);					return i;				}			}		}	}	return iArrayCount;}_PRESET_OTF_PTR RxPresetOTF::GetPresetOTF(UINT nIndex){	if(nIndex >= 0 && nIndex < (UINT)m_ArrayPresetOTF.GetSize())		return (_PRESET_OTF_PTR)m_ArrayPresetOTF.GetAt(nIndex);	else		return NULL;}int  RxPresetOTF::GetPresetOTFCount(){	return m_ArrayPresetOTF.GetSize();}void RxPresetOTF::RemovePresetOTF(UINT nIndex){	if(nIndex >= 0 && nIndex < (UINT)m_ArrayPresetOTF.GetSize())	{		_PRESET_OTF_PTR	stpPresetOTF = (_PRESET_OTF_PTR)m_ArrayPresetOTF.GetAt(nIndex);		delete stpPresetOTF;		m_ArrayPresetOTF.RemoveAt(nIndex);	}}void RxPresetOTF::RemoveAllPresetOTF(){	UINT			nCount = m_ArrayPresetOTF.GetSize();	_PRESET_OTF_PTR	stpPresetOTF;	for(UINT i = 0; i < nCount; i++)	{		stpPresetOTF = (_PRESET_OTF_PTR)m_ArrayPresetOTF.GetAt(i);		delete stpPresetOTF;	}	m_ArrayPresetOTF.RemoveAll();}void RxPresetOTF::ShowPresetOTFDialog(int iLevel, int iWidth){	RxDlgPresetOTF		dlg;	dlg.DoModal();	WritePresetOTFFile();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -