Exemplo n.º 1
0
// -------------------------------------------------------------------------------
// CREATETRIXELCHILD
// Check if trixel children structure already exists
// Assert for given <index>
// Check if select child does not exist
//   Create new vertices on side midpoints
//   Set vertices that defines the new subtrixel
// else display a message
// return the pointer
trixel* CreateTrixelChild(trixel* parent, unsigned short int& index)
{
    if (parent->_children == NULL)
    {
        llog::debug["ICoDF::CreateTrixelChild"]
            <<  "Trixel has no container for children" << std::endl;
        CreateTrixelChildren(parent);
    }

    assert(index < 4);

    if (parent->_children[index] == NULL)
    {
        parent->_children[index] = new trixel();
        InitTrixel(parent->_children[index]);
        parent->_children[index]->_HTMId = parent->_HTMId + std::to_string(index);
        Eigen::Vector3d* midPoints = ComputeTrixelMidpoints(parent);

        switch (index)
        {
            case 0:
                parent->_children[index]->_vertices[0] = parent->_vertices[0];
                parent->_children[index]->_vertices[1] = midPoints[2];
                parent->_children[index]->_vertices[2] = midPoints[1];
                break;
            case 1:
                parent->_children[index]->_vertices[0] = parent->_vertices[1];
                parent->_children[index]->_vertices[1] = midPoints[0];
                parent->_children[index]->_vertices[2] = midPoints[2];
                break;
            case 2:
                parent->_children[index]->_vertices[0] = parent->_vertices[2];
                parent->_children[index]->_vertices[1] = midPoints[1];
                parent->_children[index]->_vertices[2] = midPoints[0];
                break;
            case 3:
                parent->_children[index]->_vertices[0] = midPoints[0];
                parent->_children[index]->_vertices[1] = midPoints[1];
                parent->_children[index]->_vertices[2] = midPoints[2];
                break;
            default:
                llog::warn["ICoDF::CreateTrixelChild"]
                    << "Given <index> is out of bound" << std::endl;
                delete [] midPoints; 
                return NULL;
        }
        delete [] midPoints; 
    }
    else
    {
        llog::warn["ICoDF::CreateTrixelChild"]
            << "SubTrixel [" << parent->_HTMId << index << "] already exists"
            << std::endl;
    }

    return parent->_children[index];
}
Exemplo n.º 2
0
// -------------------------------------------------------------------------------
// CREATETRIXELCHILD
// Check if trixel children structure already exists
// Assert for given <index>
// Check if select child does not exist
//   Create new vertices on side midpoints
//   Set vertices that defines the new subtrixel
// else display a message
// return the pointer
trixel_t* ICoDF_HTM::CreateTrixelChild(trixel_t* parent, unsigned short int& index)
{
	if (parent->_children == NULL)
    {
		LS_ADDMSG(LogService::NOTICE, "ICoDF::CreateTrixelChild", "Trixel as no container for children");
		CreateTrixelChildren(parent);
    }
	
	assert(index < 4);
	
	if (parent->_children[index] == NULL)
    {
		std::stringstream tmp;
		parent->_children[index] = new trixel_t();
		InitTrixel(parent->_children[index]);
		tmp.str("");
		tmp << parent->_HTMId << index;
		parent->_children[index]->_HTMId = tmp.str();
        Vector3d midPoints[3];
		ComputeTrixelMidpoints(parent, midPoints);
		
		switch (index)
		{
			case 0:
				parent->_children[index]->_vertices[0] = parent->_vertices[0];
				parent->_children[index]->_vertices[1] = midPoints[2];
				parent->_children[index]->_vertices[2] = midPoints[1];
				break;
			case 1:
				parent->_children[index]->_vertices[0] = parent->_vertices[1];
				parent->_children[index]->_vertices[1] = midPoints[0];
				parent->_children[index]->_vertices[2] = midPoints[2];
				break;
			case 2:
				parent->_children[index]->_vertices[0] = parent->_vertices[2];
				parent->_children[index]->_vertices[1] = midPoints[1];
				parent->_children[index]->_vertices[2] = midPoints[0];
				break;
			case 3:
				parent->_children[index]->_vertices[0] = midPoints[0];
				parent->_children[index]->_vertices[1] = midPoints[1];
				parent->_children[index]->_vertices[2] = midPoints[2];
				break;
			default:
				LS_ADDMSG(LogService::FATAL, "ICoDF::CreateTrixelChild", "Given <index> is out of bound");
				return NULL;
		}
    }
	else
    {
		std::stringstream tmp;
		tmp << "SubTrixel [" << parent->_HTMId << index << "] already exists";
		LS_ADDMSG(LogService::NOTICE, "ICoDF::CreateTrixelChild", tmp.str());
    }
	
	return parent->_children[index];
}
Exemplo n.º 3
0
// AssignPoint
void ICoDF_HTM::HTM::AssignPoint(PointInfo_t* pt)
{
    unsigned int & nbChildObject = pt->_current->_nbChildObject;
    trixel_t**& children = pt->_current->_children;
    
	if (nbChildObject > 1)
    {
		unsigned short int index = GetIndex(pt->_current, pt);
		if (index == (unsigned int short)~0)
			return;
		
		if (children[index] == NULL)
			children[index] = CreateTrixelChild(pt->_current, index);
        pt->_current = children[index];
        this->_pointList.push(pt);
		
    }
	else if (nbChildObject == 1)
    {
		++nbChildObject;
		unsigned short int indexCurrent = GetIndex(pt->_current, pt);
		PointInfo_t* old = pt->_current->_info;
		pt->_current->_info = NULL;
		unsigned short int indexOld = GetIndex(old->_current, old);
		if (indexCurrent == (unsigned short int)~0 ||
            indexOld == (unsigned short int)~0)
			return;
		
		if (children == NULL)
		{
			CreateTrixelChildren(pt->_current);
			CreateTrixelChild(pt->_current, indexOld);
			if (indexOld != indexCurrent)
				CreateTrixelChild(pt->_current, indexCurrent);
		}
		old->_current = children[indexOld];
		this->_pointList.push(pt);
		this->_pointList.push(old);
		pt->_current = children[indexCurrent];
    }
	else if (nbChildObject == 0)
    {
		pt->_current->_info = pt;
		nbChildObject = 1;
    }
}
Exemplo n.º 4
0
// AssignPoint
std::string ICoDF_HTM::HTM::AssignPoint(PointInfo_t* pt)
{
  if (pt->_current->_nbChildObject > 1)
    {
      unsigned short int index = GetIndex(pt->_current, pt);
      if (index == (unsigned int short)~0)
	{
	  return std::string("error");
	}

      if (pt->_current->_children[index] != NULL)
	{
  pt->_current = pt->_current->_children[index];

	  this->_pointList.push(pt);
	}
      else
	{
	  pt->_current->_children[index] = CreateTrixelChild(pt->_current, index);
	  pt->_current = pt->_current->_children[index];
	  this->_pointList.push(pt);
	}
    }
  else if (pt->_current->_nbChildObject == 1)
    {
      ++pt->_current->_nbChildObject;
      unsigned short int indexCurrent = GetIndex(pt->_current, pt);
      PointInfo_t* old = pt->_current->_info;
      pt->_current->_info = NULL;
      unsigned short int indexOld = GetIndex(old->_current, old);
      if (indexCurrent == (unsigned short int)~0)
	{
	  return std::string("");
	}
      if (indexOld == (unsigned short int)~0)
	{
	  return std::string("");
	}
      if (pt->_current->_children == NULL)
	{
	  CreateTrixelChildren(pt->_current);
	  CreateTrixelChild(pt->_current, indexOld);
	  if (indexOld != indexCurrent)
	    CreateTrixelChild(pt->_current, indexCurrent);
	  auto it = this->_points.find(pt->_current->_HTMId);
	  this->_points.erase(it);
	}
      old->_current = pt->_current->_children[indexOld];
      this->_pointList.push(pt);
      this->_pointList.push(old);
      pt->_current = pt->_current->_children[indexCurrent];
    }
  else if (pt->_current->_nbChildObject == 0)
    {
      pt->_current->_info = pt;
      this->_points[pt->_current->_HTMId] = pt;
      pt->_current->_nbChildObject = 1;
      return pt->_current->_HTMId;
    }
  return pt->_current->_HTMId;
}