Hi Dmitri, I'll make Changed() public so you can easily resort. Also if fSegmentList is a TClonesArray than you don't have to Clear() the list. Just the access of a single element will allow a resort, so no loop needed. This will do: Segment* seg = (Segment*)(*fSegmentList)[0]; Cheers, Fons. On Fri, Jul 28, 2000 at 12:15:36PM -0500, Dmitri Litvintsev wrote: > > Hi Fons, > > I don't add objects to this array - I am ordering the segments of > 3D shapes along NDC z-axis in order to get them (shapes) drawn using > solid faces (like in X3D, only in the TCanvas). So, these z-coordinates of > the segments change each time I rotate the shape, so I need to sort them > again, which I cannot since the array has been already sorted in > previous iteration, and the function 'Changed()' is protected, so I > cannot reset IsSorted() flag. > > Courtesy to Pasha Murat, there is a way around: > > // first do this (with already filled list): > fSegmentList->Clear() > // Segment is actually a 3-D brick > > for (int i=0; i<NSegmens(); i++) { > .... > Segment* seg = (Segment*)(*fSegmentList)[i]; > ... > } > > fSegmentList->Sort() // now works all the time due to Clear() call > > Just for fun I attached the resulting PCON shape(looks more like a tube > though) drawn with solid surfaces in the Pad. > > But generally - is it possible to make Changed() method public? > > Dmitri Litvintsev > > /----------------------------------------------------------\ > | Tel: (630) 840 5005 | > | FAX: (630) 840 2968 | > | office: 169-E CDF Trailers | > | E-mail: litvinse@fnal.gov | > \----------------------------------------------------------/ > > > > > On Fri, 28 Jul 2000, Fons Rademakers wrote: > > > Hi Dmitri, > > > > as soon as you add another object to the array (or remove an object) > > IsSorted() will return false. What is the case the this does not work > > for you? > > > > Cheers, Fons. > > > > > > > > On Thu, Jul 27, 2000 at 01:11:11PM -0500, Dmitri Litvintsev wrote: > > > > > > > > > Hi Rooters, > > > > > > I've run into the following problem. > > > > > > I have a object with an attribute that changes over time. > > > I shove a set of these objects into TClonesArray(). I need > > > to sort them from time to time since they must be ordered > > > with respect to this attribute. I added method Compare. > > > And use Sort() method. > > > I noticed that this method can be called only once. Having sorted > > > an array once, the flag IsSorted() is set and cannot be changed. > > > > > > Could you advise on how to avoid this problem? > > > > > > this is really important for me, > > > Dmitri Litvintsev > > > > > > /----------------------------------------------------------\ > > > | Tel: (630) 840 5005 | > > > | FAX: (630) 840 2968 | > > > | office: 169-E CDF Trailers | > > > | E-mail: litvinse@fnal.gov | > > > \----------------------------------------------------------/ > > > > > > > > > > > > > -- > > Org: CERN, European Laboratory for Particle Physics. > > Mail: 1211 Geneve 23, Switzerland > > E-Mail: Fons.Rademakers@cern.ch Phone: +41 22 7679248 > > WWW: http://root.cern.ch/~rdm/ Fax: +41 22 7677910 > > -- Org: CERN, European Laboratory for Particle Physics. Mail: 1211 Geneve 23, Switzerland E-Mail: Fons.Rademakers@cern.ch Phone: +41 22 7679248 WWW: http://root.cern.ch/~rdm/ Fax: +41 22 7677910
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:30 MET