void C3DSkinlessModel::draw()
{
    unsigned int partCount = _mesh->getPartCount();
    bool bStatEnable = C3DStat::getInstance()->isStatEnable();
    
    C3DMaterial::TechniqueUsage techUsage = 
        getNode()->getScene()->isInShadowPass() ? C3DMaterial::TECH_USAGE_SHADOWMAP : C3DMaterial::TECH_USAGE_SCREEN;

    if (partCount == 0)
    {
        // No mesh parts (index buffers).
        if (_material)
        {
            C3DTechnique* technique = _material->getTechnique(techUsage);
            
            if (!technique)
                return;
            
            unsigned int passCount = technique->getPassCount();
            if (bStatEnable)
                C3DStat::getInstance()->incDrawCall(passCount);
            
            for (unsigned int i = 0; i < passCount; ++i)
            {
                if (bStatEnable)
                    C3DStat::getInstance()->incTriangleDraw(_mesh->getTriangleCount());
                
                C3DPass* pass = technique->getPass(i);
                //applyLightParam(pass);
				applyInternalParam(pass);
                pass->bind();
                GL_ASSERT( glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0) );               
                
                GL_ASSERT( glDrawArrays(_mesh->getPrimitiveType(), 0, _mesh->getVertexCount()) );
                
                pass->unbind();
            }
        }
    }
    else
    {
        for (unsigned int i = 0; i < partCount; ++i)
        {
            MeshPart* meshPart = _mesh->getPart(i);

            // Get the material for this mesh part.
            C3DMaterial* material = getMaterial(i);

            if (material)
            {
                C3DTechnique* technique = _material->getTechnique(techUsage);
                
                if (!technique)
                    continue;
                unsigned int passCount = technique->getPassCount();
                
                if (bStatEnable)
                    C3DStat::getInstance()->incDrawCall(passCount);
                
                for (unsigned int j = 0; j < passCount; ++j)
                {
                    if (bStatEnable)
                        C3DStat::getInstance()->incTriangleDraw(meshPart->getTriangleCount());
                    
                    C3DPass* pass = technique->getPass(j);
					applyInternalParam(pass);
                    //applyLightParam(pass);
                    //applyShadowMap(pass);

                    pass->bind();
                    GL_ASSERT( glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, meshPart->_indexBuffer) );                    
                    
                    GL_ASSERT( glDrawElements(meshPart->getPrimitiveType(), meshPart->getIndexCount(), meshPart->getIndexFormat(), 0) );
                    
                    pass->unbind();
                }
            }
        }
    }
}
Esempio n. 2
0
static boolean uniqueNodesConnect(Node * startingNode)
{
	Node *destination = NULL;
	PassageMarkerI startMarker, currentMarker;
	RBConnection *newList;
	RBConnection *list = NULL;
	boolean multipleHits = false;

	if (arcCount(startingNode) == 0)
		return false;

	if (getMarker(startingNode) == NULL_IDX)
		return false;

	dbgCounter++;

	// Checking for multiple destinations
	for (startMarker = getMarker(startingNode); startMarker != NULL_IDX;
	     startMarker = getNextInNode(startMarker)) {
		if (getFinishOffset(startMarker) >
		    2 * getWordLength(graph))
			continue;

		for (currentMarker = getNextInSequence(startMarker);
		     currentMarker != NULL_IDX;
		     currentMarker = getNextInSequence(currentMarker)) {
			if (!getUniqueness(getNode(currentMarker))) {
				continue;
			} else if (getNodeStatus(getNode(currentMarker))) {
				if (getStartOffset(currentMarker) >
				    2 * getWordLength(graph))
					break;
				for (newList = list; newList != NULL;
				     newList = newList->next) {
					if (newList->node ==
					    getNode(currentMarker)) {
						newList->multiplicity++;
						break;
					}
				}
				if (newList == NULL)
					abort();
				break;
			} else {
				if (getStartOffset(currentMarker) >
				    2 * getWordLength(graph))
					break;
				setSingleNodeStatus(getNode(currentMarker),
						    true);
				newList = allocateRBConnection();
				newList->node = getNode(currentMarker);
				newList->multiplicity = 1;
				newList->marker = startMarker;
				newList->next = list;
				list = newList;
				break;
			}
		}
	}

	while (list != NULL) {
		newList = list;
		list = newList->next;
		setSingleNodeStatus(newList->node, false);
		if (newList->multiplicity >= MULTIPLICITY_CUTOFF) {
			if (destination == NULL) {
				destination = newList->node;
				path = newList->marker;
			} else if (destination != newList->node)
				multipleHits = true;
		}
		deallocateRBConnection(newList);
	}

	if (multipleHits) {
		multCounter++;
		setUniqueness(startingNode, false);
		return false;
	}

	if (destination == NULL || destination == startingNode
	    || destination == getTwinNode(startingNode)) {
		nullCounter++;
		return false;
	}
	// Check for reciprocity
	for (startMarker = getMarker(getTwinNode(destination));
	     startMarker != NULL_IDX;
	     startMarker = getNextInNode(startMarker)) {
		if (getFinishOffset(startMarker) >
		    2 * getWordLength(graph))
			continue;

		for (currentMarker = getNextInSequence(startMarker);
		     currentMarker != NULL_IDX;
		     currentMarker = getNextInSequence(currentMarker)) {
			if (!getUniqueness(getNode(currentMarker))) {
				continue;
			} else if (getNodeStatus(getNode(currentMarker))) {
				if (getStartOffset(currentMarker) >
				    2 * getWordLength(graph))
					break;
				for (newList = list; newList != NULL;
				     newList = newList->next) {
					if (newList->node ==
					    getNode(currentMarker)) {
						newList->multiplicity++;
						break;
					}
				}
				if (newList == NULL)
					abort();
				break;
			} else {
				if (getStartOffset(currentMarker) >
				    2 * getWordLength(graph))
					break;
				setSingleNodeStatus(getNode(currentMarker),
						    true);
				newList = allocateRBConnection();
				newList->node = getNode(currentMarker);
				newList->multiplicity = 1;
				newList->next = list;
				list = newList;
				break;
			}
		}
	}

	while (list != NULL) {
		newList = list;
		list = newList->next;
		setSingleNodeStatus(newList->node, false);
		if (newList->multiplicity >= MULTIPLICITY_CUTOFF
		    && newList->node != getTwinNode(startingNode))
			multipleHits = true;
		deallocateRBConnection(newList);
	}

	if (multipleHits) {
		multCounter++;
		setUniqueness(destination, false);
		return false;
	}
	// Aligning long reads to each other:
	// TODO 

	// Merge pairwise alignments and produce consensus
	// TODO

	return true;
}
Esempio n. 3
0
static Node *bypass()
{
	Node *bypass = getNode(path);
	Node *next = NULL;
	Arc *arc;
	PassageMarkerI nextMarker;

	// Remove unwanted arcs
	while (getArc(bypass) != NULL)
		destroyArc(getArc(bypass), graph);

	// Update extensive variables (length + descriptors + passage markers)
	while (!isTerminal(path)) {
		nextMarker = getNextInSequence(path);
		next = getNode(nextMarker);
		while (next == bypass) {
			disconnectNextPassageMarker(path, graph);
			destroyPassageMarker(nextMarker);
			nextMarker = getNextInSequence(path);
			next = getNode(nextMarker);
		}

		if (next == NULL)
			return bypass;

		// Overall node update 
		if (!getUniqueness(next)) {
			adjustShortReads(bypass, getNextInSequence(path));
			appendSequence(bypass, sequences,
				       getNextInSequence(path), graph);
		} else {
			concatenateReadStarts(bypass, next, graph);

#ifndef SINGLE_COV_CAT
			Category cat;
			for (cat = 0; cat < CATEGORIES; cat++) {
				// Update virtual coverage
				incrementVirtualCoverage(bypass, cat,
							 getVirtualCoverage(next, cat));
				// Update original virtual coverage
				incrementOriginalVirtualCoverage(bypass, cat,
								 getOriginalVirtualCoverage(next, cat));
			}
#else
			incrementVirtualCoverage(bypass, getVirtualCoverage(next));
#endif
			appendDescriptors(bypass, next);
		}

		// Members
		updateMembers(bypass, next);

		// Termination 
		if (isTerminal(path) || getUniqueness(next))
			break;
	}

	// Remove unique groupies from arrival 
	admitGroupies(next, bypass);

	// Copy destination arcs
	for (arc = getArc(next); arc != NULL; arc = getNextArc(arc)) {
		if (getDestination(arc) == next)
			continue;
		else if (getDestination(arc) == getTwinNode(next))
			createAnalogousArc(bypass, getTwinNode(bypass),
					   arc, graph);
		else
			createAnalogousArc(bypass, getDestination(arc),
					   arc, graph);
	}

	destroyNode(next, graph);

	return bypass;
}
Esempio n. 4
0
Rooted<Node> ResourceManager::getNode(Manager &mgr, const Resource &resource)
{
	return getNode(mgr, getSourceId(resource));
}
Esempio n. 5
0
ManagedVector<Node> ResourceManager::parse(
    ParserContext &ctx, const std::string &path, const std::string &mimetype,
    const std::string &rel, const RttiSet &supportedTypes, ParseMode mode)
{
	// Some references used for convenience
	Registry &registry = ctx.getRegistry();
	Logger &logger = ctx.getLogger();
	ParserScope &scope = ctx.getScope();
	Resource relativeTo = getResource(ctx.getSourceId());

	// Locate the resource relative to the old resource, abort if this did not
	// work
	ResourceRequest req{path, mimetype, rel, supportedTypes, relativeTo};
	Resource resource;
	if (!req.deduce(registry, logger) ||
	    !req.locate(registry, logger, resource)) {
		return ManagedVector<Node>{};
	}

	// initialize the output vector.
	ManagedVector<Node> parsedNodes;

	// Allocate a new SourceId handle for this Resource
	bool newResource = false;
	SourceId sourceId = getSourceId(resource);
	if (sourceId == InvalidSourceId) {
		newResource = true;
		sourceId = allocateSourceId(resource);
	}
	// check for cycles.
	GuardedSetInsertion<SourceId> cycleDetection{currentlyParsing, sourceId};
	if (!cycleDetection.isSuccess()) {
		throw LoggableException{std::string("Detected cyclic parse of ") +
		                        resource.getLocation()};
	}

	if (!newResource && mode == ParseMode::IMPORT) {
		// if a already imported resource should be imported we just use the
		// cached node.
		parsedNodes.push_back(getNode(ctx.getManager(), sourceId));
	} else {
		// We can now try to parse the given file

		// Set the current source id in the logger instance. Note that this
		// modifies the logger instance -- the GuardedLogger is just used to
		// make sure the default location is popped from the stack again.
		GuardedLogger guardedLogger(logger, SourceLocation{sourceId});

		try {
			// Fetch the input stream and create a char reader
			std::unique_ptr<std::istream> is = resource.stream();
			CharReader reader(*is, sourceId);

			// Actually parse the input stream, distinguish the IMPORT and the
			// INCLUDE mode
			switch (mode) {
				case ParseMode::IMPORT: {
					// Create a new, empty parser scope instance and a new
					// parser
					// context with this instance in place
					ParserScope innerScope;
					ParserContext childCtx = ctx.clone(innerScope, sourceId);

					// Run the parser
					req.getParser()->parse(reader, childCtx);

					// Make sure the scope has been unwound and perform all
					// deferred resolutions
					innerScope.checkUnwound(logger);
					innerScope.performDeferredResolution(logger);

					// Fetch the nodes that were parsed by this parser instance
					// and
					// validate them
					parsedNodes = innerScope.getTopLevelNodes();
					for (auto parsedNode : parsedNodes) {
						parsedNode->validate(logger);
					}

					// Make sure the number of elements is exactly one -- we can
					// only store one element per top-level node.
					if (parsedNodes.empty()) {
						throw LoggableException{"Module is empty."};
					}
					if (parsedNodes.size() > 1) {
						throw LoggableException{
						    std::string(
						        "Expected exactly one top-level node but "
						        "got ") +
						    std::to_string(parsedNodes.size())};
					}

					// Store the parsed node along with the sourceId
					storeNode(sourceId, parsedNodes[0]);

					break;
				}
				case ParseMode::INCLUDE: {
					// Fork the scope instance and create a new parser context
					// with this instance in place
					ParserScope forkedScope = scope.fork();
					ParserContext childCtx = ctx.clone(forkedScope, sourceId);

					// Run the parser
					req.getParser()->parse(reader, childCtx);

					// Join the forked scope with the outer scope
					scope.join(forkedScope, logger);

					// Fetch the nodes that were parsed by this parser instance
					parsedNodes = forkedScope.getTopLevelNodes();

					break;
				}
			}
		}
		catch (LoggableException ex) {
			// Log the exception and return nullptr
			logger.log(ex);
			return ManagedVector<Node>{};
		}
	}

	// Make sure the parsed nodes fulfill the "supportedTypes" constraint,
	// remove nodes that do not the result
	for (auto it = parsedNodes.begin(); it != parsedNodes.end();) {
		const Rtti *type = (*it)->type();
		if (!type->isOneOf(supportedTypes)) {
			logger.error(std::string("Node of internal type ") + type->name +
			                 std::string(" not supported here"),
			             **it);
			it = parsedNodes.erase(it);
		} else {
			it++;
		}
	}

	return parsedNodes;
}
Esempio n. 6
0
	void Model::removeNode(const std::string &name)
	{
		Node *node = getNode(name);
		if (node)
			delete node;
	}
Esempio n. 7
0
Rooted<Node> ResourceManager::getNode(Manager &mgr, const std::string &location)
{
	return getNode(mgr, getSourceId(location));
}
Esempio n. 8
0
/** Sets all start positions depending on the quad graph. The number of
 *  entries needed is defined by the size of the start_transform (though all
 *  entries will be overwritten).
 *  E.g. the karts will be placed as:
 *   1           \
 *     2          +--  row with three karts, each kart is 'sidewards_distance'
 *       3       /     to the right of the previous kart, and
 *   4                 'forwards_distance' behind the previous kart.
 *     5               The next row starts again with the kart being
 *       6             'forwards_distance' behind the end of the previous row.
 *  etc.
 *  \param start_transforms A vector sized to the needed number of start
 *               positions. The values will all be overwritten with the
 *               default start positions.
 *  \param karts_per_row How many karts to place in each row.
 *  \param forwards_distance Distance in forward (Z) direction between
 *               each kart.
 *  \param sidewards_distance Distance in sidewards (X) direction between
 *               karts.
 */
void QuadGraph::setDefaultStartPositions(AlignedArray<btTransform>
                                                       *start_transforms,
                                         unsigned int karts_per_row,
                                         float forwards_distance,
                                         float sidewards_distance,
                                         float upwards_distance) const
{
    // We start just before the start node (which will trigger lap
    // counting when reached). The first predecessor is the one on
    // the main driveline.
    int current_node = m_all_nodes[getStartNode()]->getPredecessor(0);

    float distance_from_start = 0.1f+forwards_distance;

    // Maximum distance to left (or right) of centre line
    const float max_x_dist    = 0.5f*(karts_per_row-0.5f)*sidewards_distance;
    // X position relative to the centre line
    float x_pos               = -max_x_dist + sidewards_distance*0.5f;
    unsigned int row_number   = 0;

    for(unsigned int i=0; i<(unsigned int)start_transforms->size(); i++)
    {
        if (current_node == -1)
        {
            (*start_transforms)[i].setOrigin(Vec3(0,0,0));
            (*start_transforms)[i].setRotation(btQuaternion(btVector3(0, 1, 0),
                                                            0));
        }
        else
        {
            // First find on which segment we have to start
            while(distance_from_start > getNode(current_node).getNodeLength())
            {
                distance_from_start -= getNode(current_node).getNodeLength();
                // Only follow the main driveline, i.e. first predecessor
                current_node = getNode(current_node).getPredecessor(0);
            }
            const GraphNode &gn   = getNode(current_node);
            Vec3 center_line = gn.getLowerCenter() - gn.getUpperCenter();
            center_line.normalize();

            Vec3 horizontal_line = gn[2] - gn[3];
            horizontal_line.normalize();

            Vec3 start = gn.getUpperCenter()
                       + center_line     * distance_from_start
                       + horizontal_line * x_pos;
            // Add a certain epsilon to the height in case that the
            // drivelines are beneath the track.
            (*start_transforms)[i].setOrigin(start+Vec3(0,upwards_distance,0));
            (*start_transforms)[i].setRotation(
                btQuaternion(btVector3(0, 1, 0),
                             gn.getAngleToSuccessor(0)));
            if(x_pos >= max_x_dist-sidewards_distance*0.5f)
            {
                x_pos  = -max_x_dist;
                // Every 2nd row will be pushed sideways by half the distance
                // between karts, so that a kart can drive between the karts in
                // the row ahead of it.
                row_number ++;
                if(row_number % 2 == 0)
                    x_pos += sidewards_distance*0.5f;
            }
            else
                x_pos += sidewards_distance;
            distance_from_start += forwards_distance;
        }
    }   // for i<stk_config->m_max_karts
}   // setStartPositions
Esempio n. 9
0
	bool Model::load()
	{
		std::string path = getPath();
		std::string directory = core::FileSystem::getDirectory(path);
		// Open XML file
		TiXmlDocument xml(path.c_str());
		if (!loadResourceFile(xml))
		{
			finishLoading(false);
			return false;
		}
		// Load XML file
		TiXmlNode *root = xml.FirstChild("Model");
		if (!root || !root->ToElement())
		{
			getManager()->getLog()->error("%s: <Model> not found.",
			                              getName().c_str());
			finishLoading(false);
			return false;
		}
		// Get geometry file
		const char *geofilename = root->ToElement()->Attribute("geometry");
		if (!geofilename)
		{
			getManager()->getLog()->error("%s: No geometry file specified.",
			                              getName().c_str());
			finishLoading(false);
			return false;
		}
		// Open geometry file
		core::FileSystem::Ptr fs = getManager()->getFileSystem();
		if (!loadGeometryFile(fs->getPath(geofilename, directory)))
		{
			finishLoading(false);
			return false;
		}
		// Load nodes
		TiXmlElement *rootnodeelem = root->FirstChildElement("Node");
		if (!rootnodeelem)
		{
			getManager()->getLog()->error("%s: No node available.",
			                              getName().c_str());
			finishLoading(false);
			return false;
		}
		if (!parseNode(rootnodeelem, 0))
		{
			finishLoading(false);
			return false;
		}
		// Load joints
		for (TiXmlElement *element = root->FirstChildElement("Armature");
		     element != 0;
		     element = element->NextSiblingElement("Armature"))
		{
			// Get batch index
			const char *batchstr = element->Attribute("batch");
			if (!batchstr)
			{
				getManager()->getLog()->warning("%s: Armature batch missing.",
				                                getName().c_str());
				continue;
			}
			unsigned int batchidx = atoi(batchstr);
			if (batchidx >= batches.size())
			{
				getManager()->getLog()->warning("%s: Invalid armature batch.",
				                                getName().c_str());
				continue;
			}
			// Load joints
			for (TiXmlElement *jointelem = element->FirstChildElement("Joint");
			     jointelem != 0;
			     jointelem = jointelem->NextSiblingElement("Joint"))
			{
				// Get and check joint index
				const char *indexstr = jointelem->Attribute("index");
				if (!indexstr)
				{
					getManager()->getLog()->warning("%s: Joint index missing.",
					                                getName().c_str());
					continue;
				}
				unsigned int index = atoi(indexstr);
				if (index >= batches[batchidx].joints.size())
				{
					getManager()->getLog()->warning("%s: Joint index invalid.",
					                                getName().c_str());
					continue;
				}
				// Get and check joint name
				const char *name = jointelem->Attribute("name");
				if (!name)
				{
					getManager()->getLog()->warning("%s: Joint name missing.",
					                                getName().c_str());
					continue;
				}
				Node *node = getNode(name);
				if (!node)
				{
					getManager()->getLog()->warning("%s: Joint node \"%s\" not found.",
					                                getName().c_str(), name);
					continue;
				}
				batches[batchidx].joints[index].name = name;
				batches[batchidx].joints[index].node = node;
			}
		}
		finishLoading(true);
		return true;
	}
Esempio n. 10
0
void Update_Best_Route(T_Node Head,A_Node Ants,Info_Node& info){
	short visitCount=0;
	short left_dist=0;
	short right_dist=0;
	short left_endNode;
	short leftRout[600];
	short rightRout[600];
	short orig_dist=0;
	short start_Position=0;
	double* transfer; 
	memset(leftRout,-1,600);
	memset(rightRout,-1,600);
	Ant_Init(Ants,info); 
	//int roulette0 = Get_Random(0, info.bestLength-1);
	int roulette0=Get_Random(0, info.bestLength-1);
	int i=0;
	int k=0;
	for(int j=roulette0;j>0;j--){
		if(Check_Visit(Head,info.bestRout[j])){//将路由表进行分割,左边路由表的position为roulette
			start_Position=j;
			visitCount++;
			break;
		}
	}
	for(i=0;i<start_Position;i++)
	{
		leftRout[i]=info.bestRout[i];
		left_dist+=info.distances.data[info.bestRout[i]][info.bestRout[i+1]];
	}
	leftRout[i]=info.bestRout[i];
	orig_dist=info.distances.data[info.bestRout[i]][info.bestRout[i+1]];//需要比较的距离
	i++;
	while(Check_Visit(Head,info.bestRout[i])==false && i<info.bestLength-1)//统计两个优化位置之间的间距
	{
		orig_dist+=info.distances.data[info.bestRout[i]][info.bestRout[i+1]];
		visitCount++;
		i++;
		
	}
	if(visitCount>3){
		left_endNode=info.bestRout[i];
		while(i<info.bestLength-1){//右边路由表的起点为优化间距的右端点
			rightRout[k]=info.bestRout[i];
			right_dist+=info.distances.data[info.bestRout[i]][info.bestRout[i+1]];
			i++;
			k++;
		}
		(Ants+0)->dist=left_dist;
		while((Ants+0)->posi!=start_Position){
			(Ants+0)->rout[(Ants+i)->posi]=leftRout[(Ants+0)->posi];
			(Ants+0)->node[leftRout[(Ants+0)->posi]] = ANT_GOST;        //添加到已经过
			(Ants+0)->posi += 1;
		}
		for(int j=1;j<=k;j++){
			(Ants+0)->tabu[j]=rightRout[j];
			(Ants+0)->node[rightRout[j]] = ANT_TABU;
		}
		rightRout[k]=info.bestRout[i];
		(Ants+0)->rout[(Ants+0)->posi]=leftRout[(Ants+0)->posi];
		(Ants+0)->node[leftRout[(Ants+0)->posi]] = ANT_GOST; 
		(Ants+1)->rout[(Ants+1)->posi]=leftRout[(Ants+0)->posi];
		int best=MAX_DIST_VAL;
		int next=1;
		int i=2;
		int m,n,temp;
		int nextDist;
		int count;
		ofstream fp;
		while(true){
			int position=(Ants+next)->rout[(Ants+next)->posi];
			count = 0;
			nextDist=(Ants+next)->dist;
			for (int j = 0; j < getNode(Head,position,NODE_NUMBER); j++){//获取当前节点的出度值
				temp=0;
				n=0;
				short idata = getSubNode(Head,position,j,SUB_NODE_NEXT);// 获取出度j尾节点的值
				if (Check_Visit(Ants,0,idata)==false && Check_Tabu(Ants,0,idata)==false && Check_Visit(Ants,next,idata)==false){
					if(info.distances.data[position][idata]>0){
						while(n<i){
							n++;
							if(idata==(Ants+next)->rout[(Ants+next)->posi]){
								if(((Ants+next)->dist+info.distances.data[position][idata])<(Ants+i)->dist){
									for(m=0;m<=(Ants+next)->posi;m++){
											(Ants+n)->rout[m]=(Ants+next)->rout[m];
											(Ants+n)->node[(Ants+n)->rout[m]]=ANT_GOST;
										};
										(Ants+n)->dist=(Ants+next)->dist+info.distances.data[position][idata];
										(Ants+n)->rout[m]=idata;
										(Ants+n)->node[idata]=ANT_GOST;
										(Ants+n)->posi=m;
									}
								temp=1;
								break;
							}
						}
							if(temp==0){
								if(count==0){
									(Ants+next)->posi += 1;
									(Ants+next)->rout[(Ants+next)->posi]=idata;
									(Ants+next)->node[idata]=ANT_GOST;
									(Ants+next)->dist += info.distances.data[position][idata];
								}
								else{
									for(m=0;m<(Ants+next)->posi;m++){
										(Ants+i)->rout[m]=(Ants+next)->rout[m];
										(Ants+i)->node[(Ants+i)->rout[m]]=ANT_GOST;
									}
									(Ants+i)->posi=m;
									(Ants+i)->rout[(Ants+i)->posi]=idata;
									(Ants+i)->node[idata]=ANT_GOST;
									(Ants+i)->dist=nextDist+info.distances.data[position][idata];
									i++;
								}
								count++;
							}
							else
								continue;
					}
				}
			}
			n=1;
			best=MAX_DIST_VAL;
			while(n<i){
				if((Ants+n)->dist<best && Check_Visit(Ants,0,(Ants+n)->rout[(Ants+n)->posi])==false){
					next=n;
					best=(Ants+n)->dist;
				}
				n++;
			}
			(Ants+0)->posi += 1;
			(Ants+0)->rout[(Ants+0)->posi]=(Ants+next)->rout[(Ants+next)->posi];
			(Ants+0)->node[(Ants+0)->rout[(Ants+0)->posi]]=ANT_GOST;
			if((Ants+next)->rout[(Ants+next)->posi]==left_endNode)
			{
				break;
			}
		}
		if((Ants+next)->dist<orig_dist){
			int r=1;
			int i;
			for(i=1;i<=(Ants+next)->posi;i++){
				info.bestRout[start_Position+i]=(Ants+next)->rout[i];
			}
			while(rightRout[r]!=-1){
				info.bestRout[start_Position+i]=rightRout[r];
				i++;
				r++;
			}
			info.bestDist=left_dist+(Ants+next)->dist+right_dist;
			info.bestLength=start_Position+i;
		}
	}			
}
Esempio n. 11
0
//链表节点 蚂蚁节点 蚂蚁数量 开始节点 数量
void Build_Solution(T_Node Head,A_Node Ants,Info_Node& info,double init_prob) {

	int nodeNumber = info.nodeNumber;                      //获取节点总数
	double* transfer;                                      //转移概率分子值
	double linkRate = 0;                                   //连接度总和
	short count=0;                                         //计数器
	short tabuCount = 0;                                  //禁忌表计数器
	short tabuTemp=-1;
	if(nodeNumber>0){
	 transfer = new double[nodeNumber];                    //申请空间
	}
	Ant_Init(Ants,info);                                   //初始化蚂蚁节点,清空

	for (int i = 0; i < info.antNumber; i++) {   //根据蚂蚁只数完成一次循环
		count=0;
		short cycleCount = 0;
		tabuCount=0;
		while ((Ants+i)->rout[(Ants+i)->posi] != info.endNode){//若当前节点不是终止节点且走过的点数小于总点数
			cycleCount++;
			int position = (Ants+i)->rout[(Ants+i)->posi]; //获取当前位置节点值,相当于A->B中的A

			memset(transfer,0,nodeNumber);                 //清零概率分子值

			linkRate = 0;                                  //初始化概率分母和
			for (int j = 0; j < getNode(Head,position,NODE_NUMBER); j++){//获取当前节点的出度值
				short idata = getSubNode(Head,position,j,SUB_NODE_NEXT);// 获取出度j尾节点的值
				if (Check_Visit(Ants,i,idata) == false){
					if(info.distances.data[position][idata]>0 && Check_Visit(Ants,i,idata) == false && Check_Tabu(Ants,i,idata)==false && idata!=tabuTemp){
						if(idata == info.endNode && count != info.mustNumber){
							continue;}
						else{
							if(Check_Visit(Head,idata) && (Ants+i)->posi>1){
									info.pheromone.data[position][idata] *= 1.2;
									info.pheromone.data[(Ants+i)->rout[(Ants+i)->posi-1]][position] *= 1.2;
								}
						double current = pow(info.pheromone.data[position][idata], info.alpha) * pow(double(info.maxWeight - info.distances.data[position][idata]),info.beta);;
							linkRate += current; //连接度加和     
							transfer[idata] = current;//当前节点量值
						}
					}
				}
			}

			for (short j = 0; j < getNode(Head,position,NODE_NUMBER); j++){
				short idata = getSubNode(Head,position,j,SUB_NODE_NEXT);      //获取尾节点值
				if(info.distances.data[position][idata]>0 && Check_Visit(Ants,i,idata) == false && Check_Tabu(Ants,i,idata)==false){ 
					if(idata == info.endNode && count != info.mustNumber){
							continue;}//查看当前节点是否访问过
					else
					transfer[idata] = transfer[idata] / linkRate;
				}
			}

			double roulette = (double) Get_Random(0, 100) / 100.0;
			double minor = 0;
			double major = 0;
			short selectidata = -1;
			if(roulette<=init_prob)
			{ 
				double temp=0;
				for (int j = 0; j <getNode(Head,position,NODE_NUMBER); j++){
					short idata = getSubNode(Head,position,j,SUB_NODE_NEXT);
					if (Check_Visit(Ants,i,idata) == false && info.distances.data[position][idata]>0 && Check_Tabu(Ants,i,idata)==false)
					{
						if(idata == info.endNode && count != info.mustNumber){
							continue;}//查看当前节点是否访问过
						else
						{
							if(transfer[idata]>temp)
							{
								temp=transfer[idata];
								selectidata=idata;
							}
						}
					}
				}
			}
			else{
				for (int j = 0; j <getNode(Head,position,NODE_NUMBER); j++)
				{
					short idata = getSubNode(Head,position,j,SUB_NODE_NEXT);
					if(info.distances.data[position][idata]>0 && Check_Visit(Ants,i,idata) == false && Check_Tabu(Ants,i,idata)==false) 
					{
						if(idata == info.endNode && count != info.mustNumber){
							continue;}//查看当前节点是否访问
						else
						{
							major += transfer[idata];
							if (roulette >= minor && roulette <= major) 
							{/*
								(Ants+i)->posi += 1;                    
								(Ants+i)->rout[(Ants+i)->posi] = idata;  

								(Ants+i)->node[idata] = ANT_GOST;      
								(Ants+i)->dist += info.distances.data[position][idata];
								info.pheromone.data[position][idata] *= 0.8;

								if(Check_Visit(Head,idata))
								{
									count++;
									info.pheromone.data[position][idata] *= 1.5;
								}*/
								selectidata=idata;
								break;
							} 
						}
					}
						else
						{
							minor = major;
						}
					}
			}
			if(selectidata==-1)
			{
				if(Check_Visit(Head,(Ants+i)->rout[(Ants+i)->posi]))//查看是否为必经点
				{
					count--;
					(Ants+i)->rout[(Ants+i)->posi]=ANT_UNGO;
					(Ants+i)->tabu[tabuCount] = INVALID;
				}
				else
				{
					(Ants+i)->tabu[tabuCount] = (Ants+i)->rout[(Ants+i)->posi];
					(Ants+i)->node[position] = ANT_TABU;      //添加到已经过
				}
				(Ants+i)->rout[(Ants+i)->posi] = INVALID;
				(Ants+i)->posi -= 1;
				(Ants+i)->dist -= info.distances.data[(Ants+i)->rout[(Ants+i)->posi]][position];
				
				tabuCount++;
				//tabuTemp=(Ants+i)->rout[(Ants+i)->posi];
				if((tabuCount>nodeNumber*0.1) || (cycleCount>nodeNumber))
				{
					//cout<<cycleCount<<" "<<endl;
					break;
				}
			}
			else
			{
				(Ants+i)->posi += 1;                     //位置标记++
				(Ants+i)->rout[(Ants+i)->posi] =selectidata;  //保存下一节点值

				(Ants+i)->node[selectidata] = ANT_GOST;        //添加到已经过
				(Ants+i)->dist += info.distances.data[position][selectidata];
				info.pheromone.data[position][selectidata] *= 0.9;
				
				if(Check_Visit(Head,selectidata)){
					count++;
				}
			}
			if(count == info.mustNumber && (Ants+i)->rout[(Ants+i)->posi]==info.endNode)
					break;
		}
	}
	delete[] transfer;
}
Esempio n. 12
0
void Crowd::initstd()
{
	double ix,iy,iz;
	Node* pnd;

	if(!getSize())
		return;
	pnd = getNode(0);
	ix = pnd->getX();
	iy = pnd->getY();
	iz = pnd->getZ();
	maxpt.setCoordinates(ix,iy,iz);
	minpt.setCoordinates(ix,iy,iz);
	xwidth = ywidth = zwidth = 0.;
	maxwidth = minwidth = 0.;

	maxdensity = getNode(0)->getDensity();
	mindensity = avedensity = maxdensity;

	int n = getSize();
	for(int i = 1; i < n; i++)
	{
		pnd = getNode(i);
		ix = pnd->getX();
		iy = pnd->getY();
		iz = pnd->getZ();
		if(maxpt.getX() < ix)
		{
			maxpt.setX(ix);
			maxaxispt[0] = getNode(i);
		}
		else if(minpt.getX() > ix)
		{
			minpt.setX(ix);
			minaxispt[0] = getNode(i);
		}
		if(maxpt.getY() < iy)
		{
			maxpt.setY(iy);
			maxaxispt[1] = getNode(i);
		}
		else if(minpt.getY() > iy)
		{
			minpt.setY(iy);
			minaxispt[1] = getNode(i);
		}
		if(maxpt.getZ() < iz)
		{
			maxpt.setZ(iz);
			maxaxispt[2] = getNode(i);
		}
		else if(minpt.getZ() > iz)
		{
			minpt.setZ(iz);
			minaxispt[2] = getNode(i);
		}
		if(maxdensity < getNode(i)->getDensity())
			maxdensity = getNode(i)->getDensity();
		else if(mindensity > getNode(i)->getDensity())
			mindensity = getNode(i)->getDensity();
		avedensity += getNode(i)->getDensity();
	}
	xwidth = maxpt.getX() - minpt.getX();
	ywidth = maxpt.getY() - minpt.getY();
	zwidth = maxpt.getZ() - minpt.getZ();
	maxwidth = minwidth = xwidth;
	if(maxwidth < ywidth)
		maxwidth = ywidth;
	else if(minwidth > ywidth)
		minwidth = ywidth;
	if(maxwidth < zwidth)
		maxwidth = zwidth;
	else if(minwidth > zwidth)
		minwidth = zwidth;

	avedensity = avedensity / getSize();

	flg_wid = true;
}
Esempio n. 13
0
// Replaces two consecutive nodes into a single equivalent node
// The extra memory is freed
void concatenateStringOfNodes(Node * nodeA, Graph * graph)
{
	Node *twinA = getTwinNode(nodeA);
	Node * nodeB = nodeA;
	Node * twinB;
	Node *currentNode, *nextNode;
	Coordinate totalLength = 0;
	PassageMarker *marker, *tmpMarker;
	Arc *arc;
	Category cat;

	while (simpleArcCount(nodeB) == 1
	       &&
	       simpleArcCount(getTwinNode
			      (getDestination(getArc(nodeB)))) ==
	       1
	       && getDestination(getArc(nodeB)) != getTwinNode(nodeB)
	       && getDestination(getArc(nodeB)) != nodeA) {
		totalLength += getNodeLength(nodeB);
		nodeB = getDestination(getArc(nodeB));
	}
	twinB = getTwinNode(nodeB);
	totalLength += getNodeLength(nodeB);
	reallocateNodeDescriptor(nodeA, totalLength);

	currentNode = nodeA;
	while (currentNode != nodeB) {		
		currentNode = getDestination(getArc(currentNode));

		// Passage marker management in node A:
		for (marker = getMarker(nodeA); marker != NULL;
		     marker = getNextInNode(marker))
			if (isTerminal(marker))
				incrementFinishOffset(marker,
						      getNodeLength(currentNode));

		// Swapping new born passageMarkers from B to A
		for (marker = getMarker(currentNode); marker != NULL; marker = tmpMarker) {
			tmpMarker = getNextInNode(marker);

			if (isInitial(marker)
			    || getNode(getPreviousInSequence(marker)) != nodeA) {
				extractPassageMarker(marker);
				transposePassageMarker(marker, nodeA);
				incrementFinishOffset(getTwinMarker(marker),
						      getNodeLength(nodeA));
			} else
				disconnectNextPassageMarker(getPreviousInSequence
							    (marker), graph);
		}

		// Read starts
		concatenateReadStarts(nodeA, currentNode, graph);

		// Gaps
		appendNodeGaps(nodeA, currentNode, graph);

		// Update uniqueness:
		setUniqueness(nodeA, getUniqueness(nodeA) || getUniqueness(currentNode));

		// Update virtual coverage
		for (cat = 0; cat < CATEGORIES; cat++)
			incrementVirtualCoverage(nodeA, cat,
						 getVirtualCoverage(currentNode, cat));

		// Update original virtual coverage
		for (cat = 0; cat < CATEGORIES; cat++)
			incrementOriginalVirtualCoverage(nodeA, cat,
							 getOriginalVirtualCoverage
							 (currentNode, cat));
		// Descriptor management (node)
		directlyAppendDescriptors(nodeA, currentNode, totalLength);
	}

	// Correct arcs
	for (arc = getArc(nodeB); arc != NULL; arc = getNextArc(arc)) {
		if (getDestination(arc) != twinB)
			createAnalogousArc(nodeA, getDestination(arc),
					   arc, graph);
		else
			createAnalogousArc(nodeA, twinA, arc, graph);
	}

	// Freeing gobbled nodes
	currentNode = getTwinNode(nodeB);
	while (currentNode != getTwinNode(nodeA)) {
		arc = getArc(currentNode);
		nextNode = getDestination(arc);
		destroyNode(currentNode, graph);
		currentNode = nextNode;
	}
}
Esempio n. 14
0
// Replaces two consecutive nodes into a single equivalent node
// The extra memory is freed
void concatenateNodes(Node * nodeA, Node * nodeB, Graph * graph)
{
	PassageMarker *marker, *tmpMarker;
	Node *twinA = getTwinNode(nodeA);
	Node *twinB = getTwinNode(nodeB);
	Arc *arc;
	Category cat;

	// Arc management:
	// Freeing useless arcs
	while (getArc(nodeA) != NULL)
		destroyArc(getArc(nodeA), graph);

	// Correct arcs
	for (arc = getArc(nodeB); arc != NULL; arc = getNextArc(arc)) {
		if (getDestination(arc) != twinB)
			createAnalogousArc(nodeA, getDestination(arc),
					   arc, graph);
		else
			createAnalogousArc(nodeA, twinA, arc, graph);
	}

	// Passage marker management in node A:
	for (marker = getMarker(nodeA); marker != NULL;
	     marker = getNextInNode(marker))
		if (isTerminal(marker))
			incrementFinishOffset(marker,
					      getNodeLength(nodeB));

	// Swapping new born passageMarkers from B to A
	for (marker = getMarker(nodeB); marker != NULL; marker = tmpMarker) {
		tmpMarker = getNextInNode(marker);

		if (isInitial(marker)
		    || getNode(getPreviousInSequence(marker)) != nodeA) {
			extractPassageMarker(marker);
			transposePassageMarker(marker, nodeA);
			incrementFinishOffset(getTwinMarker(marker),
					      getNodeLength(nodeA));
		} else
			disconnectNextPassageMarker(getPreviousInSequence
						    (marker), graph);
	}

	// Read starts
	concatenateReadStarts(nodeA, nodeB, graph);

	// Gaps
	appendNodeGaps(nodeA, nodeB, graph);

	// Descriptor management (node)
	appendDescriptors(nodeA, nodeB);

	// Update uniqueness:
	setUniqueness(nodeA, getUniqueness(nodeA) || getUniqueness(nodeB));

	// Update virtual coverage
	for (cat = 0; cat < CATEGORIES; cat++)
		incrementVirtualCoverage(nodeA, cat,
					 getVirtualCoverage(nodeB, cat));

	// Update original virtual coverage
	for (cat = 0; cat < CATEGORIES; cat++)
		incrementOriginalVirtualCoverage(nodeA, cat,
						 getOriginalVirtualCoverage
						 (nodeB, cat));

	// Freeing gobbled node
	destroyNode(nodeB, graph);
}
void push(CllNode *head_ref,Key new_data){
	CllNode cllNode=getNode(new_data);
	cllNode->next=*head_ref;
	*head_ref=cllNode;
}
Esempio n. 16
0
File: dag.c Progetto: shenchi/mycc
qcode_t undag(){
	qcode_t ret = 0, nc;
	dnode cur = nodes;
	nodelist p = dnodelist; 
	ident_t nid;

	while(p){
		if(!(p->flag) && (p->addr->type != DAG_LEAF) && p->id->type == VAR){
			p->flag = 1;
			p->addr->oprand = p->id;
		}
		p = p->next;
	}

	while(cur){
		if(cur->type == DAG_OP && cur->oprand == 0){
			nid = createIdent();
			nid->name = ccgenname(namenum++, '$');
			nid->type = TEMP;
			nid->subtype = cur->vartype;
			nid->loc = LOC_LOCAL;
			insertTable(stab, nid);
			cur->oprand = nid;
		}
		cur = cur->next;
	}
	
	p = dnodelist;
	while(p){
		if(p->id->type == VAR && !(p->flag) && p->addr->oprand != p->id){
			nc = createQCode();
			nc->code = MOV;
			nc->op1 = p->addr->oprand;
			nc->op2 = 0;
			nc->opr = p->id;
			nc->next = ret;
			ret = nc;
		}
		p = p->next;
	}

	cur = getNode();

	while(cur){
		nc = createQCode();
		nc->code = cur->op;
		nc->op1 = nc->op2 = nc->opr = 0;
		if( cur->x ){
			if(cur->type <= DAG_INST)
				nc->op1 = cur->x->oprand;
			cur->x->nref--;
		}

		if( cur->y ){
			if(cur->type <= DAG_INST)
				nc->op2 = cur->y->oprand;
			cur->y->nref--;
		}
		
		if(cur->oprand){
			nc->opr = cur->oprand;
		}

		nc->next = ret;
		ret = nc;

		cur->type = DAG_DEAD;
		if(cur->l){
			cur = cur->l;
			cur->nref--;
		}else
			cur = cur->x;
		
		if(!cur || cur->type == DAG_LEAF || cur->nref)cur = getNode(); 
	}

	return ret;
}
Esempio n. 17
0
void
TR::X86DataSnippet::addMetaDataForCodeAddress(uint8_t *cursor)
   {
   // add dummy class unload/redefinition assumption.
   if (_isClassAddress)
      {
      bool needRelocation = TR::Compiler->cls.classUnloadAssumptionNeedsRelocation(cg()->comp());
      if (needRelocation && !cg()->comp()->compileRelocatableCode())
         {
         cg()->addExternalRelocation(new (TR::comp()->trHeapMemory())
                                  TR::ExternalRelocation(cursor, NULL, TR_ClassUnloadAssumption, cg()),
                                  __FILE__, __LINE__, self()->getNode());
         }

      if (TR::Compiler->target.is64Bit())
         {
         if (!needRelocation)
            cg()->jitAddPicToPatchOnClassUnload((void*)-1, (void *) cursor);
         if (cg()->wantToPatchClassPointer(NULL, cursor)) // unresolved
            {
            cg()->jitAddPicToPatchOnClassRedefinition(((void *) -1), (void *) cursor, true);
            }
         }
      else
         {
         if (!needRelocation)
            cg()->jitAdd32BitPicToPatchOnClassUnload((void*)-1, (void *) cursor);
         if (cg()->wantToPatchClassPointer(NULL, cursor)) // unresolved
            {
            cg()->jitAdd32BitPicToPatchOnClassRedefinition(((void *) -1), (void *) cursor, true);
            }
         }

      TR_OpaqueClassBlock *clazz = getData<TR_OpaqueClassBlock *>();
      if (clazz && cg()->comp()->compileRelocatableCode() && cg()->comp()->getOption(TR_UseSymbolValidationManager))
         {
         cg()->addExternalRelocation(new (cg()->trHeapMemory()) TR::ExternalRelocation(cursor,
                                                               (uint8_t *)clazz,
                                                               (uint8_t *)TR::SymbolType::typeClass,
                                                               TR_SymbolFromManager,
                                                               cg()),  __FILE__, __LINE__, getNode());
         }
      }
   }
Esempio n. 18
0
void SceneManagerCMPlay::InitSceneGraph()
{
	// root node
	this->sceneGraph = getNode();
	this->sceneGraph->SetGameObject(NULL);

	// first child node of the scenegraph consists of static nodes / nodes that do not need constantly update
	this->staticSceneGraph = getNode();
	this->staticSceneGraph->SetGameObject(NULL);
	// second child node of the scenegraph consists of dynamic / moving nodes / nodes that need to be updated with spatial partition for collision detection
	this->dynamicSceneGraph = getNode();
	this->dynamicSceneGraph->SetGameObject(NULL);

	// add the 2 child to parent node first
	sceneGraph->AddChildNode(staticSceneGraph);
	sceneGraph->AddChildNode(dynamicSceneGraph);

	SceneNode* node;
	Mesh* drawMesh;

	//Init player(Body is main node)
	Player->Init(Vector3(0, 0, 0), Vector3(0, 1, 0), resourceManager.retrieveMesh("WARRIOR_OBJ"));
	
	//Temp use all the same mesh
	drawMesh = resourceManager.retrieveMesh("WARRIOR_OBJ");

	//Head of player
	node = getNode();
	node->GetGameObject()->setMesh(drawMesh);
	node->GetGameObject()->setName("Head");
	Player->GetNode()->AddChildNode(node);
	Player->GetNode()->GetChildNode("Head")->GetGameObject()->setPosition(Vector3(0, 5, 0));
	Player->GetNode()->GetChildNode("Head")->GetGameObject()->setHitbox(Vector3(0, 0, 0), 5, 5, 5, "HeadHitbox");
	
	//Left Hand of player
	node = getNode();
	node->GetGameObject()->setMesh(drawMesh);
	node->GetGameObject()->setName("LeftHand");
	Player->GetNode()->AddChildNode(node);
	Player->GetNode()->GetChildNode("LeftHand")->GetGameObject()->setPosition(Vector3(-5, 0, 0));
	Player->GetNode()->GetChildNode("LeftHand")->GetGameObject()->setHitbox(Vector3(0,0,0), 1, 1, 1, "LeftHandHitbox");

	//Right Hand of player
	node = getNode();
	node->GetGameObject()->setMesh(drawMesh);
	node->GetGameObject()->setName("RightHand");
	Player->GetNode()->AddChildNode(node);
	Player->GetNode()->GetChildNode("RightHand")->GetGameObject()->setPosition(Vector3(5, 0, 0));
	Player->GetNode()->GetChildNode("RightHand")->GetGameObject()->setHitbox(Vector3(0, 0, 0), 1, 1, 1, "RightHandHitbox");

	//Left Leg of player
	node = getNode();
	node->GetGameObject()->setMesh(drawMesh);
	node->GetGameObject()->setName("LeftLeg");
	Player->GetNode()->AddChildNode(node);
	Player->GetNode()->GetChildNode("LeftLeg")->GetGameObject()->setPosition(Vector3(-3, -5, 0));
	Player->GetNode()->GetChildNode("LeftLeg")->GetGameObject()->setHitbox(Vector3(0, 0, 0), 1, 1, 1, "LeftLegHitbox");

	//Right Leg of player
	node = getNode();
	node->GetGameObject()->setMesh(drawMesh);
	node->GetGameObject()->setName("RightLeg");
	Player->GetNode()->AddChildNode(node);
	Player->GetNode()->GetChildNode("RightLeg")->GetGameObject()->setPosition(Vector3(3, -5, 0));
	Player->GetNode()->GetChildNode("RightLeg")->GetGameObject()->setHitbox(Vector3(0, 0, 0), 1, 1, 1, "RightLegHitbox");

	//Adds the player node
	dynamicSceneGraph->AddChildNode(Player->GetNode());

	node = getNode();
	node->GetGameObject()->setMesh(drawMesh);
	node->GetGameObject()->setName("TestObject");
	node->GetGameObject()->setPosition(Vector3(0, 0, 50));
	node->GetGameObject()->setHitbox(node->GetGameObject()->getPosition(),20,20,20,"TestObject");
	dynamicSceneGraph->AddChildNode(node);
	// Rmb to init static nodes position first

	spatialPartitionManager->addNode(sceneGraph, spatialPartitionManager->type);
}
Esempio n. 19
0
T LinkedList<T>::get(int index){
  ListNode<T> *tmp = getNode(index);
  return (tmp ? tmp->data : T());
}
Esempio n. 20
0
int main(int argc, char *argv[])
{
    ApplicationsLib::LogogSetup logog_setup;

    TCLAP::CmdLine cmd(
        "Query mesh information.\n\n"
        "OpenGeoSys-6 software, version " +
            BaseLib::BuildInfo::git_describe +
            ".\n"
            "Copyright (c) 2012-2019, OpenGeoSys Community "
            "(http://www.opengeosys.org)",
        ' ', BaseLib::BuildInfo::git_describe);
    TCLAP::UnlabeledValueArg<std::string> mesh_arg("mesh-file","input mesh file",true,"","string");
    cmd.add( mesh_arg );
    TCLAP::MultiArg<std::size_t> eleId_arg("e","element-id","element ID",false,"number");
    cmd.add( eleId_arg );
    TCLAP::MultiArg<std::size_t> nodeId_arg("n","node-id","node ID",false,"number");
    cmd.add( nodeId_arg );
    TCLAP::SwitchArg showNodeWithMaxEle_arg("", "show-node-with-max-elements", "show a node having the max number of connected elements", false);
    cmd.add( showNodeWithMaxEle_arg );

    cmd.parse( argc, argv );

    const std::string filename(mesh_arg.getValue());

    // read the mesh file
    auto const mesh = std::unique_ptr<MeshLib::Mesh>(
        MeshLib::IO::readMeshFromFile(filename));
    if (!mesh)
    {
        return EXIT_FAILURE;
    }

    std::vector<std::size_t> selected_node_ids;
    if  (showNodeWithMaxEle_arg.getValue())
    {
        auto itr = std::max_element(mesh->getNodes().begin(), mesh->getNodes().end(),
                     [](MeshLib::Node* i, MeshLib::Node* j) { return i->getNumberOfElements() < j->getNumberOfElements(); });
        if (itr != mesh->getNodes().end())
        {
            MeshLib::Node* node = *itr;
            selected_node_ids.push_back(node->getID());
        }
    }
    selected_node_ids.insert(selected_node_ids.end(), nodeId_arg.getValue().begin(), nodeId_arg.getValue().end());

    auto const materialIds = materialIDs(*mesh);
    for (auto ele_id : eleId_arg.getValue())
    {
        std::stringstream out;
        out << std::scientific
            << std::setprecision(std::numeric_limits<double>::digits10);
        out << "--------------------------------------------------------" << std::endl;
        auto* ele = mesh->getElement(ele_id);
        out << "# Element " << ele->getID() << std::endl;
        out << "Type : " << CellType2String(ele->getCellType()) << std::endl;
        if (materialIds)
        {
            out << "Mat ID : " << (*materialIds)[ele_id] << std::endl;
        }
        out << "Nodes: " << std::endl;
        for (unsigned i = 0; i < ele->getNumberOfNodes(); i++)
        {
            out << ele->getNode(i)->getID() << " " << *ele->getNode(i)
                << std::endl;
        }
        out << "Content: " << ele->getContent() << std::endl;
        out << "Neighbors: ";
        for (unsigned i=0; i<ele->getNumberOfNeighbors(); i++)
        {
            if (ele->getNeighbor(i))
            {
                out << ele->getNeighbor(i)->getID() << " ";
            }
            else
            {
                out << "none ";
            }
        }
        out << std::endl;
        INFO("%s", out.str().c_str());
    }

    for (auto node_id : selected_node_ids)
    {
        std::stringstream out;
        out << std::scientific
            << std::setprecision(std::numeric_limits<double>::digits10);
        out << "--------------------------------------------------------" << std::endl;
        MeshLib::Node const* node = mesh->getNode(node_id);
        out << "# Node " << node->getID() << std::endl;
        out << "Coordinates: " << *node << std::endl;
        out << "Connected elements (" << node->getNumberOfElements() << "): ";
        for (auto ele : node->getElements())
        {
            out << ele->getID() << " ";
        }
        out << std::endl;
        out << "Connected nodes (" << node->getConnectedNodes().size() << "): ";
        for (auto nd : node->getConnectedNodes())
        {
            out << nd->getID() << " ";
        }
        out << std::endl;
        INFO("%s", out.str().c_str());
    }
}
Esempio n. 21
0
void SceneManagerCMPlay::Update(double dt)
{
	SceneManagerGameplay::Update(dt);
	//FSMApplication();

	//spatialPartitionManager->Update();

	spatialPartitionManager->removeNode(dynamicSceneGraph);
	spatialPartitionManager->addNode(dynamicSceneGraph, this->spatialPartitionManager->type);

	// loop through partitions
	for (unsigned i = 0; i < spatialPartitionManager->partitions.size(); ++i)
	{
		// check if partitions contain more than 1 node ( can further optimize by checking if contains dynamic nodes)
		if (spatialPartitionManager->partitions[i]->nodes.size() > 0)
		{
			for (vector<SceneNode*>::iterator j = spatialPartitionManager->partitions[i]->nodes.begin(); j != spatialPartitionManager->partitions[i]->nodes.end(); ++j)
			{
				SceneNode* firstNode = *j;
				
				for (vector<SceneNode*>::iterator k = j + 1; k != spatialPartitionManager->partitions[i]->nodes.end(); ++k)
				{
					SceneNode* secondNode = *k;
					string boxName = "";
					
					if (firstNode->getActive() && secondNode->getActive())
					{
						//Only check if both are not player
						if (firstNode->GetGameObject()->getName() != "Player" && secondNode->GetGameObject()->getName() != "Player" && firstNode->GetGameObject()->getName() != "LeftHand" && secondNode->GetGameObject()->getName() != "LeftHand" && firstNode->GetGameObject()->getName() != "RightHand" && secondNode->GetGameObject()->getName() != "RightHand")
						{

							if (check3DCollision(firstNode->GetGameObject()->getHitbox(), secondNode->GetGameObject()->getHitbox(), boxName))
							{
								if (firstNode->GetGameObject()->getName() == "testprojectile")
								{
									//projectileManager.RemoveProjectile(firstNode->GetGameObject());
									spatialPartitionManager->removeNode(secondNode);
									dynamicSceneGraph->RemoveChildNode(secondNode);
									j = spatialPartitionManager->partitions[i]->nodes.begin();
									break;
								}
								else if (secondNode->GetGameObject()->getName() == "testprojectile")
								{
									//projectileManager.RemoveProjectile(firstNode->GetGameObject());
									spatialPartitionManager->removeNode(firstNode);
									dynamicSceneGraph->RemoveChildNode(firstNode);
									j = spatialPartitionManager->partitions[i]->nodes.begin();
									break;
								}
								//Every other thing
								spatialPartitionManager->removeNode(secondNode);
								dynamicSceneGraph->RemoveChildNode(secondNode);
								j = spatialPartitionManager->partitions[i]->nodes.begin();
								break;
							}
						}
					}
				}
			}
		}
	}

	/*Sound testing related keys*/
	if (inputManager->getKey("TEST_SOUND"))
	{
		resourceManager.setListenerPosition(tpCamera.getPosition(), tpCamera.getTarget());
		static int distance = 2;
		//distance++;
		//resourceManager.retrieveSoundas2D("MenuFeedback");
		resourceManager.retrieveSoundas3D("MenuFeedback", tpCamera.getPosition() + (float)distance);
	}

	if (inputManager->getKey("VOLUME_UP"))
	{
		resourceManager.IncreaseSoundEngineVolume();
	}
	if (inputManager->getKey("VOLUME_DOWN"))
	{
		resourceManager.DecreaseSoundEngineVolume();
	}

	//tpCamera.Update(dt);

	if (inputManager->getKey("RSelect"))
	{
		Vector3 characterPos = dynamicSceneGraph->GetChildNode("Player")->GetGameObject()->getPosition();
		testProjectile.setPosition(characterPos);
		CProjectile* projectile = projectileManager.FetchProjectile(testProjectile, (tpCamera.getTarget() - tpCamera.getPosition()).Normalized(), 20.f);
		GameObject3D* newProjectile = projectile;
		SceneNode* node;
		node = getNode();
		node->SetGameObject(newProjectile);
		dynamicSceneGraph->AddChildNode(node);
	}

	projectileManager.Update(dt);

	if (inputManager->getKey("LockPitch"))
	{
		tpCamera.TogglePitchLock();
	}
	if (inputManager->getKey("LockYaw"))
	{
		tpCamera.ToggleYawLock();
	}

	const float moveSpeed = 100.f;
	if (inputManager->getKey("Up"))
	{
		Player->SetAngle(tpCamera.GetCamAngle());

		if (inputManager->getKey("Left"))
		{
			Player->SetAngle(tpCamera.GetCamAngle() - 45.f);
		}

		if (inputManager->getKey("Right"))
		{
			Player->SetAngle(tpCamera.GetCamAngle() + 45.f);
		}
		Player->UpdateMovement(dt);
	}

	if (inputManager->getKey("Down"))
	{
		Player->SetAngle(tpCamera.GetCamAngle() + 180.f);

		if (inputManager->getKey("Left"))
		{
			Player->SetAngle(tpCamera.GetCamAngle() - 135.f);
		}

		if (inputManager->getKey("Right"))
		{
			Player->SetAngle(tpCamera.GetCamAngle() + 135.f);
		}
		Player->UpdateMovement(dt);

	}

	if (inputManager->getKey("Left"))
	{
		Player->SetAngle(tpCamera.GetCamAngle() + 90.f);

		Player->UpdateMovement(dt);
	}

	if (inputManager->getKey("Right"))
	{
		Player->SetAngle(tpCamera.GetCamAngle() - 90.f);

		Player->UpdateMovement(dt);
	}

	dynamicSceneGraph->GetChildNode("Player")->GetGameObject()->setPosition(Vector3(
		dynamicSceneGraph->GetChildNode("Player")->GetGameObject()->getPosition().x,
		dynamicSceneGraph->GetChildNode("Player")->GetGameObject()->getPosition().y,
		dynamicSceneGraph->GetChildNode("Player")->GetGameObject()->getPosition().z));

	dynamicSceneGraph->GetChildNode("Player")->GetGameObject()->setRotation(Player->GetAngle(),
		0,
		1,
		0);


	tpCamera.UpdatePosition(dynamicSceneGraph->GetChildNode("Player")->GetGameObject()->getPosition(), Vector3(0, 0, 0));
}
Esempio n. 22
0
void DefaultDrone::updateAlive(double timeDelta, double parentTime){
	float f = timeAlive();

	if (!mDbe->isStatic()){
		Coordinator::Transform base;
		if (mTransformCoordinator){
			base = mTransformCoordinator->getValue(timeAlive());
		}else{
			base = dynamic_cast<Coordinator::TransformCoordinator*>(Coordinator::CoordinatorFactory::getSingleton()->get("static_transform:0,0,0"))->getValue(0);
		}

		getNode()->setPosition(base.mPos);
		getNode()->setOrientation(base.mRot);
		Ogre::TransformKeyFrame key(NULL, 0);
		key = dynamic_cast<DefaultDroneDBE*>(mDbe)->getKeyFrame(f);
		Ogre::Vector3 v = key.getTranslate();
		v=v*base.mScl;

		getNode()->translate(v);
	
		Ogre::Radian angle;
		Ogre::Vector3 axis;
	
		Ogre::Quaternion r = key.getRotation();

		if ( base.mScl.x == -1){
			r.ToAngleAxis(angle, axis);
			axis.x *= -1;
			angle = (Ogre::Radian)0-angle;
			r.FromAngleAxis(angle, axis);
		}
		mSceneNode->rotate(r);


	}

	{
		list<GoAnim::GoAnim*>::iterator it, begin, end;
		
		begin = mGoAnim.begin();
		end = mGoAnim.end();
		for (it=begin;it!=end;it++){
			(*it)->update(timeDelta, parentTime);
		}
	}{
		list<FIRING_TIME>::iterator it, begin, end;
		
		begin = (dynamic_cast<DefaultDroneDBE*>(mDbe)->getFiringTime())->begin();
		end = (dynamic_cast<DefaultDroneDBE*>(mDbe)->getFiringTime())->end();
		for (it=begin;it!=end;it++){
			if (mLevelSegment->isTimeInFrame(getTimeOn()+(*it).time)){
				//Util::Log("IsTimeInFrame:"+ts(getTimeOn()+(*it).time));
				if ((*it).firingOption == FIRING_START){
					fire((*it).mount, (*it).inertia);
				}else{
					ceaseFire((*it).mount);
				}
			}
		}
	}{
		/*list<DRONE_TIMED_ANIM>::iterator it, begin, end;
		
		begin = (dynamic_cast<DefaultDroneDBE*>(mDbe)->getTimedAnim())->begin();
		end = (dynamic_cast<DefaultDroneDBE*>(mDbe)->getTimedAnim())->end();
		for (it=begin;it!=end;it++){
			if (mLevelSegment->isTimeInFrame(getTimeOn()+(*it).time)){
				Util::Log("IsTimeInFrame:"+ts(getTimeOn()+(*it).time));
				Ogre::AnimationState* as;
				as = mEntity->getAnimationState( (*it).label );
				as->setEnabled(true);
				as->setLoop((*it).loop);
				mAnim.push_back(as);
				
				//fire((*it).type);
			}
		}*/
	}{
		list<Ogre::AnimationState*>::iterator it, begin, end;
		
		begin = mAnim.begin();
		end = mAnim.end();
		for (it=begin;it!=end;it++){
			(*it)->addTime(timeDelta);//Level::getSingleton()->getTimeDelta());
		}
	}
}
Esempio n. 23
0
void DynamicSphere::addToWorld(World* world) {
	world->getDynamics()->addRigidBody(m_rigid_body);
	world->getRoot()->addChild(getNode());
}
Esempio n. 24
0
void Window::send( co::ObjectPacket& packet ) 
{
    packet.objectID = getID(); 
    getNode()->send( packet ); 
}
		void MainWindow::saveSettings()
		{
			QString location = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
			if(!QDir(location).exists())
				QDir().mkdir(location);

			playlist.savePlaylist(location + "\\Playlist." + LIST_EXT);

			QFile file(location + "\\settings.xml");

			QDomDocument doc("settings");
			if(file.open(QIODevice::ReadOnly))
			{
				doc.setContent(&file);
				file.close();
			}

			QDomElement root = getNode("settings", &doc, &doc);
			QDomElement node = getNode("InputDevice", &doc, &root);
			node.setAttribute("Id", sosContext->AudioInput->getCurrentDevice().Id);

			node = getNode("InputSamples", &doc, &root);
			node.setAttribute("Samples", sosContext->AudioAnalyzer->getSamplesArraySize());

			node = getNode("Volume", &doc, &root);
			node.setAttribute("Volume", sosContext->SongControl->getSettings()->getVolume());

			node = getNode("VolumeTreshold", &doc, &root);
			node.setAttribute("Treshold", sosContext->AudioAnalyzer->getVolumeThreshold());

			node = getNode("TextGroupBy", &doc, &root);
			node.setAttribute("GroupBy", settings->getTextGroupBy());

			node = getNode("TextLineCount", &doc, &root);
			node.setAttribute("LineCount", settings->getTextLineCount());

			node = getNode("TimeShift", &doc, &root);
			node.setAttribute("Shift", (qlonglong)settings->getOutputLatency());

			node = getNode("TimeRange", &doc, &root);
			node.setAttribute("Range", (qlonglong)settings->getViewTimeRange());

			node = getNode("LastOpenedDir", &doc, &root);
			node.setAttribute("Path", playlist.lastOpenedDir.absolutePath());

			node = getNode("Promo", &doc, &root);
			node.setAttribute("TimesLaunched", timesLaunched);
			node.setAttribute("PromoShown", promoShown);

			QDomElement guiNode = getNode("gui", &doc, &root);
			saveWinProperties(this, &doc, &guiNode);
			saveWinProperties(&settingsWindow, &doc, &guiNode);
			saveWinProperties(&outputSettings, &doc, &guiNode);
			saveWinProperties(&playlist, &doc, &guiNode);
			saveWinProperties(&songWindow, &doc, &guiNode);
			saveWinProperties(&songSearch, &doc, &guiNode);

			node = getNode(songSearch.objectName(), &doc, &guiNode);
			node.setAttribute("columns", songSearch.getColumnWidths());

			node = getNode("Skin", &doc, &guiNode);
			QString v = skinMgr ? skinMgr->getSkinName() : "";
			node.setAttribute("Name", v);

			if(file.open(QIODevice::WriteOnly))
			{
				QTextStream stream(&file);
				stream << doc.toString();
				file.close();
			}
		}
Esempio n. 26
0
bool TraceListIO::removeNode(pugi::xml_node i_traceNode) {
  pugi::xml_node documentNode = getNode();
  bool hasWorked = documentNode.remove_child(i_traceNode);
  setNode(documentNode);
  return hasWorked;
}
Esempio n. 27
0
	unsigned int PortalPath::updateLocation( const Agents::BaseAgent * agent, const NavMeshPtr & navMesh, const NavMeshLocalizer * localizer, PathPlanner * planner ) {
		// If off path, replan get a new route
		// TODO: If off "approach" vector, recompute crossing
		bool changed = false;
		unsigned int currNodeID = getNode();
		const NavMeshNode * currNode = &(navMesh->getNode( currNodeID ) );
		// test current location
		const Vector2 & p = agent->_pos;

		const unsigned int PORTAL_COUNT = static_cast< unsigned int >( _route->getPortalCount() );
		if ( ! currNode->containsPoint( p ) ) {
			// test to see if I've progressed to the next
			
			bool gotoNext = false;
			const NavMeshNode * nextNode = 0x0;
			if ( _currPortal + 1 < PORTAL_COUNT ) {
				// there is another way portal to test
				const WayPortal * nextPortal = _route->getPortal( _currPortal + 1 );
				size_t nextID = nextPortal->_nodeID;
				nextNode = &(navMesh->getNode( (unsigned int) nextID ) );
				gotoNext = nextNode->containsPoint( p );
			} else if ( _currPortal < PORTAL_COUNT ) {
				// the next node is the goal polygon
				nextNode = &(navMesh->getNode( (unsigned int) _route->getEndNode() ) );
				gotoNext = nextNode->containsPoint( p );
			}
			if ( gotoNext ) {
				// I've made progress, simply advance
				++_currPortal;	
				assert( _currPortal <= PORTAL_COUNT && "Incremented current portal larger than goal" );
				changed = true;
			}
			 else {
				const NavMeshNode * prevNode = 0x0;
				// test to see if I've gone backwards
				bool gotoPrev = false;
				if ( _currPortal > 0 ) {
					const WayPortal * prevPortal = _route->getPortal( _currPortal - 1 );
					size_t prevID = prevPortal->_nodeID;
					prevNode = &(navMesh->getNode( (unsigned int) prevID ) );
					gotoPrev = prevNode->containsPoint( p );
				}
				if ( gotoPrev ) {
					// back up to previous way portal in path
					--_currPortal;
					changed = true;
				} else {
					// Agent is not in current, previous or next polygons - agent got
					//	pushed off path - find a new path
					//	Path needs the nav mesh
					// Assume that I must be in a neighboring node (the alternative is
					//	catstrophic)
					// search current node's neighbors that aren't previous and aren't next
					const size_t NBR_COUNT = currNode->getNeighborCount();
					for ( size_t n = 0; n < NBR_COUNT; ++n ) {
						const NavMeshNode * node = currNode->getNeighbor( n );
						if ( node == nextNode || node == prevNode ) continue;
						if ( node->containsPoint( p ) ) {
							// find a new path from this node to the goal
							replan( p, node->getID(), _route->getEndNode(), agent->_radius, planner );
							changed = true;
						} 
					}

					// It is possible for the agent, in some cases, to advance several nodes in a single time step
					//	(e.g., when the navigation mesh has many long, skinny triangles and the agent steps across the
					//	narrow fan).
					//	In this case, the agent should search forwards along the path before blindly searching.

					//	TODO:
					//		If it gets "lost" at the beginning of a long path, I'm doing a bunch of wasted testing.
					//		Given how far the agent is from a particular portal, I know I should probably stop
					//		looking as the portals are only going to get farther.  So, that means the inside
					//		query should CHEAPLY compute some sense of distance to the polygon so I can drop
					//		out.
					if ( changed == false ) {
						size_t testPortal = _currPortal + 2;
						while ( testPortal < PORTAL_COUNT ) {
							const WayPortal * nextPortal = _route->getPortal( testPortal );
							size_t testID = nextPortal->_nodeID;
							const NavMeshNode * testNode = &(navMesh->getNode( (unsigned int) testID ) );
							if ( testNode->containsPoint( p ) ) {
								_currPortal = testPortal;
								changed = true;
								break;
							}
							++testPortal;
						}
					}
					if ( changed == false ) {
						// I exited the loop without finding an intermediate node -- test the goal node
						const NavMeshNode * testNode = &(navMesh->getNode( (unsigned int) _route->getEndNode() ) );
						if ( testNode->containsPoint( p ) ) {
							_currPortal = PORTAL_COUNT;
							changed = true;
						}
					}

					if ( !changed ) {
	#ifdef _DEBUG
						logger << Logger::WARN_MSG << "Agent " << agent->_id << " got pushed from its goal into a non-adjacent goal!!\n";
	#endif
						// do a full find path searching for the agent position
						float lastElevation = currNode->getElevation( p );
						unsigned int nodeID = localizer->findNodeBlind( p, lastElevation );
						if ( nodeID != NavMeshLocation::NO_NODE ) {
							try {
								replan( p, nodeID, _route->getEndNode(), agent->_radius, planner );
							} catch ( PathPlannerException ) {
								std::stringstream ss;
								ss << "Agent " << agent->_id << " trying to find a path from " << nodeID << " to " << _route->getEndNode() << ".  A* finished without a route!";
								throw PathPlannerException( ss.str() );
							}
						}
						changed = true;
					}
				}
			}
		}
		/*
		// TODO: Implement the idea of replanning the path based on getting pushed off
		//		approach vector
		if ( !changed && _currPortal < _route->getPortalCount() ) {
			// vector from crossing point to current position.
			//	examine angle between original approach vector and current approach vector.
			//	If the angle > some threshold, replan.
		}
		*/
		if ( _currPortal < _route->getPortalCount()  ) {
			return _route->getPortal( _currPortal )->_nodeID;
		} else {
			return _route->getEndNode();
		}
	}
Esempio n. 28
0
bool
CKLBUIScore::initCore(u32 order, s32 order_offset, float x, float y, 
                      const char ** tex_table, float stepX, float stepY, int column, 
                      bool fillzero, bool anim_flag, u32 align, bool countclip)
{
	if(!setupPropertyList((const char**)ms_propItems,SizeOfArray(ms_propItems))) {
		return false;
	}

	setInitPos(x, y);
	m_order         = order;
	m_orderOffset   = order_offset;
	m_stepX         = (int)stepX;
	m_stepY         = (int)stepY;
	m_column        = column;
	m_bFillZero     = fillzero;
	m_anim          = anim_flag;
	m_align         = align;
	m_bCountClip    = countclip;
	m_dotStepX		= 0;
	m_dotStepY		= 0;
	m_value         = 0xFFFFFFFF;
	m_fValue        = -12345678.0f;
	setValue(0);
	setValueFloat(0.0f, 0);
	RESET_B;	// Reset flag done by setValueFloat.


	// align設定用の幅を計算
	m_width  = stepX * column;
	m_height = stepY * column;

	// 保持できる最大値+1を計算
	m_maxvalue = 1;
    for(int i = 0; i < column; i++) { m_maxvalue = m_maxvalue * 10; }

	for(int idx = 0; idx < 10; idx++) {
		setStrC(m_asset[idx], tex_table[idx]);
	}

	CKLBTextureAsset * pTexAsset;
	pTexAsset = (CKLBTextureAsset *)CKLBUtility::loadAssetScript( m_asset[0], &m_handle, NULL, true);

	const char * texname[10];
	for(int i = 0; i < 10; i++) {
		texname[i] = m_asset[i] + 8;
	}

	m_pScoreNode = KLBNEW(CKLBScoreNode);
    if(!m_pScoreNode) {
		CKLBDataHandler::releaseHandle(m_handle);
        return false;
    }
    
    for(int i = 0; i < 10; i++) {
        m_numTex[i] = pTexAsset->getImage(texname[i]);
        if(m_numTex[i] == 0) {
			CKLBScriptEnv::getInstance().error("TEXB differs from [%s] by [%s].", texname[0], texname[i]);
			CKLBDataHandler::releaseHandle(m_handle);
			return false;
		}
    }

    bool bResult = m_pScoreNode->init(	order,
			                            order_offset,
			                            m_numTex,
			                            m_stepX,
										m_stepY,
										column,
										fillzero,
									    anim_flag);
    
    getNode()->addNode(m_pScoreNode, 0);
	m_pScoreNode->markUpMatrix();
	m_bScoreUpdate = true;

	if(!bResult) CKLBDataHandler::releaseHandle(m_handle);

	return bResult;
}
Esempio n. 29
0
void Pipe::checkRenderingParameters( Window* wnd, uint32_t frameNumber )
{
// make these checks once per frame
    if( _lastFrameNumber >= frameNumber )
        return;

    _lastFrameNumber = frameNumber;

    const Node* node = static_cast< const Node*>( getNode( ));

// enable new data if required (from node!)
    const uint32_t fileNameVersion = node->getFileNameVersion();
    if( _fileNameVersion < fileNameVersion )
    {
        LBWARN << "Setting new data" << std::endl;

        // make sure async stuff is stopped before new Model is constructed
        _deintializeModel();
        _intializeModel( wnd );

        if( !_model )
            return;

        _fileNameVersion = fileNameVersion;
        _model->setDataVersion( _fileNameVersion );
    }

    if( !_model )
        return;

    constVolumeInfoSPtr volumeInfo = node->getVolumeInfo();

// set renderer if required (from volumeInfo)
    const uint32_t rTypeVersion = volumeInfo->getRendererTypeVersion();
    if( _rTypeVersion < rTypeVersion )
    {
        LBWARN << "Setting new renderer" << std::endl;

        _model->enableRenderer( volumeInfo->getRendererType( ));

        _rTypeVersion = rTypeVersion;
    }

// set TF if required (from volumeInfo)
    const uint32_t tfVersion = volumeInfo->getTransferFunctionVersion();
    if( _tfVersion < tfVersion )
    {
        _model->initTF( volumeInfo->getTransferFunction( ));
        _tfVersion = tfVersion;
    }


// set TensorParameters if required (from volumeInfo)
    const uint32_t tpVersion = volumeInfo->getTensorParametersVersion();
    if( _tpVersion < tpVersion )
    {
        const TensorParameters& newTP = volumeInfo->getTensorParameters();
        *_tensorParameters = newTP;
        _tpVersion = tpVersion;
    }
}
Esempio n. 30
-1
	XalanNode*
	getNode(const DOM_NodeType&		theXercesNode) const
	{
		return getNode(XercesDOM_NodeHack::getImpl(theXercesNode));
	}