<p>Hi, I have been trying to develop special surface model using java and vtk 5.4.0. Therefore I have created class that derives from vtkParametricFunction. I have overriden required virtual methods from vtkParametricFunction class, that's: Evaluate, EvaluateScalar and GetDimension(). Variables like MinimumU, MaximumV etc, according to documentation, are protected in my base class (vtkParametricFunction). MySurface should then be available for using it. Source code of all these functions look as below main message. In my opinion I probably have faultless object intialization in the constructor. The problem is: the program execution fails at object initializations lines in constructor. That is: the execution of virtual machine breaks with error message:The crash happened outside the Java Virtual Machine in native code, EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x5c2e2e5c, pid=5264, tid=4908. The mystical lines are:</p>
<p>this.SetMinimumU(-Math.PI);<br> this.SetMaximumU(Math.PI);<br> this.SetMaximumV(Math.PI);<br> this.SetMinimumV(-Math.PI);<br> this.SetJoinU(1);<br> this.SetJoinV(1);<br> <br> this.SetTwistU(0);<br> this.SetTwistV(0);<br>
this.ClockwiseOrderingOn();<br> this.DerivativesAvailableOn();<br>If I comment out these lines and setup custom initialization on all required variables(like MinimumU) the break up problem still exists, but objects initialization completes with success. Even then have I never observed the execution of code in Evaluate method what is strange for me ( program breakup before calling evaluate method). <br>
</p><p>Well at first sight it seems to be problem with JNI. Can anyone say me what I am doing wrong so that executions is brought up while initializing this class? How to implement custom surface? What I am doing wrong in this code and this method (inheritance from vtkParametricFunction). Is there another mechanism to provide to vtk custom surface? <br>
</p><p>Gregory</p><p></p><p>This is my class code:</p><p>package Surfaces;<br><br>import java.lang.Math;<br><br><br>import vtk.vtkMath;<br>import vtk.vtkParametricFunction;<br>import vtk.vtkParametricMobius;<br><br>public class MySurface extends vtkParametricFunction {<br>
protected int a;<br><br><br> public MySurface()<br> {<br> super();<br> this.SetMinimumU(-Math.PI);<br> this.SetMaximumU(Math.PI);<br> this.SetMaximumV(Math.PI);<br> this.SetMinimumV(-Math.PI);<br> this.SetJoinU(1);<br>
this.SetJoinV(1);<br> <br> this.SetTwistU(0);<br> this.SetTwistV(0);<br> this.ClockwiseOrderingOn();<br> this.DerivativesAvailableOn();<br> this.a=2;<br> }<br> <br> @Override<br> public void Evaluate(double[] id0, double[] id1, double[] id2) {<br>
// TODO Auto-generated method stub<br> double u = id0[0];<br> double v = id0[1];<br> id1[0] = f(u,v);<br> id1[1] = g(u,v);<br> id1[2] = h(u,v);<br> <br> id2[0] = xu(u,v);<br> id2[1] = xv(u,v);<br> id2[3] = yu(u,v);<br>
id2[4] = yv(u,v);<br> id2[6] = zu(u,v);<br> id2[7] = zu(u,v);<br> }<br><br> @Override<br> public double EvaluateScalar(double[] id0, double[] id1, double[] id2) {<br> // TODO Auto-generated method stub<br> return 0;<br>
}<br><br> protected double f(double u,double v)<br> {<br> return Math.cos(u)*(a+ Math.sin(v)* Math.cos(u)- Math.sin(2*v)* Math.sin(u)/2);<br> }<br> <br> protected double g(double u,double v)<br> {<br> return Math.sin(u)*(a+ Math.sin(v)* Math.cos(u)- Math.sin(2*v)* Math.sin(u)/2);<br>
}<br> <br> protected double h(double u,double v)<br> {<br> return Math.sin(u)*Math.sin(v)+Math.cos(u)*Math.sin(2 * v)/2;<br> }<br> <br> /**<br> * Computes derivative of f function over x variable and along u axis<br> * @param u<br>
* @param v<br> * @return Derivative<br> */<br> protected double xu(double u,double v)<br> {<br> return -g(u,v) + Math.cos(u)*(-Math.sin(v)*Math.sin(u)-Math.sin(2*v)*Math.cos(u)/2);<br> }<br> <br> /**<br> * Computes derivative of f function over x variable and along v axis<br>
* @param u<br> * @param v<br> * @return<br> */<br> protected double xv(double u,double v)<br> {<br> return Math.cos(u)*(Math.cos(v)*Math.cos(u)-Math.cos(2*v)*Math.sin(u));<br> }<br> <br> protected double yu(double u,double v)<br>
{<br> return f(u,v)+Math.sin(u)*(-Math.sin(v)*Math.sin(u)-Math.sin(2*v)*Math.cos(u)/2);<br> }<br> <br> /**<br> * Computes derivative of f function over y variable and along v axis<br> * @param u<br> * @param v<br> * @return<br>
*/<br> protected double yv(double u,double v)<br> {<br> return Math.sin(u)*(Math.cos(v)*Math.cos(u)-Math.cos(2*v)*Math.sin(u));<br> }<br> <br> protected double zu(double u,double v)<br> {<br> return Math.sin(v)*Math.cos(u)-Math.sin(2*v)*Math.sin(u)/2;<br>
}<br> <br> protected double zv(double u,double v)<br> {<br> return Math.cos(v)*Math.sin(u)+Math.cos(2*v)*Math.cos(u);<br> }<br>}<br><br></p>