ホーム » 2010 » 10月 » 19

日別アーカイブ: 2010/10/19

2010年10月
 12
3456789
10111213141516
17181920212223
24252627282930
31  

カテゴリー

アーカイブ

ブログ統計情報

  • 80,198 アクセス



FaceA::Search の高速化

データが増えると遅かったので改良
BOOL FaceA::Search(const long edgeS,const long edgeE,long* left_Face,long* rightFace) const
{
  if (left_Face == NULL) { return FALSE ; }
  if (rightFace== NULL) { return FALSE ; }
  *left_Face = *rightFace = -1 ;
  BOOL lfFound = FALSE ;
  BOOL rfFound = FALSE ;
   static long LastFace = 0 ;
  int index = 0 ;
   for (index=LastFace ; index<GetCount() ; index++) {
     Face f = Faces[index] ;
     if (!f.Search(edgeS,edgeE,&lfFound,&rfFound)) { continue ; }
     if (*left_Face<0 && lfFound) { *left_Face = index ; }
     if (*rightFace<0 && rfFound) { *rightFace = index ; }
     if (*left_Face >= 0 && *rightFace>=0) {
       LastFace = min(*left_Face,*rightFace) ;
       return TRUE ;
       }
     }
  for (index=0 ; index<GetCount() ; index++) {
    Face f = Faces[index] ;
    if (!f.Search(edgeS,edgeE,&lfFound,&rfFound)) { continue ; }
    if (*left_Face<0 && lfFound) { *left_Face = index ; }
    if (*rightFace<0 && rfFound) { *rightFace = index ; }
    if (*left_Face >= 0 && *rightFace>=0) {
      LastFace = min(*left_Face,*rightFace) ;
      return TRUE ;
      }
    }
  return FALSE ;
  }

前に検索して一致した所から再検索するコードを追加.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

CArray の要素のコピー

FaceA::FaceA (const FaceA& other)
{

// ループによるコピー
  Faces.SetSize(other.Faces.GetSize()) ;
  for (int index=0 ; index<other.Faces.GetSize() ; index++) {
    Faces[index] = other.Faces[index] ;
    }

// CArray::Copy
  Faces.Copy(other.Faces) ;

  }

VC 6 リリース版では体感できなかったが,少なくともデバッグ版では Copy の方がはるかに速かった.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.