]> gerrit.simantics Code Review - simantics/3d.git/blob - org.jcae.opencascade/src/GeomLProp_SLProps.i
Compiler warning elimination
[simantics/3d.git] / org.jcae.opencascade / src / GeomLProp_SLProps.i
1 /*
2  * Project Info:  http://jcae.sourceforge.net
3  * 
4  * This program is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License as published by the Free
6  * Software Foundation; either version 2.1 of the License, or (at your option)
7  * any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program; if not, write to the Free Software Foundation, Inc.,
16  * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
17  *
18  * (C) Copyright 2005, by EADS CRC
19  */
20
21 /**
22  * GeomLProp_SLProps
23  */
24  %{#include "GeomLProp_SLProps.hxx"%}
25
26  %typemap(javacode) GeomLProp_SLProps
27 %{
28         /**
29          * @deprecated Typo mistake in the previous version
30          */
31         public void setParameter(double u, double v)
32         {
33                 setParameters(u, v);
34         }
35         
36         public double[] normal()
37         {
38                 double[] toReturn=new double[3];
39                 normal(toReturn);
40                 return toReturn;
41         }
42         
43         /**Return the normal on the uv nodes.<br>
44          *Invalid ones are set to zero.
45          */
46         public double[] normalArray(double[] uvNodes)
47         {
48                 if(uvNodes==null)
49                         throw new NullPointerException();
50                 
51                 if(uvNodes.length%2!=0)
52                         throw new IllegalArgumentException("uvNodes array length must be peer");
53                         
54                 int numNodes=uvNodes.length/2;
55                 double[] toReturn=new double[numNodes*3];
56                 normalArray(uvNodes,toReturn,numNodes);
57                 
58                 return toReturn;
59         }
60         
61         public double[] curvatureDirections()
62         {
63                 double[] toReturn=new double[6];
64                 if(isCurvatureDefined())
65                 {
66                         double[] max=new double[3];
67                         double[] min=new double[3];
68                         curvatureDirection(max, min);
69                         System.arraycopy(max, 0, toReturn, 0, 3);
70                         System.arraycopy(min, 0, toReturn, 3, 3);
71                 }
72                 return toReturn;
73         }
74 %}
75
76 class GeomLProp_SLProps
77 {
78         %rename(setParameters) SetParameters;
79         %rename(value) Value;
80         %rename(d1U) D1U;
81         %rename(d1V) D1V;
82         %rename(d2U) D2U;
83         %rename(d2V) D2V;
84         %rename(dUV) DUV;
85         %rename(isTangentUDefined) IsTangentUDefined;
86         %rename(tangentU) TangentU;
87         %rename(isTangentVDefined) IsTangentVDefined;
88         %rename(tangentV) TangentV;
89         %rename(isNormalDefined) IsNormalDefined;
90         %rename(isCurvatureDefined) IsCurvatureDefined;
91         %rename(isUmbilic) IsUmbilic;
92         %rename(meanCurvature) MeanCurvature;
93         %rename(gaussianCurvature) GaussianCurvature;
94         %rename(setSurface) SetSurface;
95
96         public:
97         %javamethodmodifiers GeomLProp_SLProps(const Standard_Integer, const Standard_Real) "
98         /**
99          * The current point and the derivatives are computed at the same time,
100          * which allows an optimization of the computation time.
101          * @param degree The maximum number of derivations to be done (0, 1, or 2).
102          * For example, to compute only the tangent, N should be equal to 1.
103          * @param resolution The linear tolerance (it is used to test if a vector is null).
104          */
105         public";
106         
107         %javamethodmodifiers normalArray(double*, double*, int) "private";
108
109         GeomLProp_SLProps(const Standard_Integer degree, const Standard_Real resolution);
110         void SetParameters(const Standard_Real u, const Standard_Real v) ;
111         const gp_Pnt& Value() const;
112         const gp_Vec& D1U() ;
113         const gp_Vec& D1V() ;
114         const gp_Vec& D2U() ;
115         const gp_Vec& D2V() ;
116         const gp_Vec& DUV() ;
117         Standard_Boolean IsTangentUDefined() ;
118         void TangentU(gp_Dir& D) ;
119         Standard_Boolean IsTangentVDefined() ;
120         void TangentV(gp_Dir& D) ;
121         Standard_Boolean IsNormalDefined() ;
122         Standard_Boolean IsCurvatureDefined() ;
123         Standard_Boolean IsUmbilic() ;
124         Standard_Real MeanCurvature() ;
125         Standard_Real GaussianCurvature() ;
126         void SetSurface(const Handle_Geom_Surface & S) ;
127 };
128
129 %extend GeomLProp_SLProps
130 {
131         void normal(double normal[3])
132         {
133                 if(!self->IsNormalDefined())
134                 {
135                         normal[0]=0;
136                         normal[1]=0;
137                         normal[2]=0;
138                 }
139                 else
140                 {
141                         const gp_Dir & d=self->Normal();
142                         normal[0]=d.X();
143                         normal[1]=d.Y();
144                         normal[2]=d.Z();
145                 }
146         }
147         
148         void normalArray(double* uvNodes,double* normalArray,int numNodes)
149         {
150                 for(int i=0;i<numNodes;i++)
151                 {
152                         self->SetParameters(uvNodes[2*i],uvNodes[2*i+1]);
153                         
154                         if(!self->IsNormalDefined())
155                         {
156                                 normalArray[3*i]=0;
157                                 normalArray[3*i+1]=0;
158                                 normalArray[3*i+2]=0;
159                         }
160                         else
161                         {
162                                 const gp_Dir & d=self->Normal();
163                                 
164                                 normalArray[3*i]=d.X();
165                                 normalArray[3*i+1]=d.Y();
166                                 normalArray[3*i+2]=d.Z();
167                         }
168                 }
169         }
170
171         Standard_Real minCurvature()
172         {
173                 if (!self->IsCurvatureDefined())
174                         return sqrt(-1.0);
175                 else
176                         return self->MinCurvature ();
177         }
178
179         Standard_Real maxCurvature()
180         {
181                 if (!self->IsCurvatureDefined())
182                         return sqrt(-1.0);
183                 else
184                         return self->MaxCurvature ();
185         }
186         
187         void curvatureDirection(double jmax[3], double jmin[3])
188         {
189                 gp_Dir max, min;
190                 self->CurvatureDirections(max, min);
191                 jmax[0]=max.X();
192                 jmax[1]=max.Y();
193                 jmax[2]=max.Z();
194                 jmin[0]=min.X();
195                 jmin[1]=min.Y();
196                 jmin[2]=min.Z();
197         }
198 };