示例#1
0
static void reorderNodes(tree *tr, nodeptr *np, nodeptr p, int *count)
{
  int i, found = 0;

  if((p->number <= tr->mxtips))    
    return;
  else
    {              
      for(i = tr->mxtips + 1; (i <= (tr->mxtips + tr->mxtips - 1)) && (found == 0); i++)
	{
	  if (p == np[i] || p == np[i]->next || p == np[i]->next->next)
	    {
	      if(p == np[i])			       
		tr->nodep[*count + tr->mxtips + 1] = np[i];		 		
	      else
		{
		  if(p == np[i]->next)		  
		    tr->nodep[*count + tr->mxtips + 1] = np[i]->next;		     	   
		  else		   
		    tr->nodep[*count + tr->mxtips + 1] = np[i]->next->next;		    		    
		}

	      found = 1;	      	     
	      *count = *count + 1;
	    }
	}            
     
      assert(found != 0);

      reorderNodes(tr, np, p->next->back, count);     
      reorderNodes(tr, np, p->next->next->back, count);                
    }
}
示例#2
0
int main (int argc, char* argv[])
{
	LOGOG_INITIALIZE();
	logog::Cout* logogCout = new logog::Cout;
	BaseLib::LogogSimpleFormatter* formatter = new BaseLib::LogogSimpleFormatter;
	logogCout->SetFormatter(*formatter);

	TCLAP::CmdLine cmd("Reordering of mesh nodes to make OGS Data Explorer 5 meshes compatible with OGS6.\n" \
	                   "Method 1 is the re-ordering between DataExplorer 5 and DataExplorer 6 meshes,\n" \
	                   "Method 2 is the re-ordering with and without InSitu-Lib in OGS6.",
	                   ' ', "0.1");
	TCLAP::UnlabeledValueArg<std::string> input_mesh_arg("input_mesh",
	                                                     "the name of the input mesh file",
	                                                     true, "", "oldmesh.msh");
	cmd.add(input_mesh_arg);
	TCLAP::UnlabeledValueArg<std::string> output_mesh_arg("output_mesh",
	                                                      "the name of the output mesh file",
	                                                      true, "", "newmesh.vtu");
	cmd.add(output_mesh_arg);
	TCLAP::ValueArg<int> method_arg("m", "method", "reordering method selection", false,  1, "value");

	cmd.add(method_arg);
	cmd.parse(argc, argv);

	MeshLib::Mesh* mesh (FileIO::readMeshFromFile(input_mesh_arg.getValue().c_str()));

	INFO("Reordering nodes... ");
	if (!method_arg.isSet() || method_arg.getValue() == 1)
		reorderNodes(const_cast<std::vector<MeshLib::Element*>&>(mesh->getElements()));
	else if (method_arg.getValue() == 2)
		reorderNodes2(const_cast<std::vector<MeshLib::Element*>&>(mesh->getElements()));
	else
	{
		ERR ("Unknown re-ordering method. Exit program...");
		return 1;
	}

	FileIO::VtuInterface writer(mesh);
	writer.writeToFile(output_mesh_arg.getValue().c_str());

	INFO("VTU file written.");

	delete formatter;
	delete logogCout;
	LOGOG_SHUTDOWN();

	return 0;
}
示例#3
0
static void nodeRectifierPars(tree *tr)
{
  nodeptr *np = (nodeptr *)malloc(2 * tr->mxtips * sizeof(nodeptr));
  int i;
  int count = 0;
  
  tr->start       = tr->nodep[1];
  tr->rooted      = FALSE;

  /* TODO why is tr->rooted set to FALSE here ?*/
  
  for(i = tr->mxtips + 1; i <= (tr->mxtips + tr->mxtips - 1); i++)
    np[i] = tr->nodep[i];           
  
  reorderNodes(tr, np, tr->start->back, &count); 

 
  rax_free(np);
}