<P>
hi<BR>
<BR>
i have used vtkBoxWidget for scaling my volume data and it works fine except that the image and the widget and not aligned.<BR>
When i scale the volume or rotate it , it moves out of the widget.<BR>
Please suugest a solution for this.<BR>
I am including my code here<BR>
<BR>
vtkRenderWindowInteractor *iren;<BR>
vtkVolume *vol;<BR>
vtkRenderWindow *renwin;<BR>
vtkRenderer *ren;<BR>
vtkCamera *cam;<BR>
vtkVolumeRayCastMapper *volMapper;<BR>
class vtkMyCallback : public vtkCommand<BR>
{<BR>
public:<BR>
static vtkMyCallback *New() <BR>
{ return new vtkMyCallback; }<BR>
virtual void Execute(vtkObject *caller, unsigned long, void*)<BR>
{<BR>
vtkTransform *t = vtkTransform::New();<BR>
vtkBoxWidget *widget = reinterpret_cast<vtkBoxWidget*>(caller);<BR>
widget->GetTransform(t);<BR>
widget->GetProp3D()->SetUserTransform(t);<BR>
}<BR>
};<BR>
int main( int argc, char *argv[] )<BR>
{<BR>
vtkImageReader *Reader = vtkImageReader::New();<BR>
Reader-> SetHeaderSize (0); <BR>
Reader->SetDataExtent (0,199,0,199,0,99);<BR>
Reader->SetDataSpacing(1.0,1.0,1.0);<BR>
Reader->SetDataScalarTypeToUnsignedChar();<BR>
Reader->SetDataByteOrderToLittleEndian();<BR>
Reader->SetFileDimensionality(3);<BR>
Reader->SetFileName("d:/bym280602b");<BR>
Reader->SetDataMask(0x7fff);<BR>
<BR>
vtkPiecewiseFunction *oTFun =vtkPiecewiseFunction::New();<BR>
oTFun->AddSegment(32,0,255,1.0);<BR>
vtkPiecewiseFunction *gTFun =vtkPiecewiseFunction::New();<BR>
gTFun->AddSegment(0,1.0,5,1.0);<BR>
<BR>
vtkVolumeProperty *volProperty = vtkVolumeProperty::New();<BR>
volProperty->SetColor(gTFun);<BR>
volProperty->SetScalarOpacity(oTFun);<BR>
volProperty->SetInterpolationTypeToLinear();<BR>
volProperty->ShadeOn();<BR>
<BR>
vtkVolumeRayCastCompositeFunction *compositeFunction= vtkVolumeRayCastCompositeFunction::New();<BR>
volMapper = vtkVolumeRayCastMapper::New();<BR>
volMapper->SetInput(Reader->GetOutput()); <BR>
volMapper->SetVolumeRayCastFunction(compositeFunction);<BR>
<BR>
vol=vtkVolume::New();<BR>
vol->SetMapper(volMapper); <BR>
vol->SetProperty(volProperty);<BR>
<BR>
ren=vtkRenderer::New();<BR>
ren->AddVolume(vol); <BR>
<BR>
<BR>
renwin=vtkRenderWindow::New();<BR>
renwin->AddRenderer(ren);<BR>
renwin->SetSize(500,500);<BR>
iren=vtkRenderWindowInteractor::New();<BR>
iren->SetRenderWindow(renwin);<BR>
vtkInteractorStyleTrackballCamera *style = <BR>
vtkInteractorStyleTrackballCamera::New();<BR>
iren->SetInteractorStyle(style);<BR>
vtkBoxWidget *boxWidget = vtkBoxWidget::New();<BR>
boxWidget->SetInteractor(iren);<BR>
boxWidget->SetPlaceFactor(1);<BR>
boxWidget->SetProp3D(vol);<BR>
boxWidget->PlaceWidget();<BR>
vtkMyCallback *callback = vtkMyCallback::New();<BR>
boxWidget->AddObserver(vtkCommand::InteractionEvent, callback);<BR>
boxWidget->On();<BR>
iren->Initialize();<BR>
iren->Start();<BR>
<BR>
return 0;<BR>
}<BR>
<BR>
</P>
<br><br>
<A target="_blank" HREF="http://clients.rediff.com/signature/track_sig.asp"><IMG SRC="http://ads.rediff.com/RealMedia/ads/adstream_nx.cgi/www.rediffmail.com/inbox.htm@Bottom" BORDER=0 VSPACE=0 HSPACE=0 HEIGHT=74 WIDTH=496></a>