ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/geometrie/src/mg_assemblage.cpp
Revision: 1075
Committed: Tue Aug 10 17:02:54 2021 UTC (4 years ago) by francois
File size: 4471 byte(s)
Log Message:
suppression de warning avec le dernier compilateur

File Contents

# Content
1 //------------------------------------------------------------
2 //------------------------------------------------------------
3 // MAGiC
4 // Jean Christophe Cuilli�re et Vincent FRANCOIS
5 // D�partement de G�nie M�canique - UQTR
6 //------------------------------------------------------------
7 // Le projet MAGIC est un projet de recherche du d�partement
8 // de g�nie m�canique de l'Universit� du Qu�bec �
9 // Trois Rivi�res
10 // Les librairies ne peuvent �tre utilis�es sans l'accord
11 // des auteurs (contact : francois@uqtr.ca)
12 //------------------------------------------------------------
13 //------------------------------------------------------------
14 //
15 // mg_element_geometrique.cpp
16 //
17 //------------------------------------------------------------
18 //------------------------------------------------------------
19 // COPYRIGHT 2000
20 // Version du 02/03/2006 � 11H22
21 //------------------------------------------------------------
22 //------------------------------------------------------------
23 #ifdef CSG_OCC
24
25 #include "gestionversion.h"
26 #include "mg_definition.h"
27 #include "mg_assemblage.h"
28 #include "mg_primitive.h"
29 #include "mg_arbre.h"
30
31 MG_ASSEMBLAGE::MG_ASSEMBLAGE(std::string nm): MG_CONSTRUCTION_GEOMETRIQUE(), nom(nm)
32 {
33
34 }
35
36 MG_ASSEMBLAGE::MG_ASSEMBLAGE(long unsigned int num,std::string nm): MG_CONSTRUCTION_GEOMETRIQUE(num), nom(nm)
37 {
38
39 }
40
41 MG_ASSEMBLAGE::MG_ASSEMBLAGE(MG_ASSEMBLAGE& mdd): MG_CONSTRUCTION_GEOMETRIQUE(mdd), nom(mdd.nom)
42 {
43
44 }
45
46 MG_ASSEMBLAGE::~MG_ASSEMBLAGE()
47 {
48 supprimer_tout_mg_primitive();
49 }
50
51 int MG_ASSEMBLAGE::ajouter_mg_primitive(MG_PRIMITIVE* mgprim)
52 {
53 std::pair<const unsigned long,MG_PRIMITIVE*> tmp(mgprim->get_id(),mgprim);
54 std::pair<LISTE_MG_PRIMITIVE::iterator,bool> p = lst_mg_primitive.insert(tmp);
55 if(!p.second)
56 {
57 return FAIL;
58 }
59 return OK;
60 }
61 int MG_ASSEMBLAGE::ajouter_mg_primitive(unsigned long id)
62 {
63 lst_mg_primitive_id.push_back(id);
64 return 0;
65 }
66 void MG_ASSEMBLAGE::ini_donne(MG_ARBRE* arb)
67 {
68 int nb=lst_mg_primitive_id.size();
69 for (int i=0;i<nb;i++)
70 {
71 MG_PRIMITIVE* prim=arb->get_mg_primitiveid(lst_mg_primitive_id[i]);
72 ajouter_mg_primitive(prim);
73 }
74 }
75 MG_PRIMITIVE* MG_ASSEMBLAGE::get_mg_primitiveid(long unsigned int num)
76 {
77 LISTE_MG_PRIMITIVE::iterator i=lst_mg_primitive.find(num);
78 if (i==lst_mg_primitive.end())
79 {
80 return NULL;
81 }
82 return ((*i).second);
83 }
84
85 MG_PRIMITIVE* MG_ASSEMBLAGE::get_mg_primitive(unsigned int num)
86 {
87 if (!(num<lst_mg_primitive.size()))
88 {
89 return NULL;
90 }
91 LISTE_MG_PRIMITIVE::iterator i=lst_mg_primitive.begin();
92 for (unsigned long j=0;j<num;j++) i++;
93 return ((*i).second);
94 }
95
96 MG_PRIMITIVE* MG_ASSEMBLAGE::get_premier_primitive(LISTE_MG_PRIMITIVE::iterator & it)
97 {
98 it = lst_mg_primitive.begin();
99 if (it == lst_mg_primitive.end())
100 return NULL;
101 return it->second;
102 }
103
104 MG_PRIMITIVE* MG_ASSEMBLAGE::get_suivant_primitive(LISTE_MG_PRIMITIVE::iterator & it)
105 {
106 it++;
107 if (it == lst_mg_primitive.end())
108 return NULL;
109 return it->second;
110 }
111
112 unsigned int MG_ASSEMBLAGE::get_nb_mg_primitive(void)
113 {
114 return lst_mg_primitive.size();
115 }
116
117 int MG_ASSEMBLAGE::supprimer_mg_primitiveid(long unsigned int num)
118 {
119 MG_PRIMITIVE* mgprim=get_mg_primitiveid(num);
120 if (mgprim==NULL)
121 {
122 return FAIL;
123 }
124 LISTE_MG_PRIMITIVE::iterator j=lst_mg_primitive.find(num);
125 lst_mg_primitive.erase(j);
126 delete mgprim;
127 return OK;
128 }
129
130 int MG_ASSEMBLAGE::supprimer_mg_primitive(unsigned int num)
131 {
132 MG_PRIMITIVE* mgprim=get_mg_primitive(num);
133 if (mgprim==NULL)
134 {
135 return FAIL;
136 }
137 LISTE_MG_PRIMITIVE::iterator j=lst_mg_primitive.begin();
138 for (unsigned int k=0;k<num;k++) j++;
139 lst_mg_primitive.erase(j);
140 delete mgprim;
141 return OK;
142 }
143
144 void MG_ASSEMBLAGE::supprimer_tout_mg_primitive(void)
145 {
146 while (get_nb_mg_primitive()!=0)
147 {
148 LISTE_MG_PRIMITIVE::iterator j=lst_mg_primitive.begin();
149 MG_PRIMITIVE* mgprim=(*j).second;
150 lst_mg_primitive.erase(j);
151 delete mgprim;
152 }
153 }
154
155 void MG_ASSEMBLAGE::enregistrer(ostream& o,double version)
156 {
157 o << "%" << get_id()
158 << "=ASSEMBLAGE("
159 << nom.c_str()
160 <<"," << get_nb_mg_primitive()
161 << ",(";
162 for( long i=0;i<get_nb_mg_primitive();i++)
163 {
164 o << "$" << get_mg_primitive(i)->get_id();
165 if(i!=get_nb_mg_primitive()-1) o << ",";
166 else o << ")";
167 }
168 o << ");"<< std::endl;
169 }
170
171 int MG_ASSEMBLAGE::get_type_mg_construction_geometrique(void)
172 {
173 return TYPE_MG_CONSTRUCTION_GEOMETRIQUE::ASSEMBLAGE;
174 }
175
176
177
178
179
180
181
182
183 #endif
184