Skip to content

Commit

Permalink
Add limited support for .PLY
Browse files Browse the repository at this point in the history
  • Loading branch information
captainys committed Dec 9, 2024
1 parent 3e3f003 commit ea5e265
Show file tree
Hide file tree
Showing 8 changed files with 527 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/ysgebl/src/gui/filemenu/filemenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ void GeblGuiEditorBase::File_Open(FsGuiPopUpMenuItem *)
fdlg->fileExtensionArray.Append(L".srf");
fdlg->fileExtensionArray.Append(L".stl");
fdlg->fileExtensionArray.Append(L".obj");
fdlg->fileExtensionArray.Append(L".ply");
fdlg->fileExtensionArray.Append(L".off");
fdlg->fileExtensionArray.Append(L".dxf");
fdlg->fileExtensionArray.Append(L".dnm");
Expand Down
24 changes: 24 additions & 0 deletions src/ysgebl/src/gui_foundation/ysgebl_gui_foundation_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,30 @@ GeblGuiFoundation::SlhdAndErrorCode GeblGuiFoundation::LoadGeneral(const wchar_t
returnValue.errCode=GEBLERROR_FILE_NOT_FOUND;
}
}
else if(0==ext.STRCMP(L".PLY"))
{
YsFileIO::File fp(fn,"r");
if(NULL!=fp)
{
YsShellDnmContainer <YsShellExtEditGui>::Node *newSlHd=shlGrp.CreateShell(parent);

auto inStream=fp.InStream();
if(YSOK==newSlHd->LoadPly(inStream))
{
newSlHd->SetFileName(fn);
returnValue.slHd=newSlHd;
}
else
{
shlGrp.DeleteShell(newSlHd);
returnValue.errCode=GEBLERROR_FILE_CORRUPTED;
}
}
else
{
returnValue.errCode=GEBLERROR_FILE_NOT_FOUND;
}
}
else if(0==ext.STRCMP(L".OFF"))
{
YsFileIO::File fp(fn,"r");
Expand Down
7 changes: 7 additions & 0 deletions src/ysgebl/src/kernel/ysshellext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,13 @@ YSRESULT YsShellExt::LoadObj(YsTextInputStream &inStream)
return objReader.ReadObj(*this,inStream,opt);
}

YSRESULT YsShellExt::LoadPly(YsTextInputStream &inStream)
{
YsShellExtPlyReader::ReadOption opt;
YsShellExtPlyReader PlyReader;
return PlyReader.ReadPly(*this,inStream,opt);
}

YsShellExtDrawingBuffer &YsShellExt::GetDrawingBuffer(void) const
{
return *drawingBuffer;
Expand Down
3 changes: 3 additions & 0 deletions src/ysgebl/src/kernel/ysshellext.h
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,9 @@ class YsShellExt : protected YsShell
/*! This function loads Wavefront .OBJ data. */
YSRESULT LoadObj(YsTextInputStream &inStream);

/*! This function loads Wavefront .OBJ data. */
YSRESULT LoadPly(YsTextInputStream &inStream);

/*! This function returns a drawing-buffer.
A drawing buffer stores primitive informations for rendering. */
YsShellExtDrawingBuffer &GetDrawingBuffer(void) const;
Expand Down
20 changes: 20 additions & 0 deletions src/ysgebl/src/kernel/ysshellextedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,26 @@ YSRESULT YsShellExtEdit::LoadObj(YsTextInputStream &inStream)
return objReader.ReadObj(*this,inStream,opt);
}

YSRESULT YsShellExtEdit::LoadPly(const char fn[])
{
FILE *fp=fopen(fn,"r");
if(NULL!=fp)
{
YsTextFileInputStream inStream(fp);
YSRESULT res=LoadPly(inStream);
fclose(fp);
return res;
}
return YSERR;
}

YSRESULT YsShellExtEdit::LoadPly(YsTextInputStream &inStream)
{
YsShellExtPlyReader::ReadOption opt;
YsShellExtPlyReader PlyReader;
return PlyReader.ReadPly(*this,inStream,opt);
}

YSRESULT YsShellExtEdit::MergeObj(YsTextInputStream &inStream)
{
YsShellExtObjReader::ReadOption opt;
Expand Down
6 changes: 6 additions & 0 deletions src/ysgebl/src/kernel/ysshellextedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,12 @@ class YsShellExtEdit : private YsShellExt
/*! This function loads Wavefront .OBJ data. */
YSRESULT LoadObj(YsTextInputStream &inStream);

/*! This function loads .PLY data. */
YSRESULT LoadPly(const char fn[]);

/*! This function loads .PLY data. */
YSRESULT LoadPly(YsTextInputStream &inStream);

/*! This function loads Wavefront .OBJ data. */
YSRESULT MergeObj(YsTextInputStream &inStream);

Expand Down
Loading

0 comments on commit ea5e265

Please sign in to comment.