Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/med.git] / src / MedClient / test / test2 / Compo2.cxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef _DEBUG_
24 #define _DEBUG_
25 #endif
26
27 #include "Compo2.hxx"
28 #include <utilities.h>
29 #include <typeinfo>
30 #include <iostream>
31
32 using namespace MEDMEM;
33 using namespace MED_EN;
34
35 Compo2::Compo2() : _F(NULL)
36 {
37 }
38
39 Compo2::~Compo2()
40 {
41   if (_F) delete _F;
42 }
43
44 std::string Compo2::Calcul(const MESH &M)
45 {
46   const char* LOC = "std::string Compo2::Calcul(MESH &M)";
47   BEGIN_OF(LOC);
48
49   MESSAGE("type virtuel : MESH");
50   MESSAGE("type reel : " << typeid(M).name());
51
52   std::string name = M.getName();
53
54   name += " recu";
55
56   try {
57     std::cerr << M << std::endl;
58   }
59   catch (...) {
60     std::cerr << "erreur Compo2::Calcul" << std::endl;
61   }
62
63   END_OF(LOC);
64   return name;
65 }
66
67 const FAMILY * Compo2::Calcul2(const MESH &M)
68 {
69   const char* LOC = "const FAMILY * Compo2::Calcul2(const MESH &M)";
70   BEGIN_OF(LOC);
71
72   const FAMILY * F = M.getFamily(MED_CELL, 1);
73   std::cerr << "ok ici 2" << std::endl;
74   try {
75     std::cout << F << std::endl;
76   }
77   catch (...) {
78     std::cerr << "erreur Compo2::Calcul2" << std::endl;
79   }
80
81   END_OF(LOC);
82   return F;
83 }
84
85 void Compo2::Calcul3(const FIELD<double> &F)
86 {
87   const char* LOC = "void Compo2::Calcul3(const FIELD<double> *)";
88   BEGIN_OF(LOC);
89
90   const double *v = F.getValue();
91   long i, n = F.getSupport()->getNumberOfElements(MED_CELL);
92   int j, m = F.getNumberOfComponents();
93
94   for (i=0; i<n; i++) {
95     std::cout << i << " : ";
96     for (j=0; j<m; j++)
97       std::cout << v[j + i*m];
98     std::cout << std::endl;
99   }
100   
101   END_OF(LOC);
102 }