_refLineControl = NULL;
_refLineModel = NULL;
_refLineView = NULL;
+ _imageReslicer = NULL;
+ _thresholdTable = NULL;
+ _thresholdMapper = NULL;
_thresholdActor = NULL;
_actorPresent = false;
_refLineControl = NULL;
_refLineModel = NULL;
_refLineView = NULL;
+ _imageReslicer = NULL;
+ _thresholdTable = NULL;
+ _thresholdMapper = NULL;
_thresholdActor = NULL;
_actorPresent = false;
kernelManager->setInstant(instantVect);
//_modelManager->setInstant( _actualInstant );
- updateActor();
+ onThresholdChange();
updateInstantOutlines();
updateInstantImageData();
updateInstantAxes();
{
}
-void wxContourMainFrame :: updateActor()
-{
- if (_actorPresent)
- {
- int minMax[2];
- _pannew->onThresholdInstantChange(minMax);
-
- int z = _theViewPanel->GetZ();
-
- vtkImageData * img = getImageData();
- vtkImageReslice *imageReslice = vtkImageReslice::New();
-
- imageReslice->SetInput( img );
- imageReslice->SetInformationInput(img);
- imageReslice->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
- imageReslice->SetResliceAxesOrigin(0,0,z);
- imageReslice->SetOutputDimensionality(2);
- imageReslice->SetInterpolationModeToLinear();
-
- img = imageReslice->GetOutput();
- img->Update();
- img->UpdateInformation();
-
-//EED??? wxVtkBaseView * baseView = _theViewPanel->getWxVtkBaseView();
-
- double range[2];
- img->GetScalarRange(range);
-
- int min = floor (range[0]);
- int max = ceil (range[1]);
-
- //Lookup Table
- vtkLookupTable *lookup = vtkLookupTable::New();
- lookup->SetNumberOfTableValues(max+1);
- lookup->SetTableRange(range);
- lookup->SetAlphaRange(0, 1);
- lookup->SetValueRange(0, 1);
- lookup->SetSaturationRange(0, 0);
- lookup->SetRampToLinear( );
-
- //Assign a fake color for the upper image, and set the white as transparent
- int i;
- int minVal = minMax[0];
- int maxVal = minMax[1];
-
- for(i = min; i <= max; i++)
- {
- if( i >= minVal && i <= maxVal )
- {
- lookup->SetTableValue(i, 1.0, 0.0, 0.0, 1);
- }
- else if( i >= min && i < minVal )
- {
- lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
- }
- else if( i > maxVal && i < max )
- {
- lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
- }
- else
- {
- lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
- }
- }
-
- lookup->Build( );
-
- vtkImageMapToColors *mapperImage = vtkImageMapToColors::New( );
- mapperImage->SetLookupTable( lookup );
- mapperImage->SetInput( img );
- //mapperImage->SetOutputFormatToRGBA( );
-
- _thresholdActor->SetInput( mapperImage->GetOutput() );
- printf("EED wxContourMainFrame::updateActor %d \n" , z);
- _thresholdActor->SetPosition( 0,0, 900-1 );
- }
-}
void wxContourMainFrame::onChangeDeep(int val){
_instantPanel->setConceptValue( "Axe Depth", (int)val );
saveFileWithContours( fileNameContourROI );
}
}
-void wxContourMainFrame::saveFileWithContours( std::string filename ){
+void wxContourMainFrame::saveFileWithContours( std::string filename )
+{
FILE *pFile=fopen(filename.c_str(),"w+");
std::vector< std::string > lstNameThings;
vtkPolyData* polyDataResult = cntVTK->GetOutput();
- std::cout<<"Points "<<polyDataResult->GetNumberOfPoints()<<std::endl;
+ //std::cout<<"Points "<<polyDataResult->GetNumberOfPoints()<<std::endl;
polyDataResult->Update( );
polyDataResult->UpdateInformation();
{
vecX.push_back( p[0] );
myfile <<p[0]<<","<<p[1]<<"\n";
- std::cout<<" x Anterior "<<xAct<<" x actual "<<x<<std::endl;
- std::cout<<" y Anterior "<<yAct<<" y actual "<<y<<std::endl;
- std::cout<<" x "<<p[0]<<" y "<<p[1]<<std::endl;
+ //std::cout<<" x Anterior "<<xAct<<" x actual "<<x<<std::endl;
+ //std::cout<<" y Anterior "<<yAct<<" y actual "<<y<<std::endl;
+ //std::cout<<" x "<<p[0]<<" y "<<p[1]<<std::endl;
vecY.push_back( p[1] );
vecZ.push_back( 900 );
xAct=x;
while(!vecXo.empty())
{
vecX.push_back(vecXo.back());
- std::cout<<" x Siguiente "<<vecXo.back();
+ //std::cout<<" x Siguiente "<<vecXo.back();
vecXo.pop_back();
vecZ.push_back( 900 );
}
//_refName = "";
}
-void wxContourMainFrame::onThreshold(int minVal, int maxVal)
+void wxContourMainFrame::onThreshold()
{
+ int z = _theViewPanel->GetZ();
+ double range[2];
+
+ vtkImageData * img = getImageData();
+ img->GetScalarRange(range);
+
+ int minTot = floor (range[0]);
+ int maxTot = ceil (range[1]);
+
+ double minMax[2];
+ _pannew->onThresholdInstantChange(minMax);
+ int minVal = floor (minMax[0]);
+ int maxVal = floor (minMax[1]);
+
if (!_actorPresent)
{
- int z = _theViewPanel->GetZ();
-
- vtkImageData * img = getImageData();
- vtkImageReslice *imageReslice = vtkImageReslice::New();
+ if (_imageReslicer==NULL)
+ {
+ _imageReslicer = vtkImageReslice::New();
+ _imageReslicer->SetInput( img );
+ _imageReslicer->SetInformationInput(img);
+ _imageReslicer->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
+ _imageReslicer->SetOutputDimensionality(2);
+ _imageReslicer->SetInterpolationModeToLinear();
+ }
- imageReslice->SetInput( img );
- imageReslice->SetInformationInput(img);
- imageReslice->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
- imageReslice->SetResliceAxesOrigin(0,0,z);
- imageReslice->SetOutputDimensionality(2);
- imageReslice->SetInterpolationModeToLinear();
+ _imageReslicer->SetResliceAxesOrigin(0,0,z);
- img = imageReslice->GetOutput();
+ img = _imageReslicer->GetOutput();
img->Update();
img->UpdateInformation();
wxVtkBaseView * baseView = _theViewPanel->getWxVtkBaseView();
-
- double range[2];
- img->GetScalarRange(range);
-
- int min = floor (range[0]);
- int max = ceil (range[1]);
- //Lookup Table
- vtkLookupTable *lookup = vtkLookupTable::New();
- lookup->SetNumberOfTableValues(max+1);
- lookup->SetTableRange(range);
- lookup->SetAlphaRange(0, 1);
- lookup->SetValueRange(0, 1);
- lookup->SetSaturationRange(0, 0);
- lookup->SetRampToLinear( );
+ if (_thresholdTable==NULL)
+ {
+ //Lookup Table
+ _thresholdTable = vtkLookupTable::New();
+ _thresholdTable->SetNumberOfTableValues(maxTot+1);
+ _thresholdTable->SetTableRange(range);
+ _thresholdTable->SetAlphaRange(0, 1);
+ _thresholdTable->SetValueRange(0, 1);
+ _thresholdTable->SetSaturationRange(0, 0);
+ _thresholdTable->SetRampToLinear( );
+ }
//Assign a fake color for the upper image, and set the white as transparent
int i;
- for(i = min; i <= max; i++)
+ for(i = minTot; i <= maxTot; i++)
{
if( i >= minVal && i <= maxVal )
{
- lookup->SetTableValue(i, 1.0, 0.0, 0.0, 1);
+ _thresholdTable->SetTableValue(i, 1.0, 0.0, 0.0, 1);
}
- else if( i >= min && i < minVal )
+ else if( i >= minTot && i < minVal )
{
- lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
+ _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
}
- else if( i > maxVal && i < max )
+ else if( i > maxVal && i < maxTot )
{
- lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
+ _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
}
else
{
- lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
+ _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
}
}
-
- lookup->Build( );
-
- vtkImageMapToColors *mapperImage = vtkImageMapToColors::New( );
- mapperImage->SetLookupTable( lookup );
- mapperImage->SetInput( img );
- //mapperImage->SetOutputFormatToRGBA( );
+ _thresholdTable->Build( );
+
+ if (_thresholdMapper==NULL)
+ {
+ _thresholdMapper = vtkImageMapToColors::New( );
+ }
+
+ _thresholdMapper->SetLookupTable( _thresholdTable );
+ _thresholdMapper->SetInput( img );
if (_thresholdActor==NULL)
{
_thresholdActor = vtkImageActor::New( );
_thresholdActor->SetOpacity( 0.6 );
- _thresholdActor->InterpolateOn( );
+ _thresholdActor->InterpolateOn( );
+ _thresholdActor->SetPosition( 0,0, 900-1 );
}
-printf("EED wxContourMainFrame::onThreshold \n");
- _thresholdActor->SetPosition( 0,0, z+1 );
- _thresholdActor->SetInput( mapperImage->GetOutput() );
+
+ _thresholdActor->SetInput( _thresholdMapper->GetOutput() );
baseView->GetRenderer()->AddActor( _thresholdActor );
_actorPresent = true;
}
- RefreshInterface();
-/*
- vtkImageViewer2* viewer = vtkImageViewer2::New();
- viewer->SetInput( upperImageActor->GetInput() );
- viewer->SetColorLevel((range[1]-range[0])/2);
- viewer->SetColorWindow(range[1]);
- viewer->GetRenderer()->AddActor( upperImageActor );
- viewer->Render();
-*/
-
-}
-
-void wxContourMainFrame::onThresholdChange(int minVal, int maxVal)
-{
- if (_actorPresent)
+ else
{
- int z = _theViewPanel->GetZ();
-
- vtkImageData * img = getImageData();
- vtkImageReslice *imageReslice = vtkImageReslice::New();
-
- imageReslice->SetInput( img );
- imageReslice->SetInformationInput(img);
- imageReslice->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
- imageReslice->SetResliceAxesOrigin(0,0,z);
- imageReslice->SetOutputDimensionality(2);
- imageReslice->SetInterpolationModeToLinear();
-
- img = imageReslice->GetOutput();
+ _imageReslicer->SetResliceAxesOrigin(0,0,z);
+ img = _imageReslicer->GetOutput();
img->Update();
img->UpdateInformation();
-//EED?? wxVtkBaseView * baseView = _theViewPanel->getWxVtkBaseView();
-
- double range[2];
- img->GetScalarRange(range);
-
- int min = floor (range[0]);
- int max = ceil (range[1]);
-
- //Lookup Table
- vtkLookupTable *lookup = vtkLookupTable::New();
- lookup->SetNumberOfTableValues(max+1);
- lookup->SetTableRange(range);
- lookup->SetAlphaRange(0, 1);
- lookup->SetValueRange(0, 1);
- lookup->SetSaturationRange(0, 0);
- lookup->SetRampToLinear( );
-
//Assign a fake color for the upper image, and set the white as transparent
int i;
- for(i = min; i <= max; i++)
+ for(i = minTot; i <= maxTot; i++)
{
if( i >= minVal && i <= maxVal )
{
- lookup->SetTableValue(i, 1.0, 0.0, 0.0, 1);
+ _thresholdTable->SetTableValue(i, 1.0, 0.0, 0.0, 1);
}
- else if( i >= min && i < minVal )
+ else if( i >= minTot && i < minVal )
{
- lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
+ _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
}
- else if( i > maxVal && i < max )
+ else if( i > maxVal && i < maxTot )
{
- lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
+ _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
}
else
{
- lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
+ _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
}
}
-
- lookup->Build( );
- vtkImageMapToColors *mapperImage = vtkImageMapToColors::New( );
- mapperImage->SetLookupTable( lookup );
- mapperImage->SetInput( img );
- //mapperImage->SetOutputFormatToRGBA( );
+ _thresholdTable->Build( );
+ _thresholdMapper->SetLookupTable( _thresholdTable );
+ _thresholdMapper->SetInput( img );
+ _thresholdActor->SetInput( _thresholdMapper->GetOutput() );
+ }
+ /*
+ vtkImageViewer2* viewer = vtkImageViewer2::New();
+ viewer->SetInput( upperImageActor->GetInput() );
+ viewer->SetColorLevel((range[1]-range[0])/2);
+ viewer->SetColorWindow(range[1]);
+ viewer->GetRenderer()->AddActor( upperImageActor );
+ viewer->Render();
+ */
+ _theViewPanel->RefreshInterface();
+}
- _thresholdActor->SetInput( mapperImage->GetOutput() );
-printf("EED wxContourMainFrame::onThresholdChange \n");
- _thresholdActor->SetPosition( 0,0, z+1 );
+void wxContourMainFrame::onThresholdChange()
+{
+ if (_actorPresent)
+ {
+ onThreshold();
}
-
- RefreshInterface();
}
void wxContourMainFrame::onThresholdInterpolation(bool interpolate)
_thresholdActor->InterpolateOff( );
}
- RefreshInterface();
+ _theViewPanel->RefreshInterface();
}
}
_thresholdActor->SetOpacity(opacity*0.1);
}
- RefreshInterface();
+ _theViewPanel->RefreshInterface();
}
void wxContourMainFrame::onThresholdRemove()
_actorPresent = false;
}
- RefreshInterface();
+ _theViewPanel->RefreshInterface();
}
void wxContourMainFrame::showAxis(bool show)