1 |
|
|
/* |
2 |
|
|
Teem: Tools to process and visualize scientific data and images . |
3 |
|
|
Copyright (C) 2013, 2012, 2011, 2010, 2009 University of Chicago |
4 |
|
|
Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann |
5 |
|
|
Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah |
6 |
|
|
|
7 |
|
|
This library is free software; you can redistribute it and/or |
8 |
|
|
modify it under the terms of the GNU Lesser General Public License |
9 |
|
|
(LGPL) as published by the Free Software Foundation; either |
10 |
|
|
version 2.1 of the License, or (at your option) any later version. |
11 |
|
|
The terms of redistributing and/or modifying this software also |
12 |
|
|
include exceptions to the LGPL that facilitate static linking. |
13 |
|
|
|
14 |
|
|
This library is distributed in the hope that it will be useful, |
15 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17 |
|
|
Lesser General Public License for more details. |
18 |
|
|
|
19 |
|
|
You should have received a copy of the GNU Lesser General Public License |
20 |
|
|
along with this library; if not, write to Free Software Foundation, Inc., |
21 |
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
22 |
|
|
*/ |
23 |
|
|
|
24 |
|
|
#include "echo.h" |
25 |
|
|
#include "privateEcho.h" |
26 |
|
|
|
27 |
|
|
void |
28 |
|
|
_echoPosSet(echoPos_t *p3, echoPos_t *matx, echoPos_t *p4) { |
29 |
|
|
echoPos_t a[4], b[4]; |
30 |
|
|
|
31 |
|
|
if (matx) { |
32 |
|
|
ELL_4V_SET(a, p4[0], p4[1], p4[2], 1); |
33 |
|
|
ELL_4MV_MUL(b, matx, a); |
34 |
|
|
ELL_34V_HOMOG(p3, b); |
35 |
|
|
} |
36 |
|
|
else { |
37 |
|
|
ELL_3V_COPY(p3, p4); |
38 |
|
|
} |
39 |
|
|
} |
40 |
|
|
|
41 |
|
|
echoObject * |
42 |
|
|
echoRoughSphereNew(echoScene *scene, int theRes, int phiRes, echoPos_t *matx) { |
43 |
|
|
echoObject *trim; |
44 |
|
|
echoPos_t *_pos, *pos, tmp[3]; |
45 |
|
|
int *_vert, *vert, thidx, phidx, n; |
46 |
|
|
echoPos_t th, ph; |
47 |
|
|
|
48 |
|
|
trim = echoObjectNew(scene, echoTypeTriMesh); |
49 |
|
|
TRIMESH(trim)->numV = 2 + (phiRes-1)*theRes; |
50 |
|
|
TRIMESH(trim)->numF = (2 + 2*(phiRes-2))*theRes; |
51 |
|
|
|
52 |
|
|
_pos = pos = (echoPos_t *)calloc(3*TRIMESH(trim)->numV, sizeof(echoPos_t)); |
53 |
|
|
_vert = vert = (int *)calloc(3*TRIMESH(trim)->numF, sizeof(int)); |
54 |
|
|
|
55 |
|
|
ELL_3V_SET(tmp, 0, 0, 1); _echoPosSet(pos, matx, tmp); pos += 3; |
56 |
|
|
for (phidx=1; phidx<phiRes; phidx++) { |
57 |
|
|
ph = AIR_AFFINE(0, phidx, phiRes, 0.0, AIR_PI); |
58 |
|
|
for (thidx=0; thidx<theRes; thidx++) { |
59 |
|
|
th = AIR_AFFINE(0, thidx, theRes, 0.0, 2*AIR_PI); |
60 |
|
|
ELL_3V_SET(tmp, cos(th)*sin(ph), sin(th)*sin(ph), cos(ph)); |
61 |
|
|
_echoPosSet(pos, matx, tmp); pos += 3; |
62 |
|
|
} |
63 |
|
|
} |
64 |
|
|
ELL_3V_SET(tmp, 0, 0, -1); _echoPosSet(pos, matx, tmp); |
65 |
|
|
|
66 |
|
|
for (thidx=0; thidx<theRes; thidx++) { |
67 |
|
|
n = AIR_MOD(thidx+1, theRes); |
68 |
|
|
ELL_3V_SET(vert, 0, 1+thidx, 1+n); vert += 3; |
69 |
|
|
} |
70 |
|
|
for (phidx=0; phidx<phiRes-2; phidx++) { |
71 |
|
|
for (thidx=0; thidx<theRes; thidx++) { |
72 |
|
|
n = AIR_MOD(thidx+1, theRes); |
73 |
|
|
ELL_3V_SET(vert, 1+phidx*theRes+thidx, 1+(1+phidx)*theRes+thidx, |
74 |
|
|
1+phidx*theRes+n); vert += 3; |
75 |
|
|
ELL_3V_SET(vert, 1+(1+phidx)*theRes+thidx, 1+(1+phidx)*theRes+n, |
76 |
|
|
1+phidx*theRes+n); vert += 3; |
77 |
|
|
} |
78 |
|
|
} |
79 |
|
|
for (thidx=0; thidx<theRes; thidx++) { |
80 |
|
|
n = AIR_MOD(thidx+1, theRes); |
81 |
|
|
ELL_3V_SET(vert, 1+(phiRes-2)*theRes+thidx, TRIMESH(trim)->numV-1, |
82 |
|
|
1+(phiRes-2)*theRes+n); |
83 |
|
|
vert += 3; |
84 |
|
|
} |
85 |
|
|
|
86 |
|
|
echoTriMeshSet(trim, TRIMESH(trim)->numV, _pos, TRIMESH(trim)->numF, _vert); |
87 |
|
|
return(trim); |
88 |
|
|
} |