LORENE
base_vect_from_file.C
1/*
2 * Methods for Base_vect and file manipulation
3 *
4 * (see file base_vect.h for documentation)
5 */
6
7/*
8 * Copyright (c) 2000-2001 Eric Gourgoulhon
9 *
10 * This file is part of LORENE.
11 *
12 * LORENE is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * LORENE is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with LORENE; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 */
27
28
29
30/*
31 * $Id: base_vect_from_file.C,v 1.6 2016/12/05 16:17:44 j_novak Exp $
32 * $Log: base_vect_from_file.C,v $
33 * Revision 1.6 2016/12/05 16:17:44 j_novak
34 * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
35 *
36 * Revision 1.5 2014/10/13 08:52:39 j_novak
37 * Lorene classes and functions now belong to the namespace Lorene.
38 *
39 * Revision 1.4 2014/10/06 15:12:57 j_novak
40 * Modified #include directives to use c++ syntax.
41 *
42 * Revision 1.3 2002/10/16 14:36:31 j_novak
43 * Reorganization of #include instructions of standard C++, in order to
44 * use experimental version 3 of gcc.
45 *
46 * Revision 1.2 2001/12/04 21:27:52 e_gourgoulhon
47 *
48 * All writing/reading to a binary file are now performed according to
49 * the big endian convention, whatever the system is big endian or
50 * small endian, thanks to the functions fwrite_be and fread_be
51 *
52 * Revision 1.1.1.1 2001/11/20 15:19:28 e_gourgoulhon
53 * LORENE
54 *
55 * Revision 2.0 2000/02/09 13:25:23 eric
56 * *** empty log message ***
57 *
58 *
59 * $Header: /cvsroot/Lorene/C++/Source/Base_vect/base_vect_from_file.C,v 1.6 2016/12/05 16:17:44 j_novak Exp $
60 *
61 */
62
63// Headers C
64#include <cstdlib>
65
66// Header Lorene
67#include "headcpp.h"
68#include "base_vect.h"
69#include "utilitaires.h"
70
71 //--------------------------------------//
72 // Identification virtual functions //
73 //--------------------------------------//
74
75
76namespace Lorene {
77int Base_vect_cart::identify() const { return 1; }
78
79int Base_vect_spher::identify() const { return 2; }
80
81
82
83 //--------------------------------------//
84 // Base_vect construction from a file //
85 //--------------------------------------//
86
88
89 Base_vect* p_bvect ;
90
91 // Type (class) of vectorial basis identificator ;
92 int identificator ;
93 fread_be(&identificator, sizeof(int), 1, fich) ;
94
95 switch(identificator) {
96
97 case 1 : {
98 p_bvect = new Base_vect_cart(fich) ;
99 break ;
100 }
101
102 case 2 : {
103 p_bvect = new Base_vect_spher(fich) ;
104 break ;
105 }
106
107 default : {
108 cout << "Base_vect::bvect_from_file : unknown type of Base_vect!"
109 << endl ;
110 cout << " identificator = " << identificator << endl ;
111 abort() ;
112 break ;
113 }
114
115 }
116
117 return p_bvect ;
118
119}
120
121}
Cartesian vectorial bases (triads).
Definition base_vect.h:201
virtual int identify() const
Returns a number to identify the sub-classe of Base_vect the object belongs to.
Spherical orthonormal vectorial bases (triads).
Definition base_vect.h:308
virtual int identify() const
Returns a number to identify the sub-classe of Base_vect the object belongs to.
Base_vect()
Standard constructor.
Definition base_vect.C:90
static Base_vect * bvect_from_file(FILE *)
Construction of a vectorial basis from a file (see sauve(FILE* ) ).
int fread_be(int *aa, int size, int nb, FILE *fich)
Reads integer(s) from a binary file according to the big endian convention.
Definition fread_be.C:72
Lorene prototypes.
Definition app_hor.h:67