Esempio n. 1
0
bool arlCore::PlaneSystem::isConnected( unsigned int plane1, unsigned int plane2, long int date, long int time, bool SetInv, bool ToTag )
{
    assert(!outOfRange(plane1) && !outOfRange(plane2));
    if(outOfRange(plane1, plane2)) return false;
    if(plane1==plane2 || isTagged(plane1,plane2) || isTagged(plane2,plane1)) return false;
    unsigned int index = getIndex(plane1, plane2);
    if(getStatus(index)!=STATE_UNDEFINED && getStatus(index)!=STATE_COMPUTED/* && m_trfTable[index].isEquivalent(date,time)*/)
    {
        if(ToTag) tag(plane1, plane2);
        return true;
    }
    const unsigned int InvIndex = getIndex(plane2, plane1);
    if(getStatus(InvIndex)!=STATE_UNDEFINED && getStatus(InvIndex)!=STATE_COMPUTED/* && m_trfTable[inv].isEquivalent(date,time)*/)
    {
        if(SetInv)
        {
//          Object::update();
            if(m_trfTable[index].invert(m_trfTable[InvIndex]))
            {
                m_trfState[index] = getStatus(InvIndex);
                m_trfWeight[index] = getWeight(InvIndex);
            }
        }
        if(ToTag) tag(plane1,plane2);
        return true;
    }
    return false;
}
Esempio n. 2
0
bool arlCore::PlaneSystem::setTrf( unsigned int plane1, unsigned int plane2, const vnl_rigid_matrix& T, long int date, long int time )
{
    assert(!outOfRange(plane1, plane2) && plane1!=plane2);
    if(outOfRange(plane1, plane2) || plane1==plane2) return false;
    m_trfState[getIndex(plane2, plane1)] = STATE_UNDEFINED;
    return setTrf(getIndex(plane1, plane2), T, date, time);
}
Esempio n. 3
0
bool arlCore::PlaneSystem::getPlaneName( unsigned int ID, std::string &name) const
{
    assert(!outOfRange(ID));
    if(outOfRange(ID)) return false;
    name = m_lstName[ID-1];
    return true;
}
Esempio n. 4
0
void setPslBits(struct lineFile *lf, 
	Bits *bits, struct psl *psl, int winStart, int winEnd)
/* Set bits that are in psl. */
{
int i, s, e, w, blockCount = psl->blockCount;
boolean isRev = (psl->strand[1] == '-');
for (i=0; i<blockCount; ++i)
    {
    s = psl->tStarts[i];
    e = s + psl->blockSizes[i];
    if (isRev)
       {
       /* Use w as a temp variable to reverse coordinates s&e. */
       w = psl->tSize - e;
       e = psl->tSize - s;
       s = w;
       }
    /* Clip, and if anything left set it. */
    if (s < winStart) outOfRange(lf, psl->tName, psl->tSize);
    if (e > winEnd) outOfRange(lf, psl->tName, psl->tSize);
    w = e - s;
    if (w > 0)
	bitSetRange(bits, s, w);
    }
}
Esempio n. 5
0
void fbOrBed(Bits *acc, char *track, char *chrom, int chromSize)
/* Or in bits of psl file that correspond to chrom. */
{
struct lineFile *lf;
char fileName[512];
char *row[3];
int s, e, w;

chromFileName(track, chrom, fileName);
if (!fileExists(fileName))
    return;
lf = lineFileOpen(fileName, TRUE);
while (lineFileRow(lf, row))
    {
    if (sameString(row[0], chrom))
        {
	s = lineFileNeedNum(lf, row, 1);
	if (s < 0) outOfRange(lf, chrom, chromSize);
	e = lineFileNeedNum(lf, row, 2);
	if (e > chromSize) outOfRange(lf, chrom, chromSize);
	w = e - s;
	if (w > 0)
	    bitSetRange(acc, s, w);
	}
    }
lineFileClose(&lf);
}
Esempio n. 6
0
bool arlCore::PlaneSystem::resetTrf( unsigned int plane1, unsigned int plane2 )
{
    assert(!outOfRange(plane1, plane2) && plane1!=plane2);
    if(outOfRange(plane1, plane2) || plane1==plane2) return false;
    unsigned int i = getIndex(plane1, plane2);
    Object::update();
    m_trfState[i] = STATE_UNDEFINED;
    m_trfState[getIndex(plane2, plane1)] = STATE_UNDEFINED;
    eraseComputedTrf(i);
    return true;
}
Esempio n. 7
0
bool arlCore::PlaneSystem::resetTrf( unsigned int plane )
{
    assert(!outOfRange(plane));
    if(outOfRange(plane)) return false;
    Object::update();
    unsigned int i;
    for( i=0 ; i<m_status.size() ; ++i )
        if(m_status[i])
        {
            m_trfState[getIndex(plane,i+1)] = STATE_UNDEFINED;
            m_trfState[getIndex(i+1,plane)] = STATE_UNDEFINED;
        }
    // FIXME eraseComputedTrf(?);
    return true;
}
Esempio n. 8
0
unsigned int arlCore::PlaneSystem::whoIsConnected( unsigned int connectedAt, unsigned int finalDestination, std::vector<PlaneWeight> &planes, long int date, long int time, bool SetInv, bool ToTag )
{
    assert(!outOfRange(connectedAt, finalDestination));
    planes.clear();
/*  if(isConnected(connectedAt, finalDestination, date, time, SetInv, ToTag))
    {
        planes.push_back(PlaneWeight(finalDestination, getWeight(connectedAt, finalDestination)));
        return 1;
    }*/
    unsigned int i;
    bool sort = false;
    double firstWeight = -1;
    for( i=1 ; i<=m_status.size() ; ++i )
        if(/*i!=finalDestination && */m_status[i-1])
            if(isConnected(connectedAt, i, date, time, SetInv, ToTag))
            {
                const double Weight = getWeight(connectedAt, i);
                planes.push_back(PlaneWeight(i, Weight));
                if(!sort)
                {// Sort weights only if it exists at least two different weights
                    if(firstWeight<0) firstWeight = Weight;
                    else if(Weight!=firstWeight) sort = true;
                }
            }
    if(sort) std::sort(planes.begin(), planes.end(), sortPlanes);
    return (unsigned int)planes.size();
}
Esempio n. 9
0
void List::insert(const ListItemType& newItem)
   throw(ListIndexOutOfRangeException, ListException)
{
   ListException listEx("ListException: List full on insert");
   ListIndexOutOfRangeException outOfRange("ListIndexOutOfRangeException: Bad index on insert");                  
   int index = size + 1;

   if (size >= MAX_LIST)
      throw listEx;
      //ListException("ListException: List full on insert");

   if (index >= 1 && index <= size+1)
   {
       for (int pos = size; pos >= index; --pos)
         items[translate(pos+1)] = items[translate(pos)];
      // insert new item
      items[translate(index)] = newItem;
      ++size;  // increase the size of the list by one
	  bubbleSort();
   }
   else  // index out of range
      throw outOfRange;
      //ListIndexOutOfRangeException( "ListIndexOutOfRangeException: Bad index on insert");
   // end if
}  // end insert
Esempio n. 10
0
void arlCore::PlaneSystem::untag( unsigned int plane1, unsigned int plane2 )
{
    assert(!outOfRange(plane1) && !outOfRange(plane2));
    const unsigned int Index = getIndex(plane1, plane2);
    if(isTagged(Index))
    {
        //Object::update();
        m_trfState[Index] = (ARL_PLANE_STATE)(m_trfState[Index] - NBSTATES);
    }
    const unsigned int InvIndex = getIndex(plane1, plane2);
    if(isTagged(InvIndex))
    {
        //Object::update();
        m_trfState[InvIndex] = (ARL_PLANE_STATE)(m_trfState[InvIndex] - NBSTATES);
    }
}
Esempio n. 11
0
bool arlCore::PlaneSystem::findPath( unsigned int plane1, unsigned int plane2, Path &path, long int date, long int time )
{
    assert(!outOfRange(plane1) && !outOfRange(plane2));
    std::vector<PlaneWeight> Who;
    unsigned int i, n = whoIsConnected(plane1, plane2, Who, date, time, true, true);
    if(n==0) return false;
    path.push_back(plane1);
    for( i=0 ; i<n ; ++i )
    {
        if(Who[i].first==plane2)
        {
            path.push_back(plane2);
            return true;
        }
        if(findPath(Who[i].first,plane2,path,date,time)) return true;
    }
    path.pop_back();
    return false;
}
Esempio n. 12
0
bool arlCore::PlaneSystem::setIdentity ( unsigned int plane1, unsigned int plane2, const long int date, const long int time )
{
    if(outOfRange(plane1, plane2) || plane1==plane2) return false;
    assert(!outOfRange(plane1, plane2) && plane1!=plane2);
    unsigned int index;
    vnl_rigid_matrix T;
    T.setIdentity();
    T.setTime(date, time);
    index = getIndex(plane1, plane2);
    eraseComputedTrf(index);
    Object::update();
    m_trfTable[index].copy(T);
    m_trfState[index] = STATE_IDENTITY;
    m_trfWeight[index] = 0;
    index = getIndex(plane2, plane1);
    m_trfTable[index].copy(T);
    m_trfState[index] = STATE_IDENTITY;
    m_trfWeight[index] = 0;
    return true;
}
Esempio n. 13
0
void PosEdit::stepDown()
      {
      int secNo = ed->focusSection();
      bool accepted = false;
      if (!outOfRange(secNo, sec[secNo].val-1)) {
            accepted = true;
            setSec(secNo, sec[secNo].val-1);
            }
      if (accepted) {
            changed = true;
            emit valueChanged(pos());
            }
      ed->repaint(ed->rect(), false);
      }
Esempio n. 14
0
void fbOrChain(Bits *acc, char *track, char *chrom, int chromSize)
/* Or in a chain file. */
{
struct lineFile *lf;
char fileName[512];
struct chain *chain;
struct cBlock *b;

chromFileName(track, chrom, fileName);
if (!fileExists(fileName))
    return;
lf = lineFileOpen(fileName, TRUE);
while ((chain = chainRead(lf)) != NULL)
    {
    for (b = chain->blockList; b != NULL; b = b->next)
        {
	int s = b->tStart, e = b->tEnd;
	if (s < 0) outOfRange(lf, chrom, chromSize);
	if (e > chromSize) outOfRange(lf, chrom, chromSize);
	bitSetRange(acc, b->tStart, b->tEnd - b->tStart);
	}
    chainFree(&chain);
    }
}
Esempio n. 15
0
void PosEdit::addNumber(int secNo, int num)
      {
      if (secNo == -1)
            return;
      killTimer(timerId);
      bool accepted  = false;
      typing         = true;
      int voff       = sec[secNo].voff;

      QString txt = sectionText(secNo);

      if ((unsigned) txt.length() == sec[secNo].len) {
            if (!outOfRange(secNo, num - voff)) {
                  accepted = true;
                  sec[secNo].val = num - voff;
                  }
            }
      else {
            txt += QString::number(num);
            int temp = txt.toInt() - voff;
            if (outOfRange(secNo, temp))
                  txt = sectionText(secNo);
            else {
                  accepted = true;
                  sec[secNo].val = temp;
                  }
            if (adv && ((unsigned) txt.length() == sec[secNo].len)) {
                  setFocusSection(ed->focusSection() + 1);
                  }
            }
      changed = accepted;
      if (accepted)
            emit valueChanged(pos());
      timerId = startTimer(qApp->doubleClickInterval()*4);
      ed->repaint(ed->rect(), false);
      }
Esempio n. 16
0
void KinematicPoints::CalculateMachineCoordinates(QVector3D toolPoint)
{
    SetToolPoint(toolPoint);
    SetTransitionalPoint();
    SetS1C1();
    SetS5C5();
    SetS234C234();
    SetRegionalPoint();
    SetAB();
    SetS2C2();
    SetS3C3();
    SetS23C23();
    SetS4C4();
    SetJointPoints();
    SetCalculatedJointPoints();

   static bool ok = true;
   for(int i=0; i<5; ++i)
   {
      fi[i] = c[i]>s[i]? qAsin(s[i]) : qAcos(c[i]);
      if(fi[i]!=fi[i])
      {
         if(ok)
         {
             ok = false;
             emit outOfRange();
             return;
         }

        else
         {
             ok = true;
             return;
         }
        }
   }

    if(lastValidPoint != toolPoint)
        emit statusOK();

    lastValidPoint = toolPoint;

}
Esempio n. 17
0
bool arlCore::PlaneSystem::getTrf( unsigned int plane1, unsigned int plane2, vnl_rigid_matrix &T, bool verbose )
{
//  verbose = false;
    // TODO : Manage the cases when there are many paths to reach plane2
    // TODO : Prendre uniquement le chemin le plus r�cent, le plus court, celui de poids minimum
    // TODO : Ne pas poursuivre dans les chemins incompatible avec la date
//  assert(!outOfRange(plane1, plane2));
    if(outOfRange(plane1, plane2))
    {
        T.setIdentity();
        T.setTime(0, 0);
        return false;
    }
//  Object::update(); // ?
    const long int Date = 0, Time = 0; // FIXME
    if(plane1 != plane2)
    {
        if(isConnected( plane1, plane2, Date, Time, true, false ))
        {
            if(verbose) std::cout<<"From "<<plane1<<" to "<<plane2<<"\n";
            T = m_trfTable[getIndex(plane1, plane2)];
            return true;
        }
        //std::vector< unsigned int >path;
        PlaneSystem::Path path(*this);
        bool b=findPath( plane1, plane2, path, Date, Time );
        if(b)
        {
            if(verbose) path.print();
            setTrf(path);
            T = m_trfTable[getIndex(plane1, plane2)];
        }else
        {
            T.setIdentity();
            T.setTime(0, 0);
        }
        untagAll();
        return b;
    }
    T.setIdentity();
    T.setTime(getDate(), getTime());
    return true;
}
Esempio n. 18
0
unsigned int arlCore::PlaneSystem::getIndex( unsigned int plane1, unsigned int plane2 ) const
{   // Organisation concentrique des index :
    //    |  1  2  3  4 <- plane1
    //    |===================
    //  1 | 00 01 04 09 ...
    //  2 | 03 02 05 10 ...
    //  3 | 08 07 06 11 ...
    //  4 | 15 14 13 12 ...
    //  ^plane2
    assert(!outOfRange(plane1, plane2));
    unsigned int index;
    if(plane2<=plane1)
        index = (plane1-1)*(plane1-1)+(plane2-1);
    else
        index = (plane2*plane2)-plane1;
    assert(index<m_trfState.size());
    assert(index==getInvIndex(getInvIndex(index)));
    return index;
}
Esempio n. 19
0
void lcl_OnyxLineEdit::keyReleaseEvent(QKeyEvent *ke)
{
    if (ke->key() == Qt::Key_Escape)
    {
        ke->ignore();
        return;
    }

    if (out_of_range_ || (ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Down))
    {
        out_of_range_ = false;
        qDebug("broadcast out of range signal.");
        ke->ignore();
        emit outOfRange(ke);
        return;
    }

    QLineEdit::keyReleaseEvent(ke);
    ke->accept();
}
Esempio n. 20
0
bool Lens::Refraction(Ray *ray, float n2) const {
	// I: incident vector I (normalize), 
	// C: incident circle center
	// Assume after t unit time, the point will arrive the surface,
	// then get equation below:
	// \overrightarrow{OC} + \overrightarrow{I} \times t = \overrightarrow{OP}, and |\overrightarrow{OP}| = \text{radius}
	// |\overrightarrow{OC} + \overrightarrow{I} \times t| = \overrightarrow{OP}
	// |\overrightarrow{I}|^2 t^2 + 2 \overrightarrow{OC} \cdot \overrightarrow{I} t + |\overrightarrow{OC}|^2 - \text{radius}^2 = 0
	// quadratic equation about t.
	Vector I = ray->d;
	Vector oc = ray->o - o;
	float b = I.x * oc.x + I.y * oc.y + I.z * oc.z;
	float c = oc.x * oc.x + oc.y * oc.y + oc.z * oc.z - radius * radius;
	float discrim = b * b - c, t;
	if (discrim <= 0.f)	return false;
	float rootDiscrim = sqrtf(discrim);

	if (radius > 0.f)
		t = -b + rootDiscrim;
	else
		t = -b - rootDiscrim;

	// move hit point to the surface of refraction indices
	ray->o = ray->o + t * I;
	if (outOfRange(ray->o.x, ray->o.y))
		return false;

	Vector N = Normalize(o - ray->o);
	if (radius < 0.f)
		N = -N;
	// Whitted's Method
#ifdef REFRACTION_Whitted
	float eta = n2 / n;
	Vector I2 = I / (- Dot(I, N));
	Vector J = I2 + N;
	float alpha = eta * eta * Dot(I2, I2) - Dot(J, J);
	if (alpha < 0.f)
		return false;
	alpha = 1.f / sqrt(alpha);
	Vector T2 = alpha * J - N;
	ray->d = T2 / T2.Length();
	return true;
#endif
	// Heckbert's Method
#ifdef REFRACTION_Heckbert
	float eta = n / n2;
	float c1 = - Dot(I, N);
	float c2 = 1.f - eta * eta * (1.f - c1 * c1);
	if (c2 < 0.f)
		return false;
	c2 = sqrtf(c2);
	ray->d = eta * I + (eta * c1 - c2) * N;
	return true;
#endif
	// Other Method
#ifdef REFRACTION_Other
	float eta = n2 / n;
	float c1 = - Dot(I, N);
	float beta = eta * eta - 1 + c1 * c1;
	if (beta < 0.f)
		return false;
	beta = c1 - sqrtf(beta);
	ray->d = (I + beta * N) / eta;
	return true;
#endif
}
Esempio n. 21
0
bool arlCore::PlaneSystem::isTagged( unsigned int plane1, unsigned int plane2 ) const
{
    assert(!outOfRange(plane1) && !outOfRange(plane2));
    return isTagged( getIndex(plane1, plane2) );
}
Esempio n. 22
0
// PRIVATE FUNCTIONS
bool arlCore::PlaneSystem::outOfRange( unsigned int plane1, unsigned int plane2 ) const
{   // True if plane 1 or 2 is out of range
    return (outOfRange(plane1) || outOfRange(plane2));
}
Esempio n. 23
0
arlCore::PlaneSystem::ARL_PLANE_STATE arlCore::PlaneSystem::getStatus( unsigned int plane1, unsigned int plane2 ) const
{
    assert(!outOfRange(plane1) && !outOfRange(plane2));
    return getStatus( getIndex(plane1, plane2) );
}