Hello,
I'm wondering if there is a way to know the exact order of the parents with respect to the CPT values. If so, is there also a way to change it?
I got the impression that you may change the order of parents but since it refers to ALL parents (not only direct one, with repetitions and so on), it will not came at handy to properly fulfill the task...
Thanks
Alessandro
How to know CPT's parent order (and then modify it)
-
- Posts: 10
- Joined: Tue Feb 17, 2015 9:36 am
-
- Site Admin
- Posts: 1419
- Joined: Mon Nov 26, 2007 5:51 pm
Re: How to know CPT's parent order (and then modify it)
DSL_network::GetParents returns the ordered list of parent nodes. To change it, use the following method:
Code: Select all
int DSL_network::ChangeOrderOfParents(int handle, DSL_intArray &newOrder);
-
- Posts: 10
- Joined: Tue Feb 17, 2015 9:36 am
Re: How to know CPT's parent order (and then modify it)
I tried it out but I still get a -2 error code (and no error in the ErrorHandler().GetLastErrorMessage()). I checked the array I'm passing by and it is something like: 1 0 2 3 4 5 6 7, so they are correct indexes w.r.t. a vector of 8 elements.
-
- Site Admin
- Posts: 1419
- Joined: Mon Nov 26, 2007 5:51 pm
Re: How to know CPT's parent order (and then modify it)
Due to backward compatibility issues going back to late 90's there's a nonzero chance your order array is not initialized properly. Did you use DSL_intArray::Add or DSL_intArray::SetSize?I tried it out but I still get a -2 error code (and no error in the ErrorHandler().GetLastErrorMessage()).
-
- Posts: 10
- Joined: Tue Feb 17, 2015 9:36 am
Re: How to know CPT's parent order (and then modify it)
I did use a code like the following one (resorting to SetSize() actually) because the way I need to re-order the elements requires to access indexes in a "random" way...
Code: Select all
....
DSL_intArray actual_order(m_theNet->GetParents(m_id));
DSL_intArray final_order;
...
final_order.SetSize(actual_order.GetSize());
...
final_order[index] = next_element - 1;
...
-
- Posts: 10
- Joined: Tue Feb 17, 2015 9:36 am
Re: How to know CPT's parent order (and then modify it)
Actually, I solved my problem... but there are several "issues" in the library (and documentation), from my perspective at least:
- 1. DSL_intArray::GetSize() is not useful at all: it does not return the number of elements, where DSL_intArray::NumItems() does that.
2. DSL_intArray::SetSize() does not work. It is completely ignored.
3. DSL_intArray::Insert(), works properly only if you insert indexes in the correct order (first 0, then 1, etc.). If not so, you lost all items inserted before the last one...
4. DSL_intArray::Add() seems not alter the DSL_intArray::NumItems() result (both with or without setting the size in advance, I still got 0 as number of items.
- 1. using a common for loop, DSL_intArray::Insert "fake" elements;
2. run the re-arrage algorithm changing the items (resorting to common vector [] operator...)