Skip to content

Commit bf321f2

Browse files
authored
Merge branch 'main' into sheet_and_chord_selection
2 parents 4f8a831 + 53b47c2 commit bf321f2

File tree

77 files changed

+1216
-1457
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1216
-1457
lines changed

src/Core/Geom/CommandCreateGeom.cpp

Lines changed: 8 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ namespace Geom {
3232
/*----------------------------------------------------------------------------*/
3333
CommandCreateGeom::CommandCreateGeom(Internal::Context& c, std::string name,
3434
const std::string& groupName)
35-
: Internal::CommandInternal (c, name)
35+
: Internal::CommandInternal (c, name)
36+
, m_group_helper(getInfoCommand(), c.getGroupManager())
3637
, m_group_name(groupName)
3738
, m_dim_new_group(3)
3839
, m_isPreview(false)
@@ -153,15 +154,15 @@ split(Volume* v)
153154

154155
for(unsigned int i=0;i<surfaces.size();i++){
155156
store(surfaces[i]);
156-
addToGroup(surfaces[i], true);
157+
m_group_helper.addToGroup("", surfaces[i]);
157158
}
158159
for(unsigned int i=0;i<curves.size();i++){
159160
store(curves[i]);
160-
addToGroup(curves[i], true);
161+
m_group_helper.addToGroup("", curves[i]);
161162
}
162163
for(unsigned int i=0;i<vertices.size();i++){
163164
store(vertices[i]);
164-
addToGroup(vertices[i], true);
165+
m_group_helper.addToGroup("", vertices[i]);
165166
}
166167
}
167168
/*----------------------------------------------------------------------------*/
@@ -183,11 +184,11 @@ split(Surface* s)
183184

184185
for(unsigned int i=0;i<curves.size();i++){
185186
store(curves[i]);
186-
addToGroup(curves[i], true);
187+
m_group_helper.addToGroup("", curves[i]);
187188
}
188189
for(unsigned int i=0;i<vertices.size();i++){
189190
store(vertices[i]);
190-
addToGroup(vertices[i], true);
191+
m_group_helper.addToGroup("", vertices[i]);
191192
}
192193
}
193194
/*----------------------------------------------------------------------------*/
@@ -209,7 +210,7 @@ split(Curve* c)
209210

210211
for(unsigned int i=0;i<vertices.size();i++){
211212
store(vertices[i]);
212-
addToGroup(vertices[i], true);
213+
m_group_helper.addToGroup("", vertices[i]);
213214
}
214215
}
215216
/*----------------------------------------------------------------------------*/
@@ -273,59 +274,6 @@ store(std::vector<GeomEntity*>& e){
273274
}
274275
/*----------------------------------------------------------------------------*/
275276
void CommandCreateGeom::
276-
addToGroup(GeomEntity* e, bool use_default_name)
277-
{
278-
#ifdef _DEBUG2
279-
std::cout<<"CommandCreateGeom::addToGroup("<<e->getName()<<", "<<use_default_name<<") avec m_group_name "<<m_group_name<<std::endl;
280-
#endif
281-
if(e->getDim()==0)
282-
addToGroup(dynamic_cast<Vertex*>(e), use_default_name);
283-
else if(e->getDim()==1)
284-
addToGroup(dynamic_cast<Curve*>(e), use_default_name);
285-
else if(e->getDim()==2)
286-
addToGroup(dynamic_cast<Surface*>(e), use_default_name);
287-
else
288-
addToGroup(dynamic_cast<Volume*>(e), use_default_name);
289-
290-
}
291-
/*----------------------------------------------------------------------------*/
292-
void CommandCreateGeom::
293-
addToGroup(Volume* v, bool use_default_name)
294-
{
295-
Group::Group3D* group = getContext().getGroupManager().getNewGroup3D(use_default_name?"":m_group_name, &getInfoCommand());
296-
v->add(group);
297-
group->add(v);
298-
getInfoCommand().addGroupInfoEntity(group,Internal::InfoCommand::DISPMODIFIED);
299-
}
300-
/*----------------------------------------------------------------------------*/
301-
void CommandCreateGeom::
302-
addToGroup(Surface* s, bool use_default_name)
303-
{
304-
Group::Group2D* group = getContext().getGroupManager().getNewGroup2D(use_default_name?"":m_group_name, &getInfoCommand());
305-
s->add(group);
306-
group->add(s);
307-
getInfoCommand().addGroupInfoEntity(group,Internal::InfoCommand::DISPMODIFIED);
308-
}
309-
/*----------------------------------------------------------------------------*/
310-
void CommandCreateGeom::
311-
addToGroup(Curve* c, bool use_default_name)
312-
{
313-
Group::Group1D* group = getContext().getGroupManager().getNewGroup1D(use_default_name?"":m_group_name, &getInfoCommand());
314-
c->add(group);
315-
group->add(c);
316-
getInfoCommand().addGroupInfoEntity(group,Internal::InfoCommand::DISPMODIFIED);
317-
}
318-
/*----------------------------------------------------------------------------*/
319-
void CommandCreateGeom::
320-
addToGroup(Vertex* v, bool use_default_name)
321-
{
322-
Group::Group0D* group = getContext().getGroupManager().getNewGroup0D(use_default_name?"":m_group_name, &getInfoCommand());
323-
v->add(group);
324-
group->add(v);
325-
getInfoCommand().addGroupInfoEntity(group,Internal::InfoCommand::DISPMODIFIED);
326-
}
327-
/*----------------------------------------------------------------------------*/
328-
void CommandCreateGeom::
329277
updateDimensionGroup(std::vector<GeomEntity*>& entities)
330278
{
331279
m_dim_new_group = 0;

src/Core/Geom/CommandEditGeom.cpp

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,7 @@ void CommandEditGeom::copyGroups(GeomEntity* ge1, GeomEntity* ge2)
219219
iter != grp.end(); ++iter){
220220
Group::Group3D* grp = dynamic_cast<Group::Group3D*>(*iter);
221221
if (res && grp && !res->find(grp)){
222-
grp->add(res);
223-
res->add(grp);
224-
//std::cout<<"grp : "<<grp->getInfos()<<std::endl;
222+
m_group_helper.addToGroup(grp->getName(), res);
225223
}
226224
}
227225
}
@@ -233,8 +231,7 @@ void CommandEditGeom::copyGroups(GeomEntity* ge1, GeomEntity* ge2)
233231
iter != grp.end(); ++iter){
234232
Group::Group2D* grp = dynamic_cast<Group::Group2D*>(*iter);
235233
if (res && grp && !res->find(grp)){
236-
grp->add(res);
237-
res->add(grp);
234+
m_group_helper.addToGroup(grp->getName(), res);
238235
}
239236
}
240237
}
@@ -246,21 +243,15 @@ void CommandEditGeom::copyGroups(GeomEntity* ge1, GeomEntity* ge2)
246243
iter != grp.end(); ++iter){
247244
Group::Group1D* grp = dynamic_cast<Group::Group1D*>(*iter);
248245
if (res && grp && !res->find(grp)){
249-
grp->add(res);
250-
res->add(grp);
246+
m_group_helper.addToGroup(grp->getName(), res);
251247
}
252248
}
253249
}
254250
else if (ge1->getDim() == 0 && ge2->getDim() == 0){
255-
std::vector<Group::GroupEntity*> grp;
256-
ge1->getGroups(grp);
257251
Vertex* res = dynamic_cast<Vertex*>(ge2);
258-
for (std::vector<Group::GroupEntity*>::iterator iter = grp.begin();
259-
iter != grp.end(); ++iter){
260-
Group::Group0D* grp = dynamic_cast<Group::Group0D*>(*iter);
252+
for (Group::Group0D* grp : res->getGroups()) {
261253
if (res && grp && !res->find(grp)){
262-
grp->add(res);
263-
res->add(grp);
254+
m_group_helper.addToGroup(grp->getName(), res);
264255
}
265256
}
266257
}
@@ -294,14 +285,14 @@ void CommandEditGeom::updateGroups()
294285
}
295286
}
296287

297-
// on utilise le groupe m_group_name (suivant la dimention)
288+
// on utilise le groupe m_group_name (suivant la dimension)
298289
std::vector<GeomEntity*>& newEntities = getNewEntities();
299290
for (std::vector<GeomEntity*>::iterator iter = newEntities.begin();
300291
iter != newEntities.end(); ++iter){
301292
GeomEntity* ge = *iter;
302293
if (filtre_ge[ge] == 0){
303-
bool use_group_name = (ge->getDim() == m_dim_new_group); // && (filtre_ge[ge] == 0)
304-
addToGroup(ge, !use_group_name);
294+
std::string group_name = (ge->getDim() == m_dim_new_group ? m_group_name : ""); // && (filtre_ge[ge] == 0)
295+
m_group_helper.addToGroup(group_name, ge);
305296
#ifdef _DEBUG2
306297
std::cout<<" addToGroup de "<<ge->getName()<<" avec groupe: "<<(use_group_name?m_group_name:"")<<std::endl;
307298
#endif

src/Core/Geom/CommandExtrudeDirection.cpp

Lines changed: 4 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ CommandExtrudeDirection::
2020
CommandExtrudeDirection(Internal::Context& c,
2121
std::vector<GeomEntity*>& entities,
2222
const Vector& dp, const bool keep)
23-
: CommandExtrusion(c, "Direction"),
24-
m_entities(entities),
25-
m_vector(dp),
26-
m_keep(keep)
23+
: CommandExtrusion(c, "Direction", entities, keep)
24+
, m_vector(dp)
2725
{
2826
if (m_vector.abs2()==0.0)
2927
throw TkUtil::Exception(TkUtil::UTF8String ("Le vecteur pour l'extrusion ne doit pas être nul", TkUtil::Charset::UTF_8));
@@ -40,84 +38,14 @@ CommandExtrudeDirection(Internal::Context& c,
4038
setName(comments);
4139
}
4240
/*----------------------------------------------------------------------------*/
43-
CommandExtrudeDirection::~CommandExtrudeDirection()
44-
{
45-
if(m_impl)
46-
delete m_impl;
47-
}
48-
/*----------------------------------------------------------------------------*/
4941
void CommandExtrudeDirection::
50-
internalExecute()
42+
internalSpecificExecute()
5143
{
52-
m_impl->prePerform();
53-
m_impl->perform(m_createdEntities,m_v2v, m_v2v_opp,m_v2c,
44+
getImpl()->perform(m_createdEntities,m_v2v, m_v2v_opp,m_v2c,
5445
m_c2c, m_c2c_opp, m_c2s, m_s2s, m_s2s_opp, m_s2v);
55-
std::vector<GeomEntity*>& new_entities = m_impl->getNewEntities();
56-
std::vector<GeomEntity*>& rem_entities = m_impl->getRemovedEntities();
57-
for(int i=0;i<new_entities.size();i++){
58-
GeomEntity* ge = new_entities[i];
59-
getInfoCommand ( ).addGeomInfoEntity (ge, Internal::InfoCommand::CREATED);
60-
getContext().getGeomManager().addEntity(ge);
61-
}
62-
63-
// Si on ne garde pas, alors on transmet les relations géométriques des entités supprimées aux entités copiées pour
64-
// l'extrusion
65-
if(!m_keep) {
66-
67-
//On reconstruit les relations points <-> courbes
68-
for (auto v2v : m_v2v) {
69-
Vertex *v_ref = v2v.first;
70-
Vertex *v_created = v2v.second;
71-
auto curves = v_ref->getCurves();
72-
for (int i = 0; i < curves.size(); i++) {
73-
Curve *c = curves[i];
74-
v_created->add(c);
75-
c->add(v_created);
76-
}
77-
}
78-
79-
//On reconstruit les relations courbes <-> surfaces
80-
for (auto c2c : m_c2c) {
81-
Curve *c_ref = c2c.first;
82-
Curve *c_created = c2c.second;
83-
auto surfaces = c_ref->getSurfaces();
84-
for (int i = 0; i < surfaces.size(); i++) {
85-
Surface *s = surfaces[i];
86-
c_created->add(s);
87-
s->add(c_created);
88-
}
89-
}
90-
91-
//On reconstruit les relations surfaces <-> volumes
92-
for (auto s2s : m_s2s) {
93-
Surface *s_ref = s2s.first;
94-
Surface *s_created = s2s.second;
95-
auto volumes = s_ref->getVolumes();
96-
for (int i = 0; i < volumes.size(); i++) {
97-
Volume *vol = volumes[i];
98-
s_created->add(vol);
99-
vol->add(s_created);
100-
}
101-
}
102-
103-
//On a besoin de gérer que les relations de dimension n <-> n+1, le reste est créé implicitement par ces relations
104-
}
105-
106-
for(int i=0;i<rem_entities.size();i++){
107-
getInfoCommand ( ).addGeomInfoEntity (rem_entities[i], Internal::InfoCommand::DELETED);
108-
}
109-
110-
getInfoCommand().setDestroyAndUpdateConnectivity(rem_entities);
11146

11247
// transmet les groupes du 2D vers le 3D
11348
groups2DTo3D();
114-
115-
for(int i=0;i<new_entities.size();i++){
116-
GeomEntity* ge = new_entities[i];
117-
if (ge->getNbGroups() == 0)
118-
// ajoute à un groupe par défaut
119-
addToGroup(ge);
120-
}
12149
}
12250
/*----------------------------------------------------------------------------*/
12351
} // end namespace Geom

src/Core/Geom/CommandExtrudeRevolution.cpp

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ CommandExtrudeRevolution::
2121
CommandExtrudeRevolution(Internal::Context& c,
2222
std::vector<GeomEntity*>& entities,
2323
const Utils::Math::Rotation& rot, const bool keep)
24-
: CommandExtrusion(c, "Revolution"),
25-
m_entities(entities), m_axis1(rot.getAxis1()), m_axis2(rot.getAxis2()),
26-
m_angle(rot.getAngle()), m_keep(keep)
24+
: CommandExtrusion(c, "Revolution", entities, keep)
25+
, m_axis1(rot.getAxis1())
26+
, m_axis2(rot.getAxis2())
27+
, m_angle(rot.getAngle())
2728
{
2829
if (m_angle<0.0 || m_angle>360.0)
2930
throw TkUtil::Exception(TkUtil::UTF8String ("L'angle est en degrés et doit être compris entre 0 et 360", TkUtil::Charset::UTF_8));
@@ -40,30 +41,11 @@ CommandExtrudeRevolution(Internal::Context& c,
4041
setName(comments);
4142
}
4243
/*----------------------------------------------------------------------------*/
43-
CommandExtrudeRevolution::~CommandExtrudeRevolution()
44-
{
45-
if(m_impl)
46-
delete m_impl;
47-
}
48-
/*----------------------------------------------------------------------------*/
4944
void CommandExtrudeRevolution::
50-
internalExecute()
45+
internalSpecificExecute()
5146
{
52-
m_impl->prePerform();
53-
m_impl->perform(m_createdEntities,m_v2v, m_v2v_opp,m_v2c,
47+
getImpl()->perform(m_createdEntities,m_v2v, m_v2v_opp,m_v2c,
5448
m_c2c, m_c2c_opp, m_c2s, m_s2s, m_s2s_opp, m_s2v);
55-
std::vector<GeomEntity*>& new_entities = m_impl->getNewEntities();
56-
std::vector<GeomEntity*>& rem_entities = m_impl->getRemovedEntities();
57-
for(int i=0;i<new_entities.size();i++){
58-
GeomEntity* ge = new_entities[i];
59-
getInfoCommand ( ).addGeomInfoEntity (ge, Internal::InfoCommand::CREATED);
60-
getContext().getGeomManager().addEntity(ge);
61-
}
62-
for(int i=0;i<rem_entities.size();i++){
63-
getInfoCommand ( ).addGeomInfoEntity (rem_entities[i], Internal::InfoCommand::DELETED);
64-
}
65-
66-
getInfoCommand().setDestroyAndUpdateConnectivity(rem_entities);
6749

6850
// transmet les groupes du 2D vers le 3D
6951
groups2DTo3D();
@@ -84,20 +66,11 @@ internalExecute()
8466
prefixGroupsName("P72", m_v2v_opp, m_c2c_opp, m_s2s_opp);
8567
addGroupOnAxis();
8668
}
87-
for(int i=0;i<new_entities.size();i++){
88-
GeomEntity* ge = new_entities[i];
89-
if (ge->getNbGroups() == 0)
90-
// ajoute à un groupe par défaut
91-
addToGroup(ge);
92-
}
9369
}
9470
/*----------------------------------------------------------------------------*/
9571
void CommandExtrudeRevolution::
9672
addGroupOnAxis()
9773
{
98-
// le groupe pour les courbes sur l'axe
99-
Group::Group1D* grp = getContext().getGroupManager().getNewGroup1D("AXE", &getInfoCommand());
100-
10174
// on commence par identifier les sommets sur l'axe, on les marque à 2, sinon 1
10275
std::map<Geom::Vertex* ,uint> filtre_vertices;
10376

@@ -125,11 +98,9 @@ addGroupOnAxis()
12598
&& crv1->isLinear())
12699
{
127100
//std::cout<<crv1->getName()<< " sur l'axe, et donne "<<crv2->getName()<<std::endl;
128-
crv2->add(grp);
129-
grp->add(crv2);
101+
m_group_helper.addToGroup("AXE", crv2);
130102
}
131103
}
132-
133104
}
134105
/*----------------------------------------------------------------------------*/
135106
} // end namespace Geom

0 commit comments

Comments
 (0)