25 #ifndef WGRIDREGULAR3D_H
26 #define WGRIDREGULAR3D_H
34 #include <boost/array.hpp>
38 #include "../common/WBoundingBox.h"
39 #include "../common/WCondition.h"
40 #include "../common/WDefines.h"
41 #include "../common/WProperties.h"
42 #include "../common/exceptions/WOutOfBounds.h"
43 #include "../common/exceptions/WPreconditionNotMet.h"
44 #include "../common/math/WLinearAlgebraFunctions.h"
45 #include "../common/math/WMatrix.h"
47 #include "WGridTransformOrtho.h"
57 template<
typename T >
76 typedef std::shared_ptr< WGridRegular3DTemplate >
SPtr;
81 typedef std::shared_ptr< const WGridRegular3DTemplate >
ConstSPtr;
94 template<
typename InputType >
121 double scaleX,
double scaleY,
double scaleZ );
304 int getVoxelNum(
const size_t x,
const size_t y,
const size_t z )
const;
415 const T margin = 0.0 )
const;
548 template<
typename T >
549 template<
typename InputType >
551 WGrid( rhs.m_nbPosX * rhs.m_nbPosY * rhs.m_nbPosZ ),
552 m_nbPosX( rhs.m_nbPosX ),
553 m_nbPosY( rhs.m_nbPosY ),
554 m_nbPosZ( rhs.m_nbPosZ ),
555 m_transform( rhs.m_transform )
560 template<
typename T >
563 :
WGrid( nbPosX * nbPosY * nbPosZ ),
567 m_transform( transform )
572 template<
typename T >
574 double scaleX,
double scaleY,
double scaleZ ):
575 WGrid( nbPosX * nbPosY * nbPosZ ),
584 template<
typename T >
590 template<
typename T >
596 template<
typename T >
602 template<
typename T >
605 return m_transform.getOffsetX();
608 template<
typename T >
611 return m_transform.getOffsetY();
614 template<
typename T >
617 return m_transform.getOffsetZ();
620 template<
typename T >
623 return m_transform.getDirectionX();
626 template<
typename T >
629 return m_transform.getDirectionY();
632 template<
typename T >
635 return m_transform.getDirectionZ();
638 template<
typename T >
641 return m_transform.getUnitDirectionX();
644 template<
typename T >
647 return m_transform.getUnitDirectionY();
650 template<
typename T >
653 return m_transform.getUnitDirectionZ();
656 template<
typename T >
659 return m_transform.getOrigin();
662 template<
typename T >
665 return m_transform.getTransformationMatrix();
668 template<
typename T >
673 result.
expandBy( m_transform.positionToWorldSpace(
Vector3Type( getNbCoordsX() - 1, 0.0, 0.0 ) ) );
674 result.
expandBy( m_transform.positionToWorldSpace(
Vector3Type( 0.0, getNbCoordsY() - 1, 0.0 ) ) );
675 result.
expandBy( m_transform.positionToWorldSpace(
Vector3Type( getNbCoordsX() - 1, getNbCoordsY() - 1, 0.0 ) ) );
676 result.
expandBy( m_transform.positionToWorldSpace(
Vector3Type( 0.0, 0.0, getNbCoordsZ() - 1 ) ) );
677 result.
expandBy( m_transform.positionToWorldSpace(
Vector3Type( getNbCoordsX() - 1, 0.0, getNbCoordsZ() - 1 ) ) );
678 result.
expandBy( m_transform.positionToWorldSpace(
Vector3Type( 0.0, getNbCoordsY() - 1, getNbCoordsZ() - 1 ) ) );
679 result.
expandBy( m_transform.positionToWorldSpace(
Vector3Type( getNbCoordsX() - 1, getNbCoordsY() - 1, getNbCoordsZ() - 1 ) ) );
683 template<
typename T >
688 result.
expandBy( m_transform.positionToWorldSpace(
Vector3Type( getNbCoordsX(), 0.0, 0.0 ) ) );
689 result.
expandBy( m_transform.positionToWorldSpace(
Vector3Type( 0.0, getNbCoordsY(), 0.0 ) ) );
690 result.
expandBy( m_transform.positionToWorldSpace(
Vector3Type( getNbCoordsX(), getNbCoordsY(), 0.0 ) ) );
691 result.
expandBy( m_transform.positionToWorldSpace(
Vector3Type( 0.0, 0.0, getNbCoordsZ() ) ) );
692 result.
expandBy( m_transform.positionToWorldSpace(
Vector3Type( getNbCoordsX(), 0.0, getNbCoordsZ() ) ) );
693 result.
expandBy( m_transform.positionToWorldSpace(
Vector3Type( 0.0, getNbCoordsY(), getNbCoordsZ() ) ) );
694 result.
expandBy( m_transform.positionToWorldSpace(
Vector3Type( getNbCoordsX(), getNbCoordsY(), getNbCoordsZ() ) ) );
698 template<
typename T >
703 result.
expandBy( m_transform.positionToWorldSpace(
Vector3Type( getNbCoordsX() - 0.5, -0.5, -0.5 ) ) );
704 result.
expandBy( m_transform.positionToWorldSpace(
Vector3Type( -0.5, getNbCoordsY() - 0.5, -0.5 ) ) );
705 result.
expandBy( m_transform.positionToWorldSpace(
Vector3Type( getNbCoordsX() - 0.5, getNbCoordsY() - 0.5, -0.5 ) ) );
706 result.
expandBy( m_transform.positionToWorldSpace(
Vector3Type( -0.5, -0.5, getNbCoordsZ() - 0.5 ) ) );
707 result.
expandBy( m_transform.positionToWorldSpace(
Vector3Type( getNbCoordsX() - 0.5, -0.5, getNbCoordsZ() - 0.5 ) ) );
708 result.
expandBy( m_transform.positionToWorldSpace(
Vector3Type( -0.5, getNbCoordsY() - 0.5, getNbCoordsZ() - 0.5 ) ) );
709 result.
expandBy( m_transform.positionToWorldSpace(
Vector3Type( getNbCoordsX() - 0.5, getNbCoordsY() - 0.5, getNbCoordsZ() - 0.5 ) ) );
713 template<
typename T >
716 return getPosition( i % m_nbPosX, ( i / m_nbPosX ) % m_nbPosY, i / ( m_nbPosX * m_nbPosY ) );
719 template<
typename T >
722 unsigned int iZ )
const
725 return m_transform.positionToWorldSpace( i );
728 template<
typename T >
731 Vector3Type r( m_transform.positionToGridSpace( point ) );
734 r[0] = r[0] / m_nbPosX;
735 r[1] = r[1] / m_nbPosY;
736 r[2] = r[2] / m_nbPosZ;
739 r[0] += 0.5 / m_nbPosX;
740 r[1] += 0.5 / m_nbPosY;
741 r[2] += 0.5 / m_nbPosZ;
746 template<
typename T >
760 int xVoxelCoord = getXVoxelCoord( pos );
761 int yVoxelCoord = getYVoxelCoord( pos );
762 int zVoxelCoord = getZVoxelCoord( pos );
763 if( xVoxelCoord == -1 || yVoxelCoord == -1 || zVoxelCoord == -1 )
768 + yVoxelCoord * ( m_nbPosX )
769 + zVoxelCoord * ( m_nbPosX ) * ( m_nbPosY );
772 template<
typename T >
776 if( x >= m_nbPosX || y >= m_nbPosY || z >= m_nbPosZ )
780 return x + y * ( m_nbPosX ) + z * ( m_nbPosX ) * ( m_nbPosY );
783 template<
typename T >
787 Vector3Type v = m_transform.positionToGridSpace( pos );
791 v[ 2 ] = std::modf( v[ 0 ] + T( 0.5 ), &d );
792 int i =
static_cast< int >( v[ 0 ] >= T( 0.0 ) && v[ 0 ] < m_nbPosX - T( 1.0 ) );
793 return -1 + i *
static_cast< int >( T( 1.0 ) + d );
796 template<
typename T >
799 Vector3Type v = m_transform.positionToGridSpace( pos );
802 v[ 0 ] = std::modf( v[ 1 ] + T( 0.5 ), &d );
803 int i =
static_cast< int >( v[ 1 ] >= T( 0.0 ) && v[ 1 ] < m_nbPosY - T( 1.0 ) );
804 return -1 + i *
static_cast< int >( T( 1.0 ) + d );
807 template<
typename T >
810 Vector3Type v = m_transform.positionToGridSpace( pos );
813 v[ 0 ] = std::modf( v[ 2 ] + T( 0.5 ), &d );
814 int i =
static_cast< int >( v[ 2 ] >= T( 0.0 ) && v[ 2 ] < m_nbPosZ - T( 1.0 ) );
815 return -1 + i *
static_cast< int >( T( 1.0 ) + d );
818 template<
typename T >
822 result[0] = getXVoxelCoord( pos );
823 result[1] = getYVoxelCoord( pos );
824 result[2] = getZVoxelCoord( pos );
828 template<
typename T >
831 Vector3Type v = m_transform.positionToGridSpace( pos );
833 T xCellId = floor( v[0] );
834 T yCellId = floor( v[1] );
835 T zCellId = floor( v[2] );
837 *success = xCellId >= 0 && yCellId >=0 && zCellId >= 0 && xCellId < m_nbPosX - 1 && yCellId < m_nbPosY -1 && zCellId < m_nbPosZ -1;
839 return xCellId + yCellId * ( m_nbPosX - 1 ) + zCellId * ( m_nbPosX - 1 ) * ( m_nbPosY - 1 );
842 template<
typename T >
846 size_t minVertexIdZ = cellId / ( ( m_nbPosX - 1 ) * ( m_nbPosY - 1 ) );
847 size_t remainderXY = cellId - minVertexIdZ * ( ( m_nbPosX - 1 ) * ( m_nbPosY - 1 ) );
848 size_t minVertexIdY = remainderXY / ( m_nbPosX - 1 );
849 size_t minVertexIdX = remainderXY % ( m_nbPosX - 1 );
851 size_t minVertexId = minVertexIdX + minVertexIdY * m_nbPosX + minVertexIdZ * m_nbPosX * m_nbPosY;
853 vertices[0] = minVertexId;
854 vertices[1] = vertices[0] + 1;
855 vertices[2] = minVertexId + m_nbPosX;
856 vertices[3] = vertices[2] + 1;
857 vertices[4] = minVertexId + m_nbPosX * m_nbPosY;
858 vertices[5] = vertices[4] + 1;
859 vertices[6] = vertices[4] + m_nbPosX;
860 vertices[7] = vertices[6] + 1;
864 template<
typename T >
867 typedef std::shared_ptr< std::vector< Vector3Type > > ReturnType;
868 ReturnType result = ReturnType(
new std::vector< Vector3Type > );
869 result->reserve( 8 );
870 T halfMarginX = getOffsetX() / 2.0 - std::abs( margin );
871 T halfMarginY = getOffsetY() / 2.0 - std::abs( margin );
872 T halfMarginZ = getOffsetZ() / 2.0 - std::abs( margin );
873 result->push_back(
Vector3Type( point[0] - halfMarginX, point[1] - halfMarginY, point[2] - halfMarginZ ) );
874 result->push_back(
Vector3Type( point[0] + halfMarginX, point[1] - halfMarginY, point[2] - halfMarginZ ) );
875 result->push_back(
Vector3Type( point[0] + halfMarginX, point[1] - halfMarginY, point[2] + halfMarginZ ) );
876 result->push_back(
Vector3Type( point[0] - halfMarginX, point[1] - halfMarginY, point[2] + halfMarginZ ) );
877 result->push_back(
Vector3Type( point[0] - halfMarginX, point[1] + halfMarginY, point[2] - halfMarginZ ) );
878 result->push_back(
Vector3Type( point[0] + halfMarginX, point[1] + halfMarginY, point[2] - halfMarginZ ) );
879 result->push_back(
Vector3Type( point[0] + halfMarginX, point[1] + halfMarginY, point[2] + halfMarginZ ) );
880 result->push_back(
Vector3Type( point[0] - halfMarginX, point[1] + halfMarginY, point[2] + halfMarginZ ) );
884 template<
typename T >
887 std::vector< size_t > neighbours;
888 size_t x =
id % m_nbPosX;
889 size_t y = (
id / m_nbPosX ) % m_nbPosY;
890 size_t z =
id / ( m_nbPosX * m_nbPosY );
892 if( x >= m_nbPosX || y >= m_nbPosY || z >= m_nbPosZ )
894 std::stringstream ss;
895 ss <<
"This point: " <<
id <<
" is not part of this grid: ";
896 ss <<
" nbPosX: " << m_nbPosX;
897 ss <<
" nbPosY: " << m_nbPosY;
898 ss <<
" nbPosZ: " << m_nbPosZ;
904 neighbours.push_back(
id - 1 );
906 if( x < m_nbPosX - 1 )
908 neighbours.push_back(
id + 1 );
912 neighbours.push_back(
id - m_nbPosX );
914 if( y < m_nbPosY - 1 )
916 neighbours.push_back(
id + m_nbPosX );
920 neighbours.push_back(
id - ( m_nbPosX * m_nbPosY ) );
922 if( z < m_nbPosZ - 1 )
924 neighbours.push_back(
id + ( m_nbPosX * m_nbPosY ) );
929 template<
typename T >
932 std::vector< size_t > neighbours;
933 size_t x =
id % m_nbPosX;
934 size_t y = (
id / m_nbPosX ) % m_nbPosY;
935 size_t z =
id / ( m_nbPosX * m_nbPosY );
937 if( x >= m_nbPosX || y >= m_nbPosY || z >= m_nbPosZ )
939 std::stringstream ss;
940 ss <<
"This point: " <<
id <<
" is not part of this grid: ";
941 ss <<
" nbPosX: " << m_nbPosX;
942 ss <<
" nbPosY: " << m_nbPosY;
943 ss <<
" nbPosZ: " << m_nbPosZ;
947 std::vector< int >tempResult;
949 tempResult.push_back( getVoxelNum( x , y , z ) );
950 tempResult.push_back( getVoxelNum( x , y - 1, z ) );
951 tempResult.push_back( getVoxelNum( x , y + 1, z ) );
952 tempResult.push_back( getVoxelNum( x - 1, y , z ) );
953 tempResult.push_back( getVoxelNum( x - 1, y - 1, z ) );
954 tempResult.push_back( getVoxelNum( x - 1, y + 1, z ) );
955 tempResult.push_back( getVoxelNum( x + 1, y , z ) );
956 tempResult.push_back( getVoxelNum( x + 1, y - 1, z ) );
957 tempResult.push_back( getVoxelNum( x + 1, y + 1, z ) );
959 tempResult.push_back( getVoxelNum( x , y , z - 1 ) );
960 tempResult.push_back( getVoxelNum( x , y - 1, z - 1 ) );
961 tempResult.push_back( getVoxelNum( x , y + 1, z - 1 ) );
962 tempResult.push_back( getVoxelNum( x - 1, y , z - 1 ) );
963 tempResult.push_back( getVoxelNum( x - 1, y - 1, z - 1 ) );
964 tempResult.push_back( getVoxelNum( x - 1, y + 1, z - 1 ) );
965 tempResult.push_back( getVoxelNum( x + 1, y , z - 1 ) );
966 tempResult.push_back( getVoxelNum( x + 1, y - 1, z - 1 ) );
967 tempResult.push_back( getVoxelNum( x + 1, y + 1, z - 1 ) );
969 tempResult.push_back( getVoxelNum( x , y , z + 1 ) );
970 tempResult.push_back( getVoxelNum( x , y - 1, z + 1 ) );
971 tempResult.push_back( getVoxelNum( x , y + 1, z + 1 ) );
972 tempResult.push_back( getVoxelNum( x - 1, y , z + 1 ) );
973 tempResult.push_back( getVoxelNum( x - 1, y - 1, z + 1 ) );
974 tempResult.push_back( getVoxelNum( x - 1, y + 1, z + 1 ) );
975 tempResult.push_back( getVoxelNum( x + 1, y , z + 1 ) );
976 tempResult.push_back( getVoxelNum( x + 1, y - 1, z + 1 ) );
977 tempResult.push_back( getVoxelNum( x + 1, y + 1, z + 1 ) );
979 for(
size_t k = 0; k < tempResult.size(); ++k )
981 if( tempResult[k] != -1 )
983 neighbours.push_back( tempResult[k] );
989 template<
typename T >
992 std::vector< size_t > neighbours;
993 size_t x =
id % m_nbPosX;
994 size_t y = (
id / m_nbPosX ) % m_nbPosY;
995 size_t z =
id / ( m_nbPosX * m_nbPosY );
997 if( x >= m_nbPosX || y >= m_nbPosY || z >= m_nbPosZ )
999 std::stringstream ss;
1000 ss <<
"This point: " <<
id <<
" is not part of this grid: ";
1001 ss <<
" nbPosX: " << m_nbPosX;
1002 ss <<
" nbPosY: " << m_nbPosY;
1003 ss <<
" nbPosZ: " << m_nbPosZ;
1007 std::vector< int >tempResult;
1009 for(
size_t xx = x - range; xx < x + range + 1; ++xx )
1011 for(
size_t yy = y - range; yy < y + range + 1; ++yy )
1013 for(
size_t zz = z - range; zz < z + range + 1; ++zz )
1015 tempResult.push_back( getVoxelNum( xx, yy, zz ) );
1020 for(
size_t k = 0; k < tempResult.size(); ++k )
1022 if( tempResult[k] != -1 )
1024 neighbours.push_back( tempResult[k] );
1030 template<
typename T >
1033 std::vector< size_t > neighbours;
1034 size_t x =
id % m_nbPosX;
1035 size_t y = (
id / m_nbPosX ) % m_nbPosY;
1036 size_t z =
id / ( m_nbPosX * m_nbPosY );
1038 if( x >= m_nbPosX || y >= m_nbPosY || z >= m_nbPosZ )
1040 std::stringstream ss;
1041 ss <<
"This point: " <<
id <<
" is not part of this grid: ";
1042 ss <<
" nbPosX: " << m_nbPosX;
1043 ss <<
" nbPosY: " << m_nbPosY;
1044 ss <<
" nbPosZ: " << m_nbPosZ;
1050 vNum = getVoxelNum( x - 1, y, z );
1053 neighbours.push_back( vNum );
1055 vNum = getVoxelNum( x - 1, y - 1, z );
1058 neighbours.push_back( vNum );
1060 vNum = getVoxelNum( x, y - 1, z );
1063 neighbours.push_back( vNum );
1065 vNum = getVoxelNum( x + 1, y - 1, z );
1068 neighbours.push_back( vNum );
1070 vNum = getVoxelNum( x + 1, y, z );
1073 neighbours.push_back( vNum );
1075 vNum = getVoxelNum( x + 1, y + 1, z );
1078 neighbours.push_back( vNum );
1080 vNum = getVoxelNum( x, y + 1, z );
1083 neighbours.push_back( vNum );
1085 vNum = getVoxelNum( x - 1, y + 1, z );
1088 neighbours.push_back( vNum );
1093 template<
typename T >
1096 std::vector< size_t > neighbours;
1097 size_t x =
id % m_nbPosX;
1098 size_t y = (
id / m_nbPosX ) % m_nbPosY;
1099 size_t z =
id / ( m_nbPosX * m_nbPosY );
1101 if( x >= m_nbPosX || y >= m_nbPosY || z >= m_nbPosZ )
1103 std::stringstream ss;
1104 ss <<
"This point: " <<
id <<
" is not part of this grid: ";
1105 ss <<
" nbPosX: " << m_nbPosX;
1106 ss <<
" nbPosY: " << m_nbPosY;
1107 ss <<
" nbPosZ: " << m_nbPosZ;
1113 vNum = getVoxelNum( x, y, z - 1 );
1116 neighbours.push_back( vNum );
1118 vNum = getVoxelNum( x, y - 1, z - 1 );
1121 neighbours.push_back( vNum );
1123 vNum = getVoxelNum( x, y - 1, z );
1126 neighbours.push_back( vNum );
1128 vNum = getVoxelNum( x, y - 1, z + 1 );
1131 neighbours.push_back( vNum );
1133 vNum = getVoxelNum( x, y, z + 1 );
1136 neighbours.push_back( vNum );
1138 vNum = getVoxelNum( x, y + 1, z + 1 );
1141 neighbours.push_back( vNum );
1143 vNum = getVoxelNum( x, y + 1, z );
1146 neighbours.push_back( vNum );
1148 vNum = getVoxelNum( x, y + 1, z - 1 );
1151 neighbours.push_back( vNum );
1157 template<
typename T >
1160 std::vector< size_t > neighbours;
1161 size_t x =
id % m_nbPosX;
1162 size_t y = (
id / m_nbPosX ) % m_nbPosY;
1163 size_t z =
id / ( m_nbPosX * m_nbPosY );
1165 if( x >= m_nbPosX || y >= m_nbPosY || z >= m_nbPosZ )
1167 std::stringstream ss;
1168 ss <<
"This point: " <<
id <<
" is not part of this grid: ";
1169 ss <<
" nbPosX: " << m_nbPosX;
1170 ss <<
" nbPosY: " << m_nbPosY;
1171 ss <<
" nbPosZ: " << m_nbPosZ;
1177 vNum = getVoxelNum( x, y, z - 1 );
1180 neighbours.push_back( vNum );
1182 vNum = getVoxelNum( x - 1, y, z - 1 );
1185 neighbours.push_back( vNum );
1187 vNum = getVoxelNum( x - 1, y, z );
1190 neighbours.push_back( vNum );
1192 vNum = getVoxelNum( x - 1, y, z + 1 );
1195 neighbours.push_back( vNum );
1197 vNum = getVoxelNum( x, y, z + 1 );
1200 neighbours.push_back( vNum );
1202 vNum = getVoxelNum( x + 1, y, z + 1 );
1205 neighbours.push_back( vNum );
1207 vNum = getVoxelNum( x + 1, y, z );
1210 neighbours.push_back( vNum );
1212 vNum = getVoxelNum( x + 1, y, z - 1 );
1215 neighbours.push_back( vNum );
1221 template<
typename T >
1224 Vector3Type v = m_transform.positionToGridSpace( pos );
1226 if( v[ 0 ] < T( 0.0 ) || v[ 0 ] >=
static_cast< T
>( m_nbPosX - 1 ) )
1230 if( v[ 1 ] < T( 0.0 ) || v[ 1 ] >=
static_cast< T
>( m_nbPosY - 1 ) )
1234 if( v[ 2 ] < T( 0.0 ) || v[ 2 ] >=
static_cast< T
>( m_nbPosZ - 1 ) )
1241 template<
typename T >
1244 return m_transform.isNotRotated();
1247 template<
typename T >
1253 template<
typename T >
1256 WPropInt xDim = m_infoProperties->addProperty(
"X dimension: ",
1257 "The x dimension of the grid.",
1258 static_cast<int>( getNbCoordsX() ) );
1259 WPropInt yDim = m_infoProperties->addProperty(
"Y dimension: ",
1260 "The y dimension of the grid.",
1261 static_cast<int>( getNbCoordsY() ) );
1262 WPropInt zDim = m_infoProperties->addProperty(
"Z dimension: ",
1263 "The z dimension of the grid.",
1264 static_cast<int>( getNbCoordsZ() ) );
1266 WPropDouble xOffset = m_infoProperties->addProperty(
"X offset: ",
1267 "The distance between samples in x direction",
1268 static_cast< double >( getOffsetX() ) );
1269 WPropDouble yOffset = m_infoProperties->addProperty(
"Y offset: ",
1270 "The distance between samples in y direction",
1271 static_cast< double >( getOffsetY() ) );
1272 WPropDouble zOffset = m_infoProperties->addProperty(
"Z offset: ",
1273 "The distance between samples in z direction",
1274 static_cast< double >( getOffsetZ() ) );
1277 template<
typename T >
1297 template<
typename T >
1300 boost::array< T, 3 > result = { { grid->getOffsetX(), grid->getOffsetY(), grid->getOffsetZ() } };
1311 template<
typename T >
1314 boost::array< unsigned int, 3 > result = { { grid->getNbCoordsX(), grid->getNbCoordsY(), grid->getNbCoordsZ() } };
1325 template<
typename T >
1326 inline boost::array< typename WGridRegular3DTemplate< T >::Vector3Type, 3 > getDirections( std::shared_ptr<
const WGridRegular3DTemplate< T > > grid )
1328 boost::array< typename WGridRegular3DTemplate< T >::Vector3Type, 3 > result = { { grid->getDirectionX(), grid->getDirectionY(), grid->getDirectionZ() } };
1339 template<
typename T >
1340 inline boost::array< typename WGridRegular3DTemplate< T >::Vector3Type, 3 > getUnitDirections( std::shared_ptr<
const WGridRegular3DTemplate< T > > grid )
1342 boost::array< typename WGridRegular3DTemplate< T >::Vector3Type, 3 > result = { { grid->getUnitDirectionX(), grid->getUnitDirectionY(), grid->getUnitDirectionZ() } };
void expandBy(const WBoundingBoxImpl< VT > &bb)
Expands this bounding box to include the given bounding box.
A grid that has parallelepiped cells which all have the same proportion.
unsigned int m_nbPosX
Number of positions in x direction.
Vector3Type getOrigin() const
Returns the position of the origin of the grid.
T getOffsetZ() const
Returns the distance between samples in z direction.
T getOffsetY() const
Returns the distance between samples in y direction.
unsigned int m_nbPosY
Number of positions in y direction.
WGridTransformOrthoTemplate< T > const m_transform
The grid's transformation.
std::vector< size_t > getNeighbours9YZ(size_t id) const
Return the list of all neighbour voxels.
std::vector< size_t > getNeighbours9XY(size_t id) const
Return the list of all neighbour voxels.
std::vector< size_t > getNeighbours(size_t id) const
Return the list of neighbour voxels.
size_t getCellId(const Vector3Type &pos, bool *success) const
Computes the id of the cell containing the position pos.
WMatrix< T > getTransformationMatrix() const
Returns a 4x4 matrix that represents the grid's transformation.
bool isNotRotated() const
Return whether the transformations of the grid are only translation and/or scaling.
WMatrixFixed< T, 3, 1 > Vector3Type
Convenience typedef for 3d vectors of the appropriate numerical type.
unsigned int getNbCoordsZ() const
Returns the number of samples in z direction.
Vector3Type worldCoordToTexCoord(Vector3Type point)
Transforms world coordinates to texture coordinates.
std::vector< size_t > getNeighbours27(size_t id) const
Return the list of all neighbour voxels.
bool encloses(const Vector3Type &pos) const
Decides whether a certain position is inside this grid or not.
WVector3i getVoxelCoord(const Vector3Type &pos) const
Computes the voxel coordinates of that voxel which contains the position pos.
Vector3Type getDirectionY() const
Returns the vector determining the direction of samples in y direction.
int getNVoxelCoord(const Vector3Type &pos, size_t axis) const
Computes for the n'th component of the voxel coordinate where the voxel contains the position pos.
Vector3Type getUnitDirectionX() const
Returns the vector determining the unit (normalized) direction of samples in x direction.
Vector3Type getDirectionX() const
Returns the vector determining the direction of samples in x direction.
unsigned int m_nbPosZ
Number of positions in z direction.
int getXVoxelCoord(const Vector3Type &pos) const
Computes the X coordinate of that voxel that contains the position pos.
Vector3Type getUnitDirectionY() const
Returns the vector determining the unit (normalized) direction of samples in y direction.
Vector3Type getUnitDirectionZ() const
Returns the vector determining the unit (normalized) direction of samples in z direction.
Vector3Type getPosition(unsigned int i) const
Returns the i-th position on the grid.
std::shared_ptr< WGridRegular3DTemplate > SPtr
Convenience typedef for a std::shared_ptr< WGridRegular3DTemplate >.
Vector3Type getDirectionZ() const
Returns the vector determining the direction of samples in z direction.
std::vector< size_t > getNeighboursRange(size_t id, size_t range) const
Return the list of all neighbour voxels.
unsigned int getNbCoordsX() const
Returns the number of samples in x direction.
CellVertexArray getCellVertexIds(size_t cellId) const
Computes the ids of the vertices of a cell given by its id.
WBoundingBox getBoundingBox() const
Axis aligned Bounding Box that encloses this grid.
std::vector< size_t > getNeighbours9XZ(size_t id) const
Return the list of all neighbour voxels.
WBoundingBox getBoundingBoxIncludingBorder() const
Calculates the bounding box but includes the border voxel associated cell too.
void initInformationProperties()
Adds the specific information of this grid type to the informational properties.
boost::array< size_t, 8 > CellVertexArray
Convenience typedef for a boost::array< size_t, 8 >.
int getVoxelNum(const Vector3Type &pos) const
Returns the i'th voxel where the given position belongs too.
int getYVoxelCoord(const Vector3Type &pos) const
Computes the Y coordinate of that voxel that contains the position pos.
unsigned int getNbCoordsY() const
Returns the number of samples in y direction.
int getZVoxelCoord(const Vector3Type &pos) const
Computes the Z coordinate of that voxel that contains the position pos.
bool operator==(const WGridRegular3DTemplate< T > &other) const
Compares two grids.
friend class WGridRegular3DTemplate
this (friend) is necessary to allow casting
T getOffsetX() const
Returns the distance between samples in x direction.
WGridTransformOrthoTemplate< T > const getTransform() const
Returns the transformation used by this grid.
WBoundingBox getVoxelBoundingBox() const
Calculate the bounding box in voxel space.
std::shared_ptr< std::vector< Vector3Type > > getVoxelVertices(const Vector3Type &point, const T margin=0.0) const
Computes the vertices for a voxel cuboid around the given point:
std::shared_ptr< const WGridRegular3DTemplate > ConstSPtr
Convenience typedef for a std::shared_ptr< const WGridRegular3DTemplate >.
Tests the WGridRegular3D class.
Base class to all grid types, e.g.
Matrix template class with variable number of rows and columns.
Indicates invalid element access of a container.