Пример #1
0
av::gua::Node*
av::gua::VolumeLoader::createChildren(std::shared_ptr< ::gua::node::Node> root) const {

  av::gua::Node* av_node(nullptr);

  auto group_cast(std::dynamic_pointer_cast< ::gua::node::TransformNode>(root));
  if (group_cast) {
    av_node = new av::gua::TransformNode(group_cast);
  }

  if (!av_node) {
    auto geom_cast(std::dynamic_pointer_cast< ::gua::node::VolumeNode>(root));
    if (geom_cast) {
      av_node = new av::gua::VolumeNode(geom_cast);
    }
  }

  if (av_node) {
    av_node->addToParentChildren();
  } else {
    std::cout << "Unexpected node type encountered while loading geometry!" << std::endl;
  }

  for (auto c : root->get_children()) {
    createChildren(c);
  }

  return av_node;
}
Пример #2
0
void Replicator::update(float value)
{
	//logFile << getFrequentcyRange() << " :\t " << value << "\n";
	Ogre::Vector3 currentScale = getScale();
	this->setThreshold(0.7*this->getThreshold() + 0.4*value);

	float result = value / this->getThreshold();
	int numOfChildrenToGenerate = result > 1.0 ? (result - value) * 2 : 0;
	//logFile  << value / this->getThreashold() << "\t" << (result - value) * 10 << "\t" << numOfChildrenToGenerate << "\n";
	for ( int i = 0; i < numOfChildrenToGenerate; i++ ) {
		createChildren(numOfChildrenToGenerate);
	}

	for(std::vector<Ogre::Entity*>::size_type i = 0; i < children.size(); ) {
		Ogre::SceneNode* childNode = children[i]->getParentSceneNode();
		Ogre::Real res = childNode->getScale().length();
		if ( res < 0.1 ) {
			children[i]->setVisible(false);
			childNode->setVisible(false);
			childNode->detachObject(children[i]->getName());
			_sceneManager->destroyEntity(children[i]->getName());
			// entity is now destroyed, don't try to use the pointer anymore!
			// optionally destroy node
			_sceneManager->destroySceneNode(childNode->getName());
			 children.erase( children.begin() + i );
		} else {
			Ogre::Vector3 currScale = childNode->getScale();
			childNode->setScale(Ogre::Vector3(currScale.x - currScale.x/3, currScale.y - currScale.y/3, currScale.z - currScale.z/3));
			i++;
		}
	}
}
int main (int argc, char * argv[])
{
    createChildren();
    /*
     if (argc != 1)
     {
     fprintf (stderr, "%s: invalid arguments\n", argv[0]);
     }
     
     
     //EXTRA
     printf("argc = :, %d, *argv[] = %s \n", argc, *argv);
     
     output_init ();
     
     
     // TODO:
     //  * create the message queues & the children
     createMessageQueuesAndChildren();
     
     //  * do the farming (use output_draw_pixel() for the coloring
     farm();
     //  * wait until the chilren have been stopped
     
     //  * clean up the message queues
     cleanMessageQueues();
     // Important notice: make sure that your message queues contain your
     // student name and the process id (to ensure uniqueness during testing)
     
     output_end();
     */
    return (0);
}
Пример #4
0
void sLinsysRoot::sync()
{
  //delete children
  deleteChildren();
  //assert(false);

  //delete local stuff
  if( nxupp + nxlow > 0 ) {
    delete dd; 
    delete dq; 
  }
  delete nomegaInv;
  delete rhs;
  if (solver) delete solver;
  if (kkt)    delete kkt;


  //allocate
//  if( nxupp + nxlow > 0 ) {
    //dd      = OoqpVectorHandle(stochNode->newPrimalVector());
    //dq      = OoqpVectorHandle(stochNode->newPrimalVector());
    dd = stochNode->newPrimalVector();
    dq = stochNode->newPrimalVector();
    data->getDiagonalOfQ( *dq );
//  }
  nomegaInv   = stochNode->newDualZVector();
  rhs         = stochNode->newRhs();


  data->getLocalSizes(locnx, locmy, locmz);
  createChildren(data);

  kkt = createKKT(data);
  solver = createSolver(data, kkt);
}
balazs::WeighedTree::WeighedTree(const std::vector<long double>& definingList) :
    m_definingList(definingList)
{
    m_root = new Node;
    createChildren(definingList.begin(), definingList.end(), m_root);
    m_numEdges = m_root->numDescendants();
}
Пример #6
0
sLinsysRoot::sLinsysRoot(sFactory* factory_,
			 sData* prob_,
			 OoqpVector* dd_, 
			 OoqpVector* dq_,
			 OoqpVector* nomegaInv_,
			 OoqpVector* rhs_,
			 OoqpVector* additiveDiag_, bool createChild)
  : sLinsys(factory_, prob_, dd_, dq_, nomegaInv_, rhs_, additiveDiag_), iAmDistrib(0)
{
  if( createChild ) 
	createChildren(prob_);

  if(gOuterSolve) {
      sol2 = res2 = res3 = res4 = res5 = NULL;  	
      // stuff for iterative refimenent and BiCG 
      sol  = factory_->tree->newRhs();
      res  = factory_->tree->newRhs();
      resx = factory_->tree->newPrimalVector();
      resy = factory_->tree->newDualYVector();
      resz = factory_->tree->newDualZVector();
    if(gOuterSolve==2) {
      //BiCGStab; additional vectors needed
      sol2 = factory_->tree->newRhs();
      res2 = factory_->tree->newRhs();
      res3 = factory_->tree->newRhs();
      res4 = factory_->tree->newRhs();
      res5 = factory_->tree->newRhs();
    } 
  } else {
      sol  = res  = resx = resy = resz = NULL;
      sol2 = res2 = res3 = res4 = res5 = NULL;
  }
  firstBUpdate = true; 
  firstQUpdate = true;
}
QpGenStochLinsysRootAugRedPrecond::
QpGenStochLinsysRootAugRedPrecond(QpGenStoch* factory_,
                                  QpGenStochData* prob,
                                  OoqpVector* dd_,
                                  OoqpVector* dq_,
                                  OoqpVector* nomegaInv_,
                                  OoqpVector* rhs_)
    : QpGenStochLinsysRootAugRed(),
      Pmult(NULL), Amult(NULL), tmpVec1(NULL)
{
    //QpGenStochLinsy
    factory = factory_;

    nx = prob->nx;
    my = prob->my;
    mz = prob->mz;
    ixlow = prob->ixlow;
    ixupp = prob->ixupp;
    iclow = prob->iclow;
    icupp = prob->icupp;

    nxlow = prob->nxlow;
    nxupp = prob->nxupp;
    mclow = prob->mclow;
    mcupp = prob->mcupp;

    if( nxupp + nxlow > 0 ) {
        //dd      = OoqpVectorHandle(dd_);
        dd= dd_;
        //dq      = OoqpVectorHandle(dq_);
        dq = dq_;
    }
    //nomegaInv   = OoqpVectorHandle(nomegaInv_);
    //rhs         = OoqpVectorHandle(rhs_);
    nomegaInv = nomegaInv_;
    rhs = rhs_;

    useRefs=1;
    data = prob;
    stochNode = prob->stochNode;

    //QpGenStochLinsysRoot
    iAmDistrib = 0;

    //QpGenStochLinsyRootAug
    prob->getLocalSizes(locnx, locmy, locmz);
    UtV = NULL;

    //QpGenStochLinsyRootAug
    CtDC=NULL;
    redRhs = new SimpleVector(locnx+locmy+locmz);
    kkt = createKKT(prob);
    solver = createSolver(prob, kkt);

    //intializations related to this class
    me = whoAmI();
    createChildren(prob);
};
Пример #8
0
void Node::buildTree()
{
    calcGenerators();
    createChildren();  
    if(children.empty()){
        incrementBranches();
        modifyLevel(level);
    }else{
        std::for_each(children.begin(), children.end(), step);
    }
}
QpGenStochLinsysRootAugRedPrecond::
QpGenStochLinsysRootAugRedPrecond(QpGenStoch * factory_,
                                  QpGenStochData * prob)
    : QpGenStochLinsysRootAugRed(),
      Pmult(NULL), Amult(NULL), tmpVec1(NULL)
{
    factory = factory_;
    kkt = NULL;
    solver = NULL;

    nx = prob->nx;
    my = prob->my;
    mz = prob->mz;
    ixlow = prob->ixlow;
    ixupp = prob->ixupp;
    iclow = prob->iclow;
    icupp = prob->icupp;

    nxlow = prob->nxlow;
    nxupp = prob->nxupp;
    mclow = prob->mclow;
    mcupp = prob->mcupp;

    if( nxupp + nxlow > 0 ) {
        dd      = factory_->tree->newPrimalVector();
        dq      = factory_->tree->newPrimalVector();
        prob->getDiagonalOfQ( *dq );
    }
    nomegaInv   = factory_->tree->newDualZVector();
    rhs         = factory_->tree->newRhs();

    useRefs=0;
    data = prob;
    stochNode = prob->stochNode;

    //QpGenStochLinsysRoot
    iAmDistrib = 0;

    //QpGenStochLinsyRootAug
    prob->getLocalSizes(locnx, locmy, locmz);
    UtV = NULL;

    //QpGenStochLinsyRootAug
    CtDC=NULL;
    kkt = createKKT(prob);
    solver = createSolver(prob, kkt);

    //QpGenStochLinsyRootAugRed
    redRhs = new SimpleVector(locnx+locmy+locmz);

    //intializations related to this class
    me = whoAmI();
    createChildren(prob);
};
Пример #10
0
void MainWindow::on_actionStart_triggered()
{
    if (mStarted) {
        return;
    }
    StartDialog d(this);
    if (d.exec() == QDialog::Rejected) {
        return;
    }
    mStarted = true;
    createChildren(d.vectorOfProgresses());
    packChildren();
}
Пример #11
0
void QgsDataItem::populate()
{
  if ( mPopulated )
    return;

  QgsDebugMsg( "mPath = " + mPath );

  QVector<QgsDataItem*> children = createChildren();
  foreach ( QgsDataItem *child, children )
  {
    // initialization, do not refresh! That would result in infinite loop (beginInsertItems->rowCount->populate)
    addChildItem( child );
  }
Пример #12
0
sLinsysRoot::sLinsysRoot(sFactory * factory_, sData * prob_, bool createChild)
  : sLinsys(factory_, prob_), iAmDistrib(0)
{
  assert(dd!=NULL);
  if( createChild ) 
  	createChildren(prob_);

  sol2Bicg = res2Bicg = res3Bicg = res4Bicg = res5Bicg = NULL;
  sol2 = res2 = res3 = res4 = res5 = NULL;

  if(gOuterSolve<3) { 
    // stuff for iterative refimenent and BiCG
    sol  = factory_->tree->newRhs();
    res  = factory_->tree->newRhs();
    resx = factory_->tree->newPrimalVector();
    resy = factory_->tree->newDualYVector();
    resz = factory_->tree->newDualZVector();
    if(gOuterSolve==2) {
      //BiCGStab for compressed; additional vectors needed
      sol2 = factory_->tree->newRhs();
      res2 = factory_->tree->newRhs();
      res3 = factory_->tree->newRhs();
      res4 = factory_->tree->newRhs();
      res5 = factory_->tree->newRhs();
    }
  }else if(gOuterSolve>=3) {
	sol  = factory_->tree->newRhsXSYZ();
	res  = factory_->tree->newRhsXSYZ();
	resx = factory_->tree->newPrimalVector();
	ress = factory_->tree->newDualZVector();
	resy = factory_->tree->newDualYVector();
	resz = factory_->tree->newDualZVector();
    if(gDoIR_Aug ==1 || gUsePetscOuter!=0){
	  sol2 = factory_->tree->newRhsXSYZ();
	  res2 = factory_->tree->newRhsXSYZ();
	  res3 = res4 = res5 = NULL;
    }
    if(gOuterSolve>=4) {
      //BiCGStab; additional vectors needed
      sol2Bicg  = factory_->tree->newRhsXSYZ();
      res2Bicg  = factory_->tree->newRhsXSYZ();
      res3Bicg  = factory_->tree->newRhsXSYZ();
      res4Bicg  = factory_->tree->newRhsXSYZ();
      res5Bicg  = factory_->tree->newRhsXSYZ();
    }	
  }else {
    sol  = res  = resx = resy = resz = NULL;
  }
  firstBUpdate = true; 
  firstQUpdate = true;
}
Пример #13
0
void QgsCptCityDataItem::populate()
{
  if ( mPopulated )
    return;

  QgsDebugMsg( "mPath = " + mPath );

  QApplication::setOverrideCursor( Qt::WaitCursor );

  QVector<QgsCptCityDataItem *> children = createChildren();
  Q_FOREACH ( QgsCptCityDataItem *child, children )
  {
    // initialization, do not refresh! That would result in infinite loop (beginInsertItems->rowCount->populate)
    addChildItem( child );
  }
MWidgetController *MSettingsLanguageSettingsFactory::createWidget(const MSettingsLanguageSettings &settingsItem, MSettingsLanguageWidget &rootWidget, MDataStore *dataStore)
{
    // Create content layout to layout content items in
    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
    layout->setContentsMargins(0, 0, 0, 0);
    layout->setSpacing(0);

    MStylableWidget *widget = new MStylableWidget;
    widget->setStyleName("MSettingsLanguage");
    widget->setLayout(layout);

    createChildren(layout, settingsItem, rootWidget, dataStore);
    layout->addStretch();

    return widget;
}
Пример #15
0
// Reimplemented 
void QmvItem::setOpen( bool b )
{
    
        // State consistent already
    if ( b == open )
	return;
    open = b;

        // Add the children
    if ( open ) {
        createChildren();
        initChildren();
    } else {
        deleteChildren();
    }
    
    qApp->processEvents();
    listview->updateEditorSize();
}
Пример #16
0
sResiduals::sResiduals( sTree* tree, 
			OoqpVector * rQ_,    OoqpVector * rA_, 
			OoqpVector * rC_,    OoqpVector * rz_, 
			OoqpVector * rt_,    OoqpVector * rlambda_, 
			OoqpVector * ru_,    OoqpVector * rpi_, 
			OoqpVector * rv_,    OoqpVector * rgamma_, 
			OoqpVector * rw_,    OoqpVector * rphi_, 
			OoqpVector * ixlow_, double nxlowGlobal,
			OoqpVector * ixupp_, double nxuppGlobal,
			OoqpVector * iclow_, double mclowGlobal, 
			OoqpVector * icupp_, double mcuppGlobal)
  :NlpGenResiduals()
{
  assert(false);
  SpReferTo( ixlow, ixlow_ );
  nxlow = nxlowGlobal;

  SpReferTo( ixupp, ixupp_ );
  nxupp = nxuppGlobal;

  SpReferTo( iclow, iclow_ );
  mclow = mclowGlobal;

  SpReferTo( icupp, icupp_ );
  mcupp = mcuppGlobal;

  SpReferTo( rQ, rQ_ );
  SpReferTo( rA, rA_ );
  SpReferTo( rC, rC_ );
  SpReferTo( rz, rz_ );
  SpReferTo( rt     , rt_ );
  SpReferTo( rlambda, rlambda_ );
  SpReferTo( ru    , ru_ );
  SpReferTo( rpi   , rpi_ );
  SpReferTo( rv    , rpi_ );
  SpReferTo( rgamma, rgamma_ );
  SpReferTo( rw  , rw_ );
  SpReferTo( rphi, rphi_ );

  stochNode = tree;
  createChildren();
}
Пример #17
0
void QgsMssqlConnectionItem::refresh()
{
  QgsDebugMsg( "mPath = " + mPath );

  // read up the schemas and layers from database
  QVector<QgsDataItem*> items = createChildren();

  // Add new items
  foreach ( QgsDataItem *item, items )
  {
    // Is it present in childs?
    int index = findItem( mChildren, item );
    if ( index >= 0 )
    {
      (( QgsMssqlSchemaItem* )mChildren[index] )->addLayers( item );
      delete item;
      continue;
    }
    addChildItem( item, true );
  }
Пример #18
0
void QgsDb2ConnectionItem::refresh()
{
  QgsDebugMsg( "db2 mPath = " + mPath );

  // read up the schemas and layers from database
  QVector<QgsDataItem *> items = createChildren();

  // Add new items
  Q_FOREACH ( QgsDataItem *item, items )
  {
    // Is it present in children?
    int index = findItem( mChildren, item );
    if ( index >= 0 )
    {
      ( ( QgsDb2SchemaItem * )mChildren.at( index ) )->addLayers( item );
      delete item;
      continue;
    }
    addChildItem( item, true );
  }
Пример #19
0
void KdTreeNode::computeChildren()
{
    int axis = depth % 3;

    if (terminate()) { // the node is a leaf
        return;
    }

    float limit;
    if (! findBestSplit(axis, &limit)) return;
    createChildren(axis, limit);
    splitObjects(axis, &objects, &(left->objects), &(right->objects));
    objects.clear(); // only leaves keep their objects

#pragma omp task
    left->computeChildren();

#pragma omp task
    right->computeChildren();

#pragma omp taskwait

}
Пример #20
0
/******************************************************************************
	Function evolutionStep - controls one evolution step, is called for each
		generation, manages the deffirences between CGP and coevolution
	Takes parameters:
		@input - pointer to an array of all training vectors
		@geneticP - pointer to a struct of all CGP params
		@geneticArray - pointer to a vector of whole population
		@functions - pointer to an array of available functions
		@test - pointer to the test - in variant without coevolution is NULL
******************************************************************************/
void evolutionStep(TData* input, TCgpProperties* geneticP, vector<TIndividual>* geneticArray, TFuncAvailable* functions, TTest* test){

#ifdef COEVOLUTION
	//copy test vector from shared memory
	TCoevIndividual* testVect = NULL;
	testVect = (TCoevIndividual*)malloc(sizeof(struct test));
	pthread_mutex_lock(&test->test_sem);
	testVect->value = new vector<int>(*test->test.value);
	pthread_mutex_unlock(&test->test_sem);
#endif

	getActiveNodes(geneticArray, geneticP);
 
 	for(int ind = 0; ind < geneticP->individCount; ind++){
 		resetFitness(&geneticArray->at(ind));
#ifdef COEVOLUTION
 		for(int i = 0; i < geneticP->testSize; i++){
 			getValue(&geneticArray->at(ind), geneticP, input->data[testVect->value->at(i)]);
			getFitness(&geneticArray->at(ind), geneticP, input->data[testVect->value->at(i)]);			
 		}//for all tests
#else
		for(int i = 0; i < input->dataCount; i++){
			getValue(&geneticArray->at(ind), geneticP, input->data[i]);
			getFitness(&geneticArray->at(ind), geneticP, input->data[i]);
		}//for all inputs	
#endif
 	}//for all individuals

 #ifdef COEVOLUTION
 	//tidy up the test vector
 	delete(testVect->value);
 	free(testVect);
 #endif

	getParents(geneticArray, geneticP);
	createChildren(geneticArray, geneticP, functions);
}
void balazs::WeighedTree::createChildren(std::vector<long double>::const_iterator itBegin,
                                 std::vector<long double>::const_iterator itEnd,
                                 Node* pNode){
    std::vector<long double>::const_iterator it = itBegin;
    while (it != itEnd && *it != 0) {
        if (*it < 0) {
            throw std::runtime_error("Weights of weighed trees must be positive.");
        }
        it++;
    }
    if (pNode->m_parent == NULL && (it - itBegin == 0 || it - itBegin == 2)) {
        throw std::runtime_error("The root of a weighed tree must have 1 or at least 3 neighbors.)");
    }

    if (it != itBegin) {
        pNode->m_numChildren = static_cast<int>(it - itBegin);
        if (pNode->m_parent != NULL && pNode->m_numChildren == 1) {
            throw std::runtime_error("Vertices of degree 2 are not allowed in weighed trees.");
        }
        
        
        pNode->m_children = new Node[pNode->m_numChildren];
        for (std::size_t i = 0; i < pNode->m_numChildren; i++) {
            pNode->m_children[i].m_parent = pNode;
            pNode->m_children[i].m_weight = itBegin[i];
        }
    }
    
    if (++it < itEnd) {
        pNode = nextNode(pNode);
        if (pNode->isRoot()) {
            throw std::runtime_error("Too many arguments provided for the definition of a weighed tree.");
        } else
            createChildren(it, itEnd, pNode);
    }
}
Пример #22
0
ButtonEditor::ButtonEditor (GuiObject parent)
    : HyperPage (parent, L"Buttons", NULL) {
    createMenus ();
    createChildren ();
    which (1);
}
Пример #23
0
ReferenceTreeNode::ReferenceTreeNode(const ZLTextTreeParagraph& paragraph): myParagraph(paragraph) {
	createChildren();
}
void createMessageQueuesAndChildren(){
    //TODO implement functions
    createMessageQueues();
    createChildren();
}
Пример #25
0
StringsEditor::StringsEditor (GuiObject parent, const wchar_t *title, Any data)
	: Editor (parent, 20, 40, 600, 600, title, data) {
	createMenus ();
	createChildren ();
	updateList ();
}
Пример #26
0
/**
 * Local greedy surface area heuristic
 *
 * TODO : The accurate way of determining the candidate planes thus is
 * to first clip the triangle t to the voxel V , and use the sides of
 * the clipped triangle’s AABB B(t ∩ V )
 */
bool KdTreeNode::findBestSplit(int axis, float* bestSplit)
{
    float cost, bestCost = FLT_MAX;
    std::list<float> limits;

    std::list<Object*>::iterator iterObj;
    AABB * aabb;

    for (iterObj = objects.begin(); iterObj != objects.end(); iterObj++)
    {
        aabb = (*iterObj)->getAABB();

        if (axis == 0) {        // X
            limits.push_back(aabb->minX);
            limits.push_back(aabb->maxX);
        } else if (axis == 1) { // Y
            limits.push_back(aabb->minY);
            limits.push_back(aabb->maxY);
        } else {                // Z
            limits.push_back(aabb->minZ);
            limits.push_back(aabb->maxZ);
        }
    }

    limits.sort();
    limits.unique();

    float thisMin, thisMax;

    if (axis == 0) {        // X
        thisMin = this->aabb->minX;
        thisMax = this->aabb->maxX;
    } else if (axis == 1) { // Y
        thisMin = this->aabb->minY;
        thisMax = this->aabb->maxY;
    } else {                // Z
        thisMin = this->aabb->minZ;
        thisMax = this->aabb->maxZ;
    }

    //Logger::log(LOG_DEBUG)<<"limit list size = "<<limits.size()<<std::endl;

    std::list<Object*> objectsNode;
    std::list<Object*> objectsLeft;
    std::list<Object*> objectsRight;

    objectsNode.assign(objects.begin(), objects.end());

    bool splitFound = false;

    std::list<float>::iterator iterLimit;

    for (iterLimit = limits.begin(); iterLimit != limits.end(); iterLimit++)
    {
        if (thisMin < *iterLimit && *iterLimit < thisMax) {
            splitFound = true;

            //Logger::log(LOG_DEBUG)<<"----------------------------"<<std::endl;
            //Logger::log(LOG_DEBUG)<<"limit candidate = "<<*iterLimit<<std::endl;

            createChildren(axis, *iterLimit);
            splitObjects(axis, &objectsNode, &objectsLeft, &objectsRight);
            cost = computeCost(&objectsLeft, &objectsRight);
            
            //Logger::log(LOG_DEBUG)<<"cost = "<<cost<<std::endl;
            if (cost < bestCost) {
                bestCost = cost;
                *bestSplit = *iterLimit;
            }
            //Logger::log(LOG_DEBUG)<<"best cost = "<<bestCost<<std::endl;
/*
            objectsNode.clear();
            objectsNode.splice(objectsNode.begin(), objectsRight);                          
*/
            objectsLeft.clear();
            objectsRight.clear();

            if (left != NULL) delete left;
            if (right != NULL) delete right;
        }
    }

    //Logger::log(LOG_DEBUG)<<"bestSplit = "<<*bestSplit<<std::endl;

    return splitFound;
}