/*!
  * \brief Create a new BoundingVolume object.
  *
  * This method creates and returns a new BoundingVolume object, according to
  * the preferred BoundingVolume-type settings.
  *
  * \param parent The BvhNode that the BoundingVolume should be in. See \ref
  * setHierarchyNode.
  *
  * \return A new BoundingVolume object. The caller is responsible for
  * deleting it.
  */
 BoundingVolume* BoundingVolume::createBoundingVolume(World* world, BvhNode* parent) {
     if (!world) {
         throw NullPointerException("Parameter world");
     }
     BoundingVolume* bv = 0;
     switch (getCreateRigidBoundingVolumeType(world)) {
         case BV_TYPE_AABB:
             bv = new Aabb();
             break;
         case BV_TYPE_KDOP:
             bv = new Kdop();
             break;
         case BV_TYPE_SPHERE:
             bv = new BoundingSphere();
             break;
         case BV_TYPE_OBB:
             bv = new Obb();
             break;
         default:
             // TODO: exception!!
             std::cerr << dc_funcinfo << "FATAL ERROR: bounding volume type " << getCreateRigidBoundingVolumeType(world) << " not supported" << std::endl;
             exit(1);
             return 0;
     }
     bv->setHierarchyNode(parent);
     return bv;
 }
    /*!
     * \overload
     *
     * This method creates a new BoundingVolume as a copy of \p copy.
     */
    BoundingVolume* BoundingVolume::createBoundingVolume(World* world, const BoundingVolume* copy, BvhNode* parent) {
        if (!copy) {
            return createBoundingVolume(world, parent);
        }

        if (copy->getVolumeType() != getCreateRigidBoundingVolumeType(world)) {
            std::stringstream errormessage;
            errormessage << "ERROR: requested a copy of BV type "
                    << copy->getVolumeType()
                    << ", but expected type " << getCreateRigidBoundingVolumeType(world)
                    << std::endl;
            throw TypeMismatchException(errormessage.str());
        }

        BoundingVolume* bv = 0;
        switch (getCreateRigidBoundingVolumeType(world)) {
            case BV_TYPE_AABB:
                bv = new Aabb(*static_cast<const Aabb*>(copy));
                break;
            case BV_TYPE_KDOP:
                bv = new Kdop(*static_cast<const Kdop*>(copy));
                break;
            case BV_TYPE_SPHERE:
                bv = new BoundingSphere(*static_cast<const BoundingSphere*>(copy));
                break;
            case BV_TYPE_OBB:
                bv = new Obb(*static_cast<const Obb*>(copy));
                break;
            default:
                // TODO: exception!!
                std::cerr << dc_funcinfo << "FATAL ERROR: bounding volume type " << getCreateRigidBoundingVolumeType(world) << " not supported" << std::endl;
                exit(1);
                return 0;
        }
        bv->setHierarchyNode(parent);
        return bv;
    }