Ejemplo n.º 1
0
void CMnemosynthDb::Write (const CString &sCollection, const CString &sKey, CDatum dValue)

//	Write
//
//	Write an entry in a collection

	{
	CSmartLock Lock(m_cs);

	//	Get the entry (creating it if necessary)

	SEntry *pEntry = GetWriteEntry(sCollection, sKey);

	//	Set the sequence number and owner. Since this is a local write, the
	//	owner is always us (which is always the first entry).

	pEntry->dwOwnerID = 0;
	pEntry->dwSequence = GetNextSequence();

	//	Set the data

	pEntry->dValue = dValue;

#ifdef DEBUG_MNEMOSYNTH
	printf("[CMnemosynthDb::Write]: Wrote %s/%s Seq = %x\n", (LPSTR)sCollection, (LPSTR)sKey, pEntry->dwSequence);
#endif

	//	Modified

	m_ModifiedEvent.Set();
	}
Ejemplo n.º 2
0
// ****************************************************************************
//  Method:  PointSequenceList::GetNextSequence
//
//  Purpose:
//    Extract another sequence from the connectivity array and return it
//    as a PointSequence.  Skip repeated adjacent points.
//
//  Returns:  true if we found another sequence; false otherwise
//
//  Programmer:  Jeremy Meredith
//  Creation:    November  1, 2002
//
//  Modifications:
//    Rich Cook and Hank Childs, Thu Oct  2 16:32:55 PDT 2008
//    Added support for loops.
//
//    Eric Brugger, Tue Dec 29 16:35:34 PST 2009
//    I modified the logic that looks for loops to only consider points
//    that have 2 neighbors.  Previously it would have considered points
//    with no neighbors, which caused it to reference uninitialized memory.
//
//    Jean Favre, Tue May  7 16:38:37 CEST 2013
//    I modified the calls to GetPoint() to use the other variant of the call
//    with two arguments. The previous version would never succeed in the test
//    to remove sequential identical points.
//    Used vtkIdType where needed
// ****************************************************************************
bool
vtkConnectedTubeFilter::PointSequenceList::GetNextSequence(PointSequence &seq)
{
    // index is already set by InitTraversal and previous calls to this fn
    for (; index < len; index++)
    {
        // if numneighbors is 1, then this is a start point
        if (((lookforloops && numneighbors[index] == 2) ||
              numneighbors[index] == 1) && !visited[index])
        {
            vtkIdType current = index;
            vtkIdType previous = -1;
            seq.Init(len);
            seq.Add(current, cellindex[current]);
            visited[current] = true;
            while (true)
            {
                vtkIdType n1       = connectivity[0][current];
                vtkIdType n2       = connectivity[1][current];
                vtkIdType next     = (n1 == previous) ? n2 : n1;
                previous = current;
                current = next;

 
                // we must skip any sequential identical points:
                // 1) they are useless, and 2) they mess up calculations
                double prePt[3];
                double curPt[3];
                pts->GetPoint(previous, prePt);
                pts->GetPoint(current, curPt);
                if (prePt[0] != curPt[0] ||
                    prePt[1] != curPt[1] ||
                    prePt[2] != curPt[2])
                {
                    seq.Add(current, cellindex[current]);
                }

                // check for a loop (AFTER adding the node again...)
                if (lookforloops && visited[current]) 
                {
                    break; 
                }
                visited[current] = true;

                bool endpoint = (numneighbors[current] == 1);
                if (endpoint)
                    break;
            }

            // We may have one duplicated cell index due to the way the
            // connectivity was built -- shift them all down by one from
            // the right spot, so the only duplicated one is the last one.
            for (int i=1; i<seq.length-1; i++)
            {
                if (seq.cellindex[i-1] == seq.cellindex[i])
                    seq.cellindex[i] = seq.cellindex[i+1];
            }

            // true ==> success; got another sequence
            return true;
        }
    }

    if (index == len && !lookforloops) 
    {
        lookforloops = true; 
        index=0; 
        return GetNextSequence(seq);
    }

    // false ==> failed; no more sequences
    return false;
}