<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Message</TITLE>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2769" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2><SPAN class=409505521-27102005>I was trying to
follow the applications example itkfilterlib. In that example, the smart
pointer to input and output image, as well as the smart pointer to filter,
are declared as a global variable. SetReferenceCount(2) was called to
ensure the persistance of the filter and image data. </SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=409505521-27102005>First, I don't
understand why we have to reset the referenceCount. Since the pointer are global
variable, it should still exist after the function returns.
</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=409505521-27102005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=409505521-27102005>Now, I want to build
a lib involves itkMesh manipulation. According to my understanding, we
can't pass a pointer containing the points to the itkMesh object like the
example did on itkImage. So we have to actually construct the itkMesh
object as the itk software guide illustrates, right? Now do we have to set
reference count in this case? </SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=409505521-27102005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=409505521-27102005>I may call the
itkMesh construction routine several times to create different input mesh.
I guess I need to make sure the previous mesh has been
destroyed. </SPAN></FONT><FONT face=Arial size=2><SPAN
class=409505521-27102005> Will SetReferenceCount(0) make sure that it will
be destroyed or we can call initialize() to do that? </SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=409505521-27102005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=409505521-27102005>#include
<itkMesh.h></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=409505521-27102005>typedef
itk::Mesh<g_internalDataType>
g_MeshType;</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=409505521-27102005>g_MeshType::Pointer
g_InputMesh;</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=409505521-27102005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=409505521-27102005>mylib::mylib()</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=409505521-27102005>{</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=409505521-27102005> g_InputMesh =
g_MeshType::New();</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=409505521-27102005> g_InputMesh->SetReferenceCount(2);
//necessary?</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=409505521-27102005>}</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=409505521-27102005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=409505521-27102005>void
mylib::CreateInputMesh(int& _nf, Vector<long, 3>* tricells, int&
_np, Vector<float, 3>* points)</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=409505521-27102005>{</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=409505521-27102005>
<DIV><FONT face=Arial size=2><SPAN class=409505521-27102005>
g_InputMesh->SetReferenceCount(0);</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=409505521-27102005> g_InputMesh =
g_MeshType::New(); </SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=409505521-27102005>//
or</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=409505521-27102005> g_InputMesh->Initialize();</SPAN></FONT></DIV></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=409505521-27102005>// construct
g_InputMesh</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=409505521-27102005>...</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=409505521-27102005>}</SPAN></FONT></DIV></BODY></HTML>