@@ -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 << " \n C'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- /* ----------------------------------------------------------------------------*/
15828Utils::SerializedRepresentation* Group1D::
15929getDescription (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