]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/kernel/include/marIsocontour.cpp
*** empty log message ***
[creaMaracasVisu.git] / lib / maracasVisuLib / src / kernel / include / marIsocontour.cpp
1 /*=========================================================================
2
3  Program:   wxMaracas
4  Module:    $RCSfile: marIsocontour.cpp,v $
5  Language:  C++
6  Date:      $Date: 2009/05/14 13:55:08 $
7  Version:   $Revision: 1.1 $
8  
9   Copyright: (c) 2002, 2003
10   License:
11   
12    This software is distributed WITHOUT ANY WARRANTY; without even 
13    the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14    PURPOSE.  See the above copyright notice for more information.
15    
16 =========================================================================*/
17
18
19 #include "marIsocontour.h"
20
21 // ----------------------------------------------------------------------------
22 marIsocontour::marIsocontour() {
23         intmax = -1;
24 }
25
26 // ----------------------------------------------------------------------------
27 marIsocontour::~marIsocontour() {
28         
29         //TODO - SACAR A UTILS
30         for (int ind = 0; ind < listContour.size(); ind++)
31         {
32                 marPoint* p = listContour[ind];
33                 listContour[ind] = NULL;
34                 delete p;
35                 
36         }
37         listContour.clear();
38
39 }
40
41 // ----------------------------------------------------------------------------
42 marIsocontour::marIsocontour(double intmax) {
43         this->intmax = intmax;
44 }
45         
46 // ----------------------------------------------------------------------------
47 void marIsocontour::getCG(double *x, double *y) {
48    double sumax = 0;
49    double sumay = 0;
50
51         for (int i = 0; i < listContour.size(); i++){
52                 double x, y;
53                 getPoint(i, &x, &y);
54                 sumax +=x;
55                 sumay +=y;
56         }
57
58         sumax /= listContour.size();
59         sumay /= listContour.size();
60
61         *x = (double) sumax;
62         *y = (double) sumay;
63 }
64
65 // ----------------------------------------------------------------------------
66 void marIsocontour::insertPoint(double x, double y) {
67         marPoint* p = new marPoint(x, y);
68         listContour.push_back(p);
69 }
70
71 // ----------------------------------------------------------------------------
72 void marIsocontour::getPoint(int i, double *x, double *y) {
73         marPoint* p = listContour[i];
74         *x = p->getX();
75         *y = p->getY();
76
77 }
78
79 // ----------------------------------------------------------------------------
80 void marIsocontour::setPoint(int i, double x, double y) {
81         marPoint *p = listContour[i];
82         p->setPoint(x, y);
83 }
84
85 // ----------------------------------------------------------------------------
86 int marIsocontour::getSize() {
87         return listContour.size();
88 }
89
90 // ----------------------------------------------------------------------------
91 double marIsocontour::getMaxIntensity() {
92         return intmax;
93 }
94
95 // ----------------------------------------------------------------------------
96 int marIsocontour::getType() {
97         return type;
98 }
99
100 // ----------------------------------------------------------------------------
101 void marIsocontour::setType(int type) {
102         this->type = type;
103 }
104
105 // ----------------------------------------------------------------------------
106 int marIsocontour::getDir(int i) {
107         marPoint* p = listContour[i];
108         return p->getDirection();
109 }
110
111 // ----------------------------------------------------------------------------
112 void marIsocontour::setDir(int i, int direction) {
113         marPoint *p = listContour[i];
114         p->setDirection(direction);
115 }
116
117 // ----------------------------------------------------------------------------
118 void marIsocontour::setInside(int i, bool ins) {
119         marPoint *p = listContour[i];
120         p->setInside(ins);
121 }
122
123 // ----------------------------------------------------------------------------
124 bool marIsocontour::getInside(int i) {
125         marPoint* p = listContour[i];
126         return p->getInside();
127 }
128
129 // ----------------------------------------------------------------------------
130 void marIsocontour::setMaxIntensity(double intmax) {
131         this->intmax = intmax;
132 }
133
134 // ----------------------------------------------------------------------------
135 void marIsocontour::removeLastPoint() {
136         listContour.pop_back();
137 }
138