示例#1
0
文件: View.cpp 项目: samsaradog/tttt
string View::show(const Player* human_p, 
                  const Player* computer_p,
                  const Game*   game_p) throw()
{
  string return_value = " ";
  return_value += getRepresentation(1, human_p, computer_p, game_p);
  return_value += " | ";
  return_value += getRepresentation(2, human_p, computer_p, game_p);
  return_value += " | ";
  return_value += getRepresentation(3, human_p, computer_p, game_p);
  return_value += " \n";
  return_value += "-----------\n ";
  return_value += getRepresentation(4, human_p, computer_p, game_p);
  return_value += " | ";
  return_value += getRepresentation(5, human_p, computer_p, game_p);
  return_value += " | ";
  return_value += getRepresentation(6, human_p, computer_p, game_p);
  return_value += " \n";
  return_value += "-----------\n ";
  return_value += getRepresentation(7, human_p, computer_p, game_p);
  return_value += " | ";
  return_value += getRepresentation(8, human_p, computer_p, game_p);
  return_value += " | ";
  return_value += getRepresentation(9, human_p, computer_p, game_p);
  return_value += " \n";

  return return_value;
}
示例#2
0
Vec3 Entity::getCenteredPosition() const {
	Vec3 position = getPosition();
	auto &rep = getRepresentation();
	position.x += rep.size.x / 2;
	position.y += rep.size.y / 2;

	return position;
}
Math::RigidTransform3d Fem2DLocalization::getElementPose()
{
	auto femRepresentation = std::static_pointer_cast<Fem2DRepresentation>(getRepresentation());
	auto position = getLocalPosition();
	auto femElement = femRepresentation->getFemElement(getLocalPosition().index);
	const auto& nodeIds = femElement->getNodeIds();
	std::array<Math::Vector3d, 3> nodePositions =
		{femRepresentation->getCurrentState()->getPosition(nodeIds[0]),
		 femRepresentation->getCurrentState()->getPosition(nodeIds[1]),
		 femRepresentation->getCurrentState()->getPosition(nodeIds[2])};

	Math::Vector3d edge, normal, binormal;
	edge = (nodePositions[1] - nodePositions[0]).normalized();
	normal = (nodePositions[2] - nodePositions[0]).cross(edge).normalized();
	binormal = edge.cross(normal);
	Math::Matrix33d rotation;
	rotation << edge, normal, binormal;

	return Math::makeRigidTransform(rotation, (nodePositions[0] + nodePositions[1] + nodePositions[2]) / 3.0);
}
示例#4
0
int StreamStore::getInformation(std::shared_ptr<InformationSpecification> request,
                                std::vector<std::shared_ptr<InformationElement<GContainer>>> &outInfo,
                                bool useTransfromation)
{
  int count = 0;

  for (auto &stream : this->collections)
  {
    auto gstream = std::static_pointer_cast<InformationStream<GContainer>>(stream);

    auto infoSpec = stream->getDescription()->getInformationSpecification();

    if (request->getEntity() != "*" && request->getEntity() != infoSpec->getEntity())
    {
      continue;
    }
    if (request->getEntityType() != infoSpec->getEntityType())
    {
      continue;
    }
    if (request->getScope() != infoSpec->getScope())
    {
      continue;
    }
    if (request->getRepresentation() != infoSpec->getRepresentation())
    {
      if (useTransfromation && request->getRelatedEntity() == ""
          && infoSpec->getRelatedEntity() == "")
      {
        // check if transformation exists
        auto rep = this->gcontainerFactory->getTransformation(infoSpec->getRepresentation(),
                                                              request->getRepresentation());

        if (rep == nullptr)
          continue;

        std::shared_ptr<GContainer> input[1];
        input[0] = gstream->getLast()->getInformation();
        auto transInfo = rep->transform(input);

        if (transInfo == nullptr)
          continue;

        auto spec = std::make_shared<InformationSpecification>(infoSpec->getEntity(),
                                                               infoSpec->getEntityType(),
                                                               infoSpec->getScope(),
                                                               request->getRepresentation(),
                                                               infoSpec->getRelatedEntity());
        auto element = std::make_shared<InformationElement<GContainer>>(spec, transInfo);
        outInfo.push_back(element);
        ++count;
      }

      continue;
    }
    if (request->getRelatedEntity() != infoSpec->getRelatedEntity())
    {
      continue;
    }

    outInfo.push_back(gstream->getLast());
    ++count;
  }

  return count;
}