25 #ifndef WGRIDREGULAR3D_H
26 #define WGRIDREGULAR3D_H
34 #include <boost/array.hpp>
37 #include <boost/shared_ptr.hpp>
43 #include "../common/exceptions/WOutOfBounds.h"
44 #include "../common/exceptions/WPreconditionNotMet.h"
45 #include "../common/math/WLinearAlgebraFunctions.h"
46 #include "../common/math/WMatrix.h"
47 #include "../common/WBoundingBox.h"
48 #include "../common/WCondition.h"
49 #include "../common/WDefines.h"
50 #include "../common/WProperties.h"
53 #include "WGridTransformOrtho.h"
63 template<
typename T >
82 typedef boost::shared_ptr< WGridRegular3DTemplate >
SPtr;
87 typedef boost::shared_ptr< const WGridRegular3DTemplate >
ConstSPtr;
100 template<
typename InputType >
127 double scaleX,
double scaleY,
double scaleZ );
255 Vector3Type
getPosition(
unsigned int iX,
unsigned int iY,
unsigned int iZ )
const;
310 int getVoxelNum(
const size_t x,
const size_t y,
const size_t z )
const;
370 size_t getCellId(
const Vector3Type& pos,
bool* success )
const;
420 boost::shared_ptr< std::vector< Vector3Type > >
getVoxelVertices(
const Vector3Type& point,
421 const T margin = 0.0 )
const;
498 bool encloses(
const Vector3Type& pos )
const;
554 template<
typename T >
555 template<
typename InputType >
557 WGrid( rhs.m_nbPosX * rhs.m_nbPosY * rhs.m_nbPosZ ),
558 m_nbPosX( rhs.m_nbPosX ),
559 m_nbPosY( rhs.m_nbPosY ),
560 m_nbPosZ( rhs.m_nbPosZ ),
561 m_transform( rhs.m_transform )
566 template<
typename T >
569 :
WGrid( nbPosX * nbPosY * nbPosZ ),
573 m_transform( transform )
578 template<
typename T >
580 double scaleX,
double scaleY,
double scaleZ ):
581 WGrid( nbPosX * nbPosY * nbPosZ ),
590 template<
typename T >
596 template<
typename T >
602 template<
typename T >
608 template<
typename T >
611 return m_transform.getOffsetX();
614 template<
typename T >
617 return m_transform.getOffsetY();
620 template<
typename T >
623 return m_transform.getOffsetZ();
626 template<
typename T >
629 return m_transform.getDirectionX();
632 template<
typename T >
635 return m_transform.getDirectionY();
638 template<
typename T >
641 return m_transform.getDirectionZ();
644 template<
typename T >
647 return m_transform.getUnitDirectionX();
650 template<
typename T >
653 return m_transform.getUnitDirectionY();
656 template<
typename T >
659 return m_transform.getUnitDirectionZ();
662 template<
typename T >
665 return m_transform.getOrigin();
668 template<
typename T >
671 return m_transform.getTransformationMatrix();
674 template<
typename T >
678 result.
expandBy( m_transform.positionToWorldSpace( Vector3Type( 0.0, 0.0, 0.0 ) ) );
679 result.
expandBy( m_transform.positionToWorldSpace( Vector3Type( getNbCoordsX() - 1, 0.0, 0.0 ) ) );
680 result.
expandBy( m_transform.positionToWorldSpace( Vector3Type( 0.0, getNbCoordsY() - 1, 0.0 ) ) );
681 result.
expandBy( m_transform.positionToWorldSpace( Vector3Type( getNbCoordsX() - 1, getNbCoordsY() - 1, 0.0 ) ) );
682 result.
expandBy( m_transform.positionToWorldSpace( Vector3Type( 0.0, 0.0, getNbCoordsZ() - 1 ) ) );
683 result.
expandBy( m_transform.positionToWorldSpace( Vector3Type( getNbCoordsX() - 1, 0.0, getNbCoordsZ() - 1 ) ) );
684 result.
expandBy( m_transform.positionToWorldSpace( Vector3Type( 0.0, getNbCoordsY() - 1, getNbCoordsZ() - 1 ) ) );
685 result.
expandBy( m_transform.positionToWorldSpace( Vector3Type( getNbCoordsX() - 1, getNbCoordsY() - 1, getNbCoordsZ() - 1 ) ) );
689 template<
typename T >
693 result.
expandBy( m_transform.positionToWorldSpace( Vector3Type( 0.0, 0.0, 0.0 ) ) );
694 result.
expandBy( m_transform.positionToWorldSpace( Vector3Type( getNbCoordsX(), 0.0, 0.0 ) ) );
695 result.
expandBy( m_transform.positionToWorldSpace( Vector3Type( 0.0, getNbCoordsY(), 0.0 ) ) );
696 result.
expandBy( m_transform.positionToWorldSpace( Vector3Type( getNbCoordsX(), getNbCoordsY(), 0.0 ) ) );
697 result.
expandBy( m_transform.positionToWorldSpace( Vector3Type( 0.0, 0.0, getNbCoordsZ() ) ) );
698 result.
expandBy( m_transform.positionToWorldSpace( Vector3Type( getNbCoordsX(), 0.0, getNbCoordsZ() ) ) );
699 result.
expandBy( m_transform.positionToWorldSpace( Vector3Type( 0.0, getNbCoordsY(), getNbCoordsZ() ) ) );
700 result.
expandBy( m_transform.positionToWorldSpace( Vector3Type( getNbCoordsX(), getNbCoordsY(), getNbCoordsZ() ) ) );
704 template<
typename T >
708 result.
expandBy( m_transform.positionToWorldSpace( Vector3Type( -0.5, -0.5, -0.5 ) ) );
709 result.
expandBy( m_transform.positionToWorldSpace( Vector3Type( getNbCoordsX() - 0.5, -0.5, -0.5 ) ) );
710 result.
expandBy( m_transform.positionToWorldSpace( Vector3Type( -0.5, getNbCoordsY() - 0.5, -0.5 ) ) );
711 result.
expandBy( m_transform.positionToWorldSpace( Vector3Type( getNbCoordsX() - 0.5, getNbCoordsY() - 0.5, -0.5 ) ) );
712 result.
expandBy( m_transform.positionToWorldSpace( Vector3Type( -0.5, -0.5, getNbCoordsZ() - 0.5 ) ) );
713 result.
expandBy( m_transform.positionToWorldSpace( Vector3Type( getNbCoordsX() - 0.5, -0.5, getNbCoordsZ() - 0.5 ) ) );
714 result.
expandBy( m_transform.positionToWorldSpace( Vector3Type( -0.5, getNbCoordsY() - 0.5, getNbCoordsZ() - 0.5 ) ) );
715 result.
expandBy( m_transform.positionToWorldSpace( Vector3Type( getNbCoordsX() - 0.5, getNbCoordsY() - 0.5, getNbCoordsZ() - 0.5 ) ) );
719 template<
typename T >
722 return getPosition( i % m_nbPosX, ( i / m_nbPosX ) % m_nbPosY, i / ( m_nbPosX * m_nbPosY ) );
725 template<
typename T >
728 unsigned int iZ )
const
730 Vector3Type i( iX, iY, iZ );
731 return m_transform.positionToWorldSpace( i );
734 template<
typename T >
737 Vector3Type r( m_transform.positionToGridSpace( point ) );
740 r[0] = r[0] / m_nbPosX;
741 r[1] = r[1] / m_nbPosY;
742 r[2] = r[2] / m_nbPosZ;
745 r[0] += 0.5 / m_nbPosX;
746 r[1] += 0.5 / m_nbPosY;
747 r[2] += 0.5 / m_nbPosZ;
752 template<
typename T >
766 int xVoxelCoord = getXVoxelCoord( pos );
767 int yVoxelCoord = getYVoxelCoord( pos );
768 int zVoxelCoord = getZVoxelCoord( pos );
769 if( xVoxelCoord == -1 || yVoxelCoord == -1 || zVoxelCoord == -1 )
774 + yVoxelCoord * ( m_nbPosX )
775 + zVoxelCoord * ( m_nbPosX ) * ( m_nbPosY );
778 template<
typename T >
782 if( x > m_nbPosX || y > m_nbPosY || z > m_nbPosZ )
786 return x + y * ( m_nbPosX ) + z * ( m_nbPosX ) * ( m_nbPosY );
789 template<
typename T >
793 Vector3Type v = m_transform.positionToGridSpace( pos );
797 v[ 2 ] = std::modf( v[ 0 ] + T( 0.5 ), &d );
798 int i =
static_cast< int >( v[ 0 ] >= T( 0.0 ) && v[ 0 ] < m_nbPosX - T( 1.0 ) );
799 return -1 + i *
static_cast< int >( T( 1.0 ) + d );
802 template<
typename T >
805 Vector3Type v = m_transform.positionToGridSpace( pos );
808 v[ 0 ] = std::modf( v[ 1 ] + T( 0.5 ), &d );
809 int i =
static_cast< int >( v[ 1 ] >= T( 0.0 ) && v[ 1 ] < m_nbPosY - T( 1.0 ) );
810 return -1 + i *
static_cast< int >( T( 1.0 ) + d );
813 template<
typename T >
816 Vector3Type v = m_transform.positionToGridSpace( pos );
819 v[ 0 ] = std::modf( v[ 2 ] + T( 0.5 ), &d );
820 int i =
static_cast< int >( v[ 2 ] >= T( 0.0 ) && v[ 2 ] < m_nbPosZ - T( 1.0 ) );
821 return -1 + i *
static_cast< int >( T( 1.0 ) + d );
824 template<
typename T >
828 result[0] = getXVoxelCoord( pos );
829 result[1] = getYVoxelCoord( pos );
830 result[2] = getZVoxelCoord( pos );
834 template<
typename T >
837 Vector3Type v = m_transform.positionToGridSpace( pos );
839 T xCellId = floor( v[0] );
840 T yCellId = floor( v[1] );
841 T zCellId = floor( v[2] );
843 *success = xCellId >= 0 && yCellId >=0 && zCellId >= 0 && xCellId < m_nbPosX - 1 && yCellId < m_nbPosY -1 && zCellId < m_nbPosZ -1;
845 return xCellId + yCellId * ( m_nbPosX - 1 ) + zCellId * ( m_nbPosX - 1 ) * ( m_nbPosY - 1 );
848 template<
typename T >
852 size_t minVertexIdZ = cellId / ( ( m_nbPosX - 1 ) * ( m_nbPosY - 1 ) );
853 size_t remainderXY = cellId - minVertexIdZ * ( ( m_nbPosX - 1 ) * ( m_nbPosY - 1 ) );
854 size_t minVertexIdY = remainderXY / ( m_nbPosX - 1 );
855 size_t minVertexIdX = remainderXY % ( m_nbPosX - 1 );
857 size_t minVertexId = minVertexIdX + minVertexIdY * m_nbPosX + minVertexIdZ * m_nbPosX * m_nbPosY;
859 vertices[0] = minVertexId;
860 vertices[1] = vertices[0] + 1;
861 vertices[2] = minVertexId + m_nbPosX;
862 vertices[3] = vertices[2] + 1;
863 vertices[4] = minVertexId + m_nbPosX * m_nbPosY;
864 vertices[5] = vertices[4] + 1;
865 vertices[6] = vertices[4] + m_nbPosX;
866 vertices[7] = vertices[6] + 1;
870 template<
typename T >
873 typedef boost::shared_ptr< std::vector< Vector3Type > > ReturnType;
874 ReturnType result = ReturnType(
new std::vector< Vector3Type > );
875 result->reserve( 8 );
876 T halfMarginX = getOffsetX() / 2.0 - std::abs( margin );
877 T halfMarginY = getOffsetY() / 2.0 - std::abs( margin );
878 T halfMarginZ = getOffsetZ() / 2.0 - std::abs( margin );
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 ) );
881 result->push_back( Vector3Type( point[0] + halfMarginX, point[1] - halfMarginY, point[2] + halfMarginZ ) );
882 result->push_back( Vector3Type( point[0] - halfMarginX, point[1] - halfMarginY, point[2] + halfMarginZ ) );
883 result->push_back( Vector3Type( point[0] - halfMarginX, point[1] + halfMarginY, point[2] - halfMarginZ ) );
884 result->push_back( Vector3Type( point[0] + halfMarginX, point[1] + halfMarginY, point[2] - halfMarginZ ) );
885 result->push_back( Vector3Type( point[0] + halfMarginX, point[1] + halfMarginY, point[2] + halfMarginZ ) );
886 result->push_back( Vector3Type( point[0] - halfMarginX, point[1] + halfMarginY, point[2] + halfMarginZ ) );
890 template<
typename T >
893 std::vector< size_t > neighbours;
894 size_t x =
id % m_nbPosX;
895 size_t y = (
id / m_nbPosX ) % m_nbPosY;
896 size_t z =
id / ( m_nbPosX * m_nbPosY );
898 if( x >= m_nbPosX || y >= m_nbPosY || z >= m_nbPosZ )
900 std::stringstream ss;
901 ss <<
"This point: " <<
id <<
" is not part of this grid: ";
902 ss <<
" nbPosX: " << m_nbPosX;
903 ss <<
" nbPosY: " << m_nbPosY;
904 ss <<
" nbPosZ: " << m_nbPosZ;
910 neighbours.push_back(
id - 1 );
912 if( x < m_nbPosX - 1 )
914 neighbours.push_back(
id + 1 );
918 neighbours.push_back(
id - m_nbPosX );
920 if( y < m_nbPosY - 1 )
922 neighbours.push_back(
id + m_nbPosX );
926 neighbours.push_back(
id - ( m_nbPosX * m_nbPosY ) );
928 if( z < m_nbPosZ - 1 )
930 neighbours.push_back(
id + ( m_nbPosX * m_nbPosY ) );
935 template<
typename T >
938 std::vector< size_t > neighbours;
939 size_t x =
id % m_nbPosX;
940 size_t y = (
id / m_nbPosX ) % m_nbPosY;
941 size_t z =
id / ( m_nbPosX * m_nbPosY );
943 if( x >= m_nbPosX || y >= m_nbPosY || z >= m_nbPosZ )
945 std::stringstream ss;
946 ss <<
"This point: " <<
id <<
" is not part of this grid: ";
947 ss <<
" nbPosX: " << m_nbPosX;
948 ss <<
" nbPosY: " << m_nbPosY;
949 ss <<
" nbPosZ: " << m_nbPosZ;
953 std::vector< int >tempResult;
955 tempResult.push_back( getVoxelNum( x , y , z ) );
956 tempResult.push_back( getVoxelNum( x , y - 1, z ) );
957 tempResult.push_back( getVoxelNum( x , y + 1, z ) );
958 tempResult.push_back( getVoxelNum( x - 1, y , z ) );
959 tempResult.push_back( getVoxelNum( x - 1, y - 1, z ) );
960 tempResult.push_back( getVoxelNum( x - 1, y + 1, z ) );
961 tempResult.push_back( getVoxelNum( x + 1, y , z ) );
962 tempResult.push_back( getVoxelNum( x + 1, y - 1, z ) );
963 tempResult.push_back( getVoxelNum( x + 1, y + 1, z ) );
965 tempResult.push_back( getVoxelNum( x , y , z - 1 ) );
966 tempResult.push_back( getVoxelNum( x , y - 1, z - 1 ) );
967 tempResult.push_back( getVoxelNum( x , y + 1, z - 1 ) );
968 tempResult.push_back( getVoxelNum( x - 1, y , z - 1 ) );
969 tempResult.push_back( getVoxelNum( x - 1, y - 1, z - 1 ) );
970 tempResult.push_back( getVoxelNum( x - 1, y + 1, z - 1 ) );
971 tempResult.push_back( getVoxelNum( x + 1, y , z - 1 ) );
972 tempResult.push_back( getVoxelNum( x + 1, y - 1, z - 1 ) );
973 tempResult.push_back( getVoxelNum( x + 1, y + 1, z - 1 ) );
975 tempResult.push_back( getVoxelNum( x , y , z + 1 ) );
976 tempResult.push_back( getVoxelNum( x , y - 1, z + 1 ) );
977 tempResult.push_back( getVoxelNum( x , y + 1, z + 1 ) );
978 tempResult.push_back( getVoxelNum( x - 1, y , z + 1 ) );
979 tempResult.push_back( getVoxelNum( x - 1, y - 1, z + 1 ) );
980 tempResult.push_back( getVoxelNum( x - 1, y + 1, z + 1 ) );
981 tempResult.push_back( getVoxelNum( x + 1, y , z + 1 ) );
982 tempResult.push_back( getVoxelNum( x + 1, y - 1, z + 1 ) );
983 tempResult.push_back( getVoxelNum( x + 1, y + 1, z + 1 ) );
985 for(
size_t k = 0; k < tempResult.size(); ++k )
987 if( tempResult[k] != -1 )
989 neighbours.push_back( tempResult[k] );
995 template<
typename T >
998 std::vector< size_t > neighbours;
999 size_t x =
id % m_nbPosX;
1000 size_t y = (
id / m_nbPosX ) % m_nbPosY;
1001 size_t z =
id / ( m_nbPosX * m_nbPosY );
1003 if( x >= m_nbPosX || y >= m_nbPosY || z >= m_nbPosZ )
1005 std::stringstream ss;
1006 ss <<
"This point: " <<
id <<
" is not part of this grid: ";
1007 ss <<
" nbPosX: " << m_nbPosX;
1008 ss <<
" nbPosY: " << m_nbPosY;
1009 ss <<
" nbPosZ: " << m_nbPosZ;
1013 std::vector< int >tempResult;
1015 for(
size_t xx = x - range; xx < x + range + 1; ++xx )
1017 for(
size_t yy = y - range; yy < y + range + 1; ++yy )
1019 for(
size_t zz = z - range; zz < z + range + 1; ++zz )
1021 tempResult.push_back( getVoxelNum( xx, yy, zz ) );
1026 for(
size_t k = 0; k < tempResult.size(); ++k )
1028 if( tempResult[k] != -1 )
1030 neighbours.push_back( tempResult[k] );
1036 template<
typename T >
1039 std::vector< size_t > neighbours;
1040 size_t x =
id % m_nbPosX;
1041 size_t y = (
id / m_nbPosX ) % m_nbPosY;
1042 size_t z =
id / ( m_nbPosX * m_nbPosY );
1044 if( x >= m_nbPosX || y >= m_nbPosY || z >= m_nbPosZ )
1046 std::stringstream ss;
1047 ss <<
"This point: " <<
id <<
" is not part of this grid: ";
1048 ss <<
" nbPosX: " << m_nbPosX;
1049 ss <<
" nbPosY: " << m_nbPosY;
1050 ss <<
" nbPosZ: " << m_nbPosZ;
1056 vNum = getVoxelNum( x - 1, y, z );
1059 neighbours.push_back( vNum );
1061 vNum = getVoxelNum( x - 1, y - 1, z );
1064 neighbours.push_back( vNum );
1066 vNum = getVoxelNum( x, y - 1, z );
1069 neighbours.push_back( vNum );
1071 vNum = getVoxelNum( x + 1, y - 1, z );
1074 neighbours.push_back( vNum );
1076 vNum = getVoxelNum( x + 1, y, z );
1079 neighbours.push_back( vNum );
1081 vNum = getVoxelNum( x + 1, y + 1, z );
1084 neighbours.push_back( vNum );
1086 vNum = getVoxelNum( x, y + 1, z );
1089 neighbours.push_back( vNum );
1091 vNum = getVoxelNum( x - 1, y + 1, z );
1094 neighbours.push_back( vNum );
1099 template<
typename T >
1102 std::vector< size_t > neighbours;
1103 size_t x =
id % m_nbPosX;
1104 size_t y = (
id / m_nbPosX ) % m_nbPosY;
1105 size_t z =
id / ( m_nbPosX * m_nbPosY );
1107 if( x >= m_nbPosX || y >= m_nbPosY || z >= m_nbPosZ )
1109 std::stringstream ss;
1110 ss <<
"This point: " <<
id <<
" is not part of this grid: ";
1111 ss <<
" nbPosX: " << m_nbPosX;
1112 ss <<
" nbPosY: " << m_nbPosY;
1113 ss <<
" nbPosZ: " << m_nbPosZ;
1119 vNum = getVoxelNum( x, y, z - 1 );
1122 neighbours.push_back( vNum );
1124 vNum = getVoxelNum( x, y - 1, z - 1 );
1127 neighbours.push_back( vNum );
1129 vNum = getVoxelNum( x, y - 1, z );
1132 neighbours.push_back( vNum );
1134 vNum = getVoxelNum( x, y - 1, z + 1 );
1137 neighbours.push_back( vNum );
1139 vNum = getVoxelNum( x, y, z + 1 );
1142 neighbours.push_back( vNum );
1144 vNum = getVoxelNum( x, y + 1, z + 1 );
1147 neighbours.push_back( vNum );
1149 vNum = getVoxelNum( x, y + 1, z );
1152 neighbours.push_back( vNum );
1154 vNum = getVoxelNum( x, y + 1, z - 1 );
1157 neighbours.push_back( vNum );
1163 template<
typename T >
1166 std::vector< size_t > neighbours;
1167 size_t x =
id % m_nbPosX;
1168 size_t y = (
id / m_nbPosX ) % m_nbPosY;
1169 size_t z =
id / ( m_nbPosX * m_nbPosY );
1171 if( x >= m_nbPosX || y >= m_nbPosY || z >= m_nbPosZ )
1173 std::stringstream ss;
1174 ss <<
"This point: " <<
id <<
" is not part of this grid: ";
1175 ss <<
" nbPosX: " << m_nbPosX;
1176 ss <<
" nbPosY: " << m_nbPosY;
1177 ss <<
" nbPosZ: " << m_nbPosZ;
1183 vNum = getVoxelNum( x, y, z - 1 );
1186 neighbours.push_back( vNum );
1188 vNum = getVoxelNum( x - 1, y, z - 1 );
1191 neighbours.push_back( vNum );
1193 vNum = getVoxelNum( x - 1, y, z );
1196 neighbours.push_back( vNum );
1198 vNum = getVoxelNum( x - 1, y, z + 1 );
1201 neighbours.push_back( vNum );
1203 vNum = getVoxelNum( x, y, z + 1 );
1206 neighbours.push_back( vNum );
1208 vNum = getVoxelNum( x + 1, y, z + 1 );
1211 neighbours.push_back( vNum );
1213 vNum = getVoxelNum( x + 1, y, z );
1216 neighbours.push_back( vNum );
1218 vNum = getVoxelNum( x + 1, y, z - 1 );
1221 neighbours.push_back( vNum );
1227 template<
typename T >
1230 Vector3Type v = m_transform.positionToGridSpace( pos );
1232 if( v[ 0 ] < T( 0.0 ) || v[ 0 ] >= static_cast< T >( m_nbPosX - 1 ) )
1236 if( v[ 1 ] < T( 0.0 ) || v[ 1 ] >= static_cast< T >( m_nbPosY - 1 ) )
1240 if( v[ 2 ] < T( 0.0 ) || v[ 2 ] >= static_cast< T >( m_nbPosZ - 1 ) )
1247 template<
typename T >
1250 return m_transform.isNotRotated();
1253 template<
typename T >
1259 template<
typename T >
1262 WPropInt xDim = m_infoProperties->addProperty(
"X dimension: ",
1263 "The x dimension of the grid.",
1264 static_cast<int>( getNbCoordsX() ) );
1265 WPropInt yDim = m_infoProperties->addProperty(
"Y dimension: ",
1266 "The y dimension of the grid.",
1267 static_cast<int>( getNbCoordsY() ) );
1268 WPropInt zDim = m_infoProperties->addProperty(
"Z dimension: ",
1269 "The z dimension of the grid.",
1270 static_cast<int>( getNbCoordsZ() ) );
1272 WPropDouble xOffset = m_infoProperties->addProperty(
"X offset: ",
1273 "The distance between samples in x direction",
1274 static_cast< double >( getOffsetX() ) );
1275 WPropDouble yOffset = m_infoProperties->addProperty(
"Y offset: ",
1276 "The distance between samples in y direction",
1277 static_cast< double >( getOffsetY() ) );
1278 WPropDouble zOffset = m_infoProperties->addProperty(
"Z offset: ",
1279 "The distance between samples in z direction",
1280 static_cast< double >( getOffsetZ() ) );
1283 template<
typename T >
1303 template<
typename T >
1306 boost::array< T, 3 > result = { { grid->getOffsetX(), grid->getOffsetY(), grid->getOffsetZ() } };
1317 template<
typename T >
1320 boost::array< unsigned int, 3 > result = { { grid->getNbCoordsX(), grid->getNbCoordsY(), grid->getNbCoordsZ() } };
1331 template<
typename T >
1332 inline boost::array< typename WGridRegular3DTemplate< T >::Vector3Type, 3 > getDirections( boost::shared_ptr<
const WGridRegular3DTemplate< T > > grid )
1334 boost::array< typename WGridRegular3DTemplate< T >::Vector3Type, 3 > result = { { grid->getDirectionX(), grid->getDirectionY(), grid->getDirectionZ() } };
1345 template<
typename T >
1346 inline boost::array< typename WGridRegular3DTemplate< T >::Vector3Type, 3 > getUnitDirections( boost::shared_ptr<
const WGridRegular3DTemplate< T > > grid )
1348 boost::array< typename WGridRegular3DTemplate< T >::Vector3Type, 3 > result = { { grid->getUnitDirectionX(), grid->getUnitDirectionY(), grid->getUnitDirectionZ() } };
1352 #endif // WGRIDREGULAR3D_H
Vector3Type getDirectionX() const
Returns the vector determining the direction of samples in x direction.
unsigned int getNbCoordsY() const
Returns the number of samples in y direction.
std::vector< size_t > getNeighboursRange(size_t id, size_t range) const
Return the list of all neighbour voxels.
WVector3i getVoxelCoord(const Vector3Type &pos) const
Computes the voxel coordinates of that voxel which contains the position pos.
A grid that has parallelepiped cells which all have the same proportion.
boost::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:
Vector3Type worldCoordToTexCoord(Vector3Type point)
Transforms world coordinates to texture coordinates.
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.
WMatrix< T > getTransformationMatrix() const
Returns a 4x4 matrix that represents the grid's transformation.
unsigned int m_nbPosY
Number of positions in y direction.
std::vector< size_t > getNeighbours9XY(size_t id) const
Return the list of all neighbour voxels.
WGridTransformOrthoTemplate< T > const m_transform
The grid's transformation.
void expandBy(const WBoundingBoxImpl< VT > &bb)
Expands this bounding box to include the given bounding box.
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...
WGridTransformOrthoTemplate< T > const getTransform() const
Returns the transformation used by this grid.
WBoundingBox getBoundingBoxIncludingBorder() const
Calculates the bounding box but includes the border voxel associated cell too.
boost::shared_ptr< WGridRegular3DTemplate > SPtr
Convenience typedef for a boost::shared_ptr< WGridRegular3DTemplate >.
Indicates invalid element access of a container.
std::vector< size_t > getNeighbours27(size_t id) const
Return the list of all neighbour voxels.
Base class to all grid types, e.g.
WBoundingBox getVoxelBoundingBox() const
Calculate the bounding box in voxel space.
unsigned int getNbCoordsZ() const
Returns the number of samples in z direction.
Matrix template class with variable number of rows and columns.
Vector3Type getPosition(unsigned int i) const
Returns the i-th position on the grid.
T getOffsetZ() const
Returns the distance between samples in z direction.
std::vector< size_t > getNeighbours9YZ(size_t id) const
Return the list of all neighbour voxels.
CellVertexArray getCellVertexIds(size_t cellId) const
Computes the ids of the vertices of a cell given by its id.
Vector3Type getUnitDirectionX() const
Returns the vector determining the unit (normalized) direction of samples in x direction.
T getOffsetY() const
Returns the distance between samples in y direction.
unsigned int m_nbPosX
Number of positions in x direction.
std::vector< size_t > getNeighbours9XZ(size_t id) const
Return the list of all neighbour voxels.
unsigned int m_nbPosZ
Number of positions in z direction.
size_t getCellId(const Vector3Type &pos, bool *success) const
Computes the id of the cell containing the position pos.
bool operator==(const WGridRegular3DTemplate< T > &other) const
Compares two grids.
bool isNotRotated() const
Return whether the transformations of the grid are only translation and/or scaling.
bool encloses(const Vector3Type &pos) const
Decides whether a certain position is inside this grid or not.
int getYVoxelCoord(const Vector3Type &pos) const
Computes the Y coordinate of that voxel that contains the position pos.
T getOffsetX() const
Returns the distance between samples in x direction.
int getZVoxelCoord(const Vector3Type &pos) const
Computes the Z coordinate of that voxel that contains the position pos.
Vector3Type getDirectionZ() const
Returns the vector determining the direction of samples in z direction.
Vector3Type getOrigin() const
Returns the position of the origin of the grid.
boost::shared_ptr< const WGridRegular3DTemplate > ConstSPtr
Convenience typedef for a boost::shared_ptr< const WGridRegular3DTemplate >.
Vector3Type getDirectionY() const
Returns the vector determining the direction of samples in y direction.
unsigned int getNbCoordsX() const
Returns the number of samples in x direction.
int getXVoxelCoord(const Vector3Type &pos) const
Computes the X coordinate of that voxel that contains the position pos.
Vector3Type getUnitDirectionZ() const
Returns the vector determining the unit (normalized) direction of samples in z direction.
WMatrixFixed< T, 3, 1 > Vector3Type
Convenience typedef for 3d vectors of the appropriate numerical type.
void initInformationProperties()
Adds the specific information of this grid type to the informational properties.
WBoundingBox getBoundingBox() const
Axis aligned Bounding Box that encloses this grid.
std::vector< size_t > getNeighbours(size_t id) const
Return the list of neighbour voxels.
Tests the WGridRegular3D class.
Vector3Type getUnitDirectionY() const
Returns the vector determining the unit (normalized) direction of samples in y direction.