473,320 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Class design with tightly bound iterator

I am working on a class design to contain the indices of triangle lists for
body parts. This is for 3d modeling. As as start I have:

class PartTriangles
{
public:
PartTriangels( const std::string& Name ): Name( Name ) {}
private:
std::string Name;
std::set<size_tTriangles;
std::vector<PartTrianglesConnections;
};

which may (probably will) change and a lot of things added. Anyway... the
reason I am designing this class is I need to keep a list of the indices for
a model for each body part so I can animate them, meaning I need to get some
type of list of what triangles are in, for instance, the right leg. My
thought was that this ... three type list... would start with the torso
"torso". Whoulc would have in it's vector 5 connections, head, right
bicept, left bicept, right upper leg, left upper leg. So in this way every
triangle would be list listed somewhere to contain the entire body, but only
once. Now, the situation is, I need to be able to get a list of things that
are in, say, the right leg, which would contain the upper leg, lower leg and
foot. So interators came to mind. So this is what I am planning on
developing:

someinteratortype it = MyBody("right upper leg");
It should be fairly easy for PartTriangles to return an iterator pointing to
it's std::set for the beginning of the upper leg. However, it would not
actually be in the instance of MyBody, which would have the set for Torso,
but in MyBody's vector of PartTriangles where the name is "right upper leg".
Also is the complication of .end() There are 5 end()'s, one for head, one
for right hand pinky (if I go as far as fingers), left hand pinkie, right
foot, etc..

In addition, looking at an implementation of a custom iterator, it's
increment is simply:
custom_iterator& operator++()
{
// preincrement
++m_Ptr;
return (*this);
}
custom_iterator operator++(int)
{
// postincrement
custom_iterator _Tmp = *this;
++*this;
return (_Tmp);
}

m_Ptr is
_Ty *m_Ptr;
in a template.

It seems to me that my iterator would have to store more information than a
single pointer especially for increment. Consider the case where I am
iteratiing over the right upper leg and get to the end of PartTriangle's
set, I would then want an increment to step into Connection's into it's
entries sets, etc... Of course, after it went through the first set, it may
have to back out to do the next part of the vector, looking like I have some
type of recursion taking place.

Anyone have familiarity with these types of iterators, or am I trying to
make an iterator do something it's not designed for?

I'm open to any and all suggestions.
Sep 5 '07 #1
2 1449
Jim Langston wrote:
>
someinteratortype it = MyBody("right upper leg");
It should be fairly easy for PartTriangles to return an iterator pointing to
it's std::set for the beginning of the upper leg. However, it would not
actually be in the instance of MyBody, which would have the set for Torso,
but in MyBody's vector of PartTriangles where the name is "right upper leg".
Also is the complication of .end() There are 5 end()'s, one for head, one
for right hand pinky (if I go as far as fingers), left hand pinkie, right
foot, etc..
Well, to iterate YourBody is so hard.

I happened to see an STL-like tree implementation,
it has
in_begin(), in_end()
post_being(), post_end()
....
in pair by the traverse method.

So why not doing so here.

As my conceptual idea, I would say why not buy strategy pattern.

begin(Strategy1()), end(Strategy1())

--
Thanks
Barry
Sep 6 '07 #2
"Barry" <dh*****@gmail.comwrote in message news:fb**********@aioe.org...
Jim Langston wrote:
>>
someinteratortype it = MyBody("right upper leg");
It should be fairly easy for PartTriangles to return an iterator pointing
to it's std::set for the beginning of the upper leg. However, it would
not actually be in the instance of MyBody, which would have the set for
Torso, but in MyBody's vector of PartTriangles where the name is "right
upper leg". Also is the complication of .end() There are 5 end()'s, one
for head, one for right hand pinky (if I go as far as fingers), left hand
pinkie, right foot, etc..
Well, to iterate YourBody is so hard.

I happened to see an STL-like tree implementation,
it has
in_begin(), in_end()
post_being(), post_end()
...
in pair by the traverse method.

So why not doing so here.
.... "in pair by the traverse method..." I'm not familiar with that term,
I'll try to look it up.

But, yes, it is a form of tree.
As my conceptual idea, I would say why not buy strategy pattern.

begin(Strategy1()), end(Strategy1())
Looking at the strategy design, it seems to be a form of polymorphic funcion
calls. I don't see how that will help me, unless there is some other form
of strategy pattern I'm missing.

Sep 6 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: CoolPint | last post by:
If I were to design my own container and its iterators, I understand that I need to provide both "iterator" and "const_iterator" so that begin() and end() return appropriate ones depending on the...
5
by: Mathieu Benoit | last post by:
(I'm having trouble to post this, sorry if this mail comes several times) I'm trying to optimize the use of an integer array class, and I found that one major problem is pointer aliasing. I...
3
by: alexhong2001 | last post by:
When design a class, should always make it "derivable" as a base class? Is there really a situation that the designed class not "derivable"? When should make a member "protected"? Only when...
12
by: James Brown | last post by:
Hi all, Having problems designing a template-class. I'll describe my scenario first then show what I've come up with so far: Need a class to provide pointer/array-like access to an area of...
3
by: Ed | last post by:
Hi, I have a WorkUnit class. I will pass a reference to a group of these WorkUnits to other classes in my application. I have chosen to use a vector to hold pointers to these WorkUnits for now....
9
by: David A. Osborn | last post by:
I have a set of classes that each have an enumeration in them, and based on dynamic input I need to access a different enumeration. For example Three classes Class_A, Class_B, and Class_C that...
19
by: Chocawok | last post by:
Some of the classes in my app are graphical. To encapsulate the graphical side of things I had created a class called "sprite" which holds a bit map and knows how to draw itself etc. The...
3
by: Belebele | last post by:
I have an Element class which is abstract and I would like to have an object of the Iterator class to iterate over a range of elements. I would like to use std::for_each to instrument the...
20
by: vbgunz | last post by:
I remember learning closures in Python and thought it was the dumbest idea ever. Why use a closure when Python is fully object oriented? I didn't grasp the power/reason for them until I started...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.