ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/outil/src/ot_chaine.cpp
Revision: 757
Committed: Fri Nov 6 13:42:55 2015 UTC (9 years, 6 months ago) by francois
File size: 2875 byte(s)
Log Message:
Possibilite de calculer les comtraintes et les deformations aux points de gauss
Tester en elasticite volumique

File Contents

# User Rev Content
1 francois 708 #include "gestionversion.h"
2     #include "ot_chaine.h"
3     #include <string.h>
4     #include <string>
5     #include <iostream>
6     #include <stdio.h>
7 francois 757 #include <math.h>
8 francois 708
9    
10    
11    
12    
13     OT_CHAINE::OT_CHAINE()
14     {
15 francois 749 transpose[0]='0';
16     transpose[1]='1';
17     transpose[2]='2';
18     transpose[3]='3';
19     transpose[4]='4';
20     transpose[5]='5';
21     transpose[6]='6';
22     transpose[7]='7';
23     transpose[8]='8';
24     transpose[9]='9';
25     transpose[10]='A';
26     transpose[11]='B';
27     transpose[12]='C';
28     transpose[13]='D';
29     transpose[14]='E';
30     transpose[15]='F';
31     transpose[16]='G';
32     transpose[17]='H';
33     transpose[18]='I';
34     transpose[19]='J';
35     transpose[20]='K';
36     transpose[21]='L';
37     transpose[22]='M';
38     transpose[23]='N';
39     transpose[24]='O';
40     transpose[25]='P';
41     transpose[26]='Q';
42     transpose[27]='R';
43     transpose[28]='S';
44     transpose[29]='T';
45     transpose[30]='U';
46     transpose[31]='V';
47     transpose[32]='W';
48     transpose[33]='X';
49     transpose[34]='Y';
50     transpose[35]='Z';
51 francois 757 digit['0']=0;
52     digit['1']=1;
53     digit['2']=2;
54     digit['3']=3;
55     digit['4']=4;
56     digit['5']=5;
57     digit['6']=6;
58     digit['7']=7;
59     digit['8']=8;
60     digit['9']=9;
61     digit['A']=10;
62     digit['B']=11;
63     digit['C']=12;
64     digit['D']=13;
65     digit['E']=14;
66     digit['F']=15;
67     digit['G']=16;
68     digit['H']=17;
69     digit['I']=18;
70     digit['J']=19;
71     digit['K']=20;
72     digit['L']=21;
73     digit['M']=22;
74     digit['N']=23;
75     digit['O']=24;
76     digit['P']=25;
77     digit['Q']=26;
78     digit['R']=27;
79     digit['S']=28;
80     digit['T']=29;
81     digit['U']=30;
82     digit['V']=31;
83     digit['W']=32;
84     digit['X']=33;
85     digit['Y']=34;
86     digit['Z']=35;
87 francois 708 }
88    
89    
90    
91    
92     OT_CHAINE::OT_CHAINE(OT_CHAINE& mdd)
93     {
94    
95     }
96    
97    
98    
99     OT_CHAINE::~OT_CHAINE()
100     {
101    
102     }
103    
104    
105    
106     void OT_CHAINE::ini_mg_fprintf(int pos,char c)
107     {
108     longmax=pos;
109     charseparateur=c;
110     }
111    
112    
113     void OT_CHAINE::mg_fprintf(FILE* in,char* message)
114     {
115     std::string chaine=message;
116     int lon=chaine.length();
117     while (lon>longmax)
118     {
119     int pos=chaine.rfind(charseparateur,longmax);
120     std::string chaine1=chaine.substr(0,pos);
121     chaine=chaine.substr(pos);
122     lon=chaine.length();
123     fprintf(in,"%s\n",chaine1.c_str());
124     }
125     fprintf(in,"%s",chaine.c_str());
126    
127    
128     }
129 francois 749
130     std::string OT_CHAINE::get_base(unsigned long val,int base)
131     {
132     std::string res="";
133     do
134     {
135     int reste=val%base;
136     val=val/base;
137     res=transpose[reste]+res;
138     }
139     while (val!=0);
140     return res;
141     }
142 francois 757
143    
144    
145     unsigned long OT_CHAINE::get_base(std::string val,int base)
146     {
147     unsigned long res=0;
148     int taille=val.size();
149     for (int i=taille-1;i>-1;i--)
150     res=res+digit[val[i]]*pow(base,taille-i-1);
151    
152    
153     return res;
154     }
155    
156     long unsigned int OT_CHAINE::atoi(std::string val, int base)
157     {
158     unsigned long res=0;
159     if (base==10) res=atol(val.c_str());
160     else res=get_base(val,base);
161     return res;
162     }
163    
164 francois 711
165     std::vector< std::string> OT_CHAINE::split(std::string chaine, char c)
166     {
167     std::vector<std::string> arg;
168     int pos;
169     do
170     {
171     pos=chaine.find(c);
172     std::string chaine1=chaine.substr(0,pos);
173     arg.push_back(chaine1);
174     if (pos!=std::string::npos)
175     chaine=chaine.substr(pos+1);
176     }
177     while (pos!=std::string::npos);
178     return arg;
179     }