Esempio n. 1
0
void Simplex::lagrangePolynomials(Function::Polynomial<Real>* res,
                                  const std::size_t n,
                                  const std::size_t np,
                                  const std::size_t nsc) const {
    // Computes Sylvester's polynomials.
    std::vector<Function::Polynomial<Real>> pol(n+1);
    for (std::size_t i = 0; i < (n + 1); i++) {
        pol[i] = silvesterPol(i,n);
    }
    // Computes Lagrange's polynomials.
    for (std::size_t i = 0; i < np; i++) {
        for (std::size_t j = 0; j < nsc; j++) {
            if (j == 0) {
                res[i] = pol[nodeIndex(i,j)];
            } else {
                res[i] ^= pol[nodeIndex(i,j)];
            }
        }
    }
}
Esempio n. 2
0
// Mouse interaction.
void qxgeditScale::mousePressEvent ( QMouseEvent *pMouseEvent )
{
	if (pMouseEvent->button() == Qt::LeftButton) {
		const QPoint& pos = pMouseEvent->pos();
		const int iDragNode = nodeIndex(pos);
		if (iDragNode >= 0) {
			setCursor(Qt::SizeAllCursor);
			m_iDragNode = iDragNode;
			m_posDrag = pos;
		}
	}

	QFrame::mousePressEvent(pMouseEvent);
}
Esempio n. 3
0
    FOR_ALL_ITEMS(FaceList, faces){
        Face_p pF = (*it);

        if (!pF->pData || pF->isDeleted())
            continue;

        GridPattern* patch = dynamic_cast<GridPattern*>(pF->pData);
        if (!patch)
            continue;

        int Nu = patch->USamples();;
        int Nv = patch->VSamples();

        for(int j=0; j<(Nv-1); j++){
            for(int i=0; i<(Nu-1); i++){
                //int id[4] = {patch->ind(i,  j), patch->ind(i+1,  j), patch->ind(i+1,  j+1), patch->ind(i,  j+1)};

                int id[4] = {nodeIndex(patch, i,  j), nodeIndex(patch, i+1,  j), nodeIndex(patch, i+1,  j+1), nodeIndex(patch, i,  j+1)};
                int eid = elementPage[fi] + i + j*(Nu-1);                
                outfile<<eid<<", "<<id[0]<<", "<<id[1]<<", "<<id[2]<<", "<<id[3]<<endl;

                int pat = patch->getPattern(i, j);

                if (pat>0){
                    for(int k=0; k<4; k++)
                        foldnodes[pat-1].insert(id[k]);
                }

                pat = (pat<0)?0:pat;
                elements[pat].push_back(eid);
            }
        }

        elementPage[(fi+1)] = elementPage[fi] + (Nu-1)*(Nv-1);
        fi++;
    }
Esempio n. 4
0
PotreeWriterNode *PotreeWriterNode::add(Point &point){
	addCalledSinceLastFlush = true;

	// load grid from disk to memory, if necessary
	if(grid->numAccepted != numAccepted){
		loadFromDisk();
	}

	Vector3<double> position(point.x, point.y, point.z);
	bool accepted = grid->add(position);
	//float minGap = grid->add(Vector3<double>(point.x, point.y, point.z));
	//bool accepted = minGap > spacing;
	//int targetLevel = ceil(log((1/minGap) * spacing) / log(2));
	//
	//if(targetLevel > maxLevel){
	//	return NULL;
	//}

	if(accepted){
		cache.push_back(point);
		Vector3<double> position(point.x, point.y, point.z);
		acceptedAABB.update(position);
		potreeWriter->numAccepted++;
		numAccepted++;

		return this;
	}else if(level < maxLevel){
		// try adding point to higher level

		int childIndex = nodeIndex(aabb, point);
		if(childIndex >= 0){
			PotreeWriterNode *child = children[childIndex];

			// create child node if not existent
			if(child == NULL){
				child = createChild(childIndex);
			}

			return child->add(point);
			//child->add(point, targetLevel);
		} else {
			return NULL;
		}
	}
	return NULL;
}
Esempio n. 5
0
void ArrayGraph::readFrom(const GraphAttributes& GA, const EdgeArray<float>& edgeLength, const NodeArray<float>& nodeSize)
{
    const Graph& G = GA.constGraph();
    NodeArray<__uint32> nodeIndex(G);

    node v;
    m_numNodes = 0;
    m_numEdges = 0;
    m_avgNodeSize = 0;
    m_desiredAvgEdgeLength = 0;
    forall_nodes(v, G)
    {
        m_nodeXPos[m_numNodes] = (float)GA.x(v);
        m_nodeYPos[m_numNodes] = (float)GA.y(v);
        m_nodeSize[m_numNodes] = nodeSize[v];
        nodeIndex[v] = m_numNodes;
        m_avgNodeSize += nodeSize[v];
        m_numNodes++;
    };
  // This minimizes the potential on a series of hyperplanes, all
  // perpendicular to the vector difference of the vacua. It tries to avoid
  // "zig-zag-iness" from Minuit2 coming to rest on a jittery line reasonably
  // far from the starting path by setting the starting point on each plane
  // to be the previous node plus the vector difference of previous node from
  // the node before it, with a special case for the first varying node. It
  // ignores both arguments, and also sets notYetProvidedPath to false.
  TunnelPath const* MinuitOnPotentialOnParallelPlanes::TryToImprovePath(
                                                    TunnelPath const& lastPath,
                                      BubbleProfile const& bubbleFromLastPath )
  {
    SetParallelVector( returnPathNodes.front(),
                       returnPathNodes.back() );

    // A tenth of the Euclidean distance between hyperplanes is used as the
    // initial step size for Minuit, though the step size should be adapted
    // internally as the minimization proceeds.
    SetCurrentMinuitSteps( 0.1 * segmentAuxiliaryLength );
    SetUpHouseholderReflection();

    for( size_t fieldIndex( 0 );
         fieldIndex < numberOfFields;
         ++fieldIndex )
    {
      currentHyperplaneOrigin( fieldIndex )
      = ( returnPathNodes.front()[ fieldIndex ]
          + ( segmentAuxiliaryLength
              * currentParallelComponent( fieldIndex ) ) );
    }
    RunMigradAndPutTransformedResultIn( returnPathNodes[ 1 ] );

    for( size_t nodeIndex( 2 );
         nodeIndex <= numberOfVaryingNodes;
         ++nodeIndex )
    {
      // Each minimization in the next hyperplane starts at points along the
      // straight vector between the vacua at equal intervals.
      for( size_t fieldIndex( 0 );
           fieldIndex < numberOfFields;
           ++fieldIndex )
      {
        currentHyperplaneOrigin( fieldIndex )
        += ( segmentAuxiliaryLength * currentParallelComponent( fieldIndex ) );
      }
      RunMigradAndPutTransformedResultIn( returnPathNodes[ nodeIndex ] );
    }
    return new LinearSplineThroughNodes( returnPathNodes,
                                         nodeZeroParameterization,
                                         pathTemperature );
  }
Esempio n. 7
0
PotreeWriterNode *PotreeWriterNode::add(Point &point, int minLevel){
	if(level > maxLevel){
		return NULL;
	}

	if(level < minLevel){
		// pass forth
		int childIndex = nodeIndex(aabb, point);
		if(childIndex >= 0){
			PotreeWriterNode *child = children[childIndex];

			if(child == NULL && level < maxLevel){
				child = createChild(childIndex);
			}

			return child->add(point, minLevel);
		}
	}else{
		return add(point);
	}
	
	return NULL;
}
Esempio n. 8
0
void qxgeditScale::dragNode ( const QPoint& pos )
{
	unsigned short *piBreak  = NULL;
	unsigned short *piOffset = NULL;
	switch (m_iDragNode) {
	case 1: // Break1/Offset1
		piBreak  = &m_iBreak1;
		piOffset = &m_iOffset1;
		break;
	case 2: // Break2/Offset2
		piBreak  = &m_iBreak2;
		piOffset = &m_iOffset2;
		break;
	case 3: // Break3/Offset3
		piBreak  = &m_iBreak3;
		piOffset = &m_iOffset3;
		break;
	case 4: // Break4/Offset4
		piBreak  = &m_iBreak4;
		piOffset = &m_iOffset4;
		break;
	}

	if (piBreak && piOffset) {
		int iBreak = int(*piBreak)
			+ ((pos.x() - m_posDrag.x()) << 7) / width();
		int iOffset = int(*piOffset)
			+ ((m_posDrag.y() - pos.y()) << 7) / height();
		if (iBreak < 0) iBreak = 0;
		else
		if (iBreak > 127) iBreak = 127;
		if (iOffset < 0) iOffset = 0;
		else
		if (iOffset > 127) iOffset = 127;
		if (*piBreak  != (unsigned short) iBreak ||
			*piOffset != (unsigned short) iOffset) {
			m_posDrag = pos;
			switch (m_iDragNode) {
			case 1: // Break1/Offset1
				setBreak1(iBreak);
				setOffset1(iOffset);
				break;
			case 2: // Break2/Offset2
				setBreak2(iBreak);
				setOffset2(iOffset);
				break;
			case 3: // Break3/Offset3
				setBreak3(iBreak);
				setOffset3(iOffset);
				break;
			case 4: // Break4/Offset4
				setBreak4(iBreak);
				setOffset4(iOffset);
				break;
			}
		}
	} else if (nodeIndex(pos) >= 0) {
		setCursor(Qt::PointingHandCursor);
	} else {
		unsetCursor();
	}
}
 inline F32 sample(const Point2I pos) const
 {
    return mHeights[nodeIndex(pos)];
 }