GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: src/echo/set.c Lines: 0 39 0.0 %
Date: 2017-05-26 Branches: 0 42 0.0 %

Line Branch Exec Source
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
echoSphereSet(echoObject *sphere,
29
              echoPos_t x, echoPos_t y, echoPos_t z, echoPos_t rad) {
30
31
  if (sphere && echoTypeSphere == sphere->type) {
32
    ELL_3V_SET(SPHERE(sphere)->pos, x, y, z);
33
    SPHERE(sphere)->rad = rad;
34
  }
35
  return;
36
}
37
38
void
39
echoCylinderSet(echoObject *cylind,
40
                int axis) {
41
42
  if (cylind && echoTypeCylinder == cylind->type) {
43
    CYLINDER(cylind)->axis = axis;
44
  }
45
  return;
46
}
47
48
void
49
echoSuperquadSet(echoObject *squad,
50
                 int axis, echoPos_t A, echoPos_t B) {
51
52
  if (squad && echoTypeSuperquad == squad->type) {
53
    SUPERQUAD(squad)->axis = axis;
54
    SUPERQUAD(squad)->A = A;
55
    SUPERQUAD(squad)->B = B;
56
  }
57
  return;
58
}
59
60
void
61
echoRectangleSet(echoObject *rect,
62
                 echoPos_t ogx, echoPos_t ogy, echoPos_t ogz,
63
                 echoPos_t e0x, echoPos_t e0y, echoPos_t e0z,
64
                 echoPos_t e1x, echoPos_t e1y, echoPos_t e1z) {
65
66
  if (rect && echoTypeRectangle == rect->type) {
67
    ELL_3V_SET(RECTANGLE(rect)->origin, ogx, ogy, ogz);
68
    ELL_3V_SET(RECTANGLE(rect)->edge0, e0x, e0y, e0z);
69
    ELL_3V_SET(RECTANGLE(rect)->edge1, e1x, e1y, e1z);
70
  }
71
  return;
72
}
73
74
void
75
echoTriangleSet(echoObject *tri,
76
                echoPos_t xx0, echoPos_t yy0, echoPos_t zz0,
77
                echoPos_t xx1, echoPos_t yy1, echoPos_t zz1,
78
                echoPos_t xx2, echoPos_t yy2, echoPos_t zz2) {
79
80
  if (tri && echoTypeTriangle == tri->type) {
81
    ELL_3V_SET(TRIANGLE(tri)->vert[0], xx0, yy0, zz0);
82
    ELL_3V_SET(TRIANGLE(tri)->vert[1], xx1, yy1, zz1);
83
    ELL_3V_SET(TRIANGLE(tri)->vert[2], xx2, yy2, zz2);
84
  }
85
  return;
86
}
87
88
/*
89
******** echoTriMeshSet()
90
**
91
** This has to be called any time that the locations of the points are
92
** changing, even if the connectivity is not changed, because of how
93
** the bounding box and mean vert position is calculated here.
94
**
95
** NB: the TriMesh will directly use the given pos[] and vert[] arrays,
96
** so don't go freeing them after they've been passed here.
97
*/
98
void
99
echoTriMeshSet(echoObject *trim,
100
               int numV, echoPos_t *pos,
101
               int numF, int *vert) {
102
  int i;
103
104
  if (trim && echoTypeTriMesh == trim->type) {
105
    TRIMESH(trim)->numV = numV;
106
    TRIMESH(trim)->numF = numF;
107
    TRIMESH(trim)->pos = pos;
108
    TRIMESH(trim)->vert = vert;
109
    ELL_3V_SET(TRIMESH(trim)->min, ECHO_POS_MAX, ECHO_POS_MAX, ECHO_POS_MAX);
110
    ELL_3V_SET(TRIMESH(trim)->max, ECHO_POS_MIN, ECHO_POS_MIN, ECHO_POS_MIN);
111
    ELL_3V_SET(TRIMESH(trim)->meanvert, 0.0, 0.0, 0.0);
112
    for (i=0; i<numV; i++) {
113
      ELL_3V_MIN(TRIMESH(trim)->min, TRIMESH(trim)->min, pos + 3*i);
114
      ELL_3V_MAX(TRIMESH(trim)->max, TRIMESH(trim)->max, pos + 3*i);
115
      ELL_3V_INCR(TRIMESH(trim)->meanvert, pos + 3*i);
116
    }
117
    ELL_3V_SCALE(TRIMESH(trim)->meanvert, 1.0/numV, TRIMESH(trim)->meanvert);
118
  }
119
  return;
120
}
121
122
void
123
echoInstanceSet(echoObject *inst,
124
                echoPos_t *M, echoObject *obj) {
125
126
  if (inst && echoTypeInstance == inst->type) {
127
    ell_4m_INV(INSTANCE(inst)->Mi, M);
128
    ELL_4M_COPY(INSTANCE(inst)->M, M);
129
    INSTANCE(inst)->obj = obj;
130
  }
131
}