Moka libraries
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mv-array-allocation.cc
Go to the documentation of this file.
1 /*
2  * lib-mesh : Opérations de maillage et lissage.
3  * Copyright (C) 2004, Moka Team, Université de Poitiers, Laboratoire SIC
4  * http://www.sic.sp2mi.univ-poitiers.fr/
5  * Copyright (C) 2009, Guillaume Damiand, CNRS, LIRIS,
6  * guillaume.damiand@liris.cnrs.fr, http://liris.cnrs.fr/
7  *
8  * This file is part of lib-mesh
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 //******************************************************************************
25 #include "g-map-vertex.hh"
26 #include "mesh-vertex.hh"
27 #include <cassert>
28 using namespace GMap3d;
29 //******************************************************************************
30 CVertex* CMeshVertex::allocVertexArray1(int ADimX)
31 {
32  assert(ADimX>0);
33 
34  return new CVertex[ADimX];
35 }
36 //------------------------------------------------------------------------------
37 void CMeshVertex::freeVertexArray1(CVertex* AArray1, int /*ADimX*/)
38 {
39  assert(AArray1!=NULL);
40 
41  delete [] AArray1;
42 }
43 //******************************************************************************
44 CVertex** CMeshVertex::allocVertexArray2(int ADimX, int ADimY)
45 {
46  assert(ADimX>0);
47  assert(ADimY>0);
48 
49  CVertex** result = new CVertex* [ADimX];
50 
51  for (int i=0; i<ADimX; ++i)
52  result[i] = allocVertexArray1(ADimY);
53 
54  return result;
55 }
56 //------------------------------------------------------------------------------
57 void CMeshVertex::freeVertexArray2(CVertex** AArray2, int ADimX, int ADimY)
58 {
59  assert(AArray2!=NULL);
60 
61  for (int i=0; i<ADimX; ++i)
62  freeVertexArray1(AArray2[i], ADimY);
63 
64  delete [] AArray2;
65 }
66 //******************************************************************************
67 CVertex*** CMeshVertex::allocVertexArray3(int ADimX, int ADimY, int ADimZ)
68 {
69  assert(ADimX>0);
70  assert(ADimY>0);
71  assert(ADimZ>0);
72 
73  CVertex*** result = new CVertex** [ADimX];
74 
75  for (int i=0; i<ADimX; ++i)
76  result[i] = allocVertexArray2(ADimY, ADimZ);
77 
78  return result;
79 }
80 //------------------------------------------------------------------------------
81 void CMeshVertex::freeVertexArray3(CVertex*** AArray3,
82  int ADimX, int ADimY, int ADimZ)
83 {
84  assert(AArray3!=NULL);
85 
86  for (int i=0; i<ADimX; ++i)
87  freeVertexArray2(AArray3[i], ADimY, ADimZ);
88 
89  delete [] AArray3;
90 }
91 //******************************************************************************
92 const CVertex** CMeshVertex::allocVertexPtrArray1(int ADimX)
93 {
94  assert(ADimX>0);
95 
96  return new const CVertex* [ADimX];
97 }
98 //------------------------------------------------------------------------------
99 void CMeshVertex::freeVertexPtrArray1(const CVertex** AArray1, int /*ADimX*/)
100 {
101  assert(AArray1!=NULL);
102 
103  delete [] AArray1;
104 }
105 //******************************************************************************
106 const CVertex*** CMeshVertex::allocVertexPtrArray2(int ADimX, int ADimY)
107 {
108  assert(ADimX>0);
109  assert(ADimY>0);
110 
111  const CVertex*** result = new const CVertex** [ADimX];
112 
113  for (int i=0; i<ADimX; ++i)
114  result[i] = allocVertexPtrArray1(ADimY);
115 
116  return result;
117 }
118 //------------------------------------------------------------------------------
119 void CMeshVertex::freeVertexPtrArray2(const CVertex*** AArray2,
120  int ADimX, int ADimY)
121 {
122  assert(AArray2!=NULL);
123 
124  for (int i=0; i<ADimX; ++i)
125  freeVertexPtrArray1(AArray2[i], ADimY);
126 
127  delete [] AArray2;
128 }
129 //******************************************************************************
130 const CVertex**** CMeshVertex::allocVertexPtrArray3(int ADimX, int ADimY, int ADimZ)
131 {
132  assert(ADimX>0);
133  assert(ADimY>0);
134  assert(ADimZ>0);
135 
136  const CVertex**** result = new const CVertex*** [ADimX];
137 
138  for (int i=0; i<ADimX; ++i)
139  result[i] = allocVertexPtrArray2(ADimY, ADimZ);
140 
141  return result;
142 }
143 //------------------------------------------------------------------------------
144 void CMeshVertex::freeVertexPtrArray3(const CVertex**** AArray3,
145  int ADimX, int ADimY, int ADimZ)
146 {
147  assert(AArray3!=NULL);
148 
149  for (int i=0; i<ADimX; ++i)
150  freeVertexPtrArray2(AArray3[i], ADimY, ADimZ);
151 
152  delete [] AArray3;
153 }
154 //******************************************************************************