<div>Hello Experts,,</div>
<div> </div>
<div>My question is a TCL question rather than a VTK question. I hope it is fine with other members. At the end, is the part of my code required for understanding my question.</div>
<div> </div>
<div>If you look at my code, I have defined 2 procedures: MakeSTLActor and MakeDataActor. The main function call these procedures whenever required. Now, when these procedures are called for the 1st time, only the highlighted portion of the procedure gets the job done. </div>
<div> </div>
<div>If the procedure is called again for the 2nd time, the interpreter give error saying that objects partMapper and partActoro (in MakeSTLActor procedure; this also implies for the objects in the other procedure) is already created. So, I can delete the partMapper object as soon as its job is done (specifically, after creation of partActoro). But I cannot delete partActoro because I have to return this object. So, next time when the procedure is called, I get the error regarding the existence of partActoro. </div>
<div> </div>
<div>At, this point I am using flags in my procedures (closeevent, isotrack), to delete the objects before calling the procedure for 2nd time. Although, my script runs without any bugs, I think this might not be the most elegant way of doing it. So, does any one knows a way by which I can avoid using the flags in my procedure and delete the objects (partActoro and dataActoro in the 2 procedures) before/while the return to the main function.</div>
<div> </div>
<div>Let me know if I need to clarify my question.</div>
<div> </div>
<div>Thank You,</div>
<div> </div>
<div>Sanket Jain</div>
<div> </div>
<div> </div>
<div># CODE STARTS HERE......</div>
<div><span lang="EN">
<p>package require vtk</p>
<p>package require </p>
<p>vtkinteractionpackage require vtktesting</p>
<p>#... Relevant Tk Codes for building the GUI. </p>
<p></p>
<p>proc main {} {</p>
<p>#......Some Relevant TCL Codes</p>
<p></p>
<p>vtkActor partActor</p>
<p>set partActor [<font color="#993399">MakeSTLActor</font> vtkSTLReader part] </p>
<p>[$partActor GetProperty] SetOpacity 1</p>
<p></p>
<p>vtkActor dataActor</p>
<p>set dataActor [<font color="#6600cc">MakeDataActor</font> vtkConnectivityFilter connect] </p>
<p>#.... Other Relevant TCL Codes </p>
<p>} </p>
<p>#Make Actor for STL File</p>
<p>proc MakeSTLActor {vtkSTLReader part} {</p>
<p>global closeevent</p>
<p>global isotrack</p>
<p></p>
<p>if {$isotrack==1} {</p>
<p>partMapper Delete</p>
<p>partActoro Delete</p>
<p>}</p>
<p></p>
<p>if {$closeevent == 0} {</p>
<p>partMapper Delete</p>
<p>partActoro Delete</p>
<p>} else {</p>
<p><font style="BACKGROUND-COLOR: #ffff33">vtkPolyDataMapper partMapper</font></p>
<p><font style="BACKGROUND-COLOR: #ffff33">partMapper SetInputConnection [$part GetOutputPort]</font></p>
<p><font style="BACKGROUND-COLOR: #ffff33"></font></p>
<p><font style="BACKGROUND-COLOR: #ffff33">vtkActor partActoro</font></p>
<p><font style="BACKGROUND-COLOR: #ffff33">partActoro SetMapper partMapper</font></p>
<p><font style="BACKGROUND-COLOR: #ffff33"></font></p>
<p><font style="BACKGROUND-COLOR: #ffff33">return partActoro</font></p>
<p>} </p>
<p>}</p>
<p># Makes Actor for the Original Data</p>
<p>proc MakeDataActor {vtkConnectivityFilter connecto} {</p>
<p>global closeevent</p>
<p>global isotrack</p>
<p></p>
<p>if {$isotrack==1} {</p>
<p>dataMapper Delete</p>
<p>prop Delete</p>
<p>dataActoro Delete</p>
<p>}</p>
<p></p>
<p>if {$closeevent == 0} {</p>
<p>dataMapper Delete</p>
<p>prop Delete</p>
<p>dataActoro Delete</p>
<p>} else {</p>
<p><font style="BACKGROUND-COLOR: #ffff33">vtkDataSetMapper dataMapper</font></p>
<p><font style="BACKGROUND-COLOR: #ffff33">dataMapper SetInputConnection [$connecto GetOutputPort]</font></p>
<p><font style="BACKGROUND-COLOR: #ffff33"></font></p>
<p><font style="BACKGROUND-COLOR: #ffff33">vtkProperty prop</font></p>
<p><font style="BACKGROUND-COLOR: #ffff33">prop SetOpacity 0.1</font></p>
<p><font style="BACKGROUND-COLOR: #ffff33"></font></p>
<p><font style="BACKGROUND-COLOR: #ffff33">vtkActor dataActoro</font></p>
<p><font style="BACKGROUND-COLOR: #ffff33">dataActoro SetMapper dataMapper</font></p>
<p><font style="BACKGROUND-COLOR: #ffff33">dataActoro SetProperty prop</font></p>
<p><font style="BACKGROUND-COLOR: #ffff33">dataActoro SetOrigin 0 0 0</font></p>
<p><font style="BACKGROUND-COLOR: #ffff33"></font></p>
<p><font style="BACKGROUND-COLOR: #ffff33">return dataActoro</font></p>
<p>}</p>
<p>}</p>
<p>#.... Similarly Defining other procedures</p>
<p>#which creates actors and returns to the main</p>
<p>#function which renders them. </p></span><br clear="all"><br>-- <br>Sanket Jain<br></div>