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

List:       vtkusers
Subject:    Re: [vtkusers] Fwd: Re: Heap corruption | vtkLookupTable?
From:       Ken Martin <ken.martin () kitware ! com>
Date:       2016-01-28 13:28:27
Message-ID: CANXz0SasmCjAMEa7e78X8QBh9318eHhaFAK273x=hL3eEaWHng () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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 (text/html)]

<div dir="ltr">Can you try using  SetNumberOfTableValues() instead of \
SetNuberOfColors()?<div><br></div><div>Thanks</div><div>Ken</div></div><div \
class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 27, 2016 at 4:15 PM, \
Audrius Stundzia <span dir="ltr">&lt;<a href="mailto:audrius@tomographix.com" \
target="_blank">audrius@tomographix.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><u></u>




<div><div>  </div>
<div>Hi Cory,  <br></div>
<div dir="ltr"><div>  </div>
<div>Sorry that I did not respond earlier. Overlooked your e-mail.<br></div>
<div>Thank you for your reply</div>
<div>  </div>
<div>Now using<br></div>
<div>  </div>
<div><div style="font-size:12.8px">OS: Windows 10 x64<br></div>
<div style="font-size:12.8px">IDE: MS VS 2015  <br></div>
<div style="font-size:12.8px"><span>VTK</span>: 7.0.0.rc2 x64 build<br></div>
</div>
<div>  </div>
<div>Still receiving the same error message at the same place:<br></div>
<div>  </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>  </div>
<div>No idea how to create a  <span \
style="font-size:12.8px">CMakeLists.txt</span><span style="font-size:12.8px">  file. \
Please advise.</span><br></div> <div>  </div>
<div>Regards,  <br></div>
<div>  </div>
<div>Audrius<br></div>
</div>
<div><div>  </div>
<div><div>On 8 November 2015 at 15:26, Cory Quammen <span dir="ltr">&lt;<a \
href="mailto:cory.quammen@kitware.com" \
target="_blank">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>  </div>
<div>That is indeed suspicious. I don&#39;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>  </div>
<div>Thanks,<br></div>
<div>Cory<br></div>
</div>
<div><div>  </div>
<div><div>On Thu, Nov 5, 2015 at 11:19 PM, Audrius Stundzia <span dir="ltr">&lt;<a \
href="mailto:audrius@tomographix.com" \
target="_blank">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>  </div>
</div>
<div>OS: Windows 10 x64<br></div>
<div>IDE: MS VS 2015  <br></div>
<div>VTK: 6.3.0 x64 build<br></div>
<div><div>  </div>
<div>I am getting a &quot;heap corruption&quot; message when a vtkRenderWindow is \
closed and the vtkRenderWindowInteractor is stopped.<br></div> <div>Specifically the \
line <br></div> <div>  </div>
<div><span style="line-height:10.8333px">renderWindowInteractor-&gt;TerminateApp();</span><br></div>
 <div>  </div>
<div>in a callback function<br></div>
<div>  </div>
<div><span style="line-height:10.8333px">static void \
KeyPressCallbackFunction</span><br></div> <div>  </div>
<div>The relevant code fragments, appended below, are conventional texture mapping of \
an image to a plane.<br></div> <div>This &quot;heap corruption&quot; did not occur in \
Windows 8.1 x64; MS VS 2010; VTK 5.10.1 x64 build<br></div> <div>  </div>
<div>From the call stack it appears to due to a problem with deleting an \
instantiation of vtkLoopupTable:<br></div> <div>  </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>  </div>
<div>Any insight would be appreciated.<br></div>
<div>  </div>
<div>Regards,  <br></div>
<div>  </div>
<div>Audrius<br></div>
<div>  </div>
<div>//---------------------------------------<br></div>
<div><span style="line-height:1.25">// Start: relevant code fragment</span><br></div>
<div>//---------------------------------------<br></div>
<div>  </div>
<div>{<br></div>
<div>. . .<br></div>
<div>  </div>
<div><span style="line-height:10.8333px">vtkSmartPointer&lt;vtkCamera&gt;  \
</span>camera_ = <span \
style="line-height:10.8333px">vtkSmartPointer&lt;vtkCamera&gt;::New();</span><br></div>
 <div>  </div>
<div>camera_-&gt;SetPosition( 0.0, 0.0, -1.0);<br></div>
<div>camera_-&gt;SetRoll(180.0);<br></div>
<div>  </div>
<div>camera_-&gt;Zoom( zoomFactor_ );<br></div>
<div>  </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;  </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>  </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;  \
</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>  </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;  \
</span>renderWindowInteractor_ = \
vtkSmartPointer&lt;vtkRenderWindowInteractor&gt;::New();</span><br></div> <div><span \
style="line-height:10.8333px">renderWindowInteractor_-&gt;SetRenderWindow( \
renderWindow_);      </span><br></div> <div>  </div>
<div><span style="line-height:10.8333px"><span \
style="line-height:10.8333px">vtkSmartPointer&lt;vtkCallbackCommand&gt;  \
</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>  </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>  </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">  </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_)  <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">  </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">  </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();  <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">  </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">  </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">  </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">  </div> </div>
<div>renderer_-&gt;ResetCamera();<br></div>
</div>
</div>
<div>  </div>
<div>renderWindow_-&gt;Render();<br></div>
<div>renderWindow_-&gt;SetWindowName( &quot;Window name here&quot;);<br></div>
<div>  </div>
<div>renderWindowInteractor_-&gt;Start();<br></div>
<div>  </div>
<div><div><div><div><div><span style="line-height:10.8333px">. . .</span><br></div>
<div>  </div>
<div><span style="line-height:10.8333px">}</span><br></div>
</div>
<div style="line-height:10.8333px">  </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">  </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">  </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">  </div> </div>
</div>
<div style="line-height:10.8333px">  </div>
<div style="line-height:10.8333px"><span \
style="line-height:10.8333px;white-space:pre-wrap"></span><span \
style="line-height:10.8333px">//  </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">//  </span><br></div> <div \
style="line-height:10.8333px">  </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">  </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">  </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">  </div>
<div style="line-height:10.8333px"><span \
style="white-space:pre-wrap"></span>std::cout &lt;&lt; &quot;Window closed.&quot; \
&lt;&lt; std::endl;<br></div> <div style="line-height:10.8333px"><span \
style="white-space:pre-wrap"></span>}<br></div> </div>
</div>
<div>  </div>
<div>  </div>
<div>  </div>
</div>
<div>  </div>
<div>_______________________________________________<br></div>
<div>
Powered by <a href="http://www.kitware.com" \
target="_blank">www.kitware.com</a><br></div> <div>  </div>
<div>
Visit other Kitware open-source projects at <a \
href="http://www.kitware.com/opensource/opensource.html" \
target="_blank">http://www.kitware.com/opensource/opensource.html</a><br></div> <div> \
</div> <div>
Please keep messages on-topic and check the VTK FAQ at: <a \
href="http://www.vtk.org/Wiki/VTK_FAQ" \
target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br></div> <div>  </div>
<div>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" \
target="_blank">http://markmail.org/search/?q=vtkusers</a><br></div> <div>  </div>
<div>
Follow this link to subscribe/unsubscribe:<br></div>
<div> <a href="http://public.kitware.com/mailman/listinfo/vtkusers" \
target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br></div> \
<div>  </div> </blockquote></div>
<div><span><span style="color:rgb(136,136,136)"><br><br \
clear="all"></span></span></div> <div>  </div><span class="HOEnZb"><font \
color="#888888"> <div><span><span style="color:rgb(136,136,136)">-- \
<br></span></span></div> <div><span><span style="color:rgb(136,136,136)">Cory \
Quammen<br>R&amp;D Engineer<br>Kitware, Inc.</span></span></div> <div>  </div>
</font></span></div>
</blockquote></div>
</div>
<div>  </div>
</div>

<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" \
target="_blank">www.kitware.com</a><br> <br>
Visit other Kitware open-source projects at <a \
href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" \
target="_blank">http://www.kitware.com/opensource/opensource.html</a><br> <br>
Please keep messages on-topic and check the VTK FAQ at: <a \
href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" \
target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br> <br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" \
rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br> <br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" \
target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br> \
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div \
class="gmail_signature">Ken Martin PhD<div>Chairman &amp; CFO<br>Kitware Inc.<br>28 \
Corporate Drive<br>Clifton Park NY 12065<br>518 371 3971<div><br></div><div><span \
style="font-size:10pt;font-family:Tahoma,sans-serif">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.</span></div></div></div>
</div>



_______________________________________________
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