本文整理汇总了C++中CArchive::ReadString方法的典型用法代码示例。如果您正苦于以下问题:C++ CArchive::ReadString方法的具体用法?C++ CArchive::ReadString怎么用?C++ CArchive::ReadString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CArchive
的用法示例。
在下文中一共展示了CArchive::ReadString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessTitles
BOOL CSyntaxDlg::ProcessTitles( CArchive & rar )
{
BOOL bSuccess = FALSE;
BOOL bDone = FALSE;
while( ! bDone )
{
char sz[ 200 ];
rar.ReadString( sz, 199 );
CString str( sz );
str.TrimRight();
str.TrimLeft();
bDone = (str == "$end" );
if( !bDone && str.GetLength() )
{
switch( Parameterize( str, 5 ) )
{
case IDCANCEL:
return FALSE;
case IDYES:
bSuccess = TRUE;
m_SF.m_Title.RecordSegment( str );
break;
}
}
}
if( bSuccess)
MessageBox( "Das Taggen der Titel-Syntagmen ist gelungen", "Erfolg" );
else
MessageBox( "Keine Titel-Syntagmen wurden gefunden", "Fehler" );
return TRUE;
}
示例2: DoLoadFavorites
HMENU CFavMenu::DoLoadFavorites(CArchive& ar, CStringArray& data, UINT& id, int& menu_height)
{
max_height = GetSystemMetrics(SM_CYSCREEN) - 64;
item_height = GetSystemMetrics(SM_CYMENU);
bool is_toplevel = (data.GetSize() == 0);
HMENU menu = CreatePopupMenu();
CString str;
for (; ar.ReadString(str); ++id)
{
if (str.IsEmpty()) // end of dir
{
data.Add(sep); // add separator
::AppendMenu(menu, MF_SEPARATOR, id, NULL);
++id;
if (! is_toplevel)
{
// Add to Favorites
data.Add(add_to_fav);
AppendMenu(menu, MF_OWNERDRAW, id, LPCTSTR(id), menu_height);
++id;
// Open All
data.Add(open_all);
AppendMenu(menu, MF_OWNERDRAW, id, LPCTSTR(id), menu_height);
++id;
// Organize Favorites
data.Add(org_fav);
AppendMenu(menu, MF_OWNERDRAW, id, LPCTSTR(id), menu_height);
++id;
// end of sub menu
data.Add(_T("")); // afxEmptyString is no longer in mfc7 and above
}
break;
}
data.Add(str);
if (str[0] == 'd') // dir
{
UINT submenu_id = id; // reserve id for the menu item
++id;
int submenu_height = 0;
HMENU sub = DoLoadFavorites(ar, data, id, submenu_height); // create sub menu
AppendMenu(menu, MF_OWNERDRAW | MF_POPUP,
UINT(sub), LPCTSTR(submenu_id), menu_height);
}
else
AppendMenu(menu, MF_OWNERDRAW, id, LPCTSTR(id), menu_height);
}
favmenus.Add(menu);
return menu;
}
示例3: ScanForNextFunctionOrList
// Returns the next function (including header),
// i.e. everything up to the second-next-function or end of file.
void CFormulaFileSplitter::ScanForNextFunctionOrList(CArchive &formula_file) {
// Function-header is the first line,
// (usually the last line of last scan)
// rest is content
_function_header = _next_line;
_function_text = "";
while (true) {
try {
if (!formula_file.ReadString(_next_line)) {
break;
}
}
catch (CException *e) {
// break;
}
++_total_line_processed;
// Avoid problems with "empty" lines before first function header
// that contain spaces.
_next_line.TrimRight();
#ifdef DEBUG_FORMULA_FILESPLITTER
//printf("[CFormulaFileSplitter] next line: %s\n", _next_line);
#endif
if (IsFunctionHeader(_next_line)
&& _first_function_processed) {
// Next function found
// Only continue, if we found the first one
//
// In case of break: keep that function-header for the next query
_starting_line_of_current_function = _total_line_processed;
break;
}
if (_function_header.IsEmpty() || (_function_header.Find('#') < 0)) {
// Escpecially meant to catch OpenGeeks newlines
// (which are not empty) at the beginning of the file.
// Other cases can't happen, as we search for ##
// when looking for the next function-header.
_function_header = _next_line;
} else {
_first_function_processed = true;
// Add non-function-header (content) to the functions body
_function_text += _next_line;
_function_text += "\n";
}
}
#ifdef DEBUG_FORMULA_FILESPLITTER
//printf("[CFormulaFileSplitter] next function: %s\n", _formula_content);
OH_MessageBox_Interactive(_function_text, "Function", 0);
#endif
}
示例4: SerializeAlias
void SerializeAlias( CArchive & ar, CAliasArray & aAliases )
{
char szFileMagic[] = "NETTSALIAS";
DWORD dwFileVersion = 0x20040825;
if( ar.IsStoring() )
{
ar.WriteString( szFileMagic );
ar << dwFileVersion;
ar << (int)aAliases.GetSize();
for( int i=0; i<aAliases.GetSize(); i++ )
{
CAlias & a = aAliases.ElementAt(i);
ar << a.m_strName;
ar << a.m_strValue;
}
}
else
{
TCHAR buffer[64];
memset( buffer, 0, sizeof(buffer) );
ar.ReadString( buffer, strlen(szFileMagic) );
if( 0 != strncmp( szFileMagic, buffer, strlen(szFileMagic) ) )
return;
DWORD dwVer;
ar >> dwVer;
if( dwVer > dwFileVersion )
return;
int size;
ar >> size;
if( size < 0 || size > 10000 ) // too big
return;
aAliases.SetSize( 0, size+2 );
for( int i=0; i<size; i++ )
{
CAlias a;
ar >> a.m_strName;
ar >> a.m_strValue;
aAliases.Add( a );
}
}
}
示例5: ProcessText
BOOL CSyntaxDlg::ProcessText( CArchive & rar )
{
CString strSegment;
BOOL bSuccess = FALSE;
BOOL bDone = FALSE;
while( ! bDone )
{
char sz[ 200 ];
rar.ReadString( sz, 199 );
CString str( sz );
bDone = (str == "$end" );
if( !bDone && str.GetLength() )
{
int nAt = str.FindOneOf( ".!?" );
if( nAt >= 0 )
{
strSegment += str.Left( nAt + 1 );
strSegment.TrimLeft();
switch( Parameterize( strSegment, 20 ) )
{
case IDCANCEL:
return FALSE;
case IDYES:
bSuccess = TRUE;
m_SF.m_Text.RecordSegment( strSegment );
break;
}
if( str.GetLength() > nAt + 2 )
strSegment = str.Mid( nAt + 2 );
else
strSegment = "";
}
else
strSegment += str + ' ';
}
}
if( bSuccess)
MessageBox( "Das Taggen der Syntagmen ist gelungen", "Erfolg" );
else
MessageBox( "Keine Syntagmen wurden gefunden", "Fehler" );
return TRUE;
}
示例6: Serialize
void CBugTracksDoc::Serialize(CArchive& ar)
{
if (!ar.IsStoring())
{
SBugData Data;
CString strOneLine;
while(ar.ReadString(strOneLine))
{
sscanf(strOneLine,"%g %g\n",&Data.x,&Data.y);
m_BugDataArray.Add(Data);
}
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
示例7:
LineCollection::LineCollection(CArchive &ar,int skip)
{
if (ar.IsStoring())
{
return;
}
else
{
m_Skip=skip;
CString s;
int i,j;
vect.SetSize(0);
for(i=0,j=0;ar.ReadString(s);i++)
{
if(m_Skip && s=="") continue;
vect.SetSize(j+1);
vect[j]=s;
j++;
}
}
}
示例8: Serialize
void CPMPTxtDoc::Serialize(CArchive& ar)
{
CString str;
if (ar.IsStoring())
{
// TODO: add storing code here
POSITION pos = this->GetFirstViewPosition();
CPMPTxtView * p_cPMPTxtView = (CPMPTxtView *)this->GetNextView(pos);
p_cPMPTxtView->m_ctrlRichEdit->GetWindowTextA(str);
ar.Write(str,str.GetLength());
}
else
{
// TODO: add loading code here
m_PathName = ar.m_strFileName;
m_realfilename = ar.GetFile()->GetFileName();
long size = 0;
long filesize = ar.GetFile()->GetLength();
// 允许打开一个不超过20M的文本文件
if(ar.GetFile()->GetLength()<=1024*1024*20){
char * temp = (char * )malloc(sizeof(char)*filesize + 1);
while(ar.ReadString(m_text)){
m_text.Append("\n");
strcpy(temp+size,m_text.GetBuffer(0));
m_text.ReleaseBuffer();
size+=m_text.GetLength();
}
//m_textContent.Add(temp);
m_text = temp;
free(temp);
}else{
::MessageBox(NULL,_T("Too large to open"),_T("Message"),MB_OK);
}
}
}
示例9: Serialize
void NNLayer::Serialize(CArchive &ar)
{
VectorNeurons::iterator nit;
VectorWeights::iterator wit;
VectorConnections::iterator cit;
int ii, jj;
if (ar.IsStoring())
{
// TODO: add storing code here
ar.WriteString( label.c_str() );
ar.WriteString( _T("\r\n") ); // ar.ReadString will look for \r\n when loading from the archive
ar << m_Neurons.size();
ar << m_Weights.size();
for ( nit=m_Neurons.begin(); nit<m_Neurons.end(); nit++ )
{
NNNeuron& n = *(*nit);
ar.WriteString( n.label.c_str() );
ar.WriteString( _T("\r\n") );
ar << n.m_Connections.size();
for ( cit=n.m_Connections.begin(); cit<n.m_Connections.end(); cit++ )
{
ar << (*cit).NeuronIndex;
ar << (*cit).WeightIndex;
}
}
for ( wit=m_Weights.begin(); wit<m_Weights.end(); wit++ )
{
ar.WriteString( (*wit)->label.c_str() );
ar.WriteString( _T("\r\n") );
ar << (*wit)->value;
}
}
else
{
// TODO: add loading code here
CString str;
ar.ReadString( str );
label = str;
int iNumNeurons, iNumWeights, iNumConnections;
double value;
NNNeuron* pNeuron;
NNWeight* pWeight;
NNConnection conn;
ar >> iNumNeurons;
ar >> iNumWeights;
for ( ii=0; ii<iNumNeurons; ++ii )
{
ar.ReadString( str );
pNeuron = new NNNeuron( (LPCTSTR)str );
m_Neurons.push_back( pNeuron );
ar >> iNumConnections;
for ( jj=0; jj<iNumConnections; ++jj )
{
ar >> conn.NeuronIndex;
ar >> conn.WeightIndex;
pNeuron->AddConnection( conn );
}
}
for ( jj=0; jj<iNumWeights; ++jj )
{
ar.ReadString( str );
ar >> value;
pWeight = new NNWeight( (LPCTSTR)str, value );
m_Weights.push_back( pWeight );
}
}
}
示例10: ReadFormulaFile
// Reading a part of a formula, which may be spread
// between two files in case of an old style whf / whx formula.
void CFormula::ReadFormulaFile(CArchive& ar, bool ignoreFirstLine)
{
CString strOneLine = "";
int content = 0;
char funcname[256] = {0};
int start = 0, end = 0;
SFunction func;
SHandList list;
CSLock lock(m_critsec);
// Ignore first line (date/time)
if (ignoreFirstLine)
ar.ReadString(strOneLine);
// read data in, one line at a time
strOneLine = "";
content = FTnone;
func.func = "";
while(ar.ReadString(strOneLine))
{
// If this line marks the beginning of a function, then save the previously
// collected function, and start a new one
if (strOneLine.Mid(0,2)=="##")
{
// Save the previously collected function
if (content == FTlist)
{
// Strip the LFCR off the last line (we need to add CRLF for all but the last line)
list.list_text.TrimRight("\r\n");
_formula.mHandList.Add(list);
}
else if (content == FTfunc)
{
func.func_text.TrimRight("\r\n");
_formula.mFunction.Add(func);
}
// Get the function name
start = strOneLine.Find("##",0);
// No need to check the result of start,
// as this code gets executed only,
// if a line starts with "##"
end = strOneLine.Find("##", start+2);
// Checking for malformed function header
// without trailing "##"
if (end == -1)
{
// Trying to continue gracefully.
// Skipping is not possible,
// as this crashes the formula editor.
strcpy_s(funcname, 256, strOneLine.GetString()+start+2);
funcname[strOneLine.GetLength()]='\0';
CString the_ErrorMessage = "Malformed function header!\nMissing trailing '##'.\n"
+ strOneLine + "\n"
+ "Trying to continue...";
MessageBox(0, the_ErrorMessage, "Syntax Error",
MB_OK | MB_ICONEXCLAMATION);
}
else
{
strcpy_s(funcname, 256, strOneLine.GetString()+start+2);
funcname[end-2]='\0';
}
if (strcmp(funcname, "bankroll") == 0) { _formula.dBankroll = 0.0; content = FTbankroll; }
else if (strcmp(funcname, "defcon") == 0) { _formula.dDefcon = 0.0; content = FTdefcon; }
else if (strcmp(funcname, "rake") == 0) { _formula.dRake = 0.0; content = FTrake; }
else if (strcmp(funcname, "nit") == 0) { _formula.dNit = 0.0; content = FTnit; }
else if (memcmp(funcname, "list", 4) == 0)
{
content = FTlist;
list.list = funcname;
list.list_text = "";
}
else
{
content = FTfunc;
func.func = funcname;
func.func_text = "";
func.dirty = true;
}
}
// Get the function content
else
//.........这里部分代码省略.........
示例11: LoadSettings
bool CChildView::LoadSettings(CArchive &ar)
{
int k;
try{
ar >> k;
if (k<0 || k>RGB(255,255,255)) {
CArchiveException *pfe = new CArchiveException(CArchiveException::badIndex);
throw pfe;
}
m_crBackColor = k;
ar >> k;
if (k<0 || k>RGB(255,255,255)) {
CArchiveException *pfe = new CArchiveException(CArchiveException::badIndex);
throw pfe;
}
m_WndTextColor = k;
ar >> k;
if (k<0 || k>RGB(255,255,255)) {
CArchiveException *pfe = new CArchiveException(CArchiveException::badIndex);
throw pfe;
}
m_crGraphBkClr = k;
ar >> k;
if (k<0 || k>RGB(255,255,255)) {
CArchiveException *pfe = new CArchiveException(CArchiveException::badIndex);
throw pfe;
}
m_crBorderClr = k;
ar >> k;
if (k<0 || k>100) {
CArchiveException *pfe = new CArchiveException(CArchiveException::badIndex);
throw pfe;
}
m_iBorderStyle = k;
ar >> k;
if (k<0 || k>100) {
CArchiveException *pfe = new CArchiveException(CArchiveException::badIndex);
throw pfe;
}
m_iBorderWidth = k;
ar >> k;
if (k!=1 && k!=0) {
CArchiveException *pfe = new CArchiveException(CArchiveException::badIndex);
throw pfe;
}
if(k) m_bBorder = true;
else m_bBorder = false;
ar >> k;
if (k!=1 && k!=0) {
CArchiveException *pfe = new CArchiveException(CArchiveException::badIndex);
throw pfe;
}
if(k) SetBlackAndWhite(true);
else SetBlackAndWhite(false);
ar >> m_WndLogFont.lfCharSet;
if(m_WndLogFont.lfCharSet == 0) m_WndLogFont.lfCharSet = DEFAULT_CHARSET;
ar >> m_WndLogFont.lfClipPrecision;
ar >> m_WndLogFont.lfEscapement;
ar >> m_WndLogFont.lfHeight;
ar >> m_WndLogFont.lfItalic;
ar >> m_WndLogFont.lfOrientation;
ar >> m_WndLogFont.lfOutPrecision;
ar >> m_WndLogFont.lfPitchAndFamily;
ar >> m_WndLogFont.lfQuality;
ar >> m_WndLogFont.lfStrikeOut;
ar >> m_WndLogFont.lfUnderline;
ar >> m_WndLogFont.lfWeight;
ar >> m_WndLogFont.lfWidth;
ar >> k;
if(k<0 || k>32) {
CArchiveException *pfe = new CArchiveException(CArchiveException::badIndex);
throw pfe;
}
ar.ReadString(m_WndLogFont.lfFaceName, k);
m_DefaultGraph.Serialize(ar);
//-------------
}
catch (CArchiveException *ex){
// AfxMessageBox("Failed to load settings",MB_OK);
ex->Delete();
m_pXDirect->SetDisplayDefault();
return false;
}
catch (CException *ex){
// AfxMessageBox("Failed to load settings",MB_OK);
ex->Delete();
return false;
}
return true;
}
示例12: Serialize
void CWedDoc::Serialize(CArchive& ar, const char *docname)
{
CString num, str;
CString filename = docname;
PathToFname(filename);
if (ar.IsStoring())
{
// Writing
CWaitCursor cursor;
POSITION pos;
pos = strlist.GetHeadPosition();
origlines = 0;
while(TRUE)
{
CString line;
if(!(origlines % 100))
{
num.Format("Writing %s line %d", filename, origlines);
message(num);
}
origlines++;
if (!pos)
break;
line = strlist.GetNext(pos);
// Obey tab save option
if(Tab2Space || spaceify)
ExpandTabs(line);
// Dispose space from EOL
line.TrimRight();
// Write out to file
ar.WriteString(line);
// Do end of line according to settings
if(unix)
ar.WriteString("\n");
else
ar.WriteString("\r\n");
}
num.Format("Wrote %s", filename); message(num);
// If user decides to save, save undo/redo info as well
SaveUndo(); SaveRedo();
}
else
{
// Reading
CWaitCursor cursor;
char buff[DETECTSIZE];
strlist.RemoveAll();
// Determine file type
CFile* fp = ar.GetFile();
int rlen = fp->Read(buff, DETECTSIZE);
// File without a newline ---> default to DOS
if(!strstr(buff, "\n"))
unix = FALSE;
else if (strstr(buff, "\r\n"))
unix = FALSE;
else
unix = TRUE;
// Take a wild guess for tabs
if(!strstr(buff, "\t") && rlen > DETECTSIZE/2 )
{
spaceify = TRUE;
}
// Start over on file
fp->Seek(0,CFile::begin);
origlines = 0;
// Load file
while(TRUE)
{
str = "";
if(!(origlines % 100))
{
CString num;
num.Format("Reading %s line %d", filename, origlines);
message(num);
}
if(YieldToWinEx())
{
readonly = TRUE;
AfxMessageBox("Aborted load, partial buffer is readonly.");
break;
}
TRY
{
if(!ar.ReadString(str))
//.........这里部分代码省略.........
示例13: ReadFormulaFile
// Reading a part of a formula, which may be spread
// between two files in case of an old style whf / whx formula.
void CFormula::ReadFormulaFile(CArchive& ar, bool ignoreFirstLine)
{
CString strOneLine = "";
int content = 0;
char funcname[k_max_size_of_function_name] = {0};
int start = 0, end = 0;
SFunction func;
SHandList list;
CSLock lock(m_critsec);
// Ignore first line (date/time)
if (ignoreFirstLine)
ar.ReadString(strOneLine);
// read data in, one line at a time
strOneLine = "";
content = FTnone;
func.func = "";
while(ar.ReadString(strOneLine))
{
// If this line marks the beginning of a function, then save the previously
// collected function, and start a new one
if (strOneLine.Mid(0,2)=="##")
{
// Save the previously collected function
if (content == FTlist)
{
// Strip the LFCR off the last line (we need to add CRLF for all but the last line)
list.list_text.TrimRight("\r\n");
if (DoesFormulaAlreadyExist(list.list))
{
CString ErrorMessage = "Handlist does already exist: " + list.list;
OH_MessageBox_Error_Warning(ErrorMessage, "Error");
}
else
{
_formula.mHandList.Add(list);
}
}
else if (content == FTfunc)
{
func.func_text.TrimRight("\r\n");
if (DoesFormulaAlreadyExist(func.func))
{
CString ErrorMessage = "Function does already exist: " + func.func;
OH_MessageBox_Error_Warning(ErrorMessage, "Error");
}
else
{
_formula.mFunction.Add(func);
}
}
// Get the function name
start = strOneLine.Find("##",0);
// No need to check the result of start,
// as this code gets executed only,
// if a line starts with "##"
end = strOneLine.Find("##", start+2);
// Checking for malformed function header
// without trailing "##"
if (end == k_undefined)
{
// Trying to continue gracefully.
// Skipping is not possible,
// as this crashes the formula editor.
int number_of_chars_to_copy = (strOneLine.GetLength() < k_max_size_of_function_name) ?
strOneLine.GetLength() : k_max_size_of_function_name;
strncpy_s(funcname,
k_max_size_of_function_name,
strOneLine.GetString()+start+2,
number_of_chars_to_copy);
funcname[number_of_chars_to_copy]='\0';
CString the_ErrorMessage = "Malformed function header!\nMissing trailing '##'.\n"
+ strOneLine + "\n"
+ "Trying to continue...";
OH_MessageBox_Error_Warning(the_ErrorMessage, "Syntax Error");
}
else
{
int size_of_function_name = end - start + 1;
assert(size_of_function_name < k_max_size_of_function_name);
// strncpy_s: http://msdn.microsoft.com/de-de/library/5dae5d43(v=vs.80).aspx
strncpy_s(funcname, // Destination
k_max_size_of_function_name * sizeof(char), // Size of destination
strOneLine.GetString() + start + 2, // Start of source (without leading "##")
size_of_function_name); // Elements to copy
funcname[end-2] = '\0'; // Remove trailing "##"
}
if (memcmp(funcname, "list", 4) == 0)
{
content = FTlist;
//.........这里部分代码省略.........
示例14: ReadArchive
void CProjectDoc::ReadArchive(CArchive &ar)
{
CProjectView* pview = GetProjectView();
CString s;
unsigned short first;
BOOL is_unicode;
int ibufsize = 512;
pview->UpdateData(FALSE);
// Read first two bytes to check for Unicode,
// now we can't undo with archive, so this presents
// a problem when reading the first line and there
// wasn't a unicode flag. The answer is in ProcessLine
// which accepts 'zirel' as well as 'amzirel' for the
// first line attribute.
ar.Read(&first, 2);
if (first == 0xfeff)
is_unicode = TRUE;
else
is_unicode = FALSE;
#ifdef _UNICODE
// if unicode, just read it straight
if (is_unicode)
{
while (ar.ReadString(s))
ProcessLine(s, pview);
}
// if not unicode, read into an ascii buffer
// and call mbstowcs().
else
{
char* buf = new char[ibufsize+1];
_TCHAR* sbuf = new _TCHAR[ibufsize+1];
while (ReadLineA(buf, ar, ibufsize))
{
mbstowcs(sbuf, buf, ibufsize);
s = sbuf;
ProcessLine(s, pview);
}
delete[] buf;
delete[] sbuf;
}
#else
// if not unicode, read it straight
if (!is_unicode)
{
while (ar.ReadString(s))
ProcessLine(s, pview);
}
// if unicode, get ReadLineW to read and
// translate.
else
{
wchar_t* buf = new wchar_t[ibufsize+1];
_TCHAR* sbuf = new _TCHAR[ibufsize+1];
while (ReadLineW(buf, ar, ibufsize))
{
wcstombs(sbuf, buf, ibufsize);
s = buf;
ProcessLine(s, pview);
}
delete[] buf;
delete[] sbuf;
}
#endif
if (! m_amzirel == CString(_T("4")))
AfxMessageBox(_T("Not a valid Amzi! project for this environment,\n please recreate."));
return;
}
示例15: Serialize
void CVertexCollection::Serialize(CArchive& Archive, CTriangulation *Triangulation)
{
double x = 0;
double y = 0;
double z = 0;
CVertex *Vertex = NULL;
CString sLine;
if (Archive.IsStoring())
{
for (long VertexIndex = 4; VertexIndex < m_Collection.GetCount(); VertexIndex++)
{
Vertex = (CVertex *)m_Collection[VertexIndex];
sLine.Format(_T(" %.3lf %.3lf %.3lf"),Vertex->m_Coordinate[0],Vertex->m_Coordinate[1], Vertex->m_Coordinate[2]);
Archive.WriteString(sLine);
Archive.WriteString(_T("\n"));
m_VertexNumber++;
}
}
else
{
//Let's check file extension.
CFile *File = Archive.GetFile();
CString FilePath = File->GetFilePath();
char Ext[256];
_splitpath(FilePath, NULL, NULL, NULL, Ext);
//First four verteces are verteces of bounding box/
for (int VertexIndex = 0; VertexIndex < 4; VertexIndex++)
{
Vertex = new CVertex(0, 0, 0, CVertex::BoundingBox);
Vertex->m_Index = m_Collection.Add(Vertex);
}
do
{
if (!sLine.IsEmpty())
{
CString XString;
CString YString;
CString ZString;
int Start = 0;
XString = sLine.Tokenize(_T(" "), Start);
YString = sLine.Tokenize(_T(" "), Start);
ZString = sLine.Tokenize(_T(" "), Start);
sscanf_s(XString,_T("%lf.2"), &x);
sscanf_s(YString,_T("%lf.2"), &y);
sscanf_s(ZString,_T("%lf.2"), &z);
Vertex = new CVertex(x, y, z, CVertex::Standalone);
Vertex->m_Index = m_Collection.Add(Vertex);
if (m_Collection.GetCount() == 5)
{
m_Min.m_Coordinate[0] = x;
m_Min.m_Coordinate[1] = y;
m_Min.m_Coordinate[2] = z;
m_Max.m_Coordinate[0] = x;
m_Max.m_Coordinate[1] = y;
m_Max.m_Coordinate[2] = z;
}
else
{
//todo = min
if (m_Min.m_Coordinate[0] > x)
m_Min.m_Coordinate[0] = x;
if (m_Min.m_Coordinate[1] > y)
m_Min.m_Coordinate[1] = y;
if (m_Min.m_Coordinate[2] > z)
m_Min.m_Coordinate[2] = z;
if (m_Max.m_Coordinate[0] < x)
m_Max.m_Coordinate[0] = x;
if (m_Max.m_Coordinate[1] < y)
m_Max.m_Coordinate[1] = y;
if (m_Max.m_Coordinate[2] < z)
m_Max.m_Coordinate[2] = z;
}
}
if (m_Collection.GetSize() > 100)
break;
}
while(Archive.ReadString(sLine));
//////////////////////////////////////////
m_DeltaX = 0.25 * fabs((m_Max.m_Coordinate[0] - m_Min.m_Coordinate[0]));
m_DeltaY = 0.25 * fabs((m_Max.m_Coordinate[1] - m_Min.m_Coordinate[1]));
m_Min.m_Coordinate[2] = (double)((long)m_Min.m_Coordinate[2]);
//////////////////////////////////////////////
Vertex = (CVertex *)m_Collection[0];
Vertex->m_Coordinate[0] = m_Min.m_Coordinate[0] - 2 * m_DeltaX;
//.........这里部分代码省略.........
开发者ID:southerlies,项目名称:OGRE-3D-1.7-Application-Development-Cookbook-Code,代码行数:101,代码来源:VertexCollection.cpp