#include "ImportExport.h"
#include <OCC_App.h>
-#include "SaveCSFDBDlg.h"
-
#include "SaveSTEPDlg.h"
#include "TColStd_SequenceOfAsciiString.hxx"
#include "STEPControl_Controller.hxx"
#include <BRepAlgo.hxx>
-#include <FSD_File.hxx>
-#include <ShapeSchema.hxx>
-#include <PTopoDS_HShape.hxx>
-#include <Storage_HSeqOfRoot.hxx>
-#include <Storage_Root.hxx>
-#include <PTColStd_PersistentTransientMap.hxx>
-#include <MgtBRep.hxx>
-#include <PTColStd_TransientPersistentMap.hxx>
#include <IGESControl_Controller.hxx>
#include <IGESControl_Writer.hxx>
#include <Interface_Static.hxx>
#include <VrmlData_ShapeNode.hxx>
#include <XSControl_WorkSession.hxx>
+#include <XSControl_TransferReader.hxx>
#include <STEPConstruct_Styles.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
#include <STEPConstruct.hxx>
//= =
//======================================================================
-int CImportExport::ReadBREP(const Handle_AIS_InteractiveContext& anInteractiveContext,LPCTSTR InitialDir /* = NULL*/)
+int CImportExport::ReadBREP (const Handle(AIS_InteractiveContext)& anInteractiveContext)
{
- Handle(TopTools_HSequenceOfShape) aSequence = CImportExport::ReadBREP(InitialDir);
+ Handle(TopTools_HSequenceOfShape) aSequence = CImportExport::ReadBREP();
if(aSequence->IsEmpty())
return 1;
- Handle_AIS_Shape aShape;
+ Handle(AIS_Shape) aShape;
for(int i=1;i<= aSequence->Length();i++){
aShape = new AIS_Shape(aSequence->Value(i));
anInteractiveContext->SetDisplayMode(aShape, 1, Standard_False);
return 0;
}
-Handle(TopTools_HSequenceOfShape) CImportExport::ReadBREP(LPCTSTR /*InitialDir*/ /* = NULL*/) // not by reference --> the sequence is created here !!
+Handle(TopTools_HSequenceOfShape) CImportExport::ReadBREP()
{
CFileDialog dlg(TRUE,
NULL,
NULL,
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
- "BREP Files (*.brep , *.rle)|*.brep; *.BREP; *.rle; *.RLE; |All Files (*.*)|*.*||",
+ L"BREP Files (*.brep , *.rle)|*.brep; *.BREP; *.rle; *.RLE; |All Files (*.*)|*.*||",
NULL );
- TCHAR tchBuf[80];
-
- CString CASROOTValue = ((GetEnvironmentVariable("CASROOT", tchBuf, 80) > 0) ? tchBuf : NULL);
- CString initdir = (CASROOTValue + "\\..\\data\\occ");
+ CString SHAREPATHValue;
+ SHAREPATHValue.GetEnvironmentVariable (L"CSF_OCCTDataPath");
+ CString initdir = (SHAREPATHValue + "\\occ");
dlg.m_ofn.lpstrInitialDir = initdir;
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
CString filename = dlg.GetPathName();
TopoDS_Shape aShape;
- Standard_CString aFileName = (Standard_CString)(LPCTSTR)filename;
- Standard_Boolean result = ReadBREP(aFileName,aShape);
+ Standard_Boolean result = ReadBREP (filename, aShape);
if (result)
{
if (!BRepAlgo::IsValid(aShape))
- MessageBox(AfxGetMainWnd()->m_hWnd,"Warning: The shape is not valid!","Cascade Warning",MB_ICONWARNING);
+ MessageBoxW (AfxGetMainWnd()->m_hWnd, L"Warning: The shape is not valid!", L"Cascade Warning", MB_ICONWARNING);
aSequence->Append(aShape);
}
else
- MessageBox(AfxGetMainWnd()->m_hWnd,"Error: The file was not read","Cascade Error",MB_ICONERROR);
+ MessageBoxW (AfxGetMainWnd()->m_hWnd, L"Error: The file was not read", L"Cascade Error", MB_ICONERROR);
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
}
}
//----------------------------------------------------------------------
-Standard_Boolean CImportExport::ReadBREP(const Standard_CString& aFileName,
+Standard_Boolean CImportExport::ReadBREP(CString aFileName,
TopoDS_Shape& aShape)
{
- BRep_Builder aBuilder;
- Standard_Boolean result = BRepTools::Read(aShape,aFileName,aBuilder);
- return result;
+ aShape.Nullify();
+
+ std::filebuf aFileBuf;
+ std::istream aStream (&aFileBuf);
+ if (!aFileBuf.open (aFileName, ios::in))
+ {
+ return Standard_False;
+ }
+
+ BRep_Builder aBuilder;
+ BRepTools::Read (aShape, aStream, aBuilder);
+ return !aShape.IsNull();
}
-void CImportExport::SaveBREP(const Handle_AIS_InteractiveContext& anInteractiveContext)
+void CImportExport::SaveBREP(const Handle(AIS_InteractiveContext)& anInteractiveContext)
{
anInteractiveContext->InitCurrent();
if (anInteractiveContext->NbCurrents() == 0){
- AfxMessageBox("No shape selected for export!");
+ AfxMessageBox (L"No shape selected for export!");
return;
}
Handle(TopTools_HSequenceOfShape) aHSequenceOfShape;
Standard_Boolean CImportExport::SaveBREP(const TopoDS_Shape& aShape)
{
- CFileDialog dlg(FALSE,_T("*.brep"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
- "BREP Files (*.brep)|*.brep;|BREP Files (*.BREP)|*.BREP;||", NULL );
+ CFileDialog dlg (FALSE, L"*.brep",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
+ L"BREP Files (*.brep)|*.brep;|BREP Files (*.BREP)|*.BREP;||", NULL);
-TCHAR tchBuf[80];
-
-CString CASROOTValue = ((GetEnvironmentVariable("CASROOT", tchBuf, 80) > 0) ? tchBuf : NULL);
-CString initdir = (CASROOTValue + "\\..\\data\\occ");
+CString SHAREPATHValue;
+SHAREPATHValue.GetEnvironmentVariable (L"CSF_OCCTDataPath");
+CString initdir = (SHAREPATHValue + "\\occ");
dlg.m_ofn.lpstrInitialDir = initdir;
{
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
CString filename = dlg.GetPathName();
- Standard_CString aFileName = (Standard_CString)(LPCTSTR)filename;
- result = SaveBREP(aFileName,aShape);
+ result = SaveBREP (filename, aShape);
if (!result)
- MessageBox(0,"Error : The shape or shapes were not saved.",
- "CasCade Error",MB_ICONERROR);
+ MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd,
+ L"Error : The shape or shapes were not saved.",
+ L"CasCade Error", MB_ICONERROR);
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
}
return result;
}
//----------------------------------------------------------------------------------------
-Standard_Boolean CImportExport::SaveBREP(const Standard_CString& aFileName,
- const TopoDS_Shape& aShape)
-{
- Standard_Boolean result = BRepTools::Write(aShape,aFileName);
- return result;
-}
-
-
-//======================================================================
-//= =
-//= CSFDB =
-//= =
-//======================================================================
-
-
-TCollection_AsciiString CImportExport::BuildStorageErrorMessage( Storage_Error anError)
-
-{
- TCollection_AsciiString aMessage("Storage Status :");
- switch ( anError ) {
- case Storage_VSOk :
- aMessage += "no problem \n";
- break;
- case Storage_VSOpenError :
- aMessage += "OpenError while opening the stream \n";
- break;
- case Storage_VSModeError :
- aMessage += "the stream is opened with a wrong mode for operation \n";
- break;
- case Storage_VSCloseError :
- aMessage += "CloseError while closing the stream \n";
- break;
- case Storage_VSAlreadyOpen :
- aMessage += "stream is already opened \n";
- break;
- case Storage_VSNotOpen :
- aMessage += "stream not opened \n";
- break;
- case Storage_VSSectionNotFound :
- aMessage += "the section is not found \n";
- break;
- case Storage_VSWriteError :
- aMessage += "error during writing \n";
- break;
- case Storage_VSFormatError :
- aMessage += "wrong format error occured while reading \n";
- break;
- case Storage_VSUnknownType :
- aMessage += "try to read an unknown type \n";
- break;
- case Storage_VSTypeMismatch :
- aMessage += "try to read a wrong primitive type (read a char while expecting a real) \n";
- break;
- case Storage_VSInternalError :
- aMessage += "internal error \n ";
- break;
- case Storage_VSExtCharParityError :
- aMessage += "problem with 16bit characters, may be an 8bit character is inserted inside a 16bit string \n";
- break;
- default :
- aMessage += "Unknown Status ";
- aMessage += anError;
- aMessage += " \n";
- break;
- }
- return aMessage;
-}
-
-void CImportExport::ReadCSFDB(const Handle(AIS_InteractiveContext)& anInteractiveContext)
-{
- Handle(TopTools_HSequenceOfShape) aSequence = CImportExport::ReadCSFDB();
- for(int i=1;i<= aSequence->Length();i++)
- anInteractiveContext->Display(new AIS_Shape(aSequence->Value(i)), Standard_False);
-}
-
-Handle(TopTools_HSequenceOfShape) CImportExport::ReadCSFDB() // not by reference --> the sequence is created here !!
+Standard_Boolean CImportExport::SaveBREP (CString aFileName,
+ const TopoDS_Shape& aShape)
{
- CFileDialog dlg(TRUE,
- NULL,
- NULL,
- OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
- "CSFDB Files (*.CSFDB , *.csf)|*.csfdb; *.csf; |All Files (*.*)|*.*||",
- NULL );
-
-TCHAR tchBuf[80];
-
-CString CASROOTValue = ((GetEnvironmentVariable("CASROOT", tchBuf, 80) > 0) ? tchBuf : NULL);
-CString initdir = (CASROOTValue + "\\..\\data\\csfdb");
-
-dlg.m_ofn.lpstrInitialDir = initdir;
-
- Handle(TopTools_HSequenceOfShape) aSequence = new TopTools_HSequenceOfShape();;
- if (dlg.DoModal() == IDOK)
+ std::filebuf aFileBuf;
+ std::ostream aStream (&aFileBuf);
+ if (!aFileBuf.open (aFileName, ios::out))
{
- SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
- CString filename = dlg.GetPathName();
- Standard_CString aFileName = (Standard_CString)(LPCTSTR)filename;
- TCollection_AsciiString Message;
- Standard_Boolean result = ReadCSFDB(aFileName,aSequence,Message);
- if (result)
- {
- // Display The Message :
- MessageBox(0,Message.ToCString(),"CasCade ",MB_OK);
-
-
- }
- else
- MessageBox(0,Message.ToCString(),"CasCade Error",MB_ICONERROR);
- SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
- }
- return aSequence;
-}
-
-Standard_Boolean CImportExport::ReadCSFDB(const Standard_CString& aFileName,
- Handle(TopTools_HSequenceOfShape)& aHSequenceOfShape, // out parameter
- TCollection_AsciiString& ReturnMessage) // out parameter
-{
- // an I/O driver
- FSD_File f;
-
- // the applicative Schema
- Handle(ShapeSchema) s = new ShapeSchema;
-
- // a Read/Write data object
- Handle(Storage_Data) d = new Storage_Data;
-
- d->ClearErrorStatus();
-
- // Check file type
- if ( FSD_File::IsGoodFileType( aFileName ) != Storage_VSOk) {
- ReturnMessage = "Bad file type for ";
- ReturnMessage += aFileName;
- ReturnMessage += " \n";
return Standard_False;
- }
-
- // Open the archive, Read mode
- Storage_Error err = f.Open(aFileName, Storage_VSRead);
- // Read all the persistent object in the file with the schema
- if ( err != Storage_VSOk ) {
- ReturnMessage += BuildStorageErrorMessage(d->ErrorStatus());
- return Standard_False;
- }
-
- d = s->Read( f );
- err = d->ErrorStatus() ;
-
- if ( err != Storage_VSOk ) {
- ReturnMessage += BuildStorageErrorMessage(d->ErrorStatus());
- return Standard_False;
- }
- // Close the file driver
- f.Close();
-
- ReturnMessage += "Application Name :"; ReturnMessage += d->ApplicationName();ReturnMessage += "\n";
- ReturnMessage += "Application Version :"; ReturnMessage += d->ApplicationVersion();ReturnMessage += "\n";
- ReturnMessage += "Data type :"; ReturnMessage += d->DataType();ReturnMessage += "\n";
- ReturnMessage += "== User Infos : ==\n";
- const TColStd_SequenceOfAsciiString& UserInfo = d->UserInfo();
- for (int i=1;i<=UserInfo.Length();i++)
- {ReturnMessage += UserInfo(i);ReturnMessage += "\n";}
- ReturnMessage += "== Comments : ==\n";
- const TColStd_SequenceOfExtendedString& Comments=d->Comments();
- for ( int i=1;i<=Comments.Length();i++)
- {ReturnMessage += Comments(i);ReturnMessage += "\n";}
- ReturnMessage += "----------------\n";
-
-
- // Read all the root objects
- // Get the root list
- Handle(Storage_HSeqOfRoot) roots = d->Roots();
- Handle(Standard_Persistent) p;
- Handle(Storage_Root) r;
- Handle(PTopoDS_HShape) aPShape;
- for ( int i = 1; i <= roots->Length() ; i++ )
- {
- // Get the root
- r = roots->Value(i);
-
- // Get the persistent application object from the root
- p = r->Object();
-
- // Display information
- ReturnMessage += "Persistent Object "; ReturnMessage += i; ReturnMessage += "\n";
- ReturnMessage += "Name :"; ReturnMessage += r->Name(); ReturnMessage += "\n";
- ReturnMessage += "Type :"; ReturnMessage += r->Type(); ReturnMessage += "\n";
-
- aPShape = Handle(PTopoDS_HShape)::DownCast(p);
-
- if ( !aPShape.IsNull() )
- {
- // To Be ReWriten to suppress the cout,
- // and provide a CallBack method for dynamic information.
- // Get the persistent shape
- PTColStd_PersistentTransientMap aMap;
- TopoDS_Shape aTShape;
- MgtBRep::Translate(aPShape,aMap,aTShape,
- MgtBRep_WithTriangle);
- aHSequenceOfShape->Append(aTShape);
- }
- else
- {
- ReturnMessage += "Error -> Unable to read\n";
- }
- }
- return Standard_True;
-}
-//----------------------------------------------------------------------
-void CImportExport::SaveCSFDB(const Handle(AIS_InteractiveContext)& anInteractiveContext)
-{
- anInteractiveContext->InitCurrent();
- if (anInteractiveContext->NbCurrents() == 0){
- AfxMessageBox("No shape selected for export!");
- return;
- }
- Handle(Quantity_HArray1OfColor) anArrayOfColors;
- Handle(TColStd_HArray1OfReal) anArrayOfTransparencies;
- CImportExport::SaveCSFDB(BuildSequenceFromContext(anInteractiveContext, anArrayOfColors, anArrayOfTransparencies));
-}
-
-Standard_Boolean CImportExport::SaveCSFDB(const Handle(TopTools_HSequenceOfShape)& aHSequenceOfShape)
-{
- Standard_Boolean result = Standard_False;
- CFileSaveCSFDBDialog aDlg(NULL);
- aDlg.m_TriangleMode = MgtBRep_WithTriangle;
- if (aDlg.DoModal() == IDOK)
- {
- SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
- CString filename = aDlg.GetPathName();
- Standard_CString aFileName = (Standard_CString)(LPCTSTR)filename;
- TCollection_AsciiString Message;
- //MgtBRep_TriangleMode selection = aDlg.m_TriangleMode;
- Standard_Boolean result = SaveCSFDB(aFileName,aHSequenceOfShape,Message);
- if (result)
- {
- // Display The Message :
- MessageBox(0,Message.ToCString(),"CasCade ",MB_OK);
- }
- else
- MessageBox(0,Message.ToCString(),"CasCade Error",MB_ICONERROR);
- SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
- }
- return result;
-}
-
-Standard_Boolean CImportExport::SaveCSFDB(const Standard_CString& aFileName,
- const Handle(TopTools_HSequenceOfShape)& aHSequenceOfShape,
- TCollection_AsciiString& ReturnMessage,// out parameter
- MgtBRep_TriangleMode /*aTriangleMode*/ /* = MgtBRep_WithTriangle */)
-{
- Standard_Boolean ReturnValue = Standard_True;
- if (aHSequenceOfShape->Length() == 0)
- {
- MessageBox(0,"No Shape in the HSequence!!","CasCade Warning",MB_ICONWARNING);
- return Standard_False;
- }
-
- // an I/O driver
- FSD_File f;
-
- // the applicative Schema containing
- // Pesistent Topology and Geometry
- Handle(ShapeSchema) s = new ShapeSchema;
-
- // a Read/Write data object
- Handle(Storage_Data) d = new Storage_Data;
-
- d->ClearErrorStatus();
-
- // To Be ReWriten to suppress the Strings,
- // and provide a CallBack method for dynamic information.
-
- d->SetApplicationName (TCollection_ExtendedString("SampleImportExport"));
- d->SetApplicationVersion("1");
- d->SetDataType(TCollection_ExtendedString("Shapes"));
- d->AddToUserInfo("Try to store a Persistent set of Shapes in a flat file");
- d->AddToComments(TCollection_ExtendedString("application is based on CasCade 2.0"));
-
- // Open the archive, Write mode
- Storage_Error err = f.Open(aFileName, Storage_VSWrite);
-
- if ( err != Storage_VSOk ) {
- ReturnMessage += BuildStorageErrorMessage(err);
- return Standard_False;
- }
-
- PTColStd_TransientPersistentMap aMap;
- ReturnMessage += "The Object have be saved in the file ";
- ReturnMessage += aFileName;
- ReturnMessage += "\n with the names : ";
-
- for (Standard_Integer i=1;i<=aHSequenceOfShape->Length();i++)
- {
- TopoDS_Shape aTShape= aHSequenceOfShape->Value(i);
- TCollection_AsciiString anObjectName("anObjectName_");
- anObjectName += i;
- ReturnMessage += anObjectName;
- ReturnMessage += " \n";
-
- if ( aTShape.IsNull() )
- {
- ReturnMessage += " Error : Invalid shape \n";
- ReturnValue = Standard_False;
- continue;
- }
-
- //Create the persistent Shape
-
- Handle(PTopoDS_HShape) aPShape =
- MgtBRep::Translate(aTShape, aMap, MgtBRep_WithTriangle);
-
-
- // Add the object in the data structure as root
- // To Be ReWriten to suppress the cout,
- // and provide a CallBack method for dynamic information.
- d->AddRoot(anObjectName, aPShape);
- }
-
- // Write the object in the file with the schema
- s->Write( f, d);
-
- // Close the driver
- f.Close();
+ }
- if ( d->ErrorStatus() != Storage_VSOk )
- {
- ReturnMessage += BuildStorageErrorMessage(d->ErrorStatus());
- return Standard_False;
- }
- return ReturnValue;
+ BRepTools::Write (aShape, aStream);
+ return Standard_True;
}
-
//======================================================================
//= =
//= IGES =
NULL,
NULL,
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
- "IGES Files (*.iges , *.igs)|*.iges; *.igs|All Files (*.*)|*.*||",
+ L"IGES Files (*.iges , *.igs)|*.iges; *.igs|All Files (*.*)|*.*||",
NULL );
-TCHAR tchBuf[80];
-
-CString CASROOTValue = ((GetEnvironmentVariable("CASROOT", tchBuf, 80) > 0) ? tchBuf : NULL);
-CString initdir = (CASROOTValue + "\\..\\data\\iges");
+CString SHAREPATHValue;
+SHAREPATHValue.GetEnvironmentVariable (L"CSF_OCCTDataPath");
+CString initdir = (SHAREPATHValue + "\\iges");
dlg.m_ofn.lpstrInitialDir = initdir;
if (dlg.DoModal() == IDOK)
{
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
- CString C = dlg.GetPathName();
- Standard_CString aFileName = (Standard_CString)(LPCTSTR)C;
- Standard_Integer status = ReadIGES(aFileName,aSequence);
- if (status != IFSelect_RetDone)
+ TCollection_ExtendedString aFileNameW ((Standard_ExtString )(const wchar_t* )dlg.GetPathName());
+ TCollection_AsciiString aFileName (aFileNameW, '?');
+ Standard_Integer status = ReadIGES (aFileName.ToCString(), aSequence);
+ if (status != IFSelect_RetDone)
{
- MessageBox(0,"Error : The file is not read","CasCade Error",MB_ICONERROR);
- }
-
+ MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"Error : The file is not read", L"CasCade Error", MB_ICONERROR);
+ }
+
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
}
return aSequence;
{
anInteractiveContext->InitCurrent();
if (anInteractiveContext->NbCurrents() == 0){
- AfxMessageBox("No shape selected for export!");
+ AfxMessageBox (L"No shape selected for export!");
return;
}
Handle(Quantity_HArray1OfColor) anArrayOfColors;
{
if (aHSequenceOfShape->Length() == 0)
{
- MessageBox(0,"No Shape in the HSequence!!","CasCade Warning",MB_ICONWARNING);
+ MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"No Shape in the HSequence!!", L"CasCade Warning", MB_ICONWARNING);
return Standard_False;
}
- CFileDialog dlg(FALSE,_T("*.iges"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
- "IGES Files (*.iges )|*.iges;|IGES Files (*.igs )| *.igs;||", NULL );
+ CFileDialog dlg(FALSE, L"*.iges",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
+ L"IGES Files (*.iges )|*.iges;|IGES Files (*.igs )| *.igs;||", NULL);
-TCHAR tchBuf[80];
-
-CString CASROOTValue = ((GetEnvironmentVariable("CASROOT", tchBuf, 80) > 0) ? tchBuf : NULL);
-CString initdir = (CASROOTValue + "\\..\\data\\iges");
+CString SHAREPATHValue;
+SHAREPATHValue.GetEnvironmentVariable (L"CSF_OCCTDataPath");
+CString initdir = (SHAREPATHValue + "\\iges");
dlg.m_ofn.lpstrInitialDir = initdir;
if (dlg.DoModal() == IDOK)
{
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
- CString C = dlg.GetPathName();
- Standard_CString aFileName = (Standard_CString)(LPCTSTR)C;
+ TCollection_ExtendedString aFileNameW ((Standard_ExtString )(const wchar_t* )dlg.GetPathName());
+ TCollection_AsciiString aFileName (aFileNameW, '?');
- result = SaveIGES(aFileName,aHSequenceOfShape);
+ result = SaveIGES (aFileName.ToCString(), aHSequenceOfShape);
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
}
return result;
NULL,
NULL,
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
- "STEP Files (*.stp;*.step)|*.stp; *.step|All Files (*.*)|*.*||",
+ L"STEP Files (*.stp;*.step)|*.stp; *.step|All Files (*.*)|*.*||",
NULL );
-TCHAR tchBuf[80];
-
-CString CASROOTValue = ((GetEnvironmentVariable("CASROOT", tchBuf, 80) > 0) ? tchBuf : NULL);
-CString initdir = (CASROOTValue + "\\..\\data\\step");
+CString SHAREPATHValue;
+SHAREPATHValue.GetEnvironmentVariable (L"CSF_OCCTDataPath");
+CString initdir = (SHAREPATHValue + "\\step");
dlg.m_ofn.lpstrInitialDir = initdir;
if (dlg.DoModal() == IDOK)
{
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
- CString C = dlg.GetPathName();
- Standard_CString aFileName = (Standard_CString)(LPCTSTR)C;
- IFSelect_ReturnStatus ReturnStatus = ReadSTEP(aFileName,aSequence);
+ TCollection_ExtendedString aFileNameW ((Standard_ExtString )(const wchar_t* )dlg.GetPathName());
+ TCollection_AsciiString aFileName (aFileNameW, '?');
+ IFSelect_ReturnStatus ReturnStatus = ReadSTEP (aFileName.ToCString(), aSequence);
switch (ReturnStatus)
{
case IFSelect_RetError :
- MessageBox(0,"Not a valid Step file","ERROR",MB_ICONWARNING);
+ MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"Not a valid Step file", L"ERROR", MB_ICONWARNING);
break;
case IFSelect_RetFail :
- MessageBox(0,"Reading has failed","ERROR",MB_ICONWARNING);
+ MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"Reading has failed", L"ERROR", MB_ICONWARNING);
break;
case IFSelect_RetVoid :
- MessageBox(0,"Nothing to transfer","ERROR",MB_ICONWARNING);
+ MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"Nothing to transfer", L"ERROR", MB_ICONWARNING);
break;
}
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
if (status != IFSelect_RetDone)
return status;
- aReader.WS()->MapReader()->SetTraceLevel(2); // increase default trace level
+ aReader.WS()->TransferReader()->TransientProcess()->SetTraceLevel(2); // increase default trace level
Standard_Boolean failsonly = Standard_False;
aReader.PrintCheckLoad(failsonly, IFSelect_ItemsByEntity);
{
anInteractiveContext->InitCurrent();
if (anInteractiveContext->NbCurrents() == 0){
- AfxMessageBox("No shape selected for export!");
+ AfxMessageBox (L"No shape selected for export!");
return;
}
Handle(Quantity_HArray1OfColor) anArrayOfColors;
{
if (aHSequenceOfShape->Length() == 0)
{
- MessageBox(0,"No Shape in the HSequence!!","CasCade Warning",MB_ICONWARNING);
+ MessageBox (AfxGetApp()->m_pMainWnd->m_hWnd, L"No Shape in the HSequence!!", L"CasCade Warning", MB_ICONWARNING);
return IFSelect_RetError;
}
CFileSaveSTEPDialog aDlg(NULL);
- aDlg.m_Cc1ModelType = STEPControl_ManifoldSolidBrep;
+ aDlg.m_Cc1ModelType = STEPControl_AsIs;
if (aDlg.DoModal() == IDOK) {
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
- CString C = aDlg.GetPathName();
- Standard_CString aFileName = (Standard_CString)(LPCTSTR)C;
+ TCollection_ExtendedString aFileNameW ((Standard_ExtString )(const wchar_t* )aDlg.GetPathName());
+ TCollection_AsciiString aFileName (aFileNameW, '?');
STEPControl_StepModelType selection = aDlg.m_Cc1ModelType;
if (!TestFacetedBrep(aHSequenceOfShape))
{
- MessageBox(0,"At least one shape doesn't contain facetes","CasCade Warning",MB_ICONWARNING);
+ MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"At least one shape doesn't contain facetes", L"CasCade Warning", MB_ICONWARNING);
return IFSelect_RetError;
}
- status = SaveSTEP(aFileName,aHSequenceOfShape,selection);
+ status = SaveSTEP (aFileName.ToCString(), aHSequenceOfShape, selection);
switch (status)
{
case IFSelect_RetError:
- MessageBox(0,"Incorrect Data","ERROR",MB_ICONWARNING);
+ MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"Incorrect Data", L"ERROR", MB_ICONWARNING);
break;
case IFSelect_RetFail:
- MessageBox(0,"Writing has failed","ERROR",MB_ICONWARNING);
+ MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"Writing has failed", L"ERROR", MB_ICONWARNING);
break;
case IFSelect_RetVoid:
- MessageBox(0,"Nothing to transfer","ERROR",MB_ICONWARNING);
+ MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"Nothing to transfer", L"ERROR", MB_ICONWARNING);
break;
}
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
{
anInteractiveContext->InitCurrent();
if (anInteractiveContext->NbCurrents() == 0){
- AfxMessageBox("No shape selected for export!");
+ AfxMessageBox (L"No shape selected for export!");
return;
}
Handle(Quantity_HArray1OfColor) anArrayOfColors;
Standard_Boolean CImportExport::SaveSTL(const Handle(TopTools_HSequenceOfShape)& aHSequenceOfShape)
{
- CFileDialog dlg(FALSE,_T("*.stl"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
- "stl Files (*.stl)|*.stl;|STL Files (*.STL)|*.STL;||", NULL );
+ CFileDialog dlg(FALSE, L"*.stl", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
+ L"stl Files (*.stl)|*.stl;|STL Files (*.STL)|*.STL;||", NULL);
-TCHAR tchBuf[80];
-
-CString CASROOTValue = ((GetEnvironmentVariable("CASROOT", tchBuf, 80) > 0) ? tchBuf : NULL);
-CString initdir = (CASROOTValue + "\\..\\data\\stl");
+CString SHAREPATHValue;
+SHAREPATHValue.GetEnvironmentVariable (L"CSF_OCCTDataPath");
+CString initdir = (SHAREPATHValue + "\\stl");
dlg.m_ofn.lpstrInitialDir = initdir;
- Standard_Boolean result;
+ Standard_Boolean result = Standard_False;
if (dlg.DoModal() == IDOK) {
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
- CString C = dlg.GetPathName();
- Standard_CString aFileName = (Standard_CString)(LPCTSTR)C;
+ TCollection_ExtendedString aFileNameW ((Standard_ExtString )(const wchar_t* )dlg.GetPathName());
+ TCollection_AsciiString aFileName (aFileNameW, '?');
TCollection_AsciiString Message;
- result = SaveSTL(aFileName,aHSequenceOfShape,Message);
- if (result)
- {
- // Display The Message :
- MessageBox(0,Message.ToCString(),"CasCade ",MB_OK);
- }
- else
- MessageBox(0,Message.ToCString(),"CasCade Error",MB_ICONERROR);
+ result = SaveSTL (aFileName.ToCString(), aHSequenceOfShape, Message);
+ CString aMsg (Message.ToCString());
+ MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, aMsg, result ? L"CasCade" : L"CasCade Error", result ? MB_OK : MB_ICONERROR);
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
}
return result;
Standard_Boolean ReturnValue = Standard_True;
if (aHSequenceOfShape->Length() == 0)
{
- MessageBox(0,"No Shape in the HSequence!!","CasCade Warning",MB_ICONWARNING);
+ MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"No Shape in the HSequence!!", L"CasCade Warning", MB_ICONWARNING);
return Standard_False;
}
- PTColStd_TransientPersistentMap aMap;
ReturnMessage += "The Object have be saved in the file ";
ReturnMessage += aFileName;
ReturnMessage += "\n with the names : ";
{
anInteractiveContext->InitCurrent();
if (anInteractiveContext->NbCurrents() == 0){
- AfxMessageBox("No shape selected for export!");
+ AfxMessageBox (L"No shape selected for export!");
return;
}
Handle(Quantity_HArray1OfColor) anArrayOfColors;
const Handle(Quantity_HArray1OfColor)& anArrayOfColors,
const Handle(TColStd_HArray1OfReal)& anArrayOfTransparencies)
{
- CFileDialog dlg(FALSE,_T("*.vrml"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
- "vrml Files (*.vrml)|*.vrml;|vrm Files (*.vrm)|*.vrm;||", NULL );
-
-TCHAR tchBuf[80];
+ CFileDialog dlg(FALSE, L"*.vrml", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
+ L"vrml Files (*.vrml)|*.vrml;|vrm Files (*.vrm)|*.vrm;||", NULL);
-CString CASROOTValue = ((GetEnvironmentVariable("CASROOT", tchBuf, 80) > 0) ? tchBuf : NULL);
-CString initdir = (CASROOTValue + "\\..\\data\\vrml");
+CString SHAREPATHValue;
+SHAREPATHValue.GetEnvironmentVariable (L"CSF_OCCTDataPath");
+CString initdir = (SHAREPATHValue + "\\vrml");
dlg.m_ofn.lpstrInitialDir = initdir;
- Standard_Boolean result;
+ Standard_Boolean result = Standard_False;
if (dlg.DoModal() == IDOK) {
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
- CString C = dlg.GetPathName();
- Standard_CString aFileName = (Standard_CString)(LPCTSTR)C;
+ TCollection_ExtendedString aFileNameW ((Standard_ExtString )(const wchar_t* )dlg.GetPathName());
+ TCollection_AsciiString aFileName (aFileNameW, '?');
TCollection_AsciiString Message;
- result = SaveVRML(aFileName,aHSequenceOfShape,anArrayOfColors, anArrayOfTransparencies, Message);
- if (result)
- {
- // Display The Message :
- MessageBox(0,Message.ToCString(),"CasCade ",MB_OK);
- }
- else
- MessageBox(0,Message.ToCString(),"CasCade Error",MB_ICONERROR);
+ result = SaveVRML (aFileName.ToCString(), aHSequenceOfShape, anArrayOfColors, anArrayOfTransparencies, Message);
+ CString aMsg (Message.ToCString());
+ MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, aMsg, result ? L"CasCade" : L"CasCade Error", result ? MB_OK : MB_ICONERROR);
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
}
return result;
Standard_Boolean ReturnValue = Standard_True;
if (aHSequenceOfShape->Length() == 0)
{
- MessageBox(0,"No Shape in the HSequence!!","CasCade Warning",MB_ICONWARNING);
+ MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"No Shape in the HSequence!!", L"CasCade Warning", MB_ICONWARNING);
return Standard_False;
}
- PTColStd_TransientPersistentMap aMap;
ReturnMessage += "The Object has been saved in the file ";
ReturnMessage += aFileName;
ReturnMessage += "\n with the names : ";
VrmlData_ShapeConvert converter(scene/*, 0.001*/); // from mm to meters
Standard_Integer iShape = 1; // Counter of shapes
- for ( int i = 1; i <= aHSequenceOfShape->Length(); i++ )
- {
+ for (int i = 1; i <= aHSequenceOfShape->Length(); i++)
+ {
// Shape
- TopoDS_Shape shape = aHSequenceOfShape->Value( i );
- if ( shape.IsNull() )
- {
- ReturnMessage += " Error : Invalid shape \n";
- ReturnValue = Standard_False;
- continue;
+ TopoDS_Shape shape = aHSequenceOfShape->Value(i);
+ if (shape.IsNull())
+ {
+ ReturnMessage += " Error : Invalid shape \n";
+ ReturnValue = Standard_False;
+ continue;
}
// Color
Handle(VrmlData_Node) node = itr.Value();
if (node->DynamicType() == STANDARD_TYPE(VrmlData_ShapeNode))
{
- Handle(VrmlData_ShapeNode) shape = Handle(VrmlData_ShapeNode)::DownCast(node);
- shape->SetAppearance(appearance);
+ Handle(VrmlData_ShapeNode) aShape = Handle(VrmlData_ShapeNode)::DownCast(node);
+ aShape->SetAppearance(appearance);
}
else if (itr.Value()->DynamicType() == STANDARD_TYPE(VrmlData_Group))
{