BoxShape.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_MATH_BOXSHAPE_H
#define SURGSIM_MATH_BOXSHAPE_H
#include <array>
#include "SurgSim/Framework/ObjectFactory.h"
#include "SurgSim/Math/Shape.h"
namespace SurgSim
{
namespace Math
{
SURGSIM_STATIC_REGISTRATION(BoxShape);
class BoxShape: public Shape
{
public:
explicit BoxShape(double sizeX = 0.0, double sizeY = 0.0, double sizeZ = 0.0);
SURGSIM_CLASSNAME(SurgSim::Math::BoxShape);
int getType() const override;
Vector3d getSize() const;
double getSizeX() const;
double getSizeY() const;
double getSizeZ() const;
double getVolume() const override;
Vector3d getCenter() const override;
Matrix33d getSecondMomentOfVolume() const override;
Vector3d getVertex(const int i) const;
const std::array<Vector3d, 8>& getVertices() const;
bool isValid() const override;
protected:
// Setters in 'protected' sections are for serialization purpose only.
void setSizeX(double sizeX);
void setSizeY(double sizeY);
void setSizeZ(double sizeZ);
private:
void calculateVertices();
void updateAabb();
Vector3d m_size;
std::array<Vector3d, 8> m_vertices;
};
}; // Math
}; // SurgSim
#endif // SURGSIM_MATH_BOXSHAPE_H
SurgSim::Math::BoxShape::calculateVertices
void calculateVertices()
Function that calculates the box vertices.
Definition: BoxShape.cpp:111
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Math::BoxShape::getSizeX
double getSizeX() const
Get size in X direction.
Definition: BoxShape.cpp:45
SurgSim::Math::BoxShape::getType
int getType() const override
Definition: BoxShape.cpp:35
SurgSim::Math::BoxShape::getSizeZ
double getSizeZ() const
Get size in Z direction.
Definition: BoxShape.cpp:55
SurgSim::Math::BoxShape
Box shape: box centered on (0 0 0), aligned with the axis with different sizes along X...
Definition: BoxShape.h:33
SurgSim::Math::BoxShape::setSizeZ
void setSizeZ(double sizeZ)
Set size in Z direction.
Definition: BoxShape.cpp:72
SurgSim::Math::BoxShape::getSizeY
double getSizeY() const
Get size in Y direction.
Definition: BoxShape.cpp:50
SurgSim::Math::BoxShape::setSizeY
void setSizeY(double sizeY)
Set size in Y direction.
Definition: BoxShape.cpp:66
ObjectFactory.h
SurgSim::Math::BoxShape::isValid
bool isValid() const override
Definition: BoxShape.cpp:137
SurgSim::Math::BoxShape::setSizeX
void setSizeX(double sizeX)
Set size in X direction.
Definition: BoxShape.cpp:60
SurgSim::Math::BoxShape::BoxShape
BoxShape(double sizeX=0.0, double sizeY=0.0, double sizeZ=0.0)
Constructor.
Definition: BoxShape.cpp:24
SurgSim::Math::BoxShape::getVolume
double getVolume() const override
Get the volume of the shape.
Definition: BoxShape.cpp:78
SurgSim::Math::BoxShape::getVertices
const std::array< Vector3d, 8 > & getVertices() const
Function that returns the local vertices&#39; location.
Definition: BoxShape.cpp:106
SurgSim::Math::BoxShape::getCenter
Vector3d getCenter() const override
Get the volumetric center of the shape.
Definition: BoxShape.cpp:83
SurgSim::Math::BoxShape::m_vertices
std::array< Vector3d, 8 > m_vertices
The box vertices.
Definition: BoxShape.h:112
SurgSim::Math::BoxShape::getSecondMomentOfVolume
Matrix33d getSecondMomentOfVolume() const override
Get the second central moment of the volume, commonly used to calculate the moment of inertia matrix...
Definition: BoxShape.cpp:88
SurgSim::Math::BoxShape::getVertex
Vector3d getVertex(const int i) const
Function that returns the local vertex location, given an index.
Definition: BoxShape.cpp:101
SurgSim::Math::Shape::Matrix33d
::SurgSim::Math::Matrix33d Matrix33d
Definition: Shape.h:69
SurgSim::Math::BoxShape::getSize
Vector3d getSize() const
Get size of the box.
Definition: BoxShape.cpp:40
SurgSim::Math::BoxShape::m_size
Vector3d m_size
The box sizes along the 3 axis respectively {X,Y,Z}.
Definition: BoxShape.h:109
Shape.h
SurgSim::Math::BoxShape::updateAabb
void updateAabb()
Update the local aabb for this box.
Definition: BoxShape.cpp:130
SurgSim::Math::Vector3d
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57
SurgSim::Math::BoxShape::SURGSIM_CLASSNAME
SURGSIM_CLASSNAME(SurgSim::Math::BoxShape)
SurgSim::Math::Shape
Generic rigid shape class defining a shape.
Definition: Shape.h:65