Hi,<div><br></div><div>In wanting to add programmatically a LUT to a VRTComplexSource, I read the VRT driver source code.</div><div>VRTComplexSource have three public attributes : <i>double *padfLUTInputs</i>, <i>double *padfLUTOutputs</i> and <i>int nLUTItemCount.</i></div>
<div><i><br></i></div><div>To set the LUT we have to affect directly two pointers and set the number of elements. There&#39;s no other method to set the LUT.</div><div>Maybe in other langage like Python it can be useful. But in C++, I think it&#39;s wrong for encapsulation.</div>
<div><br></div><div>But the worst think in my opinion is the VRTComplexSource destructor :</div><div><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
VRTComplexSource::~VRTComplexSource()<br>{<br>    if (padfLUTInputs)<br>        VSIFree( padfLUTInputs );<br>    if (padfLUTOutputs)<br>        VSIFree( padfLUTOutputs );<br>}</blockquote><div> </div></div><div>The destructor frees the two pointer. This can be an issue if I do that :</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">double padfLUTInputs[] = {0,1,2};</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
double padfLUTOutputs[] = {4,5,6};</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">complexSource-&gt;padfLUTInputs = padfLUTInputs ; complexSource-&gt;padfLUTOutputs = padfLUTOutputs;</blockquote>
<div><br></div><div>And what happens if I want to change the LUT? </div><div><br></div><div>I suggest to add a method VRTComplexSource::setLUT (const double *, const double *, int), and to make the public attributes protected.</div>
<div>The setLUT method frees the pointers, and clones the tables.</div><div><br></div><div>Best regards</div>