Ok.. I made the API simpler that setting the shape size...<div><br></div><div>If you do :</div><div><br></div><div> paintbrushRepresentation2D->SetSingleSliceThickBrush(true);</div><div><br></div><div>you will get a slice by slice edit, ie the edits will be confined to the a single slice on all your views (axial/coronal/sagittal).</div>
<div><br></div><div>That's it :). I checked this in a few weeks ago. So please be sure to update the repository.</div><div><br></div><div><br></div><div>----</div><div><br></div><div>The issue with setting the Shape size to flatten along an axis was that this had to be managed at the application level, since you have to flatten the shape when you switch views.</div>
<div><br></div><div>Thanks</div><div>--</div><div>karthik</div><div><div><br><div class="gmail_quote">On Mon, Mar 28, 2011 at 5:54 AM, Xiaopeng Yang <span dir="ltr"><<a href="mailto:yxp233@postech.ac.kr">yxp233@postech.ac.kr</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Sorry I mean "Hello" not "Hell".<br>
<div class="im"><br>
-----邮件原件-----<br>
发件人: Xiaopeng Yang [mailto:<a href="mailto:yxp233@postech.ac.kr">yxp233@postech.ac.kr</a>]<br>
</div>发送时间: 2011년 3월 28일 월요일 오전 9:24<br>
<div class="im">收件人: 'Karthik Krishnan'<br>
抄送: 'vtk'; '<a href="mailto:VtkEdge@vtkedge.org">VtkEdge@vtkedge.org</a>'<br>
</div>主题: RE: [vtkusers] How to make the paintbrush paint only on one slice, not on the neighbor slices<br>
<div><div></div><div class="h5"><br>
Hell Karthik,<br>
<br>
Sorry to send this question again. Since I did not receive your reply yet. My question how to set the paintbrush width? I did as you suggested before, but it said that 'SetWidth' is not a function of 'vtkKWPaintbrushShape'.<br>
<br>
Please help me!<br>
<br>
Thanks a lot,<br>
Yang<br>
<br>
-----邮件原件-----<br>
发件人: Xiaopeng Yang [mailto:<a href="mailto:yxp233@postech.ac.kr">yxp233@postech.ac.kr</a>]<br>
发送时间: 2011년 3월 23일 수요일 오후 8:49<br>
收件人: 'Karthik Krishnan'<br>
抄送: 'vtk'; '<a href="mailto:VtkEdge@vtkedge.org">VtkEdge@vtkedge.org</a>'<br>
主题: RE: [vtkusers] How to make the paintbrush paint only on one slice, not on the neighbor slices<br>
<br>
Hi Karthik,<br>
<br>
I tried to set the width of paintbrush. But the it said that SetWidth is not a function of 'vtkKWPaintbrushShape'. I added your code to the program (PaintbrushTest6) as follows:<br>
<br>
<br>
vtkKWEPaintbrushTesting *paintbrushTesting = vtkKWEPaintbrushTesting::New();<br>
paintbrushTesting->SetFilename( "D:/Hybrid Method/Hybrid/SWS/Diffusion_filter/mha/3D.mha" );<br>
paintbrushTesting->Initialize();<br>
vtkImageData * imageData = paintbrushTesting->GetInput();<br>
<br>
vtkKWEWidgetGroup *set = vtkKWEWidgetGroup::New();<br>
<br>
for (int i = 0; i < 3; i++)<br>
{<br>
vtkKWEPaintbrushWidget *w = vtkKWEPaintbrushWidget::New();<br>
w->SetInteractor( paintbrushTesting->GetNthImageViewer(i)-><br>
GetRenderWindow()->GetInteractor());<br>
vtkKWEPaintbrushRepresentationGrayscale2D * rep =<br>
vtkKWEPaintbrushRepresentationGrayscale2D::New();<br>
w->SetRepresentation(rep);<br>
if (rep)<br>
{<br>
vtkImageActor * imageActor = paintbrushTesting->GetNthImageActor(i);<br>
rep->SetImageActor(imageActor);<br>
rep->SetImageData(imageData);<br>
rep->GetPaintbrushOperation()->GetPaintbrushShape()->SetSpacing(<br>
imageData->GetSpacing() );<br>
rep->GetPaintbrushOperation()->GetPaintbrushShape()->SetOrigin(<br>
imageData->GetOrigin() );<br>
<br>
//********************************************************************************<br>
rep->GetPaintbrushOperation()->GetPaintbrushShape()->SetWidth(<br>
xx, xx, xx);<br>
//********************************************************************************<br>
}<br>
<br>
set->AddWidget(w);<br>
rep->Delete();<br>
w->Delete();<br>
}<br>
<br>
vtkKWEPaintbrushRepresentation2D * repx =<br>
vtkKWEPaintbrushRepresentation2D::SafeDownCast(<br>
set->GetNthWidget(0)->GetRepresentation());<br>
vtkKWEPaintbrushDrawing * drawingx = repx->GetPaintbrushDrawing();<br>
for (unsigned int i = 0; i < set->GetNumberOfWidgets(); i++)<br>
{<br>
vtkKWEPaintbrushRepresentation2D * repr =<br>
vtkKWEPaintbrushRepresentation2D::SafeDownCast(<br>
set->GetNthWidget(i)->GetRepresentation());<br>
repr->SetPaintbrushDrawing( drawingx );<br>
}<br>
<br>
// Now read in an initial segmentation.<br>
<br>
vtkKWEPaintbrushRepresentation2D * rep =<br>
vtkKWEPaintbrushRepresentation2D::SafeDownCast(<br>
set->GetNthWidget(0)->GetRepresentation());<br>
<br>
vtkKWEPaintbrushDrawing * drawing = rep->GetPaintbrushDrawing();<br>
drawing->InitializeData();<br>
vtkKWEPaintbrushGrayscaleData *data = vtkKWEPaintbrushGrayscaleData::New();<br>
<br>
// Read the file (initial segmentation)<br>
vtkMetaImageReader * reader = vtkMetaImageReader::New();<br>
reader->SetFileName( "D:/Hybrid Method/Hybrid/SWS/Threshold_LS/Hole filled/LabelMap/3D.mha" );<br>
reader->Update();<br>
data->SetImageData(reader->GetOutput());<br>
reader->Delete();<br>
<br>
// Set the first stroke as the initial segmentation.<br>
drawing->AddNewStroke(0, vtkKWEPaintbrushEnums::Draw, data);<br>
<br>
// Instead of the above line, you can set this directly as the new stencil,<br>
// saves some memory, as the overhead data of an extra stroke need not be<br>
// managed.<br>
// drawing->SetPaintbrushData(data);<br>
<br>
for (unsigned int i = 0; i < set->GetNumberOfWidgets(); i++)<br>
{<br>
vtkKWEPaintbrushRepresentation * repr =<br>
vtkKWEPaintbrushRepresentation::SafeDownCast(<br>
set->GetNthWidget(i)->GetRepresentation());<br>
repr->SetPaintbrushDrawing( drawing );<br>
}<br>
<br>
set->SetEnabled(1);<br>
paintbrushTesting->Run();<br>
<br>
<br>
// Save out the resulting segmentation.<br>
//<br>
vtkImageData * output = vtkImageData::New();<br>
drawing->GetPaintbrushData()-><br>
GetPaintbrushDataAsImageData( output );<br>
vtkMetaImageWriter * outputWriter = vtkMetaImageWriter::New();<br>
outputWriter->SetFileName("Drawing.mha");<br>
outputWriter->SetInput( output );<br>
outputWriter->Write();<br>
<br>
// Save out each of the resulting segmentations.<br>
//<br>
for (int i = 0; i < drawing->GetNumberOfItems(); i++)<br>
{<br>
vtkImageData * outputN = vtkImageData::New();<br>
drawing->GetItem(i)->GetPaintbrushData()-><br>
GetPaintbrushDataAsImageData( outputN );<br>
vtkMetaImageWriter * outputWriterN = vtkMetaImageWriter::New();<br>
std::ostringstream filenameN;<br>
filenameN << "Drawing" << i << ".mha" << std::ends;<br>
outputWriterN->SetFileName(filenameN.str().c_str());<br>
outputWriterN->SetInput( outputN );<br>
outputWriterN->Write();<br>
outputWriterN->Delete();<br>
outputN->Delete();<br>
}<br>
<br>
data->Delete();<br>
outputWriter->Delete();<br>
output->Delete();<br>
set->Delete();<br>
paintbrushTesting->Delete();<br>
<br>
return 0;<br>
<br>
<br>
-----邮件原件-----<br>
发件人: Karthik Krishnan [mailto:<a href="mailto:karthik.krishnan@kitware.com">karthik.krishnan@kitware.com</a>]<br>
发送时间: 2011년 3월 23일 수요일 오후 5:47<br>
收件人: Xiaopeng Yang<br>
抄送: vtk; <a href="mailto:VtkEdge@vtkedge.org">VtkEdge@vtkedge.org</a><br>
主题: Re: [vtkusers] How to make the paintbrush paint only on one slice, not on the neighbor slices<br>
<br>
I apologize for the delay in getting back to your earlier mails. I<br>
hope you've figured those out :).<br>
<br>
To make the paintbrush go into slice by slice edit mode, you simply<br>
set the width of the paintbrush shape along that axis to one unit<br>
spacing along that axis....<br>
<br>
paintbrushOperation->GetPaintbrushShape()->SetWidth(10,10,spacingZ)<br>
<br>
On 3/23/11, Xiaopeng Yang <<a href="mailto:yxp233@postech.ac.kr">yxp233@postech.ac.kr</a>> wrote:<br>
</div></div><div><div></div><div class="h5">> Dear users,<br>
><br>
><br>
><br>
> I found that when I painted on one slice of a series of images, the neighbor<br>
> slices were also painted. My question is how to make the paintbrush paint<br>
> only on that slice, not on the neighbor slices.<br>
><br>
><br>
><br>
> Thanks very much in advance!<br>
><br>
><br>
><br>
> Yang<br>
><br>
><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</div></div></blockquote></div><br></div></div>