Skip to content

Commit 1969988

Browse files
committed
Template group entity
1 parent 353caef commit 1969988

File tree

14 files changed

+365
-1290
lines changed

14 files changed

+365
-1290
lines changed

src/Core/Group/Group0D.cpp

Lines changed: 14 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -26,145 +26,28 @@ Group0D::~Group0D()
2626
{
2727
}
2828
/*----------------------------------------------------------------------------*/
29-
TkUtil::UTF8String & operator << (TkUtil::UTF8String & o, const Group0D & g)
30-
{
31-
o << g.getName()
32-
<< " (uniqueId "<<g.getUniqueId()<<")"
33-
<< (g.isDestroyed()?" (DETRUIT)":"");
34-
o << (g.isVisible()?" visible":" caché");
35-
if (g.getVertices().empty())
36-
o << " vide.";
37-
o << "\n";
38-
39-
Topo::TopoManager& topo_manager = g.getContext().getTopoManager();
40-
for (Geom::Vertex* vtx : g.getVertices()) {
41-
const std::vector<Topo::TopoEntity*>& topos = topo_manager.getRefTopos(vtx);
42-
if (topos.size() > 0) {
43-
o<<" "<<vtx->getName()<<" ->";
44-
for (Topo::TopoEntity* te : topos)
45-
o<<" "<<te->getName();
46-
o << "\n";
47-
}
48-
}
49-
50-
return o;
51-
}
52-
/*----------------------------------------------------------------------------*/
53-
std::ostream & operator << (std::ostream & o, const Group0D & g)
54-
{
55-
TkUtil::UTF8String us (TkUtil::Charset::UTF_8);
56-
us << g;
57-
o << us;
58-
return o;
59-
}
60-
/*----------------------------------------------------------------------------*/
61-
std::string Group0D::getInfos()
62-
{
63-
TkUtil::UTF8String us (TkUtil::Charset::UTF_8);
64-
us << *this;
65-
return us.iso();
66-
}
67-
/*----------------------------------------------------------------------------*/
68-
std::vector<Utils::Entity*> Group0D::getEntities() const
69-
{
70-
// return Internal::entitiesFromTypedEntities (getVertices ( ));
71-
return std::vector<Utils::Entity*> ( );
72-
}
73-
/*----------------------------------------------------------------------------*/
74-
void Group0D::remove(Geom::Vertex* vtx, const bool exceptionIfNotFound)
75-
{
76-
uint i = 0;
77-
for (; i<m_vertices.size() && vtx != m_vertices[i]; ++i)
78-
;
79-
80-
if (i!=m_vertices.size())
81-
m_vertices.erase(m_vertices.begin()+i);
82-
else if(exceptionIfNotFound){
83-
TkUtil::UTF8String messErr (TkUtil::Charset::UTF_8);
84-
messErr << "Le groupe "<<getName()<<" ne contient pas "<<vtx->getName();
85-
throw TkUtil::Exception(messErr);
86-
}
87-
}
88-
/*----------------------------------------------------------------------------*/
89-
void Group0D::remove(Topo::Vertex* vtx, const bool exceptionIfNotFound)
90-
{
91-
uint i = 0;
92-
for (; i<m_topo_vertices.size() && vtx != m_topo_vertices[i]; ++i)
93-
;
94-
95-
if (i!=m_topo_vertices.size())
96-
m_topo_vertices.erase(m_topo_vertices.begin()+i);
97-
else if(exceptionIfNotFound){
98-
TkUtil::UTF8String messErr (TkUtil::Charset::UTF_8);
99-
messErr << "Le groupe "<<getName()<<" ne contient pas "<<vtx->getName();
100-
throw TkUtil::Exception(messErr);
101-
}
102-
}
103-
/*----------------------------------------------------------------------------*/
104-
void Group0D::add(Geom::Vertex* vtx)
105-
{
106-
if (find(vtx)){
107-
TkUtil::UTF8String messErr (TkUtil::Charset::UTF_8);
108-
messErr << "Le groupe "<<getName()<<" possède déjà "<<vtx->getName();
109-
throw TkUtil::Exception(messErr);
110-
}
111-
112-
m_vertices.push_back(vtx);
113-
}
114-
/*----------------------------------------------------------------------------*/
115-
void Group0D::add(Topo::Vertex* vtx)
116-
{
117-
if (find(vtx)){
118-
TkUtil::UTF8String messErr (TkUtil::Charset::UTF_8);
119-
messErr << "Le groupe "<<getName()<<" possède déjà "<<vtx->getName();
120-
throw TkUtil::Exception(messErr);
121-
}
122-
123-
m_topo_vertices.push_back(vtx);
124-
}
125-
/*----------------------------------------------------------------------------*/
126-
bool Group0D::find(Geom::Vertex* vtx)
127-
{
128-
uint i = 0;
129-
for (; i<m_vertices.size() && vtx != m_vertices[i]; ++i)
130-
;
131-
132-
return (i!=m_vertices.size());
133-
}
134-
/*----------------------------------------------------------------------------*/
135-
bool Group0D::find(Topo::Vertex* vtx)
136-
{
137-
uint i = 0;
138-
for (; i<m_topo_vertices.size() && vtx != m_topo_vertices[i]; ++i)
139-
;
140-
141-
return (i!=m_topo_vertices.size());
142-
}
143-
/*----------------------------------------------------------------------------*/
14429
Utils::SerializedRepresentation* Group0D::
14530
getDescription (bool alsoComputed) const
14631
{
14732
std::unique_ptr<Utils::SerializedRepresentation> description (
14833
GroupEntity::getDescription (alsoComputed));
14934

150-
if (!m_vertices.empty()){
151-
Utils::SerializedRepresentation vertices ("Sommets géométriques",
152-
TkUtil::NumericConversions::toStr(m_vertices.size()));
153-
for (std::vector<Geom::Vertex*>::const_iterator its = m_vertices.begin( ); m_vertices.end( )!=its; its++)
154-
vertices.addProperty (
155-
Utils::SerializedRepresentation::Property (
156-
(*its)->getName ( ), *(*its)));
157-
description->addPropertiesSet (vertices);
35+
std::vector<Geom::Vertex*> vertices = getFilteredEntities<Geom::Vertex>();
36+
if (!vertices.empty()){
37+
Utils::SerializedRepresentation sr ("Sommets géométriques",
38+
TkUtil::NumericConversions::toStr(vertices.size()));
39+
for (Geom::Vertex* v : vertices)
40+
sr.addProperty(Utils::SerializedRepresentation::Property(v->getName(), *v));
41+
description->addPropertiesSet (sr);
15842
}
15943

160-
if (!m_topo_vertices.empty()){
161-
Utils::SerializedRepresentation vertices ("Sommets topologiques",
162-
TkUtil::NumericConversions::toStr(m_vertices.size()));
163-
for (std::vector<Topo::Vertex*>::const_iterator its = m_topo_vertices.begin( ); m_topo_vertices.end( )!=its; its++)
164-
vertices.addProperty (
165-
Utils::SerializedRepresentation::Property (
166-
(*its)->getName ( ), *(*its)));
167-
description->addPropertiesSet (vertices);
44+
std::vector<Topo::Vertex*> topo_vertices = getFilteredEntities<Topo::Vertex>();
45+
if (!topo_vertices.empty()){
46+
Utils::SerializedRepresentation sr ("Sommets topologiques",
47+
TkUtil::NumericConversions::toStr(topo_vertices.size()));
48+
for (Topo::Vertex* v : topo_vertices)
49+
sr.addProperty(Utils::SerializedRepresentation::Property(v->getName(), *v));
50+
description->addPropertiesSet (sr);
16851
}
16952

17053
return description.release ( );

src/Core/Group/Group1D.cpp

Lines changed: 14 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -25,160 +25,28 @@ Group1D::~Group1D()
2525
{
2626
}
2727
/*----------------------------------------------------------------------------*/
28-
TkUtil::UTF8String & operator << (TkUtil::UTF8String & o, const Group1D & g)
29-
{
30-
o << g.getName()
31-
<< " (uniqueId "<<g.getUniqueId()<<")"
32-
<< (g.isDestroyed()?" (DETRUIT)":"");
33-
o << (g.isVisible()?" visible":" caché");
34-
if (g.getCurves().empty())
35-
o << " vide.";
36-
o << "\n";
37-
38-
Topo::TopoManager& topo_manager = g.getContext().getTopoManager();
39-
for (Geom::Curve* curv : g.getCurves()) {
40-
const std::vector<Topo::TopoEntity*>& topos = topo_manager.getRefTopos(curv);
41-
if (topos.size() > 0) {
42-
o<<" "<<curv->getName()<<" ->";
43-
for (Topo::TopoEntity* te : topos)
44-
o<<" "<<te->getName();
45-
o << "\n";
46-
}
47-
}
48-
49-
return o;
50-
}
51-
/*----------------------------------------------------------------------------*/
52-
std::ostream & operator << (std::ostream & o, const Group1D & g)
53-
{
54-
TkUtil::UTF8String us (TkUtil::Charset::UTF_8);
55-
us << g;
56-
o << us;
57-
return o;
58-
}
59-
/*----------------------------------------------------------------------------*/
60-
std::string Group1D::getInfos()
61-
{
62-
TkUtil::UTF8String us (TkUtil::Charset::UTF_8);
63-
us << *this;
64-
return us.iso();
65-
}
66-
/*----------------------------------------------------------------------------*/
67-
std::vector<Utils::Entity*> Group1D::getEntities() const
68-
{
69-
// return Internal::entitiesFromTypedEntities (getCurves ( ));
70-
return std::vector<Utils::Entity*> ( );
71-
}
72-
/*----------------------------------------------------------------------------*/
73-
void Group1D::remove(Geom::Curve* crv, const bool exceptionIfNotFound)
74-
{
75-
uint i = 0;
76-
for (; i<m_curves.size() && crv != m_curves[i]; ++i)
77-
;
78-
79-
if (i!=m_curves.size())
80-
m_curves.erase(m_curves.begin()+i);
81-
else if(exceptionIfNotFound){
82-
TkUtil::UTF8String messErr (TkUtil::Charset::UTF_8);
83-
messErr << "Le groupe "<<getName()<<" ne contient pas "<<crv->getName();
84-
throw TkUtil::Exception(messErr);
85-
}
86-
}
87-
/*----------------------------------------------------------------------------*/
88-
void Group1D::remove(Topo::CoEdge* coedge, const bool exceptionIfNotFound)
89-
{
90-
uint i = 0;
91-
for (; i<m_coedges.size() && coedge != m_coedges[i]; ++i)
92-
;
93-
94-
if (i!=m_coedges.size())
95-
m_coedges.erase(m_coedges.begin()+i);
96-
else if(exceptionIfNotFound){
97-
bool isInCurve = false;
98-
if (coedge->getGeomAssociation()){
99-
Geom::Curve* crv = dynamic_cast<Geom::Curve*>(coedge->getGeomAssociation());
100-
if (crv && find(crv))
101-
isInCurve = true;
102-
}
103-
TkUtil::UTF8String messErr (TkUtil::Charset::UTF_8);
104-
messErr << "Le groupe "<<getName()<<" ne contient pas "<<coedge->getName();
105-
if (isInCurve)
106-
messErr << "\nC'est la courbe à laquelle est associée l'arête qui appartient à ce groupe";
107-
throw TkUtil::Exception(messErr);
108-
}
109-
}
110-
/*----------------------------------------------------------------------------*/
111-
void Group1D::add(Geom::Curve* crv)
112-
{
113-
if (find(crv)){
114-
TkUtil::UTF8String messErr (TkUtil::Charset::UTF_8);
115-
messErr << "Le groupe "<<getName()<<" possède déjà "<<crv->getName();
116-
throw TkUtil::Exception(messErr);
117-
}
118-
119-
m_curves.push_back(crv);
120-
}
121-
/*----------------------------------------------------------------------------*/
122-
void Group1D::add(Topo::CoEdge* coedge)
123-
{
124-
if (find(coedge)){
125-
TkUtil::UTF8String messErr (TkUtil::Charset::UTF_8);
126-
messErr << "Le groupe "<<getName()<<" possède déjà "<<coedge->getName();
127-
throw TkUtil::Exception(messErr);
128-
}
129-
if (coedge->getGeomAssociation()){
130-
Geom::Curve* crv = dynamic_cast<Geom::Curve*>(coedge->getGeomAssociation());
131-
if (crv && find(crv)){
132-
TkUtil::UTF8String messErr (TkUtil::Charset::UTF_8);
133-
messErr << "Le groupe "<<getName()<<" possède déjà "<<crv->getName()<<" à laquelle est associée "<<coedge->getName();
134-
throw TkUtil::Exception(messErr);
135-
}
136-
}
137-
m_coedges.push_back(coedge);
138-
}
139-
/*----------------------------------------------------------------------------*/
140-
bool Group1D::find(Geom::Curve* crv)
141-
{
142-
uint i = 0;
143-
for (; i<m_curves.size() && crv != m_curves[i]; ++i)
144-
;
145-
146-
return (i!=m_curves.size());
147-
}
148-
/*----------------------------------------------------------------------------*/
149-
bool Group1D::find(Topo::CoEdge* coedge)
150-
{
151-
uint i = 0;
152-
for (; i<m_coedges.size() && coedge != m_coedges[i]; ++i)
153-
;
154-
155-
return (i!=m_coedges.size());
156-
}
157-
/*----------------------------------------------------------------------------*/
15828
Utils::SerializedRepresentation* Group1D::
15929
getDescription (bool alsoComputed) const
16030
{
16131
std::unique_ptr<Utils::SerializedRepresentation> description (
16232
GroupEntity::getDescription (alsoComputed));
16333

164-
if (!m_curves.empty()){
165-
Utils::SerializedRepresentation curves ("Courbes géométriques",
166-
TkUtil::NumericConversions::toStr(m_curves.size()));
167-
for (std::vector<Geom::Curve*>::const_iterator its = m_curves.begin( ); m_curves.end( )!=its; its++)
168-
curves.addProperty (
169-
Utils::SerializedRepresentation::Property (
170-
(*its)->getName ( ), *(*its)));
171-
description->addPropertiesSet (curves);
34+
std::vector<Geom::Curve*> curves = getFilteredEntities<Geom::Curve>();
35+
if (!curves.empty()){
36+
Utils::SerializedRepresentation sr ("Courbes géométriques",
37+
TkUtil::NumericConversions::toStr(curves.size()));
38+
for (Geom::Curve* curve : curves)
39+
sr.addProperty(Utils::SerializedRepresentation::Property(curve->getName(), *curve));
40+
description->addPropertiesSet(sr);
17241
}
17342

174-
if (!m_coedges.empty()){
175-
Utils::SerializedRepresentation coedges ("Arêtes topologiques",
176-
TkUtil::NumericConversions::toStr(m_coedges.size()));
177-
for (std::vector<Topo::CoEdge*>::const_iterator its = m_coedges.begin( ); m_coedges.end( )!=its; its++)
178-
coedges.addProperty (
179-
Utils::SerializedRepresentation::Property (
180-
(*its)->getName ( ), *(*its)));
181-
description->addPropertiesSet (coedges);
43+
std::vector<Topo::CoEdge*> coedges = getFilteredEntities<Topo::CoEdge>();
44+
if (!coedges.empty()){
45+
Utils::SerializedRepresentation sr ("Arêtes topologiques",
46+
TkUtil::NumericConversions::toStr(coedges.size()));
47+
for (Topo::CoEdge* coedge : coedges)
48+
sr.addProperty(Utils::SerializedRepresentation::Property(coedge->getName(), *coedge));
49+
description->addPropertiesSet(sr);
18250
}
18351

18452
return description.release ( );

0 commit comments

Comments
 (0)