I guess each time you should create a new instance of writer. Cause It's a pointer to a specific memory address, your loop will keep on rewriting into the same memory space, I'm afraid. Maybe I was wrong, but it's good to try it out.<br>Best wishes,<br>Cheng Qian<br><br>Sent from my HTC<br><br>----- Reply message -----<br>From: "Xiaopeng Yang" <yxp233@postech.ac.kr><br>Date: Tue, Aug 3, 2010 10:52<br>Subject: [Insight-users] About SetFileName in for loop<br>To: "'itk'" <Insight-users@itk.org><br><br>Hi ITK users,<br><br> <br><br>In the fast marching level set method, I tried to program a simulation<br>process for changing parameter "sigma" to get different outputs. Thus I<br>tried for loop. The problem is how to save the different results in<br>different file names. I think I need to change the code of "SetFileName". If<br>I do not change it, then the later result will replace the previous result<br>automatically. Anyone has any good idea? <br><br> <br><br>for (double sigma = 1.0; sigma <=1.4; sigma += .1) {<br><br> <br><br>...<br><br> <br><br>writer->SetFileName( "D:/fast_marching_simulation/3D.dcm" );<br><br> <br><br>...<br><br> <br><br>}<br><br> <br><br>Thank you very much!<br><br> <br><br>Xiaopeng<br><br><br><br>