ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/outil/src/ot_chaine.cpp
Revision: 773
Committed: Mon Jan 18 16:07:28 2016 UTC (9 years, 3 months ago) by francois
File size: 2895 byte(s)
Log Message:
Correction de differents bug d'interface avec aster
* code de retour de aster
* calcul aux elements 
* calcul poutre_volume et volume et coque

File Contents

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