39 #include "wx/artprov.h"
61 : wxPanel(parent, id, pos, size, style)
63 m_mgr.SetManagedWindow(
this);
101 : wxPanel(parent, id, pos, size, style)
103 m_mgr.SetManagedWindow(
this);
121 m_notebook_style =wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_EXTERNAL_MOVE | wxNO_BORDER;
135 if(images.size() > 0)
148 #if defined(__GNUC__)
149 std::string str_home(getenv(
"HOME"));
150 #elif defined(_WIN32)
151 std::string str_home(getenv(
"USERPROFILE"));
153 std::string strCreaContourDataTmp = str_home +
"/.creaContourDataTemp/";
155 std::vector<std::string> conceptNameVect;
156 std::vector<int> conceptSizeVect;
238 wxSize client_size = GetClientSize();
239 wxAuiNotebook* noteBook =
new wxAuiNotebook(
this, -1, wxPoint(client_size.x, client_size.y), wxSize(430,200),
m_notebook_style);
240 wxBitmap page_bmp = wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16,16));
266 m_mgr.AddPane(
notebook, wxAuiPaneInfo().Name(wxT(
"notebook_content")).CenterPane().PaneBorder(
false));
269 SetMinSize(wxSize(300,300));
277 bool configured = panel!=NULL;
278 configured &= panel!=NULL;
282 notebook->AddPage( panel, wxT(
" Viewer "),
true );
394 std::vector<int> instantVector;
402 bool addedModel = theName.compare(
"") != 0;
419 std::vector<int> instantVector;
427 bool addedModel = theName.compare(
"") != 0;
441 manualContourModelBullEye *manModelContourBullEye =
new manualContourModelBullEye();
442 manualBaseModel *manModelContour=NULL;
443 manModelContour = manModelContourBullEye;
445 int iCrown,sizeCrowns,iSector,sizeSectors;
446 double radioA,radioB,ang,angDelta ;
448 for ( iCrown=0 ; iCrown<sizeCrowns ; iCrown++ )
452 if (iCrown==sizeCrowns-1)
460 for ( iSector=0 ; iSector<sizeSectors ; iSector++ )
464 manModelContourBullEye->AddSector(radioA,radioB,ang,angDelta);
469 return manModelContour;
482 std::vector<std::string> lstKeyNameToBeErase;
531 int i,size=keyNamesVector.size();
551 if (isedit && ispartofstaticlst)
582 std::vector<int> tempVector;
646 vtkImageData * value;
647 this->
getMaskValue(&mask, &value, typeContourGroup, selection, minZ, maxZ);
649 std::vector<int> nTypeView;
650 nTypeView.push_back(5);
651 nTypeView.push_back(1);
652 nTypeView.push_back(2);
653 nTypeView.push_back(0);
655 wxFrame *frame =
new wxFrame(
this, -1,_T(
"Result image extracted.."),wxDefaultPosition,wxSize(600,600), wxDEFAULT_FRAME_STYLE|wxSTAY_ON_TOP);
656 wxAuiManager *m_mgr_noteBookViewerResult =
new wxAuiManager();
657 m_mgr_noteBookViewerResult->SetManagedWindow(frame);
659 wxAuiNotebook* noteBookViewerResult =
new wxAuiNotebook(frame, -1, wxPoint(600, 600), wxSize(430,200),
m_notebook_style);
660 m_mgr_noteBookViewerResult->AddPane(noteBookViewerResult, wxAuiPaneInfo().Name(wxT(
"notebook_content")).CenterPane().PaneBorder(
false));
662 wxPanel *panelViewer1 =
new wxMaracas_N_ViewersWidget(noteBookViewerResult, value,&nTypeView);
663 wxPanel *panelViewer2 =
new wxMaracas_N_ViewersWidget(noteBookViewerResult, mask,&nTypeView);
666 noteBookViewerResult->AddPage( panelViewer1, wxT(
"Image result") );
667 noteBookViewerResult->AddPage( panelViewer2, wxT(
"Mask result") );
668 m_mgr_noteBookViewerResult->Update();
677 std::vector<int> instantVect;
679 int actualSlice = instantVect[1];
688 vtkImageData *mask, *value;
737 std::vector<int> inst;
764 std::vector<int> tempVector;
776 if ( theStartCommand ==
COPY )
781 std::vector<int> tempVector;
785 int i,size = elems.size();
786 for( i=0; i<size; i++ )
793 std::string filename;
802 std::string filename;
824 double pnt1X = refPoint1->GetX();
825 double pnt1Y = refPoint1->GetY();
827 double pnt2X = refPoint2->GetX();
828 double pnt2Y = refPoint2->GetY();
831 double angle = (atan2(pnt2Y - pnt1Y, pnt2X - pnt1X) * 180 / 3.1415926535897932384626433832795)+90;
832 vtkTransform *t = vtkTransform::New();
836 t->Translate(-pnt1X, -pnt1Y, 0);
840 t->Translate(pnt1X, pnt1Y, 0);
843 int i,size=manualModel->GetSizeLstPoints();
846 manualPoint * mp = manualModel->GetManualPoint(i);
852 t->TransformPoint( vecIn, vecOut );
853 mp->SetPointX( vecOut[0] );
854 mp->SetPointY( vecOut[1] );
855 mp->SetPointZ( vecOut[2] );
973 wxFileDialog dialog(NULL, _T(
"Choose a file"), _T(
""), _T(
""), _T(
"*.roi"), wxOPEN );
974 if (dialog.ShowModal() == wxID_OK)
976 fileNameContourROI = (
const char *)(dialog.GetPath().mb_str());
986 printf(
"EED wxContourMainFrame::SetZForAllContours\n");
990 std::vector< std::string > lstNameThings;
991 int i,sizeLstNameThings;
992 int ii,sizeLstPoints;
995 sizeLstNameThings = lstNameThings.size();
996 for (i=0 ; i<sizeLstNameThings ; i++)
998 printf(
"EED wxContourMainFrame::SetZForAllContours contour=%d \n", i );
1000 sizeLstPoints = manualModel->GetSizeLstPoints();
1001 for (ii=0 ; ii<sizeLstPoints ; ii++)
1003 manualModel->GetManualPoint(ii)->SetPointZ(-900);
1010 sizeLstNameThings = lstNameThings.size();
1011 for (i=0 ; i<sizeLstNameThings ; i++)
1014 sizeLstPoints = manualModel->GetSizeLstPoints();
1015 for (ii=0 ; ii<sizeLstPoints ; ii++)
1017 manualModel->GetManualPoint(ii)->SetPointZ(-900);
1029 FILE *pFile =fopen(fileNameContourROI.c_str(),
"r+");
1036 fileNameContourROI.append(
"data");
1037 FILE *pFileData=fopen(fileNameContourROI.c_str(),
"r+");
1038 if(pFileData != NULL)
1040 fscanf(pFileData,
"%s",tmpD);
1041 fscanf(pFileData,
"%s",tmpD);
1042 fscanf(pFileData,
"%s",tmpD);
1044 fscanf(pFileData,
"%s",tmpD);
1045 fscanf(pFileData,
"%s",tmpD);
1047 fscanf(pFileData,
"%s",tmpD);
1048 fscanf(pFileData,
"%s",tmpD);
1051 fscanf(pFile,
"%s",tmp);
1053 fscanf(pFile,
"%s",tmp);
1054 fscanf(pFile,
"%s",tmp);
1055 std::string version(tmp);
1058 printf(
"EED wxContourMainFrame::onLoadContours version%s \n", version.c_str() );
1063 if (version==
"1.0.3")
1070 if (version==
"1.0.2")
1081 else if (version==
"1.0.1")
1088 else if (version==
"1.0.0")
1095 if(pFileData != NULL)
1107 std::string filename, filenamecontours;
1108 wxFileDialog dialog(NULL, _T(
"Choose a XML Osirix File"), _T(
""), _T(
""), _T(
"*.xml"), wxOPEN );
1110 if (dialog.ShowModal() == wxID_OK)
1112 filename = dialog.GetPath().mb_str();
1115 if(filenamecontours.compare(
"") != 0){
1122 std::string filename, filenamecontours;
1123 wxFileDialog dialog(NULL, _T(
"Choose a File"), _T(
""), _T(
""), _T(
"*.*"), wxOPEN );
1125 if (dialog.ShowModal() == wxID_OK)
1127 filename = dialog.GetPath().mb_str();
1128 std::cout <<
"This is the filename: " << filename << std::endl;
1139 wxFileDialog dialog(NULL, _T(
"Choose a file"), _T(
""), _T(
""), _T(
"*.roi"), wxSAVE );
1140 if (dialog.ShowModal() == wxID_OK)
1142 std::string fileNameContourROI = (
const char *)(dialog.GetPath().mb_str());
1152 std::cout<<
"Nombre del archivo: "<<fileNameContourROI<<std::endl;
1163 FILE *pFile=fopen(filename.c_str(),
"w+");
1166 filename.append(
"data");
1167 std::cout<<
"Nombre del archivo: "<<filename<<std::endl;
1168 FILE *pFileData=fopen(filename.c_str(),
"w+");
1171 std::vector< std::string > lstNameThings;
1172 int i,sizeLstNameThings;
1174 fprintf(pFile,
"--CreaContour--\n");
1175 fprintf(pFile,
"Version %s\n",
"1.0.3" );
1178 fprintf(pFileData,
"--CreaContour--\n");
1179 fprintf(pFileData,
"Version %s\n",
"1.0.3" );
1184 vtkImageData *image =
_images[0];
1187 image->GetDimensions(dimRange);
1189 fprintf(pFile,
"ImageDimensions %d %d %d\n", dimRange[0], dimRange[1], dimRange[2] );
1192 image->GetSpacing(spaRange);
1194 fprintf(pFile,
"ImageSpacing %f %f %f\n", spaRange[0], spaRange[1], spaRange[2] );
1199 sizeLstNameThings = lstNameThings.size();
1200 fprintf(pFile,
"NumberOfContours %d\n", sizeLstNameThings );
1203 fprintf(pFileData,
"NumberOfContours %d\n", sizeLstNameThings );
1206 for (i=0 ; i<sizeLstNameThings ; i++)
1210 double sizeInPixel = manualModel ->GetPathSize();
1212 manualModel ->SetRealSize(realContourSize);
1227 sizeLstNameThings = lstNameThings.size();
1228 fprintf(pFile,
"NumberOfContoursStatic %d\n", sizeLstNameThings );
1231 fprintf(pFileData,
"NumberOfContoursStatic %d\n", sizeLstNameThings );
1234 for (i=0 ; i<sizeLstNameThings ; i++)
1249 double imageSpac[3];
1250 vtkImageData *image =
_images[0];
1251 image->GetDimensions(imageDim);
1252 image->GetSpacing(imageSpac);
1254 fscanf(pFile,
"%s",tmp);
1255 fscanf(pFile,
"%s",tmp);
1257 fscanf(pFile,
"%s",tmp);
1259 fscanf(pFile,
"%s",tmp);
1262 fscanf(pFile,
"%s",tmp);
1263 fscanf(pFile,
"%s",tmp);
1265 fscanf(pFile,
"%s",tmp);
1267 fscanf(pFile,
"%s",tmp);
1271 if (interactiveOption==
true)
1276 wxDialog* dial =
new wxDialog (
this,-1,_T(
"Tools"),wxDefaultPosition, wxSize(460,360));
1277 wxSizer* buttonsSizer = dial->CreateSeparatedButtonSizer(wxOK|wxCANCEL);
1278 wxBoxSizer *dialSizer =
new wxBoxSizer(wxVERTICAL);
1280 wxString lstOptOperation[2];
1281 lstOptOperation[0]=_T(
"By Dimension");
1282 lstOptOperation[1]=_T(
"By Spacing");
1283 wxRadioBox * radioOpts =
new wxRadioBox(dial, -1, _T(
"Type of Transformation"), wxDefaultPosition, wxSize(270,45), 2 , lstOptOperation, 2, wxRA_SPECIFY_COLS);
1285 dialSizer->Add(
new wxStaticText(dial,-1,_T(
"The image resolution is not compatible with the ")) , 0, wxGROW );
1286 dialSizer->Add(
new wxStaticText(dial,-1,_T(
"selected Roi file. Do you want to tranform it?")) , 0, wxGROW );
1287 dialSizer->Add(
new wxStaticText(dial,-1,_T(
" ")) , 0, wxGROW );
1288 dialSizer->Add(radioOpts,0,wxGROW);
1289 dialSizer->Add(
new wxStaticText(dial,-1,_T(
" ")) , 0, wxGROW );
1290 dialSizer->Add(buttonsSizer,0,wxGROW);
1291 dial->SetSizer(dialSizer,
true);
1298 if (dial->GetReturnCode() == wxID_OK)
1300 _tmpReadFileTypeOfTransformation = radioOpts->GetSelection();
1316 vtkImageData *image =
_images[0];
1319 double imageSpac[3];
1320 image->GetDimensions(imageDim);
1321 image->GetSpacing(imageSpac);
1324 fscanf(pFile,
"%s",tmp);
1325 fscanf(pFile,
"%s",tmp);
1326 int numberOfContours = atoi(tmp);
1328 std::vector<int> instantVector;
1329 int typeContourModel;
1330 manualBaseModel *manModelContour;
1398 for (i=0;i<numberOfContours;i++)
1400 instantVector.clear();
1401 fscanf(pFile,
"%s",tmp);
1403 fscanf(pFile,
"%s",tmp);
1404 instantVector.push_back( atoi(tmp) );
1405 fscanf(pFile,
"%s",tmp);
1406 instantVector.push_back( atoi(tmp) );
1407 fscanf(pFile,
"%s",tmp);
1408 instantVector.push_back( atoi(tmp) );
1409 fscanf(pFile,
"%s",tmp);
1410 instantVector.push_back( atoi(tmp) );
1411 fscanf(pFile,
"%s",tmp);
1412 instantVector.push_back( atoi(tmp) );
1413 fscanf(pFile,
"%s",tmp);
1414 instantVector.push_back( atoi(tmp) );
1416 fscanf(pFile,
"%s",tmp);
1417 fscanf(pFile,
"%s",tmp);
1418 typeContourModel = atoi(tmp);
1421 manModelContour->Open(pFile);
1422 if(pFileData != NULL)
1424 manModelContour->OpenData(pFileData);
1430 double transX, transY;
1433 manModelContour->Transform_Ax_Plus_B(transX,0,transY,0);
1435 double transX, transY;
1438 manModelContour->Transform_Ax_Plus_B(transX,0,transY,0);
1441 fscanf(pFile,
"%s",tmp);
1442 fscanf(pFile,
"%s",tmp);
1443 typeView = atoi(tmp);
1445 std::string theName;
1447 bool addedModel = theName.compare(
"") != 0;
1460 Instant instant(&instantVector);
1496 int typeofcontour = 1;
1501 typedef float InternalPixelType;
1502 const unsigned int Dimension = 2;
1503 typedef itk::Image< InternalPixelType, Dimension > InternalImageType;
1506 typedef unsigned char OutputPixelType;
1507 typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
1510 typedef unsigned short OutputPixelType2;
1511 typedef itk::Image< OutputPixelType2, Dimension > OutputImageType2;
1514 typedef itk::BinaryThresholdImageFilter<
1516 OutputImageType > ThresholdingFilterType;
1519 typedef itk::CastImageFilter<
1520 OutputImageType, OutputImageType2 > CastFilterType;
1523 typedef itk::CastImageFilter<
1524 OutputImageType2, InternalImageType > CastFilterType2;
1527 typedef itk::RescaleIntensityImageFilter<
1529 OutputImageType > CastFilterType3;
1532 typedef itk::RescaleIntensityImageFilter<
1534 OutputImageType > CastFilterType4;
1536 ThresholdingFilterType::Pointer thresholder = ThresholdingFilterType::New();
1538 thresholder->SetLowerThreshold( 0.0 );
1539 thresholder->SetUpperThreshold( 128 );
1541 thresholder->SetOutsideValue( 255 );
1542 thresholder->SetInsideValue( 0 );
1549 ConnectorType::Pointer connector= ConnectorType::New();
1550 ConnectorType2::Pointer connector2= ConnectorType2::New();
1553 CastFilterType::Pointer filter=CastFilterType::New();
1554 CastFilterType2::Pointer filter2=CastFilterType2::New();
1556 connector->SetInput( imagedata );
1557 filter2->SetInput(connector->GetOutput());
1559 typedef itk::CurvatureAnisotropicDiffusionImageFilter<
1561 InternalImageType > SmoothingFilterType;
1563 SmoothingFilterType::Pointer smoothing = SmoothingFilterType::New();
1565 typedef itk::GradientMagnitudeRecursiveGaussianImageFilter<
1567 InternalImageType > GradientFilterType;
1569 typedef itk::SigmoidImageFilter<
1571 InternalImageType > SigmoidFilterType;
1573 GradientFilterType::Pointer gradientMagnitude = GradientFilterType::New();
1575 SigmoidFilterType::Pointer sigmoid = SigmoidFilterType::New();
1577 sigmoid->SetOutputMinimum( 0.0 );
1578 sigmoid->SetOutputMaximum( 255.0 );
1581 typedef itk::FastMarchingImageFilter<
1583 InternalImageType > FastMarchingFilterType;
1586 FastMarchingFilterType::Pointer fastMarching = FastMarchingFilterType::New();
1588 printf(
"EED wxContourMainFrame::SegmentationOneSliceITK Skypping this code. Not compiling GeodesicActiveContourLevelSetImageFilter in fedora 17 with ITK 3.20.1 \n ");
1632 smoothing->SetTimeStep( 0.125 );
1633 smoothing->SetNumberOfIterations( 5 );
1634 smoothing->SetConductanceParameter( 9.0 );
1637 const double sigma = atof( crea::wx2std(sigm).c_str() );
1638 gradientMagnitude->SetSigma( sigma );
1640 const double alpha = atof( crea::wx2std(alf).c_str() );
1641 const double beta = atof( crea::wx2std(bet).c_str() );
1643 sigmoid->SetAlpha( alpha );
1644 sigmoid->SetBeta( beta );
1646 typedef FastMarchingFilterType::NodeContainer NodeContainer;
1647 typedef FastMarchingFilterType::NodeType NodeType;
1649 NodeContainer::Pointer seeds = NodeContainer::New();
1651 InternalImageType::IndexType seedPosition;
1652 seedPosition[0] = x;
1653 seedPosition[1] = y;
1655 const double initialDistance = atof( crea::wx2std(distanc).c_str() );
1659 const double seedValue = - initialDistance;
1661 node.SetValue( seedValue );
1662 node.SetIndex( seedPosition );
1664 seeds->Initialize();
1665 seeds->InsertElement( 0, node );
1667 fastMarching->SetTrialPoints( seeds );
1669 fastMarching->SetSpeedConstant( 1.0 );
1671 fastMarching->SetOutputSize(
1672 connector->GetOutput()->GetBufferedRegion().GetSize() );
1674 fastMarching->SetStoppingValue( 800 );
1678 connector2->Update();
1679 vtkImageData *idata = connector2->GetOutput();
1681 vtkMarchingContourFilter* cntVTK = vtkMarchingContourFilter::New( );
1683 cntVTK->SetInput( idata );
1685 cntVTK->SetNumberOfContours( 1 );
1686 cntVTK->SetValue( 0, 255 );
1688 cntVTK->UpdateInformation();
1690 vtkCleanPolyData* cpd = vtkCleanPolyData::New( );
1691 cpd->SetInput( cntVTK->GetOutput( ) );
1693 cpd->UpdateInformation();
1695 vtkPolyDataConnectivityFilter* conn = vtkPolyDataConnectivityFilter::New( );
1696 conn->SetExtractionModeToLargestRegion( );
1697 conn->SetInput( cpd->GetOutput( ) );
1699 conn->UpdateInformation();
1701 vtkStripper* vtkstripper = vtkStripper::New( );
1702 vtkstripper->SetInput( conn->GetOutput() );
1703 vtkstripper->Update();
1704 vtkstripper->UpdateInformation();
1706 vtkPolyData* polyDataResult = cntVTK->GetOutput();
1708 polyDataResult->Update( );
1709 polyDataResult->UpdateInformation();
1728 std::vector<double> vecX;
1729 std::vector<double> vecY;
1730 std::vector<double> vecXo;
1731 std::vector<double> vecYo;
1732 std::vector<double>::iterator vecXoi;
1733 std::vector<double>::iterator vecYoi;
1734 std::vector<double> vecZ;
1736 std::vector<double> vecCtrlPointX;
1737 std::vector<double> vecCtrlPointY;
1738 std::vector<double> vecCtrlPointZ;
1744 int ii,size=polyDataResult->GetNumberOfPoints();
1746 myfile.open (
"C:/Creatis/example2.txt");
1748 size=polyDataResult->GetNumberOfPoints();
1749 for (ii=0;ii<size;ii++)
1756 p = polyDataResult->GetPoint(ii);
1782 vecXo.push_back(p[0]);
1783 vecYo.push_back(p[1]);
1787 vecX.push_back( p[0] );
1788 myfile <<p[0]<<
","<<p[1]<<
"\n";
1792 vecY.push_back( p[1] );
1793 vecZ.push_back( 900 );
1801 while(!vecXo.empty())
1803 vecX.push_back(vecXo.back());
1806 vecZ.push_back( 900 );
1808 while(!vecYo.empty())
1810 vecY.push_back(vecYo.back());
1831 ExtractControlPoints2D *extractcontrolpoints2d =
new ExtractControlPoints2D();
1833 extractcontrolpoints2d->SetContour( &vecX , &vecY , &vecZ );
1837 extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
1839 else if (method==1){
1840 extractcontrolpoints2d->GetControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
1842 else if (method==2){
1843 extractcontrolpoints2d->SetSamplingControlPoints( 15 );
1844 extractcontrolpoints2d->GetSamplingControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
1848 std::vector<int> actualInstantVector;
1850 actualInstantVector[1]=z;
1852 int j,sizeCtrPt = vecCtrlPointX.size();
1855 manModelContour->SetNumberOfPointsSpline( ((sizeCtrPt/100)+1)*100 );
1857 for (j=0 ; j<sizeCtrPt ; j++)
1859 manModelContour->AddPoint( vecCtrlPointX[j] , vecCtrlPointY[j] , vecCtrlPointZ[j] );
1861 std::string theName;
1864 bool addedModel = theName.compare(
"") != 0;
1931 catch( itk::ExceptionObject & excep )
1933 std::cerr <<
"Exception caught !" << std::endl;
1934 std::cerr << excep << std::endl;
1955 int typeofcontour = 1;
1962 vtkImageReslice *imageReslice = vtkImageReslice::New();
1970 imageReslice->SetInput( imagedata );
1971 imageReslice->SetInformationInput(imagedata);
1972 imageReslice->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
1973 imageReslice->SetResliceAxesOrigin(0,0,z);
1974 imageReslice->SetOutputDimensionality(2);
1975 imageReslice->SetInterpolationModeToLinear();
1977 imagedata = imageReslice->GetOutput();
1978 imagedata->Update();
1979 imagedata->UpdateInformation();
1981 vtkContourFilter* cntVTK = vtkContourFilter::New( );
1982 cntVTK->SetInput( imagedata );
1984 cntVTK->SetNumberOfContours( 1 );
1987 cntVTK->SetValue( 1, isovalue );
1990 cntVTK->UpdateInformation();
1992 vtkCleanPolyData* cpd = vtkCleanPolyData::New( );
1993 cpd->SetInput( cntVTK->GetOutput( ) );
1994 cpd->ConvertLinesToPointsOff( );
1996 cpd->UpdateInformation();
1998 vtkPolyDataConnectivityFilter* conn = vtkPolyDataConnectivityFilter::New( );
1999 conn->SetExtractionModeToClosestPointRegion( );
2002 conn->SetInput( cpd->GetOutput( ) );
2004 conn->SetClosestPoint( x, y, 0 );
2006 conn->UpdateInformation();
2008 vtkCleanPolyData* cpd2 = vtkCleanPolyData::New( );
2009 cpd2->SetInput( conn->GetOutput( ) );
2011 cpd2->UpdateInformation();
2013 vtkStripper* vtkstripper = vtkStripper::New( );
2014 vtkstripper->SetInput( cpd2->GetOutput() );
2015 vtkstripper->Update();
2016 vtkstripper->UpdateInformation();
2019 vtkPolyData* polyDataResult = vtkstripper->GetOutput();
2021 polyDataResult->Update( );
2022 polyDataResult->UpdateInformation();
2042 std::vector<double> vecX;
2043 std::vector<double> vecY;
2044 std::vector<double> vecZ;
2046 std::vector<double> vecCtrlPointX;
2047 std::vector<double> vecCtrlPointY;
2048 std::vector<double> vecCtrlPointZ;
2052 int ii,size=polyDataResult->GetNumberOfPoints();
2054 for (ii=1;ii<=size;ii++)
2056 id = polyDataResult->GetLines()->GetData()->GetValue(ii);
2057 p = polyDataResult->GetPoint(
id);
2060 vecX.push_back( p[0] );
2061 vecY.push_back( p[1] );
2062 vecZ.push_back( 900 );
2067 ExtractControlPoints2D *extractcontrolpoints2d =
new ExtractControlPoints2D();
2068 extractcontrolpoints2d->SetContour( &vecX , &vecY , &vecZ );
2083 extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
2085 else if (method==1){
2086 extractcontrolpoints2d->GetControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
2088 else if (method==2){
2089 extractcontrolpoints2d->SetSamplingControlPoints( sampling );
2090 extractcontrolpoints2d->GetSamplingControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
2095 std::vector<int> actualInstantVector;
2097 actualInstantVector[1]=z;
2099 int j,sizeCtrPt = vecCtrlPointX.size();
2101 manModelContour->SetNumberOfPointsSpline( ((sizeCtrPt/100)+1)*100 );
2103 for (j=0 ; j<sizeCtrPt ; j++)
2105 manModelContour->AddPoint( vecCtrlPointX[j] , vecCtrlPointY[j] , vecCtrlPointZ[j] );
2107 std::string theName;
2110 bool addedModel = theName.compare(
"") != 0;
2142 double totalZ = maxZ-minZ+1;
2143 for( z=minZ ; z<=maxZ ; z++ )
2145 porcent = 100.0* (z-minZ)/totalZ;
2146 tmpString.Printf(_T(
" %d %c %d/%d %d"), (
int)porcent , 37 , z-minZ+1, (
int)totalZ,z );
2165 vtkimagedata->GetSpacing(spc);
2184 vtkInteractorStyleBaseView* style = (vtkInteractorStyleBaseView*)viewer2D->GetInteractorStyleBaseView();
2247 vtkInteractorStyleBaseView* style = (vtkInteractorStyleBaseView*)viewer2D->GetInteractorStyleBaseView();
2271 std::vector<std::string> filterCurrentSelection;
2273 std::vector<int> tempVector;
2281 if ( theStartCommand ==
COPY )
2286 std::vector<int> tempVector;
2290 int i,size = elems.size();
2291 for( i=0; i<size; i++ )
2311 int elementsSelected = currentSelection.size();
2313 if ( elementsSelected >= 1 ){
2318 std::vector<int> tempVector;
2320 Instant instant(&tempVector);
2322 int i , size=currentSelection.size();
2323 for ( i=0 ; i<size ; i++ )
2391 std::vector<double> vecX;
2392 std::vector<double> vecY;
2393 std::vector<double> vecZ;
2395 std::vector<int> tempVector;
2404 std::vector<int> tempVector;
2410 int sizeLstContourThings;
2411 for ( z=minZ ; z<=maxZ ; z++ )
2414 Instant instant(&tempVector);
2416 sizeLstContourThings = lstContourThings.size();
2417 if (sizeLstContourThings>=1)
2419 std::vector<double> vecX;
2420 std::vector<double> vecY;
2421 std::vector<double> vecZ;
2423 manualBaseModel *cModel = (*contourthing)->
getModel();
2424 int i,size = cModel->GetNumberOfPointsSpline();
2426 for (i=0; i<size; i++)
2428 cModel->GetSpline_i_Point(i, &x, &y, &z);
2445 std::vector<double> vecCtrlPointX;
2446 std::vector<double> vecCtrlPointY;
2447 std::vector<double> vecCtrlPointZ;
2451 std::vector<int> tempVector;
2460 double totalZ = maxZ-minZ+1;
2464 for ( z=(
int)minZ ; z<=(int)maxZ ; z++ )
2466 porcent = 100.0* (z-minZ)/totalZ;
2467 int numero = (int)(z-minZ+1)/(int)totalZ;
2472 int typeofcontour = 1;
2473 std::string theName;
2474 manualBaseModel* manModelContour =
kernelManager->
GetPoints(z, type, &vecCtrlPointX,&vecCtrlPointY,&vecCtrlPointZ, theName,typeofcontour, tempVector);
2476 if( manModelContour!=NULL ){
2487 int numero = (int)(z-minZ+1)/(int)totalZ;
2500 std::vector<int> tempVector;
2503 tempVector[1]=slide;
2518 wxString tempString;
2519 int maxContourGroup = 0;
2523 std::vector<manualBaseModel*> lstManConMod;
2524 std::vector<manualBaseModel*> lstManConModTmp;
2525 std::vector<manualBaseModel*> lstManConModExp;
2526 std::vector<double> pLstValue;
2527 std::vector<double> pLstValuePosX;
2528 std::vector<double> pLstValuePosY;
2529 std::vector<double> pLstValuePosZ;
2532 int resultGrayRangeCount;
2535 double resultAverage;
2536 double resultStandardeviation;
2538 std::vector<int> tempVector;
2544 int ii,sizeLstContourThings;
2555 int actualSlice = tempVector[1];
2564 totalZ = maxZ-minZ+1;
2570 for ( z=minZ ; z<=maxZ ; z++ )
2573 porcent = 100.0* (z-minZ)/totalZ;
2574 tmpString.Printf(_T(
" %d %c %d/%d %d"), (
int)porcent , 37 , z-minZ+1, (
int)totalZ ,z);
2583 Instant instant(&tempVector);
2585 sizeLstContourThings = lstContourThings.size();
2587 lstManConMod.clear();
2588 for (ii=0 ; ii<sizeLstContourThings ; ii++)
2591 lstManConMod.push_back( (*contourthing)->getModel() );
2596 tempString.Printf(_T(
"%d - %d"),z, sizeLstContourThings);
2600 int iContourGroup,sizeContourGroup;
2601 if (typeContourGroup==3)
2603 sizeContourGroup=lstManConModExp.size();
2604 if ( maxContourGroup<sizeContourGroup )
2606 maxContourGroup=sizeContourGroup;
2615 for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
2616 lstManConModTmp.clear();
2620 if (typeContourGroup==3)
2622 lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
2624 lstManConModTmp = lstManConModExp;
2631 pLstValuePosX.clear();
2632 pLstValuePosY.clear();
2633 pLstValuePosZ.clear();
2643 resultSize=numberOfPixels;
2648 &resultGrayRangeCount,
2653 &resultStandardeviation);
2662 tempString.Printf(_T(
"%d"),numberOfPixels);
2666 tempString.Printf(_T(
"%d"),resultGrayRangeCount);
2669 tempString.Printf(_T(
"%f"),resultMin);
2672 tempString.Printf(_T(
"%f"),resultMax);
2675 tempString.Printf(_T(
"%f"),resultAverage);
2678 tempString.Printf(_T(
"%f"),resultStandardeviation);
2688 int vol_rCountRange;
2690 double vol_minValue;
2691 double vol_maxValue;
2693 double vol_standardeviation;
2699 &vol_minValue, &vol_maxValue,
2700 &vol_average, &vol_standardeviation);
2704 tempString.Printf(_T(
"%d"),vol_rsize);
2707 tempString.Printf(_T(
"%d"),vol_rCountRange);
2710 tempString.Printf(_T(
"%f"),vol_minValue);
2713 tempString.Printf(_T(
"%f"),vol_maxValue);
2716 tempString.Printf(_T(
"%f"),vol_average);
2719 tempString.Printf(_T(
"%f"),vol_standardeviation);
2725 wxString tmpTitleString;
2727 for ( iTitleGroup=0 ; iTitleGroup<maxContourGroup ; iTitleGroup++ )
2730 tmpTitleString.Printf(_T(
"%d-Size Data"),iTitleGroup);
2746 int typeContourGroup,
int selection,
int minZ,
int maxZ,
bool XYZValues,
bool contourImage,
bool statistics)
2755 vtkImageData * mask;
2756 vtkImageData * value;
2757 this->
getMaskValue(&mask, &value, typeContourGroup,selection,minZ,maxZ);
2763 std::ostringstream name;
2764 name << filename <<
".xls";
2767 FILE *pFile=fopen(name.str().c_str(),
"w+");
2780 for ( iTitle=0; iTitle<sizeTitle ; iTitle++)
2783 fprintf(pFile,
"slice\t %d-Size \t SizeRange \t Min \t Max \t Ave \t StDv \t" , iTitle );
2785 fprintf(pFile,
"\n\n" );
2791 std::vector<int> tempVector;
2793 int actualSlice = tempVector[1];
2799 for ( j=minZ; j<=maxZ ; j++)
2801 fprintf(pFile,
"%d\t" , j );
2802 for (i=0 ; i<maxX ; i++){
2804 fprintf(pFile,
"%s\t" , (
const char *)(tmpString.mb_str()) );
2806 fprintf(pFile,
"\n" );
2813 fprintf(pFile,
"\n Total:\t" );
2814 for (i=0 ; i<maxX ; i++){
2816 fprintf(pFile,
"%s\t" , (
const char *)(tmpString.mb_str()) );
2818 fprintf(pFile,
"\n" );
2834 std::vector<manualBaseModel*> lstManConMod;
2835 std::vector<manualBaseModel*> lstManConModTmp;
2836 std::vector<manualBaseModel*> lstManConModExp;
2837 std::vector<double> pLstValue;
2838 std::vector<double> pLstValuePosX;
2839 std::vector<double> pLstValuePosY;
2840 std::vector<double> pLstValuePosZ;
2842 std::vector<int> tempVector;
2848 int ii,sizeLstContourThings;
2857 totalZ = maxZ-minZ+1;
2862 for ( z=0 ; z<sizeZ ; z++)
2865 porcent = 100.0* (z-minZ)/totalZ;
2867 tmpString.Printf(_T(
"Saving Values"));
2868 tmpString.Printf(_T(
" %d %c %d/%d %d"), (
int)porcent , 37 , z-minZ+1, (
int)totalZ ,z);
2877 Instant instant(&tempVector);
2879 sizeLstContourThings = lstContourThings.size();
2881 lstManConMod.clear();
2882 for (ii=0 ; ii<sizeLstContourThings ; ii++)
2885 lstManConMod.push_back( (*contourthing)->getModel() );
2892 int iContourGroup,sizeContourGroup;
2893 if (typeContourGroup==3)
2895 sizeContourGroup=lstManConModExp.size();
2900 for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
2901 lstManConModTmp.clear();
2902 if (typeContourGroup==3)
2904 lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
2906 lstManConModTmp = lstManConModExp;
2912 pLstValuePosX.clear();
2913 pLstValuePosY.clear();
2914 pLstValuePosZ.clear();
2922 std::string temp = directory +
"/" + namefile +
"-slice";
2924 temp = temp +
".txt";
2927 wxString filename = crea::std2wx(temp);
2940 FILE *pFile=fopen((
const char *)filename.mb_str(),
"w+");
2941 fprintf(pFile,
"value \t x \t y \t z\n" );
2942 int iLstValue,sizeLstValue=pLstValue.size();
2943 for (iLstValue=0 ; iLstValue<sizeLstValue ; iLstValue++ )
2945 fprintf(pFile,
"%f\t %f\t %f\t %f\n", (
float)pLstValue[iLstValue] , (
float)pLstValuePosX[iLstValue], (
float)pLstValuePosY[iLstValue], (
float)z );
2960 if (typeContourGroup==3)
2966 std::vector<manualBaseModel*> lstManConMod;
2967 std::vector<manualBaseModel*> lstManConModTmp;
2968 std::vector<manualBaseModel*> lstManConModExp;
2970 std::vector<int> tempVector;
2975 imagedata->GetExtent(ext);
2976 int sizeZimage = ext[5]-ext[4]+1;
2978 int ii,sizeLstContourThings;
2989 int actualSlice = tempVector[1];
2999 for (z=0; z<minZ; z++){
3003 for (z=maxZ+1; z<sizeZimage; z++){
3009 for ( z=minZ ; z<=maxZ ; z++)
3012 porcent = 100.0* (z-minZ)/totalZ;
3013 tmpString.Printf(_T(
"Saving Values"));
3014 tmpString.Printf(_T(
"%d %c %d/%d %d"), (
int)porcent , 37 , z-minZ+1, (
int)totalZ ,z);
3021 Instant instant(&tempVector);
3023 sizeLstContourThings = lstContourThings.size();
3025 lstManConMod.clear();
3026 for (ii=0 ; ii<sizeLstContourThings ; ii++)
3029 lstManConMod.push_back( (*contourthing)->getModel() );
3034 int iContourGroup,sizeContourGroup;
3035 if (typeContourGroup==3)
3037 sizeContourGroup=lstManConModExp.size();
3042 for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
3043 lstManConModTmp.clear();
3044 if (typeContourGroup==3)
3046 lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
3048 lstManConModTmp = lstManConModExp;
3068 std::string temp = directory +
"/" + namefile +
"-image-Value.mhd";
3070 wxString filename = crea::std2wx(temp);
3074 vtkImageChangeInformation *valueChInfo = vtkImageChangeInformation::New();
3075 valueChInfo->SetInput(value);
3076 valueChInfo->SetSpacingScale(spc);
3077 vtkMetaImageWriter *writerValueImage = vtkMetaImageWriter::New( );
3078 writerValueImage->SetInput( valueChInfo->GetOutput() );
3079 writerValueImage->SetFileName( (
const char *)filename.mb_str() );
3080 writerValueImage->SetFileDimensionality( 3 );
3081 writerValueImage->SetCompression(
false);
3082 writerValueImage->Write( );
3085 temp = directory +
"/" + namefile +
"-image-Mask.mhd";
3088 filename = crea::std2wx(temp);
3092 vtkImageChangeInformation *maskChInfo = vtkImageChangeInformation::New();
3093 maskChInfo->SetInput(mask);
3094 maskChInfo->SetSpacingScale(spc);
3095 vtkMetaImageWriter *writerMaskImage = vtkMetaImageWriter::New( );
3096 writerMaskImage->SetInput( maskChInfo->GetOutput() );
3097 writerMaskImage->SetFileName( (
const char *)filename.mb_str() );
3098 writerMaskImage->SetFileDimensionality( 3 );
3099 writerMaskImage->SetCompression(
false);
3100 writerMaskImage->Write( );
3120 std::vector<double> vecX;
3121 std::vector<double> vecY;
3122 std::vector<double> vecZ;
3125 if (vecX.size()!=0){
3126 std::vector<int> tempVector;
3128 int i,size=vecZ.size();
3129 int actualSlice = tempVector[1];
3130 for ( i=0 ; i<size ; i++ )
3132 vecZ[i] = actualSlice;
3135 wxDialog* dialog =
new wxDialog(
this, -1, wxString(_T(
"Snake")));
3136 wxPanel* panel =
new wxPanel(dialog,-1);
3138 new wxStaticText(panel, -1, wxString(_T(
"Panel para snake")));
3139 dialog->ShowModal();
3146 if(filename.compare(
"")!=0){
3195 int min = (int)floor (range[0]);
3196 int max = (int)ceil (range[1]);
3214 int min = (int)floor (range[0]);
3215 int max = (int)ceil (range[1]);
3233 if(!currentSelection.empty())
3235 std::string cloneName = currentSelection [0];
3237 tipo = manualModel-> GetTypeModel();
3244 double contourSize = 0;
3247 if(!currentSelection.empty())
3249 std::string cloneName = currentSelection [0];
3252 contourSize = manualModel-> GetPathSize();
3260 if(!currentSelection.empty())
3262 std::string cloneName = currentSelection [0];
3270 std::string labelAscii(label.ToAscii());
3271 int pos = labelAscii.find(
" ");
3275 for (j=0 ; pos != string::npos;j++)
3277 labelAscii.replace( pos, 1,
"_" );
3278 pos= labelAscii.find(
" ");
3281 manualModel -> SetLabel(labelAscii);
3285 double sizeInPixel = manualModel ->GetPathSize();
3287 double realContourSize = sizeInPixel*onePixelRealSize;
3288 manualModel ->SetRealSize(realContourSize);