Exemple #1
0
  //---------------------------------------------------------------------------------------------------
  //  Public:   PerfectMatch
  //  Purpose:  Handles the degenerate case where v and this voxel
  //            have the same vertices.
  //---------------------------------------------------------------------------------------------------
  bool CXDMVoxel::PerfectMatch( const CXDMVoxel & v ) const
  {

    if ( v.nGeneration != this->nGeneration )
      return false;
    if ( v.bVoxelPointsUp != this->bVoxelPointsUp )
      return false;
  
    Float fError = fSideLength / Float( 10.0 ); 
  
    Bool pVertexMatch[3];

    for( Int i = 0; i < 3; i ++ )
    {
      pVertexMatch[i] = false;
      for( Int j = 0; j < 3; j ++ )
      {
        SVector3 oDisp = v.pVertex[i] - this->pVertex[j];
        if ( oDisp.GetLength() < fError )
          pVertexMatch[i] = true;
      }
    }
  
    return ( pVertexMatch[0] && pVertexMatch[1] && pVertexMatch[2] );
  }
 Bool Equivilent( const CSymmetryType & oSymOps, const SVector3 &v1, const SVector3 &v2, Float fError )
 {
   const vector<SMatrix3x3> &vOperatorList = oSymOps.GetOperatorList();
   
   for( Size_Type i = 0; i < vOperatorList.size(); i ++ )
   {
     SVector3 oTmp = vOperatorList[i] * v1;
     SVector3 oDiff = oTmp - v2;
     Float fDiff = oDiff.GetLength();
     
     if( fDiff < fError )
     {
       return true;
     }
   }
   return false;
 }
Exemple #3
0
  //---------------------------------------------------------------------------------------------------
  //  MinDistance calculation
  //  --  clearly this could be optimized.  Let's get it right first.
  //
  //  Precondition:  All of the Z must be exactly the same!
  //
  //---------------------------------------------------------------------------------------------------
  bool CXDMVoxel::Connected( const SVector3 & oV1, const SVector3 & oV2,
                             const SVector3 & p, Float fError )
  {
    SVector3 oDist_Top = p - oV2;
    SVector3 oDist = p - oV1;
    oDist_Top.m_fZ = 0;   // zeroing out the out of plane components
    oDist.m_fZ     = 0;
    // check for vertex overlap
    if ( (    fabs( oDist_Top.m_fX ) < fError
           && fabs( oDist_Top.m_fY ) < fError
         )
      ||
         (    fabs( oDist.m_fX ) < fError
           && fabs( oDist.m_fY ) < fError
         )
       )
    {
      return true;
    }
    
    SVector3 oLine = oV2 - oV1;
    oLine.m_fZ = 0;
    Float    fLineLength = oLine.GetLength();
    DEBUG_ASSERT( fLineLength > std::numeric_limits<Float>::epsilon(),
                  "CXDMVoxel:: MinDistance: numerical limit reached for this floaing point numbers\n" ); 

    SVector3 oLineDir = oLine / fLineLength;
    Float    fProjected = Dot( oDist, oLineDir );
    if( fProjected < 0 || fProjected > fLineLength )
      return false;
    
    SVector3 oPerpDir( -oLineDir.m_fY, oLineDir.m_fX, oLineDir.m_fZ );
    Float fPerpDist = Dot( oDist, oPerpDir );
    return ( fabs(fPerpDist) < fError );

//----------------------------------------
//  -- Also correct, but I'm afraid of dividing and sqrt-ing very small numbers
//     SVector3 oDistPerp = oDist - fProjected * oLineDir;
//     return ( oDistPerp.GetLength() < fError );
//----------------------------------------
  }