ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/geometrie/src/mg_assemblage.cpp
Revision: 740
Committed: Wed Sep 30 22:24:50 2015 UTC (9 years, 7 months ago) by couturad
File size: 3966 byte(s)
Log Message:
Ajout d'assemblage dans un arbre caractéristique
Modification de la gestion des id de occ avec retro-compatibilité
script adaptable au assemblage

File Contents

# User Rev Content
1 couturad 740 //------------------------------------------------------------
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    
30     MG_ASSEMBLAGE::MG_ASSEMBLAGE(std::string nm): MG_CONSTRUCTION_GEOMETRIQUE(), nom(nm)
31     {
32    
33     }
34    
35     MG_ASSEMBLAGE::MG_ASSEMBLAGE(long unsigned int num,std::string nm): MG_CONSTRUCTION_GEOMETRIQUE(num), nom(nm)
36     {
37    
38     }
39    
40     MG_ASSEMBLAGE::MG_ASSEMBLAGE(MG_ASSEMBLAGE& mdd): MG_CONSTRUCTION_GEOMETRIQUE(mdd), nom(mdd.nom)
41     {
42    
43     }
44    
45     MG_ASSEMBLAGE::~MG_ASSEMBLAGE()
46     {
47     supprimer_tout_mg_primitive();
48     }
49    
50     int MG_ASSEMBLAGE::ajouter_mg_primitive(MG_PRIMITIVE* mgprim)
51     {
52     std::pair<const unsigned long,MG_PRIMITIVE*> tmp(mgprim->get_id(),mgprim);
53     std::pair<LISTE_MG_PRIMITIVE::iterator,bool> p = lst_mg_primitive.insert(tmp);
54     if(!p.second)
55     {
56     return FAIL;
57     }
58     return OK;
59     }
60    
61     MG_PRIMITIVE* MG_ASSEMBLAGE::get_mg_primitiveid(long unsigned int num)
62     {
63     LISTE_MG_PRIMITIVE::iterator i=lst_mg_primitive.find(num);
64     if (i==lst_mg_primitive.end())
65     {
66     return NULL;
67     }
68     return ((*i).second);
69     }
70    
71     MG_PRIMITIVE* MG_ASSEMBLAGE::get_mg_primitive(unsigned int num)
72     {
73     if (!(num<lst_mg_primitive.size()))
74     {
75     return NULL;
76     }
77     LISTE_MG_PRIMITIVE::iterator i=lst_mg_primitive.begin();
78     for (unsigned long j=0;j<num;j++) i++;
79     return ((*i).second);
80     }
81    
82     MG_PRIMITIVE* MG_ASSEMBLAGE::get_premier_primitive(LISTE_MG_PRIMITIVE::iterator & it)
83     {
84     it = lst_mg_primitive.begin();
85     if (it == lst_mg_primitive.end())
86     return NULL;
87     return it->second;
88     }
89    
90     MG_PRIMITIVE* MG_ASSEMBLAGE::get_suivant_primitive(LISTE_MG_PRIMITIVE::iterator & it)
91     {
92     it++;
93     if (it == lst_mg_primitive.end())
94     return NULL;
95     return it->second;
96     }
97    
98     unsigned int MG_ASSEMBLAGE::get_nb_mg_primitive(void)
99     {
100     return lst_mg_primitive.size();
101     }
102    
103     int MG_ASSEMBLAGE::supprimer_mg_primitiveid(long unsigned int num)
104     {
105     MG_PRIMITIVE* mgprim=get_mg_primitiveid(num);
106     if (mgprim==NULL)
107     {
108     return FAIL;
109     }
110     LISTE_MG_PRIMITIVE::iterator j=lst_mg_primitive.find(num);
111     lst_mg_primitive.erase(j);
112     delete mgprim;
113     return OK;
114     }
115    
116     int MG_ASSEMBLAGE::supprimer_mg_primitive(unsigned int num)
117     {
118     MG_PRIMITIVE* mgprim=get_mg_primitive(num);
119     if (mgprim==NULL)
120     {
121     return FAIL;
122     }
123     LISTE_MG_PRIMITIVE::iterator j=lst_mg_primitive.begin();
124     for (unsigned int k=0;k<num;k++) j++;
125     lst_mg_primitive.erase(j);
126     delete mgprim;
127     return OK;
128     }
129    
130     void MG_ASSEMBLAGE::supprimer_tout_mg_primitive(void)
131     {
132     while (get_nb_mg_primitive()!=0)
133     {
134     LISTE_MG_PRIMITIVE::iterator j=lst_mg_primitive.begin();
135     MG_PRIMITIVE* mgprim=(*j).second;
136     lst_mg_primitive.erase(j);
137     delete mgprim;
138     }
139     }
140    
141     void MG_ASSEMBLAGE::enregistrer(ostream& o)
142     {
143     o << "%" << get_id() << "=ASSEMBLAGE("<< nom.c_str() <<"," << get_nb_mg_primitive() << ",(";
144     for( long i=0;i<get_nb_mg_primitive();i++)
145     {
146     o << "$" << get_mg_primitive(i)->get_id();
147     if(i!=get_nb_mg_primitive()-1) o << ",";
148     else o << ")";
149     }
150     o << ");"<< std::endl;
151     }
152    
153    
154    
155    
156    
157    
158    
159     #endif
160