Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how model this problem?

47 views
Skip to first unread message

alessio211734

unread,
Mar 27, 2018, 6:04:26 AM3/27/18
to
Hello,
I should model a problem in c++.

I have a region compose by a set of points where every point have some property and a prev and next point.

start ->p1<->p2<->p3<->p4<->end

I would like split in more regions this points based on some nearby
property like curvature and high. I would like that in every region keep the adjacenty property of every point.


I tried to write some code:
I have some doubts about, what's happen if I delete some elements of shared list I think the iterator became invalid.
With a similar solution I need to sinchronyze every region when I delete an element and I should again understand what's happen on insert new element.

template <class T>
class SubRegion
{
public:
typedef typename std::list<T>::iterator ElementIterator;
typedef typename std::list<T>::const_iterator ConstElementIterator;
SubRegion(const std::list<ElementIterator> & lit)
{
pElements = lit;
};

typename std::list< ElementIterator >::iterator begin()
{
return pElements.begin();
};

typename std::list< ElementIterator >::iterator end()
{
return pElements.end();
};

T & element(typename std::list< ElementIterator >::iterator pelement)
{
return (*(*pelement));
};

std::list<ElementIterator> pElements;
};




template <class T>
class Region
{
public:
void buildRegions(std::list<T> & elements)
{
// suppose list with 3 element
shared_list = elements;
SubRegion<T>::ElementIterator it = elements.begin();
std::list<SubRegion<T>::ElementIterator> subElement1;
subElement1.push_back(it);
subRegion.push_back(subElement1);
std::list<SubRegion<T>::ElementIterator> subElement2;
subElement2.push_back(++it);
subElement2.push_back(++it);
SubRegion<T> r1(subElement1);
SubRegion<T> r2(subElement2);
subRegion.push_back(r1);
subRegion.push_back(r2);
//SubRegion<T> s1
}
SubRegion<T> & getRegion(int i)
{
return subRegion[i];
}
protected:
std::vector< SubRegion<T> > subRegion;
std::list<T> shared_list;
};

Jorgen Grahn

unread,
Mar 27, 2018, 7:08:54 AM3/27/18
to
On Tue, 2018-03-27, alessio211734 wrote:
> Hello,
> I should model a problem in c++.
>
> I have a region compose by a set of points where every point have
> some property and a prev and next point.
>
> start ->p1<->p2<->p3<->p4<->end

Are you simply trying to say you have a polygon defined by its
verticises? And that each vertex has a property?

> I would like split in more regions this points based on some nearby
> property like curvature and high. I would like that in every region
> keep the adjacenty property of every point.

I can't guess what this means. Perhaps it's not a polygon, but then I
don't know what it is. Also "based on some nearby property" sounds
very vague.

You'd get better help if you could clarify the problem a bit more.

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .

alessio211734

unread,
Mar 27, 2018, 8:01:44 AM3/27/18
to
it's a 2d section composed by 2d vertex. The section is a list of 2d vertex order in ccw way. I should divide the initial region(the initial section) in more regions based on the curvature and other property
To calculate this region I should know the adjacent vertex of every vertex.
Maybe after I divide in subregion I need to merge some region together.

Jorgen Grahn

unread,
Mar 27, 2018, 8:31:14 AM3/27/18
to
On Tue, 2018-03-27, alessio211734 wrote:
> Il giorno martedì 27 marzo 2018 13:08:54 UTC+2, Jorgen Grahn ha scritto:
>> On Tue, 2018-03-27, alessio211734 wrote:
>> > Hello,
>> > I should model a problem in c++.
>> >
>> > I have a region compose by a set of points where every point have
>> > some property and a prev and next point.
>> >
>> > start ->p1<->p2<->p3<->p4<->end
>>
>> Are you simply trying to say you have a polygon defined by its
>> verticises? And that each vertex has a property?
>>
>> > I would like split in more regions this points based on some nearby
>> > property like curvature and high. I would like that in every region
>> > keep the adjacenty property of every point.
>>
>> I can't guess what this means. Perhaps it's not a polygon, but then I
>> don't know what it is. Also "based on some nearby property" sounds
>> very vague.
>>
>> You'd get better help if you could clarify the problem a bit more.
>>
>> /Jorgen
>
> it's a 2d section composed by 2d vertex. The section is a list of 2d
> vertex order in ccw way. I should divide the initial region(the
> initial section) in more regions based on the curvature and other
> property To calculate this region I should know the adjacent vertex
> of every vertex. Maybe after I divide in subregion I need to merge
> some region together.

I still don't understand if this is a polygon or not, but perhaps
someone else does and can answer. Good luck!

Öö Tiib

unread,
Mar 27, 2018, 2:05:31 PM3/27/18
to
On Tuesday, 27 March 2018 15:31:14 UTC+3, Jorgen Grahn wrote:
>
> I still don't understand if this is a polygon or not, but perhaps
> someone else does and can answer. Good luck!

What he described sounded to me like what is in computer graphics
called "polyline" (not "polygon"). I may be wrong because I also did
not understand his question.
0 new messages