ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/geometrie/src/mg_assemblage.cpp
Revision: 906
Committed: Mon Nov 13 22:30:18 2017 UTC (7 years, 9 months ago) by couturad
File size: 4459 byte(s)
Log Message:
Nouveau opencascade commit 1

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 }
65 void MG_ASSEMBLAGE::ini_donne(MG_ARBRE* arb)
66 {
67 int nb=lst_mg_primitive_id.size();
68 for (int i=0;i<nb;i++)
69 {
70 MG_PRIMITIVE* prim=arb->get_mg_primitiveid(lst_mg_primitive_id[i]);
71 ajouter_mg_primitive(prim);
72 }
73 }
74 MG_PRIMITIVE* MG_ASSEMBLAGE::get_mg_primitiveid(long unsigned int num)
75 {
76 LISTE_MG_PRIMITIVE::iterator i=lst_mg_primitive.find(num);
77 if (i==lst_mg_primitive.end())
78 {
79 return NULL;
80 }
81 return ((*i).second);
82 }
83
84 MG_PRIMITIVE* MG_ASSEMBLAGE::get_mg_primitive(unsigned int num)
85 {
86 if (!(num<lst_mg_primitive.size()))
87 {
88 return NULL;
89 }
90 LISTE_MG_PRIMITIVE::iterator i=lst_mg_primitive.begin();
91 for (unsigned long j=0;j<num;j++) i++;
92 return ((*i).second);
93 }
94
95 MG_PRIMITIVE* MG_ASSEMBLAGE::get_premier_primitive(LISTE_MG_PRIMITIVE::iterator & it)
96 {
97 it = lst_mg_primitive.begin();
98 if (it == lst_mg_primitive.end())
99 return NULL;
100 return it->second;
101 }
102
103 MG_PRIMITIVE* MG_ASSEMBLAGE::get_suivant_primitive(LISTE_MG_PRIMITIVE::iterator & it)
104 {
105 it++;
106 if (it == lst_mg_primitive.end())
107 return NULL;
108 return it->second;
109 }
110
111 unsigned int MG_ASSEMBLAGE::get_nb_mg_primitive(void)
112 {
113 return lst_mg_primitive.size();
114 }
115
116 int MG_ASSEMBLAGE::supprimer_mg_primitiveid(long unsigned int num)
117 {
118 MG_PRIMITIVE* mgprim=get_mg_primitiveid(num);
119 if (mgprim==NULL)
120 {
121 return FAIL;
122 }
123 LISTE_MG_PRIMITIVE::iterator j=lst_mg_primitive.find(num);
124 lst_mg_primitive.erase(j);
125 delete mgprim;
126 return OK;
127 }
128
129 int MG_ASSEMBLAGE::supprimer_mg_primitive(unsigned int num)
130 {
131 MG_PRIMITIVE* mgprim=get_mg_primitive(num);
132 if (mgprim==NULL)
133 {
134 return FAIL;
135 }
136 LISTE_MG_PRIMITIVE::iterator j=lst_mg_primitive.begin();
137 for (unsigned int k=0;k<num;k++) j++;
138 lst_mg_primitive.erase(j);
139 delete mgprim;
140 return OK;
141 }
142
143 void MG_ASSEMBLAGE::supprimer_tout_mg_primitive(void)
144 {
145 while (get_nb_mg_primitive()!=0)
146 {
147 LISTE_MG_PRIMITIVE::iterator j=lst_mg_primitive.begin();
148 MG_PRIMITIVE* mgprim=(*j).second;
149 lst_mg_primitive.erase(j);
150 delete mgprim;
151 }
152 }
153
154 void MG_ASSEMBLAGE::enregistrer(ostream& o,double version)
155 {
156 o << "%" << get_id()
157 << "=ASSEMBLAGE("
158 << nom.c_str()
159 <<"," << get_nb_mg_primitive()
160 << ",(";
161 for( long i=0;i<get_nb_mg_primitive();i++)
162 {
163 o << "$" << get_mg_primitive(i)->get_id();
164 if(i!=get_nb_mg_primitive()-1) o << ",";
165 else o << ")";
166 }
167 o << ");"<< std::endl;
168 }
169
170 int MG_ASSEMBLAGE::get_type_mg_construction_geometrique(void)
171 {
172 return TYPE_MG_CONSTRUCTION_GEOMETRIQUE::ASSEMBLAGE;
173 }
174
175
176
177
178
179
180
181
182 #endif
183