ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/solveur/src/sl_solution.cpp
Revision: 1158
Committed: Thu Jun 13 22:18:49 2024 UTC (11 months, 1 week ago) by francois
File size: 2413 byte(s)
Log Message:
compatibilité Ubuntu 22.04
Suppression des refeences à Windows
Ajout d'une banière

File Contents

# User Rev Content
1 francois 1158 //####//------------------------------------------------------------
2     //####//------------------------------------------------------------
3     //####// MAGiC
4     //####// Jean Christophe Cuilliere et Vincent FRANCOIS
5     //####// Departement de Genie Mecanique - UQTR
6     //####//------------------------------------------------------------
7     //####// MAGIC est un projet de recherche de l equipe ERICCA
8     //####// du departement de genie mecanique de l Universite du Quebec a Trois Rivieres
9     //####// http://www.uqtr.ca/ericca
10     //####// http://www.uqtr.ca/
11     //####//------------------------------------------------------------
12     //####//------------------------------------------------------------
13     //####//
14     //####// sl_solution.cpp
15     //####//
16     //####//------------------------------------------------------------
17     //####//------------------------------------------------------------
18     //####// COPYRIGHT 2000-2024
19     //####// jeu 13 jun 2024 11:58:57 EDT
20     //####//------------------------------------------------------------
21     //####//------------------------------------------------------------
22 5 #include "gestionversion.h"
23     #include <math.h>
24     #include <iostream>
25     #include <stdlib.h>
26     #include <string.h>
27    
28     #include "sl_solution.h"
29    
30     #include "ot_mathematique.h"
31    
32    
33     #include <stdio.h> // pour la fonction remove() qui remplace DeleteFile
34    
35    
36     SL_SOLUTION::SL_SOLUTION(int nb,char* chemin,int code)
37     {
38     nb_champs=nb;
39    
40    
41     nom_fichier=new char[strlen(chemin)+2];
42     strcpy(nom_fichier,chemin);
43     if (code!=0)
44     {
45     in=fopen(nom_fichier,"wb");
46     for (int i=0;i<code;i++)
47     for (int j=0;j<nb;j++)
48     {
49     double val=0.0;
50     fwrite(&val,sizeof(double),1,in);
51     }
52     fclose(in);
53     }
54     in=fopen(nom_fichier,"r+b");
55     }
56    
57    
58     SL_SOLUTION::~SL_SOLUTION()
59     {
60     if (in!=NULL) fclose(in);
61     }
62    
63     void SL_SOLUTION::efface(void)
64     {
65     fclose(in);
66     remove(nom_fichier);
67     in=NULL;
68     }
69    
70     double SL_SOLUTION::lire(int i,int j)
71     {
72     long pos=(nb_champs*i+j)*sizeof(double);
73     fseek(in,pos,SEEK_SET);
74     double val;
75     fread(&val,sizeof(double),1,in);
76     return (val);
77     }
78    
79     void SL_SOLUTION::ecrire(int i,int j,double val)
80     {
81     long pos=(nb_champs*i+j)*sizeof(double);
82     fseek(in,pos,SEEK_SET);
83     fwrite(&val,sizeof(double),1,in);
84     fflush(in);
85     }
86    
87    
88    
89     int SL_SOLUTION::get_nb_champ(void)
90     {
91     return nb_champs;
92     }
93    
94    
95    
96    
97    
98    
99