Skip to content

Commit f3d4e94

Browse files
committed
Small cleanings in geometry
1 parent a3ec816 commit f3d4e94

File tree

13 files changed

+107
-172
lines changed

13 files changed

+107
-172
lines changed

src/Core/Geom/Curve.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ namespace Mgx3D {
3131
/*----------------------------------------------------------------------------*/
3232
namespace Geom {
3333
/*----------------------------------------------------------------------------*/
34-
const char* Curve::typeNameGeomCurve = "GeomCurve";
35-
/*----------------------------------------------------------------------------*/
3634
Curve::Curve(Internal::Context& ctx, Utils::Property* prop, Utils::DisplayProperties* disp,
3735
GeomProperty* gprop, TopoDS_Edge& shape)
3836
:GeomEntity(ctx, prop, disp, gprop)

src/Core/Geom/Surface_Geom.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,6 @@
2727
namespace Mgx3D {
2828
/*----------------------------------------------------------------------------*/
2929
namespace Geom {
30-
/*----------------------------------------------------------------------------*/
31-
const char* Surface::typeNameGeomSurface = "GeomSurface";
32-
33-
/*----------------------------------------------------------------------------*/
34-
//void Surface::add(TopoDS_Edge e)
35-
//{m_occ_edges.push_back(e);}
36-
///*----------------------------------------------------------------------------*/
37-
//std::vector<TopoDS_Edge> Surface::getEdges()
38-
//{return m_occ_edges;}
39-
4030
/*----------------------------------------------------------------------------*/
4131
Surface::Surface(Internal::Context& ctx, Utils::Property* prop,
4232
Utils::DisplayProperties* disp,

src/Core/Geom/Vertex_Geom.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ namespace Mgx3D {
2020
/*----------------------------------------------------------------------------*/
2121
namespace Geom {
2222
/*----------------------------------------------------------------------------*/
23-
const char* Vertex::typeNameGeomVertex = "GeomVertex";
24-
/*----------------------------------------------------------------------------*/
2523
Vertex::Vertex(Internal::Context& ctx, Utils::Property* prop, Utils::DisplayProperties* disp,
2624
GeomProperty* gprop, TopoDS_Vertex& shape)
2725
: GeomEntity(ctx, prop, disp, gprop)

src/Core/Geom/Volume_Geom.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ namespace Mgx3D {
2020
/*----------------------------------------------------------------------------*/
2121
namespace Geom {
2222
/*----------------------------------------------------------------------------*/
23-
const char* Volume::typeNameGeomVolume = "GeomVolume";
24-
/*----------------------------------------------------------------------------*/
2523
Volume::Volume(Internal::Context& ctx, Utils::Property* prop, Utils::DisplayProperties* disp,
2624
GeomProperty* gprop, TopoDS_Shape& shape)
2725
: GeomEntity(ctx, prop, disp, gprop)

src/Core/Group/GroupEntity.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
/*----------------------------------------------------------------------------*/
21
#include "Group/GroupEntity.h"
32
#include "Group/GroupEntityVisitor.h"
43
#include "Internal/Context.h"
54
#include "Mesh/MeshModificationItf.h"
5+
#include "Services/DescriptionService.h"
66
/*----------------------------------------------------------------------------*/
77
#include <TkUtil/Exception.h>
88
/*----------------------------------------------------------------------------*/

src/Core/Internal/ExportMDLImplementation.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "Topo/CoFace.h"
1616
#include "Utils/Point.h"
1717
#include "Utils/Unit.h"
18+
#include "Group/GroupManager.h"
1819
/*----------------------------------------------------------------------------*/
1920
#include <TopoDS.hxx>
2021
#include <BRep_Tool.hxx>
@@ -377,15 +378,15 @@ save(Geom::Surface* sf)
377378
// std::cout<<"nb_cd = "<<nb_cd<<std::endl;
378379
cmd.u.area.algo_mesh = "Delaunay";
379380
cmd.u.area.algo_smooth = 0;
380-
std::vector<std::string> grps;
381-
sf->getGroupsName(grps);
381+
Group::GroupManager& gm = m_context.getGroupManager();
382+
std::vector<Group::GroupEntity*> grps = gm.getGroupsFor(sf);
382383
cmd.u.area.groups_name = 0;
383384
if (!grps.empty()){
384385
TkUtil::UTF8String grps_str (TkUtil::Charset::UTF_8);
385386
for (uint i=0; i<grps.size(); i++){
386387
if (i)
387388
grps_str << " ";
388-
grps_str << grps[i];
389+
grps_str << grps[i]->getName();
389390
}
390391
char* grps_ch = new char[grps_str.length()+1];
391392
cmd.u.area.groups_name = grps_ch;

src/Core/Internal/ImportMDLImplementation.cpp

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ void ImportMDLImplementation::performGeom(Internal::InfoCommand* icmd)
113113
bool isFiltered = getFilter(filter);
114114

115115
// les surfaces
116+
Group::GroupManager& gm = m_context.getGroupManager();
116117
for (std::vector<const T_MdlCommand*>::const_iterator iter = m_vCmdArea.begin(); iter!=m_vCmdArea.end(); ++iter){
117118
const T_MdlCommand& current_command = **iter;
118119

@@ -137,25 +138,24 @@ void ImportMDLImplementation::performGeom(Internal::InfoCommand* icmd)
137138
id_grp++;
138139
if (!m_prefixName.empty())
139140
name = m_prefixName + name;
140-
Group::Group1D* group = m_context.getGroupManager().getNewGroup1D(name, icmd);
141+
Group::Group1D* group = gm.getNewGroup<Group::Group1D>(name, icmd);
141142
if (id_grp == 1)
142143
group->setLevel(2);
143144
else
144145
group->setLevel(3);
145146
if (!group->find(crv)){
146147
// il faut peut-être enlever le groupe par défaut
147-
if (crv->getNbGroups() == 1){
148-
std::vector<std::string> gn;
149-
crv->getGroupsName(gn);
150-
if (gn[0] == m_context.getGroupManager().getDefaultName(1)){
151-
Group::Group1D* grp = m_context.getGroupManager().getGroup1D(gn[0], icmd);
148+
std::vector<Group::GroupEntity*> crv_groups = gm.getGroupsFor(crv);
149+
if (crv_groups.size() == 1){
150+
Group::GroupEntity* grp = crv_groups[0];
151+
if (grp->getName() == gm.getDefaultName(1)){
152+
gm.removeGroupFor(crv, grp);
152153
grp->remove(crv);
153-
crv->remove(grp);
154-
icmd->addGroupInfoEntity(grp,Internal::InfoCommand::DISPMODIFIED);
154+
icmd->addGroupInfoEntity(grp, Internal::InfoCommand::DISPMODIFIED);
155155
}
156156
}
157157

158-
crv->add(group);
158+
gm.addGroupFor(crv, group);
159159
group->add(crv);
160160
}
161161
}
@@ -197,12 +197,12 @@ void ImportMDLImplementation::performGeom(Internal::InfoCommand* icmd)
197197
id_grp++;
198198
if (!m_prefixName.empty())
199199
name = m_prefixName + name;
200-
Group::Group2D* group = m_context.getGroupManager().getNewGroup2D(name, icmd);
200+
Group::Group2D* group = gm.getNewGroup<Group::Group2D>(name, icmd);
201201
if (id_grp == 1)
202202
group->setLevel(2);
203203
else
204204
group->setLevel(3);
205-
surf->add(group);
205+
gm.addGroupFor(surf, group);
206206
group->add(surf);
207207
}
208208
}
@@ -215,9 +215,9 @@ void ImportMDLImplementation::performGeom(Internal::InfoCommand* icmd)
215215
std::string nomDef = current_command.name.str();
216216
if (!m_prefixName.empty())
217217
nomDef = m_prefixName + nomDef;
218-
Group::Group2D* group = m_context.getGroupManager().getNewGroup2D(nomDef, icmd);
218+
Group::Group2D* group = gm.getNewGroup<Group::Group2D>(nomDef, icmd);
219219
group->setLevel(1);
220-
surf->add(group);
220+
gm.addGroupFor(surf, group);
221221
group->add(surf);
222222
}
223223

@@ -246,12 +246,12 @@ void ImportMDLImplementation::performGeom(Internal::InfoCommand* icmd)
246246
id_grp++;
247247
if (!m_prefixName.empty())
248248
name = m_prefixName + name;
249-
Group::Group0D* group = m_context.getGroupManager().getNewGroup0D(name, icmd);
249+
Group::Group0D* group = gm.getNewGroup<Group::Group0D>(name, icmd);
250250
if (id_grp == 1)
251251
group->setLevel(2);
252252
else
253253
group->setLevel(3);
254-
v->add(group);
254+
gm.addGroupFor(v, group);
255255
group->add(v);
256256
}
257257
}
@@ -592,14 +592,15 @@ MAJInterpolated(std::vector<Topo::CoEdge*>& coedges, Topo::CoFace* coface)
592592
Geom::Vertex* ImportMDLImplementation::getVertex(uint ptId)
593593
{
594594
Geom::Vertex* vtx = m_cor_ptId_vertex[ptId];
595+
Group::GroupManager& gm = m_context.getGroupManager();
595596

596597
if (!vtx){
597598
const T_MdlCommand& command_pt = *m_vCmdPt[ptId];
598599
vtx = Geom::EntityFactory(m_context).newVertex(Utils::Math::Point(command_pt.u.point.cd.x1,command_pt.u.point.cd.x2, 0.0)*m_scale_factor);
599600
m_newGeomEntities.push_back(vtx);
600601
m_cor_ptId_vertex[ptId] = vtx;
601-
Group::Group0D* group = m_context.getGroupManager().getNewGroup0D("", m_icmd);
602-
vtx->add(group);
602+
Group::Group0D* group = gm.getNewGroup<Group::Group0D>("", m_icmd);
603+
gm.addGroupFor(vtx, group);
603604
group->add(vtx);
604605
}
605606

@@ -619,6 +620,7 @@ Geom::Vertex* ImportMDLImplementation::getVertex(uint ptId)
619620
Geom::Curve* ImportMDLImplementation::getCurve(const std::string name)
620621
{
621622
Geom::Curve* crv = m_cor_name_curve[name];
623+
Group::GroupManager& gm = m_context.getGroupManager();
622624

623625
if (!crv){
624626
T_MdlCommand* ptr_current_command = m_cor_name_mdlCmd[name];
@@ -744,9 +746,9 @@ Geom::Curve* ImportMDLImplementation::getCurve(const std::string name)
744746
m_newGeomEntities.push_back(vtx1);
745747
m_newGeomEntities.push_back(vtx2);
746748

747-
Group::Group0D* group = m_context.getGroupManager().getNewGroup0D("", m_icmd);
748-
vtx1->add(group);
749-
vtx2->add(group);
749+
Group::Group0D* group = gm.getNewGroup<Group::Group0D>("", m_icmd);
750+
gm.addGroupFor(vtx1, group);
751+
gm.addGroupFor(vtx2, group);
750752
group->add(vtx1);
751753
group->add(vtx2);
752754

@@ -764,8 +766,8 @@ Geom::Curve* ImportMDLImplementation::getCurve(const std::string name)
764766
m_newGeomEntities.push_back(crv);
765767
m_cor_name_curve[name] = crv;
766768

767-
Group::Group1D* group = m_context.getGroupManager().getNewGroup1D("", m_icmd);
768-
crv->add(group);
769+
Group::Group1D* group = gm.getNewGroup<Group::Group1D>("", m_icmd);
770+
gm.addGroupFor(crv, group);
769771
group->add(crv);
770772
}
771773
}

src/Core/protected/Geom/Curve.h

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <sys/types.h> // CP : uint sur Bull
77
/*----------------------------------------------------------------------------*/
88
#include "Geom/GeomEntity.h"
9-
#include "Geom/GeomProperty.h"
109
#include "Services/MementoService.h"
1110
#include "Utils/Point.h"
1211
#include "Utils/Vector.h"
@@ -16,8 +15,6 @@
1615
namespace Mgx3D {
1716
/*----------------------------------------------------------------------------*/
1817
namespace Geom {
19-
20-
class GeomProperty;
2118
/*----------------------------------------------------------------------------*/
2219
/**
2320
* \class Curve
@@ -27,7 +24,6 @@ class GeomProperty;
2724
class Curve: public GeomEntity {
2825

2926
friend class Services::MementoService;
30-
static const char* typeNameGeomCurve;
3127

3228
public:
3329

@@ -57,42 +53,42 @@ class Curve: public GeomEntity {
5753

5854
const std::vector<TopoDS_Edge>& getOCCEdges() const { return m_occ_edges; }
5955

60-
virtual void apply(std::function<void(const TopoDS_Shape&)> const& lambda) const;
61-
virtual void applyAndReturn(std::function<TopoDS_Shape(const TopoDS_Shape&)> const& lambda);
62-
virtual void accept(ConstGeomEntityVisitor& v) const { v.visit(this); }
63-
virtual void accept(GeomEntityVisitor& v) { v.visit(this); }
56+
void apply(std::function<void(const TopoDS_Shape&)> const& lambda) const override;
57+
void applyAndReturn(std::function<TopoDS_Shape(const TopoDS_Shape&)> const& lambda) override;
58+
void accept(ConstGeomEntityVisitor& v) const override{ v.visit(this); }
59+
void accept(GeomEntityVisitor& v) override { v.visit(this); }
6460

6561
/*------------------------------------------------------------------------*/
6662
/** \brief Crée une copie (avec allocation mémoire, appel à new) de l'objet
6763
* courant.
6864
*/
69-
virtual GeomEntity* clone(Internal::Context&);
65+
GeomEntity* clone(Internal::Context&) override;
7066

7167
/*------------------------------------------------------------------------*/
7268
/** \brief Destructeur
7369
*/
7470
virtual ~Curve() = default;
7571

76-
virtual bool isEqual(Geom::Curve* curve);
72+
bool isEqual(Geom::Curve* curve);
7773

7874
/*------------------------------------------------------------------------*/
7975
/** \brief retourne la dimension de l'entité géométrique
8076
*/
81-
virtual int getDim() const {return 1;}
77+
int getDim() const override { return 1; }
8278

8379
/*------------------------------------------------------------------------*/
8480
/** \brief Calcule l'aire d'une entité: Pour une courbe, c'est la
8581
* longueur, pour une surface, l'aire, pour un volume le volume.
8682
*/
87-
virtual double computeArea() const;
83+
double computeArea() const override;
8884

8985
/*------------------------------------------------------------------------*/
9086
/** \brief Calcul de la boite englobante orientée selon les axes Ox,Oy,Oz
9187
*
9288
* \param pmin Les coordonnées min de la boite englobante
9389
* \param pmax Les coordonnées max de la boite englobante
9490
*/
95-
virtual void computeBoundingBox(Utils::Math::Point& pmin, Utils::Math::Point& pmax) const;
91+
void computeBoundingBox(Utils::Math::Point& pmin, Utils::Math::Point& pmax) const override;
9692

9793
/*------------------------------------------------------------------------*/
9894
/** \brief Donne le point en fonction du paramètre sur la courbe
@@ -200,23 +196,18 @@ class Curve: public GeomEntity {
200196
*
201197
* \param liste d'entity
202198
*/
203-
virtual void addAllDownLevelEntity(std::list<GeomEntity*>& l_entity) const;
199+
void addAllDownLevelEntity(std::list<GeomEntity*>& l_entity) const;
204200

205201
/*------------------------------------------------------------------------*/
206202
/** \brief retourne un point sur l'objet au centre si possible
207203
* \author Eric Brière de l'Isle
208204
*/
209-
virtual Utils::Math::Point getCenteredPosition() const;
210-
211-
/*------------------------------------------------------------------------*/
212-
/** \brief Donne le nom du type d'objet (un nom distinct par type d'objet)
213-
*/
214-
virtual std::string getTypeName() const {return typeNameGeomCurve;}
205+
Utils::Math::Point getCenteredPosition() const override;
215206

216207
/*------------------------------------------------------------------------*/
217208
/** \brief Donne le type de l'objet
218209
*/
219-
virtual Utils::Entity::objectType getType() const {return Utils::Entity::GeomCurve;}
210+
Utils::Entity::objectType getType() const override { return Utils::Entity::GeomCurve; }
220211

221212
/*------------------------------------------------------------------------*/
222213
/** \brief Donne le nom court du type d'objet (pour le nommage des entités)

0 commit comments

Comments
 (0)