[prev in list] [next in list] [prev in thread] [next in thread] 

List:       vtkusers
Subject:    Re: [vtkusers] Heap corruption | vtkLookupTable?
From:       Audrius Stundzia <audrius () tomographix ! com>
Date:       2016-01-28 14:52:56
Message-ID: 1453992776.2224120.505184322.646358F4 () webmail ! messagingengine ! com
[Download RAW message or body]

[Attachment #2 (--_----------=_145399277622241200)]


Using  SetNumberOfTableValues() instead of SetNumberOfColors() fixed
the problem.

Thank you.

Regards,

Audrius

On Thu, Jan 28, 2016, at 08:28, Ken Martin wrote:
> Can you try using  SetNumberOfTableValues() instead of
> SetNuberOfColors()?
>
> Thanks Ken
>
> On Wed, Jan 27, 2016 at 4:15 PM, Audrius Stundzia
> <audrius@tomographix.com> wrote:
>> __
>>
>> Hi Cory,
>>
>> Sorry that I did not respond earlier. Overlooked your e-mail. Thank
>> you for your reply
>>
>> Now using
>>
>> OS: Windows 10 x64 IDE: MS VS 2015 VTK: 7.0.0.rc2 x64 build
>>
>> Still receiving the same error message at the same place:
>>
>> HEAP CORRUPTION DETECTED: after Normal block (#218683) at
>> 0x00000286C6D22350. CRT detected that the application wrote to memory
>> after end of heap buffer.
>>
>> No idea how to create a  CMakeLists.txt  file. Please advise.
>>
>> Regards,
>>
>> Audrius
>>
>> On 8 November 2015 at 15:26, Cory Quammen
>> <cory.quammen@kitware.com> wrote:
>>> Hi Audrius,
>>>
>>> That is indeed suspicious. I don't immediately see anything in your
>>> code that would explain the crash. Would you mind attaching a
>>> compilable example program with accompanying CMakeLists.txt file?
>>> That will make it easier to take a look.
>>>
>>> Thanks, Cory
>>>
>>> On Thu, Nov 5, 2015 at 11:19 PM, Audrius Stundzia
>>> <audrius@tomographix.com> wrote:
>>>> __
>>>> Dear All,
>>>>
>>>> OS: Windows 10 x64 IDE: MS VS 2015 VTK: 6.3.0 x64 build
>>>>
>>>> I am getting a "heap corruption" message when a vtkRenderWindow is
>>>> closed and the vtkRenderWindowInteractor is stopped. Specifically
>>>> the line
>>>>
>>>> renderWindowInteractor->TerminateApp();
>>>>
>>>> in a callback function
>>>>
>>>> static void KeyPressCallbackFunction
>>>>
>>>> The relevant code fragments, appended below, are conventional
>>>> texture mapping of an image to a plane. This "heap corruption" did
>>>> not occur in Windows 8.1 x64; MS VS 2010; VTK 5.10.1 x64 build
>>>>
>>>> From the call stack it appears to due to a problem with deleting an
>>>> instantiation of vtkLoopupTable:
>>>>
>>>> vtkCommonCore-6.3.dll!vtkDataArrayTemplate<unsigned
>>>> char>::DeleteArray() Line 214 C++ vtkCommonCore-
>>>> 6.3.dll!vtkDataArrayTemplate<unsigned
>>>> char>::~vtkDataArrayTemplate<unsigned char>() Line 92 C++ vtkCommonCore-
>>>> 6.3.dll!vtkUnsignedCharArray::~vtkUnsignedCharArray() Line 37 C++
>>>> [External Code] vtkCommonCore-
>>>> 6.3.dll!vtkObjectBase::UnRegisterInternal(vtkObjectBase * __formal,
>>>> int check) Line 232 C++ vtkCommonCore-
>>>> 6.3.dll!vtkObject::UnRegisterInternal(vtkObjectBase * o, int check)
>>>> Line 901 C++ vtkCommonCore-
>>>> 6.3.dll!vtkObjectBase::UnRegister(vtkObjectBase * o) Line 190 C++
>>>> vtkCommonCore-6.3.dll!vtkLookupTable::~vtkLookupTable() Line 89C++
>>>> [External Code] vtkCommonCore-
>>>> 6.3.dll!vtkObjectBase::UnRegisterInternal(vtkObjectBase * __formal,
>>>> int check) Line 232 C++ vtkCommonCore-
>>>> 6.3.dll!vtkObject::UnRegisterInternal(vtkObjectBase * o, int check)
>>>> Line 901 C++ vtkCommonCore-
>>>> 6.3.dll!vtkObjectBase::UnRegister(vtkObjectBase * o) Line 190 C++
>>>> vtkCommonCore-6.3.dll!vtkSmartPointerBase::~vtkSmartPointerBase()
>>>> Line 62 C++ [External Code]
>>>>
>>>> Any insight would be appreciated.
>>>>
>>>> Regards,
>>>>
>>>> Audrius
>>>>
>>>> //--------------------------------------- // Start: relevant code
>>>> fragment //---------------------------------------
>>>>
>>>> {
>>>> . . .
>>>>
>>>> vtkSmartPointer<vtkCamera>  camera_ =
>>>> vtkSmartPointer<vtkCamera>::New();
>>>>
>>>> camera_->SetPosition( 0.0, 0.0, -1.0); camera_->SetRoll(180.0);
>>>>
>>>> camera_->Zoom( zoomFactor_ );
>>>>
>>>> //--------------- vtkSmartPointer<vtkRenderer>  renderer_ =
>>>> vtkSmartPointer<vtkRenderer>::New(); renderer_-
>>>> >SetActiveCamera(camera_); renderer_->SetBackground( 0.0, 0.0,
>>>> 0.0 );
>>>>
>>>> //--------------- vtkSmartPointer<vtkRenderWindow>  renderWindow_ =
>>>> vtkSmartPointer<vtkRenderWindow>::New(); renderWindow_-
>>>> >AddRenderer( renderer_ ); renderWindow_->SetSize ( winSizeX_ ,
>>>> winSizeY_ ); renderWindow_->SetPosition ( winPosX_ , winPosY_ );
>>>> renderWindow_->SwapBuffersOn();
>>>>
>>>> //--------------- vtkSmartPointer<vtkRenderWindowInteractor>
>>>> renderWindowInteractor_ =
>>>> vtkSmartPointer<vtkRenderWindowInteractor>::New();    renderWindowInteractor_-
>>>> >SetRenderWindow( renderWindow_);
>>>>
>>>> vtkSmartPointer<vtkCallbackCommand>  keyPressCallback_ =
>>>> vtkSmartPointer<vtkCallbackCommand>::New(); keyPressCallback_-
>>>> >SetCallback( advDiagnosticDisplay::KeyPressCallbackFunction);
>>>>
>>>> renderWindowInteractor_->AddObserver ( vtkCommand::KeyPressEvent ,
>>>> keyPressCallback_ );
>>>>
>>>> // Build a colour map vtkSmartPointer<vtkLookupTable> colourMap_ =
>>>> vtkSmartPointer<vtkLookupTable>::New();
>>>> InitializeColourMap(colourMap_);
>>>>
>>>> // Apply the texture vtkSmartPointer<vtkTexture> texture_ =
>>>> vtkSmartPointer<vtkTexture>::New(); if(interpolation_) texture_-
>>>> >InterpolateOn(); else texture_->InterpolateOff(); texture_-
>>>> >RepeatOff(); texture_->SetQualityTo32Bit(); texture_-
>>>> >MapColorScalarsThroughLookupTableOn(); texture_->SetInputData( imageReslice_-
>>>> >GetOutput()); texture_->SetLookupTable( colourMap_);
>>>>
>>>> //--------------- vtkSmartPointer<vtkPlaneSource> planeSource_ =
>>>> vtkSmartPointer<vtkPlaneSource>::New(); planeSource_-
>>>> >SetResolution( 1, 1 ); planeSource_->SetPoint1( eX_, 0.0, 0.0);
>>>> planeSource_->SetPoint2( 0.0, eY_, 0.0); planeSource_->SetCenter(
>>>> centre_.data()); planeSource_->SetNormal( 0.0, 0.0, 1.0); planeSource_-
>>>> >Update();
>>>>
>>>> //--------------- vtkSmartPointer<vtkPolyDataMapper> mapper_ =
>>>> vtkSmartPointer<vtkPolyDataMapper>::New(); mapper_-
>>>> >ScalarVisibilityOff(); mapper_->SetInputData( planeSource_-
>>>> >GetOutput()); mapper_->Update();
>>>>
>>>> //--------------- vtkSmartPointer<vtkProperty> property_ =
>>>> vtkSmartPointer<vtkProperty>::New(); property_->SetOpacity(
>>>> opacity_);
>>>>
>>>> //--------------- vtkSmartPointer<vtkActor> actor_ =
>>>> vtkSmartPointer<vtkActor>::New(); actor_->SetProperty( property_ );
>>>> actor_->SetTexture( texture_ ); actor_->SetMapper( mapper_ );
>>>>
>>>> //--------------- renderer_->AddActor(actor_);
>>>>
>>>> renderer_->ResetCamera();
>>>>
>>>> renderWindow_->Render(); renderWindow_->SetWindowName( "Window name
>>>> here");
>>>>
>>>> renderWindowInteractor_->Start();
>>>>
>>>> . . .
>>>>
>>>> }
>>>>
>>>> void InitializeColourMap(vtkSmartPointer<vtkLookupTable>&
>>>> colourMap) { //--------------- colourMap-
>>>> >SetNumberOfColors(nImageColours_ + 1); colourMap->SetTableRange
>>>> (minScalar_ , maxScalar_);
>>>>
>>>> if (colour_) { colourMap->SetHueRange(0.666667f, 0.0f); colourMap-
>>>> >Build(); colourMap->SetTableValue(0, 0.0f, 0.0f, 0.0f, 0.0f); }
>>>> else { colourMap->SetHueRange(0.5f, 0.5f); colourMap-
>>>> >SetSaturationRange(0.0f, 1.0f); colourMap->Build(); colourMap-
>>>> >SetTableValue(0, 0.0f, 0.0f, 0.0f, 0.0f);
>>>>
>>>> for (int iC = 1; iC <= nImageColours_; ++iC) { const float val =
>>>> static_cast<float>(iC) / static_cast<float>(nImageColours_ + 1);
>>>> colourMap->SetTableValue (iC , val , val , val , 1.0f); } } }
>>>>
>>>>
>>>> // // vtk callback function: stop rendering and close window //
>>>>
>>>> static void KeyPressCallbackFunction ( vtkObject* caller , long
>>>> unsigned int vtkNotUsed(eventId) , void* vtkNotUsed(clientData) ,
>>>> void* vtkNotUsed(callData)) { vtkRenderWindowInteractor*
>>>> renderWindowInteractor =
>>>> dynamic_cast<vtkRenderWindowInteractor*>(caller);
>>>>
>>>> // Close the window vtkRenderWindow* renderWindow = renderWindowInteractor-
>>>> >GetRenderWindow(); renderWindow->Finalize();
>>>>
>>>> // Stop the interactor // When the next line is executed, the heap
>>>> corruption message is generated renderWindowInteractor-
>>>> >TerminateApp();
>>>>
>>>> std::cout << "Window closed." << std::endl; }
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Powered by www.kitware.com
>>>>
>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.html
>>>>
>>>> Please keep messages on-topic and check the VTK FAQ at:
>>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>>
>>>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://public.kitware.com/mailman/listinfo/vtkusers
>>>>
>>>
>>>
>>>
>>> --
>>> Cory Quammen R&D Engineer Kitware, Inc.
>>>
>>>
>>
>>
>> _______________________________________________
>>
Powered by www.kitware.com
>>
>>
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
>>
>>
Please keep messages on-topic and check the VTK FAQ at:
http://www.vtk.org/Wiki/VTK_FAQ
>>
>>
Search the list archives at: http://markmail.org/search/?q=vtkusers
>>
>>
Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/vtkusers
>>
>
>
>
> --
> Ken Martin PhD Chairman & CFO Kitware Inc. 28 Corporate Drive Clifton
> Park NY 12065 518 371 3971
>
> This communication,
including all attachments, contains confidential and legally privileged
information, and it is intended only for the use of the addressee.
Access to this email by anyone else is unauthorized. If you are not the
intended recipient, any disclosure, copying, distribution or any action
taken in reliance on it is prohibited and may be unlawful. If you
received this communication in error please notify us immediately and
destroy the original message. Thank you.

[Attachment #5 (unknown)]

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>&nbsp;</div>
<div>Using&nbsp;SetNumberOfTableValues() instead of \
SetNumberOfColors()&nbsp;<br></div> <div>fixed the problem. <br></div>
<div>&nbsp;</div>
<div>Thank you.<br></div>
<div>&nbsp;</div>
<div>Regards,&nbsp;<br></div>
<div>&nbsp;</div>
<div>Audrius</div>
<div>&nbsp;</div>
<div>On Thu, Jan 28, 2016, at 08:28, Ken Martin wrote:<br></div>
<blockquote type="cite"><div dir="ltr"><div>Can you try \
using&nbsp;SetNumberOfTableValues() instead of SetNuberOfColors()?<br></div> \
<div>&nbsp;</div> <div>Thanks<br></div>
<div>Ken<br></div>
</div>
<div><div>&nbsp;</div>
<div><div>On Wed, Jan 27, 2016 at 4:15 PM, Audrius Stundzia <span dir="ltr">&lt;<a \
href="mailto:audrius@tomographix.com">audrius@tomographix.com</a>&gt;</span> \
wrote:<br></div> <blockquote \
style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204, \
204, 204);border-left-style:solid;padding-left:1ex;"><div><u></u><br></div> \
<div><div>&nbsp;</div> <div>Hi Cory,&nbsp;<br></div>
<div dir="ltr"><div>&nbsp;</div>
<div>Sorry that I did not respond earlier. Overlooked your e-mail.<br></div>
<div>Thank you for your reply<br></div>
<div>&nbsp;</div>
<div>Now using<br></div>
<div>&nbsp;</div>
<div><div style="font-size:12.8px;">OS: Windows 10 x64<br></div>
<div style="font-size:12.8px;">IDE: MS VS 2015&nbsp;<br></div>
<div style="font-size:12.8px;"><span>VTK</span>: 7.0.0.rc2 x64 build<br></div>
</div>
<div>&nbsp;</div>
<div>Still receiving the same error message at the same place:<br></div>
<div>&nbsp;</div>
<div><div>HEAP CORRUPTION DETECTED: after Normal block (#218683) at \
0x00000286C6D22350.<br></div> <div>CRT detected that the application wrote to memory \
after end of heap buffer.<br></div> </div>
<div>&nbsp;</div>
<div>No idea how to create a&nbsp;<span class="size" \
style="font-size:12.8px">CMakeLists.txt</span><span class="size" \
style="font-size:12.8px">&nbsp;file. Please advise.</span><br></div> \
<div>&nbsp;</div> <div>Regards,&nbsp;<br></div>
<div>&nbsp;</div>
<div>Audrius<br></div>
</div>
<div><div>&nbsp;</div>
<div><div>On 8 November 2015 at 15:26, Cory Quammen <span dir="ltr">&lt;<a \
href="mailto:cory.quammen@kitware.com">cory.quammen@kitware.com</a>&gt;</span> \
wrote:<br></div> <blockquote \
style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204, \
204, 204);border-left-style:solid;padding-left:1ex;"><div dir="ltr"><div>Hi \
Audrius,<br></div> <div>&nbsp;</div>
<div>That is indeed suspicious. I don't immediately see anything in your code that \
would explain the crash. Would you mind attaching a compilable example program with \
accompanying CMakeLists.txt file? That will make it easier to take a look.<br></div> \
<div>&nbsp;</div> <div>Thanks,<br></div>
<div>Cory<br></div>
</div>
<div><div>&nbsp;</div>
<div><div>On Thu, Nov 5, 2015 at 11:19 PM, Audrius Stundzia <span dir="ltr">&lt;<a \
href="mailto:audrius@tomographix.com">audrius@tomographix.com</a>&gt;</span> \
wrote:<br></div> <blockquote \
style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204, \
204, 204);border-left-style:solid;padding-left:1ex;"><div><u></u><br></div> \
<div><div><div>Dear All,<br></div> <div>&nbsp;</div>
</div>
<div>OS: Windows 10 x64<br></div>
<div>IDE: MS VS 2015&nbsp;<br></div>
<div>VTK: 6.3.0 x64 build<br></div>
<div><div>&nbsp;</div>
<div>I am getting a "heap corruption" message when a vtkRenderWindow is closed and \
the vtkRenderWindowInteractor is stopped.<br></div> <div>Specifically the line \
<br></div> <div>&nbsp;</div>
<div><span style="line-height:10.8333px;">renderWindowInteractor-&gt;TerminateApp();</span><br></div>
 <div>&nbsp;</div>
<div>in a callback function<br></div>
<div>&nbsp;</div>
<div><span style="line-height:10.8333px;">static void \
KeyPressCallbackFunction</span><br></div> <div>&nbsp;</div>
<div>The relevant code fragments, appended below, are conventional texture mapping of \
an image to a plane.<br></div> <div>This "heap corruption" did not occur in Windows \
8.1 x64; MS VS 2010; VTK 5.10.1 x64 build<br></div> <div>&nbsp;</div>
<div>From the call stack it appears to due to a problem with deleting an \
instantiation of vtkLoopupTable:<br></div> <div>&nbsp;</div>
</div>
<div>vtkCommonCore-6.3.dll!vtkDataArrayTemplate&lt;unsigned char&gt;::DeleteArray() \
Line 214 C++<br></div> <div>vtkCommonCore-6.3.dll!vtkDataArrayTemplate&lt;unsigned \
char&gt;::~vtkDataArrayTemplate&lt;unsigned char&gt;() Line 92 C++<br></div> \
<div>vtkCommonCore-6.3.dll!vtkUnsignedCharArray::~vtkUnsignedCharArray() Line 37 \
C++<br></div> <div>[External Code]<br></div>
<div>vtkCommonCore-6.3.dll!vtkObjectBase::UnRegisterInternal(vtkObjectBase * \
__formal, int check) Line 232 C++<br></div> \
<div>vtkCommonCore-6.3.dll!vtkObject::UnRegisterInternal(vtkObjectBase * o, int \
check) Line 901 C++<br></div> \
<div>vtkCommonCore-6.3.dll!vtkObjectBase::UnRegister(vtkObjectBase * o) Line 190 \
C++<br></div> <div>vtkCommonCore-6.3.dll!vtkLookupTable::~vtkLookupTable() Line \
89C++<br></div> <div>[External Code]<br></div>
<div>vtkCommonCore-6.3.dll!vtkObjectBase::UnRegisterInternal(vtkObjectBase * \
__formal, int check) Line 232 C++<br></div> \
<div>vtkCommonCore-6.3.dll!vtkObject::UnRegisterInternal(vtkObjectBase * o, int \
check) Line 901 C++<br></div> \
<div>vtkCommonCore-6.3.dll!vtkObjectBase::UnRegister(vtkObjectBase * o) Line 190 \
C++<br></div> <div>vtkCommonCore-6.3.dll!vtkSmartPointerBase::~vtkSmartPointerBase() \
Line 62 C++<br></div> <div>[External Code]<br></div>
<div>&nbsp;</div>
<div>Any insight would be appreciated.<br></div>
<div>&nbsp;</div>
<div>Regards,&nbsp;<br></div>
<div>&nbsp;</div>
<div>Audrius<br></div>
<div>&nbsp;</div>
<div>//---------------------------------------<br></div>
<div><span style="line-height:1.25;">// Start: relevant code \
fragment</span><br></div> <div>//---------------------------------------<br></div>
<div>&nbsp;</div>
<div>{<br></div>
<div>. . .<br></div>
<div>&nbsp;</div>
<div><span style="line-height:10.8333px;">vtkSmartPointer&lt;vtkCamera&gt;&nbsp;</span>camera_ \
= <span style="line-height:10.8333px;">vtkSmartPointer&lt;vtkCamera&gt;::New();</span><br></div>
 <div>&nbsp;</div>
<div>camera_-&gt;SetPosition( 0.0, 0.0, -1.0);<br></div>
<div>camera_-&gt;SetRoll(180.0);<br></div>
<div>&nbsp;</div>
<div>camera_-&gt;Zoom( zoomFactor_ );<br></div>
<div>&nbsp;</div>
<div><span style="line-height:10.8333px;">//---------------</span><br></div>
<div><span style="line-height:10.8333px;"><span \
style="line-height:10.8333px;">vtkSmartPointer&lt;vtkRenderer&gt;&nbsp;</span>renderer_ \
= vtkSmartPointer&lt;vtkRenderer&gt;::New();</span><br></div> <div><span \
style="line-height:10.8333px;">renderer_-&gt;SetActiveCamera(camera_);</span><br></div>
 <div><span style="line-height:10.8333px;">renderer_-&gt;SetBackground( 0.0, 0.0, 0.0 \
);</span><br></div> <div>&nbsp;</div>
<div><span style="line-height:10.8333px;">//---------------</span><br></div>
<div><span style="line-height:10.8333px;"><span \
style="line-height:10.8333px;">vtkSmartPointer&lt;vtkRenderWindow&gt;&nbsp;</span>renderWindow_ \
= vtkSmartPointer&lt;vtkRenderWindow&gt;::New();</span><br></div> <div><span \
style="line-height:10.8333px;">renderWindow_-&gt;AddRenderer( renderer_ \
);</span><br></div> <div><span \
style="line-height:10.8333px;">renderWindow_-&gt;SetSize</span><br></div> <div><span \
style="line-height:10.8333px;">( winSizeX_</span><br></div> <div><span \
style="line-height:10.8333px;">, winSizeY_ );</span><br></div> <div><span \
style="line-height:10.8333px;">renderWindow_-&gt;SetPosition</span><br></div> \
<div><span style="line-height:10.8333px;">( winPosX_</span><br></div> <div><span \
style="line-height:10.8333px;">, winPosY_ );</span><br></div> <div><span \
style="line-height:10.8333px;">renderWindow_-&gt;SwapBuffersOn();</span><br></div> \
<div>&nbsp;</div> <div><span \
style="line-height:10.8333px;">//---------------</span><br></div> <div><span \
style="line-height:10.8333px;"><span \
style="line-height:10.8333px;">vtkSmartPointer&lt;vtkRenderWindowInteractor&gt;&nbsp;</span>renderWindowInteractor_ \
= vtkSmartPointer&lt;vtkRenderWindowInteractor&gt;::New();</span><br></div> \
<div><span style="line-height:10.8333px;">renderWindowInteractor_-&gt;SetRenderWindow( \
renderWindow_); &nbsp; &nbsp;</span><br></div> <div>&nbsp;</div>
<div><span style="line-height:10.8333px;"><span \
style="line-height:10.8333px;">vtkSmartPointer&lt;vtkCallbackCommand&gt;&nbsp;</span>keyPressCallback_ \
= vtkSmartPointer&lt;vtkCallbackCommand&gt;::New();</span><br></div> <div><span \
style="line-height:10.8333px;">keyPressCallback_-&gt;SetCallback( \
advDiagnosticDisplay::KeyPressCallbackFunction);</span><br></div> <div>&nbsp;</div>
<div><span style="line-height:10.8333px;">renderWindowInteractor_-&gt;AddObserver</span><br></div>
 <div><span style="line-height:10.8333px;">( \
vtkCommand::KeyPressEvent</span><br></div> <div><span \
style="line-height:10.8333px;">, keyPressCallback_ );</span><br></div> \
<div><div>&nbsp;</div> <div><div><div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>// Build a colour map<br></div> <div \
style="line-height:10.8333px;"><span style="white-space:pre-wrap;"><span \
style="line-height:10.8333px;">vtkSmartPointer&lt;vtkLookupTable&gt; \
</span></span>colourMap_ = vtkSmartPointer&lt;vtkLookupTable&gt;::New();<br></div> \
<div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>InitializeColourMap(colourMap_);<br></div> <div \
style="line-height:10.8333px;">&nbsp;</div> <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>// Apply the texture<br></div> <div \
style="line-height:10.8333px;"><span style="white-space:pre-wrap;"><span \
style="line-height:10.8333px;">vtkSmartPointer&lt;vtkTexture&gt; \
</span></span>texture_ = vtkSmartPointer&lt;vtkTexture&gt;::New();<br></div> <div \
style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>if(interpolation_)&nbsp;<br></div> <div \
style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>texture_-&gt;InterpolateOn();<br></div> <div \
style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>else<span \
style="white-space:pre-wrap;"></span> <br></div> <div \
style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>texture_-&gt;InterpolateOff();<br></div> <div \
style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>texture_-&gt;RepeatOff();<br></div> <div \
style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>texture_-&gt;SetQualityTo32Bit();<br></div> <div \
style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>texture_-&gt;MapColorScalarsThroughLookupTableOn();<br></div>
 <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>texture_-&gt;SetInputData( \
imageReslice_-&gt;GetOutput());<br></div> <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>texture_-&gt;SetLookupTable( \
colourMap_);<br></div> <div style="line-height:10.8333px;">&nbsp;</div>
<div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>//---------------<br></div> <div \
style="line-height:10.8333px;"><span style="white-space:pre-wrap;"><span \
style="line-height:10.8333px;">vtkSmartPointer&lt;vtkPlaneSource&gt; \
</span></span>planeSource_ = vtkSmartPointer&lt;vtkPlaneSource&gt;::New();<br></div> \
<div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>planeSource_-&gt;SetResolution( 1, 1 \
);<br></div> <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>planeSource_-&gt;SetPoint1( eX_, 0.0, \
0.0);<br></div> <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>planeSource_-&gt;SetPoint2( 0.0, eY_, \
0.0);<br></div> <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>planeSource_-&gt;SetCenter( \
centre_.data());<br></div> <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>planeSource_-&gt;SetNormal( 0.0, 0.0, \
1.0);<br></div> <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>planeSource_-&gt;Update();<br></div> <div \
style="line-height:10.8333px;">&nbsp;</div> <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>//---------------<br></div> <div \
style="line-height:10.8333px;"><span style="white-space:pre-wrap;"><span \
style="line-height:10.8333px;">vtkSmartPointer&lt;vtkPolyDataMapper&gt; \
</span></span>mapper_ = vtkSmartPointer&lt;vtkPolyDataMapper&gt;::New();<br></div> \
<div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>mapper_-&gt;ScalarVisibilityOff();&nbsp;<br></div>
 <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>mapper_-&gt;SetInputData( \
planeSource_-&gt;GetOutput());<br></div> <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>mapper_-&gt;Update();<br></div> <div \
style="line-height:10.8333px;">&nbsp;</div> <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>//---------------<br></div> <div \
style="line-height:10.8333px;"><span style="white-space:pre-wrap;"><span \
style="line-height:10.8333px;">vtkSmartPointer&lt;vtkProperty&gt; \
</span></span>property_ = vtkSmartPointer&lt;vtkProperty&gt;::New();<br></div> <div \
style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>property_-&gt;SetOpacity( opacity_);<br></div> \
<div style="line-height:10.8333px;">&nbsp;</div> <div \
style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>//---------------<br></div> <div \
style="line-height:10.8333px;"><span style="white-space:pre-wrap;"><span \
style="line-height:10.8333px;">vtkSmartPointer&lt;vtkActor&gt; </span></span>actor_ = \
vtkSmartPointer&lt;vtkActor&gt;::New();<br></div> <div \
style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>actor_-&gt;SetProperty( property_ );<br></div> \
<div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>actor_-&gt;SetTexture( texture_ );<br></div> \
<div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>actor_-&gt;SetMapper( mapper_ );<br></div> <div \
style="line-height:10.8333px;">&nbsp;</div> <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>//---------------<br></div> <div \
style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>renderer_-&gt;AddActor(actor_);<br></div> <div \
style="line-height:10.8333px;">&nbsp;</div> </div>
<div>renderer_-&gt;ResetCamera();<br></div>
</div>
</div>
<div>&nbsp;</div>
<div>renderWindow_-&gt;Render();<br></div>
<div>renderWindow_-&gt;SetWindowName( "Window name here");<br></div>
<div>&nbsp;</div>
<div>renderWindowInteractor_-&gt;Start();<br></div>
<div>&nbsp;</div>
<div><div><div><div><div><span style="line-height:10.8333px;">. . .</span><br></div>
<div>&nbsp;</div>
<div><span style="line-height:10.8333px;">}</span><br></div>
</div>
<div style="line-height:10.8333px;">&nbsp;</div>
<div style="line-height:10.8333px;"><div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>void \
InitializeColourMap(vtkSmartPointer&lt;vtkLookupTable&gt;&amp; colourMap)<br></div> \
<div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>{<br></div> <div \
style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>//---------------<br></div> <div \
style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>colourMap-&gt;SetNumberOfColors(nImageColours_ + \
1);<br></div> <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>colourMap-&gt;SetTableRange<br></div> <div \
style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>(minScalar_<br></div> <div \
style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>, \
maxScalar_);<br></div> <div style="line-height:10.8333px;">&nbsp;</div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>if \
(colour_)<br></div> <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>{<br></div> <div \
style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>colourMap-&gt;SetHueRange(0.666667f, \
0.0f);<br></div> <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>colourMap-&gt;Build();<br></div> <div \
style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>colourMap-&gt;SetTableValue(0, 0.0f, 0.0f, 0.0f, \
0.0f);<br></div> <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>}<br></div> <div \
style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>else<br></div> <div \
style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>{<br></div> \
<div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>colourMap-&gt;SetHueRange(0.5f, 0.5f);<br></div> \
<div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>colourMap-&gt;SetSaturationRange(0.0f, \
1.0f);<br></div> <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>colourMap-&gt;Build();<br></div> <div \
style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>colourMap-&gt;SetTableValue(0, 0.0f, 0.0f, 0.0f, \
0.0f);<br></div> <div style="line-height:10.8333px;">&nbsp;</div>
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>for \
(int iC = 1; iC &lt;= nImageColours_; ++iC)<br></div> <div \
style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>{<br></div> \
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>const \
float val = static_cast&lt;float&gt;(iC) / static_cast&lt;float&gt;(nImageColours_ + \
1);<br></div> <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>colourMap-&gt;SetTableValue<br></div> <div \
style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>(iC<br></div> <div \
style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>, \
val<br></div> <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>, val<br></div> <div \
style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>, \
val<br></div> <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>, 1.0f);<br></div> <div \
style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>}<br></div> \
<div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>}<br></div> <div \
style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>}<br></div> \
<div style="line-height:10.8333px;">&nbsp;</div> </div>
</div>
<div style="line-height:10.8333px;">&nbsp;</div>
<div style="line-height:10.8333px;"><span \
style="line-height:10.8333px;white-space:pre-wrap;"></span><span \
style="line-height:10.8333px;">//&nbsp;</span><br></div> <div \
style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>// vtk \
callback function: stop rendering and close window<br></div> <div \
style="line-height:10.8333px;"><span \
style="line-height:10.8333px;white-space:pre-wrap;"></span><span \
style="line-height:10.8333px;">//&nbsp;</span><br></div> <div \
style="line-height:10.8333px;">&nbsp;</div> <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>static void KeyPressCallbackFunction<br></div> \
<div style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>( \
vtkObject* caller<br></div> <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>, long unsigned int \
vtkNotUsed(eventId)<br></div> <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>, void* vtkNotUsed(clientData)<br></div> <div \
style="line-height:10.8333px;"><span style="white-space:pre-wrap;"></span>, void* \
vtkNotUsed(callData))<br></div> <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>{<br></div> <div \
style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>vtkRenderWindowInteractor* \
renderWindowInteractor = \
dynamic_cast&lt;vtkRenderWindowInteractor*&gt;(caller);<br></div> <div \
style="line-height:10.8333px;">&nbsp;</div> <div style="line-height:10.8333px;"><span \
style="line-height:10.8333px;white-space:pre-wrap;"></span>// Close the \
window<br></div> <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>vtkRenderWindow* renderWindow = \
renderWindowInteractor-&gt;GetRenderWindow();<br></div> <div \
style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>renderWindow-&gt;Finalize();<br></div> <div \
style="line-height:10.8333px;">&nbsp;</div> <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>// Stop the interactor<br></div> <div \
style="line-height:10.8333px;"><span \
style="line-height:10.8333px;white-space:pre-wrap;"></span>// When the next line is \
executed, the heap corruption message is generated<br></div> <div \
style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>renderWindowInteractor-&gt;TerminateApp();<br></div>
 <div style="line-height:10.8333px;">&nbsp;</div>
<div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>std::cout &lt;&lt; "Window closed." &lt;&lt; \
std::endl;<br></div> <div style="line-height:10.8333px;"><span \
style="white-space:pre-wrap;"></span>}<br></div> </div>
</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
</div>
<div>&nbsp;</div>
<div>_______________________________________________<br></div>
<div>Powered by <a href="http://www.kitware.com">www.kitware.com</a><br></div>
<div>&nbsp;</div>
<div>Visit other Kitware open-source projects at <a \
href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br></div>
 <div>&nbsp;</div>
<div>Please keep messages on-topic and check the VTK FAQ at: <a \
href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br></div> \
<div>&nbsp;</div> <div>Search the list archives at: <a \
href="http://markmail.org/search/?q=vtkusers">http://markmail.org/search/?q=vtkusers</a><br></div>
 <div>&nbsp;</div>
<div>Follow this link to subscribe/unsubscribe:<br></div>
<div><a href="http://public.kitware.com/mailman/listinfo/vtkusers">http://public.kitware.com/mailman/listinfo/vtkusers</a><br></div>
 <div>&nbsp;</div>
</blockquote></div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div><span><span class="colour" style="color:rgb(136, 136, 136)"><span><span \
class="colour" style="color:rgb(136, 136, 136)">-- \
</span></span></span></span><br></div> <div><span><span class="colour" \
style="color:rgb(136, 136, 136)"><span><span class="colour" style="color:rgb(136, \
136, 136)">Cory Quammen<br>R&amp;D Engineer<br>Kitware, \
Inc.</span></span></span></span></div> <div>&nbsp;</div>
<div>&nbsp;</div>
</div>
</blockquote></div>
</div>
<div>&nbsp;</div>
</div>
<div>&nbsp;</div>
<div>_______________________________________________<br></div>
<div>
Powered by <a href="http://www.kitware.com">www.kitware.com</a><br></div>
<div>&nbsp;</div>
<div>
Visit other Kitware open-source projects at <a \
href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br></div>
 <div>&nbsp;</div>
<div>
Please keep messages on-topic and check the VTK FAQ at: <a \
href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br></div> \
<div>&nbsp;</div> <div>
Search the list archives at: <a \
href="http://markmail.org/search/?q=vtkusers">http://markmail.org/search/?q=vtkusers</a><br></div>
 <div>&nbsp;</div>
<div>
Follow this link to subscribe/unsubscribe:<br></div>
<div> <a href="http://public.kitware.com/mailman/listinfo/vtkusers">http://public.kitware.com/mailman/listinfo/vtkusers</a><br></div>
 <div>&nbsp;</div>
</blockquote></div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>-- <br></div>
<div><div>Ken Martin PhD<br></div>
<div><div>Chairman &amp; CFO<br></div>
<div>Kitware Inc.<br></div>
<div>28 Corporate Drive<br></div>
<div>Clifton Park NY 12065<br></div>
<div>518 371 3971<br></div>
<div>&nbsp;</div>
<div><span class="font" style="font-family:Tahoma, sans-serif"><span class="size" \
style="font-size:10pt">This communication, including all attachments, contains \
confidential and legally privileged information, and it is intended only for the use \
of the addressee.&nbsp; Access to this email by anyone else is unauthorized. If you \
are not the intended recipient, any disclosure, copying, distribution or any action \
taken in reliance on it is prohibited and may be unlawful. If you received this \
communication in error please notify us immediately and destroy the original \
message.&nbsp; Thank you.</span></span><br></div>
</div>
</div>
</div>
</blockquote><div>&nbsp;</div>
</body>
</html>



_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic