On-line: гостей 0. Всего: 0 [подробнее..]
Программисты всех стран, объединяйтесь!

АвторСообщение



ссылка на сообщение  Отправлено: 19.07.14 08:20. Заголовок: split a 2D vector based on (x & y) coordinates


i need a class with functionality like group an area of a 2D vector based on coordinate (x & y )
eg:
this is my 2D vector values

54 , 78 , 89 , 25 , 45
12 , 45 , 45 , 45 , 45
54 , 78 , 89 , 25 , 45
12 , 45 , 45 , 45 , 45
54 , 78 , 89 , 25 , 45
12 , 45 , 45 , 45 , 45

so in this case 2D vector coordinate look like this

01 , 02 , 03 , 04 , 05
06 , 07 , 08 , 09 , 10
11 , 12 , 13 , 14 , 15
16 , 17 , 18 , 19 , 20
21 , 22 , 23 , 24 , 25
26 , 27 , 28 , 29 , 30

you can see red number in coordinate if i input that value to class or function i need to split that area for later calculation , edit value or remove
also print edited 2D vector completely how can i done this

split-ed area
07,08,09
12,13,14,15
17,18,19
22,23,24



Спасибо: 0 
ПрофильЦитата Ответить
Ответов - 6 [только новые]





ссылка на сообщение  Отправлено: 19.07.14 14:42. Заголовок: I do not know a read..


I do not know a ready to use implementation of such a class. So you should either write the class yourself or maybe direct your attention to some free matrix software where such functionality is already realized. Unfortunately I did not deal with such a software.

Спасибо: 0 
ПрофильЦитата Ответить



ссылка на сообщение  Отправлено: 21.07.14 10:27. Заголовок: what u mean by free ..


what u mean by free matrix software its a library of code like open cv . can u show me a reference site

Спасибо: 0 
ПрофильЦитата Ответить



ссылка на сообщение  Отправлено: 21.07.14 19:49. Заголовок: All wad done before ..


All was done before us.:) i think that the similar task was already done by someone and I suppose that there might be an open source project. I was not interested in such a task so I am unable to point out the free software where the similar class is already written. If you need a ready to use program then you should search the internet and ask the question in other forums. Maybe somebody will help you.

Спасибо: 1 
ПрофильЦитата Ответить



ссылка на сообщение  Отправлено: 21.07.14 21:22. Заголовок: ok thanks :sm36: ..


ok thanks

Спасибо: 0 
ПрофильЦитата Ответить



ссылка на сообщение  Отправлено: 21.07.14 23:42. Заголовок: As i see nobody help..


As i see nobody helped you at stackoverflow

The task conld be simpler if the selected numbers would not specify ranges as in this row from your example

11 , 12 , 13 , 14 , 15

That is instead of 12, 13, 14, 15 you were to get only elements with indices 12 and 15. In this case the straightforward approach could look the following way

 
#include <iostream>
#include <vector>
#include <iterator>

int main()
{
std::vector<std::vector<int>> v =
{
{ 54 , 78 , 89 , 25 , 45 },
{ 12 , 45 , 45 , 45 , 45 },
{ 54 , 78 , 89 , 25 , 45 },
{ 12 , 45 , 45 , 45 , 45 },
{ 54 , 78 , 89 , 25 , 45 },
{ 12 , 45 , 45 , 45 , 45 }
};

for ( const std::vector<int> &v1 : v )
{
for ( int x : v1 ) std::cout << x << ' ';
std::cout << std::endl;
}
std::cout << std::endl;

size_t a[] = { 7, 8, 9, 12, 17, 19, 22, 23, 24 };

std::vector<std::vector<int>> v2;
size_t *p = a;
std::vector<int>::size_type n = 1;

for ( const std::vector<int> &v1 : v )
{
std::vector<int> tmp;
std::vector<int>::size_type i = 0;
for ( ; i < v1.size(); i++ )
{
if ( ( p != std::end( a ) ) && ( i + n == *p ) )
{
tmp.push_back( v1 );
++p;
}
}

n += i;
if ( !tmp.empty() ) v2.push_back( tmp );
}

for ( const std::vector<int> &v1 : v2 )
{
for ( int x : v1 ) std::cout << x << ' ';
std::cout << std::endl;
}
std::cout << std::endl;

return 0;
}


The output is
 
54 78 89 25 45
12 45 45 45 45
54 78 89 25 45
12 45 45 45 45
54 78 89 25 45
12 45 45 45 45

45 45 45
78
45 45
78 89 25


It is not what you want to get but it is close to the aim.






Спасибо: 0 
ПрофильЦитата Ответить



ссылка на сообщение  Отправлено: 22.07.14 12:35. Заголовок: i know no one going ..


i know no one going to help in stackoverflow because this task is little big i think , but i sure i will get sum clue about it .
i really appreciate your help thank u , all i wants a shape now i got it i will complete this code

Спасибо: 0 
ПрофильЦитата Ответить
Ответ:
1 2 3 4 5 6 7 8 9
большой шрифт малый шрифт надстрочный подстрочный заголовок большой заголовок видео с youtube.com картинка из интернета картинка с компьютера ссылка файл с компьютера русская клавиатура транслитератор  цитата  кавычки моноширинный шрифт моноширинный шрифт горизонтальная линия отступ точка LI бегущая строка оффтопик свернутый текст

показывать это сообщение только модераторам
не делать ссылки активными
Имя, пароль:      зарегистрироваться    
Тему читают:
- участник сейчас на форуме
- участник вне форума
Все даты в формате GMT  3 час. Хитов сегодня: 1
Права: смайлы да, картинки да, шрифты да, голосования нет
аватары да, автозамена ссылок вкл, премодерация откл, правка нет