Commit a5f419ce authored by Sreekanth Arikatla's avatar Sreekanth Arikatla
Browse files

STYLE: Style enforcement and add comments

Style enforcement and add comments over the entire code
parent ad9df1c0
......@@ -22,12 +22,17 @@
#ifndef imstkCollisionData_h
#define imstkCollisionData_h
//#include <pair>
// imstk
#include "imstkMath.h"
namespace imstk {
namespace imstk
{
///
/// \struct PositionDirectionCollisionData
///
/// \brief Point-penetration depth collision data
///
struct PositionDirectionCollisionData
{
Vec3d posA;
......@@ -36,12 +41,22 @@ struct PositionDirectionCollisionData
double penetrationDepth;
};
///
/// \struct MeshToAnalyticalPointDepthCollisionData
///
/// \brief Mesh to analytical point-penetration depth collision data
///
struct MeshToAnalyticalPointDepthCollisionData
{
int nodeId;
Vec3d penetrationVector;
};
///
/// \struct VertexTriangleCollisionData
///
/// \brief Vertex-triangle collision data
///
struct VertexTriangleCollisionData
{
size_t vertexIdA;
......@@ -56,6 +71,11 @@ struct VertexTriangleCollisionData
}
};
///
/// \struct TriangleVertexCollisionData
///
/// \brief Triangle-vertex collision data
///
struct TriangleVertexCollisionData
{
size_t triIdA;
......@@ -70,6 +90,11 @@ struct TriangleVertexCollisionData
}
};
///
/// \struct EdgeEdgeCollisionData
///
/// \brief Edge-Edge collision data
///
struct EdgeEdgeCollisionData
{
std::pair<size_t, size_t> edgeIdA;
......@@ -84,6 +109,11 @@ struct EdgeEdgeCollisionData
}
};
///
/// \struct CollisionData
///
/// \brief Class that is the holder of all types of collision data
///
class CollisionData
{
public:
......@@ -103,6 +133,7 @@ public:
std::vector<MeshToAnalyticalPointDepthCollisionData> PDMeshAnaColData;
};
}
#endif // ifndef imstkCollisionData_h
......@@ -24,15 +24,24 @@
#include <memory>
namespace imstk {
namespace imstk
{
class CollidingObject;
class CollisionData;
///
/// \class CollisionDetection
///
/// \brief Base class for all collsion detection classes
///
class CollisionDetection
{
public:
///
/// \brief Type of the collision detection
///
enum class Type
{
PlaneToSphere,
......@@ -78,10 +87,11 @@ public:
protected:
Type m_type; //!< Collision detection algorithm type
CollisionData& m_colData; //!< Collision data
Type m_type; ///< Collision detection algorithm type
CollisionData& m_colData; ///< Collision data
};
}
#endif // ifndef imstkCollisionDetection_h
......@@ -22,17 +22,24 @@
#ifndef imstkMeshToMeshCD_h
#define imstkMeshToMeshCD_h
#include "imstkCollisionDetection.h"
// std library
#include <memory>
// imstk
#include "imstkCollisionDetection.h"
#include "DeformModel.h"
#include <memory>
namespace imstk {
namespace imstk
{
class SurfaceMesh;
class CollisionData;
///
/// \class MeshToMeshCD
///
/// \brief Base class for mesh-to-mesh collision detection
///
class MeshToMeshCD : public CollisionDetection
{
public:
......@@ -73,11 +80,12 @@ private:
static void VFCallbackB(unsigned int fidB, unsigned int vidA,
float t, void *userdata);
std::shared_ptr<SurfaceMesh> m_meshA;
std::shared_ptr<SurfaceMesh> m_meshB;
std::shared_ptr<DeformModel> m_modelA;
std::shared_ptr<DeformModel> m_modelB;
std::shared_ptr<SurfaceMesh> m_meshA; ///> Mesh A
std::shared_ptr<SurfaceMesh> m_meshB; ///> Mesh B
std::shared_ptr<DeformModel> m_modelA; ///>
std::shared_ptr<DeformModel> m_modelB; ///>
};
}
#endif // ifndef imstkMeshToMeshCD_h
......@@ -22,16 +22,22 @@
#ifndef imstkPlaneToSphereCD_h
#define imstkPlaneToSphereCD_h
#include "imstkCollisionDetection.h"
#include <memory>
namespace imstk {
#include "imstkCollisionDetection.h"
namespace imstk
{
class Plane;
class Sphere;
class CollisionData;
///
/// \class PlaneToSphereCD
///
/// \brief Plane to sphere collision detection
///
class PlaneToSphereCD : public CollisionDetection
{
public:
......@@ -59,10 +65,10 @@ public:
private:
std::shared_ptr<Plane> m_planeA;
std::shared_ptr<Sphere> m_sphereB;
std::shared_ptr<Plane> m_planeA; ///>
std::shared_ptr<Sphere> m_sphereB; ///>
};
}
#endif // ifndef imstkPlaneToSphereCD_h
......@@ -22,15 +22,21 @@
#ifndef imstkSphereToSphereCD_h
#define imstkSphereToSphereCD_h
#include "imstkCollisionDetection.h"
#include <memory>
namespace imstk {
#include "imstkCollisionDetection.h"
namespace imstk
{
class Sphere;
class CollisionData;
///
/// \class SphereToSphereCD
///
/// \brief Sphere to sphere collision detection
///
class SphereToSphereCD : public CollisionDetection
{
public:
......@@ -58,10 +64,10 @@ public:
private:
std::shared_ptr<Sphere> m_sphereA;
std::shared_ptr<Sphere> m_sphereB;
std::shared_ptr<Sphere> m_sphereA; ///>
std::shared_ptr<Sphere> m_sphereB; ///>
};
}
#endif // ifndef imstkSphereToSphereCD_h
......@@ -22,25 +22,38 @@
#ifndef imstkCollisionHandling_h
#define imstkCollisionHandling_h
// Std library
#include <memory>
// imstk
#include "imstkCollidingObject.h"
#include "imstkCollisionData.h"
namespace imstk {
namespace imstk
{
class InteractionPair;
///
/// \class CollisionHandling
///
/// \brief Base class for all collision handling classes
///
class CollisionHandling
{
public:
///
/// \brief Type of the collision handling
///
enum class Type
{
None,
Penalty
};
///
/// \brief Direction of the collision handling
///
enum class Side
{
A,
......@@ -91,6 +104,7 @@ protected:
const CollisionData& m_colData; //!< Collision data
};
}
#endif // ifndef imstkCollisionHandling_h
......@@ -22,15 +22,23 @@
#ifndef imstkPenaltyMeshToRigidCH_h
#define imstkPenaltyMeshToRigidCH_h
#include "imstkCollisionHandling.h"
// std library
#include <memory>
namespace imstk {
// imstk
#include "imstkCollisionHandling.h"
namespace imstk
{
class CollidingObject;
class CollisionData;
///
/// \class PenaltyMeshToRigidCH
///
/// \brief Mesh-to-Rigid collision handling based on penalty approach
///
class PenaltyMeshToRigidCH : public CollisionHandling
{
public:
......@@ -59,8 +67,9 @@ private:
std::shared_ptr<CollidingObject> m_object; ///> The mesh object under collision
double m_stiffness; ///> Stiffness of contact
double m_damping; ///> Damping of the contact
double m_damping; ///> Damping of the contact
};
}
#endif // ifndef imstkPenaltyMeshToRigidCH_h
......@@ -22,15 +22,23 @@
#ifndef imstkPenaltyRigidCH_h
#define imstkPenaltyRigidCH_h
#include "imstkCollisionHandling.h"
// std library
#include <memory>
namespace imstk {
// imstk
#include "imstkCollisionHandling.h"
namespace imstk
{
class CollidingObject;
class CollisionData;
///
/// \class PenaltyRigidCH
///
/// \brief Penalty-to-rigid collision handling
///
class PenaltyRigidCH : public CollisionHandling
{
public:
......@@ -59,9 +67,10 @@ public:
private:
std::shared_ptr<CollidingObject> m_obj;
std::shared_ptr<CollidingObject> m_obj; ///>
};
}
#endif // ifndef imstkPenaltyRigidCH_h
......@@ -22,16 +22,24 @@
#ifndef imstkInteractionPair_h
#define imstkInteractionPair_h
// std library
#include <map>
#include <memory>
// imstk
#include "imstkCollidingObject.h"
#include "imstkCollisionDetection.h"
#include "imstkCollisionData.h"
#include "imstkCollisionHandling.h"
namespace imstk {
namespace imstk
{
///
/// \class InteractionPair
///
/// \brief This class implements collision interaction between two given scene objects
///
class InteractionPair
{
using ObjectsPair = std::pair<std::shared_ptr<CollidingObject>, std::shared_ptr<CollidingObject>>;
......@@ -74,14 +82,15 @@ public:
protected:
ObjectsPair m_objects; //!< Colliding objects
std::shared_ptr<CollisionDetection> m_colDetect; //!< Collision detection algorithm
CollisionData m_colData; //!< Common Collision Data
std::shared_ptr<CollisionHandling> m_colHandlingA; //!< Collision handling algorithm for A
std::shared_ptr<CollisionHandling> m_colHandlingB; //!< Collision handling algorithm for B
ObjectsPair m_objects; ///< Colliding objects
std::shared_ptr<CollisionDetection> m_colDetect; ///< Collision detection algorithm
CollisionData m_colData; ///< Common Collision Data
std::shared_ptr<CollisionHandling> m_colHandlingA; ///< Collision handling algorithm for A
std::shared_ptr<CollisionHandling> m_colHandlingB; ///< Collision handling algorithm for B
bool m_valid;
};
}
#endif // ifndef imstkInteractionPair_h
......@@ -23,7 +23,8 @@
#include <g3log/g3log.hpp>
namespace imstk {
namespace imstk
{
bool isColorRangeCorrect( double c )
{
......
......@@ -24,7 +24,14 @@
#include <iostream>
namespace imstk {
namespace imstk
{
///
/// \struct Color
///
/// \brief Color in RGB space
///
struct Color
{
union
......@@ -39,29 +46,53 @@ struct Color
};
};
///
/// \brief Constructor
///
Color();
Color(double r, double g, double b, double a = 1.0);
///
/// \brief Equality operator
///
Color &operator=(const Color &p_color);
///
/// \brief Bitwise operator
///
friend std::ostream& operator<<(std::ostream& os, const Color& c);
///
/// \brief returns the color value given with the index
///
double operator()(int p_i) const;
///
/// \brief Dark ratio. the valu is between 0 and 1.0
///
void darken(double p_darkFactor);
///
/// \brief lighten the color
///
void lighten(double p_darkFactor);
///
/// \brief set RGB color
///
void setValue(double p_red, double p_green, double p_blue, double p_alpha = 1.0);
///
/// \brief get RGB color
///
void getValue(double color[4]);
///
/// \brief get RGB color
///
const double *getValue() const;
/// Various commonly used colors
static Color White;
static Color Black;
static Color DarkGray;
......@@ -72,6 +103,6 @@ struct Color
static Color Pink;
static Color Yellow;
};
}
}
#endif // ifndef imstkColor_h
......@@ -21,7 +21,9 @@
#include "imstkLogger.h"
namespace imstk {
namespace imstk
{
stdSink::FG_Color
stdSink::GetColor(const LEVELS level) const
{
......@@ -64,4 +66,5 @@ LogUtility::createLogger(std::string name, std::string path)
std2::make_unique<stdSink>(), &stdSink::ReceiveLogMessage);
g3::initializeLogging(m_g3logWorker.get());
}
}
\ No newline at end of file
......@@ -28,8 +28,16 @@
#include "g3log/logmessage.hpp"
#include "g3log/logworker.hpp"
namespace imstk {
struct stdSink {
namespace imstk
{
///
/// \struct stdSink
///
/// \brief
///
struct stdSink
{
// Linux xterm color
// http://stackoverflow.com/questions/2616906/how-do-i-output-coloured-text-to-a-linux-terminal
enum FG_Color { YELLOW = 33, RED = 31, GREEN = 32, WHITE = 97 };
......@@ -38,13 +46,19 @@ struct stdSink {
void ReceiveLogMessage(g3::LogMessageMover logEntry);
};
struct LogUtility {
///
/// \struct LogUtility
///
/// \brief
///
struct LogUtility
{
void createLogger(std::string name, std::string path);
std::unique_ptr<g3::LogWorker> m_g3logWorker;
std::unique_ptr<g3::SinkHandle<g3::FileSink> >m_fileSinkHandle;
std::unique_ptr<g3::SinkHandle<stdSink> > m_stdSinkHandle;
};
}
}
#endif // ifndef imstkLogUtility_h
......@@ -27,7 +27,8 @@
#include <Eigen/Geometry>
#include <Eigen/Sparse>
namespace imstk {
namespace imstk
{
// 2D vector
using Vec2f = Eigen::Vector2f;
......@@ -81,7 +82,7 @@ using RigidTransform3d = Eigen::Isometry3d;
using AffineTransform3f = Eigen::Affine3f;
using AffineTransform3d = Eigen::Affine3d;
// Handy cartesian vectors in 3d
// Handy Cartesian vectors in 3d
#define UP_VECTOR Vec3d(0.0, 1.0, 0.0)
#define DOWN_VECTOR Vec3d(0, -1, 0)
#define RIGHT_VECTOR Vec3d(1, 0, 0)
......@@ -90,7 +91,7 @@ using AffineTransform3d = Eigen::Affine3d;
#define BACKWARD_VECTOR Vec3d(0, 0, 1)
#define WORLD_ORIGIN Vec3d::Zero()
// Some commonly used math constants
/// Some commonly used math constants
const double PI = 3.14159265358979323846;
const double PI_2 = 1.57079632679489661923;
const double PI_4 = 0.785398163397448309616;
......@@ -111,6 +112,6 @@ const double MAX_F = std::numeric_limits<float>::max();
const double MIN_F = std::numeric_limits<float>::min();
const double MACHINE_PRECISION = std::numeric_limits<double>::denorm_min();
}
}
#endif // ifndef imstkMath_h
......@@ -25,7 +25,9 @@
#include "g3log/g3log.hpp"
namespace imstk {
namespace imstk
{
void
Module::start()
{
......@@ -132,4 +134,5 @@ Module::setLoopDelay(int milliseconds)
{
m_loopDelay = milliseconds;
}
}
......@@ -26,9 +26,12 @@
#include <thread>
#include <atomic>
namespace imstk
namespace imstk
{
///
/// \brief Enumerations for the status of the module
///
enum class ModuleStatus
{
STARTING,
......@@ -39,37 +42,89 @@ enum class ModuleStatus
INACTIVE